extern void nvc0_init_state_functions(struct nvc0_context *);
/* nvc0_state_validate.c */
-bool nvc0_state_validate(struct nvc0_context *, uint32_t state_mask);
+struct nvc0_state_validate {
+ void (*func)(struct nvc0_context *);
+ uint32_t states;
+};
+
+bool nvc0_state_validate(struct nvc0_context *, uint32_t,
+ struct nvc0_state_validate *, int, uint32_t *,
+ struct nouveau_bufctx *);
+bool nvc0_state_validate_3d(struct nvc0_context *, uint32_t);
/* nvc0_surface.c */
extern void nvc0_clear(struct pipe_context *, unsigned buffers,
ctx_to->screen->cur_ctx = ctx_to;
}
-static struct state_validate {
- void (*func)(struct nvc0_context *);
- uint32_t states;
-} validate_list[] = {
+static struct nvc0_state_validate
+validate_list_3d[] = {
{ nvc0_validate_fb, NVC0_NEW_3D_FRAMEBUFFER },
{ nvc0_validate_blend, NVC0_NEW_3D_BLEND },
{ nvc0_validate_zsa, NVC0_NEW_3D_ZSA },
};
bool
-nvc0_state_validate(struct nvc0_context *nvc0, uint32_t mask)
+nvc0_state_validate(struct nvc0_context *nvc0, uint32_t mask,
+ struct nvc0_state_validate *validate_list, int size,
+ uint32_t *dirty, struct nouveau_bufctx *bufctx)
{
uint32_t state_mask;
int ret;
if (nvc0->screen->cur_ctx != nvc0)
nvc0_switch_pipe_context(nvc0);
- state_mask = nvc0->dirty_3d & mask;
+ state_mask = *dirty & mask;
if (state_mask) {
- for (i = 0; i < ARRAY_SIZE(validate_list); ++i) {
- struct state_validate *validate = &validate_list[i];
+ for (i = 0; i < size; ++i) {
+ struct nvc0_state_validate *validate = &validate_list[i];
if (state_mask & validate->states)
validate->func(nvc0);
}
- nvc0->dirty_3d &= ~state_mask;
+ *dirty &= ~state_mask;
- nvc0_bufctx_fence(nvc0, nvc0->bufctx_3d, false);
+ nvc0_bufctx_fence(nvc0, bufctx, false);
}
- nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx_3d);
+ nouveau_pushbuf_bufctx(nvc0->base.pushbuf, bufctx);
ret = nouveau_pushbuf_validate(nvc0->base.pushbuf);
+ return !ret;
+}
+
+bool
+nvc0_state_validate_3d(struct nvc0_context *nvc0, uint32_t mask)
+{
+ bool ret;
+
+ ret = nvc0_state_validate(nvc0, mask, validate_list_3d,
+ ARRAY_SIZE(validate_list_3d), &nvc0->dirty_3d,
+ nvc0->bufctx_3d);
+
if (unlikely(nvc0->state.flushed)) {
nvc0->state.flushed = false;
nvc0_bufctx_fence(nvc0, nvc0->bufctx_3d, true);
}
- return !ret;
+ return ret;
}
uint32_t mode = 0;
/* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */
- if (!nvc0_state_validate(nvc0, NVC0_NEW_3D_FRAMEBUFFER))
+ if (!nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER))
return;
if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) {
nvc0_blitctx_prepare_state(blit);
- nvc0_state_validate(nvc0, ~0);
+ nvc0_state_validate_3d(nvc0, ~0);
x_range = (float)info->src.box.width / (float)info->dst.box.width;
y_range = (float)info->src.box.height / (float)info->dst.box.height;