Skip to content

Commit

Permalink
Fix typo in wgpu_device_create_sampler(), and other minor cleanup and…
Browse files Browse the repository at this point in the history
… asserts
  • Loading branch information
juj committed Jun 28, 2021
1 parent fe01a95 commit 9be14f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ macro(append_linker_flags_opts FLAGS)
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} ${FLAGS}")
endmacro()

macro(append_linker_flags_minsizerel FLAGS)
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} ${FLAGS}")
endmacro()

if (EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".html")

append_compiler_flags_debug("-g4")

append_linker_flags_debug("-g4")
append_linker_flags_debug("-s ASSERTIONS=1")

append_linker_flags("--js-library ${CMAKE_CURRENT_LIST_DIR}/lib/lib_webgpu.js")
append_linker_flags("--js-library ${CMAKE_CURRENT_LIST_DIR}/lib/lib_demo.js")
append_linker_flags("--js-library ${CMAKE_CURRENT_LIST_DIR}/lib/library_miniprintf.js")
Expand All @@ -36,12 +46,12 @@ if (EMSCRIPTEN)
append_linker_flags("--shell-file \"${CMAKE_SOURCE_DIR}/shell.html\"")
append_linker_flags("-s TOTAL_STACK=16KB -s INITIAL_MEMORY=128KB")
# append_linker_flags("-s ALLOW_MEMORY_GROWTH=1")
# append_linker_flags_opts("--closure 1 --closure-args \"--externs ${CMAKE_CURRENT_LIST_DIR}/lib/webgpu_closure_externs.js\"")
append_linker_flags_debug("-g4")
append_linker_flags_debug("-s ASSERTIONS=1")
append_linker_flags("-s USE_SDL=0 -s FILESYSTEM=0 -s AUTO_JS_LIBRARIES=0 -s DISABLE_EXCEPTION_THROWING=1")
append_linker_flags("-lmath.js -lhtml5.js -lint53.js")
append_compiler_flags_debug("-g4")

append_linker_flags_opts("--closure 1 --closure-args \"--externs ${CMAKE_CURRENT_LIST_DIR}/lib/webgpu_closure_externs.js\"")

append_linker_flags_minsizerel("-Oz")
endif()

include_directories("${CMAKE_CURRENT_LIST_DIR}/lib")
Expand Down
8 changes: 4 additions & 4 deletions lib/lib_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ mergeInto(LibraryManager.library, {
if (o['destroy']) o['destroy']();
// If the given object has derived objects (GPUTexture -> GPUTextureViews), delete those in a hierarchy as well.
if (o.derivedObjects) {
for(var d of o.derivedObjects) {
_wgpu_object_destroy(d);
}
o.derivedObjects.forEach(_wgpu_object_destroy);
}
// Finally erase reference to this object.
delete wgpu[object];
Expand Down Expand Up @@ -153,6 +151,7 @@ mergeInto(LibraryManager.library, {

// Acquire the new presentation context texture..
var texture = presentationContext['getCurrentTexture']();
{{{ wassert('texture'); }}}
if (texture != wgpu[1]) {
// ... and destroy previous special presentation context texture, if it was an old one.
_wgpu_object_destroy(1);
Expand Down Expand Up @@ -558,7 +557,7 @@ mergeInto(LibraryManager.library, {
device = wgpu[device];

descriptor >>= 2;
var desc = desc ? {
var desc = descriptor ? {
'addressModeU': _wgpuStrings[HEAPU32[descriptor]],
'addressModeV': _wgpuStrings[HEAPU32[descriptor+1]],
'addressModeW': _wgpuStrings[HEAPU32[descriptor+2]],
Expand Down Expand Up @@ -760,6 +759,7 @@ mergeInto(LibraryManager.library, {
}

var depthStencilView = wgpu[HEAPU32[descriptor]];
{{{ wassert('depthStencilView || !HEAPU32[descriptor]'); }}}
var desc = {
'colorAttachments': colorAttachments,
'depthStencilAttachment': depthStencilView ? {
Expand Down

0 comments on commit 9be14f0

Please sign in to comment.