group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Boilerplate Namespace Reference

Classes

struct  ShaderInfo
 Descriptor for a single shader stage: file path, stage, and resource counts. More...
struct  VertexInputLayout
 Vertex buffer layout: stride (pitch) and per-attribute descriptions. More...
struct  PipelineDescription
struct  BufferUpload
 Describes a pending CPU-to-GPU buffer upload: target buffer, source data, and byte size. More...

Functions

ImGui_ImplSDLGPU3_InitInfo createImGuiInfo (SDL_GPUDevice *device, SDL_Window *window)
 Create an ImGui initialization info struct for SDL3 GPU rendering.
SDL_GPUVertexAttribute makeAttribute (Uint32 location, SDL_GPUVertexElementFormat format, Uint32 offset, Uint32 bufferSlot=0)
 Build an SDL_GPUVertexAttribute descriptor.
SDL_GPUColorTargetInfo makeColorTargetClear (SDL_GPUTexture *texture, SDL_FColor clearColor)
 Create a color render-target info with a clear color.
SDL_GPUColorTargetInfo makeColorTargetLoad (SDL_GPUTexture *texture)
 Create a color render-target info with a clear color.
SDL_GPUDepthStencilTargetInfo makeDepthTarget (SDL_GPUTexture *texture, Uint8 layer, bool store, bool reverseZ)
 Create a depth/stencil render-target info that clears to depth 1.0.
SDL_GPUTextureSamplerBinding makeTextureSamplerBinding (SDL_GPUTexture *texture, SDL_GPUSampler *sampler)
 Create a texture-sampler binding pair for fragment shader use.
SDL_GPUShaderFormat selectShaderFormat (SDL_GPUDevice *device)
 Pick the best available shader format for the given device.
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).
SDL_GPUShader * loadShader (SDL_GPUDevice *device, const ShaderInfo &shaderInfo, SDL_GPUShaderFormat format)
 Load and compile a shader from a ShaderInfo descriptor.
SDL_GPUGraphicsPipeline * createGraphicsDepthPipeline (SDL_GPUDevice *device, PipelineDescription pipelineDesc)
SDL_GPUGraphicsPipeline * createGraphicsPipeline (SDL_GPUDevice *device, SDL_GPUTextureFormat &colorFormat, SDL_GPUShaderFormat shaderFormat, const ShaderInfo &vertexShaderInfo, const ShaderInfo &fragmentShaderInfo, const VertexInputLayout &vertexInputLayout, bool enableDepth=true, bool overBlending=false)
 Create a full graphics pipeline from vertex/fragment shaders and vertex layout.
SDL_GPUGraphicsPipeline * createGraphicsPipeline (SDL_GPUDevice *device, const std::vector< SDL_GPUTextureFormat > &colorFormats, SDL_GPUShaderFormat shaderFormat, const ShaderInfo &vertexShaderInfo, const ShaderInfo &fragmentShaderInfo, const VertexInputLayout &vertexInputLayout, bool enableDepth=true, bool overBlending=false)
 Create a graphics pipeline with multiple color render targets.
SDL_GPUBuffer * createBuffer (SDL_GPUDevice *device, size_t bufferSize, SDL_GPUBufferUsageFlags usage)
 Allocate a GPU buffer of the given size and usage.
SDL_GPUTransferBuffer * createTransferBuffer (SDL_GPUDevice *device, size_t transferBufferSize, bool upload)
 Allocate a GPU transfer buffer for upload or download.
SDL_GPUTransferBuffer * createUploadBuffer (SDL_GPUDevice *device, size_t transferBufferSize)
 Allocate a GPU transfer buffer for uploading data.
void uploadBuffers (SDL_GPUDevice *device, SDL_GPUCommandBuffer *cmd, const std::vector< BufferUpload > &uploads)
 Batch-upload multiple CPU buffers to their corresponding GPU buffers.
SDL_GPUTexture * createEmptyTextureD32F (SDL_GPUDevice *device, Uint32 width, Uint32 height, bool cube, Uint32 arraySize)
 Create an empty depth texture, optionally cube/cube-array shaped.
SDL_GPUTexture * createTextureRGBA32 (SDL_GPUDevice *device, Uint32 width, Uint32 height, const void *data, SDL_GPUTextureFormat format)
SDL_GPUTexture * createTextureRGBA8 (SDL_GPUDevice *device, Uint32 width, Uint32 height, const void *data, SDL_GPUTextureFormat format=SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM)
 Create a 2D RGBA8 texture and upload pixel data to it.
SDL_GPUTexture * loadTexture (SDL_GPUDevice *device, const char *path)
 Load an image file from disk and create a GPU texture from it.
SDL_GPUTexture * createDepthTexture (SDL_GPUDevice *device, Uint32 width, Uint32 height)
 Create a D32_FLOAT depth texture of the given dimensions.
SDL_GPUTexture * createSampledColorTarget (SDL_GPUDevice *device, Uint32 width, Uint32 height, SDL_GPUTextureFormat format)
 Create a sampleable 2D color render target of the given dimensions.
SDL_GPUSampler * createLinearRepeatSampler (SDL_GPUDevice *device, bool nearest)
 Create a linear-filtering, repeat-addressing sampler.
SDL_GPUSampler * createLinearComparisonSampler (SDL_GPUDevice *device, SDL_GPUFilter filterMode, bool reverseZ)
 Create a linear-filtering, comparison sampler (for shadow map depth comparison).
SDL_GPUSampler * createLinearClampSampler (SDL_GPUDevice *device)
 Create a linear-filtering, clamp-to-edge sampler.

Variables

constexpr SDL_GPUColorTargetBlendState OVER_BLEND_MODE

Function Documentation

◆ createBuffer()

SDL_GPUBuffer * Boilerplate::createBuffer ( SDL_GPUDevice * device,
size_t bufferSize,
SDL_GPUBufferUsageFlags usage )

Allocate a GPU buffer of the given size and usage.

Parameters
deviceThe GPU device.
bufferSizeSize in bytes.
usageBuffer usage flags (vertex, index, etc.).
Returns
The created GPU buffer.
Here is the caller graph for this function:

◆ createDepthTexture()

SDL_GPUTexture * Boilerplate::createDepthTexture ( SDL_GPUDevice * device,
Uint32 width,
Uint32 height )

Create a D32_FLOAT depth texture of the given dimensions.

Parameters
deviceThe GPU device.
widthTexture width in pixels.
heightTexture height in pixels.
Returns
The created depth texture, or nullptr on failure.
Here is the caller graph for this function:

◆ createEmptyTextureD32F()

SDL_GPUTexture * Boilerplate::createEmptyTextureD32F ( SDL_GPUDevice * device,
Uint32 width,
Uint32 height,
bool cube,
Uint32 arraySize )

Create an empty depth texture, optionally cube/cube-array shaped.

Parameters
deviceThe GPU device.
widthTexture width in pixels.
heightTexture height in pixels.
cubeWhether to create a cube texture.
arraySizeNumber of cube/2D array entries.
Returns
The created GPU texture, or nullptr on failure.
Here is the caller graph for this function:

◆ createGraphicsDepthPipeline()

SDL_GPUGraphicsPipeline * Boilerplate::createGraphicsDepthPipeline ( SDL_GPUDevice * device,
PipelineDescription pipelineDesc )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createGraphicsPipeline() [1/2]

SDL_GPUGraphicsPipeline * Boilerplate::createGraphicsPipeline ( SDL_GPUDevice * device,
const std::vector< SDL_GPUTextureFormat > & colorFormats,
SDL_GPUShaderFormat shaderFormat,
const ShaderInfo & vertexShaderInfo,
const ShaderInfo & fragmentShaderInfo,
const VertexInputLayout & vertexInputLayout,
bool enableDepth,
bool overBlending )

Create a graphics pipeline with multiple color render targets.

Here is the call graph for this function:

◆ createGraphicsPipeline() [2/2]

SDL_GPUGraphicsPipeline * Boilerplate::createGraphicsPipeline ( SDL_GPUDevice * device,
SDL_GPUTextureFormat & colorFormat,
SDL_GPUShaderFormat shaderFormat,
const ShaderInfo & vertexShaderInfo,
const ShaderInfo & fragmentShaderInfo,
const VertexInputLayout & vertexInputLayout,
bool enableDepth = true,
bool overBlending = false )

Create a full graphics pipeline from vertex/fragment shaders and vertex layout.

Parameters
deviceThe GPU device.
colorFormat
shaderFormatThe shader binary format.
vertexShaderInfoVertex shader descriptor.
fragmentShaderInfoFragment shader descriptor.
vertexInputLayoutVertex buffer layout description.
enableDepthEnable depth testing and writing (default true).
overBlending
Returns
The created pipeline, or nullptr on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createImGuiInfo()

ImGui_ImplSDLGPU3_InitInfo Boilerplate::createImGuiInfo ( SDL_GPUDevice * device,
SDL_Window * window )

Create an ImGui initialization info struct for SDL3 GPU rendering.

Parameters
deviceThe GPU device.
windowThe SDL window.
Returns
Populated ImGui_ImplSDLGPU3_InitInfo.
Here is the caller graph for this function:

◆ createLinearClampSampler()

SDL_GPUSampler * Boilerplate::createLinearClampSampler ( SDL_GPUDevice * device)

Create a linear-filtering, clamp-to-edge sampler.

Parameters
deviceThe GPU device.
Returns
The created GPU sampler.
Here is the caller graph for this function:

◆ createLinearComparisonSampler()

SDL_GPUSampler * Boilerplate::createLinearComparisonSampler ( SDL_GPUDevice * device,
SDL_GPUFilter filterMode,
bool reverseZ )

Create a linear-filtering, comparison sampler (for shadow map depth comparison).

Parameters
deviceThe GPU device.
Returns
The created GPU sampler.
Here is the caller graph for this function:

◆ createLinearRepeatSampler()

SDL_GPUSampler * Boilerplate::createLinearRepeatSampler ( SDL_GPUDevice * device,
bool nearest )

Create a linear-filtering, repeat-addressing sampler.

Parameters
deviceThe GPU device.
Returns
The created GPU sampler.
Here is the caller graph for this function:

◆ createSampledColorTarget()

SDL_GPUTexture * Boilerplate::createSampledColorTarget ( SDL_GPUDevice * device,
Uint32 width,
Uint32 height,
SDL_GPUTextureFormat format )

Create a sampleable 2D color render target of the given dimensions.

Here is the caller graph for this function:

◆ createTextureRGBA32()

SDL_GPUTexture * Boilerplate::createTextureRGBA32 ( SDL_GPUDevice * device,
Uint32 width,
Uint32 height,
const void * data,
SDL_GPUTextureFormat format )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createTextureRGBA8()

SDL_GPUTexture * Boilerplate::createTextureRGBA8 ( SDL_GPUDevice * device,
Uint32 width,
Uint32 height,
const void * data,
SDL_GPUTextureFormat format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM )

Create a 2D RGBA8 texture and upload pixel data to it.

Parameters
deviceThe GPU device.
widthTexture width in pixels.
heightTexture height in pixels.
dataPointer to RGBA8 pixel data.
formatGPU texture format, usually RGBA8 UNORM or sRGB.
Returns
The created GPU texture, or nullptr on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createTransferBuffer()

SDL_GPUTransferBuffer * Boilerplate::createTransferBuffer ( SDL_GPUDevice * device,
size_t transferBufferSize,
bool upload )

Allocate a GPU transfer buffer for upload or download.

Parameters
deviceThe GPU device.
transferBufferSizeSize in bytes.
uploadTrue for upload, false for download.
Returns
The created transfer buffer.
Here is the caller graph for this function:

◆ createUploadBuffer()

SDL_GPUTransferBuffer * Boilerplate::createUploadBuffer ( SDL_GPUDevice * device,
size_t transferBufferSize )

Allocate a GPU transfer buffer for uploading data.

Parameters
deviceThe GPU device.
transferBufferSizeSize in bytes.
Returns
The created upload transfer buffer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadShader() [1/2]

SDL_GPUShader * Boilerplate::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).

Parameters
deviceThe GPU device.
pathBase path to the shader file (extension added automatically).
formatThe shader binary format.
stageVertex or fragment stage.
samplerCountNumber of samplers used by the shader.
uniformBufferCountNumber of uniform buffers used.
storageBufferCountNumber of storage buffers used.
storageTextureCountNumber of storage textures used.
Returns
The compiled GPU shader, or nullptr on failure.
Here is the caller graph for this function:

◆ loadShader() [2/2]

SDL_GPUShader * Boilerplate::loadShader ( SDL_GPUDevice * device,
const ShaderInfo & shaderInfo,
SDL_GPUShaderFormat format )

Load and compile a shader from a ShaderInfo descriptor.

Parameters
deviceThe GPU device.
shaderInfoShader descriptor with path, stage, and resource counts.
formatThe shader binary format.
Returns
The compiled GPU shader, or nullptr on failure.
Here is the call graph for this function:

◆ loadTexture()

SDL_GPUTexture * Boilerplate::loadTexture ( SDL_GPUDevice * device,
const char * path )

Load an image file from disk and create a GPU texture from it.

Parameters
deviceThe GPU device.
pathPath to the image file.
Returns
The created GPU texture, or nullptr on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeAttribute()

SDL_GPUVertexAttribute Boilerplate::makeAttribute ( Uint32 location,
SDL_GPUVertexElementFormat format,
Uint32 offset,
Uint32 bufferSlot = 0 )

Build an SDL_GPUVertexAttribute descriptor.

Parameters
locationShader attribute location index.
formatElement format (e.g. FLOAT3).
offsetByte offset within the vertex.
bufferSlotVertex buffer slot (default 0).
Returns
The populated vertex attribute.
Here is the caller graph for this function:

◆ makeColorTargetClear()

SDL_GPUColorTargetInfo Boilerplate::makeColorTargetClear ( SDL_GPUTexture * texture,
SDL_FColor clearColor )

Create a color render-target info with a clear color.

Parameters
textureThe target texture.
clearColorThe RGBA clear color.
Returns
Populated SDL_GPUColorTargetInfo.
Here is the caller graph for this function:

◆ makeColorTargetLoad()

SDL_GPUColorTargetInfo Boilerplate::makeColorTargetLoad ( SDL_GPUTexture * texture)

Create a color render-target info with a clear color.

Parameters
textureThe target texture.
Returns
Populated SDL_GPUColorTargetInfo.
Here is the caller graph for this function:

◆ makeDepthTarget()

SDL_GPUDepthStencilTargetInfo Boilerplate::makeDepthTarget ( SDL_GPUTexture * texture,
Uint8 layer,
bool store,
bool reverseZ )

Create a depth/stencil render-target info that clears to depth 1.0.

Parameters
textureThe depth texture.
Returns
Populated SDL_GPUDepthStencilTargetInfo.
Here is the caller graph for this function:

◆ makeTextureSamplerBinding()

SDL_GPUTextureSamplerBinding Boilerplate::makeTextureSamplerBinding ( SDL_GPUTexture * texture,
SDL_GPUSampler * sampler )

Create a texture-sampler binding pair for fragment shader use.

Parameters
textureThe GPU texture.
samplerThe GPU sampler.
Returns
Populated SDL_GPUTextureSamplerBinding.
Here is the caller graph for this function:

◆ selectShaderFormat()

SDL_GPUShaderFormat Boilerplate::selectShaderFormat ( SDL_GPUDevice * device)

Pick the best available shader format for the given device.

Parameters
deviceThe GPU device.
Returns
The selected SDL_GPUShaderFormat, or INVALID if none found.
Here is the caller graph for this function:

◆ uploadBuffers()

void Boilerplate::uploadBuffers ( SDL_GPUDevice * device,
SDL_GPUCommandBuffer * cmd,
const std::vector< BufferUpload > & uploads )

Batch-upload multiple CPU buffers to their corresponding GPU buffers.

Parameters
deviceThe GPU device.
cmdThe command buffer to record copy commands into.
uploadsVector of BufferUpload descriptors.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ OVER_BLEND_MODE

SDL_GPUColorTargetBlendState Boilerplate::OVER_BLEND_MODE
constexpr
Initial value:
= {
.src_color_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA,
.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
.color_blend_op = SDL_GPU_BLENDOP_ADD,
.src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE,
.dst_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
.alpha_blend_op = SDL_GPU_BLENDOP_ADD,
.enable_blend = true,
}