Skip to content

Commit fd98bd0

Browse files
[d3d9] Set priority only for D3DPOOL_MANAGED/DEFAULT resources
1 parent 6860e1c commit fd98bd0

14 files changed

+85
-41
lines changed

src/d3d9/d3d9_buffer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ namespace dxvk {
88

99
D3D9VertexBuffer::D3D9VertexBuffer(
1010
D3D9DeviceEx* pDevice,
11-
const D3D9_BUFFER_DESC* pDesc)
12-
: D3D9VertexBufferBase(pDevice, pDesc) {
11+
const D3D9_BUFFER_DESC* pDesc,
12+
const bool Extended)
13+
: D3D9VertexBufferBase(pDevice, pDesc, Extended) {
1314

1415
}
1516

@@ -68,8 +69,9 @@ namespace dxvk {
6869

6970
D3D9IndexBuffer::D3D9IndexBuffer(
7071
D3D9DeviceEx* pDevice,
71-
const D3D9_BUFFER_DESC* pDesc)
72-
: D3D9IndexBufferBase(pDevice, pDesc) {
72+
const D3D9_BUFFER_DESC* pDesc,
73+
const bool Extended)
74+
: D3D9IndexBufferBase(pDevice, pDesc, Extended) {
7375

7476
}
7577

src/d3d9/d3d9_buffer.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ namespace dxvk {
1313

1414
D3D9Buffer(
1515
D3D9DeviceEx* pDevice,
16-
const D3D9_BUFFER_DESC* pDesc)
17-
: D3D9Resource<Type...> (pDevice),
16+
const D3D9_BUFFER_DESC* pDesc,
17+
const bool Extended)
18+
: D3D9Resource<Type...> (pDevice, pDesc->Pool, Extended ),
1819
m_buffer (pDevice, pDesc) {
1920

2021
}
@@ -57,7 +58,8 @@ namespace dxvk {
5758

5859
D3D9VertexBuffer(
5960
D3D9DeviceEx* pDevice,
60-
const D3D9_BUFFER_DESC* pDesc);
61+
const D3D9_BUFFER_DESC* pDesc,
62+
const bool Extended);
6163

6264
HRESULT STDMETHODCALLTYPE QueryInterface(
6365
REFIID riid,
@@ -76,7 +78,8 @@ namespace dxvk {
7678

7779
D3D9IndexBuffer(
7880
D3D9DeviceEx* pDevice,
79-
const D3D9_BUFFER_DESC* pDesc);
81+
const D3D9_BUFFER_DESC* pDesc,
82+
const bool Extended);
8083

8184
HRESULT STDMETHODCALLTYPE QueryInterface(
8285
REFIID riid,

src/d3d9/d3d9_common_texture.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ namespace dxvk {
325325

326326
uint32_t GetPlaneCount() const;
327327

328+
D3DPOOL GetPool() const { return m_desc.Pool; }
329+
328330
const D3D9_VK_FORMAT_MAPPING& GetMapping() { return m_mapping; }
329331

330332
void SetLocked(UINT Subresource, bool value) { m_locked.set(Subresource, value); }

src/d3d9/d3d9_device.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ namespace dxvk {
657657
if (pSharedHandle != nullptr && Pool != D3DPOOL_DEFAULT)
658658
return D3DERR_INVALIDCALL;
659659

660-
const Com<D3D9Texture2D> texture = new D3D9Texture2D(this, &desc, pSharedHandle);
660+
const Com<D3D9Texture2D> texture = new D3D9Texture2D(this, &desc, IsExtended(), pSharedHandle);
661661

662662
m_initializer->InitTexture(texture->GetCommonTexture(), initialData);
663663
*ppTexture = texture.ref();
@@ -717,7 +717,7 @@ namespace dxvk {
717717
return D3DERR_INVALIDCALL;
718718

719719
try {
720-
const Com<D3D9Texture3D> texture = new D3D9Texture3D(this, &desc);
720+
const Com<D3D9Texture3D> texture = new D3D9Texture3D(this, &desc, IsExtended());
721721
m_initializer->InitTexture(texture->GetCommonTexture());
722722
*ppVolumeTexture = texture.ref();
723723

@@ -775,7 +775,7 @@ namespace dxvk {
775775
return D3DERR_INVALIDCALL;
776776

777777
try {
778-
const Com<D3D9TextureCube> texture = new D3D9TextureCube(this, &desc);
778+
const Com<D3D9TextureCube> texture = new D3D9TextureCube(this, &desc, IsExtended());
779779
m_initializer->InitTexture(texture->GetCommonTexture());
780780
*ppCubeTexture = texture.ref();
781781

@@ -819,7 +819,7 @@ namespace dxvk {
819819
return D3DERR_INVALIDCALL;
820820

821821
try {
822-
const Com<D3D9VertexBuffer> buffer = new D3D9VertexBuffer(this, &desc);
822+
const Com<D3D9VertexBuffer> buffer = new D3D9VertexBuffer(this, &desc, IsExtended());
823823
m_initializer->InitBuffer(buffer->GetCommonBuffer());
824824
*ppVertexBuffer = buffer.ref();
825825

@@ -862,7 +862,7 @@ namespace dxvk {
862862
return D3DERR_INVALIDCALL;
863863

864864
try {
865-
const Com<D3D9IndexBuffer> buffer = new D3D9IndexBuffer(this, &desc);
865+
const Com<D3D9IndexBuffer> buffer = new D3D9IndexBuffer(this, &desc, IsExtended());
866866
m_initializer->InitBuffer(buffer->GetCommonBuffer());
867867
*ppIndexBuffer = buffer.ref();
868868

@@ -4126,7 +4126,7 @@ namespace dxvk {
41264126
return D3DERR_INVALIDCALL;
41274127

41284128
try {
4129-
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, nullptr, pSharedHandle);
4129+
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, IsExtended(), nullptr, pSharedHandle);
41304130
m_initializer->InitTexture(surface->GetCommonTexture());
41314131
*ppSurface = surface.ref();
41324132
m_losableResourceCounter++;
@@ -4177,7 +4177,7 @@ namespace dxvk {
41774177
return D3DERR_INVALIDCALL;
41784178

41794179
try {
4180-
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, nullptr, pSharedHandle);
4180+
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, IsExtended(), nullptr, pSharedHandle);
41814181
m_initializer->InitTexture(surface->GetCommonTexture());
41824182
*ppSurface = surface.ref();
41834183

@@ -4228,7 +4228,7 @@ namespace dxvk {
42284228
return D3DERR_INVALIDCALL;
42294229

42304230
try {
4231-
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, nullptr, pSharedHandle);
4231+
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, IsExtended(), nullptr, pSharedHandle);
42324232
m_initializer->InitTexture(surface->GetCommonTexture());
42334233
*ppSurface = surface.ref();
42344234
m_losableResourceCounter++;
@@ -8509,7 +8509,7 @@ namespace dxvk {
85098509
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_SURFACE, &desc)))
85108510
return D3DERR_NOTAVAILABLE;
85118511

8512-
m_autoDepthStencil = new D3D9Surface(this, &desc, nullptr, nullptr);
8512+
m_autoDepthStencil = new D3D9Surface(this, &desc, IsExtended(), nullptr, nullptr);
85138513
m_initializer->InitTexture(m_autoDepthStencil->GetCommonTexture());
85148514
SetDepthStencilSurface(m_autoDepthStencil.ptr());
85158515
m_losableResourceCounter++;

src/d3d9/d3d9_interop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ namespace dxvk {
349349
const D3D9_COMMON_TEXTURE_DESC& desc,
350350
IDirect3DResource9** ppResult) {
351351
try {
352-
const Com<ResourceType> texture = new ResourceType(m_device, &desc);
352+
const Com<ResourceType> texture = new ResourceType(m_device, &desc, m_device->IsExtended());
353353
m_device->m_initializer->InitTexture(texture->GetCommonTexture());
354354
*ppResult = texture.ref();
355355

src/d3d9/d3d9_resource.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ namespace dxvk {
1111

1212
public:
1313

14-
D3D9Resource(D3D9DeviceEx* pDevice)
14+
D3D9Resource(D3D9DeviceEx* pDevice, D3DPOOL Pool, bool Extended)
1515
: D3D9DeviceChild<Type...>(pDevice)
16-
, m_priority ( 0 ) { }
16+
, m_pool ( Pool )
17+
, m_priority ( 0 )
18+
, m_isExtended ( Extended ) { }
1719

1820
HRESULT STDMETHODCALLTYPE SetPrivateData(
1921
REFGUID refguid,
@@ -72,9 +74,16 @@ namespace dxvk {
7274
}
7375

7476
DWORD STDMETHODCALLTYPE SetPriority(DWORD PriorityNew) {
75-
DWORD oldPriority = m_priority;
76-
m_priority = PriorityNew;
77-
return oldPriority;
77+
// Priority can only be set for D3DPOOL_MANAGED resources on
78+
// D3D9 interfaces, and for D3DPOOL_DEFAULT on D3D9Ex interfaces
79+
if ((m_pool == D3DPOOL_MANAGED && !m_isExtended)
80+
|| (m_pool == D3DPOOL_DEFAULT && m_isExtended)) {
81+
DWORD oldPriority = m_priority;
82+
m_priority = PriorityNew;
83+
return oldPriority;
84+
}
85+
86+
return m_priority;
7887
}
7988

8089
DWORD STDMETHODCALLTYPE GetPriority() {
@@ -84,10 +93,12 @@ namespace dxvk {
8493

8594
protected:
8695

87-
DWORD m_priority;
96+
D3DPOOL m_pool;
97+
DWORD m_priority;
8898

8999
private:
90100

101+
bool m_isExtended;
91102
ComPrivateData m_privateData;
92103

93104
};

src/d3d9/d3d9_subresource.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ namespace dxvk {
1212

1313
D3D9Subresource(
1414
D3D9DeviceEx* pDevice,
15+
const bool Extended,
1516
D3D9CommonTexture* pTexture,
1617
UINT Face,
1718
UINT MipLevel,
1819
IDirect3DBaseTexture9* pBaseTexture,
1920
IUnknown* pContainer)
20-
: D3D9Resource<Type...>(pDevice),
21+
: D3D9Resource<Type...>(pDevice, pTexture->GetPool(), Extended),
2122
m_container (pContainer),
2223
m_baseTexture (pBaseTexture),
2324
m_texture (pTexture),

src/d3d9/d3d9_surface.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,38 @@ namespace dxvk {
1111
D3D9Surface::D3D9Surface(
1212
D3D9DeviceEx* pDevice,
1313
const D3D9_COMMON_TEXTURE_DESC* pDesc,
14+
const bool Extended,
1415
IUnknown* pContainer,
1516
HANDLE* pSharedHandle)
1617
: D3D9SurfaceBase(
1718
pDevice,
19+
Extended,
1820
new D3D9CommonTexture( pDevice, this, pDesc, D3DRTYPE_SURFACE, pSharedHandle),
1921
0, 0,
2022
nullptr,
2123
pContainer) { }
2224

2325
D3D9Surface::D3D9Surface(
2426
D3D9DeviceEx* pDevice,
25-
const D3D9_COMMON_TEXTURE_DESC* pDesc)
27+
const D3D9_COMMON_TEXTURE_DESC* pDesc,
28+
const bool Extended)
2629
: D3D9Surface(
2730
pDevice,
2831
pDesc,
32+
Extended,
2933
nullptr,
3034
nullptr) { }
3135

3236
D3D9Surface::D3D9Surface(
3337
D3D9DeviceEx* pDevice,
38+
const bool Extended,
3439
D3D9CommonTexture* pTexture,
3540
UINT Face,
3641
UINT MipLevel,
3742
IDirect3DBaseTexture9* pBaseTexture)
3843
: D3D9SurfaceBase(
3944
pDevice,
45+
Extended,
4046
pTexture,
4147
Face, MipLevel,
4248
pBaseTexture,

src/d3d9/d3d9_surface.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ namespace dxvk {
2020
D3D9Surface(
2121
D3D9DeviceEx* pDevice,
2222
const D3D9_COMMON_TEXTURE_DESC* pDesc,
23+
const bool Extended,
2324
IUnknown* pContainer,
2425
HANDLE* pSharedHandle);
2526

2627
D3D9Surface(
2728
D3D9DeviceEx* pDevice,
28-
const D3D9_COMMON_TEXTURE_DESC* pDesc);
29+
const D3D9_COMMON_TEXTURE_DESC* pDesc,
30+
const bool Extended);
2931

3032
D3D9Surface(
3133
D3D9DeviceEx* pDevice,
34+
const bool Extended,
3235
D3D9CommonTexture* pTexture,
3336
UINT Face,
3437
UINT MipLevel,

src/d3d9/d3d9_swapchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ namespace dxvk {
10221022
for (uint32_t i = 0; i < NumBuffers; i++) {
10231023
D3D9Surface* surface;
10241024
try {
1025-
surface = new D3D9Surface(m_parent, &desc, this, nullptr);
1025+
surface = new D3D9Surface(m_parent, &desc, m_parent->IsExtended(), this, nullptr);
10261026
m_parent->IncrementLosableCounter();
10271027
} catch (const DxvkError& e) {
10281028
DestroyBackBuffers();

src/d3d9/d3d9_texture.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ namespace dxvk {
99
D3D9Texture2D::D3D9Texture2D(
1010
D3D9DeviceEx* pDevice,
1111
const D3D9_COMMON_TEXTURE_DESC* pDesc,
12+
const bool Extended,
1213
HANDLE* pSharedHandle)
13-
: D3D9Texture2DBase( pDevice, pDesc, D3DRTYPE_TEXTURE, pSharedHandle ) { }
14+
: D3D9Texture2DBase( pDevice, pDesc, Extended, D3DRTYPE_TEXTURE, pSharedHandle ) { }
1415

1516
D3D9Texture2D::D3D9Texture2D(
1617
D3D9DeviceEx* pDevice,
17-
const D3D9_COMMON_TEXTURE_DESC* pDesc)
18-
: D3D9Texture2D( pDevice, pDesc, nullptr ) { }
18+
const D3D9_COMMON_TEXTURE_DESC* pDesc,
19+
const bool Extended)
20+
: D3D9Texture2D( pDevice, pDesc, Extended, nullptr ) { }
1921

2022
HRESULT STDMETHODCALLTYPE D3D9Texture2D::QueryInterface(REFIID riid, void** ppvObject) {
2123
if (ppvObject == nullptr)
@@ -112,8 +114,9 @@ namespace dxvk {
112114

113115
D3D9Texture3D::D3D9Texture3D(
114116
D3D9DeviceEx* pDevice,
115-
const D3D9_COMMON_TEXTURE_DESC* pDesc)
116-
: D3D9Texture3DBase( pDevice, pDesc, D3DRTYPE_VOLUMETEXTURE, nullptr ) { }
117+
const D3D9_COMMON_TEXTURE_DESC* pDesc,
118+
const bool Extended)
119+
: D3D9Texture3DBase( pDevice, pDesc, Extended, D3DRTYPE_VOLUMETEXTURE, nullptr ) { }
117120

118121

119122
HRESULT STDMETHODCALLTYPE D3D9Texture3D::QueryInterface(REFIID riid, void** ppvObject) {
@@ -205,8 +208,9 @@ namespace dxvk {
205208

206209
D3D9TextureCube::D3D9TextureCube(
207210
D3D9DeviceEx* pDevice,
208-
const D3D9_COMMON_TEXTURE_DESC* pDesc)
209-
: D3D9TextureCubeBase( pDevice, pDesc, D3DRTYPE_CUBETEXTURE, nullptr ) { }
211+
const D3D9_COMMON_TEXTURE_DESC* pDesc,
212+
const bool Extended)
213+
: D3D9TextureCubeBase( pDevice, pDesc, Extended, D3DRTYPE_CUBETEXTURE, nullptr ) { }
210214

211215

212216
HRESULT STDMETHODCALLTYPE D3D9TextureCube::QueryInterface(REFIID riid, void** ppvObject) {

src/d3d9/d3d9_texture.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ namespace dxvk {
2323
D3D9BaseTexture(
2424
D3D9DeviceEx* pDevice,
2525
const D3D9_COMMON_TEXTURE_DESC* pDesc,
26+
const bool Extended,
2627
D3DRESOURCETYPE ResourceType,
2728
HANDLE* pSharedHandle)
28-
: D3D9Resource<Base...> ( pDevice )
29+
: D3D9Resource<Base...> ( pDevice, pDesc->Pool, Extended )
2930
, m_texture ( pDevice, this, pDesc, ResourceType, pSharedHandle )
3031
, m_lod ( 0 ) {
3132
const uint32_t arraySlices = m_texture.Desc()->ArraySize;
@@ -41,6 +42,7 @@ namespace dxvk {
4142

4243
new (subObj) SubresourceType(
4344
pDevice,
45+
Extended,
4446
&m_texture,
4547
i, j,
4648
this);
@@ -132,11 +134,13 @@ namespace dxvk {
132134
D3D9Texture2D(
133135
D3D9DeviceEx* pDevice,
134136
const D3D9_COMMON_TEXTURE_DESC* pDesc,
137+
const bool Extended,
135138
HANDLE* pSharedHandle);
136139

137140
D3D9Texture2D(
138141
D3D9DeviceEx* pDevice,
139-
const D3D9_COMMON_TEXTURE_DESC* pDesc);
142+
const D3D9_COMMON_TEXTURE_DESC* pDesc,
143+
const bool Extended);
140144

141145

142146
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
@@ -162,7 +166,8 @@ namespace dxvk {
162166

163167
D3D9Texture3D(
164168
D3D9DeviceEx* pDevice,
165-
const D3D9_COMMON_TEXTURE_DESC* pDesc);
169+
const D3D9_COMMON_TEXTURE_DESC* pDesc,
170+
const bool Extended);
166171

167172
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
168173

@@ -187,7 +192,8 @@ namespace dxvk {
187192

188193
D3D9TextureCube(
189194
D3D9DeviceEx* pDevice,
190-
const D3D9_COMMON_TEXTURE_DESC* pDesc);
195+
const D3D9_COMMON_TEXTURE_DESC* pDesc,
196+
const bool Extended);
191197

192198
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
193199

0 commit comments

Comments
 (0)