2019-12-29 01:45:56 +01:00
|
|
|
// Copyright 2019 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-12-29 05:05:02 +01:00
|
|
|
#include <limits>
|
|
|
|
|
2019-12-29 01:45:56 +01:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "video_core/dirty_flags.h"
|
|
|
|
#include "video_core/engines/maxwell_3d.h"
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace OpenGL {
|
|
|
|
|
|
|
|
namespace Dirty {
|
2019-12-29 02:31:00 +01:00
|
|
|
|
2019-12-29 01:45:56 +01:00
|
|
|
enum : u8 {
|
|
|
|
First = VideoCommon::Dirty::LastCommonEntry,
|
|
|
|
|
|
|
|
VertexFormats,
|
2019-12-29 03:08:40 +01:00
|
|
|
VertexFormat0,
|
|
|
|
VertexFormat31 = VertexFormat0 + 31,
|
2019-12-29 02:31:00 +01:00
|
|
|
|
2019-12-29 01:45:56 +01:00
|
|
|
VertexBuffers,
|
2019-12-29 02:31:00 +01:00
|
|
|
VertexBuffer0,
|
|
|
|
VertexBuffer31 = VertexBuffer0 + 31,
|
|
|
|
|
2019-12-29 01:45:56 +01:00
|
|
|
VertexInstances,
|
2019-12-29 02:31:00 +01:00
|
|
|
VertexInstance0,
|
|
|
|
VertexInstance31 = VertexInstance0 + 31,
|
|
|
|
|
2019-12-29 02:12:12 +01:00
|
|
|
ViewportTransform,
|
2019-12-29 02:31:00 +01:00
|
|
|
Viewports,
|
|
|
|
Viewport0,
|
|
|
|
Viewport15 = Viewport0 + 15,
|
|
|
|
|
|
|
|
Scissors,
|
|
|
|
Scissor0,
|
|
|
|
Scissor15 = Scissor0 + 15,
|
|
|
|
|
2019-12-29 02:51:04 +01:00
|
|
|
ColorMaskCommon,
|
|
|
|
ColorMasks,
|
|
|
|
ColorMask0,
|
|
|
|
ColorMask7 = ColorMask0 + 7,
|
|
|
|
|
2019-12-29 22:14:40 +01:00
|
|
|
BlendColor,
|
|
|
|
BlendIndependentEnabled,
|
|
|
|
BlendStates,
|
|
|
|
BlendState0,
|
|
|
|
BlendState7 = BlendState0 + 7,
|
|
|
|
|
2019-12-29 02:31:00 +01:00
|
|
|
Shaders,
|
2019-12-29 06:03:05 +01:00
|
|
|
ClipDistances,
|
2019-12-29 22:14:40 +01:00
|
|
|
|
2019-12-30 03:25:53 +01:00
|
|
|
ColorMask,
|
2019-12-29 01:45:56 +01:00
|
|
|
FrontFace,
|
2019-12-29 23:23:40 +01:00
|
|
|
CullTest,
|
2019-12-30 02:56:21 +01:00
|
|
|
DepthMask,
|
2019-12-29 01:45:56 +01:00
|
|
|
DepthTest,
|
|
|
|
StencilTest,
|
2019-12-30 04:37:35 +01:00
|
|
|
AlphaTest,
|
2019-12-30 03:25:53 +01:00
|
|
|
PrimitiveRestart,
|
2019-12-29 01:45:56 +01:00
|
|
|
PolygonOffset,
|
2019-12-30 04:43:15 +01:00
|
|
|
MultisampleControl,
|
2019-12-30 04:49:19 +01:00
|
|
|
RasterizeEnable,
|
2019-12-30 04:53:53 +01:00
|
|
|
FramebufferSRGB,
|
2019-12-30 04:57:50 +01:00
|
|
|
LogicOp,
|
2019-12-29 01:45:56 +01:00
|
|
|
|
2019-12-29 02:31:00 +01:00
|
|
|
Last
|
2019-12-29 01:45:56 +01:00
|
|
|
};
|
2019-12-29 05:05:02 +01:00
|
|
|
static_assert(Last <= std::numeric_limits<u8>::max());
|
2019-12-29 02:31:00 +01:00
|
|
|
|
|
|
|
} // namespace Dirty
|
2019-12-29 01:45:56 +01:00
|
|
|
|
|
|
|
class StateTracker {
|
|
|
|
public:
|
|
|
|
explicit StateTracker(Core::System& system);
|
|
|
|
|
|
|
|
void Initialize();
|
|
|
|
|
2019-12-29 03:08:40 +01:00
|
|
|
void NotifyScreenDrawVertexArray() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::VertexFormats] = true;
|
|
|
|
flags[OpenGL::Dirty::VertexFormat0 + 0] = true;
|
|
|
|
flags[OpenGL::Dirty::VertexFormat0 + 1] = true;
|
|
|
|
|
|
|
|
flags[OpenGL::Dirty::VertexBuffers] = true;
|
|
|
|
flags[OpenGL::Dirty::VertexBuffer0] = true;
|
2019-12-29 05:28:53 +01:00
|
|
|
|
|
|
|
flags[OpenGL::Dirty::VertexInstances] = true;
|
|
|
|
flags[OpenGL::Dirty::VertexInstance0 + 0] = true;
|
|
|
|
flags[OpenGL::Dirty::VertexInstance0 + 1] = true;
|
2019-12-29 03:08:40 +01:00
|
|
|
}
|
|
|
|
|
2019-12-29 02:12:12 +01:00
|
|
|
void NotifyViewport0() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::Viewports] = true;
|
|
|
|
flags[OpenGL::Dirty::Viewport0] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-29 02:31:00 +01:00
|
|
|
void NotifyScissor0() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::Scissors] = true;
|
|
|
|
flags[OpenGL::Dirty::Scissor0] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-29 02:51:04 +01:00
|
|
|
void NotifyColorMask0() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::ColorMasks] = true;
|
|
|
|
flags[OpenGL::Dirty::ColorMask0] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-29 22:14:40 +01:00
|
|
|
void NotifyBlend0() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::BlendStates] = true;
|
|
|
|
flags[OpenGL::Dirty::BlendState0] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-29 01:45:56 +01:00
|
|
|
void NotifyFramebuffer() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[VideoCommon::Dirty::RenderTargets] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-29 23:23:40 +01:00
|
|
|
void NotifyFrontFace() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::FrontFace] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyCullTest() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::CullTest] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-30 02:56:21 +01:00
|
|
|
void NotifyDepthTest() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::DepthTest] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-30 03:08:32 +01:00
|
|
|
void NotifyStencilTest() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::StencilTest] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-30 04:22:43 +01:00
|
|
|
void NotifyPolygonOffset() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::PolygonOffset] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-30 04:49:19 +01:00
|
|
|
void NotifyRasterizeEnable() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::RasterizeEnable] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-30 04:53:53 +01:00
|
|
|
void NotifyFramebufferSRGB() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::FramebufferSRGB] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-30 04:57:50 +01:00
|
|
|
void NotifyLogicOp() {
|
|
|
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
|
|
|
flags[OpenGL::Dirty::LogicOp] = true;
|
|
|
|
}
|
|
|
|
|
2019-12-29 01:45:56 +01:00
|
|
|
private:
|
|
|
|
Core::System& system;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace OpenGL
|