Renderer/Texture: Allow to keep the texture format in TextureViewInfo
This commit is contained in:
parent
00935efbe0
commit
962a2e71c7
|
|
@ -36,7 +36,7 @@ namespace Nz
|
||||||
struct TextureViewInfo
|
struct TextureViewInfo
|
||||||
{
|
{
|
||||||
ImageType viewType;
|
ImageType viewType;
|
||||||
PixelFormat reinterpretFormat;
|
PixelFormat reinterpretFormat = PixelFormat::Undefined;
|
||||||
UInt8 baseMipLevel = 0;
|
UInt8 baseMipLevel = 0;
|
||||||
UInt8 levelCount = 1;
|
UInt8 levelCount = 1;
|
||||||
unsigned int baseArrayLayer = 0;
|
unsigned int baseArrayLayer = 0;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Nz
|
||||||
inline TextureInfo Texture::ApplyView(TextureInfo textureInfo, const TextureViewInfo& viewInfo)
|
inline TextureInfo Texture::ApplyView(TextureInfo textureInfo, const TextureViewInfo& viewInfo)
|
||||||
{
|
{
|
||||||
textureInfo.type = viewInfo.viewType;
|
textureInfo.type = viewInfo.viewType;
|
||||||
textureInfo.pixelFormat = viewInfo.reinterpretFormat;
|
textureInfo.pixelFormat = (viewInfo.reinterpretFormat != PixelFormat::Undefined) ? viewInfo.reinterpretFormat : textureInfo.pixelFormat;
|
||||||
textureInfo.width = GetLevelSize(textureInfo.width, viewInfo.baseMipLevel);
|
textureInfo.width = GetLevelSize(textureInfo.width, viewInfo.baseMipLevel);
|
||||||
textureInfo.height = GetLevelSize(textureInfo.height, viewInfo.baseMipLevel);
|
textureInfo.height = GetLevelSize(textureInfo.height, viewInfo.baseMipLevel);
|
||||||
textureInfo.depth = GetLevelSize(textureInfo.depth, viewInfo.baseMipLevel);
|
textureInfo.depth = GetLevelSize(textureInfo.depth, viewInfo.baseMipLevel);
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (m_texture.Create(*m_parentTexture->m_texture.GetDevice()))
|
if (m_texture.Create(*m_parentTexture->m_texture.GetDevice()))
|
||||||
{
|
{
|
||||||
auto format = DescribeTextureFormat(viewInfo.reinterpretFormat);
|
auto format = DescribeTextureFormat(m_textureInfo.pixelFormat);
|
||||||
|
|
||||||
context.ClearErrorStack();
|
context.ClearErrorStack();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ namespace Nz
|
||||||
|
|
||||||
m_viewInfo = viewInfo;
|
m_viewInfo = viewInfo;
|
||||||
m_subresourceRange = {
|
m_subresourceRange = {
|
||||||
ToVulkan(PixelFormatInfo::GetContent(viewInfo.reinterpretFormat)),
|
ToVulkan(PixelFormatInfo::GetContent(m_textureViewInfo.pixelFormat)),
|
||||||
viewInfo.baseMipLevel,
|
viewInfo.baseMipLevel,
|
||||||
viewInfo.levelCount,
|
viewInfo.levelCount,
|
||||||
viewInfo.baseArrayLayer,
|
viewInfo.baseArrayLayer,
|
||||||
|
|
@ -290,7 +290,7 @@ namespace Nz
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitViewForFormat(viewInfo.reinterpretFormat, createInfoView);
|
InitViewForFormat(m_textureViewInfo.pixelFormat, createInfoView);
|
||||||
|
|
||||||
if (!m_imageView.Create(m_device, createInfoView))
|
if (!m_imageView.Create(m_device, createInfoView))
|
||||||
throw std::runtime_error("Failed to create image view: " + TranslateVulkanError(m_imageView.GetLastErrorCode()));
|
throw std::runtime_error("Failed to create image view: " + TranslateVulkanError(m_imageView.GetLastErrorCode()));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue