MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / updateTextureSubresources

Method updateTextureSubresources

Source/Falcor/Core/API/CopyContext.cpp:277–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277void CopyContext::updateTextureSubresources(
278 const Texture* pTexture,
279 uint32_t firstSubresource,
280 uint32_t subresourceCount,
281 const void* pData,
282 const uint3& offset,
283 const uint3& size
284)
285{
286 resourceBarrier(pTexture, Resource::State::CopyDest);
287
288 bool copyRegion = any(offset != uint3(0)) || any(size != uint3(-1));
289 FALCOR_ASSERT(subresourceCount == 1 || (copyRegion == false));
290 uint8_t* dataPtr = (uint8_t*)pData;
291 auto resourceEncoder = getLowLevelData()->getResourceCommandEncoder();
292 gfx::ITextureResource::Offset3D gfxOffset = {
293 static_cast<gfx::GfxIndex>(offset.x), static_cast<gfx::GfxIndex>(offset.y), static_cast<gfx::GfxIndex>(offset.z)};
294 gfx::ITextureResource::Extents gfxSize = {
295 static_cast<gfx::GfxCount>(size.x), static_cast<gfx::GfxCount>(size.y), static_cast<gfx::GfxCount>(size.z)};
296 gfx::FormatInfo formatInfo = {};
297 gfx::gfxGetFormatInfo(getGFXFormat(pTexture->getFormat()), &formatInfo);
298 for (uint32_t index = firstSubresource; index < firstSubresource + subresourceCount; index++)
299 {
300 gfx::SubresourceRange subresourceRange = {};
301 subresourceRange.baseArrayLayer = static_cast<gfx::GfxIndex>(pTexture->getSubresourceArraySlice(index));
302 subresourceRange.mipLevel = static_cast<gfx::GfxIndex>(pTexture->getSubresourceMipLevel(index));
303 subresourceRange.layerCount = 1;
304 subresourceRange.mipLevelCount = 1;
305 if (!copyRegion)
306 {
307 gfxSize.width = align_to(formatInfo.blockWidth, static_cast<gfx::GfxCount>(pTexture->getWidth(subresourceRange.mipLevel)));
308 gfxSize.height = align_to(formatInfo.blockHeight, static_cast<gfx::GfxCount>(pTexture->getHeight(subresourceRange.mipLevel)));
309 gfxSize.depth = static_cast<gfx::GfxCount>(pTexture->getDepth(subresourceRange.mipLevel));
310 }
311 gfx::ITextureResource::SubresourceData data = {};
312 data.data = dataPtr;
313 data.strideY = static_cast<int64_t>(gfxSize.width) / formatInfo.blockWidth * formatInfo.blockSizeInBytes;
314 data.strideZ = data.strideY * (gfxSize.height / formatInfo.blockHeight);
315 dataPtr += data.strideZ * gfxSize.depth;
316 resourceEncoder->uploadTextureData(pTexture->getGfxTextureResource(), subresourceRange, gfxOffset, gfxSize, &data, 1);
317 }
318}
319
320CopyContext::ReadTextureTask::SharedPtr CopyContext::ReadTextureTask::create(
321 CopyContext* pCtx,

Callers

nothing calls this directly

Calls 8

getLowLevelDataFunction · 0.85
getGFXFormatFunction · 0.85
align_toFunction · 0.85
getFormatMethod · 0.80
getWidthMethod · 0.80
getHeightMethod · 0.80
anyFunction · 0.50

Tested by

no test coverage detected