winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-devel
April 2019
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-devel@winehq.org
82 participants
743 discussions
Start a n
N
ew thread
[PATCH vkd3d 4/9] vkd3d: Share Vulkan render pass objects between D3D12 pipeline states.
by Józef Kucia
29 Apr '19
29 Apr '19
From: Józef Kucia <jkucia(a)codeweavers.com> For example, World of Warcraft creates 28 render passes for pipeline state objects instead of 600+ render passes. Other games appears to use similarly low number of render passes, e.g. 8, 17, 26, 60. Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> --- libs/vkd3d/device.c | 6 +- libs/vkd3d/state.c | 260 +++++++++++++++++++++++++++++++------ libs/vkd3d/vkd3d_private.h | 30 ++++- 3 files changed, 254 insertions(+
…
[View More]
), 42 deletions(-) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 5c0c880d9d25..5364df28bbc9 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -1665,7 +1665,7 @@ static HRESULT d3d12_device_init_pipeline_cache(struct d3d12_device *device) VkResult vr; int rc; - if ((rc = pthread_mutex_init(&device->pipeline_cache_mutex, NULL))) + if ((rc = pthread_mutex_init(&device->mutex, NULL))) { ERR("Failed to initialize mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -1693,7 +1693,7 @@ static void d3d12_device_destroy_pipeline_cache(struct d3d12_device *device) if (device->vk_pipeline_cache) VK_CALL(vkDestroyPipelineCache(device->vk_device, device->vk_pipeline_cache, NULL)); - pthread_mutex_destroy(&device->pipeline_cache_mutex); + pthread_mutex_destroy(&device->mutex); } D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_allocator *allocator, @@ -1866,6 +1866,7 @@ static ULONG STDMETHODCALLTYPE d3d12_device_Release(ID3D12Device *iface) vkd3d_destroy_null_resources(&device->null_resources, device); vkd3d_gpu_va_allocator_cleanup(&device->gpu_va_allocator); + vkd3d_render_pass_cache_cleanup(&device->render_pass_cache, device); vkd3d_fence_worker_stop(&device->fence_worker, device); d3d12_device_destroy_pipeline_cache(device); d3d12_device_destroy_vkd3d_queues(device); @@ -3030,6 +3031,7 @@ static HRESULT d3d12_device_init(struct d3d12_device *device, if (FAILED(hr = vkd3d_init_null_resources(&device->null_resources, device))) goto out_stop_fence_worker; + vkd3d_render_pass_cache_init(&device->render_pass_cache); vkd3d_gpu_va_allocator_init(&device->gpu_va_allocator); if ((device->parent = create_info->parent)) diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index edf3399b1aa8..b23101e868a6 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1033,6 +1033,196 @@ HRESULT d3d12_root_signature_create(struct d3d12_device *device, return S_OK; } +/* vkd3d_render_pass_cache */ +struct vkd3d_render_pass_entry +{ + struct vkd3d_render_pass_key key; + VkRenderPass vk_render_pass; +}; + +STATIC_ASSERT(sizeof(struct vkd3d_render_pass_key) == 48); + +static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pass_cache *cache, + struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass) +{ + VkAttachmentReference attachment_references[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1]; + VkAttachmentDescription attachments[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1]; + const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; + struct vkd3d_render_pass_entry *entry; + unsigned int color_attachment_index; + VkSubpassDescription sub_pass_desc; + VkRenderPassCreateInfo pass_info; + bool have_depth_stencil; + unsigned int index; + VkResult vr; + + if (!vkd3d_array_reserve((void **)&cache->render_passes, &cache->render_passes_size, + cache->render_pass_count + 1, sizeof(*cache->render_passes))) + { + *vk_render_pass = VK_NULL_HANDLE; + return E_OUTOFMEMORY; + } + + entry = &cache->render_passes[cache->render_pass_count]; + + entry->key = *key; + + have_depth_stencil = key->depth_enable || key->stencil_enable; + color_attachment_index = have_depth_stencil ? 1 : 0; + + index = 0; + if (have_depth_stencil) + { + VkImageLayout depth_layout = key->depth_stencil_write + ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL + : VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; + + attachments[index].flags = 0; + attachments[index].format = key->vk_formats[index]; + attachments[index].samples = key->sample_count; + + if (key->depth_enable) + { + attachments[index].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + attachments[index].storeOp = VK_ATTACHMENT_STORE_OP_STORE; + } + else + { + attachments[index].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + attachments[index].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + } + if (key->stencil_enable) + { + attachments[index].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + attachments[index].stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; + } + else + { + attachments[index].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + attachments[index].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + } + attachments[index].initialLayout = depth_layout; + attachments[index].finalLayout = depth_layout; + + attachment_references[index].attachment = 0; + attachment_references[index].layout = depth_layout; + + ++index; + } + + assert(index == color_attachment_index); + for (; index < key->attachment_count; ++index) + { + + attachments[index].flags = 0; + attachments[index].format = key->vk_formats[index]; + attachments[index].samples = key->sample_count; + attachments[index].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + attachments[index].storeOp = VK_ATTACHMENT_STORE_OP_STORE; + attachments[index].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + attachments[index].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attachments[index].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + attachments[index].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + + attachment_references[index].attachment = index; + attachment_references[index].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + } + + sub_pass_desc.flags = 0; + sub_pass_desc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; + sub_pass_desc.inputAttachmentCount = 0; + sub_pass_desc.pInputAttachments = NULL; + sub_pass_desc.colorAttachmentCount = key->attachment_count - color_attachment_index; + sub_pass_desc.pColorAttachments = &attachment_references[color_attachment_index]; + sub_pass_desc.pResolveAttachments = NULL; + if (have_depth_stencil) + sub_pass_desc.pDepthStencilAttachment = &attachment_references[0]; + else + sub_pass_desc.pDepthStencilAttachment = NULL; + sub_pass_desc.preserveAttachmentCount = 0; + sub_pass_desc.pPreserveAttachments = NULL; + + pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; + pass_info.pNext = NULL; + pass_info.flags = 0; + pass_info.attachmentCount = key->attachment_count; + pass_info.pAttachments = attachments; + pass_info.subpassCount = 1; + pass_info.pSubpasses = &sub_pass_desc; + pass_info.dependencyCount = 0; + pass_info.pDependencies = NULL; + if ((vr = VK_CALL(vkCreateRenderPass(device->vk_device, &pass_info, NULL, vk_render_pass))) >= 0) + { + entry->vk_render_pass = *vk_render_pass; + ++cache->render_pass_count; + } + else + { + WARN("Failed to create Vulkan render pass, vr %d.\n", vr); + *vk_render_pass = VK_NULL_HANDLE; + } + + return hresult_from_vk_result(vr); +} + +HRESULT vkd3d_render_pass_cache_find(struct vkd3d_render_pass_cache *cache, + struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass) +{ + bool found = false; + HRESULT hr = S_OK; + unsigned int i; + int rc; + + if ((rc = pthread_mutex_lock(&device->mutex))) + { + ERR("Failed to lock mutex, error %d.\n", rc); + *vk_render_pass = VK_NULL_HANDLE; + return hresult_from_errno(rc); + } + + for (i = 0; i < cache->render_pass_count; ++i) + { + struct vkd3d_render_pass_entry *current = &cache->render_passes[i]; + + if (!memcmp(¤t->key, key, sizeof(*key))) + { + *vk_render_pass = current->vk_render_pass; + found = true; + break; + } + } + + if (!found) + hr = vkd3d_render_pass_cache_create_pass_locked(cache, device, key, vk_render_pass); + + pthread_mutex_unlock(&device->mutex); + + return hr; +} + +void vkd3d_render_pass_cache_init(struct vkd3d_render_pass_cache *cache) +{ + cache->render_passes = NULL; + cache->render_pass_count = 0; + cache->render_passes_size = 0; +} + +void vkd3d_render_pass_cache_cleanup(struct vkd3d_render_pass_cache *cache, + struct d3d12_device *device) +{ + const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; + unsigned int i; + + for (i = 0; i < cache->render_pass_count; ++i) + { + struct vkd3d_render_pass_entry *current = &cache->render_passes[i]; + VK_CALL(vkDestroyRenderPass(device->vk_device, current->vk_render_pass, NULL)); + } + + vkd3d_free(cache->render_passes); + cache->render_passes = NULL; +} + struct vkd3d_pipeline_key { D3D12_PRIMITIVE_TOPOLOGY topology; @@ -1096,7 +1286,6 @@ static void d3d12_pipeline_state_destroy_graphics(struct d3d12_pipeline_state *s { VK_CALL(vkDestroyShaderModule(device->vk_device, graphics->stages[i].module, NULL)); } - VK_CALL(vkDestroyRenderPass(device->vk_device, graphics->render_pass, NULL)); LIST_FOR_EACH_ENTRY_SAFE(current, e, &graphics->compiled_pipelines, struct vkd3d_compiled_pipeline, entry) { @@ -1883,17 +2072,15 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s struct vkd3d_shader_interface_info shader_interface; const struct d3d12_root_signature *root_signature; struct vkd3d_shader_signature input_signature; + struct vkd3d_render_pass_key render_pass_key; VkShaderStageFlagBits xfb_stage = 0; VkSampleCountFlagBits sample_count; - VkSubpassDescription sub_pass_desc; const struct vkd3d_format *format; - VkRenderPassCreateInfo pass_desc; unsigned int instance_divisor; VkVertexInputRate input_rate; unsigned int i, j; size_t rt_count; uint32_t mask; - VkResult vr; HRESULT hr; int ret; @@ -1983,13 +2170,20 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s if ((ds_desc->DepthEnable && ds_desc->DepthWriteMask) || (ds_desc->StencilEnable && ds_desc->StencilWriteMask)) + { depth_layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + render_pass_key.depth_stencil_write = true; + } else + { depth_layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; + render_pass_key.depth_stencil_write = false; + } graphics->attachments[0].flags = 0; graphics->attachments[0].format = format->vk_format; graphics->attachments[0].samples = sample_count; + render_pass_key.depth_enable = desc->DepthStencilState.DepthEnable; if (desc->DepthStencilState.DepthEnable) { graphics->attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; @@ -2000,6 +2194,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s graphics->attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; graphics->attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; } + render_pass_key.stencil_enable = desc->DepthStencilState.StencilEnable; if (desc->DepthStencilState.StencilEnable) { graphics->attachments[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; @@ -2017,6 +2212,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s graphics->attachment_references[0].layout = depth_layout; ++graphics->rt_idx; + render_pass_key.vk_formats[0] = format->vk_format; + if (!desc->PS.pShaderBytecode) { if (FAILED(hr = create_shader_stage(device, &graphics->stages[graphics->stage_count], @@ -2026,6 +2223,12 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s ++graphics->stage_count; } } + else + { + render_pass_key.depth_enable = false; + render_pass_key.stencil_enable = false; + render_pass_key.depth_stencil_write = false; + } for (i = 0; i < rt_count; ++i) { @@ -2068,10 +2271,18 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s graphics->attachment_references[idx].attachment = idx; graphics->attachment_references[idx].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + render_pass_key.vk_formats[idx] = format->vk_format; + blend_attachment_from_d3d12(&graphics->blend_attachments[i], rt_desc); } graphics->attachment_count = graphics->rt_idx + rt_count; + render_pass_key.attachment_count = graphics->rt_idx + rt_count; + render_pass_key.padding = 0; + render_pass_key.sample_count = sample_count; + for (i = render_pass_key.attachment_count; i < ARRAY_SIZE(render_pass_key.vk_formats); ++i) + render_pass_key.vk_formats[i] = VK_FORMAT_UNDEFINED; + ps_shader_parameters[0].name = VKD3D_SHADER_PARAMETER_NAME_RASTERIZER_SAMPLE_COUNT; ps_shader_parameters[0].type = VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT; ps_shader_parameters[0].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32; @@ -2329,35 +2540,9 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s goto fail; } - sub_pass_desc.flags = 0; - sub_pass_desc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; - sub_pass_desc.inputAttachmentCount = 0; - sub_pass_desc.pInputAttachments = NULL; - sub_pass_desc.colorAttachmentCount = rt_count; - sub_pass_desc.pColorAttachments = &graphics->attachment_references[graphics->rt_idx]; - sub_pass_desc.pResolveAttachments = NULL; - if (graphics->rt_idx) - sub_pass_desc.pDepthStencilAttachment = &graphics->attachment_references[0]; - else - sub_pass_desc.pDepthStencilAttachment = NULL; - sub_pass_desc.preserveAttachmentCount = 0; - sub_pass_desc.pPreserveAttachments = NULL; - - pass_desc.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; - pass_desc.pNext = NULL; - pass_desc.flags = 0; - pass_desc.attachmentCount = graphics->attachment_count; - pass_desc.pAttachments = graphics->attachments; - pass_desc.subpassCount = 1; - pass_desc.pSubpasses = &sub_pass_desc; - pass_desc.dependencyCount = 0; - pass_desc.pDependencies = NULL; - if ((vr = VK_CALL(vkCreateRenderPass(device->vk_device, &pass_desc, NULL, &graphics->render_pass))) < 0) - { - WARN("Failed to create Vulkan render pass, vr %d.\n", vr); - hr = hresult_from_vk_result(vr); + if (FAILED(hr = vkd3d_render_pass_cache_find(&device->render_pass_cache, device, + &render_pass_key, &graphics->render_pass))) goto fail; - } rs_desc_from_d3d12(&graphics->rs_desc, &desc->RasterizerState); if ((!graphics->attachment_count && !(desc->PS.pShaderBytecode && desc->PS.BytecodeLength)) @@ -2392,10 +2577,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s list_init(&graphics->compiled_pipelines); if (FAILED(hr = vkd3d_private_store_init(&state->private_store))) - { - VK_CALL(vkDestroyRenderPass(device->vk_device, graphics->render_pass, NULL)); goto fail; - } state->vk_bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; state->device = device; @@ -2497,7 +2679,7 @@ static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(const struct d3d12 struct vkd3d_compiled_pipeline *current; int rc; - if (!(rc = pthread_mutex_lock(&device->pipeline_cache_mutex))) + if (!(rc = pthread_mutex_lock(&device->mutex))) { LIST_FOR_EACH_ENTRY(current, &graphics->compiled_pipelines, struct vkd3d_compiled_pipeline, entry) { @@ -2507,7 +2689,7 @@ static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(const struct d3d12 break; } } - pthread_mutex_unlock(&device->pipeline_cache_mutex); + pthread_mutex_unlock(&device->mutex); } else { @@ -2531,7 +2713,7 @@ static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_sta compiled_pipeline->key = *key; compiled_pipeline->vk_pipeline = vk_pipeline; - if ((rc = pthread_mutex_lock(&device->pipeline_cache_mutex))) + if ((rc = pthread_mutex_lock(&device->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); vkd3d_free(compiled_pipeline); @@ -2551,7 +2733,7 @@ static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_sta if (compiled_pipeline) list_add_tail(&graphics->compiled_pipelines, &compiled_pipeline->entry); - pthread_mutex_unlock(&device->pipeline_cache_mutex); + pthread_mutex_unlock(&device->mutex); return compiled_pipeline; } diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index ba586b44aab2..950be6e56981 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -184,6 +184,33 @@ void *vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocato void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address) DECLSPEC_HIDDEN; +struct vkd3d_render_pass_key +{ + unsigned int attachment_count; + bool depth_enable; + bool stencil_enable; + bool depth_stencil_write; + bool padding; + unsigned int sample_count; + VkFormat vk_formats[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1]; +}; + +struct vkd3d_render_pass_entry; + +struct vkd3d_render_pass_cache +{ + struct vkd3d_render_pass_entry *render_passes; + size_t render_pass_count; + size_t render_passes_size; +}; + +void vkd3d_render_pass_cache_cleanup(struct vkd3d_render_pass_cache *cache, + struct d3d12_device *device) DECLSPEC_HIDDEN; +HRESULT vkd3d_render_pass_cache_find(struct vkd3d_render_pass_cache *cache, + struct d3d12_device *device, const struct vkd3d_render_pass_key *key, + VkRenderPass *vk_render_pass) DECLSPEC_HIDDEN; +void vkd3d_render_pass_cache_init(struct vkd3d_render_pass_cache *cache) DECLSPEC_HIDDEN; + struct vkd3d_private_store { pthread_mutex_t mutex; @@ -925,7 +952,8 @@ struct d3d12_device struct vkd3d_gpu_va_allocator gpu_va_allocator; struct vkd3d_fence_worker fence_worker; - pthread_mutex_t pipeline_cache_mutex; + pthread_mutex_t mutex; + struct vkd3d_render_pass_cache render_pass_cache; VkPipelineCache vk_pipeline_cache; VkPhysicalDeviceMemoryProperties memory_properties; -- 2.21.0
[View Less]
2
1
0
0
[PATCH vkd3d 3/9] vkd3d-shader: Improve ID assignment for specialization constants.
by Józef Kucia
29 Apr '19
29 Apr '19
From: Józef Kucia <jkucia(a)codeweavers.com> Allows using 0 as SpecId. Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> --- libs/vkd3d-shader/spirv.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 22e02f9ffa01..86d5be89b039 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2565,20 +2565,20 @@ static const struct vkd3d_spec_constant_info *
…
[View More]
get_spec_constant_info(enum vkd3d_ static uint32_t vkd3d_dxbc_compiler_alloc_spec_constant_id(struct vkd3d_dxbc_compiler *compiler) { - if (!compiler->current_spec_constant_id && compiler->compile_args) + if (!compiler->current_spec_constant_id) { const struct vkd3d_shader_compile_arguments *compile_args = compiler->compile_args; - unsigned int i, id; + unsigned int i, id = 0; - for (i = 0, id = 0; i < compile_args->parameter_count; ++i) + for (i = 0; compiler->compile_args && i < compile_args->parameter_count; ++i) { const struct vkd3d_shader_parameter *current = &compile_args->parameters[i]; if (current->type == VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT) - id = max(current->u.specialization_constant.id, id); + id = max(current->u.specialization_constant.id + 1, id); } - compiler->current_spec_constant_id = id + 1; + compiler->current_spec_constant_id = id; } return compiler->current_spec_constant_id++; @@ -2623,9 +2623,6 @@ static uint32_t vkd3d_dxbc_compiler_get_spec_constant(struct vkd3d_dxbc_compiler return compiler->spec_constants[i].id; } - if (!spec_id) - spec_id = vkd3d_dxbc_compiler_alloc_spec_constant_id(compiler); - return vkd3d_dxbc_compiler_emit_spec_constant(compiler, name, spec_id); } @@ -2633,7 +2630,6 @@ static uint32_t vkd3d_dxbc_compiler_emit_uint_shader_parameter(struct vkd3d_dxbc enum vkd3d_shader_parameter_name name) { const struct vkd3d_shader_parameter *parameter; - uint32_t spec_constant_id = 0; if (!(parameter = vkd3d_dxbc_compiler_get_shader_parameter(compiler, name))) { @@ -2643,14 +2639,14 @@ static uint32_t vkd3d_dxbc_compiler_emit_uint_shader_parameter(struct vkd3d_dxbc if (parameter->type == VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT) return vkd3d_dxbc_compiler_get_constant_uint(compiler, parameter->u.immediate_constant.u.u32); - if (parameter->type == VKD3D_SHADER_PARAMETER_TYPE_SPECIALIZATION_CONSTANT) - spec_constant_id = parameter->u.specialization_constant.id; - else - FIXME("Unhandled parameter type %#x.\n", parameter->type); + return vkd3d_dxbc_compiler_get_spec_constant(compiler, name, parameter->u.specialization_constant.id); + + FIXME("Unhandled parameter type %#x.\n", parameter->type); default_parameter: - return vkd3d_dxbc_compiler_get_spec_constant(compiler, name, spec_constant_id); + return vkd3d_dxbc_compiler_get_spec_constant(compiler, + name, vkd3d_dxbc_compiler_alloc_spec_constant_id(compiler)); } static uint32_t vkd3d_dxbc_compiler_emit_construct_vector(struct vkd3d_dxbc_compiler *compiler, -- 2.21.0
[View Less]
2
1
0
0
[PATCH vkd3d 2/9] tests: Add test for sample positions.
by Józef Kucia
29 Apr '19
29 Apr '19
From: Józef Kucia <jkucia(a)codeweavers.com> Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> --- tests/d3d12.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/tests/d3d12.c b/tests/d3d12.c index 5f2e6b1da365..dd13ddf999b9 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -27607,6 +27607,135 @@ static void test_shader_get_render_target_sample_count(void) destroy_test_context(&context); } +static void
…
[View More]
test_shader_sample_position(void) +{ + D3D12_TEXTURE_COPY_LOCATION src_location, dst_location; + ID3D12Resource *texture, *readback_texture; + ID3D12GraphicsCommandList *command_list; + D3D12_HEAP_PROPERTIES heap_properties; + D3D12_RESOURCE_DESC resource_desc; + struct test_context_desc desc; + struct resource_readback rb; + struct test_context context; + ID3D12DescriptorHeap *heap; + ID3D12CommandQueue *queue; + uint32_t sample_index; + unsigned int i; + D3D12_BOX box; + HRESULT hr; + + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; + static const DWORD ps_code[] = + { +#if 0 + uint index; + Texture2DMS<float4> t; + + float4 main() : SV_Target + { + return float4(t.GetSamplePosition(index), 0, 0); + } +#endif + 0x43425844, 0x89611945, 0x2b7e06f0, 0x953a72bb, 0x1590618f, 0x00000001, 0x000000f8, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000080, 0x00000050, 0x00000020, + 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04002058, 0x00107000, 0x00000000, + 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x0900006e, 0x00102032, 0x00000000, 0x00107046, + 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000000, + 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; + + memset(&desc, 0, sizeof(desc)); + desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT; + desc.rt_width = desc.rt_height = 1; + desc.no_root_signature = true; + if (!init_test_context(&context, &desc)) + return; + command_list = context.list; + queue = context.queue; + + context.root_signature = create_texture_root_signature(context.device, + D3D12_SHADER_VISIBILITY_PIXEL, 1, 0); + context.pipeline_state = create_pipeline_state(context.device, + context.root_signature, context.render_target_desc.Format, NULL, &ps, NULL); + + memset(&heap_properties, 0, sizeof(heap_properties)); + heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT; + resource_desc = ID3D12Resource_GetDesc(context.render_target); + resource_desc.SampleDesc.Count = 4; + hr = ID3D12Device_CreateCommittedResource(context.device, + &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, + D3D12_RESOURCE_STATE_COMMON, NULL, &IID_ID3D12Resource, (void **)&texture); + ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + + heap = create_gpu_descriptor_heap(context.device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 16); + readback_texture = create_default_texture(context.device, 4, 1, DXGI_FORMAT_R32G32B32A32_FLOAT, + D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST); + ID3D12Device_CreateShaderResourceView(context.device, texture, NULL, + ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap)); + + transition_resource_state(command_list, + texture, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + + for (sample_index = 0; sample_index < resource_desc.SampleDesc.Count; ++sample_index) + { + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, FALSE, NULL); + ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); + ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state); + ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); + ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); + ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &heap); + ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0, + get_gpu_descriptor_handle(&context, heap, 0)); + ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 1, &sample_index, 0); + ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0); + + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + src_location.pResource = context.render_target; + src_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + src_location.SubresourceIndex = 0; + dst_location.pResource = readback_texture; + dst_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + dst_location.SubresourceIndex = 0; + set_box(&box, 0, 0, 0, 1, 1, 1); + ID3D12GraphicsCommandList_CopyTextureRegion(command_list, &dst_location, sample_index, 0, 0, &src_location, &box); + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); + } + + transition_resource_state(command_list, readback_texture, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE); + + get_texture_readback_with_command_list(readback_texture, 0, &rb, queue, command_list); + for (i = 0; i < resource_desc.SampleDesc.Count; ++i) + { + const struct vec4 *position = get_readback_vec4(&rb, i, 0); + + vkd3d_test_set_context("Sample %u", i); + + ok(-1.0f <= position->x && position->x <= 1.0f, "Unexpected x %.8e.\n", position->x); + ok(-1.0f <= position->y && position->y <= 1.0f, "Unexpected y %.8e.\n", position->y); + ok(!position->z, "Unexpected z %.8e.\n", position->z); + ok(!position->w, "Unexpected w %.8e.\n", position->w); + + if (vkd3d_test_state.debug_level > 0) + trace("Sample %u position {%.8e, %.8e}.\n", i, position->x, position->y); + + vkd3d_test_set_context(NULL); + } + release_resource_readback(&rb); + + ID3D12DescriptorHeap_Release(heap); + ID3D12Resource_Release(texture); + ID3D12Resource_Release(readback_texture); + destroy_test_context(&context); +} + static void test_shader_eval_attribute(void) { D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc; @@ -28623,6 +28752,7 @@ START_TEST(d3d12) run_test(test_sample_mask); run_test(test_coverage); run_test(test_shader_get_render_target_sample_count); + run_test(test_shader_sample_position); run_test(test_shader_eval_attribute); run_test(test_primitive_restart); run_test(test_vertex_shader_stream_output); -- 2.21.0
[View Less]
2
1
0
0
[PATCH vkd3d 1/9] vkd3d-shader: Translate samplepos instructions.
by Józef Kucia
29 Apr '19
29 Apr '19
From: Józef Kucia <jkucia(a)codeweavers.com> This returns standard sample locations. DXC and glslang do the same thing.
https://github.com/khronosgroup/glslang/commit/d4d0b29752c173d2aa8d2d105f2f…
In the long term, we could also add a shader parameter to pass sample positions to the shader compiler. Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> --- libs/vkd3d-shader/spirv.c | 171 ++++++++++++++++++++++++++++++++++---- 1 file changed, 154 insertions(+), 17 deletions(-)
…
[View More]
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 6332ef50394b..22e02f9ffa01 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -1129,6 +1129,12 @@ static uint32_t vkd3d_spirv_build_op_in_bounds_access_chain(struct vkd3d_spirv_b SpvOpInBoundsAccessChain, result_type, base_id, indexes, index_count); } +static uint32_t vkd3d_spirv_build_op_in_bounds_access_chain1(struct vkd3d_spirv_builder *builder, + uint32_t result_type, uint32_t base_id, uint32_t index) +{ + return vkd3d_spirv_build_op_in_bounds_access_chain(builder, result_type, base_id, &index, 1); +} + static uint32_t vkd3d_spirv_build_op_vector_shuffle(struct vkd3d_spirv_builder *builder, uint32_t result_type, uint32_t vector1_id, uint32_t vector2_id, const uint32_t *components, uint32_t component_count) @@ -1340,6 +1346,27 @@ static uint32_t vkd3d_spirv_build_op_shift_right_logical(struct vkd3d_spirv_buil SpvOpShiftRightLogical, result_type, base, shift); } +static uint32_t vkd3d_spirv_build_op_logical_and(struct vkd3d_spirv_builder *builder, + uint32_t result_type, uint32_t operand0, uint32_t operand1) +{ + return vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, + SpvOpLogicalAnd, result_type, operand0, operand1); +} + +static uint32_t vkd3d_spirv_build_op_uless_than(struct vkd3d_spirv_builder *builder, + uint32_t result_type, uint32_t operand0, uint32_t operand1) +{ + return vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, + SpvOpULessThan, result_type, operand0, operand1); +} + +static uint32_t vkd3d_spirv_build_op_uless_than_equal(struct vkd3d_spirv_builder *builder, + uint32_t result_type, uint32_t operand0, uint32_t operand1) +{ + return vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, + SpvOpULessThanEqual, result_type, operand0, operand1); +} + static uint32_t vkd3d_spirv_build_op_convert_utof(struct vkd3d_spirv_builder *builder, uint32_t result_type, uint32_t unsigned_value) { @@ -1989,6 +2016,7 @@ struct vkd3d_dxbc_compiler uint32_t temp_id; unsigned int temp_count; struct vkd3d_hull_shader_variables hs; + uint32_t sample_positions_id; enum vkd3d_shader_type shader_type; @@ -2917,7 +2945,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_load_scalar(struct vkd3d_dxbc_compiler const struct vkd3d_shader_register_info *reg_info) { struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; - uint32_t type_id, ptr_type_id, indexes[1], reg_id, val_id; + uint32_t type_id, ptr_type_id, index, reg_id, val_id; unsigned int component_idx, reg_component_count; enum vkd3d_component_type component_type; unsigned int skipped_component_mask; @@ -2945,9 +2973,8 @@ static uint32_t vkd3d_dxbc_compiler_emit_load_scalar(struct vkd3d_dxbc_compiler if (reg_component_count != 1) { ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, reg_info->storage_class, type_id); - indexes[0] = vkd3d_dxbc_compiler_get_constant_uint(compiler, component_idx); - reg_id = vkd3d_spirv_build_op_in_bounds_access_chain(builder, - ptr_type_id, reg_id, indexes, ARRAY_SIZE(indexes)); + index = vkd3d_dxbc_compiler_get_constant_uint(compiler, component_idx); + reg_id = vkd3d_spirv_build_op_in_bounds_access_chain1(builder, ptr_type_id, reg_id, index); } val_id = vkd3d_spirv_build_op_load(builder, type_id, reg_id, SpvMemoryAccessMaskNone); @@ -3104,7 +3131,7 @@ static void vkd3d_dxbc_compiler_emit_store_scalar(struct vkd3d_dxbc_compiler *co SpvStorageClass storage_class, unsigned int write_mask, uint32_t val_id) { struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; - uint32_t type_id, ptr_type_id, index[1]; + uint32_t type_id, ptr_type_id, index; unsigned int component_idx; if (vkd3d_write_mask_component_count(dst_write_mask) > 1) @@ -3113,8 +3140,8 @@ static void vkd3d_dxbc_compiler_emit_store_scalar(struct vkd3d_dxbc_compiler *co ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id); component_idx = vkd3d_write_mask_get_component_idx(write_mask); component_idx -= vkd3d_write_mask_get_component_idx(dst_write_mask); - index[0] = vkd3d_dxbc_compiler_get_constant_uint(compiler, component_idx); - dst_id = vkd3d_spirv_build_op_in_bounds_access_chain(builder, ptr_type_id, dst_id, index, ARRAY_SIZE(index)); + index = vkd3d_dxbc_compiler_get_constant_uint(compiler, component_idx); + dst_id = vkd3d_spirv_build_op_in_bounds_access_chain1(builder, ptr_type_id, dst_id, index); } vkd3d_spirv_build_op_store(builder, dst_id, val_id, SpvMemoryAccessMaskNone); @@ -3870,8 +3897,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi { ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassInput, type_id); index = vkd3d_dxbc_compiler_get_constant_uint(compiler, i); - val_id = vkd3d_spirv_build_op_in_bounds_access_chain(builder, - ptr_type_id, input_id, &index, 1); + val_id = vkd3d_spirv_build_op_in_bounds_access_chain1(builder, ptr_type_id, input_id, index); dst_reg.idx[0].offset = i; } val_id = vkd3d_spirv_build_op_load(builder, type_id, val_id, SpvMemoryAccessMaskNone); @@ -7704,15 +7730,12 @@ static void vkd3d_dxbc_compiler_emit_resinfo(struct vkd3d_dxbc_compiler *compile vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id); } -static void vkd3d_dxbc_compiler_emit_sample_info(struct vkd3d_dxbc_compiler *compiler, - const struct vkd3d_shader_instruction *instruction) +static uint32_t vkd3d_dxbc_compiler_emit_query_sample_count(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_src_param *src) { struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; - const struct vkd3d_shader_dst_param *dst = instruction->dst; - const struct vkd3d_shader_src_param *src = instruction->src; - uint32_t constituents[VKD3D_VEC4_SIZE]; + struct vkd3d_shader_image image; uint32_t type_id, val_id; - unsigned int i; if (src->reg.type == VKD3DSPR_RASTERIZER) { @@ -7721,8 +7744,6 @@ static void vkd3d_dxbc_compiler_emit_sample_info(struct vkd3d_dxbc_compiler *com } else { - struct vkd3d_shader_image image; - vkd3d_spirv_enable_capability(builder, SpvCapabilityImageQuery); vkd3d_dxbc_compiler_prepare_image(compiler, &image, &src->reg, NULL, VKD3D_IMAGE_FLAG_NONE); @@ -7730,6 +7751,21 @@ static void vkd3d_dxbc_compiler_emit_sample_info(struct vkd3d_dxbc_compiler *com val_id = vkd3d_spirv_build_op_image_query_samples(builder, type_id, image.image_id); } + return val_id; +} + +static void vkd3d_dxbc_compiler_emit_sample_info(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_instruction *instruction) +{ + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + const struct vkd3d_shader_dst_param *dst = instruction->dst; + const struct vkd3d_shader_src_param *src = instruction->src; + uint32_t constituents[VKD3D_VEC4_SIZE]; + uint32_t type_id, val_id; + unsigned int i; + + val_id = vkd3d_dxbc_compiler_emit_query_sample_count(compiler, src); + constituents[0] = val_id; for (i = 1; i < VKD3D_VEC4_SIZE; ++i) constituents[i] = vkd3d_dxbc_compiler_get_constant_uint(compiler, 0); @@ -7754,6 +7790,104 @@ static void vkd3d_dxbc_compiler_emit_sample_info(struct vkd3d_dxbc_compiler *com vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id); } +/* XXX: This is correct only when standard sample positions are used. */ +static void vkd3d_dxbc_compiler_emit_sample_position(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_instruction *instruction) +{ + /* Standard sample locations from the Vulkan spec. */ + static const float standard_sample_positions[][2] = + { + /* 1 sample */ + { 0.0 / 16.0, 0.0 / 16.0}, + /* 2 samples */ + { 4.0 / 16.0, 4.0 / 16.0}, + {-4.0 / 16.0, -4.0 / 16.0}, + /* 4 samples */ + {-2.0 / 16.0, -6.0 / 16.0}, + { 6.0 / 16.0, -2.0 / 16.0}, + {-6.0 / 16.0, 2.0 / 16.0}, + { 2.0 / 16.0, 6.0 / 16.0}, + /* 8 samples */ + { 1.0 / 16.0, -3.0 / 16.0}, + {-1.0 / 16.0, 3.0 / 16.0}, + { 5.0 / 16.0, 1.0 / 16.0}, + {-3.0 / 16.0, -5.0 / 16.0}, + {-5.0 / 16.0, 5.0 / 16.0}, + {-7.0 / 16.0, -1.0 / 16.0}, + { 3.0 / 16.0, 7.0 / 16.0}, + { 7.0 / 16.0, -7.0 / 16.0}, + /* 16 samples */ + { 1.0 / 16.0, 1.0 / 16.0}, + {-1.0 / 16.0, -3.0 / 16.0}, + {-3.0 / 16.0, 2.0 / 16.0}, + { 4.0 / 16.0, -1.0 / 16.0}, + {-5.0 / 16.0, -2.0 / 16.0}, + { 2.0 / 16.0, 5.0 / 16.0}, + { 5.0 / 16.0, 3.0 / 16.0}, + { 3.0 / 16.0, -5.0 / 16.0}, + {-2.0 / 16.0, 6.0 / 16.0}, + { 0.0 / 16.0, -7.0 / 16.0}, + {-4.0 / 16.0, -6.0 / 16.0}, + {-6.0 / 16.0, 4.0 / 16.0}, + {-8.0 / 16.0, 0.0 / 16.0}, + { 7.0 / 16.0, -4.0 / 16.0}, + { 6.0 / 16.0, 7.0 / 16.0}, + {-7.0 / 16.0, -8.0 / 16.0}, + }; + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + uint32_t constituents[ARRAY_SIZE(standard_sample_positions)]; + const struct vkd3d_shader_dst_param *dst = instruction->dst; + uint32_t array_type_id, length_id, index_id, id; + uint32_t sample_count_id, sample_index_id; + uint32_t type_id, bool_id, ptr_type_id; + unsigned int i; + + sample_count_id = vkd3d_dxbc_compiler_emit_query_sample_count(compiler, &instruction->src[0]); + sample_index_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &instruction->src[1], VKD3DSP_WRITEMASK_0); + + type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_UINT, 1); + index_id = vkd3d_spirv_build_op_iadd(builder, type_id, sample_count_id, sample_index_id); + index_id = vkd3d_spirv_build_op_isub(builder, + type_id, index_id, vkd3d_dxbc_compiler_get_constant_uint(compiler, 1)); + + /* Validate sample index. */ + bool_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_BOOL, 1); + id = vkd3d_spirv_build_op_logical_and(builder, bool_id, + vkd3d_spirv_build_op_uless_than(builder, bool_id, sample_index_id, sample_count_id), + vkd3d_spirv_build_op_uless_than_equal(builder, + bool_id, sample_index_id, vkd3d_dxbc_compiler_get_constant_uint(compiler, 16))); + index_id = vkd3d_spirv_build_op_select(builder, type_id, + id, index_id, vkd3d_dxbc_compiler_get_constant_uint(compiler, 0)); + + type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, 2); + if (!(id = compiler->sample_positions_id)) + { + length_id = vkd3d_dxbc_compiler_get_constant_uint(compiler, ARRAY_SIZE(standard_sample_positions)); + array_type_id = vkd3d_spirv_get_op_type_array(builder, type_id, length_id); + + for (i = 0; i < ARRAY_SIZE(standard_sample_positions); ++ i) + { + constituents[i] = vkd3d_dxbc_compiler_get_constant(compiler, + VKD3D_TYPE_FLOAT, 2, (const uint32_t *)standard_sample_positions[i]); + } + + id = vkd3d_spirv_build_op_constant_composite(builder, array_type_id, constituents, ARRAY_SIZE(constituents)); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassPrivate, array_type_id); + id = vkd3d_spirv_build_op_variable(builder, &builder->global_stream, ptr_type_id, SpvStorageClassPrivate, id); + vkd3d_spirv_build_op_name(builder, id, "sample_pos"); + compiler->sample_positions_id = id; + } + + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassPrivate, type_id); + id = vkd3d_spirv_build_op_in_bounds_access_chain1(builder, ptr_type_id, id, index_id); + id = vkd3d_spirv_build_op_load(builder, type_id, id, SpvMemoryAccessMaskNone); + + id = vkd3d_dxbc_compiler_emit_swizzle(compiler, + id, VKD3DSP_WRITEMASK_0 | VKD3DSP_WRITEMASK_1, VKD3D_TYPE_FLOAT, + instruction->src[0].swizzle, dst->write_mask); + vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, id); +} + static void vkd3d_dxbc_compiler_emit_eval_attrib(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { @@ -8208,6 +8342,9 @@ int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler, case VKD3DSIH_SAMPLE_INFO: vkd3d_dxbc_compiler_emit_sample_info(compiler, instruction); break; + case VKD3DSIH_SAMPLE_POS: + vkd3d_dxbc_compiler_emit_sample_position(compiler, instruction); + break; case VKD3DSIH_EVAL_CENTROID: case VKD3DSIH_EVAL_SAMPLE_INDEX: vkd3d_dxbc_compiler_emit_eval_attrib(compiler, instruction); -- 2.21.0
[View Less]
2
1
0
0
[PATCH v3 1/3] wrc: Support Asturian
by Alex Henrie
29 Apr '19
29 Apr '19
From: Enol Puente <enolp(a)softastur.org> Signed-off-by: Enol Puente <enolp(a)softastur.org> Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- include/winnt.rh | 1 + tools/wmc/po.c | 2 ++ tools/wrc/po.c | 2 ++ tools/wrc/utils.c | 1 + 4 files changed, 6 insertions(+) diff --git a/include/winnt.rh b/include/winnt.rh index 50aafb1d96..59791bc996 100644 --- a/include/winnt.rh +++ b/include/winnt.rh @@ -185,6 +185,7 @@ #define LANG_VENDA 0x33 /*
…
[View More]
non standard; keep the number high enough (but < 0xff) */ +#define LANG_ASTURIAN 0xa5 #define LANG_ESPERANTO 0x8f #define LANG_WALON 0x90 #define LANG_CORNISH 0x92 diff --git a/tools/wmc/po.c b/tools/wmc/po.c index 8a8064a25f..bf10c50c63 100644 --- a/tools/wmc/po.c +++ b/tools/wmc/po.c @@ -82,6 +82,8 @@ static const struct { LANG_ARMENIAN, SUBLANG_ARMENIAN_ARMENIA, "hy_AM" }, { LANG_ASSAMESE, SUBLANG_NEUTRAL, "as" }, { LANG_ASSAMESE, SUBLANG_ASSAMESE_INDIA, "as_IN" }, + { LANG_ASTURIAN, SUBLANG_NEUTRAL, "ast" }, + { LANG_ASTURIAN, SUBLANG_DEFAULT, "ast_ES" }, { LANG_AZERBAIJANI, SUBLANG_NEUTRAL, "az" }, { LANG_AZERBAIJANI, SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN,"az_AZ@latin" }, { LANG_AZERBAIJANI, SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC, "az_AZ@cyrillic" }, diff --git a/tools/wrc/po.c b/tools/wrc/po.c index 913a918a69..3f5affd49f 100644 --- a/tools/wrc/po.c +++ b/tools/wrc/po.c @@ -239,6 +239,8 @@ static const struct { LANG_ARMENIAN, SUBLANG_ARMENIAN_ARMENIA, "hy_AM" }, { LANG_ASSAMESE, SUBLANG_NEUTRAL, "as" }, { LANG_ASSAMESE, SUBLANG_ASSAMESE_INDIA, "as_IN" }, + { LANG_ASTURIAN, SUBLANG_NEUTRAL, "ast" }, + { LANG_ASTURIAN, SUBLANG_DEFAULT, "ast_ES" }, { LANG_AZERBAIJANI, SUBLANG_NEUTRAL, "az" }, { LANG_AZERBAIJANI, SUBLANG_AZERBAIJANI_AZERBAIJAN_LATIN,"az_AZ@latin" }, { LANG_AZERBAIJANI, SUBLANG_AZERBAIJANI_AZERBAIJAN_CYRILLIC, "az_AZ@cyrillic" }, diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c index 5533a531f1..a1e07b85b2 100644 --- a/tools/wrc/utils.c +++ b/tools/wrc/utils.c @@ -457,6 +457,7 @@ static const struct lang2cp lang2cps[] = { LANG_ARABIC, SUBLANG_NEUTRAL, 1256 }, { LANG_ARMENIAN, SUBLANG_NEUTRAL, 0 }, { LANG_ASSAMESE, SUBLANG_NEUTRAL, 0 }, + { LANG_ASTURIAN, SUBLANG_NEUTRAL, 1252 }, { LANG_AZERI, SUBLANG_NEUTRAL, 1254 }, { LANG_AZERI, SUBLANG_AZERI_CYRILLIC, 1251 }, { LANG_BASHKIR, SUBLANG_NEUTRAL, 1251 }, -- 2.21.0
[View Less]
3
6
0
0
[PATCH] wintrust: Use the ARRAY_SIZE() macro
by Michael Stefaniuc
29 Apr '19
29 Apr '19
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/wintrust/tests/softpub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/wintrust/tests/softpub.c b/dlls/wintrust/tests/softpub.c index 914f04d7c0..2a4f4f4b25 100644 --- a/dlls/wintrust/tests/softpub.c +++ b/dlls/wintrust/tests/softpub.c @@ -1211,7 +1211,7 @@ static void test_wintrust_digest(void) BOOL ret; int i, j; - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) + for (
…
[View More]
i = 0; i < ARRAY_SIZE(tests); i++) { file = create_temp_file(pathW); ok(file != INVALID_HANDLE_VALUE, "failed to create temporary file\n"); -- 2.20.1
[View Less]
1
0
0
0
[PATCH] mscoree: Remove a redundant NULL check before heap_free()
by Michael Stefaniuc
29 Apr '19
29 Apr '19
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/mscoree/corruntimehost.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c index 95f6a9a892..13619bdc19 100644 --- a/dlls/mscoree/corruntimehost.c +++ b/dlls/mscoree/corruntimehost.c @@ -1707,8 +1707,7 @@ static BOOL try_create_registration_free_com(REFIID clsid, WCHAR *classname, UIN ret = TRUE; end: - if (assembly_info) -
…
[View More]
heap_free(assembly_info); + heap_free(assembly_info); if (guid_info.hActCtx) ReleaseActCtx(guid_info.hActCtx); -- 2.20.1
[View Less]
1
0
0
0
[PATCH] ntdll/tests: Avoid the comma operator
by Michael Stefaniuc
29 Apr '19
29 Apr '19
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/ntdll/tests/exception.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 4f75cc2454..ada28c91eb 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -3274,7 +3274,7 @@ static void test_suspend_process(void) startup.cb = sizeof(startup); sprintf(path_name, "%s exception suspend_process", argv[0]); -
…
[View More]
ret = CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), + ret = CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info); ok(ret, "Failed to create target process.\n"); /* New process signals this event. */ -- 2.20.1
[View Less]
1
0
0
0
[PATCH] d3dcompiler: Implement D3DReadFileToBlob().
by Jactry Zeng
29 Apr '19
29 Apr '19
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com> --- dlls/d3dcompiler_43/blob.c | 54 +++++++++++++++- dlls/d3dcompiler_43/tests/blob.c | 106 +++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 2 deletions(-) diff --git a/dlls/d3dcompiler_43/blob.c b/dlls/d3dcompiler_43/blob.c index f22dc7183d..6b1b20317f 100644 --- a/dlls/d3dcompiler_43/blob.c +++ b/dlls/d3dcompiler_43/blob.c @@ -466,9 +466,59 @@ HRESULT WINAPI D3DStripShader(const void *data, SIZE_T
…
[View More]
data_size, UINT flags, ID HRESULT WINAPI D3DReadFileToBlob(const WCHAR *filename, ID3DBlob **contents) { - FIXME("filename %s, contents %p\n", debugstr_w(filename), contents); + struct d3dcompiler_blob *object; + HANDLE file; + SIZE_T data_size; + DWORD read_size; + HRESULT hr; - return E_NOTIMPL; + TRACE("filename %s, contents %p\n", debugstr_w(filename), contents); + + file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (file == INVALID_HANDLE_VALUE) + return HRESULT_FROM_WIN32(GetLastError()); + + data_size = GetFileSize(file, NULL); + if (data_size == INVALID_FILE_SIZE) + { + CloseHandle(file); + return HRESULT_FROM_WIN32(GetLastError()); + } + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + CloseHandle(file); + return E_OUTOFMEMORY; + } + + hr = d3dcompiler_blob_init(object, data_size); + if (FAILED(hr)) + { + WARN("Failed to initialize blob, hr %#x.\n", hr); + CloseHandle(file); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + if (!ReadFile(file, object->data, data_size, &read_size, NULL) || + (read_size != data_size)) + { + WARN("Failed to read file contents.\n"); + CloseHandle(file); + HeapFree(GetProcessHeap(), 0, object->data); + HeapFree(GetProcessHeap(), 0, object); + return E_FAIL; + } + CloseHandle(file); + object->size = read_size; + + *contents = &object->ID3DBlob_iface; + + TRACE("Returning ID3DBlob %p.\n", *contents); + + return S_OK; } HRESULT WINAPI D3DWriteBlobToFile(ID3DBlob* blob, const WCHAR *filename, BOOL overwrite) diff --git a/dlls/d3dcompiler_43/tests/blob.c b/dlls/d3dcompiler_43/tests/blob.c index 443ed2754c..6a9fa5de8b 100644 --- a/dlls/d3dcompiler_43/tests/blob.c +++ b/dlls/d3dcompiler_43/tests/blob.c @@ -35,6 +35,7 @@ static HRESULT (WINAPI *pD3DCreateBlob)(SIZE_T, ID3DBlob **); static HRESULT (WINAPI *pD3DGetBlobPart)(const void *, SIZE_T, D3D_BLOB_PART, UINT, ID3DBlob **); +static HRESULT (WINAPI *pD3DReadFileToBlob)(const WCHAR *, ID3DBlob **); static HRESULT (WINAPI *pD3DStripShader)(const void *, SIZE_T, UINT, ID3DBlob **); #define MAKE_TAG(ch0, ch1, ch2, ch3) \ @@ -752,6 +753,103 @@ static BOOL load_d3dcompiler(void) return TRUE; } +static BOOL load_d3dcompiler_47(void) +{ + HMODULE module; + + if (!(module = LoadLibraryA("d3dcompiler_47.dll"))) return FALSE; + + pD3DReadFileToBlob = (void*)GetProcAddress(module, "D3DReadFileToBlob"); + return TRUE; +} + +static void create_cso_file(LPCWSTR pathW, void *data, DWORD data_size) +{ + HANDLE file; + DWORD written; + + file = CreateFileW(pathW, GENERIC_READ | GENERIC_WRITE, 0, + NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "File creation failed, at %s, error 0x%08x.\n", + wine_dbgstr_w(pathW), GetLastError()); + + if (data) + { + WriteFile(file, data, data_size, &written, NULL); + ok(written == data_size, "Couldn't write .cso file.\n" ); + } + CloseHandle(file); +} + +/* .cso file compiled by fxc.exe. + HLSL source: + ``` + struct PSInput + { + float4 value : SV_POSITION; + }; + + PSInput main(float4 position : POSITION) + { + PSInput result; + result.value = position; + return result; + } + ``` + */ +static byte test_cso_data[] = +{ + 0x00,0x02,0xfe,0xff,0xfe,0xff,0x14,0x00,0x43,0x54,0x41,0x42,0x1c,0x00,0x00,0x00,0x23,0x00, + 0x00,0x00,0x00,0x02,0xfe,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, + 0x1c,0x00,0x00,0x00,0x76,0x73,0x5f,0x32,0x5f,0x30,0x00,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f, + 0x66,0x74,0x20,0x28,0x52,0x29,0x20,0x48,0x4c,0x53,0x4c,0x20,0x53,0x68,0x61,0x64,0x65,0x72, + 0x20,0x43,0x6f,0x6d,0x70,0x69,0x6c,0x65,0x72,0x20,0x31,0x30,0x2e,0x31,0x00,0xab,0x1f,0x00, + 0x00,0x02,0x00,0x00,0x00,0x80,0x00,0x00,0x0f,0x90,0x01,0x00,0x00,0x02,0x00,0x00,0x0f,0xc0, + 0x00,0x00,0xe4,0x90,0xff,0xff,0x00,0x00 +}; + +static void test_D3DReadFileToBlob(void) +{ + ID3DBlob *blob = NULL; + HRESULT hr; + static const WCHAR filenameW[] = {'t','e','s','t','.','c','s','o',0}; + byte *data_enter; + SIZE_T data_size; + + hr = pD3DReadFileToBlob(filenameW, NULL); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), + "D3DReadFileToBlob returned: 0x%08x.\n", hr); + + hr = pD3DReadFileToBlob(filenameW, &blob); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), + "D3DReadFileToBlob returned: 0x%08x.\n", hr); + + /* Crash on Windows + create_cso_file(filenameW, test_cso_data, sizeof(test_cso_data)); + pD3DReadFileToBlob(filenameW, NULL); + DeleteFileW(filenameW); + */ + + create_cso_file(filenameW, NULL, 0); + hr = pD3DReadFileToBlob(filenameW, &blob); + ok(hr == S_OK, "D3DReadFileToBlob failed: 0x%08x.\n", hr); + data_size = ID3D10Blob_GetBufferSize(blob); + ok(data_size == 0, "got wrong data size: %lu, expected %u.\n", data_size, 0); + DeleteFileW(filenameW); + ID3D10Blob_Release(blob); + + create_cso_file(filenameW, test_cso_data, sizeof(test_cso_data)); + hr = pD3DReadFileToBlob(filenameW, &blob); + ok(hr == S_OK, "D3DReadFileToBlob failed: 0x%08x.\n", hr); + data_size = ID3D10Blob_GetBufferSize(blob); + ok(data_size == sizeof(test_cso_data), "got wrong data size: %lu, expected %u.\n", + data_size, sizeof(test_cso_data)); + data_enter = ID3D10Blob_GetBufferPointer(blob); + ok(!memcmp(data_enter, test_cso_data, sizeof(test_cso_data)), "got wrong data.\n"); + DeleteFileW(filenameW); + ID3D10Blob_Release(blob); +} + START_TEST(blob) { if (!load_d3dcompiler()) @@ -763,4 +861,12 @@ START_TEST(blob) test_create_blob(); test_get_blob_part(); test_get_blob_part2(); + + if (!load_d3dcompiler_47()) + { + win_skip("Could not load d3dcompiler_47.dll\n"); + return; + } + + test_D3DReadFileToBlob(); } -- 2.20.1
[View Less]
2
1
0
0
[PATCH] user32: Add DECLSPEC_HOTPATCH to UnRegisterDeviceNotification Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=47098
by Louis Lenders
29 Apr '19
29 Apr '19
Signed-off-by: Louis Lenders <xerox.xerox2000x(a)gmail.com> --- dlls/user32/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/user32/misc.c b/dlls/user32/misc.c index bd4795a346..6ff0980ecd 100644 --- a/dlls/user32/misc.c +++ b/dlls/user32/misc.c @@ -404,7 +404,7 @@ HDEVNOTIFY WINAPI DECLSPEC_HOTPATCH RegisterDeviceNotificationW(HANDLE hRecipien * UnregisterDeviceNotification (USER32.@) * */ -BOOL WINAPI UnregisterDeviceNotification(HDEVNOTIFY hnd) +
…
[View More]
BOOL WINAPI DECLSPEC_HOTPATCH UnregisterDeviceNotification(HDEVNOTIFY hnd) { FIXME("(handle=%p), STUB!\n", hnd); return TRUE; -- 2.20.1
[View Less]
2
1
0
0
← Newer
1
2
3
4
5
6
7
8
9
...
75
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Results per page:
10
25
50
100
200