Skip to content

Commit

Permalink
Add ShaderModule and Sampler name properties
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcosmonaut committed Jan 13, 2025
1 parent d31f497 commit 372aa3a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/SDL3/SDL_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,8 @@ extern SDL_DECLSPEC SDL_GPUSampler *SDLCALL SDL_CreateGPUSampler(
SDL_GPUDevice *device,
const SDL_GPUSamplerCreateInfo *createinfo);

#define SDL_PROP_GPU_CREATESAMPLER_NAME_STRING "SDL.gpu.createsampler.name"

/**
* Creates a shader to be used when creating a graphics pipeline.
*
Expand Down Expand Up @@ -2375,6 +2377,8 @@ extern SDL_DECLSPEC SDL_GPUShader *SDLCALL SDL_CreateGPUShader(
SDL_GPUDevice *device,
const SDL_GPUShaderCreateInfo *createinfo);

#define SDL_PROP_GPU_CREATESHADER_NAME_STRING "SDL.gpu.createshader.name"

/**
* Creates a texture object to be used in graphics or compute workflows.
*
Expand Down
5 changes: 5 additions & 0 deletions src/gpu/d3d12/SDL_gpu_d3d12.c
Original file line number Diff line number Diff line change
Expand Up @@ -3206,6 +3206,9 @@ static SDL_GPUSampler *D3D12_CreateSampler(

sampler->createInfo = *createinfo;
SDL_SetAtomicInt(&sampler->referenceCount, 0);

// Ignore name property because it is not applicable to D3D12.

return (SDL_GPUSampler *)sampler;
}

Expand Down Expand Up @@ -3243,6 +3246,8 @@ static SDL_GPUShader *D3D12_CreateShader(
shader->bytecode = bytecode;
shader->bytecodeSize = bytecodeSize;

// Ignore name property because it is not applicable to D3D12.

return (SDL_GPUShader *)shader;
}

Expand Down
26 changes: 26 additions & 0 deletions src/gpu/vulkan/SDL_gpu_vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -6657,6 +6657,19 @@ static SDL_GPUSampler *VULKAN_CreateSampler(

SDL_SetAtomicInt(&vulkanSampler->referenceCount, 0);

if (renderer->debugMode && renderer->supportsDebugUtils && SDL_HasProperty(createinfo->props, SDL_PROP_GPU_CREATESAMPLER_NAME_STRING)) {
VkDebugUtilsObjectNameInfoEXT nameInfo;
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
nameInfo.pNext = NULL;
nameInfo.pObjectName = SDL_GetStringProperty(createinfo->props, SDL_PROP_GPU_CREATESAMPLER_NAME_STRING, NULL);
nameInfo.objectType = VK_OBJECT_TYPE_SAMPLER;
nameInfo.objectHandle = (uint64_t)vulkanSampler->sampler;

renderer->vkSetDebugUtilsObjectNameEXT(
renderer->logicalDevice,
&nameInfo);
}

return (SDL_GPUSampler *)vulkanSampler;
}

Expand Down Expand Up @@ -6700,6 +6713,19 @@ static SDL_GPUShader *VULKAN_CreateShader(

SDL_SetAtomicInt(&vulkanShader->referenceCount, 0);

if (renderer->debugMode && SDL_HasProperty(createinfo->props, SDL_PROP_GPU_CREATESHADER_NAME_STRING)) {
VkDebugUtilsObjectNameInfoEXT nameInfo;
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
nameInfo.pNext = NULL;
nameInfo.pObjectName = SDL_GetStringProperty(createinfo->props, SDL_PROP_GPU_CREATESHADER_NAME_STRING, NULL);
nameInfo.objectType = VK_OBJECT_TYPE_SHADER_MODULE;
nameInfo.objectHandle = (uint64_t)vulkanShader->shaderModule;

renderer->vkSetDebugUtilsObjectNameEXT(
renderer->logicalDevice,
&nameInfo);
}

return (SDL_GPUShader *)vulkanShader;
}

Expand Down

0 comments on commit 372aa3a

Please sign in to comment.