-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
1,267 additions
and
1,263 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,39 +1,39 @@ | ||
# Variables for paths | ||
WASI_SDK_PATH = ~/wasi-sdk-22.0/bin | ||
BINARYEN_PATH = ~/binaryen-version_112/bin | ||
|
||
# Variables for flags | ||
C_FLAGS = -DJS_PROGRESS=1 -DXA_DEBUG=0 -DXA_MULTITHREADED=0 -DXATLAS_C_API=1 -mnontrapping-fptoint \ | ||
-msign-ext -mbulk-memory -flto=full -ffast-math -ffp-contract=fast -fomit-frame-pointer \ | ||
-Wextra -Wall -DNDEBUG -Wextra -flto -fno-builtin -ffreestanding -fno-ident -nostartfiles | ||
LD_FLAGS = -Wl,--no-export-dynamic,--compress-relocations,--Bstatic \ | ||
-Wl,--strip-debug,--gc-sections,--no-entry,--export-dynamic,--initial-memory=131072 \ | ||
-Wl,--export=xatlasCreate,--export=xatlasDestroy,--export=xatlasAddMesh,--export=xatlasAddUvMesh \ | ||
-Wl,--export=xatlasComputeCharts,--export=xatlasPackCharts,--export=xatlasGenerate,--export=xatlasMeshDeclInit \ | ||
-Wl,--export=xatlasUvMeshDeclInit,--export=xatlasChartOptionsInit,--export=xatlasPackOptionsInit \ | ||
-Wl,--export=malloc,--export=realloc,--export=free,--export=copy_uv | ||
|
||
# Source files | ||
SRC_FILES = copy_uv.c xatlas/source/xatlas/xatlas.cpp | ||
|
||
# Targets | ||
all: xatlas-dbg.wasm xatlas-opt.wasm | ||
|
||
xatlas-dbg.wasm: $(SRC_FILES) | ||
$(WASI_SDK_PATH)/clang $(C_FLAGS) -DJS_DEBUG=1 -Og $(SRC_FILES) $(LD_FLAGS) \ | ||
-Wl,--export=xatlasAddMeshJoin,--export=xatlasAddMeshErrorString,--export=xatlasProgressCategoryString \ | ||
-o xatlas-dbg.wasm | ||
|
||
xatlas.wasm: $(SRC_FILES) | ||
$(WASI_SDK_PATH)/clang $(C_FLAGS) -DNDEBUG -O3 -Ofast -Os $(SRC_FILES) $(LD_FLAGS) \ | ||
-Wl,--strip-all,-O3,--lto-O3,--lto-CGO3 \ | ||
-o xatlas.wasm | ||
|
||
xatlas-opt.wasm: xatlas.wasm | ||
$(BINARYEN_PATH)/wasm-opt -O3 -O4 -s --directize --vacuum --zero-filled-memory --enable-nontrapping-float-to-int --enable-bulk-memory --strip-debug --strip-producers --strip-dwarf \ | ||
-o xatlas-opt.wasm xatlas.wasm | ||
|
||
clean: | ||
rm -f xatlas-dbg.wasm xatlas.wasm xatlas-opt.wasm | ||
|
||
.PHONY: all clean | ||
# Variables for paths | ||
WASI_SDK_PATH = ~/wasi-sdk-22.0/bin | ||
BINARYEN_PATH = ~/binaryen-version_112/bin | ||
|
||
# Variables for flags | ||
C_FLAGS = -DJS_PROGRESS=1 -DXA_DEBUG=0 -DXA_MULTITHREADED=0 -DXATLAS_C_API=1 -mnontrapping-fptoint \ | ||
-msign-ext -mbulk-memory -flto=full -ffast-math -ffp-contract=fast -fomit-frame-pointer \ | ||
-Wextra -Wall -DNDEBUG -Wextra -flto -fno-builtin -ffreestanding -fno-ident -nostartfiles | ||
LD_FLAGS = -Wl,--no-export-dynamic,--compress-relocations,--Bstatic \ | ||
-Wl,--strip-debug,--gc-sections,--no-entry,--export-dynamic,--initial-memory=131072 \ | ||
-Wl,--export=xatlasCreate,--export=xatlasDestroy,--export=xatlasAddMesh,--export=xatlasAddUvMesh \ | ||
-Wl,--export=xatlasComputeCharts,--export=xatlasPackCharts,--export=xatlasGenerate,--export=xatlasMeshDeclInit \ | ||
-Wl,--export=xatlasUvMeshDeclInit,--export=xatlasChartOptionsInit,--export=xatlasPackOptionsInit \ | ||
-Wl,--export=malloc,--export=realloc,--export=free,--export=copy_uv | ||
|
||
# Source files | ||
SRC_FILES = copy_uv.c xatlas/source/xatlas/xatlas.cpp | ||
|
||
# Targets | ||
all: xatlas-dbg.wasm xatlas-opt.wasm | ||
|
||
xatlas-dbg.wasm: $(SRC_FILES) | ||
$(WASI_SDK_PATH)/clang $(C_FLAGS) -DJS_DEBUG=1 -Og $(SRC_FILES) $(LD_FLAGS) \ | ||
-Wl,--export=xatlasAddMeshJoin,--export=xatlasAddMeshErrorString,--export=xatlasProgressCategoryString \ | ||
-o xatlas-dbg.wasm | ||
|
||
xatlas.wasm: $(SRC_FILES) | ||
$(WASI_SDK_PATH)/clang $(C_FLAGS) -DNDEBUG -O3 -Ofast -Os $(SRC_FILES) $(LD_FLAGS) \ | ||
-Wl,--strip-all,-O3,--lto-O3,--lto-CGO3 \ | ||
-o xatlas.wasm | ||
|
||
xatlas-opt.wasm: xatlas.wasm | ||
$(BINARYEN_PATH)/wasm-opt -O3 -O4 -s --directize --vacuum --zero-filled-memory --enable-nontrapping-float-to-int --enable-bulk-memory --strip-debug --strip-producers --strip-dwarf \ | ||
-o xatlas-opt.wasm xatlas.wasm | ||
|
||
clean: | ||
rm -f xatlas-dbg.wasm xatlas.wasm xatlas-opt.wasm | ||
|
||
.PHONY: all clean |
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,18 +1,18 @@ | ||
#include "./xatlas/source/xatlas/xatlas_c.h" | ||
#include <stdint.h> | ||
|
||
uint32_t copy_uv(xatlasAtlas * atlas, xatlasMesh * mesh, void * output) { | ||
const uint32_t vertex_count = mesh->vertexCount; | ||
uint32_t * original_index = (uint32_t *) output; | ||
float * uv = (float *) (original_index + vertex_count); | ||
const float width = atlas->width; | ||
const float height = atlas->height; | ||
|
||
for (uint32_t i = 0; i < vertex_count; i++) { | ||
const xatlasVertex * vertex = &mesh->vertexArray[i]; | ||
original_index[i] = vertex->xref; | ||
uv[i * 2] = vertex->uv[0] / width; | ||
uv[i * 2 + 1] = vertex->uv[1] / height; | ||
} | ||
return vertex_count; | ||
} | ||
#include "./xatlas/source/xatlas/xatlas_c.h" | ||
#include <stdint.h> | ||
|
||
uint32_t copy_uv(xatlasAtlas * atlas, xatlasMesh * mesh, void * output) { | ||
const uint32_t vertex_count = mesh->vertexCount; | ||
uint32_t * original_index = (uint32_t *) output; | ||
float * uv = (float *) (original_index + vertex_count); | ||
const float width = atlas->width; | ||
const float height = atlas->height; | ||
|
||
for (uint32_t i = 0; i < vertex_count; i++) { | ||
const xatlasVertex * vertex = &mesh->vertexArray[i]; | ||
original_index[i] = vertex->xref; | ||
uv[i * 2] = vertex->uv[0] / width; | ||
uv[i * 2 + 1] = vertex->uv[1] / height; | ||
} | ||
return vertex_count; | ||
} |
Oops, something went wrong.