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
a9e241e4
Commit
a9e241e4
authored
Dec 11, 2012
by
Henri Verbeet
Committed by
Alexandre Julliard
Dec 12, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3d10core: Only create unique sampler state objects.
parent
14eadb71
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
16 deletions
+91
-16
d3d10core_main.c
dlls/d3d10core/d3d10core_main.c
+7
-1
d3d10core_private.h
dlls/d3d10core/d3d10core_private.h
+8
-2
device.c
dlls/d3d10core/device.c
+60
-7
state.c
dlls/d3d10core/state.c
+16
-6
No files found.
dlls/d3d10core/d3d10core_main.c
View file @
a9e241e4
...
...
@@ -69,6 +69,7 @@ static HRESULT WINAPI layer_create(enum dxgi_device_layer_id id, void **layer_ba
void
*
device_object
,
REFIID
riid
,
void
**
device_layer
)
{
struct
d3d10_device
*
object
;
HRESULT
hr
;
TRACE
(
"id %#x, layer_base %p, unknown0 %#x, device_object %p, riid %s, device_layer %p
\n
"
,
id
,
layer_base
,
unknown0
,
device_object
,
debugstr_guid
(
riid
),
device_layer
);
...
...
@@ -81,7 +82,12 @@ static HRESULT WINAPI layer_create(enum dxgi_device_layer_id id, void **layer_ba
}
object
=
*
layer_base
;
d3d10_device_init
(
object
,
device_object
);
if
(
FAILED
(
hr
=
d3d10_device_init
(
object
,
device_object
)))
{
WARN
(
"Failed to initialize device, hr %#x.
\n
"
,
hr
);
*
device_layer
=
NULL
;
return
hr
;
}
*
device_layer
=
&
object
->
IUnknown_inner
;
TRACE
(
"Created d3d10 device at %p
\n
"
,
object
);
...
...
dlls/d3d10core/d3d10core_private.h
View file @
a9e241e4
...
...
@@ -35,6 +35,7 @@
#endif
#include "wine/wined3d.h"
#include "wine/winedxgi.h"
#include "wine/rbtree.h"
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
...
...
@@ -247,11 +248,14 @@ struct d3d10_sampler_state
ID3D10SamplerState
ID3D10SamplerState_iface
;
LONG
refcount
;
struct
d3d10_device
*
device
;
struct
wined3d_sampler
*
wined3d_sampler
;
D3D10_SAMPLER_DESC
desc
;
struct
wine_rb_entry
entry
;
};
HRESULT
d3d10_sampler_state_init
(
struct
d3d10_sampler_state
*
state
,
const
D3D10_SAMPLER_DESC
*
desc
)
DECLSPEC_HIDDEN
;
HRESULT
d3d10_sampler_state_init
(
struct
d3d10_sampler_state
*
state
,
struct
d3d10_device
*
device
,
const
D3D10_SAMPLER_DESC
*
desc
)
DECLSPEC_HIDDEN
;
struct
d3d10_sampler_state
*
unsafe_impl_from_ID3D10SamplerState
(
ID3D10SamplerState
*
iface
)
DECLSPEC_HIDDEN
;
/* ID3D10Query */
...
...
@@ -275,6 +279,8 @@ struct d3d10_device
struct
wined3d_device_parent
device_parent
;
struct
wined3d_device
*
wined3d_device
;
struct
wine_rb_tree
sampler_states
;
struct
d3d10_blend_state
*
blend_state
;
float
blend_factor
[
4
];
UINT
sample_mask
;
...
...
@@ -283,7 +289,7 @@ struct d3d10_device
struct
d3d10_rasterizer_state
*
rasterizer_state
;
};
void
d3d10_device_init
(
struct
d3d10_device
*
device
,
void
*
outer_unknown
)
DECLSPEC_HIDDEN
;
HRESULT
d3d10_device_init
(
struct
d3d10_device
*
device
,
void
*
outer_unknown
)
DECLSPEC_HIDDEN
;
/* Layered device */
enum
dxgi_device_layer_id
...
...
dlls/d3d10core/device.c
View file @
a9e241e4
...
...
@@ -72,15 +72,16 @@ static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
static
ULONG
STDMETHODCALLTYPE
d3d10_device_inner_Release
(
IUnknown
*
iface
)
{
struct
d3d10_device
*
This
=
impl_from_IUnknown
(
iface
);
ULONG
refcount
=
InterlockedDecrement
(
&
This
->
refcount
);
struct
d3d10_device
*
device
=
impl_from_IUnknown
(
iface
);
ULONG
refcount
=
InterlockedDecrement
(
&
device
->
refcount
);
TRACE
(
"%p decreasing refcount to %u
\n
"
,
This
,
refcount
);
TRACE
(
"%p decreasing refcount to %u
.
\n
"
,
device
,
refcount
);
if
(
!
refcount
)
{
if
(
This
->
wined3d_device
)
wined3d_device_decref
(
This
->
wined3d_device
);
if
(
device
->
wined3d_device
)
wined3d_device_decref
(
device
->
wined3d_device
);
wine_rb_destroy
(
&
device
->
sampler_states
,
NULL
,
NULL
);
}
return
refcount
;
...
...
@@ -1471,7 +1472,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device
static
HRESULT
STDMETHODCALLTYPE
d3d10_device_CreateSamplerState
(
ID3D10Device
*
iface
,
const
D3D10_SAMPLER_DESC
*
desc
,
ID3D10SamplerState
**
sampler_state
)
{
struct
d3d10_device
*
device
=
impl_from_ID3D10Device
(
iface
);
struct
d3d10_sampler_state
*
object
;
struct
wine_rb_entry
*
entry
;
HRESULT
hr
;
TRACE
(
"iface %p, desc %p, sampler_state %p.
\n
"
,
iface
,
desc
,
sampler_state
);
...
...
@@ -1479,6 +1482,17 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *i
if
(
!
desc
)
return
E_INVALIDARG
;
if
((
entry
=
wine_rb_get
(
&
device
->
sampler_states
,
desc
)))
{
object
=
WINE_RB_ENTRY_VALUE
(
entry
,
struct
d3d10_sampler_state
,
entry
);
TRACE
(
"Returning existing sampler state %p.
\n
"
,
object
);
*
sampler_state
=
&
object
->
ID3D10SamplerState_iface
;
ID3D10SamplerState_AddRef
(
*
sampler_state
);
return
S_OK
;
}
object
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
object
));
if
(
!
object
)
{
...
...
@@ -1486,7 +1500,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateSamplerState(ID3D10Device *i
return
E_OUTOFMEMORY
;
}
if
(
FAILED
(
hr
=
d3d10_sampler_state_init
(
object
,
desc
)))
if
(
FAILED
(
hr
=
d3d10_sampler_state_init
(
object
,
de
vice
,
de
sc
)))
{
WARN
(
"Failed to initialize sampler state, hr %#x.
\n
"
,
hr
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
...
...
@@ -1908,7 +1922,38 @@ static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
device_parent_create_swapchain
,
};
void
d3d10_device_init
(
struct
d3d10_device
*
device
,
void
*
outer_unknown
)
static
void
*
d3d10_rb_alloc
(
size_t
size
)
{
return
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
}
static
void
*
d3d10_rb_realloc
(
void
*
ptr
,
size_t
size
)
{
return
HeapReAlloc
(
GetProcessHeap
(),
0
,
ptr
,
size
);
}
static
void
d3d10_rb_free
(
void
*
ptr
)
{
HeapFree
(
GetProcessHeap
(),
0
,
ptr
);
}
static
int
d3d10_sampler_state_compare
(
const
void
*
key
,
const
struct
wine_rb_entry
*
entry
)
{
const
D3D10_SAMPLER_DESC
*
ka
=
key
;
const
D3D10_SAMPLER_DESC
*
kb
=
&
WINE_RB_ENTRY_VALUE
(
entry
,
const
struct
d3d10_sampler_state
,
entry
)
->
desc
;
return
memcmp
(
ka
,
kb
,
sizeof
(
*
ka
));
}
static
const
struct
wine_rb_functions
d3d10_sampler_state_rb_ops
=
{
d3d10_rb_alloc
,
d3d10_rb_realloc
,
d3d10_rb_free
,
d3d10_sampler_state_compare
,
};
HRESULT
d3d10_device_init
(
struct
d3d10_device
*
device
,
void
*
outer_unknown
)
{
device
->
ID3D10Device_iface
.
lpVtbl
=
&
d3d10_device_vtbl
;
device
->
IUnknown_inner
.
lpVtbl
=
&
d3d10_device_inner_unknown_vtbl
;
...
...
@@ -1917,4 +1962,12 @@ void d3d10_device_init(struct d3d10_device *device, void *outer_unknown)
device
->
refcount
=
1
;
/* COM aggregation always takes place */
device
->
outer_unk
=
outer_unknown
;
if
(
wine_rb_init
(
&
device
->
sampler_states
,
&
d3d10_sampler_state_rb_ops
)
==
-
1
)
{
WARN
(
"Failed to initialize sampler state rbtree.
\n
"
);
return
E_FAIL
;
}
return
S_OK
;
}
dlls/d3d10core/state.c
View file @
a9e241e4
...
...
@@ -438,15 +438,16 @@ static ULONG STDMETHODCALLTYPE d3d10_sampler_state_AddRef(ID3D10SamplerState *if
static
ULONG
STDMETHODCALLTYPE
d3d10_sampler_state_Release
(
ID3D10SamplerState
*
iface
)
{
struct
d3d10_sampler_state
*
This
=
impl_from_ID3D10SamplerState
(
iface
);
ULONG
refcount
=
InterlockedDecrement
(
&
This
->
refcount
);
struct
d3d10_sampler_state
*
state
=
impl_from_ID3D10SamplerState
(
iface
);
ULONG
refcount
=
InterlockedDecrement
(
&
state
->
refcount
);
TRACE
(
"%p decreasing refcount to %u.
\n
"
,
This
,
refcount
);
TRACE
(
"%p decreasing refcount to %u.
\n
"
,
state
,
refcount
);
if
(
!
refcount
)
{
wined3d_sampler_decref
(
This
->
wined3d_sampler
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
wined3d_sampler_decref
(
state
->
wined3d_sampler
);
wine_rb_remove
(
&
state
->
device
->
sampler_states
,
&
state
->
desc
);
HeapFree
(
GetProcessHeap
(),
0
,
state
);
}
return
refcount
;
...
...
@@ -512,12 +513,14 @@ static const struct ID3D10SamplerStateVtbl d3d10_sampler_state_vtbl =
d3d10_sampler_state_GetDesc
,
};
HRESULT
d3d10_sampler_state_init
(
struct
d3d10_sampler_state
*
state
,
const
D3D10_SAMPLER_DESC
*
desc
)
HRESULT
d3d10_sampler_state_init
(
struct
d3d10_sampler_state
*
state
,
struct
d3d10_device
*
device
,
const
D3D10_SAMPLER_DESC
*
desc
)
{
HRESULT
hr
;
state
->
ID3D10SamplerState_iface
.
lpVtbl
=
&
d3d10_sampler_state_vtbl
;
state
->
refcount
=
1
;
state
->
device
=
device
;
state
->
desc
=
*
desc
;
if
(
FAILED
(
hr
=
wined3d_sampler_create
(
state
,
&
state
->
wined3d_sampler
)))
...
...
@@ -526,6 +529,13 @@ HRESULT d3d10_sampler_state_init(struct d3d10_sampler_state *state, const D3D10_
return
hr
;
}
if
(
wine_rb_put
(
&
device
->
sampler_states
,
desc
,
&
state
->
entry
)
==
-
1
)
{
ERR
(
"Failed to insert sampler state entry.
\n
"
);
wined3d_sampler_decref
(
state
->
wined3d_sampler
);
return
E_FAIL
;
}
return
S_OK
;
}
...
...
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