Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLES: Specify glsl version precisely in depal, fix some shader errors #11695

Merged
merged 3 commits into from
Dec 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GPU/Common/DepalettizeShaderCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void GenerateDepalShader300(char *buffer, GEBufferFormat pixelFormat, ShaderLang
WRITE(p, "precision mediump float;\n");
WRITE(p, "precision highp int;\n");
} else {
WRITE(p, "#version 330\n");
WRITE(p, "#version %d\n", gl_extensions.GLSLVersion());
}
WRITE(p, "in vec2 v_texcoord0;\n");
WRITE(p, "out vec4 fragColor0;\n");
Expand Down
2 changes: 1 addition & 1 deletion GPU/D3D11/DepalettizeShaderD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ VS_OUT main(VS_IN input) {
output.Texcoord = input.a_texcoord0;
output.Position = float4(input.a_position, 1.0);
return output;
};
}
)";

static const D3D11_INPUT_ELEMENT_DESC g_DepalVertexElements[] = {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Directx9/DepalettizeShaderDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ VS_OUT main(VS_IN input) {
output.Texcoord = input.a_texcoord0;
output.Position = float4(input.a_position, 1.0);
return output;
};
}
)";

DepalShaderCacheDX9::DepalShaderCacheDX9(Draw::DrawContext *draw) : vertexShader_(nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions GPU/Directx9/FramebufferDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ VS_OUT main( VS_IN In ) {
Out.ProjPos = In.ObjPos;
Out.Uv = In.Uv;
return Out;
};
}
)";

static const char *pscode = R"(
Expand All @@ -72,7 +72,7 @@ struct PS_IN {
float4 main( PS_IN In ) : COLOR {
float4 c = tex2D(s, In.Uv);
return c;
};
}
)";

static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
Expand Down
9 changes: 5 additions & 4 deletions GPU/GLES/DepalettizeShaderGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ varying vec2 v_texcoord0;
void main() {
v_texcoord0 = a_texcoord0;
gl_Position = a_position;
};
}
)";

static const char *depalVShader300 = R"(
Expand All @@ -48,7 +48,7 @@ out vec2 v_texcoord0;
void main() {
v_texcoord0 = a_texcoord0;
gl_Position = a_position;
};
}
)";

DepalShaderCacheGLES::DepalShaderCacheGLES(Draw::DrawContext *draw) {
Expand All @@ -75,8 +75,9 @@ bool DepalShaderCacheGLES::CreateVertexShader() {
std::string prelude;
if (gl_extensions.IsGLES) {
prelude = useGL3_ ? "#version 300 es\n" : "#version 100\n";
} else if (useGL3_) {
prelude = "#version 330\n";
} else {
// We need to add a corresponding #version. Apple drivers fail without an exact match.
prelude = StringFromFormat("#version %d\n", gl_extensions.GLSLVersion());
}
vertexShader_ = render_->CreateShader(GL_VERTEX_SHADER, prelude + src, "depal");
return true;
Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/DepthBufferGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

static const char *depth_dl_fs = R"(
#ifdef GL_ES
#if GL_FRAGMENT_PRECISION_HIGH
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/StencilBufferGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

static const char *stencil_fs = R"(
#ifdef GL_ES
#if GL_FRAGMENT_PRECISION_HIGH
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float; // just hope it's enough..
Expand Down
2 changes: 1 addition & 1 deletion ext/native/gfx_es2/gpu_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage) {
std::string temp;
std::string version = "";
if (!gl_extensions.IsGLES && gl_extensions.IsCoreContext) {
// We need to add a corresponding #version. Apple drives fail without an exact match.
// We need to add a corresponding #version. Apple drivers fail without an exact match.
version = StringFromFormat("#version %d\n", gl_extensions.GLSLVersion());
}
if (stage == GL_FRAGMENT_SHADER) {
Expand Down