diff options
author | Axel Davy <[email protected]> | 2016-10-20 22:10:34 +0200 |
---|---|---|
committer | Axel Davy <[email protected]> | 2016-12-20 23:44:22 +0100 |
commit | b748b8fd8619ab412517f859dbf9a42b62ef6309 (patch) | |
tree | c2f892a75ad5e7126641051f191a091842842774 | |
parent | a0a18920c7cdba1ffc6d642aff039476755c1cae (diff) |
st/nine: Track dirty state groups in 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 <[email protected]>
-rw-r--r-- | src/gallium/state_trackers/nine/basetexture9.c | 3 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/device9.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_ff.c | 25 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.c | 132 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.h | 23 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/swapchain9.c | 2 |
6 files changed, 81 insertions, 106 deletions
diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index 633fa232877..ddbc5623e73 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -207,11 +207,12 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This ) 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) - state->changed.group |= NINE_STATE_TEXTURE; + context->changed.group |= NINE_STATE_TEXTURE; } /* Allocate a new resource */ diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 7863af9132d..764ebdb5e68 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -2690,7 +2690,7 @@ NineDevice9_SetSoftwareVertexProcessing( struct NineDevice9 *This, { if (This->params.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING) { This->swvp = bSoftware; - This->state.changed.group |= NINE_STATE_SWVP; + This->context.changed.group |= NINE_STATE_SWVP; return D3D_OK; } else return D3DERR_INVALIDCALL; /* msdn. TODO: check in practice */ diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c index 306b2aea722..748a9fa0f1e 100644 --- a/src/gallium/state_trackers/nine/nine_ff.c +++ b/src/gallium/state_trackers/nine/nine_ff.c @@ -1898,12 +1898,11 @@ nine_ff_load_vs_transforms(struct NineDevice9 *device) static void nine_ff_load_lights(struct NineDevice9 *device) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; struct fvec4 *dst = (struct fvec4 *)device->ff.vs_const; unsigned l; - if (state->changed.group & NINE_STATE_FF_MATERIAL) { + if (context->changed.group & NINE_STATE_FF_MATERIAL) { const D3DMATERIAL9 *mtl = &context->ff.material; memcpy(&dst[20], &mtl->Diffuse, 4 * sizeof(float)); @@ -1917,7 +1916,7 @@ nine_ff_load_lights(struct NineDevice9 *device) dst[19].z = dst[25].z * mtl->Ambient.b + mtl->Emissive.b; } - if (!(state->changed.group & NINE_STATE_FF_LIGHTING)) + if (!(context->changed.group & NINE_STATE_FF_LIGHTING)) return; for (l = 0; l < context->ff.num_lights_active; ++l) { @@ -1944,11 +1943,10 @@ nine_ff_load_lights(struct NineDevice9 *device) static void nine_ff_load_point_and_fog_params(struct NineDevice9 *device) { - const struct nine_state *state = &device->state; struct nine_context *context = &device->context; struct fvec4 *dst = (struct fvec4 *)device->ff.vs_const; - if (!(state->changed.group & NINE_STATE_FF_OTHER)) + if (!(context->changed.group & NINE_STATE_FF_OTHER)) return; dst[26].x = asfloat(context->rs[D3DRS_POINTSIZE_MIN]); dst[26].y = asfloat(context->rs[D3DRS_POINTSIZE_MAX]); @@ -1981,12 +1979,11 @@ nine_ff_load_tex_matrices(struct NineDevice9 *device) static void nine_ff_load_ps_params(struct NineDevice9 *device) { - const struct nine_state *state = &device->state; struct nine_context *context = &device->context; struct fvec4 *dst = (struct fvec4 *)device->ff.ps_const; unsigned s; - if (!(state->changed.group & (NINE_STATE_FF_PSSTAGES | NINE_STATE_FF_OTHER))) + if (!(context->changed.group & (NINE_STATE_FF_PSSTAGES | NINE_STATE_FF_OTHER))) return; for (s = 0; s < 8; ++s) @@ -2043,11 +2040,11 @@ nine_ff_update(struct NineDevice9 *device) /* NOTE: the only reference belongs to the hash table */ if (!context->programmable_vs) { device->ff.vs = nine_ff_get_vs(device); - device->state.changed.group |= NINE_STATE_VS; + context->changed.group |= NINE_STATE_VS; } if (!context->ps) { device->ff.ps = nine_ff_get_ps(device); - device->state.changed.group |= NINE_STATE_PS; + context->changed.group |= NINE_STATE_PS; } if (!context->programmable_vs) { @@ -2104,7 +2101,7 @@ nine_ff_update(struct NineDevice9 *device) context->commit |= NINE_STATE_COMMIT_CONST_PS; } - device->state.changed.group &= ~NINE_STATE_FF; + context->changed.group &= ~NINE_STATE_FF; } @@ -2158,25 +2155,29 @@ nine_ff_fini(struct NineDevice9 *device) static void nine_ff_prune_vs(struct NineDevice9 *device) { + struct nine_context *context = &device->context; + if (device->ff.num_vs > 100) { /* could destroy the bound one here, so unbind */ device->pipe->bind_vs_state(device->pipe, NULL); util_hash_table_foreach(device->ff.ht_vs, nine_ff_ht_delete_cb, NULL); util_hash_table_clear(device->ff.ht_vs); device->ff.num_vs = 0; - device->state.changed.group |= NINE_STATE_VS; + context->changed.group |= NINE_STATE_VS; } } static void nine_ff_prune_ps(struct NineDevice9 *device) { + struct nine_context *context = &device->context; + if (device->ff.num_ps > 100) { /* could destroy the bound one here, so unbind */ device->pipe->bind_fs_state(device->pipe, NULL); util_hash_table_foreach(device->ff.ht_ps, nine_ff_ht_delete_cb, NULL); util_hash_table_clear(device->ff.ht_ps); device->ff.num_ps = 0; - device->state.changed.group |= NINE_STATE_PS; + context->changed.group |= NINE_STATE_PS; } } diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index af1968a24c4..a5fa55328ca 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -85,10 +85,9 @@ prepare_rasterizer(struct NineDevice9 *device) 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; @@ -127,7 +126,7 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 *device) 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; @@ -140,7 +139,7 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 *device) 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; @@ -199,14 +198,13 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 *device) 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; @@ -219,13 +217,13 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device) 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)); @@ -269,14 +267,13 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device) 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; @@ -341,7 +338,7 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device) 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; } @@ -417,7 +414,6 @@ static void 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; @@ -487,7 +483,7 @@ update_framebuffer(struct NineDevice9 *device, bool is_clear) 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 @@ -541,7 +537,6 @@ update_viewport(struct NineDevice9 *device) 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; @@ -598,8 +593,8 @@ update_vertex_elements(struct NineDevice9 *device) 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. @@ -951,11 +946,10 @@ static void 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 @@ -969,7 +963,7 @@ nine_update_state(struct NineDevice9 *device) /* 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) @@ -1054,7 +1048,7 @@ nine_update_state(struct NineDevice9 *device) } } - device->state.changed.group &= + context->changed.group &= (NINE_STATE_FF | NINE_STATE_VS_CONST | NINE_STATE_PS_CONST); DBG("finished\n"); @@ -1126,7 +1120,6 @@ nine_context_set_render_state(struct NineDevice9 *device, D3DRENDERSTATETYPE State, DWORD Value) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; /* Amd hacks (equivalent to GL extensions) */ @@ -1139,7 +1132,7 @@ nine_context_set_render_state(struct NineDevice9 *device, 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; } } @@ -1149,7 +1142,7 @@ nine_context_set_render_state(struct NineDevice9 *device, 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; } } @@ -1157,11 +1150,11 @@ nine_context_set_render_state(struct NineDevice9 *device, 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 @@ -1170,7 +1163,6 @@ nine_context_set_texture(struct NineDevice9 *device, struct NineBaseTexture9 *tex) { struct nine_context *context = &device->context; - struct nine_state *state = &device->state; context->samplers_shadow &= ~(1 << Stage); if (tex) @@ -1178,7 +1170,7 @@ nine_context_set_texture(struct NineDevice9 *device, nine_bind(&context->texture[Stage], tex); - state->changed.group |= NINE_STATE_TEXTURE; + context->changed.group |= NINE_STATE_TEXTURE; } void @@ -1187,14 +1179,13 @@ nine_context_set_sampler_state(struct NineDevice9 *device, 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; } @@ -1223,7 +1214,6 @@ nine_context_set_stream_source_freq(struct NineDevice9 *device, UINT StreamNumber, UINT Setting) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; context->stream_freq[StreamNumber] = Setting; @@ -1234,14 +1224,13 @@ nine_context_set_stream_source_freq(struct NineDevice9 *device, 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; @@ -1254,14 +1243,13 @@ nine_context_set_indices(struct NineDevice9 *device, } 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; @@ -1270,17 +1258,16 @@ nine_context_set_vertex_declaration(struct NineDevice9 *device, 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; @@ -1292,7 +1279,7 @@ nine_context_set_vertex_shader(struct NineDevice9 *device, 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 @@ -1301,7 +1288,6 @@ nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device, 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; @@ -1318,7 +1304,7 @@ nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device, } context->changed.vs_const_f = TRUE; - state->changed.group |= NINE_STATE_VS_CONST; + context->changed.group |= NINE_STATE_VS_CONST; } @@ -1328,7 +1314,6 @@ nine_context_set_vertex_shader_constant_i(struct NineDevice9 *device, const int *pConstantData, UINT Vector4iCount) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; int i; @@ -1346,7 +1331,7 @@ nine_context_set_vertex_shader_constant_i(struct NineDevice9 *device, } context->changed.vs_const_i = TRUE; - state->changed.group |= NINE_STATE_VS_CONST; + context->changed.group |= NINE_STATE_VS_CONST; } void @@ -1355,7 +1340,6 @@ nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device, 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); @@ -1364,14 +1348,13 @@ nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device, 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; @@ -1382,13 +1365,13 @@ nine_context_set_pixel_shader(struct NineDevice9 *device, 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 @@ -1397,7 +1380,6 @@ nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device, const float *pConstantData, UINT Vector4fCount) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; memcpy(&context->ps_const_f[StartRegister * 4], @@ -1405,7 +1387,7 @@ nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device, 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 @@ -1414,7 +1396,6 @@ nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device, const int *pConstantData, UINT Vector4iCount) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; int i; @@ -1431,7 +1412,7 @@ nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device, } } context->changed.ps_const_i = TRUE; - state->changed.group |= NINE_STATE_PS_CONST; + context->changed.group |= NINE_STATE_PS_CONST; } void @@ -1440,7 +1421,6 @@ nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device, 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); @@ -1449,7 +1429,7 @@ nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device, 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 @@ -1457,7 +1437,6 @@ nine_context_set_render_target(struct NineDevice9 *device, DWORD RenderTargetIndex, struct NineSurface9 *rt) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; const unsigned i = RenderTargetIndex; @@ -1474,17 +1453,17 @@ nine_context_set_render_target(struct NineDevice9 *device, 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; } } @@ -1492,33 +1471,30 @@ void 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 @@ -1526,24 +1502,22 @@ nine_context_set_transform(struct NineDevice9 *device, 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 @@ -1551,11 +1525,10 @@ nine_context_set_light(struct NineDevice9 *device, 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 @@ -1563,10 +1536,9 @@ nine_context_light_enable(struct NineDevice9 *device, 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 @@ -1575,7 +1547,6 @@ nine_context_set_texture_stage_state(struct NineDevice9 *device, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; int bumpmap_index = -1; @@ -1600,7 +1571,7 @@ nine_context_set_texture_stage_state(struct NineDevice9 *device, 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; @@ -1608,10 +1579,10 @@ nine_context_set_texture_stage_state(struct NineDevice9 *device, 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); } @@ -1633,6 +1604,8 @@ nine_context_apply_stateblock(struct NineDevice9 *device, 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) { @@ -1856,11 +1829,11 @@ nine_context_apply_stateblock(struct NineDevice9 *device, 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); } @@ -2278,10 +2251,9 @@ static const DWORD nine_samp_state_defaults[NINED3DSAMP_LAST + 1] = 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; @@ -2343,7 +2315,7 @@ nine_state_set_defaults(struct NineDevice9 *device, const D3DCAPS9 *caps, /* 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; diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index dd3331cd390..9894f3898e0 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -163,19 +163,19 @@ struct nine_state { struct { uint32_t group; - uint32_t rs[(NINED3DRS_COUNT + 31) / 32]; /* stateblocks only */ - uint32_t vtxbuf; /* stateblocks only */ - uint32_t stream_freq; /* stateblocks only */ - uint32_t texture; /* stateblocks only */ - uint16_t sampler[NINE_MAX_SAMPLERS]; /* stateblocks only */ - struct nine_range *vs_const_f; /* stateblocks only */ - struct nine_range *ps_const_f; /* stateblocks only */ - struct nine_range *vs_const_i; /* stateblocks only */ + uint32_t rs[(NINED3DRS_COUNT + 31) / 32]; + uint32_t vtxbuf; + uint32_t stream_freq; + uint32_t texture; + uint16_t sampler[NINE_MAX_SAMPLERS]; + struct nine_range *vs_const_f; + struct nine_range *ps_const_f; + struct nine_range *vs_const_i; uint16_t ps_const_i; /* NINE_MAX_CONST_I == 16 */ - struct nine_range *vs_const_b; /* stateblocks only */ + struct nine_range *vs_const_b; uint16_t ps_const_b; /* NINE_MAX_CONST_B == 16 */ - uint8_t ucp; /* stateblocks only */ - } changed; + uint8_t ucp; + } changed; /* stateblocks only */ struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS]; struct NineSurface9 *ds; @@ -219,6 +219,7 @@ struct nine_state struct nine_context { struct { + uint32_t group; uint16_t sampler[NINE_MAX_SAMPLERS]; uint32_t vtxbuf; BOOL vs_const_f; diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c index 8a405f2374c..b45e60b97ec 100644 --- a/src/gallium/state_trackers/nine/swapchain9.c +++ b/src/gallium/state_trackers/nine/swapchain9.c @@ -896,7 +896,7 @@ NineSwapChain9_Present( struct NineSwapChain9 *This, ID3DPresent_WaitBufferReleased(This->present, This->present_handles[0]); } - This->base.device->state.changed.group |= NINE_STATE_FB; + This->base.device->context.changed.group |= NINE_STATE_FB; return hr; } |