vc4: Add kernel support for branching in shader validation.
authorEric Anholt <eric@anholt.net>
Tue, 15 Mar 2016 20:53:02 +0000 (13:53 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 13 Jul 2016 00:42:39 +0000 (17:42 -0700)
commit54800bb71c874bc7e9953a2e6d29ea53915f5be7
tree1539b95c3be9b7d015cfbe30642ad0e11db570a2
parente2d7760df5a65ce6ab119e026725c809b8e8bfe3
vc4: Add kernel support for branching in shader validation.

We're already checking that branch instructions are within the
contents of the shader and the proper PROG_END sequence is present.
The other thing we need in the presence of branching is to verify that
the shader doesn't overflow past the end of the uniforms stream.

To do that, we require that at the start of any basic block reading
uniforms have the following instructions:

load_imm temp, <offset within uniform stream>
add unif_addr, temp, unif

The instructions are generated by userspace, and the kernel verifies
that the load_imm is of the expected offset, and that the add adds it
to a uniform.  We track which uniform in the stream that is, and at
draw call time fix up the uniform stream to have the address of the
start of the shader's uniforms for that draw call.

Signed-off-by: Eric Anholt <eric@anholt.net>
src/gallium/drivers/vc4/kernel/vc4_drv.h
src/gallium/drivers/vc4/kernel/vc4_validate.c
src/gallium/drivers/vc4/kernel/vc4_validate_shaders.c