mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-21 21:57:39 +01:00
[d3d11] Implement tiled image creation
This commit is contained in:
parent
0637fdf82e
commit
0cd67cb98a
@ -128,7 +128,8 @@ namespace dxvk {
|
||||
desc.MiscFlags = pDesc->MiscFlags;
|
||||
desc.TextureLayout = D3D11_TEXTURE_LAYOUT_UNDEFINED;
|
||||
|
||||
HRESULT hr = D3D11CommonTexture::NormalizeTextureProperties(&desc);
|
||||
HRESULT hr = D3D11CommonTexture::NormalizeTextureProperties(&desc,
|
||||
D3D11_TILED_RESOURCES_NOT_SUPPORTED);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
@ -204,7 +205,7 @@ namespace dxvk {
|
||||
desc.MiscFlags = pDesc->MiscFlags;
|
||||
desc.TextureLayout = pDesc->TextureLayout;
|
||||
|
||||
HRESULT hr = D3D11CommonTexture::NormalizeTextureProperties(&desc);
|
||||
HRESULT hr = D3D11CommonTexture::NormalizeTextureProperties(&desc, m_tiledResourcesTier);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
@ -279,11 +280,15 @@ namespace dxvk {
|
||||
desc.MiscFlags = pDesc->MiscFlags;
|
||||
desc.TextureLayout = pDesc->TextureLayout;
|
||||
|
||||
HRESULT hr = D3D11CommonTexture::NormalizeTextureProperties(&desc);
|
||||
HRESULT hr = D3D11CommonTexture::NormalizeTextureProperties(&desc, m_tiledResourcesTier);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
|
||||
if ((desc.MiscFlags & D3D11_RESOURCE_MISC_TILED)
|
||||
&& (m_tiledResourcesTier < D3D11_TILED_RESOURCES_TIER_3))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (!ppTexture3D)
|
||||
return S_FALSE;
|
||||
|
||||
|
@ -43,9 +43,12 @@ namespace dxvk {
|
||||
void D3D11Initializer::InitTexture(
|
||||
D3D11CommonTexture* pTexture,
|
||||
const D3D11_SUBRESOURCE_DATA* pInitialData) {
|
||||
(pTexture->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT)
|
||||
? InitHostVisibleTexture(pTexture, pInitialData)
|
||||
: InitDeviceLocalTexture(pTexture, pInitialData);
|
||||
if (pTexture->Desc()->MiscFlags & D3D11_RESOURCE_MISC_TILED)
|
||||
InitTiledTexture(pTexture);
|
||||
else if (pTexture->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT)
|
||||
InitHostVisibleTexture(pTexture, pInitialData);
|
||||
else
|
||||
InitDeviceLocalTexture(pTexture, pInitialData);
|
||||
}
|
||||
|
||||
|
||||
@ -255,6 +258,15 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void D3D11Initializer::InitTiledTexture(
|
||||
D3D11CommonTexture* pTexture) {
|
||||
m_context->initSparseImage(pTexture->GetImage());
|
||||
|
||||
m_transferCommands += 1;
|
||||
FlushImplicit();
|
||||
}
|
||||
|
||||
|
||||
void D3D11Initializer::FlushImplicit() {
|
||||
if (m_transferCommands > MaxTransferCommands
|
||||
|| m_transferMemory > MaxTransferMemory)
|
||||
|
@ -64,7 +64,10 @@ namespace dxvk {
|
||||
void InitHostVisibleTexture(
|
||||
D3D11CommonTexture* pTexture,
|
||||
const D3D11_SUBRESOURCE_DATA* pInitialData);
|
||||
|
||||
|
||||
void InitTiledTexture(
|
||||
D3D11CommonTexture* pTexture);
|
||||
|
||||
void FlushImplicit();
|
||||
void FlushInternal();
|
||||
|
||||
|
@ -146,7 +146,8 @@ namespace dxvk {
|
||||
desc.MiscFlags = pDesc->MiscFlags;
|
||||
desc.TextureLayout = pDesc->TextureLayout;
|
||||
|
||||
HRESULT hr = D3D11CommonTexture::NormalizeTextureProperties(&desc);
|
||||
HRESULT hr = D3D11CommonTexture::NormalizeTextureProperties(&desc,
|
||||
D3D11_TILED_RESOURCES_NOT_SUPPORTED);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
@ -136,10 +136,16 @@ namespace dxvk {
|
||||
if (m_desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE)
|
||||
imageInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
|
||||
|
||||
if (m_desc.MiscFlags & D3D11_RESOURCE_MISC_TILED) {
|
||||
imageInfo.flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT
|
||||
| VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT
|
||||
| VK_IMAGE_CREATE_SPARSE_ALIASED_BIT;
|
||||
}
|
||||
|
||||
if (Dimension == D3D11_RESOURCE_DIMENSION_TEXTURE3D &&
|
||||
(m_desc.BindFlags & D3D11_BIND_RENDER_TARGET))
|
||||
imageInfo.flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT;
|
||||
|
||||
|
||||
// Swap chain back buffers need to be shader readable
|
||||
if (DxgiUsage & DXGI_USAGE_BACK_BUFFER) {
|
||||
imageInfo.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
@ -396,7 +402,7 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
HRESULT D3D11CommonTexture::NormalizeTextureProperties(D3D11_COMMON_TEXTURE_DESC* pDesc) {
|
||||
HRESULT D3D11CommonTexture::NormalizeTextureProperties(D3D11_COMMON_TEXTURE_DESC* pDesc, D3D11_TILED_RESOURCES_TIER TiledTier) {
|
||||
if (pDesc->Width == 0 || pDesc->Height == 0 || pDesc->Depth == 0 || pDesc->ArraySize == 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
@ -415,10 +421,24 @@ namespace dxvk {
|
||||
!= (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET))
|
||||
return E_INVALIDARG;
|
||||
|
||||
// TILE_POOL is invalid, but we don't support TILED either
|
||||
if (pDesc->MiscFlags & (D3D11_RESOURCE_MISC_TILE_POOL | D3D11_RESOURCE_MISC_TILED))
|
||||
// TILE_POOL is invalid for textures
|
||||
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL)
|
||||
return E_INVALIDARG;
|
||||
|
||||
// Perform basic validation for tiled resources
|
||||
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILED) {
|
||||
UINT invalidFlags = D3D11_RESOURCE_MISC_SHARED
|
||||
| D3D11_RESOURCE_MISC_SHARED_NTHANDLE
|
||||
| D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
|
||||
| D3D11_RESOURCE_MISC_GDI_COMPATIBLE;
|
||||
|
||||
if ((pDesc->MiscFlags & invalidFlags)
|
||||
|| (pDesc->Usage != D3D11_USAGE_DEFAULT)
|
||||
|| (pDesc->CPUAccessFlags)
|
||||
|| (!TiledTier))
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
// Use the maximum possible mip level count if the supplied
|
||||
// mip level count is either unspecified (0) or invalid
|
||||
const uint32_t maxMipLevelCount = (pDesc->SampleDesc.Count <= 1)
|
||||
|
@ -367,10 +367,12 @@ namespace dxvk {
|
||||
* parameters. Any error returned by this method should
|
||||
* be forwarded to the application.
|
||||
* \param [in,out] pDesc Texture description
|
||||
* \param [in] TiledTier Tiled resources tier
|
||||
* \returns \c S_OK if the parameters are valid
|
||||
*/
|
||||
static HRESULT NormalizeTextureProperties(
|
||||
D3D11_COMMON_TEXTURE_DESC* pDesc);
|
||||
D3D11_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D11_TILED_RESOURCES_TIER TiledTier);
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user