[Mesa-dev] [PATCH 3/3] r600g: handle unbind of constant buffers

Jerome Glisse j.glisse at gmail.com
Thu Oct 14 10:44:35 PDT 2010


On Thu, Oct 14, 2010 at 12:00 PM, Keith Whitwell
<keith.whitwell at gmail.com> wrote:
> Dave,
>
> Sorry for being confusing, but this patch doesn't actually work - this
> is what I think should be happening, but at the moment I have to
> return early to avoid segfaults on unbinding constant buffers, ie:
>
> +       if (buffer == NULL) {
> +                return;
> +        }
> +        else {
>                width = buffer->width0;
>                offset = r600_bo_offset(rbuffer->bo);
>                bo = rbuffer->bo;
>
>
> Otherwise I end up with a crash here:
>
> #0  r600_context_block_emit_dirty (ctx=0x837cc20, draw=0xbffff1c4)
>    at src/gallium/winsys/r600/drm/r600_priv.h:153
> 153                             r600_context_bo_reloc(ctx,
> (gdb) list
> 148
> 149             for (int j = 0; j < block->nreg; j++) {
> 150                     if (block->pm4_bo_index[j]) {
> 151                             /* find relocation */
> 152                             id = block->pm4_bo_index[j];
> 153                             r600_context_bo_reloc(ctx,
> 154
> &block->pm4[block->reloc[id].bo_pm4_index],
> 155                                             block->reloc[id].bo);
> 156                             r600_context_bo_flush(ctx,
> 157                                             block->reloc[id].flush_flags,
>
>
> I haven't really figured out the state emit mechanism in this driver
> yet...  Have you got any guidance what needs to be done here?
>
> Keith

You want somethings like what's attached, thought maybe unset function
would be cleaner.

The state emit works like that:
pipe driver fill r600_pipe_state with a list of register and their value
once the list is build they summit it to the current context using
r600_context_pipe_state_set(struct r600_context *, struct r600_pipe_state *)
In context struct register are grouped into block, each block is a set
of adjacent register. Context keep track of dirty block (block that needs
to be reemited after a flush), context also keep a ref on buffer associated
to some of the register, so when we want to free a resource we need
to make sure that we unref it in the context part (winsys)

Note that some register are handled through special function rather than
r600_context_pipe_state_set, for instance resource or sampler, this is to
simplify pipe code so pipe code doesn't have to compute right register
offset for each resource but just give resource,sampler, ... id and the
list of value for them.

Hopes it helps a little.

Cheers,
Jerome
-------------- next part --------------
A non-text attachment was scrubbed...
Name: l
Type: application/octet-stream
Size: 1857 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20101014/600106d6/attachment.obj>


More information about the mesa-dev mailing list