diff options
author | Eric Anholt <[email protected]> | 2014-08-01 11:24:29 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-11 14:45:31 -0700 |
commit | c047f1360306e0e25d2500ae13e2424254a47dbd (patch) | |
tree | 416c62babf3e7f7d843fe18dd37a766b1ddc4cfc | |
parent | 766ca5c7a5a28e6f7c0b37d6408e54f3d86b77b8 (diff) |
vc4: Align following shader recs to 16 bytes.
Otherwise, the low address bits will end up being interpreted as attribute
counts.
-rw-r--r-- | src/gallium/drivers/vc4/vc4_simulator_validate.c | 11 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_simulator_validate.h | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/gallium/drivers/vc4/vc4_simulator_validate.c b/src/gallium/drivers/vc4/vc4_simulator_validate.c index e16b3728eac..a660f94c58a 100644 --- a/src/gallium/drivers/vc4/vc4_simulator_validate.c +++ b/src/gallium/drivers/vc4/vc4_simulator_validate.c @@ -143,7 +143,8 @@ validate_gl_shader_state(VALIDATE_ARGS) *(uint32_t *)validated = (exec->shader_rec_p + exec->shader_state[i].addr); - exec->shader_rec_p += gl_shader_rec_size(exec->shader_state[i].addr); + exec->shader_rec_p += + roundup(gl_shader_rec_size(exec->shader_state[i].addr), 16); return 0; } @@ -461,7 +462,13 @@ validate_shader_rec(struct drm_device *dev, pkt_v = exec->shader_rec_v; memcpy(pkt_v, pkt_u, packet_size); exec->shader_rec_u += packet_size; - exec->shader_rec_v += packet_size; + /* Shader recs have to be aligned to 16 bytes (due to the attribute + * flags being in the low bytes), so round the next validated shader + * rec address up. This should be safe, since we've got so many + * relocations in a shader rec packet. + */ + BUG_ON(roundup(packet_size, 16) - packet_size > nr_relocs * 4); + exec->shader_rec_v += roundup(packet_size, 16); exec->shader_rec_size -= packet_size; for (i = 0; i < nr_relocs; i++) { diff --git a/src/gallium/drivers/vc4/vc4_simulator_validate.h b/src/gallium/drivers/vc4/vc4_simulator_validate.h index 28dd2f65e70..52f664adbc1 100644 --- a/src/gallium/drivers/vc4/vc4_simulator_validate.h +++ b/src/gallium/drivers/vc4/vc4_simulator_validate.h @@ -41,6 +41,7 @@ #define kfree(ptr) free(ptr) #define krealloc(ptr, size, args) realloc(ptr, size) #define roundup(x, y) align(x, y) +#define BUG_ON(condition) assert(!(condition)) static inline int copy_from_user(void *dst, void *src, size_t size) |