2017-02-19 21:02:30 +00:00
|
|
|
|
2015-10-10 14:41:19 +00:00
|
|
|
// Copyright (c) 2015- 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/.
|
|
|
|
|
2018-03-17 14:42:07 +00:00
|
|
|
#include <thread>
|
2019-09-04 19:42:47 +00:00
|
|
|
|
2020-10-04 08:04:01 +00:00
|
|
|
#include "Common/Profiler/Profiler.h"
|
2016-01-05 20:18:43 +00:00
|
|
|
|
2020-08-15 10:25:39 +00:00
|
|
|
#include "Common/Log.h"
|
2020-10-04 18:48:47 +00:00
|
|
|
#include "Common/File/FileUtil.h"
|
2016-01-05 20:18:43 +00:00
|
|
|
#include "Common/GraphicsContext.h"
|
2020-08-15 18:53:08 +00:00
|
|
|
#include "Common/Serialize/Serializer.h"
|
|
|
|
#include "Common/TimeUtil.h"
|
2016-01-05 20:18:43 +00:00
|
|
|
|
|
|
|
#include "Core/Config.h"
|
|
|
|
#include "Core/Debugger/Breakpoints.h"
|
|
|
|
#include "Core/MemMapHelpers.h"
|
|
|
|
#include "Core/Reporting.h"
|
|
|
|
#include "Core/System.h"
|
2018-03-13 22:22:21 +00:00
|
|
|
#include "Core/ELF/ParamSFO.h"
|
2016-01-05 20:18:43 +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"
|
2016-01-05 20:18:43 +00:00
|
|
|
#include "GPU/Vulkan/ShaderManagerVulkan.h"
|
2015-10-10 14:41:19 +00:00
|
|
|
#include "GPU/Vulkan/GPU_Vulkan.h"
|
2020-08-03 21:22:11 +00:00
|
|
|
#include "GPU/Vulkan/FramebufferManagerVulkan.h"
|
2016-01-05 20:18:43 +00:00
|
|
|
#include "GPU/Vulkan/DrawEngineVulkan.h"
|
|
|
|
#include "GPU/Vulkan/TextureCacheVulkan.h"
|
2020-10-04 21:24:14 +00:00
|
|
|
#include "Common/GPU/Vulkan/VulkanRenderManager.h"
|
|
|
|
#include "Common/GPU/Vulkan/VulkanQueueRunner.h"
|
2016-01-05 20:18:43 +00:00
|
|
|
|
|
|
|
#include "Core/MIPS/MIPS.h"
|
|
|
|
#include "Core/HLE/sceKernelThread.h"
|
|
|
|
#include "Core/HLE/sceKernelInterrupt.h"
|
|
|
|
#include "Core/HLE/sceGe.h"
|
|
|
|
|
2017-01-30 15:50:35 +00:00
|
|
|
GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
|
|
|
: GPUCommon(gfxCtx, draw),
|
2021-11-14 23:25:28 +00:00
|
|
|
depalShaderCache_(draw),
|
|
|
|
drawEngine_(draw),
|
|
|
|
vulkan2D_((VulkanContext *)gfxCtx->GetAPIContext()) {
|
2016-01-05 20:18:43 +00:00
|
|
|
CheckGPUFeatures();
|
|
|
|
|
2021-11-14 23:25:28 +00:00
|
|
|
VulkanContext *vulkan = (VulkanContext *)gfxCtx->GetAPIContext();
|
|
|
|
shaderManagerVulkan_ = new ShaderManagerVulkan(draw);
|
|
|
|
pipelineManager_ = new PipelineManagerVulkan(vulkan);
|
|
|
|
framebufferManagerVulkan_ = new FramebufferManagerVulkan(draw);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManager_ = framebufferManagerVulkan_;
|
2021-11-14 23:25:28 +00:00
|
|
|
textureCacheVulkan_ = new TextureCacheVulkan(draw, vulkan);
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCache_ = textureCacheVulkan_;
|
2017-01-21 19:42:40 +00:00
|
|
|
drawEngineCommon_ = &drawEngine_;
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManager_ = shaderManagerVulkan_;
|
2016-12-21 17:07:17 +00:00
|
|
|
|
|
|
|
drawEngine_.SetTextureCache(textureCacheVulkan_);
|
|
|
|
drawEngine_.SetFramebufferManager(framebufferManagerVulkan_);
|
2017-01-23 19:48:23 +00:00
|
|
|
drawEngine_.SetShaderManager(shaderManagerVulkan_);
|
2016-01-09 00:23:32 +00:00
|
|
|
drawEngine_.SetPipelineManager(pipelineManager_);
|
2021-05-08 16:10:23 +00:00
|
|
|
drawEngine_.Init();
|
2017-11-01 22:35:06 +00:00
|
|
|
framebufferManagerVulkan_->SetVulkan2D(&vulkan2D_);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerVulkan_->SetTextureCache(textureCacheVulkan_);
|
|
|
|
framebufferManagerVulkan_->SetDrawEngine(&drawEngine_);
|
2017-02-19 21:02:30 +00:00
|
|
|
framebufferManagerVulkan_->SetShaderManager(shaderManagerVulkan_);
|
2020-05-16 16:57:01 +00:00
|
|
|
framebufferManagerVulkan_->Init();
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheVulkan_->SetDepalShaderCache(&depalShaderCache_);
|
2017-10-30 11:05:08 +00:00
|
|
|
textureCacheVulkan_->SetFramebufferManager(framebufferManagerVulkan_);
|
2017-01-23 19:48:23 +00:00
|
|
|
textureCacheVulkan_->SetShaderManager(shaderManagerVulkan_);
|
2017-02-04 10:47:19 +00:00
|
|
|
textureCacheVulkan_->SetDrawEngine(&drawEngine_);
|
2017-10-30 11:05:08 +00:00
|
|
|
textureCacheVulkan_->SetVulkan2D(&vulkan2D_);
|
|
|
|
|
|
|
|
InitDeviceObjects();
|
2016-01-05 20:18:43 +00:00
|
|
|
|
|
|
|
// Sanity check gstate
|
|
|
|
if ((int *)&gstate.transferstart - (int *)&gstate != 0xEA) {
|
|
|
|
ERROR_LOG(G3D, "gstate has drifted out of sync!");
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildReportingInfo();
|
|
|
|
// Update again after init to be sure of any silly driver problems.
|
|
|
|
UpdateVsyncInterval(true);
|
2016-03-26 18:44:22 +00:00
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheVulkan_->NotifyConfigChanged();
|
2018-03-13 22:22:21 +00:00
|
|
|
|
|
|
|
// Load shader cache.
|
|
|
|
std::string discID = g_paramSFO.GetDiscID();
|
2018-12-15 09:44:05 +00:00
|
|
|
if (discID.size()) {
|
2018-03-13 22:22:21 +00:00
|
|
|
File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE));
|
2021-05-05 23:31:38 +00:00
|
|
|
shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) / (discID + ".vkshadercache");
|
2018-03-17 14:42:07 +00:00
|
|
|
shaderCacheLoaded_ = false;
|
2018-03-13 22:22:21 +00:00
|
|
|
|
2018-03-17 14:42:07 +00:00
|
|
|
std::thread th([&] {
|
|
|
|
LoadCache(shaderCachePath_);
|
|
|
|
shaderCacheLoaded_ = true;
|
|
|
|
});
|
|
|
|
th.detach();
|
2018-10-31 02:13:22 +00:00
|
|
|
} else {
|
|
|
|
shaderCacheLoaded_ = true;
|
2018-03-13 22:22:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-17 14:42:07 +00:00
|
|
|
bool GPU_Vulkan::IsReady() {
|
|
|
|
return shaderCacheLoaded_;
|
|
|
|
}
|
|
|
|
|
2018-10-31 03:32:12 +00:00
|
|
|
void GPU_Vulkan::CancelReady() {
|
|
|
|
pipelineManager_->CancelCache();
|
|
|
|
}
|
|
|
|
|
2021-05-05 23:31:38 +00:00
|
|
|
void GPU_Vulkan::LoadCache(const Path &filename) {
|
2018-03-13 22:22:21 +00:00
|
|
|
PSP_SetLoading("Loading shader cache...");
|
|
|
|
// Actually precompiled by IsReady() since we're single-threaded.
|
|
|
|
FILE *f = File::OpenCFile(filename, "rb");
|
|
|
|
if (!f)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// First compile shaders to SPIR-V, then load the pipeline cache and recreate the pipelines.
|
|
|
|
// It's when recreating the pipelines that the pipeline cache is useful - in the ideal case,
|
|
|
|
// it can just memcpy the finished shader binaries out of the pipeline cache file.
|
|
|
|
bool result = shaderManagerVulkan_->LoadCache(f);
|
|
|
|
if (result) {
|
2019-07-23 15:45:52 +00:00
|
|
|
// WARNING: See comment in LoadCache if you are tempted to flip the second parameter to true.
|
2018-03-29 14:21:58 +00:00
|
|
|
result = pipelineManager_->LoadCache(f, false, shaderManagerVulkan_, draw_, drawEngine_.GetPipelineLayout());
|
2018-03-13 22:22:21 +00:00
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
if (!result) {
|
2020-08-27 08:02:50 +00:00
|
|
|
WARN_LOG(G3D, "Incompatible Vulkan pipeline cache - rebuilding.");
|
2018-03-13 22:22:21 +00:00
|
|
|
// Bad cache file for this GPU/Driver/etc. Delete it.
|
|
|
|
File::Delete(filename);
|
|
|
|
} else {
|
|
|
|
INFO_LOG(G3D, "Loaded Vulkan pipeline cache.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-05 23:31:38 +00:00
|
|
|
void GPU_Vulkan::SaveCache(const Path &filename) {
|
2018-04-05 18:26:29 +00:00
|
|
|
if (!draw_) {
|
|
|
|
// Already got the lost message, we're in shutdown.
|
|
|
|
WARN_LOG(G3D, "Not saving shaders - shutting down from in-game.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-13 22:22:21 +00:00
|
|
|
FILE *f = File::OpenCFile(filename, "wb");
|
|
|
|
if (!f)
|
|
|
|
return;
|
|
|
|
shaderManagerVulkan_->SaveCache(f);
|
2019-07-23 15:45:52 +00:00
|
|
|
// WARNING: See comment in LoadCache if you are tempted to flip the second parameter to true.
|
2018-03-29 12:36:04 +00:00
|
|
|
pipelineManager_->SaveCache(f, false, shaderManagerVulkan_, draw_);
|
2018-03-13 22:22:21 +00:00
|
|
|
INFO_LOG(G3D, "Saved Vulkan pipeline cache");
|
|
|
|
fclose(f);
|
2015-10-10 14:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GPU_Vulkan::~GPU_Vulkan() {
|
2018-03-13 22:22:21 +00:00
|
|
|
SaveCache(shaderCachePath_);
|
|
|
|
// Note: We save the cache in DeviceLost
|
2017-10-30 11:05:08 +00:00
|
|
|
DestroyDeviceObjects();
|
2017-04-14 06:07:21 +00:00
|
|
|
framebufferManagerVulkan_->DestroyAllFBOs();
|
2016-01-05 20:18:43 +00:00
|
|
|
depalShaderCache_.Clear();
|
2019-09-17 12:46:58 +00:00
|
|
|
depalShaderCache_.DeviceLost();
|
2017-12-03 10:02:49 +00:00
|
|
|
drawEngine_.DeviceLost();
|
2019-09-17 12:46:58 +00:00
|
|
|
vulkan2D_.Shutdown();
|
2017-05-07 08:53:04 +00:00
|
|
|
delete textureCacheVulkan_;
|
2016-03-13 23:53:57 +00:00
|
|
|
delete pipelineManager_;
|
2017-01-23 19:48:23 +00:00
|
|
|
delete shaderManagerVulkan_;
|
2017-05-07 09:08:09 +00:00
|
|
|
delete framebufferManagerVulkan_;
|
2015-10-10 14:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_Vulkan::CheckGPUFeatures() {
|
2017-02-22 15:23:04 +00:00
|
|
|
uint32_t features = 0;
|
2017-11-21 10:56:42 +00:00
|
|
|
|
2021-11-14 23:25:28 +00:00
|
|
|
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
|
|
|
|
switch (vulkan->GetPhysicalDeviceProperties().properties.vendorID) {
|
2017-12-10 18:20:11 +00:00
|
|
|
case VULKAN_VENDOR_AMD:
|
|
|
|
// Accurate depth is required on AMD (due to reverse-Z driver bug) so we ignore the compat flag to disable it on those. See #9545
|
2017-11-21 10:56:42 +00:00
|
|
|
features |= GPU_SUPPORTS_ACCURATE_DEPTH;
|
2017-12-10 18:20:11 +00:00
|
|
|
break;
|
2019-02-26 14:21:21 +00:00
|
|
|
case VULKAN_VENDOR_QUALCOMM:
|
|
|
|
// Accurate depth is required on Adreno too (seems to also have a reverse-Z driver bug).
|
|
|
|
features |= GPU_SUPPORTS_ACCURATE_DEPTH;
|
|
|
|
break;
|
2017-12-10 18:20:11 +00:00
|
|
|
case VULKAN_VENDOR_ARM:
|
2019-09-04 19:42:47 +00:00
|
|
|
{
|
|
|
|
// This check is probably not exactly accurate. But old drivers had problems with reverse-Z, just like AMD and Qualcomm.
|
2021-11-14 23:25:28 +00:00
|
|
|
bool driverTooOld = IsHashMaliDriverVersion(vulkan->GetPhysicalDeviceProperties().properties)
|
|
|
|
|| VK_VERSION_MAJOR(vulkan->GetPhysicalDeviceProperties().properties.driverVersion) < 14;
|
2019-09-04 19:42:47 +00:00
|
|
|
if (!PSP_CoreParameter().compat.flags().DisableAccurateDepth || driverTooOld) {
|
2017-12-10 18:20:11 +00:00
|
|
|
features |= GPU_SUPPORTS_ACCURATE_DEPTH;
|
|
|
|
}
|
|
|
|
break;
|
2019-09-04 19:42:47 +00:00
|
|
|
}
|
2017-12-10 18:20:11 +00:00
|
|
|
default:
|
2019-09-04 21:20:57 +00:00
|
|
|
if (!PSP_CoreParameter().compat.flags().DisableAccurateDepth) {
|
2017-12-10 18:20:11 +00:00
|
|
|
features |= GPU_SUPPORTS_ACCURATE_DEPTH;
|
2019-09-04 21:20:57 +00:00
|
|
|
}
|
2017-12-10 18:20:11 +00:00
|
|
|
break;
|
2017-11-21 10:56:42 +00:00
|
|
|
}
|
2017-11-21 12:58:42 +00:00
|
|
|
|
2018-12-10 23:22:16 +00:00
|
|
|
// Might enable this later - in the first round we are mostly looking at depth/stencil/discard.
|
2021-02-01 08:22:58 +00:00
|
|
|
// if (!g_Config.bEnableVendorBugChecks)
|
2018-12-10 23:22:16 +00:00
|
|
|
// features |= GPU_SUPPORTS_ACCURATE_DEPTH;
|
|
|
|
|
2017-11-21 12:58:42 +00:00
|
|
|
// Mandatory features on Vulkan, which may be checked in "centralized" code
|
2017-11-21 10:56:42 +00:00
|
|
|
features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL;
|
2020-09-17 17:18:32 +00:00
|
|
|
features |= GPU_SUPPORTS_FRAMEBUFFER_BLIT;
|
2017-11-21 10:56:42 +00:00
|
|
|
features |= GPU_SUPPORTS_BLEND_MINMAX;
|
2020-09-17 18:23:04 +00:00
|
|
|
features |= GPU_SUPPORTS_COPY_IMAGE;
|
2020-12-14 19:06:06 +00:00
|
|
|
features |= GPU_SUPPORTS_TEXTURE_NPOT;
|
2017-11-21 10:56:42 +00:00
|
|
|
features |= GPU_SUPPORTS_INSTANCE_RENDERING;
|
|
|
|
features |= GPU_SUPPORTS_VERTEX_TEXTURE_FETCH;
|
|
|
|
features |= GPU_SUPPORTS_TEXTURE_FLOAT;
|
2020-11-10 22:36:09 +00:00
|
|
|
features |= GPU_SUPPORTS_DEPTH_TEXTURE;
|
2017-11-21 10:56:42 +00:00
|
|
|
|
2021-11-14 23:25:28 +00:00
|
|
|
if (vulkan->GetDeviceInfo().canBlitToPreferredDepthStencilFormat) {
|
2020-10-11 08:52:55 +00:00
|
|
|
features |= GPU_SUPPORTS_FRAMEBUFFER_BLIT_TO_DEPTH;
|
|
|
|
}
|
|
|
|
|
2021-11-14 23:25:28 +00:00
|
|
|
auto &enabledFeatures = vulkan->GetDeviceFeatures().enabled;
|
2021-09-12 00:10:29 +00:00
|
|
|
if (enabledFeatures.depthClamp) {
|
2017-12-27 00:35:14 +00:00
|
|
|
features |= GPU_SUPPORTS_DEPTH_CLAMP;
|
|
|
|
}
|
2021-09-20 06:27:30 +00:00
|
|
|
if (enabledFeatures.shaderClipDistance) {
|
|
|
|
features |= GPU_SUPPORTS_CLIP_DISTANCE;
|
|
|
|
}
|
|
|
|
if (enabledFeatures.shaderCullDistance) {
|
2021-09-12 00:10:29 +00:00
|
|
|
// Must support at least 8 if feature supported, so we're fine.
|
2021-09-20 06:27:30 +00:00
|
|
|
features |= GPU_SUPPORTS_CULL_DISTANCE;
|
2021-09-12 00:10:29 +00:00
|
|
|
}
|
2021-10-20 05:16:44 +00:00
|
|
|
if (!draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL)) {
|
|
|
|
// Ignore the compat setting if clip and cull are both enabled.
|
2021-10-21 22:29:51 +00:00
|
|
|
// When supported, we can do the depth side of range culling more correctly.
|
2021-10-20 05:16:44 +00:00
|
|
|
const bool supported = draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported;
|
|
|
|
const bool disabled = PSP_CoreParameter().compat.flags().DisableRangeCulling;
|
2021-10-23 15:41:12 +00:00
|
|
|
if (supported || !disabled) {
|
2021-10-20 05:16:44 +00:00
|
|
|
features |= GPU_SUPPORTS_VS_RANGE_CULLING;
|
|
|
|
}
|
|
|
|
}
|
2021-09-12 00:10:29 +00:00
|
|
|
if (enabledFeatures.dualSrcBlend) {
|
2018-12-23 20:31:19 +00:00
|
|
|
if (!g_Config.bVendorBugChecksEnabled || !draw_->GetBugs().Has(Draw::Bugs::DUAL_SOURCE_BLENDING_BROKEN)) {
|
2017-11-09 12:16:06 +00:00
|
|
|
features |= GPU_SUPPORTS_DUALSOURCE_BLEND;
|
2017-11-10 17:28:38 +00:00
|
|
|
}
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
2021-09-12 00:10:29 +00:00
|
|
|
if (enabledFeatures.logicOp) {
|
2017-02-22 15:23:04 +00:00
|
|
|
features |= GPU_SUPPORTS_LOGIC_OP;
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
2021-09-12 00:10:29 +00:00
|
|
|
if (enabledFeatures.samplerAnisotropy) {
|
2017-02-22 15:23:04 +00:00
|
|
|
features |= GPU_SUPPORTS_ANISOTROPY;
|
2016-03-18 04:59:16 +00:00
|
|
|
}
|
2017-01-28 09:04:50 +00:00
|
|
|
|
2021-07-12 09:09:39 +00:00
|
|
|
// These are VULKAN_4444_FORMAT and friends.
|
2020-03-01 13:07:13 +00:00
|
|
|
uint32_t fmt4444 = draw_->GetDataFormatSupport(Draw::DataFormat::B4G4R4A4_UNORM_PACK16);
|
|
|
|
uint32_t fmt1555 = draw_->GetDataFormatSupport(Draw::DataFormat::A1R5G5B5_UNORM_PACK16);
|
2021-07-10 21:21:10 +00:00
|
|
|
|
|
|
|
// Note that we are (accidentally) using B5G6R5 instead of the mandatory R5G6B5.
|
|
|
|
// Support is almost as widespread, but not quite. So let's just not use any 16-bit formats
|
|
|
|
// if it's not available, for simplicity.
|
|
|
|
uint32_t fmt565 = draw_->GetDataFormatSupport(Draw::DataFormat::B5G6R5_UNORM_PACK16);
|
2020-03-01 13:07:13 +00:00
|
|
|
if ((fmt4444 & Draw::FMT_TEXTURE) && (fmt565 & Draw::FMT_TEXTURE) && (fmt1555 & Draw::FMT_TEXTURE)) {
|
|
|
|
features |= GPU_SUPPORTS_16BIT_FORMATS;
|
|
|
|
} else {
|
|
|
|
INFO_LOG(G3D, "Deficient texture format support: 4444: %d 1555: %d 565: %d", fmt4444, fmt1555, fmt565);
|
|
|
|
}
|
|
|
|
|
2017-01-28 09:04:50 +00:00
|
|
|
if (PSP_CoreParameter().compat.flags().ClearToRAM) {
|
2017-02-22 15:23:04 +00:00
|
|
|
features |= GPU_USE_CLEAR_RAM_HACK;
|
2017-01-28 09:04:50 +00:00
|
|
|
}
|
|
|
|
|
2017-11-15 20:49:02 +00:00
|
|
|
if (!g_Config.bHighQualityDepth && (features & GPU_SUPPORTS_ACCURATE_DEPTH) != 0) {
|
|
|
|
features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT;
|
|
|
|
}
|
|
|
|
else if (PSP_CoreParameter().compat.flags().PixelDepthRounding) {
|
|
|
|
// Use fragment rounding on desktop and GLES3, most accurate.
|
|
|
|
features |= GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT;
|
|
|
|
}
|
|
|
|
else if (PSP_CoreParameter().compat.flags().VertexDepthRounding) {
|
|
|
|
features |= GPU_ROUND_DEPTH_TO_16BIT;
|
|
|
|
}
|
2019-01-31 12:53:27 +00:00
|
|
|
|
2017-02-22 15:23:04 +00:00
|
|
|
gstate_c.featureFlags = features;
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-01-08 00:05:52 +00:00
|
|
|
void GPU_Vulkan::BeginHostFrame() {
|
|
|
|
drawEngine_.BeginFrame();
|
2018-04-10 10:22:02 +00:00
|
|
|
UpdateCmdInfo();
|
2016-01-08 00:05:52 +00:00
|
|
|
|
|
|
|
if (resized_) {
|
|
|
|
CheckGPUFeatures();
|
2016-10-08 21:52:53 +00:00
|
|
|
// In case the GPU changed.
|
|
|
|
BuildReportingInfo();
|
2017-04-24 18:58:16 +00:00
|
|
|
framebufferManager_->Resized();
|
2016-01-08 00:05:52 +00:00
|
|
|
drawEngine_.Resized();
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheVulkan_->NotifyConfigChanged();
|
2020-06-23 23:04:41 +00:00
|
|
|
resized_ = false;
|
2016-01-08 00:05:52 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheVulkan_->StartFrame();
|
2017-10-30 11:05:08 +00:00
|
|
|
|
2021-11-14 23:25:28 +00:00
|
|
|
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
|
|
|
|
int curFrame = vulkan->GetCurFrame();
|
2017-10-31 22:49:47 +00:00
|
|
|
FrameData &frame = frameData_[curFrame];
|
2017-10-30 11:05:08 +00:00
|
|
|
|
|
|
|
frame.push_->Reset();
|
2021-11-14 23:25:28 +00:00
|
|
|
frame.push_->Begin(vulkan);
|
2016-01-08 00:05:52 +00:00
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerVulkan_->BeginFrameVulkan();
|
2017-10-31 22:49:47 +00:00
|
|
|
framebufferManagerVulkan_->SetPushBuffer(frameData_[curFrame].push_);
|
|
|
|
depalShaderCache_.SetPushBuffer(frameData_[curFrame].push_);
|
|
|
|
textureCacheVulkan_->SetPushBuffer(frameData_[curFrame].push_);
|
2017-10-30 11:05:08 +00:00
|
|
|
|
|
|
|
vulkan2D_.BeginFrame();
|
2016-03-21 23:12:41 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerVulkan_->DirtyShader();
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_ALL);
|
2016-03-21 23:12:41 +00:00
|
|
|
|
2016-01-08 00:05:52 +00:00
|
|
|
if (dumpNextFrame_) {
|
|
|
|
NOTICE_LOG(G3D, "DUMPING THIS FRAME");
|
|
|
|
dumpThisFrame_ = true;
|
|
|
|
dumpNextFrame_ = false;
|
|
|
|
} else if (dumpThisFrame_) {
|
|
|
|
dumpThisFrame_ = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_Vulkan::EndHostFrame() {
|
2021-11-14 23:25:28 +00:00
|
|
|
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
|
|
|
|
int curFrame = vulkan->GetCurFrame();
|
2017-10-31 22:49:47 +00:00
|
|
|
FrameData &frame = frameData_[curFrame];
|
2017-10-30 11:05:08 +00:00
|
|
|
frame.push_->End();
|
|
|
|
|
|
|
|
vulkan2D_.EndFrame();
|
|
|
|
|
2016-01-08 00:05:52 +00:00
|
|
|
drawEngine_.EndFrame();
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerVulkan_->EndFrame();
|
|
|
|
textureCacheVulkan_->EndFrame();
|
2020-08-22 08:50:39 +00:00
|
|
|
|
|
|
|
draw_->InvalidateCachedState();
|
2016-01-08 00:05:52 +00:00
|
|
|
}
|
2015-10-10 14:41:19 +00:00
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
// Needs to be called on GPU thread, not reporting thread.
|
|
|
|
void GPU_Vulkan::BuildReportingInfo() {
|
2021-11-14 23:25:28 +00:00
|
|
|
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
|
|
|
|
const auto &props = vulkan->GetPhysicalDeviceProperties().properties;
|
|
|
|
const auto &features = vulkan->GetDeviceFeatures().available;
|
2016-03-27 15:52:55 +00:00
|
|
|
|
2016-03-27 16:25:25 +00:00
|
|
|
#define CHECK_BOOL_FEATURE(n) do { if (features.n) { featureNames += ", " #n; } } while (false)
|
2016-03-27 15:52:55 +00:00
|
|
|
|
|
|
|
std::string featureNames = "";
|
|
|
|
CHECK_BOOL_FEATURE(robustBufferAccess);
|
|
|
|
CHECK_BOOL_FEATURE(fullDrawIndexUint32);
|
|
|
|
CHECK_BOOL_FEATURE(imageCubeArray);
|
|
|
|
CHECK_BOOL_FEATURE(independentBlend);
|
|
|
|
CHECK_BOOL_FEATURE(geometryShader);
|
|
|
|
CHECK_BOOL_FEATURE(tessellationShader);
|
|
|
|
CHECK_BOOL_FEATURE(sampleRateShading);
|
|
|
|
CHECK_BOOL_FEATURE(dualSrcBlend);
|
|
|
|
CHECK_BOOL_FEATURE(logicOp);
|
|
|
|
CHECK_BOOL_FEATURE(multiDrawIndirect);
|
|
|
|
CHECK_BOOL_FEATURE(drawIndirectFirstInstance);
|
|
|
|
CHECK_BOOL_FEATURE(depthClamp);
|
|
|
|
CHECK_BOOL_FEATURE(depthBiasClamp);
|
|
|
|
CHECK_BOOL_FEATURE(fillModeNonSolid);
|
|
|
|
CHECK_BOOL_FEATURE(depthBounds);
|
|
|
|
CHECK_BOOL_FEATURE(alphaToOne);
|
|
|
|
CHECK_BOOL_FEATURE(multiViewport);
|
|
|
|
CHECK_BOOL_FEATURE(samplerAnisotropy);
|
|
|
|
CHECK_BOOL_FEATURE(textureCompressionETC2);
|
|
|
|
CHECK_BOOL_FEATURE(textureCompressionASTC_LDR);
|
|
|
|
CHECK_BOOL_FEATURE(textureCompressionBC);
|
|
|
|
CHECK_BOOL_FEATURE(occlusionQueryPrecise);
|
|
|
|
CHECK_BOOL_FEATURE(pipelineStatisticsQuery);
|
|
|
|
CHECK_BOOL_FEATURE(vertexPipelineStoresAndAtomics);
|
|
|
|
CHECK_BOOL_FEATURE(fragmentStoresAndAtomics);
|
|
|
|
CHECK_BOOL_FEATURE(shaderTessellationAndGeometryPointSize);
|
|
|
|
CHECK_BOOL_FEATURE(shaderImageGatherExtended);
|
|
|
|
CHECK_BOOL_FEATURE(shaderStorageImageExtendedFormats);
|
|
|
|
CHECK_BOOL_FEATURE(shaderStorageImageMultisample);
|
|
|
|
CHECK_BOOL_FEATURE(shaderStorageImageReadWithoutFormat);
|
|
|
|
CHECK_BOOL_FEATURE(shaderStorageImageWriteWithoutFormat);
|
|
|
|
CHECK_BOOL_FEATURE(shaderUniformBufferArrayDynamicIndexing);
|
|
|
|
CHECK_BOOL_FEATURE(shaderSampledImageArrayDynamicIndexing);
|
|
|
|
CHECK_BOOL_FEATURE(shaderStorageBufferArrayDynamicIndexing);
|
|
|
|
CHECK_BOOL_FEATURE(shaderStorageImageArrayDynamicIndexing);
|
|
|
|
CHECK_BOOL_FEATURE(shaderClipDistance);
|
|
|
|
CHECK_BOOL_FEATURE(shaderCullDistance);
|
|
|
|
CHECK_BOOL_FEATURE(shaderFloat64);
|
|
|
|
CHECK_BOOL_FEATURE(shaderInt64);
|
|
|
|
CHECK_BOOL_FEATURE(shaderInt16);
|
|
|
|
CHECK_BOOL_FEATURE(shaderResourceResidency);
|
|
|
|
CHECK_BOOL_FEATURE(shaderResourceMinLod);
|
|
|
|
CHECK_BOOL_FEATURE(sparseBinding);
|
|
|
|
CHECK_BOOL_FEATURE(sparseResidencyBuffer);
|
|
|
|
CHECK_BOOL_FEATURE(sparseResidencyImage2D);
|
|
|
|
CHECK_BOOL_FEATURE(sparseResidencyImage3D);
|
|
|
|
CHECK_BOOL_FEATURE(sparseResidency2Samples);
|
|
|
|
CHECK_BOOL_FEATURE(sparseResidency4Samples);
|
|
|
|
CHECK_BOOL_FEATURE(sparseResidency8Samples);
|
|
|
|
CHECK_BOOL_FEATURE(sparseResidency16Samples);
|
|
|
|
CHECK_BOOL_FEATURE(sparseResidencyAliased);
|
|
|
|
CHECK_BOOL_FEATURE(variableMultisampleRate);
|
|
|
|
CHECK_BOOL_FEATURE(inheritedQueries);
|
|
|
|
|
2016-03-27 16:26:34 +00:00
|
|
|
#undef CHECK_BOOL_FEATURE
|
|
|
|
|
2016-03-27 15:52:55 +00:00
|
|
|
if (!featureNames.empty()) {
|
|
|
|
featureNames = featureNames.substr(2);
|
|
|
|
}
|
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
char temp[16384];
|
2016-03-27 15:52:55 +00:00
|
|
|
snprintf(temp, sizeof(temp), "v%08x driver v%08x (%s), vendorID=%d, deviceID=%d (features: %s)", props.apiVersion, props.driverVersion, props.deviceName, props.vendorID, props.deviceID, featureNames.c_str());
|
|
|
|
reportingPrimaryInfo_ = props.deviceName;
|
2016-01-05 20:18:43 +00:00
|
|
|
reportingFullInfo_ = temp;
|
|
|
|
|
|
|
|
Reporting::UpdateConfig();
|
2015-10-10 14:41:19 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_Vulkan::Reinitialize() {
|
|
|
|
GPUCommon::Reinitialize();
|
2016-01-05 20:18:43 +00:00
|
|
|
depalShaderCache_.Clear();
|
2015-10-10 14:41:19 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPU_Vulkan::InitClear() {
|
2020-04-04 17:51:47 +00:00
|
|
|
if (!framebufferManager_->UseBufferedRendering()) {
|
2017-11-05 19:33:28 +00:00
|
|
|
// TODO?
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-10 14:41:19 +00:00
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
void GPU_Vulkan::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
|
2018-09-01 15:32:03 +00:00
|
|
|
GPUDebug::NotifyDisplay(framebuf, stride, format);
|
2016-01-10 13:24:10 +00:00
|
|
|
framebufferManager_->SetDisplayFramebuffer(framebuf, stride, format);
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
|
2020-03-01 21:55:28 +00:00
|
|
|
void GPU_Vulkan::CopyDisplayToOutput(bool reallyDirty) {
|
2016-01-05 20:18:43 +00:00
|
|
|
// Flush anything left over.
|
2017-05-19 15:21:08 +00:00
|
|
|
drawEngine_.Flush();
|
2016-01-05 20:18:43 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerVulkan_->DirtyLastShader();
|
2016-01-05 20:18:43 +00:00
|
|
|
|
2020-03-01 21:55:28 +00:00
|
|
|
framebufferManagerVulkan_->CopyDisplayToOutput(reallyDirty);
|
2016-01-06 22:08:26 +00:00
|
|
|
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_Vulkan::FinishDeferred() {
|
2017-11-16 15:27:24 +00:00
|
|
|
drawEngine_.FinishDeferred();
|
2015-10-10 14:41:19 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
inline void GPU_Vulkan::CheckFlushOp(int cmd, u32 diff) {
|
|
|
|
const u8 cmdFlags = cmdInfo_[cmd].flags;
|
2018-09-21 03:36:41 +00:00
|
|
|
if (diff && (cmdFlags & FLAG_FLUSHBEFOREONCHANGE)) {
|
2016-01-05 20:18:43 +00:00
|
|
|
if (dumpThisFrame_) {
|
|
|
|
NOTICE_LOG(G3D, "================ FLUSH ================");
|
|
|
|
}
|
2017-05-19 15:21:08 +00:00
|
|
|
drawEngine_.Flush();
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-10 14:41:19 +00:00
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
void GPU_Vulkan::PreExecuteOp(u32 op, u32 diff) {
|
|
|
|
CheckFlushOp(op >> 24, diff);
|
2015-10-10 14:41:19 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
void GPU_Vulkan::ExecuteOp(u32 op, u32 diff) {
|
|
|
|
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);
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-10 14:41:19 +00:00
|
|
|
|
2017-10-30 11:05:08 +00:00
|
|
|
void GPU_Vulkan::InitDeviceObjects() {
|
2020-08-15 14:13:24 +00:00
|
|
|
INFO_LOG(G3D, "GPU_Vulkan::InitDeviceObjects");
|
2021-11-14 23:25:28 +00:00
|
|
|
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
|
2017-10-30 11:05:08 +00:00
|
|
|
// Initialize framedata
|
|
|
|
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
|
2020-08-15 22:38:55 +00:00
|
|
|
_assert_(!frameData_[i].push_);
|
2019-03-13 22:31:54 +00:00
|
|
|
VkBufferUsageFlags usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
|
2021-11-14 23:25:28 +00:00
|
|
|
frameData_[i].push_ = new VulkanPushBuffer(vulkan, 256 * 1024, usage);
|
2017-10-30 11:05:08 +00:00
|
|
|
}
|
2018-04-13 15:32:36 +00:00
|
|
|
|
|
|
|
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
|
|
|
uint32_t hacks = 0;
|
2018-04-13 16:05:04 +00:00
|
|
|
if (PSP_CoreParameter().compat.flags().MGS2AcidHack)
|
2018-04-13 15:32:36 +00:00
|
|
|
hacks |= QUEUE_HACK_MGS2_ACID;
|
2018-04-13 16:05:04 +00:00
|
|
|
if (PSP_CoreParameter().compat.flags().SonicRivalsHack)
|
|
|
|
hacks |= QUEUE_HACK_SONIC;
|
2019-11-03 17:22:48 +00:00
|
|
|
|
|
|
|
// Always on.
|
|
|
|
hacks |= QUEUE_HACK_RENDERPASS_MERGE;
|
2019-08-13 21:07:58 +00:00
|
|
|
|
2018-04-13 15:32:36 +00:00
|
|
|
if (hacks) {
|
|
|
|
rm->GetQueueRunner()->EnableHacks(hacks);
|
|
|
|
}
|
2017-10-30 11:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_Vulkan::DestroyDeviceObjects() {
|
2020-08-15 14:13:24 +00:00
|
|
|
INFO_LOG(G3D, "GPU_Vulkan::DestroyDeviceObjects");
|
2017-10-30 11:05:08 +00:00
|
|
|
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
|
|
|
|
if (frameData_[i].push_) {
|
2021-11-21 13:35:07 +00:00
|
|
|
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
|
2021-11-14 23:25:28 +00:00
|
|
|
frameData_[i].push_->Destroy(vulkan);
|
2017-10-30 11:05:08 +00:00
|
|
|
delete frameData_[i].push_;
|
|
|
|
frameData_[i].push_ = nullptr;
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 15:32:36 +00:00
|
|
|
|
|
|
|
// Need to turn off hacks when shutting down the GPU. Don't want them running in the menu.
|
2018-04-14 20:14:05 +00:00
|
|
|
if (draw_) {
|
|
|
|
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
|
|
|
if (rm)
|
|
|
|
rm->GetQueueRunner()->EnableHacks(0);
|
|
|
|
}
|
2017-10-30 11:05:08 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
void GPU_Vulkan::DeviceLost() {
|
2018-10-31 03:32:12 +00:00
|
|
|
CancelReady();
|
|
|
|
while (!IsReady()) {
|
|
|
|
sleep_ms(10);
|
|
|
|
}
|
2021-05-05 23:31:38 +00:00
|
|
|
if (shaderCachePath_.Valid()) {
|
2018-03-13 22:22:21 +00:00
|
|
|
SaveCache(shaderCachePath_);
|
|
|
|
}
|
2017-10-30 11:05:08 +00:00
|
|
|
DestroyDeviceObjects();
|
2017-12-01 10:16:44 +00:00
|
|
|
vulkan2D_.DeviceLost();
|
2016-10-09 18:27:16 +00:00
|
|
|
drawEngine_.DeviceLost();
|
|
|
|
pipelineManager_->DeviceLost();
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheVulkan_->DeviceLost();
|
2017-11-09 15:58:59 +00:00
|
|
|
depalShaderCache_.DeviceLost();
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerVulkan_->ClearShaders();
|
2020-11-06 23:56:48 +00:00
|
|
|
|
|
|
|
GPUCommon::DeviceLost();
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-09-11 03:29:58 +00:00
|
|
|
void GPU_Vulkan::DeviceRestore() {
|
2020-11-06 23:56:48 +00:00
|
|
|
GPUCommon::DeviceRestore();
|
2017-11-09 15:02:05 +00:00
|
|
|
InitDeviceObjects();
|
|
|
|
|
2016-10-09 18:27:16 +00:00
|
|
|
CheckGPUFeatures();
|
|
|
|
BuildReportingInfo();
|
2018-04-10 10:22:02 +00:00
|
|
|
UpdateCmdInfo();
|
2016-10-09 18:27:16 +00:00
|
|
|
|
2021-11-14 23:25:28 +00:00
|
|
|
VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT);
|
|
|
|
vulkan2D_.DeviceRestore(vulkan);
|
|
|
|
drawEngine_.DeviceRestore(draw_);
|
|
|
|
pipelineManager_->DeviceRestore(vulkan);
|
|
|
|
textureCacheVulkan_->DeviceRestore(draw_);
|
|
|
|
shaderManagerVulkan_->DeviceRestore(draw_);
|
|
|
|
depalShaderCache_.DeviceRestore(draw_);
|
2016-09-11 03:29:58 +00:00
|
|
|
}
|
|
|
|
|
2016-03-31 08:17:02 +00:00
|
|
|
void GPU_Vulkan::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;
|
2016-03-31 08:23:40 +00:00
|
|
|
const DrawEngineVulkanStats &drawStats = drawEngine_.GetStats();
|
2017-12-03 09:29:41 +00:00
|
|
|
char texStats[256];
|
|
|
|
textureCacheVulkan_->GetStats(texStats, sizeof(texStats));
|
2020-09-20 19:33:06 +00:00
|
|
|
snprintf(buffer, bufsize,
|
2016-03-31 08:23:40 +00:00
|
|
|
"Vertex, Fragment, Pipelines loaded: %i, %i, %i\n"
|
2017-12-03 09:29:41 +00:00
|
|
|
"Pushbuffer space used: UBO %d, Vtx %d, Idx %d\n"
|
|
|
|
"%s\n",
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerVulkan_->GetNumVertexShaders(),
|
|
|
|
shaderManagerVulkan_->GetNumFragmentShaders(),
|
2016-03-31 08:23:40 +00:00
|
|
|
pipelineManager_->GetNumPipelines(),
|
|
|
|
drawStats.pushUBOSpaceUsed,
|
|
|
|
drawStats.pushVertexSpaceUsed,
|
2017-12-03 09:29:41 +00:00
|
|
|
drawStats.pushIndexSpaceUsed,
|
|
|
|
texStats
|
2016-03-31 08:17:02 +00:00
|
|
|
);
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_Vulkan::ClearCacheNextFrame() {
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheVulkan_->ClearNextFrame();
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_Vulkan::ClearShaderCache() {
|
2016-01-10 13:24:10 +00:00
|
|
|
// TODO
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_Vulkan::DoState(PointerWrap &p) {
|
|
|
|
GPUCommon::DoState(p);
|
|
|
|
|
|
|
|
// TODO: Some of these things may not be necessary.
|
|
|
|
// None of these are necessary when saving.
|
|
|
|
// 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-01-05 20:18:43 +00:00
|
|
|
depalShaderCache_.Clear();
|
|
|
|
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
2020-05-13 07:06:13 +00:00
|
|
|
framebufferManager_->DestroyAllFBOs();
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> GPU_Vulkan::DebugGetShaderIDs(DebugShaderType type) {
|
|
|
|
if (type == SHADER_TYPE_VERTEXLOADER) {
|
|
|
|
return drawEngine_.DebugGetVertexLoaderIDs();
|
2016-01-09 20:19:18 +00:00
|
|
|
} else if (type == SHADER_TYPE_PIPELINE) {
|
|
|
|
return pipelineManager_->DebugGetObjectIDs(type);
|
2017-04-04 09:09:29 +00:00
|
|
|
} else if (type == SHADER_TYPE_DEPAL) {
|
|
|
|
///...
|
|
|
|
return std::vector<std::string>();
|
2017-12-06 15:01:56 +00:00
|
|
|
} else if (type == SHADER_TYPE_VERTEX || type == SHADER_TYPE_FRAGMENT) {
|
2017-01-23 19:48:23 +00:00
|
|
|
return shaderManagerVulkan_->DebugGetShaderIDs(type);
|
2017-12-06 15:01:56 +00:00
|
|
|
} else if (type == SHADER_TYPE_SAMPLER) {
|
|
|
|
return textureCacheVulkan_->DebugGetSamplerIDs();
|
|
|
|
} else {
|
|
|
|
return std::vector<std::string>();
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
2015-10-10 14:41:19 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
std::string GPU_Vulkan::DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType) {
|
|
|
|
if (type == SHADER_TYPE_VERTEXLOADER) {
|
|
|
|
return drawEngine_.DebugGetVertexLoaderString(id, stringType);
|
2016-01-09 20:19:18 +00:00
|
|
|
} else if (type == SHADER_TYPE_PIPELINE) {
|
|
|
|
return pipelineManager_->DebugGetObjectString(id, type, stringType);
|
2017-04-04 09:09:29 +00:00
|
|
|
} else if (type == SHADER_TYPE_DEPAL) {
|
|
|
|
return "";
|
2017-12-06 15:01:56 +00:00
|
|
|
} else if (type == SHADER_TYPE_SAMPLER) {
|
|
|
|
return textureCacheVulkan_->DebugGetSamplerString(id, stringType);
|
|
|
|
} else if (type == SHADER_TYPE_VERTEX || type == SHADER_TYPE_FRAGMENT) {
|
2017-01-23 19:48:23 +00:00
|
|
|
return shaderManagerVulkan_->DebugGetShaderString(id, type, stringType);
|
2017-12-06 15:01:56 +00:00
|
|
|
} else {
|
|
|
|
return std::string();
|
2016-01-05 20:18:43 +00:00
|
|
|
}
|
2015-10-10 14:41:19 +00:00
|
|
|
}
|
2019-08-20 22:03:00 +00:00
|
|
|
|
|
|
|
std::string GPU_Vulkan::GetGpuProfileString() {
|
|
|
|
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
|
|
|
return rm->GetGpuProfileString();
|
|
|
|
}
|