Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
1569698d
Commit
1569698d
authored
Nov 10, 2014
by
Matteo Bruni
Committed by
Alexandre Julliard
Nov 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9: Use an alpha-capable format when creating textures with a color key.
parent
fb9c01f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
142 additions
and
1 deletion
+142
-1
texture.c
dlls/d3dx9_36/tests/texture.c
+113
-0
texture.c
dlls/d3dx9_36/texture.c
+29
-1
No files found.
dlls/d3dx9_36/tests/texture.c
View file @
1569698d
...
...
@@ -87,6 +87,16 @@ static const unsigned char dds_volume_map[] = {
0x0f
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x10
,
0x84
,
0xef
,
0x7b
,
0xaa
,
0xab
,
0xab
,
0xab
};
static
const
unsigned
char
png_grayscale
[]
=
{
0x89
,
0x50
,
0x4e
,
0x47
,
0x0d
,
0x0a
,
0x1a
,
0x0a
,
0x00
,
0x00
,
0x00
,
0x0d
,
0x49
,
0x48
,
0x44
,
0x52
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x3a
,
0x7e
,
0x9b
,
0x55
,
0x00
,
0x00
,
0x00
,
0x0a
,
0x49
,
0x44
,
0x41
,
0x54
,
0x08
,
0xd7
,
0x63
,
0xf8
,
0x0f
,
0x00
,
0x01
,
0x01
,
0x01
,
0x00
,
0x1b
,
0xb6
,
0xee
,
0x56
,
0x00
,
0x00
,
0x00
,
0x00
,
0x49
,
0x45
,
0x4e
,
0x44
,
0xae
,
0x42
,
0x60
,
0x82
};
#define ADMITTED_ERROR 0.0001f
static
inline
float
relative_error
(
float
expected
,
float
got
)
...
...
@@ -1582,6 +1592,109 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
D3DUSAGE_DYNAMIC
|
D3DUSAGE_AUTOGENMIPMAP
,
D3DFMT_UNKNOWN
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
IDirect3DTexture9_Release
(
texture
);
/* Checking for color key format overrides. */
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
dds_16bit
,
sizeof
(
dds_16bit
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_UNKNOWN
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_X1R5G5B5
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_X1R5G5B5
);
IDirect3DTexture9_Release
(
texture
);
}
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
dds_16bit
,
sizeof
(
dds_16bit
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_UNKNOWN
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0xff000000
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_A1R5G5B5
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_A1R5G5B5
);
IDirect3DTexture9_Release
(
texture
);
}
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
dds_16bit
,
sizeof
(
dds_16bit
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_X1R5G5B5
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0xff000000
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_X1R5G5B5
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_X1R5G5B5
);
IDirect3DTexture9_Release
(
texture
);
}
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
dds_24bit
,
sizeof
(
dds_24bit
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_UNKNOWN
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_X8R8G8B8
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_X8R8G8B8
);
IDirect3DTexture9_Release
(
texture
);
}
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
dds_24bit
,
sizeof
(
dds_24bit
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_UNKNOWN
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0xff000000
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_A8R8G8B8
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_A8R8G8B8
);
IDirect3DTexture9_Release
(
texture
);
}
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
dds_24bit
,
sizeof
(
dds_24bit
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_X8R8G8B8
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0xff000000
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_X8R8G8B8
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_X8R8G8B8
);
IDirect3DTexture9_Release
(
texture
);
}
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
png_grayscale
,
sizeof
(
png_grayscale
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_UNKNOWN
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_L8
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_L8
);
IDirect3DTexture9_Release
(
texture
);
}
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
png_grayscale
,
sizeof
(
png_grayscale
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_UNKNOWN
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0xff000000
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_A8L8
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_A8L8
);
IDirect3DTexture9_Release
(
texture
);
}
hr
=
D3DXCreateTextureFromFileInMemoryEx
(
device
,
png_grayscale
,
sizeof
(
png_grayscale
),
D3DX_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0
,
D3DFMT_L8
,
D3DPOOL_DEFAULT
,
D3DX_DEFAULT
,
D3DX_DEFAULT
,
0xff000000
,
NULL
,
NULL
,
&
texture
);
ok
(
hr
==
D3D_OK
,
"D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.
\n
"
,
hr
,
D3D_OK
);
if
(
SUCCEEDED
(
hr
))
{
IDirect3DTexture9_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
IDirect3DSurface9_GetDesc
(
surface
,
&
desc
);
ok
(
desc
.
Format
==
D3DFMT_L8
,
"Returned format %u, expected %u
\n
"
,
desc
.
Format
,
D3DFMT_L8
);
IDirect3DTexture9_Release
(
texture
);
}
}
static
void
test_D3DXCreateCubeTextureFromFileInMemory
(
IDirect3DDevice9
*
device
)
...
...
dlls/d3dx9_36/texture.c
View file @
1569698d
...
...
@@ -538,6 +538,29 @@ HRESULT WINAPI D3DXCreateTexture(struct IDirect3DDevice9 *device, UINT width, UI
return
IDirect3DDevice9_CreateTexture
(
device
,
width
,
height
,
miplevels
,
usage
,
format
,
pool
,
texture
,
NULL
);
}
static
D3DFORMAT
get_alpha_replacement_format
(
D3DFORMAT
format
)
{
static
const
struct
{
D3DFORMAT
orig_format
;
D3DFORMAT
replacement_format
;
}
replacement_formats
[]
=
{
{
D3DFMT_X8R8G8B8
,
D3DFMT_A8R8G8B8
},
{
D3DFMT_X1R5G5B5
,
D3DFMT_A1R5G5B5
},
{
D3DFMT_X4R4G4B4
,
D3DFMT_A4R4G4B4
},
{
D3DFMT_X8B8G8R8
,
D3DFMT_A8B8G8R8
},
{
D3DFMT_L8
,
D3DFMT_A8L8
},
};
unsigned
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
replacement_formats
)
/
sizeof
(
replacement_formats
[
0
]);
++
i
)
if
(
replacement_formats
[
i
].
orig_format
==
format
)
return
replacement_formats
[
i
].
replacement_format
;
return
format
;
}
HRESULT
WINAPI
D3DXCreateTextureFromFileInMemoryEx
(
struct
IDirect3DDevice9
*
device
,
const
void
*
srcdata
,
UINT
srcdatasize
,
UINT
width
,
UINT
height
,
UINT
miplevels
,
DWORD
usage
,
D3DFORMAT
format
,
D3DPOOL
pool
,
DWORD
filter
,
DWORD
mipfilter
,
D3DCOLOR
colorkey
,
D3DXIMAGE_INFO
*
srcinfo
,
...
...
@@ -546,7 +569,7 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
IDirect3DTexture9
**
texptr
;
IDirect3DTexture9
*
buftex
;
IDirect3DSurface9
*
surface
;
BOOL
dynamic_texture
;
BOOL
dynamic_texture
,
format_specified
=
FALSE
;
D3DXIMAGE_INFO
imginfo
;
UINT
loaded_miplevels
,
skip_levels
;
D3DCAPS9
caps
;
...
...
@@ -585,6 +608,8 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
if
(
format
==
D3DFMT_UNKNOWN
||
format
==
D3DX_DEFAULT
)
format
=
imginfo
.
Format
;
else
format_specified
=
TRUE
;
if
(
width
==
D3DX_FROM_FILE
)
{
...
...
@@ -630,6 +655,9 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
return
hr
;
}
if
(
colorkey
&&
!
format_specified
)
format
=
get_alpha_replacement_format
(
format
);
if
(
imginfo
.
MipLevels
<
miplevels
&&
(
D3DFMT_DXT1
<=
imginfo
.
Format
&&
imginfo
.
Format
<=
D3DFMT_DXT5
))
{
FIXME
(
"Generation of mipmaps for compressed pixel formats is not implemented yet
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment