diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index f9157ad5f99b74..706ca8cf9acf40 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -154,10 +154,10 @@ #define SDL_gpu_h_ #include -#include #include #include #include +#include #include #include @@ -390,9 +390,9 @@ typedef enum SDL_GPUPrimitiveType */ typedef enum SDL_GPULoadOp { - SDL_GPU_LOADOP_LOAD, /**< The previous contents of the texture will be preserved. */ - SDL_GPU_LOADOP_CLEAR, /**< The contents of the texture will be cleared to a color. */ - SDL_GPU_LOADOP_DONT_CARE /**< The previous contents of the texture need not be preserved. The contents will be undefined. */ + SDL_GPU_LOADOP_LOAD, /**< The previous contents of the texture will be preserved. */ + SDL_GPU_LOADOP_CLEAR, /**< The contents of the texture will be cleared to a color. */ + SDL_GPU_LOADOP_DONT_CARE /**< The previous contents of the texture need not be preserved. The contents will be undefined. */ } SDL_GPULoadOp; /** @@ -405,10 +405,10 @@ typedef enum SDL_GPULoadOp */ typedef enum SDL_GPUStoreOp { - SDL_GPU_STOREOP_STORE, /**< The contents generated during the render pass will be written to memory. */ - SDL_GPU_STOREOP_DONT_CARE, /**< The contents generated during the render pass are not needed and may be discarded. The contents will be undefined. */ - SDL_GPU_STOREOP_RESOLVE, /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture may then be discarded and will be undefined. */ - SDL_GPU_STOREOP_RESOLVE_AND_STORE /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture will be written to memory. */ + SDL_GPU_STOREOP_STORE, /**< The contents generated during the render pass will be written to memory. */ + SDL_GPU_STOREOP_DONT_CARE, /**< The contents generated during the render pass are not needed and may be discarded. The contents will be undefined. */ + SDL_GPU_STOREOP_RESOLVE, /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture may then be discarded and will be undefined. */ + SDL_GPU_STOREOP_RESOLVE_AND_STORE /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture will be written to memory. */ } SDL_GPUStoreOp; /** @@ -674,11 +674,11 @@ typedef Uint32 SDL_GPUTextureUsageFlags; */ typedef enum SDL_GPUTextureType { - SDL_GPU_TEXTURETYPE_2D, /**< The texture is a 2-dimensional image. */ - SDL_GPU_TEXTURETYPE_2D_ARRAY, /**< The texture is a 2-dimensional array image. */ - SDL_GPU_TEXTURETYPE_3D, /**< The texture is a 3-dimensional image. */ - SDL_GPU_TEXTURETYPE_CUBE, /**< The texture is a cube image. */ - SDL_GPU_TEXTURETYPE_CUBE_ARRAY /**< The texture is a cube array image. */ + SDL_GPU_TEXTURETYPE_2D, /**< The texture is a 2-dimensional image. */ + SDL_GPU_TEXTURETYPE_2D_ARRAY, /**< The texture is a 2-dimensional array image. */ + SDL_GPU_TEXTURETYPE_3D, /**< The texture is a 3-dimensional image. */ + SDL_GPU_TEXTURETYPE_CUBE, /**< The texture is a cube image. */ + SDL_GPU_TEXTURETYPE_CUBE_ARRAY /**< The texture is a cube array image. */ } SDL_GPUTextureType; /** @@ -694,13 +694,12 @@ typedef enum SDL_GPUTextureType */ typedef enum SDL_GPUSampleCount { - SDL_GPU_SAMPLECOUNT_1, /**< No multisampling. */ - SDL_GPU_SAMPLECOUNT_2, /**< MSAA 2x */ - SDL_GPU_SAMPLECOUNT_4, /**< MSAA 4x */ - SDL_GPU_SAMPLECOUNT_8 /**< MSAA 8x */ + SDL_GPU_SAMPLECOUNT_1, /**< No multisampling. */ + SDL_GPU_SAMPLECOUNT_2, /**< MSAA 2x */ + SDL_GPU_SAMPLECOUNT_4, /**< MSAA 4x */ + SDL_GPU_SAMPLECOUNT_8 /**< MSAA 8x */ } SDL_GPUSampleCount; - /** * Specifies the face of a cube map. * @@ -733,12 +732,12 @@ typedef enum SDL_GPUCubeMapFace */ typedef Uint32 SDL_GPUBufferUsageFlags; -#define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0) /**< Buffer is a vertex buffer. */ -#define SDL_GPU_BUFFERUSAGE_INDEX (1u << 1) /**< Buffer is an index buffer. */ -#define SDL_GPU_BUFFERUSAGE_INDIRECT (1u << 2) /**< Buffer is an indirect buffer. */ -#define SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Buffer supports storage reads in graphics stages. */ -#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Buffer supports storage reads in the compute stage. */ -#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Buffer supports storage writes in the compute stage. */ +#define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0) /**< Buffer is a vertex buffer. */ +#define SDL_GPU_BUFFERUSAGE_INDEX (1u << 1) /**< Buffer is an index buffer. */ +#define SDL_GPU_BUFFERUSAGE_INDIRECT (1u << 2) /**< Buffer is an indirect buffer. */ +#define SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Buffer supports storage reads in graphics stages. */ +#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Buffer supports storage reads in the compute stage. */ +#define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Buffer supports storage writes in the compute stage. */ /** * Specifies how a transfer buffer is intended to be used by the client. @@ -787,6 +786,7 @@ typedef Uint32 SDL_GPUShaderFormat; #define SDL_GPU_SHADERFORMAT_DXIL (1u << 3) /**< DXIL SM6_0 shaders for D3D12. */ #define SDL_GPU_SHADERFORMAT_MSL (1u << 4) /**< MSL shaders for Metal. */ #define SDL_GPU_SHADERFORMAT_METALLIB (1u << 5) /**< Precompiled metallib shaders for Metal. */ +#define SDL_GPU_SHADERFORMAT_WGSL (1u << 6) /**< WGSL shaders for WebGPU. */ /** * Specifies the format of a vertex attribute. @@ -863,8 +863,8 @@ typedef enum SDL_GPUVertexElementFormat */ typedef enum SDL_GPUVertexInputRate { - SDL_GPU_VERTEXINPUTRATE_VERTEX, /**< Attribute addressing is a function of the vertex index. */ - SDL_GPU_VERTEXINPUTRATE_INSTANCE /**< Attribute addressing is a function of the instance index. */ + SDL_GPU_VERTEXINPUTRATE_VERTEX, /**< Attribute addressing is a function of the vertex index. */ + SDL_GPU_VERTEXINPUTRATE_INSTANCE /**< Attribute addressing is a function of the instance index. */ } SDL_GPUVertexInputRate; /** @@ -876,8 +876,8 @@ typedef enum SDL_GPUVertexInputRate */ typedef enum SDL_GPUFillMode { - SDL_GPU_FILLMODE_FILL, /**< Polygons will be rendered via rasterization. */ - SDL_GPU_FILLMODE_LINE /**< Polygon edges will be drawn as line segments. */ + SDL_GPU_FILLMODE_FILL, /**< Polygons will be rendered via rasterization. */ + SDL_GPU_FILLMODE_LINE /**< Polygon edges will be drawn as line segments. */ } SDL_GPUFillMode; /** @@ -889,9 +889,9 @@ typedef enum SDL_GPUFillMode */ typedef enum SDL_GPUCullMode { - SDL_GPU_CULLMODE_NONE, /**< No triangles are culled. */ - SDL_GPU_CULLMODE_FRONT, /**< Front-facing triangles are culled. */ - SDL_GPU_CULLMODE_BACK /**< Back-facing triangles are culled. */ + SDL_GPU_CULLMODE_NONE, /**< No triangles are culled. */ + SDL_GPU_CULLMODE_FRONT, /**< Front-facing triangles are culled. */ + SDL_GPU_CULLMODE_BACK /**< Back-facing triangles are culled. */ } SDL_GPUCullMode; /** @@ -904,8 +904,8 @@ typedef enum SDL_GPUCullMode */ typedef enum SDL_GPUFrontFace { - SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE, /**< A triangle with counter-clockwise vertex winding will be considered front-facing. */ - SDL_GPU_FRONTFACE_CLOCKWISE /**< A triangle with clockwise vertex winding will be considered front-facing. */ + SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE, /**< A triangle with counter-clockwise vertex winding will be considered front-facing. */ + SDL_GPU_FRONTFACE_CLOCKWISE /**< A triangle with clockwise vertex winding will be considered front-facing. */ } SDL_GPUFrontFace; /** @@ -918,14 +918,14 @@ typedef enum SDL_GPUFrontFace typedef enum SDL_GPUCompareOp { SDL_GPU_COMPAREOP_INVALID, - SDL_GPU_COMPAREOP_NEVER, /**< The comparison always evaluates false. */ - SDL_GPU_COMPAREOP_LESS, /**< The comparison evaluates reference < test. */ - SDL_GPU_COMPAREOP_EQUAL, /**< The comparison evaluates reference == test. */ - SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */ - SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */ - SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */ - SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evalutes reference >= test. */ - SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */ + SDL_GPU_COMPAREOP_NEVER, /**< The comparison always evaluates false. */ + SDL_GPU_COMPAREOP_LESS, /**< The comparison evaluates reference < test. */ + SDL_GPU_COMPAREOP_EQUAL, /**< The comparison evaluates reference == test. */ + SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */ + SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */ + SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */ + SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evalutes reference >= test. */ + SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */ } SDL_GPUCompareOp; /** @@ -939,14 +939,14 @@ typedef enum SDL_GPUCompareOp typedef enum SDL_GPUStencilOp { SDL_GPU_STENCILOP_INVALID, - SDL_GPU_STENCILOP_KEEP, /**< Keeps the current value. */ - SDL_GPU_STENCILOP_ZERO, /**< Sets the value to 0. */ - SDL_GPU_STENCILOP_REPLACE, /**< Sets the value to reference. */ - SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP, /**< Increments the current value and clamps to the maximum value. */ - SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP, /**< Decrements the current value and clamps to 0. */ - SDL_GPU_STENCILOP_INVERT, /**< Bitwise-inverts the current value. */ - SDL_GPU_STENCILOP_INCREMENT_AND_WRAP, /**< Increments the current value and wraps back to 0. */ - SDL_GPU_STENCILOP_DECREMENT_AND_WRAP /**< Decrements the current value and wraps to the maximum value. */ + SDL_GPU_STENCILOP_KEEP, /**< Keeps the current value. */ + SDL_GPU_STENCILOP_ZERO, /**< Sets the value to 0. */ + SDL_GPU_STENCILOP_REPLACE, /**< Sets the value to reference. */ + SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP, /**< Increments the current value and clamps to the maximum value. */ + SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP, /**< Decrements the current value and clamps to 0. */ + SDL_GPU_STENCILOP_INVERT, /**< Bitwise-inverts the current value. */ + SDL_GPU_STENCILOP_INCREMENT_AND_WRAP, /**< Increments the current value and wraps back to 0. */ + SDL_GPU_STENCILOP_DECREMENT_AND_WRAP /**< Decrements the current value and wraps to the maximum value. */ } SDL_GPUStencilOp; /** @@ -963,11 +963,11 @@ typedef enum SDL_GPUStencilOp typedef enum SDL_GPUBlendOp { SDL_GPU_BLENDOP_INVALID, - SDL_GPU_BLENDOP_ADD, /**< (source * source_factor) + (destination * destination_factor) */ - SDL_GPU_BLENDOP_SUBTRACT, /**< (source * source_factor) - (destination * destination_factor) */ - SDL_GPU_BLENDOP_REVERSE_SUBTRACT, /**< (destination * destination_factor) - (source * source_factor) */ - SDL_GPU_BLENDOP_MIN, /**< min(source, destination) */ - SDL_GPU_BLENDOP_MAX /**< max(source, destination) */ + SDL_GPU_BLENDOP_ADD, /**< (source * source_factor) + (destination * destination_factor) */ + SDL_GPU_BLENDOP_SUBTRACT, /**< (source * source_factor) - (destination * destination_factor) */ + SDL_GPU_BLENDOP_REVERSE_SUBTRACT, /**< (destination * destination_factor) - (source * source_factor) */ + SDL_GPU_BLENDOP_MIN, /**< min(source, destination) */ + SDL_GPU_BLENDOP_MAX /**< max(source, destination) */ } SDL_GPUBlendOp; /** @@ -984,19 +984,19 @@ typedef enum SDL_GPUBlendOp typedef enum SDL_GPUBlendFactor { SDL_GPU_BLENDFACTOR_INVALID, - SDL_GPU_BLENDFACTOR_ZERO, /**< 0 */ - SDL_GPU_BLENDFACTOR_ONE, /**< 1 */ - SDL_GPU_BLENDFACTOR_SRC_COLOR, /**< source color */ - SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR, /**< 1 - source color */ - SDL_GPU_BLENDFACTOR_DST_COLOR, /**< destination color */ - SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR, /**< 1 - destination color */ - SDL_GPU_BLENDFACTOR_SRC_ALPHA, /**< source alpha */ - SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, /**< 1 - source alpha */ - SDL_GPU_BLENDFACTOR_DST_ALPHA, /**< destination alpha */ - SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA, /**< 1 - destination alpha */ - SDL_GPU_BLENDFACTOR_CONSTANT_COLOR, /**< blend constant */ - SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR, /**< 1 - blend constant */ - SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE /**< min(source alpha, 1 - destination alpha) */ + SDL_GPU_BLENDFACTOR_ZERO, /**< 0 */ + SDL_GPU_BLENDFACTOR_ONE, /**< 1 */ + SDL_GPU_BLENDFACTOR_SRC_COLOR, /**< source color */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR, /**< 1 - source color */ + SDL_GPU_BLENDFACTOR_DST_COLOR, /**< destination color */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR, /**< 1 - destination color */ + SDL_GPU_BLENDFACTOR_SRC_ALPHA, /**< source alpha */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, /**< 1 - source alpha */ + SDL_GPU_BLENDFACTOR_DST_ALPHA, /**< destination alpha */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA, /**< 1 - destination alpha */ + SDL_GPU_BLENDFACTOR_CONSTANT_COLOR, /**< blend constant */ + SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR, /**< 1 - blend constant */ + SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE /**< min(source alpha, 1 - destination alpha) */ } SDL_GPUBlendFactor; /** @@ -1022,8 +1022,8 @@ typedef Uint8 SDL_GPUColorComponentFlags; */ typedef enum SDL_GPUFilter { - SDL_GPU_FILTER_NEAREST, /**< Point filtering. */ - SDL_GPU_FILTER_LINEAR /**< Linear filtering. */ + SDL_GPU_FILTER_NEAREST, /**< Point filtering. */ + SDL_GPU_FILTER_LINEAR /**< Linear filtering. */ } SDL_GPUFilter; /** @@ -1035,8 +1035,8 @@ typedef enum SDL_GPUFilter */ typedef enum SDL_GPUSamplerMipmapMode { - SDL_GPU_SAMPLERMIPMAPMODE_NEAREST, /**< Point filtering. */ - SDL_GPU_SAMPLERMIPMAPMODE_LINEAR /**< Linear filtering. */ + SDL_GPU_SAMPLERMIPMAPMODE_NEAREST, /**< Point filtering. */ + SDL_GPU_SAMPLERMIPMAPMODE_LINEAR /**< Linear filtering. */ } SDL_GPUSamplerMipmapMode; /** @@ -1049,9 +1049,9 @@ typedef enum SDL_GPUSamplerMipmapMode */ typedef enum SDL_GPUSamplerAddressMode { - SDL_GPU_SAMPLERADDRESSMODE_REPEAT, /**< Specifies that the coordinates will wrap around. */ - SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT, /**< Specifies that the coordinates will wrap around mirrored. */ - SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE /**< Specifies that the coordinates will clamp to the 0-1 range. */ + SDL_GPU_SAMPLERADDRESSMODE_REPEAT, /**< Specifies that the coordinates will wrap around. */ + SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT, /**< Specifies that the coordinates will wrap around mirrored. */ + SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE /**< Specifies that the coordinates will clamp to the 0-1 range. */ } SDL_GPUSamplerAddressMode; /** @@ -1147,12 +1147,12 @@ typedef enum SDL_GPUDriver */ typedef struct SDL_GPUViewport { - float x; /**< The left offset of the viewport. */ - float y; /**< The top offset of the viewport. */ - float w; /**< The width of the viewport. */ - float h; /**< The height of the viewport. */ - float min_depth; /**< The minimum depth of the viewport. */ - float max_depth; /**< The maximum depth of the viewport. */ + float x; /**< The left offset of the viewport. */ + float y; /**< The top offset of the viewport. */ + float w; /**< The width of the viewport. */ + float h; /**< The height of the viewport. */ + float min_depth; /**< The minimum depth of the viewport. */ + float max_depth; /**< The maximum depth of the viewport. */ } SDL_GPUViewport; /** @@ -1166,10 +1166,10 @@ typedef struct SDL_GPUViewport */ typedef struct SDL_GPUTextureTransferInfo { - SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */ - Uint32 offset; /**< The starting byte of the image data in the transfer buffer. */ - Uint32 pixels_per_row; /**< The number of pixels from one row to the next. */ - Uint32 rows_per_layer; /**< The number of rows from one layer/depth-slice to the next. */ + SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */ + Uint32 offset; /**< The starting byte of the image data in the transfer buffer. */ + Uint32 pixels_per_row; /**< The number of pixels from one row to the next. */ + Uint32 rows_per_layer; /**< The number of rows from one layer/depth-slice to the next. */ } SDL_GPUTextureTransferInfo; /** @@ -1184,8 +1184,8 @@ typedef struct SDL_GPUTextureTransferInfo */ typedef struct SDL_GPUTransferBufferLocation { - SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */ - Uint32 offset; /**< The starting byte of the buffer data in the transfer buffer. */ + SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */ + Uint32 offset; /**< The starting byte of the buffer data in the transfer buffer. */ } SDL_GPUTransferBufferLocation; /** @@ -1199,12 +1199,12 @@ typedef struct SDL_GPUTransferBufferLocation */ typedef struct SDL_GPUTextureLocation { - SDL_GPUTexture *texture; /**< The texture used in the copy operation. */ - Uint32 mip_level; /**< The mip level index of the location. */ - Uint32 layer; /**< The layer index of the location. */ - Uint32 x; /**< The left offset of the location. */ - Uint32 y; /**< The top offset of the location. */ - Uint32 z; /**< The front offset of the location. */ + SDL_GPUTexture *texture; /**< The texture used in the copy operation. */ + Uint32 mip_level; /**< The mip level index of the location. */ + Uint32 layer; /**< The layer index of the location. */ + Uint32 x; /**< The left offset of the location. */ + Uint32 y; /**< The top offset of the location. */ + Uint32 z; /**< The front offset of the location. */ } SDL_GPUTextureLocation; /** @@ -1219,15 +1219,15 @@ typedef struct SDL_GPUTextureLocation */ typedef struct SDL_GPUTextureRegion { - SDL_GPUTexture *texture; /**< The texture used in the copy operation. */ - Uint32 mip_level; /**< The mip level index to transfer. */ - Uint32 layer; /**< The layer index to transfer. */ - Uint32 x; /**< The left offset of the region. */ - Uint32 y; /**< The top offset of the region. */ - Uint32 z; /**< The front offset of the region. */ - Uint32 w; /**< The width of the region. */ - Uint32 h; /**< The height of the region. */ - Uint32 d; /**< The depth of the region. */ + SDL_GPUTexture *texture; /**< The texture used in the copy operation. */ + Uint32 mip_level; /**< The mip level index to transfer. */ + Uint32 layer; /**< The layer index to transfer. */ + Uint32 x; /**< The left offset of the region. */ + Uint32 y; /**< The top offset of the region. */ + Uint32 z; /**< The front offset of the region. */ + Uint32 w; /**< The width of the region. */ + Uint32 h; /**< The height of the region. */ + Uint32 d; /**< The depth of the region. */ } SDL_GPUTextureRegion; /** @@ -1239,13 +1239,13 @@ typedef struct SDL_GPUTextureRegion */ typedef struct SDL_GPUBlitRegion { - SDL_GPUTexture *texture; /**< The texture. */ - Uint32 mip_level; /**< The mip level index of the region. */ - Uint32 layer_or_depth_plane; /**< The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */ - Uint32 x; /**< The left offset of the region. */ - Uint32 y; /**< The top offset of the region. */ - Uint32 w; /**< The width of the region. */ - Uint32 h; /**< The height of the region. */ + SDL_GPUTexture *texture; /**< The texture. */ + Uint32 mip_level; /**< The mip level index of the region. */ + Uint32 layer_or_depth_plane; /**< The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */ + Uint32 x; /**< The left offset of the region. */ + Uint32 y; /**< The top offset of the region. */ + Uint32 w; /**< The width of the region. */ + Uint32 h; /**< The height of the region. */ } SDL_GPUBlitRegion; /** @@ -1259,8 +1259,8 @@ typedef struct SDL_GPUBlitRegion */ typedef struct SDL_GPUBufferLocation { - SDL_GPUBuffer *buffer; /**< The buffer. */ - Uint32 offset; /**< The starting byte within the buffer. */ + SDL_GPUBuffer *buffer; /**< The buffer. */ + Uint32 offset; /**< The starting byte within the buffer. */ } SDL_GPUBufferLocation; /** @@ -1275,9 +1275,9 @@ typedef struct SDL_GPUBufferLocation */ typedef struct SDL_GPUBufferRegion { - SDL_GPUBuffer *buffer; /**< The buffer. */ - Uint32 offset; /**< The starting byte within the buffer. */ - Uint32 size; /**< The size in bytes of the region. */ + SDL_GPUBuffer *buffer; /**< The buffer. */ + Uint32 offset; /**< The starting byte within the buffer. */ + Uint32 size; /**< The size in bytes of the region. */ } SDL_GPUBufferRegion; /** @@ -1330,9 +1330,9 @@ typedef struct SDL_GPUIndexedIndirectDrawCommand */ typedef struct SDL_GPUIndirectDispatchCommand { - Uint32 groupcount_x; /**< The number of local workgroups to dispatch in the X dimension. */ - Uint32 groupcount_y; /**< The number of local workgroups to dispatch in the Y dimension. */ - Uint32 groupcount_z; /**< The number of local workgroups to dispatch in the Z dimension. */ + Uint32 groupcount_x; /**< The number of local workgroups to dispatch in the X dimension. */ + Uint32 groupcount_y; /**< The number of local workgroups to dispatch in the Y dimension. */ + Uint32 groupcount_z; /**< The number of local workgroups to dispatch in the Z dimension. */ } SDL_GPUIndirectDispatchCommand; /* State structures */ @@ -1346,23 +1346,23 @@ typedef struct SDL_GPUIndirectDispatchCommand */ typedef struct SDL_GPUSamplerCreateInfo { - SDL_GPUFilter min_filter; /**< The minification filter to apply to lookups. */ - SDL_GPUFilter mag_filter; /**< The magnification filter to apply to lookups. */ - SDL_GPUSamplerMipmapMode mipmap_mode; /**< The mipmap filter to apply to lookups. */ - SDL_GPUSamplerAddressMode address_mode_u; /**< The addressing mode for U coordinates outside [0, 1). */ - SDL_GPUSamplerAddressMode address_mode_v; /**< The addressing mode for V coordinates outside [0, 1). */ - SDL_GPUSamplerAddressMode address_mode_w; /**< The addressing mode for W coordinates outside [0, 1). */ - float mip_lod_bias; /**< The bias to be added to mipmap LOD calculation. */ - float max_anisotropy; /**< The anisotropy value clamp used by the sampler. If enable_anisotropy is false, this is ignored. */ - SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */ - float min_lod; /**< Clamps the minimum of the computed LOD value. */ - float max_lod; /**< Clamps the maximum of the computed LOD value. */ - bool enable_anisotropy; /**< true to enable anisotropic filtering. */ - bool enable_compare; /**< true to enable comparison against a reference value during lookups. */ + SDL_GPUFilter min_filter; /**< The minification filter to apply to lookups. */ + SDL_GPUFilter mag_filter; /**< The magnification filter to apply to lookups. */ + SDL_GPUSamplerMipmapMode mipmap_mode; /**< The mipmap filter to apply to lookups. */ + SDL_GPUSamplerAddressMode address_mode_u; /**< The addressing mode for U coordinates outside [0, 1). */ + SDL_GPUSamplerAddressMode address_mode_v; /**< The addressing mode for V coordinates outside [0, 1). */ + SDL_GPUSamplerAddressMode address_mode_w; /**< The addressing mode for W coordinates outside [0, 1). */ + float mip_lod_bias; /**< The bias to be added to mipmap LOD calculation. */ + float max_anisotropy; /**< The anisotropy value clamp used by the sampler. If enable_anisotropy is false, this is ignored. */ + SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */ + float min_lod; /**< Clamps the minimum of the computed LOD value. */ + float max_lod; /**< Clamps the maximum of the computed LOD value. */ + bool enable_anisotropy; /**< true to enable anisotropic filtering. */ + bool enable_compare; /**< true to enable comparison against a reference value during lookups. */ Uint8 padding1; Uint8 padding2; - SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUSamplerCreateInfo; /** @@ -1385,10 +1385,10 @@ typedef struct SDL_GPUSamplerCreateInfo */ typedef struct SDL_GPUVertexBufferDescription { - Uint32 slot; /**< The binding slot of the vertex buffer. */ - Uint32 pitch; /**< The byte pitch between consecutive elements of the vertex buffer. */ - SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */ - Uint32 instance_step_rate; /**< The number of instances to draw using the same per-instance data before advancing in the instance buffer by one element. Ignored unless input_rate is SDL_GPU_VERTEXINPUTRATE_INSTANCE */ + Uint32 slot; /**< The binding slot of the vertex buffer. */ + Uint32 pitch; /**< The byte pitch between consecutive elements of the vertex buffer. */ + SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */ + Uint32 instance_step_rate; /**< The number of instances to draw using the same per-instance data before advancing in the instance buffer by one element. Ignored unless input_rate is SDL_GPU_VERTEXINPUTRATE_INSTANCE */ } SDL_GPUVertexBufferDescription; /** @@ -1404,10 +1404,10 @@ typedef struct SDL_GPUVertexBufferDescription */ typedef struct SDL_GPUVertexAttribute { - Uint32 location; /**< The shader input location index. */ - Uint32 buffer_slot; /**< The binding slot of the associated vertex buffer. */ - SDL_GPUVertexElementFormat format; /**< The size and type of the attribute data. */ - Uint32 offset; /**< The byte offset of this attribute relative to the start of the vertex element. */ + Uint32 location; /**< The shader input location index. */ + Uint32 buffer_slot; /**< The binding slot of the associated vertex buffer. */ + SDL_GPUVertexElementFormat format; /**< The size and type of the attribute data. */ + Uint32 offset; /**< The byte offset of this attribute relative to the start of the vertex element. */ } SDL_GPUVertexAttribute; /** @@ -1435,10 +1435,10 @@ typedef struct SDL_GPUVertexInputState */ typedef struct SDL_GPUStencilOpState { - SDL_GPUStencilOp fail_op; /**< The action performed on samples that fail the stencil test. */ - SDL_GPUStencilOp pass_op; /**< The action performed on samples that pass the depth and stencil tests. */ - SDL_GPUStencilOp depth_fail_op; /**< The action performed on samples that pass the stencil test and fail the depth test. */ - SDL_GPUCompareOp compare_op; /**< The comparison operator used in the stencil test. */ + SDL_GPUStencilOp fail_op; /**< The action performed on samples that fail the stencil test. */ + SDL_GPUStencilOp pass_op; /**< The action performed on samples that pass the depth and stencil tests. */ + SDL_GPUStencilOp depth_fail_op; /**< The action performed on samples that pass the stencil test and fail the depth test. */ + SDL_GPUCompareOp compare_op; /**< The comparison operator used in the stencil test. */ } SDL_GPUStencilOpState; /** @@ -1450,20 +1450,19 @@ typedef struct SDL_GPUStencilOpState */ typedef struct SDL_GPUColorTargetBlendState { - SDL_GPUBlendFactor src_color_blendfactor; /**< The value to be multiplied by the source RGB value. */ - SDL_GPUBlendFactor dst_color_blendfactor; /**< The value to be multiplied by the destination RGB value. */ - SDL_GPUBlendOp color_blend_op; /**< The blend operation for the RGB components. */ - SDL_GPUBlendFactor src_alpha_blendfactor; /**< The value to be multiplied by the source alpha. */ - SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */ - SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */ - SDL_GPUColorComponentFlags color_write_mask; /**< A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false. */ - bool enable_blend; /**< Whether blending is enabled for the color target. */ - bool enable_color_write_mask; /**< Whether the color write mask is enabled. */ + SDL_GPUBlendFactor src_color_blendfactor; /**< The value to be multiplied by the source RGB value. */ + SDL_GPUBlendFactor dst_color_blendfactor; /**< The value to be multiplied by the destination RGB value. */ + SDL_GPUBlendOp color_blend_op; /**< The blend operation for the RGB components. */ + SDL_GPUBlendFactor src_alpha_blendfactor; /**< The value to be multiplied by the source alpha. */ + SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */ + SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */ + SDL_GPUColorComponentFlags color_write_mask; /**< A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false. */ + bool enable_blend; /**< Whether blending is enabled for the color target. */ + bool enable_color_write_mask; /**< Whether the color write mask is enabled. */ Uint8 padding1; Uint8 padding2; } SDL_GPUColorTargetBlendState; - /** * A structure specifying code and metadata for creating a shader object. * @@ -1473,17 +1472,17 @@ typedef struct SDL_GPUColorTargetBlendState */ typedef struct SDL_GPUShaderCreateInfo { - size_t code_size; /**< The size in bytes of the code pointed to. */ - const Uint8 *code; /**< A pointer to shader code. */ - const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */ - SDL_GPUShaderFormat format; /**< The format of the shader code. */ - SDL_GPUShaderStage stage; /**< The stage the shader program corresponds to. */ - Uint32 num_samplers; /**< The number of samplers defined in the shader. */ - Uint32 num_storage_textures; /**< The number of storage textures defined in the shader. */ - Uint32 num_storage_buffers; /**< The number of storage buffers defined in the shader. */ - Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */ - - SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ + size_t code_size; /**< The size in bytes of the code pointed to. */ + const Uint8 *code; /**< A pointer to shader code. */ + const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */ + SDL_GPUShaderFormat format; /**< The format of the shader code. */ + SDL_GPUShaderStage stage; /**< The stage the shader program corresponds to. */ + Uint32 num_samplers; /**< The number of samplers defined in the shader. */ + Uint32 num_storage_textures; /**< The number of storage textures defined in the shader. */ + Uint32 num_storage_buffers; /**< The number of storage buffers defined in the shader. */ + Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUShaderCreateInfo; /** @@ -1499,16 +1498,16 @@ typedef struct SDL_GPUShaderCreateInfo */ typedef struct SDL_GPUTextureCreateInfo { - SDL_GPUTextureType type; /**< The base dimensionality of the texture. */ - SDL_GPUTextureFormat format; /**< The pixel format of the texture. */ - SDL_GPUTextureUsageFlags usage; /**< How the texture is intended to be used by the client. */ - Uint32 width; /**< The width of the texture. */ - Uint32 height; /**< The height of the texture. */ - Uint32 layer_count_or_depth; /**< The layer count or depth of the texture. This value is treated as a layer count on 2D array textures, and as a depth value on 3D textures. */ - Uint32 num_levels; /**< The number of mip levels in the texture. */ - SDL_GPUSampleCount sample_count; /**< The number of samples per texel. Only applies if the texture is used as a render target. */ - - SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ + SDL_GPUTextureType type; /**< The base dimensionality of the texture. */ + SDL_GPUTextureFormat format; /**< The pixel format of the texture. */ + SDL_GPUTextureUsageFlags usage; /**< How the texture is intended to be used by the client. */ + Uint32 width; /**< The width of the texture. */ + Uint32 height; /**< The height of the texture. */ + Uint32 layer_count_or_depth; /**< The layer count or depth of the texture. This value is treated as a layer count on 2D array textures, and as a depth value on 3D textures. */ + Uint32 num_levels; /**< The number of mip levels in the texture. */ + SDL_GPUSampleCount sample_count; /**< The number of samples per texel. Only applies if the texture is used as a render target. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUTextureCreateInfo; #define SDL_PROP_GPU_CREATETEXTURE_D3D12_CLEAR_R_FLOAT "SDL.gpu.createtexture.d3d12.clear.r" @@ -1530,10 +1529,10 @@ typedef struct SDL_GPUTextureCreateInfo */ typedef struct SDL_GPUBufferCreateInfo { - SDL_GPUBufferUsageFlags usage; /**< How the buffer is intended to be used by the client. */ - Uint32 size; /**< The size in bytes of the buffer. */ + SDL_GPUBufferUsageFlags usage; /**< How the buffer is intended to be used by the client. */ + Uint32 size; /**< The size in bytes of the buffer. */ - SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUBufferCreateInfo; /** @@ -1545,10 +1544,10 @@ typedef struct SDL_GPUBufferCreateInfo */ typedef struct SDL_GPUTransferBufferCreateInfo { - SDL_GPUTransferBufferUsage usage; /**< How the transfer buffer is intended to be used by the client. */ - Uint32 size; /**< The size in bytes of the transfer buffer. */ + SDL_GPUTransferBufferUsage usage; /**< How the transfer buffer is intended to be used by the client. */ + Uint32 size; /**< The size in bytes of the transfer buffer. */ - SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUTransferBufferCreateInfo; /* Pipeline state structures */ @@ -1568,14 +1567,14 @@ typedef struct SDL_GPUTransferBufferCreateInfo */ typedef struct SDL_GPURasterizerState { - SDL_GPUFillMode fill_mode; /**< Whether polygons will be filled in or drawn as lines. */ - SDL_GPUCullMode cull_mode; /**< The facing direction in which triangles will be culled. */ - SDL_GPUFrontFace front_face; /**< The vertex winding that will cause a triangle to be determined as front-facing. */ - float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */ - float depth_bias_clamp; /**< The maximum depth bias of a fragment. */ - float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */ - bool enable_depth_bias; /**< true to bias fragment depth values. */ - bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */ + SDL_GPUFillMode fill_mode; /**< Whether polygons will be filled in or drawn as lines. */ + SDL_GPUCullMode cull_mode; /**< The facing direction in which triangles will be culled. */ + SDL_GPUFrontFace front_face; /**< The vertex winding that will cause a triangle to be determined as front-facing. */ + float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */ + float depth_bias_clamp; /**< The maximum depth bias of a fragment. */ + float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */ + bool enable_depth_bias; /**< true to bias fragment depth values. */ + bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */ Uint8 padding1; Uint8 padding2; } SDL_GPURasterizerState; @@ -1590,9 +1589,9 @@ typedef struct SDL_GPURasterizerState */ typedef struct SDL_GPUMultisampleState { - SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */ - Uint32 sample_mask; /**< Determines which samples get updated in the render targets. Treated as 0xFFFFFFFF if enable_mask is false. */ - bool enable_mask; /**< Enables sample masking. */ + SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */ + Uint32 sample_mask; /**< Determines which samples get updated in the render targets. Treated as 0xFFFFFFFF if enable_mask is false. */ + bool enable_mask; /**< Enables sample masking. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -1608,14 +1607,14 @@ typedef struct SDL_GPUMultisampleState */ typedef struct SDL_GPUDepthStencilState { - SDL_GPUCompareOp compare_op; /**< The comparison operator used for depth testing. */ - SDL_GPUStencilOpState back_stencil_state; /**< The stencil op state for back-facing triangles. */ - SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */ - Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */ - Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */ - bool enable_depth_test; /**< true enables the depth test. */ - bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */ - bool enable_stencil_test; /**< true enables the stencil test. */ + SDL_GPUCompareOp compare_op; /**< The comparison operator used for depth testing. */ + SDL_GPUStencilOpState back_stencil_state; /**< The stencil op state for back-facing triangles. */ + SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */ + Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */ + Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */ + bool enable_depth_test; /**< true enables the depth test. */ + bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */ + bool enable_stencil_test; /**< true enables the stencil test. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -1631,8 +1630,8 @@ typedef struct SDL_GPUDepthStencilState */ typedef struct SDL_GPUColorTargetDescription { - SDL_GPUTextureFormat format; /**< The pixel format of the texture to be used as a color target. */ - SDL_GPUColorTargetBlendState blend_state; /**< The blend state to be used for the color target. */ + SDL_GPUTextureFormat format; /**< The pixel format of the texture to be used as a color target. */ + SDL_GPUColorTargetBlendState blend_state; /**< The blend state to be used for the color target. */ } SDL_GPUColorTargetDescription; /** @@ -1645,10 +1644,10 @@ typedef struct SDL_GPUColorTargetDescription */ typedef struct SDL_GPUGraphicsPipelineTargetInfo { - const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */ - Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */ - SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */ - bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */ + const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */ + Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */ + SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */ + bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -1663,16 +1662,16 @@ typedef struct SDL_GPUGraphicsPipelineTargetInfo */ typedef struct SDL_GPUGraphicsPipelineCreateInfo { - SDL_GPUShader *vertex_shader; /**< The vertex shader used by the graphics pipeline. */ - SDL_GPUShader *fragment_shader; /**< The fragment shader used by the graphics pipeline. */ - SDL_GPUVertexInputState vertex_input_state; /**< The vertex layout of the graphics pipeline. */ - SDL_GPUPrimitiveType primitive_type; /**< The primitive topology of the graphics pipeline. */ - SDL_GPURasterizerState rasterizer_state; /**< The rasterizer state of the graphics pipeline. */ - SDL_GPUMultisampleState multisample_state; /**< The multisample state of the graphics pipeline. */ - SDL_GPUDepthStencilState depth_stencil_state; /**< The depth-stencil state of the graphics pipeline. */ - SDL_GPUGraphicsPipelineTargetInfo target_info; /**< Formats and blend modes for the render targets of the graphics pipeline. */ - - SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ + SDL_GPUShader *vertex_shader; /**< The vertex shader used by the graphics pipeline. */ + SDL_GPUShader *fragment_shader; /**< The fragment shader used by the graphics pipeline. */ + SDL_GPUVertexInputState vertex_input_state; /**< The vertex layout of the graphics pipeline. */ + SDL_GPUPrimitiveType primitive_type; /**< The primitive topology of the graphics pipeline. */ + SDL_GPURasterizerState rasterizer_state; /**< The rasterizer state of the graphics pipeline. */ + SDL_GPUMultisampleState multisample_state; /**< The multisample state of the graphics pipeline. */ + SDL_GPUDepthStencilState depth_stencil_state; /**< The depth-stencil state of the graphics pipeline. */ + SDL_GPUGraphicsPipelineTargetInfo target_info; /**< Formats and blend modes for the render targets of the graphics pipeline. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUGraphicsPipelineCreateInfo; /** @@ -1684,21 +1683,21 @@ typedef struct SDL_GPUGraphicsPipelineCreateInfo */ typedef struct SDL_GPUComputePipelineCreateInfo { - size_t code_size; /**< The size in bytes of the compute shader code pointed to. */ - const Uint8 *code; /**< A pointer to compute shader code. */ - const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */ - SDL_GPUShaderFormat format; /**< The format of the compute shader code. */ - Uint32 num_samplers; /**< The number of samplers defined in the shader. */ - Uint32 num_readonly_storage_textures; /**< The number of readonly storage textures defined in the shader. */ - Uint32 num_readonly_storage_buffers; /**< The number of readonly storage buffers defined in the shader. */ - Uint32 num_readwrite_storage_textures; /**< The number of read-write storage textures defined in the shader. */ - Uint32 num_readwrite_storage_buffers; /**< The number of read-write storage buffers defined in the shader. */ - Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */ - Uint32 threadcount_x; /**< The number of threads in the X dimension. This should match the value in the shader. */ - Uint32 threadcount_y; /**< The number of threads in the Y dimension. This should match the value in the shader. */ - Uint32 threadcount_z; /**< The number of threads in the Z dimension. This should match the value in the shader. */ - - SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ + size_t code_size; /**< The size in bytes of the compute shader code pointed to. */ + const Uint8 *code; /**< A pointer to compute shader code. */ + const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */ + SDL_GPUShaderFormat format; /**< The format of the compute shader code. */ + Uint32 num_samplers; /**< The number of samplers defined in the shader. */ + Uint32 num_readonly_storage_textures; /**< The number of readonly storage textures defined in the shader. */ + Uint32 num_readonly_storage_buffers; /**< The number of readonly storage buffers defined in the shader. */ + Uint32 num_readwrite_storage_textures; /**< The number of read-write storage textures defined in the shader. */ + Uint32 num_readwrite_storage_buffers; /**< The number of read-write storage buffers defined in the shader. */ + Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */ + Uint32 threadcount_x; /**< The number of threads in the X dimension. This should match the value in the shader. */ + Uint32 threadcount_y; /**< The number of threads in the Y dimension. This should match the value in the shader. */ + Uint32 threadcount_z; /**< The number of threads in the Z dimension. This should match the value in the shader. */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUComputePipelineCreateInfo; /** @@ -1747,8 +1746,8 @@ typedef struct SDL_GPUColorTargetInfo SDL_GPUTexture *resolve_texture; /**< The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used. */ Uint32 resolve_mip_level; /**< The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ Uint32 resolve_layer; /**< The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ - bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */ - bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */ + bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */ + bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */ Uint8 padding1; Uint8 padding2; } SDL_GPUColorTargetInfo; @@ -1799,14 +1798,14 @@ typedef struct SDL_GPUColorTargetInfo */ typedef struct SDL_GPUDepthStencilTargetInfo { - SDL_GPUTexture *texture; /**< The texture that will be used as the depth stencil target by the render pass. */ - float clear_depth; /**< The value to clear the depth component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ - SDL_GPULoadOp load_op; /**< What is done with the depth contents at the beginning of the render pass. */ - SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */ - SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */ - SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */ - bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */ - Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ + SDL_GPUTexture *texture; /**< The texture that will be used as the depth stencil target by the render pass. */ + float clear_depth; /**< The value to clear the depth component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ + SDL_GPULoadOp load_op; /**< What is done with the depth contents at the beginning of the render pass. */ + SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */ + SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */ + SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */ + bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */ + Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ Uint8 padding1; Uint8 padding2; } SDL_GPUDepthStencilTargetInfo; @@ -1818,14 +1817,15 @@ typedef struct SDL_GPUDepthStencilTargetInfo * * \sa SDL_BlitGPUTexture */ -typedef struct SDL_GPUBlitInfo { - SDL_GPUBlitRegion source; /**< The source region for the blit. */ - SDL_GPUBlitRegion destination; /**< The destination region for the blit. */ - SDL_GPULoadOp load_op; /**< What is done with the contents of the destination before the blit. */ - SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */ - SDL_FlipMode flip_mode; /**< The flip mode for the source region. */ - SDL_GPUFilter filter; /**< The filter mode used when blitting. */ - bool cycle; /**< true cycles the destination texture if it is already bound. */ +typedef struct SDL_GPUBlitInfo +{ + SDL_GPUBlitRegion source; /**< The source region for the blit. */ + SDL_GPUBlitRegion destination; /**< The destination region for the blit. */ + SDL_GPULoadOp load_op; /**< What is done with the contents of the destination before the blit. */ + SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */ + SDL_FlipMode flip_mode; /**< The flip mode for the source region. */ + SDL_GPUFilter filter; /**< The filter mode used when blitting. */ + bool cycle; /**< true cycles the destination texture if it is already bound. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -1843,8 +1843,8 @@ typedef struct SDL_GPUBlitInfo { */ typedef struct SDL_GPUBufferBinding { - SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_VERTEX for SDL_BindGPUVertexBuffers, or SDL_GPU_BUFFERUSAGE_INDEX for SDL_BindGPUIndexBuffers. */ - Uint32 offset; /**< The starting byte of the data to bind in the buffer. */ + SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_VERTEX for SDL_BindGPUVertexBuffers, or SDL_GPU_BUFFERUSAGE_INDEX for SDL_BindGPUIndexBuffers. */ + Uint32 offset; /**< The starting byte of the data to bind in the buffer. */ } SDL_GPUBufferBinding; /** @@ -1857,8 +1857,8 @@ typedef struct SDL_GPUBufferBinding */ typedef struct SDL_GPUTextureSamplerBinding { - SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. */ - SDL_GPUSampler *sampler; /**< The sampler to bind. */ + SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. */ + SDL_GPUSampler *sampler; /**< The sampler to bind. */ } SDL_GPUTextureSamplerBinding; /** @@ -1871,8 +1871,8 @@ typedef struct SDL_GPUTextureSamplerBinding */ typedef struct SDL_GPUStorageBufferReadWriteBinding { - SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE. */ - bool cycle; /**< true cycles the buffer if it is already bound. */ + SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE. */ + bool cycle; /**< true cycles the buffer if it is already bound. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -1888,10 +1888,10 @@ typedef struct SDL_GPUStorageBufferReadWriteBinding */ typedef struct SDL_GPUStorageTextureReadWriteBinding { - SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE or SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE. */ - Uint32 mip_level; /**< The mip level index to bind. */ - Uint32 layer; /**< The layer index to bind. */ - bool cycle; /**< true cycles the texture if it is already bound. */ + SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE or SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE. */ + Uint32 mip_level; /**< The mip level index to bind. */ + Uint32 layer; /**< The layer index to bind. */ + bool cycle; /**< true cycles the texture if it is already bound. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -2009,6 +2009,7 @@ extern SDL_DECLSPEC SDL_GPUDevice *SDLCALL SDL_CreateGPUDeviceWithProperties( #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_WGSL_BOOLEAN "SDL.gpu.device.create.shaders.wgsl" #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic" /** @@ -2050,7 +2051,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGPUDrivers(void); * * \sa SDL_GetNumGPUDrivers */ -extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDriver(int index); +extern SDL_DECLSPEC const char *SDLCALL SDL_GetGPUDriver(int index); /** * Returns the name of the backend used to create this GPU context. @@ -2060,7 +2061,7 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDriver(int index); * * \since This function is available since SDL 3.1.3. */ -extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *device); +extern SDL_DECLSPEC const char *SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *device); /** * Returns the supported shader formats for this GPU context. diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c index 69fb2b560cafe2..4eecda54b96886 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -462,27 +462,27 @@ static void SDL_GPU_FillProperties( SDL_SetHint(SDL_HINT_GPU_DRIVER, "webgpu"); #endif if (formatFlags & SDL_GPU_SHADERFORMAT_PRIVATE) { - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOL, true); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN, true); } if (formatFlags & SDL_GPU_SHADERFORMAT_SPIRV) { - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOL, true); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN, true); } if (formatFlags & SDL_GPU_SHADERFORMAT_DXBC) { - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOL, true); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN, true); } if (formatFlags & SDL_GPU_SHADERFORMAT_DXIL) { - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOL, true); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN, true); } if (formatFlags & SDL_GPU_SHADERFORMAT_MSL) { - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOL, true); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN, true); } if (formatFlags & SDL_GPU_SHADERFORMAT_METALLIB) { - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOL, true); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN, true); } if (formatFlags & SDL_GPU_SHADERFORMAT_WGSL) { - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_WGSL_BOOL, true); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_WGSL_BOOLEAN, true); } - SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOL, debug_mode); + SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN, debug_mode); SDL_SetStringProperty(props, SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING, name); } #endif // SDL_GPU_DISABLED @@ -641,7 +641,6 @@ Uint32 SDL_GPUTextureFormatTexelBlockSize( case SDL_GPU_TEXTUREFORMAT_R16_UNORM: case SDL_GPU_TEXTUREFORMAT_R16_SNORM: case SDL_GPU_TEXTUREFORMAT_R16_UINT: - case SDL_GPU_TEXTUREFORMAT_D16_UNORM: return 2; case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM: case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM: @@ -656,12 +655,7 @@ Uint32 SDL_GPUTextureFormatTexelBlockSize( case SDL_GPU_TEXTUREFORMAT_R16G16_UINT: case SDL_GPU_TEXTUREFORMAT_R16G16_UNORM: case SDL_GPU_TEXTUREFORMAT_R16G16_SNORM: - case SDL_GPU_TEXTUREFORMAT_D24_UNORM: - case SDL_GPU_TEXTUREFORMAT_D32_FLOAT: - case SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT: return 4; - case SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT: - return 5; case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT: case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM: case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM: @@ -670,49 +664,6 @@ Uint32 SDL_GPUTextureFormatTexelBlockSize( return 8; case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT: return 16; - case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM: - case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM_SRGB: - case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_FLOAT: - case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_FLOAT: - return 16; default: SDL_assert_release(!"Unrecognized TextureFormat!"); return 0; @@ -808,14 +759,6 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline( } if (device->debug_mode) { - if (graphicsPipelineCreateInfo->vertex_shader == NULL) { - SDL_assert_release(!"Vertex shader cannot be NULL!"); - return NULL; - } - if (graphicsPipelineCreateInfo->fragment_shader == NULL) { - SDL_assert_release(!"Fragment shader cannot be NULL!"); - return NULL; - } if (graphicsPipelineCreateInfo->target_info.num_color_targets > 0 && graphicsPipelineCreateInfo->target_info.color_target_descriptions == NULL) { SDL_assert_release(!"Color target descriptions array pointer cannot be NULL if num_color_targets is greater than zero!"); return NULL; @@ -1331,7 +1274,6 @@ SDL_GPUCommandBuffer *SDL_AcquireGPUCommandBuffer( commandBufferHeader->compute_pipeline_bound = false; commandBufferHeader->copy_pass.command_buffer = command_buffer; commandBufferHeader->copy_pass.in_progress = false; - commandBufferHeader->swapchain_texture_acquired = false; commandBufferHeader->submitted = false; return command_buffer; @@ -2697,8 +2639,6 @@ bool SDL_AcquireGPUSwapchainTexture( Uint32 *swapchain_texture_width, Uint32 *swapchain_texture_height) { - CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer; - if (command_buffer == NULL) { SDL_InvalidParamError("command_buffer"); return false; @@ -2717,18 +2657,12 @@ bool SDL_AcquireGPUSwapchainTexture( CHECK_ANY_PASS_IN_PROGRESS("Cannot acquire a swapchain texture during a pass!", false) } - bool result = COMMAND_BUFFER_DEVICE->AcquireSwapchainTexture( + return COMMAND_BUFFER_DEVICE->AcquireSwapchainTexture( command_buffer, window, swapchain_texture, swapchain_texture_width, swapchain_texture_height); - - if (*swapchain_texture != NULL){ - commandBufferHeader->swapchain_texture_acquired = true; - } - - return result; } bool SDL_SubmitGPUCommandBuffer( @@ -2785,27 +2719,6 @@ SDL_GPUFence *SDL_SubmitGPUCommandBufferAndAcquireFence( command_buffer); } -bool SDL_CancelGPUCommandBuffer( - SDL_GPUCommandBuffer *command_buffer) -{ - CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer; - - if (command_buffer == NULL) { - SDL_InvalidParamError("command_buffer"); - return false; - } - - if (COMMAND_BUFFER_DEVICE->debug_mode) { - if (commandBufferHeader->swapchain_texture_acquired) { - SDL_assert_release(!"Cannot cancel command buffer after a swapchain texture has been acquired!"); - return false; - } - } - - return COMMAND_BUFFER_DEVICE->Cancel( - command_buffer); -} - bool SDL_WaitForGPUIdle( SDL_GPUDevice *device) { @@ -2862,16 +2775,3 @@ void SDL_ReleaseGPUFence( device->driverData, fence); } - -Uint32 SDL_CalculateGPUTextureFormatSize( - SDL_GPUTextureFormat format, - Uint32 width, - Uint32 height, - Uint32 depth_or_layer_count) -{ - Uint32 blockWidth = SDL_max(Texture_GetBlockWidth(format), 1); - Uint32 blockHeight = SDL_max(Texture_GetBlockHeight(format), 1); - Uint32 blocksPerRow = (width + blockWidth - 1) / blockWidth; - Uint32 blocksPerColumn = (height + blockHeight - 1) / blockHeight; - return depth_or_layer_count * blocksPerRow * blocksPerColumn * SDL_GPUTextureFormatTexelBlockSize(format); -}