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
4dd4a691
Commit
4dd4a691
authored
Aug 21, 2013
by
Stefan Dösinger
Committed by
Alexandre Julliard
Aug 21, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Add a function for allocating aligned resource memory.
parent
9d75a517
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
69 deletions
+93
-69
buffer.c
dlls/wined3d/buffer.c
+5
-5
resource.c
dlls/wined3d/resource.c
+34
-9
surface.c
dlls/wined3d/surface.c
+41
-45
swapchain.c
dlls/wined3d/swapchain.c
+2
-2
wined3d_private.h
dlls/wined3d/wined3d_private.h
+11
-8
No files found.
dlls/wined3d/buffer.c
View file @
4dd4a691
...
...
@@ -3,7 +3,7 @@
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2007-201
0
Stefan Dösinger for CodeWeavers
* Copyright 2007-201
1, 2013
Stefan Dösinger for CodeWeavers
* Copyright 2009-2010 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
...
...
@@ -189,9 +189,9 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, const struc
}
else
{
HeapFree
(
GetProcessHeap
(),
0
,
This
->
resource
.
heapM
emory
);
wined3d_resource_free_sysmem
(
This
->
resource
.
heap_m
emory
);
This
->
resource
.
allocatedMemory
=
NULL
;
This
->
resource
.
heap
M
emory
=
NULL
;
This
->
resource
.
heap
_m
emory
=
NULL
;
}
return
;
...
...
@@ -492,8 +492,8 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_inf
/* AllocatedMemory exists if the buffer is double buffered or has no buffer object at all */
if
(
This
->
resource
.
allocatedMemory
)
return
This
->
resource
.
allocatedMemory
;
This
->
resource
.
heap
Memory
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
This
->
resource
.
size
+
RESOURCE_ALIGNMENT
);
This
->
resource
.
allocatedMemory
=
(
BYTE
*
)(((
ULONG_PTR
)
This
->
resource
.
heapMemory
+
(
RESOURCE_ALIGNMENT
-
1
))
&
~
(
RESOURCE_ALIGNMENT
-
1
))
;
This
->
resource
.
heap
_memory
=
wined3d_resource_allocate_sysmem
(
This
->
resource
.
size
);
This
->
resource
.
allocatedMemory
=
This
->
resource
.
heap_memory
;
if
(
This
->
buffer_type_hint
==
GL_ELEMENT_ARRAY_BUFFER_ARB
)
device_invalidate_state
(
This
->
resource
.
device
,
STATE_INDEXBUFFER
);
...
...
dlls/wined3d/resource.c
View file @
4dd4a691
...
...
@@ -4,6 +4,7 @@
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2009-2010 Henri Verbeet for CodeWeavers
* Copyright 2006-2008, 2013 Stefan Dösinger for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -111,8 +112,8 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
if
(
size
)
{
resource
->
heap
Memory
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
+
RESOURCE_ALIGNMENT
);
if
(
!
resource
->
heap
M
emory
)
resource
->
heap
_memory
=
wined3d_resource_allocate_sysmem
(
size
);
if
(
!
resource
->
heap
_m
emory
)
{
ERR
(
"Out of memory!
\n
"
);
return
WINED3DERR_OUTOFVIDEOMEMORY
;
...
...
@@ -120,10 +121,9 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
}
else
{
resource
->
heap
M
emory
=
NULL
;
resource
->
heap
_m
emory
=
NULL
;
}
resource
->
allocatedMemory
=
(
BYTE
*
)(((
ULONG_PTR
)
resource
->
heapMemory
+
(
RESOURCE_ALIGNMENT
-
1
))
&
~
(
RESOURCE_ALIGNMENT
-
1
));
resource
->
allocatedMemory
=
resource
->
heap_memory
;
/* Check that we have enough video ram left */
if
(
pool
==
WINED3D_POOL_DEFAULT
&&
d3d
->
flags
&
WINED3D_VIDMEM_ACCOUNTING
)
...
...
@@ -131,7 +131,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
if
(
size
>
wined3d_device_get_available_texture_mem
(
device
))
{
ERR
(
"Out of adapter memory
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
resource
->
heapM
emory
);
wined3d_resource_free_sysmem
(
resource
->
heap_m
emory
);
return
WINED3DERR_OUTOFVIDEOMEMORY
;
}
adapter_adjust_memory
(
device
->
adapter
,
size
);
...
...
@@ -165,9 +165,9 @@ void resource_cleanup(struct wined3d_resource *resource)
ERR
(
"Failed to free private data when destroying resource %p, hr = %#x.
\n
"
,
resource
,
hr
);
}
HeapFree
(
GetProcessHeap
(),
0
,
resource
->
heapM
emory
);
resource
->
allocatedMemory
=
0
;
resource
->
heap
Memory
=
0
;
wined3d_resource_free_sysmem
(
resource
->
heap_m
emory
);
resource
->
allocatedMemory
=
NULL
;
resource
->
heap
_memory
=
NULL
;
device_resource_released
(
resource
->
device
,
resource
);
}
...
...
@@ -335,3 +335,28 @@ void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, st
desc
->
depth
=
resource
->
depth
;
desc
->
size
=
resource
->
size
;
}
void
*
wined3d_resource_allocate_sysmem
(
SIZE_T
size
)
{
void
**
p
;
SIZE_T
align
=
RESOURCE_ALIGNMENT
-
1
+
sizeof
(
*
p
);
void
*
mem
;
if
(
!
(
mem
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
+
align
)))
return
NULL
;
p
=
(
void
**
)(((
ULONG_PTR
)
mem
+
align
)
&
~
(
RESOURCE_ALIGNMENT
-
1
))
-
1
;
*
p
=
mem
;
return
++
p
;
}
void
wined3d_resource_free_sysmem
(
void
*
mem
)
{
void
**
p
=
mem
;
if
(
!
mem
)
return
;
HeapFree
(
GetProcessHeap
(),
0
,
*
(
--
p
));
}
dlls/wined3d/surface.c
View file @
4dd4a691
...
...
@@ -6,7 +6,7 @@
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2006-2011 Stefan Dösinger for CodeWeavers
* Copyright 2006-2011
, 2013
Stefan Dösinger for CodeWeavers
* Copyright 2007-2008 Henri Verbeet
* Copyright 2006-2008 Roderick Colenbrander
* Copyright 2009-2011 Henri Verbeet for CodeWeavers
...
...
@@ -572,8 +572,8 @@ static void surface_load_pbo(struct wined3d_surface *surface, const struct wined
/* We don't need the system memory anymore and we can't even use it for PBOs. */
if
(
!
(
surface
->
flags
&
SFLAG_CLIENT
))
{
HeapFree
(
GetProcessHeap
(),
0
,
surface
->
resource
.
heapM
emory
);
surface
->
resource
.
heap
M
emory
=
NULL
;
wined3d_resource_free_sysmem
(
surface
->
resource
.
heap_m
emory
);
surface
->
resource
.
heap
_m
emory
=
NULL
;
}
surface
->
resource
.
allocatedMemory
=
NULL
;
surface
->
flags
|=
SFLAG_PBO
;
...
...
@@ -592,11 +592,10 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface)
{
/* Whatever surface we have, make sure that there is memory allocated
* for the downloaded copy, or a PBO to map. */
if
(
!
surface
->
resource
.
heap
M
emory
)
surface
->
resource
.
heap
Memory
=
HeapAlloc
(
GetProcessHeap
(),
0
,
surface
->
resource
.
size
+
RESOURCE_ALIGNMENT
);
if
(
!
surface
->
resource
.
heap
_m
emory
)
surface
->
resource
.
heap
_memory
=
wined3d_resource_allocate_sysmem
(
surface
->
resource
.
size
);
surface
->
resource
.
allocatedMemory
=
(
BYTE
*
)(((
ULONG_PTR
)
surface
->
resource
.
heapMemory
+
(
RESOURCE_ALIGNMENT
-
1
))
&
~
(
RESOURCE_ALIGNMENT
-
1
));
surface
->
resource
.
allocatedMemory
=
surface
->
resource
.
heap_memory
;
if
(
surface
->
flags
&
SFLAG_INSYSMEM
)
ERR
(
"Surface without memory or PBO has SFLAG_INSYSMEM set.
\n
"
);
...
...
@@ -608,9 +607,9 @@ static void surface_evict_sysmem(struct wined3d_surface *surface)
if
(
surface
->
resource
.
map_count
||
(
surface
->
flags
&
SFLAG_DONOTFREE
))
return
;
HeapFree
(
GetProcessHeap
(),
0
,
surface
->
resource
.
heapM
emory
);
wined3d_resource_free_sysmem
(
surface
->
resource
.
heap_m
emory
);
surface
->
resource
.
allocatedMemory
=
NULL
;
surface
->
resource
.
heap
M
emory
=
NULL
;
surface
->
resource
.
heap
_m
emory
=
NULL
;
surface_modify_location
(
surface
,
SFLAG_INSYSMEM
,
FALSE
);
}
...
...
@@ -1778,14 +1777,13 @@ static void surface_remove_pbo(struct wined3d_surface *surface, const struct win
}
else
{
if
(
!
surface
->
resource
.
heap
M
emory
)
surface
->
resource
.
heap
Memory
=
HeapAlloc
(
GetProcessHeap
(),
0
,
surface
->
resource
.
size
+
RESOURCE_ALIGNMENT
);
if
(
!
surface
->
resource
.
heap
_m
emory
)
surface
->
resource
.
heap
_memory
=
wined3d_resource_allocate_sysmem
(
surface
->
resource
.
size
);
else
if
(
!
(
surface
->
flags
&
SFLAG_CLIENT
))
ERR
(
"Surface %p has heap
M
emory %p and flags %#x.
\n
"
,
surface
,
surface
->
resource
.
heap
M
emory
,
surface
->
flags
);
ERR
(
"Surface %p has heap
_m
emory %p and flags %#x.
\n
"
,
surface
,
surface
->
resource
.
heap
_m
emory
,
surface
->
flags
);
surface
->
resource
.
allocatedMemory
=
(
BYTE
*
)(((
ULONG_PTR
)
surface
->
resource
.
heapMemory
+
(
RESOURCE_ALIGNMENT
-
1
))
&
~
(
RESOURCE_ALIGNMENT
-
1
));
surface
->
resource
.
allocatedMemory
=
surface
->
resource
.
heap_memory
;
}
GL_EXTCALL
(
glBindBufferARB
(
GL_PIXEL_UNPACK_BUFFER_ARB
,
surface
->
pbo
));
...
...
@@ -1804,10 +1802,10 @@ static BOOL surface_init_sysmem(struct wined3d_surface *surface)
{
if
(
!
surface
->
resource
.
allocatedMemory
)
{
if
(
!
surface
->
resource
.
heap
M
emory
)
if
(
!
surface
->
resource
.
heap
_m
emory
)
{
if
(
!
(
surface
->
resource
.
heapMemory
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
surface
->
resource
.
size
+
RESOURCE_ALIGNMENT
))
)
surface
->
resource
.
heap_memory
=
wined3d_resource_allocate_sysmem
(
surface
->
resource
.
size
);
if
(
!
surface
->
resource
.
heap_memory
)
{
ERR
(
"Failed to allocate memory.
\n
"
);
return
FALSE
;
...
...
@@ -1815,12 +1813,11 @@ static BOOL surface_init_sysmem(struct wined3d_surface *surface)
}
else
if
(
!
(
surface
->
flags
&
SFLAG_CLIENT
))
{
ERR
(
"Surface %p has heap
M
emory %p and flags %#x.
\n
"
,
surface
,
surface
->
resource
.
heap
M
emory
,
surface
->
flags
);
ERR
(
"Surface %p has heap
_m
emory %p and flags %#x.
\n
"
,
surface
,
surface
->
resource
.
heap
_m
emory
,
surface
->
flags
);
}
surface
->
resource
.
allocatedMemory
=
(
BYTE
*
)(((
ULONG_PTR
)
surface
->
resource
.
heapMemory
+
(
RESOURCE_ALIGNMENT
-
1
))
&
~
(
RESOURCE_ALIGNMENT
-
1
));
surface
->
resource
.
allocatedMemory
=
surface
->
resource
.
heap_memory
;
}
else
{
...
...
@@ -1963,8 +1960,8 @@ static HRESULT gdi_surface_private_setup(struct wined3d_surface *surface)
hr
=
surface_create_dib_section
(
surface
);
if
(
SUCCEEDED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
surface
->
resource
.
heapM
emory
);
surface
->
resource
.
heap
M
emory
=
NULL
;
wined3d_resource_free_sysmem
(
surface
->
resource
.
heap_m
emory
);
surface
->
resource
.
heap
_m
emory
=
NULL
;
surface
->
resource
.
allocatedMemory
=
surface
->
dib
.
bitmap_data
;
}
...
...
@@ -2023,8 +2020,8 @@ static void gdi_surface_map(struct wined3d_surface *surface, const RECT *rect, D
ERR
(
"Failed to create dib section, hr %#x.
\n
"
,
hr
);
return
;
}
HeapFree
(
GetProcessHeap
(),
0
,
surface
->
resource
.
heapM
emory
);
surface
->
resource
.
heap
M
emory
=
NULL
;
wined3d_resource_free_sysmem
(
surface
->
resource
.
heap_m
emory
);
surface
->
resource
.
heap
_m
emory
=
NULL
;
surface
->
resource
.
allocatedMemory
=
surface
->
dib
.
bitmap_data
;
}
}
...
...
@@ -2691,9 +2688,8 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
/* Point OpenGL to our allocated texture memory. Do not use
* resource.allocatedMemory here because it might point into a
* PBO. Instead use heapMemory, but get the alignment right. */
mem
=
(
BYTE
*
)(((
ULONG_PTR
)
surface
->
resource
.
heapMemory
+
(
RESOURCE_ALIGNMENT
-
1
))
&
~
(
RESOURCE_ALIGNMENT
-
1
));
* PBO. Instead use heap_memory. */
mem
=
surface
->
resource
.
heap_memory
;
gl_info
->
gl_ops
.
gl
.
p_glPixelStorei
(
GL_UNPACK_CLIENT_STORAGE_APPLE
,
GL_TRUE
);
checkGLcall
(
"glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)"
);
...
...
@@ -3255,8 +3251,8 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
}
else
if
(
!
(
surface
->
flags
&
SFLAG_USERPTR
))
{
release
=
surface
->
resource
.
heap
M
emory
;
surface
->
resource
.
heap
M
emory
=
NULL
;
release
=
surface
->
resource
.
heap
_m
emory
;
surface
->
resource
.
heap
_m
emory
=
NULL
;
}
surface
->
resource
.
allocatedMemory
=
mem
;
surface
->
flags
|=
SFLAG_USERPTR
;
...
...
@@ -3269,12 +3265,12 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
surface_release_client_storage
(
surface
);
/* Now free the old memory if any. */
HeapFree
(
GetProcessHeap
(),
0
,
release
);
wined3d_resource_free_sysmem
(
release
);
}
else
if
(
surface
->
flags
&
SFLAG_USERPTR
)
{
/*
HeapM
emory should be NULL already. */
if
(
surface
->
resource
.
heap
M
emory
)
/*
heap_m
emory should be NULL already. */
if
(
surface
->
resource
.
heap
_m
emory
)
ERR
(
"User pointer surface has heap memory allocated.
\n
"
);
if
(
!
mem
)
...
...
@@ -3458,8 +3454,8 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
surface
->
flags
&=
~
(
SFLAG_LOCATIONS
|
SFLAG_USERPTR
);
surface
->
resource
.
allocatedMemory
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
surface
->
resource
.
heapM
emory
);
surface
->
resource
.
heap
M
emory
=
NULL
;
wined3d_resource_free_sysmem
(
surface
->
resource
.
heap_m
emory
);
surface
->
resource
.
heap
_m
emory
=
NULL
;
surface
->
resource
.
width
=
width
;
surface
->
resource
.
height
=
height
;
...
...
@@ -3955,8 +3951,8 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
/* Use the DIB section from now on if we are not using a PBO. */
if
(
!
(
surface
->
flags
&
(
SFLAG_PBO
|
SFLAG_PIN_SYSMEM
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
surface
->
resource
.
heapM
emory
);
surface
->
resource
.
heap
M
emory
=
NULL
;
wined3d_resource_free_sysmem
(
surface
->
resource
.
heap_m
emory
);
surface
->
resource
.
heap
_m
emory
=
NULL
;
surface
->
resource
.
allocatedMemory
=
surface
->
dib
.
bitmap_data
;
}
}
...
...
@@ -4785,9 +4781,9 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back)
front
->
resource
.
allocatedMemory
=
back
->
resource
.
allocatedMemory
;
back
->
resource
.
allocatedMemory
=
tmp
;
tmp
=
front
->
resource
.
heap
M
emory
;
front
->
resource
.
heap
Memory
=
back
->
resource
.
heapM
emory
;
back
->
resource
.
heap
M
emory
=
tmp
;
tmp
=
front
->
resource
.
heap
_m
emory
;
front
->
resource
.
heap
_memory
=
back
->
resource
.
heap_m
emory
;
back
->
resource
.
heap
_m
emory
=
tmp
;
}
/* Flip the PBO */
...
...
@@ -5456,9 +5452,9 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(struct wined3d_surface *dst_surfa
if
(
!
dst_surface
->
resource
.
map_count
&&
!
(
dst_surface
->
flags
&
SFLAG_DONOTFREE
))
{
HeapFree
(
GetProcessHeap
(),
0
,
dst_surface
->
resource
.
heapM
emory
);
wined3d_resource_free_sysmem
(
dst_surface
->
resource
.
heap_m
emory
);
dst_surface
->
resource
.
allocatedMemory
=
NULL
;
dst_surface
->
resource
.
heap
M
emory
=
NULL
;
dst_surface
->
resource
.
heap
_m
emory
=
NULL
;
}
else
{
...
...
@@ -7224,8 +7220,8 @@ static HRESULT surface_init(struct wined3d_surface *surface, UINT alignment, UIN
if
((
usage
&
WINED3DUSAGE_OWNDC
)
&&
!
surface
->
hDC
&&
SUCCEEDED
(
surface_create_dib_section
(
surface
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
surface
->
resource
.
heapM
emory
);
surface
->
resource
.
heap
M
emory
=
NULL
;
wined3d_resource_free_sysmem
(
surface
->
resource
.
heap_m
emory
);
surface
->
resource
.
heap
_m
emory
=
NULL
;
surface
->
resource
.
allocatedMemory
=
surface
->
dib
.
bitmap_data
;
}
...
...
dlls/wined3d/swapchain.c
View file @
4dd4a691
...
...
@@ -737,10 +737,10 @@ static void swapchain_gdi_present(struct wined3d_swapchain *swapchain, const REC
front
->
resource
.
allocatedMemory
=
back
->
resource
.
allocatedMemory
;
back
->
resource
.
allocatedMemory
=
tmp
;
if
(
front
->
resource
.
heap
M
emory
)
if
(
front
->
resource
.
heap
_m
emory
)
ERR
(
"GDI Surface %p has heap memory allocated.
\n
"
,
front
);
if
(
back
->
resource
.
heap
M
emory
)
if
(
back
->
resource
.
heap
_m
emory
)
ERR
(
"GDI Surface %p has heap memory allocated.
\n
"
,
back
);
}
...
...
dlls/wined3d/wined3d_private.h
View file @
4dd4a691
...
...
@@ -1926,6 +1926,9 @@ struct wined3d_resource_ops
void
(
*
resource_unload
)(
struct
wined3d_resource
*
resource
);
};
void
*
wined3d_resource_allocate_sysmem
(
SIZE_T
size
)
DECLSPEC_HIDDEN
;
void
wined3d_resource_free_sysmem
(
void
*
mem
)
DECLSPEC_HIDDEN
;
struct
wined3d_resource
{
LONG
ref
;
...
...
@@ -1935,19 +1938,19 @@ struct wined3d_resource
enum
wined3d_resource_type
type
;
const
struct
wined3d_format
*
format
;
enum
wined3d_multisample_type
multisample_type
;
UINT
multisample_quality
;
DWORD
usage
;
UINT
multisample_quality
;
DWORD
usage
;
enum
wined3d_pool
pool
;
DWORD
access_flags
;
UINT
width
;
UINT
height
;
UINT
depth
;
UINT
size
;
DWORD
priority
;
BYTE
*
allocatedMemory
;
/* Pointer to the real data location */
BYTE
*
heapMemory
;
/* Pointer to the HeapAlloced block of memory */
struct
list
privateData
;
struct
list
resource_list_entry
;
UINT
size
;
DWORD
priority
;
BYTE
*
allocatedMemory
;
/* Pointer to the real data location */
void
*
heap_memory
;
struct
list
privateData
;
struct
list
resource_list_entry
;
void
*
parent
;
const
struct
wined3d_parent_ops
*
parent_ops
;
...
...
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