7#include <SDL3/SDL_gpu.h>
9#include <backends/imgui_impl_sdlgpu3.h>
18 const char*
path =
nullptr;
19 SDL_GPUShaderStage
stage = SDL_GPU_SHADERSTAGE_VERTEX;
38 const void*
data =
nullptr;
46ImGui_ImplSDLGPU3_InitInfo
createImGuiInfo(SDL_GPUDevice* device, SDL_Window* window);
55makeAttribute(Uint32 location, SDL_GPUVertexElementFormat format, Uint32 offset, Uint32 bufferSlot = 0);
94SDL_GPUShader*
loadShader(SDL_GPUDevice* device,
96 SDL_GPUShaderFormat format,
97 SDL_GPUShaderStage stage,
99 Uint32 uniformBufferCount,
100 Uint32 storageBufferCount,
101 Uint32 storageTextureCount);
108SDL_GPUShader*
loadShader(SDL_GPUDevice* device,
const ShaderInfo& shaderInfo, SDL_GPUShaderFormat format);
121 SDL_GPUTextureFormat& colorFormat,
122 SDL_GPUShaderFormat shaderFormat,
126 bool enableDepth =
true,
127 bool overBlending =
false);
134SDL_GPUBuffer*
createBuffer(SDL_GPUDevice* device,
size_t bufferSize, SDL_GPUBufferUsageFlags usage);
141SDL_GPUTransferBuffer*
createTransferBuffer(SDL_GPUDevice* device,
size_t transferBufferSize,
bool upload);
147SDL_GPUTransferBuffer*
createUploadBuffer(SDL_GPUDevice* device,
size_t transferBufferSize);
153void uploadBuffers(SDL_GPUDevice* device, SDL_GPUCommandBuffer* cmd,
const std::vector<BufferUpload>& uploads);
161SDL_GPUTexture*
createTextureRGBA8(SDL_GPUDevice* device, Uint32 width, Uint32 height,
const void* data);
167SDL_GPUTexture*
loadTexture(SDL_GPUDevice* device,
const char* path);
174SDL_GPUTexture*
createDepthTexture(SDL_GPUDevice* device, Uint32 width, Uint32 height);
Definition Boilerplate.cpp:12
SDL_GPUTexture * createTextureRGBA8(SDL_GPUDevice *device, Uint32 width, Uint32 height, const void *data)
Create a 2D RGBA8 texture and upload pixel data to it.
Definition Boilerplate.cpp:294
SDL_GPUColorTargetInfo makeColorTargetLoad(SDL_GPUTexture *texture)
Create a color render-target info with a clear color.
Definition Boilerplate.cpp:43
SDL_GPUShader * loadShader(SDL_GPUDevice *device, const char *path, SDL_GPUShaderFormat format, SDL_GPUShaderStage stage, Uint32 samplerCount, Uint32 uniformBufferCount, Uint32 storageBufferCount, Uint32 storageTextureCount)
Load and compile a shader from disk (explicit parameters).
Definition Boilerplate.cpp:94
void uploadBuffers(SDL_GPUDevice *device, SDL_GPUCommandBuffer *cmd, const std::vector< BufferUpload > &uploads)
Batch-upload multiple CPU buffers to their corresponding GPU buffers.
Definition Boilerplate.cpp:243
SDL_GPUColorTargetInfo makeColorTargetClear(SDL_GPUTexture *texture, SDL_FColor clearColor)
Create a color render-target info with a clear color.
Definition Boilerplate.cpp:33
SDL_GPUTransferBuffer * createUploadBuffer(SDL_GPUDevice *device, size_t transferBufferSize)
Allocate a GPU transfer buffer for uploading data.
Definition Boilerplate.cpp:238
SDL_GPUSampler * createLinearRepeatSampler(SDL_GPUDevice *device)
Create a linear-filtering, repeat-addressing sampler.
Definition Boilerplate.cpp:395
SDL_GPUBuffer * createBuffer(SDL_GPUDevice *device, size_t bufferSize, SDL_GPUBufferUsageFlags usage)
Allocate a GPU buffer of the given size and usage.
Definition Boilerplate.cpp:220
SDL_GPUTexture * loadTexture(SDL_GPUDevice *device, const char *path)
Load an image file from disk and create a GPU texture from it.
Definition Boilerplate.cpp:354
SDL_GPUTransferBuffer * createTransferBuffer(SDL_GPUDevice *device, size_t transferBufferSize, bool upload)
Allocate a GPU transfer buffer for upload or download.
Definition Boilerplate.cpp:229
SDL_GPUDepthStencilTargetInfo makeDepthTarget(SDL_GPUTexture *texture)
Create a depth/stencil render-target info that clears to depth 1.0.
Definition Boilerplate.cpp:52
SDL_GPUVertexAttribute makeAttribute(Uint32 location, SDL_GPUVertexElementFormat format, Uint32 offset, Uint32 bufferSlot)
Build an SDL_GPUVertexAttribute descriptor.
Definition Boilerplate.cpp:23
SDL_GPUTextureSamplerBinding makeTextureSamplerBinding(SDL_GPUTexture *texture, SDL_GPUSampler *sampler)
Create a texture-sampler binding pair for fragment shader use.
Definition Boilerplate.cpp:66
ImGui_ImplSDLGPU3_InitInfo createImGuiInfo(SDL_GPUDevice *device, SDL_Window *window)
Create an ImGui initialization info struct for SDL3 GPU rendering.
Definition Boilerplate.cpp:13
SDL_GPUShaderFormat selectShaderFormat(SDL_GPUDevice *device)
Pick the best available shader format for the given device.
Definition Boilerplate.cpp:74
SDL_GPUGraphicsPipeline * createGraphicsPipeline(SDL_GPUDevice *device, SDL_GPUTextureFormat &colorFormat, SDL_GPUShaderFormat shaderFormat, const ShaderInfo &vertexShaderInfo, const ShaderInfo &fragmentShaderInfo, const VertexInputLayout &vertexInputLayout, bool enableDepth, bool overBlending)
Create a full graphics pipeline from vertex/fragment shaders and vertex layout.
Definition Boilerplate.cpp:152
SDL_GPUTexture * createDepthTexture(SDL_GPUDevice *device, Uint32 width, Uint32 height)
Create a D32_FLOAT depth texture of the given dimensions.
Definition Boilerplate.cpp:376
Describes a pending CPU-to-GPU buffer upload: target buffer, source data, and byte size.
Definition Boilerplate.hpp:36
SDL_GPUBuffer * buffer
Definition Boilerplate.hpp:37
const void * data
Definition Boilerplate.hpp:38
size_t size
Definition Boilerplate.hpp:39
Descriptor for a single shader stage: file path, stage, and resource counts.
Definition Boilerplate.hpp:17
SDL_GPUShaderStage stage
Definition Boilerplate.hpp:19
Uint32 uniformBufferCount
Definition Boilerplate.hpp:21
Uint32 storageBufferCount
Definition Boilerplate.hpp:22
const char * path
Definition Boilerplate.hpp:18
Uint32 storageTextureCount
Definition Boilerplate.hpp:23
Uint32 samplerCount
Definition Boilerplate.hpp:20