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
723cd0a4
Commit
723cd0a4
authored
Mar 22, 2023
by
Stefan Dösinger
Committed by
Alexandre Julliard
Mar 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Make video memory accounting a per-resource flag.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=54701
parent
d62e2268
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
48 additions
and
38 deletions
+48
-38
d3d8_private.h
dlls/d3d8/d3d8_private.h
+1
-1
directx.c
dlls/d3d8/directx.c
+4
-4
buffer.c
dlls/d3d9/buffer.c
+6
-0
device.c
dlls/d3d9/device.c
+3
-0
directx.c
dlls/d3d9/directx.c
+1
-3
texture.c
dlls/d3d9/texture.c
+9
-0
ddraw_private.h
dlls/ddraw/ddraw_private.h
+3
-4
surface.c
dlls/ddraw/surface.c
+2
-2
vertexbuffer.c
dlls/ddraw/vertexbuffer.c
+1
-1
resource.c
dlls/wined3d/resource.c
+14
-19
texture.c
dlls/wined3d/texture.c
+2
-3
utils.c
dlls/wined3d/utils.c
+1
-0
wined3d.h
include/wine/wined3d.h
+1
-1
No files found.
dlls/d3d8/d3d8_private.h
View file @
723cd0a4
...
...
@@ -371,7 +371,7 @@ static inline unsigned int wined3d_usage_from_d3d(D3DPOOL pool, DWORD usage)
usage
|=
WINED3DUSAGE_SCRATCH
;
else
if
(
pool
==
D3DPOOL_MANAGED
)
usage
|=
WINED3DUSAGE_MANAGED
;
return
usage
;
return
usage
|
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
}
static
inline
unsigned
int
wined3d_bind_flags_from_d3d8_usage
(
DWORD
usage
)
...
...
dlls/d3d8/directx.c
View file @
723cd0a4
...
...
@@ -473,10 +473,10 @@ static const struct IDirect3D8Vtbl d3d8_vtbl =
BOOL
d3d8_init
(
struct
d3d8
*
d3d8
)
{
DWORD
flags
=
WINED3D_LEGACY_DEPTH_BIAS
|
WINED3D_
VIDMEM_ACCOUNTING
|
WINED3D_
HANDLE_RESTORE
|
WINED3D_PIXEL_CENTER_INTEGE
R
|
WINED3D_
LEGACY_UNBOUND_RESOURCE_COLOR
|
WINED3D_NO_PRIMITIVE_RESTART
|
WINED3D_
LEGACY_CUBEMAP_FILTERING
|
WINED3D_
NO_DRAW_INDIRECT
;
DWORD
flags
=
WINED3D_LEGACY_DEPTH_BIAS
|
WINED3D_
HANDLE_RESTORE
|
WINED3D_
PIXEL_CENTER_INTEGER
|
WINED3D_LEGACY_UNBOUND_RESOURCE_COLO
R
|
WINED3D_
NO_PRIMITIVE_RESTART
|
WINED3D_LEGACY_CUBEMAP_FILTERING
|
WINED3D_NO_DRAW_INDIRECT
;
unsigned
int
adapter_idx
,
output_idx
,
adapter_count
,
output_count
=
0
;
struct
wined3d_adapter
*
wined3d_adapter
;
...
...
dlls/d3d9/buffer.c
View file @
723cd0a4
...
...
@@ -312,6 +312,9 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device *
desc
.
misc_flags
=
0
;
desc
.
structure_byte_stride
=
0
;
if
(
!
device
->
d3d_parent
->
extended
)
desc
.
usage
|=
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
if
(
desc
.
access
&
WINED3D_RESOURCE_ACCESS_GPU
)
{
desc
.
bind_flags
=
WINED3D_BIND_VERTEX_BUFFER
;
...
...
@@ -620,6 +623,9 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de
desc
.
misc_flags
=
0
;
desc
.
structure_byte_stride
=
0
;
if
(
!
device
->
d3d_parent
->
extended
)
desc
.
usage
|=
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
if
(
desc
.
access
&
WINED3D_RESOURCE_ACCESS_GPU
)
desc
.
bind_flags
=
WINED3D_BIND_INDEX_BUFFER
;
...
...
dlls/d3d9/device.c
View file @
723cd0a4
...
...
@@ -1986,6 +1986,9 @@ static HRESULT WINAPI d3d9_device_CreateOffscreenPlainSurface(IDirect3DDevice9Ex
access
=
wined3daccess_from_d3dpool
(
pool
,
0
)
|
WINED3D_RESOURCE_ACCESS_MAP_R
|
WINED3D_RESOURCE_ACCESS_MAP_W
;
if
(
!
device
->
d3d_parent
->
extended
)
usage
|=
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
return
d3d9_device_create_surface
(
device
,
0
,
wined3dformat_from_d3dformat
(
format
),
WINED3D_MULTISAMPLE_NONE
,
0
,
usage
,
0
,
access
,
width
,
height
,
user_mem
,
surface
);
}
...
...
dlls/d3d9/directx.c
View file @
723cd0a4
...
...
@@ -689,9 +689,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
unsigned
int
adapter_idx
,
output_idx
,
adapter_count
,
output_count
=
0
;
struct
wined3d_adapter
*
wined3d_adapter
;
if
(
!
extended
)
flags
|=
WINED3D_VIDMEM_ACCOUNTING
;
else
if
(
extended
)
flags
|=
WINED3D_RESTORE_MODE_ON_ACTIVATE
;
d3d9
->
IDirect3D9Ex_iface
.
lpVtbl
=
&
d3d9_vtbl
;
...
...
dlls/d3d9/texture.c
View file @
723cd0a4
...
...
@@ -1409,6 +1409,9 @@ HRESULT d3d9_texture_2d_init(struct d3d9_texture *texture, struct d3d9_device *d
desc
.
depth
=
1
;
desc
.
size
=
0
;
if
(
!
device
->
d3d_parent
->
extended
)
desc
.
usage
|=
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
texture
->
IDirect3DBaseTexture9_iface
.
lpVtbl
=
(
const
IDirect3DBaseTexture9Vtbl
*
)
&
d3d9_texture_2d_vtbl
;
return
d3d9_texture_init
(
texture
,
device
,
&
desc
,
pool
,
usage
,
1
,
level_count
);
}
...
...
@@ -1430,6 +1433,9 @@ HRESULT d3d9_texture_cube_init(struct d3d9_texture *texture, struct d3d9_device
desc
.
depth
=
1
;
desc
.
size
=
0
;
if
(
!
device
->
d3d_parent
->
extended
)
desc
.
usage
|=
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
texture
->
IDirect3DBaseTexture9_iface
.
lpVtbl
=
(
const
IDirect3DBaseTexture9Vtbl
*
)
&
d3d9_texture_cube_vtbl
;
return
d3d9_texture_init
(
texture
,
device
,
&
desc
,
pool
,
usage
,
6
,
level_count
);
}
...
...
@@ -1455,6 +1461,9 @@ HRESULT d3d9_texture_3d_init(struct d3d9_texture *texture, struct d3d9_device *d
desc
.
depth
=
depth
;
desc
.
size
=
0
;
if
(
!
device
->
d3d_parent
->
extended
)
desc
.
usage
|=
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
texture
->
IDirect3DBaseTexture9_iface
.
lpVtbl
=
(
const
IDirect3DBaseTexture9Vtbl
*
)
&
d3d9_texture_3d_vtbl
;
return
d3d9_texture_init
(
texture
,
device
,
&
desc
,
pool
,
usage
,
1
,
level_count
);
}
dlls/ddraw/ddraw_private.h
View file @
723cd0a4
...
...
@@ -63,10 +63,9 @@ struct FvfToDecl
#define DDRAW_STRIDE_ALIGNMENT 8
#define DDRAW_WINED3D_FLAGS (WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING \
| WINED3D_RESTORE_MODE_ON_ACTIVATE | WINED3D_FOCUS_MESSAGES | WINED3D_PIXEL_CENTER_INTEGER \
| WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART \
| WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_NO_DRAW_INDIRECT)
#define DDRAW_WINED3D_FLAGS (WINED3D_LEGACY_DEPTH_BIAS | WINED3D_RESTORE_MODE_ON_ACTIVATE \
| WINED3D_FOCUS_MESSAGES | WINED3D_PIXEL_CENTER_INTEGER | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR \
| WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_NO_DRAW_INDIRECT)
#define DDRAW_MAX_ACTIVE_LIGHTS 32
#define DDRAW_MAX_TEXTURES 8
...
...
dlls/ddraw/surface.c
View file @
723cd0a4
...
...
@@ -6031,7 +6031,7 @@ static void wined3d_resource_desc_from_ddraw(struct ddraw *ddraw,
wined3d_desc
->
format
=
wined3dformat_from_ddrawformat
(
&
desc
->
u4
.
ddpfPixelFormat
);
wined3d_desc
->
multisample_type
=
WINED3D_MULTISAMPLE_NONE
;
wined3d_desc
->
multisample_quality
=
0
;
wined3d_desc
->
usage
=
0
;
wined3d_desc
->
usage
=
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
wined3d_desc
->
bind_flags
=
0
;
wined3d_desc
->
access
=
WINED3D_RESOURCE_ACCESS_GPU
|
WINED3D_RESOURCE_ACCESS_MAP_R
|
WINED3D_RESOURCE_ACCESS_MAP_W
;
wined3d_desc
->
width
=
desc
->
dwWidth
;
...
...
@@ -6158,7 +6158,7 @@ static HRESULT ddraw_texture_init(struct ddraw_texture *texture, struct ddraw *d
draw_texture_desc
=
wined3d_desc
;
draw_texture_desc
.
bind_flags
=
bind_flags
;
draw_texture_desc
.
access
=
WINED3D_RESOURCE_ACCESS_GPU
;
draw_texture_desc
.
usage
=
WINED3DUSAGE_PRIVATE
;
draw_texture_desc
.
usage
=
0
;
if
(
FAILED
(
hr
=
wined3d_texture_create
(
wined3d_device
,
&
draw_texture_desc
,
layers
,
levels
,
0
,
NULL
,
texture
,
&
ddraw_texture_wined3d_parent_ops
,
&
draw_texture
)))
...
...
dlls/ddraw/vertexbuffer.c
View file @
723cd0a4
...
...
@@ -111,7 +111,7 @@ static HRESULT d3d_vertex_buffer_create_wined3d_buffer(struct d3d_vertex_buffer
struct
wined3d_buffer_desc
desc
;
desc
.
byte_width
=
buffer
->
size
;
desc
.
usage
=
WINED3DUSAGE_STATICDECL
;
desc
.
usage
=
WINED3DUSAGE_STATICDECL
|
WINED3DUSAGE_VIDMEM_ACCOUNTING
;
if
(
dynamic
)
desc
.
usage
|=
WINED3DUSAGE_DYNAMIC
;
desc
.
bind_flags
=
WINED3D_BIND_VERTEX_BUFFER
;
...
...
dlls/wined3d/resource.c
View file @
723cd0a4
...
...
@@ -210,21 +210,19 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource
->
map_binding
=
WINED3D_LOCATION_SYSMEM
;
resource
->
heap_memory
=
NULL
;
if
(
!
(
usage
&
WINED3DUSAGE_PRIVATE
))
/* Check that we have enough video ram left */
if
(
!
(
access
&
WINED3D_RESOURCE_ACCESS_CPU
)
&&
usage
&
WINED3DUSAGE_VIDMEM_ACCOUNTING
)
{
/* Check that we have enough video ram left */
if
(
!
(
access
&
WINED3D_RESOURCE_ACCESS_CPU
)
&&
device
->
wined3d
->
flags
&
WINED3D_VIDMEM_ACCOUNTING
)
if
(
size
>
wined3d_device_get_available_texture_mem
(
device
))
{
if
(
size
>
wined3d_device_get_available_texture_mem
(
device
))
{
ERR
(
"Out of adapter memory.
\n
"
);
return
WINED3DERR_OUTOFVIDEOMEMORY
;
}
adapter_adjust_memory
(
device
->
adapter
,
size
);
ERR
(
"Out of adapter memory.
\n
"
);
return
WINED3DERR_OUTOFVIDEOMEMORY
;
}
adapter_adjust_memory
(
device
->
adapter
,
size
);
}
if
(
!
(
usage
&
WINED3DUSAGE_PRIVATE
))
device_resource_add
(
device
,
resource
);
}
return
WINED3D_OK
;
}
...
...
@@ -241,20 +239,17 @@ static void wined3d_resource_destroy_object(void *object)
void
resource_cleanup
(
struct
wined3d_resource
*
resource
)
{
const
struct
wined3d
*
d3d
=
resource
->
device
->
wined3d
;
TRACE
(
"Cleaning up resource %p.
\n
"
,
resource
);
if
(
!
(
resource
->
usage
&
WINED3DUSAGE_PRIVATE
)
)
if
(
!
(
resource
->
access
&
WINED3D_RESOURCE_ACCESS_CPU
)
&&
resource
->
usage
&
WINED3DUSAGE_VIDMEM_ACCOUNTING
)
{
if
(
!
(
resource
->
access
&
WINED3D_RESOURCE_ACCESS_CPU
)
&&
d3d
->
flags
&
WINED3D_VIDMEM_ACCOUNTING
)
{
TRACE
(
"Decrementing device memory pool by %u.
\n
"
,
resource
->
size
);
adapter_adjust_memory
(
resource
->
device
->
adapter
,
(
INT64
)
0
-
resource
->
size
);
}
TRACE
(
"Decrementing device memory pool by %u.
\n
"
,
resource
->
size
);
adapter_adjust_memory
(
resource
->
device
->
adapter
,
(
INT64
)
0
-
resource
->
size
);
}
if
(
!
(
resource
->
usage
&
WINED3DUSAGE_PRIVATE
))
device_resource_released
(
resource
->
device
,
resource
);
}
wined3d_resource_reference
(
resource
);
wined3d_cs_destroy_object
(
resource
->
device
->
cs
,
wined3d_resource_destroy_object
,
resource
);
}
...
...
dlls/wined3d/texture.c
View file @
723cd0a4
...
...
@@ -1899,7 +1899,6 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, unsig
const
struct
wined3d_format
*
format
;
struct
wined3d_device
*
device
;
unsigned
int
resource_size
;
const
struct
wined3d
*
d3d
;
unsigned
int
slice_pitch
;
bool
update_memory_only
;
bool
create_dib
=
false
;
...
...
@@ -1910,7 +1909,6 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, unsig
sub_resource_idx
);
device
=
texture
->
resource
.
device
;
d3d
=
device
->
wined3d
;
gl_info
=
&
device
->
adapter
->
gl_info
;
d3d_info
=
&
device
->
adapter
->
d3d_info
;
format
=
wined3d_get_format
(
device
->
adapter
,
format_id
,
texture
->
resource
.
bind_flags
);
...
...
@@ -2008,7 +2006,8 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, unsig
texture
->
resource
.
multisample_quality
=
multisample_quality
;
texture
->
resource
.
width
=
width
;
texture
->
resource
.
height
=
height
;
if
(
!
(
texture
->
resource
.
access
&
WINED3D_RESOURCE_ACCESS_CPU
)
&&
d3d
->
flags
&
WINED3D_VIDMEM_ACCOUNTING
)
if
(
!
(
texture
->
resource
.
access
&
WINED3D_RESOURCE_ACCESS_CPU
)
&&
texture
->
resource
.
usage
&
WINED3DUSAGE_VIDMEM_ACCOUNTING
)
adapter_adjust_memory
(
device
->
adapter
,
(
INT64
)
texture
->
slice_pitch
-
texture
->
resource
.
size
);
texture
->
resource
.
size
=
texture
->
slice_pitch
;
sub_resource
->
size
=
texture
->
slice_pitch
;
...
...
dlls/wined3d/utils.c
View file @
723cd0a4
...
...
@@ -4952,6 +4952,7 @@ const char *debug_d3dusage(uint32_t usage)
WINED3DUSAGE_TO_STR
(
WINED3DUSAGE_STATICDECL
);
WINED3DUSAGE_TO_STR
(
WINED3DUSAGE_OVERLAY
);
WINED3DUSAGE_TO_STR
(
WINED3DUSAGE_MANAGED
);
WINED3DUSAGE_TO_STR
(
WINED3DUSAGE_VIDMEM_ACCOUNTING
);
WINED3DUSAGE_TO_STR
(
WINED3DUSAGE_QUERY_FILTER
);
WINED3DUSAGE_TO_STR
(
WINED3DUSAGE_QUERY_GENMIPMAP
);
WINED3DUSAGE_TO_STR
(
WINED3DUSAGE_QUERY_LEGACYBUMPMAP
);
...
...
include/wine/wined3d.h
View file @
723cd0a4
...
...
@@ -927,6 +927,7 @@ enum wined3d_memory_segment_group
#define WINED3DUSAGE_STATICDECL 0x04000000
#define WINED3DUSAGE_OVERLAY 0x08000000
#define WINED3DUSAGE_MANAGED 0x20000000
#define WINED3DUSAGE_VIDMEM_ACCOUNTING 0x40000000
#define WINED3DUSAGE_QUERY_GENMIPMAP 0x00000400
#define WINED3DUSAGE_QUERY_LEGACYBUMPMAP 0x00008000
...
...
@@ -1311,7 +1312,6 @@ enum wined3d_memory_segment_group
#define WINED3D_LEGACY_DEPTH_BIAS 0x00000001
#define WINED3D_NO3D 0x00000002
#define WINED3D_VIDMEM_ACCOUNTING 0x00000004
#define WINED3D_PRESENT_CONVERSION 0x00000008
#define WINED3D_RESTORE_MODE_ON_ACTIVATE 0x00000010
#define WINED3D_FOCUS_MESSAGES 0x00000020
...
...
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