mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-16 02:28:20 +02:00
nvk: use the new generation script for drirc
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41881>
This commit is contained in:
parent
4c66fc1383
commit
c0531ece56
8 changed files with 92 additions and 66 deletions
|
|
@ -119,6 +119,19 @@ nvkcl = custom_target(
|
|||
command : [prog_vtn_bindgen2, '@INPUT@', '@OUTPUT@'],
|
||||
)
|
||||
|
||||
nvk_drirc = custom_target(
|
||||
'nvk_drirc',
|
||||
input : [files('nvk_drirc_gen.py'), drirc_gen, join_paths(dir_source_root, 'src/util/00-nvk-defaults.conf')],
|
||||
output : ['nvk_drirc.c', 'nvk_drirc.h'],
|
||||
command : [
|
||||
prog_python, '@INPUT0@',
|
||||
'--import-path', join_paths(dir_source_root, 'src/util'),
|
||||
'--drirc-src', '@OUTPUT0@',
|
||||
'--drirc-hdr', '@OUTPUT1@',
|
||||
'--validate', '@INPUT2@',
|
||||
],
|
||||
)
|
||||
|
||||
nvk_deps = [
|
||||
dep_libdrm,
|
||||
idep_nak,
|
||||
|
|
@ -144,6 +157,7 @@ libnvk = static_library(
|
|||
'nvk',
|
||||
[
|
||||
nvk_entrypoints,
|
||||
nvk_drirc,
|
||||
cl_generated,
|
||||
nvk_files,
|
||||
nvkcl,
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ init_app_workarounds_entrypoints(struct nvk_device *device, struct dispatch_tabl
|
|||
struct vk_device_entrypoint_table table = {0};
|
||||
|
||||
#define SET_ENTRYPOINT(app_layer, entrypoint) table.entrypoint = app_layer##_##entrypoint;
|
||||
if (!strcmp(instance->app_layer, "metroexodus")) {
|
||||
if (!strcmp(instance->drirc.debug.app_layer, "metroexodus")) {
|
||||
SET_ENTRYPOINT(metro_exodus, GetSemaphoreCounterValue);
|
||||
}
|
||||
#undef SET_ENTRYPOINT
|
||||
|
|
|
|||
57
src/nouveau/vulkan/nvk_drirc_gen.py
Normal file
57
src/nouveau/vulkan/nvk_drirc_gen.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright © 2026 Valve Corporation
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
VALID_COMMON_VK_OPTIONS = {
|
||||
"force_vk_vendor",
|
||||
"vk_zero_vram",
|
||||
"heap_memory_percent",
|
||||
}
|
||||
|
||||
def declare_options():
|
||||
import drirc_gen
|
||||
|
||||
B = drirc_gen.DrircBool
|
||||
I = drirc_gen.DrircInt
|
||||
S = drirc_gen.DrircString
|
||||
|
||||
debug_options = [
|
||||
S("nvk_app_layer",
|
||||
description="Select an application layer",
|
||||
c_name="app_layer"),
|
||||
]
|
||||
|
||||
performance_options = []
|
||||
features_options = []
|
||||
misc_options = []
|
||||
|
||||
drirc_gen.add_common_vk_options(debug_options, features_options, misc_options,
|
||||
valid_options=VALID_COMMON_VK_OPTIONS,
|
||||
defaults={"heap_memory_percent": 0.75})
|
||||
drirc_gen.add_common_vk_wsi_options(debug_options, performance_options)
|
||||
|
||||
return [
|
||||
drirc_gen.DrircSection("Debugging", debug_options, c_name="debug"),
|
||||
drirc_gen.DrircSection("Performance", performance_options, c_name="performance"),
|
||||
drirc_gen.DrircSection("Misc", misc_options, c_name="misc"),
|
||||
]
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-p', '--import-path', required=True)
|
||||
parser.add_argument('--drirc-src', required=True)
|
||||
parser.add_argument('--drirc-hdr', required=True)
|
||||
parser.add_argument('--validate', required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
sys.path.insert(0, args.import_path)
|
||||
import drirc_gen
|
||||
|
||||
drirc_gen.drirc_validate([args.validate], declare_options())
|
||||
drirc_gen.drirc_generate(args.drirc_src, args.drirc_hdr, "nvk", declare_options())
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
#include "nvk_entrypoints.h"
|
||||
#include "nvk_physical_device.h"
|
||||
#include "nvk_drirc.h"
|
||||
|
||||
#include "vulkan/wsi/wsi_common.h"
|
||||
|
||||
#include "util/build_id.h"
|
||||
#include "util/detect_os.h"
|
||||
#include "util/driconf.h"
|
||||
#include "util/mesa-blake3.h"
|
||||
#include "util/os_misc.h"
|
||||
#include "util/u_debug.h"
|
||||
|
|
@ -98,55 +98,20 @@ nvk_init_debug_flags(struct nvk_instance *instance)
|
|||
instance->debug_flags = parse_debug_string(os_get_option("NVK_DEBUG"), flags);
|
||||
}
|
||||
|
||||
#define NVK_HEAP_MEMORY_PERCENT (0.75f)
|
||||
|
||||
static const driOptionDescription nvk_dri_options[] = {
|
||||
DRI_CONF_SECTION_PERFORMANCE
|
||||
DRI_CONF_ADAPTIVE_SYNC(true)
|
||||
DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(0)
|
||||
DRI_CONF_VK_X11_STRICT_IMAGE_COUNT(false)
|
||||
DRI_CONF_VK_X11_ENSURE_MIN_IMAGE_COUNT(false)
|
||||
DRI_CONF_VK_XWAYLAND_WAIT_READY(false)
|
||||
DRI_CONF_SECTION_END
|
||||
|
||||
DRI_CONF_SECTION_DEBUG
|
||||
DRI_CONF_FORCE_VK_VENDOR()
|
||||
DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false)
|
||||
DRI_CONF_VK_X11_IGNORE_SUBOPTIMAL(false)
|
||||
DRI_CONF_VK_ZERO_VRAM(false)
|
||||
DRI_CONF_NVK_APP_LAYER()
|
||||
DRI_CONF_SECTION_END
|
||||
|
||||
DRI_CONF_SECTION_MISCELLANEOUS
|
||||
DRI_CONF_HEAP_MEMORY_PERCENT(NVK_HEAP_MEMORY_PERCENT)
|
||||
DRI_CONF_SECTION_END
|
||||
};
|
||||
|
||||
static void
|
||||
nvk_init_dri_options(struct nvk_instance *instance)
|
||||
{
|
||||
driParseOptionInfo(&instance->available_dri_options, nvk_dri_options, ARRAY_SIZE(nvk_dri_options));
|
||||
driParseConfigFiles(&instance->dri_options, &instance->available_dri_options,
|
||||
&(driConfigFileParseParams) {
|
||||
.driverName = "nvk",
|
||||
.applicationName = instance->vk.app_info.app_name,
|
||||
.applicationVersion = instance->vk.app_info.app_version,
|
||||
.engineName = instance->vk.app_info.engine_name,
|
||||
.engineVersion = instance->vk.app_info.engine_version,
|
||||
});
|
||||
nvk_parse_dri_options(&instance->drirc,
|
||||
&(driConfigFileParseParams){
|
||||
.driverName = "nvk",
|
||||
.applicationName = instance->vk.app_info.app_name,
|
||||
.applicationVersion = instance->vk.app_info.app_version,
|
||||
.engineName = instance->vk.app_info.engine_name,
|
||||
.engineVersion = instance->vk.app_info.engine_version,
|
||||
});
|
||||
|
||||
instance->force_vk_vendor =
|
||||
driQueryOptioni(&instance->dri_options, "force_vk_vendor");
|
||||
|
||||
instance->heap_memory_percent =
|
||||
driQueryOptionf(&instance->dri_options, "heap_memory_percent");
|
||||
if (instance->heap_memory_percent == OS_GPU_HEAP_SIZE_HEURISTIC)
|
||||
instance->heap_memory_percent = NVK_HEAP_MEMORY_PERCENT;
|
||||
|
||||
if (driQueryOptionb(&instance->dri_options, "vk_zero_vram"))
|
||||
if (instance->drirc.debug.zero_vram)
|
||||
instance->debug_flags |= NVK_DEBUG_ZERO_MEMORY;
|
||||
|
||||
instance->app_layer = driQueryOptionstr(&instance->dri_options, "nvk_app_layer");
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
|
|
@ -223,8 +188,8 @@ nvk_DestroyInstance(VkInstance _instance,
|
|||
if (!instance)
|
||||
return;
|
||||
|
||||
driDestroyOptionCache(&instance->dri_options);
|
||||
driDestroyOptionInfo(&instance->available_dri_options);
|
||||
driDestroyOptionCache(&instance->drirc.options);
|
||||
driDestroyOptionInfo(&instance->drirc.available_options);
|
||||
|
||||
vk_instance_finish(&instance->vk);
|
||||
vk_free(&instance->vk.alloc, instance);
|
||||
|
|
|
|||
|
|
@ -8,21 +8,17 @@
|
|||
#include "nvk_private.h"
|
||||
|
||||
#include "nvk_debug.h"
|
||||
#include "nvk_drirc.h"
|
||||
#include "vk_instance.h"
|
||||
#include "util/xmlconfig.h"
|
||||
|
||||
struct nvk_instance {
|
||||
struct vk_instance vk;
|
||||
|
||||
enum nvk_debug debug_flags;
|
||||
|
||||
struct driOptionCache dri_options;
|
||||
struct driOptionCache available_dri_options;
|
||||
char *app_layer;
|
||||
struct nvk_drirc drirc;
|
||||
|
||||
uint8_t driver_build_sha[BLAKE3_KEY_LEN];
|
||||
uint32_t force_vk_vendor;
|
||||
float heap_memory_percent;
|
||||
};
|
||||
|
||||
VK_DEFINE_HANDLE_CASTS(nvk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE)
|
||||
|
|
|
|||
|
|
@ -834,8 +834,8 @@ nvk_get_device_properties(const struct nvk_instance *instance,
|
|||
*properties = (struct vk_properties) {
|
||||
.apiVersion = nvk_get_vk_version(info),
|
||||
.driverVersion = vk_get_driver_version(),
|
||||
.vendorID = instance->force_vk_vendor != 0 ?
|
||||
instance->force_vk_vendor : NVIDIA_VENDOR_ID,
|
||||
.vendorID = instance->drirc.debug.force_vk_vendor != 0 ?
|
||||
instance->drirc.debug.force_vk_vendor : NVIDIA_VENDOR_ID,
|
||||
.deviceID = info->device_id,
|
||||
.deviceType = info->type == NV_DEVICE_TYPE_DIS ?
|
||||
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU :
|
||||
|
|
@ -1560,8 +1560,8 @@ nvk_create_drm_physical_device(struct vk_instance *_instance,
|
|||
nvk_physical_device_init_pipeline_cache(pdev);
|
||||
|
||||
uint64_t heap_size =
|
||||
os_get_gpu_heap_size(instance->heap_memory_percent,
|
||||
&instance->heap_memory_percent);
|
||||
os_get_gpu_heap_size(instance->drirc.misc.heap_memory_percent,
|
||||
&instance->drirc.misc.heap_memory_percent);
|
||||
if (heap_size == 0) {
|
||||
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"Failed to query total system memory");
|
||||
|
|
@ -1756,7 +1756,7 @@ nvk_GetPhysicalDeviceMemoryProperties2(
|
|||
|
||||
if (heap->available == nvk_get_sysmem_heap_available) {
|
||||
/* Scale the budget the same way the heap was scaled. */
|
||||
percent *= instance->heap_memory_percent;
|
||||
percent *= instance->drirc.misc.heap_memory_percent;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ nvk_init_wsi(struct nvk_physical_device *pdev)
|
|||
nvk_physical_device_to_handle(pdev),
|
||||
nvk_wsi_proc_addr, &pdev->vk.instance->alloc,
|
||||
nvkmd_pdev_get_drm_primary_fd(pdev->nvkmd),
|
||||
&nvk_physical_device_instance(pdev)->dri_options,
|
||||
&nvk_physical_device_instance(pdev)->drirc.options,
|
||||
&wsi_options);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -604,12 +604,6 @@
|
|||
DRI_CONF_OPT_B(anv_sample_mask_out_opengl_behaviour, def, \
|
||||
"Ignore sample mask out when having single sampled target")
|
||||
|
||||
/**
|
||||
* \brief NVK specific configuration options
|
||||
*/
|
||||
|
||||
#define DRI_CONF_NVK_APP_LAYER() DRI_CONF_OPT_S_NODEF(nvk_app_layer, "Select an application layer.")
|
||||
|
||||
/**
|
||||
* \brief Asahi specific configuration options
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue