summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-lower-buffer-element-type.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-10-02 03:33:58 -0700
committerGitHub <noreply@github.com>2023-10-02 18:33:58 +0800
commitccf2611c024ab12dcccd978f3f501d4ee9fc52bc (patch)
treef4df843e3b46886005d6bfbae34dc3bcc6fb8321 /source/slang/slang-ir-lower-buffer-element-type.cpp
parent6138de5f084cafdc98381237c2d8bed7c8804f1c (diff)
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 <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-lower-buffer-element-type.cpp')
-rw-r--r--source/slang/slang-ir-lower-buffer-element-type.cpp16
1 files changed, 15 insertions, 1 deletions
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<IRBoolType>(type))
+ {
+ auto scalarType = type;
+ auto vectorType = as<IRVectorType>(scalarType);
+ if (vectorType)
+ scalarType = vectorType->getElementType();
+
+ if (as<IRBoolType>(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<IRHLSLStructuredBufferTypeBase>(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.