summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/state_trackers/nine/device9.c36
-rw-r--r--src/gallium/state_trackers/nine/nine_state.c37
-rw-r--r--src/gallium/state_trackers/nine/nine_state.h13
-rw-r--r--src/gallium/state_trackers/nine/pixelshader9.h2
-rw-r--r--src/gallium/state_trackers/nine/stateblock9.c5
-rw-r--r--src/gallium/state_trackers/nine/vertexshader9.h3
6 files changed, 68 insertions, 28 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 7519eaaa789..9923c894dd2 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2450,6 +2450,7 @@ NineDevice9_SetTexture( struct NineDevice9 *This,
{
struct nine_state *state = This->update;
struct NineBaseTexture9 *tex = NineBaseTexture9(pTexture);
+ struct NineBaseTexture9 *old;
DBG("This=%p Stage=%u pTexture=%p\n", This, Stage, pTexture);
@@ -2463,28 +2464,29 @@ NineDevice9_SetTexture( struct NineDevice9 *This,
if (Stage >= D3DDMAPSAMPLER)
Stage = Stage - D3DDMAPSAMPLER + NINE_MAX_SAMPLERS_PS;
- if (!This->is_recording) {
- struct NineBaseTexture9 *old = state->texture[Stage];
- if (old == tex)
- return D3D_OK;
+ if (This->is_recording) {
+ state->changed.texture |= 1 << Stage;
+ state->changed.group |= NINE_STATE_TEXTURE;
+ nine_bind(&state->texture[Stage], pTexture);
+ return D3D_OK;
+ }
- state->samplers_shadow &= ~(1 << Stage);
- if (tex) {
- state->samplers_shadow |= tex->shadow << Stage;
+ old = state->texture[Stage];
+ if (old == tex)
+ return D3D_OK;
- if ((tex->managed.dirty | tex->dirty_mip) && LIST_IS_EMPTY(&tex->list))
- list_add(&tex->list, &This->update_textures);
+ if (tex) {
+ if ((tex->managed.dirty | tex->dirty_mip) && LIST_IS_EMPTY(&tex->list))
+ list_add(&tex->list, &This->update_textures);
- tex->bind_count++;
- }
- if (old)
- old->bind_count--;
+ tex->bind_count++;
}
- nine_bind(&state->texture[Stage], pTexture);
+ if (old)
+ old->bind_count--;
- if (This->is_recording)
- state->changed.texture |= 1 << Stage;
- state->changed.group |= NINE_STATE_TEXTURE;
+ nine_context_set_texture(This, Stage, tex);
+
+ nine_bind(&state->texture[Stage], pTexture);
return D3D_OK;
}
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 49e36a0ab5c..b309af53fd1 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1223,9 +1223,25 @@ nine_context_set_render_state(struct NineDevice9 *device,
}
void
-nine_context_apply_stateblock(struct nine_context *dst,
+nine_context_set_texture(struct NineDevice9 *device,
+ DWORD Stage,
+ struct NineBaseTexture9 *tex)
+{
+ struct nine_context *context = &device->context;
+ struct nine_state *state = &device->state;
+
+ context->samplers_shadow &= ~(1 << Stage);
+ if (tex)
+ context->samplers_shadow |= tex->shadow << Stage;
+
+ state->changed.group |= NINE_STATE_TEXTURE;
+}
+
+void
+nine_context_apply_stateblock(struct NineDevice9 *device,
const struct nine_state *src)
{
+ struct nine_context *context = &device->context;
int i;
for (i = 0; i < ARRAY_SIZE(src->changed.rs); ++i) {
@@ -1233,7 +1249,24 @@ nine_context_apply_stateblock(struct nine_context *dst,
while (m) {
const int r = ffs(m) - 1;
m &= ~(1 << r);
- dst->rs[i * 32 + r] = nine_fix_render_state_value(i * 32 + r, src->rs_advertised[i * 32 + r]);
+ context->rs[i * 32 + r] = nine_fix_render_state_value(i * 32 + r, src->rs_advertised[i * 32 + r]);
+ }
+ }
+
+ /* Textures */
+ if (src->changed.texture) {
+ 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(&state->texture[s], src->texture[s]); Already bound by NineStateBlock9_Apply */
}
}
}
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 99b0a3835bd..686f40175fe 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -174,8 +174,6 @@ struct nine_state
BOOL ps_const_b[NINE_MAX_CONST_B];
float *ps_lconstf_temp;
- uint32_t samplers_shadow;
-
struct NineVertexDeclaration9 *vdecl;
struct NineIndexBuffer9 *idxbuf;
@@ -229,6 +227,8 @@ struct nine_context {
DWORD rs[NINED3DRS_COUNT];
+ uint32_t samplers_shadow;
+
uint8_t bound_samplers_mask_vs;
uint16_t bound_samplers_mask_ps;
@@ -273,6 +273,15 @@ nine_context_set_render_state(struct NineDevice9 *device,
DWORD Value);
void
+nine_context_set_texture(struct NineDevice9 *device,
+ DWORD Stage,
+ struct NineBaseTexture9 *tex);
+
+void
+nine_context_apply_stateblock(struct NineDevice9 *device,
+ const struct nine_state *src);
+
+void
nine_context_clear_fb(struct NineDevice9 *device, DWORD Count,
const D3DRECT *pRects, DWORD Flags,
D3DCOLOR Color, float Z, DWORD Stencil);
diff --git a/src/gallium/state_trackers/nine/pixelshader9.h b/src/gallium/state_trackers/nine/pixelshader9.h
index bc52cc70ec2..98d0b0360f5 100644
--- a/src/gallium/state_trackers/nine/pixelshader9.h
+++ b/src/gallium/state_trackers/nine/pixelshader9.h
@@ -85,7 +85,7 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps,
}
key = samplers_ps1_types;
} else {
- samplers_shadow = (uint16_t)((state->samplers_shadow & NINE_PS_SAMPLERS_MASK) >> NINE_SAMPLER_PS(0));
+ samplers_shadow = (uint16_t)((context->samplers_shadow & NINE_PS_SAMPLERS_MASK) >> NINE_SAMPLER_PS(0));
key = samplers_shadow & ps->sampler_mask;
}
diff --git a/src/gallium/state_trackers/nine/stateblock9.c b/src/gallium/state_trackers/nine/stateblock9.c
index d04ac8f7bfe..4f5e9d7b8d3 100644
--- a/src/gallium/state_trackers/nine/stateblock9.c
+++ b/src/gallium/state_trackers/nine/stateblock9.c
@@ -570,7 +570,7 @@ NineStateBlock9_Apply( struct NineStateBlock9 *This )
else
nine_state_copy_common(device, dst, src, src, TRUE, pool);
- nine_context_apply_stateblock(&device->context, src);
+ nine_context_apply_stateblock(device, src);
if ((src->changed.group & NINE_STATE_VDECL) && src->vdecl)
NineDevice9_SetVertexDeclaration(This->base.device, (IDirect3DVertexDeclaration9 *)src->vdecl);
@@ -582,8 +582,6 @@ NineStateBlock9_Apply( struct NineStateBlock9 *This )
if (src->changed.texture) {
uint32_t m = src->changed.texture;
- dst->samplers_shadow &= ~m;
-
for (s = 0; m; ++s, m >>= 1) {
struct NineBaseTexture9 *tex = src->texture[s];
if (!(m & 1))
@@ -592,7 +590,6 @@ NineStateBlock9_Apply( struct NineStateBlock9 *This )
tex->bind_count++;
if ((tex->managed.dirty | tex->dirty_mip) && LIST_IS_EMPTY(&tex->list))
list_add(&tex->list, &This->base.device->update_textures);
- dst->samplers_shadow |= tex->shadow << s;
}
if (src->texture[s])
src->texture[s]->bind_count--;
diff --git a/src/gallium/state_trackers/nine/vertexshader9.h b/src/gallium/state_trackers/nine/vertexshader9.h
index f1d8ec1e0d4..a912d4628b4 100644
--- a/src/gallium/state_trackers/nine/vertexshader9.h
+++ b/src/gallium/state_trackers/nine/vertexshader9.h
@@ -80,13 +80,12 @@ static inline BOOL
NineVertexShader9_UpdateKey( struct NineVertexShader9 *vs,
struct NineDevice9 *device )
{
- struct nine_state *state = &(device->state);
struct nine_context *context = &(device->context);
uint8_t samplers_shadow;
uint64_t key;
BOOL res;
- samplers_shadow = (uint8_t)((state->samplers_shadow & NINE_VS_SAMPLERS_MASK) >> NINE_SAMPLER_VS(0));
+ samplers_shadow = (uint8_t)((context->samplers_shadow & NINE_VS_SAMPLERS_MASK) >> NINE_SAMPLER_VS(0));
samplers_shadow &= vs->sampler_mask;
key = samplers_shadow;