Sync SDL3 wiki -> header

[ci skip]
This commit is contained in:
SDL Wiki Bot
2026-11-29 18:02:55 +00:00
parent cdf5299706
commit ac226f443d
+10 -272
View File
@@ -276,9 +276,9 @@
* WebGPU support is complicated and rapidly updating, so there's no exact
* list. Generally speaking, if you're using a modern browser you can use
* WebGPU.
*
* The WebGPU backend requires Asyncify if built with Emscripten.
* It also requires these WebGPU features to run:
*
* The WebGPU backend requires Asyncify if built with Emscripten. It also
* requires these WebGPU features to run:
*
* - `CoreFeaturesAndLimits`
* - `Depth32FloatStencil8`
@@ -292,12 +292,12 @@
* functionality:
*
* - `BGRA8UnormStorage`: Required for BGRA8Unorm storage textures.
* - `Float32Blendable`: Required for blending Float32 textures. The backend
* will safely disable blending if this is unsupported.
* - `TextureCompressionASTC` & `TextureCompressionASTCSliced3D`: Required
* for ASTC support.
* - `TextureCompressionBC` & `TextureCompressionBCSliced3D`: Required for
* BC texture format support
* - `Float32Blendable`: Required for blending Float32 textures. The backend
* will safely disable blending if this is unsupported.
* - `TextureCompressionASTC` & `TextureCompressionASTCSliced3D`: Required for
* ASTC support.
* - `TextureCompressionBC` & `TextureCompressionBCSliced3D`: Required for BC
* texture format support
* - `TextureFormatsTier1` & `TextureFormatsTier2`: Required for a lot of
* stuff, mostly related to texture sampling & access.
*
@@ -2900,8 +2900,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUD
* slot order.
*
* \param device a GPU Context.
* \param createinfo a struct describing the state of the compute pipeline to
* create.
* \param createinfo a struct describing the state of the shader to create.
* \returns a compute pipeline object on success, or NULL on failure; call
* SDL_GetError() for more information.
*
@@ -2909,273 +2908,12 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUD
*
* \sa SDL_BindGPUComputePipeline
* \sa SDL_ReleaseGPUComputePipeline
*/
extern SDL_DECLSPEC SDL_GPUComputePipeline * SDLCALL SDL_CreateGPUComputePipeline(
SDL_GPUDevice *device,
const SDL_GPUComputePipelineCreateInfo *createinfo);
#define SDL_PROP_GPU_COMPUTEPIPELINE_CREATE_NAME_STRING "SDL.gpu.computepipeline.create.name"
/**
* Creates a pipeline object to be used in a graphics workflow.
*
* There are optional properties that can be provided through `props`. These
* are the supported properties:
*
* - `SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING`: a name that can be
* displayed in debugging tools.
*
* \param device a GPU Context.
* \param createinfo a struct describing the state of the graphics pipeline to
* create.
* \returns a graphics pipeline object on success, or NULL on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_CreateGPUShader
* \sa SDL_BindGPUGraphicsPipeline
* \sa SDL_ReleaseGPUGraphicsPipeline
*/
extern SDL_DECLSPEC SDL_GPUGraphicsPipeline * SDLCALL SDL_CreateGPUGraphicsPipeline(
SDL_GPUDevice *device,
const SDL_GPUGraphicsPipelineCreateInfo *createinfo);
#define SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING "SDL.gpu.graphicspipeline.create.name"
/**
* Creates a sampler object to be used when binding textures in a graphics
* workflow.
*
* There are optional properties that can be provided through `props`. These
* are the supported properties:
*
* - `SDL_PROP_GPU_SAMPLER_CREATE_NAME_STRING`: a name that can be displayed
* in debugging tools.
*
* \param device a GPU Context.
* \param createinfo a struct describing the state of the sampler to create.
* \returns a sampler object on success, or NULL on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_BindGPUVertexSamplers
* \sa SDL_BindGPUFragmentSamplers
* \sa SDL_ReleaseGPUSampler
*/
extern SDL_DECLSPEC SDL_GPUSampler * SDLCALL SDL_CreateGPUSampler(
SDL_GPUDevice *device,
const SDL_GPUSamplerCreateInfo *createinfo);
#define SDL_PROP_GPU_SAMPLER_CREATE_NAME_STRING "SDL.gpu.sampler.create.name"
/**
* Creates a shader to be used when creating a graphics pipeline.
*
* Shader resource bindings must be authored to follow a particular convention
* depending on the shader format. See below for details.
*
* ---
*
* **SPIR-V (GLSL)**
*
* For vertex shaders, use: - Set 0 for samplers, storage textures, and
* storage buffers - Set 1 for uniform data
*
* For fragment shaders, use: - Set 2 for samplers, storage textures, and
* storage buffers - Set 3 for uniform data
*
* The first resource in a given set must have a `binding` of 0. Additional
* resources must appear at consecutive bindings (1, 2, etc), leaving no gaps
* in the set.
*
* All samplers must come first in the binding order, in order of how they are
* bound via `SDL_BindGPU*Samplers()`.
*
* All storage textures must come after all samplers in the binding order, in
* order of how they are bound via `SDL_Bind*StorageTextures()`.
*
* All storage buffers must come after all storage textures in the binding
* order, in order of how they are bound via `SDL_Bind*StorageBuffers()`.
*
* **Example**
*
* If a vertex shader binds 2 samplers, 2 storage textures, 2 storage buffers,
* and 2 uniform buffers, its binding layout should look like this:
*
* ```glsl
* // Any samplers come first in the set, in SDL bind slot order
* layout(set = 0, binding = 0) uniform sampler2D samplerBoundToSlot0;
* layout(set = 0, binding = 1) uniform sampler2D samplerBoundToSlot1;
* // Any storage textures come next in the set, in SDL bind slot order
* layout(set = 0, binding = 2) uniform image2D storageTextureBoundToSlot0;
* layout(set = 0, binding = 3) uniform image2D storageTextureBoundToSlot1;
* // Any storage buffers come next in the set, in SDL bind slot order
* layout(set = 0, binding = 4) buffer storageBufferBoundToSlot0 { ... };
* layout(set = 0, binding = 5) buffer storageBufferBoundToSlot1 { ... };
* // Any uniform buffers are in their own set, in SDL slot order
* layout(set = 1, binding = 0) uniform UniformDataBoundToSlot0 { ... };
* layout(set = 1, binding = 1) uniform UniformDataBoundToSlot1 { ... };
* ```
*
* ---
*
* **DXBC / DXIL (HLSL)**
*
* For vertex shaders, use: - `(t[n], space0)` for sampled textures, storage
* textures, and storage buffers - `(s[n], space0)` for samplers - `(b[n],
* space1)` for uniform data
*
* For fragment (aka "pixel") shaders, use: - `(t[n], space2)` for sampled
* textures, storage textures, and storage buffers - `(s[n], space2)` for
* samplers - `(b[n], space3)` for uniform data
*
* The first resource in a given register set must have a register index of
* `0`. Additional resources must appear at consecutive indices (1, 2, etc),
* leaving no gaps in the register set.
*
* All sampled textures must come first in the `t` register set, in order of
* how they are bound via `SDL_BindGPU*Samplers()`.
*
* All sampler objects must be in the `s` register set, in the same order as
* the textures above.
*
* All storage textures must come after all samplers in the `t` register set,
* in order of how they are bound via `SDL_Bind*StorageTextures()`.
*
* All storage buffers must come after all storage textures in the `t`
* register set, in order of how they are bound via
* `SDL_Bind*StorageBuffers()`.
*
* **Example**
*
* If a pixel shader binds 2 samplers, 2 storage textures, 2 storage buffers,
* and 2 uniform buffers, its binding layout should look like this:
*
* ```c
* // Any samplers and sampled textures come first in their respective register sets, in SDL bind slot order
* SamplerState SamplerBoundToSlot0 : register( s0, space2 );
* SamplerState SamplerBoundToSlot1 : register( s1, space2 );
* Texture2D SampledTextureBoundToSlot0 : register( t0, space2 );
* Texture2D SampledTextureBoundToSlot1 : register( t1, space2 );
* // Any storage textures come next in the `t` register set, in SDL bind slot order
* Texture2D StorageTextureBoundToSlot0 : register( t2, space2 );
* Texture2D StorageTextureBoundToSlot1 : register( t3, space2 );
* // Any storage buffers come next in the `t` register set, in SDL bind slot order
* ByteAddressBuffer StorageBufferBoundToSlot0 : register( t4, space2 );
* ByteAddressBuffer StorageBufferBoundToSlot1 : register( t5, space2 );
* // Any uniform buffers are in the `b` register set *and* in their own space, in SDL slot order
* cbuffer UniformDataBoundToSlot0 : register( b0, space3 ) { ... };
* cbuffer UniformDataBoundToSlot1 : register( b1, space3 ) { ... };
* ```
*
* ---
*
* **MSL / Metallib (Metal Shading Language)**
*
* The first resource in a given argument table must have an index of `0`.
* Additional resources must appear at consecutive indices (1, 2, etc),
* leaving no gaps in the table. (_Except_ in the case of vertex buffers,
* which are mentioned below.)
*
* All sampled textures must come first in the `[[texture]]` argument table,
* in order of how they are bound via `SDL_BindGPU*Samplers()`.
*
* All sampler objects must be in the `[[sampler]]` argument table, in the
* same order as the textures above.
*
* All storage textures must come after all sampled textures in the
* `[[texture]]` argument table, in order of how they are bound via
* `SDL_BindGPU*StorageTextures()`.
*
* All uniform buffers must come first in the `[[buffer]]` argument table, in
* order of their slots in `SDL_PushGPU*UniformData()`.
*
* All storage buffers must come after all uniform buffers in the `[[buffer]]`
* argument table, in order of how they are bound via
* `SDL_BindGPU*StorageBuffers()`.
*
* In Metal, vertex buffers are also included in the `[[buffer]]` argument
* table. To work around this, SDL forces the vertex buffer bound to slot 0 to
* be bound at `[[buffer(14)]]`. The vertex buffer in slot 1 will be bound to
* `[[buffer(15)]]`, and so on. Rather than manually authoring vertex buffer
* indices, use the `[[stage_in]]` attribute which will automatically use the
* vertex input information from the SDL_GPUGraphicsPipeline.
*
* **Example**
*
* For a vertex shader with 1 vertex buffer, 2 samplers, 2 storage textures, 2
* storage buffers, and 2 uniform buffers, the main function signature should
* look something like this:
*
* ```c++
* vertex VertexOutput ExampleVertexShader(
* // Vertex buffers are their own special thing...
* SomeVertexInput input [[stage_in]], // alternatively, SomeVertexInput input [[buffer(14)]]
* // Any samplers go in the `sampler` table, in SDL bind slot order
* sampler samplerBoundToSlot0 [[sampler(0)]],
* sampler samplerBoundToSlot1 [[sampler(1)]],
* // Any sampled textures come first in the `texture` table, in SDL bind slot order
* texture2d<float> sampledTextureBoundToSlot0 [[texture(0)]],
* texture2d<float> sampledTextureBoundToSlot1 [[texture(1)]],
* // Any storage textures come next in the `texture` table, in SDL bind slot order
* texture2d<float> storageTextureBoundToSlot0 [[texture(2)]],
* texture2d<float> storageTextureBoundToSlot1 [[texture(3)]],
* // Any uniform buffers come first in the `buffer` table, in SDL slot order
* constant SomeUniformStruct uniformDataBoundToSlot0 [[buffer(0)]],
* constant SomeUniformStruct uniformDataBoundToSlot1 [[buffer(1)]],
* // Any storage buffers come next in the `buffer` table, in SDL bind slot order
* device SomeBufferStruct& storageBufferBoundToSlot0 [[buffer(2)]],
* device SomeBufferStruct& storageBufferBoundToSlot1 [[buffer(3)]]);
*
* ```
*
* ---
*
* **WGSL (WebGPU Shading Language)**
*
* For vertex shaders, use: - Group 0 for samplers, storage textures, and
* storage buffers - Group 1 for uniform data
*
* For fragment shaders, use: - Group 2 for samplers, storage textures, and
* storage buffers - Group 3 for uniform data
*
* The first resource in a given set must have a `binding` of 0. Additional
* resources must appear at consecutive bindings (1, 2, etc), leaving no gaps
* in the set.
*
* All sampled textures must come first in the binding order, followed by
* their associated sampler, in order of how they are bound via
* `SDL_BindGPU*Samplers()`.
*
* All storage textures must come after all samplers and sampled textures in
* the binding order, in order of how they are bound via
* `SDL_Bind*StorageTextures()`.
*
* All storage buffers must come after all storage textures in the binding
* order, in order of how they are bound via `SDL_Bind*StorageBuffers()`.
*
* Note that WebGPU has... odd alignment rules. All types must be aligned to a
* power of two, but can be any size. Consult the
* [WebGPU spec](https://www.w3.org/TR/WGSL/#alignment-and-size)
* for more.
*
* **Example**
*
* If a vertex shader binds 2 samplers, 2 storage textures, 2 storage buffers,
* and 2 uniform buffers, its binding layout should look like this:
*
* ```wgsl // Sampled textures come first, followed by the sampler, in SDL
* slot order.
*
* \param device a GPU Context.
* \param createinfo a struct describing the state of the shader to create.
* \returns a shader object on success, or NULL on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.2.0.
*
* \sa SDL_CreateGPUGraphicsPipeline
* \sa SDL_ReleaseGPUShader
*/