diff options
-rw-r--r-- | drivers/gles2/rasterizer_scene_gles2.cpp | 4 | ||||
-rw-r--r-- | drivers/gles2/shaders/scene.glsl | 26 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 17 | ||||
-rw-r--r-- | platform/windows/context_gl_windows.cpp | 3 | ||||
-rw-r--r-- | platform/windows/context_gl_windows.h | 2 |
5 files changed, 34 insertions, 18 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 5c52d88cc7..441e7e5c1a 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -3325,6 +3325,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const glDepthMask(GL_TRUE); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); + glClear(GL_DEPTH_BUFFER_BIT); // clear color @@ -3351,13 +3352,12 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const if (!env || env->bg_mode != VS::ENV_BG_KEEP) { glClearColor(clear_color.r, clear_color.g, clear_color.b, clear_color.a); + glClear(GL_COLOR_BUFFER_BIT); } state.default_ambient = Color(clear_color.r, clear_color.g, clear_color.b, 1.0); state.default_bg = Color(clear_color.r, clear_color.g, clear_color.b, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) { glDisable(GL_SCISSOR_TEST); } diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index 63eee4eb87..ac7a8796a3 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -1666,19 +1666,19 @@ FRAGMENT_SHADER_CODE #ifdef USE_LIGHTMAP_CAPTURE { - vec3 cone_dirs[12] = vec3[]( - vec3(0.0, 0.0, 1.0), - vec3(0.866025, 0.0, 0.5), - vec3(0.267617, 0.823639, 0.5), - vec3(-0.700629, 0.509037, 0.5), - vec3(-0.700629, -0.509037, 0.5), - vec3(0.267617, -0.823639, 0.5), - vec3(0.0, 0.0, -1.0), - vec3(0.866025, 0.0, -0.5), - vec3(0.267617, 0.823639, -0.5), - vec3(-0.700629, 0.509037, -0.5), - vec3(-0.700629, -0.509037, -0.5), - vec3(0.267617, -0.823639, -0.5)); + vec3 cone_dirs[12]; + cone_dirs[0] = vec3(0.0, 0.0, 1.0); + cone_dirs[1] = vec3(0.866025, 0.0, 0.5); + cone_dirs[2] = vec3(0.267617, 0.823639, 0.5); + cone_dirs[3] = vec3(-0.700629, 0.509037, 0.5); + cone_dirs[4] = vec3(-0.700629, -0.509037, 0.5); + cone_dirs[5] = vec3(0.267617, -0.823639, 0.5); + cone_dirs[6] = vec3(0.0, 0.0, -1.0); + cone_dirs[7] = vec3(0.866025, 0.0, -0.5); + cone_dirs[8] = vec3(0.267617, 0.823639, -0.5); + cone_dirs[9] = vec3(-0.700629, 0.509037, -0.5); + cone_dirs[10] = vec3(-0.700629, -0.509037, -0.5); + cone_dirs[11] = vec3(0.267617, -0.823639, -0.5); vec3 local_normal = normalize(camera_matrix * vec4(normal, 0.0)).xyz; vec4 captured = vec4(0.0); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 8a024eef13..3678a82bee 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2134,6 +2134,17 @@ CSharpInstance::~CSharpInstance() { // Transfer ownership to an "instance binding" + Reference *ref_owner = static_cast<Reference *>(owner); + + // We will unreference the owner before referencing it again, so we need to keep it alive + Ref<Reference> scope_keep_owner_alive(ref_owner); + (void)scope_keep_owner_alive; + + // Unreference the owner here, before the new "instance binding" references it. + // Otherwise, the unsafe reference debug checks will incorrectly detect a bug. + bool die = _unreference_owner_unsafe(); + CRASH_COND(die == true); // `owner_keep_alive` holds a reference, so it can't die + void *data = owner->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index()); CRASH_COND(data == NULL); @@ -2149,8 +2160,10 @@ CSharpInstance::~CSharpInstance() { } } - bool die = _unreference_owner_unsafe(); - CRASH_COND(die == true); // The "instance binding" should be holding a reference +#ifdef DEBUG_ENABLED + // The "instance binding" holds a reference so the refcount should be at least 2 before `scope_keep_owner_alive` goes out of scope + CRASH_COND(ref_owner->reference_get_count() <= 1); +#endif } if (script.is_valid() && owner) { diff --git a/platform/windows/context_gl_windows.cpp b/platform/windows/context_gl_windows.cpp index 21d954a736..434d685250 100644 --- a/platform/windows/context_gl_windows.cpp +++ b/platform/windows/context_gl_windows.cpp @@ -89,7 +89,7 @@ void ContextGL_Windows::swap_buffers() { if (use_vsync) { bool vsync_via_compositor_now = should_vsync_via_compositor(); - if (vsync_via_compositor_now) { + if (vsync_via_compositor_now && wglGetSwapIntervalEXT() == 0) { DwmFlush(); } @@ -205,6 +205,7 @@ Error ContextGL_Windows::initialize() { } wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT"); //glWrapperInit(wrapper_get_proc_address); return OK; diff --git a/platform/windows/context_gl_windows.h b/platform/windows/context_gl_windows.h index 0c6a6d1814..280c5a1e3c 100644 --- a/platform/windows/context_gl_windows.h +++ b/platform/windows/context_gl_windows.h @@ -41,6 +41,7 @@ #include <windows.h> typedef bool(APIENTRY *PFNWGLSWAPINTERVALEXTPROC)(int interval); +typedef int(APIENTRY *PFNWGLGETSWAPINTERVALEXTPROC)(void); class ContextGL_Windows { @@ -53,6 +54,7 @@ class ContextGL_Windows { bool vsync_via_compositor; PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; + PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT; static bool should_vsync_via_compositor(); |