[Beignet] [PATCH] Correct check for optimized copy in clEnqueueReadImage and clEnqueueWriteImage.

Dag Lem dag at nimrod.no
Sat May 18 10:13:40 PDT 2013


Signed-off-by: Dag Lem <dag at nimrod.no>
---
 src/cl_api.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index a134dcc..ff1883c 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1025,7 +1025,10 @@ clEnqueueReadImage(cl_command_queue      command_queue,
   size_t offset = image->bpp*origin[0] + image->row_pitch*origin[1] + image->slice_pitch*origin[2];
   src_ptr = (char*)src_ptr + offset;
 
-  if (row_pitch == image->row_pitch && slice_pitch == image->slice_pitch) {
+  if (!origin[0] && !origin[1] &&
+      region[0] == image->w && region[1] == image->h &&
+      row_pitch == image->row_pitch && slice_pitch == image->slice_pitch)
+  {
     memcpy(ptr, src_ptr, slice_pitch ? slice_pitch*region[2] : row_pitch*region[1]);
   }
   else {
@@ -1117,7 +1120,10 @@ clEnqueueWriteImage(cl_command_queue     command_queue,
   size_t offset = image->bpp*origin[0] + image->row_pitch*origin[1] + image->slice_pitch*origin[2];
   dst_ptr = (char*)dst_ptr + offset;
 
-  if (row_pitch == image->row_pitch && slice_pitch == image->slice_pitch) {
+  if (!origin[0] && !origin[1] &&
+      region[0] == image->w && region[1] == image->h &&
+      row_pitch == image->row_pitch && slice_pitch == image->slice_pitch)
+  {
     memcpy(dst_ptr, ptr, slice_pitch ? slice_pitch*region[2] : row_pitch*region[1]);
   }
   else {
-- 
1.8.1.4



More information about the Beignet mailing list