|
|
|
@ -76,10 +76,6 @@ async function init_wasm(state) {
@@ -76,10 +76,6 @@ async function init_wasm(state) {
|
|
|
|
|
'offset': state.wasm.exports.alloc_static(state.wasm.stroke_bytes), |
|
|
|
|
'used': 0, |
|
|
|
|
}, |
|
|
|
|
'line_threshold': { |
|
|
|
|
'offset': state.wasm.exports.alloc_static(state.wasm.stroke_bytes), |
|
|
|
|
'used': 0, |
|
|
|
|
}, |
|
|
|
|
'pressures': { |
|
|
|
|
'offset': state.wasm.exports.alloc_static(state.wasm.coords_bytes / 8), |
|
|
|
|
'used': 0 |
|
|
|
@ -94,8 +90,6 @@ async function init_wasm(state) {
@@ -94,8 +90,6 @@ async function init_wasm(state) {
|
|
|
|
|
mem, state.wasm.buffers['ys'].offset); |
|
|
|
|
state.wasm.buffers['coords_from'].tv = tv_create_on(Uint32Array, state.wasm.stroke_bytes / 4, |
|
|
|
|
mem, state.wasm.buffers['coords_from'].offset); |
|
|
|
|
state.wasm.buffers['line_threshold'].tv = tv_create_on(Float32Array, state.wasm.stroke_bytes / 4, |
|
|
|
|
mem, state.wasm.buffers['line_threshold'].offset); |
|
|
|
|
state.wasm.buffers['pressures'].tv = tv_create_on(Uint8Array, state.wasm.coords_bytes / 8, |
|
|
|
|
mem, state.wasm.buffers['pressures'].offset); |
|
|
|
|
|
|
|
|
@ -107,7 +101,6 @@ function wasm_ensure_by(state, nstrokes, ncoords) {
@@ -107,7 +101,6 @@ function wasm_ensure_by(state, nstrokes, ncoords) {
|
|
|
|
|
const buffers = state.wasm.buffers; |
|
|
|
|
|
|
|
|
|
const old_coords_from_offset = buffers['coords_from'].offset; |
|
|
|
|
const old_line_threshold_offset = buffers['line_threshold'].offset; |
|
|
|
|
const old_pressures_offset = buffers['pressures'].offset; |
|
|
|
|
|
|
|
|
|
const old_size_coords = state.wasm.coords_bytes; |
|
|
|
@ -139,20 +132,17 @@ function wasm_ensure_by(state, nstrokes, ncoords) {
@@ -139,20 +132,17 @@ function wasm_ensure_by(state, nstrokes, ncoords) {
|
|
|
|
|
buffers['xs'].offset = state.wasm.exports.alloc_static(state.wasm.coords_bytes / 2); |
|
|
|
|
buffers['ys'].offset = state.wasm.exports.alloc_static(state.wasm.coords_bytes / 2); |
|
|
|
|
buffers['coords_from'].offset = state.wasm.exports.alloc_static(state.wasm.stroke_bytes); |
|
|
|
|
buffers['line_threshold'].offset = state.wasm.exports.alloc_static(state.wasm.stroke_bytes); |
|
|
|
|
buffers['pressures'].offset = state.wasm.exports.alloc_static(state.wasm.coords_bytes / 8); |
|
|
|
|
|
|
|
|
|
buffers['xs'].tv = tv_create_on(Float32Array, state.wasm.coords_bytes / 8, mem, buffers['xs'].offset); |
|
|
|
|
buffers['ys'].tv = tv_create_on(Float32Array, state.wasm.coords_bytes / 8, mem, buffers['ys'].offset); |
|
|
|
|
buffers['coords_from'].tv = tv_create_on(Uint32Array, state.wasm.stroke_bytes / 4, mem, buffers['coords_from'].offset); |
|
|
|
|
buffers['line_threshold'].tv = tv_create_on(Float32Array, state.wasm.stroke_bytes / 4, mem, buffers['line_threshold'].offset); |
|
|
|
|
buffers['pressures'].tv = tv_create_on(Uint8Array, state.wasm.coords_bytes / 8, mem, buffers['pressures'].offset); |
|
|
|
|
|
|
|
|
|
// TODO: this should have been automatic maybe?
|
|
|
|
|
buffers['xs'].tv.size = buffers['xs'].used / 4; |
|
|
|
|
buffers['ys'].tv.size = buffers['ys'].used / 4; |
|
|
|
|
buffers['coords_from'].tv.size = buffers['coords_from'].used / 4; |
|
|
|
|
buffers['line_threshold'].tv.size = buffers['line_threshold'].used / 4; |
|
|
|
|
buffers['pressures'].tv.size = buffers['pressures'].used; |
|
|
|
|
|
|
|
|
|
const tmp = new Uint8Array(Math.max(state.wasm.coords_bytes, state.wasm.stroke_bytes)); // TODO: needed?
|
|
|
|
@ -161,9 +151,6 @@ function wasm_ensure_by(state, nstrokes, ncoords) {
@@ -161,9 +151,6 @@ function wasm_ensure_by(state, nstrokes, ncoords) {
|
|
|
|
|
tmp.set(new Uint8Array(mem, old_pressures_offset, buffers['pressures'].used)); |
|
|
|
|
memv.set(new Uint8Array(tmp.buffer, 0, buffers['pressures'].used), buffers['pressures'].offset); |
|
|
|
|
|
|
|
|
|
tmp.set(new Uint8Array(mem, old_line_threshold_offset, old_size_strokes)); |
|
|
|
|
memv.set(new Uint8Array(tmp.buffer, 0, old_size_strokes), buffers['line_threshold'].offset); |
|
|
|
|
|
|
|
|
|
tmp.set(new Uint8Array(mem, old_coords_from_offset, old_size_strokes)); |
|
|
|
|
memv.set(new Uint8Array(tmp.buffer, 0, old_size_strokes), buffers['coords_from'].offset); |
|
|
|
|
} |
|
|
|
@ -187,7 +174,6 @@ async function do_lod(state, context) {
@@ -187,7 +174,6 @@ async function do_lod(state, context) {
|
|
|
|
|
const indices_per_thread = Math.floor(context.clipped_indices.size / state.wasm.workers.length); |
|
|
|
|
const offsets = { |
|
|
|
|
'coords_from': buffers['coords_from'].offset, |
|
|
|
|
'line_threshold': buffers['line_threshold'].offset, |
|
|
|
|
'xs': buffers['xs'].offset, |
|
|
|
|
'ys': buffers['ys'].offset, |
|
|
|
|
'pressures': buffers['pressures'].offset, |
|
|
|
|