diff options
author | Jason Ekstrand <[email protected]> | 2020-07-07 11:08:31 -0500 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-07-07 21:38:03 +0000 |
commit | 1d5e1882f662fb4a922353ea272c1e94398f9155 (patch) | |
tree | 15adf2f55e90cc31188e09d89faf7f64e8ccaee7 | |
parent | 3bb3e8940c93d468b9fbed18b53b6728e8664333 (diff) |
anv: Handle clamping of inverted depth ranges
Tested-by: Mike Blumenkrantz <[email protected]>
Reviewed-by: Ivan Briano <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5792>
-rw-r--r-- | src/intel/vulkan/gen8_cmd_buffer.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/intel/vulkan/gen8_cmd_buffer.c b/src/intel/vulkan/gen8_cmd_buffer.c index fe136ecd928..f2497231fea 100644 --- a/src/intel/vulkan/gen8_cmd_buffer.c +++ b/src/intel/vulkan/gen8_cmd_buffer.c @@ -104,9 +104,17 @@ gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer, for (uint32_t i = 0; i < count; i++) { const VkViewport *vp = &viewports[i]; + /* From the Vulkan spec: + * + * "It is valid for minDepth to be greater than or equal to + * maxDepth." + */ + float min_depth = MIN2(vp->minDepth, vp->maxDepth); + float max_depth = MAX2(vp->minDepth, vp->maxDepth); + struct GENX(CC_VIEWPORT) cc_viewport = { - .MinimumDepth = depth_clamp_enable ? vp->minDepth : 0.0f, - .MaximumDepth = depth_clamp_enable ? vp->maxDepth : 1.0f, + .MinimumDepth = depth_clamp_enable ? min_depth : 0.0f, + .MaximumDepth = depth_clamp_enable ? max_depth : 1.0f, }; GENX(CC_VIEWPORT_pack)(NULL, cc_state.map + i * 8, &cc_viewport); |