[Mesa-stable] [Mesa-dev] [PATCH 2/2] st/nine: Fix vertex declarations for non-standard (usage/index)

Ilia Mirkin imirkin at alum.mit.edu
Mon Dec 1 09:57:55 PST 2014


On Thu, Nov 27, 2014 at 5:13 AM, Axel Davy <axel.davy at ens.fr> wrote:
> Nine code to match vertex declaration to vs inputs was limiting
> the number of possible combinations.
>
> Some sm3 games have issues with that, because arbitrary (usage/index)
> can be used.
>
> This patch does the following changes to fix the problem:
> . Change the numbers given to (usage/index) combinations to uint16
> . Do not put limits on the indices when it doesn't make sense
> . change the conversion rule (usage/index) -> number to fit all combinations
> . Instead of having a table usage_map mapping a (usage/index) number to
> an input index, usage_map maps input indices to their (usage/index)
>
> Cc: "10.4" <mesa-stable at lists.freedesktop.org>
> Tested-by: Yaroslav Andrusyak <pontostroy at gmail.com>
> Signed-off-by: Axel Davy <axel.davy at ens.fr>
> ---
>  src/gallium/state_trackers/nine/nine_defines.h     | 40 ++++++-----
>  src/gallium/state_trackers/nine/nine_ff.c          | 49 +++++++------
>  src/gallium/state_trackers/nine/nine_shader.h      |  2 +-
>  src/gallium/state_trackers/nine/nine_state.c       | 16 +++--
>  .../state_trackers/nine/vertexdeclaration9.c       | 84 +++++++---------------
>  .../state_trackers/nine/vertexdeclaration9.h       |  4 +-
>  src/gallium/state_trackers/nine/vertexshader9.h    |  2 +-
>  7 files changed, 89 insertions(+), 108 deletions(-)
>
> diff --git a/src/gallium/state_trackers/nine/nine_defines.h b/src/gallium/state_trackers/nine/nine_defines.h
> index aa3b257..06529da 100644
> --- a/src/gallium/state_trackers/nine/nine_defines.h
> +++ b/src/gallium/state_trackers/nine/nine_defines.h
> @@ -30,25 +30,27 @@
>  #define NINE_RESOURCE_FLAG_DUMMY    (PIPE_RESOURCE_FLAG_ST_PRIV << 2)
>
>  /* vertexdeclaration9.c */
> -unsigned nine_d3d9_to_nine_declusage(unsigned usage, unsigned index);
> -
> -#define NINE_DECLUSAGE_POSITION(i)     ( 0 + (i))
> -#define NINE_DECLUSAGE_BLENDWEIGHT(i)  ( 5 + (i))
> -#define NINE_DECLUSAGE_BLENDINDICES(i) ( 9 + (i))
> -#define NINE_DECLUSAGE_NORMAL(i)       (13 + (i))
> -#define NINE_DECLUSAGE_PSIZE            15
> -#define NINE_DECLUSAGE_TEXCOORD(i)     (16 + (i))
> -#define NINE_DECLUSAGE_TANGENT(i)      (32 + (i))
> -#define NINE_DECLUSAGE_BINORMAL(i)     (34 + (i))
> -#define NINE_DECLUSAGE_TESSFACTOR       36
> -#define NINE_DECLUSAGE_POSITIONT        37
> -#define NINE_DECLUSAGE_COLOR(i)        (38 + (i))
> -#define NINE_DECLUSAGE_DEPTH            43
> -#define NINE_DECLUSAGE_FOG              44
> -#define NINE_DECLUSAGE_SAMPLE           45
> -#define NINE_DECLUSAGE_NONE             46
> -#define NINE_DECLUSAGE_LAST             NINE_DECLUSAGE_NONE
> -#define NINE_DECLUSAGE_COUNT           (NINE_DECLUSAGE_LAST + 1)
> +uint16_t nine_d3d9_to_nine_declusage(unsigned usage, unsigned index);
> +
> +#define NINE_DECLUSAGE_POSITION         0
> +#define NINE_DECLUSAGE_BLENDWEIGHT      1
> +#define NINE_DECLUSAGE_BLENDINDICES     2
> +#define NINE_DECLUSAGE_NORMAL           3
> +#define NINE_DECLUSAGE_TEXCOORD         4
> +#define NINE_DECLUSAGE_TANGENT          5
> +#define NINE_DECLUSAGE_BINORMAL         6
> +#define NINE_DECLUSAGE_COLOR            7
> +#define NINE_DECLUSAGE_POSITIONT        8
> +
> +#define NINE_DECLUSAGE_PSIZE            9
> +#define NINE_DECLUSAGE_TESSFACTOR       10
> +#define NINE_DECLUSAGE_DEPTH            11
> +#define NINE_DECLUSAGE_FOG              12
> +#define NINE_DECLUSAGE_SAMPLE           13
> +#define NINE_DECLUSAGE_NONE             14
> +#define NINE_DECLUSAGE_BASE             (NINE_DECLUSAGE_NONE + 1)

I'd call it NINE_DECLUSAGE_COUNT (as it was called before). BASE can
have many different meanings -- the numerical base (like base 2) as
you're using, or the start, or probably other things. Count is
unambiguous.

I won't pretend to having looked at this whole patch with a high level
of attention, but the concept seems fine in principle. Series is
Acked-by: Ilia Mirkin <imirkin at alum.mit.edu>


More information about the mesa-stable mailing list