struct pipe_stream_output_target *target;
struct pipe_draw_info draw;
struct pipe_box box;
+ bool programmable_vs = This->state.vs && !(This->state.vdecl && This->state.vdecl->position_t);
unsigned offsets[1] = {0};
HRESULT hr;
unsigned buffer_size;
}
- vs = This->state.programmable_vs ? This->state.vs : This->ff.vs;
+ vs = programmable_vs ? This->state.vs : This->ff.vs;
/* Note: version is 0 for ff */
user_assert(vdecl || (vs->byte_code.version < 0x30 && dst->desc.FVF),
D3DERR_INVALIDCALL);
* if not set, everything from src will be used, and dst
* must match exactly the ff vs outputs.
* TODO: Handle all the checks, etc for ff */
- user_assert(vdecl->position_t || This->state.programmable_vs,
+ user_assert(vdecl->position_t || programmable_vs,
D3DERR_INVALIDCALL);
/* TODO: Support vs < 3 and ff */
IDirect3DVertexShader9 *pShader )
{
struct nine_state *state = This->update;
- struct nine_context *context = &This->context;
- BOOL was_programmable_vs = This->state.programmable_vs;
+ struct NineVertexShader9 *vs_shader = (struct NineVertexShader9*)pShader;
DBG("This=%p pShader=%p\n", This, pShader);
- if (!This->is_recording && state->vs == (struct NineVertexShader9*)pShader)
- return D3D_OK;
-
- nine_bind(&state->vs, pShader);
+ if (unlikely(This->is_recording)) {
+ nine_bind(&state->vs, vs_shader);
+ state->changed.group |= NINE_STATE_VS;
+ return D3D_OK;
+ }
- This->state.programmable_vs = This->state.vs && !(This->context.vdecl && This->context.vdecl->position_t);
+ if (state->vs == vs_shader)
+ return D3D_OK;
- /* ff -> non-ff: commit back non-ff constants */
- if (!was_programmable_vs && This->state.programmable_vs)
- context->commit |= NINE_STATE_COMMIT_CONST_VS;
+ nine_bind(&state->vs, vs_shader);
- state->changed.group |= NINE_STATE_VS;
+ nine_context_set_vertex_shader(This, vs_shader);
return D3D_OK;
}
cb.buffer_size = 4096 * sizeof(float[4]);
cb.user_buffer = state->vs_const_f_swvp;
- if (state->vs->lconstf.ranges) {
- const struct nine_lconstf *lconstf = &device->state.vs->lconstf;
+ if (context->vs->lconstf.ranges) {
+ const struct nine_lconstf *lconstf = &(context->vs->lconstf);
const struct nine_range *r = lconstf->ranges;
unsigned n = 0;
float *dst = device->state.vs_lconstf_temp;
struct pipe_constant_buffer cb;
cb.buffer = NULL;
cb.buffer_offset = 0;
- cb.buffer_size = device->state.vs->const_used_size;
+ cb.buffer_size = context->vs->const_used_size;
cb.user_buffer = device->state.vs_const_f;
if (device->swvp) {
if (!cb.buffer_size)
return;
- if (device->state.vs->lconstf.ranges) {
+ if (context->vs->lconstf.ranges) {
/* TODO: Can we make it so that we don't have to copy everything ? */
- const struct nine_lconstf *lconstf = &device->state.vs->lconstf;
+ const struct nine_lconstf *lconstf = &(context->vs->lconstf);
const struct nine_range *r = lconstf->ranges;
unsigned n = 0;
float *dst = device->state.vs_lconstf_temp;
static inline uint32_t
prepare_vs(struct NineDevice9 *device, uint8_t shader_changed)
{
- struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
- struct NineVertexShader9 *vs = state->vs;
+ struct NineVertexShader9 *vs = context->vs;
uint32_t changed_group = 0;
int has_key_changed = 0;
- if (likely(state->programmable_vs))
+ if (likely(context->programmable_vs))
has_key_changed = NineVertexShader9_UpdateKey(vs, device);
if (!shader_changed && !has_key_changed)
return 0;
/* likely because we dislike FF */
- if (likely(state->programmable_vs)) {
+ if (likely(context->programmable_vs)) {
context->cso.vs = NineVertexShader9_GetVariant(vs);
} else {
vs = device->ff.vs;
context->stream_usage_mask = 0;
memset(vdecl_index_map, -1, 16);
memset(used_streams, 0, device->caps.MaxStreams);
- vs = state->programmable_vs ? device->state.vs : device->ff.vs;
+ vs = context->programmable_vs ? context->vs : device->ff.vs;
if (vdecl) {
for (n = 0; n < vs->num_inputs; ++n) {
cso_single_sampler_done(device->cso, PIPE_SHADER_FRAGMENT);
commit_samplers = FALSE;
- sampler_mask = state->programmable_vs ? state->vs->sampler_mask : 0;
+ sampler_mask = context->programmable_vs ? context->vs->sampler_mask : 0;
context->bound_samplers_mask_vs = 0;
for (num_textures = 0, i = 0; i < NINE_MAX_SAMPLERS_VS; ++i) {
const unsigned s = NINE_SAMPLER_VS(i);
{
struct pipe_context *pipe = device->pipe;
- if (unlikely(!device->state.programmable_vs))
+ if (unlikely(!device->context.programmable_vs))
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &device->context.pipe.cb_vs_ff);
else {
if (device->swvp) {
update_managed_buffers(device);
/* ff_update may change VS/PS dirty bits */
- if (unlikely(!state->programmable_vs || !state->ps))
+ if (unlikely(!context->programmable_vs || !state->ps))
nine_ff_update(device);
group = state->changed.group;
prepare_rasterizer(device);
if (group & (NINE_STATE_TEXTURE | NINE_STATE_SAMPLER))
update_textures_and_samplers(device);
- if ((group & (NINE_STATE_VS_CONST | NINE_STATE_VS | NINE_STATE_SWVP)) && state->programmable_vs)
+ 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)
prepare_ps_constants_userbuf(device);
{
struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
- BOOL was_programmable_vs = device->state.programmable_vs;
+ BOOL was_programmable_vs = context->programmable_vs;
nine_bind(&context->vdecl, vdecl);
- device->state.programmable_vs = device->state.vs && !(device->context.vdecl && device->context.vdecl->position_t);
- if (was_programmable_vs != device->state.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;
}
state->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;
+
+ nine_bind(&context->vs, pShader);
+
+ context->programmable_vs = context->vs && !(context->vdecl && context->vdecl->position_t);
+
+ /* ff -> non-ff: commit back non-ff constants */
+ if (!was_programmable_vs && context->programmable_vs)
+ context->commit |= NINE_STATE_COMMIT_CONST_VS;
+
+ state->changed.group |= NINE_STATE_VS;
+}
+
void
nine_context_apply_stateblock(struct NineDevice9 *device,
const struct nine_state *src)
if ((src->changed.group & NINE_STATE_VDECL) && src->vdecl)
nine_context_set_vertex_declaration(device, src->vdecl);
- device->state.programmable_vs = device->state.vs && !(context->vdecl && context->vdecl->position_t);
+ /* Vertex shader */
+ if (src->changed.group & NINE_STATE_VS)
+ nine_bind(&context->vs, src->vs);
+
+ context->programmable_vs = context->vs && !(context->vdecl && context->vdecl->position_t);
}
static void
{
unsigned i;
+ nine_bind(&context->vs, NULL);
nine_bind(&context->vdecl, NULL);
for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
pipe_resource_reference(&context->vtxbuf[i].buffer, NULL);
int dummy_vbo_stream = -1;
BOOL need_dummy_vbo = FALSE;
struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS];
+ bool programmable_vs = state->vs && !(state->vdecl && state->vdecl->position_t);
memset(vdecl_index_map, -1, 16);
memset(used_streams, 0, device->caps.MaxStreams);
- vs = state->programmable_vs ? device->state.vs : device->ff.vs;
+ vs = programmable_vs ? device->state.vs : device->ff.vs;
if (vdecl) {
for (n = 0; n < vs->num_inputs; ++n) {
int start_vertice, int num_vertices, struct pipe_stream_output_info *so)
{
struct nine_state *state = &device->state;
+ bool programmable_vs = state->vs && !(state->vdecl && state->vdecl->position_t);
+ struct NineVertexShader9 *vs = programmable_vs ? device->state.vs : device->ff.vs;
- struct NineVertexShader9 *vs = state->programmable_vs ? device->state.vs : device->ff.vs;
-
- assert(state->programmable_vs);
+ assert(programmable_vs);
DBG("Preparing draw\n");
cso_set_vertex_shader_handle(device->cso_sw,