Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

View File

@ -0,0 +1,67 @@
#include <kinc/graphics4/graphics.h>
#include <kinc/graphics4/rendertarget.h>
#include <kinc/graphics5/graphics.h>
#include <kinc/graphics5/pipeline.h>
#include <kinc/math/core.h>
// extern kinc_g5_pipeline_t *currentProgram;
void kinc_g5_internal_destroy_window(int window) {
kinc_g4_internal_destroy_window(window);
}
void kinc_g5_internal_destroy() {
kinc_g4_internal_destroy();
}
void kinc_g5_internal_init() {
kinc_g4_internal_init();
}
void kinc_g5_internal_init_window(int window, int depthBufferBits, int stencilBufferBits, bool vsync) {
kinc_g4_internal_init_window(window, depthBufferBits, stencilBufferBits, vsync);
}
// void kinc_g5_draw_indexed_vertices_instanced(int instanceCount) {}
// void kinc_g5_draw_indexed_vertices_instanced_from_to(int instanceCount, int start, int count) {}
// void kinc_g5_draw_indexed_vertices_instanced_from_to_from(int instanceCount, int start, int count, int vertex_offset) {}
void kinc_g5_begin(kinc_g5_render_target_t *renderTarget, int window) {}
void kinc_g5_end(int window) {}
bool kinc_g5_swap_buffers() {
return kinc_g4_swap_buffers();
}
void kinc_g5_flush() {}
int kinc_g5_max_bound_textures(void) {
return kinc_g4_max_bound_textures();
}
bool kinc_g5_supports_raytracing() {
return false;
}
bool kinc_g5_supports_instanced_rendering() {
return kinc_g4_supports_instanced_rendering();
}
bool kinc_g5_supports_compute_shaders() {
return kinc_g4_supports_compute_shaders();
}
bool kinc_g5_supports_blend_constants() {
return kinc_g4_supports_blend_constants();
}
bool kinc_g5_supports_non_pow2_textures() {
return kinc_g4_supports_non_pow2_textures();
}
bool kinc_g5_render_targets_inverted_y() {
return kinc_g4_render_targets_inverted_y();
}

View File

@ -0,0 +1,4 @@
#pragma once
#include <kinc/graphics5/graphics.h>
#include <kinc/math/matrix.h>

View File

@ -0,0 +1,402 @@
#include <kinc/graphics4/graphics.h>
#include <kinc/graphics5/commandlist.h>
#include <kinc/graphics5/constantbuffer.h>
#include <kinc/graphics5/indexbuffer.h>
#include <kinc/graphics5/pipeline.h>
#include <kinc/graphics5/vertexbuffer.h>
#include <kinc/log.h>
#include <assert.h>
#include <string.h>
#ifdef KINC_MICROSOFT
#include <malloc.h>
#endif
#define WRITE(type, value) \
if (list->impl.commandIndex + sizeof(type) > KINC_G5ONG4_COMMANDS_SIZE) { \
kinc_log(KINC_LOG_LEVEL_ERROR, "Trying to write too many commands to the command list."); \
return; \
} \
*(type *)(&list->impl.commands[list->impl.commandIndex]) = value; \
list->impl.commandIndex += sizeof(type);
#define READ(type, var) \
if (index + sizeof(type) > KINC_G5ONG4_COMMANDS_SIZE) { \
kinc_log(KINC_LOG_LEVEL_ERROR, "Trying to read beyond the end of the command list?"); \
return; \
} \
type var = *(type *)(&list->impl.commands[index]); \
index += sizeof(type);
typedef enum command {
Clear,
Draw,
SetViewport,
SetScissor,
SetPipeline,
SetVertexBuffers,
SetIndexBuffer,
SetRenderTargets,
SetRenderTargetFace,
DrawInstanced,
SetSampler,
SetTexture,
SetImageTexture,
SetTextureFromRenderTarget,
SetTextureFromRenderTargetDepth,
SetVertexConstantBuffer,
SetFragmentConstantBuffer,
SetBlendConstant,
} command_t;
void kinc_g4_pipeline_get_constant_locations(kinc_g4_pipeline_t *state, kinc_g4_constant_location_t *vertex_locations,
kinc_g4_constant_location_t *fragment_locations, int *vertex_sizes, int *fragment_sizes, int *max_vertex,
int *max_fragment);
void kinc_g5_command_list_init(kinc_g5_command_list_t *list) {}
void kinc_g5_command_list_destroy(kinc_g5_command_list_t *list) {}
void kinc_g5_command_list_begin(kinc_g5_command_list_t *list) {
list->impl.commandIndex = 0;
}
void kinc_g5_command_list_end(kinc_g5_command_list_t *list) {}
void kinc_g5_command_list_clear(kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget, unsigned flags, unsigned color, float depth,
int stencil) {
WRITE(command_t, Clear);
WRITE(unsigned, flags);
WRITE(unsigned, color);
WRITE(float, depth);
WRITE(int, stencil);
}
void kinc_g5_command_list_render_target_to_framebuffer_barrier(kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget) {}
void kinc_g5_command_list_framebuffer_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget) {}
void kinc_g5_command_list_texture_to_render_target_barrier(kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget) {}
void kinc_g5_command_list_render_target_to_texture_barrier(kinc_g5_command_list_t *list, struct kinc_g5_render_target *renderTarget) {}
void kinc_g5_command_list_draw_indexed_vertices(kinc_g5_command_list_t *list) {
kinc_g5_command_list_draw_indexed_vertices_from_to(list, 0, list->impl._indexCount);
}
void kinc_g5_command_list_draw_indexed_vertices_from_to(kinc_g5_command_list_t *list, int start, int count) {
WRITE(command_t, Draw);
WRITE(int, start);
WRITE(int, count);
}
void kinc_g5_command_list_draw_indexed_vertices_instanced(kinc_g5_command_list_t *list, int instanceCount) {
kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(list, instanceCount, 0, list->impl._indexCount);
}
void kinc_g5_command_list_draw_indexed_vertices_instanced_from_to(kinc_g5_command_list_t *list, int instanceCount, int start, int count) {
WRITE(command_t, DrawInstanced);
WRITE(int, instanceCount);
WRITE(int, start);
WRITE(int, count);
}
void kinc_g5_command_list_viewport(kinc_g5_command_list_t *list, int x, int y, int width, int height) {
WRITE(command_t, SetViewport);
WRITE(int, x);
WRITE(int, y);
WRITE(int, width);
WRITE(int, height);
}
void kinc_g5_command_list_scissor(kinc_g5_command_list_t *list, int x, int y, int width, int height) {
WRITE(command_t, SetScissor);
WRITE(int, x);
WRITE(int, y);
WRITE(int, width);
WRITE(int, height);
}
void kinc_g5_command_list_disable_scissor(kinc_g5_command_list_t *list) {}
void kinc_g5_command_list_set_pipeline(kinc_g5_command_list_t *list, struct kinc_g5_pipeline *pipeline) {
WRITE(command_t, SetPipeline);
WRITE(kinc_g5_pipeline_t *, pipeline);
}
void kinc_g5_command_list_set_blend_constant(kinc_g5_command_list_t *list, float r, float g, float b, float a) {
WRITE(command_t, SetBlendConstant);
WRITE(float, r);
WRITE(float, g);
WRITE(float, b);
WRITE(float, a);
}
void kinc_g5_command_list_set_vertex_buffers(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer **buffers, int *offsets, int count) {
WRITE(command_t, SetVertexBuffers);
WRITE(int, count);
for (int i = 0; i < count; ++i) {
WRITE(kinc_g5_vertex_buffer_t *, buffers[i]);
if (offsets[i] != 0) {
kinc_log(KINC_LOG_LEVEL_ERROR, "kinc_g5_command_list_set_vertex_buffers: offsets not supported");
}
}
}
void kinc_g5_command_list_set_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) {
WRITE(command_t, SetIndexBuffer);
WRITE(kinc_g5_index_buffer_t *, buffer);
list->impl._indexCount = buffer->impl.myCount;
}
void kinc_g5_command_list_set_render_targets(kinc_g5_command_list_t *list, struct kinc_g5_render_target **targets, int count) {
WRITE(command_t, SetRenderTargets);
WRITE(int, count);
for (int i = 0; i < count; ++i) {
WRITE(kinc_g5_render_target_t *, targets[i]);
}
}
void kinc_g5_command_list_upload_index_buffer(kinc_g5_command_list_t *list, struct kinc_g5_index_buffer *buffer) {}
void kinc_g5_command_list_upload_vertex_buffer(kinc_g5_command_list_t *list, struct kinc_g5_vertex_buffer *buffer) {}
void kinc_g5_command_list_upload_texture(kinc_g5_command_list_t *list, struct kinc_g5_texture *texture) {}
void kinc_g5_command_list_set_vertex_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) {
WRITE(command_t, SetVertexConstantBuffer);
WRITE(kinc_g5_constant_buffer_t *, buffer);
}
void kinc_g5_command_list_set_fragment_constant_buffer(kinc_g5_command_list_t *list, struct kinc_g5_constant_buffer *buffer, int offset, size_t size) {
WRITE(command_t, SetFragmentConstantBuffer);
WRITE(kinc_g5_constant_buffer_t *, buffer);
}
void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) {
kinc_g5_pipeline_t *current_pipeline = NULL;
int index = 0;
while (index < list->impl.commandIndex) {
READ(command_t, command);
switch (command) {
case Clear: {
READ(unsigned, flags);
READ(unsigned, color);
READ(float, depth);
READ(int, stencil);
kinc_g4_clear(flags, color, depth, stencil);
break;
}
case Draw: {
READ(int, start);
READ(int, count);
kinc_g4_draw_indexed_vertices_from_to(start, count);
break;
}
case SetViewport: {
READ(int, x);
READ(int, y);
READ(int, width);
READ(int, height);
kinc_g4_viewport(x, y, width, height);
break;
}
case SetScissor: {
READ(int, x);
READ(int, y);
READ(int, width);
READ(int, height);
kinc_g4_scissor(x, y, width, height);
break;
}
case SetPipeline: {
READ(kinc_g5_pipeline_t *, pipeline);
current_pipeline = pipeline;
kinc_g4_set_pipeline(&pipeline->impl.pipe);
break;
}
case SetVertexBuffers: {
READ(int, count);
#ifdef KINC_MICROSOFT
kinc_g4_vertex_buffer_t **buffers = (kinc_g4_vertex_buffer_t **)alloca(sizeof(kinc_g4_vertex_buffer_t *) * count);
#else
kinc_g4_vertex_buffer_t *buffers[count];
#endif
for (int i = 0; i < count; ++i) {
READ(kinc_g5_vertex_buffer_t *, buffer);
buffers[i] = &buffer->impl.buffer;
}
kinc_g4_set_vertex_buffers(buffers, count);
break;
}
case SetIndexBuffer: {
READ(kinc_g5_index_buffer_t *, buffer);
kinc_g4_set_index_buffer(&buffer->impl.buffer);
break;
}
case SetRenderTargets: {
READ(int, count);
#ifdef KINC_MICROSOFT
kinc_g4_render_target_t **buffers = (kinc_g4_render_target_t **)alloca(sizeof(kinc_g4_render_target_t *) * count);
#else
kinc_g4_render_target_t *buffers[count];
#endif
int first_framebuffer_index = -1;
for (int i = 0; i < count; ++i) {
READ(kinc_g5_render_target_t *, buffer);
if (i == 0) {
first_framebuffer_index = buffer->framebuffer_index;
}
buffers[i] = &buffer->impl.target;
}
if (first_framebuffer_index >= 0) {
if (count > 1) {
kinc_log(KINC_LOG_LEVEL_ERROR, "Rendering to backbuffer and render targets at the same time is not supported");
}
kinc_g4_restore_render_target();
}
else {
kinc_g4_set_render_targets(buffers, count);
}
break;
}
case SetRenderTargetFace: {
READ(kinc_g5_render_target_t *, target);
READ(int, face);
kinc_g4_set_render_target_face(&target->impl.target, face);
break;
}
case DrawInstanced: {
READ(int, instanceCount);
READ(int, start);
READ(int, count);
kinc_g4_draw_indexed_vertices_instanced_from_to(instanceCount, start, count);
break;
}
case SetSampler: {
assert(false);
// TODO
break;
}
case SetTexture: {
READ(kinc_g5_texture_unit_t, unit);
READ(kinc_g5_texture_t *, texture);
assert(KINC_G4_SHADER_TYPE_COUNT == KINC_G5_SHADER_TYPE_COUNT);
kinc_g4_texture_unit_t g4_unit;
memcpy(&g4_unit.stages[0], &unit.stages[0], KINC_G4_SHADER_TYPE_COUNT * sizeof(int));
#ifdef KINC_KONG
kinc_g4_set_texture(g4_unit.stages[0], &texture->impl.texture);
#else
kinc_g4_set_texture(g4_unit, &texture->impl.texture);
#endif
break;
}
case SetImageTexture: {
READ(kinc_g5_texture_unit_t, unit);
READ(kinc_g5_texture_t *, texture);
assert(KINC_G4_SHADER_TYPE_COUNT == KINC_G5_SHADER_TYPE_COUNT);
kinc_g4_texture_unit_t g4_unit;
memcpy(&g4_unit.stages[0], &unit.stages[0], KINC_G4_SHADER_TYPE_COUNT * sizeof(int));
kinc_g4_set_image_texture(g4_unit, &texture->impl.texture);
break;
}
case SetTextureFromRenderTarget: {
assert(false);
// TODO
break;
}
case SetTextureFromRenderTargetDepth: {
assert(false);
// TODO
break;
}
case SetVertexConstantBuffer: {
READ(kinc_g5_constant_buffer_t *, buffer);
(void)buffer;
(void)current_pipeline;
kinc_log(KINC_LOG_LEVEL_ERROR, "Constant buffers are not supported on G5onG4 at the moment.");
// if(current_pipeline == NULL) {
// kinc_log(KINC_LOG_LEVEL_ERROR, "Please set the pipeline before setting constant buffers.");
// } else {
// kinc_g4_constant_location_t *constant_locations = current_pipeline->impl.pipe.vertex_locations;
// int *sizes = current_pipeline->impl.pipe.vertex_sizes;
// char *data = buffer->data;
// for(int i = 0; i < current_pipeline->impl.pipe.vertex_count; ++i) {
// // kinc_g4_set
// // kinc_g4_set_vertex_constant_buffer(constant_locations[i], sizes[i], data);
// data += sizes[i];
// }
// }
break;
}
case SetFragmentConstantBuffer: {
READ(kinc_g5_constant_buffer_t *, buffer);
(void)buffer;
kinc_log(KINC_LOG_LEVEL_ERROR, "Constant buffers are not supported on G5onG4 at the moment.");
break;
}
case SetBlendConstant: {
READ(float, r);
READ(float, g);
READ(float, b);
READ(float, a);
kinc_g4_set_blend_constant(r, g, b, a);
}
default:
kinc_log(KINC_LOG_LEVEL_ERROR, "Unknown command %i\n", command);
return;
}
}
}
void kinc_g5_command_list_wait_for_execution_to_finish(kinc_g5_command_list_t *list) {
kinc_g4_flush();
}
void kinc_g5_command_list_get_render_target_pixels(kinc_g5_command_list_t *list, struct kinc_g5_render_target *render_target, uint8_t *data) {
kinc_log(KINC_LOG_LEVEL_ERROR, "kinc_g5_command_list_get_render_target_pixels not implemented");
}
void kinc_g5_command_list_set_render_target_face(kinc_g5_command_list_t *list, kinc_g5_render_target_t *texture, int face) {
WRITE(command_t, SetRenderTargetFace);
WRITE(kinc_g5_render_target_t *, texture);
WRITE(int, face);
}
void kinc_g5_command_list_set_texture(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture) {
WRITE(command_t, SetTexture);
WRITE(kinc_g5_texture_unit_t, unit);
WRITE(kinc_g5_texture_t *, texture);
}
void kinc_g5_command_list_set_sampler(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_sampler_t *sampler) {
WRITE(command_t, SetSampler);
}
void kinc_g5_command_list_set_texture_from_render_target(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_render_target_t *render_target) {
WRITE(command_t, SetTextureFromRenderTarget);
}
void kinc_g5_command_list_set_texture_from_render_target_depth(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit,
kinc_g5_render_target_t *render_target) {
WRITE(command_t, SetTextureFromRenderTargetDepth);
}
void kinc_g5_command_list_set_image_texture(kinc_g5_command_list_t *list, kinc_g5_texture_unit_t unit, kinc_g5_texture_t *texture) {
WRITE(command_t, SetImageTexture);
WRITE(kinc_g5_texture_unit_t, unit);
WRITE(kinc_g5_texture_t *, texture);
}
bool kinc_g5_command_list_init_occlusion_query(kinc_g5_command_list_t *list, unsigned *occlusionQuery) {
return false;
}
void kinc_g5_command_list_delete_occlusion_query(kinc_g5_command_list_t *list, unsigned occlusionQuery) {}
void kinc_g5_command_list_render_occlusion_query(kinc_g5_command_list_t *list, unsigned occlusionQuery, int triangles) {}
bool kinc_g5_command_list_are_query_results_available(kinc_g5_command_list_t *list, unsigned occlusionQuery) {
return false;
}
void kinc_g5_command_list_get_query_result(kinc_g5_command_list_t *list, unsigned occlusionQuery, unsigned *pixelCount) {}
void kinc_g5_command_list_set_compute_shader(kinc_g5_command_list_t *list, struct kinc_g5_compute_shader *shader) {}
void kinc_g5_command_list_compute(kinc_g5_command_list_t *list, int x, int y, int z) {}

View File

@ -0,0 +1,21 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct kinc_g5_pipeline;
#define KINC_G5ONG4_COMMANDS_SIZE 1024
typedef struct {
struct kinc_g5_pipeline *_currentPipeline;
int _indexCount;
char commands[KINC_G5ONG4_COMMANDS_SIZE];
int commandIndex;
bool closed;
} CommandList5Impl;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,30 @@
#include <kinc/graphics5/compute.h>
#include <kinc/math/core.h>
#include <assert.h>
void kinc_g5_compute_shader_init(kinc_g5_compute_shader *shader, void *source, int length) {
kinc_g4_compute_shader_init(&shader->impl.g4, source, length);
}
void kinc_g5_compute_shader_destroy(kinc_g5_compute_shader *shader) {
kinc_g4_compute_shader_destroy(&shader->impl.g4);
}
#ifndef KINC_KONG
kinc_g5_constant_location_t kinc_g5_compute_shader_get_constant_location(kinc_g5_compute_shader *shader, const char *name) {
kinc_g5_constant_location_t location = {0};
location.impl.location = kinc_g4_compute_shader_get_constant_location(&shader->impl.g4, name);
return location;
}
kinc_g5_texture_unit_t kinc_g5_compute_shader_get_texture_unit(kinc_g5_compute_shader *shader, const char *name) {
kinc_g5_texture_unit_t g5_unit = {0};
kinc_g4_texture_unit_t g4_unit = kinc_g4_compute_shader_get_texture_unit(&shader->impl.g4, name);
assert(KINC_G4_SHADER_TYPE_COUNT == KINC_G5_SHADER_TYPE_COUNT);
for (int i = 0; i < KINC_G4_SHADER_TYPE_COUNT; ++i) {
g5_unit.stages[i] = g4_unit.stages[i];
}
return g5_unit;
}
#endif

View File

@ -0,0 +1,7 @@
#pragma once
#include <kinc/graphics4/compute.h>
typedef struct kinc_g5_compute_shader_impl {
kinc_g4_compute_shader g4;
} kinc_g5_compute_shader_impl;

View File

@ -0,0 +1,33 @@
#include <kinc/graphics5/constantbuffer.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
bool kinc_g5_transposeMat3 = false;
bool kinc_g5_transposeMat4 = false;
void kinc_g5_constant_buffer_init(kinc_g5_constant_buffer_t *buffer, int size) {
buffer->impl.mySize = size;
buffer->data = malloc(size);
}
void kinc_g5_constant_buffer_destroy(kinc_g5_constant_buffer_t *buffer) {
free(buffer->data);
}
void kinc_g5_constant_buffer_lock_all(kinc_g5_constant_buffer_t *buffer) {}
void kinc_g5_constant_buffer_lock(kinc_g5_constant_buffer_t *buffer, int start, int count) {}
void kinc_g5_constant_buffer_unlock(kinc_g5_constant_buffer_t *buffer) {}
int kinc_g5_constant_buffer_size(kinc_g5_constant_buffer_t *buffer) {
return buffer->impl.mySize;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,15 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int lastStart;
int lastCount;
int mySize;
} ConstantBuffer5Impl;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,10 @@
#include "G5onG4.c.h"
#include "commandlist.c.h"
#include "constantbuffer.c.h"
#include "indexbuffer.c.h"
#include "pipeline.c.h"
#include "rendertarget.c.h"
#include "sampler.c.h"
#include "shader.c.h"
#include "texture.c.h"
#include "vertexbuffer.c.h"

View File

@ -0,0 +1,6 @@
#pragma once
#include <kinc/backend/graphics5/indexbuffer.h>
#include <kinc/backend/graphics5/rendertarget.h>
#include <kinc/backend/graphics5/texture.h>
#include <kinc/backend/graphics5/vertexbuffer.h>

View File

@ -0,0 +1,34 @@
#include "indexbuffer.h"
#include <kinc/graphics5/indexbuffer.h>
#include <stdlib.h>
void kinc_g5_index_buffer_init(kinc_g5_index_buffer_t *buffer, int count, kinc_g5_index_buffer_format_t format, bool gpuMemory) {
buffer->impl.myCount = count;
kinc_g4_index_buffer_init(&buffer->impl.buffer, count, (kinc_g4_index_buffer_format_t)format, gpuMemory ? KINC_G4_USAGE_STATIC : KINC_G4_USAGE_DYNAMIC);
}
void kinc_g5_index_buffer_destroy(kinc_g5_index_buffer_t *buffer) {
kinc_g4_index_buffer_destroy(&buffer->impl.buffer);
}
void *kinc_g5_index_buffer_lock_all(kinc_g5_index_buffer_t *buffer) {
return kinc_g4_index_buffer_lock_all(&buffer->impl.buffer);
}
void *kinc_g5_index_buffer_lock(kinc_g5_index_buffer_t *buffer, int start, int count) {
return kinc_g4_index_buffer_lock(&buffer->impl.buffer, start, count);
}
void kinc_g5_index_buffer_unlock_all(kinc_g5_index_buffer_t *buffer) {
kinc_g4_index_buffer_unlock_all(&buffer->impl.buffer);
}
void kinc_g5_index_buffer_unlock(kinc_g5_index_buffer_t *buffer, int count) {
kinc_g4_index_buffer_unlock(&buffer->impl.buffer, count);
}
int kinc_g5_index_buffer_count(kinc_g5_index_buffer_t *buffer) {
return buffer->impl.myCount;
}

View File

@ -0,0 +1,16 @@
#pragma once
#include <kinc/graphics4/indexbuffer.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
kinc_g4_index_buffer_t buffer;
int myCount;
} IndexBuffer5Impl;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,65 @@
#include <kinc/graphics4/constantlocation.h>
#include <kinc/graphics5/constantlocation.h>
#include <kinc/graphics5/pipeline.h>
#include <kinc/log.h>
#include <kinc/system.h>
#include <string.h>
void kinc_g4_pipeline_get_constant_locations(kinc_g4_pipeline_t *state, kinc_g4_constant_location_t *vertex_locations,
kinc_g4_constant_location_t *fragment_locations, int *vertex_sizes, int *fragment_sizes, int *max_vertex,
int *max_fragment);
void kinc_g5_pipeline_init(kinc_g5_pipeline_t *pipeline) {
kinc_g4_pipeline_init(&pipeline->impl.pipe);
// int vertex_count = 0;
// int fragment_count = 0;
// kinc_g4_pipeline_get_constant_locations(&pipeline->impl.pipe, NULL, NULL, NULL, NULL, &vertex_count, &fragment_count);
// pipeline->impl.vertex_locations = malloc(vertex_count * sizeof(kinc_g4_constant_location_t));
// pipeline->impl.fragment_locations = malloc(fragment_count * sizeof(kinc_g4_constant_location_t));
// pipeline->impl.vertex_sizes = malloc(vertex_count * sizeof(int));
// pipeline->impl.fragment_sizes = malloc(fragment_count * sizeof(int));
// if (pipeline->impl.vertex_locations == NULL || pipeline->impl.fragment_locations == NULL || pipeline->impl.vertex_sizes == NULL ||
// pipeline->impl.fragment_sizes == NULL) {
// kinc_log(KINC_LOG_LEVEL_ERROR, "Failed to allocate pipeline reflection data.");
// kinc_stop();
// }
// else {
// pipeline->impl.vertex_location_count = vertex_count;
// pipeline->impl.fragment_location_count = fragment_count;
// kinc_g4_pipeline_get_constant_locations(&pipeline->impl.pipe, pipeline->impl.vertex_locations, pipeline->impl.fragment_locations,
// pipeline->impl.vertex_sizes, pipeline->impl.fragment_sizes, &vertex_count, &fragment_count);
// }
}
void kinc_g5_pipeline_destroy(kinc_g5_pipeline_t *pipe) {
kinc_g4_pipeline_destroy(&pipe->impl.pipe);
}
#ifndef KINC_KONG
kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipeline_t *pipe, const char *name) {
kinc_g5_constant_location_t location;
location.impl.location = kinc_g4_pipeline_get_constant_location(&pipe->impl.pipe, name);
return location;
}
kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pipe, const char *name) {
kinc_g4_texture_unit_t g4_unit = kinc_g4_pipeline_get_texture_unit(&pipe->impl.pipe, name);
assert(KINC_G4_SHADER_TYPE_COUNT == KINC_G5_SHADER_TYPE_COUNT);
kinc_g5_texture_unit_t g5_unit;
memcpy(&g5_unit.stages[0], &g4_unit.stages[0], KINC_G5_SHADER_TYPE_COUNT * sizeof(int));
return g5_unit;
}
#endif
void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) {
for (int i = 0; i < 16; ++i) {
pipe->impl.pipe.input_layout[i] = pipe->inputLayout[i];
}
pipe->impl.pipe.vertex_shader = &pipe->vertexShader->impl.shader;
pipe->impl.pipe.fragment_shader = &pipe->fragmentShader->impl.shader;
kinc_g4_pipeline_compile(&pipe->impl.pipe);
}

View File

@ -0,0 +1,33 @@
#pragma once
#include <kinc/graphics4/pipeline.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
kinc_g4_pipeline_t pipe;
// int vertex_location_count;
// int fragment_location_count;
// kinc_g4_constant_location_t *vertex_locations;
// kinc_g4_constant_location_t *fragment_locations;
// int *vertex_sizes;
// int *fragment_sizes;
} PipelineState5Impl;
typedef struct {
int a;
} ComputePipelineState5Impl;
typedef struct {
kinc_g4_constant_location_t location;
} ConstantLocation5Impl;
typedef struct {
int nothing;
} AttributeLocation5Impl;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,45 @@
#include <kinc/graphics4/rendertarget.h>
#include <kinc/graphics5/rendertarget.h>
#include <kinc/log.h>
void kinc_g5_render_target_init_with_multisampling(kinc_g5_render_target_t *renderTarget, int width, int height, kinc_g5_render_target_format_t format,
int depthBufferBits, int stencilBufferBits, int samples_per_pixel) {
renderTarget->texWidth = renderTarget->width = width;
renderTarget->texHeight = renderTarget->height = height;
renderTarget->framebuffer_index = -1;
kinc_g4_render_target_init_with_multisampling(&renderTarget->impl.target, width, height, (kinc_g4_render_target_format_t)format, depthBufferBits,
stencilBufferBits, samples_per_pixel);
}
void kinc_g5_render_target_init_framebuffer_with_multisampling(kinc_g5_render_target_t *target, int width, int height, kinc_g5_render_target_format_t format,
int depthBufferBits, int stencilBufferBits, int samples_per_pixel) {
target->framebuffer_index = 0;
target->width = target->texWidth = width;
target->height = target->texHeight = height;
}
void kinc_g5_render_target_init_cube_with_multisampling(kinc_g5_render_target_t *target, int cubeMapSize, kinc_g5_render_target_format_t format,
int depthBufferBits, int stencilBufferBits, int samples_per_pixel) {
target->texWidth = target->width = cubeMapSize;
target->texHeight = target->height = cubeMapSize;
target->isCubeMap = true;
target->framebuffer_index = -1;
kinc_g4_render_target_init_cube_with_multisampling(&target->impl.target, cubeMapSize, (kinc_g4_render_target_format_t)format, depthBufferBits,
stencilBufferBits, samples_per_pixel);
}
void kinc_g5_render_target_destroy(kinc_g5_render_target_t *renderTarget) {
kinc_g4_render_target_destroy(&renderTarget->impl.target);
}
void kinc_g5_render_target_set_depth_stencil_from(kinc_g5_render_target_t *renderTarget, kinc_g5_render_target_t *source) {
kinc_g4_render_target_set_depth_stencil_from(&renderTarget->impl.target, &source->impl.target);
}
// void kinc_g5_render_target_get_pixels(kinc_g5_render_target_t *renderTarget, uint8_t *data) {
// kinc_g4_render_target_get_pixels(&renderTarget->impl, data);
// }
// void kinc_g5_render_target_generate_mipmaps(kinc_g5_render_target_t *renderTarget, int levels) {
// kinc_g4_render_target_generate_mipmaps(&renderTarget->impl, levels);
// }

View File

@ -0,0 +1,14 @@
#pragma once
#include <kinc/graphics4/rendertarget.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
kinc_g4_render_target_t target;
} RenderTarget5Impl;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,5 @@
#include <kinc/graphics5/sampler.h>
void kinc_g5_sampler_init(kinc_g5_sampler_t *sampler, const kinc_g5_sampler_options_t *options) {}
void kinc_g5_sampler_destroy(kinc_g5_sampler_t *sampler) {}

View File

@ -0,0 +1,5 @@
#pragma once
typedef struct kinc_g5_sampler_impl {
int a;
} kinc_g5_sampler_impl_t;

View File

@ -0,0 +1,10 @@
#include <kinc/graphics4/shader.h>
#include <kinc/graphics5/shader.h>
void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) {
kinc_g4_shader_init(&shader->impl.shader, source, length, (kinc_g4_shader_type_t)type);
}
void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) {
kinc_g4_shader_destroy(&shader->impl.shader);
}

View File

@ -0,0 +1,15 @@
#pragma once
#include <kinc/graphics4/shader.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
kinc_g4_shader_t shader;
} Shader5Impl;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,50 @@
#include "texture.h"
#include <kinc/graphics5/texture.h>
#include <kinc/log.h>
void kinc_g5_texture_init(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) {
kinc_g4_texture_init(&texture->impl.texture, width, height, format);
}
void kinc_g5_texture_init3d(kinc_g5_texture_t *texture, int width, int height, int depth, kinc_image_format_t format) {
kinc_g4_texture_init3d(&texture->impl.texture, width, height, depth, format);
}
void kinc_g5_texture_init_from_image(kinc_g5_texture_t *texture, kinc_image_t *image) {
kinc_g4_texture_init_from_image(&texture->impl.texture, image);
}
void kinc_g5_texture_init_from_encoded_data(kinc_g5_texture_t *texture, void *data, int size, const char *format, bool readable) {
kinc_log(KINC_LOG_LEVEL_ERROR, "kinc_g5_texture_init_from_encoded_data not implemented");
}
void kinc_g5_texture_init_from_data(kinc_g5_texture_t *texture, void *data, int width, int height, int format, bool readable) {
kinc_log(KINC_LOG_LEVEL_ERROR, "kinc_g5_texture_init_from_data not implemented");
}
void kinc_g5_texture_init_non_sampled_access(kinc_g5_texture_t *texture, int width, int height, kinc_image_format_t format) {
kinc_log(KINC_LOG_LEVEL_ERROR, "kinc_g5_texture_init_non_sampled_access not implemented");
}
void kinc_g5_texture_destroy(kinc_g5_texture_t *texture) {
kinc_g4_texture_destroy(&texture->impl.texture);
}
uint8_t *kinc_g5_texture_lock(kinc_g5_texture_t *texture) {
return kinc_g4_texture_lock(&texture->impl.texture);
}
void kinc_g5_texture_unlock(kinc_g5_texture_t *texture) {
kinc_g4_texture_unlock(&texture->impl.texture);
}
void kinc_g5_texture_clear(kinc_g5_texture_t *texture, int x, int y, int z, int width, int height, int depth, unsigned color) {
kinc_g4_texture_clear(&texture->impl.texture, x, y, z, width, height, depth, color);
}
int kinc_g5_texture_stride(kinc_g5_texture_t *texture) {
return kinc_g4_texture_stride(&texture->impl.texture);
}
void kinc_g5_texture_generate_mipmaps(kinc_g5_texture_t *texture, int levels) {
kinc_g4_texture_generate_mipmaps(&texture->impl.texture, levels);
}
void kinc_g5_texture_set_mipmap(kinc_g5_texture_t *texture, kinc_image_t *mipmap, int level) {
kinc_g4_texture_set_mipmap(&texture->impl.texture, mipmap, level);
}

View File

@ -0,0 +1,20 @@
#pragma once
#include <kinc/graphics4/texture.h>
#include <kinc/graphics4/textureunit.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
kinc_g4_texture_unit_t unit;
} TextureUnit5Impl;
typedef struct {
kinc_g4_texture_t texture;
} Texture5Impl;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,39 @@
#include <kinc/graphics5/vertexbuffer.h>
#include <stdlib.h>
kinc_g5_vertex_buffer_t *kinc_g5_internal_current_vertex_buffer = NULL;
void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpuMemory, int instanceDataStepRate) {
buffer->impl.myCount = count;
buffer->impl.myStart = 0;
kinc_g4_vertex_buffer_init(&buffer->impl.buffer, count, structure, KINC_G4_USAGE_STATIC, instanceDataStepRate);
}
void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer) {
kinc_g4_vertex_buffer_destroy(&buffer->impl.buffer);
}
float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer) {
return kinc_g4_vertex_buffer_lock_all(&buffer->impl.buffer);
}
float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, int count) {
return kinc_g4_vertex_buffer_lock(&buffer->impl.buffer, start, count);
}
void kinc_g5_vertex_buffer_unlock_all(kinc_g5_vertex_buffer_t *buffer) {
kinc_g4_vertex_buffer_unlock_all(&buffer->impl.buffer);
}
void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t *buffer, int count) {
kinc_g4_vertex_buffer_unlock(&buffer->impl.buffer, count);
}
int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer) {
return buffer->impl.myCount;
}
int kinc_g5_vertex_buffer_stride(kinc_g5_vertex_buffer_t *buffer) {
return kinc_g4_vertex_buffer_stride(&buffer->impl.buffer);
}

View File

@ -0,0 +1,17 @@
#pragma once
#include <kinc/graphics4/vertexbuffer.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
kinc_g4_vertex_buffer_t buffer;
int myCount;
int myStart;
} VertexBuffer5Impl;
#ifdef __cplusplus
}
#endif