static void nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq) { struct nv40_context *nv40 = nv40_context(pipe); struct nv40_query *q = nv40_query(pq); assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER); /* Happens when end_query() is called, then another begin_query() * without querying the result in-between. For now we'll wait for * the existing query to notify completion, but it could be better. */ if (q->object) { uint64_t tmp; pipe->get_query_result(pipe, pq, 1, &tmp); } if (nouveau_resource_alloc(nv40->screen->query_heap, 1, NULL, &q->object)) assert(0); nouveau_notifier_reset(nv40->screen->query, q->object->start); BEGIN_RING(curie, NV40TCL_QUERY_RESET, 1); OUT_RING (1); BEGIN_RING(curie, NV40TCL_QUERY_UNK17CC, 1); OUT_RING (1); q->ready = FALSE; }
static boolean nv50_program_validate(struct nv50_context *nv50, struct nv50_program *prog) { struct nouveau_resource *heap; int ret; unsigned size; if (!prog->translated) { prog->translated = nv50_program_translate(prog); if (!prog->translated) return FALSE; } else if (prog->res) return TRUE; if (prog->type == PIPE_SHADER_FRAGMENT) heap = nv50->screen->fp_code_heap; else if (prog->type == PIPE_SHADER_GEOMETRY) heap = nv50->screen->gp_code_heap; else heap = nv50->screen->vp_code_heap; size = align(prog->code_size, 0x100); ret = nouveau_resource_alloc(heap, size, prog, &prog->res); if (ret) { NOUVEAU_ERR("out of code space for shader type %i\n", prog->type); return FALSE; } prog->code_base = prog->res->start; nv50_relocate_program(prog, prog->code_base, 0); nv50_sifc_linear_u8(&nv50->base, nv50->screen->code, (prog->type << NV50_CODE_BO_SIZE_LOG2) + prog->code_base, NOUVEAU_BO_VRAM, prog->code_size, prog->code); BEGIN_RING(nv50->screen->base.channel, RING_3D(CODE_CB_FLUSH), 1); OUT_RING (nv50->screen->base.channel, 0); return TRUE; }
static boolean nv30_vertprog_validate(struct nv30_context *nv30) { struct pipe_screen *pscreen = nv30->pipe.screen; struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv30_vertex_program *vp; struct pipe_buffer *constbuf; boolean upload_code = FALSE, upload_data = FALSE; int i; vp = nv30->vertprog; constbuf = nv30->constbuf[PIPE_SHADER_VERTEX]; /* Translate TGSI shader into hw bytecode */ if (!vp->translated) { nv30_vertprog_translate(nv30, vp); if (!vp->translated) return FALSE; } /* Allocate hw vtxprog exec slots */ if (!vp->exec) { struct nouveau_resource *heap = nv30->screen->vp_exec_heap; struct nouveau_stateobj *so; uint vplen = vp->nr_insns; if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) { while (heap->next && heap->size < vplen) { struct nv30_vertex_program *evict; evict = heap->next->priv; nouveau_resource_free(&evict->exec); } if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) assert(0); } so = so_new(2, 0); so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1); so_data (so, vp->exec->start); so_ref(so, &vp->so); so_ref(NULL, &so); upload_code = TRUE; } /* Allocate hw vtxprog const slots */ if (vp->nr_consts && !vp->data) { struct nouveau_resource *heap = nv30->screen->vp_data_heap; if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) { while (heap->next && heap->size < vp->nr_consts) { struct nv30_vertex_program *evict; evict = heap->next->priv; nouveau_resource_free(&evict->data); } if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) assert(0); } /*XXX: handle this some day */ assert(vp->data->start >= vp->data_start_min); upload_data = TRUE; if (vp->data_start != vp->data->start) upload_code = TRUE; } /* If exec or data segments moved we need to patch the program to * fixup offsets and register IDs. */ if (vp->exec_start != vp->exec->start) { for (i = 0; i < vp->nr_insns; i++) { struct nv30_vertex_program_exec *vpi = &vp->insns[i]; if (vpi->has_branch_offset) { assert(0); } } vp->exec_start = vp->exec->start; } if (vp->nr_consts && vp->data_start != vp->data->start) { for (i = 0; i < vp->nr_insns; i++) { struct nv30_vertex_program_exec *vpi = &vp->insns[i]; if (vpi->const_index >= 0) { vpi->data[1] &= ~NV30_VP_INST_CONST_SRC_MASK; vpi->data[1] |= (vpi->const_index + vp->data->start) << NV30_VP_INST_CONST_SRC_SHIFT; } } vp->data_start = vp->data->start; } /* Update + Upload constant values */ if (vp->nr_consts) { float *map = NULL; if (constbuf) { map = pipe_buffer_map(pscreen, constbuf, PIPE_BUFFER_USAGE_CPU_READ); } for (i = 0; i < vp->nr_consts; i++) { struct nv30_vertex_program_data *vpd = &vp->consts[i]; if (vpd->index >= 0) { if (!upload_data && !memcmp(vpd->value, &map[vpd->index * 4], 4 * sizeof(float))) continue; memcpy(vpd->value, &map[vpd->index * 4], 4 * sizeof(float)); } BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_CONST_ID, 5); OUT_RING (i + vp->data->start); OUT_RINGp ((uint32_t *)vpd->value, 4); } if (constbuf) pipe_buffer_unmap(pscreen, constbuf); } /* Upload vtxprog */ if (upload_code) { #if 0 for (i = 0; i < vp->nr_insns; i++) { NOUVEAU_MSG("VP inst %d: 0x%08x 0x%08x 0x%08x 0x%08x\n", i, vp->insns[i].data[0], vp->insns[i].data[1], vp->insns[i].data[2], vp->insns[i].data[3]); } #endif BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_FROM_ID, 1); OUT_RING (vp->exec->start); for (i = 0; i < vp->nr_insns; i++) { BEGIN_RING(rankine, NV34TCL_VP_UPLOAD_INST(0), 4); OUT_RINGp (vp->insns[i].data, 4); } } if (vp->so != nv30->state.hw[NV30_STATE_VERTPROG]) { so_ref(vp->so, &nv30->state.hw[NV30_STATE_VERTPROG]); return TRUE; } return FALSE; }