Merge pull request #1253 from kemenaran/avoid-explicit-uniform-location
Use regular uniform location
This commit is contained in:
commit
ff502a51c5
|
@ -492,9 +492,10 @@ void RasterizerOpenGL::SetShader() {
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
// Set the texture samplers to correspond to different texture units
|
// Set the texture samplers to correspond to different texture units
|
||||||
glUniform1i(PicaShader::Uniform::Texture0, 0);
|
GLuint uniform_tex = glGetUniformLocation(shader->shader.handle, "tex");
|
||||||
glUniform1i(PicaShader::Uniform::Texture1, 1);
|
glUniform1i(uniform_tex, 0);
|
||||||
glUniform1i(PicaShader::Uniform::Texture2, 2);
|
glUniform1i(uniform_tex + 1, 1);
|
||||||
|
glUniform1i(uniform_tex + 2, 2);
|
||||||
|
|
||||||
current_shader = shader_cache.emplace(config, std::move(shader)).first->second.get();
|
current_shader = shader_cache.emplace(config, std::move(shader)).first->second.get();
|
||||||
|
|
||||||
|
|
|
@ -138,13 +138,6 @@ public:
|
||||||
struct PicaShader {
|
struct PicaShader {
|
||||||
/// OpenGL shader resource
|
/// OpenGL shader resource
|
||||||
OGLShader shader;
|
OGLShader shader;
|
||||||
|
|
||||||
/// Fragment shader uniforms
|
|
||||||
enum Uniform : GLuint {
|
|
||||||
Texture0 = 0,
|
|
||||||
Texture1 = 1,
|
|
||||||
Texture2 = 2,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -321,8 +321,6 @@ static void WriteTevStage(std::string& out, const PicaShaderConfig& config, unsi
|
||||||
std::string GenerateFragmentShader(const PicaShaderConfig& config) {
|
std::string GenerateFragmentShader(const PicaShaderConfig& config) {
|
||||||
std::string out = R"(
|
std::string out = R"(
|
||||||
#version 330
|
#version 330
|
||||||
#extension GL_ARB_explicit_uniform_location : require
|
|
||||||
|
|
||||||
#define NUM_TEV_STAGES 6
|
#define NUM_TEV_STAGES 6
|
||||||
|
|
||||||
in vec4 primary_color;
|
in vec4 primary_color;
|
||||||
|
@ -338,9 +336,7 @@ layout (std140) uniform shader_data {
|
||||||
|
|
||||||
)";
|
)";
|
||||||
|
|
||||||
using Uniform = RasterizerOpenGL::PicaShader::Uniform;
|
out += "uniform sampler2D tex[3];\n";
|
||||||
out += "layout(location = " + std::to_string((int)Uniform::Texture0) + ") uniform sampler2D tex[3];\n";
|
|
||||||
|
|
||||||
out += "void main() {\n";
|
out += "void main() {\n";
|
||||||
out += "vec4 combiner_buffer = tev_combiner_buffer_color;\n";
|
out += "vec4 combiner_buffer = tev_combiner_buffer_color;\n";
|
||||||
out += "vec4 last_tex_env_out = vec4(0.0);\n";
|
out += "vec4 last_tex_env_out = vec4(0.0);\n";
|
||||||
|
|
Reference in New Issue