anv: Drop the instance pointer from anv_device
There are very few times when we actually want to fetch the instance from the anv_device. We can put up with a bit of pain there in exchange for strongly discouraging people from doing this in general. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3461>
This commit is contained in:

committed by
Marge Bot

parent
f0519c9cf9
commit
78ff747408
@@ -71,8 +71,9 @@ compiler_debug_log(void *data, const char *fmt, ...)
|
||||
{
|
||||
char str[MAX_DEBUG_MESSAGE_LENGTH];
|
||||
struct anv_device *device = (struct anv_device *)data;
|
||||
struct anv_instance *instance = device->physical->instance;
|
||||
|
||||
if (list_is_empty(&device->instance->debug_report_callbacks.callbacks))
|
||||
if (list_is_empty(&instance->debug_report_callbacks.callbacks))
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
@@ -80,7 +81,7 @@ compiler_debug_log(void *data, const char *fmt, ...)
|
||||
(void) vsnprintf(str, MAX_DEBUG_MESSAGE_LENGTH, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
vk_debug_report(&device->instance->debug_report_callbacks,
|
||||
vk_debug_report(&instance->debug_report_callbacks,
|
||||
VK_DEBUG_REPORT_DEBUG_BIT_EXT,
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
|
||||
0, 0, 0, "anv", str);
|
||||
@@ -2435,6 +2436,8 @@ VkResult anv_EnumerateDeviceExtensionProperties(
|
||||
static void
|
||||
anv_device_init_dispatch(struct anv_device *device)
|
||||
{
|
||||
const struct anv_instance *instance = device->physical->instance;
|
||||
|
||||
const struct anv_device_dispatch_table *genX_table;
|
||||
switch (device->info.gen) {
|
||||
case 12:
|
||||
@@ -2466,8 +2469,8 @@ anv_device_init_dispatch(struct anv_device *device)
|
||||
/* Vulkan requires that entrypoints for extensions which have not been
|
||||
* enabled must not be advertised.
|
||||
*/
|
||||
if (!anv_device_entrypoint_is_enabled(i, device->instance->app_info.api_version,
|
||||
&device->instance->enabled_extensions,
|
||||
if (!anv_device_entrypoint_is_enabled(i, instance->app_info.api_version,
|
||||
&instance->enabled_extensions,
|
||||
&device->enabled_extensions)) {
|
||||
device->dispatch.entrypoints[i] = NULL;
|
||||
} else if (genX_table->entrypoints[i]) {
|
||||
@@ -2697,7 +2700,6 @@ VkResult anv_CreateDevice(
|
||||
}
|
||||
|
||||
device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
|
||||
device->instance = physical_device->instance;
|
||||
device->physical = physical_device;
|
||||
device->chipset_id = physical_device->chipset_id;
|
||||
device->no_hw = physical_device->no_hw;
|
||||
|
@@ -107,6 +107,8 @@ static void anv_spirv_nir_debug(void *private_data,
|
||||
const char *message)
|
||||
{
|
||||
struct anv_spirv_debug_data *debug_data = private_data;
|
||||
struct anv_instance *instance = debug_data->device->physical->instance;
|
||||
|
||||
static const VkDebugReportFlagsEXT vk_flags[] = {
|
||||
[NIR_SPIRV_DEBUG_LEVEL_INFO] = VK_DEBUG_REPORT_INFORMATION_BIT_EXT,
|
||||
[NIR_SPIRV_DEBUG_LEVEL_WARNING] = VK_DEBUG_REPORT_WARNING_BIT_EXT,
|
||||
@@ -116,7 +118,7 @@ static void anv_spirv_nir_debug(void *private_data,
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "SPIR-V offset %lu: %s", (unsigned long) spirv_offset, message);
|
||||
|
||||
vk_debug_report(&debug_data->device->instance->debug_report_callbacks,
|
||||
vk_debug_report(&instance->debug_report_callbacks,
|
||||
vk_flags[level],
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT,
|
||||
(uint64_t) (uintptr_t) debug_data->module,
|
||||
@@ -1238,7 +1240,7 @@ anv_pipeline_compile_graphics(struct anv_pipeline *pipeline,
|
||||
*/
|
||||
assert(found < __builtin_popcount(pipeline->active_stages));
|
||||
|
||||
vk_debug_report(&pipeline->device->instance->debug_report_callbacks,
|
||||
vk_debug_report(&pipeline->device->physical->instance->debug_report_callbacks,
|
||||
VK_DEBUG_REPORT_WARNING_BIT_EXT |
|
||||
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT,
|
||||
|
@@ -518,7 +518,7 @@ VkResult anv_CreatePipelineCache(
|
||||
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
anv_pipeline_cache_init(cache, device,
|
||||
device->instance->pipeline_cache_enabled);
|
||||
device->physical->instance->pipeline_cache_enabled);
|
||||
|
||||
if (pCreateInfo->initialDataSize > 0)
|
||||
anv_pipeline_cache_load(cache,
|
||||
@@ -656,7 +656,7 @@ anv_device_search_for_kernel(struct anv_device *device,
|
||||
|
||||
#ifdef ENABLE_SHADER_CACHE
|
||||
struct disk_cache *disk_cache = device->physical->disk_cache;
|
||||
if (disk_cache && device->instance->pipeline_cache_enabled) {
|
||||
if (disk_cache && device->physical->instance->pipeline_cache_enabled) {
|
||||
cache_key cache_key;
|
||||
disk_cache_compute_key(disk_cache, key_data, key_size, cache_key);
|
||||
|
||||
|
@@ -1209,7 +1209,6 @@ struct anv_device {
|
||||
|
||||
VkAllocationCallbacks alloc;
|
||||
|
||||
struct anv_instance * instance;
|
||||
struct anv_physical_device * physical;
|
||||
uint32_t chipset_id;
|
||||
bool no_hw;
|
||||
|
@@ -1163,7 +1163,7 @@ emit_cb_state(struct anv_pipeline *pipeline,
|
||||
is_dual_src_blend_factor(a->dstColorBlendFactor) ||
|
||||
is_dual_src_blend_factor(a->srcAlphaBlendFactor) ||
|
||||
is_dual_src_blend_factor(a->dstAlphaBlendFactor))) {
|
||||
vk_debug_report(&device->instance->debug_report_callbacks,
|
||||
vk_debug_report(&device->physical->instance->debug_report_callbacks,
|
||||
VK_DEBUG_REPORT_WARNING_BIT_EXT,
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
|
||||
(uint64_t)(uintptr_t)device,
|
||||
@@ -2088,7 +2088,7 @@ genX(graphics_pipeline_create)(
|
||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
|
||||
|
||||
/* Use the default pipeline cache if none is specified */
|
||||
if (cache == NULL && device->instance->pipeline_cache_enabled)
|
||||
if (cache == NULL && device->physical->instance->pipeline_cache_enabled)
|
||||
cache = &device->default_pipeline_cache;
|
||||
|
||||
pipeline = vk_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8,
|
||||
@@ -2199,7 +2199,7 @@ compute_pipeline_create(
|
||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO);
|
||||
|
||||
/* Use the default pipeline cache if none is specified */
|
||||
if (cache == NULL && device->instance->pipeline_cache_enabled)
|
||||
if (cache == NULL && device->physical->instance->pipeline_cache_enabled)
|
||||
cache = &device->default_pipeline_cache;
|
||||
|
||||
pipeline = vk_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8,
|
||||
|
Reference in New Issue
Block a user