Fix issue with push constants used across multiple draw calls not being applied.

Ensure MVKPushConstantsCommandEncoderState stays dirty until it actually makes changes.
This commit is contained in:
Bill Hollings 2019-07-19 13:32:50 -04:00
parent 948cd1a2c4
commit a1fb3b106e
3 changed files with 12 additions and 1 deletions

View File

@ -32,6 +32,7 @@ Released TBD
- 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

View File

@ -197,7 +197,7 @@ void MVKCmdPushConstants::setContent(VkPipelineLayout layout,
_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) {

View File

@ -170,9 +170,14 @@ void MVKPushConstantsCommandEncoderState::setMTLBufferIndex(uint32_t mtlBufferIn
}
}
// 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 @@ void MVKPushConstantsCommandEncoderState::encodeImpl(uint32_t stage) {
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
_isDirty = false; // Okay, I changed the encoder
}
break;
case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
@ -188,6 +194,7 @@ void MVKPushConstantsCommandEncoderState::encodeImpl(uint32_t stage) {
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
_isDirty = false; // Okay, I changed the encoder
}
break;
case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
@ -196,6 +203,7 @@ void MVKPushConstantsCommandEncoderState::encodeImpl(uint32_t stage) {
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
_isDirty = false; // Okay, I changed the encoder
}
break;
case VK_SHADER_STAGE_FRAGMENT_BIT:
@ -204,6 +212,7 @@ void MVKPushConstantsCommandEncoderState::encodeImpl(uint32_t stage) {
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
_isDirty = false; // Okay, I changed the encoder
}
break;
case VK_SHADER_STAGE_COMPUTE_BIT:
@ -211,6 +220,7 @@ void MVKPushConstantsCommandEncoderState::encodeImpl(uint32_t stage) {
_pushConstants.data(),
_pushConstants.size(),
_mtlBufferIndex);
_isDirty = false; // Okay, I changed the encoder
break;
default:
MVKAssert(false, "Unsupported shader stage: %d", _shaderStage);