Skip to content

Commit

Permalink
Reduce PowerVR blockiness problems on older GPU revisions. #7153 #7150
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 15, 2014
1 parent f424bf7 commit d9e543f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions GPU/GLES/FragmentShaderGenerator.cpp
Expand Up @@ -25,6 +25,7 @@

#include <cstdio>

#include "base/logging.h"
#include "gfx_es2/gpu_features.h"
#include "Core/Reporting.h"
#include "Core/Config.h"
Expand Down Expand Up @@ -511,7 +512,7 @@ void GenerateFragmentShader(char *buffer) {

// PowerVR needs highp to do the fog in MHU correctly.
// Others don't, and some can't handle highp in the fragment shader.
highpFog = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR;
highpFog = (gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) ? true : false;
highpTexcoord = highpFog;

// GL_NV_shader_framebuffer_fetch available on mobile platform and ES 2.0 only but not desktop
Expand Down Expand Up @@ -671,7 +672,7 @@ void GenerateFragmentShader(char *buffer) {
}

// 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) {
if ((gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) && gstate_c.needShaderTexClamp) {
WRITE(p, "float mymod(float a, float b) { return a - b * floor(a / b); }\n");
}

Expand All @@ -693,7 +694,8 @@ void GenerateFragmentShader(char *buffer) {
if (gstate.isTextureMapEnabled()) {
const char *texcoord = "v_texcoord";
// TODO: Not sure the right way to do this for projection.
if (gstate_c.needShaderTexClamp) {
// This path destroys resolution on older PowerVR no matter what I do, so we disable it on SGX 540 and lesser, and live with the consequences.
if (gstate_c.needShaderTexClamp && !(gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_TERRIBLE)) {
// We may be clamping inside a larger surface (tex = 64x64, buffer=480x272).
// We may also be wrapping in such a surface, or either one in a too-small surface.
// Obviously, clamping to a smaller surface won't work. But better to clamp to something.
Expand All @@ -707,7 +709,7 @@ void GenerateFragmentShader(char *buffer) {
vcoord = "1.0 - " + vcoord;
}

std::string modulo = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR ? "mymod" : "mod";
std::string modulo = (gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) ? "mymod" : "mod";

if (gstate.isTexCoordClampedS()) {
ucoord = "clamp(" + ucoord + ", u_texclamp.z, u_texclamp.x - u_texclamp.z)";
Expand Down
4 changes: 2 additions & 2 deletions GPU/GLES/VertexShaderGenerator.cpp
Expand Up @@ -178,8 +178,8 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf

// PowerVR needs highp to do the fog in MHU correctly.
// Others don't, and some can't handle highp in the fragment shader.
highpFog = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR;
highpTexcoord = gl_extensions.gpuVendor == GPU_VENDOR_POWERVR;
highpFog = (gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) ? true : false;
highpTexcoord = highpFog;

#elif !defined(FORCE_OPENGL_2_0)
if (gl_extensions.VersionGEThan(3, 3, 0)) {
Expand Down

0 comments on commit d9e543f

Please sign in to comment.