Skip to content

Commit

Permalink
st/nine: Fix nine_state_clear
Browse files Browse the repository at this point in the history
Improve nine_state_clear by calling
NineBindBufferToDevice and NineBindTextureToDevice
instead of nine_bind for buffers and textures.
This fixes the bind count for them.

To simplify (and because we need a pointer to device),
remove the stateblock usage from nine_state_clear and
rename to nine_device_state_clear.

Fixes:
#345

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
  • Loading branch information
axeldavy committed Apr 4, 2019
1 parent 5c3b633 commit 8d75be2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/gallium/state_trackers/nine/device9.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ NineDevice9_dtor( struct NineDevice9 *This )

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);
Expand Down Expand Up @@ -909,7 +909,7 @@ NineDevice9_Reset( struct NineDevice9 *This,
}

nine_csmt_process(This);
nine_state_clear(&This->state, TRUE);
nine_device_state_clear(This);
nine_context_clear(This);

NineDevice9_SetDefaultState(This, TRUE);
Expand Down
2 changes: 1 addition & 1 deletion src/gallium/state_trackers/nine/device9ex.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ NineDevice9Ex_Reset( struct NineDevice9Ex *This,
}

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);
Expand Down
22 changes: 11 additions & 11 deletions src/gallium/state_trackers/nine/nine_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -2880,8 +2880,9 @@ nine_state_set_defaults(struct NineDevice9 *device, const D3DCAPS9 *caps,
}

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)
Expand All @@ -2891,16 +2892,15 @@ nine_state_clear(struct nine_state *state, const boolean device)
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
Expand Down
2 changes: 1 addition & 1 deletion src/gallium/state_trackers/nine/nine_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ nine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *que
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);
Expand Down
14 changes: 13 additions & 1 deletion src/gallium/state_trackers/nine/stateblock9.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,20 @@ NineStateBlock9_dtor( struct NineStateBlock9 *This )
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);
Expand Down

0 comments on commit 8d75be2

Please sign in to comment.