mesa/src/amd/vulkan/radv_debug_nir.h
Konstantin Seurer 0d73aeea27 radv: Add RADV_DEBUG=validatevas for address validation in nir
The option creates a buffer where each bit stores whether the
corresponding 4096 byte memory section has been allocated. The helper
radv_build_is_valid_va allows for querying the validity of addresses
inside a nir shader which can be useful for debugging.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34392>
2025-08-15 10:32:35 +00:00

71 lines
1.7 KiB
C

/*
* Copyright © 2016 Red Hat.
* Copyright © 2016 Bas Nieuwenhuizen
*
* based in part on anv driver which is:
* Copyright © 2015 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/
#ifndef RADV_PRINTF_H
#define RADV_PRINTF_H
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <vulkan/vulkan_core.h>
#include "util/u_dynarray.h"
struct radv_device;
typedef struct nir_builder nir_builder;
typedef struct nir_shader nir_shader;
typedef struct nir_def nir_def;
struct radv_printf_data {
uint32_t buffer_size;
VkBuffer buffer;
VkDeviceMemory memory;
VkDeviceAddress buffer_addr;
void *data;
struct util_dynarray formats;
};
struct radv_printf_format {
char *string;
uint32_t divergence_mask;
uint8_t element_sizes[32];
};
struct radv_printf_buffer_header {
uint32_t offset;
uint32_t size;
};
void radv_device_associate_nir(struct radv_device *device, nir_shader *nir);
/* shader printf */
VkResult radv_printf_data_init(struct radv_device *device);
void radv_printf_data_finish(struct radv_device *device);
void radv_build_printf_args(nir_builder *b, nir_def *cond, const char *format, uint32_t argc, nir_def **args);
void radv_build_printf(nir_builder *b, nir_def *cond, const char *format, ...);
void radv_dump_printf_data(struct radv_device *device, FILE *out);
/* shader va validation */
VkResult radv_init_va_validation(struct radv_device *device);
void radv_finish_va_validation(struct radv_device *device);
void radv_va_validation_update_page(struct radv_device *device, uint64_t va, uint64_t size, bool valid);
nir_def *radv_build_is_valid_va(nir_builder *b, nir_def *addr);
#endif /* RADV_PRINTF_H */