Examples: Vulkan: Added shader sources/references in the .cpp source.

This commit is contained in:
omar 2019-04-03 11:23:54 +02:00
parent 8dab7ac021
commit 5c4cc370bb
3 changed files with 32 additions and 5 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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,