X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmesa%2Fstate_tracker%2Fst_program.c;h=d0e16cf16a858d3604af5d7cbf7a54243b93a59b;hb=6aea39641a6c32f780c40e3344096d3e0eccb590;hp=199825b55d5d85917c96ea8c9569ce85be7479bb;hpb=b85775900d084e3d27f269c3bd336b9aa356b98d;p=mesa.git diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 199825b55d5..d0e16cf16a8 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2007 VMware, Inc. * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,11 +10,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -22,7 +22,7 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ /* * Authors: @@ -32,7 +32,7 @@ #include "main/errors.h" -#include "util/imports.h" + #include "main/hash.h" #include "main/mtypes.h" #include "program/prog_parameter.h" @@ -70,6 +70,8 @@ #include "cso_cache/cso_context.h" +static void +destroy_program_variants(struct st_context *st, struct gl_program *target); static void set_affected_state_flags(uint64_t *states, @@ -345,7 +347,7 @@ st_release_program(struct st_context *st, struct st_program **p) if (!*p) return; - st_release_variants(st, *p); + destroy_program_variants(st, &((*p)->Base)); st_reference_prog(st, p, NULL); } @@ -714,24 +716,30 @@ st_create_vp_variant(struct st_context *st, PIPE_CAP_NIR_COMPACT_ARRAYS); bool use_eye = st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] != NULL; - gl_state_index16 clipplane_state[MAX_CLIP_PLANES][STATE_LENGTH]; - for (int i = 0; i < MAX_CLIP_PLANES; ++i) { - if (use_eye) { - clipplane_state[i][0] = STATE_CLIPPLANE; - clipplane_state[i][1] = i; - } else { - clipplane_state[i][0] = STATE_INTERNAL; - clipplane_state[i][1] = STATE_CLIP_INTERNAL; - clipplane_state[i][2] = i; + struct nir_shader *nir = state.ir.nir; + + if (nir->info.outputs_written & VARYING_BIT_CLIP_DIST0) + NIR_PASS_V(state.ir.nir, nir_lower_clip_disable, key->lower_ucp); + else { + gl_state_index16 clipplane_state[MAX_CLIP_PLANES][STATE_LENGTH]; + for (int i = 0; i < MAX_CLIP_PLANES; ++i) { + if (use_eye) { + clipplane_state[i][0] = STATE_CLIPPLANE; + clipplane_state[i][1] = i; + } else { + clipplane_state[i][0] = STATE_INTERNAL; + clipplane_state[i][1] = STATE_CLIP_INTERNAL; + clipplane_state[i][2] = i; + } + _mesa_add_state_reference(params, clipplane_state[i]); } - _mesa_add_state_reference(params, clipplane_state[i]); - } - NIR_PASS_V(state.ir.nir, nir_lower_clip_vs, key->lower_ucp, - true, can_compact, clipplane_state); - NIR_PASS_V(state.ir.nir, nir_lower_io_to_temporaries, - nir_shader_get_entrypoint(state.ir.nir), true, false); - NIR_PASS_V(state.ir.nir, nir_lower_global_vars_to_local); + NIR_PASS_V(state.ir.nir, nir_lower_clip_vs, key->lower_ucp, + true, can_compact, clipplane_state); + NIR_PASS_V(state.ir.nir, nir_lower_io_to_temporaries, + nir_shader_get_entrypoint(state.ir.nir), true, false); + NIR_PASS_V(state.ir.nir, nir_lower_global_vars_to_local); + } finalize = true; }