summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-03-19 14:55:44 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-03-19 14:55:44 +0000
commit9017ec06faef8ba9daaf616da397c98f3e3fd83f (patch)
treeb1e764e659b8a0381330f83ac241fe5c89340753 /Graphics
parentFixed issue with staging allocations in Vulkan backend on Integrated GPUs (diff)
downloadDiligentCore-9017ec06faef8ba9daaf616da397c98f3e3fd83f.tar.gz
DiligentCore-9017ec06faef8ba9daaf616da397c98f3e3fd83f.zip
Added error message when attempting to create typeless texture with GENERAT_MIPS flag in D3D12 and Vk backends (fixed https://github.com/DiligentGraphics/DiligentCore/issues/70)
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp5
-rw-r--r--Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp8
-rw-r--r--Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp11
3 files changed, 16 insertions, 8 deletions
diff --git a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp
index 48c82c4b..48e33434 100644
--- a/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/TextureBaseD3D11.cpp
@@ -39,8 +39,9 @@ TextureBaseD3D11 :: TextureBaseD3D11(IReferenceCounters* pRefCounters,
const TextureData* pInitData /*= nullptr*/) :
TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D11, TexDesc)
{
- if( TexDesc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr))
- LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time");
+ if (m_Desc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr))
+ LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time: pInitData can't be null");
+
SetState(RESOURCE_STATE_UNDEFINED);
}
diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
index 736189f5..84fccc67 100644
--- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp
@@ -78,8 +78,12 @@ TextureD3D12Impl :: TextureD3D12Impl(IReferenceCounters* pRefCounters,
const TextureData* pInitData /*= nullptr*/) :
TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D12, TexDesc)
{
- if( m_Desc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr))
- LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time");
+ if (m_Desc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr))
+ LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time: pInitData can't be null");
+
+ const auto& FmtAttribs = GetTextureFormatAttribs(m_Desc.Format);
+ if ((m_Desc.MiscFlags & MISC_TEXTURE_FLAG_GENERATE_MIPS) != 0 && FmtAttribs.IsTypeless)
+ LOG_ERROR_AND_THROW("Textures created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag can't use typeless formats. The following format was provided: ", FmtAttribs.Name, " when attempting to create texture '", m_Desc.Name, "'");
D3D12_RESOURCE_DESC Desc = {};
Desc.Alignment = 0;
diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
index 9838966e..1c77c4b3 100644
--- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
@@ -43,9 +43,13 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters,
const TextureData* pInitData /*= nullptr*/) :
TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceVk, TexDesc)
{
- if( m_Desc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr) )
- LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time");
-
+ if (m_Desc.Usage == USAGE_STATIC && (pInitData == nullptr || pInitData->pSubResources == nullptr))
+ LOG_ERROR_AND_THROW("Static textures must be initialized with data at creation time: pInitData can't be null");
+
+ const auto& FmtAttribs = GetTextureFormatAttribs(m_Desc.Format);
+ if ((m_Desc.MiscFlags & MISC_TEXTURE_FLAG_GENERATE_MIPS) != 0 && FmtAttribs.IsTypeless)
+ LOG_ERROR_AND_THROW("Textures created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag can't use typeless formats. The following format was provided: ", FmtAttribs.Name, " when attempting to create texture '", m_Desc.Name, "'");
+
const auto& LogicalDevice = pRenderDeviceVk->GetLogicalDevice();
VkImageCreateInfo ImageCI = {};
@@ -54,7 +58,6 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters,
ImageCI.flags = 0;
if(m_Desc.Type == RESOURCE_DIM_TEX_CUBE || m_Desc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
ImageCI.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
- const auto &FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
if(FmtAttribs.IsTypeless)
ImageCI.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; // Specifies that the image can be used to create a
// VkImageView with a different format from the image.