summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-12-28 21:41:41 -0300
committerGravatar ReinUsesLisp2020-02-28 17:56:41 -0300
commit9e74e6988b881c6889074bd2335239eb2e491e91 (patch)
tree8e6ab83abf58154f89f9b05f06ceb7b2cecd0764 /src/video_core
parentvideo_core: Reintroduce dirty flags infrastructure (diff)
downloadyuzu-9e74e6988b881c6889074bd2335239eb2e491e91.tar.gz
yuzu-9e74e6988b881c6889074bd2335239eb2e491e91.tar.xz
yuzu-9e74e6988b881c6889074bd2335239eb2e491e91.zip
maxwell_3d: Flatten cull and front face registers
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp6
-rw-r--r--src/video_core/engines/maxwell_3d.h30
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp6
-rw-r--r--src/video_core/renderer_opengl/maxwell_to_gl.h14
-rw-r--r--src/video_core/renderer_vulkan/fixed_pipeline_state.cpp15
-rw-r--r--src/video_core/renderer_vulkan/fixed_pipeline_state.h8
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.cpp14
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.h4
8 files changed, 47 insertions, 50 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index db710bf35..89050361e 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -76,8 +76,8 @@ void Maxwell3D::InitializeRegisterDefaults() {
76 regs.stencil_back_mask = 0xFFFFFFFF; 76 regs.stencil_back_mask = 0xFFFFFFFF;
77 77
78 regs.depth_test_func = Regs::ComparisonOp::Always; 78 regs.depth_test_func = Regs::ComparisonOp::Always;
79 regs.cull.front_face = Regs::Cull::FrontFace::CounterClockWise; 79 regs.front_face = Regs::FrontFace::CounterClockWise;
80 regs.cull.cull_face = Regs::Cull::CullFace::Back; 80 regs.cull_face = Regs::CullFace::Back;
81 81
82 // TODO(Rodrigo): Most games do not set a point size. I think this is a case of a 82 // TODO(Rodrigo): Most games do not set a point size. I think this is a case of a
83 // register carrying a default value. Assume it's OpenGL's default (1). 83 // register carrying a default value. Assume it's OpenGL's default (1).
@@ -96,7 +96,7 @@ void Maxwell3D::InitializeRegisterDefaults() {
96 regs.rasterize_enable = 1; 96 regs.rasterize_enable = 1;
97 regs.rt_separate_frag_data = 1; 97 regs.rt_separate_frag_data = 1;
98 regs.framebuffer_srgb = 1; 98 regs.framebuffer_srgb = 1;
99 regs.cull.front_face = Maxwell3D::Regs::Cull::FrontFace::ClockWise; 99 regs.front_face = Maxwell3D::Regs::FrontFace::ClockWise;
100 100
101 mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_end_gl)] = true; 101 mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_end_gl)] = true;
102 mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)] = true; 102 mme_inline[MAXWELL3D_REG_INDEX(draw.vertex_begin_gl)] = true;
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 72848b1e8..8edfa6a34 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -432,21 +432,15 @@ public:
432 GeneratedPrimitives = 0x1F, 432 GeneratedPrimitives = 0x1F,
433 }; 433 };
434 434
435 struct Cull { 435 enum class FrontFace : u32 {
436 enum class FrontFace : u32 { 436 ClockWise = 0x0900,
437 ClockWise = 0x0900, 437 CounterClockWise = 0x0901,
438 CounterClockWise = 0x0901, 438 };
439 };
440
441 enum class CullFace : u32 {
442 Front = 0x0404,
443 Back = 0x0405,
444 FrontAndBack = 0x0408,
445 };
446 439
447 u32 enabled; 440 enum class CullFace : u32 {
448 FrontFace front_face; 441 Front = 0x0404,
449 CullFace cull_face; 442 Back = 0x0405,
443 FrontAndBack = 0x0408,
450 }; 444 };
451 445
452 struct Blend { 446 struct Blend {
@@ -1052,7 +1046,9 @@ public:
1052 1046
1053 INSERT_UNION_PADDING_WORDS(1); 1047 INSERT_UNION_PADDING_WORDS(1);
1054 1048
1055 Cull cull; 1049 u32 cull_test_enabled;
1050 FrontFace front_face;
1051 CullFace cull_face;
1056 1052
1057 u32 pixel_center_integer; 1053 u32 pixel_center_integer;
1058 1054
@@ -1491,7 +1487,9 @@ ASSERT_REG_POSITION(index_array, 0x5F2);
1491ASSERT_REG_POSITION(polygon_offset_clamp, 0x61F); 1487ASSERT_REG_POSITION(polygon_offset_clamp, 0x61F);
1492ASSERT_REG_POSITION(instanced_arrays, 0x620); 1488ASSERT_REG_POSITION(instanced_arrays, 0x620);
1493ASSERT_REG_POSITION(vp_point_size, 0x644); 1489ASSERT_REG_POSITION(vp_point_size, 0x644);
1494ASSERT_REG_POSITION(cull, 0x646); 1490ASSERT_REG_POSITION(cull_test_enabled, 0x646);
1491ASSERT_REG_POSITION(front_face, 0x647);
1492ASSERT_REG_POSITION(cull_face, 0x648);
1495ASSERT_REG_POSITION(pixel_center_integer, 0x649); 1493ASSERT_REG_POSITION(pixel_center_integer, 0x649);
1496ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B); 1494ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B);
1497ASSERT_REG_POSITION(view_volume_clip_control, 0x64F); 1495ASSERT_REG_POSITION(view_volume_clip_control, 0x64F);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 3ce2a7124..2fb8ec33b 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -945,10 +945,10 @@ void RasterizerOpenGL::SyncClipCoef() {
945void RasterizerOpenGL::SyncCullMode() { 945void RasterizerOpenGL::SyncCullMode() {
946 const auto& regs = system.GPU().Maxwell3D().regs; 946 const auto& regs = system.GPU().Maxwell3D().regs;
947 947
948 oglEnable(GL_CULL_FACE, regs.cull.enabled); 948 oglEnable(GL_CULL_FACE, regs.cull_test_enabled);
949 glCullFace(MaxwellToGL::CullFace(regs.cull.cull_face)); 949 glCullFace(MaxwellToGL::CullFace(regs.cull_face));
950 950
951 glFrontFace(MaxwellToGL::FrontFace(regs.cull.front_face)); 951 glFrontFace(MaxwellToGL::FrontFace(regs.front_face));
952} 952}
953 953
954void RasterizerOpenGL::SyncPrimitiveRestart() { 954void RasterizerOpenGL::SyncPrimitiveRestart() {
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h
index 7ed505628..4c8db7cc8 100644
--- a/src/video_core/renderer_opengl/maxwell_to_gl.h
+++ b/src/video_core/renderer_opengl/maxwell_to_gl.h
@@ -401,24 +401,24 @@ inline GLenum StencilOp(Maxwell::StencilOp stencil) {
401 return GL_KEEP; 401 return GL_KEEP;
402} 402}
403 403
404inline GLenum FrontFace(Maxwell::Cull::FrontFace front_face) { 404inline GLenum FrontFace(Maxwell::FrontFace front_face) {
405 switch (front_face) { 405 switch (front_face) {
406 case Maxwell::Cull::FrontFace::ClockWise: 406 case Maxwell::FrontFace::ClockWise:
407 return GL_CW; 407 return GL_CW;
408 case Maxwell::Cull::FrontFace::CounterClockWise: 408 case Maxwell::FrontFace::CounterClockWise:
409 return GL_CCW; 409 return GL_CCW;
410 } 410 }
411 LOG_ERROR(Render_OpenGL, "Unimplemented front face cull={}", static_cast<u32>(front_face)); 411 LOG_ERROR(Render_OpenGL, "Unimplemented front face cull={}", static_cast<u32>(front_face));
412 return GL_CCW; 412 return GL_CCW;
413} 413}
414 414
415inline GLenum CullFace(Maxwell::Cull::CullFace cull_face) { 415inline GLenum CullFace(Maxwell::CullFace cull_face) {
416 switch (cull_face) { 416 switch (cull_face) {
417 case Maxwell::Cull::CullFace::Front: 417 case Maxwell::CullFace::Front:
418 return GL_FRONT; 418 return GL_FRONT;
419 case Maxwell::Cull::CullFace::Back: 419 case Maxwell::CullFace::Back:
420 return GL_BACK; 420 return GL_BACK;
421 case Maxwell::Cull::CullFace::FrontAndBack: 421 case Maxwell::CullFace::FrontAndBack:
422 return GL_FRONT_AND_BACK; 422 return GL_FRONT_AND_BACK;
423 } 423 }
424 LOG_ERROR(Render_OpenGL, "Unimplemented cull face={}", static_cast<u32>(cull_face)); 424 LOG_ERROR(Render_OpenGL, "Unimplemented cull face={}", static_cast<u32>(cull_face));
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
index 4e3ff231e..2bb376555 100644
--- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
+++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
@@ -112,19 +112,18 @@ constexpr FixedPipelineState::Rasterizer GetRasterizerState(const Maxwell& regs)
112 const auto& clip = regs.view_volume_clip_control; 112 const auto& clip = regs.view_volume_clip_control;
113 const bool depth_clamp_enabled = clip.depth_clamp_near == 1 || clip.depth_clamp_far == 1; 113 const bool depth_clamp_enabled = clip.depth_clamp_near == 1 || clip.depth_clamp_far == 1;
114 114
115 Maxwell::Cull::FrontFace front_face = regs.cull.front_face; 115 Maxwell::FrontFace front_face = regs.front_face;
116 if (regs.screen_y_control.triangle_rast_flip != 0 && 116 if (regs.screen_y_control.triangle_rast_flip != 0 &&
117 regs.viewport_transform[0].scale_y > 0.0f) { 117 regs.viewport_transform[0].scale_y > 0.0f) {
118 if (front_face == Maxwell::Cull::FrontFace::CounterClockWise) 118 if (front_face == Maxwell::FrontFace::CounterClockWise)
119 front_face = Maxwell::Cull::FrontFace::ClockWise; 119 front_face = Maxwell::FrontFace::ClockWise;
120 else if (front_face == Maxwell::Cull::FrontFace::ClockWise) 120 else if (front_face == Maxwell::FrontFace::ClockWise)
121 front_face = Maxwell::Cull::FrontFace::CounterClockWise; 121 front_face = Maxwell::FrontFace::CounterClockWise;
122 } 122 }
123 123
124 const bool gl_ndc = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne; 124 const bool gl_ndc = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne;
125 return FixedPipelineState::Rasterizer(regs.cull.enabled, depth_bias_enabled, 125 return FixedPipelineState::Rasterizer(regs.cull_test_enabled, depth_bias_enabled,
126 depth_clamp_enabled, gl_ndc, regs.cull.cull_face, 126 depth_clamp_enabled, gl_ndc, regs.cull_face, front_face);
127 front_face);
128} 127}
129 128
130} // Anonymous namespace 129} // Anonymous namespace
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h
index 87056ef37..4c8ba7f90 100644
--- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h
+++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h
@@ -171,8 +171,8 @@ struct FixedPipelineState {
171 171
172 struct Rasterizer { 172 struct Rasterizer {
173 constexpr Rasterizer(bool cull_enable, bool depth_bias_enable, bool depth_clamp_enable, 173 constexpr Rasterizer(bool cull_enable, bool depth_bias_enable, bool depth_clamp_enable,
174 bool ndc_minus_one_to_one, Maxwell::Cull::CullFace cull_face, 174 bool ndc_minus_one_to_one, Maxwell::CullFace cull_face,
175 Maxwell::Cull::FrontFace front_face) 175 Maxwell::FrontFace front_face)
176 : cull_enable{cull_enable}, depth_bias_enable{depth_bias_enable}, 176 : cull_enable{cull_enable}, depth_bias_enable{depth_bias_enable},
177 depth_clamp_enable{depth_clamp_enable}, ndc_minus_one_to_one{ndc_minus_one_to_one}, 177 depth_clamp_enable{depth_clamp_enable}, ndc_minus_one_to_one{ndc_minus_one_to_one},
178 cull_face{cull_face}, front_face{front_face} {} 178 cull_face{cull_face}, front_face{front_face} {}
@@ -182,8 +182,8 @@ struct FixedPipelineState {
182 bool depth_bias_enable; 182 bool depth_bias_enable;
183 bool depth_clamp_enable; 183 bool depth_clamp_enable;
184 bool ndc_minus_one_to_one; 184 bool ndc_minus_one_to_one;
185 Maxwell::Cull::CullFace cull_face; 185 Maxwell::CullFace cull_face;
186 Maxwell::Cull::FrontFace front_face; 186 Maxwell::FrontFace front_face;
187 187
188 std::size_t Hash() const noexcept; 188 std::size_t Hash() const noexcept;
189 189
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
index ef66dd141..088b072ef 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
@@ -572,24 +572,24 @@ vk::BlendFactor BlendFactor(Maxwell::Blend::Factor factor) {
572 return {}; 572 return {};
573} 573}
574 574
575vk::FrontFace FrontFace(Maxwell::Cull::FrontFace front_face) { 575vk::FrontFace FrontFace(Maxwell::FrontFace front_face) {
576 switch (front_face) { 576 switch (front_face) {
577 case Maxwell::Cull::FrontFace::ClockWise: 577 case Maxwell::FrontFace::ClockWise:
578 return vk::FrontFace::eClockwise; 578 return vk::FrontFace::eClockwise;
579 case Maxwell::Cull::FrontFace::CounterClockWise: 579 case Maxwell::FrontFace::CounterClockWise:
580 return vk::FrontFace::eCounterClockwise; 580 return vk::FrontFace::eCounterClockwise;
581 } 581 }
582 UNIMPLEMENTED_MSG("Unimplemented front face={}", static_cast<u32>(front_face)); 582 UNIMPLEMENTED_MSG("Unimplemented front face={}", static_cast<u32>(front_face));
583 return {}; 583 return {};
584} 584}
585 585
586vk::CullModeFlags CullFace(Maxwell::Cull::CullFace cull_face) { 586vk::CullModeFlags CullFace(Maxwell::CullFace cull_face) {
587 switch (cull_face) { 587 switch (cull_face) {
588 case Maxwell::Cull::CullFace::Front: 588 case Maxwell::CullFace::Front:
589 return vk::CullModeFlagBits::eFront; 589 return vk::CullModeFlagBits::eFront;
590 case Maxwell::Cull::CullFace::Back: 590 case Maxwell::CullFace::Back:
591 return vk::CullModeFlagBits::eBack; 591 return vk::CullModeFlagBits::eBack;
592 case Maxwell::Cull::CullFace::FrontAndBack: 592 case Maxwell::CullFace::FrontAndBack:
593 return vk::CullModeFlagBits::eFrontAndBack; 593 return vk::CullModeFlagBits::eFrontAndBack;
594 } 594 }
595 UNIMPLEMENTED_MSG("Unimplemented cull face={}", static_cast<u32>(cull_face)); 595 UNIMPLEMENTED_MSG("Unimplemented cull face={}", static_cast<u32>(cull_face));
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.h b/src/video_core/renderer_vulkan/maxwell_to_vk.h
index 7e9678b7b..24f6ab544 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.h
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.h
@@ -54,9 +54,9 @@ vk::BlendOp BlendEquation(Maxwell::Blend::Equation equation);
54 54
55vk::BlendFactor BlendFactor(Maxwell::Blend::Factor factor); 55vk::BlendFactor BlendFactor(Maxwell::Blend::Factor factor);
56 56
57vk::FrontFace FrontFace(Maxwell::Cull::FrontFace front_face); 57vk::FrontFace FrontFace(Maxwell::FrontFace front_face);
58 58
59vk::CullModeFlags CullFace(Maxwell::Cull::CullFace cull_face); 59vk::CullModeFlags CullFace(Maxwell::CullFace cull_face);
60 60
61vk::ComponentSwizzle SwizzleSource(Tegra::Texture::SwizzleSource swizzle); 61vk::ComponentSwizzle SwizzleSource(Tegra::Texture::SwizzleSource swizzle);
62 62