Merge pull request #22553 from hrydgard/gpu-fallback-fixes

GLES and fallback rendering fixes from running the framedumps on Android
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-10-14 09:20:38 +02:00
commit 88f4c12437
21 files changed
+175 -47

No files matched your search

+13
View File
@@ -35,6 +35,11 @@
#define GL_MAX_EXT 0x8008
#endif
#ifndef GL_DEPTH_CLAMP
// GL_DEPTH_CLAMP_EXT, from GL_EXT_depth_clamp. Not in every platform header.
#define GL_DEPTH_CLAMP 0x864F
#endif
#if defined(__ANDROID__)
#include <EGL/egl.h>
// Additional extensions not included in GLES2/gl2ext.h from the NDK
@@ -58,6 +63,14 @@ typedef void (EGLAPIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (
#endif
extern PFNGLBLITFRAMEBUFFERNVPROC glBlitFramebufferNV;
#ifndef GL_ZERO_TO_ONE_EXT
#define GL_LOWER_LEFT_EXT 0x8CA1
#define GL_ZERO_TO_ONE_EXT 0x935F
#endif
// Our own name for the type and the pointer, since not every NDK header declares GL_EXT_clip_control.
typedef void (GL_APIENTRYP PPSSPP_PFNGLCLIPCONTROLEXTPROC) (GLenum origin, GLenum depth);
extern PPSSPP_PFNGLCLIPCONTROLEXTPROC glClipControlEXTFunc;
#if PPSSPP_PLATFORM(IOS)
extern PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT;
extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES;
+19
View File
@@ -30,6 +30,7 @@ PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES;
PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOES;
PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOES;
PFNGLISVERTEXARRAYOESPROC glIsVertexArrayOES;
PPSSPP_PFNGLCLIPCONTROLEXTPROC glClipControlEXTFunc;
#endif
#if !PPSSPP_PLATFORM(IOS)
#include "EGL/egl.h"
@@ -381,6 +382,7 @@ bool CheckGLExtensions() {
gl_extensions.ARB_draw_instanced = g_set_gl_extensions.count("GL_ARB_draw_instanced") != 0;
gl_extensions.ARB_cull_distance = g_set_gl_extensions.count("GL_ARB_cull_distance") != 0;
gl_extensions.ARB_depth_clamp = g_set_gl_extensions.count("GL_ARB_depth_clamp") != 0;
gl_extensions.ARB_clip_control = g_set_gl_extensions.count("GL_ARB_clip_control") != 0;
gl_extensions.ARB_uniform_buffer_object = g_set_gl_extensions.count("GL_ARB_uniform_buffer_object") != 0;
gl_extensions.ARB_explicit_attrib_location = g_set_gl_extensions.count("GL_ARB_explicit_attrib_location") != 0;
gl_extensions.ARB_texture_non_power_of_two = g_set_gl_extensions.count("GL_ARB_texture_non_power_of_two") != 0;
@@ -407,6 +409,7 @@ bool CheckGLExtensions() {
gl_extensions.EXT_buffer_storage = g_set_gl_extensions.count("GL_EXT_buffer_storage") != 0;
gl_extensions.EXT_clip_cull_distance = g_set_gl_extensions.count("GL_EXT_clip_cull_distance") != 0;
gl_extensions.EXT_depth_clamp = g_set_gl_extensions.count("GL_EXT_depth_clamp") != 0;
gl_extensions.EXT_clip_control = g_set_gl_extensions.count("GL_EXT_clip_control") != 0;
gl_extensions.EXT_disjoint_timer_query = g_set_gl_extensions.count("GL_EXT_disjoint_timer_query") != 0;
gl_extensions.APPLE_clip_distance = g_set_gl_extensions.count("GL_APPLE_clip_distance") != 0;
@@ -432,6 +435,11 @@ bool CheckGLExtensions() {
glBlitFramebufferNV = (PFNGLBLITFRAMEBUFFERNVPROC)eglGetProcAddress("glBlitFramebufferNV");
}
if (gl_extensions.EXT_clip_control) {
glClipControlEXTFunc = (PPSSPP_PFNGLCLIPCONTROLEXTPROC)eglGetProcAddress("glClipControlEXT");
gl_extensions.EXT_clip_control = glClipControlEXTFunc != nullptr;
}
gl_extensions.OES_vertex_array_object = g_set_gl_extensions.count("GL_OES_vertex_array_object") != 0;
if (gl_extensions.OES_vertex_array_object) {
glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
@@ -448,6 +456,7 @@ bool CheckGLExtensions() {
#else
gl_extensions.OES_vertex_array_object = false;
gl_extensions.EXT_discard_framebuffer = false;
gl_extensions.EXT_clip_control = false;
#endif
} else {
gl_extensions.ARB_blend_func_extended = g_set_gl_extensions.count("GL_ARB_blend_func_extended") != 0;
@@ -574,6 +583,7 @@ bool CheckGLExtensions() {
gl_extensions.ARB_buffer_storage = true;
}
if (gl_extensions.VersionGEThan(4, 5)) {
gl_extensions.ARB_clip_control = true;
gl_extensions.ARB_cull_distance = true;
}
if (gl_extensions.VersionGEThan(4, 6)) {
@@ -589,6 +599,15 @@ bool CheckGLExtensions() {
gl_extensions.EXT_clip_cull_distance = false;
}
if (gl_extensions.IsGLES) {
gl_extensions.ARB_clip_control = false;
}
#if defined(__LIBRETRO__)
// The frontend shares the context, and doesn't expect its clip control changed.
gl_extensions.ARB_clip_control = false;
gl_extensions.EXT_clip_control = false;
#endif
bool clipDistanceSupported = false;
bool cullDistanceSupported = false;
+2
View File
@@ -76,6 +76,7 @@ struct GLExtensions {
bool ARB_clip_distance;
bool ARB_cull_distance;
bool ARB_depth_clamp;
bool ARB_clip_control;
bool ARB_uniform_buffer_object;
bool ARB_texture_non_power_of_two;
bool ARB_stencil_texturing;
@@ -104,6 +105,7 @@ struct GLExtensions {
bool EXT_buffer_storage;
bool EXT_clip_cull_distance;
bool EXT_depth_clamp;
bool EXT_clip_control;
// NV
bool NV_copy_image;
+20 -3
View File
@@ -50,6 +50,24 @@ void GLQueueRunner::CreateDeviceObjects() {
glGenVertexArrays(1, &globalVAO_);
}
// Texture uploads pass tightly packed rows. With the default of 4, the driver reads past the end of
// any whose rows aren't a multiple of 4 bytes (a 16-bit texture of odd width): the Adreno 840 crashed
// on one in SOCOM Fireteam Bravo 3.
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// Depth from 0 to w in clip space, as in Vulkan (see depthMinusOneToOne in thin3d_gl.cpp).
#if defined(USING_GLES2)
#if defined(__ANDROID__)
if (gl_extensions.EXT_clip_control) {
glClipControlEXTFunc(GL_LOWER_LEFT_EXT, GL_ZERO_TO_ONE_EXT);
}
#endif
#else
if (gl_extensions.ARB_clip_control) {
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
}
#endif
// An eternal optimist.
sawOutOfMemory_ = false;
@@ -1422,7 +1440,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
glDisable(GL_DITHER);
ditherEnabled = false;
}
#ifndef USING_GLES2
// GLES has it too, with GL_EXT_depth_clamp (depthClampSupported).
if (c.raster.depthClampEnable) {
if (!depthClampEnabled) {
glEnable(GL_DEPTH_CLAMP);
@@ -1432,7 +1450,6 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
glDisable(GL_DEPTH_CLAMP);
depthClampEnabled = false;
}
#endif
CHECK_GL_ERROR_IF_DEBUG();
break;
default:
@@ -1473,9 +1490,9 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
glDisable(GL_BLEND);
if (cullEnabled)
glDisable(GL_CULL_FACE);
#ifndef USING_GLES2
if (depthClampEnabled)
glDisable(GL_DEPTH_CLAMP);
#ifndef USING_GLES2
if (!gl_extensions.IsGLES && logicEnabled) {
glDisable(GL_COLOR_LOGIC_OP);
}
+6
View File
@@ -548,6 +548,8 @@ OpenGLContext::OpenGLContext(bool canChangeSwapInterval) : renderManager_(frameT
// 30 is an ok value for the max since it's 2^31-1, which is the max value for a signed int. NVIDIA also reports this.
caps_.samplerLodControl = true;
}
// GL_TEXTURE_LOD_BIAS is desktop GL only, so the shader has to apply the bias.
caps_.samplerLodBias = false;
caps_.texture3DSupported = gl_extensions.GLES3 || gl_extensions.OES_texture_3D;
caps_.textureDepthSupported = gl_extensions.GLES3 || gl_extensions.OES_depth_texture;
} else {
@@ -673,6 +675,10 @@ OpenGLContext::OpenGLContext(bool canChangeSwapInterval) : renderManager_(frameT
#endif
shaderLanguageDesc_.Init(GLSL_1xx);
// With clip control set up by GLQueueRunner, depth is 0 to w like in Vulkan. Without it, window depth 0
// comes from z = -w, where the rasterizer rounds to an ulp of 1.0 rather than of 0: a flat ground at
// z = 0 got depths just above 0, and sprites on it that test GEQUAL failed (Puyo Puyo Fever 2).
shaderLanguageDesc_.depthMinusOneToOne = !(gl_extensions.ARB_clip_control || gl_extensions.EXT_clip_control);
shaderLanguageDesc_.glslVersionNumber = gl_extensions.GLSLVersion();
+1 -1
View File
@@ -207,7 +207,7 @@ static const CommandLineParam g_autoParams[] = {
{POFF(replayEnd), CmdParamType::Int, "replay-end", '\0', "When replaying a GE frame dump, only draw primitives up to this one (1-based)", CmdLineMode::Headless},
{POFF(dumpCompat), CmdParamType::Bool, "dump-compat", '\0', "Apply the game's compat.ini settings when replaying a GE frame dump (off by default)", CmdLineMode::Headless},
{POFF(hardwareTransform), CmdParamType::Bool, "hardware-transform", '\0', "Transform vertices on the GPU (default true); false transforms them on the CPU", CmdLineMode::Headless},
{POFF(disableGPUFeatures), CmdParamType::String, "disable-gpu-features", '\0', "Act as if the GPU lacked these, to test the fallbacks: comma-separated clip-distance, cull-distance, depth-clamp", CmdLineMode::Headless},
{POFF(disableGPUFeatures), CmdParamType::String, "disable-gpu-features", '\0', "Act as if the GPU lacked these, to test the fallbacks: comma-separated clip-distance, cull-distance, depth-clamp, framebuffer-fetch, dual-source-blend", CmdLineMode::Headless},
{POFF(depthFilenameSave), CmdParamType::String, "depth-save", '\0', "Save the depth buffer to FILE along with the screenshot (u32 width, u32 height, u16 depths; float depths if FILE ends in .f32)", CmdLineMode::Headless},
{POFF(screenshotRenderTarget), CmdParamType::Bool, "screenshot-render-target", '\0', "Take screenshots of the current render target instead of the displayed framebuffer", CmdLineMode::Headless},
{POFF(screenshotFilenameDiff), CmdParamType::String, "screenshot-diff", '\0', "Save a visual comparison image to FILE when comparing screenshots", CmdLineMode::Headless},
+1 -1
View File
@@ -189,7 +189,7 @@ struct CommandLineOptions {
// Headless: apply the game's compatibility settings when replaying a GE frame dump.
std::optional<bool> dumpCompat;
std::optional<bool> hardwareTransform;
// Headless: comma-separated clip-distance, cull-distance, depth-clamp.
// Headless: comma-separated clip-distance, cull-distance, depth-clamp, framebuffer-fetch, dual-source-blend.
std::optional<std::string> disableGPUFeatures;
std::optional<bool> screenshotRenderTarget;
std::optional<std::string> screenshotFilenameDiff;
+3 -1
View File
@@ -461,7 +461,9 @@ static bool TestBoundingBoxFast(const float *cullMatrix, const void *vdata, cons
//
// Alternatively, we just do a compat flag for the affected games until we can solve this.
if (needFragmentMinMaxClipping() && (minProjZ < gstate.getDepthRangeMin() || maxProjZ > gstate.getDepthRangeMax())) {
const int depthRangeMin = gstate.getDepthRangeMin();
const int depthRangeMax = gstate.getDepthRangeMax();
if ((depthRangeMin != 0 && minProjZ < depthRangeMin) || (depthRangeMax != 0xFFFF && maxProjZ > depthRangeMax)) {
if (gstate_c.Use(GPU_USE_CLIP_DISTANCE)) {
flags |= ClipInfoFlags::MinMaxZClip;
} else {
+15 -1
View File
@@ -135,6 +135,16 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
}
ShaderDepalMode shaderDepalMode = (ShaderDepalMode)id.Bits(FS_BIT_SHADER_DEPAL_MODE, 2);
if (shaderDepalMode == ShaderDepalMode::CLUT8 && gstate_c.Use(GPU_USE_FULL_PRECISION_IN_FRAGMENT)) {
// The byte coordinate is u * up to 2048: a mediump texcoord (fp16 on Adreno) picks the wrong byte for half
// of them past 512, striping SOCOM's night vision. Vulkan always uses highp here.
highpTexcoord = true;
if (compat.gles) {
// Picking the byte also needs more than the default lowp in the rest of the shader: on PowerVR,
// SOCOM's night vision came out far too bright.
WRITE(p, "precision highp float;\n");
}
}
GEBufferFormat shaderDepalFmt = (GEBufferFormat)(id.Bits(FS_BIT_SHADER_DEPAL_FORMAT, 3));
if (texture3D) {
shaderDepalMode = ShaderDepalMode::OFF;
@@ -394,11 +404,15 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
if (texture3D) {
*uniformMask |= DIRTY_MIPBIAS;
WRITE(p, "uniform float u_mipBias;\n");
} else if (doTexture && gstate_c.Use(GPU_USE_SHADER_LOD_BIAS)) {
*uniformMask |= DIRTY_MIPBIAS;
WRITE(p, "uniform float u_texLodBias;\n");
}
if (fsMinmaxDiscard) {
*uniformMask |= DIRTY_RASTER_OFFSET; // they're updated together
WRITE(p, "uniform vec2 u_minZmaxZ;\n");
// The same precision as in the vertex shader, or PowerVR fails to link the program.
WRITE(p, "uniform highp vec2 u_minZmaxZ;\n");
}
// Varyings
+11
View File
@@ -2034,6 +2034,17 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w,
if (vfb->usageFlags & FB_USAGE_RENDER_DEPTH) {
BlitFramebuffer(vfb, 0, 0, &old, 0, 0, std::min((u16)oldWidth, std::min(vfb->bufferWidth, vfb->width)), std::min((u16)oldHeight, std::min(vfb->height, vfb->bufferHeight)), 0, RASTER_DEPTH, "BlitDepth_ResizeFramebufFBO");
}
if (!skipCopy && vfb->fb_format != GE_FORMAT_565) {
// Keep the stencil too (Need for Speed Shift stencil tests right after its framebuffer grows from 480 to
// 512 wide). D3D11 has no separate stencil copy, but copies it along with the depth above.
const int stencilW = std::min(old.renderWidth, vfb->renderWidth);
const int stencilH = std::min(old.renderHeight, vfb->renderHeight);
if (draw_->GetDeviceCaps().framebufferSeparateDepthCopySupported) {
draw_->CopyFramebufferImage(old.fbo, 0, 0, 0, 0, vfb->fbo, 0, 0, 0, 0, stencilW, stencilH, 1, Draw::Aspect::STENCIL_BIT, "CopyStencil_ResizeFramebufFBO");
} else if (draw_->GetDeviceCaps().framebufferStencilBlitSupported) {
draw_->BlitFramebuffer(old.fbo, 0, 0, stencilW, stencilH, vfb->fbo, 0, 0, stencilW, stencilH, Draw::Aspect::STENCIL_BIT, Draw::FB_BLIT_NEAREST, "BlitStencil_ResizeFramebufFBO");
}
}
}
fbosToDelete_.push_back(old.fbo);
draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "ResizeFramebufFBO");
+25 -6
View File
@@ -181,20 +181,34 @@ const bool nonAlphaDestFactors[16] = {
true,
};
// Whether the color blend uses the source alpha, so the stencil can only be written as alpha with a second output.
static bool StencilToAlphaNeedsDualSource(ReplaceBlendType replaceBlend) {
if (IsStencilTestOutputDisabled() || gstate.isModeClear()) {
return false;
}
if (replaceBlend == REPLACE_BLEND_NO || replaceBlend == REPLACE_BLEND_READ_FRAMEBUFFER) {
return false;
}
if (nonAlphaSrcFactors[gstate.getBlendFuncA()] && nonAlphaDestFactors[gstate.getBlendFuncB()]) {
return false;
}
// With no color written, the color blend can't need the source alpha (WipEout Pure writes only the stencil
// this way, then blends with it as the destination alpha).
return (gstate.getColorMask() & 0x00FFFFFF) != 0x00FFFFFF;
}
ReplaceAlphaType ReplaceAlphaWithStencil(ReplaceBlendType replaceBlend) {
if (IsStencilTestOutputDisabled() || gstate.isModeClear()) {
return REPLACE_ALPHA_NO;
}
if (replaceBlend != REPLACE_BLEND_NO && replaceBlend != REPLACE_BLEND_READ_FRAMEBUFFER) {
if (nonAlphaSrcFactors[gstate.getBlendFuncA()] && nonAlphaDestFactors[gstate.getBlendFuncB()]) {
if (!StencilToAlphaNeedsDualSource(replaceBlend)) {
return REPLACE_ALPHA_YES;
} else if (gstate_c.Use(GPU_USE_DUALSOURCE_BLEND)) {
return REPLACE_ALPHA_DUALSOURCE;
} else {
if (gstate_c.Use(GPU_USE_DUALSOURCE_BLEND)) {
return REPLACE_ALPHA_DUALSOURCE;
} else {
return REPLACE_ALPHA_NO;
}
return REPLACE_ALPHA_NO;
}
}
@@ -967,6 +981,11 @@ static void ConvertBlendState(GenericBlendState &blendState, FBReadSetting useFB
if (useFBRead == FBReadSetting::Forced) {
// Enforce blend replacement if enabled. If not, shouldn't do anything of course.
replaceBlend = gstate.isAlphaBlendEnabled() ? REPLACE_BLEND_READ_FRAMEBUFFER : REPLACE_BLEND_NO;
} else if (useFBRead == FBReadSetting::Allowed && replaceBlend != REPLACE_BLEND_BLUE_TO_ALPHA && !gstate_c.Use(GPU_USE_DUALSOURCE_BLEND) &&
gstate_c.Use(GPU_USE_FRAMEBUFFER_FETCH) && StencilToAlphaNeedsDualSource(replaceBlend)) {
// Blend in the shader, which can then write the stencil as alpha. Only with fetch: elsewhere a framebuffer
// copy per draw costs too much for something this common, so the alpha stays wrong (WipEout Pure).
replaceBlend = REPLACE_BLEND_READ_FRAMEBUFFER;
}
blendState.replaceBlend = replaceBlend;
+3 -1
View File
@@ -12,8 +12,10 @@ enum class ClipInfoFlags;
// Shared ID checks for when the vertex and fragment shaders (and host code) need to coordinate.
// NOTE: Both of these assume non-through-mode. Don't check these if in through mode.
// Each side on its own, like the clip planes: Pursuit Force's sky has min 0 and max 300, and the PSP drops it past 300.
// Can be needed together with needFragmentDepthClamp, for the side at the limit.
inline bool needFragmentMinMaxClipping() {
return gstate.getDepthRangeMin() != 0 && gstate.getDepthRangeMax() != 0xFFFF;
return gstate.getDepthRangeMin() != 0 || gstate.getDepthRangeMax() != 0xFFFF;
}
inline bool needFragmentDepthClamp() {
+4
View File
@@ -407,6 +407,10 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size,
draw_->SetScissorRect(0, 0, dstBuffer->renderWidth, dstBuffer->renderHeight);
draw_->BlitFramebuffer(blitFBO, 0, 0, w, h, dstBuffer->fbo, 0, 0, dstBuffer->renderWidth, dstBuffer->renderHeight, Draw::Aspect::STENCIL_BIT, Draw::FB_BLIT_NEAREST, "WriteStencilFromMemory_Blit");
RebindFramebuffer("RebindFramebuffer - Stencil");
} else if (dstBuffer != currentRenderVfb_) {
// dstBuffer is bound as the target now, and the draws after this don't all rebind the current one: with
// framebuffer fetch, OutRun 2006's masked draws make no copy of the target that would, and landed in dstBuffer.
RebindFramebuffer("RebindFramebuffer - Stencil");
}
draw_->Invalidate(InvalidationFlags::CACHED_RENDER_STATE);
+7 -4
View File
@@ -69,7 +69,8 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
*vertexShaderFlags = (VertexShaderFlags)0;
bool highpFog = false;
bool highpTexcoord = false;
// Highp costs nothing here, and the fragment shader can then pick it up where it needs it (CLUT8 depal).
bool highpTexcoord = gstate_c.Use(GPU_USE_FULL_PRECISION_IN_FRAGMENT);
const bool isModeThrough = id.Bit(VS_BIT_IS_THROUGH);
const bool useHWTransform = id.Bit(VS_BIT_USE_HW_TRANSFORM);
@@ -327,7 +328,8 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
WRITE(p, "uniform float u_NaN;\n");
*uniformMask |= DIRTY_FRAMEBUFFER_DIM;
WRITE(p, "uniform vec2 u_minZmaxZ;\n");
// highp to match the fragment shader's (see there).
WRITE(p, "uniform highp vec2 u_minZmaxZ;\n");
*uniformMask |= DIRTY_RASTER_OFFSET; // this flag is shared with raster offset.
if (!isModeThrough) {
@@ -959,8 +961,9 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
}
if (fsDepthClamp) {
// After the rounding, so the fragment shader clamps the Z that hardware depth clamp would.
// (Never needed together with fsMinmaxDiscard, which wants it unrounded.)
// After the rounding, so the fragment shader clamps the Z that hardware depth clamp would. With fsMinmaxDiscard
// too, this replaces its unrounded Z: the same for the max side, which rounds down anyway, and up to 2 off for
// the min one, which only meets the clamp when max is 65535.
WRITE(p, " %sv_zw = vec2(outPos.z * outPos.w, outPos.w);\n", compat.vsOutPrefix);
}
+22 -23
View File
@@ -173,6 +173,7 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs,
queries.push_back({ &u_depal_mask_shift_off_fmt, "u_depal_mask_shift_off_fmt" });
queries.push_back({ &u_mipBias, "u_mipBias" });
queries.push_back({ &u_texLodBias, "u_texLodBias" });
attrMask = vs->GetAttrMask();
availableUniforms = vs->GetUniformMask() | fs->GetUniformMask();
@@ -447,21 +448,27 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, const ShaderLanguageDesc
render_->SetUniformF(&u_uvscaleoffset, 4, uvscaleoff);
}
if ((dirty & DIRTY_TEXCLAMP) && u_texclamp != -1) {
// No checks for a location of -1 here: the GL thread fills the locations in when it links the program, which
// may be after this runs, and skips the uniforms a program doesn't have itself. Skipping them here dropped the
// values for good on drivers that link slowly (PowerVR and Mali sampled Harvest Moon's framebuffer at one
// point, with no texture clamp values).
if (dirty & DIRTY_TEXCLAMP) {
float texclamp[4];
float texclampoff[2];
CalcTexClamp(texclamp, texclampoff);
render_->SetUniformF(&u_texclamp, 4, texclamp);
if (u_texclampoff != -1) {
render_->SetUniformF(&u_texclampoff, 2, texclampoff);
}
render_->SetUniformF(&u_texclampoff, 2, texclampoff);
}
if ((dirty & DIRTY_MIPBIAS) && u_mipBias != -1) {
if (dirty & DIRTY_MIPBIAS) {
float mipBias = (float)gstate.getTexLevelOffset16() * (1.0 / 16.0f);
mipBias = (mipBias + 0.5f) / (float)(gstate.getTextureMaxLevel() + 1);
render_->SetUniformF(&u_mipBias, 1, &mipBias);
// For GPU_USE_SHADER_LOD_BIAS, like ShaderUniforms.cpp: the sampler applies the bias only in auto mode.
float lodBias = gstate.getTexLevelMode() == GE_TEXLEVEL_MODE_AUTO ? (float)gstate.getTexLevelOffset16() * (1.0f / 16.0f) : 0.0f;
render_->SetUniformF(&u_texLodBias, 1, &lodBias);
}
// Transform
@@ -520,20 +527,14 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, const ShaderLanguageDesc
}
if (dirty & DIRTY_SHADERBLEND) {
if (u_blendFixA != -1) {
SetColorUniform3(render_, &u_blendFixA, gstate.getFixA());
}
if (u_blendFixB != -1) {
SetColorUniform3(render_, &u_blendFixB, gstate.getFixB());
}
SetColorUniform3(render_, &u_blendFixA, gstate.getFixA());
SetColorUniform3(render_, &u_blendFixB, gstate.getFixB());
const float fbotexSize[2] = {
1.0f / (float)gstate_c.curRTRenderWidth,
1.0f / (float)gstate_c.curRTRenderHeight,
};
if (u_fbotexSize != -1) {
render_->SetUniformF(&u_fbotexSize, 2, fbotexSize);
}
render_->SetUniformF(&u_fbotexSize, 2, fbotexSize);
}
// Lighting
@@ -564,15 +565,13 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, const ShaderLanguageDesc
} else {
SetFloat24Uniform3(render_, &u_lightpos[i], &gstate.lpos[i * 3]);
}
if (u_lightdir[i] != -1) SetFloat24Uniform3Normalized(render_, &u_lightdir[i], &gstate.ldir[i * 3]);
if (u_lightatt[i] != -1) SetFloat24Uniform3(render_, &u_lightatt[i], &gstate.latt[i * 3]);
if (u_lightangle_spotCoef[i] != -1) {
float lightangle_spotCoef[2] = { getFloat24(gstate.lcutoff[i]), PSPLightExponent(getFloat24(gstate.lconv[i])) };
SetFloatUniform2(render_, &u_lightangle_spotCoef[i], lightangle_spotCoef);
}
if (u_lightambient[i] != -1) SetColorUniform3(render_, &u_lightambient[i], gstate.lcolor[i * 3]);
if (u_lightdiffuse[i] != -1) SetColorUniform3(render_, &u_lightdiffuse[i], gstate.lcolor[i * 3 + 1]);
if (u_lightspecular[i] != -1) SetColorUniform3(render_, &u_lightspecular[i], gstate.lcolor[i * 3 + 2]);
SetFloat24Uniform3Normalized(render_, &u_lightdir[i], &gstate.ldir[i * 3]);
SetFloat24Uniform3(render_, &u_lightatt[i], &gstate.latt[i * 3]);
float lightangle_spotCoef[2] = { getFloat24(gstate.lcutoff[i]), PSPLightExponent(getFloat24(gstate.lconv[i])) };
SetFloatUniform2(render_, &u_lightangle_spotCoef[i], lightangle_spotCoef);
SetColorUniform3(render_, &u_lightambient[i], gstate.lcolor[i * 3]);
SetColorUniform3(render_, &u_lightdiffuse[i], gstate.lcolor[i * 3 + 1]);
SetColorUniform3(render_, &u_lightspecular[i], gstate.lcolor[i * 3 + 2]);
}
}
}
+1
View File
@@ -70,6 +70,7 @@ public:
int u_texmtx;
int u_world;
int u_mipBias;
int u_texLodBias;
int u_scaleX;
int u_scaleY;
int u_NaN;
+3 -1
View File
@@ -895,8 +895,10 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
}
// See the documentation for gstate_c.blueToAlpha.
// With framebuffer fetch, the shader applies the masks and logic ops to the real bits, which gets the whole
// sequence right (OutRun 2006's water mask comes out like the software renderer's), so it isn't needed there.
bool blueToAlpha = false;
if (PSP_CoreParameter().compat.flags().BlueToAlpha) {
if (PSP_CoreParameter().compat.flags().BlueToAlpha && !gstate_c.Use(GPU_USE_FRAMEBUFFER_FETCH)) {
if (gstate_c.framebufFormat == GEBufferFormat::GE_FORMAT_565 && gstate.getColorMask() == 0x0FFFFF && !gstate.isLogicOpEnabled()) {
blueToAlpha = true;
gstate_c.framebufFormat = GEBufferFormat::GE_FORMAT_4444;
+8 -1
View File
@@ -2072,7 +2072,7 @@ ULUS10064 = true
ULKS46087 = true
[CorrectCullAfterClip]
# Only two known games need culling to happen accurately *after* clipping: Sengoku Cannon and Flatout.
# Only a few known games need culling to happen accurately *after* clipping: Sengoku Cannon, Flatout, GachiTora and Nova.
# Sengoku Cannon
UCAS40019 = true
@@ -2083,6 +2083,13 @@ ULUS10328 = true
ULES00968 = true
ULES00969 = true
# GachiTora! Abarenbou Kyoushi in High School: a sliver at the screen edge from a strip through the near plane
ULJS00355 = true
NPJH50409 = true
# Nova (minis): like GachiTora
NPUZ00179 = true
[SpriteBorderFix]
# TODO: We really need some kind of aggregation method... saying that Ridge racer is this list of IDs.
+5 -2
View File
@@ -181,8 +181,11 @@ class AdbDevice:
self.adb("push", "--sync", str(test_root) + "/.", self.dir + "/dumps")
self.shell("rm -rf %s/shots && mkdir -p %s/shots" % (shlex.quote(self.dir), shlex.quote(self.dir)))
model = self.shell("getprop ro.product.model").stdout.strip()
gpu = self.shell("dumpsys SurfaceFlinger | grep GLES", check=False).stdout.strip()
return "%s (%s)" % (model, gpu) if gpu else model
soc = self.shell("getprop ro.soc.model", check=False).stdout.strip()
# SurfaceFlinger names the GPU, except where it reports its own render engine instead (Samsung's Skia).
gles = self.shell("dumpsys SurfaceFlinger | grep GLES", check=False).stdout.strip()
gpu = next((l.strip() for l in gles.splitlines() if re.search(r"Adreno|Mali|Immortalis|PowerVR|Xclipse", l)), "")
return ", ".join(s for s in (model, soc, gpu) if s)
def run_side_by_side(headless, host_args, device, dump_path, rel, variant_args, host_path, actual_path, diff_path,
+5 -1
View File
@@ -1128,8 +1128,12 @@ int main(int argc, const char* argv[]) {
coreParameter.disabledGPUFeatures |= GPU_USE_CULL_DISTANCE;
} else if (name == "depth-clamp") {
coreParameter.disabledGPUFeatures |= GPU_USE_DEPTH_CLAMP;
} else if (name == "framebuffer-fetch") {
coreParameter.disabledGPUFeatures |= GPU_USE_FRAMEBUFFER_FETCH;
} else if (name == "dual-source-blend") {
coreParameter.disabledGPUFeatures |= GPU_USE_DUALSOURCE_BLEND;
} else {
fprintf(stderr, "Unknown feature for --disable-gpu-features: %s (expected clip-distance, cull-distance or depth-clamp)\n", name.c_str());
fprintf(stderr, "Unknown feature for --disable-gpu-features: %s (expected clip-distance, cull-distance, depth-clamp, framebuffer-fetch or dual-source-blend)\n", name.c_str());
return 1;
}
}