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
55223e25
Commit
55223e25
authored
Jul 08, 2022
by
Zebediah Figura
Committed by
Alexandre Julliard
Jul 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Introduce a wined3d_streaming_buffer helper.
parent
c77b23a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
0 deletions
+104
-0
buffer.c
dlls/wined3d/buffer.c
+78
-0
wined3d.spec
dlls/wined3d/wined3d.spec
+2
-0
wined3d.h
include/wine/wined3d.h
+24
-0
No files found.
dlls/wined3d/buffer.c
View file @
55223e25
...
...
@@ -1647,3 +1647,81 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct
return
device
->
adapter
->
adapter_ops
->
adapter_create_buffer
(
device
,
desc
,
data
,
parent
,
parent_ops
,
buffer
);
}
static
HRESULT
wined3d_streaming_buffer_prepare
(
struct
wined3d_device
*
device
,
struct
wined3d_streaming_buffer
*
buffer
,
unsigned
int
min_size
)
{
struct
wined3d_buffer
*
wined3d_buffer
;
struct
wined3d_buffer_desc
desc
;
unsigned
int
old_size
=
0
;
unsigned
int
size
;
HRESULT
hr
;
if
(
buffer
->
buffer
)
{
old_size
=
buffer
->
buffer
->
resource
.
size
;
if
(
old_size
>=
min_size
)
return
S_OK
;
}
size
=
max
(
old_size
*
2
,
min_size
);
TRACE
(
"Growing buffer to %u bytes.
\n
"
,
size
);
desc
.
byte_width
=
size
;
desc
.
usage
=
WINED3DUSAGE_DYNAMIC
;
desc
.
bind_flags
=
buffer
->
bind_flags
;
desc
.
access
=
WINED3D_RESOURCE_ACCESS_GPU
|
WINED3D_RESOURCE_ACCESS_MAP_W
;
desc
.
misc_flags
=
0
;
desc
.
structure_byte_stride
=
0
;
if
(
SUCCEEDED
(
hr
=
wined3d_buffer_create
(
device
,
&
desc
,
NULL
,
NULL
,
&
wined3d_null_parent_ops
,
&
wined3d_buffer
)))
{
if
(
buffer
->
buffer
)
wined3d_buffer_decref
(
buffer
->
buffer
);
buffer
->
buffer
=
wined3d_buffer
;
buffer
->
pos
=
0
;
}
return
hr
;
}
HRESULT
CDECL
wined3d_streaming_buffer_upload
(
struct
wined3d_device
*
device
,
struct
wined3d_streaming_buffer
*
buffer
,
const
void
*
data
,
unsigned
int
size
,
unsigned
int
stride
,
unsigned
int
*
ret_pos
)
{
unsigned
int
map_flags
=
WINED3D_MAP_WRITE
;
struct
wined3d_resource
*
resource
;
struct
wined3d_map_desc
map_desc
;
unsigned
int
pos
,
align
;
struct
wined3d_box
box
;
HRESULT
hr
;
TRACE
(
"device %p, buffer %p, data %p, size %u, stride %u, ret_pos %p.
\n
"
,
device
,
buffer
,
data
,
size
,
stride
,
ret_pos
);
if
(
FAILED
(
hr
=
wined3d_streaming_buffer_prepare
(
device
,
buffer
,
size
)))
return
hr
;
resource
=
&
buffer
->
buffer
->
resource
;
pos
=
buffer
->
pos
;
if
((
align
=
pos
%
stride
))
align
=
stride
-
align
;
if
(
pos
+
size
+
align
>
resource
->
size
)
{
pos
=
0
;
map_flags
|=
WINED3D_MAP_DISCARD
;
}
else
{
pos
+=
align
;
map_flags
|=
WINED3D_MAP_NOOVERWRITE
;
}
wined3d_box_set
(
&
box
,
pos
,
0
,
pos
+
size
,
1
,
0
,
1
);
if
(
SUCCEEDED
(
hr
=
wined3d_resource_map
(
resource
,
0
,
&
map_desc
,
&
box
,
map_flags
)))
{
memcpy
(
map_desc
.
data
,
data
,
size
);
wined3d_resource_unmap
(
resource
,
0
);
*
ret_pos
=
pos
;
buffer
->
pos
=
pos
+
size
;
}
return
hr
;
}
dlls/wined3d/wined3d.spec
View file @
55223e25
...
...
@@ -260,6 +260,8 @@
@ cdecl wined3d_stateblock_set_vs_consts_f(ptr long long ptr)
@ cdecl wined3d_stateblock_set_vs_consts_i(ptr long long ptr)
@ cdecl wined3d_streaming_buffer_upload(ptr ptr ptr long long ptr)
@ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr ptr)
@ cdecl wined3d_swapchain_decref(ptr)
@ cdecl wined3d_swapchain_get_back_buffer(ptr long)
...
...
include/wine/wined3d.h
View file @
55223e25
...
...
@@ -2320,6 +2320,13 @@ struct wined3d_private_data
typedef
HRESULT
(
CDECL
*
wined3d_device_reset_cb
)(
struct
wined3d_resource
*
resource
);
struct
wined3d_streaming_buffer
{
struct
wined3d_buffer
*
buffer
;
unsigned
int
pos
;
unsigned
int
bind_flags
;
};
void
__stdcall
wined3d_mutex_lock
(
void
);
void
__stdcall
wined3d_mutex_unlock
(
void
);
...
...
@@ -2825,6 +2832,9 @@ HRESULT __cdecl wined3d_stateblock_set_vs_consts_f(struct wined3d_stateblock *st
HRESULT
__cdecl
wined3d_stateblock_set_vs_consts_i
(
struct
wined3d_stateblock
*
stateblock
,
unsigned
int
start_idx
,
unsigned
int
count
,
const
struct
wined3d_ivec4
*
constants
);
HRESULT
__cdecl
wined3d_streaming_buffer_upload
(
struct
wined3d_device
*
device
,
struct
wined3d_streaming_buffer
*
buffer
,
const
void
*
data
,
unsigned
int
size
,
unsigned
int
stride
,
unsigned
int
*
pos
);
HRESULT
__cdecl
wined3d_swapchain_create
(
struct
wined3d_device
*
device
,
struct
wined3d_swapchain_desc
*
desc
,
struct
wined3d_swapchain_state_parent
*
state_parent
,
void
*
parent
,
const
struct
wined3d_parent_ops
*
parent_ops
,
...
...
@@ -2922,6 +2932,20 @@ ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaratio
HRESULT
__cdecl
wined3d_extract_shader_input_signature_from_dxbc
(
struct
wined3d_shader_signature
*
signature
,
const
void
*
byte_code
,
SIZE_T
byte_code_size
);
static
inline
void
wined3d_streaming_buffer_init
(
struct
wined3d_streaming_buffer
*
buffer
,
unsigned
int
bind_flags
)
{
memset
(
buffer
,
0
,
sizeof
(
*
buffer
));
buffer
->
bind_flags
=
bind_flags
;
}
static
inline
void
wined3d_streaming_buffer_cleanup
(
struct
wined3d_streaming_buffer
*
buffer
)
{
if
(
buffer
->
buffer
)
wined3d_buffer_decref
(
buffer
->
buffer
);
buffer
->
buffer
=
NULL
;
buffer
->
pos
=
0
;
}
/* Return the integer base-2 logarithm of x. Undefined for x == 0. */
static
inline
unsigned
int
wined3d_log2i
(
unsigned
int
x
)
{
...
...
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