Skip to content

Instantly share code, notes, and snippets.

@greggman
Last active March 8, 2024 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greggman/56204ce464e85bb5ad6a174fa97ebc94 to your computer and use it in GitHub Desktop.
Save greggman/56204ce464e85bb5ad6a174fa97ebc94 to your computer and use it in GitHub Desktop.
Dawn Notes

Dawn Notes

https://dawn.googlesource.com/dawn.git/+/refs/heads/main/webgpu-cts/README.md

"bots" for compat

  • linux-dawn-rel
  • dawn-linux-x64-deps-rel

file tryserver.chromium.dawn.star

places for CTS

  1. the CTS repo: https://github.com/gpuweb/cts
  2. dawn: third_party/webgpu-cts
  3. chromum: src/third_party/webgpu-cts
  4. the chromum build src/out/Release/gen/third_party/dawn/third_party/webgpu-cts (built, so .js, not .ts)

telemetry uses 2, mostly, I think wpt tests use 4 built from 3, dawn uses 2

adding tests configs to CQ

edit infra/config/generated/testing/test_suites.pyl and infra/config/targets/basic_suites.star

then run the following 3 commands

infra/config/main.star
infra/config/scripts/sync-pyl-files.py
./testing/buildbot/generate_buildbot_json.py

running in bots manually to test

https://dawn.googlesource.com/dawn/+/refs/heads/main/webgpu-cts/README.md#running-a-local-cts-build-on-swarming

updating CTS for telemetry

# copy from CTS to dawn
cp -r /Users/gman/src/gpuweb/cts/src/* $S/chromium/src/third_party/dawn/third_party/webgpu-cts/src/
# remove old generated cts
rm -rf /Users/gman/src/chromium/src/out/Release/gen/third_party/dawn/third_party/webgpu-cts
# build
nr telemetry_gpu_integration_test
# run (compat mode example)
./testing/scripts/run_gpu_integration_test_as_googletest.py content/test/gpu/run_gpu_integration_test.py --isolated-script-test-output=$T/output.json --isolated-script-test-perf-output=$T/perftest-output.json webgpu_cts --show-stdout --browser=release --passthrough -v "--extra-browser-args=--enable-logging=stderr --use-webgpu-adapter=opengles --force-webgpu-compat --use-angle=gles-egl --no-sandbox" "--test-filter=*render_pipeline,sample_mask*" --retry-limit=1 --jobs=1 --use-webgpu-compat-mode --skip-post-test-cleanup-and-debug-info

skip first N tests

diff for src/chromium/src/third_party/catapult/third_party/typ/typ/runner.py to skip first N tests

diff --git a/third_party/typ/typ/runner.py b/third_party/typ/typ/runner.py
index 7f82d863a..e62067237 100644
--- a/third_party/typ/typ/runner.py
+++ b/third_party/typ/typ/runner.py
@@ -1072,6 +1072,8 @@ def _teardown_process(child):
 
     return (child.worker_num, res, exc)
 
+hacked_skip_count = 57000 #56540 #56510
+hacked_test_count = 0
 
 def _run_one_test(child, test_input):
     def _get_expected_results_and_retry_on_failure():
@@ -1083,6 +1085,10 @@ def _run_one_test(child, test_input):
             expected_results, should_retry_on_failure = {ResultType.Pass}, False
         return expected_results, should_retry_on_failure
 
+    global hacked_test_count
+    global hacked_skip_count
+    hacked_test_count = hacked_test_count + 1
+
     h = child.host
     pid = h.getpid()
     test_name = test_input.name
@@ -1106,7 +1112,7 @@ def _run_one_test(child, test_input):
         if child.all:
             unittest.skip = lambda reason: lambda x: x
             unittest.skipIf = lambda condition, reason: lambda x: x
-        elif ResultType.Skip in expected_results:
+        elif ResultType.Skip in expected_results or hacked_test_count <= hacked_skip_count:
             h.restore_output()
             return (Result(test_name, ResultType.Skip, started, 0,
                            child.worker_num, expected=expected_results,

Setup for XCode debugging

  1. see instructions for angle
  2. set lldbinit to
settings append target.source-map ../../ /Users/gman/src/chromium/src/third_party/dawn/
settings append target.source-map . /Users/gman/src/chromium/src/third_party/dawn/out/Debug

settings append target.process.thread.step-avoid-regexp ^Matcher
settings append target.process.thread.step-avoid-regexp ^DawnTestBase::
settings append target.process.thread.step-avoid-regexp ^internal::
settings append target.process.thread.step-avoid-regexp ^testing::

Build

autoninja -C cmake-build/

Run the cts similar to the bots

cd src/chromium/src/third_party/dawn
../../testing/scripts/run_gpu_integration_test_as_googletest.py ../../content/test/gpu/run_gpu_integration_test.py --isolated-script-test-output=$T/output.json --isolated-script-test-perf-output=$T/perftest-output.json webgpu_cts --show-stdout --browser=release --passthrough -v --extra-browser-args=--enable-logging=stderr "--test-filter=*image_copy*" --retry-limit=3 --jobs=4

remove --test-filter to run all of them

note: tests are run from ./out/Release/gen/third_party/dawn/third_party/webgpu-cts

Run the cts ref tests in the webgpu cts repo

cd $S/gpuweb/cts
node tools/run_wpt_ref_tests /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome <filter>

The filter is a simple str.contains(filter)

Run web cts ref tests in the chromium repo

(see above)

  • checkout the tests in src/chromium/src/third_party/webgpu-cts/src
cd $S/chromuium/src/third_party/webgpu-cts
rm -rf src
git clone $S/gpuweb/cts src

Each time you change a test you need to re-generate the CTS tests

(cd $S/chromium/src && ~/bin/depot_tools/python-bin/python3 third_party/webgpu-cts/scripts/gen_ts_dep_lists.py && ~/bin/depot_tools/python-bin/python3 third_party/webgpu-cts/scripts/run_regenerate_internal_cts_html.py && autoninja -C out/Release webgpu_blink_web_tests)

Then you can run a test, for example

(cd $S/chromium/src && ./out/Release/bin/run_webgpu_blink_web_tests --target Release --flag-specific=webgpu --isolated-script-test-filter='wpt_internal/webgpu/web_platform/reftests/canvas_composite_alpha_bgra8unorm_premultiplied_copy.https.html')

wildcards also work

(cd $S/chromium/src && ./out/Release/bin/run_webgpu_blink_web_tests --target Release --flag-specific=webgpu --isolated-script-test-filter='wpt_internal/webgpu/web_platform/reftests/*')

You can open the results with

open $S/chromium/src/out/Release/layout-test-results/results.html

Only if a test fails will it keep the 2 .PNG screen captures around in $S/chromium/src/out/Release/layout-test-results/wpt_internal/webgpu/web_platform/reftests/

Run node cts

./tools/run run-cts --backend metal --cts=third_party/webgpu-cts/ --node=/Users/gman/src/chromium/src/third_party/dawn/third_party/node/node-darwin-arm64/bin/node --dawn-node=./cmake-build/dawn.node 'webgpu:api,operation,command_buffer,image_copy:rowsPerImage_and_bytesPerRow:*'

or with local cts

./tools/run run-cts --backend metal --cts=$S/gpuweb/cts/ --node=/Users/gman/src/chromium/src/third_party/dawn/third_party/node/node-darwin-arm64/bin/node --dawn-node=./cmake-build/dawn.node 'webgpu:api,operation,command_buffer,image_copy:rowsPerImage_and_bytesPerRow:*'

Include METAL validation when running unittest or end2end test

out/Debug/dawn_end2end_tests "--gtest_filter=CopyTests_T2B*" --enable-backend-validation

Print Texture Copy Info (just as an example of printing)

std::ostringstream s;
s << absl::StrFormat("[%s]:", texture->GetFormat().format) << ", size:(" << texture->GetSize().width << ", " << texture->GetSize().height << ", " << texture->GetSize().depthOrArrayLayers << "), mip: " << src.mipLevel << "\n";
s << "copy (" << copyInfo.textureOrigin.x << ", " << copyInfo.textureOrigin.y << ", " << copyInfo.textureOrigin.z << ")"
          << ", (" << copyInfo.copyExtent.width << ", " << copyInfo.copyExtent.height << ", "<< copyInfo.copyExtent.depthOrArrayLayers << ")\n"
          << "    bufferOffset: " << bufferOffset << "\n"
          << "    bytesPerRow: " << copyInfo.bytesPerRow << "\n"
          << "    bytesPerImage: " << copyInfo.bytesPerImage << "\n";
std::cerr << s.str();

run dawn.node with swiftshader on Mac (haven't tried)

Build swiftshader, and set VK_ICD_FILENAMES to the vk_swiftshader_icd.json file in the output directory. Example:

VK_ICD_FILENAMES=path_to_vk_swiftshader_icd.json tools/run run-cts 'webgpu:shader,execution,expression,binary,f16_subtraction:*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment