diff options
author | Axel Davy <[email protected]> | 2016-10-20 21:41:19 +0200 |
---|---|---|
committer | Axel Davy <[email protected]> | 2016-12-20 23:44:22 +0100 |
commit | c6ca7c747e47127bb0ced0c7ca38beaa760376a4 (patch) | |
tree | c136810cec1d712a621842cb6db29dfb469771ea /src/gallium | |
parent | d671190df907b7643ba00143b2fbf0a1f5bee6c4 (diff) |
st/nine: Back ps 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 <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/state_trackers/nine/device9.c | 29 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_ff.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.c | 49 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.h | 5 |
4 files changed, 59 insertions, 30 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 31765265e1c..f25d5a94670 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -3526,28 +3526,25 @@ NineDevice9_SetPixelShader( struct NineDevice9 *This, IDirect3DPixelShader9 *pShader ) { struct nine_state *state = This->update; - struct nine_context *context = &This->context; - unsigned old_mask = state->ps ? state->ps->rt_mask : 1; - unsigned mask; + struct NinePixelShader9 *ps = (struct NinePixelShader9*)pShader; DBG("This=%p pShader=%p\n", This, pShader); - if (!This->is_recording && state->ps == (struct NinePixelShader9*)pShader) - return D3D_OK; - - /* ff -> non-ff: commit back non-ff constants */ - if (!state->ps && pShader) - context->commit |= NINE_STATE_COMMIT_CONST_PS; + if (unlikely(This->is_recording)) { + /* Technically we need NINE_STATE_FB only + * if the ps mask changes, but put it always + * to be safe */ + nine_bind(&state->ps, pShader); + state->changed.group |= NINE_STATE_PS | NINE_STATE_FB; + return D3D_OK; + } - nine_bind(&state->ps, pShader); + if (state->ps == ps) + return D3D_OK; - state->changed.group |= NINE_STATE_PS; + nine_bind(&state->ps, ps); - mask = state->ps ? state->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; + nine_context_set_pixel_shader(This, ps); return D3D_OK; } diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c index 65f09ead006..306b2aea722 100644 --- a/src/gallium/state_trackers/nine/nine_ff.c +++ b/src/gallium/state_trackers/nine/nine_ff.c @@ -2038,14 +2038,14 @@ nine_ff_update(struct NineDevice9 *device) struct nine_context *context = &device->context; struct pipe_constant_buffer cb; - DBG("vs=%p ps=%p\n", context->vs, device->state.ps); + DBG("vs=%p ps=%p\n", context->vs, context->ps); /* 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; } - if (!device->state.ps) { + if (!context->ps) { device->ff.ps = nine_ff_get_ps(device); device->state.changed.group |= NINE_STATE_PS; } @@ -2080,7 +2080,7 @@ nine_ff_update(struct NineDevice9 *device) context->commit |= NINE_STATE_COMMIT_CONST_VS; } - if (!device->state.ps) { + if (!context->ps) { nine_ff_load_ps_params(device); cb.buffer_offset = 0; diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index fe4241af3c3..a868f900cb9 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -281,7 +281,7 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device) struct pipe_constant_buffer cb; cb.buffer = NULL; cb.buffer_offset = 0; - cb.buffer_size = device->state.ps->const_used_size; + cb.buffer_size = context->ps->const_used_size; cb.user_buffer = context->ps_const_f; if (context->changed.ps_const_i) { @@ -297,14 +297,14 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device) } /* Upload special constants needed to implement PS1.x instructions like TEXBEM,TEXBEML and BEM */ - if (device->state.ps->bumpenvmat_needed) { + if (context->ps->bumpenvmat_needed) { memcpy(context->ps_lconstf_temp, cb.user_buffer, cb.buffer_size); memcpy(&context->ps_lconstf_temp[4 * 8], &device->context.bumpmap_vars, sizeof(device->context.bumpmap_vars)); cb.user_buffer = context->ps_lconstf_temp; } - if (state->ps->byte_code.version < 0x30 && + if (context->ps->byte_code.version < 0x30 && context->rs[D3DRS_FOGENABLE]) { float *dst = &context->ps_lconstf_temp[4 * 32]; if (cb.user_buffer != context->ps_lconstf_temp) { @@ -383,9 +383,8 @@ prepare_vs(struct NineDevice9 *device, uint8_t shader_changed) static inline uint32_t prepare_ps(struct NineDevice9 *device, uint8_t shader_changed) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; - struct NinePixelShader9 *ps = state->ps; + struct NinePixelShader9 *ps = context->ps; uint32_t changed_group = 0; int has_key_changed = 0; @@ -426,7 +425,7 @@ update_framebuffer(struct NineDevice9 *device, bool is_clear) unsigned w = rt0->desc.Width; unsigned h = rt0->desc.Height; unsigned nr_samples = rt0->base.info.nr_samples; - unsigned ps_mask = state->ps ? state->ps->rt_mask : 1; + unsigned ps_mask = context->ps ? context->ps->rt_mask : 1; unsigned mask = is_clear ? 0xf : ps_mask; const int sRGB = context->rs[D3DRS_SRGBWRITEENABLE] ? 1 : 0; @@ -698,13 +697,12 @@ update_sampler_derived(struct nine_context *context, unsigned s) static void update_textures_and_samplers(struct NineDevice9 *device) { - struct nine_state *state = &device->state; struct nine_context *context = &device->context; struct pipe_sampler_view *view[NINE_MAX_SAMPLERS]; unsigned num_textures; unsigned i; boolean commit_samplers; - uint16_t sampler_mask = state->ps ? state->ps->sampler_mask : + uint16_t sampler_mask = context->ps ? context->ps->sampler_mask : device->ff.ps->sampler_mask; /* TODO: Can we reduce iterations here ? */ @@ -867,7 +865,7 @@ commit_ps_constants(struct NineDevice9 *device) { struct pipe_context *pipe = device->pipe; - if (unlikely(!device->state.ps)) + if (unlikely(!device->context.ps)) pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &device->context.pipe.cb_ps_ff); else pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &device->context.pipe.cb_ps); @@ -969,7 +967,7 @@ nine_update_state(struct NineDevice9 *device) update_managed_buffers(device); /* ff_update may change VS/PS dirty bits */ - if (unlikely(!context->programmable_vs || !state->ps)) + if (unlikely(!context->programmable_vs || !context->ps)) nine_ff_update(device); group = state->changed.group; @@ -1004,7 +1002,7 @@ nine_update_state(struct NineDevice9 *device) update_textures_and_samplers(device); if ((group & (NINE_STATE_VS_CONST | NINE_STATE_VS | NINE_STATE_SWVP)) && context->programmable_vs) prepare_vs_constants_userbuf(device); - if ((group & (NINE_STATE_PS_CONST | NINE_STATE_PS)) && state->ps) + if ((group & (NINE_STATE_PS_CONST | NINE_STATE_PS)) && context->ps) prepare_ps_constants_userbuf(device); } @@ -1370,6 +1368,30 @@ nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device, } 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; + + /* ff -> non-ff: commit back non-ff constants */ + if (!context->ps && ps) + context->commit |= NINE_STATE_COMMIT_CONST_PS; + + nine_bind(&context->ps, ps); + + state->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; +} + +void nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device, UINT StartRegister, const float *pConstantData, @@ -1679,6 +1701,10 @@ nine_context_apply_stateblock(struct NineDevice9 *device, context->programmable_vs = context->vs && !(context->vdecl && context->vdecl->position_t); + /* Pixel shader */ + if (src->changed.group & NINE_STATE_PS) + nine_bind(&context->ps, src->ps); + /* Vertex constants */ if (src->changed.group & NINE_STATE_VS_CONST) { struct nine_range *r; @@ -2351,6 +2377,7 @@ nine_context_clear(struct nine_context *context) nine_bind(&context->rt[i], NULL); nine_bind(&context->ds, NULL); nine_bind(&context->vs, NULL); + nine_bind(&context->ps, NULL); nine_bind(&context->vdecl, NULL); for (i = 0; i < PIPE_MAX_ATTRIBS; ++i) pipe_resource_reference(&context->vtxbuf[i].buffer, NULL); diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 78b12c68a05..acd9ac557e2 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -253,6 +253,7 @@ struct nine_context { BOOL *vs_const_b; float *vs_lconstf_temp; + struct NinePixelShader9 *ps; float *ps_const_f; int ps_const_i[NINE_MAX_CONST_I][4]; BOOL ps_const_b[NINE_MAX_CONST_B]; @@ -374,6 +375,10 @@ nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device, UINT BoolCount); void +nine_context_set_pixel_shader(struct NineDevice9 *device, + struct NinePixelShader9* ps); + +void nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device, UINT StartRegister, const float *pConstantData, |