diff options
Diffstat (limited to 'drivers/gles2')
29 files changed, 0 insertions, 624 deletions
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp index 069eeaba6c..b6e36d87a5 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_gles2.cpp @@ -40,7 +40,6 @@ #endif RID RasterizerCanvasGLES2::light_internal_create() { - return RID(); } @@ -51,7 +50,6 @@ void RasterizerCanvasGLES2::light_internal_free(RID p_rid) { } void RasterizerCanvasGLES2::_set_uniforms() { - state.canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX, state.uniforms.projection_matrix); state.canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); state.canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, state.uniforms.extra_matrix); @@ -75,7 +73,6 @@ void RasterizerCanvasGLES2::_set_uniforms() { } if (state.using_light) { - Light *light = state.using_light; state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_MATRIX, light->light_shader_xform); Transform2D basis_inverse = light->light_shader_xform.affine_inverse().orthonormalized(); @@ -110,7 +107,6 @@ void RasterizerCanvasGLES2::_set_uniforms() { } void RasterizerCanvasGLES2::canvas_begin() { - state.canvas_shader.bind(); state.using_transparent_rt = false; int viewport_x, viewport_y, viewport_width, viewport_height; @@ -160,7 +156,6 @@ void RasterizerCanvasGLES2::canvas_begin() { Transform canvas_transform; if (storage->frame.current_rt) { - float csy = 1.0; if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP]) { csy = -1.0; @@ -185,7 +180,6 @@ void RasterizerCanvasGLES2::canvas_begin() { } void RasterizerCanvasGLES2::canvas_end() { - glBindBuffer(GL_ARRAY_BUFFER, 0); for (int i = 0; i < RS::ARRAY_MAX; i++) { @@ -207,11 +201,9 @@ void RasterizerCanvasGLES2::canvas_end() { } RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) { - RasterizerStorageGLES2::Texture *tex_return = nullptr; if (p_texture.is_valid()) { - RasterizerStorageGLES2::Texture *texture = storage->texture_owner.getornull(p_texture); if (!texture) { @@ -222,7 +214,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex); } else { - if (texture->redraw_if_visible) { RenderingServerRaster::redraw_request(); } @@ -254,7 +245,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, state.current_normal.is_valid()); } else if (p_normal_map.is_valid()) { - RasterizerStorageGLES2::Texture *normal_map = storage->texture_owner.getornull(p_normal_map); if (!normal_map) { @@ -264,7 +254,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, false); } else { - if (normal_map->redraw_if_visible) { //check before proxy, because this is usually used with proxies RenderingServerRaster::redraw_request(); } @@ -278,7 +267,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con } } else { - state.current_normal = RID(); glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2); glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex); @@ -289,7 +277,6 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con } void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) { - glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData @@ -365,7 +352,6 @@ void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_coun } void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) { - glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData @@ -407,7 +393,6 @@ void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count } void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) { - glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData @@ -467,7 +452,6 @@ void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int } void RasterizerCanvasGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) { - static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN }; int color_offset = 0; @@ -542,18 +526,14 @@ static const GLenum gl_primitive[] = { }; void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip, RasterizerStorageGLES2::Material *p_material) { - int command_count = p_item->commands.size(); Item::Command **commands = p_item->commands.ptrw(); for (int i = 0; i < command_count; i++) { - Item::Command *command = commands[i]; switch (command->type) { - case Item::Command::TYPE_LINE: { - Item::CommandLine *line = static_cast<Item::CommandLine *>(command); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false); @@ -613,7 +593,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } break; case Item::Command::TYPE_RECT: { - Item::CommandRect *r = static_cast<Item::CommandRect *>(command); glDisableVertexAttribArray(RS::ARRAY_COLOR); @@ -626,7 +605,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur RasterizerStorageGLES2::Texture *texture = storage->texture_owner.getornull(r->texture); if (texture) { - texture = texture->get_ptr(); if (next_power_of_2(texture->alloc_width) != (unsigned int)texture->alloc_width && next_power_of_2(texture->alloc_height) != (unsigned int)texture->alloc_height) { @@ -750,7 +728,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } else { - bool untile = false; if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RS::TEXTURE_FLAG_REPEAT)) { @@ -807,7 +784,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } break; case Item::Command::TYPE_NINEPATCH: { - Item::CommandNinePatch *np = static_cast<Item::CommandNinePatch *>(command); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false); @@ -845,7 +821,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur float screen_scale = 1.0; if (source.size.x != 0 && source.size.y != 0) { - screen_scale = MIN(np->rect.size.x / source.size.x, np->rect.size.y / source.size.y); screen_scale = MIN(1.0, screen_scale); } @@ -857,7 +832,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur float buffer[16 * 2 + 16 * 2]; { - // first row buffer[(0 * 4 * 4) + 0] = np->rect.position.x; @@ -982,7 +956,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } break; case Item::Command::TYPE_CIRCLE: { - Item::CommandCircle *circle = static_cast<Item::CommandCircle *>(command); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false); @@ -1012,7 +985,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } break; case Item::Command::TYPE_POLYGON: { - Item::CommandPolygon *polygon = static_cast<Item::CommandPolygon *>(command); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false); @@ -1043,7 +1015,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur #endif } break; case Item::Command::TYPE_MESH: { - Item::CommandMesh *mesh = static_cast<Item::CommandMesh *>(command); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false); @@ -1061,7 +1032,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur RasterizerStorageGLES2::Mesh *mesh_data = storage->mesh_owner.getornull(mesh->mesh); if (mesh_data) { - for (int j = 0; j < mesh_data->surfaces.size(); j++) { RasterizerStorageGLES2::Surface *s = mesh_data->surfaces[j]; // materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing @@ -1186,7 +1156,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur const float *buffer = base_buffer + k * stride; { - glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 0, &buffer[0]); glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 1, &buffer[4]); if (multi_mesh->transform_format == RS::MULTIMESH_TRANSFORM_3D) { @@ -1252,7 +1221,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur glDisable(GL_LINE_SMOOTH); #endif } else { - #ifdef GLES_OVER_GL if (pline->antialiased) glEnable(GL_LINE_SMOOTH); @@ -1281,7 +1249,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } break; case Item::Command::TYPE_PRIMITIVE: { - Item::CommandPrimitive *primitive = static_cast<Item::CommandPrimitive *>(command); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false); @@ -1316,11 +1283,9 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } break; case Item::Command::TYPE_PARTICLES: { - } break; case Item::Command::TYPE_CLIP_IGNORE: { - Item::CommandClipIgnore *ci = static_cast<Item::CommandClipIgnore *>(command); if (current_clip) { if (ci->ignore != reclip) { @@ -1356,7 +1321,6 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) { - if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) { ERR_PRINT_ONCE("Cannot use screen texture copying in render target set to render direct to screen."); return; @@ -1412,7 +1376,6 @@ void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) { } void RasterizerCanvasGLES2::_copy_texscreen(const Rect2 &p_rect) { - state.canvas_texscreen_used = true; _copy_screen(p_rect); @@ -1425,7 +1388,6 @@ void RasterizerCanvasGLES2::_copy_texscreen(const Rect2 &p_rect) { } void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) { - Item *current_clip = nullptr; RasterizerStorageGLES2::Shader *shader_cache = nullptr; @@ -1447,11 +1409,9 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons RID canvas_last_material = RID(); while (p_item_list) { - Item *ci = p_item_list; if (current_clip != ci->final_clip_owner) { - current_clip = ci->final_clip_owner; if (current_clip) { @@ -1512,7 +1472,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons RasterizerStorageGLES2::Material *material_ptr = storage->material_owner.getornull(material); if (material != canvas_last_material || rebind_shader) { - RasterizerStorageGLES2::Shader *shader_ptr = nullptr; if (material_ptr) { @@ -1540,7 +1499,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } if (shader_ptr != shader_cache) { - if (shader_ptr->canvas_item.uses_time) { RenderingServerRaster::redraw_request(); } @@ -1555,13 +1513,11 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = shader_ptr->texture_hints.ptrw(); for (int i = 0; i < tc; i++) { - glActiveTexture(GL_TEXTURE0 + i); RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(textures[i].second); if (!t) { - switch (texture_hints[i]) { case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO: case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: { @@ -1616,9 +1572,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons bool reclip = false; if (last_blend_mode != blend_mode) { - switch (blend_mode) { - case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_MIX: { glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { @@ -1629,7 +1583,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } break; case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_ADD: { - glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE); @@ -1639,7 +1592,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } break; case RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_SUB: { - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE); @@ -1679,24 +1631,19 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons rebind_shader = true; // hacked in for now. if ((blend_mode == RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_MIX || blend_mode == RasterizerStorageGLES2::Shader::CanvasItem::BLEND_MODE_PMALPHA) && p_light && !unshaded) { - Light *light = p_light; bool light_used = false; RS::CanvasLightMode mode = RS::CANVAS_LIGHT_MODE_ADD; state.uniforms.final_modulate = ci->final_modulate; // remove the canvas modulate while (light) { - if (ci->light_mask & light->item_mask && p_z >= light->z_min && p_z <= light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache)) { - //intersects this light if (!light_used || mode != light->mode) { - mode = light->mode; switch (mode) { - case RS::CANVAS_LIGHT_MODE_ADD: { glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE); @@ -1716,7 +1663,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } if (!light_used) { - state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_LIGHTING, true); light_used = true; } @@ -1762,7 +1708,6 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } if (light_used) { - state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_LIGHTING, false); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS, false); state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_NEAREST, false); @@ -1824,7 +1769,6 @@ void RasterizerCanvasGLES2::canvas_debug_viewport_shadows(Light *p_lights_with_s } void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) { - RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(p_buffer); ERR_FAIL_COND(!cls); @@ -1849,7 +1793,6 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons RS::CanvasOccluderPolygonCullMode cull = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; for (int i = 0; i < 4; i++) { - //make sure it remains orthogonal, makes easy to read angle later Transform light; @@ -1893,10 +1836,8 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons LightOccluderInstance *instance = p_occluders; while (instance) { - RasterizerStorageGLES2::CanvasOccluder *cc = storage->canvas_occluder_owner.getornull(instance->polygon_buffer); if (!cc || cc->len == 0 || !(p_light_mask & instance->light_mask)) { - instance = instance->next; continue; } @@ -1914,21 +1855,17 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons } if (cull != transformed_cull_cache) { - cull = transformed_cull_cache; switch (cull) { case RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: { - glDisable(GL_CULL_FACE); } break; case RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: { - glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); } break; case RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: { - glEnable(GL_CULL_FACE); glCullFace(GL_BACK); @@ -1951,7 +1888,6 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } void RasterizerCanvasGLES2::reset_canvas() { - glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -1983,7 +1919,6 @@ void RasterizerCanvasGLES2::_bind_quad_buffer() { glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, nullptr); } void RasterizerCanvasGLES2::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) { - state.canvas_shader.set_uniform(CanvasShaderGLES2::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y)); state.canvas_shader.set_uniform(CanvasShaderGLES2::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y)); @@ -2028,7 +1963,6 @@ void RasterizerCanvasGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, float } void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_image) { - Vector2 window_size = DisplayServer::get_singleton()->window_get_size(); int window_h = window_size.height; int window_w = window_size.width; @@ -2073,14 +2007,12 @@ void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_im } if (black_image[MARGIN_BOTTOM].is_valid()) { - _bind_canvas_texture(black_image[MARGIN_BOTTOM], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM])); draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y)); } else if (black_margin[MARGIN_BOTTOM]) { - glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); @@ -2091,7 +2023,6 @@ void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_im } void RasterizerCanvasGLES2::initialize() { - // quad buffer { glGenBuffers(1, &data.canvas_quad_vertices); diff --git a/drivers/gles2/rasterizer_canvas_gles2.h b/drivers/gles2/rasterizer_canvas_gles2.h index 2d6355e948..84452fe220 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.h +++ b/drivers/gles2/rasterizer_canvas_gles2.h @@ -59,7 +59,6 @@ public: }; struct Data { - GLuint canvas_quad_vertices; GLuint polygon_buffer; GLuint polygon_index_buffer; diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 28f06f939c..fc9f3c67e6 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -86,7 +86,6 @@ #ifdef CAN_DEBUG static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam) { - if (type == _EXT_DEBUG_TYPE_OTHER_ARB) return; @@ -145,22 +144,18 @@ typedef void (*DEBUGPROCARB)(GLenum source, typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam); RasterizerStorage *RasterizerGLES2::get_storage() { - return storage; } RasterizerCanvas *RasterizerGLES2::get_canvas() { - return canvas; } RasterizerScene *RasterizerGLES2::get_scene() { - return scene; } Error RasterizerGLES2::is_viable() { - #ifdef GLAD_ENABLED if (!gladLoadGL()) { ERR_PRINT("Error initializing GLAD"); @@ -214,7 +209,6 @@ Error RasterizerGLES2::is_viable() { } void RasterizerGLES2::initialize() { - print_verbose("Using GLES2 video driver"); #ifdef GLAD_ENABLED @@ -253,7 +247,6 @@ void RasterizerGLES2::initialize() { } if (callback) { - print_line("godot: ENABLING GL DEBUG"); glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB); callback(_gl_debug_print, nullptr); @@ -296,7 +289,6 @@ void RasterizerGLES2::begin_frame(double frame_step) { } void RasterizerGLES2::set_current_render_target(RID p_render_target) { - if (!p_render_target.is_valid() && storage->frame.current_rt && storage->frame.clear_request) { // pending clear request. Do that first. glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); @@ -337,7 +329,6 @@ void RasterizerGLES2::clear_render_target(const Color &p_color) { } void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { - if (p_image.is_null() || p_image->empty()) return; @@ -364,7 +355,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height()); Rect2 screenrect; if (p_scale) { - if (window_w > window_h) { //scale horizontally screenrect.size.y = window_h; @@ -378,7 +368,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c screenrect.position.y = (window_h - screenrect.size.y) / 2; } } else { - screenrect = imgrect; screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor(); } @@ -396,7 +385,6 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c } void RasterizerGLES2::blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen) { - ERR_FAIL_COND(storage->frame.current_rt); RasterizerStorageGLES2::RenderTarget *rt = storage->render_target_owner.getornull(p_render_target); @@ -446,7 +434,6 @@ void RasterizerGLES2::output_lens_distorted_to_screen(RID p_render_target, const } void RasterizerGLES2::end_frame(bool p_swap_buffers) { - if (OS::get_singleton()->is_layered_allowed()) { if (OS::get_singleton()->get_window_per_pixel_transparency_enabled()) { #if (defined WINDOWS_ENABLED) && !(defined UWP_ENABLED) @@ -478,7 +465,6 @@ void RasterizerGLES2::finalize() { } Rasterizer *RasterizerGLES2::_create_current() { - return memnew(RasterizerGLES2); } @@ -490,7 +476,6 @@ void RasterizerGLES2::register_config() { } RasterizerGLES2::RasterizerGLES2() { - storage = memnew(RasterizerStorageGLES2); canvas = memnew(RasterizerCanvasGLES2); scene = memnew(RasterizerSceneGLES2); @@ -504,7 +489,6 @@ RasterizerGLES2::RasterizerGLES2() { } RasterizerGLES2::~RasterizerGLES2() { - memdelete(storage); memdelete(canvas); } diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 027a634ae8..e9bef31d1e 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -37,7 +37,6 @@ #include "servers/rendering/rasterizer.h" class RasterizerGLES2 : public Rasterizer { - static Rasterizer *_create_current(); RasterizerStorageGLES2 *storage; diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index bdf0559f58..02e9d7d504 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -72,7 +72,6 @@ static const GLenum _cube_side_enum[6] = { /* SHADOW ATLAS API */ RID RasterizerSceneGLES2::shadow_atlas_create() { - ShadowAtlas *shadow_atlas = memnew(ShadowAtlas); shadow_atlas->fbo = 0; shadow_atlas->depth = 0; @@ -133,7 +132,6 @@ void RasterizerSceneGLES2::shadow_atlas_set_size(RID p_atlas, int p_size) { glActiveTexture(GL_TEXTURE0); if (storage->config.use_rgba_3d_shadows) { - //maximum compatibility, renderbuffer and RGBA shadow glGenRenderbuffers(1, &shadow_atlas->depth); glBindRenderbuffer(GL_RENDERBUFFER, shadow_atlas->depth); @@ -234,7 +232,6 @@ void RasterizerSceneGLES2::shadow_atlas_set_quadrant_subdivision(RID p_atlas, in } bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_in_quadrants, int p_quadrant_count, int p_current_subdiv, uint64_t p_tick, int &r_quadrant, int &r_shadow) { - for (int i = p_quadrant_count - 1; i >= 0; i--) { int qidx = p_in_quadrants[i]; @@ -262,7 +259,6 @@ bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, ERR_CONTINUE(!sli); if (sli->last_scene_pass != scene_pass) { - // was just allocated, don't kill it so soon, wait a bit... if (p_tick - sarr[j].alloc_tick < shadow_atlas_realloc_tolerance_msec) { @@ -294,7 +290,6 @@ bool RasterizerSceneGLES2::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, } bool RasterizerSceneGLES2::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) { - ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_atlas); ERR_FAIL_COND_V(!shadow_atlas, false); @@ -441,7 +436,6 @@ void RasterizerSceneGLES2::set_directional_shadow_count(int p_count) { } int RasterizerSceneGLES2::get_directional_light_shadow_size(RID p_light_intance) { - ERR_FAIL_COND_V(directional_shadow.light_count == 0, 0); int shadow_size; @@ -481,7 +475,6 @@ void RasterizerSceneGLES2::reflection_atlas_set_subdivision(RID p_ref_atlas, int //////////////////////////////////////////////////// RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) { - RasterizerStorageGLES2::ReflectionProbe *probe = storage->reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND_V(!probe, RID()); @@ -512,7 +505,6 @@ RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) { } void RasterizerSceneGLES2::reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) { - ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance); ERR_FAIL_COND(!rpi); rpi->transform = p_transform; @@ -535,14 +527,12 @@ bool RasterizerSceneGLES2::reflection_probe_instance_has_reflection(RID p_instan } bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { - ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance); ERR_FAIL_COND_V(!rpi, false); rpi->render_step = 0; if (rpi->probe_ptr->resolution != rpi->current_resolution) { - //update cubemap if resolution changed int size = rpi->probe_ptr->resolution; rpi->current_resolution = size; @@ -594,7 +584,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance } bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_instance) { - ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance); ERR_FAIL_COND_V(!rpi, false); ERR_FAIL_COND_V(rpi->current_resolution == 0, false); @@ -643,7 +632,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst //blur while (size >= 1) { - glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, storage->resources.mipmap_blur_color); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); @@ -652,7 +640,6 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst glActiveTexture(GL_TEXTURE0); for (int i = 0; i < 6; i++) { - storage->bind_quad_array(); storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::FACE_ID, i); float roughness = CLAMP(lod / (float)(mipmaps - 1), 0, 1); @@ -684,14 +671,12 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst /* ENVIRONMENT API */ RID RasterizerSceneGLES2::environment_create() { - Environment *env = memnew(Environment); return environment_owner.make_rid(env); } void RasterizerSceneGLES2::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) { - Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->bg_mode = p_bg; @@ -756,7 +741,6 @@ void RasterizerSceneGLES2::environment_set_camera_feed_id(RID p_env, int p_camer } void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) { - Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -768,7 +752,6 @@ void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable } void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) { - Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -780,7 +763,6 @@ void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enabl } void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) { - Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -817,7 +799,6 @@ void RasterizerSceneGLES2::environment_set_tonemap(RID p_env, RS::EnvironmentTon } void RasterizerSceneGLES2::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) { - Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -829,7 +810,6 @@ void RasterizerSceneGLES2::environment_set_adjustment(RID p_env, bool p_enable, } void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) { - Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -840,7 +820,6 @@ void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, const C } void RasterizerSceneGLES2::environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve) { - Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -853,7 +832,6 @@ void RasterizerSceneGLES2::environment_set_fog_depth(RID p_env, bool p_enable, f } void RasterizerSceneGLES2::environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) { - Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -881,7 +859,6 @@ int RasterizerSceneGLES2::environment_get_canvas_max_layer(RID p_env) { } RID RasterizerSceneGLES2::light_instance_create(RID p_light) { - LightInstance *light_instance = memnew(LightInstance); light_instance->last_scene_pass = 0; @@ -902,7 +879,6 @@ RID RasterizerSceneGLES2::light_instance_create(RID p_light) { } void RasterizerSceneGLES2::light_instance_set_transform(RID p_light_instance, const Transform &p_transform) { - LightInstance *light_instance = light_instance_owner.getornull(p_light_instance); ERR_FAIL_COND(!light_instance); @@ -910,7 +886,6 @@ void RasterizerSceneGLES2::light_instance_set_transform(RID p_light_instance, co } void RasterizerSceneGLES2::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale) { - LightInstance *light_instance = light_instance_owner.getornull(p_light_instance); ERR_FAIL_COND(!light_instance); @@ -928,7 +903,6 @@ void RasterizerSceneGLES2::light_instance_set_shadow_transform(RID p_light_insta } void RasterizerSceneGLES2::light_instance_mark_visible(RID p_light_instance) { - LightInstance *light_instance = light_instance_owner.getornull(p_light_instance); ERR_FAIL_COND(!light_instance); @@ -938,7 +912,6 @@ void RasterizerSceneGLES2::light_instance_mark_visible(RID p_light_instance) { ////////////////////// RID RasterizerSceneGLES2::gi_probe_instance_create() { - return RID(); } @@ -955,7 +928,6 @@ void RasterizerSceneGLES2::gi_probe_instance_set_bounds(RID p_probe, const Vecto //////////////////////////// void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, int p_material, bool p_depth_pass, bool p_shadow_pass) { - RasterizerStorageGLES2::Material *material = nullptr; RID material_src; @@ -994,7 +966,6 @@ void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geo } } void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, RasterizerStorageGLES2::Material *p_material, bool p_depth_pass, bool p_shadow_pass) { - bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture || p_material->shader->spatial.uses_depth_texture; bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_MIX; bool has_alpha = has_base_alpha || has_blend_alpha; @@ -1016,7 +987,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G } if (p_depth_pass) { - if (has_blend_alpha || p_material->shader->spatial.uses_depth_texture || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) return; //bye @@ -1077,7 +1047,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G e->refprobe_1_index = RenderList::MAX_REFLECTION_PROBES; //refprobe disabled by default if (!p_depth_pass) { - e->depth_layer = e->instance->depth_layer; e->priority = p_material->render_priority; @@ -1119,11 +1088,9 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G if (p_material->shader->spatial.unshaded) { e->light_mode = LIGHTMODE_UNSHADED; } else { - bool copy = false; for (int i = 0; i < render_directional_lights; i++) { - if (copy) { RenderList::Element *e2 = has_alpha ? render_list.add_alpha_element() : render_list.add_element(); if (!e2) { @@ -1144,7 +1111,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G //add omni / spots for (int i = 0; i < e->instance->light_instances.size(); i++) { - LightInstance *li = light_instance_owner.getornull(e->instance->light_instances[i]); if (!li || li->light_index >= render_light_instance_count || render_light_instances[li->light_index] != li) { @@ -1186,7 +1152,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G } void RasterizerSceneGLES2::_copy_texture_to_buffer(GLuint p_texture, GLuint p_buffer) { - //copy to front buffer glBindFramebuffer(GL_FRAMEBUFFER, p_buffer); @@ -1210,7 +1175,6 @@ void RasterizerSceneGLES2::_copy_texture_to_buffer(GLuint p_texture, GLuint p_bu } void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass, bool p_shadow_pass) { - render_pass++; current_material_index = 0; current_geometry_index = 0; @@ -1219,13 +1183,10 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p current_shader_index = 0; for (int i = 0; i < p_cull_count; i++) { - InstanceBase *instance = p_cull_result[i]; switch (instance->base_type) { - case RS::INSTANCE_MESH: { - RasterizerStorageGLES2::Mesh *mesh = storage->mesh_owner.getornull(instance->base); ERR_CONTINUE(!mesh); @@ -1285,7 +1246,6 @@ static const GLenum gl_primitive[] = { }; void RasterizerSceneGLES2::_set_cull(bool p_front, bool p_disabled, bool p_reverse_cull) { - bool front = p_front; if (p_reverse_cull) front = !front; @@ -1300,14 +1260,12 @@ void RasterizerSceneGLES2::_set_cull(bool p_front, bool p_disabled, bool p_rever } if (front != state.cull_front) { - glCullFace(front ? GL_FRONT : GL_BACK); state.cull_front = front; } } bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_material, bool p_alpha_pass, Size2i p_skeleton_tex_size) { - // material parameters state.scene_shader.set_custom_shader(p_material->shader->custom_code_id); @@ -1333,7 +1291,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m switch (p_material->shader->spatial.depth_draw_mode) { case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS: case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_OPAQUE: { - glDepthMask(!p_alpha_pass && !p_material->shader->spatial.uses_depth_texture); } break; case RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALWAYS: { @@ -1355,20 +1312,17 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m state.current_main_tex = 0; for (int i = 0; i < tc; i++) { - glActiveTexture(GL_TEXTURE0 + i); RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(textures[i].second); if (!t) { - GLenum target = GL_TEXTURE_2D; GLuint tex = 0; switch (texture_types[i]) { case ShaderLanguage::TYPE_ISAMPLER2D: case ShaderLanguage::TYPE_USAMPLER2D: case ShaderLanguage::TYPE_SAMPLER2D: { - switch (texture_hints[i]) { case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO: case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: { @@ -1394,7 +1348,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m case ShaderLanguage::TYPE_ISAMPLER3D: case ShaderLanguage::TYPE_USAMPLER3D: case ShaderLanguage::TYPE_SAMPLER3D: { - target = GL_TEXTURE_3D; tex = storage->resources.white_tex_3d; @@ -1407,7 +1360,6 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m case ShaderLanguage::TYPE_ISAMPLER2DARRAY: case ShaderLanguage::TYPE_USAMPLER2DARRAY: case ShaderLanguage::TYPE_SAMPLER2DARRAY: { - target = GL_TEXTURE_2D_ARRAY; tex = storage->resources.white_tex_array; @@ -1456,9 +1408,7 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m } void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, RasterizerStorageGLES2::Skeleton *p_skeleton) { - switch (p_element->instance->base_type) { - case RS::INSTANCE_MESH: { RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry); @@ -1491,7 +1441,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste bool clear_skeleton_buffer = storage->config.use_skeleton_software; if (p_skeleton) { - if (!storage->config.use_skeleton_software) { //use float texture workflow glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1); @@ -1524,7 +1473,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste const uint8_t *vertex_data = vertex_array_read.ptr(); for (int i = 0; i < s->array_len; i++) { - // do magic size_t bones[4]; @@ -1613,7 +1561,6 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste } if (clear_skeleton_buffer) { - glDisableVertexAttribArray(INSTANCE_BONE_BASE + 0); glDisableVertexAttribArray(INSTANCE_BONE_BASE + 1); glDisableVertexAttribArray(INSTANCE_BONE_BASE + 2); @@ -1671,11 +1618,8 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste } void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { - switch (p_element->instance->base_type) { - case RS::INSTANCE_MESH: { - RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry); // drawing @@ -1704,7 +1648,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { } break; case RS::INSTANCE_MULTIMESH: { - RasterizerStorageGLES2::MultiMesh *multi_mesh = static_cast<RasterizerStorageGLES2::MultiMesh *>(p_element->owner); RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry); @@ -1727,7 +1670,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { const float *buffer = base_buffer + i * stride; { - glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 0, &buffer[0]); glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 1, &buffer[4]); glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 2, &buffer[8]); @@ -1809,7 +1751,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { glBindTexture(t->target, t->tex_id); restore_tex = true; } else if (restore_tex) { - glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, state.current_main_tex); restore_tex = false; @@ -1880,7 +1821,6 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { } void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas *shadow_atlas) { - //turn off all by default state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTING, false); state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, false); @@ -1902,7 +1842,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas switch (p_light->light_ptr->type) { case RS::LIGHT_DIRECTIONAL: { - state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_DIRECTIONAL, true); switch (p_light->light_ptr->directional_shadow_mode) { case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: { @@ -1932,7 +1871,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas } break; case RS::LIGHT_OMNI: { - state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_OMNI, true); if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) { state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, true); @@ -1947,7 +1885,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas } } break; case RS::LIGHT_SPOT: { - state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_SPOT, true); if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) { state.scene_shader.set_conditional(SceneShaderGLES2::USE_SHADOW, true); @@ -1965,7 +1902,6 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas } void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform, bool accum_pass) { - RasterizerStorageGLES2::Light *light_ptr = light->light_ptr; //common parameters @@ -1990,7 +1926,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado CameraMatrix matrices[4]; if (!state.render_no_shadows && light_ptr->shadow && directional_shadow.depth) { - int shadow_count = 0; Color split_offsets; @@ -2009,14 +1944,12 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado } for (int k = 0; k < shadow_count; k++) { - uint32_t x = light->directional_rect.position.x; uint32_t y = light->directional_rect.position.y; uint32_t width = light->directional_rect.size.x; uint32_t height = light->directional_rect.size.y; if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { - width /= 2; height /= 2; @@ -2030,7 +1963,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado } } else if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { - height /= 2; if (k != 0) { @@ -2068,7 +2000,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado } } break; case RS::LIGHT_OMNI: { - Vector3 position = p_view_transform.xform_inv(light->transform.origin); state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_POSITION, position); @@ -2080,7 +2011,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_ATTENUATION, attenuation); if (!state.render_no_shadows && light_ptr->shadow && shadow_atlas && shadow_atlas->shadow_owners.has(light->self)) { - uint32_t key = shadow_atlas->shadow_owners[light->self]; uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x03; @@ -2122,7 +2052,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado } break; case RS::LIGHT_SPOT: { - Vector3 position = p_view_transform.xform_inv(light->transform.origin); state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_POSITION, position); @@ -2191,7 +2120,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado } void RasterizerSceneGLES2::_setup_refprobes(ReflectionProbeInstance *p_refprobe1, ReflectionProbeInstance *p_refprobe2, const Transform &p_view_transform, Environment *p_env) { - if (p_refprobe1) { state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_USE_BOX_PROJECT, p_refprobe1->probe_ptr->box_projection); state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_BOX_EXTENTS, p_refprobe1->probe_ptr->extents); @@ -2240,7 +2168,6 @@ void RasterizerSceneGLES2::_setup_refprobes(ReflectionProbeInstance *p_refprobe1 } void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, int p_element_count, const Transform &p_view_transform, const CameraMatrix &p_projection, RID p_shadow_atlas, Environment *p_env, GLuint p_base_env, float p_shadow_bias, float p_shadow_normal_bias, bool p_reverse_cull, bool p_alpha_pass, bool p_shadow) { - ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas); Vector2 viewport_size = state.viewport_size; @@ -2323,7 +2250,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, bool rebind_lightmap = false; if (!p_shadow && material->shader) { - bool unshaded = material->shader->spatial.unshaded; if (unshaded != prev_unshaded) { @@ -2353,7 +2279,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, } if (light != prev_light) { - _setup_light_type(light, shadow_atlas); rebind = true; rebind_light = true; @@ -2369,7 +2294,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, } if (prev_blend_mode != blend_mode) { - if (prev_blend_mode == -1 && blend_mode != -1) { //does blend glEnable(GL_BLEND); @@ -2390,13 +2314,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, } break; case RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_ADD: { - glBlendEquation(GL_FUNC_ADD); glBlendFunc(p_alpha_pass ? GL_SRC_ALPHA : GL_ONE, GL_ONE); } break; case RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_SUB: { - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); glBlendFunc(GL_SRC_ALPHA, GL_ONE); } break; @@ -2449,13 +2371,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, use_lightmap_capture = !unshaded && !accum_pass && !e->instance->lightmap_capture_data.empty(); if (use_lightmap_capture != prev_use_lightmap_capture) { - state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP_CAPTURE, use_lightmap_capture); rebind = true; } if (!unshaded && !accum_pass && e->instance->lightmap.is_valid()) { - lightmap = storage->texture_owner.getornull(e->instance->lightmap); lightmap_energy = 1.0; if (lightmap) { @@ -2484,7 +2404,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, } if (depth_prepass != prev_depth_prepass) { - state.scene_shader.set_conditional(SceneShaderGLES2::USE_DEPTH_PREPASS, depth_prepass); prev_depth_prepass = depth_prepass; rebind = true; @@ -2493,7 +2412,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, bool instancing = e->instance->base_type == RS::INSTANCE_MULTIMESH; if (instancing != prev_instancing) { - state.scene_shader.set_conditional(SceneShaderGLES2::USE_INSTANCING, instancing); rebind = true; } @@ -2520,7 +2438,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, bool shader_rebind = false; if (rebind || material != prev_material) { - storage->info.render.material_switch_count++; shader_rebind = _setup_material(material, p_alpha_pass, Size2i(skeleton ? skeleton->size * 3 : 0, 0)); if (shader_rebind) { @@ -2572,7 +2489,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, rebind_lightmap = true; if (using_fog) { - state.scene_shader.set_uniform(SceneShaderGLES2::FOG_COLOR_BASE, p_env->fog_color); Color sun_color_amount = p_env->fog_sun_color; sun_color_amount.a = p_env->fog_sun_amount; @@ -2679,7 +2595,6 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C CameraMatrix camera; if (p_custom_fov) { - float near_plane = p_projection.get_z_near(); float far_plane = p_projection.get_z_far(); float aspect = p_projection.get_aspect(); @@ -2763,7 +2678,6 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C } void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p_cam_projection) { - //copy to front buffer glDepthMask(GL_FALSE); @@ -2839,7 +2753,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p // DOF Blur if (env->dof_blur_far_enabled) { - int vp_h = storage->frame.current_rt->height; int vp_w = storage->frame.current_rt->width; @@ -2896,7 +2809,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p } if (env->dof_blur_near_enabled) { - //convert texture to RGBA format if not already if (!storage->frame.current_rt->used_dof_blur_near) { glActiveTexture(GL_TEXTURE0); @@ -3002,10 +2914,8 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p int glow_mask = 0; if (env->glow_enabled) { - for (int i = 0; i < RS::MAX_GLOW_LEVELS; i++) { if (env->glow_levels & (1 << i)) { - if (i >= storage->frame.current_rt->mip_maps[1].sizes.size()) { max_glow_level = storage->frame.current_rt->mip_maps[1].sizes.size() - 1; glow_mask |= 1 << max_glow_level; @@ -3018,7 +2928,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p } for (int i = 0; i < (max_glow_level + 1); i++) { - int vp_w = storage->frame.current_rt->mip_maps[1].sizes[i].width; int vp_h = storage->frame.current_rt->mip_maps[1].sizes[i].height; glViewport(0, 0, vp_w, vp_h); @@ -3043,7 +2952,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p } if (i == 0) { - state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_BLOOM, env->glow_bloom); state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_HDR_THRESHOLD, env->glow_hdr_bleed_threshold); state.effect_blur_shader.set_uniform(EffectBlurShaderGLES2::GLOW_HDR_SCALE, env->glow_hdr_bleed_scale); @@ -3094,7 +3002,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p if (max_glow_level >= 0) { if (storage->frame.current_rt->mip_maps[0].color) { for (int i = 0; i < (max_glow_level + 1); i++) { - if (glow_mask & (1 << i)) { if (i == 0) { state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_LEVEL1, true); @@ -3122,11 +3029,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->mip_maps[0].color); } else { - state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_MULTI_TEXTURE_GLOW, true); int active_glow_level = 0; for (int i = 0; i < (max_glow_level + 1); i++) { - if (glow_mask & (1 << i)) { active_glow_level++; glActiveTexture(GL_TEXTURE0 + active_glow_level); @@ -3163,7 +3068,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p //Adjustments if (env->adjustments_enabled) { - state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_BCS, true); RasterizerStorageGLES2::Texture *tex = storage->texture_owner.getornull(env->color_correction); if (tex) { @@ -3176,7 +3080,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p state.tonemap_shader.bind(); if (max_glow_level >= 0) { - state.tonemap_shader.set_uniform(TonemapShaderGLES2::GLOW_INTENSITY, env->glow_intensity); int ss[2] = { storage->frame.current_rt->width, @@ -3186,7 +3089,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p } if (env->adjustments_enabled) { - state.tonemap_shader.set_uniform(TonemapShaderGLES2::BCS, Vector3(env->adjustments_brightness, env->adjustments_contrast, env->adjustments_saturation)); } @@ -3210,7 +3112,6 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p } void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) { - Transform cam_transform = p_cam_transform; storage->info.render.object_count += p_cull_count; @@ -3306,7 +3207,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const } if (p_reflection_probe_cull_count) { - reflection_probe_instances = (ReflectionProbeInstance **)alloca(sizeof(ReflectionProbeInstance *) * p_reflection_probe_cull_count); reflection_probe_count = p_reflection_probe_cull_count; for (int i = 0; i < p_reflection_probe_cull_count; i++) { @@ -3339,7 +3239,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const glViewport(viewport_x, viewport_y, viewport_width, viewport_height); if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) { - glScissor(viewport_x, viewport_y, viewport_width, viewport_height); glEnable(GL_SCISSOR_TEST); } @@ -3395,7 +3294,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const GLuint env_radiance_tex = 0; if (env) { switch (env->bg_mode) { - case RS::ENV_BG_COLOR_SKY: case RS::ENV_BG_SKY: { sky = storage->sky_owner.getornull(env->sky); @@ -3485,7 +3383,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const // then draw the sky after if (env && env->bg_mode == RS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) { - if (sky && sky->panorama.is_valid()) { _draw_sky(sky, p_cam_projection, cam_transform, false, env->sky_custom_fov, env->bg_energy, env->sky_orientation); } @@ -3586,7 +3483,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const } void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) { - state.render_no_shadows = false; LightInstance *light_instance = light_instance_owner.getornull(p_light); @@ -3652,7 +3548,6 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ height = light_instance->directional_rect.size.height; if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { - width /= 2; height /= 2; @@ -3666,11 +3561,9 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ } } else if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { - height /= 2; if (p_pass == 0) { - } else { y += height; } @@ -3737,7 +3630,6 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ light_transform = light_instance->shadow_transform[0].transform; if (light->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) { - height /= 2; y += p_pass * height; } else { @@ -3871,9 +3763,7 @@ void RasterizerSceneGLES2::set_scene_pass(uint64_t p_pass) { } bool RasterizerSceneGLES2::free(RID p_rid) { - if (light_instance_owner.owns(p_rid)) { - LightInstance *light_instance = light_instance_owner.getornull(p_rid); //remove from shadow atlases.. @@ -3892,13 +3782,11 @@ bool RasterizerSceneGLES2::free(RID p_rid) { memdelete(light_instance); } else if (shadow_atlas_owner.owns(p_rid)) { - ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_rid); shadow_atlas_set_size(p_rid, 0); shadow_atlas_owner.free(p_rid); memdelete(shadow_atlas); } else if (reflection_probe_instance_owner.owns(p_rid)) { - ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.getornull(p_rid); for (int i = 0; i < 6; i++) { @@ -4000,7 +3888,6 @@ void RasterizerSceneGLES2::initialize() { glActiveTexture(GL_TEXTURE0); while (cube_size >= 32) { - ShadowCubeMap cube; cube.size = cube_size; @@ -4009,7 +3896,6 @@ void RasterizerSceneGLES2::initialize() { glBindTexture(GL_TEXTURE_CUBE_MAP, cube.cubemap); for (int i = 0; i < 6; i++) { - glTexImage2D(_cube_side_enum[i], 0, storage->config.depth_internalformat, cube_size, cube_size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, nullptr); } @@ -4021,7 +3907,6 @@ void RasterizerSceneGLES2::initialize() { glGenFramebuffers(6, cube.fbo); for (int i = 0; i < 6; i++) { - glBindFramebuffer(GL_FRAMEBUFFER, cube.fbo[i]); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _cube_side_enum[i], cube.cubemap, 0); } diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h index 56c0e632c2..d017fc49a2 100644 --- a/drivers/gles2/rasterizer_scene_gles2.h +++ b/drivers/gles2/rasterizer_scene_gles2.h @@ -77,7 +77,6 @@ public: RasterizerStorageGLES2 *storage; struct State { - bool texscreen_copied; int current_blend_mode; float current_line_width; @@ -195,7 +194,6 @@ public: /* REFLECTION PROBE INSTANCE */ struct ReflectionProbeInstance { - RasterizerStorageGLES2::ReflectionProbe *probe_ptr; RID probe; RID self; @@ -387,7 +385,6 @@ public: /* LIGHT INSTANCE */ struct LightInstance { - struct ShadowTransform { CameraMatrix camera; Transform transform; @@ -449,7 +446,6 @@ public: }; struct RenderList { - enum { MAX_LIGHTS = 255, MAX_REFLECTION_PROBES = 255, @@ -534,7 +530,6 @@ public: } struct SortByDepth { - _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const { return A->instance->depth < B->instance->depth; } @@ -551,7 +546,6 @@ public: } struct SortByReverseDepthAndPriority { - _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const { if (A->priority == B->priority) { return A->instance->depth > B->instance->depth; diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index b8c7815f6a..0636676ffa 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -135,7 +135,6 @@ void RasterizerStorageGLES2::bind_quad_array() const { } Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const { - r_gl_format = 0; Ref<Image> image = p_image; r_compressed = false; @@ -144,9 +143,7 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_ bool need_decompress = false; switch (p_format) { - case Image::FORMAT_L8: { - r_gl_internal_format = GL_LUMINANCE; r_gl_format = GL_LUMINANCE; r_gl_type = GL_UNSIGNED_BYTE; @@ -157,7 +154,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_ r_gl_type = GL_UNSIGNED_BYTE; } break; case Image::FORMAT_R8: { - r_gl_internal_format = GL_ALPHA; r_gl_format = GL_ALPHA; r_gl_type = GL_UNSIGNED_BYTE; @@ -174,28 +170,24 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_ } break; case Image::FORMAT_RGB8: { - r_gl_internal_format = GL_RGB; r_gl_format = GL_RGB; r_gl_type = GL_UNSIGNED_BYTE; } break; case Image::FORMAT_RGBA8: { - r_gl_format = GL_RGBA; r_gl_internal_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; } break; case Image::FORMAT_RGBA4444: { - r_gl_internal_format = GL_RGBA; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_SHORT_4_4_4_4; } break; case Image::FORMAT_RGB565: { - r_gl_internal_format = GL_RGB5_A1; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_SHORT_5_5_5_1; @@ -280,7 +272,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_ } break; case Image::FORMAT_DXT1: { - if (config.s3tc_supported) { r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; r_gl_format = GL_RGBA; @@ -292,7 +283,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_ } break; case Image::FORMAT_DXT3: { - if (config.s3tc_supported) { r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT; r_gl_format = GL_RGBA; @@ -304,7 +294,6 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_ } break; case Image::FORMAT_DXT5: { - if (config.s3tc_supported) { r_gl_internal_format = _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT; r_gl_format = GL_RGBA; @@ -316,134 +305,107 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_ } break; case Image::FORMAT_RGTC_R: { - if (config.rgtc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RED_RGTC1_EXT; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_RGTC_RG: { - if (config.rgtc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RED_GREEN_RGTC2_EXT; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_BPTC_RGBA: { - if (config.bptc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RGBA_BPTC_UNORM; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_BPTC_RGBF: { - if (config.bptc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT; r_gl_format = GL_RGB; r_gl_type = GL_FLOAT; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_BPTC_RGBFU: { if (config.bptc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT; r_gl_format = GL_RGB; r_gl_type = GL_FLOAT; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_PVRTC2: { - if (config.pvrtc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_PVRTC2A: { - if (config.pvrtc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_PVRTC4: { - if (config.pvrtc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_PVRTC4A: { - if (config.pvrtc_supported) { - r_gl_internal_format = _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; } else { - need_decompress = true; } } break; case Image::FORMAT_ETC: { - if (config.etc1_supported) { r_gl_internal_format = _EXT_ETC1_RGB8_OES; r_gl_format = GL_RGBA; @@ -454,43 +416,33 @@ Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_ } } break; case Image::FORMAT_ETC2_R11: { - need_decompress = true; } break; case Image::FORMAT_ETC2_R11S: { - need_decompress = true; } break; case Image::FORMAT_ETC2_RG11: { - need_decompress = true; } break; case Image::FORMAT_ETC2_RG11S: { - need_decompress = true; } break; case Image::FORMAT_ETC2_RGB8: { - need_decompress = true; } break; case Image::FORMAT_ETC2_RGBA8: { - need_decompress = true; } break; case Image::FORMAT_ETC2_RGB8A1: { - need_decompress = true; } break; default: { - ERR_FAIL_V(Ref<Image>()); } } if (need_decompress || p_force_decompress) { - if (!image.is_null()) { - image = image->duplicate(); image->decompress(); ERR_FAIL_COND_V(image->is_compressed(), image); @@ -539,7 +491,6 @@ static const GLenum _cube_side_enum[6] = { }; RID RasterizerStorageGLES2::texture_create() { - Texture *texture = memnew(Texture); ERR_FAIL_COND_V(!texture, RID()); glGenTextures(1, &texture->tex_id); @@ -612,7 +563,6 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_ bool is_po2 = p_width == po2_width && p_height == po2_height; if (!is_po2 && (p_flags & RS::TEXTURE_FLAG_REPEAT || p_flags & RS::TEXTURE_FLAG_MIPMAPS)) { - if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) { //not supported ERR_PRINT("Streaming texture for non power of 2 or has mipmaps on this hardware: " + texture->path + "'. Mipmaps and repeat disabled."); @@ -641,7 +591,6 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_ #if defined(GLES_OVER_GL) || defined(ANDROID_ENABLED) if ((p_type == RS::TEXTURE_TYPE_3D && config.texture_3d_supported) || (p_type == RS::TEXTURE_TYPE_2D_ARRAY && config.texture_array_supported)) { - int width = p_width; int height = p_height; int depth = p_depth_3d; @@ -718,15 +667,12 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p } if (config.shrink_textures_x2 && (p_image->has_mipmaps() || !p_image->is_compressed()) && !(texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING)) { - texture->alloc_height = MAX(1, texture->alloc_height / 2); texture->alloc_width = MAX(1, texture->alloc_width / 2); if (texture->alloc_width == img->get_width() / 2 && texture->alloc_height == img->get_height() / 2) { - img->shrink_x2(); } else if (img->get_format() <= Image::FORMAT_RGBA8) { - img->resize(texture->alloc_width, texture->alloc_height, Image::INTERPOLATE_BILINEAR); } } @@ -769,16 +715,13 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p } if (texture->flags & RS::TEXTURE_FLAG_FILTER) { - glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering } else { - glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering } if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) { - if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); @@ -787,7 +730,6 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } } else { - //glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); @@ -801,11 +743,9 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p int tsize = 0; for (int i = 0; i < mipmaps; i++) { - int size, ofs; img->get_mipmap_offset_and_size(i, ofs, size); if (texture->type == RS::TEXTURE_TYPE_2D || texture->type == RS::TEXTURE_TYPE_CUBEMAP) { - if (compressed) { glPixelStorei(GL_UNPACK_ALIGNMENT, 4); @@ -814,7 +754,6 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p glCompressedTexImage2D(blit_target, i, internal_format, bw, bh, 0, size, &read[ofs]); } else { - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); if (texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) { glTexSubImage2D(blit_target, i, 0, 0, w, h, format, type, &read[ofs]); @@ -868,7 +807,6 @@ void RasterizerStorageGLES2::texture_set_data_partial(RID p_texture, const Ref<I } Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) const { - Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND_V(!texture, Ref<Image>()); @@ -902,7 +840,6 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); for (int i = 0; i < texture->mipmaps; i++) { - int ofs = Image::get_image_mipmap_offset(texture->alloc_width, texture->alloc_height, real_format, i); if (texture->compressed) { @@ -993,7 +930,6 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) } void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) { - Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND(!texture); @@ -1005,7 +941,6 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) glBindTexture(texture->target, texture->tex_id); if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) { - if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); @@ -1034,11 +969,9 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) } if (texture->flags & RS::TEXTURE_FLAG_FILTER) { - glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering } else { - glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering } } @@ -1140,7 +1073,6 @@ void RasterizerStorageGLES2::texture_debug_usage(List<RS::TextureInfo> *r_info) texture_owner.get_owned_list(&textures); for (List<RID>::Element *E = textures.front(); E; E = E->next()) { - Texture *t = texture_owner.getornull(E->get()); if (!t) continue; @@ -1164,7 +1096,6 @@ void RasterizerStorageGLES2::textures_keep_original(bool p_enable) { } Size2 RasterizerStorageGLES2::texture_size_with_proxy(RID p_texture) const { - const Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND_V(!texture, Size2()); if (texture->proxy) { @@ -1193,7 +1124,6 @@ void RasterizerStorageGLES2::texture_set_proxy(RID p_texture, RID p_proxy) { } void RasterizerStorageGLES2::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) { - Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND(!texture); @@ -1225,7 +1155,6 @@ void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, R } RID RasterizerStorageGLES2::texture_create_radiance_cubemap(RID p_source, int p_resolution) const { - return RID(); } @@ -1326,7 +1255,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra // third, render to the framebuffer using separate textures, then copy to mipmaps while (size >= 1) { - //make framebuffer size the texture size, need to use a separate texture for compatibility glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, resources.mipmap_blur_color); @@ -1348,7 +1276,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra glActiveTexture(GL_TEXTURE2); //back to panorama for (int i = 0; i < 6; i++) { - shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::FACE_ID, i); float roughness = mm_level >= 0 ? lod / (float)(mipmaps - 1) : 1; @@ -1395,7 +1322,6 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra /* SHADER API */ RID RasterizerStorageGLES2::shader_create() { - Shader *shader = memnew(Shader); shader->mode = RS::SHADER_SPATIAL; shader->shader = &scene->state.scene_shader; @@ -1414,7 +1340,6 @@ void RasterizerStorageGLES2::_shader_make_dirty(Shader *p_shader) { } void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code) { - Shader *shader = shader_owner.getornull(p_shader); ERR_FAIL_COND(!shader); @@ -1457,7 +1382,6 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code) } String RasterizerStorageGLES2::shader_get_code(RID p_shader) const { - const Shader *shader = shader_owner.getornull(p_shader); ERR_FAIL_COND_V(!shader, ""); @@ -1465,7 +1389,6 @@ String RasterizerStorageGLES2::shader_get_code(RID p_shader) const { } void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const { - _shader_dirty_list.remove(&p_shader->dirty_list); p_shader->valid = false; @@ -1480,9 +1403,7 @@ void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const { ShaderCompilerGLES2::IdentifierActions *actions = nullptr; switch (p_shader->mode) { - case RS::SHADER_CANVAS_ITEM: { - p_shader->canvas_item.light_mode = Shader::CanvasItem::LIGHT_MODE_NORMAL; p_shader->canvas_item.blend_mode = Shader::CanvasItem::BLEND_MODE_MIX; @@ -1611,7 +1532,6 @@ void RasterizerStorageGLES2::update_dirty_shaders() { } void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const { - Shader *shader = shader_owner.getornull(p_shader); ERR_FAIL_COND(!shader); @@ -1622,7 +1542,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn Map<int, StringName> order; for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { - if (E->get().texture_order >= 0) { order[E->get().texture_order + 100000] = E->key(); } else { @@ -1631,7 +1550,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn } for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) { - PropertyInfo pi; ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[E->get()]; @@ -1738,7 +1656,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn case ShaderLanguage::TYPE_SAMPLER2DARRAY: case ShaderLanguage::TYPE_ISAMPLER2DARRAY: case ShaderLanguage::TYPE_USAMPLER2DARRAY: { - pi.type = Variant::OBJECT; pi.hint = PROPERTY_HINT_RESOURCE_TYPE; pi.hint_string = "TextureArray"; @@ -1758,7 +1675,6 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn } void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) { - Shader *shader = shader_owner.getornull(p_shader); ERR_FAIL_COND(!shader); ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture)); @@ -1773,7 +1689,6 @@ void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, cons } RID RasterizerStorageGLES2::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const { - const Shader *shader = shader_owner.getornull(p_shader); ERR_FAIL_COND_V(!shader, RID()); @@ -1789,7 +1704,6 @@ RID RasterizerStorageGLES2::shader_get_default_texture_param(RID p_shader, const /* COMMON MATERIAL API */ void RasterizerStorageGLES2::_material_make_dirty(Material *p_material) const { - if (p_material->dirty_list.in_list()) return; @@ -1797,14 +1711,12 @@ void RasterizerStorageGLES2::_material_make_dirty(Material *p_material) const { } RID RasterizerStorageGLES2::material_create() { - Material *material = memnew(Material); return material_owner.make_rid(material); } void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) { - Material *material = material_owner.getornull(p_material); ERR_FAIL_COND(!material); @@ -1825,7 +1737,6 @@ void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) { } RID RasterizerStorageGLES2::material_get_shader(RID p_material) const { - const Material *material = material_owner.getornull(p_material); ERR_FAIL_COND_V(!material, RID()); @@ -1837,7 +1748,6 @@ RID RasterizerStorageGLES2::material_get_shader(RID p_material) const { } void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) { - Material *material = material_owner.getornull(p_material); ERR_FAIL_COND(!material); @@ -1851,7 +1761,6 @@ void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName } Variant RasterizerStorageGLES2::material_get_param(RID p_material, const StringName &p_param) const { - const Material *material = material_owner.getornull(p_material); ERR_FAIL_COND_V(!material, RID()); @@ -1921,7 +1830,6 @@ bool RasterizerStorageGLES2::material_casts_shadows(RID p_material) { } void RasterizerStorageGLES2::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) { - Material *material = material_owner.getornull(p_material); ERR_FAIL_COND(!material); @@ -1934,7 +1842,6 @@ void RasterizerStorageGLES2::material_add_instance_owner(RID p_material, Rasteri } void RasterizerStorageGLES2::material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) { - Material *material = material_owner.getornull(p_material); ERR_FAIL_COND(!material); @@ -1976,7 +1883,6 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) { bool is_animated = false; if (p_material->shader && p_material->shader->mode == RS::SHADER_SPATIAL) { - if (p_material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX && (!p_material->shader->spatial.uses_alpha || p_material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) { can_cast_shadow = true; @@ -2008,7 +1914,6 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) { // uniforms and other things will be set in the use_material method in ShaderGLES2 if (p_material->shader && p_material->shader->texture_count > 0) { - p_material->textures.resize(p_material->shader->texture_count); for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = p_material->shader->uniforms.front(); E; E = E->next()) { @@ -2052,7 +1957,6 @@ void RasterizerStorageGLES2::_material_add_geometry(RID p_material, Geometry *p_ } void RasterizerStorageGLES2::_material_remove_geometry(RID p_material, Geometry *p_geometry) { - Material *material = material_owner.getornull(p_material); ERR_FAIL_COND(!material); @@ -2068,7 +1972,6 @@ void RasterizerStorageGLES2::_material_remove_geometry(RID p_material, Geometry void RasterizerStorageGLES2::update_dirty_materials() { while (_material_dirty_list.first()) { - Material *material = _material_dirty_list.first()->self(); _update_material(material); } @@ -2077,14 +1980,12 @@ void RasterizerStorageGLES2::update_dirty_materials() { /* MESH API */ RID RasterizerStorageGLES2::mesh_create() { - Mesh *mesh = memnew(Mesh); return mesh_owner.make_rid(mesh); } static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_t &format, int p_vertices) { - uint32_t p_format = format; static int src_size[RS::ARRAY_MAX]; @@ -2095,7 +1996,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ int dst_stride = 0; for (int i = 0; i < RS::ARRAY_MAX; i++) { - to_convert[i] = 0; if (!(p_format & (1 << i))) { src_size[i] = 0; @@ -2104,11 +2004,8 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } switch (i) { - case RS::ARRAY_VERTEX: { - if (p_format & RS::ARRAY_COMPRESS_VERTEX) { - if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) { src_size[i] = 4; dst_size[i] = 8; @@ -2121,7 +2018,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ format &= ~RS::ARRAY_COMPRESS_VERTEX; } else { - if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) { src_size[i] = 8; dst_size[i] = 8; @@ -2133,7 +2029,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } break; case RS::ARRAY_NORMAL: { - if (p_format & RS::ARRAY_COMPRESS_NORMAL) { src_size[i] = 4; dst_size[i] = 4; @@ -2144,7 +2039,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } break; case RS::ARRAY_TANGENT: { - if (p_format & RS::ARRAY_COMPRESS_TANGENT) { src_size[i] = 4; dst_size[i] = 4; @@ -2155,7 +2049,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } break; case RS::ARRAY_COLOR: { - if (p_format & RS::ARRAY_COMPRESS_COLOR) { src_size[i] = 4; dst_size[i] = 4; @@ -2166,7 +2059,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } break; case RS::ARRAY_TEX_UV: { - if (p_format & RS::ARRAY_COMPRESS_TEX_UV) { src_size[i] = 4; to_convert[i] = 2; @@ -2179,7 +2071,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } break; case RS::ARRAY_TEX_UV2: { - if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) { src_size[i] = 4; to_convert[i] = 2; @@ -2192,7 +2083,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } break; case RS::ARRAY_BONES: { - if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) { src_size[i] = 8; dst_size[i] = 8; @@ -2203,7 +2093,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } break; case RS::ARRAY_WEIGHTS: { - if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) { src_size[i] = 8; dst_size[i] = 8; @@ -2214,7 +2103,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } break; case RS::ARRAY_INDEX: { - src_size[i] = 0; dst_size[i] = 0; @@ -2235,7 +2123,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ int dst_offset = 0; for (int i = 0; i < RS::ARRAY_MAX; i++) { - if (src_size[i] == 0) { continue; //no go } @@ -2248,7 +2135,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ float *dst = (float *)&wptr[dst_stride * j + dst_offset]; for (int k = 0; k < to_convert[i]; k++) { - dst[k] = Math::half_to_float(src[k]); } } @@ -2273,7 +2159,6 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { - Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); @@ -2293,7 +2178,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: bool uses_half_float = false; for (int i = 0; i < RS::ARRAY_MAX; i++) { - attribs[i].index = i; if (!(p_format & (1 << i))) { @@ -2307,9 +2191,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: attribs[i].integer = false; switch (i) { - case RS::ARRAY_VERTEX: { - if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) { attribs[i].size = 2; } else { @@ -2329,7 +2211,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } break; case RS::ARRAY_NORMAL: { - attribs[i].size = 3; if (p_format & RS::ARRAY_COMPRESS_NORMAL) { @@ -2344,7 +2225,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } break; case RS::ARRAY_TANGENT: { - attribs[i].size = 4; if (p_format & RS::ARRAY_COMPRESS_TANGENT) { @@ -2359,7 +2239,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } break; case RS::ARRAY_COLOR: { - attribs[i].size = 4; if (p_format & RS::ARRAY_COMPRESS_COLOR) { @@ -2374,7 +2253,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } break; case RS::ARRAY_TEX_UV: { - attribs[i].size = 2; if (p_format & RS::ARRAY_COMPRESS_TEX_UV) { @@ -2390,7 +2268,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } break; case RS::ARRAY_TEX_UV2: { - attribs[i].size = 2; if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) { @@ -2405,7 +2282,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } break; case RS::ARRAY_BONES: { - attribs[i].size = 4; if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) { @@ -2421,11 +2297,9 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } break; case RS::ARRAY_WEIGHTS: { - attribs[i].size = 4; if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) { - attribs[i].type = GL_UNSIGNED_SHORT; stride += 8; attribs[i].normalized = GL_TRUE; @@ -2437,7 +2311,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } break; case RS::ARRAY_INDEX: { - attribs[i].size = 1; if (p_vertex_count >= (1 << 16)) { @@ -2478,7 +2351,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: uint16_t one = Math::make_half_float(1); for (int i = 0; i < p_vertex_count; i++) { - *w16++ = *r16++; *w16++ = *r16++; *w16++ = *r16++; @@ -2492,7 +2364,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: ERR_FAIL_COND(array.size() != array_size); if (!config.support_half_float_vertices && uses_half_float) { - uint32_t new_format = p_format; Vector<uint8_t> unpacked_array = _unpack_half_floats(array, new_format, p_vertex_count); @@ -2501,7 +2372,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } if (p_format & RS::ARRAY_FORMAT_INDEX) { - index_array_size = attribs[RS::ARRAY_INDEX].stride * p_index_count; } @@ -2577,7 +2447,6 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: // blend shapes for (int i = 0; i < p_blend_shapes.size(); i++) { - Surface::BlendShape mt; const uint8_t *vr = p_blend_shapes[i].ptr(); @@ -2692,7 +2561,6 @@ int RasterizerStorageGLES2::mesh_surface_get_array_index_len(RID p_mesh, int p_s } Vector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, int p_surface) const { - const Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND_V(!mesh, Vector<uint8_t>()); ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<uint8_t>()); @@ -2758,7 +2626,6 @@ Vector<AABB> RasterizerStorageGLES2::mesh_surface_get_skeleton_aabb(RID p_mesh, } void RasterizerStorageGLES2::mesh_remove_surface(RID p_mesh, int p_surface) { - Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); ERR_FAIL_INDEX(p_surface, mesh->surfaces.size()); @@ -2823,12 +2690,9 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { AABB aabb; if (sk && sk->size != 0) { - for (int i = 0; i < mesh->surfaces.size(); i++) { - AABB laabb; if ((mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) { - int bs = mesh->surfaces[i]->skeleton_bone_aabb.size(); const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); const bool *skused = mesh->surfaces[i]->skeleton_bone_used.ptr(); @@ -2840,7 +2704,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { bool first = true; if (sk->use_2d) { for (int j = 0; j < bs; j++) { - if (!skused[j]) continue; @@ -2867,7 +2730,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { } } else { for (int j = 0; j < bs; j++) { - if (!skused[j]) continue; @@ -2901,7 +2763,6 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { } } else { - laabb = mesh->surfaces[i]->aabb; } @@ -2911,9 +2772,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { aabb.merge_with(laabb); } } else { - for (int i = 0; i < mesh->surfaces.size(); i++) { - if (i == 0) aabb = mesh->surfaces[i]->aabb; else @@ -3158,7 +3017,6 @@ void RasterizerStorageGLES2::multimesh_instance_set_color(RID p_multimesh, int p float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats]; if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) { - uint8_t *data8 = (uint8_t *)dataptr; data8[0] = CLAMP(p_color.r * 255.0, 0, 255); data8[1] = CLAMP(p_color.g * 255.0, 0, 255); @@ -3191,7 +3049,6 @@ void RasterizerStorageGLES2::multimesh_instance_set_custom_data(RID p_multimesh, float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats]; if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) { - uint8_t *data8 = (uint8_t *)dataptr; data8[0] = CLAMP(p_custom_data.r * 255.0, 0, 255); data8[1] = CLAMP(p_custom_data.g * 255.0, 0, 255); @@ -3379,13 +3236,10 @@ AABB RasterizerStorageGLES2::multimesh_get_aabb(RID p_multimesh) const { } void RasterizerStorageGLES2::update_dirty_multimeshes() { - while (multimesh_update_list.first()) { - MultiMesh *multimesh = multimesh_update_list.first()->self(); if (multimesh->size && multimesh->dirty_aabb) { - AABB mesh_aabb; if (multimesh->mesh.is_valid()) { @@ -3401,9 +3255,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() { AABB aabb; if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) { - for (int i = 0; i < count; i += stride) { - float *dataptr = &data[i]; Transform xform; @@ -3424,9 +3276,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() { } } else { - for (int i = 0; i < count; i += stride) { - float *dataptr = &data[i]; Transform xform; @@ -3599,7 +3449,6 @@ RID RasterizerStorageGLES2::immediate_get_material(RID p_immediate) const { /* SKELETON API */ RID RasterizerStorageGLES2::skeleton_create() { - Skeleton *skeleton = memnew(Skeleton); glGenTextures(1, &skeleton->tex_id); @@ -3608,7 +3457,6 @@ RID RasterizerStorageGLES2::skeleton_create() { } void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton) { - Skeleton *skeleton = skeleton_owner.getornull(p_skeleton); ERR_FAIL_COND(!skeleton); ERR_FAIL_COND(p_bones < 0); @@ -3621,7 +3469,6 @@ void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool skeleton->use_2d = p_2d_skeleton; if (!config.use_skeleton_software) { - glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, skeleton->tex_id); @@ -3762,7 +3609,6 @@ Transform2D RasterizerStorageGLES2::skeleton_bone_get_transform_2d(RID p_skeleto } void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) { - Skeleton *skeleton = skeleton_owner.getornull(p_skeleton); ERR_FAIL_COND(!skeleton); @@ -3770,7 +3616,6 @@ void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, cons } void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const Vector<float> &p_data, size_t p_size) { - glBindBuffer(GL_ARRAY_BUFFER, resources.skeleton_transform_buffer); if (p_size > resources.skeleton_transform_buffer_size) { @@ -3787,7 +3632,6 @@ void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const Vector<floa } void RasterizerStorageGLES2::update_dirty_skeletons() { - if (config.use_skeleton_software) return; @@ -3813,7 +3657,6 @@ void RasterizerStorageGLES2::update_dirty_skeletons() { /* Light API */ RID RasterizerStorageGLES2::light_create(RS::LightType p_type) { - Light *light = memnew(Light); light->type = p_type; @@ -4060,7 +3903,6 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const { ERR_FAIL_COND_V(!light, AABB()); switch (light->type) { - case RS::LIGHT_SPOT: { float len = light->param[RS::LIGHT_PARAM_RANGE]; float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len; @@ -4083,7 +3925,6 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const { /* PROBE API */ RID RasterizerStorageGLES2::reflection_probe_create() { - ReflectionProbe *reflection_probe = memnew(ReflectionProbe); reflection_probe->intensity = 1.0; @@ -4104,7 +3945,6 @@ RID RasterizerStorageGLES2::reflection_probe_create() { } void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4113,7 +3953,6 @@ void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::R } void RasterizerStorageGLES2::reflection_probe_set_intensity(RID p_probe, float p_intensity) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4121,7 +3960,6 @@ void RasterizerStorageGLES2::reflection_probe_set_intensity(RID p_probe, float p } void RasterizerStorageGLES2::reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4129,7 +3967,6 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient(RID p_probe, } void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4137,7 +3974,6 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_energy(RID p_ } void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4145,7 +3981,6 @@ void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_probe_contrib } void RasterizerStorageGLES2::reflection_probe_set_max_distance(RID p_probe, float p_distance) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4153,7 +3988,6 @@ void RasterizerStorageGLES2::reflection_probe_set_max_distance(RID p_probe, floa reflection_probe->instance_change_notify(true, false); } void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4161,7 +3995,6 @@ void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vec reflection_probe->instance_change_notify(true, false); } void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4170,7 +4003,6 @@ void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, con } void RasterizerStorageGLES2::reflection_probe_set_as_interior(RID p_probe, bool p_enable) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4178,7 +4010,6 @@ void RasterizerStorageGLES2::reflection_probe_set_as_interior(RID p_probe, bool reflection_probe->instance_change_notify(true, false); } void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4186,7 +4017,6 @@ void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_pr } void RasterizerStorageGLES2::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4194,7 +4024,6 @@ void RasterizerStorageGLES2::reflection_probe_set_enable_shadows(RID p_probe, bo reflection_probe->instance_change_notify(true, false); } void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4203,7 +4032,6 @@ void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_ } void RasterizerStorageGLES2::reflection_probe_set_resolution(RID p_probe, int p_resolution) { - ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4221,7 +4049,6 @@ AABB RasterizerStorageGLES2::reflection_probe_get_aabb(RID p_probe) const { return aabb; } RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const { - const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS); @@ -4229,7 +4056,6 @@ RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_updat } uint32_t RasterizerStorageGLES2::reflection_probe_get_cull_mask(RID p_probe) const { - const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND_V(!reflection_probe, 0); @@ -4237,14 +4063,12 @@ uint32_t RasterizerStorageGLES2::reflection_probe_get_cull_mask(RID p_probe) con } Vector3 RasterizerStorageGLES2::reflection_probe_get_extents(RID p_probe) const { - const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND_V(!reflection_probe, Vector3()); return reflection_probe->extents; } Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe) const { - const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND_V(!reflection_probe, Vector3()); @@ -4252,7 +4076,6 @@ Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe) } bool RasterizerStorageGLES2::reflection_probe_renders_shadows(RID p_probe) const { - const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND_V(!reflection_probe, false); @@ -4260,7 +4083,6 @@ bool RasterizerStorageGLES2::reflection_probe_renders_shadows(RID p_probe) const } float RasterizerStorageGLES2::reflection_probe_get_origin_max_distance(RID p_probe) const { - const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND_V(!reflection_probe, 0); @@ -4268,7 +4090,6 @@ float RasterizerStorageGLES2::reflection_probe_get_origin_max_distance(RID p_pro } int RasterizerStorageGLES2::reflection_probe_get_resolution(RID p_probe) const { - const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND_V(!reflection_probe, 0); @@ -4373,26 +4194,22 @@ void RasterizerStorageGLES2::gi_probe_dynamic_data_update(RID p_gi_probe_data, i /////// RID RasterizerStorageGLES2::lightmap_capture_create() { - LightmapCapture *capture = memnew(LightmapCapture); return lightmap_capture_data_owner.make_rid(capture); } void RasterizerStorageGLES2::lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) { - LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND(!capture); capture->bounds = p_bounds; capture->instance_change_notify(true, false); } AABB RasterizerStorageGLES2::lightmap_capture_get_bounds(RID p_capture) const { - const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND_V(!capture, AABB()); return capture->bounds; } void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) { - LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND(!capture); @@ -4407,7 +4224,6 @@ void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Ve capture->instance_change_notify(true, false); } Vector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const { - const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND_V(!capture, Vector<uint8_t>()); @@ -4450,14 +4266,12 @@ int RasterizerStorageGLES2::lightmap_capture_get_octree_cell_subdiv(RID p_captur } void RasterizerStorageGLES2::lightmap_capture_set_energy(RID p_capture, float p_energy) { - LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND(!capture); capture->energy = p_energy; } float RasterizerStorageGLES2::lightmap_capture_get_energy(RID p_capture) const { - const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND_V(!capture, 0); return capture->energy; @@ -4562,7 +4376,6 @@ bool RasterizerStorageGLES2::particles_is_inactive(RID p_particles) const { //////// void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) { - Skeleton *skeleton = skeleton_owner.getornull(p_skeleton); ERR_FAIL_COND(!skeleton); @@ -4570,7 +4383,6 @@ void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerSce } void RasterizerStorageGLES2::instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) { - Skeleton *skeleton = skeleton_owner.getornull(p_skeleton); ERR_FAIL_COND(!skeleton); @@ -4578,7 +4390,6 @@ void RasterizerStorageGLES2::instance_remove_skeleton(RID p_skeleton, Rasterizer } void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) { - Instantiable *inst = nullptr; switch (p_instance->base_type) { case RS::INSTANCE_MESH: { @@ -4622,7 +4433,6 @@ void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene } void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) { - Instantiable *inst = nullptr; switch (p_instance->base_type) { @@ -4669,7 +4479,6 @@ void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerSc /* RENDER TARGET */ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { - // do not allocate a render target with no size if (rt->width <= 0 || rt->height <= 0) return; @@ -4707,7 +4516,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { rt->mip_maps_allocated = false; { - /* Front FBO */ Texture *texture = texture_owner.getornull(rt->texture); @@ -4724,11 +4532,9 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, nullptr); if (texture->flags & RS::TEXTURE_FLAG_FILTER) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } @@ -4741,7 +4547,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { // depth if (config.support_depth_texture) { - glGenTextures(1, &rt->depth); glBindTexture(GL_TEXTURE_2D, rt->depth); glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, rt->width, rt->height, 0, GL_DEPTH_COMPONENT, config.depth_type, nullptr); @@ -4753,7 +4558,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0); } else { - glGenRenderbuffers(1, &rt->depth); glBindRenderbuffer(GL_RENDERBUFFER, rt->depth); @@ -4765,13 +4569,10 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { - glDeleteFramebuffers(1, &rt->fbo); if (config.support_depth_texture) { - glDeleteTextures(1, &rt->depth); } else { - glDeleteRenderbuffers(1, &rt->depth); } @@ -4806,7 +4607,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { #ifndef JAVASCRIPT_ENABLED if (rt->msaa >= RS::VIEWPORT_MSAA_2X && rt->msaa <= RS::VIEWPORT_MSAA_16X && config.multisample_supported) { - rt->multisample_active = true; static const int msaa_value[] = { 0, 2, 4, 8, 16 }; @@ -4889,7 +4689,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { // copy texscreen buffers if (!(rt->flags[RasterizerStorage::RENDER_TARGET_NO_SAMPLING])) { - glGenTextures(1, &rt->copy_screen_effect.color); glBindTexture(GL_TEXTURE_2D, rt->copy_screen_effect.color); @@ -4920,9 +4719,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { // Allocate mipmap chains for post_process effects if (!rt->flags[RasterizerStorage::RENDER_TARGET_NO_3D] && rt->width >= 2 && rt->height >= 2) { - for (int i = 0; i < 2; i++) { - ERR_FAIL_COND(rt->mip_maps[i].sizes.size()); int w = rt->width; int h = rt->height; @@ -4937,7 +4734,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { int fb_h = h; while (true) { - RenderTarget::MipMaps::Size mm; mm.width = w; mm.height = h; @@ -4956,7 +4752,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { GLsizei height = fb_h; if (config.render_to_mipmap_supported) { - glGenTextures(1, &rt->mip_maps[i].color); glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].color); @@ -4970,7 +4765,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level); #endif } else { - // Can't render to specific levels of a mipmap in ES 2.0 or Webgl so create a texture for each level for (int l = 0; l < level + 1; l++) { glGenTextures(1, &rt->mip_maps[i].sizes.write[l].color); @@ -4990,17 +4784,14 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glDepthMask(GL_TRUE); for (int j = 0; j < rt->mip_maps[i].sizes.size(); j++) { - RenderTarget::MipMaps::Size &mm = rt->mip_maps[i].sizes.write[j]; glGenFramebuffers(1, &mm.fbo); glBindFramebuffer(GL_FRAMEBUFFER, mm.fbo); if (config.render_to_mipmap_supported) { - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->mip_maps[i].color, j); } else { - glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].sizes[j].color); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->mip_maps[i].sizes[j].color, 0); } @@ -5046,7 +4837,6 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { } void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) { - // there is nothing to clear when DIRECT_TO_SCREEN is used if (rt->flags[RENDER_TARGET_DIRECT_TO_SCREEN]) return; @@ -5129,7 +4919,6 @@ void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) { } RID RasterizerStorageGLES2::render_target_create() { - RenderTarget *rt = memnew(RenderTarget); Texture *t = memnew(Texture); @@ -5160,7 +4949,6 @@ RID RasterizerStorageGLES2::render_target_create() { } void RasterizerStorageGLES2::render_target_set_position(RID p_render_target, int p_x, int p_y) { - RenderTarget *rt = render_target_owner.getornull(p_render_target); ERR_FAIL_COND(!rt); @@ -5169,7 +4957,6 @@ void RasterizerStorageGLES2::render_target_set_position(RID p_render_target, int } void RasterizerStorageGLES2::render_target_set_size(RID p_render_target, int p_width, int p_height) { - RenderTarget *rt = render_target_owner.getornull(p_render_target); ERR_FAIL_COND(!rt); @@ -5185,7 +4972,6 @@ void RasterizerStorageGLES2::render_target_set_size(RID p_render_target, int p_w } RID RasterizerStorageGLES2::render_target_get_texture(RID p_render_target) const { - RenderTarget *rt = render_target_owner.getornull(p_render_target); ERR_FAIL_COND_V(!rt, RID()); @@ -5390,7 +5176,6 @@ void RasterizerStorageGLES2::render_target_set_msaa(RID p_render_target, RS::Vie /* CANVAS SHADOW */ RID RasterizerStorageGLES2::canvas_light_shadow_buffer_create(int p_width) { - CanvasLightShadow *cls = memnew(CanvasLightShadow); if (p_width > config.max_texture_size) @@ -5442,7 +5227,6 @@ RID RasterizerStorageGLES2::canvas_light_shadow_buffer_create(int p_width) { /* LIGHT SHADOW MAPPING */ RID RasterizerStorageGLES2::canvas_light_occluder_create() { - CanvasOccluder *co = memnew(CanvasOccluder); co->index_id = 0; co->vertex_id = 0; @@ -5452,14 +5236,12 @@ RID RasterizerStorageGLES2::canvas_light_occluder_create() { } void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines) { - CanvasOccluder *co = canvas_occluder_owner.getornull(p_occluder); ERR_FAIL_COND(!co); co->lines = p_lines; if (p_lines.size() != co->len) { - if (co->index_id) glDeleteBuffers(1, &co->index_id); if (co->vertex_id) @@ -5471,7 +5253,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, } if (p_lines.size()) { - Vector<float> geometry; Vector<uint16_t> indices; int lc = p_lines.size(); @@ -5487,7 +5268,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const int POLY_HEIGHT = 16384; for (int i = 0; i < lc / 2; i++) { - vw[i * 12 + 0] = lr[i * 2 + 0].x; vw[i * 12 + 1] = lr[i * 2 + 0].y; vw[i * 12 + 2] = POLY_HEIGHT; @@ -5520,7 +5300,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id); glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_STATIC_DRAW); } else { - glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id); glBufferSubData(GL_ARRAY_BUFFER, 0, lc * 6 * sizeof(real_t), vw.ptr()); } @@ -5528,12 +5307,10 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind if (!co->index_id) { - glGenBuffers(1, &co->index_id); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id); glBufferData(GL_ELEMENT_ARRAY_BUFFER, lc * 3 * sizeof(uint16_t), iw.ptr(), GL_DYNAMIC_DRAW); } else { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, lc * 3 * sizeof(uint16_t), iw.ptr()); } @@ -5545,7 +5322,6 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, } RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const { - if (mesh_owner.owns(p_rid)) { return RS::INSTANCE_MESH; } else if (light_owner.owns(p_rid)) { @@ -5564,9 +5340,7 @@ RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const { } bool RasterizerStorageGLES2::free(RID p_rid) { - if (render_target_owner.owns(p_rid)) { - RenderTarget *rt = render_target_owner.getornull(p_rid); _render_target_clear(rt); @@ -5578,7 +5352,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (texture_owner.owns(p_rid)) { - Texture *t = texture_owner.getornull(p_rid); // can't free a render target texture ERR_FAIL_COND_V(t->render_target, true); @@ -5589,7 +5362,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (sky_owner.owns(p_rid)) { - Sky *sky = sky_owner.getornull(p_rid); sky_set_texture(p_rid, RID(), 256); sky_owner.free(p_rid); @@ -5597,7 +5369,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (shader_owner.owns(p_rid)) { - Shader *shader = shader_owner.getornull(p_rid); if (shader->shader && shader->custom_code_id) { @@ -5622,7 +5393,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (material_owner.owns(p_rid)) { - Material *m = material_owner.getornull(p_rid); if (m->shader) { @@ -5635,7 +5405,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { } for (Map<RasterizerScene::InstanceBase *, int>::Element *E = m->instance_owners.front(); E; E = E->next()) { - RasterizerScene::InstanceBase *ins = E->key(); if (ins->material_override == p_rid) { @@ -5654,7 +5423,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (skeleton_owner.owns(p_rid)) { - Skeleton *s = skeleton_owner.getornull(p_rid); if (s->update_list.in_list()) { @@ -5676,7 +5444,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (mesh_owner.owns(p_rid)) { - Mesh *mesh = mesh_owner.getornull(p_rid); mesh->instance_remove_deps(); @@ -5699,7 +5466,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (multimesh_owner.owns(p_rid)) { - MultiMesh *multimesh = multimesh_owner.getornull(p_rid); multimesh->instance_remove_deps(); @@ -5727,7 +5493,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (light_owner.owns(p_rid)) { - Light *light = light_owner.getornull(p_rid); light->instance_remove_deps(); @@ -5736,7 +5501,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (reflection_probe_owner.owns(p_rid)) { - // delete the texture ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_rid); reflection_probe->instance_remove_deps(); @@ -5746,7 +5510,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (lightmap_capture_data_owner.owns(p_rid)) { - // delete the texture LightmapCapture *lightmap_capture = lightmap_capture_data_owner.getornull(p_rid); lightmap_capture->instance_remove_deps(); @@ -5756,7 +5519,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (canvas_occluder_owner.owns(p_rid)) { - CanvasOccluder *co = canvas_occluder_owner.getornull(p_rid); if (co->index_id) glDeleteBuffers(1, &co->index_id); @@ -5769,7 +5531,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { return true; } else if (canvas_light_shadow_owner.owns(p_rid)) { - CanvasLightShadow *cls = canvas_light_shadow_owner.getornull(p_rid); glDeleteFramebuffers(1, &cls->fbo); glDeleteRenderbuffers(1, &cls->depth); @@ -5784,7 +5545,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) { } bool RasterizerStorageGLES2::has_os_feature(const String &p_feature) const { - if (p_feature == "pvrtc") return config.pvrtc_supported; @@ -5803,12 +5563,10 @@ void RasterizerStorageGLES2::set_debug_generate_wireframes(bool p_generate) { } void RasterizerStorageGLES2::render_info_begin_capture() { - info.snap = info.render; } void RasterizerStorageGLES2::render_info_end_capture() { - info.snap.object_count = info.render.object_count - info.snap.object_count; info.snap.draw_call_count = info.render.draw_call_count - info.snap.draw_call_count; info.snap.material_switch_count = info.render.material_switch_count - info.snap.material_switch_count; @@ -5818,7 +5576,6 @@ void RasterizerStorageGLES2::render_info_end_capture() { } int RasterizerStorageGLES2::get_captured_render_info(RS::RenderInfo p_info) { - switch (p_info) { case RS::INFO_OBJECTS_IN_FRAME: { return info.snap.object_count; @@ -5872,12 +5629,10 @@ int RasterizerStorageGLES2::get_render_info(RS::RenderInfo p_info) { } String RasterizerStorageGLES2::get_video_adapter_name() const { - return (const char *)glGetString(GL_RENDERER); } String RasterizerStorageGLES2::get_video_adapter_vendor() const { - return (const char *)glGetString(GL_VENDOR); } @@ -5885,7 +5640,6 @@ void RasterizerStorageGLES2::initialize() { RasterizerStorageGLES2::system_fbo = 0; { - const GLubyte *extension_string = glGetString(GL_EXTENSIONS); Vector<String> extensions = String((const char *)extension_string).split(" "); @@ -6236,7 +5990,6 @@ void RasterizerStorageGLES2::initialize() { } { - glGenFramebuffers(1, &resources.mipmap_blur_fbo); glGenTextures(1, &resources.mipmap_blur_color); } diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index 29651936fb..15761e4efd 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -57,7 +57,6 @@ public: static GLuint system_fbo; struct Config { - bool shrink_textures_x2; bool use_fast_texture_filter; bool use_skeleton_software; @@ -106,7 +105,6 @@ public: } config; struct Resources { - GLuint white_tex; GLuint black_tex; GLuint normal_tex; @@ -129,7 +127,6 @@ public: } resources; mutable struct Shaders { - ShaderCompilerGLES2 compiler; CopyShaderGLES2 copy; @@ -142,7 +139,6 @@ public: } shaders; struct Info { - uint64_t texture_mem; uint64_t vertex_mem; @@ -183,10 +179,8 @@ public: SelfList<RasterizerScene::InstanceBase>::List instance_list; _FORCE_INLINE_ void instance_change_notify(bool p_aabb, bool p_materials) { - SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first(); while (instances) { - instances->self()->base_changed(p_aabb, p_materials); instances = instances->next(); } @@ -210,7 +204,6 @@ public: }; struct Geometry : public Instantiable { - enum Type { GEOMETRY_INVALID, GEOMETRY_SURFACE, @@ -240,7 +233,6 @@ public: struct RenderTarget; struct Texture { - Texture *proxy; Set<Texture *> proxy_owners; @@ -383,7 +375,6 @@ public: /* SKY API */ struct Sky { - RID panorama; GLuint radiance; int radiance_size; @@ -399,7 +390,6 @@ public: struct Material; struct Shader { - RID self; RS::ShaderMode mode; @@ -429,7 +419,6 @@ public: uint64_t last_pass; struct CanvasItem { - enum BlendMode { BLEND_MODE_MIX, BLEND_MODE_ADD, @@ -455,7 +444,6 @@ public: } canvas_item; struct Spatial { - enum BlendMode { BLEND_MODE_MIX, BLEND_MODE_ADD, @@ -499,7 +487,6 @@ public: } spatial; struct Particles { - } particles; bool uses_vertex_time; @@ -507,7 +494,6 @@ public: Shader() : dirty_list(this) { - shader = nullptr; valid = false; custom_code_id = 0; @@ -536,7 +522,6 @@ public: /* COMMON MATERIAL API */ struct Material { - Shader *shader; Map<StringName, Variant> params; SelfList<Material> list; @@ -605,7 +590,6 @@ public: struct Mesh; struct Surface : public Geometry { - struct Attrib { bool enabled; bool integer; @@ -669,7 +653,6 @@ public: struct MultiMesh; struct Mesh : public GeometryOwner { - bool active; Vector<Surface *> surfaces; @@ -740,7 +723,6 @@ public: /* MULTIMESH API */ struct MultiMesh : public GeometryOwner { - RID mesh; int size; @@ -814,7 +796,6 @@ public: /* IMMEDIATE API */ struct Immediate : public Geometry { - struct Chunk { RID texture; RS::PrimitiveType primitive; @@ -862,7 +843,6 @@ public: /* SKELETON API */ struct Skeleton { - bool use_2d; int size; @@ -972,7 +952,6 @@ public: /* PROBE API */ struct ReflectionProbe : Instantiable { - RS::ReflectionProbeUpdateMode update_mode; float intensity; Color interior_ambient; @@ -1062,7 +1041,6 @@ public: /* LIGHTMAP */ struct LightmapCapture : public Instantiable { - Vector<LightmapCaptureOctree> octree; AABB bounds; Transform cell_xform; @@ -1165,7 +1143,6 @@ public: Effect copy_screen_effect; struct MipMaps { - struct Size { GLuint fbo; GLuint color; @@ -1252,7 +1229,6 @@ public: /* CANVAS SHADOW */ struct CanvasLightShadow { - int size; int height; GLuint fbo; @@ -1267,7 +1243,6 @@ public: /* LIGHT SHADOW MAPPING */ struct CanvasOccluder { - GLuint vertex_id; // 0 means, unconfigured GLuint index_id; // 0 means, unconfigured Vector<Vector2> lines; @@ -1284,7 +1259,6 @@ public: virtual bool free(RID p_rid); struct Frame { - RenderTarget *current_rt; bool clear_request; diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index f6a764c26c..9b57f417cb 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -38,7 +38,6 @@ #define SL ShaderLanguage static String _mktab(int p_level) { - String tb; for (int i = 0; i < p_level; i++) { tb += "\t"; @@ -48,12 +47,10 @@ static String _mktab(int p_level) { } static String _typestr(SL::DataType p_type) { - return ShaderLanguage::get_datatype_name(p_type); } static String _prestr(SL::DataPrecision p_pres) { - switch (p_pres) { case SL::PRECISION_LOWP: return "lowp "; @@ -68,7 +65,6 @@ static String _prestr(SL::DataPrecision p_pres) { } static String _qualstr(SL::ArgumentQualifier p_qual) { - switch (p_qual) { case SL::ARGUMENT_QUALIFIER_IN: return "in "; @@ -81,18 +77,15 @@ static String _qualstr(SL::ArgumentQualifier p_qual) { } static String _opstr(SL::Operator p_op) { - return SL::get_operator_text(p_op); } static String _mkid(const String &p_id) { - String id = "m_" + p_id.replace("__", "_dus_"); return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl } static String f2sp0(float p_float) { - String num = rtoss(p_float); if (num.find(".") == -1 && num.find("e") == -1) { num += ".0"; @@ -101,14 +94,12 @@ static String f2sp0(float p_float) { } static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) { - switch (p_type) { case SL::TYPE_BOOL: return p_values[0].boolean ? "true" : "false"; case SL::TYPE_BVEC2: case SL::TYPE_BVEC3: case SL::TYPE_BVEC4: { - StringBuffer<> text; text += "bvec"; @@ -131,7 +122,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo case SL::TYPE_UVEC2: case SL::TYPE_UVEC3: case SL::TYPE_UVEC4: { - StringBuffer<> text; text += "ivec"; @@ -154,7 +144,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo case SL::TYPE_IVEC2: case SL::TYPE_IVEC3: case SL::TYPE_IVEC4: { - StringBuffer<> text; text += "ivec"; @@ -176,7 +165,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo case SL::TYPE_VEC2: case SL::TYPE_VEC3: case SL::TYPE_VEC4: { - StringBuffer<> text; text += "vec"; @@ -196,7 +184,6 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo case SL::TYPE_MAT2: case SL::TYPE_MAT3: case SL::TYPE_MAT4: { - StringBuffer<> text; text += "mat"; @@ -231,7 +218,6 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri ERR_FAIL_COND(fidx == -1); for (Set<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) { - if (r_added.has(E->get())) { continue; } @@ -277,19 +263,14 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri } String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning) { - StringBuilder code; switch (p_node->type) { - case SL::Node::TYPE_SHADER: { - SL::ShaderNode *snode = (SL::ShaderNode *)p_node; for (int i = 0; i < snode->render_modes.size(); i++) { - if (p_default_actions.render_mode_defines.has(snode->render_modes[i]) && !used_rmode_defines.has(snode->render_modes[i])) { - r_gen_code.custom_defines.push_back(p_default_actions.render_mode_defines[snode->render_modes[i]].utf8()); used_rmode_defines.insert(snode->render_modes[i]); } @@ -326,7 +307,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener // structs for (int i = 0; i < snode->vstructs.size(); i++) { - SL::StructNode *st = snode->vstructs[i].shader_struct; String struct_code; @@ -393,7 +373,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener // varyings for (Map<StringName, SL::ShaderNode::Varying>::Element *E = snode->varyings.front(); E; E = E->next()) { - StringBuffer<> varying_code; varying_code += "varying "; @@ -448,7 +427,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener Set<StringName> added_fragment; for (int i = 0; i < snode->functions.size(); i++) { - SL::FunctionNode *fnode = snode->functions[i].function; current_func_name = fnode->name; @@ -472,14 +450,11 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener } break; case SL::Node::TYPE_STRUCT: { - } break; case SL::Node::TYPE_FUNCTION: { - } break; case SL::Node::TYPE_BLOCK: { - SL::BlockNode *bnode = (SL::BlockNode *)p_node; if (!bnode->single_statement) { @@ -520,7 +495,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener } for (int i = 0; i < var_dec_node->declarations.size(); i++) { - if (i > 0) { declaration += ","; } @@ -597,7 +571,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener code += ")"; } break; case SL::Node::TYPE_ARRAY_DECLARATION: { - SL::ArrayDeclarationNode *arr_dec_node = (SL::ArrayDeclarationNode *)p_node; StringBuffer<> declaration; @@ -608,7 +581,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener declaration += _typestr(arr_dec_node->datatype); } for (int i = 0; i < arr_dec_node->declarations.size(); i++) { - if (i > 0) { declaration += ","; } @@ -736,7 +708,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener } else if (op_node->op == SL::OP_CONSTRUCT) { code += var_node->name; } else { - if (var_node->name == "texture") { // emit texture call @@ -764,9 +735,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener } } else if (var_node->name == "mix") { - switch (op_node->arguments[3]->get_datatype()) { - case SL::TYPE_BVEC2: { code += "select2"; } break; @@ -783,7 +752,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener case SL::TYPE_VEC3: case SL::TYPE_VEC4: case SL::TYPE_FLOAT: { - code += "mix"; } break; @@ -846,7 +814,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener } break; case SL::OP_MOD: { - code += "mod(float("; code += _dump_node_code(op_node->arguments[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning); code += "), float("; @@ -870,7 +837,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener SL::ControlFlowNode *cf_node = (SL::ControlFlowNode *)p_node; if (cf_node->flow_op == SL::FLOW_OP_IF) { - code += _mktab(p_level); code += "if ("; code += _dump_node_code(cf_node->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning); @@ -897,7 +863,6 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener code += ")\n"; code += _dump_node_code(cf_node->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning); } else if (cf_node->flow_op == SL::FLOW_OP_FOR) { - code += _mktab(p_level); code += "for ("; code += _dump_node_code(cf_node->blocks[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning); @@ -948,11 +913,9 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener } Error ShaderCompilerGLES2::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) { - Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types()); if (err != OK) { - Vector<String> shader = p_code.split("\n"); for (int i = 0; i < shader.size(); i++) { print_line(itos(i + 1) + " " + shader[i]); @@ -985,7 +948,6 @@ Error ShaderCompilerGLES2::compile(RS::ShaderMode p_mode, const String &p_code, } ShaderCompilerGLES2::ShaderCompilerGLES2() { - /** CANVAS ITEM SHADER **/ actions[RS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy"; diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h index 757dcdd4f2..369bf7877b 100644 --- a/drivers/gles2/shader_compiler_gles2.h +++ b/drivers/gles2/shader_compiler_gles2.h @@ -40,7 +40,6 @@ class ShaderCompilerGLES2 { public: struct IdentifierActions { - Map<StringName, Pair<int *, int>> render_mode_values; Map<StringName, bool *> render_mode_flags; Map<StringName, bool *> usage_flag_pointers; @@ -50,7 +49,6 @@ public: }; struct GeneratedCode { - Vector<CharString> custom_defines; Vector<StringName> uniforms; Vector<StringName> texture_uniforms; @@ -71,7 +69,6 @@ private: ShaderLanguage parser; struct DefaultIdentifierActions { - Map<StringName, String> renames; Map<StringName, String> render_mode_defines; Map<StringName, String> usage_defines; diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp index 2c335c6c5a..48b98435c4 100644 --- a/drivers/gles2/shader_gles2.cpp +++ b/drivers/gles2/shader_gles2.cpp @@ -70,14 +70,12 @@ ShaderGLES2 *ShaderGLES2::active = nullptr; #endif GLint ShaderGLES2::get_uniform_location(int p_index) const { - ERR_FAIL_COND_V(!version, -1); return version->uniform_location[p_index]; } bool ShaderGLES2::bind() { - if (active != this || !version || new_conditional_version.key != conditional_version.key) { conditional_version = new_conditional_version; version = get_current_version(); @@ -110,7 +108,6 @@ void ShaderGLES2::unbind() { } static void _display_error_with_code(const String &p_error, const Vector<const char *> &p_code) { - int line = 1; String total_code; @@ -121,7 +118,6 @@ static void _display_error_with_code(const String &p_error, const Vector<const c Vector<String> lines = String(total_code).split("\n"); for (int j = 0; j < lines.size(); j++) { - print_line(itos(line) + ": " + lines[j]); line++; } @@ -130,13 +126,11 @@ static void _display_error_with_code(const String &p_error, const Vector<const c } static String _mkid(const String &p_id) { - String id = "m_" + p_id; return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl } ShaderGLES2::Version *ShaderGLES2::get_current_version() { - Version *_v = version_map.getptr(conditional_version); if (_v) { @@ -457,7 +451,6 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { } GLint ShaderGLES2::get_uniform_location(const String &p_name) const { - ERR_FAIL_COND_V(!version, -1); return glGetUniformLocation(version->id, p_name.ascii().get_data()); } @@ -475,7 +468,6 @@ void ShaderGLES2::setup( const char *p_fragment_code, int p_vertex_code_start, int p_fragment_code_start) { - ERR_FAIL_COND(version); conditional_version.key = 0; @@ -532,7 +524,6 @@ void ShaderGLES2::setup( String code2; if (cpos != -1) { - fragment_code1 = code.substr(0, cpos).ascii(); code2 = code.substr(cpos + light_code_tag.length(), code.length()); } else { @@ -617,7 +608,6 @@ void ShaderGLES2::set_custom_shader(uint32_t p_code_id) { } void ShaderGLES2::free_custom_shader(uint32_t p_code_id) { - ERR_FAIL_COND(!custom_code_map.has(p_code_id)); if (conditional_version.code_version == p_code_id) { conditional_version.code_version = 0; //do not keep using a version that is going away @@ -658,7 +648,6 @@ void ShaderGLES2::use_material(void *p_material) { // bind uniforms for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = material->shader->uniforms.front(); E; E = E->next()) { - if (E->get().texture_order >= 0) continue; // this is a texture, doesn't go here @@ -673,7 +662,6 @@ void ShaderGLES2::use_material(void *p_material) { if (V) { switch (E->get().type) { case ShaderLanguage::TYPE_BOOL: { - bool boolean = V->get(); glUniform1i(location, boolean ? 1 : 0); } break; @@ -684,7 +672,6 @@ void ShaderGLES2::use_material(void *p_material) { } break; case ShaderLanguage::TYPE_BVEC3: { - int flags = V->get(); glUniform3i(location, (flags & 1) ? 1 : 0, (flags & 2) ? 1 : 0, (flags & 4) ? 1 : 0); @@ -704,7 +691,6 @@ void ShaderGLES2::use_material(void *p_material) { case ShaderLanguage::TYPE_IVEC2: case ShaderLanguage::TYPE_UVEC2: { - Array r = V->get(); const int count = 2; if (r.size() == count) { @@ -776,7 +762,6 @@ void ShaderGLES2::use_material(void *p_material) { } break; case ShaderLanguage::TYPE_MAT2: { - Transform2D tr = V->get(); GLfloat matrix[4] = { /* build a 16x16 matrix */ @@ -809,7 +794,6 @@ void ShaderGLES2::use_material(void *p_material) { } break; case ShaderLanguage::TYPE_MAT4: { - Transform2D tr = V->get(); GLfloat matrix[16] = { /* build a 16x16 matrix */ tr.elements[0][0], @@ -938,19 +922,15 @@ void ShaderGLES2::use_material(void *p_material) { } break; case ShaderLanguage::TYPE_SAMPLER2D: { - } break; case ShaderLanguage::TYPE_ISAMPLER2D: { - } break; case ShaderLanguage::TYPE_USAMPLER2D: { - } break; case ShaderLanguage::TYPE_SAMPLERCUBE: { - } break; case ShaderLanguage::TYPE_SAMPLER2DARRAY: @@ -1057,19 +1037,15 @@ void ShaderGLES2::use_material(void *p_material) { } break; case ShaderLanguage::TYPE_SAMPLER2D: { - } break; case ShaderLanguage::TYPE_ISAMPLER2D: { - } break; case ShaderLanguage::TYPE_USAMPLER2D: { - } break; case ShaderLanguage::TYPE_SAMPLERCUBE: { - } break; case ShaderLanguage::TYPE_SAMPLER2DARRAY: diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h index d20d5bc585..3096c1e258 100644 --- a/drivers/gles2/shader_gles2.h +++ b/drivers/gles2/shader_gles2.h @@ -53,20 +53,17 @@ class RasterizerStorageGLES2; class ShaderGLES2 { protected: struct Enum { - uint64_t mask; uint64_t shift; const char *defines[16]; }; struct EnumValue { - uint64_t set_mask; uint64_t clear_mask; }; struct AttributePair { - const char *name; int index; }; @@ -77,7 +74,6 @@ protected: }; struct TexUnitPair { - const char *name; int index; }; @@ -94,7 +90,6 @@ private: int attribute_pair_count; struct CustomCode { - String vertex; String vertex_globals; String fragment; @@ -108,7 +103,6 @@ private: }; struct Version { - GLuint id; GLuint vert_id; GLuint frag_id; @@ -130,7 +124,6 @@ private: Version *version; union VersionKey { - struct { uint32_t version; uint32_t code_version; @@ -141,7 +134,6 @@ private: }; struct VersionKeyHash { - static _FORCE_INLINE_ uint32_t hash(const VersionKey &p_key) { return HashMapHasherDefault::hash(p_key.key); } }; @@ -252,14 +244,12 @@ public: // called a lot, made inline int ShaderGLES2::_get_uniform(int p_which) const { - ERR_FAIL_INDEX_V(p_which, uniform_count, -1); ERR_FAIL_COND_V(!version, -1); return version->uniform_location[p_which]; } void ShaderGLES2::_set_conditional(int p_which, bool p_value) { - ERR_FAIL_INDEX(p_which, conditional_count); if (p_value) new_conditional_version.version |= (1 << p_which); diff --git a/drivers/gles2/shaders/blend_shape.glsl b/drivers/gles2/shaders/blend_shape.glsl index 0d0b3e24e4..7a0a7ebe99 100644 --- a/drivers/gles2/shaders/blend_shape.glsl +++ b/drivers/gles2/shaders/blend_shape.glsl @@ -110,7 +110,6 @@ out vec4 weight_out; //tfb:ENABLE_SKELETON uniform float blend_amount; void main() { - #ifdef ENABLE_BLEND vertex_out = vertex_attrib_blend + vertex_attrib * blend_amount; diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl index 3b685b3f0b..1fadf44d97 100644 --- a/drivers/gles2/shaders/canvas.glsl +++ b/drivers/gles2/shaders/canvas.glsl @@ -111,7 +111,6 @@ vec2 select(vec2 a, vec2 b, bvec2 c) { } void main() { - vec4 color = color_attrib; vec2 uv; @@ -186,7 +185,6 @@ VERTEX_SHADER_CODE // look up transform from the "pose texture" if (bone_weights != vec4(0.0)) { - highp mat4 bone_transform = mat4(0.0); for (int i = 0; i < 4; i++) { @@ -367,7 +365,6 @@ LIGHT_SHADER_CODE } void main() { - vec4 color = color_interp; vec2 uv = uv_interp; #ifdef USE_FORCE_REPEAT @@ -499,11 +496,9 @@ FRAGMENT_SHADER_CODE point = -shadow_vec; sh = 0.5 + (1.0 / 8.0); } else if (angle_to_light > 0.0) { - point = vec2(shadow_vec.y, -shadow_vec.x); sh = 0.25 + (1.0 / 8.0); } else { - point = vec2(-shadow_vec.y, shadow_vec.x); sh = 0.75 + (1.0 / 8.0); } diff --git a/drivers/gles2/shaders/canvas_shadow.glsl b/drivers/gles2/shaders/canvas_shadow.glsl index 7a5ba4f571..2abcd5e67c 100644 --- a/drivers/gles2/shaders/canvas_shadow.glsl +++ b/drivers/gles2/shaders/canvas_shadow.glsl @@ -21,7 +21,6 @@ uniform highp float distance_norm; varying highp vec4 position_interp; void main() { - gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex, 1.0))); position_interp = gl_Position; } @@ -47,7 +46,6 @@ varying highp vec4 position_interp; /* clang-format on */ void main() { - highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias #ifdef USE_RGBA_SHADOWS diff --git a/drivers/gles2/shaders/copy.glsl b/drivers/gles2/shaders/copy.glsl index aa967115da..e833722ac3 100644 --- a/drivers/gles2/shaders/copy.glsl +++ b/drivers/gles2/shaders/copy.glsl @@ -40,7 +40,6 @@ uniform highp mat4 display_transform; #endif void main() { - #if defined(USE_CUBEMAP) || defined(USE_PANORAMA) cube_interp = cube_in; #elif defined(USE_ASYM_PANO) @@ -115,7 +114,6 @@ uniform float custom_alpha; uniform highp mat4 sky_transform; vec4 texturePanorama(sampler2D pano, vec3 normal) { - vec2 st = vec2( atan(normal.x, normal.z), acos(normal.y)); @@ -131,7 +129,6 @@ vec4 texturePanorama(sampler2D pano, vec3 normal) { #endif void main() { - #ifdef USE_PANORAMA vec3 cube_normal = normalize(cube_interp); diff --git a/drivers/gles2/shaders/cube_to_dp.glsl b/drivers/gles2/shaders/cube_to_dp.glsl index 769908c3b4..1612ec3d5a 100644 --- a/drivers/gles2/shaders/cube_to_dp.glsl +++ b/drivers/gles2/shaders/cube_to_dp.glsl @@ -17,7 +17,6 @@ attribute vec2 uv_in; // attrib:4 varying vec2 uv_interp; void main() { - uv_interp = uv_in; gl_Position = vertex_attrib; } @@ -49,7 +48,6 @@ uniform highp float z_near; uniform highp float bias; void main() { - highp vec3 normal = vec3(uv_interp * 2.0 - 1.0, 0.0); /* if (z_flip) { diff --git a/drivers/gles2/shaders/cubemap_filter.glsl b/drivers/gles2/shaders/cubemap_filter.glsl index db3d8b3a1b..f5c91cc707 100644 --- a/drivers/gles2/shaders/cubemap_filter.glsl +++ b/drivers/gles2/shaders/cubemap_filter.glsl @@ -17,7 +17,6 @@ attribute highp vec2 uv; // attrib:4 varying highp vec2 uv_interp; void main() { - uv_interp = uv; gl_Position = vec4(vertex, 0, 1); } @@ -87,7 +86,6 @@ uniform sampler2D radical_inverse_vdc_cache; // texunit:1 #ifdef USE_SOURCE_PANORAMA vec4 texturePanorama(sampler2D pano, vec3 normal) { - vec2 st = vec2( atan(normal.x, normal.z), acos(normal.y)); @@ -179,7 +177,6 @@ vec2 Hammersley(int i, int N) { uniform bool z_flip; void main() { - vec3 color = vec3(0.0); vec2 uv = (uv_interp * 2.0) - 1.0; @@ -200,7 +197,6 @@ void main() { vec4 sum = vec4(0.0); for (int sample_num = 0; sample_num < SAMPLE_COUNT; sample_num++) { - vec2 xi = Hammersley(sample_num, SAMPLE_COUNT); vec3 H = ImportanceSampleGGX(xi, roughness, N); diff --git a/drivers/gles2/shaders/effect_blur.glsl b/drivers/gles2/shaders/effect_blur.glsl index b28d78a6ca..7b607dd76a 100644 --- a/drivers/gles2/shaders/effect_blur.glsl +++ b/drivers/gles2/shaders/effect_blur.glsl @@ -23,7 +23,6 @@ uniform vec4 blur_section; #endif void main() { - uv_interp = uv_in; gl_Position = vec4(vertex_attrib, 0.0, 1.0); #ifdef USE_BLUR_SECTION @@ -127,7 +126,6 @@ uniform float camera_z_far; uniform float camera_z_near; void main() { - #ifdef GLOW_GAUSSIAN_HORIZONTAL vec2 pix_size = pixel_size; pix_size *= 0.5; //reading from larger buffer, so use more samples @@ -228,7 +226,6 @@ void main() { float k_accum = 0.0; for (int i = 0; i < dof_kernel_size; i++) { - int int_ofs = i - dof_kernel_from; vec2 tap_uv = uv_interp + dof_dir * float(int_ofs) * amount * dof_radius; @@ -265,7 +262,6 @@ void main() { float max_accum = 0.0; for (int i = 0; i < dof_kernel_size; i++) { - int int_ofs = i - dof_kernel_from; vec2 tap_uv = uv_interp + dof_dir * float(int_ofs) * dof_radius; float ofs_influence = max(0.0, 1.0 - abs(float(int_ofs)) / float(dof_kernel_from)); diff --git a/drivers/gles2/shaders/exposure.glsl b/drivers/gles2/shaders/exposure.glsl index 759adcda06..c20812bfa3 100644 --- a/drivers/gles2/shaders/exposure.glsl +++ b/drivers/gles2/shaders/exposure.glsl @@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib; /* clang-format on */ void main() { - gl_Position = vertex_attrib; } @@ -34,7 +33,6 @@ uniform highp float max_luminance; layout(location = 0) out highp float exposure; void main() { - #ifdef EXPOSURE_BEGIN ivec2 src_pos = ivec2(gl_FragCoord.xy) * source_render_size / target_size; diff --git a/drivers/gles2/shaders/lens_distorted.glsl b/drivers/gles2/shaders/lens_distorted.glsl index f4ff80ba9a..d568006ccc 100644 --- a/drivers/gles2/shaders/lens_distorted.glsl +++ b/drivers/gles2/shaders/lens_distorted.glsl @@ -19,7 +19,6 @@ uniform vec2 scale; varying vec2 uv_interp; void main() { - uv_interp = vertex.xy * 2.0 - 1.0; vec2 v = vertex.xy * scale + offset; diff --git a/drivers/gles2/shaders/particles.glsl b/drivers/gles2/shaders/particles.glsl index 5974050fc1..1575db701f 100644 --- a/drivers/gles2/shaders/particles.glsl +++ b/drivers/gles2/shaders/particles.glsl @@ -10,7 +10,6 @@ layout(location = 4) in highp vec4 xform_2; layout(location = 5) in highp vec4 xform_3; struct Attractor { - vec3 pos; vec3 dir; float radius; @@ -64,7 +63,6 @@ VERTEX_SHADER_GLOBALS /* clang-format on */ uint hash(uint x) { - x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b); x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b); x = (x >> uint(16)) ^ x; @@ -72,7 +70,6 @@ uint hash(uint x) { } void main() { - #ifdef PARTICLES_COPY out_color = color; @@ -183,10 +180,8 @@ VERTEX_SHADER_CODE #if !defined(DISABLE_FORCE) if (false) { - vec3 force = vec3(0.0); for (int i = 0; i < attractor_count; i++) { - vec3 rel_vec = xform[3].xyz - attractors[i].pos; float dist = length(rel_vec); if (attractors[i].radius < dist) @@ -214,7 +209,6 @@ VERTEX_SHADER_CODE #if !defined(DISABLE_VELOCITY) if (true) { - xform[3].xyz += out_velocity_active.xyz * local_delta; } #endif diff --git a/drivers/gles2/shaders/resolve.glsl b/drivers/gles2/shaders/resolve.glsl index 5c6f5d6561..071cb37a99 100644 --- a/drivers/gles2/shaders/resolve.glsl +++ b/drivers/gles2/shaders/resolve.glsl @@ -8,7 +8,6 @@ layout(location = 4) in vec2 uv_in; out vec2 uv_interp; void main() { - uv_interp = uv_in; gl_Position = vertex_attrib; } @@ -32,7 +31,6 @@ in vec2 uv2_interp; layout(location = 0) out vec4 frag_color; void main() { - vec4 specular = texture(source_specular, uv_interp); #ifdef USE_SSR diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index b720c71cec..d658ccd5cd 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -194,7 +194,6 @@ void light_compute( vec3 light_color, vec3 attenuation, float roughness) { - //this makes lights behave closer to linear, but then addition of lights looks bad //better left disabled @@ -249,7 +248,6 @@ void light_compute( diffuse_interp += light_color * diffuse_brdf_NL * attenuation; if (roughness > 0.0) { - // D float specular_brdf_NL = 0.0; @@ -325,7 +323,6 @@ uniform mediump float fog_height_curve; #endif //fog void main() { - highp vec4 vertex = vertex_attrib; mat4 world_matrix = world_transform; @@ -394,7 +391,6 @@ void main() { #else // look up transform from the "pose texture" { - for (int i = 0; i < 4; i++) { ivec2 tex_ofs = ivec2(int(bone_ids[i]) * 3, 0); @@ -512,7 +508,6 @@ VERTEX_SHADER_CODE float normalized_distance = light_length / light_range; if (normalized_distance < 1.0) { - float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation); vec3 attenuation = vec3(omni_attenuation); @@ -532,7 +527,6 @@ VERTEX_SHADER_CODE float normalized_distance = light_length / light_range; if (normalized_distance < 1.0) { - float spot_attenuation = pow(1.0 - normalized_distance, light_attenuation); vec3 spot_dir = light_direction; @@ -541,7 +535,6 @@ VERTEX_SHADER_CODE float angle = dot(-normalize(light_rel_vec), spot_dir); if (angle > spot_cutoff) { - float scos = max(angle, spot_cutoff); float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_cutoff)); @@ -645,7 +638,6 @@ VERTEX_SHADER_CODE #ifdef FOG_DEPTH_ENABLED { - float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex)); fog_amount = pow(fog_z, fog_depth_curve) * fog_color_base.a; @@ -1157,7 +1149,6 @@ void light_compute( inout vec3 diffuse_light, inout vec3 specular_light, inout float alpha) { - //this makes lights behave closer to linear, but then addition of lights looks bad //better left disabled @@ -1381,7 +1372,6 @@ LIGHT_SHADER_CODE #define SAMPLE_SHADOW_TEXEL_PROJ(p_shadow, p_pos) step(p_pos.z, SHADOW_DEPTH(texture2DProj(p_shadow, p_pos))) float sample_shadow(highp sampler2D shadow, highp vec4 spos) { - #ifdef SHADOW_MODE_PCF_13 spos.xyz /= spos.w; @@ -1458,7 +1448,6 @@ uniform mediump float fog_height_curve; #endif //fog void main() { - #ifdef RENDER_DEPTH_DUAL_PARABOLOID if (dp_clip > 0.0) @@ -1653,7 +1642,6 @@ FRAGMENT_SHADER_CODE // environment BRDF approximation { - #if defined(DIFFUSE_TOON) //simplify for toon, as specular_light *= specular * metallic * albedo * 2.0; @@ -1732,7 +1720,6 @@ FRAGMENT_SHADER_CODE float normalized_distance = light_length / light_range; if (normalized_distance < 1.0) { - float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation); light_att = vec3(omni_attenuation); @@ -1829,7 +1816,6 @@ FRAGMENT_SHADER_CODE } } else { if (depth_z < light_split_offsets.z) { - shadow_att = shadow3; #if defined(LIGHT_USE_PSSM_BLEND) @@ -1838,7 +1824,6 @@ FRAGMENT_SHADER_CODE #endif } else { - shadow_att = shadow4; pssm_fade = smoothstep(light_split_offsets.z, light_split_offsets.w, depth_z); @@ -1881,7 +1866,6 @@ FRAGMENT_SHADER_CODE pssm_blend = smoothstep(0.0, light_split_offsets.x, depth_z); #endif } else { - shadow_att = shadow2; pssm_fade = smoothstep(light_split_offsets.x, light_split_offsets.y, depth_z); #ifdef LIGHT_USE_PSSM_BLEND @@ -1945,7 +1929,6 @@ FRAGMENT_SHADER_CODE } } else { if (depth_z < light_split_offsets.z) { - pssm_coord = shadow_coord3; #if defined(LIGHT_USE_PSSM_BLEND) @@ -1954,7 +1937,6 @@ FRAGMENT_SHADER_CODE #endif } else { - pssm_coord = shadow_coord4; pssm_fade = smoothstep(light_split_offsets.z, light_split_offsets.w, depth_z); @@ -1968,7 +1950,6 @@ FRAGMENT_SHADER_CODE #ifdef LIGHT_USE_PSSM2 if (depth_z < light_split_offsets.x) { - pssm_coord = shadow_coord; #ifdef LIGHT_USE_PSSM_BLEND @@ -1976,7 +1957,6 @@ FRAGMENT_SHADER_CODE pssm_blend = smoothstep(0.0, light_split_offsets.x, depth_z); #endif } else { - pssm_coord = shadow_coord2; pssm_fade = smoothstep(light_split_offsets.x, light_split_offsets.y, depth_z); #ifdef LIGHT_USE_PSSM_BLEND @@ -2165,7 +2145,6 @@ FRAGMENT_SHADER_CODE #ifdef FOG_DEPTH_ENABLED { - float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex)); fog_amount = pow(fog_z, fog_depth_curve) * fog_color_base.a; diff --git a/drivers/gles2/shaders/screen_space_reflection.glsl b/drivers/gles2/shaders/screen_space_reflection.glsl index a11da10b61..6b5b7c885c 100644 --- a/drivers/gles2/shaders/screen_space_reflection.glsl +++ b/drivers/gles2/shaders/screen_space_reflection.glsl @@ -9,7 +9,6 @@ out vec2 uv_interp; out vec2 pos_interp; void main() { - uv_interp = uv_in; gl_Position = vertex_attrib; pos_interp.xy = gl_Position.xy; @@ -55,7 +54,6 @@ vec2 view_to_screen(vec3 view_pos, out float w) { #define M_PI 3.14159265359 void main() { - vec4 diffuse = texture(source_diffuse, uv_interp); vec4 normal_roughness = texture(source_normal_roughness, uv_interp); @@ -142,7 +140,6 @@ void main() { float steps_taken = 0.0; for (int i = 0; i < num_steps; i++) { - pos += line_advance; z += z_advance; w += w_advance; @@ -174,7 +171,6 @@ void main() { } if (found) { - float margin_blend = 1.0; vec2 margin = vec2((viewport_size.x + viewport_size.y) * 0.5 * 0.05); //make a uniform margin @@ -218,7 +214,6 @@ void main() { final_color = vec4(0.0); for (int i = 0; i < 7; i++) { - float op_len = 2.0 * tan(cone_angle) * cone_len; //opposite side of iso triangle float radius; { diff --git a/drivers/gles2/shaders/ssao.glsl b/drivers/gles2/shaders/ssao.glsl index 82eea8f274..0fd29e8dcc 100644 --- a/drivers/gles2/shaders/ssao.glsl +++ b/drivers/gles2/shaders/ssao.glsl @@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib; /* clang-format on */ void main() { - gl_Position = vertex_attrib; gl_Position.z = 1.0; } @@ -207,7 +206,6 @@ float sampleAO(in ivec2 ssC, in vec3 C, in vec3 n_C, in float ssDiskRadius, in f } void main() { - // Pixel being shaded ivec2 ssC = ivec2(gl_FragCoord.xy); diff --git a/drivers/gles2/shaders/ssao_blur.glsl b/drivers/gles2/shaders/ssao_blur.glsl index e4133ad534..f065cd74eb 100644 --- a/drivers/gles2/shaders/ssao_blur.glsl +++ b/drivers/gles2/shaders/ssao_blur.glsl @@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib; /* clang-format on */ void main() { - gl_Position = vertex_attrib; gl_Position.z = 1.0; } @@ -58,7 +57,6 @@ uniform float camera_z_near; uniform ivec2 screen_size; void main() { - ivec2 ssC = ivec2(gl_FragCoord.xy); float depth = texelFetch(source_depth, ssC, 0).r; @@ -91,7 +89,6 @@ void main() { // We already handled the zero case above. This loop should be unrolled and the static branch optimized out, // so the IF statement has no runtime cost if (r != 0) { - ivec2 ppos = ssC + axis * (r * filter_scale); float value = texelFetch(source_ssao, clamp(ppos, ivec2(0), clamp_limit), 0).r; ivec2 rpos = clamp(ppos, ivec2(0), clamp_limit); diff --git a/drivers/gles2/shaders/ssao_minify.glsl b/drivers/gles2/shaders/ssao_minify.glsl index 272f3e236e..f654e00a4f 100644 --- a/drivers/gles2/shaders/ssao_minify.glsl +++ b/drivers/gles2/shaders/ssao_minify.glsl @@ -5,7 +5,6 @@ layout(location = 0) in highp vec4 vertex_attrib; /* clang-format on */ void main() { - gl_Position = vertex_attrib; } @@ -33,7 +32,6 @@ uniform int source_mipmap; layout(location = 0) out mediump uint depth; void main() { - ivec2 ssP = ivec2(gl_FragCoord.xy); // Rotated grid subsampling to avoid XY directional bias or Z precision bias while downsampling. diff --git a/drivers/gles2/shaders/subsurf_scattering.glsl b/drivers/gles2/shaders/subsurf_scattering.glsl index f40fb3a244..d0c34cf1b0 100644 --- a/drivers/gles2/shaders/subsurf_scattering.glsl +++ b/drivers/gles2/shaders/subsurf_scattering.glsl @@ -8,7 +8,6 @@ layout(location = 4) in vec2 uv_in; out vec2 uv_interp; void main() { - uv_interp = uv_in; gl_Position = vertex_attrib; } @@ -102,7 +101,6 @@ uniform sampler2D source_depth; //texunit:2 layout(location = 0) out vec4 frag_color; void main() { - float strength = texture(source_sss, uv_interp).r; strength *= strength; //stored as sqrt @@ -110,7 +108,6 @@ void main() { vec4 base_color = texture(source_diffuse, uv_interp); if (strength > 0.0) { - // Fetch linear depth of current pixel: float depth = texture(source_depth, uv_interp).r * 2.0 - 1.0; #ifdef USE_ORTHOGONAL_PROJECTION |