From 2c7734eda87daa5af59fb576fc070673810f6df0 Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Tue, 28 Jul 2020 15:38:39 -0400 Subject: [PATCH] Fix issue where expected buffer-sizes buffer not bound to Metal compute encoder. MVKComputeResourcesCommandEncoderState update buffer-size value before buffer bindings are encoded into Metal and are no longer marked as dirty. --- Docs/Whats_New.md | 1 + .../Commands/MVKCommandEncoderState.mm | 32 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index 81f29f93b..07f454401 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -41,6 +41,7 @@ Released 2020/07/28 - Fix new and unexpected App Store failure on newly deprecated color space values. - Fix intermittent concurrent shader specialization race condition. - Fix offsets when flushing buffer data to GPU. +- Fix issue where expected buffer-sizes buffer not bound to Metal compute encoder. - Ensure fragment shader inputs to have as many components as vertex shader outputs. - Include vertex attribute size when testing whether attribute offset exceeds stride. - Add support for `USCALED/SSCALED` vertex formats. diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm b/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm index ac055f03c..7ac03ea50 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm @@ -781,26 +781,10 @@ void MVKComputeResourcesCommandEncoderState::encodeImpl(uint32_t) { - bool fullImageViewSwizzle = false; MVKPipeline* pipeline = _cmdEncoder->_computePipelineState.getPipeline(); - if (pipeline) - fullImageViewSwizzle = pipeline->fullImageViewSwizzle(); - - encodeBinding(_resourceBindings.bufferBindings, _resourceBindings.areBufferBindingsDirty, - [](MVKCommandEncoder* cmdEncoder, MVKMTLBufferBinding& b)->void { - if (b.isInline) - cmdEncoder->setComputeBytes(cmdEncoder->getMTLComputeEncoder(kMVKCommandUseDispatch), - b.mtlBytes, - b.size, - b.index); - else - [cmdEncoder->getMTLComputeEncoder(kMVKCommandUseDispatch) setBuffer: b.mtlBuffer - offset: b.offset - atIndex: b.index]; - }); + bool fullImageViewSwizzle = pipeline ? pipeline->fullImageViewSwizzle() : false; if (_resourceBindings.swizzleBufferBinding.isDirty) { - for (auto& b : _resourceBindings.textureBindings) { if (b.isDirty) { updateImplicitBuffer(_resourceBindings.swizzleConstants, b.index, b.swizzle); } } @@ -826,6 +810,20 @@ } + encodeBinding(_resourceBindings.bufferBindings, _resourceBindings.areBufferBindingsDirty, + [](MVKCommandEncoder* cmdEncoder, MVKMTLBufferBinding& b)->void { + if (b.isInline) { + cmdEncoder->setComputeBytes(cmdEncoder->getMTLComputeEncoder(kMVKCommandUseDispatch), + b.mtlBytes, + b.size, + b.index); + } else { + [cmdEncoder->getMTLComputeEncoder(kMVKCommandUseDispatch) setBuffer: b.mtlBuffer + offset: b.offset + atIndex: b.index]; + } + }); + encodeBinding(_resourceBindings.textureBindings, _resourceBindings.areTextureBindingsDirty, [](MVKCommandEncoder* cmdEncoder, MVKMTLTextureBinding& b)->void { [cmdEncoder->getMTLComputeEncoder(kMVKCommandUseDispatch) setTexture: b.mtlTexture