mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-07-31 04:28:56 +00:00
Metal: Fix for required rebinding when switching pipelines
This commit is contained in:
committed by
Caleb Cornett
parent
5924f36dc6
commit
4c69fd050c
@@ -2417,7 +2417,6 @@ static void METAL_BindGraphicsPipeline(
|
||||
{
|
||||
@autoreleasepool {
|
||||
MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer;
|
||||
MetalGraphicsPipeline *previousPipeline = metalCommandBuffer->graphics_pipeline;
|
||||
MetalGraphicsPipeline *pipeline = (MetalGraphicsPipeline *)graphicsPipeline;
|
||||
SDL_GPURasterizerState *rast = &pipeline->rasterizerState;
|
||||
Uint32 i;
|
||||
@@ -2444,6 +2443,14 @@ static void METAL_BindGraphicsPipeline(
|
||||
setDepthStencilState:pipeline->depth_stencil_state];
|
||||
}
|
||||
|
||||
// Mark that bindings are needed
|
||||
metalCommandBuffer->needVertexSamplerBind = true;
|
||||
metalCommandBuffer->needVertexStorageTextureBind = true;
|
||||
metalCommandBuffer->needVertexStorageBufferBind = true;
|
||||
metalCommandBuffer->needFragmentSamplerBind = true;
|
||||
metalCommandBuffer->needFragmentStorageTextureBind = true;
|
||||
metalCommandBuffer->needFragmentStorageBufferBind = true;
|
||||
|
||||
for (i = 0; i < MAX_UNIFORM_BUFFERS_PER_STAGE; i += 1) {
|
||||
metalCommandBuffer->needVertexUniformBufferBind[i] = true;
|
||||
metalCommandBuffer->needFragmentUniformBufferBind[i] = true;
|
||||
@@ -2462,17 +2469,6 @@ static void METAL_BindGraphicsPipeline(
|
||||
metalCommandBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (previousPipeline && previousPipeline != pipeline) {
|
||||
// if the number of uniform buffers has changed, the storage buffers will move as well
|
||||
// and need a rebind at their new locations
|
||||
if (previousPipeline->header.num_vertex_uniform_buffers != pipeline->header.num_vertex_uniform_buffers) {
|
||||
metalCommandBuffer->needVertexStorageBufferBind = true;
|
||||
}
|
||||
if (previousPipeline->header.num_fragment_uniform_buffers != pipeline->header.num_fragment_uniform_buffers) {
|
||||
metalCommandBuffer->needFragmentStorageBufferBind = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3188,6 +3184,10 @@ static void METAL_BindComputePipeline(
|
||||
}
|
||||
}
|
||||
|
||||
metalCommandBuffer->needComputeSamplerBind = true;
|
||||
metalCommandBuffer->needComputeReadOnlyStorageTextureBind = true;
|
||||
metalCommandBuffer->needComputeReadOnlyStorageBufferBind = true;
|
||||
|
||||
// Bind write-only resources
|
||||
if (pipeline->header.numReadWriteStorageTextures > 0) {
|
||||
[metalCommandBuffer->computeEncoder setTextures:metalCommandBuffer->computeReadWriteTextures
|
||||
|
||||
Reference in New Issue
Block a user