Skip to content

Commit

Permalink
Fixes to #88, #89
Browse files Browse the repository at this point in the history
  • Loading branch information
s-laine committed Aug 27, 2022
1 parent f157b92 commit fad71a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions nvdiffrast/common/cudaraster/impl/BinRaster.inl
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ __device__ __inline__ void binRasterImpl(const CRParams p)
hiy = add_clamp_0_x((v0y + max_max(d01y, 0, d02y)) >> binLog, 0, p.heightBins - 1);

U32 bit = 1 << threadIdx.x;
#if __CUDA_ARCH__ >= 700
bool multi = (hix != lox || hiy != loy);
if (!__any_sync(hasTriMask, multi))
{
Expand All @@ -220,6 +221,7 @@ __device__ __inline__ void binRasterImpl(const CRParams p)
s_outMask[threadIdx.y][binIdx] = mask;
__syncwarp(hasTriMask);
} else
#endif
{
bool complex = (hix > lox+1 || hiy > loy+1);
if (!__any_sync(hasTriMask, complex))
Expand Down
2 changes: 1 addition & 1 deletion nvdiffrast/common/cudaraster/impl/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Buffer::Buffer(void)
Buffer::~Buffer(void)
{
if (m_gpuPtr)
NVDR_CHECK_CUDA_ERROR(cudaFree(m_gpuPtr));
cudaFree(m_gpuPtr); // Don't throw an exception.
}

//------------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions nvdiffrast/common/cudaraster/impl/TriangleSetup.inl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ __device__ __inline__ bool prepareTriangle(
S32 e0 = t0.x * t1.y - t0.y * t1.x;
S32 e1 = t1.x * t2.y - t1.y * t2.x;
S32 e2 = t2.x * t0.y - t2.y * t0.x;
if (area < 0)
{
e0 = -e0;
e1 = -e1;
e2 = -e2;
}

if (e0 < 0 || e1 < 0 || e2 < 0)
{
Expand All @@ -92,6 +98,12 @@ __device__ __inline__ bool prepareTriangle(
e0 = t0.x * t1.y - t0.y * t1.x;
e1 = t1.x * t2.y - t1.y * t2.x;
e2 = t2.x * t0.y - t2.y * t0.x;
if (area < 0)
{
e0 = -e0;
e1 = -e1;
e2 = -e2;
}

if (e0 < 0 || e1 < 0 || e2 < 0)
return false; // Between pixels.
Expand Down

0 comments on commit fad71a4

Please sign in to comment.