struct nvc0_program *cp = nvc0->compprog;
int ret;
+ simple_mtx_lock(&screen->state_lock);
ret = !nvc0_state_validate_cp(nvc0, ~0);
if (ret) {
NOUVEAU_ERR("Failed to launch grid !\n");
- return;
+ goto out;
}
nvc0_compute_upload_input(nvc0, info);
nvc0->images_dirty[5] |= nvc0->images_valid[5];
nvc0_update_compute_invocations_counter(nvc0, info);
+
+out:
+ PUSH_KICK(push);
+ simple_mtx_unlock(&screen->state_lock);
}
static void
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
+ simple_mtx_lock(&nvc0->screen->state_lock);
if (nvc0->screen->cur_ctx == nvc0) {
nvc0->screen->cur_ctx = NULL;
nvc0->screen->save_state = nvc0->state;
nvc0->screen->save_state.tfb = NULL;
}
+ simple_mtx_unlock(&nvc0->screen->state_lock);
if (nvc0->base.pipe.stream_uploader)
u_upload_destroy(nvc0->base.pipe.stream_uploader);
/* now that there are no more opportunities for errors, set the current
* context if there isn't already one.
*/
+ simple_mtx_lock(&screen->state_lock);
if (!screen->cur_ctx) {
nvc0->state = screen->save_state;
screen->cur_ctx = nvc0;
}
+ simple_mtx_unlock(&screen->state_lock);
+
nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx);
PUSH_SPACE(nvc0->base.pushbuf, 8);
size += TU102_SHADER_HEADER_SIZE;
}
+ simple_mtx_assert_locked(&nvc0->screen->state_lock);
ret = nvc0_program_alloc_code(nvc0, prog);
if (ret) {
struct nouveau_heap *heap = screen->text_heap;
const struct pipe_shader_state pipe = prog->pipe;
const ubyte type = prog->type;
- if (prog->mem)
+ if (prog->mem) {
+ if (nvc0)
+ simple_mtx_assert_locked(&nvc0->screen->state_lock);
nouveau_heap_free(&prog->mem);
+ }
FREE(prog->code); /* may be 0 for hardcoded shaders */
FREE(prog->relocs);
FREE(prog->fixups);
nouveau_object_del(&screen->nvsw);
nouveau_screen_fini(&screen->base);
+ simple_mtx_destroy(&screen->state_lock);
FREE(screen);
}
pscreen = &screen->base.base;
pscreen->destroy = nvc0_screen_destroy;
+ simple_mtx_init(&screen->state_lock, mtx_plain);
+
ret = nouveau_screen_init(&screen->base, dev);
if (ret)
FAIL_SCREEN_INIT("Base screen init failed: %d\n", ret);
struct nvc0_context *cur_ctx;
struct nvc0_graph_state save_state;
+ simple_mtx_t state_lock;
int num_occlusion_queries_active;
{
struct nouveau_pushbuf *push = nvc0->base.pushbuf;
+ simple_mtx_assert_locked(&nvc0->screen->state_lock);
if (nvc0->screen->eng3d->oclass < GV100_3D_CLASS) {
BEGIN_NVC0(push, NVC0_3D(SP_START_ID(stage)), 1);
PUSH_DATA (push, prog->code_base);
}
}
}
+
+ simple_mtx_assert_locked(&nvc0->screen->state_lock);
nvc0->state.tfb = tfb;
if (!(nvc0->dirty_3d & NVC0_NEW_3D_TFB_TARGETS))
static void
nvc0_sp_state_delete(struct pipe_context *pipe, void *hwcso)
{
+ struct nvc0_context *nvc0 = nvc0_context(pipe);
struct nvc0_program *prog = (struct nvc0_program *)hwcso;
+ simple_mtx_lock(&nvc0->screen->state_lock);
nvc0_program_destroy(nvc0_context(pipe), prog);
+ simple_mtx_unlock(&nvc0->screen->state_lock);
if (prog->pipe.type == PIPE_SHADER_IR_TGSI)
FREE((void *)prog->pipe.tokens);
struct nvc0_context *ctx_from = ctx_to->screen->cur_ctx;
unsigned s;
+ simple_mtx_assert_locked(&ctx_to->screen->state_lock);
if (ctx_from)
ctx_to->state = ctx_from->state;
else
int ret;
unsigned i;
+ simple_mtx_assert_locked(&nvc0->screen->state_lock);
+
if (nvc0->screen->cur_ctx != nvc0)
nvc0_switch_pipe_context(nvc0);
unsigned i, j, k;
uint32_t mode = 0;
+ simple_mtx_lock(&nvc0->screen->state_lock);
+
/* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */
if (!nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER))
- return;
+ goto out;
if (scissor_state) {
uint32_t minx = scissor_state->minx;
uint32_t miny = scissor_state->miny;
uint32_t maxy = MIN2(fb->height, scissor_state->maxy);
if (maxx <= minx || maxy <= miny)
- return;
+ goto out;
BEGIN_NVC0(push, NVC0_3D(SCREEN_SCISSOR_HORIZ), 2);
PUSH_DATA (push, minx | (maxx - minx) << 16);
PUSH_DATA (push, fb->width << 16);
PUSH_DATA (push, fb->height << 16);
}
+
+out:
+ PUSH_KICK(push);
+ simple_mtx_unlock(&nvc0->screen->state_lock);
}
static void
struct nvc0_context *nvc0 = nvc0_context(pipe);
struct nouveau_pushbuf *push = nvc0->base.pushbuf;
+ simple_mtx_lock(&nvc0->screen->state_lock);
nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER);
IMMED_NVC0(push, SUBC_3D(0x11fc), 1);
+ PUSH_KICK(push);
+ simple_mtx_unlock(&nvc0->screen->state_lock);
}
if (info->num_window_rectangles > 0 || info->window_rectangle_include)
eng3d = true;
+ simple_mtx_lock(&nvc0->screen->state_lock);
if (nvc0->screen->num_occlusion_queries_active)
IMMED_NVC0(push, NVC0_3D(SAMPLECNT_ENABLE), 0);
if (nvc0->screen->num_occlusion_queries_active)
IMMED_NVC0(push, NVC0_3D(SAMPLECNT_ENABLE), 1);
+ PUSH_KICK(push);
+ simple_mtx_unlock(&nvc0->screen->state_lock);
NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_blit_count, 1);
}
if (update_vertex) {
const unsigned n = MAX2(vertex->num_elements, nvc0->state.num_vtxelts);
+ simple_mtx_assert_locked(&nvc0->screen->state_lock);
nvc0->state.constant_vbos = const_vbos;
nvc0->state.constant_elts = 0;
nvc0->state.num_vtxelts = vertex->num_elements;
BCTX_REFN_bo(nvc0->bufctx_3d, 3D_TEXT, vram_domain | NOUVEAU_BO_RD,
screen->text);
+ simple_mtx_lock(&nvc0->screen->state_lock);
+
nvc0_state_validate_3d(nvc0, ~0);
if (nvc0->vertprog->vp.need_draw_parameters && (!indirect || indirect->count_from_stream_output)) {
}
cleanup:
+ PUSH_KICK(push);
+ simple_mtx_unlock(&nvc0->screen->state_lock);
+
nvc0->base.kick_notify = nvc0_default_kick_notify;
nvc0_release_user_vbufs(nvc0);
resident->flags);
}
+ simple_mtx_lock(&screen->state_lock);
ret = !nve4_state_validate_cp(nvc0, ~0);
if (ret)
- goto out;
+ goto out_unlock;
if (nvc0->screen->compute->oclass >= GV100_COMPUTE_CLASS)
gv100_compute_setup_launch_desc(nvc0, desc, info);
nvc0_update_compute_invocations_counter(nvc0, info);
+out_unlock:
+ PUSH_KICK(push);
+ simple_mtx_unlock(&screen->state_lock);
+
out:
if (ret)
NOUVEAU_ERR("Failed to launch grid !\n");