diff options
Diffstat (limited to 'intern/cycles/kernel/kernel_camera.h')
-rw-r--r-- | intern/cycles/kernel/kernel_camera.h | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index ded222e20ff..3ce5134181a 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -16,17 +16,6 @@ CCL_NAMESPACE_BEGIN -/* Workaround for explicit conversion from constant to private memory - * pointer when using OpenCL. - * - * TODO(sergey): Find a real solution for this. - */ -#ifdef __KERNEL_OPENCL__ -# define __motion_as_decoupled_const_ptr(motion) ((motion)) -#else -# define __motion_as_decoupled_const_ptr(motion) ((const DecompMotionTransform*)(motion)) -#endif - /* Perspective Camera */ ccl_device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v) @@ -50,7 +39,7 @@ ccl_device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v) return bokeh; } -ccl_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, ccl_addr_space Ray *ray) { /* create ray form raster position */ Transform rastertocamera = kernel_data.cam.rastertocamera; @@ -80,9 +69,16 @@ ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, flo #ifdef __CAMERA_MOTION__ if(kernel_data.cam.have_motion) { +#ifdef __KERNEL_OPENCL__ + const MotionTransform tfm = kernel_data.cam.motion; transform_motion_interpolate(&cameratoworld, - __motion_as_decoupled_const_ptr(&kernel_data.cam.motion), + ((const DecompMotionTransform*)&tfm), ray->time); +#else + transform_motion_interpolate(&cameratoworld, + ((const DecompMotionTransform*)&kernel_data.cam.motion), + ray->time); +#endif } #endif @@ -112,8 +108,7 @@ ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, flo } /* Orthographic Camera */ - -ccl_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, ccl_addr_space Ray *ray) { /* create ray form raster position */ Transform rastertocamera = kernel_data.cam.rastertocamera; @@ -144,9 +139,16 @@ ccl_device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, fl #ifdef __CAMERA_MOTION__ if(kernel_data.cam.have_motion) { +#ifdef __KERNEL_OPENCL__ + const MotionTransform tfm = kernel_data.cam.motion; transform_motion_interpolate(&cameratoworld, - __motion_as_decoupled_const_ptr(&kernel_data.cam.motion), + (const DecompMotionTransform*)&tfm, ray->time); +#else + transform_motion_interpolate(&cameratoworld, + (const DecompMotionTransform*)&kernel_data.cam.motion, + ray->time); +#endif } #endif @@ -172,7 +174,7 @@ ccl_device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, fl /* Panorama Camera */ -ccl_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, ccl_addr_space Ray *ray) { Transform rastertocamera = kernel_data.cam.rastertocamera; float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f)); @@ -220,10 +222,18 @@ ccl_device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float Transform cameratoworld = kernel_data.cam.cameratoworld; #ifdef __CAMERA_MOTION__ - if(kernel_data.cam.have_motion) + if(kernel_data.cam.have_motion) { +#ifdef __KERNEL_OPENCL__ + const MotionTransform tfm = kernel_data.cam.motion; transform_motion_interpolate(&cameratoworld, - __motion_as_decoupled_const_ptr(&kernel_data.cam.motion), + (const DecompMotionTransform*)&tfm, ray->time); +#else + transform_motion_interpolate(&cameratoworld, + (const DecompMotionTransform*)&kernel_data.cam.motion, + ray->time); +#endif + } #endif ray->P = transform_point(&cameratoworld, ray->P); @@ -245,7 +255,7 @@ ccl_device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float /* Common */ 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) + float lens_u, float lens_v, float time, ccl_addr_space Ray *ray) { /* pixel filter */ int filter_table_offset = kernel_data.film.filter_table_offset; @@ -308,7 +318,7 @@ ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, { if(kernel_data.cam.type != CAMERA_PANORAMA) { /* perspective / ortho */ - if(sd->object == PRIM_NONE && kernel_data.cam.type == CAMERA_PERSPECTIVE) + if(ccl_fetch(sd, object) == PRIM_NONE && kernel_data.cam.type == CAMERA_PERSPECTIVE) P += camera_position(kg); Transform tfm = kernel_data.cam.worldtondc; @@ -318,7 +328,7 @@ ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, /* panorama */ Transform tfm = kernel_data.cam.worldtocamera; - if(sd->object != OBJECT_NONE) + if(ccl_fetch(sd, object) != OBJECT_NONE) P = normalize(transform_point(&tfm, P)); else P = normalize(transform_direction(&tfm, P)); @@ -329,7 +339,4 @@ ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, } } -#undef __motion_as_decoupled_const_ptr - CCL_NAMESPACE_END - |