Skip to content

Commit 5f64c85

Browse files
TheSpydogflibitijibibo
authored andcommitted
Document resource binding order (thatcosmonaut#73)
1 parent ed3bcbe commit 5f64c85

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

include/SDL3/SDL_gpu.h

+48
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,26 @@ extern SDL_DECLSPEC SDL_GpuBackend SDLCALL SDL_GpuGetBackend(SDL_GpuDevice *devi
831831
/**
832832
* Creates a pipeline object to be used in a compute workflow.
833833
*
834+
* Shader resource bindings must be authored to follow a particular order.
835+
* For SPIR-V shaders, use the following resource sets:
836+
* 0: Read-only storage textures, followed by read-only storage buffers
837+
* 1: Read-write storage textures, followed by read-write storage buffers
838+
* 2: Uniform buffers
839+
*
840+
* For HLSL/DXBC/DXIL, use the following order:
841+
* For t registers:
842+
* Read-only storage textures, followed by read-only storage buffers
843+
* For b registers:
844+
* Uniform buffers
845+
* For u registers:
846+
* Read-write storage textures, followed by read-write storage buffers
847+
*
848+
* For MSL/metallib, use the following order:
849+
* For [[buffer]]:
850+
* Uniform buffers, followed by read-only storage buffers, followed by read-write storage buffers
851+
* For [[texture]]:
852+
* Read-only storage textures, followed by read-write storage textures
853+
*
834854
* \param device a GPU Context
835855
* \param computePipelineCreateInfo a struct describing the state of the requested compute pipeline
836856
* \returns a compute pipeline object on success, or NULL on failure
@@ -881,6 +901,34 @@ extern SDL_DECLSPEC SDL_GpuSampler *SDLCALL SDL_GpuCreateSampler(
881901
/**
882902
* Creates a shader to be used when creating a graphics pipeline.
883903
*
904+
* Shader resource bindings must be authored to follow a particular order.
905+
* For SPIR-V shaders, use the following resource sets:
906+
* For vertex shaders:
907+
* 0: Sampled textures, followed by storage textures, followed by storage buffers
908+
* 1: Uniform buffers
909+
* For fragment shaders:
910+
* 2: Sampled textures, followed by storage textures, followed by storage buffers
911+
* 3: Uniform buffers
912+
*
913+
* For HLSL/DXBC/DXIL, use the following order:
914+
* For t registers:
915+
* Sampled textures, followed by storage textures, followed by storage buffers
916+
* For s registers:
917+
* Samplers with indices corresponding to the sampled textures
918+
* For b registers:
919+
* Uniform buffers
920+
*
921+
* For MSL/metallib, use the following order:
922+
* For [[texture]]:
923+
* Sampled textures, followed by storage textures
924+
* For [[sampler]]:
925+
* Samplers with indices corresponding to the sampled textures
926+
* For [[buffer]]:
927+
* Uniform buffers, followed by storage buffers.
928+
* Vertex buffer 0 is bound at [[buffer(30)]], vertex buffer 1 at [[buffer(29)]], and so on.
929+
* Rather than manually authoring vertex buffer indices, use the [[stage_in]] attribute
930+
* which will automatically use the vertex input information from the SDL_GpuPipeline.
931+
*
884932
* \param device a GPU Context
885933
* \param shaderCreateInfo a struct describing the state of the desired shader
886934
* \returns a shader object on success, or NULL on failure

0 commit comments

Comments
 (0)