From e67af5b1a3993529c702ff2924dea11fd1017d2e Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 2 Jun 2021 16:58:25 -0700 Subject: Various Fixes to gfx, reflection and emit. (#1867) * Various Fixes to gfx, reflection and emit. - Fix GLSL emit to properly output `*bitsTo*` functions for `IRBitCast` insts. - Add line directive mode setting for `ISession`. - Extend `TypeLayout::getElementStride` to handle `VectorType` case. - Fix `IDevice::readBufferResource` 's D3D12 implementation to copy only the requested bytes out. - Fix `render-test` to use the `ISession` from `gfx` instead of creating its own `ISession` to make sure `gfx` and `render-test` agree on WitnessTable and RTTI IDs. - Extend `render-test` to support filling vector and matrix values in the new `set x = ...` TEST_INPUT syntax. - Add a `dynamic-dispatch-15` test case to make sure packing / unpacking works correctly across all targets, and to make sure render-test's RTTI/WitnessTable ID filling logic is correct for non-trivial cases. * Remove default-major test * Fix cyclic reference in `ExtendedTypeLayout`. * Move `lineDirectiveMode` setting to `TargetDesc`. Add `structureSize` to `TargetDesc` and `SessionDesc` for future binary compatibility. * Cleanup. Co-authored-by: Yong He --- source/slang/slang-emit-glsl.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-emit-glsl.cpp') diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index b5eec456a..82804c6b5 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -1404,6 +1404,7 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu case kIROp_BitCast: { auto toType = extractBaseType(inst->getDataType()); + auto fromType = extractBaseType(inst->getOperand(0)->getDataType()); switch (toType) { default: @@ -1411,14 +1412,40 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu break; case BaseType::UInt: + if (fromType == BaseType::Float) + { + m_writer->emit("floatBitsToUint"); + } + else + { + emitType(inst->getDataType()); + } break; case BaseType::Int: - emitType(inst->getDataType()); + if (fromType == BaseType::Float) + { + m_writer->emit("floatBitsToInt"); + } + else + { + emitType(inst->getDataType()); + } break; case BaseType::Float: - m_writer->emit("uintBitsToFloat"); + switch (fromType) + { + case BaseType::Int: + m_writer->emit("intBitsToFloat"); + break; + case BaseType::UInt: + m_writer->emit("uintBitsToFloat"); + break; + default: + emitType(inst->getDataType()); + break; + } break; } -- cgit v1.2.3