vkd3d: Implement d3d12_command_list_OMSetDepthBounds().

Based on the design document, "The runtime will not clamp or validate
the input, but implementations may clamp to the range [0,1] if necessary.",
so we test for the EXT_depth_range_unrestricted extension, and only clamp if
it's not available (thus, necessary to do so).

NaNs are converted to zero as per "NaNs must be treated as 0, but the runtime
will convert NaNs to 0 on behalf of the implementation.", and a default bounds
are set to 0.0 and 1.0.
This commit is contained in:
Anna (navi) Figueiredo Gomes
2024-09-01 20:32:20 +02:00
committed by Henri Verbeet
parent 61a700bcdc
commit 127ae6cf12
Notes: Henri Verbeet 2024-09-11 15:31:24 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1031
6 changed files with 38 additions and 7 deletions

View File

@@ -19,6 +19,7 @@
*/
#include "vkd3d_private.h"
#include <math.h>
static void d3d12_fence_incref(struct d3d12_fence *fence);
static void d3d12_fence_decref(struct d3d12_fence *fence);
@@ -2451,6 +2452,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_Close(ID3D12GraphicsCommandL
}
list->is_recording = false;
list->has_depth_bounds = false;
if (!list->is_valid)
{
@@ -2479,7 +2481,7 @@ static void d3d12_command_list_reset_state(struct d3d12_command_list *list,
list->fb_layer_count = 0;
list->xfb_enabled = false;
list->has_depth_bounds = false;
list->is_predicated = false;
list->current_framebuffer = VK_NULL_HANDLE;
@@ -3363,6 +3365,12 @@ static bool d3d12_command_list_begin_render_pass(struct d3d12_command_list *list
list->xfb_enabled = true;
}
if (graphics->ds_desc.depthBoundsTestEnable && !list->has_depth_bounds)
{
list->has_depth_bounds = true;
VK_CALL(vkCmdSetDepthBounds(list->vk_command_buffer, 0.0f, 1.0f));
}
return true;
}
@@ -5951,7 +5959,25 @@ static void STDMETHODCALLTYPE d3d12_command_list_AtomicCopyBufferUINT64(ID3D12Gr
static void STDMETHODCALLTYPE d3d12_command_list_OMSetDepthBounds(ID3D12GraphicsCommandList6 *iface,
FLOAT min, FLOAT max)
{
FIXME("iface %p, min %.8e, max %.8e stub!\n", iface, min, max);
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList6(iface);
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
TRACE("iface %p, min %.8e, max %.8e.\n", iface, min, max);
if (isnan(max))
max = 0.0f;
if (isnan(min))
min = 0.0f;
if (!list->device->vk_info.EXT_depth_range_unrestricted && (min < 0.0f || min > 1.0f || max < 0.0f || max > 1.0f))
{
WARN("VK_EXT_depth_range_unrestricted was not found, clamping depth bounds to 0.0 and 1.0.\n");
max = vkd3d_clamp(max, 0.0f, 1.0f);
min = vkd3d_clamp(min, 0.0f, 1.0f);
}
list->has_depth_bounds = true;
VK_CALL(vkCmdSetDepthBounds(list->vk_command_buffer, min, max));
}
static void STDMETHODCALLTYPE d3d12_command_list_SetSamplePositions(ID3D12GraphicsCommandList6 *iface,