ReactOS 0.4.15-dev-5672-gf73ac17
dxtn.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wined3d_private.h"
#include "wine/library.h"
Include dependency graph for dxtn.c:

Go to the source code of this file.

Macros

#define LOAD_FUNCPTR(f)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
static BOOL dxt1_to_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
 
static BOOL dxt1_to_x4r4g4b4 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
 
static BOOL dxt1_to_x1r5g5b5 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
 
static BOOL dxt3_to_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
 
static BOOL dxt3_to_x4r4g4b4 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
 
static BOOL dxt5_to_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
 
static BOOL x8r8g8b8_to_dxtn (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, GLenum destformat, BOOL alpha)
 
static BOOL x1r5g5b5_to_dxtn (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, GLenum destformat, BOOL alpha)
 
BOOL wined3d_dxt1_decode (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
 
BOOL wined3d_dxt3_decode (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
 
BOOL wined3d_dxt5_decode (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
 
BOOL wined3d_dxt1_encode (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
 
BOOL wined3d_dxt3_encode (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
 
BOOL wined3d_dxt5_encode (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
 
BOOL wined3d_dxtn_init (void)
 
BOOL wined3d_dxtn_supported (void)
 
void wined3d_dxtn_free (void)
 

Variables

static voidtxc_dxtn_handle
 
static void(* pfetch_2d_texel_rgba_dxt1 )(int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel)
 
static void(* pfetch_2d_texel_rgba_dxt3 )(int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel)
 
static void(* pfetch_2d_texel_rgba_dxt5 )(int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel)
 
static void(* ptx_compress_dxtn )(int comps, int width, int height, const BYTE *srcPixData, GLenum destformat, BYTE *dest, int dstRowStride)
 

Macro Definition Documentation

◆ LOAD_FUNCPTR

#define LOAD_FUNCPTR (   f)
Value:
if (!(p##f = wine_dlsym(txc_dxtn_handle, #f, NULL, 0))) \
{ \
ERR("Can't find symbol %s , DXTn software support unavailable.\n", #f); \
goto error; \
}
#define NULL
Definition: types.h:112
static void * txc_dxtn_handle
Definition: dxtn.c:26
GLfloat f
Definition: glext.h:7540
GLfloat GLfloat p
Definition: glext.h:8902
void * wine_dlsym(void *handle, const char *symbol, char *error, size_t errorsize)
Definition: loader.c:48
#define error(str)
Definition: mkdosfs.c:1605

Function Documentation

◆ dxt1_to_x1r5g5b5()

static BOOL dxt1_to_x1r5g5b5 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h,
BOOL  alpha 
)
inlinestatic

Definition at line 97 of file dxtn.c.

99{
100 unsigned int x, y;
101 DWORD color;
102
103 TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
104
105 for (y = 0; y < h; ++y)
106 {
107 WORD *dst_line = (WORD *)(dst + y * pitch_out);
108 for (x = 0; x < w; ++x)
109 {
110 /* pfetch_2d_texel_rgba_dxt1 doesn't correctly handle pitch */
111 pfetch_2d_texel_rgba_dxt1(0, src + (y / 4) * pitch_in + (x / 4) * 16,
112 x & 3, y & 3, &color);
113 if (alpha)
114 {
115 dst_line[x] = ((color & 0x80000000) >> 16) | ((color & 0xf80000) >> 19) |
116 ((color & 0xf800) >> 6) | ((color & 0xf8) << 7);
117 }
118 else
119 {
120 dst_line[x] = 0x8000 | ((color & 0xf80000) >> 19) |
121 ((color & 0xf800) >> 6) | ((color & 0xf8) << 7);
122 }
123 }
124 }
125
126 return TRUE;
127}
#define TRUE
Definition: types.h:120
static void(* pfetch_2d_texel_rgba_dxt1)(int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel)
Definition: dxtn.c:27
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum src
Definition: glext.h:6340
GLuint color
Definition: glext.h:6243
GLenum GLenum dst
Definition: glext.h:6340
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by wined3d_dxt1_decode().

◆ dxt1_to_x4r4g4b4()

static BOOL dxt1_to_x4r4g4b4 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h,
BOOL  alpha 
)
inlinestatic

Definition at line 65 of file dxtn.c.

67{
68 unsigned int x, y;
70
71 TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
72
73 for (y = 0; y < h; ++y)
74 {
75 WORD *dst_line = (WORD *)(dst + y * pitch_out);
76 for (x = 0; x < w; ++x)
77 {
78 /* pfetch_2d_texel_rgba_dxt1 doesn't correctly handle pitch */
79 pfetch_2d_texel_rgba_dxt1(0, src + (y / 4) * pitch_in + (x / 4) * 16,
80 x & 3, y & 3, &color);
81 if (alpha)
82 {
83 dst_line[x] = ((color & 0xf0000000) >> 16) | ((color & 0xf00000) >> 20) |
84 ((color & 0xf000) >> 8) | ((color & 0xf0) << 4);
85 }
86 else
87 {
88 dst_line[x] = 0xf000 | ((color & 0xf00000) >> 20) |
89 ((color & 0xf000) >> 8) | ((color & 0xf0) << 4);
90 }
91 }
92 }
93
94 return TRUE;
95}

Referenced by wined3d_dxt1_decode().

◆ dxt1_to_x8r8g8b8()

static BOOL dxt1_to_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h,
BOOL  alpha 
)
inlinestatic

Definition at line 33 of file dxtn.c.

35{
36 unsigned int x, y;
38
39 TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
40
41 for (y = 0; y < h; ++y)
42 {
43 DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
44 for (x = 0; x < w; ++x)
45 {
46 /* pfetch_2d_texel_rgba_dxt1 doesn't correctly handle pitch */
47 pfetch_2d_texel_rgba_dxt1(0, src + (y / 4) * pitch_in + (x / 4) * 8,
48 x & 3, y & 3, &color);
49 if (alpha)
50 {
51 dst_line[x] = (color & 0xff00ff00) | ((color & 0xff) << 16) |
52 ((color & 0xff0000) >> 16);
53 }
54 else
55 {
56 dst_line[x] = 0xff000000 | ((color & 0xff) << 16) |
57 (color & 0xff00) | ((color & 0xff0000) >> 16);
58 }
59 }
60 }
61
62 return TRUE;
63}

Referenced by wined3d_dxt1_decode().

◆ dxt3_to_x4r4g4b4()

static BOOL dxt3_to_x4r4g4b4 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h,
BOOL  alpha 
)
inlinestatic

Definition at line 161 of file dxtn.c.

163{
164 unsigned int x, y;
165 DWORD color;
166
167 TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
168
169 for (y = 0; y < h; ++y)
170 {
171 WORD *dst_line = (WORD *)(dst + y * pitch_out);
172 for (x = 0; x < w; ++x)
173 {
174 /* pfetch_2d_texel_rgba_dxt3 doesn't correctly handle pitch */
175 pfetch_2d_texel_rgba_dxt3(0, src + (y / 4) * pitch_in + (x / 4) * 16,
176 x & 3, y & 3, &color);
177 if (alpha)
178 {
179 dst_line[x] = ((color & 0xf0000000) >> 16) | ((color & 0xf00000) >> 20) |
180 ((color & 0xf000) >> 8) | ((color & 0xf0) << 4);
181 }
182 else
183 {
184 dst_line[x] = 0xf000 | ((color & 0xf00000) >> 20) |
185 ((color & 0xf000) >> 8) | ((color & 0xf0) << 4);
186 }
187 }
188 }
189
190 return TRUE;
191}
static void(* pfetch_2d_texel_rgba_dxt3)(int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel)
Definition: dxtn.c:28

Referenced by wined3d_dxt3_decode().

◆ dxt3_to_x8r8g8b8()

static BOOL dxt3_to_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h,
BOOL  alpha 
)
inlinestatic

Definition at line 129 of file dxtn.c.

131{
132 unsigned int x, y;
133 DWORD color;
134
135 TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
136
137 for (y = 0; y < h; ++y)
138 {
139 DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
140 for (x = 0; x < w; ++x)
141 {
142 /* pfetch_2d_texel_rgba_dxt3 doesn't correctly handle pitch */
143 pfetch_2d_texel_rgba_dxt3(0, src + (y / 4) * pitch_in + (x / 4) * 16,
144 x & 3, y & 3, &color);
145 if (alpha)
146 {
147 dst_line[x] = (color & 0xff00ff00) | ((color & 0xff) << 16) |
148 ((color & 0xff0000) >> 16);
149 }
150 else
151 {
152 dst_line[x] = 0xff000000 | ((color & 0xff) << 16) |
153 (color & 0xff00) | ((color & 0xff0000) >> 16);
154 }
155 }
156 }
157
158 return TRUE;
159}

Referenced by wined3d_dxt3_decode().

◆ dxt5_to_x8r8g8b8()

static BOOL dxt5_to_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h,
BOOL  alpha 
)
inlinestatic

Definition at line 193 of file dxtn.c.

195{
196 unsigned int x, y;
197 DWORD color;
198
199 TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
200
201 for (y = 0; y < h; ++y)
202 {
203 DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
204 for (x = 0; x < w; ++x)
205 {
206 /* pfetch_2d_texel_rgba_dxt5 doesn't correctly handle pitch */
207 pfetch_2d_texel_rgba_dxt5(0, src + (y / 4) * pitch_in + (x / 4) * 16,
208 x & 3, y & 3, &color);
209 if (alpha)
210 {
211 dst_line[x] = (color & 0xff00ff00) | ((color & 0xff) << 16) |
212 ((color & 0xff0000) >> 16);
213 }
214 else
215 {
216 dst_line[x] = 0xff000000 | ((color & 0xff) << 16) |
217 (color & 0xff00) | ((color & 0xff0000) >> 16);
218 }
219 }
220 }
221
222 return TRUE;
223}
static void(* pfetch_2d_texel_rgba_dxt5)(int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel)
Definition: dxtn.c:29

Referenced by wined3d_dxt5_decode().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_dxt1_decode()

BOOL wined3d_dxt1_decode ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
enum wined3d_format_id  format,
unsigned int  w,
unsigned int  h 
)

Definition at line 317 of file dxtn.c.

319{
320 if (!txc_dxtn_handle)
321 return FALSE;
322
323 switch (format)
324 {
326 return dxt1_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, TRUE);
328 return dxt1_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, FALSE);
330 return dxt1_to_x4r4g4b4(src, dst, pitch_in, pitch_out, w, h, TRUE);
332 return dxt1_to_x4r4g4b4(src, dst, pitch_in, pitch_out, w, h, FALSE);
334 return dxt1_to_x1r5g5b5(src, dst, pitch_in, pitch_out, w, h, TRUE);
336 return dxt1_to_x1r5g5b5(src, dst, pitch_in, pitch_out, w, h, FALSE);
337 default:
338 break;
339 }
340
341 FIXME("Cannot find a conversion function from format DXT1 to %s.\n", debug_d3dformat(format));
342 return FALSE;
343}
#define FIXME(fmt,...)
Definition: debug.h:111
#define FALSE
Definition: types.h:117
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3980
static BOOL dxt1_to_x4r4g4b4(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
Definition: dxtn.c:65
static BOOL dxt1_to_x1r5g5b5(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
Definition: dxtn.c:97
static BOOL dxt1_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
Definition: dxtn.c:33
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
@ WINED3DFMT_B4G4R4A4_UNORM
Definition: wined3d.h:110
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:223
@ WINED3DFMT_B8G8R8X8_UNORM
Definition: wined3d.h:224
@ WINED3DFMT_B5G5R5X1_UNORM
Definition: wined3d.h:109
@ WINED3DFMT_B5G5R5A1_UNORM
Definition: wined3d.h:222
@ WINED3DFMT_B4G4R4X4_UNORM
Definition: wined3d.h:113

Referenced by convert_dxt1_a1r5g5b5(), convert_dxt1_a4r4g4b4(), convert_dxt1_a8r8g8b8(), convert_dxt1_x1r5g5b5(), convert_dxt1_x4r4g4b4(), and convert_dxt1_x8r8g8b8().

◆ wined3d_dxt1_encode()

BOOL wined3d_dxt1_encode ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
enum wined3d_format_id  format,
unsigned int  w,
unsigned int  h 
)

Definition at line 389 of file dxtn.c.

391{
392 if (!txc_dxtn_handle)
393 return FALSE;
394
395 switch (format)
396 {
398 return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
401 return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
404 return x1r5g5b5_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
407 return x1r5g5b5_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
409 default:
410 break;
411 }
412
413 FIXME("Cannot find a conversion function from format %s to DXT1.\n", debug_d3dformat(format));
414 return FALSE;
415}
static BOOL x8r8g8b8_to_dxtn(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, GLenum destformat, BOOL alpha)
Definition: dxtn.c:225
static BOOL x1r5g5b5_to_dxtn(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, GLenum destformat, BOOL alpha)
Definition: dxtn.c:265
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT
Definition: glext.h:3489
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
Definition: glext.h:3490

Referenced by convert_a1r5g5b5_dxt1(), convert_a8r8g8b8_dxt1(), convert_x1r5g5b5_dxt1(), and convert_x8r8g8b8_dxt1().

◆ wined3d_dxt3_decode()

BOOL wined3d_dxt3_decode ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
enum wined3d_format_id  format,
unsigned int  w,
unsigned int  h 
)

Definition at line 345 of file dxtn.c.

347{
348 if (!txc_dxtn_handle)
349 return FALSE;
350
351 switch (format)
352 {
354 return dxt3_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, TRUE);
356 return dxt3_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, FALSE);
358 return dxt3_to_x4r4g4b4(src, dst, pitch_in, pitch_out, w, h, TRUE);
360 return dxt3_to_x4r4g4b4(src, dst, pitch_in, pitch_out, w, h, FALSE);
361 default:
362 break;
363 }
364
365 FIXME("Cannot find a conversion function from format DXT3 to %s.\n", debug_d3dformat(format));
366 return FALSE;
367}
static BOOL dxt3_to_x4r4g4b4(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
Definition: dxtn.c:161
static BOOL dxt3_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
Definition: dxtn.c:129

Referenced by convert_dxt3_a4r4g4b4(), convert_dxt3_a8r8g8b8(), convert_dxt3_x4r4g4b4(), and convert_dxt3_x8r8g8b8().

◆ wined3d_dxt3_encode()

BOOL wined3d_dxt3_encode ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
enum wined3d_format_id  format,
unsigned int  w,
unsigned int  h 
)

Definition at line 417 of file dxtn.c.

419{
420 if (!txc_dxtn_handle)
421 return FALSE;
422
423 switch (format)
424 {
426 return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
429 return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
431 default:
432 break;
433 }
434
435 FIXME("Cannot find a conversion function from format %s to DXT3.\n", debug_d3dformat(format));
436 return FALSE;
437}
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
Definition: glext.h:3491

Referenced by convert_a8r8g8b8_dxt3(), and convert_x8r8g8b8_dxt3().

◆ wined3d_dxt5_decode()

BOOL wined3d_dxt5_decode ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
enum wined3d_format_id  format,
unsigned int  w,
unsigned int  h 
)

Definition at line 369 of file dxtn.c.

371{
372 if (!txc_dxtn_handle)
373 return FALSE;
374
375 switch (format)
376 {
378 return dxt5_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, TRUE);
380 return dxt5_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, FALSE);
381 default:
382 break;
383 }
384
385 FIXME("Cannot find a conversion function from format DXT5 to %s.\n", debug_d3dformat(format));
386 return FALSE;
387}
static BOOL dxt5_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
Definition: dxtn.c:193

Referenced by convert_dxt5_a8r8g8b8(), and convert_dxt5_x8r8g8b8().

◆ wined3d_dxt5_encode()

BOOL wined3d_dxt5_encode ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
enum wined3d_format_id  format,
unsigned int  w,
unsigned int  h 
)

Definition at line 439 of file dxtn.c.

441{
442 if (!txc_dxtn_handle)
443 return FALSE;
444
445 switch (format)
446 {
448 return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
451 return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
453 default:
454 break;
455 }
456
457 FIXME("Cannot find a conversion function from format %s to DXT5.\n", debug_d3dformat(format));
458 return FALSE;
459}
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
Definition: glext.h:3492

Referenced by convert_a8r8g8b8_dxt5(), and convert_x8r8g8b8_dxt5().

◆ wined3d_dxtn_free()

void wined3d_dxtn_free ( void  )

Definition at line 515 of file dxtn.c.

516{
517 if (txc_dxtn_handle)
519}
int wine_dlclose(void *handle, char *error, size_t errorsize)
Definition: loader.c:58

Referenced by wined3d_dll_destroy().

◆ wined3d_dxtn_init()

BOOL wined3d_dxtn_init ( void  )

Definition at line 461 of file dxtn.c.

462{
463 static const char *soname[] =
464 {
465#ifdef SONAME_LIBTXC_DXTN
467#endif
468#ifdef __APPLE__
469 "libtxc_dxtn.dylib",
470 "libtxc_dxtn_s2tc.dylib",
471#endif
472 "libtxc_dxtn.so",
473 "libtxc_dxtn_s2tc.so.0"
474 };
475 int i;
476
477 for (i = 0; i < sizeof(soname)/sizeof(soname[0]); i++)
478 {
479 txc_dxtn_handle = wine_dlopen(soname[i], RTLD_NOW, NULL, 0);
480 if (txc_dxtn_handle) break;
481 }
482
483 if (!txc_dxtn_handle)
484 {
485 FIXME("Wine cannot find the txc_dxtn library, DXTn software support unavailable.\n");
486 return FALSE;
487 }
488
489 #define LOAD_FUNCPTR(f) \
490 if (!(p##f = wine_dlsym(txc_dxtn_handle, #f, NULL, 0))) \
491 { \
492 ERR("Can't find symbol %s , DXTn software support unavailable.\n", #f); \
493 goto error; \
494 }
495
500
501 #undef LOAD_FUNCPTR
502 return TRUE;
503
504error:
507 return FALSE;
508}
void tx_compress_dxtn(GLint srccomps, GLint width, GLint height, const GLubyte *srcPixData, GLenum destFormat, GLubyte *dest, GLint dstRowStride)
void fetch_2d_texel_rgba_dxt3(GLint srcRowStride, const GLubyte *pixdata, GLint i, GLint j, GLvoid *texel)
void fetch_2d_texel_rgba_dxt1(GLint srcRowStride, const GLubyte *pixdata, GLint i, GLint j, GLvoid *texel)
void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata, GLint i, GLint j, GLvoid *texel)
#define LOAD_FUNCPTR(f)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void * wine_dlopen(const char *filename, int flag, char *error, size_t errorsize)
Definition: loader.c:53
#define RTLD_NOW
Definition: port.h:100
#define SONAME_LIBTXC_DXTN
Definition: config.h:1269

Referenced by wined3d_dll_init().

◆ wined3d_dxtn_supported()

BOOL wined3d_dxtn_supported ( void  )

Definition at line 510 of file dxtn.c.

511{
512 return (txc_dxtn_handle != NULL);
513}

Referenced by find_converter().

◆ x1r5g5b5_to_dxtn()

static BOOL x1r5g5b5_to_dxtn ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h,
GLenum  destformat,
BOOL  alpha 
)
inlinestatic

Definition at line 265 of file dxtn.c.

267{
268 static const unsigned char convert_5to8[] =
269 {
270 0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
271 0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
272 0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
273 0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
274 };
275 unsigned int x, y;
276 DWORD *tmp;
277 WORD color;
278
279 TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
280
281 tmp = HeapAlloc(GetProcessHeap(), 0, h * w * sizeof(DWORD));
282 if (!tmp)
283 {
284 ERR("Failed to allocate memory for conversion\n");
285 return FALSE;
286 }
287
288 for (y = 0; y < h; ++y)
289 {
290 const WORD *src_line = (const WORD *)(src + y * pitch_in);
291 DWORD *dst_line = tmp + y * w;
292 for (x = 0; x < w; ++x)
293 {
294 color = src_line[x];
295 if (alpha)
296 {
297 dst_line[x] = ((color & 0x8000) ? 0xff000000 : 0) |
298 convert_5to8[(color & 0x001f)] << 16 |
299 convert_5to8[(color & 0x03e0) >> 5] << 8 |
300 convert_5to8[(color & 0x7c00) >> 10];
301 }
302 else
303 {
304 dst_line[x] = 0xff000000 |
305 convert_5to8[(color & 0x001f)] << 16 |
306 convert_5to8[(color & 0x03e0) >> 5] << 8 |
307 convert_5to8[(color & 0x7c00) >> 10];
308 }
309 }
310 }
311
312 ptx_compress_dxtn(4, w, h, (BYTE *)tmp, destformat, dst, pitch_out);
313 HeapFree(GetProcessHeap(), 0, tmp);
314 return TRUE;
315}
#define ERR(fmt,...)
Definition: debug.h:110
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static void(* ptx_compress_dxtn)(int comps, int width, int height, const BYTE *srcPixData, GLenum destformat, BYTE *dest, int dstRowStride)
Definition: dxtn.c:30
unsigned char BYTE
Definition: xxhash.c:193

Referenced by wined3d_dxt1_encode().

◆ x8r8g8b8_to_dxtn()

static BOOL x8r8g8b8_to_dxtn ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h,
GLenum  destformat,
BOOL  alpha 
)
inlinestatic

Definition at line 225 of file dxtn.c.

227{
228 unsigned int x, y;
229 DWORD color, *tmp;
230
231 TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
232
233 tmp = HeapAlloc(GetProcessHeap(), 0, h * w * sizeof(DWORD));
234 if (!tmp)
235 {
236 ERR("Failed to allocate memory for conversion\n");
237 return FALSE;
238 }
239
240 for (y = 0; y < h; ++y)
241 {
242 const DWORD *src_line = (const DWORD *)(src + y * pitch_in);
243 DWORD *dst_line = tmp + y * w;
244 for (x = 0; x < w; ++x)
245 {
246 color = src_line[x];
247 if (alpha)
248 {
249 dst_line[x] = (color & 0xff00ff00) | ((color & 0xff) << 16) |
250 ((color & 0xff0000) >> 16);
251 }
252 else
253 {
254 dst_line[x] = 0xff000000 | ((color & 0xff) << 16) |
255 (color & 0xff00) | ((color & 0xff0000) >> 16);
256 }
257 }
258 }
259
260 ptx_compress_dxtn(4, w, h, (BYTE *)tmp, destformat, dst, pitch_out);
261 HeapFree(GetProcessHeap(), 0, tmp);
262 return TRUE;
263}

Referenced by wined3d_dxt1_encode(), wined3d_dxt3_encode(), and wined3d_dxt5_encode().

Variable Documentation

◆ pfetch_2d_texel_rgba_dxt1

void(* pfetch_2d_texel_rgba_dxt1) (int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel) ( int  srcRowStride,
const BYTE pixData,
int  i,
int  j,
DWORD texel 
)
static

Definition at line 27 of file dxtn.c.

Referenced by dxt1_to_x1r5g5b5(), dxt1_to_x4r4g4b4(), and dxt1_to_x8r8g8b8().

◆ pfetch_2d_texel_rgba_dxt3

void(* pfetch_2d_texel_rgba_dxt3) (int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel) ( int  srcRowStride,
const BYTE pixData,
int  i,
int  j,
DWORD texel 
)
static

Definition at line 28 of file dxtn.c.

Referenced by dxt3_to_x4r4g4b4(), and dxt3_to_x8r8g8b8().

◆ pfetch_2d_texel_rgba_dxt5

void(* pfetch_2d_texel_rgba_dxt5) (int srcRowStride, const BYTE *pixData, int i, int j, DWORD *texel) ( int  srcRowStride,
const BYTE pixData,
int  i,
int  j,
DWORD texel 
)
static

Definition at line 29 of file dxtn.c.

Referenced by dxt5_to_x8r8g8b8().

◆ ptx_compress_dxtn

void(* ptx_compress_dxtn) (int comps, int width, int height, const BYTE *srcPixData, GLenum destformat, BYTE *dest, int dstRowStride) ( int  comps,
int  width,
int  height,
const BYTE srcPixData,
GLenum  destformat,
BYTE dest,
int  dstRowStride 
)
static

Definition at line 30 of file dxtn.c.

Referenced by x1r5g5b5_to_dxtn(), and x8r8g8b8_to_dxtn().

◆ txc_dxtn_handle