summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_draw.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-09-25 14:57:01 -0700
committerEric Anholt <[email protected]>2014-10-14 11:29:48 +0100
commitb5fc9d5664d08d2e47ae89bf580e43732346a694 (patch)
treea491d70780565b0908ee273b35875b3565af1934 /src/gallium/drivers/vc4/vc4_draw.c
parenta2fd55cfb65d3933c27ed6c2259966a98acc55eb (diff)
vc4: Add support for having 0 vertex elements used.
You have to load at least 1, according to the simulator. Fixes 4 piglit tests and even more ES2 conformance tests.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_draw.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_draw.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/gallium/drivers/vc4/vc4_draw.c b/src/gallium/drivers/vc4/vc4_draw.c
index 1a0c0dc6552..0938a76e000 100644
--- a/src/gallium/drivers/vc4/vc4_draw.c
+++ b/src/gallium/drivers/vc4/vc4_draw.c
@@ -120,8 +120,12 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
&vc4->constbuf[PIPE_SHADER_VERTEX],
&vc4->verttex);
+ /* The simulator throws a fit if VS or CS don't read an attribute, so
+ * we emit a dummy read.
+ */
+ uint32_t num_elements_emit = MAX2(vtx->num_elements, 1);
/* Emit the shader record. */
- cl_start_shader_reloc(&vc4->shader_rec, 3 + vtx->num_elements);
+ cl_start_shader_reloc(&vc4->shader_rec, 3 + num_elements_emit);
cl_u16(&vc4->shader_rec,
VC4_SHADER_FLAG_ENABLE_CLIPPING |
((info->mode == PIPE_PRIM_POINTS &&
@@ -133,14 +137,14 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
cl_u32(&vc4->shader_rec, 0); /* UBO offset written by kernel */
cl_u16(&vc4->shader_rec, 0); /* vs num uniforms */
- cl_u8(&vc4->shader_rec, (1 << vtx->num_elements) - 1); /* vs attribute array bitfield */
- cl_u8(&vc4->shader_rec, 16 * vtx->num_elements); /* vs total attribute size */
+ cl_u8(&vc4->shader_rec, (1 << num_elements_emit) - 1); /* vs attribute array bitfield */
+ cl_u8(&vc4->shader_rec, 16 * num_elements_emit); /* vs total attribute size */
cl_reloc(vc4, &vc4->shader_rec, vc4->prog.vs->bo, 0);
cl_u32(&vc4->shader_rec, 0); /* UBO offset written by kernel */
cl_u16(&vc4->shader_rec, 0); /* cs num uniforms */
- cl_u8(&vc4->shader_rec, (1 << vtx->num_elements) - 1); /* cs attribute array bitfield */
- cl_u8(&vc4->shader_rec, 16 * vtx->num_elements); /* cs total attribute size */
+ cl_u8(&vc4->shader_rec, (1 << num_elements_emit) - 1); /* cs attribute array bitfield */
+ cl_u8(&vc4->shader_rec, 16 * num_elements_emit); /* cs total attribute size */
cl_reloc(vc4, &vc4->shader_rec, vc4->prog.cs->bo, 0);
cl_u32(&vc4->shader_rec, 0); /* UBO offset written by kernel */
@@ -167,13 +171,24 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
}
}
+ if (vtx->num_elements == 0) {
+ assert(num_elements_emit == 1);
+ struct vc4_bo *bo = vc4_bo_alloc(vc4->screen, 4096, "scratch VBO");
+ cl_reloc(vc4, &vc4->shader_rec, bo, 0);
+ cl_u8(&vc4->shader_rec, 16 - 1); /* element size */
+ cl_u8(&vc4->shader_rec, 0); /* stride */
+ cl_u8(&vc4->shader_rec, 0); /* VS VPM offset */
+ cl_u8(&vc4->shader_rec, 0); /* CS VPM offset */
+ vc4_bo_unreference(&bo);
+ }
+
/* the actual draw call. */
cl_u8(&vc4->bcl, VC4_PACKET_GL_SHADER_STATE);
assert(vtx->num_elements <= 8);
/* Note that number of attributes == 0 in the packet means 8
* attributes. This field also contains the offset into shader_rec.
*/
- cl_u32(&vc4->bcl, vtx->num_elements & 0x7);
+ cl_u32(&vc4->bcl, num_elements_emit & 0x7);
/* Note that the primitive type fields match with OpenGL/gallium
* definitions, up to but not including QUADS.