Previously nine_state_clear was not using
NineBindBufferToDevice and NineBindTextureToDevice
to unbind buffers and textures (but used nine_bind)
This was resulting in an uncorrect bind count for these
resources.
Combined with
0ec4e5f630ed68ece3f176b174cfd66eff023904
Some buffers were scheduled to be uploaded directly
after they were locked (because the bind count incorrectly
assumed they were needed for the next draw call),
which resulted in uploads before the data was written.
To simplify a bit the code (and because I needed to
add a pointer to device),
remove the stateblock usage from nine_state_clear and
rename to nine_device_state_clear.
Fixes:
https://github.com/iXit/Mesa-3D/issues/345
Signed-off-by: Axel Davy <davyaxel0@gmail.com>
nine_ff_fini(This);
nine_state_destroy_sw(This);
- nine_state_clear(&This->state, TRUE);
+ nine_device_state_clear(This);
nine_context_clear(This);
nine_bind(&This->record, NULL);
}
nine_csmt_process(This);
- nine_state_clear(&This->state, TRUE);
+ nine_device_state_clear(This);
nine_context_clear(This);
NineDevice9_SetDefaultState(This, TRUE);
}
nine_csmt_process(&This->base);
- nine_state_clear(&This->base.state, TRUE);
+ nine_device_state_clear((struct NineDevice9 *)This);
nine_context_clear(&This->base);
NineDevice9_SetDefaultState((struct NineDevice9 *)This, TRUE);
}
void
-nine_state_clear(struct nine_state *state, const boolean device)
+nine_device_state_clear(struct NineDevice9 *device)
{
+ struct nine_state *state = &device->state;
unsigned i;
for (i = 0; i < ARRAY_SIZE(state->rt); ++i)
nine_bind(&state->ps, NULL);
nine_bind(&state->vdecl, NULL);
for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
- nine_bind(&state->stream[i], NULL);
-
- nine_bind(&state->idxbuf, NULL);
- for (i = 0; i < NINE_MAX_SAMPLERS; ++i) {
- if (device &&
- state->texture[i] &&
- --state->texture[i]->bind_count == 0)
- list_delinit(&state->texture[i]->list);
- nine_bind(&state->texture[i], NULL);
- }
+ NineBindBufferToDevice(device,
+ (struct NineBuffer9 **)&state->stream[i],
+ NULL);
+ NineBindBufferToDevice(device,
+ (struct NineBuffer9 **)&state->idxbuf,
+ NULL);
+
+ for (i = 0; i < NINE_MAX_SAMPLERS; ++i)
+ NineBindTextureToDevice(device, &state->texture[i], NULL);
}
void
void nine_state_restore_non_cso(struct NineDevice9 *device);
void nine_state_set_defaults(struct NineDevice9 *, const D3DCAPS9 *,
boolean is_reset);
-void nine_state_clear(struct nine_state *, const boolean device);
+void nine_device_state_clear(struct NineDevice9 *);
void nine_context_clear(struct NineDevice9 *);
void nine_state_init_sw(struct NineDevice9 *device);
struct nine_state *state = &This->state;
struct nine_range *r;
struct nine_range_pool *pool = &This->base.device->range_pool;
+ unsigned i;
- nine_state_clear(state, false);
+ for (i = 0; i < ARRAY_SIZE(state->rt); ++i)
+ nine_bind(&state->rt[i], NULL);
+ nine_bind(&state->ds, NULL);
+ nine_bind(&state->vs, NULL);
+ nine_bind(&state->ps, NULL);
+ nine_bind(&state->vdecl, NULL);
+ for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
+ nine_bind(&state->stream[i], NULL);
+
+ nine_bind(&state->idxbuf, NULL);
+ for (i = 0; i < NINE_MAX_SAMPLERS; ++i)
+ nine_bind(&state->texture[i], NULL);
FREE(state->vs_const_f);
FREE(state->ps_const_f);