Skip to content

Commit cc5f833

Browse files
committed
fix some shader init errors
1 parent 9a66d6f commit cc5f833

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/FNA3D_Driver_SDL.c

+11-5
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ MOJOSHADER_sdlProgram *MOJOSHADER_sdlLinkProgram(
428428
return NULL;
429429
}
430430

431-
createInfo.code = v_transpiled_source;
431+
createInfo.code = (uint8_t*) v_transpiled_source;
432432
createInfo.codeSize = v_transpiled_len;
433433
createInfo.type = SDL_GPU_SHADERTYPE_VERTEX;
434434

@@ -437,24 +437,30 @@ MOJOSHADER_sdlProgram *MOJOSHADER_sdlLinkProgram(
437437
&createInfo
438438
);
439439

440-
ctx->free_fn((char*) v_transpiled_source, ctx->malloc_data);
440+
if (v_transpiled_source != v_shader_source)
441+
{
442+
ctx->free_fn((char*) v_transpiled_source, ctx->malloc_data);
443+
}
441444

442445
if (result->vertexModule == NULL)
443446
{
444447
ctx->free_fn(result, ctx->malloc_data);
445448
return NULL;
446449
}
447450

448-
createInfo.code = p_transpiled_source;
451+
createInfo.code = (uint8_t*) p_transpiled_source;
449452
createInfo.codeSize = p_transpiled_len;
450-
createInfo.codeSize = SDL_GPU_SHADERTYPE_FRAGMENT;
453+
createInfo.type = SDL_GPU_SHADERTYPE_FRAGMENT;
451454

452455
result->pixelModule = SDL_GpuCreateShaderModule(
453456
ctx->device,
454457
&createInfo
455458
);
456459

457-
ctx->free_fn((char*) p_transpiled_source, ctx->malloc_data);
460+
if (p_transpiled_source != p_shader_source)
461+
{
462+
ctx->free_fn((char*) p_transpiled_source, ctx->malloc_data);
463+
}
458464

459465
if (result->pixelModule == NULL)
460466
{

0 commit comments

Comments
 (0)