fixed various win64 compilation problems

metadata
Wenzel Jakob 2010-10-19 21:04:47 +02:00
parent a4db1bb008
commit 36c341f1a7
10 changed files with 531 additions and 502 deletions

View File

@ -104,7 +104,7 @@ public:
inline const int getBitsPerPixel() const { return m_bpp; }
/// Return the bitmap size in bytes
inline const int getSize() const { return m_size; }
inline const size_t getSize() const { return m_size; }
/// Return some human-readable information about this bitmap
std::string toString() const;

View File

@ -198,6 +198,10 @@ __declspec(naked) static FINLINE unsigned __int64 __cdecl rdtsc(void) {
ret
}
}
#else
static FINLINE __int64 rdtsc(void) {
return __rdtsc();
}
#endif
#endif

View File

@ -238,7 +238,7 @@ public:
const Bitmap *getBitmap(unsigned int slot = EDefaultPosition) const;
/// Return the number of stored bitmaps
inline int getBitmapCount() const { return m_bitmaps.size(); }
inline int getBitmapCount() const { return (int) m_bitmaps.size(); }
/// Upload the texture
virtual void init() = 0;

File diff suppressed because it is too large Load Diff

View File

@ -112,7 +112,7 @@ public:
Spectrum estimateIrradiance(
const Point &p, const Normal &n,
Float searchRadius,
unsigned int maxPhotons) const;
size_t maxPhotons) const;
/**
* Using the photon map, estimate the irradiance on a surface (filtered
@ -130,7 +130,7 @@ public:
Spectrum estimateIrradianceFiltered(
const Point &p, const Normal &n,
Float searchRadius,
unsigned int maxPhotons) const;
size_t maxPhotons) const;
/**
* Using the photon map and a surface intersection, estimate the
@ -146,7 +146,7 @@ public:
Spectrum estimateRadianceFiltered(
const Intersection &its,
Float searchRadius,
unsigned int maxPhotons) const;
size_t maxPhotons) const;
/**
* Compute scattered contributions from all photons within
@ -156,7 +156,7 @@ public:
* to the 'maxDepth' parameter. This function is meant to be
* used with progressive photon mapping.
*/
int estimateRadianceRaw(const Intersection &its,
size_t estimateRadianceRaw(const Intersection &its,
Float searchRadius, Spectrum &result, int maxDepth) const;
/**
@ -176,7 +176,7 @@ public:
const MediumSamplingRecord &mRec,
const Ray &ray,
Float searchRadius,
unsigned int maxPhotons,
size_t maxPhotons,
const Medium *medium) const;
/// Determine if the photon map is completely filled
@ -195,7 +195,7 @@ public:
}
/// Return the position of a photon in the photon map (for debugging)
inline Point getPhotonPosition(int i) const {
inline Point getPhotonPosition(size_t i) const {
return m_photons[i].getPosition();
}
@ -428,8 +428,8 @@ protected:
* @return
* The number of results
*/
unsigned int nnSearch(const Point &p, Float &searchRadiusSquared,
unsigned int maxSize, search_result *results) const;
size_t nnSearch(const Point &p, Float &searchRadiusSquared,
size_t maxSize, search_result *results) const;
/**
* Partition a list of photons so that there is an ordering between
@ -477,10 +477,10 @@ private:
/* ===================================================================== */
struct ThreadContext {
AABB aabb;
int photonOffset;
int photonCount;
int maxPhotons;
uint8_t unused[128]; // Avoid false sharing
size_t photonOffset;
size_t photonCount;
size_t maxPhotons;
uint8_t unused[128-sizeof(AABB)-sizeof(size_t)*3]; // Avoid false sharing
};
/* Precomputed lookup tables */

View File

@ -58,7 +58,7 @@ public:
RenderQueue();
/// Return the current number of jobs in the queue
inline int getJobCount() const { return m_jobs.size(); }
inline size_t getJobCount() const { return m_jobs.size(); }
/// Add a render job to the queue
void addJob(RenderJob *thr);

View File

@ -113,11 +113,8 @@ void Logger::log(ELogLevel level, const Class *theClass,
if (runningInDebugger)
__asm__ ("int $3");
#elif defined(WIN32)
if (IsDebuggerPresent()) {
__asm {
int 0x03
}
}
if (IsDebuggerPresent())
__debugbreak();
#endif
throw std::runtime_error(text);

View File

@ -78,7 +78,7 @@ private:
*/
class GatherPhotonWorker : public ParticleTracer {
public:
GatherPhotonWorker(GatherPhotonProcess::EGatherType type, int granularity,
GatherPhotonWorker(GatherPhotonProcess::EGatherType type, unsigned int granularity,
int maxDepth, int rrDepth)
: ParticleTracer(maxDepth, true, rrDepth),
m_type(type), m_granularity(granularity) {
@ -149,7 +149,7 @@ GatherPhotonProcess::GatherPhotonProcess(EGatherType type, size_t photonCount,
}
ref<WorkProcessor> GatherPhotonProcess::createWorkProcessor() const {
return new GatherPhotonWorker(m_type, m_granularity, m_maxDepth,
return new GatherPhotonWorker(m_type, (unsigned int) m_granularity, m_maxDepth,
m_rrDepth);
}

View File

@ -197,8 +197,8 @@ bool PhotonMap::storePhoton(const Photon &photon) {
void PhotonMap::prepareSMP(int numThreads) {
int photonsPerThread = m_maxPhotons / numThreads;
int remainder = m_maxPhotons - photonsPerThread * numThreads;
size_t photonsPerThread = m_maxPhotons / numThreads;
size_t remainder = m_maxPhotons - photonsPerThread * numThreads;
m_numThreads = numThreads;
m_context = new ThreadContext[numThreads];
@ -222,7 +222,7 @@ bool PhotonMap::storePhotonSMP(int thread, const Point &pos, const Normal &norma
/* Keep track of the volume covered by all stored photons */
m_context[thread].aabb.expandBy(pos);
int idx = m_context[thread].photonCount++;
size_t idx = m_context[thread].photonCount++;
m_photons[m_context[thread].photonOffset + idx] = Photon(pos, normal, dir, power, depth);
return true;
@ -478,11 +478,11 @@ void PhotonMap::balanceRecursive(photon_iterator basePtr,
}
}
unsigned int PhotonMap::nnSearch(const Point &p, Float &searchRadiusSquared,
unsigned int maxSize, search_result *results) const {
size_t PhotonMap::nnSearch(const Point &p, Float &searchRadiusSquared,
size_t maxSize, search_result *results) const {
const float pos[3] = { (float) p.x, (float) p.y, (float) p.z };
size_t stack[MAX_PHOTONMAP_DEPTH];
unsigned int index = 1, stackPos = 1, fill = 0;
size_t index = 1, stackPos = 1, fill = 0;
bool isPriorityQueue = false;
float distSquared = (float) searchRadiusSquared;
stack[0] = 0;
@ -557,7 +557,7 @@ unsigned int PhotonMap::nnSearch(const Point &p, Float &searchRadiusSquared,
}
Spectrum PhotonMap::estimateIrradiance(const Point &p, const Normal &n,
Float searchRadius, unsigned int maxPhotons) const {
Float searchRadius, size_t maxPhotons) const {
Spectrum result(0.0f);
/* The photon map needs to be balanced before executing searches */
@ -565,15 +565,16 @@ Spectrum PhotonMap::estimateIrradiance(const Point &p, const Normal &n,
/* Search for photons contained within a spherical region */
Float distSquared = searchRadius*searchRadius;
search_result *results = static_cast<search_result *>(alloca((maxPhotons+1) * sizeof(search_result)));
unsigned int resultCount = nnSearch(p, distSquared, maxPhotons, results);
search_result *results = static_cast<search_result *>(alloca((maxPhotons+1)
* sizeof(search_result)));
size_t resultCount = nnSearch(p, distSquared, maxPhotons, results);
/* Avoid very noisy estimates */
if (resultCount < m_minPhotons)
return result;
/* Sum over all contributions */
for (unsigned int i=0; i<resultCount; i++) {
for (size_t i=0; i<resultCount; i++) {
const Photon &photon = *results[i].second;
/* Don't use samples from the opposite side
@ -591,7 +592,7 @@ Spectrum PhotonMap::estimateIrradiance(const Point &p, const Normal &n,
#if !defined(MTS_SSE)
Spectrum PhotonMap::estimateIrradianceFiltered(const Point &p, const Normal &n,
Float searchRadius, unsigned int maxPhotons) const {
Float searchRadius, size_t maxPhotons) const {
Spectrum result(0.0f);
/* The photon map needs to be balanced before executing searches */
@ -599,14 +600,14 @@ Spectrum PhotonMap::estimateIrradianceFiltered(const Point &p, const Normal &n,
Float distSquared = searchRadius*searchRadius;
search_result *results = static_cast<search_result *>(alloca((maxPhotons+1) * sizeof(search_result)));
unsigned int resultCount = nnSearch(p, distSquared, maxPhotons, results);
size_t resultCount = nnSearch(p, distSquared, maxPhotons, results);
/* Avoid very noisy estimates */
if (EXPECT_NOT_TAKEN(resultCount < m_minPhotons))
return result;
/* Sum over all contributions */
for (unsigned int i=0; i<resultCount; i++) {
for (size_t i=0; i<resultCount; i++) {
const Float photonDistanceSqr = results[i].first;
const Photon &photon = *results[i].second;
@ -628,7 +629,7 @@ Spectrum PhotonMap::estimateIrradianceFiltered(const Point &p, const Normal &n,
#else
Spectrum PhotonMap::estimateIrradianceFiltered(const Point &p, const Normal &n,
Float searchRadius, unsigned int maxPhotons) const {
Float searchRadius, size_t maxPhotons) const {
SSEVector result(_mm_setzero_ps());
/* The photon map needs to be balanced before executing searches */
@ -636,14 +637,14 @@ Spectrum PhotonMap::estimateIrradianceFiltered(const Point &p, const Normal &n,
Float distSquared = searchRadius*searchRadius;
search_result *results = static_cast<search_result *>(alloca((maxPhotons+1) * sizeof(search_result)));
unsigned int resultCount = nnSearch(p, distSquared, maxPhotons, results);
size_t resultCount = nnSearch(p, distSquared, maxPhotons, results);
/* Avoid very noisy estimates */
if (EXPECT_NOT_TAKEN(resultCount < m_minPhotons))
return Spectrum(0.0f);
/* Sum over all contributions */
for (unsigned int i=0; i<resultCount; i++) {
for (size_t i=0; i<resultCount; i++) {
const Float photonDistanceSqr = results[i].first;
const Photon &photon = *results[i].second;
@ -676,7 +677,7 @@ Spectrum PhotonMap::estimateIrradianceFiltered(const Point &p, const Normal &n,
#endif
Spectrum PhotonMap::estimateRadianceFiltered(const Intersection &its,
Float searchRadius, unsigned int maxPhotons) const {
Float searchRadius, size_t maxPhotons) const {
Spectrum result(0.0f);
const BSDF *bsdf = its.shape->getBSDF();
@ -686,14 +687,14 @@ Spectrum PhotonMap::estimateRadianceFiltered(const Intersection &its,
/* Search for photons contained within a spherical region */
Float distSquared = searchRadius*searchRadius;
search_result *results = static_cast<search_result *>(alloca((maxPhotons+1) * sizeof(search_result)));
unsigned int resultCount = nnSearch(its.p, distSquared, maxPhotons, results);
size_t resultCount = nnSearch(its.p, distSquared, maxPhotons, results);
/* Avoid very noisy estimates */
if (EXPECT_NOT_TAKEN(resultCount < m_minPhotons))
return Spectrum(0.0f);
/* Sum over all contributions */
for (unsigned int i=0; i<resultCount; i++) {
for (size_t i=0; i<resultCount; i++) {
const Float photonDistanceSqr = results[i].first;
const Photon &photon = *results[i].second;
@ -710,7 +711,7 @@ Spectrum PhotonMap::estimateRadianceFiltered(const Intersection &its,
return result * (m_scale * 3 * INV_PI / distSquared);
}
int PhotonMap::estimateRadianceRaw(const Intersection &its,
size_t PhotonMap::estimateRadianceRaw(const Intersection &its,
Float searchRadius, Spectrum &result, int maxDepth) const {
result = Spectrum(0.0f);
const BSDF *bsdf = its.shape->getBSDF();
@ -720,7 +721,7 @@ int PhotonMap::estimateRadianceRaw(const Intersection &its,
const float pos[3] = { (float) its.p.x, (float) its.p.y, (float) its.p.z };
size_t stack[MAX_PHOTONMAP_DEPTH];
unsigned int index = 1, stackPos = 1, resultCount = 0;
size_t index = 1, stackPos = 1, resultCount = 0;
float distSquared = (float) searchRadius*searchRadius;
stack[0] = 0;
@ -788,7 +789,7 @@ int PhotonMap::estimateRadianceRaw(const Intersection &its,
}
Spectrum PhotonMap::estimateVolumeRadiance(const MediumSamplingRecord &mRec, const Ray &ray,
Float searchRadius, unsigned int maxPhotons, const Medium *medium) const {
Float searchRadius, size_t maxPhotons, const Medium *medium) const {
Spectrum result(0.0f);
/* The photon map needs to be balanced before executing searches */
@ -797,7 +798,7 @@ Spectrum PhotonMap::estimateVolumeRadiance(const MediumSamplingRecord &mRec, con
/* Search for photons contained within a spherical region */
Float distSquared = searchRadius*searchRadius;
search_result *results = static_cast<search_result *>(alloca((maxPhotons+1) * sizeof(search_result)));
unsigned int resultCount = nnSearch(ray.o, distSquared, maxPhotons, results);
size_t resultCount = nnSearch(ray.o, distSquared, maxPhotons, results);
/* Avoid very noisy estimates */
if (EXPECT_NOT_TAKEN(resultCount < m_minPhotons))
@ -807,7 +808,7 @@ Spectrum PhotonMap::estimateVolumeRadiance(const MediumSamplingRecord &mRec, con
Vector wo = -ray.d;
/* Sum over all contributions */
for (unsigned int i=0; i<resultCount; i++) {
for (size_t i=0; i<resultCount; i++) {
const Photon &photon = *results[i].second;
result += photon.getPower() * (phase->f(mRec, photon.getDirection(), wo));
}
@ -829,13 +830,13 @@ void PhotonMap::setMinPhotons(int minPhotons) {
void PhotonMap::dumpOBJ(const std::string &filename) {
std::ofstream os(filename.c_str());
os << "o Photons" << endl;
for (unsigned int i=1; i<=getPhotonCount(); i++) {
for (size_t i=1; i<=getPhotonCount(); i++) {
Point p = getPhotonPosition(i);
os << "v " << p.x << " " << p.y << " " << p.z << endl;
}
/// Need to generate some fake geometry so that blender will import the points
for (unsigned int i=3; i<=getPhotonCount(); i++)
for (size_t i=3; i<=getPhotonCount(); i++)
os << "f " << i << " " << i-1 << " " << i-2 << endl;
os.close();
}

View File

@ -72,7 +72,9 @@ void PreviewWorker::processIncoherent(const WorkUnit *workUnit, WorkResult *work
for (int y=sy; y<ey; ++y) {
for (int x=sx; x<ex; ++x) {
/* Generate a camera ray without normalization */
primary = Ray(m_cameraO, m_cameraTL + m_cameraDx*x + m_cameraDy * y);
primary = Ray(m_cameraO, m_cameraTL
+ m_cameraDx * (Float) x
+ m_cameraDy * (Float) y);
++numRays;
if (!m_kdtree->rayIntersect(primary, its)) {