From 229cce40562a16b70ba5799677aec3fa4e4ed281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Wed, 19 Aug 2020 23:34:30 +0200 Subject: [PATCH] v3dv/pipeline: track if texture is shadow To be used to decide the texture return size. We add it on the descriptor map because it is the easier place to do so. As we are lowering the texture accesses we can check instr->is_shadow at that point. It is true that it is somewhat odd, as so far the descriptor map was general-descriptor info, but is_shadow is only for textures. But it doesn't make sense to make an effort now, as it is possible that we would get more descriptor-specific info on the map on the future. We can revisit that later. Part-of: --- src/broadcom/vulkan/v3dv_pipeline.c | 14 ++++++++++---- src/broadcom/vulkan/v3dv_private.h | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index 4751fdaa44f..b3f9dbc08a7 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -539,7 +539,8 @@ descriptor_map_add(struct v3dv_descriptor_map *map, int set, int binding, int array_index, - int array_size) + int array_size, + bool is_shadow) { assert(array_index < array_size); @@ -560,6 +561,7 @@ descriptor_map_add(struct v3dv_descriptor_map *map, map->binding[map->num_desc] = binding; map->array_index[map->num_desc] = array_index; map->array_size[map->num_desc] = array_size; + map->is_shadow[map->num_desc] = is_shadow; map->num_desc++; return index; @@ -605,7 +607,8 @@ lower_vulkan_resource_index(nir_builder *b, index = descriptor_map_add(descriptor_map, set, binding, const_val->u32, - binding_layout->array_size); + binding_layout->array_size, + false /* is_shadow: Doesn't really matter in this case */); if (nir_intrinsic_desc_type(instr) == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) { /* skip index 0 which is used for push constants */ @@ -742,7 +745,9 @@ lower_tex_src_to_offset(nir_builder *b, nir_tex_instr *instr, unsigned src_idx, deref->var->data.descriptor_set, deref->var->data.binding, array_index, - binding_layout->array_size); + binding_layout->array_size, + instr->is_shadow); + if (is_sampler) instr->sampler_index = desc_index; else @@ -838,7 +843,8 @@ lower_image_deref(nir_builder *b, deref->var->data.descriptor_set, deref->var->data.binding, array_index, - binding_layout->array_size); + binding_layout->array_size, + false /* is_shadow: Doesn't really matter in this case */); /* We still need to get a combined_index, as we are integrating images with * the rest of the texture/sampler support diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index 82a5a634749..b5048c0c4bc 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -1443,6 +1443,11 @@ struct v3dv_descriptor_map { int binding[64]; int array_index[64]; int array_size[64]; + + /* The following makes sense for textures, but this is the easier place to + * put it + */ + bool is_shadow[64]; }; struct v3dv_sampler {