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
d3520ef4
Commit
d3520ef4
authored
Jan 10, 2013
by
Stefan Dösinger
Committed by
Alexandre Julliard
Jan 10, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Don't discard buffers that haven't been used in draws.
parent
5fd85293
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
174 additions
and
1 deletion
+174
-1
ddraw_private.h
dlls/ddraw/ddraw_private.h
+2
-0
device.c
dlls/ddraw/device.c
+7
-0
ddraw4.c
dlls/ddraw/tests/ddraw4.c
+80
-0
ddraw7.c
dlls/ddraw/tests/ddraw7.c
+80
-0
vertexbuffer.c
dlls/ddraw/vertexbuffer.c
+5
-1
No files found.
dlls/ddraw/ddraw_private.h
View file @
d3520ef4
...
...
@@ -535,6 +535,8 @@ struct d3d_vertex_buffer
DWORD
fvf
;
DWORD
size
;
BOOL
dynamic
;
BOOL
read_since_last_map
;
};
HRESULT
d3d_vertex_buffer_create
(
struct
d3d_vertex_buffer
**
buffer
,
struct
ddraw
*
ddraw
,
...
...
dlls/ddraw/device.c
View file @
d3520ef4
...
...
@@ -4113,6 +4113,10 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE
/* Now draw the primitives */
wined3d_device_set_primitive_type
(
device
->
wined3d_device
,
PrimitiveType
);
hr
=
wined3d_device_draw_primitive
(
device
->
wined3d_device
,
StartVertex
,
NumVertices
);
if
(
SUCCEEDED
(
hr
))
vb
->
read_since_last_map
=
TRUE
;
wined3d_mutex_unlock
();
return
hr
;
...
...
@@ -4236,6 +4240,9 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
wined3d_device_set_primitive_type
(
This
->
wined3d_device
,
PrimitiveType
);
hr
=
wined3d_device_draw_indexed_primitive
(
This
->
wined3d_device
,
ib_pos
/
sizeof
(
WORD
),
IndexCount
);
if
(
SUCCEEDED
(
hr
))
vb
->
read_since_last_map
=
TRUE
;
wined3d_mutex_unlock
();
return
hr
;
...
...
dlls/ddraw/tests/ddraw4.c
View file @
d3520ef4
...
...
@@ -2856,6 +2856,85 @@ static void test_coop_level_surf_create(void)
IDirectDraw4_Release
(
ddraw
);
}
static
void
test_vb_discard
(
void
)
{
static
const
struct
vec4
quad
[]
=
{
{
0
.
0
f
,
480
.
0
f
,
0
.
0
f
,
1
.
0
f
},
{
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
},
{
640
.
0
f
,
480
.
0
f
,
0
.
0
f
,
1
.
0
f
},
{
640
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
},
};
IDirect3DDevice3
*
device
;
IDirect3D3
*
d3d
;
IDirect3DVertexBuffer
*
buffer
;
HWND
window
;
HRESULT
hr
;
D3DVERTEXBUFFERDESC
desc
;
BYTE
*
data
;
static
const
unsigned
int
vbsize
=
16
;
unsigned
int
i
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
device
=
create_device
(
window
,
DDSCL_NORMAL
)))
{
skip
(
"Failed to create D3D device, skipping test.
\n
"
);
DestroyWindow
(
window
);
return
;
}
hr
=
IDirect3DDevice3_GetDirect3D
(
device
,
&
d3d
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get d3d interface, hr %#x.
\n
"
,
hr
);
memset
(
&
desc
,
0
,
sizeof
(
desc
));
desc
.
dwSize
=
sizeof
(
desc
);
desc
.
dwCaps
=
D3DVBCAPS_WRITEONLY
;
desc
.
dwFVF
=
D3DFVF_XYZRHW
;
desc
.
dwNumVertices
=
vbsize
;
hr
=
IDirect3D3_CreateVertexBuffer
(
d3d
,
&
desc
,
&
buffer
,
0
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create vertex buffer, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DVertexBuffer_Lock
(
buffer
,
DDLOCK_DISCARDCONTENTS
,
(
void
**
)
&
data
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to lock vertex buffer, hr %#x.
\n
"
,
hr
);
memcpy
(
data
,
quad
,
sizeof
(
quad
));
hr
=
IDirect3DVertexBuffer_Unlock
(
buffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to unlock vertex buffer, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_BeginScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to begin scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_DrawPrimitiveVB
(
device
,
D3DPT_TRIANGLESTRIP
,
buffer
,
0
,
4
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to draw, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice3_EndScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to end scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DVertexBuffer_Lock
(
buffer
,
DDLOCK_DISCARDCONTENTS
,
(
void
**
)
&
data
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to lock vertex buffer, hr %#x.
\n
"
,
hr
);
memset
(
data
,
0xaa
,
sizeof
(
struct
vec4
)
*
vbsize
);
hr
=
IDirect3DVertexBuffer_Unlock
(
buffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to unlock vertex buffer, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DVertexBuffer_Lock
(
buffer
,
DDLOCK_DISCARDCONTENTS
,
(
void
**
)
&
data
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to lock vertex buffer, hr %#x.
\n
"
,
hr
);
for
(
i
=
0
;
i
<
sizeof
(
struct
vec4
)
*
vbsize
;
i
++
)
{
if
(
data
[
i
]
!=
0xaa
)
{
ok
(
FALSE
,
"Vertex buffer data byte %u is 0x%02x, expected 0xaa
\n
"
,
i
,
data
[
i
]);
break
;
}
}
hr
=
IDirect3DVertexBuffer_Unlock
(
buffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to unlock vertex buffer, hr %#x.
\n
"
,
hr
);
IDirect3DVertexBuffer_Release
(
buffer
);
IDirect3D3_Release
(
d3d
);
IDirect3DDevice3_Release
(
device
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw4
)
{
test_process_vertices
();
...
...
@@ -2879,4 +2958,5 @@ START_TEST(ddraw4)
test_coop_level_mode_set_multi
();
test_initialize
();
test_coop_level_surf_create
();
test_vb_discard
();
}
dlls/ddraw/tests/ddraw7.c
View file @
d3520ef4
...
...
@@ -2665,6 +2665,85 @@ static void test_coop_level_surf_create(void)
IDirectDraw7_Release
(
ddraw
);
}
static
void
test_vb_discard
(
void
)
{
static
const
struct
vec4
quad
[]
=
{
{
0
.
0
f
,
480
.
0
f
,
0
.
0
f
,
1
.
0
f
},
{
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
},
{
640
.
0
f
,
480
.
0
f
,
0
.
0
f
,
1
.
0
f
},
{
640
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
},
};
IDirect3DDevice7
*
device
;
IDirect3D7
*
d3d
;
IDirect3DVertexBuffer7
*
buffer
;
HWND
window
;
HRESULT
hr
;
D3DVERTEXBUFFERDESC
desc
;
BYTE
*
data
;
static
const
unsigned
int
vbsize
=
16
;
unsigned
int
i
;
window
=
CreateWindowA
(
"static"
,
"ddraw_test"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
640
,
480
,
0
,
0
,
0
,
0
);
if
(
!
(
device
=
create_device
(
window
,
DDSCL_NORMAL
)))
{
skip
(
"Failed to create D3D device, skipping test.
\n
"
);
DestroyWindow
(
window
);
return
;
}
hr
=
IDirect3DDevice7_GetDirect3D
(
device
,
&
d3d
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get d3d interface, hr %#x.
\n
"
,
hr
);
memset
(
&
desc
,
0
,
sizeof
(
desc
));
desc
.
dwSize
=
sizeof
(
desc
);
desc
.
dwCaps
=
D3DVBCAPS_WRITEONLY
;
desc
.
dwFVF
=
D3DFVF_XYZRHW
;
desc
.
dwNumVertices
=
vbsize
;
hr
=
IDirect3D7_CreateVertexBuffer
(
d3d
,
&
desc
,
&
buffer
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create vertex buffer, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DVertexBuffer7_Lock
(
buffer
,
DDLOCK_DISCARDCONTENTS
,
(
void
**
)
&
data
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to lock vertex buffer, hr %#x.
\n
"
,
hr
);
memcpy
(
data
,
quad
,
sizeof
(
quad
));
hr
=
IDirect3DVertexBuffer7_Unlock
(
buffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to unlock vertex buffer, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice7_BeginScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to begin scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice7_DrawPrimitiveVB
(
device
,
D3DPT_TRIANGLESTRIP
,
buffer
,
0
,
4
,
0
);
ok
(
SUCCEEDED
(
hr
),
"Failed to draw, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DDevice7_EndScene
(
device
);
ok
(
SUCCEEDED
(
hr
),
"Failed to end scene, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DVertexBuffer7_Lock
(
buffer
,
DDLOCK_DISCARDCONTENTS
,
(
void
**
)
&
data
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to lock vertex buffer, hr %#x.
\n
"
,
hr
);
memset
(
data
,
0xaa
,
sizeof
(
struct
vec4
)
*
vbsize
);
hr
=
IDirect3DVertexBuffer7_Unlock
(
buffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to unlock vertex buffer, hr %#x.
\n
"
,
hr
);
hr
=
IDirect3DVertexBuffer7_Lock
(
buffer
,
DDLOCK_DISCARDCONTENTS
,
(
void
**
)
&
data
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to lock vertex buffer, hr %#x.
\n
"
,
hr
);
for
(
i
=
0
;
i
<
sizeof
(
struct
vec4
)
*
vbsize
;
i
++
)
{
if
(
data
[
i
]
!=
0xaa
)
{
ok
(
FALSE
,
"Vertex buffer data byte %u is 0x%02x, expected 0xaa
\n
"
,
i
,
data
[
i
]);
break
;
}
}
hr
=
IDirect3DVertexBuffer7_Unlock
(
buffer
);
ok
(
SUCCEEDED
(
hr
),
"Failed to unlock vertex buffer, hr %#x.
\n
"
,
hr
);
IDirect3DVertexBuffer7_Release
(
buffer
);
IDirect3D7_Release
(
d3d
);
IDirect3DDevice7_Release
(
device
);
DestroyWindow
(
window
);
}
START_TEST
(
ddraw7
)
{
HMODULE
module
=
GetModuleHandleA
(
"ddraw.dll"
);
...
...
@@ -2695,4 +2774,5 @@ START_TEST(ddraw7)
test_coop_level_mode_set_multi
();
test_initialize
();
test_coop_level_surf_create
();
test_vb_discard
();
}
dlls/ddraw/vertexbuffer.c
View file @
d3520ef4
...
...
@@ -245,7 +245,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_Lock(IDirect3DVertexBuffer7 *iface,
wined3d_flags
|=
WINED3D_MAP_READONLY
;
if
(
flags
&
DDLOCK_NOOVERWRITE
)
wined3d_flags
|=
WINED3D_MAP_NOOVERWRITE
;
if
(
flags
&
DDLOCK_DISCARDCONTENTS
)
if
(
flags
&
DDLOCK_DISCARDCONTENTS
&&
buffer
->
read_since_last_map
)
{
wined3d_flags
|=
WINED3D_MAP_DISCARD
;
...
...
@@ -278,6 +278,10 @@ static HRESULT WINAPI d3d_vertex_buffer7_Lock(IDirect3DVertexBuffer7 *iface,
}
hr
=
wined3d_buffer_map
(
buffer
->
wineD3DVertexBuffer
,
0
,
0
,
(
BYTE
**
)
data
,
wined3d_flags
);
if
(
SUCCEEDED
(
hr
))
buffer
->
read_since_last_map
=
FALSE
;
wined3d_mutex_unlock
();
return
hr
;
...
...
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