mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
libs/vkd3d: Fix initial state transtion for swapchain images.
This commit is contained in:
parent
b9da47ebe2
commit
4aab207b56
@ -407,8 +407,9 @@ static inline struct demo_swapchain *demo_swapchain_create(ID3D12CommandQueue *c
|
|||||||
resource_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
|
resource_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
|
||||||
for (i = 0; i < image_count; ++i)
|
for (i = 0; i < image_count; ++i)
|
||||||
{
|
{
|
||||||
if (FAILED(vkd3d_create_image_resource(d3d12_device,
|
if (FAILED(vkd3d_create_image_resource(d3d12_device, &resource_desc, vk_images[i],
|
||||||
&resource_desc, vk_images[i], &swapchain->buffers[i])))
|
VKD3D_RESOURCE_INITIAL_STATE_TRANSITION | VKD3D_RESOURCE_SWAPCHAIN_IMAGE,
|
||||||
|
&swapchain->buffers[i])))
|
||||||
{
|
{
|
||||||
for (j = 0; j < i; ++j)
|
for (j = 0; j < i; ++j)
|
||||||
{
|
{
|
||||||
|
@ -40,10 +40,14 @@ struct vkd3d_device_create_info
|
|||||||
vkd3d_signal_event_pfn signal_event_pfn;
|
vkd3d_signal_event_pfn signal_event_pfn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* resource flags */
|
||||||
|
#define VKD3D_RESOURCE_INITIAL_STATE_TRANSITION 0x00000001
|
||||||
|
#define VKD3D_RESOURCE_SWAPCHAIN_IMAGE 0x00000002
|
||||||
|
|
||||||
HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
|
HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
|
||||||
REFIID riid, void **device);
|
REFIID riid, void **device);
|
||||||
HRESULT vkd3d_create_image_resource(ID3D12Device *device, const D3D12_RESOURCE_DESC *desc,
|
HRESULT vkd3d_create_image_resource(ID3D12Device *device, const D3D12_RESOURCE_DESC *desc,
|
||||||
VkImage vk_image, ID3D12Resource **resource);
|
VkImage vk_image, unsigned int resource_flags, ID3D12Resource **resource);
|
||||||
VkDevice vkd3d_get_vk_device(ID3D12Device *device);
|
VkDevice vkd3d_get_vk_device(ID3D12Device *device);
|
||||||
VkFormat vkd3d_get_vk_format(DXGI_FORMAT format);
|
VkFormat vkd3d_get_vk_format(DXGI_FORMAT format);
|
||||||
VkInstance vkd3d_get_vk_instance(ID3D12Device *device);
|
VkInstance vkd3d_get_vk_instance(ID3D12Device *device);
|
||||||
|
@ -941,9 +941,8 @@ static void d3d12_command_list_invalidate_current_pipeline(struct d3d12_command_
|
|||||||
list->current_pipeline = VK_NULL_HANDLE;
|
list->current_pipeline = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
|
static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state, bool is_swapchain_image,
|
||||||
VkAccessFlags *access_mask, VkPipelineStageFlags *stage_flags,
|
VkAccessFlags *access_mask, VkPipelineStageFlags *stage_flags, VkImageLayout *image_layout)
|
||||||
VkImageLayout *image_layout)
|
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
@ -954,10 +953,20 @@ static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state,
|
|||||||
* resources can be implicitly promoted to other states out of the
|
* resources can be implicitly promoted to other states out of the
|
||||||
* COMMON state, and the resource state can decay to the COMMON
|
* COMMON state, and the resource state can decay to the COMMON
|
||||||
* state when GPU finishes execution of a command list. */
|
* state when GPU finishes execution of a command list. */
|
||||||
*access_mask = VK_ACCESS_HOST_READ_BIT | VK_ACCESS_HOST_WRITE_BIT;
|
if (is_swapchain_image)
|
||||||
*stage_flags = VK_PIPELINE_STAGE_HOST_BIT;
|
{
|
||||||
if (image_layout)
|
*access_mask = VK_ACCESS_MEMORY_READ_BIT;
|
||||||
*image_layout = VK_IMAGE_LAYOUT_GENERAL;
|
*stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
|
if (image_layout)
|
||||||
|
*image_layout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*access_mask = VK_ACCESS_HOST_READ_BIT | VK_ACCESS_HOST_WRITE_BIT;
|
||||||
|
*stage_flags = VK_PIPELINE_STAGE_HOST_BIT;
|
||||||
|
if (image_layout)
|
||||||
|
*image_layout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* Handle write states. */
|
/* Handle write states. */
|
||||||
@ -1144,6 +1153,7 @@ static void d3d12_command_list_transition_resource_to_initial_state(struct d3d12
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!vk_barrier_parameters_from_d3d12_resource_state(resource->initial_state,
|
if (!vk_barrier_parameters_from_d3d12_resource_state(resource->initial_state,
|
||||||
|
resource->flags & VKD3D_RESOURCE_SWAPCHAIN_IMAGE,
|
||||||
&barrier.dstAccessMask, &dst_stage_mask, &barrier.newLayout))
|
&barrier.dstAccessMask, &dst_stage_mask, &barrier.newLayout))
|
||||||
{
|
{
|
||||||
FIXME("Unhandled state %#x.\n", resource->initial_state);
|
FIXME("Unhandled state %#x.\n", resource->initial_state);
|
||||||
@ -1848,23 +1858,25 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource = unsafe_impl_from_ID3D12Resource(transition->pResource);
|
||||||
|
assert(resource);
|
||||||
|
sub_resource_idx = transition->Subresource;
|
||||||
|
|
||||||
if (!vk_barrier_parameters_from_d3d12_resource_state(transition->StateBefore,
|
if (!vk_barrier_parameters_from_d3d12_resource_state(transition->StateBefore,
|
||||||
|
resource->flags & VKD3D_RESOURCE_SWAPCHAIN_IMAGE,
|
||||||
&src_access_mask, &src_stage_mask, &layout_before))
|
&src_access_mask, &src_stage_mask, &layout_before))
|
||||||
{
|
{
|
||||||
FIXME("Unhandled state %#x.\n", transition->StateBefore);
|
FIXME("Unhandled state %#x.\n", transition->StateBefore);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!vk_barrier_parameters_from_d3d12_resource_state(transition->StateAfter,
|
if (!vk_barrier_parameters_from_d3d12_resource_state(transition->StateAfter,
|
||||||
|
resource->flags & VKD3D_RESOURCE_SWAPCHAIN_IMAGE,
|
||||||
&dst_access_mask, &dst_stage_mask, &layout_after))
|
&dst_access_mask, &dst_stage_mask, &layout_after))
|
||||||
{
|
{
|
||||||
FIXME("Unhandled state %#x.\n", transition->StateAfter);
|
FIXME("Unhandled state %#x.\n", transition->StateAfter);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
resource = unsafe_impl_from_ID3D12Resource(transition->pResource);
|
|
||||||
assert(resource);
|
|
||||||
sub_resource_idx = transition->Subresource;
|
|
||||||
|
|
||||||
TRACE("Transition barrier (resource %p, subresource %#x, before %#x, after %#x).\n",
|
TRACE("Transition barrier (resource %p, subresource %#x, before %#x, after %#x).\n",
|
||||||
resource, transition->Subresource, transition->StateBefore, transition->StateAfter);
|
resource, transition->Subresource, transition->StateBefore, transition->StateAfter);
|
||||||
break;
|
break;
|
||||||
@ -1879,6 +1891,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsC
|
|||||||
|
|
||||||
resource = unsafe_impl_from_ID3D12Resource(uav->pResource);
|
resource = unsafe_impl_from_ID3D12Resource(uav->pResource);
|
||||||
vk_barrier_parameters_from_d3d12_resource_state(D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
|
vk_barrier_parameters_from_d3d12_resource_state(D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
|
||||||
|
resource && (resource->flags & VKD3D_RESOURCE_SWAPCHAIN_IMAGE),
|
||||||
&access_mask, &stage_mask, &image_layout);
|
&access_mask, &stage_mask, &image_layout);
|
||||||
src_access_mask = dst_access_mask = access_mask;
|
src_access_mask = dst_access_mask = access_mask;
|
||||||
dst_stage_mask = src_stage_mask = stage_mask;
|
dst_stage_mask = src_stage_mask = stage_mask;
|
||||||
|
@ -738,7 +738,7 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
HRESULT vkd3d_create_image_resource(ID3D12Device *device, const D3D12_RESOURCE_DESC *desc,
|
HRESULT vkd3d_create_image_resource(ID3D12Device *device, const D3D12_RESOURCE_DESC *desc,
|
||||||
VkImage vk_image, ID3D12Resource **resource)
|
VkImage vk_image, unsigned int resource_flags, ID3D12Resource **resource)
|
||||||
{
|
{
|
||||||
struct d3d12_device *d3d12_device = unsafe_impl_from_ID3D12Device(device);
|
struct d3d12_device *d3d12_device = unsafe_impl_from_ID3D12Device(device);
|
||||||
struct d3d12_resource *object;
|
struct d3d12_resource *object;
|
||||||
@ -752,6 +752,7 @@ HRESULT vkd3d_create_image_resource(ID3D12Device *device, const D3D12_RESOURCE_D
|
|||||||
object->u.vk_image = vk_image;
|
object->u.vk_image = vk_image;
|
||||||
object->vk_memory = VK_NULL_HANDLE;
|
object->vk_memory = VK_NULL_HANDLE;
|
||||||
object->flags = VKD3D_RESOURCE_EXTERNAL;
|
object->flags = VKD3D_RESOURCE_EXTERNAL;
|
||||||
|
object->flags |= resource_flags & VKD3D_RESOURCE_PUBLIC_FLAGS;
|
||||||
object->map_count = 0;
|
object->map_count = 0;
|
||||||
object->map_data = NULL;
|
object->map_data = NULL;
|
||||||
memset(&object->heap_properties, 0, sizeof(object->heap_properties));
|
memset(&object->heap_properties, 0, sizeof(object->heap_properties));
|
||||||
|
@ -114,8 +114,9 @@ struct d3d12_fence
|
|||||||
HRESULT d3d12_fence_create(struct d3d12_device *device,
|
HRESULT d3d12_fence_create(struct d3d12_device *device,
|
||||||
UINT64 initial_value, D3D12_FENCE_FLAGS flags, struct d3d12_fence **fence) DECLSPEC_HIDDEN;
|
UINT64 initial_value, D3D12_FENCE_FLAGS flags, struct d3d12_fence **fence) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
#define VKD3D_RESOURCE_INITIAL_STATE_TRANSITION 0x00000001
|
#define VKD3D_RESOURCE_PUBLIC_FLAGS \
|
||||||
#define VKD3D_RESOURCE_EXTERNAL 0x00000002
|
(VKD3D_RESOURCE_INITIAL_STATE_TRANSITION | VKD3D_RESOURCE_SWAPCHAIN_IMAGE)
|
||||||
|
#define VKD3D_RESOURCE_EXTERNAL 0x00000004
|
||||||
|
|
||||||
/* ID3D12Resource */
|
/* ID3D12Resource */
|
||||||
struct d3d12_resource
|
struct d3d12_resource
|
||||||
|
Loading…
Reference in New Issue
Block a user