Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
e4d37a45
Commit
e4d37a45
authored
Oct 20, 2022
by
Zebediah Figura
Committed by
Alexandre Julliard
Nov 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d8/tests: Test drawing from a managed texture after Reset().
parent
1ed24f7e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
150 additions
and
3 deletions
+150
-3
visual.c
dlls/d3d8/tests/visual.c
+150
-3
No files found.
dlls/d3d8/tests/visual.c
View file @
e4d37a45
...
...
@@ -19,6 +19,7 @@
/* See comment in dlls/d3d9/tests/visual.c for general guidelines */
#include <stdbool.h>
#include <limits.h>
#include <math.h>
...
...
@@ -41,6 +42,14 @@ struct vec4
float
x
,
y
,
z
,
w
;
};
struct
d3d8_test_context
{
HWND
window
;
IDirect3D8
*
d3d
;
IDirect3DDevice8
*
device
;
IDirect3DSurface8
*
backbuffer
;
};
static
HWND
create_window
(
void
)
{
RECT
rect
;
...
...
@@ -239,8 +248,9 @@ static void check_rect(struct surface_readback *rb, RECT r, const char *message)
}
}
#define check_rt_color(a, b) check_rt_color_(__LINE__, a, b)
static
void
check_rt_color_
(
unsigned
int
line
,
IDirect3DSurface8
*
rt
,
D3DCOLOR
expected_color
)
#define check_rt_color(a, b) check_rt_color_(__LINE__, a, b, false)
#define check_rt_color_todo(a, b) check_rt_color_(__LINE__, a, b, true)
static
void
check_rt_color_
(
unsigned
int
line
,
IDirect3DSurface8
*
rt
,
D3DCOLOR
expected_color
,
bool
todo
)
{
unsigned
int
color
=
0xdeadbeef
;
struct
surface_readback
rb
;
...
...
@@ -264,7 +274,8 @@ static void check_rt_color_(unsigned int line, IDirect3DSurface8 *rt, D3DCOLOR e
break
;
}
release_surface_readback
(
&
rb
);
ok_
(
__FILE__
,
line
)(
color
==
expected_color
,
"Got unexpected color 0x%08x.
\n
"
,
color
);
todo_wine_if
(
todo
)
ok_
(
__FILE__
,
line
)(
color
==
expected_color
,
"Got unexpected color 0x%08x.
\n
"
,
color
);
}
static
IDirect3DDevice8
*
create_device
(
IDirect3D8
*
d3d
,
HWND
device_window
,
HWND
focus_window
,
BOOL
windowed
)
...
...
@@ -288,6 +299,101 @@ static IDirect3DDevice8 *create_device(IDirect3D8 *d3d, HWND device_window, HWND
return
NULL
;
}
static
bool
init_test_context
(
struct
d3d8_test_context
*
context
)
{
HRESULT
hr
;
memset
(
context
,
0
,
sizeof
(
*
context
));
context
->
window
=
create_window
();
context
->
d3d
=
Direct3DCreate8
(
D3D_SDK_VERSION
);
ok
(
!!
context
->
d3d
,
"Failed to create a D3D object.
\n
"
);
if
(
!
(
context
->
device
=
create_device
(
context
->
d3d
,
context
->
window
,
context
->
window
,
TRUE
)))
{
skip
(
"Failed to create a D3D device.
\n
"
);
IDirect3D8_Release
(
context
->
d3d
);
DestroyWindow
(
context
->
window
);
return
false
;
}
hr
=
IDirect3DDevice8_GetRenderTarget
(
context
->
device
,
&
context
->
backbuffer
);
ok
(
hr
==
S_OK
,
"Failed to get backbuffer, hr %#lx.
\n
"
,
hr
);
return
true
;
}
#define release_test_context(a) release_test_context_(__LINE__, a)
static
void
release_test_context_
(
unsigned
int
line
,
struct
d3d8_test_context
*
context
)
{
ULONG
refcount
;
IDirect3DSurface8_Release
(
context
->
backbuffer
);
refcount
=
IDirect3DDevice8_Release
(
context
->
device
);
ok
(
!
refcount
,
"Device has %lu references left.
\n
"
,
refcount
);
refcount
=
IDirect3D8_Release
(
context
->
d3d
);
ok
(
!
refcount
,
"D3D object has %lu references left.
\n
"
,
refcount
);
DestroyWindow
(
context
->
window
);
}
static
void
draw_textured_quad
(
struct
d3d8_test_context
*
context
,
IDirect3DTexture8
*
texture
)
{
IDirect3DDevice8
*
device
=
context
->
device
;
HRESULT
hr
;
static
const
struct
{
struct
vec3
position
;
struct
vec2
texcoord
;
}
quad
[]
=
{
{{
-
1
.
0
f
,
-
1
.
0
f
,
0
.
0
f
},
{
0
.
0
f
,
0
.
0
f
}},
{{
-
1
.
0
f
,
1
.
0
f
,
0
.
0
f
},
{
0
.
0
f
,
1
.
0
f
}},
{{
1
.
0
f
,
-
1
.
0
f
,
0
.
0
f
},
{
1
.
0
f
,
0
.
0
f
}},
{{
1
.
0
f
,
1
.
0
f
,
0
.
0
f
},
{
1
.
0
f
,
1
.
0
f
}},
};
hr
=
IDirect3DDevice8_SetRenderState
(
device
,
D3DRS_ZENABLE
,
FALSE
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice8_SetVertexShader
(
device
,
D3DFVF_XYZ
|
D3DFVF_TEX1
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice8_SetTextureStageState
(
device
,
0
,
D3DTSS_COLOROP
,
D3DTOP_SELECTARG1
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice8_SetTextureStageState
(
device
,
0
,
D3DTSS_COLORARG1
,
D3DTA_TEXTURE
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice8_SetTexture
(
device
,
0
,
(
IDirect3DBaseTexture8
*
)
texture
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice8_BeginScene
(
device
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice8_DrawPrimitiveUP
(
device
,
D3DPT_TRIANGLESTRIP
,
2
,
&
quad
,
sizeof
(
*
quad
));
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice8_EndScene
(
device
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
}
static
HRESULT
reset_device
(
struct
d3d8_test_context
*
context
)
{
D3DPRESENT_PARAMETERS
present_parameters
=
{
0
};
HRESULT
hr
;
IDirect3DSurface8_Release
(
context
->
backbuffer
);
present_parameters
.
BackBufferWidth
=
640
;
present_parameters
.
BackBufferHeight
=
480
;
present_parameters
.
BackBufferFormat
=
D3DFMT_A8R8G8B8
;
present_parameters
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
present_parameters
.
hDeviceWindow
=
context
->
window
;
present_parameters
.
Windowed
=
TRUE
;
present_parameters
.
EnableAutoDepthStencil
=
TRUE
;
present_parameters
.
AutoDepthStencilFormat
=
D3DFMT_D24S8
;
hr
=
IDirect3DDevice8_Reset
(
context
->
device
,
&
present_parameters
);
if
(
SUCCEEDED
(
hr
))
IDirect3DDevice8_GetRenderTarget
(
context
->
device
,
&
context
->
backbuffer
);
return
hr
;
}
static
void
test_sanity
(
void
)
{
IDirect3DDevice8
*
device
;
...
...
@@ -5398,6 +5504,15 @@ static void fill_surface(IDirect3DSurface8 *surface, DWORD color, DWORD flags)
ok
(
SUCCEEDED
(
hr
),
"Failed to unlock surface, hr %#lx.
\n
"
,
hr
);
}
static
void
fill_texture
(
IDirect3DTexture8
*
texture
,
DWORD
color
,
DWORD
flags
)
{
IDirect3DSurface8
*
surface
;
IDirect3DTexture8_GetSurfaceLevel
(
texture
,
0
,
&
surface
);
fill_surface
(
surface
,
color
,
flags
);
IDirect3DSurface8_Release
(
surface
);
}
static
void
add_dirty_rect_test_draw
(
IDirect3DDevice8
*
device
)
{
HRESULT
hr
;
...
...
@@ -11979,6 +12094,37 @@ static void test_filling_convention(void)
DestroyWindow
(
window
);
}
static
void
test_managed_reset
(
void
)
{
struct
d3d8_test_context
context
;
IDirect3DTexture8
*
texture
;
IDirect3DDevice8
*
device
;
HRESULT
hr
;
if
(
!
init_test_context
(
&
context
))
return
;
device
=
context
.
device
;
hr
=
IDirect3DDevice8_CreateTexture
(
device
,
256
,
256
,
1
,
0
,
D3DFMT_A8R8G8B8
,
D3DPOOL_MANAGED
,
&
texture
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
fill_texture
(
texture
,
0x0000ff00
,
0
);
draw_textured_quad
(
&
context
,
texture
);
check_rt_color
(
context
.
backbuffer
,
0x0000ff00
);
hr
=
reset_device
(
&
context
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
hr
=
IDirect3DDevice8_Clear
(
device
,
0
,
NULL
,
D3DCLEAR_TARGET
,
0xffff0000
,
0
.
0
,
0
);
ok
(
hr
==
S_OK
,
"Got hr %#lx.
\n
"
,
hr
);
draw_textured_quad
(
&
context
,
texture
);
check_rt_color_todo
(
context
.
backbuffer
,
0x0000ff00
);
IDirect3DTexture8_Release
(
texture
);
release_test_context
(
&
context
);
}
START_TEST
(
visual
)
{
D3DADAPTER_IDENTIFIER8
identifier
;
...
...
@@ -12060,4 +12206,5 @@ START_TEST(visual)
test_sample_mask
();
test_dynamic_map_synchronization
();
test_filling_convention
();
test_managed_reset
();
}
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