MCPcopy Create free account
hub / github.com/baldurk/renderdoc / SaveTexture

Method SaveTexture

renderdoc/replay/replay_controller.cpp:588–1446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586}
587
588ResultDetails ReplayController::SaveTexture(const TextureSave &saveData, const rdcstr &path)
589{
590 CHECK_REPLAY_THREAD();
591 RENDERDOC_PROFILEFUNCTION();
592
593 TextureSave sd = saveData; // mutable copy
594
595 if(sd.resourceId == ResourceId())
596 {
597 RETURN_ERROR_RESULT(ResultCode::InvalidParameter, "Invalid ID for %s getting texture data",
598 ToStr(sd.resourceId).c_str());
599 }
600
601 TextureDescription td = m_pDevice->GetTexture(sd.resourceId);
602
603 // clamp sample/mip/slice indices
604 if(td.msSamp == 1)
605 {
606 sd.sample.sampleIndex = 0;
607 sd.sample.mapToArray = false;
608 }
609 else
610 {
611 if(sd.sample.sampleIndex != ~0U)
612 sd.sample.sampleIndex = RDCCLAMP((uint32_t)sd.sample.sampleIndex, 0U, td.msSamp);
613 }
614
615 // don't support cube cruciform for non cubemaps, or
616 // cubemap arrays
617 if(!td.cubemap || td.arraysize != 6 || td.msSamp != 1)
618 sd.slice.cubeCruciform = false;
619
620 if(sd.mip != -1)
621 sd.mip = RDCCLAMP(sd.mip, 0, (int32_t)td.mips);
622 if(sd.slice.sliceIndex != -1)
623 sd.slice.sliceIndex = RDCCLAMP(sd.slice.sliceIndex, 0, int32_t(td.arraysize * td.depth));
624
625 if(td.arraysize * td.depth * td.msSamp == 1)
626 {
627 sd.slice.sliceIndex = 0;
628 sd.slice.slicesAsGrid = false;
629 }
630
631 // can't extract a channel that's not in the source texture
632 if(sd.channelExtract >= 0 && (uint32_t)sd.channelExtract >= td.format.compCount)
633 sd.channelExtract = -1;
634
635 sd.slice.sliceGridWidth = RDCMAX(sd.slice.sliceGridWidth, 1);
636
637 // store sample count so we know how many 'slices' is one real slice
638 // multisampled textures cannot have mips, subresource layout is same as would be for mips:
639 // [slice0 sample0], [slice0 sample1], [slice1 sample0], [slice1 sample1]
640 uint32_t sampleCount = RDCMAX(td.msSamp, 1U);
641 bool multisampled = td.msSamp > 1;
642
643 if(sd.sample.mapToArray)
644 sd.sample.sampleIndex = 0;
645

Callers 14

on_saveTex_clickedMethod · 0.80
sampleCodeFunction · 0.80
check_pixel_valueMethod · 0.80
check_captureMethod · 0.80
check_testMethod · 0.80
save_textureMethod · 0.80
check_captureMethod · 0.80
check_captureMethod · 0.80
check_captureMethod · 0.80
check_captureMethod · 0.80
check_captureMethod · 0.80

Calls 15

ToStrFunction · 0.85
RDCCLAMPFunction · 0.85
RDCMAXFunction · 0.85
write_dds_to_fileFunction · 0.85
stbi_write_bmp_to_funcFunction · 0.85
stbi_write_png_to_funcFunction · 0.85
stbi_write_tga_to_funcFunction · 0.85
stbi_write_hdr_to_funcFunction · 0.85
InitEXRHeaderFunction · 0.85
InitEXRImageFunction · 0.85

Tested by 4

check_pixel_valueMethod · 0.64
check_captureMethod · 0.64
save_textureMethod · 0.64