summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-specialize-resources.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-specialize-resources.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-specialize-resources.cpp')
-rw-r--r--source/slang/slang-ir-specialize-resources.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/slang/slang-ir-specialize-resources.cpp b/source/slang/slang-ir-specialize-resources.cpp
index 87d00a32b..49f1b3177 100644
--- a/source/slang/slang-ir-specialize-resources.cpp
+++ b/source/slang/slang-ir-specialize-resources.cpp
@@ -62,19 +62,18 @@ struct ResourceParameterSpecializationCondition : FunctionCallSpecializeConditio
//
if( isKhronosTarget(targetRequest) )
{
- return isIllegalGLSLParameterType(type);
+ if (targetRequest->shouldEmitSPIRVDirectly())
+ return isIllegalSPIRVParameterType(type);
+ else
+ return isIllegalGLSLParameterType(type);
}
+
// For now, we will not treat any other parameters as
// needing specialization, even if they use resource
// types like `Texure2D`, because these are allowed
// as function parameters in both HLSL and GLSL.
//
- // TODO: Eventually, if we start generating SPIR-V
- // directly rather than through glslang, we will need
- // to specialize *all* resource-type parameters
- // to follow the restrictions in the spec.
- //
// TODO: We may want to perform more aggressive
// specialization in general, especially insofar
// as it could simplify the task of supporting
@@ -1237,4 +1236,15 @@ bool isIllegalGLSLParameterType(IRType* type)
return false;
}
+bool isIllegalSPIRVParameterType(IRType* type)
+{
+ if (isIllegalGLSLParameterType(type))
+ return true;
+
+ // If we are emitting SPIRV direclty, we need to specialize
+ // all Texture types.
+ if (auto texType = as<IRTextureType>(type))
+ return true;
+ return false;
+}
} // namespace Slang