Code refactor: remove MEM_WRITE_ONLY, always use MEM_READ_WRITE.

It's unlikely the driver can do useful optimizations with this, and if
we sum multiple samples we are reading from the memory anyway.
This commit is contained in:
Brecht Van Lommel 2017-10-24 23:23:16 +02:00
parent fe253389e0
commit 34fe3f9c06
Notes: blender-bot 2023-02-14 08:06:33 +01:00
Referenced by issue #53678, Island margin in smart UV project issue with scene scale
Referenced by issue #53151, Particle instance modifier can crash when create from Children is checked and Normal is not
Referenced by issue #53079, Blender Crash to Desktop Rendering with HDRI (EXR) Maybe others not tested
6 changed files with 4 additions and 11 deletions

View File

@ -85,7 +85,6 @@ void device_memory::device_free()
void device_memory::device_copy_to()
{
assert(type != MEM_PIXELS && type != MEM_WRITE_ONLY);
if(data_size) {
device->mem_copy_to(*this);
}
@ -99,7 +98,6 @@ void device_memory::device_copy_from(int y, int w, int h, int elem)
void device_memory::device_zero()
{
assert(type != MEM_PIXELS && type != MEM_WRITE_ONLY);
if(data_size) {
device->mem_zero(*this);
}

View File

@ -33,7 +33,6 @@ class Device;
enum MemoryType {
MEM_READ_ONLY,
MEM_WRITE_ONLY,
MEM_READ_WRITE,
MEM_TEXTURE,
MEM_PIXELS
@ -325,13 +324,13 @@ public:
device_free();
host_free(data_pointer, sizeof(T)*data_size);
data_pointer = new_ptr;
assert(device_pointer == 0);
}
data_size = new_size;
data_width = width;
data_height = height;
data_depth = depth;
assert(device_pointer == 0);
return get_data();
}

View File

@ -282,7 +282,7 @@ public:
/* Can't transfer OpenGL texture over network. */
if(mem.type == MEM_PIXELS) {
mem.type = MEM_WRITE_ONLY;
mem.type = MEM_READ_WRITE;
}
}

View File

@ -319,8 +319,6 @@ void OpenCLDeviceBase::mem_alloc(device_memory& mem)
if(mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE)
mem_flag = CL_MEM_READ_ONLY;
else if(mem.type == MEM_WRITE_ONLY || mem.type == MEM_PIXELS)
mem_flag = CL_MEM_WRITE_ONLY;
else
mem_flag = CL_MEM_READ_WRITE;
@ -484,8 +482,6 @@ device_ptr OpenCLDeviceBase::mem_alloc_sub_ptr(device_memory& mem, int offset, i
cl_mem_flags mem_flag;
if(mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE)
mem_flag = CL_MEM_READ_ONLY;
else if(mem.type == MEM_WRITE_ONLY || mem.type == MEM_PIXELS)
mem_flag = CL_MEM_WRITE_ONLY;
else
mem_flag = CL_MEM_READ_WRITE;

View File

@ -37,7 +37,7 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res
int height = res;
device_vector<uint4> d_input(device, "background_input", MEM_READ_ONLY);
device_vector<float4> d_output(device, "background_output", MEM_WRITE_ONLY);
device_vector<float4> d_output(device, "background_output", MEM_READ_WRITE);
uint4 *d_input_data = d_input.alloc(width*height);

View File

@ -115,7 +115,7 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
return false;
/* run device task */
device_vector<float4> d_output(device, "displace_output", MEM_WRITE_ONLY);
device_vector<float4> d_output(device, "displace_output", MEM_READ_WRITE);
d_output.alloc(d_input_size);
d_output.zero_to_device();
d_input.copy_to_device();