From c5af96aebd2be165e29124c1e5d5bb3b7021bb30 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Wed, 19 Oct 2016 23:06:05 +0200 Subject: [PATCH] st/nine: Put ff data in a separate structure And make nine_state_access_transform take this new structure as input. Part of the refactor to move all gallium calls to nine_state.c, and have all internal states required for those calls in nine_context. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c | 6 ++-- src/gallium/state_trackers/nine/nine_ff.c | 4 +-- src/gallium/state_trackers/nine/nine_state.c | 14 ++++---- src/gallium/state_trackers/nine/nine_state.h | 46 ++++++++++++++------------- src/gallium/state_trackers/nine/stateblock9.c | 4 +-- 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index d8ff4cb..2587ad1 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1975,7 +1975,7 @@ NineDevice9_SetTransform( struct NineDevice9 *This, const D3DMATRIX *pMatrix ) { struct nine_state *state = This->update; - D3DMATRIX *M = nine_state_access_transform(state, State, TRUE); + D3DMATRIX *M = nine_state_access_transform(&state->ff, State, TRUE); DBG("This=%p State=%d pMatrix=%p\n", This, State, pMatrix); @@ -1993,7 +1993,7 @@ NineDevice9_GetTransform( struct NineDevice9 *This, D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix ) { - D3DMATRIX *M = nine_state_access_transform(&This->state, State, FALSE); + D3DMATRIX *M = nine_state_access_transform(&This->state.ff, State, FALSE); user_assert(M, D3DERR_INVALIDCALL); *pMatrix = *M; return D3D_OK; @@ -2006,7 +2006,7 @@ NineDevice9_MultiplyTransform( struct NineDevice9 *This, { struct nine_state *state = This->update; D3DMATRIX T; - D3DMATRIX *M = nine_state_access_transform(state, State, TRUE); + D3DMATRIX *M = nine_state_access_transform(&state->ff, State, TRUE); DBG("This=%p State=%d pMatrix=%p\n", This, State, pMatrix); diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c index bfabf18..0c92bd1 100644 --- a/src/gallium/state_trackers/nine/nine_ff.c +++ b/src/gallium/state_trackers/nine/nine_ff.c @@ -1708,7 +1708,7 @@ nine_ff_get_vs(struct NineDevice9 *device) return vs; } -#define GET_D3DTS(n) nine_state_access_transform(state, D3DTS_##n, FALSE) +#define GET_D3DTS(n) nine_state_access_transform(&state->ff, D3DTS_##n, FALSE) #define IS_D3DTS_DIRTY(s,n) ((s)->ff.changed.transform[(D3DTS_##n) / 32] & (1 << ((D3DTS_##n) % 32))) static struct NinePixelShader9 * @@ -1977,7 +1977,7 @@ nine_ff_load_tex_matrices(struct NineDevice9 *device) return; for (s = 0; s < 8; ++s) { if (IS_D3DTS_DIRTY(state, TEXTURE0 + s)) - nine_d3d_matrix_transpose(&M[32 + s], nine_state_access_transform(state, D3DTS_TEXTURE0 + s, FALSE)); + nine_d3d_matrix_transpose(&M[32 + s], nine_state_access_transform(&state->ff, D3DTS_TEXTURE0 + s, FALSE)); } } diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index c99c373..47fe31d 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -2783,7 +2783,7 @@ const uint32_t nine_render_state_group[NINED3DRS_LAST + 1] = /* Misc */ D3DMATRIX * -nine_state_access_transform(struct nine_state *state, D3DTRANSFORMSTATETYPE t, +nine_state_access_transform(struct nine_ff_state *ff_state, D3DTRANSFORMSTATETYPE t, boolean alloc) { static D3DMATRIX Identity = { .m[0] = { 1, 0, 0, 0 }, @@ -2810,20 +2810,20 @@ nine_state_access_transform(struct nine_state *state, D3DTRANSFORMSTATETYPE t, break; } - if (index >= state->ff.num_transforms) { + if (index >= ff_state->num_transforms) { unsigned N = index + 1; - unsigned n = state->ff.num_transforms; + unsigned n = ff_state->num_transforms; if (!alloc) return &Identity; - state->ff.transform = REALLOC(state->ff.transform, + ff_state->transform = REALLOC(ff_state->transform, n * sizeof(D3DMATRIX), N * sizeof(D3DMATRIX)); for (; n < N; ++n) - state->ff.transform[n] = Identity; - state->ff.num_transforms = N; + ff_state->transform[n] = Identity; + ff_state->num_transforms = N; } - return &state->ff.transform[index]; + return &ff_state->transform[index]; } #define D3DRS_TO_STRING_CASE(n) case D3DRS_##n: return "D3DRS_"#n diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index a6f20ab..d73c406 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -137,6 +137,28 @@ #define NINE_PS_SAMPLERS_MASK 0x00ffff #define NINE_VS_SAMPLERS_MASK 0x1e0000 +struct nine_ff_state { + struct { + uint32_t tex_stage[NINE_MAX_TEXTURE_STAGES][(NINED3DTSS_COUNT + 31) / 32]; + uint32_t transform[(NINED3DTS_COUNT + 31) / 32]; + } changed; + + D3DMATRIX *transform; /* access only via nine_state_access_transform */ + unsigned num_transforms; + + /* XXX: Do state blocks just change the set of active lights or do we + * have to store which lights have been disabled, too ? + */ + D3DLIGHT9 *light; + uint16_t active_light[NINE_MAX_LIGHTS_ACTIVE]; /* 8 */ + unsigned num_lights; + unsigned num_lights_active; + + D3DMATERIAL9 material; + + DWORD tex_stage[NINE_MAX_TEXTURE_STAGES][NINED3DTSS_COUNT]; +}; + struct nine_state { struct { @@ -192,27 +214,7 @@ struct nine_state DWORD samp_advertised[NINE_MAX_SAMPLERS][D3DSAMP_COUNT]; - struct { - struct { - uint32_t tex_stage[NINE_MAX_TEXTURE_STAGES][(NINED3DTSS_COUNT + 31) / 32]; - uint32_t transform[(NINED3DTS_COUNT + 31) / 32]; - } changed; - - D3DMATRIX *transform; /* access only via nine_state_access_transform */ - unsigned num_transforms; - - /* XXX: Do state blocks just change the set of active lights or do we - * have to store which lights have been disabled, too ? - */ - D3DLIGHT9 *light; - uint16_t active_light[NINE_MAX_LIGHTS_ACTIVE]; /* 8 */ - unsigned num_lights; - unsigned num_lights_active; - - D3DMATERIAL9 material; - - DWORD tex_stage[NINE_MAX_TEXTURE_STAGES][NINED3DTSS_COUNT]; - } ff; + struct nine_ff_state ff; }; struct nine_context { @@ -457,7 +459,7 @@ void nine_state_destroy_sw(struct NineDevice9 *device); * Therefore, do not modify if you set alloc to FALSE ! */ D3DMATRIX * -nine_state_access_transform(struct nine_state *, D3DTRANSFORMSTATETYPE, +nine_state_access_transform(struct nine_ff_state *, D3DTRANSFORMSTATETYPE, boolean alloc); const char *nine_d3drs_to_string(DWORD State); diff --git a/src/gallium/state_trackers/nine/stateblock9.c b/src/gallium/state_trackers/nine/stateblock9.c index 0aa69be..cc802d4 100644 --- a/src/gallium/state_trackers/nine/stateblock9.c +++ b/src/gallium/state_trackers/nine/stateblock9.c @@ -316,9 +316,9 @@ nine_state_copy_common(struct NineDevice9 *device, for (s = i * 32; s < (i * 32 + 32); ++s) { if (!(mask->ff.changed.transform[i] & (1 << (s % 32)))) continue; - *nine_state_access_transform(dst, s, TRUE) = + *nine_state_access_transform(&dst->ff, s, TRUE) = *nine_state_access_transform( /* const because !alloc */ - (struct nine_state *)src, s, FALSE); + (struct nine_ff_state *)&src->ff, s, FALSE); } if (apply) dst->ff.changed.transform[i] |= mask->ff.changed.transform[i]; -- 2.7.4