2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 22:58:25 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2020-10-04 08:04:01 +00:00
|
|
|
#include "Common/Profiler/Profiler.h"
|
2020-10-01 11:05:04 +00:00
|
|
|
#include "Common/Data/Text/I18n.h"
|
2013-07-26 22:44:16 +00:00
|
|
|
|
2020-08-15 10:25:39 +00:00
|
|
|
#include "Common/Log.h"
|
2020-08-10 07:12:51 +00:00
|
|
|
#include "Common/Serialize/Serializer.h"
|
2020-10-04 18:48:47 +00:00
|
|
|
#include "Common/File/FileUtil.h"
|
2015-12-31 15:59:40 +00:00
|
|
|
#include "Common/GraphicsContext.h"
|
2022-10-17 16:36:54 +00:00
|
|
|
#include "Common/VR/PPSSPPVR.h"
|
2013-12-29 22:28:31 +00:00
|
|
|
|
2015-09-05 19:23:58 +00:00
|
|
|
#include "Core/Config.h"
|
2013-12-14 22:54:05 +00:00
|
|
|
#include "Core/Debugger/Breakpoints.h"
|
2015-04-06 01:03:50 +00:00
|
|
|
#include "Core/MemMapHelpers.h"
|
2013-01-30 20:09:53 +00:00
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "Core/Config.h"
|
2013-05-11 05:51:23 +00:00
|
|
|
#include "Core/Reporting.h"
|
2013-01-30 20:09:53 +00:00
|
|
|
#include "Core/System.h"
|
2016-01-17 19:29:34 +00:00
|
|
|
#include "Core/ELF/ParamSFO.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-08-20 20:34:47 +00:00
|
|
|
#include "GPU/GPUState.h"
|
|
|
|
#include "GPU/ge_constants.h"
|
|
|
|
#include "GPU/GeDisasm.h"
|
2020-08-03 21:17:22 +00:00
|
|
|
#include "GPU/Common/FramebufferManagerCommon.h"
|
2017-01-21 21:16:30 +00:00
|
|
|
#include "GPU/GLES/ShaderManagerGLES.h"
|
2016-04-10 08:27:28 +00:00
|
|
|
#include "GPU/GLES/GPU_GLES.h"
|
2017-01-21 21:16:30 +00:00
|
|
|
#include "GPU/GLES/FramebufferManagerGLES.h"
|
2016-04-10 08:27:28 +00:00
|
|
|
#include "GPU/GLES/DrawEngineGLES.h"
|
2017-01-21 21:16:30 +00:00
|
|
|
#include "GPU/GLES/TextureCacheGLES.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2014-03-15 18:44:02 +00:00
|
|
|
#include "Core/MIPS/MIPS.h"
|
2013-08-20 20:34:47 +00:00
|
|
|
#include "Core/HLE/sceKernelThread.h"
|
|
|
|
#include "Core/HLE/sceKernelInterrupt.h"
|
|
|
|
#include "Core/HLE/sceGe.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2015-09-06 11:36:33 +00:00
|
|
|
#ifdef _WIN32
|
2015-11-03 22:22:09 +00:00
|
|
|
#include "Windows/GPU/WindowsGLContext.h"
|
2015-09-06 11:36:33 +00:00
|
|
|
#endif
|
|
|
|
|
2017-01-30 15:50:35 +00:00
|
|
|
GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
2022-08-05 11:27:55 +00:00
|
|
|
: GPUCommon(gfxCtx, draw), drawEngine_(draw), fragmentTestCache_(draw) {
|
2014-06-15 22:19:49 +00:00
|
|
|
UpdateVsyncInterval(true);
|
2022-10-17 06:27:49 +00:00
|
|
|
gstate_c.useFlags = CheckGPUFeatures();
|
2013-10-09 08:44:12 +00:00
|
|
|
|
2018-05-29 21:07:22 +00:00
|
|
|
shaderManagerGL_ = new ShaderManagerGLES(draw);
|
2022-08-16 19:38:09 +00:00
|
|
|
framebufferManagerGL_ = new FramebufferManagerGLES(draw);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManager_ = framebufferManagerGL_;
|
2022-08-23 09:11:04 +00:00
|
|
|
textureCacheGL_ = new TextureCacheGLES(draw, framebufferManager_->GetDraw2D());
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCache_ = textureCacheGL_;
|
2017-01-23 20:08:16 +00:00
|
|
|
drawEngineCommon_ = &drawEngine_;
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManager_ = shaderManagerGL_;
|
2017-01-23 20:08:16 +00:00
|
|
|
drawEngineCommon_ = &drawEngine_;
|
2016-12-21 17:07:17 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
drawEngine_.SetShaderManager(shaderManagerGL_);
|
2016-12-21 17:07:17 +00:00
|
|
|
drawEngine_.SetTextureCache(textureCacheGL_);
|
|
|
|
drawEngine_.SetFramebufferManager(framebufferManagerGL_);
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.SetFragmentTestCache(&fragmentTestCache_);
|
2021-05-08 16:10:23 +00:00
|
|
|
drawEngine_.Init();
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->SetTextureCache(textureCacheGL_);
|
2017-01-23 19:48:23 +00:00
|
|
|
framebufferManagerGL_->SetShaderManager(shaderManagerGL_);
|
2017-02-04 10:47:19 +00:00
|
|
|
framebufferManagerGL_->SetDrawEngine(&drawEngine_);
|
2020-05-16 16:57:01 +00:00
|
|
|
framebufferManagerGL_->Init();
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->SetFramebufferManager(framebufferManagerGL_);
|
2017-01-23 19:48:23 +00:00
|
|
|
textureCacheGL_->SetShaderManager(shaderManagerGL_);
|
2017-02-04 10:47:19 +00:00
|
|
|
textureCacheGL_->SetDrawEngine(&drawEngine_);
|
2016-12-21 17:07:17 +00:00
|
|
|
fragmentTestCache_.SetTextureCache(textureCacheGL_);
|
2013-01-30 19:40:26 +00:00
|
|
|
|
2012-11-22 19:57:41 +00:00
|
|
|
// Sanity check gstate
|
|
|
|
if ((int *)&gstate.transferstart - (int *)&gstate != 0xEA) {
|
|
|
|
ERROR_LOG(G3D, "gstate has drifted out of sync!");
|
|
|
|
}
|
2012-12-21 20:49:09 +00:00
|
|
|
|
2013-10-09 08:44:12 +00:00
|
|
|
// No need to flush before the tex scale/offset commands if we are baking
|
|
|
|
// the tex scale/offset into the vertices anyway.
|
2013-10-09 21:09:16 +00:00
|
|
|
|
2018-04-10 10:22:02 +00:00
|
|
|
UpdateCmdInfo();
|
|
|
|
|
2013-04-29 00:49:17 +00:00
|
|
|
BuildReportingInfo();
|
2014-06-15 22:19:49 +00:00
|
|
|
// Update again after init to be sure of any silly driver problems.
|
|
|
|
UpdateVsyncInterval(true);
|
2014-12-30 23:26:16 +00:00
|
|
|
|
2022-09-08 06:41:00 +00:00
|
|
|
textureCache_->NotifyConfigChanged();
|
2016-01-17 16:11:51 +00:00
|
|
|
|
|
|
|
// Load shader cache.
|
2017-06-03 03:54:28 +00:00
|
|
|
std::string discID = g_paramSFO.GetDiscID();
|
2016-01-17 20:35:24 +00:00
|
|
|
if (discID.size()) {
|
2021-11-21 20:23:15 +00:00
|
|
|
if (g_Config.bShaderCache) {
|
|
|
|
File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE));
|
|
|
|
shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) / (discID + ".glshadercache");
|
|
|
|
// Actually precompiled by IsReady() since we're single-threaded.
|
|
|
|
shaderManagerGL_->Load(shaderCachePath_);
|
|
|
|
} else {
|
|
|
|
INFO_LOG(G3D, "Shader cache disabled. Not loading.");
|
|
|
|
}
|
2016-01-17 20:35:24 +00:00
|
|
|
}
|
2017-01-31 14:29:13 +00:00
|
|
|
|
|
|
|
if (g_Config.bHardwareTessellation) {
|
|
|
|
// Disable hardware tessellation if device is unsupported.
|
2020-04-04 18:52:32 +00:00
|
|
|
if (!drawEngine_.SupportsHWTessellation()) {
|
2017-01-31 14:29:13 +00:00
|
|
|
ERROR_LOG(G3D, "Hardware Tessellation is unsupported, falling back to software tessellation");
|
2020-01-26 18:43:18 +00:00
|
|
|
auto gr = GetI18NCategory("Graphics");
|
2017-01-31 14:29:13 +00:00
|
|
|
host->NotifyUserMessage(gr->T("Turn off Hardware Tessellation - unsupported"), 2.5f, 0xFF3030FF);
|
|
|
|
}
|
|
|
|
}
|
2012-11-20 09:59:23 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
GPU_GLES::~GPU_GLES() {
|
2018-04-05 09:25:49 +00:00
|
|
|
if (draw_) {
|
|
|
|
GLRenderManager *render = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
|
|
|
render->Wipe();
|
|
|
|
}
|
2018-02-27 19:40:44 +00:00
|
|
|
|
|
|
|
// If we're here during app shutdown (exiting the Windows app in-game, for example)
|
|
|
|
// everything should already be cleared since DeviceLost has been run.
|
|
|
|
|
2021-05-05 23:31:38 +00:00
|
|
|
if (shaderCachePath_.Valid() && draw_) {
|
2021-11-21 20:23:15 +00:00
|
|
|
if (g_Config.bShaderCache) {
|
|
|
|
shaderManagerGL_->Save(shaderCachePath_);
|
|
|
|
} else {
|
|
|
|
INFO_LOG(G3D, "Shader cache disabled. Not saving.");
|
|
|
|
}
|
2018-06-04 14:00:29 +00:00
|
|
|
}
|
|
|
|
|
2017-04-14 06:07:21 +00:00
|
|
|
framebufferManagerGL_->DestroyAllFBOs();
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->ClearCache(true);
|
2014-08-24 22:26:38 +00:00
|
|
|
fragmentTestCache_.Clear();
|
2018-06-04 14:00:29 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
delete shaderManagerGL_;
|
|
|
|
shaderManagerGL_ = nullptr;
|
2017-02-10 13:41:32 +00:00
|
|
|
delete framebufferManagerGL_;
|
|
|
|
delete textureCacheGL_;
|
2022-11-10 20:05:08 +00:00
|
|
|
|
|
|
|
// Clear features so they're not visible in system info.
|
|
|
|
gstate_c.useFlags = 0;
|
2012-11-19 22:29:14 +00:00
|
|
|
}
|
|
|
|
|
2015-09-05 17:58:47 +00:00
|
|
|
// Take the raw GL extension and versioning data and turn into feature flags.
|
2022-08-07 09:09:34 +00:00
|
|
|
// TODO: This should use DrawContext::GetDeviceCaps() more and more, and eventually
|
|
|
|
// this can be shared between all the backends.
|
2022-09-20 08:02:15 +00:00
|
|
|
u32 GPU_GLES::CheckGPUFeatures() const {
|
|
|
|
u32 features = GPUCommon::CheckGPUFeatures();
|
2017-02-18 00:35:34 +00:00
|
|
|
|
2022-10-17 06:30:27 +00:00
|
|
|
features |= GPU_USE_16BIT_FORMATS;
|
2019-01-03 11:43:00 +00:00
|
|
|
|
2015-09-26 14:01:16 +00:00
|
|
|
if (gl_extensions.GLES3 || !gl_extensions.IsGLES)
|
2022-10-17 06:30:27 +00:00
|
|
|
features |= GPU_USE_TEXTURE_LOD_CONTROL;
|
2015-09-26 14:01:16 +00:00
|
|
|
|
2017-03-26 10:00:20 +00:00
|
|
|
bool canUseInstanceID = gl_extensions.EXT_draw_instanced || gl_extensions.ARB_draw_instanced;
|
2017-09-22 03:20:17 +00:00
|
|
|
bool canDefInstanceID = gl_extensions.IsGLES || gl_extensions.EXT_gpu_shader4 || gl_extensions.VersionGEThan(3, 1);
|
2017-03-28 10:49:37 +00:00
|
|
|
bool instanceRendering = gl_extensions.GLES3 || (canUseInstanceID && canDefInstanceID);
|
2017-12-08 13:30:03 +00:00
|
|
|
if (instanceRendering)
|
2022-10-17 06:30:27 +00:00
|
|
|
features |= GPU_USE_INSTANCE_RENDERING;
|
2017-01-31 14:21:22 +00:00
|
|
|
|
2018-01-19 23:05:59 +00:00
|
|
|
int maxVertexTextureImageUnits = gl_extensions.maxVertexTextureUnits;
|
2017-01-31 14:21:22 +00:00
|
|
|
if (maxVertexTextureImageUnits >= 3) // At least 3 for hardware tessellation
|
2022-10-17 06:30:27 +00:00
|
|
|
features |= GPU_USE_VERTEX_TEXTURE_FETCH;
|
2017-01-31 14:21:22 +00:00
|
|
|
|
2017-03-12 15:41:28 +00:00
|
|
|
if (gl_extensions.ARB_texture_float || gl_extensions.OES_texture_float)
|
2022-10-17 06:30:27 +00:00
|
|
|
features |= GPU_USE_TEXTURE_FLOAT;
|
2017-01-31 14:21:22 +00:00
|
|
|
|
2016-02-07 04:28:45 +00:00
|
|
|
// The Phantasy Star hack :(
|
2022-10-17 06:30:27 +00:00
|
|
|
if (PSP_CoreParameter().compat.flags().DepthRangeHack && (features & GPU_USE_ACCURATE_DEPTH) == 0) {
|
2016-02-07 04:28:45 +00:00
|
|
|
features |= GPU_USE_DEPTH_RANGE_HACK;
|
|
|
|
}
|
|
|
|
|
2022-10-11 14:09:57 +00:00
|
|
|
if (!draw_->GetShaderLanguageDesc().bitwiseOps) {
|
|
|
|
features |= GPU_USE_FRAGMENT_TEST_CACHE;
|
|
|
|
}
|
|
|
|
|
2022-11-06 13:36:51 +00:00
|
|
|
if (IsVREnabled()) {
|
2022-10-17 16:36:54 +00:00
|
|
|
features |= GPU_USE_VIRTUAL_REALITY;
|
|
|
|
}
|
|
|
|
if (IsMultiviewSupported()) {
|
|
|
|
features |= GPU_USE_SINGLE_PASS_STEREO;
|
|
|
|
}
|
|
|
|
|
2022-11-24 09:09:47 +00:00
|
|
|
features = CheckGPUFeaturesLate(features);
|
|
|
|
|
|
|
|
if (draw_->GetBugs().Has(Draw::Bugs::ADRENO_RESOURCE_DEADLOCK) && g_Config.bVendorBugChecksEnabled) {
|
2022-11-23 16:32:32 +00:00
|
|
|
if (PSP_CoreParameter().compat.flags().OldAdrenoPixelDepthRoundingGL) {
|
|
|
|
features |= GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-13 16:04:47 +00:00
|
|
|
// This is a bit ugly, but lets us reuse most of the depth logic in GPUCommon.
|
|
|
|
if (features & GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT) {
|
|
|
|
if (gl_extensions.IsGLES && !gl_extensions.GLES3) {
|
|
|
|
// Unsupported, switch to GPU_ROUND_DEPTH_TO_16BIT instead.
|
|
|
|
features &= ~GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT;
|
|
|
|
features |= GPU_ROUND_DEPTH_TO_16BIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-20 08:02:15 +00:00
|
|
|
return features;
|
2015-09-05 17:58:47 +00:00
|
|
|
}
|
|
|
|
|
2017-12-03 19:30:00 +00:00
|
|
|
bool GPU_GLES::IsReady() {
|
|
|
|
return shaderManagerGL_->ContinuePrecompile();
|
|
|
|
}
|
|
|
|
|
2018-10-31 03:32:12 +00:00
|
|
|
void GPU_GLES::CancelReady() {
|
|
|
|
shaderManagerGL_->CancelPrecompile();
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::BuildReportingInfo() {
|
2018-01-21 16:49:34 +00:00
|
|
|
GLRenderManager *render = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
|
|
|
|
|
|
|
std::string glVendor = render->GetGLString(GL_VENDOR);
|
|
|
|
std::string glRenderer = render->GetGLString(GL_RENDERER);
|
|
|
|
std::string glVersion = render->GetGLString(GL_VERSION);
|
|
|
|
std::string glSlVersion = render->GetGLString(GL_SHADING_LANGUAGE_VERSION);
|
|
|
|
std::string glExtensions;
|
2015-12-23 23:30:08 +00:00
|
|
|
|
|
|
|
if (gl_extensions.VersionGEThan(3, 0)) {
|
2018-01-21 16:49:34 +00:00
|
|
|
glExtensions = g_all_gl_extensions;
|
2015-12-23 23:30:08 +00:00
|
|
|
} else {
|
2018-01-21 16:49:34 +00:00
|
|
|
glExtensions = render->GetGLString(GL_EXTENSIONS);
|
2015-12-23 23:30:08 +00:00
|
|
|
}
|
2013-04-29 00:49:17 +00:00
|
|
|
|
2013-05-12 08:38:42 +00:00
|
|
|
char temp[16384];
|
2018-01-21 16:49:34 +00:00
|
|
|
snprintf(temp, sizeof(temp), "%s (%s %s), %s (extensions: %s)", glVersion.c_str(), glVendor.c_str(), glRenderer.c_str(), glSlVersion.c_str(), glExtensions.c_str());
|
2013-04-29 07:30:54 +00:00
|
|
|
reportingPrimaryInfo_ = glVendor;
|
|
|
|
reportingFullInfo_ = temp;
|
2014-02-15 23:18:01 +00:00
|
|
|
|
|
|
|
Reporting::UpdateConfig();
|
2013-04-29 00:49:17 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::DeviceLost() {
|
2020-08-15 14:13:24 +00:00
|
|
|
INFO_LOG(G3D, "GPU_GLES: DeviceLost");
|
2013-08-08 06:27:29 +00:00
|
|
|
|
2017-11-19 11:25:57 +00:00
|
|
|
// Simply drop all caches and textures.
|
|
|
|
// FBOs appear to survive? Or no?
|
|
|
|
// TransformDraw has registered as a GfxResourceHolder.
|
2018-10-31 03:32:12 +00:00
|
|
|
CancelReady();
|
2018-05-29 21:07:22 +00:00
|
|
|
shaderManagerGL_->DeviceLost();
|
2018-04-05 09:25:49 +00:00
|
|
|
textureCacheGL_->DeviceLost();
|
2018-05-29 21:07:22 +00:00
|
|
|
fragmentTestCache_.DeviceLost();
|
2017-12-09 22:58:08 +00:00
|
|
|
drawEngine_.DeviceLost();
|
2020-11-06 23:56:48 +00:00
|
|
|
|
|
|
|
GPUCommon::DeviceLost();
|
2016-09-11 03:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_GLES::DeviceRestore() {
|
2020-11-06 23:56:48 +00:00
|
|
|
GPUCommon::DeviceRestore();
|
2014-06-15 22:19:49 +00:00
|
|
|
|
2018-04-10 10:22:02 +00:00
|
|
|
UpdateCmdInfo();
|
2014-06-15 22:19:49 +00:00
|
|
|
UpdateVsyncInterval(true);
|
2017-12-07 13:56:19 +00:00
|
|
|
|
2018-05-29 21:07:22 +00:00
|
|
|
shaderManagerGL_->DeviceRestore(draw_);
|
2017-12-07 13:56:19 +00:00
|
|
|
textureCacheGL_->DeviceRestore(draw_);
|
2018-05-27 20:19:03 +00:00
|
|
|
drawEngine_.DeviceRestore(draw_);
|
2018-05-29 21:07:22 +00:00
|
|
|
fragmentTestCache_.DeviceRestore(draw_);
|
2012-12-25 14:28:34 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_GLES::Reinitialize() {
|
|
|
|
GPUCommon::Reinitialize();
|
2014-06-28 19:29:09 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_GLES::InitClear() {
|
2012-11-19 20:23:29 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2017-03-17 09:48:43 +00:00
|
|
|
void GPU_GLES::BeginHostFrame() {
|
|
|
|
GPUCommon::BeginHostFrame();
|
2017-11-19 11:25:57 +00:00
|
|
|
drawEngine_.BeginFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_GLES::EndHostFrame() {
|
|
|
|
drawEngine_.EndFrame();
|
2017-03-17 09:48:43 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_GLES::ReapplyGfxState() {
|
|
|
|
GPUCommon::ReapplyGfxState();
|
2015-09-06 10:23:14 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_GLES::BeginFrame() {
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->StartFrame();
|
2014-08-24 22:26:38 +00:00
|
|
|
fragmentTestCache_.Decimate();
|
2012-11-22 22:07:15 +00:00
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
GPUCommon::BeginFrame();
|
2016-01-17 19:29:34 +00:00
|
|
|
|
2018-03-13 22:22:21 +00:00
|
|
|
// Save the cache from time to time. TODO: How often? We save on exit, so shouldn't need to do this all that often.
|
2021-05-05 23:31:38 +00:00
|
|
|
if (shaderCachePath_.Valid() && (gpuStats.numFlips & 4095) == 0) {
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->Save(shaderCachePath_);
|
2016-01-17 20:35:24 +00:00
|
|
|
}
|
2016-01-17 16:11:51 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->DirtyShader();
|
2012-12-25 14:28:34 +00:00
|
|
|
|
|
|
|
// Not sure if this is really needed.
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_ALL_UNIFORMS);
|
2012-12-25 14:28:34 +00:00
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->BeginFrame();
|
2012-11-19 20:23:29 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2020-03-01 21:55:28 +00:00
|
|
|
void GPU_GLES::CopyDisplayToOutput(bool reallyDirty) {
|
2014-06-11 07:28:28 +00:00
|
|
|
// Flush anything left over.
|
2020-06-02 07:51:38 +00:00
|
|
|
framebufferManagerGL_->RebindFramebuffer("RebindFramebuffer - CopyDisplayToOutput");
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Flush();
|
2014-06-11 07:28:28 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->DirtyLastShader();
|
2014-06-23 04:03:33 +00:00
|
|
|
|
2020-03-01 21:55:28 +00:00
|
|
|
framebufferManagerGL_->CopyDisplayToOutput(reallyDirty);
|
2012-11-19 22:29:14 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::FinishDeferred() {
|
2015-03-15 01:11:00 +00:00
|
|
|
// This finishes reading any vertex data that is pending.
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.FinishDeferred();
|
2015-03-15 01:11:00 +00:00
|
|
|
}
|
2014-12-06 10:21:07 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
inline void GPU_GLES::CheckFlushOp(int cmd, u32 diff) {
|
2014-04-17 08:36:24 +00:00
|
|
|
const u8 cmdFlags = cmdInfo_[cmd].flags;
|
2017-08-17 11:05:13 +00:00
|
|
|
if (diff && (cmdFlags & FLAG_FLUSHBEFOREONCHANGE)) {
|
2013-01-20 12:15:46 +00:00
|
|
|
if (dumpThisFrame_) {
|
2013-09-07 20:02:55 +00:00
|
|
|
NOTICE_LOG(G3D, "================ FLUSH ================");
|
2013-01-20 12:15:46 +00:00
|
|
|
}
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Flush();
|
2013-01-20 12:15:46 +00:00
|
|
|
}
|
2012-12-29 01:10:29 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::PreExecuteOp(u32 op, u32 diff) {
|
2013-08-06 17:08:38 +00:00
|
|
|
CheckFlushOp(op >> 24, diff);
|
2013-04-28 21:23:30 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::ExecuteOp(u32 op, u32 diff) {
|
2014-04-13 17:23:21 +00:00
|
|
|
const u8 cmd = op >> 24;
|
2014-04-17 08:36:24 +00:00
|
|
|
const CommandInfo info = cmdInfo_[cmd];
|
|
|
|
const u8 cmdFlags = info.flags;
|
2014-04-13 17:23:21 +00:00
|
|
|
if ((cmdFlags & FLAG_EXECUTE) || (diff && (cmdFlags & FLAG_EXECUTEONCHANGE))) {
|
2014-04-17 08:36:24 +00:00
|
|
|
(this->*info.func)(op, diff);
|
2017-01-24 09:44:02 +00:00
|
|
|
} else if (diff) {
|
|
|
|
uint64_t dirty = info.flags >> 8;
|
|
|
|
if (dirty)
|
|
|
|
gstate_c.Dirty(dirty);
|
2014-04-13 17:23:21 +00:00
|
|
|
}
|
2013-11-06 15:50:16 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::GetStats(char *buffer, size_t bufsize) {
|
2020-09-20 19:33:06 +00:00
|
|
|
size_t offset = FormatGPUStatsCommon(buffer, bufsize);
|
|
|
|
buffer += offset;
|
|
|
|
bufsize -= offset;
|
|
|
|
if ((int)bufsize < 0)
|
|
|
|
return;
|
|
|
|
snprintf(buffer, bufsize,
|
|
|
|
"Vertex, Fragment, Programs loaded: %d, %d, %d\n",
|
2017-02-08 17:07:34 +00:00
|
|
|
shaderManagerGL_->GetNumVertexShaders(),
|
|
|
|
shaderManagerGL_->GetNumFragmentShaders(),
|
2020-09-20 19:33:06 +00:00
|
|
|
shaderManagerGL_->GetNumPrograms()
|
|
|
|
);
|
2012-11-26 16:35:08 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::DoState(PointerWrap &p) {
|
2013-01-26 23:15:39 +00:00
|
|
|
GPUCommon::DoState(p);
|
|
|
|
|
2013-09-29 20:19:32 +00:00
|
|
|
// TODO: Some of these things may not be necessary.
|
|
|
|
// None of these are necessary when saving.
|
2013-11-15 15:30:55 +00:00
|
|
|
// In Freeze-Frame mode, we don't want to do any of this.
|
|
|
|
if (p.mode == p.MODE_READ && !PSP_CoreParameter().frozen) {
|
2020-05-13 07:06:13 +00:00
|
|
|
textureCache_->Clear(true);
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.ClearTrackedVertexArrays();
|
2013-01-26 23:15:39 +00:00
|
|
|
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
2020-05-13 07:06:13 +00:00
|
|
|
framebufferManager_->DestroyAllFBOs();
|
2013-09-29 20:19:32 +00:00
|
|
|
}
|
2012-12-29 20:21:56 +00:00
|
|
|
}
|
2013-09-23 02:03:31 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
std::vector<std::string> GPU_GLES::DebugGetShaderIDs(DebugShaderType type) {
|
2017-04-04 09:09:29 +00:00
|
|
|
switch (type) {
|
|
|
|
case SHADER_TYPE_VERTEXLOADER:
|
2016-04-10 08:21:48 +00:00
|
|
|
return drawEngine_.DebugGetVertexLoaderIDs();
|
2022-08-22 10:28:46 +00:00
|
|
|
case SHADER_TYPE_TEXTURE:
|
|
|
|
return textureCache_->GetTextureShaderCache()->DebugGetShaderIDs(type);
|
2017-04-04 09:09:29 +00:00
|
|
|
default:
|
2017-01-23 19:48:23 +00:00
|
|
|
return shaderManagerGL_->DebugGetShaderIDs(type);
|
2015-10-21 21:06:32 +00:00
|
|
|
}
|
2015-10-14 15:45:21 +00:00
|
|
|
}
|
2015-10-21 21:06:32 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
std::string GPU_GLES::DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType) {
|
2017-04-04 09:09:29 +00:00
|
|
|
switch (type) {
|
|
|
|
case SHADER_TYPE_VERTEXLOADER:
|
2016-04-10 08:21:48 +00:00
|
|
|
return drawEngine_.DebugGetVertexLoaderString(id, stringType);
|
2022-08-22 10:28:46 +00:00
|
|
|
case SHADER_TYPE_TEXTURE:
|
|
|
|
return textureCache_->GetTextureShaderCache()->DebugGetShaderString(id, type, stringType);
|
2017-04-04 09:09:29 +00:00
|
|
|
default:
|
2017-01-23 19:48:23 +00:00
|
|
|
return shaderManagerGL_->DebugGetShaderString(id, type, stringType);
|
2015-10-21 21:06:32 +00:00
|
|
|
}
|
2015-10-14 15:45:21 +00:00
|
|
|
}
|