diff options
| author | 2017-01-27 20:16:36 -0800 | |
|---|---|---|
| committer | 2017-02-04 13:08:47 -0800 | |
| commit | 000e78144ce87d0be1749f26b9d0494d3c4ddf2f (patch) | |
| tree | ab7180a99b8289dff4b2ee96f7675816e5cc0d2b /src/video_core/rasterizer.cpp | |
| parent | Merge pull request #2476 from yuriks/shader-refactor3 (diff) | |
| download | yuzu-000e78144ce87d0be1749f26b9d0494d3c4ddf2f.tar.gz yuzu-000e78144ce87d0be1749f26b9d0494d3c4ddf2f.tar.xz yuzu-000e78144ce87d0be1749f26b9d0494d3c4ddf2f.zip | |
VideoCore: Split rasterizer regs from Regs struct
Diffstat (limited to 'src/video_core/rasterizer.cpp')
| -rw-r--r-- | src/video_core/rasterizer.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 287d732b5..f82873480 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -327,14 +327,14 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve | |||
| 327 | ScreenToRasterizerCoordinates(v1.screenpos), | 327 | ScreenToRasterizerCoordinates(v1.screenpos), |
| 328 | ScreenToRasterizerCoordinates(v2.screenpos)}; | 328 | ScreenToRasterizerCoordinates(v2.screenpos)}; |
| 329 | 329 | ||
| 330 | if (regs.cull_mode == Regs::CullMode::KeepAll) { | 330 | if (regs.rasterizer.cull_mode == RasterizerRegs::CullMode::KeepAll) { |
| 331 | // Make sure we always end up with a triangle wound counter-clockwise | 331 | // Make sure we always end up with a triangle wound counter-clockwise |
| 332 | if (!reversed && SignedArea(vtxpos[0].xy(), vtxpos[1].xy(), vtxpos[2].xy()) <= 0) { | 332 | if (!reversed && SignedArea(vtxpos[0].xy(), vtxpos[1].xy(), vtxpos[2].xy()) <= 0) { |
| 333 | ProcessTriangleInternal(v0, v2, v1, true); | 333 | ProcessTriangleInternal(v0, v2, v1, true); |
| 334 | return; | 334 | return; |
| 335 | } | 335 | } |
| 336 | } else { | 336 | } else { |
| 337 | if (!reversed && regs.cull_mode == Regs::CullMode::KeepClockWise) { | 337 | if (!reversed && regs.rasterizer.cull_mode == RasterizerRegs::CullMode::KeepClockWise) { |
| 338 | // Reverse vertex order and use the CCW code path. | 338 | // Reverse vertex order and use the CCW code path. |
| 339 | ProcessTriangleInternal(v0, v2, v1, true); | 339 | ProcessTriangleInternal(v0, v2, v1, true); |
| 340 | return; | 340 | return; |
| @@ -351,13 +351,13 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve | |||
| 351 | u16 max_y = std::max({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y}); | 351 | u16 max_y = std::max({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y}); |
| 352 | 352 | ||
| 353 | // Convert the scissor box coordinates to 12.4 fixed point | 353 | // Convert the scissor box coordinates to 12.4 fixed point |
| 354 | u16 scissor_x1 = (u16)(regs.scissor_test.x1 << 4); | 354 | u16 scissor_x1 = (u16)(regs.rasterizer.scissor_test.x1 << 4); |
| 355 | u16 scissor_y1 = (u16)(regs.scissor_test.y1 << 4); | 355 | u16 scissor_y1 = (u16)(regs.rasterizer.scissor_test.y1 << 4); |
| 356 | // x2,y2 have +1 added to cover the entire sub-pixel area | 356 | // x2,y2 have +1 added to cover the entire sub-pixel area |
| 357 | u16 scissor_x2 = (u16)((regs.scissor_test.x2 + 1) << 4); | 357 | u16 scissor_x2 = (u16)((regs.rasterizer.scissor_test.x2 + 1) << 4); |
| 358 | u16 scissor_y2 = (u16)((regs.scissor_test.y2 + 1) << 4); | 358 | u16 scissor_y2 = (u16)((regs.rasterizer.scissor_test.y2 + 1) << 4); |
| 359 | 359 | ||
| 360 | if (regs.scissor_test.mode == Regs::ScissorMode::Include) { | 360 | if (regs.rasterizer.scissor_test.mode == RasterizerRegs::ScissorMode::Include) { |
| 361 | // Calculate the new bounds | 361 | // Calculate the new bounds |
| 362 | min_x = std::max(min_x, scissor_x1); | 362 | min_x = std::max(min_x, scissor_x1); |
| 363 | min_y = std::max(min_y, scissor_y1); | 363 | min_y = std::max(min_y, scissor_y1); |
| @@ -411,7 +411,7 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve | |||
| 411 | 411 | ||
| 412 | // Do not process the pixel if it's inside the scissor box and the scissor mode is set | 412 | // Do not process the pixel if it's inside the scissor box and the scissor mode is set |
| 413 | // to Exclude | 413 | // to Exclude |
| 414 | if (regs.scissor_test.mode == Regs::ScissorMode::Exclude) { | 414 | if (regs.rasterizer.scissor_test.mode == RasterizerRegs::ScissorMode::Exclude) { |
| 415 | if (x >= scissor_x1 && x < scissor_x2 && y >= scissor_y1 && y < scissor_y2) | 415 | if (x >= scissor_x1 && x < scissor_x2 && y >= scissor_y1 && y < scissor_y2) |
| 416 | continue; | 416 | continue; |
| 417 | } | 417 | } |
| @@ -441,12 +441,14 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve | |||
| 441 | 441 | ||
| 442 | // Not fully accurate. About 3 bits in precision are missing. | 442 | // Not fully accurate. About 3 bits in precision are missing. |
| 443 | // Z-Buffer (z / w * scale + offset) | 443 | // Z-Buffer (z / w * scale + offset) |
| 444 | float depth_scale = float24::FromRaw(regs.viewport_depth_range).ToFloat32(); | 444 | float depth_scale = float24::FromRaw(regs.rasterizer.viewport_depth_range).ToFloat32(); |
| 445 | float depth_offset = float24::FromRaw(regs.viewport_depth_near_plane).ToFloat32(); | 445 | float depth_offset = |
| 446 | float24::FromRaw(regs.rasterizer.viewport_depth_near_plane).ToFloat32(); | ||
| 446 | float depth = interpolated_z_over_w * depth_scale + depth_offset; | 447 | float depth = interpolated_z_over_w * depth_scale + depth_offset; |
| 447 | 448 | ||
| 448 | // Potentially switch to W-Buffer | 449 | // Potentially switch to W-Buffer |
| 449 | if (regs.depthmap_enable == Pica::Regs::DepthBuffering::WBuffering) { | 450 | if (regs.rasterizer.depthmap_enable == |
| 451 | Pica::RasterizerRegs::DepthBuffering::WBuffering) { | ||
| 450 | // W-Buffer (z * scale + w * offset = (z / w * scale + offset) * w) | 452 | // W-Buffer (z * scale + w * offset = (z / w * scale + offset) * w) |
| 451 | depth *= interpolated_w_inverse.ToFloat32() * wsum; | 453 | depth *= interpolated_w_inverse.ToFloat32() * wsum; |
| 452 | } | 454 | } |