From 1d45cd0ff12c1feb29f74e73c9a3ffcac9bb760e Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Thu, 19 Mar 2015 10:31:36 +0530 Subject: [PATCH 01/11] Fix Javascript build. --- .gitignore | 3 + drivers/etc1/rg_etc1.cpp | 7 ++ platform/javascript/detect.py | 132 +++++++++++++++++----------------- 3 files changed, 78 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index 09fac622972..07af81a6c8c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ tools/editor/editor_icons.cpp make.bat log.txt +# Javascript specific +*.bc + # Android specific platform/android/java/local.properties platform/android/java/project.properties diff --git a/drivers/etc1/rg_etc1.cpp b/drivers/etc1/rg_etc1.cpp index cad9af8830e..28502191daa 100644 --- a/drivers/etc1/rg_etc1.cpp +++ b/drivers/etc1/rg_etc1.cpp @@ -24,6 +24,9 @@ namespace rg_etc1 { + inline long labs(long val) { + return val < 0 ? -val : val; + } inline int intabs(int val) { @@ -1915,7 +1918,11 @@ done: int v = etc1_decode_value(diff, inten, selector, packed_c); uint err = intabs(v - color); //printf("err: %d - %u = %u\n",v,color,err); + #ifdef JAVASCRIPT_ENABLED + if (err < best_error || best_error == cUINT32_MAX) + #else if (err < best_error) + #endif { best_error = err; best_packed_c = packed_c; diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 845b2e3395a..2067e19230c 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -3,91 +3,95 @@ import sys import string def is_active(): - return True - + return True + def get_name(): - return "JavaScript" + return "JavaScript" def can_build(): - import os - if (not os.environ.has_key("EMSCRIPTEN_ROOT")): - return False - return True + import os + if (not os.environ.has_key("EMSCRIPTEN_ROOT")): + return False + return True def get_opts(): - return [ - ['compress','Compress JS Executable','no'] - ] + return [ + ['compress','Compress JS Executable','no'] + ] def get_flags(): - return [ - ('lua', 'no'), - ('tools', 'no'), - ('nedmalloc', 'no'), - ('theora', 'no'), - ('tools', 'no'), - ('nedmalloc', 'no'), - ('vorbis', 'no'), - ('musepack', 'no'), - ('squirrel', 'no'), - ('squish', 'no'), - ('speex', 'no'), - ('old_scenes', 'no'), -# ('default_gui_theme', 'no'), + return [ + ('lua', 'no'), + ('tools', 'no'), + ('nedmalloc', 'no'), + ('theora', 'no'), + ('tools', 'no'), + ('nedmalloc', 'no'), + ('vorbis', 'no'), + ('musepack', 'no'), + ('squirrel', 'no'), + ('squish', 'no'), + ('speex', 'no'), + ('old_scenes', 'no'), +# ('default_gui_theme', 'no'), - #('builtin_zlib', 'no'), - ] + #('builtin_zlib', 'no'), + ] def configure(env): + env.Append(CPPPATH=['#platform/javascript']) + em_path=os.environ["EMSCRIPTEN_ROOT"] - env.Append(CPPPATH=['#platform/javascript']) - - em_path=os.environ["EMSCRIPTEN_ROOT"] - - env['ENV']['PATH'] = em_path+":"+env['ENV']['PATH'] + env['ENV']['PATH'] = em_path+":"+env['ENV']['PATH'] - env['CC'] = em_path+'/emcc' - env['CXX'] = em_path+'/emcc' - env['AR'] = em_path+"/emar" - env['RANLIB'] = em_path+"/emranlib" + env['CC'] = em_path+'/emcc' + env['CXX'] = em_path+'/emcc' + #env['AR'] = em_path+"/emar" + env['AR'] = em_path+"/emcc" + env['ARFLAGS'] = "-o" -# env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2']) +# env['RANLIB'] = em_path+"/emranlib" + env['RANLIB'] = em_path + "/emcc" + env['OBJSUFFIX'] = '.bc' + env['LIBSUFFIX'] = '.bc' + env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" + env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" -# env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") +# env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2']) - if (env["target"]=="release"): +# env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") - env.Append(CCFLAGS=['-O2']) - - elif (env["target"]=="release_debug"): - - env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) - - elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) - - env.Append(CPPFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST','-fno-rtti']) - env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT','-DTYPED_METHOD_BIND','-DNO_THREADS']) - env.Append(CPPFLAGS=['-DGLES2_ENABLED']) - env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) - env.Append(CPPFLAGS=['-s','ASM_JS=1']) - env.Append(CPPFLAGS=['-s','FULL_ES2=1']) -# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) - if (env["compress"]=="yes"): - lzma_binpath = em_path+"/third_party/lzma.js/lzma-native" - lzma_decoder = em_path+"/third_party/lzma.js/lzma-decoder.js" - lzma_dec = "LZMA.decompress" - - env.Append(LINKFLAGS=['--compression',lzma_binpath+","+lzma_decoder+","+lzma_dec]) - - env.Append(LINKFLAGS=['-s','ASM_JS=1']) - env.Append(LINKFLAGS=['-O2']) + if (env["target"]=="release"): + env.Append(CCFLAGS=['-O2']) + elif (env["target"]=="release_debug"): + env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) + elif (env["target"]=="debug"): + env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) + #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) + env.Append(CPPFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST','-fno-rtti']) + env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT','-DTYPED_METHOD_BIND','-DNO_THREADS']) + env.Append(CPPFLAGS=['-DGLES2_ENABLED']) + env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) + env.Append(CPPFLAGS=['-s','ASM_JS=1']) + env.Append(CPPFLAGS=['-s','FULL_ES2=1']) +# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) + if (env["compress"]=="yes"): + lzma_binpath = em_path+"/third_party/lzma.js/lzma-native" + lzma_decoder = em_path+"/third_party/lzma.js/lzma-decoder.js" + lzma_dec = "LZMA.decompress" + env.Append(LINKFLAGS=['--compression',lzma_binpath+","+lzma_decoder+","+lzma_dec]) + env.Append(LINKFLAGS=['-s','ASM_JS=1']) + env.Append(LINKFLAGS=['-O2']) + #env.Append(LINKFLAGS=['-g4']) + + #print "CCCOM is:", env.subst('$CCCOM') + #print "P: ", env['p'], " Platofrm: ", env['platform'] From 743b3157bc4912ec98aae21f0b864ee738c09105 Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Thu, 19 Mar 2015 10:35:24 +0530 Subject: [PATCH 02/11] Fix for newer gcc. Picked from GoogleCode --- drivers/etc1/rg_etc1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/etc1/rg_etc1.cpp b/drivers/etc1/rg_etc1.cpp index 28502191daa..7eb1427d7a0 100644 --- a/drivers/etc1/rg_etc1.cpp +++ b/drivers/etc1/rg_etc1.cpp @@ -1916,7 +1916,7 @@ done: for (uint packed_c = 0; packed_c < limit; packed_c++) { int v = etc1_decode_value(diff, inten, selector, packed_c); - uint err = intabs(v - color); + uint err = labs(v - static_cast(color)); //printf("err: %d - %u = %u\n",v,color,err); #ifdef JAVASCRIPT_ENABLED if (err < best_error || best_error == cUINT32_MAX) From 72895ddecf01e3559014669937df6c0b0adcca5f Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Fri, 20 Mar 2015 07:47:06 +0530 Subject: [PATCH 03/11] Replacing spaces with tabs --- platform/javascript/detect.py | 136 +++++++++++++++++----------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 2067e19230c..3123367ff0e 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -3,95 +3,95 @@ import sys import string def is_active(): - return True - + return True + def get_name(): - return "JavaScript" + return "JavaScript" def can_build(): - import os - if (not os.environ.has_key("EMSCRIPTEN_ROOT")): - return False - return True + import os + if (not os.environ.has_key("EMSCRIPTEN_ROOT")): + return False + return True def get_opts(): - return [ - ['compress','Compress JS Executable','no'] - ] + return [ + ['compress','Compress JS Executable','no'] + ] def get_flags(): - return [ - ('lua', 'no'), - ('tools', 'no'), - ('nedmalloc', 'no'), - ('theora', 'no'), - ('tools', 'no'), - ('nedmalloc', 'no'), - ('vorbis', 'no'), - ('musepack', 'no'), - ('squirrel', 'no'), - ('squish', 'no'), - ('speex', 'no'), - ('old_scenes', 'no'), -# ('default_gui_theme', 'no'), + return [ + ('lua', 'no'), + ('tools', 'no'), + ('nedmalloc', 'no'), + ('theora', 'no'), + ('tools', 'no'), + ('nedmalloc', 'no'), + ('vorbis', 'no'), + ('musepack', 'no'), + ('squirrel', 'no'), + ('squish', 'no'), + ('speex', 'no'), + ('old_scenes', 'no'), +# ('default_gui_theme', 'no'), - #('builtin_zlib', 'no'), - ] + #('builtin_zlib', 'no'), + ] def configure(env): - env.Append(CPPPATH=['#platform/javascript']) + env.Append(CPPPATH=['#platform/javascript']) - em_path=os.environ["EMSCRIPTEN_ROOT"] + em_path=os.environ["EMSCRIPTEN_ROOT"] - env['ENV']['PATH'] = em_path+":"+env['ENV']['PATH'] + env['ENV']['PATH'] = em_path+":"+env['ENV']['PATH'] - env['CC'] = em_path+'/emcc' - env['CXX'] = em_path+'/emcc' - #env['AR'] = em_path+"/emar" - env['AR'] = em_path+"/emcc" - env['ARFLAGS'] = "-o" + env['CC'] = em_path+'/emcc' + env['CXX'] = em_path+'/emcc' + #env['AR'] = em_path+"/emar" + env['AR'] = em_path+"/emcc" + env['ARFLAGS'] = "-o" -# env['RANLIB'] = em_path+"/emranlib" - env['RANLIB'] = em_path + "/emcc" - env['OBJSUFFIX'] = '.bc' - env['LIBSUFFIX'] = '.bc' - env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" - env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" +# env['RANLIB'] = em_path+"/emranlib" + env['RANLIB'] = em_path + "/emcc" + env['OBJSUFFIX'] = '.bc' + env['LIBSUFFIX'] = '.bc' + env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" + env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES" -# env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2']) +# env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2']) -# env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") +# env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ") - if (env["target"]=="release"): - env.Append(CCFLAGS=['-O2']) - elif (env["target"]=="release_debug"): - env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) - elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) - #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) + if (env["target"]=="release"): + env.Append(CCFLAGS=['-O2']) + elif (env["target"]=="release_debug"): + env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) + elif (env["target"]=="debug"): + env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) + #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED']) + env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) - env.Append(CPPFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST','-fno-rtti']) - env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT','-DTYPED_METHOD_BIND','-DNO_THREADS']) - env.Append(CPPFLAGS=['-DGLES2_ENABLED']) - env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) - env.Append(CPPFLAGS=['-s','ASM_JS=1']) - env.Append(CPPFLAGS=['-s','FULL_ES2=1']) -# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) - if (env["compress"]=="yes"): - lzma_binpath = em_path+"/third_party/lzma.js/lzma-native" - lzma_decoder = em_path+"/third_party/lzma.js/lzma-decoder.js" - lzma_dec = "LZMA.decompress" - env.Append(LINKFLAGS=['--compression',lzma_binpath+","+lzma_decoder+","+lzma_dec]) + env.Append(CPPFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST','-fno-rtti']) + env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT','-DTYPED_METHOD_BIND','-DNO_THREADS']) + env.Append(CPPFLAGS=['-DGLES2_ENABLED']) + env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) + env.Append(CPPFLAGS=['-s','ASM_JS=1']) + env.Append(CPPFLAGS=['-s','FULL_ES2=1']) +# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) + if (env["compress"]=="yes"): + lzma_binpath = em_path+"/third_party/lzma.js/lzma-native" + lzma_decoder = em_path+"/third_party/lzma.js/lzma-decoder.js" + lzma_dec = "LZMA.decompress" + env.Append(LINKFLAGS=['--compression',lzma_binpath+","+lzma_decoder+","+lzma_dec]) - env.Append(LINKFLAGS=['-s','ASM_JS=1']) - env.Append(LINKFLAGS=['-O2']) - #env.Append(LINKFLAGS=['-g4']) - - #print "CCCOM is:", env.subst('$CCCOM') - #print "P: ", env['p'], " Platofrm: ", env['platform'] + env.Append(LINKFLAGS=['-s','ASM_JS=1']) + env.Append(LINKFLAGS=['-O2']) + #env.Append(LINKFLAGS=['-g4']) + + #print "CCCOM is:", env.subst('$CCCOM') + #print "P: ", env['p'], " Platofrm: ", env['platform'] From 41b729ccff74e5a9154bee7db0d36ffd74641eae Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Fri, 20 Mar 2015 10:18:13 +0530 Subject: [PATCH 04/11] Removing etc1 from build for javascript platform. Based on inputs from reduz 1) Made etc1 optional driver and default yes. 2) Reverted the hack in rg_etc1.cpp 3) Disabled etc1 for javascript plaform. --- SConstruct | 1 + drivers/etc1/rg_etc1.cpp | 4 ---- platform/javascript/detect.py | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 2dc9fa1e704..50acd3884d6 100644 --- a/SConstruct +++ b/SConstruct @@ -111,6 +111,7 @@ opts.Add('jpg','JPG Image loader support (yes/no)','yes') opts.Add('webp','WEBP Image loader support (yes/no)','yes') opts.Add('dds','DDS Texture loader support (yes/no)','yes') opts.Add('pvr','PVR (PowerVR) Texture loader support (yes/no)','yes') +opts.Add('etc1','etc1 Texture compression support (yes/no)','yes') opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes') opts.Add('openssl','Use OpenSSL (yes/no/builtin)','no') opts.Add('musepack','Musepack Audio (yes/no)','yes') diff --git a/drivers/etc1/rg_etc1.cpp b/drivers/etc1/rg_etc1.cpp index 7eb1427d7a0..d2959da386e 100644 --- a/drivers/etc1/rg_etc1.cpp +++ b/drivers/etc1/rg_etc1.cpp @@ -1918,11 +1918,7 @@ done: int v = etc1_decode_value(diff, inten, selector, packed_c); uint err = labs(v - static_cast(color)); //printf("err: %d - %u = %u\n",v,color,err); - #ifdef JAVASCRIPT_ENABLED - if (err < best_error || best_error == cUINT32_MAX) - #else if (err < best_error) - #endif { best_error = err; best_packed_c = packed_c; diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 3123367ff0e..947a637fb99 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -36,6 +36,7 @@ def get_flags(): ('squish', 'no'), ('speex', 'no'), ('old_scenes', 'no'), + ('etc1', 'no'), # ('default_gui_theme', 'no'), #('builtin_zlib', 'no'), From d3280f91a13da6c106f95c289c095714c638d201 Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Fri, 20 Mar 2015 11:06:28 +0530 Subject: [PATCH 05/11] Missed some things in prev commit. --- SConstruct | 2 ++ drivers/etc1/SCsub | 3 ++- drivers/register_driver_types.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 50acd3884d6..42c803e81e0 100644 --- a/SConstruct +++ b/SConstruct @@ -308,6 +308,8 @@ if selected_platform in platform_list: if (env['colored']=='yes'): methods.colored(sys,env) + if (env['etc1']=='yes'): + env.Append(CPPFLAGS=['-DETC1_ENABLED']) Export('env') diff --git a/drivers/etc1/SCsub b/drivers/etc1/SCsub index 152dc3f4d04..251c3ffb868 100644 --- a/drivers/etc1/SCsub +++ b/drivers/etc1/SCsub @@ -6,7 +6,8 @@ etc_sources = [ "etc1/rg_etc1.cpp" ] -env.drivers_sources+=etc_sources +if (env["etc1"] != "no"): + env.drivers_sources+=etc_sources #env.add_source_files(env.drivers_sources, etc_sources) diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index e4bb1a343a7..e730171fbba 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -222,7 +222,10 @@ void register_driver_types() { #endif #endif +#ifdef ETC1_ENABLED _register_etc1_compress_func(); +#endif + initialize_chibi(); } From 9965e93f7eb7297490de597cc8ed8e18b4ba2872 Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Fri, 20 Mar 2015 11:12:13 +0530 Subject: [PATCH 06/11] Revert "Removing etc1 from build for javascript platform." This reverts commit 41b729ccff74e5a9154bee7db0d36ffd74641eae. --- SConstruct | 1 - drivers/etc1/rg_etc1.cpp | 4 ++++ platform/javascript/detect.py | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 42c803e81e0..cb32c0b5fff 100644 --- a/SConstruct +++ b/SConstruct @@ -111,7 +111,6 @@ opts.Add('jpg','JPG Image loader support (yes/no)','yes') opts.Add('webp','WEBP Image loader support (yes/no)','yes') opts.Add('dds','DDS Texture loader support (yes/no)','yes') opts.Add('pvr','PVR (PowerVR) Texture loader support (yes/no)','yes') -opts.Add('etc1','etc1 Texture compression support (yes/no)','yes') opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes') opts.Add('openssl','Use OpenSSL (yes/no/builtin)','no') opts.Add('musepack','Musepack Audio (yes/no)','yes') diff --git a/drivers/etc1/rg_etc1.cpp b/drivers/etc1/rg_etc1.cpp index d2959da386e..7eb1427d7a0 100644 --- a/drivers/etc1/rg_etc1.cpp +++ b/drivers/etc1/rg_etc1.cpp @@ -1918,7 +1918,11 @@ done: int v = etc1_decode_value(diff, inten, selector, packed_c); uint err = labs(v - static_cast(color)); //printf("err: %d - %u = %u\n",v,color,err); + #ifdef JAVASCRIPT_ENABLED + if (err < best_error || best_error == cUINT32_MAX) + #else if (err < best_error) + #endif { best_error = err; best_packed_c = packed_c; diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 947a637fb99..3123367ff0e 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -36,7 +36,6 @@ def get_flags(): ('squish', 'no'), ('speex', 'no'), ('old_scenes', 'no'), - ('etc1', 'no'), # ('default_gui_theme', 'no'), #('builtin_zlib', 'no'), From 2e59788aa9be6dab49e06588fcb1cf812e55a0cf Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Fri, 20 Mar 2015 11:12:59 +0530 Subject: [PATCH 07/11] Revert "Missed some things in prev commit." This reverts commit d3280f91a13da6c106f95c289c095714c638d201. --- SConstruct | 2 -- drivers/etc1/SCsub | 3 +-- drivers/register_driver_types.cpp | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index cb32c0b5fff..2dc9fa1e704 100644 --- a/SConstruct +++ b/SConstruct @@ -307,8 +307,6 @@ if selected_platform in platform_list: if (env['colored']=='yes'): methods.colored(sys,env) - if (env['etc1']=='yes'): - env.Append(CPPFLAGS=['-DETC1_ENABLED']) Export('env') diff --git a/drivers/etc1/SCsub b/drivers/etc1/SCsub index 251c3ffb868..152dc3f4d04 100644 --- a/drivers/etc1/SCsub +++ b/drivers/etc1/SCsub @@ -6,8 +6,7 @@ etc_sources = [ "etc1/rg_etc1.cpp" ] -if (env["etc1"] != "no"): - env.drivers_sources+=etc_sources +env.drivers_sources+=etc_sources #env.add_source_files(env.drivers_sources, etc_sources) diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index e730171fbba..e4bb1a343a7 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -222,10 +222,7 @@ void register_driver_types() { #endif #endif -#ifdef ETC1_ENABLED _register_etc1_compress_func(); -#endif - initialize_chibi(); } From eb3c88b3ddbe27826f634912b048589dff435847 Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Fri, 20 Mar 2015 11:47:56 +0530 Subject: [PATCH 08/11] Revert "Revert "Removing etc1 from build for javascript platform."" This reverts commit 9965e93f7eb7297490de597cc8ed8e18b4ba2872. --- SConstruct | 1 + drivers/etc1/rg_etc1.cpp | 4 ---- platform/javascript/detect.py | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 2dc9fa1e704..50acd3884d6 100644 --- a/SConstruct +++ b/SConstruct @@ -111,6 +111,7 @@ opts.Add('jpg','JPG Image loader support (yes/no)','yes') opts.Add('webp','WEBP Image loader support (yes/no)','yes') opts.Add('dds','DDS Texture loader support (yes/no)','yes') opts.Add('pvr','PVR (PowerVR) Texture loader support (yes/no)','yes') +opts.Add('etc1','etc1 Texture compression support (yes/no)','yes') opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes') opts.Add('openssl','Use OpenSSL (yes/no/builtin)','no') opts.Add('musepack','Musepack Audio (yes/no)','yes') diff --git a/drivers/etc1/rg_etc1.cpp b/drivers/etc1/rg_etc1.cpp index 7eb1427d7a0..d2959da386e 100644 --- a/drivers/etc1/rg_etc1.cpp +++ b/drivers/etc1/rg_etc1.cpp @@ -1918,11 +1918,7 @@ done: int v = etc1_decode_value(diff, inten, selector, packed_c); uint err = labs(v - static_cast(color)); //printf("err: %d - %u = %u\n",v,color,err); - #ifdef JAVASCRIPT_ENABLED - if (err < best_error || best_error == cUINT32_MAX) - #else if (err < best_error) - #endif { best_error = err; best_packed_c = packed_c; diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 3123367ff0e..947a637fb99 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -36,6 +36,7 @@ def get_flags(): ('squish', 'no'), ('speex', 'no'), ('old_scenes', 'no'), + ('etc1', 'no'), # ('default_gui_theme', 'no'), #('builtin_zlib', 'no'), From beab10ab9b18c8081ad85d2a59ce23e943f835b0 Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Fri, 20 Mar 2015 11:48:21 +0530 Subject: [PATCH 09/11] Revert "Revert "Missed some things in prev commit."" This reverts commit 2e59788aa9be6dab49e06588fcb1cf812e55a0cf. --- SConstruct | 2 ++ drivers/etc1/SCsub | 3 ++- drivers/register_driver_types.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 50acd3884d6..42c803e81e0 100644 --- a/SConstruct +++ b/SConstruct @@ -308,6 +308,8 @@ if selected_platform in platform_list: if (env['colored']=='yes'): methods.colored(sys,env) + if (env['etc1']=='yes'): + env.Append(CPPFLAGS=['-DETC1_ENABLED']) Export('env') diff --git a/drivers/etc1/SCsub b/drivers/etc1/SCsub index 152dc3f4d04..251c3ffb868 100644 --- a/drivers/etc1/SCsub +++ b/drivers/etc1/SCsub @@ -6,7 +6,8 @@ etc_sources = [ "etc1/rg_etc1.cpp" ] -env.drivers_sources+=etc_sources +if (env["etc1"] != "no"): + env.drivers_sources+=etc_sources #env.add_source_files(env.drivers_sources, etc_sources) diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index e4bb1a343a7..e730171fbba 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -222,7 +222,10 @@ void register_driver_types() { #endif #endif +#ifdef ETC1_ENABLED _register_etc1_compress_func(); +#endif + initialize_chibi(); } From 372fa5277c43d152ab75d7e15d2e0a59fd79fd3c Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Sat, 21 Mar 2015 10:12:25 +0530 Subject: [PATCH 10/11] Fix for canvas_draw_polygon on webgl. --- drivers/gles2/rasterizer_gles2.cpp | 112 +++++++++++++++++++++++++---- drivers/gles2/rasterizer_gles2.h | 3 + 2 files changed, 101 insertions(+), 14 deletions(-) diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index a21b0775e91..0774b031900 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -91,6 +91,10 @@ static RasterizerGLES2* _singleton = NULL; +#ifdef GLES_NO_CLIENT_ARRAYS +static float GlobalVertexBuffer[MAX_POLYGON_VERTICES * 8] = {0}; +#endif + static const GLenum prim_type[]={GL_POINTS,GL_LINES,GL_TRIANGLES,GL_TRIANGLE_FAN}; _FORCE_INLINE_ static void _set_color_attrib(const Color& p_color) { @@ -8337,20 +8341,22 @@ void RasterizerGLES2::canvas_draw_primitive(const Vector& p_points, cons void RasterizerGLES2::canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor) { - bool do_colors=false; + bool do_colors=false; + Color m; + if (p_singlecolor) { + m = *p_colors; + m.a*=canvas_opacity; + _set_color_attrib(m); + } else if (!p_colors) { + m = Color(1, 1, 1, canvas_opacity); + _set_color_attrib(m); + } else + do_colors=true; - if (p_singlecolor) { - Color m = *p_colors; - m.a*=canvas_opacity; - _set_color_attrib(m); - } else if (!p_colors) { - _set_color_attrib( Color(1,1,1,canvas_opacity)); - } else - do_colors=true; + Texture *texture = _bind_canvas_texture(p_texture); - Texture *texture = _bind_canvas_texture(p_texture); - - glEnableVertexAttribArray(VS::ARRAY_VERTEX); +#ifndef GLES_NO_CLIENT_ARRAYS + glEnableVertexAttribArray(VS::ARRAY_VERTEX); glVertexAttribPointer( VS::ARRAY_VERTEX, 2 ,GL_FLOAT, false, sizeof(Vector2), p_vertices ); if (do_colors) { @@ -8380,11 +8386,78 @@ void RasterizerGLES2::canvas_draw_polygon(int p_vertex_count, const int* p_indic }; glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_SHORT, _draw_poly_indices ); #endif - //glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_INT, p_indices ); } else { glDrawArrays(GL_TRIANGLES,0,p_vertex_count); } + +#else //WebGL specific impl. + glBindBuffer(GL_ARRAY_BUFFER, gui_quad_buffer); + float *b = GlobalVertexBuffer; + int ofs = 0; + if(p_vertex_count > MAX_POLYGON_VERTICES){ + print_line("Too many vertices to render"); + return; + } + glEnableVertexAttribArray(VS::ARRAY_VERTEX); + glVertexAttribPointer( VS::ARRAY_VERTEX, 2 ,GL_FLOAT, false, sizeof(float)*2, ((float*)0)+ofs ); + for(int i=0;i _max_draw_poly_indices); + static uint16_t _draw_poly_indices[_max_draw_poly_indices]; + for (int i=0; iprint("ind: %d ", p_indices[i]); + }; + + //copy the data to GPU. + glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, p_vertex_count * sizeof(uint16_t), &_draw_poly_indices[0]); + + //draw the triangles. + glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_SHORT, 0); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +#endif + _rinfo.ci_draw_commands++; }; @@ -10579,10 +10652,21 @@ void RasterizerGLES2::init() { glGenBuffers(1,&gui_quad_buffer); glBindBuffer(GL_ARRAY_BUFFER,gui_quad_buffer); - glBufferData(GL_ARRAY_BUFFER,128,NULL,GL_DYNAMIC_DRAW); +#ifdef GLES_NO_CLIENT_ARRAYS //WebGL specific implementation. + glBufferData(GL_ARRAY_BUFFER, 8 * MAX_POLYGON_VERTICES,NULL,GL_DYNAMIC_DRAW); +#else + glBufferData(GL_ARRAY_BUFFER,128,NULL,GL_DYNAMIC_DRAW); +#endif glBindBuffer(GL_ARRAY_BUFFER,0); //unbind +#ifdef GLES_NO_CLIENT_ARRAYS //webgl indices buffer + glGenBuffers(1, &indices_buffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices_buffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, 16*1024, NULL, GL_DYNAMIC_DRAW); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);// unbind +#endif + using_canvas_bg=false; _update_framebuffer(); DEBUG_TEST_ERROR("Initializing"); diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index b7895ad82e3..f59260ace63 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -31,6 +31,8 @@ #include "servers/visual/rasterizer.h" +#define MAX_POLYGON_VERTICES 4096 //used for WebGL canvas_draw_polygon call. + #ifdef GLES2_ENABLED #include "image.h" @@ -828,6 +830,7 @@ class RasterizerGLES2 : public Rasterizer { GLuint base_framebuffer; GLuint gui_quad_buffer; + GLuint indices_buffer; From 4fa71a6ee0ea72289d9e647eb0aeea59cf8a7192 Mon Sep 17 00:00:00 2001 From: "V.VamsiKrishna" Date: Sat, 21 Mar 2015 22:25:48 +0530 Subject: [PATCH 11/11] Removing Print statement effects perf. --- drivers/gles2/rasterizer_gles2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 0774b031900..22aecec0b7e 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -8445,7 +8445,7 @@ void RasterizerGLES2::canvas_draw_polygon(int p_vertex_count, const int* p_indic static uint16_t _draw_poly_indices[_max_draw_poly_indices]; for (int i=0; iprint("ind: %d ", p_indices[i]); + //OS::get_singleton()->print("ind: %d ", p_indices[i]); }; //copy the data to GPU.