2 * Copyright 2011, Blender Foundation.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 /* Constant Globals */
24 #include "osl_globals.h"
31 /* On the CPU, we pass along the struct KernelGlobals to nearly everywhere in
32 * the kernel, to access constant data. These are all stored as "textures", but
33 * these are really just standard arrays. We can't use actually globals because
34 * multiple renders may be running inside the same process. */
38 #define MAX_BYTE_IMAGES 512
39 #define MAX_FLOAT_IMAGES 5
41 typedef struct KernelGlobals {
42 texture_image_uchar4 texture_byte_images[MAX_BYTE_IMAGES];
43 texture_image_float4 texture_float_images[MAX_FLOAT_IMAGES];
45 #define KERNEL_TEX(type, ttype, name) ttype name;
46 #define KERNEL_IMAGE_TEX(type, ttype, name)
47 #include "kernel_textures.h"
52 /* On the CPU, we also have the OSL globals here. Most data structures are shared
53 * with SVM, the difference is in the shaders and object/mesh attributes. */
61 /* For CUDA, constant memory textures must be globals, so we can't put them
62 * into a struct. As a result we don't actually use this struct and use actual
63 * globals and simply pass along a NULL pointer everywhere, which we hope gets
66 #ifdef __KERNEL_CUDA__
68 __constant__ KernelData __data;
69 typedef struct KernelGlobals {} KernelGlobals;
71 #define KERNEL_TEX(type, ttype, name) ttype name;
72 #define KERNEL_IMAGE_TEX(type, ttype, name) ttype name;
73 #include "kernel_textures.h"
79 #ifdef __KERNEL_OPENCL__
81 typedef struct KernelGlobals {
82 __constant KernelData *data;
84 #define KERNEL_TEX(type, ttype, name) \
86 #include "kernel_textures.h"