ae28d55f81
Source: RGB-D -> Dyn-HaMR -> L20 retargeting -> FoundationPose -> reference repair -> SPIDER, documented in docs/PIPELINE_LATEST.md and docs/SETUP_AND_WEIGHTS.md. Adds FoundationPose and nvdiffrast upstream snapshots, requirements/pipeline_venv.txt and the FoundationPose weight manifest/downloader. Assets (Git LFS): weights/ (WiLoR detector, HandFlow denoiser, UniDepth-L), FoundationPose checkpoints, HaMeR checkpoint, Dyn-HaMR HMP model and BMC constraints, L20 URDF/meshes, the 20260915_171525 D405 recording and the two box CADs. MANO models are not redistributed (third_party/hamer/_DATA/data/mano/README.txt). Environments, caches and run outputs excluded. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
105 lines
3.0 KiB
C++
105 lines
3.0 KiB
C++
// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
|
//
|
|
// NVIDIA CORPORATION and its licensors retain all intellectual property
|
|
// and proprietary rights in and to this software, related documentation
|
|
// and any modifications thereto. Any use, reproduction, disclosure or
|
|
// distribution of this software and related documentation without an express
|
|
// license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
|
|
#include "framework.h"
|
|
#include "texture.h"
|
|
|
|
//------------------------------------------------------------------------
|
|
// Mip stack construction and access helpers.
|
|
|
|
void raiseMipSizeError(const TextureKernelParams& p)
|
|
{
|
|
char buf[1024];
|
|
int bufsz = 1024;
|
|
|
|
std::string msg = "Mip-map size error - cannot downsample an odd extent greater than 1. Resize the texture so that both spatial extents are powers of two, or limit the number of mip maps using max_mip_level argument.\n";
|
|
|
|
int w = p.texWidth;
|
|
int h = p.texHeight;
|
|
bool ew = false;
|
|
bool eh = false;
|
|
|
|
msg += "Attempted mip stack construction:\n";
|
|
msg += "level width height\n";
|
|
msg += "----- ----- ------\n";
|
|
snprintf(buf, bufsz, "base %5d %5d\n", w, h);
|
|
msg += buf;
|
|
|
|
int mipTotal = 0;
|
|
int level = 0;
|
|
while ((w|h) > 1 && !(ew || eh)) // Stop at first impossible size.
|
|
{
|
|
// Current level.
|
|
level += 1;
|
|
|
|
// Determine if downsampling fails.
|
|
ew = ew || (w > 1 && (w & 1));
|
|
eh = eh || (h > 1 && (h & 1));
|
|
|
|
// Downsample.
|
|
if (w > 1) w >>= 1;
|
|
if (h > 1) h >>= 1;
|
|
|
|
// Append level size to error message.
|
|
snprintf(buf, bufsz, "mip %-2d ", level);
|
|
msg += buf;
|
|
if (ew) snprintf(buf, bufsz, " err ");
|
|
else snprintf(buf, bufsz, "%5d ", w);
|
|
msg += buf;
|
|
if (eh) snprintf(buf, bufsz, " err\n");
|
|
else snprintf(buf, bufsz, "%5d\n", h);
|
|
msg += buf;
|
|
}
|
|
|
|
NVDR_CHECK(0, msg);
|
|
}
|
|
|
|
int calculateMipInfo(TextureKernelParams& p, int* mipOffsets)
|
|
{
|
|
// No levels at all?
|
|
if (p.mipLevelLimit == 0)
|
|
{
|
|
p.mipLevelMax = 0;
|
|
return 0;
|
|
}
|
|
|
|
// Current level size.
|
|
int w = p.texWidth;
|
|
int h = p.texHeight;
|
|
|
|
int mipTotal = 0;
|
|
int level = 0;
|
|
int c = (p.boundaryMode == TEX_BOUNDARY_MODE_CUBE) ? (p.channels * 6) : p.channels;
|
|
mipOffsets[0] = 0;
|
|
while ((w|h) > 1)
|
|
{
|
|
// Current level.
|
|
level += 1;
|
|
|
|
// Quit if cannot downsample.
|
|
if ((w > 1 && (w & 1)) || (h > 1 && (h & 1)))
|
|
raiseMipSizeError(p);
|
|
|
|
// Downsample.
|
|
if (w > 1) w >>= 1;
|
|
if (h > 1) h >>= 1;
|
|
|
|
mipOffsets[level] = mipTotal; // Store the mip offset (#floats).
|
|
mipTotal += w * h * p.texDepth * c;
|
|
|
|
// Hit the level limit?
|
|
if (p.mipLevelLimit >= 0 && level == p.mipLevelLimit)
|
|
break;
|
|
}
|
|
|
|
p.mipLevelMax = level;
|
|
return mipTotal;
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|