[Bf-blender-cvs] [905931e] soc-2016-cycles_images: Adress further review comments.

Thomas Dinges noreply at git.blender.org
Thu May 19 12:47:53 CEST 2016


Commit: 905931e3b799b54fd765b04903d3d3c33588bf59
Author: Thomas Dinges
Date:   Thu May 19 12:47:41 2016 +0200
Branches: soc-2016-cycles_images
https://developer.blender.org/rB905931e3b799b54fd765b04903d3d3c33588bf59

Adress further review comments.

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

M	intern/cycles/device/device_cpu.cpp
M	intern/cycles/device/device_cuda.cpp
M	intern/cycles/render/image.cpp

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

diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 26f8439..275ee02 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -169,7 +169,7 @@ public:
 		stats.mem_alloc(mem.device_size);
 	}
 
-	void tex_free(device_memory& mem, int /*flat_slot*/)
+	void tex_free(device_memory& mem)
 	{
 		if(mem.device_pointer) {
 			mem.device_pointer = 0;
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 4feb510..39bb442 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -101,7 +101,7 @@ public:
 
 	/* Bindless Textures */
 	device_vector<uint> bindless_mapping;
-	bool sync_bindless_mapping;
+	bool need_bindless_mapping;
 
 	CUdeviceptr cuda_device_ptr(device_ptr mem)
 	{
@@ -185,7 +185,7 @@ public:
 		cuDevice = 0;
 		cuContext = 0;
 
-		sync_bindless_mapping = false;
+		need_bindless_mapping = false;
 
 		/* intialize */
 		if(cuda_error(cuInit(0)))
@@ -223,8 +223,9 @@ public:
 	{
 		task_pool.stop();
 
-		if(info.has_bindless_textures)
+		if(info.has_bindless_textures) {
 			tex_free(bindless_mapping);
+		}
 
 		cuda_assert(cuCtxDestroy(cuContext));
 	}
@@ -405,10 +406,10 @@ public:
 
 	void load_bindless_mapping()
 	{
-		if(info.has_bindless_textures && sync_bindless_mapping) {
+		if(info.has_bindless_textures && need_bindless_mapping) {
 			tex_free(bindless_mapping);
 			tex_alloc("__bindless_mapping", bindless_mapping, INTERPOLATION_NONE, EXTENSION_REPEAT);
-			sync_bindless_mapping = false;
+			need_bindless_mapping = false;
 		}
 	}
 
@@ -694,12 +695,20 @@ public:
 
 				CUtexObject tex = 0;
 				cuda_assert(cuTexObjectCreate(&tex, &resDesc, &texDesc, NULL));
+
+				/* Safety check */
+				if((uint)tex > UINT_MAX) {
+					assert(0);
+				}
+
+				/* Resize once */
 				if(flat_slot >= bindless_mapping.size())
 					bindless_mapping.resize(4096); /*TODO(dingto): Make this a variable */
-				bindless_mapping.get_data()[flat_slot] = (uint)tex;
 
-				sync_bindless_mapping = true;
+				/* Set Mapping and tag that we need to (re-)upload to device */
+				bindless_mapping.get_data()[flat_slot] = (uint)tex;
 				tex_bindless_map[mem.device_pointer] = (uint)tex;
+				need_bindless_mapping = true;
 			}
 			/* Regular Textures - Fermi */
 			else {
@@ -762,9 +771,6 @@ public:
 		if(have_error())
 			return;
 
-		/* Upload bindless_mapping vector */
-		load_bindless_mapping();
-
 		cuda_push_context();
 
 		CUfunction cuPathTrace;
@@ -879,9 +885,6 @@ public:
 		if(have_error())
 			return;
 
-		/* Upload bindless_mapping vector */
-		load_bindless_mapping();
-
 		cuda_push_context();
 
 		CUfunction cuShader;
@@ -1191,6 +1194,9 @@ public:
 			RenderTile tile;
 			
 			bool branched = task->integrator_branched;
+
+			/* Upload Bindless Mapping */
+			load_bindless_mapping();
 			
 			/* keep rendering tiles until done */
 			while(task->acquire_tile(this, tile)) {
@@ -1214,6 +1220,9 @@ public:
 			}
 		}
 		else if(task->type == DeviceTask::SHADER) {
+			/* Upload Bindless Mapping */
+			load_bindless_mapping();
+
 			shader(*task);
 
 			cuda_push_context();
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index dcf9181..9f40e56 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -872,8 +872,6 @@ void ImageManager::device_free_image(Device *device, DeviceScene *dscene, ImageD
 {
 	Image *img = images[type][slot];
 
-	int flat_slot = type_index_to_flattened_slot(slot, type);
-
 	if(img) {
 		if(osl_texture_system && !img->builtin_data) {
 #ifdef WITH_OSL




More information about the Bf-blender-cvs mailing list