Compile shaders in the CI, to validate that their syntax is correct (#1427)

* Move to glslang's convention for shader file suffix

* Update ci.yml

* Oops, a mistake in the shader, how could that happen?

* Does the command error on its own?

* Update ci.yml

* Revert "Oops, a mistake in the shader, how could that happen?"

This reverts commit 869c3323f3d3b5fa607b40e7847c389a12b01f33.

* Update ci.yml
This commit is contained in:
IntegratedQuantum 2025-05-10 12:32:51 +02:00 committed by GitHub
parent 102a60ad30
commit c04819c5af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
59 changed files with 55 additions and 54 deletions

View File

@ -17,12 +17,13 @@ jobs:
- uses: mlugg/setup-zig@v1
with:
version: 0.14.0
- run: sudo apt install libgl-dev libasound2-dev libx11-dev
- run: sudo apt install libgl-dev libasound2-dev libx11-dev glslang-tools
- run: wget -O /opt/hostedtoolcache/zig/0.14.0/x64/lib/std/zig/render.zig https://github.com/PixelGuys/Cubyz-std-lib/releases/download/0.14.0/render.zig
- run: zig build
- run: zig build -Dtarget=x86_64-windows-gnu
- run: zig build test
- run: zig build format --summary none
- run: find assets/cubyz/shaders -type f | xargs -L1 glslangValidator -G100
- run: |
if zig build fmt -- *.zig src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig src/*/*/*/*/*.zig src/*/*/*/*/*/*.zig src/*/*/*/*/*/*/*.zig src/*/*/*/*/*/*/*/*.zig src/*/*/*/*/*/*/*/*/*.zig src/*/*/*/*/*/*/*/*/*/*.zig | grep -q . ; then
git diff --color=always;

View File

@ -465,7 +465,7 @@ pub const meshes = struct { // MARK: meshes
const emptyImage = Image{.width = 1, .height = 1, .imageData = emptyTexture[0..]};
pub fn init() void {
animationComputePipeline = graphics.ComputePipeline.init("assets/cubyz/shaders/animation_pre_processing.glsl", "", &animationUniforms);
animationComputePipeline = graphics.ComputePipeline.init("assets/cubyz/shaders/animation_pre_processing.comp", "", &animationUniforms);
blockTextureArray = .init();
emissionTextureArray = .init();
reflectivityAndAbsorptionTextureArray = .init();

View File

@ -101,8 +101,8 @@ pub const ClientEntityManager = struct {
pub fn init() void {
entities = .init();
pipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/entity_vertex.vs",
"assets/cubyz/shaders/entity_fragment.fs",
"assets/cubyz/shaders/entity_vertex.vert",
"assets/cubyz/shaders/entity_fragment.frag",
"",
&uniforms,
.{},

View File

@ -78,7 +78,7 @@ fn checkDirectory(dir: std.fs.Dir) !void {
std.log.err("File name should end with .zig.zon so it gets syntax highlighting on github.", .{});
failed = true;
}
if(child.kind == .file and (std.mem.endsWith(u8, child.basename, ".vs") or std.mem.endsWith(u8, child.basename, ".fs") or std.mem.endsWith(u8, child.basename, ".glsl"))) {
if(child.kind == .file and (std.mem.endsWith(u8, child.basename, ".vert") or std.mem.endsWith(u8, child.basename, ".frag") or std.mem.endsWith(u8, child.basename, ".comp"))) {
try checkFile(dir, child.path);
}
}

View File

@ -142,8 +142,8 @@ pub const draw = struct { // MARK: draw
fn initRect() void {
rectPipeline = Pipeline.init(
"assets/cubyz/shaders/graphics/Rect.vs",
"assets/cubyz/shaders/graphics/Rect.fs",
"assets/cubyz/shaders/graphics/Rect.vert",
"assets/cubyz/shaders/graphics/Rect.frag",
"",
&rectUniforms,
.{.cullMode = .none},
@ -205,8 +205,8 @@ pub const draw = struct { // MARK: draw
fn initRectBorder() void {
rectBorderPipeline = Pipeline.init(
"assets/cubyz/shaders/graphics/RectBorder.vs",
"assets/cubyz/shaders/graphics/RectBorder.fs",
"assets/cubyz/shaders/graphics/RectBorder.vert",
"assets/cubyz/shaders/graphics/RectBorder.frag",
"",
&rectBorderUniforms,
.{.cullMode = .none},
@ -276,8 +276,8 @@ pub const draw = struct { // MARK: draw
fn initLine() void {
linePipeline = Pipeline.init(
"assets/cubyz/shaders/graphics/Line.vs",
"assets/cubyz/shaders/graphics/Line.fs",
"assets/cubyz/shaders/graphics/Line.vert",
"assets/cubyz/shaders/graphics/Line.frag",
"",
&lineUniforms,
.{.cullMode = .none},
@ -383,8 +383,8 @@ pub const draw = struct { // MARK: draw
fn initCircle() void {
circlePipeline = Pipeline.init(
"assets/cubyz/shaders/graphics/Circle.vs",
"assets/cubyz/shaders/graphics/Circle.fs",
"assets/cubyz/shaders/graphics/Circle.vert",
"assets/cubyz/shaders/graphics/Circle.frag",
"",
&circleUniforms,
.{.cullMode = .none},
@ -445,8 +445,8 @@ pub const draw = struct { // MARK: draw
fn initImage() void {
imagePipeline = Pipeline.init(
"assets/cubyz/shaders/graphics/Image.vs",
"assets/cubyz/shaders/graphics/Image.fs",
"assets/cubyz/shaders/graphics/Image.vert",
"assets/cubyz/shaders/graphics/Image.frag",
"",
&imageUniforms,
.{.cullMode = .none},
@ -1133,8 +1133,8 @@ const TextRendering = struct { // MARK: TextRendering
fn init() !void {
pipeline = Pipeline.init(
"assets/cubyz/shaders/graphics/Text.vs",
"assets/cubyz/shaders/graphics/Text.fs",
"assets/cubyz/shaders/graphics/Text.vert",
"assets/cubyz/shaders/graphics/Text.frag",
"",
&uniforms,
.{.cullMode = .none},
@ -2504,8 +2504,8 @@ const block_texture = struct { // MARK: block_texture
fn init() void {
pipeline = Pipeline.init(
"assets/cubyz/shaders/item_texture_post.vs",
"assets/cubyz/shaders/item_texture_post.fs",
"assets/cubyz/shaders/item_texture_post.vert",
"assets/cubyz/shaders/item_texture_post.frag",
"",
&uniforms,
.{.cullMode = .none},

View File

@ -105,8 +105,8 @@ pub var borderUniforms: struct {
pub fn __init() void {
pipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/ui/button.vs",
"assets/cubyz/shaders/ui/button.fs",
"assets/cubyz/shaders/ui/button.vert",
"assets/cubyz/shaders/ui/button.frag",
"",
&windowUniforms,
.{.cullMode = .none},
@ -114,8 +114,8 @@ pub fn __init() void {
.{.attachments = &.{.alphaBlending}},
);
borderPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/ui/window_border.vs",
"assets/cubyz/shaders/ui/window_border.fs",
"assets/cubyz/shaders/ui/window_border.vert",
"assets/cubyz/shaders/ui/window_border.frag",
"",
&borderUniforms,
.{.cullMode = .none},

View File

@ -61,8 +61,8 @@ child: GuiComponent,
pub fn __init() void {
pipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/ui/button.vs",
"assets/cubyz/shaders/ui/button.fs",
"assets/cubyz/shaders/ui/button.vert",
"assets/cubyz/shaders/ui/button.frag",
"",
&buttonUniforms,
.{.cullMode = .none},

View File

@ -34,8 +34,8 @@ var uniforms: struct {
pub fn init() void {
pipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/graphics/Image.vs",
"assets/cubyz/shaders/graphics/Image.fs",
"assets/cubyz/shaders/graphics/Image.vert",
"assets/cubyz/shaders/graphics/Image.frag",
"",
&uniforms,
.{.cullMode = .none},

View File

@ -42,8 +42,8 @@ var uniforms: struct {
pub fn init() void {
ssbo = graphics.SSBO.init();
pipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/graphics/graph.vs",
"assets/cubyz/shaders/graphics/graph.fs",
"assets/cubyz/shaders/graphics/graph.vert",
"assets/cubyz/shaders/graphics/graph.frag",
"",
&uniforms,
.{.cullMode = .none},

View File

@ -649,8 +649,8 @@ pub const ItemDropRenderer = struct { // MARK: ItemDropRenderer
pub fn init() void {
itemPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/item_drop.vs",
"assets/cubyz/shaders/item_drop.fs",
"assets/cubyz/shaders/item_drop.vert",
"assets/cubyz/shaders/item_drop.frag",
"",
&itemUniforms,
.{},

View File

@ -61,8 +61,8 @@ var reflectionCubeMap: graphics.CubeMapTexture = undefined;
pub fn init() void {
deferredRenderPassPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/deferred_render_pass.vs",
"assets/cubyz/shaders/deferred_render_pass.fs",
"assets/cubyz/shaders/deferred_render_pass.vert",
"assets/cubyz/shaders/deferred_render_pass.frag",
"",
&deferredUniforms,
.{.cullMode = .none},
@ -70,8 +70,8 @@ pub fn init() void {
.{.attachments = &.{.noBlending}},
);
fakeReflectionPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/fake_reflection.vs",
"assets/cubyz/shaders/fake_reflection.fs",
"assets/cubyz/shaders/fake_reflection.vert",
"assets/cubyz/shaders/fake_reflection.frag",
"",
&fakeReflectionUniforms,
.{.cullMode = .none},
@ -340,8 +340,8 @@ const Bloom = struct { // MARK: Bloom
emptyBuffer = .init();
emptyBuffer.generate(graphics.Image.emptyImage);
firstPassPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/bloom/first_pass.vs",
"assets/cubyz/shaders/bloom/first_pass.fs",
"assets/cubyz/shaders/bloom/first_pass.vert",
"assets/cubyz/shaders/bloom/first_pass.frag",
"",
null,
.{.cullMode = .none},
@ -349,8 +349,8 @@ const Bloom = struct { // MARK: Bloom
.{.attachments = &.{.noBlending}},
);
secondPassPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/bloom/second_pass.vs",
"assets/cubyz/shaders/bloom/second_pass.fs",
"assets/cubyz/shaders/bloom/second_pass.vert",
"assets/cubyz/shaders/bloom/second_pass.frag",
"",
null,
.{.cullMode = .none},
@ -358,8 +358,8 @@ const Bloom = struct { // MARK: Bloom
.{.attachments = &.{.noBlending}},
);
colorExtractAndDownsamplePipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/bloom/color_extractor_downsample.vs",
"assets/cubyz/shaders/bloom/color_extractor_downsample.fs",
"assets/cubyz/shaders/bloom/color_extractor_downsample.vert",
"assets/cubyz/shaders/bloom/color_extractor_downsample.frag",
"",
&colorExtractUniforms,
.{.cullMode = .none},
@ -468,8 +468,8 @@ pub const MenuBackGround = struct {
fn init() !void {
lastTime = std.time.nanoTimestamp();
pipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/background/vertex.vs",
"assets/cubyz/shaders/background/fragment.fs",
"assets/cubyz/shaders/background/vertex.vert",
"assets/cubyz/shaders/background/fragment.frag",
"",
&uniforms,
.{.cullMode = .none},
@ -681,8 +681,8 @@ pub const Skybox = struct {
defer starColorImage.deinit(main.stackAllocator);
starPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/skybox/star.vs",
"assets/cubyz/shaders/skybox/star.fs",
"assets/cubyz/shaders/skybox/star.vert",
"assets/cubyz/shaders/skybox/star.frag",
"",
&starUniforms,
.{.cullMode = .none},
@ -853,8 +853,8 @@ pub const MeshSelection = struct { // MARK: MeshSelection
pub fn init() void {
pipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/block_selection_vertex.vs",
"assets/cubyz/shaders/block_selection_fragment.fs",
"assets/cubyz/shaders/block_selection_vertex.vert",
"assets/cubyz/shaders/block_selection_fragment.frag",
"",
&uniforms,
.{.depthBias = .{

View File

@ -75,8 +75,8 @@ pub var transparentQuadsDrawn: usize = 0;
pub fn init() void {
lighting.init();
pipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/chunks/chunk_vertex.vs",
"assets/cubyz/shaders/chunks/chunk_fragment.fs",
"assets/cubyz/shaders/chunks/chunk_vertex.vert",
"assets/cubyz/shaders/chunks/chunk_fragment.frag",
"",
&uniforms,
.{},
@ -84,8 +84,8 @@ pub fn init() void {
.{.attachments = &.{.noBlending}},
);
transparentPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/chunks/chunk_vertex.vs",
"assets/cubyz/shaders/chunks/transparent_fragment.fs",
"assets/cubyz/shaders/chunks/chunk_vertex.vert",
"assets/cubyz/shaders/chunks/transparent_fragment.frag",
"#define transparent\n",
&transparentUniforms,
.{},
@ -99,10 +99,10 @@ pub fn init() void {
.alphaBlendOp = .add,
}}},
);
commandPipeline = graphics.ComputePipeline.init("assets/cubyz/shaders/chunks/fillIndirectBuffer.glsl", "", &commandUniforms);
commandPipeline = graphics.ComputePipeline.init("assets/cubyz/shaders/chunks/fillIndirectBuffer.comp", "", &commandUniforms);
occlusionTestPipeline = graphics.Pipeline.init(
"assets/cubyz/shaders/chunks/occlusionTestVertex.vs",
"assets/cubyz/shaders/chunks/occlusionTestFragment.fs",
"assets/cubyz/shaders/chunks/occlusionTestVertex.vert",
"assets/cubyz/shaders/chunks/occlusionTestFragment.frag",
"",
&occlusionTestUniforms,
.{},