Skip to content

Commit b308c8c

Browse files
committed
[Feat|Chore] (Shader): Remove glsl optimizer. Upgrade legacy glsl.
1 parent 01d63f5 commit b308c8c

8 files changed

Lines changed: 13 additions & 41 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ Please see [LICENSE](https://github.com/MobileGL-Dev/MobileGlues/blob/main/LICEN
4848

4949
**glslang** by **KhronosGroup** - [Various Licenses](https://github.com/KhronosGroup/glslang/blob/main/LICENSE.txt): [github](https://github.com/KhronosGroup/glslang)
5050

51-
**GlslOptimizerV2** by **aiekick** - [Apache License 2.0](https://github.com/aiekick/GlslOptimizerV2/blob/master/LICENSE): [github](https://github.com/aiekick/GlslOptimizerV2)
52-
5351
**cJSON** by **DaveGamble** - [MIT License](https://github.com/DaveGamble/cJSON/blob/master/LICENSE): [github](https://github.com/DaveGamble/cJSON)
5452

5553
**OpenGL Mathematics (*GLM*)** by **G-Truc Creation** - [The Happy Bunny License](https://github.com/g-truc/glm/blob/master/copying.txt): [github](https://github.com/g-truc/glm)

src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ else()
9999
target_link_libraries(${CMAKE_PROJECT_NAME}
100100
${CMAKE_SOURCE_DIR}/libraries/${ANDROID_ABI}/libglslang.a
101101
${CMAKE_SOURCE_DIR}/libraries/${ANDROID_ABI}/libspirv-cross-c-shared.so
102-
${CMAKE_SOURCE_DIR}/libraries/${ANDROID_ABI}/libshaderconv.so
103102
${CMAKE_SOURCE_DIR}/libraries/${ANDROID_ABI}/libGenericCodeGen.a
104103
${CMAKE_SOURCE_DIR}/libraries/${ANDROID_ABI}/libglslang-default-resource-limits.a
105104
${CMAKE_SOURCE_DIR}/libraries/${ANDROID_ABI}/libMachineIndependent.a
@@ -122,9 +121,6 @@ if(ANDROID)
122121
COMMAND ${CMAKE_COMMAND} -E copy_if_different
123122
${CMAKE_SOURCE_DIR}/libraries/${ANDROID_ABI}/libspirv-cross-c-shared.so
124123
$<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>
125-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
126-
${CMAKE_SOURCE_DIR}/libraries/${ANDROID_ABI}/libshaderconv.so
127-
$<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>
128124
)
129125
endif()
130126

@@ -134,4 +130,4 @@ if (PROFILING)
134130
add_library(perfetto STATIC ${CMAKE_SOURCE_DIR}/3rdparty/perfetto/sdk/perfetto.cc)
135131
target_link_libraries(${CMAKE_PROJECT_NAME} perfetto ${CMAKE_THREAD_LIBS_INIT})
136132
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC PROFILING=1)
137-
endif()
133+
endif()

src/main/cpp/gl/glsl/glsl_for_es.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
const char* atomicCounterEmulatedWatermark = "// Non-opaque atomic uniform converted to SSBO";
2222

23-
#if !defined(__APPLE__)
24-
char* (*MesaConvertShader)(const char *src, unsigned int type, unsigned int glsl, unsigned int essl);
25-
#endif
26-
2723
static TBuiltInResource InitResources()
2824
{
2925
TBuiltInResource Resources{};
@@ -353,7 +349,8 @@ std::string GLSLtoGLSLES(const char* glsl_code, GLenum glsl_type, uint essl_vers
353349
}
354350

355351
return_code = -1;
356-
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);
352+
//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);
353+
std::string converted = GLSLtoGLSLES_2(glsl_code, glsl_type, essl_version, return_code);
357354
if (return_code >= 0 && !converted.empty()) {
358355
converted = process_uniform_declarations(converted);
359356
Cache::get_instance().put(sha256_string.c_str(), converted.c_str());
@@ -762,9 +759,14 @@ std::string preprocess_glsl(const std::string& glsl, GLenum shaderType, bool* at
762759
int get_or_add_glsl_version(std::string& glsl) {
763760
int glsl_version = getGLSLVersion(glsl.c_str());
764761
if (glsl_version == -1) {
765-
glsl_version = 140;
766-
glsl.insert(0, "#version 140\n");
762+
glsl_version = 150;
763+
glsl.insert(0, "#version 150\n");
764+
} else if (glsl_version < 140) {
765+
// force upgrade glsl version
766+
glsl = replace_line_starting_with(glsl, "#version", "#version 150 compatibility\n");
767+
glsl_version = 150;
767768
}
769+
768770
LOG_D("GLSL version: %d",glsl_version)
769771
return glsl_version;
770772
}
@@ -912,7 +914,8 @@ std::string GLSLtoGLSLES_2(const char *glsl_code, GLenum glsl_type, uint essl_ve
912914
return essl;
913915
}
914916

915-
std::string GLSLtoGLSLES_1(const char *glsl_code, GLenum glsl_type, uint esversion, int& return_code) {
917+
std::string GLSLtoGLSLES_1(const char *glsl_code, GLenum glsl_type, uint esversion, int& return_code) { // useless now
918+
/*
916919
#if !defined(__APPLE__)
917920
LOG_W("Warning: use glsl optimizer to convert shader.")
918921
if (esversion < 300) esversion = 300;
@@ -924,4 +927,5 @@ std::string GLSLtoGLSLES_1(const char *glsl_code, GLenum glsl_type, uint esversi
924927
LOG_W_FORCE("Cannot convert glsl with version %d in MacOS/iOS", esversion);
925928
return std::string(glsl_code);
926929
#endif
930+
*/
927931
}
-7.65 MB
Binary file not shown.
-4.7 MB
Binary file not shown.
-6.32 MB
Binary file not shown.
-7.11 MB
Binary file not shown.

src/main/cpp/main.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,6 @@ __attribute__((used))
2222
#endif
2323
const char *license = "GNU LGPL-2.1 License";
2424

25-
#ifndef __APPLE__
26-
extern char *(*MesaConvertShader)(const char *src, unsigned int type,
27-
unsigned int glsl, unsigned int essl);
28-
void init_libshaderconv() {
29-
const char *shaderconv_lib = "libshaderconv";
30-
const char *func_name = "MesaConvertShader";
31-
const char *glslconv_name[] = {shaderconv_lib, nullptr};
32-
void *glslconv = open_lib(glslconv_name, shaderconv_lib);
33-
if (glslconv == nullptr) {
34-
LOG_D("%s not found\n", shaderconv_lib);
35-
} else {
36-
MesaConvertShader = (char *(*)(const char *, unsigned int, unsigned int,
37-
unsigned int))dlsym(glslconv, func_name);
38-
if (MesaConvertShader) {
39-
LOG_D("%s loaded\n", shaderconv_lib);
40-
} else {
41-
LOG_D("failed to load %s\n", shaderconv_lib);
42-
}
43-
}
44-
}
45-
#endif
46-
4725
void init_config() {
4826
if (check_path())
4927
config_refresh();
@@ -85,10 +63,6 @@ void proc_init() {
8563

8664
init_settings_post();
8765

88-
#ifndef __APPLE__
89-
init_libshaderconv();
90-
#endif
91-
9266
#if PROFILING
9367
init_perfetto();
9468
#endif

0 commit comments

Comments
 (0)