summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.cpp6
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp20
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp51
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h5
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp6
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp2
-rw-r--r--drivers/png/png_driver_common.cpp9
-rw-r--r--drivers/windows/file_access_windows.cpp2
8 files changed, 69 insertions, 32 deletions
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp
index 16e5e92abd..e34705f7b7 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.cpp
+++ b/drivers/gles2/rasterizer_canvas_gles2.cpp
@@ -494,10 +494,8 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
if (line->width <= 1) {
Vector2 verts[2] = {
- // Offset the line slightly to make sure we always draw the pixel at the from coordinate.
- // Without this, corners of rectangles might be missing a pixel. (See diamond exit rule and #32657)
- Vector2(Math::floor(line->from.x) + 0.5, Math::floor(line->from.y) + 0.5),
- Vector2(Math::floor(line->to.x) + 0.5, Math::floor(line->to.y) + 0.5)
+ Vector2(line->from.x, line->from.y),
+ Vector2(line->to.x, line->to.y)
};
#ifdef GLES_OVER_GL
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index f712219a64..6bcda62e7f 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -2767,6 +2767,8 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
if (use_post_process) {
next_buffer = storage->frame.current_rt->mip_maps[0].sizes[0].fbo;
+ } else if (storage->frame.current_rt->external.fbo != 0) {
+ next_buffer = storage->frame.current_rt->external.fbo;
} else {
// set next_buffer to front buffer so multisample blit can happen if needed
next_buffer = storage->frame.current_rt->fbo;
@@ -2795,9 +2797,15 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
// In GLES2 Android Blit is not available, so just copy color texture manually
_copy_texture_to_buffer(storage->frame.current_rt->multisample_color, next_buffer);
+#else
+ // TODO: any other platform not supported? this will fail.. maybe we should just call _copy_texture_to_buffer here as well?
#endif
} else if (use_post_process) {
- _copy_texture_to_buffer(storage->frame.current_rt->color, storage->frame.current_rt->mip_maps[0].sizes[0].fbo);
+ if (storage->frame.current_rt->external.fbo != 0) {
+ _copy_texture_to_buffer(storage->frame.current_rt->external.color, storage->frame.current_rt->mip_maps[0].sizes[0].fbo);
+ } else {
+ _copy_texture_to_buffer(storage->frame.current_rt->color, storage->frame.current_rt->mip_maps[0].sizes[0].fbo);
+ }
}
if (!use_post_process) {
@@ -3220,14 +3228,12 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
} else {
state.render_no_shadows = false;
- if (storage->frame.current_rt->external.fbo != 0) {
+ if (storage->frame.current_rt->multisample_active) {
+ current_fb = storage->frame.current_rt->multisample_fbo;
+ } else if (storage->frame.current_rt->external.fbo != 0) {
current_fb = storage->frame.current_rt->external.fbo;
} else {
- if (storage->frame.current_rt->multisample_active) {
- current_fb = storage->frame.current_rt->multisample_fbo;
- } else {
- current_fb = storage->frame.current_rt->fbo;
- }
+ current_fb = storage->frame.current_rt->fbo;
}
env = environment_owner.getornull(p_environment);
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 9d9bceb243..82cb1ef90b 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -4694,7 +4694,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) {
/* For MSAA */
#ifndef JAVASCRIPT_ENABLED
- if (rt->msaa != VS::VIEWPORT_MSAA_DISABLED && config.multisample_supported) {
+ if (rt->msaa >= VS::VIEWPORT_MSAA_2X && rt->msaa <= VS::VIEWPORT_MSAA_16X && config.multisample_supported) {
rt->multisample_active = true;
@@ -5090,6 +5090,11 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
// free this
glDeleteFramebuffers(1, &rt->external.fbo);
+ // and this
+ if (rt->external.depth != 0) {
+ glDeleteRenderbuffers(1, &rt->external.depth);
+ }
+
// clean up our texture
Texture *t = texture_owner.get(rt->external.texture);
t->alloc_height = 0;
@@ -5102,6 +5107,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
rt->external.fbo = 0;
rt->external.color = 0;
+ rt->external.depth = 0;
}
} else {
Texture *t;
@@ -5136,6 +5142,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
t->render_target = rt;
rt->external.texture = texture_owner.make_rid(t);
+
} else {
// bind our frame buffer
glBindFramebuffer(GL_FRAMEBUFFER, rt->external.fbo);
@@ -5154,16 +5161,42 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
t->alloc_height = rt->width;
t->alloc_width = rt->height;
- // is there a point to setting the internal formats? we don't know them..
+ // Switch our texture on our frame buffer
+#if ANDROID_ENABLED
+ if (rt->msaa >= VS::VIEWPORT_MSAA_EXT_2X && rt->msaa <= VS::VIEWPORT_MSAA_EXT_4X) {
+ // This code only applies to the Oculus Go and Oculus Quest. Due to the the tiled nature
+ // of the GPU we can do a single render pass by rendering directly into our texture chains
+ // texture and apply MSAA as we render.
+
+ // On any other hardware these two modes are ignored and we do not have any MSAA,
+ // the normal MSAA modes need to be used to enable our two pass approach
+
+ static const int msaa_value[] = { 2, 4 };
+ int msaa = msaa_value[rt->msaa - VS::VIEWPORT_MSAA_EXT_2X];
+
+ if (rt->external.depth == 0) {
+ // create a multisample depth buffer, we're not reusing Godots because Godot's didn't get created..
+ glGenRenderbuffers(1, &rt->external.depth);
+ glBindRenderbuffer(GL_RENDERBUFFER, rt->external.depth);
+ glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, config.depth_internalformat, rt->width, rt->height);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->external.depth);
+ }
- // set our texture as the destination for our framebuffer
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0);
+ // and set our external texture as the texture...
+ glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0, msaa);
- // seeing we're rendering into this directly, better also use our depth buffer, just use our existing one :)
- if (config.support_depth_texture) {
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
- } else {
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
+ } else
+#endif
+ {
+ // set our texture as the destination for our framebuffer
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0);
+
+ // seeing we're rendering into this directly, better also use our depth buffer, just use our existing one :)
+ if (config.support_depth_texture) {
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
+ } else {
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
+ }
}
// check status and unbind
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index 27f06074ed..6de530d8c3 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -1182,10 +1182,13 @@ public:
struct External {
GLuint fbo;
GLuint color;
+ GLuint depth;
RID texture;
External() :
- fbo(0) {
+ fbo(0),
+ color(0),
+ depth(0) {
}
} external;
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index e09ba755ea..edffe852a2 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -548,10 +548,8 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
if (line->width <= 1) {
Vector2 verts[2] = {
- // Offset the line slightly to make sure we always draw the pixel at the from coordinate.
- // Without this, corners of rectangles might be missing a pixel. (See diamond exit rule and #32657)
- Vector2(Math::floor(line->from.x) + 0.5, Math::floor(line->from.y) + 0.5),
- Vector2(Math::floor(line->to.x) + 0.5, Math::floor(line->to.y) + 0.5)
+ Vector2(line->from.x, line->from.y),
+ Vector2(line->to.x, line->to.y)
};
#ifdef GLES_OVER_GL
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index f94020b918..71737426a9 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -6961,7 +6961,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
rt->buffers.active = true;
- static const int msaa_value[] = { 0, 2, 4, 8, 16 };
+ static const int msaa_value[] = { 0, 2, 4, 8, 16, 4, 16 }; // MSAA_EXT_nX is a GLES2 temporary hack ignored in GLES3 for now...
int msaa = msaa_value[rt->msaa];
int max_samples = 0;
diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp
index 7deac1d118..46e45d07d3 100644
--- a/drivers/png/png_driver_common.cpp
+++ b/drivers/png/png_driver_common.cpp
@@ -43,7 +43,6 @@ namespace PNGDriverCommon {
static bool check_error(const png_image &image) {
const png_uint_32 failed = PNG_IMAGE_FAILED(image);
if (failed & PNG_IMAGE_ERROR) {
- ERR_EXPLAINC(image.message);
return true;
} else if (failed) {
#ifdef TOOLS_ENABLED
@@ -67,7 +66,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
// fetch image properties
int success = png_image_begin_read_from_memory(&png_img, p_source, p_size);
- ERR_FAIL_COND_V(check_error(png_img), ERR_FILE_CORRUPT);
+ ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message);
ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT);
// flags to be masked out of input format to give target format
@@ -112,7 +111,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
// read image data to buffer and release libpng resources
success = png_image_finish_read(&png_img, NULL, writer.ptr(), stride, NULL);
- ERR_FAIL_COND_V(check_error(png_img), ERR_FILE_CORRUPT);
+ ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message);
ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT);
p_image->create(png_img.width, png_img.height, 0, dest_format, buffer);
@@ -176,7 +175,7 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
PoolVector<uint8_t>::Write writer = p_buffer.write();
success = png_image_write_to_memory(&png_img, &writer[buffer_offset],
&compressed_size, 0, reader.ptr(), 0, NULL);
- ERR_FAIL_COND_V(check_error(png_img), FAILED);
+ ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
}
if (!success) {
@@ -190,7 +189,7 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
PoolVector<uint8_t>::Write writer = p_buffer.write();
success = png_image_write_to_memory(&png_img, &writer[buffer_offset],
&compressed_size, 0, reader.ptr(), 0, NULL);
- ERR_FAIL_COND_V(check_error(png_img), FAILED);
+ ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
ERR_FAIL_COND_V(!success, FAILED);
}
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index fb21c0c5a1..4dc1b74310 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -96,7 +96,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
if (p_mode_flags == READ) {
WIN32_FIND_DATAW d;
HANDLE f = FindFirstFileW(path.c_str(), &d);
- if (f) {
+ if (f != INVALID_HANDLE_VALUE) {
String fname = d.cFileName;
if (fname != String()) {