2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* 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
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* 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
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* OpenCL kernel entry points - unfinished */
|
|
|
|
|
|
|
|
#include "kernel_compat_opencl.h"
|
|
|
|
#include "kernel_math.h"
|
|
|
|
#include "kernel_types.h"
|
|
|
|
#include "kernel_globals.h"
|
|
|
|
|
|
|
|
#include "kernel_film.h"
|
2011-05-20 12:26:01 +00:00
|
|
|
#include "kernel_path.h"
|
2014-05-19 12:57:55 +00:00
|
|
|
#include "kernel_bake.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-05-20 12:26:01 +00:00
|
|
|
__kernel void kernel_ocl_path_trace(
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_constant KernelData *data,
|
|
|
|
ccl_global float *buffer,
|
|
|
|
ccl_global uint *rng_state,
|
2011-05-20 12:26:01 +00:00
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_global type *name,
|
2011-05-20 12:26:01 +00:00
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
2011-09-16 13:14:02 +00:00
|
|
|
int sample,
|
2011-12-20 12:25:37 +00:00
|
|
|
int sx, int sy, int sw, int sh, int offset, int stride)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
KernelGlobals kglobals, *kg = &kglobals;
|
2011-05-20 12:26:01 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
kg->data = data;
|
|
|
|
|
2011-05-20 12:26:01 +00:00
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
2011-11-22 13:15:19 +00:00
|
|
|
kg->name = name;
|
2011-05-20 12:26:01 +00:00
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
|
|
|
int x = sx + get_global_id(0);
|
|
|
|
int y = sy + get_global_id(1);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-05-20 12:26:01 +00:00
|
|
|
if(x < sx + sw && y < sy + sh)
|
2013-08-28 14:36:47 +00:00
|
|
|
kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 23:49:38 +00:00
|
|
|
__kernel void kernel_ocl_convert_to_byte(
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_constant KernelData *data,
|
|
|
|
ccl_global uchar4 *rgba,
|
|
|
|
ccl_global float *buffer,
|
2011-05-20 12:26:01 +00:00
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_global type *name,
|
2011-05-20 12:26:01 +00:00
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
2013-08-30 23:49:38 +00:00
|
|
|
float sample_scale,
|
|
|
|
int sx, int sy, int sw, int sh, int offset, int stride)
|
|
|
|
{
|
|
|
|
KernelGlobals kglobals, *kg = &kglobals;
|
|
|
|
|
|
|
|
kg->data = data;
|
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
|
|
|
kg->name = name;
|
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
|
|
|
int x = sx + get_global_id(0);
|
|
|
|
int y = sy + get_global_id(1);
|
|
|
|
|
|
|
|
if(x < sx + sw && y < sy + sh)
|
|
|
|
kernel_film_convert_to_byte(kg, rgba, buffer, sample_scale, x, y, offset, stride);
|
|
|
|
}
|
|
|
|
|
|
|
|
__kernel void kernel_ocl_convert_to_half_float(
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_constant KernelData *data,
|
|
|
|
ccl_global uchar4 *rgba,
|
|
|
|
ccl_global float *buffer,
|
2013-08-30 23:49:38 +00:00
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_global type *name,
|
2013-08-30 23:49:38 +00:00
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
|
|
|
float sample_scale,
|
2011-12-20 12:25:37 +00:00
|
|
|
int sx, int sy, int sw, int sh, int offset, int stride)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
KernelGlobals kglobals, *kg = &kglobals;
|
|
|
|
|
|
|
|
kg->data = data;
|
2011-05-20 12:26:01 +00:00
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
2011-11-22 13:15:19 +00:00
|
|
|
kg->name = name;
|
2011-05-20 12:26:01 +00:00
|
|
|
#include "kernel_textures.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
int x = sx + get_global_id(0);
|
|
|
|
int y = sy + get_global_id(1);
|
|
|
|
|
|
|
|
if(x < sx + sw && y < sy + sh)
|
2013-08-30 23:49:38 +00:00
|
|
|
kernel_film_convert_to_half_float(kg, rgba, buffer, sample_scale, x, y, offset, stride);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2013-06-21 13:05:08 +00:00
|
|
|
__kernel void kernel_ocl_shader(
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_constant KernelData *data,
|
|
|
|
ccl_global uint4 *input,
|
|
|
|
ccl_global float4 *output,
|
2013-06-21 13:05:08 +00:00
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_global type *name,
|
2013-06-21 13:05:08 +00:00
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
2014-06-06 12:40:09 +00:00
|
|
|
int type, int sx, int sw, int sample)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2013-06-21 13:05:08 +00:00
|
|
|
KernelGlobals kglobals, *kg = &kglobals;
|
|
|
|
|
|
|
|
kg->data = data;
|
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
|
|
|
kg->name = name;
|
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
int x = sx + get_global_id(0);
|
|
|
|
|
2013-06-21 13:05:08 +00:00
|
|
|
if(x < sx + sw)
|
2014-06-06 12:40:09 +00:00
|
|
|
kernel_shader_evaluate(kg, input, output, (ShaderEvalType)type, x, sample);
|
2013-06-21 13:05:08 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-05-27 11:20:07 +00:00
|
|
|
__kernel void kernel_ocl_bake(
|
|
|
|
ccl_constant KernelData *data,
|
|
|
|
ccl_global uint4 *input,
|
|
|
|
ccl_global float4 *output,
|
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
|
|
|
ccl_global type *name,
|
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
2014-06-06 12:40:09 +00:00
|
|
|
int type, int sx, int sw, int sample)
|
2014-05-27 11:20:07 +00:00
|
|
|
{
|
|
|
|
KernelGlobals kglobals, *kg = &kglobals;
|
|
|
|
|
|
|
|
kg->data = data;
|
|
|
|
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
|
|
|
kg->name = name;
|
|
|
|
#include "kernel_textures.h"
|
|
|
|
|
|
|
|
int x = sx + get_global_id(0);
|
|
|
|
|
|
|
|
if(x < sx + sw)
|
2014-06-06 12:40:09 +00:00
|
|
|
kernel_bake_evaluate(kg, input, output, (ShaderEvalType)type, x, sample);
|
2014-05-27 11:20:07 +00:00
|
|
|
}
|
|
|
|
|