vkd3d: Use UAV counter address binding from descriptor heap.
Instead of binding it via push descriptors at draw time. Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
This commit is contained in:
parent
a76e311c5e
commit
dd13d44bd5
|
@ -2359,9 +2359,6 @@ static void d3d12_command_list_invalidate_root_parameters(struct d3d12_command_l
|
|||
if (bindings->root_signature->descriptor_table_count)
|
||||
bindings->dirty_flags |= VKD3D_PIPELINE_DIRTY_DESCRIPTOR_TABLE_OFFSETS;
|
||||
|
||||
if (bindings->root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_RAW_VA_UAV_COUNTERS)
|
||||
bindings->dirty_flags |= VKD3D_PIPELINE_DIRTY_UAV_COUNTER_BINDING;
|
||||
|
||||
bindings->root_descriptor_dirty_mask = bindings->root_signature->root_descriptor_mask;
|
||||
bindings->root_constant_dirty_mask = bindings->root_signature->root_constant_mask;
|
||||
|
||||
|
@ -2820,7 +2817,6 @@ static void d3d12_command_list_reset_state(struct d3d12_command_list *list,
|
|||
list->command_buffer_pipeline = VK_NULL_HANDLE;
|
||||
list->pso_render_pass = VK_NULL_HANDLE;
|
||||
list->current_render_pass = VK_NULL_HANDLE;
|
||||
list->uav_counter_address_buffer = VK_NULL_HANDLE;
|
||||
|
||||
memset(&list->dynamic_state, 0, sizeof(list->dynamic_state));
|
||||
list->dynamic_state.blend_constants[0] = D3D12_DEFAULT_BLEND_FACTOR_RED;
|
||||
|
@ -3282,35 +3278,6 @@ static void d3d12_command_list_fetch_inline_uniform_block_data(struct d3d12_comm
|
|||
bindings->root_constant_dirty_mask = 0;
|
||||
}
|
||||
|
||||
static bool vk_write_descriptor_set_from_uav_counter_binding(struct d3d12_command_list *list,
|
||||
VkPipelineBindPoint bind_point, VkDescriptorSet vk_descriptor_set,
|
||||
VkWriteDescriptorSet *vk_descriptor_write, VkDescriptorBufferInfo *vk_buffer_info)
|
||||
{
|
||||
struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
|
||||
const struct d3d12_root_signature *root_signature = bindings->root_signature;
|
||||
|
||||
bindings->dirty_flags &= ~VKD3D_PIPELINE_DIRTY_UAV_COUNTER_BINDING;
|
||||
|
||||
if (!list->uav_counter_address_buffer || !(root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_RAW_VA_UAV_COUNTERS))
|
||||
return false;
|
||||
|
||||
vk_buffer_info->buffer = list->uav_counter_address_buffer;
|
||||
vk_buffer_info->offset = 0;
|
||||
vk_buffer_info->range = VK_WHOLE_SIZE;
|
||||
|
||||
vk_descriptor_write->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
vk_descriptor_write->pNext = NULL;
|
||||
vk_descriptor_write->dstSet = vk_descriptor_set;
|
||||
vk_descriptor_write->dstBinding = root_signature->uav_counter_binding.binding;
|
||||
vk_descriptor_write->dstArrayElement = 0;
|
||||
vk_descriptor_write->descriptorCount = 1;
|
||||
vk_descriptor_write->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
vk_descriptor_write->pImageInfo = NULL;
|
||||
vk_descriptor_write->pBufferInfo = vk_buffer_info;
|
||||
vk_descriptor_write->pTexelBufferView = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void d3d12_command_list_update_root_descriptors(struct d3d12_command_list *list,
|
||||
VkPipelineBindPoint bind_point)
|
||||
{
|
||||
|
@ -3322,14 +3289,12 @@ static void d3d12_command_list_update_root_descriptors(struct d3d12_command_list
|
|||
uint32_t inline_uniform_block_data[D3D12_MAX_ROOT_COST];
|
||||
const struct d3d12_root_parameter *root_parameter;
|
||||
VkDescriptorSet descriptor_set = VK_NULL_HANDLE;
|
||||
VkDescriptorBufferInfo uav_counter_descriptor;
|
||||
unsigned int descriptor_write_count = 0;
|
||||
unsigned int root_parameter_index;
|
||||
|
||||
if (!(root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_PUSH_DESCRIPTORS))
|
||||
{
|
||||
/* Ensure that we populate all descriptors if push descriptors cannot be used */
|
||||
bindings->dirty_flags |= VKD3D_PIPELINE_DIRTY_UAV_COUNTER_BINDING;
|
||||
bindings->root_descriptor_dirty_mask |= bindings->root_descriptor_active_mask & root_signature->root_descriptor_mask;
|
||||
|
||||
descriptor_set = d3d12_command_allocator_allocate_descriptor_set(
|
||||
|
@ -3352,13 +3317,6 @@ static void d3d12_command_list_update_root_descriptors(struct d3d12_command_list
|
|||
descriptor_write_count += 1;
|
||||
}
|
||||
|
||||
if (bindings->dirty_flags & VKD3D_PIPELINE_DIRTY_UAV_COUNTER_BINDING)
|
||||
{
|
||||
if (vk_write_descriptor_set_from_uav_counter_binding(list, bind_point,
|
||||
descriptor_set, &descriptor_writes[descriptor_write_count], &uav_counter_descriptor))
|
||||
descriptor_write_count += 1;
|
||||
}
|
||||
|
||||
if (root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_INLINE_UNIFORM_BLOCK)
|
||||
{
|
||||
d3d12_command_list_fetch_inline_uniform_block_data(list, bind_point, inline_uniform_block_data);
|
||||
|
@ -3407,12 +3365,12 @@ static void d3d12_command_list_update_descriptors(struct d3d12_command_list *lis
|
|||
{
|
||||
/* Root constants and descriptor table offsets are part of the root descriptor set */
|
||||
if (bindings->root_descriptor_dirty_mask || bindings->root_constant_dirty_mask
|
||||
|| (bindings->dirty_flags & (VKD3D_PIPELINE_DIRTY_DESCRIPTOR_TABLE_OFFSETS | VKD3D_PIPELINE_DIRTY_UAV_COUNTER_BINDING)))
|
||||
|| (bindings->dirty_flags & VKD3D_PIPELINE_DIRTY_DESCRIPTOR_TABLE_OFFSETS))
|
||||
d3d12_command_list_update_root_descriptors(list, bind_point);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bindings->root_descriptor_dirty_mask || (bindings->dirty_flags & VKD3D_PIPELINE_DIRTY_UAV_COUNTER_BINDING))
|
||||
if (bindings->root_descriptor_dirty_mask)
|
||||
d3d12_command_list_update_root_descriptors(list, bind_point);
|
||||
|
||||
if (bindings->root_constant_dirty_mask)
|
||||
|
@ -5020,7 +4978,6 @@ static void STDMETHODCALLTYPE d3d12_command_list_SetDescriptorHeaps(d3d12_comman
|
|||
{
|
||||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
|
||||
struct vkd3d_bindless_state *bindless_state = &list->device->bindless_state;
|
||||
bool dirty_uav_counters = false;
|
||||
uint64_t dirty_mask = 0;
|
||||
unsigned int i, j;
|
||||
|
||||
|
@ -5042,22 +4999,12 @@ static void STDMETHODCALLTYPE d3d12_command_list_SetDescriptorHeaps(d3d12_comman
|
|||
list->descriptor_heaps[j] = heap->vk_descriptor_sets[set_index++];
|
||||
dirty_mask |= 1ull << j;
|
||||
}
|
||||
|
||||
if (heap->desc.Type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
|
||||
{
|
||||
list->uav_counter_address_buffer = heap->uav_counters.vk_buffer;
|
||||
dirty_uav_counters = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(list->pipeline_bindings); i++)
|
||||
{
|
||||
struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[i];
|
||||
bindings->descriptor_heap_dirty_mask = dirty_mask;
|
||||
|
||||
if (dirty_uav_counters && bindings->root_signature &&
|
||||
(bindings->root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_RAW_VA_UAV_COUNTERS))
|
||||
bindings->dirty_flags |= VKD3D_PIPELINE_DIRTY_UAV_COUNTER_BINDING;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -410,10 +410,6 @@ static HRESULT d3d12_root_signature_info_from_desc(struct d3d12_root_signature_i
|
|||
}
|
||||
|
||||
info->binding_count += desc->NumStaticSamplers;
|
||||
|
||||
/* Account for UAV counter binding */
|
||||
if (info->has_raw_va_uav_counters)
|
||||
info->push_descriptor_count += 1;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -613,13 +609,10 @@ static HRESULT d3d12_root_signature_init_root_descriptors(struct d3d12_root_sign
|
|||
struct vkd3d_shader_resource_binding *binding;
|
||||
VkDescriptorSetLayoutCreateFlags vk_flags;
|
||||
struct d3d12_root_parameter *param;
|
||||
unsigned int i, j, rs_flags;
|
||||
unsigned int i, j;
|
||||
HRESULT hr;
|
||||
|
||||
rs_flags = VKD3D_ROOT_SIGNATURE_USE_INLINE_UNIFORM_BLOCK |
|
||||
VKD3D_ROOT_SIGNATURE_USE_RAW_VA_UAV_COUNTERS;
|
||||
|
||||
if (!info->push_descriptor_count && !(root_signature->flags & rs_flags))
|
||||
if (!info->push_descriptor_count && !(root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_INLINE_UNIFORM_BLOCK))
|
||||
return S_OK;
|
||||
|
||||
if (!(vk_binding_info = vkd3d_malloc(sizeof(*vk_binding_info) * (info->push_descriptor_count + 1))))
|
||||
|
@ -667,21 +660,6 @@ static HRESULT d3d12_root_signature_init_root_descriptors(struct d3d12_root_sign
|
|||
context->vk_binding += 1;
|
||||
}
|
||||
|
||||
if (root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_RAW_VA_UAV_COUNTERS)
|
||||
{
|
||||
vk_binding = &vk_binding_info[j++];
|
||||
vk_binding->binding = context->vk_binding;
|
||||
vk_binding->descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
vk_binding->descriptorCount = 1;
|
||||
vk_binding->stageFlags = VK_SHADER_STAGE_ALL;
|
||||
vk_binding->pImmutableSamplers = NULL;
|
||||
|
||||
root_signature->uav_counter_binding.set = context->vk_set;
|
||||
root_signature->uav_counter_binding.binding = context->vk_binding;
|
||||
|
||||
context->vk_binding += 1;
|
||||
}
|
||||
|
||||
if (root_signature->flags & VKD3D_ROOT_SIGNATURE_USE_INLINE_UNIFORM_BLOCK)
|
||||
{
|
||||
vk_binding = &vk_binding_info[j++];
|
||||
|
@ -859,8 +837,14 @@ static HRESULT d3d12_root_signature_init(struct d3d12_root_signature *root_signa
|
|||
}
|
||||
|
||||
if (info.has_raw_va_uav_counters)
|
||||
{
|
||||
root_signature->flags |= VKD3D_ROOT_SIGNATURE_USE_RAW_VA_UAV_COUNTERS;
|
||||
|
||||
vkd3d_bindless_state_find_binding(&device->bindless_state,
|
||||
VKD3D_BINDLESS_SET_EXTRA_UAV_COUNTER_BUFFER,
|
||||
&root_signature->uav_counter_binding);
|
||||
}
|
||||
|
||||
if (FAILED(hr = d3d12_root_signature_init_root_descriptors(root_signature, desc,
|
||||
&info, &root_signature->push_constant_range, &context,
|
||||
&root_signature->vk_root_descriptor_layout)))
|
||||
|
|
|
@ -1176,7 +1176,6 @@ enum vkd3d_pipeline_dirty_flag
|
|||
{
|
||||
VKD3D_PIPELINE_DIRTY_STATIC_SAMPLER_SET = 0x00000001u,
|
||||
VKD3D_PIPELINE_DIRTY_DESCRIPTOR_TABLE_OFFSETS = 0x00000002u,
|
||||
VKD3D_PIPELINE_DIRTY_UAV_COUNTER_BINDING = 0x00000004u,
|
||||
};
|
||||
|
||||
union vkd3d_descriptor_info
|
||||
|
@ -1303,7 +1302,6 @@ struct d3d12_command_list
|
|||
|
||||
VkRenderPass pso_render_pass;
|
||||
VkRenderPass current_render_pass;
|
||||
VkBuffer uav_counter_address_buffer;
|
||||
struct vkd3d_dynamic_state dynamic_state;
|
||||
struct vkd3d_pipeline_bindings pipeline_bindings[VKD3D_PIPELINE_BIND_POINT_COUNT];
|
||||
|
||||
|
|
Loading…
Reference in New Issue