Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ jobs:

# Named for the platform-arch alone so the package job can download
# artifacts straight into dist/<platform-arch>/ without merging. Uploads
# the whole directory so win32 carries its d3dcompiler_47.dll along.
# the whole directory so win32 carries its d3dcompiler_47.dll and
# dxcompiler.dll along.
- name: Upload Artifact ⬆️
uses: actions/upload-artifact@v4
with:
Expand Down
16 changes: 16 additions & 0 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ async function createProject() {
// p1689 deps from 14 on) and the generate step fails. dawn.node doesn't
// use the C++20 module interface, so seed the check as off.
...addElemIf(isLinux, '-DDAWN_SUPPORTS_CXX_MODULES=OFF'),
// without built DXC, dawn forces d3d12 onto FXC, which was measured ~45x
// slower than DXC on a compute rasterizer and can hang the device
// (crbug.com/566251711). with it, dawn prefers DXC wherever the adapter
// supports shader model 6.0+. copyResult ships dxcompiler.dll alongside.
...addElemIf(isWin, '-DDAWN_USE_BUILT_DXC=ON'),
// dawn otherwise keeps DXC's asserts in release builds, where they trap.
...addElemIf(isWin, '-DDAWN_DXC_ENABLE_ASSERTS_IN_NDEBUG=OFF'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need to turn this off? Those asserts do a lot of work to make DXC safer to use.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We enable asserts in release primarily for security reasons. Keeping them off should make DXC run faster, although we've never measured the performance gain. Whether you want to enable this or not depends on the use-case for node-webgpu.

`-DCMAKE_BUILD_TYPE=${kConfig}`,
'-DCMAKE_CXX_VISIBILITY_PRESET=hidden',
'-DCMAKE_VISIBILITY_INLINES_HIDDEN=1',
Expand All @@ -80,6 +87,15 @@ async function copyResult(filepath, target) {
const dstFilename = path.join('dist', target, 'dawn.node');
fs.mkdirSync(path.dirname(dstFilename), {recursive: true});
fs.copyFileSync(srcFilename, dstFilename);
if (isWin) {
// dawn loads dxcompiler.dll from beside dawn.node at runtime, so ship it
// there along with DXC's license notices.
const dxcPath = path.join(kDawnPath, 'third_party', 'directx-shader-compiler', 'src');
fs.copyFileSync(path.join(filepath, kConfig, 'dxcompiler.dll'), path.join('dist', target, 'dxcompiler.dll'));
for (const notice of ['LICENSE.TXT', 'ThirdPartyNotices.txt']) {
fs.copyFileSync(path.join(dxcPath, notice), path.join('dist', target, `dxcompiler-${notice}`));
}
}
return dstFilename;
}

Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const isMac = process.platform === 'darwin';
const __dirname = dirname(fileURLToPath(import.meta.url));
const arch = isMac ? 'universal' : process.arch;
// One directory per platform-arch so each build can sit next to its own
// runtime deps (win32 needs its matching d3dcompiler_47.dll beside it).
// runtime deps (win32 needs its matching d3dcompiler_47.dll and
// dxcompiler.dll beside it).
const dawnNodePath = join(__dirname, 'dist', `${process.platform}-${arch}`, 'dawn.node');
const { create, globals } = require(dawnNodePath);

Expand Down
Loading