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
(cherry picked from commit 4c69fd050c)
This commit is contained in:
committed by
Sam Lantinga
parent
105ad5e875
commit
bcbdcaf6e4
@@ -2411,7 +2411,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;
|
||||
@@ -2438,6 +2437,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;
|
||||
@@ -2456,17 +2463,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3182,6 +3178,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