summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-07-17 21:47:09 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-07-17 21:47:09 +0000
commit3bb266bfc21f635b46fec4effdecbd305c87e7b1 (patch)
tree286426221e4e4c3597a7665299df3e41ae985af5 /Graphics
parentVK backend: fixed mipmap generation when glslang is disabled (diff)
downloadDiligentCore-3bb266bfc21f635b46fec4effdecbd305c87e7b1.tar.gz
DiligentCore-3bb266bfc21f635b46fec4effdecbd305c87e7b1.zip
Vk backend: disabled warning about missing SPV_GOOGLE_hlsl_functionality1 extension when SPIRV is not compiled from HLSL plus few improvements to handling SPIRV created from HLSL
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GLSLTools/include/SPIRVShaderResources.hpp5
-rw-r--r--Graphics/GLSLTools/src/SPIRVShaderResources.cpp17
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp19
3 files changed, 30 insertions, 11 deletions
diff --git a/Graphics/GLSLTools/include/SPIRVShaderResources.hpp b/Graphics/GLSLTools/include/SPIRVShaderResources.hpp
index addd3e1b..96e778a0 100644
--- a/Graphics/GLSLTools/include/SPIRVShaderResources.hpp
+++ b/Graphics/GLSLTools/include/SPIRVShaderResources.hpp
@@ -328,6 +328,8 @@ public:
// clang-format on
+ bool IsHLSLSource() const { return m_IsHLSLSource; }
+
private:
void Initialize(IMemoryAllocator& Allocator,
const ResourceCounters& Counters,
@@ -386,6 +388,9 @@ private:
OffsetType m_NumShaderStageInputs = 0;
SHADER_TYPE m_ShaderType = SHADER_TYPE_UNKNOWN;
+
+ // Inidicates if the shader was compiled from HLSL source.
+ bool m_IsHLSLSource = false;
};
} // namespace Diligent
diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
index 6fd96ddf..46705ace 100644
--- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
+++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
@@ -213,7 +213,8 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
// https://github.com/KhronosGroup/SPIRV-Cross/wiki/Reflection-API-user-guide
diligent_spirv_cross::Parser parser(move(spirv_binary));
parser.parse();
- auto ParsedIRSource = parser.get_parsed_ir().source;
+ const auto ParsedIRSource = parser.get_parsed_ir().source;
+ m_IsHLSLSource = ParsedIRSource.hlsl;
diligent_spirv_cross::Compiler Compiler(std::move(parser.get_parsed_ir()));
spv::ExecutionModel ExecutionModel = ShaderTypeToExecutionModel(shaderDesc.ShaderType);
@@ -270,7 +271,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
Uint32 NumShaderStageInputs = 0;
- if (resources.stage_inputs.empty())
+ if (!m_IsHLSLSource || resources.stage_inputs.empty())
LoadShaderStageInputs = false;
if (LoadShaderStageInputs)
{
@@ -302,10 +303,14 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator,
else
{
LoadShaderStageInputs = false;
- LOG_WARNING_MESSAGE("SPIRV byte code of shader '", shaderDesc.Name, "' does not use SPV_GOOGLE_hlsl_functionality1 extension. "
- "As a result, it is not possible to get semantics of shader inputs and map them to proper locations. "
- "The shader will still work correctly if all attributes are declared in ascending order without any gaps. "
- "Enable SPV_GOOGLE_hlsl_functionality1 in your compiler to allow proper mapping of vertex shader inputs.");
+ if (m_IsHLSLSource)
+ {
+ LOG_WARNING_MESSAGE("SPIRV byte code of shader '", shaderDesc.Name,
+ "' does not use SPV_GOOGLE_hlsl_functionality1 extension. "
+ "As a result, it is not possible to get semantics of shader inputs and map them to proper locations. "
+ "The shader will still work correctly if all attributes are declared in ascending order without any gaps. "
+ "Enable SPV_GOOGLE_hlsl_functionality1 in your compiler to allow proper mapping of vertex shader inputs.");
+ }
}
}
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
index 523a5108..8b3cf728 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
@@ -102,13 +102,22 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters,
// pipeline state is created
// Load shader resources
- auto& Allocator = GetRawAllocator();
- auto* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", SPIRVShaderResources, 1);
- bool IsHLSLVertexShader = CreationAttribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL && m_Desc.ShaderType == SHADER_TYPE_VERTEX;
- auto* pResources = new (pRawMem) SPIRVShaderResources(Allocator, pRenderDeviceVk, m_SPIRV, m_Desc, CreationAttribs.UseCombinedTextureSamplers ? CreationAttribs.CombinedSamplerSuffix : nullptr, IsHLSLVertexShader, m_EntryPoint);
+ auto& Allocator = GetRawAllocator();
+ auto* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", SPIRVShaderResources, 1);
+ auto LoadShaderInputs = m_Desc.ShaderType == SHADER_TYPE_VERTEX;
+ auto* pResources = new (pRawMem) SPIRVShaderResources //
+ {
+ Allocator,
+ pRenderDeviceVk,
+ m_SPIRV,
+ m_Desc,
+ CreationAttribs.UseCombinedTextureSamplers ? CreationAttribs.CombinedSamplerSuffix : nullptr,
+ LoadShaderInputs,
+ m_EntryPoint //
+ };
m_pShaderResources.reset(pResources, STDDeleterRawMem<SPIRVShaderResources>(Allocator));
- if (IsHLSLVertexShader)
+ if (LoadShaderInputs && m_pShaderResources->IsHLSLSource())
{
MapHLSLVertexShaderInputs();
}