static void
prepare_vs_constants_userbuf_swvp(struct NineDevice9 *device)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
- if (context->changed.vs_const_f || state->changed.group & NINE_STATE_SWVP) {
+ if (context->changed.vs_const_f || context->changed.group & NINE_STATE_SWVP) {
struct pipe_constant_buffer cb;
cb.buffer_offset = 0;
context->changed.vs_const_f = 0;
}
- if (context->changed.vs_const_i || state->changed.group & NINE_STATE_SWVP) {
+ if (context->changed.vs_const_i || context->changed.group & NINE_STATE_SWVP) {
struct pipe_constant_buffer cb;
cb.buffer_offset = 0;
context->changed.vs_const_i = 0;
}
- if (context->changed.vs_const_b || state->changed.group & NINE_STATE_SWVP) {
+ if (context->changed.vs_const_b || context->changed.group & NINE_STATE_SWVP) {
struct pipe_constant_buffer cb;
cb.buffer_offset = 0;
cb->user_buffer = NULL;
}
- state->changed.group &= ~NINE_STATE_VS_CONST;
+ context->changed.group &= ~NINE_STATE_VS_CONST;
context->commit |= NINE_STATE_COMMIT_CONST_VS;
}
static void
prepare_vs_constants_userbuf(struct NineDevice9 *device)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
struct pipe_constant_buffer cb;
cb.buffer = NULL;
return;
}
- if (context->changed.vs_const_i || state->changed.group & NINE_STATE_SWVP) {
+ if (context->changed.vs_const_i || context->changed.group & NINE_STATE_SWVP) {
int *idst = (int *)&context->vs_const_f[4 * device->max_vs_const_f];
memcpy(idst, context->vs_const_i, NINE_MAX_CONST_I * sizeof(int[4]));
context->changed.vs_const_i = 0;
}
- if (context->changed.vs_const_b || state->changed.group & NINE_STATE_SWVP) {
+ if (context->changed.vs_const_b || context->changed.group & NINE_STATE_SWVP) {
int *idst = (int *)&context->vs_const_f[4 * device->max_vs_const_f];
uint32_t *bdst = (uint32_t *)&idst[4 * NINE_MAX_CONST_I];
memcpy(bdst, context->vs_const_b, NINE_MAX_CONST_B * sizeof(BOOL));
context->changed.vs_const_f = 0;
- state->changed.group &= ~NINE_STATE_VS_CONST;
+ context->changed.group &= ~NINE_STATE_VS_CONST;
context->commit |= NINE_STATE_COMMIT_CONST_VS;
}
static void
prepare_ps_constants_userbuf(struct NineDevice9 *device)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
struct pipe_constant_buffer cb;
cb.buffer = NULL;
context->changed.ps_const_f = 0;
- state->changed.group &= ~NINE_STATE_PS_CONST;
+ context->changed.group &= ~NINE_STATE_PS_CONST;
context->commit |= NINE_STATE_COMMIT_CONST_PS;
}
update_framebuffer(struct NineDevice9 *device, bool is_clear)
{
struct pipe_context *pipe = device->pipe;
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
struct pipe_framebuffer_state *fb = &context->pipe.fb;
unsigned i;
pipe->set_framebuffer_state(pipe, fb); /* XXX: cso ? */
if (is_clear && context->rt_mask == ps_mask)
- state->changed.group &= ~NINE_STATE_FB;
+ context->changed.group &= ~NINE_STATE_FB;
}
static void
static void
update_vertex_elements(struct NineDevice9 *device)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
const struct NineVertexDeclaration9 *vdecl = device->context.vdecl;
const struct NineVertexShader9 *vs;
b = ve[n].vertex_buffer_index;
context->stream_usage_mask |= 1 << b;
/* XXX wine just uses 1 here: */
- if (state->stream_freq[b] & D3DSTREAMSOURCE_INSTANCEDATA)
- ve[n].instance_divisor = state->stream_freq[b] & 0x7FFFFF;
+ if (context->stream_freq[b] & D3DSTREAMSOURCE_INSTANCEDATA)
+ ve[n].instance_divisor = context->stream_freq[b] & 0x7FFFFF;
} else {
/* if the vertex declaration is incomplete compared to what the
* vertex shader needs, we bind a dummy vbo with 0 0 0 0.
nine_update_state(struct NineDevice9 *device)
{
struct pipe_context *pipe = device->pipe;
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
uint32_t group;
- DBG("changed state groups: %x\n", state->changed.group);
+ DBG("changed state groups: %x\n", context->changed.group);
/* NOTE: We may want to use the cso cache for everything, or let
* NineDevice9.RestoreNonCSOState actually set the states, then we wouldn't
/* ff_update may change VS/PS dirty bits */
if (unlikely(!context->programmable_vs || !context->ps))
nine_ff_update(device);
- group = state->changed.group;
+ group = context->changed.group;
if (group & (NINE_STATE_SHADER_CHANGE_VS | NINE_STATE_SHADER_CHANGE_PS)) {
if (group & NINE_STATE_SHADER_CHANGE_VS)
}
}
- device->state.changed.group &=
+ context->changed.group &=
(NINE_STATE_FF | NINE_STATE_VS_CONST | NINE_STATE_PS_CONST);
DBG("finished\n");
D3DRENDERSTATETYPE State,
DWORD Value)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
/* Amd hacks (equivalent to GL extensions) */
if (Value == ALPHA_TO_COVERAGE_ENABLE ||
Value == ALPHA_TO_COVERAGE_DISABLE) {
context->rs[NINED3DRS_ALPHACOVERAGE] = (Value == ALPHA_TO_COVERAGE_ENABLE);
- state->changed.group |= NINE_STATE_BLEND;
+ context->changed.group |= NINE_STATE_BLEND;
return;
}
}
if (Value == D3DFMT_ATOC || (Value == D3DFMT_UNKNOWN && context->rs[NINED3DRS_ALPHACOVERAGE])) {
context->rs[NINED3DRS_ALPHACOVERAGE] = (Value == D3DFMT_ATOC) ? 3 : 0;
context->rs[NINED3DRS_ALPHACOVERAGE] &= context->rs[D3DRS_ALPHATESTENABLE] ? 3 : 2;
- state->changed.group |= NINE_STATE_BLEND;
+ context->changed.group |= NINE_STATE_BLEND;
return;
}
}
DWORD alphacoverage_prev = context->rs[NINED3DRS_ALPHACOVERAGE];
context->rs[NINED3DRS_ALPHACOVERAGE] = (Value ? 3 : 2);
if (context->rs[NINED3DRS_ALPHACOVERAGE] != alphacoverage_prev)
- state->changed.group |= NINE_STATE_BLEND;
+ context->changed.group |= NINE_STATE_BLEND;
}
context->rs[State] = nine_fix_render_state_value(State, Value);
- state->changed.group |= nine_render_state_group[State];
+ context->changed.group |= nine_render_state_group[State];
}
void
struct NineBaseTexture9 *tex)
{
struct nine_context *context = &device->context;
- struct nine_state *state = &device->state;
context->samplers_shadow &= ~(1 << Stage);
if (tex)
nine_bind(&context->texture[Stage], tex);
- state->changed.group |= NINE_STATE_TEXTURE;
+ context->changed.group |= NINE_STATE_TEXTURE;
}
void
D3DSAMPLERSTATETYPE Type,
DWORD Value)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
if (unlikely(!nine_check_sampler_state_value(Type, Value)))
return;
context->samp[Sampler][Type] = Value;
- state->changed.group |= NINE_STATE_SAMPLER;
+ context->changed.group |= NINE_STATE_SAMPLER;
context->changed.sampler[Sampler] |= 1 << Type;
}
UINT StreamNumber,
UINT Setting)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
context->stream_freq[StreamNumber] = Setting;
context->stream_instancedata_mask &= ~(1 << StreamNumber);
if (StreamNumber != 0)
- state->changed.group |= NINE_STATE_STREAMFREQ;
+ context->changed.group |= NINE_STATE_STREAMFREQ;
}
void
nine_context_set_indices(struct NineDevice9 *device,
struct NineIndexBuffer9 *idxbuf)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
const struct pipe_index_buffer *pipe_idxbuf;
} else
pipe_resource_reference(&context->idxbuf.buffer, NULL);
- state->changed.group |= NINE_STATE_IDXBUF;
+ context->changed.group |= NINE_STATE_IDXBUF;
}
void
nine_context_set_vertex_declaration(struct NineDevice9 *device,
struct NineVertexDeclaration9 *vdecl)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
BOOL was_programmable_vs = context->programmable_vs;
context->programmable_vs = context->vs && !(context->vdecl && context->vdecl->position_t);
if (was_programmable_vs != context->programmable_vs) {
context->commit |= NINE_STATE_COMMIT_CONST_VS;
- state->changed.group |= NINE_STATE_VS;
+ context->changed.group |= NINE_STATE_VS;
}
- state->changed.group |= NINE_STATE_VDECL;
+ context->changed.group |= NINE_STATE_VDECL;
}
void
nine_context_set_vertex_shader(struct NineDevice9 *device,
struct NineVertexShader9 *pShader)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
BOOL was_programmable_vs = context->programmable_vs;
if (!was_programmable_vs && context->programmable_vs)
context->commit |= NINE_STATE_COMMIT_CONST_VS;
- state->changed.group |= NINE_STATE_VS;
+ context->changed.group |= NINE_STATE_VS;
}
void
const float *pConstantData,
UINT Vector4fCount)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
float *vs_const_f = device->may_swvp ? context->vs_const_f_swvp : context->vs_const_f;
}
context->changed.vs_const_f = TRUE;
- state->changed.group |= NINE_STATE_VS_CONST;
+ context->changed.group |= NINE_STATE_VS_CONST;
}
const int *pConstantData,
UINT Vector4iCount)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
int i;
}
context->changed.vs_const_i = TRUE;
- state->changed.group |= NINE_STATE_VS_CONST;
+ context->changed.group |= NINE_STATE_VS_CONST;
}
void
const BOOL *pConstantData,
UINT BoolCount)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
int i;
uint32_t bool_true = device->driver_caps.vs_integer ? 0xFFFFFFFF : fui(1.0f);
context->vs_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
context->changed.vs_const_b = TRUE;
- state->changed.group |= NINE_STATE_VS_CONST;
+ context->changed.group |= NINE_STATE_VS_CONST;
}
void
nine_context_set_pixel_shader(struct NineDevice9 *device,
struct NinePixelShader9* ps)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
unsigned old_mask = context->ps ? context->ps->rt_mask : 1;
unsigned mask;
nine_bind(&context->ps, ps);
- state->changed.group |= NINE_STATE_PS;
+ context->changed.group |= NINE_STATE_PS;
mask = context->ps ? context->ps->rt_mask : 1;
/* We need to update cbufs if the pixel shader would
* write to different render targets */
if (mask != old_mask)
- state->changed.group |= NINE_STATE_FB;
+ context->changed.group |= NINE_STATE_FB;
}
void
const float *pConstantData,
UINT Vector4fCount)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
memcpy(&context->ps_const_f[StartRegister * 4],
Vector4fCount * 4 * sizeof(context->ps_const_f[0]));
context->changed.ps_const_f = TRUE;
- state->changed.group |= NINE_STATE_PS_CONST;
+ context->changed.group |= NINE_STATE_PS_CONST;
}
void
const int *pConstantData,
UINT Vector4iCount)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
int i;
}
}
context->changed.ps_const_i = TRUE;
- state->changed.group |= NINE_STATE_PS_CONST;
+ context->changed.group |= NINE_STATE_PS_CONST;
}
void
const BOOL *pConstantData,
UINT BoolCount)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
int i;
uint32_t bool_true = device->driver_caps.ps_integer ? 0xFFFFFFFF : fui(1.0f);
context->ps_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
context->changed.ps_const_b = TRUE;
- state->changed.group |= NINE_STATE_PS_CONST;
+ context->changed.group |= NINE_STATE_PS_CONST;
}
void
DWORD RenderTargetIndex,
struct NineSurface9 *rt)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
const unsigned i = RenderTargetIndex;
context->scissor.maxx = rt->desc.Width;
context->scissor.maxy = rt->desc.Height;
- state->changed.group |= NINE_STATE_VIEWPORT | NINE_STATE_SCISSOR | NINE_STATE_MULTISAMPLE;
+ context->changed.group |= NINE_STATE_VIEWPORT | NINE_STATE_SCISSOR | NINE_STATE_MULTISAMPLE;
if (context->rt[0] &&
(context->rt[0]->desc.MultiSampleType <= D3DMULTISAMPLE_NONMASKABLE) !=
(rt->desc.MultiSampleType <= D3DMULTISAMPLE_NONMASKABLE))
- state->changed.group |= NINE_STATE_SAMPLE_MASK;
+ context->changed.group |= NINE_STATE_SAMPLE_MASK;
}
if (context->rt[i] != rt) {
nine_bind(&context->rt[i], rt);
- state->changed.group |= NINE_STATE_FB;
+ context->changed.group |= NINE_STATE_FB;
}
}
nine_context_set_depth_stencil(struct NineDevice9 *device,
struct NineSurface9 *ds)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
nine_bind(&context->ds, ds);
- state->changed.group |= NINE_STATE_FB;
+ context->changed.group |= NINE_STATE_FB;
}
void
nine_context_set_viewport(struct NineDevice9 *device,
const D3DVIEWPORT9 *viewport)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
context->viewport = *viewport;
- state->changed.group |= NINE_STATE_VIEWPORT;
+ context->changed.group |= NINE_STATE_VIEWPORT;
}
void
nine_context_set_scissor(struct NineDevice9 *device,
const struct pipe_scissor_state *scissor)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
context->scissor = *scissor;
- state->changed.group |= NINE_STATE_SCISSOR;
+ context->changed.group |= NINE_STATE_SCISSOR;
}
void
D3DTRANSFORMSTATETYPE State,
const D3DMATRIX *pMatrix)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
D3DMATRIX *M = nine_state_access_transform(&context->ff, State, TRUE);
*M = *pMatrix;
context->ff.changed.transform[State / 32] |= 1 << (State % 32);
- state->changed.group |= NINE_STATE_FF;
+ context->changed.group |= NINE_STATE_FF;
}
void
nine_context_set_material(struct NineDevice9 *device,
const D3DMATERIAL9 *pMaterial)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
context->ff.material = *pMaterial;
- state->changed.group |= NINE_STATE_FF_MATERIAL;
+ context->changed.group |= NINE_STATE_FF_MATERIAL;
}
void
DWORD Index,
const D3DLIGHT9 *pLight)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
(void)nine_state_set_light(&context->ff, Index, pLight);
- state->changed.group |= NINE_STATE_FF_LIGHTING;
+ context->changed.group |= NINE_STATE_FF_LIGHTING;
}
void
DWORD Index,
BOOL Enable)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
- nine_state_light_enable(&context->ff, &state->changed.group, Index, Enable);
+ nine_state_light_enable(&context->ff, &context->changed.group, Index, Enable);
}
void
D3DTEXTURESTAGESTATETYPE Type,
DWORD Value)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
int bumpmap_index = -1;
bumpmap_index = 4 * 8 + 2 * Stage + 1;
break;
case D3DTSS_TEXTURETRANSFORMFLAGS:
- state->changed.group |= NINE_STATE_PS1X_SHADER;
+ context->changed.group |= NINE_STATE_PS1X_SHADER;
break;
default:
break;
if (bumpmap_index >= 0) {
context->bumpmap_vars[bumpmap_index] = Value;
- state->changed.group |= NINE_STATE_PS_CONST;
+ context->changed.group |= NINE_STATE_PS_CONST;
}
- state->changed.group |= NINE_STATE_FF_PSSTAGES;
+ context->changed.group |= NINE_STATE_FF_PSSTAGES;
context->ff.changed.tex_stage[Stage][Type / 32] |= 1 << (Type % 32);
}
struct nine_context *context = &device->context;
int i;
+ context->changed.group |= src->changed.group;
+
for (i = 0; i < ARRAY_SIZE(src->changed.rs); ++i) {
uint32_t m = src->changed.rs[i];
while (m) {
static void
nine_update_state_framebuffer_clear(struct NineDevice9 *device)
{
- struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
validate_textures(device);
- if (state->changed.group & NINE_STATE_FB)
+ if (context->changed.group & NINE_STATE_FB)
update_framebuffer(device, TRUE);
}
void nine_state_restore_non_cso(struct NineDevice9 *device)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
- state->changed.group = NINE_STATE_ALL;
+ context->changed.group = NINE_STATE_ALL;
context->changed.vtxbuf = (1ULL << device->caps.MaxStreams) - 1;
context->changed.ucp = TRUE;
context->commit |= NINE_STATE_COMMIT_CONST_VS | NINE_STATE_COMMIT_CONST_PS;
/* Set changed flags to initialize driver.
*/
- state->changed.group = NINE_STATE_ALL;
+ context->changed.group = NINE_STATE_ALL;
context->changed.vtxbuf = (1ULL << device->caps.MaxStreams) - 1;
context->changed.ucp = TRUE;