diff --git a/drivers/metal/metal_objects.h b/drivers/metal/metal_objects.h index 3a1bb14b3b7..1e81a5def96 100644 --- a/drivers/metal/metal_objects.h +++ b/drivers/metal/metal_objects.h @@ -800,7 +800,7 @@ public: void bind_uniforms(MDShader *p_shader, MDCommandBuffer::RenderState &p_state, uint32_t p_set_index); void bind_uniforms(MDShader *p_shader, MDCommandBuffer::ComputeState &p_state, uint32_t p_set_index); - BoundUniformSet &bound_uniform_set(MDShader *p_shader, id p_device, ResourceUsageMap &p_resource_usage); + BoundUniformSet &bound_uniform_set(MDShader *p_shader, id p_device, ResourceUsageMap &p_resource_usage, uint32_t p_set_index); }; class API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) MDPipeline { diff --git a/drivers/metal/metal_objects.mm b/drivers/metal/metal_objects.mm index 4482837c439..d9661f4860b 100644 --- a/drivers/metal/metal_objects.mm +++ b/drivers/metal/metal_objects.mm @@ -1063,7 +1063,7 @@ void MDUniformSet::bind_uniforms_argument_buffers(MDShader *p_shader, MDCommandB id __unsafe_unretained enc = p_state.encoder; id __unsafe_unretained device = enc.device; - BoundUniformSet &bus = bound_uniform_set(p_shader, device, p_state.resource_usage); + BoundUniformSet &bus = bound_uniform_set(p_shader, device, p_state.resource_usage, p_set_index); // Set the buffer for the vertex stage. { @@ -1275,7 +1275,7 @@ void MDUniformSet::bind_uniforms_argument_buffers(MDShader *p_shader, MDCommandB id enc = p_state.encoder; id device = enc.device; - BoundUniformSet &bus = bound_uniform_set(p_shader, device, p_state.resource_usage); + BoundUniformSet &bus = bound_uniform_set(p_shader, device, p_state.resource_usage, p_set_index); uint32_t const *offset = set_info.offsets.getptr(RDD::SHADER_STAGE_COMPUTE); if (offset) { @@ -1417,14 +1417,14 @@ void MDUniformSet::bind_uniforms(MDShader *p_shader, MDCommandBuffer::ComputeSta } } -BoundUniformSet &MDUniformSet::bound_uniform_set(MDShader *p_shader, id p_device, ResourceUsageMap &p_resource_usage) { +BoundUniformSet &MDUniformSet::bound_uniform_set(MDShader *p_shader, id p_device, ResourceUsageMap &p_resource_usage, uint32_t p_set_index) { BoundUniformSet *sus = bound_uniforms.getptr(p_shader); if (sus != nullptr) { sus->merge_into(p_resource_usage); return *sus; } - UniformSet const &set = p_shader->sets[index]; + UniformSet const &set = p_shader->sets[p_set_index]; HashMap, StageResourceUsage> bound_resources; auto add_usage = [&bound_resources](id __unsafe_unretained res, RDD::ShaderStage stage, MTLResourceUsage usage) {