Merge pull request #9638 from unknownbrackets/gpu-minor

Oops, rebuild FBOs when buffered changes
This commit is contained in:
Henrik Rydgård
2017-04-25 02:09:50 +02:00
committed by GitHub
18 changed files with 96 additions and 208 deletions
+1 -2
View File
@@ -383,8 +383,7 @@ void PSPSaveDialog::DisplaySaveIcon()
PPGeDisableTexture();
}
PPGeDrawImage(x, y, w, h, 0, 0, 1, 1, tw, th, textureColor);
if (curSave.texture != NULL)
PPGeSetDefaultTexture();
PPGeSetDefaultTexture();
}
void PSPSaveDialog::DisplaySaveDataInfo1()
+1 -1
View File
@@ -489,7 +489,6 @@ const HLEFunction *GetSyscallFuncPointer(MIPSOpcode op)
ERROR_LOG(HLE, "Syscall had bad function number %d in module %d - probably executing garbage", funcnum, modulenum);
return NULL;
}
DEBUG_LOG(HLE, "Compiling syscall to %s", moduleDB[modulenum].funcTable[funcnum].name);
return &moduleDB[modulenum].funcTable[funcnum];
}
@@ -500,6 +499,7 @@ void *GetQuickSyscallFunc(MIPSOpcode op) {
const HLEFunction *info = GetSyscallFuncPointer(op);
if (!info || !info->func)
return nullptr;
DEBUG_LOG(HLE, "Compiling syscall to %s", info->name);
// TODO: Do this with a flag?
if (op == idleOp)
+55 -9
View File
@@ -33,6 +33,7 @@
#include "Core/System.h"
#include "Core/HLE/sceDisplay.h"
#include "GPU/Common/FramebufferCommon.h"
#include "GPU/Common/PostShader.h"
#include "GPU/Common/TextureCacheCommon.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUState.h"
@@ -142,7 +143,7 @@ void FramebufferManagerCommon::Init() {
bool FramebufferManagerCommon::UpdateSize() {
const bool newRender = renderWidth_ != (float)PSP_CoreParameter().renderWidth || renderHeight_ != (float)PSP_CoreParameter().renderHeight;
const bool newSettings = bloomHack_ != g_Config.iBloomHack || trueColor_ != g_Config.bTrueColor;
const bool newSettings = bloomHack_ != g_Config.iBloomHack || trueColor_ != g_Config.bTrueColor || useBufferedRendering_ != (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
renderWidth_ = (float)PSP_CoreParameter().renderWidth;
renderHeight_ = (float)PSP_CoreParameter().renderHeight;
@@ -150,6 +151,7 @@ bool FramebufferManagerCommon::UpdateSize() {
pixelHeight_ = PSP_CoreParameter().pixelHeight;
bloomHack_ = g_Config.iBloomHack;
trueColor_ = g_Config.bTrueColor;
useBufferedRendering_ = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
return newRender || newSettings;
}
@@ -157,7 +159,6 @@ bool FramebufferManagerCommon::UpdateSize() {
void FramebufferManagerCommon::BeginFrame() {
DecimateFBOs();
currentRenderVfb_ = 0;
useBufferedRendering_ = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
updateVRAM_ = !(g_Config.iRenderingMode == FB_NON_BUFFERED_MODE || g_Config.iRenderingMode == FB_BUFFERED_MODE);
}
@@ -579,16 +580,15 @@ void FramebufferManagerCommon::NotifyRenderFramebufferSwitched(VirtualFramebuffe
textureCache_->ForgetLastTexture();
if (useBufferedRendering_) {
if (vfb->fbo) {
draw_->BindFramebufferAsRenderTarget(vfb->fbo);
} else {
// wtf? This should only happen very briefly when toggling bBufferedRendering
draw_->BindBackbufferAsRenderTarget();
// This should only happen very briefly when toggling useBufferedRendering_.
ResizeFramebufFBO(vfb, vfb->width, vfb->height, true);
}
} else {
if (vfb->fbo) {
// wtf? This should only happen very briefly when toggling bBufferedRendering
// This should only happen very briefly when toggling useBufferedRendering_.
textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_DESTROYED);
delete vfb->fbo;
vfb->fbo = nullptr;
@@ -770,7 +770,7 @@ void FramebufferManagerCommon::DrawFramebufferToOutput(const u8 *srcPixels, GEBu
// Should try to unify this path with the regular path somehow, but this simple solution works for most of the post shaders
// (it always runs at output resolution so FXAA may look odd).
float x, y, w, h;
int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
int uvRotation = useBufferedRendering_ ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, uvRotation);
if (applyPostShader && useBufferedRendering_) {
// Might've changed if the shader was just changed to Off.
@@ -931,7 +931,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
draw_->BindFramebufferAsTexture(vfb->fbo, 0, Draw::FB_COLOR_BIT, 0);
int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
int uvRotation = useBufferedRendering_ ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
// Output coordinates
float x, y, w, h;
@@ -1045,7 +1045,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput() {
}
void FramebufferManagerCommon::DecimateFBOs() {
if (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) {
if (useBufferedRendering_) {
draw_->BindBackbufferAsRenderTarget();
}
currentRenderVfb_ = 0;
@@ -1147,6 +1147,10 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w,
}
return;
}
if (!old.fbo && vfb->last_frame_failed != 0 && vfb->last_frame_failed - gpuStats.numFlips < 63) {
// Don't constantly retry FBOs which failed to create.
return;
}
vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, (Draw::FBColorDepth)vfb->colorDepth });
if (old.fbo) {
@@ -1166,6 +1170,7 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w,
if (!vfb->fbo) {
ERROR_LOG(FRAMEBUF, "Error creating FBO! %i x %i", vfb->renderWidth, vfb->renderHeight);
vfb->last_frame_failed = gpuStats.numFlips;
}
}
@@ -1700,6 +1705,47 @@ void FramebufferManagerCommon::SetSafeSize(u16 w, u16 h) {
}
}
void FramebufferManagerCommon::Resized() {
// Check if postprocessing shader is doing upscaling as it requires native resolution
const ShaderInfo *shaderInfo = nullptr;
if (g_Config.sPostShaderName != "Off") {
shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName);
}
postShaderIsUpscalingFilter_ = shaderInfo ? shaderInfo->isUpscalingFilter : false;
// Actually, auto mode should be more granular...
// Round up to a zoom factor for the render size.
int zoom = g_Config.iInternalResolution;
if (zoom == 0) {
// auto mode, use the longest dimension
if (!g_Config.IsPortrait()) {
zoom = (PSP_CoreParameter().pixelWidth + 479) / 480;
} else {
zoom = (PSP_CoreParameter().pixelHeight + 479) / 480;
}
}
if (zoom <= 1 || postShaderIsUpscalingFilter_)
zoom = 1;
if (g_Config.IsPortrait()) {
PSP_CoreParameter().renderWidth = 272 * zoom;
PSP_CoreParameter().renderHeight = 480 * zoom;
} else {
PSP_CoreParameter().renderWidth = 480 * zoom;
PSP_CoreParameter().renderHeight = 272 * zoom;
}
gstate_c.skipDrawReason &= ~SKIPDRAW_NON_DISPLAYED_FB;
#ifdef _WIN32
// Seems related - if you're ok with numbers all the time, show some more :)
if (g_Config.iShowFPSCounter != 0) {
ShowScreenResolution();
}
#endif
}
void FramebufferManagerCommon::CalculatePostShaderUniforms(int bufferWidth, int bufferHeight, int renderWidth, int renderHeight, PostShaderUniforms *uniforms) {
float u_delta = 1.0f / renderWidth;
float v_delta = 1.0f / renderHeight;
+2 -1
View File
@@ -75,6 +75,7 @@ struct VirtualFramebuffer {
int last_frame_render;
int last_frame_displayed;
int last_frame_clut;
int last_frame_failed;
u32 clutUpdatedBytes;
bool memoryUpdated;
bool depthUpdated;
@@ -264,7 +265,7 @@ public:
void SetRenderSize(VirtualFramebuffer *vfb);
void SetSafeSize(u16 w, u16 h);
virtual void Resized() = 0;
virtual void Resized();
Draw::Framebuffer *GetTempFBO(u16 w, u16 h, Draw::FBColorDepth depth = Draw::FBO_8888);
+8 -46
View File
@@ -858,55 +858,10 @@ void FramebufferManagerD3D11::PackDepthbuffer(VirtualFramebuffer *vfb, int x, in
}
void FramebufferManagerD3D11::EndFrame() {
if (resized_) {
// Check if postprocessing shader is doing upscaling as it requires native resolution
const ShaderInfo *shaderInfo = 0;
if (g_Config.sPostShaderName != "Off") {
shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName);
}
postShaderIsUpscalingFilter_ = shaderInfo ? shaderInfo->isUpscalingFilter : false;
// Actually, auto mode should be more granular...
// Round up to a zoom factor for the render size.
int zoom = g_Config.iInternalResolution;
if (zoom == 0) {
// auto mode, use the longest dimension
if (!g_Config.IsPortrait()) {
zoom = (PSP_CoreParameter().pixelWidth + 479) / 480;
} else {
zoom = (PSP_CoreParameter().pixelHeight + 479) / 480;
}
}
if (zoom <= 1 || postShaderIsUpscalingFilter_)
zoom = 1;
if (g_Config.IsPortrait()) {
PSP_CoreParameter().renderWidth = 272 * zoom;
PSP_CoreParameter().renderHeight = 480 * zoom;
} else {
PSP_CoreParameter().renderWidth = 480 * zoom;
PSP_CoreParameter().renderHeight = 272 * zoom;
}
if (UpdateSize() || g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
DestroyAllFBOs();
}
// Seems related - if you're ok with numbers all the time, show some more :)
if (g_Config.iShowFPSCounter != 0) {
ShowScreenResolution();
}
resized_ = false;
// Might have a new post shader - let's compile it.
CompilePostShader();
}
}
void FramebufferManagerD3D11::DeviceLost() {
DestroyAllFBOs();
resized_ = false;
}
std::vector<FramebufferInfo> FramebufferManagerD3D11::GetFramebufferList() {
@@ -968,7 +923,14 @@ void FramebufferManagerD3D11::FlushBeforeCopy() {
}
void FramebufferManagerD3D11::Resized() {
resized_ = true;
FramebufferManagerCommon::Resized();
if (UpdateSize()) {
DestroyAllFBOs();
}
// Might have a new post shader - let's compile it.
CompilePostShader();
}
// Lots of this code could be shared (like the downsampling).
-2
View File
@@ -153,8 +153,6 @@ private:
// Used by post-processing shader
std::vector<Draw::Framebuffer *> extraFBOs_;
bool resized_;
#if 0
AsyncPBO *pixelBufObj_; //this isn't that large
u8 currentPBO_;
+1
View File
@@ -301,6 +301,7 @@ void GPU_D3D11::BeginHostFrame() {
GPUCommon::BeginHostFrame();
UpdateCmdInfo();
if (resized_) {
framebufferManager_->Resized();
drawEngine_.Resized();
textureCacheD3D11_->NotifyConfigChanged();
shaderManagerD3D11_->DirtyLastShader();
+5 -34
View File
@@ -753,43 +753,10 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
}
void FramebufferManagerDX9::EndFrame() {
if (resized_) {
// Actually, auto mode should be more granular...
// Round up to a zoom factor for the render size.
int zoom = g_Config.iInternalResolution;
if (zoom == 0) { // auto mode
// Use the longest dimension
if (!g_Config.IsPortrait()) {
zoom = (PSP_CoreParameter().pixelWidth + 479) / 480;
} else {
zoom = (PSP_CoreParameter().pixelHeight + 479) / 480;
}
}
if (zoom <= 1)
zoom = 1;
if (g_Config.IsPortrait()) {
PSP_CoreParameter().renderWidth = 272 * zoom;
PSP_CoreParameter().renderHeight = 480 * zoom;
} else {
PSP_CoreParameter().renderWidth = 480 * zoom;
PSP_CoreParameter().renderHeight = 272 * zoom;
}
if (UpdateSize() || g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
DestroyAllFBOs();
}
// Seems related - if you're ok with numbers all the time, show some more :)
if (g_Config.iShowFPSCounter != 0) {
ShowScreenResolution();
}
resized_ = false;
}
}
void FramebufferManagerDX9::DeviceLost() {
DestroyAllFBOs();
resized_ = false;
}
std::vector<FramebufferInfo> FramebufferManagerDX9::GetFramebufferList() {
@@ -868,7 +835,11 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
}
void FramebufferManagerDX9::Resized() {
resized_ = true;
FramebufferManagerCommon::Resized();
if (UpdateSize()) {
DestroyAllFBOs();
}
}
bool FramebufferManagerDX9::GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat fb_format, GPUDebugBuffer &buffer, int maxRes) {
-2
View File
@@ -128,8 +128,6 @@ private:
// Used by post-processing shader
std::vector<Draw::Framebuffer *> extraFBOs_;
bool resized_;
struct TempFBO {
Draw::Framebuffer *fbo;
int last_frame_used;
+1
View File
@@ -268,6 +268,7 @@ void GPU_DX9::BeginHostFrame() {
GPUCommon::BeginHostFrame();
UpdateCmdInfo();
if (resized_) {
framebufferManager_->Resized();
drawEngine_.Resized();
shaderManagerDX9_->DirtyShader();
textureCacheDX9_->NotifyConfigChanged();
+13 -53
View File
@@ -230,7 +230,6 @@ FramebufferManagerGLES::FramebufferManagerGLES(Draw::DrawContext *draw) :
deltaLoc_(-1),
textureCacheGL_(nullptr),
shaderManagerGL_(nullptr),
resized_(false),
pixelBufObj_(nullptr),
currentPBO_(0)
{
@@ -240,7 +239,7 @@ FramebufferManagerGLES::FramebufferManagerGLES(Draw::DrawContext *draw) :
void FramebufferManagerGLES::Init() {
FramebufferManagerCommon::Init();
// Workaround for upscaling shaders where we force x1 resolution without saving it
resized_ = true;
Resized();
CompileDraw2DProgram();
SetLineWidth();
}
@@ -1149,55 +1148,6 @@ void FramebufferManagerGLES::PackDepthbuffer(VirtualFramebuffer *vfb, int x, int
void FramebufferManagerGLES::EndFrame() {
CHECK_GL_ERROR_IF_DEBUG();
if (resized_) {
// Check if postprocessing shader is doing upscaling as it requires native resolution
const ShaderInfo *shaderInfo = nullptr;
if (g_Config.sPostShaderName != "Off") {
shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName);
}
postShaderIsUpscalingFilter_ = shaderInfo ? shaderInfo->isUpscalingFilter : false;
// Actually, auto mode should be more granular...
// Round up to a zoom factor for the render size.
int zoom = g_Config.iInternalResolution;
if (zoom == 0) { // auto mode
// Use the longest dimension
if (!g_Config.IsPortrait()) {
zoom = (PSP_CoreParameter().pixelWidth + 479) / 480;
} else {
zoom = (PSP_CoreParameter().pixelHeight + 479) / 480;
}
}
if (zoom <= 1 || postShaderIsUpscalingFilter_)
zoom = 1;
if (g_Config.IsPortrait()) {
PSP_CoreParameter().renderWidth = 272 * zoom;
PSP_CoreParameter().renderHeight = 480 * zoom;
} else {
PSP_CoreParameter().renderWidth = 480 * zoom;
PSP_CoreParameter().renderHeight = 272 * zoom;
}
if (UpdateSize() || g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
DestroyAllFBOs();
}
resized_ = false;
#ifdef _WIN32
// Seems related - if you're ok with numbers all the time, show some more :)
if (g_Config.iShowFPSCounter != 0) {
ShowScreenResolution();
}
#endif
DestroyDraw2DProgram();
SetLineWidth();
}
if (!draw2dprogram_) {
CompileDraw2DProgram();
}
// We flush to memory last requested framebuffer, if any.
// Only do this in the read-framebuffer modes.
@@ -1223,7 +1173,6 @@ void FramebufferManagerGLES::EndFrame() {
void FramebufferManagerGLES::DeviceLost() {
DestroyAllFBOs();
DestroyDraw2DProgram();
resized_ = false;
}
std::vector<FramebufferInfo> FramebufferManagerGLES::GetFramebufferList() {
@@ -1289,7 +1238,18 @@ void FramebufferManagerGLES::FlushBeforeCopy() {
}
void FramebufferManagerGLES::Resized() {
resized_ = true;
FramebufferManagerCommon::Resized();
if (UpdateSize()) {
DestroyAllFBOs();
}
DestroyDraw2DProgram();
SetLineWidth();
if (!draw2dprogram_) {
CompileDraw2DProgram();
}
}
bool FramebufferManagerGLES::GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes) {
-2
View File
@@ -138,8 +138,6 @@ private:
ShaderManagerGLES *shaderManagerGL_;
DrawEngineGLES *drawEngine_;
bool resized_;
// Not used under ES currently.
AsyncPBO *pixelBufObj_; //this isn't that large
u8 currentPBO_;
+1 -1
View File
@@ -406,7 +406,6 @@ void GPU_GLES::ReinitializeInternal() {
textureCacheGL_->Clear(true);
depalShaderCache_.Clear();
framebufferManagerGL_->DestroyAllFBOs();
framebufferManagerGL_->Resized();
}
void GPU_GLES::InitClearInternal() {
@@ -429,6 +428,7 @@ void GPU_GLES::BeginHostFrame() {
UpdateCmdInfo();
if (resized_) {
CheckGPUFeatures();
framebufferManager_->Resized();
drawEngine_.Resized();
shaderManagerGL_->DirtyShader();
textureCacheGL_->NotifyConfigChanged();
-1
View File
@@ -459,7 +459,6 @@ bool GPUCommon::BusyDrawing() {
void GPUCommon::Resized() {
resized_ = true;
framebufferManager_->Resized();
}
u32 GPUCommon::DrawSync(int mode) {
+6 -49
View File
@@ -89,7 +89,6 @@ FramebufferManagerVulkan::FramebufferManagerVulkan(Draw::DrawContext *draw, Vulk
convBufSize_(0),
textureCacheVulkan_(nullptr),
shaderManagerVulkan_(nullptr),
resized_(false),
pixelBufObj_(nullptr),
currentPBO_(0),
curFrame_(0),
@@ -332,7 +331,7 @@ void FramebufferManagerVulkan::UpdatePostShaderUniforms(int bufferWidth, int buf
void FramebufferManagerVulkan::Init() {
FramebufferManagerCommon::Init();
// Workaround for upscaling shaders where we force x1 resolution without saving it
resized_ = true;
Resized();
}
void FramebufferManagerVulkan::MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height, float &u1, float &v1) {
@@ -1038,51 +1037,6 @@ void FramebufferManagerVulkan::BeginFrameVulkan() {
}
void FramebufferManagerVulkan::EndFrame() {
if (resized_) {
// Check if postprocessing shader is doing upscaling as it requires native resolution
const ShaderInfo *shaderInfo = 0;
if (g_Config.sPostShaderName != "Off") {
ReloadAllPostShaderInfo();
shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName);
}
postShaderIsUpscalingFilter_ = shaderInfo ? shaderInfo->isUpscalingFilter : false;
// Actually, auto mode should be more granular...
// Round up to a zoom factor for the render size.
int zoom = g_Config.iInternalResolution;
if (zoom == 0) { // auto mode
// Use the longest dimension
if (!g_Config.IsPortrait()) {
zoom = (PSP_CoreParameter().pixelWidth + 479) / 480;
} else {
zoom = (PSP_CoreParameter().pixelHeight + 479) / 480;
}
}
if (zoom <= 1 || postShaderIsUpscalingFilter_)
zoom = 1;
if (g_Config.IsPortrait()) {
PSP_CoreParameter().renderWidth = 272 * zoom;
PSP_CoreParameter().renderHeight = 480 * zoom;
} else {
PSP_CoreParameter().renderWidth = 480 * zoom;
PSP_CoreParameter().renderHeight = 272 * zoom;
}
if (UpdateSize() || g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
DestroyAllFBOs();
}
resized_ = false;
#ifdef _WIN32
// Seems related - if you're ok with numbers all the time, show some more :)
if (g_Config.iShowFPSCounter != 0) {
ShowScreenResolution();
}
#endif
}
// We flush to memory last requested framebuffer, if any.
// Only do this in the read-framebuffer modes.
if (updateVRAM_)
@@ -1101,7 +1055,6 @@ void FramebufferManagerVulkan::DeviceLost() {
DestroyAllFBOs();
DestroyDeviceObjects();
resized_ = false;
}
void FramebufferManagerVulkan::DeviceRestore(VulkanContext *vulkan) {
@@ -1162,7 +1115,11 @@ void FramebufferManagerVulkan::FlushBeforeCopy() {
}
void FramebufferManagerVulkan::Resized() {
resized_ = true;
FramebufferManagerCommon::Resized();
if (UpdateSize()) {
DestroyAllFBOs();
}
}
bool FramebufferManagerVulkan::GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxStride) {
-2
View File
@@ -166,8 +166,6 @@ private:
ShaderManagerVulkan *shaderManagerVulkan_;
DrawEngineVulkan *drawEngine_;
bool resized_;
AsyncPBOVulkan *pixelBufObj_;
int currentPBO_;
+1 -1
View File
@@ -206,6 +206,7 @@ void GPU_Vulkan::BeginHostFrame() {
// In case the GPU changed.
BuildReportingInfo();
UpdateCmdInfo();
framebufferManager_->Resized();
drawEngine_.Resized();
textureCacheVulkan_->NotifyConfigChanged();
}
@@ -316,7 +317,6 @@ void GPU_Vulkan::ReinitializeInternal() {
textureCacheVulkan_->Clear(true);
depalShaderCache_.Clear();
framebufferManagerVulkan_->DestroyAllFBOs();
framebufferManagerVulkan_->Resized();
}
void GPU_Vulkan::InitClearInternal() {
+1 -2
View File
@@ -224,8 +224,7 @@ namespace MainWindow
if (g_Config.iTexScalingLevel == TEXSCALING_AUTO)
setTexScalingMultiplier(0);
if (gpu)
gpu->Resized();
NativeMessageReceived("gpu resized", "");
}
void CorrectCursor() {