[Mesa-dev] [PATCH 16/53] st/nine: Rework of boolean constants

Ilia Mirkin imirkin at alum.mit.edu
Wed Jan 7 09:23:53 PST 2015


On Wed, Jan 7, 2015 at 11:36 AM, Axel Davy <axel.davy at ens.fr> wrote:
> Convert them to shader booleans at earlier stage

Why? What's wrong with the conversion as it is now?

>
> Signed-off-by: Axel Davy <axel.davy at ens.fr>
>
> Cc: "10.4" <mesa-stable at lists.freedesktop.org>
> ---
>  src/gallium/state_trackers/nine/device9.c    | 35 +++++++++++++---------------
>  src/gallium/state_trackers/nine/device9.h    |  6 ++---
>  src/gallium/state_trackers/nine/nine_state.c | 13 +++--------
>  3 files changed, 22 insertions(+), 32 deletions(-)
>
> @@ -3311,14 +3308,14 @@ NineDevice9_GetPixelShaderConstantB( struct NineDevice9 *This,
>                                       UINT BoolCount )
>  {
>      const struct nine_state *state = &This->state;
> +    int i;
>
>      user_assert(StartRegister              < NINE_MAX_CONST_B, D3DERR_INVALIDCALL);
>      user_assert(StartRegister + BoolCount <= NINE_MAX_CONST_B, D3DERR_INVALIDCALL);
>      user_assert(pConstantData, D3DERR_INVALIDCALL);
>
> -    memcpy(pConstantData,
> -           &state->ps_const_b[StartRegister],
> -           BoolCount * sizeof(state->ps_const_b[0]));
> +    for (i = 0; i < BoolCount; i++)
> +        pConstantData[i] = state->ps_const_b[StartRegister + i] != 0 ? TRUE : FALSE;

The !=0 doesn't really add anything does it?

>
>      return D3D_OK;
>  }
> diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h
> index 3649e1b..cf2138a 100644
> --- a/src/gallium/state_trackers/nine/device9.h
> +++ b/src/gallium/state_trackers/nine/device9.h
> @@ -78,9 +78,7 @@ struct NineDevice9
>      struct pipe_resource *constbuf_vs;
>      struct pipe_resource *constbuf_ps;
>      uint16_t max_vs_const_f;
> -    uint16_t max_ps_const_f;
> -    uint32_t vs_bool_true;
> -    uint32_t ps_bool_true;
> +    uint16_t max_ps_const_f;;

Extra ;

>
>      struct gen_mipmap_state *gen_mipmap;
>
> @@ -111,6 +109,8 @@ struct NineDevice9
>          boolean user_vbufs;
>          boolean user_ibufs;
>          boolean window_space_position_support;
> +        boolean vs_integer;
> +        boolean ps_integer;
>      } driver_caps;
>
>      struct u_upload_mgr *upload;
> diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
> index e4e6788..00da62b 100644
> --- a/src/gallium/state_trackers/nine/nine_state.c
> +++ b/src/gallium/state_trackers/nine/nine_state.c
> @@ -347,7 +347,6 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
>      const int *const_i;
>      const BOOL *const_b;
>      uint32_t data_b[NINE_MAX_CONST_B];
> -    uint32_t b_true;
>      uint16_t dirty_i;
>      uint16_t dirty_b;
>      const unsigned usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE;
> @@ -381,7 +380,6 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
>          dirty_b = device->state.changed.vs_const_b;
>          device->state.changed.vs_const_b = 0;
>          const_b = device->state.vs_const_b;
> -        b_true = device->vs_bool_true;
>
>          lconstf = &device->state.vs->lconstf;
>          device->state.ff.clobber.vs_const = TRUE;
> @@ -406,7 +404,6 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
>          dirty_b = device->state.changed.ps_const_b;
>          device->state.changed.ps_const_b = 0;
>          const_b = device->state.ps_const_b;
> -        b_true = device->ps_bool_true;
>
>          lconstf = &device->state.ps->lconstf;
>          device->state.ff.clobber.ps_const = TRUE;
> @@ -421,7 +418,7 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
>         x = buf->width0 - (NINE_MAX_CONST_B - i) * 4;
>         c -= i;
>         for (n = 0; n < c; ++n, ++i)
> -          data_b[n] = const_b[i] ? b_true : 0;
> +          data_b[n] = const_b[i];

memcpy?

>         box.x = x;
>         box.width = n * 4;
>         DBG("upload ConstantB [%u .. %u]\n", x, x + n - 1);
> @@ -491,9 +488,7 @@ update_vs_constants_userbuf(struct NineDevice9 *device)
>      if (state->changed.vs_const_b) {
>          int *idst = (int *)&state->vs_const_f[4 * device->max_vs_const_f];
>          uint32_t *bdst = (uint32_t *)&idst[4 * NINE_MAX_CONST_I];
> -        int i;
> -        for (i = 0; i < NINE_MAX_CONST_B; ++i)
> -            bdst[i] = state->vs_const_b[i] ? device->vs_bool_true : 0;
> +        memcpy(bdst, state->vs_const_b, sizeof(state->vs_const_b));
>          state->changed.vs_const_b = 0;
>      }
>
> @@ -557,9 +552,7 @@ update_ps_constants_userbuf(struct NineDevice9 *device)
>      if (state->changed.ps_const_b) {
>          int *idst = (int *)&state->ps_const_f[4 * device->max_ps_const_f];
>          uint32_t *bdst = (uint32_t *)&idst[4 * NINE_MAX_CONST_I];
> -        int i;
> -        for (i = 0; i < NINE_MAX_CONST_B; ++i)
> -            bdst[i] = state->ps_const_b[i] ? device->ps_bool_true : 0;
> +        memcpy(bdst, state->ps_const_b, sizeof(state->ps_const_b));
>          state->changed.ps_const_b = 0;
>      }
>
> --
> 2.1.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list