rsx/gl/vk: Simulate z clipping with selective depth clamp

- The scale offset matrix is fine but on real hardware the z results seem to be independent of near/far clipping distances
-- If depth falls within near/far, clamp depth value to [0,1]
This commit is contained in:
kd-11 2018-01-18 15:06:28 +03:00
parent 1a6e53ec98
commit 0a2992839b
6 changed files with 30 additions and 12 deletions

View file

@ -39,6 +39,8 @@ void GLVertexDecompilerThread::insertHeader(std::stringstream &OS)
OS << " uint transform_branch_bits;\n";
OS << " uint vertex_base_index;\n";
OS << " float point_size;\n";
OS << " float z_near;\n";
OS << " float z_far;\n";
OS << " ivec4 input_attributes[16];\n";
OS << "};\n\n";
}
@ -297,6 +299,7 @@ void GLVertexDecompilerThread::insertMainEnd(std::stringstream & OS)
OS << " gl_PointSize = point_size;\n";
OS << " gl_Position = gl_Position * scale_offset_mat;\n";
OS << " gl_Position = apply_zclip_xform(gl_Position, z_near, z_far);\n";
//Since our clip_space is symetrical [-1, 1] we map it to linear space using the eqn:
//ln = (clip * 2) - 1 to fully utilize the 0-1 range of the depth buffer