Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More misc minor fixes #19529

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Common/GPU/OpenGL/GLRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,10 @@ class GLRenderManager {
skipGLCalls_ = true;
}

int GetNumSteps() const {
return (int)steps_.size();
}

private:
bool Run(GLRRenderThreadTask &task);

Expand Down
7 changes: 7 additions & 0 deletions Common/GPU/OpenGL/thin3d_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ class OpenGLContext : public DrawContext {
OpenGLContext(bool canChangeSwapInterval);
~OpenGLContext();

BackendState GetCurrentBackendState() const override {
return BackendState{
(u32)renderManager_.GetNumSteps(),
true, // Means that the other value is meaningful.
};
}

void SetTargetSize(int w, int h) override {
DrawContext::SetTargetSize(w, h);
renderManager_.Resize(w, h);
Expand Down
3 changes: 2 additions & 1 deletion Common/GPU/Vulkan/VulkanMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ VulkanPushPool::Block VulkanPushPool::CreateBlock(size_t size) {
VmaAllocationInfo allocInfo{};

VkResult result = vmaCreateBuffer(vulkan_->Allocator(), &b, &allocCreateInfo, &block.buffer, &block.allocation, &allocInfo);
_assert_(result == VK_SUCCESS);

_assert_msg_(result == VK_SUCCESS, "VulkanPushPool: Failed to create buffer (result = %s, size = %d)", VulkanResultToString(result), (int)size);

result = vmaMapMemory(vulkan_->Allocator(), block.allocation, (void **)(&block.writePtr));

Expand Down
1 change: 0 additions & 1 deletion Common/UI/PopupScreens.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ class FolderChooserChoice : public AbstractChoiceWithValueDisplay {

private:
std::string *value_;
BrowseFileType fileType_;
RequesterToken token_;
};

Expand Down
10 changes: 7 additions & 3 deletions GPU/Common/FramebufferManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,9 +1567,9 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) {
// No framebuffer to display! Clear to black.
if (useBufferedRendering_) {
draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput");
presentation_->NotifyPresent();
}
gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE);
presentation_->NotifyPresent();
return;
}

Expand Down Expand Up @@ -1628,15 +1628,17 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) {
if (Memory::IsValidAddress(fbaddr)) {
// The game is displaying something directly from RAM. In GTA, it's decoded video.
DrawFramebufferToOutput(Memory::GetPointerUnchecked(fbaddr), displayStride_, displayFormat_);
// This effectively calls presentation_->NotifyPresent();
return;
} else {
DEBUG_LOG(Log::FrameBuf, "Found no FBO to display! displayFBPtr = %08x", fbaddr);
// No framebuffer to display! Clear to black.
if (useBufferedRendering_) {
// Bind and clear the backbuffer. This should be the first time during the frame that it's bound.
draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput_NoFBO");
}
} // For non-buffered rendering, every frame is cleared anyway.
gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE);
presentation_->NotifyPresent();
return;
}
}
Expand Down Expand Up @@ -1700,7 +1702,9 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) {
presentation_->SourceFramebuffer(vfb->fbo, actualWidth, actualHeight);
presentation_->CopyToOutput(flags, uvRotation, u0, v0, u1, v1);
} else if (useBufferedRendering_) {
WARN_LOG(Log::FrameBuf, "Current VFB lacks an FBO: %08x", vfb->fb_address);
WARN_LOG(Log::FrameBuf, "Using buffered rendering, and current VFB lacks an FBO: %08x", vfb->fb_address);
} else {
presentation_->NotifyPresent();
}

// This may get called mid-draw if the game uses an immediate flip.
Expand Down
4 changes: 1 addition & 3 deletions GPU/Common/VertexDecoderCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,9 +1313,7 @@ void VertexDecoder::SetVertexType(u32 fmt, const VertexDecoderOptions &options,
// Can skip looking up in the JIT.
jitted_ = &VtxDec_Tu8_C5551_Ps16;
return;
}
// Fails to update alphaFull properly.
else if (!options.expand8BitNormalsToFloat && fmtWithoutSkinFlag == (GE_VTYPE_TC_16BIT | GE_VTYPE_NRM_8BIT | GE_VTYPE_COL_8888 | GE_VTYPE_POS_FLOAT)) {
} else if (!options.expand8BitNormalsToFloat && fmtWithoutSkinFlag == (GE_VTYPE_TC_16BIT | GE_VTYPE_NRM_8BIT | GE_VTYPE_COL_8888 | GE_VTYPE_POS_FLOAT)) {
jitted_ = &VtxDec_Tu16_C8888_Pfloat;
return;
}
Expand Down
18 changes: 14 additions & 4 deletions GPU/GPUCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,16 +1281,26 @@ void GPUCommon::FlushImm() {
if (immCount_ == 0 || immPrim_ == GE_PRIM_INVALID)
return;

SetDrawType(DRAW_PRIM, immPrim_);
VirtualFramebuffer *vfb = nullptr;
if (framebufferManager_)
vfb = framebufferManager_->SetRenderFrameBuffer(gstate_c.IsDirty(DIRTY_FRAMEBUF), gstate_c.skipDrawReason);
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
// No idea how many cycles to skip, heh.
immCount_ = 0;
return;
}

// Ignore immediate point primitives with a X/Y of 0.
// These are accidentally created when games clear the graphics state.
if (immCount_ == 1 && immPrim_ == GE_PRIM_POINTS && immBuffer_[0].x == 0 && immBuffer_[0].y == 0 && immBuffer_[0].z == 0 && immBuffer_[0].color0_32 == 0) {
immCount_ = 0;
return;
}

SetDrawType(DRAW_PRIM, immPrim_);

gstate_c.UpdateUVScaleOffset();

VirtualFramebuffer *vfb = nullptr;
if (framebufferManager_)
vfb = framebufferManager_->SetRenderFrameBuffer(gstate_c.IsDirty(DIRTY_FRAMEBUF), gstate_c.skipDrawReason);
if (vfb) {
CheckDepthUsage(vfb);
}
Expand Down
2 changes: 1 addition & 1 deletion UI/DisplayLayoutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void DisplayLayoutScreen::CreateViews() {
value = setting.value;

if (duplicated) {
auto sliderName = StringFromFormat("%s %s", ps->T(setting.name), ps->T("(duplicated setting, previous slider will be used)"));
auto sliderName = StringFromFormat("%s %s", ps->T_cstr(setting.name.c_str()), ps->T_cstr("(duplicated setting, previous slider will be used)"));
PopupSliderChoiceFloat *settingValue = settingContainer->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, setting.value, sliderName, setting.step, screenManager()));
settingValue->SetEnabled(false);
} else {
Expand Down
3 changes: 1 addition & 2 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,6 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {

draw->SetViewport(viewport);
draw->SetScissorRect(0, 0, g_display.pixel_xres, g_display.pixel_yres);
skipBufferEffects = true;
framebufferBound = true;
}
draw->SetTargetSize(g_display.pixel_xres, g_display.pixel_yres);
Expand Down Expand Up @@ -1510,7 +1509,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
Draw::BackendState state = draw->GetCurrentBackendState();

// We allow if !state.valid, that means it's not the Vulkan backend.
_assert_msg_(!state.valid || state.passes >= 1, "skipB: %d sw: %d", (int)skipBufferEffects, (int)g_Config.bSoftwareRendering);
_assert_msg_(!state.valid || state.passes >= 1, "skipB: %d sw: %d mode: %d back: %d", (int)skipBufferEffects, (int)g_Config.bSoftwareRendering, mode, (int)g_Config.iGPUBackend);

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

Expand Down
2 changes: 1 addition & 1 deletion UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ bool HandleGlobalMessage(UIMessage message, const std::string &value) {
return true;
} else if (message == UIMessage::SAVESTATE_DISPLAY_SLOT) {
auto sy = GetI18NCategory(I18NCat::SYSTEM);
std::string msg = StringFromFormat("%s: %d", std::string(sy->T("Savestate Slot")).c_str(), SaveState::GetCurrentSlot() + 1);
std::string msg = StringFromFormat("%s: %d", sy->T_cstr("Savestate Slot"), SaveState::GetCurrentSlot() + 1);
// Show for the same duration as the preview.
g_OSD.Show(OSDType::MESSAGE_INFO, msg, 2.0f, "savestate_slot");
return true;
Expand Down
Loading