diff options
author | Timothy Arceri <[email protected]> | 2016-02-29 11:46:37 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-03-18 10:26:34 +1100 |
commit | d6b9202873f015174592e32f3325d00c57153d2d (patch) | |
tree | a494e71d7182d4311d0b0f9a324077b961f46d66 /src/compiler/glsl/lower_packed_varyings.cpp | |
parent | c0ae6eeb3b0ea42344cc91cd0caa7bd0296172d4 (diff) |
glsl: disable varying packing when its not safe
In GL 4.4+ there is no guarantee that interpolation qualifiers will
match between stages so we cannot safely pack varyings using the
current packing pass in Mesa.
We also disable packing on outerward facing interfaces for SSO
because in ES we need to retain the unpacked varying information
for draw time validation. For desktop GL we could allow packing for
SSO in versions < 4.4 but its just safer not to do so.
We do however enable packing on individual arrays, structs, and
matrices as these are required by the transform feedback code and it
is still safe to do so.
Finally we also enable packing when a varying is only used for
transform feedback and its not a SSO.
This fixes all remaining rendering issues with the dEQP SSO tests,
the only issues remaining with thoses tests are to do with validation.
Note: There is still one remaining SSO bug that this patch doesn't fix.
Their is a chance that VS -> TCS will have mismatching interfaces
because we pack VS output in case its used by transform feedback but
don't pack TCS input for performance reasons. This patch will make the
situation better but doesn't fix it.
V4: fix out of order function params after rebase, make sure packing
still disabled in tess stages. Update comments as to why we disable
packing on SSO.
V3: ES 3.1 *does* require interpolation to match so don't disable
packing there. Rebased on master rather than on enhanced layouts
component packing series.
V2: Make is_varying_packing_safe() a function in the varying_matches
class, fix spelling (Matt) and make sure to remove the outer array
when dealing with Geom and Tess shaders where appropriate.
Lastly fix piglit regression in new piglit test and document the
undefined behaviour it depends on:
arb_separate_shader_objects/execution/vs-gs-linking.shader_test
Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Diffstat (limited to 'src/compiler/glsl/lower_packed_varyings.cpp')
-rw-r--r-- | src/compiler/glsl/lower_packed_varyings.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/compiler/glsl/lower_packed_varyings.cpp b/src/compiler/glsl/lower_packed_varyings.cpp index d91aa22c2a4..825cc9ee8cd 100644 --- a/src/compiler/glsl/lower_packed_varyings.cpp +++ b/src/compiler/glsl/lower_packed_varyings.cpp @@ -169,7 +169,8 @@ public: unsigned gs_input_vertices, exec_list *out_instructions, exec_list *out_variables, - bool disable_varying_packing); + bool disable_varying_packing, + bool xfb_enabled); void run(struct gl_shader *shader); @@ -234,6 +235,7 @@ private: exec_list *out_variables; bool disable_varying_packing; + bool xfb_enabled; }; } /* anonymous namespace */ @@ -241,7 +243,8 @@ private: lower_packed_varyings_visitor::lower_packed_varyings_visitor( void *mem_ctx, unsigned locations_used, ir_variable_mode mode, unsigned gs_input_vertices, exec_list *out_instructions, - exec_list *out_variables, bool disable_varying_packing) + exec_list *out_variables, bool disable_varying_packing, + bool xfb_enabled) : mem_ctx(mem_ctx), locations_used(locations_used), packed_varyings((ir_variable **) @@ -251,7 +254,8 @@ lower_packed_varyings_visitor::lower_packed_varyings_visitor( gs_input_vertices(gs_input_vertices), out_instructions(out_instructions), out_variables(out_variables), - disable_varying_packing(disable_varying_packing) + disable_varying_packing(disable_varying_packing), + xfb_enabled(xfb_enabled) { } @@ -660,10 +664,18 @@ lower_packed_varyings_visitor::needs_lowering(ir_variable *var) if (var->data.explicit_location) return false; - if (disable_varying_packing) + /* Override disable_varying_packing if the var is only used by transform + * feedback. Also override it if transform feedback is enabled and the + * variable is an array, struct or matrix as the elements of these types + * will always has the same interpolation and therefore asre safe to pack. + */ + const glsl_type *type = var->type; + if (disable_varying_packing && !var->data.is_xfb_only && + !((type->is_array() || type->is_record() || type->is_matrix()) && + xfb_enabled)) return false; - const glsl_type *type = var->type->without_array(); + type = type->without_array(); if (type->vector_elements == 4 && !type->is_double()) return false; return true; @@ -716,7 +728,8 @@ lower_packed_varyings_gs_splicer::visit_leave(ir_emit_vertex *ev) void lower_packed_varyings(void *mem_ctx, unsigned locations_used, ir_variable_mode mode, unsigned gs_input_vertices, - gl_shader *shader, bool disable_varying_packing) + gl_shader *shader, bool disable_varying_packing, + bool xfb_enabled) { exec_list *instructions = shader->ir; ir_function *main_func = shader->symbols->get_function("main"); @@ -728,7 +741,8 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used, gs_input_vertices, &new_instructions, &new_variables, - disable_varying_packing); + disable_varying_packing, + xfb_enabled); visitor.run(shader); if (mode == ir_var_shader_out) { if (shader->Stage == MESA_SHADER_GEOMETRY) { |