1 // Copyright 2008 David Hilvert <dhilvert@auricle.dyndns.org>,
2 // <dhilvert@gmail.com>
4 /* This file is part of the Anti-Lamenessing Engine.
6 The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the Anti-Lamenessing Engine; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * gpu.h: Graphics processor management
42 #define ALE_GPU_ASSERT_INCLUDE \
43 "(ale-define-macro (assert expr) `(if (not ,expr) (ale-error \"Assertion failed: \" ,(object->string expr))))"
59 * Libale kernel module.
65 void attach_to_program(const program
*p
) const {
66 // ale_add_kernel_module(p->lk, lkm);
68 shader(const char *source
) {
69 // lkm = ale_new_kernel_module(accel::context(), source);
71 shader (const shader
&p
) {
74 shader
&operator=(const shader
&p
) {
79 // ale_delete_kernel_module(lkm);
92 * For libraries containing multiple shaders, or
93 * referencing shaders not stored locally, this
94 * method can be overridden.
96 virtual void attach_shaders(program
*p
) const {
99 p
->attach(gpu_shader
);
103 static void set_constant(const char *name
, int value
) {
106 * XXX: if possible, it would probably be better not to
107 * use this method, as it would require addition of
108 * constant handling to Libale.
114 program_buffer_size
++;
115 size_program_buffer();
117 const int line_length
= 1000;
119 char *program_line
= (char *) malloc(line_length
* sizeof(char));
120 assert(program_line
);
124 * XXX: This seems to generate link errors, for some reason.
126 snprintf(program_line
, line_length
, "const int %s = %d;\n", name
, value
);
128 snprintf(program_line
, line_length
, "#define %s %d\n", name
, value
);
131 program_buffer
[program_buffer_size
- 1] = program_line
;
136 // lk = ale_new_kernel(accel::context());
139 program (const program
&p
) {
143 program
&operator=(const program
&p
) {
148 // ale_delete_kernel(lk);
151 void attach(const shader
*s
) {
152 s
->attach_to_program(this);
155 void attach(const library
*l
) {
156 l
->attach_shaders(this);
160 // ale_link_kernel(lk);