Skip to content

Commit dcb97a5

Browse files
committed
Set a default shader entry point
The default should be the entrypoint generated by SDL_shadercross. That way it doesn't need to be hand-specified in the common workflow.
1 parent 1a2fccc commit dcb97a5

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

src/gpu/d3d12/SDL_gpu_d3d12.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8056,7 +8056,6 @@ static void D3D12_INTERNAL_InitBlitResources(
80568056
shaderCreateInfo.code_size = sizeof(D3D12_FullscreenVert);
80578057
shaderCreateInfo.stage = SDL_GPU_SHADERSTAGE_VERTEX;
80588058
shaderCreateInfo.format = SDL_GPU_SHADERFORMAT_DXBC;
8059-
shaderCreateInfo.entrypoint = "main";
80608059

80618060
renderer->blitVertexShader = D3D12_CreateShader(
80628061
(SDL_GPURenderer *)renderer,

src/gpu/metal/SDL_gpu_metal.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,10 @@ static MetalLibraryFunction METAL_INTERNAL_CompileShader(
840840
dispatch_data_t data;
841841
id<MTLFunction> function;
842842

843+
if (!entrypoint) {
844+
entrypoint = "main0";
845+
}
846+
843847
if (format == SDL_GPU_SHADERFORMAT_MSL) {
844848
NSString *codeString = [[NSString alloc]
845849
initWithBytes:code

src/gpu/vulkan/SDL_gpu_vulkan.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ typedef struct VulkanSampler
577577
typedef struct VulkanShader
578578
{
579579
VkShaderModule shaderModule;
580-
const char *entrypointName;
580+
char *entrypointName;
581581
SDL_GPUShaderStage stage;
582582
Uint32 numSamplers;
583583
Uint32 numStorageTextures;
@@ -3115,7 +3115,7 @@ static void VULKAN_INTERNAL_DestroyShader(
31153115
vulkanShader->shaderModule,
31163116
NULL);
31173117

3118-
SDL_free((void *)vulkanShader->entrypointName);
3118+
SDL_free(vulkanShader->entrypointName);
31193119
SDL_free(vulkanShader);
31203120
}
31213121

@@ -6620,7 +6620,6 @@ static SDL_GPUShader *VULKAN_CreateShader(
66206620
VkResult vulkanResult;
66216621
VkShaderModuleCreateInfo vkShaderModuleCreateInfo;
66226622
VulkanRenderer *renderer = (VulkanRenderer *)driverData;
6623-
size_t entryPointNameLength;
66246623

66256624
vulkanShader = SDL_malloc(sizeof(VulkanShader));
66266625
vkShaderModuleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
@@ -6640,10 +6639,11 @@ static SDL_GPUShader *VULKAN_CreateShader(
66406639
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateShaderModule, NULL);
66416640
}
66426641

6643-
entryPointNameLength = SDL_strlen(createinfo->entrypoint) + 1;
6644-
vulkanShader->entrypointName = SDL_malloc(entryPointNameLength);
6645-
SDL_utf8strlcpy((char *)vulkanShader->entrypointName, createinfo->entrypoint, entryPointNameLength);
6646-
6642+
const char *entrypoint = createinfo->entrypoint;
6643+
if (!entrypoint) {
6644+
entrypoint = "main";
6645+
}
6646+
vulkanShader->entrypointName = SDL_strdup(entrypoint);
66476647
vulkanShader->stage = createinfo->stage;
66486648
vulkanShader->numSamplers = createinfo->num_samplers;
66496649
vulkanShader->numStorageTextures = createinfo->num_storage_textures;

test/testgpurender_effects.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,14 @@ static bool InitGPURenderState(void)
172172
info.format = SDL_GPU_SHADERFORMAT_SPIRV;
173173
info.code = data->spirv_shader_source;
174174
info.code_size = data->spirv_shader_source_len;
175-
info.entrypoint = "main";
176175
} else if (formats & SDL_GPU_SHADERFORMAT_DXIL) {
177176
info.format = SDL_GPU_SHADERFORMAT_DXIL;
178177
info.code = data->dxil_shader_source;
179178
info.code_size = data->dxil_shader_source_len;
180-
info.entrypoint = "main";
181179
} else if (formats & SDL_GPU_SHADERFORMAT_MSL) {
182180
info.format = SDL_GPU_SHADERFORMAT_MSL;
183181
info.code = data->msl_shader_source;
184182
info.code_size = data->msl_shader_source_len;
185-
info.entrypoint = "main0";
186183
} else {
187184
SDL_Log("No supported shader format found");
188185
return false;

test/testgpurender_msdf.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,14 @@ static bool InitGPURenderState(void)
184184
info.format = SDL_GPU_SHADERFORMAT_SPIRV;
185185
info.code = testgpurender_msdf_frag_spv;
186186
info.code_size = testgpurender_msdf_frag_spv_len;
187-
info.entrypoint = "main";
188187
} else if (formats & SDL_GPU_SHADERFORMAT_DXIL) {
189188
info.format = SDL_GPU_SHADERFORMAT_DXIL;
190189
info.code = testgpurender_msdf_frag_dxil;
191190
info.code_size = testgpurender_msdf_frag_dxil_len;
192-
info.entrypoint = "main";
193191
} else if (formats & SDL_GPU_SHADERFORMAT_MSL) {
194192
info.format = SDL_GPU_SHADERFORMAT_MSL;
195193
info.code = testgpurender_msdf_frag_msl;
196194
info.code_size = testgpurender_msdf_frag_msl_len;
197-
info.entrypoint = "main0";
198195
} else {
199196
SDL_Log("No supported shader format found");
200197
return false;

0 commit comments

Comments
 (0)