17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-12 01:48:14 +01:00

feat(vulkan): vulkan 1.4 core with the user interface and the launcher, shaders split into ogl46/vk14 with SPIR-V binaries loaded first

This commit is contained in:
2026-10-24 05:47:11 +02:00
parent 68fa5dc2da
commit bd589f272d
235 changed files with 9397 additions and 3975 deletions

32
shaders/vk14/common.glsl Normal file
View File

@@ -0,0 +1,32 @@
// what the shaders of the vulkan 1.4 renderer share: the bindings of rendering/vulkan14/vulkan14bindings.h and the settings.
// compiled by the game, the bindings come from the renderer (vk14::binding_preamble()) and are taken instead of these; the
// SPIR-V binaries (shaders/vk14bin) are compiled with the values written here, so they have to stay the same as in the game,
// which checks them when it starts (and doesn't load the binaries when they differ)
#ifndef COMMON_GLSL
#define COMMON_GLSL
#if !defined(STAGE_VERTEX) && !defined(STAGE_FRAGMENT) && !defined(STAGE_GEOMETRY) && !defined(STAGE_COMPUTE)
#error "the stage of the shader isn't defined: #define STAGE_VERTEX 1 (STAGE_FRAGMENT, STAGE_GEOMETRY, STAGE_COMPUTE) before the include of common.glsl"
#endif
#ifndef MASZYNA_CONSTANTS
#define MASZYNA_CONSTANTS 1
#define UI_SET 0
#define UI_TEXTURE 0
#define PASS_SET 0
#define MATERIAL_SET 1
#define MATERIAL_TEXTURE_FIRST 0
#define SPEC_OUTPUT_GAMMA 0
#endif
// whether the colour written to the window is encoded by the shader (FBOUT): the window has no srgb format (gfx.shadergamma yes).
// a specialization constant, set by the renderer when it makes the pipeline
layout(constant_id = SPEC_OUTPUT_GAMMA) const bool OUTPUT_GAMMA = false;
// the colour written to the window
vec4 FBOUT(vec4 x)
{
return (OUTPUT_GAMMA ? vec4(pow(x.rgb, vec3(1.0 / 2.2)), x.a) : x);
}
#endif

18
shaders/vk14/imgui.frag Normal file
View File

@@ -0,0 +1,18 @@
#version 460 core
#define STAGE_FRAGMENT 1
// the user interface (imgui): the colour of the vertices times the texture of the draw (the font, an image, a texture), pushed
// with the draw
#include "common.glsl"
layout(location = 0) in vec2 f_uv;
layout(location = 1) in vec4 f_colour;
layout(set = UI_SET, binding = UI_TEXTURE) uniform sampler2D ui_texture;
layout(location = 0) out vec4 out_colour;
void main()
{
out_colour = FBOUT(f_colour * texture(ui_texture, f_uv));
}

27
shaders/vk14/imgui.vert Normal file
View File

@@ -0,0 +1,27 @@
#version 460 core
#define STAGE_VERTEX 1
// the user interface (imgui), drawn by vk14::imgui_backend over the image of the window
#include "common.glsl"
layout(location = 0) in vec2 v_position;
layout(location = 1) in vec2 v_uv;
layout(location = 2) in vec4 v_colour;
// the pixels of the window to the clip space
layout(push_constant) uniform ui_transform
{
vec2 scale;
vec2 translate;
} transform;
layout(location = 0) out vec2 f_uv;
layout(location = 1) out vec4 f_colour;
void main()
{
f_uv = v_uv;
// the colours of imgui are srgb; they are mixed in linear light, as the user interface of the opengl renderer does it
f_colour = vec4(pow(v_colour.rgb, vec3(2.2)), v_colour.a);
gl_Position = vec4(v_position * transform.scale + transform.translate, 0.0, 1.0);
}