anv: Use the common dispatch framework

This commit switches ANV to using the new common physical device and
instance base structs as well as the new dispatch framework.  This
should make code sharing between Vulkan drivers much easier.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
This commit is contained in:
Jason Ekstrand 2021-01-23 04:57:21 -06:00 committed by Marge Bot
parent 4e190bc2ae
commit 0be8200839
13 changed files with 108 additions and 1113 deletions

View file

@ -23,7 +23,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/Makefile.sources
ANV_ENTRYPOINTS_GEN_SCRIPT := $(LOCAL_PATH)/vulkan/anv_entrypoints_gen.py
VK_ENTRYPOINTS_GEN_SCRIPT := $(MESA_TOP)/src/vulkan/util/vk_entrypoints_gen.py
ANV_EXTENSIONS_GEN_SCRIPT := $(LOCAL_PATH)/vulkan/anv_extensions_gen.py
ANV_EXTENSIONS_SCRIPT := $(LOCAL_PATH)/vulkan/anv_extensions.py
VULKAN_API_XML := $(MESA_TOP)/src/vulkan/registry/vk.xml
@ -237,20 +237,22 @@ LOCAL_STATIC_LIBRARIES := \
libmesa_vulkan_util \
libmesa_util
# The rule generates both C and H files, but due to some strange
# reason generating the files once leads to link-time issues.
# Work around create them here as well - we're safe from race
# conditions since they are stored in another location.
LOCAL_GENERATED_SOURCES := $(addprefix $(intermediates)/,$(VULKAN_GENERATED_FILES))
$(intermediates)/vulkan/anv_entrypoints.c: $(ANV_ENTRYPOINTS_GEN_SCRIPT) \
$(ANV_EXTENSIONS_SCRIPT) \
ANV_VK_ENTRYPOINTS_GEN_ARGS= \
--proto --weak --prefix anv \
--device-prefix gen7 --device-prefix gen75 \
--device-prefix gen8 --device-prefix gen9 \
--device-prefix gen11 --device-prefix gen12 \
--device-prefix gen125
$(intermediates)/vulkan/anv_entrypoints.c: $(VK_ENTRYPOINTS_GEN_SCRIPT) \
$(VULKAN_API_XML)
@mkdir -p $(dir $@)
$(MESA_PYTHON2) $(ANV_ENTRYPOINTS_GEN_SCRIPT) \
$(MESA_PYTHON2) $(VK_ENTRYPOINTS_GEN_SCRIPT) \
--xml $(VULKAN_API_XML) \
--outdir $(dir $@)
$(ANV_VK_ENTRYPOINTS_GEN_ARGS) \
--out-c $@ --out-h $(dir $@)/anv_entrypoints.h
$(intermediates)/vulkan/anv_entrypoints.h: $(intermediates)/vulkan/anv_entrypoints.c

View file

@ -378,14 +378,24 @@ anv_physical_device_try_create(struct anv_instance *instance,
}
struct anv_physical_device *device =
vk_alloc(&instance->alloc, sizeof(*device), 8,
vk_alloc(&instance->vk.alloc, sizeof(*device), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (device == NULL) {
result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_fd;
}
vk_object_base_init(NULL, &device->base, VK_OBJECT_TYPE_PHYSICAL_DEVICE);
struct vk_physical_device_dispatch_table dispatch_table;
vk_physical_device_dispatch_table_from_entrypoints(
&dispatch_table, &anv_physical_device_entrypoints, true);
result = vk_physical_device_init(&device->vk, &instance->vk,
NULL, /* We set up extensions later */
&dispatch_table);
if (result != VK_SUCCESS) {
vk_error(result);
goto fail_alloc;
}
device->instance = instance;
assert(strlen(path) < ARRAY_SIZE(device->path));
@ -411,7 +421,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
result = vk_errorfi(device->instance, NULL,
VK_ERROR_INITIALIZATION_FAILED,
"failed to get command parser version");
goto fail_alloc;
goto fail_base;
}
}
@ -419,14 +429,14 @@ anv_physical_device_try_create(struct anv_instance *instance,
result = vk_errorfi(device->instance, NULL,
VK_ERROR_INITIALIZATION_FAILED,
"kernel missing gem wait");
goto fail_alloc;
goto fail_base;
}
if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXECBUF2)) {
result = vk_errorfi(device->instance, NULL,
VK_ERROR_INITIALIZATION_FAILED,
"kernel missing execbuf2");
goto fail_alloc;
goto fail_base;
}
if (!device->info.has_llc &&
@ -434,7 +444,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
result = vk_errorfi(device->instance, NULL,
VK_ERROR_INITIALIZATION_FAILED,
"kernel missing wc mmap");
goto fail_alloc;
goto fail_base;
}
device->has_softpin = anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_SOFTPIN);
@ -451,7 +461,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
result = anv_physical_device_init_heaps(device, fd);
if (result != VK_SUCCESS)
goto fail_alloc;
goto fail_base;
device->use_softpin = device->has_softpin &&
device->supports_48bit_addresses;
@ -539,7 +549,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
device->compiler = brw_compiler_create(NULL, &device->info);
if (device->compiler == NULL) {
result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_alloc;
goto fail_base;
}
device->compiler->shader_debug_log = compiler_debug_log;
device->compiler->shader_perf_log = compiler_perf_log;
@ -572,7 +582,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
anv_physical_device_init_disk_cache(device);
if (instance->enabled_extensions.KHR_display) {
if (instance->vk.enabled_extensions.KHR_display) {
master_fd = open(primary_path, O_RDWR | O_CLOEXEC);
if (master_fd >= 0) {
/* prod the device with a GETPARAM call which will fail if
@ -596,7 +606,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
device->perf = anv_get_perf(&device->info, fd);
anv_physical_device_get_supported_extensions(device,
&device->supported_extensions);
&device->vk.supported_extensions);
device->local_fd = fd;
@ -610,8 +620,10 @@ fail_engine_info:
anv_physical_device_free_disk_cache(device);
fail_compiler:
ralloc_free(device->compiler);
fail_base:
vk_physical_device_finish(&device->vk);
fail_alloc:
vk_free(&instance->alloc, device);
vk_free(&instance->vk.alloc, device);
fail_fd:
close(fd);
if (master_fd != -1)
@ -630,8 +642,8 @@ anv_physical_device_destroy(struct anv_physical_device *device)
close(device->local_fd);
if (device->master_fd >= 0)
close(device->master_fd);
vk_object_base_finish(&device->base);
vk_free(&device->instance->alloc, device);
vk_physical_device_finish(&device->vk);
vk_free(&device->instance->vk.alloc, device);
}
static void *
@ -686,10 +698,10 @@ anv_init_dri_options(struct anv_instance *instance)
ARRAY_SIZE(anv_dri_options));
driParseConfigFiles(&instance->dri_options,
&instance->available_dri_options, 0, "anv", NULL,
instance->app_info.app_name,
instance->app_info.app_version,
instance->app_info.engine_name,
instance->app_info.engine_version);
instance->vk.app_info.app_name,
instance->vk.app_info.app_version,
instance->vk.app_info.engine_name,
instance->vk.app_info.engine_version);
}
VkResult anv_CreateInstance(
@ -702,95 +714,25 @@ VkResult anv_CreateInstance(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
struct vk_instance_extension_table enabled_extensions = {};
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
int idx;
for (idx = 0; idx < VK_INSTANCE_EXTENSION_COUNT; idx++) {
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
vk_instance_extensions[idx].extensionName) == 0)
break;
}
if (pAllocator == NULL)
pAllocator = &default_alloc;
if (idx >= VK_INSTANCE_EXTENSION_COUNT)
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
if (!anv_instance_extensions_supported.extensions[idx])
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
enabled_extensions.extensions[idx] = true;
}
instance = vk_alloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
instance = vk_alloc(pAllocator, sizeof(*instance), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!instance)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
vk_object_base_init(NULL, &instance->base, VK_OBJECT_TYPE_INSTANCE);
struct vk_instance_dispatch_table dispatch_table;
vk_instance_dispatch_table_from_entrypoints(
&dispatch_table, &anv_instance_entrypoints, true);
if (pAllocator)
instance->alloc = *pAllocator;
else
instance->alloc = default_alloc;
instance->app_info = (struct anv_app_info) { .api_version = 0 };
if (pCreateInfo->pApplicationInfo) {
const VkApplicationInfo *app = pCreateInfo->pApplicationInfo;
instance->app_info.app_name =
vk_strdup(&instance->alloc, app->pApplicationName,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
instance->app_info.app_version = app->applicationVersion;
instance->app_info.engine_name =
vk_strdup(&instance->alloc, app->pEngineName,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
instance->app_info.engine_version = app->engineVersion;
instance->app_info.api_version = app->apiVersion;
}
if (instance->app_info.api_version == 0)
instance->app_info.api_version = VK_API_VERSION_1_0;
instance->enabled_extensions = enabled_extensions;
for (unsigned i = 0; i < ARRAY_SIZE(instance->dispatch.entrypoints); i++) {
/* Vulkan requires that entrypoints for extensions which have not been
* enabled must not be advertised.
*/
if (!anv_instance_entrypoint_is_enabled(i, instance->app_info.api_version,
&instance->enabled_extensions)) {
instance->dispatch.entrypoints[i] = NULL;
} else {
instance->dispatch.entrypoints[i] =
anv_instance_dispatch_table.entrypoints[i];
}
}
for (unsigned i = 0; i < ARRAY_SIZE(instance->physical_device_dispatch.entrypoints); i++) {
/* Vulkan requires that entrypoints for extensions which have not been
* enabled must not be advertised.
*/
if (!anv_physical_device_entrypoint_is_enabled(i, instance->app_info.api_version,
&instance->enabled_extensions)) {
instance->physical_device_dispatch.entrypoints[i] = NULL;
} else {
instance->physical_device_dispatch.entrypoints[i] =
anv_physical_device_dispatch_table.entrypoints[i];
}
}
for (unsigned i = 0; i < ARRAY_SIZE(instance->device_dispatch.entrypoints); i++) {
/* Vulkan requires that entrypoints for extensions which have not been
* enabled must not be advertised.
*/
if (!anv_device_entrypoint_is_enabled(i, instance->app_info.api_version,
&instance->enabled_extensions, NULL)) {
instance->device_dispatch.entrypoints[i] = NULL;
} else {
instance->device_dispatch.entrypoints[i] =
anv_device_dispatch_table.entrypoints[i];
}
result = vk_instance_init(&instance->vk,
&anv_instance_extensions_supported,
&dispatch_table,
pCreateInfo, pAllocator);
if (result != VK_SUCCESS) {
vk_free(pAllocator, instance);
return vk_error(result);
}
instance->physical_devices_enumerated = false;
@ -798,7 +740,8 @@ VkResult anv_CreateInstance(
result = vk_debug_report_instance_init(&instance->debug_report_callbacks);
if (result != VK_SUCCESS) {
vk_free2(&default_alloc, pAllocator, instance);
vk_instance_finish(&instance->vk);
vk_free(pAllocator, instance);
return vk_error(result);
}
@ -829,9 +772,6 @@ void anv_DestroyInstance(
&instance->physical_devices, link)
anv_physical_device_destroy(pdevice);
vk_free(&instance->alloc, (char *)instance->app_info.app_name);
vk_free(&instance->alloc, (char *)instance->app_info.engine_name);
VG(VALGRIND_DESTROY_MEMPOOL(instance));
vk_debug_report_instance_destroy(&instance->debug_report_callbacks);
@ -841,8 +781,8 @@ void anv_DestroyInstance(
driDestroyOptionCache(&instance->dri_options);
driDestroyOptionInfo(&instance->available_dri_options);
vk_object_base_finish(&instance->base);
vk_free(&instance->alloc, instance);
vk_instance_finish(&instance->vk);
vk_free(&instance->vk.alloc, instance);
}
static VkResult
@ -1000,7 +940,7 @@ void anv_GetPhysicalDeviceFeatures(
pdevice->compiler->scalar_stage[MESA_SHADER_VERTEX] &&
pdevice->compiler->scalar_stage[MESA_SHADER_GEOMETRY];
struct anv_app_info *app_info = &pdevice->instance->app_info;
struct vk_app_info *app_info = &pdevice->instance->vk.app_info;
/* The new DOOM and Wolfenstein games require depthBounds without
* checking for it. They seem to run fine without it so just claim it's
@ -2396,46 +2336,9 @@ PFN_vkVoidFunction anv_GetInstanceProcAddr(
const char* pName)
{
ANV_FROM_HANDLE(anv_instance, instance, _instance);
/* The Vulkan 1.0 spec for vkGetInstanceProcAddr has a table of exactly
* when we have to return valid function pointers, NULL, or it's left
* undefined. See the table for exact details.
*/
if (pName == NULL)
return NULL;
#define LOOKUP_ANV_ENTRYPOINT(entrypoint) \
if (strcmp(pName, "vk" #entrypoint) == 0) \
return (PFN_vkVoidFunction)anv_##entrypoint
LOOKUP_ANV_ENTRYPOINT(EnumerateInstanceExtensionProperties);
LOOKUP_ANV_ENTRYPOINT(EnumerateInstanceLayerProperties);
LOOKUP_ANV_ENTRYPOINT(EnumerateInstanceVersion);
LOOKUP_ANV_ENTRYPOINT(CreateInstance);
/* GetInstanceProcAddr() can also be called with a NULL instance.
* See https://gitlab.khronos.org/vulkan/vulkan/issues/2057
*/
LOOKUP_ANV_ENTRYPOINT(GetInstanceProcAddr);
#undef LOOKUP_ANV_ENTRYPOINT
if (instance == NULL)
return NULL;
int idx = anv_get_instance_entrypoint_index(pName);
if (idx >= 0)
return instance->dispatch.entrypoints[idx];
idx = anv_get_physical_device_entrypoint_index(pName);
if (idx >= 0)
return instance->physical_device_dispatch.entrypoints[idx];
idx = anv_get_device_entrypoint_index(pName);
if (idx >= 0)
return instance->device_dispatch.entrypoints[idx];
return NULL;
return vk_instance_get_proc_addr(&instance->vk,
&anv_instance_entrypoints,
pName);
}
/* With version 1+ of the loader interface the ICD should expose
@ -2459,15 +2362,7 @@ PFN_vkVoidFunction anv_GetDeviceProcAddr(
const char* pName)
{
ANV_FROM_HANDLE(anv_device, device, _device);
if (!device || !pName)
return NULL;
int idx = anv_get_device_entrypoint_index(pName);
if (idx < 0)
return NULL;
return device->dispatch.entrypoints[idx];
return vk_device_get_proc_addr(&device->vk, pName);
}
/* With version 4+ of the loader interface the ICD should expose
@ -2483,15 +2378,7 @@ PFN_vkVoidFunction vk_icdGetPhysicalDeviceProcAddr(
const char* pName)
{
ANV_FROM_HANDLE(anv_instance, instance, _instance);
if (!pName || !instance)
return NULL;
int idx = anv_get_physical_device_entrypoint_index(pName);
if (idx < 0)
return NULL;
return instance->physical_device_dispatch.entrypoints[idx];
return vk_instance_get_physical_device_proc_addr(&instance->vk, pName);
}
@ -2503,7 +2390,7 @@ anv_CreateDebugReportCallbackEXT(VkInstance _instance,
{
ANV_FROM_HANDLE(anv_instance, instance, _instance);
return vk_create_debug_report_callback(&instance->debug_report_callbacks,
pCreateInfo, pAllocator, &instance->alloc,
pCreateInfo, pAllocator, &instance->vk.alloc,
pCallback);
}
@ -2514,7 +2401,7 @@ anv_DestroyDebugReportCallbackEXT(VkInstance _instance,
{
ANV_FROM_HANDLE(anv_instance, instance, _instance);
vk_destroy_debug_report_callback(&instance->debug_report_callbacks,
_callback, pAllocator, &instance->alloc);
_callback, pAllocator, &instance->vk.alloc);
}
void
@ -2610,7 +2497,7 @@ VkResult anv_EnumerateDeviceExtensionProperties(
VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
for (int i = 0; i < VK_DEVICE_EXTENSION_COUNT; i++) {
if (device->supported_extensions.extensions[i]) {
if (device->vk.supported_extensions.extensions[i]) {
vk_outarray_append(&out, prop) {
*prop = vk_device_extensions[i];
}
@ -2786,24 +2673,6 @@ VkResult anv_CreateDevice(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
struct vk_device_extension_table enabled_extensions = { };
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
int idx;
for (idx = 0; idx < VK_DEVICE_EXTENSION_COUNT; idx++) {
if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
vk_device_extensions[idx].extensionName) == 0)
break;
}
if (idx >= VK_DEVICE_EXTENSION_COUNT)
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
if (!physical_device->supported_extensions.extensions[idx])
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
enabled_extensions.extensions[idx] = true;
}
/* Check enabled features */
bool robust_buffer_access = false;
if (pCreateInfo->pEnabledFeatures) {
@ -2854,14 +2723,21 @@ VkResult anv_CreateDevice(
queue_priority ? queue_priority->globalPriority :
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
device = vk_alloc2(&physical_device->instance->alloc, pAllocator,
device = vk_alloc2(&physical_device->instance->vk.alloc, pAllocator,
sizeof(*device), 8,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!device)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
result = vk_device_init(&device->vk, NULL, NULL, pCreateInfo,
&physical_device->instance->alloc, pAllocator);
struct vk_device_dispatch_table dispatch_table;
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
anv_genX(&physical_device->info, device_entrypoints), true);
vk_device_dispatch_table_from_entrypoints(&dispatch_table,
&anv_device_entrypoints, false);
result = vk_device_init(&device->vk, &physical_device->vk,
&dispatch_table, pCreateInfo,
&physical_device->instance->vk.alloc, pAllocator);
if (result != VK_SUCCESS) {
vk_error(result);
goto fail_alloc;
@ -3007,22 +2883,6 @@ VkResult anv_CreateDevice(
device->can_chain_batches = device->info.gen >= 8;
device->robust_buffer_access = robust_buffer_access;
device->enabled_extensions = enabled_extensions;
const struct anv_instance *instance = physical_device->instance;
for (unsigned i = 0; i < ARRAY_SIZE(device->dispatch.entrypoints); i++) {
/* Vulkan requires that entrypoints for extensions which have not been
* enabled must not be advertised.
*/
if (!anv_device_entrypoint_is_enabled(i, instance->app_info.api_version,
&instance->enabled_extensions,
&device->enabled_extensions)) {
device->dispatch.entrypoints[i] = NULL;
} else {
device->dispatch.entrypoints[i] =
anv_resolve_device_entrypoint(&device->info, i);
}
}
if (pthread_mutex_init(&device->mutex, NULL) != 0) {
result = vk_error(VK_ERROR_INITIALIZATION_FAILED);

View file

@ -1,857 +0,0 @@
# coding=utf-8
#
# Copyright © 2015, 2017 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
import argparse
import math
import os
import xml.etree.ElementTree as et
from collections import OrderedDict, namedtuple
from mako.template import Template
from anv_extensions import VkVersion, MAX_API_VERSION, EXTENSIONS
# We generate a static hash table for entry point lookup
# (vkGetProcAddress). We use a linear congruential generator for our hash
# function and a power-of-two size table. The prime numbers are determined
# experimentally.
LAYERS = [
'anv',
'gen7',
'gen75',
'gen8',
'gen9',
'gen11',
'gen12',
'gen125',
]
TEMPLATE_H = Template("""\
/* This file generated from ${filename}, don't edit directly. */
struct anv_instance_dispatch_table {
union {
void *entrypoints[${len(instance_entrypoints)}];
struct {
% for e in instance_entrypoints:
% if e.guard is not None:
#ifdef ${e.guard}
PFN_${e.name} ${e.name};
#else
void *${e.name};
# endif
% else:
PFN_${e.name} ${e.name};
% endif
% endfor
};
};
};
struct anv_physical_device_dispatch_table {
union {
void *entrypoints[${len(physical_device_entrypoints)}];
struct {
% for e in physical_device_entrypoints:
% if e.guard is not None:
#ifdef ${e.guard}
PFN_${e.name} ${e.name};
#else
void *${e.name};
# endif
% else:
PFN_${e.name} ${e.name};
% endif
% endfor
};
};
};
struct anv_device_dispatch_table {
union {
void *entrypoints[${len(device_entrypoints)}];
struct {
% for e in device_entrypoints:
% if e.guard is not None:
#ifdef ${e.guard}
PFN_${e.name} ${e.name};
#else
void *${e.name};
# endif
% else:
PFN_${e.name} ${e.name};
% endif
% endfor
};
};
};
extern const struct anv_instance_dispatch_table anv_instance_dispatch_table;
%for layer in LAYERS:
extern const struct anv_physical_device_dispatch_table ${layer}_physical_device_dispatch_table;
%endfor
%for layer in LAYERS:
extern const struct anv_device_dispatch_table ${layer}_device_dispatch_table;
%endfor
% for e in instance_entrypoints:
% if e.alias and e.alias.enabled:
<% continue %>
% endif
% if e.guard is not None:
#ifdef ${e.guard}
% endif
${e.return_type} ${e.prefixed_name('anv')}(${e.decl_params()});
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
% for e in physical_device_entrypoints:
% if e.alias:
<% continue %>
% endif
% if e.guard is not None:
#ifdef ${e.guard}
% endif
% for layer in LAYERS:
${e.return_type} ${e.prefixed_name(layer)}(${e.decl_params()});
% endfor
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
% for e in device_entrypoints:
% if e.alias and e.alias.enabled:
<% continue %>
% endif
% if e.guard is not None:
#ifdef ${e.guard}
% endif
% for layer in LAYERS:
${e.return_type} ${e.prefixed_name(layer)}(${e.decl_params()});
% endfor
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
""", output_encoding='utf-8')
TEMPLATE_C = Template(u"""\
/*
* Copyright © 2015 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/* This file generated from ${filename}, don't edit directly. */
#include "anv_private.h"
#include "util/macros.h"
struct string_map_entry {
uint32_t name;
uint32_t hash;
uint32_t num;
};
/* We use a big string constant to avoid lots of reloctions from the entry
* point table to lots of little strings. The entries in the entry point table
* store the index into this big string.
*/
<%def name="strmap(strmap, prefix)">
static const char ${prefix}_strings[] =
% for s in strmap.sorted_strings:
"${s.string}\\0"
% endfor
;
static const struct string_map_entry ${prefix}_string_map_entries[] = {
% for s in strmap.sorted_strings:
{ ${s.offset}, ${'{:0=#8x}'.format(s.hash)}, ${s.num} }, /* ${s.string} */
% endfor
};
/* Hash table stats:
* size ${len(strmap.sorted_strings)} entries
* collisions entries:
% for i in range(10):
* ${i}${'+' if i == 9 else ' '} ${strmap.collisions[i]}
% endfor
*/
#define none 0xffff
static const uint16_t ${prefix}_string_map[${strmap.hash_size}] = {
% for e in strmap.mapping:
${ '{:0=#6x}'.format(e) if e >= 0 else 'none' },
% endfor
};
static int
${prefix}_string_map_lookup(const char *str)
{
static const uint32_t prime_factor = ${strmap.prime_factor};
static const uint32_t prime_step = ${strmap.prime_step};
const struct string_map_entry *e;
uint32_t hash, h;
uint16_t i;
const char *p;
hash = 0;
for (p = str; *p; p++)
hash = hash * prime_factor + *p;
h = hash;
while (1) {
i = ${prefix}_string_map[h & ${strmap.hash_mask}];
if (i == none)
return -1;
e = &${prefix}_string_map_entries[i];
if (e->hash == hash && strcmp(str, ${prefix}_strings + e->name) == 0)
return e->num;
h += prime_step;
}
return -1;
}
static const char *
${prefix}_entry_name(int num)
{
for (int i = 0; i < ARRAY_SIZE(${prefix}_string_map_entries); i++) {
if (${prefix}_string_map_entries[i].num == num)
return &${prefix}_strings[${prefix}_string_map_entries[i].name];
}
return NULL;
}
</%def>
${strmap(instance_strmap, 'instance')}
${strmap(physical_device_strmap, 'physical_device')}
${strmap(device_strmap, 'device')}
/* Weak aliases for all potential implementations. These will resolve to
* NULL if they're not defined, which lets the resolve_entrypoint() function
* either pick the correct entry point.
*/
% for e in instance_entrypoints:
% if e.alias and e.alias.enabled:
<% continue %>
% endif
% if e.guard is not None:
#ifdef ${e.guard}
% endif
${e.return_type} ${e.prefixed_name('anv')}(${e.decl_params()}) __attribute__ ((weak));
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
const struct anv_instance_dispatch_table anv_instance_dispatch_table = {
% for e in instance_entrypoints:
% if e.guard is not None:
#ifdef ${e.guard}
% endif
.${e.name} = ${e.prefixed_name('anv')},
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
};
% for e in physical_device_entrypoints:
% if e.alias and e.alias.enabled:
<% continue %>
% endif
% if e.guard is not None:
#ifdef ${e.guard}
% endif
${e.return_type} ${e.prefixed_name('anv')}(${e.decl_params()}) __attribute__ ((weak));
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
const struct anv_physical_device_dispatch_table anv_physical_device_dispatch_table = {
% for e in physical_device_entrypoints:
% if e.guard is not None:
#ifdef ${e.guard}
% endif
.${e.name} = ${e.prefixed_name('anv')},
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
};
% for layer in LAYERS:
% for e in device_entrypoints:
% if e.alias and e.alias.enabled:
<% continue %>
% endif
% if e.guard is not None:
#ifdef ${e.guard}
% endif
% if layer == 'anv':
${e.return_type} __attribute__ ((weak))
${e.prefixed_name('anv')}(${e.decl_params()})
{
% if e.params[0].type == 'VkDevice':
ANV_FROM_HANDLE(anv_device, anv_device, ${e.params[0].name});
return anv_device->dispatch.${e.name}(${e.call_params()});
% elif e.params[0].type == 'VkCommandBuffer':
ANV_FROM_HANDLE(anv_cmd_buffer, anv_cmd_buffer, ${e.params[0].name});
return anv_cmd_buffer->device->dispatch.${e.name}(${e.call_params()});
% elif e.params[0].type == 'VkQueue':
ANV_FROM_HANDLE(anv_queue, anv_queue, ${e.params[0].name});
return anv_queue->device->dispatch.${e.name}(${e.call_params()});
% else:
assert(!"Unhandled device child trampoline case: ${e.params[0].type}");
% endif
}
% else:
${e.return_type} ${e.prefixed_name(layer)}(${e.decl_params()}) __attribute__ ((weak));
% endif
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
const struct anv_device_dispatch_table ${layer}_device_dispatch_table = {
% for e in device_entrypoints:
% if e.guard is not None:
#ifdef ${e.guard}
% endif
.${e.name} = ${e.prefixed_name(layer)},
% if e.guard is not None:
#endif // ${e.guard}
% endif
% endfor
};
% endfor
/** Return true if the core version or extension in which the given entrypoint
* is defined is enabled.
*
* If device is NULL, all device extensions are considered enabled.
*/
bool
anv_instance_entrypoint_is_enabled(int index, uint32_t core_version,
const struct vk_instance_extension_table *instance)
{
switch (index) {
% for e in instance_entrypoints:
case ${e.num}:
/* ${e.name} */
% if e.core_version:
return ${e.core_version.c_vk_version()} <= core_version;
% elif e.extensions:
% for ext in e.extensions:
% if ext.type == 'instance':
if (instance->${ext.name[3:]}) return true;
% else:
/* All device extensions are considered enabled at the instance level */
return true;
% endif
% endfor
return false;
% else:
return true;
% endif
% endfor
default:
return false;
}
}
/** Return true if the core version or extension in which the given entrypoint
* is defined is enabled.
*
* If device is NULL, all device extensions are considered enabled.
*/
bool
anv_physical_device_entrypoint_is_enabled(int index, uint32_t core_version,
const struct vk_instance_extension_table *instance)
{
switch (index) {
% for e in physical_device_entrypoints:
case ${e.num}:
/* ${e.name} */
% if e.core_version:
return ${e.core_version.c_vk_version()} <= core_version;
% elif e.extensions:
% for ext in e.extensions:
% if ext.type == 'instance':
if (instance->${ext.name[3:]}) return true;
% else:
/* All device extensions are considered enabled at the instance level */
return true;
% endif
% endfor
return false;
% else:
return true;
% endif
% endfor
default:
return false;
}
}
/** Return true if the core version or extension in which the given entrypoint
* is defined is enabled.
*
* If device is NULL, all device extensions are considered enabled.
*/
bool
anv_device_entrypoint_is_enabled(int index, uint32_t core_version,
const struct vk_instance_extension_table *instance,
const struct vk_device_extension_table *device)
{
switch (index) {
% for e in device_entrypoints:
case ${e.num}:
/* ${e.name} */
% if e.core_version:
return ${e.core_version.c_vk_version()} <= core_version;
% elif e.extensions:
% for ext in e.extensions:
% if ext.type == 'instance':
<% assert False %>
% else:
if (!device || device->${ext.name[3:]}) return true;
% endif
% endfor
return false;
% else:
return true;
% endif
% endfor
default:
return false;
}
}
int
anv_get_instance_entrypoint_index(const char *name)
{
return instance_string_map_lookup(name);
}
int
anv_get_physical_device_entrypoint_index(const char *name)
{
return physical_device_string_map_lookup(name);
}
int
anv_get_device_entrypoint_index(const char *name)
{
return device_string_map_lookup(name);
}
const char *
anv_get_instance_entry_name(int index)
{
return instance_entry_name(index);
}
const char *
anv_get_physical_device_entry_name(int index)
{
return physical_device_entry_name(index);
}
const char *
anv_get_device_entry_name(int index)
{
return device_entry_name(index);
}
void * __attribute__ ((noinline))
anv_resolve_device_entrypoint(const struct gen_device_info *devinfo, uint32_t index)
{
const struct anv_device_dispatch_table *genX_table;
switch (devinfo->gen) {
case 12:
if (gen_device_info_is_12hp(devinfo)) {
genX_table = &gen125_device_dispatch_table;
} else {
genX_table = &gen12_device_dispatch_table;
}
break;
case 11:
genX_table = &gen11_device_dispatch_table;
break;
case 9:
genX_table = &gen9_device_dispatch_table;
break;
case 8:
genX_table = &gen8_device_dispatch_table;
break;
case 7:
if (devinfo->is_haswell)
genX_table = &gen75_device_dispatch_table;
else
genX_table = &gen7_device_dispatch_table;
break;
default:
unreachable("unsupported gen\\n");
}
if (genX_table->entrypoints[index])
return genX_table->entrypoints[index];
else
return anv_device_dispatch_table.entrypoints[index];
}
void *
anv_lookup_entrypoint(const struct gen_device_info *devinfo, const char *name)
{
int idx = anv_get_instance_entrypoint_index(name);
if (idx >= 0)
return anv_instance_dispatch_table.entrypoints[idx];
idx = anv_get_physical_device_entrypoint_index(name);
if (idx >= 0)
return anv_physical_device_dispatch_table.entrypoints[idx];
idx = anv_get_device_entrypoint_index(name);
if (idx >= 0)
return anv_resolve_device_entrypoint(devinfo, idx);
return NULL;
}""", output_encoding='utf-8')
U32_MASK = 2**32 - 1
PRIME_FACTOR = 5024183
PRIME_STEP = 19
class StringIntMapEntry(object):
def __init__(self, string, num):
self.string = string
self.num = num
# Calculate the same hash value that we will calculate in C.
h = 0
for c in string:
h = ((h * PRIME_FACTOR) + ord(c)) & U32_MASK
self.hash = h
self.offset = None
def round_to_pow2(x):
return 2**int(math.ceil(math.log(x, 2)))
class StringIntMap(object):
def __init__(self):
self.baked = False
self.strings = dict()
def add_string(self, string, num):
assert not self.baked
assert string not in self.strings
assert 0 <= num < 2**31
self.strings[string] = StringIntMapEntry(string, num)
def bake(self):
self.sorted_strings = \
sorted(self.strings.values(), key=lambda x: x.string)
offset = 0
for entry in self.sorted_strings:
entry.offset = offset
offset += len(entry.string) + 1
# Save off some values that we'll need in C
self.hash_size = round_to_pow2(len(self.strings) * 1.25)
self.hash_mask = self.hash_size - 1
self.prime_factor = PRIME_FACTOR
self.prime_step = PRIME_STEP
self.mapping = [-1] * self.hash_size
self.collisions = [0] * 10
for idx, s in enumerate(self.sorted_strings):
level = 0
h = s.hash
while self.mapping[h & self.hash_mask] >= 0:
h = h + PRIME_STEP
level = level + 1
self.collisions[min(level, 9)] += 1
self.mapping[h & self.hash_mask] = idx
EntrypointParam = namedtuple('EntrypointParam', 'type name decl')
class EntrypointBase(object):
def __init__(self, name):
self.name = name
self.alias = None
self.guard = None
self.enabled = False
self.num = None
# Extensions which require this entrypoint
self.core_version = None
self.extensions = []
def prefixed_name(self, prefix):
assert self.name.startswith('vk')
return prefix + '_' + self.name[2:]
class Entrypoint(EntrypointBase):
def __init__(self, name, return_type, params, guard=None):
super(Entrypoint, self).__init__(name)
self.return_type = return_type
self.params = params
self.guard = guard
def is_physical_device_entrypoint(self):
return self.params[0].type in ('VkPhysicalDevice', )
def is_device_entrypoint(self):
return self.params[0].type in ('VkDevice', 'VkCommandBuffer', 'VkQueue')
def decl_params(self):
return ', '.join(p.decl for p in self.params)
def call_params(self):
return ', '.join(p.name for p in self.params)
class EntrypointAlias(EntrypointBase):
def __init__(self, name, entrypoint):
super(EntrypointAlias, self).__init__(name)
self.alias = entrypoint
def is_physical_device_entrypoint(self):
return self.alias.is_physical_device_entrypoint()
def is_device_entrypoint(self):
return self.alias.is_device_entrypoint()
def prefixed_name(self, prefix):
if self.alias.enabled:
return self.alias.prefixed_name(prefix)
return super(EntrypointAlias, self).prefixed_name(prefix)
@property
def params(self):
return self.alias.params
@property
def return_type(self):
return self.alias.return_type
def decl_params(self):
return self.alias.decl_params()
def call_params(self):
return self.alias.call_params()
def get_entrypoints(doc, entrypoints_to_defines):
"""Extract the entry points from the registry."""
entrypoints = OrderedDict()
for command in doc.findall('./commands/command'):
if 'alias' in command.attrib:
alias = command.attrib['name']
target = command.attrib['alias']
entrypoints[alias] = EntrypointAlias(alias, entrypoints[target])
else:
name = command.find('./proto/name').text
ret_type = command.find('./proto/type').text
params = [EntrypointParam(
type=p.find('./type').text,
name=p.find('./name').text,
decl=''.join(p.itertext())
) for p in command.findall('./param')]
guard = entrypoints_to_defines.get(name)
# They really need to be unique
assert name not in entrypoints
entrypoints[name] = Entrypoint(name, ret_type, params, guard)
for feature in doc.findall('./feature'):
assert feature.attrib['api'] == 'vulkan'
version = VkVersion(feature.attrib['number'])
if version > MAX_API_VERSION:
continue
for command in feature.findall('./require/command'):
e = entrypoints[command.attrib['name']]
e.enabled = True
assert e.core_version is None
e.core_version = version
supported_exts = dict((ext.name, ext) for ext in EXTENSIONS)
for extension in doc.findall('.extensions/extension'):
ext_name = extension.attrib['name']
if ext_name not in supported_exts:
continue
ext = supported_exts[ext_name]
ext.type = extension.attrib['type']
for command in extension.findall('./require/command'):
e = entrypoints[command.attrib['name']]
e.enabled = True
assert e.core_version is None
e.extensions.append(ext)
return [e for e in entrypoints.values() if e.enabled]
def get_entrypoints_defines(doc):
"""Maps entry points to extension defines."""
entrypoints_to_defines = {}
platform_define = {}
for platform in doc.findall('./platforms/platform'):
name = platform.attrib['name']
define = platform.attrib['protect']
platform_define[name] = define
for extension in doc.findall('./extensions/extension[@platform]'):
platform = extension.attrib['platform']
define = platform_define[platform]
for entrypoint in extension.findall('./require/command'):
fullname = entrypoint.attrib['name']
entrypoints_to_defines[fullname] = define
return entrypoints_to_defines
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--outdir', help='Where to write the files.',
required=True)
parser.add_argument('--xml',
help='Vulkan API XML file.',
required=True,
action='append',
dest='xml_files')
args = parser.parse_args()
entrypoints = []
for filename in args.xml_files:
doc = et.parse(filename)
entrypoints += get_entrypoints(doc, get_entrypoints_defines(doc))
# Manually add CreateDmaBufImageINTEL for which we don't have an extension
# defined.
entrypoints.append(Entrypoint('vkCreateDmaBufImageINTEL', 'VkResult', [
EntrypointParam('VkDevice', 'device', 'VkDevice device'),
EntrypointParam('VkDmaBufImageCreateInfo', 'pCreateInfo',
'const VkDmaBufImageCreateInfo* pCreateInfo'),
EntrypointParam('VkAllocationCallbacks', 'pAllocator',
'const VkAllocationCallbacks* pAllocator'),
EntrypointParam('VkDeviceMemory', 'pMem', 'VkDeviceMemory* pMem'),
EntrypointParam('VkImage', 'pImage', 'VkImage* pImage')
]))
device_entrypoints = []
physical_device_entrypoints = []
instance_entrypoints = []
for e in entrypoints:
if e.is_device_entrypoint():
device_entrypoints.append(e)
elif e.is_physical_device_entrypoint():
physical_device_entrypoints.append(e)
else:
instance_entrypoints.append(e)
device_strmap = StringIntMap()
for num, e in enumerate(device_entrypoints):
device_strmap.add_string(e.name, num)
e.num = num
device_strmap.bake()
physical_device_strmap = StringIntMap()
for num, e in enumerate(physical_device_entrypoints):
physical_device_strmap.add_string(e.name, num)
e.num = num
physical_device_strmap.bake()
instance_strmap = StringIntMap()
for num, e in enumerate(instance_entrypoints):
instance_strmap.add_string(e.name, num)
e.num = num
instance_strmap.bake()
# For outputting entrypoints.h we generate a anv_EntryPoint() prototype
# per entry point.
try:
with open(os.path.join(args.outdir, 'anv_entrypoints.h'), 'wb') as f:
f.write(TEMPLATE_H.render(instance_entrypoints=instance_entrypoints,
physical_device_entrypoints=physical_device_entrypoints,
device_entrypoints=device_entrypoints,
LAYERS=LAYERS,
filename=os.path.basename(__file__)))
with open(os.path.join(args.outdir, 'anv_entrypoints.c'), 'wb') as f:
f.write(TEMPLATE_C.render(instance_entrypoints=instance_entrypoints,
physical_device_entrypoints=physical_device_entrypoints,
device_entrypoints=device_entrypoints,
LAYERS=LAYERS,
instance_strmap=instance_strmap,
physical_device_strmap=physical_device_strmap,
device_strmap=device_strmap,
filename=os.path.basename(__file__)))
except Exception:
# In the event there's an error, this imports some helpers from mako
# to print a useful stack trace and prints it, then exits with
# status 1, if python is run with debug; otherwise it just raises
# the exception
if __debug__:
import sys
from mako import exceptions
sys.stderr.write(exceptions.text_error_template().render() + '\n')
sys.exit(1)
raise
if __name__ == '__main__':
main()

View file

@ -1277,7 +1277,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
goto fail;
bool ahw_supported =
physical_device->supported_extensions.ANDROID_external_memory_android_hardware_buffer;
physical_device->vk.supported_extensions.ANDROID_external_memory_android_hardware_buffer;
if (ahw_supported && android_usage) {
android_usage->androidHardwareBufferUsage =
@ -1494,7 +1494,7 @@ void anv_GetPhysicalDeviceExternalBufferProperties(
pExternalBufferProperties->externalMemoryProperties = userptr_props;
return;
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
if (physical_device->supported_extensions.ANDROID_external_memory_android_hardware_buffer) {
if (physical_device->vk.supported_extensions.ANDROID_external_memory_android_hardware_buffer) {
pExternalBufferProperties->externalMemoryProperties = android_buffer_props;
return;
}

View file

@ -63,6 +63,8 @@
#include "vk_alloc.h"
#include "vk_debug_report.h"
#include "vk_device.h"
#include "vk_instance.h"
#include "vk_physical_device.h"
/* Pre-declarations needed for WSI entrypoints */
struct wl_surface;
@ -1063,7 +1065,7 @@ struct anv_memory_heap {
};
struct anv_physical_device {
struct vk_object_base base;
struct vk_physical_device vk;
/* Link in anv_instance::physical_devices */
struct list_head link;
@ -1135,8 +1137,6 @@ struct anv_physical_device {
bool always_flush_cache;
struct vk_device_extension_table supported_extensions;
uint32_t eu_total;
uint32_t subslice_total;
@ -1174,16 +1174,7 @@ struct anv_app_info {
};
struct anv_instance {
struct vk_object_base base;
VkAllocationCallbacks alloc;
struct anv_app_info app_info;
struct vk_instance_extension_table enabled_extensions;
struct anv_instance_dispatch_table dispatch;
struct anv_physical_device_dispatch_table physical_device_dispatch;
struct anv_device_dispatch_table device_dispatch;
struct vk_instance vk;
bool physical_devices_enumerated;
struct list_head physical_devices;
@ -1381,8 +1372,6 @@ struct anv_device {
bool can_chain_batches;
bool robust_buffer_access;
bool has_thread_submit;
struct vk_device_extension_table enabled_extensions;
struct anv_device_dispatch_table dispatch;
pthread_mutex_t vma_mutex;
struct util_vma_heap vma_lo;
@ -4515,10 +4504,8 @@ anv_device_entrypoint_is_enabled(int index, uint32_t core_version,
const struct vk_instance_extension_table *instance,
const struct vk_device_extension_table *device);
void *anv_resolve_device_entrypoint(const struct gen_device_info *devinfo,
uint32_t index);
void *anv_lookup_entrypoint(const struct gen_device_info *devinfo,
const char *name);
const struct vk_device_dispatch_table *
anv_get_device_dispatch_table(const struct gen_device_info *devinfo);
static inline uint32_t
anv_get_subpass_id(const struct anv_cmd_state * const cmd_state)
@ -4556,8 +4543,8 @@ void anv_perf_write_pass_results(struct gen_perf_config *perf,
VK_DEFINE_HANDLE_CASTS(anv_cmd_buffer, base, VkCommandBuffer,
VK_OBJECT_TYPE_COMMAND_BUFFER)
VK_DEFINE_HANDLE_CASTS(anv_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE)
VK_DEFINE_HANDLE_CASTS(anv_instance, base, VkInstance, VK_OBJECT_TYPE_INSTANCE)
VK_DEFINE_HANDLE_CASTS(anv_physical_device, base, VkPhysicalDevice,
VK_DEFINE_HANDLE_CASTS(anv_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE)
VK_DEFINE_HANDLE_CASTS(anv_physical_device, vk.base, VkPhysicalDevice,
VK_OBJECT_TYPE_PHYSICAL_DEVICE)
VK_DEFINE_HANDLE_CASTS(anv_queue, base, VkQueue, VK_OBJECT_TYPE_QUEUE)

View file

@ -29,8 +29,8 @@
static PFN_vkVoidFunction
anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
{
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
return anv_lookup_entrypoint(&physical_device->info, pName);
ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
return vk_instance_get_proc_addr_unchecked(&pdevice->instance->vk, pName);
}
static void
@ -83,7 +83,7 @@ anv_init_wsi(struct anv_physical_device *physical_device)
result = wsi_device_init(&physical_device->wsi_device,
anv_physical_device_to_handle(physical_device),
anv_wsi_proc_addr,
&physical_device->instance->alloc,
&physical_device->instance->vk.alloc,
physical_device->master_fd,
&physical_device->instance->dri_options,
false);
@ -103,7 +103,7 @@ void
anv_finish_wsi(struct anv_physical_device *physical_device)
{
wsi_device_finish(&physical_device->wsi_device,
&physical_device->instance->alloc);
&physical_device->instance->vk.alloc);
}
void anv_DestroySurfaceKHR(
@ -117,7 +117,7 @@ void anv_DestroySurfaceKHR(
if (!surface)
return;
vk_free2(&instance->alloc, pAllocator, surface);
vk_free2(&instance->vk.alloc, pAllocator, surface);
}
VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(

View file

@ -185,7 +185,7 @@ anv_CreateDisplayPlaneSurfaceKHR(
if (allocator)
alloc = allocator;
else
alloc = &instance->alloc;
alloc = &instance->vk.alloc;
return wsi_create_display_surface(_instance, alloc, create_info, surface);
}

View file

@ -47,7 +47,7 @@ VkResult anv_CreateWaylandSurfaceKHR(
if (pAllocator)
alloc = pAllocator;
else
alloc = &instance->alloc;
alloc = &instance->vk.alloc;
return wsi_create_wl_surface(alloc, pCreateInfo, pSurface);
}

View file

@ -71,7 +71,7 @@ VkResult anv_CreateXcbSurfaceKHR(
if (pAllocator)
alloc = pAllocator;
else
alloc = &instance->alloc;
alloc = &instance->vk.alloc;
return wsi_create_xcb_surface(alloc, pCreateInfo, pSurface);
}
@ -90,7 +90,7 @@ VkResult anv_CreateXlibSurfaceKHR(
if (pAllocator)
alloc = pAllocator;
else
alloc = &instance->alloc;
alloc = &instance->vk.alloc;
return wsi_create_xlib_surface(alloc, pCreateInfo, pSurface);
}

View file

@ -345,7 +345,7 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
cmd_buffer->state.gfx.primitive_topology = topology;
}
if (cmd_buffer->device->enabled_extensions.EXT_sample_locations &&
if (cmd_buffer->device->vk.enabled_extensions.EXT_sample_locations &&
cmd_buffer->state.gfx.dirty & ANV_CMD_DIRTY_DYNAMIC_SAMPLE_LOCATIONS) {
genX(emit_multisample)(&cmd_buffer->batch,
cmd_buffer->state.gfx.dynamic.sample_locations.samples,

View file

@ -648,7 +648,7 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
}
}
if (cmd_buffer->device->enabled_extensions.EXT_sample_locations &&
if (cmd_buffer->device->vk.enabled_extensions.EXT_sample_locations &&
cmd_buffer->state.gfx.dirty & ANV_CMD_DIRTY_DYNAMIC_SAMPLE_LOCATIONS) {
genX(emit_sample_pattern)(&cmd_buffer->batch,
cmd_buffer->state.gfx.dynamic.sample_locations.samples,

View file

@ -746,7 +746,7 @@ emit_ms_state(struct anv_graphics_pipeline *pipeline,
* default ones will be used either at device initialization time or
* through 3DSTATE_MULTISAMPLE on Gen7/7.5 by passing NULL locations.
*/
if (pipeline->base.device->enabled_extensions.EXT_sample_locations) {
if (pipeline->base.device->vk.enabled_extensions.EXT_sample_locations) {
#if GEN_GEN >= 8
genX(emit_sample_pattern)(&pipeline->base.batch,
pipeline->dynamic_state.sample_locations.samples,

View file

@ -21,14 +21,17 @@
anv_extensions_py = files('anv_extensions.py')
anv_entrypoints = custom_target(
'anv_entrypoints.[ch]',
input : ['anv_entrypoints_gen.py', vk_api_xml],
'anv_entrypoints',
input : [vk_entrypoints_gen, vk_api_xml],
output : ['anv_entrypoints.h', 'anv_entrypoints.c'],
command : [
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
'--outdir', meson.current_build_dir(),
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'anv',
'--device-prefix', 'gen7', '--device-prefix', 'gen75',
'--device-prefix', 'gen8', '--device-prefix', 'gen9',
'--device-prefix', 'gen11', '--device-prefix', 'gen12',
'--device-prefix', 'gen125',
],
depend_files : anv_extensions_py,
)
anv_extensions_c = custom_target(