diff options
| author | skallweitNV <64953474+skallweitNV@users.noreply.github.com> | 2024-06-11 21:33:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-11 12:33:02 -0700 |
| commit | 7e796692065060dea34b9e5b7eb224be444f5dee (patch) | |
| tree | c858c13c64789bf263234c15ae6cc61f47fde937 /tools/gfx/metal/metal-command-encoder.cpp | |
| parent | 6909d65c77bb4e7c9cfb281bd1684a58d5f8b94d (diff) | |
[gfx] Metal improvements (#4337)
* fix binding resources for render pass
* compute vertex buffer binding offset based on root layout
* fix result code
* cleanup
* implement readTextureResource
* more getNativeHandle
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/gfx/metal/metal-command-encoder.cpp')
| -rw-r--r-- | tools/gfx/metal/metal-command-encoder.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/gfx/metal/metal-command-encoder.cpp b/tools/gfx/metal/metal-command-encoder.cpp index fa1df263e..2447295c4 100644 --- a/tools/gfx/metal/metal-command-encoder.cpp +++ b/tools/gfx/metal/metal-command-encoder.cpp @@ -360,8 +360,8 @@ Result RenderCommandEncoder::prepareDraw(MTL::RenderCommandEncoder*& encoder) encoder = m_commandBuffer->getMetalRenderCommandEncoder(m_renderPassDesc.get()); encoder->setRenderPipelineState(pipeline->m_renderPipelineState.get()); - // TODO only vertex stage bindings are set for now - VertexBindingContext bindingContext; + + RenderBindingContext bindingContext; bindingContext.init(m_commandBuffer->m_device, encoder); auto program = static_cast<ShaderProgramImpl*>(m_currentPipeline->m_program.get()); m_commandBuffer->m_rootObject.bindAsRoot(&bindingContext, program->m_rootObjectLayout); @@ -406,7 +406,7 @@ Result RenderCommandEncoder::drawIndexed( SLANG_RETURN_ON_FAIL(prepareDraw(encoder)); // TODO baseVertex is not supported by Metal encoder->drawIndexedPrimitives(m_primitiveType, indexCount, m_indexBufferType, m_indexBuffer, m_indexBufferOffset); - return SLANG_E_NOT_IMPLEMENTED; + return SLANG_OK; } Result RenderCommandEncoder::drawIndirect( @@ -483,10 +483,12 @@ Result ComputeCommandEncoder::dispatchCompute(int x, int y, int z) MTL::ComputeCommandEncoder* encoder = m_commandBuffer->getMetalComputeCommandEncoder(); encoder->setComputePipelineState(pipeline->m_computePipelineState.get()); + ComputeBindingContext bindingContext; bindingContext.init(m_commandBuffer->m_device, encoder); auto program = static_cast<ShaderProgramImpl*>(m_currentPipeline->m_program.get()); m_commandBuffer->m_rootObject.bindAsRoot(&bindingContext, program->m_rootObjectLayout); + encoder->dispatchThreadgroups(MTL::Size(x, y, z), pipeline->m_threadGroupSize); return SLANG_OK; |
