diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index ae7ed927866..30b3893d6ba 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3146,7 +3146,7 @@ VkResult anv_CreateDevice( INSTRUCTION_STATE_POOL_MIN_ADDRESS; } - device->physical = physical_device; + anv_device_set_physical(device, physical_device); /* XXX(chadv): Can we dup() physicalDevice->fd here? */ device->fd = open(physical_device->path, O_RDWR | O_CLOEXEC); @@ -3271,8 +3271,6 @@ VkResult anv_CreateDevice( } } - device->info = &physical_device->info; - device->isl_dev = physical_device->isl_dev; /* On Broadwell and later, we can use batch chaining to more efficiently * implement growing command buffers. Prior to Haswell, the kernel diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 29187380518..39c2b8c6c48 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1410,6 +1410,14 @@ VkResult anv_device_set_bo_tiling(struct anv_device *device, void anv_device_release_bo(struct anv_device *device, struct anv_bo *bo); +static inline void anv_device_set_physical(struct anv_device *device, + struct anv_physical_device *physical_device) +{ + device->physical = physical_device; + device->info = &physical_device->info; + device->isl_dev = physical_device->isl_dev; +} + static inline struct anv_bo * anv_device_lookup_bo(struct anv_device *device, uint32_t gem_handle) { diff --git a/src/intel/vulkan/tests/block_pool_grow_first.c b/src/intel/vulkan/tests/block_pool_grow_first.c index d2d2b4f4a99..109275b07cc 100644 --- a/src/intel/vulkan/tests/block_pool_grow_first.c +++ b/src/intel/vulkan/tests/block_pool_grow_first.c @@ -29,9 +29,7 @@ int main(void) struct anv_physical_device physical_device = { .use_softpin = true, }; - struct anv_device device = { - .physical = &physical_device, - }; + struct anv_device device = {}; struct anv_block_pool pool; /* Create a pool with initial size smaller than the block allocated, so @@ -40,6 +38,7 @@ int main(void) const uint32_t block_size = 16 * 1024; const uint32_t initial_size = block_size / 2; + anv_device_set_physical(&device, &physical_device); pthread_mutex_init(&device.mutex, NULL); anv_bo_cache_init(&device.bo_cache, &device); anv_block_pool_init(&pool, &device, "test", 4096, initial_size); diff --git a/src/intel/vulkan/tests/block_pool_no_free.c b/src/intel/vulkan/tests/block_pool_no_free.c index f7cc85e6be3..e0e24dcc0c4 100644 --- a/src/intel/vulkan/tests/block_pool_no_free.c +++ b/src/intel/vulkan/tests/block_pool_no_free.c @@ -113,11 +113,10 @@ static void run_test() struct anv_physical_device physical_device = { .use_relocations = true, }; - struct anv_device device = { - .physical = &physical_device, - }; + struct anv_device device = {}; struct anv_block_pool pool; + anv_device_set_physical(&device, &physical_device); pthread_mutex_init(&device.mutex, NULL); anv_bo_cache_init(&device.bo_cache, &device); anv_block_pool_init(&pool, &device, "test", 4096, 4096); diff --git a/src/intel/vulkan/tests/state_pool.c b/src/intel/vulkan/tests/state_pool.c index 0b685ca4962..57cfa73d54e 100644 --- a/src/intel/vulkan/tests/state_pool.c +++ b/src/intel/vulkan/tests/state_pool.c @@ -36,11 +36,10 @@ int main(void) { struct anv_physical_device physical_device = { }; - struct anv_device device = { - .physical = &physical_device, - }; + struct anv_device device = {}; struct anv_state_pool state_pool; + anv_device_set_physical(&device, &physical_device); pthread_mutex_init(&device.mutex, NULL); anv_bo_cache_init(&device.bo_cache, &device); diff --git a/src/intel/vulkan/tests/state_pool_free_list_only.c b/src/intel/vulkan/tests/state_pool_free_list_only.c index b5e5146287b..602346fedae 100644 --- a/src/intel/vulkan/tests/state_pool_free_list_only.c +++ b/src/intel/vulkan/tests/state_pool_free_list_only.c @@ -35,11 +35,10 @@ int main(void) { struct anv_physical_device physical_device = { }; - struct anv_device device = { - .physical = &physical_device, - }; + struct anv_device device = {}; struct anv_state_pool state_pool; + anv_device_set_physical(&device, &physical_device); pthread_mutex_init(&device.mutex, NULL); anv_bo_cache_init(&device.bo_cache, &device); anv_state_pool_init(&state_pool, &device, "test", 4096, 0, 4096); diff --git a/src/intel/vulkan/tests/state_pool_no_free.c b/src/intel/vulkan/tests/state_pool_no_free.c index 04245464e79..fe076830406 100644 --- a/src/intel/vulkan/tests/state_pool_no_free.c +++ b/src/intel/vulkan/tests/state_pool_no_free.c @@ -56,11 +56,10 @@ static void *alloc_states(void *_job) static void run_test() { struct anv_physical_device physical_device = { }; - struct anv_device device = { - .physical = &physical_device, - }; + struct anv_device device = {}; struct anv_state_pool state_pool; + anv_device_set_physical(&device, &physical_device); pthread_mutex_init(&device.mutex, NULL); anv_bo_cache_init(&device.bo_cache, &device); anv_state_pool_init(&state_pool, &device, "test", 4096, 0, 64); diff --git a/src/intel/vulkan/tests/state_pool_padding.c b/src/intel/vulkan/tests/state_pool_padding.c index 54e8bc9cde8..0ed72e1e502 100644 --- a/src/intel/vulkan/tests/state_pool_padding.c +++ b/src/intel/vulkan/tests/state_pool_padding.c @@ -29,11 +29,10 @@ int main(void) struct anv_physical_device physical_device = { .use_softpin = true, }; - struct anv_device device = { - .physical = &physical_device, - }; + struct anv_device device = {}; struct anv_state_pool state_pool; + anv_device_set_physical(&device, &physical_device); pthread_mutex_init(&device.mutex, NULL); anv_bo_cache_init(&device.bo_cache, &device); anv_state_pool_init(&state_pool, &device, "test", 4096, 0, 4096);