And move samplers_shadow to nine_context.
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@ens.fr>
{
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);
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;
}
}
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) {
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 */
}
}
}
BOOL ps_const_b[NINE_MAX_CONST_B];
float *ps_lconstf_temp;
- uint32_t samplers_shadow;
-
struct NineVertexDeclaration9 *vdecl;
struct NineIndexBuffer9 *idxbuf;
DWORD rs[NINED3DRS_COUNT];
+ uint32_t samplers_shadow;
+
uint8_t bound_samplers_mask_vs;
uint16_t bound_samplers_mask_ps;
D3DRENDERSTATETYPE State,
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,
}
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;
}
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);
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))
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--;
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;