diff options
author | Axel Davy <[email protected]> | 2016-10-31 17:04:29 +0100 |
---|---|---|
committer | Axel Davy <[email protected]> | 2016-12-20 23:44:22 +0100 |
commit | 7ebdbb573b6d784068d92993d1f5f81986cfe279 (patch) | |
tree | ab4a89dcbc09e471c1e0cd8eead006c4fa25ced9 /src/gallium/state_trackers | |
parent | 152d0077690199b6cb4913d1596ed1d2048e32ca (diff) |
st/nine: Do not use NineBaseTexture9 in nine_context
Some fields are subject to modification outside of nine_context
(SetLod, etc).
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/nine/basetexture9.c | 21 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_ff.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.c | 73 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.h | 10 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/pixelshader9.h | 2 |
5 files changed, 71 insertions, 41 deletions
diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index 6bcd0c9f2df..f37dbb1d121 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -203,17 +203,6 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This ) pipe_sampler_view_reference(&This->view[0], NULL); pipe_sampler_view_reference(&This->view[1], NULL); - if (This->bind_count) { - /* mark state dirty */ - struct nine_state *state = &This->base.base.device->state; - struct nine_context *context = &This->base.base.device->context; - 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) - context->changed.group |= NINE_STATE_TEXTURE; - } - /* Allocate a new resource */ hr = NineBaseTexture9_CreatePipeResource(This, This->managed.lod_resident != -1); if (FAILED(hr)) @@ -378,6 +367,16 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This ) if (This->base.usage & D3DUSAGE_AUTOGENMIPMAP) This->dirty_mip = TRUE; + /* Set again the textures currently bound to update the texture data */ + if (This->bind_count) { + 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) + nine_context_set_texture(This->base.base.device, s, This); + } + DBG("DONE, generate mip maps = %i\n", This->dirty_mip); return D3D_OK; } diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c index b18b00e4471..a0a33cdc74a 100644 --- a/src/gallium/state_trackers/nine/nine_ff.c +++ b/src/gallium/state_trackers/nine/nine_ff.c @@ -1737,7 +1737,7 @@ nine_ff_get_ps(struct NineDevice9 *device) break; } - if (!context->texture[s] && + if (!context->texture[s].enabled && ((context->ff.tex_stage[s][D3DTSS_COLORARG0] == D3DTA_TEXTURE && used_c & 0x1) || (context->ff.tex_stage[s][D3DTSS_COLORARG1] == D3DTA_TEXTURE && @@ -1782,8 +1782,8 @@ nine_ff_get_ps(struct NineDevice9 *device) } key.ts[s].resultarg = context->ff.tex_stage[s][D3DTSS_RESULTARG] == D3DTA_TEMP; - if (context->texture[s]) { - switch (context->texture[s]->base.type) { + if (context->texture[s].enabled) { + switch (context->texture[s].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 226946031d6..928d82050c9 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -656,20 +656,20 @@ update_sampler_derived(struct nine_context *context, unsigned s) { boolean changed = FALSE; - if (context->samp[s][NINED3DSAMP_SHADOW] != context->texture[s]->shadow) { + if (context->samp[s][NINED3DSAMP_SHADOW] != context->texture[s].shadow) { changed = TRUE; - context->samp[s][NINED3DSAMP_SHADOW] = context->texture[s]->shadow; + context->samp[s][NINED3DSAMP_SHADOW] = context->texture[s].shadow; } if (context->samp[s][NINED3DSAMP_CUBETEX] != - (NineResource9(context->texture[s])->type == D3DRTYPE_CUBETEXTURE)) { + (context->texture[s].type == D3DRTYPE_CUBETEXTURE)) { changed = TRUE; context->samp[s][NINED3DSAMP_CUBETEX] = - NineResource9(context->texture[s])->type == D3DRTYPE_CUBETEXTURE; + context->texture[s].type == D3DRTYPE_CUBETEXTURE; } if (context->samp[s][D3DSAMP_MIPFILTER] != D3DTEXF_NONE) { - int lod = context->samp[s][D3DSAMP_MAXMIPLEVEL] - context->texture[s]->managed.lod; + int lod = context->samp[s][D3DSAMP_MAXMIPLEVEL] - context->texture[s].lod; if (lod < 0) lod = 0; if (context->samp[s][NINED3DSAMP_MINLOD] != lod) { @@ -703,15 +703,15 @@ update_textures_and_samplers(struct NineDevice9 *device) const unsigned s = NINE_SAMPLER_PS(i); int sRGB; - if (!context->texture[s] && !(sampler_mask & (1 << i))) { + if (!context->texture[s].enabled && !(sampler_mask & (1 << i))) { view[i] = NULL; continue; } - if (context->texture[s]) { + if (context->texture[s].enabled) { sRGB = context->samp[s][D3DSAMP_SRGBTEXTURE] ? 1 : 0; - view[i] = NineBaseTexture9_GetSamplerView(context->texture[s], sRGB); + view[i] = context->texture[s].view[sRGB]; num_textures = i + 1; if (update_sampler_derived(context, s) || (context->changed.sampler[s] & 0x05fe)) { @@ -751,15 +751,15 @@ update_textures_and_samplers(struct NineDevice9 *device) const unsigned s = NINE_SAMPLER_VS(i); int sRGB; - if (!context->texture[s] && !(sampler_mask & (1 << i))) { + if (!context->texture[s].enabled && !(sampler_mask & (1 << i))) { view[i] = NULL; continue; } - if (context->texture[s]) { + if (context->texture[s].enabled) { sRGB = context->samp[s][D3DSAMP_SRGBTEXTURE] ? 1 : 0; - view[i] = NineBaseTexture9_GetSamplerView(context->texture[s], sRGB); + view[i] = context->texture[s].view[sRGB]; num_textures = i + 1; if (update_sampler_derived(context, s) || (context->changed.sampler[s] & 0x05fe)) { @@ -1043,18 +1043,17 @@ NineDevice9_ResolveZ( struct NineDevice9 *device ) struct nine_context *context = &device->context; const struct util_format_description *desc; struct NineSurface9 *source = context->ds; - struct NineBaseTexture9 *destination = context->texture[0]; struct pipe_resource *src, *dst; struct pipe_blit_info blit; DBG("RESZ resolve\n"); - if (!source || !destination || - destination->base.type != D3DRTYPE_TEXTURE) + if (!source || !context->texture[0].enabled || + context->texture[0].type != D3DRTYPE_TEXTURE) return; src = source->base.resource; - dst = destination->base.resource; + dst = context->texture[0].resource; if (!src || !dst) return; @@ -1146,10 +1145,31 @@ nine_context_set_texture(struct NineDevice9 *device, struct nine_context *context = &device->context; context->samplers_shadow &= ~(1 << Stage); - if (tex) + /* For managed pool, the data can be initially incomplete. + * In that case, the texture is rebound later + * (in NineBaseTexture9_Validate/NineBaseTexture9_UploadSelf). */ + if (tex && tex->base.resource) { context->samplers_shadow |= tex->shadow << Stage; - - nine_bind(&context->texture[Stage], tex); + context->texture[Stage].enabled = TRUE; + context->texture[Stage].shadow = tex->shadow; + context->texture[Stage].lod = tex->managed.lod; + context->texture[Stage].type = tex->base.type; + context->texture[Stage].pstype = tex->pstype; + pipe_resource_reference(&context->texture[Stage].resource, + tex->base.resource); + pipe_sampler_view_reference(&context->texture[Stage].view[0], + NineBaseTexture9_GetSamplerView(tex, 0)); + pipe_sampler_view_reference(&context->texture[Stage].view[1], + NineBaseTexture9_GetSamplerView(tex, 1)); + } else { + context->texture[Stage].enabled = FALSE; + pipe_resource_reference(&context->texture[Stage].resource, + NULL); + pipe_sampler_view_reference(&context->texture[Stage].view[0], + NULL); + pipe_sampler_view_reference(&context->texture[Stage].view[1], + NULL); + } context->changed.group |= NINE_STATE_TEXTURE; } @@ -1601,15 +1621,11 @@ nine_context_apply_stateblock(struct NineDevice9 *device, uint32_t m = src->changed.texture; unsigned s; - context->samplers_shadow &= ~m; - for (s = 0; m; ++s, m >>= 1) { struct NineBaseTexture9 *tex = src->texture[s]; if (!(m & 1)) continue; - if (tex) - context->samplers_shadow |= tex->shadow << s; - nine_bind(&context->texture[s], src->texture[s]); + nine_context_set_texture(device, s, tex); } } @@ -2424,8 +2440,15 @@ nine_context_clear(struct NineDevice9 *device) pipe_resource_reference(&context->vtxbuf[i].buffer, NULL); pipe_resource_reference(&context->idxbuf.buffer, NULL); - for (i = 0; i < NINE_MAX_SAMPLERS; ++i) - nine_bind(&context->texture[i], NULL); + for (i = 0; i < NINE_MAX_SAMPLERS; ++i) { + context->texture[i].enabled = FALSE; + pipe_resource_reference(&context->texture[i].resource, + NULL); + pipe_sampler_view_reference(&context->texture[i].view[0], + NULL); + pipe_sampler_view_reference(&context->texture[i].view[1], + NULL); + } } void diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 11a213e3066..42d45d959b9 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -277,7 +277,15 @@ struct nine_context { DWORD rs[NINED3DRS_COUNT]; - struct NineBaseTexture9 *texture[NINE_MAX_SAMPLERS]; + struct { + BOOL enabled; + BOOL shadow; + DWORD lod; + D3DRESOURCETYPE type; + struct pipe_resource *resource; + struct pipe_sampler_view *view[2]; + uint8_t pstype; + } texture[NINE_MAX_SAMPLERS]; DWORD samp[NINE_MAX_SAMPLERS][NINED3DSAMP_COUNT]; diff --git a/src/gallium/state_trackers/nine/pixelshader9.h b/src/gallium/state_trackers/nine/pixelshader9.h index 67a18f20c42..accd00a6a8c 100644 --- a/src/gallium/state_trackers/nine/pixelshader9.h +++ b/src/gallium/state_trackers/nine/pixelshader9.h @@ -80,7 +80,7 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps, while (m) { int s = ffs(m) - 1; m &= ~(1 << s); - samplers_ps1_types |= (context->texture[s] ? context->texture[s]->pstype : 1) << (s * 2); + samplers_ps1_types |= (context->texture[s].enabled ? context->texture[s].pstype : 1) << (s * 2); } key = samplers_ps1_types; } else { |