[Bf-blender-cvs] [a5e4bfb] soc-2016-cycles_denoising: Merge remote-tracking branch 'origin/master' into soc-2016-cycles_denoising

Lukas Stockner noreply at git.blender.org
Tue Nov 22 04:25:00 CET 2016


Commit: a5e4bfb807aa1363c49625cb6c4d2a0f7b9db968
Author: Lukas Stockner
Date:   Fri Nov 11 03:17:19 2016 +0100
Branches: soc-2016-cycles_denoising
https://developer.blender.org/rBa5e4bfb807aa1363c49625cb6c4d2a0f7b9db968

Merge remote-tracking branch 'origin/master' into soc-2016-cycles_denoising

Conflicts:
	intern/cycles/blender/blender_python.cpp
	intern/cycles/device/device_opencl.cpp
	intern/cycles/kernel/kernel_accumulate.h
	intern/cycles/kernel/kernel_path.h
	intern/cycles/kernel/kernel_path_branched.h
	intern/cycles/kernel/kernel_path_surface.h
	intern/cycles/kernel/kernel_types.h
	intern/cycles/kernel/svm/svm_displace.h

===================================================================



===================================================================

diff --cc intern/cycles/blender/blender_python.cpp
index 2814fa5,438abc4..bbda3bb
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@@ -675,58 -676,20 +676,72 @@@ static PyObject *set_resumable_chunks_f
  	Py_RETURN_NONE;
  }
  
 +static PyObject *can_postprocess_func(PyObject * /*self*/, PyObject *args)
 +{
 +	PyObject *pyresult;
 +
 +	if(!PyArg_ParseTuple(args, "O", &pyresult))
 +		return NULL;
 +
 +	/* RNA */
 +	PointerRNA resultptr;
 +	RNA_pointer_create(NULL, &RNA_RenderResult, (void*)PyLong_AsVoidPtr(pyresult), &resultptr);
 +	BL::RenderResult b_rr(resultptr);
 +
 +	bool can_denoise = can_denoise_render_result(b_rr);
 +
 +	return Py_BuildValue("i", can_denoise? 1: 0);
 +}
 +
 +static PyObject *postprocess_func(PyObject * /*self*/, PyObject *args)
 +{
 +	PyObject *pyresult, *pyengine, *pyuserpref, *pyscene;
 +
 +	if(!PyArg_ParseTuple(args, "OOOO", &pyengine, &pyuserpref, &pyscene, &pyresult))
 +		return NULL;
 +
 +	/* RNA */
 +	PointerRNA engineptr;
 +	RNA_pointer_create(NULL, &RNA_RenderEngine, (void*)PyLong_AsVoidPtr(pyengine), &engineptr);
 +	BL::RenderEngine engine(engineptr);
 +
 +	PointerRNA userprefptr;
 +	RNA_pointer_create(NULL, &RNA_UserPreferences, (void*)PyLong_AsVoidPtr(pyuserpref), &userprefptr);
 +	BL::UserPreferences userpref(userprefptr);
 +
 +	PointerRNA sceneptr;
 +	RNA_pointer_create(NULL, &RNA_Scene, (void*)PyLong_AsVoidPtr(pyscene), &sceneptr);
 +	BL::Scene scene(sceneptr);
 +
 +	PointerRNA resultptr;
 +	RNA_pointer_create(NULL, &RNA_RenderResult, (void*)PyLong_AsVoidPtr(pyresult), &resultptr);
 +	BL::RenderResult b_rr(resultptr);
 +
 +	BlenderSession session(engine, userpref, scene);
 +
 +	python_thread_state_save(&session.python_thread_state);
 +
 +	session.denoise(b_rr);
 +
 +	python_thread_state_restore(&session.python_thread_state);
 +
 +	Py_RETURN_NONE;
 +}
 +
+ static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/)
+ {
+ 	vector<DeviceInfo>& devices = Device::available_devices();
+ 	bool has_cuda = false, has_opencl = false;
+ 	for(int i = 0; i < devices.size(); i++) {
+ 		has_cuda   |= (devices[i].type == DEVICE_CUDA);
+ 		has_opencl |= (devices[i].type == DEVICE_OPENCL);
+ 	}
+ 	PyObject *list = PyTuple_New(2);
+ 	PyTuple_SET_ITEM(list, 0, PyBool_FromLong(has_cuda));
+ 	PyTuple_SET_ITEM(list, 1, PyBool_FromLong(has_opencl));
+ 	return list;
+ }
+ 
  static PyMethodDef methods[] = {
  	{"init", init_func, METH_VARARGS, ""},
  	{"exit", exit_func, METH_VARARGS, ""},
diff --cc intern/cycles/device/opencl/opencl_mega.cpp
index 0000000,369c086..a1bf504
mode 000000,100644..100644
--- a/intern/cycles/device/opencl/opencl_mega.cpp
+++ b/intern/cycles/device/opencl/opencl_mega.cpp
@@@ -1,0 -1,150 +1,151 @@@
+ /*
+  * Copyright 2011-2013 Blender Foundation
+  *
+  * Licensed under the Apache License, Version 2.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  * http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ #ifdef WITH_OPENCL
+ 
+ #include "opencl.h"
+ 
+ #include "buffers.h"
+ 
+ #include "kernel_types.h"
+ 
+ #include "util_md5.h"
+ #include "util_path.h"
+ #include "util_time.h"
+ 
+ CCL_NAMESPACE_BEGIN
+ 
+ class OpenCLDeviceMegaKernel : public OpenCLDeviceBase
+ {
+ public:
+ 	OpenCLProgram path_trace_program;
+ 
+ 	OpenCLDeviceMegaKernel(DeviceInfo& info, Stats &stats, bool background_)
+ 	: OpenCLDeviceBase(info, stats, background_),
+ 	  path_trace_program(this, "megakernel", "kernel.cl", "-D__COMPILE_ONLY_MEGAKERNEL__ ")
+ 	{
+ 	}
+ 
+ 	virtual void load_kernels(const DeviceRequestedFeatures& /*requested_features*/,
+ 	                          vector<OpenCLProgram*> &programs)
+ 	{
+ 		path_trace_program.add_kernel(ustring("path_trace"));
+ 		programs.push_back(&path_trace_program);
+ 	}
+ 
+ 	~OpenCLDeviceMegaKernel()
+ 	{
+ 		task_pool.stop();
+ 		path_trace_program.release();
+ 	}
+ 
+ 	void path_trace(RenderTile& rtile, int sample)
+ 	{
+ 		/* Cast arguments to cl types. */
+ 		cl_mem d_data = CL_MEM_PTR(const_mem_map["__data"]->device_pointer);
+ 		cl_mem d_buffer = CL_MEM_PTR(rtile.buffer);
+ 		cl_mem d_rng_state = CL_MEM_PTR(rtile.rng_state);
+ 		cl_int d_x = rtile.x;
+ 		cl_int d_y = rtile.y;
+ 		cl_int d_w = rtile.w;
+ 		cl_int d_h = rtile.h;
+ 		cl_int d_offset = rtile.offset;
+ 		cl_int d_stride = rtile.stride;
+ 
+ 		/* Sample arguments. */
+ 		cl_int d_sample = sample;
+ 
+ 		cl_kernel ckPathTraceKernel = path_trace_program(ustring("path_trace"));
+ 
+ 		cl_uint start_arg_index =
+ 			kernel_set_args(ckPathTraceKernel,
+ 			                0,
+ 			                d_data,
+ 			                d_buffer,
+ 			                d_rng_state);
+ 
+ #define KERNEL_TEX(type, ttype, name) \
+ 		set_kernel_arg_mem(ckPathTraceKernel, &start_arg_index, #name);
+ #include "kernel_textures.h"
+ #undef KERNEL_TEX
+ 
+ 		start_arg_index += kernel_set_args(ckPathTraceKernel,
+ 		                                   start_arg_index,
+ 		                                   d_sample,
+ 		                                   d_x,
+ 		                                   d_y,
+ 		                                   d_w,
+ 		                                   d_h,
+ 		                                   d_offset,
+ 		                                   d_stride);
+ 
+ 		enqueue_kernel(ckPathTraceKernel, d_w, d_h);
+ 	}
+ 
+ 	void thread_run(DeviceTask *task)
+ 	{
+ 		if(task->type == DeviceTask::FILM_CONVERT) {
+ 			film_convert(*task, task->buffer, task->rgba_byte, task->rgba_half);
+ 		}
+ 		else if(task->type == DeviceTask::SHADER) {
+ 			shader(*task);
+ 		}
 -		else if(task->type == DeviceTask::PATH_TRACE) {
++		else if(task->type == DeviceTask::RENDER) {
+ 			RenderTile tile;
+ 			/* Keep rendering tiles until done. */
+ 			while(task->acquire_tile(this, tile)) {
++				assert(tile.task == RenderTile::PATH_TRACE);
+ 				int start_sample = tile.start_sample;
+ 				int end_sample = tile.start_sample + tile.num_samples;
+ 
+ 				for(int sample = start_sample; sample < end_sample; sample++) {
+ 					if(task->get_cancel()) {
+ 						if(task->need_finish_queue == false)
+ 							break;
+ 					}
+ 
+ 					path_trace(tile, sample);
+ 
+ 					tile.sample = sample + 1;
+ 
+ 					task->update_progress(&tile);
+ 				}
+ 
+ 				/* Complete kernel execution before release tile */
+ 				/* This helps in multi-device render;
+ 				 * The device that reaches the critical-section function
+ 				 * release_tile waits (stalling other devices from entering
+ 				 * release_tile) for all kernels to complete. If device1 (a
+ 				 * slow-render device) reaches release_tile first then it would
+ 				 * stall device2 (a fast-render device) from proceeding to render
+ 				 * next tile.
+ 				 */
+ 				clFinish(cqCommandQueue);
+ 
+ 				task->release_tile(tile);
+ 			}
+ 		}
+ 	}
+ };
+ 
+ Device *opencl_create_mega_device(DeviceInfo& info, Stats& stats, bool background)
+ {
+ 	return new OpenCLDeviceMegaKernel(info, stats, background);
+ }
+ 
+ CCL_NAMESPACE_END
+ 
+ #endif
diff --cc intern/cycles/device/opencl/opencl_split.cpp
index 0000000,239e73a..c4e752d
mode 000000,100644..100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@@ -1,0 -1,1307 +1,1308 @@@
+ /*
+  * Copyright 2011-2013 Blender Foundation
+  *
+  * Licensed under the Apache License, Version 2.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  * http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ #ifdef WITH_OPENCL
+ 
+ #include "opencl.h"
+ 
+ #include "buffers.h"
+ 
+ #include "kernel_types.h"
+ 
+ #include "util_md5.h"
+ #include "util_path.h"
+ #include "util_time.h"
+ 
+ CCL_NAMESPACE_BEGIN
+ 
+ /* TODO(sergey): This is to keep tile split on OpenCL level working
+  * for now, since without this view-port render does not work as it
+  * should.
+  *
+  * Ideally it'll be done on the higher level, but we need to get ready
+  * for merge rather soon, so let's keep split logic private here in
+  * the file.
+  */
+ class SplitRenderTile : public RenderTile {
+ public:
+ 	SplitRenderTile()
+ 		: RenderTile(),
+ 		  buffer_offset_x(0),
+ 		  buffer_offset_y(0),
+ 		  rng_state_offset_x(0),
+ 		  rng_state_offset_y(0),
+ 		  buffer_rng_state_stride(0) {}
+ 
+ 	explicit SplitRenderTile(RenderTile& tile)
+ 		: RenderTile(),
+ 		  buffer_offset_x(0),
+ 		  buffer_offset_y(0),
+ 		  rng_state_offset_x(0),
+ 		  rng_state_offset_y(0),
+ 		  buffer_rng_state_stride(0)
+ 	{
+ 		x = tile.x;
+ 		y = tile.y;
+ 		w = tile.w;
+ 		h = tile.h;
+ 		start_sample = tile.start_sample;
+ 		num_samples = tile.num_samples;
+ 		sample = tile.sample;
+ 		resolution = tile.resolution;
+ 		offset = tile.offset;
+ 		stride = tile.stride;
+ 		buffer = tile.buffer;
+ 		rng_state = tile.rng_state;
+ 		buffers = tile.buffers;
+ 	}
+ 
+ 	/* Split kernel is device global memory constrained;
+ 	 * hence split kernel cant render big tile size's in
+ 	 * one go. If the user sets a big tile size (big tile size
+ 	 * is a term relative to the available device global memory),
+ 	 * we split the tile further and then call path_trace on
+ 	 * each of those split tiles. The following variables declared,
+ 	 * assist in achieving that purpose
+ 	 */
+ 	int buffer_offset_x;
+ 	int buffer_offset_y;
+ 	int rng_state_offset_x;
+ 	int rng_state_offset_y;
+ 	int buffer_rng_state_stride;
+ };
+ 
+ /* OpenCLDeviceSplitKernel's declaration/definition. */
+ class Ope

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list