Commit: 95ef9953706c80b0cfbdfe39cd96bcf000717792
Author: Thomas Dinges
Date:   Thu May 19 01:48:21 2016 +0200
Branches: soc-2016-cycles_images
https://developer.blender.org/rB95ef9953706c80b0cfbdfe39cd96bcf000717792

Only have one bindless_mapping vector, and also load textures for shader() 
kernel.

This fixes float4 textures \o/

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

M       intern/cycles/device/device_cuda.cpp
M       intern/cycles/kernel/kernel_textures.h

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

diff --git a/intern/cycles/device/device_cuda.cpp 
b/intern/cycles/device/device_cuda.cpp
index c28c41e..0e629ec 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -99,8 +99,7 @@ public:
        map<device_ptr, PixelMem> pixel_mem_map;
 
        /* Bindless Textures */
-       CUtexObject bindless_mapping[4096];
-       device_vector<uint> bindless_mapping_device;
+       device_vector<uint> bindless_mapping;
        bool sync_bindless_mapping;
 
        CUdeviceptr cuda_device_ptr(device_ptr mem)
@@ -223,7 +222,7 @@ public:
        {
                task_pool.stop();
 
-               tex_free(bindless_mapping_device);
+               tex_free(bindless_mapping);
 
                cuda_assert(cuCtxDestroy(cuContext));
        }
@@ -402,6 +401,14 @@ public:
                return (result == CUDA_SUCCESS);
        }
 
+       void load_bindless_mapping()
+       {
+               if(sync_bindless_mapping) {
+                       tex_alloc("__bindless_mapping", bindless_mapping, 
INTERPOLATION_NONE, EXTENSION_REPEAT, 0);
+                       sync_bindless_mapping = false;
+               }
+       }
+
        void mem_alloc(device_memory& mem, MemoryType /*type*/)
        {
                cuda_push_context();
@@ -670,7 +677,9 @@ public:
 
                                CUtexObject tex = 0;
                                cuda_assert(cuTexObjectCreate(&tex, &resDesc, 
&texDesc, NULL));
-                               bindless_mapping[flat_slot] = tex;
+                               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;
                        }
@@ -732,16 +741,7 @@ public:
                        return;
 
                /* Upload bindless_mapping vector */
-               if(cuDevArchitecture >= 300) {
-                       if(sync_bindless_mapping) {
-                               uint *tmp = 
bindless_mapping_device.resize(4096);
-                               for(size_t i = 0; i < 4096; i++) {
-                                       tmp[i] = (uint)bindless_mapping[i];
-                               }
-                               tex_alloc("__bindless_mapping", 
bindless_mapping_device, INTERPOLATION_NONE, EXTENSION_REPEAT, 0);
-                               sync_bindless_mapping = false;
-                       }
-               }
+               load_bindless_mapping();
 
                cuda_push_context();
 
@@ -857,6 +857,9 @@ public:
                if(have_error())
                        return;
 
+               /* Upload bindless_mapping vector */
+               load_bindless_mapping();
+
                cuda_push_context();
 
                CUfunction cuShader;
diff --git a/intern/cycles/kernel/kernel_textures.h 
b/intern/cycles/kernel/kernel_textures.h
index 285da14..f2467d5 100644
--- a/intern/cycles/kernel/kernel_textures.h
+++ b/intern/cycles/kernel/kernel_textures.h
@@ -176,7 +176,9 @@ KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, 
__tex_image_byte4_091)
 KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_092)
 
 /* bindless textures */
+#if defined(__KERNEL_CUDA__) && __CUDA_ARCH__ >= 300
 KERNEL_TEX(uint, texture_uint, __bindless_mapping)
+#endif
 
 /* packed image (opencl) */
 KERNEL_TEX(uchar4, texture_uchar4, __tex_image_byte4_packed)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to