mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-11-16 22:32:23 +00:00
Merge 7495c99d13 into 0fdf1cc386
This commit is contained in:
commit
cc8c09b16b
@ -34,10 +34,21 @@ void AbstractGfx::BeginUtilityDrawing()
|
||||
|
||||
void AbstractGfx::EndUtilityDrawing()
|
||||
{
|
||||
// Reset framebuffer/scissor/viewport. Pipeline will be reset at next draw.
|
||||
// Reset framebuffer. Pipeline will be reset at next draw.
|
||||
g_framebuffer_manager->BindEFBFramebuffer();
|
||||
BPFunctions::SetScissorAndViewport(g_framebuffer_manager.get(), bpmem.scissorTL, bpmem.scissorBR,
|
||||
bpmem.scissorOffset, xfmem.viewport);
|
||||
|
||||
// Reset our viewport and scissors to the last stored value if we have it
|
||||
// We might not have one in the scenario where we're doing utility drawing
|
||||
// at the start of launching the software (ex: drawing the compile shaders
|
||||
// before start dialog)
|
||||
if (m_viewport_and_scissors)
|
||||
{
|
||||
SetViewport(m_viewport_and_scissors->viewport_x, m_viewport_and_scissors->viewport_y,
|
||||
m_viewport_and_scissors->viewport_width, m_viewport_and_scissors->viewport_height,
|
||||
m_viewport_and_scissors->viewport_near_depth,
|
||||
m_viewport_and_scissors->viewport_far_depth);
|
||||
SetScissorRect(m_viewport_and_scissors->scissors_rect);
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractGfx::SetFramebuffer(AbstractFramebuffer* framebuffer)
|
||||
@ -87,6 +98,16 @@ void AbstractGfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool co
|
||||
EndUtilityDrawing();
|
||||
}
|
||||
|
||||
void AbstractGfx::SetViewportAndScissor(ViewportAndScissors viewport_and_scissors)
|
||||
{
|
||||
m_viewport_and_scissors = std::move(viewport_and_scissors);
|
||||
}
|
||||
|
||||
const std::optional<AbstractGfx::ViewportAndScissors>& AbstractGfx::GetViewportAndScissors() const
|
||||
{
|
||||
return m_viewport_and_scissors;
|
||||
}
|
||||
|
||||
void AbstractGfx::SetViewportAndScissor(const MathUtil::Rectangle<int>& rect, float min_depth,
|
||||
float max_depth)
|
||||
{
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
class AbstractFramebuffer;
|
||||
@ -126,6 +127,23 @@ public:
|
||||
|
||||
AbstractFramebuffer* GetCurrentFramebuffer() const { return m_current_framebuffer; }
|
||||
|
||||
struct ViewportAndScissors
|
||||
{
|
||||
MathUtil::Rectangle<int> scissors_rect;
|
||||
float viewport_x;
|
||||
float viewport_y;
|
||||
float viewport_width;
|
||||
float viewport_height;
|
||||
float viewport_near_depth;
|
||||
float viewport_far_depth;
|
||||
};
|
||||
|
||||
// Sets the last viewport and scissors, uses it to restore on 'EndUtilityDrawing'
|
||||
void SetViewportAndScissor(ViewportAndScissors viewport_and_scissors);
|
||||
|
||||
// Gets the last set viewport and scissors
|
||||
const std::optional<ViewportAndScissors>& GetViewportAndScissors() const;
|
||||
|
||||
// Sets viewport and scissor to the specified rectangle. rect is assumed to be in framebuffer
|
||||
// coordinates, i.e. lower-left origin in OpenGL.
|
||||
void SetViewportAndScissor(const MathUtil::Rectangle<int>& rect, float min_depth = 0.0f,
|
||||
@ -177,6 +195,7 @@ protected:
|
||||
|
||||
private:
|
||||
Common::EventHook m_config_changed;
|
||||
std::optional<ViewportAndScissors> m_viewport_and_scissors;
|
||||
};
|
||||
|
||||
extern std::unique_ptr<AbstractGfx> g_gfx;
|
||||
|
||||
@ -265,6 +265,14 @@ void SetScissorAndViewport(FramebufferManager* frame_buffer_manager, ScissorPos
|
||||
y = static_cast<float>(g_gfx->GetCurrentFramebuffer()->GetHeight()) - y - height;
|
||||
|
||||
g_gfx->SetViewport(x, y, width, height, near_depth, far_depth);
|
||||
|
||||
g_gfx->SetViewportAndScissor(AbstractGfx::ViewportAndScissors{.scissors_rect = converted_rc,
|
||||
.viewport_x = x,
|
||||
.viewport_y = y,
|
||||
.viewport_width = width,
|
||||
.viewport_height = height,
|
||||
.viewport_near_depth = near_depth,
|
||||
.viewport_far_depth = far_depth});
|
||||
}
|
||||
|
||||
void SetDepthMode()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user