Skip to content

Commit

Permalink
GLES3: Fix usage of texture max level parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
LRFLEW committed Sep 4, 2024
1 parent e2dd56b commit 33adb7b
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 53 deletions.
6 changes: 3 additions & 3 deletions drivers/gles3/effects/copy_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ void CopyEffects::gaussian_blur(GLuint p_source_texture, int p_mipmap_count, con
base_size.x >>= 1;
base_size.y >>= 1;

glBindTexture(GL_TEXTURE_2D, p_source_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, i - 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, i - 1);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_source_texture, i);
Expand Down Expand Up @@ -275,10 +274,11 @@ void CopyEffects::gaussian_blur(GLuint p_source_texture, int p_mipmap_count, con
glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo);
glDeleteFramebuffers(1, &framebuffer);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, p_mipmap_count - 1);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);

glViewport(0, 0, p_size.x, p_size.y);
Expand Down
5 changes: 3 additions & 2 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,9 @@ void RasterizerCanvasGLES3::_update_shadow_atlas() {

glGenTextures(1, &state.shadow_texture);
glBindTexture(GL_TEXTURE_2D, state.shadow_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

if (config->float_texture_supported) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, state.shadow_texture_size, data.max_lights_per_render * 2, 0, GL_RED, GL_FLOAT, nullptr);
} else {
Expand All @@ -1857,8 +1860,6 @@ void RasterizerCanvasGLES3::_update_shadow_atlas() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, state.shadow_texture, 0);

GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
Expand Down
21 changes: 18 additions & 3 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ GLuint _init_radiance_texture(int p_size, int p_mipmaps, String p_name) {

glGenTextures(1, &radiance_id);
glBindTexture(GL_TEXTURE_CUBE_MAP, radiance_id);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, p_mipmaps - 1);

#ifdef GL_API_ENABLED
if (RasterizerGLES3::is_gles_over_gl()) {
//TODO, on low-end compare this to allocating each face of each mip individually
Expand All @@ -576,8 +579,6 @@ GLuint _init_radiance_texture(int p_size, int p_mipmaps, String p_name) {
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, p_mipmaps - 1);

GLES3::Utilities::get_singleton()->texture_allocated_data(radiance_id, Image::get_image_data_size(p_size, p_size, Image::FORMAT_RGBA8, true), p_name);
return radiance_id;
Expand All @@ -588,7 +589,8 @@ void RasterizerSceneGLES3::_update_dirty_skys() {

while (sky) {
if (sky->radiance == 0) {
sky->mipmap_count = Image::get_image_required_mipmaps(sky->radiance_size, sky->radiance_size, Image::FORMAT_RGBA8) - 1;
// Limit mipmaps so smallest is 4x4 for optimization
sky->mipmap_count = MAX(1, Image::get_image_required_mipmaps(sky->radiance_size, sky->radiance_size, Image::FORMAT_RGBA8) - 1);
// Left uninitialized, will attach a texture at render time
glGenFramebuffers(1, &sky->radiance_framebuffer);
sky->radiance = _init_radiance_texture(sky->radiance_size, sky->mipmap_count, "Sky radiance texture");
Expand Down Expand Up @@ -1023,6 +1025,9 @@ Ref<Image> RasterizerSceneGLES3::sky_bake_panorama(RID p_sky, float p_energy, bo
GLuint rad_tex = 0;
glGenTextures(1, &rad_tex);
glBindTexture(GL_TEXTURE_2D, rad_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

if (config->float_texture_supported) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, p_size.width, p_size.height, 0, GL_RGBA, GL_FLOAT, nullptr);
GLES3::Utilities::get_singleton()->texture_allocated_data(rad_tex, p_size.width * p_size.height * 16, "Temp sky panorama");
Expand Down Expand Up @@ -3885,19 +3890,27 @@ TypedArray<Image> RasterizerSceneGLES3::bake_render_uv2(RID p_base, const TypedA
glGenTextures(1, &depth_tex);

glBindTexture(GL_TEXTURE_2D, albedo_alpha_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p_image_size.width, p_image_size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
GLES3::Utilities::get_singleton()->texture_allocated_data(albedo_alpha_tex, p_image_size.width * p_image_size.height * 4, "Lightmap albedo texture");

glBindTexture(GL_TEXTURE_2D, normal_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p_image_size.width, p_image_size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
GLES3::Utilities::get_singleton()->texture_allocated_data(normal_tex, p_image_size.width * p_image_size.height * 4, "Lightmap normal texture");

glBindTexture(GL_TEXTURE_2D, orm_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p_image_size.width, p_image_size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
GLES3::Utilities::get_singleton()->texture_allocated_data(orm_tex, p_image_size.width * p_image_size.height * 4, "Lightmap ORM texture");

// Consider rendering to RGBA8 encoded as RGBE, then manually convert to RGBAH on CPU.
glBindTexture(GL_TEXTURE_2D, emission_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
if (config->float_texture_supported) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, p_image_size.width, p_image_size.height, 0, GL_RGBA, GL_FLOAT, nullptr);
GLES3::Utilities::get_singleton()->texture_allocated_data(emission_tex, p_image_size.width * p_image_size.height * 16, "Lightmap emission texture");
Expand All @@ -3908,6 +3921,8 @@ TypedArray<Image> RasterizerSceneGLES3::bake_render_uv2(RID p_base, const TypedA
}

glBindTexture(GL_TEXTURE_2D, depth_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, p_image_size.width, p_image_size.height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
GLES3::Utilities::get_singleton()->texture_allocated_data(depth_tex, p_image_size.width * p_image_size.height * 3, "Lightmap depth texture");

Expand Down
20 changes: 15 additions & 5 deletions drivers/gles3/storage/light_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,8 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_

if (atlas->depth == 0) {
// We need to create our textures
atlas->mipmap_count = Image::get_image_required_mipmaps(atlas->size, atlas->size, Image::FORMAT_RGBAH) - 1;
// Limit mipmaps so smallest is 4x4 for optimization
atlas->mipmap_count = MAX(1, Image::get_image_required_mipmaps(atlas->size, atlas->size, Image::FORMAT_RGBAH) - 1);
atlas->mipmap_count = MIN(atlas->mipmap_count, 8); // No more than 8 please..

glActiveTexture(GL_TEXTURE0);
Expand All @@ -808,6 +809,8 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
// We create one set of 6 layers for depth, we can reuse this when rendering.
glGenTextures(1, &atlas->depth);
glBindTexture(GL_TEXTURE_2D_ARRAY, atlas->depth);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT24, atlas->size, atlas->size, 6, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);

Expand All @@ -822,6 +825,8 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
GLuint color = 0;
glGenTextures(1, &color);
glBindTexture(GL_TEXTURE_CUBE_MAP, color);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, atlas->mipmap_count - 1);
atlas->reflections.write[i].color = color;

#ifdef GL_API_ENABLED
Expand All @@ -842,8 +847,6 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, atlas->mipmap_count - 1);

// Setup sizes and calculate how much memory we're using.
int mipmap_size = atlas->size;
Expand All @@ -860,6 +863,8 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
GLuint radiance = 0;
glGenTextures(1, &radiance);
glBindTexture(GL_TEXTURE_CUBE_MAP, radiance);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, atlas->mipmap_count - 1);
atlas->reflections.write[i].radiance = radiance;

#ifdef GL_API_ENABLED
Expand All @@ -880,8 +885,6 @@ bool LightStorage::reflection_probe_instance_begin_render(RID p_instance, RID p_
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, atlas->mipmap_count - 1);

// Same data size as our color buffer
GLES3::Utilities::get_singleton()->texture_allocated_data(radiance, data_size, String("Reflection probe atlas (") + String::num_int64(i) + String(", radiance)"));
Expand Down Expand Up @@ -1466,6 +1469,9 @@ bool LightStorage::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_i

if (is_omni) {
glBindTexture(GL_TEXTURE_CUBE_MAP, texture_id);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0);

for (int id = 0; id < 6; id++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + id, 0, format, size / 2, size / 2, 0, GL_DEPTH_COMPONENT, type, nullptr);
}
Expand All @@ -1491,6 +1497,8 @@ bool LightStorage::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_i
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
} else {
glBindTexture(GL_TEXTURE_2D, texture_id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

glTexImage2D(GL_TEXTURE_2D, 0, format, size, size, 0, GL_DEPTH_COMPONENT, type, nullptr);

Expand Down Expand Up @@ -1578,6 +1586,8 @@ void LightStorage::update_directional_shadow_atlas() {
glGenTextures(1, &directional_shadow.depth);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, directional_shadow.depth);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

GLenum format = directional_shadow.use_16_bits ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24;
GLenum type = directional_shadow.use_16_bits ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
Expand Down
2 changes: 2 additions & 0 deletions drivers/gles3/storage/light_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ class LightStorage : public RendererLightStorage {
glGenTextures(1, &atlas->debug_texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, atlas->debug_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, atlas->size, atlas->size, 0, GL_RED, GL_UNSIGNED_INT, nullptr);

Expand Down
6 changes: 6 additions & 0 deletions drivers/gles3/storage/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,11 @@ void MeshStorage::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_
skeleton->data.resize(256 * skeleton->height * 4);
glGenTextures(1, &skeleton->transforms_texture);
glBindTexture(GL_TEXTURE_2D, skeleton->transforms_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 256, skeleton->height, 0, GL_RGBA, GL_FLOAT, nullptr);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
Expand Down Expand Up @@ -2324,6 +2328,8 @@ void MeshStorage::_update_dirty_skeletons() {

if (skeleton->size) {
glBindTexture(GL_TEXTURE_2D, skeleton->transforms_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 256, skeleton->height, 0, GL_RGBA, GL_FLOAT, skeleton->data.ptr());
glBindTexture(GL_TEXTURE_2D, 0);
}
Expand Down
5 changes: 3 additions & 2 deletions drivers/gles3/storage/particles_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,12 +1249,13 @@ GLuint ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_p
glGenTextures(1, &particles_collision->heightfield_texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, particles_collision->heightfield_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, size.x, size.y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

Expand Down
13 changes: 10 additions & 3 deletions drivers/gles3/storage/render_scene_buffers_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
// Create our color buffer.
glGenTextures(1, &internal3d.color);
glBindTexture(texture_target, internal3d.color);
glTexParameteri(texture_target, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(texture_target, GL_TEXTURE_MAX_LEVEL, 0);

if (use_multiview) {
glTexImage3D(texture_target, 0, color_internal_format, internal_size.x, internal_size.y, view_count, 0, color_format, color_type, nullptr);
Expand All @@ -227,6 +229,8 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
// Create our depth buffer.
glGenTextures(1, &internal3d.depth);
glBindTexture(texture_target, internal3d.depth);
glTexParameteri(texture_target, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(texture_target, GL_TEXTURE_MAX_LEVEL, 0);

if (use_multiview) {
glTexImage3D(texture_target, 0, GL_DEPTH_COMPONENT24, internal_size.x, internal_size.y, view_count, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
Expand Down Expand Up @@ -478,6 +482,8 @@ void RenderSceneBuffersGLES3::check_backbuffer(bool p_need_color, bool p_need_de
if (backbuffer3d.color == 0 && p_need_color) {
glGenTextures(1, &backbuffer3d.color);
glBindTexture(texture_target, backbuffer3d.color);
glTexParameteri(texture_target, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(texture_target, GL_TEXTURE_MAX_LEVEL, 0);

if (use_multiview) {
glTexImage3D(texture_target, 0, color_internal_format, internal_size.x, internal_size.y, view_count, 0, color_format, color_type, nullptr);
Expand Down Expand Up @@ -506,6 +512,8 @@ void RenderSceneBuffersGLES3::check_backbuffer(bool p_need_color, bool p_need_de
if (backbuffer3d.depth == 0 && p_need_depth) {
glGenTextures(1, &backbuffer3d.depth);
glBindTexture(texture_target, backbuffer3d.depth);
glTexParameteri(texture_target, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(texture_target, GL_TEXTURE_MAX_LEVEL, 0);

if (use_multiview) {
glTexImage3D(texture_target, 0, GL_DEPTH_COMPONENT24, internal_size.x, internal_size.y, view_count, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
Expand Down Expand Up @@ -579,6 +587,8 @@ void RenderSceneBuffersGLES3::check_glow_buffers() {
glGenTextures(1, &glow.levels[i].color);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, glow.levels[i].color);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, level_size.x, level_size.y, 0, color_format, color_type, nullptr);

Expand All @@ -587,9 +597,6 @@ void RenderSceneBuffersGLES3::check_glow_buffers() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

GLES3::Utilities::get_singleton()->texture_allocated_data(glow.levels[i].color, level_size.x * level_size.y * color_format_size, String("Glow buffer ") + String::num_int64(i));

// Create our FBO
Expand Down
Loading

0 comments on commit 33adb7b

Please sign in to comment.