diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-31 12:20:18 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-01 02:25:05 +0000 |
commit | b033189dd7d0e2c403ed17b5ec5e76b0c93dbb36 (patch) | |
tree | 444a931ffac17b3cd5355fce1c2fef0d07122419 /src | |
parent | b26214e9075c5b8dfc24118a1724b5dd3bb5e22b (diff) |
pan/bit: Wire through I/O
We'd like to wire in attributes and uniforms as inputs and look at the
varying as output for automatic testing on-device, building up a test
framework for us.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4396>
Diffstat (limited to 'src')
-rw-r--r-- | src/panfrost/bifrost/cmdline.c | 21 | ||||
-rw-r--r-- | src/panfrost/bifrost/test/bi_submit.c | 54 | ||||
-rw-r--r-- | src/panfrost/bifrost/test/bit.h | 13 |
3 files changed, 76 insertions, 12 deletions
diff --git a/src/panfrost/bifrost/cmdline.c b/src/panfrost/bifrost/cmdline.c index a62f230cbba..a0be7605b8b 100644 --- a/src/panfrost/bifrost/cmdline.c +++ b/src/panfrost/bifrost/cmdline.c @@ -103,7 +103,24 @@ test_vertex(char **argv) { void *memctx = NULL; /* TODO */ struct panfrost_device *dev = bit_initialize(memctx); - bit_vertex(dev, compile_shader(argv, true)); + + float iubo[] = { + 0.1, 0.2, 0.3, 0.4 + }; + + float iattr[] = { + 0.5, 0.6, 0.7, 0.8 + }; + + float expected[] = { + 0.6, 0.8, 1.0, 1.2 + }; + + bit_vertex(dev, compile_shader(argv, true), + (uint32_t *) iubo, sizeof(iubo), + (uint32_t *) iattr, sizeof(iattr), + (uint32_t *) expected, sizeof(expected), + BIT_DEBUG_ALL); } static void @@ -133,7 +150,7 @@ run(const char *filename) }, }; - bit_vertex(dev, prog); + bit_vertex(dev, prog, NULL, 0, NULL, 0, NULL, 0, BIT_DEBUG_FAIL); free(code); } diff --git a/src/panfrost/bifrost/test/bi_submit.c b/src/panfrost/bifrost/test/bi_submit.c index 17b7a3600cd..685fca2cb6b 100644 --- a/src/panfrost/bifrost/test/bi_submit.c +++ b/src/panfrost/bifrost/test/bi_submit.c @@ -61,7 +61,7 @@ static bool bit_submit(struct panfrost_device *dev, enum mali_job_type T, void *payload, size_t payload_size, - struct panfrost_bo **bos, size_t bo_count, bool trace) + struct panfrost_bo **bos, size_t bo_count, enum bit_debug debug) { struct mali_job_descriptor_header header = { .job_descriptor_size = MALI_JOB_64, @@ -96,7 +96,7 @@ bit_submit(struct panfrost_device *dev, free(bo_handles); drmSyncobjWait(dev->fd, &syncobj, 1, INT64_MAX, 0, NULL); - if (trace) + if (debug >= BIT_DEBUG_ALL) pandecode_jc(submit.jc, true, dev->gpu_id, false); return true; } @@ -126,7 +126,10 @@ bit_sanity_check(struct panfrost_device *dev) /* Constructs a vertex job */ bool -bit_vertex(struct panfrost_device *dev, panfrost_program prog) +bit_vertex(struct panfrost_device *dev, panfrost_program prog, + uint32_t *iubo, size_t sz_ubo, + uint32_t *iattr, size_t sz_attr, + uint32_t *expected, size_t sz_expected, enum bit_debug debug) { struct panfrost_bo *scratchpad = bit_bo_create(dev, 4096); @@ -155,12 +158,17 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog) memcpy(ubo->cpu, &my_ubo, sizeof(my_ubo)); memcpy(var->cpu, &vmeta, sizeof(vmeta)); + + vmeta.unknown1 = 0x2; /* XXX: only attrib? */ memcpy(attr->cpu, &vmeta, sizeof(vmeta)); memcpy(var->cpu + 256, &vary, sizeof(vary)); memcpy(attr->cpu + 256, &attr_, sizeof(vary)); - float *fvaryings = (float *) (var->cpu + 1024); - float *fubo = (float *) (ubo->cpu + 1024); + if (sz_ubo) + memcpy(ubo->cpu + 1024, iubo, sz_ubo); + + if (sz_attr) + memcpy(attr->cpu + 1024, iattr, sz_attr); struct panfrost_bo *shmem = bit_bo_create(dev, 4096); struct mali_shared_memory shmemp = { @@ -176,11 +184,12 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog) .varying_count = 1, .bifrost1 = { .unk1 = 0x800200, + .uniform_buffer_count = 1, }, .bifrost2 = { .unk3 = 0x0, .preload_regs = 0xc0, - .uniform_count = 0, + .uniform_count = sz_ubo / 16, .unk4 = 0x0, }, }; @@ -200,7 +209,7 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog) .uniforms = ubo->gpu + 1024, .uniform_buffers = ubo->gpu, .attribute_meta = attr->gpu, - .attributes = var->gpu + 256, + .attributes = attr->gpu + 256, .varying_meta = var->gpu, .varyings = var->gpu + 256, }, @@ -217,6 +226,33 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog) scratchpad, shmem, shader, shader_desc, ubo, var, attr }; - return bit_submit(dev, JOB_TYPE_VERTEX, &payload, - sizeof(payload), bos, ARRAY_SIZE(bos), true); + bool succ = bit_submit(dev, JOB_TYPE_VERTEX, &payload, + sizeof(payload), bos, ARRAY_SIZE(bos), debug); + + /* Check the output varyings */ + + if (sz_expected) { + uint32_t *output = (uint32_t *) (var->cpu + 1024); + float *foutput = (float *) output; + float *fexpected = (float *) expected; + + unsigned comp = memcmp(output, expected, sz_expected); + succ &= (comp == 0); + + if (comp && (debug >= BIT_DEBUG_FAIL)) { + fprintf(stderr, "expected ["); + + for (unsigned i = 0; i < (sz_expected >> 2); ++i) + fprintf(stderr, "%08X /* %f */ ", expected[i], fexpected[i]); + + fprintf(stderr, "], got ["); + + for (unsigned i = 0; i < (sz_expected >> 2); ++i) + fprintf(stderr, "%08X /* %f */ ", output[i], foutput[i]); + + fprintf(stderr, "\n"); + } + } + + return succ; } diff --git a/src/panfrost/bifrost/test/bit.h b/src/panfrost/bifrost/test/bit.h index 9dddf4bc1ca..6700bcb228e 100644 --- a/src/panfrost/bifrost/test/bit.h +++ b/src/panfrost/bifrost/test/bit.h @@ -36,7 +36,18 @@ struct panfrost_device * bit_initialize(void *memctx); bool bit_sanity_check(struct panfrost_device *dev); -bool bit_vertex(struct panfrost_device *dev, panfrost_program prog); + +enum bit_debug { + BIT_DEBUG_NONE = 0, + BIT_DEBUG_FAIL, + BIT_DEBUG_ALL +}; + +bool +bit_vertex(struct panfrost_device *dev, panfrost_program prog, + uint32_t *iubo, size_t sz_ubo, + uint32_t *iattr, size_t sz_attr, + uint32_t *expected, size_t sz_expected, enum bit_debug); #endif |