struct tu_pipeline_layout *layout = pipeline->layout;
for (unsigned i = 0; i < layout->num_sets; i++) {
+ /* From 13.2.7. Descriptor Set Binding:
+ *
+ * A compatible descriptor set must be bound for all set numbers that
+ * any shaders in a pipeline access, at the time that a draw or
+ * dispatch command is recorded to execute using that pipeline.
+ * However, if none of the shaders in a pipeline statically use any
+ * bindings with a particular set number, then no descriptor set need
+ * be bound for that set number, even if the pipeline layout includes
+ * a non-trivial descriptor set layout for that set number.
+ *
+ * This means that descriptor sets unused by the pipeline may have a
+ * garbage or 0 BINDLESS_BASE register, which will cause context faults
+ * when prefetching descriptors from these sets. Skip prefetching for
+ * descriptors from them to avoid this. This is also an optimization,
+ * since these prefetches would be useless.
+ */
+ if (!(pipeline->active_desc_sets & (1u << i)))
+ continue;
+
struct tu_descriptor_set_layout *set_layout = layout->set[i].layout;
for (unsigned j = 0; j < set_layout->binding_count; j++) {
struct tu_descriptor_set_binding_layout *binding = &set_layout->binding[j];
}
pipeline->active_stages = stages;
+ uint32_t desc_sets = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
if (!builder->shaders[i])
continue;
tu_pipeline_set_linkage(&pipeline->program.link[i],
builder->shaders[i],
&builder->shaders[i]->variants[0]);
+ desc_sets |= builder->shaders[i]->active_desc_sets;
}
+ pipeline->active_desc_sets = desc_sets;
if (builder->shaders[MESA_SHADER_FRAGMENT]) {
memcpy(pipeline->program.input_attachment_idx,
struct tu_push_constant_range push_consts;
unsigned attachment_idx[MAX_RTS];
+ uint8_t active_desc_sets;
/* This may be true for vertex shaders. When true, variants[1] is the
* binning variant and binning_binary is non-NULL.
bool need_indirect_descriptor_sets;
VkShaderStageFlags active_stages;
+ uint32_t active_desc_sets;
struct tu_streamout_state streamout;
&set_layout->binding[binding];
uint32_t base;
+ shader->active_desc_sets |= 1u << set;
+
switch (binding_layout->type) {
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
const struct tu_descriptor_set_binding_layout *bind_layout =
&layout->set[set].layout->binding[binding];
+ shader->active_desc_sets |= 1u << set;
+
nir_ssa_def *desc_offset;
unsigned descriptor_stride;
if (bind_layout->type == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) {