Skip to content

Commit

Permalink
Merge pull request #979 from billhollings/master
Browse files Browse the repository at this point in the history
Fix issue where expected buffer-sizes buffer not bound to Metal compute encoder.
  • Loading branch information
billhollings authored Jul 28, 2020
2 parents 1e993f8 + 2c7734e commit 8f6edef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
1 change: 1 addition & 0 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 15 additions & 17 deletions MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm
Original file line number Diff line number Diff line change
Expand Up @@ -781,26 +781,10 @@

void MVKComputeResourcesCommandEncoderState::encodeImpl(uint32_t) {

bool fullImageViewSwizzle = false;
MVKPipeline* pipeline = _cmdEncoder->_computePipelineState.getPipeline();
if (pipeline)
fullImageViewSwizzle = pipeline->fullImageViewSwizzle();

encodeBinding<MVKMTLBufferBinding>(_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); }
}
Expand All @@ -826,6 +810,20 @@

}

encodeBinding<MVKMTLBufferBinding>(_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<MVKMTLTextureBinding>(_resourceBindings.textureBindings, _resourceBindings.areTextureBindingsDirty,
[](MVKCommandEncoder* cmdEncoder, MVKMTLTextureBinding& b)->void {
[cmdEncoder->getMTLComputeEncoder(kMVKCommandUseDispatch) setTexture: b.mtlTexture
Expand Down

0 comments on commit 8f6edef

Please sign in to comment.