summaryrefslogtreecommitdiffstats
path: root/Imgui/src/ImGuiDiligentRenderer.cpp
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-06-29 16:14:07 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-06-29 16:14:07 +0000
commita246e44b7b46bc26ea335e51f1d56388933fb62b (patch)
tree14b76073989e3105fb34ed263a8aa5b07f3f0ed1 /Imgui/src/ImGuiDiligentRenderer.cpp
parentGLTFLoader: updated bound box calculations (diff)
downloadDiligentTools-a246e44b7b46bc26ea335e51f1d56388933fb62b.tar.gz
DiligentTools-a246e44b7b46bc26ea335e51f1d56388933fb62b.zip
Imgui renderer: using pre-compiled SPIRV shaders in Vulkan mode
Diffstat (limited to 'Imgui/src/ImGuiDiligentRenderer.cpp')
-rw-r--r--Imgui/src/ImGuiDiligentRenderer.cpp104
1 files changed, 102 insertions, 2 deletions
diff --git a/Imgui/src/ImGuiDiligentRenderer.cpp b/Imgui/src/ImGuiDiligentRenderer.cpp
index 780e5a2..61d1208 100644
--- a/Imgui/src/ImGuiDiligentRenderer.cpp
+++ b/Imgui/src/ImGuiDiligentRenderer.cpp
@@ -79,6 +79,90 @@ float4 main(in PSInput PSIn) : SV_Target
}
)";
+// clang-format off
+
+// glslangValidator.exe -fhlsl_functionality1 -V -e main --vn VertexShader_SPIRV ImGUI.vert.hlsl
+
+static const uint32_t VertexShader_SPIRV[] =
+{
+ 0x07230203,0x00010000,0x0008000a,0x00000054,0x00000000,0x00020011,0x00000001,0x0009000a,
+ 0x5f565053,0x474f4f47,0x685f454c,0x5f6c736c,0x636e7566,0x6e6f6974,0x74696c61,0x00003179,
+ 0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,
+ 0x00000001,0x000b000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000030,0x00000033,
+ 0x00000037,0x00000041,0x00000044,0x00000048,0x00030003,0x00000005,0x000001f4,0x00040005,
+ 0x00000004,0x6e69616d,0x00000000,0x00050005,0x0000001d,0x736e6f43,0x746e6174,0x00000073,
+ 0x00080006,0x0000001d,0x00000000,0x6a6f7250,0x69746365,0x614d6e6f,0x78697274,0x00000000,
+ 0x00030005,0x0000001f,0x00000000,0x00050005,0x00000030,0x6e495356,0x736f702e,0x00000000,
+ 0x00040005,0x00000033,0x6e495356,0x0076752e,0x00050005,0x00000037,0x6e495356,0x6c6f632e,
+ 0x00000000,0x00050005,0x00000041,0x6e495350,0x736f702e,0x00000000,0x00050005,0x00000044,
+ 0x6e495350,0x6c6f632e,0x00000000,0x00040005,0x00000048,0x6e495350,0x0076752e,0x00040048,
+ 0x0000001d,0x00000000,0x00000004,0x00050048,0x0000001d,0x00000000,0x00000023,0x00000000,
+ 0x00050048,0x0000001d,0x00000000,0x00000007,0x00000010,0x00030047,0x0000001d,0x00000002,
+ 0x00040047,0x0000001f,0x00000022,0x00000000,0x00040047,0x0000001f,0x00000021,0x00000000,
+ 0x00040047,0x00000030,0x0000001e,0x00000000,0x00051600,0x00000030,0x00001603,0x52545441,
+ 0x00304249,0x00040047,0x00000033,0x0000001e,0x00000001,0x00051600,0x00000033,0x00001603,
+ 0x52545441,0x00314249,0x00040047,0x00000037,0x0000001e,0x00000002,0x00051600,0x00000037,
+ 0x00001603,0x52545441,0x00324249,0x00040047,0x00000041,0x0000000b,0x00000000,0x00061600,
+ 0x00000041,0x00001603,0x505f5653,0x5449534f,0x004e4f49,0x00040047,0x00000044,0x0000001e,
+ 0x00000000,0x00051600,0x00000044,0x00001603,0x4f4c4f43,0x00000052,0x00040047,0x00000048,
+ 0x0000001e,0x00000001,0x00061600,0x00000048,0x00001603,0x43584554,0x44524f4f,0x00000000,
+ 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,
+ 0x00040017,0x00000007,0x00000006,0x00000002,0x00040017,0x00000008,0x00000006,0x00000004,
+ 0x00040015,0x00000012,0x00000020,0x00000001,0x0004002b,0x00000012,0x00000013,0x00000000,
+ 0x0004002b,0x00000006,0x00000017,0x00000000,0x0004002b,0x00000006,0x00000018,0x3f800000,
+ 0x00040018,0x0000001c,0x00000008,0x00000004,0x0003001e,0x0000001d,0x0000001c,0x00040020,
+ 0x0000001e,0x00000002,0x0000001d,0x0004003b,0x0000001e,0x0000001f,0x00000002,0x00040020,
+ 0x00000020,0x00000002,0x0000001c,0x00040020,0x0000002f,0x00000001,0x00000007,0x0004003b,
+ 0x0000002f,0x00000030,0x00000001,0x0004003b,0x0000002f,0x00000033,0x00000001,0x00040020,
+ 0x00000036,0x00000001,0x00000008,0x0004003b,0x00000036,0x00000037,0x00000001,0x00040020,
+ 0x00000040,0x00000003,0x00000008,0x0004003b,0x00000040,0x00000041,0x00000003,0x0004003b,
+ 0x00000040,0x00000044,0x00000003,0x00040020,0x00000047,0x00000003,0x00000007,0x0004003b,
+ 0x00000047,0x00000048,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,
+ 0x000200f8,0x00000005,0x0004003d,0x00000007,0x00000031,0x00000030,0x0004003d,0x00000007,
+ 0x00000034,0x00000033,0x0004003d,0x00000008,0x00000038,0x00000037,0x00050051,0x00000006,
+ 0x0000004e,0x00000031,0x00000000,0x00050051,0x00000006,0x0000004f,0x00000031,0x00000001,
+ 0x00070050,0x00000008,0x00000050,0x0000004e,0x0000004f,0x00000017,0x00000018,0x00050041,
+ 0x00000020,0x00000051,0x0000001f,0x00000013,0x0004003d,0x0000001c,0x00000052,0x00000051,
+ 0x00050090,0x00000008,0x00000053,0x00000050,0x00000052,0x0003003e,0x00000041,0x00000053,
+ 0x0003003e,0x00000044,0x00000038,0x0003003e,0x00000048,0x00000034,0x000100fd,0x00010038
+};
+
+static const uint32_t FragmentShader_SPIRV[] =
+{
+ 0x07230203, 0x00010000, 0x0008000a, 0x00000043, 0x00000000, 0x00020011, 0x00000001, 0x0009000a,
+ 0x5f565053, 0x474f4f47, 0x685f454c, 0x5f6c736c, 0x636e7566, 0x6e6f6974, 0x74696c61, 0x00003179,
+ 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000,
+ 0x00000001, 0x0009000f, 0x00000004, 0x00000004, 0x6e69616d, 0x00000000, 0x00000029, 0x0000002c,
+ 0x00000030, 0x00000034, 0x00030010, 0x00000004, 0x00000007, 0x00030003, 0x00000005, 0x000001f4,
+ 0x00040005, 0x00000004, 0x6e69616d, 0x00000000, 0x00040005, 0x00000016, 0x74786554, 0x00657275,
+ 0x00060005, 0x0000001a, 0x74786554, 0x5f657275, 0x706d6173, 0x0072656c, 0x00050005, 0x00000029,
+ 0x6e495350, 0x736f702e, 0x00000000, 0x00050005, 0x0000002c, 0x6e495350, 0x6c6f632e, 0x00000000,
+ 0x00040005, 0x00000030, 0x6e495350, 0x0076752e, 0x00070005, 0x00000034, 0x746e6540, 0x6f507972,
+ 0x4f746e69, 0x75707475, 0x00000074, 0x00040047, 0x00000016, 0x00000022, 0x00000000, 0x00040047,
+ 0x00000016, 0x00000021, 0x00000000, 0x00040047, 0x0000001a, 0x00000022, 0x00000000, 0x00040047,
+ 0x0000001a, 0x00000021, 0x00000000, 0x00040047, 0x00000029, 0x0000000b, 0x0000000f, 0x00061600,
+ 0x00000029, 0x00001603, 0x505f5653, 0x5449534f, 0x004e4f49, 0x00040047, 0x0000002c, 0x0000001e,
+ 0x00000000, 0x00051600, 0x0000002c, 0x00001603, 0x4f4c4f43, 0x00000052, 0x00040047, 0x00000030,
+ 0x0000001e, 0x00000001, 0x00061600, 0x00000030, 0x00001603, 0x43584554, 0x44524f4f, 0x00000000,
+ 0x00040047, 0x00000034, 0x0000001e, 0x00000000, 0x00061600, 0x00000034, 0x00001603, 0x545f5653,
+ 0x45475241, 0x00000054, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016,
+ 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000004, 0x00040017, 0x00000008,
+ 0x00000006, 0x00000002, 0x00090019, 0x00000014, 0x00000006, 0x00000001, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000000, 0x00040020, 0x00000015, 0x00000000, 0x00000014, 0x0004003b,
+ 0x00000015, 0x00000016, 0x00000000, 0x0002001a, 0x00000018, 0x00040020, 0x00000019, 0x00000000,
+ 0x00000018, 0x0004003b, 0x00000019, 0x0000001a, 0x00000000, 0x0003001b, 0x0000001c, 0x00000014,
+ 0x00040020, 0x00000028, 0x00000001, 0x00000007, 0x0004003b, 0x00000028, 0x00000029, 0x00000001,
+ 0x0004003b, 0x00000028, 0x0000002c, 0x00000001, 0x00040020, 0x0000002f, 0x00000001, 0x00000008,
+ 0x0004003b, 0x0000002f, 0x00000030, 0x00000001, 0x00040020, 0x00000033, 0x00000003, 0x00000007,
+ 0x0004003b, 0x00000033, 0x00000034, 0x00000003, 0x00050036, 0x00000002, 0x00000004, 0x00000000,
+ 0x00000003, 0x000200f8, 0x00000005, 0x0004003d, 0x00000007, 0x0000002d, 0x0000002c, 0x0004003d,
+ 0x00000008, 0x00000031, 0x00000030, 0x0004003d, 0x00000014, 0x0000003c, 0x00000016, 0x0004003d,
+ 0x00000018, 0x0000003d, 0x0000001a, 0x00050056, 0x0000001c, 0x0000003e, 0x0000003c, 0x0000003d,
+ 0x00050057, 0x00000007, 0x00000041, 0x0000003e, 0x00000031, 0x00050085, 0x00000007, 0x00000042,
+ 0x0000002d, 0x00000041, 0x0003003e, 0x00000034, 0x00000042, 0x000100fd, 0x00010038
+};
+// clang-format on
+
ImGuiDiligentRenderer::ImGuiDiligentRenderer(IRenderDevice* pDevice,
TEXTURE_FORMAT BackBufferFmt,
TEXTURE_FORMAT DepthBufferFmt,
@@ -142,7 +226,15 @@ void ImGuiDiligentRenderer::CreateDeviceObjects()
{
ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX;
ShaderCI.Desc.Name = "Imgui VS";
- ShaderCI.Source = VertexShaderSource;
+ if (m_pDevice->GetDeviceCaps().IsVulkanDevice())
+ {
+ ShaderCI.ByteCode = VertexShader_SPIRV;
+ ShaderCI.ByteCodeSize = sizeof(VertexShader_SPIRV);
+ }
+ else
+ {
+ ShaderCI.Source = VertexShaderSource;
+ }
m_pDevice->CreateShader(ShaderCI, &pVS);
}
@@ -150,7 +242,15 @@ void ImGuiDiligentRenderer::CreateDeviceObjects()
{
ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL;
ShaderCI.Desc.Name = "Imgui PS";
- ShaderCI.Source = PixelShaderSource;
+ if (m_pDevice->GetDeviceCaps().IsVulkanDevice())
+ {
+ ShaderCI.ByteCode = FragmentShader_SPIRV;
+ ShaderCI.ByteCodeSize = sizeof(FragmentShader_SPIRV);
+ }
+ else
+ {
+ ShaderCI.Source = PixelShaderSource;
+ }
m_pDevice->CreateShader(ShaderCI, &pPS);
}