From ccf2611c024ab12dcccd978f3f501d4ee9fc52bc Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 2 Oct 2023 03:33:58 -0700 Subject: Add SPIRV intrinsics for ShaderExecutionReordering and RW/Buffer. (#3252) * Add SPIRV intrinsics for ShaderExecutionReordering. * Add intrinsics for `Buffer` and `RWBuffer`. * Various spirv fixes. * Marshal bool vector type. * Inline global constants + OpFOrdNotEqual->OpFUnordNotEqual. * Fix. --------- Co-authored-by: Yong He --- source/slang/slang-ir-lower-buffer-element-type.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir-lower-buffer-element-type.cpp') diff --git a/source/slang/slang-ir-lower-buffer-element-type.cpp b/source/slang/slang-ir-lower-buffer-element-type.cpp index ffdd4584a..378201fdb 100644 --- a/source/slang/slang-ir-lower-buffer-element-type.cpp +++ b/source/slang/slang-ir-lower-buffer-element-type.cpp @@ -409,10 +409,18 @@ namespace Slang { case CodeGenTarget::SPIRV: case CodeGenTarget::SPIRVAssembly: - if (as(type)) + { + auto scalarType = type; + auto vectorType = as(scalarType); + if (vectorType) + scalarType = vectorType->getElementType(); + + if (as(scalarType)) { // Bool is an abstract type in SPIRV, so we need to lower them into an int. info.loweredType = builder.getIntType(); + if (vectorType) + info.loweredType = builder.getVectorType(info.loweredType, vectorType->getElementCount()); // Create unpack func. { builder.setInsertAfter(type); @@ -440,6 +448,7 @@ namespace Slang } return info; } + } default: break; } @@ -642,6 +651,11 @@ namespace Slang break; case kIROp_Call: { + // If a structured buffer typed value is used directly as an argument, + // we don't need to do any marshalling here. + if (as(ptrVal->getDataType())) + break; + // If we are calling a function with an l-value pointer from buffer access, // we need to materialize the object as a local variable, and pass the address // of the local variable to the function. -- cgit v1.2.3