MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / FillTextureInfoOffsets

Function FillTextureInfoOffsets

src/engine/DDSFile.cpp:522–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

520 }
521
522 static size_t FillTextureInfoOffsets(TextureData& textureInfo, size_t dataSize, ptrdiff_t dataOffset)
523 {
524 textureInfo.originalBitsPerPixel = BitsPerPixel(textureInfo.format);
525
526 textureInfo.dataLayout.resize(textureInfo.arraySize);
527 for (uint32_t arraySlice = 0; arraySlice < textureInfo.arraySize; arraySlice++)
528 {
529 size_t w = textureInfo.width;
530 size_t h = textureInfo.height;
531 size_t d = textureInfo.depth;
532
533 std::vector<TextureSubresourceData>& sliceData = textureInfo.dataLayout[arraySlice];
534 sliceData.resize(textureInfo.mipLevels);
535
536 for (uint32_t mipLevel = 0; mipLevel < textureInfo.mipLevels; mipLevel++)
537 {
538 size_t NumBytes = 0;
539 size_t RowBytes = 0;
540 size_t NumRows = 0;
541 GetSurfaceInfo(w, h, textureInfo.format, textureInfo.originalBitsPerPixel, &NumBytes, &RowBytes, &NumRows);
542
543 TextureSubresourceData& levelData = sliceData[mipLevel];
544 levelData.dataOffset = dataOffset;
545 levelData.dataSize = NumBytes;
546 levelData.rowPitch = RowBytes;
547 levelData.depthPitch = RowBytes * NumRows;
548
549 dataOffset += NumBytes * d;
550
551 if (dataSize > 0 && dataOffset > static_cast<ptrdiff_t>(dataSize))
552 return 0;
553
554 w = w >> 1;
555 h = h >> 1;
556 d = d >> 1;
557
558 if (w == 0) w = 1;
559 if (h == 0) h = 1;
560 if (d == 0) d = 1;
561 }
562 }
563
564 return dataOffset;
565 }
566
567 bool LoadDDSTextureFromMemory(TextureData& textureInfo)
568 {

Callers 2

LoadDDSTextureFromMemoryFunction · 0.85
SaveStagingTextureAsDDSFunction · 0.85

Calls 2

BitsPerPixelFunction · 0.85
GetSurfaceInfoFunction · 0.85

Tested by

no test coverage detected