diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index c976826733c..c737fb6e366 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -1131,6 +1131,7 @@ glsl_type::component_slots() const return 1; case GLSL_TYPE_SUBROUTINE: return 1; + case GLSL_TYPE_FUNCTION: case GLSL_TYPE_SAMPLER: case GLSL_TYPE_ATOMIC_UINT: diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index f7d000c028b..0a8a0b97dc9 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -265,16 +265,17 @@ struct glsl_type { enum glsl_interface_packing packing, const char *block_name); + /** + * Get the instance of an subroutine type + */ + static const glsl_type *get_subroutine_instance(const char *subroutine_name); + /** * Get the instance of a function type */ static const glsl_type *get_function_instance(const struct glsl_type *return_type, const glsl_function_param *parameters, unsigned num_params); - /** - * Get the instance of an subroutine type - */ - static const glsl_type *get_subroutine_instance(const char *subroutine_name); /** * Get the type resulting from a multiplication of \p type_a * \p type_b @@ -715,12 +716,12 @@ private: /** Hash table containing the known interface types. */ static struct hash_table *interface_types; - /** Hash table containing the known function types. */ - static struct hash_table *function_types; - /** Hash table containing the known subroutine types. */ static struct hash_table *subroutine_types; + /** Hash table containing the known function types. */ + static struct hash_table *function_types; + static bool record_key_compare(const void *a, const void *b); static unsigned record_key_hash(const void *key); diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index af9f6ebb513..a5abc043867 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -296,12 +296,16 @@ typedef struct { */ int index; + /** + * Descriptor set binding for sampler or UBO. + */ + int descriptor_set; + /** * Initial binding point for a sampler or UBO. * * For array types, this represents the binding point for the first element. */ - int descriptor_set; int binding; /** diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index 3aa0efded3c..295a209b4e6 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -49,8 +49,7 @@ nir_builder_instr_insert(nir_builder *build, nir_instr *instr) nir_instr_insert(build->cursor, instr); /* Move the cursor forward. */ - if (build->cursor.option == nir_cursor_after_instr) - build->cursor.instr = instr; + build->cursor = nir_after_instr(instr); } static inline void diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c index 1fd8b24d33d..94002f18cd7 100644 --- a/src/glsl/nir/nir_from_ssa.c +++ b/src/glsl/nir/nir_from_ssa.c @@ -249,12 +249,7 @@ add_parallel_copy_to_end_of_block(nir_block *block, void *void_state) nir_parallel_copy_instr *pcopy = nir_parallel_copy_instr_create(state->dead_ctx); - nir_instr *last_instr = nir_block_last_instr(block); - if (last_instr && last_instr->type == nir_instr_type_jump) { - nir_instr_insert_before(last_instr, &pcopy->instr); - } else { - nir_instr_insert_after_block(block, &pcopy->instr); - } + nir_instr_insert(nir_after_block_before_jump(block), &pcopy->instr); } return true; diff --git a/src/glsl/nir/nir_lower_outputs_to_temporaries.c b/src/glsl/nir/nir_lower_outputs_to_temporaries.c index 715f1f84c48..1a3e7721c31 100644 --- a/src/glsl/nir/nir_lower_outputs_to_temporaries.c +++ b/src/glsl/nir/nir_lower_outputs_to_temporaries.c @@ -53,11 +53,7 @@ emit_output_copies(nir_shader *shader, nir_variable *temp, nir_variable *output) copy->variables[0] = nir_deref_var_create(copy, output); copy->variables[1] = nir_deref_var_create(copy, temp); - nir_instr *last_instr = nir_block_last_instr(block); - if (last_instr && last_instr->type == nir_instr_type_jump) - nir_instr_insert_before(last_instr, ©->instr); - else - nir_instr_insert_after_block(block, ©->instr); + nir_instr_insert(nir_after_block_before_jump(block), ©->instr); } } } @@ -83,8 +79,8 @@ nir_lower_outputs_to_temporaries(nir_shader *shader) if (output->name) ralloc_steal(output, output->name); - /* Give the temporary a new name with @out-temp appended */ - temp->name = ralloc_asprintf(temp, "%s@out-temp", output->name); + /* Give the output a new name with @out-temp appended */ + temp->name = ralloc_asprintf(var, "%s@out-temp", output->name); temp->data.mode = nir_var_global; temp->constant_initializer = NULL; @@ -93,5 +89,5 @@ nir_lower_outputs_to_temporaries(nir_shader *shader) emit_output_copies(shader, temp, output); } - exec_list_append(&shader->globals, &old_outputs); + exec_list_append(&shader->globals, &old_outputs); } diff --git a/src/glsl/nir/nir_types.cpp b/src/glsl/nir/nir_types.cpp index f3f3af97fde..809a7cff79c 100644 --- a/src/glsl/nir/nir_types.cpp +++ b/src/glsl/nir/nir_types.cpp @@ -252,7 +252,7 @@ glsl_vector_type(enum glsl_base_type base_type, unsigned components) const glsl_type * glsl_matrix_type(enum glsl_base_type base_type, unsigned rows, unsigned columns) { - assert(rows >= 1 && rows <= 4 && columns >= 1 && columns <= 4); + assert(rows > 1 && rows <= 4 && columns > 1 && columns <= 4); return glsl_type::get_instance(base_type, rows, columns); } diff --git a/src/glsl/nir/spirv.h b/src/glsl/nir/spirv.h index ea3799e2d8f..8472caf30e5 100644 --- a/src/glsl/nir/spirv.h +++ b/src/glsl/nir/spirv.h @@ -1,12 +1,17 @@ /* ** Copyright (c) 2014-2015 The Khronos Group Inc. +<<<<<<< HEAD ** +======= +** +>>>>>>> fdo-personal/nir-spirv ** Permission is hereby granted, free of charge, to any person obtaining a copy ** of this software and/or associated documentation files (the "Materials"), ** to deal in the Materials without restriction, including without limitation ** the rights to use, copy, modify, merge, publish, distribute, sublicense, ** and/or sell copies of the Materials, and to permit persons to whom the ** Materials are furnished to do so, subject to the following conditions: +<<<<<<< HEAD ** ** The above copyright notice and this permission notice shall be included in ** all copies or substantial portions of the Materials. @@ -15,6 +20,16 @@ ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND ** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ** +======= +** +** The above copyright notice and this permission notice shall be included in +** all copies or substantial portions of the Materials. +** +** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** +>>>>>>> fdo-personal/nir-spirv ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -33,13 +48,21 @@ ** Specification revision 31. ** Enumeration tokens for SPIR-V, in various styles: ** C, C++, C++11, JSON, Lua, Python +<<<<<<< HEAD ** +======= +** +>>>>>>> fdo-personal/nir-spirv ** - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL ** - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL ** - C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL ** - Lua will use tables, e.g.: spv.SourceLanguage.GLSL ** - Python will use dictionaries, e.g.: spv['SourceLanguage']['GLSL'] +<<<<<<< HEAD ** +======= +** +>>>>>>> fdo-personal/nir-spirv ** Some tokens act like mask values, which can be OR'd together, ** while others are mutually exclusive. The mask-like ones have ** "Mask" in their name, and a parallel enum that has the shift @@ -818,4 +841,3 @@ typedef enum SpvOp_ { } SpvOp; #endif // #ifndef spirv_H - diff --git a/src/glsl/nir/spirv2nir.c b/src/glsl/nir/spirv2nir.c index a7b8c0f4b15..e06e82595a2 100644 --- a/src/glsl/nir/spirv2nir.c +++ b/src/glsl/nir/spirv2nir.c @@ -49,6 +49,7 @@ int main(int argc, char **argv) const void *map = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0); assert(map != NULL); - nir_shader *shader = spirv_to_nir(map, word_count, MESA_SHADER_FRAGMENT, NULL); + nir_shader *shader = spirv_to_nir(map, MESA_SHADER_FRAGMENT, + word_count, NULL); nir_print_shader(shader, stderr); } diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 8fa80ba0f85..c3a16986fc1 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -556,7 +556,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode, default: unreachable("Unhandled opcode"); } - + vtn_foreach_decoration(b, val, type_decoration_cb, NULL); } @@ -644,10 +644,7 @@ vtn_get_builtin_location(SpvBuiltIn builtin, int *location, /* XXX figure this out */ unreachable("unhandled builtin"); case SpvBuiltInVertexId: - /* Vulkan defines VertexID to be zero-based and reserves the new - * builtin keyword VertexIndex to indicate the non-zero-based value. - */ - *location = SYSTEM_VALUE_VERTEX_ID_ZERO_BASE; + *location = SYSTEM_VALUE_VERTEX_ID; *mode = nir_var_system_value; break; case SpvBuiltInInstanceId: @@ -825,7 +822,7 @@ get_builtin_variable(struct vtn_builder *b, if (!var) { var = ralloc(b->shader, nir_variable); var->type = type; - + nir_variable_mode mode; vtn_get_builtin_location(builtin, &var->data.location, &mode); var->data.mode = mode; @@ -1060,10 +1057,10 @@ vtn_block_load(struct vtn_builder *b, nir_deref_var *src, struct vtn_type *type, nir_deref *src_tail) { unsigned set = src->var->data.descriptor_set; - + nir_ssa_def *binding = nir_imm_int(&b->nb, src->var->data.binding); nir_deref *deref = &src->deref; - + /* The block variable may be an array, in which case the array index adds * an offset to the binding. Figure out that index now. */ @@ -1097,7 +1094,7 @@ vtn_block_load(struct vtn_builder *b, nir_deref_var *src, type = type->array_element; break; } - + case nir_deref_type_struct: { nir_deref_struct *deref_struct = nir_deref_as_struct(deref); offset += type->offsets[deref_struct->index]; @@ -1461,7 +1458,7 @@ vtn_create_ssa_value(struct vtn_builder *b, const struct glsl_type *type) { struct vtn_ssa_value *val = rzalloc(b, struct vtn_ssa_value); val->type = type; - + if (!glsl_type_is_vector_or_scalar(type)) { unsigned elems = glsl_get_length(type); val->elems = ralloc_array(b, struct vtn_ssa_value *, elems); @@ -1517,16 +1514,16 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, unsigned coord_components = 0; switch (opcode) { case SpvOpImageSampleImplicitLod: - case SpvOpImageSampleExplicitLod: - case SpvOpImageSampleDrefImplicitLod: - case SpvOpImageSampleDrefExplicitLod: + case SpvOpImageSampleExplicitLod: + case SpvOpImageSampleDrefImplicitLod: + case SpvOpImageSampleDrefExplicitLod: case SpvOpImageSampleProjImplicitLod: - case SpvOpImageSampleProjExplicitLod: - case SpvOpImageSampleProjDrefImplicitLod: - case SpvOpImageSampleProjDrefExplicitLod: + case SpvOpImageSampleProjExplicitLod: + case SpvOpImageSampleProjDrefImplicitLod: + case SpvOpImageSampleProjDrefExplicitLod: case SpvOpImageFetch: case SpvOpImageGather: - case SpvOpImageDrefGather: + case SpvOpImageDrefGather: case SpvOpImageQueryLod: { /* All these types have the coordinate as their first real argument */ struct vtn_ssa_value *coord = vtn_ssa_value(b, w[idx++]); @@ -1547,16 +1544,16 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, texop = nir_texop_tex; break; - case SpvOpImageSampleExplicitLod: - case SpvOpImageSampleDrefImplicitLod: - case SpvOpImageSampleDrefExplicitLod: + case SpvOpImageSampleExplicitLod: + case SpvOpImageSampleDrefImplicitLod: + case SpvOpImageSampleDrefExplicitLod: case SpvOpImageSampleProjImplicitLod: - case SpvOpImageSampleProjExplicitLod: - case SpvOpImageSampleProjDrefImplicitLod: - case SpvOpImageSampleProjDrefExplicitLod: + case SpvOpImageSampleProjExplicitLod: + case SpvOpImageSampleProjDrefImplicitLod: + case SpvOpImageSampleProjDrefExplicitLod: case SpvOpImageFetch: case SpvOpImageGather: - case SpvOpImageDrefGather: + case SpvOpImageDrefGather: case SpvOpImageQuerySizeLod: case SpvOpImageQuerySize: case SpvOpImageQueryLod: @@ -1753,7 +1750,7 @@ vtn_matrix_multiply(struct vtn_builder *b, } } } - + dest = vtn_unwrap_matrix(dest); if (transpose_result) @@ -2386,10 +2383,7 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, break; case SpvOpExecutionMode: - /* - * TODO handle these - for Vulkan OriginUpperLeft is always set for - * fragment shaders, so we can ignore this for now - */ + /* TODO */ break; case SpvOpString: @@ -2603,16 +2597,16 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode, break; case SpvOpImageSampleImplicitLod: - case SpvOpImageSampleExplicitLod: - case SpvOpImageSampleDrefImplicitLod: - case SpvOpImageSampleDrefExplicitLod: + case SpvOpImageSampleExplicitLod: + case SpvOpImageSampleDrefImplicitLod: + case SpvOpImageSampleDrefExplicitLod: case SpvOpImageSampleProjImplicitLod: - case SpvOpImageSampleProjExplicitLod: - case SpvOpImageSampleProjDrefImplicitLod: - case SpvOpImageSampleProjDrefExplicitLod: + case SpvOpImageSampleProjExplicitLod: + case SpvOpImageSampleProjDrefImplicitLod: + case SpvOpImageSampleProjDrefExplicitLod: case SpvOpImageFetch: case SpvOpImageGather: - case SpvOpImageDrefGather: + case SpvOpImageDrefGather: case SpvOpImageQuerySizeLod: case SpvOpImageQuerySize: case SpvOpImageQueryLod: diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h index 0c64af05fad..9bb163f3bb0 100644 --- a/src/glsl/shader_enums.h +++ b/src/glsl/shader_enums.h @@ -23,8 +23,6 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "main/config.h" - #ifndef SHADER_ENUMS_H #define SHADER_ENUMS_H @@ -47,6 +45,7 @@ typedef enum #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1) + /** * Indexes for vertex program attributes. * GL_NV_vertex_program aliases generic attributes over the conventional @@ -153,6 +152,7 @@ typedef enum BITFIELD64_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX) /*@}*/ + /** * Indexes for vertex shader outputs, geometry shader inputs/outputs, and * fragment shader inputs.