Updated d3dx9_36-DXTn patchset

Make dxtn library internal.
This commit is contained in:
Alistair Leslie-Hughes 2018-05-05 10:57:18 +10:00
parent 7c9f9bc0c1
commit 82eedec6ed
7 changed files with 1732 additions and 1076 deletions

View File

@ -1,7 +1,7 @@
From 46fa101a9cab46e4a0ed28e8cb9e4e199b0a0f81 Mon Sep 17 00:00:00 2001
From: Christian Costa <titan.costa@gmail.com>
Date: Sat, 1 Nov 2014 13:08:05 +0100
Subject: [PATCH] d3dx9_36: Add dxtn support.
From 9acf83e4be20fe0ce12df7c966a748bf8524f26f Mon Sep 17 00:00:00 2001
From: Kyle Devir <kyle.devir@mykolab.com>
Date: Fri, 30 Mar 2018 08:22:02 +0000
Subject: [PATCH] d3dx9_36: add DXTn support
---
dlls/d3dx9_24/Makefile.in | 2 +-
@ -17,7 +17,7 @@ Subject: [PATCH] d3dx9_36: Add dxtn support.
dlls/d3dx9_34/Makefile.in | 2 +-
dlls/d3dx9_35/Makefile.in | 2 +-
dlls/d3dx9_36/Makefile.in | 2 +-
dlls/d3dx9_36/surface.c | 103 +++++++++++++++++++++++++++++++++++++++---
dlls/d3dx9_36/surface.c | 100 +++++++++++++++++++++++++++++++++++++++---
dlls/d3dx9_36/tests/surface.c | 8 ++--
dlls/d3dx9_37/Makefile.in | 2 +-
dlls/d3dx9_38/Makefile.in | 2 +-
@ -26,10 +26,10 @@ Subject: [PATCH] d3dx9_36: Add dxtn support.
dlls/d3dx9_41/Makefile.in | 2 +-
dlls/d3dx9_42/Makefile.in | 2 +-
dlls/d3dx9_43/Makefile.in | 2 +-
22 files changed, 120 insertions(+), 31 deletions(-)
22 files changed, 117 insertions(+), 31 deletions(-)
diff --git a/dlls/d3dx9_24/Makefile.in b/dlls/d3dx9_24/Makefile.in
index 482c92d..d969a55 100644
index 482c92d64e..d969a55b10 100644
--- a/dlls/d3dx9_24/Makefile.in
+++ b/dlls/d3dx9_24/Makefile.in
@@ -1,6 +1,6 @@
@ -41,7 +41,7 @@ index 482c92d..d969a55 100644
C_SRCS = \
diff --git a/dlls/d3dx9_25/Makefile.in b/dlls/d3dx9_25/Makefile.in
index be4c769..b232290 100644
index be4c76980e..b232290d25 100644
--- a/dlls/d3dx9_25/Makefile.in
+++ b/dlls/d3dx9_25/Makefile.in
@@ -1,6 +1,6 @@
@ -53,7 +53,7 @@ index be4c769..b232290 100644
C_SRCS = \
diff --git a/dlls/d3dx9_26/Makefile.in b/dlls/d3dx9_26/Makefile.in
index c5e9e85..525009d 100644
index c5e9e85bfb..525009d292 100644
--- a/dlls/d3dx9_26/Makefile.in
+++ b/dlls/d3dx9_26/Makefile.in
@@ -1,6 +1,6 @@
@ -65,7 +65,7 @@ index c5e9e85..525009d 100644
C_SRCS = \
diff --git a/dlls/d3dx9_27/Makefile.in b/dlls/d3dx9_27/Makefile.in
index ee7f0e2..da98482 100644
index ee7f0e2449..da98482d24 100644
--- a/dlls/d3dx9_27/Makefile.in
+++ b/dlls/d3dx9_27/Makefile.in
@@ -1,6 +1,6 @@
@ -77,7 +77,7 @@ index ee7f0e2..da98482 100644
C_SRCS = \
diff --git a/dlls/d3dx9_28/Makefile.in b/dlls/d3dx9_28/Makefile.in
index 0944200..d50e035 100644
index 094420013d..d50e035853 100644
--- a/dlls/d3dx9_28/Makefile.in
+++ b/dlls/d3dx9_28/Makefile.in
@@ -1,6 +1,6 @@
@ -89,7 +89,7 @@ index 0944200..d50e035 100644
C_SRCS = \
diff --git a/dlls/d3dx9_29/Makefile.in b/dlls/d3dx9_29/Makefile.in
index 88cb110..cfc1a15 100644
index 88cb110ff5..cfc1a15034 100644
--- a/dlls/d3dx9_29/Makefile.in
+++ b/dlls/d3dx9_29/Makefile.in
@@ -1,6 +1,6 @@
@ -101,7 +101,7 @@ index 88cb110..cfc1a15 100644
C_SRCS = \
diff --git a/dlls/d3dx9_30/Makefile.in b/dlls/d3dx9_30/Makefile.in
index 6ab2ff2..726c92e 100644
index 6ab2ff2451..726c92e8fd 100644
--- a/dlls/d3dx9_30/Makefile.in
+++ b/dlls/d3dx9_30/Makefile.in
@@ -1,6 +1,6 @@
@ -113,7 +113,7 @@ index 6ab2ff2..726c92e 100644
C_SRCS = \
diff --git a/dlls/d3dx9_31/Makefile.in b/dlls/d3dx9_31/Makefile.in
index 3d44da1..2014301 100644
index 3d44da147d..201430127c 100644
--- a/dlls/d3dx9_31/Makefile.in
+++ b/dlls/d3dx9_31/Makefile.in
@@ -1,6 +1,6 @@
@ -125,7 +125,7 @@ index 3d44da1..2014301 100644
C_SRCS = \
diff --git a/dlls/d3dx9_32/Makefile.in b/dlls/d3dx9_32/Makefile.in
index 37cc279..442258d 100644
index 37cc2797af..442258d8f3 100644
--- a/dlls/d3dx9_32/Makefile.in
+++ b/dlls/d3dx9_32/Makefile.in
@@ -1,6 +1,6 @@
@ -137,7 +137,7 @@ index 37cc279..442258d 100644
C_SRCS = \
diff --git a/dlls/d3dx9_33/Makefile.in b/dlls/d3dx9_33/Makefile.in
index 5b03ec1..cc98ed2 100644
index 5b03ec134d..cc98ed2501 100644
--- a/dlls/d3dx9_33/Makefile.in
+++ b/dlls/d3dx9_33/Makefile.in
@@ -1,6 +1,6 @@
@ -149,7 +149,7 @@ index 5b03ec1..cc98ed2 100644
C_SRCS = \
diff --git a/dlls/d3dx9_34/Makefile.in b/dlls/d3dx9_34/Makefile.in
index b7f9c46..4862fe9 100644
index b7f9c46d5e..4862fe94af 100644
--- a/dlls/d3dx9_34/Makefile.in
+++ b/dlls/d3dx9_34/Makefile.in
@@ -1,6 +1,6 @@
@ -161,7 +161,7 @@ index b7f9c46..4862fe9 100644
C_SRCS = \
diff --git a/dlls/d3dx9_35/Makefile.in b/dlls/d3dx9_35/Makefile.in
index 9c196ea..3f529c9 100644
index 9c196ea038..3f529c9915 100644
--- a/dlls/d3dx9_35/Makefile.in
+++ b/dlls/d3dx9_35/Makefile.in
@@ -1,6 +1,6 @@
@ -173,7 +173,7 @@ index 9c196ea..3f529c9 100644
C_SRCS = \
diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in
index da8098d..166031e 100644
index da8098dd8d..166031e6a4 100644
--- a/dlls/d3dx9_36/Makefile.in
+++ b/dlls/d3dx9_36/Makefile.in
@@ -1,7 +1,7 @@
@ -186,7 +186,7 @@ index da8098d..166031e 100644
C_SRCS = \
animation.c \
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index d1af90c..a1e56bd 100644
index d1af90ccd1..73a1cbde1a 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -27,6 +27,8 @@
@ -198,7 +198,7 @@ index d1af90c..a1e56bd 100644
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
@@ -1817,6 +1819,27 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
@@ -1817,6 +1819,24 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic
}
}
@ -210,13 +210,10 @@ index d1af90c..a1e56bd 100644
+ switch (format)
+ {
+ case D3DFMT_DXT1:
+ if (!wined3d_dxtn_supported()) return NULL;
+ return encode ? wined3d_dxt1_encode : wined3d_dxt1_decode;
+ case D3DFMT_DXT3:
+ if (!wined3d_dxtn_supported()) return NULL;
+ return encode ? wined3d_dxt3_encode : wined3d_dxt3_decode;
+ case D3DFMT_DXT5:
+ if (!wined3d_dxtn_supported()) return NULL;
+ return encode ? wined3d_dxt5_encode : wined3d_dxt5_decode;
+ default:
+ return NULL;
@ -226,7 +223,7 @@ index d1af90c..a1e56bd 100644
/************************************************************
* D3DXLoadSurfaceFromMemory
*
@@ -1858,6 +1881,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
@@ -1858,6 +1878,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
D3DSURFACE_DESC surfdesc;
D3DLOCKED_RECT lockrect;
struct volume src_size, dst_size;
@ -234,7 +231,7 @@ index d1af90c..a1e56bd 100644
TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s, %#x, 0x%08x)\n",
dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_memory, src_format,
@@ -1939,8 +1963,15 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
@@ -1939,8 +1960,15 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
}
else /* Stretching or format conversion. */
{
@ -252,7 +249,7 @@ index d1af90c..a1e56bd 100644
{
FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format);
return E_NOTIMPL;
@@ -1949,10 +1980,52 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
@@ -1949,10 +1977,52 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
if (FAILED(IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0)))
return D3DXERR_INVALIDDATA;
@ -307,7 +304,7 @@ index d1af90c..a1e56bd 100644
}
else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */
{
@@ -1961,14 +2034,30 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
@@ -1961,14 +2031,30 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface,
/* Always apply a point filter until D3DX_FILTER_LINEAR,
* D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */
@ -342,7 +339,7 @@ index d1af90c..a1e56bd 100644
/************************************************************
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index 753b302..680f59c 100644
index 753b30273d..680f59ca21 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -1205,7 +1205,7 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
@ -377,7 +374,7 @@ index 753b302..680f59c 100644
check_release((IUnknown*)newsurf, 1);
check_release((IUnknown*)tex, 0);
diff --git a/dlls/d3dx9_37/Makefile.in b/dlls/d3dx9_37/Makefile.in
index ab790a4..51382c7 100644
index ab790a4d5c..51382c7109 100644
--- a/dlls/d3dx9_37/Makefile.in
+++ b/dlls/d3dx9_37/Makefile.in
@@ -1,6 +1,6 @@
@ -389,7 +386,7 @@ index ab790a4..51382c7 100644
C_SRCS = \
diff --git a/dlls/d3dx9_38/Makefile.in b/dlls/d3dx9_38/Makefile.in
index 6125c2d..f6257cb 100644
index 6125c2da67..f6257cbdec 100644
--- a/dlls/d3dx9_38/Makefile.in
+++ b/dlls/d3dx9_38/Makefile.in
@@ -1,6 +1,6 @@
@ -401,7 +398,7 @@ index 6125c2d..f6257cb 100644
C_SRCS = \
diff --git a/dlls/d3dx9_39/Makefile.in b/dlls/d3dx9_39/Makefile.in
index d97a787..a68ee9f 100644
index d97a787c67..a68ee9f3ad 100644
--- a/dlls/d3dx9_39/Makefile.in
+++ b/dlls/d3dx9_39/Makefile.in
@@ -1,6 +1,6 @@
@ -413,7 +410,7 @@ index d97a787..a68ee9f 100644
C_SRCS = \
diff --git a/dlls/d3dx9_40/Makefile.in b/dlls/d3dx9_40/Makefile.in
index 36c5a21..7f2cfe1 100644
index 36c5a210cd..7f2cfe1a47 100644
--- a/dlls/d3dx9_40/Makefile.in
+++ b/dlls/d3dx9_40/Makefile.in
@@ -1,6 +1,6 @@
@ -425,7 +422,7 @@ index 36c5a21..7f2cfe1 100644
C_SRCS = \
diff --git a/dlls/d3dx9_41/Makefile.in b/dlls/d3dx9_41/Makefile.in
index d4552cf..c5c3ab1 100644
index d4552cf608..c5c3ab1aae 100644
--- a/dlls/d3dx9_41/Makefile.in
+++ b/dlls/d3dx9_41/Makefile.in
@@ -1,6 +1,6 @@
@ -437,7 +434,7 @@ index d4552cf..c5c3ab1 100644
C_SRCS = \
diff --git a/dlls/d3dx9_42/Makefile.in b/dlls/d3dx9_42/Makefile.in
index 5806fce..e9a8e89 100644
index 5806fce66c..e9a8e89da5 100644
--- a/dlls/d3dx9_42/Makefile.in
+++ b/dlls/d3dx9_42/Makefile.in
@@ -1,6 +1,6 @@
@ -449,7 +446,7 @@ index 5806fce..e9a8e89 100644
C_SRCS = \
diff --git a/dlls/d3dx9_43/Makefile.in b/dlls/d3dx9_43/Makefile.in
index 72ba8b4..33185bf 100644
index 72ba8b4c1e..33185bf7a8 100644
--- a/dlls/d3dx9_43/Makefile.in
+++ b/dlls/d3dx9_43/Makefile.in
@@ -1,6 +1,6 @@
@ -461,5 +458,5 @@ index 72ba8b4..33185bf 100644
C_SRCS = \
--
1.9.1
2.16.3

View File

@ -3331,19 +3331,13 @@ fi
# | * [#17913] Port Royale doesn't display ocean correctly
# |
# | Modified files:
# | * configure.ac, dlls/wined3d/Makefile.in, dlls/wined3d/dxtn.c, dlls/wined3d/surface.c, dlls/wined3d/wined3d.spec,
# | dlls/wined3d/wined3d_main.c, dlls/wined3d/wined3d_private.h, include/wine/wined3d.h
# | * dlls/wined3d/Makefile.in, dlls/wined3d/dxtn.c, dlls/wined3d/dxtn.h, dlls/wined3d/surface.c, dlls/wined3d/wined3d.spec,
# | dlls/wined3d/wined3d_main.c, include/wine/wined3d.h
# |
if test "$enable_wined3d_DXTn" -eq 1; then
patch_apply wined3d-DXTn/0001-wined3d-Add-support-for-DXTn-software-decoding-throu.patch
patch_apply wined3d-DXTn/0002-wined3d-Improve-DXTn-support-and-export-conversion-f.patch
patch_apply wined3d-DXTn/0003-wined3d-add-DXT1-to-B4G4R4A4-DXT1-to-B5G5R5A1-and-DX.patch
patch_apply wined3d-DXTn/0004-wined3d-Load-dxtn-dylib-library-on-Mac-OS-X.patch
patch_apply wined3d-DXTn/0001-wined3d-add-DXTn-support.patch
(
printf '%s\n' '+ { "Michael Müller", "wined3d: Add support for DXTn software decoding through libtxc_dxtn.", 3 },';
printf '%s\n' '+ { "Christian Costa", "wined3d: Improve DXTn support and export conversion functions for d3dx9_36.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Add DXT1 to B4G4R4A4, DXT1 to B5G5R5A1 and DXT3 to B4G4R4A4 conversion.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Load dxtn dylib library on Mac OS X.", 1 },';
printf '%s\n' '+ { "Kyle Devir", "wined3d: Add DXTn support.", 1 },';
) >> "$patchlist"
fi
@ -3369,7 +3363,7 @@ fi
if test "$enable_d3dx9_36_DXTn" -eq 1; then
patch_apply d3dx9_36-DXTn/0001-d3dx9_36-Add-dxtn-support.patch
(
printf '%s\n' '+ { "Christian Costa", "d3dx9_36: Add dxtn support.", 1 },';
printf '%s\n' '+ { "Kyle Devir", "d3dx9_36: Add DXTn support.", 1 },';
) >> "$patchlist"
fi

View File

@ -1,509 +0,0 @@
From ba82f3225b3d2491f702d7f82a2f22fd50425198 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 20 Sep 2014 02:48:07 +0200
Subject: [PATCH] wined3d: Add support for DXTn software decoding through
libtxc_dxtn. (rev 3)
Changes in rev 2:
* Do not use dxtn library when some imports are missing.
* Do not advertise dxtn converter functions when they are not supported (because
of missing library or support not compiled in).
Changes in rev 3:
* Do not require txc_dxtn at compile time by trying some fallback paths.
---
configure.ac | 3 +
dlls/wined3d/Makefile.in | 1 +
dlls/wined3d/dxtn.c | 299 +++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/surface.c | 80 +++++++++++
dlls/wined3d/wined3d_main.c | 5 +
dlls/wined3d/wined3d_private.h | 13 ++
6 files changed, 401 insertions(+)
create mode 100644 dlls/wined3d/dxtn.c
diff --git a/configure.ac b/configure.ac
index 7b796ef..7b26e45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1737,6 +1737,9 @@ fi
WINE_NOTICE_WITH(tiff,[test "x$ac_cv_lib_soname_tiff" = "x"],
[libtiff ${notice_platform}development files not found, TIFF won't be supported.])
+dnl **** Check for libtxc_dxtn ****
+WINE_CHECK_SONAME(txc_dxtn,tx_compress_dxtn,,,,[[libtxc_dxtn\\(_s2tc\\)\\{0,1\\}]])
+
dnl **** Check for mpg123 ****
if test "x$with_mpg123" != "xno"
then
diff --git a/dlls/wined3d/Makefile.in b/dlls/wined3d/Makefile.in
index 58fc2d5..b850ba6 100644
--- a/dlls/wined3d/Makefile.in
+++ b/dlls/wined3d/Makefile.in
@@ -10,6 +10,7 @@ C_SRCS = \
cs.c \
device.c \
directx.c \
+ dxtn.c \
gl_compat.c \
glsl_shader.c \
nvidia_texture_shader.c \
diff --git a/dlls/wined3d/dxtn.c b/dlls/wined3d/dxtn.c
new file mode 100644
index 0000000..ce98949
--- /dev/null
+++ b/dlls/wined3d/dxtn.c
@@ -0,0 +1,299 @@
+/*
+ * Copyright 2014 Michael Müller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+#include "wined3d_private.h"
+#include "wine/library.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d);
+
+static void* txc_dxtn_handle;
+static void (*pfetch_2d_texel_rgba_dxt1)(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);
+
+static inline BOOL dxt1_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in,
+ DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
+{
+ unsigned int x, y;
+ DWORD color;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ /* pfetch_2d_texel_rgba_dxt1 doesn't correctly handle pitch */
+ pfetch_2d_texel_rgba_dxt1(0, src + (y / 4) * pitch_in + (x / 4) * 8,
+ x & 3, y & 3, &color);
+ if (alpha)
+ {
+ dst_line[x] = (color & 0xff00ff00) | ((color & 0xff) << 16) |
+ ((color & 0xff0000) >> 16);
+ }
+ else
+ {
+ dst_line[x] = 0xff000000 | ((color & 0xff) << 16) |
+ (color & 0xff00) | ((color & 0xff0000) >> 16);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+static inline 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)
+{
+ unsigned int x, y;
+ DWORD color, *tmp;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+ tmp = HeapAlloc(GetProcessHeap(), 0, h * w * sizeof(DWORD));
+ if (!tmp)
+ {
+ ERR("Failed to allocate memory for conversion\n");
+ return FALSE;
+ }
+
+ for (y = 0; y < h; ++y)
+ {
+ const DWORD *src_line = (const DWORD *)(src + y * pitch_in);
+ DWORD *dst_line = tmp + y * w;
+ for (x = 0; x < w; ++x)
+ {
+ color = src_line[x];
+ if (alpha)
+ {
+ dst_line[x] = (color & 0xff00ff00) | ((color & 0xff) << 16) |
+ ((color & 0xff0000) >> 16);
+ }
+ else
+ {
+ dst_line[x] = 0xff000000 | ((color & 0xff) << 16) |
+ (color & 0xff00) | ((color & 0xff0000) >> 16);
+ }
+ }
+ }
+
+ ptx_compress_dxtn(4, w, h, (BYTE *)tmp, destformat, dst, pitch_out);
+ HeapFree(GetProcessHeap(), 0, tmp);
+ return TRUE;
+}
+
+static inline 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)
+{
+ static const unsigned char convert_5to8[] =
+ {
+ 0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
+ 0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
+ 0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
+ 0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
+ };
+ unsigned int x, y;
+ DWORD *tmp;
+ WORD color;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
+
+ tmp = HeapAlloc(GetProcessHeap(), 0, h * w * sizeof(DWORD));
+ if (!tmp)
+ {
+ ERR("Failed to allocate memory for conversion\n");
+ return FALSE;
+ }
+
+ for (y = 0; y < h; ++y)
+ {
+ const WORD *src_line = (const WORD *)(src + y * pitch_in);
+ DWORD *dst_line = tmp + y * w;
+ for (x = 0; x < w; ++x)
+ {
+ color = src_line[x];
+ if (alpha)
+ {
+ dst_line[x] = ((color & 0x8000) ? 0xff000000 : 0) |
+ convert_5to8[(color & 0x001f)] << 16 |
+ convert_5to8[(color & 0x03e0) >> 5] << 8 |
+ convert_5to8[(color & 0x7c00) >> 10];
+ }
+ else
+ {
+ dst_line[x] = 0xff000000 |
+ convert_5to8[(color & 0x001f)] << 16 |
+ convert_5to8[(color & 0x03e0) >> 5] << 8 |
+ convert_5to8[(color & 0x7c00) >> 10];
+ }
+ }
+ }
+
+ ptx_compress_dxtn(4, w, h, (BYTE *)tmp, destformat, dst, pitch_out);
+ HeapFree(GetProcessHeap(), 0, tmp);
+ return TRUE;
+}
+
+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)
+{
+ if (!txc_dxtn_handle)
+ return FALSE;
+
+ switch (format)
+ {
+ case WINED3DFMT_B8G8R8A8_UNORM:
+ return dxt1_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, TRUE);
+ case WINED3DFMT_B8G8R8X8_UNORM:
+ return dxt1_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, FALSE);
+ default:
+ break;
+ }
+
+ FIXME("Cannot find a conversion function from format DXT1 to %s.\n", debug_d3dformat(format));
+ return FALSE;
+}
+
+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)
+{
+ if (!txc_dxtn_handle)
+ return FALSE;
+
+ switch (format)
+ {
+ case WINED3DFMT_B8G8R8A8_UNORM:
+ return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, TRUE);
+ case WINED3DFMT_B8G8R8X8_UNORM:
+ return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT, FALSE);
+ case WINED3DFMT_B5G5R5A1_UNORM:
+ return x1r5g5b5_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, TRUE);
+ case WINED3DFMT_B5G5R5X1_UNORM:
+ return x1r5g5b5_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT, FALSE);
+ default:
+ break;
+ }
+
+ FIXME("Cannot find a conversion function from format %s to DXT1.\n", debug_d3dformat(format));
+ return FALSE;
+}
+
+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)
+{
+ if (!txc_dxtn_handle)
+ return FALSE;
+
+ switch (format)
+ {
+ case WINED3DFMT_B8G8R8A8_UNORM:
+ return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, TRUE);
+ case WINED3DFMT_B8G8R8X8_UNORM:
+ return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, FALSE);
+ default:
+ break;
+ }
+
+ FIXME("Cannot find a conversion function from format %s to DXT3.\n", debug_d3dformat(format));
+ return FALSE;
+}
+
+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)
+{
+ if (!txc_dxtn_handle)
+ return FALSE;
+
+ switch (format)
+ {
+ case WINED3DFMT_B8G8R8A8_UNORM:
+ return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, TRUE);
+ case WINED3DFMT_B8G8R8X8_UNORM:
+ return x8r8g8b8_to_dxtn(src, dst, pitch_in, pitch_out, w, h,
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, FALSE);
+ default:
+ break;
+ }
+
+ FIXME("Cannot find a conversion function from format %s to DXT5.\n", debug_d3dformat(format));
+ return FALSE;
+}
+
+BOOL wined3d_dxtn_init(void)
+{
+ static const char *soname[] =
+ {
+#ifdef SONAME_LIBTXC_DXTN
+ SONAME_LIBTXC_DXTN,
+#endif
+ "libtxc_dxtn.so",
+ "libtxc_dxtn_s2tc.so.0"
+ };
+ int i;
+
+ for (i = 0; i < sizeof(soname)/sizeof(soname[0]); i++)
+ {
+ txc_dxtn_handle = wine_dlopen(soname[i], RTLD_NOW, NULL, 0);
+ if (txc_dxtn_handle) break;
+ }
+
+ if (!txc_dxtn_handle)
+ {
+ FIXME("Wine cannot find the txc_dxtn library, DXTn software support unavailable.\n");
+ return FALSE;
+ }
+
+ #define LOAD_FUNCPTR(f) \
+ 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; \
+ }
+
+ LOAD_FUNCPTR(fetch_2d_texel_rgba_dxt1);
+ LOAD_FUNCPTR(tx_compress_dxtn);
+
+ #undef LOAD_FUNCPTR
+ return TRUE;
+
+error:
+ wine_dlclose(txc_dxtn_handle, NULL, 0);
+ txc_dxtn_handle = NULL;
+ return FALSE;
+}
+
+BOOL wined3d_dxtn_supported(void)
+{
+ return (txc_dxtn_handle != NULL);
+}
+
+void wined3d_dxtn_free(void)
+{
+ if (txc_dxtn_handle)
+ wine_dlclose(txc_dxtn_handle, NULL, 0);
+}
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 9ef917f..7201a7c 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1279,6 +1279,66 @@ static void convert_yuy2_r5g6b5(const BYTE *src, BYTE *dst,
}
}
+static void convert_dxt1_a8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
+}
+
+static void convert_dxt1_x8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
+}
+
+static void convert_a8r8g8b8_dxt1(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
+}
+
+static void convert_x8r8g8b8_dxt1(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
+}
+
+static void convert_a1r5g5b5_dxt1(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5A1_UNORM, w, h);
+}
+
+static void convert_x1r5g5b5_dxt1(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5X1_UNORM, w, h);
+}
+
+static void convert_a8r8g8b8_dxt3(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt3_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
+}
+
+static void convert_x8r8g8b8_dxt3(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt3_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
+}
+
+static void convert_a8r8g8b8_dxt5(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt5_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
+}
+
+static void convert_x8r8g8b8_dxt5(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt5_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
+}
+
struct d3dfmt_converter_desc
{
enum wined3d_format_id from, to;
@@ -1295,6 +1355,20 @@ static const struct d3dfmt_converter_desc converters[] =
{WINED3DFMT_YUY2, WINED3DFMT_B5G6R5_UNORM, convert_yuy2_r5g6b5},
};
+static const struct d3dfmt_converter_desc dxtn_converters[] =
+{
+ {WINED3DFMT_DXT1, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt1_a8r8g8b8},
+ {WINED3DFMT_DXT1, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt1_x8r8g8b8},
+ {WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_DXT1, convert_a8r8g8b8_dxt1},
+ {WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_DXT1, convert_x8r8g8b8_dxt1},
+ {WINED3DFMT_B5G5R5A1_UNORM, WINED3DFMT_DXT1, convert_a1r5g5b5_dxt1},
+ {WINED3DFMT_B5G5R5X1_UNORM, WINED3DFMT_DXT1, convert_x1r5g5b5_dxt1},
+ {WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_DXT3, convert_a8r8g8b8_dxt3},
+ {WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_DXT3, convert_x8r8g8b8_dxt3},
+ {WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_DXT5, convert_a8r8g8b8_dxt5},
+ {WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_DXT5, convert_x8r8g8b8_dxt5}
+};
+
static inline const struct d3dfmt_converter_desc *find_converter(enum wined3d_format_id from,
enum wined3d_format_id to)
{
@@ -1306,6 +1380,12 @@ static inline const struct d3dfmt_converter_desc *find_converter(enum wined3d_fo
return &converters[i];
}
+ for (i = 0; i < (sizeof(dxtn_converters) / sizeof(*dxtn_converters)); ++i)
+ {
+ if (dxtn_converters[i].from == from && dxtn_converters[i].to == to)
+ return wined3d_dxtn_supported() ? &dxtn_converters[i] : NULL;
+ }
+
return NULL;
}
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index b57bcdc..1de0e56 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -326,6 +326,8 @@ static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
if (appkey) RegCloseKey( appkey );
if (hkey) RegCloseKey( hkey );
+ wined3d_dxtn_init();
+
return TRUE;
}
@@ -357,6 +359,9 @@ static BOOL wined3d_dll_destroy(HINSTANCE hInstDLL)
DeleteCriticalSection(&wined3d_wndproc_cs);
DeleteCriticalSection(&wined3d_cs);
+
+ wined3d_dxtn_free();
+
return TRUE;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 7813df5..45fe82a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4447,6 +4447,19 @@ static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
assert(cs->thread_id != GetCurrentThreadId());
}
+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) DECLSPEC_HIDDEN;
+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) DECLSPEC_HIDDEN;
+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) DECLSPEC_HIDDEN;
+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) DECLSPEC_HIDDEN;
+
+BOOL wined3d_dxtn_init(void) DECLSPEC_HIDDEN;
+BOOL wined3d_dxtn_supported(void) DECLSPEC_HIDDEN;
+void wined3d_dxtn_free(void) DECLSPEC_HIDDEN;
+
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
--
2.7.4

File diff suppressed because it is too large Load Diff

View File

@ -1,269 +0,0 @@
From 3887fb8fe306cce71cd026c060346083659bf20b Mon Sep 17 00:00:00 2001
From: Christian Costa <titan.costa@gmail.com>
Date: Tue, 4 Nov 2014 22:41:45 +0100
Subject: wined3d: Improve DXTn support and export conversion functions for
d3dx9_36.
---
dlls/wined3d/dxtn.c | 108 +++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/surface.c | 31 ++++++++++++
dlls/wined3d/wined3d.spec | 8 +++
dlls/wined3d/wined3d_private.h | 10 ----
include/wine/wined3d.h | 14 ++++++
5 files changed, 161 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/dxtn.c b/dlls/wined3d/dxtn.c
index ce989490ef..77f7d550a5 100644
--- a/dlls/wined3d/dxtn.c
+++ b/dlls/wined3d/dxtn.c
@@ -25,6 +25,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
static void* txc_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);
@@ -60,6 +62,70 @@ static inline BOOL dxt1_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in,
return TRUE;
}
+static inline BOOL dxt3_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in,
+ DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
+{
+ unsigned int x, y;
+ DWORD color;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ /* pfetch_2d_texel_rgba_dxt3 doesn't correctly handle pitch */
+ pfetch_2d_texel_rgba_dxt3(0, src + (y / 4) * pitch_in + (x / 4) * 16,
+ x & 3, y & 3, &color);
+ if (alpha)
+ {
+ dst_line[x] = (color & 0xff00ff00) | ((color & 0xff) << 16) |
+ ((color & 0xff0000) >> 16);
+ }
+ else
+ {
+ dst_line[x] = 0xff000000 | ((color & 0xff) << 16) |
+ (color & 0xff00) | ((color & 0xff0000) >> 16);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+static inline BOOL dxt5_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in,
+ DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
+{
+ unsigned int x, y;
+ DWORD color;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ /* pfetch_2d_texel_rgba_dxt5 doesn't correctly handle pitch */
+ pfetch_2d_texel_rgba_dxt5(0, src + (y / 4) * pitch_in + (x / 4) * 16,
+ x & 3, y & 3, &color);
+ if (alpha)
+ {
+ dst_line[x] = (color & 0xff00ff00) | ((color & 0xff) << 16) |
+ ((color & 0xff0000) >> 16);
+ }
+ else
+ {
+ dst_line[x] = 0xff000000 | ((color & 0xff) << 16) |
+ (color & 0xff00) | ((color & 0xff0000) >> 16);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
static inline 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)
{
@@ -172,6 +238,46 @@ BOOL wined3d_dxt1_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch
return FALSE;
}
+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)
+{
+ if (!txc_dxtn_handle)
+ return FALSE;
+
+ switch (format)
+ {
+ case WINED3DFMT_B8G8R8A8_UNORM:
+ return dxt3_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, TRUE);
+ case WINED3DFMT_B8G8R8X8_UNORM:
+ return dxt3_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, FALSE);
+ default:
+ break;
+ }
+
+ FIXME("Cannot find a conversion function from format DXT3 to %s.\n", debug_d3dformat(format));
+ return FALSE;
+}
+
+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)
+{
+ if (!txc_dxtn_handle)
+ return FALSE;
+
+ switch (format)
+ {
+ case WINED3DFMT_B8G8R8A8_UNORM:
+ return dxt5_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, TRUE);
+ case WINED3DFMT_B8G8R8X8_UNORM:
+ return dxt5_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, FALSE);
+ default:
+ break;
+ }
+
+ FIXME("Cannot find a conversion function from format DXT5 to %s.\n", debug_d3dformat(format));
+ return FALSE;
+}
+
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)
{
@@ -276,6 +382,8 @@ BOOL wined3d_dxtn_init(void)
}
LOAD_FUNCPTR(fetch_2d_texel_rgba_dxt1);
+ LOAD_FUNCPTR(fetch_2d_texel_rgba_dxt3);
+ LOAD_FUNCPTR(fetch_2d_texel_rgba_dxt5);
LOAD_FUNCPTR(tx_compress_dxtn);
#undef LOAD_FUNCPTR
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 3a91e98e98..a694de41d2 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1227,6 +1227,30 @@ static void convert_dxt1_x8r8g8b8(const BYTE *src, BYTE *dst,
wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
+static void convert_dxt3_a8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
+}
+
+static void convert_dxt3_x8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
+}
+
+static void convert_dxt5_a8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt5_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
+}
+
+static void convert_dxt5_x8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt5_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
+}
+
static void convert_a8r8g8b8_dxt1(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
@@ -1293,8 +1317,15 @@ static const struct d3dfmt_converter_desc converters[] =
static const struct d3dfmt_converter_desc dxtn_converters[] =
{
+ /* decode DXT */
{WINED3DFMT_DXT1, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt1_a8r8g8b8},
{WINED3DFMT_DXT1, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt1_x8r8g8b8},
+ {WINED3DFMT_DXT3, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt3_a8r8g8b8},
+ {WINED3DFMT_DXT3, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt3_x8r8g8b8},
+ {WINED3DFMT_DXT5, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt5_a8r8g8b8},
+ {WINED3DFMT_DXT5, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt5_x8r8g8b8},
+
+ /* encode DXT */
{WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_DXT1, convert_a8r8g8b8_dxt1},
{WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_DXT1, convert_x8r8g8b8_dxt1},
{WINED3DFMT_B5G5R5A1_UNORM, WINED3DFMT_DXT1, convert_a1r5g5b5_dxt1},
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 12246122f0..ed943dcf69 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -295,3 +295,11 @@
@ cdecl wined3d_vertex_declaration_decref(ptr)
@ cdecl wined3d_vertex_declaration_get_parent(ptr)
@ cdecl wined3d_vertex_declaration_incref(ptr)
+
+@ cdecl wined3d_dxtn_supported()
+@ cdecl wined3d_dxt1_decode(ptr ptr long long long long long)
+@ cdecl wined3d_dxt1_encode(ptr ptr long long long long long)
+@ cdecl wined3d_dxt3_decode(ptr ptr long long long long long)
+@ cdecl wined3d_dxt3_encode(ptr ptr long long long long long)
+@ cdecl wined3d_dxt5_decode(ptr ptr long long long long long)
+@ cdecl wined3d_dxt5_encode(ptr ptr long long long long long)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index e6f9ebc79a..a5eeb31f3e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4062,17 +4062,7 @@ static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
assert(cs->thread_id != GetCurrentThreadId());
}
-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) DECLSPEC_HIDDEN;
-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) DECLSPEC_HIDDEN;
-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) DECLSPEC_HIDDEN;
-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) DECLSPEC_HIDDEN;
-
BOOL wined3d_dxtn_init(void) DECLSPEC_HIDDEN;
-BOOL wined3d_dxtn_supported(void) DECLSPEC_HIDDEN;
void wined3d_dxtn_free(void) DECLSPEC_HIDDEN;
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 2831357c6e..bbd5be95bf 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2680,4 +2680,18 @@ static inline void wined3d_box_set(struct wined3d_box *box, unsigned int left, u
box->back = back;
}
+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_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_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_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_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_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_supported(void);
+
#endif /* __WINE_WINED3D_H */
--
2.11.0

View File

@ -1,223 +0,0 @@
From 69d910d52fb2c6a98a6658faa2efa9b95982e68b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Wed, 26 Nov 2014 14:24:57 +0100
Subject: wined3d: add DXT1 to B4G4R4A4, DXT1 to B5G5R5A1 and DXT3 to B4G4R4A4
conversion.
---
dlls/wined3d/dxtn.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/surface.c | 42 +++++++++++++++++++
2 files changed, 150 insertions(+)
diff --git a/dlls/wined3d/dxtn.c b/dlls/wined3d/dxtn.c
index 6623e64..57da0df 100644
--- a/dlls/wined3d/dxtn.c
+++ b/dlls/wined3d/dxtn.c
@@ -64,6 +64,70 @@ static inline BOOL dxt1_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in,
return TRUE;
}
+static inline BOOL dxt1_to_x4r4g4b4(const BYTE *src, BYTE *dst, DWORD pitch_in,
+ DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
+{
+ unsigned int x, y;
+ DWORD color;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ WORD *dst_line = (WORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ /* pfetch_2d_texel_rgba_dxt1 doesn't correctly handle pitch */
+ pfetch_2d_texel_rgba_dxt1(0, src + (y / 4) * pitch_in + (x / 4) * 16,
+ x & 3, y & 3, &color);
+ if (alpha)
+ {
+ dst_line[x] = ((color & 0xf0000000) >> 16) | ((color & 0xf00000) >> 20) |
+ ((color & 0xf000) >> 8) | ((color & 0xf0) << 4);
+ }
+ else
+ {
+ dst_line[x] = 0xf000 | ((color & 0xf00000) >> 20) |
+ ((color & 0xf000) >> 8) | ((color & 0xf0) << 4);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+static inline BOOL dxt1_to_x1r5g5b5(const BYTE *src, BYTE *dst, DWORD pitch_in,
+ DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
+{
+ unsigned int x, y;
+ DWORD color;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ WORD *dst_line = (WORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ /* pfetch_2d_texel_rgba_dxt1 doesn't correctly handle pitch */
+ pfetch_2d_texel_rgba_dxt1(0, src + (y / 4) * pitch_in + (x / 4) * 16,
+ x & 3, y & 3, &color);
+ if (alpha)
+ {
+ dst_line[x] = ((color & 0x80000000) >> 16) | ((color & 0xf80000) >> 19) |
+ ((color & 0xf800) >> 6) | ((color & 0xf8) << 7);
+ }
+ else
+ {
+ dst_line[x] = 0x8000 | ((color & 0xf80000) >> 19) |
+ ((color & 0xf800) >> 6) | ((color & 0xf8) << 7);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
static inline BOOL dxt3_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in,
DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
{
@@ -96,6 +160,38 @@ static inline BOOL dxt3_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in,
return TRUE;
}
+static inline BOOL dxt3_to_x4r4g4b4(const BYTE *src, BYTE *dst, DWORD pitch_in,
+ DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
+{
+ unsigned int x, y;
+ DWORD color;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ WORD *dst_line = (WORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ /* pfetch_2d_texel_rgba_dxt3 doesn't correctly handle pitch */
+ pfetch_2d_texel_rgba_dxt3(0, src + (y / 4) * pitch_in + (x / 4) * 16,
+ x & 3, y & 3, &color);
+ if (alpha)
+ {
+ dst_line[x] = ((color & 0xf0000000) >> 16) | ((color & 0xf00000) >> 20) |
+ ((color & 0xf000) >> 8) | ((color & 0xf0) << 4);
+ }
+ else
+ {
+ dst_line[x] = 0xf000 | ((color & 0xf00000) >> 20) |
+ ((color & 0xf000) >> 8) | ((color & 0xf0) << 4);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
static inline BOOL dxt5_to_x8r8g8b8(const BYTE *src, BYTE *dst, DWORD pitch_in,
DWORD pitch_out, unsigned int w, unsigned int h, BOOL alpha)
{
@@ -232,6 +328,14 @@ BOOL wined3d_dxt1_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch
return dxt1_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, TRUE);
case WINED3DFMT_B8G8R8X8_UNORM:
return dxt1_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, FALSE);
+ case WINED3DFMT_B4G4R4A4_UNORM:
+ return dxt1_to_x4r4g4b4(src, dst, pitch_in, pitch_out, w, h, TRUE);
+ case WINED3DFMT_B4G4R4X4_UNORM:
+ return dxt1_to_x4r4g4b4(src, dst, pitch_in, pitch_out, w, h, FALSE);
+ case WINED3DFMT_B5G5R5A1_UNORM:
+ return dxt1_to_x1r5g5b5(src, dst, pitch_in, pitch_out, w, h, TRUE);
+ case WINED3DFMT_B5G5R5X1_UNORM:
+ return dxt1_to_x1r5g5b5(src, dst, pitch_in, pitch_out, w, h, FALSE);
default:
break;
}
@@ -252,6 +356,10 @@ BOOL wined3d_dxt3_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch
return dxt3_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, TRUE);
case WINED3DFMT_B8G8R8X8_UNORM:
return dxt3_to_x8r8g8b8(src, dst, pitch_in, pitch_out, w, h, FALSE);
+ case WINED3DFMT_B4G4R4A4_UNORM:
+ return dxt3_to_x4r4g4b4(src, dst, pitch_in, pitch_out, w, h, TRUE);
+ case WINED3DFMT_B4G4R4X4_UNORM:
+ return dxt3_to_x4r4g4b4(src, dst, pitch_in, pitch_out, w, h, FALSE);
default:
break;
}
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 4fc917d..689fc0e 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2428,6 +2428,30 @@ static void convert_dxt1_x8r8g8b8(const BYTE *src, BYTE *dst,
wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
+static void convert_dxt1_a4r4g4b4(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4A4_UNORM, w, h);
+}
+
+static void convert_dxt1_x4r4g4b4(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4X4_UNORM, w, h);
+}
+
+static void convert_dxt1_a1r5g5b5(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5A1_UNORM, w, h);
+}
+
+static void convert_dxt1_x1r5g5b5(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5X1_UNORM, w, h);
+}
+
static void convert_dxt3_a8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
@@ -2440,6 +2464,18 @@ static void convert_dxt3_x8r8g8b8(const BYTE *src, BYTE *dst,
wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
}
+static void convert_dxt3_a4r4g4b4(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4A4_UNORM, w, h);
+}
+
+static void convert_dxt3_x4r4g4b4(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4X4_UNORM, w, h);
+}
+
static void convert_dxt5_a8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
@@ -2521,8 +2557,14 @@ static const struct d3dfmt_converter_desc dxtn_converters[] =
/* decode DXT */
{WINED3DFMT_DXT1, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt1_a8r8g8b8},
{WINED3DFMT_DXT1, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt1_x8r8g8b8},
+ {WINED3DFMT_DXT1, WINED3DFMT_B4G4R4A4_UNORM, convert_dxt1_a4r4g4b4},
+ {WINED3DFMT_DXT1, WINED3DFMT_B4G4R4X4_UNORM, convert_dxt1_x4r4g4b4},
+ {WINED3DFMT_DXT1, WINED3DFMT_B5G5R5A1_UNORM, convert_dxt1_a1r5g5b5},
+ {WINED3DFMT_DXT1, WINED3DFMT_B5G5R5X1_UNORM, convert_dxt1_x1r5g5b5},
{WINED3DFMT_DXT3, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt3_a8r8g8b8},
{WINED3DFMT_DXT3, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt3_x8r8g8b8},
+ {WINED3DFMT_DXT3, WINED3DFMT_B4G4R4A4_UNORM, convert_dxt3_a4r4g4b4},
+ {WINED3DFMT_DXT3, WINED3DFMT_B4G4R4X4_UNORM, convert_dxt3_x4r4g4b4},
{WINED3DFMT_DXT5, WINED3DFMT_B8G8R8A8_UNORM, convert_dxt5_a8r8g8b8},
{WINED3DFMT_DXT5, WINED3DFMT_B8G8R8X8_UNORM, convert_dxt5_x8r8g8b8},
--
2.2.1

View File

@ -1,27 +0,0 @@
From d8452914d07d7a24aa2647bf7c98383d962693f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 27 Jun 2015 22:26:14 +0200
Subject: wined3d: Load dxtn dylib library on Mac OS X.
---
dlls/wined3d/dxtn.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/dlls/wined3d/dxtn.c b/dlls/wined3d/dxtn.c
index 2639788..03e4b26 100644
--- a/dlls/wined3d/dxtn.c
+++ b/dlls/wined3d/dxtn.c
@@ -465,6 +465,10 @@ BOOL wined3d_dxtn_init(void)
#ifdef SONAME_LIBTXC_DXTN
SONAME_LIBTXC_DXTN,
#endif
+#ifdef __APPLE__
+ "libtxc_dxtn.dylib",
+ "libtxc_dxtn_s2tc.dylib",
+#endif
"libtxc_dxtn.so",
"libtxc_dxtn_s2tc.so.0"
};
--
2.4.3