Skip to content

Commit

Permalink
Metal: Fix crash when uniform set is empty for classic binding mode
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo Locurcio <[email protected]>
  • Loading branch information
stuartcarnie and Calinou committed Dec 23, 2024
1 parent 0f95e9f commit 5568f79
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/metal/metal_objects.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@

#import <os/signpost.h>

// We have to undefine these macros because they are defined in NSObjCRuntime.h.
#undef MIN
#undef MAX

void MDCommandBuffer::begin() {
DEV_ASSERT(commandBuffer == nil);
commandBuffer = queue.commandBufferWithUnretainedReferences;
Expand Down Expand Up @@ -764,6 +768,7 @@
[render.encoder setVertexBuffers:render.vertex_buffers.ptr()
offsets:render.vertex_offsets.ptr()
withRange:NSMakeRange(first, p_binding_count)];
render.dirty.clear_flag(RenderState::DIRTY_VERTEX);
} else {
render.dirty.set_flag(RenderState::DIRTY_VERTEX);
}
Expand Down Expand Up @@ -1082,7 +1087,7 @@

UniformSet const &set = p_shader->sets[index];

for (uint32_t i = 0; i < uniforms.size(); i++) {
for (uint32_t i = 0; i < MIN(uniforms.size(), set.uniforms.size()); i++) {
RDD::BoundUniform const &uniform = uniforms[i];
UniformInfo ui = set.uniforms[i];

Expand Down

0 comments on commit 5568f79

Please sign in to comment.