From cf8d1ceffcfbbb64734e6180a2c0cebd033f5b2e Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:16:28 -0400 Subject: Implementing `tbuffer` layout(s) (#4436) * Implementing `tbuffer` layouts. 1. Add to layout options 'TextureBuffer' layouts. 2. Add on to existing logic a way to allocate appropriate registers for TextureBufferType (this was made to work with parameter block logic). 3. Added asserts so objects missing a layout will gracefully crash This means `tbuffer` now works for hlsl,glsl,metal targets, spirv has yet to implement logic for `TextureBufferType`. * disable metal tests and fix emitting code a bit fixing the emitting code means metal compilation emits a useful error (help point users/developers to #4435) * fix warning --- source/slang/slang-emit-hlsl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-emit-hlsl.cpp') diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp index 72b2a08b0..04f5bd643 100644 --- a/source/slang/slang-emit-hlsl.cpp +++ b/source/slang/slang-emit-hlsl.cpp @@ -191,8 +191,10 @@ void HLSLSourceEmitter::_emitHLSLParameterGroupFieldLayoutSemantics(IRVarLayout* void HLSLSourceEmitter::_emitHLSLParameterGroup(IRGlobalParam* varDecl, IRUniformParameterGroupType* type) { + LayoutResourceKind layoutResourceKind = LayoutResourceKind::ConstantBuffer; if (as(type)) { + layoutResourceKind = LayoutResourceKind::ShaderResource; m_writer->emit("tbuffer "); } else @@ -218,7 +220,7 @@ void HLSLSourceEmitter::_emitHLSLParameterGroup(IRGlobalParam* varDecl, IRUnifor typeLayout = parameterGroupTypeLayout->getElementVarLayout()->getTypeLayout(); } - _emitHLSLRegisterSemantic(LayoutResourceKind::ConstantBuffer, &containerChain, varDecl); + _emitHLSLRegisterSemantic(layoutResourceKind, &containerChain, varDecl); auto elementType = type->getElementType(); if (shouldForceUnpackConstantBufferElements(type) || hasExplicitConstantBufferOffset(type)) -- cgit v1.2.3