Sync SDL3 wiki -> header
[ci skip]
This commit is contained in:
@@ -162,17 +162,17 @@
|
|||||||
*
|
*
|
||||||
* **Question: Why is my shader not working?**
|
* **Question: Why is my shader not working?**
|
||||||
*
|
*
|
||||||
* Answer: A common oversight when using shaders is not properly laying out the
|
* Answer: A common oversight when using shaders is not properly laying out
|
||||||
* shader resources/registers correctly. The GPU API is very strict with how it
|
* the shader resources/registers correctly. The GPU API is very strict with
|
||||||
* wants resources to be laid out and it's difficult for the API to
|
* how it wants resources to be laid out and it's difficult for the API to
|
||||||
* automatically validate shaders to see if they have a compatible layout. See
|
* automatically validate shaders to see if they have a compatible layout. See
|
||||||
* the documentation for SDL_CreateGPUShader() and
|
* the documentation for SDL_CreateGPUShader() and
|
||||||
* SDL_CreateGPUComputePipeline() for information on the expected layout.
|
* SDL_CreateGPUComputePipeline() for information on the expected layout.
|
||||||
*
|
*
|
||||||
* Another common issue is not setting the correct number of samplers, textures,
|
* Another common issue is not setting the correct number of samplers,
|
||||||
* and buffers in SDL_GPUShaderCreateInfo. If possible use shader reflection to
|
* textures, and buffers in SDL_GPUShaderCreateInfo. If possible use shader
|
||||||
* extract the required information from the shader automatically instead of
|
* reflection to extract the required information from the shader
|
||||||
* manually filling in the struct's values.
|
* automatically instead of manually filling in the struct's values.
|
||||||
*
|
*
|
||||||
* ## System Requirements
|
* ## System Requirements
|
||||||
*
|
*
|
||||||
@@ -211,54 +211,55 @@
|
|||||||
* keeps its value throughout the command buffer until you call the relevant
|
* keeps its value throughout the command buffer until you call the relevant
|
||||||
* Push function on that slot again.
|
* Push function on that slot again.
|
||||||
*
|
*
|
||||||
* For example, you could write your vertex shaders to read a camera matrix from
|
* For example, you could write your vertex shaders to read a camera matrix
|
||||||
* uniform binding slot 0, push the camera matrix at the start of the command
|
* from uniform binding slot 0, push the camera matrix at the start of the
|
||||||
* buffer, and that data will be used for every subsequent draw call.
|
* command buffer, and that data will be used for every subsequent draw call.
|
||||||
*
|
*
|
||||||
* It is valid to push uniform data during a render or compute pass.
|
* It is valid to push uniform data during a render or compute pass.
|
||||||
*
|
*
|
||||||
* Uniforms are best for pushing small amounts of data. If you are pushing more
|
* Uniforms are best for pushing small amounts of data. If you are pushing
|
||||||
* than a matrix or two per call you should consider using a storage buffer
|
* more than a matrix or two per call you should consider using a storage
|
||||||
* instead.
|
* buffer instead.
|
||||||
*
|
*
|
||||||
* ## A Note On Cycling
|
* ## A Note On Cycling
|
||||||
*
|
*
|
||||||
* When using a command buffer, operations do not occur immediately - they occur
|
* When using a command buffer, operations do not occur immediately - they
|
||||||
* some time after the command buffer is submitted.
|
* occur some time after the command buffer is submitted.
|
||||||
*
|
*
|
||||||
* When a resource is used in a pending or active command buffer, it is
|
* When a resource is used in a pending or active command buffer, it is
|
||||||
* considered to be "bound". When a resource is no longer used in any pending or
|
* considered to be "bound". When a resource is no longer used in any pending
|
||||||
* active command buffers, it is considered to be "unbound".
|
* or active command buffers, it is considered to be "unbound".
|
||||||
*
|
*
|
||||||
* If data resources are bound, it is unspecified when that data will be unbound
|
* If data resources are bound, it is unspecified when that data will be
|
||||||
* unless you acquire a fence when submitting the command buffer and wait on it.
|
* unbound unless you acquire a fence when submitting the command buffer and
|
||||||
* However, this doesn't mean you need to track resource usage manually.
|
* wait on it. However, this doesn't mean you need to track resource usage
|
||||||
|
* manually.
|
||||||
*
|
*
|
||||||
* All of the functions and structs that involve writing to a resource have a
|
* All of the functions and structs that involve writing to a resource have a
|
||||||
* "cycle" bool. SDL_GPUTransferBuffer, SDL_GPUBuffer, and SDL_GPUTexture all
|
* "cycle" bool. SDL_GPUTransferBuffer, SDL_GPUBuffer, and SDL_GPUTexture all
|
||||||
* effectively function as ring buffers on internal resources. When cycle is
|
* effectively function as ring buffers on internal resources. When cycle is
|
||||||
* true, if the resource is bound, the cycle rotates to the next unbound
|
* true, if the resource is bound, the cycle rotates to the next unbound
|
||||||
* internal resource, or if none are available, a new one is created. This means
|
* internal resource, or if none are available, a new one is created. This
|
||||||
* you don't have to worry about complex state tracking and synchronization as
|
* means you don't have to worry about complex state tracking and
|
||||||
* long as cycling is correctly employed.
|
* synchronization as long as cycling is correctly employed.
|
||||||
*
|
*
|
||||||
* For example: you can call SDL_MapGPUTransferBuffer(), write texture data,
|
* For example: you can call SDL_MapGPUTransferBuffer(), write texture data,
|
||||||
* SDL_UnmapGPUTransferBuffer(), and then SDL_UploadToGPUTexture(). The next
|
* SDL_UnmapGPUTransferBuffer(), and then SDL_UploadToGPUTexture(). The next
|
||||||
* time you write texture data to the transfer buffer, if you set the cycle
|
* time you write texture data to the transfer buffer, if you set the cycle
|
||||||
* param to true, you don't have to worry about overwriting any data that is not
|
* param to true, you don't have to worry about overwriting any data that is
|
||||||
* yet uploaded.
|
* not yet uploaded.
|
||||||
*
|
*
|
||||||
* Another example: If you are using a texture in a render pass every frame,
|
* 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 true in
|
* this can cause a data dependency between frames. If you set cycle to true
|
||||||
* the SDL_GPUColorTargetInfo struct, you can prevent this data dependency.
|
* in the SDL_GPUColorTargetInfo struct, you can prevent this data dependency.
|
||||||
*
|
*
|
||||||
* Cycling will never undefine already bound data. When cycling, all data in the
|
* Cycling will never undefine already bound data. When cycling, all data in
|
||||||
* resource is considered to be undefined for subsequent commands until that
|
* the resource is considered to be undefined for subsequent commands until
|
||||||
* data is written again. You must take care not to read undefined data.
|
* that data is written again. You must take care not to read undefined data.
|
||||||
*
|
*
|
||||||
* Note that when cycling a texture, the entire texture will be cycled, even if
|
* Note that when cycling a texture, the entire texture will be cycled, even
|
||||||
* only part of the texture is used in the call, so you must consider the entire
|
* if only part of the texture is used in the call, so you must consider the
|
||||||
* texture to contain undefined data after cycling.
|
* entire texture to contain undefined data after cycling.
|
||||||
*
|
*
|
||||||
* You must also take care not to overwrite a section of data that has been
|
* You must also take care not to overwrite a section of data that has been
|
||||||
* referenced in a command without cycling first. It is OK to overwrite
|
* referenced in a command without cycling first. It is OK to overwrite
|
||||||
@@ -1214,8 +1215,8 @@ typedef enum SDL_GPUPresentMode
|
|||||||
*
|
*
|
||||||
* - SDR: B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in sRGB encoding.
|
* - SDR: B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in sRGB encoding.
|
||||||
* - SDR_LINEAR: B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are
|
* - SDR_LINEAR: B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are
|
||||||
* stored in memory in sRGB encoding but accessed in shaders in "linear sRGB"
|
* stored in memory in sRGB encoding but accessed in shaders in "linear
|
||||||
* encoding which is sRGB but with a linear transfer function.
|
* sRGB" encoding which is sRGB but with a linear transfer function.
|
||||||
* - HDR_EXTENDED_LINEAR: R16G16B16A16_SFLOAT swapchain. Pixel values are in
|
* - HDR_EXTENDED_LINEAR: R16G16B16A16_SFLOAT swapchain. Pixel values are in
|
||||||
* extended linear sRGB encoding and permits values outside of the [0, 1]
|
* extended linear sRGB encoding and permits values outside of the [0, 1]
|
||||||
* range.
|
* range.
|
||||||
|
|||||||
Reference in New Issue
Block a user