GameInfo: Try to reduce the locking a bit.

This commit is contained in:
Henrik Rydgård 2024-01-18 22:52:56 +01:00
parent e5339bdaa2
commit 74f5be02a1
8 changed files with 59 additions and 27 deletions

View file

@ -96,6 +96,10 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback(
// Clear value but no LOAD_OP_CLEAR. Not worth fixing right now.
return false;
case 1544472022:
// MSAA depth resolve write-after-write??
return false;
default:
break;
}

View file

@ -35,6 +35,10 @@ public:
return !descPool_;
}
void SetTag(const char *tag) {
tag_ = tag;
}
private:
VkResult Recreate(bool grow);

View file

@ -1575,7 +1575,7 @@ void VulkanRenderManager::ResetStats() {
VKRPipelineLayout *VulkanRenderManager::CreatePipelineLayout(BindingType *bindingTypes, size_t bindingTypesCount, bool geoShadersEnabled, const char *tag) {
VKRPipelineLayout *layout = new VKRPipelineLayout();
layout->tag = tag;
layout->SetTag(tag);
layout->bindingTypesCount = (uint32_t)bindingTypesCount;
_dbg_assert_(bindingTypesCount <= ARRAY_SIZE(layout->bindingTypes));

View file

@ -192,9 +192,10 @@ struct PackedDescriptor {
};
// Note that we only support a single descriptor set due to compatibility with some ancient devices.
// We should probably eventually give that up.
// We should probably eventually give that up eventually.
struct VKRPipelineLayout {
~VKRPipelineLayout();
enum { MAX_DESC_SET_BINDINGS = 10 };
BindingType bindingTypes[MAX_DESC_SET_BINDINGS];
@ -205,7 +206,8 @@ struct VKRPipelineLayout {
const char *tag = nullptr;
struct FrameData {
FrameData() : pool("GameDescPool", true) {}
FrameData() : pool("N/A", true) {}
VulkanDescSetPool pool;
FastVec<PackedDescriptor> descData_;
FastVec<PendingDescSet> descSets_;
@ -217,6 +219,12 @@ struct VKRPipelineLayout {
FrameData frameData[VulkanContext::MAX_INFLIGHT_FRAMES];
void FlushDescSets(VulkanContext *vulkan, int frame, QueueProfileContext *profile);
void SetTag(const char *tag) {
this->tag = tag;
for (int i = 0; i < ARRAY_SIZE(frameData); i++) {
frameData[i].pool.SetTag(tag);
}
}
};
class VulkanRenderManager {

View file

@ -381,6 +381,9 @@ public:
~VKContext();
void DebugAnnotate(const char *annotation) override;
void Wait() override {
vkDeviceWaitIdle(vulkan_->GetDevice());
}
const DeviceCaps &GetDeviceCaps() const override {
return caps_;

View file

@ -693,6 +693,8 @@ public:
Bugs GetBugs() const { return bugs_; }
virtual void Wait() {}
virtual const DeviceCaps &GetDeviceCaps() const = 0;
virtual uint32_t GetDataFormatSupport(DataFormat fmt) const = 0;
virtual std::vector<std::string> GetFeatureList() const { return std::vector<std::string>(); }

View file

@ -229,6 +229,7 @@ void TextureCacheVulkan::DeviceLost() {
nextTexture_ = nullptr;
draw_ = nullptr;
Unbind();
}
void TextureCacheVulkan::DeviceRestore(Draw::DrawContext *draw) {
@ -372,8 +373,7 @@ void TextureCacheVulkan::UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutB
void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) {
if (!entry || !entry->vkTex) {
imageView_ = VK_NULL_HANDLE;
curSampler_ = VK_NULL_HANDLE;
Unbind();
return;
}

View file

@ -227,21 +227,25 @@ u64 GameInfo::GetInstallDataSizeInBytes() {
}
bool GameInfo::LoadFromPath(const Path &gamePath) {
std::lock_guard<std::mutex> guard(lock);
// No need to rebuild if we already have it loaded.
if (filePath_ != gamePath) {
{
std::lock_guard<std::mutex> guard(loaderLock);
fileLoader.reset(ConstructFileLoader(gamePath));
if (!fileLoader)
return false;
{
std::lock_guard<std::mutex> guard(lock);
// No need to rebuild if we already have it loaded.
if (filePath_ == gamePath) {
return true;
}
filePath_ = gamePath;
// This is a fallback title, while we're loading / if unable to load.
title = filePath_.GetFilename();
}
{
std::lock_guard<std::mutex> guard(loaderLock);
fileLoader.reset(ConstructFileLoader(gamePath));
if (!fileLoader)
return false;
}
std::lock_guard<std::mutex> guard(lock);
filePath_ = gamePath;
// This is a fallback title, while we're loading / if unable to load.
title = filePath_.GetFilename();
return true;
}
@ -476,20 +480,26 @@ public:
if (info_->wantFlags & GAMEINFO_WANTBG) {
if (pbp.GetSubFileSize(PBP_PIC0_PNG) > 0) {
std::string data;
pbp.GetSubFileAsString(PBP_PIC0_PNG, &data);
std::lock_guard<std::mutex> lock(info_->lock);
pbp.GetSubFileAsString(PBP_PIC0_PNG, &info_->pic0.data);
info_->pic0.data = std::move(data);
info_->pic0.dataLoaded = true;
}
if (pbp.GetSubFileSize(PBP_PIC1_PNG) > 0) {
std::string data;
pbp.GetSubFileAsString(PBP_PIC1_PNG, &data);
std::lock_guard<std::mutex> lock(info_->lock);
pbp.GetSubFileAsString(PBP_PIC1_PNG, &info_->pic1.data);
info_->pic1.data = std::move(data);
info_->pic1.dataLoaded = true;
}
}
if (info_->wantFlags & GAMEINFO_WANTSND) {
if (pbp.GetSubFileSize(PBP_SND0_AT3) > 0) {
std::string data;
pbp.GetSubFileAsString(PBP_SND0_AT3, &data);
std::lock_guard<std::mutex> lock(info_->lock);
pbp.GetSubFileAsString(PBP_SND0_AT3, &info_->sndFileData);
info_->sndFileData = std::move(data);
info_->sndDataLoaded = true;
}
}
@ -628,16 +638,17 @@ handleELF:
// Alright, let's fetch the PARAM.SFO.
std::string paramSFOcontents;
if (ReadFileToString(&umd, "/PSP_GAME/PARAM.SFO", &paramSFOcontents, nullptr)) {
std::lock_guard<std::mutex> lock(info_->lock);
info_->paramSFO.ReadSFO((const u8 *)paramSFOcontents.data(), paramSFOcontents.size());
info_->ParseParamSFO();
{
std::lock_guard<std::mutex> lock(info_->lock);
info_->paramSFO.ReadSFO((const u8 *)paramSFOcontents.data(), paramSFOcontents.size());
info_->ParseParamSFO();
}
if (info_->wantFlags & GAMEINFO_WANTBG) {
info_->pic0.dataLoaded = ReadFileToString(&umd, "/PSP_GAME/PIC0.PNG", &info_->pic0.data, nullptr);
info_->pic1.dataLoaded = ReadFileToString(&umd, "/PSP_GAME/PIC1.PNG", &info_->pic1.data, nullptr);
info_->pic0.dataLoaded = ReadFileToString(&umd, "/PSP_GAME/PIC0.PNG", &info_->pic0.data, &info_->lock);
info_->pic1.dataLoaded = ReadFileToString(&umd, "/PSP_GAME/PIC1.PNG", &info_->pic1.data, &info_->lock);
}
if (info_->wantFlags & GAMEINFO_WANTSND) {
info_->sndDataLoaded = ReadFileToString(&umd, "/PSP_GAME/SND0.AT3", &info_->sndFileData, nullptr);
info_->sndDataLoaded = ReadFileToString(&umd, "/PSP_GAME/SND0.AT3", &info_->sndFileData, &info_->lock);
}
}