nvk: Initialize the debug flags in nvk_instance

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30033>
This commit is contained in:
Faith Ekstrand
2024-07-03 21:06:43 -05:00
committed by Marge Bot
parent 1f405ef9c6
commit 6de4a408f5
7 changed files with 33 additions and 25 deletions

View File

@@ -71,7 +71,7 @@ mme_hw_runner::set_up_hw(uint16_t min_cls, uint16_t max_cls)
if (devices[i]->available_nodes & 1 << DRM_NODE_RENDER &&
devices[i]->bustype == DRM_BUS_PCI &&
devices[i]->deviceinfo.pci->vendor_id == 0x10de) {
dev = nouveau_ws_device_new(devices[i]);
dev = nouveau_ws_device_new(devices[i], (enum nvk_debug)0);
if (dev == NULL)
continue;

View File

@@ -158,7 +158,7 @@ nvk_CreateDevice(VkPhysicalDevice physicalDevice,
goto fail_init;
}
dev->ws_dev = nouveau_ws_device_new(drm_device);
dev->ws_dev = nouveau_ws_device_new(drm_device, pdev->ws_dev->debug_flags);
drmFreeDevice(&drm_device);
if (dev->ws_dev == NULL) {
result = vk_errorf(dev, VK_ERROR_INITIALIZATION_FAILED,

View File

@@ -12,6 +12,7 @@
#include "util/build_id.h"
#include "util/driconf.h"
#include "util/mesa-sha1.h"
#include "util/u_debug.h"
VKAPI_ATTR VkResult VKAPI_CALL
nvk_EnumerateInstanceVersion(uint32_t *pApiVersion)
@@ -74,6 +75,22 @@ nvk_EnumerateInstanceExtensionProperties(const char *pLayerName,
&instance_extensions, pPropertyCount, pProperties);
}
static void
nvk_init_debug_flags(struct nvk_instance *instance)
{
const struct debug_control flags[] = {
{ "push_dump", NVK_DEBUG_PUSH_DUMP },
{ "push", NVK_DEBUG_PUSH_DUMP },
{ "push_sync", NVK_DEBUG_PUSH_SYNC },
{ "zero_memory", NVK_DEBUG_ZERO_MEMORY },
{ "vm", NVK_DEBUG_VM },
{ "no_cbuf", NVK_DEBUG_NO_CBUF },
{ NULL, 0 },
};
instance->debug_flags = parse_debug_string(getenv("NVK_DEBUG"), flags);
}
static const driOptionDescription nvk_dri_options[] = {
DRI_CONF_SECTION_PERFORMANCE
DRI_CONF_ADAPTIVE_SYNC(true)
@@ -132,6 +149,7 @@ nvk_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
if (result != VK_SUCCESS)
goto fail_alloc;
nvk_init_debug_flags(instance);
nvk_init_dri_options(instance);
instance->vk.physical_devices.try_create_for_drm =

View File

@@ -7,12 +7,15 @@
#include "nvk_private.h"
#include "nouveau_device.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;

View File

@@ -1155,7 +1155,8 @@ nvk_create_drm_physical_device(struct vk_instance *_instance,
if (!drm_device_is_nouveau(drm_device->nodes[DRM_NODE_RENDER]))
return VK_ERROR_INCOMPATIBLE_DRIVER;
struct nouveau_ws_device *ws_dev = nouveau_ws_device_new(drm_device);
struct nouveau_ws_device *ws_dev =
nouveau_ws_device_new(drm_device, instance->debug_flags);
if (!ws_dev)
return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
@@ -1257,7 +1258,7 @@ nvk_create_drm_physical_device(struct vk_instance *_instance,
goto fail_master_fd;
pdev->info = info;
pdev->debug_flags = ws_dev->debug_flags;
pdev->debug_flags = instance->debug_flags;
pdev->render_dev = render_dev;
pdev->master_fd = master_fd;
pdev->ws_dev = ws_dev;

View File

@@ -156,22 +156,6 @@ mp_per_tpc_for_chipset(uint16_t chipset)
return 1;
}
static void
nouveau_ws_device_set_dbg_flags(struct nouveau_ws_device *dev)
{
const struct debug_control flags[] = {
{ "push_dump", NVK_DEBUG_PUSH_DUMP },
{ "push", NVK_DEBUG_PUSH_DUMP },
{ "push_sync", NVK_DEBUG_PUSH_SYNC },
{ "zero_memory", NVK_DEBUG_ZERO_MEMORY },
{ "vm", NVK_DEBUG_VM },
{ "no_cbuf", NVK_DEBUG_NO_CBUF },
{ NULL, 0 },
};
dev->debug_flags = parse_debug_string(getenv("NVK_DEBUG"), flags);
}
static int
nouveau_ws_param(int fd, uint64_t param, uint64_t *value)
{
@@ -272,7 +256,8 @@ nouveau_ws_device_info(int fd, struct nouveau_ws_device *dev)
}
struct nouveau_ws_device *
nouveau_ws_device_new(drmDevicePtr drm_device)
nouveau_ws_device_new(drmDevicePtr drm_device,
enum nvk_debug debug_flags)
{
const char *path = drm_device->nodes[DRM_NODE_RENDER];
struct nouveau_ws_device *device = CALLOC_STRUCT(nouveau_ws_device);
@@ -373,7 +358,7 @@ nouveau_ws_device_new(drmDevicePtr drm_device)
device->info.gpc_count = (value >> 0) & 0x000000ff;
device->info.tpc_count = (value >> 8) & 0x0000ffff;
nouveau_ws_device_set_dbg_flags(device);
device->debug_flags = debug_flags;
struct nouveau_ws_context *tmp_ctx;
if (nouveau_ws_context_create(device, ~0, &tmp_ctx))

View File

@@ -22,8 +22,8 @@ enum nvk_debug {
/* push buffer submissions wait on completion
*
* This is useful to find the submission killing the GPU context. For easier debugging it also
* dumps the buffer leading to that.
* This is useful to find the submission killing the GPU context. For
* easier debugging it also dumps the buffer leading to that.
*/
NVK_DEBUG_PUSH_SYNC = 1ull << 1,
@@ -61,7 +61,8 @@ struct nouveau_ws_device {
simple_mtx_t vma_mutex;
};
struct nouveau_ws_device *nouveau_ws_device_new(struct _drmDevice *drm_device);
struct nouveau_ws_device *nouveau_ws_device_new(struct _drmDevice *drm_device,
enum nvk_debug debug_flags);
void nouveau_ws_device_destroy(struct nouveau_ws_device *);
uint64_t nouveau_ws_device_vram_used(struct nouveau_ws_device *);