GPU: Fix memory leak when creating D3D12 compute pipelines
This commit is contained in:
@@ -2953,8 +2953,6 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
|
|||||||
const SDL_GPUComputePipelineCreateInfo *createinfo)
|
const SDL_GPUComputePipelineCreateInfo *createinfo)
|
||||||
{
|
{
|
||||||
D3D12Renderer *renderer = (D3D12Renderer *)driverData;
|
D3D12Renderer *renderer = (D3D12Renderer *)driverData;
|
||||||
void *bytecode;
|
|
||||||
size_t bytecodeSize;
|
|
||||||
ID3D12PipelineState *pipelineState;
|
ID3D12PipelineState *pipelineState;
|
||||||
|
|
||||||
if (!D3D12_INTERNAL_CreateShaderBytecode(
|
if (!D3D12_INTERNAL_CreateShaderBytecode(
|
||||||
@@ -2962,8 +2960,8 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
|
|||||||
createinfo->code,
|
createinfo->code,
|
||||||
createinfo->code_size,
|
createinfo->code_size,
|
||||||
createinfo->format,
|
createinfo->format,
|
||||||
&bytecode,
|
NULL,
|
||||||
&bytecodeSize)) {
|
NULL)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2972,13 +2970,12 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
|
|||||||
createinfo);
|
createinfo);
|
||||||
|
|
||||||
if (rootSignature == NULL) {
|
if (rootSignature == NULL) {
|
||||||
SDL_free(bytecode);
|
|
||||||
SET_STRING_ERROR_AND_RETURN("Could not create root signature!", NULL);
|
SET_STRING_ERROR_AND_RETURN("Could not create root signature!", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_COMPUTE_PIPELINE_STATE_DESC pipelineDesc;
|
D3D12_COMPUTE_PIPELINE_STATE_DESC pipelineDesc;
|
||||||
pipelineDesc.CS.pShaderBytecode = bytecode;
|
pipelineDesc.CS.pShaderBytecode = createinfo->code;
|
||||||
pipelineDesc.CS.BytecodeLength = bytecodeSize;
|
pipelineDesc.CS.BytecodeLength = createinfo->code_size;
|
||||||
pipelineDesc.pRootSignature = rootSignature->handle;
|
pipelineDesc.pRootSignature = rootSignature->handle;
|
||||||
pipelineDesc.CachedPSO.CachedBlobSizeInBytes = 0;
|
pipelineDesc.CachedPSO.CachedBlobSizeInBytes = 0;
|
||||||
pipelineDesc.CachedPSO.pCachedBlob = NULL;
|
pipelineDesc.CachedPSO.pCachedBlob = NULL;
|
||||||
@@ -2993,7 +2990,6 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
|
|||||||
|
|
||||||
if (FAILED(res)) {
|
if (FAILED(res)) {
|
||||||
D3D12_INTERNAL_SetError(renderer, "Could not create compute pipeline state", res);
|
D3D12_INTERNAL_SetError(renderer, "Could not create compute pipeline state", res);
|
||||||
SDL_free(bytecode);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3002,7 +2998,6 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
|
|||||||
|
|
||||||
if (!computePipeline) {
|
if (!computePipeline) {
|
||||||
ID3D12PipelineState_Release(pipelineState);
|
ID3D12PipelineState_Release(pipelineState);
|
||||||
SDL_free(bytecode);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user