diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 27 | ||||
| -rw-r--r-- | source/slang/slang-capabilities.capdef | 5 | ||||
| -rw-r--r-- | source/slang/slang-emit-glsl.cpp | 18 |
3 files changed, 44 insertions, 6 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index d7a65c031..6fb3af7fd 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -8084,9 +8084,20 @@ uint countbits(T value) // 16-bit support dependent on SM6.2 and dxil __intrinsic_asm "countbits"; case glsl: - // 64-bit support dependent on GL_ARB_gpu_shader_int64 - // 16-bit support dependent on GL_EXT_shader_16bit_storage - __intrinsic_asm "bitCount"; + if(T is int64_t || T is uint64_t) + { + return __emulatedCountbits64(__intCast<uint64_t>(value)); + } + else if (T is int16_t || T is uint16_t) + { + // emulate 16-bit + return countbits(__intCast<uint32_t>(value)); + } + else + { + // bitCount only supports 32-bit + __intrinsic_asm "bitCount"; + } case metal: if (T is int64_t || T is uint64_t) { @@ -8150,7 +8161,15 @@ vector<uint, N> countbits(vector<T, N> value) case hlsl: __intrinsic_asm "countbits"; case glsl: - __intrinsic_asm "bitCount"; + if(T is int64_t || T is uint64_t || T is int16_t || T is uint16_t) + { + // Emulate 64-bit and 16-bit + VECTOR_MAP_UNARY(uint, N, countbits, value); + } + else + { + __intrinsic_asm "bitCount"; + } case metal: if(T is int64_t || T is uint64_t || T is int16_t || T is uint16_t) { diff --git a/source/slang/slang-capabilities.capdef b/source/slang/slang-capabilities.capdef index 937584908..9a1a89bfe 100644 --- a/source/slang/slang-capabilities.capdef +++ b/source/slang/slang-capabilities.capdef @@ -813,6 +813,7 @@ def _GL_EXT_shader_atomic_float : glsl; def _GL_EXT_shader_atomic_float_min_max : glsl; def _GL_EXT_shader_atomic_float2 : glsl; def _GL_EXT_shader_atomic_int64 : glsl; +def _GL_EXT_shader_explicit_arithmetic_types : _GLSL_140; def _GL_EXT_shader_explicit_arithmetic_types_int64 : _GLSL_140; def _GL_EXT_shader_image_load_store : _GLSL_130; def _GL_EXT_shader_realtime_clock : glsl; @@ -937,6 +938,10 @@ alias GL_EXT_shader_atomic_float2 = _GL_EXT_shader_atomic_float2 | spvAtomicFloa /// [EXT] alias GL_EXT_shader_atomic_int64 = _GL_EXT_shader_atomic_int64 | spvInt64Atomics; +/// Represents the GL_EXT_shader_explicit_arithmetic_types extension. +/// [EXT] +alias GL_EXT_shader_explicit_arithmetic_types = _GL_EXT_shader_explicit_arithmetic_types | _spirv_1_0; + /// Represents the GL_EXT_shader_explicit_arithmetic_types_int64 extension. /// [EXT] alias GL_EXT_shader_explicit_arithmetic_types_int64 = _GL_EXT_shader_explicit_arithmetic_types_int64 | _spirv_1_0; 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<IRBasicType>(type)->getBaseType()); m_writer->emit("i8"); break; case kIROp_Int16Type: + _requireBaseType(cast<IRBasicType>(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<IRBasicType>(type)->getBaseType()); m_writer->emit("u8"); break; case kIROp_UInt16Type: + _requireBaseType(cast<IRBasicType>(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) { |
