Blender  V3.3
DirectDrawSurface.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 /*
8  * This file is based on a similar file from the NVIDIA texture tools
9  * (http://nvidia-texture-tools.googlecode.com/)
10  *
11  * Original license from NVIDIA follows.
12  */
13 
14 /* Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
15  *
16  * Permission is hereby granted, free of charge, to any person
17  * obtaining a copy of this software and associated documentation
18  * files (the "Software"), to deal in the Software without
19  * restriction, including without limitation the rights to use,
20  * copy, modify, merge, publish, distribute, sublicense, and/or sell
21  * copies of the Software, and to permit persons to whom the
22  * Software is furnished to do so, subject to the following
23  * conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  * OTHER DEALINGS IN THE SOFTWARE. */
36 
37 #include "BLI_utildefines.h"
38 #undef CLAMP
39 
40 #include <BlockDXT.h>
41 #include <DirectDrawSurface.h>
42 #include <PixelFormat.h>
43 
44 #include <cmath> /* sqrt */
45 #include <cstdio> /* printf */
46 #include <cstdlib> /* malloc */
47 #include <sys/types.h>
48 
49 /*** declarations ***/
50 
51 #if !defined(DDS_MAKEFOURCC)
52 # define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3) \
53  (uint(uint8(ch0)) | (uint(uint8(ch1)) << 8) | (uint(uint8(ch2)) << 16) | \
54  (uint(uint8(ch3)) << 24))
55 #endif
56 
57 static const uint FOURCC_NVTT = DDS_MAKEFOURCC('N', 'V', 'T', 'T');
58 static const uint FOURCC_DDS = DDS_MAKEFOURCC('D', 'D', 'S', ' ');
59 static const uint FOURCC_DXT1 = DDS_MAKEFOURCC('D', 'X', 'T', '1');
60 static const uint FOURCC_DXT2 = DDS_MAKEFOURCC('D', 'X', 'T', '2');
61 static const uint FOURCC_DXT3 = DDS_MAKEFOURCC('D', 'X', 'T', '3');
62 static const uint FOURCC_DXT4 = DDS_MAKEFOURCC('D', 'X', 'T', '4');
63 static const uint FOURCC_DXT5 = DDS_MAKEFOURCC('D', 'X', 'T', '5');
64 static const uint FOURCC_RXGB = DDS_MAKEFOURCC('R', 'X', 'G', 'B');
65 static const uint FOURCC_ATI1 = DDS_MAKEFOURCC('A', 'T', 'I', '1');
66 static const uint FOURCC_ATI2 = DDS_MAKEFOURCC('A', 'T', 'I', '2');
67 
68 #if 0 /* Valid but currently unused. */
69 static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
70 #endif
71 
72 static const uint FOURCC_DX10 = DDS_MAKEFOURCC('D', 'X', '1', '0');
73 
74 static const uint FOURCC_UVER = DDS_MAKEFOURCC('U', 'V', 'E', 'R');
75 
76 /* 32 bit RGB formats. */
77 static const uint D3DFMT_R8G8B8 = 20;
78 static const uint D3DFMT_A8R8G8B8 = 21;
79 static const uint D3DFMT_X8R8G8B8 = 22;
80 static const uint D3DFMT_R5G6B5 = 23;
81 static const uint D3DFMT_X1R5G5B5 = 24;
82 static const uint D3DFMT_A1R5G5B5 = 25;
83 static const uint D3DFMT_A4R4G4B4 = 26;
84 static const uint D3DFMT_R3G3B2 = 27;
85 static const uint D3DFMT_A8 = 28;
86 static const uint D3DFMT_A8R3G3B2 = 29;
87 static const uint D3DFMT_X4R4G4B4 = 30;
88 static const uint D3DFMT_A2B10G10R10 = 31;
89 static const uint D3DFMT_A8B8G8R8 = 32;
90 static const uint D3DFMT_X8B8G8R8 = 33;
91 static const uint D3DFMT_G16R16 = 34;
92 static const uint D3DFMT_A2R10G10B10 = 35;
93 
94 #if 0 /* Valid but currently unused. */
95 static const uint D3DFMT_A16B16G16R16 = 36;
96 #endif
97 
98 /* Palette formats. */
99 #if 0 /* Valid but currently unused. */
100 static const uint D3DFMT_A8P8 = 40;
101 static const uint D3DFMT_P8 = 41;
102 #endif
103 
104 /* Luminance formats. */
105 static const uint D3DFMT_L8 = 50;
106 #if 0 /* Valid but currently unused. */
107 static const uint D3DFMT_A8L8 = 51;
108 static const uint D3DFMT_A4L4 = 52;
109 #endif
110 static const uint D3DFMT_L16 = 81;
111 
112 /* Floating point formats */
113 #if 0 /* Valid but currently unused. */
114 static const uint D3DFMT_R16F = 111;
115 static const uint D3DFMT_G16R16F = 112;
116 static const uint D3DFMT_A16B16G16R16F = 113;
117 static const uint D3DFMT_R32F = 114;
118 static const uint D3DFMT_G32R32F = 115;
119 static const uint D3DFMT_A32B32G32R32F = 116;
120 #endif
121 
122 static const uint DDSD_CAPS = 0x00000001U;
123 static const uint DDSD_PIXELFORMAT = 0x00001000U;
124 static const uint DDSD_WIDTH = 0x00000004U;
125 static const uint DDSD_HEIGHT = 0x00000002U;
126 static const uint DDSD_PITCH = 0x00000008U;
127 static const uint DDSD_MIPMAPCOUNT = 0x00020000U;
128 static const uint DDSD_LINEARSIZE = 0x00080000U;
129 static const uint DDSD_DEPTH = 0x00800000U;
130 
131 static const uint DDSCAPS_COMPLEX = 0x00000008U;
132 static const uint DDSCAPS_TEXTURE = 0x00001000U;
133 static const uint DDSCAPS_MIPMAP = 0x00400000U;
134 static const uint DDSCAPS2_VOLUME = 0x00200000U;
135 static const uint DDSCAPS2_CUBEMAP = 0x00000200U;
136 
137 static const uint DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400U;
138 static const uint DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800U;
139 static const uint DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000U;
140 static const uint DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000U;
141 static const uint DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000U;
142 static const uint DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000U;
143 static const uint DDSCAPS2_CUBEMAP_ALL_FACES = 0x0000FC00U;
144 
145 static const uint DDPF_ALPHAPIXELS = 0x00000001U;
146 static const uint DDPF_ALPHA = 0x00000002U;
147 static const uint DDPF_FOURCC = 0x00000004U;
148 static const uint DDPF_RGB = 0x00000040U;
149 static const uint DDPF_PALETTEINDEXED1 = 0x00000800U;
150 static const uint DDPF_PALETTEINDEXED2 = 0x00001000U;
151 static const uint DDPF_PALETTEINDEXED4 = 0x00000008U;
152 static const uint DDPF_PALETTEINDEXED8 = 0x00000020U;
153 static const uint DDPF_LUMINANCE = 0x00020000U;
154 static const uint DDPF_ALPHAPREMULT = 0x00008000U;
155 
156 /* Custom NVTT flags. */
157 static const uint DDPF_NORMAL = 0x80000000U;
158 static const uint DDPF_SRGB = 0x40000000U;
159 
160 /* DX10 formats. */
163 
168 
173 
180 
185 
190 
194 
196 
203 
210 
216 
221 
227 
235 
242 
244 
246 
249 
253 
257 
261 
265 
269 
274 
280 
284 
288 };
289 
296 };
297 
298 static const char *getDxgiFormatString(DXGI_FORMAT dxgiFormat)
299 {
300 #define CASE(format) \
301  case DXGI_FORMAT_##format: \
302  return #format
303  switch (dxgiFormat) {
304  CASE(UNKNOWN);
305 
306  CASE(R32G32B32A32_TYPELESS);
307  CASE(R32G32B32A32_FLOAT);
308  CASE(R32G32B32A32_UINT);
309  CASE(R32G32B32A32_SINT);
310 
311  CASE(R32G32B32_TYPELESS);
312  CASE(R32G32B32_FLOAT);
313  CASE(R32G32B32_UINT);
314  CASE(R32G32B32_SINT);
315 
316  CASE(R16G16B16A16_TYPELESS);
317  CASE(R16G16B16A16_FLOAT);
318  CASE(R16G16B16A16_UNORM);
319  CASE(R16G16B16A16_UINT);
320  CASE(R16G16B16A16_SNORM);
321  CASE(R16G16B16A16_SINT);
322 
323  CASE(R32G32_TYPELESS);
324  CASE(R32G32_FLOAT);
325  CASE(R32G32_UINT);
326  CASE(R32G32_SINT);
327 
328  CASE(R32G8X24_TYPELESS);
329  CASE(D32_FLOAT_S8X24_UINT);
330  CASE(R32_FLOAT_X8X24_TYPELESS);
331  CASE(X32_TYPELESS_G8X24_UINT);
332 
333  CASE(R10G10B10A2_TYPELESS);
334  CASE(R10G10B10A2_UNORM);
335  CASE(R10G10B10A2_UINT);
336 
337  CASE(R11G11B10_FLOAT);
338 
339  CASE(R8G8B8A8_TYPELESS);
340  CASE(R8G8B8A8_UNORM);
341  CASE(R8G8B8A8_UNORM_SRGB);
342  CASE(R8G8B8A8_UINT);
343  CASE(R8G8B8A8_SNORM);
344  CASE(R8G8B8A8_SINT);
345 
346  CASE(R16G16_TYPELESS);
347  CASE(R16G16_FLOAT);
348  CASE(R16G16_UNORM);
349  CASE(R16G16_UINT);
350  CASE(R16G16_SNORM);
351  CASE(R16G16_SINT);
352 
353  CASE(R32_TYPELESS);
354  CASE(D32_FLOAT);
355  CASE(R32_FLOAT);
356  CASE(R32_UINT);
357  CASE(R32_SINT);
358 
359  CASE(R24G8_TYPELESS);
360  CASE(D24_UNORM_S8_UINT);
361  CASE(R24_UNORM_X8_TYPELESS);
362  CASE(X24_TYPELESS_G8_UINT);
363 
364  CASE(R8G8_TYPELESS);
365  CASE(R8G8_UNORM);
366  CASE(R8G8_UINT);
367  CASE(R8G8_SNORM);
368  CASE(R8G8_SINT);
369 
370  CASE(R16_TYPELESS);
371  CASE(R16_FLOAT);
372  CASE(D16_UNORM);
373  CASE(R16_UNORM);
374  CASE(R16_UINT);
375  CASE(R16_SNORM);
376  CASE(R16_SINT);
377 
378  CASE(R8_TYPELESS);
379  CASE(R8_UNORM);
380  CASE(R8_UINT);
381  CASE(R8_SNORM);
382  CASE(R8_SINT);
383  CASE(A8_UNORM);
384 
385  CASE(R1_UNORM);
386 
387  CASE(R9G9B9E5_SHAREDEXP);
388 
389  CASE(R8G8_B8G8_UNORM);
390  CASE(G8R8_G8B8_UNORM);
391 
392  CASE(BC1_TYPELESS);
393  CASE(BC1_UNORM);
394  CASE(BC1_UNORM_SRGB);
395 
396  CASE(BC2_TYPELESS);
397  CASE(BC2_UNORM);
398  CASE(BC2_UNORM_SRGB);
399 
400  CASE(BC3_TYPELESS);
401  CASE(BC3_UNORM);
402  CASE(BC3_UNORM_SRGB);
403 
404  CASE(BC4_TYPELESS);
405  CASE(BC4_UNORM);
406  CASE(BC4_SNORM);
407 
408  CASE(BC5_TYPELESS);
409  CASE(BC5_UNORM);
410  CASE(BC5_SNORM);
411 
412  CASE(B5G6R5_UNORM);
413  CASE(B5G5R5A1_UNORM);
414  CASE(B8G8R8A8_UNORM);
415  CASE(B8G8R8X8_UNORM);
416 
417  default:
418  return "UNKNOWN";
419  }
420 #undef CASE
421 }
422 
423 static const char *getD3d10ResourceDimensionString(D3D10_RESOURCE_DIMENSION resourceDimension)
424 {
425  switch (resourceDimension) {
426  default:
428  return "UNKNOWN";
430  return "BUFFER";
432  return "TEXTURE1D";
434  return "TEXTURE2D";
436  return "TEXTURE3D";
437  }
438 }
439 
440 /*** implementation ***/
441 
443 {
444  mem_read(mem, pf.size);
445  mem_read(mem, pf.flags);
446  mem_read(mem, pf.fourcc);
447  mem_read(mem, pf.bitcount);
448  mem_read(mem, pf.rmask);
449  mem_read(mem, pf.gmask);
450  mem_read(mem, pf.bmask);
451  mem_read(mem, pf.amask);
452 }
453 
454 void mem_read(Stream &mem, DDSCaps &caps)
455 {
456  mem_read(mem, caps.caps1);
457  mem_read(mem, caps.caps2);
458  mem_read(mem, caps.caps3);
459  mem_read(mem, caps.caps4);
460 }
461 
462 void mem_read(Stream &mem, DDSHeader10 &header)
463 {
464  mem_read(mem, header.dxgiFormat);
465  mem_read(mem, header.resourceDimension);
466  mem_read(mem, header.miscFlag);
467  mem_read(mem, header.arraySize);
468  mem_read(mem, header.reserved);
469 }
470 
471 void mem_read(Stream &mem, DDSHeader &header)
472 {
473  mem_read(mem, header.fourcc);
474  mem_read(mem, header.size);
475  mem_read(mem, header.flags);
476  mem_read(mem, header.height);
477  mem_read(mem, header.width);
478  mem_read(mem, header.pitch);
479  mem_read(mem, header.depth);
480  mem_read(mem, header.mipmapcount);
481  for (uint i = 0; i < 11; i++) {
482  mem_read(mem, header.reserved[i]);
483  }
484  mem_read(mem, header.pf);
485  mem_read(mem, header.caps);
486  mem_read(mem, header.notused);
487 
488  if (header.hasDX10Header()) {
489  mem_read(mem, header.header10);
490  }
491 }
492 
493 namespace {
494 struct FormatDescriptor {
495  uint format;
496  uint bitcount;
497  uint rmask;
498  uint gmask;
499  uint bmask;
500  uint amask;
501 };
502 
503 const FormatDescriptor s_d3dFormats[] = {
504  {D3DFMT_R8G8B8, 24, 0xFF0000, 0xFF00, 0xFF, 0},
505  {D3DFMT_A8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000}, /* DXGI_FORMAT_B8G8R8A8_UNORM */
506  {D3DFMT_X8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0}, /* DXGI_FORMAT_B8G8R8X8_UNORM */
507  {D3DFMT_R5G6B5, 16, 0xF800, 0x7E0, 0x1F, 0}, /* DXGI_FORMAT_B5G6R5_UNORM */
508  {D3DFMT_X1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0},
509  {D3DFMT_A1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0x8000}, /* DXGI_FORMAT_B5G5R5A1_UNORM */
510  {D3DFMT_A4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0xF000},
511  {D3DFMT_R3G3B2, 8, 0xE0, 0x1C, 0x3, 0},
512  {D3DFMT_A8, 8, 0, 0, 0, 8}, /* DXGI_FORMAT_A8_UNORM */
513  {D3DFMT_A8R3G3B2, 16, 0xE0, 0x1C, 0x3, 0xFF00},
514  {D3DFMT_X4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0},
515  {D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000}, /* DXGI_FORMAT_R10G10B10A2 */
516  {D3DFMT_A8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000}, /* DXGI_FORMAT_R8G8B8A8_UNORM */
517  {D3DFMT_X8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0},
518  {D3DFMT_G16R16, 32, 0xFFFF, 0xFFFF0000, 0, 0}, /* DXGI_FORMAT_R16G16_UNORM */
519  {D3DFMT_A2R10G10B10, 32, 0x3FF00000, 0xFFC00, 0x3FF, 0xC0000000},
520  {D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000},
521 
522  {D3DFMT_L8, 8, 8, 0, 0, 0}, /* DXGI_FORMAT_R8_UNORM */
523  {D3DFMT_L16, 16, 16, 0, 0, 0}, /* DXGI_FORMAT_R16_UNORM */
524 };
525 
526 const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]);
527 
528 } /* namespace */
529 
530 static uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
531 {
532  for (int i = 0; i < s_d3dFormatCount; i++) {
533  if (s_d3dFormats[i].bitcount == bitcount && s_d3dFormats[i].rmask == rmask &&
534  s_d3dFormats[i].gmask == gmask && s_d3dFormats[i].bmask == bmask &&
535  s_d3dFormats[i].amask == amask) {
536  return s_d3dFormats[i].format;
537  }
538  }
539 
540  return 0;
541 }
542 
544 {
545  this->fourcc = FOURCC_DDS;
546  this->size = 124;
547  this->flags = (DDSD_CAPS | DDSD_PIXELFORMAT);
548  this->height = 0;
549  this->width = 0;
550  this->pitch = 0;
551  this->depth = 0;
552  this->mipmapcount = 0;
553  for (uint i = 0; i < 11; i++) {
554  this->reserved[i] = 0;
555  }
556 
557  /* Store version information on the reserved header attributes. */
558  this->reserved[9] = FOURCC_NVTT;
559  this->reserved[10] = (2 << 16) | (1 << 8) | (0); /* major.minor.revision */
560 
561  this->pf.size = 32;
562  this->pf.flags = 0;
563  this->pf.fourcc = 0;
564  this->pf.bitcount = 0;
565  this->pf.rmask = 0;
566  this->pf.gmask = 0;
567  this->pf.bmask = 0;
568  this->pf.amask = 0;
569  this->caps.caps1 = DDSCAPS_TEXTURE;
570  this->caps.caps2 = 0;
571  this->caps.caps3 = 0;
572  this->caps.caps4 = 0;
573  this->notused = 0;
574 
577  this->header10.miscFlag = 0;
578  this->header10.arraySize = 0;
579  this->header10.reserved = 0;
580 }
581 
583 {
584  this->flags |= DDSD_WIDTH;
585  this->width = w;
586 }
587 
589 {
590  this->flags |= DDSD_HEIGHT;
591  this->height = h;
592 }
593 
595 {
596  this->flags |= DDSD_DEPTH;
597  this->depth = d;
598 }
599 
601 {
602  if (ELEM(count, 0, 1)) {
603  this->flags &= ~DDSD_MIPMAPCOUNT;
604  this->mipmapcount = 1;
605 
606  if (this->caps.caps2 == 0) {
607  this->caps.caps1 = DDSCAPS_TEXTURE;
608  }
609  else {
611  }
612  }
613  else {
614  this->flags |= DDSD_MIPMAPCOUNT;
615  this->mipmapcount = count;
616 
618  }
619 }
620 
622 {
624  this->header10.arraySize = 1;
625 }
626 
628 {
629  this->caps.caps2 = DDSCAPS2_VOLUME;
630 
632  this->header10.arraySize = 1;
633 }
634 
636 {
637  this->caps.caps1 |= DDSCAPS_COMPLEX;
639 
641  this->header10.arraySize = 6;
642 }
643 
645 {
646  this->flags &= ~DDSD_PITCH;
647  this->flags |= DDSD_LINEARSIZE;
648  this->pitch = size;
649 }
650 
652 {
653  this->flags &= ~DDSD_LINEARSIZE;
654  this->flags |= DDSD_PITCH;
655  this->pitch = pitch;
656 }
657 
659 {
660  /* set fourcc pixel format. */
661  this->pf.flags = DDPF_FOURCC;
662  this->pf.fourcc = DDS_MAKEFOURCC(c0, c1, c2, c3);
663 
664  this->pf.bitcount = 0;
665  this->pf.rmask = 0;
666  this->pf.gmask = 0;
667  this->pf.bmask = 0;
668  this->pf.amask = 0;
669 }
670 
672 {
673  /* set fourcc pixel format. */
674  this->pf.flags = DDPF_FOURCC;
675  this->pf.fourcc = code;
676 
677  this->pf.bitcount = 0;
678  this->pf.rmask = 0;
679  this->pf.gmask = 0;
680  this->pf.bmask = 0;
681  this->pf.amask = 0;
682 }
683 
685 {
686  this->pf.bitcount = DDS_MAKEFOURCC(c0, c1, c2, c3);
687 }
688 
689 void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
690 {
691  /* Make sure the masks are correct. */
692  if ((rmask & gmask) || (rmask & bmask) || (rmask & amask) || (gmask & bmask) ||
693  (gmask & amask) || (bmask & amask)) {
694  printf("DDS: bad RGBA masks, pixel format not set\n");
695  return;
696  }
697 
698  if (rmask != 0 || gmask != 0 || bmask != 0) {
699  if (gmask == 0 && bmask == 0) {
700  this->pf.flags = DDPF_LUMINANCE;
701  }
702  else {
703  this->pf.flags = DDPF_RGB;
704  }
705 
706  if (amask != 0) {
707  this->pf.flags |= DDPF_ALPHAPIXELS;
708  }
709  }
710  else if (amask != 0) {
711  this->pf.flags |= DDPF_ALPHA;
712  }
713 
714  if (bitcount == 0) {
715  /* Compute bit count from the masks. */
716  uint total = rmask | gmask | bmask | amask;
717  while (total != 0) {
718  bitcount++;
719  total >>= 1;
720  }
721  }
722 
723  /* D3DX functions do not like this: */
724  this->pf.fourcc = 0; // findD3D9Format(bitcount, rmask, gmask, bmask, amask);
725 #if 0
726  if (this->pf.fourcc) {
727  this->pf.flags |= DDPF_FOURCC;
728  }
729 #endif
730 
731  if (!(bitcount > 0 && bitcount <= 32)) {
732  printf("DDS: bad bit count, pixel format not set\n");
733  return;
734  }
735  this->pf.bitcount = bitcount;
736  this->pf.rmask = rmask;
737  this->pf.gmask = gmask;
738  this->pf.bmask = bmask;
739  this->pf.amask = amask;
740 }
741 
743 {
744  // this->pf.flags = 0;
745  this->pf.fourcc = FOURCC_DX10;
746  this->header10.dxgiFormat = format;
747 }
748 
750 {
751  if (b) {
752  this->pf.flags |= DDPF_NORMAL;
753  }
754  else {
755  this->pf.flags &= ~DDPF_NORMAL;
756  }
757 }
758 
760 {
761  if (b) {
762  this->pf.flags |= DDPF_SRGB;
763  }
764  else {
765  this->pf.flags &= ~DDPF_SRGB;
766  }
767 }
768 
770 {
771  if (b) {
772  this->pf.flags |= DDPF_ALPHAPIXELS;
773  }
774  else {
775  this->pf.flags &= ~DDPF_ALPHAPIXELS;
776  }
777 }
778 
779 void DDSHeader::setUserVersion(int version)
780 {
781  this->reserved[7] = FOURCC_UVER;
782  this->reserved[8] = version;
783 }
784 
785 #if 0
786 void DDSHeader::swapBytes()
787 {
788  this->fourcc = POSH_LittleU32(this->fourcc);
789  this->size = POSH_LittleU32(this->size);
790  this->flags = POSH_LittleU32(this->flags);
791  this->height = POSH_LittleU32(this->height);
792  this->width = POSH_LittleU32(this->width);
793  this->pitch = POSH_LittleU32(this->pitch);
794  this->depth = POSH_LittleU32(this->depth);
795  this->mipmapcount = POSH_LittleU32(this->mipmapcount);
796 
797  for (int i = 0; i < 11; i++) {
798  this->reserved[i] = POSH_LittleU32(this->reserved[i]);
799  }
800 
801  this->pf.size = POSH_LittleU32(this->pf.size);
802  this->pf.flags = POSH_LittleU32(this->pf.flags);
803  this->pf.fourcc = POSH_LittleU32(this->pf.fourcc);
804  this->pf.bitcount = POSH_LittleU32(this->pf.bitcount);
805  this->pf.rmask = POSH_LittleU32(this->pf.rmask);
806  this->pf.gmask = POSH_LittleU32(this->pf.gmask);
807  this->pf.bmask = POSH_LittleU32(this->pf.bmask);
808  this->pf.amask = POSH_LittleU32(this->pf.amask);
809  this->caps.caps1 = POSH_LittleU32(this->caps.caps1);
810  this->caps.caps2 = POSH_LittleU32(this->caps.caps2);
811  this->caps.caps3 = POSH_LittleU32(this->caps.caps3);
812  this->caps.caps4 = POSH_LittleU32(this->caps.caps4);
813  this->notused = POSH_LittleU32(this->notused);
814 
815  this->header10.dxgiFormat = POSH_LittleU32(this->header10.dxgiFormat);
816  this->header10.resourceDimension = POSH_LittleU32(this->header10.resourceDimension);
817  this->header10.miscFlag = POSH_LittleU32(this->header10.miscFlag);
818  this->header10.arraySize = POSH_LittleU32(this->header10.arraySize);
819  this->header10.reserved = POSH_LittleU32(this->header10.reserved);
820 }
821 #endif
822 
824 {
825  return this->pf.fourcc == FOURCC_DX10;
826 }
827 
829 {
830  return this->reserved[9];
831 }
832 
834 {
835  return this->reserved[10];
836 }
837 
839 {
840  if (this->reserved[7] == FOURCC_UVER) {
841  return this->reserved[8];
842  }
843  return 0;
844 }
845 
847 {
848  return (pf.flags & DDPF_NORMAL) != 0;
849 }
850 
851 bool DDSHeader::isSrgb() const
852 {
853  return (pf.flags & DDPF_SRGB) != 0;
854 }
855 
857 {
858  return (pf.flags & DDPF_ALPHAPIXELS) != 0;
859 }
860 
862 {
863  if (pf.flags & DDPF_FOURCC) {
864  return pf.fourcc;
865  }
866 
868 }
869 
870 DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header()
871 {
872  mem_read(stream, header);
873 
874  /* Some ATI2 compressed normal maps do not have their
875  * normal flag set, so force it here (the original nvtt don't do
876  * this, but the decompressor has a -forcenormal flag). */
877  if (header.pf.fourcc == FOURCC_ATI2) {
878  header.setNormalFlag(true);
879  }
880 }
881 
883 {
884  if (header.fourcc != FOURCC_DDS || header.size != 124) {
885  return false;
886  }
887 
888  const uint required = (DDSD_WIDTH | DDSD_HEIGHT /*|DDSD_CAPS|DDSD_PIXELFORMAT*/);
889  if ((header.flags & required) != required) {
890  return false;
891  }
892 
893  if (header.pf.size != 32) {
894  return false;
895  }
896 
897  /* in some files DDSCAPS_TEXTURE is missing: silently ignore */
898 #if 0
899  if (!(header.caps.caps1 & DDSCAPS_TEXTURE)) {
900  return false;
901  }
902 #endif
903 
904  return true;
905 }
906 
908 {
909  if (header.hasDX10Header()) {
910  if (ELEM(header.header10.dxgiFormat,
916  return true;
917  }
918 
919  return false;
920  }
921 
922  if (header.pf.flags & DDPF_FOURCC) {
923  if (!ELEM(header.pf.fourcc,
924  FOURCC_DXT1,
925  FOURCC_DXT2,
926  FOURCC_DXT3,
927  FOURCC_DXT4,
928  FOURCC_DXT5,
929  FOURCC_RXGB,
930  FOURCC_ATI1,
931  FOURCC_ATI2)) {
932  /* Unknown fourcc code. */
933  return false;
934  }
935  }
936  else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE)) {
937  /* All RGB and luminance formats are supported now. */
938  }
939  else {
940  return false;
941  }
942 
943  if (isTextureCube() &&
945  /* Cubemaps must contain all faces. */
946  return false;
947  }
948 
949  if (isTexture3D()) {
950  /* @@ 3D textures not supported yet. */
951  return false;
952  }
953 
954  return true;
955 }
956 
958 {
959  if (header.hasDX10Header()) {
960  /* TODO: Update hasAlpha to handle all DX10 formats. */
961  return header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM ||
964  }
965 
966  if (header.pf.flags & DDPF_RGB) {
967  return header.pf.amask != 0;
968  }
969  if (header.pf.flags & DDPF_FOURCC) {
970  if (header.pf.fourcc == FOURCC_RXGB || header.pf.fourcc == FOURCC_ATI1 ||
971  header.pf.fourcc == FOURCC_ATI2 || header.pf.flags & DDPF_NORMAL) {
972  return false;
973  }
974 
975  /* @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?) */
976  return true;
977  }
978 
979  return false;
980 }
981 
983 {
984  if (header.flags & DDSD_MIPMAPCOUNT) {
985  return header.mipmapcount;
986  }
987 
988  return 1;
989 }
990 
992 {
993  return header.pf.fourcc;
994 }
995 
997 {
998  if (header.flags & DDSD_WIDTH) {
999  return header.width;
1000  }
1001 
1002  return 1;
1003 }
1004 
1006 {
1007  if (header.flags & DDSD_HEIGHT) {
1008  return header.height;
1009  }
1010 
1011  return 1;
1012 }
1013 
1015 {
1016  if (header.flags & DDSD_DEPTH) {
1017  return header.depth;
1018  }
1019 
1020  return 1;
1021 }
1022 
1024 {
1025  if (header.hasDX10Header()) {
1027  }
1028  return false;
1029 }
1030 
1032 {
1033  if (header.hasDX10Header()) {
1035  }
1036 
1037  return !isTexture3D() && !isTextureCube();
1038 }
1039 
1041 {
1042  if (header.hasDX10Header()) {
1044  }
1045 
1046  return (header.caps.caps2 & DDSCAPS2_VOLUME) != 0;
1047 }
1048 
1050 {
1051  return (header.caps.caps2 & DDSCAPS2_CUBEMAP) != 0;
1052 }
1053 
1055 {
1056  header.setNormalFlag(b);
1057 }
1058 
1060 {
1061  header.setHasAlphaFlag(b);
1062 }
1063 
1065 {
1066  header.setUserVersion(version);
1067 }
1068 
1069 void DirectDrawSurface::mipmap(Image *img, uint face, uint mipmap)
1070 {
1071  stream.seek(offset(face, mipmap));
1072 
1073  uint w = width();
1074  uint h = height();
1075 
1076  /* Compute width and height. */
1077  for (uint m = 0; m < mipmap; m++) {
1078  w = MAX(1U, w / 2);
1079  h = MAX(1U, h / 2);
1080  }
1081 
1082  img->allocate(w, h);
1083 
1084  if (hasAlpha()) {
1086  }
1087  else {
1089  }
1090 
1091  if (header.hasDX10Header()) {
1092  /* So far only block formats supported. */
1093  readBlockImage(img);
1094  }
1095  else {
1096  if (header.pf.flags & DDPF_RGB) {
1097  readLinearImage(img);
1098  }
1099  else if (header.pf.flags & DDPF_FOURCC) {
1100  readBlockImage(img);
1101  }
1102  }
1103 }
1104 
1106 {
1107  uint header_size = 128; // sizeof(DDSHeader);
1108  if (header.hasDX10Header()) {
1109  header_size += 20; // sizeof(DDSHeader10);
1110  }
1111 
1112  uint size = stream.size - header_size;
1113  rsize = size;
1114 
1115  unsigned char *data = (unsigned char *)malloc(sizeof(*data) * size);
1116 
1117  stream.seek(header_size);
1118  mem_read(stream, data, size);
1119 
1120  if (stream.failed) {
1121  free(data);
1122  data = nullptr;
1123  rsize = 0;
1124  }
1125 
1126  /* Maybe check if size == rsize? assert() isn't in this scope. */
1127 
1128  return data;
1129 }
1130 
1131 void DirectDrawSurface::readLinearImage(Image *img)
1132 {
1133 
1134  const uint w = img->width();
1135  const uint h = img->height();
1136 
1137  uint rshift, rsize;
1138  PixelFormat::maskShiftAndSize(header.pf.rmask, &rshift, &rsize);
1139 
1140  uint gshift, gsize;
1141  PixelFormat::maskShiftAndSize(header.pf.gmask, &gshift, &gsize);
1142 
1143  uint bshift, bsize;
1144  PixelFormat::maskShiftAndSize(header.pf.bmask, &bshift, &bsize);
1145 
1146  uint ashift, asize;
1147  PixelFormat::maskShiftAndSize(header.pf.amask, &ashift, &asize);
1148 
1149  uint byteCount = (header.pf.bitcount + 7) / 8;
1150 
1151  if (byteCount > 4) {
1152  /* just in case... we could have segfaults later on if byteCount > 4 */
1153  printf("DDS: bitcount too large");
1154  return;
1155  }
1156 
1157  /* Read linear RGB images. */
1158  for (uint y = 0; y < h; y++) {
1159  for (uint x = 0; x < w; x++) {
1160  uint c = 0;
1161  mem_read(stream, (unsigned char *)(&c), byteCount);
1162 
1163  Color32 pixel(0, 0, 0, 0xFF);
1164  pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8);
1165  pixel.g = PixelFormat::convert((c & header.pf.gmask) >> gshift, gsize, 8);
1166  pixel.b = PixelFormat::convert((c & header.pf.bmask) >> bshift, bsize, 8);
1167  pixel.a = PixelFormat::convert((c & header.pf.amask) >> ashift, asize, 8);
1168 
1169  img->pixel(x, y) = pixel;
1170  }
1171  }
1172 }
1173 
1174 void DirectDrawSurface::readBlockImage(Image *img)
1175 {
1176 
1177  const uint w = img->width();
1178  const uint h = img->height();
1179 
1180  const uint bw = (w + 3) / 4;
1181  const uint bh = (h + 3) / 4;
1182 
1183  for (uint by = 0; by < bh; by++) {
1184  for (uint bx = 0; bx < bw; bx++) {
1185  ColorBlock block;
1186 
1187  /* Read color block. */
1188  readBlock(&block);
1189 
1190  /* Write color block. */
1191  for (uint y = 0; y < MIN(4U, h - 4 * by); y++) {
1192  for (uint x = 0; x < MIN(4U, w - 4 * bx); x++) {
1193  img->pixel(4 * bx + x, 4 * by + y) = block.color(x, y);
1194  }
1195  }
1196  }
1197  }
1198 }
1199 
1201 {
1202  float nx = 2 * (x / 255.0f) - 1;
1203  float ny = 2 * (y / 255.0f) - 1;
1204  float nz = 0.0f;
1205  if (1 - nx * nx - ny * ny > 0) {
1206  nz = sqrt(1 - nx * nx - ny * ny);
1207  }
1208  uint8 z = CLAMP(int(255.0f * (nz + 1) / 2.0f), 0, 255);
1209 
1210  return Color32(x, y, z);
1211 }
1212 
1213 void DirectDrawSurface::readBlock(ColorBlock *rgba)
1214 {
1215  uint fourcc = header.pf.fourcc;
1216 
1217  /* Map DX10 block formats to fourcc codes. */
1218  if (header.hasDX10Header()) {
1219  if (header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM) {
1220  fourcc = FOURCC_DXT1;
1221  }
1222  if (header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM) {
1223  fourcc = FOURCC_DXT3;
1224  }
1225  if (header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM) {
1226  fourcc = FOURCC_DXT5;
1227  }
1228  if (header.header10.dxgiFormat == DXGI_FORMAT_BC4_UNORM) {
1229  fourcc = FOURCC_ATI1;
1230  }
1231  if (header.header10.dxgiFormat == DXGI_FORMAT_BC5_UNORM) {
1232  fourcc = FOURCC_ATI2;
1233  }
1234  }
1235 
1236  if (fourcc == FOURCC_DXT1) {
1237  BlockDXT1 block;
1238  mem_read(stream, block);
1239  block.decodeBlock(rgba);
1240  }
1241  else if (fourcc == FOURCC_DXT2 || header.pf.fourcc == FOURCC_DXT3) {
1242  BlockDXT3 block;
1243  mem_read(stream, block);
1244  block.decodeBlock(rgba);
1245  }
1246  else if (fourcc == FOURCC_DXT4 || header.pf.fourcc == FOURCC_DXT5 ||
1247  header.pf.fourcc == FOURCC_RXGB) {
1248  BlockDXT5 block;
1249  mem_read(stream, block);
1250  block.decodeBlock(rgba);
1251 
1252  if (fourcc == FOURCC_RXGB) {
1253  /* Swap R & A. */
1254  for (int i = 0; i < 16; i++) {
1255  Color32 &c = rgba->color(i);
1256  uint tmp = c.r;
1257  c.r = c.a;
1258  c.a = tmp;
1259  }
1260  }
1261  }
1262  else if (fourcc == FOURCC_ATI1) {
1263  BlockATI1 block;
1264  mem_read(stream, block);
1265  block.decodeBlock(rgba);
1266  }
1267  else if (fourcc == FOURCC_ATI2) {
1268  BlockATI2 block;
1269  mem_read(stream, block);
1270  block.decodeBlock(rgba);
1271  }
1272 
1273  /* If normal flag set, convert to normal. */
1274  if (header.pf.flags & DDPF_NORMAL) {
1275  if (fourcc == FOURCC_ATI2) {
1276  for (int i = 0; i < 16; i++) {
1277  Color32 &c = rgba->color(i);
1278  c = buildNormal(c.r, c.g);
1279  }
1280  }
1281  else if (fourcc == FOURCC_DXT5) {
1282  for (int i = 0; i < 16; i++) {
1283  Color32 &c = rgba->color(i);
1284  c = buildNormal(c.a, c.g);
1285  }
1286  }
1287  }
1288 }
1289 
1290 uint DirectDrawSurface::blockSize() const
1291 {
1292  switch (header.pf.fourcc) {
1293  case FOURCC_DXT1:
1294  case FOURCC_ATI1:
1295  return 8;
1296  case FOURCC_DXT2:
1297  case FOURCC_DXT3:
1298  case FOURCC_DXT4:
1299  case FOURCC_DXT5:
1300  case FOURCC_RXGB:
1301  case FOURCC_ATI2:
1302  return 16;
1303  case FOURCC_DX10:
1304  switch (header.header10.dxgiFormat) {
1306  case DXGI_FORMAT_BC1_UNORM:
1309  case DXGI_FORMAT_BC4_UNORM:
1310  case DXGI_FORMAT_BC4_SNORM:
1311  return 8;
1313  case DXGI_FORMAT_BC2_UNORM:
1316  case DXGI_FORMAT_BC3_UNORM:
1319  case DXGI_FORMAT_BC5_UNORM:
1320  case DXGI_FORMAT_BC5_SNORM:
1321  return 16;
1322  }
1323  }
1324 
1325  /* Not a block image. */
1326  return 0;
1327 }
1328 
1329 uint DirectDrawSurface::mipmapSize(uint mipmap) const
1330 {
1331  uint w = width();
1332  uint h = height();
1333  uint d = depth();
1334 
1335  for (uint m = 0; m < mipmap; m++) {
1336  w = MAX(1U, w / 2);
1337  h = MAX(1U, h / 2);
1338  d = MAX(1U, d / 2);
1339  }
1340 
1341  if (header.pf.flags & DDPF_FOURCC) {
1342  /* @@ How are 3D textures aligned? */
1343  w = (w + 3) / 4;
1344  h = (h + 3) / 4;
1345  return blockSize() * w * h;
1346  }
1347  if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE)) {
1348  /* Assuming 8 bit alignment, which is the same D3DX expects. */
1349  uint pitch = computePitch(w, header.pf.bitcount, 8);
1350 
1351  return pitch * h * d;
1352  }
1353 
1354  printf("DDS: mipmap format not supported\n");
1355  return 0;
1356 }
1357 
1358 uint DirectDrawSurface::faceSize() const
1359 {
1360  const uint count = mipmapCount();
1361  uint size = 0;
1362 
1363  for (uint m = 0; m < count; m++) {
1364  size += mipmapSize(m);
1365  }
1366 
1367  return size;
1368 }
1369 
1370 uint DirectDrawSurface::offset(const uint face, const uint mipmap)
1371 {
1372  uint size = 128; // sizeof(DDSHeader);
1373 
1374  if (header.hasDX10Header()) {
1375  size += 20; // sizeof(DDSHeader10);
1376  }
1377 
1378  if (face != 0) {
1379  size += face * faceSize();
1380  }
1381 
1382  for (uint m = 0; m < mipmap; m++) {
1383  size += mipmapSize(m);
1384  }
1385 
1386  return size;
1387 }
1388 
1390 {
1391  printf("Flags: 0x%.8X\n", header.flags);
1392  if (header.flags & DDSD_CAPS) {
1393  printf("\tDDSD_CAPS\n");
1394  }
1395  if (header.flags & DDSD_PIXELFORMAT) {
1396  printf("\tDDSD_PIXELFORMAT\n");
1397  }
1398  if (header.flags & DDSD_WIDTH) {
1399  printf("\tDDSD_WIDTH\n");
1400  }
1401  if (header.flags & DDSD_HEIGHT) {
1402  printf("\tDDSD_HEIGHT\n");
1403  }
1404  if (header.flags & DDSD_DEPTH) {
1405  printf("\tDDSD_DEPTH\n");
1406  }
1407  if (header.flags & DDSD_PITCH) {
1408  printf("\tDDSD_PITCH\n");
1409  }
1410  if (header.flags & DDSD_LINEARSIZE) {
1411  printf("\tDDSD_LINEARSIZE\n");
1412  }
1413  if (header.flags & DDSD_MIPMAPCOUNT) {
1414  printf("\tDDSD_MIPMAPCOUNT\n");
1415  }
1416 
1417  printf("Height: %u\n", header.height);
1418  printf("Width: %u\n", header.width);
1419  printf("Depth: %u\n", header.depth);
1420  if (header.flags & DDSD_PITCH) {
1421  printf("Pitch: %u\n", header.pitch);
1422  }
1423  else if (header.flags & DDSD_LINEARSIZE) {
1424  printf("Linear size: %u\n", header.pitch);
1425  }
1426  printf("Mipmap count: %u\n", header.mipmapcount);
1427 
1428  printf("Pixel Format:\n");
1429  printf("\tFlags: 0x%.8X\n", header.pf.flags);
1430  if (header.pf.flags & DDPF_RGB) {
1431  printf("\t\tDDPF_RGB\n");
1432  }
1433  if (header.pf.flags & DDPF_LUMINANCE) {
1434  printf("\t\tDDPF_LUMINANCE\n");
1435  }
1436  if (header.pf.flags & DDPF_FOURCC) {
1437  printf("\t\tDDPF_FOURCC\n");
1438  }
1439  if (header.pf.flags & DDPF_ALPHAPIXELS) {
1440  printf("\t\tDDPF_ALPHAPIXELS\n");
1441  }
1442  if (header.pf.flags & DDPF_ALPHA) {
1443  printf("\t\tDDPF_ALPHA\n");
1444  }
1445  if (header.pf.flags & DDPF_PALETTEINDEXED1) {
1446  printf("\t\tDDPF_PALETTEINDEXED1\n");
1447  }
1448  if (header.pf.flags & DDPF_PALETTEINDEXED2) {
1449  printf("\t\tDDPF_PALETTEINDEXED2\n");
1450  }
1451  if (header.pf.flags & DDPF_PALETTEINDEXED4) {
1452  printf("\t\tDDPF_PALETTEINDEXED4\n");
1453  }
1454  if (header.pf.flags & DDPF_PALETTEINDEXED8) {
1455  printf("\t\tDDPF_PALETTEINDEXED8\n");
1456  }
1457  if (header.pf.flags & DDPF_ALPHAPREMULT) {
1458  printf("\t\tDDPF_ALPHAPREMULT\n");
1459  }
1460  if (header.pf.flags & DDPF_NORMAL) {
1461  printf("\t\tDDPF_NORMAL\n");
1462  }
1463 
1464  if (header.pf.fourcc != 0) {
1465  /* Display fourcc code even when DDPF_FOURCC flag not set. */
1466  printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n",
1467  (int)((header.pf.fourcc >> 0) & 0xFF),
1468  (int)((header.pf.fourcc >> 8) & 0xFF),
1469  (int)((header.pf.fourcc >> 16) & 0xFF),
1470  (int)((header.pf.fourcc >> 24) & 0xFF),
1471  header.pf.fourcc);
1472  }
1473 
1474  if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0)) {
1475  printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n",
1476  (int)(header.pf.bitcount >> 0) & 0xFF,
1477  (int)(header.pf.bitcount >> 8) & 0xFF,
1478  (int)(header.pf.bitcount >> 16) & 0xFF,
1479  (int)(header.pf.bitcount >> 24) & 0xFF,
1480  header.pf.bitcount);
1481  }
1482  else {
1483  printf("\tBit count: %u\n", header.pf.bitcount);
1484  }
1485 
1486  printf("\tRed mask: 0x%.8X\n", header.pf.rmask);
1487  printf("\tGreen mask: 0x%.8X\n", header.pf.gmask);
1488  printf("\tBlue mask: 0x%.8X\n", header.pf.bmask);
1489  printf("\tAlpha mask: 0x%.8X\n", header.pf.amask);
1490 
1491  printf("Caps:\n");
1492  printf("\tCaps 1: 0x%.8X\n", header.caps.caps1);
1493  if (header.caps.caps1 & DDSCAPS_COMPLEX) {
1494  printf("\t\tDDSCAPS_COMPLEX\n");
1495  }
1496  if (header.caps.caps1 & DDSCAPS_TEXTURE) {
1497  printf("\t\tDDSCAPS_TEXTURE\n");
1498  }
1499  if (header.caps.caps1 & DDSCAPS_MIPMAP) {
1500  printf("\t\tDDSCAPS_MIPMAP\n");
1501  }
1502 
1503  printf("\tCaps 2: 0x%.8X\n", header.caps.caps2);
1504  if (header.caps.caps2 & DDSCAPS2_VOLUME) {
1505  printf("\t\tDDSCAPS2_VOLUME\n");
1506  }
1507  else if (header.caps.caps2 & DDSCAPS2_CUBEMAP) {
1508  printf("\t\tDDSCAPS2_CUBEMAP\n");
1510  printf("\t\tDDSCAPS2_CUBEMAP_ALL_FACES\n");
1511  }
1512  else {
1513  if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEX) {
1514  printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEX\n");
1515  }
1516  if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) {
1517  printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEX\n");
1518  }
1519  if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEY) {
1520  printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEY\n");
1521  }
1522  if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) {
1523  printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEY\n");
1524  }
1525  if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) {
1526  printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEZ\n");
1527  }
1528  if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) {
1529  printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEZ\n");
1530  }
1531  }
1532  }
1533 
1534  printf("\tCaps 3: 0x%.8X\n", header.caps.caps3);
1535  printf("\tCaps 4: 0x%.8X\n", header.caps.caps4);
1536 
1537  if (header.hasDX10Header()) {
1538  printf("DX10 Header:\n");
1539  printf("\tDXGI Format: %u (%s)\n",
1540  header.header10.dxgiFormat,
1542  printf("\tResource dimension: %u (%s)\n",
1543  header.header10.resourceDimension,
1546  printf("\tMisc flag: %u\n", header.header10.miscFlag);
1547  printf("\tArray size: %u\n", header.header10.arraySize);
1548  }
1549 
1550  if (header.reserved[9] == FOURCC_NVTT) {
1551  int major = (header.reserved[10] >> 16) & 0xFF;
1552  int minor = (header.reserved[10] >> 8) & 0xFF;
1553  int revision = header.reserved[10] & 0xFF;
1554 
1555  printf("Version:\n");
1556  printf("\tNVIDIA Texture Tools %d.%d.%d\n", major, minor, revision);
1557  }
1558 
1559  if (header.reserved[7] == FOURCC_UVER) {
1560  printf("User Version: %u\n", header.reserved[8]);
1561  }
1562 }
sqrt(x)+1/max(0
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
unsigned int uint
Definition: BLI_sys_types.h:67
#define ELEM(...)
unsigned int uint32
Definition: Common.h:29
uint computePitch(uint w, uint bitsize, uint alignment)
Definition: Common.h:33
#define MIN(a, b)
Definition: Common.h:10
unsigned char uint8
Definition: Common.h:26
#define MAX(a, b)
Definition: Common.h:13
static const uint D3DFMT_L16
void mem_read(Stream &mem, DDSPixelFormat &pf)
static const uint DDSCAPS2_CUBEMAP_POSITIVEX
static const uint DDSCAPS2_VOLUME
static const uint D3DFMT_R5G6B5
static const uint DDPF_PALETTEINDEXED1
static const uint DDSD_LINEARSIZE
static const uint DDSCAPS2_CUBEMAP_POSITIVEY
static const uint FOURCC_UVER
static const uint D3DFMT_R8G8B8
static const uint DDPF_PALETTEINDEXED4
static const uint FOURCC_DX10
static const uint D3DFMT_X8B8G8R8
static const uint FOURCC_DXT2
static const uint DDSD_WIDTH
static const uint DDPF_RGB
static const uint FOURCC_DXT3
static const uint DDPF_PALETTEINDEXED2
static uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
static const uint FOURCC_RXGB
#define CASE(format)
static const uint DDPF_SRGB
@ DXGI_FORMAT_R16_UINT
@ DXGI_FORMAT_B8G8R8A8_UNORM
@ DXGI_FORMAT_R8_TYPELESS
@ DXGI_FORMAT_BC3_UNORM_SRGB
@ DXGI_FORMAT_R8G8_B8G8_UNORM
@ DXGI_FORMAT_R32G32B32_TYPELESS
@ DXGI_FORMAT_BC3_TYPELESS
@ DXGI_FORMAT_R16G16_SNORM
@ DXGI_FORMAT_D32_FLOAT_S8X24_UINT
@ DXGI_FORMAT_R32G32B32A32_SINT
@ DXGI_FORMAT_BC5_UNORM
@ DXGI_FORMAT_BC1_UNORM
@ DXGI_FORMAT_R8G8_UINT
@ DXGI_FORMAT_R32G32B32A32_UINT
@ DXGI_FORMAT_R16G16B16A16_SNORM
@ DXGI_FORMAT_R32_FLOAT
@ DXGI_FORMAT_R16G16B16A16_UNORM
@ DXGI_FORMAT_R32_SINT
@ DXGI_FORMAT_R8G8_UNORM
@ DXGI_FORMAT_R16G16_UNORM
@ DXGI_FORMAT_BC1_UNORM_SRGB
@ DXGI_FORMAT_R16G16_SINT
@ DXGI_FORMAT_R24_UNORM_X8_TYPELESS
@ DXGI_FORMAT_R8G8B8A8_TYPELESS
@ DXGI_FORMAT_BC2_TYPELESS
@ DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
@ DXGI_FORMAT_R32G32B32_FLOAT
@ DXGI_FORMAT_R32G32B32_SINT
@ DXGI_FORMAT_R32G32B32A32_TYPELESS
@ DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
@ DXGI_FORMAT_B8G8R8X8_TYPELESS
@ DXGI_FORMAT_B8G8R8A8_TYPELESS
@ DXGI_FORMAT_UNKNOWN
@ DXGI_FORMAT_X24_TYPELESS_G8_UINT
@ DXGI_FORMAT_R16_SINT
@ DXGI_FORMAT_R1_UNORM
@ DXGI_FORMAT_R16G16B16A16_UINT
@ DXGI_FORMAT_R16_UNORM
@ DXGI_FORMAT_R8G8B8A8_SINT
@ DXGI_FORMAT_D24_UNORM_S8_UINT
@ DXGI_FORMAT_R8G8B8A8_SNORM
@ DXGI_FORMAT_A8_UNORM
@ DXGI_FORMAT_R8G8B8A8_UINT
@ DXGI_FORMAT_R10G10B10A2_TYPELESS
@ DXGI_FORMAT_R32G32_FLOAT
@ DXGI_FORMAT_BC6H_UF16
@ DXGI_FORMAT_BC6H_SF16
@ DXGI_FORMAT_R10G10B10A2_UNORM
@ DXGI_FORMAT_R8_SNORM
@ DXGI_FORMAT_R9G9B9E5_SHAREDEXP
@ DXGI_FORMAT_R16G16B16A16_TYPELESS
@ DXGI_FORMAT_R16G16B16A16_FLOAT
@ DXGI_FORMAT_BC7_TYPELESS
@ DXGI_FORMAT_R32_TYPELESS
@ DXGI_FORMAT_R8_UNORM
@ DXGI_FORMAT_R32G32_UINT
@ DXGI_FORMAT_R11G11B10_FLOAT
@ DXGI_FORMAT_R8G8B8A8_UNORM
@ DXGI_FORMAT_G8R8_G8B8_UNORM
@ DXGI_FORMAT_D16_UNORM
@ DXGI_FORMAT_R16_FLOAT
@ DXGI_FORMAT_R10G10B10A2_UINT
@ DXGI_FORMAT_BC6H_TYPELESS
@ DXGI_FORMAT_BC7_UNORM
@ DXGI_FORMAT_BC5_TYPELESS
@ DXGI_FORMAT_R32G32_SINT
@ DXGI_FORMAT_BC2_UNORM_SRGB
@ DXGI_FORMAT_R16_SNORM
@ DXGI_FORMAT_R8_SINT
@ DXGI_FORMAT_BC5_SNORM
@ DXGI_FORMAT_R32_UINT
@ DXGI_FORMAT_BC4_TYPELESS
@ DXGI_FORMAT_R32G32B32A32_FLOAT
@ DXGI_FORMAT_R24G8_TYPELESS
@ DXGI_FORMAT_R8G8_SINT
@ DXGI_FORMAT_R16_TYPELESS
@ DXGI_FORMAT_BC3_UNORM
@ DXGI_FORMAT_R32G32B32_UINT
@ DXGI_FORMAT_R16G16_TYPELESS
@ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
@ DXGI_FORMAT_R16G16_UINT
@ DXGI_FORMAT_D32_FLOAT
@ DXGI_FORMAT_R8G8_TYPELESS
@ DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
@ DXGI_FORMAT_R16G16B16A16_SINT
@ DXGI_FORMAT_BC1_TYPELESS
@ DXGI_FORMAT_BC7_UNORM_SRGB
@ DXGI_FORMAT_BC2_UNORM
@ DXGI_FORMAT_R32G32_TYPELESS
@ DXGI_FORMAT_R32G8X24_TYPELESS
@ DXGI_FORMAT_R16G16_FLOAT
@ DXGI_FORMAT_B5G6R5_UNORM
@ DXGI_FORMAT_BC4_UNORM
@ DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
@ DXGI_FORMAT_R8G8_SNORM
@ DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
@ DXGI_FORMAT_R8_UINT
@ DXGI_FORMAT_BC4_SNORM
@ DXGI_FORMAT_B5G5R5A1_UNORM
@ DXGI_FORMAT_B8G8R8X8_UNORM
static const uint DDSD_PIXELFORMAT
static const uint FOURCC_ATI1
static const uint FOURCC_DXT5
static const uint DDSCAPS_COMPLEX
static const uint DDPF_PALETTEINDEXED8
static const uint D3DFMT_X4R4G4B4
static const uint D3DFMT_R3G3B2
static const uint DDSD_DEPTH
static const uint DDSD_MIPMAPCOUNT
#define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3)
static const uint DDSCAPS2_CUBEMAP
static const uint DDPF_NORMAL
static const uint D3DFMT_A8B8G8R8
static const uint D3DFMT_X8R8G8B8
static const uint DDSCAPS2_CUBEMAP_ALL_FACES
static const uint D3DFMT_X1R5G5B5
static const uint D3DFMT_L8
static const uint FOURCC_NVTT
static const uint DDPF_ALPHAPREMULT
static const uint DDSD_HEIGHT
static const uint DDSCAPS2_CUBEMAP_NEGATIVEX
static const char * getD3d10ResourceDimensionString(D3D10_RESOURCE_DIMENSION resourceDimension)
static const uint D3DFMT_A8
static const uint DDPF_ALPHAPIXELS
static Color32 buildNormal(uint8 x, uint8 y)
static const uint D3DFMT_A4R4G4B4
static const uint FOURCC_DXT1
static const uint DDSCAPS_MIPMAP
static const uint D3DFMT_A8R3G3B2
static const uint FOURCC_ATI2
static const uint DDSCAPS2_CUBEMAP_POSITIVEZ
static const uint D3DFMT_A2R10G10B10
static const uint D3DFMT_A8R8G8B8
static const uint FOURCC_DXT4
static const uint DDSCAPS2_CUBEMAP_NEGATIVEZ
static const uint D3DFMT_A1R5G5B5
static const uint DDPF_ALPHA
static const char * getDxgiFormatString(DXGI_FORMAT dxgiFormat)
static const uint DDSD_CAPS
static const uint D3DFMT_G16R16
static const uint DDSCAPS2_CUBEMAP_NEGATIVEY
static const uint FOURCC_DDS
static const uint DDSD_PITCH
static const uint D3DFMT_A2B10G10R10
static const uint DDSCAPS_TEXTURE
D3D10_RESOURCE_DIMENSION
@ D3D10_RESOURCE_DIMENSION_TEXTURE1D
@ D3D10_RESOURCE_DIMENSION_UNKNOWN
@ D3D10_RESOURCE_DIMENSION_BUFFER
@ D3D10_RESOURCE_DIMENSION_TEXTURE3D
@ D3D10_RESOURCE_DIMENSION_TEXTURE2D
static const uint DDPF_FOURCC
static const uint DDPF_LUMINANCE
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble ny
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
Definition: Color.h:19
void mipmap(Image *img, uint f, uint m)
void * readData(uint &size)
void setUserVersion(int version)
void setHasAlphaFlag(bool b)
DirectDrawSurface(unsigned char *mem, uint size)
void allocate(uint w, uint h)
Definition: Image.cpp:30
const Color32 & pixel(uint idx) const
Definition: Image.cpp:82
uint height() const
Definition: Image.cpp:49
void setFormat(Format f)
Definition: Image.cpp:105
uint width() const
Definition: Image.cpp:44
#define pf(_x, _i)
Prefetch 64.
Definition: gim_memory.h:48
int count
format
Definition: logImageCore.h:38
static unsigned c
Definition: RandGen.cpp:83
uint convert(uint c, uint inbits, uint outbits)
Definition: PixelFormat.h:45
void maskShiftAndSize(uint mask, uint *shift, uint *size)
Definition: PixelFormat.h:61
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken rgba("rgba", pxr::TfToken::Immortal)
void decodeBlock(ColorBlock *block) const
Definition: BlockDXT.cpp:451
void decodeBlock(ColorBlock *block) const
Definition: BlockDXT.cpp:476
void decodeBlock(ColorBlock *block) const
Definition: BlockDXT.cpp:196
void decodeBlock(ColorBlock *block) const
Definition: BlockDXT.cpp:249
void decodeBlock(ColorBlock *block) const
Definition: BlockDXT.cpp:421
Color32 color(uint i) const
Definition: ColorBlock.h:62
bool isNormalMap() const
DDSHeader10 header10
void setUserVersion(int version)
void setFormatCode(uint code)
void setDX10Format(uint format)
void setSwizzleCode(uint8 c0, uint8 c1, uint8 c2, uint8 c3)
void setHasAlphaFlag(bool b)
void setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
void setMipmapCount(uint count)
void setNormalFlag(bool b)
DDSPixelFormat pf
uint userVersion() const
void setWidth(uint w)
void setHeight(uint h)
void setPitch(uint pitch)
bool hasDX10Header() const
void setDepth(uint d)
uint d3d9Format() const
bool isSrgb() const
void setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3)
bool hasAlpha() const
void setLinearSize(uint size)
uint signature() const
uint reserved[11]
uint toolVersion() const
void setSrgbFlag(bool b)
Definition: Stream.h:11
bool failed
Definition: Stream.h:15
unsigned int seek(unsigned int p)
Definition: Stream.cpp:30
unsigned int size
Definition: Stream.h:13