2013-08-17 09:23:51 +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
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// 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/.
|
|
|
|
|
2013-12-29 23:55:09 +00:00
|
|
|
#include <set>
|
|
|
|
|
2020-08-10 07:12:51 +00:00
|
|
|
#include "Common/Serialize/Serializer.h"
|
2016-02-13 18:53:28 +00:00
|
|
|
#include "Common/GraphicsContext.h"
|
2020-10-04 08:30:18 +00:00
|
|
|
#include "Common/System/System.h"
|
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"
|
2014-09-14 00:28:35 +00:00
|
|
|
#include "Core/Debugger/Breakpoints.h"
|
2015-04-06 01:03:50 +00:00
|
|
|
#include "Core/MemMapHelpers.h"
|
2014-09-14 00:28:35 +00:00
|
|
|
#include "Core/MIPS/MIPS.h"
|
2013-08-17 09:23:51 +00:00
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "Core/Config.h"
|
2018-06-17 01:42:31 +00:00
|
|
|
#include "Core/ConfigValues.h"
|
2013-08-17 09:23:51 +00:00
|
|
|
#include "Core/Reporting.h"
|
|
|
|
#include "Core/System.h"
|
|
|
|
|
2020-10-04 21:24:14 +00:00
|
|
|
#include "Common/GPU/D3D9/D3D9StateCache.h"
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2013-08-25 11:56:29 +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"
|
2018-09-01 15:32:03 +00:00
|
|
|
#include "GPU/Debugger/Debugger.h"
|
2013-09-15 10:46:14 +00:00
|
|
|
#include "GPU/Directx9/ShaderManagerDX9.h"
|
|
|
|
#include "GPU/Directx9/GPU_DX9.h"
|
2020-08-03 21:24:50 +00:00
|
|
|
#include "GPU/Directx9/FramebufferManagerDX9.h"
|
2016-04-10 08:27:28 +00:00
|
|
|
#include "GPU/Directx9/DrawEngineDX9.h"
|
2013-09-15 10:46:14 +00:00
|
|
|
#include "GPU/Directx9/TextureCacheDX9.h"
|
2013-08-25 11:56:29 +00:00
|
|
|
|
|
|
|
#include "Core/HLE/sceKernelThread.h"
|
|
|
|
#include "Core/HLE/sceKernelInterrupt.h"
|
|
|
|
#include "Core/HLE/sceGe.h"
|
|
|
|
|
2013-09-15 15:53:21 +00:00
|
|
|
namespace DX9 {
|
|
|
|
|
2017-01-30 15:50:35 +00:00
|
|
|
GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
2017-03-02 10:39:02 +00:00
|
|
|
: GPUCommon(gfxCtx, draw),
|
|
|
|
depalShaderCache_(draw),
|
|
|
|
drawEngine_(draw) {
|
2017-02-05 19:36:00 +00:00
|
|
|
device_ = (LPDIRECT3DDEVICE9)draw->GetNativeObject(Draw::NativeObject::DEVICE);
|
|
|
|
deviceEx_ = (LPDIRECT3DDEVICE9EX)draw->GetNativeObject(Draw::NativeObject::DEVICE_EX);
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2018-12-23 20:06:29 +00:00
|
|
|
shaderManagerDX9_ = new ShaderManagerDX9(draw, device_);
|
2017-02-05 18:51:50 +00:00
|
|
|
framebufferManagerDX9_ = new FramebufferManagerDX9(draw);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManager_ = framebufferManagerDX9_;
|
2017-02-05 18:51:50 +00:00
|
|
|
textureCacheDX9_ = new TextureCacheDX9(draw);
|
2016-12-21 17:51:19 +00:00
|
|
|
textureCache_ = textureCacheDX9_;
|
2017-01-21 19:42:40 +00:00
|
|
|
drawEngineCommon_ = &drawEngine_;
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManager_ = shaderManagerDX9_;
|
2016-12-21 17:07:17 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
drawEngine_.SetShaderManager(shaderManagerDX9_);
|
2016-12-21 17:51:19 +00:00
|
|
|
drawEngine_.SetTextureCache(textureCacheDX9_);
|
2016-12-21 17:07:17 +00:00
|
|
|
drawEngine_.SetFramebufferManager(framebufferManagerDX9_);
|
2016-12-21 17:51:19 +00:00
|
|
|
framebufferManagerDX9_->SetTextureCache(textureCacheDX9_);
|
2017-01-23 19:48:23 +00:00
|
|
|
framebufferManagerDX9_->SetShaderManager(shaderManagerDX9_);
|
2017-02-04 10:47:19 +00:00
|
|
|
framebufferManagerDX9_->SetDrawEngine(&drawEngine_);
|
2020-05-16 16:57:01 +00:00
|
|
|
framebufferManagerDX9_->Init();
|
2016-12-21 17:51:19 +00:00
|
|
|
textureCacheDX9_->SetFramebufferManager(framebufferManagerDX9_);
|
|
|
|
textureCacheDX9_->SetDepalShaderCache(&depalShaderCache_);
|
2017-01-23 19:48:23 +00:00
|
|
|
textureCacheDX9_->SetShaderManager(shaderManagerDX9_);
|
2013-08-17 09:23:51 +00:00
|
|
|
|
|
|
|
// Sanity check gstate
|
|
|
|
if ((int *)&gstate.transferstart - (int *)&gstate != 0xEA) {
|
|
|
|
ERROR_LOG(G3D, "gstate has drifted out of sync!");
|
|
|
|
}
|
|
|
|
|
2018-04-10 10:22:02 +00:00
|
|
|
// No need to flush before the tex scale/offset commands if we are baking
|
|
|
|
// the tex scale/offset into the vertices anyway.
|
|
|
|
UpdateCmdInfo();
|
2018-03-01 08:26:45 +00:00
|
|
|
CheckGPUFeatures();
|
2013-12-05 15:37:52 +00:00
|
|
|
|
2014-09-13 10:11:34 +00:00
|
|
|
BuildReportingInfo();
|
2014-12-30 23:26:16 +00:00
|
|
|
|
|
|
|
// Some of our defaults are different from hw defaults, let's assert them.
|
|
|
|
// We restore each frame anyway, but here is convenient for tests.
|
|
|
|
dxstate.Restore();
|
2016-12-21 17:51:19 +00:00
|
|
|
textureCache_->NotifyConfigChanged();
|
2017-02-25 09:04:09 +00:00
|
|
|
|
|
|
|
if (g_Config.bHardwareTessellation) {
|
|
|
|
// Disable hardware tessellation bacause DX9 is still unsupported.
|
|
|
|
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-02-25 09:04:09 +00:00
|
|
|
host->NotifyUserMessage(gr->T("Turn off Hardware Tessellation - unsupported"), 2.5f, 0xFF3030FF);
|
|
|
|
}
|
2014-09-13 10:11:34 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 21:44:02 +00:00
|
|
|
// TODO: Move this detection elsewhere when it's needed elsewhere, not before. It's ugly.
|
|
|
|
// Source: https://envytools.readthedocs.io/en/latest/hw/pciid.html#gf100
|
|
|
|
enum NVIDIAGeneration {
|
|
|
|
NV_PRE_KEPLER,
|
|
|
|
NV_KEPLER,
|
|
|
|
NV_MAXWELL,
|
|
|
|
NV_PASCAL,
|
|
|
|
NV_VOLTA,
|
|
|
|
NV_TURING, // or later
|
|
|
|
};
|
|
|
|
|
|
|
|
static NVIDIAGeneration NVIDIAGetDeviceGeneration(int deviceID) {
|
|
|
|
if (deviceID >= 0x1180 && deviceID <= 0x11bf)
|
|
|
|
return NV_KEPLER; // GK104
|
|
|
|
if (deviceID >= 0x11c0 && deviceID <= 0x11fa)
|
|
|
|
return NV_KEPLER; // GK106
|
|
|
|
if (deviceID >= 0x0fc0 && deviceID <= 0x0fff)
|
|
|
|
return NV_KEPLER; // GK107
|
|
|
|
if (deviceID >= 0x1003 && deviceID <= 0x1028)
|
|
|
|
return NV_KEPLER; // GK110(B)
|
|
|
|
if (deviceID >= 0x1280 && deviceID <= 0x12ba)
|
|
|
|
return NV_KEPLER; // GK208
|
|
|
|
if (deviceID >= 0x1381 && deviceID <= 0x13b0)
|
|
|
|
return NV_MAXWELL; // GM107
|
|
|
|
if (deviceID >= 0x1340 && deviceID <= 0x134d)
|
|
|
|
return NV_MAXWELL; // GM108
|
|
|
|
if (deviceID >= 0x13c0 && deviceID <= 0x13d9)
|
|
|
|
return NV_MAXWELL; // GM204
|
|
|
|
if (deviceID >= 0x1401 && deviceID <= 0x1427)
|
|
|
|
return NV_MAXWELL; // GM206
|
|
|
|
if (deviceID >= 0x15f7 && deviceID <= 0x15f9)
|
|
|
|
return NV_PASCAL; // GP100
|
|
|
|
if (deviceID >= 0x15f7 && deviceID <= 0x15f9)
|
|
|
|
return NV_PASCAL; // GP100
|
|
|
|
if (deviceID >= 0x1b00 && deviceID <= 0x1b38)
|
|
|
|
return NV_PASCAL; // GP102
|
|
|
|
if (deviceID >= 0x1b80 && deviceID <= 0x1be1)
|
|
|
|
return NV_PASCAL; // GP104
|
|
|
|
if (deviceID >= 0x1c02 && deviceID <= 0x1c62)
|
|
|
|
return NV_PASCAL; // GP106
|
|
|
|
if (deviceID >= 0x1c81 && deviceID <= 0x1c92)
|
|
|
|
return NV_PASCAL; // GP107
|
|
|
|
if (deviceID >= 0x1d01 && deviceID <= 0x1d12)
|
|
|
|
return NV_PASCAL; // GP108
|
|
|
|
if (deviceID >= 0x1d81 && deviceID <= 0x1dba)
|
|
|
|
return NV_VOLTA; // GV100
|
|
|
|
if (deviceID >= 0x1e02 && deviceID <= 0x1e3c)
|
|
|
|
return NV_TURING; // TU102
|
|
|
|
if (deviceID >= 0x1e82 && deviceID <= 0x1ed0)
|
|
|
|
return NV_TURING; // TU104
|
|
|
|
if (deviceID >= 0x1f02 && deviceID <= 0x1f51)
|
|
|
|
return NV_TURING; // TU104
|
|
|
|
if (deviceID >= 0x1e02)
|
|
|
|
return NV_TURING; // More TU models or later, probably.
|
|
|
|
return NV_PRE_KEPLER;
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::CheckGPUFeatures() {
|
2015-09-26 14:01:16 +00:00
|
|
|
u32 features = 0;
|
2017-02-22 15:23:04 +00:00
|
|
|
features |= GPU_SUPPORTS_16BIT_FORMATS;
|
2015-09-26 14:01:16 +00:00
|
|
|
features |= GPU_SUPPORTS_BLEND_MINMAX;
|
|
|
|
features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL;
|
2017-11-21 14:42:01 +00:00
|
|
|
|
2020-04-19 05:34:33 +00:00
|
|
|
// Accurate depth is required because the Direct3D API does not support inverse Z.
|
|
|
|
// So we cannot incorrectly use the viewport transform as the depth range on Direct3D.
|
|
|
|
// TODO: Breaks text in PaRappa for some reason?
|
|
|
|
features |= GPU_SUPPORTS_ACCURATE_DEPTH;
|
2015-09-26 14:01:16 +00:00
|
|
|
|
2020-04-19 05:34:33 +00:00
|
|
|
auto vendor = draw_->GetDeviceCaps().vendor;
|
2020-12-26 18:56:49 +00:00
|
|
|
if (!PSP_CoreParameter().compat.flags().DisableRangeCulling) {
|
2019-02-26 15:07:11 +00:00
|
|
|
// VS range culling (killing triangles in the vertex shader using NaN) causes problems on Intel.
|
|
|
|
// Also causes problems on old NVIDIA.
|
|
|
|
switch (vendor) {
|
|
|
|
case Draw::GPUVendor::VENDOR_INTEL:
|
|
|
|
break;
|
|
|
|
case Draw::GPUVendor::VENDOR_NVIDIA:
|
|
|
|
// Older NVIDIAs don't seem to like NaNs in their DX9 vertex shaders.
|
|
|
|
// No idea if KEPLER is the right cutoff, but let's go with it.
|
|
|
|
if (NVIDIAGetDeviceGeneration(draw_->GetDeviceCaps().deviceID) >= NV_KEPLER) {
|
|
|
|
features |= GPU_SUPPORTS_VS_RANGE_CULLING;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2019-02-06 21:44:02 +00:00
|
|
|
features |= GPU_SUPPORTS_VS_RANGE_CULLING;
|
2019-02-26 15:07:11 +00:00
|
|
|
break;
|
2019-02-06 21:44:02 +00:00
|
|
|
}
|
2018-10-21 07:36:15 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 04:56:04 +00:00
|
|
|
D3DCAPS9 caps;
|
|
|
|
ZeroMemory(&caps, sizeof(caps));
|
|
|
|
HRESULT result = 0;
|
2017-02-05 19:36:00 +00:00
|
|
|
if (deviceEx_) {
|
|
|
|
result = deviceEx_->GetDeviceCaps(&caps);
|
2016-03-18 04:56:04 +00:00
|
|
|
} else {
|
2017-02-05 19:36:00 +00:00
|
|
|
result = device_->GetDeviceCaps(&caps);
|
2016-03-18 04:56:04 +00:00
|
|
|
}
|
|
|
|
if (FAILED(result)) {
|
|
|
|
WARN_LOG_REPORT(G3D, "Direct3D9: Failed to get the device caps!");
|
|
|
|
} else {
|
|
|
|
if ((caps.RasterCaps & D3DPRASTERCAPS_ANISOTROPY) != 0 && caps.MaxAnisotropy > 1)
|
|
|
|
features |= GPU_SUPPORTS_ANISOTROPY;
|
|
|
|
if ((caps.TextureCaps & (D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_POW2)) == 0)
|
2020-12-14 19:06:06 +00:00
|
|
|
features |= GPU_SUPPORTS_TEXTURE_NPOT;
|
2016-03-18 04:56:04 +00:00
|
|
|
}
|
|
|
|
|
2016-01-21 06:00:07 +00:00
|
|
|
if (!g_Config.bHighQualityDepth) {
|
|
|
|
features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT;
|
2016-01-21 06:02:07 +00:00
|
|
|
} else if (PSP_CoreParameter().compat.flags().PixelDepthRounding) {
|
|
|
|
// Assume we always have a 24-bit depth buffer.
|
|
|
|
features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT;
|
2016-01-21 06:00:07 +00:00
|
|
|
} else if (PSP_CoreParameter().compat.flags().VertexDepthRounding) {
|
2015-09-26 14:01:16 +00:00
|
|
|
features |= GPU_ROUND_DEPTH_TO_16BIT;
|
2015-11-05 21:02:06 +00:00
|
|
|
}
|
|
|
|
|
2017-01-28 09:04:50 +00:00
|
|
|
if (PSP_CoreParameter().compat.flags().ClearToRAM) {
|
|
|
|
features |= GPU_USE_CLEAR_RAM_HACK;
|
|
|
|
}
|
|
|
|
|
2015-09-26 14:01:16 +00:00
|
|
|
gstate_c.featureFlags = features;
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
GPU_DX9::~GPU_DX9() {
|
2017-04-14 06:07:21 +00:00
|
|
|
framebufferManagerDX9_->DestroyAllFBOs();
|
2017-02-10 13:41:32 +00:00
|
|
|
delete framebufferManagerDX9_;
|
|
|
|
delete textureCache_;
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerDX9_->ClearCache(true);
|
|
|
|
delete shaderManagerDX9_;
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Needs to be called on GPU thread, not reporting thread.
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::BuildReportingInfo() {
|
2016-12-25 17:18:19 +00:00
|
|
|
using namespace Draw;
|
2017-02-06 10:20:27 +00:00
|
|
|
DrawContext *thin3d = gfxCtx_->GetDrawContext();
|
2016-02-13 17:51:09 +00:00
|
|
|
|
2016-12-25 17:52:05 +00:00
|
|
|
reportingPrimaryInfo_ = thin3d->GetInfoString(InfoField::VENDORSTRING);
|
|
|
|
reportingFullInfo_ = reportingPrimaryInfo_ + " - " + System_GetProperty(SYSPROP_GPUDRIVER_VERSION) + " - " + thin3d->GetInfoString(InfoField::SHADELANGVERSION);
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::DeviceLost() {
|
2013-08-17 09:23:51 +00:00
|
|
|
// Simply drop all caches and textures.
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerDX9_->ClearCache(false);
|
2016-12-21 17:51:19 +00:00
|
|
|
textureCacheDX9_->Clear(false);
|
2020-11-06 23:56:48 +00:00
|
|
|
GPUCommon::DeviceLost();
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-09-11 03:29:58 +00:00
|
|
|
void GPU_DX9::DeviceRestore() {
|
2020-11-06 23:56:48 +00:00
|
|
|
GPUCommon::DeviceRestore();
|
2016-09-11 03:29:58 +00:00
|
|
|
// Nothing needed.
|
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_DX9::InitClear() {
|
2020-04-04 17:51:47 +00:00
|
|
|
if (!framebufferManager_->UseBufferedRendering()) {
|
2013-08-17 09:23:51 +00:00
|
|
|
dxstate.depthWrite.set(true);
|
|
|
|
dxstate.colorMask.set(true, true, true, true);
|
2017-02-05 19:36:00 +00:00
|
|
|
device_->Clear(0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.f, 0);
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-17 09:48:43 +00:00
|
|
|
void GPU_DX9::BeginHostFrame() {
|
|
|
|
GPUCommon::BeginHostFrame();
|
2018-04-10 10:22:02 +00:00
|
|
|
UpdateCmdInfo();
|
2017-03-17 10:26:11 +00:00
|
|
|
if (resized_) {
|
2018-03-01 08:26:45 +00:00
|
|
|
CheckGPUFeatures();
|
2017-04-24 18:58:16 +00:00
|
|
|
framebufferManager_->Resized();
|
2017-03-17 10:26:11 +00:00
|
|
|
drawEngine_.Resized();
|
|
|
|
shaderManagerDX9_->DirtyShader();
|
|
|
|
textureCacheDX9_->NotifyConfigChanged();
|
|
|
|
resized_ = false;
|
|
|
|
}
|
2017-03-17 09:48:43 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_DX9::ReapplyGfxState() {
|
2015-11-12 13:47:43 +00:00
|
|
|
dxstate.Restore();
|
2017-11-05 19:33:28 +00:00
|
|
|
GPUCommon::ReapplyGfxState();
|
2015-09-06 10:23:14 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_DX9::BeginFrame() {
|
2016-12-21 17:51:19 +00:00
|
|
|
textureCacheDX9_->StartFrame();
|
2020-05-24 18:57:59 +00:00
|
|
|
drawEngine_.BeginFrame();
|
2014-09-17 21:26:20 +00:00
|
|
|
depalShaderCache_.Decimate();
|
2014-09-13 10:11:34 +00:00
|
|
|
// fragmentTestCache_.Decimate();
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
GPUCommon::BeginFrame();
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerDX9_->DirtyShader();
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2017-10-26 09:33:52 +00:00
|
|
|
framebufferManager_->BeginFrame();
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
|
2018-09-01 15:32:03 +00:00
|
|
|
GPUDebug::NotifyDisplay(framebuf, stride, format);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerDX9_->SetDisplayFramebuffer(framebuf, stride, format);
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2020-03-01 21:55:28 +00:00
|
|
|
void GPU_DX9::CopyDisplayToOutput(bool reallyDirty) {
|
2013-08-17 09:23:51 +00:00
|
|
|
dxstate.depthWrite.set(true);
|
|
|
|
dxstate.colorMask.set(true, true, true, true);
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Flush();
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2020-03-01 21:55:28 +00:00
|
|
|
framebufferManagerDX9_->CopyDisplayToOutput(reallyDirty);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerDX9_->EndFrame();
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2013-11-15 13:24:25 +00:00
|
|
|
// shaderManager_->EndFrame();
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerDX9_->DirtyLastShader();
|
2013-08-17 09:23:51 +00:00
|
|
|
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::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
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
inline void GPU_DX9::CheckFlushOp(int cmd, u32 diff) {
|
2014-09-13 10:11:34 +00:00
|
|
|
const u8 cmdFlags = cmdInfo_[cmd].flags;
|
2017-08-17 11:05:13 +00:00
|
|
|
if (diff && (cmdFlags & FLAG_FLUSHBEFOREONCHANGE)) {
|
2013-08-17 09:23:51 +00:00
|
|
|
if (dumpThisFrame_) {
|
2013-09-10 20:35:38 +00:00
|
|
|
NOTICE_LOG(G3D, "================ FLUSH ================");
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Flush();
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::PreExecuteOp(u32 op, u32 diff) {
|
2013-08-19 18:36:43 +00:00
|
|
|
CheckFlushOp(op >> 24, diff);
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::ExecuteOp(u32 op, u32 diff) {
|
2014-09-13 10:11:34 +00:00
|
|
|
const u8 cmd = op >> 24;
|
|
|
|
const CommandInfo info = cmdInfo_[cmd];
|
|
|
|
const u8 cmdFlags = info.flags;
|
|
|
|
if ((cmdFlags & FLAG_EXECUTE) || (diff && (cmdFlags & FLAG_EXECUTEONCHANGE))) {
|
|
|
|
(this->*info.func)(op, diff);
|
2017-01-24 11:45:50 +00:00
|
|
|
} else if (diff) {
|
|
|
|
uint64_t dirty = info.flags >> 8;
|
|
|
|
if (dirty)
|
|
|
|
gstate_c.Dirty(dirty);
|
2014-09-13 10:11:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::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,
|
2016-03-31 08:23:40 +00:00
|
|
|
"Vertex, Fragment shaders loaded: %i, %i\n",
|
2017-02-08 17:07:34 +00:00
|
|
|
shaderManagerDX9_->GetNumVertexShaders(),
|
|
|
|
shaderManagerDX9_->GetNumFragmentShaders()
|
2016-03-31 08:17:02 +00:00
|
|
|
);
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::ClearCacheNextFrame() {
|
2016-12-21 17:51:19 +00:00
|
|
|
textureCacheDX9_->ClearNextFrame();
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::ClearShaderCache() {
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerDX9_->ClearCache(true);
|
2013-12-05 15:37:52 +00:00
|
|
|
}
|
2014-09-11 23:48:43 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_DX9::DoState(PointerWrap &p) {
|
2013-08-17 09:23:51 +00:00
|
|
|
GPUCommon::DoState(p);
|
|
|
|
|
2013-12-05 15:37:52 +00:00
|
|
|
// TODO: Some of these things may not be necessary.
|
|
|
|
// None of these are necessary when saving.
|
2017-11-11 16:09:56 +00:00
|
|
|
if (p.mode == p.MODE_READ && !PSP_CoreParameter().frozen) {
|
2020-05-13 07:06:13 +00:00
|
|
|
textureCache_->Clear(true);
|
|
|
|
depalShaderCache_.Clear();
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.ClearTrackedVertexArrays();
|
2013-08-17 09:23:51 +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-12-05 15:37:52 +00:00
|
|
|
}
|
2013-08-17 09:23:51 +00:00
|
|
|
}
|
2013-09-15 15:53:21 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
std::vector<std::string> GPU_DX9::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();
|
2017-04-04 09:09:29 +00:00
|
|
|
case SHADER_TYPE_DEPAL:
|
|
|
|
return depalShaderCache_.DebugGetShaderIDs(type);
|
|
|
|
default:
|
2017-01-23 19:48:23 +00:00
|
|
|
return shaderManagerDX9_->DebugGetShaderIDs(type);
|
2015-10-24 22:34:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
std::string GPU_DX9::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);
|
2017-04-04 09:09:29 +00:00
|
|
|
case SHADER_TYPE_DEPAL:
|
|
|
|
return depalShaderCache_.DebugGetShaderString(id, type, stringType);
|
|
|
|
default:
|
2017-01-23 19:48:23 +00:00
|
|
|
return shaderManagerDX9_->DebugGetShaderString(id, type, stringType);
|
2015-10-24 22:34:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-13 10:11:34 +00:00
|
|
|
} // namespace DX9
|