diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/d3d12unit.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/d3d12unit.cpp index cc7e30a76..42633b9e7 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/d3d12unit.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/d3d12unit.cpp @@ -4,5 +4,4 @@ #include "commandlist.cpp" #include "device.cpp" #include "pipeline.cpp" -#include "shader.cpp" #include "texture.cpp" diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/pipeline.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/pipeline.cpp index 54a65f421..b9a1a66a7 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/pipeline.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/pipeline.cpp @@ -1,8 +1,6 @@ #include "pipeline_functions.h" #include "pipeline_structs.h" -#include "shader_structs.h" - #include #include @@ -147,14 +145,14 @@ static void set_blend_state(D3D12_BLEND_DESC *desc, const kope_d3d12_color_targe desc->RenderTarget[target].SrcBlendAlpha = convert_blend_factor(target_state->blend.alpha.src_factor); desc->RenderTarget[target].DestBlendAlpha = convert_blend_factor(target_state->blend.alpha.dst_factor); desc->RenderTarget[target].BlendOpAlpha = convert_blend_operation(target_state->blend.alpha.operation); - desc->RenderTarget[target].RenderTargetWriteMask = target_state->write_mask; + desc->RenderTarget[target].RenderTargetWriteMask = (UINT8)target_state->write_mask; } void kope_d3d12_pipeline_init(kope_d3d12_device *device, kope_d3d12_pipeline *pipe, const kope_d3d12_pipeline_parameters *parameters) { D3D12_GRAPHICS_PIPELINE_STATE_DESC desc = {0}; - desc.VS.BytecodeLength = parameters->vertex.shader->size; - desc.VS.pShaderBytecode = parameters->vertex.shader->data; + desc.VS.BytecodeLength = parameters->vertex.shader.size; + desc.VS.pShaderBytecode = parameters->vertex.shader.data; assert(parameters->vertex.buffers_count <= KOPE_D3D12_MAX_VERTEX_ATTRIBUTES); D3D12_INPUT_ELEMENT_DESC input_elements[KOPE_D3D12_MAX_VERTEX_ATTRIBUTES] = {0}; @@ -279,7 +277,7 @@ void kope_d3d12_pipeline_init(kope_d3d12_device *device, kope_d3d12_pipeline *pi desc.PrimitiveTopologyType = convert_primitive_topology(parameters->primitive.topology); - desc.RasterizerState.FrontCounterClockwise = parameters->primitive.frontFace == KOPE_D3D12_FRONT_FACE_CCW ? TRUE : FALSE; + desc.RasterizerState.FrontCounterClockwise = parameters->primitive.front_face == KOPE_D3D12_FRONT_FACE_CCW ? TRUE : FALSE; desc.RasterizerState.CullMode = convert_cull_mode(parameters->primitive.cull_mode); desc.RasterizerState.DepthClipEnable = parameters->primitive.unclipped_depth ? FALSE : TRUE; @@ -319,8 +317,8 @@ void kope_d3d12_pipeline_init(kope_d3d12_device *device, kope_d3d12_pipeline *pi desc.SampleMask = 0xFFFFFFFF; desc.BlendState.AlphaToCoverageEnable = parameters->multisample.alpha_to_coverage_enabled ? TRUE : FALSE; - desc.PS.BytecodeLength = parameters->fragment.shader->size; - desc.PS.pShaderBytecode = parameters->fragment.shader->data; + desc.PS.BytecodeLength = parameters->fragment.shader.size; + desc.PS.pShaderBytecode = parameters->fragment.shader.data; desc.NumRenderTargets = (UINT)parameters->fragment.targets_count; assert(parameters->fragment.targets_count <= KOPE_D3D12_MAX_COLOR_TARGETS); diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/pipeline_structs.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/pipeline_structs.h index c8bffda73..0348a614c 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/pipeline_structs.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/pipeline_structs.h @@ -1,9 +1,9 @@ #ifndef KOPE_D3D12_PIPELINE_STRUCTS_HEADER #define KOPE_D3D12_PIPELINE_STRUCTS_HEADER -#include "shader_structs.h" - #include +#include +#include #include #ifdef __cplusplus @@ -61,10 +61,15 @@ typedef struct kope_d3d12_vertex_buffer_layout { size_t attributes_count; } kope_d3d12_vertex_buffer_layout; +typedef struct kope_d3d12_shader { + uint8_t *data; + size_t size; +} kope_d3d12_shader; + #define KOPE_D3D12_MAX_VERTEX_BUFFERS 16 typedef struct kope_d3d12_vertex_state { - kope_d3d12_shader *shader; + kope_d3d12_shader shader; kope_d3d12_vertex_buffer_layout buffers[KOPE_D3D12_MAX_VERTEX_BUFFERS]; size_t buffers_count; } kope_d3d12_vertex_state; @@ -84,7 +89,7 @@ typedef enum kope_d3d12_cull_mode { KOPE_D3D12_CULL_MODE_NONE, KOPE_D3D12_CULL_M typedef struct kope_d3d12_primitive_state { kope_d3d12_primitive_topology topology; kope_g5_index_format strip_index_format; - kope_d3d12_front_face frontFace; + kope_d3d12_front_face front_face; kope_d3d12_cull_mode cull_mode; bool unclipped_depth; } kope_d3d12_primitive_state; @@ -189,7 +194,7 @@ typedef struct kope_d3d12_color_target_state { #define KOPE_D3D12_MAX_COLOR_TARGETS 8 typedef struct kope_d3d12_fragment_state { - kope_d3d12_shader *shader; + kope_d3d12_shader shader; kope_d3d12_color_target_state targets[KOPE_D3D12_MAX_COLOR_TARGETS]; size_t targets_count; } kope_d3d12_fragment_state; diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader.cpp deleted file mode 100644 index 0072fae21..000000000 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "shader_functions.h" -#include "shader_structs.h" - -void kope_d3d12_shader_init(kope_d3d12_shader *shader, const void *data, size_t size, kope_d3d12_shader_stage stage) { - shader->size = size; - shader->data = (uint8_t *)malloc(size); - memcpy(shader->data, data, size); -} - -void kope_d3d12_shader_destroy(kope_d3d12_shader *shader) { - free(shader->data); -} diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader_functions.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader_functions.h deleted file mode 100644 index ced8a047a..000000000 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader_functions.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef KOPE_D3D12_SHADER_FUNCTIONS_HEADER -#define KOPE_D3D12_SHADER_FUNCTIONS_HEADER - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader_structs.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader_structs.h deleted file mode 100644 index 5db1537d7..000000000 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/shader_structs.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef KOPE_D3D12_SHADER_STRUCTS_HEADER -#define KOPE_D3D12_SHADER_STRUCTS_HEADER - -#include "d3d12mini.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum kope_d3d12_shader_stage { - KOPE_D3D12_SHADER_STAGE_VERTEX, - KOPE_D3D12_SHADER_STAGE_AMPLIFICATION, - KOPE_D3D12_SHADER_STAGE_MESH, - KOPE_D3D12_SHADER_STAGE_FRAGMENT, - KOPE_D3D12_SHADER_STAGE_COMPUTE, - KOPE_D3D12_SHADER_STAGE_RAY_GENERATION, - KOPE_D3D12_SHADER_STAGE_RAY_MISS, - KOPE_D3D12_SHADER_STAGE_RAY_CLOSEST_HIT, - KOPE_D3D12_SHADER_STAGE_RAY_INTERSECTION, - KOPE_D3D12_SHADER_STAGE_RAY_ANY_HIT -} kope_d3d12_shader_stage; - -typedef struct kope_d3d12_shader { - uint8_t *data; - size_t size; -} kope_d3d12_shader; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Backends/System/Windows/Sources/kinc/backend/system.c.h b/Backends/System/Windows/Sources/kinc/backend/system.c.h index 15ad48b18..891081b81 100644 --- a/Backends/System/Windows/Sources/kinc/backend/system.c.h +++ b/Backends/System/Windows/Sources/kinc/backend/system.c.h @@ -1076,9 +1076,8 @@ bool handleDirectInputPad(int padIndex) { } static bool isXInputGamepad(int gamepad) { - //if gamepad is greater than XInput max, treat it as DINPUT. - if (gamepad >= XUSER_MAX_COUNT) - { + // if gamepad is greater than XInput max, treat it as DINPUT. + if (gamepad >= XUSER_MAX_COUNT) { return false; } XINPUT_STATE state; @@ -1169,9 +1168,9 @@ bool kinc_internal_handle_messages() { } } else { - if (handleDirectInputPad(i)) { - gamepadFound = true; - } + if (handleDirectInputPad(i)) { + gamepadFound = true; + } } } } @@ -1416,7 +1415,7 @@ int kinc_init(const char *name, int width, int height, kinc_window_options_t *wi loadXInput(); initializeDirectInput(); -#ifdef KINC_KONG +#if defined(KINC_KONG) && !defined(KOPE) kong_init(); #endif diff --git a/Sources/kinc/graphics1/graphics.c b/Sources/kinc/graphics1/graphics.c index e316f91e4..634d9958a 100644 --- a/Sources/kinc/graphics1/graphics.c +++ b/Sources/kinc/graphics1/graphics.c @@ -9,6 +9,8 @@ #include #include +#ifndef KOPE + #ifdef KINC_KONG #include #endif @@ -36,9 +38,12 @@ void kinc_g1_begin(void) { static inline kinc_g4_texture_filter_t map_texture_filter(kinc_g1_texture_filter_t filter) { switch (filter) { - case KINC_G1_TEXTURE_FILTER_POINT: return KINC_G4_TEXTURE_FILTER_POINT; - case KINC_G1_TEXTURE_FILTER_LINEAR: return KINC_G4_TEXTURE_FILTER_LINEAR; - case KINC_G1_TEXTURE_FILTER_ANISOTROPIC: return KINC_G4_TEXTURE_FILTER_ANISOTROPIC; + case KINC_G1_TEXTURE_FILTER_POINT: + return KINC_G4_TEXTURE_FILTER_POINT; + case KINC_G1_TEXTURE_FILTER_LINEAR: + return KINC_G4_TEXTURE_FILTER_LINEAR; + case KINC_G1_TEXTURE_FILTER_ANISOTROPIC: + return KINC_G4_TEXTURE_FILTER_ANISOTROPIC; } kinc_log(KINC_LOG_LEVEL_WARNING, "unhandled kinc_g1_texture_filter_t (%i)", filter); @@ -47,9 +52,12 @@ static inline kinc_g4_texture_filter_t map_texture_filter(kinc_g1_texture_filter static inline kinc_g4_texture_filter_t map_mipmap_filter(kinc_g1_texture_filter_t filter) { switch (filter) { - case KINC_G1_MIPMAP_FILTER_NONE: return KINC_G4_MIPMAP_FILTER_NONE; - case KINC_G1_MIPMAP_FILTER_POINT: return KINC_G4_MIPMAP_FILTER_POINT; - case KINC_G1_MIPMAP_FILTER_LINEAR: return KINC_G4_MIPMAP_FILTER_LINEAR; + case KINC_G1_MIPMAP_FILTER_NONE: + return KINC_G4_MIPMAP_FILTER_NONE; + case KINC_G1_MIPMAP_FILTER_POINT: + return KINC_G4_MIPMAP_FILTER_POINT; + case KINC_G1_MIPMAP_FILTER_LINEAR: + return KINC_G4_MIPMAP_FILTER_LINEAR; } kinc_log(KINC_LOG_LEVEL_WARNING, "unhandled kinc_g1_mipmap_filter_t (%i)", filter); @@ -214,3 +222,5 @@ void kinc_g1_set_texture_mipmap_filter(kinc_g1_mipmap_filter_t filter) { } #endif + +#endif diff --git a/Sources/kinc/graphics2/g2unit.c b/Sources/kinc/graphics2/g2unit.c index 612f64053..45a1123e7 100644 --- a/Sources/kinc/graphics2/g2unit.c +++ b/Sources/kinc/graphics2/g2unit.c @@ -1,4 +1,4 @@ -#ifdef KINC_KONG +#if defined(KINC_KONG) && !defined(KOPE) #include "colored_painter.c.h" #include "image_painter.c.h" #include "text_painter.c.h"