Merge pull request #19134 from hrydgard/assorted-bugfixes

Don't enable the Mali "never" workaround on all GPUs (oops). Minor fixes.
This commit is contained in:
Henrik Rydgård 2024-05-12 00:54:50 +02:00 committed by GitHub
commit 5e6f5eaefe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 60 additions and 16 deletions

View File

@ -533,6 +533,10 @@ public:
void StartThreads();
void StopThreads();
size_t GetNumSteps() const {
return steps_.size();
}
private:
void EndCurRenderStep();

View File

@ -380,6 +380,13 @@ public:
VKContext(VulkanContext *vulkan, bool useRenderThread);
~VKContext();
BackendState GetCurrentBackendState() const override {
return BackendState{
(u32)renderManager_.GetNumSteps(),
true,
};
}
void DebugAnnotate(const char *annotation) override;
void Wait() override {
vkDeviceWaitIdle(vulkan_->GetDevice());
@ -1047,8 +1054,6 @@ VKContext::VKContext(VulkanContext *vulkan, bool useRenderThread)
INFO_LOG(G3D, "KHR_depth_stencil_resolve not supported, disabling multisampling");
}
bugs_.Infest(Draw::Bugs::NO_DEPTH_CANNOT_DISCARD_STENCIL_MALI);
// We limit multisampling functionality to reasonably recent and known-good tiling GPUs.
if (multisampleAllowed) {
// Check for depth stencil resolve. Without it, depth textures won't work, and we don't want that mess

View File

@ -687,6 +687,11 @@ enum class DebugFlags {
};
ENUM_CLASS_BITOPS(DebugFlags);
struct BackendState {
u32 passes;
bool valid;
};
class DrawContext {
public:
virtual ~DrawContext();
@ -705,6 +710,10 @@ public:
virtual std::vector<std::string> GetPresentModeList(std::string_view currentMarkerString) const { return std::vector<std::string>(); }
virtual std::vector<std::string> GetSurfaceFormatList() const { return std::vector<std::string>(); }
virtual BackendState GetCurrentBackendState() const {
return BackendState{};
}
// Describes the primary shader language that this implementation prefers.
const ShaderLanguageDesc &GetShaderLanguageDesc() {
return shaderLanguageDesc_;

View File

@ -187,7 +187,8 @@ ScreenRenderFlags ScreenManager::render() {
bool first = true;
do {
--iter;
if (!foundBackgroundScreen && iter->screen->canBeBackground(first)) {
ScreenRenderRole role = iter->screen->renderRole(first);
if (!foundBackgroundScreen && (role & ScreenRenderRole::CAN_BE_BACKGROUND)) {
// There still might be a screen that wants to be background - generally the EmuScreen if present.
layers.push_back(iter->screen);
foundBackgroundScreen = iter->screen;
@ -198,6 +199,9 @@ ScreenRenderFlags ScreenManager::render() {
coveringScreen = iter->screen;
}
first = false;
if (role & ScreenRenderRole::MUST_BE_FIRST) {
break;
}
} while (iter != stack_.begin());
if (backgroundScreen_ && !foundBackgroundScreen) {

View File

@ -61,6 +61,14 @@ enum class ScreenRenderFlags {
};
ENUM_CLASS_BITOPS(ScreenRenderFlags);
enum class ScreenRenderRole {
NONE = 0,
CAN_BE_BACKGROUND = 1,
MUST_BE_FIRST = 2,
};
ENUM_CLASS_BITOPS(ScreenRenderRole);
class Screen {
public:
Screen() : screenManager_(nullptr) { }
@ -74,7 +82,7 @@ public:
virtual void sendMessage(UIMessage message, const char *value) {}
virtual void deviceLost() {}
virtual void deviceRestored() {}
virtual bool canBeBackground(bool isTop) const { return false; }
virtual ScreenRenderRole renderRole(bool isTop) const { return ScreenRenderRole::NONE; }
virtual bool wantBrightBackground() const { return false; } // special hack for DisplayLayoutScreen.
virtual void focusChanged(ScreenFocusChange focusChange);

View File

@ -84,12 +84,12 @@ void VtxDec_Tu16_C8888_Pfloat(const u8 *srcp, u8 *dstp, int count, const UVScale
float32x2_t finalUV = vadd_f32(vmul_f32(vcvt_f32_u32(fuv), uvScale), uvOff);
u32 normal = src[i].packed_normal;
uint32x4_t colpos = vld1q_u32((const u32 *)&src[i].col);
alphaMask = vandq_u32(alphaMask, colpos);
alphaMask = vandq_u32(alphaMask, colpos);
vst1_f32(&dst[i].u, finalUV);
dst[i].packed_normal = normal;
vst1q_u32(&dst[i].col, colpos);
}
alpha = vgetq_lane_u32(alphaMask, 0);
alpha = vgetq_lane_u32(alphaMask, 0);
#else
for (int i = 0; i < count; i++) {
float u = src[i].u * uscale + uoff;

View File

@ -1279,17 +1279,25 @@ bool EmuScreen::checkPowerDown() {
return false;
}
bool EmuScreen::canBeBackground(bool isTop) const {
if (g_Config.bSkipBufferEffects) {
return isTop || (g_Config.bTransparentBackground && Core_ShouldRunBehind());
}
ScreenRenderRole EmuScreen::renderRole(bool isTop) const {
auto CanBeBackground = [&]() -> bool {
if (g_Config.bSkipBufferEffects) {
return isTop || (g_Config.bTransparentBackground && Core_ShouldRunBehind());
}
if (!g_Config.bTransparentBackground && !isTop) {
if (Core_ShouldRunBehind() || screenManager()->topScreen()->wantBrightBackground())
return true;
return false;
if (!g_Config.bTransparentBackground && !isTop) {
if (Core_ShouldRunBehind() || screenManager()->topScreen()->wantBrightBackground())
return true;
return false;
}
return true;
};
ScreenRenderRole role = ScreenRenderRole::MUST_BE_FIRST;
if (CanBeBackground()) {
role |= ScreenRenderRole::CAN_BE_BACKGROUND;
}
return true;
return role;
}
void EmuScreen::darken() {
@ -1313,6 +1321,12 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
return flags; // shouldn't really happen but I've seen a suspicious stack trace..
}
// Sanity check
#ifdef _DEBUG
Draw::BackendState state = draw->GetCurrentBackendState();
_dbg_assert_(!state.valid || state.passes == 0);
#endif
GamepadUpdateOpacity();
bool skipBufferEffects = g_Config.bSkipBufferEffects;

View File

@ -46,7 +46,7 @@ public:
void dialogFinished(const Screen *dialog, DialogResult result) override;
void sendMessage(UIMessage message, const char *value) override;
void resized() override;
bool canBeBackground(bool isTop) const override;
ScreenRenderRole renderRole(bool isTop) const override;
// Note: Unlike your average boring UIScreen, here we override the Unsync* functions
// to get minimal latency and full control. We forward to UIScreen when needed.