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

@ -799,14 +799,8 @@ namespace rsx
if (flip_y) scale_y *= -1;
if (flip_y) offset_y *= -1;
float clip_min = rsx::method_registers.clip_min();
float clip_max = rsx::method_registers.clip_max();
float z_clip_scale = (clip_max + clip_min) == 0.f ? 1.f : (clip_max + clip_min);
float z_offset_scale = (clip_max - clip_min) == 0.f ? 1.f : (clip_max - clip_min);
float scale_z = rsx::method_registers.viewport_scale_z() / z_clip_scale;
float offset_z = rsx::method_registers.viewport_offset_z() / z_offset_scale;
float scale_z = rsx::method_registers.viewport_scale_z();
float offset_z = rsx::method_registers.viewport_offset_z();
float one = 1.f;
stream_vector(buffer, (u32&)scale_x, 0, 0, (u32&)offset_x);