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

Axel Davy axel.davy at ens.fr
Wed Jan 7 14:24:31 PST 2015


On 07/01/2015 18:23, Ilia Mirkin wrote :
> 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?
The conversion is fine for booleans, but not for integers.
I think it is cleaner to have both boolean and integers filled
right away as right format. The next patch fixes the conversion
for integers. It is possible if this patch doesn't fit for 10.4
to put only the next one, but with vs_integer and ps_integer definitions 
added.

>
>> 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?
yeah, it should be fine removing 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 ;

Thanks for the catch
>
>>       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?
yes memcpy would be better
>
>>          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