Vulkan ARM mali Z hack: Modify the matrix instead of the shader.

This commit is contained in:
Henrik Rydgård 2019-09-09 00:09:57 +02:00
parent 0462c01228
commit f76adfd760
4 changed files with 8 additions and 7 deletions

View file

@ -363,6 +363,3 @@ std::string FormatDriverVersion(const VkPhysicalDeviceProperties &props);
// Simple heuristic. // Simple heuristic.
bool IsHashMaliDriverVersion(const VkPhysicalDeviceProperties &props); bool IsHashMaliDriverVersion(const VkPhysicalDeviceProperties &props);
// For the ARM Mali depth scale hack.
#define DEPTH_SCALE_HACK_VALUE 0.9999f

View file

@ -151,6 +151,10 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
flippedMatrix = flippedMatrix * g_display_rot_matrix; flippedMatrix = flippedMatrix * g_display_rot_matrix;
} }
if (gstate_c.Supports(GPU_NEEDS_DEPTH_SCALE_HACK)) {
flippedMatrix[10] *= DEPTH_SCALE_HACK_VALUE;
}
CopyMatrix4x4(ub->proj, flippedMatrix.getReadPtr()); CopyMatrix4x4(ub->proj, flippedMatrix.getReadPtr());
} }
@ -164,6 +168,7 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE && g_display_rotation != DisplayRotation::ROTATE_0) { if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE && g_display_rotation != DisplayRotation::ROTATE_0) {
proj_through = proj_through * g_display_rot_matrix; proj_through = proj_through * g_display_rot_matrix;
} }
proj_through[10] *= 0.999f;
CopyMatrix4x4(ub->proj_through, proj_through.getReadPtr()); CopyMatrix4x4(ub->proj_through, proj_through.getReadPtr());
} }

View file

@ -500,6 +500,9 @@ enum {
GPU_PREFER_REVERSE_COLOR_ORDER = FLAG_BIT(31), GPU_PREFER_REVERSE_COLOR_ORDER = FLAG_BIT(31),
}; };
// For the ARM Mali depth scale hack.
#define DEPTH_SCALE_HACK_VALUE 0.9999f
struct KnownVertexBounds { struct KnownVertexBounds {
u16 minU; u16 minU;
u16 minV; u16 minV;

View file

@ -636,10 +636,6 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
} }
WRITE(p, " gl_Position = outPos;\n"); WRITE(p, " gl_Position = outPos;\n");
if (gstate_c.Supports(GPU_NEEDS_DEPTH_SCALE_HACK)) {
WRITE(p, " gl_Position.z *= %f;\n", DEPTH_SCALE_HACK_VALUE);
}
WRITE(p, "}\n"); WRITE(p, "}\n");
return true; return true;
} }