gpu topic

CategoryGPU

The GPU API offers a cross-platform way for apps to talk to modern graphics hardware. It offers both 3D graphics and compute support, in the style of Metal, Vulkan, and Direct3D 12.

A basic workflow might be something like this:

The app creates a GPU device with SDL_CreateGPUDevice(), and assigns it to a window with SDL_ClaimWindowForGPUDevice()--although strictly speaking you can render offscreen entirely, perhaps for image processing, and not use a window at all.

Next, the app prepares static data (things that are created once and used over and over). For example:

  • Shaders (programs that run on the GPU): use SDL_CreateGPUShader().
  • Vertex buffers (arrays of geometry data) and other rendering data: use SDL_CreateGPUBuffer() and SDL_UploadToGPUBuffer().
  • Textures (images): use SDL_CreateGPUTexture() and SDL_UploadToGPUTexture().
  • Samplers (how textures should be read from): use SDL_CreateGPUSampler().
  • Render pipelines (precalculated rendering state): use SDL_CreateGPUGraphicsPipeline()

To render, the app creates one or more command buffers, with SDL_AcquireGPUCommandBuffer(). Command buffers collect rendering instructions that will be submitted to the GPU in batch. Complex scenes can use multiple command buffers, maybe configured across multiple threads in parallel, as long as they are submitted in the correct order, but many apps will just need one command buffer per frame.

Rendering can happen to a texture (what other APIs call a "render target") or it can happen to the swapchain texture (which is just a special texture that represents a window's contents). The app can use SDL_WaitAndAcquireGPUSwapchainTexture() to render to the window.

Rendering actually happens in a Render Pass, which is encoded into a command buffer. One can encode multiple render passes (or alternate between render and compute passes) in a single command buffer, but many apps might simply need a single render pass in a single command buffer. Render Passes can render to up to four color textures and one depth texture simultaneously. If the set of textures being rendered to needs to change, the Render Pass must be ended and a new one must be begun.

The app calls SDL_BeginGPURenderPass(). Then it sets states it needs for each draw:

  • SDL_BindGPUGraphicsPipeline()
  • SDL_SetGPUViewport()
  • SDL_BindGPUVertexBuffers()
  • SDL_BindGPUVertexSamplers()
  • etc

Then, make the actual draw commands with these states:

  • SDL_DrawGPUPrimitives()
  • SDL_DrawGPUPrimitivesIndirect()
  • SDL_DrawGPUIndexedPrimitivesIndirect()
  • etc

After all the drawing commands for a pass are complete, the app should call SDL_EndGPURenderPass(). Once a render pass ends all render-related state is reset.

The app can begin new Render Passes and make new draws in the same command buffer until the entire scene is rendered.

Once all of the render commands for the scene are complete, the app calls SDL_SubmitGPUCommandBuffer() to send it to the GPU for processing.

If the app needs to read back data from texture or buffers, the API has an efficient way of doing this, provided that the app is willing to tolerate some latency. When the app uses SDL_DownloadFromGPUTexture() or SDL_DownloadFromGPUBuffer(), submitting the command buffer with SDL_SubmitGPUCommandBufferAndAcquireFence() will return a fence handle that the app can poll or wait on in a thread. Once the fence indicates that the command buffer is done processing, it is safe to read the downloaded data. Make sure to call SDL_ReleaseGPUFence() when done with the fence.

The API also has "compute" support. The app calls SDL_BeginGPUComputePass() with compute-writeable textures and/or buffers, which can be written to in a compute shader. Then it sets states it needs for the compute dispatches:

  • SDL_BindGPUComputePipeline()
  • SDL_BindGPUComputeStorageBuffers()
  • SDL_BindGPUComputeStorageTextures()

Then, dispatch compute work:

  • SDL_DispatchGPUCompute()

For advanced users, this opens up powerful GPU-driven workflows.

Graphics and compute pipelines require the use of shaders, which as mentioned above are small programs executed on the GPU. Each backend (Vulkan, Metal, D3D12) requires a different shader format. When the app creates the GPU device, the app lets the device know which shader formats the app can provide. It will then select the appropriate backend depending on the available shader formats and the backends available on the platform. When creating shaders, the app must provide the correct shader format for the selected backend. If you would like to learn more about why the API works this way, there is a detailed blog post explaining this situation.

It is optimal for apps to pre-compile the shader formats they might use, but for ease of use SDL provides a separate project, SDL_shadercross , for performing runtime shader cross-compilation. It also has a CLI interface for offline precompilation as well.

This is an extremely quick overview that leaves out several important details. Already, though, one can see that GPU programming can be quite complex! If you just need simple 2D graphics, the Render API is much easier to use but still hardware-accelerated. That said, even for 2D applications the performance benefits and expressiveness of the GPU API are significant.

The GPU API targets a feature set with a wide range of hardware support and ease of portability. It is designed so that the app won't have to branch itself by querying feature support. If you need cutting-edge features with limited hardware support, this API is probably not for you.

Examples demonstrating proper usage of this API can be found here .

Performance considerations

Here are some basic tips for maximizing your rendering performance.

  • Beginning a new render pass is relatively expensive. Use as few render passes as you can.
  • Minimize the amount of state changes. For example, binding a pipeline is relatively cheap, but doing it hundreds of times when you don't need to will slow the performance significantly.
  • Perform your data uploads as early as possible in the frame.
  • Don't churn resources. Creating and releasing resources is expensive. It's better to create what you need up front and cache it.
  • Don't use uniform buffers for large amounts of data (more than a matrix or so). Use a storage buffer instead.
  • Use cycling correctly. There is a detailed explanation of cycling further below.
  • Use culling techniques to minimize pixel writes. The less writing the GPU has to do the better. Culling can be a very advanced topic but even simple culling techniques can boost performance significantly.

In general try to remember the golden rule of performance: doing things is more expensive than not doing things. Don't Touch The Driver!

FAQ

Question: When are you adding more advanced features, like ray tracing or mesh shaders?

Answer: We don't have immediate plans to add more bleeding-edge features, but we certainly might in the future, when these features prove worthwhile, and reasonable to implement across several platforms and underlying APIs. So while these things are not in the "never" category, they are definitely not "near future" items either.

Question: Why is my shader not working?

Answer: A common oversight when using shaders is not properly laying out the shader resources/registers correctly. The GPU API is very strict with 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 the documentation for SDL_CreateGPUShader() and SDL_CreateGPUComputePipeline() for information on the expected layout.

Another common issue is not setting the correct number of samplers, textures, and buffers in SDL_GPUShaderCreateInfo. If possible use shader reflection to extract the required information from the shader automatically instead of manually filling in the struct's values.

Question: My application isn't performing very well. Is this the GPU API's fault?

Answer: No. Long answer: The GPU API is a relatively thin layer over the underlying graphics API. While it's possible that we have done something inefficiently, it's very unlikely especially if you are relatively inexperienced with GPU rendering. Please see the performance tips above and make sure you are following them. Additionally, tools like RenderDoc can be very helpful for diagnosing incorrect behavior and performance issues.

System Requirements

Vulkan

SDL driver name: "vulkan" (for use in SDL_CreateGPUDevice() and SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING)

Supported on Windows, Linux, Nintendo Switch, and certain Android devices. Requires Vulkan 1.0 with the following extensions and device features:

  • VK_KHR_swapchain
  • VK_KHR_maintenance1
  • independentBlend
  • imageCubeArray
  • depthClamp
  • shaderClipDistance
  • drawIndirectFirstInstance
  • sampleRateShading

D3D12

SDL driver name: "direct3d12"

Supported on Windows 10 or newer, Xbox One (GDK), and Xbox Series X|S (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_0 and Resource Binding Tier 2 or above.

Metal

SDL driver name: "metal"

Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware requirements vary by operating system:

  • macOS requires an Apple Silicon or Intel Mac2 family GPU
  • iOS/tvOS requires an A9 GPU or newer
  • iOS Simulator and tvOS Simulator are unsupported

Coordinate System

The GPU API uses a left-handed coordinate system, following the convention of D3D12 and Metal. Specifically:

  • Normalized Device Coordinates: The lower-left corner has an x,y coordinate of (-1.0, -1.0). The upper-right corner is (1.0, 1.0). Z values range from [0.0, 1.0] where 0 is the near plane.
  • Viewport Coordinates: The top-left corner has an x,y coordinate of (0, 0) and extends to the bottom-right corner at (viewportWidth, viewportHeight). +Y is down.
  • Texture Coordinates: The top-left corner has an x,y coordinate of (0, 0) and extends to the bottom-right corner at (1.0, 1.0). +Y is down.

If the backend driver differs from this convention (e.g. Vulkan, which has an NDC that assumes +Y is down), SDL will automatically convert the coordinate system behind the scenes, so you don't need to perform any coordinate flipping logic in your shaders.

Uniform Data

Uniforms are for passing data to shaders. The uniform data will be constant across all executions of the shader.

There are 4 available uniform slots per shader stage (where the stages are vertex, fragment, and compute). Uniform data pushed to a slot on a stage keeps its value throughout the command buffer until you call the relevant Push function on that slot again.

For example, you could write your vertex shaders to read a camera matrix from uniform binding slot 0, push the camera matrix at the start of the 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.

Uniforms are best for pushing small amounts of data. If you are pushing more than a matrix or two per call you should consider using a storage buffer instead.

A Note On Cycling

When using a command buffer, operations do not occur immediately - they occur some time after the command buffer is submitted.

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 active command buffers, it is considered to be "unbound".

If data resources are bound, it is unspecified when that data will be unbound unless you acquire a fence when submitting the command buffer and 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 "cycle" bool. SDL_GPUTransferBuffer, SDL_GPUBuffer, and SDL_GPUTexture all effectively function as ring buffers on internal resources. When cycle is 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 you don't have to worry about complex state tracking and synchronization as long as cycling is correctly employed.

For example: you can call SDL_MapGPUTransferBuffer(), write texture data, SDL_UnmapGPUTransferBuffer(), and then SDL_UploadToGPUTexture(). The next 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 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 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. You must take care not to read undefined data.

Note that when cycling a texture, the entire texture will be cycled, even if only part of the texture is used in the call, so you must consider the entire texture to contain undefined data after cycling.

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 unreferenced data in a bound resource without cycling, but overwriting a section of data that has already been referenced will produce unexpected results.

Debugging

At some point of your GPU journey, you will probably encounter issues that are not traceable with regular debugger - for example, your code compiles but you get an empty screen, or your shader fails in runtime.

For debugging such cases, there are tools that allow visually inspecting the whole GPU frame, every drawcall, every bound resource, memory buffers, etc. They are the following, per platform:

  • For Windows/Linux, use RenderDoc
  • For MacOS (Metal), use Xcode built-in debugger (Open XCode, go to Debug > Debug Executable..., select your application, set "GPU Frame Capture" to "Metal" in scheme "Options" window, run your app, and click the small Metal icon on the bottom to capture a frame)

Aside from that, you may want to enable additional debug layers to receive more detailed error messages, based on your GPU backend:

  • For D3D12, the debug layer is an optional feature that can be installed via "Windows Settings -> System -> Optional features" and adding the "Graphics Tools" optional feature.
  • For Vulkan, you will need to install Vulkan SDK on Windows, and on Linux, you usually have some sort of vulkan-validation-layers system package that should be installed.
  • For Metal, it should be enough just to run the application from XCode to receive detailed errors or warnings in the output.

Don't hesitate to use tools as RenderDoc when encountering runtime issues or unexpected output on screen, quick GPU frame inspection can usually help you fix the majority of such problems.

Classes

SdlGpuBlitInfo gpu
SdlGpuBlitRegion gpu
SdlGpuBuffer gpu
SdlGpuBufferBinding gpu
SdlGpuBufferCreateInfo gpu
SdlGpuBufferLocation gpu
SdlGpuBufferRegion gpu
SdlGpuColorTargetBlendState gpu
SdlGpuColorTargetDescription gpu
SdlGpuColorTargetInfo gpu
SdlGpuCommandBuffer gpu
SdlGpuComputePass gpu
SdlGpuComputePipeline gpu
SdlGpuComputePipelineCreateInfo gpu
SdlGpuCopyPass gpu
SdlGpuDepthStencilState gpu
SdlGpuDepthStencilTargetInfo gpu
SdlGpuDevice gpu
SdlGpuFence gpu
SdlGpuGraphicsPipeline gpu
SdlGpuGraphicsPipelineCreateInfo gpu
SdlGpuGraphicsPipelineTargetInfo gpu
SdlGpuIndexedIndirectDrawCommand gpu
SdlGpuIndirectDispatchCommand gpu
SdlGpuIndirectDrawCommand gpu
SdlGpuMultisampleState gpu
SdlGpuRasterizerState gpu
SdlGpuRenderPass gpu
SdlGpuSampler gpu
SdlGpuSamplerCreateInfo gpu
SdlGpuShader gpu
SdlGpuShaderCreateInfo gpu
SdlGpuStencilOpState gpu
SdlGpuStorageBufferReadWriteBinding gpu
SdlGpuStorageTextureReadWriteBinding gpu
SdlGpuTexture gpu
SdlGpuTextureCreateInfo gpu
SdlGpuTextureLocation gpu
SdlGpuTextureRegion gpu
SdlGpuTextureSamplerBinding gpu
SdlGpuTextureTransferInfo gpu
SdlGpuTransferBuffer gpu
SdlGpuTransferBufferCreateInfo gpu
SdlGpuTransferBufferLocation gpu
SdlGpuVertexAttribute gpu
SdlGpuVertexBufferDescription gpu
SdlGpuVertexInputState gpu
SdlGpuViewport gpu
SdlkGpuBlendfactor gpu
SdlkGpuBlendop gpu
SdlkGpuBufferusage gpu
SdlkGpuColorcomponent gpu
SdlkGpuCompareop gpu
SdlkGpuCubemapface gpu
SdlkGpuCullmode gpu
SdlkGpuFillmode gpu
SdlkGpuFilter gpu
SdlkGpuFrontface gpu
SdlkGpuIndexelementsize gpu
SdlkGpuLoadop gpu
SdlkGpuPresentmode gpu
SdlkGpuPrimitivetype gpu
SdlkGpuSamplecount gpu
SdlkGpuSampleraddressmode gpu
SdlkGpuSamplermipmapmode gpu
SdlkGpuShaderformat gpu
SdlkGpuShaderstage gpu
SdlkGpuStencilop gpu
SdlkGpuStoreop gpu
SdlkGpuSwapchaincomposition gpu
SdlkGpuTextureformat gpu
SdlkGpuTexturetype gpu
SdlkGpuTextureusage gpu
SdlkGpuTransferbufferusage gpu
SdlkGpuVertexelementformat gpu
SdlkGpuVertexinputrate gpu
SdlkPropGpu gpu

Functions

sdlAcquireGpuCommandBuffer(Pointer<SdlGpuDevice> device) Pointer<SdlGpuCommandBuffer> gpu
Acquire a command buffer.
sdlAcquireGpuSwapchainTexture(Pointer<SdlGpuCommandBuffer> commandBuffer, Pointer<SdlWindow> window, Pointer<Pointer<SdlGpuTexture>> swapchainTexture, Pointer<Uint32> swapchainTextureWidth, Pointer<Uint32> swapchainTextureHeight) bool gpu
Acquire a texture to use in presentation.
sdlBeginGpuComputePass(Pointer<SdlGpuCommandBuffer> commandBuffer, Pointer<SdlGpuStorageTextureReadWriteBinding> storageTextureBindings, int numStorageTextureBindings, Pointer<SdlGpuStorageBufferReadWriteBinding> storageBufferBindings, int numStorageBufferBindings) Pointer<SdlGpuComputePass> gpu
Begins a compute pass on a command buffer.
sdlBeginGpuCopyPass(Pointer<SdlGpuCommandBuffer> commandBuffer) Pointer<SdlGpuCopyPass> gpu
Begins a copy pass on a command buffer.
sdlBeginGpuRenderPass(Pointer<SdlGpuCommandBuffer> commandBuffer, Pointer<SdlGpuColorTargetInfo> colorTargetInfos, int numColorTargets, Pointer<SdlGpuDepthStencilTargetInfo> depthStencilTargetInfo) Pointer<SdlGpuRenderPass> gpu
Begins a render pass on a command buffer.
sdlBindGpuComputePipeline(Pointer<SdlGpuComputePass> computePass, Pointer<SdlGpuComputePipeline> computePipeline) → void gpu
Binds a compute pipeline on a command buffer for use in compute dispatch.
sdlBindGpuComputeSamplers(Pointer<SdlGpuComputePass> computePass, int firstSlot, Pointer<SdlGpuTextureSamplerBinding> textureSamplerBindings, int numBindings) → void gpu
Binds texture-sampler pairs for use on the compute shader.
sdlBindGpuComputeStorageBuffers(Pointer<SdlGpuComputePass> computePass, int firstSlot, Pointer<Pointer<SdlGpuBuffer>> storageBuffers, int numBindings) → void gpu
Binds storage buffers as readonly for use on the compute pipeline.
sdlBindGpuComputeStorageTextures(Pointer<SdlGpuComputePass> computePass, int firstSlot, Pointer<Pointer<SdlGpuTexture>> storageTextures, int numBindings) → void gpu
Binds storage textures as readonly for use on the compute pipeline.
sdlBindGpuFragmentSamplers(Pointer<SdlGpuRenderPass> renderPass, int firstSlot, Pointer<SdlGpuTextureSamplerBinding> textureSamplerBindings, int numBindings) → void gpu
Binds texture-sampler pairs for use on the fragment shader.
sdlBindGpuFragmentStorageBuffers(Pointer<SdlGpuRenderPass> renderPass, int firstSlot, Pointer<Pointer<SdlGpuBuffer>> storageBuffers, int numBindings) → void gpu
Binds storage buffers for use on the fragment shader.
sdlBindGpuFragmentStorageTextures(Pointer<SdlGpuRenderPass> renderPass, int firstSlot, Pointer<Pointer<SdlGpuTexture>> storageTextures, int numBindings) → void gpu
Binds storage textures for use on the fragment shader.
sdlBindGpuGraphicsPipeline(Pointer<SdlGpuRenderPass> renderPass, Pointer<SdlGpuGraphicsPipeline> graphicsPipeline) → void gpu
Binds a graphics pipeline on a render pass to be used in rendering.
sdlBindGpuIndexBuffer(Pointer<SdlGpuRenderPass> renderPass, Pointer<SdlGpuBufferBinding> binding, int indexElementSize) → void gpu
Binds an index buffer on a command buffer for use with subsequent draw calls.
sdlBindGpuVertexBuffers(Pointer<SdlGpuRenderPass> renderPass, int firstSlot, Pointer<SdlGpuBufferBinding> bindings, int numBindings) → void gpu
Binds vertex buffers on a command buffer for use with subsequent draw calls.
sdlBindGpuVertexSamplers(Pointer<SdlGpuRenderPass> renderPass, int firstSlot, Pointer<SdlGpuTextureSamplerBinding> textureSamplerBindings, int numBindings) → void gpu
Binds texture-sampler pairs for use on the vertex shader.
sdlBindGpuVertexStorageBuffers(Pointer<SdlGpuRenderPass> renderPass, int firstSlot, Pointer<Pointer<SdlGpuBuffer>> storageBuffers, int numBindings) → void gpu
Binds storage buffers for use on the vertex shader.
sdlBindGpuVertexStorageTextures(Pointer<SdlGpuRenderPass> renderPass, int firstSlot, Pointer<Pointer<SdlGpuTexture>> storageTextures, int numBindings) → void gpu
Binds storage textures for use on the vertex shader.
sdlBlitGpuTexture(Pointer<SdlGpuCommandBuffer> commandBuffer, Pointer<SdlGpuBlitInfo> info) → void gpu
Blits from a source texture region to a destination texture region.
sdlCalculateGpuTextureFormatSize(int format, int width, int height, int depthOrLayerCount) int gpu
Calculate the size in bytes of a texture format with dimensions.
sdlCancelGpuCommandBuffer(Pointer<SdlGpuCommandBuffer> commandBuffer) bool gpu
Cancels a command buffer.
sdlClaimWindowForGpuDevice(Pointer<SdlGpuDevice> device, Pointer<SdlWindow> window) bool gpu
Claims a window, creating a swapchain structure for it.
sdlCopyGpuBufferToBuffer(Pointer<SdlGpuCopyPass> copyPass, Pointer<SdlGpuBufferLocation> source, Pointer<SdlGpuBufferLocation> destination, int size, bool cycle) → void gpu
Performs a buffer-to-buffer copy.
sdlCopyGpuTextureToTexture(Pointer<SdlGpuCopyPass> copyPass, Pointer<SdlGpuTextureLocation> source, Pointer<SdlGpuTextureLocation> destination, int w, int h, int d, bool cycle) → void gpu
Performs a texture-to-texture copy.
sdlCreateGpuBuffer(Pointer<SdlGpuDevice> device, Pointer<SdlGpuBufferCreateInfo> createinfo) Pointer<SdlGpuBuffer> gpu
Creates a buffer object to be used in graphics or compute workflows.
sdlCreateGpuComputePipeline(Pointer<SdlGpuDevice> device, Pointer<SdlGpuComputePipelineCreateInfo> createinfo) Pointer<SdlGpuComputePipeline> gpu
Creates a pipeline object to be used in a compute workflow.
sdlCreateGpuDevice(int formatFlags, bool debugMode, String? name) Pointer<SdlGpuDevice> gpu
Creates a GPU context.
sdlCreateGpuDeviceWithProperties(int props) Pointer<SdlGpuDevice> gpu
Creates a GPU context.
sdlCreateGpuGraphicsPipeline(Pointer<SdlGpuDevice> device, Pointer<SdlGpuGraphicsPipelineCreateInfo> createinfo) Pointer<SdlGpuGraphicsPipeline> gpu
Creates a pipeline object to be used in a graphics workflow.
sdlCreateGpuSampler(Pointer<SdlGpuDevice> device, Pointer<SdlGpuSamplerCreateInfo> createinfo) Pointer<SdlGpuSampler> gpu
Creates a sampler object to be used when binding textures in a graphics workflow.
sdlCreateGpuShader(Pointer<SdlGpuDevice> device, Pointer<SdlGpuShaderCreateInfo> createinfo) Pointer<SdlGpuShader> gpu
Creates a shader to be used when creating a graphics pipeline.
sdlCreateGpuTexture(Pointer<SdlGpuDevice> device, Pointer<SdlGpuTextureCreateInfo> createinfo) Pointer<SdlGpuTexture> gpu
Creates a texture object to be used in graphics or compute workflows.
sdlCreateGpuTransferBuffer(Pointer<SdlGpuDevice> device, Pointer<SdlGpuTransferBufferCreateInfo> createinfo) Pointer<SdlGpuTransferBuffer> gpu
Creates a transfer buffer to be used when uploading to or downloading from graphics resources.
sdlDestroyGpuDevice(Pointer<SdlGpuDevice> device) → void gpu
Destroys a GPU context previously returned by SDL_CreateGPUDevice.
sdlDispatchGpuCompute(Pointer<SdlGpuComputePass> computePass, int groupcountX, int groupcountY, int groupcountZ) → void gpu
Dispatches compute work.
sdlDispatchGpuComputeIndirect(Pointer<SdlGpuComputePass> computePass, Pointer<SdlGpuBuffer> buffer, int offset) → void gpu
Dispatches compute work with parameters set from a buffer.
sdlDownloadFromGpuBuffer(Pointer<SdlGpuCopyPass> copyPass, Pointer<SdlGpuBufferRegion> source, Pointer<SdlGpuTransferBufferLocation> destination) → void gpu
Copies data from a buffer to a transfer buffer on the GPU timeline.
sdlDownloadFromGpuTexture(Pointer<SdlGpuCopyPass> copyPass, Pointer<SdlGpuTextureRegion> source, Pointer<SdlGpuTextureTransferInfo> destination) → void gpu
Copies data from a texture to a transfer buffer on the GPU timeline.
sdlDrawGpuIndexedPrimitives(Pointer<SdlGpuRenderPass> renderPass, int numIndices, int numInstances, int firstIndex, int vertexOffset, int firstInstance) → void gpu
Draws data using bound graphics state with an index buffer and instancing enabled.
sdlDrawGpuIndexedPrimitivesIndirect(Pointer<SdlGpuRenderPass> renderPass, Pointer<SdlGpuBuffer> buffer, int offset, int drawCount) → void gpu
Draws data using bound graphics state with an index buffer enabled and with draw parameters set from a buffer.
sdlDrawGpuPrimitives(Pointer<SdlGpuRenderPass> renderPass, int numVertices, int numInstances, int firstVertex, int firstInstance) → void gpu
Draws data using bound graphics state.
sdlDrawGpuPrimitivesIndirect(Pointer<SdlGpuRenderPass> renderPass, Pointer<SdlGpuBuffer> buffer, int offset, int drawCount) → void gpu
Draws data using bound graphics state and with draw parameters set from a buffer.
sdlEndGpuComputePass(Pointer<SdlGpuComputePass> computePass) → void gpu
Ends the current compute pass.
sdlEndGpuCopyPass(Pointer<SdlGpuCopyPass> copyPass) → void gpu
Ends the current copy pass.
sdlEndGpuRenderPass(Pointer<SdlGpuRenderPass> renderPass) → void gpu
Ends the given render pass.
sdlGdkResumeGpu(Pointer<SdlGpuDevice> device) → void gpu
Call this to resume GPU operation on Xbox when you receive the SDL_EVENT_WILL_ENTER_FOREGROUND event.
sdlGdkSuspendGpu(Pointer<SdlGpuDevice> device) → void gpu
Call this to suspend GPU operation on Xbox when you receive the SDL_EVENT_DID_ENTER_BACKGROUND event.
sdlGenerateMipmapsForGpuTexture(Pointer<SdlGpuCommandBuffer> commandBuffer, Pointer<SdlGpuTexture> texture) → void gpu
Generates mipmaps for the given texture.
sdlGetGpuDeviceDriver(Pointer<SdlGpuDevice> device) String? gpu
Returns the name of the backend used to create this GPU context.
sdlGetGpuDeviceProperties(Pointer<SdlGpuDevice> device) int gpu
Get the properties associated with a GPU device.
sdlGetGpuDriver(int index) String? gpu
Get the name of a built in GPU driver.
sdlGetGpuShaderFormats(Pointer<SdlGpuDevice> device) int gpu
Returns the supported shader formats for this GPU context.
sdlGetGpuSwapchainTextureFormat(Pointer<SdlGpuDevice> device, Pointer<SdlWindow> window) int gpu
Obtains the texture format of the swapchain for the given window.
sdlGetGpuTextureFormatFromPixelFormat(int format) int gpu
Get the GPU texture format corresponding to an SDL pixel format.
sdlGetNumGpuDrivers() int gpu
Get the number of GPU drivers compiled into SDL.
sdlGetPixelFormatFromGpuTextureFormat(int format) int gpu
Get the SDL pixel format corresponding to a GPU texture format.
sdlGpuSupportsProperties(int props) bool gpu
Checks for GPU runtime support.
sdlGpuSupportsShaderFormats(int formatFlags, String? name) bool gpu
Checks for GPU runtime support.
sdlGpuTextureFormatTexelBlockSize(int format) int gpu
Obtains the texel block size for a texture format.
sdlGpuTextureSupportsFormat(Pointer<SdlGpuDevice> device, int format, int type, int usage) bool gpu
Determines whether a texture format is supported for a given type and usage.
sdlGpuTextureSupportsSampleCount(Pointer<SdlGpuDevice> device, int format, int sampleCount) bool gpu
Determines if a sample count for a texture format is supported.
sdlInsertGpuDebugLabel(Pointer<SdlGpuCommandBuffer> commandBuffer, String? text) → void gpu
Inserts an arbitrary string label into the command buffer callstream.
sdlMapGpuTransferBuffer(Pointer<SdlGpuDevice> device, Pointer<SdlGpuTransferBuffer> transferBuffer, bool cycle) Pointer<NativeType> gpu
Maps a transfer buffer into application address space.
sdlPopGpuDebugGroup(Pointer<SdlGpuCommandBuffer> commandBuffer) → void gpu
Ends the most-recently pushed debug group.
sdlPushGpuComputeUniformData(Pointer<SdlGpuCommandBuffer> commandBuffer, int slotIndex, Pointer<NativeType> data, int length) → void gpu
Pushes data to a uniform slot on the command buffer.
sdlPushGpuDebugGroup(Pointer<SdlGpuCommandBuffer> commandBuffer, String? name) → void gpu
Begins a debug group with an arbitrary name.
sdlPushGpuFragmentUniformData(Pointer<SdlGpuCommandBuffer> commandBuffer, int slotIndex, Pointer<NativeType> data, int length) → void gpu
Pushes data to a fragment uniform slot on the command buffer.
sdlPushGpuVertexUniformData(Pointer<SdlGpuCommandBuffer> commandBuffer, int slotIndex, Pointer<NativeType> data, int length) → void gpu
Pushes data to a vertex uniform slot on the command buffer.
sdlQueryGpuFence(Pointer<SdlGpuDevice> device, Pointer<SdlGpuFence> fence) bool gpu
Checks the status of a fence.
sdlReleaseGpuBuffer(Pointer<SdlGpuDevice> device, Pointer<SdlGpuBuffer> buffer) → void gpu
Frees the given buffer as soon as it is safe to do so.
sdlReleaseGpuComputePipeline(Pointer<SdlGpuDevice> device, Pointer<SdlGpuComputePipeline> computePipeline) → void gpu
Frees the given compute pipeline as soon as it is safe to do so.
sdlReleaseGpuFence(Pointer<SdlGpuDevice> device, Pointer<SdlGpuFence> fence) → void gpu
Releases a fence obtained from SDL_SubmitGPUCommandBufferAndAcquireFence.
sdlReleaseGpuGraphicsPipeline(Pointer<SdlGpuDevice> device, Pointer<SdlGpuGraphicsPipeline> graphicsPipeline) → void gpu
Frees the given graphics pipeline as soon as it is safe to do so.
sdlReleaseGpuSampler(Pointer<SdlGpuDevice> device, Pointer<SdlGpuSampler> sampler) → void gpu
Frees the given sampler as soon as it is safe to do so.
sdlReleaseGpuShader(Pointer<SdlGpuDevice> device, Pointer<SdlGpuShader> shader) → void gpu
Frees the given shader as soon as it is safe to do so.
sdlReleaseGpuTexture(Pointer<SdlGpuDevice> device, Pointer<SdlGpuTexture> texture) → void gpu
Frees the given texture as soon as it is safe to do so.
sdlReleaseGpuTransferBuffer(Pointer<SdlGpuDevice> device, Pointer<SdlGpuTransferBuffer> transferBuffer) → void gpu
Frees the given transfer buffer as soon as it is safe to do so.
sdlReleaseWindowFromGpuDevice(Pointer<SdlGpuDevice> device, Pointer<SdlWindow> window) → void gpu
Unclaims a window, destroying its swapchain structure.
sdlSetGpuAllowedFramesInFlight(Pointer<SdlGpuDevice> device, int allowedFramesInFlight) bool gpu
Configures the maximum allowed number of frames in flight.
sdlSetGpuBlendConstants(Pointer<SdlGpuRenderPass> renderPass, SdlFColor blendAnts) → void gpu
Sets the current blend constants on a command buffer.
sdlSetGpuBufferName(Pointer<SdlGpuDevice> device, Pointer<SdlGpuBuffer> buffer, String? text) → void gpu
Sets an arbitrary string constant to label a buffer.
sdlSetGpuScissor(Pointer<SdlGpuRenderPass> renderPass, Pointer<SdlRect> scissor) → void gpu
Sets the current scissor state on a command buffer.
sdlSetGpuStencilReference(Pointer<SdlGpuRenderPass> renderPass, int reference) → void gpu
Sets the current stencil reference value on a command buffer.
sdlSetGpuSwapchainParameters(Pointer<SdlGpuDevice> device, Pointer<SdlWindow> window, int swapchainComposition, int presentMode) bool gpu
Changes the swapchain parameters for the given claimed window.
sdlSetGpuTextureName(Pointer<SdlGpuDevice> device, Pointer<SdlGpuTexture> texture, String? text) → void gpu
Sets an arbitrary string constant to label a texture.
sdlSetGpuViewport(Pointer<SdlGpuRenderPass> renderPass, Pointer<SdlGpuViewport> viewport) → void gpu
Sets the current viewport state on a command buffer.
sdlSubmitGpuCommandBuffer(Pointer<SdlGpuCommandBuffer> commandBuffer) bool gpu
Submits a command buffer so its commands can be processed on the GPU.
sdlSubmitGpuCommandBufferAndAcquireFence(Pointer<SdlGpuCommandBuffer> commandBuffer) Pointer<SdlGpuFence> gpu
Submits a command buffer so its commands can be processed on the GPU, and acquires a fence associated with the command buffer.
sdlUnmapGpuTransferBuffer(Pointer<SdlGpuDevice> device, Pointer<SdlGpuTransferBuffer> transferBuffer) → void gpu
Unmaps a previously mapped transfer buffer.
sdlUploadToGpuBuffer(Pointer<SdlGpuCopyPass> copyPass, Pointer<SdlGpuTransferBufferLocation> source, Pointer<SdlGpuBufferRegion> destination, bool cycle) → void gpu
Uploads data from a transfer buffer to a buffer.
sdlUploadToGpuTexture(Pointer<SdlGpuCopyPass> copyPass, Pointer<SdlGpuTextureTransferInfo> source, Pointer<SdlGpuTextureRegion> destination, bool cycle) → void gpu
Uploads data from a transfer buffer to a texture.
sdlWaitAndAcquireGpuSwapchainTexture(Pointer<SdlGpuCommandBuffer> commandBuffer, Pointer<SdlWindow> window, Pointer<Pointer<SdlGpuTexture>> swapchainTexture, Pointer<Uint32> swapchainTextureWidth, Pointer<Uint32> swapchainTextureHeight) bool gpu
Blocks the thread until a swapchain texture is available to be acquired, and then acquires it.
sdlWaitForGpuFences(Pointer<SdlGpuDevice> device, bool waitAll, Pointer<Pointer<SdlGpuFence>> fences, int numFences) bool gpu
Blocks the thread until the given fences are signaled.
sdlWaitForGpuIdle(Pointer<SdlGpuDevice> device) bool gpu
Blocks the thread until the GPU is completely idle.
sdlWaitForGpuSwapchain(Pointer<SdlGpuDevice> device, Pointer<SdlWindow> window) bool gpu
Blocks the thread until a swapchain texture is available to be acquired.
sdlWindowSupportsGpuPresentMode(Pointer<SdlGpuDevice> device, Pointer<SdlWindow> window, int presentMode) bool gpu
Determines whether a presentation mode is supported by the window.
sdlWindowSupportsGpuSwapchainComposition(Pointer<SdlGpuDevice> device, Pointer<SdlWindow> window, int swapchainComposition) bool gpu
Determines whether a swapchain composition is supported by the window.