Fix for Cycles (CUDA) compilation (again ...). Moved the AttributeStandard enum typed...
[blender.git] / intern / cycles / kernel / kernel_types.h
index 477b08f2f872ea9ec316dd528318605f4ada4911..ce21ab994f084dca8675d80e1f6895eea14d3130 100644 (file)
 #define __KERNEL_TYPES_H__
 
 #include "kernel_math.h"
-
 #include "svm/svm_types.h"
 
+#ifndef __KERNEL_GPU__
+#define __KERNEL_CPU__
+#endif
+
 CCL_NAMESPACE_BEGIN
 
 /* constants */
 #define OBJECT_SIZE            16
 #define LIGHT_SIZE                     4
 #define FILTER_TABLE_SIZE      256
+#define RAMP_TABLE_SIZE                256
+#define PARTICLE_SIZE          5
+#define TIME_INVALID           FLT_MAX
 
 /* device capabilities */
 #ifdef __KERNEL_CPU__
 #define __KERNEL_SHADING__
 #define __KERNEL_ADV_SHADING__
+#ifdef WITH_OSL
+#define __OSL__
+#endif
+#define __NON_PROGRESSIVE__
 #endif
 
 #ifdef __KERNEL_CUDA__
@@ -44,8 +54,30 @@ CCL_NAMESPACE_BEGIN
 #endif
 
 #ifdef __KERNEL_OPENCL__
-//#define __KERNEL_SHADING__
-//#define __KERNEL_ADV_SHADING__
+
+#ifdef __KERNEL_OPENCL_NVIDIA__
+#define __KERNEL_SHADING__
+#define __MULTI_CLOSURE__
+#endif
+
+#ifdef __KERNEL_OPENCL_APPLE__
+//#define __SVM__
+//#define __EMISSION__
+//#define __IMAGE_TEXTURES__
+//#define __HOLDOUT__
+//#define __PROCEDURAL_TEXTURES__
+//#define __EXTRA_NODES__
+#endif
+
+#ifdef __KERNEL_OPENCL_AMD__
+#define __SVM__
+#define __EMISSION__
+#define __IMAGE_TEXTURES__
+#define __HOLDOUT__
+#define __PROCEDURAL_TEXTURES__
+#define __EXTRA_NODES__
+#endif
+
 #endif
 
 /* kernel features */
@@ -59,11 +91,14 @@ CCL_NAMESPACE_BEGIN
 #define __RAY_DIFFERENTIALS__
 #define __CAMERA_CLIPPING__
 #define __INTERSECTION_REFINE__
+#define __CLAMP_SAMPLE__
 
 #ifdef __KERNEL_SHADING__
 #define __SVM__
 #define __EMISSION__
-#define __TEXTURES__
+#define __PROCEDURAL_TEXTURES__
+#define __IMAGE_TEXTURES__
+#define __EXTRA_NODES__
 #define __HOLDOUT__
 #endif
 
@@ -72,12 +107,11 @@ CCL_NAMESPACE_BEGIN
 #define __TRANSPARENT_SHADOWS__
 #define __PASSES__
 #define __BACKGROUND_MIS__
+#define __AO__
+//#define __MOTION__
 #endif
 
-//#define __MULTI_LIGHT__
-//#define __OSL__
 //#define __SOBOL_FULL_SCREEN__
-//#define __MODIFY_TP__
 //#define __QBVH__
 
 /* Shader Evaluation */
@@ -87,14 +121,21 @@ enum ShaderEvalType {
        SHADER_EVAL_BACKGROUND
 };
 
-/* Path Tracing */
+/* Path Tracing
+ * note we need to keep the u/v pairs at even values */
 
 enum PathTraceDimension {
        PRNG_FILTER_U = 0,
        PRNG_FILTER_V = 1,
        PRNG_LENS_U = 2,
        PRNG_LENS_V = 3,
+#ifdef __MOTION__
+       PRNG_TIME = 4,
+       PRNG_UNUSED = 5,
+       PRNG_BASE_NUM = 6,
+#else
        PRNG_BASE_NUM = 4,
+#endif
 
        PRNG_BSDF_U = 0,
        PRNG_BSDF_V = 1,
@@ -131,6 +172,8 @@ enum PathRayFlag {
 
        PATH_RAY_ALL = (1|2|4|8|16|32|64|128|256|512),
 
+       /* this gives collisions with localview bits
+        * see: CYCLES_LOCAL_LAYER_HACK(), grr - Campbell */
        PATH_RAY_LAYER_SHIFT = (32-20)
 };
 
@@ -158,21 +201,25 @@ typedef enum PassType {
        PASS_NONE = 0,
        PASS_COMBINED = 1,
        PASS_DEPTH = 2,
-       PASS_NORMAL = 8,
-       PASS_UV = 16,
-       PASS_OBJECT_ID = 32,
-       PASS_MATERIAL_ID = 64,
-       PASS_DIFFUSE_COLOR = 128,
-       PASS_GLOSSY_COLOR = 256,
-       PASS_TRANSMISSION_COLOR = 512,
-       PASS_DIFFUSE_INDIRECT = 1024,
-       PASS_GLOSSY_INDIRECT = 2048,
-       PASS_TRANSMISSION_INDIRECT = 4096,
-       PASS_DIFFUSE_DIRECT = 8192,
-       PASS_GLOSSY_DIRECT = 16384,
-       PASS_TRANSMISSION_DIRECT = 32768,
-       PASS_EMISSION = 65536,
-       PASS_BACKGROUND = 131072
+       PASS_NORMAL = 4,
+       PASS_UV = 8,
+       PASS_OBJECT_ID = 16,
+       PASS_MATERIAL_ID = 32,
+       PASS_DIFFUSE_COLOR = 64,
+       PASS_GLOSSY_COLOR = 128,
+       PASS_TRANSMISSION_COLOR = 256,
+       PASS_DIFFUSE_INDIRECT = 512,
+       PASS_GLOSSY_INDIRECT = 1024,
+       PASS_TRANSMISSION_INDIRECT = 2048,
+       PASS_DIFFUSE_DIRECT = 4096,
+       PASS_GLOSSY_DIRECT = 8192,
+       PASS_TRANSMISSION_DIRECT = 16384,
+       PASS_EMISSION = 32768,
+       PASS_BACKGROUND = 65536,
+       PASS_AO = 131072,
+       PASS_SHADOW = 262144,
+       PASS_MOTION = 524288,
+       PASS_MOTION_WEIGHT = 1048576
 } PassType;
 
 #define PASS_ALL (~0)
@@ -181,11 +228,12 @@ typedef enum PassType {
 
 typedef float3 PathThroughput;
 
-struct PathRadiance {
+typedef struct PathRadiance {
        int use_light_pass;
 
        float3 emission;
        float3 background;
+       float3 ao;
 
        float3 indirect;
        float3 direct_throughput;
@@ -202,16 +250,18 @@ struct PathRadiance {
        float3 indirect_diffuse;
        float3 indirect_glossy;
        float3 indirect_transmission;
-};
 
-struct BsdfEval {
+       float4 shadow;
+} PathRadiance;
+
+typedef struct BsdfEval {
        int use_light_pass;
 
        float3 diffuse;
        float3 glossy;
        float3 transmission;
        float3 transparent;
-};
+} BsdfEval;
 
 #else
 
@@ -237,9 +287,27 @@ typedef enum LightType {
        LIGHT_POINT,
        LIGHT_DISTANT,
        LIGHT_BACKGROUND,
-       LIGHT_AREA
+       LIGHT_AREA,
+       LIGHT_AO,
+       LIGHT_SPOT
 } LightType;
 
+/* Camera Type */
+
+enum CameraType {
+       CAMERA_PERSPECTIVE,
+       CAMERA_ORTHOGRAPHIC,
+       CAMERA_PANORAMA
+};
+
+/* Panorama Type */
+
+enum PanoramaType {
+       PANORAMA_EQUIRECTANGULAR,
+       PANORAMA_FISHEYE_EQUIDISTANT,
+       PANORAMA_FISHEYE_EQUISOLID
+};
+
 /* Differential */
 
 typedef struct differential3 {
@@ -258,6 +326,7 @@ typedef struct Ray {
        float3 P;
        float3 D;
        float t;
+       float time;
 
 #ifdef __RAY_DIFFERENTIALS__
        differential3 dP;
@@ -297,10 +366,9 @@ typedef struct ShaderClosure {
 
 #ifdef __OSL__
        void *prim;
-#else
+#endif
        float data0;
        float data1;
-#endif
 
 } ShaderClosure;
 
@@ -323,7 +391,11 @@ enum ShaderDataFlag {
        SD_SAMPLE_AS_LIGHT = 128,                       /* direct light sample */
        SD_HAS_SURFACE_TRANSPARENT = 256,       /* has surface transparency */
        SD_HAS_VOLUME = 512,                            /* has volume shader */
-       SD_HOMOGENEOUS_VOLUME = 1024            /* has homogeneous volume */
+       SD_HOMOGENEOUS_VOLUME = 1024,           /* has homogeneous volume */
+
+       /* object flags */
+       SD_HOLDOUT_MASK = 2048,                         /* holdout for camera rays */
+       SD_OBJECT_MOTION = 4096                         /* has object motion blur */
 };
 
 typedef struct ShaderData {
@@ -348,6 +420,19 @@ typedef struct ShaderData {
        /* object id if there is one, ~0 otherwise */
        int object;
 
+       /* motion blur sample time */
+       float time;
+       
+       /* length of the ray being shaded */
+       float ray_length;
+
+#ifdef __MOTION__
+       /* object <-> world space transformations, cached to avoid
+        * re-interpolating them constantly for shading */
+       Transform ob_tfm;
+       Transform ob_itfm;
+#endif
+
 #ifdef __RAY_DIFFERENTIALS__
        /* differential of P. these are orthogonal to Ng, not N */
        differential3 dP;
@@ -387,8 +472,12 @@ typedef struct ShaderData {
 
 typedef struct KernelCamera {
        /* type */
-       int ortho;
-       int pad1, pad2, pad3;
+       int type;
+
+       /* panorama */
+       int panorama_type;
+       float fisheye_fov;
+       float fisheye_lens;
 
        /* matrices */
        Transform cameratoworld;
@@ -405,13 +494,20 @@ typedef struct KernelCamera {
        float focaldistance;
 
        /* motion blur */
-       float shutteropen;
-       float shutterclose;
+       float shuttertime;
+       int have_motion;
 
        /* clipping */
        float nearclip;
        float cliplength;
 
+       /* sensor size */
+       float sensorwidth;
+       float sensorheight;
+
+       /* render size */
+       float width, height;
+
        /* more matrices */
        Transform screentoworld;
        Transform rastertoworld;
@@ -420,6 +516,8 @@ typedef struct KernelCamera {
        Transform worldtoraster;
        Transform worldtondc;
        Transform worldtocamera;
+
+       MotionTransform motion;
 } KernelCamera;
 
 typedef struct KernelFilm {
@@ -431,32 +529,42 @@ typedef struct KernelFilm {
        int pass_combined;
        int pass_depth;
        int pass_normal;
-       int pass_pad;
+       int pass_motion;
 
+       int pass_motion_weight;
        int pass_uv;
        int pass_object_id;
        int pass_material_id;
-       int pass_diffuse_color;
 
+       int pass_diffuse_color;
        int pass_glossy_color;
        int pass_transmission_color;
        int pass_diffuse_indirect;
-       int pass_glossy_indirect;
 
+       int pass_glossy_indirect;
        int pass_transmission_indirect;
        int pass_diffuse_direct;
        int pass_glossy_direct;
-       int pass_transmission_direct;
 
+       int pass_transmission_direct;
        int pass_emission;
        int pass_background;
+       int pass_ao;
+
+       int pass_shadow;
+       int pass_pad1;
+       int pass_pad2;
+       int pass_pad3;
 } KernelFilm;
 
 typedef struct KernelBackground {
        /* only shader index */
        int shader;
        int transparent;
-       int pad1, pad2;
+
+       /* ambient occlusion */
+       float ao_factor;
+       float ao_distance;
 } KernelBackground;
 
 typedef struct KernelSunSky {
@@ -472,6 +580,7 @@ typedef struct KernelSunSky {
 typedef struct KernelIntegrator {
        /* emission */
        int use_direct_light;
+       int use_ambient_occlusion;
        int num_distribution;
        int num_all_lights;
        float pdf_triangles;
@@ -493,12 +602,25 @@ typedef struct KernelIntegrator {
 
        /* caustics */
        int no_caustics;
+       float filter_glossy;
 
        /* seed */
        int seed;
 
        /* render layer */
        int layer_flag;
+
+       /* clamp */
+       float sample_clamp;
+
+       /* non-progressive */
+       int progressive;
+       int diffuse_samples;
+       int glossy_samples;
+       int transmission_samples;
+       int ao_samples;
+       int mesh_light_samples;
+       int pad1, pad2;
 } KernelIntegrator;
 
 typedef struct KernelBVH {