mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
nvk: use common calibrated timestamp support
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32689>
This commit is contained in:
parent
33ca377fab
commit
491b785fed
2 changed files with 12 additions and 78 deletions
|
|
@ -118,6 +118,14 @@ nvk_slm_area_ensure(struct nvk_device *dev,
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
nvk_device_get_timestamp(struct vk_device *vk_dev, uint64_t *timestamp)
|
||||
{
|
||||
struct nvk_device *dev = container_of(vk_dev, struct nvk_device, vk);
|
||||
*timestamp = nvkmd_dev_get_gpu_timestamp(dev->nvkmd);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
nvk_CreateDevice(VkPhysicalDevice physicalDevice,
|
||||
const VkDeviceCreateInfo *pCreateInfo,
|
||||
|
|
@ -153,6 +161,8 @@ nvk_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
vk_device_set_drm_fd(&dev->vk, nvkmd_dev_get_drm_fd(dev->nvkmd));
|
||||
dev->vk.command_buffer_ops = &nvk_cmd_buffer_ops;
|
||||
|
||||
dev->vk.get_timestamp = nvk_device_get_timestamp;
|
||||
|
||||
result = nvk_upload_queue_init(dev, &dev->upload);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_nvkmd;
|
||||
|
|
@ -317,57 +327,6 @@ nvk_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator)
|
|||
vk_free(&dev->vk.alloc, dev);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
nvk_GetCalibratedTimestampsKHR(VkDevice _device,
|
||||
uint32_t timestampCount,
|
||||
const VkCalibratedTimestampInfoKHR *pTimestampInfos,
|
||||
uint64_t *pTimestamps,
|
||||
uint64_t *pMaxDeviation)
|
||||
{
|
||||
VK_FROM_HANDLE(nvk_device, dev, _device);
|
||||
uint64_t max_clock_period = 0;
|
||||
uint64_t begin, end;
|
||||
int d;
|
||||
|
||||
#ifdef CLOCK_MONOTONIC_RAW
|
||||
begin = vk_clock_gettime(CLOCK_MONOTONIC_RAW);
|
||||
#else
|
||||
begin = vk_clock_gettime(CLOCK_MONOTONIC);
|
||||
#endif
|
||||
|
||||
for (d = 0; d < timestampCount; d++) {
|
||||
switch (pTimestampInfos[d].timeDomain) {
|
||||
case VK_TIME_DOMAIN_DEVICE_KHR:
|
||||
pTimestamps[d] = nvkmd_dev_get_gpu_timestamp(dev->nvkmd);
|
||||
max_clock_period = MAX2(max_clock_period, 1); /* FIXME: Is timestamp period actually 1? */
|
||||
break;
|
||||
case VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR:
|
||||
pTimestamps[d] = vk_clock_gettime(CLOCK_MONOTONIC);
|
||||
max_clock_period = MAX2(max_clock_period, 1);
|
||||
break;
|
||||
|
||||
#ifdef CLOCK_MONOTONIC_RAW
|
||||
case VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR:
|
||||
pTimestamps[d] = begin;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
pTimestamps[d] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CLOCK_MONOTONIC_RAW
|
||||
end = vk_clock_gettime(CLOCK_MONOTONIC_RAW);
|
||||
#else
|
||||
end = vk_clock_gettime(CLOCK_MONOTONIC);
|
||||
#endif
|
||||
|
||||
*pMaxDeviation = vk_time_max_deviation(begin, end, max_clock_period);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult
|
||||
nvk_device_ensure_slm(struct nvk_device *dev,
|
||||
uint32_t slm_bytes_per_lane,
|
||||
|
|
|
|||
|
|
@ -815,7 +815,8 @@ nvk_get_device_properties(const struct nvk_instance *instance,
|
|||
.storageImageSampleCounts = sample_counts,
|
||||
.maxSampleMaskWords = 1,
|
||||
.timestampComputeAndGraphics = true,
|
||||
.timestampPeriod = 1,
|
||||
/* FIXME: Is timestamp period actually 1? */
|
||||
.timestampPeriod = 1.0f,
|
||||
.maxClipDistances = 8,
|
||||
.maxCullDistances = 8,
|
||||
.maxCombinedClipAndCullDistances = 8,
|
||||
|
|
@ -1620,32 +1621,6 @@ nvk_GetPhysicalDeviceQueueFamilyProperties2(
|
|||
}
|
||||
}
|
||||
|
||||
static const VkTimeDomainKHR nvk_time_domains[] = {
|
||||
VK_TIME_DOMAIN_DEVICE_KHR,
|
||||
VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR,
|
||||
#ifdef CLOCK_MONOTONIC_RAW
|
||||
VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR,
|
||||
#endif
|
||||
};
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
nvk_GetPhysicalDeviceCalibrateableTimeDomainsKHR(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
uint32_t *pTimeDomainCount,
|
||||
VkTimeDomainKHR *pTimeDomains)
|
||||
{
|
||||
VK_OUTARRAY_MAKE_TYPED(VkTimeDomainKHR, out, pTimeDomains, pTimeDomainCount);
|
||||
|
||||
for (int d = 0; d < ARRAY_SIZE(nvk_time_domains); d++) {
|
||||
vk_outarray_append_typed(VkTimeDomainKHR, &out, i) {
|
||||
*i = nvk_time_domains[d];
|
||||
}
|
||||
}
|
||||
|
||||
return vk_outarray_status(&out);
|
||||
}
|
||||
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
nvk_GetPhysicalDeviceMultisamplePropertiesEXT(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue