Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8c5f64d
add capacity semantics to ManagedBuffer
nmwsharp May 4, 2026
735a44c
make ManagedBuffer own the .data buffer, rather than wrapping it
nmwsharp May 4, 2026
e2a8ebc
ManagedBuffer now owns data arrays, rather than wrapping
nmwsharp May 9, 2026
a759ef6
pass managed buffers directly to shaders, change lazy update strategy
nmwsharp May 9, 2026
20eb643
bugfix with new setter
nmwsharp May 9, 2026
7e9995e
remove duplicated lines
nmwsharp May 9, 2026
4b967f8
avoid duplicate mark
nmwsharp May 9, 2026
89e14cf
additional cleanup of ManagedBuffer api
nmwsharp May 9, 2026
6557ac3
slight cleanup, use managed buffer for index
nmwsharp May 10, 2026
47a2965
set drawCount explicitly
nmwsharp May 20, 2026
d092631
add some unit tests for new managed buffer logic
nmwsharp Nov 22, 2026
c009f07
rename getIndexedView and fix capacity related bug
nmwsharp Nov 22, 2026
5f9c5a0
bugfixes and capacity cleanup
nmwsharp Nov 23, 2026
c9cc2d8
support partial setData uploads
nmwsharp Nov 23, 2026
bace841
initial work on simple triangle vertex and face quantities
nmwsharp Mar 25, 2026
ea5c760
clean up unfiorms
nmwsharp Mar 25, 2026
40d6d7b
quantities on simple triangle meshes
nmwsharp Apr 5, 2026
adc7de3
clean up quantities, implement picking for SimpleTriangleMesh
nmwsharp Apr 6, 2026
b89fcc1
initial support for updates in SimpleTriangleMesh
nmwsharp May 4, 2026
51f3f67
update for new managed buffer setup
nmwsharp May 10, 2026
60a13f4
add forced update option for object bounds
nmwsharp May 10, 2026
66a103e
remove redundant updaters
nmwsharp May 10, 2026
073701a
naming fixes
nmwsharp May 10, 2026
4a799c4
update SimpleTriangleMesh for new buffer conventions
nmwsharp Nov 23, 2026
0b9c058
add better warnings around 1d texture size
nmwsharp Nov 23, 2026
c8a6a2c
add support for GLBufferTextures from attributes, generalize texture …
nmwsharp Nov 24, 2026
60bb35d
add edge wireframe support to SimpleTriangleMesh
nmwsharp Nov 24, 2026
10fa034
fix premultiplied alpha
nmwsharp Nov 24, 2026
3dde74b
fix packages for latest github actions
nmwsharp Nov 25, 2026
0992207
avoid reference inside constructor lambda for MSVC
nmwsharp Nov 25, 2026
4eb69e0
limit parallel builds in CI
nmwsharp Nov 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
submodules: true

- name: install packages
run: sudo apt-get update && sudo apt-get install -y xorg-dev libglu1-mesa-dev xpra xserver-xorg-video-dummy freeglut3-dev
run: sudo apt-get update && sudo apt-get install -y xorg-dev libglu1-mesa-dev libegl-dev libgl1-mesa-dri

- name: configure
run: cd test && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DPOLYSCOPE_BACKEND_OPENGL3_GLFW=ON -DPOLYSCOPE_BACKEND_OPENGL_MOCK=ON ..

- name: build
run: cd test/build && cmake --build "." --parallel
run: cd test/build && cmake --build "." --parallel 4

- name: run test mock backend
run: cd test/build && ./bin/polyscope-test --gtest_catch_exceptions=0 backend=openGL_mock
Expand Down Expand Up @@ -65,13 +65,13 @@ jobs:
submodules: true

- name: install packages
run: sudo apt-get update && sudo apt-get install -y xorg-dev libglu1-mesa-dev xpra xserver-xorg-video-dummy freeglut3-dev
run: sudo apt-get update && sudo apt-get install -y xorg-dev libglu1-mesa-dev libegl-dev libgl1-mesa-dri

- name: configure
run: cd test && mkdir build && cd build && cmake -DBUILD_SHARED_LIBS=TRUE -DCMAKE_BUILD_TYPE=Debug -DPOLYSCOPE_BACKEND_OPENGL3_GLFW=ON -DPOLYSCOPE_BACKEND_OPENGL_MOCK=ON -DPOLYSCOPE_BACKEND_OPENGL3_EGL=ON ..

- name: build
run: cd test/build && cmake --build "." --parallel
run: cd test/build && cmake --build "." --parallel 4

- name: run test mock backend
run: cd test/build && ./bin/polyscope-test --gtest_catch_exceptions=0 backend=openGL_mock
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: cd test && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DPOLYSCOPE_BACKEND_OPENGL3_GLFW=ON -DPOLYSCOPE_BACKEND_OPENGL_MOCK=ON ..

- name: build
run: cd test/build && cmake --build "." --parallel
run: cd test/build && cmake --build "." --parallel 4

- name: run test
run: cd test/build && ./bin/polyscope-test --gtest_catch_exceptions=0 backend=openGL_mock
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
run: cd test && mkdir build && cd build && cmake -DBUILD_SHARED_LIBS=TRUE -DCMAKE_BUILD_TYPE=Debug -DPOLYSCOPE_BACKEND_OPENGL3_GLFW=ON -DPOLYSCOPE_BACKEND_OPENGL_MOCK=ON ..

- name: build
run: cd test/build && cmake --build "." --parallel
run: cd test/build && cmake --build "." --parallel 4

- name: run test
run: cd test/build && ./bin/polyscope-test --gtest_catch_exceptions=0 backend=openGL_mock
9 changes: 8 additions & 1 deletion examples/demo-app/demo_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void processFileOBJ(std::string filename) {
}
auto psMesh = polyscope::registerSurfaceMesh(niceName, vertexPositionsGLM, faceIndices);

auto psSimpleMesh = polyscope::registerSimpleTriangleMesh(niceName, vertexPositionsGLM, faceIndices);
auto psSimpleMesh = polyscope::registerSimpleTriangleMesh(niceName + " (simple)", vertexPositionsGLM, faceIndices);
psSimpleMesh->setEnabled(false);

// Useful data
Expand Down Expand Up @@ -154,6 +154,10 @@ void processFileOBJ(std::string filename) {
polyscope::getSurfaceMesh(niceName)->addVertexScalarQuantity("categorical vert", valCat,
polyscope::DataType::CATEGORICAL);

// Simple triangle mesh quantities
psSimpleMesh->addVertexScalarQuantity("cY", valY);
psSimpleMesh->addVertexColorQuantity("vColor", randColor);

polyscope::getSurfaceMesh(niceName)->addVertexDistanceQuantity("cY_dist", valY);
polyscope::getSurfaceMesh(niceName)->addVertexSignedDistanceQuantity("cY_signeddist", valY);

Expand Down Expand Up @@ -186,6 +190,9 @@ void processFileOBJ(std::string filename) {
polyscope::getSurfaceMesh(niceName)->addFaceScalarQuantity("categorical face", fCat,
polyscope::DataType::CATEGORICAL);

psSimpleMesh->addFaceScalarQuantity("face area", fArea, polyscope::DataType::MAGNITUDE);
psSimpleMesh->addFaceColorQuantity("fColor", fColor);


// size_t nEdges = psMesh->nEdges();

Expand Down
2 changes: 0 additions & 2 deletions include/polyscope/color_image_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class ColorImageQuantity : public ImageQuantity {


protected:
std::vector<glm::vec4> colorsData;

PersistentValue<bool> isPremultiplied;

// rendering internals
Expand Down
2 changes: 0 additions & 2 deletions include/polyscope/color_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class ColorQuantity {
// === ~DANGER~ experimental/unsupported functions

protected:
std::vector<glm::vec3> colorsData;

// === Visualization parameters

// Parameters
Expand Down
6 changes: 4 additions & 2 deletions include/polyscope/color_quantity.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace polyscope {

template <typename QuantityT>
ColorQuantity<QuantityT>::ColorQuantity(QuantityT& quantity_, const std::vector<glm::vec3>& colors_)
: quantity(quantity_), colors(&quantity, quantity.uniquePrefix() + "colors", colorsData), colorsData(colors_) {
: quantity(quantity_), colors(&quantity, quantity.uniquePrefix() + "colors", std::vector<glm::vec3>(colors_)) {
colors.checkInvalidValues();
}

Expand All @@ -27,7 +27,9 @@ template <typename QuantityT>
template <class V>
void ColorQuantity<QuantityT>::updateData(const V& newColors) {
validateSize(newColors, colors.size(), "color quantity");
colors.data = standardizeVectorArray<glm::vec3, 3>(newColors);
auto d = standardizeVectorArray<glm::vec3, 3>(newColors);
colors.resize(d.size());
colors.setDataHost(d);
colors.markHostBufferUpdated();
}

Expand Down
5 changes: 1 addition & 4 deletions include/polyscope/color_render_image_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class ColorRenderImageQuantity : public RenderImageQuantityBase {
protected:
// === Visualization parameters

// Store the raw data
std::vector<glm::vec3> colorsData;

// === Render data
std::shared_ptr<render::ShaderProgram> program;

Expand All @@ -60,7 +57,7 @@ void ColorRenderImageQuantity::updateBuffers(const T1& depthData, const T2& norm
std::vector<glm::vec3> standardNormal(standardizeVectorArray<glm::vec3, 3>(normalData));
std::vector<glm::vec3> standardColor(standardizeVectorArray<glm::vec3, 3>(colorsData));

colors.data = standardColor;
colors.setDataHost(standardColor);
colors.markHostBufferUpdated();

updateBaseBuffers(standardDepth, standardNormal);
Expand Down
7 changes: 0 additions & 7 deletions include/polyscope/curve_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,6 @@ class CurveNetwork : public Structure {


private:
// Storage for the managed buffers above. You should generally interact with these through the managed buffers, not
// these members.
std::vector<glm::vec3> nodePositionsData;
std::vector<uint32_t> edgeTailIndsData;
std::vector<uint32_t> edgeTipIndsData;
std::vector<glm::vec3> edgeCentersData;

void computeEdgeCenters();

// === Visualization parameters
Expand Down
4 changes: 3 additions & 1 deletion include/polyscope/curve_network.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ CurveNetwork* registerCurveNetworkLoop2D(std::string name, const P& nodes) {
template <class V>
void CurveNetwork::updateNodePositions(const V& newPositions) {
validateSize(newPositions, nNodes(), "newPositions");
nodePositions.data = standardizeVectorArray<glm::vec3, 3>(newPositions);
auto d = standardizeVectorArray<glm::vec3, 3>(newPositions);
nodePositions.resize(d.size());
nodePositions.setDataHost(d);
nodePositions.markHostBufferUpdated();
recomputeGeometryIfPopulated();
}
Expand Down
3 changes: 0 additions & 3 deletions include/polyscope/curve_network_color_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ class CurveNetworkEdgeColorQuantity : public CurveNetworkColorQuantity {

render::ManagedBuffer<glm::vec3> nodeAverageColors;
void updateNodeAverageColors();

private:
std::vector<glm::vec3> nodeAverageColorsData;
};

} // namespace polyscope
3 changes: 0 additions & 3 deletions include/polyscope/curve_network_scalar_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ class CurveNetworkEdgeScalarQuantity : public CurveNetworkScalarQuantity {

render::ManagedBuffer<float> nodeAverageValues;
void updateNodeAverageValues();

private:
std::vector<float> nodeAverageValuesData;
};


Expand Down
3 changes: 0 additions & 3 deletions include/polyscope/parameterization_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class ParameterizationQuantity {
void setParameterizationUniforms(render::ShaderProgram& p);

protected:
// Raw storage for the data. You should only interact with this via the managed buffer above
std::vector<glm::vec2> coordsData;
std::vector<float> islandLabelsData;
bool islandLabelsPopulated = false;

// === Visualization parameters
Expand Down
9 changes: 5 additions & 4 deletions include/polyscope/parameterization_quantity.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ ParameterizationQuantity<QuantityT>::ParameterizationQuantity(QuantityT& quantit
: quantity(quantity_),

// buffers
coords(&quantity, quantity.uniquePrefix() + "#coords", coordsData),
islandLabels(&quantity, quantity.uniquePrefix() + "#islandLabels", islandLabelsData), coordsType(type_),
coordsData(coords_),
coords(&quantity, quantity.uniquePrefix() + "#coords", std::vector<glm::vec2>(coords_)),
islandLabels(&quantity, quantity.uniquePrefix() + "#islandLabels", std::vector<float>{}), coordsType(type_),

// options
checkerSize(quantity.uniquePrefix() + "#checkerSize", 0.02),
Expand Down Expand Up @@ -227,7 +226,9 @@ template <typename QuantityT>
template <class V>
void ParameterizationQuantity<QuantityT>::updateCoords(const V& newCoords) {
validateSize(newCoords, coords.size(), "parameterization quantity " + quantity.name);
coords.data = standardizeVectorArray<glm::vec2, 2>(newCoords);
auto d = standardizeVectorArray<glm::vec2, 2>(newCoords);
coords.resize(d.size());
coords.setDataHost(d);
coords.markHostBufferUpdated();
}

Expand Down
50 changes: 50 additions & 0 deletions include/polyscope/pick.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const uint64_t bitsForPickPacking = 22;

inline glm::vec3 indToVec(size_t globalInd) {

// NOTE: there is a duplicate version of this logic in a macro below, which must be kept in sync.

// Can comfortably fit a 22 bit integer exactly in a single precision float
uint64_t factor = 1 << bitsForPickPacking;
uint64_t mask = factor - 1;
Expand Down Expand Up @@ -48,5 +50,53 @@ inline uint64_t vecToInd(glm::vec3 vec) {
return ind;
}


// == Weird alternate implementation of indToVec()
// This is here because sometimes we want to evaluate the indToVec() bit-bashing logic in a shader, and get exactly
// the same result as the C++ version above. A GLSL implementation is not too bad, but it's hard to test to ensure
// it really matches.
//
// The solution here is a funky macro'd implementation, that compiles as C++ or GLSL. We compile it as C++ in the tests
// and verify it matches the usual indToVec() implementation, then compile it as GLSL in shaders.
//
// All of the macro stuff you see below is just boilerplate to make that possible.

#define POLYSCOPE_PICK_STR_H(...) #__VA_ARGS__
#define POLYSCOPE_PICK_STR(...) POLYSCOPE_PICK_STR_H(__VA_ARGS__)

// See note above. This is logic that is meant to be identical to indToVec().
// clang-format off
#define POLYSCOPE_PICK_INDEX_COLOR_BODY \
POLYSCOPE_PICK_UINT idxLow = pickStartLow + primID; \
POLYSCOPE_PICK_UINT carry = (idxLow < pickStartLow) ? 1u : 0u; \
POLYSCOPE_PICK_UINT idxHigh = pickStartHigh + carry; \
POLYSCOPE_PICK_UINT low22 = idxLow & 0x3FFFFFu; \
POLYSCOPE_PICK_UINT med22 = ((idxLow >> 22u) | (idxHigh << 10u)) & 0x3FFFFFu; \
POLYSCOPE_PICK_UINT high22 = (idxHigh >> 12u) & 0x3FFFFFu; \
return POLYSCOPE_PICK_VEC3(float(low22), float(med22), float(high22)) / 4194304.0f;
// clang-format on

// C++ version: compile the body with C++ types.
#define POLYSCOPE_PICK_UINT uint32_t
#define POLYSCOPE_PICK_VEC3 glm::vec3
inline glm::vec3 pickIndexToColorImpl(uint32_t pickStartLow, uint32_t pickStartHigh, uint32_t primID) {
POLYSCOPE_PICK_INDEX_COLOR_BODY
}
#undef POLYSCOPE_PICK_UINT
#undef POLYSCOPE_PICK_VEC3

// Convenience wrapper for C++ callers that have a combined uint64_t pickStart.
inline glm::vec3 pickIndexToColor(uint64_t pickStart, uint32_t primID) {
return pickIndexToColorImpl(static_cast<uint32_t>(pickStart & 0xFFFFFFFFull), static_cast<uint32_t>(pickStart >> 32),
primID);
}

// GLSL string macro. Stringifies POLYSCOPE_PICK_INDEX_COLOR_BODY using GLSL type names.
// REQUIRES: POLYSCOPE_PICK_UINT must equal "uint" and POLYSCOPE_PICK_VEC3 must equal "vec3"
// at the point of expansion (see common.cpp for the usage pattern).
#define POLYSCOPE_PICK_INDEX_TO_COLOR_GLSL \
"vec3 pickIndexToColor(uint pickStartLow, uint pickStartHigh, uint primID) { " POLYSCOPE_PICK_STR( \
POLYSCOPE_PICK_INDEX_COLOR_BODY) " }"

} // namespace pick
} // namespace polyscope
2 changes: 0 additions & 2 deletions include/polyscope/point_cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ class PointCloud : public Structure {


private:
// Storage for the managed buffers above. You should generally interact with this directly through them.
std::vector<glm::vec3> pointsData;

// === Visualization parameters
PersistentValue<std::string> pointRenderMode;
Expand Down
4 changes: 3 additions & 1 deletion include/polyscope/point_cloud.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ PointCloud* registerPointCloud2D(std::string name, const T& points) {
template <class V>
void PointCloud::updatePointPositions(const V& newPositions) {
validateSize(newPositions, nPoints(), "point cloud updated positions " + name);
points.data = standardizeVectorArray<glm::vec3, 3>(newPositions);
auto d = standardizeVectorArray<glm::vec3, 3>(newPositions);
points.resize(d.size());
points.setDataHost(d);
points.markHostBufferUpdated();
}

Expand Down
1 change: 1 addition & 0 deletions include/polyscope/polyscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ void drawStructuresDelayed();
// need to call this directly.
void processLazyProperties();
void processLazyPropertiesOutsideOfImGui();
void forceRecomputeAllStructureBounds();


} // namespace polyscope
5 changes: 1 addition & 4 deletions include/polyscope/raw_color_alpha_render_image_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class RawColorAlphaRenderImageQuantity : public RenderImageQuantityBase {
bool getIsPremultiplied();

protected:
// Store the raw data
std::vector<glm::vec4> colorsData;

// === Visualization parameters
PersistentValue<bool> isPremultiplied;

Expand All @@ -59,7 +56,7 @@ void RawColorAlphaRenderImageQuantity::updateBuffers(const T1& depthData, const
std::vector<glm::vec3> standardNormal;
std::vector<glm::vec4> standardColor(standardizeVectorArray<glm::vec4, 4>(colorsData));

colors.data = standardColor;
colors.setDataHost(standardColor);
colors.markHostBufferUpdated();

updateBaseBuffers(standardDepth, standardNormal);
Expand Down
5 changes: 1 addition & 4 deletions include/polyscope/raw_color_render_image_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class RawColorRenderImageQuantity : public RenderImageQuantityBase {
protected:
// === Visualization parameters

// Store the raw data
std::vector<glm::vec3> colorsData;

// === Render data
std::shared_ptr<render::ShaderProgram> program;

Expand All @@ -56,7 +53,7 @@ void RawColorRenderImageQuantity::updateBuffers(const T1& depthData, const T2& c
std::vector<glm::vec3> standardNormal;
std::vector<glm::vec3> standardColor(standardizeVectorArray<glm::vec3, 3>(colorsData));

colors.data = standardColor;
colors.setDataHost(standardColor);
colors.markHostBufferUpdated();

updateBaseBuffers(standardDepth, standardNormal);
Expand Down
Loading
Loading