diff options
| author | 2015-05-06 23:04:30 -0400 | |
|---|---|---|
| committer | 2015-05-09 22:12:38 -0400 | |
| commit | 547da374b83063a3ca8111ba49049353c3388de8 (patch) | |
| tree | 483b1c5f67d1df1c4a22f43cdcdb289dd28c6669 /src | |
| parent | rasterizer: Implement combiner buffer input. (diff) | |
| download | yuzu-547da374b83063a3ca8111ba49049353c3388de8.tar.gz yuzu-547da374b83063a3ca8111ba49049353c3388de8.tar.xz yuzu-547da374b83063a3ca8111ba49049353c3388de8.zip | |
rasterizer: Fixed a depth testing bug.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/pica.h | 18 | ||||
| -rw-r--r-- | src/video_core/rasterizer.cpp | 7 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 30c8b7816..26a700038 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -452,9 +452,7 @@ struct Regs { | |||
| 452 | D24S8 = 3 | 452 | D24S8 = 3 |
| 453 | }; | 453 | }; |
| 454 | 454 | ||
| 455 | /* | 455 | // Returns the number of bytes in the specified depth format |
| 456 | * Returns the number of bytes in the specified depth format | ||
| 457 | */ | ||
| 458 | static u32 BytesPerDepthPixel(DepthFormat format) { | 456 | static u32 BytesPerDepthPixel(DepthFormat format) { |
| 459 | switch (format) { | 457 | switch (format) { |
| 460 | case DepthFormat::D16: | 458 | case DepthFormat::D16: |
| @@ -469,6 +467,20 @@ struct Regs { | |||
| 469 | } | 467 | } |
| 470 | } | 468 | } |
| 471 | 469 | ||
| 470 | // Returns the number of bits per depth component of the specified depth format | ||
| 471 | static u32 DepthBitsPerPixel(DepthFormat format) { | ||
| 472 | switch (format) { | ||
| 473 | case DepthFormat::D16: | ||
| 474 | return 16; | ||
| 475 | case DepthFormat::D24: | ||
| 476 | case DepthFormat::D24S8: | ||
| 477 | return 24; | ||
| 478 | default: | ||
| 479 | LOG_CRITICAL(HW_GPU, "Unknown depth format %u", format); | ||
| 480 | UNIMPLEMENTED(); | ||
| 481 | } | ||
| 482 | } | ||
| 483 | |||
| 472 | struct { | 484 | struct { |
| 473 | // Components are laid out in reverse byte order, most significant bits first. | 485 | // Components are laid out in reverse byte order, most significant bits first. |
| 474 | enum ColorFormat : u32 { | 486 | enum ColorFormat : u32 { |
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 7bdb503c8..2662faac5 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -643,9 +643,10 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0, | |||
| 643 | 643 | ||
| 644 | // TODO: Does depth indeed only get written even if depth testing is enabled? | 644 | // TODO: Does depth indeed only get written even if depth testing is enabled? |
| 645 | if (registers.output_merger.depth_test_enable) { | 645 | if (registers.output_merger.depth_test_enable) { |
| 646 | u16 z = (u16)((v0.screenpos[2].ToFloat32() * w0 + | 646 | unsigned num_bits = Pica::Regs::DepthBitsPerPixel(registers.framebuffer.depth_format); |
| 647 | v1.screenpos[2].ToFloat32() * w1 + | 647 | u32 z = (u32)((v0.screenpos[2].ToFloat32() * w0 + |
| 648 | v2.screenpos[2].ToFloat32() * w2) * 65535.f / wsum); | 648 | v1.screenpos[2].ToFloat32() * w1 + |
| 649 | v2.screenpos[2].ToFloat32() * w2) * ((1 << num_bits) - 1) / wsum); | ||
| 649 | u32 ref_z = GetDepth(x >> 4, y >> 4); | 650 | u32 ref_z = GetDepth(x >> 4, y >> 4); |
| 650 | 651 | ||
| 651 | bool pass = false; | 652 | bool pass = false; |