Skip to content

Commit

Permalink
Merge pull request #18757 from hrydgard/more-tweaks
Browse files Browse the repository at this point in the history
More asserts, move play button on pause screen
  • Loading branch information
hrydgard committed Jan 24, 2024
2 parents 138890a + 22e91c9 commit 408d3aa
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 19 deletions.
18 changes: 18 additions & 0 deletions Common/GPU/Vulkan/VulkanRenderManager.cpp
Expand Up @@ -348,6 +348,11 @@ bool VulkanRenderManager::CreateBackbuffers() {
}

void VulkanRenderManager::StartThreads() {
{
std::unique_lock<std::mutex> lock(compileMutex_);
_assert_(compileQueue_.empty());
}

runCompileThread_ = true; // For controlling the compiler thread's exit

if (useRenderThread_) {
Expand Down Expand Up @@ -403,6 +408,11 @@ void VulkanRenderManager::StopThreads() {

INFO_LOG(G3D, "Vulkan compiler thread joined. Now wait for any straggling compile tasks.");
CreateMultiPipelinesTask::WaitForAll();

{
std::unique_lock<std::mutex> lock(compileMutex_);
_assert_(compileQueue_.empty());
}
}

void VulkanRenderManager::DestroyBackbuffers() {
Expand All @@ -412,6 +422,14 @@ void VulkanRenderManager::DestroyBackbuffers() {
queueRunner_.DestroyBackBuffers();
}

void VulkanRenderManager::CheckNothingPending() {
_assert_(pipelinesToCheck_.empty());
{
std::unique_lock<std::mutex> lock(compileMutex_);
_assert_(compileQueue_.empty());
}
}

VulkanRenderManager::~VulkanRenderManager() {
INFO_LOG(G3D, "VulkanRenderManager destructor");

Expand Down
4 changes: 2 additions & 2 deletions Common/GPU/Vulkan/VulkanRenderManager.h
Expand Up @@ -115,13 +115,12 @@ class VKRGraphicsPipelineDesc : public Draw::RefCountedObject {
RPKey rpKey{};
};

// Wrapped pipeline. Doesn't own desc.
// Wrapped pipeline. Does own desc!
struct VKRGraphicsPipeline {
VKRGraphicsPipeline(PipelineFlags flags, const char *tag) : flags_(flags), tag_(tag) {}
~VKRGraphicsPipeline();

bool Create(VulkanContext *vulkan, VkRenderPass compatibleRenderPass, RenderPassType rpType, VkSampleCountFlagBits sampleCount, double scheduleTime, int countToCompile);

void DestroyVariants(VulkanContext *vulkan, bool msaaOnly);

// This deletes the whole VKRGraphicsPipeline, you must remove your last pointer to it when doing this.
Expand Down Expand Up @@ -237,6 +236,7 @@ class VulkanRenderManager {
// These can run on a different thread!
void Finish();
void Present();
void CheckNothingPending();

void SetInvalidationCallback(InvalidationCallback callback) {
invalidationCallback_ = callback;
Expand Down
13 changes: 7 additions & 6 deletions Core/FileLoaders/HTTPFileLoader.cpp
Expand Up @@ -128,8 +128,10 @@ int HTTPFileLoader::SendHEAD(const Url &url, std::vector<std::string> &responseH
return -400;
}

client_.SetDataTimeout(20.0);
Connect();
double timeout = 20.0;

client_.SetDataTimeout(timeout);
Connect(10.0);
if (!connected_) {
ERROR_LOG(LOADER, "HTTP request failed, failed to connect: %s port %d (resource: '%s')", url.Host().c_str(), url.Port(), url.Resource().c_str());
latestError_ = "Could not connect (refused to connect)";
Expand Down Expand Up @@ -186,7 +188,7 @@ size_t HTTPFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data, Flags f
return 0;
}

Connect();
Connect(10.0);
if (!connected_) {
return 0;
}
Expand Down Expand Up @@ -258,10 +260,9 @@ size_t HTTPFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data, Flags f
return readBytes;
}

void HTTPFileLoader::Connect() {
void HTTPFileLoader::Connect(double timeout) {
if (!connected_) {
cancel_ = false;
// Latency is important here, so reduce the timeout.
connected_ = client_.Connect(3, 10.0, &cancel_);
connected_ = client_.Connect(3, timeout, &cancel_);
}
}
2 changes: 1 addition & 1 deletion Core/FileLoaders/HTTPFileLoader.h
Expand Up @@ -58,7 +58,7 @@ class HTTPFileLoader : public FileLoader {
void Prepare();
int SendHEAD(const Url &url, std::vector<std::string> &responseHeaders);

void Connect();
void Connect(double timeout);

void Disconnect() {
if (connected_) {
Expand Down
1 change: 1 addition & 0 deletions GPU/Vulkan/GPU_Vulkan.cpp
Expand Up @@ -169,6 +169,7 @@ GPU_Vulkan::~GPU_Vulkan() {
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
// This now also does a hard sync with the render thread, so that we can safely delete our pipeline layout below.
rm->StopThreads();
rm->CheckNothingPending();
}

SaveCache(shaderCachePath_);
Expand Down
21 changes: 11 additions & 10 deletions UI/PauseScreen.cpp
Expand Up @@ -348,7 +348,6 @@ void GamePauseScreen::CreateViews() {
leftColumn->Add(leftColumnItems);

leftColumnItems->SetSpacing(5.0f);
leftColumnItems->Add(new Spacer(0.0f));
if (Achievements::IsActive()) {
leftColumnItems->Add(new GameAchievementSummaryView());

Expand Down Expand Up @@ -379,6 +378,9 @@ void GamePauseScreen::CreateViews() {
leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, notAvailable, ""));
}

ViewGroup *middleColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(64, FILL_PARENT, Margins(0, 10, 0, 15)));
root_->Add(middleColumn);

ViewGroup *rightColumnHolder = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(vertical ? 200 : 300, FILL_PARENT, actionMenuMargins));

ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f));
Expand Down Expand Up @@ -443,15 +445,14 @@ void GamePauseScreen::CreateViews() {
}

if (!Core_MustRunBehind()) {
ViewGroup *playControls = rightColumnHolder->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
playControls->SetTag("debug");
playControls->Add(new Spacer(new LinearLayoutParams(1.0f)));
playButton_ = playControls->Add(new Button("", g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"), new LinearLayoutParams(0.0f, G_RIGHT)));
playButton_->OnClick.Add([=](UI::EventParams &e) {
g_Config.bRunBehindPauseMenu = !g_Config.bRunBehindPauseMenu;
playButton_->SetImageID(g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"));
return UI::EVENT_DONE;
});
if (middleColumn) {
playButton_ = middleColumn->Add(new Button("", g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"), new LinearLayoutParams(64, 64)));
playButton_->OnClick.Add([=](UI::EventParams &e) {
g_Config.bRunBehindPauseMenu = !g_Config.bRunBehindPauseMenu;
playButton_->SetImageID(g_Config.bRunBehindPauseMenu ? ImageID("I_PAUSE") : ImageID("I_PLAY"));
return UI::EVENT_DONE;
});
}
} else {
auto nw = GetI18NCategory(I18NCat::NETWORKING);
rightColumnHolder->Add(new TextView(nw->T("Network connected")));
Expand Down
1 change: 1 addition & 0 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Expand Up @@ -820,6 +820,7 @@ protected void onDestroy() {
if (isVRDevice()) {
System.exit(0);
}
Log.i(TAG, "onDestroy");
}

@Override
Expand Down

0 comments on commit 408d3aa

Please sign in to comment.