mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 05:52:11 +01:00
[d3d11] Add internal DXGI usage flags to textures
We need this for swap chain images.
This commit is contained in:
parent
a60916f7ee
commit
c98c5f5d17
@ -155,7 +155,7 @@ namespace dxvk {
|
||||
return S_FALSE;
|
||||
|
||||
try {
|
||||
Com<D3D11Texture2D> texture = new D3D11Texture2D(m_device, &desc, vkImage);
|
||||
Com<D3D11Texture2D> texture = new D3D11Texture2D(m_device, &desc, 0, vkImage);
|
||||
*ppTexture2D = texture.ref();
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
|
@ -96,7 +96,7 @@ namespace dxvk {
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
DXGI_USAGE usage = 0;
|
||||
DXGI_USAGE usage = desc.DxgiUsage;
|
||||
|
||||
switch (desc.Usage) {
|
||||
case D3D11_USAGE_IMMUTABLE: usage |= DXGI_CPU_ACCESS_NONE; break;
|
||||
@ -160,6 +160,7 @@ namespace dxvk {
|
||||
pDesc->BindFlags = buffer->Desc()->BindFlags;
|
||||
pDesc->CPUAccessFlags = buffer->Desc()->CPUAccessFlags;
|
||||
pDesc->MiscFlags = buffer->Desc()->MiscFlags;
|
||||
pDesc->DxgiUsage = 0;
|
||||
return S_OK;
|
||||
} else if (texture != nullptr) {
|
||||
pResource->GetType(&pDesc->Dim);
|
||||
@ -168,6 +169,7 @@ namespace dxvk {
|
||||
pDesc->BindFlags = texture->Desc()->BindFlags;
|
||||
pDesc->CPUAccessFlags = texture->Desc()->CPUAccessFlags;
|
||||
pDesc->MiscFlags = texture->Desc()->MiscFlags;
|
||||
pDesc->DxgiUsage = texture->GetDxgiUsage();
|
||||
return S_OK;
|
||||
} else {
|
||||
pDesc->Dim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||
@ -176,6 +178,7 @@ namespace dxvk {
|
||||
pDesc->BindFlags = 0;
|
||||
pDesc->CPUAccessFlags = 0;
|
||||
pDesc->MiscFlags = 0;
|
||||
pDesc->DxgiUsage = 0;
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace dxvk {
|
||||
UINT BindFlags;
|
||||
UINT CPUAccessFlags;
|
||||
UINT MiscFlags;
|
||||
UINT DxgiUsage;
|
||||
};
|
||||
|
||||
|
||||
|
@ -535,7 +535,13 @@ namespace dxvk {
|
||||
if (m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE)
|
||||
desc.MiscFlags |= D3D11_RESOURCE_MISC_GDI_COMPATIBLE;
|
||||
|
||||
m_backBuffer = new D3D11Texture2D(m_parent, &desc);
|
||||
DXGI_USAGE dxgiUsage = DXGI_USAGE_BACK_BUFFER;
|
||||
|
||||
if (m_desc.SwapEffect == DXGI_SWAP_EFFECT_DISCARD
|
||||
|| m_desc.SwapEffect == DXGI_SWAP_EFFECT_FLIP_DISCARD)
|
||||
dxgiUsage |= DXGI_USAGE_DISCARD_ON_PRESENT;
|
||||
|
||||
m_backBuffer = new D3D11Texture2D(m_parent, &desc, dxgiUsage, VK_NULL_HANDLE);
|
||||
m_backBuffer->AddRefPrivate();
|
||||
|
||||
m_swapImage = GetCommonTexture(m_backBuffer)->GetImage();
|
||||
|
@ -8,8 +8,9 @@ namespace dxvk {
|
||||
D3D11Device* pDevice,
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D11_RESOURCE_DIMENSION Dimension,
|
||||
DXGI_USAGE DxgiUsage,
|
||||
VkImage vkImage)
|
||||
: m_device(pDevice), m_desc(*pDesc) {
|
||||
: m_device(pDevice), m_desc(*pDesc), m_dxgiUsage(DxgiUsage) {
|
||||
DXGI_VK_FORMAT_MODE formatMode = GetFormatMode();
|
||||
DXGI_VK_FORMAT_INFO formatInfo = m_device->LookupFormat(m_desc.Format, formatMode);
|
||||
DXGI_VK_FORMAT_FAMILY formatFamily = m_device->LookupFamily(m_desc.Format, formatMode);
|
||||
@ -775,7 +776,7 @@ namespace dxvk {
|
||||
D3D11Device* pDevice,
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc)
|
||||
: D3D11DeviceChild<ID3D11Texture1D>(pDevice),
|
||||
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE1D, VK_NULL_HANDLE),
|
||||
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE1D, 0, VK_NULL_HANDLE),
|
||||
m_interop (this, &m_texture),
|
||||
m_surface (this, &m_texture),
|
||||
m_resource(this),
|
||||
@ -873,7 +874,7 @@ namespace dxvk {
|
||||
D3D11Device* pDevice,
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc)
|
||||
: D3D11DeviceChild<ID3D11Texture2D1>(pDevice),
|
||||
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, VK_NULL_HANDLE),
|
||||
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, 0, VK_NULL_HANDLE),
|
||||
m_interop (this, &m_texture),
|
||||
m_surface (this, &m_texture),
|
||||
m_resource(this),
|
||||
@ -885,9 +886,10 @@ namespace dxvk {
|
||||
D3D11Texture2D::D3D11Texture2D(
|
||||
D3D11Device* pDevice,
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc,
|
||||
VkImage vkImage)
|
||||
DXGI_USAGE DxgiUsage,
|
||||
VkImage vkImage)
|
||||
: D3D11DeviceChild<ID3D11Texture2D1>(pDevice),
|
||||
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, vkImage),
|
||||
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, DxgiUsage, vkImage),
|
||||
m_interop (this, &m_texture),
|
||||
m_surface (this, &m_texture),
|
||||
m_resource(this),
|
||||
@ -1003,7 +1005,7 @@ namespace dxvk {
|
||||
D3D11Device* pDevice,
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc)
|
||||
: D3D11DeviceChild<ID3D11Texture3D1>(pDevice),
|
||||
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE3D, VK_NULL_HANDLE),
|
||||
m_texture (pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE3D, 0, VK_NULL_HANDLE),
|
||||
m_interop (this, &m_texture),
|
||||
m_resource(this),
|
||||
m_d3d10 (this) {
|
||||
|
@ -63,6 +63,7 @@ namespace dxvk {
|
||||
D3D11Device* pDevice,
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D11_RESOURCE_DIMENSION Dimension,
|
||||
DXGI_USAGE DxgiUsage,
|
||||
VkImage vkImage);
|
||||
|
||||
~D3D11CommonTexture();
|
||||
@ -78,6 +79,17 @@ namespace dxvk {
|
||||
return &m_desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Special DXGI usage flags
|
||||
*
|
||||
* Flags that are set in addition to the bind
|
||||
* flags. Zero for application-created textures.
|
||||
* \returns DXGI usage flags
|
||||
*/
|
||||
DXGI_USAGE GetDxgiUsage() const {
|
||||
return m_dxgiUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Counts number of subresources
|
||||
* \returns Number of subresources
|
||||
@ -205,6 +217,7 @@ namespace dxvk {
|
||||
D3D11Device* const m_device;
|
||||
D3D11_COMMON_TEXTURE_DESC m_desc;
|
||||
D3D11_COMMON_TEXTURE_MAP_MODE m_mapMode;
|
||||
DXGI_USAGE m_dxgiUsage;
|
||||
|
||||
Rc<DxvkImage> m_image;
|
||||
std::vector<Rc<DxvkBuffer>> m_buffers;
|
||||
@ -417,6 +430,7 @@ namespace dxvk {
|
||||
D3D11Texture2D(
|
||||
D3D11Device* pDevice,
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc,
|
||||
DXGI_USAGE DxgiUsage,
|
||||
VkImage vkImage);
|
||||
|
||||
~D3D11Texture2D();
|
||||
|
Loading…
x
Reference in New Issue
Block a user