Skip to content

Commit

Permalink
Fixes to build with latest Emscripten and spec
Browse files Browse the repository at this point in the history
Note: until the native builds catch-up this only works in the browser.
  • Loading branch information
cwoffenden committed Mar 5, 2024
1 parent c04468d commit fbaa7ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (EMSCRIPTEN)
# -s EVAL_CTORS=1

# Linker flags to optimize for smallest output code size
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ENVIRONMENT=web -s TEXTDECODER=2 -s ABORTING_MALLOC=0 -s ALLOW_MEMORY_GROWTH=0 -s SUPPORT_ERRNO=0 -s MALLOC=emmalloc -s NO_FILESYSTEM=1 --output_eol=linux")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ENVIRONMENT=web -s TEXTDECODER=2 -s ABORTING_MALLOC=0 -s ALLOW_MEMORY_GROWTH=0 -s MALLOC=emmalloc -s NO_FILESYSTEM=1 --output_eol=linux")
# -s MINIMAL_RUNTIME=2
elseif (WIN32)
file(GLOB_RECURSE platform_sources src/win/*)
Expand Down
11 changes: 2 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static char const triangle_frag_wgsl[] = R"(
static WGPUShaderModule createShader(const char* const code, const char* label = nullptr) {
WGPUShaderModuleWGSLDescriptor wgsl = {};
wgsl.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
wgsl.source = code;
wgsl.code = code;
WGPUShaderModuleDescriptor desc = {};
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl);
desc.label = label;
Expand Down Expand Up @@ -338,20 +338,13 @@ static bool redraw() {

WGPURenderPassColorAttachment colorDesc = {};
colorDesc.view = backBufView;
colorDesc.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
colorDesc.loadOp = WGPULoadOp_Clear;
colorDesc.storeOp = WGPUStoreOp_Store;
#ifdef __EMSCRIPTEN__
// Dawn has both clearValue/clearColor but only Color works; Emscripten only has Value
colorDesc.clearValue.r = 0.3f;
colorDesc.clearValue.g = 0.3f;
colorDesc.clearValue.b = 0.3f;
colorDesc.clearValue.a = 1.0f;
#else
colorDesc.clearColor.r = 0.3f;
colorDesc.clearColor.g = 0.3f;
colorDesc.clearColor.b = 0.3f;
colorDesc.clearColor.a = 1.0f;
#endif

WGPURenderPassDescriptor renderPass = {};
renderPass.colorAttachmentCount = 1;
Expand Down

0 comments on commit fbaa7ff

Please sign in to comment.