blob: 0f84e4bb87b3b324dff8186b6bbe8f106cbd86b4 [file] [log] [blame]
Jason Samsaeb094b2010-05-18 13:35:45 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "rsContext.h"
18#include "rsScriptC.h"
19#include "rsMatrix.h"
Jason Samsaeb094b2010-05-18 13:35:45 -070020
Jason Samsaeb094b2010-05-18 13:35:45 -070021#include "utils/Timers.h"
22
23#define GL_GLEXT_PROTOTYPES
24
25#include <GLES/gl.h>
26#include <GLES/glext.h>
27#include <GLES2/gl2.h>
28#include <GLES2/gl2ext.h>
29
30#include <time.h>
31
32using namespace android;
33using namespace android::renderscript;
34
35#define GET_TLS() Context::ScriptTLSStruct * tls = \
36 (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \
37 Context * rsc = tls->mContext; \
38 ScriptC * sc = (ScriptC *) tls->mScript
39
40
41//////////////////////////////////////////////////////////////////////////////
Jason Samsaeb094b2010-05-18 13:35:45 -070042// Context
43//////////////////////////////////////////////////////////////////////////////
44
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080045static void SC_bindTexture(RsProgramFragment vpf, uint32_t slot, RsAllocation va) {
Jason Sams605048a2010-09-30 18:15:52 -070046 CHECK_OBJ_OR_NULL(va);
47 CHECK_OBJ(vpf);
Jason Samsaeb094b2010-05-18 13:35:45 -070048 GET_TLS();
49 rsi_ProgramBindTexture(rsc,
50 static_cast<ProgramFragment *>(vpf),
51 slot,
52 static_cast<Allocation *>(va));
Jason Samsaeb094b2010-05-18 13:35:45 -070053}
54
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080055static void SC_bindSampler(RsProgramFragment vpf, uint32_t slot, RsSampler vs) {
Jason Sams605048a2010-09-30 18:15:52 -070056 CHECK_OBJ_OR_NULL(vs);
57 CHECK_OBJ(vpf);
Jason Samsaeb094b2010-05-18 13:35:45 -070058 GET_TLS();
59 rsi_ProgramBindSampler(rsc,
60 static_cast<ProgramFragment *>(vpf),
61 slot,
62 static_cast<Sampler *>(vs));
Jason Samsaeb094b2010-05-18 13:35:45 -070063}
64
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080065static void SC_bindProgramStore(RsProgramStore pfs) {
Jason Sams605048a2010-09-30 18:15:52 -070066 CHECK_OBJ_OR_NULL(pfs);
Jason Samsaeb094b2010-05-18 13:35:45 -070067 GET_TLS();
68 rsi_ContextBindProgramStore(rsc, pfs);
69}
70
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080071static void SC_bindProgramFragment(RsProgramFragment pf) {
Jason Sams605048a2010-09-30 18:15:52 -070072 CHECK_OBJ_OR_NULL(pf);
Jason Samsaeb094b2010-05-18 13:35:45 -070073 GET_TLS();
74 rsi_ContextBindProgramFragment(rsc, pf);
75}
76
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080077static void SC_bindProgramVertex(RsProgramVertex pv) {
Jason Sams605048a2010-09-30 18:15:52 -070078 CHECK_OBJ_OR_NULL(pv);
Jason Samsaeb094b2010-05-18 13:35:45 -070079 GET_TLS();
80 rsi_ContextBindProgramVertex(rsc, pv);
81}
82
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080083static void SC_bindProgramRaster(RsProgramRaster pv) {
Jason Sams605048a2010-09-30 18:15:52 -070084 CHECK_OBJ_OR_NULL(pv);
Jason Samsaeb094b2010-05-18 13:35:45 -070085 GET_TLS();
86 rsi_ContextBindProgramRaster(rsc, pv);
87}
88
89//////////////////////////////////////////////////////////////////////////////
90// VP
91//////////////////////////////////////////////////////////////////////////////
92
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080093static void SC_vpLoadProjectionMatrix(const rsc_Matrix *m) {
Jim Millera490f102010-07-28 14:46:22 -070094 GET_TLS();
Jason Sams60709252010-11-17 15:29:32 -080095 rsc->getProgramVertex()->setProjectionMatrix(rsc, m);
Jim Millera490f102010-07-28 14:46:22 -070096}
97
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080098static void SC_vpLoadModelMatrix(const rsc_Matrix *m) {
Jason Samsaeb094b2010-05-18 13:35:45 -070099 GET_TLS();
Jason Sams60709252010-11-17 15:29:32 -0800100 rsc->getProgramVertex()->setModelviewMatrix(rsc, m);
Jason Samsaeb094b2010-05-18 13:35:45 -0700101}
102
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800103static void SC_vpLoadTextureMatrix(const rsc_Matrix *m) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700104 GET_TLS();
Jason Sams60709252010-11-17 15:29:32 -0800105 rsc->getProgramVertex()->setTextureMatrix(rsc, m);
Jason Samsaeb094b2010-05-18 13:35:45 -0700106}
107
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800108static void SC_pfConstantColor(RsProgramFragment vpf, float r, float g, float b, float a) {
Alex Sakhartchouk383e5b12010-09-23 16:16:33 -0700109 GET_TLS();
Jason Sams605048a2010-09-30 18:15:52 -0700110 CHECK_OBJ(vpf);
Jason Sams6445e522010-08-04 17:50:20 -0700111 ProgramFragment *pf = static_cast<ProgramFragment *>(vpf);
Alex Sakhartchouk383e5b12010-09-23 16:16:33 -0700112 pf->setConstantColor(rsc, r, g, b, a);
Jason Sams6445e522010-08-04 17:50:20 -0700113}
114
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800115static void SC_vpGetProjectionMatrix(rsc_Matrix *m) {
Alex Sakhartchouk95333f92010-08-16 17:40:10 -0700116 GET_TLS();
Jason Sams60709252010-11-17 15:29:32 -0800117 rsc->getProgramVertex()->getProjectionMatrix(rsc, m);
Alex Sakhartchouk95333f92010-08-16 17:40:10 -0700118}
119
Jason Samsaeb094b2010-05-18 13:35:45 -0700120//////////////////////////////////////////////////////////////////////////////
121// Drawing
122//////////////////////////////////////////////////////////////////////////////
123
Jason Samsaeb094b2010-05-18 13:35:45 -0700124static void SC_drawQuadTexCoords(float x1, float y1, float z1,
125 float u1, float v1,
126 float x2, float y2, float z2,
127 float u2, float v2,
128 float x3, float y3, float z3,
129 float u3, float v3,
130 float x4, float y4, float z4,
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800131 float u4, float v4) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700132 GET_TLS();
133 if (!rsc->setupCheck()) {
134 return;
135 }
136
137 //LOGE("Quad");
138 //LOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1);
139 //LOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2);
140 //LOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3);
141 //LOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4);
142
143 float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4};
144 const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4};
145
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -0800146 VertexArray::Attrib attribs[2];
147 attribs[0].set(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "ATTRIB_position");
148 attribs[1].set(GL_FLOAT, 2, 8, false, (uint32_t)tex, "ATTRIB_texture0");
149
150 VertexArray va(attribs, 2);
Jason Sams79f52df2010-06-01 15:47:01 -0700151 va.setupGL2(rsc, &rsc->mStateVertexArray, &rsc->mShaderCache);
Jason Samsaeb094b2010-05-18 13:35:45 -0700152
153 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
154}
155
156static void SC_drawQuad(float x1, float y1, float z1,
157 float x2, float y2, float z2,
158 float x3, float y3, float z3,
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800159 float x4, float y4, float z4) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700160 SC_drawQuadTexCoords(x1, y1, z1, 0, 1,
161 x2, y2, z2, 1, 1,
162 x3, y3, z3, 1, 0,
163 x4, y4, z4, 0, 0);
164}
165
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800166static void SC_drawSpriteScreenspace(float x, float y, float z, float w, float h) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700167 GET_TLS();
Jason Sams60709252010-11-17 15:29:32 -0800168 ObjectBaseRef<const ProgramVertex> tmp(rsc->getProgramVertex());
169 rsc->setProgramVertex(rsc->getDefaultProgramVertex());
Jason Samsaeb094b2010-05-18 13:35:45 -0700170 //rsc->setupCheck();
171
172 //GLint crop[4] = {0, h, w, -h};
173
174 float sh = rsc->getHeight();
175
176 SC_drawQuad(x, sh - y, z,
177 x+w, sh - y, z,
178 x+w, sh - (y+h), z,
179 x, sh - (y+h), z);
Jason Sams60709252010-11-17 15:29:32 -0800180 rsc->setProgramVertex((ProgramVertex *)tmp.get());
Jason Samsaeb094b2010-05-18 13:35:45 -0700181}
Jason Samsbdb04602010-06-17 18:05:38 -0700182/*
Jason Samsaeb094b2010-05-18 13:35:45 -0700183static void SC_drawSprite(float x, float y, float z, float w, float h)
184{
185 GET_TLS();
186 float vin[3] = {x, y, z};
187 float vout[4];
188
189 //LOGE("ds in %f %f %f", x, y, z);
190 rsc->getVertex()->transformToScreen(rsc, vout, vin);
191 //LOGE("ds out %f %f %f %f", vout[0], vout[1], vout[2], vout[3]);
192 vout[0] /= vout[3];
193 vout[1] /= vout[3];
194 vout[2] /= vout[3];
195
196 vout[0] *= rsc->getWidth() / 2;
197 vout[1] *= rsc->getHeight() / 2;
198 vout[0] += rsc->getWidth() / 2;
199 vout[1] += rsc->getHeight() / 2;
200
201 vout[0] -= w/2;
202 vout[1] -= h/2;
203
204 //LOGE("ds out2 %f %f %f", vout[0], vout[1], vout[2]);
205
206 // U, V, W, H
207 SC_drawSpriteScreenspace(vout[0], vout[1], z, h, w);
208 //rsc->setupCheck();
209}
Jason Samsbdb04602010-06-17 18:05:38 -0700210*/
Jason Samsaeb094b2010-05-18 13:35:45 -0700211
212static void SC_drawRect(float x1, float y1,
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800213 float x2, float y2, float z) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700214 //LOGE("SC_drawRect %f,%f %f,%f %f", x1, y1, x2, y2, z);
215 SC_drawQuad(x1, y2, z,
216 x2, y2, z,
217 x2, y1, z,
218 x1, y1, z);
219}
220
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800221static void SC_drawMesh(RsMesh vsm) {
Jason Sams605048a2010-09-30 18:15:52 -0700222 CHECK_OBJ(vsm);
Alex Sakhartchouk4e9a7a82010-07-01 16:14:06 -0700223 GET_TLS();
224 Mesh *sm = static_cast<Mesh *>(vsm);
Jason Samsaeb094b2010-05-18 13:35:45 -0700225 if (!rsc->setupCheck()) {
226 return;
227 }
228 sm->render(rsc);
229}
230
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800231static void SC_drawMeshPrimitive(RsMesh vsm, uint32_t primIndex) {
Jason Sams605048a2010-09-30 18:15:52 -0700232 CHECK_OBJ(vsm);
Jason Samsaeb094b2010-05-18 13:35:45 -0700233 GET_TLS();
Alex Sakhartchouk4e9a7a82010-07-01 16:14:06 -0700234 Mesh *sm = static_cast<Mesh *>(vsm);
Jason Samsaeb094b2010-05-18 13:35:45 -0700235 if (!rsc->setupCheck()) {
236 return;
237 }
Alex Sakhartchouk4e9a7a82010-07-01 16:14:06 -0700238 sm->renderPrimitive(rsc, primIndex);
239}
240
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800241static void SC_drawMeshPrimitiveRange(RsMesh vsm, uint32_t primIndex, uint32_t start, uint32_t len) {
Jason Sams605048a2010-09-30 18:15:52 -0700242 CHECK_OBJ(vsm);
Alex Sakhartchouk4e9a7a82010-07-01 16:14:06 -0700243 GET_TLS();
244 Mesh *sm = static_cast<Mesh *>(vsm);
245 if (!rsc->setupCheck()) {
246 return;
247 }
248 sm->renderPrimitiveRange(rsc, primIndex, start, len);
Jason Samsaeb094b2010-05-18 13:35:45 -0700249}
250
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800251static void SC_meshComputeBoundingBox(RsMesh vsm,
252 float *minX, float *minY, float *minZ,
253 float *maxX, float *maxY, float *maxZ) {
Jason Sams605048a2010-09-30 18:15:52 -0700254 CHECK_OBJ(vsm);
Alex Sakhartchoukba4aa5c2010-08-13 14:32:23 -0700255 GET_TLS();
256 Mesh *sm = static_cast<Mesh *>(vsm);
257 sm->computeBBox();
258 *minX = sm->mBBoxMin[0];
259 *minY = sm->mBBoxMin[1];
260 *minZ = sm->mBBoxMin[2];
261 *maxX = sm->mBBoxMax[0];
262 *maxY = sm->mBBoxMax[1];
263 *maxZ = sm->mBBoxMax[2];
264}
265
Jason Samsaeb094b2010-05-18 13:35:45 -0700266
267//////////////////////////////////////////////////////////////////////////////
268//
269//////////////////////////////////////////////////////////////////////////////
270
271
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800272static void SC_color(float r, float g, float b, float a) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700273 GET_TLS();
Jason Sams60709252010-11-17 15:29:32 -0800274 ProgramFragment *pf = (ProgramFragment *)rsc->getProgramFragment();
Alex Sakhartchouk383e5b12010-09-23 16:16:33 -0700275 pf->setConstantColor(rsc, r, g, b, a);
Jason Samsaeb094b2010-05-18 13:35:45 -0700276}
277
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800278static void SC_uploadToTexture2(RsAllocation va, uint32_t baseMipLevel) {
Jason Sams605048a2010-09-30 18:15:52 -0700279 CHECK_OBJ(va);
Jason Samsaeb094b2010-05-18 13:35:45 -0700280 GET_TLS();
281 rsi_AllocationUploadToTexture(rsc, va, false, baseMipLevel);
282}
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800283
284static void SC_uploadToTexture(RsAllocation va) {
Jason Sams605048a2010-09-30 18:15:52 -0700285 CHECK_OBJ(va);
Jason Sams22fa3712010-05-19 17:22:57 -0700286 GET_TLS();
287 rsi_AllocationUploadToTexture(rsc, va, false, 0);
288}
Jason Samsaeb094b2010-05-18 13:35:45 -0700289
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800290static void SC_uploadToBufferObject(RsAllocation va) {
Jason Sams605048a2010-09-30 18:15:52 -0700291 CHECK_OBJ(va);
Jason Samsaeb094b2010-05-18 13:35:45 -0700292 GET_TLS();
293 rsi_AllocationUploadToBufferObject(rsc, va);
294}
295
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800296static void SC_ClearColor(float r, float g, float b, float a) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700297 GET_TLS();
Alex Sakhartchouk889fe502010-10-01 10:54:06 -0700298 rsc->setupProgramStore();
Jason Sams22fa3712010-05-19 17:22:57 -0700299
300 glClearColor(r, g, b, a);
301 glClear(GL_COLOR_BUFFER_BIT);
302}
303
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800304static void SC_ClearDepth(float v) {
Jason Sams22fa3712010-05-19 17:22:57 -0700305 GET_TLS();
Alex Sakhartchouk889fe502010-10-01 10:54:06 -0700306 rsc->setupProgramStore();
Jason Sams22fa3712010-05-19 17:22:57 -0700307
308 glClearDepthf(v);
309 glClear(GL_DEPTH_BUFFER_BIT);
Jason Samsaeb094b2010-05-18 13:35:45 -0700310}
311
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800312static uint32_t SC_getWidth() {
Jason Samsaeb094b2010-05-18 13:35:45 -0700313 GET_TLS();
314 return rsc->getWidth();
315}
316
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800317static uint32_t SC_getHeight() {
Jason Samsaeb094b2010-05-18 13:35:45 -0700318 GET_TLS();
319 return rsc->getHeight();
320}
321
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800322static void SC_DrawTextAlloc(RsAllocation va, int x, int y) {
Jason Sams605048a2010-09-30 18:15:52 -0700323 CHECK_OBJ(va);
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700324 GET_TLS();
325 Allocation *alloc = static_cast<Allocation *>(va);
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700326 const char *text = (const char *)alloc->getPtr();
327 size_t allocSize = alloc->getType()->getSizeBytes();
328 rsc->mStateFont.renderText(text, allocSize, x, y);
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700329}
330
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800331static void SC_DrawText(const char *text, int x, int y) {
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700332 GET_TLS();
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700333 size_t textLen = strlen(text);
334 rsc->mStateFont.renderText(text, textLen, x, y);
335}
336
337static void SC_setMetrics(Font::Rect *metrics,
338 int32_t *left, int32_t *right,
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800339 int32_t *top, int32_t *bottom) {
340 if (left) {
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700341 *left = metrics->left;
342 }
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800343 if (right) {
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700344 *right = metrics->right;
345 }
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800346 if (top) {
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700347 *top = metrics->top;
348 }
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800349 if (bottom) {
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700350 *bottom = metrics->bottom;
351 }
352}
353
354static void SC_MeasureTextAlloc(RsAllocation va,
355 int32_t *left, int32_t *right,
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800356 int32_t *top, int32_t *bottom) {
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700357 CHECK_OBJ(va);
358 GET_TLS();
359 Allocation *alloc = static_cast<Allocation *>(va);
360 const char *text = (const char *)alloc->getPtr();
361 size_t textLen = alloc->getType()->getSizeBytes();
362 Font::Rect metrics;
363 rsc->mStateFont.measureText(text, textLen, &metrics);
364 SC_setMetrics(&metrics, left, right, top, bottom);
365}
366
367static void SC_MeasureText(const char *text,
368 int32_t *left, int32_t *right,
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800369 int32_t *top, int32_t *bottom) {
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700370 GET_TLS();
371 size_t textLen = strlen(text);
372 Font::Rect metrics;
373 rsc->mStateFont.measureText(text, textLen, &metrics);
374 SC_setMetrics(&metrics, left, right, top, bottom);
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700375}
376
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800377static void SC_BindFont(RsFont font) {
Jason Sams605048a2010-09-30 18:15:52 -0700378 CHECK_OBJ(font);
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700379 GET_TLS();
380 rsi_ContextBindFont(rsc, font);
381}
Jason Samsaeb094b2010-05-18 13:35:45 -0700382
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800383static void SC_FontColor(float r, float g, float b, float a) {
Alex Sakhartchouk9fc9f032010-08-04 14:45:48 -0700384 GET_TLS();
385 rsc->mStateFont.setFontColor(r, g, b, a);
386}
387
Jason Samsaeb094b2010-05-18 13:35:45 -0700388//////////////////////////////////////////////////////////////////////////////
389// Class implementation
390//////////////////////////////////////////////////////////////////////////////
391
392// llvm name mangling ref
393// <builtin-type> ::= v # void
394// ::= b # bool
395// ::= c # char
396// ::= a # signed char
397// ::= h # unsigned char
398// ::= s # short
399// ::= t # unsigned short
400// ::= i # int
401// ::= j # unsigned int
402// ::= l # long
403// ::= m # unsigned long
404// ::= x # long long, __int64
405// ::= y # unsigned long long, __int64
406// ::= f # float
407// ::= d # double
408
409static ScriptCState::SymbolTable_t gSyms[] = {
Jason Sams6bfc1b92010-11-01 14:26:30 -0700410 { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_bindProgramFragment, false },
411 { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_bindProgramStore, false },
412 { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_bindProgramVertex, false },
413 { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_bindProgramRaster, false },
414 { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_bindSampler, false },
415 { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_bindTexture, false },
Jason Sams22fa3712010-05-19 17:22:57 -0700416
Jason Sams6bfc1b92010-11-01 14:26:30 -0700417 { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_vpLoadProjectionMatrix, false },
418 { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_vpLoadModelMatrix, false },
419 { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_vpLoadTextureMatrix, false },
Jason Sams22fa3712010-05-19 17:22:57 -0700420
Jason Sams6bfc1b92010-11-01 14:26:30 -0700421 { "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", (void *)&SC_vpGetProjectionMatrix, false },
Alex Sakhartchouk95333f92010-08-16 17:40:10 -0700422
Jason Sams6bfc1b92010-11-01 14:26:30 -0700423 { "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", (void *)&SC_pfConstantColor, false },
Jason Sams6445e522010-08-04 17:50:20 -0700424
Jason Sams6bfc1b92010-11-01 14:26:30 -0700425 { "_Z11rsgGetWidthv", (void *)&SC_getWidth, false },
426 { "_Z12rsgGetHeightv", (void *)&SC_getHeight, false },
Jason Sams22fa3712010-05-19 17:22:57 -0700427
Jason Sams6bfc1b92010-11-01 14:26:30 -0700428 { "_Z18rsgUploadToTexture13rs_allocationj", (void *)&SC_uploadToTexture2, false },
429 { "_Z18rsgUploadToTexture13rs_allocation", (void *)&SC_uploadToTexture, false },
430 { "_Z23rsgUploadToBufferObject13rs_allocation", (void *)&SC_uploadToBufferObject, false },
Jason Sams22fa3712010-05-19 17:22:57 -0700431
Jason Sams6bfc1b92010-11-01 14:26:30 -0700432 { "_Z11rsgDrawRectfffff", (void *)&SC_drawRect, false },
433 { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_drawQuad, false },
434 { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_drawQuadTexCoords, false },
435 { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_drawSpriteScreenspace, false },
Jason Sams22fa3712010-05-19 17:22:57 -0700436
Jason Sams6bfc1b92010-11-01 14:26:30 -0700437 { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_drawMesh, false },
438 { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_drawMeshPrimitive, false },
439 { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_drawMeshPrimitiveRange, false },
440 { "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", (void *)&SC_meshComputeBoundingBox, false },
Alex Sakhartchouk4e9a7a82010-07-01 16:14:06 -0700441
Jason Sams6bfc1b92010-11-01 14:26:30 -0700442 { "_Z13rsgClearColorffff", (void *)&SC_ClearColor, false },
443 { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth, false },
Jason Sams22fa3712010-05-19 17:22:57 -0700444
Jason Sams6bfc1b92010-11-01 14:26:30 -0700445 { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText, false },
446 { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc, false },
447 { "_Z14rsgMeasureTextPKcPiS1_S1_S1_", (void *)&SC_MeasureText, false },
448 { "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", (void *)&SC_MeasureTextAlloc, false },
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700449
Jason Sams6bfc1b92010-11-01 14:26:30 -0700450 { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont, false },
451 { "_Z12rsgFontColorffff", (void *)&SC_FontColor, false },
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700452
Jason Samsaeb094b2010-05-18 13:35:45 -0700453 // misc
Jason Sams6bfc1b92010-11-01 14:26:30 -0700454 { "_Z5colorffff", (void *)&SC_color, false },
Jason Samsaeb094b2010-05-18 13:35:45 -0700455
Jason Sams6bfc1b92010-11-01 14:26:30 -0700456 { NULL, NULL, false }
Jason Samsaeb094b2010-05-18 13:35:45 -0700457};
458
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -0800459const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbolGL(const char *sym) {
Jason Samsaeb094b2010-05-18 13:35:45 -0700460 ScriptCState::SymbolTable_t *syms = gSyms;
461
462 while (syms->mPtr) {
463 if (!strcmp(syms->mName, sym)) {
464 return syms;
465 }
466 syms++;
467 }
468 return NULL;
469}
470