Remove braces around shader source strings (warnings)

This commit is contained in:
JohnHolmesII 2019-04-05 23:48:58 -07:00 committed by Nekotekina
parent d0eae7bab1
commit a124ec4a26
3 changed files with 23 additions and 69 deletions

View File

@ -277,7 +277,6 @@ namespace gl
depth_convert_pass()
{
vs_src =
{
"#version 420\n\n"
"uniform vec2 tex_scale;\n"
"out vec2 tc0;\n"
@ -288,11 +287,9 @@ namespace gl
" vec2 coords[] = {vec2(0., 0.), vec2(1., 0.), vec2(0., 1.), vec2(1., 1.)};\n"
" gl_Position = vec4(positions[gl_VertexID % 4], 0., 1.);\n"
" tc0 = coords[gl_VertexID % 4] * tex_scale;\n"
"}\n"
};
"}\n";
fs_src =
{
"#version 420\n\n"
"in vec2 tc0;\n"
"layout(binding=31) uniform sampler2D fs0;\n"
@ -301,8 +298,7 @@ namespace gl
"{\n"
" vec4 rgba_in = texture(fs0, tc0);\n"
" gl_FragDepth = rgba_in.w * 0.99609 + rgba_in.x * 0.00389 + rgba_in.y * 0.00002;\n"
"}\n"
};
"}\n";
}
void run(const areai& src_area, const areai& dst_area, gl::texture* source, gl::texture* target)
@ -325,18 +321,15 @@ namespace gl
rgba8_unorm_rg16_sfloat_convert_pass()
{
vs_src =
{
"#version 420\n\n"
"\n"
"void main()\n"
"{\n"
" vec2 positions[] = {vec2(-1., -1.), vec2(1., -1.), vec2(-1., 1.), vec2(1., 1.)};\n"
" gl_Position = vec4(positions[gl_VertexID % 4], 0., 1.);\n"
"}\n"
};
"}\n";
fs_src =
{
"#version 420\n\n"
"layout(binding=31) uniform sampler2D fs0;\n"
"layout(location=0) out vec4 ocol;\n"
@ -345,8 +338,7 @@ namespace gl
"{\n"
" uint value = packUnorm4x8(texelFetch(fs0, ivec2(gl_FragCoord.xy), 0).zyxw);\n"
" ocol.xy = unpackHalf2x16(value);\n"
"}\n"
};
"}\n";
}
void run(u16 w, u16 h, GLuint target, GLuint source)
@ -371,7 +363,6 @@ namespace gl
ui_overlay_renderer()
{
vs_src =
{
"#version 420\n\n"
"layout(location=0) in vec4 in_pos;\n"
"layout(location=0) out vec2 tc0;\n"
@ -396,11 +387,9 @@ namespace gl
" window_coord.y = (1. - window_coord.y); // Invert y axis\n"
" vec4 pos = vec4(window_coord, 0., 1.);\n"
" gl_Position = (pos + pos) - 1.;\n"
"}\n"
};
"}\n";
fs_src =
{
"#version 420\n\n"
"layout(binding=31) uniform sampler2D fs0;\n"
"layout(location=0) in vec2 tc0;\n"
@ -482,8 +471,7 @@ namespace gl
" ocol = sample_image(fs0, tc0) * diff_color;\n"
" else\n"
" ocol = diff_color;\n"
"}\n"
};
"}\n";
// Smooth filtering required for inputs
input_filter = GL_LINEAR;
@ -682,7 +670,6 @@ namespace gl
video_out_calibration_pass()
{
vs_src =
{
"#version 420\n\n"
"layout(location=0) out vec2 tc0;\n"
"uniform float x_scale;\n"
@ -697,11 +684,9 @@ namespace gl
" tc0 = coords[gl_VertexID % 4];\n"
" vec2 pos = positions[gl_VertexID % 4] * vec2(x_scale, y_scale) + (2. * vec2(x_offset, y_offset));\n"
" gl_Position = vec4(pos, 0., 1.);\n"
"}\n"
};
"}\n";
fs_src =
{
"#version 420\n\n"
"layout(binding=31) uniform sampler2D fs0;\n"
"layout(location=0) in vec2 tc0;\n"
@ -718,8 +703,7 @@ namespace gl
" ocol = ((color * 220.) + 16.) / 255.;\n"
" else\n"
" ocol = color;\n"
"}\n"
};
"}\n";
input_filter = GL_LINEAR;
}

View File

@ -205,20 +205,14 @@ namespace vk
cs_shuffle_base()
{
work_kernel =
{
" value = data[index];\n"
" data[index] = %f(value);\n"
};
" data[index] = %f(value);\n";
loop_advance =
{
" index++;\n"
};
" index++;\n";
suffix =
{
"}\n"
};
"}\n";
}
void build(const char* function_name, u32 _kernel_size = 0)
@ -229,7 +223,6 @@ namespace vk
kernel_size = _kernel_size? _kernel_size : optimal_kernel_size;
m_src =
{
"#version 430\n"
"layout(local_size_x=%ws, local_size_y=1, local_size_z=1) in;\n"
"layout(std430, set=0, binding=0) buffer ssbo{ uint data[]; };\n"
@ -254,8 +247,7 @@ namespace vk
" uint index = gl_GlobalInvocationID.x * KERNEL_SIZE;\n"
" uint value;\n"
" %vars"
"\n"
};
"\n";
const std::pair<std::string, std::string> syntax_replace[] =
{
@ -413,15 +405,13 @@ namespace vk
uniform_inputs = true;
variables =
{
" uint block_length = params[0].x >> 2;\n"
" uint z_offset = params[0].y >> 2;\n"
" uint s_offset = params[0].z >> 2;\n"
" uint depth;\n"
" uint stencil;\n"
" uint stencil_shift;\n"
" uint stencil_offset;\n"
};
" uint stencil_offset;\n";
}
void bind_resources() override
@ -450,7 +440,6 @@ namespace vk
cs_gather_d24x8()
{
work_kernel =
{
" if (index >= block_length)\n"
" return;\n"
"\n"
@ -460,8 +449,7 @@ namespace vk
" stencil = data[stencil_offset + s_offset];\n"
" stencil = (stencil >> stencil_shift) & 0xFF;\n"
" value = (depth << 8) | stencil;\n"
" data[index] = value;\n"
};
" data[index] = value;\n";
cs_shuffle_base::build("");
}
@ -472,7 +460,6 @@ namespace vk
cs_gather_d32x8()
{
work_kernel =
{
" if (index >= block_length)\n"
" return;\n"
"\n"
@ -482,8 +469,7 @@ namespace vk
" stencil = data[stencil_offset + s_offset];\n"
" stencil = (stencil >> stencil_shift) & 0xFF;\n"
" value = (depth << 8) | stencil;\n"
" data[index] = value;\n"
};
" data[index] = value;\n";
cs_shuffle_base::build("");
}
@ -494,7 +480,6 @@ namespace vk
cs_scatter_d24x8()
{
work_kernel =
{
" if (index >= block_length)\n"
" return;\n"
"\n"
@ -503,8 +488,7 @@ namespace vk
" stencil_offset = (index / 4);\n"
" stencil_shift = (index % 4) * 8;\n"
" stencil = (value & 0xFF) << stencil_shift;\n"
" data[stencil_offset + s_offset] |= stencil;\n"
};
" data[stencil_offset + s_offset] |= stencil;\n";
cs_shuffle_base::build("");
}
@ -515,7 +499,6 @@ namespace vk
cs_scatter_d32x8()
{
work_kernel =
{
" if (index >= block_length)\n"
" return;\n"
"\n"
@ -524,8 +507,7 @@ namespace vk
" stencil_offset = (index / 4);\n"
" stencil_shift = (index % 4) * 8;\n"
" stencil = (value & 0xFF) << stencil_shift;\n"
" data[stencil_offset + s_offset] |= stencil;\n"
};
" data[stencil_offset + s_offset] |= stencil;\n";
cs_shuffle_base::build("");
}

View File

@ -384,7 +384,6 @@ namespace vk
depth_convert_pass()
{
vs_src =
{
"#version 450\n"
"#extension GL_ARB_separate_shader_objects : enable\n"
"layout(std140, set=0, binding=0) uniform static_data{ vec4 regs[8]; };\n"
@ -396,11 +395,9 @@ namespace vk
" vec2 coords[] = {vec2(0., 0.), vec2(1., 0.), vec2(0., 1.), vec2(1., 1.)};\n"
" gl_Position = vec4(positions[gl_VertexIndex % 4], 0., 1.);\n"
" tc0 = coords[gl_VertexIndex % 4] * regs[0].xy;\n"
"}\n"
};
"}\n";
fs_src =
{
"#version 420\n"
"#extension GL_ARB_separate_shader_objects : enable\n"
"#extension GL_ARB_shader_stencil_export : enable\n\n"
@ -411,8 +408,7 @@ namespace vk
"{\n"
" vec4 rgba_in = texture(fs0, tc0);\n"
" gl_FragDepth = rgba_in.w * 0.99609 + rgba_in.x * 0.00389 + rgba_in.y * 0.00002;\n"
"}\n"
};
"}\n";
renderpass_config.set_depth_mask(true);
renderpass_config.enable_depth_test(VK_COMPARE_OP_ALWAYS);
@ -463,7 +459,6 @@ namespace vk
ui_overlay_renderer()
{
vs_src =
{
"#version 450\n"
"#extension GL_ARB_separate_shader_objects : enable\n"
"layout(location=0) in vec4 in_pos;\n"
@ -490,11 +485,9 @@ namespace vk
" vec4 pos = vec4((in_pos.xy * regs[0].zw) / regs[0].xy, 0.5, 1.);\n"
" pos.xy = snap_to_grid(pos.xy);\n"
" gl_Position = (pos + pos) - 1.;\n"
"}\n"
};
"}\n";
fs_src =
{
"#version 420\n"
"#extension GL_ARB_separate_shader_objects : enable\n"
"layout(set=0, binding=1) uniform sampler2D fs0;\n"
@ -576,8 +569,7 @@ namespace vk
" ocol = texture(fs0, tc0).rrrr * diff_color;\n"
" else\n"
" ocol = sample_image(fs0, tc0, parameters2.x).bgra * diff_color;\n"
"}\n"
};
"}\n";
renderpass_config.set_attachment_count(1);
renderpass_config.set_color_mask(true, true, true, true);
@ -823,7 +815,6 @@ namespace vk
attachment_clear_pass()
{
vs_src =
{
"#version 450\n"
"#extension GL_ARB_separate_shader_objects : enable\n"
"layout(push_constant) uniform static_data{ vec4 regs[2]; };\n"
@ -839,11 +830,9 @@ namespace vk
" color = regs[0];\n"
" mask = regs[1];\n"
" gl_Position = vec4(positions[gl_VertexIndex % 4], 0., 1.);\n"
"}\n"
};
"}\n";
fs_src =
{
"#version 420\n"
"#extension GL_ARB_separate_shader_objects : enable\n"
"layout(set=0, binding=1) uniform sampler2D fs0;\n"
@ -856,8 +845,7 @@ namespace vk
"{\n"
" vec4 original_color = texture(fs0, tc0);\n"
" out_color = mix(original_color, color, bvec4(mask));\n"
"}\n"
};
"}\n";
renderpass_config.set_depth_mask(false);
renderpass_config.set_color_mask(true, true, true, true);