mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 07:20:10 +01:00
v3dv: add v3d vulkan driver skeleton
Initial commit, mostly a import of the minimum from anv/radv to get a skeleton to start to work with. In includes: * meson files * Copy & adapt entrypoints ane extensions scripts from anv (that were later used on radv) This is a firt approach, but is is likely that we can remove/simplify some things. v2: fix copyright character at broadcom/vulkan/meson.build (Eric) v3: no spaces inside arrays (Dylan) v4: add gnu_symbol_visibility (detected by CI on first Merge attemp) Reviewed-by: Eric Anholt <eric@anholt.net> squash! v3dv: add v3d vulkan driver skeleton Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
parent
bdb1e5aa0a
commit
e5034f0d0d
15 changed files with 1886 additions and 3 deletions
|
|
@ -273,6 +273,7 @@ with_amd_vk = _vulkan_drivers.contains('amd')
|
||||||
with_freedreno_vk = _vulkan_drivers.contains('freedreno')
|
with_freedreno_vk = _vulkan_drivers.contains('freedreno')
|
||||||
with_swrast_vk = _vulkan_drivers.contains('swrast')
|
with_swrast_vk = _vulkan_drivers.contains('swrast')
|
||||||
with_freedreno_kgsl = get_option('freedreno-kgsl')
|
with_freedreno_kgsl = get_option('freedreno-kgsl')
|
||||||
|
with_broadcom_vk = _vulkan_drivers.contains('broadcom')
|
||||||
with_any_vk = _vulkan_drivers.length() != 0
|
with_any_vk = _vulkan_drivers.length() != 0
|
||||||
|
|
||||||
if with_swrast_vk and not with_gallium_softpipe
|
if with_swrast_vk and not with_gallium_softpipe
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ option(
|
||||||
'vulkan-drivers',
|
'vulkan-drivers',
|
||||||
type : 'array',
|
type : 'array',
|
||||||
value : ['auto'],
|
value : ['auto'],
|
||||||
choices : ['auto', 'amd', 'freedreno', 'intel', 'swrast'],
|
choices : ['auto', 'amd', 'broadcom', 'freedreno', 'intel', 'swrast'],
|
||||||
description : 'List of vulkan drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
|
description : 'List of vulkan drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
|
||||||
)
|
)
|
||||||
option(
|
option(
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ subdir('cle')
|
||||||
v3d_versions = ['33', '41', '42']
|
v3d_versions = ['33', '41', '42']
|
||||||
v3d_libs = []
|
v3d_libs = []
|
||||||
|
|
||||||
if with_gallium_v3d
|
if with_gallium_v3d or with_broadcom_vk
|
||||||
subdir('compiler')
|
subdir('compiler')
|
||||||
subdir('qpu')
|
subdir('qpu')
|
||||||
subdir('simulator')
|
subdir('simulator')
|
||||||
|
|
@ -63,3 +63,7 @@ libbroadcom_v3d = static_library(
|
||||||
build_by_default : false,
|
build_by_default : false,
|
||||||
dependencies: [dep_valgrind, dep_thread],
|
dependencies: [dep_valgrind, dep_thread],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if with_broadcom_vk
|
||||||
|
subdir('vulkan')
|
||||||
|
endif
|
||||||
|
|
|
||||||
8
src/broadcom/vulkan/.dir-locals.el
Normal file
8
src/broadcom/vulkan/.dir-locals.el
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
((prog-mode
|
||||||
|
(indent-tabs-mode . nil)
|
||||||
|
(tab-width . 8)
|
||||||
|
(c-basic-offset . 3)
|
||||||
|
(c-file-style . "k&r")
|
||||||
|
(fill-column . 78)
|
||||||
|
)
|
||||||
|
)
|
||||||
3
src/broadcom/vulkan/.editorconfig
Normal file
3
src/broadcom/vulkan/.editorconfig
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[*.{c,h}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 3
|
||||||
113
src/broadcom/vulkan/meson.build
Normal file
113
src/broadcom/vulkan/meson.build
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
# Copyright © 2019 Raspberry Pi
|
||||||
|
#
|
||||||
|
# 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 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.
|
||||||
|
|
||||||
|
v3dv_entrypoints = custom_target(
|
||||||
|
'v3dv_entrypoints.[ch]',
|
||||||
|
input : ['v3dv_entrypoints_gen.py', vk_api_xml],
|
||||||
|
output : ['v3dv_entrypoints.h', 'v3dv_entrypoints.c'],
|
||||||
|
command : [
|
||||||
|
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--outdir',
|
||||||
|
meson.current_build_dir()
|
||||||
|
],
|
||||||
|
depend_files : files('v3dv_extensions.py'),
|
||||||
|
)
|
||||||
|
|
||||||
|
v3dv_extensions_c = custom_target(
|
||||||
|
'v3dv_extensions.c',
|
||||||
|
input : ['v3dv_extensions_gen.py', vk_api_xml],
|
||||||
|
output : 'v3dv_extensions.c',
|
||||||
|
command : [
|
||||||
|
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
||||||
|
'--out-c', '@OUTPUT@',
|
||||||
|
],
|
||||||
|
depend_files : files('v3dv_extensions.py'),
|
||||||
|
)
|
||||||
|
|
||||||
|
v3dv_extensions_h = custom_target(
|
||||||
|
'v3dv_extensions.h',
|
||||||
|
input : ['v3dv_extensions_gen.py', vk_api_xml],
|
||||||
|
output : 'v3dv_extensions.h',
|
||||||
|
command : [
|
||||||
|
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
||||||
|
'--out-h', '@OUTPUT@',
|
||||||
|
],
|
||||||
|
depend_files : files('v3dv_extensions.py'),
|
||||||
|
)
|
||||||
|
|
||||||
|
libv3dv_files = files(
|
||||||
|
'v3dv_device.c',
|
||||||
|
'v3dv_pipeline.c',
|
||||||
|
'v3dv_private.h',
|
||||||
|
'v3dv_util.c',
|
||||||
|
)
|
||||||
|
|
||||||
|
# The vulkan driver only supports version >= 42, which is the version present in
|
||||||
|
# Rpi4. We need to explicitly set it as we are reusing pieces from the GL v3d
|
||||||
|
# driver.
|
||||||
|
v3dv_flags = ['-DV3D_VERSION=42']
|
||||||
|
|
||||||
|
v3dv_deps = [
|
||||||
|
dep_libdrm,
|
||||||
|
idep_vulkan_util,
|
||||||
|
]
|
||||||
|
|
||||||
|
libvulkan_broadcom = shared_library(
|
||||||
|
'vulkan_broadcom',
|
||||||
|
[libv3dv_files, v3dv_entrypoints, v3dv_extensions_c, v3dv_extensions_h, sha1_h],
|
||||||
|
include_directories : [
|
||||||
|
inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_broadcom, inc_compiler, inc_util,
|
||||||
|
],
|
||||||
|
link_with : [
|
||||||
|
libbroadcom_v3d,
|
||||||
|
],
|
||||||
|
dependencies : v3dv_deps,
|
||||||
|
c_args : v3dv_flags,
|
||||||
|
link_args : ['-Wl,--build-id=sha1', ld_args_bsymbolic, ld_args_gc_sections],
|
||||||
|
gnu_symbol_visibility : 'hidden',
|
||||||
|
install : true,
|
||||||
|
)
|
||||||
|
|
||||||
|
if with_symbols_check
|
||||||
|
test(
|
||||||
|
'v3dv symbols check',
|
||||||
|
symbols_check,
|
||||||
|
args : [
|
||||||
|
'--lib', libvulkan_broadcom,
|
||||||
|
'--symbols-file', vulkan_icd_symbols,
|
||||||
|
symbols_check_args,
|
||||||
|
],
|
||||||
|
suite : ['broadcom'],
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
broadcom_icd = custom_target(
|
||||||
|
'broadcom_icd',
|
||||||
|
input : 'v3dv_icd.py',
|
||||||
|
output : 'broadcom_icd.@0@.json'.format(host_machine.cpu()),
|
||||||
|
command : [
|
||||||
|
prog_python, '@INPUT@',
|
||||||
|
'--lib-path', join_paths(get_option('prefix'), get_option('libdir')),
|
||||||
|
'--out', '@OUTPUT@',
|
||||||
|
],
|
||||||
|
depend_files : files('v3dv_extensions.py'),
|
||||||
|
build_by_default : true,
|
||||||
|
install_dir : with_vulkan_icd_dir,
|
||||||
|
install : true,
|
||||||
|
)
|
||||||
241
src/broadcom/vulkan/v3dv_device.c
Normal file
241
src/broadcom/vulkan/v3dv_device.c
Normal file
|
|
@ -0,0 +1,241 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2019 Raspberry Pi
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "v3dv_private.h"
|
||||||
|
#include "vk_util.h"
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
v3dv_EnumerateInstanceExtensionProperties(const char *pLayerName,
|
||||||
|
uint32_t *pPropertyCount,
|
||||||
|
VkExtensionProperties *pProperties)
|
||||||
|
{
|
||||||
|
VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
|
||||||
|
|
||||||
|
for (int i = 0; i < V3DV_INSTANCE_EXTENSION_COUNT; i++) {
|
||||||
|
if (v3dv_instance_extensions_supported.extensions[i]) {
|
||||||
|
vk_outarray_append(&out, prop) {
|
||||||
|
*prop = v3dv_instance_extensions[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vk_outarray_status(&out);
|
||||||
|
}
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
v3dv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
||||||
|
const VkAllocationCallbacks *pAllocator,
|
||||||
|
VkInstance *pInstance)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_DestroyInstance(VkInstance _instance,
|
||||||
|
const VkAllocationCallbacks *pAllocator)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
v3dv_EnumeratePhysicalDevices(VkInstance _instance,
|
||||||
|
uint32_t *pPhysicalDeviceCount,
|
||||||
|
VkPhysicalDevice *pPhysicalDevices)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
|
||||||
|
VkPhysicalDeviceFeatures *pFeatures)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
|
||||||
|
VkPhysicalDeviceProperties *pProperties)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice,
|
||||||
|
uint32_t *pCount,
|
||||||
|
VkQueueFamilyProperties *pQueueFamilyProperties)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_GetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice,
|
||||||
|
VkPhysicalDeviceMemoryProperties *pMemoryProperties)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PFN_vkVoidFunction
|
||||||
|
v3dv_GetInstanceProcAddr(VkInstance _instance,
|
||||||
|
const char *pName)
|
||||||
|
{
|
||||||
|
V3DV_FROM_HANDLE(v3dv_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_V3DV_ENTRYPOINT(entrypoint) \
|
||||||
|
if (strcmp(pName, "vk" #entrypoint) == 0) \
|
||||||
|
return (PFN_vkVoidFunction)v3dv_##entrypoint
|
||||||
|
|
||||||
|
LOOKUP_V3DV_ENTRYPOINT(EnumerateInstanceExtensionProperties);
|
||||||
|
LOOKUP_V3DV_ENTRYPOINT(CreateInstance);
|
||||||
|
|
||||||
|
#undef LOOKUP_V3DV_ENTRYPOINT
|
||||||
|
|
||||||
|
if (instance == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
int idx = v3dv_get_instance_entrypoint_index(pName);
|
||||||
|
if (idx >= 0)
|
||||||
|
return instance->dispatch.entrypoints[idx];
|
||||||
|
|
||||||
|
idx = v3dv_get_physical_device_entrypoint_index(pName);
|
||||||
|
if (idx >= 0)
|
||||||
|
return instance->physicalDevice.dispatch.entrypoints[idx];
|
||||||
|
|
||||||
|
idx = v3dv_get_device_entrypoint_index(pName);
|
||||||
|
if (idx >= 0)
|
||||||
|
return instance->device_dispatch.entrypoints[idx];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* With version 1+ of the loader interface the ICD should expose
|
||||||
|
* vk_icdGetInstanceProcAddr to work around certain LD_PRELOAD issues seen in apps.
|
||||||
|
*/
|
||||||
|
PUBLIC
|
||||||
|
VKAPI_ATTR PFN_vkVoidFunction
|
||||||
|
VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance,
|
||||||
|
const char *pName);
|
||||||
|
|
||||||
|
PUBLIC
|
||||||
|
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
|
||||||
|
vk_icdGetInstanceProcAddr(VkInstance instance,
|
||||||
|
const char* pName)
|
||||||
|
{
|
||||||
|
return v3dv_GetInstanceProcAddr(instance, pName);
|
||||||
|
}
|
||||||
|
|
||||||
|
PFN_vkVoidFunction
|
||||||
|
v3dv_GetDeviceProcAddr(VkDevice _device,
|
||||||
|
const char *pName)
|
||||||
|
{
|
||||||
|
V3DV_FROM_HANDLE(v3dv_device, device, _device);
|
||||||
|
|
||||||
|
if (!device || !pName)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
int idx = v3dv_get_device_entrypoint_index(pName);
|
||||||
|
if (idx < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return device->dispatch.entrypoints[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* With version 4+ of the loader interface the ICD should expose
|
||||||
|
* vk_icdGetPhysicalDeviceProcAddr()
|
||||||
|
*/
|
||||||
|
PUBLIC
|
||||||
|
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
|
||||||
|
vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance,
|
||||||
|
const char* pName);
|
||||||
|
|
||||||
|
PFN_vkVoidFunction
|
||||||
|
vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance,
|
||||||
|
const char* pName)
|
||||||
|
{
|
||||||
|
V3DV_FROM_HANDLE(v3dv_instance, instance, _instance);
|
||||||
|
|
||||||
|
if (!pName || !instance)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
int idx = v3dv_get_physical_device_entrypoint_index(pName);
|
||||||
|
if (idx < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return instance->physicalDevice.dispatch.entrypoints[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
v3dv_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
|
||||||
|
const char *pLayerName,
|
||||||
|
uint32_t *pPropertyCount,
|
||||||
|
VkExtensionProperties *pProperties)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
v3dv_CreateDevice(VkPhysicalDevice physicalDevice,
|
||||||
|
const VkDeviceCreateInfo *pCreateInfo,
|
||||||
|
const VkAllocationCallbacks *pAllocator,
|
||||||
|
VkDevice *pDevice)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_DestroyDevice(VkDevice _device,
|
||||||
|
const VkAllocationCallbacks *pAllocator)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_GetDeviceQueue(VkDevice _device,
|
||||||
|
uint32_t queueNodeIndex,
|
||||||
|
uint32_t queueIndex,
|
||||||
|
VkQueue *pQueue)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
798
src/broadcom/vulkan/v3dv_entrypoints_gen.py
Normal file
798
src/broadcom/vulkan/v3dv_entrypoints_gen.py
Normal file
|
|
@ -0,0 +1,798 @@
|
||||||
|
# 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.cElementTree as et
|
||||||
|
|
||||||
|
from collections import OrderedDict, namedtuple
|
||||||
|
from mako.template import Template
|
||||||
|
|
||||||
|
from v3dv_extensions import VkVersion, MAX_API_VERSION, EXTENSIONS
|
||||||
|
|
||||||
|
# We currently don't use layers in v3dv, but keeping the ability for anv
|
||||||
|
# anyways, so we can use it for device groups.
|
||||||
|
|
||||||
|
LAYERS = [
|
||||||
|
'v3dv'
|
||||||
|
]
|
||||||
|
|
||||||
|
TEMPLATE_H = Template("""\
|
||||||
|
/* This file generated from ${filename}, don't edit directly. */
|
||||||
|
|
||||||
|
struct v3dv_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 v3dv_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 v3dv_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 v3dv_instance_dispatch_table v3dv_instance_dispatch_table;
|
||||||
|
%for layer in LAYERS:
|
||||||
|
extern const struct v3dv_physical_device_dispatch_table ${layer}_physical_device_dispatch_table;
|
||||||
|
%endfor
|
||||||
|
%for layer in LAYERS:
|
||||||
|
extern const struct v3dv_device_dispatch_table ${layer}_device_dispatch_table;
|
||||||
|
%endfor
|
||||||
|
|
||||||
|
% for e in instance_entrypoints:
|
||||||
|
% if e.alias:
|
||||||
|
<% continue %>
|
||||||
|
% endif
|
||||||
|
% if e.guard is not None:
|
||||||
|
#ifdef ${e.guard}
|
||||||
|
% endif
|
||||||
|
${e.return_type} ${e.prefixed_name('v3dv')}(${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:
|
||||||
|
<% 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 "v3dv_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:
|
||||||
|
<% continue %>
|
||||||
|
% endif
|
||||||
|
% if e.guard is not None:
|
||||||
|
#ifdef ${e.guard}
|
||||||
|
% endif
|
||||||
|
${e.return_type} ${e.prefixed_name('v3dv')}(${e.decl_params()}) __attribute__ ((weak));
|
||||||
|
% if e.guard is not None:
|
||||||
|
#endif // ${e.guard}
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
|
||||||
|
const struct v3dv_instance_dispatch_table v3dv_instance_dispatch_table = {
|
||||||
|
% for e in instance_entrypoints:
|
||||||
|
% if e.guard is not None:
|
||||||
|
#ifdef ${e.guard}
|
||||||
|
% endif
|
||||||
|
.${e.name} = ${e.prefixed_name('v3dv')},
|
||||||
|
% if e.guard is not None:
|
||||||
|
#endif // ${e.guard}
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
};
|
||||||
|
|
||||||
|
% for layer in LAYERS:
|
||||||
|
% for e in physical_device_entrypoints:
|
||||||
|
% if e.alias:
|
||||||
|
<% continue %>
|
||||||
|
% endif
|
||||||
|
% if e.guard is not None:
|
||||||
|
#ifdef ${e.guard}
|
||||||
|
% endif
|
||||||
|
% if layer == 'v3dv':
|
||||||
|
${e.return_type} __attribute__ ((weak))
|
||||||
|
${e.prefixed_name('v3dv')}(${e.decl_params()})
|
||||||
|
{
|
||||||
|
% if e.params[0].type == 'VkPhysicalDevice':
|
||||||
|
V3DV_FROM_HANDLE(v3dv_physical_device, v3dv_physical_device, ${e.params[0].name});
|
||||||
|
return v3dv_physical_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 v3dv_physical_device_dispatch_table ${layer}_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(layer)},
|
||||||
|
% if e.guard is not None:
|
||||||
|
#endif // ${e.guard}
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
};
|
||||||
|
% endfor
|
||||||
|
|
||||||
|
|
||||||
|
% for layer in LAYERS:
|
||||||
|
% for e in device_entrypoints:
|
||||||
|
% if e.alias:
|
||||||
|
<% continue %>
|
||||||
|
% endif
|
||||||
|
% if e.guard is not None:
|
||||||
|
#ifdef ${e.guard}
|
||||||
|
% endif
|
||||||
|
% if layer == 'v3dv':
|
||||||
|
${e.return_type} __attribute__ ((weak))
|
||||||
|
${e.prefixed_name('v3dv')}(${e.decl_params()})
|
||||||
|
{
|
||||||
|
% if e.params[0].type == 'VkDevice':
|
||||||
|
V3DV_FROM_HANDLE(v3dv_device, v3dv_device, ${e.params[0].name});
|
||||||
|
return v3dv_device->dispatch.${e.name}(${e.call_params()});
|
||||||
|
% elif e.params[0].type == 'VkCommandBuffer':
|
||||||
|
V3DV_FROM_HANDLE(v3dv_cmd_buffer, v3dv_cmd_buffer, ${e.params[0].name});
|
||||||
|
return v3dv_cmd_buffer->device->dispatch.${e.name}(${e.call_params()});
|
||||||
|
% elif e.params[0].type == 'VkQueue':
|
||||||
|
V3DV_FROM_HANDLE(v3dv_queue, v3dv_queue, ${e.params[0].name});
|
||||||
|
return v3dv_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 v3dv_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
|
||||||
|
v3dv_instance_entrypoint_is_enabled(int index, uint32_t core_version,
|
||||||
|
const struct v3dv_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
|
||||||
|
v3dv_physical_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
||||||
|
const struct v3dv_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
|
||||||
|
v3dv_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
||||||
|
const struct v3dv_instance_extension_table *instance,
|
||||||
|
const struct v3dv_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
|
||||||
|
v3dv_get_instance_entrypoint_index(const char *name)
|
||||||
|
{
|
||||||
|
return instance_string_map_lookup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
v3dv_get_physical_device_entrypoint_index(const char *name)
|
||||||
|
{
|
||||||
|
return physical_device_string_map_lookup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
v3dv_get_device_entrypoint_index(const char *name)
|
||||||
|
{
|
||||||
|
return device_string_map_lookup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
v3dv_get_instance_entry_name(int index)
|
||||||
|
{
|
||||||
|
return instance_entry_name(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
v3dv_get_physical_device_entry_name(int index)
|
||||||
|
{
|
||||||
|
return physical_device_entry_name(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
v3dv_get_device_entry_name(int index)
|
||||||
|
{
|
||||||
|
return device_entry_name(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
v3dv_lookup_entrypoint(const struct v3d_device_info *devinfo, const char *name)
|
||||||
|
{
|
||||||
|
int idx = v3dv_get_instance_entrypoint_index(name);
|
||||||
|
if (idx >= 0)
|
||||||
|
return v3dv_instance_dispatch_table.entrypoints[idx];
|
||||||
|
|
||||||
|
idx = v3dv_get_physical_device_entrypoint_index(name);
|
||||||
|
if (idx >= 0)
|
||||||
|
return v3dv_physical_device_dispatch_table.entrypoints[idx];
|
||||||
|
|
||||||
|
idx = v3dv_get_device_entrypoint_index(name);
|
||||||
|
if (idx >= 0)
|
||||||
|
return v3dv_device_dispatch_table.entrypoints[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 = []
|
||||||
|
|
||||||
|
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 prefixed_name(self, prefix):
|
||||||
|
assert self.name.startswith('vk')
|
||||||
|
return prefix + '_' + self.name[2:]
|
||||||
|
|
||||||
|
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):
|
||||||
|
return self.alias.prefixed_name(prefix)
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
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 v3dv_EntryPoint() prototype
|
||||||
|
# per entry point.
|
||||||
|
try:
|
||||||
|
with open(os.path.join(args.outdir, 'v3dv_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, 'v3dv_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()
|
||||||
137
src/broadcom/vulkan/v3dv_extensions.py
Normal file
137
src/broadcom/vulkan/v3dv_extensions.py
Normal file
|
|
@ -0,0 +1,137 @@
|
||||||
|
COPYRIGHT = """\
|
||||||
|
/*
|
||||||
|
* Copyright 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, sub license, 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 NON-INFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 copy
|
||||||
|
import re
|
||||||
|
|
||||||
|
def _bool_to_c_expr(b):
|
||||||
|
if b is True:
|
||||||
|
return 'true'
|
||||||
|
if b is False:
|
||||||
|
return 'false'
|
||||||
|
return b
|
||||||
|
|
||||||
|
class Extension:
|
||||||
|
def __init__(self, name, ext_version, enable):
|
||||||
|
self.name = name
|
||||||
|
self.ext_version = int(ext_version)
|
||||||
|
self.enable = _bool_to_c_expr(enable)
|
||||||
|
|
||||||
|
class ApiVersion:
|
||||||
|
def __init__(self, version, enable):
|
||||||
|
self.version = version
|
||||||
|
self.enable = _bool_to_c_expr(enable)
|
||||||
|
|
||||||
|
API_PATCH_VERSION = 155
|
||||||
|
|
||||||
|
# Supported API versions. Each one is the maximum patch version for the given
|
||||||
|
# version. Version come in increasing order and each version is available if
|
||||||
|
# it's provided "enable" condition is true and all previous versions are
|
||||||
|
# available.
|
||||||
|
API_VERSIONS = [
|
||||||
|
ApiVersion('1.0', True),
|
||||||
|
|
||||||
|
# FIXME: for now we only support 1.0. We maintain this support from anv just in case in
|
||||||
|
# the future we support more that one version supported.
|
||||||
|
# ApiVersion('1.1', <condition> ),
|
||||||
|
]
|
||||||
|
|
||||||
|
MAX_API_VERSION = None # Computed later
|
||||||
|
|
||||||
|
EXTENSIONS = [
|
||||||
|
#FIXME: for now we don't support additional extensions beyond 1.0. Revisit later
|
||||||
|
]
|
||||||
|
|
||||||
|
# Sort the extension list the way we expect: KHR, then EXT, then vendors
|
||||||
|
# alphabetically. For digits, read them as a whole number sort that.
|
||||||
|
# eg.: VK_KHR_8bit_storage < VK_KHR_16bit_storage < VK_EXT_acquire_xlib_display
|
||||||
|
def extension_order(ext):
|
||||||
|
order = []
|
||||||
|
for substring in re.split('(KHR|EXT|[0-9]+)', ext.name):
|
||||||
|
if substring == 'KHR':
|
||||||
|
order.append(1)
|
||||||
|
if substring == 'EXT':
|
||||||
|
order.append(2)
|
||||||
|
elif substring.isdigit():
|
||||||
|
order.append(int(substring))
|
||||||
|
else:
|
||||||
|
order.append(substring)
|
||||||
|
return order
|
||||||
|
for i in range(len(EXTENSIONS) - 1):
|
||||||
|
if extension_order(EXTENSIONS[i + 1]) < extension_order(EXTENSIONS[i]):
|
||||||
|
print(EXTENSIONS[i + 1].name + ' should come before ' + EXTENSIONS[i].name)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
class VkVersion:
|
||||||
|
def __init__(self, string):
|
||||||
|
split = string.split('.')
|
||||||
|
self.major = int(split[0])
|
||||||
|
self.minor = int(split[1])
|
||||||
|
if len(split) > 2:
|
||||||
|
assert len(split) == 3
|
||||||
|
self.patch = int(split[2])
|
||||||
|
else:
|
||||||
|
self.patch = None
|
||||||
|
|
||||||
|
# Sanity check. The range bits are required by the definition of the
|
||||||
|
# VK_MAKE_VERSION macro
|
||||||
|
assert self.major < 1024 and self.minor < 1024
|
||||||
|
assert self.patch is None or self.patch < 4096
|
||||||
|
assert str(self) == string
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
ver_list = [str(self.major), str(self.minor)]
|
||||||
|
if self.patch is not None:
|
||||||
|
ver_list.append(str(self.patch))
|
||||||
|
return '.'.join(ver_list)
|
||||||
|
|
||||||
|
def c_vk_version(self):
|
||||||
|
patch = self.patch if self.patch is not None else 0
|
||||||
|
ver_list = [str(self.major), str(self.minor), str(patch)]
|
||||||
|
return 'VK_MAKE_VERSION(' + ', '.join(ver_list) + ')'
|
||||||
|
|
||||||
|
def __int_ver(self):
|
||||||
|
# This is just an expansion of VK_VERSION
|
||||||
|
patch = self.patch if self.patch is not None else 0
|
||||||
|
return (self.major << 22) | (self.minor << 12) | patch
|
||||||
|
|
||||||
|
def __gt__(self, other):
|
||||||
|
# If only one of them has a patch version, "ignore" it by making
|
||||||
|
# other's patch version match self.
|
||||||
|
if (self.patch is None) != (other.patch is None):
|
||||||
|
other = copy.copy(other)
|
||||||
|
other.patch = self.patch
|
||||||
|
|
||||||
|
return self.__int_ver() > other.__int_ver()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MAX_API_VERSION = VkVersion('0.0.0')
|
||||||
|
for version in API_VERSIONS:
|
||||||
|
version.version = VkVersion(version.version)
|
||||||
|
version.version.patch = API_PATCH_VERSION
|
||||||
|
assert version.version > MAX_API_VERSION
|
||||||
|
MAX_API_VERSION = version.version
|
||||||
216
src/broadcom/vulkan/v3dv_extensions_gen.py
Normal file
216
src/broadcom/vulkan/v3dv_extensions_gen.py
Normal file
|
|
@ -0,0 +1,216 @@
|
||||||
|
COPYRIGHT = """\
|
||||||
|
/*
|
||||||
|
* Copyright 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, sub license, 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 NON-INFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 xml.etree.cElementTree as et
|
||||||
|
|
||||||
|
from mako.template import Template
|
||||||
|
|
||||||
|
from v3dv_extensions import *
|
||||||
|
|
||||||
|
platform_defines = []
|
||||||
|
|
||||||
|
def _init_exts_from_xml(xml):
|
||||||
|
""" Walk the Vulkan XML and fill out extra extension information. """
|
||||||
|
|
||||||
|
xml = et.parse(xml)
|
||||||
|
|
||||||
|
ext_name_map = {}
|
||||||
|
for ext in EXTENSIONS:
|
||||||
|
ext_name_map[ext.name] = ext
|
||||||
|
|
||||||
|
# KHR_display is missing from the list.
|
||||||
|
platform_defines.append('VK_USE_PLATFORM_DISPLAY_KHR')
|
||||||
|
for platform in xml.findall('./platforms/platform'):
|
||||||
|
platform_defines.append(platform.attrib['protect'])
|
||||||
|
|
||||||
|
for ext_elem in xml.findall('.extensions/extension'):
|
||||||
|
ext_name = ext_elem.attrib['name']
|
||||||
|
if ext_name not in ext_name_map:
|
||||||
|
continue
|
||||||
|
|
||||||
|
ext = ext_name_map[ext_name]
|
||||||
|
ext.type = ext_elem.attrib['type']
|
||||||
|
|
||||||
|
_TEMPLATE_H = Template(COPYRIGHT + """
|
||||||
|
|
||||||
|
#ifndef V3DV_EXTENSIONS_H
|
||||||
|
#define V3DV_EXTENSIONS_H
|
||||||
|
|
||||||
|
#include "stdbool.h"
|
||||||
|
|
||||||
|
#define V3DV_INSTANCE_EXTENSION_COUNT ${len(instance_extensions)}
|
||||||
|
|
||||||
|
extern const VkExtensionProperties v3dv_instance_extensions[];
|
||||||
|
|
||||||
|
struct v3dv_instance_extension_table {
|
||||||
|
union {
|
||||||
|
bool extensions[V3DV_INSTANCE_EXTENSION_COUNT];
|
||||||
|
struct {
|
||||||
|
%for ext in instance_extensions:
|
||||||
|
bool ${ext.name[3:]};
|
||||||
|
%endfor
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const struct v3dv_instance_extension_table v3dv_instance_extensions_supported;
|
||||||
|
|
||||||
|
|
||||||
|
#define V3DV_DEVICE_EXTENSION_COUNT ${len(device_extensions)}
|
||||||
|
|
||||||
|
extern const VkExtensionProperties v3dv_device_extensions[];
|
||||||
|
|
||||||
|
struct v3dv_device_extension_table {
|
||||||
|
union {
|
||||||
|
bool extensions[V3DV_DEVICE_EXTENSION_COUNT];
|
||||||
|
struct {
|
||||||
|
%for ext in device_extensions:
|
||||||
|
bool ${ext.name[3:]};
|
||||||
|
%endfor
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v3dv_physical_device;
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_physical_device_get_supported_extensions(const struct v3dv_physical_device *device,
|
||||||
|
struct v3dv_device_extension_table *extensions);
|
||||||
|
|
||||||
|
#endif /* V3DV_EXTENSIONS_H */
|
||||||
|
""")
|
||||||
|
|
||||||
|
_TEMPLATE_C = Template(COPYRIGHT + """
|
||||||
|
#include "v3dv_private.h"
|
||||||
|
|
||||||
|
#include "vk_util.h"
|
||||||
|
|
||||||
|
/* Convert the VK_USE_PLATFORM_* defines to booleans */
|
||||||
|
%for platform_define in platform_defines:
|
||||||
|
#ifdef ${platform_define}
|
||||||
|
# undef ${platform_define}
|
||||||
|
# define ${platform_define} true
|
||||||
|
#else
|
||||||
|
# define ${platform_define} false
|
||||||
|
#endif
|
||||||
|
%endfor
|
||||||
|
|
||||||
|
/* And ANDROID too */
|
||||||
|
#ifdef ANDROID
|
||||||
|
# undef ANDROID
|
||||||
|
# define ANDROID true
|
||||||
|
#else
|
||||||
|
# define ANDROID false
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define V3DV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || \\
|
||||||
|
VK_USE_PLATFORM_XCB_KHR || \\
|
||||||
|
VK_USE_PLATFORM_XLIB_KHR || \\
|
||||||
|
VK_USE_PLATFORM_DISPLAY_KHR)
|
||||||
|
|
||||||
|
static const uint32_t MAX_API_VERSION = ${MAX_API_VERSION.c_vk_version()};
|
||||||
|
|
||||||
|
const VkExtensionProperties v3dv_instance_extensions[V3DV_INSTANCE_EXTENSION_COUNT] = {
|
||||||
|
%for ext in instance_extensions:
|
||||||
|
{"${ext.name}", ${ext.ext_version}},
|
||||||
|
%endfor
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct v3dv_instance_extension_table v3dv_instance_extensions_supported = {
|
||||||
|
%for ext in instance_extensions:
|
||||||
|
.${ext.name[3:]} = ${ext.enable},
|
||||||
|
%endfor
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
v3dv_physical_device_api_version(struct v3dv_physical_device *device)
|
||||||
|
{
|
||||||
|
uint32_t version = 0;
|
||||||
|
|
||||||
|
uint32_t override = vk_get_version_override();
|
||||||
|
if (override)
|
||||||
|
return MIN2(override, MAX_API_VERSION);
|
||||||
|
|
||||||
|
%for version in API_VERSIONS:
|
||||||
|
if (!(${version.enable}))
|
||||||
|
return version;
|
||||||
|
version = ${version.version.c_vk_version()};
|
||||||
|
|
||||||
|
%endfor
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VkExtensionProperties v3dv_device_extensions[V3DV_DEVICE_EXTENSION_COUNT] = {
|
||||||
|
%for ext in device_extensions:
|
||||||
|
{"${ext.name}", ${ext.ext_version}},
|
||||||
|
%endfor
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_physical_device_get_supported_extensions(const struct v3dv_physical_device *device,
|
||||||
|
struct v3dv_device_extension_table *extensions)
|
||||||
|
{
|
||||||
|
*extensions = (struct v3dv_device_extension_table) {
|
||||||
|
%for ext in device_extensions:
|
||||||
|
.${ext.name[3:]} = ${ext.enable},
|
||||||
|
%endfor
|
||||||
|
};
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--out-c', help='Output C file.')
|
||||||
|
parser.add_argument('--out-h', help='Output H file.')
|
||||||
|
parser.add_argument('--xml',
|
||||||
|
help='Vulkan API XML file.',
|
||||||
|
required=True,
|
||||||
|
action='append',
|
||||||
|
dest='xml_files')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
for filename in args.xml_files:
|
||||||
|
_init_exts_from_xml(filename)
|
||||||
|
|
||||||
|
for ext in EXTENSIONS:
|
||||||
|
assert ext.type == 'instance' or ext.type == 'device'
|
||||||
|
|
||||||
|
template_env = {
|
||||||
|
'API_VERSIONS': API_VERSIONS,
|
||||||
|
'MAX_API_VERSION': MAX_API_VERSION,
|
||||||
|
'instance_extensions': [e for e in EXTENSIONS if e.type == 'instance'],
|
||||||
|
'device_extensions': [e for e in EXTENSIONS if e.type == 'device'],
|
||||||
|
'platform_defines': platform_defines,
|
||||||
|
}
|
||||||
|
|
||||||
|
if args.out_h:
|
||||||
|
with open(args.out_h, 'w') as f:
|
||||||
|
f.write(_TEMPLATE_H.render(**template_env))
|
||||||
|
|
||||||
|
if args.out_c:
|
||||||
|
with open(args.out_c, 'w') as f:
|
||||||
|
f.write(_TEMPLATE_C.render(**template_env))
|
||||||
48
src/broadcom/vulkan/v3dv_icd.py
Normal file
48
src/broadcom/vulkan/v3dv_icd.py
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
# Copyright 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, sub license, 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 NON-INFRINGEMENT.
|
||||||
|
# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 json
|
||||||
|
import os.path
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from v3dv_extensions import MAX_API_VERSION
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--out', help='Output json file.', required=True)
|
||||||
|
parser.add_argument('--lib-path', help='Path to libvulkan_broadcom.so')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
path = 'libvulkan_broadcom.so'
|
||||||
|
if args.lib_path:
|
||||||
|
path = os.path.join(args.lib_path, path)
|
||||||
|
|
||||||
|
json_data = {
|
||||||
|
'file_format_version': '1.0.0',
|
||||||
|
'ICD': {
|
||||||
|
'library_path': path,
|
||||||
|
'api_version': str(MAX_API_VERSION),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
with open(args.out, 'w') as f:
|
||||||
|
json.dump(json_data, f, indent=4, sort_keys=True, separators=(',', ': '))
|
||||||
53
src/broadcom/vulkan/v3dv_pipeline.c
Normal file
53
src/broadcom/vulkan/v3dv_pipeline.c
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2019 Raspberry Pi
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "vk_util.h"
|
||||||
|
|
||||||
|
#include "v3dv_private.h"
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
v3dv_CreateShaderModule(VkDevice _device,
|
||||||
|
const VkShaderModuleCreateInfo *pCreateInfo,
|
||||||
|
const VkAllocationCallbacks *pAllocator,
|
||||||
|
VkShaderModule *pShaderModule)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_DestroyShaderModule(VkDevice _device,
|
||||||
|
VkShaderModule _module,
|
||||||
|
const VkAllocationCallbacks *pAllocator)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
v3dv_DestroyPipeline(VkDevice _device,
|
||||||
|
VkPipeline _pipeline,
|
||||||
|
const VkAllocationCallbacks *pAllocator)
|
||||||
|
{
|
||||||
|
/* FIXME: stub */
|
||||||
|
}
|
||||||
176
src/broadcom/vulkan/v3dv_private.h
Normal file
176
src/broadcom/vulkan/v3dv_private.h
Normal file
|
|
@ -0,0 +1,176 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2019 Raspberry Pi
|
||||||
|
*
|
||||||
|
* based in part on anv driver which is:
|
||||||
|
* Copyright © 2015 Intel Corporation
|
||||||
|
*
|
||||||
|
* based in part on radv driver which is:
|
||||||
|
* Copyright © 2016 Red Hat.
|
||||||
|
* Copyright © 2016 Bas Nieuwenhuizen
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef V3DV_PRIVATE_H
|
||||||
|
#define V3DV_PRIVATE_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#include <vulkan/vk_icd.h>
|
||||||
|
|
||||||
|
#include "common/v3d_device_info.h"
|
||||||
|
|
||||||
|
#include "vk_debug_report.h"
|
||||||
|
#include "util/xmlconfig.h"
|
||||||
|
|
||||||
|
#include "v3dv_entrypoints.h"
|
||||||
|
#include "v3dv_extensions.h"
|
||||||
|
|
||||||
|
struct v3dv_instance;
|
||||||
|
|
||||||
|
struct v3dv_device {
|
||||||
|
VK_LOADER_DATA _loader_data;
|
||||||
|
|
||||||
|
VkAllocationCallbacks alloc;
|
||||||
|
|
||||||
|
struct v3dv_instance *instance;
|
||||||
|
|
||||||
|
struct v3dv_device_extension_table enabled_extensions;
|
||||||
|
struct v3dv_device_dispatch_table dispatch;
|
||||||
|
|
||||||
|
/* FIXME: stub */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct v3dv_physical_device {
|
||||||
|
VK_LOADER_DATA _loader_data;
|
||||||
|
|
||||||
|
struct v3dv_instance *instance;
|
||||||
|
|
||||||
|
struct v3dv_device_extension_table supported_extensions;
|
||||||
|
struct v3dv_physical_device_dispatch_table dispatch;
|
||||||
|
|
||||||
|
/* FIXME: stub */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v3dv_app_info {
|
||||||
|
const char *app_name;
|
||||||
|
uint32_t app_version;
|
||||||
|
const char *engine_name;
|
||||||
|
uint32_t engine_version;
|
||||||
|
uint32_t api_version;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v3dv_instance {
|
||||||
|
VK_LOADER_DATA _loader_data;
|
||||||
|
|
||||||
|
VkAllocationCallbacks alloc;
|
||||||
|
|
||||||
|
struct v3dv_app_info app_info;
|
||||||
|
|
||||||
|
struct v3dv_instance_extension_table enabled_extensions;
|
||||||
|
struct v3dv_instance_dispatch_table dispatch;
|
||||||
|
struct v3dv_device_dispatch_table device_dispatch;
|
||||||
|
|
||||||
|
int physicalDeviceCount;
|
||||||
|
struct v3dv_physical_device physicalDevice;
|
||||||
|
|
||||||
|
struct vk_debug_report_instance debug_report_callbacks;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v3dv_queue {
|
||||||
|
VK_LOADER_DATA _loader_data;
|
||||||
|
|
||||||
|
struct v3dv_device *device;
|
||||||
|
|
||||||
|
VkDeviceQueueCreateFlags flags;
|
||||||
|
|
||||||
|
/* FIXME: stub */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v3dv_cmd_buffer {
|
||||||
|
VK_LOADER_DATA _loader_data;
|
||||||
|
|
||||||
|
struct v3dv_device *device;
|
||||||
|
|
||||||
|
/* FIXME: stub */
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t v3dv_physical_device_api_version(struct v3dv_physical_device *dev);
|
||||||
|
|
||||||
|
int v3dv_get_instance_entrypoint_index(const char *name);
|
||||||
|
int v3dv_get_device_entrypoint_index(const char *name);
|
||||||
|
int v3dv_get_physical_device_entrypoint_index(const char *name);
|
||||||
|
|
||||||
|
const char *v3dv_get_instance_entry_name(int index);
|
||||||
|
const char *v3dv_get_physical_device_entry_name(int index);
|
||||||
|
const char *v3dv_get_device_entry_name(int index);
|
||||||
|
|
||||||
|
bool
|
||||||
|
v3dv_instance_entrypoint_is_enabled(int index, uint32_t core_version,
|
||||||
|
const struct v3dv_instance_extension_table *instance);
|
||||||
|
bool
|
||||||
|
v3dv_physical_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
||||||
|
const struct v3dv_instance_extension_table *instance);
|
||||||
|
bool
|
||||||
|
v3dv_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
||||||
|
const struct v3dv_instance_extension_table *instance,
|
||||||
|
const struct v3dv_device_extension_table *device);
|
||||||
|
|
||||||
|
void *v3dv_lookup_entrypoint(const struct v3d_device_info *devinfo,
|
||||||
|
const char *name);
|
||||||
|
|
||||||
|
#define v3dv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
|
||||||
|
|
||||||
|
VkResult __vk_errorf(struct v3dv_instance *instance, VkResult error,
|
||||||
|
const char *file, int line,
|
||||||
|
const char *format, ...);
|
||||||
|
|
||||||
|
#define vk_error(instance, error) __vk_errorf(instance, error, __FILE__, __LINE__, NULL);
|
||||||
|
#define vk_errorf(instance, error, format, ...) __vk_errorf(instance, error, __FILE__, __LINE__, format, ## __VA_ARGS__);
|
||||||
|
|
||||||
|
void v3dv_loge(const char *format, ...) v3dv_printflike(1, 2);
|
||||||
|
void v3dv_loge_v(const char *format, va_list va);
|
||||||
|
|
||||||
|
#define V3DV_DEFINE_HANDLE_CASTS(__v3dv_type, __VkType) \
|
||||||
|
\
|
||||||
|
static inline struct __v3dv_type * \
|
||||||
|
__v3dv_type ## _from_handle(__VkType _handle) \
|
||||||
|
{ \
|
||||||
|
return (struct __v3dv_type *) _handle; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static inline __VkType \
|
||||||
|
__v3dv_type ## _to_handle(struct __v3dv_type *_obj) \
|
||||||
|
{ \
|
||||||
|
return (__VkType) _obj; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define V3DV_FROM_HANDLE(__v3dv_type, __name, __handle) \
|
||||||
|
struct __v3dv_type *__name = __v3dv_type ## _from_handle(__handle)
|
||||||
|
|
||||||
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_cmd_buffer, VkCommandBuffer)
|
||||||
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_device, VkDevice)
|
||||||
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_instance, VkInstance)
|
||||||
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_physical_device, VkPhysicalDevice)
|
||||||
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_queue, VkQueue)
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* V3DV_PRIVATE_H */
|
||||||
85
src/broadcom/vulkan/v3dv_util.c
Normal file
85
src/broadcom/vulkan/v3dv_util.c
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2019 Raspberry Pi
|
||||||
|
*
|
||||||
|
* based in part on anv driver which is:
|
||||||
|
* Copyright © 2015 Intel Corporation
|
||||||
|
*
|
||||||
|
* based in part on radv driver which is:
|
||||||
|
* Copyright © 2016 Red Hat.
|
||||||
|
* Copyright © 2016 Bas Nieuwenhuizen
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "vk_enum_to_str.h"
|
||||||
|
#include "v3dv_private.h"
|
||||||
|
|
||||||
|
/** Log an error message. */
|
||||||
|
void v3dv_printflike(1, 2)
|
||||||
|
v3dv_loge(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
|
||||||
|
va_start(va, format);
|
||||||
|
v3dv_loge_v(format, va);
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \see v3dv_loge() */
|
||||||
|
void
|
||||||
|
v3dv_loge_v(const char *format, va_list va)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "vk: error: ");
|
||||||
|
vfprintf(stderr, format, va);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
__vk_errorf(struct v3dv_instance *instance, VkResult error, const char *file,
|
||||||
|
int line, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char buffer[256];
|
||||||
|
|
||||||
|
const char *error_str = vk_Result_to_str(error);
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
|
return error;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (format) {
|
||||||
|
va_start(ap, format);
|
||||||
|
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s:%d: %s\n", file, line, error_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
@ -73,7 +73,7 @@ endif
|
||||||
if with_gallium_radeonsi or with_amd_vk
|
if with_gallium_radeonsi or with_amd_vk
|
||||||
subdir('amd')
|
subdir('amd')
|
||||||
endif
|
endif
|
||||||
if with_gallium_vc4 or with_gallium_v3d
|
if with_gallium_vc4 or with_gallium_v3d or with_broadcom_vk
|
||||||
subdir('broadcom')
|
subdir('broadcom')
|
||||||
endif
|
endif
|
||||||
if with_gallium_etnaviv
|
if with_gallium_etnaviv
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue