Skip to content

Commit

Permalink
CI: add clang-format-check.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
w3ntao committed Oct 24, 2024
1 parent 781e902 commit 02837a5
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 15 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: formatting check (clang-format-16)

on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]
workflow_dispatch:

jobs:
formatting-check:
name: formatting check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '16'
check-path: 'src/pbrt'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pbrt-minus

[![cuda-build](https://github.com/w3ntao/pbrt-minus/actions/workflows/cuda-build.yml/badge.svg)](https://github.com/w3ntao/pbrt-minus/actions/workflows/cuda-build.yml)
[![formatted with clang-format-16](https://github.com/w3ntao/pbrt-minus/actions/workflows/clang-format-check.yml/badge.svg)](https://github.com/w3ntao/pbrt-minus/actions/workflows/clang-format-check.yml)

A simpler, less performant, physically based, GPU ray tracer rewritten from PBRT-v4.

Expand Down
2 changes: 1 addition & 1 deletion src/pbrt/accelerator/hlbvh.cu
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void HLBVH::build_bvh(const std::vector<const Primitive *> &gpu_primitives,
if (verify_counter != num_total_primitives) {
REPORT_FATAL_ERROR();
}

printf("HLBVH: %zu/%d (%.2f%) treelets filled (max primitives in a treelet: %d)\n",
dense_treelet_indices.size(), MAX_TREELET_NUM,
double(dense_treelet_indices.size()) / MAX_TREELET_NUM * 100,
Expand Down
4 changes: 2 additions & 2 deletions src/pbrt/base/megakernel_integrator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ void Integrator::render(Film *film, const std::string &sampler_type, uint sample
uint thread_width = 8;
uint thread_height = 8;

std::cout << " (samples per pixel: " << samples_per_pixel << ") " << "in " << thread_width
<< "x" << thread_height << " blocks.\n"
std::cout << " (samples per pixel: " << samples_per_pixel << ") "
<< "in " << thread_width << "x" << thread_height << " blocks.\n"
<< std::flush;

dim3 blocks(divide_and_ceil(uint(film_resolution.x), thread_width),
Expand Down
2 changes: 1 addition & 1 deletion src/pbrt/bxdfs/layered_bxdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ template <typename TopBxDF, typename BottomBxDF, bool twoSided>
class LayeredBxDF {
public:
PBRT_GPU
LayeredBxDF() {};
LayeredBxDF(){};

PBRT_GPU
LayeredBxDF(TopBxDF top, BottomBxDF bottom, FloatType thickness, const SampledSpectrum &albedo,
Expand Down
2 changes: 1 addition & 1 deletion src/pbrt/euclidean_space/bounds2.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Bounds2 {

PBRT_CPU_GPU
Bounds2(Point2<T> p1, Point2<T> p2) : p_min(p1.min(p2)), p_max(p1.max(p2)) {}

PBRT_CPU_GPU
Vector2<T> Diagonal() const {
return p_max - p_min;
Expand Down
4 changes: 2 additions & 2 deletions src/pbrt/euclidean_space/point2.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class Point2 {
public:
T x, y;

PBRT_CPU_GPU Point2() {};
PBRT_CPU_GPU Point2(){};

PBRT_CPU_GPU Point2(T _x, T _y) : x(_x), y(_y) {};
PBRT_CPU_GPU Point2(T _x, T _y) : x(_x), y(_y){};

PBRT_CPU_GPU
explicit Point2(const Vector2<T> v) : x(v.x), y(v.y) {}
Expand Down
4 changes: 2 additions & 2 deletions src/pbrt/euclidean_space/point3.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class Point3 {
public:
T x, y, z;

PBRT_CPU_GPU Point3() : x(NAN), y(NAN), z(NAN) {};
PBRT_CPU_GPU Point3() : x(NAN), y(NAN), z(NAN){};

PBRT_CPU_GPU Point3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {};
PBRT_CPU_GPU Point3(T _x, T _y, T _z) : x(_x), y(_y), z(_z){};

PBRT_CPU_GPU T &operator[](uint8_t index) {
switch (index) {
Expand Down
2 changes: 1 addition & 1 deletion src/pbrt/euclidean_space/vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Vector3 {
public:
T x, y, z;

PBRT_CPU_GPU Vector3() : x(NAN), y(NAN), z(NAN) {};
PBRT_CPU_GPU Vector3() : x(NAN), y(NAN), z(NAN){};

PBRT_CPU_GPU Vector3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {}

Expand Down
2 changes: 1 addition & 1 deletion src/pbrt/films/rgb_film.cu
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void RGBFilm::add_sample(uint pixel_index, const SampledSpectrum &radiance_l,
if (weight == 0) {
return;
}

auto rgb = sensor->to_sensor_rgb(radiance_l, lambda);

if (DEBUG_MODE && rgb.has_nan()) {
Expand Down
3 changes: 2 additions & 1 deletion src/pbrt/filters/mitchell.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ FloatType MitchellFilter::Mitchell1D(FloatType x) const {
if (x <= 1) {
return ((12 - 9 * b - 6 * c) * x * x * x + (-18 + 12 * b + 6 * c) * x * x + (6 - 2 * b)) *
(1.f / 6.f);
} else if (x <= 2) {
}
if (x <= 2) {
return ((-b - 6 * c) * x * x * x + (6 * b + 30 * c) * x * x + (-12 * b - 48 * c) * x +
(8 * b + 24 * c)) *
(1.f / 6.f);
Expand Down
2 changes: 1 addition & 1 deletion src/pbrt/lights/spot_light.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SpotLight : public LightBase {
PBRT_GPU
SampledSpectrum l(Point3f p, Normal3f n, Point2f uv, Vector3f w,
const SampledWavelengths &lambda) const;

PBRT_GPU
cuda::std::optional<LightLiSample> sample_li(const LightSampleContext &ctx, const Point2f &u,
SampledWavelengths &lambda) const;
Expand Down
2 changes: 1 addition & 1 deletion src/pbrt/util/float.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Half {

if (f.u >= f16max.u) { // result is Inf or NaN (all exponent bits set)
o.u = (f.u > f32infty.u) ? 0x7e00 : 0x7c00;
} // NaN->qNaN and Inf->Inf
} // NaN->qNaN and Inf->Inf
else { // (De)normalized number or zero
if (f.u < (113 << 23)) { // resulting FP16 is subnormal or zero
// use a magic value to align our 10 mantissa bits at the bottom
Expand Down
2 changes: 1 addition & 1 deletion src/pbrt/util/piecewise_constant_1d.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PiecewiseConstant1D {

// Compute offset along CDF segment
FloatType du = u - cdf[o];

if (cdf[o + 1] - cdf[o] > 0) {
du /= cdf[o + 1] - cdf[o];
}
Expand Down

0 comments on commit 02837a5

Please sign in to comment.