summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-04-19 09:34:54 -0700
committerGitHub <noreply@github.com>2018-04-19 09:34:54 -0700
commitc68c6fa02690012f54928202811050cee649d81e (patch)
tree614447345c070429b1b2ea0c3639cdc4ffbf81a9 /source/slang/emit.cpp
parent17fa424a195ed562e0c9d87cee57577c90c1fc37 (diff)
Fix up DXR type emission from IR type system (#498)
* There was a simple typo where we were emitting `RaytracingAccelerationStructureType` instead of `RaytracingAccelerationStructure` * The IR lowering logic was failing to handle types with an `__intrinsic_type` modifier (which maps them to a single IR opcode) that weren't in one of the various special cases. I added a catch-all case to the handling of `DeclRefType`. This notably affected the `RayDesc` type. * Even if we lower `RayDesc` to an intrinsic type, we still need to lower its *fields* too, and these were getting emitted with mangled names (as would happen for any user-defined fields). The solution I implemented was to allow for fields to have `__target_intrinsic` modifiers in the stdlib, to specify the un-mangled name they should use on each target. I'm not 100% happy with this solution, because it seems odd to have `RayDesc` be an intrinsic type, but then to also have field keys used in `getField` instructions as if it were an ordinary `struct`. It seems like a better solution would be to have it lower to an IR `struct`, just with an appropriate modifier.
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index e93dfbbb5..71d323c9e 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -1095,9 +1095,9 @@ struct EmitVisitor
{
switch (type->op)
{
- case kIROp_HLSLByteAddressBufferType: Emit("ByteAddressBuffer"); break;
- case kIROp_HLSLRWByteAddressBufferType: Emit("RWByteAddressBuffer"); break;
- case kIROp_RaytracingAccelerationStructureType: Emit("RaytracingAccelerationStructureType"); break;
+ case kIROp_HLSLByteAddressBufferType: Emit("ByteAddressBuffer"); break;
+ case kIROp_HLSLRWByteAddressBufferType: Emit("RWByteAddressBuffer"); break;
+ case kIROp_RaytracingAccelerationStructureType: Emit("RaytracingAccelerationStructure"); break;
default:
SLANG_DIAGNOSE_UNEXPECTED(getSink(), SourceLoc(), "unhandled buffer type");
@@ -1110,9 +1110,9 @@ struct EmitVisitor
{
switch (type->op)
{
- case kIROp_HLSLByteAddressBufferType: Emit("ByteAddressBuffer"); break;
- case kIROp_HLSLRWByteAddressBufferType: Emit("RWByteAddressBuffer"); break;
- case kIROp_RaytracingAccelerationStructureType: Emit("RaytracingAccelerationStructureType"); break;
+ case kIROp_HLSLByteAddressBufferType: Emit("ByteAddressBuffer"); break;
+ case kIROp_HLSLRWByteAddressBufferType: Emit("RWByteAddressBuffer"); break;
+ case kIROp_RaytracingAccelerationStructureType: Emit("RaytracingAccelerationStructure"); break;
default:
SLANG_DIAGNOSE_UNEXPECTED(getSink(), SourceLoc(), "unhandled buffer type");
@@ -1898,6 +1898,14 @@ struct EmitVisitor
String getIRName(
IRInst* inst)
{
+ // If the instruction names something
+ // that should be emitted as a target intrinsic,
+ // then use that name instead.
+ if(auto intrinsicDecoration = findTargetIntrinsicDecoration(context, inst))
+ {
+ return intrinsicDecoration->definition;
+ }
+
// If the instruction has a mangled name, then emit using that.
if (auto globalValue = as<IRGlobalValue>(inst))
{
@@ -2498,9 +2506,9 @@ struct EmitVisitor
IRTargetIntrinsicDecoration* findTargetIntrinsicDecoration(
EmitContext* /* ctx */,
- IRFunc* func)
+ IRInst* inst)
{
- for (auto dd = func->firstDecoration; dd; dd = dd->next)
+ for (auto dd = inst->firstDecoration; dd; dd = dd->next)
{
if (dd->op != kIRDecorationOp_TargetIntrinsic)
continue;