Fix T54001: AMD OpenCL fails with certain resolutions, after recent changes.

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.
This commit is contained in:
Brecht Van Lommel 2018-02-05 22:13:08 +01:00
parent bd9ed0228b
commit ce3e0afe59
6 changed files with 12 additions and 12 deletions

@ -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;

@ -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;
}

@ -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;

@ -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);

@ -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)

@ -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;
}