diff options
author | Axel Davy <[email protected]> | 2016-10-04 19:45:40 +0200 |
---|---|---|
committer | Axel Davy <[email protected]> | 2016-10-10 23:43:49 +0200 |
commit | f8c8f4424405c4789a044470e64df810720358c8 (patch) | |
tree | 99abbff56842e37643fb3df1a44fbfa995d81b77 /src/gallium | |
parent | a83dce01284f220b1bf932774730e13fca6cdd20 (diff) |
st/nine: Rework vs int and bool constants buffer
This will help to support swvp constants.
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/state_trackers/nine/device9.c | 35 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.h | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/stateblock9.c | 18 |
4 files changed, 37 insertions, 24 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 591a021002a..dca75c53e6e 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -326,8 +326,11 @@ NineDevice9_ctor( struct NineDevice9 *This, This->state.ps_const_f = CALLOC(This->ps_const_size, 1); This->state.vs_lconstf_temp = CALLOC(This->vs_const_size,1); This->state.ps_lconstf_temp = CALLOC(This->ps_const_size,1); + This->state.vs_const_i = CALLOC(NINE_MAX_CONST_I * sizeof(int[4]), 1); + This->state.vs_const_b = CALLOC(NINE_MAX_CONST_B * sizeof(BOOL), 1); if (!This->state.vs_const_f || !This->state.ps_const_f || - !This->state.vs_lconstf_temp || !This->state.ps_lconstf_temp) + !This->state.vs_lconstf_temp || !This->state.ps_lconstf_temp || + !This->state.vs_const_i || !This->state.vs_const_b) return E_OUTOFMEMORY; if (strstr(pScreen->get_name(pScreen), "AMD") || @@ -459,6 +462,8 @@ NineDevice9_dtor( struct NineDevice9 *This ) FREE(This->state.ps_const_f); FREE(This->state.vs_lconstf_temp); FREE(This->state.ps_lconstf_temp); + FREE(This->state.vs_const_i); + FREE(This->state.vs_const_b); if (This->swapchains) { for (i = 0; i < This->nswapchains; ++i) @@ -3438,19 +3443,19 @@ NineDevice9_SetVertexShaderConstantI( struct NineDevice9 *This, if (This->driver_caps.vs_integer) { if (!This->is_recording) { - if (!memcmp(&state->vs_const_i[StartRegister][0], pConstantData, - Vector4iCount * sizeof(state->vs_const_i[0]))) + if (!memcmp(&state->vs_const_i[4 * StartRegister], pConstantData, + Vector4iCount * sizeof(int[4]))) return D3D_OK; } - memcpy(&state->vs_const_i[StartRegister][0], + memcpy(&state->vs_const_i[4 * StartRegister], pConstantData, - Vector4iCount * sizeof(state->vs_const_i[0])); + Vector4iCount * sizeof(int[4])); } else { for (i = 0; i < Vector4iCount; i++) { - state->vs_const_i[StartRegister+i][0] = fui((float)(pConstantData[4*i])); - state->vs_const_i[StartRegister+i][1] = fui((float)(pConstantData[4*i+1])); - state->vs_const_i[StartRegister+i][2] = fui((float)(pConstantData[4*i+2])); - state->vs_const_i[StartRegister+i][3] = fui((float)(pConstantData[4*i+3])); + state->vs_const_i[4 * (StartRegister + i)] = fui((float)(pConstantData[4 * i])); + state->vs_const_i[4 * (StartRegister + i) + 1] = fui((float)(pConstantData[4 * i + 1])); + state->vs_const_i[4 * (StartRegister + i) + 2] = fui((float)(pConstantData[4 * i + 2])); + state->vs_const_i[4 * (StartRegister + i) + 3] = fui((float)(pConstantData[4 * i + 3])); } } @@ -3477,14 +3482,14 @@ NineDevice9_GetVertexShaderConstantI( struct NineDevice9 *This, if (This->driver_caps.vs_integer) { memcpy(pConstantData, - &state->vs_const_i[StartRegister][0], - Vector4iCount * sizeof(state->vs_const_i[0])); + &state->vs_const_i[4 * StartRegister], + Vector4iCount * sizeof(int[4])); } else { for (i = 0; i < Vector4iCount; i++) { - pConstantData[4*i] = (int32_t) uif(state->vs_const_i[StartRegister+i][0]); - pConstantData[4*i+1] = (int32_t) uif(state->vs_const_i[StartRegister+i][1]); - pConstantData[4*i+2] = (int32_t) uif(state->vs_const_i[StartRegister+i][2]); - pConstantData[4*i+3] = (int32_t) uif(state->vs_const_i[StartRegister+i][3]); + pConstantData[4 * i] = (int32_t) uif(state->vs_const_i[4 * (StartRegister + i)]); + pConstantData[4 * i + 1] = (int32_t) uif(state->vs_const_i[4 * (StartRegister + i) + 1]); + pConstantData[4 * i + 2] = (int32_t) uif(state->vs_const_i[4 * (StartRegister + i) + 2]); + pConstantData[4 * i + 3] = (int32_t) uif(state->vs_const_i[4 * (StartRegister + i) + 3]); } } diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index b7a211d21f7..2faca121fe6 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -93,13 +93,13 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device) if (state->changed.vs_const_i) { int *idst = (int *)&state->vs_const_f[4 * device->max_vs_const_f]; - memcpy(idst, state->vs_const_i, sizeof(state->vs_const_i)); + memcpy(idst, state->vs_const_i, NINE_MAX_CONST_I * sizeof(int[4])); state->changed.vs_const_i = 0; } 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]; - memcpy(bdst, state->vs_const_b, sizeof(state->vs_const_b)); + memcpy(bdst, state->vs_const_b, NINE_MAX_CONST_B * sizeof(BOOL)); state->changed.vs_const_b = 0; } diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 7c395b84a28..8c9483231e0 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -157,8 +157,8 @@ struct nine_state */ struct NineVertexShader9 *vs; float *vs_const_f; - int vs_const_i[NINE_MAX_CONST_I][4]; - BOOL vs_const_b[NINE_MAX_CONST_B]; + int *vs_const_i; + BOOL *vs_const_b; float *vs_lconstf_temp; BOOL programmable_vs; diff --git a/src/gallium/state_trackers/nine/stateblock9.c b/src/gallium/state_trackers/nine/stateblock9.c index 7ba19e76c19..19c3766b3c6 100644 --- a/src/gallium/state_trackers/nine/stateblock9.c +++ b/src/gallium/state_trackers/nine/stateblock9.c @@ -30,6 +30,9 @@ /* XXX TODO: handling of lights is broken */ +#define VS_CONST_I_SIZE (NINE_MAX_CONST_I * sizeof(int[4])) +#define VS_CONST_B_SIZE (NINE_MAX_CONST_B * sizeof(BOOL)) + HRESULT NineStateBlock9_ctor( struct NineStateBlock9 *This, struct NineUnknownParams *pParams, @@ -46,7 +49,10 @@ NineStateBlock9_ctor( struct NineStateBlock9 *This, This->state.vs_const_f = MALLOC(This->base.device->vs_const_size); This->state.ps_const_f = MALLOC(This->base.device->ps_const_size); - if (!This->state.vs_const_f || !This->state.ps_const_f) + This->state.vs_const_i = MALLOC(VS_CONST_I_SIZE); + This->state.vs_const_b = MALLOC(VS_CONST_B_SIZE); + if (!This->state.vs_const_f || !This->state.ps_const_f || + !This->state.vs_const_i || !This->state.vs_const_b) return E_OUTOFMEMORY; return D3D_OK; @@ -63,6 +69,8 @@ NineStateBlock9_dtor( struct NineStateBlock9 *This ) FREE(state->vs_const_f); FREE(state->ps_const_f); + FREE(state->vs_const_i); + FREE(state->vs_const_b); FREE(state->ff.light); @@ -131,8 +139,8 @@ nine_state_copy_common(struct nine_state *dst, pool); } for (r = mask->changed.vs_const_i; r; r = r->next) { - memcpy(&dst->vs_const_i[r->bgn], - &src->vs_const_i[r->bgn], + memcpy(&dst->vs_const_i[r->bgn * 4], + &src->vs_const_i[r->bgn * 4], (r->end - r->bgn) * 4 * sizeof(int)); if (apply) nine_ranges_insert(&dst->changed.vs_const_i, r->bgn, r->end, @@ -365,8 +373,8 @@ nine_state_copy_common_all(struct nine_state *dst, if (apply) nine_ranges_insert(&dst->changed.vs_const_f, r->bgn, r->end, pool); - memcpy(dst->vs_const_i, src->vs_const_i, sizeof(dst->vs_const_i)); - memcpy(dst->vs_const_b, src->vs_const_b, sizeof(dst->vs_const_b)); + memcpy(dst->vs_const_i, src->vs_const_i, VS_CONST_I_SIZE); + memcpy(dst->vs_const_b, src->vs_const_b, VS_CONST_B_SIZE); if (apply) { r = help->changed.vs_const_i; nine_ranges_insert(&dst->changed.vs_const_i, r->bgn, r->end, pool); |