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
path: root/intern
diff options
context:
space:
mode:
Diffstat (limited to 'intern')
-rw-r--r--intern/CMakeLists.txt2
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.cpp24
-rw-r--r--intern/audaspace/intern/AUD_AnimateableProperty.cpp88
-rw-r--r--intern/audaspace/intern/AUD_AnimateableProperty.h14
-rw-r--r--intern/bsp/intern/BOP_CarveInterface.cpp63
-rw-r--r--intern/cycles/CMakeLists.txt4
-rw-r--r--intern/cycles/SConscript10
-rw-r--r--intern/cycles/app/cycles_standalone.cpp2
-rw-r--r--intern/cycles/blender/addon/properties.py8
-rw-r--r--intern/cycles/blender/addon/ui.py4
-rw-r--r--intern/cycles/blender/blender_curves.cpp69
-rw-r--r--intern/cycles/blender/blender_mesh.cpp12
-rw-r--r--intern/cycles/blender/blender_object.cpp6
-rw-r--r--intern/cycles/blender/blender_shader.cpp86
-rw-r--r--intern/cycles/blender/blender_sync.h3
-rw-r--r--intern/cycles/bvh/bvh_build.cpp2
-rw-r--r--intern/cycles/device/CMakeLists.txt4
-rw-r--r--intern/cycles/device/device.cpp7
-rw-r--r--intern/cycles/device/device_cpu.cpp66
-rw-r--r--intern/cycles/kernel/CMakeLists.txt9
-rw-r--r--intern/cycles/kernel/closure/bsdf.h6
-rw-r--r--intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_diffuse.h22
-rw-r--r--intern/cycles/kernel/closure/bsdf_diffuse_ramp.h12
-rw-r--r--intern/cycles/kernel/closure/bsdf_hair.h20
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet.h24
-rw-r--r--intern/cycles/kernel/closure/bsdf_oren_nayar.h12
-rw-r--r--intern/cycles/kernel/closure/bsdf_phong_ramp.h12
-rw-r--r--intern/cycles/kernel/closure/bsdf_reflection.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_refraction.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_toon.h24
-rw-r--r--intern/cycles/kernel/closure/bsdf_transparent.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_util.h8
-rw-r--r--intern/cycles/kernel/closure/bsdf_ward.h10
-rw-r--r--intern/cycles/kernel/closure/bsdf_westin.h20
-rw-r--r--intern/cycles/kernel/closure/bssrdf.h26
-rw-r--r--intern/cycles/kernel/closure/emissive.h6
-rw-r--r--intern/cycles/kernel/closure/volume.h10
-rw-r--r--intern/cycles/kernel/kernel.cl32
-rw-r--r--intern/cycles/kernel/kernel.h9
-rw-r--r--intern/cycles/kernel/kernel_accumulate.h28
-rw-r--r--intern/cycles/kernel/kernel_bvh.h40
-rw-r--r--intern/cycles/kernel/kernel_bvh_subsurface.h2
-rw-r--r--intern/cycles/kernel/kernel_bvh_traversal.h2
-rw-r--r--intern/cycles/kernel/kernel_camera.h16
-rw-r--r--intern/cycles/kernel/kernel_compat_cuda.h13
-rw-r--r--intern/cycles/kernel/kernel_compat_opencl.h14
-rw-r--r--intern/cycles/kernel/kernel_curve.h8
-rw-r--r--intern/cycles/kernel/kernel_differential.h10
-rw-r--r--intern/cycles/kernel/kernel_displace.h2
-rw-r--r--intern/cycles/kernel/kernel_emission.h10
-rw-r--r--intern/cycles/kernel/kernel_film.h33
-rw-r--r--intern/cycles/kernel/kernel_globals.h8
-rw-r--r--intern/cycles/kernel/kernel_jitter.h18
-rw-r--r--intern/cycles/kernel/kernel_light.h38
-rw-r--r--intern/cycles/kernel/kernel_montecarlo.h24
-rw-r--r--intern/cycles/kernel/kernel_object.h52
-rw-r--r--intern/cycles/kernel/kernel_passes.h16
-rw-r--r--intern/cycles/kernel/kernel_path.h24
-rw-r--r--intern/cycles/kernel/kernel_path_state.h8
-rw-r--r--intern/cycles/kernel/kernel_primitive.h12
-rw-r--r--intern/cycles/kernel/kernel_projection.h24
-rw-r--r--intern/cycles/kernel/kernel_random.h34
-rw-r--r--intern/cycles/kernel/kernel_shader.h58
-rw-r--r--intern/cycles/kernel/kernel_sse41.cpp76
-rw-r--r--intern/cycles/kernel/kernel_subsurface.h14
-rw-r--r--intern/cycles/kernel/kernel_triangle.h16
-rw-r--r--intern/cycles/kernel/shaders/node_math.osl2
-rw-r--r--intern/cycles/kernel/svm/svm.h28
-rw-r--r--intern/cycles/kernel/svm/svm_attribute.h8
-rw-r--r--intern/cycles/kernel/svm/svm_blackbody.h2
-rw-r--r--intern/cycles/kernel/svm/svm_brick.h6
-rw-r--r--intern/cycles/kernel/svm/svm_brightness.h2
-rw-r--r--intern/cycles/kernel/svm/svm_camera.h2
-rw-r--r--intern/cycles/kernel/svm/svm_checker.h4
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h34
-rw-r--r--intern/cycles/kernel/svm/svm_convert.h2
-rw-r--r--intern/cycles/kernel/svm/svm_displace.h4
-rw-r--r--intern/cycles/kernel/svm/svm_fresnel.h22
-rw-r--r--intern/cycles/kernel/svm/svm_gamma.h2
-rw-r--r--intern/cycles/kernel/svm/svm_geometry.h12
-rw-r--r--intern/cycles/kernel/svm/svm_gradient.h4
-rw-r--r--intern/cycles/kernel/svm/svm_hsv.h2
-rw-r--r--intern/cycles/kernel/svm/svm_image.h18
-rw-r--r--intern/cycles/kernel/svm/svm_invert.h4
-rw-r--r--intern/cycles/kernel/svm/svm_light_path.h4
-rw-r--r--intern/cycles/kernel/svm/svm_magic.h4
-rw-r--r--intern/cycles/kernel/svm/svm_mapping.h4
-rw-r--r--intern/cycles/kernel/svm/svm_math.h10
-rw-r--r--intern/cycles/kernel/svm/svm_mix.h42
-rw-r--r--intern/cycles/kernel/svm/svm_musgrave.h14
-rw-r--r--intern/cycles/kernel/svm/svm_noise.h36
-rw-r--r--intern/cycles/kernel/svm/svm_noisetex.h4
-rw-r--r--intern/cycles/kernel/svm/svm_normal.h2
-rw-r--r--intern/cycles/kernel/svm/svm_ramp.h8
-rw-r--r--intern/cycles/kernel/svm/svm_sepcomb_hsv.h4
-rw-r--r--intern/cycles/kernel/svm/svm_sepcomb_rgb.h4
-rw-r--r--intern/cycles/kernel/svm/svm_sky.h12
-rw-r--r--intern/cycles/kernel/svm/svm_tex_coord.h10
-rw-r--r--intern/cycles/kernel/svm/svm_texture.h34
-rw-r--r--intern/cycles/kernel/svm/svm_value.h4
-rw-r--r--intern/cycles/kernel/svm/svm_vector_transform.h2
-rw-r--r--intern/cycles/kernel/svm/svm_voronoi.h4
-rw-r--r--intern/cycles/kernel/svm/svm_wave.h4
-rw-r--r--intern/cycles/kernel/svm/svm_wavelength.h2
-rw-r--r--intern/cycles/kernel/svm/svm_wireframe.h2
-rw-r--r--intern/cycles/render/buffers.cpp6
-rw-r--r--intern/cycles/render/graph.h3
-rw-r--r--intern/cycles/render/nodes.cpp16
-rw-r--r--intern/cycles/render/object.cpp4
-rw-r--r--intern/cycles/render/shader.cpp3
-rw-r--r--intern/cycles/render/sky_model.h2
-rw-r--r--intern/cycles/util/util_color.h18
-rw-r--r--intern/cycles/util/util_math.h315
-rw-r--r--intern/cycles/util/util_system.cpp5
-rw-r--r--intern/cycles/util/util_system.h1
-rw-r--r--intern/cycles/util/util_task.cpp4
-rw-r--r--intern/cycles/util/util_task.h4
-rw-r--r--intern/cycles/util/util_transform.h60
-rw-r--r--intern/cycles/util/util_types.h116
-rw-r--r--intern/ffmpeg/ffmpeg_compat.h2
-rw-r--r--intern/ghost/CMakeLists.txt69
-rw-r--r--intern/ghost/SConscript37
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp175
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCarbon.h116
-rw-r--r--intern/ghost/intern/GHOST_ISystem.cpp10
-rw-r--r--intern/ghost/intern/GHOST_ISystemPaths.cpp8
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.cpp1241
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.h298
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm256
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsCarbon.cpp88
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsCarbon.h87
-rw-r--r--intern/ghost/intern/GHOST_WindowCarbon.cpp751
-rw-r--r--intern/ghost/intern/GHOST_WindowCarbon.h321
-rw-r--r--intern/ghost/test/CMakeLists.txt1
-rw-r--r--intern/guardedalloc/CMakeLists.txt3
-rw-r--r--intern/guardedalloc/intern/mallocn_lockfree_impl.c13
-rw-r--r--intern/guardedalloc/intern/mmap_win.c14
-rw-r--r--intern/locale/CMakeLists.txt8
-rw-r--r--intern/locale/SConscript53
-rw-r--r--intern/locale/msgfmt.cc369
-rw-r--r--intern/rigidbody/CMakeLists.txt3
-rw-r--r--intern/rigidbody/rb_bullet_api.cpp6
143 files changed, 1874 insertions, 4356 deletions
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 364db3592c7..c45e66cd77b 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -61,7 +61,7 @@ if(WITH_IK_ITASC)
add_subdirectory(itasc)
endif()
-if(WITH_IK_SOLVER OR WITH_GAMEENGINE)
+if(WITH_IK_SOLVER OR WITH_GAMEENGINE OR WITH_MOD_BOOLEAN)
add_subdirectory(moto)
endif()
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
index 676a86e88fe..c3877c2c9f2 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
@@ -119,6 +119,14 @@ AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, A
{
length = m_device->m_buffersize;
reader->read(length, eos, m_device->m_buffer.getBuffer());
+
+ if(length == 0)
+ {
+ // AUD_XXX: TODO: don't fill all buffers and enqueue them later
+ length = 1;
+ memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs));
+ }
+
alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(),
length * AUD_DEVICE_SAMPLE_SIZE(specs),
specs.rate);
@@ -132,8 +140,7 @@ AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, A
try
{
- alSourceQueueBuffers(m_source, CYCLE_BUFFERS,
- m_buffers);
+ alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers);
if(alGetError() != AL_NO_ERROR)
AUD_THROW(AUD_ERROR_OPENAL, queue_error);
}
@@ -289,6 +296,14 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position)
{
length = m_device->m_buffersize;
m_reader->read(length, m_eos, m_device->m_buffer.getBuffer());
+
+ if(length == 0)
+ {
+ // AUD_XXX: TODO: don't fill all buffers and enqueue them later
+ length = 1;
+ memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs));
+ }
+
alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(),
length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate);
@@ -933,9 +948,8 @@ void AUD_OpenALDevice::updateStreams()
break;
}
- // unqueue buffer
- alSourceUnqueueBuffers(sound->m_source, 1,
- &sound->m_buffers[sound->m_current]);
+ // unqueue buffer (warning: this might fail for slow early returning sources (none exist so far) if the buffer was not queued due to recent changes - has to be tested)
+ alSourceUnqueueBuffers(sound->m_source, 1, &sound->m_buffers[sound->m_current]);
ALenum err;
if((err = alGetError()) != AL_NO_ERROR)
{
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
index 0b333e687ff..61adae4b34b 100644
--- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp
+++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp
@@ -47,6 +47,15 @@ AUD_AnimateableProperty::AUD_AnimateableProperty(int count) :
pthread_mutexattr_destroy(&attr);
}
+void AUD_AnimateableProperty::updateUnknownCache(int start, int end)
+{
+ float* buf = getBuffer();
+
+ for(int i = start; i <= end; i++)
+ // TODO: maybe first instead of zero order interpolation?
+ memcpy(buf + i * m_count, buf + (start - 1) * m_count, m_count * sizeof(float));
+}
+
AUD_AnimateableProperty::~AUD_AnimateableProperty()
{
pthread_mutex_destroy(&m_mutex);
@@ -67,6 +76,7 @@ void AUD_AnimateableProperty::write(const float* data)
AUD_MutexLock lock(*this);
m_isAnimated = false;
+ m_unknown.clear();
memcpy(getBuffer(), data, m_count * sizeof(float));
}
@@ -74,18 +84,88 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count)
{
AUD_MutexLock lock(*this);
- m_isAnimated = true;
-
int pos = getSize() / (sizeof(float) * m_count);
+ if(!m_isAnimated)
+ pos = 0;
+
+ m_isAnimated = true;
+
assureSize((count + position) * m_count * sizeof(float), true);
float* buf = getBuffer();
memcpy(buf + position * m_count, data, count * m_count * sizeof(float));
- for(int i = pos; i < position; i++)
- memcpy(buf + i * m_count, buf + (pos - 1) * m_count, m_count * sizeof(float));
+ // have to fill up space between?
+ if(pos < position)
+ {
+ m_unknown.push_back(Unknown(pos, position - 1));
+
+ if(pos == 0)
+ {
+ memset(buf, 0, position * m_count * sizeof(float));
+ }
+ else
+ updateUnknownCache(pos, position - 1);
+ }
+ // otherwise it's not at the end, let's check if some unknown part got filled
+ else
+ {
+ bool erased = false;
+
+ for(std::list<Unknown>::iterator it = m_unknown.begin(); it != m_unknown.end(); erased ? it : it++)
+ {
+ erased = false;
+
+ // unknown area before position
+ if(it->end < position)
+ continue;
+
+ // we're after the new area, let's stop
+ if(it->start >= position + count)
+ break;
+
+ // we have an intersection, now 4 cases:
+ // the start is included
+ if(position <= it->start)
+ {
+ // the end is included
+ if(position + count > it->end)
+ {
+ // simply delete
+ it = m_unknown.erase(it);
+ erased = true;
+ }
+ // the end is excluded, a second part remains
+ else
+ {
+ // update second part
+ it->start = position + count;
+ updateUnknownCache(it->start, it->end);
+ break;
+ }
+ }
+ // start is excluded, a first part remains
+ else
+ {
+ // the end is included
+ if(position + count > it->end)
+ {
+ // update first part
+ it->end = position - 1;
+ }
+ // the end is excluded, a second part remains
+ else
+ {
+ // add another item and update both parts
+ m_unknown.insert(it, Unknown(it->start, position - 1));
+ it->start = position + count;
+ updateUnknownCache(it->start, it->end);
+ }
+ }
+ }
+ }
}
void AUD_AnimateableProperty::read(float position, float* out)
diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.h b/intern/audaspace/intern/AUD_AnimateableProperty.h
index 322748ad571..37eb8f84550 100644
--- a/intern/audaspace/intern/AUD_AnimateableProperty.h
+++ b/intern/audaspace/intern/AUD_AnimateableProperty.h
@@ -34,6 +34,7 @@
#include "AUD_ILockable.h"
#include <pthread.h>
+#include <list>
/**
* This class saves animation data for float properties.
@@ -41,6 +42,14 @@
class AUD_AnimateableProperty : private AUD_Buffer, public AUD_ILockable
{
private:
+ struct Unknown {
+ int start;
+ int end;
+
+ Unknown(int start, int end) :
+ start(start), end(end) {}
+ };
+
/// The count of floats for a single property.
const int m_count;
@@ -50,10 +59,15 @@ private:
/// The mutex for locking.
pthread_mutex_t m_mutex;
+ /// The list of unknown buffer areas.
+ std::list<Unknown> m_unknown;
+
// hide copy constructor and operator=
AUD_AnimateableProperty(const AUD_AnimateableProperty&);
AUD_AnimateableProperty& operator=(const AUD_AnimateableProperty&);
+ void updateUnknownCache(int start, int end);
+
public:
/**
* Creates a new animateable property.
diff --git a/intern/bsp/intern/BOP_CarveInterface.cpp b/intern/bsp/intern/BOP_CarveInterface.cpp
index bb3a783548c..a96196ee8f5 100644
--- a/intern/bsp/intern/BOP_CarveInterface.cpp
+++ b/intern/bsp/intern/BOP_CarveInterface.cpp
@@ -711,6 +711,47 @@ static BSP_CSGMesh *Carve_exportMesh(MeshSet<3>* &poly, carve::interpolate::Face
return outputMesh;
}
+static void meshSetMinMax(const MeshSet<3> *mesh,
+ carve::geom3d::Vector *min,
+ carve::geom3d::Vector *max)
+{
+ for (uint i = 0; i < mesh->vertex_storage.size(); ++i) {
+ min->x = MIN(min->x, mesh->vertex_storage[i].v.x);
+ min->y = MIN(min->y, mesh->vertex_storage[i].v.y);
+ min->z = MIN(min->z, mesh->vertex_storage[i].v.z);
+ max->x = MAX(max->x, mesh->vertex_storage[i].v.x);
+ max->y = MAX(max->y, mesh->vertex_storage[i].v.y);
+ max->z = MAX(max->z, mesh->vertex_storage[i].v.z);
+ }
+}
+
+static void getRescaleMinMax(const MeshSet<3> *left,
+ const MeshSet<3> *right,
+ carve::geom3d::Vector *min,
+ carve::geom3d::Vector *max)
+{
+ min->x = max->x = left->vertex_storage[0].v.x;
+ min->y = max->y = left->vertex_storage[0].v.y;
+ min->z = max->z = left->vertex_storage[0].v.z;
+
+ meshSetMinMax(left, min, max);
+ meshSetMinMax(right, min, max);
+
+ // Make sure we don't scale object with zer oscale
+ if ((min->x - max->x) < DBL_EPSILON) {
+ min->x = -1.0;
+ max->x = 1.0;
+ }
+ if ((min->y - max->y) < DBL_EPSILON) {
+ min->y = -1.0;
+ max->y = 1.0;
+ }
+ if ((min->z - max->z) < DBL_EPSILON) {
+ min->z = -1.0;
+ max->z = 1.0;
+ }
+}
+
/**
* Performs a generic booleam operation, the entry point for external modules.
* @param opType Boolean operation type BOP_INTERSECTION, BOP_UNION, BOP_DIFFERENCE
@@ -753,29 +794,11 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType,
left = Carve_addMesh(obAFaces, obAVertices, oface_num, num_origfaces );
right = Carve_addMesh(obBFaces, obBVertices, oface_num, num_origfaces );
- min.x = max.x = left->vertex_storage[0].v.x;
- min.y = max.y = left->vertex_storage[0].v.y;
- min.z = max.z = left->vertex_storage[0].v.z;
- for (uint i = 1; i < left->vertex_storage.size(); ++i) {
- min.x = MIN(min.x,left->vertex_storage[i].v.x);
- min.y = MIN(min.y,left->vertex_storage[i].v.y);
- min.z = MIN(min.z,left->vertex_storage[i].v.z);
- max.x = MAX(max.x,left->vertex_storage[i].v.x);
- max.y = MAX(max.y,left->vertex_storage[i].v.y);
- max.z = MAX(max.z,left->vertex_storage[i].v.z);
- }
- for (uint i = 0; i < right->vertex_storage.size(); ++i) {
- min.x = MIN(min.x,right->vertex_storage[i].v.x);
- min.y = MIN(min.y,right->vertex_storage[i].v.y);
- min.z = MIN(min.z,right->vertex_storage[i].v.z);
- max.x = MAX(max.x,right->vertex_storage[i].v.x);
- max.y = MAX(max.y,right->vertex_storage[i].v.y);
- max.z = MAX(max.z,right->vertex_storage[i].v.z);
- }
+ getRescaleMinMax(left, right, &min, &max);
carve::rescale::rescale scaler(min.x, min.y, min.z, max.x, max.y, max.z);
carve::rescale::fwd fwd_r(scaler);
- carve::rescale::rev rev_r(scaler);
+ carve::rescale::rev rev_r(scaler);
left->transform(fwd_r);
right->transform(fwd_r);
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 6821e93ad87..9b84f882046 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -17,9 +17,11 @@ if(WIN32 AND MSVC)
if(CMAKE_CL_64)
set(CYCLES_SSE2_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
set(CYCLES_SSE3_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
+ set(CYCLES_SSE41_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
else()
set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
set(CYCLES_SSE3_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
+ set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
@@ -29,10 +31,12 @@ if(WIN32 AND MSVC)
elseif(CMAKE_COMPILER_IS_GNUCC)
set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2 -mfpmath=sse")
set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse")
+ set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mfpmath=sse")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2")
set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3")
+ set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
endif()
diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript
index e61018bc3dd..eeb60f37f92 100644
--- a/intern/cycles/SConscript
+++ b/intern/cycles/SConscript
@@ -37,6 +37,7 @@ sources = cycles.Glob('bvh/*.cpp') + cycles.Glob('device/*.cpp') + cycles.Glob('
sources.remove(path.join('util', 'util_view.cpp'))
sources.remove(path.join('kernel', 'kernel_sse2.cpp'))
sources.remove(path.join('kernel', 'kernel_sse3.cpp'))
+sources.remove(path.join('kernel', 'kernel_sse41.cpp'))
incs = []
defs = []
@@ -77,21 +78,30 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', '
if env['WITH_BF_RAYOPTIMIZATION']:
sse2_cxxflags = Split(env['CXXFLAGS'])
sse3_cxxflags = Split(env['CXXFLAGS'])
+ sse41_cxxflags = Split(env['CXXFLAGS'])
if env['OURPLATFORM'] == 'win32-vc':
# there is no /arch:SSE3, but intrinsics are available anyway
sse2_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
sse3_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
+ sse41_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
elif env['OURPLATFORM'] == 'win64-vc':
sse2_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
sse3_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
+ sse41_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split())
else:
sse2_cxxflags.append('-ffast-math -msse -msse2 -mfpmath=sse'.split())
sse3_cxxflags.append('-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse'.split())
+ sse41_cxxflags.append('-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mfpmath=sse'.split())
defs.append('WITH_OPTIMIZED_KERNEL')
optim_defs = defs[:]
+ # Disabled sse4+ patchs for now
+ #cycles_sse41 = cycles.Clone()
+ #sse41_sources = [path.join('kernel', 'kernel_sse41.cpp')]
+ #cycles_sse41.BlenderLib('bf_intern_cycles_sse41', sse41_sources, incs, optim_defs, libtype=['intern'], priority=[10], cxx_compileflags=sse41_cxxflags)
+
cycles_sse3 = cycles.Clone()
sse3_sources = [path.join('kernel', 'kernel_sse3.cpp')]
cycles_sse3.BlenderLib('bf_intern_cycles_sse3', sse3_sources, incs, optim_defs, libtype=['intern'], priority=[10], cxx_compileflags=sse3_cxxflags)
diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp
index 2a438397ae0..6b201017c46 100644
--- a/intern/cycles/app/cycles_standalone.cpp
+++ b/intern/cycles/app/cycles_standalone.cpp
@@ -190,7 +190,7 @@ static void keyboard(unsigned char key)
if(key == 'r')
options.session->reset(session_buffer_params(), options.session_params.samples);
else if(key == 27) // escape
- options.session->progress.set_cancel("Cancelled");
+ options.session->progress.set_cancel("Canceled");
}
#endif
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 367f021ee34..ac15acee0c5 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -253,26 +253,26 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
name="Max Bounces",
description="Total maximum number of bounces",
min=0, max=1024,
- default=8,
+ default=12,
)
cls.diffuse_bounces = IntProperty(
name="Diffuse Bounces",
description="Maximum number of diffuse reflection bounces, bounded by total maximum",
min=0, max=1024,
- default=128,
+ default=4,
)
cls.glossy_bounces = IntProperty(
name="Glossy Bounces",
description="Maximum number of glossy reflection bounces, bounded by total maximum",
min=0, max=1024,
- default=128,
+ default=4,
)
cls.transmission_bounces = IntProperty(
name="Transmission Bounces",
description="Maximum number of transmission bounces, bounded by total maximum",
min=0, max=1024,
- default=128,
+ default=12,
)
cls.transparent_min_bounces = IntProperty(
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 7a03df4f35a..cbf26fb8d0a 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -324,7 +324,7 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
rl = rd.layers.active
row = layout.row()
- row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2)
+ row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=1)
col = row.column(align=True)
col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
@@ -503,7 +503,7 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
if ob:
row = layout.row()
- row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=2)
+ row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=1)
col = row.column(align=True)
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 1cddc25a22b..b780877a158 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -628,6 +628,47 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
}
}
+static void ExportCurveSegmentsMotion(Scene *scene, Mesh *mesh, ParticleCurveData *CData, int motion)
+{
+ /* export motion vectors for curve keys */
+ AttributeStandard std = (motion == -1)? ATTR_STD_MOTION_PRE: ATTR_STD_MOTION_POST;
+ Attribute *attr_motion = mesh->curve_attributes.add(std);
+ float3 *data_motion = attr_motion->data_float3();
+ float3 *current_motion = data_motion;
+ size_t size = mesh->curve_keys.size();
+ size_t i = 0;
+ bool have_motion = false;
+
+ for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+ if(CData->psys_curvenum[sys] == 0)
+ continue;
+
+ for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
+ if(CData->curve_keynum[curve] <= 1)
+ continue;
+
+ for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; curvekey++) {
+ if(i < mesh->curve_keys.size()) {
+ *current_motion = CData->curvekey_co[curvekey];
+
+ /* unlike mesh coordinates, these tend to be slightly different
+ * between frames due to particle transforms into/out of object
+ * space, so we use an epsilon to detect actual changes */
+ if(len_squared(*current_motion - mesh->curve_keys[i].co) > 1e-5f*1e-5f)
+ have_motion = true;
+
+ current_motion++;
+ }
+
+ i++;
+ }
+ }
+ }
+
+ if(i != size || !have_motion)
+ mesh->curve_attributes.remove(std);
+}
+
void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata)
{
if(uvdata == NULL)
@@ -778,18 +819,21 @@ void BlenderSync::sync_curve_settings()
}
-void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool object_updated)
+void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, int motion)
{
- /* Clear stored curve data */
- mesh->curve_keys.clear();
- mesh->curves.clear();
- mesh->curve_attributes.clear();
+ if(!motion) {
+ /* Clear stored curve data */
+ mesh->curve_keys.clear();
+ mesh->curves.clear();
+ mesh->curve_attributes.clear();
+ }
/* obtain general settings */
bool use_curves = scene->curve_system_manager->use_curves;
if(!(use_curves && b_ob.mode() == b_ob.mode_OBJECT)) {
- mesh->compute_bounds();
+ if(!motion)
+ mesh->compute_bounds();
return;
}
@@ -829,13 +873,15 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
}
}
else {
- ExportCurveSegments(scene, mesh, &CData);
+ if(motion)
+ ExportCurveSegmentsMotion(scene, mesh, &CData, motion);
+ else
+ ExportCurveSegments(scene, mesh, &CData);
}
-
/* generated coordinates from first key. we should ideally get this from
* blender to handle deforming objects */
- {
+ if(!motion) {
if(mesh->need_attribute(scene, ATTR_STD_GENERATED)) {
float3 loc, size;
mesh_texture_space(b_mesh, loc, size);
@@ -861,7 +907,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
}
/* create vertex color attributes */
- {
+ if(!motion) {
BL::Mesh::tessface_vertex_colors_iterator l;
int vcol_num = 0;
@@ -895,7 +941,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
}
/* create UV attributes */
- {
+ if(!motion) {
BL::Mesh::tessface_uv_textures_iterator l;
int uv_num = 0;
@@ -943,6 +989,5 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
mesh->compute_bounds();
}
-
CCL_NAMESPACE_END
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 940a923e5af..e42af60c27b 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -488,7 +488,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
}
if(render_layer.use_hair)
- sync_curves(mesh, b_mesh, b_ob, object_updated);
+ sync_curves(mesh, b_mesh, b_ob, 0);
/* free derived mesh */
b_data.meshes.remove(b_mesh);
@@ -539,6 +539,12 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion)
if(!size || !ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview))
return;
+ /* ensure we only sync instanced meshes once */
+ if(mesh_motion_synced.find(mesh) != mesh_motion_synced.end())
+ return;
+
+ mesh_motion_synced.insert(mesh);
+
/* get derived mesh */
BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, false);
@@ -556,6 +562,10 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion)
if(i != size || memcmp(M, &mesh->verts[0], sizeof(float3)*size) == 0)
mesh->attributes.remove(std);
+ /* hair motion */
+ if(render_layer.use_hair)
+ sync_curves(mesh, b_mesh, b_ob, motion);
+
/* free derived mesh */
b_data.meshes.remove(b_mesh);
}
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 461e897efe1..ba584e172dc 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -405,6 +405,9 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
mesh_synced.clear();
particle_system_map.pre_sync();
}
+ else {
+ mesh_motion_synced.clear();
+ }
/* object loop */
BL::Scene::objects_iterator b_ob;
@@ -492,6 +495,9 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
scene->particle_system_manager->tag_update(scene);
mesh_synced.clear();
}
+
+ if(motion)
+ mesh_motion_synced.clear();
}
void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override)
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index b576181d890..a6d2b537bc7 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -673,59 +673,73 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
return node;
}
+static bool node_use_modified_socket_name(ShaderNode *node)
+{
+ if (node->special_type == SHADER_SPECIAL_TYPE_SCRIPT)
+ return false;
+
+ return true;
+}
+
static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket)
{
- BL::Node::inputs_iterator b_input;
string name = b_socket.name();
- bool found = false;
- int counter = 0, total = 0;
- for (b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
- if (b_input->name() == name) {
- if (!found)
- counter++;
- total++;
+ if (node_use_modified_socket_name(node)) {
+ BL::Node::inputs_iterator b_input;
+ bool found = false;
+ int counter = 0, total = 0;
+
+ for (b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
+ if (b_input->name() == name) {
+ if (!found)
+ counter++;
+ total++;
+ }
+
+ if(b_input->ptr.data == b_socket.ptr.data)
+ found = true;
}
-
- if(b_input->ptr.data == b_socket.ptr.data)
- found = true;
+
+ /* rename if needed */
+ if (name == "Shader")
+ name = "Closure";
+
+ if (total > 1)
+ name = string_printf("%s%d", name.c_str(), counter);
}
- /* rename if needed */
- if (name == "Shader")
- name = "Closure";
-
- if (total > 1)
- name = string_printf("%s%d", name.c_str(), counter);
-
return node->input(name.c_str());
}
static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket)
{
- BL::Node::outputs_iterator b_output;
string name = b_socket.name();
- bool found = false;
- int counter = 0, total = 0;
- for (b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
- if (b_output->name() == name) {
- if (!found)
- counter++;
- total++;
+ if (node_use_modified_socket_name(node)) {
+ BL::Node::outputs_iterator b_output;
+ bool found = false;
+ int counter = 0, total = 0;
+
+ for (b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
+ if (b_output->name() == name) {
+ if (!found)
+ counter++;
+ total++;
+ }
+
+ if(b_output->ptr.data == b_socket.ptr.data)
+ found = true;
}
-
- if(b_output->ptr.data == b_socket.ptr.data)
- found = true;
+
+ /* rename if needed */
+ if (name == "Shader")
+ name = "Closure";
+
+ if (total > 1)
+ name = string_printf("%s%d", name.c_str(), counter);
}
- /* rename if needed */
- if (name == "Shader")
- name = "Closure";
-
- if (total > 1)
- name = string_printf("%s%d", name.c_str(), counter);
-
return node->output(name.c_str());
}
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index f6e19229578..3d2a3ae5aac 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -81,7 +81,7 @@ private:
void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree);
Mesh *sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tris);
- void sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool object_updated);
+ void sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, int motion);
Object *sync_object(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::DupliObject b_dupli_object, Transform& tfm, uint layer_flag, int motion, bool hide_tris);
void sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::Object b_ob, Transform& tfm);
void sync_background_light();
@@ -108,6 +108,7 @@ private:
id_map<ObjectKey, Light> light_map;
id_map<ParticleSystemKey, ParticleSystem> particle_system_map;
set<Mesh*> mesh_synced;
+ set<Mesh*> mesh_motion_synced;
void *world_map;
bool world_recalc;
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 2c3c31b5429..b21b20a87e5 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -225,7 +225,7 @@ BVHNode* BVHBuild::run()
task_pool.wait_work();
}
- /* delete if we cancelled */
+ /* delete if we canceled */
if(rootnode) {
if(progress.get_cancel()) {
rootnode->deleteSubtree();
diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt
index fe2368b7ea8..920223dd8a4 100644
--- a/intern/cycles/device/CMakeLists.txt
+++ b/intern/cycles/device/CMakeLists.txt
@@ -13,6 +13,10 @@ set(INC_SYS
${GLEW_INCLUDE_PATH}
)
+if(WITH_CYCLES_OPTIMIZED_KERNEL_SSE41)
+ add_definitions(-DWITH_CYCLES_OPTIMIZED_KERNEL_SSE41=1)
+endif()
+
set(SRC
device.cpp
device_cpu.cpp
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index eb262a907a4..5c771aa1c8b 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -64,11 +64,16 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
glColor3f(1.0f, 1.0f, 1.0f);
if(rgba.data_type == TYPE_HALF) {
+ /* for multi devices, this assumes the ineffecient method that we allocate
+ * all pixels on the device even though we only render to a subset */
+ GLhalf *data_pointer = (GLhalf*)rgba.data_pointer;
+ data_pointer += 4*y*w;
+
/* draw half float texture, GLSL shader for display transform assumed to be bound */
GLuint texid;
glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, w, h, 0, GL_RGBA, GL_HALF_FLOAT, (void*)rgba.data_pointer);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, w, h, 0, GL_RGBA, GL_HALF_FLOAT, data_pointer);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index b1dbdec9d36..85a7b9c186d 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -58,6 +58,7 @@ public:
/* do now to avoid thread issues */
system_cpu_support_sse2();
system_cpu_support_sse3();
+ system_cpu_support_sse41();
}
~CPUDevice()
@@ -144,7 +145,7 @@ public:
void thread_path_trace(DeviceTask& task)
{
- if(task_pool.cancelled()) {
+ if(task_pool.canceled()) {
if(task.need_finish_queue == false)
return;
}
@@ -164,9 +165,31 @@ public:
int end_sample = tile.start_sample + tile.num_samples;
#ifdef WITH_OPTIMIZED_KERNEL
+#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
+ if(system_cpu_support_sse41()) {
+ for(int sample = start_sample; sample < end_sample; sample++) {
+ if (task.get_cancel() || task_pool.canceled()) {
+ if(task.need_finish_queue == false)
+ break;
+ }
+
+ for(int y = tile.y; y < tile.y + tile.h; y++) {
+ for(int x = tile.x; x < tile.x + tile.w; x++) {
+ kernel_cpu_sse41_path_trace(&kg, render_buffer, rng_state,
+ sample, x, y, tile.offset, tile.stride);
+ }
+ }
+
+ tile.sample = sample + 1;
+
+ task.update_progress(tile);
+ }
+ }
+ else
+#endif
if(system_cpu_support_sse3()) {
for(int sample = start_sample; sample < end_sample; sample++) {
- if (task.get_cancel() || task_pool.cancelled()) {
+ if (task.get_cancel() || task_pool.canceled()) {
if(task.need_finish_queue == false)
break;
}
@@ -185,7 +208,7 @@ public:
}
else if(system_cpu_support_sse2()) {
for(int sample = start_sample; sample < end_sample; sample++) {
- if (task.get_cancel() || task_pool.cancelled()) {
+ if (task.get_cancel() || task_pool.canceled()) {
if(task.need_finish_queue == false)
break;
}
@@ -206,7 +229,7 @@ public:
#endif
{
for(int sample = start_sample; sample < end_sample; sample++) {
- if (task.get_cancel() || task_pool.cancelled()) {
+ if (task.get_cancel() || task_pool.canceled()) {
if(task.need_finish_queue == false)
break;
}
@@ -226,7 +249,7 @@ public:
task.release_tile(tile);
- if(task_pool.cancelled()) {
+ if(task_pool.canceled()) {
if(task.need_finish_queue == false)
break;
}
@@ -243,6 +266,15 @@ public:
if(task.rgba_half) {
#ifdef WITH_OPTIMIZED_KERNEL
+#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
+ if(system_cpu_support_sse41()) {
+ for(int y = task.y; y < task.y + task.h; y++)
+ for(int x = task.x; x < task.x + task.w; x++)
+ kernel_cpu_sse41_convert_to_half_float(&kernel_globals, (uchar4*)task.rgba_half, (float*)task.buffer,
+ sample_scale, x, y, task.offset, task.stride);
+ }
+ else
+#endif
if(system_cpu_support_sse3()) {
for(int y = task.y; y < task.y + task.h; y++)
for(int x = task.x; x < task.x + task.w; x++)
@@ -266,6 +298,14 @@ public:
}
else {
#ifdef WITH_OPTIMIZED_KERNEL
+#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
+ if(system_cpu_support_sse41()) {
+ for(int y = task.y; y < task.y + task.h; y++)
+ for(int x = task.x; x < task.x + task.w; x++)
+ kernel_cpu_sse41_convert_to_byte(&kernel_globals, (uchar4*)task.rgba_byte, (float*)task.buffer,
+ sample_scale, x, y, task.offset, task.stride);
+ }
+#endif
if(system_cpu_support_sse3()) {
for(int y = task.y; y < task.y + task.h; y++)
for(int x = task.x; x < task.x + task.w; x++)
@@ -298,11 +338,21 @@ public:
#endif
#ifdef WITH_OPTIMIZED_KERNEL
+#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
+ if(system_cpu_support_sse41()) {
+ for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
+ kernel_cpu_sse41_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
+
+ if(task_pool.canceled())
+ break;
+ }
+ }
+#endif
if(system_cpu_support_sse3()) {
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.cancelled())
+ if(task_pool.canceled())
break;
}
}
@@ -310,7 +360,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.cancelled())
+ if(task_pool.canceled())
break;
}
}
@@ -320,7 +370,7 @@ public:
for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
kernel_cpu_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
- if(task_pool.cancelled())
+ if(task_pool.canceled())
break;
}
}
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 56ba0e08743..39444b91131 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -190,13 +190,18 @@ endif()
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})
-add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS})
-
if(WITH_CYCLES_OPTIMIZED_KERNEL)
set_source_files_properties(kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
set_source_files_properties(kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
endif()
+if(WITH_CYCLES_OPTIMIZED_KERNEL_SSE41)
+ set_source_files_properties(kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
+ list(APPEND SRC kernel_sse41.cpp)
+endif()
+
+add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS})
+
if(WITH_CYCLES_CUDA)
add_dependencies(cycles_kernel cycles_kernel_cuda)
endif()
diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h
index 86fea48760f..b3141d1154f 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf)
+ccl_device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf)
{
int label;
@@ -132,7 +132,7 @@ __device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderCl
return label;
}
-__device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf)
{
float3 eval;
@@ -275,7 +275,7 @@ __device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderC
return eval;
}
-__device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness)
+ccl_device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness)
{
#ifdef __OSL__
if(kg->osl && sc->prim) {
diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
index 94bc6eb0dc5..3631f90bf8c 100644
--- a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
+++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc)
+ccl_device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc)
{
float sigma = fmaxf(sc->data0, 0.01f);
sc->data0 = 1.0f/(sigma * sigma); /* m_invsigma2 */
@@ -45,11 +45,11 @@ __device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_ashikhmin_velvet_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_ashikhmin_velvet_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_invsigma2 = sc->data0;
float3 N = sc->N;
@@ -87,12 +87,12 @@ __device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, cons
return make_float3(0, 0, 0);
}
-__device float3 bsdf_ashikhmin_velvet_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_ashikhmin_velvet_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_invsigma2 = sc->data0;
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_diffuse.h b/intern/cycles/kernel/closure/bsdf_diffuse.h
index 46318ecd138..949fe869549 100644
--- a/intern/cycles/kernel/closure/bsdf_diffuse.h
+++ b/intern/cycles/kernel/closure/bsdf_diffuse.h
@@ -37,17 +37,17 @@ CCL_NAMESPACE_BEGIN
/* DIFFUSE */
-__device int bsdf_diffuse_setup(ShaderClosure *sc)
+ccl_device int bsdf_diffuse_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_DIFFUSE_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_diffuse_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_diffuse_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float3 N = sc->N;
@@ -56,12 +56,12 @@ __device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3
return make_float3(cos_pi, cos_pi, cos_pi);
}
-__device float3 bsdf_diffuse_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
@@ -84,22 +84,22 @@ __device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, f
/* TRANSLUCENT */
-__device int bsdf_translucent_setup(ShaderClosure *sc)
+ccl_device int bsdf_translucent_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_TRANSLUCENT_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_translucent_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_translucent_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_translucent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_translucent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float3 N = sc->N;
@@ -108,12 +108,12 @@ __device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const fl
return make_float3 (cos_pi, cos_pi, cos_pi);
}
-__device float bsdf_translucent_albedo(const ShaderClosure *sc, const float3 I)
+ccl_device float bsdf_translucent_albedo(const ShaderClosure *sc, const float3 I)
{
return 1.0f;
}
-__device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
index 2e43e16693f..b856774375f 100644
--- a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
+++ b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
+ccl_device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
{
int MAXCOLORS = 8;
@@ -49,17 +49,17 @@ __device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float
return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset;
}
-__device int bsdf_diffuse_ramp_setup(ShaderClosure *sc)
+ccl_device int bsdf_diffuse_ramp_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_DIFFUSE_RAMP_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
-__device void bsdf_diffuse_ramp_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_diffuse_ramp_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
{
float3 N = sc->N;
@@ -68,12 +68,12 @@ __device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const fl
return bsdf_diffuse_ramp_get_color(sc, colors, cos_pi) * M_1_PI_F;
}
-__device float3 bsdf_diffuse_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_hair.h b/intern/cycles/kernel/closure/bsdf_hair.h
index 5825d2637ba..163e7cc5ee2 100644
--- a/intern/cycles/kernel/closure/bsdf_hair.h
+++ b/intern/cycles/kernel/closure/bsdf_hair.h
@@ -36,15 +36,15 @@
CCL_NAMESPACE_BEGIN
-__device void bsdf_hair_reflection_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_hair_reflection_blur(ShaderClosure *sc, float roughness)
{
}
-__device void bsdf_hair_transmission_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_hair_transmission_blur(ShaderClosure *sc, float roughness)
{
}
-__device int bsdf_hair_reflection_setup(ShaderClosure *sc)
+ccl_device int bsdf_hair_reflection_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_HAIR_REFLECTION_ID;
sc->data0 = clamp(sc->data0, 0.001f, 1.0f);
@@ -52,7 +52,7 @@ __device int bsdf_hair_reflection_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device int bsdf_hair_transmission_setup(ShaderClosure *sc)
+ccl_device int bsdf_hair_transmission_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_HAIR_TRANSMISSION_ID;
sc->data0 = clamp(sc->data0, 0.001f, 1.0f);
@@ -60,7 +60,7 @@ __device int bsdf_hair_transmission_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
#ifdef __HAIR__
float offset = sc->offset;
@@ -106,18 +106,18 @@ __device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const
return make_float3(*pdf, *pdf, *pdf);
}
-__device float3 bsdf_hair_transmission_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_hair_transmission_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_hair_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_hair_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
#ifdef __HAIR__
float offset = sc->offset;
@@ -163,7 +163,7 @@ __device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, co
return make_float3(*pdf, *pdf, *pdf);
}
-__device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
#ifdef __HAIR__
float offset = sc->offset;
@@ -218,7 +218,7 @@ __device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, flo
return LABEL_REFLECT|LABEL_GLOSSY;
}
-__device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
#ifdef __HAIR__
float offset = sc->offset;
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index b159f585831..737cffb0f18 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* GGX */
-__device int bsdf_microfacet_ggx_setup(ShaderClosure *sc)
+ccl_device int bsdf_microfacet_ggx_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ag */
@@ -46,7 +46,7 @@ __device int bsdf_microfacet_ggx_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc)
+ccl_device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ag */
@@ -55,12 +55,12 @@ __device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_microfacet_ggx_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_microfacet_ggx_blur(ShaderClosure *sc, float roughness)
{
sc->data0 = fmaxf(roughness, sc->data0); /* m_ag */
}
-__device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ag = max(sc->data0, 1e-4f);
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
@@ -97,7 +97,7 @@ __device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ag = max(sc->data0, 1e-4f);
float m_eta = sc->data1;
@@ -134,7 +134,7 @@ __device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const
return make_float3 (out, out, out);
}
-__device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_ag = sc->data0;
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
@@ -255,7 +255,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, floa
/* BECKMANN */
-__device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc)
+ccl_device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ab */
@@ -263,7 +263,7 @@ __device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc)
+ccl_device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ab */
@@ -271,12 +271,12 @@ __device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness)
{
sc->data0 = fmaxf(roughness, sc->data0); /* m_ab */
}
-__device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ab = max(sc->data0, 1e-4f);
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
@@ -315,7 +315,7 @@ __device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, c
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ab = max(sc->data0, 1e-4f);
float m_eta = sc->data1;
@@ -354,7 +354,7 @@ __device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc,
return make_float3 (out, out, out);
}
-__device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_ab = sc->data0;
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
diff --git a/intern/cycles/kernel/closure/bsdf_oren_nayar.h b/intern/cycles/kernel/closure/bsdf_oren_nayar.h
index c6c6811c007..6f685d5eeea 100644
--- a/intern/cycles/kernel/closure/bsdf_oren_nayar.h
+++ b/intern/cycles/kernel/closure/bsdf_oren_nayar.h
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-__device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n, float3 v, float3 l)
+ccl_device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n, float3 v, float3 l)
{
float nl = max(dot(n, l), 0.0f);
float nv = max(dot(n, v), 0.0f);
@@ -31,7 +31,7 @@ __device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n,
return make_float3(is, is, is);
}
-__device int bsdf_oren_nayar_setup(ShaderClosure *sc)
+ccl_device int bsdf_oren_nayar_setup(ShaderClosure *sc)
{
float sigma = sc->data0;
@@ -47,11 +47,11 @@ __device int bsdf_oren_nayar_setup(ShaderClosure *sc)
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
-__device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
if (dot(sc->N, omega_in) > 0.0f) {
*pdf = 0.5f * M_1_PI_F;
@@ -63,12 +63,12 @@ __device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const floa
}
}
-__device float3 bsdf_oren_nayar_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_oren_nayar_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_oren_nayar_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_oren_nayar_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
sample_uniform_hemisphere(sc->N, randu, randv, omega_in, pdf);
diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
index 1e332933287..219c5aea159 100644
--- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h
+++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
+ccl_device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos)
{
int MAXCOLORS = 8;
@@ -49,7 +49,7 @@ __device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3
return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset;
}
-__device int bsdf_phong_ramp_setup(ShaderClosure *sc)
+ccl_device int bsdf_phong_ramp_setup(ShaderClosure *sc)
{
sc->data0 = max(sc->data0, 0.0f);
@@ -57,11 +57,11 @@ __device int bsdf_phong_ramp_setup(ShaderClosure *sc)
return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY;
}
-__device void bsdf_phong_ramp_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_phong_ramp_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
{
float m_exponent = sc->data0;
float cosNI = dot(sc->N, omega_in);
@@ -83,12 +83,12 @@ __device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const floa
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_phong_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_phong_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float cosNO = dot(sc->N, I);
float m_exponent = sc->data0;
diff --git a/intern/cycles/kernel/closure/bsdf_reflection.h b/intern/cycles/kernel/closure/bsdf_reflection.h
index 7715aac936f..0baccdf155c 100644
--- a/intern/cycles/kernel/closure/bsdf_reflection.h
+++ b/intern/cycles/kernel/closure/bsdf_reflection.h
@@ -37,27 +37,27 @@ CCL_NAMESPACE_BEGIN
/* REFLECTION */
-__device int bsdf_reflection_setup(ShaderClosure *sc)
+ccl_device int bsdf_reflection_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_REFLECTION_ID;
return SD_BSDF;
}
-__device void bsdf_reflection_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_reflection_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_refraction.h b/intern/cycles/kernel/closure/bsdf_refraction.h
index 8565c99d04e..c4698b42060 100644
--- a/intern/cycles/kernel/closure/bsdf_refraction.h
+++ b/intern/cycles/kernel/closure/bsdf_refraction.h
@@ -37,27 +37,27 @@ CCL_NAMESPACE_BEGIN
/* REFRACTION */
-__device int bsdf_refraction_setup(ShaderClosure *sc)
+ccl_device int bsdf_refraction_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_REFRACTION_ID;
return SD_BSDF;
}
-__device void bsdf_refraction_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_refraction_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_refraction_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_refraction_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_refraction_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_refraction_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_eta = sc->data0;
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bsdf_toon.h b/intern/cycles/kernel/closure/bsdf_toon.h
index e69981dba77..797fa4227ae 100644
--- a/intern/cycles/kernel/closure/bsdf_toon.h
+++ b/intern/cycles/kernel/closure/bsdf_toon.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* DIFFUSE TOON */
-__device int bsdf_diffuse_toon_setup(ShaderClosure *sc)
+ccl_device int bsdf_diffuse_toon_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_DIFFUSE_TOON_ID;
sc->data0 = clamp(sc->data0, 0.0f, 1.0f);
@@ -46,11 +46,11 @@ __device int bsdf_diffuse_toon_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_diffuse_toon_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_diffuse_toon_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float angle)
+ccl_device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float angle)
{
float is;
@@ -64,12 +64,12 @@ __device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float ang
return make_float3(is, is, is);
}
-__device float bsdf_toon_get_sample_angle(float max_angle, float smooth)
+ccl_device float bsdf_toon_get_sample_angle(float max_angle, float smooth)
{
return fminf(max_angle + smooth, M_PI_2_F);
}
-__device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float max_angle = sc->data0*M_PI_2_F;
float smooth = sc->data1*M_PI_2_F;
@@ -87,12 +87,12 @@ __device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const fl
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_diffuse_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_diffuse_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float max_angle = sc->data0*M_PI_2_F;
float smooth = sc->data1*M_PI_2_F;
@@ -121,7 +121,7 @@ __device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3
/* GLOSSY TOON */
-__device int bsdf_glossy_toon_setup(ShaderClosure *sc)
+ccl_device int bsdf_glossy_toon_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_GLOSSY_TOON_ID;
sc->data0 = clamp(sc->data0, 0.0f, 1.0f);
@@ -130,11 +130,11 @@ __device int bsdf_glossy_toon_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-__device void bsdf_glossy_toon_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_glossy_toon_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float max_angle = sc->data0*M_PI_2_F;
float smooth = sc->data1*M_PI_2_F;
@@ -158,12 +158,12 @@ __device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const flo
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_glossy_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_glossy_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float max_angle = sc->data0*M_PI_2_F;
float smooth = sc->data1*M_PI_2_F;
diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h
index 81bc7690b50..e62aecf3da6 100644
--- a/intern/cycles/kernel/closure/bsdf_transparent.h
+++ b/intern/cycles/kernel/closure/bsdf_transparent.h
@@ -35,27 +35,27 @@
CCL_NAMESPACE_BEGIN
-__device int bsdf_transparent_setup(ShaderClosure *sc)
+ccl_device int bsdf_transparent_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_BSDF_TRANSPARENT_ID;
return SD_BSDF;
}
-__device void bsdf_transparent_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_transparent_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_transparent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_transparent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device float3 bsdf_transparent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_transparent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_transparent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_transparent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
// only one direction is possible
*omega_in = -I;
diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h
index 5ac26055e8d..f6dceb3ca82 100644
--- a/intern/cycles/kernel/closure/bsdf_util.h
+++ b/intern/cycles/kernel/closure/bsdf_util.h
@@ -35,7 +35,7 @@
CCL_NAMESPACE_BEGIN
-__device float fresnel_dielectric(float eta, const float3 N,
+ccl_device float fresnel_dielectric(float eta, const float3 N,
const float3 I, float3 *R, float3 *T,
#ifdef __RAY_DIFFERENTIALS__
const float3 dIdx, const float3 dIdy,
@@ -95,7 +95,7 @@ __device float fresnel_dielectric(float eta, const float3 N,
}
}
-__device float fresnel_dielectric_cos(float cosi, float eta)
+ccl_device float fresnel_dielectric_cos(float cosi, float eta)
{
// compute fresnel reflectance without explicitly computing
// the refracted direction
@@ -110,7 +110,7 @@ __device float fresnel_dielectric_cos(float cosi, float eta)
return 1.0f; // TIR(no refracted component)
}
-__device float fresnel_conductor(float cosi, float eta, float k)
+ccl_device float fresnel_conductor(float cosi, float eta, float k)
{
float tmp_f = eta * eta + k * k;
float tmp = tmp_f * cosi * cosi;
@@ -121,7 +121,7 @@ __device float fresnel_conductor(float cosi, float eta, float k)
return(Rparl2 + Rperp2) * 0.5f;
}
-__device float smooth_step(float edge0, float edge1, float x)
+ccl_device float smooth_step(float edge0, float edge1, float x)
{
float result;
if(x < edge0) result = 0.0f;
diff --git a/intern/cycles/kernel/closure/bsdf_ward.h b/intern/cycles/kernel/closure/bsdf_ward.h
index 0e5b0c544c7..c9de615a011 100644
--- a/intern/cycles/kernel/closure/bsdf_ward.h
+++ b/intern/cycles/kernel/closure/bsdf_ward.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* WARD */
-__device int bsdf_ward_setup(ShaderClosure *sc)
+ccl_device int bsdf_ward_setup(ShaderClosure *sc)
{
sc->data0 = clamp(sc->data0, 1e-4f, 1.0f); /* m_ax */
sc->data1 = clamp(sc->data1, 1e-4f, 1.0f); /* m_ay */
@@ -46,13 +46,13 @@ __device int bsdf_ward_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_ward_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_ward_blur(ShaderClosure *sc, float roughness)
{
sc->data0 = fmaxf(roughness, sc->data0); /* m_ax */
sc->data1 = fmaxf(roughness, sc->data1); /* m_ay */
}
-__device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_ax = sc->data0;
float m_ay = sc->data1;
@@ -87,12 +87,12 @@ __device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I,
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_ward_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_ward_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_ward_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_ward_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_ax = sc->data0;
float m_ay = sc->data1;
diff --git a/intern/cycles/kernel/closure/bsdf_westin.h b/intern/cycles/kernel/closure/bsdf_westin.h
index e1a6b031d5e..ca4c05e91fe 100644
--- a/intern/cycles/kernel/closure/bsdf_westin.h
+++ b/intern/cycles/kernel/closure/bsdf_westin.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* WESTIN BACKSCATTER */
-__device int bsdf_westin_backscatter_setup(ShaderClosure *sc)
+ccl_device int bsdf_westin_backscatter_setup(ShaderClosure *sc)
{
float roughness = sc->data0;
roughness = clamp(roughness, 1e-5f, 1.0f);
@@ -49,14 +49,14 @@ __device int bsdf_westin_backscatter_setup(ShaderClosure *sc)
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_westin_backscatter_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_westin_backscatter_blur(ShaderClosure *sc, float roughness)
{
float m_invroughness = sc->data0;
m_invroughness = min(1.0f/roughness, m_invroughness);
sc->data0 = m_invroughness;
}
-__device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_invroughness = sc->data0;
float3 N = sc->N;
@@ -73,12 +73,12 @@ __device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, co
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_westin_backscatter_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_westin_backscatter_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_invroughness = sc->data0;
float3 N = sc->N;
@@ -116,18 +116,18 @@ __device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng,
/* WESTIN SHEEN */
-__device int bsdf_westin_sheen_setup(ShaderClosure *sc)
+ccl_device int bsdf_westin_sheen_setup(ShaderClosure *sc)
{
/* float edginess = sc->data0; */
sc->type = CLOSURE_BSDF_WESTIN_SHEEN_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY;
}
-__device void bsdf_westin_sheen_blur(ShaderClosure *sc, float roughness)
+ccl_device void bsdf_westin_sheen_blur(ShaderClosure *sc, float roughness)
{
}
-__device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float m_edginess = sc->data0;
float3 N = sc->N;
@@ -144,12 +144,12 @@ __device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const fl
return make_float3 (0, 0, 0);
}
-__device float3 bsdf_westin_sheen_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
+ccl_device float3 bsdf_westin_sheen_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
-__device int bsdf_westin_sheen_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+ccl_device int bsdf_westin_sheen_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
float m_edginess = sc->data0;
float3 N = sc->N;
diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h
index 4ceff655dd5..3849dedc3b6 100644
--- a/intern/cycles/kernel/closure/bssrdf.h
+++ b/intern/cycles/kernel/closure/bssrdf.h
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-__device int bssrdf_setup(ShaderClosure *sc, ClosureType type)
+ccl_device int bssrdf_setup(ShaderClosure *sc, ClosureType type)
{
if(sc->data0 < BSSRDF_MIN_RADIUS) {
/* revert to diffuse BSDF if radius too small */
@@ -47,7 +47,7 @@ __device int bssrdf_setup(ShaderClosure *sc, ClosureType type)
/* paper suggests 1/12.46 which is much too small, suspect it's *12.46 */
#define GAUSS_TRUNCATE 12.46f
-__device float bssrdf_gaussian_eval(ShaderClosure *sc, float r)
+ccl_device float bssrdf_gaussian_eval(ShaderClosure *sc, float r)
{
/* integrate (2*pi*r * exp(-r*r/(2*v)))/(2*pi*v)) from 0 to Rm
* = 1 - exp(-Rm*Rm/(2*v)) */
@@ -60,7 +60,7 @@ __device float bssrdf_gaussian_eval(ShaderClosure *sc, float r)
return expf(-r*r/(2.0f*v))/(2.0f*M_PI_F*v);
}
-__device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r)
+ccl_device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r)
{
/* 1.0 - expf(-Rm*Rm/(2*v)) simplified */
const float area_truncated = 1.0f - expf(-0.5f*GAUSS_TRUNCATE);
@@ -68,7 +68,7 @@ __device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r)
return bssrdf_gaussian_eval(sc, r) * (1.0f/(area_truncated));
}
-__device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, float *h)
+ccl_device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, float *h)
{
/* xi = integrate (2*pi*r * exp(-r*r/(2*v)))/(2*pi*v)) = -exp(-r^2/(2*v))
* r = sqrt(-2*v*logf(xi)) */
@@ -94,7 +94,7 @@ __device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, floa
* far as I can tell has no closed form solution. So we get an iterative solution
* instead with newton-raphson. */
-__device float bssrdf_cubic_eval(ShaderClosure *sc, float r)
+ccl_device float bssrdf_cubic_eval(ShaderClosure *sc, float r)
{
const float sharpness = sc->T.x;
@@ -141,13 +141,13 @@ __device float bssrdf_cubic_eval(ShaderClosure *sc, float r)
}
}
-__device float bssrdf_cubic_pdf(ShaderClosure *sc, float r)
+ccl_device float bssrdf_cubic_pdf(ShaderClosure *sc, float r)
{
return bssrdf_cubic_eval(sc, r);
}
/* solve 10x^2 - 20x^3 + 15x^4 - 4x^5 - xi == 0 */
-__device float bssrdf_cubic_quintic_root_find(float xi)
+ccl_device float bssrdf_cubic_quintic_root_find(float xi)
{
/* newton-raphson iteration, usually succeeds in 2-4 iterations, except
* outside 0.02 ... 0.98 where it can go up to 10, so overall performance
@@ -174,7 +174,7 @@ __device float bssrdf_cubic_quintic_root_find(float xi)
return x;
}
-__device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float *h)
+ccl_device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float *h)
{
float Rm = sc->data0;
float r_ = bssrdf_cubic_quintic_root_find(xi);
@@ -196,13 +196,13 @@ __device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float *
*
* Samples distributed over disk with no falloff, for reference. */
-__device float bssrdf_none_eval(ShaderClosure *sc, float r)
+ccl_device float bssrdf_none_eval(ShaderClosure *sc, float r)
{
const float Rm = sc->data0;
return (r < Rm)? 1.0f: 0.0f;
}
-__device float bssrdf_none_pdf(ShaderClosure *sc, float r)
+ccl_device float bssrdf_none_pdf(ShaderClosure *sc, float r)
{
/* integrate (2*pi*r)/(pi*Rm*Rm) from 0 to Rm = 1 */
const float Rm = sc->data0;
@@ -211,7 +211,7 @@ __device float bssrdf_none_pdf(ShaderClosure *sc, float r)
return bssrdf_none_eval(sc, r) / area;
}
-__device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h)
+ccl_device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h)
{
/* xi = integrate (2*pi*r)/(pi*Rm*Rm) = r^2/Rm^2
* r = sqrt(xi)*Rm */
@@ -226,7 +226,7 @@ __device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h
/* Generic */
-__device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h)
+ccl_device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h)
{
if(sc->type == CLOSURE_BSSRDF_CUBIC_ID)
bssrdf_cubic_sample(sc, xi, r, h);
@@ -234,7 +234,7 @@ __device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h)
bssrdf_gaussian_sample(sc, xi, r, h);
}
-__device float bssrdf_pdf(ShaderClosure *sc, float r)
+ccl_device float bssrdf_pdf(ShaderClosure *sc, float r)
{
if(sc->type == CLOSURE_BSSRDF_CUBIC_ID)
return bssrdf_cubic_pdf(sc, r);
diff --git a/intern/cycles/kernel/closure/emissive.h b/intern/cycles/kernel/closure/emissive.h
index 33b1b695a9a..c534df373bd 100644
--- a/intern/cycles/kernel/closure/emissive.h
+++ b/intern/cycles/kernel/closure/emissive.h
@@ -37,19 +37,19 @@ CCL_NAMESPACE_BEGIN
/* return the probability distribution function in the direction I,
* given the parameters and the light's surface normal. This MUST match
* the PDF computed by sample(). */
-__device float emissive_pdf(const float3 Ng, const float3 I)
+ccl_device float emissive_pdf(const float3 Ng, const float3 I)
{
float cosNO = fabsf(dot(Ng, I));
return (cosNO > 0.0f)? 1.0f: 0.0f;
}
-__device void emissive_sample(const float3 Ng, float randu, float randv,
+ccl_device void emissive_sample(const float3 Ng, float randu, float randv,
float3 *omega_out, float *pdf)
{
/* todo: not implemented and used yet */
}
-__device float3 emissive_simple_eval(const float3 Ng, const float3 I)
+ccl_device float3 emissive_simple_eval(const float3 Ng, const float3 I)
{
float res = emissive_pdf(Ng, I);
diff --git a/intern/cycles/kernel/closure/volume.h b/intern/cycles/kernel/closure/volume.h
index ddaf939984e..f30b30c8c76 100644
--- a/intern/cycles/kernel/closure/volume.h
+++ b/intern/cycles/kernel/closure/volume.h
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
/* ISOTROPIC VOLUME CLOSURE */
-__device int volume_isotropic_setup(ShaderClosure *sc, float density)
+ccl_device int volume_isotropic_setup(ShaderClosure *sc, float density)
{
sc->type = CLOSURE_VOLUME_ISOTROPIC_ID;
sc->data0 = density;
@@ -29,14 +29,14 @@ __device int volume_isotropic_setup(ShaderClosure *sc, float density)
return SD_VOLUME;
}
-__device float3 volume_isotropic_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
+ccl_device float3 volume_isotropic_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
{
return make_float3(1.0f, 1.0f, 1.0f);
}
/* TRANSPARENT VOLUME CLOSURE */
-__device int volume_transparent_setup(ShaderClosure *sc, float density)
+ccl_device int volume_transparent_setup(ShaderClosure *sc, float density)
{
sc->type = CLOSURE_VOLUME_TRANSPARENT_ID;
sc->data0 = density;
@@ -44,14 +44,14 @@ __device int volume_transparent_setup(ShaderClosure *sc, float density)
return SD_VOLUME;
}
-__device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
+ccl_device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
{
return make_float3(1.0f, 1.0f, 1.0f);
}
/* VOLUME CLOSURE */
-__device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
+ccl_device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
{
#ifdef __OSL__
if(kg->osl && sc->prim)
diff --git a/intern/cycles/kernel/kernel.cl b/intern/cycles/kernel/kernel.cl
index 28e72d78731..6988ad6027f 100644
--- a/intern/cycles/kernel/kernel.cl
+++ b/intern/cycles/kernel/kernel.cl
@@ -26,12 +26,12 @@
#include "kernel_displace.h"
__kernel void kernel_ocl_path_trace(
- __constant KernelData *data,
- __global float *buffer,
- __global uint *rng_state,
+ ccl_constant KernelData *data,
+ ccl_global float *buffer,
+ ccl_global uint *rng_state,
#define KERNEL_TEX(type, ttype, name) \
- __global type *name,
+ ccl_global type *name,
#include "kernel_textures.h"
int sample,
@@ -53,12 +53,12 @@ __kernel void kernel_ocl_path_trace(
}
__kernel void kernel_ocl_convert_to_byte(
- __constant KernelData *data,
- __global uchar4 *rgba,
- __global float *buffer,
+ ccl_constant KernelData *data,
+ ccl_global uchar4 *rgba,
+ ccl_global float *buffer,
#define KERNEL_TEX(type, ttype, name) \
- __global type *name,
+ ccl_global type *name,
#include "kernel_textures.h"
float sample_scale,
@@ -80,12 +80,12 @@ __kernel void kernel_ocl_convert_to_byte(
}
__kernel void kernel_ocl_convert_to_half_float(
- __constant KernelData *data,
- __global uchar4 *rgba,
- __global float *buffer,
+ ccl_constant KernelData *data,
+ ccl_global uchar4 *rgba,
+ ccl_global float *buffer,
#define KERNEL_TEX(type, ttype, name) \
- __global type *name,
+ ccl_global type *name,
#include "kernel_textures.h"
float sample_scale,
@@ -107,12 +107,12 @@ __kernel void kernel_ocl_convert_to_half_float(
}
__kernel void kernel_ocl_shader(
- __constant KernelData *data,
- __global uint4 *input,
- __global float4 *output,
+ ccl_constant KernelData *data,
+ ccl_global uint4 *input,
+ ccl_global float4 *output,
#define KERNEL_TEX(type, ttype, name) \
- __global type *name,
+ ccl_global type *name,
#include "kernel_textures.h"
int type, int sx, int sw)
diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h
index 361f5b0856d..105a3887da0 100644
--- a/intern/cycles/kernel/kernel.h
+++ b/intern/cycles/kernel/kernel.h
@@ -61,6 +61,15 @@ void kernel_cpu_sse3_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, floa
float sample_scale, int x, int y, int offset, int stride);
void kernel_cpu_sse3_shader(KernelGlobals *kg, uint4 *input, float4 *output,
int type, int i);
+
+void kernel_cpu_sse41_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state,
+ int sample, int x, int y, int offset, int stride);
+void kernel_cpu_sse41_convert_to_byte(KernelGlobals *kg, uchar4 *rgba, float *buffer,
+ float sample_scale, int x, int y, int offset, int stride);
+void kernel_cpu_sse41_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, float *buffer,
+ float sample_scale, int x, int y, int offset, int stride);
+void kernel_cpu_sse41_shader(KernelGlobals *kg, uint4 *input, float4 *output,
+ int type, int i);
#endif
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h
index d7531be0d8a..f4febd7cf2c 100644
--- a/intern/cycles/kernel/kernel_accumulate.h
+++ b/intern/cycles/kernel/kernel_accumulate.h
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
* BSDF evaluation result, split per BSDF type. This is used to accumulate
* render passes separately. */
-__device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass)
+ccl_device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass)
{
#ifdef __PASSES__
eval->use_light_pass = use_light_pass;
@@ -51,7 +51,7 @@ __device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 val
#endif
}
-__device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value)
+ccl_device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value)
{
#ifdef __PASSES__
if(eval->use_light_pass) {
@@ -73,7 +73,7 @@ __device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 va
#endif
}
-__device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
+ccl_device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
{
#ifdef __PASSES__
if(eval->use_light_pass) {
@@ -90,7 +90,7 @@ __device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
#endif
}
-__device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value)
+ccl_device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value)
{
#ifdef __PASSES__
if(eval->use_light_pass) {
@@ -115,7 +115,7 @@ __device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value)
* visible as the first non-transparent hit, while indirectly visible are the
* bounces after that. */
-__device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
+ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
{
/* clear all */
#ifdef __PASSES__
@@ -159,7 +159,7 @@ __device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
#endif
}
-__device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughput,
+ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughput,
BsdfEval *bsdf_eval, float bsdf_pdf, int bounce, int bsdf_label)
{
float inverse_pdf = 1.0f/bsdf_pdf;
@@ -192,7 +192,7 @@ __device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughp
#endif
}
-__device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce)
+ccl_device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -210,7 +210,7 @@ __device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throug
#endif
}
-__device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, float3 bsdf, float3 ao, int bounce)
+ccl_device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, float3 bsdf, float3 ao, int bounce)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -231,7 +231,7 @@ __device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput,
#endif
}
-__device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, int bounce, bool is_lamp)
+ccl_device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, int bounce, bool is_lamp)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -261,7 +261,7 @@ __device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughpu
#endif
}
-__device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce)
+ccl_device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -279,7 +279,7 @@ __device_inline void path_radiance_accum_background(PathRadiance *L, float3 thro
#endif
}
-__device_inline void path_radiance_sum_indirect(PathRadiance *L)
+ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L)
{
#ifdef __PASSES__
/* this division is a bit ugly, but means we only have to keep track of
@@ -301,7 +301,7 @@ __device_inline void path_radiance_sum_indirect(PathRadiance *L)
#endif
}
-__device_inline void path_radiance_reset_indirect(PathRadiance *L)
+ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -316,7 +316,7 @@ __device_inline void path_radiance_reset_indirect(PathRadiance *L)
#endif
}
-__device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L)
+ccl_device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L)
{
#ifdef __PASSES__
if(L->use_light_pass) {
@@ -338,7 +338,7 @@ __device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L)
#endif
}
-__device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float clamp)
+ccl_device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float clamp)
{
float sum = fabsf((*L_sum).x) + fabsf((*L_sum).y) + fabsf((*L_sum).z);
diff --git a/intern/cycles/kernel/kernel_bvh.h b/intern/cycles/kernel/kernel_bvh.h
index 44a9822c103..5aae4111fca 100644
--- a/intern/cycles/kernel/kernel_bvh.h
+++ b/intern/cycles/kernel/kernel_bvh.h
@@ -42,7 +42,7 @@ CCL_NAMESPACE_BEGIN
#define NO_EXTENDED_PRECISION volatile
#endif
-__device_inline float3 bvh_inverse_direction(float3 dir)
+ccl_device_inline float3 bvh_inverse_direction(float3 dir)
{
/* avoid divide by zero (ooeps = exp2f(-80.0f)) */
float ooeps = 0.00000000000000000000000082718061255302767487140869206996285356581211090087890625f;
@@ -55,7 +55,7 @@ __device_inline float3 bvh_inverse_direction(float3 dir)
return idir;
}
-__device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
+ccl_device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
{
Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
@@ -72,7 +72,7 @@ __device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray
*t *= len;
}
-__device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
+ccl_device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax)
{
if(*t != FLT_MAX) {
Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
@@ -84,7 +84,7 @@ __device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *
}
#ifdef __OBJECT_MOTION__
-__device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
+ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
{
Transform itfm;
*tfm = object_fetch_transform_motion_test(kg, object, ray->time, &itfm);
@@ -102,7 +102,7 @@ __device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, con
*t *= len;
}
-__device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
+ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax)
{
if(*t != FLT_MAX)
*t *= len(transform_direction(tfm, 1.0f/(*idir)));
@@ -113,7 +113,7 @@ __device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, cons
#endif
/* Sven Woop's algorithm */
-__device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *isect,
+ccl_device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *isect,
float3 P, float3 idir, uint visibility, int object, int triAddr)
{
/* compute and check intersection t-value */
@@ -161,7 +161,7 @@ __device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *ise
}
#ifdef __HAIR__
-__device_inline void curvebounds(float *lower, float *upper, float *extremta, float *extrema, float *extremtb, float *extremb, float p0, float p1, float p2, float p3)
+ccl_device_inline void curvebounds(float *lower, float *upper, float *extremta, float *extrema, float *extremtb, float *extremb, float p0, float p1, float p2, float p3)
{
float halfdiscroot = (p2 * p2 - 3 * p3 * p1);
float ta = -1.0f;
@@ -211,7 +211,7 @@ __device_inline void curvebounds(float *lower, float *upper, float *extremta, fl
}
}
-__device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect,
+ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect,
float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax)
{
float epsilon = 0.0f;
@@ -520,7 +520,7 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio
return hit;
}
-__device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
+ccl_device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax)
{
/* curve Intersection check */
@@ -689,7 +689,7 @@ __device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
* only want to intersect with primitives in the same object, and if case of
* multiple hits we pick a single random primitive as the intersection point. */
-__device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Intersection *isect_array,
+ccl_device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Intersection *isect_array,
float3 P, float3 idir, int object, int triAddr, float tmax, uint *num_hits, uint *lcg_state, int max_hits)
{
/* compute and check intersection t-value */
@@ -811,9 +811,9 @@ __device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Inters
/* to work around titan bug when using arrays instead of textures */
#if !defined(__KERNEL_CUDA__) || defined(__KERNEL_CUDA_TEX_STORAGE__)
-__device_inline
+ccl_device_inline
#else
-__device_noinline
+ccl_device_noinline
#endif
#ifdef __HAIR__
bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, Intersection *isect, uint *lcg_state, float difl, float extmax)
@@ -859,9 +859,9 @@ bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, I
/* to work around titan bug when using arrays instead of textures */
#ifdef __SUBSURFACE__
#if !defined(__KERNEL_CUDA__) || defined(__KERNEL_CUDA_TEX_STORAGE__)
-__device_inline
+ccl_device_inline
#else
-__device_noinline
+ccl_device_noinline
#endif
uint scene_intersect_subsurface(KernelGlobals *kg, const Ray *ray, Intersection *isect, int subsurface_object, uint *lcg_state, int max_hits)
{
@@ -903,7 +903,7 @@ uint scene_intersect_subsurface(KernelGlobals *kg, const Ray *ray, Intersection
/* Ray offset to avoid self intersection */
-__device_inline float3 ray_offset(float3 P, float3 Ng)
+ccl_device_inline float3 ray_offset(float3 P, float3 Ng)
{
#ifdef __INTERSECTION_REFINE__
const float epsilon_f = 1e-5f;
@@ -955,7 +955,7 @@ __device_inline float3 ray_offset(float3 P, float3 Ng)
* far the precision is often not so good, this reintersects the primitive from
* a closer distance. */
-__device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
+ccl_device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
{
float3 P = ray->P;
float3 D = ray->D;
@@ -1000,7 +1000,7 @@ __device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, co
}
/* same as above, except that isect->t is assumed to be in object space for instancing */
-__device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
+ccl_device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray)
{
float3 P = ray->P;
float3 D = ray->D;
@@ -1046,7 +1046,7 @@ __device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderD
#ifdef __HAIR__
-__device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3)
+ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3)
{
float fc = 0.71f;
float data[4];
@@ -1058,7 +1058,7 @@ __device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, fl
return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
}
-__device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3)
+ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3)
{
float data[4];
float fc = 0.71f;
@@ -1071,7 +1071,7 @@ __device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, floa
return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3;
}
-__device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray, float t)
+ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray, float t)
{
int flag = kernel_data.curve.curveflags;
float3 P = ray->P;
diff --git a/intern/cycles/kernel/kernel_bvh_subsurface.h b/intern/cycles/kernel/kernel_bvh_subsurface.h
index 4446c1821d5..fb41bdcfa37 100644
--- a/intern/cycles/kernel/kernel_bvh_subsurface.h
+++ b/intern/cycles/kernel/kernel_bvh_subsurface.h
@@ -28,7 +28,7 @@
#define FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0)
-__device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersection *isect_array,
+ccl_device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersection *isect_array,
int subsurface_object, uint *lcg_state, int max_hits)
{
/* todo:
diff --git a/intern/cycles/kernel/kernel_bvh_traversal.h b/intern/cycles/kernel/kernel_bvh_traversal.h
index a9264f318eb..8f69083575b 100644
--- a/intern/cycles/kernel/kernel_bvh_traversal.h
+++ b/intern/cycles/kernel/kernel_bvh_traversal.h
@@ -30,7 +30,7 @@
#define FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0)
-__device bool BVH_FUNCTION_NAME
+ccl_device bool BVH_FUNCTION_NAME
(KernelGlobals *kg, const Ray *ray, Intersection *isect, const uint visibility
#if FEATURE(BVH_HAIR_MINIMUM_WIDTH)
, uint *lcg_state, float difl, float extmax
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h
index 966f28df05f..887b1afddd4 100644
--- a/intern/cycles/kernel/kernel_camera.h
+++ b/intern/cycles/kernel/kernel_camera.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Perspective Camera */
-__device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v)
+ccl_device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v)
{
float blades = kernel_data.cam.blades;
@@ -33,7 +33,7 @@ __device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v)
}
}
-__device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
+ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
{
/* create ray form raster position */
Transform rastertocamera = kernel_data.cam.rastertocamera;
@@ -91,7 +91,7 @@ __device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float
/* Orthographic Camera */
-__device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
+ccl_device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
{
/* create ray form raster position */
Transform rastertocamera = kernel_data.cam.rastertocamera;
@@ -147,7 +147,7 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa
/* Panorama Camera */
-__device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
+ccl_device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
{
Transform rastertocamera = kernel_data.cam.rastertocamera;
float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f));
@@ -216,7 +216,7 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra
/* Common */
-__device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v,
+ccl_device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v,
float lens_u, float lens_v, float time, Ray *ray)
{
/* pixel filter */
@@ -243,13 +243,13 @@ __device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, flo
/* Utilities */
-__device_inline float3 camera_position(KernelGlobals *kg)
+ccl_device_inline float3 camera_position(KernelGlobals *kg)
{
Transform cameratoworld = kernel_data.cam.cameratoworld;
return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
}
-__device_inline float camera_distance(KernelGlobals *kg, float3 P)
+ccl_device_inline float camera_distance(KernelGlobals *kg, float3 P)
{
Transform cameratoworld = kernel_data.cam.cameratoworld;
float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
@@ -262,7 +262,7 @@ __device_inline float camera_distance(KernelGlobals *kg, float3 P)
return len(P - camP);
}
-__device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P)
+ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P)
{
if(kernel_data.cam.type != CAMERA_PANORAMA) {
/* perspective / ortho */
diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h
index 44c2b9effe9..76f885aefe0 100644
--- a/intern/cycles/kernel/kernel_compat_cuda.h
+++ b/intern/cycles/kernel/kernel_compat_cuda.h
@@ -27,13 +27,12 @@
/* Qualifier wrappers for different names on different devices */
-#define __device __device__ __inline__
-#define __device_inline __device__ __inline__
-#define __device_noinline __device__ __noinline__
-#define __global
-#define __shared __shared__
-#define __constant
-#define __may_alias
+#define ccl_device __device__ __inline__
+#define ccl_device_inline __device__ __inline__
+#define ccl_device_noinline __device__ __noinline__
+#define ccl_global
+#define ccl_constant
+#define ccl_may_alias
/* No assert supported for CUDA */
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h
index e0102a01146..1ff3615e448 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -33,16 +33,18 @@
#endif
#ifdef __CL_NOINLINE__
-#define __noinline __attribute__((noinline))
+#define ccl_noinline __attribute__((noinline))
#else
-#define __noinline
+#define ccl_noinline
#endif
/* in opencl all functions are device functions, so leave this empty */
-#define __device
-#define __device_inline __device
-#define __device_noinline __device __noinline
-#define __may_alias
+#define ccl_device
+#define ccl_device_inline ccl_device
+#define ccl_device_noinline ccl_device ccl_noinline
+#define ccl_may_alias
+#define ccl_constant __constant
+#define ccl_global __global
/* no assert in opencl */
#define kernel_assert(cond)
diff --git a/intern/cycles/kernel/kernel_curve.h b/intern/cycles/kernel/kernel_curve.h
index 9f7a1388a2b..821ac50eaa9 100644
--- a/intern/cycles/kernel/kernel_curve.h
+++ b/intern/cycles/kernel/kernel_curve.h
@@ -20,7 +20,7 @@ CCL_NAMESPACE_BEGIN
/* curve attributes */
-__device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
+ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
{
if(elem == ATTR_ELEMENT_CURVE) {
#ifdef __RAY_DIFFERENTIALS__
@@ -55,7 +55,7 @@ __device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, At
}
}
-__device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
+ccl_device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
{
if(elem == ATTR_ELEMENT_CURVE) {
/* idea: we can't derive any useful differentials here, but for tiled
@@ -96,7 +96,7 @@ __device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd,
/* hair info node functions */
-__device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
+ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
{
float r = 0.0f;
@@ -113,7 +113,7 @@ __device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
return r*2.0f;
}
-__device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
{
float3 tgN = make_float3(0.0f,0.0f,0.0f);
diff --git a/intern/cycles/kernel/kernel_differential.h b/intern/cycles/kernel/kernel_differential.h
index 71d6e87a4d9..daba2d927b7 100644
--- a/intern/cycles/kernel/kernel_differential.h
+++ b/intern/cycles/kernel/kernel_differential.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* See "Tracing Ray Differentials", Homan Igehy, 1999. */
-__device void differential_transfer(differential3 *dP_, const differential3 dP, float3 D, const differential3 dD, float3 Ng, float t)
+ccl_device void differential_transfer(differential3 *dP_, const differential3 dP, float3 D, const differential3 dD, float3 Ng, float t)
{
/* ray differential transfer through homogeneous medium, to
* compute dPdx/dy at a shading point from the incoming ray */
@@ -31,7 +31,7 @@ __device void differential_transfer(differential3 *dP_, const differential3 dP,
dP_->dy = tmpy - dot(tmpy, Ng)*tmp;
}
-__device void differential_incoming(differential3 *dI, const differential3 dD)
+ccl_device void differential_incoming(differential3 *dI, const differential3 dD)
{
/* compute dIdx/dy at a shading point, we just need to negate the
* differential of the ray direction */
@@ -40,7 +40,7 @@ __device void differential_incoming(differential3 *dI, const differential3 dD)
dI->dy = -dD.dy;
}
-__device void differential_dudv(differential *du, differential *dv, float3 dPdu, float3 dPdv, differential3 dP, float3 Ng)
+ccl_device void differential_dudv(differential *du, differential *dv, float3 dPdu, float3 dPdv, differential3 dP, float3 Ng)
{
/* now we have dPdx/dy from the ray differential transfer, and dPdu/dv
* from the primitive, we can compute dudx/dy and dvdx/dy. these are
@@ -84,7 +84,7 @@ __device void differential_dudv(differential *du, differential *dv, float3 dPdu,
dv->dy = (dP.dy.y*dPdu.x - dP.dy.x*dPdu.y)*det;
}
-__device differential differential_zero()
+ccl_device differential differential_zero()
{
differential d;
d.dx = 0.0f;
@@ -93,7 +93,7 @@ __device differential differential_zero()
return d;
}
-__device differential3 differential3_zero()
+ccl_device differential3 differential3_zero()
{
differential3 d;
d.dx = make_float3(0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/kernel/kernel_displace.h b/intern/cycles/kernel/kernel_displace.h
index 38152b5571e..c50e2166660 100644
--- a/intern/cycles/kernel/kernel_displace.h
+++ b/intern/cycles/kernel/kernel_displace.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void kernel_shader_evaluate(KernelGlobals *kg, __global uint4 *input, __global float4 *output, ShaderEvalType type, int i)
+ccl_device void kernel_shader_evaluate(KernelGlobals *kg, ccl_global uint4 *input, ccl_global float4 *output, ShaderEvalType type, int i)
{
ShaderData sd;
uint4 in = input[i];
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index 0c8d69fb594..2ce0b758972 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Direction Emission */
-__device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
+ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
LightSample *ls, float u, float v, float3 I, differential3 dI, float t, float time, int bounce)
{
/* setup shading at emitter */
@@ -70,7 +70,7 @@ __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
return eval;
}
-__device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
+ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval,
bool *is_lamp, int bounce)
{
@@ -160,7 +160,7 @@ __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int li
/* Indirect Primitive Emission */
-__device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf)
+ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf)
{
/* evaluate emissive closure */
float3 L = shader_emissive_eval(kg, sd);
@@ -183,7 +183,7 @@ __device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderDa
/* Indirect Lamp Emission */
-__device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission, int bounce)
+ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission, int bounce)
{
LightSample ls;
int lamp = lamp_light_eval_sample(kg, randt);
@@ -222,7 +222,7 @@ __device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int p
/* Indirect Background */
-__device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, int bounce)
+ccl_device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, int bounce)
{
#ifdef __BACKGROUND__
int shader = kernel_data.background.shader;
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h
index 721eceabc37..b4118666491 100644
--- a/intern/cycles/kernel/kernel_film.h
+++ b/intern/cycles/kernel/kernel_film.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale)
+ccl_device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale)
{
float exposure = kernel_data.film.exposure;
float4 result = irradiance*scale;
@@ -32,7 +32,7 @@ __device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale)
return result;
}
-__device uchar4 film_float_to_byte(float4 color)
+ccl_device uchar4 film_float_to_byte(float4 color)
{
uchar4 result;
@@ -45,8 +45,8 @@ __device uchar4 film_float_to_byte(float4 color)
return result;
}
-__device void kernel_film_convert_to_byte(KernelGlobals *kg,
- __global uchar4 *rgba, __global float *buffer,
+ccl_device void kernel_film_convert_to_byte(KernelGlobals *kg,
+ ccl_global uchar4 *rgba, ccl_global float *buffer,
float sample_scale, int x, int y, int offset, int stride)
{
/* buffer offset */
@@ -56,25 +56,36 @@ __device void kernel_film_convert_to_byte(KernelGlobals *kg,
buffer += index*kernel_data.film.pass_stride;
/* map colors */
- float4 irradiance = *((__global float4*)buffer);
+ float4 irradiance = *((ccl_global float4*)buffer);
float4 float_result = film_map(kg, irradiance, sample_scale);
uchar4 byte_result = film_float_to_byte(float_result);
*rgba = byte_result;
}
-__device void kernel_film_convert_to_half_float(KernelGlobals *kg,
- __global uchar4 *rgba, __global float *buffer,
+ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg,
+ ccl_global uchar4 *rgba, ccl_global float *buffer,
float sample_scale, int x, int y, int offset, int stride)
{
/* buffer offset */
int index = offset + x + y*stride;
- __global float4 *in = (__global float4*)(buffer + index*kernel_data.film.pass_stride);
- __global half *out = (__global half*)rgba + index*4;
- float scale = kernel_data.film.exposure*sample_scale;
+ ccl_global float4 *in = (ccl_global float4*)(buffer + index*kernel_data.film.pass_stride);
+ ccl_global half *out = (ccl_global half*)rgba + index*4;
- float4_store_half(out, in, scale);
+ float exposure = kernel_data.film.exposure;
+
+ if(exposure == 1.0f) {
+ float4_store_half(out, in, sample_scale);
+ }
+ else {
+ float4 rgba = *in;
+ rgba.x *= exposure;
+ rgba.y *= exposure;
+ rgba.z *= exposure;
+
+ float4_store_half(out, &rgba, sample_scale);
+ }
}
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h
index b5e691eb615..e60bd6c0067 100644
--- a/intern/cycles/kernel/kernel_globals.h
+++ b/intern/cycles/kernel/kernel_globals.h
@@ -81,10 +81,10 @@ typedef struct KernelGlobals {} KernelGlobals;
#ifdef __KERNEL_OPENCL__
typedef struct KernelGlobals {
- __constant KernelData *data;
+ ccl_constant KernelData *data;
#define KERNEL_TEX(type, ttype, name) \
- __global type *name;
+ ccl_global type *name;
#include "kernel_textures.h"
} KernelGlobals;
@@ -92,7 +92,7 @@ typedef struct KernelGlobals {
/* Interpolated lookup table access */
-__device float lookup_table_read(KernelGlobals *kg, float x, int offset, int size)
+ccl_device float lookup_table_read(KernelGlobals *kg, float x, int offset, int size)
{
x = clamp(x, 0.0f, 1.0f)*(size-1);
@@ -108,7 +108,7 @@ __device float lookup_table_read(KernelGlobals *kg, float x, int offset, int siz
return (1.0f - t)*data0 + t*data1;
}
-__device float lookup_table_read_2D(KernelGlobals *kg, float x, float y, int offset, int xsize, int ysize)
+ccl_device float lookup_table_read_2D(KernelGlobals *kg, float x, float y, int offset, int xsize, int ysize)
{
y = clamp(y, 0.0f, 1.0f)*(ysize-1);
diff --git a/intern/cycles/kernel/kernel_jitter.h b/intern/cycles/kernel/kernel_jitter.h
index 18666b51c0c..7a850844bf2 100644
--- a/intern/cycles/kernel/kernel_jitter.h
+++ b/intern/cycles/kernel/kernel_jitter.h
@@ -22,18 +22,18 @@ CCL_NAMESPACE_BEGIN
/* todo: find good value, suggested 64 gives pattern on cornell box ceiling */
#define CMJ_RANDOM_OFFSET_LIMIT 4096
-__device_inline bool cmj_is_pow2(int i)
+ccl_device_inline bool cmj_is_pow2(int i)
{
return (i & (i - 1)) == 0;
}
-__device_inline int cmj_fast_mod_pow2(int a, int b)
+ccl_device_inline int cmj_fast_mod_pow2(int a, int b)
{
return (a & (b - 1));
}
/* a must be > 0 and b must be > 1 */
-__device_inline int cmj_fast_div_pow2(int a, int b)
+ccl_device_inline int cmj_fast_div_pow2(int a, int b)
{
#if defined(__KERNEL_SSE2__) && !defined(_MSC_VER)
return a >> __builtin_ctz(b);
@@ -42,7 +42,7 @@ __device_inline int cmj_fast_div_pow2(int a, int b)
#endif
}
-__device_inline uint cmj_w_mask(uint w)
+ccl_device_inline uint cmj_w_mask(uint w)
{
#if defined(__KERNEL_SSE2__) && !defined(_MSC_VER)
return ((1 << (32 - __builtin_clz(w))) - 1);
@@ -57,7 +57,7 @@ __device_inline uint cmj_w_mask(uint w)
#endif
}
-__device_inline uint cmj_permute(uint i, uint l, uint p)
+ccl_device_inline uint cmj_permute(uint i, uint l, uint p)
{
uint w = l - 1;
@@ -113,7 +113,7 @@ __device_inline uint cmj_permute(uint i, uint l, uint p)
}
}
-__device_inline uint cmj_hash(uint i, uint p)
+ccl_device_inline uint cmj_hash(uint i, uint p)
{
i ^= p;
i ^= i >> 17;
@@ -129,13 +129,13 @@ __device_inline uint cmj_hash(uint i, uint p)
return i;
}
-__device_inline float cmj_randfloat(uint i, uint p)
+ccl_device_inline float cmj_randfloat(uint i, uint p)
{
return cmj_hash(i, p) * (1.0f / 4294967808.0f);
}
#ifdef __CMJ__
-__device float cmj_sample_1D(int s, int N, int p)
+ccl_device float cmj_sample_1D(int s, int N, int p)
{
kernel_assert(s < N);
@@ -146,7 +146,7 @@ __device float cmj_sample_1D(int s, int N, int p)
return (x + jx)*invN;
}
-__device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy)
+ccl_device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy)
{
kernel_assert(s < N);
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 6b00bd2ab01..9915cd2495f 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -36,7 +36,7 @@ typedef struct LightSample {
#ifdef __BACKGROUND_MIS__
-__device float3 background_light_sample(KernelGlobals *kg, float randu, float randv, float *pdf)
+ccl_device float3 background_light_sample(KernelGlobals *kg, float randu, float randv, float *pdf)
{
/* for the following, the CDF values are actually a pair of floats, with the
* function value as X and the actual CDF as Y. The last entry's function
@@ -112,7 +112,7 @@ __device float3 background_light_sample(KernelGlobals *kg, float randu, float ra
return -equirectangular_to_direction(u, v);
}
-__device float background_light_pdf(KernelGlobals *kg, float3 direction)
+ccl_device float background_light_pdf(KernelGlobals *kg, float3 direction)
{
float2 uv = direction_to_equirectangular(direction);
int res = kernel_data.integrator.pdf_background_res;
@@ -146,7 +146,7 @@ __device float background_light_pdf(KernelGlobals *kg, float3 direction)
/* Regular Light */
-__device float3 disk_light_sample(float3 v, float randu, float randv)
+ccl_device float3 disk_light_sample(float3 v, float randu, float randv)
{
float3 ru, rv;
@@ -156,17 +156,17 @@ __device float3 disk_light_sample(float3 v, float randu, float randv)
return ru*randu + rv*randv;
}
-__device float3 distant_light_sample(float3 D, float radius, float randu, float randv)
+ccl_device float3 distant_light_sample(float3 D, float radius, float randu, float randv)
{
return normalize(D + disk_light_sample(D, randu, randv)*radius);
}
-__device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv)
+ccl_device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv)
{
return disk_light_sample(normalize(P - center), randu, randv)*radius;
}
-__device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float randv)
+ccl_device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float randv)
{
randu = randu - 0.5f;
randv = randv - 0.5f;
@@ -174,7 +174,7 @@ __device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float
return axisu*randu + axisv*randv;
}
-__device float spot_light_attenuation(float4 data1, float4 data2, LightSample *ls)
+ccl_device float spot_light_attenuation(float4 data1, float4 data2, LightSample *ls)
{
float3 dir = make_float3(data2.y, data2.z, data2.w);
float3 I = ls->Ng;
@@ -197,7 +197,7 @@ __device float spot_light_attenuation(float4 data1, float4 data2, LightSample *l
return attenuation;
}
-__device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t)
+ccl_device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t)
{
float cos_pi = dot(Ng, I);
@@ -207,7 +207,7 @@ __device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I
return t*t/cos_pi;
}
-__device void lamp_light_sample(KernelGlobals *kg, int lamp,
+ccl_device void lamp_light_sample(KernelGlobals *kg, int lamp,
float randu, float randv, float3 P, LightSample *ls)
{
float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0);
@@ -298,7 +298,7 @@ __device void lamp_light_sample(KernelGlobals *kg, int lamp,
}
}
-__device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, LightSample *ls)
+ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, LightSample *ls)
{
float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0);
float4 data1 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 1);
@@ -422,7 +422,7 @@ __device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, f
/* Triangle Light */
-__device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, int object, float time)
+ccl_device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, int object, float time)
{
#ifdef __INSTANCING__
/* instance transform */
@@ -440,7 +440,7 @@ __device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls,
#endif
}
-__device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
+ccl_device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
float randu, float randv, float time, LightSample *ls)
{
/* triangle, so get position, normal, shader */
@@ -457,7 +457,7 @@ __device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
object_transform_light_sample(kg, ls, object, time);
}
-__device float triangle_light_pdf(KernelGlobals *kg,
+ccl_device float triangle_light_pdf(KernelGlobals *kg,
const float3 Ng, const float3 I, float t)
{
float pdf = kernel_data.integrator.pdf_triangles;
@@ -473,7 +473,7 @@ __device float triangle_light_pdf(KernelGlobals *kg,
#ifdef __HAIR__
-__device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object,
+ccl_device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object,
int segment, float randu, float randv, float time, LightSample *ls)
{
/* this strand code needs completion */
@@ -515,7 +515,7 @@ __device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object
/* Light Distribution */
-__device int light_distribution_sample(KernelGlobals *kg, float randt)
+ccl_device int light_distribution_sample(KernelGlobals *kg, float randt)
{
/* this is basically std::upper_bound as used by pbrt, to find a point light or
* triangle to emit from, proportional to area. a good improvement would be to
@@ -544,7 +544,7 @@ __device int light_distribution_sample(KernelGlobals *kg, float randt)
/* Generic Light */
-__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls)
+ccl_device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls)
{
/* sample index */
int index = light_distribution_sample(kg, randt);
@@ -577,18 +577,18 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra
}
}
-__device int light_select_num_samples(KernelGlobals *kg, int index)
+ccl_device int light_select_num_samples(KernelGlobals *kg, int index)
{
float4 data3 = kernel_tex_fetch(__light_data, index*LIGHT_SIZE + 3);
return __float_as_int(data3.x);
}
-__device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls)
+ccl_device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls)
{
lamp_light_sample(kg, index, randu, randv, P, ls);
}
-__device int lamp_light_eval_sample(KernelGlobals *kg, float randt)
+ccl_device int lamp_light_eval_sample(KernelGlobals *kg, float randt)
{
/* sample index */
int index = light_distribution_sample(kg, randt);
diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h
index b3d53e00be7..92f3420a218 100644
--- a/intern/cycles/kernel/kernel_montecarlo.h
+++ b/intern/cycles/kernel/kernel_montecarlo.h
@@ -36,7 +36,7 @@
CCL_NAMESPACE_BEGIN
/* distribute uniform xy on [0,1] over unit disk [-1,1] */
-__device void to_unit_disk(float *x, float *y)
+ccl_device void to_unit_disk(float *x, float *y)
{
float phi = M_2PI_F * (*x);
float r = sqrtf(*y);
@@ -47,14 +47,14 @@ __device void to_unit_disk(float *x, float *y)
/* return an orthogonal tangent and bitangent given a normal and tangent that
* may not be exactly orthogonal */
-__device void make_orthonormals_tangent(const float3 N, const float3 T, float3 *a, float3 *b)
+ccl_device void make_orthonormals_tangent(const float3 N, const float3 T, float3 *a, float3 *b)
{
*b = normalize(cross(N, T));
*a = cross(*b, N);
}
/* sample direction with cosine weighted distributed in hemisphere */
-__device_inline void sample_cos_hemisphere(const float3 N,
+ccl_device_inline void sample_cos_hemisphere(const float3 N,
float randu, float randv, float3 *omega_in, float *pdf)
{
to_unit_disk(&randu, &randv);
@@ -66,7 +66,7 @@ __device_inline void sample_cos_hemisphere(const float3 N,
}
/* sample direction uniformly distributed in hemisphere */
-__device_inline void sample_uniform_hemisphere(const float3 N,
+ccl_device_inline void sample_uniform_hemisphere(const float3 N,
float randu, float randv,
float3 *omega_in, float *pdf)
{
@@ -83,7 +83,7 @@ __device_inline void sample_uniform_hemisphere(const float3 N,
}
/* sample direction uniformly distributed in cone */
-__device_inline void sample_uniform_cone(const float3 N, float angle,
+ccl_device_inline void sample_uniform_cone(const float3 N, float angle,
float randu, float randv,
float3 *omega_in, float *pdf)
{
@@ -100,7 +100,7 @@ __device_inline void sample_uniform_cone(const float3 N, float angle,
}
/* sample uniform point on the surface of a sphere */
-__device float3 sample_uniform_sphere(float u1, float u2)
+ccl_device float3 sample_uniform_sphere(float u1, float u2)
{
float z = 1.0f - 2.0f*u1;
float r = sqrtf(fmaxf(0.0f, 1.0f - z*z));
@@ -111,29 +111,29 @@ __device float3 sample_uniform_sphere(float u1, float u2)
return make_float3(x, y, z);
}
-__device float balance_heuristic(float a, float b)
+ccl_device float balance_heuristic(float a, float b)
{
return (a)/(a + b);
}
-__device float balance_heuristic_3(float a, float b, float c)
+ccl_device float balance_heuristic_3(float a, float b, float c)
{
return (a)/(a + b + c);
}
-__device float power_heuristic(float a, float b)
+ccl_device float power_heuristic(float a, float b)
{
return (a*a)/(a*a + b*b);
}
-__device float power_heuristic_3(float a, float b, float c)
+ccl_device float power_heuristic_3(float a, float b, float c)
{
return (a*a)/(a*a + b*b + c*c);
}
/* distribute uniform xy on [0,1] over unit disk [-1,1], with concentric mapping
* to better preserve stratification for some RNG sequences */
-__device float2 concentric_sample_disk(float u1, float u2)
+ccl_device float2 concentric_sample_disk(float u1, float u2)
{
float phi, r;
float a = 2.0f*u1 - 1.0f;
@@ -155,7 +155,7 @@ __device float2 concentric_sample_disk(float u1, float u2)
}
/* sample point in unit polygon with given number of corners and rotation */
-__device float2 regular_polygon_sample(float corners, float rotation, float u, float v)
+ccl_device float2 regular_polygon_sample(float corners, float rotation, float u, float v)
{
/* sample corner number and reuse u */
float corner = floorf(u*corners);
diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h
index d0aae119476..a66277e10cd 100644
--- a/intern/cycles/kernel/kernel_object.h
+++ b/intern/cycles/kernel/kernel_object.h
@@ -30,7 +30,7 @@ enum ObjectVectorTransform {
OBJECT_VECTOR_MOTION_POST = 3
};
-__device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, enum ObjectTransform type)
+ccl_device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, enum ObjectTransform type)
{
int offset = object*OBJECT_SIZE + (int)type;
@@ -43,7 +43,7 @@ __device_inline Transform object_fetch_transform(KernelGlobals *kg, int object,
return tfm;
}
-__device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int object, enum ObjectVectorTransform type)
+ccl_device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int object, enum ObjectVectorTransform type)
{
int offset = object*OBJECT_VECTOR_SIZE + (int)type;
@@ -57,7 +57,7 @@ __device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int o
}
#ifdef __OBJECT_MOTION__
-__device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int object, float time)
+ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int object, float time)
{
DecompMotionTransform motion;
@@ -79,7 +79,7 @@ __device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int o
return tfm;
}
-__device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg, int object, float time, Transform *itfm)
+ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg, int object, float time, Transform *itfm)
{
int object_flag = kernel_tex_fetch(__object_flag, object);
@@ -102,7 +102,7 @@ __device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg,
}
#endif
-__device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
+ccl_device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
{
#ifdef __OBJECT_MOTION__
*P = transform_point(&sd->ob_tfm, *P);
@@ -112,7 +112,7 @@ __device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd
#endif
}
-__device_inline void object_inverse_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
+ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P)
{
#ifdef __OBJECT_MOTION__
*P = transform_point(&sd->ob_itfm, *P);
@@ -122,7 +122,7 @@ __device_inline void object_inverse_position_transform(KernelGlobals *kg, Shader
#endif
}
-__device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
+ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
{
#ifdef __OBJECT_MOTION__
*N = normalize(transform_direction_transposed(&sd->ob_tfm, *N));
@@ -132,7 +132,7 @@ __device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderDa
#endif
}
-__device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
+ccl_device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N)
{
#ifdef __OBJECT_MOTION__
*N = normalize(transform_direction_transposed(&sd->ob_itfm, *N));
@@ -142,7 +142,7 @@ __device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd,
#endif
}
-__device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
+ccl_device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
{
#ifdef __OBJECT_MOTION__
*D = transform_direction(&sd->ob_tfm, *D);
@@ -152,7 +152,7 @@ __device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, flo
#endif
}
-__device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
+ccl_device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D)
{
#ifdef __OBJECT_MOTION__
*D = transform_direction(&sd->ob_itfm, *D);
@@ -162,7 +162,7 @@ __device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData
#endif
}
-__device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
+ccl_device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
{
if(sd->object == ~0)
return make_float3(0.0f, 0.0f, 0.0f);
@@ -175,14 +175,14 @@ __device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device_inline float object_surface_area(KernelGlobals *kg, int object)
+ccl_device_inline float object_surface_area(KernelGlobals *kg, int object)
{
int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES;
float4 f = kernel_tex_fetch(__objects, offset);
return f.x;
}
-__device_inline float object_pass_id(KernelGlobals *kg, int object)
+ccl_device_inline float object_pass_id(KernelGlobals *kg, int object)
{
if(object == ~0)
return 0.0f;
@@ -192,7 +192,7 @@ __device_inline float object_pass_id(KernelGlobals *kg, int object)
return f.y;
}
-__device_inline float object_random_number(KernelGlobals *kg, int object)
+ccl_device_inline float object_random_number(KernelGlobals *kg, int object)
{
if(object == ~0)
return 0.0f;
@@ -202,7 +202,7 @@ __device_inline float object_random_number(KernelGlobals *kg, int object)
return f.z;
}
-__device_inline uint object_particle_id(KernelGlobals *kg, int object)
+ccl_device_inline uint object_particle_id(KernelGlobals *kg, int object)
{
if(object == ~0)
return 0.0f;
@@ -212,7 +212,7 @@ __device_inline uint object_particle_id(KernelGlobals *kg, int object)
return __float_as_uint(f.w);
}
-__device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
+ccl_device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
{
if(object == ~0)
return make_float3(0.0f, 0.0f, 0.0f);
@@ -222,7 +222,7 @@ __device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
return make_float3(f.x, f.y, f.z);
}
-__device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
+ccl_device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
{
if(object == ~0)
return make_float3(0.0f, 0.0f, 0.0f);
@@ -233,54 +233,54 @@ __device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
}
-__device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
+ccl_device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
{
return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1);
}
-__device_inline float particle_index(KernelGlobals *kg, int particle)
+ccl_device_inline float particle_index(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
return f.x;
}
-__device float particle_age(KernelGlobals *kg, int particle)
+ccl_device float particle_age(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
return f.y;
}
-__device float particle_lifetime(KernelGlobals *kg, int particle)
+ccl_device float particle_lifetime(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
return f.z;
}
-__device float particle_size(KernelGlobals *kg, int particle)
+ccl_device float particle_size(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
return f.w;
}
-__device float4 particle_rotation(KernelGlobals *kg, int particle)
+ccl_device float4 particle_rotation(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 1);
return f;
}
-__device float3 particle_location(KernelGlobals *kg, int particle)
+ccl_device float3 particle_location(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 2);
return make_float3(f.x, f.y, f.z);
}
-__device float3 particle_velocity(KernelGlobals *kg, int particle)
+ccl_device float3 particle_velocity(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f2 = kernel_tex_fetch(__particles, offset + 2);
@@ -288,7 +288,7 @@ __device float3 particle_velocity(KernelGlobals *kg, int particle)
return make_float3(f2.w, f3.x, f3.y);
}
-__device float3 particle_angular_velocity(KernelGlobals *kg, int particle)
+ccl_device float3 particle_angular_velocity(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f3 = kernel_tex_fetch(__particles, offset + 3);
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index 5e91b13f90c..512db9ec392 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -16,25 +16,25 @@
CCL_NAMESPACE_BEGIN
-__device_inline void kernel_write_pass_float(__global float *buffer, int sample, float value)
+ccl_device_inline void kernel_write_pass_float(ccl_global float *buffer, int sample, float value)
{
- __global float *buf = buffer;
+ ccl_global float *buf = buffer;
*buf = (sample == 0)? value: *buf + value;
}
-__device_inline void kernel_write_pass_float3(__global float *buffer, int sample, float3 value)
+ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, int sample, float3 value)
{
- __global float3 *buf = (__global float3*)buffer;
+ ccl_global float3 *buf = (ccl_global float3*)buffer;
*buf = (sample == 0)? value: *buf + value;
}
-__device_inline void kernel_write_pass_float4(__global float *buffer, int sample, float4 value)
+ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sample, float4 value)
{
- __global float4 *buf = (__global float4*)buffer;
+ ccl_global float4 *buf = (ccl_global float4*)buffer;
*buf = (sample == 0)? value: *buf + value;
}
-__device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L,
+ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L,
ShaderData *sd, int sample, int path_flag, float3 throughput)
{
#ifdef __PASSES__
@@ -114,7 +114,7 @@ __device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float
#endif
}
-__device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample)
+ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L, int sample)
{
#ifdef __PASSES__
int flag = kernel_data.film.pass_flag;
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 5354738d378..4f3957b66ef 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -42,7 +42,7 @@
CCL_NAMESPACE_BEGIN
-__device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow)
+ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow)
{
*shadow = make_float3(1.0f, 1.0f, 1.0f);
@@ -122,7 +122,7 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
#if defined(__BRANCHED_PATH__) || defined(__SUBSURFACE__)
-__device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer,
+ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer,
float3 throughput, int num_samples, int num_total_samples,
float min_ray_pdf, float ray_pdf, PathState state, int rng_offset, PathRadiance *L)
{
@@ -359,7 +359,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
#ifdef __SUBSURFACE__
-__device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
+ccl_device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
int sample, int num_samples,
ShaderData *sd, float3 *throughput,
float *min_ray_pdf, float *ray_pdf, PathState *state,
@@ -452,7 +452,7 @@ __device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
#endif
-__device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer)
+ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
{
/* initialize */
PathRadiance L;
@@ -790,11 +790,11 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R
#ifdef __BRANCHED_PATH__
-__device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
+ccl_device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg, RNG *rng,
int sample, int aa_samples,
ShaderData *sd, float3 throughput, float num_samples_adjust,
float min_ray_pdf, float ray_pdf, PathState state,
- int rng_offset, PathRadiance *L, __global float *buffer)
+ int rng_offset, PathRadiance *L, ccl_global float *buffer)
{
#ifdef __EMISSION__
/* sample illumination from lights to find path contribution */
@@ -941,7 +941,7 @@ __device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg
}
}
-__device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer)
+ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
{
/* initialize */
PathRadiance L;
@@ -1166,7 +1166,7 @@ __device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int
#endif
-__device_inline void kernel_path_trace_setup(KernelGlobals *kg, __global uint *rng_state, int sample, int x, int y, RNG *rng, Ray *ray)
+ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int x, int y, RNG *rng, Ray *ray)
{
float filter_u;
float filter_v;
@@ -1195,8 +1195,8 @@ __device_inline void kernel_path_trace_setup(KernelGlobals *kg, __global uint *r
camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray);
}
-__device void kernel_path_trace(KernelGlobals *kg,
- __global float *buffer, __global uint *rng_state,
+ccl_device void kernel_path_trace(KernelGlobals *kg,
+ ccl_global float *buffer, ccl_global uint *rng_state,
int sample, int x, int y, int offset, int stride)
{
/* buffer offset */
@@ -1227,8 +1227,8 @@ __device void kernel_path_trace(KernelGlobals *kg,
}
#ifdef __BRANCHED_PATH__
-__device void kernel_branched_path_trace(KernelGlobals *kg,
- __global float *buffer, __global uint *rng_state,
+ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
+ ccl_global float *buffer, ccl_global uint *rng_state,
int sample, int x, int y, int offset, int stride)
{
/* buffer offset */
diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h
index e0e0f43fd26..0ded332b3b9 100644
--- a/intern/cycles/kernel/kernel_path_state.h
+++ b/intern/cycles/kernel/kernel_path_state.h
@@ -26,7 +26,7 @@ typedef struct PathState {
int transparent_bounce;
} PathState;
-__device_inline void path_state_init(PathState *state)
+ccl_device_inline void path_state_init(PathState *state)
{
state->flag = PATH_RAY_CAMERA|PATH_RAY_SINGULAR|PATH_RAY_MIS_SKIP;
state->bounce = 0;
@@ -36,7 +36,7 @@ __device_inline void path_state_init(PathState *state)
state->transparent_bounce = 0;
}
-__device_inline void path_state_next(KernelGlobals *kg, PathState *state, int label)
+ccl_device_inline void path_state_next(KernelGlobals *kg, PathState *state, int label)
{
/* ray through transparent keeps same flags from previous ray and is
* not counted as a regular bounce, transparent has separate max */
@@ -88,7 +88,7 @@ __device_inline void path_state_next(KernelGlobals *kg, PathState *state, int la
}
}
-__device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state)
+ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state)
{
uint flag = state->flag & PATH_RAY_ALL_VISIBILITY;
@@ -102,7 +102,7 @@ __device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *sta
return flag;
}
-__device_inline float path_state_terminate_probability(KernelGlobals *kg, PathState *state, const float3 throughput)
+ccl_device_inline float path_state_terminate_probability(KernelGlobals *kg, PathState *state, const float3 throughput)
{
if(state->flag & PATH_RAY_TRANSPARENT) {
/* transparent rays treated separately */
diff --git a/intern/cycles/kernel/kernel_primitive.h b/intern/cycles/kernel/kernel_primitive.h
index 636cfd06532..ababad28f35 100644
--- a/intern/cycles/kernel/kernel_primitive.h
+++ b/intern/cycles/kernel/kernel_primitive.h
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
/* attribute lookup */
-__device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, AttributeElement *elem)
+ccl_device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, AttributeElement *elem)
{
if(sd->object == ~0)
return (int)ATTR_STD_NOT_FOUND;
@@ -52,7 +52,7 @@ __device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, A
}
}
-__device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
+ccl_device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
{
#ifdef __HAIR__
if(sd->segment == ~0)
@@ -64,7 +64,7 @@ __device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd
#endif
}
-__device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
+ccl_device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
{
#ifdef __HAIR__
if(sd->segment == ~0)
@@ -76,7 +76,7 @@ __device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *
#endif
}
-__device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd)
{
AttributeElement elem_uv;
int offset_uv = find_attribute(kg, sd, ATTR_STD_UV, &elem_uv);
@@ -89,7 +89,7 @@ __device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd)
return uv;
}
-__device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __HAIR__
if(sd->segment != ~0)
@@ -122,7 +122,7 @@ __device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
/* motion */
-__device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd)
+ccl_device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd)
{
float3 motion_pre = sd->P, motion_post = sd->P;
diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h
index d9520de7956..e2108604bc8 100644
--- a/intern/cycles/kernel/kernel_projection.h
+++ b/intern/cycles/kernel/kernel_projection.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
/* Spherical coordinates <-> Cartesian direction */
-__device float2 direction_to_spherical(float3 dir)
+ccl_device float2 direction_to_spherical(float3 dir)
{
float theta = acosf(dir.z);
float phi = atan2f(dir.x, dir.y);
@@ -45,7 +45,7 @@ __device float2 direction_to_spherical(float3 dir)
return make_float2(theta, phi);
}
-__device float3 spherical_to_direction(float theta, float phi)
+ccl_device float3 spherical_to_direction(float theta, float phi)
{
return make_float3(
sinf(theta)*cosf(phi),
@@ -55,7 +55,7 @@ __device float3 spherical_to_direction(float theta, float phi)
/* Equirectangular coordinates <-> Cartesian direction */
-__device float2 direction_to_equirectangular(float3 dir)
+ccl_device float2 direction_to_equirectangular(float3 dir)
{
float u = -atan2f(dir.y, dir.x)/(M_2PI_F) + 0.5f;
float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f;
@@ -63,7 +63,7 @@ __device float2 direction_to_equirectangular(float3 dir)
return make_float2(u, v);
}
-__device float3 equirectangular_to_direction(float u, float v)
+ccl_device float3 equirectangular_to_direction(float u, float v)
{
float phi = M_PI_F*(1.0f - 2.0f*u);
float theta = M_PI_F*(1.0f - v);
@@ -76,7 +76,7 @@ __device float3 equirectangular_to_direction(float u, float v)
/* Fisheye <-> Cartesian direction */
-__device float2 direction_to_fisheye(float3 dir, float fov)
+ccl_device float2 direction_to_fisheye(float3 dir, float fov)
{
float r = atan2f(sqrtf(dir.y*dir.y + dir.z*dir.z), dir.x) / fov;
float phi = atan2f(dir.z, dir.y);
@@ -87,7 +87,7 @@ __device float2 direction_to_fisheye(float3 dir, float fov)
return make_float2(u, v);
}
-__device float3 fisheye_to_direction(float u, float v, float fov)
+ccl_device float3 fisheye_to_direction(float u, float v, float fov)
{
u = (u - 0.5f) * 2.0f;
v = (v - 0.5f) * 2.0f;
@@ -109,7 +109,7 @@ __device float3 fisheye_to_direction(float u, float v, float fov)
);
}
-__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height)
+ccl_device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height)
{
float theta = acosf(dir.x);
float r = 2.0f * lens * sinf(theta * 0.5f);
@@ -121,7 +121,7 @@ __device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float wid
return make_float2(u, v);
}
-__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height)
+ccl_device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height)
{
u = (u - 0.5f) * width;
v = (v - 0.5f) * height;
@@ -146,7 +146,7 @@ __device float3 fisheye_equisolid_to_direction(float u, float v, float lens, flo
/* Mirror Ball <-> Cartesion direction */
-__device float3 mirrorball_to_direction(float u, float v)
+ccl_device float3 mirrorball_to_direction(float u, float v)
{
/* point on sphere */
float3 dir;
@@ -161,7 +161,7 @@ __device float3 mirrorball_to_direction(float u, float v)
return 2.0f*dot(dir, I)*dir - I;
}
-__device float2 direction_to_mirrorball(float3 dir)
+ccl_device float2 direction_to_mirrorball(float3 dir)
{
/* inverse of mirrorball_to_direction */
dir.y -= 1.0f;
@@ -176,7 +176,7 @@ __device float2 direction_to_mirrorball(float3 dir)
return make_float2(u, v);
}
-__device float3 panorama_to_direction(KernelGlobals *kg, float u, float v)
+ccl_device float3 panorama_to_direction(KernelGlobals *kg, float u, float v)
{
switch(kernel_data.cam.panorama_type) {
case PANORAMA_EQUIRECTANGULAR:
@@ -190,7 +190,7 @@ __device float3 panorama_to_direction(KernelGlobals *kg, float u, float v)
}
}
-__device float2 direction_to_panorama(KernelGlobals *kg, float3 dir)
+ccl_device float2 direction_to_panorama(KernelGlobals *kg, float3 dir)
{
switch(kernel_data.cam.panorama_type) {
case PANORAMA_EQUIRECTANGULAR:
diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h
index dc977a8780f..69e7b439e1c 100644
--- a/intern/cycles/kernel/kernel_random.h
+++ b/intern/cycles/kernel/kernel_random.h
@@ -30,7 +30,7 @@ typedef uint RNG;
/* High Dimensional Sobol */
/* van der corput radical inverse */
-__device uint van_der_corput(uint bits)
+ccl_device uint van_der_corput(uint bits)
{
bits = (bits << 16) | (bits >> 16);
bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8);
@@ -41,7 +41,7 @@ __device uint van_der_corput(uint bits)
}
/* sobol radical inverse */
-__device uint sobol(uint i)
+ccl_device uint sobol(uint i)
{
uint r = 0;
@@ -53,7 +53,7 @@ __device uint sobol(uint i)
}
/* inverse of sobol radical inverse */
-__device uint sobol_inverse(uint i)
+ccl_device uint sobol_inverse(uint i)
{
const uint msb = 1U << 31;
uint r = 0;
@@ -67,7 +67,7 @@ __device uint sobol_inverse(uint i)
/* multidimensional sobol with generator matrices
* dimension 0 and 1 are equal to van_der_corput() and sobol() respectively */
-__device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
+ccl_device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
{
uint result = 0;
uint i = index;
@@ -80,7 +80,7 @@ __device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
}
/* lookup index and x/y coordinate, assumes m is a power of two */
-__device uint sobol_lookup(const uint m, const uint frame, const uint ex, const uint ey, uint *x, uint *y)
+ccl_device uint sobol_lookup(const uint m, const uint frame, const uint ex, const uint ey, uint *x, uint *y)
{
/* shift is constant per frame */
const uint shift = frame << (m << 1);
@@ -100,7 +100,7 @@ __device uint sobol_lookup(const uint m, const uint frame, const uint ex, const
return index;
}
-__device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension)
+ccl_device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension)
{
#ifdef __CMJ__
if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ) {
@@ -131,7 +131,7 @@ __device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int n
#endif
}
-__device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension, float *fx, float *fy)
+ccl_device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension, float *fx, float *fy)
{
#ifdef __CMJ__
if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ) {
@@ -148,7 +148,7 @@ __device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int nu
}
}
-__device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)
+ccl_device_inline void path_rng_init(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)
{
#ifdef __SOBOL_FULL_SCREEN__
uint px, py;
@@ -183,7 +183,7 @@ __device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state,
#endif
}
-__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
+ccl_device void path_rng_end(KernelGlobals *kg, ccl_global uint *rng_state, RNG rng)
{
/* nothing to do */
}
@@ -192,24 +192,24 @@ __device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
/* Linear Congruential Generator */
-__device float path_rng(KernelGlobals *kg, RNG& rng, int sample, int dimension)
+ccl_device float path_rng(KernelGlobals *kg, RNG& rng, int sample, int dimension)
{
}
-__device_inline float path_rng_1D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension)
+ccl_device_inline float path_rng_1D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension)
{
/* implicit mod 2^32 */
rng = (1103515245*(rng) + 12345);
return (float)rng * (1.0f/(float)0xFFFFFFFF);
}
-__device_inline void path_rng_2D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension, float *fx, float *fy)
+ccl_device_inline void path_rng_2D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension, float *fx, float *fy)
{
*fx = path_rng_1D(kg, rng, sample, num_samples, dimension);
*fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1);
}
-__device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)
+ccl_device void path_rng_init(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)
{
/* load state */
*rng = *rng_state;
@@ -225,7 +225,7 @@ __device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sam
}
}
-__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
+ccl_device void path_rng_end(KernelGlobals *kg, ccl_global uint *rng_state, RNG rng)
{
/* store state for next sample */
*rng_state = rng;
@@ -233,21 +233,21 @@ __device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng)
#endif
-__device uint lcg_step_uint(uint *rng)
+ccl_device uint lcg_step_uint(uint *rng)
{
/* implicit mod 2^32 */
*rng = (1103515245*(*rng) + 12345);
return *rng;
}
-__device float lcg_step_float(uint *rng)
+ccl_device float lcg_step_float(uint *rng)
{
/* implicit mod 2^32 */
*rng = (1103515245*(*rng) + 12345);
return (float)*rng * (1.0f/(float)0xFFFFFFFF);
}
-__device uint lcg_init(uint seed)
+ccl_device uint lcg_init(uint seed)
{
uint rng = seed;
lcg_step_uint(&rng);
diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h
index 81630caed9a..77154ce3aef 100644
--- a/intern/cycles/kernel/kernel_shader.h
+++ b/intern/cycles/kernel/kernel_shader.h
@@ -36,7 +36,7 @@ CCL_NAMESPACE_BEGIN
/* ShaderData setup from incoming ray */
#ifdef __OBJECT_MOTION__
-__device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time)
+ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time)
{
if(sd->flag & SD_OBJECT_MOTION) {
sd->ob_tfm = object_fetch_transform_motion(kg, sd->object, time);
@@ -49,7 +49,7 @@ __device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd,
}
#endif
-__device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
const Intersection *isect, const Ray *ray, int bounce)
{
#ifdef __INSTANCING__
@@ -161,7 +161,7 @@ __device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
/* ShaderData setup from BSSRDF scatter */
#ifdef __SUBSURFACE__
-__device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData *sd,
+ccl_device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData *sd,
const Intersection *isect, const Ray *ray)
{
bool backfacing = sd->flag & SD_BACKFACING;
@@ -237,7 +237,7 @@ __device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData
/* ShaderData setup from position sampled on mesh */
-__device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
const float3 P, const float3 Ng, const float3 I,
int shader, int object, int prim, float u, float v, float t, float time, int bounce, int segment)
{
@@ -357,7 +357,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
/* ShaderData setup for displacement */
-__device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
int object, int prim, float u, float v)
{
float3 P, Ng, I = make_float3(0.0f, 0.0f, 0.0f);
@@ -376,7 +376,7 @@ __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
/* ShaderData setup from ray into background */
-__device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce)
+ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce)
{
/* vectors */
sd->P = ray->D;
@@ -426,7 +426,7 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData
#ifdef __MULTI_CLOSURE__
-__device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData *sd, const float3 omega_in, float *pdf,
+ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData *sd, const float3 omega_in, float *pdf,
int skip_bsdf, BsdfEval *result_eval, float sum_pdf, float sum_sample_weight)
{
/* this is the veach one-sample model with balance heuristic, some pdf
@@ -455,7 +455,7 @@ __device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData
#endif
-__device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
+ccl_device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
const float3 omega_in, BsdfEval *eval, float *pdf)
{
#ifdef __MULTI_CLOSURE__
@@ -470,7 +470,7 @@ __device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
#endif
}
-__device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
+ccl_device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
float randu, float randv, BsdfEval *bsdf_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
@@ -534,7 +534,7 @@ __device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
#endif
}
-__device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd,
+ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd,
const ShaderClosure *sc, float randu, float randv, BsdfEval *bsdf_eval,
float3 *omega_in, differential3 *domega_in, float *pdf)
{
@@ -550,7 +550,7 @@ __device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd,
return label;
}
-__device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
+ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
{
#ifdef __MULTI_CLOSURE__
for(int i = 0; i< sd->num_closure; i++) {
@@ -564,7 +564,7 @@ __device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughnes
#endif
}
-__device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -585,7 +585,7 @@ __device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
{
float3 alpha = make_float3(1.0f, 1.0f, 1.0f) - shader_bsdf_transparency(kg, sd);
@@ -595,7 +595,7 @@ __device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
return alpha;
}
-__device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -616,7 +616,7 @@ __device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -637,7 +637,7 @@ __device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -658,7 +658,7 @@ __device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -679,7 +679,7 @@ __device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
#endif
}
-__device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_)
+ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -717,7 +717,7 @@ __device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_facto
#endif
}
-__device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blur_)
+ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blur_)
{
#ifdef __MULTI_CLOSURE__
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -762,7 +762,7 @@ __device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blu
/* Emission */
-__device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *sc)
+ccl_device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *sc)
{
#ifdef __OSL__
if(kg->osl && sc->prim)
@@ -772,7 +772,7 @@ __device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *
return emissive_simple_eval(sd->Ng, sd->I);
}
-__device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
{
float3 eval;
#ifdef __MULTI_CLOSURE__
@@ -793,7 +793,7 @@ __device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
/* Holdout */
-__device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
+ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
{
#ifdef __MULTI_CLOSURE__
float3 weight = make_float3(0.0f, 0.0f, 0.0f);
@@ -816,7 +816,7 @@ __device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
/* Surface Evaluation */
-__device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
float randb, int path_flag, ShaderContext ctx)
{
#ifdef __OSL__
@@ -837,7 +837,7 @@ __device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
/* Background Evaluation */
-__device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int path_flag, ShaderContext ctx)
+ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int path_flag, ShaderContext ctx)
{
#ifdef __OSL__
if (kg->osl)
@@ -875,7 +875,7 @@ __device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int pa
/* Volume */
-__device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd,
+ccl_device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd,
float3 omega_in, float3 omega_out)
{
#ifdef __MULTI_CLOSURE__
@@ -896,7 +896,7 @@ __device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd,
/* Volume Evaluation */
-__device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
+ccl_device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
float randb, int path_flag, ShaderContext ctx)
{
#ifdef __SVM__
@@ -911,7 +911,7 @@ __device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
/* Displacement Evaluation */
-__device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx)
+ccl_device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx)
{
/* this will modify sd->P */
#ifdef __SVM__
@@ -927,7 +927,7 @@ __device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, Shader
/* Transparent Shadows */
#ifdef __TRANSPARENT_SHADOWS__
-__device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
+ccl_device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
{
int prim = kernel_tex_fetch(__prim_index, isect->prim);
int shader = 0;
@@ -953,7 +953,7 @@ __device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
/* Merging */
#ifdef __BRANCHED_PATH__
-__device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd)
+ccl_device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd)
{
/* merge identical closures, better when we sample a single closure at a time */
for(int i = 0; i < sd->num_closure; i++) {
diff --git a/intern/cycles/kernel/kernel_sse41.cpp b/intern/cycles/kernel/kernel_sse41.cpp
new file mode 100644
index 00000000000..0c68fd3651b
--- /dev/null
+++ b/intern/cycles/kernel/kernel_sse41.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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
+ */
+
+/* Optimized CPU kernel entry points. This file is compiled with SSE3/SSSE3
+ * optimization flags and nearly all functions inlined, while kernel.cpp
+ * is compiled without for other CPU's. */
+
+#ifdef WITH_OPTIMIZED_KERNEL
+
+/* SSE optimization disabled for now on 32 bit, see bug #36316 */
+#if !(defined(__GNUC__) && (defined(i386) || defined(_M_IX86)))
+#define __KERNEL_SSE2__
+#define __KERNEL_SSE3__
+#define __KERNEL_SSSE3__
+#define __KERNEL_SSE41__
+#endif
+
+#include "kernel.h"
+#include "kernel_compat_cpu.h"
+#include "kernel_math.h"
+#include "kernel_types.h"
+#include "kernel_globals.h"
+#include "kernel_film.h"
+#include "kernel_path.h"
+#include "kernel_displace.h"
+
+CCL_NAMESPACE_BEGIN
+
+/* Path Tracing */
+
+void kernel_cpu_sse41_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride)
+{
+#ifdef __BRANCHED_PATH__
+ if(kernel_data.integrator.branched)
+ kernel_branched_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
+ else
+#endif
+ kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
+}
+
+/* Film */
+
+void kernel_cpu_sse41_convert_to_byte(KernelGlobals *kg, uchar4 *rgba, float *buffer, float sample_scale, int x, int y, int offset, int stride)
+{
+ kernel_film_convert_to_byte(kg, rgba, buffer, sample_scale, x, y, offset, stride);
+}
+
+void kernel_cpu_sse41_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, float *buffer, float sample_scale, int x, int y, int offset, int stride)
+{
+ kernel_film_convert_to_half_float(kg, rgba, buffer, sample_scale, x, y, offset, stride);
+}
+
+/* Shader Evaluate */
+
+void kernel_cpu_sse41_shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int i)
+{
+ kernel_shader_evaluate(kg, input, output, (ShaderEvalType)type, i);
+}
+
+CCL_NAMESPACE_END
+
+#endif
+
diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h
index d16b9328bf2..2326ca18b55 100644
--- a/intern/cycles/kernel/kernel_subsurface.h
+++ b/intern/cycles/kernel/kernel_subsurface.h
@@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN
#define BSSRDF_MULTI_EVAL
-__device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, ShaderData *sd, float *probability)
+ccl_device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, ShaderData *sd, float *probability)
{
/* sum sample weights of bssrdf and bsdf */
float bsdf_sum = 0.0f;
@@ -80,7 +80,7 @@ __device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, Shade
return NULL;
}
-__device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float disk_r, float r, bool all)
+ccl_device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float disk_r, float r, bool all)
{
#ifdef BSSRDF_MULTI_EVAL
/* this is the veach one-sample model with balance heuristic, some pdf
@@ -133,7 +133,7 @@ __device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float
}
/* replace closures with a single diffuse bsdf closure after scatter step */
-__device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weight, bool hit, float3 N)
+ccl_device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weight, bool hit, float3 N)
{
sd->flag &= ~SD_CLOSURE_FLAGS;
sd->randb_closure = 0.0f;
@@ -158,7 +158,7 @@ __device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weigh
}
/* optionally do blurring of color and/or bump mapping, at the cost of a shader evaluation */
-__device float3 subsurface_color_pow(float3 color, float exponent)
+ccl_device float3 subsurface_color_pow(float3 color, float exponent)
{
color = max(color, make_float3(0.0f, 0.0f, 0.0f));
@@ -179,7 +179,7 @@ __device float3 subsurface_color_pow(float3 color, float exponent)
return color;
}
-__device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd, ShaderData *in_sd, int state_flag, float3 *eval, float3 *N)
+ccl_device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd, ShaderData *in_sd, int state_flag, float3 *eval, float3 *N)
{
/* average color and texture blur at outgoing point */
float texture_blur;
@@ -207,7 +207,7 @@ __device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd,
}
/* subsurface scattering step, from a point on the surface to other nearby points on the same object */
-__device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, ShaderData bssrdf_sd[BSSRDF_MAX_HITS],
+ccl_device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, ShaderData bssrdf_sd[BSSRDF_MAX_HITS],
int state_flag, ShaderClosure *sc, uint *lcg_state, float disk_u, float disk_v, bool all)
{
/* pick random axis in local frame and point on disk */
@@ -313,7 +313,7 @@ __device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, Sh
}
/* subsurface scattering step, from a point on the surface to another nearby point on the same object */
-__device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd,
+ccl_device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd,
int state_flag, ShaderClosure *sc, uint *lcg_state, float disk_u, float disk_v, bool all)
{
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/kernel/kernel_triangle.h b/intern/cycles/kernel/kernel_triangle.h
index 71389e0ec32..d457b67e77e 100644
--- a/intern/cycles/kernel/kernel_triangle.h
+++ b/intern/cycles/kernel/kernel_triangle.h
@@ -17,7 +17,7 @@
CCL_NAMESPACE_BEGIN
/* Point on triangle for Moller-Trumbore triangles */
-__device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float u, float v)
+ccl_device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float u, float v)
{
/* load triangle vertices */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index));
@@ -32,7 +32,7 @@ __device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float
}
/* Sample point on triangle */
-__device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, float randu, float randv)
+ccl_device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, float randu, float randv)
{
/* compute point */
randu = sqrtf(randu);
@@ -44,7 +44,7 @@ __device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, floa
}
/* Normal for Moller-Trumbore triangles */
-__device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int *shader)
+ccl_device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int *shader)
{
#if 0
/* load triangle vertices */
@@ -64,7 +64,7 @@ __device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int
}
/* Return 3 triangle vertex locations */
-__device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3 P[3])
+ccl_device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3 P[3])
{
/* load triangle vertices */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index));
@@ -74,7 +74,7 @@ __device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3
P[2] = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.z)));
}
-__device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index, float u, float v)
+ccl_device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index, float u, float v)
{
/* load triangle vertices */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index));
@@ -86,7 +86,7 @@ __device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index,
return normalize((1.0f - u - v)*n2 + u*n0 + v*n1);
}
-__device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dPdv, int tri)
+ccl_device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dPdv, int tri)
{
/* fetch triangle vertex coordinates */
float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri));
@@ -102,7 +102,7 @@ __device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dP
/* attributes */
-__device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
+ccl_device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy)
{
if(elem == ATTR_ELEMENT_FACE) {
if(dx) *dx = 0.0f;
@@ -145,7 +145,7 @@ __device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd,
}
}
-__device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
+ccl_device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy)
{
if(elem == ATTR_ELEMENT_FACE) {
if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl
index c29891ed574..066e5f8dbe1 100644
--- a/intern/cycles/kernel/shaders/node_math.osl
+++ b/intern/cycles/kernel/shaders/node_math.osl
@@ -95,6 +95,6 @@ shader node_math(
Value = safe_modulo(Value1, Value2);
if (Clamp)
- Value = clamp(Value1, 0.0, 1.0);
+ Value = clamp(Value, 0.0, 1.0);
}
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index 168127c620c..b2be9deb938 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -45,14 +45,14 @@ CCL_NAMESPACE_BEGIN
/* Stack */
-__device_inline float3 stack_load_float3(float *stack, uint a)
+ccl_device_inline float3 stack_load_float3(float *stack, uint a)
{
kernel_assert(a+2 < SVM_STACK_SIZE);
return make_float3(stack[a+0], stack[a+1], stack[a+2]);
}
-__device_inline void stack_store_float3(float *stack, uint a, float3 f)
+ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f)
{
kernel_assert(a+2 < SVM_STACK_SIZE);
@@ -61,59 +61,59 @@ __device_inline void stack_store_float3(float *stack, uint a, float3 f)
stack[a+2] = f.z;
}
-__device_inline float stack_load_float(float *stack, uint a)
+ccl_device_inline float stack_load_float(float *stack, uint a)
{
kernel_assert(a < SVM_STACK_SIZE);
return stack[a];
}
-__device_inline float stack_load_float_default(float *stack, uint a, uint value)
+ccl_device_inline float stack_load_float_default(float *stack, uint a, uint value)
{
return (a == (uint)SVM_STACK_INVALID)? __uint_as_float(value): stack_load_float(stack, a);
}
-__device_inline void stack_store_float(float *stack, uint a, float f)
+ccl_device_inline void stack_store_float(float *stack, uint a, float f)
{
kernel_assert(a < SVM_STACK_SIZE);
stack[a] = f;
}
-__device_inline int stack_load_int(float *stack, uint a)
+ccl_device_inline int stack_load_int(float *stack, uint a)
{
kernel_assert(a < SVM_STACK_SIZE);
return __float_as_int(stack[a]);
}
-__device_inline float stack_load_int_default(float *stack, uint a, uint value)
+ccl_device_inline float stack_load_int_default(float *stack, uint a, uint value)
{
return (a == (uint)SVM_STACK_INVALID)? (int)value: stack_load_int(stack, a);
}
-__device_inline void stack_store_int(float *stack, uint a, int i)
+ccl_device_inline void stack_store_int(float *stack, uint a, int i)
{
kernel_assert(a < SVM_STACK_SIZE);
stack[a] = __int_as_float(i);
}
-__device_inline bool stack_valid(uint a)
+ccl_device_inline bool stack_valid(uint a)
{
return a != (uint)SVM_STACK_INVALID;
}
/* Reading Nodes */
-__device_inline uint4 read_node(KernelGlobals *kg, int *offset)
+ccl_device_inline uint4 read_node(KernelGlobals *kg, int *offset)
{
uint4 node = kernel_tex_fetch(__svm_nodes, *offset);
(*offset)++;
return node;
}
-__device_inline float4 read_node_float(KernelGlobals *kg, int *offset)
+ccl_device_inline float4 read_node_float(KernelGlobals *kg, int *offset)
{
uint4 node = kernel_tex_fetch(__svm_nodes, *offset);
float4 f = make_float4(__uint_as_float(node.x), __uint_as_float(node.y), __uint_as_float(node.z), __uint_as_float(node.w));
@@ -121,13 +121,13 @@ __device_inline float4 read_node_float(KernelGlobals *kg, int *offset)
return f;
}
-__device_inline float4 fetch_node_float(KernelGlobals *kg, int offset)
+ccl_device_inline float4 fetch_node_float(KernelGlobals *kg, int offset)
{
uint4 node = kernel_tex_fetch(__svm_nodes, offset);
return make_float4(__uint_as_float(node.x), __uint_as_float(node.y), __uint_as_float(node.z), __uint_as_float(node.w));
}
-__device_inline void decode_node_uchar4(uint i, uint *x, uint *y, uint *z, uint *w)
+ccl_device_inline void decode_node_uchar4(uint i, uint *x, uint *y, uint *z, uint *w)
{
if(x) *x = (i & 0xFF);
if(y) *y = ((i >> 8) & 0xFF);
@@ -182,7 +182,7 @@ CCL_NAMESPACE_BEGIN
/* Main Interpreter Loop */
-__device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderType type, float randb, int path_flag)
+ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderType type, float randb, int path_flag)
{
float stack[SVM_STACK_SIZE];
float closure_weight = 1.0f;
diff --git a/intern/cycles/kernel/svm/svm_attribute.h b/intern/cycles/kernel/svm/svm_attribute.h
index 8e71e7cdd56..90409e16477 100644
--- a/intern/cycles/kernel/svm/svm_attribute.h
+++ b/intern/cycles/kernel/svm/svm_attribute.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Attribute Node */
-__device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd,
+ccl_device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd,
uint4 node, NodeAttributeType *type,
NodeAttributeType *mesh_type, AttributeElement *elem, int *offset, uint *out_offset)
{
@@ -52,7 +52,7 @@ __device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd,
*type = (NodeAttributeType)node.w;
}
-__device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
NodeAttributeType type, mesh_type;
AttributeElement elem;
@@ -84,7 +84,7 @@ __device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uin
}
}
-__device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
NodeAttributeType type, mesh_type;
AttributeElement elem;
@@ -120,7 +120,7 @@ __device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *st
}
}
-__device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
NodeAttributeType type, mesh_type;
AttributeElement elem;
diff --git a/intern/cycles/kernel/svm/svm_blackbody.h b/intern/cycles/kernel/svm/svm_blackbody.h
index 2fc2c770a83..63dbf27d35e 100644
--- a/intern/cycles/kernel/svm/svm_blackbody.h
+++ b/intern/cycles/kernel/svm/svm_blackbody.h
@@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN
/* Blackbody Node */
-__device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack, uint temperature_offset, uint col_offset)
+ccl_device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack, uint temperature_offset, uint col_offset)
{
/* Output */
float3 color_rgb = make_float3(0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/kernel/svm/svm_brick.h b/intern/cycles/kernel/svm/svm_brick.h
index 19b4b5e779f..7cac922d8a6 100644
--- a/intern/cycles/kernel/svm/svm_brick.h
+++ b/intern/cycles/kernel/svm/svm_brick.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Brick */
-__device_noinline float brick_noise(int n) /* fast integer noise */
+ccl_device_noinline float brick_noise(int n) /* fast integer noise */
{
int nn;
n = (n >> 13) ^ n;
@@ -26,7 +26,7 @@ __device_noinline float brick_noise(int n) /* fast integer noise */
return 0.5f * ((float)nn / 1073741824.0f);
}
-__device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, float bias,
+ccl_device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, float bias,
float brick_width, float row_height, float offset_amount, int offset_frequency,
float squash_amount, int squash_frequency)
{
@@ -56,7 +56,7 @@ __device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, flo
y > (row_height - mortar_size)) ? 1.0f : 0.0f);
}
-__device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint4 node3 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_brightness.h b/intern/cycles/kernel/svm/svm_brightness.h
index 3e977dcbe1b..9b330b3213f 100644
--- a/intern/cycles/kernel/svm/svm_brightness.h
+++ b/intern/cycles/kernel/svm/svm_brightness.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, uint out_color, uint node)
+ccl_device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, uint out_color, uint node)
{
uint bright_offset, contrast_offset;
float3 color = stack_load_float3(stack, in_color);
diff --git a/intern/cycles/kernel/svm/svm_camera.h b/intern/cycles/kernel/svm/svm_camera.h
index 76f50e196eb..bfe9289fa02 100644
--- a/intern/cycles/kernel/svm/svm_camera.h
+++ b/intern/cycles/kernel/svm/svm_camera.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_vector, uint out_zdepth, uint out_distance)
+ccl_device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_vector, uint out_zdepth, uint out_distance)
{
float distance;
float zdepth;
diff --git a/intern/cycles/kernel/svm/svm_checker.h b/intern/cycles/kernel/svm/svm_checker.h
index 70fe2ac5a92..ebc48e16d68 100644
--- a/intern/cycles/kernel/svm/svm_checker.h
+++ b/intern/cycles/kernel/svm/svm_checker.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Checker */
-__device_noinline float svm_checker(float3 p, float scale)
+ccl_device_noinline float svm_checker(float3 p, float scale)
{
p *= scale;
@@ -34,7 +34,7 @@ __device_noinline float svm_checker(float3 p, float scale)
return ((xi % 2 == yi % 2) == (zi % 2))? 1.0f: 0.0f;
}
-__device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint co_offset, color1_offset, color2_offset, scale_offset;
uint color_offset, fac_offset;
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index 0d4716ab078..2c6fb5deca4 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Closure Nodes */
-__device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, float eta, float roughness, bool refract)
+ccl_device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, float eta, float roughness, bool refract)
{
if(type == CLOSURE_BSDF_SHARP_GLASS_ID) {
if(refract) {
@@ -49,7 +49,7 @@ __device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type,
}
}
-__device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, ClosureType type, float mix_weight)
+ccl_device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, ClosureType type, float mix_weight)
{
#ifdef __MULTI_CLOSURE__
ShaderClosure *sc = &sd->closure[sd->num_closure];
@@ -70,7 +70,7 @@ __device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, Clo
#endif
}
-__device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float mix_weight)
+ccl_device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float mix_weight)
{
#ifdef __MULTI_CLOSURE__
ShaderClosure *sc = &sd->closure[sd->num_closure];
@@ -93,7 +93,7 @@ __device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float m
#endif
}
-__device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, float randb, int path_flag, int *offset)
+ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, float randb, int path_flag, int *offset)
{
uint type, param1_offset, param2_offset;
@@ -456,7 +456,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st
}
}
-__device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag)
+ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag)
{
uint type, param1_offset, param2_offset;
@@ -499,7 +499,7 @@ __device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *
}
}
-__device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node)
{
#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
@@ -522,7 +522,7 @@ __device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node
sd->flag |= SD_EMISSION;
}
-__device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node)
{
#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
@@ -543,7 +543,7 @@ __device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 no
#endif
}
-__device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
{
#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
@@ -566,7 +566,7 @@ __device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
sd->flag |= SD_HOLDOUT;
}
-__device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node)
{
#ifdef __MULTI_CLOSURE__
uint mix_weight_offset = node.y;
@@ -591,7 +591,7 @@ __device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, u
/* Closure Nodes */
-__device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
+ccl_device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
{
#ifdef __MULTI_CLOSURE__
if(sd->num_closure < MAX_CLOSURE)
@@ -601,13 +601,13 @@ __device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight
#endif
}
-__device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b)
+ccl_device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b)
{
float3 weight = make_float3(__uint_as_float(r), __uint_as_float(g), __uint_as_float(b));
svm_node_closure_store_weight(sd, weight);
}
-__device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData *sd, uint r, uint g, uint b)
+ccl_device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData *sd, uint r, uint g, uint b)
{
float3 weight = make_float3(__uint_as_float(r), __uint_as_float(g), __uint_as_float(b));
@@ -617,14 +617,14 @@ __device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData *
svm_node_closure_store_weight(sd, weight);
}
-__device void svm_node_closure_weight(ShaderData *sd, float *stack, uint weight_offset)
+ccl_device void svm_node_closure_weight(ShaderData *sd, float *stack, uint weight_offset)
{
float3 weight = stack_load_float3(stack, weight_offset);
svm_node_closure_store_weight(sd, weight);
}
-__device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint color_offset = node.y;
uint strength_offset = node.z;
@@ -639,7 +639,7 @@ __device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float
svm_node_closure_store_weight(sd, weight);
}
-__device void svm_node_mix_closure(ShaderData *sd, float *stack,
+ccl_device void svm_node_mix_closure(ShaderData *sd, float *stack,
uint4 node, int *offset, float *randb)
{
#ifdef __MULTI_CLOSURE__
@@ -675,7 +675,7 @@ __device void svm_node_mix_closure(ShaderData *sd, float *stack,
#endif
}
-__device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused,
+ccl_device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused,
uint node_jump, int *offset, float *randb, float *closure_weight)
{
#ifdef __MULTI_CLOSURE__
@@ -699,7 +699,7 @@ __device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused,
/* (Bump) normal */
-__device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_direction, uint out_normal)
+ccl_device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_direction, uint out_normal)
{
float3 normal = stack_load_float3(stack, in_direction);
sd->N = normal;
diff --git a/intern/cycles/kernel/svm/svm_convert.h b/intern/cycles/kernel/svm/svm_convert.h
index 22f4651689d..2503912c5c6 100644
--- a/intern/cycles/kernel/svm/svm_convert.h
+++ b/intern/cycles/kernel/svm/svm_convert.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Conversion Nodes */
-__device void svm_node_convert(ShaderData *sd, float *stack, uint type, uint from, uint to)
+ccl_device void svm_node_convert(ShaderData *sd, float *stack, uint type, uint from, uint to)
{
switch(type) {
case NODE_CONVERT_FI: {
diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h
index d0bac647a7c..6cd5ee4b375 100644
--- a/intern/cycles/kernel/svm/svm_displace.h
+++ b/intern/cycles/kernel/svm/svm_displace.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Bump Node */
-__device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
#ifdef __RAY_DIFFERENTIALS__
/* get normal input */
@@ -62,7 +62,7 @@ __device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack,
/* Displacement Node */
-__device void svm_node_set_displacement(ShaderData *sd, float *stack, uint fac_offset)
+ccl_device void svm_node_set_displacement(ShaderData *sd, float *stack, uint fac_offset)
{
float d = stack_load_float(stack, fac_offset);
sd->P += sd->N*d*0.1f; /* todo: get rid of this factor */
diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h
index 549c0351d83..0a3d576cfe1 100644
--- a/intern/cycles/kernel/svm/svm_fresnel.h
+++ b/intern/cycles/kernel/svm/svm_fresnel.h
@@ -18,27 +18,33 @@ CCL_NAMESPACE_BEGIN
/* Fresnel Node */
-__device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint out_offset)
+ccl_device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint node)
{
+ uint normal_offset, out_offset;
+ decode_node_uchar4(node, &normal_offset, &out_offset, NULL, NULL);
float eta = (stack_valid(ior_offset))? stack_load_float(stack, ior_offset): __uint_as_float(ior_value);
+ float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
+
eta = fmaxf(eta, 1.0f + 1e-5f);
eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
- float f = fresnel_dielectric_cos(dot(sd->I, sd->N), eta);
+ float f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta);
stack_store_float(stack, out_offset, f);
}
/* Layer Weight Node */
-__device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
{
uint blend_offset = node.y;
uint blend_value = node.z;
- float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value);
- uint type, out_offset;
- decode_node_uchar4(node.w, &type, &out_offset, NULL, NULL);
+ uint type, normal_offset, out_offset;
+ decode_node_uchar4(node.w, &type, &normal_offset, &out_offset, NULL);
+
+ float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value);
+ float3 normal_in = (stack_valid(normal_offset))? stack_load_float3(stack, normal_offset): sd->N;
float f;
@@ -46,10 +52,10 @@ __device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
float eta = fmaxf(1.0f - blend, 1e-5f);
eta = (sd->flag & SD_BACKFACING)? eta: 1.0f/eta;
- f = fresnel_dielectric_cos(dot(sd->I, sd->N), eta);
+ f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta);
}
else {
- f = fabsf(dot(sd->I, sd->N));
+ f = fabsf(dot(sd->I, normal_in));
if(blend != 0.5f) {
blend = clamp(blend, 0.0f, 1.0f-1e-5f);
diff --git a/intern/cycles/kernel/svm/svm_gamma.h b/intern/cycles/kernel/svm/svm_gamma.h
index ef1581fba8d..c4749e7b936 100644
--- a/intern/cycles/kernel/svm/svm_gamma.h
+++ b/intern/cycles/kernel/svm/svm_gamma.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_gamma(ShaderData *sd, float *stack, uint in_gamma, uint in_color, uint out_color)
+ccl_device void svm_node_gamma(ShaderData *sd, float *stack, uint in_gamma, uint in_color, uint out_color)
{
float3 color = stack_load_float3(stack, in_color);
float gamma = stack_load_float(stack, in_gamma);
diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h
index 818d8694453..ad0cacb027a 100644
--- a/intern/cycles/kernel/svm/svm_geometry.h
+++ b/intern/cycles/kernel/svm/svm_geometry.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Geometry Node */
-__device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
float3 data;
@@ -38,7 +38,7 @@ __device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack,
stack_store_float3(stack, out_offset, data);
}
-__device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
@@ -55,7 +55,7 @@ __device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float
#endif
}
-__device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
@@ -74,7 +74,7 @@ __device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float
/* Object Info */
-__device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
float data;
@@ -94,7 +94,7 @@ __device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *sta
/* Particle Info */
-__device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
switch(type) {
case NODE_INFO_PAR_INDEX: {
@@ -146,7 +146,7 @@ __device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *s
/* Hair Info */
-__device void svm_node_hair_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_hair_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
{
float data;
float3 data3;
diff --git a/intern/cycles/kernel/svm/svm_gradient.h b/intern/cycles/kernel/svm/svm_gradient.h
index 1c0fe511f9b..a4b3c0583f7 100644
--- a/intern/cycles/kernel/svm/svm_gradient.h
+++ b/intern/cycles/kernel/svm/svm_gradient.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Gradient */
-__device float svm_gradient(float3 p, NodeGradientType type)
+ccl_device float svm_gradient(float3 p, NodeGradientType type)
{
float x, y, z;
@@ -57,7 +57,7 @@ __device float svm_gradient(float3 p, NodeGradientType type)
return 0.0f;
}
-__device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node)
{
uint type, co_offset, color_offset, fac_offset;
diff --git a/intern/cycles/kernel/svm/svm_hsv.h b/intern/cycles/kernel/svm/svm_hsv.h
index e16fb7582c1..11dfc4f096b 100644
--- a/intern/cycles/kernel/svm/svm_hsv.h
+++ b/intern/cycles/kernel/svm/svm_hsv.h
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_color_offset, uint fac_offset, uint out_color_offset, int *offset)
+ccl_device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_color_offset, uint fac_offset, uint out_color_offset, int *offset)
{
/* read extra data */
uint4 node1 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index e18fe7c53a7..58e5775265a 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -21,14 +21,14 @@ CCL_NAMESPACE_BEGIN
/* For OpenCL all images are packed in a single array, and we do manual lookup
* and interpolation. */
-__device_inline float4 svm_image_texture_read(KernelGlobals *kg, int offset)
+ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int offset)
{
uchar4 r = kernel_tex_fetch(__tex_image_packed, offset);
float f = 1.0f/255.0f;
return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
}
-__device_inline int svm_image_texture_wrap_periodic(int x, int width)
+ccl_device_inline int svm_image_texture_wrap_periodic(int x, int width)
{
x %= width;
if(x < 0)
@@ -36,19 +36,19 @@ __device_inline int svm_image_texture_wrap_periodic(int x, int width)
return x;
}
-__device_inline int svm_image_texture_wrap_clamp(int x, int width)
+ccl_device_inline int svm_image_texture_wrap_clamp(int x, int width)
{
return clamp(x, 0, width-1);
}
-__device_inline float svm_image_texture_frac(float x, int *ix)
+ccl_device_inline float svm_image_texture_frac(float x, int *ix)
{
int i = float_to_int(x) - ((x < 0.0f)? 1: 0);
*ix = i;
return x - (float)i;
}
-__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
+ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
{
/* first slots are used by float textures, which are not supported here */
if(id < TEX_NUM_FLOAT_IMAGES)
@@ -110,7 +110,7 @@ __device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, u
#else
-__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
+ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
{
float4 r;
@@ -257,7 +257,7 @@ __device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, u
#endif
-__device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint id = node.y;
uint co_offset, out_offset, alpha_offset, srgb;
@@ -274,7 +274,7 @@ __device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack
stack_store_float(stack, alpha_offset, f.w);
}
-__device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
/* get object space normal */
float3 N = sd->N;
@@ -363,7 +363,7 @@ __device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *s
}
-__device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint id = node.y;
uint co_offset, out_offset, alpha_offset, srgb;
diff --git a/intern/cycles/kernel/svm/svm_invert.h b/intern/cycles/kernel/svm/svm_invert.h
index 4c40afeadd9..eb47e9ad4ab 100644
--- a/intern/cycles/kernel/svm/svm_invert.h
+++ b/intern/cycles/kernel/svm/svm_invert.h
@@ -16,12 +16,12 @@
CCL_NAMESPACE_BEGIN
-__device float invert(float color, float factor)
+ccl_device float invert(float color, float factor)
{
return factor*(1.0f - color) + (1.0f - factor) * color;
}
-__device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint in_color, uint out_color)
+ccl_device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint in_color, uint out_color)
{
float factor = stack_load_float(stack, in_fac);
float3 color = stack_load_float3(stack, in_color);
diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h
index ff6776d751e..e7afa2d2200 100644
--- a/intern/cycles/kernel/svm/svm_light_path.h
+++ b/intern/cycles/kernel/svm/svm_light_path.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Light Path Node */
-__device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint out_offset, int path_flag)
+ccl_device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint out_offset, int path_flag)
{
float info = 0.0f;
@@ -40,7 +40,7 @@ __device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint
/* Light Falloff Node */
-__device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node)
{
uint strength_offset, out_offset, smooth_offset;
diff --git a/intern/cycles/kernel/svm/svm_magic.h b/intern/cycles/kernel/svm/svm_magic.h
index 7a5eba3f564..b661f5cacf8 100644
--- a/intern/cycles/kernel/svm/svm_magic.h
+++ b/intern/cycles/kernel/svm/svm_magic.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Magic */
-__device_noinline float3 svm_magic(float3 p, int n, float distortion)
+ccl_device_noinline float3 svm_magic(float3 p, int n, float distortion)
{
float x = sinf((p.x + p.y + p.z)*5.0f);
float y = cosf((-p.x + p.y - p.z)*5.0f);
@@ -87,7 +87,7 @@ __device_noinline float3 svm_magic(float3 p, int n, float distortion)
return make_float3(0.5f - x, 0.5f - y, 0.5f - z);
}
-__device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint depth;
uint scale_offset, distortion_offset, co_offset, fac_offset, color_offset;
diff --git a/intern/cycles/kernel/svm/svm_mapping.h b/intern/cycles/kernel/svm/svm_mapping.h
index fcdd92dd575..c9fa8502dd1 100644
--- a/intern/cycles/kernel/svm/svm_mapping.h
+++ b/intern/cycles/kernel/svm/svm_mapping.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Mapping Node */
-__device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
+ccl_device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
{
float3 v = stack_load_float3(stack, vec_offset);
@@ -32,7 +32,7 @@ __device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack,
stack_store_float3(stack, out_offset, r);
}
-__device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
+ccl_device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
{
float3 v = stack_load_float3(stack, vec_offset);
diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h
index d4863dd6216..bb46d443a6b 100644
--- a/intern/cycles/kernel/svm/svm_math.h
+++ b/intern/cycles/kernel/svm/svm_math.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device float svm_math(NodeMath type, float Fac1, float Fac2)
+ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
{
float Fac;
@@ -64,12 +64,12 @@ __device float svm_math(NodeMath type, float Fac1, float Fac2)
return Fac;
}
-__device float average_fac(float3 v)
+ccl_device float average_fac(float3 v)
{
return (fabsf(v.x) + fabsf(v.y) + fabsf(v.z))/3.0f;
}
-__device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, float3 Vector1, float3 Vector2)
+ccl_device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, float3 Vector1, float3 Vector2)
{
if(type == NODE_VECTOR_MATH_ADD) {
*Vector = Vector1 + Vector2;
@@ -104,7 +104,7 @@ __device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, f
/* Nodes */
-__device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint f1_offset, uint f2_offset, int *offset)
+ccl_device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint f1_offset, uint f2_offset, int *offset)
{
NodeMath type = (NodeMath)itype;
float f1 = stack_load_float(stack, f1_offset);
@@ -116,7 +116,7 @@ __device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uin
stack_store_float(stack, node1.y, f);
}
-__device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint v1_offset, uint v2_offset, int *offset)
+ccl_device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint v1_offset, uint v2_offset, int *offset)
{
NodeVectorMath type = (NodeVectorMath)itype;
float3 v1 = stack_load_float3(stack, v1_offset);
diff --git a/intern/cycles/kernel/svm/svm_mix.h b/intern/cycles/kernel/svm/svm_mix.h
index 506f772dba5..0eeb4cf9b05 100644
--- a/intern/cycles/kernel/svm/svm_mix.h
+++ b/intern/cycles/kernel/svm/svm_mix.h
@@ -16,22 +16,22 @@
CCL_NAMESPACE_BEGIN
-__device float3 svm_mix_blend(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_blend(float t, float3 col1, float3 col2)
{
return interp(col1, col2, t);
}
-__device float3 svm_mix_add(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_add(float t, float3 col1, float3 col2)
{
return interp(col1, col1 + col2, t);
}
-__device float3 svm_mix_mul(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_mul(float t, float3 col1, float3 col2)
{
return interp(col1, col1 * col2, t);
}
-__device float3 svm_mix_screen(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_screen(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
float3 one = make_float3(1.0f, 1.0f, 1.0f);
@@ -40,7 +40,7 @@ __device float3 svm_mix_screen(float t, float3 col1, float3 col2)
return one - (tm3 + t*(one - col2))*(one - col1);
}
-__device float3 svm_mix_overlay(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_overlay(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -64,12 +64,12 @@ __device float3 svm_mix_overlay(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_sub(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_sub(float t, float3 col1, float3 col2)
{
return interp(col1, col1 - col2, t);
}
-__device float3 svm_mix_div(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_div(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -82,22 +82,22 @@ __device float3 svm_mix_div(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_diff(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_diff(float t, float3 col1, float3 col2)
{
return interp(col1, fabs(col1 - col2), t);
}
-__device float3 svm_mix_dark(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_dark(float t, float3 col1, float3 col2)
{
return min(col1, col2*t);
}
-__device float3 svm_mix_light(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_light(float t, float3 col1, float3 col2)
{
return max(col1, col2*t);
}
-__device float3 svm_mix_dodge(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_dodge(float t, float3 col1, float3 col2)
{
float3 outcol = col1;
@@ -132,7 +132,7 @@ __device float3 svm_mix_dodge(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_burn(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_burn(float t, float3 col1, float3 col2)
{
float tmp, tm = 1.0f - t;
@@ -171,7 +171,7 @@ __device float3 svm_mix_burn(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_hue(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_hue(float t, float3 col1, float3 col2)
{
float3 outcol = col1;
@@ -188,7 +188,7 @@ __device float3 svm_mix_hue(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_sat(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_sat(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -206,7 +206,7 @@ __device float3 svm_mix_sat(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_val(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_val(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -218,7 +218,7 @@ __device float3 svm_mix_val(float t, float3 col1, float3 col2)
return hsv_to_rgb(hsv);
}
-__device float3 svm_mix_color(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_color(float t, float3 col1, float3 col2)
{
float3 outcol = col1;
float3 hsv2 = rgb_to_hsv(col2);
@@ -235,7 +235,7 @@ __device float3 svm_mix_color(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_soft(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_soft(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
@@ -245,7 +245,7 @@ __device float3 svm_mix_soft(float t, float3 col1, float3 col2)
return tm*col1 + t*((one - col1)*col2*col1 + col1*scr);
}
-__device float3 svm_mix_linear(float t, float3 col1, float3 col2)
+ccl_device float3 svm_mix_linear(float t, float3 col1, float3 col2)
{
float3 outcol = col1;
@@ -267,7 +267,7 @@ __device float3 svm_mix_linear(float t, float3 col1, float3 col2)
return outcol;
}
-__device float3 svm_mix_clamp(float3 col)
+ccl_device float3 svm_mix_clamp(float3 col)
{
float3 outcol = col;
@@ -278,7 +278,7 @@ __device float3 svm_mix_clamp(float3 col)
return outcol;
}
-__device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
+ccl_device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
{
float t = clamp(fac, 0.0f, 1.0f);
@@ -309,7 +309,7 @@ __device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
/* Node */
-__device void svm_node_mix(KernelGlobals *kg, ShaderData *sd, float *stack, uint fac_offset, uint c1_offset, uint c2_offset, int *offset)
+ccl_device void svm_node_mix(KernelGlobals *kg, ShaderData *sd, float *stack, uint fac_offset, uint c1_offset, uint c2_offset, int *offset)
{
/* read extra data */
uint4 node1 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_musgrave.h b/intern/cycles/kernel/svm/svm_musgrave.h
index 65dcf1a9f83..c67dc8297e4 100644
--- a/intern/cycles/kernel/svm/svm_musgrave.h
+++ b/intern/cycles/kernel/svm/svm_musgrave.h
@@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN
* from "Texturing and Modelling: A procedural approach"
*/
-__device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves)
+ccl_device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves)
{
float rmd;
float value = 0.0f;
@@ -53,7 +53,7 @@ __device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float
* octaves: number of frequencies in the fBm
*/
-__device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves)
+ccl_device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves)
{
float rmd;
float value = 1.0f;
@@ -82,7 +82,7 @@ __device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis ba
* offset: raises the terrain from `sea level'
*/
-__device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset)
+ccl_device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset)
{
float value, increment, rmd;
float pwHL = powf(lacunarity, -H);
@@ -117,7 +117,7 @@ __device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis b
* offset: raises the terrain from `sea level'
*/
-__device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain)
+ccl_device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain)
{
float result, signal, weight, rmd;
float pwHL = powf(lacunarity, -H);
@@ -154,7 +154,7 @@ __device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseB
* offset: raises the terrain from `sea level'
*/
-__device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain)
+ccl_device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain)
{
float result, signal, weight;
float pwHL = powf(lacunarity, -H);
@@ -181,7 +181,7 @@ __device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseB
/* Shader */
-__device float svm_musgrave(NodeMusgraveType type, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float scale, float3 p)
+ccl_device float svm_musgrave(NodeMusgraveType type, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float scale, float3 p)
{
NodeNoiseBasis basis = NODE_NOISE_PERLIN;
p *= scale;
@@ -200,7 +200,7 @@ __device float svm_musgrave(NodeMusgraveType type, float dimension, float lacuna
return 0.0f;
}
-__device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint4 node3 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_noise.h b/intern/cycles/kernel/svm/svm_noise.h
index a55c635b679..2055b0e3ec7 100644
--- a/intern/cycles/kernel/svm/svm_noise.h
+++ b/intern/cycles/kernel/svm/svm_noise.h
@@ -32,17 +32,17 @@
CCL_NAMESPACE_BEGIN
-__device int quick_floor(float x)
+ccl_device int quick_floor(float x)
{
return float_to_int(x) - ((x < 0) ? 1 : 0);
}
-__device float bits_to_01(uint bits)
+ccl_device float bits_to_01(uint bits)
{
return bits * (1.0f/(float)0xFFFFFFFF);
}
-__device uint hash(uint kx, uint ky, uint kz)
+ccl_device uint hash(uint kx, uint ky, uint kz)
{
// define some handy macros
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
@@ -71,34 +71,34 @@ __device uint hash(uint kx, uint ky, uint kz)
#undef final
}
-__device int imod(int a, int b)
+ccl_device int imod(int a, int b)
{
a %= b;
return a < 0 ? a + b : a;
}
-__device uint phash(int kx, int ky, int kz, int3 p)
+ccl_device uint phash(int kx, int ky, int kz, int3 p)
{
return hash(imod(kx, p.x), imod(ky, p.y), imod(kz, p.z));
}
-__device float floorfrac(float x, int* i)
+ccl_device float floorfrac(float x, int* i)
{
*i = quick_floor(x);
return x - *i;
}
-__device float fade(float t)
+ccl_device float fade(float t)
{
return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f);
}
-__device float nerp(float t, float a, float b)
+ccl_device float nerp(float t, float a, float b)
{
return (1.0f - t) * a + t * b;
}
-__device float grad(int hash, float x, float y, float z)
+ccl_device float grad(int hash, float x, float y, float z)
{
// use vectors pointing to the edges of the cube
int h = hash & 15;
@@ -107,12 +107,12 @@ __device float grad(int hash, float x, float y, float z)
return ((h&1) ? -u : u) + ((h&2) ? -v : v);
}
-__device float scale3(float result)
+ccl_device float scale3(float result)
{
return 0.9820f * result;
}
-__device_noinline float perlin(float x, float y, float z)
+ccl_device_noinline float perlin(float x, float y, float z)
{
int X; float fx = floorfrac(x, &X);
int Y; float fy = floorfrac(y, &Y);
@@ -138,7 +138,7 @@ __device_noinline float perlin(float x, float y, float z)
return (isfinite(r))? r: 0.0f;
}
-__device_noinline float perlin_periodic(float x, float y, float z, float3 pperiod)
+ccl_device_noinline float perlin_periodic(float x, float y, float z, float3 pperiod)
{
int X; float fx = floorfrac(x, &X);
int Y; float fy = floorfrac(y, &Y);
@@ -171,20 +171,20 @@ __device_noinline float perlin_periodic(float x, float y, float z, float3 pperio
}
/* perlin noise in range 0..1 */
-__device float noise(float3 p)
+ccl_device float noise(float3 p)
{
float r = perlin(p.x, p.y, p.z);
return 0.5f*r + 0.5f;
}
/* perlin noise in range -1..1 */
-__device float snoise(float3 p)
+ccl_device float snoise(float3 p)
{
return perlin(p.x, p.y, p.z);
}
/* cell noise */
-__device_noinline float cellnoise(float3 p)
+ccl_device_noinline float cellnoise(float3 p)
{
uint ix = quick_floor(p.x);
uint iy = quick_floor(p.y);
@@ -193,7 +193,7 @@ __device_noinline float cellnoise(float3 p)
return bits_to_01(hash(ix, iy, iz));
}
-__device float3 cellnoise_color(float3 p)
+ccl_device float3 cellnoise_color(float3 p)
{
float r = cellnoise(p);
float g = cellnoise(make_float3(p.y, p.x, p.z));
@@ -203,14 +203,14 @@ __device float3 cellnoise_color(float3 p)
}
/* periodic perlin noise in range 0..1 */
-__device float pnoise(float3 p, float3 pperiod)
+ccl_device float pnoise(float3 p, float3 pperiod)
{
float r = perlin_periodic(p.x, p.y, p.z, pperiod);
return 0.5f*r + 0.5f;
}
/* periodic perlin noise in range -1..1 */
-__device float psnoise(float3 p, float3 pperiod)
+ccl_device float psnoise(float3 p, float3 pperiod)
{
return perlin_periodic(p.x, p.y, p.z, pperiod);
}
diff --git a/intern/cycles/kernel/svm/svm_noisetex.h b/intern/cycles/kernel/svm/svm_noisetex.h
index acb3f20246e..02583131704 100644
--- a/intern/cycles/kernel/svm/svm_noisetex.h
+++ b/intern/cycles/kernel/svm/svm_noisetex.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Noise */
-__device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color)
+ccl_device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color)
{
NodeNoiseBasis basis = NODE_NOISE_PERLIN;
int hard = 0;
@@ -41,7 +41,7 @@ __device_inline void svm_noise(float3 p, float scale, float detail, float distor
noise_turbulence(make_float3(p.y, p.z, p.x), basis, detail, hard));
}
-__device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint co_offset, scale_offset, detail_offset, distortion_offset, fac_offset, color_offset;
diff --git a/intern/cycles/kernel/svm/svm_normal.h b/intern/cycles/kernel/svm/svm_normal.h
index dd7506bb5fc..8695031b8b9 100644
--- a/intern/cycles/kernel/svm/svm_normal.h
+++ b/intern/cycles/kernel/svm/svm_normal.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset)
+ccl_device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset)
{
/* read extra data */
uint4 node1 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_ramp.h b/intern/cycles/kernel/svm/svm_ramp.h
index 3cb23a2b2dd..55eee3d24c3 100644
--- a/intern/cycles/kernel/svm/svm_ramp.h
+++ b/intern/cycles/kernel/svm/svm_ramp.h
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-__device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool interpolate)
+ccl_device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool interpolate)
{
f = clamp(f, 0.0f, 1.0f)*(RAMP_TABLE_SIZE-1);
@@ -35,7 +35,7 @@ __device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool int
return a;
}
-__device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint fac_offset, color_offset, alpha_offset;
uint interpolate = node.z;
@@ -53,7 +53,7 @@ __device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack,
*offset += RAMP_TABLE_SIZE;
}
-__device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint fac_offset = node.y;
uint color_offset = node.z;
@@ -72,7 +72,7 @@ __device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stac
*offset += RAMP_TABLE_SIZE;
}
-__device void svm_node_vector_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_vector_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint fac_offset = node.y;
uint color_offset = node.z;
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
index 130890fdc8e..0f68ecbea03 100644
--- a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
+++ b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint hue_in, uint saturation_in, uint value_in, int *offset)
+ccl_device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint hue_in, uint saturation_in, uint value_in, int *offset)
{
uint4 node1 = read_node(kg, offset);
uint color_out = node1.y;
@@ -32,7 +32,7 @@ __device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *sta
stack_store_float3(stack, color_out, color);
}
-__device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint color_in, uint hue_out, uint saturation_out, int *offset)
+ccl_device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint color_in, uint hue_out, uint saturation_out, int *offset)
{
uint4 node1 = read_node(kg, offset);
uint value_out = node1.y;
diff --git a/intern/cycles/kernel/svm/svm_sepcomb_rgb.h b/intern/cycles/kernel/svm/svm_sepcomb_rgb.h
index 5c3d95435f2..34c4449ecdb 100644
--- a/intern/cycles/kernel/svm/svm_sepcomb_rgb.h
+++ b/intern/cycles/kernel/svm/svm_sepcomb_rgb.h
@@ -16,7 +16,7 @@
CCL_NAMESPACE_BEGIN
-__device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset, uint color_index, uint out_offset)
+ccl_device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset, uint color_index, uint out_offset)
{
float color = stack_load_float(stack, in_offset);
@@ -24,7 +24,7 @@ __device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset,
stack_store_float(stack, out_offset+color_index, color);
}
-__device void svm_node_separate_rgb(ShaderData *sd, float *stack, uint icolor_offset, uint color_index, uint out_offset)
+ccl_device void svm_node_separate_rgb(ShaderData *sd, float *stack, uint icolor_offset, uint color_index, uint out_offset)
{
float3 color = stack_load_float3(stack, icolor_offset);
diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h
index 81b5f1a201f..1e3552647bd 100644
--- a/intern/cycles/kernel/svm/svm_sky.h
+++ b/intern/cycles/kernel/svm/svm_sky.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Sky texture */
-__device float sky_angle_between(float thetav, float phiv, float theta, float phi)
+ccl_device float sky_angle_between(float thetav, float phiv, float theta, float phi)
{
float cospsi = sinf(thetav)*sinf(theta)*cosf(phi - phiv) + cosf(thetav)*cosf(theta);
return safe_acosf(cospsi);
@@ -28,7 +28,7 @@ __device float sky_angle_between(float thetav, float phiv, float theta, float ph
* "A Practical Analytic Model for Daylight"
* A. J. Preetham, Peter Shirley, Brian Smits
*/
-__device float sky_perez_function(float *lam, float theta, float gamma)
+ccl_device float sky_perez_function(float *lam, float theta, float gamma)
{
float ctheta = cosf(theta);
float cgamma = cosf(gamma);
@@ -36,7 +36,7 @@ __device float sky_perez_function(float *lam, float theta, float gamma)
return (1.0f + lam[0]*expf(lam[1]/ctheta)) * (1.0f + lam[2]*expf(lam[3]*gamma) + lam[4]*cgamma*cgamma);
}
-__device float3 sky_radiance_old(KernelGlobals *kg, float3 dir,
+ccl_device float3 sky_radiance_old(KernelGlobals *kg, float3 dir,
float sunphi, float suntheta,
float radiance_x, float radiance_y, float radiance_z,
float *config_x, float *config_y, float *config_z)
@@ -66,7 +66,7 @@ __device float3 sky_radiance_old(KernelGlobals *kg, float3 dir,
* "An Analytic Model for Full Spectral Sky-Dome Radiance"
* Lukas Hosek, Alexander Wilkie
*/
-__device float sky_radiance_internal(float *configuration, float theta, float gamma)
+ccl_device float sky_radiance_internal(float *configuration, float theta, float gamma)
{
float ctheta = cosf(theta);
float cgamma = cosf(gamma);
@@ -80,7 +80,7 @@ __device float sky_radiance_internal(float *configuration, float theta, float ga
(configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith);
}
-__device float3 sky_radiance_new(KernelGlobals *kg, float3 dir,
+ccl_device float3 sky_radiance_new(KernelGlobals *kg, float3 dir,
float sunphi, float suntheta,
float radiance_x, float radiance_y, float radiance_z,
float *config_x, float *config_y, float *config_z)
@@ -105,7 +105,7 @@ __device float3 sky_radiance_new(KernelGlobals *kg, float3 dir,
return xyz_to_rgb(x, y, z) * (M_2PI_F/683);
}
-__device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
/* Define variables */
float sunphi, suntheta, radiance_x, radiance_y, radiance_z;
diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index 9f88389fcb1..3044cbf81e0 100644
--- a/intern/cycles/kernel/svm/svm_tex_coord.h
+++ b/intern/cycles/kernel/svm/svm_tex_coord.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Texture Coordinate Node */
-__device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
{
float3 data;
@@ -78,7 +78,7 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_fla
stack_store_float3(stack, out_offset, data);
}
-__device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
@@ -142,7 +142,7 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int
#endif
}
-__device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
@@ -206,7 +206,7 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int
#endif
}
-__device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint color_offset, strength_offset, normal_offset, space;
decode_node_uchar4(node.y, &color_offset, &strength_offset, &normal_offset, &space);
@@ -280,7 +280,7 @@ __device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stac
stack_store_float3(stack, normal_offset, N);
}
-__device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint tangent_offset, direction_type, axis;
decode_node_uchar4(node.y, &tangent_offset, &direction_type, &axis, NULL);
diff --git a/intern/cycles/kernel/svm/svm_texture.h b/intern/cycles/kernel/svm/svm_texture.h
index 7f3e09a481d..8ced8390b0b 100644
--- a/intern/cycles/kernel/svm/svm_texture.h
+++ b/intern/cycles/kernel/svm/svm_texture.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Voronoi Distances */
-__device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, float e)
+ccl_device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, float e)
{
#if 0
if(distance_metric == NODE_VORONOI_DISTANCE_SQUARED)
@@ -44,7 +44,7 @@ __device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, fl
/* Voronoi / Worley like */
-__device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2)
+ccl_device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2)
{
float da[4];
float3 pa[4];
@@ -120,29 +120,29 @@ __device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2)
return result;
}
-__device float voronoi_F1(float3 p) { return voronoi_Fn(p, 0.0f, 0, -1).w; }
-__device float voronoi_F2(float3 p) { return voronoi_Fn(p, 0.0f, 1, -1).w; }
-__device float voronoi_F3(float3 p) { return voronoi_Fn(p, 0.0f, 2, -1).w; }
-__device float voronoi_F4(float3 p) { return voronoi_Fn(p, 0.0f, 3, -1).w; }
-__device float voronoi_F1F2(float3 p) { return voronoi_Fn(p, 0.0f, 0, 1).w; }
+ccl_device float voronoi_F1(float3 p) { return voronoi_Fn(p, 0.0f, 0, -1).w; }
+ccl_device float voronoi_F2(float3 p) { return voronoi_Fn(p, 0.0f, 1, -1).w; }
+ccl_device float voronoi_F3(float3 p) { return voronoi_Fn(p, 0.0f, 2, -1).w; }
+ccl_device float voronoi_F4(float3 p) { return voronoi_Fn(p, 0.0f, 3, -1).w; }
+ccl_device float voronoi_F1F2(float3 p) { return voronoi_Fn(p, 0.0f, 0, 1).w; }
-__device float voronoi_Cr(float3 p)
+ccl_device float voronoi_Cr(float3 p)
{
/* crackle type pattern, just a scale/clamp of F2-F1 */
float t = 10.0f*voronoi_F1F2(p);
return (t > 1.0f)? 1.0f: t;
}
-__device float voronoi_F1S(float3 p) { return 2.0f*voronoi_F1(p) - 1.0f; }
-__device float voronoi_F2S(float3 p) { return 2.0f*voronoi_F2(p) - 1.0f; }
-__device float voronoi_F3S(float3 p) { return 2.0f*voronoi_F3(p) - 1.0f; }
-__device float voronoi_F4S(float3 p) { return 2.0f*voronoi_F4(p) - 1.0f; }
-__device float voronoi_F1F2S(float3 p) { return 2.0f*voronoi_F1F2(p) - 1.0f; }
-__device float voronoi_CrS(float3 p) { return 2.0f*voronoi_Cr(p) - 1.0f; }
+ccl_device float voronoi_F1S(float3 p) { return 2.0f*voronoi_F1(p) - 1.0f; }
+ccl_device float voronoi_F2S(float3 p) { return 2.0f*voronoi_F2(p) - 1.0f; }
+ccl_device float voronoi_F3S(float3 p) { return 2.0f*voronoi_F3(p) - 1.0f; }
+ccl_device float voronoi_F4S(float3 p) { return 2.0f*voronoi_F4(p) - 1.0f; }
+ccl_device float voronoi_F1F2S(float3 p) { return 2.0f*voronoi_F1F2(p) - 1.0f; }
+ccl_device float voronoi_CrS(float3 p) { return 2.0f*voronoi_Cr(p) - 1.0f; }
/* Noise Bases */
-__device float noise_basis(float3 p, NodeNoiseBasis basis)
+ccl_device float noise_basis(float3 p, NodeNoiseBasis basis)
{
/* Only Perlin enabled for now, others break CUDA compile by making kernel
* too big, with compile using > 4GB, due to everything being inlined. */
@@ -173,7 +173,7 @@ __device float noise_basis(float3 p, NodeNoiseBasis basis)
/* Soft/Hard Noise */
-__device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard)
+ccl_device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard)
{
float t = noise_basis(p, basis);
return (hard)? fabsf(2.0f*t - 1.0f): t;
@@ -181,7 +181,7 @@ __device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard)
/* Turbulence */
-__device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard)
+ccl_device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard)
{
float fscale = 1.0f;
float amp = 1.0f;
diff --git a/intern/cycles/kernel/svm/svm_value.h b/intern/cycles/kernel/svm/svm_value.h
index cd5a2e0d871..7beed065288 100644
--- a/intern/cycles/kernel/svm/svm_value.h
+++ b/intern/cycles/kernel/svm/svm_value.h
@@ -18,12 +18,12 @@ CCL_NAMESPACE_BEGIN
/* Value Nodes */
-__device void svm_node_value_f(KernelGlobals *kg, ShaderData *sd, float *stack, uint ivalue, uint out_offset)
+ccl_device void svm_node_value_f(KernelGlobals *kg, ShaderData *sd, float *stack, uint ivalue, uint out_offset)
{
stack_store_float(stack, out_offset, __uint_as_float(ivalue));
}
-__device void svm_node_value_v(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_offset, int *offset)
+ccl_device void svm_node_value_v(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_offset, int *offset)
{
/* read extra data */
uint4 node1 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_vector_transform.h b/intern/cycles/kernel/svm/svm_vector_transform.h
index 95ef8e3e558..1e3fc2fa03b 100644
--- a/intern/cycles/kernel/svm/svm_vector_transform.h
+++ b/intern/cycles/kernel/svm/svm_vector_transform.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Vector Transform */
-__device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
+ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
uint itype, ifrom, ito;
uint vector_in, vector_out;
diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h
index c9ebea2bceb..604fd3404c5 100644
--- a/intern/cycles/kernel/svm/svm_voronoi.h
+++ b/intern/cycles/kernel/svm/svm_voronoi.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Voronoi */
-__device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale, float3 p)
+ccl_device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale, float3 p)
{
/* compute distance and point coordinate of 4 nearest neighbours */
float4 dpa0 = voronoi_Fn(p*scale, 1.0f, 0, -1);
@@ -39,7 +39,7 @@ __device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale,
return make_float4(color.x, color.y, color.z, fac);
}
-__device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint coloring = node.y;
uint scale_offset, co_offset, fac_offset, color_offset;
diff --git a/intern/cycles/kernel/svm/svm_wave.h b/intern/cycles/kernel/svm/svm_wave.h
index d906266bcf9..3749135f8c7 100644
--- a/intern/cycles/kernel/svm/svm_wave.h
+++ b/intern/cycles/kernel/svm/svm_wave.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Wave */
-__device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float detail, float distortion, float dscale)
+ccl_device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float detail, float distortion, float dscale)
{
float n;
@@ -35,7 +35,7 @@ __device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float
return 0.5f + 0.5f * sinf(n);
}
-__device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
+ccl_device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
diff --git a/intern/cycles/kernel/svm/svm_wavelength.h b/intern/cycles/kernel/svm/svm_wavelength.h
index f9dd24dacef..dca4003b89a 100644
--- a/intern/cycles/kernel/svm/svm_wavelength.h
+++ b/intern/cycles/kernel/svm/svm_wavelength.h
@@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN
/* Wavelength to RGB */
-__device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out)
+ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out)
{
// CIE colour matching functions xBar, yBar, and zBar for
// wavelengths from 380 through 780 nanometers, every 5
diff --git a/intern/cycles/kernel/svm/svm_wireframe.h b/intern/cycles/kernel/svm/svm_wireframe.h
index 9ecb81847d7..e560e6303cc 100644
--- a/intern/cycles/kernel/svm/svm_wireframe.h
+++ b/intern/cycles/kernel/svm/svm_wireframe.h
@@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN
/* Wireframe Node */
-__device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_size, uint out_fac, uint use_pixel_size)
+ccl_device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_size, uint out_fac, uint use_pixel_size)
{
/* Input Data */
float size = stack_load_float(stack, in_size);
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 5fb648cec5f..44a050ca530 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -184,6 +184,12 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
pixels[0] = (f == 0.0f)? 1e10f: f*scale_exposure;
}
}
+ else if(type == PASS_MIST) {
+ for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
+ float f = *in;
+ pixels[0] = clamp(f*scale_exposure, 0.0f, 1.0f);
+ }
+ }
else {
for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
float f = *in;
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 8ebdf3cc220..dfa737115e2 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -75,7 +75,8 @@ enum ShaderNodeSpecialType {
SHADER_SPECIAL_TYPE_PROXY,
SHADER_SPECIAL_TYPE_MIX_CLOSURE,
SHADER_SPECIAL_TYPE_AUTOCONVERT,
- SHADER_SPECIAL_TYPE_GEOMETRY
+ SHADER_SPECIAL_TYPE_GEOMETRY,
+ SHADER_SPECIAL_TYPE_SCRIPT
};
/* Enum
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 621d52bbbbf..daf75c81396 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3166,12 +3166,17 @@ FresnelNode::FresnelNode()
void FresnelNode::compile(SVMCompiler& compiler)
{
+ ShaderInput *normal_in = input("Normal");
ShaderInput *ior_in = input("IOR");
ShaderOutput *fac_out = output("Fac");
compiler.stack_assign(ior_in);
compiler.stack_assign(fac_out);
- compiler.add_node(NODE_FRESNEL, ior_in->stack_offset, __float_as_int(ior_in->value.x), fac_out->stack_offset);
+
+ if(normal_in->link)
+ compiler.stack_assign(normal_in);
+
+ compiler.add_node(NODE_FRESNEL, ior_in->stack_offset, __float_as_int(ior_in->value.x), compiler.encode_uchar4(normal_in->stack_offset, fac_out->stack_offset));
}
void FresnelNode::compile(OSLCompiler& compiler)
@@ -3193,8 +3198,12 @@ LayerWeightNode::LayerWeightNode()
void LayerWeightNode::compile(SVMCompiler& compiler)
{
+ ShaderInput *normal_in = input("Normal");
ShaderInput *blend_in = input("Blend");
+ if(normal_in->link)
+ compiler.stack_assign(normal_in);
+
if(blend_in->link)
compiler.stack_assign(blend_in);
@@ -3202,14 +3211,14 @@ void LayerWeightNode::compile(SVMCompiler& compiler)
if(!fresnel_out->links.empty()) {
compiler.stack_assign(fresnel_out);
compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
- compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, fresnel_out->stack_offset));
+ compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, normal_in->stack_offset, fresnel_out->stack_offset));
}
ShaderOutput *facing_out = output("Facing");
if(!facing_out->links.empty()) {
compiler.stack_assign(facing_out);
compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
- compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, facing_out->stack_offset));
+ compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, normal_in->stack_offset, facing_out->stack_offset));
}
}
@@ -3719,6 +3728,7 @@ void SetNormalNode::compile(OSLCompiler& compiler)
OSLScriptNode::OSLScriptNode()
: ShaderNode("osl_script")
{
+ special_type = SHADER_SPECIAL_TYPE_SCRIPT;
}
void OSLScriptNode::compile(SVMCompiler& compiler)
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index 0479dd9af74..6fb96a3290c 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -253,9 +253,9 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
Transform mtfm_pre = ob->motion.pre;
Transform mtfm_post = ob->motion.post;
- if(!mesh->attributes.find(ATTR_STD_MOTION_PRE))
+ if(!(mesh->attributes.find(ATTR_STD_MOTION_PRE) || mesh->curve_attributes.find(ATTR_STD_MOTION_PRE)))
mtfm_pre = mtfm_pre * itfm;
- if(!mesh->attributes.find(ATTR_STD_MOTION_POST))
+ if(!(mesh->attributes.find(ATTR_STD_MOTION_POST) || mesh->curve_attributes.find(ATTR_STD_MOTION_POST)))
mtfm_post = mtfm_post * itfm;
memcpy(&objects_vector[i*OBJECT_VECTOR_SIZE+0], &mtfm_pre, sizeof(float4)*3);
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 26af60572f6..8dbff224225 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -217,7 +217,6 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
uint shader_flag_size = scene->shaders.size()*4;
uint *shader_flag = dscene->shader_flag.resize(shader_flag_size);
uint i = 0;
- bool has_surface_bssrdf = false;
bool has_converter_blackbody = false;
foreach(Shader *shader, scene->shaders) {
@@ -231,8 +230,6 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
flag |= SD_HAS_VOLUME;
if(shader->homogeneous_volume)
flag |= SD_HOMOGENEOUS_VOLUME;
- if(shader->has_surface_bssrdf)
- has_surface_bssrdf = true;
if(shader->has_bssrdf_bump)
flag |= SD_HAS_BSSRDF_BUMP;
if(shader->has_converter_blackbody)
diff --git a/intern/cycles/render/sky_model.h b/intern/cycles/render/sky_model.h
index 4f0833aef5a..3814543c8b6 100644
--- a/intern/cycles/render/sky_model.h
+++ b/intern/cycles/render/sky_model.h
@@ -136,7 +136,7 @@ and solar radii: 'arhosekskymodelstate_alienworld_alloc_init()'.
See the notes about the "Alien World" functionality provided further down for a
discussion of the usefulness and limits of that second initalisation function.
-Sky model states that have been initialised with either function behave in a
+Sky model states that have been initialized with either function behave in a
completely identical fashion during use and cleanup.
Using the model to generate skydome samples
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index 9bdd5b29a8e..8b13a006673 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -22,7 +22,7 @@
CCL_NAMESPACE_BEGIN
-__device float color_srgb_to_scene_linear(float c)
+ccl_device float color_srgb_to_scene_linear(float c)
{
if(c < 0.04045f)
return (c < 0.0f)? 0.0f: c * (1.0f/12.92f);
@@ -30,7 +30,7 @@ __device float color_srgb_to_scene_linear(float c)
return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
}
-__device float color_scene_linear_to_srgb(float c)
+ccl_device float color_scene_linear_to_srgb(float c)
{
if(c < 0.0031308f)
return (c < 0.0f)? 0.0f: c * 12.92f;
@@ -38,7 +38,7 @@ __device float color_scene_linear_to_srgb(float c)
return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
}
-__device float3 rgb_to_hsv(float3 rgb)
+ccl_device float3 rgb_to_hsv(float3 rgb)
{
float cmax, cmin, h, s, v, cdelta;
float3 c;
@@ -77,7 +77,7 @@ __device float3 rgb_to_hsv(float3 rgb)
return make_float3(h, s, v);
}
-__device float3 hsv_to_rgb(float3 hsv)
+ccl_device float3 hsv_to_rgb(float3 hsv)
{
float i, f, p, q, t, h, s, v;
float3 rgb;
@@ -112,7 +112,7 @@ __device float3 hsv_to_rgb(float3 hsv)
return rgb;
}
-__device float3 xyY_to_xyz(float x, float y, float Y)
+ccl_device float3 xyY_to_xyz(float x, float y, float Y)
{
float X, Z;
@@ -125,7 +125,7 @@ __device float3 xyY_to_xyz(float x, float y, float Y)
return make_float3(X, Y, Z);
}
-__device float3 xyz_to_rgb(float x, float y, float z)
+ccl_device float3 xyz_to_rgb(float x, float y, float z)
{
return make_float3(3.240479f * x + -1.537150f * y + -0.498535f * z,
-0.969256f * x + 1.875991f * y + 0.041556f * z,
@@ -134,7 +134,7 @@ __device float3 xyz_to_rgb(float x, float y, float z)
#ifndef __KERNEL_OPENCL__
-__device float3 color_srgb_to_scene_linear(float3 c)
+ccl_device float3 color_srgb_to_scene_linear(float3 c)
{
return make_float3(
color_srgb_to_scene_linear(c.x),
@@ -142,7 +142,7 @@ __device float3 color_srgb_to_scene_linear(float3 c)
color_srgb_to_scene_linear(c.z));
}
-__device float3 color_scene_linear_to_srgb(float3 c)
+ccl_device float3 color_scene_linear_to_srgb(float3 c)
{
return make_float3(
color_scene_linear_to_srgb(c.x),
@@ -152,7 +152,7 @@ __device float3 color_scene_linear_to_srgb(float3 c)
#endif
-__device float linear_rgb_to_gray(float3 c)
+ccl_device float linear_rgb_to_gray(float3 c)
{
return c.x*0.2126f + c.y*0.7152f + c.z*0.0722f;
}
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 987ef4f17ac..851c67b1189 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -89,12 +89,12 @@ CCL_NAMESPACE_BEGIN
#ifndef __KERNEL_OPENCL__
-__device_inline float fmaxf(float a, float b)
+ccl_device_inline float fmaxf(float a, float b)
{
return (a > b)? a: b;
}
-__device_inline float fminf(float a, float b)
+ccl_device_inline float fminf(float a, float b)
{
return (a < b)? a: b;
}
@@ -105,63 +105,63 @@ __device_inline float fminf(float a, float b)
#ifndef __KERNEL_GPU__
-__device_inline int max(int a, int b)
+ccl_device_inline int max(int a, int b)
{
return (a > b)? a: b;
}
-__device_inline int min(int a, int b)
+ccl_device_inline int min(int a, int b)
{
return (a < b)? a: b;
}
-__device_inline float max(float a, float b)
+ccl_device_inline float max(float a, float b)
{
return (a > b)? a: b;
}
-__device_inline float min(float a, float b)
+ccl_device_inline float min(float a, float b)
{
return (a < b)? a: b;
}
-__device_inline double max(double a, double b)
+ccl_device_inline double max(double a, double b)
{
return (a > b)? a: b;
}
-__device_inline double min(double a, double b)
+ccl_device_inline double min(double a, double b)
{
return (a < b)? a: b;
}
#endif
-__device_inline float min4(float a, float b, float c, float d)
+ccl_device_inline float min4(float a, float b, float c, float d)
{
return min(min(a, b), min(c, d));
}
-__device_inline float max4(float a, float b, float c, float d)
+ccl_device_inline float max4(float a, float b, float c, float d)
{
return max(max(a, b), max(c, d));
}
#ifndef __KERNEL_OPENCL__
-__device_inline int clamp(int a, int mn, int mx)
+ccl_device_inline int clamp(int a, int mn, int mx)
{
return min(max(a, mn), mx);
}
-__device_inline float clamp(float a, float mn, float mx)
+ccl_device_inline float clamp(float a, float mn, float mx)
{
return min(max(a, mn), mx);
}
#endif
-__device_inline int float_to_int(float f)
+ccl_device_inline int float_to_int(float f)
{
#if defined(__KERNEL_SSE2__) && !defined(_MSC_VER)
return _mm_cvtt_ss2si(_mm_load_ss(&f));
@@ -170,22 +170,22 @@ __device_inline int float_to_int(float f)
#endif
}
-__device_inline int floor_to_int(float f)
+ccl_device_inline int floor_to_int(float f)
{
return float_to_int(floorf(f));
}
-__device_inline int ceil_to_int(float f)
+ccl_device_inline int ceil_to_int(float f)
{
return float_to_int(ceilf(f));
}
-__device_inline float signf(float f)
+ccl_device_inline float signf(float f)
{
return (f < 0.0f)? -1.0f: 1.0f;
}
-__device_inline float nonzerof(float f, float eps)
+ccl_device_inline float nonzerof(float f, float eps)
{
if(fabsf(f) < eps)
return signf(f)*eps;
@@ -193,7 +193,7 @@ __device_inline float nonzerof(float f, float eps)
return f;
}
-__device_inline float smoothstepf(float f)
+ccl_device_inline float smoothstepf(float f)
{
float ff = f*f;
return (3.0f*ff - 2.0f*ff*f);
@@ -203,7 +203,7 @@ __device_inline float smoothstepf(float f)
#ifndef __KERNEL_OPENCL__
-__device_inline bool is_zero(const float2 a)
+ccl_device_inline bool is_zero(const float2 a)
{
return (a.x == 0.0f && a.y == 0.0f);
}
@@ -212,7 +212,7 @@ __device_inline bool is_zero(const float2 a)
#ifndef __KERNEL_OPENCL__
-__device_inline float average(const float2 a)
+ccl_device_inline float average(const float2 a)
{
return (a.x + a.y)*(1.0f/2.0f);
}
@@ -221,85 +221,85 @@ __device_inline float average(const float2 a)
#ifndef __KERNEL_OPENCL__
-__device_inline float2 operator-(const float2 a)
+ccl_device_inline float2 operator-(const float2 a)
{
return make_float2(-a.x, -a.y);
}
-__device_inline float2 operator*(const float2 a, const float2 b)
+ccl_device_inline float2 operator*(const float2 a, const float2 b)
{
return make_float2(a.x*b.x, a.y*b.y);
}
-__device_inline float2 operator*(const float2 a, float f)
+ccl_device_inline float2 operator*(const float2 a, float f)
{
return make_float2(a.x*f, a.y*f);
}
-__device_inline float2 operator*(float f, const float2 a)
+ccl_device_inline float2 operator*(float f, const float2 a)
{
return make_float2(a.x*f, a.y*f);
}
-__device_inline float2 operator/(float f, const float2 a)
+ccl_device_inline float2 operator/(float f, const float2 a)
{
return make_float2(f/a.x, f/a.y);
}
-__device_inline float2 operator/(const float2 a, float f)
+ccl_device_inline float2 operator/(const float2 a, float f)
{
float invf = 1.0f/f;
return make_float2(a.x*invf, a.y*invf);
}
-__device_inline float2 operator/(const float2 a, const float2 b)
+ccl_device_inline float2 operator/(const float2 a, const float2 b)
{
return make_float2(a.x/b.x, a.y/b.y);
}
-__device_inline float2 operator+(const float2 a, const float2 b)
+ccl_device_inline float2 operator+(const float2 a, const float2 b)
{
return make_float2(a.x+b.x, a.y+b.y);
}
-__device_inline float2 operator-(const float2 a, const float2 b)
+ccl_device_inline float2 operator-(const float2 a, const float2 b)
{
return make_float2(a.x-b.x, a.y-b.y);
}
-__device_inline float2 operator+=(float2& a, const float2 b)
+ccl_device_inline float2 operator+=(float2& a, const float2 b)
{
return a = a + b;
}
-__device_inline float2 operator*=(float2& a, const float2 b)
+ccl_device_inline float2 operator*=(float2& a, const float2 b)
{
return a = a * b;
}
-__device_inline float2 operator*=(float2& a, float f)
+ccl_device_inline float2 operator*=(float2& a, float f)
{
return a = a * f;
}
-__device_inline float2 operator/=(float2& a, const float2 b)
+ccl_device_inline float2 operator/=(float2& a, const float2 b)
{
return a = a / b;
}
-__device_inline float2 operator/=(float2& a, float f)
+ccl_device_inline float2 operator/=(float2& a, float f)
{
float invf = 1.0f/f;
return a = a * invf;
}
-__device_inline float dot(const float2 a, const float2 b)
+ccl_device_inline float dot(const float2 a, const float2 b)
{
return a.x*b.x + a.y*b.y;
}
-__device_inline float cross(const float2 a, const float2 b)
+ccl_device_inline float cross(const float2 a, const float2 b)
{
return (a.x*b.y - a.y*b.x);
}
@@ -308,58 +308,58 @@ __device_inline float cross(const float2 a, const float2 b)
#ifndef __KERNEL_OPENCL__
-__device_inline bool operator==(const int2 a, const int2 b)
+ccl_device_inline bool operator==(const int2 a, const int2 b)
{
return (a.x == b.x && a.y == b.y);
}
-__device_inline float len(const float2 a)
+ccl_device_inline float len(const float2 a)
{
return sqrtf(dot(a, a));
}
-__device_inline float2 normalize(const float2 a)
+ccl_device_inline float2 normalize(const float2 a)
{
return a/len(a);
}
-__device_inline float2 normalize_len(const float2 a, float *t)
+ccl_device_inline float2 normalize_len(const float2 a, float *t)
{
*t = len(a);
return a/(*t);
}
-__device_inline bool operator==(const float2 a, const float2 b)
+ccl_device_inline bool operator==(const float2 a, const float2 b)
{
return (a.x == b.x && a.y == b.y);
}
-__device_inline bool operator!=(const float2 a, const float2 b)
+ccl_device_inline bool operator!=(const float2 a, const float2 b)
{
return !(a == b);
}
-__device_inline float2 min(float2 a, float2 b)
+ccl_device_inline float2 min(float2 a, float2 b)
{
return make_float2(min(a.x, b.x), min(a.y, b.y));
}
-__device_inline float2 max(float2 a, float2 b)
+ccl_device_inline float2 max(float2 a, float2 b)
{
return make_float2(max(a.x, b.x), max(a.y, b.y));
}
-__device_inline float2 clamp(float2 a, float2 mn, float2 mx)
+ccl_device_inline float2 clamp(float2 a, float2 mn, float2 mx)
{
return min(max(a, mn), mx);
}
-__device_inline float2 fabs(float2 a)
+ccl_device_inline float2 fabs(float2 a)
{
return make_float2(fabsf(a.x), fabsf(a.y));
}
-__device_inline float2 as_float2(const float4 a)
+ccl_device_inline float2 as_float2(const float4 a)
{
return make_float2(a.x, a.y);
}
@@ -368,7 +368,7 @@ __device_inline float2 as_float2(const float4 a)
#ifndef __KERNEL_GPU__
-__device_inline void print_float2(const char *label, const float2& a)
+ccl_device_inline void print_float2(const char *label, const float2& a)
{
printf("%s: %.8f %.8f\n", label, (double)a.x, (double)a.y);
}
@@ -377,7 +377,7 @@ __device_inline void print_float2(const char *label, const float2& a)
#ifndef __KERNEL_OPENCL__
-__device_inline float2 interp(float2 a, float2 b, float t)
+ccl_device_inline float2 interp(float2 a, float2 b, float t)
{
return a + t*(b - a);
}
@@ -388,84 +388,88 @@ __device_inline float2 interp(float2 a, float2 b, float t)
#ifndef __KERNEL_OPENCL__
-__device_inline float3 operator-(const float3 a)
+ccl_device_inline float3 operator-(const float3 a)
{
return make_float3(-a.x, -a.y, -a.z);
}
-__device_inline float3 operator*(const float3 a, const float3 b)
+ccl_device_inline float3 operator*(const float3 a, const float3 b)
{
return make_float3(a.x*b.x, a.y*b.y, a.z*b.z);
}
-__device_inline float3 operator*(const float3 a, float f)
+ccl_device_inline float3 operator*(const float3 a, float f)
{
return make_float3(a.x*f, a.y*f, a.z*f);
}
-__device_inline float3 operator*(float f, const float3 a)
+ccl_device_inline float3 operator*(float f, const float3 a)
{
return make_float3(a.x*f, a.y*f, a.z*f);
}
-__device_inline float3 operator/(float f, const float3 a)
+ccl_device_inline float3 operator/(float f, const float3 a)
{
return make_float3(f/a.x, f/a.y, f/a.z);
}
-__device_inline float3 operator/(const float3 a, float f)
+ccl_device_inline float3 operator/(const float3 a, float f)
{
float invf = 1.0f/f;
return make_float3(a.x*invf, a.y*invf, a.z*invf);
}
-__device_inline float3 operator/(const float3 a, const float3 b)
+ccl_device_inline float3 operator/(const float3 a, const float3 b)
{
return make_float3(a.x/b.x, a.y/b.y, a.z/b.z);
}
-__device_inline float3 operator+(const float3 a, const float3 b)
+ccl_device_inline float3 operator+(const float3 a, const float3 b)
{
return make_float3(a.x+b.x, a.y+b.y, a.z+b.z);
}
-__device_inline float3 operator-(const float3 a, const float3 b)
+ccl_device_inline float3 operator-(const float3 a, const float3 b)
{
return make_float3(a.x-b.x, a.y-b.y, a.z-b.z);
}
-__device_inline float3 operator+=(float3& a, const float3 b)
+ccl_device_inline float3 operator+=(float3& a, const float3 b)
{
return a = a + b;
}
-__device_inline float3 operator*=(float3& a, const float3 b)
+ccl_device_inline float3 operator*=(float3& a, const float3 b)
{
return a = a * b;
}
-__device_inline float3 operator*=(float3& a, float f)
+ccl_device_inline float3 operator*=(float3& a, float f)
{
return a = a * f;
}
-__device_inline float3 operator/=(float3& a, const float3 b)
+ccl_device_inline float3 operator/=(float3& a, const float3 b)
{
return a = a / b;
}
-__device_inline float3 operator/=(float3& a, float f)
+ccl_device_inline float3 operator/=(float3& a, float f)
{
float invf = 1.0f/f;
return a = a * invf;
}
-__device_inline float dot(const float3 a, const float3 b)
+ccl_device_inline float dot(const float3 a, const float3 b)
{
+#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__)
+ return _mm_cvtss_f32(_mm_dp_ps(a, b, 0x7F));
+#else
return a.x*b.x + a.y*b.y + a.z*b.z;
+#endif
}
-__device_inline float3 cross(const float3 a, const float3 b)
+ccl_device_inline float3 cross(const float3 a, const float3 b)
{
float3 r = make_float3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x);
return r;
@@ -473,26 +477,35 @@ __device_inline float3 cross(const float3 a, const float3 b)
#endif
-__device_inline float len(const float3 a)
+ccl_device_inline float len(const float3 a)
{
+#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__)
+ return _mm_cvtss_f32(_mm_sqrt_ss(_mm_dp_ps(a.m128, a.m128, 0x7F)));
+#else
return sqrtf(dot(a, a));
+#endif
}
-__device_inline float len_squared(const float3 a)
+ccl_device_inline float len_squared(const float3 a)
{
return dot(a, a);
}
#ifndef __KERNEL_OPENCL__
-__device_inline float3 normalize(const float3 a)
+ccl_device_inline float3 normalize(const float3 a)
{
+#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__)
+ __m128 norm = _mm_sqrt_ps(_mm_dp_ps(a.m128, a.m128, 0x7F));
+ return _mm_div_ps(a.m128, norm);
+#else
return a/len(a);
+#endif
}
#endif
-__device_inline float3 normalize_len(const float3 a, float *t)
+ccl_device_inline float3 normalize_len(const float3 a, float *t)
{
*t = len(a);
return a/(*t);
@@ -500,7 +513,7 @@ __device_inline float3 normalize_len(const float3 a, float *t)
#ifndef __KERNEL_OPENCL__
-__device_inline bool operator==(const float3 a, const float3 b)
+ccl_device_inline bool operator==(const float3 a, const float3 b)
{
#ifdef __KERNEL_SSE__
return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 7) == 7;
@@ -509,12 +522,12 @@ __device_inline bool operator==(const float3 a, const float3 b)
#endif
}
-__device_inline bool operator!=(const float3 a, const float3 b)
+ccl_device_inline bool operator!=(const float3 a, const float3 b)
{
return !(a == b);
}
-__device_inline float3 min(float3 a, float3 b)
+ccl_device_inline float3 min(float3 a, float3 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_ps(a.m128, b.m128);
@@ -523,7 +536,7 @@ __device_inline float3 min(float3 a, float3 b)
#endif
}
-__device_inline float3 max(float3 a, float3 b)
+ccl_device_inline float3 max(float3 a, float3 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_ps(a.m128, b.m128);
@@ -532,12 +545,12 @@ __device_inline float3 max(float3 a, float3 b)
#endif
}
-__device_inline float3 clamp(float3 a, float3 mn, float3 mx)
+ccl_device_inline float3 clamp(float3 a, float3 mn, float3 mx)
{
return min(max(a, mn), mx);
}
-__device_inline float3 fabs(float3 a)
+ccl_device_inline float3 fabs(float3 a)
{
#ifdef __KERNEL_SSE__
__m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff));
@@ -549,29 +562,29 @@ __device_inline float3 fabs(float3 a)
#endif
-__device_inline float3 float2_to_float3(const float2 a)
+ccl_device_inline float3 float2_to_float3(const float2 a)
{
return make_float3(a.x, a.y, 0.0f);
}
-__device_inline float3 float4_to_float3(const float4 a)
+ccl_device_inline float3 float4_to_float3(const float4 a)
{
return make_float3(a.x, a.y, a.z);
}
-__device_inline float4 float3_to_float4(const float3 a)
+ccl_device_inline float4 float3_to_float4(const float3 a)
{
return make_float4(a.x, a.y, a.z, 1.0f);
}
#ifndef __KERNEL_GPU__
-__device_inline void print_float3(const char *label, const float3& a)
+ccl_device_inline void print_float3(const char *label, const float3& a)
{
printf("%s: %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z);
}
-__device_inline float3 rcp(const float3& a)
+ccl_device_inline float3 rcp(const float3& a)
{
#ifdef __KERNEL_SSE__
float4 r = _mm_rcp_ps(a.m128);
@@ -583,12 +596,12 @@ __device_inline float3 rcp(const float3& a)
#endif
-__device_inline float3 interp(float3 a, float3 b, float t)
+ccl_device_inline float3 interp(float3 a, float3 b, float t)
{
return a + t*(b - a);
}
-__device_inline bool is_zero(const float3 a)
+ccl_device_inline bool is_zero(const float3 a)
{
#ifdef __KERNEL_SSE__
return a == make_float3(0.0f);
@@ -597,7 +610,7 @@ __device_inline bool is_zero(const float3 a)
#endif
}
-__device_inline float reduce_add(const float3 a)
+ccl_device_inline float reduce_add(const float3 a)
{
#ifdef __KERNEL_SSE__
return (a.x + a.y + a.z);
@@ -606,7 +619,7 @@ __device_inline float reduce_add(const float3 a)
#endif
}
-__device_inline float average(const float3 a)
+ccl_device_inline float average(const float3 a)
{
return reduce_add(a)*(1.0f/3.0f);
}
@@ -639,7 +652,7 @@ template<> __forceinline const float4 shuffle<0, 1, 0, 1>(const float4& b)
#ifndef __KERNEL_OPENCL__
-__device_inline float4 operator-(const float4& a)
+ccl_device_inline float4 operator-(const float4& a)
{
#ifdef __KERNEL_SSE__
__m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
@@ -649,7 +662,7 @@ __device_inline float4 operator-(const float4& a)
#endif
}
-__device_inline float4 operator*(const float4& a, const float4& b)
+ccl_device_inline float4 operator*(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_mul_ps(a.m128, b.m128);
@@ -658,7 +671,7 @@ __device_inline float4 operator*(const float4& a, const float4& b)
#endif
}
-__device_inline float4 operator*(const float4& a, float f)
+ccl_device_inline float4 operator*(const float4& a, float f)
{
#ifdef __KERNEL_SSE__
return a * make_float4(f);
@@ -667,12 +680,12 @@ __device_inline float4 operator*(const float4& a, float f)
#endif
}
-__device_inline float4 operator*(float f, const float4& a)
+ccl_device_inline float4 operator*(float f, const float4& a)
{
return a * f;
}
-__device_inline float4 rcp(const float4& a)
+ccl_device_inline float4 rcp(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 r = _mm_rcp_ps(a.m128);
@@ -682,12 +695,12 @@ __device_inline float4 rcp(const float4& a)
#endif
}
-__device_inline float4 operator/(const float4& a, float f)
+ccl_device_inline float4 operator/(const float4& a, float f)
{
return a * (1.0f/f);
}
-__device_inline float4 operator/(const float4& a, const float4& b)
+ccl_device_inline float4 operator/(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return a * rcp(b);
@@ -697,7 +710,7 @@ __device_inline float4 operator/(const float4& a, const float4& b)
}
-__device_inline float4 operator+(const float4& a, const float4& b)
+ccl_device_inline float4 operator+(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_add_ps(a.m128, b.m128);
@@ -706,7 +719,7 @@ __device_inline float4 operator+(const float4& a, const float4& b)
#endif
}
-__device_inline float4 operator-(const float4& a, const float4& b)
+ccl_device_inline float4 operator-(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_sub_ps(a.m128, b.m128);
@@ -715,22 +728,22 @@ __device_inline float4 operator-(const float4& a, const float4& b)
#endif
}
-__device_inline float4 operator+=(float4& a, const float4& b)
+ccl_device_inline float4 operator+=(float4& a, const float4& b)
{
return a = a + b;
}
-__device_inline float4 operator*=(float4& a, const float4& b)
+ccl_device_inline float4 operator*=(float4& a, const float4& b)
{
return a = a * b;
}
-__device_inline float4 operator/=(float4& a, float f)
+ccl_device_inline float4 operator/=(float4& a, float f)
{
return a = a / f;
}
-__device_inline int4 operator<(const float4& a, const float4& b)
+ccl_device_inline int4 operator<(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmplt_ps(a.m128, b.m128)); /* todo: avoid cvt */
@@ -739,7 +752,7 @@ __device_inline int4 operator<(const float4& a, const float4& b)
#endif
}
-__device_inline int4 operator>=(float4 a, float4 b)
+ccl_device_inline int4 operator>=(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmpge_ps(a.m128, b.m128)); /* todo: avoid cvt */
@@ -748,7 +761,7 @@ __device_inline int4 operator>=(float4 a, float4 b)
#endif
}
-__device_inline int4 operator<=(const float4& a, const float4& b)
+ccl_device_inline int4 operator<=(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return _mm_cvtps_epi32(_mm_cmple_ps(a.m128, b.m128)); /* todo: avoid cvt */
@@ -757,7 +770,7 @@ __device_inline int4 operator<=(const float4& a, const float4& b)
#endif
}
-__device_inline bool operator==(const float4 a, const float4 b)
+ccl_device_inline bool operator==(const float4 a, const float4 b)
{
#ifdef __KERNEL_SSE__
return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 15) == 15;
@@ -766,7 +779,7 @@ __device_inline bool operator==(const float4 a, const float4 b)
#endif
}
-__device_inline float4 cross(const float4& a, const float4& b)
+ccl_device_inline float4 cross(const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
return (shuffle<1,2,0,0>(a)*shuffle<2,0,1,0>(b)) - (shuffle<2,0,1,0>(a)*shuffle<1,2,0,0>(b));
@@ -775,7 +788,7 @@ __device_inline float4 cross(const float4& a, const float4& b)
#endif
}
-__device_inline bool is_zero(const float4& a)
+ccl_device_inline bool is_zero(const float4& a)
{
#ifdef __KERNEL_SSE__
return a == make_float4(0.0f);
@@ -784,7 +797,7 @@ __device_inline bool is_zero(const float4& a)
#endif
}
-__device_inline float reduce_add(const float4& a)
+ccl_device_inline float reduce_add(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = shuffle<1,0,3,2>(a) + a;
@@ -794,27 +807,27 @@ __device_inline float reduce_add(const float4& a)
#endif
}
-__device_inline float average(const float4& a)
+ccl_device_inline float average(const float4& a)
{
return reduce_add(a) * 0.25f;
}
-__device_inline float dot(const float4& a, const float4& b)
+ccl_device_inline float dot(const float4& a, const float4& b)
{
return reduce_add(a * b);
}
-__device_inline float len(const float4 a)
+ccl_device_inline float len(const float4 a)
{
return sqrtf(dot(a, a));
}
-__device_inline float4 normalize(const float4 a)
+ccl_device_inline float4 normalize(const float4 a)
{
return a/len(a);
}
-__device_inline float4 min(float4 a, float4 b)
+ccl_device_inline float4 min(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_ps(a.m128, b.m128);
@@ -823,7 +836,7 @@ __device_inline float4 min(float4 a, float4 b)
#endif
}
-__device_inline float4 max(float4 a, float4 b)
+ccl_device_inline float4 max(float4 a, float4 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_ps(a.m128, b.m128);
@@ -836,7 +849,7 @@ __device_inline float4 max(float4 a, float4 b)
#ifndef __KERNEL_GPU__
-__device_inline float4 select(const int4& mask, const float4& a, const float4& b)
+ccl_device_inline float4 select(const int4& mask, const float4& a, const float4& b)
{
#ifdef __KERNEL_SSE__
/* blendv is sse4, and apparently broken on vs2008 */
@@ -846,7 +859,7 @@ __device_inline float4 select(const int4& mask, const float4& a, const float4& b
#endif
}
-__device_inline float4 reduce_min(const float4& a)
+ccl_device_inline float4 reduce_min(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = min(shuffle<1,0,3,2>(a), a);
@@ -856,7 +869,7 @@ __device_inline float4 reduce_min(const float4& a)
#endif
}
-__device_inline float4 reduce_max(const float4& a)
+ccl_device_inline float4 reduce_max(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = max(shuffle<1,0,3,2>(a), a);
@@ -867,7 +880,7 @@ __device_inline float4 reduce_max(const float4& a)
}
#if 0
-__device_inline float4 reduce_add(const float4& a)
+ccl_device_inline float4 reduce_add(const float4& a)
{
#ifdef __KERNEL_SSE__
float4 h = shuffle<1,0,3,2>(a) + a;
@@ -878,7 +891,7 @@ __device_inline float4 reduce_add(const float4& a)
}
#endif
-__device_inline void print_float4(const char *label, const float4& a)
+ccl_device_inline void print_float4(const char *label, const float4& a)
{
printf("%s: %.8f %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z, (double)a.w);
}
@@ -889,7 +902,7 @@ __device_inline void print_float4(const char *label, const float4& a)
#ifndef __KERNEL_OPENCL__
-__device_inline int3 min(int3 a, int3 b)
+ccl_device_inline int3 min(int3 a, int3 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_epi32(a.m128, b.m128);
@@ -898,7 +911,7 @@ __device_inline int3 min(int3 a, int3 b)
#endif
}
-__device_inline int3 max(int3 a, int3 b)
+ccl_device_inline int3 max(int3 a, int3 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_epi32(a.m128, b.m128);
@@ -907,7 +920,7 @@ __device_inline int3 max(int3 a, int3 b)
#endif
}
-__device_inline int3 clamp(const int3& a, int mn, int mx)
+ccl_device_inline int3 clamp(const int3& a, int mn, int mx)
{
#ifdef __KERNEL_SSE__
return min(max(a, make_int3(mn)), make_int3(mx));
@@ -916,7 +929,7 @@ __device_inline int3 clamp(const int3& a, int mn, int mx)
#endif
}
-__device_inline int3 clamp(const int3& a, int3& mn, int mx)
+ccl_device_inline int3 clamp(const int3& a, int3& mn, int mx)
{
#ifdef __KERNEL_SSE__
return min(max(a, mn), make_int3(mx));
@@ -929,7 +942,7 @@ __device_inline int3 clamp(const int3& a, int3& mn, int mx)
#ifndef __KERNEL_GPU__
-__device_inline void print_int3(const char *label, const int3& a)
+ccl_device_inline void print_int3(const char *label, const int3& a)
{
printf("%s: %d %d %d\n", label, a.x, a.y, a.z);
}
@@ -940,7 +953,7 @@ __device_inline void print_int3(const char *label, const int3& a)
#ifndef __KERNEL_GPU__
-__device_inline int4 operator+(const int4& a, const int4& b)
+ccl_device_inline int4 operator+(const int4& a, const int4& b)
{
#ifdef __KERNEL_SSE__
return _mm_add_epi32(a.m128, b.m128);
@@ -949,12 +962,12 @@ __device_inline int4 operator+(const int4& a, const int4& b)
#endif
}
-__device_inline int4 operator+=(int4& a, const int4& b)
+ccl_device_inline int4 operator+=(int4& a, const int4& b)
{
return a = a + b;
}
-__device_inline int4 operator>>(const int4& a, int i)
+ccl_device_inline int4 operator>>(const int4& a, int i)
{
#ifdef __KERNEL_SSE__
return _mm_srai_epi32(a.m128, i);
@@ -963,7 +976,7 @@ __device_inline int4 operator>>(const int4& a, int i)
#endif
}
-__device_inline int4 min(int4 a, int4 b)
+ccl_device_inline int4 min(int4 a, int4 b)
{
#ifdef __KERNEL_SSE__
return _mm_min_epi32(a.m128, b.m128);
@@ -972,7 +985,7 @@ __device_inline int4 min(int4 a, int4 b)
#endif
}
-__device_inline int4 max(int4 a, int4 b)
+ccl_device_inline int4 max(int4 a, int4 b)
{
#ifdef __KERNEL_SSE__
return _mm_max_epi32(a.m128, b.m128);
@@ -981,12 +994,12 @@ __device_inline int4 max(int4 a, int4 b)
#endif
}
-__device_inline int4 clamp(const int4& a, const int4& mn, const int4& mx)
+ccl_device_inline int4 clamp(const int4& a, const int4& mn, const int4& mx)
{
return min(max(a, mn), mx);
}
-__device_inline int4 select(const int4& mask, const int4& a, const int4& b)
+ccl_device_inline int4 select(const int4& mask, const int4& a, const int4& b)
{
#ifdef __KERNEL_SSE__
__m128 m = _mm_cvtepi32_ps(mask);
@@ -996,7 +1009,7 @@ __device_inline int4 select(const int4& mask, const int4& a, const int4& b)
#endif
}
-__device_inline void print_int4(const char *label, const int4& a)
+ccl_device_inline void print_int4(const char *label, const int4& a)
{
printf("%s: %d %d %d %d\n", label, a.x, a.y, a.z, a.w);
}
@@ -1007,49 +1020,49 @@ __device_inline void print_int4(const char *label, const int4& a)
#ifndef __KERNEL_OPENCL__
-__device_inline int as_int(uint i)
+ccl_device_inline int as_int(uint i)
{
union { uint ui; int i; } u;
u.ui = i;
return u.i;
}
-__device_inline uint as_uint(int i)
+ccl_device_inline uint as_uint(int i)
{
union { uint ui; int i; } u;
u.i = i;
return u.ui;
}
-__device_inline uint as_uint(float f)
+ccl_device_inline uint as_uint(float f)
{
union { uint i; float f; } u;
u.f = f;
return u.i;
}
-__device_inline int __float_as_int(float f)
+ccl_device_inline int __float_as_int(float f)
{
union { int i; float f; } u;
u.f = f;
return u.i;
}
-__device_inline float __int_as_float(int i)
+ccl_device_inline float __int_as_float(int i)
{
union { int i; float f; } u;
u.i = i;
return u.f;
}
-__device_inline uint __float_as_uint(float f)
+ccl_device_inline uint __float_as_uint(float f)
{
union { uint i; float f; } u;
u.f = f;
return u.i;
}
-__device_inline float __uint_as_float(uint i)
+ccl_device_inline float __uint_as_float(uint i)
{
union { uint i; float f; } u;
u.i = i;
@@ -1065,7 +1078,7 @@ template<class A, class B> A lerp(const A& a, const A& b, const B& t)
/* Triangle */
-__device_inline float triangle_area(const float3 v1, const float3 v2, const float3 v3)
+ccl_device_inline float triangle_area(const float3 v1, const float3 v2, const float3 v3)
{
return len(cross(v3 - v2, v1 - v2))*0.5f;
}
@@ -1074,7 +1087,7 @@ __device_inline float triangle_area(const float3 v1, const float3 v2, const floa
/* Orthonormal vectors */
-__device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b)
+ccl_device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b)
{
#if 0
if(fabsf(N.y) >= 0.999f) {
@@ -1100,7 +1113,7 @@ __device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b)
/* Color division */
-__device_inline float3 safe_divide_color(float3 a, float3 b)
+ccl_device_inline float3 safe_divide_color(float3 a, float3 b)
{
float x, y, z;
@@ -1111,7 +1124,7 @@ __device_inline float3 safe_divide_color(float3 a, float3 b)
return make_float3(x, y, z);
}
-__device_inline float3 safe_divide_even_color(float3 a, float3 b)
+ccl_device_inline float3 safe_divide_even_color(float3 a, float3 b)
{
float x, y, z;
@@ -1149,7 +1162,7 @@ __device_inline float3 safe_divide_even_color(float3 a, float3 b)
/* Rotation of point around axis and angle */
-__device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)
+ccl_device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)
{
float costheta = cosf(angle);
float sintheta = sinf(angle);
@@ -1172,12 +1185,12 @@ __device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)
/* NaN-safe math ops */
-__device_inline float safe_sqrtf(float f)
+ccl_device_inline float safe_sqrtf(float f)
{
return sqrtf(max(f, 0.0f));
}
-__device float safe_asinf(float a)
+ccl_device float safe_asinf(float a)
{
if(a <= -1.0f)
return -M_PI_2_F;
@@ -1187,7 +1200,7 @@ __device float safe_asinf(float a)
return asinf(a);
}
-__device float safe_acosf(float a)
+ccl_device float safe_acosf(float a)
{
if(a <= -1.0f)
return M_PI_F;
@@ -1197,7 +1210,7 @@ __device float safe_acosf(float a)
return acosf(a);
}
-__device float compatible_powf(float x, float y)
+ccl_device float compatible_powf(float x, float y)
{
/* GPU pow doesn't accept negative x, do manual checks here */
if(x < 0.0f) {
@@ -1212,7 +1225,7 @@ __device float compatible_powf(float x, float y)
return powf(x, y);
}
-__device float safe_powf(float a, float b)
+ccl_device float safe_powf(float a, float b)
{
if(b == 0.0f)
return 1.0f;
@@ -1224,7 +1237,7 @@ __device float safe_powf(float a, float b)
return compatible_powf(a, b);
}
-__device float safe_logf(float a, float b)
+ccl_device float safe_logf(float a, float b)
{
if(a < 0.0f || b < 0.0f)
return 0.0f;
@@ -1232,19 +1245,19 @@ __device float safe_logf(float a, float b)
return logf(a)/logf(b);
}
-__device float safe_divide(float a, float b)
+ccl_device float safe_divide(float a, float b)
{
return (b != 0.0f)? a/b: 0.0f;
}
-__device float safe_modulo(float a, float b)
+ccl_device float safe_modulo(float a, float b)
{
return (b != 0.0f)? fmodf(a, b): 0.0f;
}
/* Ray Intersection */
-__device bool ray_sphere_intersect(
+ccl_device bool ray_sphere_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 sphere_P, float sphere_radius,
float3 *isect_P, float *isect_t)
@@ -1276,7 +1289,7 @@ __device bool ray_sphere_intersect(
return false;
}
-__device bool ray_aligned_disk_intersect(
+ccl_device bool ray_aligned_disk_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 disk_P, float disk_radius,
float3 *isect_P, float *isect_t)
@@ -1305,7 +1318,7 @@ __device bool ray_aligned_disk_intersect(
return true;
}
-__device bool ray_triangle_intersect(
+ccl_device bool ray_triangle_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 v0, float3 v1, float3 v2,
float3 *isect_P, float *isect_t)
@@ -1348,7 +1361,7 @@ __device bool ray_triangle_intersect(
return true;
}
-__device bool ray_quad_intersect(
+ccl_device bool ray_quad_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 quad_P, float3 quad_u, float3 quad_v,
float3 *isect_P, float *isect_t)
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 345c76bdfab..8b249106913 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -195,6 +195,11 @@ bool system_cpu_support_sse3()
return caps.sse && caps.sse2 && caps.sse3 && caps.ssse3;
}
+bool system_cpu_support_sse41()
+{
+ CPUCapabilities& caps = system_cpu_capabilities();
+ return caps.sse && caps.sse2 && caps.sse3 && caps.ssse3 && caps.sse41;
+}
#else
bool system_cpu_support_sse2()
diff --git a/intern/cycles/util/util_system.h b/intern/cycles/util/util_system.h
index 333782c2d01..64cfa4906b3 100644
--- a/intern/cycles/util/util_system.h
+++ b/intern/cycles/util/util_system.h
@@ -26,6 +26,7 @@ string system_cpu_brand_string();
int system_cpu_bits();
bool system_cpu_support_sse2();
bool system_cpu_support_sse3();
+bool system_cpu_support_sse41();
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
index e5a5ac8cddf..14a81ecbb05 100644
--- a/intern/cycles/util/util_task.cpp
+++ b/intern/cycles/util/util_task.cpp
@@ -136,7 +136,7 @@ void TaskPool::stop()
assert(num == 0);
}
-bool TaskPool::cancelled()
+bool TaskPool::canceled()
{
return do_cancel;
}
@@ -366,7 +366,7 @@ void DedicatedTaskPool::stop()
assert(num == 0);
}
-bool DedicatedTaskPool::cancelled()
+bool DedicatedTaskPool::canceled()
{
return do_cancel;
}
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h
index 22515e3e433..42a1e2f5a58 100644
--- a/intern/cycles/util/util_task.h
+++ b/intern/cycles/util/util_task.h
@@ -66,7 +66,7 @@ public:
void cancel(); /* cancel all tasks, keep worker threads running */
void stop(); /* stop all worker threads */
- bool cancelled(); /* for worker threads, test if cancelled */
+ bool canceled(); /* for worker threads, test if canceled */
protected:
friend class TaskScheduler;
@@ -142,7 +142,7 @@ public:
void cancel(); /* cancel all tasks, keep worker thread running */
void stop(); /* stop worker thread */
- bool cancelled(); /* for worker thread, test if cancelled */
+ bool canceled(); /* for worker thread, test if canceled */
protected:
void num_decrease(int done);
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index 01655bdf9bc..1b6315ba484 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -43,7 +43,7 @@ typedef struct Transform {
*
* For the DecompMotionTransform we drop scale from pre/post. */
-typedef struct __may_alias MotionTransform {
+typedef struct ccl_may_alias MotionTransform {
Transform pre;
Transform mid;
Transform post;
@@ -57,7 +57,7 @@ typedef struct DecompMotionTransform {
/* Functions */
-__device_inline float3 transform_perspective(const Transform *t, const float3 a)
+ccl_device_inline float3 transform_perspective(const Transform *t, const float3 a)
{
float4 b = make_float4(a.x, a.y, a.z, 1.0f);
float3 c = make_float3(dot(t->x, b), dot(t->y, b), dot(t->z, b));
@@ -66,7 +66,7 @@ __device_inline float3 transform_perspective(const Transform *t, const float3 a)
return (w != 0.0f)? c/w: make_float3(0.0f, 0.0f, 0.0f);
}
-__device_inline float3 transform_point(const Transform *t, const float3 a)
+ccl_device_inline float3 transform_point(const Transform *t, const float3 a)
{
float3 c = make_float3(
a.x*t->x.x + a.y*t->x.y + a.z*t->x.z + t->x.w,
@@ -76,7 +76,7 @@ __device_inline float3 transform_point(const Transform *t, const float3 a)
return c;
}
-__device_inline float3 transform_direction(const Transform *t, const float3 a)
+ccl_device_inline float3 transform_direction(const Transform *t, const float3 a)
{
float3 c = make_float3(
a.x*t->x.x + a.y*t->x.y + a.z*t->x.z,
@@ -86,7 +86,7 @@ __device_inline float3 transform_direction(const Transform *t, const float3 a)
return c;
}
-__device_inline float3 transform_direction_transposed(const Transform *t, const float3 a)
+ccl_device_inline float3 transform_direction_transposed(const Transform *t, const float3 a)
{
float3 x = make_float3(t->x.x, t->y.x, t->z.x);
float3 y = make_float3(t->x.y, t->y.y, t->z.y);
@@ -95,7 +95,7 @@ __device_inline float3 transform_direction_transposed(const Transform *t, const
return make_float3(dot(x, a), dot(y, a), dot(z, a));
}
-__device_inline Transform transform_transpose(const Transform a)
+ccl_device_inline Transform transform_transpose(const Transform a)
{
Transform t;
@@ -107,7 +107,7 @@ __device_inline Transform transform_transpose(const Transform a)
return t;
}
-__device_inline Transform make_transform(float a, float b, float c, float d,
+ccl_device_inline Transform make_transform(float a, float b, float c, float d,
float e, float f, float g, float h,
float i, float j, float k, float l,
float m, float n, float o, float p)
@@ -124,7 +124,7 @@ __device_inline Transform make_transform(float a, float b, float c, float d,
#ifndef __KERNEL_GPU__
-__device_inline Transform operator*(const Transform a, const Transform b)
+ccl_device_inline Transform operator*(const Transform a, const Transform b)
{
Transform c = transform_transpose(b);
Transform t;
@@ -137,7 +137,7 @@ __device_inline Transform operator*(const Transform a, const Transform b)
return t;
}
-__device_inline void print_transform(const char *label, const Transform& t)
+ccl_device_inline void print_transform(const char *label, const Transform& t)
{
print_float4(label, t.x);
print_float4(label, t.y);
@@ -146,7 +146,7 @@ __device_inline void print_transform(const char *label, const Transform& t)
printf("\n");
}
-__device_inline Transform transform_translate(float3 t)
+ccl_device_inline Transform transform_translate(float3 t)
{
return make_transform(
1, 0, 0, t.x,
@@ -155,12 +155,12 @@ __device_inline Transform transform_translate(float3 t)
0, 0, 0, 1);
}
-__device_inline Transform transform_translate(float x, float y, float z)
+ccl_device_inline Transform transform_translate(float x, float y, float z)
{
return transform_translate(make_float3(x, y, z));
}
-__device_inline Transform transform_scale(float3 s)
+ccl_device_inline Transform transform_scale(float3 s)
{
return make_transform(
s.x, 0, 0, 0,
@@ -169,12 +169,12 @@ __device_inline Transform transform_scale(float3 s)
0, 0, 0, 1);
}
-__device_inline Transform transform_scale(float x, float y, float z)
+ccl_device_inline Transform transform_scale(float x, float y, float z)
{
return transform_scale(make_float3(x, y, z));
}
-__device_inline Transform transform_perspective(float fov, float n, float f)
+ccl_device_inline Transform transform_perspective(float fov, float n, float f)
{
Transform persp = make_transform(
1, 0, 0, 0,
@@ -189,7 +189,7 @@ __device_inline Transform transform_perspective(float fov, float n, float f)
return scale * persp;
}
-__device_inline Transform transform_rotate(float angle, float3 axis)
+ccl_device_inline Transform transform_rotate(float angle, float3 axis)
{
float s = sinf(angle);
float c = cosf(angle);
@@ -216,7 +216,7 @@ __device_inline Transform transform_rotate(float angle, float3 axis)
0.0f, 0.0f, 0.0f, 1.0f);
}
-__device_inline Transform transform_euler(float3 euler)
+ccl_device_inline Transform transform_euler(float3 euler)
{
return
transform_rotate(euler.x, make_float3(1.0f, 0.0f, 0.0f)) *
@@ -224,33 +224,33 @@ __device_inline Transform transform_euler(float3 euler)
transform_rotate(euler.z, make_float3(0.0f, 0.0f, 1.0f));
}
-__device_inline Transform transform_orthographic(float znear, float zfar)
+ccl_device_inline Transform transform_orthographic(float znear, float zfar)
{
return transform_scale(1.0f, 1.0f, 1.0f / (zfar-znear)) *
transform_translate(0.0f, 0.0f, -znear);
}
-__device_inline Transform transform_identity()
+ccl_device_inline Transform transform_identity()
{
return transform_scale(1.0f, 1.0f, 1.0f);
}
-__device_inline bool operator==(const Transform& A, const Transform& B)
+ccl_device_inline bool operator==(const Transform& A, const Transform& B)
{
return memcmp(&A, &B, sizeof(Transform)) == 0;
}
-__device_inline bool operator!=(const Transform& A, const Transform& B)
+ccl_device_inline bool operator!=(const Transform& A, const Transform& B)
{
return !(A == B);
}
-__device_inline float3 transform_get_column(const Transform *t, int column)
+ccl_device_inline float3 transform_get_column(const Transform *t, int column)
{
return make_float3(t->x[column], t->y[column], t->z[column]);
}
-__device_inline void transform_set_column(Transform *t, int column, float3 value)
+ccl_device_inline void transform_set_column(Transform *t, int column, float3 value)
{
t->x[column] = value.x;
t->y[column] = value.y;
@@ -259,7 +259,7 @@ __device_inline void transform_set_column(Transform *t, int column, float3 value
Transform transform_inverse(const Transform& a);
-__device_inline bool transform_uniform_scale(const Transform& tfm, float& scale)
+ccl_device_inline bool transform_uniform_scale(const Transform& tfm, float& scale)
{
/* the epsilon here is quite arbitrary, but this function is only used for
* surface area and bump, where we except it to not be so sensitive */
@@ -283,7 +283,7 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale)
return false;
}
-__device_inline bool transform_negative_scale(const Transform& tfm)
+ccl_device_inline bool transform_negative_scale(const Transform& tfm)
{
float3 c0 = transform_get_column(&tfm, 0);
float3 c1 = transform_get_column(&tfm, 1);
@@ -292,7 +292,7 @@ __device_inline bool transform_negative_scale(const Transform& tfm)
return (dot(cross(c0, c1), c2) < 0.0f);
}
-__device_inline Transform transform_clear_scale(const Transform& tfm)
+ccl_device_inline Transform transform_clear_scale(const Transform& tfm)
{
Transform ntfm = tfm;
@@ -307,7 +307,7 @@ __device_inline Transform transform_clear_scale(const Transform& tfm)
/* Motion Transform */
-__device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
+ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
{
/* use simpe nlerp instead of slerp. it's faster and almost the same */
return normalize((1.0f - t)*q1 + t*q2);
@@ -333,7 +333,7 @@ __device_inline float4 quat_interpolate(float4 q1, float4 q2, float t)
#endif
}
-__device_inline Transform transform_quick_inverse(Transform M)
+ccl_device_inline Transform transform_quick_inverse(Transform M)
{
/* possible optimization: can we avoid doing this altogether and construct
* the inverse matrix directly from negated translation, transposed rotation,
@@ -356,7 +356,7 @@ __device_inline Transform transform_quick_inverse(Transform M)
return R;
}
-__device_inline void transform_compose(Transform *tfm, const Transform *decomp)
+ccl_device_inline void transform_compose(Transform *tfm, const Transform *decomp)
{
/* rotation */
float q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc;
@@ -395,7 +395,7 @@ __device_inline void transform_compose(Transform *tfm, const Transform *decomp)
/* Disabled for now, need arc-length parametrization for constant speed motion.
* #define CURVED_MOTION_INTERPOLATE */
-__device void transform_motion_interpolate(Transform *tfm, const DecompMotionTransform *motion, float t)
+ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionTransform *motion, float t)
{
/* possible optimization: is it worth it adding a check to skip scaling?
* it's probably quite uncommon to have scaling objects. or can we skip
@@ -447,7 +447,7 @@ __device void transform_motion_interpolate(Transform *tfm, const DecompMotionTra
#ifndef __KERNEL_GPU__
-__device_inline bool operator==(const MotionTransform& A, const MotionTransform& B)
+ccl_device_inline bool operator==(const MotionTransform& A, const MotionTransform& B)
{
return (A.pre == B.pre && A.post == B.post);
}
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index a8f514864db..3fa1df6ab44 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -23,38 +23,40 @@
#endif
+/* Bitness */
+
+#if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_X64)
+#define __KERNEL_64_BIT__
+#endif
+
/* Qualifiers for kernel code shared by CPU and GPU */
#ifndef __KERNEL_GPU__
-#define __device static inline
-#define __device_noinline static
-#define __global
-#define __local
-#define __shared
-#define __constant
+#define ccl_device static inline
+#define ccl_device_noinline static
+#define ccl_global
+#define ccl_constant
#if defined(_WIN32) && !defined(FREE_WINDOWS)
-#define __device_inline static __forceinline
-#define __align(...) __declspec(align(__VA_ARGS__))
-#define __may_alias
+#define ccl_device_inline static __forceinline
+#ifdef __KERNEL_64_BIT__
+#define ccl_align(...) __declspec(align(__VA_ARGS__))
+#else
+#define ccl_align(...) /* not support for function arguments (error C2719) */
+#endif
+#define ccl_may_alias
#else
-#define __device_inline static inline __attribute__((always_inline))
+#define ccl_device_inline static inline __attribute__((always_inline))
#ifndef FREE_WINDOWS64
#define __forceinline inline __attribute__((always_inline))
#endif
-#define __align(...) __attribute__((aligned(__VA_ARGS__)))
-#define __may_alias __attribute__((__may_alias__))
+#define ccl_align(...) __attribute__((aligned(__VA_ARGS__)))
+#define ccl_may_alias __attribute__((__may_alias__))
#endif
#endif
-/* Bitness */
-
-#if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_X64)
-#define __KERNEL_64_BIT__
-#endif
-
/* SIMD Types */
#ifndef __KERNEL_GPU__
@@ -97,6 +99,10 @@
#include <tmmintrin.h> /* SSSE 3 */
#endif
+#ifdef __KERNEL_SSE41__
+#include <smmintrin.h> /* SSE 4.1 */
+#endif
+
#else
/* MinGW64 has conflicting declarations for these SSE headers in <windows.h>.
@@ -190,7 +196,7 @@ struct int2 {
};
#ifdef __KERNEL_SSE__
-struct __align(16) int3 {
+struct ccl_align(16) int3 {
union {
__m128i m128;
struct { int x, y, z, w; };
@@ -201,7 +207,7 @@ struct __align(16) int3 {
__forceinline operator const __m128i&(void) const { return m128; }
__forceinline operator __m128i&(void) { return m128; }
#else
-struct int3 {
+struct ccl_align(16) int3 {
int x, y, z, w;
#endif
@@ -210,7 +216,7 @@ struct int3 {
};
#ifdef __KERNEL_SSE__
-struct __align(16) int4 {
+struct ccl_align(16) int4 {
union {
__m128i m128;
struct { int x, y, z, w; };
@@ -221,7 +227,7 @@ struct __align(16) int4 {
__forceinline operator const __m128i&(void) const { return m128; }
__forceinline operator __m128i&(void) { return m128; }
#else
-struct int4 {
+struct ccl_align(16) int4 {
int x, y, z, w;
#endif
@@ -258,7 +264,7 @@ struct float2 {
};
#ifdef __KERNEL_SSE__
-struct __align(16) float3 {
+struct ccl_align(16) float3 {
union {
__m128 m128;
struct { float x, y, z, w; };
@@ -269,7 +275,7 @@ struct __align(16) float3 {
__forceinline operator const __m128&(void) const { return m128; }
__forceinline operator __m128&(void) { return m128; }
#else
-struct float3 {
+struct ccl_align(16) float3 {
float x, y, z, w;
#endif
@@ -278,7 +284,7 @@ struct float3 {
};
#ifdef __KERNEL_SSE__
-struct __align(16) float4 {
+struct ccl_align(16) float4 {
union {
__m128 m128;
struct { float x, y, z, w; };
@@ -289,7 +295,7 @@ struct __align(16) float4 {
__forceinline operator const __m128&(void) const { return m128; }
__forceinline operator __m128&(void) { return m128; }
#else
-struct float4 {
+struct ccl_align(16) float4 {
float x, y, z, w;
#endif
@@ -305,31 +311,31 @@ struct float4 {
*
* OpenCL does not support C++ class, so we use these instead. */
-__device_inline uchar2 make_uchar2(uchar x, uchar y)
+ccl_device_inline uchar2 make_uchar2(uchar x, uchar y)
{
uchar2 a = {x, y};
return a;
}
-__device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z)
+ccl_device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z)
{
uchar3 a = {x, y, z};
return a;
}
-__device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w)
+ccl_device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w)
{
uchar4 a = {x, y, z, w};
return a;
}
-__device_inline int2 make_int2(int x, int y)
+ccl_device_inline int2 make_int2(int x, int y)
{
int2 a = {x, y};
return a;
}
-__device_inline int3 make_int3(int x, int y, int z)
+ccl_device_inline int3 make_int3(int x, int y, int z)
{
#ifdef __KERNEL_SSE__
int3 a;
@@ -341,7 +347,7 @@ __device_inline int3 make_int3(int x, int y, int z)
return a;
}
-__device_inline int4 make_int4(int x, int y, int z, int w)
+ccl_device_inline int4 make_int4(int x, int y, int z, int w)
{
#ifdef __KERNEL_SSE__
int4 a;
@@ -353,31 +359,31 @@ __device_inline int4 make_int4(int x, int y, int z, int w)
return a;
}
-__device_inline uint2 make_uint2(uint x, uint y)
+ccl_device_inline uint2 make_uint2(uint x, uint y)
{
uint2 a = {x, y};
return a;
}
-__device_inline uint3 make_uint3(uint x, uint y, uint z)
+ccl_device_inline uint3 make_uint3(uint x, uint y, uint z)
{
uint3 a = {x, y, z};
return a;
}
-__device_inline uint4 make_uint4(uint x, uint y, uint z, uint w)
+ccl_device_inline uint4 make_uint4(uint x, uint y, uint z, uint w)
{
uint4 a = {x, y, z, w};
return a;
}
-__device_inline float2 make_float2(float x, float y)
+ccl_device_inline float2 make_float2(float x, float y)
{
float2 a = {x, y};
return a;
}
-__device_inline float3 make_float3(float x, float y, float z)
+ccl_device_inline float3 make_float3(float x, float y, float z)
{
#ifdef __KERNEL_SSE__
float3 a;
@@ -389,7 +395,7 @@ __device_inline float3 make_float3(float x, float y, float z)
return a;
}
-__device_inline float4 make_float4(float x, float y, float z, float w)
+ccl_device_inline float4 make_float4(float x, float y, float z, float w)
{
#ifdef __KERNEL_SSE__
float4 a;
@@ -401,12 +407,12 @@ __device_inline float4 make_float4(float x, float y, float z, float w)
return a;
}
-__device_inline int align_up(int offset, int alignment)
+ccl_device_inline int align_up(int offset, int alignment)
{
return (offset + alignment - 1) & ~(alignment - 1);
}
-__device_inline int3 make_int3(int i)
+ccl_device_inline int3 make_int3(int i)
{
#ifdef __KERNEL_SSE__
int3 a;
@@ -418,7 +424,7 @@ __device_inline int3 make_int3(int i)
return a;
}
-__device_inline int4 make_int4(int i)
+ccl_device_inline int4 make_int4(int i)
{
#ifdef __KERNEL_SSE__
int4 a;
@@ -430,7 +436,7 @@ __device_inline int4 make_int4(int i)
return a;
}
-__device_inline float3 make_float3(float f)
+ccl_device_inline float3 make_float3(float f)
{
#ifdef __KERNEL_SSE__
float3 a;
@@ -442,7 +448,7 @@ __device_inline float3 make_float3(float f)
return a;
}
-__device_inline float4 make_float4(float f)
+ccl_device_inline float4 make_float4(float f)
{
#ifdef __KERNEL_SSE__
float4 a;
@@ -454,7 +460,7 @@ __device_inline float4 make_float4(float f)
return a;
}
-__device_inline float4 make_float4(const int4& i)
+ccl_device_inline float4 make_float4(const int4& i)
{
#ifdef __KERNEL_SSE__
float4 a;
@@ -466,7 +472,7 @@ __device_inline float4 make_float4(const int4& i)
return a;
}
-__device_inline int4 make_int4(const float3& f)
+ccl_device_inline int4 make_int4(const float3& f)
{
#ifdef __KERNEL_SSE__
int4 a;
@@ -489,17 +495,17 @@ __device_inline int4 make_int4(const float3& f)
/* faster version for SSSE3 */
typedef __m128i shuffle_swap_t;
-__device_inline const shuffle_swap_t shuffle_swap_identity(void)
+ccl_device_inline const shuffle_swap_t shuffle_swap_identity(void)
{
return _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
}
-__device_inline const shuffle_swap_t shuffle_swap_swap(void)
+ccl_device_inline const shuffle_swap_t shuffle_swap_swap(void)
{
return _mm_set_epi8(7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8);
}
-__device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t& shuf)
+ccl_device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t& shuf)
{
return _mm_castsi128_ps(_mm_shuffle_epi8(_mm_castps_si128(a), shuf));
}
@@ -509,17 +515,17 @@ __device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t&
/* somewhat slower version for SSE2 */
typedef int shuffle_swap_t;
-__device_inline const shuffle_swap_t shuffle_swap_identity(void)
+ccl_device_inline const shuffle_swap_t shuffle_swap_identity(void)
{
return 0;
}
-__device_inline const shuffle_swap_t shuffle_swap_swap(void)
+ccl_device_inline const shuffle_swap_t shuffle_swap_swap(void)
{
return 1;
}
-__device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf)
+ccl_device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf)
{
/* shuffle value must be a constant, so we need to branch */
if(shuf)
@@ -530,12 +536,12 @@ __device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf)
#endif
-template<size_t i0, size_t i1, size_t i2, size_t i3> __device_inline const __m128 shuffle(const __m128& a, const __m128& b)
+template<size_t i0, size_t i1, size_t i2, size_t i3> ccl_device_inline const __m128 shuffle(const __m128& a, const __m128& b)
{
return _mm_shuffle_ps(a, b, _MM_SHUFFLE(i3, i2, i1, i0));
}
-template<size_t i0, size_t i1, size_t i2, size_t i3> __device_inline const __m128 shuffle(const __m128& b)
+template<size_t i0, size_t i1, size_t i2, size_t i3> ccl_device_inline const __m128 shuffle(const __m128& b)
{
return _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(b), _MM_SHUFFLE(i3, i2, i1, i0)));
}
@@ -554,7 +560,7 @@ struct half4 { half x, y, z, w; };
#ifdef __KERNEL_CUDA__
-__device_inline void float4_store_half(half *h, const float4 *f, float scale)
+ccl_device_inline void float4_store_half(half *h, const float4 *f, float scale)
{
h[0] = __float2half_rn(f->x * scale);
h[1] = __float2half_rn(f->y * scale);
@@ -564,7 +570,7 @@ __device_inline void float4_store_half(half *h, const float4 *f, float scale)
#else
-__device_inline void float4_store_half(half *h, const float4 *f, float scale)
+ccl_device_inline void float4_store_half(half *h, const float4 *f, float scale)
{
#ifndef __KERNEL_SSE2__
for(int i = 0; i < 4; i++) {
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
index 3b0180fd71a..459bee48e0e 100644
--- a/intern/ffmpeg/ffmpeg_compat.h
+++ b/intern/ffmpeg/ffmpeg_compat.h
@@ -2,7 +2,7 @@
* compatibility macros to make every ffmpeg installation appear
* like the most current installation (wrapping some functionality sometimes)
* it also includes all ffmpeg header files at once, no need to do it
- * seperately.
+ * separately.
*
* Copyright (c) 2011 Peter Schlaile
*
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 3873bae1eea..beca24fc5e9 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -44,7 +44,6 @@ set(SRC
intern/GHOST_ISystemPaths.cpp
intern/GHOST_ModifierKeys.cpp
intern/GHOST_Path-api.cpp
- intern/GHOST_Path-api.cpp
intern/GHOST_Rect.cpp
intern/GHOST_System.cpp
intern/GHOST_TimerManager.cpp
@@ -132,17 +131,10 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
# ack, this is still system dependant
if(APPLE)
- if(WITH_COCOA)
- list(APPEND SRC
- intern/GHOST_SystemPathsCocoa.mm
- intern/GHOST_SystemPathsCocoa.h
- )
- else()
- list(APPEND SRC
- intern/GHOST_SystemPathsCarbon.cpp
- intern/GHOST_SystemPathsCarbon.h
- )
- endif()
+ list(APPEND SRC
+ intern/GHOST_SystemPathsCocoa.mm
+ intern/GHOST_SystemPathsCocoa.h
+ )
elseif(UNIX)
list(APPEND SRC
@@ -173,41 +165,26 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
endif()
elseif(APPLE)
- if(WITH_COCOA)
- list(APPEND SRC
- intern/GHOST_DisplayManagerCocoa.mm
- intern/GHOST_SystemCocoa.mm
- intern/GHOST_SystemPathsCocoa.mm
- intern/GHOST_WindowCocoa.mm
-
- intern/GHOST_DisplayManagerCocoa.h
- intern/GHOST_SystemCocoa.h
- intern/GHOST_SystemPathsCocoa.h
- intern/GHOST_WindowCocoa.h
- )
-
- if(WITH_INPUT_NDOF)
- list(APPEND SRC
- intern/GHOST_NDOFManagerCocoa.mm
- intern/GHOST_NDOFManagerCocoa.h
- )
- list(APPEND SRC_NDOF3DCONNEXION
- intern/GHOST_NDOFManager3Dconnexion.c
- intern/GHOST_NDOFManager3Dconnexion.h
- )
- endif()
+ list(APPEND SRC
+ intern/GHOST_DisplayManagerCocoa.mm
+ intern/GHOST_SystemCocoa.mm
+ intern/GHOST_SystemPathsCocoa.mm
+ intern/GHOST_WindowCocoa.mm
+
+ intern/GHOST_DisplayManagerCocoa.h
+ intern/GHOST_SystemCocoa.h
+ intern/GHOST_SystemPathsCocoa.h
+ intern/GHOST_WindowCocoa.h
+ )
- else()
+ if(WITH_INPUT_NDOF)
list(APPEND SRC
- intern/GHOST_DisplayManagerCarbon.cpp
- intern/GHOST_SystemCarbon.cpp
- intern/GHOST_SystemPathsCarbon.cpp
- intern/GHOST_WindowCarbon.cpp
-
- intern/GHOST_DisplayManagerCarbon.h
- intern/GHOST_SystemCarbon.h
- intern/GHOST_SystemPathsCarbon.h
- intern/GHOST_WindowCarbon.h
+ intern/GHOST_NDOFManagerCocoa.mm
+ intern/GHOST_NDOFManagerCocoa.h
+ )
+ list(APPEND SRC_NDOF3DCONNEXION
+ intern/GHOST_NDOFManager3Dconnexion.c
+ intern/GHOST_NDOFManager3Dconnexion.h
)
endif()
@@ -324,6 +301,6 @@ add_definitions(-DGLEW_STATIC)
blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}")
# workaround for apple clang mangling extern "C" symbols
-if(WITH_INPUT_NDOF AND WITH_COCOA)
+if(WITH_INPUT_NDOF AND APPLE)
blender_add_lib(bf_intern_ghostndof3dconnexion "${SRC_NDOF3DCONNEXION}" "${INC}" "${INC_SYS}")
endif()
diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript
index fed8cd7aa3c..df4efe60a11 100644
--- a/intern/ghost/SConscript
+++ b/intern/ghost/SConscript
@@ -55,7 +55,6 @@ incs += ' ' + env['BF_OPENGL_INC']
if env['WITH_GHOST_SDL']:
for f in pf:
try:
- sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'Win32.cpp')
sources.remove('intern' + os.sep + f + 'X11.cpp')
except ValueError:
@@ -66,7 +65,6 @@ elif window_system in ('linux', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'f
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'Win32.cpp')
- sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
@@ -94,34 +92,19 @@ elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'X11.cpp')
- sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
elif window_system == 'darwin':
- if env['WITH_GHOST_COCOA']:
- if env['WITH_BF_QUICKTIME']:
- defs.append('WITH_QUICKTIME')
- if env['USE_QTKIT']:
- defs.append('USE_QTKIT')
- for f in pf:
- try:
- sources.remove('intern' + os.sep + f + 'Win32.cpp')
- sources.remove('intern' + os.sep + f + 'X11.cpp')
- sources.remove('intern' + os.sep + f + 'Carbon.cpp')
- sources.remove('intern' + os.sep + f + 'SDL.cpp')
- except ValueError:
- pass
- else:
- for f in pf:
- try:
- sources.remove('intern' + os.sep + f + 'Win32.cpp')
- sources.remove('intern' + os.sep + f + 'X11.cpp')
- sources.remove('intern' + os.sep + f + 'Cocoa.mm')
- sources.remove('intern' + os.sep + f + 'SDL.cpp')
- except ValueError:
- pass
-
+ if env['WITH_BF_QUICKTIME']:
+ defs.append('WITH_QUICKTIME')
+ for f in pf:
+ try:
+ sources.remove('intern' + os.sep + f + 'Win32.cpp')
+ sources.remove('intern' + os.sep + f + 'X11.cpp')
+ sources.remove('intern' + os.sep + f + 'SDL.cpp')
+ except ValueError:
+ pass
else:
print "Unknown window system specified."
Exit()
@@ -155,7 +138,7 @@ if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-v
if window_system in ('win32-vc', 'win64-vc'):
env.BlenderLib ('bf_intern_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15]) #, cc_compileflags=env['CCFLAGS'].append('/WX') )
-elif env['WITH_GHOST_COCOA']: # always use default-Apple-gcc for objC language, for gnu-compilers do not support it fully yet
+elif window_system == 'darwin': # always use default-Apple-gcc for objC language, for gnu-compilers do not support it fully yet
env.BlenderLib ('bf_intern_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15], cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++' )
print "GHOST COCOA WILL BE COMPILED WITH APPLE GCC"
if env['WITH_BF_3DMOUSE']:
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp b/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp
deleted file mode 100644
index 25e9123dae6..00000000000
--- a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_DisplayManagerCarbon.cpp
- * \ingroup GHOST
- */
-
-
-/**
- * Copyright (C) 2001 NaN Technologies B.V.
- * \author Maarten Gribnau
- * \date September 21, 2001
- */
-
-#include "GHOST_DisplayManagerCarbon.h"
-#include "GHOST_Debug.h"
-
-// We do not support multiple monitors at the moment
-
-
-GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(void)
-{
- if (::CGGetActiveDisplayList(0, NULL, &m_numDisplays) != CGDisplayNoErr)
- {
- m_numDisplays = 0;
- m_displayIDs = NULL;
- }
- if (m_numDisplays > 0)
- {
- m_displayIDs = new CGDirectDisplayID[m_numDisplays];
- GHOST_ASSERT((m_displayIDs != NULL), "GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(): memory allocation failed");
- ::CGGetActiveDisplayList(m_numDisplays, m_displayIDs, &m_numDisplays);
- }
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplays(GHOST_TUns8& numDisplays) const
-{
- numDisplays = (GHOST_TUns8) m_numDisplays;
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const
-{
- GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getNumDisplaySettings(): only main display is supported");
-
- CFArrayRef displayModes;
- displayModes = ::CGDisplayAvailableModes(m_displayIDs[display]);
- CFIndex numModes = ::CFArrayGetCount(displayModes);
- numSettings = (GHOST_TInt32)numModes;
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const
-{
- GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getDisplaySetting(): only main display is supported");
-
- CFArrayRef displayModes;
- CGDirectDisplayID d = m_displayIDs[display];
- displayModes = ::CGDisplayAvailableModes(d);
- //CFIndex numModes = ::CFArrayGetCount(displayModes);/*unused*/
- //GHOST_TInt32 numSettings = (GHOST_TInt32)numModes; /*unused*/
- CFDictionaryRef displayModeValues = (CFDictionaryRef) ::CFArrayGetValueAtIndex(displayModes, index);
-
- setting.xPixels = getValue(displayModeValues, kCGDisplayWidth);
- setting.yPixels = getValue(displayModeValues, kCGDisplayHeight);
- setting.bpp = getValue(displayModeValues, kCGDisplayBitsPerPixel);
- setting.frequency = getValue(displayModeValues, kCGDisplayRefreshRate);
-
-#ifdef GHOST_DEBUG
- printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
-#endif // GHOST_DEBUG
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const
-{
- GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(): only main display is supported");
-
- CFDictionaryRef displayModeValues = ::CGDisplayCurrentMode(m_displayIDs[display]);
-
- setting.xPixels = getValue(displayModeValues, kCGDisplayWidth);
- setting.yPixels = getValue(displayModeValues, kCGDisplayHeight);
- setting.bpp = getValue(displayModeValues, kCGDisplayBitsPerPixel);
- setting.frequency = getValue(displayModeValues, kCGDisplayRefreshRate);
-
-#ifdef GHOST_DEBUG
- printf("current display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
-#endif // GHOST_DEBUG
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting)
-{
- GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): only main display is supported");
-
-#ifdef GHOST_DEBUG
- printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): requested settings:\n");
- printf(" setting.xPixels=%d\n", setting.xPixels);
- printf(" setting.yPixels=%d\n", setting.yPixels);
- printf(" setting.bpp=%d\n", setting.bpp);
- printf(" setting.frequency=%d\n", setting.frequency);
-#endif // GHOST_DEBUG
-
- CFDictionaryRef displayModeValues = ::CGDisplayBestModeForParametersAndRefreshRate(
- m_displayIDs[display],
- (size_t)setting.bpp,
- (size_t)setting.xPixels,
- (size_t)setting.yPixels,
- (CGRefreshRate)setting.frequency,
- NULL);
-
-#ifdef GHOST_DEBUG
- printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): switching to:\n");
- printf(" setting.xPixels=%d\n", getValue(displayModeValues, kCGDisplayWidth));
- printf(" setting.yPixels=%d\n", getValue(displayModeValues, kCGDisplayHeight));
- printf(" setting.bpp=%d\n", getValue(displayModeValues, kCGDisplayBitsPerPixel));
- printf(" setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate));
-#endif // GHOST_DEBUG
-
- CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
-
- return err == CGDisplayNoErr ? GHOST_kSuccess : GHOST_kFailure;
-}
-
-
-long GHOST_DisplayManagerCarbon::getValue(CFDictionaryRef values, CFStringRef key) const
-{
- CFNumberRef numberValue = (CFNumberRef) CFDictionaryGetValue(values, key);
-
- if (!numberValue)
- {
- return -1;
- }
-
- long intValue;
-
- if (!CFNumberGetValue(numberValue, kCFNumberLongType, &intValue))
- {
- return -1;
- }
-
- return intValue;
-}
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.h b/intern/ghost/intern/GHOST_DisplayManagerCarbon.h
deleted file mode 100644
index 1ac6540b7bd..00000000000
--- a/intern/ghost/intern/GHOST_DisplayManagerCarbon.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_DisplayManagerCarbon.h
- * \ingroup GHOST
- * Declaration of GHOST_DisplayManagerCarbon class.
- */
-
-#ifndef __GHOST_DISPLAYMANAGERCARBON_H__
-#define __GHOST_DISPLAYMANAGERCARBON_H__
-
-#ifndef __APPLE__
-#error Apple only!
-#endif // __APPLE__
-
-#include "GHOST_DisplayManager.h"
-
-#define __CARBONSOUND__
-#include <Carbon/Carbon.h>
-
-/**
- * Manages system displays (Mac OSX/Carbon implementation).
- * \see GHOST_DisplayManager
- * \author Maarten Gribnau
- * \date September 21, 2001
- */
-class GHOST_DisplayManagerCarbon : public GHOST_DisplayManager
-{
-public:
- /**
- * Constructor.
- */
- GHOST_DisplayManagerCarbon(void);
-
- /**
- * Returns the number of display devices on this system.
- * \param numDisplays The number of displays on this system.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getNumDisplays(GHOST_TUns8& numDisplays) const;
-
- /**
- * Returns the number of display settings for this display device.
- * \param display The index of the display to query with 0 <= display < getNumDisplays().
- * \param setting The number of settings of the display device with this index.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const;
-
- /**
- * Returns the current setting for this display device.
- * \param display The index of the display to query with 0 <= display < getNumDisplays().
- * \param index The setting index to be returned.
- * \param setting The setting of the display device with this index.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const;
-
- /**
- * Returns the current setting for this display device.
- * \param display The index of the display to query with 0 <= display < getNumDisplays().
- * \param setting The current setting of the display device with this index.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const;
-
- /**
- * Changes the current setting for this display device.
- * \param display The index of the display to query with 0 <= display < getNumDisplays().
- * \param setting The current setting of the display device with this index.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting);
-
-protected:
- /**
- * Returns a value from a dictionary.
- * \param values Dictionary to return value from.
- * \param key Key to return value for.
- * \return The value for this key.
- */
- long getValue(CFDictionaryRef values, CFStringRef key) const;
-
- /** Cached number of displays. */
- CGDisplayCount m_numDisplays;
- /** Cached display id's for each display. */
- CGDirectDisplayID *m_displayIDs;
-};
-
-
-#endif // __GHOST_DISPLAYMANAGERCARBON_H__
-
diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp
index f6973caad03..009753cb29e 100644
--- a/intern/ghost/intern/GHOST_ISystem.cpp
+++ b/intern/ghost/intern/GHOST_ISystem.cpp
@@ -46,11 +46,7 @@
# include "GHOST_SystemWin32.h"
#else
# ifdef __APPLE__
-# ifdef GHOST_COCOA
-# include "GHOST_SystemCocoa.h"
-# else
-# include "GHOST_SystemCarbon.h"
-# endif
+# include "GHOST_SystemCocoa.h"
# else
# include "GHOST_SystemX11.h"
# endif
@@ -72,11 +68,7 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
m_system = new GHOST_SystemWin32();
#else
# ifdef __APPLE__
-# ifdef GHOST_COCOA
m_system = new GHOST_SystemCocoa();
-# else
- m_system = new GHOST_SystemCarbon();
-# endif
# else
m_system = new GHOST_SystemX11();
# endif
diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp
index ae9a8e49057..581467fb666 100644
--- a/intern/ghost/intern/GHOST_ISystemPaths.cpp
+++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp
@@ -42,11 +42,7 @@
# include "GHOST_SystemPathsWin32.h"
#else
# ifdef __APPLE__
-# ifdef GHOST_COCOA
# include "GHOST_SystemPathsCocoa.h"
-# else
-# include "GHOST_SystemPathsCarbon.h"
-# endif
# else
# include "GHOST_SystemPathsX11.h"
# endif
@@ -64,11 +60,7 @@ GHOST_TSuccess GHOST_ISystemPaths::create()
m_systemPaths = new GHOST_SystemPathsWin32();
#else
# ifdef __APPLE__
-# ifdef GHOST_COCOA
m_systemPaths = new GHOST_SystemPathsCocoa();
-# else
- m_systemPaths = new GHOST_SystemPathsCarbon();
-# endif
# else
m_systemPaths = new GHOST_SystemPathsX11();
# endif
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp
deleted file mode 100644
index 6e72e26beb4..00000000000
--- a/intern/ghost/intern/GHOST_SystemCarbon.cpp
+++ /dev/null
@@ -1,1241 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_SystemCarbon.cpp
- * \ingroup GHOST
- */
-
-
-/**
- * Copyright (C) 2001 NaN Technologies B.V.
- * \author Maarten Gribnau
- * \date May 7, 2001
- */
-
-#include <Carbon/Carbon.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include "GHOST_SystemCarbon.h"
-
-#include "GHOST_DisplayManagerCarbon.h"
-#include "GHOST_EventKey.h"
-#include "GHOST_EventButton.h"
-#include "GHOST_EventCursor.h"
-#include "GHOST_EventWheel.h"
-#ifdef WITH_INPUT_NDOF
-#include "GHOST_EventNDOF.h"
-#endif
-
-#include "GHOST_TimerManager.h"
-#include "GHOST_TimerTask.h"
-#include "GHOST_WindowManager.h"
-#include "GHOST_WindowCarbon.h"
-#include "GHOST_NDOFManager.h"
-#include "AssertMacros.h"
-
-/* blender class and types events */
-enum {
- kEventClassBlender = 'blnd'
-};
-
-enum {
- kEventBlenderNdofAxis = 1,
- kEventBlenderNdofButtons = 2
-};
-
-const EventTypeSpec kEvents[] =
-{
- { kEventClassAppleEvent, kEventAppleEvent },
-#if 0
- { kEventClassApplication, kEventAppActivated },
- { kEventClassApplication, kEventAppDeactivated },
- #endif
- { kEventClassKeyboard, kEventRawKeyDown },
- { kEventClassKeyboard, kEventRawKeyRepeat },
- { kEventClassKeyboard, kEventRawKeyUp },
- { kEventClassKeyboard, kEventRawKeyModifiersChanged },
-
- { kEventClassMouse, kEventMouseDown },
- { kEventClassMouse, kEventMouseUp },
- { kEventClassMouse, kEventMouseMoved },
- { kEventClassMouse, kEventMouseDragged },
- { kEventClassMouse, kEventMouseWheelMoved },
-
- { kEventClassWindow, kEventWindowClickZoomRgn }, /* for new zoom behaviour */
- { kEventClassWindow, kEventWindowZoom }, /* for new zoom behaviour */
- { kEventClassWindow, kEventWindowExpand }, /* for new zoom behaviour */
- { kEventClassWindow, kEventWindowExpandAll }, /* for new zoom behaviour */
-
- { kEventClassWindow, kEventWindowClose },
- { kEventClassWindow, kEventWindowActivated },
- { kEventClassWindow, kEventWindowDeactivated },
- { kEventClassWindow, kEventWindowUpdate },
- { kEventClassWindow, kEventWindowBoundsChanged },
-
- { kEventClassBlender, kEventBlenderNdofAxis },
- { kEventClassBlender, kEventBlenderNdofButtons }
-
-
-
-};
-
-
-
-static GHOST_TButtonMask convertButton(EventMouseButton button)
-{
- switch (button) {
- case kEventMouseButtonPrimary:
- return GHOST_kButtonMaskLeft;
- case kEventMouseButtonSecondary:
- return GHOST_kButtonMaskRight;
- case kEventMouseButtonTertiary:
- default:
- return GHOST_kButtonMaskMiddle;
- }
-}
-
-static GHOST_TKey convertKey(int rawCode)
-{
- /* This bit of magic converts the rawCode into a virtual
- * Mac key based on the current keyboard mapping, but
- * without regard to the modifiers (so we don't get 'a'
- * and 'A' for example.
- */
- static UInt32 dummy = 0;
- Handle transData = (Handle) GetScriptManagerVariable(smKCHRCache);
- unsigned char vk = KeyTranslate(transData, rawCode, &dummy);
- /* Map numpad based on rawcodes first, otherwise they
- * look like non-numpad events.
- * Added too: mapping the number keys, for french keyboards etc (ton)
- */
- // printf("GHOST: vk: %d %c raw: %d\n", vk, vk, rawCode);
-
- switch (rawCode) {
- case 18: return GHOST_kKey1;
- case 19: return GHOST_kKey2;
- case 20: return GHOST_kKey3;
- case 21: return GHOST_kKey4;
- case 23: return GHOST_kKey5;
- case 22: return GHOST_kKey6;
- case 26: return GHOST_kKey7;
- case 28: return GHOST_kKey8;
- case 25: return GHOST_kKey9;
- case 29: return GHOST_kKey0;
-
- case 82: return GHOST_kKeyNumpad0;
- case 83: return GHOST_kKeyNumpad1;
- case 84: return GHOST_kKeyNumpad2;
- case 85: return GHOST_kKeyNumpad3;
- case 86: return GHOST_kKeyNumpad4;
- case 87: return GHOST_kKeyNumpad5;
- case 88: return GHOST_kKeyNumpad6;
- case 89: return GHOST_kKeyNumpad7;
- case 91: return GHOST_kKeyNumpad8;
- case 92: return GHOST_kKeyNumpad9;
- case 65: return GHOST_kKeyNumpadPeriod;
- case 76: return GHOST_kKeyNumpadEnter;
- case 69: return GHOST_kKeyNumpadPlus;
- case 78: return GHOST_kKeyNumpadMinus;
- case 67: return GHOST_kKeyNumpadAsterisk;
- case 75: return GHOST_kKeyNumpadSlash;
- }
-
- if ((vk >= 'a') && (vk <= 'z')) {
- return (GHOST_TKey) (vk - 'a' + GHOST_kKeyA);
- }
- else if ((vk >= '0') && (vk <= '9')) {
- return (GHOST_TKey) (vk - '0' + GHOST_kKey0);
- }
- else if (vk == 16) {
- switch (rawCode) {
- case 122: return GHOST_kKeyF1;
- case 120: return GHOST_kKeyF2;
- case 99: return GHOST_kKeyF3;
- case 118: return GHOST_kKeyF4;
- case 96: return GHOST_kKeyF5;
- case 97: return GHOST_kKeyF6;
- case 98: return GHOST_kKeyF7;
- case 100: return GHOST_kKeyF8;
- case 101: return GHOST_kKeyF9;
- case 109: return GHOST_kKeyF10;
- case 103: return GHOST_kKeyF11;
- case 111: return GHOST_kKeyF12; // Never get, is used for ejecting the CD!
- }
- }
- else {
- switch (vk) {
- case kUpArrowCharCode: return GHOST_kKeyUpArrow;
- case kDownArrowCharCode: return GHOST_kKeyDownArrow;
- case kLeftArrowCharCode: return GHOST_kKeyLeftArrow;
- case kRightArrowCharCode: return GHOST_kKeyRightArrow;
-
- case kReturnCharCode: return GHOST_kKeyEnter;
- case kBackspaceCharCode: return GHOST_kKeyBackSpace;
- case kDeleteCharCode: return GHOST_kKeyDelete;
- case kEscapeCharCode: return GHOST_kKeyEsc;
- case kTabCharCode: return GHOST_kKeyTab;
- case kSpaceCharCode: return GHOST_kKeySpace;
-
- case kHomeCharCode: return GHOST_kKeyHome;
- case kEndCharCode: return GHOST_kKeyEnd;
- case kPageUpCharCode: return GHOST_kKeyUpPage;
- case kPageDownCharCode: return GHOST_kKeyDownPage;
-
- case '-': return GHOST_kKeyMinus;
- case '=': return GHOST_kKeyEqual;
- case ',': return GHOST_kKeyComma;
- case '.': return GHOST_kKeyPeriod;
- case '/': return GHOST_kKeySlash;
- case ';': return GHOST_kKeySemicolon;
- case '\'': return GHOST_kKeyQuote;
- case '\\': return GHOST_kKeyBackslash;
- case '[': return GHOST_kKeyLeftBracket;
- case ']': return GHOST_kKeyRightBracket;
- case '`': return GHOST_kKeyAccentGrave;
- }
- }
-
- // printf("GHOST: unknown key: %d %d\n", vk, rawCode);
-
- return GHOST_kKeyUnknown;
-}
-
-/* MacOSX returns a Roman charset with kEventParamKeyMacCharCodes
- * as defined here: http://developer.apple.com/documentation/mac/Text/Text-516.html
- * I am not sure how international this works...
- * For cross-platform convention, we'll use the Latin ascii set instead.
- * As defined at: http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html
- *
- */
-static unsigned char convertRomanToLatin(unsigned char ascii)
-{
-
- if (ascii < 128) return ascii;
-
- switch (ascii) {
- case 128: return 142;
- case 129: return 143;
- case 130: return 128;
- case 131: return 201;
- case 132: return 209;
- case 133: return 214;
- case 134: return 220;
- case 135: return 225;
- case 136: return 224;
- case 137: return 226;
- case 138: return 228;
- case 139: return 227;
- case 140: return 229;
- case 141: return 231;
- case 142: return 233;
- case 143: return 232;
- case 144: return 234;
- case 145: return 235;
- case 146: return 237;
- case 147: return 236;
- case 148: return 238;
- case 149: return 239;
- case 150: return 241;
- case 151: return 243;
- case 152: return 242;
- case 153: return 244;
- case 154: return 246;
- case 155: return 245;
- case 156: return 250;
- case 157: return 249;
- case 158: return 251;
- case 159: return 252;
- case 160: return 0;
- case 161: return 176;
- case 162: return 162;
- case 163: return 163;
- case 164: return 167;
- case 165: return 183;
- case 166: return 182;
- case 167: return 223;
- case 168: return 174;
- case 169: return 169;
- case 170: return 174;
- case 171: return 180;
- case 172: return 168;
- case 173: return 0;
- case 174: return 198;
- case 175: return 216;
- case 176: return 0;
- case 177: return 177;
- case 178: return 0;
- case 179: return 0;
- case 180: return 165;
- case 181: return 181;
- case 182: return 0;
- case 183: return 0;
- case 184: return 215;
- case 185: return 0;
- case 186: return 0;
- case 187: return 170;
- case 188: return 186;
- case 189: return 0;
- case 190: return 230;
- case 191: return 248;
- case 192: return 191;
- case 193: return 161;
- case 194: return 172;
- case 195: return 0;
- case 196: return 0;
- case 197: return 0;
- case 198: return 0;
- case 199: return 171;
- case 200: return 187;
- case 201: return 201;
- case 202: return 0;
- case 203: return 192;
- case 204: return 195;
- case 205: return 213;
- case 206: return 0;
- case 207: return 0;
- case 208: return 0;
- case 209: return 0;
- case 210: return 0;
-
- case 214: return 247;
-
- case 229: return 194;
- case 230: return 202;
- case 231: return 193;
- case 232: return 203;
- case 233: return 200;
- case 234: return 205;
- case 235: return 206;
- case 236: return 207;
- case 237: return 204;
- case 238: return 211;
- case 239: return 212;
- case 240: return 0;
- case 241: return 210;
- case 242: return 218;
- case 243: return 219;
- case 244: return 217;
- case 245: return 0;
- case 246: return 0;
- case 247: return 0;
- case 248: return 0;
- case 249: return 0;
- case 250: return 0;
-
-
- default: return 0;
- }
-
-}
-
-
-/***/
-
-GHOST_SystemCarbon::GHOST_SystemCarbon() :
- m_modifierMask(0)
-{
- m_displayManager = new GHOST_DisplayManagerCarbon();
- GHOST_ASSERT(m_displayManager, "GHOST_SystemCarbon::GHOST_SystemCarbon(): m_displayManager==0\n");
- m_displayManager->initialize();
-
- UnsignedWide micros;
- ::Microseconds(&micros);
- m_start_time = UnsignedWideToUInt64(micros) / 1000;
- m_ignoreWindowSizedMessages = false;
-}
-
-GHOST_SystemCarbon::~GHOST_SystemCarbon()
-{
-}
-
-
-GHOST_TUns64 GHOST_SystemCarbon::getMilliSeconds() const
-{
- UnsignedWide micros;
- ::Microseconds(&micros);
- UInt64 millis;
- millis = UnsignedWideToUInt64(micros);
- return (millis / 1000) - m_start_time;
-}
-
-GHOST_TUns8 GHOST_SystemCarbon::getNumDisplays() const
-{
- // We do not support multiple monitors at the moment
- return 1;
-}
-
-
-void GHOST_SystemCarbon::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
-{
- BitMap screenBits;
- Rect bnds = GetQDGlobalsScreenBits(&screenBits)->bounds;
- width = bnds.right - bnds.left;
- height = bnds.bottom - bnds.top;
-}
-
-void GHOST_SystemCarbon::getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
-{
- /* TODO */
- getMainDisplayDimensions(width, height);
-}
-
-GHOST_IWindow *GHOST_SystemCarbon::createWindow(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type,
- bool stereoVisual,
- const bool exclusive,
- const GHOST_TUns16 numOfAASamples,
- const GHOST_TEmbedderWindowID parentWindow)
-{
- GHOST_IWindow *window = 0;
-
- window = new GHOST_WindowCarbon(title, left, top, width, height, state, type);
-
- if (window) {
- if (window->getValid()) {
- // Store the pointer to the window
- GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
- m_windowManager->addWindow(window);
- m_windowManager->setActiveWindow(window);
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
- }
- else {
- GHOST_PRINT("GHOST_SystemCarbon::createWindow(): window invalid\n");
- delete window;
- window = 0;
- }
- }
- else {
- GHOST_PRINT("GHOST_SystemCarbon::createWindow(): could not create window\n");
- }
- return window;
-}
-
-GHOST_TSuccess GHOST_SystemCarbon::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow **window, const bool stereoVisual)
-{
- GHOST_TSuccess success = GHOST_kFailure;
-
- // need yo make this Carbon all on 10.5 for fullscreen to work correctly
- CGCaptureAllDisplays();
-
- success = GHOST_System::beginFullScreen(setting, window, stereoVisual);
-
- if (success != GHOST_kSuccess) {
- // fullscreen failed for other reasons, release
- CGReleaseAllDisplays();
- }
-
- return success;
-}
-
-GHOST_TSuccess GHOST_SystemCarbon::endFullScreen(void)
-{
- CGReleaseAllDisplays();
- return GHOST_System::endFullScreen();
-}
-
-/* this is an old style low level event queue.
- * As we want to handle our own timers, this is ok.
- * the full screen hack should be removed */
-bool GHOST_SystemCarbon::processEvents(bool waitForEvent)
-{
- bool anyProcessed = false;
- EventRef event;
-
-// SetMouseCoalescingEnabled(false, NULL);
-
- do {
- GHOST_TimerManager *timerMgr = getTimerManager();
-
- if (waitForEvent) {
- GHOST_TUns64 next = timerMgr->nextFireTime();
- double timeOut;
-
- if (next == GHOST_kFireTimeNever) {
- timeOut = kEventDurationForever;
- }
- else {
- timeOut = (double)(next - getMilliSeconds()) / 1000.0;
- if (timeOut < 0.0)
- timeOut = 0.0;
- }
-
- ::ReceiveNextEvent(0, NULL, timeOut, false, &event);
- }
-
- if (timerMgr->fireTimers(getMilliSeconds())) {
- anyProcessed = true;
- }
-
- if (getFullScreen()) {
- // Check if the full-screen window is dirty
- GHOST_IWindow *window = m_windowManager->getFullScreenWindow();
- if (((GHOST_WindowCarbon *)window)->getFullScreenDirty()) {
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
- anyProcessed = true;
- }
- }
-
- /* end loop when no more events available */
- while (::ReceiveNextEvent(0, NULL, 0, true, &event) == noErr) {
- OSStatus status = ::SendEventToEventTarget(event, ::GetEventDispatcherTarget());
- if (status == noErr) {
- anyProcessed = true;
- }
- else {
- UInt32 i = ::GetEventClass(event);
-
- /* Ignore 'cgs ' class, no documentation on what they
- * are, but we get a lot of them
- */
- if (i != 'cgs ') {
- if (i != 'tblt') { // tablet event. we use the one packaged in the mouse event
- ; //printf("Missed - Class: '%.4s', Kind: %d\n", &i, ::GetEventKind(event));
- }
- }
- }
- ::ReleaseEvent(event);
- }
- } while (waitForEvent && !anyProcessed);
-
- return anyProcessed;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const
-{
- Point mouseLoc;
- // Get the position of the mouse in the active port
- ::GetGlobalMouse(&mouseLoc);
- // Convert the coordinates to screen coordinates
- x = (GHOST_TInt32)mouseLoc.h;
- y = (GHOST_TInt32)mouseLoc.v;
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
-{
- float xf = (float)x, yf = (float)y;
-
- CGAssociateMouseAndMouseCursorPosition(false);
- CGSetLocalEventsSuppressionInterval(0);
- CGWarpMouseCursorPosition(CGPointMake(xf, yf));
- CGAssociateMouseAndMouseCursorPosition(true);
-
-//this doesn't work properly, see game engine mouse-look scripts
-// CGWarpMouseCursorPosition(CGPointMake(xf, yf));
- // this call below sends event, but empties other events (like shift)
- // CGPostMouseEvent(CGPointMake(xf, yf), TRUE, 1, FALSE, 0);
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::getModifierKeys(GHOST_ModifierKeys& keys) const
-{
- UInt32 modifiers = ::GetCurrentKeyModifiers();
-
- keys.set(GHOST_kModifierKeyOS, (modifiers & cmdKey) ? true : false);
- keys.set(GHOST_kModifierKeyLeftAlt, (modifiers & optionKey) ? true : false);
- keys.set(GHOST_kModifierKeyLeftShift, (modifiers & shiftKey) ? true : false);
- keys.set(GHOST_kModifierKeyLeftControl, (modifiers & controlKey) ? true : false);
-
- return GHOST_kSuccess;
-}
-
-/* XXX, incorrect for multibutton mice */
-GHOST_TSuccess GHOST_SystemCarbon::getButtons(GHOST_Buttons& buttons) const
-{
- Boolean theOnlyButtonIsDown = ::Button();
- buttons.clear();
- buttons.set(GHOST_kButtonMaskLeft, theOnlyButtonIsDown);
- return GHOST_kSuccess;
-}
-
-#define FIRSTFILEBUFLG 512
-static bool g_hasFirstFile = false;
-static char g_firstFileBuf[512];
-
-extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
-{
- if (g_hasFirstFile) {
- strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
- buf[FIRSTFILEBUFLG - 1] = '\0';
- return 1;
- }
- else {
- return 0;
- }
-}
-
-OSErr GHOST_SystemCarbon::sAEHandlerLaunch(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
-{
- //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon;
-
- return noErr;
-}
-
-OSErr GHOST_SystemCarbon::sAEHandlerOpenDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
-{
- //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon;
- AEDescList docs;
- SInt32 ndocs;
- OSErr err;
-
- err = AEGetParamDesc(event, keyDirectObject, typeAEList, &docs);
- if (err != noErr) return err;
-
- err = AECountItems(&docs, &ndocs);
- if (err == noErr) {
- int i;
-
- for (i = 0; i < ndocs; i++) {
- FSSpec fss;
- AEKeyword kwd;
- DescType actType;
- Size actSize;
-
- err = AEGetNthPtr(&docs, i + 1, typeFSS, &kwd, &actType, &fss, sizeof(fss), &actSize);
- if (err != noErr)
- break;
-
- if (i == 0) {
- FSRef fsref;
-
- if (FSpMakeFSRef(&fss, &fsref) != noErr)
- break;
- if (FSRefMakePath(&fsref, (UInt8 *) g_firstFileBuf, sizeof(g_firstFileBuf)) != noErr)
- break;
-
- g_hasFirstFile = true;
- }
- }
- }
-
- AEDisposeDesc(&docs);
-
- return err;
-}
-
-OSErr GHOST_SystemCarbon::sAEHandlerPrintDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
-{
- //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon;
-
- return noErr;
-}
-
-OSErr GHOST_SystemCarbon::sAEHandlerQuit(const AppleEvent *event, AppleEvent *reply, SInt32 refCon)
-{
- GHOST_SystemCarbon *sys = (GHOST_SystemCarbon *) refCon;
-
- sys->pushEvent(new GHOST_Event(sys->getMilliSeconds(), GHOST_kEventQuit, NULL) );
-
- return noErr;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::init()
-{
-
- GHOST_TSuccess success = GHOST_System::init();
- if (success) {
- /*
- * Initialize the cursor to the standard arrow shape (so that we can change it later on).
- * This initializes the cursor's visibility counter to 0.
- */
- ::InitCursor();
-
- MenuRef windMenu;
- ::CreateStandardWindowMenu(0, &windMenu);
- ::InsertMenu(windMenu, 0);
- ::DrawMenuBar();
-
- ::InstallApplicationEventHandler(sEventHandlerProc, GetEventTypeCount(kEvents), kEvents, this, &m_handler);
-
- ::AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, sAEHandlerLaunch, (SInt32) this, false);
- ::AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, sAEHandlerOpenDocs, (SInt32) this, false);
- ::AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, sAEHandlerPrintDocs, (SInt32) this, false);
- ::AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, sAEHandlerQuit, (SInt32) this, false);
-
- }
- return success;
-}
-
-
-GHOST_TSuccess GHOST_SystemCarbon::exit()
-{
- return GHOST_System::exit();
-}
-
-
-OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
-{
- WindowRef windowRef;
- GHOST_WindowCarbon *window;
- OSStatus err = eventNotHandledErr;
-
- // Check if the event was send to a GHOST window
- ::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &windowRef);
- window = (GHOST_WindowCarbon *) ::GetWRefCon(windowRef);
- if (!validWindow(window)) {
- return err;
- }
-
- //if (!getFullScreen()) {
- err = noErr;
- switch (::GetEventKind(event))
- {
- case kEventWindowClose:
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) );
- break;
- case kEventWindowActivated:
- m_windowManager->setActiveWindow(window);
- window->loadCursor(window->getCursorVisibility(), window->getCursorShape());
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) );
- break;
- case kEventWindowDeactivated:
- m_windowManager->setWindowInactive(window);
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) );
- break;
- case kEventWindowUpdate:
- //if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n");
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
- break;
- case kEventWindowBoundsChanged:
- if (!m_ignoreWindowSizedMessages)
- {
- window->updateDrawingContext();
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
- }
- break;
- default:
- err = eventNotHandledErr;
- break;
- }
-// }
- //else {
- //window = (GHOST_WindowCarbon*) m_windowManager->getFullScreenWindow();
- //GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen window event, " << window << "\n");
- //::RemoveEventFromQueue(::GetMainEventQueue(), event);
- //}
-
- return err;
-}
-
-OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event)
-{
- GHOST_IWindow *window = m_windowManager->getActiveWindow();
- TabletPointRec tabletPointRecord;
- TabletProximityRec tabletProximityRecord;
- UInt32 anInt32;
- GHOST_TabletData& ct = ((GHOST_WindowCarbon *)window)->GetCarbonTabletData();
- OSStatus err = eventNotHandledErr;
-
- ct.Pressure = 0;
- ct.Xtilt = 0;
- ct.Ytilt = 0;
-
- // is there an embedded tablet event inside this mouse event?
- if (noErr == GetEventParameter(event, kEventParamTabletEventType, typeUInt32, NULL, sizeof(UInt32), NULL, (void *)&anInt32))
- {
- // yes there is one!
- // Embedded tablet events can either be a proximity or pointer event.
- if (anInt32 == kEventTabletPoint)
- {
- //GHOST_PRINT("Embedded pointer event!\n");
-
- // Extract the tablet Pointer Event. If there is no Tablet Pointer data
- // in this event, then this call will return an error. Just ignore the
- // error and go on. This can occur when a proximity event is embedded in
- // a mouse event and you did not check the mouse event to see which type
- // of tablet event was embedded.
- if (noErr == GetEventParameter(event, kEventParamTabletPointRec,
- typeTabletPointRec, NULL,
- sizeof(TabletPointRec),
- NULL, (void *)&tabletPointRecord))
- {
- ct.Pressure = tabletPointRecord.pressure / 65535.0f;
- ct.Xtilt = tabletPointRecord.tiltX / 32767.0f; /* can be positive or negative */
- ct.Ytilt = tabletPointRecord.tiltY / 32767.0f; /* can be positive or negative */
- }
- }
- else {
- //GHOST_PRINT("Embedded proximity event\n");
-
- // Extract the Tablet Proximity record from the event.
- if (noErr == GetEventParameter(event, kEventParamTabletProximityRec,
- typeTabletProximityRec, NULL,
- sizeof(TabletProximityRec),
- NULL, (void *)&tabletProximityRecord))
- {
- if (tabletProximityRecord.enterProximity) {
- //pointer is entering tablet area proximity
-
- switch (tabletProximityRecord.pointerType)
- {
- case 1: /* stylus */
- ct.Active = GHOST_kTabletModeStylus;
- break;
- case 2: /* puck, not supported so far */
- ct.Active = GHOST_kTabletModeNone;
- break;
- case 3: /* eraser */
- ct.Active = GHOST_kTabletModeEraser;
- break;
- default:
- ct.Active = GHOST_kTabletModeNone;
- break;
- }
- }
- else {
- // pointer is leaving - return to mouse
- ct.Active = GHOST_kTabletModeNone;
- }
- }
- }
- err = noErr;
- }
- return err;
-}
-
-OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event)
-{
- OSStatus err = eventNotHandledErr;
- GHOST_IWindow *window = m_windowManager->getActiveWindow();
- UInt32 kind = ::GetEventKind(event);
-
- switch (kind)
- {
- case kEventMouseDown:
- case kEventMouseUp:
- // Handle Mac application responsibilities
- if ((kind == kEventMouseDown) && handleMouseDown(event)) {
- err = noErr;
- }
- else {
- GHOST_TEventType type = (kind == kEventMouseDown) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp;
- EventMouseButton button;
-
- /* Window still gets mouse up after command-H */
- if (m_windowManager->getActiveWindow()) {
- // handle any tablet events that may have come with the mouse event (optional)
- handleTabletEvent(event);
-
- ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
- pushEvent(new GHOST_EventButton(getMilliSeconds(), type, window, convertButton(button)));
- err = noErr;
- }
- }
- break;
-
- case kEventMouseMoved:
- case kEventMouseDragged:
- {
- Point mousePos;
-
- if (window) {
- //handle any tablet events that may have come with the mouse event (optional)
- handleTabletEvent(event);
-
- ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
- pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v));
- err = noErr;
- }
- break;
- }
- case kEventMouseWheelMoved:
- {
- OSStatus status;
- //UInt32 modifiers;
- EventMouseWheelAxis axis;
- SInt32 delta;
- //status = ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers);
- //GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
- status = ::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis);
- GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
- if (axis == kEventMouseWheelAxisY)
- {
- status = ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta);
- GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
- /*
- * Limit mouse wheel delta to plus and minus one.
- */
- delta = delta > 0 ? 1 : -1;
- pushEvent(new GHOST_EventWheel(getMilliSeconds(), window, delta));
- err = noErr;
- }
- }
- break;
- }
-
- return err;
-}
-
-
-OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event)
-{
- OSStatus err = eventNotHandledErr;
- GHOST_IWindow *window = m_windowManager->getActiveWindow();
- UInt32 kind = ::GetEventKind(event);
- UInt32 modifiers;
- UInt32 rawCode;
- GHOST_TKey key;
- unsigned char ascii;
-
- /* Can happen, very rarely - seems to only be when command-H makes
- * the window go away and we still get an HKey up.
- */
- if (!window) {
- //::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode);
- //key = convertKey(rawCode);
- return err;
- }
-
- err = noErr;
- switch (kind) {
- case kEventRawKeyDown:
- case kEventRawKeyRepeat:
- case kEventRawKeyUp:
- ::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode);
- ::GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &ascii);
-
- key = convertKey(rawCode);
- ascii = convertRomanToLatin(ascii);
-
- // if (key!=GHOST_kKeyUnknown) {
- GHOST_TEventType type;
- if (kind == kEventRawKeyDown) {
- type = GHOST_kEventKeyDown;
- }
- else if (kind == kEventRawKeyRepeat) {
- type = GHOST_kEventKeyDown; /* XXX, fixme */
- }
- else {
- type = GHOST_kEventKeyUp;
- }
- pushEvent(new GHOST_EventKey(getMilliSeconds(), type, window, key, ascii, NULL) );
-// }
- break;
-
- case kEventRawKeyModifiersChanged:
- /* ugh */
- ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
- if ((modifiers & shiftKey) != (m_modifierMask & shiftKey)) {
- pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & shiftKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) );
- }
- if ((modifiers & controlKey) != (m_modifierMask & controlKey)) {
- pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & controlKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) );
- }
- if ((modifiers & optionKey) != (m_modifierMask & optionKey)) {
- pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & optionKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
- }
- if ((modifiers & cmdKey) != (m_modifierMask & cmdKey)) {
- pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyOS) );
- }
-
- m_modifierMask = modifiers;
- break;
-
- default:
- err = eventNotHandledErr;
- break;
- }
-
- return err;
-}
-
-
-bool GHOST_SystemCarbon::handleMouseDown(EventRef event)
-{
- WindowPtr window;
- short part;
- BitMap screenBits;
- bool handled = true;
- GHOST_WindowCarbon *ghostWindow;
- Point mousePos = {0, 0};
-
- ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
-
- part = ::FindWindow(mousePos, &window);
- ghostWindow = (GHOST_WindowCarbon *) ::GetWRefCon(window);
-
- switch (part) {
- case inMenuBar:
- handleMenuCommand(::MenuSelect(mousePos));
- break;
-
- case inDrag:
- /*
- * The DragWindow() routine creates a lot of kEventWindowBoundsChanged
- * events. By setting m_ignoreWindowSizedMessages these are suppressed.
- * \see GHOST_SystemCarbon::handleWindowEvent(EventRef event)
- */
- /* even worse: scale window also generates a load of events, and nothing
- * is handled (read: client's event proc called) until you release mouse (ton) */
-
- GHOST_ASSERT(validWindow(ghostWindow), "GHOST_SystemCarbon::handleMouseDown: invalid window");
- m_ignoreWindowSizedMessages = true;
- ::DragWindow(window, mousePos, &GetQDGlobalsScreenBits(&screenBits)->bounds);
- m_ignoreWindowSizedMessages = false;
-
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, ghostWindow) );
-
- break;
-
- case inContent:
- if (window != ::FrontWindow()) {
- ::SelectWindow(window);
- /*
- * We add a mouse down event on the newly actived window
- */
- //GHOST_PRINT("GHOST_SystemCarbon::handleMouseDown(): adding mouse down event, " << ghostWindow << "\n");
- EventMouseButton button;
- ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
- pushEvent(new GHOST_EventButton(getMilliSeconds(), GHOST_kEventButtonDown, ghostWindow, convertButton(button)));
- }
- else {
- handled = false;
- }
- break;
-
- case inGoAway:
- GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
- if (::TrackGoAway(window, mousePos))
- {
- // todo: add option-close, because it's in the HIG
- // if (event.modifiers & optionKey) {
- // Close the clean documents, others will be confirmed one by one.
- //}
- // else {
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, ghostWindow));
- //}
- }
- break;
-
- case inGrow:
- GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
- ::ResizeWindow(window, mousePos, NULL, NULL);
- break;
-
- case inZoomIn:
- case inZoomOut:
- GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
- if (::TrackBox(window, mousePos, part)) {
- int macState;
-
- macState = ghostWindow->getMac_windowState();
- if (macState == 0)
- ::ZoomWindow(window, part, true);
- else
- if (macState == 2) { // always ok
- ::ZoomWindow(window, part, true);
- ghostWindow->setMac_windowState(1);
- }
- else { // need to force size again
- // GHOST_TUns32 scr_x,scr_y; /*unused*/
- Rect outAvailableRect;
-
- ghostWindow->setMac_windowState(2);
- ::GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect);
-
- //this->getMainDisplayDimensions(scr_x,scr_y);
- ::SizeWindow(window, outAvailableRect.right - outAvailableRect.left, outAvailableRect.bottom - outAvailableRect.top - 1, false);
- ::MoveWindow(window, outAvailableRect.left, outAvailableRect.top, true);
- }
-
- }
- break;
-
- default:
- handled = false;
- break;
- }
-
- return handled;
-}
-
-
-bool GHOST_SystemCarbon::handleMenuCommand(GHOST_TInt32 menuResult)
-{
- short menuID;
- short menuItem;
- UInt32 command;
- bool handled;
- OSErr err;
-
- menuID = HiWord(menuResult);
- menuItem = LoWord(menuResult);
-
- err = ::GetMenuItemCommandID(::GetMenuHandle(menuID), menuItem, &command);
-
- handled = false;
-
- if (err || command == 0) {
- }
- else {
- switch (command) {
- }
- }
-
- ::HiliteMenu(0);
- return handled;
-}
-
-
-OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData)
-{
- GHOST_SystemCarbon *sys = (GHOST_SystemCarbon *) userData;
- OSStatus err = eventNotHandledErr;
- GHOST_IWindow *window;
-#ifdef WITH_INPUT_NDOF
- GHOST_TEventNDOFData data;
-#endif
- UInt32 kind;
-
- switch (::GetEventClass(event))
- {
- case kEventClassAppleEvent:
- EventRecord eventrec;
- if (ConvertEventRefToEventRecord(event, &eventrec)) {
- err = AEProcessAppleEvent(&eventrec);
- }
- break;
- case kEventClassMouse:
- err = sys->handleMouseEvent(event);
- break;
- case kEventClassWindow:
- err = sys->handleWindowEvent(event);
- break;
- case kEventClassKeyboard:
- err = sys->handleKeyEvent(event);
- break;
- case kEventClassBlender:
-#ifdef WITH_INPUT_NDOF
- window = sys->m_windowManager->getActiveWindow();
- sys->m_ndofManager->GHOST_NDOFGetDatas(data);
- kind = ::GetEventKind(event);
-
- switch (kind)
- {
- case 1:
- sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data));
- // printf("motion\n");
- break;
- case 2:
- sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFButton, window, data));
-// printf("button\n");
- break;
- }
-#endif
- err = noErr;
- break;
- default:
- ;
- break;
- }
-
- return err;
-}
-
-GHOST_TUns8 *GHOST_SystemCarbon::getClipboard(bool selection) const
-{
- PasteboardRef inPasteboard;
- PasteboardItemID itemID;
- CFDataRef flavorData;
- OSStatus err = noErr;
- GHOST_TUns8 *temp_buff;
- CFRange range;
- OSStatus syncFlags;
-
- err = PasteboardCreate(kPasteboardClipboard, &inPasteboard);
- if (err != noErr) { return NULL; }
-
- syncFlags = PasteboardSynchronize(inPasteboard);
- /* as we always get in a new string, we can safely ignore sync flags if not an error*/
- if (syncFlags < 0) { return NULL; }
-
-
- err = PasteboardGetItemIdentifier(inPasteboard, 1, &itemID);
- if (err != noErr) { return NULL; }
-
- err = PasteboardCopyItemFlavorData(inPasteboard, itemID, CFSTR("public.utf8-plain-text"), &flavorData);
- if (err != noErr) { return NULL; }
-
- range = CFRangeMake(0, CFDataGetLength(flavorData));
-
- temp_buff = (GHOST_TUns8 *) malloc(range.length + 1);
-
- CFDataGetBytes(flavorData, range, (UInt8 *)temp_buff);
-
- temp_buff[range.length] = '\0';
-
- if (temp_buff) {
- return temp_buff;
- }
- else {
- return NULL;
- }
-}
-
-void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const
-{
- if (selection) {return; } // for copying the selection, used on X11
-
- PasteboardRef inPasteboard;
- CFDataRef textData = NULL;
- OSStatus err = noErr; /*For error checking*/
- OSStatus syncFlags;
-
- err = PasteboardCreate(kPasteboardClipboard, &inPasteboard);
- if (err != noErr) { return; }
-
- syncFlags = PasteboardSynchronize(inPasteboard);
- /* as we always put in a new string, we can safely ignore sync flags */
- if (syncFlags < 0) { return; }
-
- err = PasteboardClear(inPasteboard);
- if (err != noErr) { return; }
-
- textData = CFDataCreate(kCFAllocatorDefault, (UInt8 *)buffer, strlen(buffer));
-
- if (textData) {
- err = PasteboardPutItemFlavor(inPasteboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), textData, 0);
- if (err != noErr) {
- if (textData) { CFRelease(textData); }
- return;
- }
- }
-
- if (textData) {
- CFRelease(textData);
- }
-}
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.h b/intern/ghost/intern/GHOST_SystemCarbon.h
deleted file mode 100644
index 9faf5423205..00000000000
--- a/intern/ghost/intern/GHOST_SystemCarbon.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_SystemCarbon.h
- * \ingroup GHOST
- * Declaration of GHOST_SystemCarbon class.
- */
-
-#ifndef __GHOST_SYSTEMCARBON_H__
-#define __GHOST_SYSTEMCARBON_H__
-
-#ifndef __APPLE__
-#error Apple OSX only!
-#endif // __APPLE__
-
-#define __CARBONSOUND__
-#include <Carbon/Carbon.h>
-
-#include "GHOST_System.h"
-
-class GHOST_EventCursor;
-class GHOST_EventKey;
-class GHOST_EventWindow;
-
-/**
- * OSX/Carbon Implementation of GHOST_System class.
- * \see GHOST_System.
- * \author Maarten Gribnau
- * \date May 21, 2001
- */
-class GHOST_SystemCarbon : public GHOST_System {
-public:
- /**
- * Constructor.
- */
- GHOST_SystemCarbon();
-
- /**
- * Destructor.
- */
- ~GHOST_SystemCarbon();
-
- /***************************************************************************************
- ** Time(r) functionality
- ***************************************************************************************/
-
- /**
- * Returns the system time.
- * Returns the number of milliseconds since the start of the system process.
- * Based on ANSI clock() routine.
- * \return The number of milliseconds.
- */
- virtual GHOST_TUns64 getMilliSeconds() const;
-
- /***************************************************************************************
- ** Display/window management functionality
- ***************************************************************************************/
-
- /**
- * Returns the number of displays on this system.
- * \return The number of displays.
- */
- virtual GHOST_TUns8 getNumDisplays() const;
-
- /**
- * Returns the dimensions of the main display on this system.
- * \return The dimension of the main display.
- */
- virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
-
- /**
- * Returns the combine dimensions of all monitors.
- * \return The dimension of the workspace.
- */
- virtual void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const;
-
- /**
- * Create a new window.
- * The new window is added to the list of windows managed.
- * Never explicitly delete the window, use disposeWindow() instead.
- * \param title The name of the window (displayed in the title bar of the window if the OS supports it).
- * \param left The coordinate of the left edge of the window.
- * \param top The coordinate of the top edge of the window.
- * \param width The width the window.
- * \param height The height the window.
- * \param state The state of the window when opened.
- * \param type The type of drawing context installed in this window.
- * \param parentWindow Parent (embedder) window
- * \return The new window (or 0 if creation failed).
- */
- virtual GHOST_IWindow *createWindow(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type,
- const bool stereoVisual,
- const bool exclusive = false,
- const GHOST_TUns16 numOfAASamples = 0,
- const GHOST_TEmbedderWindowID parentWindow = 0
- );
-
- virtual GHOST_TSuccess beginFullScreen(
- const GHOST_DisplaySetting& setting,
- GHOST_IWindow **window,
- const bool stereoVisual
- );
-
- virtual GHOST_TSuccess endFullScreen(void);
-
- /***************************************************************************************
- ** Event management functionality
- ***************************************************************************************/
-
- /**
- * Gets events from the system and stores them in the queue.
- * \param waitForEvent Flag to wait for an event (or return immediately).
- * \return Indication of the presence of events.
- */
- virtual bool processEvents(bool waitForEvent);
-
- /***************************************************************************************
- ** Cursor management functionality
- ***************************************************************************************/
-
- /**
- * Returns the current location of the cursor (location in screen coordinates)
- * \param x The x-coordinate of the cursor.
- * \param y The y-coordinate of the cursor.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const;
-
- /**
- * Updates the location of the cursor (location in screen coordinates).
- * \param x The x-coordinate of the cursor.
- * \param y The y-coordinate of the cursor.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y);
-
- /***************************************************************************************
- ** Access to mouse button and keyboard states.
- ***************************************************************************************/
-
- /**
- * Returns the state of all modifier keys.
- * \param keys The state of all modifier keys (true == pressed).
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys& keys) const;
-
- /**
- * Returns the state of the mouse buttons (ouside the message queue).
- * \param buttons The state of the buttons.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess getButtons(GHOST_Buttons& buttons) const;
-
- /**
- * Returns Clipboard data
- * \param selection Indicate which buffer to return
- * \return Returns the selected buffer
- */
- virtual GHOST_TUns8 *getClipboard(bool selection) const;
-
- /**
- * Puts buffer to system clipboard
- * \param buffer The buffer to be copied
- * \param selection Indicates which buffer to copy too, only used on X11
- */
- virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
-
- /**
- * \see GHOST_ISystem
- */
- int toggleConsole(int action) {
- return 0;
- }
-
-protected:
- /**
- * Initializes the system.
- * For now, it justs registers the window class (WNDCLASS).
- * \return A success value.
- */
- virtual GHOST_TSuccess init();
-
- /**
- * Closes the system down.
- * \return A success value.
- */
- virtual GHOST_TSuccess exit();
-
-
- /**
- * Handles a tablet event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- OSStatus handleTabletEvent(EventRef event);
- /**
- * Handles a mouse event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- OSStatus handleMouseEvent(EventRef event);
-
- /**
- * Handles a key event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- OSStatus handleKeyEvent(EventRef event);
-
- /**
- * Handles a window event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- OSStatus handleWindowEvent(EventRef event);
-
- /**
- * Handles all basic Mac application stuff for a mouse down event.
- * \param event A Mac event.
- * \return Indication whether the event was handled.
- */
- bool handleMouseDown(EventRef event);
-
- /**
- * Handles a Mac menu command.
- * \param menuResult A Mac menu/item identifier.
- * \return Indication whether the event was handled.
- */
- bool handleMenuCommand(GHOST_TInt32 menuResult);
-
- /* callback for blender generated events */
- // static OSStatus blendEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData);
-
-
- /**
- * Callback for Carbon when it has events.
- */
- static OSStatus sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData);
-
- /** Apple Event Handlers */
- static OSErr sAEHandlerLaunch(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
- static OSErr sAEHandlerOpenDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
- static OSErr sAEHandlerPrintDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
- static OSErr sAEHandlerQuit(const AppleEvent *event, AppleEvent *reply, SInt32 refCon);
-
- /**
- * Callback for Mac Timer tasks that expire.
- * \param tmTask Pointer to the timer task that expired.
- */
- //static void s_timerCallback(TMTaskPtr tmTask);
-
- /** Event handler reference. */
- EventHandlerRef m_handler;
-
- /** Start time at initialization. */
- GHOST_TUns64 m_start_time;
-
- /** State of the modifiers. */
- UInt32 m_modifierMask;
-
- /** Ignores window size messages (when window is dragged). */
- bool m_ignoreWindowSizedMessages;
-};
-
-#endif // __GHOST_SYSTEMCARBON_H__
-
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index fcf39523917..c60ded15d6c 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -57,156 +57,6 @@
#include "AssertMacros.h"
#pragma mark KeyMap, mouse converters
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040
-/* Keycodes not defined in Tiger */
-/*
- * Summary:
- * Virtual keycodes
- *
- * Discussion:
- * These constants are the virtual keycodes defined originally in
- * Inside Mac Volume V, pg. V-191. They identify physical keys on a
- * keyboard. Those constants with "ANSI" in the name are labeled
- * according to the key position on an ANSI-standard US keyboard.
- * For example, kVK_ANSI_A indicates the virtual keycode for the key
- * with the letter 'A' in the US keyboard layout. Other keyboard
- * layouts may have the 'A' key label on a different physical key;
- * in this case, pressing 'A' will generate a different virtual
- * keycode.
- */
-enum {
- kVK_ANSI_A = 0x00,
- kVK_ANSI_S = 0x01,
- kVK_ANSI_D = 0x02,
- kVK_ANSI_F = 0x03,
- kVK_ANSI_H = 0x04,
- kVK_ANSI_G = 0x05,
- kVK_ANSI_Z = 0x06,
- kVK_ANSI_X = 0x07,
- kVK_ANSI_C = 0x08,
- kVK_ANSI_V = 0x09,
- kVK_ANSI_B = 0x0B,
- kVK_ANSI_Q = 0x0C,
- kVK_ANSI_W = 0x0D,
- kVK_ANSI_E = 0x0E,
- kVK_ANSI_R = 0x0F,
- kVK_ANSI_Y = 0x10,
- kVK_ANSI_T = 0x11,
- kVK_ANSI_1 = 0x12,
- kVK_ANSI_2 = 0x13,
- kVK_ANSI_3 = 0x14,
- kVK_ANSI_4 = 0x15,
- kVK_ANSI_6 = 0x16,
- kVK_ANSI_5 = 0x17,
- kVK_ANSI_Equal = 0x18,
- kVK_ANSI_9 = 0x19,
- kVK_ANSI_7 = 0x1A,
- kVK_ANSI_Minus = 0x1B,
- kVK_ANSI_8 = 0x1C,
- kVK_ANSI_0 = 0x1D,
- kVK_ANSI_RightBracket = 0x1E,
- kVK_ANSI_O = 0x1F,
- kVK_ANSI_U = 0x20,
- kVK_ANSI_LeftBracket = 0x21,
- kVK_ANSI_I = 0x22,
- kVK_ANSI_P = 0x23,
- kVK_ANSI_L = 0x25,
- kVK_ANSI_J = 0x26,
- kVK_ANSI_Quote = 0x27,
- kVK_ANSI_K = 0x28,
- kVK_ANSI_Semicolon = 0x29,
- kVK_ANSI_Backslash = 0x2A,
- kVK_ANSI_Comma = 0x2B,
- kVK_ANSI_Slash = 0x2C,
- kVK_ANSI_N = 0x2D,
- kVK_ANSI_M = 0x2E,
- kVK_ANSI_Period = 0x2F,
- kVK_ANSI_Grave = 0x32,
- kVK_ANSI_KeypadDecimal = 0x41,
- kVK_ANSI_KeypadMultiply = 0x43,
- kVK_ANSI_KeypadPlus = 0x45,
- kVK_ANSI_KeypadClear = 0x47,
- kVK_ANSI_KeypadDivide = 0x4B,
- kVK_ANSI_KeypadEnter = 0x4C,
- kVK_ANSI_KeypadMinus = 0x4E,
- kVK_ANSI_KeypadEquals = 0x51,
- kVK_ANSI_Keypad0 = 0x52,
- kVK_ANSI_Keypad1 = 0x53,
- kVK_ANSI_Keypad2 = 0x54,
- kVK_ANSI_Keypad3 = 0x55,
- kVK_ANSI_Keypad4 = 0x56,
- kVK_ANSI_Keypad5 = 0x57,
- kVK_ANSI_Keypad6 = 0x58,
- kVK_ANSI_Keypad7 = 0x59,
- kVK_ANSI_Keypad8 = 0x5B,
- kVK_ANSI_Keypad9 = 0x5C
-};
-
-/* keycodes for keys that are independent of keyboard layout*/
-enum {
- kVK_Return = 0x24,
- kVK_Tab = 0x30,
- kVK_Space = 0x31,
- kVK_Delete = 0x33,
- kVK_Escape = 0x35,
- kVK_Command = 0x37,
- kVK_Shift = 0x38,
- kVK_CapsLock = 0x39,
- kVK_Option = 0x3A,
- kVK_Control = 0x3B,
- kVK_RightShift = 0x3C,
- kVK_RightOption = 0x3D,
- kVK_RightControl = 0x3E,
- kVK_Function = 0x3F,
- kVK_F17 = 0x40,
- kVK_VolumeUp = 0x48,
- kVK_VolumeDown = 0x49,
- kVK_Mute = 0x4A,
- kVK_F18 = 0x4F,
- kVK_F19 = 0x50,
- kVK_F20 = 0x5A,
- kVK_F5 = 0x60,
- kVK_F6 = 0x61,
- kVK_F7 = 0x62,
- kVK_F3 = 0x63,
- kVK_F8 = 0x64,
- kVK_F9 = 0x65,
- kVK_F11 = 0x67,
- kVK_F13 = 0x69,
- kVK_F16 = 0x6A,
- kVK_F14 = 0x6B,
- kVK_F10 = 0x6D,
- kVK_F12 = 0x6F,
- kVK_F15 = 0x71,
- kVK_Help = 0x72,
- kVK_Home = 0x73,
- kVK_PageUp = 0x74,
- kVK_ForwardDelete = 0x75,
- kVK_F4 = 0x76,
- kVK_End = 0x77,
- kVK_F2 = 0x78,
- kVK_PageDown = 0x79,
- kVK_F1 = 0x7A,
- kVK_LeftArrow = 0x7B,
- kVK_RightArrow = 0x7C,
- kVK_DownArrow = 0x7D,
- kVK_UpArrow = 0x7E
-};
-
-/* ISO keyboards only*/
-enum {
- kVK_ISO_Section = 0x0A
-};
-
-/* JIS keyboards only*/
-enum {
- kVK_JIS_Yen = 0x5D,
- kVK_JIS_Underscore = 0x5E,
- kVK_JIS_KeypadComma = 0x5F,
- kVK_JIS_Eisu = 0x66,
- kVK_JIS_Kana = 0x68
-};
-#endif
static GHOST_TButtonMask convertButton(int button)
{
@@ -361,47 +211,28 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
return (GHOST_TKey) (recvChar - 'a' + GHOST_kKeyA);
}
else {
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040
- KeyboardLayoutRef keyLayout;
- UCKeyboardLayout *uchrData;
-
- KLGetCurrentKeyboardLayout(&keyLayout);
- KLGetKeyboardLayoutProperty(keyLayout, kKLuchrData, (const void **)
- &uchrData);
- /*get actual character value of the "remappable" keys in int'l keyboards,
- if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
- then fallback on using the received charactersIgnoringModifiers */
- if (uchrData)
- {
- UInt32 deadKeyState=0;
- UniCharCount actualStrLength=0;
-
- UCKeyTranslate(uchrData, rawCode, keyAction, 0,
- LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar);
-
- }
-#else
- /* Leopard and Snow Leopard 64bit compatible API*/
- CFDataRef uchrHandle; /*the keyboard layout*/
- TISInputSourceRef kbdTISHandle;
+
+ /* Leopard and Snow Leopard 64bit compatible API*/
+ CFDataRef uchrHandle; /*the keyboard layout*/
+ TISInputSourceRef kbdTISHandle;
+
+ kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource();
+ uchrHandle = (CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData);
+ CFRelease(kbdTISHandle);
+
+ /*get actual character value of the "remappable" keys in int'l keyboards,
+ if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
+ then fallback on using the received charactersIgnoringModifiers */
+ if (uchrHandle)
+ {
+ UInt32 deadKeyState=0;
+ UniCharCount actualStrLength=0;
- kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource();
- uchrHandle = (CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData);
- CFRelease(kbdTISHandle);
+ UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode, keyAction, 0,
+ LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar);
- /*get actual character value of the "remappable" keys in int'l keyboards,
- if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger),
- then fallback on using the received charactersIgnoringModifiers */
- if (uchrHandle)
- {
- UInt32 deadKeyState=0;
- UniCharCount actualStrLength=0;
-
- UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode, keyAction, 0,
- LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar);
-
- }
-#endif
+ }
+
switch (recvChar) {
case '-': return GHOST_kKeyMinus;
case '=': return GHOST_kKeyEqual;
@@ -424,26 +255,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
#pragma mark defines for 10.6 api not documented in 10.5
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040
-enum {
- /* The following event types are available on some hardware on 10.5.2 and later */
- NSEventTypeGesture = 29,
- NSEventTypeMagnify = 30,
- NSEventTypeSwipe = 31,
- NSEventTypeRotate = 18,
- NSEventTypeBeginGesture = 19,
- NSEventTypeEndGesture = 20
-};
-
-@interface NSEvent(GestureEvents)
-- (float)magnification; // change in magnification.
-#else
-@interface NSEvent(GestureEvents)
-- (CGFloat)magnification; // change in magnification on 10.5.2 or later.
-@end
-
-#endif
-
#pragma mark Utility functions
@@ -464,29 +275,6 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
}
}
-#if defined(WITH_QUICKTIME) && !defined(USE_QTKIT)
-//Need to place this quicktime function in an ObjC file
-//It is used to avoid memory leak when raising the quicktime "compression settings" standard dialog
-extern "C" {
- struct bContext;
- struct wmOperator;
- extern int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op);
-
-
-int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
-{
- int result;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- result = fromcocoa_request_qtcodec_settings(C, op);
-
- [pool drain];
- return result;
-}
-};
-#endif
-
-
#pragma mark Cocoa objects
/**
@@ -517,7 +305,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
- //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be cancelled
+ //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be canceled
//Note that Cmd+Q is already handled by keyhandler
if (systemCocoa->handleQuitRequest() == GHOST_kExitNow)
return NSTerminateCancel;//NSTerminateNow;
@@ -525,7 +313,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
return NSTerminateCancel;
}
-// To avoid cancelling a log off process, we must use Cocoa termination process
+// To avoid canceling a log off process, we must use Cocoa termination process
// And this function is the only chance to perform clean up
// So WM_exit needs to be called directly, as the event loop will never run before termination
- (void)applicationWillTerminate:(NSNotification *)aNotification
diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp b/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp
deleted file mode 100644
index 7d43392a79c..00000000000
--- a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2009 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Damien Plisson 2010
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_SystemPathsCarbon.cpp
- * \ingroup GHOST
- */
-
-
-#include <Carbon/Carbon.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include "GHOST_SystemPathsCarbon.h"
-
-
-/***/
-
-GHOST_SystemPathsCarbon::GHOST_SystemPathsCarbon()
-{
-}
-
-GHOST_SystemPathsCarbon::~GHOST_SystemPathsCarbon()
-{
-}
-
-const GHOST_TUns8 *GHOST_SystemPathsCarbon::getSystemDir(int, const char *versionstr) const
-{
- static char systemPath[1024];
-
- snprintf(systemPath, sizeof(systemPath), "/Library/Application Support/Blender/%s", versionstr);
-
- return (GHOST_TUns8*)systemPath;
-}
-
-const GHOST_TUns8 *GHOST_SystemPathsCarbon::getUserDir(int, const char *versionstr) const
-{
- static char usrPath[1024];
- char *env = getenv("HOME");
-
- if (env) {
- snprintf(usrPath, sizeof(usrPath), "%s/Library/Application Support/Blender/%s", env, versionstr);
- return (GHOST_TUns8*)usrPath;
- }
- else
- return NULL;
-}
-
-const GHOST_TUns8 *GHOST_SystemPathsCarbon::getBinaryDir() const
-{
- CFURLRef bundleURL;
- CFStringRef pathStr;
- static char path[256];
- CFBundleRef mainBundle = CFBundleGetMainBundle();
-
- bundleURL = CFBundleCopyBundleURL(mainBundle);
- pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
- CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII);
- CFRelease(pathStr);
- CFRelease(bundleURL);
- return (GHOST_TUns8 *)path;
-}
-
-void GHOST_SystemPathsCarbon::addToSystemRecentFiles(const char *filename) const
-{
- /* XXXXX TODO: Implementation for Carbon if possible */
-
-}
diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.h b/intern/ghost/intern/GHOST_SystemPathsCarbon.h
deleted file mode 100644
index 9d9a3a22564..00000000000
--- a/intern/ghost/intern/GHOST_SystemPathsCarbon.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2010 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Damien Plisson 2010
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_SystemPathsCarbon.h
- * \ingroup GHOST
- */
-
-
-#ifndef __GHOST_SYSTEMPATHSCARBON_H__
-#define __GHOST_SYSTEMPATHSCARBON_H__
-
-#ifndef __APPLE__
-#error Apple OSX only!
-#endif // __APPLE__
-
-#include <Carbon/Carbon.h>
-
-#include "GHOST_SystemPaths.h"
-
-/**
- * OSX/Carbon Implementation of GHOST_SystemPaths class.
- * \see GHOST_System.
- * \author Andrea Weikert
- * \date Aug 1, 2010
- */
-class GHOST_SystemPathsCarbon : public GHOST_SystemPaths {
-public:
- /**
- * Constructor.
- */
- GHOST_SystemPathsCarbon();
-
- /**
- * Destructor.
- */
- ~GHOST_SystemPathsCarbon();
-
- /**
- * Determine the base dir in which shared resources are located. It will first try to use
- * "unpack and run" path, then look for properly installed path, including versioning.
- * \return Unsigned char string pointing to system dir (eg /usr/share/blender/).
- */
- virtual const GHOST_TUns8 *getSystemDir(int version, const char *versionstr) const;
-
- /**
- * Determine the base dir in which user configuration is stored, including versioning.
- * If needed, it will create the base directory.
- * \return Unsigned char string pointing to user dir (eg ~/.blender/).
- */
- virtual const GHOST_TUns8 *getUserDir(int version, const char *versionstr) const;
-
- /**
- * Determine the directory of the current binary
- * \return Unsigned char string pointing to the binary dir
- */
- virtual const GHOST_TUns8 *getBinaryDir() const;
-
- /**
- * Add the file to the operating system most recently used files
- */
- void addToSystemRecentFiles(const char *filename) const;
-};
-
-#endif // __GHOST_SYSTEMPATHSCARBON_H__
diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp
deleted file mode 100644
index 36d45b4790c..00000000000
--- a/intern/ghost/intern/GHOST_WindowCarbon.cpp
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_WindowCarbon.cpp
- * \ingroup GHOST
- */
-
-
-/**
- * Copyright (C) 2001 NaN Technologies B.V.
- * \author Maarten Gribnau
- * \date May 10, 2001
- */
-
-#include "GHOST_WindowCarbon.h"
-#include "GHOST_Debug.h"
-
-AGLContext GHOST_WindowCarbon::s_firstaglCtx = NULL;
-#ifdef GHOST_DRAW_CARBON_GUTTER
-const GHOST_TInt32 GHOST_WindowCarbon::s_sizeRectSize = 16;
-#endif //GHOST_DRAW_CARBON_GUTTER
-
-static const GLint sPreferredFormatWindow[10] = {
- AGL_RGBA,
- AGL_DOUBLEBUFFER,
- AGL_ACCELERATED,
- AGL_DEPTH_SIZE, 32,
- AGL_NONE,
-};
-
-static const GLint sPreferredFormatFullScreen[11] = {
- AGL_RGBA,
- AGL_DOUBLEBUFFER,
- AGL_ACCELERATED,
- AGL_FULLSCREEN,
- AGL_DEPTH_SIZE, 32,
- AGL_NONE,
-};
-
-
-
-WindowRef ugly_hack = NULL;
-
-const EventTypeSpec kWEvents[] = {
- { kEventClassWindow, kEventWindowZoom }, /* for new zoom behaviour */
-};
-
-static OSStatus myWEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData)
-{
- WindowRef mywindow;
- GHOST_WindowCarbon *ghost_window;
- OSStatus err;
- int theState;
-
- if (::GetEventKind(event) == kEventWindowZoom) {
- err = ::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(mywindow), NULL, &mywindow);
- ghost_window = (GHOST_WindowCarbon *) GetWRefCon(mywindow);
- theState = ghost_window->getMac_windowState();
- if (theState == 1)
- ghost_window->setMac_windowState(2);
- else if (theState == 2)
- ghost_window->setMac_windowState(1);
-
- }
- return eventNotHandledErr;
-}
-
-GHOST_WindowCarbon::GHOST_WindowCarbon(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type,
- const bool stereoVisual,
- const GHOST_TUns16 numOfAASamples
- ) :
- GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone),
- m_windowRef(0),
- m_grafPtr(0),
- m_aglCtx(0),
- m_customCursor(0),
- m_fullScreenDirty(false)
-{
- Str255 title255;
- OSStatus err;
-
- //fprintf(stderr," main screen top %i left %i height %i width %i\n", top, left, height, width);
-
- if (state >= GHOST_kWindowState8Normal) {
- if (state == GHOST_kWindowState8Normal) state = GHOST_kWindowStateNormal;
- else if (state == GHOST_kWindowState8Maximized) state = GHOST_kWindowStateMaximized;
- else if (state == GHOST_kWindowState8Minimized) state = GHOST_kWindowStateMinimized;
- else if (state == GHOST_kWindowState8FullScreen) state = GHOST_kWindowStateFullScreen;
-
- // state = state - 8; this was the simple version of above code, doesnt work in gcc 4.0
-
- setMac_windowState(1);
- }
- else
- setMac_windowState(0);
-
- if (state != GHOST_kWindowStateFullScreen) {
- Rect bnds = { top, left, top + height, left + width };
- // Boolean visible = (state == GHOST_kWindowStateNormal) || (state == GHOST_kWindowStateMaximized); /*unused*/
- gen2mac(title, title255);
-
- err = ::CreateNewWindow(kDocumentWindowClass,
- kWindowStandardDocumentAttributes + kWindowLiveResizeAttribute,
- &bnds,
- &m_windowRef);
-
- if (err != noErr) {
- fprintf(stderr, " error creating window %i \n", (int)err);
- }
- else {
-
- ::SetWRefCon(m_windowRef, (SInt32) this);
- setTitle(title);
- err = InstallWindowEventHandler(m_windowRef, myWEventHandlerProc, GetEventTypeCount(kWEvents), kWEvents, NULL, NULL);
- if (err != noErr) {
- fprintf(stderr, " error creating handler %i \n", (int)err);
- }
- else {
- // ::TransitionWindow (m_windowRef,kWindowZoomTransitionEffect,kWindowShowTransitionAction,NULL);
- ::ShowWindow(m_windowRef);
- ::MoveWindow(m_windowRef, left, top, true);
-
- }
- }
- if (m_windowRef) {
- m_grafPtr = ::GetWindowPort(m_windowRef);
- setDrawingContextType(type);
- updateDrawingContext();
- activateDrawingContext();
- }
- if (ugly_hack == NULL) {
- ugly_hack = m_windowRef;
- // when started from commandline, window remains in the back... also for play anim
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- SetFrontProcess(&psn);
- }
- }
- else {
-#if 0
- Rect bnds = { top, left, top + height, left + width };
- gen2mac("", title255);
- m_windowRef = ::NewCWindow(
- nil, // Storage
- &bnds, // Bounding rectangle of the window
- title255, // Title of the window
- 0, // Window initially visible
- plainDBox, // procID
- (WindowRef) - 1L, // Put window before all other windows
- 0, // Window has minimize box
- (SInt32) this); // Store a pointer to the class in the refCon
-#endif
- //GHOST_PRINT("GHOST_WindowCarbon::GHOST_WindowCarbon(): creating full-screen OpenGL context\n");
- setDrawingContextType(GHOST_kDrawingContextTypeOpenGL);
- installDrawingContext(GHOST_kDrawingContextTypeOpenGL);
- updateDrawingContext();
- activateDrawingContext();
-
- m_tablet.Active = GHOST_kTabletModeNone;
- }
-}
-
-
-GHOST_WindowCarbon::~GHOST_WindowCarbon()
-{
- if (m_customCursor) delete m_customCursor;
-
- if (ugly_hack == m_windowRef) ugly_hack = NULL;
-
- // printf("GHOST_WindowCarbon::~GHOST_WindowCarbon(): removing drawing context\n");
- if (ugly_hack == NULL) setDrawingContextType(GHOST_kDrawingContextTypeNone);
- if (m_windowRef) {
- ::DisposeWindow(m_windowRef);
- m_windowRef = 0;
- }
-}
-
-bool GHOST_WindowCarbon::getValid() const
-{
- bool valid;
- if (!m_fullScreen) {
- valid = (m_windowRef != 0) && (m_grafPtr != 0) && ::IsValidWindowPtr(m_windowRef);
- }
- else {
- valid = true;
- }
- return valid;
-}
-
-
-void GHOST_WindowCarbon::setTitle(const STR_String& title)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setTitle(): window invalid");
- Str255 title255;
- gen2mac(title, title255);
- ::SetWTitle(m_windowRef, title255);
-}
-
-
-void GHOST_WindowCarbon::getTitle(STR_String& title) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getTitle(): window invalid");
- Str255 title255;
- ::GetWTitle(m_windowRef, title255);
- mac2gen(title255, title);
-}
-
-
-void GHOST_WindowCarbon::getWindowBounds(GHOST_Rect& bounds) const
-{
- OSStatus success;
- Rect rect;
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getWindowBounds(): window invalid");
- success = ::GetWindowBounds(m_windowRef, kWindowStructureRgn, &rect);
- bounds.m_b = rect.bottom;
- bounds.m_l = rect.left;
- bounds.m_r = rect.right;
- bounds.m_t = rect.top;
-}
-
-
-void GHOST_WindowCarbon::getClientBounds(GHOST_Rect& bounds) const
-{
- Rect rect;
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getClientBounds(): window invalid");
- //::GetPortBounds(m_grafPtr, &rect);
- ::GetWindowBounds(m_windowRef, kWindowContentRgn, &rect);
-
- bounds.m_b = rect.bottom;
- bounds.m_l = rect.left;
- bounds.m_r = rect.right;
- bounds.m_t = rect.top;
-
- // Subtract gutter height from bottom
-#ifdef GHOST_DRAW_CARBON_GUTTER
- if ((bounds.m_b - bounds.m_t) > s_sizeRectSize)
- {
- bounds.m_b -= s_sizeRectSize;
- }
- else {
- bounds.m_t = bounds.m_b;
- }
-#endif //GHOST_DRAW_CARBON_GUTTER
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setClientWidth(GHOST_TUns32 width)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientWidth(): window invalid");
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
- if (((GHOST_TUns32)cBnds.getWidth()) != width) {
- ::SizeWindow(m_windowRef, width, cBnds.getHeight(), true);
- }
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setClientHeight(GHOST_TUns32 height)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientHeight(): window invalid");
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
-#ifdef GHOST_DRAW_CARBON_GUTTER
- if (((GHOST_TUns32)cBnds.getHeight()) != height + s_sizeRectSize) {
- ::SizeWindow(m_windowRef, cBnds.getWidth(), height + s_sizeRectSize, true);
- }
-#else //GHOST_DRAW_CARBON_GUTTER
- if (((GHOST_TUns32)cBnds.getHeight()) != height) {
- ::SizeWindow(m_windowRef, cBnds.getWidth(), height, true);
- }
-#endif //GHOST_DRAW_CARBON_GUTTER
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setClientSize(GHOST_TUns32 width, GHOST_TUns32 height)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientSize(): window invalid");
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
-#ifdef GHOST_DRAW_CARBON_GUTTER
- if ((((GHOST_TUns32)cBnds.getWidth()) != width) ||
- (((GHOST_TUns32)cBnds.getHeight()) != height + s_sizeRectSize))
- {
- ::SizeWindow(m_windowRef, width, height + s_sizeRectSize, true);
- }
-#else //GHOST_DRAW_CARBON_GUTTER
- if ((((GHOST_TUns32)cBnds.getWidth()) != width) ||
- (((GHOST_TUns32)cBnds.getHeight()) != height)) {
- ::SizeWindow(m_windowRef, width, height, true);
- }
-#endif //GHOST_DRAW_CARBON_GUTTER
- return GHOST_kSuccess;
-}
-
-
-GHOST_TWindowState GHOST_WindowCarbon::getState() const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getState(): window invalid");
- GHOST_TWindowState state;
- if (::IsWindowVisible(m_windowRef) == false) {
- state = GHOST_kWindowStateMinimized;
- }
- else if (::IsWindowInStandardState(m_windowRef, nil, nil)) {
- state = GHOST_kWindowStateMaximized;
- }
- else {
- state = GHOST_kWindowStateNormal;
- }
- return state;
-}
-
-
-void GHOST_WindowCarbon::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::screenToClient(): window invalid");
- Point point;
- point.h = inX;
- point.v = inY;
- GrafPtr oldPort;
- ::GetPort(&oldPort);
- ::SetPort(m_grafPtr);
- ::GlobalToLocal(&point);
- ::SetPort(oldPort);
- outX = point.h;
- outY = point.v;
-}
-
-
-void GHOST_WindowCarbon::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::clientToScreen(): window invalid");
- Point point;
- point.h = inX;
- point.v = inY;
- GrafPtr oldPort;
- ::GetPort(&oldPort);
- ::SetPort(m_grafPtr);
- ::LocalToGlobal(&point);
- ::SetPort(oldPort);
- outX = point.h;
- outY = point.v;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setState(GHOST_TWindowState state)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setState(): window invalid");
- switch (state) {
- case GHOST_kWindowStateMinimized:
- ::HideWindow(m_windowRef);
- break;
- case GHOST_kWindowStateModified:
- SetWindowModified(m_windowRef, 1);
- break;
- case GHOST_kWindowStateUnModified:
- SetWindowModified(m_windowRef, 0);
- break;
- case GHOST_kWindowStateMaximized:
- case GHOST_kWindowStateNormal:
- default:
- ::ShowWindow(m_windowRef);
- break;
- }
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setOrder(GHOST_TWindowOrder order)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setOrder(): window invalid");
- if (order == GHOST_kWindowOrderTop) {
- //::BringToFront(m_windowRef); is wrong, front window should be active for input too
- ::SelectWindow(m_windowRef);
- }
- else {
- /* doesnt work if you do this with a mouseclick */
- ::SendBehind(m_windowRef, nil);
- }
- return GHOST_kSuccess;
-}
-
-/*#define WAIT_FOR_VSYNC 1*/
-#ifdef WAIT_FOR_VSYNC
-#include <OpenGL/OpenGL.h>
-#endif
-
-GHOST_TSuccess GHOST_WindowCarbon::swapBuffers()
-{
-#ifdef WAIT_FOR_VSYNC
-/* wait for vsync, to avoid tearing artifacts */
- long VBL = 1;
- CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL);
-#endif
-
- GHOST_TSuccess succeeded = GHOST_kSuccess;
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_aglCtx) {
- ::aglSwapBuffers(m_aglCtx);
- }
- else {
- succeeded = GHOST_kFailure;
- }
- }
- return succeeded;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::updateDrawingContext()
-{
- GHOST_TSuccess succeeded = GHOST_kSuccess;
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_aglCtx) {
- ::aglUpdateContext(m_aglCtx);
- }
- else {
- succeeded = GHOST_kFailure;
- }
- }
- return succeeded;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::activateDrawingContext()
-{
- GHOST_TSuccess succeeded = GHOST_kSuccess;
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_aglCtx) {
- ::aglSetCurrentContext(m_aglCtx);
-#ifdef GHOST_DRAW_CARBON_GUTTER
- // Restrict drawing to non-gutter area
- ::aglEnable(m_aglCtx, AGL_BUFFER_RECT);
- GHOST_Rect bnds;
- getClientBounds(bnds);
- GLint b[4] =
- {
- bnds.m_l,
- bnds.m_t + s_sizeRectSize,
- bnds.m_r - bnds.m_l,
- bnds.m_b - bnds.m_t
- };
- GLboolean result = ::aglSetInteger(m_aglCtx, AGL_BUFFER_RECT, b);
-#endif //GHOST_DRAW_CARBON_GUTTER
- }
- else {
- succeeded = GHOST_kFailure;
- }
- }
- return succeeded;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::installDrawingContext(GHOST_TDrawingContextType type)
-{
- GHOST_TSuccess success = GHOST_kFailure;
- switch (type) {
- case GHOST_kDrawingContextTypeOpenGL:
- {
- if (!getValid()) break;
-
- AGLPixelFormat pixelFormat;
- if (!m_fullScreen) {
- pixelFormat = ::aglChoosePixelFormat(0, 0, sPreferredFormatWindow);
- m_aglCtx = ::aglCreateContext(pixelFormat, s_firstaglCtx);
- if (!m_aglCtx) break;
- if (!s_firstaglCtx) s_firstaglCtx = m_aglCtx;
- success = ::aglSetDrawable(m_aglCtx, m_grafPtr) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure;
- }
- else {
- //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL\n");
- GDHandle device = ::GetMainDevice(); pixelFormat = ::aglChoosePixelFormat(&device, 1, sPreferredFormatFullScreen);
- m_aglCtx = ::aglCreateContext(pixelFormat, 0);
- if (!m_aglCtx) break;
- if (!s_firstaglCtx) s_firstaglCtx = m_aglCtx;
- //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): created OpenGL context\n");
- //::CGGetActiveDisplayList(0, NULL, &m_numDisplays)
- success = ::aglSetFullScreen(m_aglCtx, m_fullScreenWidth, m_fullScreenHeight, 75, 0) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure;
-#if 0
- if (success == GHOST_kSuccess) {
- GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL succeeded\n");
- }
- else {
- GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL failed\n");
- }
-#endif
- }
- ::aglDestroyPixelFormat(pixelFormat);
- }
- break;
-
- case GHOST_kDrawingContextTypeNone:
- success = GHOST_kSuccess;
- break;
-
- default:
- break;
- }
- return success;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::removeDrawingContext()
-{
- GHOST_TSuccess success = GHOST_kFailure;
- switch (m_drawingContextType) {
- case GHOST_kDrawingContextTypeOpenGL:
- if (m_aglCtx) {
- aglSetCurrentContext(NULL);
- aglSetDrawable(m_aglCtx, NULL);
- //aglDestroyContext(m_aglCtx);
- if (s_firstaglCtx == m_aglCtx) s_firstaglCtx = NULL;
- success = ::aglDestroyContext(m_aglCtx) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure;
- m_aglCtx = 0;
- }
- break;
- case GHOST_kDrawingContextTypeNone:
- success = GHOST_kSuccess;
- break;
- default:
- break;
- }
- return success;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::invalidate()
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::invalidate(): window invalid");
- if (!m_fullScreen) {
- Rect rect;
- ::GetPortBounds(m_grafPtr, &rect);
- ::InvalWindowRect(m_windowRef, &rect);
- }
- else {
- //EventRef event;
- //OSStatus status = ::CreateEvent(NULL, kEventClassWindow, kEventWindowUpdate, 0, 0, &event);
- //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): created event " << status << " \n");
- //status = ::SetEventParameter(event, kEventParamDirectObject, typeWindowRef, sizeof(WindowRef), this);
- //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): set event parameter " << status << " \n");
- //status = ::PostEventToQueue(::GetMainEventQueue(), event, kEventPriorityStandard);
- //status = ::SendEventToEventTarget(event, ::GetApplicationEventTarget());
- //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): added event to queue " << status << " \n");
- m_fullScreenDirty = true;
- }
- return GHOST_kSuccess;
-}
-
-
-void GHOST_WindowCarbon::gen2mac(const STR_String& in, Str255 out) const
-{
- STR_String tempStr = in;
- int num = tempStr.Length();
- if (num > 255) num = 255;
- ::memcpy(out + 1, tempStr.Ptr(), num);
- out[0] = num;
-}
-
-
-void GHOST_WindowCarbon::mac2gen(const Str255 in, STR_String& out) const
-{
- char tmp[256];
- ::memcpy(tmp, in + 1, in[0]);
- tmp[in[0]] = '\0';
- out = tmp;
-}
-
-void GHOST_WindowCarbon::loadCursor(bool visible, GHOST_TStandardCursor cursor) const
-{
- static bool systemCursorVisible = true;
-
- if (visible != systemCursorVisible) {
- if (visible) {
- ::ShowCursor();
- systemCursorVisible = true;
- }
- else {
- ::HideCursor();
- systemCursorVisible = false;
- }
- }
-
- if (cursor == GHOST_kStandardCursorCustom && m_customCursor) {
- ::SetCursor(m_customCursor);
- }
- else {
- int carbon_cursor;
-
-#define GCMAP(ghostCursor, carbonCursor) case ghostCursor: carbon_cursor = carbonCursor; break
- switch (cursor) {
- default:
- GCMAP(GHOST_kStandardCursorDefault, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorRightArrow, kThemeAliasArrowCursor);
- GCMAP(GHOST_kStandardCursorLeftArrow, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorInfo, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorDestroy, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorHelp, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorCycle, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorSpray, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorWait, kThemeWatchCursor);
- GCMAP(GHOST_kStandardCursorText, kThemeIBeamCursor);
- GCMAP(GHOST_kStandardCursorCrosshair, kThemeCrossCursor);
- GCMAP(GHOST_kStandardCursorUpDown, kThemeClosedHandCursor);
- GCMAP(GHOST_kStandardCursorLeftRight, kThemeClosedHandCursor);
- GCMAP(GHOST_kStandardCursorTopSide, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorBottomSide, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorLeftSide, kThemeResizeLeftCursor);
- GCMAP(GHOST_kStandardCursorRightSide, kThemeResizeRightCursor);
- GCMAP(GHOST_kStandardCursorTopLeftCorner, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorTopRightCorner, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorBottomRightCorner, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorBottomLeftCorner, kThemeArrowCursor);
- GCMAP(GHOST_kStandardCursorCopy, kThemeCopyArrowCursor);
- };
-#undef GCMAP
-
- ::SetThemeCursor(carbon_cursor);
- }
-}
-
-
-bool GHOST_WindowCarbon::getFullScreenDirty()
-{
- return m_fullScreen && m_fullScreenDirty;
-}
-
-
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCursorVisibility(bool visible)
-{
- if (::FrontWindow() == m_windowRef) {
- loadCursor(visible, getCursorShape());
- }
-
- return GHOST_kSuccess;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCursorShape(GHOST_TStandardCursor shape)
-{
- if (m_customCursor) {
- delete m_customCursor;
- m_customCursor = 0;
- }
-
- if (::FrontWindow() == m_windowRef) {
- loadCursor(getCursorVisibility(), shape);
- }
-
- return GHOST_kSuccess;
-}
-
-#if 0 /* UNUSED */
-/** Reverse the bits in a GHOST_TUns8 */
-static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch)
-{
- ch = ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA);
- ch = ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC);
- ch = ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0);
- return ch;
-}
-#endif
-
-
-/** Reverse the bits in a GHOST_TUns16 */
-static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
-{
- shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA);
- shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC);
- shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0);
- shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00);
- return shrt;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
- int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color)
-{
- int y;
-
- if (m_customCursor) {
- delete m_customCursor;
- m_customCursor = 0;
- }
-
- m_customCursor = new Cursor;
- if (!m_customCursor) return GHOST_kFailure;
-
- for (y = 0; y < 16; y++) {
-#if !defined(__LITTLE_ENDIAN__)
- m_customCursor->data[y] = uns16ReverseBits((bitmap[2 * y] << 0) | (bitmap[2 * y + 1] << 8));
- m_customCursor->mask[y] = uns16ReverseBits((mask[2 * y] << 0) | (mask[2 * y + 1] << 8));
-#else
- m_customCursor->data[y] = uns16ReverseBits((bitmap[2 * y + 1] << 0) | (bitmap[2 * y] << 8));
- m_customCursor->mask[y] = uns16ReverseBits((mask[2 * y + 1] << 0) | (mask[2 * y] << 8));
-#endif
-
- }
-
- m_customCursor->hotSpot.h = hotX;
- m_customCursor->hotSpot.v = hotY;
-
- if (::FrontWindow() == m_windowRef) {
- loadCursor(getCursorVisibility(), GHOST_kStandardCursorCustom);
- }
-
- return GHOST_kSuccess;
-}
-
-GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2], int hotX, int hotY)
-{
- return setWindowCustomCursorShape((GHOST_TUns8 *)bitmap, (GHOST_TUns8 *) mask, 16, 16, hotX, hotY, 0, 1);
-}
-
-
-void GHOST_WindowCarbon::setMac_windowState(short value)
-{
- mac_windowState = value;
-}
-
-short GHOST_WindowCarbon::getMac_windowState()
-{
- return mac_windowState;
-}
diff --git a/intern/ghost/intern/GHOST_WindowCarbon.h b/intern/ghost/intern/GHOST_WindowCarbon.h
deleted file mode 100644
index 16f305e93c5..00000000000
--- a/intern/ghost/intern/GHOST_WindowCarbon.h
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file ghost/intern/GHOST_WindowCarbon.h
- * \ingroup GHOST
- * Declaration of GHOST_WindowCarbon class.
- */
-
-#ifndef __GHOST_WINDOWCARBON_H__
-#define __GHOST_WINDOWCARBON_H__
-
-#ifndef __APPLE__
-#error Apple OSX only!
-#endif // __APPLE__
-
-#include "GHOST_Window.h"
-#include "STR_String.h"
-
-#define __CARBONSOUND__
-#include <Carbon/Carbon.h>
-
-#include <AGL/agl.h>
-
-
-/**
- * Window on Mac OSX/Carbon.
- * Carbon windows have a size widget in the lower right corner of the window.
- * To force it to be visible, the height of the client rectangle is reduced so
- * that applications do not draw in that area. GHOST will manage that area
- * which is called the gutter.
- * When OpenGL contexts are active, GHOST will use AGL_BUFFER_RECT to prevent
- * OpenGL drawing outside the reduced client rectangle.
- * \author Maarten Gribnau
- * \date May 23, 2001
- */
-class GHOST_WindowCarbon : public GHOST_Window {
-public:
- /**
- * Constructor.
- * Creates a new window and opens it.
- * To check if the window was created properly, use the getValid() method.
- * \param title The text shown in the title bar of the window.
- * \param left The coordinate of the left edge of the window.
- * \param top The coordinate of the top edge of the window.
- * \param width The width the window.
- * \param height The height the window.
- * \param state The state the window is initially opened with.
- * \param type The type of drawing context installed in this window.
- * \param stereoVisual Stereo visual for quad buffered stereo.
- */
- GHOST_WindowCarbon(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
- const bool stereoVisual = false,
- const GHOST_TUns16 numOfAASamples = 0
- );
-
- /**
- * Destructor.
- * Closes the window and disposes resources allocated.
- */
- virtual ~GHOST_WindowCarbon();
-
- /**
- * Returns indication as to whether the window is valid.
- * \return The validity of the window.
- */
- virtual bool getValid() const;
-
- /**
- * Sets the title displayed in the title bar.
- * \param title The title to display in the title bar.
- */
- virtual void setTitle(const STR_String& title);
-
- /**
- * Returns the title displayed in the title bar.
- * \param title The title displayed in the title bar.
- */
- virtual void getTitle(STR_String& title) const;
-
- /**
- * Returns the window rectangle dimensions.
- * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
- * \param bounds The bounding rectangle of the window.
- */
- virtual void getWindowBounds(GHOST_Rect& bounds) const;
-
- /**
- * Returns the client rectangle dimensions.
- * The left and top members of the rectangle are always zero.
- * \param bounds The bounding rectangle of the cleient area of the window.
- */
- virtual void getClientBounds(GHOST_Rect& bounds) const;
-
- /**
- * Resizes client rectangle width.
- * \param width The new width of the client area of the window.
- */
- virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width);
-
- /**
- * Resizes client rectangle height.
- * \param height The new height of the client area of the window.
- */
- virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height);
-
- /**
- * Resizes client rectangle.
- * \param width The new width of the client area of the window.
- * \param height The new height of the client area of the window.
- */
- virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height);
-
- /**
- * Returns the state of the window (normal, minimized, maximized).
- * \return The state of the window.
- */
- virtual GHOST_TWindowState getState() const;
-
- /**
- * Converts a point in screen coordinates to client rectangle coordinates
- * \param inX The x-coordinate on the screen.
- * \param inY The y-coordinate on the screen.
- * \param outX The x-coordinate in the client rectangle.
- * \param outY The y-coordinate in the client rectangle.
- */
- virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
-
- /**
- * Converts a point in screen coordinates to client rectangle coordinates
- * \param inX The x-coordinate in the client rectangle.
- * \param inY The y-coordinate in the client rectangle.
- * \param outX The x-coordinate on the screen.
- * \param outY The y-coordinate on the screen.
- */
- virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const;
-
- /**
- * Sets the state of the window (normal, minimized, maximized).
- * \param state The state of the window.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess setState(GHOST_TWindowState state);
-
- /**
- * Sets the order of the window (bottom, top).
- * \param order The order of the window.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
-
- /**
- * Swaps front and back buffers of a window.
- * \return A boolean success indicator.
- */
- virtual GHOST_TSuccess swapBuffers();
-
- /**
- * Updates the drawing context of this window. Needed
- * whenever the window is changed.
- * \return Indication of success.
- */
- GHOST_TSuccess updateDrawingContext();
-
- /**
- * Activates the drawing context of this window.
- * \return A boolean success indicator.
- */
- virtual GHOST_TSuccess activateDrawingContext();
-
- virtual void loadCursor(bool visible, GHOST_TStandardCursor cursor) const;
-
- /**
- * Returns the dirty state of the window when in full-screen mode.
- * \return Whether it is dirty.
- */
- virtual bool getFullScreenDirty();
-
- /* accessor for fullscreen window */
- virtual void setMac_windowState(short value);
- virtual short getMac_windowState();
-
-
- const GHOST_TabletData *GetTabletData()
- {
- return &m_tablet;
- }
-
- GHOST_TabletData& GetCarbonTabletData()
- {
- return m_tablet;
- }
-
- GHOST_TSuccess beginFullScreen() const {return GHOST_kFailure;}
-
- GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;}
-
-protected:
- /**
- * Tries to install a rendering context in this window.
- * \param type The type of rendering context installed.
- * \return Indication as to whether installation has succeeded.
- */
- virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
-
- /**
- * Removes the current drawing context.
- * \return Indication as to whether removal has succeeded.
- */
- virtual GHOST_TSuccess removeDrawingContext();
-
- /**
- * Invalidates the contents of this window.
- * \return Indication of success.
- */
- virtual GHOST_TSuccess invalidate();
-
- /**
- * Sets the cursor visibility on the window using
- * native window system calls.
- */
- virtual GHOST_TSuccess setWindowCursorVisibility(bool visible);
-
- /**
- * Sets the cursor shape on the window using
- * native window system calls.
- */
- virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape);
-
- /**
- * Sets the cursor shape on the window using
- * native window system calls.
- */
- virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
- int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color);
-
- virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
-
- /**
- * Converts a string object to a Mac Pascal string.
- * \param in The string object to be converted.
- * \param out The converted string.
- */
- virtual void gen2mac(const STR_String& in, Str255 out) const;
-
- /**
- * Converts a Mac Pascal string to a string object.
- * \param in The string to be converted.
- * \param out The converted string object.
- */
- virtual void mac2gen(const Str255 in, STR_String& out) const;
-
- WindowRef m_windowRef;
- CGrafPtr m_grafPtr;
- AGLContext m_aglCtx;
-
- /** The first created OpenGL context (for sharing display lists) */
- static AGLContext s_firstaglCtx;
-
- Cursor *m_customCursor;
-
- GHOST_TabletData m_tablet;
-
- /** When running in full-screen this tells whether to refresh the window. */
- bool m_fullScreenDirty;
-
- /** specific MacOs X full screen window setting as we use partially system mechanism
- * values : 0 not maximizable default
- * 1 normal state
- * 2 maximized state
- *
- * this will be reworked when rebuilding GHOST carbon to use new OS X apis
- * in order to be unified with GHOST fullscreen/maximised settings
- *
- * (lukep)
- **/
-
- short mac_windowState;
-
-
- /**
- * The width/height of the size rectangle in the lower right corner of a
- * Mac/Carbon window. This is also the height of the gutter area.
- */
-#ifdef GHOST_DRAW_CARBON_GUTTER
- static const GHOST_TInt32 s_sizeRectSize;
-#endif // GHOST_DRAW_CARBON_GUTTER
-};
-
-#endif // __GHOST_WINDOWCARBON_H__
-
diff --git a/intern/ghost/test/CMakeLists.txt b/intern/ghost/test/CMakeLists.txt
index 455fff74a5c..84b6f663ff2 100644
--- a/intern/ghost/test/CMakeLists.txt
+++ b/intern/ghost/test/CMakeLists.txt
@@ -122,6 +122,7 @@ add_library(bli_lib
"../../../source/blender/blenlib/intern/listbase.c"
"../../../source/blender/blenlib/intern/math_color.c"
"../../../source/blender/blenlib/intern/storage.c"
+ "../../../source/blender/blenlib/intern/task.c"
"../../../source/blender/blenlib/intern/threads.c"
"../../../source/blender/blenlib/intern/time.c"
"../../../source/blender/blenlib/intern/path_util.c"
diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt
index b7a59da7813..1d041ba5380 100644
--- a/intern/guardedalloc/CMakeLists.txt
+++ b/intern/guardedalloc/CMakeLists.txt
@@ -39,6 +39,9 @@ set(SRC
MEM_guardedalloc.h
./intern/mallocn_intern.h
+
+ # only so the header is known by cmake
+ ../atomic/atomic_ops.h
)
if(WIN32 AND NOT UNIX)
diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
index 35caebcc5e8..44f51a34134 100644
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@ -61,6 +61,7 @@ static void (*thread_unlock_callback)(void) = NULL;
#define MEMHEAD_FROM_PTR(ptr) (((MemHead*) vmemh) - 1)
#define PTR_FROM_MEMHEAD(memhead) (memhead + 1)
+#define MEMHEAD_IS_MMAP(memhead) ((memhead)->len & (size_t) 1)
#ifdef __GNUC__
__attribute__ ((format(printf, 1, 2)))
@@ -112,13 +113,13 @@ void MEM_lockfree_freeN(void *vmemh)
atomic_sub_u(&totblock, 1);
atomic_sub_z(&mem_in_use, len);
- if (memh->len & (size_t) 1) {
+ if (MEMHEAD_IS_MMAP(memh)) {
atomic_sub_z(&mmap_in_use, len);
#if defined(WIN32)
/* our windows mmap implementation is not thread safe */
mem_lock_thread();
#endif
- if (munmap(memh, memh->len + sizeof(MemHead)))
+ if (munmap(memh, len + sizeof(MemHead)))
printf("Couldn't unmap memory\n");
#if defined(WIN32)
mem_unlock_thread();
@@ -136,8 +137,14 @@ void *MEM_lockfree_dupallocN(const void *vmemh)
{
void *newp = NULL;
if (vmemh) {
+ MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
const size_t prev_size = MEM_allocN_len(vmemh);
- newp = MEM_lockfree_mallocN(prev_size, "dupli_malloc");
+ if (MEMHEAD_IS_MMAP(memh)) {
+ newp = MEM_lockfree_mapallocN(prev_size, "dupli_mapalloc");
+ }
+ else {
+ newp = MEM_lockfree_mallocN(prev_size, "dupli_malloc");
+ }
memcpy(newp, vmemh, prev_size);
}
return newp;
diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c
index 6f03188a579..3096c589101 100644
--- a/intern/guardedalloc/intern/mmap_win.c
+++ b/intern/guardedalloc/intern/mmap_win.c
@@ -182,14 +182,14 @@ static void mmap_addtail(volatile mmapListBase *listbase, void *vlink)
{
struct mmapLink *link = vlink;
- if (link == 0) return;
- if (listbase == 0) return;
+ if (link == NULL) return;
+ if (listbase == NULL) return;
link->next = 0;
link->prev = listbase->last;
if (listbase->last) ((struct mmapLink *)listbase->last)->next = link;
- if (listbase->first == 0) listbase->first = link;
+ if (listbase->first == NULL) listbase->first = link;
listbase->last = link;
}
@@ -197,8 +197,8 @@ static void mmap_remlink(volatile mmapListBase *listbase, void *vlink)
{
struct mmapLink *link = vlink;
- if (link == 0) return;
- if (listbase == 0) return;
+ if (link == NULL) return;
+ if (listbase == NULL) return;
if (link->next) link->next->prev = link->prev;
if (link->prev) link->prev->next = link->next;
@@ -211,8 +211,8 @@ static void *mmap_findlink(volatile mmapListBase *listbase, void *ptr)
{
MemMap *mm;
- if (ptr == 0) return NULL;
- if (listbase == 0) return NULL;
+ if (ptr == NULL) return NULL;
+ if (listbase == NULL) return NULL;
mm = (MemMap *)listbase->first;
while (mm) {
diff --git a/intern/locale/CMakeLists.txt b/intern/locale/CMakeLists.txt
index 1f14a0e7a6a..3599aa68545 100644
--- a/intern/locale/CMakeLists.txt
+++ b/intern/locale/CMakeLists.txt
@@ -45,3 +45,11 @@ if(WITH_INTERNATIONAL)
endif()
blender_add_lib(bf_intern_locale "${SRC}" "${INC}" "${INC_SYS}")
+
+# -----------------------------------------------------------------------------
+# Build msgfmt executable
+set(MSFFMT_SRC
+ msgfmt.cc
+)
+
+add_executable(msgfmt ${MSFFMT_SRC})
diff --git a/intern/locale/SConscript b/intern/locale/SConscript
index f60bd90fb38..4136ac8237d 100644
--- a/intern/locale/SConscript
+++ b/intern/locale/SConscript
@@ -37,3 +37,56 @@ if env['WITH_BF_INTERNATIONAL']:
incs += ' ' + env['BF_BOOST_INC']
env.BlenderLib( 'bf_intern_locale', sources, Split(incs), defs, libtype=['intern','player'], priority=[10, 185])
+
+if env['WITH_BF_INTERNATIONAL']:
+ import os
+ from os.path import dirname
+
+ def normpath(path):
+ return os.path.abspath(os.path.normpath(path))
+
+ # build directory
+ source_dir = Dir('.').srcnode().path
+ root_build_dir = normpath(env['BF_BUILDDIR'])
+ root_source_dir = dirname(dirname(normpath(source_dir)))
+ po_dir = os.path.join(root_source_dir, "release", "datafiles", "locale", "po")
+ build_dir = os.path.join(root_build_dir, 'locale')
+
+ if os.path.exists(po_dir):
+ # create directory if needed
+ if not os.path.exists(build_dir):
+ os.makedirs(build_dir)
+
+ msgfmt_tool = env.Clone()
+ msgfmt_tool.Append(LINKFLAGS = env['PLATFORM_LINKFLAGS'])
+
+ targetpath = root_build_dir + '/msgfmt'
+
+ msgfmt_target = msgfmt_tool.Program(target = targetpath, source = ['msgfmt.cc'])
+
+ locale = env.Clone()
+
+ msgfmt_executable = targetpath
+ if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'):
+ msgfmt_executable += ".exe"
+
+ # dependencies
+ dependencies = [msgfmt_target]
+
+ # add command for each locale
+ all_mo_files = []
+ for f in os.listdir(po_dir):
+ if not f.endswith(".po"):
+ continue
+
+ po_file = os.path.join(po_dir, f)
+ mo_file = os.path.join(build_dir, os.path.splitext(f)[0] + ".mo")
+
+ command = "\"%s\" \"%s\" \"%s\"" % (msgfmt_executable, po_file, mo_file)
+
+ locale.Command(mo_file, po_file, command)
+ locale.Depends(mo_file, dependencies)
+
+ all_mo_files.append(mo_file)
+
+ env.Depends("boost_locale_wrapper.cpp", all_mo_files)
diff --git a/intern/locale/msgfmt.cc b/intern/locale/msgfmt.cc
new file mode 100644
index 00000000000..17720adfa48
--- /dev/null
+++ b/intern/locale/msgfmt.cc
@@ -0,0 +1,369 @@
+// Written by Sergey Sharybin <sergey.vfx@gmail.com>
+// Added support for contexts
+//
+// Based on Python script msgfmt.py from Python source
+// code tree, which was written by Written by
+// Martin v. Löwis <loewis@informatik.hu-berlin.de>
+//
+// Generate binary message catalog from textual translation description.
+//
+// This program converts a textual Uniforum-style message catalog (.po file) into
+// a binary GNU catalog (.mo file). This is essentially the same function as the
+// GNU msgfmt program, however, it is a simpler implementation.
+//
+// Usage: msgfmt input.po output.po
+
+#include <algorithm>
+#include <cctype>
+#include <fstream>
+#include <functional>
+#include <iostream>
+#include <map>
+#include <stdlib.h>
+#include <string>
+#include <vector>
+
+namespace {
+
+std::map<std::string, std::string> MESSAGES;
+
+bool starts_with(const std::string &string,
+ const std::string &prefix) {
+ return prefix.size() <= string.size() &&
+ string.compare(0, prefix.size(), prefix) == 0;
+}
+
+std::string ltrim(const std::string &s) {
+ std::string result = s;
+ result.erase(result.begin(),
+ std::find_if(result.begin(),
+ result.end(),
+ std::not1(std::ptr_fun<int, int>(std::isspace))));
+ return result;
+}
+
+std::string rtrim(const std::string &s) {
+ std::string result = s;
+ result.erase(
+ std::find_if(result.rbegin(),
+ result.rend(),
+ std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
+ result.end());
+ return result;
+}
+
+std::string trim(const std::string &s) {
+ return ltrim(rtrim(s));
+}
+
+std::string unescape(const std::string &s) {
+ std::string result;
+ std::string::const_iterator it = s.begin();
+ while (it != s.end()) {
+ char current_char = *it++;
+ if (current_char == '\\' && it != s.end()) {
+ char next_char = *it++;
+ if (next_char == '\\') {
+ current_char = '\\';
+ } else if (next_char == 'n') {
+ current_char = '\n';
+ } else if (next_char == 't') {
+ current_char = '\t';
+ } else {
+ current_char = next_char;
+ }
+ }
+ result += current_char;
+ }
+
+ if (result[0] == '"' && result[result.size() - 1] == '"') {
+ result = result.substr(1, result.size() - 2);
+ }
+
+ return result;
+}
+
+// Add a non-fuzzy translation to the dictionary.
+void add(const std::string &msgctxt,
+ const std::string &msgid,
+ const std::string &msgstr,
+ bool fuzzy) {
+ if (fuzzy == false && msgstr.empty() == false) {
+ if (msgctxt.empty()) {
+ MESSAGES[msgid] = msgstr;
+ } else {
+ MESSAGES[msgctxt + (char)0x04 + msgid] = msgstr;
+ }
+ }
+}
+
+template<typename TKey, typename TValue>
+void get_keys(std::map<TKey, TValue> map,
+ std::vector<TKey> *keys) {
+ for (typename std::map<TKey, TValue>::iterator it = map.begin();
+ it != map.end();
+ it++) {
+ keys->push_back(it->first);
+ }
+}
+
+std::string intToBytes(int value) {
+ std::string result;
+ for (unsigned int i = 0; i < sizeof(value); i++) {
+ result += (unsigned char) ((value >> (i * 8)) & 0xff);
+ }
+ return result;
+}
+
+typedef enum {
+ SECTION_NONE = 0,
+ SECTION_CTX = 1,
+ SECTION_ID = 2,
+ SECTION_STR = 3
+} eSectionType;
+
+struct Offset {
+ unsigned int o1, l1, o2, l2;
+};
+
+// Return the generated output.
+std::string generate(void) {
+ // The keys are sorted in the .mo file
+ std::vector<std::string> keys;
+
+ // Get list of sorted keys.
+ get_keys(MESSAGES, &keys);
+ std::sort(keys.begin(), keys.end());
+
+ std::vector<Offset> offsets;
+ std::string ids = "", strs = "";
+ for (std::vector<std::string>::iterator it = keys.begin();
+ it != keys.end();
+ it++) {
+ std::string &id = *it;
+ // For each string, we need size and file offset. Each string is NUL
+ // terminated; the NUL does not count into the size.
+ Offset offset = {(unsigned int) ids.size(),
+ (unsigned int) id.size(),
+ (unsigned int) strs.size(),
+ (unsigned int) MESSAGES[id].size()};
+ offsets.push_back(offset);
+ ids += id + '\0';
+ strs += MESSAGES[id] + '\0';
+ }
+
+ // The header is 7 32-bit unsigned integers. We don't use hash tables, so
+ // the keys start right after the index tables.
+ // translated string.
+ int keystart = 7 * 4 + 16 * keys.size();
+ // and the values start after the keys
+ int valuestart = keystart + ids.size();
+ std::vector<int> koffsets;
+ std::vector<int> voffsets;
+ // The string table first has the list of keys, then the list of values.
+ // Each entry has first the size of the string, then the file offset.
+ for (std::vector<Offset>::iterator it = offsets.begin();
+ it != offsets.end();
+ it++) {
+ Offset &offset = *it;
+ koffsets.push_back(offset.l1);
+ koffsets.push_back(offset.o1 + keystart);
+ voffsets.push_back(offset.l2);
+ voffsets.push_back(offset.o2 + valuestart);
+ }
+
+ std::vector<int> all_offsets;
+ all_offsets.reserve(koffsets.size() + voffsets.size());
+ all_offsets.insert(all_offsets.end(), koffsets.begin(), koffsets.end());
+ all_offsets.insert(all_offsets.end(), voffsets.begin(), voffsets.end());
+
+ std::string output = "";
+ output += intToBytes(0x950412de); // Magic
+ output += intToBytes(0x0); // Version
+ output += intToBytes(keys.size()); // # of entries
+ output += intToBytes(7 * 4); // start of key index
+ output += intToBytes(7 * 4 + keys.size() * 8); // start of value index
+ output += intToBytes(0); // Size of hash table
+ output += intToBytes(0); // Offset of hash table
+
+ for (std::vector<int>::iterator it = all_offsets.begin();
+ it != all_offsets.end();
+ it++) {
+ int offset = *it;
+ output += intToBytes(offset);
+ }
+
+ output += ids;
+ output += strs;
+
+ return output;
+}
+
+void make(const char *input_file_name,
+ const char *output_file_name) {
+ std::map<std::string, std::string> messages;
+
+ // Start off assuming Latin-1, so everything decodes without failure,
+ // until we know the exact encoding.
+ // TODO(sergey): Support encoding.
+ // const char *encoding = "latin-1";
+
+ eSectionType section = SECTION_NONE;
+ bool fuzzy = false;
+ bool is_plural = false;
+ std::string msgctxt, msgid, msgstr;
+
+ std::ifstream input_file_stream(input_file_name);
+
+ // Parse the catalog.
+ int lno = 0;
+ for (std::string l; getline(input_file_stream, l); ) {
+ lno++;
+ // If we get a comment line after a msgstr, this is a new entry.
+ if (l[0] == '#' && section == SECTION_STR) {
+ add(msgctxt, msgid, msgstr, fuzzy);
+ section = SECTION_NONE;
+ msgctxt = "";
+ fuzzy = false;
+ }
+ // Record a fuzzy mark.
+ if (starts_with(l, "#,") && l.find("fuzzy") != std::string::npos) {
+ fuzzy = 1;
+ }
+ // Skip comments
+ if (l[0] == '#') {
+ continue;
+ }
+ // Now we are in a msgid section, output previous section.
+ if (starts_with(l, "msgctxt")) {
+ if (section == SECTION_STR) {
+ add(msgctxt, msgid, msgstr, fuzzy);
+ }
+ section = SECTION_CTX;
+ l = l.substr(7, l.size() - 7);
+ msgctxt = msgid = msgstr = "";
+ }
+ else if (starts_with(l, "msgid") && !starts_with(l, "msgid_plural")) {
+ if (section == SECTION_STR) {
+ add(msgctxt, msgid, msgstr, fuzzy);
+ msgctxt = "";
+ if (msgid == "") {
+#if 0
+ // See whether there is an encoding declaration.
+ p = HeaderParser();
+ charset = p.parsestr(msgstr.decode(encoding)).get_content_charset();
+ if (charset) {
+ encoding = charset;
+ }
+#else
+ // Not ported to C++ yet.
+ std::cerr << "Encoding declarations are not supported yet.\n"
+ << std::endl;
+ abort();
+#endif
+ }
+ }
+ section = SECTION_ID;
+ l = l.substr(5, l.size() - 5);
+ msgid = msgstr = "";
+ is_plural = false;
+ } else if (starts_with(l, "msgid_plural")) {
+ // This is a message with plural forms.
+ if (section != SECTION_ID) {
+ std::cerr << "msgid_plural not preceeded by msgid on"
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ l = l.substr(12, l.size() - 12);
+ msgid += '\0'; // separator of singular and plural
+ is_plural = true;
+ } else if (starts_with(l, "msgstr")) {
+ // Now we are in a msgstr section
+ section = SECTION_STR;
+ if (starts_with(l, "msgstr[")) {
+ if (is_plural == false) {
+ std::cerr << "plural without msgid_plural on "
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ int bracket_position = l.find(']');
+ if (bracket_position == std::string::npos) {
+ std::cerr << "Syntax error on "
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ l = l.substr(bracket_position, l.size() - bracket_position);
+ if (msgstr != "") {
+ msgstr += '\0'; // Separator of the various plural forms;
+ }
+ } else {
+ if (is_plural) {
+ std::cerr << "indexed msgstr required for plural on "
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ l = l.substr(6, l.size() - 6);
+ }
+ }
+ // Skip empty lines.
+ l = trim(l);
+ if (l.empty()) {
+ continue;
+ }
+ l = unescape(l);
+ if (section == SECTION_CTX) {
+ // TODO(sergey): Support encoding.
+ // msgid += l.encode(encoding);
+ msgctxt += l;
+ }
+ else if (section == SECTION_ID) {
+ // TODO(sergey): Support encoding.
+ // msgid += l.encode(encoding);
+ msgid += l;
+ } else if (section == SECTION_STR) {
+ // TODO(sergey): Support encoding.
+ // msgstr += l.encode(encoding)
+ msgstr += l;
+ } else {
+ std::cerr << "Syntax error on "
+ << input_file_name << ":"
+ << lno
+ << std::endl;
+ abort();
+ }
+ // Add last entry
+ if (section == SECTION_STR) {
+ add(msgctxt, msgid, msgstr, fuzzy);
+ }
+ }
+
+ // Compute output
+ std::string output = generate();
+
+ std::ofstream output_file_stream(output_file_name,
+ std::ios::out | std::ios::binary);
+ output_file_stream << output;
+}
+
+} // namespace
+
+int main(int argc, char **argv) {
+ if (argc != 3) {
+ printf("Usage: %s <input.po> <output.mo>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+ const char *input_file = argv[1];
+ const char *output_file = argv[2];
+
+ make(input_file, output_file);
+
+ return EXIT_SUCCESS;
+}
diff --git a/intern/rigidbody/CMakeLists.txt b/intern/rigidbody/CMakeLists.txt
index 80ea567c9f5..f01ca127b3f 100644
--- a/intern/rigidbody/CMakeLists.txt
+++ b/intern/rigidbody/CMakeLists.txt
@@ -24,12 +24,11 @@
set(INC
.
../../source/blender/gpu
- ../../extern/bullet2/src
../../extern/HACD
)
set(INC_SYS
-
+ ${BULLET_INCLUDE_DIRS}
)
set(SRC
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index 6c794e805da..5eff4fa60a2 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -1254,11 +1254,7 @@ rbConstraint *RB_constraint_new_fixed(float pivot[3], float orn[4], rbRigidBody
make_constraint_transforms(transform1, transform2, body1, body2, pivot, orn);
- btGeneric6DofConstraint *con = new btGeneric6DofConstraint(*body1, *body2, transform1, transform2, true);
-
- /* lock all axes */
- for (int i = 0; i < 6; i++)
- con->setLimit(i, 0, 0);
+ btFixedConstraint *con = new btFixedConstraint(*body1, *body2, transform1, transform2);
return (rbConstraint *)con;
}