Skip to content

Commit dbebfc3

Browse files
committed
Various fixes to try to get the MSVC2015 build working.
Missing header files. Hexadecimal floating-point constants converted to decimal (feh). Issue mmp#32.
1 parent a4033f7 commit dbebfc3

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ENDIF()
1717

1818
IF(MSVC)
1919
ADD_DEFINITIONS (/D _CRT_SECURE_NO_WARNINGS)
20+
ADD_DEFINITIONS (/D YY_NO_UNISTD_H)
2021
ENDIF()
2122

2223
FIND_PACKAGE ( Threads )

src/core/imageio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
// core/imageio.h*
4343
#include "pbrt.h"
4444
#include "geometry.h"
45+
#include <cctype>
4546

4647
// ImageIO Declarations
4748
inline bool HasExtension(const std::string &value, const std::string &ending) {

src/core/lowdiscrepancy.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,11 @@ Float RadicalInverse(int baseIndex, uint64_t a) {
450450
switch (baseIndex) {
451451
case 0:
452452
// Compute base-2 radical inverse
453-
return ReverseBits64(a) * 0x1p-64;
453+
#ifdef PBRT_IS_MSVC
454+
return ReverseBits64(a) * 5.4210108624275222e-20;
455+
#else
456+
return ReverseBits64(a) * 0x1p-64;
457+
#endif
454458
case 1:
455459
return RadicalInverseSpecialized<3>(a);
456460
case 2:

src/core/lowdiscrepancy.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ inline uint32_t ReverseMultiplyGenerator(const uint32_t *C, uint32_t a) {
106106

107107
inline Float SampleGeneratorMatrix(const uint32_t *C, uint32_t a,
108108
uint32_t scramble = 0) {
109+
#ifdef PBRT_IS_MSVC
110+
return (ReverseMultiplyGenerator(C, a) ^ scramble) * 2.3283064365386963e-10f);
111+
#else
109112
return (ReverseMultiplyGenerator(C, a) ^ scramble) * 0x1p-32f;
113+
#endif
110114
}
111115

112116
inline uint32_t GrayCode(uint32_t v) { return (v >> 1) ^ v; }
@@ -115,7 +119,11 @@ inline void GrayCodeSample(const uint32_t *C, uint32_t n, uint32_t scramble,
115119
Float *p) {
116120
uint32_t v = scramble;
117121
for (uint32_t i = 0; i < n; ++i) {
122+
#ifdef PBRT_IS_MSVC
123+
p[i] = v * 2.3283064365386963e-10f; /* 1/2^32 */
124+
#else
118125
p[i] = v * 0x1p-32f; /* 1/2^32 */
126+
#endif
119127
v ^= C[31 - CountTrailingZeros(i + 1)];
120128
}
121129
}
@@ -124,8 +132,13 @@ inline void GrayCodeSample(const uint32_t *C0, const uint32_t *C1, uint32_t n,
124132
const Point2i &scramble, Point2f *p) {
125133
uint32_t v[2] = {(uint32_t)scramble.x, (uint32_t)scramble.y};
126134
for (uint32_t i = 0; i < n; ++i) {
135+
#ifdef PBRT_IS_MSVC
136+
p[i].x = v[0] * 2.3283064365386963e-10f;
137+
p[i].y = v[1] * 2.3283064365386963e-10f;
138+
#else
127139
p[i].x = v[0] * 0x1p-32f;
128140
p[i].y = v[1] * 0x1p-32f;
141+
#endif
129142
v[0] ^= C0[31 - CountTrailingZeros(i + 1)];
130143
v[1] ^= C1[31 - CountTrailingZeros(i + 1)];
131144
}
@@ -222,7 +235,11 @@ inline float SobolSampleFloat(int64_t a, int dimension, uint32_t scramble) {
222235
for (int i = dimension * SobolMatrixSize + SobolMatrixSize - 1; a != 0;
223236
a >>= 1, --i)
224237
if (a & 1) v ^= SobolMatrices32[i];
238+
#ifdef PBRT_IS_MSVC
239+
return v * 2.3283064365386963e-10f; /* 1/2^32 */
240+
#else
225241
return v * 0x1p-32f; /* 1/2^32 */
242+
#endif
226243
}
227244

228245
inline double SobolSampleDouble(int64_t index, int dimension,

src/core/rng.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ class RNG {
7171
}
7272
}
7373
Float UniformFloat() {
74+
#ifdef PBRT_IS_MSVC
75+
return std::min(OneMinusEpsilon, UniformUInt32() * 2.3283064365386963e-10f);
76+
#else
7477
return std::min(OneMinusEpsilon, UniformUInt32() * 0x1p-32f);
78+
#endif
7579
}
7680
template <typename Iterator>
7781
void Shuffle(Iterator begin, Iterator end) {

src/core/stats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <map>
4545
#include <chrono>
4646
#include <string>
47+
#include <functional>
4748

4849
// Statistics Declarations
4950
class StatsAccumulator;

0 commit comments

Comments
 (0)