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