[Mesa-dev] [PATCH] i965: Use the predicate enable bit for conditional rendering without stalling

Daniel Vetter daniel at ffwll.ch
Sun Nov 9 07:34:17 PST 2014


On Fri, Nov 07, 2014 at 03:28:01PM +0000, Neil Roberts wrote:
> Previously whenever a primitive is drawn the driver would call
> _mesa_check_conditional_render which blocks waiting for the result of the
> query to determine whether to render. On Gen7+ there is a bit in the
> 3DPRIMITIVE command which can be used to disable the primitive based on the
> value of a state bit. This state bit can be set based on whether two registers
> have different values using the MI_PREDICATE command. We can load these two
> registers with the pixel count values stored in the query begin and end to
> implement conditional rendering without stalling.
> 
> Unfortunately these two source registers are not in the whitelist of available
> registers in the kernel driver so this needs a kernel patch to work. This
> patch tries to check whether it is possible to write to this register by
> creating a DRM buffer with a single command to write to the register and then
> trying to exec it. The return value of the exec function (and hence the ioctl)
> is checked.
> 
> There is a function with a similar goal just above to check whether the
> OACONTROL register can be used. This works by putting the test command in the
> regular batch buffer and trying to compare whether the value was successfully
> written. I couldn't get this approach to work because intel_batchbuffer_flush
> actually calls exit() if the ioctl fails. I am suspicious that this approach
> doesn't work for OACONTROL either.

Atm the cmd parser for gen7 validates the batch and rejects it if there's
something in there it doesn't like. But it doesn't grant any additional
privs. Hence
- OACONTROL passes since it's in the whitelist, but since the cmd parser
  doesn't grant the needed privs the writes would need.
- your new regs aren't in the whitelist, so the execbuf fails with
  -EINVAL.

We have a cmd parser version which we intend to bump every time we add new
registers, so probably better to check that. And I guess we'd need one to
indicate that the cmd parser actually does something useful. Probably best
done with just another bump. And if we do that we could replace the
current trick mesa uses with just a getparam query - the getparam is fixed
so either returns -EINVAL on old kernels or the cmd parser version.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the mesa-dev mailing list