diff --git a/drivers/metal/metal_objects.mm b/drivers/metal/metal_objects.mm index b44c496e4f6f..04900a0e5162 100644 --- a/drivers/metal/metal_objects.mm +++ b/drivers/metal/metal_objects.mm @@ -56,6 +56,10 @@ #import +// 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; @@ -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); } @@ -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];