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
301a48f1
Commit
301a48f1
authored
Jul 08, 2022
by
Zebediah Figura
Committed by
Alexandre Julliard
Jul 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d8: Use the wined3d_streaming_buffer helpers to manage the streaming vertex buffer.
parent
55223e25
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
96 deletions
+14
-96
d3d8_private.h
dlls/d3d8/d3d8_private.h
+1
-4
device.c
dlls/d3d8/device.c
+13
-92
No files found.
dlls/d3d8/d3d8_private.h
View file @
301a48f1
...
@@ -123,10 +123,7 @@ struct d3d8_device
...
@@ -123,10 +123,7 @@ struct d3d8_device
struct
FvfToDecl
*
decls
;
struct
FvfToDecl
*
decls
;
UINT
numConvertedDecls
,
declArraySize
;
UINT
numConvertedDecls
,
declArraySize
;
/* User data draws */
struct
wined3d_streaming_buffer
vertex_buffer
;
struct
wined3d_buffer
*
vertex_buffer
;
UINT
vertex_buffer_size
;
UINT
vertex_buffer_pos
;
struct
wined3d_buffer
*
index_buffer
;
struct
wined3d_buffer
*
index_buffer
;
UINT
index_buffer_size
;
UINT
index_buffer_size
;
UINT
index_buffer_pos
;
UINT
index_buffer_pos
;
...
...
dlls/d3d8/device.c
View file @
301a48f1
...
@@ -625,8 +625,7 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface)
...
@@ -625,8 +625,7 @@ static ULONG WINAPI d3d8_device_Release(IDirect3DDevice8 *iface)
}
}
heap_free
(
device
->
decls
);
heap_free
(
device
->
decls
);
if
(
device
->
vertex_buffer
)
wined3d_streaming_buffer_cleanup
(
&
device
->
vertex_buffer
);
wined3d_buffer_decref
(
device
->
vertex_buffer
);
if
(
device
->
index_buffer
)
if
(
device
->
index_buffer
)
wined3d_buffer_decref
(
device
->
index_buffer
);
wined3d_buffer_decref
(
device
->
index_buffer
);
...
@@ -963,12 +962,7 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface,
...
@@ -963,12 +962,7 @@ static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface,
wined3d_mutex_lock
();
wined3d_mutex_lock
();
if
(
device
->
vertex_buffer
)
wined3d_streaming_buffer_cleanup
(
&
device
->
vertex_buffer
);
{
wined3d_buffer_decref
(
device
->
vertex_buffer
);
device
->
vertex_buffer
=
NULL
;
device
->
vertex_buffer_size
=
0
;
}
if
(
device
->
index_buffer
)
if
(
device
->
index_buffer
)
{
{
wined3d_buffer_decref
(
device
->
index_buffer
);
wined3d_buffer_decref
(
device
->
index_buffer
);
...
@@ -2546,55 +2540,15 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitive(IDirect3DDevice8 *iface,
...
@@ -2546,55 +2540,15 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitive(IDirect3DDevice8 *iface,
return
D3D_OK
;
return
D3D_OK
;
}
}
/* The caller is responsible for wined3d locking */
static
HRESULT
d3d8_device_prepare_vertex_buffer
(
struct
d3d8_device
*
device
,
UINT
min_size
)
{
HRESULT
hr
;
if
(
device
->
vertex_buffer_size
<
min_size
||
!
device
->
vertex_buffer
)
{
UINT
size
=
max
(
device
->
vertex_buffer_size
*
2
,
min_size
);
struct
wined3d_buffer_desc
desc
;
struct
wined3d_buffer
*
buffer
;
TRACE
(
"Growing vertex buffer to %u bytes
\n
"
,
size
);
desc
.
byte_width
=
size
;
desc
.
usage
=
WINED3DUSAGE_DYNAMIC
;
desc
.
bind_flags
=
WINED3D_BIND_VERTEX_BUFFER
;
desc
.
access
=
WINED3D_RESOURCE_ACCESS_GPU
|
WINED3D_RESOURCE_ACCESS_MAP_W
;
desc
.
misc_flags
=
0
;
desc
.
structure_byte_stride
=
0
;
if
(
FAILED
(
hr
=
wined3d_buffer_create
(
device
->
wined3d_device
,
&
desc
,
NULL
,
NULL
,
&
d3d8_null_wined3d_parent_ops
,
&
buffer
)))
{
ERR
(
"Failed to create vertex buffer, hr %#x.
\n
"
,
hr
);
return
hr
;
}
if
(
device
->
vertex_buffer
)
wined3d_buffer_decref
(
device
->
vertex_buffer
);
device
->
vertex_buffer
=
buffer
;
device
->
vertex_buffer_size
=
size
;
device
->
vertex_buffer_pos
=
0
;
}
return
D3D_OK
;
}
static
HRESULT
WINAPI
d3d8_device_DrawPrimitiveUP
(
IDirect3DDevice8
*
iface
,
static
HRESULT
WINAPI
d3d8_device_DrawPrimitiveUP
(
IDirect3DDevice8
*
iface
,
D3DPRIMITIVETYPE
primitive_type
,
UINT
primitive_count
,
const
void
*
data
,
D3DPRIMITIVETYPE
primitive_type
,
UINT
primitive_count
,
const
void
*
data
,
UINT
stride
)
UINT
stride
)
{
{
struct
d3d8_device
*
device
=
impl_from_IDirect3DDevice8
(
iface
);
struct
d3d8_device
*
device
=
impl_from_IDirect3DDevice8
(
iface
);
HRESULT
hr
;
UINT
vtx_count
=
vertex_count_from_primitive_count
(
primitive_type
,
primitive_count
);
UINT
vtx_count
=
vertex_count_from_primitive_count
(
primitive_type
,
primitive_count
);
struct
wined3d_map_desc
wined3d_map_desc
;
struct
wined3d_box
wined3d_box
=
{
0
};
UINT
size
=
vtx_count
*
stride
;
UINT
size
=
vtx_count
*
stride
;
struct
wined3d_resource
*
vb
;
unsigned
int
vb_pos
;
UINT
vb_pos
,
align
;
HRESULT
hr
;
TRACE
(
"iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.
\n
"
,
TRACE
(
"iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.
\n
"
,
iface
,
primitive_type
,
primitive_count
,
data
,
stride
);
iface
,
primitive_type
,
primitive_count
,
data
,
stride
);
...
@@ -2606,29 +2560,12 @@ static HRESULT WINAPI d3d8_device_DrawPrimitiveUP(IDirect3DDevice8 *iface,
...
@@ -2606,29 +2560,12 @@ static HRESULT WINAPI d3d8_device_DrawPrimitiveUP(IDirect3DDevice8 *iface,
}
}
wined3d_mutex_lock
();
wined3d_mutex_lock
();
hr
=
d3d8_device_prepare_vertex_buffer
(
device
,
size
);
if
(
FAILED
(
hr
))
goto
done
;
vb_pos
=
device
->
vertex_buffer_pos
;
if
(
FAILED
(
hr
=
wined3d_streaming_buffer_upload
(
device
->
wined3d_device
,
align
=
vb_pos
%
stride
;
&
device
->
vertex_buffer
,
data
,
size
,
stride
,
&
vb_pos
)))
if
(
align
)
align
=
stride
-
align
;
if
(
vb_pos
+
size
+
align
>
device
->
vertex_buffer_size
)
vb_pos
=
0
;
else
vb_pos
+=
align
;
wined3d_box
.
left
=
vb_pos
;
wined3d_box
.
right
=
vb_pos
+
size
;
vb
=
wined3d_buffer_get_resource
(
device
->
vertex_buffer
);
if
(
FAILED
(
wined3d_resource_map
(
vb
,
0
,
&
wined3d_map_desc
,
&
wined3d_box
,
WINED3D_MAP_WRITE
|
(
vb_pos
?
WINED3D_MAP_NOOVERWRITE
:
WINED3D_MAP_DISCARD
))))
goto
done
;
goto
done
;
memcpy
(
wined3d_map_desc
.
data
,
data
,
size
);
wined3d_resource_unmap
(
vb
,
0
);
device
->
vertex_buffer_pos
=
vb_pos
+
size
;
hr
=
wined3d_stateblock_set_stream_source
(
device
->
state
,
0
,
device
->
vertex_buffer
,
0
,
stride
);
hr
=
wined3d_stateblock_set_stream_source
(
device
->
state
,
0
,
device
->
vertex_buffer
.
buffer
,
0
,
stride
);
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
))
goto
done
;
goto
done
;
...
@@ -2692,8 +2629,8 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
...
@@ -2692,8 +2629,8 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
UINT
idx_size
=
idx_count
*
idx_fmt_size
;
UINT
idx_size
=
idx_count
*
idx_fmt_size
;
struct
wined3d_map_desc
wined3d_map_desc
;
struct
wined3d_map_desc
wined3d_map_desc
;
struct
wined3d_box
wined3d_box
=
{
0
};
struct
wined3d_box
wined3d_box
=
{
0
};
struct
wined3d_resource
*
ib
,
*
vb
;
unsigned
int
base_vertex_idx
;
unsigned
int
base_vertex_idx
;
struct
wined3d_resource
*
ib
;
UINT
vb_pos
,
ib_pos
,
align
;
UINT
vb_pos
,
ib_pos
,
align
;
HRESULT
hr
;
HRESULT
hr
;
...
@@ -2710,27 +2647,9 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
...
@@ -2710,27 +2647,9 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
wined3d_mutex_lock
();
wined3d_mutex_lock
();
hr
=
d3d8_device_prepare_vertex_buffer
(
device
,
vtx_size
);
if
(
FAILED
(
hr
=
wined3d_streaming_buffer_upload
(
device
->
wined3d_device
,
&
device
->
vertex_buffer
,
if
(
FAILED
(
hr
))
(
char
*
)
vertex_data
+
min_vertex_idx
*
vertex_stride
,
vtx_size
,
vertex_stride
,
&
vb_pos
)))
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
;
wined3d_box
.
left
=
vb_pos
;
wined3d_box
.
right
=
vb_pos
+
vtx_size
;
vb
=
wined3d_buffer_get_resource
(
device
->
vertex_buffer
);
if
(
FAILED
(
hr
=
wined3d_resource_map
(
vb
,
0
,
&
wined3d_map_desc
,
&
wined3d_box
,
WINED3D_MAP_WRITE
|
(
vb_pos
?
WINED3D_MAP_NOOVERWRITE
:
WINED3D_MAP_DISCARD
))))
goto
done
;
goto
done
;
memcpy
(
wined3d_map_desc
.
data
,
(
char
*
)
vertex_data
+
min_vertex_idx
*
vertex_stride
,
vtx_size
);
wined3d_resource_unmap
(
vb
,
0
);
device
->
vertex_buffer_pos
=
vb_pos
+
vtx_size
;
hr
=
d3d8_device_prepare_index_buffer
(
device
,
idx_size
);
hr
=
d3d8_device_prepare_index_buffer
(
device
,
idx_size
);
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
))
...
@@ -2754,7 +2673,7 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
...
@@ -2754,7 +2673,7 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
wined3d_resource_unmap
(
ib
,
0
);
wined3d_resource_unmap
(
ib
,
0
);
device
->
index_buffer_pos
=
ib_pos
+
idx_size
;
device
->
index_buffer_pos
=
ib_pos
+
idx_size
;
hr
=
wined3d_stateblock_set_stream_source
(
device
->
state
,
0
,
device
->
vertex_buffer
,
0
,
vertex_stride
);
hr
=
wined3d_stateblock_set_stream_source
(
device
->
state
,
0
,
device
->
vertex_buffer
.
buffer
,
0
,
vertex_stride
);
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
))
goto
done
;
goto
done
;
...
@@ -3799,6 +3718,8 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
...
@@ -3799,6 +3718,8 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
device
->
stateblock_state
=
wined3d_stateblock_get_state
(
device
->
state
);
device
->
stateblock_state
=
wined3d_stateblock_get_state
(
device
->
state
);
device
->
update_state
=
device
->
state
;
device
->
update_state
=
device
->
state
;
wined3d_streaming_buffer_init
(
&
device
->
vertex_buffer
,
WINED3D_BIND_VERTEX_BUFFER
);
if
(
!
parameters
->
Windowed
)
if
(
!
parameters
->
Windowed
)
{
{
if
(
!
focus_window
)
if
(
!
focus_window
)
...
...
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