This commit is contained in:
Tilka 2024-11-11 22:13:07 +08:00 committed by GitHub
commit b37674a035
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -3,6 +3,7 @@
#include "VideoBackends/Software/SWVertexLoader.h" #include "VideoBackends/Software/SWVertexLoader.h"
#include <cfenv>
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
@ -78,6 +79,10 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
SetFormat(); SetFormat();
ParseVertex(VertexLoaderManager::GetCurrentVertexFormat()->GetVertexDeclaration(), index); ParseVertex(VertexLoaderManager::GetCurrentVertexFormat()->GetVertexDeclaration(), index);
// At least the position transform uses round-to-zero.
const auto round_mode = std::fegetround();
std::fesetround(FE_TOWARDZERO);
// transform this vertex so that it can be used for rasterization (outVertex) // transform this vertex so that it can be used for rasterization (outVertex)
OutputVertexData* outVertex = m_setup_unit.GetVertex(); OutputVertexData* outVertex = m_setup_unit.GetVertex();
TransformUnit::TransformPosition(&m_vertex, outVertex); TransformUnit::TransformPosition(&m_vertex, outVertex);
@ -85,6 +90,8 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
TransformUnit::TransformColor(&m_vertex, outVertex); TransformUnit::TransformColor(&m_vertex, outVertex);
TransformUnit::TransformTexCoord(&m_vertex, outVertex); TransformUnit::TransformTexCoord(&m_vertex, outVertex);
std::fesetround(round_mode);
// assemble and rasterize the primitive // assemble and rasterize the primitive
m_setup_unit.SetupVertex(); m_setup_unit.SetupVertex();

View File

@ -61,8 +61,7 @@ static void MultipleVec3Perspective(const Vec3& vec, const Projection::Raw& proj
{ {
result.x = proj[0] * vec.x + proj[1] * vec.z; result.x = proj[0] * vec.x + proj[1] * vec.z;
result.y = proj[2] * vec.y + proj[3] * vec.z; result.y = proj[2] * vec.y + proj[3] * vec.z;
// result.z = (proj[4] * vec.z + proj[5]); result.z = proj[4] * vec.z + proj[5];
result.z = (proj[4] * vec.z + proj[5]) * (1.0f - (float)1e-7);
result.w = -vec.z; result.w = -vec.z;
} }