summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-02-26 11:58:47 -0300
committerJuan Linietsky <juan@godotengine.org>2019-02-26 11:58:47 -0300
commit5eeb06ffd1bf9cc79142760c372c17cd858cbe49 (patch)
tree824bdca6e0072ff877a1944c5b2c248c2bca0fbb
parent329904598829dcbed462b012dee39bc37d7d7c83 (diff)
downloadredot-engine-5eeb06ffd1bf9cc79142760c372c17cd858cbe49.tar.gz
-Remove harcoded opengl extension testing from OS, ask rasterizer instead.
-Fixed a bug where etc textures were imported broken
-rw-r--r--core/os/os.cpp11
-rw-r--r--core/os/os.h4
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp5
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h1
-rw-r--r--editor/import/resource_importer_texture.cpp1
-rw-r--r--platform/android/os_android.cpp2
-rw-r--r--platform/haiku/os_haiku.cpp2
-rw-r--r--platform/iphone/os_iphone.cpp2
-rw-r--r--platform/javascript/os_javascript.cpp10
-rw-r--r--platform/osx/os_osx.mm2
-rw-r--r--platform/uwp/os_uwp.cpp2
-rw-r--r--platform/windows/os_windows.cpp2
-rw-r--r--platform/x11/os_x11.cpp2
-rw-r--r--servers/register_server_types.cpp13
14 files changed, 41 insertions, 18 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp
index d2d39d253a..03e63f636e 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -569,6 +569,11 @@ int OS::get_power_percent_left() {
return -1;
}
+void OS::set_has_server_feature_callback(HasServerFeatureCallback p_callback) {
+
+ has_server_feature_callback = p_callback;
+}
+
bool OS::has_feature(const String &p_feature) {
if (p_feature == get_name())
@@ -625,6 +630,10 @@ bool OS::has_feature(const String &p_feature) {
if (_check_internal_feature_support(p_feature))
return true;
+ if (has_server_feature_callback && has_server_feature_callback(p_feature)) {
+ return true;
+ }
+
if (ProjectSettings::get_singleton()->has_custom_feature(p_feature))
return true;
@@ -729,6 +738,8 @@ OS::OS() {
_logger = NULL;
+ has_server_feature_callback = NULL;
+
Vector<Logger *> loggers;
loggers.push_back(memnew(StdLogger));
_set_logger(memnew(CompositeLogger(loggers)));
diff --git a/core/os/os.h b/core/os/os.h
index 396555970a..f58d607937 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -77,6 +77,7 @@ protected:
public:
typedef void (*ImeCallback)(void *p_inp, String p_text, Point2 p_selection);
+ typedef bool (*HasServerFeatureCallback)(const String &p_feature);
enum PowerState {
POWERSTATE_UNKNOWN, /**< cannot determine power status */
@@ -121,6 +122,7 @@ public:
protected:
friend class Main;
+ HasServerFeatureCallback has_server_feature_callback;
RenderThreadMode _render_thread_mode;
// functions used by main to initialize/deinitialize the OS
@@ -507,6 +509,8 @@ public:
virtual void force_process_input(){};
bool has_feature(const String &p_feature);
+ void set_has_server_feature_callback(HasServerFeatureCallback p_callback);
+
bool is_layered_allowed() const { return _allow_layered; }
bool is_hidpi_allowed() const { return _allow_hidpi; }
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 0acbb8cf51..db88339249 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -4922,6 +4922,9 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
bool RasterizerStorageGLES2::has_os_feature(const String &p_feature) const {
+ if (p_feature == "pvrtc")
+ return config.pvrtc_supported;
+
if (p_feature == "s3tc")
return config.s3tc_supported;
@@ -4971,12 +4974,14 @@ void RasterizerStorageGLES2::initialize() {
#ifdef GLES_OVER_GL
config.float_texture_supported = true;
config.s3tc_supported = true;
+ config.pvrtc_supported = false;
config.etc1_supported = false;
config.support_npot_repeat_mipmap = true;
#else
config.float_texture_supported = config.extensions.has("GL_ARB_texture_float") || config.extensions.has("GL_OES_texture_float");
config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_s3tc") || config.extensions.has("WEBGL_compressed_texture_s3tc");
config.etc1_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture") || config.extensions.has("WEBGL_compressed_texture_etc1");
+ config.pvrtc_supported = config.extensions.has("IMG_texture_compression_pvrtc");
config.support_npot_repeat_mipmap = config.extensions.has("GL_OES_texture_npot");
#endif
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index 8e177ba57f..f6c8faa497 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -72,6 +72,7 @@ public:
bool float_texture_supported;
bool s3tc_supported;
bool etc1_supported;
+ bool pvrtc_supported;
bool keep_original_textures;
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 112e39cb4a..3e03b697ed 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -235,7 +235,6 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
f->store_16(p_image->get_width());
f->store_16(next_power_of_2(p_image->get_height()));
f->store_16(p_image->get_height());
- f->store_16(0);
} else {
f->store_16(p_image->get_width());
f->store_16(0);
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 3ba8468e0b..b86976843c 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -706,7 +706,7 @@ String OS_Android::get_joy_guid(int p_device) const {
}
bool OS_Android::_check_internal_feature_support(const String &p_feature) {
- if (p_feature == "mobile" || p_feature == "etc" || p_feature == "etc2") {
+ if (p_feature == "mobile") {
//TODO support etc2 only if GLES3 driver is selected
return true;
}
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
index a5b2e66a22..a6d5a00852 100644
--- a/platform/haiku/os_haiku.cpp
+++ b/platform/haiku/os_haiku.cpp
@@ -322,7 +322,7 @@ String OS_Haiku::get_executable_path() const {
bool OS_Haiku::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc";
+ return p_feature == "pc";
}
String OS_Haiku::get_config_path() const {
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index c939e234b9..b44b3127c7 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -587,7 +587,7 @@ void OSIPhone::native_video_stop() {
bool OSIPhone::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "mobile" || p_feature == "etc" || p_feature == "pvrtc" || p_feature == "etc2";
+ return p_feature == "mobile";
}
// Initialization order between compilation units is not guaranteed,
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 594c0a46cc..57ae1b6e26 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -1071,16 +1071,6 @@ bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) {
return true;
#endif
- EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context();
- // All extensions are already automatically enabled, this function allows
- // checking WebGL extension support without inline JavaScript
- if (p_feature == "s3tc")
- return emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_s3tc_srgb");
- if (p_feature == "etc")
- return emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_etc1");
- if (p_feature == "etc2")
- return emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_etc");
-
return false;
}
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 4e4d9c9eea..5206dc13b6 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -2812,7 +2812,7 @@ OS_OSX::OS_OSX() {
}
bool OS_OSX::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc";
+ return p_feature == "pc";
}
void OS_OSX::disable_crash_handler() {
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 520e179611..637ef5aaef 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -889,7 +889,7 @@ String OS_UWP::get_user_data_dir() const {
}
bool OS_UWP::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc";
+ return p_feature == "pc";
}
OS::PowerState OS_UWP::get_power_state() {
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 6e31f5b21d..61aeb3ec93 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2976,7 +2976,7 @@ int OS_Windows::get_power_percent_left() {
bool OS_Windows::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc" || p_feature == "bptc";
+ return p_feature == "pc";
}
void OS_Windows::disable_crash_handler() {
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 879642d8f9..6a09c507c6 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -2593,7 +2593,7 @@ Error OS_X11::shell_open(String p_uri) {
bool OS_X11::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc" || p_feature == "bptc";
+ return p_feature == "pc";
}
String OS_X11::get_config_path() const {
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index 4e167be300..922f017d0b 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -88,8 +88,21 @@ Physics2DServer *_createGodotPhysics2DCallback() {
return Physics2DServerWrapMT::init_server<Physics2DServerSW>();
}
+static bool has_server_feature_callback(const String &p_feature) {
+
+ if (VisualServer::get_singleton()) {
+ if (VisualServer::get_singleton()->has_os_feature(p_feature)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void register_server_types() {
+ OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback);
+
ClassDB::register_virtual_class<VisualServer>();
ClassDB::register_class<AudioServer>();
ClassDB::register_virtual_class<PhysicsServer>();