Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk committed Feb 6, 2024
1 parent c3bf40e commit dd1652c
Show file tree
Hide file tree
Showing 22 changed files with 81 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
uses: ./source/.github/actions/generic-ci
with:
vtk_version: ${{matrix.vtk_version}}
raytracing_label: raytracing
raytracing_label: ${{matrix.raytracing_label}}
lfs_sha: ${{ needs.cache_lfs.outputs.lfs_sha}}

#----------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion .lsan.supp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ leak:TKernel
leak:libtbb

# Potential mesa/VTK leak with incomplete callstack
# forces us to hide all leaks from the libf3dSDKTests
# forces us to hide all leaks from the tests using a render window
# https://gitlab.kitware.com/vtk/vtk/-/issues/18504
leak:libf3dSDKTests
leak:VTKExtensionsRenderingTests
2 changes: 1 addition & 1 deletion application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ else()
endif()

# Needs splat sorting with compute shaders
if(VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240202)
if(VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240203)
if(NOT APPLE) # MacOS does not support compute shaders
f3d_test(NAME Test3DGaussiansSplatting DATA small.splat ARGS -osy --up=-Y --point-size=1 --point-type=gaussian --camera-position=-3.6,0.5,-4.2)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <vtkTestUtilities.h>
#include <vtkVersion.h>

#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240202)
#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240203)
#include "vtkF3DPointSplatMapper.h"
#endif

Expand All @@ -23,7 +23,7 @@ int TestF3DObjectFactory(int argc, char* argv[])
vtkObjectFactory::RegisterFactory(factory);
vtkObjectFactory::SetAllEnableFlags(0, "vtkPolyDataMapper", "vtkOpenGLPolyDataMapper");

#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240202)
#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240203)
vtkObjectFactory::SetAllEnableFlags(0, "vtkPointGaussianMapper", "vtkOpenGLPointGaussianMapper");
#endif

Expand All @@ -48,7 +48,7 @@ int TestF3DObjectFactory(int argc, char* argv[])
return EXIT_FAILURE;
}

#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240202)
#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240203)
vtkNew<vtkPointGaussianMapper> pointMapper;
pointMapper->Print(cout);
vtkF3DPointSplatMapper* pointMapperPtr = vtkF3DPointSplatMapper::SafeDownCast(pointMapper);
Expand Down
6 changes: 3 additions & 3 deletions library/VTKExtensions/Applicative/vtkF3DObjectFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "vtkF3DPolyDataMapper.h"

#if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && \
VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240202)
VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240203)
#include "vtkF3DPointSplatMapper.h"
#endif

Expand All @@ -29,7 +29,7 @@ vtkStandardNewMacro(vtkF3DObjectFactory);
VTK_CREATE_CREATE_FUNCTION(vtkF3DPolyDataMapper)

#if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && \
VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240202)
VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240203)
VTK_CREATE_CREATE_FUNCTION(vtkF3DPointSplatMapper)
#endif

Expand All @@ -53,7 +53,7 @@ vtkF3DObjectFactory::vtkF3DObjectFactory()
"vtkPolyDataMapper override for F3D", 1, vtkObjectFactoryCreatevtkF3DPolyDataMapper);

#if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && \
VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240202)
VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240203)
this->RegisterOverride("vtkPointGaussianMapper", "vtkF3DPointSplatMapper",
"vtkPointGaussianMapper override for F3D", 1, vtkObjectFactoryCreatevtkF3DPointSplatMapper);
#endif
Expand Down
2 changes: 1 addition & 1 deletion library/VTKExtensions/Rendering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ set(classes
)

# Needs https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10675
if(NOT ANDROID AND NOT EMSCRIPTEN AND VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240202)
if(NOT ANDROID AND NOT EMSCRIPTEN AND VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240203)
set(classes ${classes} vtkF3DBitonicSort vtkF3DPointSplatMapper)
endif()

Expand Down
3 changes: 1 addition & 2 deletions library/VTKExtensions/Rendering/Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ list(APPEND VTKExtensionsRenderingTests_list
TestF3DCachedTexturesPrint.cxx
)

# Compute shaders are not supported on mac
# Also needs https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10675
if(NOT ANDROID AND NOT EMSCRIPTEN AND VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240202)
if(NOT ANDROID AND NOT EMSCRIPTEN AND VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240203)
list(APPEND VTKExtensionsRenderingTests_list
TestF3DBitonicSort.cxx)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <vtkShader.h>

#include "vtkF3DBitonicSort.h"

#include "vtkF3DBitonicSortFunctions.h"
#include "vtkF3DBitonicSortGlobalDisperseCS.h"
#include "vtkF3DBitonicSortGlobalFlipCS.h"
Expand All @@ -12,7 +11,6 @@

#include <algorithm>
#include <random>
#include <sstream>

int TestF3DBitonicSort(int argc, char* argv[])
{
Expand All @@ -30,12 +28,12 @@ int TestF3DBitonicSort(int argc, char* argv[])
constexpr int nbElements = 10000;

// fill CPU keys and values buffers
std::vector<float> keys(nbElements);
std::vector<double> keys(nbElements);
std::vector<int> values(nbElements);

std::random_device dev;
std::mt19937 rng(dev());
std::uniform_real_distribution<float> dist(0.0f, 1.0f);
std::uniform_real_distribution<double> dist(0.0, 1.0);

std::generate(std::begin(keys), std::end(keys), [&]() { return dist(rng); });
std::fill(std::begin(values), std::end(values), 0); // we do not care about the values
Expand All @@ -49,7 +47,7 @@ int TestF3DBitonicSort(int argc, char* argv[])

// sort
vtkNew<vtkF3DBitonicSort> sorter;
sorter->Initialize(128, VTK_FLOAT, VTK_INT);
sorter->Initialize(128, VTK_DOUBLE, VTK_INT);
sorter->Run(vtkOpenGLRenderWindow::SafeDownCast(renWin), nbElements, bufferKeys, bufferValues);

// download sorted key buffer to CPU
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ivec2 disperse(uint t, uint h)
ivec2 disperse(uint h)
{
uint t = gl_GlobalInvocationID.x;
uint q = (t / h) * 2 * h;

uint x = q + t % h;
Expand All @@ -8,8 +9,9 @@ ivec2 disperse(uint t, uint h)
return ivec2(x, y);
}

ivec2 flip(uint t, uint h)
ivec2 flip(uint h)
{
uint t = gl_GlobalInvocationID.x;
uint q = (t / h) * 2 * h;

uint x = q + t % h;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ layout(location = 1) uniform int height;

void main()
{
compare_and_swap(disperse(gl_GlobalInvocationID.x, height));
compare_and_swap(disperse(height));
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ layout(location = 1) uniform int height;

void main()
{
compare_and_swap(flip(gl_GlobalInvocationID.x, height));
compare_and_swap(flip(height));
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ void main()
for (uint h = WorkgroupSize; h >= 1; h /= 2)
{
barrier();
compare_and_swap(disperse(gl_GlobalInvocationID.x, h));
compare_and_swap(disperse(h));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ void main()
for (uint h = 1; h <= WorkgroupSize; h *= 2)
{
barrier();
compare_and_swap(flip(gl_GlobalInvocationID.x, h));
compare_and_swap(flip(h));

for (uint hh = h; hh >= 1; hh /= 2)
{
barrier();
compare_and_swap(disperse(gl_GlobalInvocationID.x, hh));
compare_and_swap(disperse(hh));
}
}
}
13 changes: 13 additions & 0 deletions library/VTKExtensions/Rendering/vtkF3DBitonicSort.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,21 @@ class vtkF3DBitonicSort : public vtkObject
static vtkF3DBitonicSort* New();
vtkTypeMacro(vtkF3DBitonicSort, vtkObject);

/**
* Initialize the compute shaders.
* workgroupSize is the number of threads running in a single GPU workgroup
* keyType and valueType are the VTK types of the key and value to sort respectively
* Only VTK_DOUBLE, VTK_FLOAT, VTK_INT and VTK_UNSIGNED_INT are supported
*/
void Initialize(int workgroupSize, int keyType, int valueType);

/**
* Run the compute shader and sort the buffers.
* An OpenGL context must exists and given as input in the first argument
* nbPairs is the number of element in the buffer keys and values
* OpenGL buffers keys and values must be valid and containing data types specified when
* this class has been initialized
*/
void Run(vtkOpenGLRenderWindow* context, int nbPairs, vtkOpenGLBufferObject* keys,
vtkOpenGLBufferObject* values);

Expand Down
2 changes: 1 addition & 1 deletion library/src/init.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ init::init()
vtkObjectFactory::RegisterFactory(factory);
vtkObjectFactory::SetAllEnableFlags(0, "vtkPolyDataMapper", "vtkOpenGLPolyDataMapper");

#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240202)
#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240203)
vtkObjectFactory::SetAllEnableFlags(0, "vtkPointGaussianMapper", "vtkOpenGLPointGaussianMapper");
#endif

Expand Down
15 changes: 6 additions & 9 deletions library/src/window_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,16 @@ void window_impl::UpdateDynamicOptions()
this->Internals->Renderer->SetInvertZoom(
this->Internals->Options.getAsBool("interactor.invert-zoom"));

std::string splatType = this->Internals->Options.getAsString("render.splat-type");
std::string splatTypeStr = this->Internals->Options.getAsString("render.splat-type");
int pointSize = this->Internals->Options.getAsDouble("render.point-size");
if (splatType == "gaussian")
vtkF3DRendererWithColoring::SplatType splatType = vtkF3DRendererWithColoring::SplatType::SPHERE;
if (splatTypeStr == "gaussian")
{
this->Internals->Renderer->SetPointProperties(
vtkF3DRendererWithColoring::SplatType::GAUSSIAN, pointSize);
}
else if (splatType == "sphere")
{
this->Internals->Renderer->SetPointProperties(
vtkF3DRendererWithColoring::SplatType::SPHERE, pointSize);
splatType = vtkF3DRendererWithColoring::SplatType::GAUSSIAN;
}

this->Internals->Renderer->SetPointProperties(splatType, pointSize);

this->Internals->Renderer->SetLineWidth(
this->Internals->Options.getAsDouble("render.line-width"));
this->Internals->Renderer->ShowEdge(this->Internals->Options.getAsBool("render.show-edges"));
Expand Down
1 change: 1 addition & 0 deletions plugins/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ f3d_plugin_declare_reader(

f3d_plugin_declare_reader(
NAME Splat
SCORE 90
EXTENSIONS splat
MIMETYPES application/vnd.splat
VTK_READER vtkF3DSplatReader
Expand Down
14 changes: 14 additions & 0 deletions plugins/native/configs/config.d/10_native.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,19 @@
{
"comp": "-2",
"translucency-support": true
},
".*(splat)":
{
"point-sprites": true,
"point-size": 1,
"point-type": "gaussian",
"scalars": "color",
"comp": "-2",
"bg-color": "0, 0, 0",
"up": "-Y",
"trackball": true,
"camera-position": "0,1,-5.2",
"camera-focal-point": "0,1,0",
"camera-view-up": "0,-1,0"
}
}
12 changes: 12 additions & 0 deletions plugins/native/configs/thumbnail.d/10_native.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,17 @@
{
"comp": "-2",
"translucency-support": true
},
".*(splat)":
{
"point-sprites": true,
"point-size": 1,
"point-type": "gaussian",
"scalars": "color",
"comp": "-2",
"up": "-Y",
"camera-position": "0,1,-5.2",
"camera-focal-point": "0,1,0",
"camera-view-up": "0,-1,0"
}
}
4 changes: 4 additions & 0 deletions plugins/native/f3d-3d-formats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
<comment>Polygon File Format</comment>
<glob pattern="*.ply"/>
</mime-type>
<mime-type type="application/vnd.splat">
<comment>3D Gaussians Splat File Format</comment>
<glob pattern="*.splat"/>
</mime-type>
</mime-info>
3 changes: 0 additions & 3 deletions plugins/native/module/vtkF3DSplatReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ vtkF3DSplatReader::vtkF3DSplatReader()
this->SetNumberOfInputPorts(0);
}

//----------------------------------------------------------------------------
vtkF3DSplatReader::~vtkF3DSplatReader() = default;

//----------------------------------------------------------------------------
int vtkF3DSplatReader::RequestData(
vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
Expand Down
9 changes: 6 additions & 3 deletions plugins/native/module/vtkF3DSplatReader.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/**
* @class vtkF3DSplatReader
* @brief VTK Reader for DRC files using Draco
* @brief VTK Reader for 3D Gaussians in binary .splat file format
*
* Reader for .splat 3D Gaussians files
* Reader for binary .splat files as defined in https://github.com/antimatter15/splat
* This reader will probably evolve until there is no standard defined yet
* An interesting discussion can be followed here:
* https://github.com/mkkellogg/GaussianSplats3D/issues/47
*/

#ifndef vtkF3DSplatReader_h
Expand All @@ -24,7 +27,7 @@ class vtkF3DSplatReader : public vtkPolyDataAlgorithm

protected:
vtkF3DSplatReader();
~vtkF3DSplatReader() override;
~vtkF3DSplatReader() override = default;

int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

Expand Down

0 comments on commit dd1652c

Please sign in to comment.