mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 14:20:38 +08:00
deterministic rasterization
Summary: Attempt to fix #659, an observation that the rasterizer is nondeterministic, by resolving tied faces by picking those with lower index. Reviewed By: nikhilaravi, patricklabatut Differential Revision: D30699039 fbshipit-source-id: 39ed797eb7e9ce7370ae71259ad6b757f9449923
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cb170ac024
commit
860b742a02
@@ -28,7 +28,7 @@ struct Pixel {
|
||||
};
|
||||
|
||||
__device__ bool operator<(const Pixel& a, const Pixel& b) {
|
||||
return a.z < b.z;
|
||||
return a.z < b.z || (a.z == b.z && a.idx < b.idx);
|
||||
}
|
||||
|
||||
// Get the xyz coordinates of the three vertices for the face given by the
|
||||
|
||||
@@ -117,13 +117,6 @@ struct IsNeighbor {
|
||||
int neighbor_idx;
|
||||
};
|
||||
|
||||
// Function to sort based on the z distance in the top K queue
|
||||
bool SortTopKByZdist(
|
||||
std::tuple<float, int, float, float, float, float> a,
|
||||
std::tuple<float, int, float, float, float, float> b) {
|
||||
return std::get<0>(a) < std::get<0>(b);
|
||||
}
|
||||
|
||||
std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
|
||||
RasterizeMeshesNaiveCpu(
|
||||
const torch::Tensor& face_verts,
|
||||
@@ -310,7 +303,7 @@ RasterizeMeshesNaiveCpu(
|
||||
|
||||
// Sort the deque inplace based on the z distance
|
||||
// to mimic using a priority queue.
|
||||
std::sort(q.begin(), q.end(), SortTopKByZdist);
|
||||
std::sort(q.begin(), q.end());
|
||||
if (static_cast<int>(q.size()) > K) {
|
||||
// remove the last value
|
||||
q.pop_back();
|
||||
|
||||
Reference in New Issue
Block a user