mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-15 00:10:25 +01:00
anv: VK_INTEL_performance_query interaction with VK_EXT_private_data
All objects are expected to have the base internal object for private
data storage.
This also fixes a memory leak of a gen_perf_registers structure.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 51c6bc13ce ("anv,vulkan: Implement VK_EXT_private_data")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6255>
This commit is contained in:
parent
5d52c26e78
commit
b6a013ccab
2 changed files with 44 additions and 15 deletions
|
|
@ -180,24 +180,38 @@ VkResult anv_AcquirePerformanceConfigurationINTEL(
|
|||
VkPerformanceConfigurationINTEL* pConfiguration)
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
int ret = -1;
|
||||
struct anv_performance_configuration_intel *config;
|
||||
|
||||
config = vk_alloc(&device->vk.alloc, sizeof(*config), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
||||
if (!config)
|
||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG))) {
|
||||
struct gen_perf_registers *perf_config =
|
||||
config->register_config =
|
||||
gen_perf_load_configuration(device->physical->perf, device->fd,
|
||||
GEN_PERF_QUERY_GUID_MDAPI);
|
||||
if (!perf_config)
|
||||
return VK_INCOMPLETE;
|
||||
|
||||
ret = gen_perf_store_configuration(device->physical->perf, device->fd,
|
||||
perf_config, NULL /* guid */);
|
||||
if (ret < 0) {
|
||||
ralloc_free(perf_config);
|
||||
if (!config->register_config) {
|
||||
vk_free(&device->vk.alloc, config);
|
||||
return VK_INCOMPLETE;
|
||||
}
|
||||
|
||||
int ret =
|
||||
gen_perf_store_configuration(device->physical->perf, device->fd,
|
||||
config->register_config, NULL /* guid */);
|
||||
if (ret < 0) {
|
||||
ralloc_free(config->register_config);
|
||||
vk_free(&device->vk.alloc, config);
|
||||
return VK_INCOMPLETE;
|
||||
}
|
||||
|
||||
config->config_id = ret;
|
||||
}
|
||||
|
||||
*pConfiguration = (VkPerformanceConfigurationINTEL) (uint64_t) ret;
|
||||
vk_object_base_init(&device->vk, &config->base,
|
||||
VK_OBJECT_TYPE_PERFORMANCE_CONFIGURATION_INTEL);
|
||||
|
||||
*pConfiguration = anv_performance_configuration_intel_to_handle(config);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
|
@ -207,10 +221,14 @@ VkResult anv_ReleasePerformanceConfigurationINTEL(
|
|||
VkPerformanceConfigurationINTEL _configuration)
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||
uint64_t config = (uint64_t) _configuration;
|
||||
ANV_FROM_HANDLE(anv_performance_configuration_intel, config, _configuration);
|
||||
|
||||
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG)))
|
||||
gen_ioctl(device->fd, DRM_IOCTL_I915_PERF_REMOVE_CONFIG, &config);
|
||||
gen_ioctl(device->fd, DRM_IOCTL_I915_PERF_REMOVE_CONFIG, &config->config_id);
|
||||
|
||||
ralloc_free(config->register_config);
|
||||
vk_object_base_finish(&config->base);
|
||||
vk_free(&device->vk.alloc, config);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
|
@ -220,17 +238,17 @@ VkResult anv_QueueSetPerformanceConfigurationINTEL(
|
|||
VkPerformanceConfigurationINTEL _configuration)
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_queue, queue, _queue);
|
||||
ANV_FROM_HANDLE(anv_performance_configuration_intel, config, _configuration);
|
||||
struct anv_device *device = queue->device;
|
||||
uint64_t configuration = (uint64_t) _configuration;
|
||||
|
||||
if (likely(!(INTEL_DEBUG & DEBUG_NO_OACONFIG))) {
|
||||
if (device->perf_fd < 0) {
|
||||
device->perf_fd = anv_device_perf_open(device, configuration);
|
||||
device->perf_fd = anv_device_perf_open(device, config->config_id);
|
||||
if (device->perf_fd < 0)
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
} else {
|
||||
int ret = gen_ioctl(device->perf_fd, I915_PERF_IOCTL_CONFIG,
|
||||
(void *)(uintptr_t) _configuration);
|
||||
(void *)(uintptr_t) config->config_id);
|
||||
if (ret < 0)
|
||||
return anv_device_set_lost(device, "i915-perf config failed: %m");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4456,6 +4456,14 @@ anv_get_subpass_id(const struct anv_cmd_state * const cmd_state)
|
|||
return subpass_id;
|
||||
}
|
||||
|
||||
struct anv_performance_configuration_intel {
|
||||
struct vk_object_base base;
|
||||
|
||||
struct gen_perf_registers *register_config;
|
||||
|
||||
uint64_t config_id;
|
||||
};
|
||||
|
||||
struct gen_perf_config *anv_get_perf(const struct gen_device_info *devinfo, int fd);
|
||||
void anv_device_perf_init(struct anv_device *device);
|
||||
void anv_perf_write_pass_results(struct gen_perf_config *perf,
|
||||
|
|
@ -4518,6 +4526,9 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(anv_shader_module, base, VkShaderModule,
|
|||
VK_DEFINE_NONDISP_HANDLE_CASTS(anv_ycbcr_conversion, base,
|
||||
VkSamplerYcbcrConversion,
|
||||
VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(anv_performance_configuration_intel, base,
|
||||
VkPerformanceConfigurationINTEL,
|
||||
VK_OBJECT_TYPE_PERFORMANCE_CONFIGURATION_INTEL)
|
||||
|
||||
/* Gen-specific function declarations */
|
||||
#ifdef genX
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue