From 9730f62e8cb535646fb28d32b1add493f67bae0d Mon Sep 17 00:00:00 2001 From: Caleb Cornett Date: Fri, 6 Sep 2024 18:38:23 -0500 Subject: [PATCH] GPU: Rename struct members and parameters for SDL3 naming conventions (#10730) --------- Co-authored-by: Evan Hemsley <2342303+thatcosmonaut@users.noreply.github.com> --- include/SDL3/SDL_gpu.h | 833 ++++++++------- src/dynapi/SDL_dynapi_procs.h | 2 +- src/gpu/SDL_gpu.c | 1404 +++++++++++++------------- src/gpu/SDL_sysgpu.h | 116 +-- src/gpu/d3d11/SDL_gpu_d3d11.c | 723 ++++++------- src/gpu/d3d12/SDL_gpu_d3d12.c | 930 ++++++++--------- src/gpu/metal/SDL_gpu_metal.m | 686 ++++++------- src/gpu/vulkan/SDL_gpu_vulkan.c | 948 ++++++++--------- src/render/sdlgpu/SDL_pipeline_gpu.c | 60 +- src/render/sdlgpu/SDL_render_gpu.c | 70 +- src/render/sdlgpu/SDL_shaders_gpu.c | 8 +- test/testgpu_simple_clear.c | 21 +- test/testgpu_spinning_cube.c | 134 +-- 13 files changed, 2963 insertions(+), 2972 deletions(-) diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 09f46738b4..ce026a485a 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -494,7 +494,7 @@ typedef enum SDL_GPUTextureType * Specifies the sample count of a texture. * * Used in multisampling. Note that this value only applies when the texture - * is used as a render pass attachment. + * is used as a render target. * * \since This enum is available since SDL 3.0.0 * @@ -751,8 +751,7 @@ typedef enum SDL_GPUStencilOp } SDL_GPUStencilOp; /** - * Specifies the operator to be used when pixels in a render pass texture - * attachment are blended with existing pixels in the texture. + * Specifies the operator to be used when pixels in a render target are blended with existing pixels in the texture. * * The source color is the value written by the fragment shader. The * destination color is the value currently existing in the texture. @@ -771,8 +770,7 @@ typedef enum SDL_GPUBlendOp } SDL_GPUBlendOp; /** - * Specifies a blending factor to be used when pixels in a render pass texture - * attachment are blended with existing pixels in the texture. + * Specifies a blending factor to be used when pixels in a render target are blended with existing pixels in the texture. * * The source color is the value written by the fragment shader. The * destination color is the value currently existing in the texture. @@ -958,28 +956,28 @@ typedef struct SDL_GPUViewport float y; float w; float h; - float minDepth; - float maxDepth; + float min_depth; + float max_depth; } SDL_GPUViewport; typedef struct SDL_GPUTextureTransferInfo { - SDL_GPUTransferBuffer *transferBuffer; - Uint32 offset; /* starting location of the image data */ - Uint32 imagePitch; /* number of pixels from one row to the next */ - Uint32 imageHeight; /* number of rows from one layer/depth-slice to the next */ + SDL_GPUTransferBuffer *transfer_buffer; + Uint32 offset; /* starting location of the image data */ + Uint32 pixels_per_row; /* number of pixels from one row to the next */ + Uint32 rows_per_layer; /* number of rows from one layer/depth-slice to the next */ } SDL_GPUTextureTransferInfo; typedef struct SDL_GPUTransferBufferLocation { - SDL_GPUTransferBuffer *transferBuffer; + SDL_GPUTransferBuffer *transfer_buffer; Uint32 offset; } SDL_GPUTransferBufferLocation; typedef struct SDL_GPUTextureLocation { SDL_GPUTexture *texture; - Uint32 mipLevel; + Uint32 mip_level; Uint32 layer; Uint32 x; Uint32 y; @@ -989,7 +987,7 @@ typedef struct SDL_GPUTextureLocation typedef struct SDL_GPUTextureRegion { SDL_GPUTexture *texture; - Uint32 mipLevel; + Uint32 mip_level; Uint32 layer; Uint32 x; Uint32 y; @@ -1002,8 +1000,8 @@ typedef struct SDL_GPUTextureRegion typedef struct SDL_GPUBlitRegion { SDL_GPUTexture *texture; - Uint32 mipLevel; - Uint32 layerOrDepthPlane; + Uint32 mip_level; + Uint32 layer_or_depth_plane; Uint32 x; Uint32 y; Uint32 w; @@ -1023,54 +1021,54 @@ typedef struct SDL_GPUBufferRegion Uint32 size; } SDL_GPUBufferRegion; -/* Note that the `firstVertex` and `firstInstance` parameters are NOT compatible with +/* Note that the `first_vertex` and `first_instance` parameters are NOT compatible with * built-in vertex/instance ID variables in shaders (for example, SV_VertexID). If * your shader depends on these variables, the correlating draw call parameter MUST * be 0. */ typedef struct SDL_GPUIndirectDrawCommand { - Uint32 vertexCount; /* number of vertices to draw */ - Uint32 instanceCount; /* number of instances to draw */ - Uint32 firstVertex; /* index of the first vertex to draw */ - Uint32 firstInstance; /* ID of the first instance to draw */ + Uint32 num_vertices; /* number of vertices to draw */ + Uint32 num_instances; /* number of instances to draw */ + Uint32 first_vertex; /* index of the first vertex to draw */ + Uint32 first_instance; /* ID of the first instance to draw */ } SDL_GPUIndirectDrawCommand; typedef struct SDL_GPUIndexedIndirectDrawCommand { - Uint32 indexCount; /* number of vertices to draw per instance */ - Uint32 instanceCount; /* number of instances to draw */ - Uint32 firstIndex; /* base index within the index buffer */ - Sint32 vertexOffset; /* value added to vertex index before indexing into the vertex buffer */ - Uint32 firstInstance; /* ID of the first instance to draw */ + Uint32 num_indices; /* number of vertices to draw per instance */ + Uint32 num_instances; /* number of instances to draw */ + Uint32 first_index; /* base index within the index buffer */ + Sint32 vertex_offset; /* value added to vertex index before indexing into the vertex buffer */ + Uint32 first_instance; /* ID of the first instance to draw */ } SDL_GPUIndexedIndirectDrawCommand; typedef struct SDL_GPUIndirectDispatchCommand { - Uint32 groupCountX; - Uint32 groupCountY; - Uint32 groupCountZ; + Uint32 groupcount_x; + Uint32 groupcount_y; + Uint32 groupcount_z; } SDL_GPUIndirectDispatchCommand; /* State structures */ typedef struct SDL_GPUSamplerCreateInfo { - SDL_GPUFilter minFilter; - SDL_GPUFilter magFilter; - SDL_GPUSamplerMipmapMode mipmapMode; - SDL_GPUSamplerAddressMode addressModeU; - SDL_GPUSamplerAddressMode addressModeV; - SDL_GPUSamplerAddressMode addressModeW; - float mipLodBias; - float maxAnisotropy; - SDL_bool anisotropyEnable; - SDL_bool compareEnable; + SDL_GPUFilter min_filter; + SDL_GPUFilter mag_filter; + SDL_GPUSamplerMipmapMode mipmap_mode; + SDL_GPUSamplerAddressMode address_mode_u; + SDL_GPUSamplerAddressMode address_mode_v; + SDL_GPUSamplerAddressMode address_mode_w; + float mip_lod_bias; + float max_anisotropy; + SDL_bool enable_anisotropy; + SDL_bool enable_compare; Uint8 padding1; Uint8 padding2; - SDL_GPUCompareOp compareOp; - float minLod; - float maxLod; + SDL_GPUCompareOp compare_op; + float min_lod; + float max_lod; SDL_PropertiesID props; } SDL_GPUSamplerCreateInfo; @@ -1078,9 +1076,9 @@ typedef struct SDL_GPUSamplerCreateInfo typedef struct SDL_GPUVertexBinding { Uint32 binding; - Uint32 stride; - SDL_GPUVertexInputRate inputRate; - Uint32 instanceStepRate; /* ignored unless inputRate is INSTANCE */ + Uint32 pitch; + SDL_GPUVertexInputRate input_rate; + Uint32 instance_step_rate; /* ignored unless input_rate is INSTANCE */ } SDL_GPUVertexBinding; typedef struct SDL_GPUVertexAttribute @@ -1093,46 +1091,46 @@ typedef struct SDL_GPUVertexAttribute typedef struct SDL_GPUVertexInputState { - const SDL_GPUVertexBinding *vertexBindings; - Uint32 vertexBindingCount; - const SDL_GPUVertexAttribute *vertexAttributes; - Uint32 vertexAttributeCount; + const SDL_GPUVertexBinding *vertex_bindings; + Uint32 num_vertex_bindings; + const SDL_GPUVertexAttribute *vertex_attributes; + Uint32 num_vertex_attributes; } SDL_GPUVertexInputState; typedef struct SDL_GPUStencilOpState { - SDL_GPUStencilOp failOp; - SDL_GPUStencilOp passOp; - SDL_GPUStencilOp depthFailOp; - SDL_GPUCompareOp compareOp; + SDL_GPUStencilOp fail_op; + SDL_GPUStencilOp pass_op; + SDL_GPUStencilOp depth_fail_op; + SDL_GPUCompareOp compare_op; } SDL_GPUStencilOpState; -typedef struct SDL_GPUColorAttachmentBlendState +typedef struct SDL_GPUColorTargetBlendState { - SDL_bool blendEnable; + SDL_bool enable_blend; Uint8 padding1; Uint8 padding2; Uint8 padding3; - SDL_GPUBlendFactor srcColorBlendFactor; - SDL_GPUBlendFactor dstColorBlendFactor; - SDL_GPUBlendOp colorBlendOp; - SDL_GPUBlendFactor srcAlphaBlendFactor; - SDL_GPUBlendFactor dstAlphaBlendFactor; - SDL_GPUBlendOp alphaBlendOp; - SDL_GPUColorComponentFlags colorWriteMask; -} SDL_GPUColorAttachmentBlendState; + SDL_GPUBlendFactor src_color_blendfactor; + SDL_GPUBlendFactor dst_color_blendfactor; + SDL_GPUBlendOp color_blend_op; + SDL_GPUBlendFactor src_alpha_blendfactor; + SDL_GPUBlendFactor dst_alpha_blendfactor; + SDL_GPUBlendOp alpha_blend_op; + SDL_GPUColorComponentFlags color_write_mask; +} SDL_GPUColorTargetBlendState; typedef struct SDL_GPUShaderCreateInfo { - size_t codeSize; + size_t code_size; const Uint8 *code; - const char *entryPointName; + const char *entrypoint; SDL_GPUShaderFormat format; SDL_GPUShaderStage stage; - Uint32 samplerCount; - Uint32 storageTextureCount; - Uint32 storageBufferCount; - Uint32 uniformBufferCount; + Uint32 num_samplers; + Uint32 num_storage_textures; + Uint32 num_storage_buffers; + Uint32 num_uniform_buffers; SDL_PropertiesID props; } SDL_GPUShaderCreateInfo; @@ -1141,12 +1139,12 @@ typedef struct SDL_GPUTextureCreateInfo { SDL_GPUTextureType type; SDL_GPUTextureFormat format; - SDL_GPUTextureUsageFlags usageFlags; + SDL_GPUTextureUsageFlags usage; Uint32 width; Uint32 height; - Uint32 layerCountOrDepth; - Uint32 levelCount; - SDL_GPUSampleCount sampleCount; + Uint32 layer_count_or_depth; + Uint32 num_levels; + SDL_GPUSampleCount sample_count; SDL_PropertiesID props; } SDL_GPUTextureCreateInfo; @@ -1160,8 +1158,8 @@ typedef struct SDL_GPUTextureCreateInfo typedef struct SDL_GPUBufferCreateInfo { - SDL_GPUBufferUsageFlags usageFlags; - Uint32 sizeInBytes; + SDL_GPUBufferUsageFlags usage; + Uint32 size; SDL_PropertiesID props; } SDL_GPUBufferCreateInfo; @@ -1169,7 +1167,7 @@ typedef struct SDL_GPUBufferCreateInfo typedef struct SDL_GPUTransferBufferCreateInfo { SDL_GPUTransferBufferUsage usage; - Uint32 sizeInBytes; + Uint32 size; SDL_PropertiesID props; } SDL_GPUTransferBufferCreateInfo; @@ -1178,97 +1176,97 @@ typedef struct SDL_GPUTransferBufferCreateInfo typedef struct SDL_GPURasterizerState { - SDL_GPUFillMode fillMode; - SDL_GPUCullMode cullMode; - SDL_GPUFrontFace frontFace; - SDL_bool depthBiasEnable; + SDL_GPUFillMode fill_mode; + SDL_GPUCullMode cull_mode; + SDL_GPUFrontFace front_face; + SDL_bool enable_depth_bias; Uint8 padding1; Uint8 padding2; Uint8 padding3; - float depthBiasConstantFactor; - float depthBiasClamp; - float depthBiasSlopeFactor; + float depth_bias_constant_factor; + float depth_bias_clamp; + float depth_bias_slope_factor; } SDL_GPURasterizerState; typedef struct SDL_GPUMultisampleState { - SDL_GPUSampleCount sampleCount; - Uint32 sampleMask; + SDL_GPUSampleCount sample_count; + Uint32 sample_mask; } SDL_GPUMultisampleState; typedef struct SDL_GPUDepthStencilState { - SDL_bool depthTestEnable; - SDL_bool depthWriteEnable; - SDL_bool stencilTestEnable; + SDL_bool enable_depth_test; + SDL_bool enable_depth_write; + SDL_bool enable_stencil_test; Uint8 padding1; - SDL_GPUCompareOp compareOp; - SDL_GPUStencilOpState backStencilState; - SDL_GPUStencilOpState frontStencilState; - Uint8 compareMask; - Uint8 writeMask; + SDL_GPUCompareOp compare_op; + SDL_GPUStencilOpState back_stencil_state; + SDL_GPUStencilOpState front_stencil_state; + Uint8 compare_mask; + Uint8 write_mask; Uint8 padding2; Uint8 padding3; } SDL_GPUDepthStencilState; -typedef struct SDL_GPUColorAttachmentDescription +typedef struct SDL_GPUColorTargetDescription { SDL_GPUTextureFormat format; - SDL_GPUColorAttachmentBlendState blendState; -} SDL_GPUColorAttachmentDescription; + SDL_GPUColorTargetBlendState blend_state; +} SDL_GPUColorTargetDescription; -typedef struct SDL_GPUGraphicsPipelineAttachmentInfo +typedef struct SDL_GpuGraphicsPipelineTargetInfo { - const SDL_GPUColorAttachmentDescription *colorAttachmentDescriptions; - Uint32 colorAttachmentCount; - SDL_bool hasDepthStencilAttachment; + const SDL_GPUColorTargetDescription *color_target_descriptions; + Uint32 num_color_targets; + SDL_bool has_depth_stencil_target; Uint8 padding1; Uint8 padding2; Uint8 padding3; - SDL_GPUTextureFormat depthStencilFormat; -} SDL_GPUGraphicsPipelineAttachmentInfo; + SDL_GPUTextureFormat depth_stencil_format; +} SDL_GpuGraphicsPipelineTargetInfo; typedef struct SDL_GPUGraphicsPipelineCreateInfo { - SDL_GPUShader *vertexShader; - SDL_GPUShader *fragmentShader; - SDL_GPUVertexInputState vertexInputState; - SDL_GPUPrimitiveType primitiveType; - SDL_GPURasterizerState rasterizerState; - SDL_GPUMultisampleState multisampleState; - SDL_GPUDepthStencilState depthStencilState; - SDL_GPUGraphicsPipelineAttachmentInfo attachmentInfo; + SDL_GPUShader *vertex_shader; + SDL_GPUShader *fragment_shader; + SDL_GPUVertexInputState vertex_input_state; + SDL_GPUPrimitiveType primitive_type; + SDL_GPURasterizerState rasterizer_state; + SDL_GPUMultisampleState multisample_state; + SDL_GPUDepthStencilState depth_stencil_state; + SDL_GpuGraphicsPipelineTargetInfo target_info; SDL_PropertiesID props; } SDL_GPUGraphicsPipelineCreateInfo; typedef struct SDL_GPUComputePipelineCreateInfo { - size_t codeSize; + size_t code_size; const Uint8 *code; - const char *entryPointName; + const char *entrypoint; SDL_GPUShaderFormat format; - Uint32 readOnlyStorageTextureCount; - Uint32 readOnlyStorageBufferCount; - Uint32 writeOnlyStorageTextureCount; - Uint32 writeOnlyStorageBufferCount; - Uint32 uniformBufferCount; - Uint32 threadCountX; - Uint32 threadCountY; - Uint32 threadCountZ; + Uint32 num_readonly_storage_textures; + Uint32 num_readonly_storage_buffers; + Uint32 num_writeonly_storage_textures; + Uint32 num_writeonly_storage_buffers; + Uint32 num_uniform_buffers; + Uint32 threadcount_x; + Uint32 threadcount_y; + Uint32 threadcount_z; SDL_PropertiesID props; } SDL_GPUComputePipelineCreateInfo; -typedef struct SDL_GPUColorAttachmentInfo +typedef struct SDL_GPUColorTargetInfo { - /* The texture that will be used as a color attachment by a render pass. */ + /* The texture that will be used as a color target by a render pass. */ SDL_GPUTexture *texture; - Uint32 mipLevel; - Uint32 layerOrDepthPlane; /* For 3D textures, you can bind an individual depth plane as an attachment. */ + Uint32 mip_level; + Uint32 layer_or_depth_plane; /* For 3D textures, you can bind an individual depth plane as a target. */ /* Can be ignored by RenderPass if CLEAR is not used */ - SDL_FColor clearColor; + SDL_FColor clear_color; /* Determines what is done with the texture at the beginning of the render pass. * @@ -1282,7 +1280,7 @@ typedef struct SDL_GPUColorAttachmentInfo * The driver will do whatever it wants with the texture memory. * This is a good option if you know that every single pixel will be touched in the render pass. */ - SDL_GPULoadOp loadOp; + SDL_GPULoadOp load_op; /* Determines what is done with the texture at the end of the render pass. * @@ -1293,22 +1291,22 @@ typedef struct SDL_GPUColorAttachmentInfo * The driver will do whatever it wants with the texture memory. * This is often a good option for depth/stencil textures. */ - SDL_GPUStoreOp storeOp; + SDL_GPUStoreOp store_op; - /* if SDL_TRUE, cycles the texture if the texture is bound and loadOp is not LOAD */ + /* if SDL_TRUE, cycles the texture if the texture is bound and load_op is not LOAD */ SDL_bool cycle; Uint8 padding1; Uint8 padding2; Uint8 padding3; -} SDL_GPUColorAttachmentInfo; +} SDL_GPUColorTargetInfo; -typedef struct SDL_GPUDepthStencilAttachmentInfo +typedef struct SDL_GPUDepthStencilTargetInfo { - /* The texture that will be used as the depth stencil attachment by a render pass. */ + /* The texture that will be used as the depth stencil target by a render pass. */ SDL_GPUTexture *texture; /* Can be ignored by the render pass if CLEAR is not used */ - SDL_GPUDepthStencilValue depthStencilClearValue; + SDL_GPUDepthStencilValue clear_value; /* Determines what is done with the depth values at the beginning of the render pass. * @@ -1322,7 +1320,7 @@ typedef struct SDL_GPUDepthStencilAttachmentInfo * The driver will do whatever it wants with the memory. * This is a good option if you know that every single pixel will be touched in the render pass. */ - SDL_GPULoadOp loadOp; + SDL_GPULoadOp load_op; /* Determines what is done with the depth values at the end of the render pass. * @@ -1333,7 +1331,7 @@ typedef struct SDL_GPUDepthStencilAttachmentInfo * The driver will do whatever it wants with the texture memory. * This is often a good option for depth/stencil textures. */ - SDL_GPUStoreOp storeOp; + SDL_GPUStoreOp store_op; /* Determines what is done with the stencil values at the beginning of the render pass. * @@ -1347,7 +1345,7 @@ typedef struct SDL_GPUDepthStencilAttachmentInfo * The driver will do whatever it wants with the memory. * This is a good option if you know that every single pixel will be touched in the render pass. */ - SDL_GPULoadOp stencilLoadOp; + SDL_GPULoadOp stencil_load_op; /* Determines what is done with the stencil values at the end of the render pass. * @@ -1358,14 +1356,14 @@ typedef struct SDL_GPUDepthStencilAttachmentInfo * The driver will do whatever it wants with the texture memory. * This is often a good option for depth/stencil textures. */ - SDL_GPUStoreOp stencilStoreOp; + SDL_GPUStoreOp stencil_store_op; /* if SDL_TRUE, cycles the texture if the texture is bound and any load ops are not LOAD */ SDL_bool cycle; Uint8 padding1; Uint8 padding2; Uint8 padding3; -} SDL_GPUDepthStencilAttachmentInfo; +} SDL_GPUDepthStencilTargetInfo; /* Binding structs */ @@ -1395,7 +1393,7 @@ typedef struct SDL_GPUStorageBufferWriteOnlyBinding typedef struct SDL_GPUStorageTextureWriteOnlyBinding { SDL_GPUTexture *texture; - Uint32 mipLevel; + Uint32 mip_level; Uint32 layer; /* if SDL_TRUE, cycles the texture if the texture is bound. */ @@ -1412,9 +1410,9 @@ typedef struct SDL_GPUStorageTextureWriteOnlyBinding /** * Creates a GPU context. * - * \param formatFlags a bitflag indicating which shader formats the app is + * \param format_flags a bitflag indicating which shader formats the app is * able to provide. - * \param debugMode enable debug mode properties and validations. + * \param debug_mode enable debug mode properties and validations. * \param name the preferred GPU driver, or NULL to let SDL pick the optimal * driver. * \returns a GPU context on success or NULL on failure. @@ -1425,8 +1423,8 @@ typedef struct SDL_GPUStorageTextureWriteOnlyBinding * \sa SDL_DestroyGPUDevice */ extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDevice( - SDL_GPUShaderFormat formatFlags, - SDL_bool debugMode, + SDL_GPUShaderFormat format_flags, + SDL_bool debug_mode, const char *name); /** @@ -1542,8 +1540,7 @@ extern SDL_DECLSPEC SDL_GPUDriver SDLCALL SDL_GetGPUDriver(SDL_GPUDevice *device * textures * * \param device a GPU Context. - * \param computePipelineCreateInfo a struct describing the state of the - * requested compute pipeline. + * \param createinfo a struct describing the state of the compute pipeline to create. * \returns a compute pipeline object on success, or NULL on failure. * * \since This function is available since SDL 3.0.0. @@ -1553,14 +1550,13 @@ extern SDL_DECLSPEC SDL_GPUDriver SDLCALL SDL_GetGPUDriver(SDL_GPUDevice *device */ extern SDL_DECLSPEC SDL_GPUComputePipeline *SDLCALL SDL_CreateGPUComputePipeline( SDL_GPUDevice *device, - const SDL_GPUComputePipelineCreateInfo *computePipelineCreateInfo); + const SDL_GPUComputePipelineCreateInfo *createinfo); /** * Creates a pipeline object to be used in a graphics workflow. * * \param device a GPU Context. - * \param pipelineCreateInfo a struct describing the state of the desired - * graphics pipeline. + * \param createinfo a struct describing the state of the graphics pipeline to create. * \returns a graphics pipeline object on success, or NULL on failure. * * \since This function is available since SDL 3.0.0. @@ -1571,15 +1567,14 @@ extern SDL_DECLSPEC SDL_GPUComputePipeline *SDLCALL SDL_CreateGPUComputePipeline */ extern SDL_DECLSPEC SDL_GPUGraphicsPipeline *SDLCALL SDL_CreateGPUGraphicsPipeline( SDL_GPUDevice *device, - const SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo); + const SDL_GPUGraphicsPipelineCreateInfo *createinfo); /** * Creates a sampler object to be used when binding textures in a graphics * workflow. * * \param device a GPU Context. - * \param samplerCreateInfo a struct describing the state of the desired - * sampler. + * \param createinfo a struct describing the state of the sampler to create. * \returns a sampler object on success, or NULL on failure. * * \since This function is available since SDL 3.0.0. @@ -1590,7 +1585,7 @@ extern SDL_DECLSPEC SDL_GPUGraphicsPipeline *SDLCALL SDL_CreateGPUGraphicsPipeli */ extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler( SDL_GPUDevice *device, - const SDL_GPUSamplerCreateInfo *samplerCreateInfo); + const SDL_GPUSamplerCreateInfo *createinfo); /** * Creates a shader to be used when creating a graphics pipeline. @@ -1648,8 +1643,7 @@ extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler( * information from the SDL_GPUPipeline. * * \param device a GPU Context. - * \param shaderCreateInfo a struct describing the state of the desired - * shader. + * \param createinfo a struct describing the state of the shader to create. * \returns a shader object on success, or NULL on failure. * * \since This function is available since SDL 3.0.0. @@ -1659,7 +1653,7 @@ extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler( */ extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader( SDL_GPUDevice *device, - const SDL_GPUShaderCreateInfo *shaderCreateInfo); + const SDL_GPUShaderCreateInfo *createinfo); /** * Creates a texture object to be used in graphics or compute workflows. @@ -1675,8 +1669,7 @@ extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader( * count. * * \param device a GPU Context. - * \param textureCreateInfo a struct describing the state of the texture to - * create. + * \param createinfo a struct describing the state of the texture to create. * \returns a texture object on success, or NULL on failure. * * \since This function is available since SDL 3.0.0. @@ -1694,7 +1687,7 @@ extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader( */ extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture( SDL_GPUDevice *device, - const SDL_GPUTextureCreateInfo *textureCreateInfo); + const SDL_GPUTextureCreateInfo *createinfo); /** * Creates a buffer object to be used in graphics or compute workflows. @@ -1706,8 +1699,7 @@ extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture( * buffer cannot have both the VERTEX and INDEX flags. * * \param device a GPU Context. - * \param bufferCreateInfo a struct describing the state of the buffer to - * create. + * \param createinfo a struct describing the state of the buffer to create. * \returns a buffer object on success, or NULL on failure. * * \since This function is available since SDL 3.0.0. @@ -1728,15 +1720,14 @@ extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture( */ extern SDL_DECLSPEC SDL_GPUBuffer *SDLCALL SDL_CreateGPUBuffer( SDL_GPUDevice *device, - const SDL_GPUBufferCreateInfo *bufferCreateInfo); + const SDL_GPUBufferCreateInfo *createinfo); /** * Creates a transfer buffer to be used when uploading to or downloading from * graphics resources. * * \param device a GPU Context. - * \param transferBufferCreateInfo a struct describing the state of the - * transfer buffer to create. + * \param createinfo a struct describing the state of the transfer buffer to create. * \returns a transfer buffer on success, or NULL on failure. * * \since This function is available since SDL 3.0.0. @@ -1749,7 +1740,7 @@ extern SDL_DECLSPEC SDL_GPUBuffer *SDLCALL SDL_CreateGPUBuffer( */ extern SDL_DECLSPEC SDL_GPUTransferBuffer *SDLCALL SDL_CreateGPUTransferBuffer( SDL_GPUDevice *device, - const SDL_GPUTransferBufferCreateInfo *transferBufferCreateInfo); + const SDL_GPUTransferBufferCreateInfo *createinfo); /* Debug Naming */ @@ -1790,13 +1781,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName( * * Useful for debugging. * - * \param commandBuffer a command buffer. + * \param command_buffer a command buffer. * \param text a UTF-8 string constant to insert as the label. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, const char *text); /** @@ -1813,7 +1804,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel( * pass rather than the command buffer. For best results, if you push a debug * group during a pass, always pop it in the same pass. * - * \param commandBuffer a command buffer. + * \param command_buffer a command buffer. * \param name a UTF-8 string constant that names the group. * * \since This function is available since SDL 3.0.0. @@ -1821,20 +1812,20 @@ extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel( * \sa SDL_PopGPUDebugGroup */ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, const char *name); /** * Ends the most-recently pushed debug group. * - * \param commandBuffer a command buffer. + * \param command_buffer a command buffer. * * \since This function is available since SDL 3.0.0. * * \sa SDL_PushGPUDebugGroup */ extern SDL_DECLSPEC void SDLCALL SDL_PopGPUDebugGroup( - SDL_GPUCommandBuffer *commandBuffer); + SDL_GPUCommandBuffer *command_buffer); /* Disposal */ @@ -1886,13 +1877,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUBuffer( * You must not reference the transfer buffer after calling this function. * * \param device a GPU context. - * \param transferBuffer a transfer buffer to be destroyed. + * \param transfer_buffer a transfer buffer to be destroyed. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer( SDL_GPUDevice *device, - SDL_GPUTransferBuffer *transferBuffer); + SDL_GPUTransferBuffer *transfer_buffer); /** * Frees the given compute pipeline as soon as it is safe to do so. @@ -1900,13 +1891,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer( * You must not reference the compute pipeline after calling this function. * * \param device a GPU context. - * \param computePipeline a compute pipeline to be destroyed. + * \param compute_pipeline a compute pipeline to be destroyed. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUComputePipeline( SDL_GPUDevice *device, - SDL_GPUComputePipeline *computePipeline); + SDL_GPUComputePipeline *compute_pipeline); /** * Frees the given shader as soon as it is safe to do so. @@ -1928,13 +1919,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUShader( * You must not reference the graphics pipeline after calling this function. * * \param device a GPU context. - * \param graphicsPipeline a graphics pipeline to be destroyed. + * \param graphics_pipeline a graphics pipeline to be destroyed. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUGraphicsPipeline( SDL_GPUDevice *device, - SDL_GPUGraphicsPipeline *graphicsPipeline); + SDL_GPUGraphicsPipeline *graphics_pipeline); /** * Acquire a command buffer. @@ -1980,54 +1971,54 @@ extern SDL_DECLSPEC SDL_GPUCommandBuffer *SDLCALL SDL_AcquireGPUCommandBuffer( * * Subsequent draw calls will use this uniform data. * - * \param commandBuffer a command buffer. - * \param slotIndex the vertex uniform slot to push data to. + * \param command_buffer a command buffer. + * \param slot_index the vertex uniform slot to push data to. * \param data client data to write. - * \param dataLengthInBytes the length of the data to write. + * \param length the length of the data to write. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData( - SDL_GPUCommandBuffer *commandBuffer, - Uint32 slotIndex, + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, const void *data, - Uint32 dataLengthInBytes); + Uint32 length); /** * Pushes data to a fragment uniform slot on the command buffer. * * Subsequent draw calls will use this uniform data. * - * \param commandBuffer a command buffer. - * \param slotIndex the fragment uniform slot to push data to. + * \param command_buffer a command buffer. + * \param slot_index the fragment uniform slot to push data to. * \param data client data to write. - * \param dataLengthInBytes the length of the data to write. + * \param length the length of the data to write. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData( - SDL_GPUCommandBuffer *commandBuffer, - Uint32 slotIndex, + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, const void *data, - Uint32 dataLengthInBytes); + Uint32 length); /** * Pushes data to a uniform slot on the command buffer. * * Subsequent draw calls will use this uniform data. * - * \param commandBuffer a command buffer. - * \param slotIndex the uniform slot to push data to. + * \param command_buffer a command buffer. + * \param slot_index the uniform slot to push data to. * \param data client data to write. - * \param dataLengthInBytes the length of the data to write. + * \param length the length of the data to write. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData( - SDL_GPUCommandBuffer *commandBuffer, - Uint32 slotIndex, + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, const void *data, - Uint32 dataLengthInBytes); + Uint32 length); /* * A NOTE ON CYCLING @@ -2053,7 +2044,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData( * to worry about overwriting any data that is not yet uploaded. * * Another example: If you are using a texture in a render pass every frame, this can cause a data dependency between frames. - * If you set cycle to SDL_TRUE in the ColorAttachmentInfo struct, you can prevent this data dependency. + * If you set cycle to SDL_TRUE in the SDL_GPUColorTargetInfo struct, you can prevent this data dependency. * * Cycling will never undefine already bound data. * When cycling, all data in the resource is considered to be undefined for subsequent commands until that data is written again. @@ -2081,12 +2072,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData( * is called. You cannot begin another render pass, or begin a compute pass or * copy pass until you have ended the render pass. * - * \param commandBuffer a command buffer. - * \param colorAttachmentInfos an array of texture subresources with + * \param command_buffer a command buffer. + * \param color_target_infos an array of texture subresources with * corresponding clear values and load/store ops. - * \param colorAttachmentCount the number of color attachments in the - * colorAttachmentInfos array. - * \param depthStencilAttachmentInfo a texture subresource with corresponding + * \param num_color_targets the number of color targets in the + * color_target_infos array. + * \param depth_stencil_target_info a texture subresource with corresponding * clear value and load/store ops, may be * NULL. * \returns a render pass handle. @@ -2096,54 +2087,54 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData( * \sa SDL_EndGPURenderPass */ extern SDL_DECLSPEC SDL_GPURenderPass *SDLCALL SDL_BeginGPURenderPass( - SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo); + SDL_GPUCommandBuffer *command_buffer, + const SDL_GPUColorTargetInfo *color_target_infos, + Uint32 num_color_targets, + const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info); /** * Binds a graphics pipeline on a render pass to be used in rendering. * * A graphics pipeline must be bound before making any draw calls. * - * \param renderPass a render pass handle. - * \param graphicsPipeline the graphics pipeline to bind. + * \param render_pass a render pass handle. + * \param graphics_pipeline the graphics pipeline to bind. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline( - SDL_GPURenderPass *renderPass, - SDL_GPUGraphicsPipeline *graphicsPipeline); + SDL_GPURenderPass *render_pass, + SDL_GPUGraphicsPipeline *graphics_pipeline); /** * Sets the current viewport state on a command buffer. * - * \param renderPass a render pass handle. + * \param render_pass a render pass handle. * \param viewport the viewport to set. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUViewport( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, const SDL_GPUViewport *viewport); /** * Sets the current scissor state on a command buffer. * - * \param renderPass a render pass handle. + * \param render_pass a render pass handle. * \param scissor the scissor area to set. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, const SDL_Rect *scissor); /** * Sets the current blend constants on a command buffer. * - * \param renderPass a render pass handle. - * \param blendConstants the blend constant color. + * \param render_pass a render pass handle. + * \param blend_constants the blend constant color. * * \since This function is available since SDL 3.0.0. * @@ -2151,74 +2142,74 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor( * \sa SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBlendConstants( - SDL_GPURenderPass *renderPass, - SDL_FColor blendConstants); + SDL_GPURenderPass *render_pass, + SDL_FColor blend_constants); /** * Sets the current stencil reference value on a command buffer. * - * \param renderPass a render pass handle. + * \param render_pass a render pass handle. * \param reference the stencil reference value to set. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUStencilReference( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, Uint8 reference); /** * Binds vertex buffers on a command buffer for use with subsequent draw * calls. * - * \param renderPass a render pass handle. - * \param firstBinding the starting bind point for the vertex buffers. - * \param pBindings an array of SDL_GPUBufferBinding structs containing vertex + * \param render_pass a render pass handle. + * \param first_binding the starting bind point for the vertex buffers. + * \param bindings an array of SDL_GPUBufferBinding structs containing vertex * buffers and offset values. - * \param bindingCount the number of bindings in the pBindings array. + * \param num_bindings the number of bindings in the bindings array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers( - SDL_GPURenderPass *renderPass, - Uint32 firstBinding, - const SDL_GPUBufferBinding *pBindings, - Uint32 bindingCount); + SDL_GPURenderPass *render_pass, + Uint32 first_binding, + const SDL_GPUBufferBinding *bindings, + Uint32 num_bindings); /** * Binds an index buffer on a command buffer for use with subsequent draw * calls. * - * \param renderPass a render pass handle. - * \param pBinding a pointer to a struct containing an index buffer and + * \param render_pass a render pass handle. + * \param binding a pointer to a struct containing an index buffer and * offset. - * \param indexElementSize whether the index values in the buffer are 16- or + * \param index_element_size whether the index values in the buffer are 16- or * 32-bit. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer( - SDL_GPURenderPass *renderPass, - const SDL_GPUBufferBinding *pBinding, - SDL_GPUIndexElementSize indexElementSize); + SDL_GPURenderPass *render_pass, + const SDL_GPUBufferBinding *binding, + SDL_GPUIndexElementSize index_element_size); /** * Binds texture-sampler pairs for use on the vertex shader. * * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. * - * \param renderPass a render pass handle. - * \param firstSlot the vertex sampler slot to begin binding from. - * \param textureSamplerBindings an array of texture-sampler binding structs. - * \param bindingCount the number of texture-sampler pairs to bind from the + * \param render_pass a render pass handle. + * \param first_slot the vertex sampler slot to begin binding from. + * \param texture_sampler_bindings an array of texture-sampler binding structs. + * \param num_bindings the number of texture-sampler pairs to bind from the * array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount); + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, + Uint32 num_bindings); /** * Binds storage textures for use on the vertex shader. @@ -2226,18 +2217,18 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers( * These textures must have been created with * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ. * - * \param renderPass a render pass handle. - * \param firstSlot the vertex storage texture slot to begin binding from. - * \param storageTextures an array of storage textures. - * \param bindingCount the number of storage texture to bind from the array. + * \param render_pass a render pass handle. + * \param first_slot the vertex storage texture slot to begin binding from. + * \param storage_textures an array of storage textures. + * \param num_bindings the number of storage texture to bind from the array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount); + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings); /** * Binds storage buffers for use on the vertex shader. @@ -2245,37 +2236,37 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures( * These buffers must have been created with * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ. * - * \param renderPass a render pass handle. - * \param firstSlot the vertex storage buffer slot to begin binding from. - * \param storageBuffers an array of buffers. - * \param bindingCount the number of buffers to bind from the array. + * \param render_pass a render pass handle. + * \param first_slot the vertex storage buffer slot to begin binding from. + * \param storage_buffers an array of buffers. + * \param num_bindings the number of buffers to bind from the array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount); + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings); /** * Binds texture-sampler pairs for use on the fragment shader. * * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. * - * \param renderPass a render pass handle. - * \param firstSlot the fragment sampler slot to begin binding from. - * \param textureSamplerBindings an array of texture-sampler binding structs. - * \param bindingCount the number of texture-sampler pairs to bind from the + * \param render_pass a render pass handle. + * \param first_slot the fragment sampler slot to begin binding from. + * \param texture_sampler_bindings an array of texture-sampler binding structs. + * \param num_bindings the number of texture-sampler pairs to bind from the * array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount); + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, + Uint32 num_bindings); /** * Binds storage textures for use on the fragment shader. @@ -2283,18 +2274,18 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers( * These textures must have been created with * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ. * - * \param renderPass a render pass handle. - * \param firstSlot the fragment storage texture slot to begin binding from. - * \param storageTextures an array of storage textures. - * \param bindingCount the number of storage textures to bind from the array. + * \param render_pass a render pass handle. + * \param first_slot the fragment storage texture slot to begin binding from. + * \param storage_textures an array of storage textures. + * \param num_bindings the number of storage textures to bind from the array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount); + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings); /** * Binds storage buffers for use on the fragment shader. @@ -2302,18 +2293,18 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures( * These buffers must have been created with * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ. * - * \param renderPass a render pass handle. - * \param firstSlot the fragment storage buffer slot to begin binding from. - * \param storageBuffers an array of storage buffers. - * \param bindingCount the number of storage buffers to bind from the array. + * \param render_pass a render pass handle. + * \param first_slot the fragment storage buffer slot to begin binding from. + * \param storage_buffers an array of storage buffers. + * \param num_bindings the number of storage buffers to bind from the array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount); + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings); /* Drawing */ @@ -2323,53 +2314,53 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers( * * You must not call this function before binding a graphics pipeline. * - * Note that the `firstVertex` and `firstInstance` parameters are NOT + * Note that the `first_vertex` and `first_instance` parameters are NOT * compatible with built-in vertex/instance ID variables in shaders (for * example, SV_VertexID). If your shader depends on these variables, the * correlating draw call parameter MUST be 0. * - * \param renderPass a render pass handle. - * \param indexCount the number of vertices to draw per instance. - * \param instanceCount the number of instances to draw. - * \param firstIndex the starting index within the index buffer. - * \param vertexOffset value added to vertex index before indexing into the + * \param render_pass a render pass handle. + * \param num_indices the number of vertices to draw per instance. + * \param num_instances the number of instances to draw. + * \param first_index the starting index within the index buffer. + * \param vertex_offset value added to vertex index before indexing into the * vertex buffer. - * \param firstInstance the ID of the first instance to draw. + * \param first_instance the ID of the first instance to draw. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives( - SDL_GPURenderPass *renderPass, - Uint32 indexCount, - Uint32 instanceCount, - Uint32 firstIndex, - Sint32 vertexOffset, - Uint32 firstInstance); + SDL_GPURenderPass *render_pass, + Uint32 num_indices, + Uint32 num_instances, + Uint32 first_index, + Sint32 vertex_offset, + Uint32 first_instance); /** * Draws data using bound graphics state. * * You must not call this function before binding a graphics pipeline. * - * Note that the `firstVertex` and `firstInstance` parameters are NOT + * Note that the `first_vertex` and `first_instance` parameters are NOT * compatible with built-in vertex/instance ID variables in shaders (for * example, SV_VertexID). If your shader depends on these variables, the * correlating draw call parameter MUST be 0. * - * \param renderPass a render pass handle. - * \param vertexCount the number of vertices to draw. - * \param instanceCount the number of instances that will be drawn. - * \param firstVertex the index of the first vertex to draw. - * \param firstInstance the ID of the first instance to draw. + * \param render_pass a render pass handle. + * \param num_vertices the number of vertices to draw. + * \param num_instances the number of instances that will be drawn. + * \param first_vertex the index of the first vertex to draw. + * \param first_instance the ID of the first instance to draw. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives( - SDL_GPURenderPass *renderPass, - Uint32 vertexCount, - Uint32 instanceCount, - Uint32 firstVertex, - Uint32 firstInstance); + SDL_GPURenderPass *render_pass, + Uint32 num_vertices, + Uint32 num_instances, + Uint32 first_vertex, + Uint32 first_instance); /** * Draws data using bound graphics state and with draw parameters set from a @@ -2378,21 +2369,21 @@ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives( * The buffer layout should match the layout of SDL_GPUIndirectDrawCommand. * You must not call this function before binding a graphics pipeline. * - * \param renderPass a render pass handle. + * \param render_pass a render pass handle. * \param buffer a buffer containing draw parameters. - * \param offsetInBytes the offset to start reading from the draw buffer. - * \param drawCount the number of draw parameter sets that should be read from + * \param offset the offset to start reading from the draw buffer. + * \param draw_count the number of draw parameter sets that should be read from * the draw buffer. - * \param stride the byte stride between sets of draw parameters. + * \param pitch the byte pitch between sets of draw parameters. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, - Uint32 drawCount, - Uint32 stride); + Uint32 offset, + Uint32 draw_count, + Uint32 pitch); /** * Draws data using bound graphics state with an index buffer enabled and with @@ -2402,21 +2393,21 @@ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect( * SDL_GPUIndexedIndirectDrawCommand. You must not call this function before * binding a graphics pipeline. * - * \param renderPass a render pass handle. + * \param render_pass a render pass handle. * \param buffer a buffer containing draw parameters. - * \param offsetInBytes the offset to start reading from the draw buffer. - * \param drawCount the number of draw parameter sets that should be read from + * \param offset the offset to start reading from the draw buffer. + * \param draw_count the number of draw parameter sets that should be read from * the draw buffer. - * \param stride the byte stride between sets of draw parameters. + * \param pitch the byte pitch between sets of draw parameters. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, - Uint32 drawCount, - Uint32 stride); + Uint32 offset, + Uint32 draw_count, + Uint32 pitch); /** * Ends the given render pass. @@ -2424,12 +2415,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect( * All bound graphics state on the render pass command buffer is unset. The * render pass handle is now invalid. * - * \param renderPass a render pass handle. + * \param render_pass a render pass handle. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass( - SDL_GPURenderPass *renderPass); + SDL_GPURenderPass *render_pass); /* Compute Pass */ @@ -2449,14 +2440,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass( * dispatch, you MUST end the current compute pass and begin a new one before * you can safely access the data. * - * \param commandBuffer a command buffer. - * \param storageTextureBindings an array of writeable storage texture binding + * \param command_buffer a command buffer. + * \param storage_texture_bindings an array of writeable storage texture binding * structs. - * \param storageTextureBindingCount the number of storage textures to bind + * \param num_storage_texture_bindings the number of storage textures to bind * from the array. - * \param storageBufferBindings an array of writeable storage buffer binding + * \param storage_buffer_bindings an array of writeable storage buffer binding * structs. - * \param storageBufferBindingCount the number of storage buffers to bind from + * \param num_storage_buffer_bindings the number of storage buffers to bind from * the array. * \returns a compute pass handle. * @@ -2465,23 +2456,23 @@ extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass( * \sa SDL_EndGPUComputePass */ extern SDL_DECLSPEC SDL_GPUComputePass *SDLCALL SDL_BeginGPUComputePass( - SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings, - Uint32 storageTextureBindingCount, - const SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings, - Uint32 storageBufferBindingCount); + SDL_GPUCommandBuffer *command_buffer, + const SDL_GPUStorageTextureWriteOnlyBinding *storage_texture_bindings, + Uint32 num_storage_texture_bindings, + const SDL_GPUStorageBufferWriteOnlyBinding *storage_buffer_bindings, + Uint32 num_storage_buffer_bindings); /** * Binds a compute pipeline on a command buffer for use in compute dispatch. * - * \param computePass a compute pass handle. - * \param computePipeline a compute pipeline to bind. + * \param compute_pass a compute pass handle. + * \param compute_pipeline a compute pipeline to bind. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline( - SDL_GPUComputePass *computePass, - SDL_GPUComputePipeline *computePipeline); + SDL_GPUComputePass *compute_pass, + SDL_GPUComputePipeline *compute_pipeline); /** * Binds storage textures as readonly for use on the compute pipeline. @@ -2489,18 +2480,18 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline( * These textures must have been created with * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ. * - * \param computePass a compute pass handle. - * \param firstSlot the compute storage texture slot to begin binding from. - * \param storageTextures an array of storage textures. - * \param bindingCount the number of storage textures to bind from the array. + * \param compute_pass a compute pass handle. + * \param first_slot the compute storage texture slot to begin binding from. + * \param storage_textures an array of storage textures. + * \param num_bindings the number of storage textures to bind from the array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures( - SDL_GPUComputePass *computePass, - Uint32 firstSlot, - SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount); + SDL_GPUComputePass *compute_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings); /** * Binds storage buffers as readonly for use on the compute pipeline. @@ -2508,18 +2499,18 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures( * These buffers must have been created with * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ. * - * \param computePass a compute pass handle. - * \param firstSlot the compute storage buffer slot to begin binding from. - * \param storageBuffers an array of storage buffer binding structs. - * \param bindingCount the number of storage buffers to bind from the array. + * \param compute_pass a compute pass handle. + * \param first_slot the compute storage buffer slot to begin binding from. + * \param storage_buffers an array of storage buffer binding structs. + * \param num_bindings the number of storage buffers to bind from the array. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers( - SDL_GPUComputePass *computePass, - Uint32 firstSlot, - SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount); + SDL_GPUComputePass *compute_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings); /** * Dispatches compute work. @@ -2531,21 +2522,21 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers( * guarantee of which order the writes will occur. If the write order matters, * you MUST end the compute pass and begin another one. * - * \param computePass a compute pass handle. - * \param groupCountX number of local workgroups to dispatch in the X + * \param compute_pass a compute pass handle. + * \param groupcount_x number of local workgroups to dispatch in the X * dimension. - * \param groupCountY number of local workgroups to dispatch in the Y + * \param groupcount_y number of local workgroups to dispatch in the Y * dimension. - * \param groupCountZ number of local workgroups to dispatch in the Z + * \param groupcount_z number of local workgroups to dispatch in the Z * dimension. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute( - SDL_GPUComputePass *computePass, - Uint32 groupCountX, - Uint32 groupCountY, - Uint32 groupCountZ); + SDL_GPUComputePass *compute_pass, + Uint32 groupcount_x, + Uint32 groupcount_y, + Uint32 groupcount_z); /** * Dispatches compute work with parameters set from a buffer. @@ -2559,16 +2550,16 @@ extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute( * guarantee of which order the writes will occur. If the write order matters, * you MUST end the compute pass and begin another one. * - * \param computePass a compute pass handle. + * \param compute_pass a compute pass handle. * \param buffer a buffer containing dispatch parameters. - * \param offsetInBytes the offset to start reading from the dispatch buffer. + * \param offset the offset to start reading from the dispatch buffer. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect( - SDL_GPUComputePass *computePass, + SDL_GPUComputePass *compute_pass, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes); + Uint32 offset); /** * Ends the current compute pass. @@ -2576,12 +2567,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect( * All bound compute state on the command buffer is unset. The compute pass * handle is now invalid. * - * \param computePass a compute pass handle. + * \param compute_pass a compute pass handle. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass( - SDL_GPUComputePass *computePass); + SDL_GPUComputePass *compute_pass); /* TransferBuffer Data */ @@ -2591,7 +2582,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass( * You must unmap the transfer buffer before encoding upload commands. * * \param device a GPU context. - * \param transferBuffer a transfer buffer. + * \param transfer_buffer a transfer buffer. * \param cycle if SDL_TRUE, cycles the transfer buffer if it is bound. * \returns the address of the mapped transfer buffer memory. * @@ -2599,20 +2590,20 @@ extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass( */ extern SDL_DECLSPEC void *SDLCALL SDL_MapGPUTransferBuffer( SDL_GPUDevice *device, - SDL_GPUTransferBuffer *transferBuffer, + SDL_GPUTransferBuffer *transfer_buffer, SDL_bool cycle); /** * Unmaps a previously mapped transfer buffer. * * \param device a GPU context. - * \param transferBuffer a previously mapped transfer buffer. + * \param transfer_buffer a previously mapped transfer buffer. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer( SDL_GPUDevice *device, - SDL_GPUTransferBuffer *transferBuffer); + SDL_GPUTransferBuffer *transfer_buffer); /* Copy Pass */ @@ -2623,13 +2614,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer( * inside a copy pass. You must not begin another copy pass, or a render pass * or compute pass before ending the copy pass. * - * \param commandBuffer a command buffer. + * \param command_buffer a command buffer. * \returns a copy pass handle. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC SDL_GPUCopyPass *SDLCALL SDL_BeginGPUCopyPass( - SDL_GPUCommandBuffer *commandBuffer); + SDL_GPUCommandBuffer *command_buffer); /** * Uploads data from a transfer buffer to a texture. @@ -2640,7 +2631,7 @@ extern SDL_DECLSPEC SDL_GPUCopyPass *SDLCALL SDL_BeginGPUCopyPass( * You must align the data in the transfer buffer to a multiple of the texel * size of the texture format. * - * \param copyPass a copy pass handle. + * \param copy_pass a copy pass handle. * \param source the source transfer buffer with image layout information. * \param destination the destination texture region. * \param cycle if SDL_TRUE, cycles the texture if the texture is bound, @@ -2649,7 +2640,7 @@ extern SDL_DECLSPEC SDL_GPUCopyPass *SDLCALL SDL_BeginGPUCopyPass( * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureTransferInfo *source, const SDL_GPUTextureRegion *destination, SDL_bool cycle); @@ -2662,7 +2653,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture( * The upload occurs on the GPU timeline. You may assume that the upload has * finished in subsequent commands. * - * \param copyPass a copy pass handle. + * \param copy_pass a copy pass handle. * \param source the source transfer buffer with offset. * \param destination the destination buffer with offset and size. * \param cycle if SDL_TRUE, cycles the buffer if it is bound, otherwise @@ -2671,7 +2662,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture( * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUTransferBufferLocation *source, const SDL_GPUBufferRegion *destination, SDL_bool cycle); @@ -2682,7 +2673,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer( * This copy occurs on the GPU timeline. You may assume the copy has finished * in subsequent commands. * - * \param copyPass a copy pass handle. + * \param copy_pass a copy pass handle. * \param source a source texture region. * \param destination a destination texture region. * \param w the width of the region to copy. @@ -2694,7 +2685,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer( * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureLocation *source, const SDL_GPUTextureLocation *destination, Uint32 w, @@ -2710,7 +2701,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture( * This copy occurs on the GPU timeline. You may assume the copy has finished * in subsequent commands. * - * \param copyPass a copy pass handle. + * \param copy_pass a copy pass handle. * \param source the buffer and offset to copy from. * \param destination the buffer and offset to copy to. * \param size the length of the buffer to copy. @@ -2720,7 +2711,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture( * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferLocation *source, const SDL_GPUBufferLocation *destination, Uint32 size, @@ -2732,7 +2723,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer( * This data is not guaranteed to be copied until the command buffer fence is * signaled. * - * \param copyPass a copy pass handle. + * \param copy_pass a copy pass handle. * \param source the source texture region. * \param destination the destination transfer buffer with image layout * information. @@ -2740,7 +2731,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer( * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureRegion *source, const SDL_GPUTextureTransferInfo *destination); @@ -2750,39 +2741,39 @@ extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture( * This data is not guaranteed to be copied until the command buffer fence is * signaled. * - * \param copyPass a copy pass handle. + * \param copy_pass a copy pass handle. * \param source the source buffer with offset and size. * \param destination the destination transfer buffer with offset. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferRegion *source, const SDL_GPUTransferBufferLocation *destination); /** * Ends the current copy pass. * - * \param copyPass a copy pass handle. + * \param copy_pass a copy pass handle. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass( - SDL_GPUCopyPass *copyPass); + SDL_GPUCopyPass *copy_pass); /** * Generates mipmaps for the given texture. * * This function must not be called inside of any pass. * - * \param commandBuffer a commandBuffer. + * \param command_buffer a command_buffer. * \param texture a texture with more than 1 mip level. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, SDL_GPUTexture *texture); /** @@ -2790,22 +2781,22 @@ extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture( * * This function must not be called inside of any pass. * - * \param commandBuffer a command buffer. + * \param command_buffer a command buffer. * \param source the texture region to copy from. * \param destination the texture region to copy to. - * \param flipMode the flip mode for the source texture region. - * \param filterMode the filter mode that will be used when blitting. + * \param flip_mode the flip mode for the source texture region. + * \param filter the filter mode that will be used when blitting. * \param cycle if SDL_TRUE, cycles the destination texture if the destination * texture is bound, otherwise overwrites the data. * * \since This function is available since SDL 3.0.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, - SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_FlipMode flip_mode, + SDL_GPUFilter filter, SDL_bool cycle); /* Submission/Presentation */ @@ -2817,7 +2808,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture( * * \param device a GPU context. * \param window an SDL_Window. - * \param swapchainComposition the swapchain composition to check. + * \param swapchain_composition the swapchain composition to check. * \returns SDL_TRUE if supported, SDL_FALSE if unsupported (or on error). * * \since This function is available since SDL 3.0.0. @@ -2827,7 +2818,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture( extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition( SDL_GPUDevice *device, SDL_Window *window, - SDL_GPUSwapchainComposition swapchainComposition); + SDL_GPUSwapchainComposition swapchain_composition); /** * Determines whether a presentation mode is supported by the window. @@ -2836,7 +2827,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition( * * \param device a GPU context. * \param window an SDL_Window. - * \param presentMode the presentation mode to check. + * \param present_mode the presentation mode to check. * \returns SDL_TRUE if supported, SDL_FALSE if unsupported (or on error). * * \since This function is available since SDL 3.0.0. @@ -2846,7 +2837,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition( extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowSupportsGPUPresentMode( SDL_GPUDevice *device, SDL_Window *window, - SDL_GPUPresentMode presentMode); + SDL_GPUPresentMode present_mode); /** * Claims a window, creating a swapchain structure for it. @@ -2901,8 +2892,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice( * * \param device a GPU context. * \param window an SDL_Window that has been claimed. - * \param swapchainComposition the desired composition of the swapchain. - * \param presentMode the desired present mode for the swapchain. + * \param swapchain_composition the desired composition of the swapchain. + * \param present_mode the desired present mode for the swapchain. * \returns SDL_TRUE if successful, SDL_FALSE on error. * * \since This function is available since SDL 3.0.0. @@ -2913,8 +2904,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice( extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetGPUSwapchainParameters( SDL_GPUDevice *device, SDL_Window *window, - SDL_GPUSwapchainComposition swapchainComposition, - SDL_GPUPresentMode presentMode); + SDL_GPUSwapchainComposition swapchain_composition, + SDL_GPUPresentMode present_mode); /** * Obtains the texture format of the swapchain for the given window. @@ -2940,10 +2931,10 @@ extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureForma * and must not be freed by the user. You MUST NOT call this function from any * thread other than the one that created the window. * - * \param commandBuffer a command buffer. + * \param command_buffer a command buffer. * \param window a window that has been claimed. - * \param pWidth a pointer filled in with the swapchain width. - * \param pHeight a pointer filled in with the swapchain height. + * \param w a pointer filled in with the swapchain width. + * \param h a pointer filled in with the swapchain height. * \returns a swapchain texture. * * \since This function is available since SDL 3.0.0. @@ -2953,10 +2944,10 @@ extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureForma * \sa SDL_SubmitGPUCommandBufferAndAcquireFence */ extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_AcquireGPUSwapchainTexture( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, SDL_Window *window, - Uint32 *pWidth, - Uint32 *pHeight); + Uint32 *w, + Uint32 *h); /** * Submits a command buffer so its commands can be processed on the GPU. @@ -2968,7 +2959,7 @@ extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_AcquireGPUSwapchainTexture( * All commands in the submission are guaranteed to begin executing before any * command in a subsequent submission begins executing. * - * \param commandBuffer a command buffer. + * \param command_buffer a command buffer. * * \since This function is available since SDL 3.0.0. * @@ -2977,7 +2968,7 @@ extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_AcquireGPUSwapchainTexture( * \sa SDL_SubmitGPUCommandBufferAndAcquireFence */ extern SDL_DECLSPEC void SDLCALL SDL_SubmitGPUCommandBuffer( - SDL_GPUCommandBuffer *commandBuffer); + SDL_GPUCommandBuffer *command_buffer); /** * Submits a command buffer so its commands can be processed on the GPU, and @@ -2991,7 +2982,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_SubmitGPUCommandBuffer( * All commands in the submission are guaranteed to begin executing before any * command in a subsequent submission begins executing. * - * \param commandBuffer a command buffer. + * \param command_buffer a command buffer. * \returns a fence associated with the command buffer. * * \since This function is available since SDL 3.0.0. @@ -3002,7 +2993,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_SubmitGPUCommandBuffer( * \sa SDL_ReleaseGPUFence */ extern SDL_DECLSPEC SDL_GPUFence *SDLCALL SDL_SubmitGPUCommandBufferAndAcquireFence( - SDL_GPUCommandBuffer *commandBuffer); + SDL_GPUCommandBuffer *command_buffer); /** * Blocks the thread until the GPU is completely idle. @@ -3020,10 +3011,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUIdle( * Blocks the thread until the given fences are signaled. * * \param device a GPU context. - * \param waitAll if 0, wait for any fence to be signaled, if 1, wait for all + * \param wait_all if 0, wait for any fence to be signaled, if 1, wait for all * fences to be signaled. - * \param pFences an array of fences to wait on. - * \param fenceCount the number of fences in the pFences array. + * \param fences an array of fences to wait on. + * \param num_fences the number of fences in the fences array. * * \since This function is available since SDL 3.0.0. * @@ -3032,9 +3023,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUIdle( */ extern SDL_DECLSPEC void SDLCALL SDL_WaitForGPUFences( SDL_GPUDevice *device, - SDL_bool waitAll, - SDL_GPUFence *const *pFences, - Uint32 fenceCount); + SDL_bool wait_all, + SDL_GPUFence *const *fences, + Uint32 num_fences); /** * Checks the status of a fence. @@ -3070,7 +3061,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence( /** * Obtains the texel block size for a texture format. * - * \param textureFormat the texture format you want to know the texel size of. + * \param format the texture format you want to know the texel size of. * \returns the texel block size of the texture format. * * \since This function is available since SDL 3.0.0. @@ -3078,7 +3069,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence( * \sa SDL_UploadToGPUTexture */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GPUTextureFormatTexelBlockSize( - SDL_GPUTextureFormat textureFormat); + SDL_GPUTextureFormat format); /** * Determines whether a texture format is supported for a given type and @@ -3103,7 +3094,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsFormat( * * \param device a GPU context. * \param format the texture format to check. - * \param sampleCount the sample count to check. + * \param sample_count the sample count to check. * \returns a hardware-specific version of min(preferred, possible). * * \since This function is available since SDL 3.0.0. @@ -3111,7 +3102,7 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsFormat( extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GPUTextureSupportsSampleCount( SDL_GPUDevice *device, SDL_GPUTextureFormat format, - SDL_GPUSampleCount sampleCount); + SDL_GPUSampleCount sample_count); #ifdef SDL_PLATFORM_GDK diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index d7364bc978..d65faa6151 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -70,7 +70,7 @@ SDL_DYNAPI_PROC(SDL_JoystickID,SDL_AttachVirtualJoystick,(const SDL_VirtualJoyst SDL_DYNAPI_PROC(SDL_bool,SDL_AudioDevicePaused,(SDL_AudioDeviceID a),(a),return) SDL_DYNAPI_PROC(SDL_GPUComputePass*,SDL_BeginGPUComputePass,(SDL_GPUCommandBuffer *a, const SDL_GPUStorageTextureWriteOnlyBinding *b, Uint32 c, const SDL_GPUStorageBufferWriteOnlyBinding *d, Uint32 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_GPUCopyPass*,SDL_BeginGPUCopyPass,(SDL_GPUCommandBuffer *a),(a),return) -SDL_DYNAPI_PROC(SDL_GPURenderPass*,SDL_BeginGPURenderPass,(SDL_GPUCommandBuffer *a, const SDL_GPUColorAttachmentInfo *b, Uint32 c, const SDL_GPUDepthStencilAttachmentInfo *d),(a,b,c,d),return) +SDL_DYNAPI_PROC(SDL_GPURenderPass*,SDL_BeginGPURenderPass,(SDL_GPUCommandBuffer *a, const SDL_GPUColorTargetInfo *b, Uint32 c, const SDL_GPUDepthStencilTargetInfo *d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_bool,SDL_BindAudioStream,(SDL_AudioDeviceID a, SDL_AudioStream *b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_BindAudioStreams,(SDL_AudioDeviceID a, SDL_AudioStream **b, int c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_BindGPUComputePipeline,(SDL_GPUComputePass *a, SDL_GPUComputePipeline *b),(a,b),) diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c index 8f8a3593fe..6e4d275b43 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -29,52 +29,52 @@ } #define CHECK_COMMAND_BUFFER \ - if (((CommandBufferCommonHeader *)commandBuffer)->submitted) { \ + if (((CommandBufferCommonHeader *)command_buffer)->submitted) { \ SDL_assert_release(!"Command buffer already submitted!"); \ return; \ } #define CHECK_COMMAND_BUFFER_RETURN_NULL \ - if (((CommandBufferCommonHeader *)commandBuffer)->submitted) { \ + if (((CommandBufferCommonHeader *)command_buffer)->submitted) { \ SDL_assert_release(!"Command buffer already submitted!"); \ return NULL; \ } #define CHECK_ANY_PASS_IN_PROGRESS(msg, retval) \ if ( \ - ((CommandBufferCommonHeader *)commandBuffer)->renderPass.inProgress || \ - ((CommandBufferCommonHeader *)commandBuffer)->computePass.inProgress || \ - ((CommandBufferCommonHeader *)commandBuffer)->copyPass.inProgress) { \ + ((CommandBufferCommonHeader *)command_buffer)->render_pass.in_progress || \ + ((CommandBufferCommonHeader *)command_buffer)->compute_pass.in_progress || \ + ((CommandBufferCommonHeader *)command_buffer)->copy_pass.in_progress) { \ SDL_assert_release(!msg); \ return retval; \ } #define CHECK_RENDERPASS \ - if (!((Pass *)renderPass)->inProgress) { \ + if (!((Pass *)render_pass)->in_progress) { \ SDL_assert_release(!"Render pass not in progress!"); \ return; \ } #define CHECK_GRAPHICS_PIPELINE_BOUND \ - if (!((CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER)->graphicsPipelineBound) { \ + if (!((CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER)->graphics_pipeline_bound) { \ SDL_assert_release(!"Graphics pipeline not bound!"); \ return; \ } #define CHECK_COMPUTEPASS \ - if (!((Pass *)computePass)->inProgress) { \ + if (!((Pass *)compute_pass)->in_progress) { \ SDL_assert_release(!"Compute pass not in progress!"); \ return; \ } #define CHECK_COMPUTE_PIPELINE_BOUND \ - if (!((CommandBufferCommonHeader *)COMPUTEPASS_COMMAND_BUFFER)->computePipelineBound) { \ + if (!((CommandBufferCommonHeader *)COMPUTEPASS_COMMAND_BUFFER)->compute_pipeline_bound) { \ SDL_assert_release(!"Compute pipeline not bound!"); \ return; \ } #define CHECK_COPYPASS \ - if (!((Pass *)copyPass)->inProgress) { \ + if (!((Pass *)copy_pass)->in_progress) { \ SDL_assert_release(!"Copy pass not in progress!"); \ return; \ } @@ -98,22 +98,22 @@ } #define COMMAND_BUFFER_DEVICE \ - ((CommandBufferCommonHeader *)commandBuffer)->device + ((CommandBufferCommonHeader *)command_buffer)->device #define RENDERPASS_COMMAND_BUFFER \ - ((Pass *)renderPass)->commandBuffer + ((Pass *)render_pass)->command_buffer #define RENDERPASS_DEVICE \ ((CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER)->device #define COMPUTEPASS_COMMAND_BUFFER \ - ((Pass *)computePass)->commandBuffer + ((Pass *)compute_pass)->command_buffer #define COMPUTEPASS_DEVICE \ ((CommandBufferCommonHeader *)COMPUTEPASS_COMMAND_BUFFER)->device #define COPYPASS_COMMAND_BUFFER \ - ((Pass *)copyPass)->commandBuffer + ((Pass *)copy_pass)->command_buffer #define COPYPASS_DEVICE \ ((CommandBufferCommonHeader *)COPYPASS_COMMAND_BUFFER)->device @@ -140,63 +140,63 @@ static const SDL_GPUBootstrap *backends[] = { SDL_GPUGraphicsPipeline *SDL_GPU_FetchBlitPipeline( SDL_GPUDevice *device, - SDL_GPUTextureType sourceTextureType, - SDL_GPUTextureFormat destinationFormat, - SDL_GPUShader *blitVertexShader, - SDL_GPUShader *blitFrom2DShader, - SDL_GPUShader *blitFrom2DArrayShader, - SDL_GPUShader *blitFrom3DShader, - SDL_GPUShader *blitFromCubeShader, - BlitPipelineCacheEntry **blitPipelines, - Uint32 *blitPipelineCount, - Uint32 *blitPipelineCapacity) + SDL_GPUTextureType source_texture_type, + SDL_GPUTextureFormat destination_format, + SDL_GPUShader *blit_vertex_shader, + SDL_GPUShader *blit_from_2d_shader, + SDL_GPUShader *blit_from_2d_array_shader, + SDL_GPUShader *blit_from_3d_shader, + SDL_GPUShader *blit_from_cube_shader, + BlitPipelineCacheEntry **blit_pipelines, + Uint32 *blit_pipeline_count, + Uint32 *blit_pipeline_capacity) { - SDL_GPUGraphicsPipelineCreateInfo blitPipelineCreateInfo; - SDL_GPUColorAttachmentDescription colorAttachmentDesc; + SDL_GPUGraphicsPipelineCreateInfo blit_pipeline_create_info; + SDL_GPUColorTargetDescription color_target_desc; SDL_GPUGraphicsPipeline *pipeline; - if (blitPipelineCount == NULL) { + if (blit_pipeline_count == NULL) { // use pre-created, format-agnostic pipelines - return (*blitPipelines)[sourceTextureType].pipeline; + return (*blit_pipelines)[source_texture_type].pipeline; } - for (Uint32 i = 0; i < *blitPipelineCount; i += 1) { - if ((*blitPipelines)[i].type == sourceTextureType && (*blitPipelines)[i].format == destinationFormat) { - return (*blitPipelines)[i].pipeline; + for (Uint32 i = 0; i < *blit_pipeline_count; i += 1) { + if ((*blit_pipelines)[i].type == source_texture_type && (*blit_pipelines)[i].format == destination_format) { + return (*blit_pipelines)[i].pipeline; } } // No pipeline found, we'll need to make one! - SDL_zero(blitPipelineCreateInfo); + SDL_zero(blit_pipeline_create_info); - SDL_zero(colorAttachmentDesc); - colorAttachmentDesc.blendState.colorWriteMask = 0xF; - colorAttachmentDesc.format = destinationFormat; + SDL_zero(color_target_desc); + color_target_desc.blend_state.color_write_mask = 0xF; + color_target_desc.format = destination_format; - blitPipelineCreateInfo.attachmentInfo.colorAttachmentDescriptions = &colorAttachmentDesc; - blitPipelineCreateInfo.attachmentInfo.colorAttachmentCount = 1; - blitPipelineCreateInfo.attachmentInfo.depthStencilFormat = SDL_GPU_TEXTUREFORMAT_D16_UNORM; // arbitrary - blitPipelineCreateInfo.attachmentInfo.hasDepthStencilAttachment = false; + blit_pipeline_create_info.target_info.color_target_descriptions = &color_target_desc; + blit_pipeline_create_info.target_info.num_color_targets = 1; + blit_pipeline_create_info.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D16_UNORM; // arbitrary + blit_pipeline_create_info.target_info.has_depth_stencil_target = false; - blitPipelineCreateInfo.vertexShader = blitVertexShader; - if (sourceTextureType == SDL_GPU_TEXTURETYPE_CUBE) { - blitPipelineCreateInfo.fragmentShader = blitFromCubeShader; - } else if (sourceTextureType == SDL_GPU_TEXTURETYPE_2D_ARRAY) { - blitPipelineCreateInfo.fragmentShader = blitFrom2DArrayShader; - } else if (sourceTextureType == SDL_GPU_TEXTURETYPE_3D) { - blitPipelineCreateInfo.fragmentShader = blitFrom3DShader; + blit_pipeline_create_info.vertex_shader = blit_vertex_shader; + if (source_texture_type == SDL_GPU_TEXTURETYPE_CUBE) { + blit_pipeline_create_info.fragment_shader = blit_from_cube_shader; + } else if (source_texture_type == SDL_GPU_TEXTURETYPE_2D_ARRAY) { + blit_pipeline_create_info.fragment_shader = blit_from_2d_array_shader; + } else if (source_texture_type == SDL_GPU_TEXTURETYPE_3D) { + blit_pipeline_create_info.fragment_shader = blit_from_3d_shader; } else { - blitPipelineCreateInfo.fragmentShader = blitFrom2DShader; + blit_pipeline_create_info.fragment_shader = blit_from_2d_shader; } - blitPipelineCreateInfo.multisampleState.sampleCount = SDL_GPU_SAMPLECOUNT_1; - blitPipelineCreateInfo.multisampleState.sampleMask = 0xFFFFFFFF; + blit_pipeline_create_info.multisample_state.sample_count = SDL_GPU_SAMPLECOUNT_1; + blit_pipeline_create_info.multisample_state.sample_mask = 0xFFFFFFFF; - blitPipelineCreateInfo.primitiveType = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; + blit_pipeline_create_info.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; pipeline = SDL_CreateGPUGraphicsPipeline( device, - &blitPipelineCreateInfo); + &blit_pipeline_create_info); if (pipeline == NULL) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Failed to create graphics pipeline for blit"); @@ -205,89 +205,89 @@ SDL_GPUGraphicsPipeline *SDL_GPU_FetchBlitPipeline( // Cache the new pipeline EXPAND_ARRAY_IF_NEEDED( - (*blitPipelines), + (*blit_pipelines), BlitPipelineCacheEntry, - *blitPipelineCount + 1, - *blitPipelineCapacity, - *blitPipelineCapacity * 2) + *blit_pipeline_count + 1, + *blit_pipeline_capacity, + *blit_pipeline_capacity * 2) - (*blitPipelines)[*blitPipelineCount].pipeline = pipeline; - (*blitPipelines)[*blitPipelineCount].type = sourceTextureType; - (*blitPipelines)[*blitPipelineCount].format = destinationFormat; - *blitPipelineCount += 1; + (*blit_pipelines)[*blit_pipeline_count].pipeline = pipeline; + (*blit_pipelines)[*blit_pipeline_count].type = source_texture_type; + (*blit_pipelines)[*blit_pipeline_count].format = destination_format; + *blit_pipeline_count += 1; return pipeline; } void SDL_GPU_BlitCommon( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, - SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_FlipMode flip_mode, + SDL_GPUFilter filter, bool cycle, - SDL_GPUSampler *blitLinearSampler, - SDL_GPUSampler *blitNearestSampler, - SDL_GPUShader *blitVertexShader, - SDL_GPUShader *blitFrom2DShader, - SDL_GPUShader *blitFrom2DArrayShader, - SDL_GPUShader *blitFrom3DShader, - SDL_GPUShader *blitFromCubeShader, - BlitPipelineCacheEntry **blitPipelines, - Uint32 *blitPipelineCount, - Uint32 *blitPipelineCapacity) + SDL_GPUSampler *blit_linear_sampler, + SDL_GPUSampler *blit_nearest_sampler, + SDL_GPUShader *blit_vertex_shader, + SDL_GPUShader *blit_from_2d_shader, + SDL_GPUShader *blit_from_2d_array_shader, + SDL_GPUShader *blit_from_3d_shader, + SDL_GPUShader *blit_from_cube_shader, + BlitPipelineCacheEntry **blit_pipelines, + Uint32 *blit_pipeline_count, + Uint32 *blit_pipeline_capacity) { - CommandBufferCommonHeader *cmdbufHeader = (CommandBufferCommonHeader *)commandBuffer; - SDL_GPURenderPass *renderPass; - TextureCommonHeader *srcHeader = (TextureCommonHeader *)source->texture; - TextureCommonHeader *dstHeader = (TextureCommonHeader *)destination->texture; - SDL_GPUGraphicsPipeline *blitPipeline; - SDL_GPUColorAttachmentInfo colorAttachmentInfo; + CommandBufferCommonHeader *cmdbufHeader = (CommandBufferCommonHeader *)command_buffer; + SDL_GPURenderPass *render_pass; + TextureCommonHeader *src_header = (TextureCommonHeader *)source->texture; + TextureCommonHeader *dst_header = (TextureCommonHeader *)destination->texture; + SDL_GPUGraphicsPipeline *blit_pipeline; + SDL_GPUColorTargetInfo color_target_info; SDL_GPUViewport viewport; - SDL_GPUTextureSamplerBinding textureSamplerBinding; - BlitFragmentUniforms blitFragmentUniforms; - Uint32 layerDivisor; + SDL_GPUTextureSamplerBinding texture_sampler_binding; + BlitFragmentUniforms blit_fragment_uniforms; + Uint32 layer_divisor; - blitPipeline = SDL_GPU_FetchBlitPipeline( + blit_pipeline = SDL_GPU_FetchBlitPipeline( cmdbufHeader->device, - srcHeader->info.type, - dstHeader->info.format, - blitVertexShader, - blitFrom2DShader, - blitFrom2DArrayShader, - blitFrom3DShader, - blitFromCubeShader, - blitPipelines, - blitPipelineCount, - blitPipelineCapacity); + src_header->info.type, + dst_header->info.format, + blit_vertex_shader, + blit_from_2d_shader, + blit_from_2d_array_shader, + blit_from_3d_shader, + blit_from_cube_shader, + blit_pipelines, + blit_pipeline_count, + blit_pipeline_capacity); - if (blitPipeline == NULL) { + if (blit_pipeline == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_GPU, "Could not fetch blit pipeline"); return; } // If the entire destination is blitted, we don't have to load if ( - dstHeader->info.layerCountOrDepth == 1 && - dstHeader->info.levelCount == 1 && - dstHeader->info.type != SDL_GPU_TEXTURETYPE_3D && - destination->w == dstHeader->info.width && - destination->h == dstHeader->info.height) { - colorAttachmentInfo.loadOp = SDL_GPU_LOADOP_DONT_CARE; + dst_header->info.layer_count_or_depth == 1 && + dst_header->info.num_levels == 1 && + dst_header->info.type != SDL_GPU_TEXTURETYPE_3D && + destination->w == dst_header->info.width && + destination->h == dst_header->info.height) { + color_target_info.load_op = SDL_GPU_LOADOP_DONT_CARE; } else { - colorAttachmentInfo.loadOp = SDL_GPU_LOADOP_LOAD; + color_target_info.load_op = SDL_GPU_LOADOP_LOAD; } - colorAttachmentInfo.storeOp = SDL_GPU_STOREOP_STORE; + color_target_info.store_op = SDL_GPU_STOREOP_STORE; - colorAttachmentInfo.texture = destination->texture; - colorAttachmentInfo.mipLevel = destination->mipLevel; - colorAttachmentInfo.layerOrDepthPlane = destination->layerOrDepthPlane; - colorAttachmentInfo.cycle = cycle; + color_target_info.texture = destination->texture; + color_target_info.mip_level = destination->mip_level; + color_target_info.layer_or_depth_plane = destination->layer_or_depth_plane; + color_target_info.cycle = cycle; - renderPass = SDL_BeginGPURenderPass( - commandBuffer, - &colorAttachmentInfo, + render_pass = SDL_BeginGPURenderPass( + command_buffer, + &color_target_info, 1, NULL); @@ -295,54 +295,54 @@ void SDL_GPU_BlitCommon( viewport.y = (float)destination->y; viewport.w = (float)destination->w; viewport.h = (float)destination->h; - viewport.minDepth = 0; - viewport.maxDepth = 1; + viewport.min_depth = 0; + viewport.max_depth = 1; SDL_SetGPUViewport( - renderPass, + render_pass, &viewport); SDL_BindGPUGraphicsPipeline( - renderPass, - blitPipeline); + render_pass, + blit_pipeline); - textureSamplerBinding.texture = source->texture; - textureSamplerBinding.sampler = - filterMode == SDL_GPU_FILTER_NEAREST ? blitNearestSampler : blitLinearSampler; + texture_sampler_binding.texture = source->texture; + texture_sampler_binding.sampler = + filter == SDL_GPU_FILTER_NEAREST ? blit_nearest_sampler : blit_linear_sampler; SDL_BindGPUFragmentSamplers( - renderPass, + render_pass, 0, - &textureSamplerBinding, + &texture_sampler_binding, 1); - blitFragmentUniforms.left = (float)source->x / (srcHeader->info.width >> source->mipLevel); - blitFragmentUniforms.top = (float)source->y / (srcHeader->info.height >> source->mipLevel); - blitFragmentUniforms.width = (float)source->w / (srcHeader->info.width >> source->mipLevel); - blitFragmentUniforms.height = (float)source->h / (srcHeader->info.height >> source->mipLevel); - blitFragmentUniforms.mipLevel = source->mipLevel; + blit_fragment_uniforms.left = (float)source->x / (src_header->info.width >> source->mip_level); + blit_fragment_uniforms.top = (float)source->y / (src_header->info.height >> source->mip_level); + blit_fragment_uniforms.width = (float)source->w / (src_header->info.width >> source->mip_level); + blit_fragment_uniforms.height = (float)source->h / (src_header->info.height >> source->mip_level); + blit_fragment_uniforms.mip_level = source->mip_level; - layerDivisor = (srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D) ? srcHeader->info.layerCountOrDepth : 1; - blitFragmentUniforms.layerOrDepth = (float)source->layerOrDepthPlane / layerDivisor; + layer_divisor = (src_header->info.type == SDL_GPU_TEXTURETYPE_3D) ? src_header->info.layer_count_or_depth : 1; + blit_fragment_uniforms.layer_or_depth = (float)source->layer_or_depth_plane / layer_divisor; - if (flipMode & SDL_FLIP_HORIZONTAL) { - blitFragmentUniforms.left += blitFragmentUniforms.width; - blitFragmentUniforms.width *= -1; + if (flip_mode & SDL_FLIP_HORIZONTAL) { + blit_fragment_uniforms.left += blit_fragment_uniforms.width; + blit_fragment_uniforms.width *= -1; } - if (flipMode & SDL_FLIP_VERTICAL) { - blitFragmentUniforms.top += blitFragmentUniforms.height; - blitFragmentUniforms.height *= -1; + if (flip_mode & SDL_FLIP_VERTICAL) { + blit_fragment_uniforms.top += blit_fragment_uniforms.height; + blit_fragment_uniforms.height *= -1; } SDL_PushGPUFragmentUniformData( - commandBuffer, + command_buffer, 0, - &blitFragmentUniforms, - sizeof(blitFragmentUniforms)); + &blit_fragment_uniforms, + sizeof(blit_fragment_uniforms)); - SDL_DrawGPUPrimitives(renderPass, 3, 1, 0, 0); - SDL_EndGPURenderPass(renderPass); + SDL_DrawGPUPrimitives(render_pass, 3, 1, 0, 0); + SDL_EndGPURenderPass(render_pass); } // Driver Functions @@ -350,15 +350,15 @@ void SDL_GPU_BlitCommon( static SDL_GPUDriver SDL_GPUSelectBackend( SDL_VideoDevice *_this, const char *gpudriver, - SDL_GPUShaderFormat formatFlags) + SDL_GPUShaderFormat format_flags) { Uint32 i; // Environment/Properties override... if (gpudriver != NULL) { for (i = 0; backends[i]; i += 1) { - if (SDL_strcasecmp(gpudriver, backends[i]->Name) == 0) { - if (!(backends[i]->shaderFormats & formatFlags)) { + if (SDL_strcasecmp(gpudriver, backends[i]->name) == 0) { + if (!(backends[i]->shader_formats & format_flags)) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Required shader format for backend %s not provided!", gpudriver); return SDL_GPU_DRIVER_INVALID; } @@ -373,7 +373,7 @@ static SDL_GPUDriver SDL_GPUSelectBackend( } for (i = 0; backends[i]; i += 1) { - if ((backends[i]->shaderFormats & formatFlags) == 0) { + if ((backends[i]->shader_formats & format_flags) == 0) { // Don't select a backend which doesn't support the app's shaders. continue; } @@ -387,31 +387,31 @@ static SDL_GPUDriver SDL_GPUSelectBackend( } SDL_GPUDevice *SDL_CreateGPUDevice( - SDL_GPUShaderFormat formatFlags, - SDL_bool debugMode, + SDL_GPUShaderFormat format_flags, + SDL_bool debug_mode, const char *name) { SDL_GPUDevice *result; SDL_PropertiesID props = SDL_CreateProperties(); - if (formatFlags & SDL_GPU_SHADERFORMAT_PRIVATE) { + if (format_flags & SDL_GPU_SHADERFORMAT_PRIVATE) { SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOL, true); } - if (formatFlags & SDL_GPU_SHADERFORMAT_SPIRV) { + if (format_flags & SDL_GPU_SHADERFORMAT_SPIRV) { SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL, true); } - if (formatFlags & SDL_GPU_SHADERFORMAT_DXBC) { + if (format_flags & SDL_GPU_SHADERFORMAT_DXBC) { SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL, true); } - if (formatFlags & SDL_GPU_SHADERFORMAT_DXIL) { + if (format_flags & SDL_GPU_SHADERFORMAT_DXIL) { SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL, true); } - if (formatFlags & SDL_GPU_SHADERFORMAT_MSL) { + if (format_flags & SDL_GPU_SHADERFORMAT_MSL) { SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL, true); } - if (formatFlags & SDL_GPU_SHADERFORMAT_METALLIB) { + if (format_flags & SDL_GPU_SHADERFORMAT_METALLIB) { SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL, true); } - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL, debugMode); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL, debug_mode); SDL_SetStringProperty(props, SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING, name); result = SDL_CreateGPUDeviceWithProperties(props); SDL_DestroyProperties(props); @@ -420,8 +420,8 @@ SDL_GPUDevice *SDL_CreateGPUDevice( SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props) { - SDL_GPUShaderFormat formatFlags = 0; - bool debugMode; + SDL_GPUShaderFormat format_flags = 0; + bool debug_mode; bool preferLowPower; int i; @@ -436,25 +436,25 @@ SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props) } if (SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOL, false)) { - formatFlags |= SDL_GPU_SHADERFORMAT_PRIVATE; + format_flags |= SDL_GPU_SHADERFORMAT_PRIVATE; } if (SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL, false)) { - formatFlags |= SDL_GPU_SHADERFORMAT_SPIRV; + format_flags |= SDL_GPU_SHADERFORMAT_SPIRV; } if (SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL, false)) { - formatFlags |= SDL_GPU_SHADERFORMAT_DXBC; + format_flags |= SDL_GPU_SHADERFORMAT_DXBC; } if (SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL, false)) { - formatFlags |= SDL_GPU_SHADERFORMAT_DXIL; + format_flags |= SDL_GPU_SHADERFORMAT_DXIL; } if (SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL, false)) { - formatFlags |= SDL_GPU_SHADERFORMAT_MSL; + format_flags |= SDL_GPU_SHADERFORMAT_MSL; } if (SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL, false)) { - formatFlags |= SDL_GPU_SHADERFORMAT_METALLIB; + format_flags |= SDL_GPU_SHADERFORMAT_METALLIB; } - debugMode = SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL, true); + debug_mode = SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL, true); preferLowPower = SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOL, false); gpudriver = SDL_GetHint(SDL_HINT_GPU_DRIVER); @@ -462,15 +462,15 @@ SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props) gpudriver = SDL_GetStringProperty(props, SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING, NULL); } - selectedBackend = SDL_GPUSelectBackend(_this, gpudriver, formatFlags); + selectedBackend = SDL_GPUSelectBackend(_this, gpudriver, format_flags); if (selectedBackend != SDL_GPU_DRIVER_INVALID) { for (i = 0; backends[i]; i += 1) { if (backends[i]->backendflag == selectedBackend) { - result = backends[i]->CreateDevice(debugMode, preferLowPower, props); + result = backends[i]->CreateDevice(debug_mode, preferLowPower, props); if (result != NULL) { result->backend = backends[i]->backendflag; - result->shaderFormats = backends[i]->shaderFormats; - result->debugMode = debugMode; + result->shader_formats = backends[i]->shader_formats; + result->debug_mode = debug_mode; break; } } @@ -494,9 +494,9 @@ SDL_GPUDriver SDL_GetGPUDriver(SDL_GPUDevice *device) } Uint32 SDL_GPUTextureFormatTexelBlockSize( - SDL_GPUTextureFormat textureFormat) + SDL_GPUTextureFormat format) { - switch (textureFormat) { + switch (format) { case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM: case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB: case SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM: @@ -563,7 +563,7 @@ SDL_bool SDL_GPUTextureSupportsFormat( { CHECK_DEVICE_MAGIC(device, false); - if (device->debugMode) { + if (device->debug_mode) { CHECK_TEXTUREFORMAT_ENUM_INVALID(format, false) } @@ -577,49 +577,49 @@ SDL_bool SDL_GPUTextureSupportsFormat( SDL_bool SDL_GPUTextureSupportsSampleCount( SDL_GPUDevice *device, SDL_GPUTextureFormat format, - SDL_GPUSampleCount sampleCount) + SDL_GPUSampleCount sample_count) { CHECK_DEVICE_MAGIC(device, 0); - if (device->debugMode) { + if (device->debug_mode) { CHECK_TEXTUREFORMAT_ENUM_INVALID(format, 0) } return device->SupportsSampleCount( device->driverData, format, - sampleCount); + sample_count); } // State Creation SDL_GPUComputePipeline *SDL_CreateGPUComputePipeline( SDL_GPUDevice *device, - const SDL_GPUComputePipelineCreateInfo *computePipelineCreateInfo) + const SDL_GPUComputePipelineCreateInfo *createinfo) { CHECK_DEVICE_MAGIC(device, NULL); - if (computePipelineCreateInfo == NULL) { - SDL_InvalidParamError("computePipelineCreateInfo"); + if (createinfo == NULL) { + SDL_InvalidParamError("createinfo"); return NULL; } - if (device->debugMode) { - if (!(computePipelineCreateInfo->format & device->shaderFormats)) { + if (device->debug_mode) { + if (!(createinfo->format & device->shader_formats)) { SDL_assert_release(!"Incompatible shader format for GPU backend"); return NULL; } - if (computePipelineCreateInfo->writeOnlyStorageTextureCount > MAX_COMPUTE_WRITE_TEXTURES) { + if (createinfo->num_writeonly_storage_textures > MAX_COMPUTE_WRITE_TEXTURES) { SDL_assert_release(!"Compute pipeline write-only texture count cannot be higher than 8!"); return NULL; } - if (computePipelineCreateInfo->writeOnlyStorageBufferCount > MAX_COMPUTE_WRITE_BUFFERS) { + if (createinfo->num_writeonly_storage_buffers > MAX_COMPUTE_WRITE_BUFFERS) { SDL_assert_release(!"Compute pipeline write-only buffer count cannot be higher than 8!"); return NULL; } - if (computePipelineCreateInfo->threadCountX == 0 || - computePipelineCreateInfo->threadCountY == 0 || - computePipelineCreateInfo->threadCountZ == 0) { + if (createinfo->threadcount_x == 0 || + createinfo->threadcount_y == 0 || + createinfo->threadcount_z == 0) { SDL_assert_release(!"Compute pipeline threadCount dimensions must be at least 1!"); return NULL; } @@ -627,7 +627,7 @@ SDL_GPUComputePipeline *SDL_CreateGPUComputePipeline( return device->CreateComputePipeline( device->driverData, - computePipelineCreateInfo); + createinfo); } SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline( @@ -640,18 +640,18 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline( return NULL; } - if (device->debugMode) { - for (Uint32 i = 0; i < graphicsPipelineCreateInfo->attachmentInfo.colorAttachmentCount; i += 1) { - CHECK_TEXTUREFORMAT_ENUM_INVALID(graphicsPipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions[i].format, NULL); - if (IsDepthFormat(graphicsPipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions[i].format)) { - SDL_assert_release(!"Color attachment formats cannot be a depth format!"); + if (device->debug_mode) { + for (Uint32 i = 0; i < graphicsPipelineCreateInfo->target_info.num_color_targets; i += 1) { + CHECK_TEXTUREFORMAT_ENUM_INVALID(graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].format, NULL); + if (IsDepthFormat(graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].format)) { + SDL_assert_release(!"Color target formats cannot be a depth format!"); return NULL; } } - if (graphicsPipelineCreateInfo->attachmentInfo.hasDepthStencilAttachment) { - CHECK_TEXTUREFORMAT_ENUM_INVALID(graphicsPipelineCreateInfo->attachmentInfo.depthStencilFormat, NULL); - if (!IsDepthFormat(graphicsPipelineCreateInfo->attachmentInfo.depthStencilFormat)) { - SDL_assert_release(!"Depth-stencil attachment format must be a depth format!"); + if (graphicsPipelineCreateInfo->target_info.has_depth_stencil_target) { + CHECK_TEXTUREFORMAT_ENUM_INVALID(graphicsPipelineCreateInfo->target_info.depth_stencil_format, NULL); + if (!IsDepthFormat(graphicsPipelineCreateInfo->target_info.depth_stencil_format)) { + SDL_assert_release(!"Depth-stencil target format must be a depth format!"); return NULL; } } @@ -664,31 +664,31 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline( SDL_GPUSampler *SDL_CreateGPUSampler( SDL_GPUDevice *device, - const SDL_GPUSamplerCreateInfo *samplerCreateInfo) + const SDL_GPUSamplerCreateInfo *createinfo) { CHECK_DEVICE_MAGIC(device, NULL); - if (samplerCreateInfo == NULL) { - SDL_InvalidParamError("samplerCreateInfo"); + if (createinfo == NULL) { + SDL_InvalidParamError("createinfo"); return NULL; } return device->CreateSampler( device->driverData, - samplerCreateInfo); + createinfo); } SDL_GPUShader *SDL_CreateGPUShader( SDL_GPUDevice *device, - const SDL_GPUShaderCreateInfo *shaderCreateInfo) + const SDL_GPUShaderCreateInfo *createinfo) { CHECK_DEVICE_MAGIC(device, NULL); - if (shaderCreateInfo == NULL) { - SDL_InvalidParamError("shaderCreateInfo"); + if (createinfo == NULL) { + SDL_InvalidParamError("createinfo"); return NULL; } - if (device->debugMode) { - if (!(shaderCreateInfo->format & device->shaderFormats)) { + if (device->debug_mode) { + if (!(createinfo->format & device->shader_formats)) { SDL_assert_release(!"Incompatible shader format for GPU backend"); return NULL; } @@ -696,109 +696,109 @@ SDL_GPUShader *SDL_CreateGPUShader( return device->CreateShader( device->driverData, - shaderCreateInfo); + createinfo); } SDL_GPUTexture *SDL_CreateGPUTexture( SDL_GPUDevice *device, - const SDL_GPUTextureCreateInfo *textureCreateInfo) + const SDL_GPUTextureCreateInfo *createinfo) { CHECK_DEVICE_MAGIC(device, NULL); - if (textureCreateInfo == NULL) { - SDL_InvalidParamError("textureCreateInfo"); + if (createinfo == NULL) { + SDL_InvalidParamError("createinfo"); return NULL; } - if (device->debugMode) { + if (device->debug_mode) { bool failed = false; const Uint32 MAX_2D_DIMENSION = 16384; const Uint32 MAX_3D_DIMENSION = 2048; // Common checks for all texture types - CHECK_TEXTUREFORMAT_ENUM_INVALID(textureCreateInfo->format, NULL) + CHECK_TEXTUREFORMAT_ENUM_INVALID(createinfo->format, NULL) - if (textureCreateInfo->width <= 0 || textureCreateInfo->height <= 0 || textureCreateInfo->layerCountOrDepth <= 0) { - SDL_assert_release(!"For any texture: width, height, and layerCountOrDepth must be >= 1"); + if (createinfo->width <= 0 || createinfo->height <= 0 || createinfo->layer_count_or_depth <= 0) { + SDL_assert_release(!"For any texture: width, height, and layer_count_or_depth must be >= 1"); failed = true; } - if (textureCreateInfo->levelCount <= 0) { - SDL_assert_release(!"For any texture: levelCount must be >= 1"); + if (createinfo->num_levels <= 0) { + SDL_assert_release(!"For any texture: num_levels must be >= 1"); failed = true; } - if ((textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ) && (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_SAMPLER)) { - SDL_assert_release(!"For any texture: usageFlags cannot contain both GRAPHICS_STORAGE_READ and SAMPLER"); + if ((createinfo->usage & SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ) && (createinfo->usage & SDL_GPU_TEXTUREUSAGE_SAMPLER)) { + SDL_assert_release(!"For any texture: usage cannot contain both GRAPHICS_STORAGE_READ and SAMPLER"); failed = true; } - if (IsDepthFormat(textureCreateInfo->format) && (textureCreateInfo->usageFlags & ~(SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER))) { - SDL_assert_release(!"For depth textures: usageFlags cannot contain any flags except for DEPTH_STENCIL_TARGET and SAMPLER"); + if (IsDepthFormat(createinfo->format) && (createinfo->usage & ~(SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER))) { + SDL_assert_release(!"For depth textures: usage cannot contain any flags except for DEPTH_STENCIL_TARGET and SAMPLER"); failed = true; } - if (IsIntegerFormat(textureCreateInfo->format) && (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_SAMPLER)) { - SDL_assert_release(!"For any texture: usageFlags cannot contain SAMPLER for textures with an integer format"); + if (IsIntegerFormat(createinfo->format) && (createinfo->usage & SDL_GPU_TEXTUREUSAGE_SAMPLER)) { + SDL_assert_release(!"For any texture: usage cannot contain SAMPLER for textures with an integer format"); failed = true; } - if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_CUBE) { + if (createinfo->type == SDL_GPU_TEXTURETYPE_CUBE) { // Cubemap validation - if (textureCreateInfo->width != textureCreateInfo->height) { + if (createinfo->width != createinfo->height) { SDL_assert_release(!"For cube textures: width and height must be identical"); failed = true; } - if (textureCreateInfo->width > MAX_2D_DIMENSION || textureCreateInfo->height > MAX_2D_DIMENSION) { + if (createinfo->width > MAX_2D_DIMENSION || createinfo->height > MAX_2D_DIMENSION) { SDL_assert_release(!"For cube textures: width and height must be <= 16384"); failed = true; } - if (textureCreateInfo->layerCountOrDepth != 6) { - SDL_assert_release(!"For cube textures: layerCountOrDepth must be 6"); + if (createinfo->layer_count_or_depth != 6) { + SDL_assert_release(!"For cube textures: layer_count_or_depth must be 6"); failed = true; } - if (textureCreateInfo->sampleCount > SDL_GPU_SAMPLECOUNT_1) { - SDL_assert_release(!"For cube textures: sampleCount must be SDL_GPU_SAMPLECOUNT_1"); + if (createinfo->sample_count > SDL_GPU_SAMPLECOUNT_1) { + SDL_assert_release(!"For cube textures: sample_count must be SDL_GPU_SAMPLECOUNT_1"); failed = true; } - if (!SDL_GPUTextureSupportsFormat(device, textureCreateInfo->format, SDL_GPU_TEXTURETYPE_CUBE, textureCreateInfo->usageFlags)) { - SDL_assert_release(!"For cube textures: the format is unsupported for the given usageFlags"); + if (!SDL_GPUTextureSupportsFormat(device, createinfo->format, SDL_GPU_TEXTURETYPE_CUBE, createinfo->usage)) { + SDL_assert_release(!"For cube textures: the format is unsupported for the given usage"); failed = true; } - } else if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D) { + } else if (createinfo->type == SDL_GPU_TEXTURETYPE_3D) { // 3D Texture Validation - if (textureCreateInfo->width > MAX_3D_DIMENSION || textureCreateInfo->height > MAX_3D_DIMENSION || textureCreateInfo->layerCountOrDepth > MAX_3D_DIMENSION) { - SDL_assert_release(!"For 3D textures: width, height, and layerCountOrDepth must be <= 2048"); + if (createinfo->width > MAX_3D_DIMENSION || createinfo->height > MAX_3D_DIMENSION || createinfo->layer_count_or_depth > MAX_3D_DIMENSION) { + SDL_assert_release(!"For 3D textures: width, height, and layer_count_or_depth must be <= 2048"); failed = true; } - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) { - SDL_assert_release(!"For 3D textures: usageFlags must not contain DEPTH_STENCIL_TARGET"); + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) { + SDL_assert_release(!"For 3D textures: usage must not contain DEPTH_STENCIL_TARGET"); failed = true; } - if (textureCreateInfo->sampleCount > SDL_GPU_SAMPLECOUNT_1) { - SDL_assert_release(!"For 3D textures: sampleCount must be SDL_GPU_SAMPLECOUNT_1"); + if (createinfo->sample_count > SDL_GPU_SAMPLECOUNT_1) { + SDL_assert_release(!"For 3D textures: sample_count must be SDL_GPU_SAMPLECOUNT_1"); failed = true; } - if (!SDL_GPUTextureSupportsFormat(device, textureCreateInfo->format, SDL_GPU_TEXTURETYPE_3D, textureCreateInfo->usageFlags)) { - SDL_assert_release(!"For 3D textures: the format is unsupported for the given usageFlags"); + if (!SDL_GPUTextureSupportsFormat(device, createinfo->format, SDL_GPU_TEXTURETYPE_3D, createinfo->usage)) { + SDL_assert_release(!"For 3D textures: the format is unsupported for the given usage"); failed = true; } } else { - if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY) { + if (createinfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY) { // Array Texture Validation - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) { - SDL_assert_release(!"For array textures: usageFlags must not contain DEPTH_STENCIL_TARGET"); + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) { + SDL_assert_release(!"For array textures: usage must not contain DEPTH_STENCIL_TARGET"); failed = true; } - if (textureCreateInfo->sampleCount > SDL_GPU_SAMPLECOUNT_1) { - SDL_assert_release(!"For array textures: sampleCount must be SDL_GPU_SAMPLECOUNT_1"); + if (createinfo->sample_count > SDL_GPU_SAMPLECOUNT_1) { + SDL_assert_release(!"For array textures: sample_count must be SDL_GPU_SAMPLECOUNT_1"); failed = true; } } else { // 2D Texture Validation - if (textureCreateInfo->sampleCount > SDL_GPU_SAMPLECOUNT_1 && textureCreateInfo->levelCount > 1) { - SDL_assert_release(!"For 2D textures: if sampleCount is >= SDL_GPU_SAMPLECOUNT_1, then levelCount must be 1"); + if (createinfo->sample_count > SDL_GPU_SAMPLECOUNT_1 && createinfo->num_levels > 1) { + SDL_assert_release(!"For 2D textures: if sample_count is >= SDL_GPU_SAMPLECOUNT_1, then num_levels must be 1"); failed = true; } } - if (!SDL_GPUTextureSupportsFormat(device, textureCreateInfo->format, SDL_GPU_TEXTURETYPE_2D, textureCreateInfo->usageFlags)) { - SDL_assert_release(!"For 2D textures: the format is unsupported for the given usageFlags"); + if (!SDL_GPUTextureSupportsFormat(device, createinfo->format, SDL_GPU_TEXTURETYPE_2D, createinfo->usage)) { + SDL_assert_release(!"For 2D textures: the format is unsupported for the given usage"); failed = true; } } @@ -810,39 +810,39 @@ SDL_GPUTexture *SDL_CreateGPUTexture( return device->CreateTexture( device->driverData, - textureCreateInfo); + createinfo); } SDL_GPUBuffer *SDL_CreateGPUBuffer( SDL_GPUDevice *device, - const SDL_GPUBufferCreateInfo *bufferCreateInfo) + const SDL_GPUBufferCreateInfo *createinfo) { CHECK_DEVICE_MAGIC(device, NULL); - if (bufferCreateInfo == NULL) { - SDL_InvalidParamError("bufferCreateInfo"); + if (createinfo == NULL) { + SDL_InvalidParamError("createinfo"); return NULL; } return device->CreateBuffer( device->driverData, - bufferCreateInfo->usageFlags, - bufferCreateInfo->sizeInBytes); + createinfo->usage, + createinfo->size); } SDL_GPUTransferBuffer *SDL_CreateGPUTransferBuffer( SDL_GPUDevice *device, - const SDL_GPUTransferBufferCreateInfo *transferBufferCreateInfo) + const SDL_GPUTransferBufferCreateInfo *createinfo) { CHECK_DEVICE_MAGIC(device, NULL); - if (transferBufferCreateInfo == NULL) { - SDL_InvalidParamError("transferBufferCreateInfo"); + if (createinfo == NULL) { + SDL_InvalidParamError("createinfo"); return NULL; } return device->CreateTransferBuffer( device->driverData, - transferBufferCreateInfo->usage, - transferBufferCreateInfo->sizeInBytes); + createinfo->usage, + createinfo->size); } // Debug Naming @@ -888,11 +888,11 @@ void SDL_SetGPUTextureName( } void SDL_InsertGPUDebugLabel( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, const char *text) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } if (text == NULL) { @@ -900,21 +900,21 @@ void SDL_InsertGPUDebugLabel( return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER } COMMAND_BUFFER_DEVICE->InsertDebugLabel( - commandBuffer, + command_buffer, text); } void SDL_PushGPUDebugGroup( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, const char *name) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } if (name == NULL) { @@ -922,29 +922,29 @@ void SDL_PushGPUDebugGroup( return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER } COMMAND_BUFFER_DEVICE->PushDebugGroup( - commandBuffer, + command_buffer, name); } void SDL_PopGPUDebugGroup( - SDL_GPUCommandBuffer *commandBuffer) + SDL_GPUCommandBuffer *command_buffer) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER } COMMAND_BUFFER_DEVICE->PopDebugGroup( - commandBuffer); + command_buffer); } // Disposal @@ -993,16 +993,16 @@ void SDL_ReleaseGPUBuffer( void SDL_ReleaseGPUTransferBuffer( SDL_GPUDevice *device, - SDL_GPUTransferBuffer *transferBuffer) + SDL_GPUTransferBuffer *transfer_buffer) { CHECK_DEVICE_MAGIC(device, ); - if (transferBuffer == NULL) { + if (transfer_buffer == NULL) { return; } device->ReleaseTransferBuffer( device->driverData, - transferBuffer); + transfer_buffer); } void SDL_ReleaseGPUShader( @@ -1021,30 +1021,30 @@ void SDL_ReleaseGPUShader( void SDL_ReleaseGPUComputePipeline( SDL_GPUDevice *device, - SDL_GPUComputePipeline *computePipeline) + SDL_GPUComputePipeline *compute_pipeline) { CHECK_DEVICE_MAGIC(device, ); - if (computePipeline == NULL) { + if (compute_pipeline == NULL) { return; } device->ReleaseComputePipeline( device->driverData, - computePipeline); + compute_pipeline); } void SDL_ReleaseGPUGraphicsPipeline( SDL_GPUDevice *device, - SDL_GPUGraphicsPipeline *graphicsPipeline) + SDL_GPUGraphicsPipeline *graphics_pipeline) { CHECK_DEVICE_MAGIC(device, ); - if (graphicsPipeline == NULL) { + if (graphics_pipeline == NULL) { return; } device->ReleaseGraphicsPipeline( device->driverData, - graphicsPipeline); + graphics_pipeline); } // Command Buffer @@ -1052,43 +1052,43 @@ void SDL_ReleaseGPUGraphicsPipeline( SDL_GPUCommandBuffer *SDL_AcquireGPUCommandBuffer( SDL_GPUDevice *device) { - SDL_GPUCommandBuffer *commandBuffer; + SDL_GPUCommandBuffer *command_buffer; CommandBufferCommonHeader *commandBufferHeader; CHECK_DEVICE_MAGIC(device, NULL); - commandBuffer = device->AcquireCommandBuffer( + command_buffer = device->AcquireCommandBuffer( device->driverData); - if (commandBuffer == NULL) { + if (command_buffer == NULL) { return NULL; } - commandBufferHeader = (CommandBufferCommonHeader *)commandBuffer; + commandBufferHeader = (CommandBufferCommonHeader *)command_buffer; commandBufferHeader->device = device; - commandBufferHeader->renderPass.commandBuffer = commandBuffer; - commandBufferHeader->renderPass.inProgress = false; - commandBufferHeader->graphicsPipelineBound = false; - commandBufferHeader->computePass.commandBuffer = commandBuffer; - commandBufferHeader->computePass.inProgress = false; - commandBufferHeader->computePipelineBound = false; - commandBufferHeader->copyPass.commandBuffer = commandBuffer; - commandBufferHeader->copyPass.inProgress = false; + commandBufferHeader->render_pass.command_buffer = command_buffer; + commandBufferHeader->render_pass.in_progress = false; + commandBufferHeader->graphics_pipeline_bound = false; + commandBufferHeader->compute_pass.command_buffer = command_buffer; + commandBufferHeader->compute_pass.in_progress = false; + commandBufferHeader->compute_pipeline_bound = false; + commandBufferHeader->copy_pass.command_buffer = command_buffer; + commandBufferHeader->copy_pass.in_progress = false; commandBufferHeader->submitted = false; - return commandBuffer; + return command_buffer; } // Uniforms void SDL_PushGPUVertexUniformData( - SDL_GPUCommandBuffer *commandBuffer, - Uint32 slotIndex, + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } if (data == NULL) { @@ -1096,25 +1096,25 @@ void SDL_PushGPUVertexUniformData( return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER } COMMAND_BUFFER_DEVICE->PushVertexUniformData( - commandBuffer, - slotIndex, + command_buffer, + slot_index, data, - dataLengthInBytes); + length); } void SDL_PushGPUFragmentUniformData( - SDL_GPUCommandBuffer *commandBuffer, - Uint32 slotIndex, + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } if (data == NULL) { @@ -1122,25 +1122,25 @@ void SDL_PushGPUFragmentUniformData( return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER } COMMAND_BUFFER_DEVICE->PushFragmentUniformData( - commandBuffer, - slotIndex, + command_buffer, + slot_index, data, - dataLengthInBytes); + length); } void SDL_PushGPUComputeUniformData( - SDL_GPUCommandBuffer *commandBuffer, - Uint32 slotIndex, + SDL_GPUCommandBuffer *command_buffer, + Uint32 slot_index, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } if (data == NULL) { @@ -1148,96 +1148,96 @@ void SDL_PushGPUComputeUniformData( return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER } COMMAND_BUFFER_DEVICE->PushComputeUniformData( - commandBuffer, - slotIndex, + command_buffer, + slot_index, data, - dataLengthInBytes); + length); } // Render Pass SDL_GPURenderPass *SDL_BeginGPURenderPass( - SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo) + SDL_GPUCommandBuffer *command_buffer, + const SDL_GPUColorTargetInfo *color_target_infos, + Uint32 num_color_targets, + const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info) { CommandBufferCommonHeader *commandBufferHeader; - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return NULL; } - if (colorAttachmentInfos == NULL && colorAttachmentCount > 0) { - SDL_InvalidParamError("colorAttachmentInfos"); + if (color_target_infos == NULL && num_color_targets > 0) { + SDL_InvalidParamError("color_target_infos"); return NULL; } - if (colorAttachmentCount > MAX_COLOR_TARGET_BINDINGS) { - SDL_SetError("colorAttachmentCount exceeds MAX_COLOR_TARGET_BINDINGS"); + if (num_color_targets > MAX_COLOR_TARGET_BINDINGS) { + SDL_SetError("num_color_targets exceeds MAX_COLOR_TARGET_BINDINGS"); return NULL; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER_RETURN_NULL CHECK_ANY_PASS_IN_PROGRESS("Cannot begin render pass during another pass!", NULL) - for (Uint32 i = 0; i < colorAttachmentCount; i += 1) { - if (colorAttachmentInfos[i].cycle && colorAttachmentInfos[i].loadOp == SDL_GPU_LOADOP_LOAD) { - SDL_assert_release(!"Cannot cycle color attachment when load op is LOAD!"); + for (Uint32 i = 0; i < num_color_targets; i += 1) { + if (color_target_infos[i].cycle && color_target_infos[i].load_op == SDL_GPU_LOADOP_LOAD) { + SDL_assert_release(!"Cannot cycle color target when load op is LOAD!"); } } - if (depthStencilAttachmentInfo != NULL && depthStencilAttachmentInfo->cycle && (depthStencilAttachmentInfo->loadOp == SDL_GPU_LOADOP_LOAD || depthStencilAttachmentInfo->loadOp == SDL_GPU_LOADOP_LOAD)) { - SDL_assert_release(!"Cannot cycle depth attachment when load op or stencil load op is LOAD!"); + if (depth_stencil_target_info != NULL && depth_stencil_target_info->cycle && (depth_stencil_target_info->load_op == SDL_GPU_LOADOP_LOAD || depth_stencil_target_info->load_op == SDL_GPU_LOADOP_LOAD)) { + SDL_assert_release(!"Cannot cycle depth target when load op or stencil load op is LOAD!"); } } COMMAND_BUFFER_DEVICE->BeginRenderPass( - commandBuffer, - colorAttachmentInfos, - colorAttachmentCount, - depthStencilAttachmentInfo); + command_buffer, + color_target_infos, + num_color_targets, + depth_stencil_target_info); - commandBufferHeader = (CommandBufferCommonHeader *)commandBuffer; - commandBufferHeader->renderPass.inProgress = true; - return (SDL_GPURenderPass *)&(commandBufferHeader->renderPass); + commandBufferHeader = (CommandBufferCommonHeader *)command_buffer; + commandBufferHeader->render_pass.in_progress = true; + return (SDL_GPURenderPass *)&(commandBufferHeader->render_pass); } void SDL_BindGPUGraphicsPipeline( - SDL_GPURenderPass *renderPass, - SDL_GPUGraphicsPipeline *graphicsPipeline) + SDL_GPURenderPass *render_pass, + SDL_GPUGraphicsPipeline *graphics_pipeline) { CommandBufferCommonHeader *commandBufferHeader; - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (graphicsPipeline == NULL) { - SDL_InvalidParamError("graphicsPipeline"); + if (graphics_pipeline == NULL) { + SDL_InvalidParamError("graphics_pipeline"); return; } RENDERPASS_DEVICE->BindGraphicsPipeline( RENDERPASS_COMMAND_BUFFER, - graphicsPipeline); + graphics_pipeline); commandBufferHeader = (CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER; - commandBufferHeader->graphicsPipelineBound = true; + commandBufferHeader->graphics_pipeline_bound = true; } void SDL_SetGPUViewport( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, const SDL_GPUViewport *viewport) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } if (viewport == NULL) { @@ -1245,7 +1245,7 @@ void SDL_SetGPUViewport( return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } @@ -1255,11 +1255,11 @@ void SDL_SetGPUViewport( } void SDL_SetGPUScissor( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, const SDL_Rect *scissor) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } if (scissor == NULL) { @@ -1267,7 +1267,7 @@ void SDL_SetGPUScissor( return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } @@ -1277,33 +1277,33 @@ void SDL_SetGPUScissor( } void SDL_SetGPUBlendConstants( - SDL_GPURenderPass *renderPass, - SDL_FColor blendConstants) + SDL_GPURenderPass *render_pass, + SDL_FColor blend_constants) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->SetBlendConstants( RENDERPASS_COMMAND_BUFFER, - blendConstants); + blend_constants); } void SDL_SetGPUStencilReference( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, Uint8 reference) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } @@ -1313,272 +1313,272 @@ void SDL_SetGPUStencilReference( } void SDL_BindGPUVertexBuffers( - SDL_GPURenderPass *renderPass, - Uint32 firstBinding, - const SDL_GPUBufferBinding *pBindings, - Uint32 bindingCount) + SDL_GPURenderPass *render_pass, + Uint32 first_binding, + const SDL_GPUBufferBinding *bindings, + Uint32 num_bindings) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (pBindings == NULL && bindingCount > 0) { - SDL_InvalidParamError("pBindings"); + if (bindings == NULL && num_bindings > 0) { + SDL_InvalidParamError("bindings"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->BindVertexBuffers( RENDERPASS_COMMAND_BUFFER, - firstBinding, - pBindings, - bindingCount); + first_binding, + bindings, + num_bindings); } void SDL_BindGPUIndexBuffer( - SDL_GPURenderPass *renderPass, - const SDL_GPUBufferBinding *pBinding, - SDL_GPUIndexElementSize indexElementSize) + SDL_GPURenderPass *render_pass, + const SDL_GPUBufferBinding *binding, + SDL_GPUIndexElementSize index_element_size) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (pBinding == NULL) { - SDL_InvalidParamError("pBinding"); + if (binding == NULL) { + SDL_InvalidParamError("binding"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->BindIndexBuffer( RENDERPASS_COMMAND_BUFFER, - pBinding, - indexElementSize); + binding, + index_element_size); } void SDL_BindGPUVertexSamplers( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, + Uint32 num_bindings) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (textureSamplerBindings == NULL && bindingCount > 0) { - SDL_InvalidParamError("textureSamplerBindings"); + if (texture_sampler_bindings == NULL && num_bindings > 0) { + SDL_InvalidParamError("texture_sampler_bindings"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->BindVertexSamplers( RENDERPASS_COMMAND_BUFFER, - firstSlot, - textureSamplerBindings, - bindingCount); + first_slot, + texture_sampler_bindings, + num_bindings); } void SDL_BindGPUVertexStorageTextures( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (storageTextures == NULL && bindingCount > 0) { - SDL_InvalidParamError("storageTextures"); + if (storage_textures == NULL && num_bindings > 0) { + SDL_InvalidParamError("storage_textures"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->BindVertexStorageTextures( RENDERPASS_COMMAND_BUFFER, - firstSlot, - storageTextures, - bindingCount); + first_slot, + storage_textures, + num_bindings); } void SDL_BindGPUVertexStorageBuffers( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (storageBuffers == NULL && bindingCount > 0) { - SDL_InvalidParamError("storageBuffers"); + if (storage_buffers == NULL && num_bindings > 0) { + SDL_InvalidParamError("storage_buffers"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->BindVertexStorageBuffers( RENDERPASS_COMMAND_BUFFER, - firstSlot, - storageBuffers, - bindingCount); + first_slot, + storage_buffers, + num_bindings); } void SDL_BindGPUFragmentSamplers( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, + Uint32 num_bindings) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (textureSamplerBindings == NULL && bindingCount > 0) { - SDL_InvalidParamError("textureSamplerBindings"); + if (texture_sampler_bindings == NULL && num_bindings > 0) { + SDL_InvalidParamError("texture_sampler_bindings"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->BindFragmentSamplers( RENDERPASS_COMMAND_BUFFER, - firstSlot, - textureSamplerBindings, - bindingCount); + first_slot, + texture_sampler_bindings, + num_bindings); } void SDL_BindGPUFragmentStorageTextures( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (storageTextures == NULL && bindingCount > 0) { - SDL_InvalidParamError("storageTextures"); + if (storage_textures == NULL && num_bindings > 0) { + SDL_InvalidParamError("storage_textures"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->BindFragmentStorageTextures( RENDERPASS_COMMAND_BUFFER, - firstSlot, - storageTextures, - bindingCount); + first_slot, + storage_textures, + num_bindings); } void SDL_BindGPUFragmentStorageBuffers( - SDL_GPURenderPass *renderPass, - Uint32 firstSlot, - SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + SDL_GPURenderPass *render_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (storageBuffers == NULL && bindingCount > 0) { - SDL_InvalidParamError("storageBuffers"); + if (storage_buffers == NULL && num_bindings > 0) { + SDL_InvalidParamError("storage_buffers"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } RENDERPASS_DEVICE->BindFragmentStorageBuffers( RENDERPASS_COMMAND_BUFFER, - firstSlot, - storageBuffers, - bindingCount); + first_slot, + storage_buffers, + num_bindings); } void SDL_DrawGPUIndexedPrimitives( - SDL_GPURenderPass *renderPass, - Uint32 indexCount, - Uint32 instanceCount, - Uint32 firstIndex, - Sint32 vertexOffset, - Uint32 firstInstance) + SDL_GPURenderPass *render_pass, + Uint32 num_indices, + Uint32 num_instances, + Uint32 first_index, + Sint32 vertex_offset, + Uint32 first_instance) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS CHECK_GRAPHICS_PIPELINE_BOUND } RENDERPASS_DEVICE->DrawIndexedPrimitives( RENDERPASS_COMMAND_BUFFER, - indexCount, - instanceCount, - firstIndex, - vertexOffset, - firstInstance); + num_indices, + num_instances, + first_index, + vertex_offset, + first_instance); } void SDL_DrawGPUPrimitives( - SDL_GPURenderPass *renderPass, - Uint32 vertexCount, - Uint32 instanceCount, - Uint32 firstVertex, - Uint32 firstInstance) + SDL_GPURenderPass *render_pass, + Uint32 num_vertices, + Uint32 num_instances, + Uint32 first_vertex, + Uint32 first_instance) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS CHECK_GRAPHICS_PIPELINE_BOUND } RENDERPASS_DEVICE->DrawPrimitives( RENDERPASS_COMMAND_BUFFER, - vertexCount, - instanceCount, - firstVertex, - firstInstance); + num_vertices, + num_instances, + first_vertex, + first_instance); } void SDL_DrawGPUPrimitivesIndirect( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, - Uint32 drawCount, - Uint32 stride) + Uint32 offset, + Uint32 draw_count, + Uint32 pitch) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } if (buffer == NULL) { @@ -1586,7 +1586,7 @@ void SDL_DrawGPUPrimitivesIndirect( return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS CHECK_GRAPHICS_PIPELINE_BOUND } @@ -1594,20 +1594,20 @@ void SDL_DrawGPUPrimitivesIndirect( RENDERPASS_DEVICE->DrawPrimitivesIndirect( RENDERPASS_COMMAND_BUFFER, buffer, - offsetInBytes, - drawCount, - stride); + offset, + draw_count, + pitch); } void SDL_DrawGPUIndexedPrimitivesIndirect( - SDL_GPURenderPass *renderPass, + SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, - Uint32 drawCount, - Uint32 stride) + Uint32 offset, + Uint32 draw_count, + Uint32 pitch) { - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } if (buffer == NULL) { @@ -1615,7 +1615,7 @@ void SDL_DrawGPUIndexedPrimitivesIndirect( return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS CHECK_GRAPHICS_PIPELINE_BOUND } @@ -1623,22 +1623,22 @@ void SDL_DrawGPUIndexedPrimitivesIndirect( RENDERPASS_DEVICE->DrawIndexedPrimitivesIndirect( RENDERPASS_COMMAND_BUFFER, buffer, - offsetInBytes, - drawCount, - stride); + offset, + draw_count, + pitch); } void SDL_EndGPURenderPass( - SDL_GPURenderPass *renderPass) + SDL_GPURenderPass *render_pass) { CommandBufferCommonHeader *commandBufferCommonHeader; - if (renderPass == NULL) { - SDL_InvalidParamError("renderPass"); + if (render_pass == NULL) { + SDL_InvalidParamError("render_pass"); return; } - if (RENDERPASS_DEVICE->debugMode) { + if (RENDERPASS_DEVICE->debug_mode) { CHECK_RENDERPASS } @@ -1646,171 +1646,171 @@ void SDL_EndGPURenderPass( RENDERPASS_COMMAND_BUFFER); commandBufferCommonHeader = (CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER; - commandBufferCommonHeader->renderPass.inProgress = false; - commandBufferCommonHeader->graphicsPipelineBound = false; + commandBufferCommonHeader->render_pass.in_progress = false; + commandBufferCommonHeader->graphics_pipeline_bound = false; } // Compute Pass SDL_GPUComputePass *SDL_BeginGPUComputePass( - SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings, - Uint32 storageTextureBindingCount, - const SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings, - Uint32 storageBufferBindingCount) + SDL_GPUCommandBuffer *command_buffer, + const SDL_GPUStorageTextureWriteOnlyBinding *storage_texture_bindings, + Uint32 num_storage_texture_bindings, + const SDL_GPUStorageBufferWriteOnlyBinding *storage_buffer_bindings, + Uint32 num_storage_buffer_bindings) { CommandBufferCommonHeader *commandBufferHeader; - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return NULL; } - if (storageTextureBindings == NULL && storageTextureBindingCount > 0) { - SDL_InvalidParamError("storageTextureBindings"); + if (storage_texture_bindings == NULL && num_storage_texture_bindings > 0) { + SDL_InvalidParamError("storage_texture_bindings"); return NULL; } - if (storageBufferBindings == NULL && storageBufferBindingCount > 0) { - SDL_InvalidParamError("storageBufferBindings"); + if (storage_buffer_bindings == NULL && num_storage_buffer_bindings > 0) { + SDL_InvalidParamError("storage_buffer_bindings"); return NULL; } - if (storageTextureBindingCount > MAX_COMPUTE_WRITE_TEXTURES) { - SDL_InvalidParamError("storageTextureBindingCount"); + if (num_storage_texture_bindings > MAX_COMPUTE_WRITE_TEXTURES) { + SDL_InvalidParamError("num_storage_texture_bindings"); return NULL; } - if (storageBufferBindingCount > MAX_COMPUTE_WRITE_BUFFERS) { - SDL_InvalidParamError("storageBufferBindingCount"); + if (num_storage_buffer_bindings > MAX_COMPUTE_WRITE_BUFFERS) { + SDL_InvalidParamError("num_storage_buffer_bindings"); return NULL; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER_RETURN_NULL CHECK_ANY_PASS_IN_PROGRESS("Cannot begin compute pass during another pass!", NULL) } COMMAND_BUFFER_DEVICE->BeginComputePass( - commandBuffer, - storageTextureBindings, - storageTextureBindingCount, - storageBufferBindings, - storageBufferBindingCount); + command_buffer, + storage_texture_bindings, + num_storage_texture_bindings, + storage_buffer_bindings, + num_storage_buffer_bindings); - commandBufferHeader = (CommandBufferCommonHeader *)commandBuffer; - commandBufferHeader->computePass.inProgress = true; - return (SDL_GPUComputePass *)&(commandBufferHeader->computePass); + commandBufferHeader = (CommandBufferCommonHeader *)command_buffer; + commandBufferHeader->compute_pass.in_progress = true; + return (SDL_GPUComputePass *)&(commandBufferHeader->compute_pass); } void SDL_BindGPUComputePipeline( - SDL_GPUComputePass *computePass, - SDL_GPUComputePipeline *computePipeline) + SDL_GPUComputePass *compute_pass, + SDL_GPUComputePipeline *compute_pipeline) { CommandBufferCommonHeader *commandBufferHeader; - if (computePass == NULL) { - SDL_InvalidParamError("computePass"); + if (compute_pass == NULL) { + SDL_InvalidParamError("compute_pass"); return; } - if (computePipeline == NULL) { - SDL_InvalidParamError("computePipeline"); + if (compute_pipeline == NULL) { + SDL_InvalidParamError("compute_pipeline"); return; } - if (COMPUTEPASS_DEVICE->debugMode) { + if (COMPUTEPASS_DEVICE->debug_mode) { CHECK_COMPUTEPASS } COMPUTEPASS_DEVICE->BindComputePipeline( COMPUTEPASS_COMMAND_BUFFER, - computePipeline); + compute_pipeline); commandBufferHeader = (CommandBufferCommonHeader *)COMPUTEPASS_COMMAND_BUFFER; - commandBufferHeader->computePipelineBound = true; + commandBufferHeader->compute_pipeline_bound = true; } void SDL_BindGPUComputeStorageTextures( - SDL_GPUComputePass *computePass, - Uint32 firstSlot, - SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + SDL_GPUComputePass *compute_pass, + Uint32 first_slot, + SDL_GPUTexture *const *storage_textures, + Uint32 num_bindings) { - if (computePass == NULL) { - SDL_InvalidParamError("computePass"); + if (compute_pass == NULL) { + SDL_InvalidParamError("compute_pass"); return; } - if (storageTextures == NULL && bindingCount > 0) { - SDL_InvalidParamError("storageTextures"); + if (storage_textures == NULL && num_bindings > 0) { + SDL_InvalidParamError("storage_textures"); return; } - if (COMPUTEPASS_DEVICE->debugMode) { + if (COMPUTEPASS_DEVICE->debug_mode) { CHECK_COMPUTEPASS } COMPUTEPASS_DEVICE->BindComputeStorageTextures( COMPUTEPASS_COMMAND_BUFFER, - firstSlot, - storageTextures, - bindingCount); + first_slot, + storage_textures, + num_bindings); } void SDL_BindGPUComputeStorageBuffers( - SDL_GPUComputePass *computePass, - Uint32 firstSlot, - SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + SDL_GPUComputePass *compute_pass, + Uint32 first_slot, + SDL_GPUBuffer *const *storage_buffers, + Uint32 num_bindings) { - if (computePass == NULL) { - SDL_InvalidParamError("computePass"); + if (compute_pass == NULL) { + SDL_InvalidParamError("compute_pass"); return; } - if (storageBuffers == NULL && bindingCount > 0) { - SDL_InvalidParamError("storageBuffers"); + if (storage_buffers == NULL && num_bindings > 0) { + SDL_InvalidParamError("storage_buffers"); return; } - if (COMPUTEPASS_DEVICE->debugMode) { + if (COMPUTEPASS_DEVICE->debug_mode) { CHECK_COMPUTEPASS } COMPUTEPASS_DEVICE->BindComputeStorageBuffers( COMPUTEPASS_COMMAND_BUFFER, - firstSlot, - storageBuffers, - bindingCount); + first_slot, + storage_buffers, + num_bindings); } void SDL_DispatchGPUCompute( - SDL_GPUComputePass *computePass, - Uint32 groupCountX, - Uint32 groupCountY, - Uint32 groupCountZ) + SDL_GPUComputePass *compute_pass, + Uint32 groupcount_x, + Uint32 groupcount_y, + Uint32 groupcount_z) { - if (computePass == NULL) { - SDL_InvalidParamError("computePass"); + if (compute_pass == NULL) { + SDL_InvalidParamError("compute_pass"); return; } - if (COMPUTEPASS_DEVICE->debugMode) { + if (COMPUTEPASS_DEVICE->debug_mode) { CHECK_COMPUTEPASS CHECK_COMPUTE_PIPELINE_BOUND } COMPUTEPASS_DEVICE->DispatchCompute( COMPUTEPASS_COMMAND_BUFFER, - groupCountX, - groupCountY, - groupCountZ); + groupcount_x, + groupcount_y, + groupcount_z); } void SDL_DispatchGPUComputeIndirect( - SDL_GPUComputePass *computePass, + SDL_GPUComputePass *compute_pass, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes) + Uint32 offset) { - if (computePass == NULL) { - SDL_InvalidParamError("computePass"); + if (compute_pass == NULL) { + SDL_InvalidParamError("compute_pass"); return; } - if (COMPUTEPASS_DEVICE->debugMode) { + if (COMPUTEPASS_DEVICE->debug_mode) { CHECK_COMPUTEPASS CHECK_COMPUTE_PIPELINE_BOUND } @@ -1818,20 +1818,20 @@ void SDL_DispatchGPUComputeIndirect( COMPUTEPASS_DEVICE->DispatchComputeIndirect( COMPUTEPASS_COMMAND_BUFFER, buffer, - offsetInBytes); + offset); } void SDL_EndGPUComputePass( - SDL_GPUComputePass *computePass) + SDL_GPUComputePass *compute_pass) { CommandBufferCommonHeader *commandBufferCommonHeader; - if (computePass == NULL) { - SDL_InvalidParamError("computePass"); + if (compute_pass == NULL) { + SDL_InvalidParamError("compute_pass"); return; } - if (COMPUTEPASS_DEVICE->debugMode) { + if (COMPUTEPASS_DEVICE->debug_mode) { CHECK_COMPUTEPASS } @@ -1839,77 +1839,77 @@ void SDL_EndGPUComputePass( COMPUTEPASS_COMMAND_BUFFER); commandBufferCommonHeader = (CommandBufferCommonHeader *)COMPUTEPASS_COMMAND_BUFFER; - commandBufferCommonHeader->computePass.inProgress = false; - commandBufferCommonHeader->computePipelineBound = false; + commandBufferCommonHeader->compute_pass.in_progress = false; + commandBufferCommonHeader->compute_pipeline_bound = false; } // TransferBuffer Data void *SDL_MapGPUTransferBuffer( SDL_GPUDevice *device, - SDL_GPUTransferBuffer *transferBuffer, + SDL_GPUTransferBuffer *transfer_buffer, SDL_bool cycle) { CHECK_DEVICE_MAGIC(device, NULL); - if (transferBuffer == NULL) { - SDL_InvalidParamError("transferBuffer"); + if (transfer_buffer == NULL) { + SDL_InvalidParamError("transfer_buffer"); return NULL; } return device->MapTransferBuffer( device->driverData, - transferBuffer, + transfer_buffer, cycle); } void SDL_UnmapGPUTransferBuffer( SDL_GPUDevice *device, - SDL_GPUTransferBuffer *transferBuffer) + SDL_GPUTransferBuffer *transfer_buffer) { CHECK_DEVICE_MAGIC(device, ); - if (transferBuffer == NULL) { - SDL_InvalidParamError("transferBuffer"); + if (transfer_buffer == NULL) { + SDL_InvalidParamError("transfer_buffer"); return; } device->UnmapTransferBuffer( device->driverData, - transferBuffer); + transfer_buffer); } // Copy Pass SDL_GPUCopyPass *SDL_BeginGPUCopyPass( - SDL_GPUCommandBuffer *commandBuffer) + SDL_GPUCommandBuffer *command_buffer) { CommandBufferCommonHeader *commandBufferHeader; - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return NULL; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER_RETURN_NULL CHECK_ANY_PASS_IN_PROGRESS("Cannot begin copy pass during another pass!", NULL) } COMMAND_BUFFER_DEVICE->BeginCopyPass( - commandBuffer); + command_buffer); - commandBufferHeader = (CommandBufferCommonHeader *)commandBuffer; - commandBufferHeader->copyPass.inProgress = true; - return (SDL_GPUCopyPass *)&(commandBufferHeader->copyPass); + commandBufferHeader = (CommandBufferCommonHeader *)command_buffer; + commandBufferHeader->copy_pass.in_progress = true; + return (SDL_GPUCopyPass *)&(commandBufferHeader->copy_pass); } void SDL_UploadToGPUTexture( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureTransferInfo *source, const SDL_GPUTextureRegion *destination, SDL_bool cycle) { - if (copyPass == NULL) { - SDL_InvalidParamError("copyPass"); + if (copy_pass == NULL) { + SDL_InvalidParamError("copy_pass"); return; } if (source == NULL) { @@ -1921,7 +1921,7 @@ void SDL_UploadToGPUTexture( return; } - if (COPYPASS_DEVICE->debugMode) { + if (COPYPASS_DEVICE->debug_mode) { CHECK_COPYPASS } @@ -1933,13 +1933,13 @@ void SDL_UploadToGPUTexture( } void SDL_UploadToGPUBuffer( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUTransferBufferLocation *source, const SDL_GPUBufferRegion *destination, SDL_bool cycle) { - if (copyPass == NULL) { - SDL_InvalidParamError("copyPass"); + if (copy_pass == NULL) { + SDL_InvalidParamError("copy_pass"); return; } if (source == NULL) { @@ -1959,7 +1959,7 @@ void SDL_UploadToGPUBuffer( } void SDL_CopyGPUTextureToTexture( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureLocation *source, const SDL_GPUTextureLocation *destination, Uint32 w, @@ -1967,8 +1967,8 @@ void SDL_CopyGPUTextureToTexture( Uint32 d, SDL_bool cycle) { - if (copyPass == NULL) { - SDL_InvalidParamError("copyPass"); + if (copy_pass == NULL) { + SDL_InvalidParamError("copy_pass"); return; } if (source == NULL) { @@ -1991,14 +1991,14 @@ void SDL_CopyGPUTextureToTexture( } void SDL_CopyGPUBufferToBuffer( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferLocation *source, const SDL_GPUBufferLocation *destination, Uint32 size, SDL_bool cycle) { - if (copyPass == NULL) { - SDL_InvalidParamError("copyPass"); + if (copy_pass == NULL) { + SDL_InvalidParamError("copy_pass"); return; } if (source == NULL) { @@ -2019,12 +2019,12 @@ void SDL_CopyGPUBufferToBuffer( } void SDL_DownloadFromGPUTexture( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureRegion *source, const SDL_GPUTextureTransferInfo *destination) { - if (copyPass == NULL) { - SDL_InvalidParamError("copyPass"); + if (copy_pass == NULL) { + SDL_InvalidParamError("copy_pass"); return; } if (source == NULL) { @@ -2043,12 +2043,12 @@ void SDL_DownloadFromGPUTexture( } void SDL_DownloadFromGPUBuffer( - SDL_GPUCopyPass *copyPass, + SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferRegion *source, const SDL_GPUTransferBufferLocation *destination) { - if (copyPass == NULL) { - SDL_InvalidParamError("copyPass"); + if (copy_pass == NULL) { + SDL_InvalidParamError("copy_pass"); return; } if (source == NULL) { @@ -2067,29 +2067,29 @@ void SDL_DownloadFromGPUBuffer( } void SDL_EndGPUCopyPass( - SDL_GPUCopyPass *copyPass) + SDL_GPUCopyPass *copy_pass) { - if (copyPass == NULL) { - SDL_InvalidParamError("copyPass"); + if (copy_pass == NULL) { + SDL_InvalidParamError("copy_pass"); return; } - if (COPYPASS_DEVICE->debugMode) { + if (COPYPASS_DEVICE->debug_mode) { CHECK_COPYPASS } COPYPASS_DEVICE->EndCopyPass( COPYPASS_COMMAND_BUFFER); - ((CommandBufferCommonHeader *)COPYPASS_COMMAND_BUFFER)->copyPass.inProgress = false; + ((CommandBufferCommonHeader *)COPYPASS_COMMAND_BUFFER)->copy_pass.in_progress = false; } void SDL_GenerateMipmapsForGPUTexture( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, SDL_GPUTexture *texture) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } if (texture == NULL) { @@ -2097,37 +2097,37 @@ void SDL_GenerateMipmapsForGPUTexture( return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER CHECK_ANY_PASS_IN_PROGRESS("Cannot generate mipmaps during a pass!", ) TextureCommonHeader *header = (TextureCommonHeader *)texture; - if (header->info.levelCount <= 1) { - SDL_assert_release(!"Cannot generate mipmaps for texture with levelCount <= 1!"); + if (header->info.num_levels <= 1) { + SDL_assert_release(!"Cannot generate mipmaps for texture with num_levels <= 1!"); return; } - if (!(header->info.usageFlags & SDL_GPU_TEXTUREUSAGE_SAMPLER) || !(header->info.usageFlags & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) { + if (!(header->info.usage & SDL_GPU_TEXTUREUSAGE_SAMPLER) || !(header->info.usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) { SDL_assert_release(!"GenerateMipmaps texture must be created with SAMPLER and COLOR_TARGET usage flags!"); return; } } COMMAND_BUFFER_DEVICE->GenerateMipmaps( - commandBuffer, + command_buffer, texture); } void SDL_BlitGPUTexture( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, - SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_FlipMode flip_mode, + SDL_GPUFilter filter, SDL_bool cycle) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } if (source == NULL) { @@ -2139,7 +2139,7 @@ void SDL_BlitGPUTexture( return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER CHECK_ANY_PASS_IN_PROGRESS("Cannot blit during a pass!", ) @@ -2152,11 +2152,11 @@ void SDL_BlitGPUTexture( SDL_assert_release(!"Blit source and destination textures must be non-NULL"); return; // attempting to proceed will crash } - if ((srcHeader->info.usageFlags & SDL_GPU_TEXTUREUSAGE_SAMPLER) == 0) { + if ((srcHeader->info.usage & SDL_GPU_TEXTUREUSAGE_SAMPLER) == 0) { SDL_assert_release(!"Blit source texture must be created with the SAMPLER usage flag"); failed = true; } - if ((dstHeader->info.usageFlags & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET) == 0) { + if ((dstHeader->info.usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET) == 0) { SDL_assert_release(!"Blit destination texture must be created with the COLOR_TARGET usage flag"); failed = true; } @@ -2175,11 +2175,11 @@ void SDL_BlitGPUTexture( } COMMAND_BUFFER_DEVICE->Blit( - commandBuffer, + command_buffer, source, destination, - flipMode, - filterMode, + flip_mode, + filter, cycle); } @@ -2188,7 +2188,7 @@ void SDL_BlitGPUTexture( SDL_bool SDL_WindowSupportsGPUSwapchainComposition( SDL_GPUDevice *device, SDL_Window *window, - SDL_GPUSwapchainComposition swapchainComposition) + SDL_GPUSwapchainComposition swapchain_composition) { CHECK_DEVICE_MAGIC(device, false); if (window == NULL) { @@ -2196,20 +2196,20 @@ SDL_bool SDL_WindowSupportsGPUSwapchainComposition( return false; } - if (device->debugMode) { - CHECK_SWAPCHAINCOMPOSITION_ENUM_INVALID(swapchainComposition, false) + if (device->debug_mode) { + CHECK_SWAPCHAINCOMPOSITION_ENUM_INVALID(swapchain_composition, false) } return device->SupportsSwapchainComposition( device->driverData, window, - swapchainComposition); + swapchain_composition); } SDL_bool SDL_WindowSupportsGPUPresentMode( SDL_GPUDevice *device, SDL_Window *window, - SDL_GPUPresentMode presentMode) + SDL_GPUPresentMode present_mode) { CHECK_DEVICE_MAGIC(device, false); if (window == NULL) { @@ -2217,14 +2217,14 @@ SDL_bool SDL_WindowSupportsGPUPresentMode( return false; } - if (device->debugMode) { - CHECK_PRESENTMODE_ENUM_INVALID(presentMode, false) + if (device->debug_mode) { + CHECK_PRESENTMODE_ENUM_INVALID(present_mode, false) } return device->SupportsPresentMode( device->driverData, window, - presentMode); + present_mode); } SDL_bool SDL_ClaimWindowForGPUDevice( @@ -2260,8 +2260,8 @@ void SDL_ReleaseWindowFromGPUDevice( SDL_bool SDL_SetGPUSwapchainParameters( SDL_GPUDevice *device, SDL_Window *window, - SDL_GPUSwapchainComposition swapchainComposition, - SDL_GPUPresentMode presentMode) + SDL_GPUSwapchainComposition swapchain_composition, + SDL_GPUPresentMode present_mode) { CHECK_DEVICE_MAGIC(device, false); if (window == NULL) { @@ -2269,16 +2269,16 @@ SDL_bool SDL_SetGPUSwapchainParameters( return false; } - if (device->debugMode) { - CHECK_SWAPCHAINCOMPOSITION_ENUM_INVALID(swapchainComposition, false) - CHECK_PRESENTMODE_ENUM_INVALID(presentMode, false) + if (device->debug_mode) { + CHECK_SWAPCHAINCOMPOSITION_ENUM_INVALID(swapchain_composition, false) + CHECK_PRESENTMODE_ENUM_INVALID(present_mode, false) } return device->SetSwapchainParameters( device->driverData, window, - swapchainComposition, - presentMode); + swapchain_composition, + present_mode); } SDL_GPUTextureFormat SDL_GetGPUSwapchainTextureFormat( @@ -2297,56 +2297,56 @@ SDL_GPUTextureFormat SDL_GetGPUSwapchainTextureFormat( } SDL_GPUTexture *SDL_AcquireGPUSwapchainTexture( - SDL_GPUCommandBuffer *commandBuffer, + SDL_GPUCommandBuffer *command_buffer, SDL_Window *window, - Uint32 *pWidth, - Uint32 *pHeight) + Uint32 *w, + Uint32 *h) { - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return NULL; } if (window == NULL) { SDL_InvalidParamError("window"); return NULL; } - if (pWidth == NULL) { - SDL_InvalidParamError("pWidth"); + if (w == NULL) { + SDL_InvalidParamError("w"); return NULL; } - if (pHeight == NULL) { - SDL_InvalidParamError("pHeight"); + if (h == NULL) { + SDL_InvalidParamError("h"); return NULL; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER_RETURN_NULL CHECK_ANY_PASS_IN_PROGRESS("Cannot acquire a swapchain texture during a pass!", NULL) } return COMMAND_BUFFER_DEVICE->AcquireSwapchainTexture( - commandBuffer, + command_buffer, window, - pWidth, - pHeight); + w, + h); } void SDL_SubmitGPUCommandBuffer( - SDL_GPUCommandBuffer *commandBuffer) + SDL_GPUCommandBuffer *command_buffer) { - CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)commandBuffer; + CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer; - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER if ( - commandBufferHeader->renderPass.inProgress || - commandBufferHeader->computePass.inProgress || - commandBufferHeader->copyPass.inProgress) { + commandBufferHeader->render_pass.in_progress || + commandBufferHeader->compute_pass.in_progress || + commandBufferHeader->copy_pass.in_progress) { SDL_assert_release(!"Cannot submit command buffer while a pass is in progress!"); return; } @@ -2355,25 +2355,25 @@ void SDL_SubmitGPUCommandBuffer( commandBufferHeader->submitted = true; COMMAND_BUFFER_DEVICE->Submit( - commandBuffer); + command_buffer); } SDL_GPUFence *SDL_SubmitGPUCommandBufferAndAcquireFence( - SDL_GPUCommandBuffer *commandBuffer) + SDL_GPUCommandBuffer *command_buffer) { - CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)commandBuffer; + CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer; - if (commandBuffer == NULL) { - SDL_InvalidParamError("commandBuffer"); + if (command_buffer == NULL) { + SDL_InvalidParamError("command_buffer"); return NULL; } - if (COMMAND_BUFFER_DEVICE->debugMode) { + if (COMMAND_BUFFER_DEVICE->debug_mode) { CHECK_COMMAND_BUFFER_RETURN_NULL if ( - commandBufferHeader->renderPass.inProgress || - commandBufferHeader->computePass.inProgress || - commandBufferHeader->copyPass.inProgress) { + commandBufferHeader->render_pass.in_progress || + commandBufferHeader->compute_pass.in_progress || + commandBufferHeader->copy_pass.in_progress) { SDL_assert_release(!"Cannot submit command buffer while a pass is in progress!"); return NULL; } @@ -2382,7 +2382,7 @@ SDL_GPUFence *SDL_SubmitGPUCommandBufferAndAcquireFence( commandBufferHeader->submitted = true; return COMMAND_BUFFER_DEVICE->SubmitAndAcquireFence( - commandBuffer); + command_buffer); } void SDL_WaitForGPUIdle( @@ -2396,21 +2396,21 @@ void SDL_WaitForGPUIdle( void SDL_WaitForGPUFences( SDL_GPUDevice *device, - SDL_bool waitAll, - SDL_GPUFence *const *pFences, - Uint32 fenceCount) + SDL_bool wait_all, + SDL_GPUFence *const *fences, + Uint32 num_fences) { CHECK_DEVICE_MAGIC(device, ); - if (pFences == NULL && fenceCount > 0) { - SDL_InvalidParamError("pFences"); + if (fences == NULL && num_fences > 0) { + SDL_InvalidParamError("fences"); return; } device->WaitForFences( device->driverData, - waitAll, - pFences, - fenceCount); + wait_all, + fences, + num_fences); } SDL_bool SDL_QueryGPUFence( diff --git a/src/gpu/SDL_sysgpu.h b/src/gpu/SDL_sysgpu.h index f9585e5b4b..f419c4b1d2 100644 --- a/src/gpu/SDL_sysgpu.h +++ b/src/gpu/SDL_sysgpu.h @@ -28,18 +28,18 @@ typedef struct Pass { - SDL_GPUCommandBuffer *commandBuffer; - bool inProgress; + SDL_GPUCommandBuffer *command_buffer; + bool in_progress; } Pass; typedef struct CommandBufferCommonHeader { SDL_GPUDevice *device; - Pass renderPass; - bool graphicsPipelineBound; - Pass computePass; - bool computePipelineBound; - Pass copyPass; + Pass render_pass; + bool graphics_pipeline_bound; + Pass compute_pass; + bool compute_pipeline_bound; + Pass copy_pass; bool submitted; } CommandBufferCommonHeader; @@ -56,8 +56,8 @@ typedef struct BlitFragmentUniforms float width; float height; - Uint32 mipLevel; - float layerOrDepth; + Uint32 mip_level; + float layer_or_depth; } BlitFragmentUniforms; typedef struct BlitPipelineCacheEntry @@ -266,7 +266,7 @@ void SDL_GPU_BlitCommon( const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_GPUFilter filter, bool cycle, SDL_GPUSampler *blitLinearSampler, SDL_GPUSampler *blitNearestSampler, @@ -297,33 +297,33 @@ struct SDL_GPUDevice SDL_GPUComputePipeline *(*CreateComputePipeline)( SDL_GPURenderer *driverData, - const SDL_GPUComputePipelineCreateInfo *pipelineCreateInfo); + const SDL_GPUComputePipelineCreateInfo *createinfo); SDL_GPUGraphicsPipeline *(*CreateGraphicsPipeline)( SDL_GPURenderer *driverData, - const SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo); + const SDL_GPUGraphicsPipelineCreateInfo *createinfo); SDL_GPUSampler *(*CreateSampler)( SDL_GPURenderer *driverData, - const SDL_GPUSamplerCreateInfo *samplerCreateInfo); + const SDL_GPUSamplerCreateInfo *createinfo); SDL_GPUShader *(*CreateShader)( SDL_GPURenderer *driverData, - const SDL_GPUShaderCreateInfo *shaderCreateInfo); + const SDL_GPUShaderCreateInfo *createinfo); SDL_GPUTexture *(*CreateTexture)( SDL_GPURenderer *driverData, - const SDL_GPUTextureCreateInfo *textureCreateInfo); + const SDL_GPUTextureCreateInfo *createinfo); SDL_GPUBuffer *(*CreateBuffer)( SDL_GPURenderer *driverData, SDL_GPUBufferUsageFlags usageFlags, - Uint32 sizeInBytes); + Uint32 size); SDL_GPUTransferBuffer *(*CreateTransferBuffer)( SDL_GPURenderer *driverData, SDL_GPUTransferBufferUsage usage, - Uint32 sizeInBytes); + Uint32 size); // Debug Naming @@ -382,9 +382,9 @@ struct SDL_GPUDevice void (*BeginRenderPass)( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo); + const SDL_GPUColorTargetInfo *colorTargetInfos, + Uint32 numColorTargets, + const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo); void (*BindGraphicsPipeline)( SDL_GPUCommandBuffer *commandBuffer, @@ -409,90 +409,90 @@ struct SDL_GPUDevice void (*BindVertexBuffers)( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstBinding, - const SDL_GPUBufferBinding *pBindings, - Uint32 bindingCount); + const SDL_GPUBufferBinding *bindings, + Uint32 numBindings); void (*BindIndexBuffer)( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUBufferBinding *pBinding, + const SDL_GPUBufferBinding *binding, SDL_GPUIndexElementSize indexElementSize); void (*BindVertexSamplers)( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount); + Uint32 numBindings); void (*BindVertexStorageTextures)( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount); + Uint32 numBindings); void (*BindVertexStorageBuffers)( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount); + Uint32 numBindings); void (*BindFragmentSamplers)( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount); + Uint32 numBindings); void (*BindFragmentStorageTextures)( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount); + Uint32 numBindings); void (*BindFragmentStorageBuffers)( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount); + Uint32 numBindings); void (*PushVertexUniformData)( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes); + Uint32 length); void (*PushFragmentUniformData)( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes); + Uint32 length); void (*DrawIndexedPrimitives)( SDL_GPUCommandBuffer *commandBuffer, - Uint32 indexCount, - Uint32 instanceCount, + Uint32 numIndices, + Uint32 numInstances, Uint32 firstIndex, Sint32 vertexOffset, Uint32 firstInstance); void (*DrawPrimitives)( SDL_GPUCommandBuffer *commandBuffer, - Uint32 vertexCount, - Uint32 instanceCount, + Uint32 numVertices, + Uint32 numInstances, Uint32 firstVertex, Uint32 firstInstance); void (*DrawPrimitivesIndirect)( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride); + Uint32 pitch); void (*DrawIndexedPrimitivesIndirect)( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride); + Uint32 pitch); void (*EndRenderPass)( SDL_GPUCommandBuffer *commandBuffer); @@ -502,9 +502,9 @@ struct SDL_GPUDevice void (*BeginComputePass)( SDL_GPUCommandBuffer *commandBuffer, const SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings, - Uint32 storageTextureBindingCount, + Uint32 numStorageTextureBindings, const SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings, - Uint32 storageBufferBindingCount); + Uint32 numStorageBufferBindings); void (*BindComputePipeline)( SDL_GPUCommandBuffer *commandBuffer, @@ -514,30 +514,30 @@ struct SDL_GPUDevice SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount); + Uint32 numBindings); void (*BindComputeStorageBuffers)( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount); + Uint32 numBindings); void (*PushComputeUniformData)( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes); + Uint32 length); void (*DispatchCompute)( SDL_GPUCommandBuffer *commandBuffer, - Uint32 groupCountX, - Uint32 groupCountY, - Uint32 groupCountZ); + Uint32 groupcountX, + Uint32 groupcountY, + Uint32 groupcountZ); void (*DispatchComputeIndirect)( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes); + Uint32 offset); void (*EndComputePass)( SDL_GPUCommandBuffer *commandBuffer); @@ -608,7 +608,7 @@ struct SDL_GPUDevice const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_GPUFilter filter, bool cycle); // Submission/Presentation @@ -647,8 +647,8 @@ struct SDL_GPUDevice SDL_GPUTexture *(*AcquireSwapchainTexture)( SDL_GPUCommandBuffer *commandBuffer, SDL_Window *window, - Uint32 *pWidth, - Uint32 *pHeight); + Uint32 *w, + Uint32 *h); void (*Submit)( SDL_GPUCommandBuffer *commandBuffer); @@ -662,8 +662,8 @@ struct SDL_GPUDevice void (*WaitForFences)( SDL_GPURenderer *driverData, bool waitAll, - SDL_GPUFence *const *pFences, - Uint32 fenceCount); + SDL_GPUFence *const *fences, + Uint32 numFences); bool (*QueryFence)( SDL_GPURenderer *driverData, @@ -693,8 +693,8 @@ struct SDL_GPUDevice SDL_GPUDriver backend; // Store this for SDL_gpu.c's debug layer - bool debugMode; - SDL_GPUShaderFormat shaderFormats; + bool debug_mode; + SDL_GPUShaderFormat shader_formats; }; #define ASSIGN_DRIVER_FUNC(func, name) \ @@ -780,11 +780,11 @@ struct SDL_GPUDevice typedef struct SDL_GPUBootstrap { - const char *Name; + const char *name; const SDL_GPUDriver backendflag; - const SDL_GPUShaderFormat shaderFormats; + const SDL_GPUShaderFormat shader_formats; bool (*PrepareDriver)(SDL_VideoDevice *_this); - SDL_GPUDevice *(*CreateDevice)(bool debugMode, bool preferLowPower, SDL_PropertiesID props); + SDL_GPUDevice *(*CreateDevice)(bool debug_mode, bool prefer_low_power, SDL_PropertiesID props); } SDL_GPUBootstrap; #ifdef __cplusplus diff --git a/src/gpu/d3d11/SDL_gpu_d3d11.c b/src/gpu/d3d11/SDL_gpu_d3d11.c index 741a593b95..bffd91d9d1 100644 --- a/src/gpu/d3d11/SDL_gpu_d3d11.c +++ b/src/gpu/d3d11/SDL_gpu_d3d11.c @@ -361,29 +361,29 @@ static D3D11_TEXTURE_ADDRESS_MODE SDLToD3D11_SamplerAddressMode[] = { static D3D11_FILTER SDLToD3D11_Filter(const SDL_GPUSamplerCreateInfo *createInfo) { - if (createInfo->minFilter == SDL_GPU_FILTER_LINEAR) { - if (createInfo->magFilter == SDL_GPU_FILTER_LINEAR) { - if (createInfo->mipmapMode == SDL_GPU_SAMPLERMIPMAPMODE_LINEAR) { + if (createInfo->min_filter == SDL_GPU_FILTER_LINEAR) { + if (createInfo->mag_filter == SDL_GPU_FILTER_LINEAR) { + if (createInfo->mipmap_mode == SDL_GPU_SAMPLERMIPMAPMODE_LINEAR) { return D3D11_FILTER_MIN_MAG_MIP_LINEAR; } else { return D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT; } } else { - if (createInfo->mipmapMode == SDL_GPU_SAMPLERMIPMAPMODE_LINEAR) { + if (createInfo->mipmap_mode == SDL_GPU_SAMPLERMIPMAPMODE_LINEAR) { return D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR; } else { return D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT; } } } else { - if (createInfo->magFilter == SDL_GPU_FILTER_LINEAR) { - if (createInfo->mipmapMode == SDL_GPU_SAMPLERMIPMAPMODE_LINEAR) { + if (createInfo->mag_filter == SDL_GPU_FILTER_LINEAR) { + if (createInfo->mipmap_mode == SDL_GPU_SAMPLERMIPMAPMODE_LINEAR) { return D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR; } else { return D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT; } } else { - if (createInfo->mipmapMode == SDL_GPU_SAMPLERMIPMAPMODE_LINEAR) { + if (createInfo->mipmap_mode == SDL_GPU_SAMPLERMIPMAPMODE_LINEAR) { return D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR; } else { return D3D11_FILTER_MIN_MAG_MIP_POINT; @@ -437,7 +437,7 @@ struct D3D11Texture ID3D11ShaderResourceView *shaderView; D3D11TextureSubresource *subresources; - Uint32 subresourceCount; /* layerCount * levelCount */ + Uint32 subresourceCount; /* layerCount * num_levels */ SDL_AtomicInt referenceCount; }; @@ -468,22 +468,22 @@ typedef struct D3D11Shader void *bytecode; size_t bytecodeSize; - Uint32 samplerCount; - Uint32 uniformBufferCount; - Uint32 storageBufferCount; - Uint32 storageTextureCount; + Uint32 numSamplers; + Uint32 numUniformBuffers; + Uint32 numStorageBuffers; + Uint32 numStorageTextures; } D3D11Shader; typedef struct D3D11GraphicsPipeline { - Sint32 numColorAttachments; - DXGI_FORMAT colorAttachmentFormats[MAX_COLOR_TARGET_BINDINGS]; - ID3D11BlendState *colorAttachmentBlendState; + Sint32 numColorTargets; + DXGI_FORMAT colorTargetFormats[MAX_COLOR_TARGET_BINDINGS]; + ID3D11BlendState *colorTargetBlendState; SDL_GPUMultisampleState multisampleState; - Uint8 hasDepthStencilAttachment; - DXGI_FORMAT depthStencilAttachmentFormat; + Uint8 hasDepthStencilTarget; + DXGI_FORMAT depthStencilTargetFormat; ID3D11DepthStencilState *depthStencilState; SDL_GPUPrimitiveType primitiveType; @@ -510,11 +510,11 @@ typedef struct D3D11ComputePipeline { ID3D11ComputeShader *computeShader; - Uint32 readOnlyStorageTextureCount; - Uint32 writeOnlyStorageTextureCount; - Uint32 readOnlyStorageBufferCount; - Uint32 writeOnlyStorageBufferCount; - Uint32 uniformBufferCount; + Uint32 numReadonlyStorageTextures; + Uint32 numWriteonlyStorageTextures; + Uint32 numReadonlyStorageBuffers; + Uint32 numWriteonlyStorageBuffers; + Uint32 numUniformBuffers; } D3D11ComputePipeline; typedef struct D3D11Buffer @@ -1227,7 +1227,7 @@ static void D3D11_ReleaseGraphicsPipeline( (void)driverData; // used by other backends D3D11GraphicsPipeline *d3d11GraphicsPipeline = (D3D11GraphicsPipeline *)graphicsPipeline; - ID3D11BlendState_Release(d3d11GraphicsPipeline->colorAttachmentBlendState); + ID3D11BlendState_Release(d3d11GraphicsPipeline->colorTargetBlendState); ID3D11DepthStencilState_Release(d3d11GraphicsPipeline->depthStencilState); ID3D11RasterizerState_Release(d3d11GraphicsPipeline->rasterizerState); @@ -1248,8 +1248,8 @@ static void D3D11_ReleaseGraphicsPipeline( static ID3D11BlendState *D3D11_INTERNAL_FetchBlendState( D3D11Renderer *renderer, - Uint32 numColorAttachments, - const SDL_GPUColorAttachmentDescription *colorAttachments) + Uint32 numColorTargets, + const SDL_GPUColorTargetDescription *colorTargets) { ID3D11BlendState *result; D3D11_BLEND_DESC blendDesc; @@ -1263,15 +1263,15 @@ static ID3D11BlendState *D3D11_INTERNAL_FetchBlendState( blendDesc.AlphaToCoverageEnable = FALSE; blendDesc.IndependentBlendEnable = TRUE; - for (Uint32 i = 0; i < numColorAttachments; i += 1) { - blendDesc.RenderTarget[i].BlendEnable = colorAttachments[i].blendState.blendEnable; - blendDesc.RenderTarget[i].BlendOp = SDLToD3D11_BlendOp[colorAttachments[i].blendState.colorBlendOp]; - blendDesc.RenderTarget[i].BlendOpAlpha = SDLToD3D11_BlendOp[colorAttachments[i].blendState.alphaBlendOp]; - blendDesc.RenderTarget[i].DestBlend = SDLToD3D11_BlendFactor[colorAttachments[i].blendState.dstColorBlendFactor]; - blendDesc.RenderTarget[i].DestBlendAlpha = SDLToD3D11_BlendFactorAlpha[colorAttachments[i].blendState.dstAlphaBlendFactor]; - blendDesc.RenderTarget[i].RenderTargetWriteMask = colorAttachments[i].blendState.colorWriteMask; - blendDesc.RenderTarget[i].SrcBlend = SDLToD3D11_BlendFactor[colorAttachments[i].blendState.srcColorBlendFactor]; - blendDesc.RenderTarget[i].SrcBlendAlpha = SDLToD3D11_BlendFactorAlpha[colorAttachments[i].blendState.srcAlphaBlendFactor]; + for (Uint32 i = 0; i < numColorTargets; i += 1) { + blendDesc.RenderTarget[i].BlendEnable = colorTargets[i].blend_state.enable_blend; + blendDesc.RenderTarget[i].BlendOp = SDLToD3D11_BlendOp[colorTargets[i].blend_state.color_blend_op]; + blendDesc.RenderTarget[i].BlendOpAlpha = SDLToD3D11_BlendOp[colorTargets[i].blend_state.alpha_blend_op]; + blendDesc.RenderTarget[i].DestBlend = SDLToD3D11_BlendFactor[colorTargets[i].blend_state.dst_color_blendfactor]; + blendDesc.RenderTarget[i].DestBlendAlpha = SDLToD3D11_BlendFactorAlpha[colorTargets[i].blend_state.dst_alpha_blendfactor]; + blendDesc.RenderTarget[i].RenderTargetWriteMask = colorTargets[i].blend_state.color_write_mask; + blendDesc.RenderTarget[i].SrcBlend = SDLToD3D11_BlendFactor[colorTargets[i].blend_state.src_color_blendfactor]; + blendDesc.RenderTarget[i].SrcBlendAlpha = SDLToD3D11_BlendFactorAlpha[colorTargets[i].blend_state.src_alpha_blendfactor]; } res = ID3D11Device_CreateBlendState( @@ -1294,23 +1294,23 @@ static ID3D11DepthStencilState *D3D11_INTERNAL_FetchDepthStencilState( /* Create a new depth-stencil state. * The spec says the driver will not create duplicate states, so there's no need to cache. */ - dsDesc.DepthEnable = depthStencilState.depthTestEnable; - dsDesc.StencilEnable = depthStencilState.stencilTestEnable; - dsDesc.DepthFunc = SDLToD3D11_CompareOp[depthStencilState.compareOp]; - dsDesc.DepthWriteMask = (depthStencilState.depthWriteEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO); + dsDesc.DepthEnable = depthStencilState.enable_depth_test; + dsDesc.StencilEnable = depthStencilState.enable_stencil_test; + dsDesc.DepthFunc = SDLToD3D11_CompareOp[depthStencilState.compare_op]; + dsDesc.DepthWriteMask = (depthStencilState.enable_depth_write ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO); - dsDesc.BackFace.StencilFunc = SDLToD3D11_CompareOp[depthStencilState.backStencilState.compareOp]; - dsDesc.BackFace.StencilDepthFailOp = SDLToD3D11_StencilOp[depthStencilState.backStencilState.depthFailOp]; - dsDesc.BackFace.StencilFailOp = SDLToD3D11_StencilOp[depthStencilState.backStencilState.failOp]; - dsDesc.BackFace.StencilPassOp = SDLToD3D11_StencilOp[depthStencilState.backStencilState.passOp]; + dsDesc.BackFace.StencilFunc = SDLToD3D11_CompareOp[depthStencilState.back_stencil_state.compare_op]; + dsDesc.BackFace.StencilDepthFailOp = SDLToD3D11_StencilOp[depthStencilState.back_stencil_state.depth_fail_op]; + dsDesc.BackFace.StencilFailOp = SDLToD3D11_StencilOp[depthStencilState.back_stencil_state.fail_op]; + dsDesc.BackFace.StencilPassOp = SDLToD3D11_StencilOp[depthStencilState.back_stencil_state.pass_op]; - dsDesc.FrontFace.StencilFunc = SDLToD3D11_CompareOp[depthStencilState.frontStencilState.compareOp]; - dsDesc.FrontFace.StencilDepthFailOp = SDLToD3D11_StencilOp[depthStencilState.frontStencilState.depthFailOp]; - dsDesc.FrontFace.StencilFailOp = SDLToD3D11_StencilOp[depthStencilState.frontStencilState.failOp]; - dsDesc.FrontFace.StencilPassOp = SDLToD3D11_StencilOp[depthStencilState.frontStencilState.passOp]; + dsDesc.FrontFace.StencilFunc = SDLToD3D11_CompareOp[depthStencilState.front_stencil_state.compare_op]; + dsDesc.FrontFace.StencilDepthFailOp = SDLToD3D11_StencilOp[depthStencilState.front_stencil_state.depth_fail_op]; + dsDesc.FrontFace.StencilFailOp = SDLToD3D11_StencilOp[depthStencilState.front_stencil_state.fail_op]; + dsDesc.FrontFace.StencilPassOp = SDLToD3D11_StencilOp[depthStencilState.front_stencil_state.pass_op]; - dsDesc.StencilReadMask = depthStencilState.compareMask; - dsDesc.StencilWriteMask = depthStencilState.writeMask; + dsDesc.StencilReadMask = depthStencilState.compare_mask; + dsDesc.StencilWriteMask = depthStencilState.write_mask; res = ID3D11Device_CreateDepthStencilState( renderer->device, @@ -1333,15 +1333,15 @@ static ID3D11RasterizerState *D3D11_INTERNAL_FetchRasterizerState( * The spec says the driver will not create duplicate states, so there's no need to cache. */ rasterizerDesc.AntialiasedLineEnable = FALSE; - rasterizerDesc.CullMode = SDLToD3D11_CullMode[rasterizerState.cullMode]; - rasterizerDesc.DepthBias = SDL_lroundf(rasterizerState.depthBiasConstantFactor); - rasterizerDesc.DepthBiasClamp = rasterizerState.depthBiasClamp; + rasterizerDesc.CullMode = SDLToD3D11_CullMode[rasterizerState.cull_mode]; + rasterizerDesc.DepthBias = SDL_lroundf(rasterizerState.depth_bias_constant_factor); + rasterizerDesc.DepthBiasClamp = rasterizerState.depth_bias_clamp; rasterizerDesc.DepthClipEnable = TRUE; - rasterizerDesc.FillMode = (rasterizerState.fillMode == SDL_GPU_FILLMODE_FILL) ? D3D11_FILL_SOLID : D3D11_FILL_WIREFRAME; - rasterizerDesc.FrontCounterClockwise = (rasterizerState.frontFace == SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE); + rasterizerDesc.FillMode = (rasterizerState.fill_mode == SDL_GPU_FILLMODE_FILL) ? D3D11_FILL_SOLID : D3D11_FILL_WIREFRAME; + rasterizerDesc.FrontCounterClockwise = (rasterizerState.front_face == SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE); rasterizerDesc.MultisampleEnable = TRUE; // only applies to MSAA render targets rasterizerDesc.ScissorEnable = TRUE; - rasterizerDesc.SlopeScaledDepthBias = rasterizerState.depthBiasSlopeFactor; + rasterizerDesc.SlopeScaledDepthBias = rasterizerState.depth_bias_slope_factor; res = ID3D11Device_CreateRasterizerState( renderer->device, @@ -1379,37 +1379,37 @@ static ID3D11InputLayout *D3D11_INTERNAL_FetchInputLayout( HRESULT res; // Don't bother creating/fetching an input layout if there are no attributes. - if (inputState.vertexAttributeCount == 0) { + if (inputState.num_vertex_attributes == 0) { return NULL; } // Allocate an array of vertex elements elementDescs = SDL_stack_alloc( D3D11_INPUT_ELEMENT_DESC, - inputState.vertexAttributeCount); + inputState.num_vertex_attributes); // Create the array of input elements - for (Uint32 i = 0; i < inputState.vertexAttributeCount; i += 1) { - elementDescs[i].AlignedByteOffset = inputState.vertexAttributes[i].offset; - elementDescs[i].Format = SDLToD3D11_VertexFormat[inputState.vertexAttributes[i].format]; - elementDescs[i].InputSlot = inputState.vertexAttributes[i].binding; + for (Uint32 i = 0; i < inputState.num_vertex_attributes; i += 1) { + elementDescs[i].AlignedByteOffset = inputState.vertex_attributes[i].offset; + elementDescs[i].Format = SDLToD3D11_VertexFormat[inputState.vertex_attributes[i].format]; + elementDescs[i].InputSlot = inputState.vertex_attributes[i].binding; bindingIndex = D3D11_INTERNAL_FindIndexOfVertexBinding( elementDescs[i].InputSlot, - inputState.vertexBindings, - inputState.vertexBindingCount); - elementDescs[i].InputSlotClass = SDLToD3D11_VertexInputRate[inputState.vertexBindings[bindingIndex].inputRate]; + inputState.vertex_bindings, + inputState.num_vertex_bindings); + elementDescs[i].InputSlotClass = SDLToD3D11_VertexInputRate[inputState.vertex_bindings[bindingIndex].input_rate]; // The spec requires this to be 0 for per-vertex data - elementDescs[i].InstanceDataStepRate = (inputState.vertexBindings[bindingIndex].inputRate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) ? inputState.vertexBindings[bindingIndex].instanceStepRate : 0; + elementDescs[i].InstanceDataStepRate = (inputState.vertex_bindings[bindingIndex].input_rate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) ? inputState.vertex_bindings[bindingIndex].instance_step_rate : 0; - elementDescs[i].SemanticIndex = inputState.vertexAttributes[i].location; + elementDescs[i].SemanticIndex = inputState.vertex_attributes[i].location; elementDescs[i].SemanticName = "TEXCOORD"; } res = ID3D11Device_CreateInputLayout( renderer->device, elementDescs, - inputState.vertexAttributeCount, + inputState.num_vertex_attributes, shaderBytes, shaderByteLength, &result); @@ -1435,7 +1435,7 @@ static ID3D11DeviceChild *D3D11_INTERNAL_CreateID3D11Shader( Uint32 stage, const Uint8 *code, size_t codeSize, - const char *entryPointName, + const char *entrypointName, void **pBytecode, size_t *pBytecodeSize) { @@ -1489,7 +1489,7 @@ static ID3D11DeviceChild *D3D11_INTERNAL_CreateID3D11Shader( static SDL_GPUComputePipeline *D3D11_CreateComputePipeline( SDL_GPURenderer *driverData, - const SDL_GPUComputePipelineCreateInfo *pipelineCreateInfo) + const SDL_GPUComputePipelineCreateInfo *createinfo) { D3D11Renderer *renderer = (D3D11Renderer *)driverData; ID3D11ComputeShader *shader; @@ -1498,9 +1498,9 @@ static SDL_GPUComputePipeline *D3D11_CreateComputePipeline( shader = (ID3D11ComputeShader *)D3D11_INTERNAL_CreateID3D11Shader( renderer, SDL_GPU_SHADERSTAGE_COMPUTE, - pipelineCreateInfo->code, - pipelineCreateInfo->codeSize, - pipelineCreateInfo->entryPointName, + createinfo->code, + createinfo->code_size, + createinfo->entrypoint, NULL, NULL); if (shader == NULL) { @@ -1510,11 +1510,11 @@ static SDL_GPUComputePipeline *D3D11_CreateComputePipeline( pipeline = SDL_malloc(sizeof(D3D11ComputePipeline)); pipeline->computeShader = shader; - pipeline->readOnlyStorageTextureCount = pipelineCreateInfo->readOnlyStorageTextureCount; - pipeline->writeOnlyStorageTextureCount = pipelineCreateInfo->writeOnlyStorageTextureCount; - pipeline->readOnlyStorageBufferCount = pipelineCreateInfo->readOnlyStorageBufferCount; - pipeline->writeOnlyStorageBufferCount = pipelineCreateInfo->writeOnlyStorageBufferCount; - pipeline->uniformBufferCount = pipelineCreateInfo->uniformBufferCount; + pipeline->numReadonlyStorageTextures = createinfo->num_readonly_storage_textures; + pipeline->numWriteonlyStorageTextures = createinfo->num_writeonly_storage_textures; + pipeline->numReadonlyStorageBuffers = createinfo->num_readonly_storage_buffers; + pipeline->numWriteonlyStorageBuffers = createinfo->num_writeonly_storage_buffers; + pipeline->numUniformBuffers = createinfo->num_uniform_buffers; // thread counts are ignored in d3d11 return (SDL_GPUComputePipeline *)pipeline; @@ -1522,44 +1522,44 @@ static SDL_GPUComputePipeline *D3D11_CreateComputePipeline( static SDL_GPUGraphicsPipeline *D3D11_CreateGraphicsPipeline( SDL_GPURenderer *driverData, - const SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo) + const SDL_GPUGraphicsPipelineCreateInfo *createinfo) { D3D11Renderer *renderer = (D3D11Renderer *)driverData; - D3D11Shader *vertShader = (D3D11Shader *)pipelineCreateInfo->vertexShader; - D3D11Shader *fragShader = (D3D11Shader *)pipelineCreateInfo->fragmentShader; + D3D11Shader *vertShader = (D3D11Shader *)createinfo->vertex_shader; + D3D11Shader *fragShader = (D3D11Shader *)createinfo->fragment_shader; D3D11GraphicsPipeline *pipeline = SDL_malloc(sizeof(D3D11GraphicsPipeline)); // Blend - pipeline->colorAttachmentBlendState = D3D11_INTERNAL_FetchBlendState( + pipeline->colorTargetBlendState = D3D11_INTERNAL_FetchBlendState( renderer, - pipelineCreateInfo->attachmentInfo.colorAttachmentCount, - pipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions); + createinfo->target_info.num_color_targets, + createinfo->target_info.color_target_descriptions); - pipeline->numColorAttachments = pipelineCreateInfo->attachmentInfo.colorAttachmentCount; - for (Sint32 i = 0; i < pipeline->numColorAttachments; i += 1) { - pipeline->colorAttachmentFormats[i] = SDLToD3D11_TextureFormat[pipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions[i].format]; + pipeline->numColorTargets = createinfo->target_info.num_color_targets; + for (Sint32 i = 0; i < pipeline->numColorTargets; i += 1) { + pipeline->colorTargetFormats[i] = SDLToD3D11_TextureFormat[createinfo->target_info.color_target_descriptions[i].format]; } // Multisample - pipeline->multisampleState = pipelineCreateInfo->multisampleState; + pipeline->multisampleState = createinfo->multisample_state; // Depth-Stencil pipeline->depthStencilState = D3D11_INTERNAL_FetchDepthStencilState( renderer, - pipelineCreateInfo->depthStencilState); + createinfo->depth_stencil_state); - pipeline->hasDepthStencilAttachment = pipelineCreateInfo->attachmentInfo.hasDepthStencilAttachment; - pipeline->depthStencilAttachmentFormat = SDLToD3D11_TextureFormat[pipelineCreateInfo->attachmentInfo.depthStencilFormat]; + pipeline->hasDepthStencilTarget = createinfo->target_info.has_depth_stencil_target; + pipeline->depthStencilTargetFormat = SDLToD3D11_TextureFormat[createinfo->target_info.depth_stencil_format]; // Rasterizer - pipeline->primitiveType = pipelineCreateInfo->primitiveType; + pipeline->primitiveType = createinfo->primitive_type; pipeline->rasterizerState = D3D11_INTERNAL_FetchRasterizerState( renderer, - pipelineCreateInfo->rasterizerState); + createinfo->rasterizer_state); // Shaders @@ -1573,17 +1573,17 @@ static SDL_GPUGraphicsPipeline *D3D11_CreateGraphicsPipeline( pipeline->inputLayout = D3D11_INTERNAL_FetchInputLayout( renderer, - pipelineCreateInfo->vertexInputState, + createinfo->vertex_input_state, vertShader->bytecode, vertShader->bytecodeSize); - if (pipelineCreateInfo->vertexInputState.vertexBindingCount > 0) { + if (createinfo->vertex_input_state.num_vertex_bindings > 0) { pipeline->vertexStrides = SDL_malloc( sizeof(Uint32) * - pipelineCreateInfo->vertexInputState.vertexBindingCount); + createinfo->vertex_input_state.num_vertex_bindings); - for (Uint32 i = 0; i < pipelineCreateInfo->vertexInputState.vertexBindingCount; i += 1) { - pipeline->vertexStrides[i] = pipelineCreateInfo->vertexInputState.vertexBindings[i].stride; + for (Uint32 i = 0; i < createinfo->vertex_input_state.num_vertex_bindings; i += 1) { + pipeline->vertexStrides[i] = createinfo->vertex_input_state.vertex_bindings[i].pitch; } } else { pipeline->vertexStrides = NULL; @@ -1591,15 +1591,15 @@ static SDL_GPUGraphicsPipeline *D3D11_CreateGraphicsPipeline( // Resource layout - pipeline->vertexSamplerCount = vertShader->samplerCount; - pipeline->vertexStorageTextureCount = vertShader->storageTextureCount; - pipeline->vertexStorageBufferCount = vertShader->storageBufferCount; - pipeline->vertexUniformBufferCount = vertShader->uniformBufferCount; + pipeline->vertexSamplerCount = vertShader->numSamplers; + pipeline->vertexStorageTextureCount = vertShader->numStorageTextures; + pipeline->vertexStorageBufferCount = vertShader->numStorageBuffers; + pipeline->vertexUniformBufferCount = vertShader->numUniformBuffers; - pipeline->fragmentSamplerCount = fragShader->samplerCount; - pipeline->fragmentStorageTextureCount = fragShader->storageTextureCount; - pipeline->fragmentStorageBufferCount = fragShader->storageBufferCount; - pipeline->fragmentUniformBufferCount = fragShader->uniformBufferCount; + pipeline->fragmentSamplerCount = fragShader->numSamplers; + pipeline->fragmentStorageTextureCount = fragShader->numStorageTextures; + pipeline->fragmentStorageBufferCount = fragShader->numStorageBuffers; + pipeline->fragmentUniformBufferCount = fragShader->numUniformBuffers; return (SDL_GPUGraphicsPipeline *)pipeline; } @@ -1694,10 +1694,10 @@ static bool D3D11_INTERNAL_StrToWStr( D3D11Renderer *renderer, const char *str, wchar_t *wstr, - size_t wstr_size) + size_t wstrSize) { size_t inlen, result; - size_t outlen = wstr_size; + size_t outlen = wstrSize; if (renderer->iconv == NULL) { renderer->iconv = SDL_iconv_open("WCHAR_T", "UTF-8"); @@ -1780,7 +1780,7 @@ static void D3D11_PopDebugGroup( static SDL_GPUSampler *D3D11_CreateSampler( SDL_GPURenderer *driverData, - const SDL_GPUSamplerCreateInfo *samplerCreateInfo) + const SDL_GPUSamplerCreateInfo *createinfo) { D3D11Renderer *renderer = (D3D11Renderer *)driverData; D3D11_SAMPLER_DESC samplerDesc; @@ -1788,15 +1788,15 @@ static SDL_GPUSampler *D3D11_CreateSampler( D3D11Sampler *d3d11Sampler; HRESULT res; - samplerDesc.AddressU = SDLToD3D11_SamplerAddressMode[samplerCreateInfo->addressModeU]; - samplerDesc.AddressV = SDLToD3D11_SamplerAddressMode[samplerCreateInfo->addressModeV]; - samplerDesc.AddressW = SDLToD3D11_SamplerAddressMode[samplerCreateInfo->addressModeW]; - samplerDesc.ComparisonFunc = (samplerCreateInfo->compareEnable ? SDLToD3D11_CompareOp[samplerCreateInfo->compareOp] : SDLToD3D11_CompareOp[SDL_GPU_COMPAREOP_ALWAYS]); - samplerDesc.MaxAnisotropy = (samplerCreateInfo->anisotropyEnable ? (UINT)samplerCreateInfo->maxAnisotropy : 0); - samplerDesc.Filter = SDLToD3D11_Filter(samplerCreateInfo); - samplerDesc.MaxLOD = samplerCreateInfo->maxLod; - samplerDesc.MinLOD = samplerCreateInfo->minLod; - samplerDesc.MipLODBias = samplerCreateInfo->mipLodBias; + samplerDesc.AddressU = SDLToD3D11_SamplerAddressMode[createinfo->address_mode_u]; + samplerDesc.AddressV = SDLToD3D11_SamplerAddressMode[createinfo->address_mode_v]; + samplerDesc.AddressW = SDLToD3D11_SamplerAddressMode[createinfo->address_mode_w]; + samplerDesc.ComparisonFunc = (createinfo->enable_compare ? SDLToD3D11_CompareOp[createinfo->compare_op] : SDLToD3D11_CompareOp[SDL_GPU_COMPAREOP_ALWAYS]); + samplerDesc.MaxAnisotropy = (createinfo->enable_anisotropy ? (UINT)createinfo->max_anisotropy : 0); + samplerDesc.Filter = SDLToD3D11_Filter(createinfo); + samplerDesc.MaxLOD = createinfo->max_lod; + samplerDesc.MinLOD = createinfo->min_lod; + samplerDesc.MipLODBias = createinfo->mip_lod_bias; SDL_zeroa(samplerDesc.BorderColor); // arbitrary, unused res = ID3D11Device_CreateSamplerState( @@ -1813,7 +1813,7 @@ static SDL_GPUSampler *D3D11_CreateSampler( SDL_GPUShader *D3D11_CreateShader( SDL_GPURenderer *driverData, - const SDL_GPUShaderCreateInfo *shaderCreateInfo) + const SDL_GPUShaderCreateInfo *createinfo) { D3D11Renderer *renderer = (D3D11Renderer *)driverData; ID3D11DeviceChild *handle; @@ -1823,23 +1823,23 @@ SDL_GPUShader *D3D11_CreateShader( handle = D3D11_INTERNAL_CreateID3D11Shader( renderer, - shaderCreateInfo->stage, - shaderCreateInfo->code, - shaderCreateInfo->codeSize, - shaderCreateInfo->entryPointName, - shaderCreateInfo->stage == SDL_GPU_SHADERSTAGE_VERTEX ? &bytecode : NULL, - shaderCreateInfo->stage == SDL_GPU_SHADERSTAGE_VERTEX ? &bytecodeSize : NULL); + createinfo->stage, + createinfo->code, + createinfo->code_size, + createinfo->entrypoint, + createinfo->stage == SDL_GPU_SHADERSTAGE_VERTEX ? &bytecode : NULL, + createinfo->stage == SDL_GPU_SHADERSTAGE_VERTEX ? &bytecodeSize : NULL); if (!handle) { return NULL; } shader = (D3D11Shader *)SDL_calloc(1, sizeof(D3D11Shader)); shader->handle = handle; - shader->samplerCount = shaderCreateInfo->samplerCount; - shader->storageBufferCount = shaderCreateInfo->storageBufferCount; - shader->storageTextureCount = shaderCreateInfo->storageTextureCount; - shader->uniformBufferCount = shaderCreateInfo->uniformBufferCount; - if (shaderCreateInfo->stage == SDL_GPU_SHADERSTAGE_VERTEX) { + shader->numSamplers = createinfo->num_samplers; + shader->numStorageBuffers = createinfo->num_storage_buffers; + shader->numStorageTextures = createinfo->num_storage_textures; + shader->numUniformBuffers = createinfo->num_uniform_buffers; + if (createinfo->stage == SDL_GPU_SHADERSTAGE_VERTEX) { // Store the raw bytecode and its length for creating InputLayouts shader->bytecode = bytecode; shader->bytecodeSize = bytecodeSize; @@ -1860,27 +1860,27 @@ static D3D11Texture *D3D11_INTERNAL_CreateTexture( D3D11Texture *d3d11Texture; HRESULT res; - isColorTarget = createInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; - isDepthStencil = createInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET; + isColorTarget = createInfo->usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; + isDepthStencil = createInfo->usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET; needsSRV = - (createInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_SAMPLER) || - (createInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ) || - (createInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ); + (createInfo->usage & SDL_GPU_TEXTUREUSAGE_SAMPLER) || + (createInfo->usage & SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ) || + (createInfo->usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ); needSubresourceUAV = - (createInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE); - isMultisample = createInfo->sampleCount > SDL_GPU_SAMPLECOUNT_1; - isStaging = createInfo->usageFlags == 0; + (createInfo->usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE); + isMultisample = createInfo->sample_count > SDL_GPU_SAMPLECOUNT_1; + isStaging = createInfo->usage == 0; isMippable = - createInfo->levelCount > 1 && - (createInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_SAMPLER) && - (createInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET); + createInfo->num_levels > 1 && + (createInfo->usage & SDL_GPU_TEXTUREUSAGE_SAMPLER) && + (createInfo->usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET); format = SDLToD3D11_TextureFormat[createInfo->format]; if (isDepthStencil) { format = D3D11_INTERNAL_GetTypelessFormat(format); } - Uint32 layerCount = createInfo->type == SDL_GPU_TEXTURETYPE_3D ? 1 : createInfo->layerCountOrDepth; - Uint32 depth = createInfo->type == SDL_GPU_TEXTURETYPE_3D ? createInfo->layerCountOrDepth : 1; + Uint32 layerCount = createInfo->type == SDL_GPU_TEXTURETYPE_3D ? 1 : createInfo->layer_count_or_depth; + Uint32 depth = createInfo->type == SDL_GPU_TEXTURETYPE_3D ? createInfo->layer_count_or_depth : 1; if (createInfo->type != SDL_GPU_TEXTURETYPE_3D) { D3D11_TEXTURE2D_DESC desc2D; @@ -1904,7 +1904,7 @@ static D3D11Texture *D3D11_INTERNAL_CreateTexture( desc2D.ArraySize = layerCount; desc2D.CPUAccessFlags = isStaging ? D3D11_CPU_ACCESS_WRITE : 0; desc2D.Format = format; - desc2D.MipLevels = createInfo->levelCount; + desc2D.MipLevels = createInfo->num_levels; desc2D.MiscFlags = 0; desc2D.SampleDesc.Count = 1; desc2D.SampleDesc.Quality = 0; @@ -1975,7 +1975,7 @@ static D3D11Texture *D3D11_INTERNAL_CreateTexture( desc3D.Depth = depth; desc3D.CPUAccessFlags = isStaging ? D3D11_CPU_ACCESS_WRITE : 0; desc3D.Format = format; - desc3D.MipLevels = createInfo->levelCount; + desc3D.MipLevels = createInfo->num_levels; desc3D.MiscFlags = isMippable ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0; desc3D.Usage = isStaging ? D3D11_USAGE_STAGING : D3D11_USAGE_DEFAULT; @@ -2014,16 +2014,16 @@ static D3D11Texture *D3D11_INTERNAL_CreateTexture( d3d11Texture->container = NULL; d3d11Texture->containerIndex = 0; - d3d11Texture->subresourceCount = createInfo->levelCount * layerCount; + d3d11Texture->subresourceCount = createInfo->num_levels * layerCount; d3d11Texture->subresources = SDL_malloc( d3d11Texture->subresourceCount * sizeof(D3D11TextureSubresource)); for (Uint32 layerIndex = 0; layerIndex < layerCount; layerIndex += 1) { - for (Uint32 levelIndex = 0; levelIndex < createInfo->levelCount; levelIndex += 1) { + for (Uint32 levelIndex = 0; levelIndex < createInfo->num_levels; levelIndex += 1) { Uint32 subresourceIndex = D3D11_INTERNAL_CalcSubresource( levelIndex, layerIndex, - createInfo->levelCount); + createInfo->num_levels); d3d11Texture->subresources[subresourceIndex].parent = d3d11Texture; d3d11Texture->subresources[subresourceIndex].layer = layerIndex; @@ -2053,7 +2053,7 @@ static D3D11Texture *D3D11_INTERNAL_CreateTexture( desc2D.Format = format; desc2D.MipLevels = 1; desc2D.MiscFlags = 0; - desc2D.SampleDesc.Count = SDLToD3D11_SampleCount[createInfo->sampleCount]; + desc2D.SampleDesc.Count = SDLToD3D11_SampleCount[createInfo->sample_count]; desc2D.SampleDesc.Quality = (UINT)D3D11_STANDARD_MULTISAMPLE_PATTERN; desc2D.Usage = D3D11_USAGE_DEFAULT; @@ -2181,7 +2181,7 @@ static bool D3D11_SupportsSampleCount( static SDL_GPUTexture *D3D11_CreateTexture( SDL_GPURenderer *driverData, - const SDL_GPUTextureCreateInfo *textureCreateInfo) + const SDL_GPUTextureCreateInfo *createinfo) { D3D11Renderer *renderer = (D3D11Renderer *)driverData; D3D11TextureContainer *container; @@ -2189,7 +2189,7 @@ static SDL_GPUTexture *D3D11_CreateTexture( texture = D3D11_INTERNAL_CreateTexture( renderer, - textureCreateInfo, + createinfo, NULL); if (texture == NULL) { @@ -2198,7 +2198,7 @@ static SDL_GPUTexture *D3D11_CreateTexture( } container = SDL_malloc(sizeof(D3D11TextureContainer)); - container->header.info = *textureCreateInfo; + container->header.info = *createinfo; container->canBeCycled = 1; container->activeTexture = texture; container->textureCapacity = 1; @@ -2266,7 +2266,7 @@ static D3D11TextureSubresource *D3D11_INTERNAL_FetchTextureSubresource( Uint32 index = D3D11_INTERNAL_CalcSubresource( level, layer, - container->header.info.levelCount); + container->header.info.num_levels); return &container->activeTexture->subresources[index]; } @@ -2302,7 +2302,7 @@ static D3D11TextureSubresource *D3D11_INTERNAL_PrepareTextureSubresourceForWrite static D3D11Buffer *D3D11_INTERNAL_CreateBuffer( D3D11Renderer *renderer, D3D11_BUFFER_DESC *bufferDesc, - Uint32 sizeInBytes) + Uint32 size) { ID3D11Buffer *bufferHandle; ID3D11UnorderedAccessView *uav = NULL; @@ -2311,7 +2311,7 @@ static D3D11Buffer *D3D11_INTERNAL_CreateBuffer( HRESULT res; // Storage buffers have to be 4-aligned, so might as well align them all - sizeInBytes = D3D11_INTERNAL_NextHighestAlignment(sizeInBytes, 4); + size = D3D11_INTERNAL_NextHighestAlignment(size, 4); res = ID3D11Device_CreateBuffer( renderer->device, @@ -2328,7 +2328,7 @@ static D3D11Buffer *D3D11_INTERNAL_CreateBuffer( uavDesc.Format = DXGI_FORMAT_R32_TYPELESS; uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; uavDesc.Buffer.FirstElement = 0; - uavDesc.Buffer.NumElements = sizeInBytes / sizeof(Uint32); + uavDesc.Buffer.NumElements = size / sizeof(Uint32); uavDesc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_RAW; res = ID3D11Device_CreateUnorderedAccessView( @@ -2347,7 +2347,7 @@ static D3D11Buffer *D3D11_INTERNAL_CreateBuffer( srvDesc.Format = DXGI_FORMAT_R32_TYPELESS; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX; srvDesc.BufferEx.FirstElement = 0; - srvDesc.BufferEx.NumElements = sizeInBytes / sizeof(Uint32); + srvDesc.BufferEx.NumElements = size / sizeof(Uint32); srvDesc.BufferEx.Flags = D3D11_BUFFEREX_SRV_FLAG_RAW; res = ID3D11Device_CreateShaderResourceView( @@ -2363,7 +2363,7 @@ static D3D11Buffer *D3D11_INTERNAL_CreateBuffer( d3d11Buffer = SDL_malloc(sizeof(D3D11Buffer)); d3d11Buffer->handle = bufferHandle; - d3d11Buffer->size = sizeInBytes; + d3d11Buffer->size = size; d3d11Buffer->uav = uav; d3d11Buffer->srv = srv; SDL_AtomicSet(&d3d11Buffer->referenceCount, 0); @@ -2374,7 +2374,7 @@ static D3D11Buffer *D3D11_INTERNAL_CreateBuffer( static SDL_GPUBuffer *D3D11_CreateBuffer( SDL_GPURenderer *driverData, SDL_GPUBufferUsageFlags usageFlags, - Uint32 sizeInBytes) + Uint32 size) { D3D11Renderer *renderer = (D3D11Renderer *)driverData; D3D11BufferContainer *container; @@ -2398,7 +2398,7 @@ static SDL_GPUBuffer *D3D11_CreateBuffer( bufferDesc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE; } - bufferDesc.ByteWidth = sizeInBytes; + bufferDesc.ByteWidth = size; bufferDesc.Usage = D3D11_USAGE_DEFAULT; bufferDesc.CPUAccessFlags = 0; bufferDesc.StructureByteStride = 0; @@ -2416,7 +2416,7 @@ static SDL_GPUBuffer *D3D11_CreateBuffer( buffer = D3D11_INTERNAL_CreateBuffer( renderer, &bufferDesc, - sizeInBytes); + size); if (buffer == NULL) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Failed to create buffer!"); @@ -2438,7 +2438,7 @@ static SDL_GPUBuffer *D3D11_CreateBuffer( static D3D11UniformBuffer *D3D11_INTERNAL_CreateUniformBuffer( D3D11Renderer *renderer, - Uint32 sizeInBytes) + Uint32 size) { D3D11UniformBuffer *uniformBuffer; ID3D11Buffer *buffer; @@ -2446,7 +2446,7 @@ static D3D11UniformBuffer *D3D11_INTERNAL_CreateUniformBuffer( HRESULT res; bufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bufferDesc.ByteWidth = sizeInBytes; + bufferDesc.ByteWidth = size; bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; bufferDesc.MiscFlags = 0; bufferDesc.StructureByteStride = 0; @@ -2522,12 +2522,12 @@ static D3D11Buffer *D3D11_INTERNAL_PrepareBufferForWrite( static D3D11TransferBuffer *D3D11_INTERNAL_CreateTransferBuffer( D3D11Renderer *renderer, - Uint32 sizeInBytes) + Uint32 size) { D3D11TransferBuffer *transferBuffer = SDL_malloc(sizeof(D3D11TransferBuffer)); - transferBuffer->data = (Uint8 *)SDL_malloc(sizeInBytes); - transferBuffer->size = sizeInBytes; + transferBuffer->data = (Uint8 *)SDL_malloc(size); + transferBuffer->size = size; SDL_AtomicSet(&transferBuffer->referenceCount, 0); transferBuffer->bufferDownloads = NULL; @@ -2545,7 +2545,7 @@ static D3D11TransferBuffer *D3D11_INTERNAL_CreateTransferBuffer( static SDL_GPUTransferBuffer *D3D11_CreateTransferBuffer( SDL_GPURenderer *driverData, SDL_GPUTransferBufferUsage usage, // ignored on D3D11 - Uint32 sizeInBytes) + Uint32 size) { D3D11Renderer *renderer = (D3D11Renderer *)driverData; D3D11TransferBufferContainer *container = (D3D11TransferBufferContainer *)SDL_malloc(sizeof(D3D11TransferBufferContainer)); @@ -2557,7 +2557,7 @@ static SDL_GPUTransferBuffer *D3D11_CreateTransferBuffer( container->buffers[0] = D3D11_INTERNAL_CreateTransferBuffer( renderer, - sizeInBytes); + size); container->activeBuffer = container->buffers[0]; @@ -2641,12 +2641,12 @@ static void D3D11_UploadToTexture( { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11Renderer *renderer = (D3D11Renderer *)d3d11CommandBuffer->renderer; - D3D11TransferBufferContainer *srcTransferContainer = (D3D11TransferBufferContainer *)source->transferBuffer; + D3D11TransferBufferContainer *srcTransferContainer = (D3D11TransferBufferContainer *)source->transfer_buffer; D3D11TransferBuffer *srcTransferBuffer = srcTransferContainer->activeBuffer; D3D11TextureContainer *dstTextureContainer = (D3D11TextureContainer *)destination->texture; SDL_GPUTextureFormat dstFormat = dstTextureContainer->header.info.format; - Uint32 bufferStride = source->imagePitch; - Uint32 bufferImageHeight = source->imageHeight; + Uint32 bufferStride = source->pixels_per_row; + Uint32 bufferImageHeight = source->rows_per_layer; Sint32 w = destination->w; Sint32 h = destination->h; D3D11Texture *stagingTexture; @@ -2657,7 +2657,7 @@ static void D3D11_UploadToTexture( renderer, dstTextureContainer, destination->layer, - destination->mipLevel, + destination->mip_level, cycle); Sint32 blockSize = Texture_GetBlockSize(dstFormat); @@ -2684,11 +2684,11 @@ static void D3D11_UploadToTexture( stagingTextureCreateInfo.width = w; stagingTextureCreateInfo.height = h; - stagingTextureCreateInfo.layerCountOrDepth = 1; - stagingTextureCreateInfo.levelCount = 1; + stagingTextureCreateInfo.layer_count_or_depth = 1; + stagingTextureCreateInfo.num_levels = 1; stagingTextureCreateInfo.type = SDL_GPU_TEXTURETYPE_2D; - stagingTextureCreateInfo.usageFlags = 0; - stagingTextureCreateInfo.sampleCount = SDL_GPU_SAMPLECOUNT_1; + stagingTextureCreateInfo.usage = 0; + stagingTextureCreateInfo.sample_count = SDL_GPU_SAMPLECOUNT_1; stagingTextureCreateInfo.format = dstFormat; initialData.pSysMem = srcTransferBuffer->data + source->offset; @@ -2731,7 +2731,7 @@ static void D3D11_UploadToBuffer( { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11Renderer *renderer = (D3D11Renderer *)d3d11CommandBuffer->renderer; - D3D11TransferBufferContainer *transferContainer = (D3D11TransferBufferContainer *)source->transferBuffer; + D3D11TransferBufferContainer *transferContainer = (D3D11TransferBufferContainer *)source->transfer_buffer; D3D11TransferBuffer *d3d11TransferBuffer = transferContainer->activeBuffer; D3D11BufferContainer *bufferContainer = (D3D11BufferContainer *)destination->buffer; D3D11Buffer *d3d11Buffer = D3D11_INTERNAL_PrepareBufferForWrite( @@ -2787,7 +2787,7 @@ static void D3D11_DownloadFromTexture( { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11Renderer *renderer = d3d11CommandBuffer->renderer; - D3D11TransferBufferContainer *dstTransferContainer = (D3D11TransferBufferContainer *)destination->transferBuffer; + D3D11TransferBufferContainer *dstTransferContainer = (D3D11TransferBufferContainer *)destination->transfer_buffer; D3D11TransferBuffer *d3d11TransferBuffer = dstTransferContainer->activeBuffer; D3D11TextureContainer *srcTextureContainer = (D3D11TextureContainer *)source->texture; SDL_GPUTextureFormat srcFormat = srcTextureContainer->header.info.format; @@ -2796,10 +2796,10 @@ static void D3D11_DownloadFromTexture( D3D11TextureSubresource *textureSubresource = D3D11_INTERNAL_FetchTextureSubresource( srcTextureContainer, source->layer, - source->mipLevel); + source->mip_level); D3D11TextureDownload *textureDownload; - Uint32 bufferStride = destination->imagePitch; - Uint32 bufferImageHeight = destination->imageHeight; + Uint32 bufferStride = destination->pixels_per_row; + Uint32 bufferImageHeight = destination->rows_per_layer; Uint32 bytesPerRow, bytesPerDepthSlice; D3D11_BOX srcBox = { source->x, source->y, source->z, source->x + source->w, source->y + source->h, source->z + source->d }; HRESULT res; @@ -2892,7 +2892,7 @@ static void D3D11_DownloadFromBuffer( { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11Renderer *renderer = d3d11CommandBuffer->renderer; - D3D11TransferBufferContainer *dstTransferContainer = (D3D11TransferBufferContainer *)destination->transferBuffer; + D3D11TransferBufferContainer *dstTransferContainer = (D3D11TransferBufferContainer *)destination->transfer_buffer; D3D11TransferBuffer *d3d11TransferBuffer = dstTransferContainer->activeBuffer; D3D11BufferContainer *srcBufferContainer = (D3D11BufferContainer *)source->buffer; D3D11BufferDownload *bufferDownload; @@ -2962,13 +2962,13 @@ static void D3D11_CopyTextureToTexture( D3D11TextureSubresource *srcSubresource = D3D11_INTERNAL_FetchTextureSubresource( srcContainer, source->layer, - source->mipLevel); + source->mip_level); D3D11TextureSubresource *dstSubresource = D3D11_INTERNAL_PrepareTextureSubresourceForWrite( renderer, dstContainer, destination->layer, - destination->mipLevel, + destination->mip_level, cycle); ID3D11DeviceContext1_CopySubresourceRegion( @@ -3287,7 +3287,7 @@ static void D3D11_INTERNAL_PushUniformData( SDL_GPUShaderStage shaderStage, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { D3D11Renderer *renderer = d3d11CommandBuffer->renderer; D3D11UniformBuffer *d3d11UniformBuffer; @@ -3319,7 +3319,7 @@ static void D3D11_INTERNAL_PushUniformData( d3d11UniformBuffer->currentBlockSize = D3D11_INTERNAL_NextHighestAlignment( - dataLengthInBytes, + length, 256); // If there is no more room, acquire a new uniform buffer @@ -3365,7 +3365,7 @@ static void D3D11_INTERNAL_PushUniformData( SDL_memcpy( (Uint8 *)d3d11UniformBuffer->mappedData + d3d11UniformBuffer->writeOffset, data, - dataLengthInBytes); + length); d3d11UniformBuffer->writeOffset += d3d11UniformBuffer->currentBlockSize; @@ -3390,8 +3390,8 @@ static void D3D11_SetViewport( viewport->y, viewport->w, viewport->h, - viewport->minDepth, - viewport->maxDepth + viewport->min_depth, + viewport->max_depth }; ID3D11DeviceContext_RSSetViewports( @@ -3430,9 +3430,9 @@ static void D3D11_SetBlendConstants( if (d3d11CommandBuffer->graphicsPipeline != NULL) { ID3D11DeviceContext_OMSetBlendState( d3d11CommandBuffer->context, - d3d11CommandBuffer->graphicsPipeline->colorAttachmentBlendState, + d3d11CommandBuffer->graphicsPipeline->colorTargetBlendState, blendFactor, - d3d11CommandBuffer->graphicsPipeline->multisampleState.sampleMask); + d3d11CommandBuffer->graphicsPipeline->multisampleState.sample_mask); } } @@ -3454,9 +3454,9 @@ static void D3D11_SetStencilReference( static void D3D11_BeginRenderPass( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo) + const SDL_GPUColorTargetInfo *colorTargetInfos, + Uint32 numColorTargets, + const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11Renderer *renderer = (D3D11Renderer *)d3d11CommandBuffer->renderer; @@ -3481,14 +3481,14 @@ static void D3D11_BeginRenderPass( } // Set up the new color target bindings - for (Uint32 i = 0; i < colorAttachmentCount; i += 1) { - D3D11TextureContainer *container = (D3D11TextureContainer *)colorAttachmentInfos[i].texture; + for (Uint32 i = 0; i < numColorTargets; i += 1) { + D3D11TextureContainer *container = (D3D11TextureContainer *)colorTargetInfos[i].texture; D3D11TextureSubresource *subresource = D3D11_INTERNAL_PrepareTextureSubresourceForWrite( renderer, container, - container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorAttachmentInfos[i].layerOrDepthPlane, - colorAttachmentInfos[i].mipLevel, - colorAttachmentInfos[i].cycle); + container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorTargetInfos[i].layer_or_depth_plane, + colorTargetInfos[i].mip_level, + colorTargetInfos[i].cycle); if (subresource->msaaHandle != NULL) { d3d11CommandBuffer->colorTargetResolveTexture[i] = subresource->parent; @@ -3498,16 +3498,16 @@ static void D3D11_BeginRenderPass( rtvs[i] = subresource->msaaTargetView; } else { - Uint32 rtvIndex = container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? colorAttachmentInfos[i].layerOrDepthPlane : 0; + Uint32 rtvIndex = container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? colorTargetInfos[i].layer_or_depth_plane : 0; rtvs[i] = subresource->colorTargetViews[rtvIndex]; } - if (colorAttachmentInfos[i].loadOp == SDL_GPU_LOADOP_CLEAR) { + if (colorTargetInfos[i].load_op == SDL_GPU_LOADOP_CLEAR) { float clearColor[] = { - colorAttachmentInfos[i].clearColor.r, - colorAttachmentInfos[i].clearColor.g, - colorAttachmentInfos[i].clearColor.b, - colorAttachmentInfos[i].clearColor.a + colorTargetInfos[i].clear_color.r, + colorTargetInfos[i].clear_color.g, + colorTargetInfos[i].clear_color.b, + colorTargetInfos[i].clear_color.a }; ID3D11DeviceContext_ClearRenderTargetView( d3d11CommandBuffer->context, @@ -3520,15 +3520,15 @@ static void D3D11_BeginRenderPass( subresource->parent); } - // Get the DSV for the depth stencil attachment, if applicable - if (depthStencilAttachmentInfo != NULL) { - D3D11TextureContainer *container = (D3D11TextureContainer *)depthStencilAttachmentInfo->texture; + // Get the DSV for the depth stencil target, if applicable + if (depthStencilTargetInfo != NULL) { + D3D11TextureContainer *container = (D3D11TextureContainer *)depthStencilTargetInfo->texture; D3D11TextureSubresource *subresource = D3D11_INTERNAL_PrepareTextureSubresourceForWrite( renderer, container, 0, 0, - depthStencilAttachmentInfo->cycle); + depthStencilTargetInfo->cycle); dsv = subresource->depthStencilTargetView; @@ -3540,16 +3540,16 @@ static void D3D11_BeginRenderPass( // Actually set the RTs ID3D11DeviceContext_OMSetRenderTargets( d3d11CommandBuffer->context, - colorAttachmentCount, - colorAttachmentCount > 0 ? rtvs : NULL, + numColorTargets, + numColorTargets > 0 ? rtvs : NULL, dsv); - if (depthStencilAttachmentInfo != NULL) { + if (depthStencilTargetInfo != NULL) { D3D11_CLEAR_FLAG dsClearFlags = 0; - if (depthStencilAttachmentInfo->loadOp == SDL_GPU_LOADOP_CLEAR) { + if (depthStencilTargetInfo->load_op == SDL_GPU_LOADOP_CLEAR) { dsClearFlags |= D3D11_CLEAR_DEPTH; } - if (depthStencilAttachmentInfo->stencilLoadOp == SDL_GPU_LOADOP_CLEAR) { + if (depthStencilTargetInfo->stencil_load_op == SDL_GPU_LOADOP_CLEAR) { dsClearFlags |= D3D11_CLEAR_STENCIL; } @@ -3558,16 +3558,16 @@ static void D3D11_BeginRenderPass( d3d11CommandBuffer->context, dsv, dsClearFlags, - depthStencilAttachmentInfo->depthStencilClearValue.depth, - depthStencilAttachmentInfo->depthStencilClearValue.stencil); + depthStencilTargetInfo->clear_value.depth, + depthStencilTargetInfo->clear_value.stencil); } } - // The viewport cannot be larger than the smallest attachment. - for (Uint32 i = 0; i < colorAttachmentCount; i += 1) { - D3D11TextureContainer *container = (D3D11TextureContainer *)colorAttachmentInfos[i].texture; - Uint32 w = container->header.info.width >> colorAttachmentInfos[i].mipLevel; - Uint32 h = container->header.info.height >> colorAttachmentInfos[i].mipLevel; + // The viewport cannot be larger than the smallest target. + for (Uint32 i = 0; i < numColorTargets; i += 1) { + D3D11TextureContainer *container = (D3D11TextureContainer *)colorTargetInfos[i].texture; + Uint32 w = container->header.info.width >> colorTargetInfos[i].mip_level; + Uint32 h = container->header.info.height >> colorTargetInfos[i].mip_level; if (w < vpWidth) { vpWidth = w; @@ -3578,8 +3578,8 @@ static void D3D11_BeginRenderPass( } } - if (depthStencilAttachmentInfo != NULL) { - D3D11TextureContainer *container = (D3D11TextureContainer *)depthStencilAttachmentInfo->texture; + if (depthStencilTargetInfo != NULL) { + D3D11TextureContainer *container = (D3D11TextureContainer *)depthStencilTargetInfo->texture; Uint32 w = container->header.info.width; Uint32 h = container->header.info.height; @@ -3597,8 +3597,8 @@ static void D3D11_BeginRenderPass( viewport.y = 0; viewport.w = (float)vpWidth; viewport.h = (float)vpHeight; - viewport.minDepth = 0; - viewport.maxDepth = 1; + viewport.min_depth = 0; + viewport.max_depth = 1; D3D11_SetViewport( commandBuffer, @@ -3639,9 +3639,9 @@ static void D3D11_BindGraphicsPipeline( ID3D11DeviceContext_OMSetBlendState( d3d11CommandBuffer->context, - pipeline->colorAttachmentBlendState, + pipeline->colorTargetBlendState, blendFactor, - pipeline->multisampleState.sampleMask); + pipeline->multisampleState.sample_mask); ID3D11DeviceContext_OMSetDepthStencilState( d3d11CommandBuffer->context, @@ -3695,31 +3695,31 @@ static void D3D11_BindGraphicsPipeline( static void D3D11_BindVertexBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstBinding, - const SDL_GPUBufferBinding *pBindings, - Uint32 bindingCount) + const SDL_GPUBufferBinding *bindings, + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { - D3D11Buffer *currentBuffer = ((D3D11BufferContainer *)pBindings[i].buffer)->activeBuffer; + for (Uint32 i = 0; i < numBindings; i += 1) { + D3D11Buffer *currentBuffer = ((D3D11BufferContainer *)bindings[i].buffer)->activeBuffer; d3d11CommandBuffer->vertexBuffers[firstBinding + i] = currentBuffer->handle; - d3d11CommandBuffer->vertexBufferOffsets[firstBinding + i] = pBindings[i].offset; + d3d11CommandBuffer->vertexBufferOffsets[firstBinding + i] = bindings[i].offset; D3D11_INTERNAL_TrackBuffer(d3d11CommandBuffer, currentBuffer); } d3d11CommandBuffer->vertexBufferCount = - SDL_max(d3d11CommandBuffer->vertexBufferCount, firstBinding + bindingCount); + SDL_max(d3d11CommandBuffer->vertexBufferCount, firstBinding + numBindings); d3d11CommandBuffer->needVertexBufferBind = true; } static void D3D11_BindIndexBuffer( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUBufferBinding *pBinding, + const SDL_GPUBufferBinding *binding, SDL_GPUIndexElementSize indexElementSize) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; - D3D11Buffer *d3d11Buffer = ((D3D11BufferContainer *)pBinding->buffer)->activeBuffer; + D3D11Buffer *d3d11Buffer = ((D3D11BufferContainer *)binding->buffer)->activeBuffer; D3D11_INTERNAL_TrackBuffer(d3d11CommandBuffer, d3d11Buffer); @@ -3727,18 +3727,18 @@ static void D3D11_BindIndexBuffer( d3d11CommandBuffer->context, d3d11Buffer->handle, SDLToD3D11_IndexType[indexElementSize], - (UINT)pBinding->offset); + (UINT)binding->offset); } static void D3D11_BindVertexSamplers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D11TextureContainer *textureContainer = (D3D11TextureContainer *)textureSamplerBindings[i].texture; D3D11_INTERNAL_TrackTexture( @@ -3760,11 +3760,11 @@ static void D3D11_BindVertexStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D11TextureContainer *textureContainer = (D3D11TextureContainer *)storageTextures[i]; D3D11_INTERNAL_TrackTexture( @@ -3782,13 +3782,13 @@ static void D3D11_BindVertexStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11BufferContainer *bufferContainer; Uint32 i; - for (i = 0; i < bindingCount; i += 1) { + for (i = 0; i < numBindings; i += 1) { bufferContainer = (D3D11BufferContainer *)storageBuffers[i]; D3D11_INTERNAL_TrackBuffer( @@ -3807,11 +3807,11 @@ static void D3D11_BindFragmentSamplers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D11TextureContainer *textureContainer = (D3D11TextureContainer *)textureSamplerBindings[i].texture; D3D11_INTERNAL_TrackTexture( @@ -3833,11 +3833,11 @@ static void D3D11_BindFragmentStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D11TextureContainer *textureContainer = (D3D11TextureContainer *)storageTextures[i]; D3D11_INTERNAL_TrackTexture( @@ -3855,13 +3855,13 @@ static void D3D11_BindFragmentStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11BufferContainer *bufferContainer; Uint32 i; - for (i = 0; i < bindingCount; i += 1) { + for (i = 0; i < numBindings; i += 1) { bufferContainer = (D3D11BufferContainer *)storageBuffers[i]; D3D11_INTERNAL_TrackBuffer( @@ -4007,8 +4007,8 @@ static void D3D11_INTERNAL_BindGraphicsResources( static void D3D11_DrawIndexedPrimitives( SDL_GPUCommandBuffer *commandBuffer, - Uint32 indexCount, - Uint32 instanceCount, + Uint32 numIndices, + Uint32 numInstances, Uint32 firstIndex, Sint32 vertexOffset, Uint32 firstInstance) @@ -4018,8 +4018,8 @@ static void D3D11_DrawIndexedPrimitives( ID3D11DeviceContext_DrawIndexedInstanced( d3d11CommandBuffer->context, - indexCount, - instanceCount, + numIndices, + numInstances, firstIndex, vertexOffset, firstInstance); @@ -4027,8 +4027,8 @@ static void D3D11_DrawIndexedPrimitives( static void D3D11_DrawPrimitives( SDL_GPUCommandBuffer *commandBuffer, - Uint32 vertexCount, - Uint32 instanceCount, + Uint32 numVertices, + Uint32 numInstances, Uint32 firstVertex, Uint32 firstInstance) { @@ -4037,8 +4037,8 @@ static void D3D11_DrawPrimitives( ID3D11DeviceContext_DrawInstanced( d3d11CommandBuffer->context, - vertexCount, - instanceCount, + numVertices, + numInstances, firstVertex, firstInstance); } @@ -4046,9 +4046,9 @@ static void D3D11_DrawPrimitives( static void D3D11_DrawPrimitivesIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride) + Uint32 pitch) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11_INTERNAL_BindGraphicsResources(d3d11CommandBuffer); @@ -4062,7 +4062,7 @@ static void D3D11_DrawPrimitivesIndirect( ID3D11DeviceContext_DrawInstancedIndirect( d3d11CommandBuffer->context, d3d11Buffer->handle, - offsetInBytes + (stride * i)); + offset + (pitch * i)); } D3D11_INTERNAL_TrackBuffer(d3d11CommandBuffer, d3d11Buffer); @@ -4071,9 +4071,9 @@ static void D3D11_DrawPrimitivesIndirect( static void D3D11_DrawIndexedPrimitivesIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride) + Uint32 pitch) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11_INTERNAL_BindGraphicsResources(d3d11CommandBuffer); @@ -4087,7 +4087,7 @@ static void D3D11_DrawIndexedPrimitivesIndirect( ID3D11DeviceContext_DrawIndexedInstancedIndirect( d3d11CommandBuffer->context, d3d11Buffer->handle, - offsetInBytes + (stride * i)); + offset + (pitch * i)); } D3D11_INTERNAL_TrackBuffer(d3d11CommandBuffer, d3d11Buffer); @@ -4136,28 +4136,28 @@ static void D3D11_PushVertexUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { D3D11_INTERNAL_PushUniformData( (D3D11CommandBuffer *)commandBuffer, SDL_GPU_SHADERSTAGE_VERTEX, slotIndex, data, - dataLengthInBytes); + length); } static void D3D11_PushFragmentUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { D3D11_INTERNAL_PushUniformData( (D3D11CommandBuffer *)commandBuffer, SDL_GPU_SHADERSTAGE_FRAGMENT, slotIndex, data, - dataLengthInBytes); + length); } // Blit @@ -4167,7 +4167,7 @@ static void D3D11_Blit( const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_GPUFilter filter, bool cycle) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; @@ -4179,7 +4179,7 @@ static void D3D11_Blit( source, destination, flipMode, - filterMode, + filter, cycle, renderer->blitLinearSampler, renderer->blitNearestSampler, @@ -4198,9 +4198,9 @@ static void D3D11_Blit( static void D3D11_BeginComputePass( SDL_GPUCommandBuffer *commandBuffer, const SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings, - Uint32 storageTextureBindingCount, + Uint32 numStorageTextureBindings, const SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings, - Uint32 storageBufferBindingCount) + Uint32 numStorageBufferBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11TextureContainer *textureContainer; @@ -4209,9 +4209,9 @@ static void D3D11_BeginComputePass( D3D11Buffer *buffer; Uint32 i; - for (i = 0; i < storageTextureBindingCount; i += 1) { + for (i = 0; i < numStorageTextureBindings; i += 1) { textureContainer = (D3D11TextureContainer *)storageTextureBindings[i].texture; - if (!(textureContainer->header.info.usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE)) { + if (!(textureContainer->header.info.usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE)) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Attempted to bind read-only texture as compute write texture"); } @@ -4219,7 +4219,7 @@ static void D3D11_BeginComputePass( d3d11CommandBuffer->renderer, textureContainer, storageTextureBindings[i].layer, - storageTextureBindings[i].mipLevel, + storageTextureBindings[i].mip_level, storageTextureBindings[i].cycle); D3D11_INTERNAL_TrackTexture( @@ -4229,7 +4229,7 @@ static void D3D11_BeginComputePass( d3d11CommandBuffer->computeUnorderedAccessViews[i] = textureSubresource->uav; } - for (i = 0; i < storageBufferBindingCount; i += 1) { + for (i = 0; i < numStorageBufferBindings; i += 1) { bufferContainer = (D3D11BufferContainer *)storageBufferBindings[i].buffer; buffer = D3D11_INTERNAL_PrepareBufferForWrite( @@ -4241,7 +4241,7 @@ static void D3D11_BeginComputePass( d3d11CommandBuffer, buffer); - d3d11CommandBuffer->computeUnorderedAccessViews[i + storageTextureBindingCount] = buffer->uav; + d3d11CommandBuffer->computeUnorderedAccessViews[i + numStorageTextureBindings] = buffer->uav; } d3d11CommandBuffer->needComputeUAVBind = true; @@ -4263,7 +4263,7 @@ static void D3D11_BindComputePipeline( 0); // Acquire uniform buffers if necessary - for (Uint32 i = 0; i < pipeline->uniformBufferCount; i += 1) { + for (Uint32 i = 0; i < pipeline->numUniformBuffers; i += 1) { if (d3d11CommandBuffer->computeUniformBuffers[i] == NULL) { d3d11CommandBuffer->computeUniformBuffers[i] = D3D11_INTERNAL_AcquireUniformBufferFromPool( d3d11CommandBuffer); @@ -4277,11 +4277,11 @@ static void D3D11_BindComputeStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D11TextureContainer *textureContainer = (D3D11TextureContainer *)storageTextures[i]; D3D11_INTERNAL_TrackTexture( @@ -4299,13 +4299,13 @@ static void D3D11_BindComputeStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11BufferContainer *bufferContainer; Uint32 i; - for (i = 0; i < bindingCount; i += 1) { + for (i = 0; i < numBindings; i += 1) { bufferContainer = (D3D11BufferContainer *)storageBuffers[i]; D3D11_INTERNAL_TrackBuffer( @@ -4313,7 +4313,7 @@ static void D3D11_BindComputeStorageBuffers( bufferContainer->activeBuffer); d3d11CommandBuffer->computeShaderResourceViews[firstSlot + i + - d3d11CommandBuffer->computePipeline->readOnlyStorageTextureCount] = bufferContainer->activeBuffer->srv; + d3d11CommandBuffer->computePipeline->numReadonlyStorageTextures] = bufferContainer->activeBuffer->srv; } d3d11CommandBuffer->needComputeSRVBind = true; @@ -4323,14 +4323,14 @@ static void D3D11_PushComputeUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { D3D11_INTERNAL_PushUniformData( (D3D11CommandBuffer *)commandBuffer, SDL_GPU_SHADERSTAGE_COMPUTE, slotIndex, data, - dataLengthInBytes); + length); } static void D3D11_INTERNAL_BindComputeResources( @@ -4339,12 +4339,12 @@ static void D3D11_INTERNAL_BindComputeResources( D3D11ComputePipeline *computePipeline = commandBuffer->computePipeline; Uint32 readOnlyResourceCount = - computePipeline->readOnlyStorageTextureCount + - computePipeline->readOnlyStorageBufferCount; + computePipeline->numReadonlyStorageTextures + + computePipeline->numReadonlyStorageBuffers; Uint32 writeOnlyResourceCount = - computePipeline->writeOnlyStorageTextureCount + - computePipeline->writeOnlyStorageBufferCount; + computePipeline->numWriteonlyStorageTextures + + computePipeline->numWriteonlyStorageBuffers; ID3D11Buffer *nullBuf = NULL; Uint32 offsetInConstants, blockSizeInConstants, i; @@ -4371,7 +4371,7 @@ static void D3D11_INTERNAL_BindComputeResources( } if (commandBuffer->needComputeUniformBufferBind) { - for (i = 0; i < computePipeline->uniformBufferCount; i += 1) { + for (i = 0; i < computePipeline->numUniformBuffers; i += 1) { /* stupid workaround for god awful D3D11 drivers * see: https://learn.microsoft.com/en-us/windows/win32/api/d3d11_1/nf-d3d11_1-id3d11devicecontext1-vssetconstantbuffers1#calling-vssetconstantbuffers1-with-command-list-emulation */ @@ -4398,24 +4398,24 @@ static void D3D11_INTERNAL_BindComputeResources( static void D3D11_DispatchCompute( SDL_GPUCommandBuffer *commandBuffer, - Uint32 groupCountX, - Uint32 groupCountY, - Uint32 groupCountZ) + Uint32 groupcountX, + Uint32 groupcountY, + Uint32 groupcountZ) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11_INTERNAL_BindComputeResources(d3d11CommandBuffer); ID3D11DeviceContext_Dispatch( d3d11CommandBuffer->context, - groupCountX, - groupCountY, - groupCountZ); + groupcountX, + groupcountY, + groupcountZ); } static void D3D11_DispatchComputeIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes) + Uint32 offset) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11Buffer *d3d11Buffer = ((D3D11BufferContainer *)buffer)->activeBuffer; @@ -4425,7 +4425,7 @@ static void D3D11_DispatchComputeIndirect( ID3D11DeviceContext_DispatchIndirect( d3d11CommandBuffer->context, d3d11Buffer->handle, - offsetInBytes); + offset); D3D11_INTERNAL_TrackBuffer(d3d11CommandBuffer, d3d11Buffer); } @@ -4736,8 +4736,8 @@ static void D3D11_INTERNAL_WaitForFence( static void D3D11_WaitForFences( SDL_GPURenderer *driverData, bool waitAll, - SDL_GPUFence *const *pFences, - Uint32 fenceCount) + SDL_GPUFence *const *fences, + Uint32 numFences) { D3D11Renderer *renderer = (D3D11Renderer *)driverData; D3D11Fence *fence; @@ -4745,16 +4745,16 @@ static void D3D11_WaitForFences( HRESULT res = S_FALSE; if (waitAll) { - for (Uint32 i = 0; i < fenceCount; i += 1) { - fence = (D3D11Fence *)pFences[i]; + for (Uint32 i = 0; i < numFences; i += 1) { + fence = (D3D11Fence *)fences[i]; D3D11_INTERNAL_WaitForFence(renderer, fence); } } else { SDL_LockMutex(renderer->contextLock); while (res != S_OK) { - for (Uint32 i = 0; i < fenceCount; i += 1) { - fence = (D3D11Fence *)pFences[i]; + for (Uint32 i = 0; i < numFences; i += 1) { + fence = (D3D11Fence *)fences[i]; res = ID3D11DeviceContext_GetData( renderer->immediateContext, (ID3D11Asynchronous *)fence->handle, @@ -5032,12 +5032,12 @@ static bool D3D11_INTERNAL_CreateSwapchain( windowData->textureContainer.textureCount = 1; windowData->textureContainer.textureCapacity = 1; - windowData->textureContainer.header.info.layerCountOrDepth = 1; + windowData->textureContainer.header.info.layer_count_or_depth = 1; windowData->textureContainer.header.info.format = SwapchainCompositionToSDLTextureFormat[windowData->swapchainComposition]; windowData->textureContainer.header.info.type = SDL_GPU_TEXTURETYPE_2D; - windowData->textureContainer.header.info.levelCount = 1; - windowData->textureContainer.header.info.sampleCount = SDL_GPU_SAMPLECOUNT_1; - windowData->textureContainer.header.info.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; + windowData->textureContainer.header.info.num_levels = 1; + windowData->textureContainer.header.info.sample_count = SDL_GPU_SAMPLECOUNT_1; + windowData->textureContainer.header.info.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; windowData->texture.container = &windowData->textureContainer; windowData->texture.containerIndex = 0; @@ -5254,14 +5254,14 @@ static void D3D11_ReleaseWindow( static SDL_GPUTexture *D3D11_AcquireSwapchainTexture( SDL_GPUCommandBuffer *commandBuffer, SDL_Window *window, - Uint32 *pWidth, - Uint32 *pHeight) + Uint32 *w, + Uint32 *h) { D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer; D3D11Renderer *renderer = (D3D11Renderer *)d3d11CommandBuffer->renderer; D3D11WindowData *windowData; DXGI_SWAP_CHAIN_DESC swapchainDesc; - int w, h; + int windowW, windowH; HRESULT res; windowData = D3D11_INTERNAL_FetchWindowData(window); @@ -5271,14 +5271,15 @@ static SDL_GPUTexture *D3D11_AcquireSwapchainTexture( // Check for window size changes and resize the swapchain if needed. IDXGISwapChain_GetDesc(windowData->swapchain, &swapchainDesc); - SDL_GetWindowSize(window, &w, &h); + SDL_GetWindowSize(window, &windowW, &windowH); + SDL_Log("%d x %d", windowW, windowH); - if ((UINT)w != swapchainDesc.BufferDesc.Width || (UINT)h != swapchainDesc.BufferDesc.Height) { + if ((UINT)windowW != swapchainDesc.BufferDesc.Width || (UINT)windowH != swapchainDesc.BufferDesc.Height) { res = D3D11_INTERNAL_ResizeSwapchain( renderer, windowData, - w, - h); + windowW, + windowH); ERROR_CHECK_RETURN("Could not resize swapchain", NULL); } @@ -5318,12 +5319,12 @@ static SDL_GPUTexture *D3D11_AcquireSwapchainTexture( ERROR_CHECK_RETURN("Could not acquire swapchain!", NULL); // Send the dimensions to the out parameters. - *pWidth = w; - *pHeight = h; + *w = windowW; + *h = windowH; // Update the texture container dimensions - windowData->textureContainer.header.info.width = w; - windowData->textureContainer.header.info.height = h; + windowData->textureContainer.header.info.width = windowW; + windowData->textureContainer.header.info.height = windowH; // Set up presentation if (d3d11CommandBuffer->windowDataCount == d3d11CommandBuffer->windowDataCapacity) { @@ -5629,12 +5630,12 @@ static bool D3D11_SupportsTextureFormat( // Device Creation -static bool D3D11_PrepareDriver(SDL_VideoDevice *_this) +static bool D3D11_PrepareDriver(SDL_VideoDevice *this) { void *d3d11_dll, *dxgi_dll; PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc; D3D_FEATURE_LEVEL levels[] = { D3D_FEATURE_LEVEL_11_1 }; - PFN_CREATE_DXGI_FACTORY1 CreateDXGIFactoryFunc; + PFN_CREATE_DXGI_FACTORY1 CreateDxgiFactoryFunc; HRESULT res; // Can we load D3D11? @@ -5683,11 +5684,11 @@ static bool D3D11_PrepareDriver(SDL_VideoDevice *_this) return false; } - CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY1)SDL_LoadFunction( + CreateDxgiFactoryFunc = (PFN_CREATE_DXGI_FACTORY1)SDL_LoadFunction( dxgi_dll, CREATE_DXGI_FACTORY1_FUNC); SDL_UnloadObject(dxgi_dll); // We're not going to call this function, so we can just unload now. - if (CreateDXGIFactoryFunc == NULL) { + if (CreateDxgiFactoryFunc == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_GPU, "D3D11: Could not find function " CREATE_DXGI_FACTORY1_FUNC " in " DXGI_DLL); return false; } @@ -5739,15 +5740,15 @@ static void D3D11_INTERNAL_InitBlitPipelines( SDL_GPUGraphicsPipelineCreateInfo blitPipelineCreateInfo; SDL_GPUGraphicsPipeline *blitPipeline; SDL_GPUSamplerCreateInfo samplerCreateInfo; - SDL_GPUColorAttachmentDescription colorAttachmentDesc; + SDL_GPUColorTargetDescription colorTargetDesc; // Fullscreen vertex shader SDL_zero(shaderCreateInfo); shaderCreateInfo.code = (Uint8 *)D3D11_FullscreenVert; - shaderCreateInfo.codeSize = sizeof(D3D11_FullscreenVert); + shaderCreateInfo.code_size = sizeof(D3D11_FullscreenVert); shaderCreateInfo.stage = SDL_GPU_SHADERSTAGE_VERTEX; shaderCreateInfo.format = SDL_GPU_SHADERFORMAT_DXBC; - shaderCreateInfo.entryPointName = "main"; + shaderCreateInfo.entrypoint = "main"; fullscreenVertexShader = D3D11_CreateShader( (SDL_GPURenderer *)renderer, @@ -5759,10 +5760,10 @@ static void D3D11_INTERNAL_InitBlitPipelines( // BlitFrom2D pixel shader shaderCreateInfo.code = (Uint8 *)D3D11_BlitFrom2D; - shaderCreateInfo.codeSize = sizeof(D3D11_BlitFrom2D); + shaderCreateInfo.code_size = sizeof(D3D11_BlitFrom2D); shaderCreateInfo.stage = SDL_GPU_SHADERSTAGE_FRAGMENT; - shaderCreateInfo.samplerCount = 1; - shaderCreateInfo.uniformBufferCount = 1; + shaderCreateInfo.num_samplers = 1; + shaderCreateInfo.num_uniform_buffers = 1; blitFrom2DPixelShader = D3D11_CreateShader( (SDL_GPURenderer *)renderer, @@ -5774,7 +5775,7 @@ static void D3D11_INTERNAL_InitBlitPipelines( // BlitFrom2DArray pixel shader shaderCreateInfo.code = (Uint8 *)D3D11_BlitFrom2DArray; - shaderCreateInfo.codeSize = sizeof(D3D11_BlitFrom2DArray); + shaderCreateInfo.code_size = sizeof(D3D11_BlitFrom2DArray); blitFrom2DArrayPixelShader = D3D11_CreateShader( (SDL_GPURenderer *)renderer, @@ -5786,7 +5787,7 @@ static void D3D11_INTERNAL_InitBlitPipelines( // BlitFrom3D pixel shader shaderCreateInfo.code = (Uint8 *)D3D11_BlitFrom3D; - shaderCreateInfo.codeSize = sizeof(D3D11_BlitFrom3D); + shaderCreateInfo.code_size = sizeof(D3D11_BlitFrom3D); blitFrom3DPixelShader = D3D11_CreateShader( (SDL_GPURenderer *)renderer, @@ -5798,7 +5799,7 @@ static void D3D11_INTERNAL_InitBlitPipelines( // BlitFromCube pixel shader shaderCreateInfo.code = (Uint8 *)D3D11_BlitFromCube; - shaderCreateInfo.codeSize = sizeof(D3D11_BlitFromCube); + shaderCreateInfo.code_size = sizeof(D3D11_BlitFromCube); blitFromCubePixelShader = D3D11_CreateShader( (SDL_GPURenderer *)renderer, @@ -5811,22 +5812,22 @@ static void D3D11_INTERNAL_InitBlitPipelines( // BlitFrom2D pipeline SDL_zero(blitPipelineCreateInfo); - SDL_zero(colorAttachmentDesc); - colorAttachmentDesc.blendState.colorWriteMask = 0xF; - colorAttachmentDesc.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; // format doesn't matter in d3d11 + SDL_zero(colorTargetDesc); + colorTargetDesc.blend_state.color_write_mask = 0xF; + colorTargetDesc.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; // format doesn't matter in d3d11 - blitPipelineCreateInfo.attachmentInfo.colorAttachmentDescriptions = &colorAttachmentDesc; - blitPipelineCreateInfo.attachmentInfo.colorAttachmentCount = 1; - blitPipelineCreateInfo.attachmentInfo.depthStencilFormat = SDL_GPU_TEXTUREFORMAT_D16_UNORM; // arbitrary - blitPipelineCreateInfo.attachmentInfo.hasDepthStencilAttachment = false; + blitPipelineCreateInfo.target_info.color_target_descriptions = &colorTargetDesc; + blitPipelineCreateInfo.target_info.num_color_targets = 1; + blitPipelineCreateInfo.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D16_UNORM; // arbitrary + blitPipelineCreateInfo.target_info.has_depth_stencil_target = false; - blitPipelineCreateInfo.vertexShader = fullscreenVertexShader; - blitPipelineCreateInfo.fragmentShader = blitFrom2DPixelShader; + blitPipelineCreateInfo.vertex_shader = fullscreenVertexShader; + blitPipelineCreateInfo.fragment_shader = blitFrom2DPixelShader; - blitPipelineCreateInfo.multisampleState.sampleCount = SDL_GPU_SAMPLECOUNT_1; - blitPipelineCreateInfo.multisampleState.sampleMask = 0xFFFFFFFF; + blitPipelineCreateInfo.multisample_state.sample_count = SDL_GPU_SAMPLECOUNT_1; + blitPipelineCreateInfo.multisample_state.sample_mask = 0xFFFFFFFF; - blitPipelineCreateInfo.primitiveType = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; + blitPipelineCreateInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; blitPipeline = D3D11_CreateGraphicsPipeline( (SDL_GPURenderer *)renderer, @@ -5841,7 +5842,7 @@ static void D3D11_INTERNAL_InitBlitPipelines( renderer->blitPipelines[SDL_GPU_TEXTURETYPE_2D].format = SDL_GPU_TEXTUREFORMAT_INVALID; // BlitFrom2DArrayPipeline - blitPipelineCreateInfo.fragmentShader = blitFrom2DArrayPixelShader; + blitPipelineCreateInfo.fragment_shader = blitFrom2DArrayPixelShader; blitPipeline = D3D11_CreateGraphicsPipeline( (SDL_GPURenderer *)renderer, &blitPipelineCreateInfo); @@ -5855,7 +5856,7 @@ static void D3D11_INTERNAL_InitBlitPipelines( renderer->blitPipelines[SDL_GPU_TEXTURETYPE_2D_ARRAY].format = SDL_GPU_TEXTUREFORMAT_INVALID; // BlitFrom3DPipeline - blitPipelineCreateInfo.fragmentShader = blitFrom3DPixelShader; + blitPipelineCreateInfo.fragment_shader = blitFrom3DPixelShader; blitPipeline = D3D11_CreateGraphicsPipeline( (SDL_GPURenderer *)renderer, &blitPipelineCreateInfo); @@ -5869,7 +5870,7 @@ static void D3D11_INTERNAL_InitBlitPipelines( renderer->blitPipelines[SDL_GPU_TEXTURETYPE_3D].format = SDL_GPU_TEXTUREFORMAT_INVALID; // BlitFromCubePipeline - blitPipelineCreateInfo.fragmentShader = blitFromCubePixelShader; + blitPipelineCreateInfo.fragment_shader = blitFromCubePixelShader; blitPipeline = D3D11_CreateGraphicsPipeline( (SDL_GPURenderer *)renderer, &blitPipelineCreateInfo); @@ -5883,17 +5884,17 @@ static void D3D11_INTERNAL_InitBlitPipelines( renderer->blitPipelines[SDL_GPU_TEXTURETYPE_CUBE].format = SDL_GPU_TEXTUREFORMAT_INVALID; // Create samplers - samplerCreateInfo.addressModeU = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.addressModeV = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.addressModeW = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.anisotropyEnable = 0; - samplerCreateInfo.compareEnable = 0; - samplerCreateInfo.magFilter = SDL_GPU_FILTER_NEAREST; - samplerCreateInfo.minFilter = SDL_GPU_FILTER_NEAREST; - samplerCreateInfo.mipmapMode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST; - samplerCreateInfo.mipLodBias = 0.0f; - samplerCreateInfo.minLod = 0; - samplerCreateInfo.maxLod = 1000; + samplerCreateInfo.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + samplerCreateInfo.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + samplerCreateInfo.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + samplerCreateInfo.enable_anisotropy = 0; + samplerCreateInfo.enable_compare = 0; + samplerCreateInfo.mag_filter = SDL_GPU_FILTER_NEAREST; + samplerCreateInfo.min_filter = SDL_GPU_FILTER_NEAREST; + samplerCreateInfo.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST; + samplerCreateInfo.mip_lod_bias = 0.0f; + samplerCreateInfo.min_lod = 0; + samplerCreateInfo.max_lod = 1000; renderer->blitNearestSampler = D3D11_CreateSampler( (SDL_GPURenderer *)renderer, @@ -5903,9 +5904,9 @@ static void D3D11_INTERNAL_InitBlitPipelines( SDL_LogError(SDL_LOG_CATEGORY_GPU, "Failed to create blit nearest sampler!"); } - samplerCreateInfo.magFilter = SDL_GPU_FILTER_LINEAR; - samplerCreateInfo.minFilter = SDL_GPU_FILTER_LINEAR; - samplerCreateInfo.mipmapMode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR; + samplerCreateInfo.mag_filter = SDL_GPU_FILTER_LINEAR; + samplerCreateInfo.min_filter = SDL_GPU_FILTER_LINEAR; + samplerCreateInfo.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR; renderer->blitLinearSampler = D3D11_CreateSampler( (SDL_GPURenderer *)renderer, @@ -5937,7 +5938,7 @@ static void D3D11_INTERNAL_DestroyBlitPipelines( static SDL_GPUDevice *D3D11_CreateDevice(bool debugMode, bool preferLowPower, SDL_PropertiesID props) { D3D11Renderer *renderer; - PFN_CREATE_DXGI_FACTORY1 CreateDXGIFactoryFunc; + PFN_CREATE_DXGI_FACTORY1 CreateDxgiFactoryFunc; PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc; D3D_FEATURE_LEVEL levels[] = { D3D_FEATURE_LEVEL_11_1 }; IDXGIFactory4 *factory4; @@ -5959,16 +5960,16 @@ static SDL_GPUDevice *D3D11_CreateDevice(bool debugMode, bool preferLowPower, SD } // Load the CreateDXGIFactory1 function - CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY1)SDL_LoadFunction( + CreateDxgiFactoryFunc = (PFN_CREATE_DXGI_FACTORY1)SDL_LoadFunction( renderer->dxgi_dll, CREATE_DXGI_FACTORY1_FUNC); - if (CreateDXGIFactoryFunc == NULL) { + if (CreateDxgiFactoryFunc == NULL) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Could not load function: " CREATE_DXGI_FACTORY1_FUNC); return NULL; } // Create the DXGI factory - res = CreateDXGIFactoryFunc( + res = CreateDxgiFactoryFunc( &D3D_IID_IDXGIFactory1, (void **)&renderer->factory); ERROR_CHECK_RETURN("Could not create DXGIFactory", NULL); diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c index d7d173f478..90bb64629c 100644 --- a/src/gpu/d3d12/SDL_gpu_d3d12.c +++ b/src/gpu/d3d12/SDL_gpu_d3d12.c @@ -493,7 +493,7 @@ struct D3D12Texture Uint32 containerIndex; D3D12TextureSubresource *subresources; - Uint32 subresourceCount; /* layerCount * levelCount */ + Uint32 subresourceCount; /* layerCount * num_levels */ ID3D12Resource *resource; D3D12CPUDescriptor srvHandle; @@ -517,7 +517,7 @@ typedef struct D3D12WindowData #else IDXGISwapChain3 *swapchain; #endif - SDL_GPUPresentMode presentMode; + SDL_GPUPresentMode present_mode; SDL_GPUSwapchainComposition swapchainComposition; DXGI_COLOR_SPACE_TYPE swapchainColorSpace; Uint32 frameCounter; @@ -557,7 +557,7 @@ struct D3D12Renderer ID3D12CommandQueue *commandQueue; - bool debugMode; + bool debug_mode; bool GPUUploadHeapSupported; // FIXME: these might not be necessary since we're not using custom heaps bool UMA; @@ -657,8 +657,8 @@ struct D3D12CommandBuffer Uint32 presentDataCount; Uint32 presentDataCapacity; - Uint32 colorAttachmentTextureSubresourceCount; - D3D12TextureSubresource *colorAttachmentTextureSubresources[MAX_COLOR_TARGET_BINDINGS]; + Uint32 colorTargetTextureSubresourceCount; + D3D12TextureSubresource *colorTargetTextureSubresources[MAX_COLOR_TARGET_BINDINGS]; D3D12TextureSubresource *depthStencilTextureSubresource; D3D12GraphicsPipeline *currentGraphicsPipeline; D3D12ComputePipeline *currentComputePipeline; @@ -742,10 +742,10 @@ struct D3D12Shader void *bytecode; size_t bytecodeSize; - Uint32 samplerCount; - Uint32 uniformBufferCount; - Uint32 storageBufferCount; - Uint32 storageTextureCount; + Uint32 num_samplers; + Uint32 numUniformBuffers; + Uint32 numStorageBuffers; + Uint32 numStorageTextures; }; typedef struct D3D12GraphicsRootSignature @@ -804,11 +804,11 @@ struct D3D12ComputePipeline ID3D12PipelineState *pipelineState; D3D12ComputeRootSignature *rootSignature; - Uint32 readOnlyStorageTextureCount; - Uint32 readOnlyStorageBufferCount; - Uint32 writeOnlyStorageTextureCount; - Uint32 writeOnlyStorageBufferCount; - Uint32 uniformBufferCount; + Uint32 num_readonly_storage_textures; + Uint32 num_readonly_storage_buffers; + Uint32 num_writeonly_storage_textures; + Uint32 num_writeonly_storage_buffers; + Uint32 numUniformBuffers; SDL_AtomicInt referenceCount; }; @@ -843,7 +843,7 @@ struct D3D12Buffer struct D3D12BufferContainer { - SDL_GPUBufferUsageFlags usageFlags; + SDL_GPUBufferUsageFlags usage; Uint32 size; D3D12BufferType type; @@ -870,7 +870,7 @@ struct D3D12UniformBuffer static void D3D12_ReleaseWindow(SDL_GPURenderer *driverData, SDL_Window *window); static void D3D12_Wait(SDL_GPURenderer *driverData); -static void D3D12_WaitForFences(SDL_GPURenderer *driverData, bool waitAll, SDL_GPUFence *const *pFences, Uint32 fenceCount); +static void D3D12_WaitForFences(SDL_GPURenderer *driverData, bool waitAll, SDL_GPUFence *const *fences, Uint32 numFences); static void D3D12_INTERNAL_ReleaseBlitPipelines(SDL_GPURenderer *driverData); // Helpers @@ -954,7 +954,7 @@ static void D3D12_INTERNAL_SetResourceName( ID3D12Resource *resource, const char *text) { - if (renderer->debugMode) { + if (renderer->debug_mode) { ID3D12DeviceChild_SetPrivateData( resource, D3D_GUID(D3D_IID_D3DDebugObjectName), @@ -1489,7 +1489,7 @@ static void D3D12_INTERNAL_TextureSubresourceBarrier( destinationState, textureSubresource->parent->resource, textureSubresource->index, - textureSubresource->parent->container->header.info.usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE); + textureSubresource->parent->container->header.info.usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE); } static D3D12_RESOURCE_STATES D3D12_INTERNAL_DefaultTextureResourceState( @@ -1522,7 +1522,7 @@ static void D3D12_INTERNAL_TextureSubresourceTransitionFromDefaultUsage( { D3D12_INTERNAL_TextureSubresourceBarrier( commandBuffer, - D3D12_INTERNAL_DefaultTextureResourceState(textureSubresource->parent->container->header.info.usageFlags), + D3D12_INTERNAL_DefaultTextureResourceState(textureSubresource->parent->container->header.info.usage), destinationUsageMode, textureSubresource); } @@ -1548,7 +1548,7 @@ static void D3D12_INTERNAL_TextureSubresourceTransitionToDefaultUsage( D3D12_INTERNAL_TextureSubresourceBarrier( commandBuffer, sourceUsageMode, - D3D12_INTERNAL_DefaultTextureResourceState(textureSubresource->parent->container->header.info.usageFlags), + D3D12_INTERNAL_DefaultTextureResourceState(textureSubresource->parent->container->header.info.usage), textureSubresource); } @@ -1568,17 +1568,17 @@ static void D3D12_INTERNAL_TextureTransitionToDefaultUsage( static D3D12_RESOURCE_STATES D3D12_INTERNAL_DefaultBufferResourceState( D3D12Buffer *buffer) { - if (buffer->container->usageFlags & SDL_GPU_BUFFERUSAGE_VERTEX) { + if (buffer->container->usage & SDL_GPU_BUFFERUSAGE_VERTEX) { return D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER; - } else if (buffer->container->usageFlags & SDL_GPU_BUFFERUSAGE_INDEX) { + } else if (buffer->container->usage & SDL_GPU_BUFFERUSAGE_INDEX) { return D3D12_RESOURCE_STATE_INDEX_BUFFER; - } else if (buffer->container->usageFlags & SDL_GPU_BUFFERUSAGE_INDIRECT) { + } else if (buffer->container->usage & SDL_GPU_BUFFERUSAGE_INDIRECT) { return D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT; - } else if (buffer->container->usageFlags & SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ) { + } else if (buffer->container->usage & SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ) { return D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE; - } else if (buffer->container->usageFlags & SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ) { + } else if (buffer->container->usage & SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ) { return D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; - } else if (buffer->container->usageFlags & SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE) { + } else if (buffer->container->usage & SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE) { return D3D12_RESOURCE_STATE_UNORDERED_ACCESS; } else { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Buffer has no default usage mode!"); @@ -1598,7 +1598,7 @@ static void D3D12_INTERNAL_BufferBarrier( destinationState, buffer->handle, 0, - buffer->container->usageFlags & SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE); + buffer->container->usage & SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE); buffer->transitioned = true; } @@ -1870,10 +1870,10 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( d3d12GraphicsRootSignature->fragmentUniformBufferRootIndex[i] = -1; } - if (vertexShader->samplerCount > 0) { + if (vertexShader->num_samplers > 0) { // Vertex Samplers descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER; - descriptorRange.NumDescriptors = vertexShader->samplerCount; + descriptorRange.NumDescriptors = vertexShader->num_samplers; descriptorRange.BaseShaderRegister = 0; descriptorRange.RegisterSpace = 0; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -1889,7 +1889,7 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( parameterCount += 1; descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descriptorRange.NumDescriptors = vertexShader->samplerCount; + descriptorRange.NumDescriptors = vertexShader->num_samplers; descriptorRange.BaseShaderRegister = 0; descriptorRange.RegisterSpace = 0; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -1905,11 +1905,11 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( parameterCount += 1; } - if (vertexShader->storageTextureCount) { + if (vertexShader->numStorageTextures) { // Vertex storage textures descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descriptorRange.NumDescriptors = vertexShader->storageTextureCount; - descriptorRange.BaseShaderRegister = vertexShader->samplerCount; + descriptorRange.NumDescriptors = vertexShader->numStorageTextures; + descriptorRange.BaseShaderRegister = vertexShader->num_samplers; descriptorRange.RegisterSpace = 0; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; descriptorRanges[rangeCount] = descriptorRange; @@ -1924,12 +1924,12 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( parameterCount += 1; } - if (vertexShader->storageBufferCount) { + if (vertexShader->numStorageBuffers) { // Vertex storage buffers descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descriptorRange.NumDescriptors = vertexShader->storageBufferCount; - descriptorRange.BaseShaderRegister = vertexShader->samplerCount + vertexShader->storageTextureCount; + descriptorRange.NumDescriptors = vertexShader->numStorageBuffers; + descriptorRange.BaseShaderRegister = vertexShader->num_samplers + vertexShader->numStorageTextures; descriptorRange.RegisterSpace = 0; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; descriptorRanges[rangeCount] = descriptorRange; @@ -1945,7 +1945,7 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( } // Vertex Uniforms - for (Uint32 i = 0; i < vertexShader->uniformBufferCount; i += 1) { + for (Uint32 i = 0; i < vertexShader->numUniformBuffers; i += 1) { rootParameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; rootParameter.Descriptor.ShaderRegister = i; rootParameter.Descriptor.RegisterSpace = 1; @@ -1955,10 +1955,10 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( parameterCount += 1; } - if (fragmentShader->samplerCount) { + if (fragmentShader->num_samplers) { // Fragment Samplers descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER; - descriptorRange.NumDescriptors = fragmentShader->samplerCount; + descriptorRange.NumDescriptors = fragmentShader->num_samplers; descriptorRange.BaseShaderRegister = 0; descriptorRange.RegisterSpace = 2; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -1974,7 +1974,7 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( parameterCount += 1; descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descriptorRange.NumDescriptors = fragmentShader->samplerCount; + descriptorRange.NumDescriptors = fragmentShader->num_samplers; descriptorRange.BaseShaderRegister = 0; descriptorRange.RegisterSpace = 2; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -1990,11 +1990,11 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( parameterCount += 1; } - if (fragmentShader->storageTextureCount) { + if (fragmentShader->numStorageTextures) { // Fragment Storage Textures descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descriptorRange.NumDescriptors = fragmentShader->storageTextureCount; - descriptorRange.BaseShaderRegister = fragmentShader->samplerCount; + descriptorRange.NumDescriptors = fragmentShader->numStorageTextures; + descriptorRange.BaseShaderRegister = fragmentShader->num_samplers; descriptorRange.RegisterSpace = 2; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; descriptorRanges[rangeCount] = descriptorRange; @@ -2009,11 +2009,11 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( parameterCount += 1; } - if (fragmentShader->storageBufferCount) { + if (fragmentShader->numStorageBuffers) { // Fragment Storage Buffers descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descriptorRange.NumDescriptors = fragmentShader->storageBufferCount; - descriptorRange.BaseShaderRegister = fragmentShader->samplerCount + fragmentShader->storageTextureCount; + descriptorRange.NumDescriptors = fragmentShader->numStorageBuffers; + descriptorRange.BaseShaderRegister = fragmentShader->num_samplers + fragmentShader->numStorageTextures; descriptorRange.RegisterSpace = 2; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; descriptorRanges[rangeCount] = descriptorRange; @@ -2029,7 +2029,7 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature( } // Fragment Uniforms - for (Uint32 i = 0; i < fragmentShader->uniformBufferCount; i += 1) { + for (Uint32 i = 0; i < fragmentShader->numUniformBuffers; i += 1) { rootParameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; rootParameter.Descriptor.ShaderRegister = i; rootParameter.Descriptor.RegisterSpace = 3; @@ -2095,7 +2095,7 @@ static bool D3D12_INTERNAL_CreateShaderBytecode( SDL_GPUShaderFormat format, const Uint8 *code, size_t codeSize, - const char *entryPointName, + const char *entrypointName, void **pBytecode, size_t *pBytecodeSize) { @@ -2141,9 +2141,9 @@ static D3D12ComputeRootSignature *D3D12_INTERNAL_CreateComputeRootSignature( d3d12ComputeRootSignature->uniformBufferRootIndex[i] = -1; } - if (createInfo->readOnlyStorageTextureCount) { + if (createInfo->num_readonly_storage_textures) { descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descriptorRange.NumDescriptors = createInfo->readOnlyStorageTextureCount; + descriptorRange.NumDescriptors = createInfo->num_readonly_storage_textures; descriptorRange.BaseShaderRegister = 0; descriptorRange.RegisterSpace = 0; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -2159,10 +2159,10 @@ static D3D12ComputeRootSignature *D3D12_INTERNAL_CreateComputeRootSignature( parameterCount += 1; } - if (createInfo->readOnlyStorageBufferCount) { + if (createInfo->num_readonly_storage_buffers) { descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descriptorRange.NumDescriptors = createInfo->readOnlyStorageBufferCount; - descriptorRange.BaseShaderRegister = createInfo->readOnlyStorageTextureCount; + descriptorRange.NumDescriptors = createInfo->num_readonly_storage_buffers; + descriptorRange.BaseShaderRegister = createInfo->num_readonly_storage_textures; descriptorRange.RegisterSpace = 0; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; descriptorRanges[rangeCount] = descriptorRange; @@ -2177,9 +2177,9 @@ static D3D12ComputeRootSignature *D3D12_INTERNAL_CreateComputeRootSignature( parameterCount += 1; } - if (createInfo->writeOnlyStorageTextureCount) { + if (createInfo->num_writeonly_storage_textures) { descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; - descriptorRange.NumDescriptors = createInfo->writeOnlyStorageTextureCount; + descriptorRange.NumDescriptors = createInfo->num_writeonly_storage_textures; descriptorRange.BaseShaderRegister = 0; descriptorRange.RegisterSpace = 1; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; @@ -2195,10 +2195,10 @@ static D3D12ComputeRootSignature *D3D12_INTERNAL_CreateComputeRootSignature( parameterCount += 1; } - if (createInfo->writeOnlyStorageBufferCount) { + if (createInfo->num_writeonly_storage_buffers) { descriptorRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; - descriptorRange.NumDescriptors = createInfo->writeOnlyStorageBufferCount; - descriptorRange.BaseShaderRegister = createInfo->writeOnlyStorageTextureCount; + descriptorRange.NumDescriptors = createInfo->num_writeonly_storage_buffers; + descriptorRange.BaseShaderRegister = createInfo->num_writeonly_storage_textures; descriptorRange.RegisterSpace = 1; descriptorRange.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; descriptorRanges[rangeCount] = descriptorRange; @@ -2213,7 +2213,7 @@ static D3D12ComputeRootSignature *D3D12_INTERNAL_CreateComputeRootSignature( parameterCount += 1; } - for (Uint32 i = 0; i < createInfo->uniformBufferCount; i += 1) { + for (Uint32 i = 0; i < createInfo->num_uniform_buffers; i += 1) { rootParameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; rootParameter.Descriptor.ShaderRegister = i; rootParameter.Descriptor.RegisterSpace = 2; @@ -2272,7 +2272,7 @@ static D3D12ComputeRootSignature *D3D12_INTERNAL_CreateComputeRootSignature( static SDL_GPUComputePipeline *D3D12_CreateComputePipeline( SDL_GPURenderer *driverData, - const SDL_GPUComputePipelineCreateInfo *pipelineCreateInfo) + const SDL_GPUComputePipelineCreateInfo *createinfo) { D3D12Renderer *renderer = (D3D12Renderer *)driverData; void *bytecode; @@ -2282,10 +2282,10 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline( if (!D3D12_INTERNAL_CreateShaderBytecode( renderer, SDL_GPU_SHADERSTAGE_COMPUTE, - pipelineCreateInfo->format, - pipelineCreateInfo->code, - pipelineCreateInfo->codeSize, - pipelineCreateInfo->entryPointName, + createinfo->format, + createinfo->code, + createinfo->code_size, + createinfo->entrypoint, &bytecode, &bytecodeSize)) { return NULL; @@ -2293,7 +2293,7 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline( D3D12ComputeRootSignature *rootSignature = D3D12_INTERNAL_CreateComputeRootSignature( renderer, - pipelineCreateInfo); + createinfo); if (rootSignature == NULL) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Could not create root signature!"); @@ -2333,11 +2333,11 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline( computePipeline->pipelineState = pipelineState; computePipeline->rootSignature = rootSignature; - computePipeline->readOnlyStorageTextureCount = pipelineCreateInfo->readOnlyStorageTextureCount; - computePipeline->readOnlyStorageBufferCount = pipelineCreateInfo->readOnlyStorageBufferCount; - computePipeline->writeOnlyStorageTextureCount = pipelineCreateInfo->writeOnlyStorageTextureCount; - computePipeline->writeOnlyStorageBufferCount = pipelineCreateInfo->writeOnlyStorageBufferCount; - computePipeline->uniformBufferCount = pipelineCreateInfo->uniformBufferCount; + computePipeline->num_readonly_storage_textures = createinfo->num_readonly_storage_textures; + computePipeline->num_readonly_storage_buffers = createinfo->num_readonly_storage_buffers; + computePipeline->num_writeonly_storage_textures = createinfo->num_writeonly_storage_textures; + computePipeline->num_writeonly_storage_buffers = createinfo->num_writeonly_storage_buffers; + computePipeline->numUniformBuffers = createinfo->num_uniform_buffers; SDL_AtomicSet(&computePipeline->referenceCount, 0); return (SDL_GPUComputePipeline *)computePipeline; @@ -2349,10 +2349,10 @@ static bool D3D12_INTERNAL_ConvertRasterizerState(SDL_GPURasterizerState rasteri return false; } - desc->FillMode = SDLToD3D12_FillMode[rasterizerState.fillMode]; - desc->CullMode = SDLToD3D12_CullMode[rasterizerState.cullMode]; + desc->FillMode = SDLToD3D12_FillMode[rasterizerState.fill_mode]; + desc->CullMode = SDLToD3D12_CullMode[rasterizerState.cull_mode]; - switch (rasterizerState.frontFace) { + switch (rasterizerState.front_face) { case SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE: desc->FrontCounterClockwise = TRUE; break; @@ -2363,10 +2363,10 @@ static bool D3D12_INTERNAL_ConvertRasterizerState(SDL_GPURasterizerState rasteri return false; } - if (rasterizerState.depthBiasEnable) { - desc->DepthBias = SDL_lroundf(rasterizerState.depthBiasConstantFactor); - desc->DepthBiasClamp = rasterizerState.depthBiasClamp; - desc->SlopeScaledDepthBias = rasterizerState.depthBiasSlopeFactor; + if (rasterizerState.enable_depth_bias) { + desc->DepthBias = SDL_lroundf(rasterizerState.depth_bias_constant_factor); + desc->DepthBiasClamp = rasterizerState.depth_bias_clamp; + desc->SlopeScaledDepthBias = rasterizerState.depth_bias_slope_factor; } else { desc->DepthBias = 0; desc->DepthBiasClamp = 0.0f; @@ -2407,19 +2407,19 @@ static bool D3D12_INTERNAL_ConvertBlendState( rtBlendDesc.LogicOp = D3D12_LOGIC_OP_NOOP; rtBlendDesc.RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; - // If attachmentInfo has more blend states, you can set IndependentBlendEnable to TRUE and assign different blend states to each render target slot - if (i < pipelineInfo->attachmentInfo.colorAttachmentCount) { + // If target_info has more blend states, you can set IndependentBlendEnable to TRUE and assign different blend states to each render target slot + if (i < pipelineInfo->target_info.num_color_targets) { - SDL_GPUColorAttachmentBlendState sdlBlendState = pipelineInfo->attachmentInfo.colorAttachmentDescriptions[i].blendState; + SDL_GPUColorTargetBlendState sdlBlendState = pipelineInfo->target_info.color_target_descriptions[i].blend_state; - rtBlendDesc.BlendEnable = sdlBlendState.blendEnable; - rtBlendDesc.SrcBlend = SDLToD3D12_BlendFactor[sdlBlendState.srcColorBlendFactor]; - rtBlendDesc.DestBlend = SDLToD3D12_BlendFactor[sdlBlendState.dstColorBlendFactor]; - rtBlendDesc.BlendOp = SDLToD3D12_BlendOp[sdlBlendState.colorBlendOp]; - rtBlendDesc.SrcBlendAlpha = SDLToD3D12_BlendFactorAlpha[sdlBlendState.srcAlphaBlendFactor]; - rtBlendDesc.DestBlendAlpha = SDLToD3D12_BlendFactorAlpha[sdlBlendState.dstAlphaBlendFactor]; - rtBlendDesc.BlendOpAlpha = SDLToD3D12_BlendOp[sdlBlendState.alphaBlendOp]; - rtBlendDesc.RenderTargetWriteMask = sdlBlendState.colorWriteMask; + rtBlendDesc.BlendEnable = sdlBlendState.enable_blend; + rtBlendDesc.SrcBlend = SDLToD3D12_BlendFactor[sdlBlendState.src_color_blendfactor]; + rtBlendDesc.DestBlend = SDLToD3D12_BlendFactor[sdlBlendState.dst_color_blendfactor]; + rtBlendDesc.BlendOp = SDLToD3D12_BlendOp[sdlBlendState.color_blend_op]; + rtBlendDesc.SrcBlendAlpha = SDLToD3D12_BlendFactorAlpha[sdlBlendState.src_alpha_blendfactor]; + rtBlendDesc.DestBlendAlpha = SDLToD3D12_BlendFactorAlpha[sdlBlendState.dst_alpha_blendfactor]; + rtBlendDesc.BlendOpAlpha = SDLToD3D12_BlendOp[sdlBlendState.alpha_blend_op]; + rtBlendDesc.RenderTargetWriteMask = sdlBlendState.color_write_mask; if (i > 0) { blendDesc->IndependentBlendEnable = TRUE; @@ -2438,42 +2438,42 @@ static bool D3D12_INTERNAL_ConvertDepthStencilState(SDL_GPUDepthStencilState dep return false; } - desc->DepthEnable = depthStencilState.depthTestEnable == true ? TRUE : FALSE; - desc->DepthWriteMask = depthStencilState.depthWriteEnable == true ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; - desc->DepthFunc = SDLToD3D12_CompareOp[depthStencilState.compareOp]; - desc->StencilEnable = depthStencilState.stencilTestEnable == true ? TRUE : FALSE; - desc->StencilReadMask = depthStencilState.compareMask; - desc->StencilWriteMask = depthStencilState.writeMask; + desc->DepthEnable = depthStencilState.enable_depth_test == true ? TRUE : FALSE; + desc->DepthWriteMask = depthStencilState.enable_depth_write == true ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; + desc->DepthFunc = SDLToD3D12_CompareOp[depthStencilState.compare_op]; + desc->StencilEnable = depthStencilState.enable_stencil_test == true ? TRUE : FALSE; + desc->StencilReadMask = depthStencilState.compare_mask; + desc->StencilWriteMask = depthStencilState.write_mask; - desc->FrontFace.StencilFailOp = SDLToD3D12_StencilOp[depthStencilState.frontStencilState.failOp]; - desc->FrontFace.StencilDepthFailOp = SDLToD3D12_StencilOp[depthStencilState.frontStencilState.depthFailOp]; - desc->FrontFace.StencilPassOp = SDLToD3D12_StencilOp[depthStencilState.frontStencilState.passOp]; - desc->FrontFace.StencilFunc = SDLToD3D12_CompareOp[depthStencilState.frontStencilState.compareOp]; + desc->FrontFace.StencilFailOp = SDLToD3D12_StencilOp[depthStencilState.front_stencil_state.fail_op]; + desc->FrontFace.StencilDepthFailOp = SDLToD3D12_StencilOp[depthStencilState.front_stencil_state.depth_fail_op]; + desc->FrontFace.StencilPassOp = SDLToD3D12_StencilOp[depthStencilState.front_stencil_state.pass_op]; + desc->FrontFace.StencilFunc = SDLToD3D12_CompareOp[depthStencilState.front_stencil_state.compare_op]; - desc->BackFace.StencilFailOp = SDLToD3D12_StencilOp[depthStencilState.backStencilState.failOp]; - desc->BackFace.StencilDepthFailOp = SDLToD3D12_StencilOp[depthStencilState.backStencilState.depthFailOp]; - desc->BackFace.StencilPassOp = SDLToD3D12_StencilOp[depthStencilState.backStencilState.passOp]; - desc->BackFace.StencilFunc = SDLToD3D12_CompareOp[depthStencilState.backStencilState.compareOp]; + desc->BackFace.StencilFailOp = SDLToD3D12_StencilOp[depthStencilState.back_stencil_state.fail_op]; + desc->BackFace.StencilDepthFailOp = SDLToD3D12_StencilOp[depthStencilState.back_stencil_state.depth_fail_op]; + desc->BackFace.StencilPassOp = SDLToD3D12_StencilOp[depthStencilState.back_stencil_state.pass_op]; + desc->BackFace.StencilFunc = SDLToD3D12_CompareOp[depthStencilState.back_stencil_state.compare_op]; return true; } static bool D3D12_INTERNAL_ConvertVertexInputState(SDL_GPUVertexInputState vertexInputState, D3D12_INPUT_ELEMENT_DESC *desc, const char *semantic) { - if (desc == NULL || vertexInputState.vertexAttributeCount == 0) { + if (desc == NULL || vertexInputState.num_vertex_attributes == 0) { return false; } - for (Uint32 i = 0; i < vertexInputState.vertexAttributeCount; i += 1) { - SDL_GPUVertexAttribute attribute = vertexInputState.vertexAttributes[i]; + for (Uint32 i = 0; i < vertexInputState.num_vertex_attributes; i += 1) { + SDL_GPUVertexAttribute attribute = vertexInputState.vertex_attributes[i]; desc[i].SemanticName = semantic; desc[i].SemanticIndex = attribute.location; desc[i].Format = SDLToD3D12_VertexFormat[attribute.format]; desc[i].InputSlot = attribute.binding; desc[i].AlignedByteOffset = attribute.offset; - desc[i].InputSlotClass = SDLToD3D12_InputRate[vertexInputState.vertexBindings[attribute.binding].inputRate]; - desc[i].InstanceDataStepRate = (vertexInputState.vertexBindings[attribute.binding].inputRate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) ? vertexInputState.vertexBindings[attribute.binding].instanceStepRate : 0; + desc[i].InputSlotClass = SDLToD3D12_InputRate[vertexInputState.vertex_bindings[attribute.binding].input_rate]; + desc[i].InstanceDataStepRate = (vertexInputState.vertex_bindings[attribute.binding].input_rate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) ? vertexInputState.vertex_bindings[attribute.binding].instance_step_rate : 0; } return true; @@ -2513,11 +2513,11 @@ static void D3D12_INTERNAL_AssignCpuDescriptorHandle( static SDL_GPUGraphicsPipeline *D3D12_CreateGraphicsPipeline( SDL_GPURenderer *driverData, - const SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo) + const SDL_GPUGraphicsPipelineCreateInfo *createinfo) { D3D12Renderer *renderer = (D3D12Renderer *)driverData; - D3D12Shader *vertShader = (D3D12Shader *)pipelineCreateInfo->vertexShader; - D3D12Shader *fragShader = (D3D12Shader *)pipelineCreateInfo->fragmentShader; + D3D12Shader *vertShader = (D3D12Shader *)createinfo->vertex_shader; + D3D12Shader *fragShader = (D3D12Shader *)createinfo->fragment_shader; D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc; SDL_zero(psoDesc); @@ -2527,21 +2527,21 @@ static SDL_GPUGraphicsPipeline *D3D12_CreateGraphicsPipeline( psoDesc.PS.BytecodeLength = fragShader->bytecodeSize; D3D12_INPUT_ELEMENT_DESC inputElementDescs[D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT]; - if (pipelineCreateInfo->vertexInputState.vertexAttributeCount > 0) { + if (createinfo->vertex_input_state.num_vertex_attributes > 0) { psoDesc.InputLayout.pInputElementDescs = inputElementDescs; - psoDesc.InputLayout.NumElements = pipelineCreateInfo->vertexInputState.vertexAttributeCount; - D3D12_INTERNAL_ConvertVertexInputState(pipelineCreateInfo->vertexInputState, inputElementDescs, renderer->semantic); + psoDesc.InputLayout.NumElements = createinfo->vertex_input_state.num_vertex_attributes; + D3D12_INTERNAL_ConvertVertexInputState(createinfo->vertex_input_state, inputElementDescs, renderer->semantic); } psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - if (!D3D12_INTERNAL_ConvertRasterizerState(pipelineCreateInfo->rasterizerState, &psoDesc.RasterizerState)) { + if (!D3D12_INTERNAL_ConvertRasterizerState(createinfo->rasterizer_state, &psoDesc.RasterizerState)) { return NULL; } - if (!D3D12_INTERNAL_ConvertBlendState(pipelineCreateInfo, &psoDesc.BlendState)) { + if (!D3D12_INTERNAL_ConvertBlendState(createinfo, &psoDesc.BlendState)) { return NULL; } - if (!D3D12_INTERNAL_ConvertDepthStencilState(pipelineCreateInfo->depthStencilState, &psoDesc.DepthStencilState)) { + if (!D3D12_INTERNAL_ConvertDepthStencilState(createinfo->depth_stencil_state, &psoDesc.DepthStencilState)) { return NULL; } @@ -2551,13 +2551,13 @@ static SDL_GPUGraphicsPipeline *D3D12_CreateGraphicsPipeline( } psoDesc.SampleMask = UINT_MAX; - psoDesc.SampleDesc.Count = SDLToD3D12_SampleCount[pipelineCreateInfo->multisampleState.sampleCount]; + psoDesc.SampleDesc.Count = SDLToD3D12_SampleCount[createinfo->multisample_state.sample_count]; psoDesc.SampleDesc.Quality = 0; - psoDesc.DSVFormat = SDLToD3D12_TextureFormat[pipelineCreateInfo->attachmentInfo.depthStencilFormat]; - psoDesc.NumRenderTargets = pipelineCreateInfo->attachmentInfo.colorAttachmentCount; - for (uint32_t i = 0; i < pipelineCreateInfo->attachmentInfo.colorAttachmentCount; i += 1) { - psoDesc.RTVFormats[i] = SDLToD3D12_TextureFormat[pipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions[i].format]; + psoDesc.DSVFormat = SDLToD3D12_TextureFormat[createinfo->target_info.depth_stencil_format]; + psoDesc.NumRenderTargets = createinfo->target_info.num_color_targets; + for (uint32_t i = 0; i < createinfo->target_info.num_color_targets; i += 1) { + psoDesc.RTVFormats[i] = SDLToD3D12_TextureFormat[createinfo->target_info.color_target_descriptions[i].format]; } // Assuming some default values or further initialization @@ -2595,21 +2595,21 @@ static SDL_GPUGraphicsPipeline *D3D12_CreateGraphicsPipeline( pipeline->pipelineState = pipelineState; - for (Uint32 i = 0; i < pipelineCreateInfo->vertexInputState.vertexBindingCount; i += 1) { - pipeline->vertexStrides[i] = pipelineCreateInfo->vertexInputState.vertexBindings[i].stride; + for (Uint32 i = 0; i < createinfo->vertex_input_state.num_vertex_bindings; i += 1) { + pipeline->vertexStrides[i] = createinfo->vertex_input_state.vertex_bindings[i].pitch; } - pipeline->primitiveType = pipelineCreateInfo->primitiveType; + pipeline->primitiveType = createinfo->primitive_type; - pipeline->vertexSamplerCount = vertShader->samplerCount; - pipeline->vertexStorageTextureCount = vertShader->storageTextureCount; - pipeline->vertexStorageBufferCount = vertShader->storageBufferCount; - pipeline->vertexUniformBufferCount = vertShader->uniformBufferCount; + pipeline->vertexSamplerCount = vertShader->num_samplers; + pipeline->vertexStorageTextureCount = vertShader->numStorageTextures; + pipeline->vertexStorageBufferCount = vertShader->numStorageBuffers; + pipeline->vertexUniformBufferCount = vertShader->numUniformBuffers; - pipeline->fragmentSamplerCount = fragShader->samplerCount; - pipeline->fragmentStorageTextureCount = fragShader->storageTextureCount; - pipeline->fragmentStorageBufferCount = fragShader->storageBufferCount; - pipeline->fragmentUniformBufferCount = fragShader->uniformBufferCount; + pipeline->fragmentSamplerCount = fragShader->num_samplers; + pipeline->fragmentStorageTextureCount = fragShader->numStorageTextures; + pipeline->fragmentStorageBufferCount = fragShader->numStorageBuffers; + pipeline->fragmentUniformBufferCount = fragShader->numUniformBuffers; SDL_AtomicSet(&pipeline->referenceCount, 0); return (SDL_GPUGraphicsPipeline *)pipeline; @@ -2617,7 +2617,7 @@ static SDL_GPUGraphicsPipeline *D3D12_CreateGraphicsPipeline( static SDL_GPUSampler *D3D12_CreateSampler( SDL_GPURenderer *driverData, - const SDL_GPUSamplerCreateInfo *samplerCreateInfo) + const SDL_GPUSamplerCreateInfo *createinfo) { D3D12Renderer *renderer = (D3D12Renderer *)driverData; D3D12Sampler *sampler = (D3D12Sampler *)SDL_calloc(1, sizeof(D3D12Sampler)); @@ -2627,19 +2627,19 @@ static SDL_GPUSampler *D3D12_CreateSampler( D3D12_SAMPLER_DESC samplerDesc; samplerDesc.Filter = SDLToD3D12_Filter( - samplerCreateInfo->minFilter, - samplerCreateInfo->magFilter, - samplerCreateInfo->mipmapMode, - samplerCreateInfo->compareEnable, - samplerCreateInfo->anisotropyEnable); - samplerDesc.AddressU = SDLToD3D12_SamplerAddressMode[samplerCreateInfo->addressModeU]; - samplerDesc.AddressV = SDLToD3D12_SamplerAddressMode[samplerCreateInfo->addressModeV]; - samplerDesc.AddressW = SDLToD3D12_SamplerAddressMode[samplerCreateInfo->addressModeW]; - samplerDesc.MaxAnisotropy = (Uint32)samplerCreateInfo->maxAnisotropy; - samplerDesc.ComparisonFunc = SDLToD3D12_CompareOp[samplerCreateInfo->compareOp]; - samplerDesc.MinLOD = samplerCreateInfo->minLod; - samplerDesc.MaxLOD = samplerCreateInfo->maxLod; - samplerDesc.MipLODBias = samplerCreateInfo->mipLodBias; + createinfo->min_filter, + createinfo->mag_filter, + createinfo->mipmap_mode, + createinfo->enable_compare, + createinfo->enable_anisotropy); + samplerDesc.AddressU = SDLToD3D12_SamplerAddressMode[createinfo->address_mode_u]; + samplerDesc.AddressV = SDLToD3D12_SamplerAddressMode[createinfo->address_mode_v]; + samplerDesc.AddressW = SDLToD3D12_SamplerAddressMode[createinfo->address_mode_w]; + samplerDesc.MaxAnisotropy = (Uint32)createinfo->max_anisotropy; + samplerDesc.ComparisonFunc = SDLToD3D12_CompareOp[createinfo->compare_op]; + samplerDesc.MinLOD = createinfo->min_lod; + samplerDesc.MaxLOD = createinfo->max_lod; + samplerDesc.MipLODBias = createinfo->mip_lod_bias; samplerDesc.BorderColor[0] = 0; samplerDesc.BorderColor[1] = 0; samplerDesc.BorderColor[2] = 0; @@ -2655,14 +2655,14 @@ static SDL_GPUSampler *D3D12_CreateSampler( &samplerDesc, sampler->handle.cpuHandle); - sampler->createInfo = *samplerCreateInfo; + sampler->createInfo = *createinfo; SDL_AtomicSet(&sampler->referenceCount, 0); return (SDL_GPUSampler *)sampler; } static SDL_GPUShader *D3D12_CreateShader( SDL_GPURenderer *driverData, - const SDL_GPUShaderCreateInfo *shaderCreateInfo) + const SDL_GPUShaderCreateInfo *createinfo) { D3D12Renderer *renderer = (D3D12Renderer *)driverData; void *bytecode; @@ -2671,11 +2671,11 @@ static SDL_GPUShader *D3D12_CreateShader( if (!D3D12_INTERNAL_CreateShaderBytecode( renderer, - shaderCreateInfo->stage, - shaderCreateInfo->format, - shaderCreateInfo->code, - shaderCreateInfo->codeSize, - shaderCreateInfo->entryPointName, + createinfo->stage, + createinfo->format, + createinfo->code, + createinfo->code_size, + createinfo->entrypoint, &bytecode, &bytecodeSize)) { return NULL; @@ -2685,10 +2685,10 @@ static SDL_GPUShader *D3D12_CreateShader( SDL_free(bytecode); return NULL; } - shader->samplerCount = shaderCreateInfo->samplerCount; - shader->storageBufferCount = shaderCreateInfo->storageBufferCount; - shader->storageTextureCount = shaderCreateInfo->storageTextureCount; - shader->uniformBufferCount = shaderCreateInfo->uniformBufferCount; + shader->num_samplers = createinfo->num_samplers; + shader->numStorageBuffers = createinfo->num_storage_buffers; + shader->numStorageTextures = createinfo->num_storage_textures; + shader->numUniformBuffers = createinfo->num_uniform_buffers; shader->bytecode = bytecode; shader->bytecodeSize = bytecodeSize; @@ -2698,7 +2698,7 @@ static SDL_GPUShader *D3D12_CreateShader( static D3D12Texture *D3D12_INTERNAL_CreateTexture( D3D12Renderer *renderer, - const SDL_GPUTextureCreateInfo *textureCreateInfo, + const SDL_GPUTextureCreateInfo *createinfo, bool isSwapchainTexture) { D3D12Texture *texture; @@ -2717,26 +2717,26 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( return NULL; } - Uint32 layerCount = textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D ? 1 : textureCreateInfo->layerCountOrDepth; - Uint32 depth = textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D ? textureCreateInfo->layerCountOrDepth : 1; + Uint32 layerCount = createinfo->type == SDL_GPU_TEXTURETYPE_3D ? 1 : createinfo->layer_count_or_depth; + Uint32 depth = createinfo->type == SDL_GPU_TEXTURETYPE_3D ? createinfo->layer_count_or_depth : 1; - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET) { + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET) { resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; useClearValue = true; - clearValue.Color[0] = SDL_GetFloatProperty(textureCreateInfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT, 0); - clearValue.Color[1] = SDL_GetFloatProperty(textureCreateInfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT, 0); - clearValue.Color[2] = SDL_GetFloatProperty(textureCreateInfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT, 0); - clearValue.Color[3] = SDL_GetFloatProperty(textureCreateInfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT, 0); + clearValue.Color[0] = SDL_GetFloatProperty(createinfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT, 0); + clearValue.Color[1] = SDL_GetFloatProperty(createinfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_G_FLOAT, 0); + clearValue.Color[2] = SDL_GetFloatProperty(createinfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_B_FLOAT, 0); + clearValue.Color[3] = SDL_GetFloatProperty(createinfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_A_FLOAT, 0); } - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) { + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) { resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; useClearValue = true; - clearValue.DepthStencil.Depth = SDL_GetFloatProperty(textureCreateInfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT, 0); - clearValue.DepthStencil.Stencil = (UINT8)SDL_GetNumberProperty(textureCreateInfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8, 0); + clearValue.DepthStencil.Depth = SDL_GetFloatProperty(createinfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_DEPTH_FLOAT, 0); + clearValue.DepthStencil.Stencil = (UINT8)SDL_GetNumberProperty(createinfo->props, SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_STENCIL_UINT8, 0); } - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE) { + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE) { resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; } @@ -2748,14 +2748,14 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( heapFlags = isSwapchainTexture ? D3D12_HEAP_FLAG_ALLOW_DISPLAY : D3D12_HEAP_FLAG_NONE; - if (textureCreateInfo->type != SDL_GPU_TEXTURETYPE_3D) { + if (createinfo->type != SDL_GPU_TEXTURETYPE_3D) { desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; desc.Alignment = isSwapchainTexture ? 0 : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - desc.Width = textureCreateInfo->width; - desc.Height = textureCreateInfo->height; - desc.DepthOrArraySize = (UINT16)textureCreateInfo->layerCountOrDepth; - desc.MipLevels = (UINT16)textureCreateInfo->levelCount; - desc.Format = SDLToD3D12_TextureFormat[textureCreateInfo->format]; + desc.Width = createinfo->width; + desc.Height = createinfo->height; + desc.DepthOrArraySize = (UINT16)createinfo->layer_count_or_depth; + desc.MipLevels = (UINT16)createinfo->num_levels; + desc.Format = SDLToD3D12_TextureFormat[createinfo->format]; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; // Apparently this is the most efficient choice @@ -2763,18 +2763,18 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( } else { desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE3D; desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - desc.Width = textureCreateInfo->width; - desc.Height = textureCreateInfo->height; - desc.DepthOrArraySize = (UINT16)textureCreateInfo->layerCountOrDepth; - desc.MipLevels = (UINT16)textureCreateInfo->levelCount; - desc.Format = SDLToD3D12_TextureFormat[textureCreateInfo->format]; + desc.Width = createinfo->width; + desc.Height = createinfo->height; + desc.DepthOrArraySize = (UINT16)createinfo->layer_count_or_depth; + desc.MipLevels = (UINT16)createinfo->num_levels; + desc.Format = SDLToD3D12_TextureFormat[createinfo->format]; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; desc.Flags = resourceFlags; } - initialState = isSwapchainTexture ? D3D12_RESOURCE_STATE_PRESENT : D3D12_INTERNAL_DefaultTextureResourceState(textureCreateInfo->usageFlags); + initialState = isSwapchainTexture ? D3D12_RESOURCE_STATE_PRESENT : D3D12_INTERNAL_DefaultTextureResourceState(createinfo->usage); clearValue.Format = desc.Format; res = ID3D12Device_CreateCommittedResource( @@ -2795,9 +2795,9 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( texture->resource = handle; // Create the SRV if applicable - if ((textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_SAMPLER) || - (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ) || - (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ)) { + if ((createinfo->usage & SDL_GPU_TEXTUREUSAGE_SAMPLER) || + (createinfo->usage & SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ) || + (createinfo->usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ)) { D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc; D3D12_INTERNAL_AssignCpuDescriptorHandle( @@ -2805,30 +2805,30 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, &texture->srvHandle); - srvDesc.Format = SDLToD3D12_TextureFormat[textureCreateInfo->format]; + srvDesc.Format = SDLToD3D12_TextureFormat[createinfo->format]; srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_CUBE) { + if (createinfo->type == SDL_GPU_TEXTURETYPE_CUBE) { srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; - srvDesc.TextureCube.MipLevels = textureCreateInfo->levelCount; + srvDesc.TextureCube.MipLevels = createinfo->num_levels; srvDesc.TextureCube.MostDetailedMip = 0; srvDesc.TextureCube.ResourceMinLODClamp = 0; - } else if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY) { + } else if (createinfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY) { srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - srvDesc.Texture2DArray.MipLevels = textureCreateInfo->levelCount; + srvDesc.Texture2DArray.MipLevels = createinfo->num_levels; srvDesc.Texture2DArray.MostDetailedMip = 0; srvDesc.Texture2DArray.FirstArraySlice = 0; srvDesc.Texture2DArray.ArraySize = layerCount; srvDesc.Texture2DArray.ResourceMinLODClamp = 0; srvDesc.Texture2DArray.PlaneSlice = 0; - } else if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D) { + } else if (createinfo->type == SDL_GPU_TEXTURETYPE_3D) { srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D; - srvDesc.Texture3D.MipLevels = textureCreateInfo->levelCount; + srvDesc.Texture3D.MipLevels = createinfo->num_levels; srvDesc.Texture3D.MostDetailedMip = 0; srvDesc.Texture3D.ResourceMinLODClamp = 0; // default behavior } else { srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = textureCreateInfo->levelCount; + srvDesc.Texture2D.MipLevels = createinfo->num_levels; srvDesc.Texture2D.MostDetailedMip = 0; srvDesc.Texture2D.PlaneSlice = 0; srvDesc.Texture2D.ResourceMinLODClamp = 0; // default behavior @@ -2843,7 +2843,7 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( SDL_AtomicSet(&texture->referenceCount, 0); - texture->subresourceCount = textureCreateInfo->levelCount * layerCount; + texture->subresourceCount = createinfo->num_levels * layerCount; texture->subresources = (D3D12TextureSubresource *)SDL_calloc( texture->subresourceCount, sizeof(D3D12TextureSubresource)); if (!texture->subresources) { @@ -2851,11 +2851,11 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( return NULL; } for (Uint32 layerIndex = 0; layerIndex < layerCount; layerIndex += 1) { - for (Uint32 levelIndex = 0; levelIndex < textureCreateInfo->levelCount; levelIndex += 1) { + for (Uint32 levelIndex = 0; levelIndex < createinfo->num_levels; levelIndex += 1) { Uint32 subresourceIndex = D3D12_INTERNAL_CalcSubresource( levelIndex, layerIndex, - textureCreateInfo->levelCount); + createinfo->num_levels); texture->subresources[subresourceIndex].parent = texture; texture->subresources[subresourceIndex].layer = layerIndex; @@ -2868,7 +2868,7 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( texture->subresources[subresourceIndex].dsvHandle.heap = NULL; // Create RTV if needed - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET) { + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET) { texture->subresources[subresourceIndex].rtvHandles = (D3D12CPUDescriptor *)SDL_calloc(depth, sizeof(D3D12CPUDescriptor)); for (Uint32 depthIndex = 0; depthIndex < depth; depthIndex += 1) { @@ -2879,15 +2879,15 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( D3D12_DESCRIPTOR_HEAP_TYPE_RTV, &texture->subresources[subresourceIndex].rtvHandles[depthIndex]); - rtvDesc.Format = SDLToD3D12_TextureFormat[textureCreateInfo->format]; + rtvDesc.Format = SDLToD3D12_TextureFormat[createinfo->format]; - if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY || textureCreateInfo->type == SDL_GPU_TEXTURETYPE_CUBE) { + if (createinfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY || createinfo->type == SDL_GPU_TEXTURETYPE_CUBE) { rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY; rtvDesc.Texture2DArray.MipSlice = levelIndex; rtvDesc.Texture2DArray.FirstArraySlice = layerIndex; rtvDesc.Texture2DArray.ArraySize = 1; rtvDesc.Texture2DArray.PlaneSlice = 0; - } else if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D) { + } else if (createinfo->type == SDL_GPU_TEXTURETYPE_3D) { rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE3D; rtvDesc.Texture3D.MipSlice = levelIndex; rtvDesc.Texture3D.FirstWSlice = depthIndex; @@ -2907,7 +2907,7 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( } // Create DSV if needed - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) { + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) { D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc; D3D12_INTERNAL_AssignCpuDescriptorHandle( @@ -2915,7 +2915,7 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( D3D12_DESCRIPTOR_HEAP_TYPE_DSV, &texture->subresources[subresourceIndex].dsvHandle); - dsvDesc.Format = SDLToD3D12_TextureFormat[textureCreateInfo->format]; + dsvDesc.Format = SDLToD3D12_TextureFormat[createinfo->format]; dsvDesc.Flags = (D3D12_DSV_FLAGS)0; dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; dsvDesc.Texture2D.MipSlice = levelIndex; @@ -2928,7 +2928,7 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( } // Create subresource UAV if necessary - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE) { + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE) { D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc; D3D12_INTERNAL_AssignCpuDescriptorHandle( @@ -2936,14 +2936,14 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, &texture->subresources[subresourceIndex].uavHandle); - uavDesc.Format = SDLToD3D12_TextureFormat[textureCreateInfo->format]; + uavDesc.Format = SDLToD3D12_TextureFormat[createinfo->format]; - if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY || textureCreateInfo->type == SDL_GPU_TEXTURETYPE_CUBE) { + if (createinfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY || createinfo->type == SDL_GPU_TEXTURETYPE_CUBE) { uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; uavDesc.Texture2DArray.MipSlice = levelIndex; uavDesc.Texture2DArray.FirstArraySlice = layerIndex; uavDesc.Texture2DArray.ArraySize = 1; - } else if (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D) { + } else if (createinfo->type == SDL_GPU_TEXTURETYPE_3D) { uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D; uavDesc.Texture3D.MipSlice = levelIndex; uavDesc.Texture3D.FirstWSlice = 0; @@ -2969,14 +2969,14 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture( static SDL_GPUTexture *D3D12_CreateTexture( SDL_GPURenderer *driverData, - const SDL_GPUTextureCreateInfo *textureCreateInfo) + const SDL_GPUTextureCreateInfo *createinfo) { D3D12TextureContainer *container = (D3D12TextureContainer *)SDL_calloc(1, sizeof(D3D12TextureContainer)); if (!container) { return NULL; } - container->header.info = *textureCreateInfo; + container->header.info = *createinfo; container->textureCapacity = 1; container->textureCount = 1; container->textures = (D3D12Texture **)SDL_calloc( @@ -2992,7 +2992,7 @@ static SDL_GPUTexture *D3D12_CreateTexture( D3D12Texture *texture = D3D12_INTERNAL_CreateTexture( (D3D12Renderer *)driverData, - textureCreateInfo, + createinfo, false); if (!texture) { @@ -3013,7 +3013,7 @@ static SDL_GPUTexture *D3D12_CreateTexture( static D3D12Buffer *D3D12_INTERNAL_CreateBuffer( D3D12Renderer *renderer, SDL_GPUBufferUsageFlags usageFlags, - Uint32 sizeInBytes, + Uint32 size, D3D12BufferType type) { D3D12Buffer *buffer; @@ -3038,7 +3038,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer( resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; } #if (defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) - if (usageFlags & SDL_GPU_BUFFERUSAGE_INDIRECT) { + if (usage & SDL_GPU_BUFFERUSAGE_INDIRECT) { resourceFlags |= D3D12XBOX_RESOURCE_FLAG_ALLOW_INDIRECT_BUFFER; } #endif @@ -3083,7 +3083,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer( desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - desc.Width = sizeInBytes; + desc.Width = size; desc.Height = 1; desc.DepthOrArraySize = 1; desc.MipLevels = 1; @@ -3124,7 +3124,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer( uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; uavDesc.Format = DXGI_FORMAT_R32_TYPELESS; uavDesc.Buffer.FirstElement = 0; - uavDesc.Buffer.NumElements = sizeInBytes / sizeof(Uint32); + uavDesc.Buffer.NumElements = size / sizeof(Uint32); uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW; uavDesc.Buffer.CounterOffsetInBytes = 0; // TODO: support counters? uavDesc.Buffer.StructureByteStride = 0; @@ -3150,7 +3150,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer( srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; srvDesc.Buffer.FirstElement = 0; - srvDesc.Buffer.NumElements = sizeInBytes / sizeof(Uint32); + srvDesc.Buffer.NumElements = size / sizeof(Uint32); srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; srvDesc.Buffer.StructureByteStride = 0; @@ -3170,7 +3170,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer( &buffer->cbvDescriptor); cbvDesc.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(handle); - cbvDesc.SizeInBytes = sizeInBytes; + cbvDesc.SizeInBytes = size; // Create CBV ID3D12Device_CreateConstantBufferView( @@ -3210,7 +3210,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer( static D3D12BufferContainer *D3D12_INTERNAL_CreateBufferContainer( D3D12Renderer *renderer, SDL_GPUBufferUsageFlags usageFlags, - Uint32 sizeInBytes, + Uint32 size, D3D12BufferType type) { D3D12BufferContainer *container; @@ -3221,8 +3221,8 @@ static D3D12BufferContainer *D3D12_INTERNAL_CreateBufferContainer( return NULL; } - container->usageFlags = usageFlags; - container->size = sizeInBytes; + container->usage = usageFlags; + container->size = size; container->type = type; container->bufferCapacity = 1; @@ -3238,7 +3238,7 @@ static D3D12BufferContainer *D3D12_INTERNAL_CreateBufferContainer( buffer = D3D12_INTERNAL_CreateBuffer( renderer, usageFlags, - sizeInBytes, + size, type); if (buffer == NULL) { @@ -3259,24 +3259,24 @@ static D3D12BufferContainer *D3D12_INTERNAL_CreateBufferContainer( static SDL_GPUBuffer *D3D12_CreateBuffer( SDL_GPURenderer *driverData, SDL_GPUBufferUsageFlags usageFlags, - Uint32 sizeInBytes) + Uint32 size) { return (SDL_GPUBuffer *)D3D12_INTERNAL_CreateBufferContainer( (D3D12Renderer *)driverData, usageFlags, - sizeInBytes, + size, D3D12_BUFFER_TYPE_GPU); } static SDL_GPUTransferBuffer *D3D12_CreateTransferBuffer( SDL_GPURenderer *driverData, SDL_GPUTransferBufferUsage usage, - Uint32 sizeInBytes) + Uint32 size) { return (SDL_GPUTransferBuffer *)D3D12_INTERNAL_CreateBufferContainer( (D3D12Renderer *)driverData, 0, - sizeInBytes, + size, usage == SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD ? D3D12_BUFFER_TYPE_UPLOAD : D3D12_BUFFER_TYPE_DOWNLOAD); } @@ -3291,7 +3291,7 @@ static void D3D12_SetBufferName( D3D12BufferContainer *container = (D3D12BufferContainer *)buffer; size_t textLength = SDL_strlen(text) + 1; - if (renderer->debugMode) { + if (renderer->debug_mode) { container->debugName = (char *)SDL_realloc( container->debugName, textLength); @@ -3319,7 +3319,7 @@ static void D3D12_SetTextureName( D3D12TextureContainer *container = (D3D12TextureContainer *)texture; size_t textLength = SDL_strlen(text) + 1; - if (renderer->debugMode) { + if (renderer->debug_mode) { container->debugName = (char *)SDL_realloc( container->debugName, textLength); @@ -3346,11 +3346,11 @@ static bool D3D12_INTERNAL_StrToWStr( D3D12Renderer *renderer, const char *str, wchar_t *wstr, - size_t wstr_size, + size_t wstrSize, Uint32 *outSize) { size_t inlen, result; - size_t outlen = wstr_size; + size_t outlen = wstrSize; if (renderer->iconv == NULL) { renderer->iconv = SDL_iconv_open("WCHAR_T", "UTF-8"); @@ -3585,8 +3585,8 @@ static void D3D12_SetViewport( d3d12Viewport.TopLeftY = viewport->y; d3d12Viewport.Width = viewport->w; d3d12Viewport.Height = viewport->h; - d3d12Viewport.MinDepth = viewport->minDepth; - d3d12Viewport.MaxDepth = viewport->maxDepth; + d3d12Viewport.MinDepth = viewport->min_depth; + d3d12Viewport.MaxDepth = viewport->max_depth; ID3D12GraphicsCommandList_RSSetViewports(d3d12CommandBuffer->graphicsCommandList, 1, &d3d12Viewport); } @@ -3628,7 +3628,7 @@ static D3D12TextureSubresource *D3D12_INTERNAL_FetchTextureSubresource( Uint32 index = D3D12_INTERNAL_CalcSubresource( level, layer, - container->header.info.levelCount); + container->header.info.num_levels); return &container->activeTexture->subresources[index]; } @@ -3673,7 +3673,7 @@ static void D3D12_INTERNAL_CycleActiveTexture( container->activeTexture = texture; - if (renderer->debugMode && container->debugName != NULL) { + if (renderer->debug_mode && container->debugName != NULL) { D3D12_INTERNAL_SetResourceName( renderer, container->activeTexture->resource, @@ -3732,7 +3732,7 @@ static void D3D12_INTERNAL_CycleActiveBuffer( // No buffer handle is available, create a new one. D3D12Buffer *buffer = D3D12_INTERNAL_CreateBuffer( renderer, - container->usageFlags, + container->usage, container->size, container->type); @@ -3755,7 +3755,7 @@ static void D3D12_INTERNAL_CycleActiveBuffer( container->activeBuffer = buffer; - if (renderer->debugMode && container->debugName != NULL) { + if (renderer->debug_mode && container->debugName != NULL) { D3D12_INTERNAL_SetResourceName( renderer, container->activeBuffer->handle, @@ -3787,21 +3787,21 @@ static D3D12Buffer *D3D12_INTERNAL_PrepareBufferForWrite( static void D3D12_BeginRenderPass( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo) + const SDL_GPUColorTargetInfo *colorTargetInfos, + Uint32 numColorTargets, + const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; Uint32 framebufferWidth = SDL_MAX_UINT32; Uint32 framebufferHeight = SDL_MAX_UINT32; - for (Uint32 i = 0; i < colorAttachmentCount; i += 1) { - D3D12TextureContainer *container = (D3D12TextureContainer *)colorAttachmentInfos[i].texture; - Uint32 h = container->header.info.height >> colorAttachmentInfos[i].mipLevel; - Uint32 w = container->header.info.width >> colorAttachmentInfos[i].mipLevel; + for (Uint32 i = 0; i < numColorTargets; i += 1) { + D3D12TextureContainer *container = (D3D12TextureContainer *)colorTargetInfos[i].texture; + Uint32 h = container->header.info.height >> colorTargetInfos[i].mip_level; + Uint32 w = container->header.info.width >> colorTargetInfos[i].mip_level; - // The framebuffer cannot be larger than the smallest attachment. + // The framebuffer cannot be larger than the smallest target. if (w < framebufferWidth) { framebufferWidth = w; @@ -3811,19 +3811,19 @@ static void D3D12_BeginRenderPass( framebufferHeight = h; } - if (!(container->header.info.usageFlags & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) { - SDL_LogError(SDL_LOG_CATEGORY_GPU, "Color attachment texture was not designated as a color target!"); + if (!(container->header.info.usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) { + SDL_LogError(SDL_LOG_CATEGORY_GPU, "Color target texture was not designated as a color target!"); return; } } - if (depthStencilAttachmentInfo != NULL) { - D3D12TextureContainer *container = (D3D12TextureContainer *)depthStencilAttachmentInfo->texture; + if (depthStencilTargetInfo != NULL) { + D3D12TextureContainer *container = (D3D12TextureContainer *)depthStencilTargetInfo->texture; Uint32 h = container->header.info.height; Uint32 w = container->header.info.width; - // The framebuffer cannot be larger than the smallest attachment. + // The framebuffer cannot be larger than the smallest target. if (w < framebufferWidth) { framebufferWidth = w; @@ -3834,34 +3834,34 @@ static void D3D12_BeginRenderPass( } // Fixme: - if (!(container->header.info.usageFlags & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) { - SDL_LogError(SDL_LOG_CATEGORY_GPU, "Depth stencil attachment texture was not designated as a depth target!"); + if (!(container->header.info.usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) { + SDL_LogError(SDL_LOG_CATEGORY_GPU, "Depth stencil target texture was not designated as a depth target!"); return; } } D3D12_CPU_DESCRIPTOR_HANDLE rtvs[MAX_COLOR_TARGET_BINDINGS]; - for (Uint32 i = 0; i < colorAttachmentCount; i += 1) { - D3D12TextureContainer *container = (D3D12TextureContainer *)colorAttachmentInfos[i].texture; + for (Uint32 i = 0; i < numColorTargets; i += 1) { + D3D12TextureContainer *container = (D3D12TextureContainer *)colorTargetInfos[i].texture; D3D12TextureSubresource *subresource = D3D12_INTERNAL_PrepareTextureSubresourceForWrite( d3d12CommandBuffer, container, - container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorAttachmentInfos[i].layerOrDepthPlane, - colorAttachmentInfos[i].mipLevel, - colorAttachmentInfos[i].cycle, + container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorTargetInfos[i].layer_or_depth_plane, + colorTargetInfos[i].mip_level, + colorTargetInfos[i].cycle, D3D12_RESOURCE_STATE_RENDER_TARGET); - Uint32 rtvIndex = container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? colorAttachmentInfos[i].layerOrDepthPlane : 0; + Uint32 rtvIndex = container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? colorTargetInfos[i].layer_or_depth_plane : 0; D3D12_CPU_DESCRIPTOR_HANDLE rtv = subresource->rtvHandles[rtvIndex].cpuHandle; - if (colorAttachmentInfos[i].loadOp == SDL_GPU_LOADOP_CLEAR) { + if (colorTargetInfos[i].load_op == SDL_GPU_LOADOP_CLEAR) { float clearColor[4]; - clearColor[0] = colorAttachmentInfos[i].clearColor.r; - clearColor[1] = colorAttachmentInfos[i].clearColor.g; - clearColor[2] = colorAttachmentInfos[i].clearColor.b; - clearColor[3] = colorAttachmentInfos[i].clearColor.a; + clearColor[0] = colorTargetInfos[i].clear_color.r; + clearColor[1] = colorTargetInfos[i].clear_color.g; + clearColor[2] = colorTargetInfos[i].clear_color.b; + clearColor[3] = colorTargetInfos[i].clear_color.a; ID3D12GraphicsCommandList_ClearRenderTargetView( d3d12CommandBuffer->graphicsCommandList, @@ -3872,32 +3872,32 @@ static void D3D12_BeginRenderPass( } rtvs[i] = rtv; - d3d12CommandBuffer->colorAttachmentTextureSubresources[i] = subresource; + d3d12CommandBuffer->colorTargetTextureSubresources[i] = subresource; D3D12_INTERNAL_TrackTexture(d3d12CommandBuffer, subresource->parent); } - d3d12CommandBuffer->colorAttachmentTextureSubresourceCount = colorAttachmentCount; + d3d12CommandBuffer->colorTargetTextureSubresourceCount = numColorTargets; D3D12_CPU_DESCRIPTOR_HANDLE dsv; - if (depthStencilAttachmentInfo != NULL) { - D3D12TextureContainer *container = (D3D12TextureContainer *)depthStencilAttachmentInfo->texture; + if (depthStencilTargetInfo != NULL) { + D3D12TextureContainer *container = (D3D12TextureContainer *)depthStencilTargetInfo->texture; D3D12TextureSubresource *subresource = D3D12_INTERNAL_PrepareTextureSubresourceForWrite( d3d12CommandBuffer, container, 0, 0, - depthStencilAttachmentInfo->cycle, + depthStencilTargetInfo->cycle, D3D12_RESOURCE_STATE_DEPTH_WRITE); if ( - depthStencilAttachmentInfo->loadOp == SDL_GPU_LOADOP_CLEAR || - depthStencilAttachmentInfo->stencilLoadOp == SDL_GPU_LOADOP_CLEAR) { + depthStencilTargetInfo->load_op == SDL_GPU_LOADOP_CLEAR || + depthStencilTargetInfo->stencil_load_op == SDL_GPU_LOADOP_CLEAR) { D3D12_CLEAR_FLAGS clearFlags = (D3D12_CLEAR_FLAGS)0; - if (depthStencilAttachmentInfo->loadOp == SDL_GPU_LOADOP_CLEAR) { + if (depthStencilTargetInfo->load_op == SDL_GPU_LOADOP_CLEAR) { clearFlags |= D3D12_CLEAR_FLAG_DEPTH; } - if (depthStencilAttachmentInfo->stencilLoadOp == SDL_GPU_LOADOP_CLEAR) { + if (depthStencilTargetInfo->stencil_load_op == SDL_GPU_LOADOP_CLEAR) { clearFlags |= D3D12_CLEAR_FLAG_STENCIL; } @@ -3905,8 +3905,8 @@ static void D3D12_BeginRenderPass( d3d12CommandBuffer->graphicsCommandList, subresource->dsvHandle.cpuHandle, clearFlags, - depthStencilAttachmentInfo->depthStencilClearValue.depth, - depthStencilAttachmentInfo->depthStencilClearValue.stencil, + depthStencilTargetInfo->clear_value.depth, + depthStencilTargetInfo->clear_value.stencil, 0, NULL); } @@ -3918,10 +3918,10 @@ static void D3D12_BeginRenderPass( ID3D12GraphicsCommandList_OMSetRenderTargets( d3d12CommandBuffer->graphicsCommandList, - colorAttachmentCount, + numColorTargets, rtvs, false, - (depthStencilAttachmentInfo == NULL) ? NULL : &dsv); + (depthStencilTargetInfo == NULL) ? NULL : &dsv); // Set sensible default states SDL_GPUViewport defaultViewport; @@ -3929,8 +3929,8 @@ static void D3D12_BeginRenderPass( defaultViewport.y = 0; defaultViewport.w = (float)framebufferWidth; defaultViewport.h = (float)framebufferHeight; - defaultViewport.minDepth = 0; - defaultViewport.maxDepth = 1; + defaultViewport.min_depth = 0; + defaultViewport.max_depth = 1; D3D12_SetViewport( commandBuffer, @@ -4048,7 +4048,7 @@ static void D3D12_INTERNAL_PushUniformData( SDL_GPUShaderStage shaderStage, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { D3D12UniformBuffer *uniformBuffer; @@ -4077,7 +4077,7 @@ static void D3D12_INTERNAL_PushUniformData( uniformBuffer->currentBlockSize = D3D12_INTERNAL_Align( - dataLengthInBytes, + length, 256); // If there is no more room, acquire a new uniform buffer @@ -4109,7 +4109,7 @@ static void D3D12_INTERNAL_PushUniformData( SDL_memcpy( (Uint8 *)uniformBuffer->buffer->mapPointer + uniformBuffer->writeOffset, data, - dataLengthInBytes); + length); uniformBuffer->writeOffset += uniformBuffer->currentBlockSize; @@ -4172,37 +4172,37 @@ static void D3D12_BindGraphicsPipeline( static void D3D12_BindVertexBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstBinding, - const SDL_GPUBufferBinding *pBindings, - Uint32 bindingCount) + const SDL_GPUBufferBinding *bindings, + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { - D3D12Buffer *currentBuffer = ((D3D12BufferContainer *)pBindings[i].buffer)->activeBuffer; + for (Uint32 i = 0; i < numBindings; i += 1) { + D3D12Buffer *currentBuffer = ((D3D12BufferContainer *)bindings[i].buffer)->activeBuffer; d3d12CommandBuffer->vertexBuffers[firstBinding + i] = currentBuffer; - d3d12CommandBuffer->vertexBufferOffsets[firstBinding + i] = pBindings[i].offset; + d3d12CommandBuffer->vertexBufferOffsets[firstBinding + i] = bindings[i].offset; D3D12_INTERNAL_TrackBuffer(d3d12CommandBuffer, currentBuffer); } d3d12CommandBuffer->vertexBufferCount = - SDL_max(d3d12CommandBuffer->vertexBufferCount, firstBinding + bindingCount); + SDL_max(d3d12CommandBuffer->vertexBufferCount, firstBinding + numBindings); d3d12CommandBuffer->needVertexBufferBind = true; } static void D3D12_BindIndexBuffer( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUBufferBinding *pBinding, + const SDL_GPUBufferBinding *binding, SDL_GPUIndexElementSize indexElementSize) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - D3D12Buffer *buffer = ((D3D12BufferContainer *)pBinding->buffer)->activeBuffer; + D3D12Buffer *buffer = ((D3D12BufferContainer *)binding->buffer)->activeBuffer; D3D12_INDEX_BUFFER_VIEW view; D3D12_INTERNAL_TrackBuffer(d3d12CommandBuffer, buffer); - view.BufferLocation = buffer->virtualAddress + pBinding->offset; - view.SizeInBytes = buffer->container->size - pBinding->offset; + view.BufferLocation = buffer->virtualAddress + binding->offset; + view.SizeInBytes = buffer->container->size - binding->offset; view.Format = indexElementSize == SDL_GPU_INDEXELEMENTSIZE_16BIT ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT; @@ -4215,11 +4215,11 @@ static void D3D12_BindVertexSamplers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D12TextureContainer *container = (D3D12TextureContainer *)textureSamplerBindings[i].texture; D3D12Sampler *sampler = (D3D12Sampler *)textureSamplerBindings[i].sampler; @@ -4242,11 +4242,11 @@ static void D3D12_BindVertexStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D12TextureContainer *container = (D3D12TextureContainer *)storageTextures[i]; D3D12Texture *texture = container->activeTexture; @@ -4262,11 +4262,11 @@ static void D3D12_BindVertexStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D12BufferContainer *container = (D3D12BufferContainer *)storageBuffers[i]; D3D12_INTERNAL_TrackBuffer( @@ -4283,11 +4283,11 @@ static void D3D12_BindFragmentSamplers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D12TextureContainer *container = (D3D12TextureContainer *)textureSamplerBindings[i].texture; D3D12Sampler *sampler = (D3D12Sampler *)textureSamplerBindings[i].sampler; @@ -4310,11 +4310,11 @@ static void D3D12_BindFragmentStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D12TextureContainer *container = (D3D12TextureContainer *)storageTextures[i]; D3D12Texture *texture = container->activeTexture; @@ -4330,11 +4330,11 @@ static void D3D12_BindFragmentStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { D3D12BufferContainer *container = (D3D12BufferContainer *)storageBuffers[i]; D3D12_INTERNAL_TrackBuffer( @@ -4351,7 +4351,7 @@ static void D3D12_PushVertexUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; @@ -4360,14 +4360,14 @@ static void D3D12_PushVertexUniformData( SDL_GPU_SHADERSTAGE_VERTEX, slotIndex, data, - dataLengthInBytes); + length); } static void D3D12_PushFragmentUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; @@ -4376,7 +4376,7 @@ static void D3D12_PushFragmentUniformData( SDL_GPU_SHADERSTAGE_FRAGMENT, slotIndex, data, - dataLengthInBytes); + length); } static void D3D12_INTERNAL_WriteGPUDescriptors( @@ -4614,8 +4614,8 @@ static void D3D12_INTERNAL_BindGraphicsResources( static void D3D12_DrawIndexedPrimitives( SDL_GPUCommandBuffer *commandBuffer, - Uint32 indexCount, - Uint32 instanceCount, + Uint32 numIndices, + Uint32 numInstances, Uint32 firstIndex, Sint32 vertexOffset, Uint32 firstInstance) @@ -4625,8 +4625,8 @@ static void D3D12_DrawIndexedPrimitives( ID3D12GraphicsCommandList_DrawIndexedInstanced( d3d12CommandBuffer->graphicsCommandList, - indexCount, - instanceCount, + numIndices, + numInstances, firstIndex, vertexOffset, firstInstance); @@ -4634,8 +4634,8 @@ static void D3D12_DrawIndexedPrimitives( static void D3D12_DrawPrimitives( SDL_GPUCommandBuffer *commandBuffer, - Uint32 vertexCount, - Uint32 instanceCount, + Uint32 numVertices, + Uint32 numInstances, Uint32 firstVertex, Uint32 firstInstance) { @@ -4644,8 +4644,8 @@ static void D3D12_DrawPrimitives( ID3D12GraphicsCommandList_DrawInstanced( d3d12CommandBuffer->graphicsCommandList, - vertexCount, - instanceCount, + numVertices, + numInstances, firstVertex, firstInstance); } @@ -4653,29 +4653,29 @@ static void D3D12_DrawPrimitives( static void D3D12_DrawPrimitivesIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride) + Uint32 pitch) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; D3D12Buffer *d3d12Buffer = ((D3D12BufferContainer *)buffer)->activeBuffer; D3D12_INTERNAL_BindGraphicsResources(d3d12CommandBuffer); - if (stride == sizeof(SDL_GPUIndirectDrawCommand)) { + if (pitch == sizeof(SDL_GPUIndirectDrawCommand)) { // Real multi-draw! ID3D12GraphicsCommandList_ExecuteIndirect( d3d12CommandBuffer->graphicsCommandList, d3d12CommandBuffer->renderer->indirectDrawCommandSignature, drawCount, d3d12Buffer->handle, - offsetInBytes, + offset, NULL, 0); } else { /* Fake multi-draw... * FIXME: we could make this real multi-draw - * if we have a lookup to get command signature per stride value + * if we have a lookup to get command signature per pitch value */ for (Uint32 i = 0; i < drawCount; i += 1) { ID3D12GraphicsCommandList_ExecuteIndirect( @@ -4683,7 +4683,7 @@ static void D3D12_DrawPrimitivesIndirect( d3d12CommandBuffer->renderer->indirectDrawCommandSignature, 1, d3d12Buffer->handle, - offsetInBytes + (stride * i), + offset + (pitch * i), NULL, 0); } @@ -4693,29 +4693,29 @@ static void D3D12_DrawPrimitivesIndirect( static void D3D12_DrawIndexedPrimitivesIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride) + Uint32 pitch) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; D3D12Buffer *d3d12Buffer = ((D3D12BufferContainer *)buffer)->activeBuffer; D3D12_INTERNAL_BindGraphicsResources(d3d12CommandBuffer); - if (stride == sizeof(SDL_GPUIndexedIndirectDrawCommand)) { + if (pitch == sizeof(SDL_GPUIndexedIndirectDrawCommand)) { // Real multi-draw! ID3D12GraphicsCommandList_ExecuteIndirect( d3d12CommandBuffer->graphicsCommandList, d3d12CommandBuffer->renderer->indirectIndexedDrawCommandSignature, drawCount, d3d12Buffer->handle, - offsetInBytes, + offset, NULL, 0); } else { /* Fake multi-draw... * FIXME: we could make this real multi-draw - * if we have a lookup to get command signature per stride value + * if we have a lookup to get command signature per pitch value */ for (Uint32 i = 0; i < drawCount; i += 1) { ID3D12GraphicsCommandList_ExecuteIndirect( @@ -4723,7 +4723,7 @@ static void D3D12_DrawIndexedPrimitivesIndirect( d3d12CommandBuffer->renderer->indirectIndexedDrawCommandSignature, 1, d3d12Buffer->handle, - offsetInBytes + (stride * i), + offset + (pitch * i), NULL, 0); } @@ -4736,15 +4736,15 @@ static void D3D12_EndRenderPass( D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; Uint32 i; - for (i = 0; i < d3d12CommandBuffer->colorAttachmentTextureSubresourceCount; i += 1) { + for (i = 0; i < d3d12CommandBuffer->colorTargetTextureSubresourceCount; i += 1) { D3D12_INTERNAL_TextureSubresourceTransitionToDefaultUsage( d3d12CommandBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, - d3d12CommandBuffer->colorAttachmentTextureSubresources[i]); + d3d12CommandBuffer->colorTargetTextureSubresources[i]); - d3d12CommandBuffer->colorAttachmentTextureSubresources[i] = NULL; + d3d12CommandBuffer->colorTargetTextureSubresources[i] = NULL; } - d3d12CommandBuffer->colorAttachmentTextureSubresourceCount = 0; + d3d12CommandBuffer->colorTargetTextureSubresourceCount = 0; if (d3d12CommandBuffer->depthStencilTextureSubresource != NULL) { D3D12_INTERNAL_TextureSubresourceTransitionToDefaultUsage( @@ -4765,7 +4765,7 @@ static void D3D12_EndRenderPass( NULL); // Reset bind state - SDL_zeroa(d3d12CommandBuffer->colorAttachmentTextureSubresources); + SDL_zeroa(d3d12CommandBuffer->colorTargetTextureSubresources); d3d12CommandBuffer->depthStencilTextureSubresource = NULL; SDL_zeroa(d3d12CommandBuffer->vertexBuffers); @@ -4788,23 +4788,23 @@ static void D3D12_EndRenderPass( static void D3D12_BeginComputePass( SDL_GPUCommandBuffer *commandBuffer, const SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings, - Uint32 storageTextureBindingCount, + Uint32 numStorageTextureBindings, const SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings, - Uint32 storageBufferBindingCount) + Uint32 numStorageBufferBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - d3d12CommandBuffer->computeWriteOnlyStorageTextureSubresourceCount = storageTextureBindingCount; - d3d12CommandBuffer->computeWriteOnlyStorageBufferCount = storageBufferBindingCount; + d3d12CommandBuffer->computeWriteOnlyStorageTextureSubresourceCount = numStorageTextureBindings; + d3d12CommandBuffer->computeWriteOnlyStorageBufferCount = numStorageBufferBindings; /* Write-only resources will be actually bound in BindComputePipeline * after the root signature is set. * We also have to scan to see which barriers we actually need because depth slices aren't separate subresources */ - if (storageTextureBindingCount > 0) { - for (Uint32 i = 0; i < storageTextureBindingCount; i += 1) { + if (numStorageTextureBindings > 0) { + for (Uint32 i = 0; i < numStorageTextureBindings; i += 1) { D3D12TextureContainer *container = (D3D12TextureContainer *)storageTextureBindings[i].texture; - if (!(container->header.info.usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE)) { + if (!(container->header.info.usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE)) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Attempted to bind read-only texture as compute write texture"); } @@ -4812,7 +4812,7 @@ static void D3D12_BeginComputePass( d3d12CommandBuffer, container, storageTextureBindings[i].layer, - storageTextureBindings[i].mipLevel, + storageTextureBindings[i].mip_level, storageTextureBindings[i].cycle, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); @@ -4824,10 +4824,10 @@ static void D3D12_BeginComputePass( } } - if (storageBufferBindingCount > 0) { - for (Uint32 i = 0; i < storageBufferBindingCount; i += 1) { + if (numStorageBufferBindings > 0) { + for (Uint32 i = 0; i < numStorageBufferBindings; i += 1) { D3D12BufferContainer *container = (D3D12BufferContainer *)storageBufferBindings[i].buffer; - if (!(container->usageFlags & SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE)) { + if (!(container->usage & SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE)) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Attempted to bind read-only texture as compute write texture"); } D3D12Buffer *buffer = D3D12_INTERNAL_PrepareBufferForWrite( @@ -4871,7 +4871,7 @@ static void D3D12_BindComputePipeline( d3d12CommandBuffer->needComputeUniformBufferBind[i] = true; } - for (Uint32 i = 0; i < pipeline->uniformBufferCount; i += 1) { + for (Uint32 i = 0; i < pipeline->numUniformBuffers; i += 1) { if (d3d12CommandBuffer->computeUniformBuffers[i] == NULL) { d3d12CommandBuffer->computeUniformBuffers[i] = D3D12_INTERNAL_AcquireUniformBufferFromPool( d3d12CommandBuffer); @@ -4881,8 +4881,8 @@ static void D3D12_BindComputePipeline( D3D12_INTERNAL_TrackComputePipeline(d3d12CommandBuffer, pipeline); // Bind write-only resources after setting root signature - if (pipeline->writeOnlyStorageTextureCount > 0) { - for (Uint32 i = 0; i < pipeline->writeOnlyStorageTextureCount; i += 1) { + if (pipeline->num_writeonly_storage_textures > 0) { + for (Uint32 i = 0; i < pipeline->num_writeonly_storage_textures; i += 1) { cpuHandles[i] = d3d12CommandBuffer->computeWriteOnlyStorageTextureSubresources[i]->uavHandle.cpuHandle; } @@ -4899,8 +4899,8 @@ static void D3D12_BindComputePipeline( gpuDescriptorHandle); } - if (pipeline->writeOnlyStorageBufferCount > 0) { - for (Uint32 i = 0; i < pipeline->writeOnlyStorageBufferCount; i += 1) { + if (pipeline->num_writeonly_storage_buffers > 0) { + for (Uint32 i = 0; i < pipeline->num_writeonly_storage_buffers; i += 1) { cpuHandles[i] = d3d12CommandBuffer->computeWriteOnlyStorageBuffers[i]->uavDescriptor.cpuHandle; } @@ -4922,11 +4922,11 @@ static void D3D12_BindComputeStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { if (d3d12CommandBuffer->computeReadOnlyStorageTextures[firstSlot + i] != NULL) { D3D12_INTERNAL_TextureTransitionToDefaultUsage( d3d12CommandBuffer, @@ -4954,11 +4954,11 @@ static void D3D12_BindComputeStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { if (d3d12CommandBuffer->computeReadOnlyStorageBuffers[firstSlot + i] != NULL) { D3D12_INTERNAL_BufferTransitionToDefaultUsage( d3d12CommandBuffer, @@ -4988,7 +4988,7 @@ static void D3D12_PushComputeUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; @@ -4997,7 +4997,7 @@ static void D3D12_PushComputeUniformData( SDL_GPU_SHADERSTAGE_COMPUTE, slotIndex, data, - dataLengthInBytes); + length); } static void D3D12_INTERNAL_BindComputeResources( @@ -5009,8 +5009,8 @@ static void D3D12_INTERNAL_BindComputeResources( D3D12_GPU_DESCRIPTOR_HANDLE gpuDescriptorHandle; if (commandBuffer->needComputeReadOnlyStorageTextureBind) { - if (computePipeline->readOnlyStorageTextureCount > 0) { - for (Uint32 i = 0; i < computePipeline->readOnlyStorageTextureCount; i += 1) { + if (computePipeline->num_readonly_storage_textures > 0) { + for (Uint32 i = 0; i < computePipeline->num_readonly_storage_textures; i += 1) { cpuHandles[i] = commandBuffer->computeReadOnlyStorageTextures[i]->srvHandle.cpuHandle; } @@ -5018,7 +5018,7 @@ static void D3D12_INTERNAL_BindComputeResources( commandBuffer, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, cpuHandles, - computePipeline->readOnlyStorageTextureCount, + computePipeline->num_readonly_storage_textures, &gpuDescriptorHandle); ID3D12GraphicsCommandList_SetComputeRootDescriptorTable( @@ -5030,8 +5030,8 @@ static void D3D12_INTERNAL_BindComputeResources( } if (commandBuffer->needComputeReadOnlyStorageBufferBind) { - if (computePipeline->readOnlyStorageBufferCount > 0) { - for (Uint32 i = 0; i < computePipeline->readOnlyStorageBufferCount; i += 1) { + if (computePipeline->num_readonly_storage_buffers > 0) { + for (Uint32 i = 0; i < computePipeline->num_readonly_storage_buffers; i += 1) { cpuHandles[i] = commandBuffer->computeReadOnlyStorageBuffers[i]->srvDescriptor.cpuHandle; } @@ -5039,7 +5039,7 @@ static void D3D12_INTERNAL_BindComputeResources( commandBuffer, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, cpuHandles, - computePipeline->readOnlyStorageBufferCount, + computePipeline->num_readonly_storage_buffers, &gpuDescriptorHandle); ID3D12GraphicsCommandList_SetComputeRootDescriptorTable( @@ -5052,7 +5052,7 @@ static void D3D12_INTERNAL_BindComputeResources( for (Uint32 i = 0; i < MAX_UNIFORM_BUFFERS_PER_STAGE; i += 1) { if (commandBuffer->needComputeUniformBufferBind[i]) { - if (computePipeline->uniformBufferCount > i) { + if (computePipeline->numUniformBuffers > i) { ID3D12GraphicsCommandList_SetComputeRootConstantBufferView( commandBuffer->graphicsCommandList, computePipeline->rootSignature->uniformBufferRootIndex[i], @@ -5065,24 +5065,24 @@ static void D3D12_INTERNAL_BindComputeResources( static void D3D12_DispatchCompute( SDL_GPUCommandBuffer *commandBuffer, - Uint32 groupCountX, - Uint32 groupCountY, - Uint32 groupCountZ) + Uint32 groupcountX, + Uint32 groupcountY, + Uint32 groupcountZ) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; D3D12_INTERNAL_BindComputeResources(d3d12CommandBuffer); ID3D12GraphicsCommandList_Dispatch( d3d12CommandBuffer->graphicsCommandList, - groupCountX, - groupCountY, - groupCountZ); + groupcountX, + groupcountY, + groupcountZ); } static void D3D12_DispatchComputeIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes) + Uint32 offset) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; D3D12Buffer *d3d12Buffer = ((D3D12BufferContainer *)buffer)->activeBuffer; @@ -5093,7 +5093,7 @@ static void D3D12_DispatchComputeIndirect( d3d12CommandBuffer->renderer->indirectDispatchCommandSignature, 1, d3d12Buffer->handle, - offsetInBytes, + offset, NULL, 0); } @@ -5217,14 +5217,14 @@ static void D3D12_UploadToTexture( bool cycle) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - D3D12BufferContainer *transferBufferContainer = (D3D12BufferContainer *)source->transferBuffer; + D3D12BufferContainer *transferBufferContainer = (D3D12BufferContainer *)source->transfer_buffer; D3D12Buffer *temporaryBuffer = NULL; D3D12_TEXTURE_COPY_LOCATION sourceLocation; D3D12_TEXTURE_COPY_LOCATION destinationLocation; - Uint32 pixelsPerRow = source->imagePitch; + Uint32 pixelsPerRow = source->pixels_per_row; Uint32 rowPitch; Uint32 alignedRowPitch; - Uint32 rowsPerSlice = source->imageHeight; + Uint32 rowsPerSlice = source->rows_per_layer; Uint32 bytesPerSlice; bool needsRealignment; bool needsPlacementCopy; @@ -5236,7 +5236,7 @@ static void D3D12_UploadToTexture( d3d12CommandBuffer, textureContainer, destination->layer, - destination->mipLevel, + destination->mip_level, cycle, D3D12_RESOURCE_STATE_COPY_DEST); @@ -5393,7 +5393,7 @@ static void D3D12_UploadToBuffer( bool cycle) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; - D3D12BufferContainer *transferBufferContainer = (D3D12BufferContainer *)source->transferBuffer; + D3D12BufferContainer *transferBufferContainer = (D3D12BufferContainer *)source->transfer_buffer; D3D12BufferContainer *bufferContainer = (D3D12BufferContainer *)destination->buffer; // The transfer buffer does not need a barrier, it is synced by the client. @@ -5437,13 +5437,13 @@ static void D3D12_CopyTextureToTexture( D3D12TextureSubresource *sourceSubresource = D3D12_INTERNAL_FetchTextureSubresource( (D3D12TextureContainer *)source->texture, source->layer, - source->mipLevel); + source->mip_level); D3D12TextureSubresource *destinationSubresource = D3D12_INTERNAL_PrepareTextureSubresourceForWrite( d3d12CommandBuffer, (D3D12TextureContainer *)destination->texture, destination->layer, - destination->mipLevel, + destination->mip_level, cycle, D3D12_RESOURCE_STATE_COPY_DEST); @@ -5543,10 +5543,10 @@ static void D3D12_DownloadFromTexture( D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; D3D12_TEXTURE_COPY_LOCATION sourceLocation; D3D12_TEXTURE_COPY_LOCATION destinationLocation; - Uint32 pixelsPerRow = destination->imagePitch; + Uint32 pixelsPerRow = destination->pixels_per_row; Uint32 rowPitch; Uint32 alignedRowPitch; - Uint32 rowsPerSlice = destination->imageHeight; + Uint32 rowsPerSlice = destination->rows_per_layer; bool needsRealignment; bool needsPlacementCopy; D3D12TextureDownload *textureDownload = NULL; @@ -5554,8 +5554,8 @@ static void D3D12_DownloadFromTexture( D3D12TextureSubresource *sourceSubresource = D3D12_INTERNAL_FetchTextureSubresource( sourceContainer, source->layer, - source->mipLevel); - D3D12BufferContainer *destinationContainer = (D3D12BufferContainer *)destination->transferBuffer; + source->mip_level); + D3D12BufferContainer *destinationContainer = (D3D12BufferContainer *)destination->transfer_buffer; D3D12Buffer *destinationBuffer = destinationContainer->activeBuffer; /* D3D12 requires texture data row pitch to be 256 byte aligned, which is obviously insane. @@ -5681,7 +5681,7 @@ static void D3D12_DownloadFromBuffer( { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; D3D12BufferContainer *sourceContainer = (D3D12BufferContainer *)source->buffer; - D3D12BufferContainer *destinationContainer = (D3D12BufferContainer *)destination->transferBuffer; + D3D12BufferContainer *destinationContainer = (D3D12BufferContainer *)destination->transfer_buffer; D3D12Buffer *sourceBuffer = sourceContainer->activeBuffer; D3D12_INTERNAL_BufferTransitionFromDefaultUsage( @@ -5744,20 +5744,20 @@ static void D3D12_GenerateMipmaps( } // We have to do this one subresource at a time - for (Uint32 layerOrDepthIndex = 0; layerOrDepthIndex < container->header.info.layerCountOrDepth; layerOrDepthIndex += 1) { - for (Uint32 levelIndex = 1; levelIndex < container->header.info.levelCount; levelIndex += 1) { + for (Uint32 layerOrDepthIndex = 0; layerOrDepthIndex < container->header.info.layer_count_or_depth; layerOrDepthIndex += 1) { + for (Uint32 levelIndex = 1; levelIndex < container->header.info.num_levels; levelIndex += 1) { srcRegion.texture = texture; - srcRegion.mipLevel = levelIndex - 1; - srcRegion.layerOrDepthPlane = layerOrDepthIndex; + srcRegion.mip_level = levelIndex - 1; + srcRegion.layer_or_depth_plane = layerOrDepthIndex; srcRegion.x = 0; srcRegion.y = 0; srcRegion.w = container->header.info.width >> (levelIndex - 1); srcRegion.h = container->header.info.height >> (levelIndex - 1); dstRegion.texture = texture; - dstRegion.mipLevel = levelIndex; - dstRegion.layerOrDepthPlane = layerOrDepthIndex; + dstRegion.mip_level = levelIndex; + dstRegion.layer_or_depth_plane = layerOrDepthIndex; dstRegion.x = 0; dstRegion.y = 0; dstRegion.w = container->header.info.width >> levelIndex; @@ -5781,7 +5781,7 @@ static void D3D12_Blit( const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_GPUFilter filter, bool cycle) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; @@ -5792,7 +5792,7 @@ static void D3D12_Blit( source, destination, flipMode, - filterMode, + filter, cycle, renderer->blitLinearSampler, renderer->blitNearestSampler, @@ -5822,8 +5822,8 @@ static bool D3D12_SupportsSwapchainComposition( { #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) // FIXME: HDR support would be nice to add, but it seems complicated... - return swapchainComposition == SDL_GPU_SWAPCHAINCOMPOSITION_SDR || - swapchainComposition == SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR; + return swapchain_composition == SDL_GPU_SWAPCHAINCOMPOSITION_SDR || + swapchain_composition == SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR; #else D3D12Renderer *renderer = (D3D12Renderer *)driverData; DXGI_FORMAT format; @@ -5898,8 +5898,8 @@ static bool D3D12_SupportsPresentMode( static bool D3D12_INTERNAL_CreateSwapchain( D3D12Renderer *renderer, D3D12WindowData *windowData, - SDL_GPUSwapchainComposition swapchainComposition, - SDL_GPUPresentMode presentMode) + SDL_GPUSwapchainComposition swapchain_composition, + SDL_GPUPresentMode present_mode) { int width, height; SDL_GPUTextureCreateInfo createInfo; @@ -5913,10 +5913,10 @@ static bool D3D12_INTERNAL_CreateSwapchain( createInfo.type = SDL_GPU_TEXTURETYPE_2D; createInfo.width = width; createInfo.height = height; - createInfo.format = SwapchainCompositionToSDLTextureFormat[swapchainComposition]; - createInfo.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; - createInfo.layerCountOrDepth = 1; - createInfo.levelCount = 1; + createInfo.format = SwapchainCompositionToSDLTextureFormat[swapchain_composition]; + createInfo.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; + createInfo.layer_count_or_depth = 1; + createInfo.num_levels = 1; for (Uint32 i = 0; i < MAX_FRAMES_IN_FLIGHT; i += 1) { texture = D3D12_INTERNAL_CreateTexture(renderer, &createInfo, true); @@ -5930,8 +5930,8 @@ static bool D3D12_INTERNAL_CreateSwapchain( } // Initialize the swapchain data - windowData->presentMode = presentMode; - windowData->swapchainComposition = swapchainComposition; + windowData->present_mode = present_mode; + windowData->swapchain_composition = swapchain_composition; windowData->swapchainColorSpace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; windowData->frameCounter = 0; windowData->swapchainWidth = width; @@ -5993,8 +5993,8 @@ static bool D3D12_INTERNAL_ResizeSwapchainIfNeeded( D3D12_INTERNAL_CreateSwapchain( renderer, windowData, - windowData->swapchainComposition, - windowData->presentMode); + windowData->swapchain_composition, + windowData->present_mode); } return true; @@ -6048,11 +6048,11 @@ static bool D3D12_INTERNAL_InitializeSwapchainTexture( ID3D12Resource_GetDesc(swapchainTexture, &textureDesc); pTextureContainer->header.info.width = (Uint32)textureDesc.Width; pTextureContainer->header.info.height = (Uint32)textureDesc.Height; - pTextureContainer->header.info.layerCountOrDepth = 1; - pTextureContainer->header.info.levelCount = 1; + pTextureContainer->header.info.layer_count_or_depth = 1; + pTextureContainer->header.info.num_levels = 1; pTextureContainer->header.info.type = SDL_GPU_TEXTURETYPE_2D; - pTextureContainer->header.info.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; - pTextureContainer->header.info.sampleCount = SDL_GPU_SAMPLECOUNT_1; + pTextureContainer->header.info.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; + pTextureContainer->header.info.sample_count = SDL_GPU_SAMPLECOUNT_1; pTextureContainer->header.info.format = SwapchainCompositionToSDLTextureFormat[composition]; pTextureContainer->debugName = NULL; @@ -6312,7 +6312,7 @@ static bool D3D12_INTERNAL_CreateSwapchain( // Initialize the swapchain data windowData->swapchain = swapchain3; - windowData->presentMode = presentMode; + windowData->present_mode = presentMode; windowData->swapchainComposition = swapchainComposition; windowData->swapchainColorSpace = SwapchainCompositionToColorSpace[swapchainComposition]; windowData->frameCounter = 0; @@ -6459,7 +6459,7 @@ static bool D3D12_SetSwapchainParameters( if ( swapchainComposition != windowData->swapchainComposition || - presentMode != windowData->presentMode) { + presentMode != windowData->present_mode) { D3D12_Wait(driverData); // Recreate the swapchain @@ -6714,8 +6714,8 @@ static SDL_GPUCommandBuffer *D3D12_AcquireCommandBuffer( // Set the bind state commandBuffer->currentGraphicsPipeline = NULL; - SDL_zeroa(commandBuffer->colorAttachmentTextureSubresources); - commandBuffer->colorAttachmentTextureSubresourceCount = 0; + SDL_zeroa(commandBuffer->colorTargetTextureSubresources); + commandBuffer->colorTargetTextureSubresourceCount = 0; commandBuffer->depthStencilTextureSubresource = NULL; SDL_zeroa(commandBuffer->vertexBuffers); @@ -6748,8 +6748,8 @@ static SDL_GPUCommandBuffer *D3D12_AcquireCommandBuffer( static SDL_GPUTexture *D3D12_AcquireSwapchainTexture( SDL_GPUCommandBuffer *commandBuffer, SDL_Window *window, - Uint32 *pWidth, - Uint32 *pHeight) + Uint32 *w, + Uint32 *h) { D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer; D3D12Renderer *renderer = d3d12CommandBuffer->renderer; @@ -6768,7 +6768,7 @@ static SDL_GPUTexture *D3D12_AcquireSwapchainTexture( ERROR_CHECK_RETURN("Could not resize swapchain", NULL); if (windowData->inFlightFences[windowData->frameCounter] != NULL) { - if (windowData->presentMode == SDL_GPU_PRESENTMODE_VSYNC) { + if (windowData->present_mode == SDL_GPU_PRESENTMODE_VSYNC) { // In VSYNC mode, block until the least recent presented frame is done D3D12_WaitForFences( (SDL_GPURenderer *)renderer, @@ -6812,8 +6812,8 @@ static SDL_GPUTexture *D3D12_AcquireSwapchainTexture( #endif // Send the dimensions to the out parameters. - *pWidth = windowData->textureContainers[swapchainIndex].header.info.width; - *pHeight = windowData->textureContainers[swapchainIndex].header.info.height; + *w = windowData->textureContainers[swapchainIndex].header.info.width; + *h = windowData->textureContainers[swapchainIndex].header.info.height; // Set up presentation if (d3d12CommandBuffer->presentDataCount == d3d12CommandBuffer->presentDataCapacity) { @@ -7171,20 +7171,20 @@ static void D3D12_Submit( D3D12XBOX_PRESENT_PARAMETERS presentParams; SDL_zero(presentParams); - presentParams.Flags = (windowData->presentMode == SDL_GPU_PRESENTMODE_IMMEDIATE) ? D3D12XBOX_PRESENT_FLAG_IMMEDIATE : D3D12XBOX_PRESENT_FLAG_NONE; + presentParams.Flags = (windowData->present_mode == SDL_GPU_PRESENTMODE_IMMEDIATE) ? D3D12XBOX_PRESENT_FLAG_IMMEDIATE : D3D12XBOX_PRESENT_FLAG_NONE; renderer->commandQueue->PresentX(1, &planeParams, &presentParams); #else // NOTE: flip discard always supported since DXGI 1.4 is required Uint32 syncInterval = 1; - if (windowData->presentMode == SDL_GPU_PRESENTMODE_IMMEDIATE || - windowData->presentMode == SDL_GPU_PRESENTMODE_MAILBOX) { + if (windowData->present_mode == SDL_GPU_PRESENTMODE_IMMEDIATE || + windowData->present_mode == SDL_GPU_PRESENTMODE_MAILBOX) { syncInterval = 0; } Uint32 presentFlags = 0; if (renderer->supportsTearing && - windowData->presentMode == SDL_GPU_PRESENTMODE_IMMEDIATE) { + windowData->present_mode == SDL_GPU_PRESENTMODE_IMMEDIATE) { presentFlags = DXGI_PRESENT_ALLOW_TEARING; } @@ -7276,18 +7276,18 @@ static void D3D12_Wait( static void D3D12_WaitForFences( SDL_GPURenderer *driverData, bool waitAll, - SDL_GPUFence *const *pFences, - Uint32 fenceCount) + SDL_GPUFence *const *fences, + Uint32 numFences) { D3D12Renderer *renderer = (D3D12Renderer *)driverData; D3D12Fence *fence; - HANDLE *events = SDL_stack_alloc(HANDLE, fenceCount); + HANDLE *events = SDL_stack_alloc(HANDLE, numFences); HRESULT res; SDL_LockMutex(renderer->submitLock); - for (Uint32 i = 0; i < fenceCount; i += 1) { - fence = (D3D12Fence *)pFences[i]; + for (Uint32 i = 0; i < numFences; i += 1) { + fence = (D3D12Fence *)fences[i]; res = ID3D12Fence_SetEventOnCompletion( fence->handle, @@ -7299,7 +7299,7 @@ static void D3D12_WaitForFences( } WaitForMultipleObjects( - fenceCount, + numFences, events, waitAll, INFINITE); @@ -7419,10 +7419,10 @@ static void D3D12_INTERNAL_InitBlitResources( // Fullscreen vertex shader SDL_zero(shaderCreateInfo); shaderCreateInfo.code = (Uint8 *)D3D12_FullscreenVert; - shaderCreateInfo.codeSize = sizeof(D3D12_FullscreenVert); + shaderCreateInfo.code_size = sizeof(D3D12_FullscreenVert); shaderCreateInfo.stage = SDL_GPU_SHADERSTAGE_VERTEX; shaderCreateInfo.format = SDL_GPU_SHADERFORMAT_DXBC; - shaderCreateInfo.entryPointName = "main"; + shaderCreateInfo.entrypoint = "main"; renderer->blitVertexShader = D3D12_CreateShader( (SDL_GPURenderer *)renderer, @@ -7434,10 +7434,10 @@ static void D3D12_INTERNAL_InitBlitResources( // BlitFrom2D pixel shader shaderCreateInfo.code = (Uint8 *)D3D12_BlitFrom2D; - shaderCreateInfo.codeSize = sizeof(D3D12_BlitFrom2D); + shaderCreateInfo.code_size = sizeof(D3D12_BlitFrom2D); shaderCreateInfo.stage = SDL_GPU_SHADERSTAGE_FRAGMENT; - shaderCreateInfo.samplerCount = 1; - shaderCreateInfo.uniformBufferCount = 1; + shaderCreateInfo.num_samplers = 1; + shaderCreateInfo.num_uniform_buffers = 1; renderer->blitFrom2DShader = D3D12_CreateShader( (SDL_GPURenderer *)renderer, @@ -7449,7 +7449,7 @@ static void D3D12_INTERNAL_InitBlitResources( // BlitFrom2DArray pixel shader shaderCreateInfo.code = (Uint8 *)D3D12_BlitFrom2DArray; - shaderCreateInfo.codeSize = sizeof(D3D12_BlitFrom2DArray); + shaderCreateInfo.code_size = sizeof(D3D12_BlitFrom2DArray); renderer->blitFrom2DArrayShader = D3D12_CreateShader( (SDL_GPURenderer *)renderer, @@ -7461,7 +7461,7 @@ static void D3D12_INTERNAL_InitBlitResources( // BlitFrom3D pixel shader shaderCreateInfo.code = (Uint8 *)D3D12_BlitFrom3D; - shaderCreateInfo.codeSize = sizeof(D3D12_BlitFrom3D); + shaderCreateInfo.code_size = sizeof(D3D12_BlitFrom3D); renderer->blitFrom3DShader = D3D12_CreateShader( (SDL_GPURenderer *)renderer, @@ -7473,7 +7473,7 @@ static void D3D12_INTERNAL_InitBlitResources( // BlitFromCube pixel shader shaderCreateInfo.code = (Uint8 *)D3D12_BlitFromCube; - shaderCreateInfo.codeSize = sizeof(D3D12_BlitFromCube); + shaderCreateInfo.code_size = sizeof(D3D12_BlitFromCube); renderer->blitFromCubeShader = D3D12_CreateShader( (SDL_GPURenderer *)renderer, @@ -7484,19 +7484,19 @@ static void D3D12_INTERNAL_InitBlitResources( } // Create samplers - samplerCreateInfo.addressModeU = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.addressModeV = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.addressModeW = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.anisotropyEnable = 0; - samplerCreateInfo.compareEnable = 0; - samplerCreateInfo.magFilter = SDL_GPU_FILTER_NEAREST; - samplerCreateInfo.minFilter = SDL_GPU_FILTER_NEAREST; - samplerCreateInfo.mipmapMode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST; - samplerCreateInfo.mipLodBias = 0.0f; - samplerCreateInfo.minLod = 0; - samplerCreateInfo.maxLod = 1000; - samplerCreateInfo.maxAnisotropy = 1.0f; - samplerCreateInfo.compareOp = SDL_GPU_COMPAREOP_ALWAYS; + samplerCreateInfo.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + samplerCreateInfo.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + samplerCreateInfo.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + samplerCreateInfo.enable_anisotropy = 0; + samplerCreateInfo.enable_compare = 0; + samplerCreateInfo.mag_filter = SDL_GPU_FILTER_NEAREST; + samplerCreateInfo.min_filter = SDL_GPU_FILTER_NEAREST; + samplerCreateInfo.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST; + samplerCreateInfo.mip_lod_bias = 0.0f; + samplerCreateInfo.min_lod = 0; + samplerCreateInfo.max_lod = 1000; + samplerCreateInfo.max_anisotropy = 1.0f; + samplerCreateInfo.compare_op = SDL_GPU_COMPAREOP_ALWAYS; renderer->blitNearestSampler = D3D12_CreateSampler( (SDL_GPURenderer *)renderer, @@ -7506,9 +7506,9 @@ static void D3D12_INTERNAL_InitBlitResources( SDL_LogError(SDL_LOG_CATEGORY_GPU, "Failed to create blit nearest sampler!"); } - samplerCreateInfo.magFilter = SDL_GPU_FILTER_LINEAR; - samplerCreateInfo.minFilter = SDL_GPU_FILTER_LINEAR; - samplerCreateInfo.mipmapMode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR; + samplerCreateInfo.mag_filter = SDL_GPU_FILTER_LINEAR; + samplerCreateInfo.min_filter = SDL_GPU_FILTER_LINEAR; + samplerCreateInfo.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR; renderer->blitLinearSampler = D3D12_CreateSampler( (SDL_GPURenderer *)renderer, @@ -7519,13 +7519,13 @@ static void D3D12_INTERNAL_InitBlitResources( } } -static bool D3D12_PrepareDriver(SDL_VideoDevice *_this) +static bool D3D12_PrepareDriver(SDL_VideoDevice *this) { #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) return true; #else - void *d3d12_dll; - void *dxgi_dll; + void *d3d12Dll; + void *dxgiDll; PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc; PFN_CREATE_DXGI_FACTORY1 CreateDXGIFactoryFunc; HRESULT res; @@ -7537,35 +7537,35 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this) // Can we load D3D12? - d3d12_dll = SDL_LoadObject(D3D12_DLL); - if (d3d12_dll == NULL) { + d3d12Dll = SDL_LoadObject(D3D12_DLL); + if (d3d12Dll == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D12: Could not find " D3D12_DLL); return false; } D3D12CreateDeviceFunc = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction( - d3d12_dll, + d3d12Dll, D3D12_CREATE_DEVICE_FUNC); if (D3D12CreateDeviceFunc == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D12: Could not find function " D3D12_CREATE_DEVICE_FUNC " in " D3D12_DLL); - SDL_UnloadObject(d3d12_dll); + SDL_UnloadObject(d3d12Dll); return false; } // Can we load DXGI? - dxgi_dll = SDL_LoadObject(DXGI_DLL); - if (dxgi_dll == NULL) { + dxgiDll = SDL_LoadObject(DXGI_DLL); + if (dxgiDll == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D12: Could not find " DXGI_DLL); return false; } CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY1)SDL_LoadFunction( - dxgi_dll, + dxgiDll, CREATE_DXGI_FACTORY1_FUNC); if (CreateDXGIFactoryFunc == NULL) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D12: Could not find function " CREATE_DXGI_FACTORY1_FUNC " in " DXGI_DLL); - SDL_UnloadObject(dxgi_dll); + SDL_UnloadObject(dxgiDll); return false; } @@ -7577,8 +7577,8 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this) (void **)&factory); if (FAILED(res)) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D12: Could not create DXGIFactory"); - SDL_UnloadObject(d3d12_dll); - SDL_UnloadObject(dxgi_dll); + SDL_UnloadObject(d3d12Dll); + SDL_UnloadObject(dxgiDll); return false; } @@ -7590,8 +7590,8 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this) if (FAILED(res)) { IDXGIFactory1_Release(factory); SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D12: Failed to find DXGI1.4 support, required for DX12"); - SDL_UnloadObject(d3d12_dll); - SDL_UnloadObject(dxgi_dll); + SDL_UnloadObject(d3d12Dll); + SDL_UnloadObject(dxgiDll); return false; } IDXGIFactory4_Release(factory4); @@ -7617,8 +7617,8 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this) if (FAILED(res)) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D12: Failed to find adapter for D3D12Device"); IDXGIFactory1_Release(factory); - SDL_UnloadObject(d3d12_dll); - SDL_UnloadObject(dxgi_dll); + SDL_UnloadObject(d3d12Dll); + SDL_UnloadObject(dxgiDll); return false; } @@ -7634,8 +7634,8 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this) IDXGIAdapter1_Release(adapter); IDXGIFactory1_Release(factory); - SDL_UnloadObject(d3d12_dll); - SDL_UnloadObject(dxgi_dll); + SDL_UnloadObject(d3d12Dll); + SDL_UnloadObject(dxgiDll); if (FAILED(res)) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "D3D12: Could not create D3D12Device with feature level " D3D_FEATURE_LEVEL_CHOICE_STR); @@ -7916,7 +7916,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD #if defined(SDL_PLATFORM_XBOXSERIES) createDeviceParams.DisableDXR = TRUE; #endif - if (debugMode) { + if (debug_mode) { createDeviceParams.ProcessDebugFlags = D3D12XBOX_PROCESS_DEBUG_FLAG_DEBUG; } @@ -8200,7 +8200,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD renderer->fenceLock = SDL_CreateMutex(); renderer->disposeLock = SDL_CreateMutex(); - renderer->debugMode = debugMode; + renderer->debug_mode = debugMode; renderer->semantic = SDL_GetStringProperty(props, SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING, "TEXCOORD"); @@ -8217,7 +8217,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD ASSIGN_DRIVER(D3D12) result->driverData = (SDL_GPURenderer *)renderer; - result->debugMode = debugMode; + result->debug_mode = debugMode; renderer->sdlGPUDevice = result; return result; diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m index 8bcc1f68a0..f9e9986bc6 100644 --- a/src/gpu/metal/SDL_gpu_metal.m +++ b/src/gpu/metal/SDL_gpu_metal.m @@ -392,22 +392,22 @@ typedef struct MetalShader id library; id function; - Uint32 samplerCount; - Uint32 uniformBufferCount; - Uint32 storageBufferCount; - Uint32 storageTextureCount; + Uint32 num_samplers; + Uint32 numUniformBuffers; + Uint32 numStorageBuffers; + Uint32 numStorageTextures; } MetalShader; typedef struct MetalGraphicsPipeline { id handle; - Uint32 sampleMask; + Uint32 sample_mask; SDL_GPURasterizerState rasterizerState; SDL_GPUPrimitiveType primitiveType; - id depthStencilState; + id depth_stencil_state; Uint32 vertexSamplerCount; Uint32 vertexUniformBufferCount; @@ -423,14 +423,14 @@ typedef struct MetalGraphicsPipeline typedef struct MetalComputePipeline { id handle; - Uint32 readOnlyStorageTextureCount; - Uint32 writeOnlyStorageTextureCount; - Uint32 readOnlyStorageBufferCount; - Uint32 writeOnlyStorageBufferCount; - Uint32 uniformBufferCount; - Uint32 threadCountX; - Uint32 threadCountY; - Uint32 threadCountZ; + Uint32 num_readonly_storage_textures; + Uint32 num_writeonly_storage_textures; + Uint32 num_readonly_storage_buffers; + Uint32 num_writeonly_storage_buffers; + Uint32 numUniformBuffers; + Uint32 threadcount_x; + Uint32 threadcount_y; + Uint32 threadcount_z; } MetalComputePipeline; typedef struct MetalBuffer @@ -477,17 +477,17 @@ typedef struct MetalCommandBuffer // Render Pass id renderEncoder; - MetalGraphicsPipeline *graphicsPipeline; + MetalGraphicsPipeline *graphics_pipeline; MetalBuffer *indexBuffer; Uint32 indexBufferOffset; - SDL_GPUIndexElementSize indexElementSize; + SDL_GPUIndexElementSize index_element_size; // Copy Pass id blitEncoder; // Compute Pass id computeEncoder; - MetalComputePipeline *computePipeline; + MetalComputePipeline *compute_pipeline; // Resource slot state bool needVertexSamplerBind; @@ -561,7 +561,7 @@ struct MetalRenderer id device; id queue; - bool debugMode; + bool debug_mode; MetalWindowData **claimedWindows; Uint32 claimedWindowCount; @@ -754,7 +754,7 @@ static MetalLibraryFunction METAL_INTERNAL_CompileShader( SDL_GPUShaderFormat format, const Uint8 *code, size_t codeSize, - const char *entryPointName) + const char *entrypoint) { MetalLibraryFunction libraryFunction = { nil, nil }; id library; @@ -796,7 +796,7 @@ static MetalLibraryFunction METAL_INTERNAL_CompileShader( [[error description] cStringUsingEncoding:[NSString defaultCStringEncoding]]); } - function = [library newFunctionWithName:@(entryPointName)]; + function = [library newFunctionWithName:@(entrypoint)]; if (function == nil) { SDL_LogError( SDL_LOG_CATEGORY_GPU, @@ -934,7 +934,7 @@ static void METAL_ReleaseGraphicsPipeline( @autoreleasepool { MetalGraphicsPipeline *metalGraphicsPipeline = (MetalGraphicsPipeline *)graphicsPipeline; metalGraphicsPipeline->handle = nil; - metalGraphicsPipeline->depthStencilState = nil; + metalGraphicsPipeline->depth_stencil_state = nil; SDL_free(metalGraphicsPipeline); } } @@ -943,7 +943,7 @@ static void METAL_ReleaseGraphicsPipeline( static SDL_GPUComputePipeline *METAL_CreateComputePipeline( SDL_GPURenderer *driverData, - const SDL_GPUComputePipelineCreateInfo *pipelineCreateInfo) + const SDL_GPUComputePipelineCreateInfo *createinfo) { @autoreleasepool { MetalRenderer *renderer = (MetalRenderer *)driverData; @@ -954,10 +954,10 @@ static SDL_GPUComputePipeline *METAL_CreateComputePipeline( libraryFunction = METAL_INTERNAL_CompileShader( renderer, - pipelineCreateInfo->format, - pipelineCreateInfo->code, - pipelineCreateInfo->codeSize, - pipelineCreateInfo->entryPointName); + createinfo->format, + createinfo->code, + createinfo->code_size, + createinfo->entrypoint); if (libraryFunction.library == nil || libraryFunction.function == nil) { return NULL; @@ -973,14 +973,14 @@ static SDL_GPUComputePipeline *METAL_CreateComputePipeline( pipeline = SDL_calloc(1, sizeof(MetalComputePipeline)); pipeline->handle = handle; - pipeline->readOnlyStorageTextureCount = pipelineCreateInfo->readOnlyStorageTextureCount; - pipeline->writeOnlyStorageTextureCount = pipelineCreateInfo->writeOnlyStorageTextureCount; - pipeline->readOnlyStorageBufferCount = pipelineCreateInfo->readOnlyStorageBufferCount; - pipeline->writeOnlyStorageBufferCount = pipelineCreateInfo->writeOnlyStorageBufferCount; - pipeline->uniformBufferCount = pipelineCreateInfo->uniformBufferCount; - pipeline->threadCountX = pipelineCreateInfo->threadCountX; - pipeline->threadCountY = pipelineCreateInfo->threadCountY; - pipeline->threadCountZ = pipelineCreateInfo->threadCountZ; + pipeline->num_readonly_storage_textures = createinfo->num_readonly_storage_textures; + pipeline->num_writeonly_storage_textures = createinfo->num_writeonly_storage_textures; + pipeline->num_readonly_storage_buffers = createinfo->num_readonly_storage_buffers; + pipeline->num_writeonly_storage_buffers = createinfo->num_writeonly_storage_buffers; + pipeline->numUniformBuffers = createinfo->num_uniform_buffers; + pipeline->threadcount_x = createinfo->threadcount_x; + pipeline->threadcount_y = createinfo->threadcount_y; + pipeline->threadcount_z = createinfo->threadcount_z; return (SDL_GPUComputePipeline *)pipeline; } @@ -988,14 +988,14 @@ static SDL_GPUComputePipeline *METAL_CreateComputePipeline( static SDL_GPUGraphicsPipeline *METAL_CreateGraphicsPipeline( SDL_GPURenderer *driverData, - const SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo) + const SDL_GPUGraphicsPipelineCreateInfo *createinfo) { @autoreleasepool { MetalRenderer *renderer = (MetalRenderer *)driverData; - MetalShader *vertexShader = (MetalShader *)pipelineCreateInfo->vertexShader; - MetalShader *fragmentShader = (MetalShader *)pipelineCreateInfo->fragmentShader; + MetalShader *vertexShader = (MetalShader *)createinfo->vertex_shader; + MetalShader *fragmentShader = (MetalShader *)createinfo->fragment_shader; MTLRenderPipelineDescriptor *pipelineDescriptor; - const SDL_GPUColorAttachmentBlendState *blendState; + const SDL_GPUColorTargetBlendState *blendState; MTLVertexDescriptor *vertexDescriptor; Uint32 binding; MTLDepthStencilDescriptor *depthStencilDescriptor; @@ -1010,52 +1010,52 @@ static SDL_GPUGraphicsPipeline *METAL_CreateGraphicsPipeline( // Blend - for (Uint32 i = 0; i < pipelineCreateInfo->attachmentInfo.colorAttachmentCount; i += 1) { - blendState = &pipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions[i].blendState; + for (Uint32 i = 0; i < createinfo->target_info.num_color_targets; i += 1) { + blendState = &createinfo->target_info.color_target_descriptions[i].blend_state; - pipelineDescriptor.colorAttachments[i].pixelFormat = SDLToMetal_SurfaceFormat[pipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions[i].format]; - pipelineDescriptor.colorAttachments[i].writeMask = SDLToMetal_ColorWriteMask(blendState->colorWriteMask); - pipelineDescriptor.colorAttachments[i].blendingEnabled = blendState->blendEnable; - pipelineDescriptor.colorAttachments[i].rgbBlendOperation = SDLToMetal_BlendOp[blendState->colorBlendOp]; - pipelineDescriptor.colorAttachments[i].alphaBlendOperation = SDLToMetal_BlendOp[blendState->alphaBlendOp]; - pipelineDescriptor.colorAttachments[i].sourceRGBBlendFactor = SDLToMetal_BlendFactor[blendState->srcColorBlendFactor]; - pipelineDescriptor.colorAttachments[i].sourceAlphaBlendFactor = SDLToMetal_BlendFactor[blendState->srcAlphaBlendFactor]; - pipelineDescriptor.colorAttachments[i].destinationRGBBlendFactor = SDLToMetal_BlendFactor[blendState->dstColorBlendFactor]; - pipelineDescriptor.colorAttachments[i].destinationAlphaBlendFactor = SDLToMetal_BlendFactor[blendState->dstAlphaBlendFactor]; + pipelineDescriptor.colorAttachments[i].pixelFormat = SDLToMetal_SurfaceFormat[createinfo->target_info.color_target_descriptions[i].format]; + pipelineDescriptor.colorAttachments[i].writeMask = SDLToMetal_ColorWriteMask(blendState->color_write_mask); + pipelineDescriptor.colorAttachments[i].blendingEnabled = blendState->enable_blend; + pipelineDescriptor.colorAttachments[i].rgbBlendOperation = SDLToMetal_BlendOp[blendState->color_blend_op]; + pipelineDescriptor.colorAttachments[i].alphaBlendOperation = SDLToMetal_BlendOp[blendState->alpha_blend_op]; + pipelineDescriptor.colorAttachments[i].sourceRGBBlendFactor = SDLToMetal_BlendFactor[blendState->src_color_blendfactor]; + pipelineDescriptor.colorAttachments[i].sourceAlphaBlendFactor = SDLToMetal_BlendFactor[blendState->src_alpha_blendfactor]; + pipelineDescriptor.colorAttachments[i].destinationRGBBlendFactor = SDLToMetal_BlendFactor[blendState->dst_color_blendfactor]; + pipelineDescriptor.colorAttachments[i].destinationAlphaBlendFactor = SDLToMetal_BlendFactor[blendState->dst_alpha_blendfactor]; } // Multisample - pipelineDescriptor.rasterSampleCount = SDLToMetal_SampleCount[pipelineCreateInfo->multisampleState.sampleCount]; + pipelineDescriptor.rasterSampleCount = SDLToMetal_SampleCount[createinfo->multisample_state.sample_count]; // Depth Stencil - if (pipelineCreateInfo->attachmentInfo.hasDepthStencilAttachment) { - pipelineDescriptor.depthAttachmentPixelFormat = SDLToMetal_SurfaceFormat[pipelineCreateInfo->attachmentInfo.depthStencilFormat]; + if (createinfo->target_info.has_depth_stencil_target) { + pipelineDescriptor.depthAttachmentPixelFormat = SDLToMetal_SurfaceFormat[createinfo->target_info.depth_stencil_format]; - if (pipelineCreateInfo->depthStencilState.stencilTestEnable) { - pipelineDescriptor.stencilAttachmentPixelFormat = SDLToMetal_SurfaceFormat[pipelineCreateInfo->attachmentInfo.depthStencilFormat]; + if (createinfo->depth_stencil_state.enable_stencil_test) { + pipelineDescriptor.stencilAttachmentPixelFormat = SDLToMetal_SurfaceFormat[createinfo->target_info.depth_stencil_format]; frontStencilDescriptor = [MTLStencilDescriptor new]; - frontStencilDescriptor.stencilCompareFunction = SDLToMetal_CompareOp[pipelineCreateInfo->depthStencilState.frontStencilState.compareOp]; - frontStencilDescriptor.stencilFailureOperation = SDLToMetal_StencilOp[pipelineCreateInfo->depthStencilState.frontStencilState.failOp]; - frontStencilDescriptor.depthStencilPassOperation = SDLToMetal_StencilOp[pipelineCreateInfo->depthStencilState.frontStencilState.passOp]; - frontStencilDescriptor.depthFailureOperation = SDLToMetal_StencilOp[pipelineCreateInfo->depthStencilState.frontStencilState.depthFailOp]; - frontStencilDescriptor.readMask = pipelineCreateInfo->depthStencilState.compareMask; - frontStencilDescriptor.writeMask = pipelineCreateInfo->depthStencilState.writeMask; + frontStencilDescriptor.stencilCompareFunction = SDLToMetal_CompareOp[createinfo->depth_stencil_state.front_stencil_state.compare_op]; + frontStencilDescriptor.stencilFailureOperation = SDLToMetal_StencilOp[createinfo->depth_stencil_state.front_stencil_state.fail_op]; + frontStencilDescriptor.depthStencilPassOperation = SDLToMetal_StencilOp[createinfo->depth_stencil_state.front_stencil_state.pass_op]; + frontStencilDescriptor.depthFailureOperation = SDLToMetal_StencilOp[createinfo->depth_stencil_state.front_stencil_state.depth_fail_op]; + frontStencilDescriptor.readMask = createinfo->depth_stencil_state.compare_mask; + frontStencilDescriptor.writeMask = createinfo->depth_stencil_state.write_mask; backStencilDescriptor = [MTLStencilDescriptor new]; - backStencilDescriptor.stencilCompareFunction = SDLToMetal_CompareOp[pipelineCreateInfo->depthStencilState.backStencilState.compareOp]; - backStencilDescriptor.stencilFailureOperation = SDLToMetal_StencilOp[pipelineCreateInfo->depthStencilState.backStencilState.failOp]; - backStencilDescriptor.depthStencilPassOperation = SDLToMetal_StencilOp[pipelineCreateInfo->depthStencilState.backStencilState.passOp]; - backStencilDescriptor.depthFailureOperation = SDLToMetal_StencilOp[pipelineCreateInfo->depthStencilState.backStencilState.depthFailOp]; - backStencilDescriptor.readMask = pipelineCreateInfo->depthStencilState.compareMask; - backStencilDescriptor.writeMask = pipelineCreateInfo->depthStencilState.writeMask; + backStencilDescriptor.stencilCompareFunction = SDLToMetal_CompareOp[createinfo->depth_stencil_state.back_stencil_state.compare_op]; + backStencilDescriptor.stencilFailureOperation = SDLToMetal_StencilOp[createinfo->depth_stencil_state.back_stencil_state.fail_op]; + backStencilDescriptor.depthStencilPassOperation = SDLToMetal_StencilOp[createinfo->depth_stencil_state.back_stencil_state.pass_op]; + backStencilDescriptor.depthFailureOperation = SDLToMetal_StencilOp[createinfo->depth_stencil_state.back_stencil_state.depth_fail_op]; + backStencilDescriptor.readMask = createinfo->depth_stencil_state.compare_mask; + backStencilDescriptor.writeMask = createinfo->depth_stencil_state.write_mask; } depthStencilDescriptor = [MTLDepthStencilDescriptor new]; - depthStencilDescriptor.depthCompareFunction = pipelineCreateInfo->depthStencilState.depthTestEnable ? SDLToMetal_CompareOp[pipelineCreateInfo->depthStencilState.compareOp] : MTLCompareFunctionAlways; - depthStencilDescriptor.depthWriteEnabled = pipelineCreateInfo->depthStencilState.depthWriteEnable; + depthStencilDescriptor.depthCompareFunction = createinfo->depth_stencil_state.enable_depth_test ? SDLToMetal_CompareOp[createinfo->depth_stencil_state.compare_op] : MTLCompareFunctionAlways; + depthStencilDescriptor.depthWriteEnabled = createinfo->depth_stencil_state.enable_depth_write; depthStencilDescriptor.frontFaceStencil = frontStencilDescriptor; depthStencilDescriptor.backFaceStencil = backStencilDescriptor; @@ -1069,21 +1069,21 @@ static SDL_GPUGraphicsPipeline *METAL_CreateGraphicsPipeline( // Vertex Descriptor - if (pipelineCreateInfo->vertexInputState.vertexBindingCount > 0) { + if (createinfo->vertex_input_state.num_vertex_bindings > 0) { vertexDescriptor = [MTLVertexDescriptor vertexDescriptor]; - for (Uint32 i = 0; i < pipelineCreateInfo->vertexInputState.vertexAttributeCount; i += 1) { - Uint32 loc = pipelineCreateInfo->vertexInputState.vertexAttributes[i].location; - vertexDescriptor.attributes[loc].format = SDLToMetal_VertexFormat[pipelineCreateInfo->vertexInputState.vertexAttributes[i].format]; - vertexDescriptor.attributes[loc].offset = pipelineCreateInfo->vertexInputState.vertexAttributes[i].offset; - vertexDescriptor.attributes[loc].bufferIndex = METAL_INTERNAL_GetVertexBufferIndex(pipelineCreateInfo->vertexInputState.vertexAttributes[i].binding); + for (Uint32 i = 0; i < createinfo->vertex_input_state.num_vertex_attributes; i += 1) { + Uint32 loc = createinfo->vertex_input_state.vertex_attributes[i].location; + vertexDescriptor.attributes[loc].format = SDLToMetal_VertexFormat[createinfo->vertex_input_state.vertex_attributes[i].format]; + vertexDescriptor.attributes[loc].offset = createinfo->vertex_input_state.vertex_attributes[i].offset; + vertexDescriptor.attributes[loc].bufferIndex = METAL_INTERNAL_GetVertexBufferIndex(createinfo->vertex_input_state.vertex_attributes[i].binding); } - for (Uint32 i = 0; i < pipelineCreateInfo->vertexInputState.vertexBindingCount; i += 1) { - binding = METAL_INTERNAL_GetVertexBufferIndex(pipelineCreateInfo->vertexInputState.vertexBindings[i].binding); - vertexDescriptor.layouts[binding].stepFunction = SDLToMetal_StepFunction[pipelineCreateInfo->vertexInputState.vertexBindings[i].inputRate]; - vertexDescriptor.layouts[binding].stepRate = (pipelineCreateInfo->vertexInputState.vertexBindings[i].inputRate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) ? pipelineCreateInfo->vertexInputState.vertexBindings[i].instanceStepRate : 1; - vertexDescriptor.layouts[binding].stride = pipelineCreateInfo->vertexInputState.vertexBindings[i].stride; + for (Uint32 i = 0; i < createinfo->vertex_input_state.num_vertex_bindings; i += 1) { + binding = METAL_INTERNAL_GetVertexBufferIndex(createinfo->vertex_input_state.vertex_bindings[i].binding); + vertexDescriptor.layouts[binding].stepFunction = SDLToMetal_StepFunction[createinfo->vertex_input_state.vertex_bindings[i].input_rate]; + vertexDescriptor.layouts[binding].stepRate = (createinfo->vertex_input_state.vertex_bindings[i].input_rate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) ? createinfo->vertex_input_state.vertex_bindings[i].instance_step_rate : 1; + vertexDescriptor.layouts[binding].stride = createinfo->vertex_input_state.vertex_bindings[i].pitch; } pipelineDescriptor.vertexDescriptor = vertexDescriptor; @@ -1101,18 +1101,18 @@ static SDL_GPUGraphicsPipeline *METAL_CreateGraphicsPipeline( result = SDL_calloc(1, sizeof(MetalGraphicsPipeline)); result->handle = pipelineState; - result->sampleMask = pipelineCreateInfo->multisampleState.sampleMask; - result->depthStencilState = depthStencilState; - result->rasterizerState = pipelineCreateInfo->rasterizerState; - result->primitiveType = pipelineCreateInfo->primitiveType; - result->vertexSamplerCount = vertexShader->samplerCount; - result->vertexUniformBufferCount = vertexShader->uniformBufferCount; - result->vertexStorageBufferCount = vertexShader->storageBufferCount; - result->vertexStorageTextureCount = vertexShader->storageTextureCount; - result->fragmentSamplerCount = fragmentShader->samplerCount; - result->fragmentUniformBufferCount = fragmentShader->uniformBufferCount; - result->fragmentStorageBufferCount = fragmentShader->storageBufferCount; - result->fragmentStorageTextureCount = fragmentShader->storageTextureCount; + result->sample_mask = createinfo->multisample_state.sample_mask; + result->depth_stencil_state = depthStencilState; + result->rasterizerState = createinfo->rasterizer_state; + result->primitiveType = createinfo->primitive_type; + result->vertexSamplerCount = vertexShader->num_samplers; + result->vertexUniformBufferCount = vertexShader->numUniformBuffers; + result->vertexStorageBufferCount = vertexShader->numStorageBuffers; + result->vertexStorageTextureCount = vertexShader->numStorageTextures; + result->fragmentSamplerCount = fragmentShader->num_samplers; + result->fragmentUniformBufferCount = fragmentShader->numUniformBuffers; + result->fragmentStorageBufferCount = fragmentShader->numStorageBuffers; + result->fragmentStorageTextureCount = fragmentShader->numStorageTextures; return (SDL_GPUGraphicsPipeline *)result; } } @@ -1129,7 +1129,7 @@ static void METAL_SetBufferName( MetalBufferContainer *container = (MetalBufferContainer *)buffer; size_t textLength = SDL_strlen(text) + 1; - if (renderer->debugMode) { + if (renderer->debug_mode) { container->debugName = SDL_realloc( container->debugName, textLength); @@ -1156,7 +1156,7 @@ static void METAL_SetTextureName( MetalTextureContainer *container = (MetalTextureContainer *)texture; size_t textLength = SDL_strlen(text) + 1; - if (renderer->debugMode) { + if (renderer->debug_mode) { container->debugName = SDL_realloc( container->debugName, textLength); @@ -1237,7 +1237,7 @@ static void METAL_PopDebugGroup( static SDL_GPUSampler *METAL_CreateSampler( SDL_GPURenderer *driverData, - const SDL_GPUSamplerCreateInfo *samplerCreateInfo) + const SDL_GPUSamplerCreateInfo *createinfo) { @autoreleasepool { MetalRenderer *renderer = (MetalRenderer *)driverData; @@ -1245,16 +1245,16 @@ static SDL_GPUSampler *METAL_CreateSampler( id sampler; MetalSampler *metalSampler; - samplerDesc.rAddressMode = SDLToMetal_SamplerAddressMode[samplerCreateInfo->addressModeU]; - samplerDesc.sAddressMode = SDLToMetal_SamplerAddressMode[samplerCreateInfo->addressModeV]; - samplerDesc.tAddressMode = SDLToMetal_SamplerAddressMode[samplerCreateInfo->addressModeW]; - samplerDesc.minFilter = SDLToMetal_MinMagFilter[samplerCreateInfo->minFilter]; - samplerDesc.magFilter = SDLToMetal_MinMagFilter[samplerCreateInfo->magFilter]; - samplerDesc.mipFilter = SDLToMetal_MipFilter[samplerCreateInfo->mipmapMode]; // FIXME: Is this right with non-mipmapped samplers? - samplerDesc.lodMinClamp = samplerCreateInfo->minLod; - samplerDesc.lodMaxClamp = samplerCreateInfo->maxLod; - samplerDesc.maxAnisotropy = (NSUInteger)((samplerCreateInfo->anisotropyEnable) ? samplerCreateInfo->maxAnisotropy : 1); - samplerDesc.compareFunction = (samplerCreateInfo->compareEnable) ? SDLToMetal_CompareOp[samplerCreateInfo->compareOp] : MTLCompareFunctionAlways; + samplerDesc.rAddressMode = SDLToMetal_SamplerAddressMode[createinfo->address_mode_u]; + samplerDesc.sAddressMode = SDLToMetal_SamplerAddressMode[createinfo->address_mode_v]; + samplerDesc.tAddressMode = SDLToMetal_SamplerAddressMode[createinfo->address_mode_w]; + samplerDesc.minFilter = SDLToMetal_MinMagFilter[createinfo->min_filter]; + samplerDesc.magFilter = SDLToMetal_MinMagFilter[createinfo->mag_filter]; + samplerDesc.mipFilter = SDLToMetal_MipFilter[createinfo->mipmap_mode]; // FIXME: Is this right with non-mipmapped samplers? + samplerDesc.lodMinClamp = createinfo->min_lod; + samplerDesc.lodMaxClamp = createinfo->max_lod; + samplerDesc.maxAnisotropy = (NSUInteger)((createinfo->enable_anisotropy) ? createinfo->max_anisotropy : 1); + samplerDesc.compareFunction = (createinfo->enable_compare) ? SDLToMetal_CompareOp[createinfo->compare_op] : MTLCompareFunctionAlways; samplerDesc.borderColor = MTLSamplerBorderColorTransparentBlack; // arbitrary, unused sampler = [renderer->device newSamplerStateWithDescriptor:samplerDesc]; @@ -1271,7 +1271,7 @@ static SDL_GPUSampler *METAL_CreateSampler( static SDL_GPUShader *METAL_CreateShader( SDL_GPURenderer *driverData, - const SDL_GPUShaderCreateInfo *shaderCreateInfo) + const SDL_GPUShaderCreateInfo *createinfo) { @autoreleasepool { MetalLibraryFunction libraryFunction; @@ -1279,10 +1279,10 @@ static SDL_GPUShader *METAL_CreateShader( libraryFunction = METAL_INTERNAL_CompileShader( (MetalRenderer *)driverData, - shaderCreateInfo->format, - shaderCreateInfo->code, - shaderCreateInfo->codeSize, - shaderCreateInfo->entryPointName); + createinfo->format, + createinfo->code, + createinfo->code_size, + createinfo->entrypoint); if (libraryFunction.library == nil || libraryFunction.function == nil) { return NULL; @@ -1291,10 +1291,10 @@ static SDL_GPUShader *METAL_CreateShader( result = SDL_calloc(1, sizeof(MetalShader)); result->library = libraryFunction.library; result->function = libraryFunction.function; - result->samplerCount = shaderCreateInfo->samplerCount; - result->storageBufferCount = shaderCreateInfo->storageBufferCount; - result->storageTextureCount = shaderCreateInfo->storageTextureCount; - result->uniformBufferCount = shaderCreateInfo->uniformBufferCount; + result->num_samplers = createinfo->num_samplers; + result->numStorageBuffers = createinfo->num_storage_buffers; + result->numStorageTextures = createinfo->num_storage_textures; + result->numUniformBuffers = createinfo->num_uniform_buffers; return (SDL_GPUShader *)result; } } @@ -1302,17 +1302,17 @@ static SDL_GPUShader *METAL_CreateShader( // This function assumes that it's called from within an autorelease pool static MetalTexture *METAL_INTERNAL_CreateTexture( MetalRenderer *renderer, - const SDL_GPUTextureCreateInfo *textureCreateInfo) + const SDL_GPUTextureCreateInfo *createinfo) { MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor new]; id texture; id msaaTexture = NULL; MetalTexture *metalTexture; - textureDescriptor.textureType = SDLToMetal_TextureType[textureCreateInfo->type]; - textureDescriptor.pixelFormat = SDLToMetal_SurfaceFormat[textureCreateInfo->format]; + textureDescriptor.textureType = SDLToMetal_TextureType[createinfo->type]; + textureDescriptor.pixelFormat = SDLToMetal_SurfaceFormat[createinfo->format]; // This format isn't natively supported so let's swizzle! - if (textureCreateInfo->format == SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM) { + if (createinfo->format == SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM) { textureDescriptor.swizzle = MTLTextureSwizzleChannelsMake( MTLTextureSwizzleBlue, MTLTextureSwizzleGreen, @@ -1320,25 +1320,25 @@ static MetalTexture *METAL_INTERNAL_CreateTexture( MTLTextureSwizzleAlpha); } - textureDescriptor.width = textureCreateInfo->width; - textureDescriptor.height = textureCreateInfo->height; - textureDescriptor.depth = (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D) ? textureCreateInfo->layerCountOrDepth : 1; - textureDescriptor.mipmapLevelCount = textureCreateInfo->levelCount; + textureDescriptor.width = createinfo->width; + textureDescriptor.height = createinfo->height; + textureDescriptor.depth = (createinfo->type == SDL_GPU_TEXTURETYPE_3D) ? createinfo->layer_count_or_depth : 1; + textureDescriptor.mipmapLevelCount = createinfo->num_levels; textureDescriptor.sampleCount = 1; - textureDescriptor.arrayLength = (textureCreateInfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY) ? textureCreateInfo->layerCountOrDepth : 1; + textureDescriptor.arrayLength = (createinfo->type == SDL_GPU_TEXTURETYPE_2D_ARRAY) ? createinfo->layer_count_or_depth : 1; textureDescriptor.storageMode = MTLStorageModePrivate; textureDescriptor.usage = 0; - if (textureCreateInfo->usageFlags & (SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | - SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) { + if (createinfo->usage & (SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | + SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) { textureDescriptor.usage |= MTLTextureUsageRenderTarget; } - if (textureCreateInfo->usageFlags & (SDL_GPU_TEXTUREUSAGE_SAMPLER | - SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ | - SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ)) { + if (createinfo->usage & (SDL_GPU_TEXTUREUSAGE_SAMPLER | + SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ | + SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ)) { textureDescriptor.usage |= MTLTextureUsageShaderRead; } - if (textureCreateInfo->usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE) { + if (createinfo->usage & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE) { textureDescriptor.usage |= MTLTextureUsageShaderWrite; } @@ -1349,9 +1349,9 @@ static MetalTexture *METAL_INTERNAL_CreateTexture( } // Create the MSAA texture, if needed - if (textureCreateInfo->sampleCount > SDL_GPU_SAMPLECOUNT_1 && textureCreateInfo->type == SDL_GPU_TEXTURETYPE_2D) { + if (createinfo->sample_count > SDL_GPU_SAMPLECOUNT_1 && createinfo->type == SDL_GPU_TEXTURETYPE_2D) { textureDescriptor.textureType = MTLTextureType2DMultisample; - textureDescriptor.sampleCount = SDLToMetal_SampleCount[textureCreateInfo->sampleCount]; + textureDescriptor.sampleCount = SDLToMetal_SampleCount[createinfo->sample_count]; textureDescriptor.usage = MTLTextureUsageRenderTarget; msaaTexture = [renderer->device newTextureWithDescriptor:textureDescriptor]; @@ -1382,7 +1382,7 @@ static bool METAL_SupportsSampleCount( static SDL_GPUTexture *METAL_CreateTexture( SDL_GPURenderer *driverData, - const SDL_GPUTextureCreateInfo *textureCreateInfo) + const SDL_GPUTextureCreateInfo *createinfo) { @autoreleasepool { MetalRenderer *renderer = (MetalRenderer *)driverData; @@ -1391,7 +1391,7 @@ static SDL_GPUTexture *METAL_CreateTexture( texture = METAL_INTERNAL_CreateTexture( renderer, - textureCreateInfo); + createinfo); if (texture == NULL) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Failed to create texture!"); @@ -1400,7 +1400,7 @@ static SDL_GPUTexture *METAL_CreateTexture( container = SDL_calloc(1, sizeof(MetalTextureContainer)); container->canBeCycled = 1; - container->header.info = *textureCreateInfo; + container->header.info = *createinfo; container->activeTexture = texture; container->textureCapacity = 1; container->textureCount = 1; @@ -1444,7 +1444,7 @@ static MetalTexture *METAL_INTERNAL_PrepareTextureForWrite( container->activeTexture = container->textures[container->textureCount - 1]; - if (renderer->debugMode && container->debugName != NULL) { + if (renderer->debug_mode && container->debugName != NULL) { container->activeTexture->handle.label = @(container->debugName); } } @@ -1455,16 +1455,16 @@ static MetalTexture *METAL_INTERNAL_PrepareTextureForWrite( // This function assumes that it's called from within an autorelease pool static MetalBuffer *METAL_INTERNAL_CreateBuffer( MetalRenderer *renderer, - Uint32 sizeInBytes, + Uint32 size, MTLResourceOptions resourceOptions) { id bufferHandle; MetalBuffer *metalBuffer; // Storage buffers have to be 4-aligned, so might as well align them all - sizeInBytes = METAL_INTERNAL_NextHighestAlignment(sizeInBytes, 4); + size = METAL_INTERNAL_NextHighestAlignment(size, 4); - bufferHandle = [renderer->device newBufferWithLength:sizeInBytes options:resourceOptions]; + bufferHandle = [renderer->device newBufferWithLength:size options:resourceOptions]; if (bufferHandle == NULL) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Could not create buffer"); return NULL; @@ -1480,14 +1480,14 @@ static MetalBuffer *METAL_INTERNAL_CreateBuffer( // This function assumes that it's called from within an autorelease pool static MetalBufferContainer *METAL_INTERNAL_CreateBufferContainer( MetalRenderer *renderer, - Uint32 sizeInBytes, + Uint32 size, bool isPrivate, bool isWriteOnly) { MetalBufferContainer *container = SDL_calloc(1, sizeof(MetalBufferContainer)); MTLResourceOptions resourceOptions; - container->size = sizeInBytes; + container->size = size; container->bufferCapacity = 1; container->bufferCount = 1; container->buffers = SDL_calloc( @@ -1508,7 +1508,7 @@ static MetalBufferContainer *METAL_INTERNAL_CreateBufferContainer( container->buffers[0] = METAL_INTERNAL_CreateBuffer( renderer, - sizeInBytes, + size, resourceOptions); container->activeBuffer = container->buffers[0]; @@ -1517,13 +1517,13 @@ static MetalBufferContainer *METAL_INTERNAL_CreateBufferContainer( static SDL_GPUBuffer *METAL_CreateBuffer( SDL_GPURenderer *driverData, - SDL_GPUBufferUsageFlags usageFlags, - Uint32 sizeInBytes) + SDL_GPUBufferUsageFlags usage, + Uint32 size) { @autoreleasepool { return (SDL_GPUBuffer *)METAL_INTERNAL_CreateBufferContainer( (MetalRenderer *)driverData, - sizeInBytes, + size, true, false); } @@ -1532,12 +1532,12 @@ static SDL_GPUBuffer *METAL_CreateBuffer( static SDL_GPUTransferBuffer *METAL_CreateTransferBuffer( SDL_GPURenderer *driverData, SDL_GPUTransferBufferUsage usage, - Uint32 sizeInBytes) + Uint32 size) { @autoreleasepool { return (SDL_GPUTransferBuffer *)METAL_INTERNAL_CreateBufferContainer( (MetalRenderer *)driverData, - sizeInBytes, + size, false, usage == SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD); } @@ -1546,12 +1546,12 @@ static SDL_GPUTransferBuffer *METAL_CreateTransferBuffer( // This function assumes that it's called from within an autorelease pool static MetalUniformBuffer *METAL_INTERNAL_CreateUniformBuffer( MetalRenderer *renderer, - Uint32 sizeInBytes) + Uint32 size) { MetalUniformBuffer *uniformBuffer; id bufferHandle; - bufferHandle = [renderer->device newBufferWithLength:sizeInBytes options:MTLResourceCPUCacheModeWriteCombined]; + bufferHandle = [renderer->device newBufferWithLength:size options:MTLResourceCPUCacheModeWriteCombined]; if (bufferHandle == nil) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Could not create uniform buffer"); return NULL; @@ -1608,7 +1608,7 @@ static MetalBuffer *METAL_INTERNAL_PrepareBufferForWrite( container->activeBuffer = container->buffers[container->bufferCount - 1]; - if (renderer->debugMode && container->debugName != NULL) { + if (renderer->debug_mode && container->debugName != NULL) { container->activeBuffer->handle.label = @(container->debugName); } } @@ -1667,7 +1667,7 @@ static void METAL_UploadToTexture( @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalRenderer *renderer = metalCommandBuffer->renderer; - MetalBufferContainer *bufferContainer = (MetalBufferContainer *)source->transferBuffer; + MetalBufferContainer *bufferContainer = (MetalBufferContainer *)source->transfer_buffer; MetalTextureContainer *textureContainer = (MetalTextureContainer *)destination->texture; MetalTexture *metalTexture = METAL_INTERNAL_PrepareTextureForWrite(renderer, textureContainer, cycle); @@ -1680,7 +1680,7 @@ static void METAL_UploadToTexture( sourceSize:MTLSizeMake(destination->w, destination->h, destination->d) toTexture:metalTexture->handle destinationSlice:destination->layer - destinationLevel:destination->mipLevel + destinationLevel:destination->mip_level destinationOrigin:MTLOriginMake(destination->x, destination->y, destination->z)]; METAL_INTERNAL_TrackTexture(metalCommandBuffer, metalTexture); @@ -1697,7 +1697,7 @@ static void METAL_UploadToBuffer( @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalRenderer *renderer = metalCommandBuffer->renderer; - MetalBufferContainer *transferContainer = (MetalBufferContainer *)source->transferBuffer; + MetalBufferContainer *transferContainer = (MetalBufferContainer *)source->transfer_buffer; MetalBufferContainer *bufferContainer = (MetalBufferContainer *)destination->buffer; MetalBuffer *metalBuffer = METAL_INTERNAL_PrepareBufferForWrite( @@ -1741,12 +1741,12 @@ static void METAL_CopyTextureToTexture( [metalCommandBuffer->blitEncoder copyFromTexture:srcTexture->handle sourceSlice:source->layer - sourceLevel:source->mipLevel + sourceLevel:source->mip_level sourceOrigin:MTLOriginMake(source->x, source->y, source->z) sourceSize:MTLSizeMake(w, h, d) toTexture:dstTexture->handle destinationSlice:destination->layer - destinationLevel:destination->mipLevel + destinationLevel:destination->mip_level destinationOrigin:MTLOriginMake(destination->x, destination->y, destination->z)]; METAL_INTERNAL_TrackTexture(metalCommandBuffer, srcTexture); @@ -1795,9 +1795,9 @@ static void METAL_DownloadFromTexture( MetalRenderer *renderer = metalCommandBuffer->renderer; MetalTextureContainer *textureContainer = (MetalTextureContainer *)source->texture; MetalTexture *metalTexture = textureContainer->activeTexture; - MetalBufferContainer *bufferContainer = (MetalBufferContainer *)destination->transferBuffer; - Uint32 bufferStride = destination->imagePitch; - Uint32 bufferImageHeight = destination->imageHeight; + MetalBufferContainer *bufferContainer = (MetalBufferContainer *)destination->transfer_buffer; + Uint32 bufferStride = destination->pixels_per_row; + Uint32 bufferImageHeight = destination->rows_per_layer; Uint32 bytesPerRow, bytesPerDepthSlice; MetalBuffer *dstBuffer = METAL_INTERNAL_PrepareBufferForWrite( @@ -1826,7 +1826,7 @@ static void METAL_DownloadFromTexture( [metalCommandBuffer->blitEncoder copyFromTexture:metalTexture->handle sourceSlice:source->layer - sourceLevel:source->mipLevel + sourceLevel:source->mip_level sourceOrigin:regionOrigin sourceSize:regionSize toBuffer:dstBuffer->handle @@ -2007,8 +2007,8 @@ static SDL_GPUCommandBuffer *METAL_AcquireCommandBuffer( commandBuffer = METAL_INTERNAL_GetInactiveCommandBufferFromPool(renderer); commandBuffer->handle = [renderer->queue commandBuffer]; - commandBuffer->graphicsPipeline = NULL; - commandBuffer->computePipeline = NULL; + commandBuffer->graphics_pipeline = NULL; + commandBuffer->compute_pipeline = NULL; for (Uint32 i = 0; i < MAX_UNIFORM_BUFFERS_PER_STAGE; i += 1) { commandBuffer->vertexUniformBuffers[i] = NULL; commandBuffer->fragmentUniformBuffers[i] = NULL; @@ -2092,8 +2092,8 @@ static void METAL_SetViewport( metalViewport.originY = viewport->y; metalViewport.width = viewport->w; metalViewport.height = viewport->h; - metalViewport.znear = viewport->minDepth; - metalViewport.zfar = viewport->maxDepth; + metalViewport.znear = viewport->min_depth; + metalViewport.zfar = viewport->max_depth; [metalCommandBuffer->renderEncoder setViewport:metalViewport]; } @@ -2131,8 +2131,8 @@ static void METAL_SetBlendConstants( static void METAL_SetStencilReference( SDL_GPUCommandBuffer *commandBuffer, - Uint8 reference -) { + Uint8 reference) +{ @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; [metalCommandBuffer->renderEncoder setStencilReferenceValue:reference]; @@ -2141,9 +2141,9 @@ static void METAL_SetStencilReference( static void METAL_BeginRenderPass( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo) + const SDL_GPUColorTargetInfo *colorTargetInfos, + Uint32 numColorTargets, + const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; @@ -2154,12 +2154,12 @@ static void METAL_BeginRenderPass( SDL_GPUViewport viewport; SDL_Rect scissorRect; - for (Uint32 i = 0; i < colorAttachmentCount; i += 1) { - MetalTextureContainer *container = (MetalTextureContainer *)colorAttachmentInfos[i].texture; + for (Uint32 i = 0; i < numColorTargets; i += 1) { + MetalTextureContainer *container = (MetalTextureContainer *)colorTargetInfos[i].texture; MetalTexture *texture = METAL_INTERNAL_PrepareTextureForWrite( renderer, container, - colorAttachmentInfos[i].cycle); + colorTargetInfos[i].cycle); if (texture->msaaHandle) { passDescriptor.colorAttachments[i].texture = texture->msaaHandle; @@ -2167,31 +2167,31 @@ static void METAL_BeginRenderPass( } else { passDescriptor.colorAttachments[i].texture = texture->handle; } - passDescriptor.colorAttachments[i].level = colorAttachmentInfos[i].mipLevel; + passDescriptor.colorAttachments[i].level = colorTargetInfos[i].mip_level; if (container->header.info.type == SDL_GPU_TEXTURETYPE_3D) { - passDescriptor.colorAttachments[i].depthPlane = colorAttachmentInfos[i].layerOrDepthPlane; + passDescriptor.colorAttachments[i].depthPlane = colorTargetInfos[i].layer_or_depth_plane; } else { - passDescriptor.colorAttachments[i].slice = colorAttachmentInfos[i].layerOrDepthPlane; + passDescriptor.colorAttachments[i].slice = colorTargetInfos[i].layer_or_depth_plane; } passDescriptor.colorAttachments[i].clearColor = MTLClearColorMake( - colorAttachmentInfos[i].clearColor.r, - colorAttachmentInfos[i].clearColor.g, - colorAttachmentInfos[i].clearColor.b, - colorAttachmentInfos[i].clearColor.a); - passDescriptor.colorAttachments[i].loadAction = SDLToMetal_LoadOp[colorAttachmentInfos[i].loadOp]; + colorTargetInfos[i].clear_color.r, + colorTargetInfos[i].clear_color.g, + colorTargetInfos[i].clear_color.b, + colorTargetInfos[i].clear_color.a); + passDescriptor.colorAttachments[i].loadAction = SDLToMetal_LoadOp[colorTargetInfos[i].load_op]; passDescriptor.colorAttachments[i].storeAction = SDLToMetal_StoreOp( - colorAttachmentInfos[i].storeOp, + colorTargetInfos[i].store_op, texture->msaaHandle ? 1 : 0); METAL_INTERNAL_TrackTexture(metalCommandBuffer, texture); } - if (depthStencilAttachmentInfo != NULL) { - MetalTextureContainer *container = (MetalTextureContainer *)depthStencilAttachmentInfo->texture; + if (depthStencilTargetInfo != NULL) { + MetalTextureContainer *container = (MetalTextureContainer *)depthStencilTargetInfo->texture; MetalTexture *texture = METAL_INTERNAL_PrepareTextureForWrite( renderer, container, - depthStencilAttachmentInfo->cycle); + depthStencilTargetInfo->cycle); if (texture->msaaHandle) { passDescriptor.depthAttachment.texture = texture->msaaHandle; @@ -2199,11 +2199,11 @@ static void METAL_BeginRenderPass( } else { passDescriptor.depthAttachment.texture = texture->handle; } - passDescriptor.depthAttachment.loadAction = SDLToMetal_LoadOp[depthStencilAttachmentInfo->loadOp]; + passDescriptor.depthAttachment.loadAction = SDLToMetal_LoadOp[depthStencilTargetInfo->load_op]; passDescriptor.depthAttachment.storeAction = SDLToMetal_StoreOp( - depthStencilAttachmentInfo->storeOp, + depthStencilTargetInfo->store_op, texture->msaaHandle ? 1 : 0); - passDescriptor.depthAttachment.clearDepth = depthStencilAttachmentInfo->depthStencilClearValue.depth; + passDescriptor.depthAttachment.clearDepth = depthStencilTargetInfo->clear_value.depth; if (IsStencilFormat(container->header.info.format)) { if (texture->msaaHandle) { @@ -2212,11 +2212,11 @@ static void METAL_BeginRenderPass( } else { passDescriptor.stencilAttachment.texture = texture->handle; } - passDescriptor.stencilAttachment.loadAction = SDLToMetal_LoadOp[depthStencilAttachmentInfo->loadOp]; + passDescriptor.stencilAttachment.loadAction = SDLToMetal_LoadOp[depthStencilTargetInfo->load_op]; passDescriptor.stencilAttachment.storeAction = SDLToMetal_StoreOp( - depthStencilAttachmentInfo->storeOp, + depthStencilTargetInfo->store_op, texture->msaaHandle ? 1 : 0); - passDescriptor.stencilAttachment.clearStencil = depthStencilAttachmentInfo->depthStencilClearValue.stencil; + passDescriptor.stencilAttachment.clearStencil = depthStencilTargetInfo->clear_value.stencil; } METAL_INTERNAL_TrackTexture(metalCommandBuffer, texture); @@ -2224,11 +2224,11 @@ static void METAL_BeginRenderPass( metalCommandBuffer->renderEncoder = [metalCommandBuffer->handle renderCommandEncoderWithDescriptor:passDescriptor]; - // The viewport cannot be larger than the smallest attachment. - for (Uint32 i = 0; i < colorAttachmentCount; i += 1) { - MetalTextureContainer *container = (MetalTextureContainer *)colorAttachmentInfos[i].texture; - Uint32 w = container->header.info.width >> colorAttachmentInfos[i].mipLevel; - Uint32 h = container->header.info.height >> colorAttachmentInfos[i].mipLevel; + // The viewport cannot be larger than the smallest target. + for (Uint32 i = 0; i < numColorTargets; i += 1) { + MetalTextureContainer *container = (MetalTextureContainer *)colorTargetInfos[i].texture; + Uint32 w = container->header.info.width >> colorTargetInfos[i].mip_level; + Uint32 h = container->header.info.height >> colorTargetInfos[i].mip_level; if (w < vpWidth) { vpWidth = w; @@ -2239,8 +2239,8 @@ static void METAL_BeginRenderPass( } } - if (depthStencilAttachmentInfo != NULL) { - MetalTextureContainer *container = (MetalTextureContainer *)depthStencilAttachmentInfo->texture; + if (depthStencilTargetInfo != NULL) { + MetalTextureContainer *container = (MetalTextureContainer *)depthStencilTargetInfo->texture; Uint32 w = container->header.info.width; Uint32 h = container->header.info.height; @@ -2258,8 +2258,8 @@ static void METAL_BeginRenderPass( viewport.y = 0; viewport.w = vpWidth; viewport.h = vpHeight; - viewport.minDepth = 0; - viewport.maxDepth = 1; + viewport.min_depth = 0; + viewport.max_depth = 1; METAL_SetViewport(commandBuffer, &viewport); scissorRect.x = 0; @@ -2287,23 +2287,23 @@ static void METAL_BindGraphicsPipeline( MetalGraphicsPipeline *metalGraphicsPipeline = (MetalGraphicsPipeline *)graphicsPipeline; SDL_GPURasterizerState *rast = &metalGraphicsPipeline->rasterizerState; - metalCommandBuffer->graphicsPipeline = metalGraphicsPipeline; + metalCommandBuffer->graphics_pipeline = metalGraphicsPipeline; [metalCommandBuffer->renderEncoder setRenderPipelineState:metalGraphicsPipeline->handle]; // Apply rasterizer state - [metalCommandBuffer->renderEncoder setTriangleFillMode:SDLToMetal_PolygonMode[metalGraphicsPipeline->rasterizerState.fillMode]]; - [metalCommandBuffer->renderEncoder setCullMode:SDLToMetal_CullMode[metalGraphicsPipeline->rasterizerState.cullMode]]; - [metalCommandBuffer->renderEncoder setFrontFacingWinding:SDLToMetal_FrontFace[metalGraphicsPipeline->rasterizerState.frontFace]]; + [metalCommandBuffer->renderEncoder setTriangleFillMode:SDLToMetal_PolygonMode[metalGraphicsPipeline->rasterizerState.fill_mode]]; + [metalCommandBuffer->renderEncoder setCullMode:SDLToMetal_CullMode[metalGraphicsPipeline->rasterizerState.cull_mode]]; + [metalCommandBuffer->renderEncoder setFrontFacingWinding:SDLToMetal_FrontFace[metalGraphicsPipeline->rasterizerState.front_face]]; [metalCommandBuffer->renderEncoder - setDepthBias:((rast->depthBiasEnable) ? rast->depthBiasConstantFactor : 0) - slopeScale:((rast->depthBiasEnable) ? rast->depthBiasSlopeFactor : 0) - clamp:((rast->depthBiasEnable) ? rast->depthBiasClamp : 0)]; + setDepthBias:((rast->enable_depth_bias) ? rast->depth_bias_constant_factor : 0) + slopeScale:((rast->enable_depth_bias) ? rast->depth_bias_slope_factor : 0) + clamp:((rast->enable_depth_bias) ? rast->depth_bias_clamp : 0)]; // Apply depth-stencil state - if (metalGraphicsPipeline->depthStencilState != NULL) { + if (metalGraphicsPipeline->depth_stencil_state != NULL) { [metalCommandBuffer->renderEncoder - setDepthStencilState:metalGraphicsPipeline->depthStencilState]; + setDepthStencilState:metalGraphicsPipeline->depth_stencil_state]; } for (Uint32 i = 0; i < metalGraphicsPipeline->vertexUniformBufferCount; i += 1) { @@ -2328,24 +2328,24 @@ static void METAL_BindGraphicsPipeline( static void METAL_BindVertexBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstBinding, - const SDL_GPUBufferBinding *pBindings, - Uint32 bindingCount) + const SDL_GPUBufferBinding *bindings, + Uint32 numBindings) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; id metalBuffers[MAX_BUFFER_BINDINGS]; NSUInteger bufferOffsets[MAX_BUFFER_BINDINGS]; - NSRange range = NSMakeRange(METAL_INTERNAL_GetVertexBufferIndex(firstBinding), bindingCount); + NSRange range = NSMakeRange(METAL_INTERNAL_GetVertexBufferIndex(firstBinding), numBindings); if (range.length == 0) { return; } for (Uint32 i = 0; i < range.length; i += 1) { - MetalBuffer *currentBuffer = ((MetalBufferContainer *)pBindings[i].buffer)->activeBuffer; + MetalBuffer *currentBuffer = ((MetalBufferContainer *)bindings[i].buffer)->activeBuffer; NSUInteger bindingIndex = range.length - 1 - i; metalBuffers[bindingIndex] = currentBuffer->handle; - bufferOffsets[bindingIndex] = pBindings[i].offset; + bufferOffsets[bindingIndex] = bindings[i].offset; METAL_INTERNAL_TrackBuffer(metalCommandBuffer, currentBuffer); } @@ -2355,13 +2355,13 @@ static void METAL_BindVertexBuffers( static void METAL_BindIndexBuffer( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUBufferBinding *pBinding, + const SDL_GPUBufferBinding *binding, SDL_GPUIndexElementSize indexElementSize) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; - metalCommandBuffer->indexBuffer = ((MetalBufferContainer *)pBinding->buffer)->activeBuffer; - metalCommandBuffer->indexBufferOffset = pBinding->offset; - metalCommandBuffer->indexElementSize = indexElementSize; + metalCommandBuffer->indexBuffer = ((MetalBufferContainer *)binding->buffer)->activeBuffer; + metalCommandBuffer->indexBufferOffset = binding->offset; + metalCommandBuffer->index_element_size = indexElementSize; METAL_INTERNAL_TrackBuffer(metalCommandBuffer, metalCommandBuffer->indexBuffer); } @@ -2370,12 +2370,12 @@ static void METAL_BindVertexSamplers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + Uint32 numBindings) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalTextureContainer *textureContainer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { textureContainer = (MetalTextureContainer *)textureSamplerBindings[i].texture; METAL_INTERNAL_TrackTexture( @@ -2396,12 +2396,12 @@ static void METAL_BindVertexStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalTextureContainer *textureContainer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { textureContainer = (MetalTextureContainer *)storageTextures[i]; METAL_INTERNAL_TrackTexture( @@ -2419,12 +2419,12 @@ static void METAL_BindVertexStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalBufferContainer *bufferContainer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { bufferContainer = (MetalBufferContainer *)storageBuffers[i]; METAL_INTERNAL_TrackBuffer( @@ -2442,12 +2442,12 @@ static void METAL_BindFragmentSamplers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + Uint32 numBindings) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalTextureContainer *textureContainer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { textureContainer = (MetalTextureContainer *)textureSamplerBindings[i].texture; METAL_INTERNAL_TrackTexture( @@ -2468,12 +2468,12 @@ static void METAL_BindFragmentStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalTextureContainer *textureContainer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { textureContainer = (MetalTextureContainer *)storageTextures[i]; METAL_INTERNAL_TrackTexture( @@ -2491,12 +2491,12 @@ static void METAL_BindFragmentStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalBufferContainer *bufferContainer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { bufferContainer = (MetalBufferContainer *)storageBuffers[i]; METAL_INTERNAL_TrackBuffer( @@ -2514,7 +2514,7 @@ static void METAL_BindFragmentStorageBuffers( static void METAL_INTERNAL_BindGraphicsResources( MetalCommandBuffer *commandBuffer) { - MetalGraphicsPipeline *graphicsPipeline = commandBuffer->graphicsPipeline; + MetalGraphicsPipeline *graphicsPipeline = commandBuffer->graphics_pipeline; NSUInteger offsets[MAX_STORAGE_BUFFERS_PER_STAGE] = { 0 }; // Vertex Samplers+Textures @@ -2603,48 +2603,48 @@ static void METAL_INTERNAL_BindGraphicsResources( static void METAL_INTERNAL_BindComputeResources( MetalCommandBuffer *commandBuffer) { - MetalComputePipeline *computePipeline = commandBuffer->computePipeline; + MetalComputePipeline *computePipeline = commandBuffer->compute_pipeline; NSUInteger offsets[MAX_STORAGE_BUFFERS_PER_STAGE] = { 0 }; // 8 is the max for both read and write-only if (commandBuffer->needComputeTextureBind) { // Bind read-only textures - if (computePipeline->readOnlyStorageTextureCount > 0) { + if (computePipeline->num_readonly_storage_textures > 0) { [commandBuffer->computeEncoder setTextures:commandBuffer->computeReadOnlyTextures - withRange:NSMakeRange(0, computePipeline->readOnlyStorageTextureCount)]; + withRange:NSMakeRange(0, computePipeline->num_readonly_storage_textures)]; } // Bind write-only textures - if (computePipeline->writeOnlyStorageTextureCount > 0) { + if (computePipeline->num_writeonly_storage_textures > 0) { [commandBuffer->computeEncoder setTextures:commandBuffer->computeWriteOnlyTextures withRange:NSMakeRange( - computePipeline->readOnlyStorageTextureCount, - computePipeline->writeOnlyStorageTextureCount)]; + computePipeline->num_readonly_storage_textures, + computePipeline->num_writeonly_storage_textures)]; } commandBuffer->needComputeTextureBind = false; } if (commandBuffer->needComputeBufferBind) { // Bind read-only buffers - if (computePipeline->readOnlyStorageBufferCount > 0) { + if (computePipeline->num_readonly_storage_buffers > 0) { [commandBuffer->computeEncoder setBuffers:commandBuffer->computeReadOnlyBuffers offsets:offsets - withRange:NSMakeRange(computePipeline->uniformBufferCount, - computePipeline->readOnlyStorageBufferCount)]; + withRange:NSMakeRange(computePipeline->numUniformBuffers, + computePipeline->num_readonly_storage_buffers)]; } // Bind write-only buffers - if (computePipeline->writeOnlyStorageBufferCount > 0) { + if (computePipeline->num_writeonly_storage_buffers > 0) { [commandBuffer->computeEncoder setBuffers:commandBuffer->computeWriteOnlyBuffers offsets:offsets withRange:NSMakeRange( - computePipeline->uniformBufferCount + - computePipeline->readOnlyStorageBufferCount, - computePipeline->writeOnlyStorageBufferCount)]; + computePipeline->numUniformBuffers + + computePipeline->num_readonly_storage_buffers, + computePipeline->num_writeonly_storage_buffers)]; } commandBuffer->needComputeBufferBind = false; } if (commandBuffer->needComputeUniformBind) { - for (Uint32 i = 0; i < computePipeline->uniformBufferCount; i += 1) { + for (Uint32 i = 0; i < computePipeline->numUniformBuffers; i += 1) { [commandBuffer->computeEncoder setBuffer:commandBuffer->computeUniformBuffers[i]->handle offset:commandBuffer->computeUniformBuffers[i]->drawOffset @@ -2657,26 +2657,26 @@ static void METAL_INTERNAL_BindComputeResources( static void METAL_DrawIndexedPrimitives( SDL_GPUCommandBuffer *commandBuffer, - Uint32 indexCount, - Uint32 instanceCount, + Uint32 numIndices, + Uint32 numInstances, Uint32 firstIndex, Sint32 vertexOffset, Uint32 firstInstance) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; - SDL_GPUPrimitiveType primitiveType = metalCommandBuffer->graphicsPipeline->primitiveType; - Uint32 indexSize = IndexSize(metalCommandBuffer->indexElementSize); + SDL_GPUPrimitiveType primitiveType = metalCommandBuffer->graphics_pipeline->primitiveType; + Uint32 indexSize = IndexSize(metalCommandBuffer->index_element_size); METAL_INTERNAL_BindGraphicsResources(metalCommandBuffer); [metalCommandBuffer->renderEncoder drawIndexedPrimitives:SDLToMetal_PrimitiveType[primitiveType] - indexCount:indexCount - indexType:SDLToMetal_IndexType[metalCommandBuffer->indexElementSize] + indexCount:numIndices + indexType:SDLToMetal_IndexType[metalCommandBuffer->index_element_size] indexBuffer:metalCommandBuffer->indexBuffer->handle indexBufferOffset:metalCommandBuffer->indexBufferOffset + (firstIndex * indexSize) - instanceCount:instanceCount + instanceCount:numInstances baseVertex:vertexOffset baseInstance:firstInstance]; } @@ -2684,22 +2684,22 @@ static void METAL_DrawIndexedPrimitives( static void METAL_DrawPrimitives( SDL_GPUCommandBuffer *commandBuffer, - Uint32 vertexCount, - Uint32 instanceCount, + Uint32 numVertices, + Uint32 numInstances, Uint32 firstVertex, Uint32 firstInstance) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; - SDL_GPUPrimitiveType primitiveType = metalCommandBuffer->graphicsPipeline->primitiveType; + SDL_GPUPrimitiveType primitiveType = metalCommandBuffer->graphics_pipeline->primitiveType; METAL_INTERNAL_BindGraphicsResources(metalCommandBuffer); [metalCommandBuffer->renderEncoder drawPrimitives:SDLToMetal_PrimitiveType[primitiveType] vertexStart:firstVertex - vertexCount:vertexCount - instanceCount:instanceCount + vertexCount:numVertices + instanceCount:numInstances baseInstance:firstInstance]; } } @@ -2707,14 +2707,14 @@ static void METAL_DrawPrimitives( static void METAL_DrawPrimitivesIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride) + Uint32 pitch) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalBuffer *metalBuffer = ((MetalBufferContainer *)buffer)->activeBuffer; - SDL_GPUPrimitiveType primitiveType = metalCommandBuffer->graphicsPipeline->primitiveType; + SDL_GPUPrimitiveType primitiveType = metalCommandBuffer->graphics_pipeline->primitiveType; METAL_INTERNAL_BindGraphicsResources(metalCommandBuffer); @@ -2725,7 +2725,7 @@ static void METAL_DrawPrimitivesIndirect( [metalCommandBuffer->renderEncoder drawPrimitives:SDLToMetal_PrimitiveType[primitiveType] indirectBuffer:metalBuffer->handle - indirectBufferOffset:offsetInBytes + (stride * i)]; + indirectBufferOffset:offset + (pitch * i)]; } METAL_INTERNAL_TrackBuffer(metalCommandBuffer, metalBuffer); @@ -2735,25 +2735,25 @@ static void METAL_DrawPrimitivesIndirect( static void METAL_DrawIndexedPrimitivesIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride) + Uint32 pitch) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalBuffer *metalBuffer = ((MetalBufferContainer *)buffer)->activeBuffer; - SDL_GPUPrimitiveType primitiveType = metalCommandBuffer->graphicsPipeline->primitiveType; + SDL_GPUPrimitiveType primitiveType = metalCommandBuffer->graphics_pipeline->primitiveType; METAL_INTERNAL_BindGraphicsResources(metalCommandBuffer); for (Uint32 i = 0; i < drawCount; i += 1) { [metalCommandBuffer->renderEncoder drawIndexedPrimitives:SDLToMetal_PrimitiveType[primitiveType] - indexType:SDLToMetal_IndexType[metalCommandBuffer->indexElementSize] + indexType:SDLToMetal_IndexType[metalCommandBuffer->index_element_size] indexBuffer:metalCommandBuffer->indexBuffer->handle indexBufferOffset:metalCommandBuffer->indexBufferOffset indirectBuffer:metalBuffer->handle - indirectBufferOffset:offsetInBytes + (stride * i)]; + indirectBufferOffset:offset + (pitch * i)]; } METAL_INTERNAL_TrackBuffer(metalCommandBuffer, metalBuffer); @@ -2791,7 +2791,7 @@ static void METAL_INTERNAL_PushUniformData( SDL_GPUShaderStage shaderStage, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { MetalUniformBuffer *metalUniformBuffer; Uint32 alignedDataLength; @@ -2820,7 +2820,7 @@ static void METAL_INTERNAL_PushUniformData( } alignedDataLength = METAL_INTERNAL_NextHighestAlignment( - dataLengthInBytes, + length, 256); if (metalUniformBuffer->writeOffset + alignedDataLength >= UNIFORM_BUFFER_SIZE) { @@ -2847,7 +2847,7 @@ static void METAL_INTERNAL_PushUniformData( SDL_memcpy( (metalUniformBuffer->handle).contents + metalUniformBuffer->writeOffset, data, - dataLengthInBytes); + length); metalUniformBuffer->writeOffset += alignedDataLength; @@ -2866,7 +2866,7 @@ static void METAL_PushVertexUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { @autoreleasepool { METAL_INTERNAL_PushUniformData( @@ -2874,7 +2874,7 @@ static void METAL_PushVertexUniformData( SDL_GPU_SHADERSTAGE_VERTEX, slotIndex, data, - dataLengthInBytes); + length); } } @@ -2882,7 +2882,7 @@ static void METAL_PushFragmentUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { @autoreleasepool { METAL_INTERNAL_PushUniformData( @@ -2890,7 +2890,7 @@ static void METAL_PushFragmentUniformData( SDL_GPU_SHADERSTAGE_FRAGMENT, slotIndex, data, - dataLengthInBytes); + length); } } @@ -2901,7 +2901,7 @@ static void METAL_Blit( const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_GPUFilter filter, bool cycle) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; @@ -2912,7 +2912,7 @@ static void METAL_Blit( source, destination, flipMode, - filterMode, + filter, cycle, renderer->blitLinearSampler, renderer->blitNearestSampler, @@ -2931,9 +2931,9 @@ static void METAL_Blit( static void METAL_BeginComputePass( SDL_GPUCommandBuffer *commandBuffer, const SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings, - Uint32 storageTextureBindingCount, + Uint32 numStorageTextureBindings, const SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings, - Uint32 storageBufferBindingCount) + Uint32 numStorageBufferBindings) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; @@ -2945,7 +2945,7 @@ static void METAL_BeginComputePass( metalCommandBuffer->computeEncoder = [metalCommandBuffer->handle computeCommandEncoder]; - for (Uint32 i = 0; i < storageTextureBindingCount; i += 1) { + for (Uint32 i = 0; i < numStorageTextureBindings; i += 1) { textureContainer = (MetalTextureContainer *)storageTextureBindings[i].texture; texture = METAL_INTERNAL_PrepareTextureForWrite( @@ -2957,14 +2957,14 @@ static void METAL_BeginComputePass( textureView = [texture->handle newTextureViewWithPixelFormat:SDLToMetal_SurfaceFormat[textureContainer->header.info.format] textureType:SDLToMetal_TextureType[textureContainer->header.info.type] - levels:NSMakeRange(storageTextureBindings[i].mipLevel, 1) + levels:NSMakeRange(storageTextureBindings[i].mip_level, 1) slices:NSMakeRange(storageTextureBindings[i].layer, 1)]; metalCommandBuffer->computeWriteOnlyTextures[i] = textureView; metalCommandBuffer->needComputeTextureBind = true; } - for (Uint32 i = 0; i < storageBufferBindingCount; i += 1) { + for (Uint32 i = 0; i < numStorageBufferBindings; i += 1) { bufferContainer = (MetalBufferContainer *)storageBufferBindings[i].buffer; buffer = METAL_INTERNAL_PrepareBufferForWrite( @@ -2990,11 +2990,11 @@ static void METAL_BindComputePipeline( MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalComputePipeline *pipeline = (MetalComputePipeline *)computePipeline; - metalCommandBuffer->computePipeline = pipeline; + metalCommandBuffer->compute_pipeline = pipeline; [metalCommandBuffer->computeEncoder setComputePipelineState:pipeline->handle]; - for (Uint32 i = 0; i < pipeline->uniformBufferCount; i += 1) { + for (Uint32 i = 0; i < pipeline->numUniformBuffers; i += 1) { if (metalCommandBuffer->computeUniformBuffers[i] == NULL) { metalCommandBuffer->computeUniformBuffers[i] = METAL_INTERNAL_AcquireUniformBufferFromPool( metalCommandBuffer); @@ -3009,12 +3009,12 @@ static void METAL_BindComputeStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalTextureContainer *textureContainer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { textureContainer = (MetalTextureContainer *)storageTextures[i]; METAL_INTERNAL_TrackTexture( @@ -3032,12 +3032,12 @@ static void METAL_BindComputeStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalBufferContainer *bufferContainer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { bufferContainer = (MetalBufferContainer *)storageBuffers[i]; METAL_INTERNAL_TrackBuffer( @@ -3055,7 +3055,7 @@ static void METAL_PushComputeUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { @autoreleasepool { METAL_INTERNAL_PushUniformData( @@ -3063,23 +3063,23 @@ static void METAL_PushComputeUniformData( SDL_GPU_SHADERSTAGE_COMPUTE, slotIndex, data, - dataLengthInBytes); + length); } } static void METAL_DispatchCompute( SDL_GPUCommandBuffer *commandBuffer, - Uint32 groupCountX, - Uint32 groupCountY, - Uint32 groupCountZ) + Uint32 groupcountX, + Uint32 groupcountY, + Uint32 groupcountZ) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; - MTLSize threadgroups = MTLSizeMake(groupCountX, groupCountY, groupCountZ); + MTLSize threadgroups = MTLSizeMake(groupcountX, groupcountY, groupcountZ); MTLSize threadsPerThreadgroup = MTLSizeMake( - metalCommandBuffer->computePipeline->threadCountX, - metalCommandBuffer->computePipeline->threadCountY, - metalCommandBuffer->computePipeline->threadCountZ); + metalCommandBuffer->compute_pipeline->threadcount_x, + metalCommandBuffer->compute_pipeline->threadcount_y, + metalCommandBuffer->compute_pipeline->threadcount_z); METAL_INTERNAL_BindComputeResources(metalCommandBuffer); @@ -3092,21 +3092,21 @@ static void METAL_DispatchCompute( static void METAL_DispatchComputeIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes) + Uint32 offset) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; MetalBuffer *metalBuffer = ((MetalBufferContainer *)buffer)->activeBuffer; MTLSize threadsPerThreadgroup = MTLSizeMake( - metalCommandBuffer->computePipeline->threadCountX, - metalCommandBuffer->computePipeline->threadCountY, - metalCommandBuffer->computePipeline->threadCountZ); + metalCommandBuffer->compute_pipeline->threadcount_x, + metalCommandBuffer->compute_pipeline->threadcount_y, + metalCommandBuffer->compute_pipeline->threadcount_z); METAL_INTERNAL_BindComputeResources(metalCommandBuffer); [metalCommandBuffer->computeEncoder dispatchThreadgroupsWithIndirectBuffer:metalBuffer->handle - indirectBufferOffset:offsetInBytes + indirectBufferOffset:offset threadsPerThreadgroup:threadsPerThreadgroup]; METAL_INTERNAL_TrackBuffer(metalCommandBuffer, metalBuffer); @@ -3299,24 +3299,24 @@ static void METAL_INTERNAL_PerformPendingDestroys( static void METAL_WaitForFences( SDL_GPURenderer *driverData, bool waitAll, - SDL_GPUFence *const *pFences, - Uint32 fenceCount) + SDL_GPUFence *const *fences, + Uint32 numFences) { @autoreleasepool { MetalRenderer *renderer = (MetalRenderer *)driverData; bool waiting; if (waitAll) { - for (Uint32 i = 0; i < fenceCount; i += 1) { - while (!SDL_AtomicGet(&((MetalFence *)pFences[i])->complete)) { + for (Uint32 i = 0; i < numFences; i += 1) { + while (!SDL_AtomicGet(&((MetalFence *)fences[i])->complete)) { // Spin! } } } else { waiting = 1; while (waiting) { - for (Uint32 i = 0; i < fenceCount; i += 1) { - if (SDL_AtomicGet(&((MetalFence *)pFences[i])->complete) > 0) { + for (Uint32 i = 0; i < numFences; i += 1) { + if (SDL_AtomicGet(&((MetalFence *)fences[i])->complete) > 0) { waiting = 0; break; } @@ -3414,10 +3414,10 @@ static Uint8 METAL_INTERNAL_CreateSwapchain( windowData->textureContainer.textureCapacity = 1; windowData->textureContainer.textureCount = 1; windowData->textureContainer.header.info.format = SwapchainCompositionToFormat[swapchainComposition]; - windowData->textureContainer.header.info.levelCount = 1; - windowData->textureContainer.header.info.layerCountOrDepth = 1; + windowData->textureContainer.header.info.num_levels = 1; + windowData->textureContainer.header.info.layer_count_or_depth = 1; windowData->textureContainer.header.info.type = SDL_GPU_TEXTURETYPE_2D; - windowData->textureContainer.header.info.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; + windowData->textureContainer.header.info.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; drawableSize = windowData->layer.drawableSize; windowData->textureContainer.header.info.width = (Uint32)drawableSize.width; @@ -3517,8 +3517,8 @@ static void METAL_ReleaseWindow( static SDL_GPUTexture *METAL_AcquireSwapchainTexture( SDL_GPUCommandBuffer *commandBuffer, SDL_Window *window, - Uint32 *pWidth, - Uint32 *pHeight) + Uint32 *w, + Uint32 *h) { @autoreleasepool { MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer; @@ -3540,8 +3540,8 @@ static SDL_GPUTexture *METAL_AcquireSwapchainTexture( windowData->textureContainer.header.info.height = (Uint32)drawableSize.height; // Send the dimensions to the out parameters. - *pWidth = (Uint32)drawableSize.width; - *pHeight = (Uint32)drawableSize.height; + *w = (Uint32)drawableSize.width; + *h = (Uint32)drawableSize.height; // Set up presentation if (metalCommandBuffer->windowDataCount == metalCommandBuffer->windowDataCapacity) { @@ -3779,17 +3779,17 @@ static bool METAL_SupportsTextureFormat( // Device Creation -static bool METAL_PrepareDriver(SDL_VideoDevice *_this) +static bool METAL_PrepareDriver(SDL_VideoDevice *this) { // FIXME: Add a macOS / iOS version check! Maybe support >= 10.14? - return (_this->Metal_CreateView != NULL); + return (this->Metal_CreateView != NULL); } static void METAL_INTERNAL_InitBlitResources( MetalRenderer *renderer) { SDL_GPUShaderCreateInfo shaderModuleCreateInfo; - SDL_GPUSamplerCreateInfo samplerCreateInfo; + SDL_GPUSamplerCreateInfo createinfo; // Allocate the dynamic blit pipeline list renderer->blitPipelineCapacity = 2; @@ -3800,10 +3800,10 @@ static void METAL_INTERNAL_InitBlitResources( // Fullscreen vertex shader SDL_zero(shaderModuleCreateInfo); shaderModuleCreateInfo.code = FullscreenVert_metallib; - shaderModuleCreateInfo.codeSize = FullscreenVert_metallib_len; + shaderModuleCreateInfo.code_size = FullscreenVert_metallib_len; shaderModuleCreateInfo.stage = SDL_GPU_SHADERSTAGE_VERTEX; shaderModuleCreateInfo.format = SDL_GPU_SHADERFORMAT_METALLIB; - shaderModuleCreateInfo.entryPointName = "FullscreenVert"; + shaderModuleCreateInfo.entrypoint = "FullscreenVert"; renderer->blitVertexShader = METAL_CreateShader( (SDL_GPURenderer *)renderer, @@ -3815,11 +3815,11 @@ static void METAL_INTERNAL_InitBlitResources( // BlitFrom2D fragment shader shaderModuleCreateInfo.code = BlitFrom2D_metallib; - shaderModuleCreateInfo.codeSize = BlitFrom2D_metallib_len; + shaderModuleCreateInfo.code_size = BlitFrom2D_metallib_len; shaderModuleCreateInfo.stage = SDL_GPU_SHADERSTAGE_FRAGMENT; - shaderModuleCreateInfo.entryPointName = "BlitFrom2D"; - shaderModuleCreateInfo.samplerCount = 1; - shaderModuleCreateInfo.uniformBufferCount = 1; + shaderModuleCreateInfo.entrypoint = "BlitFrom2D"; + shaderModuleCreateInfo.num_samplers = 1; + shaderModuleCreateInfo.num_uniform_buffers = 1; renderer->blitFrom2DShader = METAL_CreateShader( (SDL_GPURenderer *)renderer, @@ -3831,8 +3831,8 @@ static void METAL_INTERNAL_InitBlitResources( // BlitFrom2DArray fragment shader shaderModuleCreateInfo.code = BlitFrom2DArray_metallib; - shaderModuleCreateInfo.codeSize = BlitFrom2DArray_metallib_len; - shaderModuleCreateInfo.entryPointName = "BlitFrom2DArray"; + shaderModuleCreateInfo.code_size = BlitFrom2DArray_metallib_len; + shaderModuleCreateInfo.entrypoint = "BlitFrom2DArray"; renderer->blitFrom2DArrayShader = METAL_CreateShader( (SDL_GPURenderer *)renderer, @@ -3844,8 +3844,8 @@ static void METAL_INTERNAL_InitBlitResources( // BlitFrom3D fragment shader shaderModuleCreateInfo.code = BlitFrom3D_metallib; - shaderModuleCreateInfo.codeSize = BlitFrom3D_metallib_len; - shaderModuleCreateInfo.entryPointName = "BlitFrom3D"; + shaderModuleCreateInfo.code_size = BlitFrom3D_metallib_len; + shaderModuleCreateInfo.entrypoint = "BlitFrom3D"; renderer->blitFrom3DShader = METAL_CreateShader( (SDL_GPURenderer *)renderer, @@ -3857,8 +3857,8 @@ static void METAL_INTERNAL_InitBlitResources( // BlitFromCube fragment shader shaderModuleCreateInfo.code = BlitFromCube_metallib; - shaderModuleCreateInfo.codeSize = BlitFromCube_metallib_len; - shaderModuleCreateInfo.entryPointName = "BlitFromCube"; + shaderModuleCreateInfo.code_size = BlitFromCube_metallib_len; + shaderModuleCreateInfo.entrypoint = "BlitFromCube"; renderer->blitFromCubeShader = METAL_CreateShader( (SDL_GPURenderer *)renderer, @@ -3869,35 +3869,35 @@ static void METAL_INTERNAL_InitBlitResources( } // Create samplers - samplerCreateInfo.addressModeU = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.addressModeV = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.addressModeW = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - samplerCreateInfo.anisotropyEnable = 0; - samplerCreateInfo.compareEnable = 0; - samplerCreateInfo.magFilter = SDL_GPU_FILTER_NEAREST; - samplerCreateInfo.minFilter = SDL_GPU_FILTER_NEAREST; - samplerCreateInfo.mipmapMode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST; - samplerCreateInfo.mipLodBias = 0.0f; - samplerCreateInfo.minLod = 0; - samplerCreateInfo.maxLod = 1000; - samplerCreateInfo.maxAnisotropy = 1.0f; - samplerCreateInfo.compareOp = SDL_GPU_COMPAREOP_ALWAYS; + createinfo.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + createinfo.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + createinfo.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + createinfo.enable_anisotropy = 0; + createinfo.enable_compare = 0; + createinfo.mag_filter = SDL_GPU_FILTER_NEAREST; + createinfo.min_filter = SDL_GPU_FILTER_NEAREST; + createinfo.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST; + createinfo.mip_lod_bias = 0.0f; + createinfo.min_lod = 0; + createinfo.max_lod = 1000; + createinfo.max_anisotropy = 1.0f; + createinfo.compare_op = SDL_GPU_COMPAREOP_ALWAYS; renderer->blitNearestSampler = METAL_CreateSampler( (SDL_GPURenderer *)renderer, - &samplerCreateInfo); + &createinfo); if (renderer->blitNearestSampler == NULL) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Failed to create blit nearest sampler!"); } - samplerCreateInfo.magFilter = SDL_GPU_FILTER_LINEAR; - samplerCreateInfo.minFilter = SDL_GPU_FILTER_LINEAR; - samplerCreateInfo.mipmapMode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR; + createinfo.mag_filter = SDL_GPU_FILTER_LINEAR; + createinfo.min_filter = SDL_GPU_FILTER_LINEAR; + createinfo.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR; renderer->blitLinearSampler = METAL_CreateSampler( (SDL_GPURenderer *)renderer, - &samplerCreateInfo); + &createinfo); if (renderer->blitLinearSampler == NULL) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Failed to create blit linear sampler!"); @@ -3955,7 +3955,7 @@ static SDL_GPUDevice *METAL_CreateDevice(bool debugMode, bool preferLowPower, SD [renderer->device.name UTF8String]); // Remember debug mode - renderer->debugMode = debugMode; + renderer->debug_mode = debugMode; // Set up colorspace array SwapchainCompositionToColorSpace[0] = kCGColorSpaceSRGB; diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index 8fcea98422..ae6bd91301 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -630,11 +630,11 @@ typedef struct VulkanSampler typedef struct VulkanShader { VkShaderModule shaderModule; - const char *entryPointName; - Uint32 samplerCount; - Uint32 storageTextureCount; - Uint32 storageBufferCount; - Uint32 uniformBufferCount; + const char *entrypointName; + Uint32 numSamplers; + Uint32 numStorageTextures; + Uint32 numStorageBuffers; + Uint32 numUniformBuffers; SDL_AtomicInt referenceCount; } VulkanShader; @@ -675,7 +675,7 @@ struct VulkanTexture Uint32 depth; Uint32 layerCount; - Uint32 levelCount; + Uint32 numLevels; VkSampleCountFlagBits sampleCount; // NOTE: This refers to the sample count of a render target pass using this texture, not the actual sample count of the texture VkFormat format; VkComponentMapping swizzle; @@ -886,11 +886,11 @@ typedef struct VulkanComputePipelineResourceLayout */ DescriptorSetPool descriptorSetPools[3]; - Uint32 readOnlyStorageTextureCount; - Uint32 readOnlyStorageBufferCount; - Uint32 writeOnlyStorageTextureCount; - Uint32 writeOnlyStorageBufferCount; - Uint32 uniformBufferCount; + Uint32 numReadonlyStorageTextures; + Uint32 numReadonlyStorageBuffers; + Uint32 numWriteonlyStorageTextures; + Uint32 numWriteonlyStorageBuffers; + Uint32 numUniformBuffers; } VulkanComputePipelineResourceLayout; typedef struct VulkanComputePipeline @@ -925,7 +925,7 @@ typedef struct CommandPoolHashTableKey typedef struct RenderPassHashTableKey { RenderPassColorTargetDescription colorTargetDescriptions[MAX_COLOR_TARGET_BINDINGS]; - Uint32 colorAttachmentCount; + Uint32 numColorTargets; RenderPassDepthStencilTargetDescription depthStencilTargetDescription; VkSampleCountFlagBits colorAttachmentSampleCount; } RenderPassHashTableKey; @@ -939,7 +939,7 @@ typedef struct FramebufferHashTableKey { VkImageView colorAttachmentViews[MAX_COLOR_TARGET_BINDINGS]; VkImageView colorMultiSampleAttachmentViews[MAX_COLOR_TARGET_BINDINGS]; - Uint32 colorAttachmentCount; + Uint32 numColorTargets; VkImageView depthStencilAttachmentView; Uint32 width; Uint32 height; @@ -1208,7 +1208,7 @@ static Uint8 VULKAN_INTERNAL_DefragmentMemory(VulkanRenderer *renderer); static void VULKAN_INTERNAL_BeginCommandBuffer(VulkanRenderer *renderer, VulkanCommandBuffer *commandBuffer); static void VULKAN_ReleaseWindow(SDL_GPURenderer *driverData, SDL_Window *window); static void VULKAN_Wait(SDL_GPURenderer *driverData); -static void VULKAN_WaitForFences(SDL_GPURenderer *driverData, bool waitAll, SDL_GPUFence *const *pFences, Uint32 fenceCount); +static void VULKAN_WaitForFences(SDL_GPURenderer *driverData, bool waitAll, SDL_GPUFence *const *fences, Uint32 numFences); static void VULKAN_Submit(SDL_GPUCommandBuffer *commandBuffer); static VulkanTexture *VULKAN_INTERNAL_CreateTexture( VulkanRenderer *renderer, @@ -1217,7 +1217,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture( Uint32 depth, SDL_GPUTextureType type, Uint32 layerCount, - Uint32 levelCount, + Uint32 numLevels, VkSampleCountFlagBits sampleCount, VkFormat format, VkComponentMapping swizzle, @@ -2953,7 +2953,7 @@ static void VULKAN_INTERNAL_RemoveFramebuffersContainingView( while (SDL_IterateHashTable(renderer->framebufferHashTable, (const void **)&key, (const void **)&value, &iter)) { bool remove = false; - for (Uint32 i = 0; i < key->colorAttachmentCount; i += 1) { + for (Uint32 i = 0; i < key->numColorTargets; i += 1) { if (key->colorAttachmentViews[i] == view) { remove = true; } @@ -3192,7 +3192,7 @@ static void VULKAN_INTERNAL_DestroyShader( vulkanShader->shaderModule, NULL); - SDL_free((void *)vulkanShader->entryPointName); + SDL_free((void *)vulkanShader->entrypointName); SDL_free(vulkanShader); } @@ -3300,22 +3300,22 @@ static Uint32 VULKAN_INTERNAL_RenderPassHashFunction( * is taken from Josh Bloch's "Effective Java". * (https://stackoverflow.com/a/113600/12492383) */ - const Uint32 HASH_FACTOR = 31; + const Uint32 hashFactor = 31; Uint32 result = 1; - for (Uint32 i = 0; i < hashTableKey->colorAttachmentCount; i += 1) { - result = result * HASH_FACTOR + hashTableKey->colorTargetDescriptions[i].loadOp; - result = result * HASH_FACTOR + hashTableKey->colorTargetDescriptions[i].storeOp; - result = result * HASH_FACTOR + hashTableKey->colorTargetDescriptions[i].format; + for (Uint32 i = 0; i < hashTableKey->numColorTargets; i += 1) { + result = result * hashFactor + hashTableKey->colorTargetDescriptions[i].loadOp; + result = result * hashFactor + hashTableKey->colorTargetDescriptions[i].storeOp; + result = result * hashFactor + hashTableKey->colorTargetDescriptions[i].format; } - result = result * HASH_FACTOR + hashTableKey->depthStencilTargetDescription.loadOp; - result = result * HASH_FACTOR + hashTableKey->depthStencilTargetDescription.storeOp; - result = result * HASH_FACTOR + hashTableKey->depthStencilTargetDescription.stencilLoadOp; - result = result * HASH_FACTOR + hashTableKey->depthStencilTargetDescription.stencilStoreOp; - result = result * HASH_FACTOR + hashTableKey->depthStencilTargetDescription.format; + result = result * hashFactor + hashTableKey->depthStencilTargetDescription.loadOp; + result = result * hashFactor + hashTableKey->depthStencilTargetDescription.storeOp; + result = result * hashFactor + hashTableKey->depthStencilTargetDescription.stencilLoadOp; + result = result * hashFactor + hashTableKey->depthStencilTargetDescription.stencilStoreOp; + result = result * hashFactor + hashTableKey->depthStencilTargetDescription.format; - result = result * HASH_FACTOR + hashTableKey->colorAttachmentSampleCount; + result = result * hashFactor + hashTableKey->colorAttachmentSampleCount; return result; } @@ -3328,7 +3328,7 @@ static bool VULKAN_INTERNAL_RenderPassHashKeyMatch( RenderPassHashTableKey *a = (RenderPassHashTableKey *)aKey; RenderPassHashTableKey *b = (RenderPassHashTableKey *)bKey; - if (a->colorAttachmentCount != b->colorAttachmentCount) { + if (a->numColorTargets != b->numColorTargets) { return 0; } @@ -3336,7 +3336,7 @@ static bool VULKAN_INTERNAL_RenderPassHashKeyMatch( return 0; } - for (Uint32 i = 0; i < a->colorAttachmentCount; i += 1) { + for (Uint32 i = 0; i < a->numColorTargets; i += 1) { if (a->colorTargetDescriptions[i].format != b->colorTargetDescriptions[i].format) { return 0; } @@ -3395,17 +3395,17 @@ static Uint32 VULKAN_INTERNAL_FramebufferHashFunction( * is taken from Josh Bloch's "Effective Java". * (https://stackoverflow.com/a/113600/12492383) */ - const Uint32 HASH_FACTOR = 31; + const Uint32 hashFactor = 31; Uint32 result = 1; - for (Uint32 i = 0; i < hashTableKey->colorAttachmentCount; i += 1) { - result = result * HASH_FACTOR + (Uint32)(uintptr_t)hashTableKey->colorAttachmentViews[i]; - result = result * HASH_FACTOR + (Uint32)(uintptr_t)hashTableKey->colorMultiSampleAttachmentViews[i]; + for (Uint32 i = 0; i < hashTableKey->numColorTargets; i += 1) { + result = result * hashFactor + (Uint32)(uintptr_t)hashTableKey->colorAttachmentViews[i]; + result = result * hashFactor + (Uint32)(uintptr_t)hashTableKey->colorMultiSampleAttachmentViews[i]; } - result = result * HASH_FACTOR + (Uint32)(uintptr_t)hashTableKey->depthStencilAttachmentView; - result = result * HASH_FACTOR + hashTableKey->width; - result = result * HASH_FACTOR + hashTableKey->height; + result = result * hashFactor + (Uint32)(uintptr_t)hashTableKey->depthStencilAttachmentView; + result = result * hashFactor + hashTableKey->width; + result = result * hashFactor + hashTableKey->height; return result; } @@ -3418,11 +3418,11 @@ static bool VULKAN_INTERNAL_FramebufferHashKeyMatch( FramebufferHashTableKey *a = (FramebufferHashTableKey *)aKey; FramebufferHashTableKey *b = (FramebufferHashTableKey *)bKey; - if (a->colorAttachmentCount != b->colorAttachmentCount) { + if (a->numColorTargets != b->numColorTargets) { return 0; } - for (Uint32 i = 0; i < a->colorAttachmentCount; i += 1) { + for (Uint32 i = 0; i < a->numColorTargets; i += 1) { if (a->colorAttachmentViews[i] != b->colorAttachmentViews[i]) { return 0; } @@ -3586,15 +3586,15 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( VkResult vulkanResult; Uint32 i; - pipelineResourceLayout->vertexSamplerCount = vertexShader->samplerCount; - pipelineResourceLayout->vertexStorageTextureCount = vertexShader->storageTextureCount; - pipelineResourceLayout->vertexStorageBufferCount = vertexShader->storageBufferCount; - pipelineResourceLayout->vertexUniformBufferCount = vertexShader->uniformBufferCount; + pipelineResourceLayout->vertexSamplerCount = vertexShader->numSamplers; + pipelineResourceLayout->vertexStorageTextureCount = vertexShader->numStorageTextures; + pipelineResourceLayout->vertexStorageBufferCount = vertexShader->numStorageBuffers; + pipelineResourceLayout->vertexUniformBufferCount = vertexShader->numUniformBuffers; - pipelineResourceLayout->fragmentSamplerCount = fragmentShader->samplerCount; - pipelineResourceLayout->fragmentStorageTextureCount = fragmentShader->storageTextureCount; - pipelineResourceLayout->fragmentStorageBufferCount = fragmentShader->storageBufferCount; - pipelineResourceLayout->fragmentUniformBufferCount = fragmentShader->uniformBufferCount; + pipelineResourceLayout->fragmentSamplerCount = fragmentShader->numSamplers; + pipelineResourceLayout->fragmentStorageTextureCount = fragmentShader->numStorageTextures; + pipelineResourceLayout->fragmentStorageBufferCount = fragmentShader->numStorageBuffers; + pipelineResourceLayout->fragmentUniformBufferCount = fragmentShader->numUniformBuffers; // Vertex Resources @@ -3603,9 +3603,9 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetLayoutCreateInfo.flags = 0; descriptorSetLayoutCreateInfo.pBindings = NULL; descriptorSetLayoutCreateInfo.bindingCount = - vertexShader->samplerCount + - vertexShader->storageTextureCount + - vertexShader->storageBufferCount; + vertexShader->numSamplers + + vertexShader->numStorageTextures + + vertexShader->numStorageBuffers; descriptorSetPool = &pipelineResourceLayout->descriptorSetPools[0]; @@ -3616,7 +3616,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool->descriptorInfos = SDL_malloc( descriptorSetPool->descriptorInfoCount * sizeof(VulkanDescriptorInfo)); - for (i = 0; i < vertexShader->samplerCount; i += 1) { + for (i = 0; i < vertexShader->numSamplers; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; @@ -3627,7 +3627,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool->descriptorInfos[i].stageFlag = VK_SHADER_STAGE_VERTEX_BIT; } - for (i = vertexShader->samplerCount; i < vertexShader->samplerCount + vertexShader->storageTextureCount; i += 1) { + for (i = vertexShader->numSamplers; i < vertexShader->numSamplers + vertexShader->numStorageTextures; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; @@ -3638,7 +3638,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool->descriptorInfos[i].stageFlag = VK_SHADER_STAGE_VERTEX_BIT; } - for (i = vertexShader->samplerCount + vertexShader->storageTextureCount; i < descriptorSetLayoutCreateInfo.bindingCount; i += 1) { + for (i = vertexShader->numSamplers + vertexShader->numStorageTextures; i < descriptorSetLayoutCreateInfo.bindingCount; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; @@ -3679,7 +3679,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool->descriptorInfos = SDL_malloc( descriptorSetPool->descriptorInfoCount * sizeof(VulkanDescriptorInfo)); - for (i = 0; i < vertexShader->uniformBufferCount; i += 1) { + for (i = 0; i < vertexShader->numUniformBuffers; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; @@ -3711,9 +3711,9 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool = &pipelineResourceLayout->descriptorSetPools[2]; descriptorSetLayoutCreateInfo.bindingCount = - fragmentShader->samplerCount + - fragmentShader->storageTextureCount + - fragmentShader->storageBufferCount; + fragmentShader->numSamplers + + fragmentShader->numStorageTextures + + fragmentShader->numStorageBuffers; descriptorSetLayoutCreateInfo.pBindings = NULL; @@ -3724,7 +3724,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool->descriptorInfos = SDL_malloc( descriptorSetPool->descriptorInfoCount * sizeof(VulkanDescriptorInfo)); - for (i = 0; i < fragmentShader->samplerCount; i += 1) { + for (i = 0; i < fragmentShader->numSamplers; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; @@ -3735,7 +3735,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool->descriptorInfos[i].stageFlag = VK_SHADER_STAGE_FRAGMENT_BIT; } - for (i = fragmentShader->samplerCount; i < fragmentShader->samplerCount + fragmentShader->storageTextureCount; i += 1) { + for (i = fragmentShader->numSamplers; i < fragmentShader->numSamplers + fragmentShader->numStorageTextures; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; @@ -3746,7 +3746,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool->descriptorInfos[i].stageFlag = VK_SHADER_STAGE_FRAGMENT_BIT; } - for (i = fragmentShader->samplerCount + fragmentShader->storageTextureCount; i < descriptorSetLayoutCreateInfo.bindingCount; i += 1) { + for (i = fragmentShader->numSamplers + fragmentShader->numStorageTextures; i < descriptorSetLayoutCreateInfo.bindingCount; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; @@ -3789,7 +3789,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( descriptorSetPool->descriptorInfos = SDL_malloc( descriptorSetPool->descriptorInfoCount * sizeof(VulkanDescriptorInfo)); - for (i = 0; i < fragmentShader->uniformBufferCount; i += 1) { + for (i = 0; i < fragmentShader->numUniformBuffers; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; @@ -3848,7 +3848,7 @@ static bool VULKAN_INTERNAL_InitializeGraphicsPipelineResourceLayout( static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( VulkanRenderer *renderer, - const SDL_GPUComputePipelineCreateInfo *pipelineCreateInfo, + const SDL_GPUComputePipelineCreateInfo *createinfo, VulkanComputePipelineResourceLayout *pipelineResourceLayout) { VkDescriptorSetLayoutBinding descriptorSetLayoutBindings[MAX_UNIFORM_BUFFERS_PER_STAGE]; @@ -3859,11 +3859,11 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( VkResult vulkanResult; Uint32 i; - pipelineResourceLayout->readOnlyStorageTextureCount = pipelineCreateInfo->readOnlyStorageTextureCount; - pipelineResourceLayout->readOnlyStorageBufferCount = pipelineCreateInfo->readOnlyStorageBufferCount; - pipelineResourceLayout->writeOnlyStorageTextureCount = pipelineCreateInfo->writeOnlyStorageTextureCount; - pipelineResourceLayout->writeOnlyStorageBufferCount = pipelineCreateInfo->writeOnlyStorageBufferCount; - pipelineResourceLayout->uniformBufferCount = pipelineCreateInfo->uniformBufferCount; + pipelineResourceLayout->numReadonlyStorageTextures = createinfo->num_readonly_storage_textures; + pipelineResourceLayout->numReadonlyStorageBuffers = createinfo->num_readonly_storage_buffers; + pipelineResourceLayout->numWriteonlyStorageTextures = createinfo->num_writeonly_storage_textures; + pipelineResourceLayout->numWriteonlyStorageBuffers = createinfo->num_writeonly_storage_buffers; + pipelineResourceLayout->numUniformBuffers = createinfo->num_uniform_buffers; // Read-only resources @@ -3872,8 +3872,8 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( descriptorSetLayoutCreateInfo.flags = 0; descriptorSetLayoutCreateInfo.pBindings = NULL; descriptorSetLayoutCreateInfo.bindingCount = - pipelineCreateInfo->readOnlyStorageTextureCount + - pipelineCreateInfo->readOnlyStorageBufferCount; + createinfo->num_readonly_storage_textures + + createinfo->num_readonly_storage_buffers; descriptorSetPool = &pipelineResourceLayout->descriptorSetPools[0]; @@ -3884,7 +3884,7 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( descriptorSetPool->descriptorInfos = SDL_malloc( descriptorSetPool->descriptorInfoCount * sizeof(VulkanDescriptorInfo)); - for (i = 0; i < pipelineCreateInfo->readOnlyStorageTextureCount; i += 1) { + for (i = 0; i < createinfo->num_readonly_storage_textures; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; @@ -3895,7 +3895,7 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( descriptorSetPool->descriptorInfos[i].stageFlag = VK_SHADER_STAGE_COMPUTE_BIT; } - for (i = pipelineCreateInfo->readOnlyStorageTextureCount; i < descriptorSetLayoutCreateInfo.bindingCount; i += 1) { + for (i = createinfo->num_readonly_storage_textures; i < descriptorSetLayoutCreateInfo.bindingCount; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; @@ -3925,8 +3925,8 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( // Write-only resources descriptorSetLayoutCreateInfo.bindingCount = - pipelineCreateInfo->writeOnlyStorageTextureCount + - pipelineCreateInfo->writeOnlyStorageBufferCount; + createinfo->num_writeonly_storage_textures + + createinfo->num_writeonly_storage_buffers; descriptorSetLayoutCreateInfo.pBindings = NULL; @@ -3939,7 +3939,7 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( descriptorSetPool->descriptorInfos = SDL_malloc( descriptorSetPool->descriptorInfoCount * sizeof(VulkanDescriptorInfo)); - for (i = 0; i < pipelineCreateInfo->writeOnlyStorageTextureCount; i += 1) { + for (i = 0; i < createinfo->num_writeonly_storage_textures; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; @@ -3950,7 +3950,7 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( descriptorSetPool->descriptorInfos[i].stageFlag = VK_SHADER_STAGE_COMPUTE_BIT; } - for (i = pipelineCreateInfo->writeOnlyStorageTextureCount; i < descriptorSetLayoutCreateInfo.bindingCount; i += 1) { + for (i = createinfo->num_writeonly_storage_textures; i < descriptorSetLayoutCreateInfo.bindingCount; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; @@ -3981,7 +3981,7 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( descriptorSetPool = &pipelineResourceLayout->descriptorSetPools[2]; - descriptorSetLayoutCreateInfo.bindingCount = pipelineCreateInfo->uniformBufferCount; + descriptorSetLayoutCreateInfo.bindingCount = createinfo->num_uniform_buffers; descriptorSetLayoutCreateInfo.pBindings = NULL; descriptorSetPool->descriptorInfoCount = descriptorSetLayoutCreateInfo.bindingCount; @@ -3991,7 +3991,7 @@ static bool VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( descriptorSetPool->descriptorInfos = SDL_malloc( descriptorSetPool->descriptorInfoCount * sizeof(VulkanDescriptorInfo)); - for (i = 0; i < pipelineCreateInfo->uniformBufferCount; i += 1) { + for (i = 0; i < createinfo->num_uniform_buffers; i += 1) { descriptorSetLayoutBindings[i].binding = i; descriptorSetLayoutBindings[i].descriptorCount = 1; descriptorSetLayoutBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; @@ -4058,7 +4058,7 @@ static VulkanBuffer *VULKAN_INTERNAL_CreateBuffer( { VulkanBuffer *buffer; VkResult vulkanResult; - VkBufferCreateInfo bufferCreateInfo; + VkBufferCreateInfo createinfo; VkBufferUsageFlags vulkanUsageFlags = 0; Uint8 bindResult; @@ -4095,21 +4095,21 @@ static VulkanBuffer *VULKAN_INTERNAL_CreateBuffer( buffer->markedForDestroy = 0; buffer->transitioned = false; - bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - bufferCreateInfo.pNext = NULL; - bufferCreateInfo.flags = 0; - bufferCreateInfo.size = size; - bufferCreateInfo.usage = vulkanUsageFlags; - bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - bufferCreateInfo.queueFamilyIndexCount = 1; - bufferCreateInfo.pQueueFamilyIndices = &renderer->queueFamilyIndex; + createinfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + createinfo.pNext = NULL; + createinfo.flags = 0; + createinfo.size = size; + createinfo.usage = vulkanUsageFlags; + createinfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + createinfo.queueFamilyIndexCount = 1; + createinfo.pQueueFamilyIndices = &renderer->queueFamilyIndex; // Set transfer bits so we can defrag - bufferCreateInfo.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + createinfo.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; vulkanResult = renderer->vkCreateBuffer( renderer->logicalDevice, - &bufferCreateInfo, + &createinfo, NULL, &buffer->buffer); VULKAN_ERROR_CHECK(vulkanResult, vkCreateBuffer, 0) @@ -4141,7 +4141,7 @@ static VulkanBuffer *VULKAN_INTERNAL_CreateBuffer( // Indirection so we can cleanly defrag buffers static VulkanBufferHandle *VULKAN_INTERNAL_CreateBufferHandle( VulkanRenderer *renderer, - VkDeviceSize sizeInBytes, + VkDeviceSize size, SDL_GPUBufferUsageFlags usageFlags, VulkanBufferType type) { @@ -4150,7 +4150,7 @@ static VulkanBufferHandle *VULKAN_INTERNAL_CreateBufferHandle( buffer = VULKAN_INTERNAL_CreateBuffer( renderer, - sizeInBytes, + size, usageFlags, type); @@ -4170,7 +4170,7 @@ static VulkanBufferHandle *VULKAN_INTERNAL_CreateBufferHandle( static VulkanBufferContainer *VULKAN_INTERNAL_CreateBufferContainer( VulkanRenderer *renderer, - VkDeviceSize sizeInBytes, + VkDeviceSize size, SDL_GPUBufferUsageFlags usageFlags, VulkanBufferType type) { @@ -4179,7 +4179,7 @@ static VulkanBufferContainer *VULKAN_INTERNAL_CreateBufferContainer( bufferHandle = VULKAN_INTERNAL_CreateBufferHandle( renderer, - sizeInBytes, + size, usageFlags, type); @@ -4221,7 +4221,7 @@ static VulkanTextureSubresource *VULKAN_INTERNAL_FetchTextureSubresource( Uint32 index = VULKAN_INTERNAL_GetTextureSubresourceIndex( level, layer, - textureContainer->header.info.levelCount); + textureContainer->header.info.num_levels); return &textureContainer->activeTextureHandle->vulkanTexture->subresources[index]; } @@ -4461,17 +4461,17 @@ static bool VULKAN_INTERNAL_CreateSwapchain( bool hasValidSwapchainComposition, hasValidPresentMode; Sint32 drawableWidth, drawableHeight; Uint32 i; - SDL_VideoDevice *_this = SDL_GetVideoDevice(); + SDL_VideoDevice *this = SDL_GetVideoDevice(); - SDL_assert(_this && _this->Vulkan_CreateSurface); + SDL_assert(this && this->Vulkan_CreateSurface); swapchainData = SDL_malloc(sizeof(VulkanSwapchainData)); swapchainData->frameCounter = 0; // Each swapchain must have its own surface. - if (!_this->Vulkan_CreateSurface( - _this, + if (!this->Vulkan_CreateSurface( + this, windowData->window, renderer->instance, NULL, // FIXME: VAllocationCallbacks @@ -4571,7 +4571,7 @@ static bool VULKAN_INTERNAL_CreateSwapchain( SDL_LogError(SDL_LOG_CATEGORY_GPU, "Device does not support requested swapchain composition!"); } if (!hasValidPresentMode) { - SDL_LogError(SDL_LOG_CATEGORY_GPU, "Device does not support requested presentMode!"); + SDL_LogError(SDL_LOG_CATEGORY_GPU, "Device does not support requested present_mode!"); } return false; } @@ -4712,14 +4712,14 @@ static bool VULKAN_INTERNAL_CreateSwapchain( swapchainData->textureContainers[i].canBeCycled = false; swapchainData->textureContainers[i].header.info.width = drawableWidth; swapchainData->textureContainers[i].header.info.height = drawableHeight; - swapchainData->textureContainers[i].header.info.layerCountOrDepth = 1; + swapchainData->textureContainers[i].header.info.layer_count_or_depth = 1; swapchainData->textureContainers[i].header.info.format = SwapchainCompositionToSDLFormat( windowData->swapchainComposition, swapchainData->usingFallbackFormat); swapchainData->textureContainers[i].header.info.type = SDL_GPU_TEXTURETYPE_2D; - swapchainData->textureContainers[i].header.info.levelCount = 1; - swapchainData->textureContainers[i].header.info.sampleCount = SDL_GPU_SAMPLECOUNT_1; - swapchainData->textureContainers[i].header.info.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; + swapchainData->textureContainers[i].header.info.num_levels = 1; + swapchainData->textureContainers[i].header.info.sample_count = SDL_GPU_SAMPLECOUNT_1; + swapchainData->textureContainers[i].header.info.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; swapchainData->textureContainers[i].activeTextureHandle = SDL_malloc(sizeof(VulkanTextureHandle)); @@ -4737,7 +4737,7 @@ static bool VULKAN_INTERNAL_CreateSwapchain( swapchainData->textureContainers[i].activeTextureHandle->vulkanTexture->type = SDL_GPU_TEXTURETYPE_2D; swapchainData->textureContainers[i].activeTextureHandle->vulkanTexture->depth = 1; swapchainData->textureContainers[i].activeTextureHandle->vulkanTexture->layerCount = 1; - swapchainData->textureContainers[i].activeTextureHandle->vulkanTexture->levelCount = 1; + swapchainData->textureContainers[i].activeTextureHandle->vulkanTexture->numLevels = 1; swapchainData->textureContainers[i].activeTextureHandle->vulkanTexture->sampleCount = VK_SAMPLE_COUNT_1_BIT; swapchainData->textureContainers[i].activeTextureHandle->vulkanTexture->usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET; @@ -5351,8 +5351,8 @@ static void VULKAN_INTERNAL_BindGraphicsDescriptorSets( static void VULKAN_DrawIndexedPrimitives( SDL_GPUCommandBuffer *commandBuffer, - Uint32 indexCount, - Uint32 instanceCount, + Uint32 numIndices, + Uint32 numInstances, Uint32 firstIndex, Sint32 vertexOffset, Uint32 firstInstance) @@ -5364,8 +5364,8 @@ static void VULKAN_DrawIndexedPrimitives( renderer->vkCmdDrawIndexed( vulkanCommandBuffer->commandBuffer, - indexCount, - instanceCount, + numIndices, + numInstances, firstIndex, vertexOffset, firstInstance); @@ -5373,8 +5373,8 @@ static void VULKAN_DrawIndexedPrimitives( static void VULKAN_DrawPrimitives( SDL_GPUCommandBuffer *commandBuffer, - Uint32 vertexCount, - Uint32 instanceCount, + Uint32 numVertices, + Uint32 numInstances, Uint32 firstVertex, Uint32 firstInstance) { @@ -5385,8 +5385,8 @@ static void VULKAN_DrawPrimitives( renderer->vkCmdDraw( vulkanCommandBuffer->commandBuffer, - vertexCount, - instanceCount, + numVertices, + numInstances, firstVertex, firstInstance); } @@ -5394,9 +5394,9 @@ static void VULKAN_DrawPrimitives( static void VULKAN_DrawPrimitivesIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride) + Uint32 pitch) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; @@ -5410,18 +5410,18 @@ static void VULKAN_DrawPrimitivesIndirect( renderer->vkCmdDrawIndirect( vulkanCommandBuffer->commandBuffer, vulkanBuffer->buffer, - offsetInBytes, + offset, drawCount, - stride); + pitch); } else { // Fake multi-draw... for (i = 0; i < drawCount; i += 1) { renderer->vkCmdDrawIndirect( vulkanCommandBuffer->commandBuffer, vulkanBuffer->buffer, - offsetInBytes + (stride * i), + offset + (pitch * i), 1, - stride); + pitch); } } @@ -5431,9 +5431,9 @@ static void VULKAN_DrawPrimitivesIndirect( static void VULKAN_DrawIndexedPrimitivesIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes, + Uint32 offset, Uint32 drawCount, - Uint32 stride) + Uint32 pitch) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; @@ -5447,18 +5447,18 @@ static void VULKAN_DrawIndexedPrimitivesIndirect( renderer->vkCmdDrawIndexedIndirect( vulkanCommandBuffer->commandBuffer, vulkanBuffer->buffer, - offsetInBytes, + offset, drawCount, - stride); + pitch); } else { // Fake multi-draw... for (i = 0; i < drawCount; i += 1) { renderer->vkCmdDrawIndexedIndirect( vulkanCommandBuffer->commandBuffer, vulkanBuffer->buffer, - offsetInBytes + (stride * i), + offset + (pitch * i), 1, - stride); + pitch); } } @@ -5619,7 +5619,7 @@ static VulkanTextureHandle *VULKAN_INTERNAL_CreateTextureHandle( Uint32 depth, SDL_GPUTextureType type, Uint32 layerCount, - Uint32 levelCount, + Uint32 numLevels, VkSampleCountFlagBits sampleCount, VkFormat format, VkComponentMapping swizzle, @@ -5637,7 +5637,7 @@ static VulkanTextureHandle *VULKAN_INTERNAL_CreateTextureHandle( depth, type, layerCount, - levelCount, + numLevels, sampleCount, format, swizzle, @@ -5666,7 +5666,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture( Uint32 depth, SDL_GPUTextureType type, Uint32 layerCount, - Uint32 levelCount, + Uint32 numLevels, VkSampleCountFlagBits sampleCount, VkFormat format, VkComponentMapping swizzle, @@ -5718,7 +5718,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture( imageCreateInfo.extent.width = width; imageCreateInfo.extent.height = height; imageCreateInfo.extent.depth = depth; - imageCreateInfo.mipLevels = levelCount; + imageCreateInfo.mipLevels = numLevels; imageCreateInfo.arrayLayers = layerCount; imageCreateInfo.samples = isMSAAColorTarget || VULKAN_INTERNAL_IsVulkanDepthFormat(format) ? sampleCount : VK_SAMPLE_COUNT_1_BIT; imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL; @@ -5767,7 +5767,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture( imageViewCreateInfo.components = swizzle; imageViewCreateInfo.subresourceRange.aspectMask = aspectMask; imageViewCreateInfo.subresourceRange.baseMipLevel = 0; - imageViewCreateInfo.subresourceRange.levelCount = levelCount; + imageViewCreateInfo.subresourceRange.levelCount = numLevels; imageViewCreateInfo.subresourceRange.baseArrayLayer = 0; imageViewCreateInfo.subresourceRange.layerCount = layerCount; @@ -5799,7 +5799,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture( texture->depth = depth; texture->format = format; texture->swizzle = swizzle; - texture->levelCount = levelCount; + texture->numLevels = numLevels; texture->layerCount = layerCount; texture->sampleCount = sampleCount; texture->usageFlags = textureUsageFlags; @@ -5809,17 +5809,17 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture( // Define slices texture->subresourceCount = texture->layerCount * - texture->levelCount; + texture->numLevels; texture->subresources = SDL_malloc( texture->subresourceCount * sizeof(VulkanTextureSubresource)); for (Uint32 i = 0; i < texture->layerCount; i += 1) { - for (Uint32 j = 0; j < texture->levelCount; j += 1) { + for (Uint32 j = 0; j < texture->numLevels; j += 1) { Uint32 subresourceIndex = VULKAN_INTERNAL_GetTextureSubresourceIndex( j, i, - texture->levelCount); + texture->numLevels); texture->subresources[subresourceIndex].renderTargetViews = NULL; texture->subresources[subresourceIndex].computeWriteView = VK_NULL_HANDLE; @@ -5970,7 +5970,7 @@ static void VULKAN_INTERNAL_CycleActiveTexture( textureContainer->activeTextureHandle->vulkanTexture->depth, textureContainer->activeTextureHandle->vulkanTexture->type, textureContainer->activeTextureHandle->vulkanTexture->layerCount, - textureContainer->activeTextureHandle->vulkanTexture->levelCount, + textureContainer->activeTextureHandle->vulkanTexture->numLevels, textureContainer->activeTextureHandle->vulkanTexture->sampleCount, textureContainer->activeTextureHandle->vulkanTexture->format, textureContainer->activeTextureHandle->vulkanTexture->swizzle, @@ -6066,9 +6066,9 @@ static VulkanTextureSubresource *VULKAN_INTERNAL_PrepareTextureSubresourceForWri static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( VulkanRenderer *renderer, VulkanCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo) + const SDL_GPUColorTargetInfo *colorTargetInfos, + Uint32 numColorTargets, + const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo) { VkResult vulkanResult; VkAttachmentDescription attachmentDescriptions[2 * MAX_COLOR_TARGET_BINDINGS + 1]; @@ -6086,8 +6086,8 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( VulkanTexture *texture = NULL; - for (i = 0; i < colorAttachmentCount; i += 1) { - texture = ((VulkanTextureContainer *)colorAttachmentInfos[i].texture)->activeTextureHandle->vulkanTexture; + for (i = 0; i < numColorTargets; i += 1) { + texture = ((VulkanTextureContainer *)colorTargetInfos[i].texture)->activeTextureHandle->vulkanTexture; if (texture->sampleCount > VK_SAMPLE_COUNT_1_BIT) { // Resolve attachment and multisample attachment @@ -6096,7 +6096,7 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( attachmentDescriptions[attachmentDescriptionCount].format = texture->format; attachmentDescriptions[attachmentDescriptionCount].samples = VK_SAMPLE_COUNT_1_BIT; - attachmentDescriptions[attachmentDescriptionCount].loadOp = SDLToVK_LoadOp[colorAttachmentInfos[i].loadOp]; + attachmentDescriptions[attachmentDescriptionCount].loadOp = SDLToVK_LoadOp[colorTargetInfos[i].load_op]; attachmentDescriptions[attachmentDescriptionCount].storeOp = VK_ATTACHMENT_STORE_OP_STORE; // Always store the resolve texture attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = @@ -6119,8 +6119,8 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( attachmentDescriptions[attachmentDescriptionCount].flags = 0; attachmentDescriptions[attachmentDescriptionCount].format = texture->format; attachmentDescriptions[attachmentDescriptionCount].samples = texture->sampleCount; - attachmentDescriptions[attachmentDescriptionCount].loadOp = SDLToVK_LoadOp[colorAttachmentInfos[i].loadOp]; - attachmentDescriptions[attachmentDescriptionCount].storeOp = SDLToVK_StoreOp[colorAttachmentInfos[i].storeOp]; + attachmentDescriptions[attachmentDescriptionCount].loadOp = SDLToVK_LoadOp[colorTargetInfos[i].load_op]; + attachmentDescriptions[attachmentDescriptionCount].storeOp = SDLToVK_StoreOp[colorTargetInfos[i].store_op]; attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachmentDescriptions[attachmentDescriptionCount].stencilStoreOp = @@ -6142,7 +6142,7 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( attachmentDescriptions[attachmentDescriptionCount].format = texture->format; attachmentDescriptions[attachmentDescriptionCount].samples = VK_SAMPLE_COUNT_1_BIT; - attachmentDescriptions[attachmentDescriptionCount].loadOp = SDLToVK_LoadOp[colorAttachmentInfos[i].loadOp]; + attachmentDescriptions[attachmentDescriptionCount].loadOp = SDLToVK_LoadOp[colorTargetInfos[i].load_op]; attachmentDescriptions[attachmentDescriptionCount].storeOp = VK_ATTACHMENT_STORE_OP_STORE; // Always store non-MSAA textures attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = @@ -6167,24 +6167,24 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( subpass.flags = 0; subpass.inputAttachmentCount = 0; subpass.pInputAttachments = NULL; - subpass.colorAttachmentCount = colorAttachmentCount; + subpass.colorAttachmentCount = numColorTargets; subpass.pColorAttachments = colorAttachmentReferences; subpass.preserveAttachmentCount = 0; subpass.pPreserveAttachments = NULL; - if (depthStencilAttachmentInfo == NULL) { + if (depthStencilTargetInfo == NULL) { subpass.pDepthStencilAttachment = NULL; } else { - texture = ((VulkanTextureContainer *)depthStencilAttachmentInfo->texture)->activeTextureHandle->vulkanTexture; + texture = ((VulkanTextureContainer *)depthStencilTargetInfo->texture)->activeTextureHandle->vulkanTexture; attachmentDescriptions[attachmentDescriptionCount].flags = 0; attachmentDescriptions[attachmentDescriptionCount].format = texture->format; attachmentDescriptions[attachmentDescriptionCount].samples = texture->sampleCount; - attachmentDescriptions[attachmentDescriptionCount].loadOp = SDLToVK_LoadOp[depthStencilAttachmentInfo->loadOp]; - attachmentDescriptions[attachmentDescriptionCount].storeOp = SDLToVK_StoreOp[depthStencilAttachmentInfo->storeOp]; - attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = SDLToVK_LoadOp[depthStencilAttachmentInfo->stencilLoadOp]; - attachmentDescriptions[attachmentDescriptionCount].stencilStoreOp = SDLToVK_StoreOp[depthStencilAttachmentInfo->stencilStoreOp]; + attachmentDescriptions[attachmentDescriptionCount].loadOp = SDLToVK_LoadOp[depthStencilTargetInfo->load_op]; + attachmentDescriptions[attachmentDescriptionCount].storeOp = SDLToVK_StoreOp[depthStencilTargetInfo->store_op]; + attachmentDescriptions[attachmentDescriptionCount].stencilLoadOp = SDLToVK_LoadOp[depthStencilTargetInfo->stencil_load_op]; + attachmentDescriptions[attachmentDescriptionCount].stencilStoreOp = SDLToVK_StoreOp[depthStencilTargetInfo->stencil_store_op]; attachmentDescriptions[attachmentDescriptionCount].initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; attachmentDescriptions[attachmentDescriptionCount].finalLayout = @@ -6233,14 +6233,14 @@ static VkRenderPass VULKAN_INTERNAL_CreateRenderPass( static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( VulkanRenderer *renderer, - SDL_GPUGraphicsPipelineAttachmentInfo attachmentInfo, + SDL_GpuGraphicsPipelineTargetInfo attachmentInfo, VkSampleCountFlagBits sampleCount) { VkAttachmentDescription attachmentDescriptions[2 * MAX_COLOR_TARGET_BINDINGS + 1]; VkAttachmentReference colorAttachmentReferences[MAX_COLOR_TARGET_BINDINGS]; VkAttachmentReference resolveReferences[MAX_COLOR_TARGET_BINDINGS + 1]; VkAttachmentReference depthStencilAttachmentReference; - SDL_GPUColorAttachmentDescription attachmentDescription; + SDL_GPUColorTargetDescription attachmentDescription; VkSubpassDescription subpass; VkRenderPassCreateInfo renderPassCreateInfo; VkRenderPass renderPass; @@ -6252,8 +6252,8 @@ static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( Uint32 resolveReferenceCount = 0; Uint32 i; - for (i = 0; i < attachmentInfo.colorAttachmentCount; i += 1) { - attachmentDescription = attachmentInfo.colorAttachmentDescriptions[i]; + for (i = 0; i < attachmentInfo.num_color_targets; i += 1) { + attachmentDescription = attachmentInfo.color_target_descriptions[i]; if (sampleCount > VK_SAMPLE_COUNT_1_BIT) { multisampling = 1; @@ -6325,15 +6325,15 @@ static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( subpass.flags = 0; subpass.inputAttachmentCount = 0; subpass.pInputAttachments = NULL; - subpass.colorAttachmentCount = attachmentInfo.colorAttachmentCount; + subpass.colorAttachmentCount = attachmentInfo.num_color_targets; subpass.pColorAttachments = colorAttachmentReferences; subpass.preserveAttachmentCount = 0; subpass.pPreserveAttachments = NULL; - if (attachmentInfo.hasDepthStencilAttachment) { + if (attachmentInfo.has_depth_stencil_target) { attachmentDescriptions[attachmentDescriptionCount].flags = 0; attachmentDescriptions[attachmentDescriptionCount].format = - SDLToVK_SurfaceFormat[attachmentInfo.depthStencilFormat]; + SDLToVK_SurfaceFormat[attachmentInfo.depth_stencil_format]; attachmentDescriptions[attachmentDescriptionCount].samples = sampleCount; attachmentDescriptions[attachmentDescriptionCount].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; @@ -6390,7 +6390,7 @@ static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass( static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( SDL_GPURenderer *driverData, - const SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo) + const SDL_GPUGraphicsPipelineCreateInfo *createinfo) { VkResult vulkanResult; Uint32 i; @@ -6403,9 +6403,9 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo; VkPipelineVertexInputDivisorStateCreateInfoEXT divisorStateCreateInfo; - VkVertexInputBindingDescription *vertexInputBindingDescriptions = SDL_stack_alloc(VkVertexInputBindingDescription, pipelineCreateInfo->vertexInputState.vertexBindingCount); - VkVertexInputAttributeDescription *vertexInputAttributeDescriptions = SDL_stack_alloc(VkVertexInputAttributeDescription, pipelineCreateInfo->vertexInputState.vertexAttributeCount); - VkVertexInputBindingDivisorDescriptionEXT *divisorDescriptions = SDL_stack_alloc(VkVertexInputBindingDivisorDescriptionEXT, pipelineCreateInfo->vertexInputState.vertexBindingCount); + VkVertexInputBindingDescription *vertexInputBindingDescriptions = SDL_stack_alloc(VkVertexInputBindingDescription, createinfo->vertex_input_state.num_vertex_bindings); + VkVertexInputAttributeDescription *vertexInputAttributeDescriptions = SDL_stack_alloc(VkVertexInputAttributeDescription, createinfo->vertex_input_state.num_vertex_attributes); + VkVertexInputBindingDivisorDescriptionEXT *divisorDescriptions = SDL_stack_alloc(VkVertexInputBindingDivisorDescriptionEXT, createinfo->vertex_input_state.num_vertex_bindings); Uint32 divisorDescriptionCount = 0; VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCreateInfo; @@ -6423,7 +6423,7 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( VkPipelineColorBlendStateCreateInfo colorBlendStateCreateInfo; VkPipelineColorBlendAttachmentState *colorBlendAttachmentStates = SDL_stack_alloc( VkPipelineColorBlendAttachmentState, - pipelineCreateInfo->attachmentInfo.colorAttachmentCount); + createinfo->target_info.num_color_targets); static const VkDynamicState dynamicStates[] = { VK_DYNAMIC_STATE_VIEWPORT, @@ -6439,13 +6439,13 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( actualSampleCount = VULKAN_INTERNAL_GetMaxMultiSampleCount( renderer, - SDLToVK_SampleCount[pipelineCreateInfo->multisampleState.sampleCount]); + SDLToVK_SampleCount[createinfo->multisample_state.sample_count]); // Create a "compatible" render pass VkRenderPass transientRenderPass = VULKAN_INTERNAL_CreateTransientRenderPass( renderer, - pipelineCreateInfo->attachmentInfo, + createinfo->target_info, actualSampleCount); // Dynamic state @@ -6458,7 +6458,7 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( // Shader stages - graphicsPipeline->vertexShader = (VulkanShader *)pipelineCreateInfo->vertexShader; + graphicsPipeline->vertexShader = (VulkanShader *)createinfo->vertex_shader; SDL_AtomicIncRef(&graphicsPipeline->vertexShader->referenceCount); shaderStageCreateInfos[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; @@ -6466,10 +6466,10 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( shaderStageCreateInfos[0].flags = 0; shaderStageCreateInfos[0].stage = VK_SHADER_STAGE_VERTEX_BIT; shaderStageCreateInfos[0].module = graphicsPipeline->vertexShader->shaderModule; - shaderStageCreateInfos[0].pName = graphicsPipeline->vertexShader->entryPointName; + shaderStageCreateInfos[0].pName = graphicsPipeline->vertexShader->entrypointName; shaderStageCreateInfos[0].pSpecializationInfo = NULL; - graphicsPipeline->fragmentShader = (VulkanShader *)pipelineCreateInfo->fragmentShader; + graphicsPipeline->fragmentShader = (VulkanShader *)createinfo->fragment_shader; SDL_AtomicIncRef(&graphicsPipeline->fragmentShader->referenceCount); shaderStageCreateInfos[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; @@ -6477,43 +6477,43 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( shaderStageCreateInfos[1].flags = 0; shaderStageCreateInfos[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; shaderStageCreateInfos[1].module = graphicsPipeline->fragmentShader->shaderModule; - shaderStageCreateInfos[1].pName = graphicsPipeline->fragmentShader->entryPointName; + shaderStageCreateInfos[1].pName = graphicsPipeline->fragmentShader->entrypointName; shaderStageCreateInfos[1].pSpecializationInfo = NULL; // Vertex input - for (i = 0; i < pipelineCreateInfo->vertexInputState.vertexBindingCount; i += 1) { - vertexInputBindingDescriptions[i].binding = pipelineCreateInfo->vertexInputState.vertexBindings[i].binding; - vertexInputBindingDescriptions[i].inputRate = SDLToVK_VertexInputRate[pipelineCreateInfo->vertexInputState.vertexBindings[i].inputRate]; - vertexInputBindingDescriptions[i].stride = pipelineCreateInfo->vertexInputState.vertexBindings[i].stride; + for (i = 0; i < createinfo->vertex_input_state.num_vertex_bindings; i += 1) { + vertexInputBindingDescriptions[i].binding = createinfo->vertex_input_state.vertex_bindings[i].binding; + vertexInputBindingDescriptions[i].inputRate = SDLToVK_VertexInputRate[createinfo->vertex_input_state.vertex_bindings[i].input_rate]; + vertexInputBindingDescriptions[i].stride = createinfo->vertex_input_state.vertex_bindings[i].pitch; - if (pipelineCreateInfo->vertexInputState.vertexBindings[i].inputRate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) { + if (createinfo->vertex_input_state.vertex_bindings[i].input_rate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) { divisorDescriptionCount += 1; } } - for (i = 0; i < pipelineCreateInfo->vertexInputState.vertexAttributeCount; i += 1) { - vertexInputAttributeDescriptions[i].binding = pipelineCreateInfo->vertexInputState.vertexAttributes[i].binding; - vertexInputAttributeDescriptions[i].format = SDLToVK_VertexFormat[pipelineCreateInfo->vertexInputState.vertexAttributes[i].format]; - vertexInputAttributeDescriptions[i].location = pipelineCreateInfo->vertexInputState.vertexAttributes[i].location; - vertexInputAttributeDescriptions[i].offset = pipelineCreateInfo->vertexInputState.vertexAttributes[i].offset; + for (i = 0; i < createinfo->vertex_input_state.num_vertex_attributes; i += 1) { + vertexInputAttributeDescriptions[i].binding = createinfo->vertex_input_state.vertex_attributes[i].binding; + vertexInputAttributeDescriptions[i].format = SDLToVK_VertexFormat[createinfo->vertex_input_state.vertex_attributes[i].format]; + vertexInputAttributeDescriptions[i].location = createinfo->vertex_input_state.vertex_attributes[i].location; + vertexInputAttributeDescriptions[i].offset = createinfo->vertex_input_state.vertex_attributes[i].offset; } vertexInputStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertexInputStateCreateInfo.pNext = NULL; vertexInputStateCreateInfo.flags = 0; - vertexInputStateCreateInfo.vertexBindingDescriptionCount = pipelineCreateInfo->vertexInputState.vertexBindingCount; + vertexInputStateCreateInfo.vertexBindingDescriptionCount = createinfo->vertex_input_state.num_vertex_bindings; vertexInputStateCreateInfo.pVertexBindingDescriptions = vertexInputBindingDescriptions; - vertexInputStateCreateInfo.vertexAttributeDescriptionCount = pipelineCreateInfo->vertexInputState.vertexAttributeCount; + vertexInputStateCreateInfo.vertexAttributeDescriptionCount = createinfo->vertex_input_state.num_vertex_attributes; vertexInputStateCreateInfo.pVertexAttributeDescriptions = vertexInputAttributeDescriptions; if (divisorDescriptionCount > 0) { divisorDescriptionCount = 0; - for (i = 0; i < pipelineCreateInfo->vertexInputState.vertexBindingCount; i += 1) { - if (pipelineCreateInfo->vertexInputState.vertexBindings[i].inputRate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) { - divisorDescriptions[divisorDescriptionCount].binding = pipelineCreateInfo->vertexInputState.vertexBindings[i].binding; - divisorDescriptions[divisorDescriptionCount].divisor = pipelineCreateInfo->vertexInputState.vertexBindings[i].instanceStepRate; + for (i = 0; i < createinfo->vertex_input_state.num_vertex_bindings; i += 1) { + if (createinfo->vertex_input_state.vertex_bindings[i].input_rate == SDL_GPU_VERTEXINPUTRATE_INSTANCE) { + divisorDescriptions[divisorDescriptionCount].binding = createinfo->vertex_input_state.vertex_bindings[i].binding; + divisorDescriptions[divisorDescriptionCount].divisor = createinfo->vertex_input_state.vertex_bindings[i].instance_step_rate; divisorDescriptionCount += 1; } @@ -6533,9 +6533,9 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( inputAssemblyStateCreateInfo.pNext = NULL; inputAssemblyStateCreateInfo.flags = 0; inputAssemblyStateCreateInfo.primitiveRestartEnable = VK_FALSE; - inputAssemblyStateCreateInfo.topology = SDLToVK_PrimitiveType[pipelineCreateInfo->primitiveType]; + inputAssemblyStateCreateInfo.topology = SDLToVK_PrimitiveType[createinfo->primitive_type]; - graphicsPipeline->primitiveType = pipelineCreateInfo->primitiveType; + graphicsPipeline->primitiveType = createinfo->primitive_type; // Viewport @@ -6558,17 +6558,17 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( rasterizationStateCreateInfo.rasterizerDiscardEnable = VK_FALSE; rasterizationStateCreateInfo.polygonMode = SDLToVK_PolygonMode( renderer, - pipelineCreateInfo->rasterizerState.fillMode); - rasterizationStateCreateInfo.cullMode = SDLToVK_CullMode[pipelineCreateInfo->rasterizerState.cullMode]; - rasterizationStateCreateInfo.frontFace = SDLToVK_FrontFace[pipelineCreateInfo->rasterizerState.frontFace]; + createinfo->rasterizer_state.fill_mode); + rasterizationStateCreateInfo.cullMode = SDLToVK_CullMode[createinfo->rasterizer_state.cull_mode]; + rasterizationStateCreateInfo.frontFace = SDLToVK_FrontFace[createinfo->rasterizer_state.front_face]; rasterizationStateCreateInfo.depthBiasEnable = - pipelineCreateInfo->rasterizerState.depthBiasEnable; + createinfo->rasterizer_state.enable_depth_bias; rasterizationStateCreateInfo.depthBiasConstantFactor = - pipelineCreateInfo->rasterizerState.depthBiasConstantFactor; + createinfo->rasterizer_state.depth_bias_constant_factor; rasterizationStateCreateInfo.depthBiasClamp = - pipelineCreateInfo->rasterizerState.depthBiasClamp; + createinfo->rasterizer_state.depth_bias_clamp; rasterizationStateCreateInfo.depthBiasSlopeFactor = - pipelineCreateInfo->rasterizerState.depthBiasSlopeFactor; + createinfo->rasterizer_state.depth_bias_slope_factor; rasterizationStateCreateInfo.lineWidth = 1.0f; // Multisample @@ -6580,43 +6580,43 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( multisampleStateCreateInfo.sampleShadingEnable = VK_FALSE; multisampleStateCreateInfo.minSampleShading = 1.0f; multisampleStateCreateInfo.pSampleMask = - &pipelineCreateInfo->multisampleState.sampleMask; + &createinfo->multisample_state.sample_mask; multisampleStateCreateInfo.alphaToCoverageEnable = VK_FALSE; multisampleStateCreateInfo.alphaToOneEnable = VK_FALSE; // Depth Stencil State - frontStencilState.failOp = SDLToVK_StencilOp[pipelineCreateInfo->depthStencilState.frontStencilState.failOp]; - frontStencilState.passOp = SDLToVK_StencilOp[pipelineCreateInfo->depthStencilState.frontStencilState.passOp]; - frontStencilState.depthFailOp = SDLToVK_StencilOp[pipelineCreateInfo->depthStencilState.frontStencilState.depthFailOp]; - frontStencilState.compareOp = SDLToVK_CompareOp[pipelineCreateInfo->depthStencilState.frontStencilState.compareOp]; + frontStencilState.failOp = SDLToVK_StencilOp[createinfo->depth_stencil_state.front_stencil_state.fail_op]; + frontStencilState.passOp = SDLToVK_StencilOp[createinfo->depth_stencil_state.front_stencil_state.pass_op]; + frontStencilState.depthFailOp = SDLToVK_StencilOp[createinfo->depth_stencil_state.front_stencil_state.depth_fail_op]; + frontStencilState.compareOp = SDLToVK_CompareOp[createinfo->depth_stencil_state.front_stencil_state.compare_op]; frontStencilState.compareMask = - pipelineCreateInfo->depthStencilState.compareMask; + createinfo->depth_stencil_state.compare_mask; frontStencilState.writeMask = - pipelineCreateInfo->depthStencilState.writeMask; + createinfo->depth_stencil_state.write_mask; frontStencilState.reference = 0; - backStencilState.failOp = SDLToVK_StencilOp[pipelineCreateInfo->depthStencilState.backStencilState.failOp]; - backStencilState.passOp = SDLToVK_StencilOp[pipelineCreateInfo->depthStencilState.backStencilState.passOp]; - backStencilState.depthFailOp = SDLToVK_StencilOp[pipelineCreateInfo->depthStencilState.backStencilState.depthFailOp]; - backStencilState.compareOp = SDLToVK_CompareOp[pipelineCreateInfo->depthStencilState.backStencilState.compareOp]; + backStencilState.failOp = SDLToVK_StencilOp[createinfo->depth_stencil_state.back_stencil_state.fail_op]; + backStencilState.passOp = SDLToVK_StencilOp[createinfo->depth_stencil_state.back_stencil_state.pass_op]; + backStencilState.depthFailOp = SDLToVK_StencilOp[createinfo->depth_stencil_state.back_stencil_state.depth_fail_op]; + backStencilState.compareOp = SDLToVK_CompareOp[createinfo->depth_stencil_state.back_stencil_state.compare_op]; backStencilState.compareMask = - pipelineCreateInfo->depthStencilState.compareMask; + createinfo->depth_stencil_state.compare_mask; backStencilState.writeMask = - pipelineCreateInfo->depthStencilState.writeMask; + createinfo->depth_stencil_state.write_mask; backStencilState.reference = 0; depthStencilStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; depthStencilStateCreateInfo.pNext = NULL; depthStencilStateCreateInfo.flags = 0; depthStencilStateCreateInfo.depthTestEnable = - pipelineCreateInfo->depthStencilState.depthTestEnable; + createinfo->depth_stencil_state.enable_depth_test; depthStencilStateCreateInfo.depthWriteEnable = - pipelineCreateInfo->depthStencilState.depthWriteEnable; - depthStencilStateCreateInfo.depthCompareOp = SDLToVK_CompareOp[pipelineCreateInfo->depthStencilState.compareOp]; + createinfo->depth_stencil_state.enable_depth_write; + depthStencilStateCreateInfo.depthCompareOp = SDLToVK_CompareOp[createinfo->depth_stencil_state.compare_op]; depthStencilStateCreateInfo.depthBoundsTestEnable = VK_FALSE; depthStencilStateCreateInfo.stencilTestEnable = - pipelineCreateInfo->depthStencilState.stencilTestEnable; + createinfo->depth_stencil_state.enable_stencil_test; depthStencilStateCreateInfo.front = frontStencilState; depthStencilStateCreateInfo.back = backStencilState; depthStencilStateCreateInfo.minDepthBounds = 0; // unused @@ -6624,26 +6624,26 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( // Color Blend - for (i = 0; i < pipelineCreateInfo->attachmentInfo.colorAttachmentCount; i += 1) { - SDL_GPUColorAttachmentBlendState blendState = pipelineCreateInfo->attachmentInfo.colorAttachmentDescriptions[i].blendState; + for (i = 0; i < createinfo->target_info.num_color_targets; i += 1) { + SDL_GPUColorTargetBlendState blendState = createinfo->target_info.color_target_descriptions[i].blend_state; colorBlendAttachmentStates[i].blendEnable = - blendState.blendEnable; - colorBlendAttachmentStates[i].srcColorBlendFactor = SDLToVK_BlendFactor[blendState.srcColorBlendFactor]; - colorBlendAttachmentStates[i].dstColorBlendFactor = SDLToVK_BlendFactor[blendState.dstColorBlendFactor]; - colorBlendAttachmentStates[i].colorBlendOp = SDLToVK_BlendOp[blendState.colorBlendOp]; - colorBlendAttachmentStates[i].srcAlphaBlendFactor = SDLToVK_BlendFactor[blendState.srcAlphaBlendFactor]; - colorBlendAttachmentStates[i].dstAlphaBlendFactor = SDLToVK_BlendFactor[blendState.dstAlphaBlendFactor]; - colorBlendAttachmentStates[i].alphaBlendOp = SDLToVK_BlendOp[blendState.alphaBlendOp]; + blendState.enable_blend; + colorBlendAttachmentStates[i].srcColorBlendFactor = SDLToVK_BlendFactor[blendState.src_color_blendfactor]; + colorBlendAttachmentStates[i].dstColorBlendFactor = SDLToVK_BlendFactor[blendState.dst_color_blendfactor]; + colorBlendAttachmentStates[i].colorBlendOp = SDLToVK_BlendOp[blendState.color_blend_op]; + colorBlendAttachmentStates[i].srcAlphaBlendFactor = SDLToVK_BlendFactor[blendState.src_alpha_blendfactor]; + colorBlendAttachmentStates[i].dstAlphaBlendFactor = SDLToVK_BlendFactor[blendState.dst_alpha_blendfactor]; + colorBlendAttachmentStates[i].alphaBlendOp = SDLToVK_BlendOp[blendState.alpha_blend_op]; colorBlendAttachmentStates[i].colorWriteMask = - blendState.colorWriteMask; + blendState.color_write_mask; } colorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; colorBlendStateCreateInfo.pNext = NULL; colorBlendStateCreateInfo.flags = 0; colorBlendStateCreateInfo.attachmentCount = - pipelineCreateInfo->attachmentInfo.colorAttachmentCount; + createinfo->target_info.num_color_targets; colorBlendStateCreateInfo.pAttachments = colorBlendAttachmentStates; colorBlendStateCreateInfo.blendConstants[0] = 1.0f; @@ -6726,17 +6726,17 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline( static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline( SDL_GPURenderer *driverData, - const SDL_GPUComputePipelineCreateInfo *pipelineCreateInfo) + const SDL_GPUComputePipelineCreateInfo *createinfo) { VkShaderModuleCreateInfo shaderModuleCreateInfo; - VkComputePipelineCreateInfo computePipelineCreateInfo; + VkComputePipelineCreateInfo vkShaderCreateInfo; VkPipelineShaderStageCreateInfo pipelineShaderStageCreateInfo; VkResult vulkanResult; Uint32 i; VulkanRenderer *renderer = (VulkanRenderer *)driverData; VulkanComputePipeline *vulkanComputePipeline; - if (pipelineCreateInfo->format != SDL_GPU_SHADERFORMAT_SPIRV) { + if (createinfo->format != SDL_GPU_SHADERFORMAT_SPIRV) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Incompatible shader format for Vulkan!"); return NULL; } @@ -6745,8 +6745,8 @@ static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline( shaderModuleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; shaderModuleCreateInfo.pNext = NULL; shaderModuleCreateInfo.flags = 0; - shaderModuleCreateInfo.codeSize = pipelineCreateInfo->codeSize; - shaderModuleCreateInfo.pCode = (Uint32 *)pipelineCreateInfo->code; + shaderModuleCreateInfo.codeSize = createinfo->code_size; + shaderModuleCreateInfo.pCode = (Uint32 *)createinfo->code; vulkanResult = renderer->vkCreateShaderModule( renderer->logicalDevice, @@ -6766,12 +6766,12 @@ static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline( pipelineShaderStageCreateInfo.flags = 0; pipelineShaderStageCreateInfo.stage = VK_SHADER_STAGE_COMPUTE_BIT; pipelineShaderStageCreateInfo.module = vulkanComputePipeline->shaderModule; - pipelineShaderStageCreateInfo.pName = pipelineCreateInfo->entryPointName; + pipelineShaderStageCreateInfo.pName = createinfo->entrypoint; pipelineShaderStageCreateInfo.pSpecializationInfo = NULL; if (!VULKAN_INTERNAL_InitializeComputePipelineResourceLayout( renderer, - pipelineCreateInfo, + createinfo, &vulkanComputePipeline->resourceLayout)) { renderer->vkDestroyShaderModule( renderer->logicalDevice, @@ -6781,20 +6781,20 @@ static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline( return NULL; } - computePipelineCreateInfo.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO; - computePipelineCreateInfo.pNext = NULL; - computePipelineCreateInfo.flags = 0; - computePipelineCreateInfo.stage = pipelineShaderStageCreateInfo; - computePipelineCreateInfo.layout = + vkShaderCreateInfo.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO; + vkShaderCreateInfo.pNext = NULL; + vkShaderCreateInfo.flags = 0; + vkShaderCreateInfo.stage = pipelineShaderStageCreateInfo; + vkShaderCreateInfo.layout = vulkanComputePipeline->resourceLayout.pipelineLayout; - computePipelineCreateInfo.basePipelineHandle = (VkPipeline)VK_NULL_HANDLE; - computePipelineCreateInfo.basePipelineIndex = 0; + vkShaderCreateInfo.basePipelineHandle = (VkPipeline)VK_NULL_HANDLE; + vkShaderCreateInfo.basePipelineIndex = 0; vulkanResult = renderer->vkCreateComputePipelines( renderer->logicalDevice, (VkPipelineCache)VK_NULL_HANDLE, 1, - &computePipelineCreateInfo, + &vkShaderCreateInfo, NULL, &vulkanComputePipeline->pipeline); @@ -6827,7 +6827,7 @@ static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline( static SDL_GPUSampler *VULKAN_CreateSampler( SDL_GPURenderer *driverData, - const SDL_GPUSamplerCreateInfo *samplerCreateInfo) + const SDL_GPUSamplerCreateInfo *createinfo) { VulkanRenderer *renderer = (VulkanRenderer *)driverData; VulkanSampler *vulkanSampler = SDL_malloc(sizeof(VulkanSampler)); @@ -6837,19 +6837,19 @@ static SDL_GPUSampler *VULKAN_CreateSampler( vkSamplerCreateInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; vkSamplerCreateInfo.pNext = NULL; vkSamplerCreateInfo.flags = 0; - vkSamplerCreateInfo.magFilter = SDLToVK_Filter[samplerCreateInfo->magFilter]; - vkSamplerCreateInfo.minFilter = SDLToVK_Filter[samplerCreateInfo->minFilter]; - vkSamplerCreateInfo.mipmapMode = SDLToVK_SamplerMipmapMode[samplerCreateInfo->mipmapMode]; - vkSamplerCreateInfo.addressModeU = SDLToVK_SamplerAddressMode[samplerCreateInfo->addressModeU]; - vkSamplerCreateInfo.addressModeV = SDLToVK_SamplerAddressMode[samplerCreateInfo->addressModeV]; - vkSamplerCreateInfo.addressModeW = SDLToVK_SamplerAddressMode[samplerCreateInfo->addressModeW]; - vkSamplerCreateInfo.mipLodBias = samplerCreateInfo->mipLodBias; - vkSamplerCreateInfo.anisotropyEnable = samplerCreateInfo->anisotropyEnable; - vkSamplerCreateInfo.maxAnisotropy = samplerCreateInfo->maxAnisotropy; - vkSamplerCreateInfo.compareEnable = samplerCreateInfo->compareEnable; - vkSamplerCreateInfo.compareOp = SDLToVK_CompareOp[samplerCreateInfo->compareOp]; - vkSamplerCreateInfo.minLod = samplerCreateInfo->minLod; - vkSamplerCreateInfo.maxLod = samplerCreateInfo->maxLod; + vkSamplerCreateInfo.magFilter = SDLToVK_Filter[createinfo->mag_filter]; + vkSamplerCreateInfo.minFilter = SDLToVK_Filter[createinfo->min_filter]; + vkSamplerCreateInfo.mipmapMode = SDLToVK_SamplerMipmapMode[createinfo->mipmap_mode]; + vkSamplerCreateInfo.addressModeU = SDLToVK_SamplerAddressMode[createinfo->address_mode_u]; + vkSamplerCreateInfo.addressModeV = SDLToVK_SamplerAddressMode[createinfo->address_mode_v]; + vkSamplerCreateInfo.addressModeW = SDLToVK_SamplerAddressMode[createinfo->address_mode_w]; + vkSamplerCreateInfo.mipLodBias = createinfo->mip_lod_bias; + vkSamplerCreateInfo.anisotropyEnable = createinfo->enable_anisotropy; + vkSamplerCreateInfo.maxAnisotropy = createinfo->max_anisotropy; + vkSamplerCreateInfo.compareEnable = createinfo->enable_compare; + vkSamplerCreateInfo.compareOp = SDLToVK_CompareOp[createinfo->compare_op]; + vkSamplerCreateInfo.minLod = createinfo->min_lod; + vkSamplerCreateInfo.maxLod = createinfo->max_lod; vkSamplerCreateInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; // arbitrary, unused vkSamplerCreateInfo.unnormalizedCoordinates = VK_FALSE; @@ -6872,7 +6872,7 @@ static SDL_GPUSampler *VULKAN_CreateSampler( static SDL_GPUShader *VULKAN_CreateShader( SDL_GPURenderer *driverData, - const SDL_GPUShaderCreateInfo *shaderCreateInfo) + const SDL_GPUShaderCreateInfo *createinfo) { VulkanShader *vulkanShader; VkResult vulkanResult; @@ -6884,8 +6884,8 @@ static SDL_GPUShader *VULKAN_CreateShader( vkShaderModuleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; vkShaderModuleCreateInfo.pNext = NULL; vkShaderModuleCreateInfo.flags = 0; - vkShaderModuleCreateInfo.codeSize = shaderCreateInfo->codeSize; - vkShaderModuleCreateInfo.pCode = (Uint32 *)shaderCreateInfo->code; + vkShaderModuleCreateInfo.codeSize = createinfo->code_size; + vkShaderModuleCreateInfo.pCode = (Uint32 *)createinfo->code; vulkanResult = renderer->vkCreateShaderModule( renderer->logicalDevice, @@ -6900,14 +6900,14 @@ static SDL_GPUShader *VULKAN_CreateShader( return NULL; } - entryPointNameLength = SDL_strlen(shaderCreateInfo->entryPointName) + 1; - vulkanShader->entryPointName = SDL_malloc(entryPointNameLength); - SDL_utf8strlcpy((char *)vulkanShader->entryPointName, shaderCreateInfo->entryPointName, entryPointNameLength); + entryPointNameLength = SDL_strlen(createinfo->entrypoint) + 1; + vulkanShader->entrypointName = SDL_malloc(entryPointNameLength); + SDL_utf8strlcpy((char *)vulkanShader->entrypointName, createinfo->entrypoint, entryPointNameLength); - vulkanShader->samplerCount = shaderCreateInfo->samplerCount; - vulkanShader->storageTextureCount = shaderCreateInfo->storageTextureCount; - vulkanShader->storageBufferCount = shaderCreateInfo->storageBufferCount; - vulkanShader->uniformBufferCount = shaderCreateInfo->uniformBufferCount; + vulkanShader->numSamplers = createinfo->num_samplers; + vulkanShader->numStorageTextures = createinfo->num_storage_textures; + vulkanShader->numStorageBuffers = createinfo->num_storage_buffers; + vulkanShader->numUniformBuffers = createinfo->num_uniform_buffers; SDL_AtomicSet(&vulkanShader->referenceCount, 0); @@ -6927,23 +6927,23 @@ static bool VULKAN_SupportsSampleCount( static SDL_GPUTexture *VULKAN_CreateTexture( SDL_GPURenderer *driverData, - const SDL_GPUTextureCreateInfo *textureCreateInfo) + const SDL_GPUTextureCreateInfo *createinfo) { VulkanRenderer *renderer = (VulkanRenderer *)driverData; VkImageAspectFlags imageAspectFlags; - Uint8 isDepthFormat = IsDepthFormat(textureCreateInfo->format); + Uint8 isDepthFormat = IsDepthFormat(createinfo->format); VkFormat format; VkComponentMapping swizzle; VulkanTextureContainer *container; VulkanTextureHandle *textureHandle; - format = SDLToVK_SurfaceFormat[textureCreateInfo->format]; - swizzle = SDLToVK_SurfaceSwizzle[textureCreateInfo->format]; + format = SDLToVK_SurfaceFormat[createinfo->format]; + swizzle = SDLToVK_SurfaceSwizzle[createinfo->format]; if (isDepthFormat) { imageAspectFlags = VK_IMAGE_ASPECT_DEPTH_BIT; - if (IsStencilFormat(textureCreateInfo->format)) { + if (IsStencilFormat(createinfo->format)) { imageAspectFlags |= VK_IMAGE_ASPECT_STENCIL_BIT; } } else { @@ -6952,17 +6952,17 @@ static SDL_GPUTexture *VULKAN_CreateTexture( textureHandle = VULKAN_INTERNAL_CreateTextureHandle( renderer, - textureCreateInfo->width, - textureCreateInfo->height, - textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D ? textureCreateInfo->layerCountOrDepth : 1, - textureCreateInfo->type, - textureCreateInfo->type == SDL_GPU_TEXTURETYPE_3D ? 1 : textureCreateInfo->layerCountOrDepth, - textureCreateInfo->levelCount, - SDLToVK_SampleCount[textureCreateInfo->sampleCount], + createinfo->width, + createinfo->height, + createinfo->type == SDL_GPU_TEXTURETYPE_3D ? createinfo->layer_count_or_depth : 1, + createinfo->type, + createinfo->type == SDL_GPU_TEXTURETYPE_3D ? 1 : createinfo->layer_count_or_depth, + createinfo->num_levels, + SDLToVK_SampleCount[createinfo->sample_count], format, swizzle, imageAspectFlags, - textureCreateInfo->usageFlags, + createinfo->usage, false); if (textureHandle == NULL) { @@ -6971,7 +6971,7 @@ static SDL_GPUTexture *VULKAN_CreateTexture( } container = SDL_malloc(sizeof(VulkanTextureContainer)); - container->header.info = *textureCreateInfo; + container->header.info = *createinfo; container->canBeCycled = 1; container->activeTextureHandle = textureHandle; container->textureCapacity = 1; @@ -6989,24 +6989,24 @@ static SDL_GPUTexture *VULKAN_CreateTexture( static SDL_GPUBuffer *VULKAN_CreateBuffer( SDL_GPURenderer *driverData, SDL_GPUBufferUsageFlags usageFlags, - Uint32 sizeInBytes) + Uint32 size) { return (SDL_GPUBuffer *)VULKAN_INTERNAL_CreateBufferContainer( (VulkanRenderer *)driverData, - (VkDeviceSize)sizeInBytes, + (VkDeviceSize)size, usageFlags, VULKAN_BUFFER_TYPE_GPU); } static VulkanUniformBuffer *VULKAN_INTERNAL_CreateUniformBuffer( VulkanRenderer *renderer, - Uint32 sizeInBytes) + Uint32 size) { VulkanUniformBuffer *uniformBuffer = SDL_malloc(sizeof(VulkanUniformBuffer)); uniformBuffer->bufferHandle = VULKAN_INTERNAL_CreateBufferHandle( renderer, - (VkDeviceSize)sizeInBytes, + (VkDeviceSize)size, 0, VULKAN_BUFFER_TYPE_UNIFORM); @@ -7019,11 +7019,11 @@ static VulkanUniformBuffer *VULKAN_INTERNAL_CreateUniformBuffer( static SDL_GPUTransferBuffer *VULKAN_CreateTransferBuffer( SDL_GPURenderer *driverData, SDL_GPUTransferBufferUsage usage, // ignored on Vulkan - Uint32 sizeInBytes) + Uint32 size) { return (SDL_GPUTransferBuffer *)VULKAN_INTERNAL_CreateBufferContainer( (VulkanRenderer *)driverData, - (VkDeviceSize)sizeInBytes, + (VkDeviceSize)size, 0, VULKAN_BUFFER_TYPE_TRANSFER); } @@ -7243,40 +7243,40 @@ static void VULKAN_ReleaseGraphicsPipeline( static VkRenderPass VULKAN_INTERNAL_FetchRenderPass( VulkanRenderer *renderer, VulkanCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo) + const SDL_GPUColorTargetInfo *colorTargetInfos, + Uint32 numColorTargets, + const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo) { VulkanRenderPassHashTableValue *renderPassWrapper = NULL; VkRenderPass renderPassHandle; RenderPassHashTableKey key; Uint32 i; - for (i = 0; i < colorAttachmentCount; i += 1) { - key.colorTargetDescriptions[i].format = ((VulkanTextureContainer *)colorAttachmentInfos[i].texture)->activeTextureHandle->vulkanTexture->format; - key.colorTargetDescriptions[i].loadOp = colorAttachmentInfos[i].loadOp; - key.colorTargetDescriptions[i].storeOp = colorAttachmentInfos[i].storeOp; + for (i = 0; i < numColorTargets; i += 1) { + key.colorTargetDescriptions[i].format = ((VulkanTextureContainer *)colorTargetInfos[i].texture)->activeTextureHandle->vulkanTexture->format; + key.colorTargetDescriptions[i].loadOp = colorTargetInfos[i].load_op; + key.colorTargetDescriptions[i].storeOp = colorTargetInfos[i].store_op; } key.colorAttachmentSampleCount = VK_SAMPLE_COUNT_1_BIT; - if (colorAttachmentCount > 0) { - key.colorAttachmentSampleCount = ((VulkanTextureContainer *)colorAttachmentInfos[0].texture)->activeTextureHandle->vulkanTexture->sampleCount; + if (numColorTargets > 0) { + key.colorAttachmentSampleCount = ((VulkanTextureContainer *)colorTargetInfos[0].texture)->activeTextureHandle->vulkanTexture->sampleCount; } - key.colorAttachmentCount = colorAttachmentCount; + key.numColorTargets = numColorTargets; - if (depthStencilAttachmentInfo == NULL) { + if (depthStencilTargetInfo == NULL) { key.depthStencilTargetDescription.format = 0; key.depthStencilTargetDescription.loadOp = SDL_GPU_LOADOP_DONT_CARE; key.depthStencilTargetDescription.storeOp = SDL_GPU_STOREOP_DONT_CARE; key.depthStencilTargetDescription.stencilLoadOp = SDL_GPU_LOADOP_DONT_CARE; key.depthStencilTargetDescription.stencilStoreOp = SDL_GPU_STOREOP_DONT_CARE; } else { - key.depthStencilTargetDescription.format = ((VulkanTextureContainer *)depthStencilAttachmentInfo->texture)->activeTextureHandle->vulkanTexture->format; - key.depthStencilTargetDescription.loadOp = depthStencilAttachmentInfo->loadOp; - key.depthStencilTargetDescription.storeOp = depthStencilAttachmentInfo->storeOp; - key.depthStencilTargetDescription.stencilLoadOp = depthStencilAttachmentInfo->stencilLoadOp; - key.depthStencilTargetDescription.stencilStoreOp = depthStencilAttachmentInfo->stencilStoreOp; + key.depthStencilTargetDescription.format = ((VulkanTextureContainer *)depthStencilTargetInfo->texture)->activeTextureHandle->vulkanTexture->format; + key.depthStencilTargetDescription.loadOp = depthStencilTargetInfo->load_op; + key.depthStencilTargetDescription.storeOp = depthStencilTargetInfo->store_op; + key.depthStencilTargetDescription.stencilLoadOp = depthStencilTargetInfo->stencil_load_op; + key.depthStencilTargetDescription.stencilStoreOp = depthStencilTargetInfo->stencil_store_op; } SDL_LockMutex(renderer->renderPassFetchLock); @@ -7295,9 +7295,9 @@ static VkRenderPass VULKAN_INTERNAL_FetchRenderPass( renderPassHandle = VULKAN_INTERNAL_CreateRenderPass( renderer, commandBuffer, - colorAttachmentInfos, - colorAttachmentCount, - depthStencilAttachmentInfo); + colorTargetInfos, + numColorTargets, + depthStencilTargetInfo); if (renderPassHandle == VK_NULL_HANDLE) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Failed to create VkRenderPass!"); @@ -7325,9 +7325,9 @@ static VkRenderPass VULKAN_INTERNAL_FetchRenderPass( static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer( VulkanRenderer *renderer, VkRenderPass renderPass, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo, + const SDL_GPUColorTargetInfo *colorTargetInfos, + Uint32 numColorTargets, + const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo, Uint32 width, Uint32 height) { @@ -7344,17 +7344,17 @@ static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer( key.colorMultiSampleAttachmentViews[i] = VK_NULL_HANDLE; } - key.colorAttachmentCount = colorAttachmentCount; + key.numColorTargets = numColorTargets; - for (i = 0; i < colorAttachmentCount; i += 1) { - VulkanTextureContainer *container = (VulkanTextureContainer *)colorAttachmentInfos[i].texture; + for (i = 0; i < numColorTargets; i += 1) { + VulkanTextureContainer *container = (VulkanTextureContainer *)colorTargetInfos[i].texture; VulkanTextureSubresource *subresource = VULKAN_INTERNAL_FetchTextureSubresource( container, - container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorAttachmentInfos[i].layerOrDepthPlane, - colorAttachmentInfos[i].mipLevel); + container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorTargetInfos[i].layer_or_depth_plane, + colorTargetInfos[i].mip_level); Uint32 rtvIndex = - container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? colorAttachmentInfos[i].layerOrDepthPlane : 0; + container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? colorTargetInfos[i].layer_or_depth_plane : 0; key.colorAttachmentViews[i] = subresource->renderTargetViews[rtvIndex]; if (subresource->msaaTexHandle != NULL) { @@ -7362,11 +7362,11 @@ static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer( } } - if (depthStencilAttachmentInfo == NULL) { + if (depthStencilTargetInfo == NULL) { key.depthStencilAttachmentView = VK_NULL_HANDLE; } else { VulkanTextureSubresource *subresource = VULKAN_INTERNAL_FetchTextureSubresource( - (VulkanTextureContainer *)depthStencilAttachmentInfo->texture, + (VulkanTextureContainer *)depthStencilTargetInfo->texture, 0, 0); key.depthStencilAttachmentView = subresource->depthStencilView; @@ -7394,15 +7394,15 @@ static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer( // Create a new framebuffer - for (i = 0; i < colorAttachmentCount; i += 1) { - VulkanTextureContainer *container = (VulkanTextureContainer *)colorAttachmentInfos[i].texture; + for (i = 0; i < numColorTargets; i += 1) { + VulkanTextureContainer *container = (VulkanTextureContainer *)colorTargetInfos[i].texture; VulkanTextureSubresource *subresource = VULKAN_INTERNAL_FetchTextureSubresource( container, - container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorAttachmentInfos[i].layerOrDepthPlane, - colorAttachmentInfos[i].mipLevel); + container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorTargetInfos[i].layer_or_depth_plane, + colorTargetInfos[i].mip_level); Uint32 rtvIndex = - container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? colorAttachmentInfos[i].layerOrDepthPlane : 0; + container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? colorTargetInfos[i].layer_or_depth_plane : 0; imageViewAttachments[attachmentCount] = subresource->renderTargetViews[rtvIndex]; @@ -7417,9 +7417,9 @@ static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer( } } - if (depthStencilAttachmentInfo != NULL) { + if (depthStencilTargetInfo != NULL) { VulkanTextureSubresource *subresource = VULKAN_INTERNAL_FetchTextureSubresource( - (VulkanTextureContainer *)depthStencilAttachmentInfo->texture, + (VulkanTextureContainer *)depthStencilTargetInfo->texture, 0, 0); imageViewAttachments[attachmentCount] = subresource->depthStencilView; @@ -7473,8 +7473,8 @@ static void VULKAN_INTERNAL_SetCurrentViewport( vulkanCommandBuffer->currentViewport.x = viewport->x; vulkanCommandBuffer->currentViewport.width = viewport->w; - vulkanCommandBuffer->currentViewport.minDepth = viewport->minDepth; - vulkanCommandBuffer->currentViewport.maxDepth = viewport->maxDepth; + vulkanCommandBuffer->currentViewport.minDepth = viewport->min_depth; + vulkanCommandBuffer->currentViewport.maxDepth = viewport->max_depth; // Viewport flip for consistency with other backends // FIXME: need moltenVK hack @@ -7582,11 +7582,11 @@ static void VULKAN_BindVertexSamplers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)textureSamplerBindings[i].texture; vulkanCommandBuffer->vertexSamplerTextures[firstSlot + i] = textureContainer->activeTextureHandle->vulkanTexture; vulkanCommandBuffer->vertexSamplers[firstSlot + i] = (VulkanSampler *)textureSamplerBindings[i].sampler; @@ -7607,11 +7607,11 @@ static void VULKAN_BindVertexStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)storageTextures[i]; vulkanCommandBuffer->vertexStorageTextures[firstSlot + i] = textureContainer->activeTextureHandle->vulkanTexture; @@ -7628,13 +7628,13 @@ static void VULKAN_BindVertexStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanBufferContainer *bufferContainer; Uint32 i; - for (i = 0; i < bindingCount; i += 1) { + for (i = 0; i < numBindings; i += 1) { bufferContainer = (VulkanBufferContainer *)storageBuffers[i]; vulkanCommandBuffer->vertexStorageBuffers[firstSlot + i] = bufferContainer->activeBufferHandle->vulkanBuffer; @@ -7651,11 +7651,11 @@ static void VULKAN_BindFragmentSamplers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, const SDL_GPUTextureSamplerBinding *textureSamplerBindings, - Uint32 bindingCount) + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)textureSamplerBindings[i].texture; vulkanCommandBuffer->fragmentSamplerTextures[firstSlot + i] = textureContainer->activeTextureHandle->vulkanTexture; vulkanCommandBuffer->fragmentSamplers[firstSlot + i] = (VulkanSampler *)textureSamplerBindings[i].sampler; @@ -7676,11 +7676,11 @@ static void VULKAN_BindFragmentStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)storageTextures[i]; vulkanCommandBuffer->fragmentStorageTextures[firstSlot + i] = @@ -7698,13 +7698,13 @@ static void VULKAN_BindFragmentStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanBufferContainer *bufferContainer; Uint32 i; - for (i = 0; i < bindingCount; i += 1) { + for (i = 0; i < numBindings; i += 1) { bufferContainer = (VulkanBufferContainer *)storageBuffers[i]; vulkanCommandBuffer->fragmentStorageBuffers[firstSlot + i] = bufferContainer->activeBufferHandle->vulkanBuffer; @@ -7764,11 +7764,11 @@ static void VULKAN_INTERNAL_PushUniformData( VulkanUniformBufferStage uniformBufferStage, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { Uint32 blockSize = VULKAN_INTERNAL_NextHighestAlignment32( - dataLengthInBytes, + length, commandBuffer->renderer->minUBOAlignment); VulkanUniformBuffer *uniformBuffer; @@ -7828,7 +7828,7 @@ static void VULKAN_INTERNAL_PushUniformData( SDL_memcpy( dst, data, - dataLengthInBytes); + length); uniformBuffer->writeOffset += blockSize; @@ -7846,9 +7846,9 @@ static void VULKAN_INTERNAL_PushUniformData( static void VULKAN_BeginRenderPass( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUColorAttachmentInfo *colorAttachmentInfos, - Uint32 colorAttachmentCount, - const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo) + const SDL_GPUColorTargetInfo *colorTargetInfos, + Uint32 numColorTargets, + const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; @@ -7857,7 +7857,7 @@ static void VULKAN_BeginRenderPass( Uint32 w, h; VkClearValue *clearValues; - Uint32 clearCount = colorAttachmentCount; + Uint32 clearCount = numColorTargets; Uint32 multisampleAttachmentCount = 0; Uint32 totalColorAttachmentCount = 0; Uint32 i; @@ -7866,11 +7866,11 @@ static void VULKAN_BeginRenderPass( Uint32 framebufferWidth = UINT32_MAX; Uint32 framebufferHeight = UINT32_MAX; - for (i = 0; i < colorAttachmentCount; i += 1) { - VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)colorAttachmentInfos[i].texture; + for (i = 0; i < numColorTargets; i += 1) { + VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)colorTargetInfos[i].texture; - w = textureContainer->activeTextureHandle->vulkanTexture->dimensions.width >> colorAttachmentInfos[i].mipLevel; - h = textureContainer->activeTextureHandle->vulkanTexture->dimensions.height >> colorAttachmentInfos[i].mipLevel; + w = textureContainer->activeTextureHandle->vulkanTexture->dimensions.width >> colorTargetInfos[i].mip_level; + h = textureContainer->activeTextureHandle->vulkanTexture->dimensions.height >> colorTargetInfos[i].mip_level; // The framebuffer cannot be larger than the smallest attachment. @@ -7883,14 +7883,14 @@ static void VULKAN_BeginRenderPass( } // FIXME: validate this in gpu.c - if (!(textureContainer->header.info.usageFlags & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) { + if (!(textureContainer->header.info.usage & SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Color attachment texture was not designated as a target!"); return; } } - if (depthStencilAttachmentInfo != NULL) { - VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)depthStencilAttachmentInfo->texture; + if (depthStencilTargetInfo != NULL) { + VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)depthStencilTargetInfo->texture; w = textureContainer->activeTextureHandle->vulkanTexture->dimensions.width; h = textureContainer->activeTextureHandle->vulkanTexture->dimensions.height; @@ -7906,21 +7906,21 @@ static void VULKAN_BeginRenderPass( } // FIXME: validate this in gpu.c - if (!(textureContainer->header.info.usageFlags & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) { + if (!(textureContainer->header.info.usage & SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Depth stencil attachment texture was not designated as a target!"); return; } } - for (i = 0; i < colorAttachmentCount; i += 1) { - VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)colorAttachmentInfos[i].texture; + for (i = 0; i < numColorTargets; i += 1) { + VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)colorTargetInfos[i].texture; VulkanTextureSubresource *subresource = VULKAN_INTERNAL_PrepareTextureSubresourceForWrite( renderer, vulkanCommandBuffer, textureContainer, - textureContainer->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorAttachmentInfos[i].layerOrDepthPlane, - colorAttachmentInfos[i].mipLevel, - colorAttachmentInfos[i].cycle, + textureContainer->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorTargetInfos[i].layer_or_depth_plane, + colorTargetInfos[i].mip_level, + colorTargetInfos[i].cycle, VULKAN_TEXTURE_USAGE_MODE_COLOR_ATTACHMENT); if (subresource->msaaTexHandle != NULL) { @@ -7941,17 +7941,17 @@ static void VULKAN_BeginRenderPass( // TODO: do we need to track the msaa texture? or is it implicitly only used when the regular texture is used? } - vulkanCommandBuffer->colorAttachmentSubresourceCount = colorAttachmentCount; + vulkanCommandBuffer->colorAttachmentSubresourceCount = numColorTargets; - if (depthStencilAttachmentInfo != NULL) { - VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)depthStencilAttachmentInfo->texture; + if (depthStencilTargetInfo != NULL) { + VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)depthStencilTargetInfo->texture; VulkanTextureSubresource *subresource = VULKAN_INTERNAL_PrepareTextureSubresourceForWrite( renderer, vulkanCommandBuffer, textureContainer, 0, 0, - depthStencilAttachmentInfo->cycle, + depthStencilTargetInfo->cycle, VULKAN_TEXTURE_USAGE_MODE_DEPTH_STENCIL_ATTACHMENT); clearCount += 1; @@ -7966,16 +7966,16 @@ static void VULKAN_BeginRenderPass( renderPass = VULKAN_INTERNAL_FetchRenderPass( renderer, vulkanCommandBuffer, - colorAttachmentInfos, - colorAttachmentCount, - depthStencilAttachmentInfo); + colorTargetInfos, + numColorTargets, + depthStencilTargetInfo); framebuffer = VULKAN_INTERNAL_FetchFramebuffer( renderer, renderPass, - colorAttachmentInfos, - colorAttachmentCount, - depthStencilAttachmentInfo, + colorTargetInfos, + numColorTargets, + depthStencilTargetInfo, framebufferWidth, framebufferHeight); @@ -7985,34 +7985,34 @@ static void VULKAN_BeginRenderPass( clearValues = SDL_stack_alloc(VkClearValue, clearCount); - totalColorAttachmentCount = colorAttachmentCount + multisampleAttachmentCount; + totalColorAttachmentCount = numColorTargets + multisampleAttachmentCount; for (i = 0; i < totalColorAttachmentCount; i += 1) { - clearValues[i].color.float32[0] = colorAttachmentInfos[i].clearColor.r; - clearValues[i].color.float32[1] = colorAttachmentInfos[i].clearColor.g; - clearValues[i].color.float32[2] = colorAttachmentInfos[i].clearColor.b; - clearValues[i].color.float32[3] = colorAttachmentInfos[i].clearColor.a; + clearValues[i].color.float32[0] = colorTargetInfos[i].clear_color.r; + clearValues[i].color.float32[1] = colorTargetInfos[i].clear_color.g; + clearValues[i].color.float32[2] = colorTargetInfos[i].clear_color.b; + clearValues[i].color.float32[3] = colorTargetInfos[i].clear_color.a; - VulkanTextureContainer *container = (VulkanTextureContainer *)colorAttachmentInfos[i].texture; + VulkanTextureContainer *container = (VulkanTextureContainer *)colorTargetInfos[i].texture; VulkanTextureSubresource *subresource = VULKAN_INTERNAL_FetchTextureSubresource( container, - container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorAttachmentInfos[i].layerOrDepthPlane, - colorAttachmentInfos[i].mipLevel); + container->header.info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : colorTargetInfos[i].layer_or_depth_plane, + colorTargetInfos[i].mip_level); if (subresource->parent->sampleCount > VK_SAMPLE_COUNT_1_BIT) { - clearValues[i + 1].color.float32[0] = colorAttachmentInfos[i].clearColor.r; - clearValues[i + 1].color.float32[1] = colorAttachmentInfos[i].clearColor.g; - clearValues[i + 1].color.float32[2] = colorAttachmentInfos[i].clearColor.b; - clearValues[i + 1].color.float32[3] = colorAttachmentInfos[i].clearColor.a; + clearValues[i + 1].color.float32[0] = colorTargetInfos[i].clear_color.r; + clearValues[i + 1].color.float32[1] = colorTargetInfos[i].clear_color.g; + clearValues[i + 1].color.float32[2] = colorTargetInfos[i].clear_color.b; + clearValues[i + 1].color.float32[3] = colorTargetInfos[i].clear_color.a; i += 1; } } - if (depthStencilAttachmentInfo != NULL) { + if (depthStencilTargetInfo != NULL) { clearValues[totalColorAttachmentCount].depthStencil.depth = - depthStencilAttachmentInfo->depthStencilClearValue.depth; + depthStencilTargetInfo->clear_value.depth; clearValues[totalColorAttachmentCount].depthStencil.stencil = - depthStencilAttachmentInfo->depthStencilClearValue.stencil; + depthStencilTargetInfo->clear_value.stencil; } VkRenderPassBeginInfo renderPassBeginInfo; @@ -8040,8 +8040,8 @@ static void VULKAN_BeginRenderPass( defaultViewport.y = 0; defaultViewport.w = (float)framebufferWidth; defaultViewport.h = (float)framebufferHeight; - defaultViewport.minDepth = 0; - defaultViewport.maxDepth = 1; + defaultViewport.min_depth = 0; + defaultViewport.max_depth = 1; VULKAN_INTERNAL_SetCurrentViewport( vulkanCommandBuffer, @@ -8130,27 +8130,27 @@ static void VULKAN_BindGraphicsPipeline( static void VULKAN_BindVertexBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstBinding, - const SDL_GPUBufferBinding *pBindings, - Uint32 bindingCount) + const SDL_GPUBufferBinding *bindings, + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; VulkanBuffer *currentVulkanBuffer; - VkBuffer *buffers = SDL_stack_alloc(VkBuffer, bindingCount); - VkDeviceSize *offsets = SDL_stack_alloc(VkDeviceSize, bindingCount); + VkBuffer *buffers = SDL_stack_alloc(VkBuffer, numBindings); + VkDeviceSize *offsets = SDL_stack_alloc(VkDeviceSize, numBindings); Uint32 i; - for (i = 0; i < bindingCount; i += 1) { - currentVulkanBuffer = ((VulkanBufferContainer *)pBindings[i].buffer)->activeBufferHandle->vulkanBuffer; + for (i = 0; i < numBindings; i += 1) { + currentVulkanBuffer = ((VulkanBufferContainer *)bindings[i].buffer)->activeBufferHandle->vulkanBuffer; buffers[i] = currentVulkanBuffer->buffer; - offsets[i] = (VkDeviceSize)pBindings[i].offset; + offsets[i] = (VkDeviceSize)bindings[i].offset; VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, currentVulkanBuffer); } renderer->vkCmdBindVertexBuffers( vulkanCommandBuffer->commandBuffer, firstBinding, - bindingCount, + numBindings, buffers, offsets); @@ -8160,19 +8160,19 @@ static void VULKAN_BindVertexBuffers( static void VULKAN_BindIndexBuffer( SDL_GPUCommandBuffer *commandBuffer, - const SDL_GPUBufferBinding *pBinding, + const SDL_GPUBufferBinding *binding, SDL_GPUIndexElementSize indexElementSize) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; - VulkanBuffer *vulkanBuffer = ((VulkanBufferContainer *)pBinding->buffer)->activeBufferHandle->vulkanBuffer; + VulkanBuffer *vulkanBuffer = ((VulkanBufferContainer *)binding->buffer)->activeBufferHandle->vulkanBuffer; VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, vulkanBuffer); renderer->vkCmdBindIndexBuffer( vulkanCommandBuffer->commandBuffer, vulkanBuffer->buffer, - (VkDeviceSize)pBinding->offset, + (VkDeviceSize)binding->offset, SDLToVK_IndexType[indexElementSize]); } @@ -8180,7 +8180,7 @@ static void VULKAN_PushVertexUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; @@ -8189,14 +8189,14 @@ static void VULKAN_PushVertexUniformData( VULKAN_UNIFORM_BUFFER_STAGE_VERTEX, slotIndex, data, - dataLengthInBytes); + length); } static void VULKAN_PushFragmentUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; @@ -8205,7 +8205,7 @@ static void VULKAN_PushFragmentUniformData( VULKAN_UNIFORM_BUFFER_STAGE_FRAGMENT, slotIndex, data, - dataLengthInBytes); + length); } static void VULKAN_EndRenderPass( @@ -8261,9 +8261,9 @@ static void VULKAN_EndRenderPass( static void VULKAN_BeginComputePass( SDL_GPUCommandBuffer *commandBuffer, const SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings, - Uint32 storageTextureBindingCount, + Uint32 numStorageTextureBindings, const SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings, - Uint32 storageBufferBindingCount) + Uint32 numStorageBufferBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = vulkanCommandBuffer->renderer; @@ -8271,9 +8271,9 @@ static void VULKAN_BeginComputePass( VulkanBuffer *buffer; Uint32 i; - vulkanCommandBuffer->writeOnlyComputeStorageTextureSubresourceCount = storageTextureBindingCount; + vulkanCommandBuffer->writeOnlyComputeStorageTextureSubresourceCount = numStorageTextureBindings; - for (i = 0; i < storageTextureBindingCount; i += 1) { + for (i = 0; i < numStorageTextureBindings; i += 1) { VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)storageTextureBindings[i].texture; if (!(textureContainer->activeTextureHandle->vulkanTexture->usageFlags & SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE)) { SDL_LogError(SDL_LOG_CATEGORY_GPU, "Attempted to bind read-only texture as compute write texture"); @@ -8284,7 +8284,7 @@ static void VULKAN_BeginComputePass( vulkanCommandBuffer, textureContainer, storageTextureBindings[i].layer, - storageTextureBindings[i].mipLevel, + storageTextureBindings[i].mip_level, storageTextureBindings[i].cycle, VULKAN_TEXTURE_USAGE_MODE_COMPUTE_STORAGE_READ_WRITE); @@ -8295,7 +8295,7 @@ static void VULKAN_BeginComputePass( subresource->parent); } - for (i = 0; i < storageBufferBindingCount; i += 1) { + for (i = 0; i < numStorageBufferBindings; i += 1) { bufferContainer = (VulkanBufferContainer *)storageBufferBindings[i].buffer; buffer = VULKAN_INTERNAL_PrepareBufferForWrite( renderer, @@ -8330,7 +8330,7 @@ static void VULKAN_BindComputePipeline( VULKAN_INTERNAL_TrackComputePipeline(vulkanCommandBuffer, vulkanComputePipeline); // Acquire uniform buffers if necessary - for (Uint32 i = 0; i < vulkanComputePipeline->resourceLayout.uniformBufferCount; i += 1) { + for (Uint32 i = 0; i < vulkanComputePipeline->resourceLayout.numUniformBuffers; i += 1) { if (vulkanCommandBuffer->computeUniformBuffers[i] == NULL) { vulkanCommandBuffer->computeUniformBuffers[i] = VULKAN_INTERNAL_AcquireUniformBufferFromPool( vulkanCommandBuffer); @@ -8348,12 +8348,12 @@ static void VULKAN_BindComputeStorageTextures( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUTexture *const *storageTextures, - Uint32 bindingCount) + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = vulkanCommandBuffer->renderer; - for (Uint32 i = 0; i < bindingCount; i += 1) { + for (Uint32 i = 0; i < numBindings; i += 1) { if (vulkanCommandBuffer->readOnlyComputeStorageTextures[firstSlot + i] != NULL) { VULKAN_INTERNAL_TextureTransitionToDefaultUsage( renderer, @@ -8385,14 +8385,14 @@ static void VULKAN_BindComputeStorageBuffers( SDL_GPUCommandBuffer *commandBuffer, Uint32 firstSlot, SDL_GPUBuffer *const *storageBuffers, - Uint32 bindingCount) + Uint32 numBindings) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = vulkanCommandBuffer->renderer; VulkanBufferContainer *bufferContainer; Uint32 i; - for (i = 0; i < bindingCount; i += 1) { + for (i = 0; i < numBindings; i += 1) { if (vulkanCommandBuffer->readOnlyComputeStorageBuffers[firstSlot + i] != NULL) { VULKAN_INTERNAL_BufferTransitionToDefaultUsage( renderer, @@ -8423,7 +8423,7 @@ static void VULKAN_PushComputeUniformData( SDL_GPUCommandBuffer *commandBuffer, Uint32 slotIndex, const void *data, - Uint32 dataLengthInBytes) + Uint32 length) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; @@ -8432,7 +8432,7 @@ static void VULKAN_PushComputeUniformData( VULKAN_UNIFORM_BUFFER_STAGE_COMPUTE, slotIndex, data, - dataLengthInBytes); + length); } static void VULKAN_INTERNAL_BindComputeDescriptorSets( @@ -8462,10 +8462,10 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( writeDescriptorSets = SDL_stack_alloc( VkWriteDescriptorSet, - resourceLayout->readOnlyStorageTextureCount + - resourceLayout->readOnlyStorageBufferCount); + resourceLayout->numReadonlyStorageTextures + + resourceLayout->numReadonlyStorageBuffers); - for (i = 0; i < resourceLayout->readOnlyStorageTextureCount; i += 1) { + for (i = 0; i < resourceLayout->numReadonlyStorageTextures; i += 1) { currentWriteDescriptorSet = &writeDescriptorSets[i]; currentWriteDescriptorSet->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; currentWriteDescriptorSet->pNext = NULL; @@ -8486,15 +8486,15 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( imageInfoCount += 1; } - for (i = 0; i < resourceLayout->readOnlyStorageBufferCount; i += 1) { - currentWriteDescriptorSet = &writeDescriptorSets[resourceLayout->readOnlyStorageTextureCount + i]; + for (i = 0; i < resourceLayout->numReadonlyStorageBuffers; i += 1) { + currentWriteDescriptorSet = &writeDescriptorSets[resourceLayout->numReadonlyStorageTextures + i]; currentWriteDescriptorSet->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; currentWriteDescriptorSet->pNext = NULL; currentWriteDescriptorSet->descriptorCount = 1; currentWriteDescriptorSet->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; currentWriteDescriptorSet->dstArrayElement = 0; - currentWriteDescriptorSet->dstBinding = resourceLayout->readOnlyStorageTextureCount + i; + currentWriteDescriptorSet->dstBinding = resourceLayout->numReadonlyStorageTextures + i; currentWriteDescriptorSet->dstSet = commandBuffer->computeReadOnlyDescriptorSet; currentWriteDescriptorSet->pTexelBufferView = NULL; currentWriteDescriptorSet->pImageInfo = NULL; @@ -8510,7 +8510,7 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( renderer->vkUpdateDescriptorSets( renderer->logicalDevice, - resourceLayout->readOnlyStorageTextureCount + resourceLayout->readOnlyStorageBufferCount, + resourceLayout->numReadonlyStorageTextures + resourceLayout->numReadonlyStorageBuffers, writeDescriptorSets, 0, NULL); @@ -8542,10 +8542,10 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( writeDescriptorSets = SDL_stack_alloc( VkWriteDescriptorSet, - resourceLayout->writeOnlyStorageTextureCount + - resourceLayout->writeOnlyStorageBufferCount); + resourceLayout->numWriteonlyStorageTextures + + resourceLayout->numWriteonlyStorageBuffers); - for (i = 0; i < resourceLayout->writeOnlyStorageTextureCount; i += 1) { + for (i = 0; i < resourceLayout->numWriteonlyStorageTextures; i += 1) { currentWriteDescriptorSet = &writeDescriptorSets[i]; currentWriteDescriptorSet->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; @@ -8567,15 +8567,15 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( imageInfoCount += 1; } - for (i = 0; i < resourceLayout->writeOnlyStorageBufferCount; i += 1) { - currentWriteDescriptorSet = &writeDescriptorSets[resourceLayout->writeOnlyStorageTextureCount + i]; + for (i = 0; i < resourceLayout->numWriteonlyStorageBuffers; i += 1) { + currentWriteDescriptorSet = &writeDescriptorSets[resourceLayout->numWriteonlyStorageTextures + i]; currentWriteDescriptorSet->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; currentWriteDescriptorSet->pNext = NULL; currentWriteDescriptorSet->descriptorCount = 1; currentWriteDescriptorSet->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; currentWriteDescriptorSet->dstArrayElement = 0; - currentWriteDescriptorSet->dstBinding = resourceLayout->writeOnlyStorageTextureCount + i; + currentWriteDescriptorSet->dstBinding = resourceLayout->numWriteonlyStorageTextures + i; currentWriteDescriptorSet->dstSet = commandBuffer->computeWriteOnlyDescriptorSet; currentWriteDescriptorSet->pTexelBufferView = NULL; currentWriteDescriptorSet->pImageInfo = NULL; @@ -8591,7 +8591,7 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( renderer->vkUpdateDescriptorSets( renderer->logicalDevice, - resourceLayout->writeOnlyStorageTextureCount + resourceLayout->writeOnlyStorageBufferCount, + resourceLayout->numWriteonlyStorageTextures + resourceLayout->numWriteonlyStorageBuffers, writeDescriptorSets, 0, NULL); @@ -8623,9 +8623,9 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( writeDescriptorSets = SDL_stack_alloc( VkWriteDescriptorSet, - resourceLayout->uniformBufferCount); + resourceLayout->numUniformBuffers); - for (i = 0; i < resourceLayout->uniformBufferCount; i += 1) { + for (i = 0; i < resourceLayout->numUniformBuffers; i += 1) { currentWriteDescriptorSet = &writeDescriptorSets[i]; currentWriteDescriptorSet->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; @@ -8649,7 +8649,7 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( renderer->vkUpdateDescriptorSets( renderer->logicalDevice, - resourceLayout->uniformBufferCount, + resourceLayout->numUniformBuffers, writeDescriptorSets, 0, NULL); @@ -8663,7 +8663,7 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( } if (commandBuffer->needNewComputeUniformOffsets) { - for (i = 0; i < resourceLayout->uniformBufferCount; i += 1) { + for (i = 0; i < resourceLayout->numUniformBuffers; i += 1) { dynamicOffsets[i] = commandBuffer->computeUniformBuffers[i]->drawOffset; } @@ -8674,7 +8674,7 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( 2, 1, &commandBuffer->computeUniformDescriptorSet, - resourceLayout->uniformBufferCount, + resourceLayout->numUniformBuffers, dynamicOffsets); commandBuffer->needNewComputeUniformOffsets = false; @@ -8683,9 +8683,9 @@ static void VULKAN_INTERNAL_BindComputeDescriptorSets( static void VULKAN_DispatchCompute( SDL_GPUCommandBuffer *commandBuffer, - Uint32 groupCountX, - Uint32 groupCountY, - Uint32 groupCountZ) + Uint32 groupcountX, + Uint32 groupcountY, + Uint32 groupcountZ) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; @@ -8694,15 +8694,15 @@ static void VULKAN_DispatchCompute( renderer->vkCmdDispatch( vulkanCommandBuffer->commandBuffer, - groupCountX, - groupCountY, - groupCountZ); + groupcountX, + groupcountY, + groupcountZ); } static void VULKAN_DispatchComputeIndirect( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUBuffer *buffer, - Uint32 offsetInBytes) + Uint32 offset) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; @@ -8713,7 +8713,7 @@ static void VULKAN_DispatchComputeIndirect( renderer->vkCmdDispatchIndirect( vulkanCommandBuffer->commandBuffer, vulkanBuffer->buffer, - offsetInBytes); + offset); VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, vulkanBuffer); } @@ -8824,7 +8824,7 @@ static void VULKAN_UploadToTexture( { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; - VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)source->transferBuffer; + VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)source->transfer_buffer; VulkanTextureContainer *vulkanTextureContainer = (VulkanTextureContainer *)destination->texture; VulkanTextureSubresource *vulkanTextureSubresource; VkBufferImageCopy imageCopy; @@ -8836,7 +8836,7 @@ static void VULKAN_UploadToTexture( vulkanCommandBuffer, vulkanTextureContainer, destination->layer, - destination->mipLevel, + destination->mip_level, cycle, VULKAN_TEXTURE_USAGE_MODE_COPY_DESTINATION); @@ -8849,10 +8849,10 @@ static void VULKAN_UploadToTexture( imageCopy.imageSubresource.aspectMask = vulkanTextureSubresource->parent->aspectFlags; imageCopy.imageSubresource.baseArrayLayer = destination->layer; imageCopy.imageSubresource.layerCount = 1; - imageCopy.imageSubresource.mipLevel = destination->mipLevel; + imageCopy.imageSubresource.mipLevel = destination->mip_level; imageCopy.bufferOffset = source->offset; - imageCopy.bufferRowLength = source->imagePitch; - imageCopy.bufferImageHeight = source->imageHeight; + imageCopy.bufferRowLength = source->pixels_per_row; + imageCopy.bufferImageHeight = source->rows_per_layer; renderer->vkCmdCopyBufferToImage( vulkanCommandBuffer->commandBuffer, @@ -8880,7 +8880,7 @@ static void VULKAN_UploadToBuffer( { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; - VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)source->transferBuffer; + VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)source->transfer_buffer; VulkanBufferContainer *bufferContainer = (VulkanBufferContainer *)destination->buffer; VkBufferCopy bufferCopy; @@ -8925,12 +8925,12 @@ static void VULKAN_DownloadFromTexture( VulkanRenderer *renderer = vulkanCommandBuffer->renderer; VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)source->texture; VulkanTextureSubresource *vulkanTextureSubresource; - VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)destination->transferBuffer; + VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)destination->transfer_buffer; VkBufferImageCopy imageCopy; vulkanTextureSubresource = VULKAN_INTERNAL_FetchTextureSubresource( textureContainer, source->layer, - source->mipLevel); + source->mip_level); // Note that the transfer buffer does not need a barrier, as it is synced by the client @@ -8949,10 +8949,10 @@ static void VULKAN_DownloadFromTexture( imageCopy.imageSubresource.aspectMask = vulkanTextureSubresource->parent->aspectFlags; imageCopy.imageSubresource.baseArrayLayer = source->layer; imageCopy.imageSubresource.layerCount = 1; - imageCopy.imageSubresource.mipLevel = source->mipLevel; + imageCopy.imageSubresource.mipLevel = source->mip_level; imageCopy.bufferOffset = destination->offset; - imageCopy.bufferRowLength = destination->imagePitch; - imageCopy.bufferImageHeight = destination->imageHeight; + imageCopy.bufferRowLength = destination->pixels_per_row; + imageCopy.bufferImageHeight = destination->rows_per_layer; renderer->vkCmdCopyImageToBuffer( vulkanCommandBuffer->commandBuffer, @@ -8980,7 +8980,7 @@ static void VULKAN_DownloadFromBuffer( VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = vulkanCommandBuffer->renderer; VulkanBufferContainer *bufferContainer = (VulkanBufferContainer *)source->buffer; - VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)destination->transferBuffer; + VulkanBufferContainer *transferBufferContainer = (VulkanBufferContainer *)destination->transfer_buffer; VkBufferCopy bufferCopy; // Note that transfer buffer does not need a barrier, as it is synced by the client @@ -9030,14 +9030,14 @@ static void VULKAN_CopyTextureToTexture( srcSubresource = VULKAN_INTERNAL_FetchTextureSubresource( (VulkanTextureContainer *)source->texture, source->layer, - source->mipLevel); + source->mip_level); dstSubresource = VULKAN_INTERNAL_PrepareTextureSubresourceForWrite( renderer, vulkanCommandBuffer, (VulkanTextureContainer *)destination->texture, destination->layer, - destination->mipLevel, + destination->mip_level, cycle, VULKAN_TEXTURE_USAGE_MODE_COPY_DESTINATION); @@ -9053,14 +9053,14 @@ static void VULKAN_CopyTextureToTexture( imageCopy.srcSubresource.aspectMask = srcSubresource->parent->aspectFlags; imageCopy.srcSubresource.baseArrayLayer = source->layer; imageCopy.srcSubresource.layerCount = 1; - imageCopy.srcSubresource.mipLevel = source->mipLevel; + imageCopy.srcSubresource.mipLevel = source->mip_level; imageCopy.dstOffset.x = destination->x; imageCopy.dstOffset.y = destination->y; imageCopy.dstOffset.z = destination->z; imageCopy.dstSubresource.aspectMask = dstSubresource->parent->aspectFlags; imageCopy.dstSubresource.baseArrayLayer = destination->layer; imageCopy.dstSubresource.layerCount = 1; - imageCopy.dstSubresource.mipLevel = destination->mipLevel; + imageCopy.dstSubresource.mipLevel = destination->mip_level; imageCopy.extent.width = w; imageCopy.extent.height = h; imageCopy.extent.depth = d; @@ -9156,18 +9156,18 @@ static void VULKAN_GenerateMipmaps( // Blit each slice sequentially. Barriers, barriers everywhere! for (Uint32 layerOrDepthIndex = 0; layerOrDepthIndex < vulkanTexture->layerCount; layerOrDepthIndex += 1) - for (Uint32 level = 1; level < vulkanTexture->levelCount; level += 1) { + for (Uint32 level = 1; level < vulkanTexture->numLevels; level += 1) { Uint32 layer = vulkanTexture->type == SDL_GPU_TEXTURETYPE_3D ? 0 : layerOrDepthIndex; Uint32 depth = vulkanTexture->type == SDL_GPU_TEXTURETYPE_3D ? layerOrDepthIndex : 0; Uint32 srcSubresourceIndex = VULKAN_INTERNAL_GetTextureSubresourceIndex( level - 1, layer, - vulkanTexture->levelCount); + vulkanTexture->numLevels); Uint32 dstSubresourceIndex = VULKAN_INTERNAL_GetTextureSubresourceIndex( level, layer, - vulkanTexture->levelCount); + vulkanTexture->numLevels); srcTextureSubresource = &vulkanTexture->subresources[srcSubresourceIndex]; dstTextureSubresource = &vulkanTexture->subresources[dstSubresourceIndex]; @@ -9249,7 +9249,7 @@ static void VULKAN_Blit( const SDL_GPUBlitRegion *source, const SDL_GPUBlitRegion *destination, SDL_FlipMode flipMode, - SDL_GPUFilter filterMode, + SDL_GPUFilter filter, bool cycle) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; @@ -9257,23 +9257,23 @@ static void VULKAN_Blit( TextureCommonHeader *srcHeader = (TextureCommonHeader *)source->texture; TextureCommonHeader *dstHeader = (TextureCommonHeader *)destination->texture; VkImageBlit region; - Uint32 srcLayer = srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : source->layerOrDepthPlane; - Uint32 srcDepth = srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? source->layerOrDepthPlane : 0; - Uint32 dstLayer = dstHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : destination->layerOrDepthPlane; - Uint32 dstDepth = dstHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? destination->layerOrDepthPlane : 0; + Uint32 srcLayer = srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : source->layer_or_depth_plane; + Uint32 srcDepth = srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? source->layer_or_depth_plane : 0; + Uint32 dstLayer = dstHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : destination->layer_or_depth_plane; + Uint32 dstDepth = dstHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? destination->layer_or_depth_plane : 0; int32_t swap; VulkanTextureSubresource *srcSubresource = VULKAN_INTERNAL_FetchTextureSubresource( (VulkanTextureContainer *)source->texture, srcLayer, - source->mipLevel); + source->mip_level); VulkanTextureSubresource *dstSubresource = VULKAN_INTERNAL_PrepareTextureSubresourceForWrite( renderer, vulkanCommandBuffer, (VulkanTextureContainer *)destination->texture, dstLayer, - destination->mipLevel, + destination->mip_level, cycle, VULKAN_TEXTURE_USAGE_MODE_COPY_DESTINATION); @@ -9327,7 +9327,7 @@ static void VULKAN_Blit( VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion, - SDLToVK_Filter[filterMode]); + SDLToVK_Filter[filter]); VULKAN_INTERNAL_TextureSubresourceTransitionToDefaultUsage( renderer, @@ -9920,8 +9920,8 @@ static bool VULKAN_INTERNAL_RecreateSwapchain( static SDL_GPUTexture *VULKAN_AcquireSwapchainTexture( SDL_GPUCommandBuffer *commandBuffer, SDL_Window *window, - Uint32 *pWidth, - Uint32 *pHeight) + Uint32 *w, + Uint32 *h) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer; @@ -10098,8 +10098,8 @@ static SDL_GPUTexture *VULKAN_AcquireSwapchainTexture( swapchainData->renderFinishedSemaphore[swapchainData->frameCounter]; vulkanCommandBuffer->signalSemaphoreCount += 1; - *pWidth = swapchainData->textureContainers[swapchainData->frameCounter].header.info.width; - *pHeight = swapchainData->textureContainers[swapchainData->frameCounter].header.info.height; + *w = swapchainData->textureContainers[swapchainData->frameCounter].header.info.width; + *h = swapchainData->textureContainers[swapchainData->frameCounter].header.info.height; return (SDL_GPUTexture *)swapchainTextureContainer; } @@ -10415,21 +10415,21 @@ static void VULKAN_INTERNAL_CleanCommandBuffer( static void VULKAN_WaitForFences( SDL_GPURenderer *driverData, bool waitAll, - SDL_GPUFence *const *pFences, - Uint32 fenceCount) + SDL_GPUFence *const *fences, + Uint32 numFences) { VulkanRenderer *renderer = (VulkanRenderer *)driverData; - VkFence *fences = SDL_stack_alloc(VkFence, fenceCount); + VkFence *vkFences = SDL_stack_alloc(VkFence, numFences); VkResult result; - for (Uint32 i = 0; i < fenceCount; i += 1) { - fences[i] = ((VulkanFenceHandle *)pFences[i])->fence; + for (Uint32 i = 0; i < numFences; i += 1) { + vkFences[i] = ((VulkanFenceHandle *)fences[i])->fence; } result = renderer->vkWaitForFences( renderer->logicalDevice, - fenceCount, - fences, + numFences, + vkFences, waitAll, UINT64_MAX); @@ -10437,7 +10437,7 @@ static void VULKAN_WaitForFences( LogVulkanResultAsError("vkWaitForFences", result); } - SDL_stack_free(fences); + SDL_stack_free(vkFences); SDL_LockMutex(renderer->submitLock); @@ -10774,7 +10774,7 @@ static Uint8 VULKAN_INTERNAL_DefragmentMemory( currentRegion->vulkanTexture->depth, currentRegion->vulkanTexture->type, currentRegion->vulkanTexture->layerCount, - currentRegion->vulkanTexture->levelCount, + currentRegion->vulkanTexture->numLevels, currentRegion->vulkanTexture->sampleCount, currentRegion->vulkanTexture->format, currentRegion->vulkanTexture->swizzle, @@ -11623,13 +11623,13 @@ static bool VULKAN_INTERNAL_PrepareVulkan( return true; } -static bool VULKAN_PrepareDriver(SDL_VideoDevice *_this) +static bool VULKAN_PrepareDriver(SDL_VideoDevice *this) { // Set up dummy VulkanRenderer VulkanRenderer *renderer; Uint8 result; - if (_this->Vulkan_CreateSurface == NULL) { + if (this->Vulkan_CreateSurface == NULL) { return false; } diff --git a/src/render/sdlgpu/SDL_pipeline_gpu.c b/src/render/sdlgpu/SDL_pipeline_gpu.c index a076aba9bc..b15bb1cd0c 100644 --- a/src/render/sdlgpu/SDL_pipeline_gpu.c +++ b/src/render/sdlgpu/SDL_pipeline_gpu.c @@ -97,34 +97,34 @@ void GPU_DestroyPipelineCache(GPU_PipelineCache *cache) static SDL_GPUGraphicsPipeline *MakePipeline(SDL_GPUDevice *device, GPU_Shaders *shaders, const GPU_PipelineParameters *params) { - SDL_GPUColorAttachmentDescription ad; + SDL_GPUColorTargetDescription ad; SDL_zero(ad); ad.format = params->attachment_format; SDL_BlendMode blend = params->blend_mode; - ad.blendState.blendEnable = blend != 0; - ad.blendState.colorWriteMask = 0xF; - ad.blendState.alphaBlendOp = GPU_ConvertBlendOperation(SDL_GetBlendModeAlphaOperation(blend)); - ad.blendState.dstAlphaBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstAlphaFactor(blend)); - ad.blendState.srcAlphaBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcAlphaFactor(blend)); - ad.blendState.colorBlendOp = GPU_ConvertBlendOperation(SDL_GetBlendModeColorOperation(blend)); - ad.blendState.dstColorBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstColorFactor(blend)); - ad.blendState.srcColorBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcColorFactor(blend)); + ad.blend_state.enable_blend = blend != 0; + ad.blend_state.color_write_mask = 0xF; + ad.blend_state.alpha_blend_op = GPU_ConvertBlendOperation(SDL_GetBlendModeAlphaOperation(blend)); + ad.blend_state.dst_alpha_blendfactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstAlphaFactor(blend)); + ad.blend_state.src_alpha_blendfactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcAlphaFactor(blend)); + ad.blend_state.color_blend_op = GPU_ConvertBlendOperation(SDL_GetBlendModeColorOperation(blend)); + ad.blend_state.dst_color_blendfactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstColorFactor(blend)); + ad.blend_state.src_color_blendfactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcColorFactor(blend)); SDL_GPUGraphicsPipelineCreateInfo pci; SDL_zero(pci); - pci.attachmentInfo.hasDepthStencilAttachment = false; - pci.attachmentInfo.colorAttachmentCount = 1; - pci.attachmentInfo.colorAttachmentDescriptions = &ad; - pci.vertexShader = GPU_GetVertexShader(shaders, params->vert_shader); - pci.fragmentShader = GPU_GetFragmentShader(shaders, params->frag_shader); - pci.multisampleState.sampleCount = SDL_GPU_SAMPLECOUNT_1; - pci.multisampleState.sampleMask = 0xFFFF; - pci.primitiveType = params->primitive_type; + pci.target_info.has_depth_stencil_target = false; + pci.target_info.num_color_targets = 1; + pci.target_info.color_target_descriptions = &ad; + pci.vertex_shader = GPU_GetVertexShader(shaders, params->vert_shader); + pci.fragment_shader = GPU_GetFragmentShader(shaders, params->frag_shader); + pci.multisample_state.sample_count = SDL_GPU_SAMPLECOUNT_1; + pci.multisample_state.sample_mask = 0xFFFF; + pci.primitive_type = params->primitive_type; - pci.rasterizerState.cullMode = SDL_GPU_CULLMODE_NONE; - pci.rasterizerState.fillMode = SDL_GPU_FILLMODE_FILL; - pci.rasterizerState.frontFace = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE; + pci.rasterizer_state.cull_mode = SDL_GPU_CULLMODE_NONE; + pci.rasterizer_state.fill_mode = SDL_GPU_FILLMODE_FILL; + pci.rasterizer_state.front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE; SDL_GPUVertexBinding bind; SDL_zero(bind); @@ -150,16 +150,16 @@ static SDL_GPUGraphicsPipeline *MakePipeline(SDL_GPUDevice *device, GPU_Shaders // Position attribs[num_attribs].location = num_attribs; attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2; - attribs[num_attribs].offset = bind.stride; - bind.stride += 2 * sizeof(float); + attribs[num_attribs].offset = bind.pitch; + bind.pitch += 2 * sizeof(float); num_attribs++; if (have_attr_color) { // Color attribs[num_attribs].location = num_attribs; attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4; - attribs[num_attribs].offset = bind.stride; - bind.stride += 4 * sizeof(float); + attribs[num_attribs].offset = bind.pitch; + bind.pitch += 4 * sizeof(float); num_attribs++; } @@ -167,15 +167,15 @@ static SDL_GPUGraphicsPipeline *MakePipeline(SDL_GPUDevice *device, GPU_Shaders // UVs attribs[num_attribs].location = num_attribs; attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2; - attribs[num_attribs].offset = bind.stride; - bind.stride += 2 * sizeof(float); + attribs[num_attribs].offset = bind.pitch; + bind.pitch += 2 * sizeof(float); num_attribs++; } - pci.vertexInputState.vertexAttributeCount = num_attribs; - pci.vertexInputState.vertexAttributes = attribs; - pci.vertexInputState.vertexBindingCount = 1; - pci.vertexInputState.vertexBindings = &bind; + pci.vertex_input_state.num_vertex_attributes = num_attribs; + pci.vertex_input_state.vertex_attributes = attribs; + pci.vertex_input_state.num_vertex_bindings = 1; + pci.vertex_input_state.vertex_bindings = &bind; return SDL_CreateGPUGraphicsPipeline(device, &pci); } diff --git a/src/render/sdlgpu/SDL_render_gpu.c b/src/render/sdlgpu/SDL_render_gpu.c index c5403a095d..af5f61dd4e 100644 --- a/src/render/sdlgpu/SDL_render_gpu.c +++ b/src/render/sdlgpu/SDL_render_gpu.c @@ -69,7 +69,7 @@ typedef struct GPU_RenderData SDL_GPURenderPass *render_pass; SDL_Texture *render_target; SDL_GPUCommandBuffer *command_buffer; - SDL_GPUColorAttachmentInfo color_attachment; + SDL_GPUColorTargetInfo color_attachment; SDL_GPUViewport viewport; SDL_Rect scissor; SDL_FColor draw_color; @@ -219,12 +219,12 @@ static bool GPU_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ SDL_GPUTextureCreateInfo tci; SDL_zero(tci); tci.format = format; - tci.layerCountOrDepth = 1; - tci.levelCount = 1; - tci.usageFlags = usage; + tci.layer_count_or_depth = 1; + tci.num_levels = 1; + tci.usage = usage; tci.width = texture->w; tci.height = texture->h; - tci.sampleCount = SDL_GPU_SAMPLECOUNT_1; + tci.sample_count = SDL_GPU_SAMPLECOUNT_1; data->format = format; data->texture = SDL_CreateGPUTexture(renderdata->device, &tci); @@ -258,7 +258,7 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_GPUTransferBufferCreateInfo tbci; SDL_zero(tbci); - tbci.sizeInBytes = (Uint32)data_size; + tbci.size = (Uint32)data_size; tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; SDL_GPUTransferBuffer *tbuf = SDL_CreateGPUTransferBuffer(renderdata->device, &tbci); @@ -273,7 +273,7 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, memcpy(output, pixels, data_size); } else { // FIXME is negative pitch supposed to work? - // If not, maybe use SDL_GPUTextureTransferInfo::imagePitch instead of this + // If not, maybe use SDL_GPUTextureTransferInfo::pixels_per_row instead of this const Uint8 *input = pixels; for (int i = 0; i < rect->h; ++i) { @@ -290,9 +290,9 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_GPUTextureTransferInfo tex_src; SDL_zero(tex_src); - tex_src.transferBuffer = tbuf; - tex_src.imageHeight = rect->h; - tex_src.imagePitch = rect->w; + tex_src.transfer_buffer = tbuf; + tex_src.rows_per_layer = rect->h; + tex_src.pixels_per_row = rect->w; SDL_GPUTextureRegion tex_dst; SDL_zero(tex_dst); @@ -467,7 +467,7 @@ static SDL_GPURenderPass *RestartRenderPass(GPU_RenderData *data) // This is busted. We should be able to know which load op to use. // LOAD is incorrect behavior most of the time, unless we had to break a render pass. // -cosmonaut - data->state.color_attachment.loadOp = SDL_GPU_LOADOP_LOAD; + data->state.color_attachment.load_op = SDL_GPU_LOADOP_LOAD; data->state.scissor_was_enabled = false; return data->state.render_pass; @@ -524,7 +524,7 @@ static void Draw( Uint32 offset, SDL_GPUPrimitiveType prim) { - if (!data->state.render_pass || data->state.color_attachment.loadOp == SDL_GPU_LOADOP_CLEAR) { + if (!data->state.render_pass || data->state.color_attachment.load_op == SDL_GPU_LOADOP_CLEAR) { RestartRenderPass(data); } @@ -607,8 +607,8 @@ static bool InitVertexBuffer(GPU_RenderData *data, Uint32 size) { SDL_GPUBufferCreateInfo bci; SDL_zero(bci); - bci.sizeInBytes = size; - bci.usageFlags = SDL_GPU_BUFFERUSAGE_VERTEX; + bci.size = size; + bci.usage = SDL_GPU_BUFFERUSAGE_VERTEX; data->vertices.buffer = SDL_CreateGPUBuffer(data->device, &bci); @@ -618,7 +618,7 @@ static bool InitVertexBuffer(GPU_RenderData *data, Uint32 size) SDL_GPUTransferBufferCreateInfo tbci; SDL_zero(tbci); - tbci.sizeInBytes = size; + tbci.size = size; tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; data->vertices.transfer_buf = SDL_CreateGPUTransferBuffer(data->device, &tbci); @@ -655,7 +655,7 @@ static bool UploadVertices(GPU_RenderData *data, void *vertices, size_t vertsize SDL_GPUTransferBufferLocation src; SDL_zero(src); - src.transferBuffer = data->vertices.transfer_buf; + src.transfer_buffer = data->vertices.transfer_buf; SDL_GPUBufferRegion dst; SDL_zero(dst); @@ -685,7 +685,7 @@ static bool GPU_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, return false; } - data->state.color_attachment.loadOp = SDL_GPU_LOADOP_LOAD; + data->state.color_attachment.load_op = SDL_GPU_LOADOP_LOAD; if (renderer->target) { GPU_TextureData *tdata = renderer->target->internal; @@ -729,8 +729,8 @@ static bool GPU_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, case SDL_RENDERCMD_CLEAR: { - data->state.color_attachment.clearColor = GetDrawCmdColor(renderer, cmd); - data->state.color_attachment.loadOp = SDL_GPU_LOADOP_CLEAR; + data->state.color_attachment.clear_color = GetDrawCmdColor(renderer, cmd); + data->state.color_attachment.load_op = SDL_GPU_LOADOP_CLEAR; break; } @@ -823,7 +823,7 @@ static bool GPU_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, cmd = cmd->next; } - if (data->state.color_attachment.loadOp == SDL_GPU_LOADOP_CLEAR) { + if (data->state.color_attachment.load_op == SDL_GPU_LOADOP_CLEAR) { RestartRenderPass(data); } @@ -873,7 +873,7 @@ static SDL_Surface *GPU_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect SDL_GPUTransferBufferCreateInfo tbci; SDL_zero(tbci); - tbci.sizeInBytes = (Uint32)image_size; + tbci.size = (Uint32)image_size; tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD; SDL_GPUTransferBuffer *tbuf = SDL_CreateGPUTransferBuffer(data->device, &tbci); @@ -895,9 +895,9 @@ static SDL_Surface *GPU_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect SDL_GPUTextureTransferInfo dst; SDL_zero(dst); - dst.transferBuffer = tbuf; - dst.imageHeight = rect->h; - dst.imagePitch = rect->w; + dst.transfer_buffer = tbuf; + dst.rows_per_layer = rect->h; + dst.pixels_per_row = rect->w; SDL_DownloadFromGPUTexture(pass, &src, &dst); SDL_EndGPUCopyPass(pass); @@ -935,10 +935,10 @@ static bool CreateBackbuffer(GPU_RenderData *data, Uint32 w, Uint32 h, SDL_GPUTe tci.width = w; tci.height = h; tci.format = fmt; - tci.layerCountOrDepth = 1; - tci.levelCount = 1; - tci.sampleCount = SDL_GPU_SAMPLECOUNT_1; - tci.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER; + tci.layer_count_or_depth = 1; + tci.num_levels = 1; + tci.sample_count = SDL_GPU_SAMPLECOUNT_1; + tci.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER; data->backbuffer.texture = SDL_CreateGPUTexture(data->device, &tci); data->backbuffer.width = w; @@ -1167,11 +1167,11 @@ static bool InitSamplers(GPU_RenderData *data) for (Uint32 i = 0; i < SDL_arraysize(configs); ++i) { SDL_GPUSamplerCreateInfo sci; SDL_zero(sci); - sci.maxAnisotropy = configs[i].gpu.anisotropy; - sci.anisotropyEnable = configs[i].gpu.anisotropy > 0; - sci.addressModeU = sci.addressModeV = sci.addressModeW = configs[i].gpu.address_mode; - sci.minFilter = sci.magFilter = configs[i].gpu.filter; - sci.mipmapMode = configs[i].gpu.mipmap_mode; + sci.max_anisotropy = configs[i].gpu.anisotropy; + sci.enable_anisotropy = configs[i].gpu.anisotropy > 0; + sci.address_mode_u = sci.address_mode_v = sci.address_mode_w = configs[i].gpu.address_mode; + sci.min_filter = sci.mag_filter = configs[i].gpu.filter; + sci.mipmap_mode = configs[i].gpu.mipmap_mode; SDL_GPUSampler *sampler = SDL_CreateGPUSampler(data->device, &sci); @@ -1286,8 +1286,8 @@ static bool GPU_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P data->state.draw_color.g = 1.0f; data->state.draw_color.b = 1.0f; data->state.draw_color.a = 1.0f; - data->state.viewport.minDepth = 0; - data->state.viewport.maxDepth = 1; + data->state.viewport.min_depth = 0; + data->state.viewport.max_depth = 1; data->state.command_buffer = SDL_AcquireGPUCommandBuffer(data->device); int w, h; diff --git a/src/render/sdlgpu/SDL_shaders_gpu.c b/src/render/sdlgpu/SDL_shaders_gpu.c index 1b60b7c6a4..e71b49c266 100644 --- a/src/render/sdlgpu/SDL_shaders_gpu.c +++ b/src/render/sdlgpu/SDL_shaders_gpu.c @@ -167,12 +167,12 @@ static SDL_GPUShader *CompileShader(const GPU_ShaderSources *sources, SDL_GPUDev SDL_GPUShaderCreateInfo sci = { 0 }; sci.code = sms->code; - sci.codeSize = sms->code_len; + sci.code_size = sms->code_len; sci.format = sms->format; // FIXME not sure if this is correct - sci.entryPointName = driver == SDL_GPU_DRIVER_METAL ? "main0" : "main"; - sci.samplerCount = sources->num_samplers; - sci.uniformBufferCount = sources->num_uniform_buffers; + sci.entrypoint = driver == SDL_GPU_DRIVER_METAL ? "main0" : "main"; + sci.num_samplers = sources->num_samplers; + sci.num_uniform_buffers = sources->num_uniform_buffers; sci.stage = stage; return SDL_CreateGPUShader(device, &sci); diff --git a/test/testgpu_simple_clear.c b/test/testgpu_simple_clear.c index 904526d5de..ea9d2eb6fe 100644 --- a/test/testgpu_simple_clear.c +++ b/test/testgpu_simple_clear.c @@ -89,17 +89,17 @@ SDL_AppResult SDL_AppIterate(void *appstate) if (swapchainTexture != NULL) { const double currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency(); SDL_GPURenderPass *renderPass; - SDL_GPUColorAttachmentInfo colorAttachmentInfo; - SDL_zero(colorAttachmentInfo); - colorAttachmentInfo.texture = swapchainTexture; - colorAttachmentInfo.clearColor.r = (float)(0.5 + 0.5 * SDL_sin(currentTime)); - colorAttachmentInfo.clearColor.g = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 2 / 3)); - colorAttachmentInfo.clearColor.b = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 4 / 3));; - colorAttachmentInfo.clearColor.a = 1.0f; - colorAttachmentInfo.loadOp = SDL_GPU_LOADOP_CLEAR; - colorAttachmentInfo.storeOp = SDL_GPU_STOREOP_STORE; + SDL_GPUColorTargetInfo color_target_info; + SDL_zero(color_target_info); + color_target_info.texture = swapchainTexture; + color_target_info.clear_color.r = (float)(0.5 + 0.5 * SDL_sin(currentTime)); + color_target_info.clear_color.g = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 2 / 3)); + color_target_info.clear_color.b = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 4 / 3));; + color_target_info.clear_color.a = 1.0f; + color_target_info.load_op = SDL_GPU_LOADOP_CLEAR; + color_target_info.store_op = SDL_GPU_STOREOP_STORE; - renderPass = SDL_BeginGPURenderPass(cmdbuf, &colorAttachmentInfo, 1, NULL); + renderPass = SDL_BeginGPURenderPass(cmdbuf, &color_target_info, 1, NULL); SDL_EndGPURenderPass(renderPass); } @@ -122,4 +122,3 @@ void SDL_AppQuit(void *appstate) SDL_DestroyGPUDevice(gpu_device); SDLTest_CommonQuit(state); } - diff --git a/test/testgpu_spinning_cube.c b/test/testgpu_spinning_cube.c index dbf5f923e7..ad417ab9d2 100644 --- a/test/testgpu_spinning_cube.c +++ b/test/testgpu_spinning_cube.c @@ -256,10 +256,10 @@ CreateDepthTexture(Uint32 drawablew, Uint32 drawableh) depthtex_createinfo.format = SDL_GPU_TEXTUREFORMAT_D16_UNORM; depthtex_createinfo.width = drawablew; depthtex_createinfo.height = drawableh; - depthtex_createinfo.layerCountOrDepth = 1; - depthtex_createinfo.levelCount = 1; - depthtex_createinfo.sampleCount = render_state.sample_count; - depthtex_createinfo.usageFlags = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET; + depthtex_createinfo.layer_count_or_depth = 1; + depthtex_createinfo.num_levels = 1; + depthtex_createinfo.sample_count = render_state.sample_count; + depthtex_createinfo.usage = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET; depthtex_createinfo.props = 0; result = SDL_CreateGPUTexture(gpu_device, &depthtex_createinfo); @@ -282,10 +282,10 @@ CreateMSAATexture(Uint32 drawablew, Uint32 drawableh) msaatex_createinfo.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]); msaatex_createinfo.width = drawablew; msaatex_createinfo.height = drawableh; - msaatex_createinfo.layerCountOrDepth = 1; - msaatex_createinfo.levelCount = 1; - msaatex_createinfo.sampleCount = render_state.sample_count; - msaatex_createinfo.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER; + msaatex_createinfo.layer_count_or_depth = 1; + msaatex_createinfo.num_levels = 1; + msaatex_createinfo.sample_count = render_state.sample_count; + msaatex_createinfo.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER; msaatex_createinfo.props = 0; result = SDL_CreateGPUTexture(gpu_device, &msaatex_createinfo); @@ -299,8 +299,8 @@ Render(SDL_Window *window, const int windownum) { WindowState *winstate = &window_states[windownum]; SDL_GPUTexture *swapchain; - SDL_GPUColorAttachmentInfo color_attachment; - SDL_GPUDepthStencilAttachmentInfo depth_attachment; + SDL_GPUColorTargetInfo color_target; + SDL_GPUDepthStencilTargetInfo depth_target; float matrix_rotate[16], matrix_modelview[16], matrix_perspective[16], matrix_final[16]; Uint32 drawablew, drawableh; SDL_GPUCommandBuffer *cmd; @@ -363,18 +363,18 @@ Render(SDL_Window *window, const int windownum) /* Set up the pass */ - SDL_zero(color_attachment); - color_attachment.clearColor.a = 1.0f; - color_attachment.loadOp = SDL_GPU_LOADOP_CLEAR; - color_attachment.storeOp = SDL_GPU_STOREOP_STORE; - color_attachment.texture = winstate->tex_msaa ? winstate->tex_msaa : swapchain; + SDL_zero(color_target); + color_target.clear_color.a = 1.0f; + color_target.load_op = SDL_GPU_LOADOP_CLEAR; + color_target.store_op = SDL_GPU_STOREOP_STORE; + color_target.texture = winstate->tex_msaa ? winstate->tex_msaa : swapchain; - SDL_zero(depth_attachment); - depth_attachment.depthStencilClearValue.depth = 1.0f; - depth_attachment.loadOp = SDL_GPU_LOADOP_CLEAR; - depth_attachment.storeOp = SDL_GPU_STOREOP_DONT_CARE; - depth_attachment.texture = winstate->tex_depth; - depth_attachment.cycle = SDL_TRUE; + SDL_zero(depth_target); + depth_target.clear_value.depth = 1.0f; + depth_target.load_op = SDL_GPU_LOADOP_CLEAR; + depth_target.store_op = SDL_GPU_STOREOP_DONT_CARE; + depth_target.texture = winstate->tex_depth; + depth_target.cycle = SDL_TRUE; /* Set up the bindings */ @@ -385,7 +385,7 @@ Render(SDL_Window *window, const int windownum) SDL_PushGPUVertexUniformData(cmd, 0, matrix_final, sizeof(matrix_final)); - pass = SDL_BeginGPURenderPass(cmd, &color_attachment, 1, &depth_attachment); + pass = SDL_BeginGPURenderPass(cmd, &color_target, 1, &depth_target); SDL_BindGPUGraphicsPipeline(pass, render_state.pipeline); SDL_BindGPUVertexBuffers(pass, 0, &vertex_binding, 1); SDL_DrawGPUPrimitives(pass, 36, 1, 0, 0); @@ -414,33 +414,33 @@ static SDL_GPUShader* load_shader(SDL_bool is_vertex) { SDL_GPUShaderCreateInfo createinfo; - createinfo.samplerCount = 0; - createinfo.storageBufferCount = 0; - createinfo.storageTextureCount = 0; - createinfo.uniformBufferCount = is_vertex ? 1 : 0; + createinfo.num_samplers = 0; + createinfo.num_storage_buffers = 0; + createinfo.num_storage_textures = 0; + createinfo.num_uniform_buffers = is_vertex ? 1 : 0; createinfo.props = 0; SDL_GPUDriver backend = SDL_GetGPUDriver(gpu_device); if (backend == SDL_GPU_DRIVER_D3D11) { createinfo.format = SDL_GPU_SHADERFORMAT_DXBC; createinfo.code = is_vertex ? D3D11_CubeVert : D3D11_CubeFrag; - createinfo.codeSize = is_vertex ? SDL_arraysize(D3D11_CubeVert) : SDL_arraysize(D3D11_CubeFrag); - createinfo.entryPointName = is_vertex ? "VSMain" : "PSMain"; + createinfo.code_size = is_vertex ? SDL_arraysize(D3D11_CubeVert) : SDL_arraysize(D3D11_CubeFrag); + createinfo.entrypoint = is_vertex ? "VSMain" : "PSMain"; } else if (backend == SDL_GPU_DRIVER_D3D12) { createinfo.format = SDL_GPU_SHADERFORMAT_DXIL; createinfo.code = is_vertex ? D3D12_CubeVert : D3D12_CubeFrag; - createinfo.codeSize = is_vertex ? SDL_arraysize(D3D12_CubeVert) : SDL_arraysize(D3D12_CubeFrag); - createinfo.entryPointName = is_vertex ? "VSMain" : "PSMain"; + createinfo.code_size = is_vertex ? SDL_arraysize(D3D12_CubeVert) : SDL_arraysize(D3D12_CubeFrag); + createinfo.entrypoint = is_vertex ? "VSMain" : "PSMain"; } else if (backend == SDL_GPU_DRIVER_METAL) { createinfo.format = SDL_GPU_SHADERFORMAT_METALLIB; createinfo.code = is_vertex ? cube_vert_metallib : cube_frag_metallib; - createinfo.codeSize = is_vertex ? cube_vert_metallib_len : cube_frag_metallib_len; - createinfo.entryPointName = is_vertex ? "vs_main" : "fs_main"; + createinfo.code_size = is_vertex ? cube_vert_metallib_len : cube_frag_metallib_len; + createinfo.entrypoint = is_vertex ? "vs_main" : "fs_main"; } else { createinfo.format = SDL_GPU_SHADERFORMAT_SPIRV; createinfo.code = is_vertex ? cube_vert_spv : cube_frag_spv; - createinfo.codeSize = is_vertex ? cube_vert_spv_len : cube_frag_spv_len; - createinfo.entryPointName = "main"; + createinfo.code_size = is_vertex ? cube_vert_spv_len : cube_frag_spv_len; + createinfo.entrypoint = "main"; } createinfo.stage = is_vertex ? SDL_GPU_SHADERSTAGE_VERTEX : SDL_GPU_SHADERSTAGE_FRAGMENT; @@ -459,7 +459,7 @@ init_render_state(int msaa) SDL_GPUBufferCreateInfo buffer_desc; SDL_GPUTransferBufferCreateInfo transfer_buffer_desc; SDL_GPUGraphicsPipelineCreateInfo pipelinedesc; - SDL_GPUColorAttachmentDescription color_attachment_desc; + SDL_GPUColorTargetDescription color_target_desc; Uint32 drawablew, drawableh; SDL_GPUVertexAttribute vertex_attributes[2]; SDL_GPUVertexBinding vertex_binding; @@ -492,8 +492,8 @@ init_render_state(int msaa) /* Create buffers */ - buffer_desc.usageFlags = SDL_GPU_BUFFERUSAGE_VERTEX; - buffer_desc.sizeInBytes = sizeof(vertex_data); + buffer_desc.usage = SDL_GPU_BUFFERUSAGE_VERTEX; + buffer_desc.size = sizeof(vertex_data); buffer_desc.props = 0; render_state.buf_vertex = SDL_CreateGPUBuffer( gpu_device, @@ -504,7 +504,7 @@ init_render_state(int msaa) SDL_SetGPUBufferName(gpu_device, render_state.buf_vertex, "космонавт"); transfer_buffer_desc.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; - transfer_buffer_desc.sizeInBytes = sizeof(vertex_data); + transfer_buffer_desc.size = sizeof(vertex_data); transfer_buffer_desc.props = 0; buf_transfer = SDL_CreateGPUTransferBuffer( gpu_device, @@ -519,7 +519,7 @@ init_render_state(int msaa) cmd = SDL_AcquireGPUCommandBuffer(gpu_device); copy_pass = SDL_BeginGPUCopyPass(cmd); - buf_location.transferBuffer = buf_transfer; + buf_location.transfer_buffer = buf_transfer; buf_location.offset = 0; dst_region.buffer = render_state.buf_vertex; dst_region.offset = 0; @@ -543,38 +543,38 @@ init_render_state(int msaa) SDL_zero(pipelinedesc); - color_attachment_desc.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]); + color_target_desc.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]); - color_attachment_desc.blendState.blendEnable = 0; - color_attachment_desc.blendState.alphaBlendOp = SDL_GPU_BLENDOP_ADD; - color_attachment_desc.blendState.colorBlendOp = SDL_GPU_BLENDOP_ADD; - color_attachment_desc.blendState.colorWriteMask = 0xF; - color_attachment_desc.blendState.srcAlphaBlendFactor = SDL_GPU_BLENDFACTOR_ONE; - color_attachment_desc.blendState.dstAlphaBlendFactor = SDL_GPU_BLENDFACTOR_ZERO; - color_attachment_desc.blendState.srcColorBlendFactor = SDL_GPU_BLENDFACTOR_ONE; - color_attachment_desc.blendState.dstColorBlendFactor = SDL_GPU_BLENDFACTOR_ZERO; + color_target_desc.blend_state.enable_blend = 0; + color_target_desc.blend_state.alpha_blend_op = SDL_GPU_BLENDOP_ADD; + color_target_desc.blend_state.color_blend_op = SDL_GPU_BLENDOP_ADD; + color_target_desc.blend_state.color_write_mask = 0xF; + color_target_desc.blend_state.src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE; + color_target_desc.blend_state.dst_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ZERO; + color_target_desc.blend_state.src_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE; + color_target_desc.blend_state.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ZERO; - pipelinedesc.attachmentInfo.colorAttachmentCount = 1; - pipelinedesc.attachmentInfo.colorAttachmentDescriptions = &color_attachment_desc; - pipelinedesc.attachmentInfo.depthStencilFormat = SDL_GPU_TEXTUREFORMAT_D16_UNORM; - pipelinedesc.attachmentInfo.hasDepthStencilAttachment = SDL_TRUE; + pipelinedesc.target_info.num_color_targets = 1; + pipelinedesc.target_info.color_target_descriptions = &color_target_desc; + pipelinedesc.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D16_UNORM; + pipelinedesc.target_info.has_depth_stencil_target = SDL_TRUE; - pipelinedesc.depthStencilState.depthTestEnable = 1; - pipelinedesc.depthStencilState.depthWriteEnable = 1; - pipelinedesc.depthStencilState.compareOp = SDL_GPU_COMPAREOP_LESS_OR_EQUAL; + pipelinedesc.depth_stencil_state.enable_depth_test = 1; + pipelinedesc.depth_stencil_state.enable_depth_write = 1; + pipelinedesc.depth_stencil_state.compare_op = SDL_GPU_COMPAREOP_LESS_OR_EQUAL; - pipelinedesc.multisampleState.sampleCount = render_state.sample_count; - pipelinedesc.multisampleState.sampleMask = 0xF; + pipelinedesc.multisample_state.sample_count = render_state.sample_count; + pipelinedesc.multisample_state.sample_mask = 0xF; - pipelinedesc.primitiveType = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; + pipelinedesc.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; - pipelinedesc.vertexShader = vertex_shader; - pipelinedesc.fragmentShader = fragment_shader; + pipelinedesc.vertex_shader = vertex_shader; + pipelinedesc.fragment_shader = fragment_shader; vertex_binding.binding = 0; - vertex_binding.inputRate = SDL_GPU_VERTEXINPUTRATE_VERTEX; - vertex_binding.instanceStepRate = 0; - vertex_binding.stride = sizeof(VertexData); + vertex_binding.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX; + vertex_binding.instance_step_rate = 0; + vertex_binding.pitch = sizeof(VertexData); vertex_attributes[0].binding = 0; vertex_attributes[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3; @@ -586,10 +586,10 @@ init_render_state(int msaa) vertex_attributes[1].location = 1; vertex_attributes[1].offset = sizeof(float) * 3; - pipelinedesc.vertexInputState.vertexBindingCount = 1; - pipelinedesc.vertexInputState.vertexBindings = &vertex_binding; - pipelinedesc.vertexInputState.vertexAttributeCount = 2; - pipelinedesc.vertexInputState.vertexAttributes = (SDL_GPUVertexAttribute*) &vertex_attributes; + pipelinedesc.vertex_input_state.num_vertex_bindings = 1; + pipelinedesc.vertex_input_state.vertex_bindings = &vertex_binding; + pipelinedesc.vertex_input_state.num_vertex_attributes = 2; + pipelinedesc.vertex_input_state.vertex_attributes = (SDL_GPUVertexAttribute*) &vertex_attributes; pipelinedesc.props = 0;