diff options
Diffstat (limited to 'drivers/gles2/rasterizer_storage_gles2.cpp')
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.cpp | 247 |
1 files changed, 0 insertions, 247 deletions
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); } |