summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDaniel Rakos <daniel.rakos@rastergrid.com>2019-05-07 11:26:58 +0200
committerDaniel Rakos <daniel.rakos@rastergrid.com>2019-05-07 11:30:18 +0200
commit9dc4c762a75820b126bbb183a7d33e60d7f39366 (patch)
treece9dab46e3975bf06fa1a68f37f6201dc688bc05 /modules
parent0239d8bd9fa03965439aac2482d18746f807bd00 (diff)
Fixes to the DDS loader
* Added missing format info entries for ATI1 and ATI2 formats * Added missing A2XY format
Diffstat (limited to 'modules')
-rw-r--r--modules/dds/texture_loader_dds.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index 059c06c37c..50fdc8ab20 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -31,6 +31,8 @@
#include "texture_loader_dds.h"
#include "core/os/file_access.h"
+#define PF_FOURCC(s) (((s)[3] << 24U) | ((s)[2] << 16U) | ((s)[1] << 8U) | ((s)[0]))
+
enum {
DDS_MAGIC = 0x20534444,
DDSD_CAPS = 0x00000001,
@@ -51,6 +53,7 @@ enum DDSFormat {
DDS_DXT5,
DDS_ATI1,
DDS_ATI2,
+ DDS_A2XY,
DDS_BGRA8,
DDS_BGR8,
DDS_RGBA8, //flipped in dds
@@ -74,9 +77,12 @@ struct DDSFormatInfo {
};
static const DDSFormatInfo dds_format_info[DDS_MAX] = {
- { "DXT1", true, false, 4, 8, Image::FORMAT_DXT1 },
- { "DXT3", true, false, 4, 16, Image::FORMAT_DXT3 },
- { "DXT5", true, false, 4, 16, Image::FORMAT_DXT5 },
+ { "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 },
@@ -158,22 +164,25 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
DDSFormat dds_format;
- if (format_flags & DDPF_FOURCC && format_fourcc == 0x31545844) { //'1TXD'
+ if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT1")) {
dds_format = DDS_DXT1;
- } else if (format_flags & DDPF_FOURCC && format_fourcc == 0x33545844) { //'3TXD'
+ } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT3")) {
dds_format = DDS_DXT3;
- } else if (format_flags & DDPF_FOURCC && format_fourcc == 0x35545844) { //'5TXD'
+ } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT5")) {
dds_format = DDS_DXT5;
- } else if (format_flags & DDPF_FOURCC && format_fourcc == 0x31495441) { //'1ITA'
+ } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI1")) {
dds_format = DDS_ATI1;
- } else if (format_flags & DDPF_FOURCC && format_fourcc == 0x32495441) { //'2ITA'
+ } 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) {