Skip to content

Commit

Permalink
Merge pull request #18725 from hrydgard/additional-beta-fixes
Browse files Browse the repository at this point in the history
Additional beta fixes
  • Loading branch information
hrydgard committed Jan 18, 2024
2 parents bfe16fd + 103d8b1 commit 10d16ea
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 42 deletions.
4 changes: 4 additions & 0 deletions Common/GPU/Vulkan/VulkanDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions Common/GPU/Vulkan/VulkanDescSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class VulkanDescSetPool {
return !descPool_;
}

void SetTag(const char *tag) {
tag_ = tag;
}

private:
VkResult Recreate(bool grow);

Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
12 changes: 10 additions & 2 deletions Common/GPU/Vulkan/VulkanRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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_;
Expand All @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions Common/GPU/Vulkan/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ class VKContext : public DrawContext {
~VKContext();

void DebugAnnotate(const char *annotation) override;
void Wait() override {
vkDeviceWaitIdle(vulkan_->GetDevice());
}

const DeviceCaps &GetDeviceCaps() const override {
return caps_;
Expand Down
2 changes: 2 additions & 0 deletions Common/GPU/thin3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ class DrawContext {

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>(); }
Expand Down
4 changes: 2 additions & 2 deletions Core/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static bool RegisterServer(int port) {

http.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));

char resource4[1024] = {};
char resource4[1024]{};
if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT, net::DNSType::IPV4)) {
if (http.Connect()) {
std::string ip = fd_util::GetLocalIP(http.sock());
Expand All @@ -97,7 +97,7 @@ static bool RegisterServer(int port) {

if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT, net::DNSType::IPV6)) {
// If IPv4 was successful, don't give this as much time (it blocks and sometimes IPv6 is broken.)
double timeout = success ? 2.0 : 20.0;
double timeout = success ? 2.0 : 10.0;

// We register both IPv4 and IPv6 in case the other client is using a different one.
if (resource4[0] != 0 && http.Connect(timeout)) {
Expand Down
4 changes: 2 additions & 2 deletions GPU/Common/SoftwareTransformCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void SoftwareTransform::BuildDrawingParams(int prim, int vertexCount, u32 vertTy

inds = newInds;
}
} else if (throughmode && g_Config.bSmart2DTexFiltering) {
} else if (throughmode && g_Config.bSmart2DTexFiltering && !gstate_c.textureIsVideo) {
// We check some common cases for pixel mapping.
// TODO: It's not really optimal that some previous step has removed the triangle strip.
if (vertexCount <= 6 && prim == GE_PRIM_TRIANGLES) {
Expand Down Expand Up @@ -682,7 +682,7 @@ bool SoftwareTransform::ExpandRectangles(int vertexCount, int &numDecodedVerts,
vscale /= gstate_c.curTextureHeight;
}

bool pixelMapped = g_Config.bSmart2DTexFiltering;
bool pixelMapped = g_Config.bSmart2DTexFiltering && !gstate_c.textureIsVideo;

for (int i = 0; i < vertexCount; i += 2) {
const TransformedVertex &transVtxTL = transformed[indsIn[i + 0]];
Expand Down
5 changes: 5 additions & 0 deletions GPU/Common/TextureCacheCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
if (!Memory::IsValidAddress(texaddr)) {
// Bind a null texture and return.
Unbind();
gstate_c.SetTextureIsVideo(false);
gstate_c.SetTextureIs3D(false);
gstate_c.SetTextureIsArray(false);
gstate_c.SetTextureIsFramebuffer(false);
Expand Down Expand Up @@ -569,6 +570,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
// got one!
gstate_c.curTextureWidth = w;
gstate_c.curTextureHeight = h;
gstate_c.SetTextureIsVideo(false);
gstate_c.SetTextureIs3D((entry->status & TexCacheEntry::STATUS_3D) != 0);
gstate_c.SetTextureIsArray(false);
gstate_c.SetTextureIsBGRA((entry->status & TexCacheEntry::STATUS_BGRA) != 0);
Expand Down Expand Up @@ -675,6 +677,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {

gstate_c.curTextureWidth = w;
gstate_c.curTextureHeight = h;
gstate_c.SetTextureIsVideo(false);
gstate_c.SetTextureIs3D((entry->status & TexCacheEntry::STATUS_3D) != 0);
gstate_c.SetTextureIsArray(false); // Ordinary 2D textures still aren't used by array view in VK. We probably might as well, though, at this point..
gstate_c.SetTextureIsFramebuffer(false);
Expand Down Expand Up @@ -1197,6 +1200,7 @@ void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate)
nextTexture_ = nullptr;
}

gstate_c.SetTextureIsVideo(false);
gstate_c.SetTextureIs3D(false);
gstate_c.SetTextureIsArray(true);

Expand Down Expand Up @@ -2154,6 +2158,7 @@ void TextureCacheCommon::ApplyTexture() {
ForgetLastTexture();
}

gstate_c.SetTextureIsVideo((entry->status & TexCacheEntry::STATUS_VIDEO) != 0);
if (entry->status & TexCacheEntry::STATUS_CLUT_GPU) {
// Special process.
ApplyTextureDepal(entry);
Expand Down
4 changes: 4 additions & 0 deletions GPU/GPUState.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ struct GPUStateCache {
Dirty(DIRTY_FRAGMENTSHADER_STATE);
}
}
void SetTextureIsVideo(bool isVideo) {
textureIsVideo = isVideo;
}
void SetTextureIsBGRA(bool isBGRA) {
if (bgraTexture != isBGRA) {
bgraTexture = isBGRA;
Expand Down Expand Up @@ -657,6 +660,7 @@ struct GPUStateCache {
bool needShaderTexClamp;
bool textureIsArray;
bool textureIsFramebuffer;
bool textureIsVideo;
bool useFlagsChanged;

float morphWeights[8];
Expand Down
4 changes: 2 additions & 2 deletions GPU/Vulkan/TextureCacheVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void TextureCacheVulkan::DeviceLost() {

nextTexture_ = nullptr;
draw_ = nullptr;
Unbind();
}

void TextureCacheVulkan::DeviceRestore(Draw::DrawContext *draw) {
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 5 additions & 2 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ void EmuScreen::bootGame(const Path &filename) {
if (!info || info->pending)
return;

SetExtraAssertInfo((info->id + " " + info->GetTitle()).c_str());
extraAssertInfoStr_ = info->id + " " + info->GetTitle();
SetExtraAssertInfo(extraAssertInfoStr_.c_str());

if (!info->id.empty()) {
g_Config.loadGameConfig(info->id, info->GetTitle());
Expand Down Expand Up @@ -468,6 +469,7 @@ void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) {
if (Core_IsActive())
UI::EnableFocusMovement(false);
RecreateViews();
SetExtraAssertInfo(extraAssertInfoStr_.c_str());
}

static void AfterSaveStateAction(SaveState::Status status, const std::string &message, void *) {
Expand Down Expand Up @@ -1612,14 +1614,15 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
PSP_EndHostFrame();
}

screenManager()->getUIContext()->BeginFrame();

if (gpu && !gpu->PresentedThisFrame() && !skipBufferEffects) {
draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, clearColor }, "EmuScreen_NoFrame");
draw->SetViewport(viewport);
draw->SetScissorRect(0, 0, g_display.pixel_xres, g_display.pixel_yres);
}

screenManager()->getUIContext()->BeginFrame();

if (!(mode & ScreenRenderMode::TOP)) {
// We're in run-behind mode, but we don't want to draw chat, debug UI and stuff.
// So, darken and bail here.
Expand Down
2 changes: 2 additions & 0 deletions UI/EmuScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ class EmuScreen : public UIScreen {

UI::Button *cardboardDisableButton_ = nullptr;

std::string extraAssertInfoStr_;

ControlMapper controlMapper_;
};
69 changes: 42 additions & 27 deletions UI/GameInfoCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -340,16 +344,19 @@ static bool ReadFileToString(IFileSystem *fs, const char *filename, std::string
if (handle < 0) {
return false;
}

if (mtx) {
std::string data;
data.resize(info.size);
fs->ReadFile(handle, (u8 *)data.data(), info.size);
fs->CloseFile(handle);

std::lock_guard<std::mutex> lock(*mtx);
contents->resize(info.size);
fs->ReadFile(handle, (u8 *)contents->data(), info.size);
*contents = std::move(data);
} else {
contents->resize(info.size);
fs->ReadFile(handle, (u8 *)contents->data(), info.size);
fs->CloseFile(handle);
}
fs->CloseFile(handle);
return true;
}

Expand All @@ -363,12 +370,13 @@ static bool ReadVFSToString(const char *filename, std::string *contents, std::mu
} else {
*contents = std::string((const char *)data, sz);
}
} else {
return false;
}
delete [] data;
return data != nullptr;
return true;
}


class GameInfoWorkItem : public Task {
public:
GameInfoWorkItem(const Path &gamePath, std::shared_ptr<GameInfo> &info)
Expand Down Expand Up @@ -472,20 +480,26 @@ class GameInfoWorkItem : public Task {

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;
}
}
Expand Down Expand Up @@ -624,16 +638,17 @@ class GameInfoWorkItem : public Task {
// 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);
}
}

Expand Down
Loading

0 comments on commit 10d16ea

Please sign in to comment.