mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 00:49:19 +02:00
CI shader validation
This commit is contained in:
14
ci_shadervalidator/Globals.h
Normal file
14
ci_shadervalidator/Globals.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
struct _global
|
||||
{
|
||||
bool gfx_shadowmap_enabled;
|
||||
bool gfx_envmap_enabled;
|
||||
bool gfx_postfx_motionblur_enabled;
|
||||
bool gfx_skippipeline;
|
||||
bool gfx_extraeffects;
|
||||
bool gfx_shadergamma;
|
||||
bool gfx_usegles;
|
||||
};
|
||||
|
||||
extern _global Global;
|
||||
|
||||
8
ci_shadervalidator/Logs.h
Normal file
8
ci_shadervalidator/Logs.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
enum class logtype : unsigned int {
|
||||
shader
|
||||
};
|
||||
|
||||
inline void ErrorLog(const std::string &, logtype const)
|
||||
{
|
||||
}
|
||||
2
ci_shadervalidator/build.sh
Executable file
2
ci_shadervalidator/build.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
g++ -std=c++17 -O2 -DSHADERVALIDATOR_STANDALONE ../ref/glad/src/glad.c ../gl/glsl_common.cpp ../gl/shader.cpp main.cpp -I../ref/glad/include -I../ref/glm -I. -o validateshaders
|
||||
112
ci_shadervalidator/main.cpp
Normal file
112
ci_shadervalidator/main.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#include "stdafx.h"
|
||||
#include "../gl/shader.h"
|
||||
#include "../gl/glsl_common.h"
|
||||
#include "Globals.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
|
||||
_global Global;
|
||||
|
||||
bool check_shader(std::string filename)
|
||||
{
|
||||
gl::shader shader_processor;
|
||||
|
||||
gl::glsl_common_setup();
|
||||
std::pair<GLuint, std::string> source = shader_processor.process_source(filename, "../shaders/");
|
||||
|
||||
std::string stage;
|
||||
if (source.first == GL_VERTEX_SHADER)
|
||||
stage = "vert";
|
||||
else if (source.first == GL_FRAGMENT_SHADER)
|
||||
stage = "frag";
|
||||
else if (source.first == GL_GEOMETRY_SHADER)
|
||||
stage = "geom";
|
||||
else
|
||||
return false;
|
||||
|
||||
std::ofstream file("/tmp/shader");
|
||||
file << source.second;
|
||||
file.close();
|
||||
|
||||
int ret = system(("glslangValidator -S " + stage + " /tmp/shader").c_str());
|
||||
|
||||
return ret == 0;
|
||||
}
|
||||
|
||||
bool check_shader_allopts(std::string filename)
|
||||
{
|
||||
bool suc = true;
|
||||
|
||||
std::cout << "features on..." << std::flush;
|
||||
Global.gfx_shadowmap_enabled = true;
|
||||
Global.gfx_envmap_enabled = true;
|
||||
Global.gfx_postfx_motionblur_enabled = true;
|
||||
Global.gfx_skippipeline = false;
|
||||
Global.gfx_extraeffects = true;
|
||||
Global.gfx_shadergamma = true;
|
||||
if (!check_shader(filename))
|
||||
suc = false;
|
||||
|
||||
std::cout << "done, features off..." << std::flush;
|
||||
Global.gfx_shadowmap_enabled = false;
|
||||
Global.gfx_envmap_enabled = false;
|
||||
Global.gfx_postfx_motionblur_enabled = false;
|
||||
Global.gfx_skippipeline = true;
|
||||
Global.gfx_extraeffects = false;
|
||||
Global.gfx_shadergamma = false;
|
||||
if (!check_shader(filename))
|
||||
suc = false;
|
||||
|
||||
std::cout << "done" << std::flush;
|
||||
|
||||
return suc;
|
||||
}
|
||||
|
||||
|
||||
bool check_shader_confs(std::string filename)
|
||||
{
|
||||
bool suc = true;
|
||||
|
||||
std::cout << "desktop GL: " << std::flush;
|
||||
Global.gfx_usegles = false;
|
||||
if (!check_shader_allopts(filename))
|
||||
suc = false;
|
||||
|
||||
std::cout << "; GLES: " << std::flush;
|
||||
GLAD_GL_ES_VERSION_3_1 = 1;
|
||||
Global.gfx_usegles = true;
|
||||
if (!check_shader_allopts(filename))
|
||||
suc = false;
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
return suc;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
bool suc = true;
|
||||
for (auto &f : std::filesystem::recursive_directory_iterator("../shaders/")) {
|
||||
if (!f.is_regular_file())
|
||||
continue;
|
||||
|
||||
std::string relative = std::filesystem::relative(f.path(), "../shaders/").string();
|
||||
if (f.path().extension() != ".frag" && f.path().extension() != ".geom" && f.path().extension() != ".vert")
|
||||
continue;
|
||||
|
||||
std::cout << "== validating shader " << relative << ": " << std::flush;
|
||||
if (!check_shader_confs(relative))
|
||||
suc = false;
|
||||
}
|
||||
|
||||
if (suc)
|
||||
std::cout << "==== all checks ok" << std::endl;
|
||||
else {
|
||||
std::cout << "==== checks failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
6
ci_shadervalidator/stdafx.h
Normal file
6
ci_shadervalidator/stdafx.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#define GLM_FORCE_CTOR_INIT
|
||||
#include <glm/glm.hpp>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
Reference in New Issue
Block a user