[Mesa-dev] [PATCH 17/75] st/nine: Change dirty tracking for vs int and bool constants
Axel Davy
axel.davy at ens.fr
Wed Oct 5 20:08:50 UTC 2016
This change makes easier to introduce tracking for
swvp constants.
Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
src/gallium/state_trackers/nine/device9.c | 14 +++++++---
src/gallium/state_trackers/nine/nine_state.c | 18 +++++++++++++
src/gallium/state_trackers/nine/nine_state.h | 8 +++---
src/gallium/state_trackers/nine/stateblock9.c | 38 +++++++++++++++++----------
4 files changed, 56 insertions(+), 22 deletions(-)
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index dc5d647..4cb0912 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2483,8 +2483,10 @@ NineDevice9_CreateStateBlock( struct NineDevice9 *This,
nine_render_states_vertex, sizeof(dst->changed.rs));
nine_ranges_insert(&dst->changed.vs_const_f, 0, This->max_vs_const_f,
&This->range_pool);
- dst->changed.vs_const_i = 0xffff;
- dst->changed.vs_const_b = 0xffff;
+ nine_ranges_insert(&dst->changed.vs_const_i, 0, NINE_MAX_CONST_I,
+ &This->range_pool);
+ nine_ranges_insert(&dst->changed.vs_const_b, 0, NINE_MAX_CONST_B,
+ &This->range_pool);
for (s = 0; s < NINE_MAX_SAMPLERS; ++s)
dst->changed.sampler[s] |= 1 << D3DSAMP_DMAPOFFSET;
if (This->state.ff.num_lights) {
@@ -3447,7 +3449,9 @@ NineDevice9_SetVertexShaderConstantI( struct NineDevice9 *This,
}
}
- state->changed.vs_const_i |= ((1 << Vector4iCount) - 1) << StartRegister;
+ nine_ranges_insert(&state->changed.vs_const_i,
+ StartRegister, StartRegister + Vector4iCount,
+ &This->range_pool);
state->changed.group |= NINE_STATE_VS_CONST;
return D3D_OK;
@@ -3512,7 +3516,9 @@ NineDevice9_SetVertexShaderConstantB( struct NineDevice9 *This,
for (i = 0; i < BoolCount; i++)
state->vs_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
- state->changed.vs_const_b |= ((1 << BoolCount) - 1) << StartRegister;
+ nine_ranges_insert(&state->changed.vs_const_b,
+ StartRegister, StartRegister + BoolCount,
+ &This->range_pool);
state->changed.group |= NINE_STATE_VS_CONST;
return D3D_OK;
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index a18dd73..b7a211d 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -143,6 +143,24 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device)
nine_range_pool_put_chain(&device->range_pool, r, p);
device->state.changed.vs_const_f = NULL;
}
+
+ if (device->state.changed.vs_const_i) {
+ struct nine_range *r = device->state.changed.vs_const_i;
+ struct nine_range *p = r;
+ while (p->next)
+ p = p->next;
+ nine_range_pool_put_chain(&device->range_pool, r, p);
+ device->state.changed.vs_const_i = NULL;
+ }
+
+ if (device->state.changed.vs_const_b) {
+ struct nine_range *r = device->state.changed.vs_const_b;
+ struct nine_range *p = r;
+ while (p->next)
+ p = p->next;
+ nine_range_pool_put_chain(&device->range_pool, r, p);
+ device->state.changed.vs_const_b = NULL;
+ }
state->changed.group &= ~NINE_STATE_VS_CONST;
state->commit |= NINE_STATE_COMMIT_CONST_VS;
}
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index d3c36f8..7c395b8 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -137,10 +137,10 @@ struct nine_state
uint16_t sampler[NINE_MAX_SAMPLERS];
struct nine_range *vs_const_f;
struct nine_range *ps_const_f;
- uint16_t vs_const_i; /* NINE_MAX_CONST_I == 16 */
- uint16_t ps_const_i;
- uint16_t vs_const_b; /* NINE_MAX_CONST_B == 16 */
- uint16_t ps_const_b;
+ struct nine_range *vs_const_i;
+ uint16_t ps_const_i; /* NINE_MAX_CONST_I == 16 */
+ struct nine_range *vs_const_b;
+ uint16_t ps_const_b; /* NINE_MAX_CONST_B == 16 */
uint8_t ucp;
} changed;
diff --git a/src/gallium/state_trackers/nine/stateblock9.c b/src/gallium/state_trackers/nine/stateblock9.c
index bcc00ab..7ba19e7 100644
--- a/src/gallium/state_trackers/nine/stateblock9.c
+++ b/src/gallium/state_trackers/nine/stateblock9.c
@@ -76,6 +76,14 @@ NineStateBlock9_dtor( struct NineStateBlock9 *This )
for (r = This->state.changed.vs_const_f; r->next; r = r->next);
nine_range_pool_put_chain(pool, This->state.changed.vs_const_f, r);
}
+ if (This->state.changed.vs_const_i) {
+ for (r = This->state.changed.vs_const_i; r->next; r = r->next);
+ nine_range_pool_put_chain(pool, This->state.changed.vs_const_i, r);
+ }
+ if (This->state.changed.vs_const_b) {
+ for (r = This->state.changed.vs_const_b; r->next; r = r->next);
+ nine_range_pool_put_chain(pool, This->state.changed.vs_const_b, r);
+ }
NineUnknown_dtor(&This->base);
}
@@ -122,21 +130,21 @@ nine_state_copy_common(struct nine_state *dst,
nine_ranges_insert(&dst->changed.vs_const_f, r->bgn, r->end,
pool);
}
- if (mask->changed.vs_const_i) {
- uint16_t m = mask->changed.vs_const_i;
- for (i = ffs(m) - 1, m >>= i; m; ++i, m >>= 1)
- if (m & 1)
- memcpy(dst->vs_const_i[i], src->vs_const_i[i], 4 * sizeof(int));
+ for (r = mask->changed.vs_const_i; r; r = r->next) {
+ memcpy(&dst->vs_const_i[r->bgn],
+ &src->vs_const_i[r->bgn],
+ (r->end - r->bgn) * 4 * sizeof(int));
if (apply)
- dst->changed.vs_const_i |= mask->changed.vs_const_i;
+ nine_ranges_insert(&dst->changed.vs_const_i, r->bgn, r->end,
+ pool);
}
- if (mask->changed.vs_const_b) {
- uint16_t m = mask->changed.vs_const_b;
- for (i = ffs(m) - 1, m >>= i; m; ++i, m >>= 1)
- if (m & 1)
- dst->vs_const_b[i] = src->vs_const_b[i];
+ for (r = mask->changed.vs_const_b; r; r = r->next) {
+ memcpy(&dst->vs_const_b[r->bgn],
+ &src->vs_const_b[r->bgn],
+ (r->end - r->bgn) * sizeof(int));
if (apply)
- dst->changed.vs_const_b |= mask->changed.vs_const_b;
+ nine_ranges_insert(&dst->changed.vs_const_b, r->bgn, r->end,
+ pool);
}
}
@@ -360,8 +368,10 @@ nine_state_copy_common_all(struct nine_state *dst,
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));
if (apply) {
- dst->changed.vs_const_i |= src->changed.vs_const_i;
- dst->changed.vs_const_b |= src->changed.vs_const_b;
+ r = help->changed.vs_const_i;
+ nine_ranges_insert(&dst->changed.vs_const_i, r->bgn, r->end, pool);
+ r = help->changed.vs_const_b;
+ nine_ranges_insert(&dst->changed.vs_const_b, r->bgn, r->end, pool);
}
}
--
2.10.0
More information about the mesa-dev
mailing list