mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-16 22:44:10 +01:00
Review of the alpha to coverage change for alpha tested surfaces: - An alpha which is flat over the pixel (fwidth 0) and equal to the opacity threshold got a coverage of 0.5, so e.g. opacity 1 on an opaque or DXT1 texture turned half see-through with multisampling. Without an alpha edge in the pixel the plain test decides now: step(opacity, alpha). - The shaders took the coverage path whenever they were built with multisampling, also where alpha to coverage is off (the reflections pass) or does nothing (the single-sampled model previews), and grew the cut-outs there by about half a pixel. model_ubo gets an alpha_to_coverage flag, set together with the GL state, and the shaders keep the plain alpha test without it. The previews no longer turn alpha to coverage on. The flag takes 4 of the 12 padding bytes after shadow_tone, so the std140 layout and the size of the block stay the same. - The shader validator never set iMultisampling, so it never compiled the alpha to coverage branches. Its "features on" configuration uses the default of 2 now, on desktop GL and GLES.
116 lines
2.7 KiB
C++
116 lines
2.7 KiB
C++
#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;
|
|
// the default of the simulator, which compiles the alpha to coverage branches of the shaders
|
|
Global.iMultisampling = 2;
|
|
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;
|
|
Global.iMultisampling = 0;
|
|
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;
|
|
}
|