Commit 2aac5650 authored by Caio Marcelo de Oliveira Filho's avatar Caio Marcelo de Oliveira Filho
Browse files

anv: Add support for INTEL_DEBUG=bt

Print all the bindings, with the corresponding BTI or nothing in case
of bindless.  Output looks like

    Bindings for MESA_SHADER_COMPUTE
      [000] anv num work groups
      [001] anv buffer for set 0
      [002] anv shader constants
            VK_DESCRIPTOR_TYPE_STORAGE_BUFFER 0:0
parent 9d93d2a4
Pipeline #41081 passed with stages
in 19 minutes and 31 seconds
......@@ -393,9 +393,7 @@ VkResult anv_CreateDescriptorSetLayout(
if (binding->descriptorCount == 0)
continue;
#ifndef NDEBUG
set_layout->binding[b].type = binding->descriptorType;
#endif
if (binding_flags_info && binding_flags_info->bindingCount > 0) {
assert(binding_flags_info->bindingCount == pCreateInfo->bindingCount);
......
......@@ -26,6 +26,7 @@
#include "nir/nir_builder.h"
#include "compiler/brw_nir.h"
#include "util/set.h"
#include "vk_enum_to_str.h"
/* Sampler tables don't actually have a maximum size but we pick one just so
* that we don't end up emitting too much state on-the-fly.
......@@ -1093,6 +1094,68 @@ compare_binding_infos(const void *_a, const void *_b)
return a->binding - b->binding;
}
static void
anv_print_bindings(FILE *fp, const char *name,
struct apply_pipeline_layout_state *state,
struct anv_pipeline_bind_map *map)
{
const struct anv_pipeline_layout *layout = state->layout;
fprintf(fp, "Bindings for %s\n", name);
/* First handle bindings that have a BTI. */
for (int i = 0; i < map->surface_count; i++) {
struct anv_pipeline_binding *pb = &map->surface_to_descriptor[i];
switch (pb->set) {
case ANV_DESCRIPTOR_SET_DESCRIPTORS:
/* Here 'binding' holds the descriptor set the buffer refers to. */
fprintf(fp, " [%03u] anv buffer for set %u\n", i, pb->binding);
break;
case ANV_DESCRIPTOR_SET_NUM_WORK_GROUPS:
fprintf(fp, " [%03u] anv num work groups\n", i);
break;
case ANV_DESCRIPTOR_SET_SHADER_CONSTANTS:
fprintf(fp, " [%03u] anv shader constants\n", i);
break;
case ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS:
fprintf(fp, " [%03u] anv color attachments\n", i);
break;
default: {
struct anv_descriptor_set_layout *set_layout = layout->set[pb->set].layout;
struct anv_descriptor_set_binding_layout *binding =
&set_layout->binding[pb->binding];
fprintf(fp, " [%03u] %s %u:%u\n",
state->set[pb->set].surface_offsets[pb->binding],
vk_DescriptorType_to_str(binding->type),
pb->set, pb->binding);
break;
}
}
}
/* Then handle the bindless. */
for (uint32_t set = 0; set < layout->num_sets; set++) {
struct anv_descriptor_set_layout *set_layout = layout->set[set].layout;
for (unsigned b = 0; b < set_layout->binding_count; b++) {
uint32_t surface_index = state->set[set].surface_offsets[b];
if (surface_index < MAX_BINDING_TABLE_SIZE)
continue;
struct anv_descriptor_set_binding_layout *binding =
&set_layout->binding[b];
fprintf(fp, " %s %u:%u\n",
vk_DescriptorType_to_str(binding->type), set, b);
}
}
fprintf(fp, "\n");
}
void
anv_nir_apply_pipeline_layout(const struct anv_physical_device *pdevice,
bool robust_buffer_access,
......@@ -1315,6 +1378,11 @@ anv_nir_apply_pipeline_layout(const struct anv_physical_device *pdevice,
}
}
if (unlikely(INTEL_DEBUG & DEBUG_BT)) {
anv_print_bindings(stderr, gl_shader_stage_name(shader->info.stage),
&state, map);
}
nir_foreach_function(function, shader) {
if (!function->impl)
continue;
......
......@@ -1605,10 +1605,8 @@ enum anv_descriptor_data {
};
struct anv_descriptor_set_binding_layout {
#ifndef NDEBUG
/* The type of the descriptors in this binding */
VkDescriptorType type;
#endif
/* Flags provided when this binding was created */
VkDescriptorBindingFlagsEXT flags;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment