1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-23 10:54:14 +01:00

[d3d9] Set priority only for D3DPOOL_MANAGED/DEFAULT resources

This commit is contained in:
WinterSnowfall 2025-02-14 01:44:53 +02:00 committed by Philip Rebohle
parent 84b2ac3f97
commit 274c590ad6
14 changed files with 86 additions and 42 deletions

View File

@ -8,8 +8,9 @@ namespace dxvk {
D3D9VertexBuffer::D3D9VertexBuffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc)
: D3D9VertexBufferBase(pDevice, pDesc) {
const D3D9_BUFFER_DESC* pDesc,
const bool Extended)
: D3D9VertexBufferBase(pDevice, pDesc, Extended) {
}
@ -68,8 +69,9 @@ namespace dxvk {
D3D9IndexBuffer::D3D9IndexBuffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc)
: D3D9IndexBufferBase(pDevice, pDesc) {
const D3D9_BUFFER_DESC* pDesc,
const bool Extended)
: D3D9IndexBufferBase(pDevice, pDesc, Extended) {
}

View File

@ -13,8 +13,9 @@ namespace dxvk {
D3D9Buffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc)
: D3D9Resource<Type...> (pDevice),
const D3D9_BUFFER_DESC* pDesc,
const bool Extended)
: D3D9Resource<Type...> (pDevice, pDesc->Pool, Extended ),
m_buffer (pDevice, pDesc) {
}
@ -57,7 +58,8 @@ namespace dxvk {
D3D9VertexBuffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc);
const D3D9_BUFFER_DESC* pDesc,
const bool Extended);
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
@ -76,7 +78,8 @@ namespace dxvk {
D3D9IndexBuffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc);
const D3D9_BUFFER_DESC* pDesc,
const bool Extended);
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,

View File

@ -325,6 +325,8 @@ namespace dxvk {
uint32_t GetPlaneCount() const;
D3DPOOL GetPool() const { return m_desc.Pool; }
const D3D9_VK_FORMAT_MAPPING& GetMapping() { return m_mapping; }
void SetLocked(UINT Subresource, bool value) { m_locked.set(Subresource, value); }

View File

@ -657,7 +657,7 @@ namespace dxvk {
if (pSharedHandle != nullptr && Pool != D3DPOOL_DEFAULT)
return D3DERR_INVALIDCALL;
const Com<D3D9Texture2D> texture = new D3D9Texture2D(this, &desc, pSharedHandle);
const Com<D3D9Texture2D> texture = new D3D9Texture2D(this, &desc, IsExtended(), pSharedHandle);
m_initializer->InitTexture(texture->GetCommonTexture(), initialData);
*ppTexture = texture.ref();
@ -717,7 +717,7 @@ namespace dxvk {
return D3DERR_INVALIDCALL;
try {
const Com<D3D9Texture3D> texture = new D3D9Texture3D(this, &desc);
const Com<D3D9Texture3D> texture = new D3D9Texture3D(this, &desc, IsExtended());
m_initializer->InitTexture(texture->GetCommonTexture());
*ppVolumeTexture = texture.ref();
@ -775,7 +775,7 @@ namespace dxvk {
return D3DERR_INVALIDCALL;
try {
const Com<D3D9TextureCube> texture = new D3D9TextureCube(this, &desc);
const Com<D3D9TextureCube> texture = new D3D9TextureCube(this, &desc, IsExtended());
m_initializer->InitTexture(texture->GetCommonTexture());
*ppCubeTexture = texture.ref();
@ -819,7 +819,7 @@ namespace dxvk {
return D3DERR_INVALIDCALL;
try {
const Com<D3D9VertexBuffer> buffer = new D3D9VertexBuffer(this, &desc);
const Com<D3D9VertexBuffer> buffer = new D3D9VertexBuffer(this, &desc, IsExtended());
m_initializer->InitBuffer(buffer->GetCommonBuffer());
*ppVertexBuffer = buffer.ref();
@ -862,7 +862,7 @@ namespace dxvk {
return D3DERR_INVALIDCALL;
try {
const Com<D3D9IndexBuffer> buffer = new D3D9IndexBuffer(this, &desc);
const Com<D3D9IndexBuffer> buffer = new D3D9IndexBuffer(this, &desc, IsExtended());
m_initializer->InitBuffer(buffer->GetCommonBuffer());
*ppIndexBuffer = buffer.ref();
@ -4126,7 +4126,7 @@ namespace dxvk {
return D3DERR_INVALIDCALL;
try {
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, nullptr, pSharedHandle);
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, IsExtended(), nullptr, pSharedHandle);
m_initializer->InitTexture(surface->GetCommonTexture());
*ppSurface = surface.ref();
m_losableResourceCounter++;
@ -4177,7 +4177,7 @@ namespace dxvk {
return D3DERR_INVALIDCALL;
try {
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, nullptr, pSharedHandle);
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, IsExtended(), nullptr, pSharedHandle);
m_initializer->InitTexture(surface->GetCommonTexture());
*ppSurface = surface.ref();
@ -4228,7 +4228,7 @@ namespace dxvk {
return D3DERR_INVALIDCALL;
try {
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, nullptr, pSharedHandle);
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, IsExtended(), nullptr, pSharedHandle);
m_initializer->InitTexture(surface->GetCommonTexture());
*ppSurface = surface.ref();
m_losableResourceCounter++;
@ -8510,7 +8510,7 @@ namespace dxvk {
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_SURFACE, &desc)))
return D3DERR_NOTAVAILABLE;
m_autoDepthStencil = new D3D9Surface(this, &desc, nullptr, nullptr);
m_autoDepthStencil = new D3D9Surface(this, &desc, IsExtended(), nullptr, nullptr);
m_initializer->InitTexture(m_autoDepthStencil->GetCommonTexture());
SetDepthStencilSurface(m_autoDepthStencil.ptr());
m_losableResourceCounter++;

View File

@ -349,7 +349,7 @@ namespace dxvk {
const D3D9_COMMON_TEXTURE_DESC& desc,
IDirect3DResource9** ppResult) {
try {
const Com<ResourceType> texture = new ResourceType(m_device, &desc);
const Com<ResourceType> texture = new ResourceType(m_device, &desc, m_device->IsExtended());
m_device->m_initializer->InitTexture(texture->GetCommonTexture());
*ppResult = texture.ref();

View File

@ -11,9 +11,11 @@ namespace dxvk {
public:
D3D9Resource(D3D9DeviceEx* pDevice)
D3D9Resource(D3D9DeviceEx* pDevice, D3DPOOL Pool, bool Extended)
: D3D9DeviceChild<Type...>(pDevice)
, m_priority ( 0 ) { }
, m_pool ( Pool )
, m_priority ( 0 )
, m_isExtended ( Extended ) { }
HRESULT STDMETHODCALLTYPE SetPrivateData(
REFGUID refguid,
@ -72,9 +74,16 @@ namespace dxvk {
}
DWORD STDMETHODCALLTYPE SetPriority(DWORD PriorityNew) {
DWORD oldPriority = m_priority;
m_priority = PriorityNew;
return oldPriority;
// Priority can only be set for D3DPOOL_MANAGED resources on
// D3D9 interfaces, and for D3DPOOL_DEFAULT on D3D9Ex interfaces
if (likely((m_pool == D3DPOOL_MANAGED && !m_isExtended)
|| (m_pool == D3DPOOL_DEFAULT && m_isExtended))) {
DWORD oldPriority = m_priority;
m_priority = PriorityNew;
return oldPriority;
}
return m_priority;
}
DWORD STDMETHODCALLTYPE GetPriority() {
@ -84,11 +93,13 @@ namespace dxvk {
protected:
DWORD m_priority;
const D3DPOOL m_pool;
DWORD m_priority;
private:
ComPrivateData m_privateData;
const bool m_isExtended;
ComPrivateData m_privateData;
};

View File

@ -12,12 +12,13 @@ namespace dxvk {
D3D9Subresource(
D3D9DeviceEx* pDevice,
const bool Extended,
D3D9CommonTexture* pTexture,
UINT Face,
UINT MipLevel,
IDirect3DBaseTexture9* pBaseTexture,
IUnknown* pContainer)
: D3D9Resource<Type...>(pDevice),
: D3D9Resource<Type...>(pDevice, pTexture->GetPool(), Extended),
m_container (pContainer),
m_baseTexture (pBaseTexture),
m_texture (pTexture),

View File

@ -11,10 +11,12 @@ namespace dxvk {
D3D9Surface::D3D9Surface(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended,
IUnknown* pContainer,
HANDLE* pSharedHandle)
: D3D9SurfaceBase(
pDevice,
Extended,
new D3D9CommonTexture( pDevice, this, pDesc, D3DRTYPE_SURFACE, pSharedHandle),
0, 0,
nullptr,
@ -22,21 +24,25 @@ namespace dxvk {
D3D9Surface::D3D9Surface(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc)
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended)
: D3D9Surface(
pDevice,
pDesc,
Extended,
nullptr,
nullptr) { }
D3D9Surface::D3D9Surface(
D3D9DeviceEx* pDevice,
const bool Extended,
D3D9CommonTexture* pTexture,
UINT Face,
UINT MipLevel,
IDirect3DBaseTexture9* pBaseTexture)
: D3D9SurfaceBase(
pDevice,
Extended,
pTexture,
Face, MipLevel,
pBaseTexture,

View File

@ -20,15 +20,18 @@ namespace dxvk {
D3D9Surface(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended,
IUnknown* pContainer,
HANDLE* pSharedHandle);
D3D9Surface(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc);
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended);
D3D9Surface(
D3D9DeviceEx* pDevice,
const bool Extended,
D3D9CommonTexture* pTexture,
UINT Face,
UINT MipLevel,

View File

@ -1022,7 +1022,7 @@ namespace dxvk {
for (uint32_t i = 0; i < NumBuffers; i++) {
D3D9Surface* surface;
try {
surface = new D3D9Surface(m_parent, &desc, this, nullptr);
surface = new D3D9Surface(m_parent, &desc, m_parent->IsExtended(), this, nullptr);
m_parent->IncrementLosableCounter();
} catch (const DxvkError& e) {
DestroyBackBuffers();

View File

@ -9,13 +9,15 @@ namespace dxvk {
D3D9Texture2D::D3D9Texture2D(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended,
HANDLE* pSharedHandle)
: D3D9Texture2DBase( pDevice, pDesc, D3DRTYPE_TEXTURE, pSharedHandle ) { }
: D3D9Texture2DBase( pDevice, pDesc, Extended, D3DRTYPE_TEXTURE, pSharedHandle ) { }
D3D9Texture2D::D3D9Texture2D(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc)
: D3D9Texture2D( pDevice, pDesc, nullptr ) { }
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended)
: D3D9Texture2D( pDevice, pDesc, Extended, nullptr ) { }
HRESULT STDMETHODCALLTYPE D3D9Texture2D::QueryInterface(REFIID riid, void** ppvObject) {
if (ppvObject == nullptr)
@ -112,8 +114,9 @@ namespace dxvk {
D3D9Texture3D::D3D9Texture3D(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc)
: D3D9Texture3DBase( pDevice, pDesc, D3DRTYPE_VOLUMETEXTURE, nullptr ) { }
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended)
: D3D9Texture3DBase( pDevice, pDesc, Extended, D3DRTYPE_VOLUMETEXTURE, nullptr ) { }
HRESULT STDMETHODCALLTYPE D3D9Texture3D::QueryInterface(REFIID riid, void** ppvObject) {
@ -205,8 +208,9 @@ namespace dxvk {
D3D9TextureCube::D3D9TextureCube(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc)
: D3D9TextureCubeBase( pDevice, pDesc, D3DRTYPE_CUBETEXTURE, nullptr ) { }
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended)
: D3D9TextureCubeBase( pDevice, pDesc, Extended, D3DRTYPE_CUBETEXTURE, nullptr ) { }
HRESULT STDMETHODCALLTYPE D3D9TextureCube::QueryInterface(REFIID riid, void** ppvObject) {

View File

@ -23,9 +23,10 @@ namespace dxvk {
D3D9BaseTexture(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended,
D3DRESOURCETYPE ResourceType,
HANDLE* pSharedHandle)
: D3D9Resource<Base...> ( pDevice )
: D3D9Resource<Base...> ( pDevice, pDesc->Pool, Extended )
, m_texture ( pDevice, this, pDesc, ResourceType, pSharedHandle )
, m_lod ( 0 ) {
const uint32_t arraySlices = m_texture.Desc()->ArraySize;
@ -41,6 +42,7 @@ namespace dxvk {
new (subObj) SubresourceType(
pDevice,
Extended,
&m_texture,
i, j,
this);
@ -132,11 +134,13 @@ namespace dxvk {
D3D9Texture2D(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended,
HANDLE* pSharedHandle);
D3D9Texture2D(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc);
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended);
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
@ -162,7 +166,8 @@ namespace dxvk {
D3D9Texture3D(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc);
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended);
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
@ -187,7 +192,8 @@ namespace dxvk {
D3D9TextureCube(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc);
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended);
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);

View File

@ -7,9 +7,11 @@ namespace dxvk {
D3D9Volume::D3D9Volume(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc)
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended)
: D3D9VolumeBase(
pDevice,
Extended,
new D3D9CommonTexture( pDevice, this, pDesc, D3DRTYPE_VOLUMETEXTURE, nullptr ),
0, 0,
nullptr,
@ -18,12 +20,14 @@ namespace dxvk {
D3D9Volume::D3D9Volume(
D3D9DeviceEx* pDevice,
const bool Extended,
D3D9CommonTexture* pTexture,
UINT Face,
UINT MipLevel,
IDirect3DBaseTexture9* pContainer)
: D3D9VolumeBase(
pDevice,
Extended,
pTexture,
Face, MipLevel,
pContainer,

View File

@ -13,10 +13,12 @@ namespace dxvk {
D3D9Volume(
D3D9DeviceEx* pDevice,
const D3D9_COMMON_TEXTURE_DESC* pDesc);
const D3D9_COMMON_TEXTURE_DESC* pDesc,
const bool Extended);
D3D9Volume(
D3D9DeviceEx* pDevice,
const bool Extended,
D3D9CommonTexture* pTexture,
UINT Face,
UINT MipLevel,