Skip to content

Commit 1bb5b3e

Browse files
Use FmtAttribs.GetElementSize() instead of manual element size calculation
1 parent 3665fff commit 1bb5b3e

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

Graphics/GraphicsTools/src/GPUUploadManagerImpl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,7 @@ bool GPUUploadManagerImpl::Page::ScheduleTextureUpdate(const ScheduleTextureUpda
423423
SrcX = Region.x;
424424
SrcY = Region.y;
425425

426-
const Uint32 ElementSize = FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED ?
427-
FmtAttribs.ComponentSize :
428-
FmtAttribs.ComponentSize * FmtAttribs.NumComponents;
426+
const Uint32 ElementSize = FmtAttribs.GetElementSize();
429427

430428
DstRowStride = m_pStagingAtlas->RowStride;
431429
DstDepthStride = m_pStagingAtlas->DepthStride;

Tests/DiligentCoreAPITest/src/GPUUploadManagerTest.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,7 @@ void TestTextureUpdates(TEXTURE_FORMAT Format, RESOURCE_DIMENSION Type, Uint32 F
796796

797797
const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
798798

799-
const Uint32 ElementSize = FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED ?
800-
FmtAttribs.ComponentSize :
801-
FmtAttribs.ComponentSize * FmtAttribs.NumComponents;
799+
const Uint32 ElementSize = FmtAttribs.GetElementSize();
802800

803801
for (Uint32 MipLevel = 0; MipLevel < TexDesc.MipLevels; ++MipLevel)
804802
{

Tests/DiligentCoreAPITest/src/UpdateTextureFromBufferTest.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ void RunCopyBufferToTextureTest(const TextureDesc& BaseTexDesc)
150150

151151
const TextureFormatAttribs& FmtAttribs = pDevice->GetTextureFormatInfo(BaseTexDesc.Format);
152152

153-
const Uint32 ElementSize = FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED ?
154-
FmtAttribs.ComponentSize :
155-
FmtAttribs.ComponentSize * FmtAttribs.NumComponents;
153+
const Uint32 ElementSize = FmtAttribs.GetElementSize();
156154

157155
ForEachSubresource(BaseTexDesc, [&](Uint32 mip, Uint32 slice, const MipLevelProperties& Mip) {
158156
auto& Subres = RefSubresources[GetSubresourceIndex(mip, slice)];

0 commit comments

Comments
 (0)