GPU: Fix D3D11/D3D12 vertex strides for multiple vertex buffers (#10818)

This commit is contained in:
Caleb Cornett 2024-09-13 09:57:55 -05:00 committed by GitHub
parent 371cfaf8fe
commit 5771b502f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 12 deletions

View File

@ -509,7 +509,7 @@ typedef struct D3D11GraphicsPipeline
ID3D11PixelShader *fragmentShader; ID3D11PixelShader *fragmentShader;
ID3D11InputLayout *inputLayout; ID3D11InputLayout *inputLayout;
Uint32 *vertexStrides; Uint32 vertexStrides[MAX_VERTEX_BUFFERS];
Uint32 vertexSamplerCount; Uint32 vertexSamplerCount;
Uint32 vertexUniformBufferCount; Uint32 vertexUniformBufferCount;
@ -1258,9 +1258,6 @@ static void D3D11_ReleaseGraphicsPipeline(
if (d3d11GraphicsPipeline->inputLayout) { if (d3d11GraphicsPipeline->inputLayout) {
ID3D11InputLayout_Release(d3d11GraphicsPipeline->inputLayout); ID3D11InputLayout_Release(d3d11GraphicsPipeline->inputLayout);
} }
if (d3d11GraphicsPipeline->vertexStrides) {
SDL_free(d3d11GraphicsPipeline->vertexStrides);
}
ID3D11VertexShader_Release(d3d11GraphicsPipeline->vertexShader); ID3D11VertexShader_Release(d3d11GraphicsPipeline->vertexShader);
ID3D11PixelShader_Release(d3d11GraphicsPipeline->fragmentShader); ID3D11PixelShader_Release(d3d11GraphicsPipeline->fragmentShader);
@ -1611,16 +1608,12 @@ static SDL_GPUGraphicsPipeline *D3D11_CreateGraphicsPipeline(
vertShader->bytecode, vertShader->bytecode,
vertShader->bytecodeSize); vertShader->bytecodeSize);
SDL_zeroa(pipeline->vertexStrides);
if (createinfo->vertex_input_state.num_vertex_buffers > 0) { if (createinfo->vertex_input_state.num_vertex_buffers > 0) {
pipeline->vertexStrides = SDL_malloc(
sizeof(Uint32) *
createinfo->vertex_input_state.num_vertex_buffers);
for (Uint32 i = 0; i < createinfo->vertex_input_state.num_vertex_buffers; i += 1) { for (Uint32 i = 0; i < createinfo->vertex_input_state.num_vertex_buffers; i += 1) {
pipeline->vertexStrides[i] = createinfo->vertex_input_state.vertex_buffer_descriptions[i].pitch; pipeline->vertexStrides[createinfo->vertex_input_state.vertex_buffer_descriptions[i].slot] =
createinfo->vertex_input_state.vertex_buffer_descriptions[i].pitch;
} }
} else {
pipeline->vertexStrides = NULL;
} }
// Resource layout // Resource layout

View File

@ -2663,7 +2663,8 @@ static SDL_GPUGraphicsPipeline *D3D12_CreateGraphicsPipeline(
pipeline->pipelineState = pipelineState; pipeline->pipelineState = pipelineState;
for (Uint32 i = 0; i < createinfo->vertex_input_state.num_vertex_buffers; i += 1) { for (Uint32 i = 0; i < createinfo->vertex_input_state.num_vertex_buffers; i += 1) {
pipeline->vertexStrides[i] = createinfo->vertex_input_state.vertex_buffer_descriptions[i].pitch; pipeline->vertexStrides[createinfo->vertex_input_state.vertex_buffer_descriptions[i].slot] =
createinfo->vertex_input_state.vertex_buffer_descriptions[i].pitch;
} }
pipeline->primitiveType = createinfo->primitive_type; pipeline->primitiveType = createinfo->primitive_type;