-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
152 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
add_subdirectory(private) | ||
add_subdirectory(public) | ||
add_subdirectory(private) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
set(shader_files | ||
glsl/vtkF3DBitonicSortGlobalDisperseCS.glsl | ||
glsl/vtkF3DBitonicSortGlobalFlipCS.glsl | ||
glsl/vtkF3DBitonicSortLocalDisperseCS.glsl | ||
glsl/vtkF3DBitonicSortLocalSortCS.glsl | ||
glsl/vtkF3DBitonicSortFunctions.glsl) | ||
|
||
foreach(file IN LISTS shader_files) | ||
vtk_encode_string( | ||
INPUT "${file}" | ||
HEADER_OUTPUT header | ||
SOURCE_OUTPUT source) | ||
list(APPEND sources | ||
"${source}") | ||
list(APPEND private_headers | ||
"${header}") | ||
endforeach() | ||
|
||
set(classes | ||
vtkF3DFaceVaryingPointDispatcher | ||
) | ||
|
||
# Needs https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10675 | ||
if(NOT ANDROID AND NOT EMSCRIPTEN AND VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240203) | ||
set(classes ${classes} vtkF3DBitonicSort) | ||
endif() | ||
|
||
vtk_module_add_module(f3d::vtkext | ||
CLASSES ${classes}) | ||
CLASSES ${classes} | ||
SOURCES ${sources} | ||
PRIVATE_HEADERS ${private_headers} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#include <vtkOpenGLBufferObject.h> | ||
#include <vtkOpenGLRenderWindow.h> | ||
#include <vtkShader.h> | ||
|
||
#include "vtkF3DBitonicSort.h" | ||
#include "vtkF3DBitonicSortFunctions.h" | ||
#include "vtkF3DBitonicSortGlobalDisperseCS.h" | ||
#include "vtkF3DBitonicSortGlobalFlipCS.h" | ||
#include "vtkF3DBitonicSortLocalDisperseCS.h" | ||
#include "vtkF3DBitonicSortLocalSortCS.h" | ||
|
||
#include <algorithm> | ||
#include <random> | ||
|
||
int TestF3DBitonicSort(int argc, char* argv[]) | ||
{ | ||
// Turn off VTK error reporting to avoid unwanted failure detection by ctest | ||
vtkObject::GlobalWarningDisplayOff(); | ||
|
||
// we need an OpenGL context | ||
vtkNew<vtkRenderWindow> renWin; | ||
renWin->OffScreenRenderingOn(); | ||
renWin->Start(); | ||
|
||
if (!vtkShader::IsComputeShaderSupported()) | ||
{ | ||
std::cerr << "Compute shaders are not supported on this system, skipping the test.\n"; | ||
return EXIT_SUCCESS; | ||
} | ||
|
||
constexpr int nbElements = 10000; | ||
|
||
// fill CPU keys and values buffers | ||
std::vector<double> keys(nbElements); | ||
std::vector<int> values(nbElements); | ||
|
||
std::random_device dev; | ||
std::mt19937 rng(dev()); | ||
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 | ||
|
||
// upload these buffers to the GPU | ||
vtkNew<vtkOpenGLBufferObject> bufferKeys; | ||
vtkNew<vtkOpenGLBufferObject> bufferValues; | ||
|
||
bufferKeys->Upload(keys, vtkOpenGLBufferObject::ArrayBuffer); | ||
bufferValues->Upload(values, vtkOpenGLBufferObject::ArrayBuffer); | ||
|
||
// sort | ||
vtkNew<vtkF3DBitonicSort> sorter; | ||
|
||
// check invalid workgroup size | ||
if (sorter->Initialize(-1, VTK_FLOAT, VTK_FLOAT)) | ||
{ | ||
std::cerr << "The invalid workgroup size is not failing" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
// check invalid types | ||
if (sorter->Initialize(128, VTK_CHAR, VTK_FLOAT)) | ||
{ | ||
std::cerr << "The invalid key type is not failing" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (sorter->Initialize(128, VTK_FLOAT, VTK_CHAR)) | ||
{ | ||
std::cerr << "The invalid key type is not failing" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (sorter->Run( | ||
vtkOpenGLRenderWindow::SafeDownCast(renWin), nbElements, bufferKeys, bufferValues)) | ||
{ | ||
std::cerr << "Uninitialized run is not failing" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!sorter->Initialize(128, VTK_DOUBLE, VTK_INT)) | ||
{ | ||
std::cerr << "Valid Initialize call failed" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!sorter->Run( | ||
vtkOpenGLRenderWindow::SafeDownCast(renWin), nbElements, bufferKeys, bufferValues)) | ||
{ | ||
std::cerr << "Sorter Run call failed" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
// download sorted key buffer to CPU | ||
bufferKeys->Download(keys.data(), keys.size()); | ||
|
||
// check if correctly sorted | ||
for (int i = 1; i < nbElements; i++) | ||
{ | ||
if (keys[i - 1] > keys[i]) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.