mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-26 07:10:05 +00:00
gl_state_tracker: Implement dirty flags for clip control
This commit is contained in:
parent
4f8d152b18
commit
a42a6e1a2c
@ -460,7 +460,6 @@ void RasterizerOpenGL::Clear() {
|
||||
// TODO: Signal state tracker about these changes
|
||||
state_tracker.NotifyBlend0();
|
||||
// TODO(Rodrigo): Find out if these changes affect clearing
|
||||
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||
glDisablei(GL_BLEND, 0);
|
||||
|
||||
UNIMPLEMENTED_IF(regs.clear_flags.viewport);
|
||||
@ -927,7 +926,23 @@ void RasterizerOpenGL::SyncViewport() {
|
||||
auto& flags = gpu.dirty.flags;
|
||||
const auto& regs = gpu.regs;
|
||||
|
||||
if (flags[Dirty::Viewports]) {
|
||||
const bool dirty_viewport = flags[Dirty::Viewports];
|
||||
if (dirty_viewport || flags[Dirty::ClipControl]) {
|
||||
flags[Dirty::ClipControl] = false;
|
||||
|
||||
bool flip_y = false;
|
||||
if (regs.viewport_transform[0].scale_y < 0.0) {
|
||||
flip_y = !flip_y;
|
||||
}
|
||||
if (regs.screen_y_control.y_negate != 0) {
|
||||
flip_y = !flip_y;
|
||||
}
|
||||
glClipControl(flip_y ? GL_UPPER_LEFT : GL_LOWER_LEFT,
|
||||
regs.depth_mode == Maxwell::DepthMode::ZeroToOne ? GL_ZERO_TO_ONE
|
||||
: GL_NEGATIVE_ONE_TO_ONE);
|
||||
}
|
||||
|
||||
if (dirty_viewport) {
|
||||
flags[Dirty::Viewports] = false;
|
||||
|
||||
const bool force = flags[Dirty::ViewportTransform];
|
||||
@ -948,17 +963,6 @@ void RasterizerOpenGL::SyncViewport() {
|
||||
static_cast<GLdouble>(src.depth_range_far));
|
||||
}
|
||||
}
|
||||
|
||||
bool flip_y = false;
|
||||
if (regs.viewport_transform[0].scale_y < 0.0) {
|
||||
flip_y = !flip_y;
|
||||
}
|
||||
if (regs.screen_y_control.y_negate != 0) {
|
||||
flip_y = !flip_y;
|
||||
}
|
||||
glClipControl(flip_y ? GL_UPPER_LEFT : GL_LOWER_LEFT,
|
||||
regs.depth_mode == Maxwell::DepthMode::ZeroToOne ? GL_ZERO_TO_ONE
|
||||
: GL_NEGATIVE_ONE_TO_ONE);
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncDepthClamp() {
|
||||
|
@ -211,6 +211,12 @@ void SetupDirtyPointSize(Tables& tables) {
|
||||
tables[0][OFF(point_sprite_enable)] = PointSize;
|
||||
}
|
||||
|
||||
void SetupDirtyClipControl(Tables& tables) {
|
||||
auto& table = tables[0];
|
||||
table[OFF(screen_y_control)] = ClipControl;
|
||||
table[OFF(depth_mode)] = ClipControl;
|
||||
}
|
||||
|
||||
void SetupDirtyMisc(Tables& tables) {
|
||||
auto& table = tables[0];
|
||||
|
||||
@ -248,6 +254,7 @@ void StateTracker::Initialize() {
|
||||
SetupDirtyLogicOp(tables);
|
||||
SetupDirtyFragmentClampColor(tables);
|
||||
SetupDirtyPointSize(tables);
|
||||
SetupDirtyClipControl(tables);
|
||||
SetupDirtyMisc(tables);
|
||||
|
||||
auto& store = dirty.on_write_stores;
|
||||
|
@ -71,6 +71,7 @@ enum : u8 {
|
||||
LogicOp,
|
||||
FragmentClampColor,
|
||||
PointSize,
|
||||
ClipControl,
|
||||
|
||||
Last
|
||||
};
|
||||
@ -167,6 +168,11 @@ public:
|
||||
flags[OpenGL::Dirty::LogicOp] = true;
|
||||
}
|
||||
|
||||
void NotifyClipControl() {
|
||||
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
||||
flags[OpenGL::Dirty::ClipControl] = true;
|
||||
}
|
||||
|
||||
private:
|
||||
Core::System& system;
|
||||
};
|
||||
|
@ -532,11 +532,9 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
|
||||
}
|
||||
// TODO(Rodrigo): Find out if rasterizer discard affects blits
|
||||
// TODO(Rodrigo): Find out if blending affects blits
|
||||
// TODO(Rodrigo): Find out if clip control affects blits
|
||||
glDisable(GL_RASTERIZER_DISCARD);
|
||||
glDisablei(GL_SCISSOR_TEST, 0);
|
||||
glDisablei(GL_BLEND, 0);
|
||||
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, src_framebuffer.handle);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst_framebuffer.handle);
|
||||
|
@ -590,6 +590,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
|
||||
state_tracker.NotifyRasterizeEnable();
|
||||
state_tracker.NotifyFramebufferSRGB();
|
||||
state_tracker.NotifyLogicOp();
|
||||
state_tracker.NotifyClipControl();
|
||||
|
||||
program_manager.UseVertexShader(vertex_program.handle);
|
||||
program_manager.UseGeometryShader(0);
|
||||
|
Loading…
Reference in New Issue
Block a user