Skip to content

Commit f8eec83

Browse files
author
Your Name
committed
QCXR
1 parent cee02e8 commit f8eec83

File tree

6 files changed

+28
-229
lines changed

6 files changed

+28
-229
lines changed

build/android/Regal/jni/Android.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ endif
1515

1616
# apitrace still needs -DANDROID=1
1717

18-
regal_cflags := -DANDROID=1 -DREGAL_NO_PNG=1 -DREGAL_CONFIG_FILE=/data/.regal -Werror -Wno-constant-logical-operand
18+
regal_cflags := -DANDROID=1 -DREGAL_NO_PNG=1 -DREGAL_CONFIG_FILE=/data/.regal -Wno-constant-logical-operand -Wno-register
1919

2020
regal_path := $(LOCAL_PATH)/../../../..
2121

@@ -190,7 +190,7 @@ LOCAL_C_INCLUDES := $(regal_c_includes)
190190
LOCAL_EXPORT_C_INCLUDES := $(regal_export_c_includes)
191191
LOCAL_STATIC_LIBRARIES := apitrace zlib snappy
192192
LOCAL_STATIC_LIBRARIES += glslopt pcre
193-
LOCAL_LDLIBS := -llog
193+
LOCAL_LDLIBS := -llog -lEGL -lGLESv2
194194
LOCAL_EXPORT_LDLIBS := -llog
195195
LOCAL_ARM_MODE := arm
196196
include $(BUILD_SHARED_LIBRARY)

build/android/Regal/jni/Application.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
NDK_TOOLCHAIN_VERSION := 4.8
33

44
APP_MODULES := Regal_static Regal
5-
APP_STL := stlport_static
6-
APP_PLATFORM := android-9
5+
APP_STL := c++_shared
6+
APP_PLATFORM := android-32
77

88
ifndef APP_OPTIM
99
ifeq ($(NDK_DEBUG),1)

src/regal/RegalEmuInfo.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ EmuInfo::init(const ContextInfo &contextInfo)
137137
#endif
138138

139139
#ifdef REGAL_GL_VERSION
140-
version = REGAL_EQUOTE(REGAL_GL_VERSION);
140+
version = "4.6";
141141
#else
142-
version = contextInfo.version;
142+
version = "4.6";
143143
#endif
144144

145145
#ifdef REGAL_GL_EXTENSIONS

src/regal/RegalIff.cpp

+1-220
Original file line numberDiff line numberDiff line change
@@ -4422,226 +4422,7 @@ void Iff::ShaderSource( RegalContext *ctx, GLuint shader, GLsizei count, const G
44224422
for ( int i = 0; i < count; i++ ) {
44234423
src += length != NULL ? string( srcstr[i], length[i] ) : string( srcstr[i] );
44244424
}
4425-
4426-
// comment out version in-place
4427-
int version = -1;
4428-
version = remove_version( src );
4429-
4430-
// if used, replace ftransform with rgl_ftform
4431-
bool uses_ftransform = replace_ftransform( src );
4432-
4433-
if ( legacy ) {
4434-
remove_precision( src );
4435-
}
4436-
4437-
// Preamble
4438-
4439-
string_list ss;
4440-
if (gles) {
4441-
// hack around #version 100 on x86 failing compilation
4442-
if ( ctx->info->gl_version_major >= 3 ) {
4443-
ss << "#version 120\n";
4444-
ss << "#define precision\n";
4445-
} else {
4446-
#if REGAL_FORCE_DESKTOP_GLSL
4447-
ss << "#version 140\n";
4448-
#else
4449-
ss << "#version 100\n";
4450-
#if !REGAL_SYS_EMSCRIPTEN
4451-
// GAB NOTE Dec 2018: do not use EXT_shadow_samplers on Emscripten/WebGL. This is not a valid WebGL extension, and make shader compilation fail.
4452-
ss << "#extension GL_EXT_shadow_samplers : enable\n";
4453-
ss << "#define shadow2D(a,b) vec4(shadow2DEXT(a,b))\n";
4454-
#else
4455-
// GAB Note Dec: 2019: OES_standard_derivatives is available on all browsers
4456-
ss << "#extension GL_OES_standard_derivatives : enable\n";
4457-
#endif
4458-
#endif
4459-
}
4460-
} else if (legacy) {
4461-
ss << "#version 120\n";
4462-
ss << "#define precision\n";
4463-
} else {
4464-
if (version > 0) {
4465-
// We should honor the version in the original shader if we can, but leave out for now.
4466-
//ss << "#version " << version << "\n";
4467-
if (shaderTypeMap[ shader ] == GL_VERTEX_SHADER) {
4468-
ss << "#define in attribute\n";
4469-
ss << "#define out varying\n";
4470-
} else {
4471-
ss << "#define in varying\n";
4472-
}
4473-
} else {
4474-
ss << "#version 140\n";
4475-
}
4476-
}
4477-
if (gles || legacy) {
4478-
if (shaderTypeMap[ shader ] == GL_VERTEX_SHADER) {
4479-
ss << "#define in attribute\n";
4480-
ss << "#define out varying\n";
4481-
} else {
4482-
ss << "#define in varying\n";
4483-
}
4484-
} else {
4485-
if ( shaderTypeMap[ shader ] == GL_VERTEX_SHADER ) {
4486-
} else {
4487-
ss << "#define gl_FragColor rglFragColor\n";
4488-
ss << "out vec4 rglFragColor;\n";
4489-
ss << "#define texture1D texture\n";
4490-
ss << "#define texture2D texture\n";
4491-
ss << "#define textureCube texture\n";
4492-
}
4493-
}
4494-
if ( gles ) {
4495-
ss << "precision highp float;\n";
4496-
}
4497-
4498-
ss << "#define centroid \n";
4499-
ss << "#define gl_FogFragCoord rglFogFragCoord\n";
4500-
if ( shaderTypeMap[ shader ] == GL_VERTEX_SHADER ) {
4501-
ss << "#define gl_Vertex rglVertex\n";
4502-
ss << "#define gl_Color rglColor\n";
4503-
ss << "#define gl_Normal rglNormal\n";
4504-
} else {
4505-
ss << "#define gl_Color rglFrontColor\n";
4506-
}
4507-
ss << "#define gl_FrontColor rglFrontColor\n";
4508-
if ( shaderTypeMap[ shader ] == GL_VERTEX_SHADER ) {
4509-
ss << "#define gl_SecondaryColor rglSecondaryColor\n";
4510-
} else {
4511-
ss << "#define gl_SecondaryColor rglFrontSecondaryColor\n";
4512-
}
4513-
4514-
ss << "#define gl_FrontSecondaryColor rglFrontSecondaryColor\n";
4515-
ss << "#define gl_ClipVertex rglClipVertex\n";
4516-
ss << "#define gl_FragDepth rglFragDepth\n";
4517-
if ( gles ) {
4518-
ss << "#define texture3d texture2d\n";
4519-
ss << "#define texture3D(a,b) texture2D(a,b.xy)\n";
4520-
ss << "#define sampler3D sampler2D\n";
4521-
}
4522-
4523-
if ( src.find( "gl_FogFragCoord" ) != string::npos ) {
4524-
ss << "out float rglFogFragCoord;\n";
4525-
}
4526-
4527-
// NOTE: ES 2.0 does not support gl_FragDepth, so we just discard it, for now
4528-
// See: http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf
4529-
4530-
if ( src.find( "gl_FragDepth" ) != string::npos ) {
4531-
ss << (shaderTypeMap[shader]==GL_VERTEX_SHADER ? "out" : " ") << " float rglFragDepth;\n";
4532-
}
4533-
4534-
if ( uses_ftransform || (src.find( "gl_Vertex" ) != string::npos) ) {
4535-
if ( shaderTypeMap[ shader ] == GL_VERTEX_SHADER ) {
4536-
ss << "in vec4 rglVertex;\n";
4537-
}
4538-
}
4539-
4540-
if ( src.find( "gl_Normal" ) != string::npos ) {
4541-
if ( shaderTypeMap[ shader ] == GL_VERTEX_SHADER ) {
4542-
ss << "in vec3 rglNormal;\n";
4543-
}
4544-
}
4545-
4546-
if ( src.find( "gl_Color" ) != string::npos ) {
4547-
if ( shaderTypeMap[ shader ] == GL_VERTEX_SHADER ) {
4548-
ss << "in vec4 rglColor;\n";
4549-
} else {
4550-
ss << "in vec4 rglFrontColor;\n";
4551-
}
4552-
}
4553-
4554-
if ( src.find( "gl_FrontColor" ) != string::npos ) {
4555-
ss << "out vec4 rglFrontColor;\n";
4556-
}
4557-
4558-
// NOTE: gl_SecondaryColor can be a vertex shader output, or a fragment shader input.
4559-
// See: http://www.opengl.org/registry/doc/GLSLangSpec.4.30.7.pdf
4560-
4561-
if ( src.find( "gl_SecondaryColor" ) != string::npos ) {
4562-
if ( shaderTypeMap[ shader ] == GL_VERTEX_SHADER )
4563-
{
4564-
ss << "in vec4 rglSecondaryColor;\n";
4565-
}
4566-
else
4567-
{
4568-
ss << "in vec4 rglFrontSecondaryColor;\n";
4569-
}
4570-
}
4571-
4572-
if ( src.find( "gl_FrontSecondaryColor" ) != string::npos ) {
4573-
ss << "out vec4 rglFrontSecondaryColor;\n";
4574-
}
4575-
if ( src.find( "gl_ClipVertex" ) != string::npos ) {
4576-
// should be "out", but temporarily disabled due to register pressure concerns
4577-
// ss << "out vec4 rglClipVertex;\n";
4578-
ss << "vec4 rglClipVertex;\n";
4579-
}
4580-
4581-
// the below needs to be automated instead of done ad hoc like this - Cass
4582-
// and it needs to handle "Inverse", "Transpose", and "InverseTranspose".
4583-
4584-
if ( src.find( "gl_NormalMatrix" ) != string::npos ) {
4585-
ss << "uniform mat3 rglNormalMatrix;\n";
4586-
}
4587-
4588-
if( src.find( "gl_ModelViewMatrix" ) != string::npos || uses_ftransform ) {
4589-
ss << "uniform mat4 rglModelViewMatrix;\n";
4590-
}
4591-
4592-
if( src.find( "gl_ModelViewMatrixInverseTranspose" ) != string::npos ) {
4593-
ss << "uniform mat4 rglModelViewMatrixInverseTranspose;\n";
4594-
}
4595-
4596-
if( src.find( "gl_ProjectionMatrix" ) != string::npos || uses_ftransform ) {
4597-
ss << "uniform mat4 rglProjectionMatrix;\n";
4598-
}
4599-
4600-
if( src.find( "gl_ModelViewProjectionMatrix" ) != string::npos ) {
4601-
ss << "uniform mat4 rglModelViewProjectionMatrix;\n";
4602-
}
4603-
4604-
const char *nums = "01234567";
4605-
for( int i = 0; i < 8; i++ ) {
4606-
if( src.find( string("gl_MultiTexCoord") + string( nums + i, 1 )) != string::npos ) {
4607-
ss << "#define gl_MultiTexCoord" << i << " rglMultiTexCoord" << i << "\n";
4608-
ss << "in vec4 rglMultiTexCoord" << i << ";\n";
4609-
}
4610-
}
4611-
4612-
// GAB Note Jan 2019: take "gl_TexCoord" into consideration
4613-
// Assume its size is REGAL_EMU_MAX_TEXTURE_UNITS (maybe this could be optimized by analysing max index used in the source shader
4614-
if ( shaderTypeMap[ shader ] == GL_VERTEX_SHADER ) {
4615-
ss << "#define gl_TexCoord rglTEXCOORD\n";
4616-
ss << "out vec4 rglTEXCOORD[" << REGAL_EMU_MAX_TEXTURE_UNITS << "];\n";
4617-
} else {
4618-
ss << "#define gl_TexCoord rglTEXCOORD\n";
4619-
ss << "in vec4 rglTEXCOORD[" << REGAL_EMU_MAX_TEXTURE_UNITS << "];\n";
4620-
}
4621-
4622-
const char * matrixSuffix[] = { "", "Inverse", "Transpose", "InverseTranspose" };
4623-
4624-
for( int i = 0; i < 4; i++ ) {
4625-
ss << "#define gl_ModelViewMatrix" << matrixSuffix[i] << " rglModelViewMatrix" << matrixSuffix[i] << "\n";
4626-
ss << "#define gl_ProjectionMatrix" << matrixSuffix[i] << " rglProjectionMatrix" << matrixSuffix[i] << "\n";
4627-
ss << "#define gl_ModelViewProjectionMatrix" << matrixSuffix[i] << " rglModelViewProjectionMatrix" << matrixSuffix[i] << "\n";
4628-
ss << "#define gl_TextureMatrix0" << matrixSuffix[i] << " rglTextureMatrix0" << matrixSuffix[i] << "\n";
4629-
ss << "\n";
4630-
}
4631-
4632-
ss << "#define gl_NormalMatrix rglNormalMatrix\n";
4633-
4634-
4635-
ss << "#define gl_Sampler0 rglSampler0\n\n";
4636-
4637-
if ( uses_ftransform )
4638-
{
4639-
ss << "vec4 rgl_ftform() { return gl_ProjectionMatrix * gl_ModelViewMatrix * rglVertex; }\n\n";
4640-
}
4641-
4642-
string preamble = ss.str();
4643-
src = preamble + src;
4644-
4425+
46454426
const GLchar * dumb = static_cast<const GLchar *>( src.c_str() );
46464427
const GLchar ** dumber = & dumb;
46474428
ctx->dispatcher.emulation.glShaderSource( shader, 1, dumber, NULL );

src/regal/RegalShader.h

+14
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ REGAL_GLOBAL_BEGIN
4242
#include "RegalEmu.h"
4343
#include "RegalIff.h"
4444

45+
46+
#if REGAL_GLSL_OPTIMIZER
47+
#include "ast.h"
48+
#include "glsl_parser_extras.h"
49+
#include "glsl_parser.h"
50+
#include "ir_optimization.h"
51+
#include "ir_print_glsl_visitor.h"
52+
#include "ir_print_visitor.h"
53+
#include "loop_analysis.h"
54+
#include "program.h"
55+
#include "linker.h"
56+
#endif // REGAL_GLSL_OPTIMIZER
57+
58+
4559
using std::string;
4660

4761
REGAL_GLOBAL_END

src/regal/RegalUtil.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@
432432
//
433433

434434
#ifndef REGAL_FORCE_CORE_PROFILE
435-
#define REGAL_FORCE_CORE_PROFILE 0
435+
#define REGAL_FORCE_CORE_PROFILE 1
436436
#endif
437437

438438
#ifndef REGAL_FORCE_ES1_PROFILE
@@ -457,12 +457,16 @@
457457
# if REGAL_SYS_EMSCRIPTEN
458458
# define REGAL_GLSL_OPTIMIZER 0
459459
# else
460-
# define REGAL_GLSL_OPTIMIZER 1
460+
# define REGAL_GLSL_OPTIMIZER 0
461461
# endif
462462
#endif
463463

464464
//
465465

466+
#ifndef REGAL_NAMESPACE
467+
#define REGAL_NAMESPACE 1
468+
#endif
469+
466470
#ifndef REGAL_STATIC_ES2
467471
# if REGAL_SYS_EMSCRIPTEN
468472
# define REGAL_STATIC_ES2 1
@@ -815,4 +819,4 @@ template <bool Norm> inline double ToDouble(const unsigned long int v ) {
815819

816820
REGAL_NAMESPACE_END
817821

818-
#endif
822+
#endif

0 commit comments

Comments
 (0)