libs/vkd3d: Cache the number of valid bits in queue timestamp queries.

This commit is contained in:
Sven Hesse 2017-08-29 15:16:41 +02:00
parent 4bfa651561
commit 5b6bd40464
3 changed files with 23 additions and 0 deletions

View File

@ -3698,6 +3698,7 @@ static HRESULT d3d12_command_queue_init(struct d3d12_command_queue *queue,
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
unsigned int queue_family_index;
uint32_t timestamp_bits;
queue->ID3D12CommandQueue_iface.lpVtbl = &d3d12_command_queue_vtbl;
queue->refcount = 1;
@ -3710,12 +3711,15 @@ static HRESULT d3d12_command_queue_init(struct d3d12_command_queue *queue,
{
case D3D12_COMMAND_LIST_TYPE_DIRECT:
queue_family_index = device->direct_queue_family_index;
timestamp_bits = device->direct_queue_timestamp_bits;
break;
case D3D12_COMMAND_LIST_TYPE_COPY:
queue_family_index = device->copy_queue_family_index;
timestamp_bits = device->copy_queue_timestamp_bits;
break;
case D3D12_COMMAND_LIST_TYPE_COMPUTE:
queue_family_index = device->compute_queue_family_index;
timestamp_bits = device->compute_queue_timestamp_bits;
break;
default:
FIXME("Unhandled command list type %#x.\n", desc->Type);
@ -3730,6 +3734,7 @@ static HRESULT d3d12_command_queue_init(struct d3d12_command_queue *queue,
/* FIXME: Access to VkQueue must be externally synchronized. */
VK_CALL(vkGetDeviceQueue(device->vk_device, queue_family_index, 0, &queue->vk_queue));
queue->vk_queue_family_index = queue_family_index;
queue->vk_queue_timestamp_bits = timestamp_bits;
queue->device = device;
ID3D12Device_AddRef(&device->ID3D12Device_iface);

View File

@ -523,6 +523,7 @@ static HRESULT vkd3d_select_physical_device(struct vkd3d_instance *instance,
static HRESULT vkd3d_create_vk_device(struct d3d12_device *device)
{
unsigned int direct_queue_family_index, copy_queue_family_index, compute_queue_family_index;
uint32_t direct_queue_timestamp_bits, copy_queue_timestamp_bits, compute_queue_timestamp_bits;
const struct vkd3d_vk_instance_procs *vk_procs = &device->vkd3d_instance.vk_procs;
const char *extensions[MAX_DEVICE_EXTENSION_COUNT];
VkQueueFamilyProperties *queue_properties;
@ -571,12 +572,21 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device)
if ((queue_properties[i].queueFlags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT))
== (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT))
{
direct_queue_family_index = i;
direct_queue_timestamp_bits = queue_properties[i].timestampValidBits;
}
if (queue_properties[i].queueFlags & VK_QUEUE_TRANSFER_BIT)
{
copy_queue_family_index = i;
copy_queue_timestamp_bits = queue_properties[i].timestampValidBits;
}
if ((queue_properties[i].queueFlags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT))
== VK_QUEUE_COMPUTE_BIT)
{
compute_queue_family_index = i;
compute_queue_timestamp_bits = queue_properties[i].timestampValidBits;
}
}
vkd3d_free(queue_properties);
@ -596,11 +606,15 @@ static HRESULT vkd3d_create_vk_device(struct d3d12_device *device)
{
/* No compute-only queue family, reuse the direct queue family with graphics and compute. */
compute_queue_family_index = direct_queue_family_index;
compute_queue_timestamp_bits = direct_queue_timestamp_bits;
}
device->direct_queue_family_index = direct_queue_family_index;
device->copy_queue_family_index = copy_queue_family_index;
device->compute_queue_family_index = compute_queue_family_index;
device->direct_queue_timestamp_bits = direct_queue_timestamp_bits;
device->copy_queue_timestamp_bits = copy_queue_timestamp_bits;
device->compute_queue_timestamp_bits = compute_queue_timestamp_bits;
TRACE("Using queue family %u for direct command queues.\n", direct_queue_family_index);
TRACE("Using queue family %u for copy command queues.\n", copy_queue_family_index);
TRACE("Using queue family %u for compute command queues.\n", compute_queue_family_index);

View File

@ -479,6 +479,7 @@ struct d3d12_command_queue
VkQueue vk_queue;
uint32_t vk_queue_family_index;
uint32_t vk_queue_timestamp_bits;
struct d3d12_device *device;
};
@ -527,6 +528,9 @@ struct d3d12_device
unsigned int copy_queue_family_index;
unsigned int compute_queue_family_index;
VkPhysicalDeviceMemoryProperties memory_properties;
uint32_t direct_queue_timestamp_bits;
uint32_t copy_queue_timestamp_bits;
uint32_t compute_queue_timestamp_bits;
struct vkd3d_vulkan_info vk_info;