1.3.64
 
Loading...
Searching...
No Matches
PixelCoordinate Struct Reference

Camera pixel coordinate abstraction for tiled rendering. More...

#include <BufferIndexing.h>

Public Member Functions

HELIOS_HOST_DEVICE PixelCoordinate (uint x_coord, uint y_coord)
 Construct pixel coordinate from global x, y.
 
size_t toFlatIndex (const helios::int2 &full_resolution) const
 Convert to flat array index (row-major)
 

Data Fields

uint x
 Global x-coordinate (column index)
 
uint y
 Global y-coordinate (row index)
 

Detailed Description

Camera pixel coordinate abstraction for tiled rendering.

Encapsulates the tile offset + coordinate mapping + flattening complexity. Prevents x/y swapping, wrong offset, wrong resolution variable errors.

This helper makes it impossible to:

  • Forget tile offset when computing global coordinates
  • Swap x and y coordinates (launch_index.y → x, launch_index.z → y)
  • Use wrong resolution (tile vs full)
  • Get flattening formula wrong (always row-major: y * width + x)

Usage in CUDA camera ray generation:

// Simple one-line pixel index calculation:
size_t pixel_idx = PixelCoordinate::computeFlatIndex(
launch_index, camera_pixel_offset, camera_resolution_full);
camera_pixel_label[pixel_idx] = hit_UUID + 1;
// Or step-by-step if you need the coordinates:
PixelCoordinate pixel = PixelCoordinate::fromTiledLaunch(
launch_index, camera_pixel_offset, camera_resolution_full);
size_t idx = pixel.toFlatIndex(camera_resolution_full);

Historical bugs prevented:

  • Forgetting camera_pixel_offset in tiled rendering
  • Swapping x/y coordinates
  • Using camera_resolution instead of camera_resolution_full

Definition at line 363 of file BufferIndexing.h.

Constructor & Destructor Documentation

◆ PixelCoordinate()

HELIOS_HOST_DEVICE PixelCoordinate::PixelCoordinate ( uint  x_coord,
uint  y_coord 
)
inline

Construct pixel coordinate from global x, y.

Definition at line 369 of file BufferIndexing.h.

Member Function Documentation

◆ toFlatIndex()

size_t PixelCoordinate::toFlatIndex ( const helios::int2 full_resolution) const
inline

Convert to flat array index (row-major)

Parameters
full_resolutionGlobal camera resolution (width, height)
Returns
Flattened index: y * width + x (always row-major)

Definition at line 384 of file BufferIndexing.h.

Field Documentation

◆ x

uint PixelCoordinate::x

Global x-coordinate (column index)

Definition at line 364 of file BufferIndexing.h.

◆ y

uint PixelCoordinate::y

Global y-coordinate (row index)

Definition at line 365 of file BufferIndexing.h.


The documentation for this struct was generated from the following file: