mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
This commit is contained in:
parent
e2d2950865
commit
f424bf73ae
2 changed files with 19 additions and 7 deletions
|
@ -487,6 +487,7 @@ void GenerateFragmentShader(char *buffer) {
|
||||||
const char *texture = "texture2D";
|
const char *texture = "texture2D";
|
||||||
const char *texelFetch = NULL;
|
const char *texelFetch = NULL;
|
||||||
bool highpFog = false;
|
bool highpFog = false;
|
||||||
|
bool highpTexcoord = false;
|
||||||
bool bitwiseOps = false;
|
bool bitwiseOps = false;
|
||||||
|
|
||||||
#if defined(USING_GLES2)
|
#if defined(USING_GLES2)
|
||||||
|
@ -511,6 +512,7 @@ void GenerateFragmentShader(char *buffer) {
|
||||||
// PowerVR needs highp to do the fog in MHU correctly.
|
// PowerVR needs highp to do the fog in MHU correctly.
|
||||||
// Others don't, and some can't handle highp in the fragment shader.
|
// Others don't, and some can't handle highp in the fragment shader.
|
||||||
highpFog = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR;
|
highpFog = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR;
|
||||||
|
highpTexcoord = highpFog;
|
||||||
|
|
||||||
// GL_NV_shader_framebuffer_fetch available on mobile platform and ES 2.0 only but not desktop
|
// GL_NV_shader_framebuffer_fetch available on mobile platform and ES 2.0 only but not desktop
|
||||||
if (gl_extensions.NV_shader_framebuffer_fetch) {
|
if (gl_extensions.NV_shader_framebuffer_fetch) {
|
||||||
|
@ -635,9 +637,9 @@ void GenerateFragmentShader(char *buffer) {
|
||||||
}
|
}
|
||||||
if (doTexture) {
|
if (doTexture) {
|
||||||
if (doTextureProjection)
|
if (doTextureProjection)
|
||||||
WRITE(p, "%s mediump vec3 v_texcoord;\n", varying);
|
WRITE(p, "%s %s vec3 v_texcoord;\n", varying, highpTexcoord ? "highp" : "mediump");
|
||||||
else
|
else
|
||||||
WRITE(p, "%s mediump vec2 v_texcoord;\n", varying);
|
WRITE(p, "%s %s vec2 v_texcoord;\n", varying, highpTexcoord ? "highp" : "mediump");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_Config.bFragmentTestCache) {
|
if (!g_Config.bFragmentTestCache) {
|
||||||
|
@ -668,6 +670,11 @@ void GenerateFragmentShader(char *buffer) {
|
||||||
WRITE(p, "out vec4 fragColor0;\n");
|
WRITE(p, "out vec4 fragColor0;\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PowerVR needs a custom modulo function. For some reason, this has far higher precision than the builtin one.
|
||||||
|
if (gl_extensions.gpuVendor == GPU_VENDOR_POWERVR && gstate_c.needShaderTexClamp) {
|
||||||
|
WRITE(p, "float mymod(float a, float b) { return a - b * floor(a / b); }\n");
|
||||||
|
}
|
||||||
|
|
||||||
WRITE(p, "void main() {\n");
|
WRITE(p, "void main() {\n");
|
||||||
|
|
||||||
if (gstate.isModeClear()) {
|
if (gstate.isModeClear()) {
|
||||||
|
@ -700,15 +707,17 @@ void GenerateFragmentShader(char *buffer) {
|
||||||
vcoord = "1.0 - " + vcoord;
|
vcoord = "1.0 - " + vcoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string modulo = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR ? "mymod" : "mod";
|
||||||
|
|
||||||
if (gstate.isTexCoordClampedS()) {
|
if (gstate.isTexCoordClampedS()) {
|
||||||
ucoord = "clamp(" + ucoord + ", u_texclamp.z, u_texclamp.x - u_texclamp.z)";
|
ucoord = "clamp(" + ucoord + ", u_texclamp.z, u_texclamp.x - u_texclamp.z)";
|
||||||
} else {
|
} else {
|
||||||
ucoord = "mod(" + ucoord + ", u_texclamp.x)";
|
ucoord = modulo + "(" + ucoord + ", u_texclamp.x)";
|
||||||
}
|
}
|
||||||
if (gstate.isTexCoordClampedT()) {
|
if (gstate.isTexCoordClampedT()) {
|
||||||
vcoord = "clamp(" + vcoord + ", u_texclamp.w, u_texclamp.y - u_texclamp.w)";
|
vcoord = "clamp(" + vcoord + ", u_texclamp.w, u_texclamp.y - u_texclamp.w)";
|
||||||
} else {
|
} else {
|
||||||
vcoord = "mod(" + vcoord + ", u_texclamp.y)";
|
vcoord = modulo + "(" + vcoord + ", u_texclamp.y)";
|
||||||
}
|
}
|
||||||
if (textureAtOffset) {
|
if (textureAtOffset) {
|
||||||
ucoord = "(" + ucoord + " + u_texclampoff.x)";
|
ucoord = "(" + ucoord + " + u_texclampoff.x)";
|
||||||
|
|
|
@ -163,6 +163,7 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf
|
||||||
const char *attribute = "attribute";
|
const char *attribute = "attribute";
|
||||||
const char * const * boneWeightDecl = boneWeightAttrDecl;
|
const char * const * boneWeightDecl = boneWeightAttrDecl;
|
||||||
bool highpFog = false;
|
bool highpFog = false;
|
||||||
|
bool highpTexcoord = false;
|
||||||
|
|
||||||
#if defined(USING_GLES2)
|
#if defined(USING_GLES2)
|
||||||
// Let's wait until we have a real use for this.
|
// Let's wait until we have a real use for this.
|
||||||
|
@ -178,6 +179,8 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf
|
||||||
// PowerVR needs highp to do the fog in MHU correctly.
|
// PowerVR needs highp to do the fog in MHU correctly.
|
||||||
// Others don't, and some can't handle highp in the fragment shader.
|
// Others don't, and some can't handle highp in the fragment shader.
|
||||||
highpFog = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR;
|
highpFog = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR;
|
||||||
|
highpTexcoord = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR;
|
||||||
|
|
||||||
#elif !defined(FORCE_OPENGL_2_0)
|
#elif !defined(FORCE_OPENGL_2_0)
|
||||||
if (gl_extensions.VersionGEThan(3, 3, 0)) {
|
if (gl_extensions.VersionGEThan(3, 3, 0)) {
|
||||||
glslES30 = true;
|
glslES30 = true;
|
||||||
|
@ -339,9 +342,9 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf
|
||||||
}
|
}
|
||||||
if (doTexture) {
|
if (doTexture) {
|
||||||
if (doTextureProjection)
|
if (doTextureProjection)
|
||||||
WRITE(p, "%s mediump vec3 v_texcoord;\n", varying);
|
WRITE(p, "%s %s vec3 v_texcoord;\n", varying, highpTexcoord ? "highp" : "mediump");
|
||||||
else
|
else
|
||||||
WRITE(p, "%s mediump vec2 v_texcoord;\n", varying);
|
WRITE(p, "%s %s vec2 v_texcoord;\n", varying, highpTexcoord ? "highp" : "mediump");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue