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
b70bc731
Commit
b70bc731
authored
Jun 02, 2007
by
H. Verbeet
Committed by
Alexandre Julliard
Jun 04, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d9: Add a test for calling DrawIndexedPrimitive with a NULL index buffer.
parent
93dcfe35
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
device.c
dlls/d3d9/tests/device.c
+118
-0
No files found.
dlls/d3d9/tests/device.c
View file @
b70bc731
...
...
@@ -2,6 +2,7 @@
* Copyright (C) 2006 Vitaliy Margolen
* Copyright (C) 2006 Chris Robinson
* Copyright (C) 2006-2007 Stefan Dsinger(For CodeWeavers)
* Copyright 2007 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -1238,6 +1239,122 @@ cleanup:
if
(
hwnd
)
DestroyWindow
(
hwnd
);
}
/* Test what happens when IDirect3DDevice9_DrawIndexedPrimitive is called without a valid index buffer set. */
static
void
test_draw_indexed
(
void
)
{
static
const
struct
{
float
position
[
3
];
DWORD
color
;
}
quad
[]
=
{
{{
-
1
.
0
f
,
-
1
.
0
f
,
0
.
0
f
},
0xffff0000
},
{{
-
1
.
0
f
,
1
.
0
f
,
0
.
0
f
},
0xffff0000
},
{{
1
.
0
f
,
1
.
0
f
,
0
.
0
f
},
0xffff0000
},
{{
1
.
0
f
,
-
1
.
0
f
,
0
.
0
f
},
0xffff0000
},
};
WORD
indices
[]
=
{
0
,
1
,
2
,
3
,
0
,
2
};
static
const
D3DVERTEXELEMENT9
decl_elements
[]
=
{
{
0
,
0
,
D3DDECLTYPE_FLOAT3
,
D3DDECLMETHOD_DEFAULT
,
D3DDECLUSAGE_POSITION
,
0
},
{
0
,
12
,
D3DDECLTYPE_D3DCOLOR
,
D3DDECLMETHOD_DEFAULT
,
D3DDECLUSAGE_COLOR
,
0
},
D3DDECL_END
()
};
IDirect3DVertexDeclaration9
*
vertex_declaration
=
NULL
;
IDirect3DVertexBuffer9
*
vertex_buffer
=
NULL
;
IDirect3DIndexBuffer9
*
index_buffer
=
NULL
;
D3DPRESENT_PARAMETERS
present_parameters
;
IDirect3DDevice9
*
device
;
IDirect3D9
*
d3d9
;
HRESULT
hr
;
HWND
hwnd
;
void
*
ptr
;
hwnd
=
CreateWindow
(
"static"
,
"d3d9_test"
,
0
,
0
,
0
,
10
,
10
,
0
,
0
,
0
,
0
);
if
(
!
hwnd
)
{
skip
(
"Failed to create window
\n
"
);
return
;
}
d3d9
=
pDirect3DCreate9
(
D3D_SDK_VERSION
);
if
(
!
d3d9
)
{
skip
(
"Failed to create IDirect3D9 object
\n
"
);
goto
cleanup
;
}
ZeroMemory
(
&
present_parameters
,
sizeof
(
present_parameters
));
present_parameters
.
Windowed
=
TRUE
;
present_parameters
.
hDeviceWindow
=
hwnd
;
present_parameters
.
SwapEffect
=
D3DSWAPEFFECT_DISCARD
;
hr
=
IDirect3D9_CreateDevice
(
d3d9
,
D3DADAPTER_DEFAULT
,
D3DDEVTYPE_HAL
,
NULL
,
D3DCREATE_SOFTWARE_VERTEXPROCESSING
,
&
present_parameters
,
&
device
);
if
(
FAILED
(
hr
)
||
!
device
)
{
skip
(
"Failed to create device
\n
"
);
goto
cleanup
;
}
hr
=
IDirect3DDevice9_CreateVertexDeclaration
(
device
,
decl_elements
,
&
vertex_declaration
);
ok
(
SUCCEEDED
(
hr
),
"CreateVertexDeclaration failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetVertexDeclaration
(
device
,
vertex_declaration
);
ok
(
SUCCEEDED
(
hr
),
"SetVertexDeclaration failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_CreateVertexBuffer
(
device
,
sizeof
(
quad
),
0
,
0
,
D3DPOOL_DEFAULT
,
&
vertex_buffer
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"CreateVertexBuffer failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DVertexBuffer9_Lock
(
vertex_buffer
,
0
,
0
,
&
ptr
,
D3DLOCK_DISCARD
);
ok
(
SUCCEEDED
(
hr
),
"Lock failed (0x%08x)
\n
"
,
hr
);
memcpy
(
ptr
,
quad
,
sizeof
(
quad
));
hr
=
IDirect3DVertexBuffer9_Unlock
(
vertex_buffer
);
ok
(
SUCCEEDED
(
hr
),
"Unlock failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetStreamSource
(
device
,
0
,
vertex_buffer
,
0
,
sizeof
(
*
quad
));
ok
(
SUCCEEDED
(
hr
),
"SetStreamSource failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_CreateIndexBuffer
(
device
,
sizeof
(
indices
),
0
,
D3DFMT_INDEX16
,
D3DPOOL_DEFAULT
,
&
index_buffer
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"CreateIndexBuffer failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DIndexBuffer9_Lock
(
index_buffer
,
0
,
0
,
&
ptr
,
D3DLOCK_DISCARD
);
ok
(
SUCCEEDED
(
hr
),
"Lock failed (0x%08x)
\n
"
,
hr
);
memcpy
(
ptr
,
indices
,
sizeof
(
indices
));
hr
=
IDirect3DIndexBuffer9_Unlock
(
index_buffer
);
ok
(
SUCCEEDED
(
hr
),
"Unlock failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_SetRenderState
(
device
,
D3DRS_LIGHTING
,
FALSE
);
ok
(
SUCCEEDED
(
hr
),
"SetRenderState D3DRS_LIGHTING failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_BeginScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"BeginScene failed (0x%08x)
\n
"
,
hr
);
/* NULL index buffer. Should fail */
hr
=
IDirect3DDevice9_SetIndices
(
device
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"SetIndices failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_DrawIndexedPrimitive
(
device
,
D3DPT_TRIANGLELIST
,
0
/* BaseVertexIndex */
,
0
/* MinIndex */
,
4
/* NumVerts */
,
0
/* StartIndex */
,
2
/*PrimCount */
);
ok
(
hr
==
D3DERR_INVALIDCALL
,
"DrawIndexedPrimitive returned 0x%08x, expected D3DERR_INVALIDCALL (0x%08x)
\n
"
,
hr
,
D3DERR_INVALIDCALL
);
/* Valid index buffer. Should succeed */
hr
=
IDirect3DDevice9_SetIndices
(
device
,
index_buffer
);
ok
(
SUCCEEDED
(
hr
),
"SetIndices failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_DrawIndexedPrimitive
(
device
,
D3DPT_TRIANGLELIST
,
0
/* BaseVertexIndex */
,
0
/* MinIndex */
,
4
/* NumVerts */
,
0
/* StartIndex */
,
2
/*PrimCount */
);
ok
(
SUCCEEDED
(
hr
),
"DrawIndexedPrimitive failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_EndScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"EndScene failed (0x%08x)
\n
"
,
hr
);
hr
=
IDirect3DDevice9_Present
(
device
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Present failed (0x%08x)
\n
"
,
hr
);
IDirect3DVertexBuffer9_Release
(
vertex_buffer
);
IDirect3DIndexBuffer9_Release
(
index_buffer
);
IDirect3DVertexDeclaration9_Release
(
vertex_declaration
);
cleanup:
if
(
d3d9
)
IDirect3D9_Release
(
d3d9
);
if
(
device
)
IDirect3DDevice9_Release
(
device
);
if
(
hwnd
)
DestroyWindow
(
hwnd
);
}
START_TEST
(
device
)
{
HMODULE
d3d9_handle
=
LoadLibraryA
(
"d3d9.dll"
);
...
...
@@ -1260,5 +1377,6 @@ START_TEST(device)
test_scene
();
test_limits
();
test_depthstenciltest
();
test_draw_indexed
();
}
}
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