mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-29 14:57:41 -05:00
maxwell_3d: Flatten cull and front face registers
This commit is contained in:
parent
eed789d0d1
commit
9e74e6988b
8 changed files with 47 additions and 50 deletions
|
@ -76,8 +76,8 @@ void Maxwell3D::InitializeRegisterDefaults() {
|
||||||
regs.stencil_back_mask = 0xFFFFFFFF;
|
regs.stencil_back_mask = 0xFFFFFFFF;
|
||||||
|
|
||||||
regs.depth_test_func = Regs::ComparisonOp::Always;
|
regs.depth_test_func = Regs::ComparisonOp::Always;
|
||||||
regs.cull.front_face = Regs::Cull::FrontFace::CounterClockWise;
|
regs.front_face = Regs::FrontFace::CounterClockWise;
|
||||||
regs.cull.cull_face = Regs::Cull::CullFace::Back;
|
regs.cull_face = Regs::CullFace::Back;
|
||||||
|
|
||||||
// TODO(Rodrigo): Most games do not set a point size. I think this is a case of a
|
// TODO(Rodrigo): Most games do not set a point size. I think this is a case of a
|
||||||
// register carrying a default value. Assume it's OpenGL's default (1).
|
// register carrying a default value. Assume it's OpenGL's default (1).
|
||||||
|
@ -96,7 +96,7 @@ void Maxwell3D::InitializeRegisterDefaults() {
|
||||||
regs.rasterize_enable = 1;
|
regs.rasterize_enable = 1;
|
||||||
regs.rt_separate_frag_data = 1;
|
regs.rt_separate_frag_data = 1;
|
||||||
regs.framebuffer_srgb = 1;
|
regs.framebuffer_srgb = 1;
|
||||||
regs.cull.front_face = Maxwell3D::Regs::Cull::FrontFace::ClockWise;
|
regs.front_face = Maxwell3D::Regs::FrontFace::ClockWise;
|
||||||
|
|
||||||
mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_end_gl)] = true;
|
mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_end_gl)] = true;
|
||||||
mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)] = true;
|
mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)] = true;
|
||||||
|
|
|
@ -432,7 +432,6 @@ public:
|
||||||
GeneratedPrimitives = 0x1F,
|
GeneratedPrimitives = 0x1F,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Cull {
|
|
||||||
enum class FrontFace : u32 {
|
enum class FrontFace : u32 {
|
||||||
ClockWise = 0x0900,
|
ClockWise = 0x0900,
|
||||||
CounterClockWise = 0x0901,
|
CounterClockWise = 0x0901,
|
||||||
|
@ -444,11 +443,6 @@ public:
|
||||||
FrontAndBack = 0x0408,
|
FrontAndBack = 0x0408,
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 enabled;
|
|
||||||
FrontFace front_face;
|
|
||||||
CullFace cull_face;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Blend {
|
struct Blend {
|
||||||
enum class Equation : u32 {
|
enum class Equation : u32 {
|
||||||
Add = 1,
|
Add = 1,
|
||||||
|
@ -1052,7 +1046,9 @@ public:
|
||||||
|
|
||||||
INSERT_UNION_PADDING_WORDS(1);
|
INSERT_UNION_PADDING_WORDS(1);
|
||||||
|
|
||||||
Cull cull;
|
u32 cull_test_enabled;
|
||||||
|
FrontFace front_face;
|
||||||
|
CullFace cull_face;
|
||||||
|
|
||||||
u32 pixel_center_integer;
|
u32 pixel_center_integer;
|
||||||
|
|
||||||
|
@ -1491,7 +1487,9 @@ ASSERT_REG_POSITION(index_array, 0x5F2);
|
||||||
ASSERT_REG_POSITION(polygon_offset_clamp, 0x61F);
|
ASSERT_REG_POSITION(polygon_offset_clamp, 0x61F);
|
||||||
ASSERT_REG_POSITION(instanced_arrays, 0x620);
|
ASSERT_REG_POSITION(instanced_arrays, 0x620);
|
||||||
ASSERT_REG_POSITION(vp_point_size, 0x644);
|
ASSERT_REG_POSITION(vp_point_size, 0x644);
|
||||||
ASSERT_REG_POSITION(cull, 0x646);
|
ASSERT_REG_POSITION(cull_test_enabled, 0x646);
|
||||||
|
ASSERT_REG_POSITION(front_face, 0x647);
|
||||||
|
ASSERT_REG_POSITION(cull_face, 0x648);
|
||||||
ASSERT_REG_POSITION(pixel_center_integer, 0x649);
|
ASSERT_REG_POSITION(pixel_center_integer, 0x649);
|
||||||
ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B);
|
ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B);
|
||||||
ASSERT_REG_POSITION(view_volume_clip_control, 0x64F);
|
ASSERT_REG_POSITION(view_volume_clip_control, 0x64F);
|
||||||
|
|
|
@ -945,10 +945,10 @@ void RasterizerOpenGL::SyncClipCoef() {
|
||||||
void RasterizerOpenGL::SyncCullMode() {
|
void RasterizerOpenGL::SyncCullMode() {
|
||||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
const auto& regs = system.GPU().Maxwell3D().regs;
|
||||||
|
|
||||||
oglEnable(GL_CULL_FACE, regs.cull.enabled);
|
oglEnable(GL_CULL_FACE, regs.cull_test_enabled);
|
||||||
glCullFace(MaxwellToGL::CullFace(regs.cull.cull_face));
|
glCullFace(MaxwellToGL::CullFace(regs.cull_face));
|
||||||
|
|
||||||
glFrontFace(MaxwellToGL::FrontFace(regs.cull.front_face));
|
glFrontFace(MaxwellToGL::FrontFace(regs.front_face));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncPrimitiveRestart() {
|
void RasterizerOpenGL::SyncPrimitiveRestart() {
|
||||||
|
|
|
@ -401,24 +401,24 @@ inline GLenum StencilOp(Maxwell::StencilOp stencil) {
|
||||||
return GL_KEEP;
|
return GL_KEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline GLenum FrontFace(Maxwell::Cull::FrontFace front_face) {
|
inline GLenum FrontFace(Maxwell::FrontFace front_face) {
|
||||||
switch (front_face) {
|
switch (front_face) {
|
||||||
case Maxwell::Cull::FrontFace::ClockWise:
|
case Maxwell::FrontFace::ClockWise:
|
||||||
return GL_CW;
|
return GL_CW;
|
||||||
case Maxwell::Cull::FrontFace::CounterClockWise:
|
case Maxwell::FrontFace::CounterClockWise:
|
||||||
return GL_CCW;
|
return GL_CCW;
|
||||||
}
|
}
|
||||||
LOG_ERROR(Render_OpenGL, "Unimplemented front face cull={}", static_cast<u32>(front_face));
|
LOG_ERROR(Render_OpenGL, "Unimplemented front face cull={}", static_cast<u32>(front_face));
|
||||||
return GL_CCW;
|
return GL_CCW;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline GLenum CullFace(Maxwell::Cull::CullFace cull_face) {
|
inline GLenum CullFace(Maxwell::CullFace cull_face) {
|
||||||
switch (cull_face) {
|
switch (cull_face) {
|
||||||
case Maxwell::Cull::CullFace::Front:
|
case Maxwell::CullFace::Front:
|
||||||
return GL_FRONT;
|
return GL_FRONT;
|
||||||
case Maxwell::Cull::CullFace::Back:
|
case Maxwell::CullFace::Back:
|
||||||
return GL_BACK;
|
return GL_BACK;
|
||||||
case Maxwell::Cull::CullFace::FrontAndBack:
|
case Maxwell::CullFace::FrontAndBack:
|
||||||
return GL_FRONT_AND_BACK;
|
return GL_FRONT_AND_BACK;
|
||||||
}
|
}
|
||||||
LOG_ERROR(Render_OpenGL, "Unimplemented cull face={}", static_cast<u32>(cull_face));
|
LOG_ERROR(Render_OpenGL, "Unimplemented cull face={}", static_cast<u32>(cull_face));
|
||||||
|
|
|
@ -112,19 +112,18 @@ constexpr FixedPipelineState::Rasterizer GetRasterizerState(const Maxwell& regs)
|
||||||
const auto& clip = regs.view_volume_clip_control;
|
const auto& clip = regs.view_volume_clip_control;
|
||||||
const bool depth_clamp_enabled = clip.depth_clamp_near == 1 || clip.depth_clamp_far == 1;
|
const bool depth_clamp_enabled = clip.depth_clamp_near == 1 || clip.depth_clamp_far == 1;
|
||||||
|
|
||||||
Maxwell::Cull::FrontFace front_face = regs.cull.front_face;
|
Maxwell::FrontFace front_face = regs.front_face;
|
||||||
if (regs.screen_y_control.triangle_rast_flip != 0 &&
|
if (regs.screen_y_control.triangle_rast_flip != 0 &&
|
||||||
regs.viewport_transform[0].scale_y > 0.0f) {
|
regs.viewport_transform[0].scale_y > 0.0f) {
|
||||||
if (front_face == Maxwell::Cull::FrontFace::CounterClockWise)
|
if (front_face == Maxwell::FrontFace::CounterClockWise)
|
||||||
front_face = Maxwell::Cull::FrontFace::ClockWise;
|
front_face = Maxwell::FrontFace::ClockWise;
|
||||||
else if (front_face == Maxwell::Cull::FrontFace::ClockWise)
|
else if (front_face == Maxwell::FrontFace::ClockWise)
|
||||||
front_face = Maxwell::Cull::FrontFace::CounterClockWise;
|
front_face = Maxwell::FrontFace::CounterClockWise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool gl_ndc = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne;
|
const bool gl_ndc = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne;
|
||||||
return FixedPipelineState::Rasterizer(regs.cull.enabled, depth_bias_enabled,
|
return FixedPipelineState::Rasterizer(regs.cull_test_enabled, depth_bias_enabled,
|
||||||
depth_clamp_enabled, gl_ndc, regs.cull.cull_face,
|
depth_clamp_enabled, gl_ndc, regs.cull_face, front_face);
|
||||||
front_face);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
|
@ -171,8 +171,8 @@ struct FixedPipelineState {
|
||||||
|
|
||||||
struct Rasterizer {
|
struct Rasterizer {
|
||||||
constexpr Rasterizer(bool cull_enable, bool depth_bias_enable, bool depth_clamp_enable,
|
constexpr Rasterizer(bool cull_enable, bool depth_bias_enable, bool depth_clamp_enable,
|
||||||
bool ndc_minus_one_to_one, Maxwell::Cull::CullFace cull_face,
|
bool ndc_minus_one_to_one, Maxwell::CullFace cull_face,
|
||||||
Maxwell::Cull::FrontFace front_face)
|
Maxwell::FrontFace front_face)
|
||||||
: cull_enable{cull_enable}, depth_bias_enable{depth_bias_enable},
|
: cull_enable{cull_enable}, depth_bias_enable{depth_bias_enable},
|
||||||
depth_clamp_enable{depth_clamp_enable}, ndc_minus_one_to_one{ndc_minus_one_to_one},
|
depth_clamp_enable{depth_clamp_enable}, ndc_minus_one_to_one{ndc_minus_one_to_one},
|
||||||
cull_face{cull_face}, front_face{front_face} {}
|
cull_face{cull_face}, front_face{front_face} {}
|
||||||
|
@ -182,8 +182,8 @@ struct FixedPipelineState {
|
||||||
bool depth_bias_enable;
|
bool depth_bias_enable;
|
||||||
bool depth_clamp_enable;
|
bool depth_clamp_enable;
|
||||||
bool ndc_minus_one_to_one;
|
bool ndc_minus_one_to_one;
|
||||||
Maxwell::Cull::CullFace cull_face;
|
Maxwell::CullFace cull_face;
|
||||||
Maxwell::Cull::FrontFace front_face;
|
Maxwell::FrontFace front_face;
|
||||||
|
|
||||||
std::size_t Hash() const noexcept;
|
std::size_t Hash() const noexcept;
|
||||||
|
|
||||||
|
|
|
@ -572,24 +572,24 @@ vk::BlendFactor BlendFactor(Maxwell::Blend::Factor factor) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::FrontFace FrontFace(Maxwell::Cull::FrontFace front_face) {
|
vk::FrontFace FrontFace(Maxwell::FrontFace front_face) {
|
||||||
switch (front_face) {
|
switch (front_face) {
|
||||||
case Maxwell::Cull::FrontFace::ClockWise:
|
case Maxwell::FrontFace::ClockWise:
|
||||||
return vk::FrontFace::eClockwise;
|
return vk::FrontFace::eClockwise;
|
||||||
case Maxwell::Cull::FrontFace::CounterClockWise:
|
case Maxwell::FrontFace::CounterClockWise:
|
||||||
return vk::FrontFace::eCounterClockwise;
|
return vk::FrontFace::eCounterClockwise;
|
||||||
}
|
}
|
||||||
UNIMPLEMENTED_MSG("Unimplemented front face={}", static_cast<u32>(front_face));
|
UNIMPLEMENTED_MSG("Unimplemented front face={}", static_cast<u32>(front_face));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::CullModeFlags CullFace(Maxwell::Cull::CullFace cull_face) {
|
vk::CullModeFlags CullFace(Maxwell::CullFace cull_face) {
|
||||||
switch (cull_face) {
|
switch (cull_face) {
|
||||||
case Maxwell::Cull::CullFace::Front:
|
case Maxwell::CullFace::Front:
|
||||||
return vk::CullModeFlagBits::eFront;
|
return vk::CullModeFlagBits::eFront;
|
||||||
case Maxwell::Cull::CullFace::Back:
|
case Maxwell::CullFace::Back:
|
||||||
return vk::CullModeFlagBits::eBack;
|
return vk::CullModeFlagBits::eBack;
|
||||||
case Maxwell::Cull::CullFace::FrontAndBack:
|
case Maxwell::CullFace::FrontAndBack:
|
||||||
return vk::CullModeFlagBits::eFrontAndBack;
|
return vk::CullModeFlagBits::eFrontAndBack;
|
||||||
}
|
}
|
||||||
UNIMPLEMENTED_MSG("Unimplemented cull face={}", static_cast<u32>(cull_face));
|
UNIMPLEMENTED_MSG("Unimplemented cull face={}", static_cast<u32>(cull_face));
|
||||||
|
|
|
@ -54,9 +54,9 @@ vk::BlendOp BlendEquation(Maxwell::Blend::Equation equation);
|
||||||
|
|
||||||
vk::BlendFactor BlendFactor(Maxwell::Blend::Factor factor);
|
vk::BlendFactor BlendFactor(Maxwell::Blend::Factor factor);
|
||||||
|
|
||||||
vk::FrontFace FrontFace(Maxwell::Cull::FrontFace front_face);
|
vk::FrontFace FrontFace(Maxwell::FrontFace front_face);
|
||||||
|
|
||||||
vk::CullModeFlags CullFace(Maxwell::Cull::CullFace cull_face);
|
vk::CullModeFlags CullFace(Maxwell::CullFace cull_face);
|
||||||
|
|
||||||
vk::ComponentSwizzle SwizzleSource(Tegra::Texture::SwizzleSource swizzle);
|
vk::ComponentSwizzle SwizzleSource(Tegra::Texture::SwizzleSource swizzle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue