diff options
| author | Yong He <yonghe@outlook.com> | 2021-09-13 00:27:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-13 00:27:13 -0700 |
| commit | 579df478de078f0a22f72f499c13ce442b4cd290 (patch) | |
| tree | 11307366f454449e101c31b30492010aeb9ad7ed /source | |
| parent | 27ce5eb0de9f792f3e433bcb239c07d79371cf45 (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')
| -rw-r--r-- | source/slang/slang-emit-glsl.cpp | 43 | ||||
| -rw-r--r-- | source/slang/slang-emit-hlsl.cpp | 14 |
2 files changed, 43 insertions, 14 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) { diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp index 2fda8ab99..dc58b7507 100644 --- a/source/slang/slang-emit-hlsl.cpp +++ b/source/slang/slang-emit-hlsl.cpp @@ -766,23 +766,11 @@ void HLSLSourceEmitter::emitSimpleTypeImpl(IRType* type) case kIROp_UInt64Type: case kIROp_FloatType: case kIROp_DoubleType: - { - m_writer->emit(getDefaultBuiltinTypeName(type->getOp())); - return; - } case kIROp_Int16Type: - { - m_writer->emit("min16int"); - return; - } case kIROp_UInt16Type: { - m_writer->emit("min16uint"); - return; - } case kIROp_HalfType: - { - m_writer->emit("min16float"); + m_writer->emit(getDefaultBuiltinTypeName(type->getOp())); return; } case kIROp_StructType: |
