Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-22 17:15:19 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-11-22 17:15:19 +0400
commit47853bf6f6fa7ab4dc523fe255a8253b7ae9f914 (patch)
tree8c968c8577dc88681b121501f87851d9eca35dab /intern/cycles/device/device_opencl.cpp
parentc71e31eb4f814c1ef561ac5467af3c16efa02a0d (diff)
Cycles: OpenCL tweaks
* Reduce kernel arguments size, helps compile for apple nvidia. * Fix use of unitialized variable in displace kernel. * Use build flags in opencl kernel md5 hash. * Reorganize code for kernel feature #defines a bit.
Diffstat (limited to 'intern/cycles/device/device_opencl.cpp')
-rw-r--r--intern/cycles/device/device_opencl.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index c96d4617ffb..f75928c1b80 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -260,12 +260,9 @@ public:
return true;
}
- bool build_kernel(const string& kernel_path)
+ string kernel_build_options()
{
- string build_options = "";
-
- build_options += "-I " + kernel_path + ""; /* todo: escape path */
- build_options += " -cl-fast-relaxed-math ";
+ string build_options = " -cl-fast-relaxed-math ";
/* Full Shading only on NVIDIA cards at the moment */
char vendor[256];
@@ -273,14 +270,19 @@ public:
clGetPlatformInfo(cpPlatform, CL_PLATFORM_NAME, sizeof(vendor), &vendor, NULL);
string name = vendor;
- if (name == "NVIDIA CUDA") {
- build_options += "-D __SVM__ ";
- build_options += "-D __EMISSION__ ";
- build_options += "-D __TEXTURES__ ";
- build_options += "-D __HOLDOUT__ ";
- build_options += "-D __MULTI_CLOSURE__ ";
- }
+ if(name == "NVIDIA CUDA")
+ build_options += "-D__KERNEL_SHADING__ -D__MULTI_CLOSURE__ ";
+ return build_options;
+ }
+
+ bool build_kernel(const string& kernel_path)
+ {
+ string build_options = "";
+
+ build_options += "-I " + kernel_path + ""; /* todo: escape path, but it doesn't get parsed correct? */
+ build_options += kernel_build_options();
+
ciErr = clBuildProgram(cpProgram, 0, NULL, build_options.c_str(), NULL, NULL);
if(ciErr != CL_SUCCESS) {
@@ -344,6 +346,9 @@ public:
md5.append((uint8_t*)name, strlen(name));
md5.append((uint8_t*)driver, strlen(driver));
+ string options = kernel_build_options();
+ md5.append((uint8_t*)options.c_str(), options.size());
+
return md5.get_hex();
}
@@ -563,24 +568,20 @@ public:
cl_int set_kernel_arg_mem(cl_kernel kernel, int *narg, const char *name)
{
cl_mem ptr;
- cl_int size, err = 0;
+ cl_int err = 0;
if(mem_map.find(name) != mem_map.end()) {
device_memory *mem = mem_map[name];
ptr = CL_MEM_PTR(mem->device_pointer);
- size = mem->data_width;
}
else {
/* work around NULL not working, even though the spec says otherwise */
ptr = CL_MEM_PTR(null_mem);
- size = 1;
}
err |= clSetKernelArg(kernel, (*narg)++, sizeof(ptr), (void*)&ptr);
opencl_assert(err);
- err |= clSetKernelArg(kernel, (*narg)++, sizeof(size), (void*)&size);
- opencl_assert(err);
return err;
}