From 8151bc6df37372eb91011edede9ffbb258ebeab6 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 22 May 2020 16:19:39 -0700 Subject: Unified VULKAN shader define in VK and GL backends --- Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp index 11385ae6..74293d1b 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp @@ -61,15 +61,19 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters, DEV_CHECK_ERR(CreationAttribs.ByteCode == nullptr, "'ByteCode' must be null when shader is created from source code or a file"); DEV_CHECK_ERR(CreationAttribs.ByteCodeSize == 0, "'ByteCodeSize' must be 0 when shader is created from source code or a file"); + static constexpr char* VulkanDefine = + "#ifndef VULKAN\n" + "# define VULKAN 1\n" + "#endif\n"; if (CreationAttribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL) { - m_SPIRV = HLSLtoSPIRV(CreationAttribs, CreationAttribs.ppCompilerOutput); + m_SPIRV = HLSLtoSPIRV(CreationAttribs, VulkanDefine, CreationAttribs.ppCompilerOutput); } else { auto GLSLSource = BuildGLSLSourceString(CreationAttribs, pRenderDeviceVk->GetDeviceCaps(), TargetGLSLCompiler::glslang, - "#define TARGET_API_VULKAN 1\n"); + VulkanDefine); m_SPIRV = GLSLtoSPIRV(m_Desc.ShaderType, GLSLSource.c_str(), static_cast(GLSLSource.length()), -- cgit v1.2.3