[Mesa-dev] [PATCH] draw: make sure key size is calculated consistently.
Jose Fonseca
jfonseca at vmware.com
Thu Feb 21 01:50:30 PST 2013
Looks perfect. Thanks Roland.
Jose
----- Original Message -----
> From: Roland Scheidegger <sroland at vmware.com>
>
> Some parts calculated key size by using shader information, others by using
> the pipe_vertex_element information. Since it is perfectly valid to have more
> vertex_elements set than the vertex shader is using those may not be the
> same,
> so we weren't copying over all vertex_element state - this caused the tgsi
> dump
> to assert (iterates over all vertex elements). More importantly in this
> situation it would also break vertex texturing completely (since the sampler
> state derived from the key is at a different position than expected).
> Fix thix by deriving key->nr_vertex_elements from the shader information
> instead of the pipe_vertex_element state (unlike dx10, we can't have "holes"
> in pipe_vertex_element state, so this should be safe).
> (Note that actual llvm shader generation does not use the pipe_vertex_element
> state from the key itself in any case (althogh I guess it could) but uses
> the one from draw.pt (which should be the same though contains all elements)
> instead.)
> ---
> src/gallium/auxiliary/draw/draw_llvm.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/auxiliary/draw/draw_llvm.c
> b/src/gallium/auxiliary/draw/draw_llvm.c
> index f3bbbbb..2467e5a 100644
> --- a/src/gallium/auxiliary/draw/draw_llvm.c
> +++ b/src/gallium/auxiliary/draw/draw_llvm.c
> @@ -420,8 +420,8 @@ draw_llvm_destroy(struct draw_llvm *llvm)
> */
> struct draw_llvm_variant *
> draw_llvm_create_variant(struct draw_llvm *llvm,
> - unsigned num_inputs,
> - const struct draw_llvm_variant_key *key)
> + unsigned num_inputs,
> + const struct draw_llvm_variant_key *key)
> {
> struct draw_llvm_variant *variant;
> struct llvm_vertex_shader *shader =
> @@ -429,8 +429,8 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
> LLVMTypeRef vertex_header;
>
> variant = MALLOC(sizeof *variant +
> - shader->variant_key_size -
> - sizeof variant->key);
> + shader->variant_key_size -
> + sizeof variant->key);
> if (variant == NULL)
> return NULL;
>
> @@ -1415,8 +1415,12 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm,
> char *store)
>
> /* Presumably all variants of the shader should have the same
> * number of vertex elements - ie the number of shader inputs.
> + * NOTE: we NEED to store the needed number of needed inputs
> + * here, not the number of provided elements to match keysize
> + * (and the offset of sampler state in the key).
> */
> - key->nr_vertex_elements = llvm->draw->pt.nr_vertex_elements;
> + key->nr_vertex_elements =
> llvm->draw->vs.vertex_shader->info.file_max[TGSI_FILE_INPUT] + 1;
> + assert(key->nr_vertex_elements <= llvm->draw->pt.nr_vertex_elements);
>
> /* will have to rig this up properly later */
> key->clip_xy = llvm->draw->clip_xy;
> --
> 1.7.9.5
>
More information about the mesa-dev
mailing list