[Bf-blender-cvs] [3fba620] master: Cycles: Prepare for more image extension types support

Sergey Sharybin noreply at git.blender.org
Tue Jul 28 14:46:06 CEST 2015


Commit: 3fba620858fa5bf44bec3124c61f6cc2e40356b0
Author: Sergey Sharybin
Date:   Tue Jul 28 13:51:10 2015 +0200
Branches: master
https://developer.blender.org/rB3fba620858fa5bf44bec3124c61f6cc2e40356b0

Cycles: Prepare for more image extension types support

Basically just replace boolean periodic flag with extension type enum in the
device API.

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

M	intern/cycles/device/device.h
M	intern/cycles/device/device_cpu.cpp
M	intern/cycles/device/device_cuda.cpp
M	intern/cycles/device/device_multi.cpp
M	intern/cycles/device/device_network.cpp
M	intern/cycles/device/device_opencl.cpp
M	intern/cycles/kernel/kernel.h
M	intern/cycles/kernel/kernel_compat_cpu.h
M	intern/cycles/kernel/kernels/cpu/kernel.cpp
M	intern/cycles/render/image.cpp

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

diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index ea1e20d..3c0fb88 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -173,10 +173,10 @@ public:
 	virtual void tex_alloc(const char * /*name*/,
 	                       device_memory& /*mem*/,
 	                       InterpolationType interpolation = INTERPOLATION_NONE,
-	                       bool periodic = false)
+	                       ExtensionType extension = EXTENSION_REPEAT)
 	{
 		(void)interpolation;  /* Ignored. */
-		(void)periodic;  /* Ignored. */
+		(void)extension;  /* Ignored. */
 	};
 	virtual void tex_free(device_memory& /*mem*/) {};
 
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index ec82b38..f06963c 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -126,7 +126,7 @@ public:
 	void tex_alloc(const char *name,
 	               device_memory& mem,
 	               InterpolationType interpolation,
-	               bool periodic)
+	               ExtensionType extension)
 	{
 		VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
 		kernel_tex_copy(&kernel_globals,
@@ -136,7 +136,7 @@ public:
 		                mem.data_height,
 		                mem.data_depth,
 		                interpolation,
-		                periodic);
+		                extension);
 		mem.device_pointer = mem.data_pointer;
 		mem.device_size = mem.memory_size();
 		stats.mem_alloc(mem.device_size);
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 4a9c27f..9703b78 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -416,7 +416,10 @@ public:
 		cuda_pop_context();
 	}
 
-	void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic)
+	void tex_alloc(const char *name,
+	               device_memory& mem,
+	               InterpolationType interpolation,
+	               ExtensionType extension)
 	{
 		/* todo: support 3D textures, only CPU for now */
 		VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
@@ -510,7 +513,7 @@ public:
 				cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_READ_AS_INTEGER));
 			}
 
-			if(periodic) {
+			if(extension == EXTENSION_REPEAT) {
 				cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_WRAP));
 				cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_WRAP));
 			}
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index c61e550..8fb841b 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -169,13 +169,17 @@ public:
 			sub.device->const_copy_to(name, host, size);
 	}
 
-	void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic)
+	void tex_alloc(const char *name,
+	               device_memory& mem,
+	               InterpolationType
+	               interpolation,
+	               ExtensionType extension)
 	{
 		VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
 
 		foreach(SubDevice& sub, devices) {
 			mem.device_pointer = 0;
-			sub.device->tex_alloc(name, mem, interpolation, periodic);
+			sub.device->tex_alloc(name, mem, interpolation, extension);
 			sub.ptr_map[unique_ptr] = mem.device_pointer;
 		}
 
diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp
index 1d6066c..d1f941a 100644
--- a/intern/cycles/device/device_network.cpp
+++ b/intern/cycles/device/device_network.cpp
@@ -163,7 +163,10 @@ public:
 		snd.write_buffer(host, size);
 	}
 
-	void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic)
+	void tex_alloc(const char *name,
+	               device_memory& mem,
+	               InterpolationType interpolation,
+	               ExtensionType extension)
 	{
 		VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
 
@@ -178,7 +181,7 @@ public:
 		snd.add(name_string);
 		snd.add(mem);
 		snd.add(interpolation);
-		snd.add(periodic);
+		snd.add(extension);
 		snd.write();
 		snd.write_buffer((void*)mem.data_pointer, mem.memory_size());
 	}
@@ -571,13 +574,13 @@ protected:
 			network_device_memory mem;
 			string name;
 			InterpolationType interpolation;
-			bool periodic;
+			ExtensionType extension_typr;
 			device_ptr client_pointer;
 
 			rcv.read(name);
 			rcv.read(mem);
 			rcv.read(interpolation);
-			rcv.read(periodic);
+			rcv.read(extension);
 			lock.unlock();
 
 			client_pointer = mem.device_pointer;
@@ -593,7 +596,7 @@ protected:
 
 			rcv.read_buffer((uint8_t*)mem.data_pointer, data_size);
 
-			device->tex_alloc(name.c_str(), mem, interpolation, periodic);
+			device->tex_alloc(name.c_str(), mem, interpolation, extension);
 
 			pointer_mapping_insert(client_pointer, mem.device_pointer);
 		}
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 0cc49e8..fee9a8a 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -1179,7 +1179,7 @@ public:
 	void tex_alloc(const char *name,
 	               device_memory& mem,
 	               InterpolationType /*interpolation*/,
-	               bool /*periodic*/)
+	               ExtensionType /*extension*/)
 	{
 		VLOG(1) << "Texture allocate: " << name << ", " << mem.memory_size() << " bytes.";
 		mem_alloc(mem, MEM_READ_ONLY);
diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h
index 5c34ddc..b2596d1 100644
--- a/intern/cycles/kernel/kernel.h
+++ b/intern/cycles/kernel/kernel.h
@@ -39,7 +39,7 @@ void kernel_tex_copy(KernelGlobals *kg,
                      size_t height,
                      size_t depth,
                      InterpolationType interpolation=INTERPOLATION_LINEAR,
-                     bool periodic = true);
+                     ExtensionType extension = EXTENSION_REPEAT);
 
 void kernel_cpu_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state,
 	int sample, int x, int y, int offset, int stride);
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index a780c35..be8e54b 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -138,7 +138,7 @@ template<typename T> struct texture_image  {
 		if(interpolation == INTERPOLATION_CLOSEST) {
 			frac(x*(float)width, &ix);
 			frac(y*(float)height, &iy);
-			if(periodic) {
+			if(extension == EXTENSION_REPEAT) {
 				ix = wrap_periodic(ix, width);
 				iy = wrap_periodic(iy, height);
 
@@ -153,7 +153,7 @@ template<typename T> struct texture_image  {
 			float tx = frac(x*(float)width - 0.5f, &ix);
 			float ty = frac(y*(float)height - 0.5f, &iy);
 
-			if(periodic) {
+			if(extension == EXTENSION_REPEAT) {
 				ix = wrap_periodic(ix, width);
 				iy = wrap_periodic(iy, height);
 
@@ -180,7 +180,7 @@ template<typename T> struct texture_image  {
 			const float tx = frac(x*(float)width - 0.5f, &ix);
 			const float ty = frac(y*(float)height - 0.5f, &iy);
 			int pix, piy, nnix, nniy;
-			if(periodic) {
+			if(extension == EXTENSION_REPEAT) {
 				ix = wrap_periodic(ix, width);
 				iy = wrap_periodic(iy, height);
 
@@ -251,7 +251,7 @@ template<typename T> struct texture_image  {
 			frac(y*(float)height, &iy);
 			frac(z*(float)depth, &iz);
 
-			if(periodic) {
+			if(extension == EXTENSION_REPEAT) {
 				ix = wrap_periodic(ix, width);
 				iy = wrap_periodic(iy, height);
 				iz = wrap_periodic(iz, depth);
@@ -269,7 +269,7 @@ template<typename T> struct texture_image  {
 			float ty = frac(y*(float)height - 0.5f, &iy);
 			float tz = frac(z*(float)depth - 0.5f, &iz);
 
-			if(periodic) {
+			if(extension == EXTENSION_REPEAT) {
 				ix = wrap_periodic(ix, width);
 				iy = wrap_periodic(iy, height);
 				iz = wrap_periodic(iz, depth);
@@ -309,7 +309,7 @@ template<typename T> struct texture_image  {
 			const float tz = frac(z*(float)depth - 0.5f, &iz);
 			int pix, piy, piz, nnix, nniy, nniz;
 
-			if(periodic) {
+			if(extension == EXTENSION_REPEAT) {
 				ix = wrap_periodic(ix, width);
 				iy = wrap_periodic(iy, height);
 				iz = wrap_periodic(iz, depth);
@@ -392,7 +392,7 @@ template<typename T> struct texture_image  {
 
 	T *data;
 	int interpolation;
-	bool periodic;
+	ExtensionType extension;
 	int width, height, depth;
 #undef SET_CUBIC_SPLINE_WEIGHTS
 };
diff --git a/intern/cycles/kernel/kernels/cpu/kernel.cpp b/intern/cycles/kernel/kernels/cpu/kernel.cpp
index 2dbd9e6..2c8d350 100644
--- a/intern/cycles/kernel/kernels/cpu/kernel.cpp
+++ b/intern/cycles/kernel/kernels/cpu/kernel.cpp
@@ -45,7 +45,7 @@ void kernel_tex_copy(KernelGlobals *kg,
                      size_t height,
                      size_t depth,
                      InterpolationType interpolation,
-                     bool periodic)
+                     ExtensionType extension)
 {
 	if(0) {
 	}
@@ -71,7 +71,7 @@ void kernel_tex_copy(KernelGlobals *kg,
 			tex->data = (float4*)mem;
 			tex->dimensions_set(width, height, depth);
 			tex->interpolation = interpolation;
-			tex->periodic = periodic;
+			tex->extension = extension;
 		}
 	}
 	else if(strstr(name, "__tex_image")) {
@@ -87,7 +87,7 @@ void kernel_tex_copy(KernelGlobals *kg,
 			tex->data = (uchar4*)mem;
 			tex->dimensions_set(width, height, depth);
 			tex->interpolation = interpolation;
-			tex->periodic = periodic;
+			tex->extension = extension;
 		}
 	}
 	else
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index dc9aeee..7bceb8a 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -714,7 +714,7 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl
 			device->tex_alloc(name.c_str(),
 			                  tex_img,
 			                  img->interpolation,
-			                  img->extension == EXTENSION_REPEAT);
+			                  img->extension);
 		}
 	}
 	else {
@@ -749,7 +749,7 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl
 			d

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list