diff options
Diffstat (limited to 'drivers/gles3')
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.cpp | 22 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_gles3.cpp | 28 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 2 | ||||
-rw-r--r-- | drivers/gles3/storage/material_storage.cpp | 12 | ||||
-rw-r--r-- | drivers/gles3/storage/mesh_storage.cpp | 23 | ||||
-rw-r--r-- | drivers/gles3/storage/mesh_storage.h | 3 | ||||
-rw-r--r-- | drivers/gles3/storage/particles_storage.cpp | 11 | ||||
-rw-r--r-- | drivers/gles3/storage/texture_storage.cpp | 11 |
8 files changed, 65 insertions, 47 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index be18b008be..ecad4b66a5 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1131,16 +1131,10 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend RID particles = pt->particles; state.canvas_instance_batches[state.current_batch_index].tex = pt->texture; state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_INSTANCED; - bool local_coords = particles_storage->particles_is_using_local_coords(particles); if (particles_storage->particles_has_collision(particles) && texture_storage->render_target_is_sdf_enabled(p_render_target)) { // Pass collision information. - Transform2D xform; - if (local_coords) { - xform = p_item->final_transform; - } else { - xform = p_canvas_transform_inverse; - } + Transform2D xform = p_item->final_transform; GLuint sdf_texture = texture_storage->render_target_get_sdf_texture(p_render_target); @@ -2101,6 +2095,9 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe if (t) { ERR_FAIL_COND(!t->canvas_texture); ct = t->canvas_texture; + if (t->render_target) { + t->render_target->used_in_frame = true; + } } else { ct = texture_storage->get_canvas_texture(p_texture); } @@ -2128,6 +2125,9 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe glBindTexture(GL_TEXTURE_2D, texture->tex_id); texture->gl_set_filter(filter); texture->gl_set_repeat(repeat); + if (texture->render_target) { + texture->render_target->used_in_frame = true; + } } GLES3::Texture *normal_map = texture_storage->get_texture(ct->normal_map); @@ -2141,6 +2141,9 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe glBindTexture(GL_TEXTURE_2D, normal_map->tex_id); normal_map->gl_set_filter(filter); normal_map->gl_set_repeat(repeat); + if (normal_map->render_target) { + normal_map->render_target->used_in_frame = true; + } } GLES3::Texture *specular_map = texture_storage->get_texture(ct->specular); @@ -2154,6 +2157,9 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe glBindTexture(GL_TEXTURE_2D, specular_map->tex_id); specular_map->gl_set_filter(filter); specular_map->gl_set_repeat(repeat); + if (specular_map->render_target) { + specular_map->render_target->used_in_frame = true; + } } } @@ -2631,7 +2637,7 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() { global_defines += "#define MAX_LIGHTS " + itos(data.max_lights_per_render) + "\n"; global_defines += "#define MAX_DRAW_DATA_INSTANCES " + itos(data.max_instances_per_batch) + "\n"; - GLES3::MaterialStorage::get_singleton()->shaders.canvas_shader.initialize(global_defines); + GLES3::MaterialStorage::get_singleton()->shaders.canvas_shader.initialize(global_defines, 1); data.canvas_shader_default_version = GLES3::MaterialStorage::get_singleton()->shaders.canvas_shader.version_create(); shadow_render.shader.initialize(); diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 7b4131b3a3..75fc0c8c35 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -333,18 +333,14 @@ void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_c return; } - Size2i win_size = DisplayServer::get_singleton()->screen_get_size(); + Size2i win_size = DisplayServer::get_singleton()->window_get_size(); glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, win_size.width, win_size.height); - glDisable(GL_BLEND); + glEnable(GL_BLEND); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); glDepthMask(GL_FALSE); - if (false) { - // if (OS::get_singleton()->get_window_per_pixel_transparency_enabled()) { - glClearColor(0.0, 0.0, 0.0, 0.0); - } else { - glClearColor(p_color.r, p_color.g, p_color.b, 1.0); - } + glClearColor(p_color.r, p_color.g, p_color.b, 1.0); glClear(GL_COLOR_BUFFER_BIT); RID texture = texture_storage->texture_allocate(); @@ -370,14 +366,24 @@ void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_c screenrect.position += ((Size2(win_size.width, win_size.height) - screenrect.size) / 2.0).floor(); } + // Flip Y. + screenrect.position.y = win_size.y - screenrect.position.y; + screenrect.size.y = -screenrect.size.y; + + // Normalize texture coordinates to window size. + screenrect.position /= win_size; + screenrect.size /= win_size; + GLES3::Texture *t = texture_storage->get_texture(texture); - glActiveTexture(GL_TEXTURE0 + config->max_texture_image_units - 1); + t->gl_set_filter(p_use_filter ? RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR : RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, t->tex_id); + copy_effects->copy_to_rect(screenrect); glBindTexture(GL_TEXTURE_2D, 0); - texture_storage->texture_free(texture); - end_frame(true); + + texture_storage->texture_free(texture); } #endif // GLES3_ENABLED diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index ae5515e249..2b44043faf 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1739,7 +1739,7 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_ render_data.reflection_probes = ∅ } - bool reverse_cull = false; + bool reverse_cull = render_data.cam_transform.basis.determinant() < 0; /////////// // Fill Light lists here diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index e7eeacf576..ebafdc88d8 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -3027,6 +3027,9 @@ void CanvasMaterialData::bind_uniforms() { Texture *texture = TextureStorage::get_singleton()->get_texture(textures[ti]); glActiveTexture(GL_TEXTURE1 + ti); // Start at GL_TEXTURE1 because texture slot 0 is used by the base texture glBindTexture(target_from_type[texture_uniforms[ti].type], texture->tex_id); + if (texture->render_target) { + texture->render_target->used_in_frame = true; + } // Set sampler state here as the same texture can be used in multiple places with different flags // Need to convert sampler state from ShaderLanguage::Texture* to RS::CanvasItemTexture* @@ -3194,6 +3197,9 @@ void SkyMaterialData::bind_uniforms() { Texture *texture = TextureStorage::get_singleton()->get_texture(textures[ti]); glActiveTexture(GL_TEXTURE0 + ti); glBindTexture(target_from_type[texture_uniforms[ti].type], texture->tex_id); + if (texture->render_target) { + texture->render_target->used_in_frame = true; + } // Set sampler state here as the same texture can be used in multiple places with different flags // Need to convert sampler state from ShaderLanguage::Texture* to RS::CanvasItemTexture* @@ -3447,6 +3453,9 @@ void SceneMaterialData::bind_uniforms() { Texture *texture = TextureStorage::get_singleton()->get_texture(textures[ti]); glActiveTexture(GL_TEXTURE0 + ti); glBindTexture(target_from_type[texture_uniforms[ti].type], texture->tex_id); + if (texture->render_target) { + texture->render_target->used_in_frame = true; + } // Set sampler state here as the same texture can be used in multiple places with different flags // Need to convert sampler state from ShaderLanguage::Texture* to RS::CanvasItemTexture* @@ -3562,6 +3571,9 @@ void ParticleProcessMaterialData::bind_uniforms() { Texture *texture = TextureStorage::get_singleton()->get_texture(textures[ti]); glActiveTexture(GL_TEXTURE1 + ti); // Start at GL_TEXTURE1 because texture slot 0 is reserved for the heightmap texture. glBindTexture(target_from_type[texture_uniforms[ti].type], texture->tex_id); + if (texture->render_target) { + texture->render_target->used_in_frame = true; + } // Set sampler state here as the same texture can be used in multiple places with different flags // Need to convert sampler state from ShaderLanguage::Texture* to RS::CanvasItemTexture* diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index 5bbbc7b91b..d31ac4d413 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -323,27 +323,8 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) } if (mesh->surface_count == 0) { - mesh->bone_aabbs = p_surface.bone_aabbs; mesh->aabb = p_surface.aabb; } else { - if (mesh->bone_aabbs.size() < p_surface.bone_aabbs.size()) { - // ArrayMesh::_surface_set_data only allocates bone_aabbs up to max_bone - // Each surface may affect different numbers of bones. - mesh->bone_aabbs.resize(p_surface.bone_aabbs.size()); - } - for (int i = 0; i < p_surface.bone_aabbs.size(); i++) { - const AABB &bone = p_surface.bone_aabbs[i]; - if (bone.has_volume()) { - AABB &mesh_bone = mesh->bone_aabbs.write[i]; - if (mesh_bone != AABB()) { - // Already initialized, merge AABBs. - mesh_bone.merge_with(bone); - } else { - // Not yet initialized, copy the bone AABB. - mesh_bone = bone; - } - } - } mesh->aabb.merge_with(p_surface.aabb); } @@ -528,7 +509,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton); - if (!skeleton || skeleton->size == 0) { + if (!skeleton || skeleton->size == 0 || mesh->skeleton_aabb_version == skeleton->version) { return mesh->aabb; } @@ -622,6 +603,8 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { } } + mesh->aabb = aabb; + mesh->skeleton_aabb_version = skeleton->version; return aabb; } diff --git a/drivers/gles3/storage/mesh_storage.h b/drivers/gles3/storage/mesh_storage.h index 0f30814928..cbbba0d03e 100644 --- a/drivers/gles3/storage/mesh_storage.h +++ b/drivers/gles3/storage/mesh_storage.h @@ -120,12 +120,11 @@ struct Mesh { Surface **surfaces = nullptr; uint32_t surface_count = 0; - Vector<AABB> bone_aabbs; - bool has_bone_weights = false; AABB aabb; AABB custom_aabb; + uint64_t skeleton_aabb_version = 0; Vector<RID> material_cache; diff --git a/drivers/gles3/storage/particles_storage.cpp b/drivers/gles3/storage/particles_storage.cpp index 1a0d97df01..e158a3e90c 100644 --- a/drivers/gles3/storage/particles_storage.cpp +++ b/drivers/gles3/storage/particles_storage.cpp @@ -53,7 +53,7 @@ ParticlesStorage::ParticlesStorage() { { String global_defines; global_defines += "#define MAX_GLOBAL_SHADER_UNIFORMS 256\n"; // TODO: this is arbitrary for now - material_storage->shaders.particles_process_shader.initialize(global_defines); + material_storage->shaders.particles_process_shader.initialize(global_defines, 1); } { // default material and shader for particles shader @@ -528,6 +528,15 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta //2D collision Transform2D xform = p_particles->sdf_collision_transform; //will use dotproduct manually so invert beforehand + + if (!p_particles->use_local_coords) { + Transform2D emission; + emission.columns[0] = Vector2(p_particles->emission_transform.basis.get_column(0).x, p_particles->emission_transform.basis.get_column(0).y); + emission.columns[1] = Vector2(p_particles->emission_transform.basis.get_column(1).x, p_particles->emission_transform.basis.get_column(1).y); + emission.set_origin(Vector2(p_particles->emission_transform.origin.x, p_particles->emission_transform.origin.y)); + xform = xform * emission.affine_inverse(); + } + Transform2D revert = xform.affine_inverse(); frame_params.collider_count = 1; frame_params.colliders[0].transform[0] = xform.columns[0][0]; diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 99908d197a..e6aa6a39c1 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1606,9 +1606,9 @@ void TextureStorage::_update_render_target(RenderTarget *rt) { return; } - if (rt->overridden.color.is_valid()) { - texture->is_render_target = true; - } else { + texture->is_render_target = true; + texture->render_target = rt; + if (rt->overridden.color.is_null()) { texture->format = rt->image_format; texture->real_format = rt->image_format; texture->target = texture_target; @@ -1717,9 +1717,12 @@ void TextureStorage::_clear_render_target(RenderTarget *rt) { tex->width = 0; tex->height = 0; tex->active = false; + tex->render_target = nullptr; + tex->is_render_target = false; } } else { Texture *tex = get_texture(rt->overridden.color); + tex->render_target = nullptr; tex->is_render_target = false; } @@ -1751,7 +1754,7 @@ void TextureStorage::_clear_render_target(RenderTarget *rt) { RID TextureStorage::render_target_create() { RenderTarget render_target; - //render_target.was_used = false; + render_target.used_in_frame = false; render_target.clear_requested = false; Texture t; |