summaryrefslogtreecommitdiffstats
path: root/Graphics/GLSLTools
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-05-05 22:46:25 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-05-05 22:46:25 +0000
commit86500467cbf998df13f3644c1e04040ce2dd5907 (patch)
tree16f299b3bda4cfc8b7f0afcdb93bd11ec3c839d7 /Graphics/GLSLTools
parentFixed GLSL shader compilation to generate bindings and descriptor sets; updat... (diff)
downloadDiligentCore-86500467cbf998df13f3644c1e04040ce2dd5907.tar.gz
DiligentCore-86500467cbf998df13f3644c1e04040ce2dd5907.zip
Added shader variable type parsing in Vulkan
Diffstat (limited to 'Graphics/GLSLTools')
-rw-r--r--Graphics/GLSLTools/CMakeLists.txt1
-rw-r--r--Graphics/GLSLTools/include/SPIRVShaderResources.h7
-rw-r--r--Graphics/GLSLTools/src/SPIRVShaderResources.cpp29
3 files changed, 28 insertions, 9 deletions
diff --git a/Graphics/GLSLTools/CMakeLists.txt b/Graphics/GLSLTools/CMakeLists.txt
index 32cd107a..46392807 100644
--- a/Graphics/GLSLTools/CMakeLists.txt
+++ b/Graphics/GLSLTools/CMakeLists.txt
@@ -28,6 +28,7 @@ PUBLIC
include
PRIVATE
../HLSL2GLSLConverterLib/include
+ ../GraphicsEngine/include
)
target_link_libraries(GLSLTools
diff --git a/Graphics/GLSLTools/include/SPIRVShaderResources.h b/Graphics/GLSLTools/include/SPIRVShaderResources.h
index 9d952a97..df853933 100644
--- a/Graphics/GLSLTools/include/SPIRVShaderResources.h
+++ b/Graphics/GLSLTools/include/SPIRVShaderResources.h
@@ -116,7 +116,12 @@ struct SPIRVShaderResourceAttribs
class SPIRVShaderResources
{
public:
- SPIRVShaderResources(IMemoryAllocator &Allocator, SHADER_TYPE ShaderType, std::vector<uint32_t> spirv_binary);
+ SPIRVShaderResources(IMemoryAllocator &Allocator,
+ SHADER_TYPE ShaderType,
+ std::vector<uint32_t> spirv_binary,
+ SHADER_VARIABLE_TYPE DefaultVariableType,
+ const ShaderVariableDesc *VariableDesc,
+ Uint32 NumVars);
// Copies specified types of resources from another ShaderResources objects
// Only resources listed in AllowedVarTypes are copied
diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
index 1e2a5865..854f6582 100644
--- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
+++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp
@@ -23,6 +23,7 @@
#include "SPIRVShaderResources.h"
#include "spirv_cross.hpp"
+#include "ShaderBase.h"
namespace Diligent
{
@@ -73,7 +74,12 @@ SPIRVShaderResourceAttribs::SPIRVShaderResourceAttribs(const spirv_cross::Compil
{
}
-SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator &Allocator, SHADER_TYPE ShaderType, std::vector<uint32_t> spirv_binary) :
+SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator &Allocator,
+ SHADER_TYPE ShaderType,
+ std::vector<uint32_t> spirv_binary,
+ SHADER_VARIABLE_TYPE DefaultVariableType,
+ const ShaderVariableDesc *VariableDesc,
+ Uint32 NumVars) :
m_MemoryBuffer(nullptr, STDDeleterRawMem<void>(Allocator)),
m_ShaderType(ShaderType)
{
@@ -95,37 +101,44 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator &Allocator, SHADER_T
Uint32 CurrUB = 0, CurrSB = 0, CurrImg = 0, CurrSmplImg = 0, CurrAC = 0, CurrSepImg = 0, CurrSepSmpl = 0;
for (const auto &UB : resources.uniform_buffers)
{
- new (&GetUB(CurrUB++)) SPIRVShaderResourceAttribs(Compiler, UB, SPIRVShaderResourceAttribs::ResourceType::UniformBuffer, SHADER_VARIABLE_TYPE_STATIC);
+ auto VarType = GetShaderVariableType(UB.name.c_str(), DefaultVariableType, VariableDesc, NumVars);
+ new (&GetUB(CurrUB++)) SPIRVShaderResourceAttribs(Compiler, UB, SPIRVShaderResourceAttribs::ResourceType::UniformBuffer, VarType);
}
for (const auto &SB : resources.storage_buffers)
{
- new (&GetSB(CurrSB++)) SPIRVShaderResourceAttribs(Compiler, SB, SPIRVShaderResourceAttribs::ResourceType::StorageBuffer, SHADER_VARIABLE_TYPE_STATIC);
+ auto VarType = GetShaderVariableType(SB.name.c_str(), DefaultVariableType, VariableDesc, NumVars);
+ new (&GetSB(CurrSB++)) SPIRVShaderResourceAttribs(Compiler, SB, SPIRVShaderResourceAttribs::ResourceType::StorageBuffer, VarType);
}
for (const auto &SmplImg : resources.sampled_images)
{
- new (&GetSmplImg(CurrSmplImg++)) SPIRVShaderResourceAttribs(Compiler, SmplImg, SPIRVShaderResourceAttribs::ResourceType::SampledImage, SHADER_VARIABLE_TYPE_STATIC);
+ auto VarType = GetShaderVariableType(SmplImg.name.c_str(), DefaultVariableType, VariableDesc, NumVars);
+ new (&GetSmplImg(CurrSmplImg++)) SPIRVShaderResourceAttribs(Compiler, SmplImg, SPIRVShaderResourceAttribs::ResourceType::SampledImage, VarType);
}
for (const auto &Img : resources.storage_images)
{
- new (&GetImg(CurrImg++)) SPIRVShaderResourceAttribs(Compiler, Img, SPIRVShaderResourceAttribs::ResourceType::StorageImage, SHADER_VARIABLE_TYPE_STATIC);
+ auto VarType = GetShaderVariableType(Img.name.c_str(), DefaultVariableType, VariableDesc, NumVars);
+ new (&GetImg(CurrImg++)) SPIRVShaderResourceAttribs(Compiler, Img, SPIRVShaderResourceAttribs::ResourceType::StorageImage, VarType);
}
for (const auto &AC : resources.atomic_counters)
{
- new (&GetAC(CurrAC++)) SPIRVShaderResourceAttribs(Compiler, AC, SPIRVShaderResourceAttribs::ResourceType::AtomicCounter, SHADER_VARIABLE_TYPE_STATIC);
+ auto VarType = GetShaderVariableType(AC.name.c_str(), DefaultVariableType, VariableDesc, NumVars);
+ new (&GetAC(CurrAC++)) SPIRVShaderResourceAttribs(Compiler, AC, SPIRVShaderResourceAttribs::ResourceType::AtomicCounter, VarType);
}
for (const auto &SepImg : resources.separate_images)
{
- new (&GetSepImg(CurrSepImg++)) SPIRVShaderResourceAttribs(Compiler, SepImg, SPIRVShaderResourceAttribs::ResourceType::SeparateImage, SHADER_VARIABLE_TYPE_STATIC);
+ auto VarType = GetShaderVariableType(SepImg.name.c_str(), DefaultVariableType, VariableDesc, NumVars);
+ new (&GetSepImg(CurrSepImg++)) SPIRVShaderResourceAttribs(Compiler, SepImg, SPIRVShaderResourceAttribs::ResourceType::SeparateImage, VarType);
}
for (const auto &SepSam : resources.separate_samplers)
{
- new (&GetSepSmpl(CurrSepSmpl++)) SPIRVShaderResourceAttribs(Compiler, SepSam, SPIRVShaderResourceAttribs::ResourceType::SeparateSampler, SHADER_VARIABLE_TYPE_STATIC);
+ auto VarType = GetShaderVariableType(SepSam.name.c_str(), DefaultVariableType, VariableDesc, NumVars);
+ new (&GetSepSmpl(CurrSepSmpl++)) SPIRVShaderResourceAttribs(Compiler, SepSam, SPIRVShaderResourceAttribs::ResourceType::SeparateSampler, VarType);
}
VERIFY_EXPR(CurrUB == GetNumUBs());