summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dummy/rasterizer_dummy.h1
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.cpp7
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp6
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp19
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h1
-rw-r--r--drivers/gles2/shader_gles2.cpp27
-rw-r--r--drivers/gles2/shader_gles2.h1
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp8
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp14
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp13
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h2
-rw-r--r--drivers/gles3/shader_gles3.cpp25
-rw-r--r--drivers/gles3/shader_gles3.h1
-rw-r--r--drivers/unix/dir_access_unix.h1
-rw-r--r--drivers/unix/thread_posix.cpp17
-rw-r--r--drivers/windows/dir_access_windows.cpp40
-rw-r--r--drivers/windows/dir_access_windows.h1
17 files changed, 146 insertions, 38 deletions
diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h
index ddc0dd5fa9..214da82819 100644
--- a/drivers/dummy/rasterizer_dummy.h
+++ b/drivers/dummy/rasterizer_dummy.h
@@ -241,6 +241,7 @@ public:
void textures_keep_original(bool p_enable) {}
void texture_set_proxy(RID p_proxy, RID p_base) {}
+ virtual Size2 texture_size_with_proxy(RID p_texture) const { return Size2(); }
void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {}
/* SKY API */
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp
index 6f686690bf..64e4dbdab4 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.cpp
+++ b/drivers/gles2/rasterizer_canvas_gles2.cpp
@@ -112,9 +112,11 @@ void RasterizerCanvasGLES2::_set_uniforms() {
void RasterizerCanvasGLES2::canvas_begin() {
state.canvas_shader.bind();
+ bool transparent = false;
if (storage->frame.current_rt) {
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo);
glColorMask(1, 1, 1, 1);
+ transparent = storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT];
}
if (storage->frame.clear_request) {
@@ -122,11 +124,13 @@ void RasterizerCanvasGLES2::canvas_begin() {
glClearColor(storage->frame.clear_request_color.r,
storage->frame.clear_request_color.g,
storage->frame.clear_request_color.b,
- storage->frame.clear_request_color.a);
+ transparent ? storage->frame.clear_request_color.a : 1.0);
glClear(GL_COLOR_BUFFER_BIT);
storage->frame.clear_request = false;
}
+ glColorMask(1, 1, 1, transparent ? 1 : 0);
+
/*
if (storage->frame.current_rt) {
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo);
@@ -182,6 +186,7 @@ void RasterizerCanvasGLES2::canvas_end() {
state.using_texture_rect = false;
state.using_skeleton = false;
state.using_ninepatch = false;
+ glColorMask(1, 1, 1, 1);
}
RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index 47a4f8bc27..ae677b606d 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -994,6 +994,12 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
e->depth_layer = e->instance->depth_layer;
e->priority = p_material->render_priority;
+ if (has_alpha && p_material->shader->spatial.depth_draw_mode == RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
+ //add element to opaque
+ RenderList::Element *eo = render_list.add_element();
+ *eo = *e;
+ }
+
int rpsize = e->instance->reflection_probe_instances.size();
if (rpsize > 0) {
bool first = true;
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index f0deff4791..d00d572ccf 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -195,11 +195,11 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_DXT1: {
- r_compressed = true;
if (config.s3tc_supported) {
r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
+ r_compressed = true;
} else {
need_decompress = true;
}
@@ -846,6 +846,17 @@ void RasterizerStorageGLES2::textures_keep_original(bool p_enable) {
config.keep_original_textures = p_enable;
}
+Size2 RasterizerStorageGLES2::texture_size_with_proxy(RID p_texture) const {
+
+ const Texture *texture = texture_owner.getornull(p_texture);
+ ERR_FAIL_COND_V(!texture, Size2());
+ if (texture->proxy) {
+ return Size2(texture->proxy->width, texture->proxy->height);
+ } else {
+ return Size2(texture->width, texture->height);
+ }
+}
+
void RasterizerStorageGLES2::texture_set_proxy(RID p_texture, RID p_proxy) {
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);
@@ -4631,7 +4642,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
Shader *shader = shader_owner.get(p_rid);
- if (shader->shader) {
+ if (shader->shader && shader->custom_code_id) {
shader->shader->free_custom_shader(shader->custom_code_id);
}
@@ -4868,8 +4879,8 @@ void RasterizerStorageGLES2::initialize() {
config.etc1_supported = false;
#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.etc1_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture");
+ 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");
#endif
#ifdef GLES_OVER_GL
config.use_rgba_2d_shadows = false;
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index ed21238db6..ba48ddd185 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -342,6 +342,7 @@ public:
virtual void textures_keep_original(bool p_enable);
virtual void texture_set_proxy(RID p_texture, RID p_proxy);
+ virtual Size2 texture_size_with_proxy(RID p_texture) const;
virtual void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);
virtual void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);
diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp
index b50da3e9fe..5e259a01f0 100644
--- a/drivers/gles2/shader_gles2.cpp
+++ b/drivers/gles2/shader_gles2.cpp
@@ -519,6 +519,10 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() {
glUseProgram(0);
v.ok = true;
+ if (cc) {
+ cc->versions.insert(conditional_version.version);
+ }
+
return &v;
}
@@ -683,9 +687,28 @@ void ShaderGLES2::set_custom_shader(uint32_t p_code_id) {
}
void ShaderGLES2::free_custom_shader(uint32_t p_code_id) {
+
ERR_FAIL_COND(!custom_code_map.has(p_code_id));
- if (conditional_version.code_version == p_code_id)
- conditional_version.code_version = 0;
+ if (conditional_version.code_version == p_code_id) {
+ conditional_version.code_version = 0; //do not keep using a version that is going away
+ unbind();
+ }
+
+ VersionKey key;
+ key.code_version = p_code_id;
+ for (Set<uint32_t>::Element *E = custom_code_map[p_code_id].versions.front(); E; E = E->next()) {
+ key.version = E->get();
+ ERR_CONTINUE(!version_map.has(key));
+ Version &v = version_map[key];
+
+ glDeleteShader(v.vert_id);
+ glDeleteShader(v.frag_id);
+ glDeleteProgram(v.id);
+ memdelete_arr(v.uniform_location);
+ v.id = 0;
+
+ version_map.erase(key);
+ }
custom_code_map.erase(p_code_id);
}
diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h
index 5805432d09..d493880d0b 100644
--- a/drivers/gles2/shader_gles2.h
+++ b/drivers/gles2/shader_gles2.h
@@ -104,6 +104,7 @@ private:
Vector<StringName> texture_uniforms;
Vector<StringName> custom_uniforms;
Vector<CharString> custom_defines;
+ Set<uint32_t> versions;
};
struct Version {
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 79fec63db0..b8f0965af8 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -146,10 +146,15 @@ void RasterizerCanvasGLES3::canvas_begin() {
if (storage->frame.current_rt && storage->frame.clear_request) {
// a clear request may be pending, so do it
+ bool transparent = storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT];
- glClearColor(storage->frame.clear_request_color.r, storage->frame.clear_request_color.g, storage->frame.clear_request_color.b, storage->frame.clear_request_color.a);
+ glClearColor(storage->frame.clear_request_color.r,
+ storage->frame.clear_request_color.g,
+ storage->frame.clear_request_color.b,
+ transparent ? storage->frame.clear_request_color.a : 1.0);
glClear(GL_COLOR_BUFFER_BIT);
storage->frame.clear_request = false;
+ glColorMask(1, 1, 1, transparent ? 1 : 0);
}
reset_canvas();
@@ -193,6 +198,7 @@ void RasterizerCanvasGLES3::canvas_end() {
glBindVertexArray(0);
glBindBufferBase(GL_UNIFORM_BUFFER, 0, 0);
+ glColorMask(1, 1, 1, 1);
state.using_texture_rect = false;
state.using_ninepatch = false;
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 02dbe096c5..966466d9bc 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -4132,9 +4132,19 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
glDepthFunc(GL_LEQUAL);
- state.used_contact_shadows = true;
+ state.used_contact_shadows = false;
- if (!storage->config.no_depth_prepass && storage->frame.current_rt && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { //detect with state.used_contact_shadows too
+ for (int i = 0; i < p_light_cull_count; i++) {
+
+ ERR_BREAK(i >= RenderList::MAX_LIGHTS);
+
+ LightInstance *li = light_instance_owner.getptr(p_light_cull_result[i]);
+ if (li->light_ptr->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] > CMP_EPSILON) {
+ state.used_contact_shadows = true;
+ }
+ }
+
+ if (!storage->config.no_depth_prepass && storage->frame.current_rt && state.debug_draw != VS::VIEWPORT_DEBUG_DRAW_OVERDRAW && !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_NO_3D_EFFECTS]) { //detect with state.used_contact_shadows too
//pre z pass
glDisable(GL_BLEND);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 8b3f1a1b77..9754cbe0f0 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -1687,6 +1687,17 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_
return texture_owner.make_rid(ctex);
}
+Size2 RasterizerStorageGLES3::texture_size_with_proxy(RID p_texture) const {
+
+ const Texture *texture = texture_owner.getornull(p_texture);
+ ERR_FAIL_COND_V(!texture, Size2());
+ if (texture->proxy) {
+ return Size2(texture->proxy->width, texture->proxy->height);
+ } else {
+ return Size2(texture->width, texture->height);
+ }
+}
+
void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
Texture *texture = texture_owner.get(p_texture);
@@ -7486,7 +7497,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
// delete the texture
Shader *shader = shader_owner.get(p_rid);
- if (shader->shader)
+ if (shader->shader && shader->custom_code_id)
shader->shader->free_custom_shader(shader->custom_code_id);
if (shader->dirty_list.in_list())
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index 811f9c8d80..ca45b1a814 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -375,6 +375,8 @@ public:
virtual void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);
virtual void texture_set_proxy(RID p_texture, RID p_proxy);
+ virtual Size2 texture_size_with_proxy(RID p_texture) const;
+
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable);
/* SKY API */
diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp
index edc2a6c054..2db0223edd 100644
--- a/drivers/gles3/shader_gles3.cpp
+++ b/drivers/gles3/shader_gles3.cpp
@@ -559,6 +559,9 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() {
glUseProgram(0);
v.ok = true;
+ if (cc) {
+ cc->versions.insert(conditional_version.version);
+ }
return &v;
}
@@ -741,8 +744,26 @@ void ShaderGLES3::set_custom_shader(uint32_t p_code_id) {
void ShaderGLES3::free_custom_shader(uint32_t p_code_id) {
ERR_FAIL_COND(!custom_code_map.has(p_code_id));
- if (conditional_version.code_version == p_code_id)
- conditional_version.code_version = 0; //bye
+ if (conditional_version.code_version == p_code_id) {
+ conditional_version.code_version = 0; //do not keep using a version that is going away
+ unbind();
+ }
+
+ VersionKey key;
+ key.code_version = p_code_id;
+ for (Set<uint32_t>::Element *E = custom_code_map[p_code_id].versions.front(); E; E = E->next()) {
+ key.version = E->get();
+ ERR_CONTINUE(!version_map.has(key));
+ Version &v = version_map[key];
+
+ glDeleteShader(v.vert_id);
+ glDeleteShader(v.frag_id);
+ glDeleteProgram(v.id);
+ memdelete_arr(v.uniform_location);
+ v.id = 0;
+
+ version_map.erase(key);
+ }
custom_code_map.erase(p_code_id);
}
diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h
index 1f98f4883d..1ed30986bf 100644
--- a/drivers/gles3/shader_gles3.h
+++ b/drivers/gles3/shader_gles3.h
@@ -117,6 +117,7 @@ private:
uint32_t version;
Vector<StringName> texture_uniforms;
Vector<CharString> custom_defines;
+ Set<uint32_t> versions;
};
struct Version {
diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h
index b85ae719ff..579cb0e798 100644
--- a/drivers/unix/dir_access_unix.h
+++ b/drivers/unix/dir_access_unix.h
@@ -84,7 +84,6 @@ public:
virtual String get_filesystem_type() const;
-
DirAccessUnix();
~DirAccessUnix();
};
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index a81292d4a2..ef3f5fb49c 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -40,9 +40,13 @@
#include "core/os/memory.h"
#include "core/safe_refcount.h"
+static void _thread_id_key_destr_callback(void *p_value) {
+ memdelete(static_cast<Thread::ID *>(p_value));
+}
+
static pthread_key_t _create_thread_id_key() {
pthread_key_t key;
- pthread_key_create(&key, NULL);
+ pthread_key_create(&key, &_thread_id_key_destr_callback);
return key;
}
@@ -63,7 +67,7 @@ void *ThreadPosix::thread_callback(void *userdata) {
ThreadPosix *t = reinterpret_cast<ThreadPosix *>(userdata);
t->id = atomic_increment(&next_thread_id);
- pthread_setspecific(thread_id_key, (void *)t->id);
+ pthread_setspecific(thread_id_key, (void *)memnew(ID(t->id)));
ScriptServer::thread_enter(); //scripts may need to attach a stack
@@ -89,7 +93,14 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_
}
Thread::ID ThreadPosix::get_thread_id_func_posix() {
- return (ID)pthread_getspecific(thread_id_key);
+ void *value = pthread_getspecific(thread_id_key);
+
+ if (value)
+ return *static_cast<ID *>(value);
+
+ ID new_id = atomic_increment(&next_thread_id);
+ pthread_setspecific(thread_id_key, (void *)memnew(ID(new_id)));
+ return new_id;
}
void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index c32e063736..499bb4f34b 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -347,27 +347,27 @@ size_t DirAccessWindows::get_space_left() {
}
String DirAccessWindows::get_filesystem_type() const {
- String path = fix_path(const_cast<DirAccessWindows*>(this)->get_current_dir());
- print_line("fixed path: "+path);
+ String path = fix_path(const_cast<DirAccessWindows *>(this)->get_current_dir());
+ print_line("fixed path: " + path);
int unit_end = path.find(":");
- ERR_FAIL_COND_V(unit_end==-1,String());
- String unit = path.substr(0,unit_end+1) + "\\";
- print_line("unit: "+unit);
-
- TCHAR szVolumeName[100] = "";
- TCHAR szFileSystemName[10] = "";
- DWORD dwSerialNumber = 0;
- DWORD dwMaxFileNameLength = 0;
- DWORD dwFileSystemFlags = 0;
-
- if(::GetVolumeInformation(unit.utf8().get_data(),
- szVolumeName,
- sizeof(szVolumeName),
- &dwSerialNumber,
- &dwMaxFileNameLength,
- &dwFileSystemFlags,
- szFileSystemName,
- sizeof(szFileSystemName)) == TRUE) {
+ ERR_FAIL_COND_V(unit_end == -1, String());
+ String unit = path.substr(0, unit_end + 1) + "\\";
+ print_line("unit: " + unit);
+
+ WCHAR szVolumeName[100];
+ WCHAR szFileSystemName[10];
+ DWORD dwSerialNumber = 0;
+ DWORD dwMaxFileNameLength = 0;
+ DWORD dwFileSystemFlags = 0;
+
+ if (::GetVolumeInformationW(unit.c_str(),
+ szVolumeName,
+ sizeof(szVolumeName),
+ &dwSerialNumber,
+ &dwMaxFileNameLength,
+ &dwFileSystemFlags,
+ szFileSystemName,
+ sizeof(szFileSystemName)) == TRUE) {
return String(szFileSystemName);
}
diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h
index b8599d5c26..10eee07f0c 100644
--- a/drivers/windows/dir_access_windows.h
+++ b/drivers/windows/dir_access_windows.h
@@ -84,7 +84,6 @@ public:
virtual String get_filesystem_type() const;
-
DirAccessWindows();
~DirAccessWindows();
};