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
Expand all
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
This diff is collapsed.
Click to expand it.
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