wine-staging/patches/vkd3d-latest/0004-Updated-vkd3d-to-d3ba810c98b4d2df260a527f74586a0b314.patch

356 lines
17 KiB
Diff
Raw Normal View History

2024-06-14 20:57:32 -07:00
From ff5cec233618d8feefafc6d551634c080150ebd8 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sat, 15 Jun 2024 08:36:52 +1000
Subject: [PATCH] Updated vkd3d to d3ba810c98b4d2df260a527f74586a0b31408510.
---
libs/vkd3d/libs/vkd3d-shader/fx.c | 5 +-
libs/vkd3d/libs/vkd3d-shader/hlsl.h | 1 +
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 2 +
libs/vkd3d/libs/vkd3d/command.c | 128 ++++++++++++--------
libs/vkd3d/libs/vkd3d/device.c | 12 +-
libs/vkd3d/libs/vkd3d/vkd3d_private.h | 2 +
6 files changed, 97 insertions(+), 53 deletions(-)
diff --git a/libs/vkd3d/libs/vkd3d-shader/fx.c b/libs/vkd3d/libs/vkd3d-shader/fx.c
index bd3bba6a3d5..3ba0a9ba994 100644
--- a/libs/vkd3d/libs/vkd3d-shader/fx.c
+++ b/libs/vkd3d/libs/vkd3d-shader/fx.c
@@ -989,8 +989,7 @@ static void write_fx_4_numeric_variable(struct hlsl_ir_var *var, bool shared, st
};
struct hlsl_ctx *ctx = fx->ctx;
- /* Explicit bind point. */
- if (var->reg_reservation.reg_type)
+ if (var->has_explicit_bind_point)
flags |= HAS_EXPLICIT_BIND_POINT;
type_offset = write_type(var->data_type, fx);
@@ -1001,7 +1000,7 @@ static void write_fx_4_numeric_variable(struct hlsl_ir_var *var, bool shared, st
put_u32(buffer, type_offset);
semantic_offset = put_u32(buffer, semantic_offset); /* Semantic */
- put_u32(buffer, var->buffer_offset); /* Offset in the constant buffer */
+ put_u32(buffer, var->buffer_offset * 4); /* Offset in the constant buffer, in bytes. */
value_offset = put_u32(buffer, 0); /* Default value offset */
put_u32(buffer, flags); /* Flags */
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
index 46042745f40..179cc219e68 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
@@ -492,6 +492,7 @@ struct hlsl_ir_var
uint32_t is_param : 1;
uint32_t is_separated_resource : 1;
uint32_t is_synthetic : 1;
+ uint32_t has_explicit_bind_point : 1;
};
/* This struct is used to represent assignments in state block entries:
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
index fb108ad939f..09066a6191a 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
@@ -4791,6 +4791,7 @@ static void hlsl_calculate_buffer_offset(struct hlsl_ctx *ctx, struct hlsl_ir_va
if (register_reservation)
{
var->buffer_offset = 4 * var->reg_reservation.reg_index;
+ var->has_explicit_bind_point = 1;
}
else
{
@@ -4823,6 +4824,7 @@ static void hlsl_calculate_buffer_offset(struct hlsl_ctx *ctx, struct hlsl_ir_va
}
}
var->buffer_offset = var->reg_reservation.offset_index;
+ var->has_explicit_bind_point = 1;
}
else
{
diff --git a/libs/vkd3d/libs/vkd3d/command.c b/libs/vkd3d/libs/vkd3d/command.c
index 6e37209cb1a..6c463be8d60 100644
--- a/libs/vkd3d/libs/vkd3d/command.c
+++ b/libs/vkd3d/libs/vkd3d/command.c
@@ -2025,7 +2025,8 @@ static void d3d12_command_list_invalidate_root_parameters(struct d3d12_command_l
static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state, unsigned int stencil_state,
const struct d3d12_resource *resource, VkQueueFlags vk_queue_flags, const struct vkd3d_vulkan_info *vk_info,
- VkAccessFlags *access_mask, VkPipelineStageFlags *stage_flags, VkImageLayout *image_layout)
+ VkAccessFlags *access_mask, VkPipelineStageFlags *stage_flags, VkImageLayout *image_layout,
+ struct d3d12_device *device)
{
bool is_swapchain_image = resource && (resource->flags & VKD3D_RESOURCE_PRESENT_STATE_TRANSITION);
VkPipelineStageFlags queue_shader_stages = 0;
@@ -2035,8 +2036,9 @@ static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
queue_shader_stages |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
| VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
| VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
- | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
| VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
+ if (device->vk_info.geometry_shaders)
+ queue_shader_stages |= VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT;
}
if (vk_queue_flags & VK_QUEUE_COMPUTE_BIT)
queue_shader_stages |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
@@ -2054,7 +2056,7 @@ static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
{
if (resource->present_state != D3D12_RESOURCE_STATE_PRESENT)
return vk_barrier_parameters_from_d3d12_resource_state(resource->present_state, 0,
- resource, vk_queue_flags, vk_info, access_mask, stage_flags, image_layout);
+ resource, vk_queue_flags, vk_info, access_mask, stage_flags, image_layout, device);
*access_mask = VK_ACCESS_MEMORY_READ_BIT;
*stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
@@ -2251,7 +2253,8 @@ static void d3d12_command_list_transition_resource_to_initial_state(struct d3d12
VK_IMAGE_LAYOUT_PREINITIALIZED : VK_IMAGE_LAYOUT_UNDEFINED;
if (!vk_barrier_parameters_from_d3d12_resource_state(resource->initial_state, 0,
- resource, list->vk_queue_flags, vk_info, &barrier.dstAccessMask, &dst_stage_mask, &barrier.newLayout))
+ resource, list->vk_queue_flags, vk_info, &barrier.dstAccessMask,
+ &dst_stage_mask, &barrier.newLayout, list->device))
{
FIXME("Unhandled state %#x.\n", resource->initial_state);
return;
@@ -4277,13 +4280,15 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC
}
if (!vk_barrier_parameters_from_d3d12_resource_state(state_before, stencil_state_before,
- resource, list->vk_queue_flags, vk_info, &src_access_mask, &src_stage_mask, &layout_before))
+ resource, list->vk_queue_flags, vk_info, &src_access_mask,
+ &src_stage_mask, &layout_before, list->device))
{
FIXME("Unhandled state %#x.\n", state_before);
continue;
}
if (!vk_barrier_parameters_from_d3d12_resource_state(state_after, stencil_state_after,
- resource, list->vk_queue_flags, vk_info, &dst_access_mask, &dst_stage_mask, &layout_after))
+ resource, list->vk_queue_flags, vk_info, &dst_access_mask,
+ &dst_stage_mask, &layout_after, list->device))
{
FIXME("Unhandled state %#x.\n", state_after);
continue;
@@ -4303,7 +4308,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC
resource = unsafe_impl_from_ID3D12Resource(uav->pResource);
vk_barrier_parameters_from_d3d12_resource_state(D3D12_RESOURCE_STATE_UNORDERED_ACCESS, 0,
- resource, list->vk_queue_flags, vk_info, &access_mask, &stage_mask, &image_layout);
+ resource, list->vk_queue_flags, vk_info, &access_mask,
+ &stage_mask, &image_layout, list->device);
src_access_mask = dst_access_mask = access_mask;
src_stage_mask = dst_stage_mask = stage_mask;
layout_before = layout_after = image_layout;
@@ -5428,6 +5434,52 @@ static const struct vkd3d_format *vkd3d_fixup_clear_uav_uint_colour(struct d3d12
}
}
+static struct vkd3d_view *create_uint_view(struct d3d12_device *device, const struct vkd3d_resource_view *view,
+ struct d3d12_resource *resource, VkClearColorValue *colour)
+{
+ struct vkd3d_texture_view_desc view_desc;
+ const struct vkd3d_format *uint_format;
+ struct vkd3d_view *uint_view;
+
+ if (!(uint_format = vkd3d_find_uint_format(device, view->format->dxgi_format))
+ && !(uint_format = vkd3d_fixup_clear_uav_uint_colour(device, view->format->dxgi_format, colour)))
+ {
+ ERR("Unhandled format %#x.\n", view->format->dxgi_format);
+ return NULL;
+ }
+
+ if (d3d12_resource_is_buffer(resource))
+ {
+ if (!vkd3d_create_buffer_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV, resource->u.vk_buffer,
+ uint_format, view->info.buffer.offset, view->info.buffer.size, &uint_view))
+ {
+ ERR("Failed to create buffer view.\n");
+ return NULL;
+ }
+
+ return uint_view;
+ }
+
+ memset(&view_desc, 0, sizeof(view_desc));
+ view_desc.view_type = view->info.texture.vk_view_type;
+ view_desc.format = uint_format;
+ view_desc.miplevel_idx = view->info.texture.miplevel_idx;
+ view_desc.miplevel_count = 1;
+ view_desc.layer_idx = view->info.texture.layer_idx;
+ view_desc.layer_count = view->info.texture.layer_count;
+ view_desc.vk_image_aspect = VK_IMAGE_ASPECT_COLOR_BIT;
+ view_desc.usage = VK_IMAGE_USAGE_STORAGE_BIT;
+
+ if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV,
+ resource->u.vk_image, &view_desc, &uint_view))
+ {
+ ERR("Failed to create image view.\n");
+ return NULL;
+ }
+
+ return uint_view;
+}
+
static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID3D12GraphicsCommandList5 *iface,
D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource,
const UINT values[4], UINT rect_count, const D3D12_RECT *rects)
@@ -5435,8 +5487,6 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList5(iface);
struct vkd3d_view *descriptor, *uint_view = NULL;
struct d3d12_device *device = list->device;
- struct vkd3d_texture_view_desc view_desc;
- const struct vkd3d_format *uint_format;
const struct vkd3d_resource_view *view;
struct d3d12_resource *resource_impl;
VkClearColorValue colour;
@@ -5450,44 +5500,11 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID
view = &descriptor->v;
memcpy(colour.uint32, values, sizeof(colour.uint32));
- if (view->format->type != VKD3D_FORMAT_TYPE_UINT)
+ if (view->format->type != VKD3D_FORMAT_TYPE_UINT
+ && !(descriptor = uint_view = create_uint_view(device, view, resource_impl, &colour)))
{
- if (!(uint_format = vkd3d_find_uint_format(device, view->format->dxgi_format))
- && !(uint_format = vkd3d_fixup_clear_uav_uint_colour(device, view->format->dxgi_format, &colour)))
- {
- ERR("Unhandled format %#x.\n", view->format->dxgi_format);
- return;
- }
-
- if (d3d12_resource_is_buffer(resource_impl))
- {
- if (!vkd3d_create_buffer_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV, resource_impl->u.vk_buffer,
- uint_format, view->info.buffer.offset, view->info.buffer.size, &uint_view))
- {
- ERR("Failed to create buffer view.\n");
- return;
- }
- }
- else
- {
- memset(&view_desc, 0, sizeof(view_desc));
- view_desc.view_type = view->info.texture.vk_view_type;
- view_desc.format = uint_format;
- view_desc.miplevel_idx = view->info.texture.miplevel_idx;
- view_desc.miplevel_count = 1;
- view_desc.layer_idx = view->info.texture.layer_idx;
- view_desc.layer_count = view->info.texture.layer_count;
- view_desc.vk_image_aspect = VK_IMAGE_ASPECT_COLOR_BIT;
- view_desc.usage = VK_IMAGE_USAGE_STORAGE_BIT;
-
- if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV, resource_impl->u.vk_image, &view_desc,
- &uint_view))
- {
- ERR("Failed to create image view.\n");
- return;
- }
- }
- descriptor = uint_view;
+ ERR("Failed to create UINT view.\n");
+ return;
}
d3d12_command_list_clear_uav(list, resource_impl, descriptor, &colour, rect_count, rects);
@@ -5501,19 +5518,32 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewFloat(I
const float values[4], UINT rect_count, const D3D12_RECT *rects)
{
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList5(iface);
+ struct vkd3d_view *descriptor, *uint_view = NULL;
+ struct d3d12_device *device = list->device;
+ const struct vkd3d_resource_view *view;
struct d3d12_resource *resource_impl;
VkClearColorValue colour;
- struct vkd3d_view *view;
TRACE("iface %p, gpu_handle %s, cpu_handle %s, resource %p, values %p, rect_count %u, rects %p.\n",
iface, debug_gpu_handle(gpu_handle), debug_cpu_handle(cpu_handle), resource, values, rect_count, rects);
resource_impl = unsafe_impl_from_ID3D12Resource(resource);
- if (!(view = d3d12_desc_from_cpu_handle(cpu_handle)->s.u.view))
+ if (!(descriptor = d3d12_desc_from_cpu_handle(cpu_handle)->s.u.view))
return;
+ view = &descriptor->v;
memcpy(colour.float32, values, sizeof(colour.float32));
- d3d12_command_list_clear_uav(list, resource_impl, view, &colour, rect_count, rects);
+ if (view->format->type == VKD3D_FORMAT_TYPE_SINT
+ && !(descriptor = uint_view = create_uint_view(device, view, resource_impl, &colour)))
+ {
+ ERR("Failed to create UINT view.\n");
+ return;
+ }
+
+ d3d12_command_list_clear_uav(list, resource_impl, descriptor, &colour, rect_count, rects);
+
+ if (uint_view)
+ vkd3d_view_decref(uint_view, device);
}
static void STDMETHODCALLTYPE d3d12_command_list_DiscardResource(ID3D12GraphicsCommandList5 *iface,
diff --git a/libs/vkd3d/libs/vkd3d/device.c b/libs/vkd3d/libs/vkd3d/device.c
index c27a96e2df8..674e46fe5c5 100644
--- a/libs/vkd3d/libs/vkd3d/device.c
+++ b/libs/vkd3d/libs/vkd3d/device.c
@@ -76,6 +76,14 @@ static const char * const required_device_extensions[] =
VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME,
};
+/* In general we don't want to enable Vulkan beta extensions, but make an
+ * exception for VK_KHR_portability_subset because we draw no real feature from
+ * it, but it's still useful to be able to develop for MoltenVK without being
+ * spammed with validation errors. */
+#ifndef VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME
+#define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset"
+#endif
+
static const struct vkd3d_optional_extension_info optional_device_extensions[] =
{
/* KHR extensions */
@@ -85,6 +93,7 @@ static const struct vkd3d_optional_extension_info optional_device_extensions[] =
VK_EXTENSION(KHR_IMAGE_FORMAT_LIST, KHR_image_format_list),
VK_EXTENSION(KHR_MAINTENANCE2, KHR_maintenance2),
VK_EXTENSION(KHR_MAINTENANCE3, KHR_maintenance3),
+ VK_EXTENSION(KHR_PORTABILITY_SUBSET, KHR_portability_subset),
VK_EXTENSION(KHR_PUSH_DESCRIPTOR, KHR_push_descriptor),
VK_EXTENSION(KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE, KHR_sampler_mirror_clamp_to_edge),
VK_EXTENSION(KHR_TIMELINE_SEMAPHORE, KHR_timeline_semaphore),
@@ -92,7 +101,7 @@ static const struct vkd3d_optional_extension_info optional_device_extensions[] =
VK_EXTENSION(EXT_4444_FORMATS, EXT_4444_formats),
VK_EXTENSION(EXT_CALIBRATED_TIMESTAMPS, EXT_calibrated_timestamps),
VK_EXTENSION(EXT_CONDITIONAL_RENDERING, EXT_conditional_rendering),
- VK_EXTENSION(EXT_DEBUG_MARKER, EXT_debug_marker),
+ VK_DEBUG_EXTENSION(EXT_DEBUG_MARKER, EXT_debug_marker),
VK_EXTENSION(EXT_DEPTH_CLIP_ENABLE, EXT_depth_clip_enable),
VK_EXTENSION(EXT_DESCRIPTOR_INDEXING, EXT_descriptor_indexing),
VK_EXTENSION(EXT_FRAGMENT_SHADER_INTERLOCK, EXT_fragment_shader_interlock),
@@ -1634,6 +1643,7 @@ static HRESULT vkd3d_init_device_caps(struct d3d12_device *device,
vulkan_info->device_limits = physical_device_info->properties2.properties.limits;
vulkan_info->sparse_properties = physical_device_info->properties2.properties.sparseProperties;
+ vulkan_info->geometry_shaders = physical_device_info->features2.features.geometryShader;
vulkan_info->sparse_binding = features->sparseBinding;
vulkan_info->sparse_residency_3d = features->sparseResidencyImage3D;
vulkan_info->rasterization_stream = physical_device_info->xfb_properties.transformFeedbackRasterizationStreamSelect;
diff --git a/libs/vkd3d/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/libs/vkd3d/vkd3d_private.h
index d1fa866d9e3..a55e967cdfc 100644
--- a/libs/vkd3d/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/libs/vkd3d/vkd3d_private.h
@@ -123,6 +123,7 @@ struct vkd3d_vulkan_info
bool KHR_image_format_list;
bool KHR_maintenance2;
bool KHR_maintenance3;
+ bool KHR_portability_subset;
bool KHR_push_descriptor;
bool KHR_sampler_mirror_clamp_to_edge;
bool KHR_timeline_semaphore;
@@ -145,6 +146,7 @@ struct vkd3d_vulkan_info
bool rasterization_stream;
bool transform_feedback_queries;
+ bool geometry_shaders;
bool uav_read_without_format;
--
2.43.0