summaryrefslogtreecommitdiff
path: root/utests/compiler_copy_image_3d.cpp
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2013-09-13 13:56:54 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-09-18 14:45:43 +0800
commit658f1ae2358e498e0b7e242269bd48b76bd5e34c (patch)
tree513c21905d9d6979a989c25928802868709a36f3 /utests/compiler_copy_image_3d.cpp
parent984e9ba2c2f83ad822699fdcedfb3c95afa38de8 (diff)
downloadbeignet-658f1ae2358e498e0b7e242269bd48b76bd5e34c.tar.gz
Utests: refine the previous fake 3D test cases.
All the previous 3D test cases are only using depth 1, and not really touch the 3D read/write code path. Now fix them. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: He Junyan <junyan.he@inbox.com>
Diffstat (limited to 'utests/compiler_copy_image_3d.cpp')
-rw-r--r--utests/compiler_copy_image_3d.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/utests/compiler_copy_image_3d.cpp b/utests/compiler_copy_image_3d.cpp
index 5290090b..ff493e76 100644
--- a/utests/compiler_copy_image_3d.cpp
+++ b/utests/compiler_copy_image_3d.cpp
@@ -1,10 +1,11 @@
#include "utest_helper.hpp"
+#include "string.h"
static void compiler_copy_image_3d(void)
{
const size_t w = 512;
const size_t h = 512;
- const size_t depth = 1;
+ const size_t depth = 4;
cl_image_format format;
cl_sampler sampler;
@@ -14,12 +15,14 @@ static void compiler_copy_image_3d(void)
for (uint32_t k = 0; k < depth; k++)
for (uint32_t j = 0; j < h; j++)
for (uint32_t i = 0; i < w; i++)
- ((uint32_t*)buf_data[0])[k*w*h + j*w + i] = k*w*h + j*w + i;
+ ((float*)buf_data[0])[k*w*h + j*w + i] = (k << 10) + (j << 10) + i;
format.image_channel_order = CL_RGBA;
- format.image_channel_data_type = CL_UNSIGNED_INT8;
- OCL_CREATE_IMAGE3D(buf[0], CL_MEM_COPY_HOST_PTR, &format, w, h, depth, 0, 0, buf_data[0]);
+ format.image_channel_data_type = CL_UNORM_INT8;
+ OCL_CREATE_IMAGE3D(buf[0], CL_MEM_COPY_HOST_PTR, &format, w, h, depth, w*4, w*h*4, buf_data[0]);
OCL_CREATE_IMAGE3D(buf[1], 0, &format, w, h, depth, 0, 0, NULL);
+ for(uint32_t i = 0; i < depth; i++)
+ OCL_CREATE_IMAGE2D(buf[2 + i], 0, &format, w, h, 0, NULL);
OCL_CREATE_SAMPLER(sampler, CL_ADDRESS_REPEAT, CL_FILTER_NEAREST);
free(buf_data[0]);
buf_data[0] = NULL;
@@ -28,21 +31,28 @@ static void compiler_copy_image_3d(void)
OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
OCL_SET_ARG(2, sizeof(sampler), &sampler);
+ for(uint32_t i = 0; i < depth; i++)
+ OCL_SET_ARG(3 + i, sizeof(cl_mem), &buf[2 + i]);
globals[0] = w;
globals[1] = h;
- locals[0] = 16;
- locals[1] = 16;
- OCL_NDRANGE(2);
+ globals[2] = depth;
+ locals[0] = 64;
+ locals[1] = 1;
+ locals[2] = 1;
+ OCL_NDRANGE(3);
// Check result
- OCL_MAP_BUFFER(0);
- OCL_MAP_BUFFER(1);
+ for(uint32_t i = 0; i < depth + 2; i++)
+ OCL_MAP_BUFFER_GTT(i);
for (uint32_t k = 0; k < depth; k++)
for (uint32_t j = 0; j < h; ++j)
- for (uint32_t i = 0; i < w; i++)
- OCL_ASSERT(((uint32_t*)buf_data[0])[k*w*h + j*w + i] == ((uint32_t*)buf_data[1])[k*w*h + j*w + i]);
- OCL_UNMAP_BUFFER(0);
- OCL_UNMAP_BUFFER(1);
+ for (uint32_t i = 0; i < w; i++) {
+ OCL_ASSERT(((float*)buf_data[0])[k*w*((h+1)&-2LL) + j*w + i] == ((float*)buf_data[1])[k*w*((h+1)&-2LL) + j*w + i]);
+ OCL_ASSERT(((float*)buf_data[0])[k*w*((h+1)&-2LL) + j*w + i] == ((float*)buf_data[k + 2])[j * w + i]);
+ }
+
+ for(uint32_t i = 0; i < depth + 2; i++)
+ OCL_UNMAP_BUFFER_GTT(i);
}
MAKE_UTEST_FROM_FUNCTION(compiler_copy_image_3d);