diff --git a/3rdparty/glsl-optimizer/Changelog.md b/3rdparty/glsl-optimizer/Changelog.md index 2c308bcf7..3c0dd4166 100644 --- a/3rdparty/glsl-optimizer/Changelog.md +++ b/3rdparty/glsl-optimizer/Changelog.md @@ -1,9 +1,31 @@ GLSL optimizer Change Log ========================= +2015 06 +------- + +Fixes: + +* Fixed some cases of different precision matrix assignments being miscompiled on Metal. +* Fixed yet more issues with translation of weird loops. +* Fixed translation of matrix+scalar, matrix-scalar, matrix/scalar operations on Metal. + + +2015 05 +------- + +Fixes: + +* Fixes some cases of highp/mediump sampler sampling resulting in resulting temporaries wrongly being lowp. + + 2015 04 ------- +Goodies: +* GLES2: support EXT_draw_instanced / gl_InstanceIDEXT. +* Support gl_VertexID in GLSL < 1.30 when EXT_gpu_shader4 is used. + Fixes: * Metal: fixed some bugs with translation of weird loops. diff --git a/3rdparty/glsl-optimizer/src/glsl/ast_function.cpp b/3rdparty/glsl-optimizer/src/glsl/ast_function.cpp index de0ddd0e1..55d9e91a1 100644 --- a/3rdparty/glsl-optimizer/src/glsl/ast_function.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/ast_function.cpp @@ -1212,7 +1212,7 @@ emit_inline_matrix_constructor(const glsl_type *type, int ast_precision, * * - Construct a matrix from an arbirary combination of vectors and * scalars. The components of the constructor parameters are assigned - * to the matrix in colum-major order until the matrix is full. + * to the matrix in column-major order until the matrix is full. * * - Construct a matrix from a single matrix. The source matrix is copied * to the upper left portion of the constructed matrix, and the remaining diff --git a/3rdparty/glsl-optimizer/src/glsl/ast_to_hir.cpp b/3rdparty/glsl-optimizer/src/glsl/ast_to_hir.cpp index 9223557f6..c19ca4321 100644 --- a/3rdparty/glsl-optimizer/src/glsl/ast_to_hir.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/ast_to_hir.cpp @@ -3136,13 +3136,13 @@ process_initializer(ir_variable *var, ast_declaration *decl, static void apply_precision_to_variable(const struct ast_type_qualifier& qual, - ir_variable *var, + ir_variable *var, bool function_param, struct _mesa_glsl_parse_state *state) { if (!state->es_shader) return; - if (var->type->is_sampler() && qual.precision == ast_precision_none) - var->data.precision = ast_precision_low; // samplers default to low precision + if (var->type->is_sampler() && qual.precision == ast_precision_none && !function_param) + var->data.precision = ast_precision_low; // samplers default to low precision (outside of function arguments) else var->data.precision = qual.precision; } @@ -3548,7 +3548,7 @@ ast_declarator_list::hir(exec_list *instructions, apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc, false); - apply_precision_to_variable(this->type->qualifier, var, state); + apply_precision_to_variable(this->type->qualifier, var, false, state); if (this->type->qualifier.flags.q.invariant) { if (!is_varying_var(var, state->stage)) { @@ -4005,7 +4005,7 @@ ast_parameter_declarator::hir(exec_list *instructions, */ apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc, true); - apply_precision_to_variable(this->type->qualifier, var, state); + apply_precision_to_variable(this->type->qualifier, var, true, state); /* From section 4.1.7 of the GLSL 4.40 spec: * diff --git a/3rdparty/glsl-optimizer/src/glsl/builtin_variables.cpp b/3rdparty/glsl-optimizer/src/glsl/builtin_variables.cpp index 91beeb0ac..d887201ad 100644 --- a/3rdparty/glsl-optimizer/src/glsl/builtin_variables.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/builtin_variables.cpp @@ -830,10 +830,12 @@ void builtin_variable_generator::generate_vs_special_vars() { - if (state->is_version(130, 300)) + if (state->is_version(130, 300) || state->EXT_gpu_shader4_enable) add_system_value(SYSTEM_VALUE_VERTEX_ID, state->metal_target ? uint_t : int_t, "gl_VertexID", glsl_precision_high); if (state->ARB_draw_instanced_enable) add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceIDARB", glsl_precision_high); + if (state->EXT_draw_instanced_enable) + add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceIDEXT", glsl_precision_high); if (state->ARB_draw_instanced_enable || state->is_version(140, 300)) add_system_value(SYSTEM_VALUE_INSTANCE_ID, state->metal_target ? uint_t : int_t, "gl_InstanceID", glsl_precision_high); if (state->AMD_vertex_shader_layer_enable) diff --git a/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-parse.c b/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-parse.c index 21f7780b1..66e5f083b 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-parse.c +++ b/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-parse.c @@ -3727,7 +3727,7 @@ _arguments_parse (argument_list_t *arguments, else { if (argument->head == NULL) { /* Don't treat initial whitespace as - * part of the arguement. */ + * part of the argument. */ if (node->token->type == SPACE) continue; } @@ -4679,6 +4679,9 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio if (extensions->ARB_draw_instanced) add_builtin_define(parser, "GL_ARB_draw_instanced", 1); + if (extensions->EXT_draw_instanced) + add_builtin_define(parser, "GL_EXT_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); diff --git a/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-parse.y b/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-parse.y index 9cc5f4ac5..25a91169e 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-parse.y +++ b/3rdparty/glsl-optimizer/src/glsl/glcpp/glcpp-parse.y @@ -1462,7 +1462,7 @@ _arguments_parse (argument_list_t *arguments, else { if (argument->head == NULL) { /* Don't treat initial whitespace as - * part of the arguement. */ + * part of the argument. */ if (node->token->type == SPACE) continue; } @@ -2414,6 +2414,9 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio if (extensions->ARB_draw_instanced) add_builtin_define(parser, "GL_ARB_draw_instanced", 1); + if (extensions->EXT_draw_instanced) + add_builtin_define(parser, "GL_EXT_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); diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp index df9b8be42..ed732e2db 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_optimizer.cpp @@ -265,6 +265,21 @@ static void propagate_precision_expr(ir_instruction *ir, void *data) } +static void propagate_precision_texture(ir_instruction *ir, void *data) +{ + ir_texture* tex = ir->as_texture(); + if (!tex) + return; + + glsl_precision sampler_prec = tex->sampler->get_precision(); + if (tex->get_precision() == sampler_prec || sampler_prec == glsl_precision_undefined) + return; + + // set precision of ir_texture node to that of the sampler itself + tex->set_precision(sampler_prec); + ((precision_ctx*)data)->res = true; +} + struct undefined_ass_ctx { ir_variable* var; @@ -381,8 +396,19 @@ static bool propagate_precision(exec_list* list, bool assign_high_to_undefined) ctx.root_ir = list; foreach_in_list(ir_instruction, ir, list) { + visit_tree (ir, propagate_precision_texture, &ctx); visit_tree (ir, propagate_precision_deref, &ctx); + bool hadProgress = ctx.res; + ctx.res = false; visit_tree (ir, propagate_precision_assign, &ctx); + if (ctx.res) + { + // assignment precision propagation might have added precision + // to some variables; need to propagate dereference precision right + // after that too. + visit_tree (ir, propagate_precision_deref, &ctx); + } + ctx.res |= hadProgress; visit_tree (ir, propagate_precision_call, &ctx); visit_tree (ir, propagate_precision_expr, &ctx); } diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.cpp index 58f0ba475..f742e9fd1 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.cpp @@ -562,7 +562,9 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { EXT(AMD_vertex_shader_layer, true, false, AMD_vertex_shader_layer), EXT(AMD_vertex_shader_viewport_index, true, false, AMD_vertex_shader_viewport_index), EXT(EXT_draw_buffers, false, true, EXT_draw_buffers), + EXT(EXT_draw_instanced, false, true, EXT_draw_instanced), EXT(EXT_frag_depth, false, true, EXT_frag_depth), + EXT(EXT_gpu_shader4, true, false, EXT_gpu_shader4), EXT(EXT_separate_shader_objects, false, true, dummy_true), EXT(EXT_shader_framebuffer_fetch, false, true, EXT_shader_framebuffer_fetch), EXT(EXT_shader_integer_mix, true, true, EXT_shader_integer_mix), diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.h b/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.h index 746fd0dcf..51530d536 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.h +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_parser_extras.h @@ -473,8 +473,12 @@ struct _mesa_glsl_parse_state { bool AMD_vertex_shader_viewport_index_warn; bool EXT_draw_buffers_enable; bool EXT_draw_buffers_warn; + bool EXT_draw_instanced_enable; + bool EXT_draw_instanced_warn; bool EXT_frag_depth_enable; bool EXT_frag_depth_warn; + bool EXT_gpu_shader4_enable; + bool EXT_gpu_shader4_warn; bool EXT_separate_shader_objects_enable; bool EXT_separate_shader_objects_warn; bool EXT_shader_framebuffer_fetch_enable; diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp index 4e10082cd..9135d0933 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp @@ -642,7 +642,7 @@ glsl_type::field_type(const char *name) const return error_type; } -glsl_precision +const glsl_precision glsl_type::field_precision(const char *name) const { if (this->base_type != GLSL_TYPE_STRUCT) diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp index d7628eed7..9c5d807d8 100644 --- a/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/ir_print_glsl_visitor.cpp @@ -231,6 +231,10 @@ _mesa_print_ir_glsl(exec_list *instructions, } if (state->ARB_shader_texture_lod_enable) str.asprintf_append ("#extension GL_ARB_shader_texture_lod : enable\n"); + if (state->ARB_draw_instanced_enable) + str.asprintf_append ("#extension GL_ARB_draw_instanced : enable\n"); + if (state->EXT_gpu_shader4_enable) + str.asprintf_append ("#extension GL_EXT_gpu_shader4 : enable\n"); if (state->EXT_shader_texture_lod_enable) str.asprintf_append ("#extension GL_EXT_shader_texture_lod : enable\n"); if (state->OES_standard_derivatives_enable) @@ -242,7 +246,9 @@ _mesa_print_ir_glsl(exec_list *instructions, if (state->es_shader && state->language_version < 300) { if (state->EXT_draw_buffers_enable) - str.asprintf_append ("#extension GL_EXT_draw_buffers : require\n"); + str.asprintf_append ("#extension GL_EXT_draw_buffers : enable\n"); + if (state->EXT_draw_instanced_enable) + str.asprintf_append ("#extension GL_EXT_draw_instanced : enable\n"); } if (state->EXT_shader_framebuffer_fetch_enable) str.asprintf_append ("#extension GL_EXT_shader_framebuffer_fetch : enable\n"); @@ -823,7 +829,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir) sampler_uv_dim += 1; const bool is_proj = (uv_dim > sampler_uv_dim); const bool is_lod = (ir->op == ir_txl); - + #if 0 // BK - disable LOD workarounds. if (is_lod && state->es_shader && state->language_version < 300 && state->stage == MESA_SHADER_FRAGMENT) { @@ -855,6 +861,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir) } #endif // 0 + // texture function name //ACS: shadow lookups and lookups with dimensionality included in the name were deprecated in 130 if(state->language_version<130) diff --git a/3rdparty/glsl-optimizer/src/glsl/ir_print_metal_visitor.cpp b/3rdparty/glsl-optimizer/src/glsl/ir_print_metal_visitor.cpp index 01dcf8ee9..bad74c2de 100644 --- a/3rdparty/glsl-optimizer/src/glsl/ir_print_metal_visitor.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/ir_print_metal_visitor.cpp @@ -101,6 +101,7 @@ struct metal_print_context , paramsStr(ralloc_strdup(buffer, "")) , writingParams(false) , matrixCastsDone(false) + , matrixConstructorsDone(false) , shadowSamplerDone(false) , textureCounter(0) , attributeCounter(0) @@ -118,6 +119,7 @@ struct metal_print_context string_buffer paramsStr; bool writingParams; bool matrixCastsDone; + bool matrixConstructorsDone; bool shadowSamplerDone; int textureCounter; int attributeCounter; @@ -940,22 +942,57 @@ void ir_print_metal_visitor::visit(ir_expression *ir) bool op0cast = ir->operands[0] && is_different_precision(arg_prec, ir->operands[0]->get_precision()); bool op1cast = ir->operands[1] && is_different_precision(arg_prec, ir->operands[1]->get_precision()); bool op2cast = ir->operands[2] && is_different_precision(arg_prec, ir->operands[2]->get_precision()); + const bool op0matrix = ir->operands[0] && ir->operands[0]->type->is_matrix(); + const bool op1matrix = ir->operands[1] && ir->operands[1]->type->is_matrix(); + bool op0castTo1 = false; + bool op1castTo0 = false; // Metal does not support matrix precision casts, so when any of the arguments is a matrix, // take precision from it. This isn't fully robust now, but oh well. - if (op0cast && ir->operands[0]->type->is_matrix() && !op1cast) + if (op0cast && op0matrix && !op1cast) { op0cast = false; arg_prec = ir->operands[0]->get_precision(); op1cast = ir->operands[1] && is_different_precision(arg_prec, ir->operands[1]->get_precision()); } - if (op1cast && ir->operands[1]->type->is_matrix() && !op0cast) + if (op1cast && op1matrix && !op0cast) { op1cast = false; arg_prec = ir->operands[1]->get_precision(); op0cast = ir->operands[0] && is_different_precision(arg_prec, ir->operands[0]->get_precision()); } + // Metal does not have matrix+scalar and matrix-scalar operations; we need to create matrices + // out of the non-matrix argument. + if (ir->operation == ir_binop_add || ir->operation == ir_binop_sub) + { + if (op0matrix && !op1matrix) + { + op1cast = true; + op1castTo0 = true; + } + if (op1matrix && !op0matrix) + { + op0cast = true; + op0castTo1 = true; + } + if (op1castTo0 || op0castTo1) + { + if (!ctx.matrixConstructorsDone) + { + ctx.prefixStr.asprintf_append( + "inline float4x4 _xlinit_float4x4(float v) { return float4x4(float4(v), float4(v), float4(v), float4(v)); }\n" + "inline float3x3 _xlinit_float3x3(float v) { return float3x3(float3(v), float3(v), float3(v)); }\n" + "inline float2x2 _xlinit_float2x2(float v) { return float2x2(float2(v), float2(v)); }\n" + "inline half4x4 _xlinit_half4x4(half v) { return half4x4(half4(v), half4(v), half4(v), half4(v)); }\n" + "inline half3x3 _xlinit_half3x3(half v) { return half3x3(half3(v), half3(v), half3(v)); }\n" + "inline half2x2 _xlinit_half2x2(half v) { return half2x2(half2(v), half2(v)); }\n" + ); + ctx.matrixConstructorsDone = true; + } + } + } + const bool rescast = is_different_precision(arg_prec, res_prec) && !ir->type->is_boolean(); if (rescast) { @@ -1000,6 +1037,7 @@ void ir_print_metal_visitor::visit(ir_expression *ir) } else if (is_binop_func_like(ir->operation, ir->type)) { + // binary operation that must be printed like a function, "foo(a,b)" if (ir->operation == ir_binop_mod) { buffer.asprintf_append ("("); @@ -1025,23 +1063,58 @@ void ir_print_metal_visitor::visit(ir_expression *ir) if (ir->operation == ir_binop_mod) buffer.asprintf_append ("))"); } + else if (ir->get_num_operands() == 2 && ir->operation == ir_binop_div && op0matrix && !op1matrix) + { + // "matrix/scalar" - Metal does not have it, so print multiply by inverse instead + buffer.asprintf_append ("("); + ir->operands[0]->accept(this); + const bool halfCast = (arg_prec == glsl_precision_medium || arg_prec == glsl_precision_low); + buffer.asprintf_append (halfCast ? " * (1.0h/half(" : " * (1.0/("); + ir->operands[1]->accept(this); + buffer.asprintf_append (")))"); + } else if (ir->get_num_operands() == 2) { + // regular binary operator buffer.asprintf_append ("("); if (ir->operands[0]) { - if (op0cast) + if (op0castTo1) + { + buffer.asprintf_append ("_xlinit_"); + print_type_precision(buffer, ir->operands[1]->type, arg_prec, false); + buffer.asprintf_append ("("); + } + else if (op0cast) + { print_cast (buffer, arg_prec, ir->operands[0]); + } ir->operands[0]->accept(this); + if (op0castTo1) + { + buffer.asprintf_append (")"); + } } buffer.asprintf_append (" %s ", operator_glsl_strs[ir->operation]); if (ir->operands[1]) { - if (op1cast) + if (op1castTo0) + { + buffer.asprintf_append ("_xlinit_"); + print_type_precision(buffer, ir->operands[0]->type, arg_prec, false); + buffer.asprintf_append ("("); + } + else if (op1cast) + { print_cast (buffer, arg_prec, ir->operands[1]); + } ir->operands[1]->accept(this); + if (op1castTo0) + { + buffer.asprintf_append (")"); + } } buffer.asprintf_append (")"); } diff --git a/3rdparty/glsl-optimizer/src/glsl/link_uniforms.cpp b/3rdparty/glsl-optimizer/src/glsl/link_uniforms.cpp index ea2b0aa07..832c73b53 100644 --- a/3rdparty/glsl-optimizer/src/glsl/link_uniforms.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/link_uniforms.cpp @@ -256,7 +256,7 @@ namespace { * * As uniforms are added to the active set the number of active uniforms and * the storage requirements for those uniforms are accumulated. The active - * uniforms are added the the hash table supplied to the constructor. + * uniforms are added to the hash table supplied to the constructor. * * If the same uniform is added multiple times (i.e., once for each shader * target), it will only be accounted once. diff --git a/3rdparty/glsl-optimizer/src/glsl/loop_analysis.cpp b/3rdparty/glsl-optimizer/src/glsl/loop_analysis.cpp index 71fdcfc1a..240ffc739 100644 --- a/3rdparty/glsl-optimizer/src/glsl/loop_analysis.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/loop_analysis.cpp @@ -28,6 +28,8 @@ static bool is_loop_terminator(ir_if *ir); +static bool used_outside_loops(exec_node *head, ir_variable *var, bool first_assignment); + static bool all_expression_operands_are_loop_constant(ir_rvalue *, hash_table *); @@ -121,13 +123,20 @@ loop_state::get_for_inductor(const ir_variable *ir) } void +loop_state::insert_non_inductor(ir_variable *var) +{ + // key doesn't matter, just needs to be non-NULL + hash_table_insert(this->ht_non_inductors, this, var); +} + +bool loop_state::insert_inductor(loop_variable* loopvar, loop_variable_state* state, ir_loop* loop) { ir_variable* var = loopvar->var; // Check if this variable is already marked as "sure can't be a private inductor variable" if (hash_table_find(this->ht_non_inductors, var)) - return; + return false; // Check if this variable is used after the loop anywhere. If it is, it can't be a // variable that's private to the loop. @@ -143,7 +152,7 @@ loop_state::insert_inductor(loop_variable* loopvar, loop_variable_state* state, // add to list of "non inductors", so that next loop does not try // to add it as inductor again hash_table_insert(this->ht_non_inductors, state, var); - return; + return false; } } @@ -166,12 +175,13 @@ loop_state::insert_inductor(loop_variable* loopvar, loop_variable_state* state, // add to list of "non inductors", so that next loop does not try // to add it as inductor again hash_table_insert(this->ht_non_inductors, state, var); - return; + return false; } } state->private_induction_variable_count++; hash_table_insert(this->ht_inductors, state, var); + return true; } @@ -245,6 +255,8 @@ public: virtual ir_visitor_status visit(ir_loop_jump *); virtual ir_visitor_status visit(ir_dereference_variable *); + virtual ir_visitor_status visit(ir_variable *); + virtual ir_visitor_status visit_enter(ir_call *); virtual ir_visitor_status visit_enter(ir_loop *); @@ -288,6 +300,28 @@ loop_analysis::visit(ir_loop_jump *ir) } +ir_visitor_status +loop_analysis::visit(ir_variable *var) +{ + // if inside a loop, simply continue - we're only interested in variables declared + // entirely outside of any loops + if (!this->state.is_empty()) + return visit_continue; + + // Check if this variable is used outside a loop anywhere. If it is, it can't be a + // variable that's private to the loop, so can't be an inductor. + // This doesn't reject all possible non-inductors, notably anything declared in an + // outer loop that isn't an inductor in an inner loop, but it can eliminate some + // problem cases + if (used_outside_loops(var->next, var, false)) + { + // add to list of "non inductors" + loops->insert_non_inductor(var); + } + + return visit_continue; +} + ir_visitor_status loop_analysis::visit_enter(ir_call *) { @@ -451,11 +485,12 @@ loop_analysis::visit_leave(ir_loop *ir) ir_rvalue *const inc = get_basic_induction_increment(lv->first_assignment, ls->var_hash); if (inc != NULL) { - lv->increment = inc; + lv->increment = inc; - lv->remove(); - ls->induction_variables.push_tail(lv); - loops->insert_inductor(lv, ls, ir); + if (loops->insert_inductor(lv, ls, ir)) { + lv->remove(); + ls->induction_variables.push_tail(lv); + } } } @@ -699,6 +734,65 @@ is_loop_terminator(ir_if *ir) } +bool +used_outside_loops(exec_node *head, ir_variable *var, bool first_assignment) +{ + ir_variable_refcount_visitor refs; + for (exec_node* node = head; + !node->is_tail_sentinel(); + node = node->next) + { + ir_instruction *ir = (ir_instruction *) node; + if (ir->ir_type == ir_type_variable) + continue; + + // ignore the first assignment + if (!first_assignment && ir->ir_type == ir_type_assignment) + { + ir_assignment *assign = ir->as_assignment(); + ir_variable *assignee = assign->lhs->whole_variable_referenced(); + + if(assignee == var) + { + first_assignment = true; + continue; + } + } + + // we don't want to recurse into loops + if (ir->ir_type == ir_type_loop) + continue; + + // recurse only for if statements, the other case we would need to recurse is + // loops, but we are looking for uses outside of loops. + if (ir->ir_type == ir_type_if) + { + ir_if *irif = ir->as_if(); + if (used_outside_loops(irif->then_instructions.head, var, first_assignment)) + return true; + if (used_outside_loops(irif->else_instructions.head, var, first_assignment)) + return true; + + // if we didn't find in each branch with our recursion, skip + // otherwise the accept (&refs) below will recurse into loops + // and may give a false positive. + continue; + } + + // we know that we're not inside a loop as we haven't recursed inside, + // and we started outside of a loop, so any references to this variable + // mean it is used outside of any loops + ir->accept (&refs); + if (refs.find_variable_entry(var)) + { + return true; + } + } + + return false; +} + + loop_state * analyze_loop_variables(exec_list *instructions) { diff --git a/3rdparty/glsl-optimizer/src/glsl/loop_analysis.h b/3rdparty/glsl-optimizer/src/glsl/loop_analysis.h index 09882d933..299dbcfc8 100644 --- a/3rdparty/glsl-optimizer/src/glsl/loop_analysis.h +++ b/3rdparty/glsl-optimizer/src/glsl/loop_analysis.h @@ -249,7 +249,8 @@ public: loop_variable_state *insert(ir_loop *ir); loop_variable_state* get_for_inductor (const ir_variable*); - void insert_inductor(loop_variable* loopvar, loop_variable_state* state, ir_loop* loop); + bool insert_inductor(loop_variable* loopvar, loop_variable_state* state, ir_loop* loop); + void insert_non_inductor(ir_variable *var); bool loop_found; diff --git a/3rdparty/glsl-optimizer/src/glsl/lower_packing_builtins.cpp b/3rdparty/glsl-optimizer/src/glsl/lower_packing_builtins.cpp index db73c7b0f..f6b38e3f8 100644 --- a/3rdparty/glsl-optimizer/src/glsl/lower_packing_builtins.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/lower_packing_builtins.cpp @@ -569,8 +569,8 @@ private: * return pack_uvec2_to_uint(uvec2( * round(clamp(VEC2_RVALUE, 0.0f, 1.0f) * 65535.0f))); * - * Here it is safe to directly convert the vec2 to uvec2 because the the - * vec2 has been clamped to a non-negative range. + * Here it is safe to directly convert the vec2 to uvec2 because the vec2 + * has been clamped to a non-negative range. */ assert(vec2_rval->type == glsl_type::vec2_type); diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_dead_builtin_varyings.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_dead_builtin_varyings.cpp index d7face480..cb8cf87e3 100644 --- a/3rdparty/glsl-optimizer/src/glsl/opt_dead_builtin_varyings.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/opt_dead_builtin_varyings.cpp @@ -35,7 +35,7 @@ * the built-in varyings have pre-assigned locations. Also, the elimination * of unused gl_TexCoord elements requires its own lowering pass anyway. * - * It's implemented by replacing all occurences of dead varyings with + * It's implemented by replacing all occurrences of dead varyings with * temporary variables, which creates dead code. It is recommended to run * a dead-code elimination pass after this. * @@ -280,7 +280,7 @@ public: * * We're going to break down the gl_TexCoord array into separate * variables. First, add declarations of the new variables all - * occurences of gl_TexCoord will be replaced with. + * occurrences of gl_TexCoord will be replaced with. */ if (info->lower_texcoord_array) { prepare_array(ir, this->new_texcoord, ARRAY_SIZE(this->new_texcoord), @@ -411,7 +411,7 @@ public: * variable dereference representing gl_TexCoord[i]. */ if (this->info->lower_texcoord_array) { - /* gl_TexCoord[i] occurence */ + /* gl_TexCoord[i] occurrence */ ir_dereference_array *const da = (*rvalue)->as_dereference_array(); if (da && da->variable_referenced() == @@ -425,7 +425,7 @@ public: /* Same for gl_FragData. */ if (this->info->lower_fragdata_array) { - /* gl_FragData[i] occurence */ + /* gl_FragData[i] occurrence */ ir_dereference_array *const da = (*rvalue)->as_dereference_array(); if (da && da->variable_referenced() == this->info->fragdata_array) { diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_function_inlining.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_function_inlining.cpp index b9c373b2b..90cca2b75 100644 --- a/3rdparty/glsl-optimizer/src/glsl/opt_function_inlining.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/opt_function_inlining.cpp @@ -150,7 +150,7 @@ ir_call::generate_inline(ir_instruction *next_ir) parameters[i]->data.precision = param->get_precision(); prec_params_max = higher_precision (prec_params_max, (glsl_precision)parameters[i]->data.precision); - /* Remove the read-only decoration becuase we're going to write + /* Remove the read-only decoration because we're going to write * directly to this variable. If the cloned variable is left * read-only and the inlined function is inside a loop, the loop * analysis code will get confused. diff --git a/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp index 2d014b47a..b5ad168ae 100644 --- a/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp @@ -106,6 +106,8 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Extensions.OES_EGL_image_external = true; ctx->Extensions.OES_standard_derivatives = true; + ctx->Extensions.EXT_draw_instanced = true; + ctx->Extensions.EXT_gpu_shader4 = true; ctx->Extensions.EXT_shader_integer_mix = true; ctx->Extensions.EXT_texture3D = true; ctx->Extensions.EXT_texture_array = true; @@ -113,6 +115,8 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Extensions.NV_texture_rectangle = true; + ctx->Const.AllowGLSLExtensionDirectiveMidShader = true; // makes it easier to run tests + ctx->Const.GLSLVersion = 120; /* 1.20 minimums. */ diff --git a/3rdparty/glsl-optimizer/src/mesa/main/mtypes.h b/3rdparty/glsl-optimizer/src/mesa/main/mtypes.h index 2003632bf..d351159d0 100644 --- a/3rdparty/glsl-optimizer/src/mesa/main/mtypes.h +++ b/3rdparty/glsl-optimizer/src/mesa/main/mtypes.h @@ -1491,6 +1491,7 @@ struct gl_extensions GLboolean EXT_depth_bounds_test; GLboolean EXT_draw_buffers; GLboolean EXT_draw_buffers2; + GLboolean EXT_draw_instanced; GLboolean EXT_framebuffer_blit; GLboolean EXT_framebuffer_multisample; GLboolean EXT_framebuffer_multisample_blit_scaled; diff --git a/3rdparty/glsl-optimizer/src/mesa/program/hash_table.h b/3rdparty/glsl-optimizer/src/mesa/program/hash_table.h index e95fc4982..20595aac4 100644 --- a/3rdparty/glsl-optimizer/src/mesa/program/hash_table.h +++ b/3rdparty/glsl-optimizer/src/mesa/program/hash_table.h @@ -116,8 +116,8 @@ extern void hash_table_insert(struct hash_table *ht, void *data, * Add an element to a hash table with replacement * * \return - * 1 if it did replace the the value (in which case the old key is kept), 0 if - * it did not replace the value (in which case the new key is kept). + * 1 if it did replace the value (in which case the old key is kept), 0 if it + * did not replace the value (in which case the new key is kept). * * \warning * If \c key is already in the hash table, \c data will \b replace the most diff --git a/3rdparty/glsl-optimizer/tests/fragment/ast-out.txt b/3rdparty/glsl-optimizer/tests/fragment/ast-out.txt index fae455fda..90a8b9fa3 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/ast-out.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/ast-out.txt @@ -5,7 +5,8 @@ void main () discard; }; a_2 = 4.0; - for (int i_1 = 0; i_1 < 10; i_1++, a_2 += 1.0) { + for (int i_1 = 0; i_1 < 10; i_1++) { + a_2 += 1.0; }; while (true) { a_2 += 2.0; diff --git a/3rdparty/glsl-optimizer/tests/fragment/ast-outES3.txt b/3rdparty/glsl-optimizer/tests/fragment/ast-outES3.txt index 73a494c03..da1b7ee4b 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/ast-outES3.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/ast-outES3.txt @@ -7,7 +7,8 @@ void main () discard; }; a_2 = 4.0; - for (highp int i_1 = 0; i_1 < 10; i_1++, a_2 += 1.0) { + for (highp int i_1 = 0; i_1 < 10; i_1++) { + a_2 += 1.0; }; while (true) { a_2 += 2.0; diff --git a/3rdparty/glsl-optimizer/tests/fragment/ast-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/fragment/ast-outES3Metal.txt index 3f7ca4fde..0069dadf4 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/ast-outES3Metal.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/ast-outES3Metal.txt @@ -16,7 +16,8 @@ fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]] discard_fragment(); }; a_2 = 4.0; - for (int i_1 = 0; i_1 < 10; i_1++, a_2 += 1.0) { + for (int i_1 = 0; i_1 < 10; i_1++) { + a_2 += 1.0; }; while (true) { a_2 += 2.0; diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-loop-share-index-out.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-loop-share-index-out.txt index c934a7645..bc1b63be6 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/bug-loop-share-index-out.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-loop-share-index-out.txt @@ -5,16 +5,24 @@ void main () int myIdx_2; r_1 = vec4(0.0, 0.0, 0.0, 0.0); myIdx_2 = 1; - for (; myIdx_2 < loopNum; myIdx_2++) { + while (true) { + if ((myIdx_2 >= loopNum)) { + break; + }; r_1.x = (r_1.x + 1.0); r_1.y = (r_1.y + 2.0); r_1.z = (r_1.z + 3.0); + myIdx_2++; }; myIdx_2 = 2; - for (; myIdx_2 < loopNum; myIdx_2++) { + while (true) { + if ((myIdx_2 >= loopNum)) { + break; + }; r_1.x = (r_1.x + 1.0); r_1.y = (r_1.y + 2.0); r_1.z = (r_1.z + 3.0); + myIdx_2++; }; gl_FragColor = r_1; } diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-inES3.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-inES3.txt new file mode 100644 index 000000000..97eb07112 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-inES3.txt @@ -0,0 +1,15 @@ +#version 300 es + +// There was a bug where due to xll_tex2Dlod sampling of a _CameraDepthTexture (that is a highp sampler) +// was producing a missing cast between half4 and float4 on Metal output. +// Shader is a minimal part of Unity's camera motion blur shader that exposes the bug + +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { return textureLod(s, coord.xy, coord.w); } +uniform highp sampler2D _CameraDepthTexture; +in highp vec2 varUV; +out mediump vec4 _fragData; +void main() +{ + highp float z = xll_tex2Dlod(_CameraDepthTexture, vec4(varUV, 0.0, 0.0)).x; + _fragData = vec4(z); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-outES3.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-outES3.txt new file mode 100644 index 000000000..836ee2a6c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-outES3.txt @@ -0,0 +1,17 @@ +#version 300 es +uniform highp sampler2D _CameraDepthTexture; +in highp vec2 varUV; +out mediump vec4 _fragData; +void main () +{ + highp vec4 tmpvar_1; + tmpvar_1 = textureLod (_CameraDepthTexture, varUV, 0.0).xxxx; + _fragData = tmpvar_1; +} + + +// stats: 0 alu 1 tex 0 flow +// inputs: 1 +// #0: varUV (high float) 2x1 [-1] +// textures: 1 +// #0: _CameraDepthTexture (high 2d) 0x0 [-1] diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-outES3Metal.txt new file mode 100644 index 000000000..993c73706 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highp-outES3Metal.txt @@ -0,0 +1,26 @@ +#include +using namespace metal; +struct xlatMtlShaderInput { + float2 varUV; +}; +struct xlatMtlShaderOutput { + half4 _fragData [[color(0)]]; +}; +struct xlatMtlShaderUniform { +}; +fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]] + , texture2d _CameraDepthTexture [[texture(0)]], sampler _mtlsmp__CameraDepthTexture [[sampler(0)]]) +{ + xlatMtlShaderOutput _mtl_o; + float4 tmpvar_1; + tmpvar_1 = _CameraDepthTexture.sample(_mtlsmp__CameraDepthTexture, (float2)(_mtl_i.varUV), level(0.0)).xxxx; + _mtl_o._fragData = half4(tmpvar_1); + return _mtl_o; +} + + +// stats: 0 alu 1 tex 0 flow +// inputs: 1 +// #0: varUV (high float) 2x1 [-1] +// textures: 1 +// #0: _CameraDepthTexture (high 2d) 0x0 [-1] loc 0 diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-inES3.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-inES3.txt new file mode 100644 index 000000000..07579cf92 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-inES3.txt @@ -0,0 +1,118 @@ +#version 300 es + +// There was a bug where due to xll_tex2Dlod sampling of a _CameraDepthTexture (that is a highp sampler) +// was producing a missing cast between half4 and float4 on Metal output. +// Shader is part of Unity's camera motion blur shader. + +vec4 xll_tex2Dlod(sampler2D s, vec4 coord) { return textureLod( s, coord.xy, coord.w); } +struct v2f { + highp vec4 pos; + highp vec2 uv; +}; +uniform highp vec3 _WorldSpaceCameraPos; +uniform highp vec4 _ProjectionParams; +uniform highp vec4 _ScreenParams; +uniform highp vec4 _ZBufferParams; +uniform highp vec4 _WorldSpaceLightPos0; +uniform highp mat4 _Object2World; +uniform highp mat4 _World2Object; +uniform highp float _MaxRadiusOrKInPaper; +const highp int SmallDiscKernelSamples = 12; +const highp vec2[12] SmallDiscKernel = vec2[12]( vec2( -0.326212, -0.40581), vec2( -0.840144, -0.07358), vec2( -0.695914, 0.457137), vec2( -0.203345, 0.620716), vec2( 0.96234, -0.194983), vec2( 0.473434, -0.480026), vec2( 0.519456, 0.767022), vec2( 0.185461, -0.893124), vec2( 0.507431, 0.064425), vec2( 0.89642, 0.412458), vec2( -0.32194, -0.932615), vec2( -0.791559, -0.59771)); +uniform sampler2D _MainTex; +uniform highp sampler2D _CameraDepthTexture; +uniform sampler2D _VelTex; +uniform sampler2D _NeighbourMaxTex; +uniform sampler2D _NoiseTex; +uniform sampler2D _TileTexDebug; +uniform highp vec4 _MainTex_TexelSize; +uniform highp vec4 _CameraDepthTexture_TexelSize; +uniform highp vec4 _VelTex_TexelSize; +uniform highp mat4 _InvViewProj; +uniform highp mat4 _PrevViewProj; +uniform highp mat4 _ToPrevViewProjCombined; +uniform highp float _Jitter; +uniform highp float _VelocityScale; +uniform highp float _DisplayVelocityScale; +uniform highp float _MaxVelocity; +uniform highp float _MinVelocity; +uniform highp vec4 _BlurDirectionPacked; +uniform highp float _SoftZDistance; +highp float Linear01Depth( in highp float z ) +{ + return (1.0 / ((_ZBufferParams.x * z) + _ZBufferParams.y)); +} +highp float cone( in highp vec2 px, in highp vec2 py, in highp vec2 v ) +{ + return clamp( (1.0 - (length((px - py)) / length(v))), 0.0, 1.0); +} +highp float cylinder( in highp vec2 x, in highp vec2 y, in highp vec2 v ) +{ + highp float lv = length(v); + return (1.0 - smoothstep( (0.95 * lv), (1.05 * lv), length((x - y)))); +} +highp float softDepthCompare( in highp float za, in highp float zb ) +{ + return clamp( (1.0 - ((za - zb) / _SoftZDistance)), 0.0, 1.0); +} +highp vec4 ReconstructionDiscBlur( in v2f i ) +{ + highp vec2 xf = i.uv; + highp vec2 x = i.uv; + + if ((_MainTex_TexelSize.y < 0.0)) + { + xf.y = (1.0 - xf.y); + } + + highp vec2 x2 = xf; + highp vec2 vn = xll_tex2Dlod(_NeighbourMaxTex, vec4(x2, 0.0, 0.0)).xy; + highp vec4 cx = xll_tex2Dlod(_MainTex, vec4(x, 0.0, 0.0)); + + highp vec2 vx = xll_tex2Dlod(_VelTex, vec4(xf, 0.0, 0.0)).xy; + highp vec4 noise = ((xll_tex2Dlod( _NoiseTex, (vec4(i.uv, 0.0, 0.0) * 11.0)) * 2.0) - 1.0); + highp float zx = xll_tex2Dlod(_CameraDepthTexture, vec4(x, 0.0, 0.0)).x; + + zx = (-Linear01Depth( zx)); + noise *= (_MainTex_TexelSize.xyxy * _Jitter); + + highp float weight = 1.0; + highp vec4 sum = (cx * weight); + highp vec4 jitteredDir = (vn.xyxy + noise.xyyz); + + jitteredDir = ((max( abs(jitteredDir.xyxy), ((_MainTex_TexelSize.xyxy * _MaxVelocity) * 0.15)) * sign(jitteredDir.xyxy)) * vec4( 1.0, 1.0, -1.0, -1.0)); + highp int l = 0; + for ( ; (l < 12); (l++)) { + + highp vec4 y = (i.uv.xyxy + ((jitteredDir.xyxy * SmallDiscKernel[l].xyxy) * vec4( 1.0, 1.0, -1.0, -1.0))); + highp vec4 yf = y; + + if ((_MainTex_TexelSize.y < 0.0)){ + yf.yw = (1.0 - yf.yw); + } + + highp vec2 vy = xll_tex2Dlod( _VelTex, vec4( yf.xy, 0.0, 0.0)).xy; + highp float zy = xll_tex2Dlod( _CameraDepthTexture, vec4( y.xy, 0.0, 0.0)).x; + zy = (-Linear01Depth( zy)); + + highp float f = softDepthCompare( zx, zy); + highp float b = softDepthCompare( zy, zx); + highp float alphay = (((b * cone( x, y.xy, vx)) + (f * cone( y.xy, x, vy))) + ((cylinder( y.xy, x, vy) * cylinder( x, y.xy, vx)) * 2.0)); + + highp vec4 cy = xll_tex2Dlod( _MainTex, vec4( y.xy, 0.0, 0.0)); + sum += (cy * alphay); + weight += alphay; + } + + return (sum / weight); +} +in highp vec2 xlv_TEXCOORD0; +out mediump vec4 _fragData; +void main() { + highp vec4 xl_retval; + v2f xlt_i; + xlt_i.pos = vec4(0.0); + xlt_i.uv = vec2(xlv_TEXCOORD0); + xl_retval = ReconstructionDiscBlur(xlt_i); + _fragData = vec4(xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-outES3.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-outES3.txt new file mode 100644 index 000000000..8b29e014c --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-outES3.txt @@ -0,0 +1,161 @@ +#version 300 es +uniform highp vec4 _ZBufferParams; +uniform sampler2D _MainTex; +uniform highp sampler2D _CameraDepthTexture; +uniform sampler2D _VelTex; +uniform sampler2D _NeighbourMaxTex; +uniform sampler2D _NoiseTex; +uniform highp vec4 _MainTex_TexelSize; +uniform highp float _Jitter; +uniform highp float _MaxVelocity; +uniform highp float _SoftZDistance; +in highp vec2 xlv_TEXCOORD0; +out mediump vec4 _fragData; +void main () +{ + highp vec2 tmpvar_1; + tmpvar_1 = xlv_TEXCOORD0; + highp vec4 jitteredDir_3; + highp vec4 sum_4; + highp float weight_5; + highp float zx_6; + highp vec2 vx_7; + highp vec2 x_8; + highp vec2 xf_9; + xf_9 = xlv_TEXCOORD0; + x_8 = xlv_TEXCOORD0; + if ((_MainTex_TexelSize.y < 0.0)) { + xf_9.y = (1.0 - xlv_TEXCOORD0.y); + }; + lowp vec4 tmpvar_10; + tmpvar_10 = textureLod (_NeighbourMaxTex, xf_9, 0.0); + highp vec2 tmpvar_11; + tmpvar_11 = tmpvar_10.xy; + lowp vec4 tmpvar_12; + tmpvar_12 = textureLod (_MainTex, xlv_TEXCOORD0, 0.0); + highp vec4 tmpvar_13; + tmpvar_13 = tmpvar_12; + lowp vec4 tmpvar_14; + tmpvar_14 = textureLod (_VelTex, xf_9, 0.0); + highp vec2 tmpvar_15; + tmpvar_15 = tmpvar_14.xy; + vx_7 = tmpvar_15; + highp vec4 tmpvar_16; + tmpvar_16.zw = vec2(0.0, 0.0); + tmpvar_16.xy = xlv_TEXCOORD0; + highp vec4 coord_17; + coord_17 = (tmpvar_16 * 11.0); + lowp vec4 tmpvar_18; + tmpvar_18 = textureLod (_NoiseTex, coord_17.xy, coord_17.w); + highp vec4 tmpvar_19; + tmpvar_19 = ((tmpvar_18 * 2.0) - 1.0); + zx_6 = -((1.0/(( + (_ZBufferParams.x * textureLod (_CameraDepthTexture, xlv_TEXCOORD0, 0.0).x) + + _ZBufferParams.y)))); + weight_5 = 1.0; + sum_4 = tmpvar_13; + highp vec4 tmpvar_20; + tmpvar_20 = (tmpvar_11.xyxy + (tmpvar_19 * (_MainTex_TexelSize.xyxy * _Jitter)).xyyz); + jitteredDir_3 = ((max ( + abs(tmpvar_20.xyxy) + , + ((_MainTex_TexelSize.xyxy * _MaxVelocity) * 0.15) + ) * sign(tmpvar_20.xyxy)) * vec4(1.0, 1.0, -1.0, -1.0)); + for (highp int l_2 = 0; l_2 < 12; l_2++) { + highp float zy_21; + highp vec4 yf_22; + highp vec4 tmpvar_23; + tmpvar_23 = (tmpvar_1.xyxy + ((jitteredDir_3.xyxy * vec2[12](vec2(-0.326212, -0.40581), vec2(-0.840144, -0.07358), vec2(-0.695914, 0.457137), vec2(-0.203345, 0.620716), vec2(0.96234, -0.194983), vec2(0.473434, -0.480026), vec2(0.519456, 0.767022), vec2(0.185461, -0.893124), vec2(0.507431, 0.064425), vec2(0.89642, 0.412458), vec2(-0.32194, -0.932615), vec2(-0.791559, -0.59771))[l_2].xyxy) * vec4(1.0, 1.0, -1.0, -1.0))); + yf_22 = tmpvar_23; + if ((_MainTex_TexelSize.y < 0.0)) { + yf_22.yw = (1.0 - tmpvar_23.yw); + }; + lowp vec4 tmpvar_24; + tmpvar_24 = textureLod (_VelTex, yf_22.xy, 0.0); + highp vec2 tmpvar_25; + tmpvar_25 = tmpvar_24.xy; + zy_21 = -((1.0/(( + (_ZBufferParams.x * textureLod (_CameraDepthTexture, tmpvar_23.xy, 0.0).x) + + _ZBufferParams.y)))); + highp vec2 x_26; + x_26 = (x_8 - tmpvar_23.xy); + highp vec2 x_27; + x_27 = (tmpvar_23.xy - x_8); + highp float tmpvar_28; + tmpvar_28 = sqrt(dot (tmpvar_25, tmpvar_25)); + highp vec2 x_29; + x_29 = (tmpvar_23.xy - x_8); + highp float edge0_30; + edge0_30 = (0.95 * tmpvar_28); + highp float tmpvar_31; + tmpvar_31 = clamp ((( + sqrt(dot (x_29, x_29)) + - edge0_30) / ( + (1.05 * tmpvar_28) + - edge0_30)), 0.0, 1.0); + highp float tmpvar_32; + tmpvar_32 = sqrt(dot (vx_7, vx_7)); + highp vec2 x_33; + x_33 = (x_8 - tmpvar_23.xy); + highp float edge0_34; + edge0_34 = (0.95 * tmpvar_32); + highp float tmpvar_35; + tmpvar_35 = clamp ((( + sqrt(dot (x_33, x_33)) + - edge0_34) / ( + (1.05 * tmpvar_32) + - edge0_34)), 0.0, 1.0); + highp float tmpvar_36; + tmpvar_36 = ((( + clamp ((1.0 - ((zy_21 - zx_6) / _SoftZDistance)), 0.0, 1.0) + * + clamp ((1.0 - (sqrt( + dot (x_26, x_26) + ) / sqrt( + dot (vx_7, vx_7) + ))), 0.0, 1.0) + ) + ( + clamp ((1.0 - ((zx_6 - zy_21) / _SoftZDistance)), 0.0, 1.0) + * + clamp ((1.0 - (sqrt( + dot (x_27, x_27) + ) / sqrt( + dot (tmpvar_25, tmpvar_25) + ))), 0.0, 1.0) + )) + (( + (1.0 - (tmpvar_31 * (tmpvar_31 * (3.0 - + (2.0 * tmpvar_31) + )))) + * + (1.0 - (tmpvar_35 * (tmpvar_35 * (3.0 - + (2.0 * tmpvar_35) + )))) + ) * 2.0)); + lowp vec4 tmpvar_37; + tmpvar_37 = textureLod (_MainTex, tmpvar_23.xy, 0.0); + highp vec4 tmpvar_38; + tmpvar_38 = tmpvar_37; + sum_4 = (sum_4 + (tmpvar_38 * tmpvar_36)); + weight_5 = (weight_5 + tmpvar_36); + }; + highp vec4 tmpvar_39; + tmpvar_39 = (sum_4 / weight_5); + _fragData = tmpvar_39; +} + + +// stats: 99 alu 8 tex 4 flow +// inputs: 1 +// #0: xlv_TEXCOORD0 (high float) 2x1 [-1] +// uniforms: 5 (total size: 0) +// #0: _ZBufferParams (high float) 4x1 [-1] +// #1: _MainTex_TexelSize (high float) 4x1 [-1] +// #2: _Jitter (high float) 1x1 [-1] +// #3: _MaxVelocity (high float) 1x1 [-1] +// #4: _SoftZDistance (high float) 1x1 [-1] +// textures: 5 +// #0: _MainTex (low 2d) 0x0 [-1] +// #1: _CameraDepthTexture (high 2d) 0x0 [-1] +// #2: _VelTex (low 2d) 0x0 [-1] +// #3: _NeighbourMaxTex (low 2d) 0x0 [-1] +// #4: _NoiseTex (low 2d) 0x0 [-1] diff --git a/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-outES3Metal.txt new file mode 100644 index 000000000..504f13c2f --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/bug-sampler-highpfull-outES3Metal.txt @@ -0,0 +1,171 @@ +#include +using namespace metal; +constant float2 _xlat_mtl_const1[12] = {float2(-0.326212, -0.40581), float2(-0.840144, -0.07358), float2(-0.695914, 0.457137), float2(-0.203345, 0.620716), float2(0.96234, -0.194983), float2(0.473434, -0.480026), float2(0.519456, 0.767022), float2(0.185461, -0.893124), float2(0.507431, 0.064425), float2(0.89642, 0.412458), float2(-0.32194, -0.932615), float2(-0.791559, -0.59771)}; +struct xlatMtlShaderInput { + float2 xlv_TEXCOORD0; +}; +struct xlatMtlShaderOutput { + half4 _fragData [[color(0)]]; +}; +struct xlatMtlShaderUniform { + float4 _ZBufferParams; + float4 _MainTex_TexelSize; + float _Jitter; + float _MaxVelocity; + float _SoftZDistance; +}; +fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]] + , texture2d _MainTex [[texture(0)]], sampler _mtlsmp__MainTex [[sampler(0)]] + , texture2d _CameraDepthTexture [[texture(1)]], sampler _mtlsmp__CameraDepthTexture [[sampler(1)]] + , texture2d _VelTex [[texture(2)]], sampler _mtlsmp__VelTex [[sampler(2)]] + , texture2d _NeighbourMaxTex [[texture(3)]], sampler _mtlsmp__NeighbourMaxTex [[sampler(3)]] + , texture2d _NoiseTex [[texture(4)]], sampler _mtlsmp__NoiseTex [[sampler(4)]]) +{ + xlatMtlShaderOutput _mtl_o; + float2 tmpvar_1; + tmpvar_1 = _mtl_i.xlv_TEXCOORD0; + float4 jitteredDir_3; + float4 sum_4; + float weight_5; + float zx_6; + float2 vx_7; + float2 x_8; + float2 xf_9; + xf_9 = _mtl_i.xlv_TEXCOORD0; + x_8 = _mtl_i.xlv_TEXCOORD0; + if ((_mtl_u._MainTex_TexelSize.y < 0.0)) { + xf_9.y = (1.0 - _mtl_i.xlv_TEXCOORD0.y); + }; + half4 tmpvar_10; + tmpvar_10 = _NeighbourMaxTex.sample(_mtlsmp__NeighbourMaxTex, (float2)(xf_9), level(0.0)); + float2 tmpvar_11; + tmpvar_11 = float2(tmpvar_10.xy); + half4 tmpvar_12; + tmpvar_12 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0), level(0.0)); + float4 tmpvar_13; + tmpvar_13 = float4(tmpvar_12); + half4 tmpvar_14; + tmpvar_14 = _VelTex.sample(_mtlsmp__VelTex, (float2)(xf_9), level(0.0)); + float2 tmpvar_15; + tmpvar_15 = float2(tmpvar_14.xy); + vx_7 = tmpvar_15; + float4 tmpvar_16; + tmpvar_16.zw = float2(0.0, 0.0); + tmpvar_16.xy = _mtl_i.xlv_TEXCOORD0; + float4 coord_17; + coord_17 = (tmpvar_16 * 11.0); + half4 tmpvar_18; + tmpvar_18 = _NoiseTex.sample(_mtlsmp__NoiseTex, (float2)(coord_17.xy), level(coord_17.w)); + float4 tmpvar_19; + tmpvar_19 = float4(((tmpvar_18 * (half)2.0) - (half)1.0)); + zx_6 = -((1.0/(( + (_mtl_u._ZBufferParams.x * _CameraDepthTexture.sample(_mtlsmp__CameraDepthTexture, (float2)(_mtl_i.xlv_TEXCOORD0), level(0.0)).x) + + _mtl_u._ZBufferParams.y)))); + weight_5 = 1.0; + sum_4 = tmpvar_13; + float4 tmpvar_20; + tmpvar_20 = (tmpvar_11.xyxy + (tmpvar_19 * (_mtl_u._MainTex_TexelSize.xyxy * _mtl_u._Jitter)).xyyz); + jitteredDir_3 = ((max ( + abs(tmpvar_20.xyxy) + , + ((_mtl_u._MainTex_TexelSize.xyxy * _mtl_u._MaxVelocity) * 0.15) + ) * sign(tmpvar_20.xyxy)) * float4(1.0, 1.0, -1.0, -1.0)); + for (int l_2 = 0; l_2 < 12; l_2++) { + float zy_21; + float4 yf_22; + float4 tmpvar_23; + tmpvar_23 = (tmpvar_1.xyxy + ((jitteredDir_3.xyxy * _xlat_mtl_const1[l_2].xyxy) * float4(1.0, 1.0, -1.0, -1.0))); + yf_22 = tmpvar_23; + if ((_mtl_u._MainTex_TexelSize.y < 0.0)) { + yf_22.yw = (1.0 - tmpvar_23.yw); + }; + half4 tmpvar_24; + tmpvar_24 = _VelTex.sample(_mtlsmp__VelTex, (float2)(yf_22.xy), level(0.0)); + float2 tmpvar_25; + tmpvar_25 = float2(tmpvar_24.xy); + zy_21 = -((1.0/(( + (_mtl_u._ZBufferParams.x * _CameraDepthTexture.sample(_mtlsmp__CameraDepthTexture, (float2)(tmpvar_23.xy), level(0.0)).x) + + _mtl_u._ZBufferParams.y)))); + float2 x_26; + x_26 = (x_8 - tmpvar_23.xy); + float2 x_27; + x_27 = (tmpvar_23.xy - x_8); + float tmpvar_28; + tmpvar_28 = sqrt(dot (tmpvar_25, tmpvar_25)); + float2 x_29; + x_29 = (tmpvar_23.xy - x_8); + float edge0_30; + edge0_30 = (0.95 * tmpvar_28); + float tmpvar_31; + tmpvar_31 = clamp ((( + sqrt(dot (x_29, x_29)) + - edge0_30) / ( + (1.05 * tmpvar_28) + - edge0_30)), 0.0, 1.0); + float tmpvar_32; + tmpvar_32 = sqrt(dot (vx_7, vx_7)); + float2 x_33; + x_33 = (x_8 - tmpvar_23.xy); + float edge0_34; + edge0_34 = (0.95 * tmpvar_32); + float tmpvar_35; + tmpvar_35 = clamp ((( + sqrt(dot (x_33, x_33)) + - edge0_34) / ( + (1.05 * tmpvar_32) + - edge0_34)), 0.0, 1.0); + float tmpvar_36; + tmpvar_36 = ((( + clamp ((1.0 - ((zy_21 - zx_6) / _mtl_u._SoftZDistance)), 0.0, 1.0) + * + clamp ((1.0 - (sqrt( + dot (x_26, x_26) + ) / sqrt( + dot (vx_7, vx_7) + ))), 0.0, 1.0) + ) + ( + clamp ((1.0 - ((zx_6 - zy_21) / _mtl_u._SoftZDistance)), 0.0, 1.0) + * + clamp ((1.0 - (sqrt( + dot (x_27, x_27) + ) / sqrt( + dot (tmpvar_25, tmpvar_25) + ))), 0.0, 1.0) + )) + (( + (1.0 - (tmpvar_31 * (tmpvar_31 * (3.0 - + (2.0 * tmpvar_31) + )))) + * + (1.0 - (tmpvar_35 * (tmpvar_35 * (3.0 - + (2.0 * tmpvar_35) + )))) + ) * 2.0)); + half4 tmpvar_37; + tmpvar_37 = _MainTex.sample(_mtlsmp__MainTex, (float2)(tmpvar_23.xy), level(0.0)); + float4 tmpvar_38; + tmpvar_38 = float4(tmpvar_37); + sum_4 = (sum_4 + (tmpvar_38 * tmpvar_36)); + weight_5 = (weight_5 + tmpvar_36); + }; + float4 tmpvar_39; + tmpvar_39 = (sum_4 / weight_5); + _mtl_o._fragData = half4(tmpvar_39); + return _mtl_o; +} + + +// stats: 99 alu 8 tex 4 flow +// inputs: 1 +// #0: xlv_TEXCOORD0 (high float) 2x1 [-1] +// uniforms: 5 (total size: 44) +// #0: _ZBufferParams (high float) 4x1 [-1] loc 0 +// #1: _MainTex_TexelSize (high float) 4x1 [-1] loc 16 +// #2: _Jitter (high float) 1x1 [-1] loc 32 +// #3: _MaxVelocity (high float) 1x1 [-1] loc 36 +// #4: _SoftZDistance (high float) 1x1 [-1] loc 40 +// textures: 5 +// #0: _MainTex (low 2d) 0x0 [-1] loc 0 +// #1: _CameraDepthTexture (high 2d) 0x0 [-1] loc 1 +// #2: _VelTex (low 2d) 0x0 [-1] loc 2 +// #3: _NeighbourMaxTex (low 2d) 0x0 [-1] loc 3 +// #4: _NoiseTex (low 2d) 0x0 [-1] loc 4 diff --git a/3rdparty/glsl-optimizer/tests/fragment/loop-foraliasinductor-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/loop-foraliasinductor-inES.txt new file mode 100644 index 000000000..5cf1a88c2 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/loop-foraliasinductor-inES.txt @@ -0,0 +1,29 @@ +struct v2f { + highp vec2 uv; + highp vec3 nl; +}; +uniform sampler2D _MainTex; +uniform highp vec4 _TerrainTreeLightColors[4]; +lowp vec4 xlat_main (in v2f i) { + lowp vec4 col = texture2D( _MainTex, i.uv); + mediump vec3 light = vec3(0.0); + if(col.x >= 0.0) { + for (float j = 0.0; (j < i.uv.x); (j++)) { + light += col.xyz; + } + } + if(col.x >= 1.0) { + float j = i.uv.y; + j *= sin(j); + light += col.xyz*j; + } + return vec4(light, 1.0); +} +varying highp vec2 xlv_uv; +varying highp vec3 xlv_nl; +void main() { + v2f i; + i.uv = xlv_uv; + i.nl = xlv_nl; + gl_FragData[0] = xlat_main(i); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/loop-foraliasinductor-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/loop-foraliasinductor-outES.txt new file mode 100644 index 000000000..774b8fe2d --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/loop-foraliasinductor-outES.txt @@ -0,0 +1,36 @@ +uniform sampler2D _MainTex; +varying highp vec2 xlv_uv; +void main () +{ + lowp vec4 tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = xlv_uv; + mediump vec3 light_3; + lowp vec4 col_4; + lowp vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex, xlv_uv); + col_4 = tmpvar_5; + light_3 = vec3(0.0, 0.0, 0.0); + if ((tmpvar_5.x >= 0.0)) { + for (highp float j_6 = 0.0; j_6 < tmpvar_2.x; j_6 += 1.0) { + light_3 = (light_3 + col_4.xyz); + }; + }; + if ((tmpvar_5.x >= 1.0)) { + highp float j_7; + j_7 = (xlv_uv.y * sin(xlv_uv.y)); + light_3 = (light_3 + (tmpvar_5.xyz * j_7)); + }; + mediump vec4 tmpvar_8; + tmpvar_8.w = 1.0; + tmpvar_8.xyz = light_3; + tmpvar_1 = tmpvar_8; + gl_FragData[0] = tmpvar_1; +} + + +// stats: 12 alu 1 tex 4 flow +// inputs: 1 +// #0: xlv_uv (high float) 2x1 [-1] +// textures: 1 +// #0: _MainTex (low 2d) 0x0 [-1] diff --git a/3rdparty/glsl-optimizer/tests/fragment/loop-forwronginductor-inES.txt b/3rdparty/glsl-optimizer/tests/fragment/loop-forwronginductor-inES.txt new file mode 100644 index 000000000..34ab82efd --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/loop-forwronginductor-inES.txt @@ -0,0 +1,24 @@ +struct v2f { + highp vec2 uv; + highp vec3 nl; +}; +uniform sampler2D _MainTex; +uniform highp vec4 _TerrainTreeLightColors[4]; +lowp vec4 xlat_main (in v2f i) { + lowp vec4 col = texture2D( _MainTex, i.uv); + mediump vec3 light = vec3(0.0); + if(col.x >= 0.0) { + for (float j = 0.0; (j < i.uv.x); (j++)) { + light += col.xyz; + } + } + return vec4(light, 1.0); +} +varying highp vec2 xlv_uv; +varying highp vec3 xlv_nl; +void main() { + v2f i; + i.uv = xlv_uv; + i.nl = xlv_nl; + gl_FragData[0] = xlat_main(i); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/loop-forwronginductor-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/loop-forwronginductor-outES.txt new file mode 100644 index 000000000..3383ff082 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/loop-forwronginductor-outES.txt @@ -0,0 +1,31 @@ +uniform sampler2D _MainTex; +varying highp vec2 xlv_uv; +void main () +{ + lowp vec4 tmpvar_1; + highp vec2 tmpvar_2; + tmpvar_2 = xlv_uv; + mediump vec3 light_3; + lowp vec4 col_4; + lowp vec4 tmpvar_5; + tmpvar_5 = texture2D (_MainTex, xlv_uv); + col_4 = tmpvar_5; + light_3 = vec3(0.0, 0.0, 0.0); + if ((tmpvar_5.x >= 0.0)) { + for (highp float j_6 = 0.0; j_6 < tmpvar_2.x; j_6 += 1.0) { + light_3 = (light_3 + col_4.xyz); + }; + }; + mediump vec4 tmpvar_7; + tmpvar_7.w = 1.0; + tmpvar_7.xyz = light_3; + tmpvar_1 = tmpvar_7; + gl_FragData[0] = tmpvar_1; +} + + +// stats: 7 alu 1 tex 3 flow +// inputs: 1 +// #0: xlv_uv (high float) 2x1 [-1] +// textures: 1 +// #0: _MainTex (low 2d) 0x0 [-1] diff --git a/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-inES3.txt b/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-inES3.txt new file mode 100644 index 000000000..196b2f75e --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-inES3.txt @@ -0,0 +1,94 @@ +#version 300 es + +// Shader below was causing invalid matrix assignment (different types, i.e. half3x3 vs float3x3) +// in the resulting Metal code. Caused by some combination of matrix transposes and other operations +// on them. + +mat3 xll_transpose_mf3x3(mat3 m) { + return mat3( m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} +vec3 xll_matrixindex_mf3x3_i (mat3 m, int i) { vec3 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; return v; } +struct SurfaceOutput { + lowp vec3 Albedo; + lowp vec3 Normal; + lowp vec3 Emission; + mediump float Specular; + lowp float Gloss; + lowp float Alpha; +}; +struct Input { + highp vec2 uv_PanelTex; + highp vec2 uv2_DecalTex; +}; +struct v2f_surf { + highp vec4 pos; + highp vec4 pack0; + highp vec4 tSpace0; + highp vec4 tSpace1; + highp vec4 tSpace2; +}; +uniform highp vec4 _WorldSpaceLightPos0; +uniform sampler2D _PanelNorm; +uniform sampler2D _DecalNorm; +highp vec3 UnityWorldSpaceLightDir( in highp vec3 worldPos ) { + return (_WorldSpaceLightPos0.xyz - (worldPos * _WorldSpaceLightPos0.w)); +} +void surf( in Input IN, inout SurfaceOutput o ) { + + lowp vec3 baseNormal = ((texture( _DecalNorm, IN.uv2_DecalTex).xyz * 2.0) - 1.0); + lowp vec3 detailNormal = ((texture( _PanelNorm, IN.uv_PanelTex).xyz * 2.0) - 1.0); + highp mat3 nBasis = xll_transpose_mf3x3(mat3( vec3( baseNormal.z, baseNormal.y, (-baseNormal.x)), vec3( baseNormal.x, baseNormal.z, (-baseNormal.y)), vec3( baseNormal.x, baseNormal.y, baseNormal.z))); + + lowp vec3 combinedNormal = normalize((((detailNormal.x * xll_matrixindex_mf3x3_i (nBasis, 0)) + (detailNormal.y * xll_matrixindex_mf3x3_i (nBasis, 1))) + (detailNormal.z * xll_matrixindex_mf3x3_i (nBasis, 2)))); + combinedNormal *= 1.0; + o.Normal = combinedNormal; +} +lowp vec4 frag_surf( in v2f_surf IN ) { + Input surfIN; + + surfIN.uv_PanelTex = IN.pack0.xy; + surfIN.uv2_DecalTex = IN.pack0.zw; + highp vec3 worldPos = vec3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w); + + lowp vec3 lightDir = normalize(UnityWorldSpaceLightDir( worldPos)); + + SurfaceOutput o; + o.Albedo = vec3( 0.0); + o.Emission = vec3( 0.0); + + o.Specular = 0.0; + o.Alpha = 0.0; + o.Gloss = 0.0; + lowp vec3 normalWorldVertex = vec3( 0.0, 0.0, 1.0); + + surf( surfIN, o); + lowp vec3 worldN; + worldN.x = dot( IN.tSpace0.xyz, o.Normal); + worldN.y = dot( IN.tSpace1.xyz, o.Normal); + + worldN.z = dot( IN.tSpace2.xyz, o.Normal); + o.Normal = worldN; + + lowp vec4 res; + res.xyz = ((o.Normal * 0.5) + 0.5); + res.w = o.Specular; + return res; +} +in highp vec4 xlv_TEXCOORD0; +in highp vec4 xlv_TEXCOORD1; +in highp vec4 xlv_TEXCOORD2; +in highp vec4 xlv_TEXCOORD3; +out lowp vec4 _fragData; +void main() { + lowp vec4 xl_retval; + v2f_surf xlt_IN; + xlt_IN.pos = vec4(0.0); + xlt_IN.pack0 = vec4(xlv_TEXCOORD0); + xlt_IN.tSpace0 = vec4(xlv_TEXCOORD1); + xlt_IN.tSpace1 = vec4(xlv_TEXCOORD2); + xlt_IN.tSpace2 = vec4(xlv_TEXCOORD3); + xl_retval = frag_surf( xlt_IN); + _fragData = vec4(xl_retval); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-outES3.txt b/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-outES3.txt new file mode 100644 index 000000000..c5fcdb4bb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-outES3.txt @@ -0,0 +1,78 @@ +#version 300 es +uniform sampler2D _PanelNorm; +uniform sampler2D _DecalNorm; +in highp vec4 xlv_TEXCOORD0; +in highp vec4 xlv_TEXCOORD1; +in highp vec4 xlv_TEXCOORD2; +in highp vec4 xlv_TEXCOORD3; +out lowp vec4 _fragData; +void main () +{ + lowp vec4 res_1; + lowp vec3 worldN_2; + lowp vec3 combinedNormal_3; + lowp vec3 tmpvar_4; + tmpvar_4 = ((texture (_DecalNorm, xlv_TEXCOORD0.zw).xyz * 2.0) - 1.0); + lowp vec3 tmpvar_5; + tmpvar_5 = ((texture (_PanelNorm, xlv_TEXCOORD0.xy).xyz * 2.0) - 1.0); + lowp vec3 tmpvar_6; + tmpvar_6.x = tmpvar_4.z; + tmpvar_6.y = tmpvar_4.y; + tmpvar_6.z = -(tmpvar_4.x); + lowp vec3 tmpvar_7; + tmpvar_7.x = tmpvar_4.x; + tmpvar_7.y = tmpvar_4.z; + tmpvar_7.z = -(tmpvar_4.y); + highp mat3 tmpvar_8; + lowp mat3 tmpvar_9; + tmpvar_9[uint(0)].x = tmpvar_6.x; + tmpvar_9[uint(0)].y = tmpvar_7.x; + tmpvar_9[uint(0)].z = tmpvar_4.x; + tmpvar_9[1u].x = tmpvar_6.y; + tmpvar_9[1u].y = tmpvar_7.y; + tmpvar_9[1u].z = tmpvar_4.y; + tmpvar_9[2u].x = tmpvar_6.z; + tmpvar_9[2u].y = tmpvar_7.z; + tmpvar_9[2u].z = tmpvar_4.z; + tmpvar_8 = tmpvar_9; + highp vec3 v_10; + v_10.x = tmpvar_8[0].x; + v_10.y = tmpvar_8[1].x; + v_10.z = tmpvar_8[2].x; + highp vec3 v_11; + v_11.x = tmpvar_8[0].y; + v_11.y = tmpvar_8[1].y; + v_11.z = tmpvar_8[2].y; + highp vec3 v_12; + v_12.x = tmpvar_8[0].z; + v_12.y = tmpvar_8[1].z; + v_12.z = tmpvar_8[2].z; + combinedNormal_3 = normalize((( + (tmpvar_5.x * v_10) + + + (tmpvar_5.y * v_11) + ) + (tmpvar_5.z * v_12))); + highp float tmpvar_13; + tmpvar_13 = dot (xlv_TEXCOORD1.xyz, combinedNormal_3); + worldN_2.x = tmpvar_13; + highp float tmpvar_14; + tmpvar_14 = dot (xlv_TEXCOORD2.xyz, combinedNormal_3); + worldN_2.y = tmpvar_14; + highp float tmpvar_15; + tmpvar_15 = dot (xlv_TEXCOORD3.xyz, combinedNormal_3); + worldN_2.z = tmpvar_15; + res_1.xyz = ((worldN_2 * 0.5) + 0.5); + res_1.w = 0.0; + _fragData = res_1; +} + + +// stats: 18 alu 2 tex 0 flow +// inputs: 4 +// #0: xlv_TEXCOORD0 (high float) 4x1 [-1] +// #1: xlv_TEXCOORD1 (high float) 4x1 [-1] +// #2: xlv_TEXCOORD2 (high float) 4x1 [-1] +// #3: xlv_TEXCOORD3 (high float) 4x1 [-1] +// textures: 2 +// #0: _PanelNorm (low 2d) 0x0 [-1] +// #1: _DecalNorm (low 2d) 0x0 [-1] diff --git a/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-outES3Metal.txt new file mode 100644 index 000000000..bb6013bd8 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/matrix-cast-types-outES3Metal.txt @@ -0,0 +1,93 @@ +#include +using namespace metal; +inline float4x4 _xlcast_float4x4(half4x4 v) { return float4x4(float4(v[0]), float4(v[1]), float4(v[2]), float4(v[3])); } +inline float3x3 _xlcast_float3x3(half3x3 v) { return float3x3(float3(v[0]), float3(v[1]), float3(v[2])); } +inline float2x2 _xlcast_float2x2(half2x2 v) { return float2x2(float2(v[0]), float2(v[1])); } +inline half4x4 _xlcast_half4x4(float4x4 v) { return half4x4(half4(v[0]), half4(v[1]), half4(v[2]), half4(v[3])); } +inline half3x3 _xlcast_half3x3(float3x3 v) { return half3x3(half3(v[0]), half3(v[1]), half3(v[2])); } +inline half2x2 _xlcast_half2x2(float2x2 v) { return half2x2(half2(v[0]), half2(v[1])); } +struct xlatMtlShaderInput { + float4 xlv_TEXCOORD0; + float4 xlv_TEXCOORD1; + float4 xlv_TEXCOORD2; + float4 xlv_TEXCOORD3; +}; +struct xlatMtlShaderOutput { + half4 _fragData [[color(0)]]; +}; +struct xlatMtlShaderUniform { +}; +fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]] + , texture2d _PanelNorm [[texture(0)]], sampler _mtlsmp__PanelNorm [[sampler(0)]] + , texture2d _DecalNorm [[texture(1)]], sampler _mtlsmp__DecalNorm [[sampler(1)]]) +{ + xlatMtlShaderOutput _mtl_o; + half4 res_1; + half3 worldN_2; + half3 combinedNormal_3; + half3 tmpvar_4; + tmpvar_4 = ((_DecalNorm.sample(_mtlsmp__DecalNorm, (float2)(_mtl_i.xlv_TEXCOORD0.zw)).xyz * (half)2.0) - (half)1.0); + half3 tmpvar_5; + tmpvar_5 = ((_PanelNorm.sample(_mtlsmp__PanelNorm, (float2)(_mtl_i.xlv_TEXCOORD0.xy)).xyz * (half)2.0) - (half)1.0); + half3 tmpvar_6; + tmpvar_6.x = tmpvar_4.z; + tmpvar_6.y = tmpvar_4.y; + tmpvar_6.z = -(tmpvar_4.x); + half3 tmpvar_7; + tmpvar_7.x = tmpvar_4.x; + tmpvar_7.y = tmpvar_4.z; + tmpvar_7.z = -(tmpvar_4.y); + float3x3 tmpvar_8; + half3x3 tmpvar_9; + tmpvar_9[0].x = tmpvar_6.x; + tmpvar_9[0].y = tmpvar_7.x; + tmpvar_9[0].z = tmpvar_4.x; + tmpvar_9[1].x = tmpvar_6.y; + tmpvar_9[1].y = tmpvar_7.y; + tmpvar_9[1].z = tmpvar_4.y; + tmpvar_9[2].x = tmpvar_6.z; + tmpvar_9[2].y = tmpvar_7.z; + tmpvar_9[2].z = tmpvar_4.z; + tmpvar_8 = _xlcast_float3x3(tmpvar_9); + float3 v_10; + v_10.x = tmpvar_8[0].x; + v_10.y = tmpvar_8[1].x; + v_10.z = tmpvar_8[2].x; + float3 v_11; + v_11.x = tmpvar_8[0].y; + v_11.y = tmpvar_8[1].y; + v_11.z = tmpvar_8[2].y; + float3 v_12; + v_12.x = tmpvar_8[0].z; + v_12.y = tmpvar_8[1].z; + v_12.z = tmpvar_8[2].z; + combinedNormal_3 = normalize((( + ((half3)((float)tmpvar_5.x * v_10)) + + + ((half3)((float)tmpvar_5.y * v_11)) + ) + ((half3)((float)tmpvar_5.z * v_12)))); + float tmpvar_13; + tmpvar_13 = dot (_mtl_i.xlv_TEXCOORD1.xyz, (float3)combinedNormal_3); + worldN_2.x = half(tmpvar_13); + float tmpvar_14; + tmpvar_14 = dot (_mtl_i.xlv_TEXCOORD2.xyz, (float3)combinedNormal_3); + worldN_2.y = half(tmpvar_14); + float tmpvar_15; + tmpvar_15 = dot (_mtl_i.xlv_TEXCOORD3.xyz, (float3)combinedNormal_3); + worldN_2.z = half(tmpvar_15); + res_1.xyz = ((worldN_2 * (half)0.5) + (half)0.5); + res_1.w = half(0.0); + _mtl_o._fragData = res_1; + return _mtl_o; +} + + +// stats: 18 alu 2 tex 0 flow +// inputs: 4 +// #0: xlv_TEXCOORD0 (high float) 4x1 [-1] +// #1: xlv_TEXCOORD1 (high float) 4x1 [-1] +// #2: xlv_TEXCOORD2 (high float) 4x1 [-1] +// #3: xlv_TEXCOORD3 (high float) 4x1 [-1] +// textures: 2 +// #0: _PanelNorm (low 2d) 0x0 [-1] loc 0 +// #1: _DecalNorm (low 2d) 0x0 [-1] loc 1 diff --git a/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-inES3.txt b/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-inES3.txt new file mode 100644 index 000000000..03239e909 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-inES3.txt @@ -0,0 +1,30 @@ +#version 300 es +out mediump vec4 _fragData; +uniform highp float _Speed; +uniform highp vec4 _Time; +highp vec4 func( in highp vec2 uv ) +{ + highp float s = sin(_Speed * _Time.x); + highp float c = cos(_Speed * _Time.x); + + highp mat2 rotationMatrix = mat2(c, s, -s, c); + // various operations on a matrix + rotationMatrix = rotationMatrix * 2.0; + rotationMatrix = rotationMatrix - 1.0; + rotationMatrix = s - rotationMatrix; + rotationMatrix = c + rotationMatrix; + rotationMatrix /= s; + + mediump mat2 halfMatrix = mat2(c, s, -s, c); + halfMatrix = halfMatrix * 2.0; + halfMatrix = halfMatrix - 1.0; + halfMatrix = s - halfMatrix; + halfMatrix = c + halfMatrix; + halfMatrix /= s; + + return vec4((rotationMatrix * uv), (halfMatrix * uv)); +} +in highp vec2 uv; +void main() { + _fragData = func(uv); +} diff --git a/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-outES3.txt b/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-outES3.txt new file mode 100644 index 000000000..4f2d14e9a --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-outES3.txt @@ -0,0 +1,49 @@ +#version 300 es +out mediump vec4 _fragData; +uniform highp float _Speed; +uniform highp vec4 _Time; +in highp vec2 uv; +void main () +{ + mediump mat2 halfMatrix_1; + highp mat2 rotationMatrix_2; + highp float tmpvar_3; + highp float tmpvar_4; + tmpvar_4 = (_Speed * _Time.x); + tmpvar_3 = sin(tmpvar_4); + highp float tmpvar_5; + tmpvar_5 = cos(tmpvar_4); + highp mat2 tmpvar_6; + tmpvar_6[uint(0)].x = tmpvar_5; + tmpvar_6[uint(0)].y = tmpvar_3; + tmpvar_6[1u].x = -(tmpvar_3); + tmpvar_6[1u].y = tmpvar_5; + rotationMatrix_2 = (tmpvar_6 * 2.0); + rotationMatrix_2 = (rotationMatrix_2 - 1.0); + rotationMatrix_2 = (tmpvar_3 - rotationMatrix_2); + rotationMatrix_2 = (tmpvar_5 + rotationMatrix_2); + rotationMatrix_2 = (rotationMatrix_2 / tmpvar_3); + highp mat2 tmpvar_7; + tmpvar_7[uint(0)].x = tmpvar_5; + tmpvar_7[uint(0)].y = tmpvar_3; + tmpvar_7[1u].x = -(tmpvar_3); + tmpvar_7[1u].y = tmpvar_5; + halfMatrix_1 = tmpvar_7; + halfMatrix_1 = (halfMatrix_1 * 2.0); + halfMatrix_1 = (halfMatrix_1 - 1.0); + halfMatrix_1 = (tmpvar_3 - halfMatrix_1); + halfMatrix_1 = (tmpvar_5 + halfMatrix_1); + halfMatrix_1 = (halfMatrix_1 / tmpvar_3); + highp vec4 tmpvar_8; + tmpvar_8.xy = (rotationMatrix_2 * uv); + tmpvar_8.zw = (halfMatrix_1 * uv); + _fragData = tmpvar_8; +} + + +// stats: 17 alu 0 tex 0 flow +// inputs: 1 +// #0: uv (high float) 2x1 [-1] +// uniforms: 2 (total size: 0) +// #0: _Speed (high float) 1x1 [-1] +// #1: _Time (high float) 4x1 [-1] diff --git a/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-outES3Metal.txt new file mode 100644 index 000000000..458ecd3d4 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/fragment/matrix-ops-outES3Metal.txt @@ -0,0 +1,70 @@ +#include +using namespace metal; +inline float4x4 _xlinit_float4x4(float v) { return float4x4(float4(v), float4(v), float4(v), float4(v)); } +inline float3x3 _xlinit_float3x3(float v) { return float3x3(float3(v), float3(v), float3(v)); } +inline float2x2 _xlinit_float2x2(float v) { return float2x2(float2(v), float2(v)); } +inline half4x4 _xlinit_half4x4(half v) { return half4x4(half4(v), half4(v), half4(v), half4(v)); } +inline half3x3 _xlinit_half3x3(half v) { return half3x3(half3(v), half3(v), half3(v)); } +inline half2x2 _xlinit_half2x2(half v) { return half2x2(half2(v), half2(v)); } +inline float4x4 _xlcast_float4x4(half4x4 v) { return float4x4(float4(v[0]), float4(v[1]), float4(v[2]), float4(v[3])); } +inline float3x3 _xlcast_float3x3(half3x3 v) { return float3x3(float3(v[0]), float3(v[1]), float3(v[2])); } +inline float2x2 _xlcast_float2x2(half2x2 v) { return float2x2(float2(v[0]), float2(v[1])); } +inline half4x4 _xlcast_half4x4(float4x4 v) { return half4x4(half4(v[0]), half4(v[1]), half4(v[2]), half4(v[3])); } +inline half3x3 _xlcast_half3x3(float3x3 v) { return half3x3(half3(v[0]), half3(v[1]), half3(v[2])); } +inline half2x2 _xlcast_half2x2(float2x2 v) { return half2x2(half2(v[0]), half2(v[1])); } +struct xlatMtlShaderInput { + float2 uv; +}; +struct xlatMtlShaderOutput { + half4 _fragData [[color(0)]]; +}; +struct xlatMtlShaderUniform { + float _Speed; + float4 _Time; +}; +fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]) +{ + xlatMtlShaderOutput _mtl_o; + half2x2 halfMatrix_1; + float2x2 rotationMatrix_2; + float tmpvar_3; + float tmpvar_4; + tmpvar_4 = (_mtl_u._Speed * _mtl_u._Time.x); + tmpvar_3 = sin(tmpvar_4); + float tmpvar_5; + tmpvar_5 = cos(tmpvar_4); + float2x2 tmpvar_6; + tmpvar_6[0].x = tmpvar_5; + tmpvar_6[0].y = tmpvar_3; + tmpvar_6[1].x = -(tmpvar_3); + tmpvar_6[1].y = tmpvar_5; + rotationMatrix_2 = (tmpvar_6 * 2.0); + rotationMatrix_2 = (rotationMatrix_2 - _xlinit_float2x2(1.0)); + rotationMatrix_2 = (_xlinit_float2x2(tmpvar_3) - rotationMatrix_2); + rotationMatrix_2 = (_xlinit_float2x2(tmpvar_5) + rotationMatrix_2); + rotationMatrix_2 = (rotationMatrix_2 * (1.0/(tmpvar_3))); + float2x2 tmpvar_7; + tmpvar_7[0].x = tmpvar_5; + tmpvar_7[0].y = tmpvar_3; + tmpvar_7[1].x = -(tmpvar_3); + tmpvar_7[1].y = tmpvar_5; + halfMatrix_1 = _xlcast_half2x2(tmpvar_7); + halfMatrix_1 = (halfMatrix_1 * (half)2.0); + halfMatrix_1 = (halfMatrix_1 - _xlinit_half2x2(1.0)); + halfMatrix_1 = _xlcast_half2x2(((float2x2)(_xlinit_half2x2(tmpvar_3) - halfMatrix_1))); + halfMatrix_1 = _xlcast_half2x2(((float2x2)(_xlinit_half2x2(tmpvar_5) + halfMatrix_1))); + halfMatrix_1 = _xlcast_half2x2(((float2x2)(halfMatrix_1 * (1.0h/half(tmpvar_3))))); + float4 tmpvar_8; + tmpvar_8.xy = (rotationMatrix_2 * _mtl_i.uv); + tmpvar_8.zw = ((float2)(halfMatrix_1 * (half2)_mtl_i.uv)); + _mtl_o._fragData = half4(tmpvar_8); + return _mtl_o; +} + + +// stats: 17 alu 0 tex 0 flow +// inputs: 1 +// #0: uv (high float) 2x1 [-1] +// uniforms: 2 (total size: 32) +// #0: _Speed (high float) 1x1 [-1] loc 0 +// #1: _Time (high float) 4x1 [-1] loc 16 diff --git a/3rdparty/glsl-optimizer/tests/fragment/mrt-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/mrt-outES.txt index d137db095..5dc219732 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/mrt-outES.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/mrt-outES.txt @@ -1,4 +1,4 @@ -#extension GL_EXT_draw_buffers : require +#extension GL_EXT_draw_buffers : enable void main () { gl_FragData[0] = vec4(0.0, 0.0, 0.0, 0.0); diff --git a/3rdparty/glsl-optimizer/tests/fragment/opt-movevars-sideeffect2-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/opt-movevars-sideeffect2-outES.txt index bb9473b03..3c7c7d1a8 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/opt-movevars-sideeffect2-outES.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/opt-movevars-sideeffect2-outES.txt @@ -12,7 +12,8 @@ void main () discard; }; c_1 = 0.0; - for (highp int i_2 = tmpvar_3; i_2 < 4; i_2++, c_1 = (c_1 + xx)) { + for (highp int i_2 = tmpvar_3; i_2 < 4; i_2++) { + c_1 = (c_1 + xx); }; lowp vec4 tmpvar_4; tmpvar_4 = vec4(c_1); diff --git a/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-outES.txt index c8a562aa2..bdda6f01f 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-outES.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/prec-inlineexpr1-outES.txt @@ -5,13 +5,13 @@ uniform mediump float _EmberFadeStart; varying mediump vec2 xlv_TEXCOORD0; void main () { - mediump float x_1; - x_1 = ((_EmberFadeStart - 0.05) / (_EmberFadeStart - _EmberFadeEnd)); - lowp float tmpvar_2; - tmpvar_2 = clamp (x_1, 0.0, 1.0); + lowp float tmpvar_1; + mediump float tmpvar_2; + tmpvar_2 = clamp (((_EmberFadeStart - 0.05) / (_EmberFadeStart - _EmberFadeEnd)), 0.0, 1.0); + tmpvar_1 = tmpvar_2; lowp vec4 tmpvar_3; tmpvar_3.w = 1.0; - tmpvar_3.xyz = mix (texture2D (_MainTex, xlv_TEXCOORD0).xyz, texture2D (_BurntTex, xlv_TEXCOORD0).xyz, vec3(tmpvar_2)); + tmpvar_3.xyz = mix (texture2D (_MainTex, xlv_TEXCOORD0).xyz, texture2D (_BurntTex, xlv_TEXCOORD0).xyz, vec3(tmpvar_1)); gl_FragColor = tmpvar_3; } diff --git a/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES.txt index 2ba7fa788..7301c179f 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES.txt @@ -11,21 +11,17 @@ void main () lowp vec4 tmpvar_2; tmpvar_2 = texture2D (texlow, varUV.xy); c_1 = tmpvar_2; - mediump vec4 tmpvar_3; - tmpvar_3 = texture2D (texmed, varUV.xy); + c_1 = (c_1 + texture2D (texmed, varUV.xy)); + highp vec4 tmpvar_3; + tmpvar_3 = texture2D (texhigh, varUV.xy); c_1 = (c_1 + tmpvar_3); - highp vec4 tmpvar_4; - tmpvar_4 = texture2D (texhigh, varUV.xy); + lowp vec4 tmpvar_4; + tmpvar_4 = textureCube (cubelow, varUV.xyz); c_1 = (c_1 + tmpvar_4); - lowp vec4 tmpvar_5; - tmpvar_5 = textureCube (cubelow, varUV.xyz); + c_1 = (c_1 + textureCube (cubemed, varUV.xyz)); + highp vec4 tmpvar_5; + tmpvar_5 = textureCube (cubehigh, varUV.xyz); c_1 = (c_1 + tmpvar_5); - mediump vec4 tmpvar_6; - tmpvar_6 = textureCube (cubemed, varUV.xyz); - c_1 = (c_1 + tmpvar_6); - highp vec4 tmpvar_7; - tmpvar_7 = textureCube (cubehigh, varUV.xyz); - c_1 = (c_1 + tmpvar_7); gl_FragData[0] = c_1; } diff --git a/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES3.txt b/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES3.txt index b0fdc1856..af995d19c 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES3.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES3.txt @@ -13,21 +13,17 @@ void main () lowp vec4 tmpvar_2; tmpvar_2 = texture (texlow, varUV.xy); c_1 = tmpvar_2; - mediump vec4 tmpvar_3; - tmpvar_3 = texture (texmed, varUV.xy); + c_1 = (c_1 + texture (texmed, varUV.xy)); + highp vec4 tmpvar_3; + tmpvar_3 = texture (texhigh, varUV.xy); c_1 = (c_1 + tmpvar_3); - highp vec4 tmpvar_4; - tmpvar_4 = texture (texhigh, varUV.xy); + lowp vec4 tmpvar_4; + tmpvar_4 = texture (cubelow, varUV.xyz); c_1 = (c_1 + tmpvar_4); - lowp vec4 tmpvar_5; - tmpvar_5 = texture (cubelow, varUV.xyz); + c_1 = (c_1 + texture (cubemed, varUV.xyz)); + highp vec4 tmpvar_5; + tmpvar_5 = texture (cubehigh, varUV.xyz); c_1 = (c_1 + tmpvar_5); - mediump vec4 tmpvar_6; - tmpvar_6 = texture (cubemed, varUV.xyz); - c_1 = (c_1 + tmpvar_6); - highp vec4 tmpvar_7; - tmpvar_7 = texture (cubehigh, varUV.xyz); - c_1 = (c_1 + tmpvar_7); _fragData = c_1; } diff --git a/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES3Metal.txt index f59c19a1c..7d8a5f943 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES3Metal.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/sampler-precision-outES3Metal.txt @@ -21,21 +21,17 @@ fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]] half4 tmpvar_2; tmpvar_2 = texlow.sample(_mtlsmp_texlow, (float2)(_mtl_i.varUV.xy)); c_1 = tmpvar_2; - half4 tmpvar_3; - tmpvar_3 = texmed.sample(_mtlsmp_texmed, (float2)(_mtl_i.varUV.xy)); - c_1 = (c_1 + tmpvar_3); - float4 tmpvar_4; - tmpvar_4 = float4(texhigh.sample(_mtlsmp_texhigh, (float2)(_mtl_i.varUV.xy))); - c_1 = half4(((float4)c_1 + tmpvar_4)); - half4 tmpvar_5; - tmpvar_5 = cubelow.sample(_mtlsmp_cubelow, (float3)(_mtl_i.varUV.xyz)); - c_1 = (c_1 + tmpvar_5); - half4 tmpvar_6; - tmpvar_6 = cubemed.sample(_mtlsmp_cubemed, (float3)(_mtl_i.varUV.xyz)); - c_1 = (c_1 + tmpvar_6); - float4 tmpvar_7; - tmpvar_7 = float4(cubehigh.sample(_mtlsmp_cubehigh, (float3)(_mtl_i.varUV.xyz))); - c_1 = half4(((float4)c_1 + tmpvar_7)); + c_1 = (c_1 + texmed.sample(_mtlsmp_texmed, (float2)(_mtl_i.varUV.xy))); + float4 tmpvar_3; + tmpvar_3 = texhigh.sample(_mtlsmp_texhigh, (float2)(_mtl_i.varUV.xy)); + c_1 = half4(((float4)c_1 + tmpvar_3)); + half4 tmpvar_4; + tmpvar_4 = cubelow.sample(_mtlsmp_cubelow, (float3)(_mtl_i.varUV.xyz)); + c_1 = (c_1 + tmpvar_4); + c_1 = (c_1 + cubemed.sample(_mtlsmp_cubemed, (float3)(_mtl_i.varUV.xyz))); + float4 tmpvar_5; + tmpvar_5 = cubehigh.sample(_mtlsmp_cubehigh, (float3)(_mtl_i.varUV.xyz)); + c_1 = half4(((float4)c_1 + tmpvar_5)); _mtl_o._fragData = c_1; return _mtl_o; } diff --git a/3rdparty/glsl-optimizer/tests/fragment/z-fxaa3-11-pc39-outES.txt b/3rdparty/glsl-optimizer/tests/fragment/z-fxaa3-11-pc39-outES.txt index 898fcd4d7..376ff3ebd 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/z-fxaa3-11-pc39-outES.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/z-fxaa3-11-pc39-outES.txt @@ -53,116 +53,116 @@ void main () highp float range_37; highp float lumaN_38; highp float lumaS_39; - highp vec4 rgbyM_40; - highp vec2 posM_41; - posM_41 = xlv_TEXCOORD0; + highp vec2 posM_40; + posM_40 = xlv_TEXCOORD0; + highp vec4 tmpvar_41; lowp vec4 tmpvar_42; tmpvar_42 = impl_low_texture2DLodEXT (_MainTex, xlv_TEXCOORD0, 0.0); - rgbyM_40 = tmpvar_42; + tmpvar_41 = tmpvar_42; highp vec4 tmpvar_43; tmpvar_43.zw = vec2(0.0, 0.0); tmpvar_43.xy = (xlv_TEXCOORD0 + (vec2(0.0, 1.0) * _MainTex_TexelSize.xy)); - lowp vec4 tmpvar_44; - tmpvar_44 = impl_low_texture2DLodEXT (_MainTex, tmpvar_43.xy, 0.0); - highp vec4 rgba_45; - rgba_45 = tmpvar_44; - lumaS_39 = rgba_45.w; + highp vec4 tmpvar_44; + lowp vec4 tmpvar_45; + tmpvar_45 = impl_low_texture2DLodEXT (_MainTex, tmpvar_43.xy, 0.0); + tmpvar_44 = tmpvar_45; + lumaS_39 = tmpvar_44.w; highp vec4 tmpvar_46; tmpvar_46.zw = vec2(0.0, 0.0); tmpvar_46.xy = (xlv_TEXCOORD0 + (vec2(1.0, 0.0) * _MainTex_TexelSize.xy)); - lowp vec4 tmpvar_47; - tmpvar_47 = impl_low_texture2DLodEXT (_MainTex, tmpvar_46.xy, 0.0); - highp float tmpvar_48; - highp vec4 rgba_49; - rgba_49 = tmpvar_47; - tmpvar_48 = rgba_49.w; + highp vec4 tmpvar_47; + lowp vec4 tmpvar_48; + tmpvar_48 = impl_low_texture2DLodEXT (_MainTex, tmpvar_46.xy, 0.0); + tmpvar_47 = tmpvar_48; + highp float tmpvar_49; + tmpvar_49 = tmpvar_47.w; highp vec4 tmpvar_50; tmpvar_50.zw = vec2(0.0, 0.0); tmpvar_50.xy = (xlv_TEXCOORD0 + (vec2(0.0, -1.0) * _MainTex_TexelSize.xy)); - lowp vec4 tmpvar_51; - tmpvar_51 = impl_low_texture2DLodEXT (_MainTex, tmpvar_50.xy, 0.0); - highp vec4 rgba_52; - rgba_52 = tmpvar_51; - lumaN_38 = rgba_52.w; + highp vec4 tmpvar_51; + lowp vec4 tmpvar_52; + tmpvar_52 = impl_low_texture2DLodEXT (_MainTex, tmpvar_50.xy, 0.0); + tmpvar_51 = tmpvar_52; + lumaN_38 = tmpvar_51.w; highp vec4 tmpvar_53; tmpvar_53.zw = vec2(0.0, 0.0); tmpvar_53.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 0.0) * _MainTex_TexelSize.xy)); - lowp vec4 tmpvar_54; - tmpvar_54 = impl_low_texture2DLodEXT (_MainTex, tmpvar_53.xy, 0.0); - highp float tmpvar_55; - highp vec4 rgba_56; - rgba_56 = tmpvar_54; - tmpvar_55 = rgba_56.w; + highp vec4 tmpvar_54; + lowp vec4 tmpvar_55; + tmpvar_55 = impl_low_texture2DLodEXT (_MainTex, tmpvar_53.xy, 0.0); + tmpvar_54 = tmpvar_55; + highp float tmpvar_56; + tmpvar_56 = tmpvar_54.w; highp float tmpvar_57; - tmpvar_57 = max (max (rgba_52.w, rgba_56.w), max (max (rgba_49.w, rgba_45.w), rgbyM_40.w)); - range_37 = (tmpvar_57 - min (min (rgba_52.w, rgba_56.w), min ( - min (rgba_49.w, rgba_45.w) - , rgbyM_40.w))); + tmpvar_57 = max (max (tmpvar_51.w, tmpvar_54.w), max (max (tmpvar_47.w, tmpvar_44.w), tmpvar_41.w)); + range_37 = (tmpvar_57 - min (min (tmpvar_51.w, tmpvar_54.w), min ( + min (tmpvar_47.w, tmpvar_44.w) + , tmpvar_41.w))); if ((range_37 < max (0.0833, (tmpvar_57 * 0.166)))) { - tmpvar_2 = rgbyM_40; + tmpvar_2 = tmpvar_41; } else { highp vec4 tmpvar_58; tmpvar_58.zw = vec2(0.0, 0.0); tmpvar_58.xy = (xlv_TEXCOORD0 - _MainTex_TexelSize.xy); - lowp vec4 tmpvar_59; - tmpvar_59 = impl_low_texture2DLodEXT (_MainTex, tmpvar_58.xy, 0.0); - highp vec4 rgba_60; - rgba_60 = tmpvar_59; + highp vec4 tmpvar_59; + lowp vec4 tmpvar_60; + tmpvar_60 = impl_low_texture2DLodEXT (_MainTex, tmpvar_58.xy, 0.0); + tmpvar_59 = tmpvar_60; highp vec4 tmpvar_61; tmpvar_61.zw = vec2(0.0, 0.0); tmpvar_61.xy = (xlv_TEXCOORD0 + _MainTex_TexelSize.xy); - lowp vec4 tmpvar_62; - tmpvar_62 = impl_low_texture2DLodEXT (_MainTex, tmpvar_61.xy, 0.0); - highp vec4 rgba_63; - rgba_63 = tmpvar_62; + highp vec4 tmpvar_62; + lowp vec4 tmpvar_63; + tmpvar_63 = impl_low_texture2DLodEXT (_MainTex, tmpvar_61.xy, 0.0); + tmpvar_62 = tmpvar_63; highp vec4 tmpvar_64; tmpvar_64.zw = vec2(0.0, 0.0); tmpvar_64.xy = (xlv_TEXCOORD0 + (vec2(1.0, -1.0) * _MainTex_TexelSize.xy)); - lowp vec4 tmpvar_65; - tmpvar_65 = impl_low_texture2DLodEXT (_MainTex, tmpvar_64.xy, 0.0); - highp vec4 rgba_66; - rgba_66 = tmpvar_65; + highp vec4 tmpvar_65; + lowp vec4 tmpvar_66; + tmpvar_66 = impl_low_texture2DLodEXT (_MainTex, tmpvar_64.xy, 0.0); + tmpvar_65 = tmpvar_66; highp vec4 tmpvar_67; tmpvar_67.zw = vec2(0.0, 0.0); tmpvar_67.xy = (xlv_TEXCOORD0 + (vec2(-1.0, 1.0) * _MainTex_TexelSize.xy)); - lowp vec4 tmpvar_68; - tmpvar_68 = impl_low_texture2DLodEXT (_MainTex, tmpvar_67.xy, 0.0); - highp vec4 rgba_69; - rgba_69 = tmpvar_68; - lumaNS_36 = (rgba_52.w + rgba_45.w); - lumaWE_35 = (rgba_56.w + rgba_49.w); + highp vec4 tmpvar_68; + lowp vec4 tmpvar_69; + tmpvar_69 = impl_low_texture2DLodEXT (_MainTex, tmpvar_67.xy, 0.0); + tmpvar_68 = tmpvar_69; + lumaNS_36 = (tmpvar_51.w + tmpvar_44.w); + lumaWE_35 = (tmpvar_54.w + tmpvar_47.w); subpixRcpRange_34 = (1.0/(range_37)); - lumaNESE_33 = (rgba_66.w + rgba_63.w); - lumaNWSW_32 = (rgba_60.w + rgba_69.w); + lumaNESE_33 = (tmpvar_65.w + tmpvar_62.w); + lumaNWSW_32 = (tmpvar_59.w + tmpvar_68.w); lengthSign_31 = fxaaQualityRcpFrame_1.x; horzSpan_30 = ((abs( - ((-2.0 * rgba_56.w) + lumaNWSW_32) + ((-2.0 * tmpvar_54.w) + lumaNWSW_32) ) + ( - (abs(((-2.0 * rgbyM_40.w) + lumaNS_36)) * 2.0) + (abs(((-2.0 * tmpvar_41.w) + lumaNS_36)) * 2.0) + - abs(((-2.0 * rgba_49.w) + lumaNESE_33)) + abs(((-2.0 * tmpvar_47.w) + lumaNESE_33)) )) >= (abs( - ((-2.0 * rgba_45.w) + (rgba_69.w + rgba_63.w)) + ((-2.0 * tmpvar_44.w) + (tmpvar_68.w + tmpvar_62.w)) ) + ( - (abs(((-2.0 * rgbyM_40.w) + lumaWE_35)) * 2.0) + (abs(((-2.0 * tmpvar_41.w) + lumaWE_35)) * 2.0) + - abs(((-2.0 * rgba_52.w) + (rgba_60.w + rgba_66.w))) + abs(((-2.0 * tmpvar_51.w) + (tmpvar_59.w + tmpvar_65.w))) ))); subpixA_29 = (((lumaNS_36 + lumaWE_35) * 2.0) + (lumaNWSW_32 + lumaNESE_33)); if (!(horzSpan_30)) { - lumaN_38 = tmpvar_55; + lumaN_38 = tmpvar_56; }; if (!(horzSpan_30)) { - lumaS_39 = tmpvar_48; + lumaS_39 = tmpvar_49; }; if (horzSpan_30) { lengthSign_31 = fxaaQualityRcpFrame_1.y; }; - subpixB_28 = ((subpixA_29 * 0.0833333) - rgbyM_40.w); - gradientN_27 = (lumaN_38 - rgbyM_40.w); - gradientS_26 = (lumaS_39 - rgbyM_40.w); - lumaNN_25 = (lumaN_38 + rgbyM_40.w); - lumaSS_24 = (lumaS_39 + rgbyM_40.w); + subpixB_28 = ((subpixA_29 * 0.0833333) - tmpvar_41.w); + gradientN_27 = (lumaN_38 - tmpvar_41.w); + gradientS_26 = (lumaS_39 - tmpvar_41.w); + lumaNN_25 = (lumaN_38 + tmpvar_41.w); + lumaSS_24 = (lumaS_39 + tmpvar_41.w); pairN_23 = (abs(gradientN_27) >= abs(gradientS_26)); highp float tmpvar_70; tmpvar_70 = max (abs(gradientN_27), abs(gradientS_26)); @@ -195,25 +195,25 @@ void main () posP_20.x = (posB_22.x + tmpvar_72); posP_20.y = (posB_22.y + tmpvar_73); subpixD_19 = ((-2.0 * tmpvar_71) + 3.0); - lowp vec4 tmpvar_74; - tmpvar_74 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_75; - rgba_75 = tmpvar_74; - lumaEndN_18 = rgba_75.w; + highp vec4 tmpvar_74; + lowp vec4 tmpvar_75; + tmpvar_75 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_74 = tmpvar_75; + lumaEndN_18 = tmpvar_74.w; subpixE_17 = (tmpvar_71 * tmpvar_71); - lowp vec4 tmpvar_76; - tmpvar_76 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_77; - rgba_77 = tmpvar_76; - lumaEndP_16 = rgba_77.w; + highp vec4 tmpvar_76; + lowp vec4 tmpvar_77; + tmpvar_77 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_76 = tmpvar_77; + lumaEndP_16 = tmpvar_76.w; if (!(pairN_23)) { lumaNN_25 = lumaSS_24; }; gradientScaled_15 = (tmpvar_70 / 4.0); subpixF_14 = (subpixD_19 * subpixE_17); - lumaMLTZero_13 = ((rgbyM_40.w - (lumaNN_25 * 0.5)) < 0.0); - lumaEndN_18 = (rgba_75.w - (lumaNN_25 * 0.5)); - lumaEndP_16 = (rgba_77.w - (lumaNN_25 * 0.5)); + lumaMLTZero_13 = ((tmpvar_41.w - (lumaNN_25 * 0.5)) < 0.0); + lumaEndN_18 = (tmpvar_74.w - (lumaNN_25 * 0.5)); + lumaEndP_16 = (tmpvar_76.w - (lumaNN_25 * 0.5)); doneN_12 = (abs(lumaEndN_18) >= gradientScaled_15); doneP_11 = (abs(lumaEndP_16) >= gradientScaled_15); if (!(doneN_12)) { @@ -231,18 +231,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_78; - tmpvar_78 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_79; - rgba_79 = tmpvar_78; - lumaEndN_18 = rgba_79.w; + highp vec4 tmpvar_78; + lowp vec4 tmpvar_79; + tmpvar_79 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_78 = tmpvar_79; + lumaEndN_18 = tmpvar_78.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_80; - tmpvar_80 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_81; - rgba_81 = tmpvar_80; - lumaEndP_16 = rgba_81.w; + highp vec4 tmpvar_80; + lowp vec4 tmpvar_81; + tmpvar_81 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_80 = tmpvar_81; + lumaEndP_16 = tmpvar_80.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -267,18 +267,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_82; - tmpvar_82 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_83; - rgba_83 = tmpvar_82; - lumaEndN_18 = rgba_83.w; + highp vec4 tmpvar_82; + lowp vec4 tmpvar_83; + tmpvar_83 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_82 = tmpvar_83; + lumaEndN_18 = tmpvar_82.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_84; - tmpvar_84 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_85; - rgba_85 = tmpvar_84; - lumaEndP_16 = rgba_85.w; + highp vec4 tmpvar_84; + lowp vec4 tmpvar_85; + tmpvar_85 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_84 = tmpvar_85; + lumaEndP_16 = tmpvar_84.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -303,18 +303,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_86; - tmpvar_86 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_87; - rgba_87 = tmpvar_86; - lumaEndN_18 = rgba_87.w; + highp vec4 tmpvar_86; + lowp vec4 tmpvar_87; + tmpvar_87 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_86 = tmpvar_87; + lumaEndN_18 = tmpvar_86.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_88; - tmpvar_88 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_89; - rgba_89 = tmpvar_88; - lumaEndP_16 = rgba_89.w; + highp vec4 tmpvar_88; + lowp vec4 tmpvar_89; + tmpvar_89 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_88 = tmpvar_89; + lumaEndP_16 = tmpvar_88.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -339,18 +339,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_90; - tmpvar_90 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_91; - rgba_91 = tmpvar_90; - lumaEndN_18 = rgba_91.w; + highp vec4 tmpvar_90; + lowp vec4 tmpvar_91; + tmpvar_91 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_90 = tmpvar_91; + lumaEndN_18 = tmpvar_90.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_92; - tmpvar_92 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_93; - rgba_93 = tmpvar_92; - lumaEndP_16 = rgba_93.w; + highp vec4 tmpvar_92; + lowp vec4 tmpvar_93; + tmpvar_93 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_92 = tmpvar_93; + lumaEndP_16 = tmpvar_92.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -375,18 +375,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_94; - tmpvar_94 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_95; - rgba_95 = tmpvar_94; - lumaEndN_18 = rgba_95.w; + highp vec4 tmpvar_94; + lowp vec4 tmpvar_95; + tmpvar_95 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_94 = tmpvar_95; + lumaEndN_18 = tmpvar_94.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_96; - tmpvar_96 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_97; - rgba_97 = tmpvar_96; - lumaEndP_16 = rgba_97.w; + highp vec4 tmpvar_96; + lowp vec4 tmpvar_97; + tmpvar_97 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_96 = tmpvar_97; + lumaEndP_16 = tmpvar_96.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -411,18 +411,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_98; - tmpvar_98 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_99; - rgba_99 = tmpvar_98; - lumaEndN_18 = rgba_99.w; + highp vec4 tmpvar_98; + lowp vec4 tmpvar_99; + tmpvar_99 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_98 = tmpvar_99; + lumaEndN_18 = tmpvar_98.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_100; - tmpvar_100 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_101; - rgba_101 = tmpvar_100; - lumaEndP_16 = rgba_101.w; + highp vec4 tmpvar_100; + lowp vec4 tmpvar_101; + tmpvar_101 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_100 = tmpvar_101; + lumaEndP_16 = tmpvar_100.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -447,18 +447,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_102; - tmpvar_102 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_103; - rgba_103 = tmpvar_102; - lumaEndN_18 = rgba_103.w; + highp vec4 tmpvar_102; + lowp vec4 tmpvar_103; + tmpvar_103 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_102 = tmpvar_103; + lumaEndN_18 = tmpvar_102.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_104; - tmpvar_104 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_105; - rgba_105 = tmpvar_104; - lumaEndP_16 = rgba_105.w; + highp vec4 tmpvar_104; + lowp vec4 tmpvar_105; + tmpvar_105 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_104 = tmpvar_105; + lumaEndP_16 = tmpvar_104.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -483,18 +483,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_106; - tmpvar_106 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_107; - rgba_107 = tmpvar_106; - lumaEndN_18 = rgba_107.w; + highp vec4 tmpvar_106; + lowp vec4 tmpvar_107; + tmpvar_107 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_106 = tmpvar_107; + lumaEndN_18 = tmpvar_106.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_108; - tmpvar_108 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_109; - rgba_109 = tmpvar_108; - lumaEndP_16 = rgba_109.w; + highp vec4 tmpvar_108; + lowp vec4 tmpvar_109; + tmpvar_109 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_108 = tmpvar_109; + lumaEndP_16 = tmpvar_108.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -519,18 +519,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_110; - tmpvar_110 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_111; - rgba_111 = tmpvar_110; - lumaEndN_18 = rgba_111.w; + highp vec4 tmpvar_110; + lowp vec4 tmpvar_111; + tmpvar_111 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_110 = tmpvar_111; + lumaEndN_18 = tmpvar_110.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_112; - tmpvar_112 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_113; - rgba_113 = tmpvar_112; - lumaEndP_16 = rgba_113.w; + highp vec4 tmpvar_112; + lowp vec4 tmpvar_113; + tmpvar_113 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_112 = tmpvar_113; + lumaEndP_16 = tmpvar_112.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -555,18 +555,18 @@ void main () }; if (doneNP_10) { if (!(doneN_12)) { - lowp vec4 tmpvar_114; - tmpvar_114 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); - highp vec4 rgba_115; - rgba_115 = tmpvar_114; - lumaEndN_18 = rgba_115.w; + highp vec4 tmpvar_114; + lowp vec4 tmpvar_115; + tmpvar_115 = impl_low_texture2DLodEXT (_MainTex, posN_21, 0.0); + tmpvar_114 = tmpvar_115; + lumaEndN_18 = tmpvar_114.w; }; if (!(doneP_11)) { - lowp vec4 tmpvar_116; - tmpvar_116 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); - highp vec4 rgba_117; - rgba_117 = tmpvar_116; - lumaEndP_16 = rgba_117.w; + highp vec4 tmpvar_116; + lowp vec4 tmpvar_117; + tmpvar_117 = impl_low_texture2DLodEXT (_MainTex, posP_20, 0.0); + tmpvar_116 = tmpvar_117; + lumaEndP_16 = tmpvar_116.w; }; if (!(doneN_12)) { lumaEndN_18 = (lumaEndN_18 - (lumaNN_25 * 0.5)); @@ -629,16 +629,16 @@ void main () highp float tmpvar_121; tmpvar_121 = max (tmpvar_120, subpixH_3); if (!(horzSpan_30)) { - posM_41.x = (xlv_TEXCOORD0.x + (tmpvar_121 * lengthSign_31)); + posM_40.x = (xlv_TEXCOORD0.x + (tmpvar_121 * lengthSign_31)); }; if (horzSpan_30) { - posM_41.y = (xlv_TEXCOORD0.y + (tmpvar_121 * lengthSign_31)); + posM_40.y = (xlv_TEXCOORD0.y + (tmpvar_121 * lengthSign_31)); }; lowp vec4 tmpvar_122; - tmpvar_122 = impl_low_texture2DLodEXT (_MainTex, posM_41, 0.0); + tmpvar_122 = impl_low_texture2DLodEXT (_MainTex, posM_40, 0.0); highp vec4 tmpvar_123; tmpvar_123.xyz = tmpvar_122.xyz; - tmpvar_123.w = rgbyM_40.w; + tmpvar_123.w = tmpvar_41.w; tmpvar_2 = tmpvar_123; }; gl_FragData[0] = tmpvar_2; diff --git a/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO24-outES3.txt b/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO24-outES3.txt index 34fdad70d..8ba9f361f 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO24-outES3.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO24-outES3.txt @@ -51,16 +51,14 @@ void main () }; randomDir_14 = (randomDir_14 * -(tmpvar_18)); randomDir_14 = (randomDir_14 + (viewNorm_7 * 0.3)); - highp vec4 tmpvar_19; - tmpvar_19 = texture (_CameraDepthNormalsTexture, (tmpvar_2 + (randomDir_14.xy * scale_5))); - highp float tmpvar_20; - tmpvar_20 = clamp (((depth_6 - + highp float tmpvar_19; + tmpvar_19 = clamp (((depth_6 - (randomDir_14.z * _Params.x) ) - ( - dot (tmpvar_19.zw, vec2(1.0, 0.00392157)) + dot (texture (_CameraDepthNormalsTexture, (tmpvar_2 + (randomDir_14.xy * scale_5))).zw, vec2(1.0, 0.00392157)) * _ProjectionParams.z)), 0.0, 1.0); - if ((tmpvar_20 > _Params.y)) { - occ_4 = (occ_4 + pow ((1.0 - tmpvar_20), _Params.z)); + if ((tmpvar_19 > _Params.y)) { + occ_4 = (occ_4 + pow ((1.0 - tmpvar_19), _Params.z)); }; }; occ_4 = (occ_4 / 8.0); diff --git a/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO24-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO24-outES3Metal.txt index d31961e71..de7007b91 100644 --- a/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO24-outES3Metal.txt +++ b/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO24-outES3Metal.txt @@ -29,7 +29,7 @@ fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]] tmpvar_9 = ((_RandomTexture.sample(_mtlsmp__RandomTexture, (float2)(_mtl_i.xlv_TEXCOORD1)).xyz * (half)2.0) - (half)1.0); randN_8 = tmpvar_9; float4 tmpvar_10; - tmpvar_10 = float4(_CameraDepthNormalsTexture.sample(_mtlsmp__CameraDepthNormalsTexture, (float2)(_mtl_i.xlv_TEXCOORD0))); + tmpvar_10 = _CameraDepthNormalsTexture.sample(_mtlsmp__CameraDepthNormalsTexture, (float2)(_mtl_i.xlv_TEXCOORD0)); float3 n_11; float3 tmpvar_12; tmpvar_12 = ((tmpvar_10.xyz * float3(3.5554, 3.5554, 0.0)) + float3(-1.7777, -1.7777, 1.0)); @@ -60,16 +60,14 @@ fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]] }; randomDir_14 = (randomDir_14 * -(tmpvar_18)); randomDir_14 = half3(((float3)randomDir_14 + (viewNorm_7 * 0.3))); - float4 tmpvar_19; - tmpvar_19 = float4(_CameraDepthNormalsTexture.sample(_mtlsmp__CameraDepthNormalsTexture, (float2)((tmpvar_2 + ((float2)randomDir_14.xy * scale_5))))); - float tmpvar_20; - tmpvar_20 = clamp (((depth_6 - + float tmpvar_19; + tmpvar_19 = clamp (((depth_6 - ((float)randomDir_14.z * _mtl_u._Params.x) ) - ( - dot (tmpvar_19.zw, float2(1.0, 0.00392157)) + dot (_CameraDepthNormalsTexture.sample(_mtlsmp__CameraDepthNormalsTexture, (float2)((tmpvar_2 + ((float2)randomDir_14.xy * scale_5)))).zw, float2(1.0, 0.00392157)) * _mtl_u._ProjectionParams.z)), 0.0, 1.0); - if ((tmpvar_20 > _mtl_u._Params.y)) { - occ_4 = (occ_4 + pow ((1.0 - tmpvar_20), _mtl_u._Params.z)); + if ((tmpvar_19 > _mtl_u._Params.y)) { + occ_4 = (occ_4 + pow ((1.0 - tmpvar_19), _mtl_u._Params.z)); }; }; occ_4 = (occ_4 / 8.0); diff --git a/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.cpp b/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.cpp index fe23cd4dc..98c3d032f 100644 --- a/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.cpp +++ b/3rdparty/glsl-optimizer/tests/glsl_optimizer_tests.cpp @@ -19,23 +19,23 @@ #include #include extern "C" { -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -typedef void (WINAPI * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (WINAPI * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (WINAPI * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (WINAPI * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef void (WINAPI * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (WINAPI * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -static PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; -static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; -static PFNGLSHADERSOURCEARBPROC glShaderSourceARB; -static PFNGLCOMPILESHADERARBPROC glCompileShaderARB; -static PFNGLGETINFOLOGARBPROC glGetInfoLogARB; -static PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; +typedef char GLchar; /* native character */ +typedef unsigned int GLuint; /* shader object handle */ +#define GL_VERTEX_SHADER 0x8B31 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_COMPILE_STATUS 0x8B81 +typedef void (WINAPI * PFNGLDELETESHADERPROC) (GLuint shader); +typedef GLuint (WINAPI * PFNGLCREATESHADERPROC) (GLenum type); +typedef void (WINAPI * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (WINAPI * PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (WINAPI * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (WINAPI * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +static PFNGLDELETESHADERPROC glDeleteShader; +static PFNGLCREATESHADERPROC glCreateShader; +static PFNGLSHADERSOURCEPROC glShaderSource; +static PFNGLCOMPILESHADERPROC glCompileShader; +static PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +static PFNGLGETSHADERIVPROC glGetShaderiv; } #endif // #ifdef _MSC_VER @@ -154,12 +154,12 @@ static bool InitializeOpenGL () #ifdef _MSC_VER if (hasGLSL) { - glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)wglGetProcAddress("glDeleteObjectARB"); - glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)wglGetProcAddress("glCreateShaderObjectARB"); - glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)wglGetProcAddress("glShaderSourceARB"); - glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)wglGetProcAddress("glCompileShaderARB"); - glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)wglGetProcAddress("glGetInfoLogARB"); - glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); + glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); + glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); + glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); + glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); + glGetShaderiv = (PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv"); } #endif @@ -266,6 +266,8 @@ static bool CheckGLSL (bool vertex, bool gles, const std::string& testName, cons if (gles) { replace_string (src, "GL_EXT_shader_texture_lod", "GL_ARB_shader_texture_lod", 0); + replace_string (src, "GL_EXT_draw_instanced", "GL_ARB_draw_instanced", 0); + replace_string (src, "gl_InstanceIDEXT", "gl_InstanceIDARB ", 0); replace_string (src, "#extension GL_OES_standard_derivatives : require", "", 0); replace_string (src, "#extension GL_EXT_shadow_samplers : require", "", 0); replace_string (src, "#extension GL_EXT_frag_depth : require", "", 0); diff --git a/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-in.txt b/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-in.txt new file mode 100644 index 000000000..b5d7a3083 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-in.txt @@ -0,0 +1,16 @@ +#extension GL_ARB_draw_instanced : require +#extension GL_EXT_gpu_shader4 : require + +attribute vec3 _inPos; +attribute vec3 _inNor; + +void main() +{ + vec3 p; + p = _inPos; + p.y += float(gl_VertexID); + p.y += float(gl_InstanceIDARB); + p += _inNor; + gl_Position = vec4(p,1.0); + gl_PointSize = p.x; +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-inES.txt b/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-inES.txt new file mode 100644 index 000000000..dbf6c1650 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-inES.txt @@ -0,0 +1,14 @@ +#extension GL_EXT_draw_instanced : require + +attribute highp vec3 _inPos; +attribute highp vec3 _inNor; + +void main() +{ + highp vec3 p; + p = _inPos; + p.y += float(gl_InstanceIDEXT); + p += _inNor; + gl_Position = vec4(p,1.0); + gl_PointSize = p.x; +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-out.txt b/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-out.txt new file mode 100644 index 000000000..9b18e44ea --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-out.txt @@ -0,0 +1,23 @@ +#extension GL_ARB_draw_instanced : enable +#extension GL_EXT_gpu_shader4 : enable +attribute vec3 _inPos; +attribute vec3 _inNor; +void main () +{ + vec3 p_1; + p_1.xz = _inPos.xz; + p_1.y = (_inPos.y + float(gl_VertexID)); + p_1.y = (p_1.y + float(gl_InstanceIDARB)); + p_1 = (p_1 + _inNor); + vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = p_1; + gl_Position = tmpvar_2; + gl_PointSize = p_1.x; +} + + +// stats: 6 alu 0 tex 0 flow +// inputs: 2 +// #0: _inPos (high float) 3x1 [-1] +// #1: _inNor (high float) 3x1 [-1] diff --git a/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-outES.txt new file mode 100644 index 000000000..f82939e25 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/builtin-vars-outES.txt @@ -0,0 +1,21 @@ +#extension GL_EXT_draw_instanced : enable +attribute highp vec3 _inPos; +attribute highp vec3 _inNor; +void main () +{ + highp vec3 p_1; + p_1.xz = _inPos.xz; + p_1.y = (_inPos.y + float(gl_InstanceIDEXT)); + p_1 = (p_1 + _inNor); + highp vec4 tmpvar_2; + tmpvar_2.w = 1.0; + tmpvar_2.xyz = p_1; + gl_Position = tmpvar_2; + gl_PointSize = p_1.x; +} + + +// stats: 4 alu 0 tex 0 flow +// inputs: 2 +// #0: _inPos (high float) 3x1 [-1] +// #1: _inNor (high float) 3x1 [-1] diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3.txt index b1fca1d8e..d3a42f5a0 100644 --- a/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3.txt +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3.txt @@ -40,7 +40,10 @@ void main () Temp_int_1.xyz = floatBitsToInt((intBitsToFloat(Temp_int_0).www * intBitsToFloat(Temp_int_1).xyz)); Temp_2.xyz = glstate_lightmodel_ambient.xyz; Temp_int_0.w = 0; - for (; Temp_int_0.w < 4; Temp_int_0.w = (Temp_int_0.w + 1)) { + while (true) { + if ((Temp_int_0.w >= 4)) { + break; + }; Temp_3.xyz = ((-( intBitsToFloat(Temp_int_0) .xyz) * unity_LightPosition[Temp_int_0.w].www) + unity_LightPosition[Temp_int_0.w].xyz); @@ -61,6 +64,7 @@ void main () Temp_2.w = max (Temp_2.w, 0.0); Temp_int_1.w = floatBitsToInt((intBitsToFloat(Temp_int_1).w * Temp_2.w)); Temp_2.xyz = ((unity_LightColor[Temp_int_0.w].xyz * intBitsToFloat(Temp_int_1).www) + Temp_2.xyz); + Temp_int_0.w = (Temp_int_0.w + 1); }; COLOR0.xyz = (Temp_2.xyz * _Color.xyz); COLOR0.w = (_Color.w * _ReflectColor.w); diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3Metal.txt index ede21264b..a6e6c9b72 100644 --- a/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3Metal.txt +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-for-withvec4inductorW-outES3Metal.txt @@ -49,7 +49,10 @@ int4 Temp_int_1_5; Temp_int_1_5.xyz = as_type((as_type(Temp_int_0_4).www * as_type(Temp_int_1_5).xyz)); Temp_2_2.xyz = _mtl_u.glstate_lightmodel_ambient.xyz; Temp_int_0_4.w = 0; - for (; Temp_int_0_4.w < 4; Temp_int_0_4.w = (Temp_int_0_4.w + 1)) { + while (true) { + if ((Temp_int_0_4.w >= 4)) { + break; + }; Temp_3_3.xyz = ((-( as_type(Temp_int_0_4) .xyz) * _mtl_u.unity_LightPosition[Temp_int_0_4.w].www) + _mtl_u.unity_LightPosition[Temp_int_0_4.w].xyz); @@ -70,6 +73,7 @@ int4 Temp_int_1_5; Temp_2_2.w = max (Temp_2_2.w, 0.0); Temp_int_1_5.w = as_type((as_type(Temp_int_1_5).w * Temp_2_2.w)); Temp_2_2.xyz = ((_mtl_u.unity_LightColor[Temp_int_0_4.w].xyz * as_type(Temp_int_1_5).www) + Temp_2_2.xyz); + Temp_int_0_4.w = (Temp_int_0_4.w + 1); }; _mtl_o.COLOR0.xyz = (Temp_2_2.xyz * _mtl_u._Color.xyz); _mtl_o.COLOR0.w = (_mtl_u._Color.w * _mtl_u._ReflectColor.w); diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-inES.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-inES.txt new file mode 100644 index 000000000..c13e7e1c9 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-inES.txt @@ -0,0 +1,63 @@ +#line 1 +attribute vec4 _glesVertex; +attribute vec3 _glesNormal; +struct v2f { + lowp vec4 color; + highp vec4 pos; +}; +struct appdata { + highp vec3 pos; + highp vec3 normal; +}; +uniform mediump vec4 unity_LightColor[8]; +uniform highp vec4 unity_LightPosition[8]; +uniform highp ivec4 unity_VertexLightParams; +mediump vec3 computeLighting(in highp int idx, in mediump vec3 dirToLight, in mediump vec3 eyeNormal, in mediump float atten) +{ + mediump float NdotL = max( dot( eyeNormal, dirToLight), 0.0); + mediump vec3 color = NdotL * unity_LightColor[idx].xyz; + return color * atten; +} +mediump vec3 computeOneLight( in highp int idx, in mediump vec3 eyeNormal) +{ + highp vec3 dirToLight = unity_LightPosition[idx].xyz; + mediump float att = 1.0; + + att *= 0.5; + return min( computeLighting( idx, dirToLight, eyeNormal, att), vec3(1.0)); +} +v2f vert( in appdata IN ) +{ + v2f o; + mediump vec4 color = vec4(0.0, 0.0, 0.0, 1.1); + + mediump vec3 eyeNormal = IN.normal; + + mediump vec3 lcolor = vec3(0.0); + + // loop doing up to N lights, with max cap + highp int il = 0; + for ( ; (float(il) < min( 8.0, float(unity_VertexLightParams.x))); (++il)) + { + lcolor += computeOneLight(il, eyeNormal); + } + color.xyz = lcolor.xyz; + + // other forms of a similar loop + for (int j = 0; j < int(min(float(unity_VertexLightParams.y),4.0)); ++j) + color.xyz += unity_LightColor[j].xyz; + + o.color = color; + o.pos = vec4(IN.pos,1.0); + return o; +} +varying lowp vec4 xlv_COLOR0; +void main() { + v2f xl_retval; + appdata xlt_IN; + xlt_IN.pos = _glesVertex.xyz; + xlt_IN.normal = _glesNormal; + xl_retval = vert(xlt_IN); + xlv_COLOR0 = vec4(xl_retval.color); + gl_Position = vec4(xl_retval.pos); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-inES3.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-inES3.txt new file mode 100644 index 000000000..e2f957ddb --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-inES3.txt @@ -0,0 +1,66 @@ +#version 300 es +#line 2 +in vec4 _glesVertex; +in vec3 _glesNormal; +struct v2f { + lowp vec4 color; + highp vec4 pos; +}; +struct appdata { + highp vec3 pos; + highp vec3 normal; +}; +uniform mediump vec4 unity_LightColor[8]; +uniform highp vec4 unity_LightPosition[8]; +uniform highp ivec4 unity_VertexLightParams; +mediump vec3 computeLighting(in highp int idx, in mediump vec3 dirToLight, in mediump vec3 eyeNormal, in mediump float atten) +{ + mediump float NdotL = max( dot( eyeNormal, dirToLight), 0.0); + mediump vec3 color = NdotL * unity_LightColor[idx].xyz; + return color * atten; +} +mediump vec3 computeOneLight( in highp int idx, in mediump vec3 eyeNormal) +{ + highp vec3 dirToLight = unity_LightPosition[idx].xyz; + mediump float att = 1.0; + + att *= 0.5; + return min( computeLighting( idx, dirToLight, eyeNormal, att), vec3(1.0)); +} +v2f vert( in appdata IN ) +{ + v2f o; + mediump vec4 color = vec4(0.0, 0.0, 0.0, 1.1); + + mediump vec3 eyeNormal = IN.normal; + + mediump vec3 lcolor = vec3(0.0); + + // loop doing up to N lights, with max cap + highp int il = 0; + for ( ; (float(il) < min( 8.0, float(unity_VertexLightParams.x))); (++il)) + { + lcolor += computeOneLight(il, eyeNormal); + } + color.xyz = lcolor.xyz; + + // other forms of a similar loop + for (int j = 0; j < int(min(float(unity_VertexLightParams.y),4.0)); ++j) + color.xyz += unity_LightColor[j].xyz; + for (int j = 0; j < min(unity_VertexLightParams.y,4); ++j) + color.xyz *= unity_LightColor[j].xyz; + + o.color = color; + o.pos = vec4(IN.pos,1.0); + return o; +} +out lowp vec4 xlv_COLOR0; +void main() { + v2f xl_retval; + appdata xlt_IN; + xlt_IN.pos = _glesVertex.xyz; + xlt_IN.normal = _glesNormal; + xl_retval = vert(xlt_IN); + xlv_COLOR0 = vec4(xl_retval.color); + gl_Position = vec4(xl_retval.pos); +} diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES.txt new file mode 100644 index 000000000..0a91784e1 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES.txt @@ -0,0 +1,65 @@ +attribute vec4 _glesVertex; +attribute vec3 _glesNormal; +uniform mediump vec4 unity_LightColor[8]; +uniform highp vec4 unity_LightPosition[8]; +uniform highp ivec4 unity_VertexLightParams; +varying lowp vec4 xlv_COLOR0; +void main () +{ + highp vec3 tmpvar_1; + highp vec3 tmpvar_2; + tmpvar_1 = _glesVertex.xyz; + tmpvar_2 = _glesNormal; + highp int j_3; + highp int il_4; + mediump vec3 lcolor_5; + mediump vec3 eyeNormal_6; + mediump vec4 color_7; + lowp vec4 tmpvar_8; + color_7 = vec4(0.0, 0.0, 0.0, 1.1); + eyeNormal_6 = tmpvar_2; + lcolor_5 = vec3(0.0, 0.0, 0.0); + il_4 = 0; + while (true) { + highp float tmpvar_9; + tmpvar_9 = min (8.0, float(unity_VertexLightParams.x)); + if ((float(il_4) >= tmpvar_9)) { + break; + }; + highp vec3 tmpvar_10; + tmpvar_10 = unity_LightPosition[il_4].xyz; + mediump vec3 dirToLight_11; + dirToLight_11 = tmpvar_10; + lcolor_5 = (lcolor_5 + min (( + (max (dot (eyeNormal_6, dirToLight_11), 0.0) * unity_LightColor[il_4].xyz) + * 0.5), vec3(1.0, 1.0, 1.0))); + il_4++; + }; + color_7.xyz = lcolor_5; + j_3 = 0; + while (true) { + highp float tmpvar_12; + tmpvar_12 = min (float(unity_VertexLightParams.y), 4.0); + if ((j_3 >= int(tmpvar_12))) { + break; + }; + color_7.xyz = (color_7.xyz + unity_LightColor[j_3].xyz); + j_3++; + }; + tmpvar_8 = color_7; + highp vec4 tmpvar_13; + tmpvar_13.w = 1.0; + tmpvar_13.xyz = tmpvar_1; + xlv_COLOR0 = tmpvar_8; + gl_Position = tmpvar_13; +} + + +// stats: 22 alu 0 tex 4 flow +// inputs: 2 +// #0: _glesVertex (high float) 4x1 [-1] +// #1: _glesNormal (high float) 3x1 [-1] +// uniforms: 3 (total size: 0) +// #0: unity_LightColor (medium float) 4x1 [8] +// #1: unity_LightPosition (high float) 4x1 [8] +// #2: unity_VertexLightParams (high int) 4x1 [-1] diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES3.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES3.txt new file mode 100644 index 000000000..83f6ba5d5 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES3.txt @@ -0,0 +1,77 @@ +#version 300 es +in vec4 _glesVertex; +in vec3 _glesNormal; +uniform mediump vec4 unity_LightColor[8]; +uniform highp vec4 unity_LightPosition[8]; +uniform highp ivec4 unity_VertexLightParams; +out lowp vec4 xlv_COLOR0; +void main () +{ + highp vec3 tmpvar_1; + highp vec3 tmpvar_2; + tmpvar_1 = _glesVertex.xyz; + tmpvar_2 = _glesNormal; + highp int j_3; + highp int j_4; + highp int il_5; + mediump vec3 lcolor_6; + mediump vec3 eyeNormal_7; + mediump vec4 color_8; + lowp vec4 tmpvar_9; + color_8 = vec4(0.0, 0.0, 0.0, 1.1); + eyeNormal_7 = tmpvar_2; + lcolor_6 = vec3(0.0, 0.0, 0.0); + il_5 = 0; + while (true) { + highp float tmpvar_10; + tmpvar_10 = min (8.0, float(unity_VertexLightParams.x)); + if ((float(il_5) >= tmpvar_10)) { + break; + }; + highp vec3 tmpvar_11; + tmpvar_11 = unity_LightPosition[il_5].xyz; + mediump vec3 dirToLight_12; + dirToLight_12 = tmpvar_11; + lcolor_6 = (lcolor_6 + min (( + (max (dot (eyeNormal_7, dirToLight_12), 0.0) * unity_LightColor[il_5].xyz) + * 0.5), vec3(1.0, 1.0, 1.0))); + il_5++; + }; + color_8.xyz = lcolor_6; + j_4 = 0; + while (true) { + highp float tmpvar_13; + tmpvar_13 = min (float(unity_VertexLightParams.y), 4.0); + if ((j_4 >= int(tmpvar_13))) { + break; + }; + color_8.xyz = (color_8.xyz + unity_LightColor[j_4].xyz); + j_4++; + }; + j_3 = 0; + while (true) { + highp int tmpvar_14; + tmpvar_14 = min (unity_VertexLightParams.y, 4); + if ((j_3 >= tmpvar_14)) { + break; + }; + color_8.xyz = (color_8.xyz * unity_LightColor[j_3].xyz); + j_3++; + }; + tmpvar_9 = color_8; + highp vec4 tmpvar_15; + tmpvar_15.w = 1.0; + tmpvar_15.xyz = tmpvar_1; + xlv_COLOR0 = tmpvar_9; + gl_Position = tmpvar_15; +} + + +// stats: 27 alu 0 tex 6 flow +// inputs: 2 +// #0: _glesVertex (high float) 4x1 [-1] +// #1: _glesNormal (high float) 3x1 [-1] +// uniforms: 3 (total size: 0) +// #0: unity_LightColor (medium float) 4x1 [8] +// #1: unity_LightPosition (high float) 4x1 [8] +// #2: unity_VertexLightParams (high int) 4x1 [-1] diff --git a/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES3Metal.txt new file mode 100644 index 000000000..4fff005a3 --- /dev/null +++ b/3rdparty/glsl-optimizer/tests/vertex/loops-forlimitbreak-outES3Metal.txt @@ -0,0 +1,85 @@ +#include +using namespace metal; +struct xlatMtlShaderInput { + float4 _glesVertex [[attribute(0)]]; + float3 _glesNormal [[attribute(1)]]; +}; +struct xlatMtlShaderOutput { + float4 gl_Position [[position]]; + half4 xlv_COLOR0; +}; +struct xlatMtlShaderUniform { + half4 unity_LightColor[8]; + float4 unity_LightPosition[8]; + int4 unity_VertexLightParams; +}; +vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]) +{ + xlatMtlShaderOutput _mtl_o; + float3 tmpvar_1; + tmpvar_1 = _mtl_i._glesVertex.xyz; + int j_2; + int j_3; + int il_4; + half3 lcolor_5; + half3 eyeNormal_6; + half4 color_7; + half4 tmpvar_8; + color_7 = half4(float4(0.0, 0.0, 0.0, 1.1)); + eyeNormal_6 = half3(_mtl_i._glesNormal); + lcolor_5 = half3(float3(0.0, 0.0, 0.0)); + il_4 = 0; + while (true) { + float tmpvar_9; + tmpvar_9 = min (8.0, float(_mtl_u.unity_VertexLightParams.x)); + if ((float(il_4) >= tmpvar_9)) { + break; + }; + float3 tmpvar_10; + tmpvar_10 = _mtl_u.unity_LightPosition[il_4].xyz; + half3 dirToLight_11; + dirToLight_11 = half3(tmpvar_10); + lcolor_5 = (lcolor_5 + min (( + (max (dot (eyeNormal_6, dirToLight_11), (half)0.0) * _mtl_u.unity_LightColor[il_4].xyz) + * (half)0.5), (half3)float3(1.0, 1.0, 1.0))); + il_4++; + }; + color_7.xyz = lcolor_5; + j_3 = 0; + while (true) { + float tmpvar_12; + tmpvar_12 = min (float(_mtl_u.unity_VertexLightParams.y), 4.0); + if ((j_3 >= int(tmpvar_12))) { + break; + }; + color_7.xyz = (color_7.xyz + _mtl_u.unity_LightColor[j_3].xyz); + j_3++; + }; + j_2 = 0; + while (true) { + int tmpvar_13; + tmpvar_13 = min (_mtl_u.unity_VertexLightParams.y, 4); + if ((j_2 >= tmpvar_13)) { + break; + }; + color_7.xyz = (color_7.xyz * _mtl_u.unity_LightColor[j_2].xyz); + j_2++; + }; + tmpvar_8 = color_7; + float4 tmpvar_14; + tmpvar_14.w = 1.0; + tmpvar_14.xyz = tmpvar_1; + _mtl_o.xlv_COLOR0 = tmpvar_8; + _mtl_o.gl_Position = tmpvar_14; + return _mtl_o; +} + + +// stats: 27 alu 0 tex 6 flow +// inputs: 2 +// #0: _glesVertex (high float) 4x1 [-1] loc 0 +// #1: _glesNormal (high float) 3x1 [-1] loc 1 +// uniforms: 3 (total size: 208) +// #0: unity_LightColor (medium float) 4x1 [8] loc 0 +// #1: unity_LightPosition (high float) 4x1 [8] loc 64 +// #2: unity_VertexLightParams (high int) 4x1 [-1] loc 192 diff --git a/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES.txt b/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES.txt index 692c21722..b6e32666a 100644 --- a/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES.txt +++ b/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES.txt @@ -17,134 +17,134 @@ void main () highp vec2 tmpvar_6; tmpvar_6.y = 1.0; tmpvar_6.x = float(tmpvar_5.x); - mediump vec4 tmpvar_7; - mediump vec2 coord_8; - coord_8 = tmpvar_6; + mediump vec2 coord_7; + coord_7 = tmpvar_6; + mediump vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = (coord_7 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_9; - tmpvar_9.zw = vec2(0.0, 0.0); - tmpvar_9.xy = (coord_8 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_10; - tmpvar_10 = texture2DLod (_DynLampInfo, tmpvar_9.xy, 0.0); - tmpvar_7 = tmpvar_10; + tmpvar_10 = texture2DLod (_DynLampInfo, tmpvar_8.xy, 0.0); + tmpvar_9 = tmpvar_10; highp vec2 tmpvar_11; tmpvar_11.y = 2.0; tmpvar_11.x = float(tmpvar_5.x); - mediump vec4 tmpvar_12; - mediump vec2 coord_13; - coord_13 = tmpvar_11; + mediump vec2 coord_12; + coord_12 = tmpvar_11; + mediump vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = (coord_12 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_14; - tmpvar_14.zw = vec2(0.0, 0.0); - tmpvar_14.xy = (coord_13 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_15; - tmpvar_15 = texture2DLod (_DynLampInfo, tmpvar_14.xy, 0.0); - tmpvar_12 = tmpvar_15; + tmpvar_15 = texture2DLod (_DynLampInfo, tmpvar_13.xy, 0.0); + tmpvar_14 = tmpvar_15; highp vec2 tmpvar_16; tmpvar_16.y = 1.0; tmpvar_16.x = float(tmpvar_5.y); - mediump vec4 tmpvar_17; - mediump vec2 coord_18; - coord_18 = tmpvar_16; + mediump vec2 coord_17; + coord_17 = tmpvar_16; + mediump vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = (coord_17 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_19; - tmpvar_19.zw = vec2(0.0, 0.0); - tmpvar_19.xy = (coord_18 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_20; - tmpvar_20 = texture2DLod (_DynLampInfo, tmpvar_19.xy, 0.0); - tmpvar_17 = tmpvar_20; + tmpvar_20 = texture2DLod (_DynLampInfo, tmpvar_18.xy, 0.0); + tmpvar_19 = tmpvar_20; highp vec2 tmpvar_21; tmpvar_21.y = 2.0; tmpvar_21.x = float(tmpvar_5.y); - mediump vec4 tmpvar_22; - mediump vec2 coord_23; - coord_23 = tmpvar_21; + mediump vec2 coord_22; + coord_22 = tmpvar_21; + mediump vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = (coord_22 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_24; - tmpvar_24.zw = vec2(0.0, 0.0); - tmpvar_24.xy = (coord_23 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_25; - tmpvar_25 = texture2DLod (_DynLampInfo, tmpvar_24.xy, 0.0); - tmpvar_22 = tmpvar_25; + tmpvar_25 = texture2DLod (_DynLampInfo, tmpvar_23.xy, 0.0); + tmpvar_24 = tmpvar_25; highp vec2 tmpvar_26; tmpvar_26.y = 1.0; tmpvar_26.x = float(tmpvar_5.z); - mediump vec4 tmpvar_27; - mediump vec2 coord_28; - coord_28 = tmpvar_26; + mediump vec2 coord_27; + coord_27 = tmpvar_26; + mediump vec4 tmpvar_28; + tmpvar_28.zw = vec2(0.0, 0.0); + tmpvar_28.xy = (coord_27 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_29; - tmpvar_29.zw = vec2(0.0, 0.0); - tmpvar_29.xy = (coord_28 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_30; - tmpvar_30 = texture2DLod (_DynLampInfo, tmpvar_29.xy, 0.0); - tmpvar_27 = tmpvar_30; + tmpvar_30 = texture2DLod (_DynLampInfo, tmpvar_28.xy, 0.0); + tmpvar_29 = tmpvar_30; highp vec2 tmpvar_31; tmpvar_31.y = 2.0; tmpvar_31.x = float(tmpvar_5.z); - mediump vec4 tmpvar_32; - mediump vec2 coord_33; - coord_33 = tmpvar_31; + mediump vec2 coord_32; + coord_32 = tmpvar_31; + mediump vec4 tmpvar_33; + tmpvar_33.zw = vec2(0.0, 0.0); + tmpvar_33.xy = (coord_32 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_34; - tmpvar_34.zw = vec2(0.0, 0.0); - tmpvar_34.xy = (coord_33 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_35; - tmpvar_35 = texture2DLod (_DynLampInfo, tmpvar_34.xy, 0.0); - tmpvar_32 = tmpvar_35; + tmpvar_35 = texture2DLod (_DynLampInfo, tmpvar_33.xy, 0.0); + tmpvar_34 = tmpvar_35; highp vec2 tmpvar_36; tmpvar_36.y = 1.0; tmpvar_36.x = float(tmpvar_5.w); - mediump vec4 tmpvar_37; - mediump vec2 coord_38; - coord_38 = tmpvar_36; + mediump vec2 coord_37; + coord_37 = tmpvar_36; + mediump vec4 tmpvar_38; + tmpvar_38.zw = vec2(0.0, 0.0); + tmpvar_38.xy = (coord_37 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_39; - tmpvar_39.zw = vec2(0.0, 0.0); - tmpvar_39.xy = (coord_38 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_40; - tmpvar_40 = texture2DLod (_DynLampInfo, tmpvar_39.xy, 0.0); - tmpvar_37 = tmpvar_40; + tmpvar_40 = texture2DLod (_DynLampInfo, tmpvar_38.xy, 0.0); + tmpvar_39 = tmpvar_40; highp vec2 tmpvar_41; tmpvar_41.y = 2.0; tmpvar_41.x = float(tmpvar_5.w); - mediump vec4 tmpvar_42; - mediump vec2 coord_43; - coord_43 = tmpvar_41; + mediump vec2 coord_42; + coord_42 = tmpvar_41; + mediump vec4 tmpvar_43; + tmpvar_43.zw = vec2(0.0, 0.0); + tmpvar_43.xy = (coord_42 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_44; - tmpvar_44.zw = vec2(0.0, 0.0); - tmpvar_44.xy = (coord_43 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_45; - tmpvar_45 = texture2DLod (_DynLampInfo, tmpvar_44.xy, 0.0); - tmpvar_42 = tmpvar_45; + tmpvar_45 = texture2DLod (_DynLampInfo, tmpvar_43.xy, 0.0); + tmpvar_44 = tmpvar_45; mediump vec3 hybridCol_46; mediump vec4 atten_47; highp vec3 tmpvar_48; - tmpvar_48 = (tmpvar_7.xyz - tmpvar_2); + tmpvar_48 = (tmpvar_9.xyz - tmpvar_2); highp float tmpvar_49; tmpvar_49 = dot (tmpvar_48, tmpvar_48); mediump vec4 tmpvar_50; tmpvar_50.yzw = atten_47.yzw; - tmpvar_50.x = (tmpvar_49 * tmpvar_7.w); + tmpvar_50.x = (tmpvar_49 * tmpvar_9.w); highp vec3 tmpvar_51; - tmpvar_51 = (tmpvar_17.xyz - tmpvar_2); + tmpvar_51 = (tmpvar_19.xyz - tmpvar_2); highp float tmpvar_52; tmpvar_52 = dot (tmpvar_51, tmpvar_51); mediump vec4 tmpvar_53; tmpvar_53.xzw = tmpvar_50.xzw; - tmpvar_53.y = (tmpvar_52 * tmpvar_17.w); + tmpvar_53.y = (tmpvar_52 * tmpvar_19.w); highp vec3 tmpvar_54; - tmpvar_54 = (tmpvar_27.xyz - tmpvar_2); + tmpvar_54 = (tmpvar_29.xyz - tmpvar_2); highp float tmpvar_55; tmpvar_55 = dot (tmpvar_54, tmpvar_54); mediump vec4 tmpvar_56; tmpvar_56.xyw = tmpvar_53.xyw; - tmpvar_56.z = (tmpvar_55 * tmpvar_27.w); + tmpvar_56.z = (tmpvar_55 * tmpvar_29.w); highp vec3 tmpvar_57; - tmpvar_57 = (tmpvar_37.xyz - tmpvar_2); + tmpvar_57 = (tmpvar_39.xyz - tmpvar_2); highp float tmpvar_58; tmpvar_58 = dot (tmpvar_57, tmpvar_57); mediump vec4 tmpvar_59; tmpvar_59.xyz = tmpvar_56.xyz; - tmpvar_59.w = (tmpvar_58 * tmpvar_37.w); + tmpvar_59.w = (tmpvar_58 * tmpvar_39.w); atten_47 = tmpvar_59; - hybridCol_46 = (hybridCol_4 + (tmpvar_12.xyz * tmpvar_50.x)); - hybridCol_46 = (hybridCol_46 + (tmpvar_22.xyz * tmpvar_53.y)); - hybridCol_46 = (hybridCol_46 + (tmpvar_32.xyz * tmpvar_56.z)); - hybridCol_46 = (hybridCol_46 + (tmpvar_42.xyz * tmpvar_59.w)); + hybridCol_46 = (hybridCol_4 + (tmpvar_14.xyz * tmpvar_50.x)); + hybridCol_46 = (hybridCol_46 + (tmpvar_24.xyz * tmpvar_53.y)); + hybridCol_46 = (hybridCol_46 + (tmpvar_34.xyz * tmpvar_56.z)); + hybridCol_46 = (hybridCol_46 + (tmpvar_44.xyz * tmpvar_59.w)); tmpvar_3 = hybridCol_46; tmpvar_1 = tmpvar_3; gl_Position = (glstate_matrix_mvp * _glesVertex); diff --git a/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES3.txt b/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES3.txt index dc583a7a2..8b320c494 100644 --- a/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES3.txt +++ b/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES3.txt @@ -18,134 +18,134 @@ void main () highp vec2 tmpvar_6; tmpvar_6.y = 1.0; tmpvar_6.x = float(tmpvar_5.x); - mediump vec4 tmpvar_7; - mediump vec2 coord_8; - coord_8 = tmpvar_6; + mediump vec2 coord_7; + coord_7 = tmpvar_6; + mediump vec4 tmpvar_8; + tmpvar_8.zw = vec2(0.0, 0.0); + tmpvar_8.xy = (coord_7 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_9; - tmpvar_9.zw = vec2(0.0, 0.0); - tmpvar_9.xy = (coord_8 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_10; - tmpvar_10 = textureLod (_DynLampInfo, tmpvar_9.xy, 0.0); - tmpvar_7 = tmpvar_10; + tmpvar_10 = textureLod (_DynLampInfo, tmpvar_8.xy, 0.0); + tmpvar_9 = tmpvar_10; highp vec2 tmpvar_11; tmpvar_11.y = 2.0; tmpvar_11.x = float(tmpvar_5.x); - mediump vec4 tmpvar_12; - mediump vec2 coord_13; - coord_13 = tmpvar_11; + mediump vec2 coord_12; + coord_12 = tmpvar_11; + mediump vec4 tmpvar_13; + tmpvar_13.zw = vec2(0.0, 0.0); + tmpvar_13.xy = (coord_12 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_14; - tmpvar_14.zw = vec2(0.0, 0.0); - tmpvar_14.xy = (coord_13 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_15; - tmpvar_15 = textureLod (_DynLampInfo, tmpvar_14.xy, 0.0); - tmpvar_12 = tmpvar_15; + tmpvar_15 = textureLod (_DynLampInfo, tmpvar_13.xy, 0.0); + tmpvar_14 = tmpvar_15; highp vec2 tmpvar_16; tmpvar_16.y = 1.0; tmpvar_16.x = float(tmpvar_5.y); - mediump vec4 tmpvar_17; - mediump vec2 coord_18; - coord_18 = tmpvar_16; + mediump vec2 coord_17; + coord_17 = tmpvar_16; + mediump vec4 tmpvar_18; + tmpvar_18.zw = vec2(0.0, 0.0); + tmpvar_18.xy = (coord_17 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_19; - tmpvar_19.zw = vec2(0.0, 0.0); - tmpvar_19.xy = (coord_18 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_20; - tmpvar_20 = textureLod (_DynLampInfo, tmpvar_19.xy, 0.0); - tmpvar_17 = tmpvar_20; + tmpvar_20 = textureLod (_DynLampInfo, tmpvar_18.xy, 0.0); + tmpvar_19 = tmpvar_20; highp vec2 tmpvar_21; tmpvar_21.y = 2.0; tmpvar_21.x = float(tmpvar_5.y); - mediump vec4 tmpvar_22; - mediump vec2 coord_23; - coord_23 = tmpvar_21; + mediump vec2 coord_22; + coord_22 = tmpvar_21; + mediump vec4 tmpvar_23; + tmpvar_23.zw = vec2(0.0, 0.0); + tmpvar_23.xy = (coord_22 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_24; - tmpvar_24.zw = vec2(0.0, 0.0); - tmpvar_24.xy = (coord_23 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_25; - tmpvar_25 = textureLod (_DynLampInfo, tmpvar_24.xy, 0.0); - tmpvar_22 = tmpvar_25; + tmpvar_25 = textureLod (_DynLampInfo, tmpvar_23.xy, 0.0); + tmpvar_24 = tmpvar_25; highp vec2 tmpvar_26; tmpvar_26.y = 1.0; tmpvar_26.x = float(tmpvar_5.z); - mediump vec4 tmpvar_27; - mediump vec2 coord_28; - coord_28 = tmpvar_26; + mediump vec2 coord_27; + coord_27 = tmpvar_26; + mediump vec4 tmpvar_28; + tmpvar_28.zw = vec2(0.0, 0.0); + tmpvar_28.xy = (coord_27 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_29; - tmpvar_29.zw = vec2(0.0, 0.0); - tmpvar_29.xy = (coord_28 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_30; - tmpvar_30 = textureLod (_DynLampInfo, tmpvar_29.xy, 0.0); - tmpvar_27 = tmpvar_30; + tmpvar_30 = textureLod (_DynLampInfo, tmpvar_28.xy, 0.0); + tmpvar_29 = tmpvar_30; highp vec2 tmpvar_31; tmpvar_31.y = 2.0; tmpvar_31.x = float(tmpvar_5.z); - mediump vec4 tmpvar_32; - mediump vec2 coord_33; - coord_33 = tmpvar_31; + mediump vec2 coord_32; + coord_32 = tmpvar_31; + mediump vec4 tmpvar_33; + tmpvar_33.zw = vec2(0.0, 0.0); + tmpvar_33.xy = (coord_32 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_34; - tmpvar_34.zw = vec2(0.0, 0.0); - tmpvar_34.xy = (coord_33 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_35; - tmpvar_35 = textureLod (_DynLampInfo, tmpvar_34.xy, 0.0); - tmpvar_32 = tmpvar_35; + tmpvar_35 = textureLod (_DynLampInfo, tmpvar_33.xy, 0.0); + tmpvar_34 = tmpvar_35; highp vec2 tmpvar_36; tmpvar_36.y = 1.0; tmpvar_36.x = float(tmpvar_5.w); - mediump vec4 tmpvar_37; - mediump vec2 coord_38; - coord_38 = tmpvar_36; + mediump vec2 coord_37; + coord_37 = tmpvar_36; + mediump vec4 tmpvar_38; + tmpvar_38.zw = vec2(0.0, 0.0); + tmpvar_38.xy = (coord_37 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_39; - tmpvar_39.zw = vec2(0.0, 0.0); - tmpvar_39.xy = (coord_38 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_40; - tmpvar_40 = textureLod (_DynLampInfo, tmpvar_39.xy, 0.0); - tmpvar_37 = tmpvar_40; + tmpvar_40 = textureLod (_DynLampInfo, tmpvar_38.xy, 0.0); + tmpvar_39 = tmpvar_40; highp vec2 tmpvar_41; tmpvar_41.y = 2.0; tmpvar_41.x = float(tmpvar_5.w); - mediump vec4 tmpvar_42; - mediump vec2 coord_43; - coord_43 = tmpvar_41; + mediump vec2 coord_42; + coord_42 = tmpvar_41; + mediump vec4 tmpvar_43; + tmpvar_43.zw = vec2(0.0, 0.0); + tmpvar_43.xy = (coord_42 / _DynLampInfo_bufferSize); mediump vec4 tmpvar_44; - tmpvar_44.zw = vec2(0.0, 0.0); - tmpvar_44.xy = (coord_43 / _DynLampInfo_bufferSize); lowp vec4 tmpvar_45; - tmpvar_45 = textureLod (_DynLampInfo, tmpvar_44.xy, 0.0); - tmpvar_42 = tmpvar_45; + tmpvar_45 = textureLod (_DynLampInfo, tmpvar_43.xy, 0.0); + tmpvar_44 = tmpvar_45; mediump vec3 hybridCol_46; mediump vec4 atten_47; highp vec3 tmpvar_48; - tmpvar_48 = (tmpvar_7.xyz - tmpvar_2); + tmpvar_48 = (tmpvar_9.xyz - tmpvar_2); highp float tmpvar_49; tmpvar_49 = dot (tmpvar_48, tmpvar_48); mediump vec4 tmpvar_50; tmpvar_50.yzw = atten_47.yzw; - tmpvar_50.x = (tmpvar_49 * tmpvar_7.w); + tmpvar_50.x = (tmpvar_49 * tmpvar_9.w); highp vec3 tmpvar_51; - tmpvar_51 = (tmpvar_17.xyz - tmpvar_2); + tmpvar_51 = (tmpvar_19.xyz - tmpvar_2); highp float tmpvar_52; tmpvar_52 = dot (tmpvar_51, tmpvar_51); mediump vec4 tmpvar_53; tmpvar_53.xzw = tmpvar_50.xzw; - tmpvar_53.y = (tmpvar_52 * tmpvar_17.w); + tmpvar_53.y = (tmpvar_52 * tmpvar_19.w); highp vec3 tmpvar_54; - tmpvar_54 = (tmpvar_27.xyz - tmpvar_2); + tmpvar_54 = (tmpvar_29.xyz - tmpvar_2); highp float tmpvar_55; tmpvar_55 = dot (tmpvar_54, tmpvar_54); mediump vec4 tmpvar_56; tmpvar_56.xyw = tmpvar_53.xyw; - tmpvar_56.z = (tmpvar_55 * tmpvar_27.w); + tmpvar_56.z = (tmpvar_55 * tmpvar_29.w); highp vec3 tmpvar_57; - tmpvar_57 = (tmpvar_37.xyz - tmpvar_2); + tmpvar_57 = (tmpvar_39.xyz - tmpvar_2); highp float tmpvar_58; tmpvar_58 = dot (tmpvar_57, tmpvar_57); mediump vec4 tmpvar_59; tmpvar_59.xyz = tmpvar_56.xyz; - tmpvar_59.w = (tmpvar_58 * tmpvar_37.w); + tmpvar_59.w = (tmpvar_58 * tmpvar_39.w); atten_47 = tmpvar_59; - hybridCol_46 = (hybridCol_4 + (tmpvar_12.xyz * tmpvar_50.x)); - hybridCol_46 = (hybridCol_46 + (tmpvar_22.xyz * tmpvar_53.y)); - hybridCol_46 = (hybridCol_46 + (tmpvar_32.xyz * tmpvar_56.z)); - hybridCol_46 = (hybridCol_46 + (tmpvar_42.xyz * tmpvar_59.w)); + hybridCol_46 = (hybridCol_4 + (tmpvar_14.xyz * tmpvar_50.x)); + hybridCol_46 = (hybridCol_46 + (tmpvar_24.xyz * tmpvar_53.y)); + hybridCol_46 = (hybridCol_46 + (tmpvar_34.xyz * tmpvar_56.z)); + hybridCol_46 = (hybridCol_46 + (tmpvar_44.xyz * tmpvar_59.w)); tmpvar_3 = hybridCol_46; tmpvar_1 = tmpvar_3; gl_Position = (glstate_matrix_mvp * _glesVertex); diff --git a/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES3Metal.txt b/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES3Metal.txt index a8e3d7ef5..a56f7df07 100644 --- a/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES3Metal.txt +++ b/3rdparty/glsl-optimizer/tests/vertex/z-NichsHybridLightVectorInsertBug-outES3Metal.txt @@ -27,134 +27,134 @@ vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], float2 tmpvar_6; tmpvar_6.y = 1.0; tmpvar_6.x = float(tmpvar_5.x); - half4 tmpvar_7; - half2 coord_8; - coord_8 = half2(tmpvar_6); + half2 coord_7; + coord_7 = half2(tmpvar_6); + half4 tmpvar_8; + tmpvar_8.zw = half2(float2(0.0, 0.0)); + tmpvar_8.xy = (coord_7 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_9; - tmpvar_9.zw = half2(float2(0.0, 0.0)); - tmpvar_9.xy = (coord_8 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_10; - tmpvar_10 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_9.xy), level(0.0)); - tmpvar_7 = tmpvar_10; + tmpvar_10 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_8.xy), level(0.0)); + tmpvar_9 = tmpvar_10; float2 tmpvar_11; tmpvar_11.y = 2.0; tmpvar_11.x = float(tmpvar_5.x); - half4 tmpvar_12; - half2 coord_13; - coord_13 = half2(tmpvar_11); + half2 coord_12; + coord_12 = half2(tmpvar_11); + half4 tmpvar_13; + tmpvar_13.zw = half2(float2(0.0, 0.0)); + tmpvar_13.xy = (coord_12 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_14; - tmpvar_14.zw = half2(float2(0.0, 0.0)); - tmpvar_14.xy = (coord_13 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_15; - tmpvar_15 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_14.xy), level(0.0)); - tmpvar_12 = tmpvar_15; + tmpvar_15 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_13.xy), level(0.0)); + tmpvar_14 = tmpvar_15; float2 tmpvar_16; tmpvar_16.y = 1.0; tmpvar_16.x = float(tmpvar_5.y); - half4 tmpvar_17; - half2 coord_18; - coord_18 = half2(tmpvar_16); + half2 coord_17; + coord_17 = half2(tmpvar_16); + half4 tmpvar_18; + tmpvar_18.zw = half2(float2(0.0, 0.0)); + tmpvar_18.xy = (coord_17 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_19; - tmpvar_19.zw = half2(float2(0.0, 0.0)); - tmpvar_19.xy = (coord_18 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_20; - tmpvar_20 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_19.xy), level(0.0)); - tmpvar_17 = tmpvar_20; + tmpvar_20 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_18.xy), level(0.0)); + tmpvar_19 = tmpvar_20; float2 tmpvar_21; tmpvar_21.y = 2.0; tmpvar_21.x = float(tmpvar_5.y); - half4 tmpvar_22; - half2 coord_23; - coord_23 = half2(tmpvar_21); + half2 coord_22; + coord_22 = half2(tmpvar_21); + half4 tmpvar_23; + tmpvar_23.zw = half2(float2(0.0, 0.0)); + tmpvar_23.xy = (coord_22 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_24; - tmpvar_24.zw = half2(float2(0.0, 0.0)); - tmpvar_24.xy = (coord_23 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_25; - tmpvar_25 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_24.xy), level(0.0)); - tmpvar_22 = tmpvar_25; + tmpvar_25 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_23.xy), level(0.0)); + tmpvar_24 = tmpvar_25; float2 tmpvar_26; tmpvar_26.y = 1.0; tmpvar_26.x = float(tmpvar_5.z); - half4 tmpvar_27; - half2 coord_28; - coord_28 = half2(tmpvar_26); + half2 coord_27; + coord_27 = half2(tmpvar_26); + half4 tmpvar_28; + tmpvar_28.zw = half2(float2(0.0, 0.0)); + tmpvar_28.xy = (coord_27 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_29; - tmpvar_29.zw = half2(float2(0.0, 0.0)); - tmpvar_29.xy = (coord_28 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_30; - tmpvar_30 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_29.xy), level(0.0)); - tmpvar_27 = tmpvar_30; + tmpvar_30 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_28.xy), level(0.0)); + tmpvar_29 = tmpvar_30; float2 tmpvar_31; tmpvar_31.y = 2.0; tmpvar_31.x = float(tmpvar_5.z); - half4 tmpvar_32; - half2 coord_33; - coord_33 = half2(tmpvar_31); + half2 coord_32; + coord_32 = half2(tmpvar_31); + half4 tmpvar_33; + tmpvar_33.zw = half2(float2(0.0, 0.0)); + tmpvar_33.xy = (coord_32 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_34; - tmpvar_34.zw = half2(float2(0.0, 0.0)); - tmpvar_34.xy = (coord_33 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_35; - tmpvar_35 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_34.xy), level(0.0)); - tmpvar_32 = tmpvar_35; + tmpvar_35 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_33.xy), level(0.0)); + tmpvar_34 = tmpvar_35; float2 tmpvar_36; tmpvar_36.y = 1.0; tmpvar_36.x = float(tmpvar_5.w); - half4 tmpvar_37; - half2 coord_38; - coord_38 = half2(tmpvar_36); + half2 coord_37; + coord_37 = half2(tmpvar_36); + half4 tmpvar_38; + tmpvar_38.zw = half2(float2(0.0, 0.0)); + tmpvar_38.xy = (coord_37 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_39; - tmpvar_39.zw = half2(float2(0.0, 0.0)); - tmpvar_39.xy = (coord_38 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_40; - tmpvar_40 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_39.xy), level(0.0)); - tmpvar_37 = tmpvar_40; + tmpvar_40 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_38.xy), level(0.0)); + tmpvar_39 = tmpvar_40; float2 tmpvar_41; tmpvar_41.y = 2.0; tmpvar_41.x = float(tmpvar_5.w); - half4 tmpvar_42; - half2 coord_43; - coord_43 = half2(tmpvar_41); + half2 coord_42; + coord_42 = half2(tmpvar_41); + half4 tmpvar_43; + tmpvar_43.zw = half2(float2(0.0, 0.0)); + tmpvar_43.xy = (coord_42 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_44; - tmpvar_44.zw = half2(float2(0.0, 0.0)); - tmpvar_44.xy = (coord_43 / _mtl_u._DynLampInfo_bufferSize); half4 tmpvar_45; - tmpvar_45 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_44.xy), level(0.0)); - tmpvar_42 = tmpvar_45; + tmpvar_45 = _DynLampInfo.sample(_mtlsmp__DynLampInfo, (float2)(tmpvar_43.xy), level(0.0)); + tmpvar_44 = tmpvar_45; half3 hybridCol_46; half4 atten_47; float3 tmpvar_48; - tmpvar_48 = ((float3)tmpvar_7.xyz - tmpvar_2); + tmpvar_48 = ((float3)tmpvar_9.xyz - tmpvar_2); float tmpvar_49; tmpvar_49 = dot (tmpvar_48, tmpvar_48); half4 tmpvar_50; tmpvar_50.yzw = atten_47.yzw; - tmpvar_50.x = half((tmpvar_49 * (float)tmpvar_7.w)); + tmpvar_50.x = half((tmpvar_49 * (float)tmpvar_9.w)); float3 tmpvar_51; - tmpvar_51 = ((float3)tmpvar_17.xyz - tmpvar_2); + tmpvar_51 = ((float3)tmpvar_19.xyz - tmpvar_2); float tmpvar_52; tmpvar_52 = dot (tmpvar_51, tmpvar_51); half4 tmpvar_53; tmpvar_53.xzw = tmpvar_50.xzw; - tmpvar_53.y = half((tmpvar_52 * (float)tmpvar_17.w)); + tmpvar_53.y = half((tmpvar_52 * (float)tmpvar_19.w)); float3 tmpvar_54; - tmpvar_54 = ((float3)tmpvar_27.xyz - tmpvar_2); + tmpvar_54 = ((float3)tmpvar_29.xyz - tmpvar_2); float tmpvar_55; tmpvar_55 = dot (tmpvar_54, tmpvar_54); half4 tmpvar_56; tmpvar_56.xyw = tmpvar_53.xyw; - tmpvar_56.z = half((tmpvar_55 * (float)tmpvar_27.w)); + tmpvar_56.z = half((tmpvar_55 * (float)tmpvar_29.w)); float3 tmpvar_57; - tmpvar_57 = ((float3)tmpvar_37.xyz - tmpvar_2); + tmpvar_57 = ((float3)tmpvar_39.xyz - tmpvar_2); float tmpvar_58; tmpvar_58 = dot (tmpvar_57, tmpvar_57); half4 tmpvar_59; tmpvar_59.xyz = tmpvar_56.xyz; - tmpvar_59.w = half((tmpvar_58 * (float)tmpvar_37.w)); + tmpvar_59.w = half((tmpvar_58 * (float)tmpvar_39.w)); atten_47 = tmpvar_59; - hybridCol_46 = (hybridCol_4 + (tmpvar_12.xyz * tmpvar_50.x)); - hybridCol_46 = (hybridCol_46 + (tmpvar_22.xyz * tmpvar_53.y)); - hybridCol_46 = (hybridCol_46 + (tmpvar_32.xyz * tmpvar_56.z)); - hybridCol_46 = (hybridCol_46 + (tmpvar_42.xyz * tmpvar_59.w)); + hybridCol_46 = (hybridCol_4 + (tmpvar_14.xyz * tmpvar_50.x)); + hybridCol_46 = (hybridCol_46 + (tmpvar_24.xyz * tmpvar_53.y)); + hybridCol_46 = (hybridCol_46 + (tmpvar_34.xyz * tmpvar_56.z)); + hybridCol_46 = (hybridCol_46 + (tmpvar_44.xyz * tmpvar_59.w)); tmpvar_3 = float3(hybridCol_46); tmpvar_1 = half3(tmpvar_3); _mtl_o.gl_Position = (_mtl_u.glstate_matrix_mvp * _mtl_i._glesVertex);