summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-glsl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-09-13 00:27:13 -0700
committerGitHub <noreply@github.com>2021-09-13 00:27:13 -0700
commit579df478de078f0a22f72f499c13ce442b4cd290 (patch)
tree11307366f454449e101c31b30492010aeb9ad7ed /source/slang/slang-emit-glsl.cpp
parent27ce5eb0de9f792f3e433bcb239c07d79371cf45 (diff)
Bug fix in 16bit type emit, vk validation error fix. (#1936)
+ Implement bit_cast between float16 and uint16 in GLSL. + Enable pack-any-value-16bit test on vk. 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.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp
index 82804c6b5..634067ab7 100644
--- a/source/slang/slang-emit-glsl.cpp
+++ b/source/slang/slang-emit-glsl.cpp
@@ -1432,7 +1432,48 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
emitType(inst->getDataType());
}
break;
-
+ case BaseType::UInt16:
+ if (fromType == BaseType::Half)
+ {
+ m_writer->emit("uint16_t(packHalf2x16(vec2(");
+ emitOperand(inst->getOperand(0), getInfo(EmitOp::General));
+ m_writer->emit(", 0.0)))");
+ return true;
+ }
+ else
+ {
+ emitType(inst->getDataType());
+ }
+ break;
+ case BaseType::Int16:
+ if (fromType == BaseType::Half)
+ {
+ m_writer->emit("int16_t(packHalf2x16(vec2(");
+ emitOperand(inst->getOperand(0), getInfo(EmitOp::General));
+ m_writer->emit(", 0.0)))");
+ return true;
+ }
+ else
+ {
+ emitType(inst->getDataType());
+ }
+ break;
+ case BaseType::Half:
+ switch (fromType)
+ {
+ case BaseType::Int16:
+ case BaseType::UInt16:
+ case BaseType::Int:
+ case BaseType::UInt:
+ m_writer->emit("float16_t(unpackHalf2x16(uint(");
+ emitOperand(inst->getOperand(0), getInfo(EmitOp::General));
+ m_writer->emit(")).x)");
+ return true;
+ default:
+ emitType(inst->getDataType());
+ break;
+ }
+ break;
case BaseType::Float:
switch (fromType)
{