From 51d23be17245ff32236395235fa2f2e94ac004e4 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 17 Apr 2021 12:50:22 -0700 Subject: [PATCH] Fix some MSVC warnings --- CMakeLists.txt | 2 +- src/pbrt/samplers_test.cpp | 2 +- src/pbrt/util/lowdiscrepancy.h | 2 +- src/pbrt/util/math.h | 4 ++-- src/pbrt/util/progressreporter.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7864f0..943f891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -860,7 +860,7 @@ add_executable (pbrt::pspec ALIAS pspec) target_compile_definitions (pspec PRIVATE ${PBRT_DEFINITIONS}) target_compile_options (pspec PRIVATE ${PBRT_CXX_FLAGS}) target_include_directories (pspec PRIVATE src src/ext) -target_link_libraries (pspec PRIVATE ${ALL_PBRT_LIBS}) +target_link_libraries (pspec PRIVATE ${ALL_PBRT_LIBS} pbrt_warnings) add_sanitizers (pspec) diff --git a/src/pbrt/samplers_test.cpp b/src/pbrt/samplers_test.cpp index e3fa2f9..140cc7a 100644 --- a/src/pbrt/samplers_test.cpp +++ b/src/pbrt/samplers_test.cpp @@ -76,7 +76,7 @@ static void checkElementary(const char *name, std::vector samples, // in each dimension. int nx = 1 << i, ny = 1 << (logSamples - i); - std::vector count(1 << logSamples, 0); + std::vector count(size_t(1 << logSamples), 0); for (const Point2f &s : samples) { // Map the sample to an interval Float x = nx * s.x, y = ny * s.y; diff --git a/src/pbrt/util/lowdiscrepancy.h b/src/pbrt/util/lowdiscrepancy.h index 261aa71..76cb4c8 100644 --- a/src/pbrt/util/lowdiscrepancy.h +++ b/src/pbrt/util/lowdiscrepancy.h @@ -240,7 +240,7 @@ struct OwenScrambler { for (int b = 1; b < 32; ++b) { // Apply Owen scrambling to binary digit _b_ in _v_ uint32_t mask = (~0u) << (32 - b); - if (MixBits((v & mask) ^ seed) & (1u << b)) + if ((uint32_t)MixBits((v & mask) ^ seed) & (1u << b)) v ^= 1u << (31 - b); } return v; diff --git a/src/pbrt/util/math.h b/src/pbrt/util/math.h index ac6f7c2..c603d7f 100644 --- a/src/pbrt/util/math.h +++ b/src/pbrt/util/math.h @@ -243,9 +243,9 @@ PBRT_CPU_GPU inline Float Lerp(Float x, Float a, Float b) { template PBRT_CPU_GPU inline constexpr T Clamp(T val, U low, V high) { if (val < low) - return low; + return T(low); else if (val > high) - return high; + return T(high); else return val; } diff --git a/src/pbrt/util/progressreporter.h b/src/pbrt/util/progressreporter.h index 84c1876..83d432e 100644 --- a/src/pbrt/util/progressreporter.h +++ b/src/pbrt/util/progressreporter.h @@ -71,7 +71,7 @@ class ProgressReporter { #ifdef PBRT_BUILD_GPU_RENDERER std::vector gpuEvents; - std::atomic gpuEventsLaunchedOffset; + std::atomic gpuEventsLaunchedOffset; int gpuEventsFinishedOffset; #endif }; -- GitLab