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
021ae0c3
Commit
021ae0c3
authored
Nov 16, 2017
by
Henri Verbeet
Committed by
Alexandre Julliard
Nov 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d11/tests: Introduce a format compatibility test.
Signed-off-by:
Henri Verbeet
<
hverbeet@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d192e9a1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
0 deletions
+133
-0
d3d11.c
dlls/d3d11/tests/d3d11.c
+133
-0
No files found.
dlls/d3d11/tests/d3d11.c
View file @
021ae0c3
...
...
@@ -22315,6 +22315,138 @@ static void test_conservative_depth_output(void)
release_test_context
(
&
test_context
);
}
static
void
test_format_compatibility
(
void
)
{
ID3D11Texture2D
*
dst_texture
,
*
src_texture
;
D3D11_SUBRESOURCE_DATA
resource_data
;
D3D11_TEXTURE2D_DESC
texture_desc
;
ID3D11DeviceContext
*
context
;
struct
resource_readback
rb
;
DWORD
colour
,
expected
;
ID3D11Device
*
device
;
unsigned
int
i
,
j
;
ULONG
refcount
;
HRESULT
hr
;
static
const
struct
{
DXGI_FORMAT
src_format
;
DXGI_FORMAT
dst_format
;
size_t
texel_size
;
BOOL
success
;
}
test_data
[]
=
{
{
DXGI_FORMAT_R8G8B8A8_TYPELESS
,
DXGI_FORMAT_R8G8B8A8_UNORM
,
4
,
TRUE
},
{
DXGI_FORMAT_R8G8B8A8_UNORM
,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
4
,
TRUE
},
{
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
,
DXGI_FORMAT_R8G8B8A8_UINT
,
4
,
TRUE
},
{
DXGI_FORMAT_R8G8B8A8_UINT
,
DXGI_FORMAT_R8G8B8A8_SNORM
,
4
,
TRUE
},
{
DXGI_FORMAT_R8G8B8A8_SNORM
,
DXGI_FORMAT_R8G8B8A8_SINT
,
4
,
TRUE
},
{
DXGI_FORMAT_R8G8B8A8_SINT
,
DXGI_FORMAT_R8G8B8A8_TYPELESS
,
4
,
TRUE
},
{
DXGI_FORMAT_R8G8B8A8_UNORM
,
DXGI_FORMAT_B8G8R8A8_UNORM
,
4
,
FALSE
},
{
DXGI_FORMAT_R8G8B8A8_UINT
,
DXGI_FORMAT_R16G16_UINT
,
4
,
FALSE
},
{
DXGI_FORMAT_R16G16_TYPELESS
,
DXGI_FORMAT_R16G16_FLOAT
,
4
,
TRUE
},
{
DXGI_FORMAT_R16G16_FLOAT
,
DXGI_FORMAT_R16G16_UNORM
,
4
,
TRUE
},
{
DXGI_FORMAT_R16G16_UNORM
,
DXGI_FORMAT_R16G16_UINT
,
4
,
TRUE
},
{
DXGI_FORMAT_R16G16_UINT
,
DXGI_FORMAT_R16G16_SNORM
,
4
,
TRUE
},
{
DXGI_FORMAT_R16G16_SNORM
,
DXGI_FORMAT_R16G16_SINT
,
4
,
TRUE
},
{
DXGI_FORMAT_R16G16_SINT
,
DXGI_FORMAT_R16G16_TYPELESS
,
4
,
TRUE
},
{
DXGI_FORMAT_R16G16_TYPELESS
,
DXGI_FORMAT_R32_TYPELESS
,
4
,
FALSE
},
{
DXGI_FORMAT_R32G32_TYPELESS
,
DXGI_FORMAT_R32G32_FLOAT
,
8
,
TRUE
},
{
DXGI_FORMAT_R32G32_FLOAT
,
DXGI_FORMAT_R32G32_UINT
,
8
,
TRUE
},
{
DXGI_FORMAT_R32G32_UINT
,
DXGI_FORMAT_R32G32_SINT
,
8
,
TRUE
},
{
DXGI_FORMAT_R32G32_SINT
,
DXGI_FORMAT_R32G32_TYPELESS
,
8
,
TRUE
},
};
static
const
DWORD
initial_data
[
16
]
=
{
0
};
static
const
DWORD
bitmap_data
[]
=
{
0xff0000ff
,
0xff00ffff
,
0xff00ff00
,
0xffffff00
,
0xffff0000
,
0xffff00ff
,
0xff000000
,
0xff7f7f7f
,
0xffffffff
,
0xffffffff
,
0xffffffff
,
0xff000000
,
0xffffffff
,
0xff000000
,
0xff000000
,
0xff000000
,
};
if
(
!
(
device
=
create_device
(
NULL
)))
{
skip
(
"Failed to create device.
\n
"
);
return
;
}
ID3D11Device_GetImmediateContext
(
device
,
&
context
);
texture_desc
.
Height
=
4
;
texture_desc
.
MipLevels
=
1
;
texture_desc
.
ArraySize
=
1
;
texture_desc
.
SampleDesc
.
Count
=
1
;
texture_desc
.
SampleDesc
.
Quality
=
0
;
texture_desc
.
BindFlags
=
D3D11_BIND_SHADER_RESOURCE
;
texture_desc
.
CPUAccessFlags
=
0
;
texture_desc
.
MiscFlags
=
0
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
test_data
);
++
i
)
{
unsigned
int
x
,
y
,
texel_dwords
;
D3D11_BOX
box
;
texture_desc
.
Width
=
sizeof
(
bitmap_data
)
/
(
texture_desc
.
Height
*
test_data
[
i
].
texel_size
);
texture_desc
.
Format
=
test_data
[
i
].
src_format
;
texture_desc
.
Usage
=
D3D11_USAGE_IMMUTABLE
;
resource_data
.
pSysMem
=
bitmap_data
;
resource_data
.
SysMemPitch
=
texture_desc
.
Width
*
test_data
[
i
].
texel_size
;
resource_data
.
SysMemSlicePitch
=
0
;
hr
=
ID3D11Device_CreateTexture2D
(
device
,
&
texture_desc
,
&
resource_data
,
&
src_texture
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create source texture, hr %#x.
\n
"
,
hr
);
texture_desc
.
Format
=
test_data
[
i
].
dst_format
;
texture_desc
.
Usage
=
D3D11_USAGE_DEFAULT
;
resource_data
.
pSysMem
=
initial_data
;
hr
=
ID3D11Device_CreateTexture2D
(
device
,
&
texture_desc
,
&
resource_data
,
&
dst_texture
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create destination texture, hr %#x.
\n
"
,
hr
);
set_box
(
&
box
,
0
,
0
,
0
,
texture_desc
.
Width
-
1
,
texture_desc
.
Height
-
1
,
1
);
ID3D11DeviceContext_CopySubresourceRegion
(
context
,
(
ID3D11Resource
*
)
dst_texture
,
0
,
1
,
1
,
0
,
(
ID3D11Resource
*
)
src_texture
,
0
,
&
box
);
texel_dwords
=
test_data
[
i
].
texel_size
/
sizeof
(
DWORD
);
get_texture_readback
(
dst_texture
,
0
,
&
rb
);
for
(
j
=
0
;
j
<
ARRAY_SIZE
(
bitmap_data
);
++
j
)
{
x
=
j
%
4
;
y
=
j
/
4
;
colour
=
get_readback_color
(
&
rb
,
x
,
y
);
expected
=
test_data
[
i
].
success
&&
x
>=
texel_dwords
&&
y
?
bitmap_data
[
j
-
(
4
+
texel_dwords
)]
:
initial_data
[
j
];
ok
(
colour
==
expected
,
"Test %u: Got unexpected colour 0x%08x at (%u, %u), expected 0x%08x.
\n
"
,
i
,
colour
,
x
,
y
,
expected
);
}
release_resource_readback
(
&
rb
);
ID3D11DeviceContext_CopyResource
(
context
,
(
ID3D11Resource
*
)
dst_texture
,
(
ID3D11Resource
*
)
src_texture
);
get_texture_readback
(
dst_texture
,
0
,
&
rb
);
for
(
j
=
0
;
j
<
ARRAY_SIZE
(
bitmap_data
);
++
j
)
{
x
=
j
%
4
;
y
=
j
/
4
;
colour
=
get_readback_color
(
&
rb
,
x
,
y
);
expected
=
test_data
[
i
].
success
?
bitmap_data
[
j
]
:
initial_data
[
j
];
ok
(
colour
==
expected
,
"Test %u: Got unexpected colour 0x%08x at (%u, %u), expected 0x%08x.
\n
"
,
i
,
colour
,
x
,
y
,
expected
);
}
release_resource_readback
(
&
rb
);
ID3D11Texture2D_Release
(
dst_texture
);
ID3D11Texture2D_Release
(
src_texture
);
}
ID3D11DeviceContext_Release
(
context
);
refcount
=
ID3D11Device_Release
(
device
);
ok
(
!
refcount
,
"Device has %u references left.
\n
"
,
refcount
);
}
START_TEST
(
d3d11
)
{
test_create_device
();
...
...
@@ -22420,4 +22552,5 @@ START_TEST(d3d11)
test_fractional_viewports
();
test_early_depth_stencil
();
test_conservative_depth_output
();
test_format_compatibility
();
}
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