mirror of
https://github.com/MobileGL-Dev/MobileGlues.git
synced 2025-09-24 19:52:49 -04:00
[Misc] (...): Changes for fpe.
This commit is contained in:
parent
9a879d228a
commit
a097855389
@ -53,6 +53,7 @@ add_library(${CMAKE_PROJECT_NAME} SHARED
|
|||||||
config/settings.cpp
|
config/settings.cpp
|
||||||
gl/glsl/glslconv_gl4es.cpp
|
gl/glsl/glslconv_gl4es.cpp
|
||||||
|
|
||||||
|
gl/gl4es/gl/vgpu/shaderconv.c
|
||||||
gl/gl4es/gl/string_utils.c
|
gl/gl4es/gl/string_utils.c
|
||||||
gl/gl4es/gl/arbconverter.c
|
gl/gl4es/gl/arbconverter.c
|
||||||
gl/gl4es/gl/arbgenerator.c
|
gl/gl4es/gl/arbgenerator.c
|
||||||
|
@ -350,6 +350,13 @@ EXPORT void glFramebufferTexture3DARB(GLenum target, GLenum attachment,
|
|||||||
EXPORT void glDrawBuffersARB(GLsizei n, const GLenum *bufs) {
|
EXPORT void glDrawBuffersARB(GLsizei n, const GLenum *bufs) {
|
||||||
glDrawBuffers(n, bufs);
|
glDrawBuffers(n, bufs);
|
||||||
}
|
}
|
||||||
|
EXPORT void glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget,
|
||||||
|
GLuint texture, GLint level) {
|
||||||
|
glFramebufferTexture2D(target, attachment, GL_TEXTURE_2D, texture, level);
|
||||||
|
}
|
||||||
|
EXPORT void glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget,
|
||||||
|
GLuint texture, GLint level, GLint zoffset) {
|
||||||
|
LOG()
|
||||||
|
GLES.glFramebufferTexture3DOES(target, attachment, textarget, texture, level, zoffset);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1497,7 +1497,7 @@ void APIENTRY_GL4ES gl4es_glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX
|
|||||||
memcpy(vp, &glstate->raster.viewport, sizeof(vp));
|
memcpy(vp, &glstate->raster.viewport, sizeof(vp));
|
||||||
gl4es_glViewport(0, 0, fbowidth, fboheight);
|
gl4es_glViewport(0, 0, fbowidth, fboheight);
|
||||||
// TODO: Handle the conflict between Core Profile with Compatibility Profile
|
// TODO: Handle the conflict between Core Profile with Compatibility Profile
|
||||||
gl4es_blitTexture(glname, srcX0, srcY0, srcW, srcH, nwidth, nheight, zoomx, zoomy, 0, 0, dstX0, dstY0, BLIT_OPAQUE);
|
//gl4es_blitTexture(glname, srcX0, srcY0, srcW, srcH, nwidth, nheight, zoomx, zoomy, 0, 0, dstX0, dstY0, BLIT_OPAQUE);
|
||||||
gl4es_glViewport(vp[0], vp[1], vp[2], vp[3]);
|
gl4es_glViewport(vp[0], vp[1], vp[2], vp[3]);
|
||||||
if(created) {
|
if(created) {
|
||||||
gl4es_glDeleteTextures(1, &texture);
|
gl4es_glDeleteTextures(1, &texture);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "loader.h"
|
#include "loader.h"
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "buffers.h"
|
#include "buffers.h"
|
||||||
|
#include "vgpu/shaderconv.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifdef _WINBASE_
|
#ifdef _WINBASE_
|
||||||
#define GSM_CAST(c) ((LPFILETIME)c)
|
#define GSM_CAST(c) ((LPFILETIME)c)
|
||||||
|
@ -122,6 +122,7 @@ static inline void errorGL() { // next glGetError will be from GL
|
|||||||
glstate->type_error = 1; // will need to read glGetError...
|
glstate->type_error = 1; // will need to read glGetError...
|
||||||
}
|
}
|
||||||
static inline void errorShim(GLenum error) { // next glGetError will be "error" from gl4es
|
static inline void errorShim(GLenum error) { // next glGetError will be "error" from gl4es
|
||||||
|
DBG(LOGD(" -> error set: %d", error))
|
||||||
if(glstate->type_error && glstate->shim_error==GL_NO_ERROR)
|
if(glstate->type_error && glstate->shim_error==GL_NO_ERROR)
|
||||||
glstate->type_error = 1;
|
glstate->type_error = 1;
|
||||||
if(glstate->shim_error == GL_NO_ERROR)
|
if(glstate->shim_error == GL_NO_ERROR)
|
||||||
|
@ -425,11 +425,14 @@ void initialize_gl4es() {
|
|||||||
globals4es.nointovlhack = 1;
|
globals4es.nointovlhack = 1;
|
||||||
SHUT_LOGD("MobileGlues-gl4es: No hack in shader converter to define overloaded function with int\n");
|
SHUT_LOGD("MobileGlues-gl4es: No hack in shader converter to define overloaded function with int\n");
|
||||||
}
|
}
|
||||||
|
globals4es.nointovlhack = 1;
|
||||||
if(GL4ES_IsEnvVarTrue("LIBGL_NOSHADERLOD")) {
|
if(GL4ES_IsEnvVarTrue("LIBGL_NOSHADERLOD")) {
|
||||||
globals4es.noshaderlod = 1;
|
globals4es.noshaderlod = 1;
|
||||||
SHUT_LOGD("MobileGlues-gl4es: No GL_EXT_shader_texture_lod used even if present\n");
|
SHUT_LOGD("MobileGlues-gl4es: No GL_EXT_shader_texture_lod used even if present\n");
|
||||||
hardext.shaderlod=0;
|
hardext.shaderlod=0;
|
||||||
}
|
}
|
||||||
|
hardext.shaderlod=0;
|
||||||
|
globals4es.noshaderlod = 1;
|
||||||
|
|
||||||
int env_begin_end;
|
int env_begin_end;
|
||||||
if(GL4ES_GetEnvVarInt("LIBGL_BEGINEND",&env_begin_end,0)) {
|
if(GL4ES_GetEnvVarInt("LIBGL_BEGINEND",&env_begin_end,0)) {
|
||||||
@ -618,7 +621,7 @@ void initialize_gl4es() {
|
|||||||
env(LIBGL_SHADERNOGLES, globals4es.shadernogles, "Remove GLES part in shader");
|
env(LIBGL_SHADERNOGLES, globals4es.shadernogles, "Remove GLES part in shader");
|
||||||
env(LIBGL_NOES2COMPAT, globals4es.noes2, "Don't expose GLX_EXT_create_context_es2_profile extension");
|
env(LIBGL_NOES2COMPAT, globals4es.noes2, "Don't expose GLX_EXT_create_context_es2_profile extension");
|
||||||
env(LIBGL_NORMALIZE, globals4es.normalize, "Force normals to be normalized on FPE shaders");
|
env(LIBGL_NORMALIZE, globals4es.normalize, "Force normals to be normalized on FPE shaders");
|
||||||
|
globals4es.normalize=1;
|
||||||
globals4es.dbgshaderconv=GL4ES_ReturnEnvVarIntDef("LIBGL_DBGSHADERCONV",0);
|
globals4es.dbgshaderconv=GL4ES_ReturnEnvVarIntDef("LIBGL_DBGSHADERCONV",0);
|
||||||
if(globals4es.dbgshaderconv) {
|
if(globals4es.dbgshaderconv) {
|
||||||
if(globals4es.dbgshaderconv==1)
|
if(globals4es.dbgshaderconv==1)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "shaderconv.h"
|
#include "shaderconv.h"
|
||||||
#include "fpe_shader.h"
|
#include "fpe_shader.h"
|
||||||
|
|
||||||
//#define DEBUG
|
#define DEBUG
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DBG(a) a
|
#define DBG(a) a
|
||||||
#else
|
#else
|
||||||
@ -46,11 +46,12 @@ void APIENTRY_GL4ES gl4es_glAttachShader(GLuint program, GLuint shader) {
|
|||||||
// send to hadware
|
// send to hadware
|
||||||
LOAD_GLES2(glAttachShader);
|
LOAD_GLES2(glAttachShader);
|
||||||
if(gl4es_gles_glAttachShader) {
|
if(gl4es_gles_glAttachShader) {
|
||||||
if(strstr((glshader->converted)?glshader->converted:glshader->source, "FPE")!=NULL) {
|
if(glshader->is_gl4es_conv_shader) {
|
||||||
gl4es_gles_glAttachShader(glprogram->id, glshader->id);
|
// gl4es_gles_glAttachShader(glprogram->id, glshader->id);
|
||||||
|
gl4es_gles_glAttachShader(program, glshader->id);
|
||||||
|
// use fronted program id?
|
||||||
}
|
}
|
||||||
|
|
||||||
{} //STUB of gl4es_gles_glAttachShader(glprogram->id, glshader->id);
|
|
||||||
errorGL();
|
errorGL();
|
||||||
} else
|
} else
|
||||||
noerrorShim();
|
noerrorShim();
|
||||||
@ -795,10 +796,8 @@ void APIENTRY_GL4ES gl4es_glLinkProgram(GLuint program) {
|
|||||||
if(gl4es_gles_glLinkProgram) {
|
if(gl4es_gles_glLinkProgram) {
|
||||||
LOAD_GLES(glGetError);
|
LOAD_GLES(glGetError);
|
||||||
LOAD_GLES2(glGetProgramiv);
|
LOAD_GLES2(glGetProgramiv);
|
||||||
if(strstr((glprogram->last_vert->converted)?glprogram->last_vert->converted:glprogram->last_vert->source, "FPE")!=NULL) {
|
|
||||||
gl4es_gles_glLinkProgram(glprogram->id);
|
gl4es_gles_glLinkProgram(glprogram->id);
|
||||||
}
|
|
||||||
{} //STUB of gl4es_gles_glLinkProgram(glprogram->id);
|
|
||||||
GLenum err = gl4es_gles_glGetError();
|
GLenum err = gl4es_gles_glGetError();
|
||||||
// Get Link Status
|
// Get Link Status
|
||||||
gl4es_gles_glGetProgramiv(glprogram->id, GL_LINK_STATUS, &glprogram->linked);
|
gl4es_gles_glGetProgramiv(glprogram->id, GL_LINK_STATUS, &glprogram->linked);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "loader.h"
|
#include "loader.h"
|
||||||
#include "shaderconv.h"
|
#include "shaderconv.h"
|
||||||
|
|
||||||
//#define DEBUG
|
#define DEBUG
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DBG(a) a
|
#define DBG(a) a
|
||||||
#else
|
#else
|
||||||
@ -110,7 +110,8 @@ void APIENTRY_GL4ES gl4es_glDeleteShader(GLuint shader) {
|
|||||||
LOAD_GLES2(glDeleteShader);
|
LOAD_GLES2(glDeleteShader);
|
||||||
if(gl4es_gles_glDeleteShader) {
|
if(gl4es_gles_glDeleteShader) {
|
||||||
errorGL();
|
errorGL();
|
||||||
{} //STUB of gl4es_gles_glDeleteShader(shader);
|
if(glshader->is_gl4es_conv_shader)
|
||||||
|
gl4es_gles_glDeleteShader(shader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,10 +124,8 @@ void APIENTRY_GL4ES gl4es_glCompileShader(GLuint shader) {
|
|||||||
glshader->compiled = 1;
|
glshader->compiled = 1;
|
||||||
LOAD_GLES2(glCompileShader);
|
LOAD_GLES2(glCompileShader);
|
||||||
if(gl4es_gles_glCompileShader) {
|
if(gl4es_gles_glCompileShader) {
|
||||||
{} //STUB of gl4es_gles_glCompileShader(glshader->id);
|
|
||||||
if(strstr((glshader->converted)?glshader->converted:glshader->source, "FPE")!=NULL) {
|
|
||||||
gl4es_gles_glCompileShader(glshader->id);
|
gl4es_gles_glCompileShader(glshader->id);
|
||||||
}
|
|
||||||
errorGL();
|
errorGL();
|
||||||
if(globals4es.logshader) {
|
if(globals4es.logshader) {
|
||||||
// get compile status and print shaders sources if compile fail...
|
// get compile status and print shaders sources if compile fail...
|
||||||
@ -178,9 +177,15 @@ void APIENTRY_GL4ES gl4es_glShaderSource(GLuint shader, GLsizei count, const GLc
|
|||||||
if(glstate->glsl->es2 && !strncmp(glshader->source, "#version 100", 12))
|
if(glstate->glsl->es2 && !strncmp(glshader->source, "#version 100", 12))
|
||||||
glshader->converted = strdup(glshader->source);
|
glshader->converted = strdup(glshader->source);
|
||||||
else
|
else
|
||||||
glshader->converted = ConvertShader(glshader->source, glshader->type==GL_VERTEX_SHADER?1:0, &glshader->need);
|
glshader->converted = strdup(ConvertShaderConditionally(glshader));
|
||||||
// send source to GLES2 hardware if any
|
// send source to GLES2 hardware if any
|
||||||
if(strstr((glshader->converted)?glshader->converted:glshader->source, "FPE")!=NULL) {
|
int getGLSLVersion(const char* glsl_code);
|
||||||
|
SHUT_LOGD("shader version: %d",getGLSLVersion(glshader->source))
|
||||||
|
SHUT_LOGD("\nshader source: %s\n",glshader->source)
|
||||||
|
glshader->is_gl4es_conv_shader=0;
|
||||||
|
if(getGLSLVersion(glshader->source) < 140 || strstr((glshader->converted)?glshader->converted:glshader->source, "FPE")!=NULL) {
|
||||||
|
glshader->is_gl4es_conv_shader=1;
|
||||||
|
SHUT_LOGD("\nconverted and used in gl4es:\n%s\n",glshader->converted);
|
||||||
gl4es_gles_glShaderSource(shader, 1, (const GLchar * const*)((glshader->converted)?(&glshader->converted):(&glshader->source)), NULL);
|
gl4es_gles_glShaderSource(shader, 1, (const GLchar * const*)((glshader->converted)?(&glshader->converted):(&glshader->source)), NULL);
|
||||||
}
|
}
|
||||||
errorGL();
|
errorGL();
|
||||||
@ -237,7 +242,7 @@ void redoShader(GLuint shader, shaderconv_need_t *need) {
|
|||||||
return;
|
return;
|
||||||
free(glshader->converted);
|
free(glshader->converted);
|
||||||
memcpy(&glshader->need, need, sizeof(shaderconv_need_t));
|
memcpy(&glshader->need, need, sizeof(shaderconv_need_t));
|
||||||
glshader->converted = ConvertShader(glshader->source, glshader->type==GL_VERTEX_SHADER?1:0, &glshader->need);
|
glshader->converted = ConvertShaderConditionally(glshader);
|
||||||
// send source to GLES2 hardware if any
|
// send source to GLES2 hardware if any
|
||||||
gl4es_gles_glShaderSource(shader, 1, (const GLchar * const*)((glshader->converted)?(&glshader->converted):(&glshader->source)), NULL);
|
gl4es_gles_glShaderSource(shader, 1, (const GLchar * const*)((glshader->converted)?(&glshader->converted):(&glshader->source)), NULL);
|
||||||
// recompile...
|
// recompile...
|
||||||
|
@ -35,6 +35,7 @@ struct shader_s {
|
|||||||
char* converted; // converted source (or null if nothing)
|
char* converted; // converted source (or null if nothing)
|
||||||
// shaderconv
|
// shaderconv
|
||||||
shaderconv_need_t need; // the varying need / provide of the shader
|
shaderconv_need_t need; // the varying need / provide of the shader
|
||||||
|
int is_gl4es_conv_shader;
|
||||||
}; // shader_t defined in oldprogram.h
|
}; // shader_t defined in oldprogram.h
|
||||||
|
|
||||||
KHASH_MAP_DECLARE_INT(shaderlist, struct shader_s *);
|
KHASH_MAP_DECLARE_INT(shaderlist, struct shader_s *);
|
||||||
|
@ -263,15 +263,8 @@ static const char* gl4es_ftransformSource =
|
|||||||
" return gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
" return gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
static const char* gl4es_ClipVertex =
|
static const char* gl4es_dummyClipVertex =
|
||||||
"vec4 gl4es_ClipVertex;\n";
|
"vec4 dummyClipVertex_%d";
|
||||||
|
|
||||||
static const char* gl4es_ClipVertexSource =
|
|
||||||
"gl4es_ClipVertex";
|
|
||||||
|
|
||||||
static const char* gl4es_ClipVertex_clip =
|
|
||||||
"\nif(any(lessThanEqual(gl4es_ClipVertex.xyz, vec3(-gl4es_ClipVertex.w)))"
|
|
||||||
" || any(greaterThanEqual(gl4es_ClipVertex.xyz, vec3(gl4es_ClipVertex.w)))) discard;\n";
|
|
||||||
|
|
||||||
static const char* gl_TexCoordSource = "gl_TexCoord[";
|
static const char* gl_TexCoordSource = "gl_TexCoord[";
|
||||||
|
|
||||||
@ -285,25 +278,26 @@ static const char* gl_TexMatrixSources[] = {
|
|||||||
static const char* GLESHeader[] = {
|
static const char* GLESHeader[] = {
|
||||||
"#version 100\n%sprecision %s float;\nprecision %s int;\n",
|
"#version 100\n%sprecision %s float;\nprecision %s int;\n",
|
||||||
"#version 120\n%sprecision %s float;\nprecision %s int;\n",
|
"#version 120\n%sprecision %s float;\nprecision %s int;\n",
|
||||||
"#version 310 es\n#define attribute in\n#define varying out\n%sprecision %s float;\nprecision %s int;\n",
|
"#version 310 es\n%sprecision %s float;\nprecision %s int;\n",
|
||||||
"#version 300 es\n#define attribute in\n#define varying out\n%sprecision %s float;\nprecision %s int;\n"
|
"#version 300 es\n%sprecision %s float;\nprecision %s int;\n",
|
||||||
|
"#version 320 es\n%sprecision %s float;\nprecision %s int;\n"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* gl4es_transpose =
|
static const char* gl4es_transpose =
|
||||||
"mat2 gl4es_transpose(mat2 m) {\n"
|
"mat2 gl4es_transpose(mat2 m) {\n"
|
||||||
" return mat2(m[0][0], m[1][0],\n"
|
" return mat2(m[0][0], m[0][1],\n"
|
||||||
" m[0][1], m[1][1]);\n"
|
" m[1][0], m[1][1]);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"mat3 gl4es_transpose(mat3 m) {\n"
|
"mat3 gl4es_transpose(mat3 m) {\n"
|
||||||
" return mat3(m[0][0], m[1][0], m[2][0],\n"
|
" return mat3(m[0][0], m[0][1], m[0][2],\n"
|
||||||
" m[0][1], m[1][1], m[2][1],\n"
|
" m[1][0], m[1][1], m[1][2],\n"
|
||||||
" m[0][2], m[1][2], m[2][2]);\n"
|
" m[2][0], m[2][1], m[2][2]);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"mat4 gl4es_transpose(mat4 m) {\n"
|
"mat4 gl4es_transpose(mat4 m) {\n"
|
||||||
" return mat4(m[0][0], m[1][0], m[2][0], m[3][0],\n"
|
" return mat4(m[0][0], m[0][1], m[0][2], m[0][3],\n"
|
||||||
" m[0][1], m[1][1], m[2][1], m[3][1],\n"
|
" m[1][0], m[1][1], m[1][2], m[1][3],\n"
|
||||||
" m[0][2], m[1][2], m[2][2], m[3][2],\n"
|
" m[2][0], m[2][1], m[2][2], m[2][3],\n"
|
||||||
" m[0][3], m[1][3], m[2][3], m[3][3]);\n"
|
" m[3][0], m[3][1], m[3][2], m[3][3]);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
static const char* HackAltPow =
|
static const char* HackAltPow =
|
||||||
@ -437,10 +431,34 @@ static const char* gl4es_VertexAttrib = "_gl4es_VertexAttrib_";
|
|||||||
char gl_VA[MAX_VATTRIB][32] = {0};
|
char gl_VA[MAX_VATTRIB][32] = {0};
|
||||||
char gl4es_VA[MAX_VATTRIB][32] = {0};
|
char gl4es_VA[MAX_VATTRIB][32] = {0};
|
||||||
|
|
||||||
char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
void AppendToEnd(char **str, const char *suffix);
|
||||||
{
|
void InsertAtBeginning(char **str, const char *prefix);
|
||||||
#define ShadAppend(S) Tmp = gl4es_append(Tmp, &tmpsize, S)
|
|
||||||
|
|
||||||
|
char * InplaceReplaceByIndex(char* pBuffer, int* size, int startIndex, int endIndex, const char* replacement);
|
||||||
|
char * InplaceInsertByIndex(char * source, int *sourceLength, int insertPoint, const char *insertedString);
|
||||||
|
|
||||||
|
extern const char* FindString(const char* pBuffer, const char* S);
|
||||||
|
extern char* FindStringNC(char* pBuffer, const char* S);
|
||||||
|
extern int CountString(const char* pBuffer, const char* S);
|
||||||
|
extern char* ResizeIfNeeded(char* pBuffer, int *size, int addsize);
|
||||||
|
extern char* InplaceReplace(char* pBuffer, int* size, const char* S, const char* D);
|
||||||
|
extern char* Append(char* pBuffer, int* size, const char* S);
|
||||||
|
extern char* InplaceInsert(char* pBuffer, const char* S, char* master, int* size);
|
||||||
|
extern char* GetLine(char* pBuffer, int num);
|
||||||
|
extern int CountLine(const char* pBuffer);
|
||||||
|
extern int GetLineFor(const char* pBuffer, const char* S);
|
||||||
|
extern char* StrNext(char *pBuffer, const char* S);
|
||||||
|
extern char* NextStr(char* pBuffer);
|
||||||
|
extern char* PrevStr(char* Str, char* pBuffer);
|
||||||
|
extern char* NextBlank(char* pBuffer);
|
||||||
|
extern char* NextLine(char* pBuffer);
|
||||||
|
extern const char* GetNextStr(char* pBuffer);
|
||||||
|
extern int CountStringSimple(char* pBuffer, const char* S);
|
||||||
|
extern char* InplaceReplaceSimple(char* pBuffer, int* size, const char* S, const char* D);
|
||||||
|
|
||||||
|
|
||||||
|
char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need, int forwardPort)
|
||||||
|
{
|
||||||
if(gl_VA[0][0]=='\0') {
|
if(gl_VA[0][0]=='\0') {
|
||||||
for (int i=0; i<MAX_VATTRIB; ++i) {
|
for (int i=0; i<MAX_VATTRIB; ++i) {
|
||||||
sprintf(gl_VA[i], "%s%d", gl_VertexAttrib, i);
|
sprintf(gl_VA[i], "%s%d", gl_VertexAttrib, i);
|
||||||
@ -451,7 +469,7 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
int maskbefore = 4|(isVertex?1:2);
|
int maskbefore = 4|(isVertex?1:2);
|
||||||
int maskafter = 8|(isVertex?1:2);
|
int maskafter = 8|(isVertex?1:2);
|
||||||
if((globals4es.dbgshaderconv&maskbefore)==maskbefore) {
|
if((globals4es.dbgshaderconv&maskbefore)==maskbefore) {
|
||||||
SHUT_LOGD("MobileGlues-gl4es: Shader source%s:\n%s\n", fpeShader?" (FPEShader generated)":"", pEntry);
|
printf("Shader source%s:\n%s\n", pEntry, fpeShader?" (FPEShader generated)":"");
|
||||||
}
|
}
|
||||||
int comments = globals4es.comments;
|
int comments = globals4es.comments;
|
||||||
|
|
||||||
@ -472,7 +490,7 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
// now comment all line starting with precision...
|
// now comment all line starting with precision...
|
||||||
if(strstr(pBuffer, "\nprecision")) {
|
if(strstr(pBuffer, "\nprecision")) {
|
||||||
int sz = strlen(pBuffer);
|
int sz = strlen(pBuffer);
|
||||||
pBuffer = gl4es_inplace_replace(pBuffer, &sz, "\nprecision", "\n//precision");
|
pBuffer = InplaceReplace(pBuffer, &sz, "\nprecision", "\n//precision");
|
||||||
}
|
}
|
||||||
// should do something with the extension list...
|
// should do something with the extension list...
|
||||||
if(exts.ext)
|
if(exts.ext)
|
||||||
@ -487,25 +505,21 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
}
|
}
|
||||||
int notexarray = globals4es.notexarray || need->need_notexarray || fpeShader;
|
int notexarray = globals4es.notexarray || need->need_notexarray || fpeShader;
|
||||||
|
|
||||||
//const char* GLESUseFragHighp = "#extension GL_OES_fragment_precision_high : enable\n"; // is this needed?
|
//const char* GLESUseFragHighp = "#extension GL_OES_fragment_precision_high : enable\n"; // does this one is needed?
|
||||||
char GLESFullHeader[512];
|
char GLESFullHeader[512];
|
||||||
int wanthighp = !fpeShader;
|
int wanthighp = !fpeShader;
|
||||||
if(wanthighp && !hardext.highp) wanthighp = 0;
|
if(wanthighp && !hardext.highp) wanthighp = 0;
|
||||||
int versionHeader = 0;
|
int versionHeader = 0;
|
||||||
#if 0
|
printf("version string: %s", versionString);
|
||||||
// support for higher glsl require much more work
|
if(versionString && (strcmp(versionString, "120")==0 || strcmp(versionString, "110")==0 || strstr(versionString, "150") != NULL))
|
||||||
// around some keyword
|
version120 = forwardPort ? 1 : 0;
|
||||||
// like in/out that depends on the shader being vertex or fragment
|
|
||||||
// and a few other little things...
|
|
||||||
if(versionString && strcmp(versionString, "120")==0)
|
|
||||||
version120 = 1;
|
|
||||||
if(version120) {
|
if(version120) {
|
||||||
if(hardext.glsl120) versionHeader = 1;
|
if(hardext.glsl120) versionHeader = 1;
|
||||||
|
else if(1) versionHeader = 4;
|
||||||
else if(hardext.glsl310es) versionHeader = 2;
|
else if(hardext.glsl310es) versionHeader = 2;
|
||||||
else if(hardext.glsl300es) { versionHeader = 3; /* location on uniform not supported ! */ }
|
else if(hardext.glsl300es) { versionHeader = 3; /* location on uniform not supported ! */ }
|
||||||
/* else no location or in / out are supported */
|
/* else no location or in / out are supported */
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
//sprintf(GLESFullHeader, GLESHeader, (wanthighp && hardext.highp==1 && !isVertex)?GLESUseFragHighp:"", (wanthighp)?"highp":"mediump", (wanthighp)?"highp":"mediump");
|
//sprintf(GLESFullHeader, GLESHeader, (wanthighp && hardext.highp==1 && !isVertex)?GLESUseFragHighp:"", (wanthighp)?"highp":"mediump", (wanthighp)?"highp":"mediump");
|
||||||
sprintf(GLESFullHeader, GLESHeader[versionHeader], "", (wanthighp)?"highp":"mediump", (wanthighp)?"highp":"mediump");
|
sprintf(GLESFullHeader, GLESHeader[versionHeader], "", (wanthighp)?"highp":"mediump", (wanthighp)?"highp":"mediump");
|
||||||
|
|
||||||
@ -517,28 +531,20 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
char* newptr;
|
char* newptr;
|
||||||
newptr=strstr(Tmp, "#version");
|
newptr=strstr(Tmp, "#version");
|
||||||
if (!newptr) {
|
if (!newptr) {
|
||||||
Tmp = gl4es_inplace_insert(Tmp, GLESFullHeader, Tmp, &tmpsize);
|
Tmp = InplaceInsert(Tmp, GLESFullHeader, Tmp, &tmpsize);
|
||||||
} else {
|
} else {
|
||||||
while(*newptr!=0x0a) newptr++;
|
while(*newptr!=0x0a) newptr++;
|
||||||
newptr++;
|
newptr++;
|
||||||
memmove(Tmp, newptr, strlen(newptr)+1);
|
memmove(Tmp, newptr, strlen(newptr)+1);
|
||||||
Tmp = gl4es_inplace_insert(Tmp, GLESFullHeader, Tmp, &tmpsize);
|
Tmp = InplaceInsert(Tmp, GLESFullHeader, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
int headline = 3;
|
int headline = 3;
|
||||||
// move all "#extension in header zone"
|
int texture3D = (strstr(pBuffer, "texture3D")) ? 1 : 0;
|
||||||
while (strstr(Tmp, "#extension") && strstr(Tmp, "#extension")>gl4es_getline(Tmp, headline-2)) {
|
const char* GLESUseTexture3D = "#extension GL_OES_texture_3D : enable\nprecision lowp sampler3D;\n";
|
||||||
char* ext = strstr(Tmp, "#extension");
|
if (texture3D)
|
||||||
size_t l = (uintptr_t)strstr(ext, "\n")-(uintptr_t)ext + sizeof("\n");
|
{
|
||||||
#ifndef _MSC_VER
|
Tmp = InplaceInsert(GetLine(Tmp, 1), GLESUseTexture3D, Tmp, &tmpsize);
|
||||||
char e[l];
|
headline++;
|
||||||
#else
|
|
||||||
char* e = _alloca(l);
|
|
||||||
#endif
|
|
||||||
memset(e, 0, l);
|
|
||||||
strncpy(e, ext, l-1);
|
|
||||||
Tmp = gl4es_inplace_replace_simple(Tmp, &tmpsize, e, "");
|
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline-2), e, Tmp, &tmpsize);
|
|
||||||
++headline;
|
|
||||||
}
|
}
|
||||||
// check if gl_FragDepth is used
|
// check if gl_FragDepth is used
|
||||||
int fragdepth = (strstr(pBuffer, "gl_FragDepth"))?1:0;
|
int fragdepth = (strstr(pBuffer, "gl_FragDepth"))?1:0;
|
||||||
@ -547,17 +553,17 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
if (fragdepth) {
|
if (fragdepth) {
|
||||||
/* If #extension is used, it should be placed before the second line of the header. */
|
/* If #extension is used, it should be placed before the second line of the header. */
|
||||||
if(hardext.fragdepth)
|
if(hardext.fragdepth)
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 1), GLESUseFragDepth, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, 1), GLESUseFragDepth, Tmp, &tmpsize);
|
||||||
else
|
else
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline-1), GLESFakeFragDepth, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline-1), GLESFakeFragDepth, Tmp, &tmpsize);
|
||||||
headline++;
|
headline++;
|
||||||
}
|
}
|
||||||
|
// check if the shader uses 3D textures
|
||||||
const char* GLESUseShaderNonConstantGlobalInitialzers = "#extension GL_EXT_shader_non_constant_global_initializers : enable\n";
|
int threed_texture = (strstr(pBuffer, "sampler3D"))?1:0;
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 1), GLESUseShaderNonConstantGlobalInitialzers, Tmp, &tmpsize);
|
const char* GLESUse3DTexture = "#extension GL_OES_texture_3D : enable\n";
|
||||||
++headline;
|
if(threed_texture) {
|
||||||
|
Tmp = InplaceInsert(GetLine(Tmp, 1), GLESUse3DTexture, Tmp, &tmpsize); // no fallback possible if device does not support 3D textures
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline-1), "#define GL4ES\n", Tmp, &tmpsize);
|
}
|
||||||
|
|
||||||
int derivatives = (strstr(pBuffer, "dFdx(") || strstr(pBuffer, "dFdy(") || strstr(pBuffer, "fwidth("))?1:0;
|
int derivatives = (strstr(pBuffer, "dFdx(") || strstr(pBuffer, "dFdy(") || strstr(pBuffer, "fwidth("))?1:0;
|
||||||
const char* GLESUseDerivative = "#extension GL_OES_standard_derivatives : enable\n";
|
const char* GLESUseDerivative = "#extension GL_OES_standard_derivatives : enable\n";
|
||||||
@ -569,105 +575,91 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
if (derivatives) {
|
if (derivatives) {
|
||||||
/* If #extension is used, it should be placed before the second line of the header. */
|
/* If #extension is used, it should be placed before the second line of the header. */
|
||||||
if(hardext.derivatives)
|
if(hardext.derivatives)
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 1), GLESUseDerivative, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, 1), GLESUseDerivative, Tmp, &tmpsize);
|
||||||
else
|
else
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline-1), GLESFakeDerivative, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline-1), GLESFakeDerivative, Tmp, &tmpsize);
|
||||||
headline++;
|
headline++;
|
||||||
}
|
}
|
||||||
// check if draw_buffers may be used (no fallback here :( )
|
// check if draw_buffers may be used (no fallback here :( )
|
||||||
if(hardext.maxdrawbuffers>1 && strstr(pBuffer, "gl_FragData[")) {
|
if(hardext.maxdrawbuffers>1 && strstr(pBuffer, "gl_FragData[")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 1), useEXTDrawBuffers, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, 1), useEXTDrawBuffers, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
// if some functions are used, add some int/float alternative
|
// if some functions are used, add some int/float alternative
|
||||||
if(!fpeShader && !globals4es.nointovlhack) {
|
if(!fpeShader && !globals4es.nointovlhack) {
|
||||||
if(strstr(Tmp, "pow(") || strstr(Tmp, "pow (")) {
|
if(strstr(Tmp, "pow(") || strstr(Tmp, "pow (")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), HackAltPow, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), HackAltPow, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "max(") || strstr(Tmp, "max (")) {
|
if(strstr(Tmp, "max(") || strstr(Tmp, "max (")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), HackAltMax, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), HackAltMax, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "min(") || strstr(Tmp, "min (")) {
|
if(strstr(Tmp, "min(") || strstr(Tmp, "min (")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), HackAltMin, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), HackAltMin, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "clamp(") || strstr(Tmp, "clamp (")) {
|
if(strstr(Tmp, "clamp(") || strstr(Tmp, "clamp (")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), HackAltClamp, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), HackAltClamp, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "mod(") || strstr(Tmp, "mod (")) {
|
if(strstr(Tmp, "mod(") || strstr(Tmp, "mod (")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), HackAltMod, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), HackAltMod, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isVertex && hardext.shaderlod &&
|
if(!isVertex && hardext.shaderlod &&
|
||||||
(gl4es_find_string(Tmp, "texture2DLod") || gl4es_find_string(Tmp, "texture2DProjLod")
|
(FindString(Tmp, "tLod") || FindString(Tmp, "texture2DProjLod")
|
||||||
|| gl4es_find_string(Tmp, "textureCubeLod")
|
|| FindString(Tmp, "textureCubeLod")
|
||||||
|| gl4es_find_string(Tmp, "texture2DGradARB") || gl4es_find_string(Tmp, "texture2DProjGradARB")|| gl4es_find_string(Tmp, "textureCubeGradARB")
|
|| FindString(Tmp, "texture2DGradARB") || FindString(Tmp, "texture2DProjGradARB")|| FindString(Tmp, "textureCubeGradARB")
|
||||||
)) {
|
)) {
|
||||||
const char* GLESUseShaderLod = "#extension GL_EXT_shader_texture_lod : enable\n";
|
const char* GLESUseShaderLod = "#extension GL_EXT_shader_texture_lod : enable\n";
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 1), GLESUseShaderLod, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, 1), GLESUseShaderLod, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
if(!isVertex && (gl4es_find_string(Tmp, "texture2DLod"))) {
|
if(!isVertex && (FindString(Tmp, "texture2DLod"))) {
|
||||||
if(hardext.shaderlod) {
|
if(hardext.shaderlod) {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "texture2DLod", "texture2DLodEXT");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "texture2DLod", "texture2DLodEXT");
|
||||||
} else {
|
} else {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "texture2DLod", "_gl4es_texture2DLod");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "texture2DLod", "_gl4es_texture2DLod");
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), texture2DLodAlt, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), texture2DLodAlt, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isVertex && (gl4es_find_string(Tmp, "texture2DProjLod"))) {
|
if(!isVertex && (FindString(Tmp, "texture2DProjLod"))) {
|
||||||
if(hardext.shaderlod) {
|
if(hardext.shaderlod) {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "texture2DProjLod", "texture2DProjLodEXT");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "texture2DProjLod", "texture2DProjLodEXT");
|
||||||
} else {
|
} else {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "texture2DProjLod", "_gl4es_texture2DProjLod");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "texture2DProjLod", "_gl4es_texture2DProjLod");
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), texture2DProjLodAlt, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), texture2DProjLodAlt, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isVertex && (gl4es_find_string(Tmp, "textureCubeLod"))) {
|
if(!isVertex && (FindString(Tmp, "textureCubeLod"))) {
|
||||||
if(hardext.shaderlod) {
|
if(hardext.shaderlod) {
|
||||||
if(!hardext.cubelod)
|
if(!hardext.cubelod)
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "textureCubeLod", "textureCubeLodEXT");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "textureCubeLod", "textureCubeLodEXT");
|
||||||
} else {
|
} else {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "textureCubeLod", "_gl4es_textureCubeLod");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "textureCubeLod", "_gl4es_textureCubeLod");
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), textureCubeLodAlt, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), textureCubeLodAlt, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isVertex && (gl4es_find_string(Tmp, "texture2DGradARB"))) {
|
if(!isVertex && (FindString(Tmp, "texture2DGradARB"))) {
|
||||||
if(hardext.shaderlod) {
|
if(hardext.shaderlod) {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "texture2DGradARB", "texture2DGradEXT");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "texture2DGradARB", "texture2DGradEXT");
|
||||||
} else {
|
} else {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "texture2DGradARB", "_gl4es_texture2DGrad");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "texture2DGradARB", "_gl4es_texture2DGrad");
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), texture2DGradAlt, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), texture2DGradAlt, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isVertex && (gl4es_find_string(Tmp, "texture2DProjGradARB"))) {
|
if(!isVertex && (FindString(Tmp, "texture2DProjGradARB"))) {
|
||||||
if(hardext.shaderlod) {
|
if(hardext.shaderlod) {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "texture2DProjGradARB", "texture2DProjGradEXT");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "texture2DProjGradARB", "texture2DProjGradEXT");
|
||||||
} else {
|
} else {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "texture2DProjGradARB", "_gl4es_texture2DProjGrad");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "texture2DProjGradARB", "_gl4es_texture2DProjGrad");
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), texture2DProjGradAlt, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), texture2DProjGradAlt, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isVertex && (gl4es_find_string(Tmp, "textureCubeGradARB"))) {
|
if(!isVertex && (FindString(Tmp, "textureCubeGradARB"))) {
|
||||||
if(hardext.shaderlod) {
|
if(hardext.shaderlod) {
|
||||||
if(!hardext.cubelod)
|
if(!hardext.cubelod)
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "textureCubeGradARB", "textureCubeGradEXT");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "textureCubeGradARB", "textureCubeGradEXT");
|
||||||
} else {
|
} else {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "textureCubeGradARB", "_gl4es_textureCubeGrad");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "textureCubeGradARB", "_gl4es_textureCubeGrad");
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), textureCubeGradAlt, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), textureCubeGradAlt, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some drivers have troubles with "\\\r\n" or "\\\n" sequences on preprocessor macros
|
|
||||||
newptr = Tmp;
|
|
||||||
while (*newptr!=0x00) {
|
|
||||||
if (*newptr == '\\') {
|
|
||||||
if (*(newptr+1) == '\r' && *(newptr+2) == '\n')
|
|
||||||
memmove(newptr, newptr+3, strlen(newptr+3)+1);
|
|
||||||
else if (*(newptr+1) == '\n')
|
|
||||||
memmove(newptr, newptr+2, strlen(newptr+2)+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
newptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// now check to remove trailling "f" after float, as it's not supported too
|
// now check to remove trailling "f" after float, as it's not supported too
|
||||||
newptr = Tmp;
|
newptr = Tmp;
|
||||||
// simple state machine...
|
// simple state machine...
|
||||||
@ -719,35 +711,38 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
}
|
}
|
||||||
newptr++;
|
newptr++;
|
||||||
}
|
}
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_FragDepth", (hardext.fragdepth)?"gl_FragDepthEXT":"fakeFragDepth");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_FragDepth", (hardext.fragdepth)?"gl_FragDepthEXT":"fakeFragDepth");
|
||||||
// builtin attribs
|
// builtin attribs
|
||||||
if(isVertex) {
|
if(isVertex) {
|
||||||
|
// ANGLE already has ftransform, so skip it
|
||||||
|
#ifndef __APPLE__
|
||||||
// check for ftransform function
|
// check for ftransform function
|
||||||
if(strstr(Tmp, "ftransform(")) {
|
if(strstr(Tmp, "ftransform(")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_ftransformSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_ftransformSource, Tmp, &tmpsize);
|
||||||
// don't increment headline count, as all variying and attributes should be created before
|
// don't increment headline count, as all variying and attributes should be created before
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// check for builtin OpenGL attributes...
|
// check for builtin OpenGL attributes...
|
||||||
int n = sizeof(builtin_attrib)/sizeof(builtin_attrib_t);
|
int n = sizeof(builtin_attrib)/sizeof(builtin_attrib_t);
|
||||||
for (int i=0; i<n; i++) {
|
for (int i=0; i<n; i++) {
|
||||||
if(strstr(Tmp, builtin_attrib[i].glname)) {
|
if(strstr(Tmp, builtin_attrib[i].glname)) {
|
||||||
// ok, this attribute is used
|
// ok, this attribute is used
|
||||||
// replace gl_name by _gl4es_ one
|
// replace gl_name by _gl4es_ one
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, builtin_attrib[i].glname, builtin_attrib[i].name);
|
Tmp = InplaceReplace(Tmp, &tmpsize, builtin_attrib[i].glname, builtin_attrib[i].name);
|
||||||
// insert a declaration of it
|
// insert a declaration of it
|
||||||
char def[100];
|
char def[100];
|
||||||
sprintf(def, "attribute %s %s %s;\n", builtin_attrib[i].prec, builtin_attrib[i].type, builtin_attrib[i].name);
|
sprintf(def, "attribute %s %s %s;\n", builtin_attrib[i].prec, builtin_attrib[i].type, builtin_attrib[i].name);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline++), def, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline++), def, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, gl_VertexAttrib)) {
|
if(strstr(Tmp, gl_VertexAttrib)) {
|
||||||
// Generic VA from Old Programs
|
// Generic VA from Old Programs
|
||||||
for (int i=0; i<MAX_VATTRIB; ++i) {
|
for (int i=0; i<MAX_VATTRIB; ++i) {
|
||||||
char A[100];
|
char A[100];
|
||||||
if(gl4es_find_string(Tmp, gl_VA[i])) {
|
if(FindString(Tmp, gl_VA[i])) {
|
||||||
sprintf(A, "attribute highp vec4 %s%d;\n", gl4es_VertexAttrib, i);
|
sprintf(A, "attribute highp vec4 %s%d;\n", gl4es_VertexAttrib, i);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, gl_VA[i], gl4es_VA[i]);
|
Tmp = InplaceReplace(Tmp, &tmpsize, gl_VA[i], gl4es_VA[i]);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline++), A, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline++), A, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -756,46 +751,46 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
int nvarying = 0;
|
int nvarying = 0;
|
||||||
if(strstr(Tmp, "gl_Color") || need->need_color) {
|
if(strstr(Tmp, "gl_Color") || need->need_color) {
|
||||||
if(need->need_color<1) need->need_color = 1;
|
if(need->need_color<1) need->need_color = 1;
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_Color", (need->need_color==1)?"gl_FrontColor":"(gl_FrontFacing?gl_FrontColor:gl_BackColor)");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_Color", (need->need_color==1)?"gl_FrontColor":"(gl_FrontFacing?gl_FrontColor:gl_BackColor)");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_FrontColor") || need->need_color) {
|
if(strstr(Tmp, "gl_FrontColor") || need->need_color) {
|
||||||
if(need->need_color<1) need->need_color = 1;
|
if(need->need_color<1) need->need_color = 1;
|
||||||
nvarying+=1;
|
nvarying+=1;
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_frontColorSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_frontColorSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_frontColorSource);
|
headline+=CountLine(gl4es_frontColorSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_FrontColor", "_gl4es_FrontColor");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_FrontColor", "_gl4es_FrontColor");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_BackColor") || (need->need_color==2)) {
|
if(strstr(Tmp, "gl_BackColor") || (need->need_color==2)) {
|
||||||
need->need_color = 2;
|
need->need_color = 2;
|
||||||
nvarying+=1;
|
nvarying+=1;
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_backColorSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_backColorSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_backColorSource);
|
headline+=CountLine(gl4es_backColorSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_BackColor", "_gl4es_BackColor");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_BackColor", "_gl4es_BackColor");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_SecondaryColor") || need->need_secondary) {
|
if(strstr(Tmp, "gl_SecondaryColor") || need->need_secondary) {
|
||||||
if(need->need_secondary<1) need->need_secondary = 1;
|
if(need->need_secondary<1) need->need_secondary = 1;
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_SecondaryColor", (need->need_secondary==1)?"gl_FrontSecondaryColor":"(gl_FrontFacing?gl_FrontSecondaryColor:gl_BackSecondaryColor)");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_SecondaryColor", (need->need_secondary==1)?"gl_FrontSecondaryColor":"(gl_FrontFacing?gl_FrontSecondaryColor:gl_BackSecondaryColor)");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_FrontSecondaryColor") || need->need_secondary) {
|
if(strstr(Tmp, "gl_FrontSecondaryColor") || need->need_secondary) {
|
||||||
if(need->need_secondary<1) need->need_secondary = 1;
|
if(need->need_secondary<1) need->need_secondary = 1;
|
||||||
nvarying+=1;
|
nvarying+=1;
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_frontSecondaryColorSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_frontSecondaryColorSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_frontSecondaryColorSource);
|
headline+=CountLine(gl4es_frontSecondaryColorSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_FrontSecondaryColor", "_gl4es_FrontSecondaryColor");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_FrontSecondaryColor", "_gl4es_FrontSecondaryColor");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_BackSecondaryColor") || (need->need_secondary==2)) {
|
if(strstr(Tmp, "gl_BackSecondaryColor") || (need->need_secondary==2)) {
|
||||||
need->need_secondary = 2;
|
need->need_secondary = 2;
|
||||||
nvarying+=1;
|
nvarying+=1;
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_backSecondaryColorSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_backSecondaryColorSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_backSecondaryColorSource);
|
headline+=CountLine(gl4es_backSecondaryColorSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_BackSecondaryColor", "_gl4es_BackSecondaryColor");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_BackSecondaryColor", "_gl4es_BackSecondaryColor");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_FogFragCoord") || need->need_fogcoord) {
|
if(strstr(Tmp, "gl_FogFragCoord") || need->need_fogcoord) {
|
||||||
need->need_fogcoord = 1;
|
need->need_fogcoord = 1;
|
||||||
nvarying+=1;
|
nvarying+=1;
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_fogcoordSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_fogcoordSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_fogcoordSource);
|
headline+=CountLine(gl4es_fogcoordSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_FogFragCoord", "_gl4es_FogFragCoord");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_FogFragCoord", "_gl4es_FogFragCoord");
|
||||||
}
|
}
|
||||||
// Get the max_texunit and the calc notexarray
|
// Get the max_texunit and the calc notexarray
|
||||||
if(strstr(Tmp, "gl_TexCoord") || need->need_texcoord!=-1) {
|
if(strstr(Tmp, "gl_TexCoord") || need->need_texcoord!=-1) {
|
||||||
@ -825,7 +820,7 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
notexarray = 1;
|
notexarray = 1;
|
||||||
need->need_notexarray = 1;
|
need->need_notexarray = 1;
|
||||||
}
|
}
|
||||||
// check constraints
|
// check constaints
|
||||||
if (!notexarray && ntex+nvarying>hardext.maxvarying) ntex = hardext.maxvarying - nvarying;
|
if (!notexarray && ntex+nvarying>hardext.maxvarying) ntex = hardext.maxvarying - nvarying;
|
||||||
need->need_texcoord = ntex;
|
need->need_texcoord = ntex;
|
||||||
char d[100];
|
char d[100];
|
||||||
@ -835,10 +830,10 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
sprintf(d2, "gl_TexCoord[%d]", k);
|
sprintf(d2, "gl_TexCoord[%d]", k);
|
||||||
if(strstr(Tmp, d2)) {
|
if(strstr(Tmp, d2)) {
|
||||||
sprintf(d, gl4es_texcoordSourceAlt, k);
|
sprintf(d, gl4es_texcoordSourceAlt, k);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), d, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), d, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(d);
|
headline+=CountLine(d);
|
||||||
sprintf(d, "_gl4es_TexCoord_%d", k);
|
sprintf(d, "_gl4es_TexCoord_%d", k);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, d2, d);
|
Tmp = InplaceReplace(Tmp, &tmpsize, d2, d);
|
||||||
}
|
}
|
||||||
// check if texture is there
|
// check if texture is there
|
||||||
sprintf(d2, "_gl4es_TexCoord_%d", k);
|
sprintf(d2, "_gl4es_TexCoord_%d", k);
|
||||||
@ -847,9 +842,9 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sprintf(d, gl4es_texcoordSource, ntex+1);
|
sprintf(d, gl4es_texcoordSource, ntex+1);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), d, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), d, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(d);
|
headline+=CountLine(d);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_TexCoord", "_gl4es_TexCoord");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_TexCoord", "_gl4es_TexCoord");
|
||||||
// set textures as all ntex used
|
// set textures as all ntex used
|
||||||
for (int k=0; k<ntex+1; k++)
|
for (int k=0; k<ntex+1; k++)
|
||||||
need->need_texs |= (1<<k);
|
need->need_texs |= (1<<k);
|
||||||
@ -859,8 +854,8 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
// builtin matrices work
|
// builtin matrices work
|
||||||
{
|
{
|
||||||
if(strstr(Tmp, "transpose(") || strstr(Tmp, "transpose ") || strstr(Tmp, "transpose\t")) {
|
if(strstr(Tmp, "transpose(") || strstr(Tmp, "transpose ") || strstr(Tmp, "transpose\t")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_transpose, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_transpose, Tmp, &tmpsize);
|
||||||
gl4es_inplace_replace(Tmp, &tmpsize, "transpose", "gl4es_transpose");
|
InplaceReplace(Tmp, &tmpsize, "transpose", "gl4es_transpose");
|
||||||
// don't increment headline count, as all variying and attributes should be created before
|
// don't increment headline count, as all variying and attributes should be created before
|
||||||
}
|
}
|
||||||
// check for builtin matrix uniform...
|
// check for builtin matrix uniform...
|
||||||
@ -903,7 +898,7 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
sprintf(d2, "gl_TextureMatrix[%d]", k);
|
sprintf(d2, "gl_TextureMatrix[%d]", k);
|
||||||
if(strstr(Tmp, d2)) {
|
if(strstr(Tmp, d2)) {
|
||||||
sprintf(d, "gl_TextureMatrix_%d", k);
|
sprintf(d, "gl_TextureMatrix_%d", k);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, d2, d);
|
Tmp = InplaceReplace(Tmp, &tmpsize, d2, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -913,7 +908,7 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
if(strstr(Tmp, builtin_matrix[i].glname)) {
|
if(strstr(Tmp, builtin_matrix[i].glname)) {
|
||||||
// ok, this matrix is used
|
// ok, this matrix is used
|
||||||
// replace gl_name by _gl4es_ one
|
// replace gl_name by _gl4es_ one
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, builtin_matrix[i].glname, builtin_matrix[i].name);
|
Tmp = InplaceReplace(Tmp, &tmpsize, builtin_matrix[i].glname, builtin_matrix[i].name);
|
||||||
// insert a declaration of it
|
// insert a declaration of it
|
||||||
char def[100];
|
char def[100];
|
||||||
int ishighp = (isVertex || hardext.highp)?1:0;
|
int ishighp = (isVertex || hardext.highp)?1:0;
|
||||||
@ -939,7 +934,7 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
sprintf(def, "uniform %s%s %s[%d];\n", (ishighp)?"highp ":"mediump ", builtin_matrix[i].type, builtin_matrix[i].name, ntex);
|
sprintf(def, "uniform %s%s %s[%d];\n", (ishighp)?"highp ":"mediump ", builtin_matrix[i].type, builtin_matrix[i].name, ntex);
|
||||||
else
|
else
|
||||||
sprintf(def, "uniform %s%s %s;\n", (ishighp)?"highp ":"mediump ", builtin_matrix[i].type, builtin_matrix[i].name);
|
sprintf(def, "uniform %s%s %s;\n", (ishighp)?"highp ":"mediump ", builtin_matrix[i].type, builtin_matrix[i].name);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline++), def, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline++), def, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -951,13 +946,13 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
while((p=strstr(p, "gl_LightSource["))) {
|
while((p=strstr(p, "gl_LightSource["))) {
|
||||||
char *p2 = strchr(p, ']');
|
char *p2 = strchr(p, ']');
|
||||||
if (p2 && !strncmp(p2, "].halfVector", strlen("].halfVector"))) {
|
if (p2 && !strncmp(p2, "].halfVector", strlen("].halfVector"))) {
|
||||||
// found an occurrence, lets change
|
// found an occurence, lets change
|
||||||
char p3[500];
|
char p3[500];
|
||||||
strncpy(p3,p, (p2-p)+1); p3[(p2-p)+1]='\0';
|
strncpy(p3,p, (p2-p)+1); p3[(p2-p)+1]='\0';
|
||||||
char p4[500], p5[500];
|
char p4[500], p5[500];
|
||||||
sprintf(p4, "%s.halfVector", p3);
|
sprintf(p4, "%s.halfVector", p3);
|
||||||
sprintf(p5, "normalize(normalize(%s.position.xyz) + vec3(0., 0., 1.))", p3);
|
sprintf(p5, "normalize(normalize(%s.position.xyz) + vec3(0., 0., 1.))", p3);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, p4, p5);
|
Tmp = InplaceReplace(Tmp, &tmpsize, p4, p5);
|
||||||
p = Tmp;
|
p = Tmp;
|
||||||
} else
|
} else
|
||||||
++p;
|
++p;
|
||||||
@ -970,7 +965,7 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
while((p=strstr(p, "centroid"))!=NULL)
|
while((p=strstr(p, "centroid"))!=NULL)
|
||||||
{
|
{
|
||||||
if(p[8]==' ' || p[8]=='\t') { // what next...
|
if(p[8]==' ' || p[8]=='\t') { // what next...
|
||||||
const char* p2 = gl4es_get_next_str(p+8);
|
const char* p2 = GetNextStr(p+8);
|
||||||
if(strcmp(p2, "uniform")==0 || strcmp(p2, "varying")==0) {
|
if(strcmp(p2, "uniform")==0 || strcmp(p2, "varying")==0) {
|
||||||
memset(p, ' ', 8); // erase the keyword...
|
memset(p, ' ', 8); // erase the keyword...
|
||||||
}
|
}
|
||||||
@ -982,172 +977,167 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
// check for builtin OpenGL gl_LightSource & friends
|
// check for builtin OpenGL gl_LightSource & friends
|
||||||
if(strstr(Tmp, "gl_LightSourceParameters") || strstr(Tmp, "gl_LightSource"))
|
if(strstr(Tmp, "gl_LightSourceParameters") || strstr(Tmp, "gl_LightSource"))
|
||||||
{
|
{
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_LightSourceParametersSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_LightSourceParametersSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_LightSourceParametersSource);
|
headline+=CountLine(gl4es_LightSourceParametersSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_LightSourceParameters", "_gl4es_LightSourceParameters");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_LightSourceParameters", "_gl4es_LightSourceParameters");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_LightModelParameters") || strstr(Tmp, "gl_LightModel"))
|
if(strstr(Tmp, "gl_LightModelParameters") || strstr(Tmp, "gl_LightModel"))
|
||||||
{
|
{
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_LightModelParametersSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_LightModelParametersSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_LightModelParametersSource);
|
headline+=CountLine(gl4es_LightModelParametersSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_LightModelParameters", "_gl4es_LightModelParameters");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_LightModelParameters", "_gl4es_LightModelParameters");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_LightModelProducts") || strstr(Tmp, "gl_FrontLightModelProduct") || strstr(Tmp, "gl_BackLightModelProduct"))
|
if(strstr(Tmp, "gl_LightModelProducts") || strstr(Tmp, "gl_FrontLightModelProduct") || strstr(Tmp, "gl_BackLightModelProduct"))
|
||||||
{
|
{
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_LightModelProductsSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_LightModelProductsSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_LightModelProductsSource);
|
headline+=CountLine(gl4es_LightModelProductsSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_LightModelProducts", "_gl4es_LightModelProducts");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_LightModelProducts", "_gl4es_LightModelProducts");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_LightProducts") || strstr(Tmp, "gl_FrontLightProduct") || strstr(Tmp, "gl_BackLightProduct"))
|
if(strstr(Tmp, "gl_LightProducts") || strstr(Tmp, "gl_FrontLightProduct") || strstr(Tmp, "gl_BackLightProduct"))
|
||||||
{
|
{
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_LightProductsSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_LightProductsSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_LightProductsSource);
|
headline+=CountLine(gl4es_LightProductsSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_LightProducts", "_gl4es_LightProducts");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_LightProducts", "_gl4es_LightProducts");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_MaterialParameters ") || (strstr(Tmp, "gl_FrontMaterial")) || strstr(Tmp, "gl_BackMaterial"))
|
if(strstr(Tmp, "gl_MaterialParameters ") || (strstr(Tmp, "gl_FrontMaterial")) || strstr(Tmp, "gl_BackMaterial"))
|
||||||
{
|
{
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_MaterialParametersSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_MaterialParametersSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_MaterialParametersSource);
|
headline+=CountLine(gl4es_MaterialParametersSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_MaterialParameters", "_gl4es_MaterialParameters");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_MaterialParameters", "_gl4es_MaterialParameters");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_LightSource")) {
|
if(strstr(Tmp, "gl_LightSource")) {
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_LightSource", "_gl4es_LightSource");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_LightSource", "_gl4es_LightSource");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_LightModel"))
|
if(strstr(Tmp, "gl_LightModel"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_LightModel", "_gl4es_LightModel");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_LightModel", "_gl4es_LightModel");
|
||||||
if(strstr(Tmp, "gl_FrontLightModelProduct"))
|
if(strstr(Tmp, "gl_FrontLightModelProduct"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_FrontLightModelProduct", "_gl4es_FrontLightModelProduct");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_FrontLightModelProduct", "_gl4es_FrontLightModelProduct");
|
||||||
if(strstr(Tmp, "gl_BackLightModelProduct"))
|
if(strstr(Tmp, "gl_BackLightModelProduct"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_BackLightModelProduct", "_gl4es_BackLightModelProduct");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_BackLightModelProduct", "_gl4es_BackLightModelProduct");
|
||||||
if(strstr(Tmp, "gl_FrontLightProduct"))
|
if(strstr(Tmp, "gl_FrontLightProduct"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_FrontLightProduct", "_gl4es_FrontLightProduct");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_FrontLightProduct", "_gl4es_FrontLightProduct");
|
||||||
if(strstr(Tmp, "gl_BackLightProduct"))
|
if(strstr(Tmp, "gl_BackLightProduct"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_BackLightProduct", "_gl4es_BackLightProduct");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_BackLightProduct", "_gl4es_BackLightProduct");
|
||||||
if(strstr(Tmp, "gl_FrontMaterial"))
|
if(strstr(Tmp, "gl_FrontMaterial"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_FrontMaterial", "_gl4es_FrontMaterial");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_FrontMaterial", "_gl4es_FrontMaterial");
|
||||||
if(strstr(Tmp, "gl_BackMaterial"))
|
if(strstr(Tmp, "gl_BackMaterial"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_BackMaterial", "_gl4es_BackMaterial");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_BackMaterial", "_gl4es_BackMaterial");
|
||||||
if(strstr(Tmp, "gl_MaxLights"))
|
if(strstr(Tmp, "gl_MaxLights"))
|
||||||
{
|
{
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 2), gl4es_MaxLightsSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, 2), gl4es_MaxLightsSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_MaxLightsSource);
|
headline+=CountLine(gl4es_MaxLightsSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_MaxLights", "_gl4es_MaxLights");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_MaxLights", "_gl4es_MaxLights");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_NormalScale")) {
|
if(strstr(Tmp, "gl_NormalScale")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_normalscaleSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_normalscaleSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_normalscaleSource);
|
headline+=CountLine(gl4es_normalscaleSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_NormalScale", "_gl4es_NormalScale");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_NormalScale", "_gl4es_NormalScale");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_InstanceID") || strstr(Tmp, "gl_InstanceIDARB")) {
|
if(strstr(Tmp, "gl_InstanceID") || strstr(Tmp, "gl_InstanceIDARB")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_instanceID, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_instanceID, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_instanceID);
|
headline+=CountLine(gl4es_instanceID);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_InstanceIDARB", "_gl4es_InstanceID");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_InstanceIDARB", "_gl4es_InstanceID");
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_InstanceID", "_gl4es_InstanceID");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_InstanceID", "_gl4es_InstanceID");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_ClipPlane")) {
|
if(strstr(Tmp, "gl_ClipPlane")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_clipplanesSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_clipplanesSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_clipplanesSource);
|
headline+=CountLine(gl4es_clipplanesSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_ClipPlane", "_gl4es_ClipPlane");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_ClipPlane", "_gl4es_ClipPlane");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_MaxClipPlanes")) {
|
if(strstr(Tmp, "gl_MaxClipPlanes")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 2), gl4es_MaxClipPlanesSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, 2), gl4es_MaxClipPlanesSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_MaxClipPlanesSource);
|
headline+=CountLine(gl4es_MaxClipPlanesSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_MaxClipPlanes", "_gl4es_MaxClipPlanes");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_MaxClipPlanes", "_gl4es_MaxClipPlanes");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strstr(Tmp, "gl_PointParameters") || strstr(Tmp, "gl_Point"))
|
if(strstr(Tmp, "gl_PointParameters") || strstr(Tmp, "gl_Point"))
|
||||||
{
|
{
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_PointSpriteSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_PointSpriteSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_PointSpriteSource);
|
headline+=CountLine(gl4es_PointSpriteSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_PointParameters", "_gl4es_PointParameters");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_PointParameters", "_gl4es_PointParameters");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_Point"))
|
if(strstr(Tmp, "gl_Point"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_Point", "_gl4es_Point");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_Point", "_gl4es_Point");
|
||||||
if(strstr(Tmp, "gl_FogParameters") || strstr(Tmp, "gl_Fog"))
|
if(strstr(Tmp, "gl_FogParameters") || strstr(Tmp, "gl_Fog"))
|
||||||
{
|
{
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), hardext.highp?gl4es_FogParametersSourceHighp:gl4es_FogParametersSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), hardext.highp?gl4es_FogParametersSourceHighp:gl4es_FogParametersSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_FogParametersSource);
|
headline+=CountLine(gl4es_FogParametersSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_FogParameters", "_gl4es_FogParameters");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_FogParameters", "_gl4es_FogParameters");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_Fog"))
|
if(strstr(Tmp, "gl_Fog"))
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_Fog", "_gl4es_Fog");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_Fog", "_gl4es_Fog");
|
||||||
if(strstr(Tmp, "gl_TextureEnvColor")) {
|
if(strstr(Tmp, "gl_TextureEnvColor")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texenvcolorSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texenvcolorSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texenvcolorSource);
|
headline+=CountLine(gl4es_texenvcolorSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_TextureEnvColor", "_gl4es_TextureEnvColor");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_TextureEnvColor", "_gl4es_TextureEnvColor");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_EyePlaneS")) {
|
if(strstr(Tmp, "gl_EyePlaneS")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texgeneyeSource[0], Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texgeneyeSource[0], Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texgeneyeSource[0]);
|
headline+=CountLine(gl4es_texgeneyeSource[0]);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_EyePlaneS", "_gl4es_EyePlaneS");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_EyePlaneS", "_gl4es_EyePlaneS");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_EyePlaneT")) {
|
if(strstr(Tmp, "gl_EyePlaneT")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texgeneyeSource[1], Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texgeneyeSource[1], Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texgeneyeSource[1]);
|
headline+=CountLine(gl4es_texgeneyeSource[1]);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_EyePlaneT", "_gl4es_EyePlaneT");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_EyePlaneT", "_gl4es_EyePlaneT");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_EyePlaneR")) {
|
if(strstr(Tmp, "gl_EyePlaneR")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texgeneyeSource[2], Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texgeneyeSource[2], Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texgeneyeSource[2]);
|
headline+=CountLine(gl4es_texgeneyeSource[2]);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_EyePlaneR", "_gl4es_EyePlaneR");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_EyePlaneR", "_gl4es_EyePlaneR");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_EyePlaneQ")) {
|
if(strstr(Tmp, "gl_EyePlaneQ")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texgeneyeSource[3], Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texgeneyeSource[3], Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texgeneyeSource[3]);
|
headline+=CountLine(gl4es_texgeneyeSource[3]);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_EyePlaneQ", "_gl4es_EyePlaneQ");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_EyePlaneQ", "_gl4es_EyePlaneQ");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_ObjectPlaneS")) {
|
if(strstr(Tmp, "gl_ObjectPlaneS")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texgenobjSource[0], Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texgenobjSource[0], Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texgenobjSource[0]);
|
headline+=CountLine(gl4es_texgenobjSource[0]);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_ObjectPlaneS", "_gl4es_ObjectPlaneS");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_ObjectPlaneS", "_gl4es_ObjectPlaneS");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_ObjectPlaneT")) {
|
if(strstr(Tmp, "gl_ObjectPlaneT")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texgenobjSource[1], Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texgenobjSource[1], Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texgenobjSource[1]);
|
headline+=CountLine(gl4es_texgenobjSource[1]);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_ObjectPlaneT", "_gl4es_ObjectPlaneT");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_ObjectPlaneT", "_gl4es_ObjectPlaneT");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_ObjectPlaneR")) {
|
if(strstr(Tmp, "gl_ObjectPlaneR")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texgenobjSource[2], Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texgenobjSource[2], Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texgenobjSource[2]);
|
headline+=CountLine(gl4es_texgenobjSource[2]);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_ObjectPlaneR", "_gl4es_ObjectPlaneR");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_ObjectPlaneR", "_gl4es_ObjectPlaneR");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_ObjectPlaneQ")) {
|
if(strstr(Tmp, "gl_ObjectPlaneQ")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_texgenobjSource[3], Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), gl4es_texgenobjSource[3], Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_texgenobjSource[3]);
|
headline+=CountLine(gl4es_texgenobjSource[3]);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_ObjectPlaneQ", "_gl4es_ObjectPlaneQ");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_ObjectPlaneQ", "_gl4es_ObjectPlaneQ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strstr(Tmp, "gl_MaxTextureUnits")) {
|
if(strstr(Tmp, "gl_MaxTextureUnits")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 2), gl4es_MaxTextureUnitsSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, 2), gl4es_MaxTextureUnitsSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_MaxTextureUnitsSource);
|
headline+=CountLine(gl4es_MaxTextureUnitsSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_MaxTextureUnits", "_gl4es_MaxTextureUnits");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_MaxTextureUnits", "_gl4es_MaxTextureUnits");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_MaxTextureCoords")) {
|
if(strstr(Tmp, "gl_MaxTextureCoords")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 2), gl4es_MaxTextureCoordsSource, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, 2), gl4es_MaxTextureCoordsSource, Tmp, &tmpsize);
|
||||||
headline+=gl4es_countline(gl4es_MaxTextureCoordsSource);
|
headline+=CountLine(gl4es_MaxTextureCoordsSource);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_MaxTextureCoords", "_gl4es_MaxTextureCoords");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_MaxTextureCoords", "_gl4es_MaxTextureCoords");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "gl_ClipVertex")) {
|
if(strstr(Tmp, "gl_ClipVertex")) {
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 2), gl4es_ClipVertex, Tmp, &tmpsize);
|
// gl_ClipVertex is not handled for now
|
||||||
headline+=gl4es_countline(gl4es_ClipVertex);
|
// Proper way would be to copy handling from fpe_shader, but then, need to use gl_ClipPlane...
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "gl_ClipVertex", gl4es_ClipVertexSource);
|
static int ncv = 0;
|
||||||
need->need_clipvertex = 1;
|
char CV[60];
|
||||||
} else if(isVertex && need && need->need_clipvertex) {
|
sprintf(CV, gl4es_dummyClipVertex, ncv);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, 2), gl4es_ClipVertex, Tmp, &tmpsize);
|
++ncv;
|
||||||
headline+=gl4es_countline(gl4es_ClipVertex);
|
Tmp = InplaceReplace(Tmp, &tmpsize, "gl_ClipVertex", CV);
|
||||||
char *p = strchr(gl4es_find_string_nc(Tmp, "main"), '{'); // find the openning curly bracket of main
|
|
||||||
if(p) {
|
|
||||||
// add regular clipping at start of main
|
|
||||||
Tmp = gl4es_inplace_insert(p+1, gl4es_ClipVertex_clip, Tmp, &tmpsize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//oldprogram uniforms...
|
//oldprogram uniforms...
|
||||||
if(gl4es_find_string(Tmp, gl_ProgramEnv)) {
|
if(FindString(Tmp, gl_ProgramEnv)) {
|
||||||
// check if array can be removed
|
// check if array can be removed
|
||||||
int maxind = -1;
|
int maxind = -1;
|
||||||
int noarray_ok = 1;
|
int noarray_ok = 1;
|
||||||
char* p = Tmp;
|
char* p = Tmp;
|
||||||
while(noarray_ok && (p=gl4es_find_string_nc(p, gl_ProgramEnv))) {
|
while(noarray_ok && (p=FindStringNC(p, gl_ProgramEnv))) {
|
||||||
p+=strlen(gl_ProgramEnv);
|
p+=strlen(gl_ProgramEnv);
|
||||||
if(*p=='[') {
|
if(*p=='[') {
|
||||||
++p;
|
++p;
|
||||||
@ -1167,11 +1157,11 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
for(int i=0; i<=maxind; ++i) {
|
for(int i=0; i<=maxind; ++i) {
|
||||||
sprintf(F, "%s[%d]", gl_ProgramEnv, i);
|
sprintf(F, "%s[%d]", gl_ProgramEnv, i);
|
||||||
sprintf(T, "_gl4es_%s_ProgramEnv_%d", isVertex?"Vertex":"Fragment", i);
|
sprintf(T, "_gl4es_%s_ProgramEnv_%d", isVertex?"Vertex":"Fragment", i);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, F, T);
|
Tmp = InplaceReplace(Tmp, &tmpsize, F, T);
|
||||||
if(gl4es_find_string(Tmp, T)) {
|
if(FindString(Tmp, T)) {
|
||||||
// add the uniform declaration if needed
|
// add the uniform declaration if needed
|
||||||
sprintf(U, "uniform vec4 %s;\n", T);
|
sprintf(U, "uniform vec4 %s;\n", T);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), U, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), U, Tmp, &tmpsize);
|
||||||
headline += 1;
|
headline += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1180,17 +1170,17 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
char T[60], U[300];
|
char T[60], U[300];
|
||||||
sprintf(T, "_gl4es_%s_ProgramEnv", isVertex?"Vertex":"Fragment");
|
sprintf(T, "_gl4es_%s_ProgramEnv", isVertex?"Vertex":"Fragment");
|
||||||
sprintf(U, "uniform vec4 %s[%d];\n", T, isVertex?MAX_VTX_PROG_ENV_PARAMS:MAX_FRG_PROG_ENV_PARAMS);
|
sprintf(U, "uniform vec4 %s[%d];\n", T, isVertex?MAX_VTX_PROG_ENV_PARAMS:MAX_FRG_PROG_ENV_PARAMS);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), U, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), U, Tmp, &tmpsize);
|
||||||
headline += 1;
|
headline += 1;
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, gl_ProgramEnv, T);
|
Tmp = InplaceReplace(Tmp, &tmpsize, gl_ProgramEnv, T);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(gl4es_find_string(Tmp, gl_ProgramLocal)) {
|
if(FindString(Tmp, gl_ProgramLocal)) {
|
||||||
// check if array can be removed
|
// check if array can be removed
|
||||||
int maxind = -1;
|
int maxind = -1;
|
||||||
int noarray_ok = 1;
|
int noarray_ok = 1;
|
||||||
char* p = Tmp;
|
char* p = Tmp;
|
||||||
while(noarray_ok && (p=gl4es_find_string_nc(p, gl_ProgramLocal))) {
|
while(noarray_ok && (p=FindStringNC(p, gl_ProgramLocal))) {
|
||||||
p+=strlen(gl_ProgramLocal);
|
p+=strlen(gl_ProgramLocal);
|
||||||
if(*p=='[') {
|
if(*p=='[') {
|
||||||
++p;
|
++p;
|
||||||
@ -1210,11 +1200,11 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
for(int i=0; i<=maxind; ++i) {
|
for(int i=0; i<=maxind; ++i) {
|
||||||
sprintf(F, "%s[%d]", gl_ProgramLocal, i);
|
sprintf(F, "%s[%d]", gl_ProgramLocal, i);
|
||||||
sprintf(T, "_gl4es_%s_ProgramLocal_%d", isVertex?"Vertex":"Fragment", i);
|
sprintf(T, "_gl4es_%s_ProgramLocal_%d", isVertex?"Vertex":"Fragment", i);
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, F, T);
|
Tmp = InplaceReplace(Tmp, &tmpsize, F, T);
|
||||||
if(gl4es_find_string(Tmp, T)) {
|
if(FindString(Tmp, T)) {
|
||||||
// add the uniform declaration if needed
|
// add the uniform declaration if needed
|
||||||
sprintf(U, "uniform vec4 %s;\n", T);
|
sprintf(U, "uniform vec4 %s;\n", T);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), U, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), U, Tmp, &tmpsize);
|
||||||
headline += 1;
|
headline += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1223,9 +1213,9 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
char T[60], U[300];
|
char T[60], U[300];
|
||||||
sprintf(T, "_gl4es_%s_ProgramLocal", isVertex?"Vertex":"Fragment");
|
sprintf(T, "_gl4es_%s_ProgramLocal", isVertex?"Vertex":"Fragment");
|
||||||
sprintf(U, "uniform vec4 %s[%d];\n", T, isVertex?MAX_VTX_PROG_LOC_PARAMS:MAX_FRG_PROG_LOC_PARAMS);
|
sprintf(U, "uniform vec4 %s[%d];\n", T, isVertex?MAX_VTX_PROG_LOC_PARAMS:MAX_FRG_PROG_LOC_PARAMS);
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), U, Tmp, &tmpsize);
|
Tmp = InplaceInsert(GetLine(Tmp, headline), U, Tmp, &tmpsize);
|
||||||
headline += 1;
|
headline += 1;
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, gl_ProgramLocal, T);
|
Tmp = InplaceReplace(Tmp, &tmpsize, gl_ProgramLocal, T);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define GO(A) \
|
#define GO(A) \
|
||||||
@ -1233,11 +1223,11 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
char S[60], D[60], U[60]; \
|
char S[60], D[60], U[60]; \
|
||||||
for(int i=0; i<MAX_TEX; ++i) { \
|
for(int i=0; i<MAX_TEX; ++i) { \
|
||||||
sprintf(S, "%s%d", gl_Samplers ## A, i); \
|
sprintf(S, "%s%d", gl_Samplers ## A, i); \
|
||||||
if(gl4es_find_string(Tmp, S)) { \
|
if(FindString(Tmp, S)) { \
|
||||||
sprintf(D, "%s%d", gl4es_Samplers ## A, i); \
|
sprintf(D, "%s%d", gl4es_Samplers ## A, i); \
|
||||||
sprintf(U, "%s%d;\n", gl4es_Samplers ## A ## _uniform, i); \
|
sprintf(U, "%s%d;\n", gl4es_Samplers ## A ## _uniform, i); \
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, S, D); \
|
Tmp = InplaceReplace(Tmp, &tmpsize, S, D); \
|
||||||
Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), U, Tmp, &tmpsize); \
|
Tmp = InplaceInsert(GetLine(Tmp, headline), U, Tmp, &tmpsize); \
|
||||||
headline += 1; \
|
headline += 1; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -1252,20 +1242,26 @@ char* ConvertShader(const char* pEntry, int isVertex, shaderconv_need_t *need)
|
|||||||
// the square one first
|
// the square one first
|
||||||
if(strstr(Tmp, "mat2x2")) {
|
if(strstr(Tmp, "mat2x2")) {
|
||||||
// better to use #define ?
|
// better to use #define ?
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "mat2x2", "mat2");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "mat2x2", "mat2");
|
||||||
}
|
}
|
||||||
if(strstr(Tmp, "mat3x3")) {
|
if(strstr(Tmp, "mat3x3")) {
|
||||||
// better to use #define ?
|
// better to use #define ?
|
||||||
Tmp = gl4es_inplace_replace(Tmp, &tmpsize, "mat3x3", "mat3");
|
Tmp = InplaceReplace(Tmp, &tmpsize, "mat3x3", "mat3");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (versionHeader > 1) {
|
||||||
|
const char* GLESBackport = "#define texture2D texture\n#define attribute in\n#define varying out\n";
|
||||||
|
Tmp = InplaceInsert(GetLine(Tmp, 1), GLESBackport, Tmp, &tmpsize);
|
||||||
|
}else {
|
||||||
|
const char* GLESForwardPort = "#define texture texture2D\n #define textureProj texture2DProj\n #define mod(a,b) (int(a) - int(b) * int(a/b))\n";
|
||||||
|
Tmp = InplaceInsert(GetLine(Tmp, 1), GLESForwardPort, Tmp, &tmpsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish
|
// finish
|
||||||
if((globals4es.dbgshaderconv&maskafter)==maskafter) {
|
if((globals4es.dbgshaderconv&maskafter)==maskafter) {
|
||||||
SHUT_LOGD("MobileGlues-gl4es: New Shader source:\n%s\n", Tmp);
|
printf("New Shader source:\n%s\n", Tmp);
|
||||||
}
|
}
|
||||||
// clean preproc'd source
|
// clean preproc'd source
|
||||||
if(versionString != NULL)
|
|
||||||
free(versionString);
|
|
||||||
if(pEntry!=pBuffer)
|
if(pEntry!=pBuffer)
|
||||||
free(pBuffer);
|
free(pBuffer);
|
||||||
return Tmp;
|
return Tmp;
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
#include "gles.h"
|
#include "gles.h"
|
||||||
#include "program.h"
|
#include "program.h"
|
||||||
|
|
||||||
char* ConvertShader(const char* pBuffer, int isVertex, shaderconv_need_t *need);
|
char * ConvertShaderConditionally(struct shader_s * shader_source);
|
||||||
|
char* ConvertShader(const char* pBuffer, int isVertex, shaderconv_need_t *need, int forwardPort);
|
||||||
|
|
||||||
int isBuiltinAttrib(const char* name);
|
int isBuiltinAttrib(const char* name);
|
||||||
int isBuiltinMatrix(const char* name);
|
int isBuiltinMatrix(const char* name);
|
||||||
|
@ -8,6 +8,67 @@ const char* AllSeparators = " \t\n\r.,;()[]{}-<>+*/%&\\\"'^$=!:?";
|
|||||||
|
|
||||||
char* gl4es_resize_if_needed(char* pBuffer, int *size, int addsize);
|
char* gl4es_resize_if_needed(char* pBuffer, int *size, int addsize);
|
||||||
|
|
||||||
|
void AppendToEnd(char **str, const char *suffix) {
|
||||||
|
size_t len = strlen(*str);
|
||||||
|
size_t suffixLen = strlen(suffix);
|
||||||
|
char *newStr = (char *)malloc(len + suffixLen + 1);
|
||||||
|
if (newStr == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
strcpy(newStr, *str);
|
||||||
|
strcpy(newStr + len, suffix);
|
||||||
|
free(*str);
|
||||||
|
*str = newStr;
|
||||||
|
}
|
||||||
|
void InsertAtBeginning(char **str, const char *prefix) {
|
||||||
|
size_t len = strlen(*str);
|
||||||
|
size_t prefixLen = strlen(prefix);
|
||||||
|
char *newStr = (char *)malloc(len + prefixLen + 1);
|
||||||
|
strcpy(newStr, prefix);
|
||||||
|
strcpy(newStr + prefixLen, *str);
|
||||||
|
free(*str);
|
||||||
|
*str = newStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char * InplaceReplaceByIndex(char* pBuffer, int* size, const int startIndex, const int endIndex, const char* replacement)
|
||||||
|
{
|
||||||
|
//printf("BY INDEX: %s", replacement);
|
||||||
|
//printf("BY INDEX: %i", strlen(replacement));
|
||||||
|
int length_difference;
|
||||||
|
if(endIndex < startIndex)
|
||||||
|
length_difference = strlen(replacement) + (endIndex - startIndex);
|
||||||
|
else if(endIndex == startIndex)
|
||||||
|
length_difference = strlen(replacement) - 1; // The initial char gets replaced
|
||||||
|
else
|
||||||
|
length_difference = strlen(replacement) - (endIndex - startIndex); // Can be negative if repl is smaller
|
||||||
|
pBuffer = gl4es_resize_if_needed(pBuffer, size, length_difference);
|
||||||
|
//printf("BEFORE MOVING: \n%s", pBuffer);
|
||||||
|
// Move the end of the string
|
||||||
|
memmove(pBuffer + startIndex + strlen(replacement) , pBuffer + endIndex + 1, strlen(pBuffer) - endIndex + 1);
|
||||||
|
//printf("AFTER MOVING 1: \n%s", pBuffer);
|
||||||
|
// Insert the replacement
|
||||||
|
memcpy(pBuffer + startIndex, replacement, strlen(replacement));
|
||||||
|
//strncpy(pBuffer + startIndex, replacement, strlen(replacement));
|
||||||
|
//printf("AFTER MOVING 2: \n%s", pBuffer);
|
||||||
|
return pBuffer;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Insert the string at the index, pushing "every chars to the right"
|
||||||
|
* @param source The shader as a string
|
||||||
|
* @param sourceLength The ALLOCATED length of the shader
|
||||||
|
* @param insertPoint The index at which the string is inserted.
|
||||||
|
* @param insertedString The string to insert
|
||||||
|
* @return The shader as a string, maybe in a different memory location
|
||||||
|
*/
|
||||||
|
char * InplaceInsertByIndex(char * source, int *sourceLength, const int insertPoint, const char *insertedString){
|
||||||
|
int insertLength = strlen(insertedString);
|
||||||
|
source = gl4es_resize_if_needed(source, sourceLength, insertLength);
|
||||||
|
memmove(source + insertPoint + insertLength, source + insertPoint, strlen(source) - insertPoint + 1);
|
||||||
|
memcpy(source + insertPoint, insertedString, insertLength);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
char* gl4es_inplace_replace(char* pBuffer, int* size, const char* S, const char* D)
|
char* gl4es_inplace_replace(char* pBuffer, int* size, const char* S, const char* D)
|
||||||
{
|
{
|
||||||
int lS = strlen(S), lD = strlen(D);
|
int lS = strlen(S), lD = strlen(D);
|
||||||
@ -129,13 +190,21 @@ char* gl4es_resize_if_needed(char* pBuffer, int *size, int addsize) {
|
|||||||
char* p = pBuffer;
|
char* p = pBuffer;
|
||||||
int newsize = strlen(pBuffer)+addsize+1;
|
int newsize = strlen(pBuffer)+addsize+1;
|
||||||
if (newsize>*size) {
|
if (newsize>*size) {
|
||||||
newsize += 100;
|
//newsize += 100;
|
||||||
p = (char*)realloc(pBuffer, newsize);
|
p = (char*)realloc(pBuffer, newsize);
|
||||||
*size=newsize;
|
*size=newsize;
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int isDigit(char value){
|
||||||
|
return (value >= '0' && value <= '9');
|
||||||
|
}
|
||||||
|
|
||||||
|
int isValidFunctionName(char value){
|
||||||
|
return ((value >= 'a' && value <= 'z') || (value >= 'A' && value <= 'Z') || (value == '_'));
|
||||||
|
}
|
||||||
|
|
||||||
char* gl4es_append(char* pBuffer, int* size, const char* S) {
|
char* gl4es_append(char* pBuffer, int* size, const char* S) {
|
||||||
char* p =pBuffer;
|
char* p =pBuffer;
|
||||||
p = gl4es_resize_if_needed(pBuffer, size, strlen(S));
|
p = gl4es_resize_if_needed(pBuffer, size, strlen(S));
|
||||||
@ -246,3 +315,24 @@ char* gl4es_inplace_replace_simple(char* pBuffer, int* size, const char* S, cons
|
|||||||
|
|
||||||
return pBuffer;
|
return pBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// for vgpu/shaderconv.c
|
||||||
|
const char* FindString(const char* pBuffer, const char* S) __attribute__((alias("gl4es_find_string")));
|
||||||
|
char* FindStringNC(char* pBuffer, const char* S) __attribute__((alias("gl4es_find_string_nc")));
|
||||||
|
int CountString(const char* pBuffer, const char* S) __attribute__((alias("gl4es_count_string")));
|
||||||
|
char* ResizeIfNeeded(char* pBuffer, int *size, int addsize) __attribute__((alias("gl4es_resize_if_needed")));
|
||||||
|
char* InplaceReplace(char* pBuffer, int* size, const char* S, const char* D) __attribute__((alias("gl4es_inplace_replace")));
|
||||||
|
char* Append(char* pBuffer, int* size, const char* S) __attribute__((alias("gl4es_append")));
|
||||||
|
char* InplaceInsert(char* pBuffer, const char* S, char* master, int* size) __attribute__((alias("gl4es_inplace_insert")));
|
||||||
|
char* GetLine(char* pBuffer, int num) __attribute__((alias("gl4es_getline")));
|
||||||
|
int CountLine(const char* pBuffer) __attribute__((alias("gl4es_countline")));
|
||||||
|
int GetLineFor(const char* pBuffer, const char* S) __attribute__((alias("gl4es_getline_for")));
|
||||||
|
char* StrNext(char *pBuffer, const char* S) __attribute__((alias("gl4es_str_next")));
|
||||||
|
char* NextStr(char* pBuffer) __attribute__((alias("gl4es_next_str")));
|
||||||
|
char* PrevStr(char* Str, char* pBuffer) __attribute__((alias("gl4es_prev_str")));
|
||||||
|
char* NextBlank(char* pBuffer) __attribute__((alias("gl4es_next_blank")));
|
||||||
|
char* NextLine(char* pBuffer) __attribute__((alias("gl4es_next_line")));
|
||||||
|
const char* GetNextStr(char* pBuffer) __attribute__((alias("gl4es_get_next_str")));
|
||||||
|
int CountStringSimple(char* pBuffer, const char* S) __attribute__((alias("gl4es_countstring_simple")));
|
||||||
|
char* InplaceReplaceSimple(char* pBuffer, int* size, const char* S, const char* D) __attribute__((alias("gl4es_inplace_replace_simple")));
|
@ -20,11 +20,40 @@ char* gl4es_prev_str(char* Str, char* pBuffer); // go to previous non "blank"
|
|||||||
char* gl4es_next_blank(char* pBuffer); // go to next "blank"
|
char* gl4es_next_blank(char* pBuffer); // go to next "blank"
|
||||||
char* gl4es_next_line(char* pBuffer); // go to next new line (crlf not included)
|
char* gl4es_next_line(char* pBuffer); // go to next new line (crlf not included)
|
||||||
|
|
||||||
|
|
||||||
const char* gl4es_get_next_str(char* pBuffer); // get a (static) copy of next str (until next separator), can be a simple number or separator also
|
const char* gl4es_get_next_str(char* pBuffer); // get a (static) copy of next str (until next separator), can be a simple number or separator also
|
||||||
|
|
||||||
// those function don't try to be smart with separators...
|
// those function don't try to be smart with separators...
|
||||||
int gl4es_countstring_simple(char* pBuffer, const char* S);
|
int gl4es_countstring_simple(char* pBuffer, const char* S);
|
||||||
char* gl4es_inplace_replace_simple(char* pBuffer, int* size, const char* S, const char* D);
|
char* gl4es_inplace_replace_simple(char* pBuffer, int* size, const char* S, const char* D);
|
||||||
|
|
||||||
|
// dare not to change their names into gl4es_xxx :(
|
||||||
|
int isDigit(char value);
|
||||||
|
int isValidFunctionName(char value);
|
||||||
|
void AppendToEnd(char **str, const char *suffix);
|
||||||
|
void InsertAtBeginning(char **str, const char *prefix);
|
||||||
|
|
||||||
|
char * InplaceReplaceByIndex(char* pBuffer, int* size, int startIndex, int endIndex, const char* replacement);
|
||||||
|
char * InplaceInsertByIndex(char * source, int *sourceLength, int insertPoint, const char *insertedString);
|
||||||
|
|
||||||
|
extern const char* FindString(const char* pBuffer, const char* S);
|
||||||
|
extern char* FindStringNC(char* pBuffer, const char* S);
|
||||||
|
extern int CountString(const char* pBuffer, const char* S);
|
||||||
|
extern char* ResizeIfNeeded(char* pBuffer, int *size, int addsize);
|
||||||
|
extern char* InplaceReplace(char* pBuffer, int* size, const char* S, const char* D);
|
||||||
|
extern char* Append(char* pBuffer, int* size, const char* S);
|
||||||
|
extern char* InplaceInsert(char* pBuffer, const char* S, char* master, int* size);
|
||||||
|
extern char* GetLine(char* pBuffer, int num);
|
||||||
|
extern int CountLine(const char* pBuffer);
|
||||||
|
extern int GetLineFor(const char* pBuffer, const char* S);
|
||||||
|
extern char* StrNext(char *pBuffer, const char* S);
|
||||||
|
extern char* NextStr(char* pBuffer);
|
||||||
|
extern char* PrevStr(char* Str, char* pBuffer);
|
||||||
|
extern char* NextBlank(char* pBuffer);
|
||||||
|
extern char* NextLine(char* pBuffer);
|
||||||
|
extern const char* GetNextStr(char* pBuffer);
|
||||||
|
extern int CountStringSimple(char* pBuffer, const char* S);
|
||||||
|
extern char* InplaceReplaceSimple(char* pBuffer, int* size, const char* S, const char* D);
|
||||||
|
|
||||||
|
|
||||||
#endif // _GL4ES_STRING_UTILS_H_
|
#endif // _GL4ES_STRING_UTILS_H_
|
||||||
|
@ -400,7 +400,7 @@ void APIENTRY_GL4ES gl4es_glTexParameterf(GLenum target, GLenum pname, GLfloat p
|
|||||||
gl4es_glTexParameterfv(target, pname, ¶m);
|
gl4es_glTexParameterfv(target, pname, ¶m);
|
||||||
}
|
}
|
||||||
void gl4es_glTexParameterf_real(GLenum target, GLenum pname, GLfloat param) {
|
void gl4es_glTexParameterf_real(GLenum target, GLenum pname, GLfloat param) {
|
||||||
DBG(SHUT_LOGD("MobileGlues-gl4es: glTexParameterfv(%s, %s, [%f(%s)...])\n", PrintEnum(target), PrintEnum(pname), params[0], PrintEnum(params[0]));)
|
DBG(SHUT_LOGD("MobileGlues-gl4es: glTexParameterfv(%s, %s, [%f(%s)...])\n", PrintEnum(target), PrintEnum(pname), param, PrintEnum(param));)
|
||||||
GLfloat* params = ¶m;
|
GLfloat* params = ¶m;
|
||||||
if(!glstate->list.pending) {
|
if(!glstate->list.pending) {
|
||||||
PUSH_IF_COMPILING(glTexParameterfv);
|
PUSH_IF_COMPILING(glTexParameterfv);
|
||||||
@ -462,7 +462,7 @@ void APIENTRY_GL4ES gl4es_glTexParameteri(GLenum target, GLenum pname, GLint par
|
|||||||
gl4es_glTexParameterfv(target, pname, &fparam);
|
gl4es_glTexParameterfv(target, pname, &fparam);
|
||||||
}
|
}
|
||||||
void gl4es_glTexParameteri_real(GLenum target, GLenum pname, GLint param) {
|
void gl4es_glTexParameteri_real(GLenum target, GLenum pname, GLint param) {
|
||||||
DBG(SHUT_LOGD("MobileGlues-gl4es: glTexParameterfv(%s, %s, [%f(%s)...])\n", PrintEnum(target), PrintEnum(pname), params[0], PrintEnum(params[0]));)
|
DBG(SHUT_LOGD("MobileGlues-gl4es: glTexParameterfv(%s, %s, [%f(%s)...])\n", PrintEnum(target), PrintEnum(pname), param, PrintEnum(param));)
|
||||||
if(!glstate->list.pending) {
|
if(!glstate->list.pending) {
|
||||||
GLfloat *params = ¶m;
|
GLfloat *params = ¶m;
|
||||||
PUSH_IF_COMPILING(glTexParameterfv);
|
PUSH_IF_COMPILING(glTexParameterfv);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <GLES3/gl32.h>
|
||||||
#include "uniform.h"
|
#include "uniform.h"
|
||||||
|
|
||||||
#include "../glx/hardext.h"
|
#include "../glx/hardext.h"
|
||||||
@ -227,6 +228,10 @@ void GoUniformiv(program_t *glprogram, GLint location, int size, int count, cons
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m = kh_value(glprogram->uniform, k);
|
m = kh_value(glprogram->uniform, k);
|
||||||
|
if(m->type == GL_FLOAT && count == 1) {
|
||||||
|
glUniform1f(location, (float)*value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(size != n_uniform(m->type) || !is_uniform_int(m->type) || count>m->size) {
|
if(size != n_uniform(m->type) || !is_uniform_int(m->type) || count>m->size) {
|
||||||
errorShim(GL_INVALID_OPERATION);
|
errorShim(GL_INVALID_OPERATION);
|
||||||
return;
|
return;
|
||||||
|
1358
src/main/cpp/gl/gl4es/gl/vgpu/shaderconv.c
Normal file
1358
src/main/cpp/gl/gl4es/gl/vgpu/shaderconv.c
Normal file
File diff suppressed because it is too large
Load Diff
47
src/main/cpp/gl/gl4es/gl/vgpu/shaderconv.h
Normal file
47
src/main/cpp/gl/gl4es/gl/vgpu/shaderconv.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
//
|
||||||
|
// Created by serpentspirale on 13/01/2022.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef UNTITLED_SHADERCONV_H
|
||||||
|
#define UNTITLED_SHADERCONV_H
|
||||||
|
|
||||||
|
#include "../shader.h"
|
||||||
|
|
||||||
|
char* ConvertShaderVgpu(struct shader_s* shader_source);
|
||||||
|
|
||||||
|
char * GLSLHeader(char* source);
|
||||||
|
char * RemoveConstInsideBlocks(char* source, int * sourceLength);
|
||||||
|
char * ForceIntegerArrayAccess(char* source, int * sourceLength);
|
||||||
|
char * CoerceIntToFloat(char * source, int * sourceLength);
|
||||||
|
char * ReplaceModOperator(char * source, int * sourceLength);
|
||||||
|
char * WrapIvecFunctions(char * source, int * sourceLength);
|
||||||
|
char * WrapFunction(char * source, int * sourceLength, char * functionName, char * wrapperFunctionName, char * wrapperFunction);
|
||||||
|
int FindPositionAfterDirectives(char * source);
|
||||||
|
int FindPositionAfterVersion(char * source);
|
||||||
|
char * ReplaceGLFragData(char * source, int * sourceLength);
|
||||||
|
char * ReplaceGLFragColor(char * source, int * sourceLength);
|
||||||
|
char * ReplaceVariableName(char * source, int * sourceLength, char * initialName, char* newName);
|
||||||
|
char * ReplaceFunctionName(char * source, int * sourceLength, char * initialName, char * finalName);
|
||||||
|
char * RemoveUnsupportedExtensions(char * source);
|
||||||
|
int doesShaderVersionContainsES(const char * source);
|
||||||
|
char *ReplacePrecisionQualifiers(char *source, int *sourceLength, int isVertex);
|
||||||
|
char * GetClosingTokens(char openingToken);
|
||||||
|
int isOpeningToken(char openingToken);
|
||||||
|
int GetClosingTokenPosition(const char * source, int initialTokenPosition);
|
||||||
|
int GetClosingTokenPositionTokenOverride(const char * source, int initialTokenPosition, char initialToken);
|
||||||
|
int GetNextTokenPosition(const char * source, int initialPosition, char token, const char * acceptedChars);
|
||||||
|
void GetNextWord(char *source, int startPoint, int * startWord, int * endWord);
|
||||||
|
unsigned long strstrPos(const char * haystack, const char * needle);
|
||||||
|
char * insertIntAtFunctionCall(char * source, int * sourceSize, const char * functionName, int argumentPosition);
|
||||||
|
char * InsertExtension(char * source, int * sourceLength, int insertPoint, const char * extension);
|
||||||
|
char * InsertExtensions(char *source, int *sourceLength);
|
||||||
|
int GetShaderVersion(const char * source);
|
||||||
|
char * ReplaceFragmentOut(char * source, int *sourceLength);
|
||||||
|
char * BackportConstArrays(char *source, int * sourceLength);
|
||||||
|
char * ExtractString(char * source, int startString, int endString);
|
||||||
|
char* ProcessSwitchCases(char* source, int* length);
|
||||||
|
|
||||||
|
|
||||||
|
char* GetOperandFromOperator(char* source, int operatorIndex, int rightOperand, int * limit);
|
||||||
|
|
||||||
|
#endif //UNTITLED_SHADERCONV_H
|
@ -424,23 +424,29 @@ void GetHardwareExtensions(int notest)
|
|||||||
hardext.vendor = VEND_ARM;
|
hardext.vendor = VEND_ARM;
|
||||||
else if(strstr(vendor, "Imagination Technologies"))
|
else if(strstr(vendor, "Imagination Technologies"))
|
||||||
hardext.vendor = VEND_IMGTEC;
|
hardext.vendor = VEND_IMGTEC;
|
||||||
if(hardext.esversion>1) {
|
|
||||||
if(testGLSL("#version 120", 1))
|
hardext.glsl120 = 0;
|
||||||
hardext.glsl120 = 1;
|
|
||||||
if(testGLSL("#version 300 es", 0))
|
|
||||||
hardext.glsl300es = 1;
|
hardext.glsl300es = 1;
|
||||||
if(testGLSL("#version 310 es", 1))
|
|
||||||
hardext.glsl310es = 1;
|
hardext.glsl310es = 1;
|
||||||
}
|
// TODO: Check gles caps
|
||||||
if(hardext.glsl120) {
|
|
||||||
SHUT_LOGD("MobileGlues-gl4es: GLSL 120 supported and used\n");
|
//if(hardext.esversion>1) {
|
||||||
}
|
// if(testGLSL("#version 120", 1))
|
||||||
if(hardext.glsl300es) {
|
// hardext.glsl120 = 1;
|
||||||
SHUT_LOGD("MobileGlues-gl4es: GLSL 300 es supported%s\n", (hardext.glsl120||hardext.glsl310es)?"":" and used");
|
// if(testGLSL("#version 300 es", 0))
|
||||||
}
|
// hardext.glsl300es = 1;
|
||||||
if(hardext.glsl310es) {
|
// if(testGLSL("#version 310 es", 1))
|
||||||
SHUT_LOGD("MobileGlues-gl4es: GLSL 310 es supported%s\n", hardext.glsl120?"":" and used");
|
// hardext.glsl310es = 1;
|
||||||
}
|
//}
|
||||||
|
//if(hardext.glsl120) {
|
||||||
|
// SHUT_LOGD("MobileGlues-gl4es: GLSL 120 supported and used\n");
|
||||||
|
//}
|
||||||
|
//if(hardext.glsl300es) {
|
||||||
|
// SHUT_LOGD("MobileGlues-gl4es: GLSL 300 es supported%s\n", (hardext.glsl120||hardext.glsl310es)?"":" and used");
|
||||||
|
//}
|
||||||
|
//if(hardext.glsl310es) {
|
||||||
|
// SHUT_LOGD("MobileGlues-gl4es: GLSL 310 es supported%s\n", hardext.glsl120?"":" and used");
|
||||||
|
//}
|
||||||
|
|
||||||
#ifndef NOEGL
|
#ifndef NOEGL
|
||||||
if(strstr(gl4es_egl_eglQueryString(eglDisplay, EGL_EXTENSIONS), "EGL_KHR_gl_colorspace")) {
|
if(strstr(gl4es_egl_eglQueryString(eglDisplay, EGL_EXTENSIONS), "EGL_KHR_gl_colorspace")) {
|
||||||
|
@ -32,13 +32,13 @@ NATIVE_FUNCTION_HEAD(void, glClearColor, GLfloat red, GLfloat green, GLfloat blu
|
|||||||
NATIVE_FUNCTION_HEAD(void, glClearDepthf, GLfloat d) NATIVE_FUNCTION_END_NO_RETURN(void, glClearDepthf, d)
|
NATIVE_FUNCTION_HEAD(void, glClearDepthf, GLfloat d) NATIVE_FUNCTION_END_NO_RETURN(void, glClearDepthf, d)
|
||||||
NATIVE_FUNCTION_HEAD(void, glClearStencil, GLint s) NATIVE_FUNCTION_END_NO_RETURN(void, glClearStencil, s)
|
NATIVE_FUNCTION_HEAD(void, glClearStencil, GLint s) NATIVE_FUNCTION_END_NO_RETURN(void, glClearStencil, s)
|
||||||
NATIVE_FUNCTION_HEAD(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) NATIVE_FUNCTION_END_NO_RETURN(void, glColorMask, red,green,blue,alpha)
|
NATIVE_FUNCTION_HEAD(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) NATIVE_FUNCTION_END_NO_RETURN(void, glColorMask, red,green,blue,alpha)
|
||||||
NATIVE_FUNCTION_HEAD(void, glCompileShader, GLuint shader) NATIVE_FUNCTION_END_NO_RETURN(void, glCompileShader, shader)
|
//NATIVE_FUNCTION_HEAD(void, glCompileShader, GLuint shader) NATIVE_FUNCTION_END_NO_RETURN(void, glCompileShader, shader)
|
||||||
NATIVE_FUNCTION_HEAD(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data) NATIVE_FUNCTION_END_NO_RETURN(void, glCompressedTexImage2D, target,level,internalformat,width,height,border,imageSize,data)
|
NATIVE_FUNCTION_HEAD(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data) NATIVE_FUNCTION_END_NO_RETURN(void, glCompressedTexImage2D, target,level,internalformat,width,height,border,imageSize,data)
|
||||||
NATIVE_FUNCTION_HEAD(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data) NATIVE_FUNCTION_END_NO_RETURN(void, glCompressedTexSubImage2D, target,level,xoffset,yoffset,width,height,format,imageSize,data)
|
NATIVE_FUNCTION_HEAD(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data) NATIVE_FUNCTION_END_NO_RETURN(void, glCompressedTexSubImage2D, target,level,xoffset,yoffset,width,height,format,imageSize,data)
|
||||||
//NATIVE_FUNCTION_HEAD(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) NATIVE_FUNCTION_END_NO_RETURN(void, glCopyTexImage2D, target,level,internalformat,x,y,width,height,border)
|
//NATIVE_FUNCTION_HEAD(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) NATIVE_FUNCTION_END_NO_RETURN(void, glCopyTexImage2D, target,level,internalformat,x,y,width,height,border)
|
||||||
//NATIVE_FUNCTION_HEAD(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) NATIVE_FUNCTION_END_NO_RETURN(void, glCopyTexSubImage2D, target,level,xoffset,yoffset,x,y,width,height)
|
//NATIVE_FUNCTION_HEAD(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) NATIVE_FUNCTION_END_NO_RETURN(void, glCopyTexSubImage2D, target,level,xoffset,yoffset,x,y,width,height)
|
||||||
NATIVE_FUNCTION_HEAD(GLuint, glCreateProgram) NATIVE_FUNCTION_END(GLuint, glCreateProgram)
|
//NATIVE_FUNCTION_HEAD(GLuint, glCreateProgram) NATIVE_FUNCTION_END(GLuint, glCreateProgram)
|
||||||
NATIVE_FUNCTION_HEAD(GLuint, glCreateShader, GLenum type) NATIVE_FUNCTION_END(GLuint, glCreateShader, type)
|
//NATIVE_FUNCTION_HEAD(GLuint, glCreateShader, GLenum type) NATIVE_FUNCTION_END(GLuint, glCreateShader, type)
|
||||||
NATIVE_FUNCTION_HEAD(void, glCullFace, GLenum mode) NATIVE_FUNCTION_END_NO_RETURN(void, glCullFace, mode)
|
NATIVE_FUNCTION_HEAD(void, glCullFace, GLenum mode) NATIVE_FUNCTION_END_NO_RETURN(void, glCullFace, mode)
|
||||||
//NATIVE_FUNCTION_HEAD(void, glDeleteBuffers, GLsizei n, const GLuint *buffers) NATIVE_FUNCTION_END_NO_RETURN(void, glDeleteBuffers, n,buffers)
|
//NATIVE_FUNCTION_HEAD(void, glDeleteBuffers, GLsizei n, const GLuint *buffers) NATIVE_FUNCTION_END_NO_RETURN(void, glDeleteBuffers, n,buffers)
|
||||||
NATIVE_FUNCTION_HEAD(void, glDeleteFramebuffers, GLsizei n, const GLuint *framebuffers) NATIVE_FUNCTION_END_NO_RETURN(void, glDeleteFramebuffers, n,framebuffers)
|
NATIVE_FUNCTION_HEAD(void, glDeleteFramebuffers, GLsizei n, const GLuint *framebuffers) NATIVE_FUNCTION_END_NO_RETURN(void, glDeleteFramebuffers, n,framebuffers)
|
||||||
|
@ -943,7 +943,7 @@ STUB_FUNCTION_HEAD(void, glEvaluateDepthValuesARB,void); STUB_FUNCTION_END_NO_RE
|
|||||||
//STUB_FUNCTION_HEAD(void, glGetObjectParameterfvARB, GLhandleARB obj, GLenum pname, GLfloat* params); STUB_FUNCTION_END_NO_RETURN(void, glGetObjectParameterfvARB,obj,pname,params)
|
//STUB_FUNCTION_HEAD(void, glGetObjectParameterfvARB, GLhandleARB obj, GLenum pname, GLfloat* params); STUB_FUNCTION_END_NO_RETURN(void, glGetObjectParameterfvARB,obj,pname,params)
|
||||||
//STUB_FUNCTION_HEAD(void, glGetObjectParameterivARB, GLhandleARB obj, GLenum pname, GLint* params); STUB_FUNCTION_END_NO_RETURN(void, glGetObjectParameterivARB,obj,pname,params)
|
//STUB_FUNCTION_HEAD(void, glGetObjectParameterivARB, GLhandleARB obj, GLenum pname, GLint* params); STUB_FUNCTION_END_NO_RETURN(void, glGetObjectParameterivARB,obj,pname,params)
|
||||||
STUB_FUNCTION_HEAD(void, glGetInfoLogARB, GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB* infoLog); STUB_FUNCTION_END_NO_RETURN(void, glGetInfoLogARB,obj,maxLength,length,infoLog)
|
STUB_FUNCTION_HEAD(void, glGetInfoLogARB, GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB* infoLog); STUB_FUNCTION_END_NO_RETURN(void, glGetInfoLogARB,obj,maxLength,length,infoLog)
|
||||||
STUB_FUNCTION_HEAD(void, glGetAttachedObjectsARB, GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB* obj); STUB_FUNCTION_END_NO_RETURN(void, glGetAttachedObjectsARB,containerObj,maxCount,count,obj)
|
//STUB_FUNCTION_HEAD(void, ,glGetAttachedObjectsARB GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB* obj); STUB_FUNCTION_END_NO_RETURN(void, glGetAttachedObjectsARB,containerObj,maxCount,count,obj)
|
||||||
STUB_FUNCTION_HEAD(void, glNamedStringARB, GLenum type, GLint namelen, const GLchar* name, GLint stringlen, const GLchar* string); STUB_FUNCTION_END_NO_RETURN(void, glNamedStringARB,type,namelen,name,stringlen,string)
|
STUB_FUNCTION_HEAD(void, glNamedStringARB, GLenum type, GLint namelen, const GLchar* name, GLint stringlen, const GLchar* string); STUB_FUNCTION_END_NO_RETURN(void, glNamedStringARB,type,namelen,name,stringlen,string)
|
||||||
STUB_FUNCTION_HEAD(void, glDeleteNamedStringARB, GLint namelen, const GLchar* name); STUB_FUNCTION_END_NO_RETURN(void, glDeleteNamedStringARB,namelen,name)
|
STUB_FUNCTION_HEAD(void, glDeleteNamedStringARB, GLint namelen, const GLchar* name); STUB_FUNCTION_END_NO_RETURN(void, glDeleteNamedStringARB,namelen,name)
|
||||||
STUB_FUNCTION_HEAD(void, glCompileShaderIncludeARB, GLuint shader, GLsizei count, const GLchar* const*path, const GLint* length); STUB_FUNCTION_END_NO_RETURN(void, glCompileShaderIncludeARB,shader,count,path,length)
|
STUB_FUNCTION_HEAD(void, glCompileShaderIncludeARB, GLuint shader, GLsizei count, const GLchar* const*path, const GLint* length); STUB_FUNCTION_END_NO_RETURN(void, glCompileShaderIncludeARB,shader,count,path,length)
|
||||||
@ -1627,8 +1627,8 @@ STUB_FUNCTION_HEAD(void, glFogCoordfvEXT,const GLfloat* coord); STUB_FUNCTION_EN
|
|||||||
STUB_FUNCTION_HEAD(void, glFogCoorddEXT, GLdouble coord); STUB_FUNCTION_END_NO_RETURN(void, glFogCoorddEXT,coord)
|
STUB_FUNCTION_HEAD(void, glFogCoorddEXT, GLdouble coord); STUB_FUNCTION_END_NO_RETURN(void, glFogCoorddEXT,coord)
|
||||||
STUB_FUNCTION_HEAD(void, glFogCoorddvEXT,const GLdouble* coord); STUB_FUNCTION_END_NO_RETURN(void, glFogCoorddvEXT,coord)
|
STUB_FUNCTION_HEAD(void, glFogCoorddvEXT,const GLdouble* coord); STUB_FUNCTION_END_NO_RETURN(void, glFogCoorddvEXT,coord)
|
||||||
STUB_FUNCTION_HEAD(void, glFogCoordPointerEXT, GLenum type, GLsizei stride, const void* pointer); STUB_FUNCTION_END_NO_RETURN(void, glFogCoordPointerEXT,type,stride,pointer)
|
STUB_FUNCTION_HEAD(void, glFogCoordPointerEXT, GLenum type, GLsizei stride, const void* pointer); STUB_FUNCTION_END_NO_RETURN(void, glFogCoordPointerEXT,type,stride,pointer)
|
||||||
STUB_FUNCTION_HEAD(void, glFramebufferTexture1DEXT, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); STUB_FUNCTION_END_NO_RETURN(void, glFramebufferTexture1DEXT,target,attachment,textarget,texture,level)
|
//STUB_FUNCTION_HEAD(void, glFramebufferTexture1DEXT, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); STUB_FUNCTION_END_NO_RETURN(void, glFramebufferTexture1DEXT,target,attachment,textarget,texture,level)
|
||||||
STUB_FUNCTION_HEAD(void, glFramebufferTexture3DEXT, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); STUB_FUNCTION_END_NO_RETURN(void, glFramebufferTexture3DEXT,target,attachment,textarget,texture,level,zoffset)
|
//STUB_FUNCTION_HEAD(void, glFramebufferTexture3DEXT, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); STUB_FUNCTION_END_NO_RETURN(void, glFramebufferTexture3DEXT,target,attachment,textarget,texture,level,zoffset)
|
||||||
STUB_FUNCTION_HEAD(void, glProgramEnvParameters4fvEXT, GLenum target, GLuint index, GLsizei count, const GLfloat* params); STUB_FUNCTION_END_NO_RETURN(void, glProgramEnvParameters4fvEXT,target,index,count,params)
|
STUB_FUNCTION_HEAD(void, glProgramEnvParameters4fvEXT, GLenum target, GLuint index, GLsizei count, const GLfloat* params); STUB_FUNCTION_END_NO_RETURN(void, glProgramEnvParameters4fvEXT,target,index,count,params)
|
||||||
STUB_FUNCTION_HEAD(void, glProgramLocalParameters4fvEXT, GLenum target, GLuint index, GLsizei count, const GLfloat* params); STUB_FUNCTION_END_NO_RETURN(void, glProgramLocalParameters4fvEXT,target,index,count,params)
|
STUB_FUNCTION_HEAD(void, glProgramLocalParameters4fvEXT, GLenum target, GLuint index, GLsizei count, const GLfloat* params); STUB_FUNCTION_END_NO_RETURN(void, glProgramLocalParameters4fvEXT,target,index,count,params)
|
||||||
//STUB_FUNCTION_HEAD(void, glBindFragDataLocationEXT, GLuint program, GLuint color, const GLchar* name); STUB_FUNCTION_END_NO_RETURN(void, glBindFragDataLocationEXT,program,color,name)
|
//STUB_FUNCTION_HEAD(void, glBindFragDataLocationEXT, GLuint program, GLuint color, const GLchar* name); STUB_FUNCTION_END_NO_RETURN(void, glBindFragDataLocationEXT,program,color,name)
|
||||||
|
@ -705,6 +705,11 @@ std::string process_uniform_declarations(const std::string& glslCode) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" char* process_uniform_declarations_for_c(char* glslCode) {
|
||||||
|
std::string glslCode_str(glslCode);
|
||||||
|
return strdup(process_uniform_declarations(glslCode_str).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
std::string processOutColorLocations(const std::string& glslCode) {
|
std::string processOutColorLocations(const std::string& glslCode) {
|
||||||
const static std::regex pattern(R"(\n(out highp vec4 outColor)(\d+);)");
|
const static std::regex pattern(R"(\n(out highp vec4 outColor)(\d+);)");
|
||||||
const std::string replacement = "\nlayout(location=$2) $1$2;";
|
const std::string replacement = "\nlayout(location=$2) $1$2;";
|
||||||
@ -732,13 +737,7 @@ std::string GLSLtoGLSLES(const char* glsl_code, GLenum glsl_type, uint essl_vers
|
|||||||
}
|
}
|
||||||
|
|
||||||
int return_code = -1;
|
int return_code = -1;
|
||||||
//std::string converted = /*glsl_version<140? GLSLtoGLSLES_1(glsl_code, glsl_type, essl_version, return_code):*/GLSLtoGLSLES_2(glsl_code, glsl_type, essl_version, return_code);
|
std::string converted = /*glsl_version<140? GLSLtoGLSLES_1(glsl_code, glsl_type, essl_version, return_code):*/GLSLtoGLSLES_2(glsl_code, glsl_type, essl_version, return_code);
|
||||||
std::string converted;
|
|
||||||
if (glsl_version<140) {
|
|
||||||
converted = GLSLtoGLSLES_3(glsl_code, glsl_type, essl_version, return_code);
|
|
||||||
} else {
|
|
||||||
converted = GLSLtoGLSLES_2(glsl_code, glsl_type, essl_version, return_code);
|
|
||||||
}
|
|
||||||
if (return_code == 0 && !converted.empty()) {
|
if (return_code == 0 && !converted.empty()) {
|
||||||
converted = process_uniform_declarations(converted);
|
converted = process_uniform_declarations(converted);
|
||||||
Cache::get_instance().put(sha256_string.c_str(), converted.c_str());
|
Cache::get_instance().put(sha256_string.c_str(), converted.c_str());
|
||||||
@ -750,6 +749,7 @@ std::string GLSLtoGLSLES(const char* glsl_code, GLenum glsl_type, uint essl_vers
|
|||||||
|
|
||||||
std::string GLSLtoGLSLES_3(const char *glsl_code, GLenum glsl_type, uint essl_version, int& return_code) {
|
std::string GLSLtoGLSLES_3(const char *glsl_code, GLenum glsl_type, uint essl_version, int& return_code) {
|
||||||
LOG_W("Warning: use gl4es shaderconv to convert shader.")
|
LOG_W("Warning: use gl4es shaderconv to convert shader.")
|
||||||
|
/*
|
||||||
gl4es_code::GL4ES_shaderconv_need_t need;
|
gl4es_code::GL4ES_shaderconv_need_t need;
|
||||||
need.need_texcoord = -1;
|
need.need_texcoord = -1;
|
||||||
int shaderCompileStatus;
|
int shaderCompileStatus;
|
||||||
@ -775,6 +775,7 @@ std::string GLSLtoGLSLES_3(const char *glsl_code, GLenum glsl_type, uint essl_ve
|
|||||||
LOG_D("converted:\n%s", converted)
|
LOG_D("converted:\n%s", converted)
|
||||||
return_code = 0;
|
return_code = 0;
|
||||||
return std::string(converted);
|
return std::string(converted);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string replace_line_starting_with(const std::string& glslCode, const std::string& starting, const std::string& substitution = "") {
|
std::string replace_line_starting_with(const std::string& glslCode, const std::string& starting, const std::string& substitution = "") {
|
||||||
|
@ -21,6 +21,6 @@ std::string GLSLtoGLSLES(const char *glsl_code, GLenum glsl_type, uint esversion
|
|||||||
std::string GLSLtoGLSLES_1(const char *glsl_code, GLenum glsl_type, uint esversion, int& return_code);
|
std::string GLSLtoGLSLES_1(const char *glsl_code, GLenum glsl_type, uint esversion, int& return_code);
|
||||||
std::string GLSLtoGLSLES_2(const char *glsl_code, GLenum glsl_type, uint essl_version, int& return_code);
|
std::string GLSLtoGLSLES_2(const char *glsl_code, GLenum glsl_type, uint essl_version, int& return_code);
|
||||||
std::string GLSLtoGLSLES_3(const char *glsl_code, GLenum glsl_type, uint essl_version, int& return_code);
|
std::string GLSLtoGLSLES_3(const char *glsl_code, GLenum glsl_type, uint essl_version, int& return_code);
|
||||||
int getGLSLVersion(const char* glsl_code);
|
extern "C" int getGLSLVersion(const char* glsl_code);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -12,7 +12,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 0
|
||||||
|
|
||||||
namespace gl4es_code {
|
namespace gl4es_code {
|
||||||
|
|
||||||
|
@ -88,10 +88,15 @@ void glBindFragDataLocation(GLuint program, GLuint color, const GLchar *name) {
|
|||||||
shaderInfo.frag_data_changed = 1;
|
shaderInfo.frag_data_changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" EXPORT GLuint glCreateProgram() {
|
||||||
|
LOG()
|
||||||
|
GLuint program = gl4es_glCreateProgram();
|
||||||
|
CHECK_GL_ERROR
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
void glLinkProgram(GLuint program) {
|
void glLinkProgram(GLuint program) {
|
||||||
LOG()
|
LOG()
|
||||||
GET_GL4ES_FUNC(void, glLinkProgram, GLuint program)
|
|
||||||
CALL_GL4ES_FUNC(glLinkProgram, program)
|
|
||||||
LOG_D("glLinkProgram(%d)", program)
|
LOG_D("glLinkProgram(%d)", program)
|
||||||
if (!shaderInfo.converted.empty() && shaderInfo.frag_data_changed) {
|
if (!shaderInfo.converted.empty() && shaderInfo.frag_data_changed) {
|
||||||
GLES.glShaderSource(shaderInfo.id, 1, (const GLchar * const*) &shaderInfo.frag_data_changed_converted, nullptr);
|
GLES.glShaderSource(shaderInfo.id, 1, (const GLchar * const*) &shaderInfo.frag_data_changed_converted, nullptr);
|
||||||
@ -111,7 +116,9 @@ void glLinkProgram(GLuint program) {
|
|||||||
shaderInfo.converted = "";
|
shaderInfo.converted = "";
|
||||||
shaderInfo.frag_data_changed_converted = nullptr;
|
shaderInfo.frag_data_changed_converted = nullptr;
|
||||||
shaderInfo.frag_data_changed = 0;
|
shaderInfo.frag_data_changed = 0;
|
||||||
GLES.glLinkProgram(program);
|
//GLES.glLinkProgram(program);
|
||||||
|
GET_GL4ES_FUNC(void, glLinkProgram, GLuint program)
|
||||||
|
CALL_GL4ES_FUNC(glLinkProgram, program)
|
||||||
|
|
||||||
CHECK_GL_ERROR
|
CHECK_GL_ERROR
|
||||||
}
|
}
|
||||||
@ -191,4 +198,13 @@ EXPORT GLint glGetProgramResourceLocationIndex(GLuint program, GLenum programInt
|
|||||||
}
|
}
|
||||||
EXPORT void glGetProgramResourceLocationIndexARB(GLuint program, GLenum programInterface, const char *name) __attribute__((alias("glGetProgramResourceLocationIndex")));
|
EXPORT void glGetProgramResourceLocationIndexARB(GLuint program, GLenum programInterface, const char *name) __attribute__((alias("glGetProgramResourceLocationIndex")));
|
||||||
|
|
||||||
|
EXPORT void glGetAttachedObjectsARB(GLhandleARB program, GLsizei maxCount, GLsizei* count, GLhandleARB* objects) {
|
||||||
|
if (program == 0 || glIsProgram(program) == GL_FALSE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
glGetAttachedShaders(program, maxCount, count, (GLuint*)objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT GLhandleARB glCreateProgramARB() { return glCreateProgram(); }
|
||||||
|
|
||||||
}
|
}
|
@ -40,10 +40,22 @@ bool is_direct_shader(const char *glsl)
|
|||||||
return es3_ability;
|
return es3_ability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" EXPORT GLuint glCreateShader(GLenum type) {
|
||||||
|
LOG()
|
||||||
|
GLuint shader = gl4es_glCreateShader(type);
|
||||||
|
CHECK_GL_ERROR
|
||||||
|
return shader;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" EXPORT void glCompileShader(GLuint shader) {
|
||||||
|
LOG()
|
||||||
|
gl4es_glCompileShader(shader);
|
||||||
|
CHECK_GL_ERROR
|
||||||
|
}
|
||||||
|
|
||||||
void glShaderSource(GLuint shader, GLsizei count, const GLchar *const* string, const GLint *length) {
|
void glShaderSource(GLuint shader, GLsizei count, const GLchar *const* string, const GLint *length) {
|
||||||
LOG()
|
LOG()
|
||||||
GET_GL4ES_FUNC(void, glShaderSource, GLuint shader, GLsizei count, const GLchar *const* string, const GLint *length)
|
gl4es_glShaderSource(shader,count,string,length);
|
||||||
CALL_GL4ES_FUNC(glShaderSource, shader, count, string, length)
|
|
||||||
shaderInfo.id = 0;
|
shaderInfo.id = 0;
|
||||||
shaderInfo.converted = "";
|
shaderInfo.converted = "";
|
||||||
shaderInfo.frag_data_changed = 0;
|
shaderInfo.frag_data_changed = 0;
|
||||||
@ -69,6 +81,7 @@ void glShaderSource(GLuint shader, GLsizei count, const GLchar *const* string, c
|
|||||||
essl_src = glsl_src;
|
essl_src = glsl_src;
|
||||||
} else {
|
} else {
|
||||||
int glsl_version = getGLSLVersion(glsl_src.c_str());
|
int glsl_version = getGLSLVersion(glsl_src.c_str());
|
||||||
|
if (glsl_version < 140) { LOG_D("Shader won't be processed in mg shaderconv."); return; } // will be converted in gl4es
|
||||||
LOG_D("[INFO] [Shader] Shader source: ")
|
LOG_D("[INFO] [Shader] Shader source: ")
|
||||||
LOG_D("%s", glsl_src.c_str())
|
LOG_D("%s", glsl_src.c_str())
|
||||||
GLint shaderType;
|
GLint shaderType;
|
||||||
@ -87,9 +100,7 @@ void glShaderSource(GLuint shader, GLsizei count, const GLchar *const* string, c
|
|||||||
shaderInfo.converted = essl_src;
|
shaderInfo.converted = essl_src;
|
||||||
const char* s[] = { essl_src.c_str() };
|
const char* s[] = { essl_src.c_str() };
|
||||||
GLES.glShaderSource(shader, count, s, nullptr);
|
GLES.glShaderSource(shader, count, s, nullptr);
|
||||||
}
|
} else LOG_E("Failed to convert glsl.")
|
||||||
else
|
|
||||||
LOG_E("Failed to convert glsl.")
|
|
||||||
CHECK_GL_ERROR
|
CHECK_GL_ERROR
|
||||||
} else {
|
} else {
|
||||||
LOG_E("No GLES.glShaderSource")
|
LOG_E("No GLES.glShaderSource")
|
||||||
@ -209,6 +220,9 @@ EXPORT void glVertexAttrib4ubvARB(GLuint index, const GLubyte *v) { glVertexAttr
|
|||||||
EXPORT void glVertexAttrib4usvARB(GLuint index, const GLushort *v) { glVertexAttrib4fv(index, (GLfloat*)v); }
|
EXPORT void glVertexAttrib4usvARB(GLuint index, const GLushort *v) { glVertexAttrib4fv(index, (GLfloat*)v); }
|
||||||
EXPORT void glVertexAttrib4uivARB(GLuint index, const GLuint *v) { glVertexAttrib4fv(index, (GLfloat*)v); }
|
EXPORT void glVertexAttrib4uivARB(GLuint index, const GLuint *v) { glVertexAttrib4fv(index, (GLfloat*)v); }
|
||||||
|
|
||||||
|
EXPORT void glCompileShaderARB(GLhandleARB shader) { glCompileShader(shader); }
|
||||||
|
EXPORT GLhandleARB glCreateShaderARB(GLenum shaderType) { return glCreateShader(shaderType); }
|
||||||
|
|
||||||
//EXPORT void glVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer) {
|
//EXPORT void glVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer) {
|
||||||
// glVertexAttribPointer(index, size, type, normalized, stride, pointer);
|
// glVertexAttribPointer(index, size, type, normalized, stride, pointer);
|
||||||
//}
|
//}
|
||||||
|
@ -526,6 +526,8 @@ GL_FUNC_TYPEDEF(void, glMultiDrawArraysIndirectEXT, GLenum mode, const void *ind
|
|||||||
GL_FUNC_TYPEDEF(void, glMultiDrawElementsIndirectEXT, GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride)
|
GL_FUNC_TYPEDEF(void, glMultiDrawElementsIndirectEXT, GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride)
|
||||||
GL_FUNC_TYPEDEF(void, glBruh)
|
GL_FUNC_TYPEDEF(void, glBruh)
|
||||||
GL_FUNC_TYPEDEF(void, glMultiDrawElementsBaseVertexEXT, GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex)
|
GL_FUNC_TYPEDEF(void, glMultiDrawElementsBaseVertexEXT, GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex)
|
||||||
|
GL_FUNC_TYPEDEF(void, glFramebufferTexture3DOES, GLenum target, GLenum attachment, GLenum textarget,
|
||||||
|
GLuint texture, GLint level, GLint layer)
|
||||||
|
|
||||||
#define GL_FUNC_DECL(name) \
|
#define GL_FUNC_DECL(name) \
|
||||||
name##_PTR name;
|
name##_PTR name;
|
||||||
@ -903,6 +905,8 @@ struct gles_func_t {
|
|||||||
GL_FUNC_DECL(glMultiDrawElementsBaseVertexEXT)
|
GL_FUNC_DECL(glMultiDrawElementsBaseVertexEXT)
|
||||||
|
|
||||||
GL_FUNC_DECL(glBruh)
|
GL_FUNC_DECL(glBruh)
|
||||||
|
|
||||||
|
GL_FUNC_DECL(glFramebufferTexture3DOES)
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct gles_func_t g_gles_func;
|
extern struct gles_func_t g_gles_func;
|
||||||
|
@ -580,6 +580,8 @@ void init_target_gles() {
|
|||||||
INIT_GLES_FUNC(glMultiDrawArraysIndirectEXT)
|
INIT_GLES_FUNC(glMultiDrawArraysIndirectEXT)
|
||||||
INIT_GLES_FUNC(glMultiDrawElementsIndirectEXT)
|
INIT_GLES_FUNC(glMultiDrawElementsIndirectEXT)
|
||||||
INIT_GLES_FUNC(glMultiDrawElementsBaseVertexEXT)
|
INIT_GLES_FUNC(glMultiDrawElementsBaseVertexEXT)
|
||||||
|
|
||||||
|
INIT_GLES_FUNC(glFramebufferTexture3DOES)
|
||||||
// INIT_GLES_FUNC(glBruh)
|
// INIT_GLES_FUNC(glBruh)
|
||||||
|
|
||||||
LOG_D("glMultiDrawArraysIndirectEXT() @ 0x%x", GLES.glMultiDrawArraysIndirectEXT)
|
LOG_D("glMultiDrawArraysIndirectEXT() @ 0x%x", GLES.glMultiDrawArraysIndirectEXT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user