From 53731f674601a2eb81c5715957d2e0e65637aee3 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 19 Oct 2018 13:53:18 -0700 Subject: Vulkan implicit sampler fixups (#686) * Fix sampler-less texture functions (#685) * Fix sampler-less texeture functions I'm honestly not sure how the original work on this feature in #648 worked at all (probably insufficient testing). We have these front-end modifiers to indicate that a particular function definition requires a certain GLSL version, or a GLSL extension in order to be used, and they are supposed to be automatically employed by the logic in `emit.cpp` to output `#extension` lines in the output GLSL. However, it turns out that nothing is actually wired up right now, so that adding the modifiers to a declaration is a placebo. This change propagates the modifiers through as decorations, and then uses them during GLSL code emit, which allows the functions that require `EXT_samplerless_texture_functions` to work. * fixup: 32-bit warning * Add serialization support for GLSL extension/version decorations --- source/slang/ir-serialize.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source/slang/ir-serialize.cpp') diff --git a/source/slang/ir-serialize.cpp b/source/slang/ir-serialize.cpp index 3b0e45e23..e204944a7 100644 --- a/source/slang/ir-serialize.cpp +++ b/source/slang/ir-serialize.cpp @@ -531,6 +531,22 @@ Result IRSerialWriter::write(IRModule* module, SourceManager* sourceManager, Opt dstInst.m_payloadType = PayloadType::Empty; break; } + case kIRDecorationOp_RequireGLSLExtension: + { + auto extDecor = static_cast(srcDecor); + + dstInst.m_payloadType = PayloadType::String_1; + dstInst.m_payload.m_stringIndices[0] = getStringIndex(extDecor->extensionName); + break; + } + case kIRDecorationOp_RequireGLSLVersion: + { + auto verDecor = static_cast(srcDecor); + + dstInst.m_payloadType = PayloadType::UInt32; + dstInst.m_payload.m_uint32 = uint32_t(verDecor->languageVersion); + break; + } default: { SLANG_ASSERT(!"Unhandled decoration type"); @@ -1513,6 +1529,20 @@ IRDecoration* IRSerialReader::_createDecoration(const Ser::Inst& srcInst) SLANG_ASSERT(srcInst.m_payloadType == PayloadType::Empty); return decor; } + case kIRDecorationOp_RequireGLSLExtension: + { + auto decor = createEmptyDecoration(m_module); + SLANG_ASSERT(srcInst.m_payloadType == PayloadType::String_1); + decor->extensionName = getStringRepresentation(srcInst.m_payload.m_stringIndices[0]); + return decor; + } + case kIRDecorationOp_RequireGLSLVersion: + { + auto decor = createEmptyDecoration(m_module); + SLANG_ASSERT(srcInst.m_payloadType == Ser::Inst::PayloadType::UInt32); + decor->languageVersion = Int(srcInst.m_payload.m_uint32); + return decor; + } default: { SLANG_ASSERT(!"Unhandled decoration type"); -- cgit v1.2.3