Skip to content
Permalink
Browse files

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

  • Loading branch information...
hrydgard committed Sep 8, 2019
1 parent 0462c01 commit f76adfd760403ce1a9390135c4e61c295c6b6e2c
@@ -363,6 +363,3 @@ std::string FormatDriverVersion(const VkPhysicalDeviceProperties &props);

// Simple heuristic.
bool IsHashMaliDriverVersion(const VkPhysicalDeviceProperties &props);

// For the ARM Mali depth scale hack.
#define DEPTH_SCALE_HACK_VALUE 0.9999f
@@ -151,6 +151,10 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
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());
}

@@ -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) {
proj_through = proj_through * g_display_rot_matrix;
}
proj_through[10] *= 0.999f;
CopyMatrix4x4(ub->proj_through, proj_through.getReadPtr());
}

@@ -500,6 +500,9 @@ enum {
GPU_PREFER_REVERSE_COLOR_ORDER = FLAG_BIT(31),
};

// For the ARM Mali depth scale hack.
#define DEPTH_SCALE_HACK_VALUE 0.9999f

struct KnownVertexBounds {
u16 minU;
u16 minV;
@@ -636,10 +636,6 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
}
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");
return true;
}

0 comments on commit f76adfd

Please sign in to comment.
You can’t perform that action at this time.