Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index d763dc3..f00361d 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -32,6 +32,7 @@
- Fix race condition between swapchain image destruction and presentation completion callback.
- Set Metal texture usage to allow texture copy via view.
- Fix memory leak in debug marker and debug utils labelling.
+- Fix issue with push constants used across multiple draw calls not being applied.
- Reduce use of autoreleased Obj-C objects, and ensure those remaining are
covered by deliberate autorelease pools.
- `vkCmdCopyImage()` support copying between compressed and uncompressed formats
diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm b/MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm
index b8e106b..18fe127 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm
@@ -197,7 +197,7 @@
_offset = offset;
_pushConstants.resize(size);
- std::copy_n((char*)pValues, size, _pushConstants.begin());
+ std::copy_n((char*)pValues, size, _pushConstants.begin());
}
void MVKCmdPushConstants::encode(MVKCommandEncoder* cmdEncoder) {
diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm b/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm
index 35d6a02..641832e 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm
@@ -170,9 +170,14 @@
}
}
+// At this point, I have been marked not-dirty, under the assumption that I will make changes to the encoder.
+// However, some of the paths below decide not to actually make any changes to the encoder. In that case,
+// I should remain dirty until I actually do make encoder changes.
void MVKPushConstantsCommandEncoderState::encodeImpl(uint32_t stage) {
if (_pushConstants.empty() ) { return; }
+ _isDirty = true; // Stay dirty until I actually decide to make a change to the encoder
+
switch (_shaderStage) {
case VK_SHADER_STAGE_VERTEX_BIT:
if (stage == (isTessellating() ? kMVKGraphicsStageVertex : kMVKGraphicsStageRasterization)) {
@@ -180,6 +185,7 @@
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
+ _isDirty = false; // Okay, I changed the encoder
}
break;
case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
@@ -188,6 +194,7 @@
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
+ _isDirty = false; // Okay, I changed the encoder
}
break;
case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
@@ -196,6 +203,7 @@
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
+ _isDirty = false; // Okay, I changed the encoder
}
break;
case VK_SHADER_STAGE_FRAGMENT_BIT:
@@ -204,6 +212,7 @@
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
+ _isDirty = false; // Okay, I changed the encoder
}
break;
case VK_SHADER_STAGE_COMPUTE_BIT:
@@ -211,6 +220,7 @@
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
+ _isDirty = false; // Okay, I changed the encoder
break;
default:
MVKAssert(false, "Unsupported shader stage: %d", _shaderStage);