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
01197730
Commit
01197730
authored
Dec 18, 2012
by
Stefan Dösinger
Committed by
Alexandre Julliard
Dec 19, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d8: Use dynamic buffers for DrawIndexedPrimitiveUP.
parent
7dd4460b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
7 deletions
+115
-7
d3d8_private.h
dlls/d3d8/d3d8_private.h
+3
-0
device.c
dlls/d3d8/device.c
+112
-7
No files found.
dlls/d3d8/d3d8_private.h
View file @
01197730
...
...
@@ -162,6 +162,9 @@ struct d3d8_device
struct
wined3d_buffer
*
vertex_buffer
;
UINT
vertex_buffer_size
;
UINT
vertex_buffer_pos
;
struct
wined3d_buffer
*
index_buffer
;
UINT
index_buffer_size
;
UINT
index_buffer_pos
;
/* Avoids recursion with nested ReleaseRef to 0 */
BOOL
inDestruction
;
...
...
dlls/d3d8/device.c
View file @
01197730
...
...
@@ -359,6 +359,8 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface)
if
(
device
->
vertex_buffer
)
wined3d_buffer_decref
(
device
->
vertex_buffer
);
if
(
device
->
index_buffer
)
wined3d_buffer_decref
(
device
->
index_buffer
);
wined3d_device_uninit_3d
(
device
->
wined3d_device
);
wined3d_device_release_focus_window
(
device
->
wined3d_device
);
...
...
@@ -605,6 +607,12 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface,
device
->
vertex_buffer
=
NULL
;
device
->
vertex_buffer_size
=
0
;
}
if
(
device
->
index_buffer
)
{
wined3d_buffer_decref
(
device
->
index_buffer
);
device
->
index_buffer
=
NULL
;
device
->
index_buffer_size
=
0
;
}
wined3d_swapchain_desc_from_present_parameters
(
&
swapchain_desc
,
present_parameters
);
if
(
SUCCEEDED
(
hr
=
wined3d_device_reset
(
device
->
wined3d_device
,
&
swapchain_desc
,
...
...
@@ -1989,26 +1997,123 @@ done:
return
hr
;
}
/* The caller is responsible for wined3d locking */
static
HRESULT
d3d8_device_prepare_index_buffer
(
struct
d3d8_device
*
device
,
UINT
min_size
)
{
HRESULT
hr
;
if
(
device
->
index_buffer_size
<
min_size
||
!
device
->
index_buffer
)
{
UINT
size
=
max
(
device
->
index_buffer_size
*
2
,
min_size
);
struct
wined3d_buffer
*
buffer
;
TRACE
(
"Growing index buffer to %u bytes
\n
"
,
size
);
hr
=
wined3d_buffer_create_ib
(
device
->
wined3d_device
,
size
,
WINED3DUSAGE_DYNAMIC
|
WINED3DUSAGE_WRITEONLY
,
WINED3D_POOL_DEFAULT
,
NULL
,
&
d3d8_null_wined3d_parent_ops
,
&
buffer
);
if
(
FAILED
(
hr
))
{
ERR
(
"(%p) wined3d_buffer_create_ib failed with hr = %08x
\n
"
,
device
,
hr
);
return
hr
;
}
if
(
device
->
index_buffer
)
wined3d_buffer_decref
(
device
->
index_buffer
);
device
->
index_buffer
=
buffer
;
device
->
index_buffer_size
=
size
;
device
->
index_buffer_pos
=
0
;
}
return
D3D_OK
;
}
static
HRESULT
WINAPI
d3d8_device_DrawIndexedPrimitiveUP
(
IDirect3DDevice8
*
iface
,
D3DPRIMITIVETYPE
primitive_type
,
UINT
min_vertex_idx
,
UINT
ind
ex_count
,
D3DPRIMITIVETYPE
primitive_type
,
UINT
min_vertex_idx
,
UINT
vert
ex_count
,
UINT
primitive_count
,
const
void
*
index_data
,
D3DFORMAT
index_format
,
const
void
*
vertex_data
,
UINT
vertex_stride
)
{
struct
d3d8_device
*
device
=
impl_from_IDirect3DDevice8
(
iface
);
HRESULT
hr
;
BYTE
*
buffer_data
;
UINT
idx_count
=
vertex_count_from_primitive_count
(
primitive_type
,
primitive_count
);
UINT
idx_fmt_size
=
index_format
==
D3DFMT_INDEX16
?
2
:
4
;
UINT
idx_size
=
idx_count
*
idx_fmt_size
;
UINT
ib_pos
;
TRACE
(
"iface %p, primitive_type %#x, min_vertex_idx %u, index_count %u, primitive_count %u,
\n
"
UINT
vtx_size
=
vertex_count
*
vertex_stride
;
UINT
vb_pos
,
align
;
TRACE
(
"iface %p, primitive_type %#x, min_vertex_idx %u, vertex_count %u, primitive_count %u,
\n
"
"index_data %p, index_format %#x, vertex_data %p, vertex_stride %u.
\n
"
,
iface
,
primitive_type
,
min_vertex_idx
,
ind
ex_count
,
primitive_count
,
iface
,
primitive_type
,
min_vertex_idx
,
vert
ex_count
,
primitive_count
,
index_data
,
index_format
,
vertex_data
,
vertex_stride
);
if
(
!
primitive_count
)
{
WARN
(
"primitive_count is 0, returning D3D_OK
\n
"
);
return
D3D_OK
;
}
wined3d_mutex_lock
();
hr
=
d3d8_device_prepare_vertex_buffer
(
device
,
vtx_size
);
if
(
FAILED
(
hr
))
goto
done
;
vb_pos
=
device
->
vertex_buffer_pos
;
align
=
vb_pos
%
vertex_stride
;
if
(
align
)
align
=
vertex_stride
-
align
;
if
(
vb_pos
+
vtx_size
+
align
>
device
->
vertex_buffer_size
)
vb_pos
=
0
;
else
vb_pos
+=
align
;
hr
=
wined3d_buffer_map
(
device
->
vertex_buffer
,
vb_pos
,
vtx_size
,
&
buffer_data
,
vb_pos
?
WINED3D_MAP_NOOVERWRITE
:
WINED3D_MAP_DISCARD
);
if
(
FAILED
(
hr
))
goto
done
;
memcpy
(
buffer_data
,
vertex_data
,
vtx_size
);
wined3d_buffer_unmap
(
device
->
vertex_buffer
);
device
->
vertex_buffer_pos
=
vb_pos
+
vtx_size
;
hr
=
d3d8_device_prepare_index_buffer
(
device
,
idx_size
);
if
(
FAILED
(
hr
))
goto
done
;
ib_pos
=
device
->
index_buffer_pos
;
align
=
ib_pos
%
idx_fmt_size
;
if
(
align
)
align
=
idx_fmt_size
-
align
;
if
(
ib_pos
+
idx_size
+
align
>
device
->
index_buffer_size
)
ib_pos
=
0
;
else
ib_pos
+=
align
;
hr
=
wined3d_buffer_map
(
device
->
index_buffer
,
ib_pos
,
idx_size
,
&
buffer_data
,
ib_pos
?
WINED3D_MAP_NOOVERWRITE
:
WINED3D_MAP_DISCARD
);
if
(
FAILED
(
hr
))
goto
done
;
memcpy
(
buffer_data
,
index_data
,
idx_size
);
wined3d_buffer_unmap
(
device
->
index_buffer
);
device
->
index_buffer_pos
=
ib_pos
+
idx_size
;
hr
=
wined3d_device_set_stream_source
(
device
->
wined3d_device
,
0
,
device
->
vertex_buffer
,
0
,
vertex_stride
);
if
(
FAILED
(
hr
))
goto
done
;
wined3d_device_set_index_buffer
(
device
->
wined3d_device
,
device
->
index_buffer
,
wined3dformat_from_d3dformat
(
index_format
));
wined3d_device_set_base_vertex_index
(
device
->
wined3d_device
,
vb_pos
/
vertex_stride
);
wined3d_device_set_primitive_type
(
device
->
wined3d_device
,
primitive_type
);
hr
=
wined3d_device_draw_indexed_primitive_up
(
device
->
wined3d_device
,
vertex_count_from_primitive_count
(
primitive_type
,
primitive_count
),
index_data
,
wined3dformat_from_d3dformat
(
index_format
),
vertex_data
,
vertex_stride
);
wined3d_mutex_unlock
();
hr
=
wined3d_device_draw_indexed_primitive
(
device
->
wined3d_device
,
ib_pos
/
idx_fmt_size
,
idx_count
);
wined3d_device_set_stream_source
(
device
->
wined3d_device
,
0
,
NULL
,
0
,
0
);
wined3d_device_set_index_buffer
(
device
->
wined3d_device
,
NULL
,
WINED3DFMT_UNKNOWN
);
wined3d_device_set_base_vertex_index
(
device
->
wined3d_device
,
0
);
done:
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