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.
24 #include "device_memory.h"
25 #include "device_task.h"
27 #include "util_list.h"
28 #include "util_stats.h"
29 #include "util_string.h"
30 #include "util_thread.h"
31 #include "util_types.h"
32 #include "util_vector.h"
57 bool advanced_shading;
59 vector<DeviceInfo> multi_devices;
66 display_device = false;
67 advanced_shading = true;
76 Device(Stats &stats_) : stats(stats_) {}
86 virtual const string& error_message() { return error_msg; }
92 virtual void mem_alloc(device_memory& mem, MemoryType type) = 0;
93 virtual void mem_copy_to(device_memory& mem) = 0;
94 virtual void mem_copy_from(device_memory& mem,
95 int y, int w, int h, int elem) = 0;
96 virtual void mem_zero(device_memory& mem) = 0;
97 virtual void mem_free(device_memory& mem) = 0;
100 virtual void const_copy_to(const char *name, void *host, size_t size) = 0;
103 virtual void tex_alloc(const char *name, device_memory& mem,
104 bool interpolation = false, bool periodic = false) {};
105 virtual void tex_free(device_memory& mem) {};
108 virtual void pixels_alloc(device_memory& mem);
109 virtual void pixels_copy_from(device_memory& mem, int y, int w, int h);
110 virtual void pixels_free(device_memory& mem);
112 /* open shading language, only for CPU device */
113 virtual void *osl_memory() { return NULL; }
115 /* load/compile kernels, must be called before adding tasks */
116 virtual bool load_kernels(bool experimental) { return true; }
119 virtual void task_add(DeviceTask& task) = 0;
120 virtual void task_wait() = 0;
121 virtual void task_cancel() = 0;
124 virtual void draw_pixels(device_memory& mem, int y, int w, int h,
125 int dy, int width, int height, bool transparent);
133 virtual void map_tile(Device *sub_device, RenderTile& tile) {}
134 virtual int device_number(Device *sub_device) { return 0; }
137 static Device *create(DeviceInfo& info, Stats &stats, bool background = true, int threads = 0);
139 static DeviceType type_from_string(const char *name);
140 static string string_from_type(DeviceType type);
141 static vector<DeviceType>& available_types();
142 static vector<DeviceInfo>& available_devices();
147 #endif /* __DEVICE_H__ */