From cf24211d55b304991a87c47a42caae31cbcb13fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg=20Kristensen?= Date: Fri, 25 Sep 2015 10:42:07 -0700 Subject: [PATCH] vk: Roll back GLSL parser support for vulkan In the interest of reducing our delta to mesa master, let's undo these changes now that we only support SPIR-V. --- src/glsl/ast.h | 8 -------- src/glsl/ast_to_hir.cpp | 19 +------------------ src/glsl/ast_type.cpp | 5 ----- src/glsl/glsl_parser.yy | 10 ++++------ src/glsl/ir.h | 14 +------------- .../link_uniform_block_active_visitor.cpp | 5 ----- src/glsl/link_uniform_block_active_visitor.h | 2 -- src/glsl/link_uniform_blocks.cpp | 4 ---- src/glsl/nir/glsl_to_nir.cpp | 17 ++++------------- 9 files changed, 10 insertions(+), 74 deletions(-) diff --git a/src/glsl/ast.h b/src/glsl/ast.h index eb6d8461671..d8c6cea7832 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -527,9 +527,6 @@ struct ast_type_qualifier { unsigned explicit_stream:1; /**< stream value assigned explicitly by shader code */ /** \} */ - /** \name Vulkan qualifiers */ - unsigned vk_set:1; - /** \name Layout qualifiers for GL_ARB_tessellation_shader */ /** \{ */ /* tess eval input layout */ @@ -642,11 +639,6 @@ struct ast_type_qualifier { */ glsl_base_type image_base_type; - /** - * Vulkan descriptor set - */ - int set; - /** * Return true if and only if an interpolation qualifier is present. */ diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 981438de597..81b44bd6786 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2777,16 +2777,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, state->fs_redeclares_gl_fragcoord_with_no_layout_qualifiers; } - if (qual->flags.q.vk_set) { - if (!qual->flags.q.explicit_binding) - _mesa_glsl_error(loc, state, - "Vulkan descriptor set layout requires both set " - "and binding qualifiers"); - - var->data.vk_set = true; - var->data.set = qual->set; - var->data.binding = qual->binding; - } else if (qual->flags.q.explicit_location) { + if (qual->flags.q.explicit_location) { validate_explicit_location(qual, var, state, loc); } else if (qual->flags.q.explicit_index) { _mesa_glsl_error(loc, state, "explicit index requires explicit location"); @@ -6280,10 +6271,6 @@ ast_interface_block::hir(exec_list *instructions, var->data.explicit_binding = this->layout.flags.q.explicit_binding; var->data.binding = this->layout.binding; - var->data.vk_set = this->layout.flags.q.vk_set; - var->data.set = this->layout.set; - var->data.binding = this->layout.binding; - state->symbols->add_variable(var); instructions->push_tail(var); } @@ -6357,10 +6344,6 @@ ast_interface_block::hir(exec_list *instructions, var->data.explicit_binding = this->layout.flags.q.explicit_binding; var->data.binding = this->layout.binding; - var->data.vk_set = this->layout.flags.q.vk_set; - var->data.set = this->layout.set; - var->data.binding = this->layout.binding; - state->symbols->add_variable(var); instructions->push_tail(var); } diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index 892122af03d..a4671e203e2 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -297,11 +297,6 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc, this->image_base_type = q.image_base_type; } - if (q.flags.q.vk_set) { - this->set = q.set; - this->binding = q.binding; - } - return true; } diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index e1b390844d3..59e4527b238 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -1468,16 +1468,14 @@ layout_qualifier_id: } } - if (match_layout_qualifier("binding", $1, state) == 0) { + if ((state->has_420pack() || + state->has_atomic_counters() || + state->has_shader_storage_buffer_objects()) && + match_layout_qualifier("binding", $1, state) == 0) { $$.flags.q.explicit_binding = 1; $$.binding = $3; } - if (match_layout_qualifier("set", $1, state) == 0) { - $$.flags.q.vk_set = 1; - $$.set = $3; - } - if (state->has_atomic_counters() && match_layout_qualifier("offset", $1, state) == 0) { $$.flags.q.explicit_offset = 1; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 7aac9af9001..ede8caa6e47 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -688,11 +688,6 @@ public: unsigned explicit_location:1; unsigned explicit_index:1; - /** - * Do we have a Vulkan (group, index) qualifier for this variable? - */ - unsigned vk_set:1; - /** * Was an initial binding explicitly set in the shader? * @@ -762,10 +757,8 @@ public: * \note * The GLSL spec only allows the values 0 or 1 for the index in \b dual * source blending. - * - * This is now also used for the Vulkan descriptor set index. */ - int16_t index; + unsigned index:1; /** * \brief Layout qualifier for gl_FragDepth. @@ -813,11 +806,6 @@ public: */ int16_t binding; - /** - * Vulkan descriptor set for the resource. - */ - int16_t set; - /** * Storage location of the base of this variable * diff --git a/src/glsl/link_uniform_block_active_visitor.cpp b/src/glsl/link_uniform_block_active_visitor.cpp index 981c1f75571..510294783a0 100644 --- a/src/glsl/link_uniform_block_active_visitor.cpp +++ b/src/glsl/link_uniform_block_active_visitor.cpp @@ -54,11 +54,6 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var) b->binding = 0; } - if (var->data.vk_set) { - b->set = var->data.set; - b->index = var->data.index; - } - _mesa_hash_table_insert(ht, var->get_interface_type()->name, (void *) b); return b; } else { diff --git a/src/glsl/link_uniform_block_active_visitor.h b/src/glsl/link_uniform_block_active_visitor.h index d8aefd69991..b663a884db4 100644 --- a/src/glsl/link_uniform_block_active_visitor.h +++ b/src/glsl/link_uniform_block_active_visitor.h @@ -35,8 +35,6 @@ struct link_uniform_block_active { unsigned num_array_elements; unsigned binding; - unsigned set; - unsigned index; bool has_instance_name; bool has_binding; diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp index b80e5736f6b..4df39e200d5 100644 --- a/src/glsl/link_uniform_blocks.cpp +++ b/src/glsl/link_uniform_blocks.cpp @@ -293,8 +293,6 @@ link_uniform_blocks(void *mem_ctx, blocks[i].NumUniforms = (unsigned)(ptrdiff_t)(&variables[parcel.index] - blocks[i].Uniforms); - blocks[i].Set = b->set; - blocks[i].Binding = b->binding; blocks[i].IsShaderStorage = b->is_shader_storage; i++; @@ -315,8 +313,6 @@ link_uniform_blocks(void *mem_ctx, blocks[i].NumUniforms = (unsigned)(ptrdiff_t)(&variables[parcel.index] - blocks[i].Uniforms); - blocks[i].Set = b->set; - blocks[i].Binding = b->binding; blocks[i].IsShaderStorage = b->is_shader_storage; i++; diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index af97da9cc21..e3597e57e73 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -327,7 +327,7 @@ nir_visitor::visit(ir_variable *ir) } var->data.index = ir->data.index; - var->data.descriptor_set = ir->data.set; + var->data.descriptor_set = 0; var->data.binding = ir->data.binding; /* XXX Get rid of buffer_index */ var->data.atomic.buffer_index = ir->data.binding; @@ -1003,20 +1003,11 @@ nir_visitor::visit(ir_expression *ir) op = nir_intrinsic_load_ubo_indirect; } - ir_constant *const_block = ir->operands[0]->as_constant(); - assert(const_block && "can't figure out descriptor set index"); - unsigned index = const_block->value.u[0]; - unsigned set = sh->UniformBlocks[index].Set; - unsigned binding = sh->UniformBlocks[index].Binding; - nir_intrinsic_instr *load = nir_intrinsic_instr_create(this->shader, op); load->num_components = ir->type->vector_elements; - load->const_index[0] = set; - load->const_index[1] = const_index ? const_index->value.u[0] : 0; /* base offset */ - nir_load_const_instr *load_binding = nir_load_const_instr_create(shader, 1); - load_binding->value.u[0] = binding; - nir_instr_insert_after_cf_list(this->cf_node_list, &load_binding->instr); - load->src[0] = nir_src_for_ssa(&load_binding->def); + load->const_index[0] = const_index ? const_index->value.u[0] : 0; /* base offset */ + load->const_index[1] = 1; /* number of vec4's */ + load->src[0] = evaluate_rvalue(ir->operands[0]); if (!const_index) load->src[1] = evaluate_rvalue(ir->operands[1]); add_instr(&load->instr, ir->type->vector_elements); -- 2.30.2