From 5c4cc370bb0e063d8e12b9fff71c85fab6b0cbbd Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 3 Apr 2019 11:23:54 +0200 Subject: [PATCH] Examples: Vulkan: Added shader sources/references in the .cpp source. --- examples/example_glfw_vulkan/glsl_shader.frag | 2 +- examples/example_glfw_vulkan/glsl_shader.vert | 8 +++--- examples/imgui_impl_vulkan.cpp | 27 +++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/examples/example_glfw_vulkan/glsl_shader.frag index 313a8880..ce7e6f72 100644 --- a/examples/example_glfw_vulkan/glsl_shader.frag +++ b/examples/example_glfw_vulkan/glsl_shader.frag @@ -3,7 +3,7 @@ layout(location = 0) out vec4 fColor; layout(set=0, binding=0) uniform sampler2D sTexture; -layout(location = 0) in struct{ +layout(location = 0) in struct { vec4 Color; vec2 UV; } In; diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/examples/example_glfw_vulkan/glsl_shader.vert index 20b29082..9425365a 100644 --- a/examples/example_glfw_vulkan/glsl_shader.vert +++ b/examples/example_glfw_vulkan/glsl_shader.vert @@ -3,16 +3,16 @@ layout(location = 0) in vec2 aPos; layout(location = 1) in vec2 aUV; layout(location = 2) in vec4 aColor; -layout(push_constant) uniform uPushConstant{ +layout(push_constant) uniform uPushConstant { vec2 uScale; vec2 uTranslate; } pc; -out gl_PerVertex{ +out gl_PerVertex { vec4 gl_Position; }; -layout(location = 0) out struct{ +layout(location = 0) out struct { vec4 Color; vec2 UV; } Out; @@ -21,5 +21,5 @@ void main() { Out.Color = aColor; Out.UV = aUV; - gl_Position = vec4(aPos*pc.uScale+pc.uTranslate, 0, 1); + gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1); } diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp index 3aafb555..962ce841 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/examples/imgui_impl_vulkan.cpp @@ -76,6 +76,23 @@ static VkBuffer g_UploadBuffer = VK_NULL_HANDLE; // glsl_shader.vert, compiled with: // # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert +/* +#version 450 core +layout(location = 0) in vec2 aPos; +layout(location = 1) in vec2 aUV; +layout(location = 2) in vec4 aColor; +layout(push_constant) uniform uPushConstant { vec2 uScale; vec2 uTranslate; } pc; + +out gl_PerVertex { vec4 gl_Position; }; +layout(location = 0) out struct { vec4 Color; vec2 UV; } Out; + +void main() +{ + Out.Color = aColor; + Out.UV = aUV; + gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1); +} +*/ static uint32_t __glsl_shader_vert_spv[] = { 0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b, @@ -123,6 +140,16 @@ static uint32_t __glsl_shader_vert_spv[] = // glsl_shader.frag, compiled with: // # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag +/* +#version 450 core +layout(location = 0) out vec4 fColor; +layout(set=0, binding=0) uniform sampler2D sTexture; +layout(location = 0) in struct { vec4 Color; vec2 UV; } In; +void main() +{ + fColor = In.Color * texture(sTexture, In.UV.st); +} +*/ static uint32_t __glsl_shader_frag_spv[] = { 0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b,