diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 41 | ||||
| -rw-r--r-- | drivers/gles3/storage/light_storage.cpp | 5 | ||||
| -rw-r--r-- | drivers/gles3/storage/material_storage.cpp | 4 | ||||
| -rw-r--r-- | drivers/gles3/storage/mesh_storage.cpp | 4 | ||||
| -rw-r--r-- | drivers/gles3/storage/mesh_storage.h | 2 | ||||
| -rw-r--r-- | drivers/gles3/storage/texture_storage.cpp | 4 | ||||
| -rw-r--r-- | drivers/metal/metal_objects.mm | 6 | ||||
| -rw-r--r-- | drivers/unix/dir_access_unix.cpp | 9 | ||||
| -rw-r--r-- | drivers/vulkan/rendering_device_driver_vulkan.cpp | 9 | ||||
| -rw-r--r-- | drivers/vulkan/rendering_device_driver_vulkan.h | 3 | ||||
| -rw-r--r-- | drivers/windows/file_access_windows.cpp | 50 |
11 files changed, 84 insertions, 53 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 8b6d3e3268..39aad6bfbf 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1363,38 +1363,25 @@ void RasterizerSceneGLES3::_fill_render_list(RenderListType p_render_list, const GeometryInstanceSurface *surf = inst->surface_caches; + float lod_distance = 0.0; + + if (p_render_data->cam_orthogonal) { + lod_distance = 1.0; + } else { + Vector3 aabb_min = inst->transformed_aabb.position; + Vector3 aabb_max = inst->transformed_aabb.position + inst->transformed_aabb.size; + Vector3 camera_position = p_render_data->main_cam_transform.origin; + Vector3 surface_distance = Vector3(0.0, 0.0, 0.0).max(aabb_min - camera_position).max(camera_position - aabb_max); + + lod_distance = surface_distance.length(); + } + while (surf) { // LOD if (p_render_data->screen_mesh_lod_threshold > 0.0 && mesh_storage->mesh_surface_has_lod(surf->surface)) { - float distance = 0.0; - - // Check if camera is NOT inside the mesh AABB. - if (!inst->transformed_aabb.has_point(p_render_data->main_cam_transform.origin)) { - // Get the LOD support points on the mesh AABB. - Vector3 lod_support_min = inst->transformed_aabb.get_support(p_render_data->main_cam_transform.basis.get_column(Vector3::AXIS_Z)); - Vector3 lod_support_max = inst->transformed_aabb.get_support(-p_render_data->main_cam_transform.basis.get_column(Vector3::AXIS_Z)); - - // Get the distances to those points on the AABB from the camera origin. - float distance_min = (float)p_render_data->main_cam_transform.origin.distance_to(lod_support_min); - float distance_max = (float)p_render_data->main_cam_transform.origin.distance_to(lod_support_max); - - if (distance_min * distance_max < 0.0) { - //crossing plane - distance = 0.0; - } else if (distance_min >= 0.0) { - distance = distance_min; - } else if (distance_max <= 0.0) { - distance = -distance_max; - } - } - - if (p_render_data->cam_orthogonal) { - distance = 1.0; - } - uint32_t indices = 0; - surf->lod_index = mesh_storage->mesh_surface_get_lod(surf->surface, inst->lod_model_scale * inst->lod_bias, distance * p_render_data->lod_distance_multiplier, p_render_data->screen_mesh_lod_threshold, indices); + surf->lod_index = mesh_storage->mesh_surface_get_lod(surf->surface, inst->lod_model_scale * inst->lod_bias, lod_distance * p_render_data->lod_distance_multiplier, p_render_data->screen_mesh_lod_threshold, indices); surf->index_count = indices; if (p_render_data->render_info) { diff --git a/drivers/gles3/storage/light_storage.cpp b/drivers/gles3/storage/light_storage.cpp index aab1aadf02..9b976c2206 100644 --- a/drivers/gles3/storage/light_storage.cpp +++ b/drivers/gles3/storage/light_storage.cpp @@ -1521,6 +1521,11 @@ bool LightStorage::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_i uint64_t min_pass = 0; // Pass of the existing one, try to use the least recently used one (LRU fashion). for (int j = 0; j < sc; j++) { + if (sarr[j].owner_is_omni != is_omni) { + // Existing light instance type doesn't match new light instance type skip. + continue; + } + LightInstance *sli = light_instance_owner.get_or_null(sarr[j].owner); if (!sli) { // Found a released light instance. diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index a37eba3b15..7d5af48384 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -348,7 +348,7 @@ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataType type, int p_ } } -_FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, const Vector<ShaderLanguage::ConstantNode::Value> &value, uint8_t *data) { +_FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, const Vector<ShaderLanguage::Scalar> &value, uint8_t *data) { switch (type) { case ShaderLanguage::TYPE_BOOL: { uint32_t *gui = (uint32_t *)data; @@ -572,7 +572,7 @@ void ShaderData::set_default_texture_parameter(const StringName &p_name, RID p_t Variant ShaderData::get_default_parameter(const StringName &p_parameter) const { if (uniforms.has(p_parameter)) { ShaderLanguage::ShaderNode::Uniform uniform = uniforms[p_parameter]; - Vector<ShaderLanguage::ConstantNode::Value> default_value = uniform.default_value; + Vector<ShaderLanguage::Scalar> default_value = uniform.default_value; return ShaderLanguage::constant_value_to_variant(default_value, uniform.type, uniform.array_size, uniform.hint); } return Variant(); diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index de82d74aff..5058554659 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -1769,14 +1769,14 @@ AABB MeshStorage::_multimesh_get_custom_aabb(RID p_multimesh) const { return multimesh->custom_aabb; } -AABB MeshStorage::_multimesh_get_aabb(RID p_multimesh) const { +AABB MeshStorage::_multimesh_get_aabb(RID p_multimesh) { MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh); ERR_FAIL_NULL_V(multimesh, AABB()); if (multimesh->custom_aabb != AABB()) { return multimesh->custom_aabb; } if (multimesh->aabb_dirty) { - const_cast<MeshStorage *>(this)->_update_dirty_multimeshes(); + _update_dirty_multimeshes(); } return multimesh->aabb; } diff --git a/drivers/gles3/storage/mesh_storage.h b/drivers/gles3/storage/mesh_storage.h index a2edbb9c48..31858cd372 100644 --- a/drivers/gles3/storage/mesh_storage.h +++ b/drivers/gles3/storage/mesh_storage.h @@ -510,7 +510,7 @@ public: virtual RID _multimesh_get_mesh(RID p_multimesh) const override; virtual void _multimesh_set_custom_aabb(RID p_multimesh, const AABB &p_aabb) override; virtual AABB _multimesh_get_custom_aabb(RID p_multimesh) const override; - virtual AABB _multimesh_get_aabb(RID p_multimesh) const override; + virtual AABB _multimesh_get_aabb(RID p_multimesh) override; virtual Transform3D _multimesh_instance_get_transform(RID p_multimesh, int p_index) const override; virtual Transform2D _multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const override; diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 36393dde86..54012c20e9 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -1039,7 +1039,7 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const { data.resize(data_size); ERR_FAIL_COND_V(data.is_empty(), Ref<Image>()); - image = Image::create_from_data(texture->width, texture->height, texture->mipmaps > 1, texture->real_format, data); + image = Image::create_from_data(texture->alloc_width, texture->alloc_height, texture->mipmaps > 1, texture->real_format, data); ERR_FAIL_COND_V(image->is_empty(), Ref<Image>()); if (texture->format != texture->real_format) { image->convert(texture->format); @@ -1095,7 +1095,7 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const { data.resize(data_size); ERR_FAIL_COND_V(data.is_empty(), Ref<Image>()); - image = Image::create_from_data(texture->width, texture->height, false, Image::FORMAT_RGBA8, data); + image = Image::create_from_data(texture->alloc_width, texture->alloc_height, false, Image::FORMAT_RGBA8, data); ERR_FAIL_COND_V(image->is_empty(), Ref<Image>()); if (texture->format != Image::FORMAT_RGBA8) { diff --git a/drivers/metal/metal_objects.mm b/drivers/metal/metal_objects.mm index abdcccf00c..d3c3d2b232 100644 --- a/drivers/metal/metal_objects.mm +++ b/drivers/metal/metal_objects.mm @@ -560,10 +560,10 @@ void MDCommandBuffer::_render_clear_render_area() { } } uint32_t ds_index = subpass.depth_stencil_reference.attachment; - MDAttachment const &attachment = pass.attachments[ds_index]; - bool shouldClearDepth = (ds_index != RDD::AttachmentReference::UNUSED && attachment.shouldClear(subpass, false)); - bool shouldClearStencil = (ds_index != RDD::AttachmentReference::UNUSED && attachment.shouldClear(subpass, true)); + bool shouldClearDepth = (ds_index != RDD::AttachmentReference::UNUSED && pass.attachments[ds_index].shouldClear(subpass, false)); + bool shouldClearStencil = (ds_index != RDD::AttachmentReference::UNUSED && pass.attachments[ds_index].shouldClear(subpass, true)); if (shouldClearDepth || shouldClearStencil) { + MDAttachment const &attachment = pass.attachments[ds_index]; BitField<RDD::TextureAspectBits> bits; if (shouldClearDepth && attachment.type & MDAttachmentType::Depth) { bits.set_flag(RDD::TEXTURE_ASPECT_DEPTH_BIT); diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 489181a025..e4bad88083 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -419,6 +419,9 @@ Error DirAccessUnix::remove(String p_path) { } p_path = fix_path(p_path); + if (p_path.ends_with("/")) { + p_path = p_path.left(-1); + } struct stat flags = {}; if ((stat(p_path.utf8().get_data(), &flags) != 0)) { @@ -438,6 +441,9 @@ bool DirAccessUnix::is_link(String p_file) { } p_file = fix_path(p_file); + if (p_file.ends_with("/")) { + p_file = p_file.left(-1); + } struct stat flags = {}; if ((lstat(p_file.utf8().get_data(), &flags) != 0)) { @@ -453,6 +459,9 @@ String DirAccessUnix::read_link(String p_file) { } p_file = fix_path(p_file); + if (p_file.ends_with("/")) { + p_file = p_file.left(-1); + } char buf[256]; memset(buf, 0, 256); diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index 4ea46e8214..bd395f41e2 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -1772,16 +1772,17 @@ RDD::TextureID RenderingDeviceDriverVulkan::texture_create_from_extension(uint64 tex_info->vk_view = vk_image_view; tex_info->rd_format = p_format; tex_info->vk_view_create_info = image_view_create_info; - +#ifdef DEBUG_ENABLED + tex_info->created_from_extension = true; +#endif return TextureID(tex_info); } RDD::TextureID RenderingDeviceDriverVulkan::texture_create_shared(TextureID p_original_texture, const TextureView &p_view) { const TextureInfo *owner_tex_info = (const TextureInfo *)p_original_texture.id; #ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!owner_tex_info->allocation.handle, TextureID()); + ERR_FAIL_COND_V(!owner_tex_info->allocation.handle && !owner_tex_info->created_from_extension, TextureID()); #endif - VkImageViewCreateInfo image_view_create_info = owner_tex_info->vk_view_create_info; image_view_create_info.format = RD_TO_VK_FORMAT[p_view.format]; image_view_create_info.components.r = (VkComponentSwizzle)p_view.swizzle_r; @@ -1837,7 +1838,7 @@ RDD::TextureID RenderingDeviceDriverVulkan::texture_create_shared(TextureID p_or RDD::TextureID RenderingDeviceDriverVulkan::texture_create_shared_from_slice(TextureID p_original_texture, const TextureView &p_view, TextureSliceType p_slice_type, uint32_t p_layer, uint32_t p_layers, uint32_t p_mipmap, uint32_t p_mipmaps) { const TextureInfo *owner_tex_info = (const TextureInfo *)p_original_texture.id; #ifdef DEBUG_ENABLED - ERR_FAIL_COND_V(!owner_tex_info->allocation.handle, TextureID()); + ERR_FAIL_COND_V(!owner_tex_info->allocation.handle && !owner_tex_info->created_from_extension, TextureID()); #endif VkImageViewCreateInfo image_view_create_info = owner_tex_info->vk_view_create_info; diff --git a/drivers/vulkan/rendering_device_driver_vulkan.h b/drivers/vulkan/rendering_device_driver_vulkan.h index 2615d9824d..81f4256941 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.h +++ b/drivers/vulkan/rendering_device_driver_vulkan.h @@ -213,6 +213,9 @@ public: VmaAllocation handle = nullptr; VmaAllocationInfo info = {}; } allocation; // All 0/null if just a view. +#ifdef DEBUG_ENABLED + bool created_from_extension = false; +#endif }; VkSampleCountFlagBits _ensure_supported_sample_count(TextureSamples p_requested_sample_count); diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 0243d863f8..9d6aa13332 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -118,11 +118,12 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) { return ERR_INVALID_PARAMETER; } - struct _stat st; - if (_wstat((LPCWSTR)(path.utf16().get_data()), &st) == 0) { - if (!S_ISREG(st.st_mode)) { - return ERR_FILE_CANT_OPEN; - } + if (path.ends_with(":\\") || path.ends_with(":")) { + return ERR_FILE_CANT_OPEN; + } + DWORD file_attr = GetFileAttributesW((LPCWSTR)(path.utf16().get_data())); + if (file_attr != INVALID_FILE_ATTRIBUTES && (file_attr & FILE_ATTRIBUTE_DIRECTORY)) { + return ERR_FILE_CANT_OPEN; } #ifdef TOOLS_ENABLED @@ -412,15 +413,40 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) { file = file.substr(0, file.length() - 1); } - struct _stat st; - int rv = _wstat((LPCWSTR)(file.utf16().get_data()), &st); + HANDLE handle = CreateFileW((LPCWSTR)(file.utf16().get_data()), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); - if (rv == 0) { - return st.st_mtime; - } else { - print_verbose("Failed to get modified time for: " + p_file + ""); - return 0; + if (handle != INVALID_HANDLE_VALUE) { + FILETIME ft_create, ft_write; + + bool status = GetFileTime(handle, &ft_create, nullptr, &ft_write); + + CloseHandle(handle); + + if (status) { + uint64_t ret = 0; + + // If write time is invalid, fallback to creation time. + if (ft_write.dwHighDateTime == 0 && ft_write.dwLowDateTime == 0) { + ret = ft_create.dwHighDateTime; + ret <<= 32; + ret |= ft_create.dwLowDateTime; + } else { + ret = ft_write.dwHighDateTime; + ret <<= 32; + ret |= ft_write.dwLowDateTime; + } + + const uint64_t WINDOWS_TICKS_PER_SECOND = 10000000; + const uint64_t TICKS_TO_UNIX_EPOCH = 116444736000000000LL; + + if (ret >= TICKS_TO_UNIX_EPOCH) { + return (ret - TICKS_TO_UNIX_EPOCH) / WINDOWS_TICKS_PER_SECOND; + } + } } + + print_verbose("Failed to get modified time for: " + p_file); + return 0; } BitField<FileAccess::UnixPermissionFlags> FileAccessWindows::_get_unix_permissions(const String &p_file) { |
