Skip to content

Commit ec5e096

Browse files
committed
Merge pull request godotengine#103645 from stuartcarnie/fix_101696_pt_2
Metal: Use `p_set_index` when binding uniforms, to use correct data
2 parents 10b1bc5 + a4fb68f commit ec5e096

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

drivers/metal/metal_objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ class API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) MDUniformSet {
800800
void bind_uniforms(MDShader *p_shader, MDCommandBuffer::RenderState &p_state, uint32_t p_set_index);
801801
void bind_uniforms(MDShader *p_shader, MDCommandBuffer::ComputeState &p_state, uint32_t p_set_index);
802802

803-
BoundUniformSet &bound_uniform_set(MDShader *p_shader, id<MTLDevice> p_device, ResourceUsageMap &p_resource_usage);
803+
BoundUniformSet &bound_uniform_set(MDShader *p_shader, id<MTLDevice> p_device, ResourceUsageMap &p_resource_usage, uint32_t p_set_index);
804804
};
805805

806806
class API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) MDPipeline {

drivers/metal/metal_objects.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@
10631063
id<MTLRenderCommandEncoder> __unsafe_unretained enc = p_state.encoder;
10641064
id<MTLDevice> __unsafe_unretained device = enc.device;
10651065

1066-
BoundUniformSet &bus = bound_uniform_set(p_shader, device, p_state.resource_usage);
1066+
BoundUniformSet &bus = bound_uniform_set(p_shader, device, p_state.resource_usage, p_set_index);
10671067

10681068
// Set the buffer for the vertex stage.
10691069
{
@@ -1275,7 +1275,7 @@
12751275
id<MTLComputeCommandEncoder> enc = p_state.encoder;
12761276
id<MTLDevice> device = enc.device;
12771277

1278-
BoundUniformSet &bus = bound_uniform_set(p_shader, device, p_state.resource_usage);
1278+
BoundUniformSet &bus = bound_uniform_set(p_shader, device, p_state.resource_usage, p_set_index);
12791279

12801280
uint32_t const *offset = set_info.offsets.getptr(RDD::SHADER_STAGE_COMPUTE);
12811281
if (offset) {
@@ -1417,14 +1417,14 @@
14171417
}
14181418
}
14191419

1420-
BoundUniformSet &MDUniformSet::bound_uniform_set(MDShader *p_shader, id<MTLDevice> p_device, ResourceUsageMap &p_resource_usage) {
1420+
BoundUniformSet &MDUniformSet::bound_uniform_set(MDShader *p_shader, id<MTLDevice> p_device, ResourceUsageMap &p_resource_usage, uint32_t p_set_index) {
14211421
BoundUniformSet *sus = bound_uniforms.getptr(p_shader);
14221422
if (sus != nullptr) {
14231423
sus->merge_into(p_resource_usage);
14241424
return *sus;
14251425
}
14261426

1427-
UniformSet const &set = p_shader->sets[index];
1427+
UniformSet const &set = p_shader->sets[p_set_index];
14281428

14291429
HashMap<id<MTLResource>, StageResourceUsage> bound_resources;
14301430
auto add_usage = [&bound_resources](id<MTLResource> __unsafe_unretained res, RDD::ShaderStage stage, MTLResourceUsage usage) {

0 commit comments

Comments
 (0)