[Mesa-dev] [PATCH 06/84] st/nine: Back textures into nine_context
Axel Davy
axel.davy at ens.fr
Wed Dec 7 22:54:39 UTC 2016
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 <axel.davy at ens.fr>
---
src/gallium/state_trackers/nine/basetexture9.c | 1 +
src/gallium/state_trackers/nine/device9.c | 2 ++
src/gallium/state_trackers/nine/device9ex.c | 1 +
src/gallium/state_trackers/nine/nine_ff.c | 6 ++--
src/gallium/state_trackers/nine/nine_state.c | 44 ++++++++++++++++----------
src/gallium/state_trackers/nine/nine_state.h | 3 ++
src/gallium/state_trackers/nine/pixelshader9.h | 2 +-
src/gallium/state_trackers/nine/stateblock9.c | 2 +-
8 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c
index e7b049c..633fa23 100644
--- a/src/gallium/state_trackers/nine/basetexture9.c
+++ b/src/gallium/state_trackers/nine/basetexture9.c
@@ -209,6 +209,7 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This )
struct nine_state *state = &This->base.base.device->state;
unsigned s;
for (s = 0; s < NINE_MAX_SAMPLERS; ++s)
+ /* Dirty tracking is done in device9 state, not nine_context. */
if (state->texture[s] == This)
state->changed.group |= NINE_STATE_TEXTURE;
}
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index d8440e6..b153616 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -486,6 +486,7 @@ NineDevice9_dtor( struct NineDevice9 *This )
nine_ff_fini(This);
nine_state_destroy_sw(This);
nine_state_clear(&This->state, TRUE);
+ nine_context_clear(&This->context);
if (This->vertex_uploader)
u_upload_destroy(This->vertex_uploader);
@@ -856,6 +857,7 @@ NineDevice9_Reset( struct NineDevice9 *This,
nine_pipe_context_clear(This);
nine_state_clear(&This->state, TRUE);
+ nine_context_clear(&This->context);
NineDevice9_SetDefaultState(This, TRUE);
NineDevice9_SetRenderTarget(
diff --git a/src/gallium/state_trackers/nine/device9ex.c b/src/gallium/state_trackers/nine/device9ex.c
index fd42724..77a364a 100644
--- a/src/gallium/state_trackers/nine/device9ex.c
+++ b/src/gallium/state_trackers/nine/device9ex.c
@@ -259,6 +259,7 @@ NineDevice9Ex_Reset( struct NineDevice9Ex *This,
nine_pipe_context_clear((struct NineDevice9 *)This);
nine_state_clear(&This->base.state, TRUE);
+ nine_context_clear(&This->base.context);
NineDevice9_SetDefaultState((struct NineDevice9 *)This, TRUE);
NineDevice9_SetRenderTarget(
diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
index c01db01..c0f15d8 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -1739,7 +1739,7 @@ nine_ff_get_ps(struct NineDevice9 *device)
break;
}
- if (!state->texture[s] &&
+ if (!context->texture[s] &&
((state->ff.tex_stage[s][D3DTSS_COLORARG0] == D3DTA_TEXTURE &&
used_c & 0x1) ||
(state->ff.tex_stage[s][D3DTSS_COLORARG1] == D3DTA_TEXTURE &&
@@ -1784,8 +1784,8 @@ nine_ff_get_ps(struct NineDevice9 *device)
}
key.ts[s].resultarg = state->ff.tex_stage[s][D3DTSS_RESULTARG] == D3DTA_TEMP;
- if (state->texture[s]) {
- switch (state->texture[s]->base.type) {
+ if (context->texture[s]) {
+ switch (context->texture[s]->base.type) {
case D3DRTYPE_TEXTURE: key.ts[s].textarget = 1; break;
case D3DRTYPE_VOLUMETEXTURE: key.ts[s].textarget = 2; break;
case D3DRTYPE_CUBETEXTURE: key.ts[s].textarget = 3; break;
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index f42f8cb..9feef20 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -719,24 +719,24 @@ update_vertex_buffers(struct NineDevice9 *device)
}
static inline boolean
-update_sampler_derived(struct nine_state *state, unsigned s)
+update_sampler_derived(struct nine_state *state, struct nine_context *context, unsigned s)
{
boolean changed = FALSE;
- if (state->samp[s][NINED3DSAMP_SHADOW] != state->texture[s]->shadow) {
+ if (state->samp[s][NINED3DSAMP_SHADOW] != context->texture[s]->shadow) {
changed = TRUE;
- state->samp[s][NINED3DSAMP_SHADOW] = state->texture[s]->shadow;
+ state->samp[s][NINED3DSAMP_SHADOW] = context->texture[s]->shadow;
}
if (state->samp[s][NINED3DSAMP_CUBETEX] !=
- (NineResource9(state->texture[s])->type == D3DRTYPE_CUBETEXTURE)) {
+ (NineResource9(context->texture[s])->type == D3DRTYPE_CUBETEXTURE)) {
changed = TRUE;
state->samp[s][NINED3DSAMP_CUBETEX] =
- NineResource9(state->texture[s])->type == D3DRTYPE_CUBETEXTURE;
+ NineResource9(context->texture[s])->type == D3DRTYPE_CUBETEXTURE;
}
if (state->samp[s][D3DSAMP_MIPFILTER] != D3DTEXF_NONE) {
- int lod = state->samp[s][D3DSAMP_MAXMIPLEVEL] - state->texture[s]->managed.lod;
+ int lod = state->samp[s][D3DSAMP_MAXMIPLEVEL] - context->texture[s]->managed.lod;
if (lod < 0)
lod = 0;
if (state->samp[s][NINED3DSAMP_MINLOD] != lod) {
@@ -771,18 +771,18 @@ update_textures_and_samplers(struct NineDevice9 *device)
const unsigned s = NINE_SAMPLER_PS(i);
int sRGB;
- if (!state->texture[s] && !(sampler_mask & (1 << i))) {
+ if (!context->texture[s] && !(sampler_mask & (1 << i))) {
view[i] = NULL;
continue;
}
- if (state->texture[s]) {
+ if (context->texture[s]) {
sRGB = state->samp[s][D3DSAMP_SRGBTEXTURE] ? 1 : 0;
- view[i] = NineBaseTexture9_GetSamplerView(state->texture[s], sRGB);
+ view[i] = NineBaseTexture9_GetSamplerView(context->texture[s], sRGB);
num_textures = i + 1;
- if (update_sampler_derived(state, s) || (state->changed.sampler[s] & 0x05fe)) {
+ if (update_sampler_derived(state, context, s) || (state->changed.sampler[s] & 0x05fe)) {
state->changed.sampler[s] = 0;
commit_samplers = TRUE;
nine_convert_sampler_state(device->cso, s, state->samp[s]);
@@ -819,18 +819,18 @@ update_textures_and_samplers(struct NineDevice9 *device)
const unsigned s = NINE_SAMPLER_VS(i);
int sRGB;
- if (!state->texture[s] && !(sampler_mask & (1 << i))) {
+ if (!context->texture[s] && !(sampler_mask & (1 << i))) {
view[i] = NULL;
continue;
}
- if (state->texture[s]) {
+ if (context->texture[s]) {
sRGB = state->samp[s][D3DSAMP_SRGBTEXTURE] ? 1 : 0;
- view[i] = NineBaseTexture9_GetSamplerView(state->texture[s], sRGB);
+ view[i] = NineBaseTexture9_GetSamplerView(context->texture[s], sRGB);
num_textures = i + 1;
- if (update_sampler_derived(state, s) || (state->changed.sampler[s] & 0x05fe)) {
+ if (update_sampler_derived(state, context, s) || (state->changed.sampler[s] & 0x05fe)) {
state->changed.sampler[s] = 0;
commit_samplers = TRUE;
nine_convert_sampler_state(device->cso, s, state->samp[s]);
@@ -1124,9 +1124,10 @@ static void
NineDevice9_ResolveZ( struct NineDevice9 *device )
{
struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
const struct util_format_description *desc;
struct NineSurface9 *source = state->ds;
- struct NineBaseTexture9 *destination = state->texture[0];
+ struct NineBaseTexture9 *destination = context->texture[0];
struct pipe_resource *src, *dst;
struct pipe_blit_info blit;
@@ -1234,6 +1235,8 @@ nine_context_set_texture(struct NineDevice9 *device,
if (tex)
context->samplers_shadow |= tex->shadow << Stage;
+ nine_bind(&context->texture[Stage], tex);
+
state->changed.group |= NINE_STATE_TEXTURE;
}
@@ -1266,7 +1269,7 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
continue;
if (tex)
context->samplers_shadow |= tex->shadow << s;
- /* nine_bind(&state->texture[s], src->texture[s]); Already bound by NineStateBlock9_Apply */
+ nine_bind(&context->texture[s], src->texture[s]);
}
}
}
@@ -1797,6 +1800,15 @@ nine_state_clear(struct nine_state *state, const boolean device)
}
void
+nine_context_clear(struct nine_context *context)
+{
+ unsigned i;
+
+ for (i = 0; i < NINE_MAX_SAMPLERS; ++i)
+ nine_bind(&context->texture[i], NULL);
+}
+
+void
nine_state_init_sw(struct NineDevice9 *device)
{
struct pipe_context *pipe_sw = device->pipe_sw;
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 686f401..71a5293 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -227,6 +227,8 @@ struct nine_context {
DWORD rs[NINED3DRS_COUNT];
+ struct NineBaseTexture9 *texture[NINE_MAX_SAMPLERS];
+
uint32_t samplers_shadow;
uint8_t bound_samplers_mask_vs;
@@ -320,6 +322,7 @@ void nine_state_restore_non_cso(struct NineDevice9 *device);
void nine_state_set_defaults(struct NineDevice9 *, const D3DCAPS9 *,
boolean is_reset);
void nine_state_clear(struct nine_state *, const boolean device);
+void nine_context_clear(struct nine_context *);
void nine_state_init_sw(struct NineDevice9 *device);
void nine_state_prepare_draw_sw(struct NineDevice9 *device,
diff --git a/src/gallium/state_trackers/nine/pixelshader9.h b/src/gallium/state_trackers/nine/pixelshader9.h
index 98d0b03..4c0b537 100644
--- a/src/gallium/state_trackers/nine/pixelshader9.h
+++ b/src/gallium/state_trackers/nine/pixelshader9.h
@@ -81,7 +81,7 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps,
while (m) {
int s = ffs(m) - 1;
m &= ~(1 << s);
- samplers_ps1_types |= (state->texture[s] ? state->texture[s]->pstype : 1) << (s * 2);
+ samplers_ps1_types |= (context->texture[s] ? context->texture[s]->pstype : 1) << (s * 2);
}
key = samplers_ps1_types;
} else {
diff --git a/src/gallium/state_trackers/nine/stateblock9.c b/src/gallium/state_trackers/nine/stateblock9.c
index 4f5e9d7..d0063ed 100644
--- a/src/gallium/state_trackers/nine/stateblock9.c
+++ b/src/gallium/state_trackers/nine/stateblock9.c
@@ -73,7 +73,7 @@ NineStateBlock9_dtor( struct NineStateBlock9 *This )
struct nine_range *r;
struct nine_range_pool *pool = &This->base.device->range_pool;
- nine_state_clear(state, FALSE);
+ nine_state_clear(state, false);
FREE(state->vs_const_f);
FREE(state->ps_const_f);
--
2.10.2
More information about the mesa-dev
mailing list