From 0045dc204c954edfcc8f15751d4ea54174da7818 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Tue, 29 Aug 2023 14:25:16 +0200 Subject: [PATCH] Revert "Implement loading DDS textures at run-time" This reverts commit 34ab1c8a36e61b386c210fb908b9ebfa86513149. --- core/io/image.cpp | 10 - core/io/image.h | 2 - doc/classes/Image.xml | 7 - modules/dds/image_loader_dds.cpp | 421 ----------------------------- modules/dds/image_loader_dds.h | 43 --- modules/dds/register_types.cpp | 8 - modules/dds/texture_loader_dds.cpp | 362 ++++++++++++++++++++++++- tests/core/io/test_image.h | 10 - tests/data/images/icon.dds | Bin 87536 -> 0 bytes 9 files changed, 357 insertions(+), 506 deletions(-) delete mode 100644 modules/dds/image_loader_dds.cpp delete mode 100644 modules/dds/image_loader_dds.h delete mode 100644 tests/data/images/icon.dds diff --git a/core/io/image.cpp b/core/io/image.cpp index 3ca39f98c052..ce2f47371af6 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -3017,7 +3017,6 @@ ImageMemLoadFunc Image::_webp_mem_loader_func = nullptr; ImageMemLoadFunc Image::_tga_mem_loader_func = nullptr; ImageMemLoadFunc Image::_bmp_mem_loader_func = nullptr; ScalableImageMemLoadFunc Image::_svg_scalable_mem_loader_func = nullptr; -ImageMemLoadFunc Image::_dds_mem_loader_func = nullptr; ImageMemLoadFunc Image::_ktx_mem_loader_func = nullptr; void (*Image::_image_compress_bc_func)(Image *, Image::UsedChannels) = nullptr; @@ -3490,7 +3489,6 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("load_webp_from_buffer", "buffer"), &Image::load_webp_from_buffer); ClassDB::bind_method(D_METHOD("load_tga_from_buffer", "buffer"), &Image::load_tga_from_buffer); ClassDB::bind_method(D_METHOD("load_bmp_from_buffer", "buffer"), &Image::load_bmp_from_buffer); - ClassDB::bind_method(D_METHOD("load_dds_from_buffer", "buffer"), &Image::load_dds_from_buffer); ClassDB::bind_method(D_METHOD("load_ktx_from_buffer", "buffer"), &Image::load_ktx_from_buffer); ClassDB::bind_method(D_METHOD("load_svg_from_buffer", "buffer", "scale"), &Image::load_svg_from_buffer, DEFVAL(1.0)); @@ -3867,14 +3865,6 @@ Error Image::load_svg_from_string(const String &p_svg_str, float scale) { return load_svg_from_buffer(p_svg_str.to_utf8_buffer(), scale); } -Error Image::load_dds_from_buffer(const Vector &p_array) { - ERR_FAIL_NULL_V_MSG( - _dds_mem_loader_func, - ERR_UNAVAILABLE, - "The DDS module isn't enabled. Recompile the Godot editor or export template binary with the `module_dds_enabled=yes` SCons option."); - return _load_from_buffer(p_array, _dds_mem_loader_func); -} - Error Image::load_ktx_from_buffer(const Vector &p_array) { ERR_FAIL_NULL_V_MSG( _ktx_mem_loader_func, diff --git a/core/io/image.h b/core/io/image.h index cb7c6bff5296..a21d05187b5b 100644 --- a/core/io/image.h +++ b/core/io/image.h @@ -150,7 +150,6 @@ class Image : public Resource { static ImageMemLoadFunc _tga_mem_loader_func; static ImageMemLoadFunc _bmp_mem_loader_func; static ScalableImageMemLoadFunc _svg_scalable_mem_loader_func; - static ImageMemLoadFunc _dds_mem_loader_func; static ImageMemLoadFunc _ktx_mem_loader_func; static void (*_image_compress_bc_func)(Image *, UsedChannels p_channels); @@ -404,7 +403,6 @@ class Image : public Resource { Error load_webp_from_buffer(const Vector &p_array); Error load_tga_from_buffer(const Vector &p_array); Error load_bmp_from_buffer(const Vector &p_array); - Error load_dds_from_buffer(const Vector &p_array); Error load_ktx_from_buffer(const Vector &p_array); Error load_svg_from_buffer(const Vector &p_array, float scale = 1.0); diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 6451062fc552..5f1f9e6c183c 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -312,13 +312,6 @@ [b]Note:[/b] Godot's BMP module doesn't support 16-bit per pixel images. Only 1-bit, 4-bit, 8-bit, 24-bit, and 32-bit per pixel images are supported. - - - - - Loads an image from the binary contents of a DDS file. - - diff --git a/modules/dds/image_loader_dds.cpp b/modules/dds/image_loader_dds.cpp deleted file mode 100644 index d661f6664a2e..000000000000 --- a/modules/dds/image_loader_dds.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************/ -/* image_loader_dds.cpp */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#include "image_loader_dds.h" - -#include "core/os/os.h" - -#include "core/io/file_access.h" -#include "core/io/file_access_memory.h" - -#include - -#define PF_FOURCC(s) ((uint32_t)(((s)[3] << 24U) | ((s)[2] << 16U) | ((s)[1] << 8U) | ((s)[0]))) - -// Reference: https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dds-header - -enum { - DDS_MAGIC = 0x20534444, - DDSD_PITCH = 0x00000008, - DDSD_LINEARSIZE = 0x00080000, - DDSD_MIPMAPCOUNT = 0x00020000, - DDPF_FOURCC = 0x00000004, - DDPF_ALPHAPIXELS = 0x00000001, - DDPF_INDEXED = 0x00000020, - DDPF_RGB = 0x00000040, -}; - -enum DDSFormat { - DDS_DXT1, - DDS_DXT3, - DDS_DXT5, - DDS_ATI1, - DDS_ATI2, - DDS_A2XY, - DDS_BGRA8, - DDS_BGR8, - DDS_RGBA8, //flipped in dds - DDS_RGB8, //flipped in dds - DDS_BGR5A1, - DDS_BGR565, - DDS_BGR10A2, - DDS_LUMINANCE, - DDS_LUMINANCE_ALPHA, - DDS_MAX -}; - -struct DDSFormatInfo { - const char *name = nullptr; - bool compressed = false; - bool palette = false; - uint32_t divisor = 0; - uint32_t block_size = 0; - Image::Format format = Image::Format::FORMAT_BPTC_RGBA; -}; - -static const DDSFormatInfo dds_format_info[DDS_MAX] = { - { "DXT1/BC1", true, false, 4, 8, Image::FORMAT_DXT1 }, - { "DXT3/BC2", true, false, 4, 16, Image::FORMAT_DXT3 }, - { "DXT5/BC3", true, false, 4, 16, Image::FORMAT_DXT5 }, - { "ATI1/BC4", true, false, 4, 8, Image::FORMAT_RGTC_R }, - { "ATI2/3DC/BC5", true, false, 4, 16, Image::FORMAT_RGTC_RG }, - { "A2XY/DXN/BC5", true, false, 4, 16, Image::FORMAT_RGTC_RG }, - { "BGRA8", false, false, 1, 4, Image::FORMAT_RGBA8 }, - { "BGR8", false, false, 1, 3, Image::FORMAT_RGB8 }, - { "RGBA8", false, false, 1, 4, Image::FORMAT_RGBA8 }, - { "RGB8", false, false, 1, 3, Image::FORMAT_RGB8 }, - { "BGR5A1", false, false, 1, 2, Image::FORMAT_RGBA8 }, - { "BGR565", false, false, 1, 2, Image::FORMAT_RGB8 }, - { "BGR10A2", false, false, 1, 4, Image::FORMAT_RGBA8 }, - { "GRAYSCALE", false, false, 1, 1, Image::FORMAT_L8 }, - { "GRAYSCALE_ALPHA", false, false, 1, 2, Image::FORMAT_LA8 } -}; - -static Ref _dds_mem_loader_func(const uint8_t *p_buffer, int p_buffer_len) { - Ref memfile; - memfile.instantiate(); - Error open_memfile_error = memfile->open_custom(p_buffer, p_buffer_len); - ERR_FAIL_COND_V_MSG(open_memfile_error, Ref(), "Could not create memfile for DDS image buffer."); - - Ref img; - img.instantiate(); - Error load_error = ImageLoaderDDS().load_image(img, memfile, false, 1.0f); - ERR_FAIL_COND_V_MSG(load_error, Ref(), "Failed to load DDS image."); - return img; -} - -Error ImageLoaderDDS::load_image(Ref p_image, Ref f, BitField p_flags, float p_scale) { - uint32_t magic = f->get_32(); - uint32_t hsize = f->get_32(); - uint32_t flags = f->get_32(); - uint32_t height = f->get_32(); - uint32_t width = f->get_32(); - uint32_t pitch = f->get_32(); - /* uint32_t depth = */ f->get_32(); - uint32_t mipmaps = f->get_32(); - - //skip 11 - for (int i = 0; i < 11; i++) { - f->get_32(); - } - - //validate - - // We don't check DDSD_CAPS or DDSD_PIXELFORMAT, as they're mandatory when writing, - // but non-mandatory when reading (as some writers don't set them)... - if (magic != DDS_MAGIC || hsize != 124) { - ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid or unsupported DDS texture file '" + f->get_path() + "'."); - } - - /* uint32_t format_size = */ f->get_32(); - uint32_t format_flags = f->get_32(); - uint32_t format_fourcc = f->get_32(); - uint32_t format_rgb_bits = f->get_32(); - uint32_t format_red_mask = f->get_32(); - uint32_t format_green_mask = f->get_32(); - uint32_t format_blue_mask = f->get_32(); - uint32_t format_alpha_mask = f->get_32(); - - /* uint32_t caps_1 = */ f->get_32(); - /* uint32_t caps_2 = */ f->get_32(); - /* uint32_t caps_ddsx = */ f->get_32(); - - //reserved skip - f->get_32(); - f->get_32(); - - /* - print_line("DDS width: "+itos(width)); - print_line("DDS height: "+itos(height)); - print_line("DDS mipmaps: "+itos(mipmaps)); - - printf("fourcc: %x fflags: %x, rgbbits: %x, fsize: %x\n",format_fourcc,format_flags,format_rgb_bits,format_size); - printf("rmask: %x gmask: %x, bmask: %x, amask: %x\n",format_red_mask,format_green_mask,format_blue_mask,format_alpha_mask); - */ - - //must avoid this later - while (f->get_position() < 128) { - f->get_8(); - } - - DDSFormat dds_format; - - if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT1")) { - dds_format = DDS_DXT1; - } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT3")) { - dds_format = DDS_DXT3; - - } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT5")) { - dds_format = DDS_DXT5; - } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI1")) { - dds_format = DDS_ATI1; - } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI2")) { - dds_format = DDS_ATI2; - } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("A2XY")) { - dds_format = DDS_A2XY; - - } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff && format_alpha_mask == 0xff000000) { - dds_format = DDS_BGRA8; - } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 24 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff) { - dds_format = DDS_BGR8; - } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000 && format_alpha_mask == 0xff000000) { - dds_format = DDS_RGBA8; - } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 24 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000) { - dds_format = DDS_RGB8; - - } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 16 && format_red_mask == 0x00007c00 && format_green_mask == 0x000003e0 && format_blue_mask == 0x0000001f && format_alpha_mask == 0x00008000) { - dds_format = DDS_BGR5A1; - } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0x3ff00000 && format_green_mask == 0xffc00 && format_blue_mask == 0x3ff && format_alpha_mask == 0xc0000000) { - dds_format = DDS_BGR10A2; - } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 16 && format_red_mask == 0x0000f800 && format_green_mask == 0x000007e0 && format_blue_mask == 0x0000001f) { - dds_format = DDS_BGR565; - } else if (!(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 8 && format_red_mask == 0xff) { - dds_format = DDS_LUMINANCE; - } else if ((format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 16 && format_red_mask == 0xff && format_alpha_mask == 0xff00) { - dds_format = DDS_LUMINANCE_ALPHA; - } else if (format_flags & DDPF_INDEXED && format_rgb_bits == 8) { - dds_format = DDS_BGR565; - } else { - //printf("unrecognized fourcc %x format_flags: %x - rgbbits %i - red_mask %x green mask %x blue mask %x alpha mask %x\n", format_fourcc, format_flags, format_rgb_bits, format_red_mask, format_green_mask, format_blue_mask, format_alpha_mask); - ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Unrecognized or unsupported color layout in DDS '" + f->get_path() + "'."); - } - - if (!(flags & DDSD_MIPMAPCOUNT)) { - mipmaps = 1; - } - - Vector src_data; - - const DDSFormatInfo &info = dds_format_info[dds_format]; - uint32_t w = width; - uint32_t h = height; - - if (info.compressed) { - //compressed bc - - uint32_t size = MAX(info.divisor, w) / info.divisor * MAX(info.divisor, h) / info.divisor * info.block_size; - ERR_FAIL_COND_V(size != pitch, ERR_FILE_CORRUPT); - ERR_FAIL_COND_V(!(flags & DDSD_LINEARSIZE), ERR_FILE_CORRUPT); - - for (uint32_t i = 1; i < mipmaps; i++) { - w = MAX(1u, w >> 1); - h = MAX(1u, h >> 1); - uint32_t bsize = MAX(info.divisor, w) / info.divisor * MAX(info.divisor, h) / info.divisor * info.block_size; - //printf("%i x %i - block: %i\n",w,h,bsize); - size += bsize; - } - - src_data.resize(size); - uint8_t *wb = src_data.ptrw(); - f->get_buffer(wb, size); - - } else if (info.palette) { - //indexed - ERR_FAIL_COND_V(!(flags & DDSD_PITCH), ERR_FILE_CORRUPT); - ERR_FAIL_COND_V(format_rgb_bits != 8, ERR_FILE_CORRUPT); - - uint32_t size = pitch * height; - ERR_FAIL_COND_V(size != width * height * info.block_size, ERR_FILE_CORRUPT); - - uint8_t palette[256 * 4]; - f->get_buffer(palette, 256 * 4); - - int colsize = 3; - for (int i = 0; i < 256; i++) { - if (palette[i * 4 + 3] < 255) { - colsize = 4; - } - } - - int w2 = width; - int h2 = height; - - for (uint32_t i = 1; i < mipmaps; i++) { - w2 = (w2 + 1) >> 1; - h2 = (h2 + 1) >> 1; - size += w2 * h2 * info.block_size; - } - - src_data.resize(size + 256 * colsize); - uint8_t *wb = src_data.ptrw(); - f->get_buffer(wb, size); - - for (int i = 0; i < 256; i++) { - int dst_ofs = size + i * colsize; - int src_ofs = i * 4; - wb[dst_ofs + 0] = palette[src_ofs + 2]; - wb[dst_ofs + 1] = palette[src_ofs + 1]; - wb[dst_ofs + 2] = palette[src_ofs + 0]; - if (colsize == 4) { - wb[dst_ofs + 3] = palette[src_ofs + 3]; - } - } - } else { - //uncompressed generic... - - uint32_t size = width * height * info.block_size; - - for (uint32_t i = 1; i < mipmaps; i++) { - w = (w + 1) >> 1; - h = (h + 1) >> 1; - size += w * h * info.block_size; - } - - if (dds_format == DDS_BGR565) { - size = size * 3 / 2; - } else if (dds_format == DDS_BGR5A1) { - size = size * 2; - } - - src_data.resize(size); - uint8_t *wb = src_data.ptrw(); - f->get_buffer(wb, size); - - switch (dds_format) { - case DDS_BGR5A1: { - // TO RGBA - int colcount = size / 4; - - for (int i = colcount - 1; i >= 0; i--) { - int src_ofs = i * 2; - int dst_ofs = i * 4; - - uint8_t a = wb[src_ofs + 1] & 0x80; - uint8_t b = wb[src_ofs] & 0x1F; - uint8_t g = (wb[src_ofs] >> 5) | ((wb[src_ofs + 1] & 0x3) << 3); - uint8_t r = (wb[src_ofs + 1] >> 2) & 0x1F; - wb[dst_ofs + 0] = r << 3; - wb[dst_ofs + 1] = g << 3; - wb[dst_ofs + 2] = b << 3; - wb[dst_ofs + 3] = a ? 255 : 0; - } - } break; - case DDS_BGR565: { - int colcount = size / 3; - - for (int i = colcount - 1; i >= 0; i--) { - int src_ofs = i * 2; - int dst_ofs = i * 3; - - uint8_t b = wb[src_ofs] & 0x1F; - uint8_t g = (wb[src_ofs] >> 5) | ((wb[src_ofs + 1] & 0x7) << 3); - uint8_t r = wb[src_ofs + 1] >> 3; - wb[dst_ofs + 0] = r << 3; - wb[dst_ofs + 1] = g << 2; - wb[dst_ofs + 2] = b << 3; //b<<3; - } - - } break; - case DDS_BGR10A2: { - // TO RGBA - int colcount = size / 4; - - for (int i = colcount - 1; i >= 0; i--) { - int ofs = i * 4; - - uint32_t w32 = uint32_t(wb[ofs + 0]) | (uint32_t(wb[ofs + 1]) << 8) | (uint32_t(wb[ofs + 2]) << 16) | (uint32_t(wb[ofs + 3]) << 24); - - uint8_t a = (w32 & 0xc0000000) >> 24; - uint8_t r = (w32 & 0x3ff00000) >> 22; - uint8_t g = (w32 & 0xffc00) >> 12; - uint8_t b = (w32 & 0x3ff) >> 2; - - wb[ofs + 0] = r; - wb[ofs + 1] = g; - wb[ofs + 2] = b; - wb[ofs + 3] = a == 0xc0 ? 255 : a; //0xc0 should be opaque - } - } break; - case DDS_BGRA8: { - int colcount = size / 4; - - for (int i = 0; i < colcount; i++) { - SWAP(wb[i * 4 + 0], wb[i * 4 + 2]); - } - - } break; - case DDS_BGR8: { - int colcount = size / 3; - - for (int i = 0; i < colcount; i++) { - SWAP(wb[i * 3 + 0], wb[i * 3 + 2]); - } - } break; - case DDS_RGBA8: { - /* do nothing either - int colcount = size/4; - - for(int i=0;iset_data(width, height, mipmaps - 1, info.format, src_data); - return OK; -} - -ImageLoaderDDS::ImageLoaderDDS() { - Image::_dds_mem_loader_func = _dds_mem_loader_func; -} - -void ImageLoaderDDS::get_recognized_extensions(List *p_extensions) const { - p_extensions->push_back("dds"); -} diff --git a/modules/dds/image_loader_dds.h b/modules/dds/image_loader_dds.h deleted file mode 100644 index 81cfd43551ef..000000000000 --- a/modules/dds/image_loader_dds.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************/ -/* image_loader_dds.h */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#ifndef IMAGE_LOADER_DDS_H -#define IMAGE_LOADER_DDS_H - -#include "core/io/image_loader.h" - -class ImageLoaderDDS : public ImageFormatLoader { -public: - virtual Error load_image(Ref p_image, Ref f, BitField p_flags, float p_scale); - virtual void get_recognized_extensions(List *p_extensions) const; - ImageLoaderDDS(); -}; - -#endif // IMAGE_LOADER_DDS_H diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp index b4d406eda9db..d336269eb379 100644 --- a/modules/dds/register_types.cpp +++ b/modules/dds/register_types.cpp @@ -30,11 +30,9 @@ #include "register_types.h" -#include "image_loader_dds.h" #include "texture_loader_dds.h" static Ref resource_loader_dds; -static Ref image_loader_dds; void initialize_dds_module(ModuleInitializationLevel p_level) { if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { @@ -43,9 +41,6 @@ void initialize_dds_module(ModuleInitializationLevel p_level) { resource_loader_dds.instantiate(); ResourceLoader::add_resource_format_loader(resource_loader_dds); - - image_loader_dds.instantiate(); - ImageLoader::add_image_format_loader(image_loader_dds); } void uninitialize_dds_module(ModuleInitializationLevel p_level) { @@ -55,7 +50,4 @@ void uninitialize_dds_module(ModuleInitializationLevel p_level) { ResourceLoader::remove_resource_format_loader(resource_loader_dds); resource_loader_dds.unref(); - - ImageLoader::remove_image_format_loader(image_loader_dds); - image_loader_dds.unref(); } diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 861cf20cc2fa..8a3a36e84bb9 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -29,11 +29,72 @@ /**************************************************************************/ #include "texture_loader_dds.h" -#include "image_loader_dds.h" #include "core/io/file_access.h" #include "scene/resources/image_texture.h" +#define PF_FOURCC(s) ((uint32_t)(((s)[3] << 24U) | ((s)[2] << 16U) | ((s)[1] << 8U) | ((s)[0]))) + +// Reference: https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dds-header + +enum { + DDS_MAGIC = 0x20534444, + DDSD_PITCH = 0x00000008, + DDSD_LINEARSIZE = 0x00080000, + DDSD_MIPMAPCOUNT = 0x00020000, + DDPF_FOURCC = 0x00000004, + DDPF_ALPHAPIXELS = 0x00000001, + DDPF_INDEXED = 0x00000020, + DDPF_RGB = 0x00000040, +}; + +enum DDSFormat { + DDS_DXT1, + DDS_DXT3, + DDS_DXT5, + DDS_ATI1, + DDS_ATI2, + DDS_A2XY, + DDS_BGRA8, + DDS_BGR8, + DDS_RGBA8, //flipped in dds + DDS_RGB8, //flipped in dds + DDS_BGR5A1, + DDS_BGR565, + DDS_BGR10A2, + DDS_INDEXED, + DDS_LUMINANCE, + DDS_LUMINANCE_ALPHA, + DDS_MAX +}; + +struct DDSFormatInfo { + const char *name = nullptr; + bool compressed = false; + bool palette = false; + uint32_t divisor = 0; + uint32_t block_size = 0; + Image::Format format = Image::Format::FORMAT_BPTC_RGBA; +}; + +static const DDSFormatInfo dds_format_info[DDS_MAX] = { + { "DXT1/BC1", true, false, 4, 8, Image::FORMAT_DXT1 }, + { "DXT3/BC2", true, false, 4, 16, Image::FORMAT_DXT3 }, + { "DXT5/BC3", true, false, 4, 16, Image::FORMAT_DXT5 }, + { "ATI1/BC4", true, false, 4, 8, Image::FORMAT_RGTC_R }, + { "ATI2/3DC/BC5", true, false, 4, 16, Image::FORMAT_RGTC_RG }, + { "A2XY/DXN/BC5", true, false, 4, 16, Image::FORMAT_RGTC_RG }, + { "BGRA8", false, false, 1, 4, Image::FORMAT_RGBA8 }, + { "BGR8", false, false, 1, 3, Image::FORMAT_RGB8 }, + { "RGBA8", false, false, 1, 4, Image::FORMAT_RGBA8 }, + { "RGB8", false, false, 1, 3, Image::FORMAT_RGB8 }, + { "BGR5A1", false, false, 1, 2, Image::FORMAT_RGBA8 }, + { "BGR565", false, false, 1, 2, Image::FORMAT_RGB8 }, + { "BGR10A2", false, false, 1, 4, Image::FORMAT_RGBA8 }, + { "GRAYSCALE", false, false, 1, 1, Image::FORMAT_L8 }, + { "GRAYSCALE_ALPHA", false, false, 1, 2, Image::FORMAT_LA8 } +}; + Ref ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { if (r_error) { *r_error = ERR_CANT_OPEN; @@ -52,12 +113,303 @@ Ref ResourceFormatDDS::load(const String &p_path, const String &p_orig ERR_FAIL_COND_V_MSG(err != OK, Ref(), "Unable to open DDS texture file '" + p_path + "'."); - Ref img = memnew(Image); - Error i_error = ImageLoaderDDS().load_image(img, f, false, 1.0); - if (r_error) { - *r_error = i_error; + uint32_t magic = f->get_32(); + uint32_t hsize = f->get_32(); + uint32_t flags = f->get_32(); + uint32_t height = f->get_32(); + uint32_t width = f->get_32(); + uint32_t pitch = f->get_32(); + /* uint32_t depth = */ f->get_32(); + uint32_t mipmaps = f->get_32(); + + //skip 11 + for (int i = 0; i < 11; i++) { + f->get_32(); + } + + //validate + + // We don't check DDSD_CAPS or DDSD_PIXELFORMAT, as they're mandatory when writing, + // but non-mandatory when reading (as some writers don't set them)... + if (magic != DDS_MAGIC || hsize != 124) { + ERR_FAIL_V_MSG(Ref(), "Invalid or unsupported DDS texture file '" + p_path + "'."); + } + + /* uint32_t format_size = */ f->get_32(); + uint32_t format_flags = f->get_32(); + uint32_t format_fourcc = f->get_32(); + uint32_t format_rgb_bits = f->get_32(); + uint32_t format_red_mask = f->get_32(); + uint32_t format_green_mask = f->get_32(); + uint32_t format_blue_mask = f->get_32(); + uint32_t format_alpha_mask = f->get_32(); + + /* uint32_t caps_1 = */ f->get_32(); + /* uint32_t caps_2 = */ f->get_32(); + /* uint32_t caps_ddsx = */ f->get_32(); + + //reserved skip + f->get_32(); + f->get_32(); + + /* + print_line("DDS width: "+itos(width)); + print_line("DDS height: "+itos(height)); + print_line("DDS mipmaps: "+itos(mipmaps)); + + printf("fourcc: %x fflags: %x, rgbbits: %x, fsize: %x\n",format_fourcc,format_flags,format_rgb_bits,format_size); + printf("rmask: %x gmask: %x, bmask: %x, amask: %x\n",format_red_mask,format_green_mask,format_blue_mask,format_alpha_mask); + */ + + //must avoid this later + while (f->get_position() < 128) { + f->get_8(); + } + + DDSFormat dds_format; + + if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT1")) { + dds_format = DDS_DXT1; + } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT3")) { + dds_format = DDS_DXT3; + + } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT5")) { + dds_format = DDS_DXT5; + } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI1")) { + dds_format = DDS_ATI1; + } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI2")) { + dds_format = DDS_ATI2; + } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("A2XY")) { + dds_format = DDS_A2XY; + + } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff && format_alpha_mask == 0xff000000) { + dds_format = DDS_BGRA8; + } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 24 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff) { + dds_format = DDS_BGR8; + } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000 && format_alpha_mask == 0xff000000) { + dds_format = DDS_RGBA8; + } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 24 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000) { + dds_format = DDS_RGB8; + + } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 16 && format_red_mask == 0x00007c00 && format_green_mask == 0x000003e0 && format_blue_mask == 0x0000001f && format_alpha_mask == 0x00008000) { + dds_format = DDS_BGR5A1; + } else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0x3ff00000 && format_green_mask == 0xffc00 && format_blue_mask == 0x3ff && format_alpha_mask == 0xc0000000) { + dds_format = DDS_BGR10A2; + } else if (format_flags & DDPF_RGB && !(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 16 && format_red_mask == 0x0000f800 && format_green_mask == 0x000007e0 && format_blue_mask == 0x0000001f) { + dds_format = DDS_BGR565; + } else if (!(format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 8 && format_red_mask == 0xff && format_green_mask == 0xff && format_blue_mask == 0xff) { + dds_format = DDS_LUMINANCE; + } else if ((format_flags & DDPF_ALPHAPIXELS) && format_rgb_bits == 16 && format_red_mask == 0xff && format_green_mask == 0xff && format_blue_mask == 0xff && format_alpha_mask == 0xff00) { + dds_format = DDS_LUMINANCE_ALPHA; + } else if (format_flags & DDPF_INDEXED && format_rgb_bits == 8) { + dds_format = DDS_BGR565; + } else { + //printf("unrecognized fourcc %x format_flags: %x - rgbbits %i - red_mask %x green mask %x blue mask %x alpha mask %x\n", format_fourcc, format_flags, format_rgb_bits, format_red_mask, format_green_mask, format_blue_mask, format_alpha_mask); + ERR_FAIL_V_MSG(Ref(), "Unrecognized or unsupported color layout in DDS '" + p_path + "'."); + } + + if (!(flags & DDSD_MIPMAPCOUNT)) { + mipmaps = 1; + } + + Vector src_data; + + const DDSFormatInfo &info = dds_format_info[dds_format]; + uint32_t w = width; + uint32_t h = height; + + if (info.compressed) { + //compressed bc + + uint32_t size = MAX(info.divisor, w) / info.divisor * MAX(info.divisor, h) / info.divisor * info.block_size; + ERR_FAIL_COND_V(size != pitch, Ref()); + ERR_FAIL_COND_V(!(flags & DDSD_LINEARSIZE), Ref()); + + for (uint32_t i = 1; i < mipmaps; i++) { + w = MAX(1u, w >> 1); + h = MAX(1u, h >> 1); + uint32_t bsize = MAX(info.divisor, w) / info.divisor * MAX(info.divisor, h) / info.divisor * info.block_size; + //printf("%i x %i - block: %i\n",w,h,bsize); + size += bsize; + } + + src_data.resize(size); + uint8_t *wb = src_data.ptrw(); + f->get_buffer(wb, size); + + } else if (info.palette) { + //indexed + ERR_FAIL_COND_V(!(flags & DDSD_PITCH), Ref()); + ERR_FAIL_COND_V(format_rgb_bits != 8, Ref()); + + uint32_t size = pitch * height; + ERR_FAIL_COND_V(size != width * height * info.block_size, Ref()); + + uint8_t palette[256 * 4]; + f->get_buffer(palette, 256 * 4); + + int colsize = 3; + for (int i = 0; i < 256; i++) { + if (palette[i * 4 + 3] < 255) { + colsize = 4; + } + } + + int w2 = width; + int h2 = height; + + for (uint32_t i = 1; i < mipmaps; i++) { + w2 = (w2 + 1) >> 1; + h2 = (h2 + 1) >> 1; + size += w2 * h2 * info.block_size; + } + + src_data.resize(size + 256 * colsize); + uint8_t *wb = src_data.ptrw(); + f->get_buffer(wb, size); + + for (int i = 0; i < 256; i++) { + int dst_ofs = size + i * colsize; + int src_ofs = i * 4; + wb[dst_ofs + 0] = palette[src_ofs + 2]; + wb[dst_ofs + 1] = palette[src_ofs + 1]; + wb[dst_ofs + 2] = palette[src_ofs + 0]; + if (colsize == 4) { + wb[dst_ofs + 3] = palette[src_ofs + 3]; + } + } + } else { + //uncompressed generic... + + uint32_t size = width * height * info.block_size; + + for (uint32_t i = 1; i < mipmaps; i++) { + w = (w + 1) >> 1; + h = (h + 1) >> 1; + size += w * h * info.block_size; + } + + if (dds_format == DDS_BGR565) { + size = size * 3 / 2; + } else if (dds_format == DDS_BGR5A1) { + size = size * 2; + } + + src_data.resize(size); + uint8_t *wb = src_data.ptrw(); + f->get_buffer(wb, size); + + switch (dds_format) { + case DDS_BGR5A1: { + // TO RGBA + int colcount = size / 4; + + for (int i = colcount - 1; i >= 0; i--) { + int src_ofs = i * 2; + int dst_ofs = i * 4; + + uint8_t a = wb[src_ofs + 1] & 0x80; + uint8_t b = wb[src_ofs] & 0x1F; + uint8_t g = (wb[src_ofs] >> 5) | ((wb[src_ofs + 1] & 0x3) << 3); + uint8_t r = (wb[src_ofs + 1] >> 2) & 0x1F; + wb[dst_ofs + 0] = r << 3; + wb[dst_ofs + 1] = g << 3; + wb[dst_ofs + 2] = b << 3; + wb[dst_ofs + 3] = a ? 255 : 0; + } + } break; + case DDS_BGR565: { + int colcount = size / 3; + + for (int i = colcount - 1; i >= 0; i--) { + int src_ofs = i * 2; + int dst_ofs = i * 3; + + uint8_t b = wb[src_ofs] & 0x1F; + uint8_t g = (wb[src_ofs] >> 5) | ((wb[src_ofs + 1] & 0x7) << 3); + uint8_t r = wb[src_ofs + 1] >> 3; + wb[dst_ofs + 0] = r << 3; + wb[dst_ofs + 1] = g << 2; + wb[dst_ofs + 2] = b << 3; //b<<3; + } + + } break; + case DDS_BGR10A2: { + // TO RGBA + int colcount = size / 4; + + for (int i = colcount - 1; i >= 0; i--) { + int ofs = i * 4; + + uint32_t w32 = uint32_t(wb[ofs + 0]) | (uint32_t(wb[ofs + 1]) << 8) | (uint32_t(wb[ofs + 2]) << 16) | (uint32_t(wb[ofs + 3]) << 24); + + uint8_t a = (w32 & 0xc0000000) >> 24; + uint8_t r = (w32 & 0x3ff00000) >> 22; + uint8_t g = (w32 & 0xffc00) >> 12; + uint8_t b = (w32 & 0x3ff) >> 2; + + wb[ofs + 0] = r; + wb[ofs + 1] = g; + wb[ofs + 2] = b; + wb[ofs + 3] = a == 0xc0 ? 255 : a; //0xc0 should be opaque + } + } break; + case DDS_BGRA8: { + int colcount = size / 4; + + for (int i = 0; i < colcount; i++) { + SWAP(wb[i * 4 + 0], wb[i * 4 + 2]); + } + + } break; + case DDS_BGR8: { + int colcount = size / 3; + + for (int i = 0; i < colcount; i++) { + SWAP(wb[i * 3 + 0], wb[i * 3 + 2]); + } + } break; + case DDS_RGBA8: { + /* do nothing either + int colcount = size/4; + + for(int i=0;i img = memnew(Image(width, height, mipmaps - 1, info.format, src_data)); Ref texture = ImageTexture::create_from_image(img); if (r_error) { diff --git a/tests/core/io/test_image.h b/tests/core/io/test_image.h index 189797111321..07c7c04e3641 100644 --- a/tests/core/io/test_image.h +++ b/tests/core/io/test_image.h @@ -115,16 +115,6 @@ TEST_CASE("[Image] Saving and loading") { image_bmp->load_bmp_from_buffer(data_bmp) == OK, "The BMP image should load successfully."); - // Load DDS - Ref image_dds = memnew(Image()); - Ref f_dds = FileAccess::open(TestUtils::get_data_path("images/icon.dds"), FileAccess::READ, &err); - PackedByteArray data_dds; - data_dds.resize(f_dds->get_length() + 1); - f_dds->get_buffer(data_dds.ptrw(), f_dds->get_length()); - CHECK_MESSAGE( - image_dds->load_dds_from_buffer(data_dds) == OK, - "The DDS image should load successfully."); - // Load JPG Ref image_jpg = memnew(Image()); Ref f_jpg = FileAccess::open(TestUtils::get_data_path("images/icon.jpg"), FileAccess::READ, &err); diff --git a/tests/data/images/icon.dds b/tests/data/images/icon.dds deleted file mode 100644 index 8a9de402cbf13d8d031586d450e0e0cb48df294d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 87536 zcmeHw4|JT>b?2Lr1d<$ML#!4O8bptTZMjAvv5ZX(9xKzc$e9Gu%xEUAYH3sNS?ZFF z+Qgc{iLHr%p2R&gGK*}LQhVwKB9DT_$woNPwWX!mQqpbd=~;ztHh8o&dnA->$H|E@ zLSVi9-S>U(&-X_5pp5@v&m1TC`hDN~-n;ky?!E86f5G6VYQMx7yLNdsV?O+a{^$H3 ztHR&@UCSq0*9L>1YOgAzf^+_AQCg1w1!Li+g&wS29$4U?TOO~&A1X-W$5@Fj@uQ>< zB|MbuLCGGL{6Wbdmg0d@JWz@UO7TD`9w@~FrFfte50v783mFf5&B?#KKM`Uq5{dW{ zg6^$L1O*+w-1X0C@8jiBr~NfffBg5j{Rv#|?Ju>jgzsYTeZ7O<@}_oy*BUP9ANsll z9x52o11lI4G;+P1y|9{MOTr7Ke)<0p31AivJrvv?olkR?=&etdt)lYQR=~%p|FX^3 za`wvp_uaAF7loy&sPHlVI`gB^=w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