diff options
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r-- | mesalib/src/glsl/Android.mk | 4 | ||||
-rw-r--r-- | mesalib/src/glsl/Makefile.am | 1 | ||||
-rw-r--r-- | mesalib/src/glsl/Makefile.sources | 10 | ||||
-rw-r--r-- | mesalib/src/glsl/SConscript | 2 | ||||
-rw-r--r-- | mesalib/src/glsl/builtin_compiler/Makefile.am | 3 | ||||
-rw-r--r-- | mesalib/src/glsl/glcpp/Makefile.am | 2 | ||||
-rw-r--r-- | mesalib/src/glsl/glcpp/glcpp-parse.y | 83 | ||||
-rw-r--r-- | mesalib/src/glsl/linker.cpp | 3 | ||||
-rw-r--r-- | mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp | 16 |
9 files changed, 66 insertions, 58 deletions
diff --git a/mesalib/src/glsl/Android.mk b/mesalib/src/glsl/Android.mk index f975d03d1..f5006ab03 100644 --- a/mesalib/src/glsl/Android.mk +++ b/mesalib/src/glsl/Android.mk @@ -36,8 +36,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(LIBGLCPP_FILES) \ - $(LIBGLSL_FILES) \ - $(LIBGLSL_CXX_FILES) + $(LIBGLSL_FILES) LOCAL_C_INCLUDES := \ external/astl/include \ @@ -59,7 +58,6 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(LIBGLCPP_FILES) \ $(LIBGLSL_FILES) \ - $(LIBGLSL_CXX_FILES) \ $(GLSL_SRCDIR)/builtin_compiler/builtin_stubs.cpp \ $(GLSL_COMPILER_CXX_FILES) diff --git a/mesalib/src/glsl/Makefile.am b/mesalib/src/glsl/Makefile.am index 6fb3d2d9d..ea7617685 100644 --- a/mesalib/src/glsl/Makefile.am +++ b/mesalib/src/glsl/Makefile.am @@ -43,7 +43,6 @@ libglsl_la_SOURCES = \ glsl_lexer.ll \ glsl_parser.cc \ $(LIBGLSL_FILES) \ - $(LIBGLSL_CXX_FILES) \ builtin_function.cpp libglsl_la_LIBADD = glcpp/libglcpp.la diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources index aafb53eae..5e098fc05 100644 --- a/mesalib/src/glsl/Makefile.sources +++ b/mesalib/src/glsl/Makefile.sources @@ -15,10 +15,6 @@ LIBGLCPP_GENERATED_FILES = \ # libglsl LIBGLSL_FILES = \ - $(GLSL_SRCDIR)/strtod.c \ - $(GLSL_SRCDIR)/ralloc.c - -LIBGLSL_CXX_FILES = \ $(GLSL_SRCDIR)/ast_expr.cpp \ $(GLSL_SRCDIR)/ast_function.cpp \ $(GLSL_SRCDIR)/ast_to_hir.cpp \ @@ -85,7 +81,9 @@ LIBGLSL_CXX_FILES = \ $(GLSL_SRCDIR)/opt_structure_splitting.cpp \ $(GLSL_SRCDIR)/opt_swizzle_swizzle.cpp \ $(GLSL_SRCDIR)/opt_tree_grafting.cpp \ - $(GLSL_SRCDIR)/s_expression.cpp + $(GLSL_SRCDIR)/s_expression.cpp \ + $(GLSL_SRCDIR)/strtod.c \ + $(GLSL_SRCDIR)/ralloc.c # glsl_compiler @@ -95,7 +93,7 @@ GLSL_COMPILER_CXX_FILES = \ # builtin_compiler # -# This is built before libglsl to generate builtin_funciton.cpp for libglsl. +# This is built before libglsl to generate builtin_function.cpp for libglsl. # For this to work, a dummy version of builtin_function.cpp, # builtin_stubs.cpp, is used. diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript index 89014ee3c..0cf25c07b 100644 --- a/mesalib/src/glsl/SConscript +++ b/mesalib/src/glsl/SConscript @@ -46,7 +46,7 @@ glsl_sources = [ source_lists = env.ParseSourceList('Makefile.sources') # add non-generated sources -for l in ('LIBGLCPP_FILES', 'LIBGLSL_FILES', 'LIBGLSL_CXX_FILES'): +for l in ('LIBGLCPP_FILES', 'LIBGLSL_FILES'): glsl_sources += source_lists[l] if env['msvc']: diff --git a/mesalib/src/glsl/builtin_compiler/Makefile.am b/mesalib/src/glsl/builtin_compiler/Makefile.am index 72032b524..d6f85a7f4 100644 --- a/mesalib/src/glsl/builtin_compiler/Makefile.am +++ b/mesalib/src/glsl/builtin_compiler/Makefile.am @@ -35,6 +35,7 @@ AM_CFLAGS = \ -I $(top_srcdir)/src/mesa \ -I $(GLSL_SRCDIR) \ -I $(GLSL_SRCDIR)/glcpp \ + -I $(GLSL_BUILDDIR) \ $(DEFINES_FOR_BUILD) AM_CXXFLAGS = $(AM_CFLAGS) @@ -51,7 +52,7 @@ builtin_compiler_SOURCES = \ $(GLSL_SRCDIR)/glcpp/glcpp-parse.y \ $(LIBGLCPP_FILES) \ $(GLSL_SRCDIR)/glsl_lexer.ll \ - $(GLSL_SRCDIR)/glsl_parser.cc \ + $(GLSL_BUILDDIR)/glsl_parser.cc \ $(LIBGLSL_FILES) \ $(LIBGLSL_CXX_FILES) \ $(top_srcdir)/src/mesa/program/hash_table.c \ diff --git a/mesalib/src/glsl/glcpp/Makefile.am b/mesalib/src/glsl/glcpp/Makefile.am index 87affce1c..04d8cda01 100644 --- a/mesalib/src/glsl/glcpp/Makefile.am +++ b/mesalib/src/glsl/glcpp/Makefile.am @@ -22,6 +22,8 @@ include ../Makefile.sources +TESTS = tests/glcpp-test + AM_CFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src/mapi \ diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y index 40c43c63e..b0537c3b0 100644 --- a/mesalib/src/glsl/glcpp/glcpp-parse.y +++ b/mesalib/src/glsl/glcpp/glcpp-parse.y @@ -190,6 +190,14 @@ line: control_line { ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n"); } +| HASH_LINE pp_tokens NEWLINE { + if (parser->skip_stack == NULL || + parser->skip_stack->type == SKIP_NO_SKIP) + { + _glcpp_parser_expand_and_lex_from (parser, + LINE_EXPANDED, $2); + } + } | text_line { _glcpp_parser_print_expanded_token_list (parser, $1); ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n"); @@ -244,14 +252,6 @@ control_line: } ralloc_free ($2); } -| HASH_LINE pp_tokens NEWLINE { - if (parser->skip_stack == NULL || - parser->skip_stack->type == SKIP_NO_SKIP) - { - _glcpp_parser_expand_and_lex_from (parser, - LINE_EXPANDED, $2); - } - } | HASH_IF conditional_tokens NEWLINE { /* Be careful to only evaluate the 'if' expression if * we are not skipping. When we are skipping, we @@ -327,12 +327,12 @@ control_line: glcpp_warning(& @1, parser, "ignoring illegal #elif without expression"); } } -| HASH_ELSE NEWLINE { +| HASH_ELSE { _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1); - } -| HASH_ENDIF NEWLINE { + } NEWLINE +| HASH_ENDIF { _glcpp_parser_skip_stack_pop (parser, & @1); - } + } NEWLINE | HASH_VERSION integer_constant NEWLINE { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { @@ -1150,46 +1150,49 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api) parser->new_source_number = 0; /* Add pre-defined macros. */ - add_builtin_define(parser, "GL_ARB_draw_buffers", 1); - add_builtin_define(parser, "GL_ARB_texture_rectangle", 1); + if (extensions != NULL) { + if (extensions->OES_EGL_image_external) + add_builtin_define(parser, "GL_OES_EGL_image_external", 1); + } if (api == API_OPENGLES2) add_builtin_define(parser, "GL_ES", 1); + else { + add_builtin_define(parser, "GL_ARB_draw_buffers", 1); + add_builtin_define(parser, "GL_ARB_texture_rectangle", 1); - if (extensions != NULL) { - if (extensions->EXT_texture_array) { - add_builtin_define(parser, "GL_EXT_texture_array", 1); - } + if (extensions != NULL) { + if (extensions->EXT_texture_array) { + add_builtin_define(parser, "GL_EXT_texture_array", 1); + } - if (extensions->ARB_fragment_coord_conventions) - add_builtin_define(parser, "GL_ARB_fragment_coord_conventions", - 1); + if (extensions->ARB_fragment_coord_conventions) + add_builtin_define(parser, "GL_ARB_fragment_coord_conventions", + 1); - if (extensions->ARB_explicit_attrib_location) - add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1); + if (extensions->ARB_explicit_attrib_location) + add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1); - if (extensions->ARB_shader_texture_lod) - add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1); + if (extensions->ARB_shader_texture_lod) + add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1); - if (extensions->ARB_draw_instanced) - add_builtin_define(parser, "GL_ARB_draw_instanced", 1); + if (extensions->ARB_draw_instanced) + add_builtin_define(parser, "GL_ARB_draw_instanced", 1); - if (extensions->ARB_conservative_depth) { - add_builtin_define(parser, "GL_AMD_conservative_depth", 1); - add_builtin_define(parser, "GL_ARB_conservative_depth", 1); - } + if (extensions->ARB_conservative_depth) { + add_builtin_define(parser, "GL_AMD_conservative_depth", 1); + add_builtin_define(parser, "GL_ARB_conservative_depth", 1); + } - if (extensions->OES_EGL_image_external) - add_builtin_define(parser, "GL_OES_EGL_image_external", 1); - - if (extensions->ARB_shader_bit_encoding) - add_builtin_define(parser, "GL_ARB_shader_bit_encoding", 1); + if (extensions->ARB_shader_bit_encoding) + add_builtin_define(parser, "GL_ARB_shader_bit_encoding", 1); - if (extensions->ARB_uniform_buffer_object) - add_builtin_define(parser, "GL_ARB_uniform_buffer_object", 1); + if (extensions->ARB_uniform_buffer_object) + add_builtin_define(parser, "GL_ARB_uniform_buffer_object", 1); - if (extensions->ARB_texture_cube_map_array) - add_builtin_define(parser, "GL_ARB_texture_cube_map_array", 1); + if (extensions->ARB_texture_cube_map_array) + add_builtin_define(parser, "GL_ARB_texture_cube_map_array", 1); + } } language_version = 110; diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp index 86371b5e6..3b2ab962b 100644 --- a/mesalib/src/glsl/linker.cpp +++ b/mesalib/src/glsl/linker.cpp @@ -2010,8 +2010,7 @@ is_varying_var(GLenum shaderType, const ir_variable *var) { /* Only fragment shaders will take a varying variable as an input */ if (shaderType == GL_FRAGMENT_SHADER && - var->mode == ir_var_in && - var->explicit_location) { + var->mode == ir_var_in) { switch (var->location) { case FRAG_ATTRIB_WPOS: case FRAG_ATTRIB_FACE: diff --git a/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp b/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp index 789f62afe..f85875f49 100644 --- a/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp +++ b/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp @@ -68,9 +68,9 @@ ir_rvalue * ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue *ir) { ir_dereference_array *orig_deref = ir->as_dereference_array(); - ir_assignment *assign; - ir_variable *index, *var; - ir_dereference *deref; + ir_assignment *assign, *value_assign; + ir_variable *index, *var, *value; + ir_dereference *deref, *deref_value; unsigned i; if (!orig_deref) @@ -95,6 +95,14 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL); list.push_tail(assign); + /* Store the value inside a temp, thus avoiding matrixes duplication */ + value = new(base_ir) ir_variable(orig_deref->array->type, "vec_value_tmp", + ir_var_temporary); + list.push_tail(value); + deref_value = new(base_ir) ir_dereference_variable(value); + value_assign = new(base_ir) ir_assignment(deref_value, orig_deref->array); + list.push_tail(value_assign); + /* Temporary where we store whichever value we swizzle out. */ var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v", ir_var_temporary); @@ -117,7 +125,7 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue * underlying variable. */ ir_rvalue *swizzle = - new(base_ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), + new(base_ir) ir_swizzle(deref_value->clone(mem_ctx, NULL), i, 0, 0, 0, 1); deref = new(base_ir) ir_dereference_variable(var); |