Skip to content

Commit a0dc3a6

Browse files
lmurrayflibitijibibo
authored andcommitted
GPU: Fix memory leak when creating D3D12 compute pipelines
1 parent 742a6fd commit a0dc3a6

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/gpu/d3d12/SDL_gpu_d3d12.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,17 +2953,15 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
29532953
const SDL_GPUComputePipelineCreateInfo *createinfo)
29542954
{
29552955
D3D12Renderer *renderer = (D3D12Renderer *)driverData;
2956-
void *bytecode;
2957-
size_t bytecodeSize;
29582956
ID3D12PipelineState *pipelineState;
29592957

29602958
if (!D3D12_INTERNAL_CreateShaderBytecode(
29612959
renderer,
29622960
createinfo->code,
29632961
createinfo->code_size,
29642962
createinfo->format,
2965-
&bytecode,
2966-
&bytecodeSize)) {
2963+
NULL,
2964+
NULL)) {
29672965
return NULL;
29682966
}
29692967

@@ -2972,13 +2970,12 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
29722970
createinfo);
29732971

29742972
if (rootSignature == NULL) {
2975-
SDL_free(bytecode);
29762973
SET_STRING_ERROR_AND_RETURN("Could not create root signature!", NULL);
29772974
}
29782975

29792976
D3D12_COMPUTE_PIPELINE_STATE_DESC pipelineDesc;
2980-
pipelineDesc.CS.pShaderBytecode = bytecode;
2981-
pipelineDesc.CS.BytecodeLength = bytecodeSize;
2977+
pipelineDesc.CS.pShaderBytecode = createinfo->code;
2978+
pipelineDesc.CS.BytecodeLength = createinfo->code_size;
29822979
pipelineDesc.pRootSignature = rootSignature->handle;
29832980
pipelineDesc.CachedPSO.CachedBlobSizeInBytes = 0;
29842981
pipelineDesc.CachedPSO.pCachedBlob = NULL;
@@ -2993,7 +2990,6 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
29932990

29942991
if (FAILED(res)) {
29952992
D3D12_INTERNAL_SetError(renderer, "Could not create compute pipeline state", res);
2996-
SDL_free(bytecode);
29972993
return NULL;
29982994
}
29992995

@@ -3002,7 +2998,6 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
30022998

30032999
if (!computePipeline) {
30043000
ID3D12PipelineState_Release(pipelineState);
3005-
SDL_free(bytecode);
30063001
return NULL;
30073002
}
30083003

0 commit comments

Comments
 (0)