Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdf interpreter #1122

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
05e64d7
init sdf eval stuff
pca006132 Dec 22, 2024
d065f1d
initial codegen
pca006132 Dec 23, 2024
c62ccf6
fix control flow
pca006132 Dec 24, 2024
6e4fe65
use size_t for i
pca006132 Dec 24, 2024
01ef224
fixes
pca006132 Dec 24, 2024
6104170
fix simple error
pca006132 Dec 24, 2024
e3e1ddb
add reschedule
pca006132 Dec 24, 2024
a702cc8
remove prints
pca006132 Dec 24, 2024
05107c9
common subexpression elimination
pca006132 Dec 24, 2024
dbad415
clear cache to avoid having stale data
pca006132 Dec 24, 2024
6b1fa4b
format
pca006132 Dec 24, 2024
366d91c
proper spilling
pca006132 Dec 24, 2024
4a9f62e
pleaase msvc
pca006132 Dec 24, 2024
9f01e3f
optimize a bit
pca006132 Dec 25, 2024
2a864ed
fix small_vector
pca006132 Dec 25, 2024
6bd7bfe
update register allocation
pca006132 Dec 25, 2024
1045db7
further fixes
pca006132 Dec 25, 2024
c11d1e6
fix small_vector
pca006132 Dec 25, 2024
53523bb
simplify
pca006132 Dec 25, 2024
f960290
simplify code
pca006132 Dec 26, 2024
181bf17
idea about optimizing tape
pca006132 Dec 26, 2024
3e71d27
format
pca006132 Dec 26, 2024
7eeb12a
remove incorrect constexpr
pca006132 Dec 27, 2024
82627c9
speedup codegen
pca006132 Dec 27, 2024
36321cd
avoid recursive value drop
pca006132 Dec 27, 2024
7cbc4de
do some optimizations
pca006132 Dec 27, 2024
2da5ffb
fix small_vector, really dumb
pca006132 Dec 28, 2024
d261422
more optimization
pca006132 Dec 28, 2024
f596295
make affine value optimization more general
pca006132 Dec 28, 2024
19d4111
generate negation
pca006132 Dec 28, 2024
b989c06
bypass more simplification
pca006132 Dec 28, 2024
5f1c19f
remove fixme
pca006132 Dec 28, 2024
1555326
affine value optimization subsumes constant propagation
pca006132 Dec 29, 2024
d0df1fb
simplify code
pca006132 Dec 29, 2024
486c762
simplify further
pca006132 Dec 29, 2024
5ad914f
fixed some bugs and simplify a bit
pca006132 Dec 29, 2024
9716bc3
update optimizing_tape
pca006132 Dec 29, 2024
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
2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $CLANG_FORMAT -i bindings/wasm/*.{js,ts} &
$CLANG_FORMAT -i bindings/wasm/examples/*.{js,ts,html} &
$CLANG_FORMAT -i bindings/wasm/examples/public/*.{js,ts} &
$CLANG_FORMAT -i src/*.{h,cpp} &
$CLANG_FORMAT -i src/*/*.cpp &
$CLANG_FORMAT -i src/*/*.{h,cpp} &
$CLANG_FORMAT -i include/manifold/*.h &

black --quiet bindings/python/examples/*.py &
Expand Down
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ set(
smoothing.cpp
sort.cpp
subdivision.cpp
sdf/value.cpp
sdf/context.cpp
# optional source files
$<$<BOOL:${MANIFOLD_CROSS_SECTION}>:cross_section/cross_section.cpp>
$<$<BOOL:${MANIFOLD_EXPORT}>:meshIO/meshIO.cpp>
Expand All @@ -51,6 +53,10 @@ set(
tri_dist.h
utils.h
vec.h
sdf/interval.h
sdf/tape.h
sdf/value.h
sdf/context.h
)

# Include directories
Expand Down
1 change: 1 addition & 0 deletions src/sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ Manifold Manifold::LevelSet(std::function<double(vec3)> sdf, Box bounds,

const vec3 origin = bounds.min;
Vec<double> voxels(maxIndex);

for_each_n(
pol, countAt(0_uz), maxIndex,
[&voxels, sdf, level, origin, spacing, gridSize, gridPow](Uint64 idx) {
Expand Down
42 changes: 42 additions & 0 deletions src/sdf/affine_value.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 The Manifold Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once

#include "context.h"

namespace manifold::sdf {
struct AffineValue {
// value = var * a + b
Operand var;
double a;
double b;

AffineValue(Operand var, double a, double b) : var(var), a(a), b(b) {}
AffineValue(double constant) : var(Operand::none()), a(0.0), b(constant) {}
bool operator==(const AffineValue &other) const {

Check warning on line 27 in src/sdf/affine_value.h

View check run for this annotation

Codecov / codecov/patch

src/sdf/affine_value.h#L26-L27

Added lines #L26 - L27 were not covered by tests
return var == other.var && a == other.a && b == other.b;
}
AffineValue operator+(double d) { return AffineValue(var, a, b + d); }
AffineValue operator*(double d) { return AffineValue(var, a * d, b * d); }
};
} // namespace manifold::sdf

template <>
struct std::hash<AffineValue> {
size_t operator()(const AffineValue &value) const {

Check warning on line 37 in src/sdf/affine_value.h

View check run for this annotation

Codecov / codecov/patch

src/sdf/affine_value.h#L37

Added line #L37 was not covered by tests
size_t h = std::hash<int>()(value.var.id);
hash_combine(h, value.a, value.b);
return h;
}
};
Loading
Loading