summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-04-15 04:08:00 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-04-15 04:08:00 +0000
commita47df897d30a8fdacc28235ab708ac4b28748eae (patch)
treea5c266a835b56a519388253abcd4a19b642db589 /Graphics/GraphicsEngineVulkan
parentAdded glslang to the project (diff)
downloadDiligentCore-a47df897d30a8fdacc28235ab708ac4b28748eae.tar.gz
DiligentCore-a47df897d30a8fdacc28235ab708ac4b28748eae.zip
Added GLSL to SPIRV shader compilation
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/CMakeLists.txt1
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp12
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp5
4 files changed, 17 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt
index bf8a78ea..5d417d8a 100644
--- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt
+++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt
@@ -158,6 +158,7 @@ set(PRIVATE_DEPENDENCIES
Common
TargetPlatform
GraphicsEngine
+ GLSLTools
)
if(PLATFORM_WIN32)
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
index 904ae379..4bd9d43d 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
@@ -47,7 +47,7 @@ class ShaderVkImpl : public ShaderBase<IShaderVk, IRenderDeviceVk>
public:
typedef ShaderBase<IShaderVk, IRenderDeviceVk> TShaderBase;
- ShaderVkImpl(IReferenceCounters *pRefCounters, class RenderDeviceVkImpl *pRenderDeviceVk, const ShaderCreationAttribs &ShaderCreationAttribs);
+ ShaderVkImpl(IReferenceCounters *pRefCounters, class RenderDeviceVkImpl *pRenderDeviceVk, const ShaderCreationAttribs &CreationAttribs);
~ShaderVkImpl();
//virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override;
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
index 0b96448c..d012b1bc 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
@@ -26,6 +26,8 @@
#include "ShaderVkImpl.h"
#include "RenderDeviceVkImpl.h"
#include "DataBlobImpl.h"
+#include "GLSLSourceBuilder.h"
+#include "GLSL2SPIRV.h"
//#include "D3DShaderResourceLoader.h"
using namespace Diligent;
@@ -34,13 +36,19 @@ namespace Diligent
{
-ShaderVkImpl::ShaderVkImpl(IReferenceCounters *pRefCounters, RenderDeviceVkImpl *pRenderDeviceVk, const ShaderCreationAttribs &ShaderCreationAttribs) :
- TShaderBase(pRefCounters, pRenderDeviceVk, ShaderCreationAttribs.Desc)/*,
+ShaderVkImpl::ShaderVkImpl(IReferenceCounters *pRefCounters, RenderDeviceVkImpl *pRenderDeviceVk, const ShaderCreationAttribs &CreationAttribs) :
+ TShaderBase(pRefCounters, pRenderDeviceVk, CreationAttribs.Desc)/*,
ShaderD3DBase(ShaderCreationAttribs),
m_StaticResLayout(*this, GetRawAllocator()),
m_DummyShaderVar(*this),
m_ConstResCache(ShaderResourceCacheVk::DbgCacheContentType::StaticShaderResources)*/
{
+ auto GLSLSource = BuildGLSLSourceString(CreationAttribs);
+ auto SPIRV = GLSLtoSPIRV(m_Desc.ShaderType, GLSLSource.c_str());
+ if(SPIRV.empty())
+ {
+ LOG_ERROR_AND_THROW("Failed to compile shader");
+ }
/*
// Load shader resources
auto &Allocator = GetRawAllocator();
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
index a47c0ec0..a8e34a82 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
@@ -26,6 +26,7 @@
#include "VulkanErrors.h"
#include "VulkanUtilities/VulkanInstance.h"
#include "VulkanUtilities/VulkanDebug.h"
+#include "GLSL2SPIRV.h"
namespace VulkanUtilities
{
@@ -186,6 +187,8 @@ namespace VulkanUtilities
CHECK_VK_ERROR(err, "Failed to enumerate physical devices");
VERIFY_EXPR(m_PhysicalDevices.size() == PhysicalDeviceCount);
}
+
+ Diligent::InitializeGlslang();
}
VulkanInstance::~VulkanInstance()
@@ -195,6 +198,8 @@ namespace VulkanUtilities
VulkanUtilities::FreeDebugCallback(m_VkInstance);
}
vkDestroyInstance(m_VkInstance, m_pVkAllocator);
+
+ Diligent::FinalizeGlslang();
}
VkPhysicalDevice VulkanInstance::SelectPhysicalDevice()