diff options
| author | Yong He <yonghe@outlook.com> | 2023-09-03 12:56:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-03 12:56:31 -0700 |
| commit | 1d4b5b6fd2433a10cc7ab87626cb560f54b0acbb (patch) | |
| tree | 6196d519190720fd2968ac7d4b373e3c967d5fe6 /source/slang/slang-emit-glsl.cpp | |
| parent | 355bb4287861f96082751042f4e58ff3598b4e5e (diff) | |
Proper lowering of functiosn that returns NonCopyable values. (#3179)
* Proper lowering of functiosn that returns NonCopyable values.
* Fix tests.
* Fix clang errors.
* Fix.
* Fix clang error.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-glsl.cpp')
| -rw-r--r-- | source/slang/slang-emit-glsl.cpp | 67 |
1 files changed, 10 insertions, 57 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index c651c8735..94c85409f 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -927,61 +927,6 @@ void GLSLSourceEmitter::emitLoopControlDecorationImpl(IRLoopControlDecoration* d } } -void GLSLSourceEmitter::_emitInstAsVarInitializerImpl(IRInst* inst) -{ - // Some opcodes can be folded into a variable initialization - // by allowing the variable to be "default-constructed." - // - switch (inst->getOp()) - { - case kIROp_AllocateOpaqueHandle: - // - // Note: semantically, we should only elide the initializer - // if `inst` is able to be folded here, since otherwise - // it could be a single allocation that is used to initialize - // multiple local variables (which should then alias the - // same location). - // - // However, since GlSL doesn't support assignment of opaque - // handle types, code will fail to compile downstream in - // the case where the initializer *doesn't* fold. - // - // The decision being made here should help ensure that we - // don't emit code that silently has different semantics - // than the input. - // - if (shouldFoldInstIntoUseSites(inst)) - { - return; - } - break; - - default: - break; - } - - // We fall back to the default behavior for all targets, - // which is to emit `inst` as an initial-value expression - // after an `=`. - // - Super::_emitInstAsVarInitializerImpl(inst); -} - -void GLSLSourceEmitter::_emitStoreImpl(IRStore* store) -{ - auto srcVal = store->getVal(); - switch (srcVal->getOp()) - { - default: - Super::_emitStoreImpl(store); - break; - - case kIROp_AllocateOpaqueHandle: - break; - } - -} - void GLSLSourceEmitter::_emitSpecialFloatImpl(IRType* type, const char* valueExpr) { if( type->getOp() != kIROp_FloatType ) @@ -2215,9 +2160,17 @@ void GLSLSourceEmitter::emitParamTypeImpl(IRType* type, String const& name) { if (auto refType = as<IRRefType>(type)) { - _requireGLSLExtension(UnownedStringSlice("GL_EXT_spirv_intrinsics")); - m_writer->emit("spirv_by_reference "); type = refType->getValueType(); + + if (as<IRRayQueryType>(type) || as<IRHitObjectType>(type)) + { + // GLSL will automatically pass these by reference, so we don't need to do anything. + } + else + { + _requireGLSLExtension(UnownedStringSlice("GL_EXT_spirv_intrinsics")); + m_writer->emit("spirv_by_reference "); + } } else if (auto spirvLiteralType = as<IRSPIRVLiteralType>(type)) { |
