mirror of
https://github.com/azahar-emu/azahar.git
synced 2025-04-28 13:47:59 +03:00
Pica: Cleanup clipping code and change screenspace z to range from -1..0.
The change in depth range seems to reflect better to what applications are expecting, and makes for cleaner code overall (hence is more likely to reflect hardware behavior).
This commit is contained in:
parent
70a764d992
commit
365236fa4c
2 changed files with 42 additions and 53 deletions
|
@ -106,16 +106,17 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
|
|||
ScreenToRasterizerCoordinates(v1.screenpos),
|
||||
ScreenToRasterizerCoordinates(v2.screenpos) };
|
||||
|
||||
if (registers.cull_mode == Regs::CullMode::KeepClockWise) {
|
||||
// Reverse vertex order and use the CCW code path.
|
||||
if (registers.cull_mode == Regs::CullMode::KeepCounterClockWise) {
|
||||
// Reverse vertex order and use the CW code path.
|
||||
std::swap(vtxpos[1], vtxpos[2]);
|
||||
}
|
||||
|
||||
if (registers.cull_mode != Regs::CullMode::KeepAll) {
|
||||
// Cull away triangles which are wound clockwise.
|
||||
// TODO: A check for degenerate triangles ("== 0") should be considered for CullMode::KeepAll
|
||||
// Cull away triangles which are wound counter-clockwise.
|
||||
if (SignedArea(vtxpos[0].xy(), vtxpos[1].xy(), vtxpos[2].xy()) <= 0)
|
||||
return;
|
||||
} else {
|
||||
// TODO: Consider A check for degenerate triangles ("SignedArea == 0")
|
||||
}
|
||||
|
||||
// TODO: Proper scissor rect test!
|
||||
|
@ -475,7 +476,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
|
|||
|
||||
// TODO: Does depth indeed only get written even if depth testing is enabled?
|
||||
if (registers.output_merger.depth_test_enable) {
|
||||
u16 z = (u16)(-(v0.screenpos[2].ToFloat32() * w0 +
|
||||
u16 z = (u16)((v0.screenpos[2].ToFloat32() * w0 +
|
||||
v1.screenpos[2].ToFloat32() * w1 +
|
||||
v2.screenpos[2].ToFloat32() * w2) * 65535.f / wsum);
|
||||
u16 ref_z = GetDepth(x >> 4, y >> 4);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue