Fix T54001: AMD OpenCL fails with certain resolutions, after recent changes.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 5 Feb 2018 21:13:08 +0000 (22:13 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 5 Feb 2018 21:19:49 +0000 (22:19 +0100)
We should actually be using CL_DEVICE_MEM_BASE_ADDR_ALIGN for sub buffers,
previous change in this code was incorrect. Renamed the function now to
make the specific purpose of this alignment clear, it's not required for
data types in general.

intern/cycles/device/device.h
intern/cycles/device/device_cpu.cpp
intern/cycles/device/device_denoising.cpp
intern/cycles/device/opencl/opencl.h
intern/cycles/device/opencl/opencl_base.cpp
intern/cycles/device/opencl/opencl_util.cpp

index 99e80d104245d1ed5fb8687ed94674339afdd93d..555fd5ec2d21ddc878b6856ed62f5c865e553034 100644 (file)
@@ -288,7 +288,7 @@ public:
        Stats &stats;
 
        /* memory alignment */
-       virtual int mem_address_alignment() { return MIN_ALIGNMENT_CPU_DATA_TYPES; }
+       virtual int mem_sub_ptr_alignment() { return MIN_ALIGNMENT_CPU_DATA_TYPES; }
 
        /* constant memory */
        virtual void const_copy_to(const char *name, void *host, size_t size) = 0;
index fd55ec3687ae161171d4cec38260bff1fa8d1fff..6be60f8bbb6ec096c190968059dc87abec854664 100644 (file)
@@ -299,7 +299,7 @@ public:
 
                        if(mem.type == MEM_DEVICE_ONLY) {
                                assert(!mem.host_pointer);
-                               size_t alignment = mem_address_alignment();
+                               size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES;
                                void *data = util_aligned_malloc(mem.memory_size(), alignment);
                                mem.device_pointer = (device_ptr)data;
                        }
index 1862deb9a61b2e9eab3e03dd917051936d050fd8..644cf6cd10e8d903d011612fd716ea9ed596c605 100644 (file)
@@ -95,7 +95,7 @@ bool DenoisingTask::run_denoising()
        buffer.width = rect.z - rect.x;
        buffer.stride = align_up(buffer.width, 4);
        buffer.h = rect.w - rect.y;
-       buffer.pass_stride = align_up(buffer.stride * buffer.h, divide_up(device->mem_address_alignment(), sizeof(float)));
+       buffer.pass_stride = align_up(buffer.stride * buffer.h, divide_up(device->mem_sub_ptr_alignment(), sizeof(float)));
        buffer.mem.alloc_to_device(buffer.pass_stride * buffer.passes, false);
 
        device_ptr null_ptr = (device_ptr) 0;
index f38c2f65c1e7f450734e5ac1d9a08c5d2f243829..85ef14ee29ad489ad603e21fffbd93f80c90a2e1 100644 (file)
@@ -140,7 +140,7 @@ public:
                                       int *minor,
                                       cl_int* error = NULL);
 
-       static int mem_address_alignment(cl_device_id device_id);
+       static int mem_sub_ptr_alignment(cl_device_id device_id);
 
        /* Get somewhat more readable device name.
         * Main difference is AMD OpenCL here which only gives code name
@@ -346,7 +346,7 @@ public:
        void mem_zero(device_memory& mem);
        void mem_free(device_memory& mem);
 
-       int mem_address_alignment();
+       int mem_sub_ptr_alignment();
 
        void const_copy_to(const char *name, void *host, size_t size);
        void tex_alloc(device_memory& mem);
index 7de78d413ed8b6c865f440f19661a5f3636c7571..bfa2702ad6211e7dd37d814bf573f6669c7d110a 100644 (file)
@@ -473,9 +473,9 @@ void OpenCLDeviceBase::mem_free(device_memory& mem)
        }
 }
 
-int OpenCLDeviceBase::mem_address_alignment()
+int OpenCLDeviceBase::mem_sub_ptr_alignment()
 {
-       return OpenCLInfo::mem_address_alignment(cdDevice);
+       return OpenCLInfo::mem_sub_ptr_alignment(cdDevice);
 }
 
 device_ptr OpenCLDeviceBase::mem_alloc_sub_ptr(device_memory& mem, int offset, int size)
index 7db6fa0c4168c8de285f91c977f732d6c35098da..a776f48b5e95438c4661ba260cd2ce6dafac4671 100644 (file)
@@ -1136,16 +1136,16 @@ bool OpenCLInfo::get_driver_version(cl_device_id device_id,
        return true;
 }
 
-int OpenCLInfo::mem_address_alignment(cl_device_id device_id)
+int OpenCLInfo::mem_sub_ptr_alignment(cl_device_id device_id)
 {
-       int base_align_bytes;
+       int base_align_bits;
        if(clGetDeviceInfo(device_id,
-                          CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE,
+                          CL_DEVICE_MEM_BASE_ADDR_ALIGN,
                           sizeof(int),
-                          &base_align_bytes,
+                          &base_align_bits,
                           NULL) == CL_SUCCESS)
        {
-               return base_align_bytes;
+               return base_align_bits/8;
        }
        return 1;
 }