@@ -232,8 +232,13 @@ enum class ELensMode : int {
232232 FTheta,
233233 LatLong,
234234 OpenCVFisheye,
235+ Equirectangular,
235236};
236- static constexpr const char * LensModeStr = " Perspective\0 OpenCV\0 F-Theta\0 LatLong\0 OpenCV Fisheye\0\0 " ;
237+ static constexpr const char * LensModeStr = " Perspective\0 OpenCV\0 F-Theta\0 LatLong\0 OpenCV Fisheye\0 Equirectangular\0\0 " ;
238+
239+ inline bool supports_dlss (ELensMode mode) {
240+ return mode == ELensMode::Perspective || mode == ELensMode::OpenCV || mode == ELensMode::OpenCVFisheye;
241+ }
237242
238243struct Lens {
239244 ELensMode mode = ELensMode::Perspective;
@@ -343,6 +348,47 @@ class Ema {
343348 std::chrono::time_point<std::chrono::steady_clock> m_creation_time;
344349};
345350
351+ template <typename T>
352+ struct Buffer2DView {
353+ T* data = nullptr ;
354+ Eigen::Vector2i resolution = Eigen::Vector2i::Zero();
355+
356+ // Lookup via integer pixel position (no bounds checking)
357+ NGP_HOST_DEVICE T at (const Eigen::Vector2i& xy) const {
358+ return data[xy.x () + xy.y () * resolution.x ()];
359+ }
360+
361+ // Lookup via UV coordinates in [0,1]^2
362+ NGP_HOST_DEVICE T at (const Eigen::Vector2f& uv) const {
363+ Eigen::Vector2i xy = resolution.cast <float >().cwiseProduct (uv).cast <int >().cwiseMax (0 ).cwiseMin (resolution - Eigen::Vector2i::Ones ());
364+ return at (xy);
365+ }
366+
367+ // Lookup via UV coordinates in [0,1]^2 and LERP the nearest texels
368+ NGP_HOST_DEVICE T at_lerp (const Eigen::Vector2f& uv) const {
369+ const Eigen::Vector2f xy_float = resolution.cast <float >().cwiseProduct (uv);
370+ const Eigen::Vector2i xy = xy_float.cast <int >();
371+
372+ const Eigen::Vector2f weight = xy_float - xy.cast <float >();
373+
374+ auto read_val = [&](Eigen::Vector2i pos) {
375+ pos = pos.cwiseMax (0 ).cwiseMin (resolution - Eigen::Vector2i::Ones ());
376+ return at (pos);
377+ };
378+
379+ return (
380+ (1 - weight.x ()) * (1 - weight.y ()) * read_val ({xy.x (), xy.y ()}) +
381+ (weight.x ()) * (1 - weight.y ()) * read_val ({xy.x ()+1 , xy.y ()}) +
382+ (1 - weight.x ()) * (weight.y ()) * read_val ({xy.x (), xy.y ()+1 }) +
383+ (weight.x ()) * (weight.y ()) * read_val ({xy.x ()+1 , xy.y ()+1 })
384+ );
385+ }
386+
387+ NGP_HOST_DEVICE operator bool () const {
388+ return data;
389+ }
390+ };
391+
346392uint8_t * load_stbi (const fs::path& path, int * width, int * height, int * comp, int req_comp);
347393float * load_stbi_float (const fs::path& path, int * width, int * height, int * comp, int req_comp);
348394uint16_t * load_stbi_16 (const fs::path& path, int * width, int * height, int * comp, int req_comp);
0 commit comments