Only copy the relevant portion of the screen when copying to backbuffer in Compatibility backend
This commit is contained in:
parent
e5bacbc471
commit
e69968b794
4 changed files with 20 additions and 3 deletions
|
@ -125,6 +125,18 @@ void CopyEffects::copy_to_rect(const Rect2 &p_rect) {
|
|||
draw_screen_quad();
|
||||
}
|
||||
|
||||
void CopyEffects::copy_to_and_from_rect(const Rect2 &p_rect) {
|
||||
bool success = copy.shader.version_bind_shader(copy.shader_version, CopyShaderGLES3::MODE_COPY_SECTION_SOURCE);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
|
||||
copy.shader.version_set_uniform(CopyShaderGLES3::COPY_SECTION, p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y, copy.shader_version, CopyShaderGLES3::MODE_COPY_SECTION_SOURCE);
|
||||
copy.shader.version_set_uniform(CopyShaderGLES3::SOURCE_SECTION, p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y, copy.shader_version, CopyShaderGLES3::MODE_COPY_SECTION_SOURCE);
|
||||
|
||||
draw_screen_quad();
|
||||
}
|
||||
|
||||
void CopyEffects::copy_screen() {
|
||||
bool success = copy.shader.version_bind_shader(copy.shader_version, CopyShaderGLES3::MODE_DEFAULT);
|
||||
if (!success) {
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
|
||||
// These functions assume that a framebuffer and texture are bound already. They only manage the shader, uniforms, and vertex array.
|
||||
void copy_to_rect(const Rect2 &p_rect);
|
||||
void copy_to_and_from_rect(const Rect2 &p_rect);
|
||||
void copy_screen();
|
||||
void copy_cube_to_rect(const Rect2 &p_rect);
|
||||
void bilinear_blur(GLuint p_source_texture, int p_mipmap_count, const Rect2i &p_region);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
mode_default = #define MODE_SIMPLE_COPY
|
||||
mode_copy_section = #define USE_COPY_SECTION \n#define MODE_SIMPLE_COPY
|
||||
mode_copy_section_source = #define USE_COPY_SECTION \n#define MODE_SIMPLE_COPY \n#define MODE_COPY_FROM
|
||||
mode_gaussian_blur = #define MODE_GAUSSIAN_BLUR
|
||||
mode_mipmap = #define MODE_MIPMAP
|
||||
mode_simple_color = #define MODE_SIMPLE_COLOR \n#define USE_COPY_SECTION
|
||||
|
@ -21,7 +22,7 @@ out vec2 uv_interp;
|
|||
// Defined in 0-1 coords.
|
||||
uniform highp vec4 copy_section;
|
||||
#endif
|
||||
#ifdef MODE_GAUSSIAN_BLUR
|
||||
#if defined(MODE_GAUSSIAN_BLUR) || defined(MODE_COPY_FROM)
|
||||
uniform highp vec4 source_section;
|
||||
#endif
|
||||
|
||||
|
@ -32,7 +33,7 @@ void main() {
|
|||
#if defined(USE_COPY_SECTION) || defined(MODE_GAUSSIAN_BLUR)
|
||||
gl_Position.xy = (copy_section.xy + uv_interp.xy * copy_section.zw) * 2.0 - 1.0;
|
||||
#endif
|
||||
#ifdef MODE_GAUSSIAN_BLUR
|
||||
#if defined(MODE_GAUSSIAN_BLUR) || defined(MODE_COPY_FROM)
|
||||
uv_interp = source_section.xy + uv_interp * source_section.zw;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -2599,7 +2599,10 @@ void TextureStorage::render_target_copy_to_back_buffer(RID p_render_target, cons
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, rt->backbuffer_fbo);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->color);
|
||||
GLES3::CopyEffects::get_singleton()->copy_screen();
|
||||
Rect2 normalized_region = region;
|
||||
normalized_region.position = normalized_region.position / Size2(rt->size);
|
||||
normalized_region.size = normalized_region.size / Size2(rt->size);
|
||||
GLES3::CopyEffects::get_singleton()->copy_to_and_from_rect(normalized_region);
|
||||
|
||||
if (p_gen_mipmaps) {
|
||||
GLES3::CopyEffects::get_singleton()->gaussian_blur(rt->backbuffer, rt->mipmap_count, region, rt->size);
|
||||
|
|
Loading…
Reference in a new issue