vulkan: use specialization constants
This commit is contained in:
parent
218f8d7ba2
commit
cca0af3d0d
7 changed files with 58 additions and 39 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#version 450
|
||||
|
||||
#include "frag_spec_const.glsl"
|
||||
|
||||
layout(push_constant, std430) uniform Data {
|
||||
layout(offset = 32) vec4 color;
|
||||
} data;
|
||||
|
|
|
|||
1
src/gfx_apis/vulkan/shaders/frag_spec_const.glsl
Normal file
1
src/gfx_apis/vulkan/shaders/frag_spec_const.glsl
Normal file
|
|
@ -0,0 +1 @@
|
|||
layout(constant_id = 0) const bool src_has_alpha = false;
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#version 450
|
||||
|
||||
#include "frag_spec_const.glsl"
|
||||
|
||||
#ifdef ALPHA_MULTIPLIER
|
||||
layout(push_constant, std430) uniform Data {
|
||||
layout(offset = 64) float mul;
|
||||
|
|
@ -11,10 +13,11 @@ layout(location = 0) out vec4 out_color;
|
|||
|
||||
void main() {
|
||||
#ifdef ALPHA_MULTIPLIER
|
||||
#ifdef ALPHA
|
||||
out_color = textureLod(tex, tex_pos, 0) * data.mul;
|
||||
#endif // !ALPHA
|
||||
out_color = vec4(textureLod(tex, tex_pos, 0).rgb * data.mul, data.mul);
|
||||
if (src_has_alpha) {
|
||||
out_color = textureLod(tex, tex_pos, 0) * data.mul;
|
||||
} else {
|
||||
out_color = vec4(textureLod(tex, tex_pos, 0).rgb * data.mul, data.mul);
|
||||
}
|
||||
#else // !ALPHA_MULTIPLIER
|
||||
out_color = textureLod(tex, tex_pos, 0);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue