From b39ec87cccaadebbb9325dd2adb8c0b13b364805 Mon Sep 17 00:00:00 2001 From: sricker-nvidia <115114531+sricker-nvidia@users.noreply.github.com> Date: Thu, 15 May 2025 17:01:08 -0700 Subject: Fix broken -emit-spirv-via-glsl test option (#7091) Fixes issue #6898 The -emit-spirv-via-glsl slang-test option has been broken for some amount of time. Tests that were using it were operating as if using -emit-spirv-directly, leading to many duplicated tests. After fixing the test option, there were an number of errors that appeared as a result. This change fixes the broken test option and the resulting test errors. Some of the test errors revealed some legitimate issues, such as: -The GLSL bitCount instrinsic only supports 32-bit integers and requires emulation for other bit widths. -Emitting GLSL 8-bit and 16-bit glsl integer types did not emit the proper extension requirements -Emitting GLSL and casting for 16-bit integers was missing a closing parenthesis. -Missing profile for GL_EXT_shader_explicit_arithmetic_types -Missing toType cases for UInt8/Int8 for the kIROp_BitCast case in tryEmitInstExprImpl. --- source/slang/slang-emit-glsl.cpp | 18 ++++++++++++++++-- 1 file changed, 16 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 39b318ff3..116d9b1d6 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -1080,9 +1080,11 @@ void GLSLSourceEmitter::_emitGLSLTypePrefix(IRType* type, bool promoteHalfToFloa break; case kIROp_Int8Type: + _requireBaseType(cast(type)->getBaseType()); m_writer->emit("i8"); break; case kIROp_Int16Type: + _requireBaseType(cast(type)->getBaseType()); m_writer->emit("i16"); break; case kIROp_IntType: @@ -1106,9 +1108,11 @@ void GLSLSourceEmitter::_emitGLSLTypePrefix(IRType* type, bool promoteHalfToFloa } case kIROp_UInt8Type: + _requireBaseType(cast(type)->getBaseType()); m_writer->emit("u8"); break; case kIROp_UInt16Type: + _requireBaseType(cast(type)->getBaseType()); m_writer->emit("u16"); break; case kIROp_UIntType: @@ -1327,8 +1331,10 @@ void GLSLSourceEmitter::emitSimpleValueImpl(IRInst* inst) } case BaseType::Int16: { + emitType(type); + m_writer->emit("("); m_writer->emit(int16_t(litInst->value.intVal)); - m_writer->emit("S"); + m_writer->emit("S)"); return; } case BaseType::Int: @@ -1346,8 +1352,10 @@ void GLSLSourceEmitter::emitSimpleValueImpl(IRInst* inst) } case BaseType::UInt16: { + emitType(type); + m_writer->emit("("); m_writer->emit(UInt(uint16_t(litInst->value.intVal))); - m_writer->emit("US"); + m_writer->emit("US)"); return; } case BaseType::UInt: @@ -2289,6 +2297,12 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu emitType(inst->getDataType()); } break; + case BaseType::UInt8: + emitType(inst->getDataType()); + break; + case BaseType::Int8: + emitType(inst->getDataType()); + break; case BaseType::UInt16: if (fromType == BaseType::Half) { -- cgit v1.2.3