From de357f5cc08b3bff0cadd7c67a8dc8bd622e45c3 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 15 Sep 2020 14:15:48 -0700 Subject: Fixed validation of Texture1D/Texture1DArray parameters for compressed formats --- Graphics/GraphicsEngine/src/TextureBase.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/src/TextureBase.cpp b/Graphics/GraphicsEngine/src/TextureBase.cpp index c4e5e999..93050ff1 100644 --- a/Graphics/GraphicsEngine/src/TextureBase.cpp +++ b/Graphics/GraphicsEngine/src/TextureBase.cpp @@ -36,6 +36,8 @@ void ValidateTextureDesc(const TextureDesc& Desc) { #define LOG_TEXTURE_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Texture '", (Desc.Name ? Desc.Name : ""), "': ", ##__VA_ARGS__) + const auto& FmtAttribs = GetTextureFormatAttribs(Desc.Format); + if (Desc.Type == RESOURCE_DIM_UNDEFINED) { LOG_TEXTURE_ERROR_AND_THROW("Resource dimension is undefined"); @@ -54,8 +56,19 @@ void ValidateTextureDesc(const TextureDesc& Desc) // Perform some parameter correctness check if (Desc.Type == RESOURCE_DIM_TEX_1D || Desc.Type == RESOURCE_DIM_TEX_1D_ARRAY) { - if (Desc.Height != 1) - LOG_TEXTURE_ERROR_AND_THROW("Height (", Desc.Height, ") of Texture 1D/Texture 1D Array must be 1"); + if (Desc.Height != FmtAttribs.BlockHeight) + { + if (FmtAttribs.BlockHeight == 1) + { + LOG_TEXTURE_ERROR_AND_THROW("Height (", Desc.Height, ") of a Texture 1D/Texture 1D Array must be 1"); + } + else + { + LOG_TEXTURE_ERROR_AND_THROW("For block-compressed formats, the height (", Desc.Height, + ") of a Texture 1D/Texture 1D Array must be equal to the compressed block height (", + Uint32{FmtAttribs.BlockHeight}, ")"); + } + } } else { -- cgit v1.2.3