summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-12-15 23:41:27 +0800
committerGitHub <noreply@github.com>2023-12-15 23:41:27 +0800
commit21d17abb0e511806b7c93effc58f37169d837766 (patch)
treea39b8bc015d5f0a5e6fd12b6a31a92f162aaad44 /source/slang/slang-ir.cpp
parent34f04a4670f86e64d4b35ce720281a6f0e72f733 (diff)
GLSL SSBO Support (#3400)
* Squash warnings and fix build with SLANG_EMBED_STDLIB * Add GLSLShaderStorageBuffer magic wrapper * Make GLSLSSBO not a uniform type * Buffers are global variables * Allow creating ssbo aggregate types * Allow reading from RWSB using builder * Nicer debug printing for ssbos * Lower SSBO to RWSB * Parse interface blocks into wrapped structs * Lower Interface Block Decls to structs * remove comment * Two simple ssbo tests * Move ssbo pass earlier * Correct mutable buffer detection * Do not replace ssbo usages outside of blocks * Treat GLSLSSBO as a mutable buffer for type layouts * regenerate vs projects * Correctly detect ssbo types * Diagnose illegal ssbo * remove unreachable code * neaten * ci wobble * Make GLSLSSBO ast handling more uniform * Add modifier cases for glsl * Use empty val info for unhandled interface blocks necessary for ./tests/glsl/out-binding-redeclaration.slang * more sophisticated modifier check * Correct ssbo wrapper name
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 833ce5bb5..f9a1276fe 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -4418,6 +4418,16 @@ namespace Slang
return classType;
}
+ IRGLSLShaderStorageBufferType* IRBuilder::createGLSLShaderStorableBufferType()
+ {
+ IRGLSLShaderStorageBufferType* ssboType = createInst<IRGLSLShaderStorageBufferType>(
+ this,
+ kIROp_GLSLShaderStorageBufferType,
+ getTypeKind());
+ addGlobalValue(this, ssboType);
+ return ssboType;
+ }
+
IRInterfaceType* IRBuilder::createInterfaceType(UInt operandCount, IRInst* const* operands)
{
IRInterfaceType* interfaceType = createInst<IRInterfaceType>(
@@ -5932,6 +5942,22 @@ namespace Slang
return emitIntrinsicInst(nullptr, kIROp_GenericAsm, 1, &arg);
}
+ IRInst* IRBuilder::emitRWStructuredBufferGetElementPtr(IRInst* structuredBuffer, IRInst* index)
+ {
+ const auto sbt = cast<IRHLSLRWStructuredBufferType>(structuredBuffer->getDataType());
+ const auto t = getPtrType(sbt->getElementType());
+ IRInst* const operands[2] = {structuredBuffer, index};
+ const auto i = createInst<IRRWStructuredBufferGetElementPtr>(
+ this,
+ kIROp_RWStructuredBufferGetElementPtr,
+ t,
+ 2,
+ operands
+ );
+ addInst(i);
+ return i;
+ }
+
//
// Decorations
//
@@ -6416,6 +6442,8 @@ namespace Slang
switch( inst->getOp() )
{
case kIROp_StructType:
+ case kIROp_ClassType:
+ case kIROp_GLSLShaderStorageBufferType:
case kIROp_InterfaceType:
return false;
@@ -6812,6 +6840,8 @@ namespace Slang
case kIROp_WitnessTable:
case kIROp_StructType:
+ case kIROp_ClassType:
+ case kIROp_GLSLShaderStorageBufferType:
case kIROp_SPIRVAsm:
dumpIRParentInst(context, inst);
return;
@@ -7012,6 +7042,7 @@ namespace Slang
{
case kIROp_StructType:
case kIROp_ClassType:
+ case kIROp_GLSLShaderStorageBufferType:
case kIROp_InterfaceType:
case kIROp_Generic:
case kIROp_Param:
@@ -7737,6 +7768,7 @@ namespace Slang
// All of the cases for "global values" are side-effect-free.
case kIROp_StructType:
case kIROp_StructField:
+ case kIROp_GLSLShaderStorageBufferType:
case kIROp_RTTIPointerType:
case kIROp_RTTIObject:
case kIROp_RTTIType: