1
0
Fork 0
forked from suyu/suyu

gl_state: Remove color mask tracking

This commit is contained in:
ReinUsesLisp 2019-12-26 01:19:15 -03:00
parent 2392b548be
commit 0914c70b7f
4 changed files with 12 additions and 40 deletions

View file

@ -411,12 +411,10 @@ void RasterizerOpenGL::Clear() {
use_color = true;
}
if (use_color) {
clear_state.color_mask[0].red_enabled = regs.clear_buffers.R ? GL_TRUE : GL_FALSE;
clear_state.color_mask[0].green_enabled = regs.clear_buffers.G ? GL_TRUE : GL_FALSE;
clear_state.color_mask[0].blue_enabled = regs.clear_buffers.B ? GL_TRUE : GL_FALSE;
clear_state.color_mask[0].alpha_enabled = regs.clear_buffers.A ? GL_TRUE : GL_FALSE;
// TODO: Signal state tracker about these changes
glColorMaski(0, regs.clear_buffers.R, regs.clear_buffers.G, regs.clear_buffers.B,
regs.clear_buffers.A);
SyncFramebufferSRGB();
// TODO(Rodrigo): Determine if clamping is used on clears
SyncFragmentColorClampState();
@ -1071,15 +1069,14 @@ void RasterizerOpenGL::SyncColorMask() {
auto& maxwell3d = system.GPU().Maxwell3D();
const auto& regs = maxwell3d.regs;
const std::size_t count =
regs.independent_blend_enable ? Tegra::Engines::Maxwell3D::Regs::NumRenderTargets : 1;
for (std::size_t i = 0; i < count; i++) {
const auto& source = regs.color_mask[regs.color_mask_common ? 0 : i];
auto& dest = state.color_mask[i];
dest.red_enabled = (source.R == 0) ? GL_FALSE : GL_TRUE;
dest.green_enabled = (source.G == 0) ? GL_FALSE : GL_TRUE;
dest.blue_enabled = (source.B == 0) ? GL_FALSE : GL_TRUE;
dest.alpha_enabled = (source.A == 0) ? GL_FALSE : GL_TRUE;
if (regs.color_mask_common) {
auto& mask = regs.color_mask[0];
glColorMask(mask.R, mask.B, mask.G, mask.A);
} else {
for (std::size_t i = 0; i < Maxwell::NumRenderTargets; ++i) {
const auto& mask = regs.color_mask[regs.color_mask_common ? 0 : i];
glColorMaski(static_cast<GLuint>(i), mask.R, mask.G, mask.B, mask.A);
}
}
}

View file

@ -121,21 +121,6 @@ void OpenGLState::ApplyRasterizerDiscard() {
Enable(GL_RASTERIZER_DISCARD, cur_state.rasterizer_discard, rasterizer_discard);
}
void OpenGLState::ApplyColorMask() {
for (std::size_t i = 0; i < Maxwell::NumRenderTargets; ++i) {
const auto& updated = color_mask[i];
auto& current = cur_state.color_mask[i];
if (updated.red_enabled != current.red_enabled ||
updated.green_enabled != current.green_enabled ||
updated.blue_enabled != current.blue_enabled ||
updated.alpha_enabled != current.alpha_enabled) {
current = updated;
glColorMaski(static_cast<GLuint>(i), updated.red_enabled, updated.green_enabled,
updated.blue_enabled, updated.alpha_enabled);
}
}
}
void OpenGLState::ApplyStencilTest() {
Enable(GL_STENCIL_TEST, cur_state.stencil.test_enabled, stencil.test_enabled);
@ -311,7 +296,6 @@ void OpenGLState::Apply() {
ApplyProgramPipeline();
ApplyClipDistances();
ApplyRasterizerDiscard();
ApplyColorMask();
ApplyViewport();
ApplyStencilTest();
ApplyBlending();

View file

@ -15,15 +15,6 @@ class OpenGLState {
public:
bool rasterizer_discard = false; // GL_RASTERIZER_DISCARD
struct ColorMask {
GLboolean red_enabled = GL_TRUE;
GLboolean green_enabled = GL_TRUE;
GLboolean blue_enabled = GL_TRUE;
GLboolean alpha_enabled = GL_TRUE;
};
std::array<ColorMask, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets>
color_mask; // GL_COLOR_WRITEMASK
struct {
bool test_enabled = false; // GL_STENCIL_TEST
struct {
@ -107,7 +98,6 @@ public:
void ApplyProgramPipeline();
void ApplyClipDistances();
void ApplyRasterizerDiscard();
void ApplyColorMask();
void ApplyStencilTest();
void ApplyViewport();
void ApplyTargetBlending(std::size_t target, bool force);

View file

@ -570,6 +570,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
glDisable(GL_POLYGON_OFFSET_FILL);
glCullFace(GL_BACK);
glFrontFace(GL_CW);
glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glVertexAttribFormat(PositionLocation, 2, GL_FLOAT, GL_FALSE,
offsetof(ScreenRectVertex, position));