summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-cuda.cpp
diff options
context:
space:
mode:
authorNathan V. Morrical <natemorrical@gmail.com>2021-06-04 17:18:14 -0600
committerGitHub <noreply@github.com>2021-06-04 16:18:14 -0700
commit1617c2d4d7145435f34619d8d6706c5845b898c0 (patch)
tree46187a6ac9cae538d20593eb10ab319acf21973f /source/slang/slang-emit-cuda.cpp
parent95a90d7fda3097d085cde1fea5213667277e729b (diff)
Enable tracing rays with OptiX backend (#1871)
* OptiX ray payload can now be read from and written to using the two payload register pointer method * changing op to more descriptive name * small tweak to allow for dumping out intermediate source for cuda targets * initial trace ray call compiling * hit attributes now work for float and int types, and vectors thereof * Hitgroups using structs and arrays now work with optix Co-authored-by: T. Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit-cuda.cpp')
-rw-r--r--source/slang/slang-emit-cuda.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/slang/slang-emit-cuda.cpp b/source/slang/slang-emit-cuda.cpp
index 4c430cfa6..0a375cb56 100644
--- a/source/slang/slang-emit-cuda.cpp
+++ b/source/slang/slang-emit-cuda.cpp
@@ -788,6 +788,29 @@ bool CUDASourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
m_writer->emit(")getOptiXRayPayloadPtr()");
return true;
}
+ case kIROp_GetOptiXHitAttribute:
+ {
+ auto typeToFetch = inst->getOperand(0);
+ auto idxInst = as<IRIntLit>(inst->getOperand(1));
+ IRIntegerValue idx = idxInst->getValue();
+ if (typeToFetch->getOp() == kIROp_FloatType) {
+ m_writer->emit("__int_as_float(optixGetAttribute_");
+ }
+ else
+ {
+ m_writer->emit("optixGetAttribute_");
+ }
+ m_writer->emit(idx);
+ if (typeToFetch->getOp() == kIROp_FloatType)
+ {
+ m_writer->emit("())");
+ }
+ else
+ {
+ m_writer->emit("()");
+ }
+ return true;
+ }
default: break;
}