diff options
Diffstat (limited to 'mesalib/src')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_blitter.c | 12 | ||||
-rw-r--r-- | mesalib/src/glsl/Makefile.am | 18 | ||||
-rw-r--r-- | mesalib/src/glsl/ast_to_hir.cpp | 1 | ||||
-rw-r--r-- | mesalib/src/glsl/builtin_variables.cpp | 1 | ||||
-rw-r--r-- | mesalib/src/glsl/glsl_parser.yy | 35 | ||||
-rw-r--r-- | mesalib/src/glsl/ir.cpp | 11 | ||||
-rw-r--r-- | mesalib/src/glsl/linker.cpp | 60 | ||||
-rw-r--r-- | mesalib/src/glsl/linker.h | 3 | ||||
-rw-r--r-- | mesalib/src/glsl/opt_algebraic.cpp | 40 | ||||
-rwxr-xr-x | mesalib/src/mapi/glapi/gen/gl_API.xml | 32 | ||||
-rw-r--r-- | mesalib/src/mesa/main/macros.h | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/main/querymatrix.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_draw.c | 19 |
13 files changed, 142 insertions, 98 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index a51b9ef20..096d3bc2b 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -535,9 +535,9 @@ static void blitter_restore_textures(struct blitter_context_priv *ctx) ctx->base.saved_num_sampler_states = ~0; /* Fragment sampler views. */ - pipe->set_fragment_sampler_views(pipe, - ctx->base.saved_num_sampler_views, - ctx->base.saved_sampler_views); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, + ctx->base.saved_num_sampler_views, + ctx->base.saved_sampler_views); for (i = 0; i < ctx->base.saved_num_sampler_views; i++) pipe_sampler_view_reference(&ctx->base.saved_sampler_views[i], NULL); @@ -1309,7 +1309,7 @@ void util_blitter_blit_generic(struct blitter_context *blitter, views[0] = src; views[1] = pipe->create_sampler_view(pipe, src->texture, &templ); - pipe->set_fragment_sampler_views(pipe, 2, views); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, views); pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 2, samplers); pipe_sampler_view_reference(&views[1], NULL); @@ -1324,13 +1324,13 @@ void util_blitter_blit_generic(struct blitter_context *blitter, view = pipe->create_sampler_view(pipe, src->texture, &templ); - pipe->set_fragment_sampler_views(pipe, 1, &view); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &view); pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_state); pipe_sampler_view_reference(&view, NULL); } else { - pipe->set_fragment_sampler_views(pipe, 1, &src); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &src); pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_state); } diff --git a/mesalib/src/glsl/Makefile.am b/mesalib/src/glsl/Makefile.am index cbf253cb5..b9ed5b62b 100644 --- a/mesalib/src/glsl/Makefile.am +++ b/mesalib/src/glsl/Makefile.am @@ -32,6 +32,7 @@ AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) include Makefile.sources TESTS = glcpp/tests/glcpp-test \ + tests/general-ir-test \ tests/optimization-test \ tests/ralloc-test \ tests/sampler-types-test \ @@ -45,12 +46,29 @@ noinst_LTLIBRARIES = libglsl.la libglcpp.la check_PROGRAMS = \ glcpp/glcpp \ glsl_test \ + tests/general-ir-test \ tests/ralloc-test \ tests/sampler-types-test \ tests/uniform-initializer-test noinst_PROGRAMS = glsl_compiler +tests_general_ir_test_SOURCES = \ + $(top_srcdir)/src/mesa/main/hash_table.c \ + $(top_srcdir)/src/mesa/main/imports.c \ + $(top_srcdir)/src/mesa/program/prog_hash_table.c\ + $(top_srcdir)/src/mesa/program/symbol_table.c \ + $(GLSL_SRCDIR)/standalone_scaffolding.cpp \ + tests/builtin_variable_test.cpp \ + tests/invalidate_locations_test.cpp \ + tests/general_ir_test.cpp +tests_general_ir_test_CFLAGS = \ + $(PTHREAD_CFLAGS) +tests_general_ir_test_LDADD = \ + $(top_builddir)/src/gtest/libgtest.la \ + $(top_builddir)/src/glsl/libglsl.la \ + $(PTHREAD_LIBS) + tests_uniform_initializer_test_SOURCES = \ $(top_srcdir)/src/mesa/main/hash_table.c \ $(top_srcdir)/src/mesa/main/imports.c \ diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp index dfa32d920..b644b22c7 100644 --- a/mesalib/src/glsl/ast_to_hir.cpp +++ b/mesalib/src/glsl/ast_to_hir.cpp @@ -4876,7 +4876,6 @@ ast_interface_block::hir(exec_list *instructions, var_mode); } - var->init_interface_type(block_type); if (state->target == geometry_shader && var_mode == ir_var_shader_in) handle_geometry_shader_input_decl(state, loc, var); diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp index 64f34061a..fc1115bc4 100644 --- a/mesalib/src/glsl/builtin_variables.cpp +++ b/mesalib/src/glsl/builtin_variables.cpp @@ -890,7 +890,6 @@ builtin_variable_generator::generate_varyings() this->per_vertex_in.construct_interface_instance(); ir_variable *var = add_variable("gl_in", array(per_vertex_in_type, 0), ir_var_shader_in, -1); - var->init_interface_type(per_vertex_in_type); } if (state->target == vertex_shader || state->target == geometry_shader) { const glsl_type *per_vertex_out_type = diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy index 00589e28e..0a0708e95 100644 --- a/mesalib/src/glsl/glsl_parser.yy +++ b/mesalib/src/glsl/glsl_parser.yy @@ -2372,6 +2372,7 @@ layout_defaults: | layout_qualifier IN_TOK ';' { void *ctx = state; + $$ = NULL; if (state->target != geometry_shader) { _mesa_glsl_error(& @1, state, "input layout qualifiers only valid in " @@ -2380,8 +2381,22 @@ layout_defaults: _mesa_glsl_error(& @1, state, "input layout qualifiers must specify a primitive" " type"); + } else { + /* Make sure this is a valid input primitive type. */ + switch ($1.prim_type) { + case GL_POINTS: + case GL_LINES: + case GL_LINES_ADJACENCY: + case GL_TRIANGLES: + case GL_TRIANGLES_ADJACENCY: + $$ = new(ctx) ast_gs_input_layout(@1, $1.prim_type); + break; + default: + _mesa_glsl_error(&@1, state, + "invalid geometry shader input primitive type"); + break; + } } - $$ = new(ctx) ast_gs_input_layout(@1, $1.prim_type); } | layout_qualifier OUT_TOK ';' @@ -2390,8 +2405,22 @@ layout_defaults: _mesa_glsl_error(& @1, state, "out layout qualifiers only valid in " "geometry shaders"); - } else if (!state->out_qualifier->merge_qualifier(& @1, state, $1)) { - YYERROR; + } else { + if ($1.flags.q.prim_type) { + /* Make sure this is a valid output primitive type. */ + switch ($1.prim_type) { + case GL_POINTS: + case GL_LINE_STRIP: + case GL_TRIANGLE_STRIP: + break; + default: + _mesa_glsl_error(&@1, state, "invalid geometry shader output " + "primitive type"); + break; + } + } + if (!state->out_qualifier->merge_qualifier(& @1, state, $1)) + YYERROR; } $$ = NULL; } diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp index de9613e8f..54a8e400c 100644 --- a/mesalib/src/glsl/ir.cpp +++ b/mesalib/src/glsl/ir.cpp @@ -1603,8 +1603,15 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->depth_layout = ir_depth_layout_none; this->used = false; - if (type && type->base_type == GLSL_TYPE_SAMPLER) - this->read_only = true; + if (type != NULL) { + if (type->base_type == GLSL_TYPE_SAMPLER) + this->read_only = true; + + if (type->is_interface()) + this->init_interface_type(type); + else if (type->is_array() && type->fields.array->is_interface()) + this->init_interface_type(type->fields.array); + } } diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp index 9095a4015..b23c31a16 100644 --- a/mesalib/src/glsl/linker.cpp +++ b/mesalib/src/glsl/linker.cpp @@ -366,35 +366,38 @@ parse_program_resource_name(const GLchar *name, void -link_invalidate_variable_locations(gl_shader *sh, int input_base, - int output_base) +link_invalidate_variable_locations(exec_list *ir) { - foreach_list(node, sh->ir) { + foreach_list(node, ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); if (var == NULL) continue; - int base; - switch (var->mode) { - case ir_var_shader_in: - base = input_base; - break; - case ir_var_shader_out: - base = output_base; - break; - default: - continue; - } - - /* Only assign locations for generic attributes / varyings / etc. + /* Only assign locations for variables that lack an explicit location. + * Explicit locations are set for all built-in variables, generic vertex + * shader inputs (via layout(location=...)), and generic fragment shader + * outputs (also via layout(location=...)). */ - if ((var->location >= base) && !var->explicit_location) + if (!var->explicit_location) { var->location = -1; + var->location_frac = 0; + } - if ((var->location == -1) && !var->explicit_location) { + /* ir_variable::is_unmatched_generic_inout is used by the linker while + * connecting outputs from one stage to inputs of the next stage. + * + * There are two implicit assumptions here. First, we assume that any + * built-in variable (i.e., non-generic in or out) will have + * explicit_location set. Second, we assume that any generic in or out + * will not have explicit_location set. + * + * This second assumption will only be valid until + * GL_ARB_separate_shader_objects is supported. When that extension is + * implemented, this function will need some modifications. + */ + if (!var->explicit_location) { var->is_unmatched_generic_inout = 1; - var->location_frac = 0; } else { var->is_unmatched_generic_inout = 0; } @@ -2057,14 +2060,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) } } - /* Previous to GLSL version 1.30, different compilation units could mix and - * match shading language versions. With GLSL 1.30 and later, the versions - * of all shaders must match. - * - * GLSL ES has never allowed mixing of shading language versions. + /* In desktop GLSL, different shader versions may be linked together. In + * GLSL ES, all shader versions must be the same. */ - if ((is_es_prog || max_version >= 130) - && min_version != max_version) { + if (is_es_prog && min_version != max_version) { linker_error(prog, "all shaders must use same shading " "language version\n"); goto done; @@ -2221,18 +2220,15 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) /* Mark all generic shader inputs and outputs as unpaired. */ if (prog->_LinkedShaders[MESA_SHADER_VERTEX] != NULL) { link_invalidate_variable_locations( - prog->_LinkedShaders[MESA_SHADER_VERTEX], - VERT_ATTRIB_GENERIC0, VARYING_SLOT_VAR0); + prog->_LinkedShaders[MESA_SHADER_VERTEX]->ir); } if (prog->_LinkedShaders[MESA_SHADER_GEOMETRY] != NULL) { link_invalidate_variable_locations( - prog->_LinkedShaders[MESA_SHADER_GEOMETRY], - VARYING_SLOT_VAR0, VARYING_SLOT_VAR0); + prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->ir); } if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] != NULL) { link_invalidate_variable_locations( - prog->_LinkedShaders[MESA_SHADER_FRAGMENT], - VARYING_SLOT_VAR0, FRAG_RESULT_DATA0); + prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir); } /* FINISHME: The value of the max_attribute_index parameter is diff --git a/mesalib/src/glsl/linker.h b/mesalib/src/glsl/linker.h index 8a0027d2b..887cd33d1 100644 --- a/mesalib/src/glsl/linker.h +++ b/mesalib/src/glsl/linker.h @@ -31,8 +31,7 @@ link_function_calls(gl_shader_program *prog, gl_shader *main, gl_shader **shader_list, unsigned num_shaders); extern void -link_invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode, - int generic_base); +link_invalidate_variable_locations(exec_list *ir); extern void link_assign_uniform_locations(struct gl_shader_program *prog); diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp index 3e5802e18..37b2f02c6 100644 --- a/mesalib/src/glsl/opt_algebraic.cpp +++ b/mesalib/src/glsl/opt_algebraic.cpp @@ -210,6 +210,34 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) this->mem_ctx = ralloc_parent(ir); switch (ir->operation) { + case ir_unop_abs: + if (op_expr[0] == NULL) + break; + + switch (op_expr[0]->operation) { + case ir_unop_abs: + case ir_unop_neg: + this->progress = true; + temp = new(mem_ctx) ir_expression(ir_unop_abs, + ir->type, + op_expr[0]->operands[0], + NULL); + return swizzle_if_required(ir, temp); + default: + break; + } + break; + + case ir_unop_neg: + if (op_expr[0] == NULL) + break; + + if (op_expr[0]->operation == ir_unop_neg) { + this->progress = true; + return swizzle_if_required(ir, op_expr[0]->operands[0]); + } + break; + case ir_unop_logic_not: { enum ir_expression_operation new_op = ir_unop_logic_not; @@ -257,11 +285,9 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) * folding. */ if (op_const[0] && !op_const[1]) - reassociate_constant(ir, 0, op_const[0], - ir->operands[1]->as_expression()); + reassociate_constant(ir, 0, op_const[0], op_expr[1]); if (op_const[1] && !op_const[0]) - reassociate_constant(ir, 1, op_const[1], - ir->operands[0]->as_expression()); + reassociate_constant(ir, 1, op_const[1], op_expr[0]); break; case ir_binop_sub: @@ -315,11 +341,9 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) * constant folding. */ if (op_const[0] && !op_const[1]) - reassociate_constant(ir, 0, op_const[0], - ir->operands[1]->as_expression()); + reassociate_constant(ir, 0, op_const[0], op_expr[1]); if (op_const[1] && !op_const[0]) - reassociate_constant(ir, 1, op_const[1], - ir->operands[0]->as_expression()); + reassociate_constant(ir, 1, op_const[1], op_expr[0]); break; diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml index 0c78c5208..17c322519 100755 --- a/mesalib/src/mapi/glapi/gen/gl_API.xml +++ b/mesalib/src/mapi/glapi/gen/gl_API.xml @@ -13027,38 +13027,6 @@ <enum name="RGBA8_SNORM" value="0x8F97"/> </category> -<category name="GL_MESA_shader_debug"> - <enum name="DEBUG_OBJECT_MESA" value="0x8759"/> - <enum name="DEBUG_PRINT_MESA" value="0x875A"/> - <enum name="DEBUG_ASSERT_MESA" value="0x875B"/> - <function name="CreateDebugObjectMESA" exec="skip"> - <return type="GLhandleARB"/> - <glx ignore="true"/> - </function> - <function name="ClearDebugLogMESA" exec="skip"> - <param name="obj" type="GLhandleARB"/> - <param name="logType" type="GLenum"/> - <param name="shaderType" type="GLenum"/> - <glx ignore="true"/> - </function> - <function name="GetDebugLogMESA" exec="skip"> - <param name="obj" type="GLhandleARB"/> - <param name="logType" type="GLenum"/> - <param name="shaderType" type="GLenum"/> - <param name="maxLength" type="GLsizei"/> - <param name="length" type="GLsizei *" output="true"/> - <param name="debugLog" type="GLcharARB *" output="true"/> - <glx ignore="true"/> - </function> - <function name="GetDebugLogLengthMESA" exec="skip"> - <return type="GLsizei"/> - <param name="obj" type="GLhandleARB"/> - <param name="logType" type="GLenum"/> - <param name="shaderType" type="GLenum"/> - <glx ignore="true"/> - </function> -</category> - <category name="GL_SGIS_point_parameters"> <enum name="POINT_SIZE_MIN_SGIS" count="1" value="0x8126"> <size name="PointParameterfv" mode="get"/> diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h index 880c6564e..379f75663 100644 --- a/mesalib/src/mesa/main/macros.h +++ b/mesalib/src/mesa/main/macros.h @@ -193,7 +193,7 @@ static INLINE uint32_t U_FIXED(float value, uint32_t frac_bits) { value *= (1 << frac_bits); - return value < 0 ? 0 : value; + return value < 0.0f ? 0 : (uint32_t) value; } /** @@ -201,10 +201,10 @@ U_FIXED(float value, uint32_t frac_bits) * * \param frac_bits The number of bits used to store the fractional part. */ -static INLINE uint32_t +static INLINE int32_t S_FIXED(float value, uint32_t frac_bits) { - return value * (1 << frac_bits); + return (int32_t) (value * (1 << frac_bits)); } /*@}*/ diff --git a/mesalib/src/mesa/main/querymatrix.c b/mesalib/src/mesa/main/querymatrix.c index aee8aef12..19a8e9201 100644 --- a/mesalib/src/mesa/main/querymatrix.c +++ b/mesalib/src/mesa/main/querymatrix.c @@ -38,6 +38,7 @@ #define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0)) #if defined(_MSC_VER) +#if _MSC_VER < 1800 /* Not required on VS2013 and above. */ /* Oddly, the fpclassify() function doesn't exist in such a form * on MSVC. This is an implementation using slightly different * lower-level Windows functions. @@ -70,6 +71,7 @@ fpclassify(double x) return FP_NAN; } } +#endif /* _MSC_VER < 1800 */ #elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \ defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c index a440ae2a8..c35723087 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.c +++ b/mesalib/src/mesa/state_tracker/st_draw.c @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,11 +10,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS 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 NON-INFRINGEMENT. @@ -22,7 +22,7 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ /* @@ -72,7 +72,7 @@ static GLboolean all_varyings_in_vbos(const struct gl_client_array *arrays[]) { GLuint i; - + for (i = 0; i < VERT_ATTRIB_MAX; i++) if (arrays[i]->StrideB && !arrays[i]->InstanceDivisor && @@ -104,6 +104,7 @@ setup_index_buffer(struct st_context *st, ibuffer->offset = pointer_to_offset(ib->ptr); } else if (st->indexbuf_uploader) { + /* upload indexes from user memory into a real buffer */ if (u_upload_data(st->indexbuf_uploader, 0, ib->count * ibuffer->index_size, ib->ptr, &ibuffer->offset, &ibuffer->buffer) != PIPE_OK) { @@ -222,6 +223,7 @@ st_draw_vbo(struct gl_context *ctx, } util_draw_init_info(&info); + if (ib) { /* Get index bounds for user buffers. */ if (!index_bounds_valid) @@ -256,7 +258,7 @@ st_draw_vbo(struct gl_context *ctx, /* do actual drawing */ for (i = 0; i < nr_prims; i++) { - info.mode = translate_prim( ctx, prims[i].mode ); + info.mode = translate_prim(ctx, prims[i].mode); info.start = prims[i].start; info.count = prims[i].count; info.start_instance = prims[i].base_instance; @@ -282,8 +284,9 @@ st_draw_vbo(struct gl_context *ctx, /* don't trim, restarts might be inside index list */ cso_draw_vbo(st->cso_context, &info); } - else if (u_trim_pipe_prim(prims[i].mode, &info.count)) + else if (u_trim_pipe_prim(prims[i].mode, &info.count)) { cso_draw_vbo(st->cso_context, &info); + } } if (ib && st->indexbuf_uploader && !_mesa_is_bufferobj(ib->obj)) { |