Merge remote-tracking branch 'upstream/main'

This commit is contained in:
Luke Street 2022-08-29 13:51:59 -04:00
commit 73f3dde770
26768 changed files with 853351 additions and 247635 deletions

View File

@ -7,4 +7,4 @@ ColumnLimit: 100
IndentWidth: 4
ObjCBlockIndentWidth: 4
AccessModifierOffset: -2
InsertBraces: true

163
.clang-tidy Normal file
View File

@ -0,0 +1,163 @@
FormatStyle: file
Checks: "-*,\
abseil-*,\
-abseil-string-find-startswith,\
-abseil-string-find-str-contains,\
bugprone-*,\
-bugprone-branch-clone,\
-bugprone-copy-constructor-init,\
-bugprone-easily-swappable-parameters,\
-bugprone-forwarding-reference-overload,\
-bugprone-implicit-widening-of-multiplication-result,\
-bugprone-lambda-function-name,\
-bugprone-macro-parentheses,\
-bugprone-misplaced-widening-cast,\
-bugprone-narrowing-conversions,\
-bugprone-parent-virtual-call,\
-bugprone-reserved-identifier,\
-bugprone-signed-char-misuse,\
-bugprone-sizeof-expression,\
-bugprone-string-constructor,\
-bugprone-suspicious-include,\
-bugprone-too-small-loop-variable,\
-bugprone-unhandled-self-assignment,\
-bugprone-use-after-move,\
cert-*,\
-cert-dcl16-c,\
-cert-dcl21-cpp,\
-cert-dcl37-c,\
-cert-dcl50-cpp,\
-cert-dcl51-cpp,\
-cert-dcl54-cpp,\
-cert-dcl58-cpp,\
-cert-err33-c,\
-cert-msc30-c,\
-cert-msc32-c,\
-cert-msc50-cpp,\
-cert-msc51-cpp,\
-cert-oop54-cpp,\
-cert-str34-c,\
-cert-str34-c,\
-cert-str34-c,\
-cert-str34-c,\
-clang-analyzer-*,\
concurrency-*,\
-concurrency-mt-unsafe,\
cppcoreguidelines-*,\
-concurrency-mt-unsafe,\
-cppcoreguidelines-avoid-c-arrays,\
-cppcoreguidelines-avoid-goto,\
-cppcoreguidelines-avoid-magic-numbers,\
-cppcoreguidelines-avoid-non-const-global-variables,\
-cppcoreguidelines-c-copy-assignment-signature,\
-cppcoreguidelines-explicit-virtual-functions,\
-cppcoreguidelines-init-variables,\
-cppcoreguidelines-interfaces-global-init,\
-cppcoreguidelines-macro-usage,\
-cppcoreguidelines-narrowing-conversions,\
-cppcoreguidelines-no-malloc,\
-cppcoreguidelines-non-private-member-variables-in-classes,\
-cppcoreguidelines-owning-memory,\
-cppcoreguidelines-prefer-member-initializer,\
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,\
-cppcoreguidelines-pro-bounds-constant-array-index,\
-cppcoreguidelines-pro-bounds-pointer-arithmetic,\
-cppcoreguidelines-pro-type-const-cast,\
-cppcoreguidelines-pro-type-member-init,\
-cppcoreguidelines-pro-type-reinterpret-cast,\
-cppcoreguidelines-pro-type-static-cast-downcast,\
-cppcoreguidelines-pro-type-union-access,\
-cppcoreguidelines-pro-type-vararg,\
-cppcoreguidelines-slicing,\
-cppcoreguidelines-special-member-functions,\
-cppcoreguidelines-virtual-class-destructor,\
google-*,\
-google-default-arguments,\
-google-explicit-constructor,\
-google-readability-avoid-underscore-in-googletest-name,\
-google-readability-braces-around-statements,\
-google-readability-casting,\
-google-readability-namespace-comments,\
-google-readability-todo,\
-google-runtime-int,\
-google-upgrade-googletest-case,\
misc-*,\
-misc-misplaced-const,\
-misc-new-delete-overloads,\
-misc-non-private-member-variables-in-classes,\
-misc-no-recursion,\
-misc-redundant-expression,\
-misc-uniqueptr-reset-release,\
-misc-unconventional-assign-operator,\
-misc-unused-parameters,\
-misc-unused-using-decls,\
modernize-*,\
-modernize-avoid-c-arrays,\
-modernize-concat-nested-namespaces,\
-modernize-deprecated-headers,\
-modernize-loop-convert,\
-modernize-macro-to-enum,\
-modernize-make-unique,\
-modernize-pass-by-value,\
-modernize-raw-string-literal,\
-modernize-redundant-void-arg,\
-modernize-return-braced-init-list,\
-modernize-unary-static-assert,\
-modernize-use-auto,\
-modernize-use-bool-literals,\
-modernize-use-default-member-init,\
-modernize-use-emplace,\
-modernize-use-equals-default,\
-modernize-use-equals-delete,\
-modernize-use-nodiscard,\
-modernize-use-nullptr,\
-modernize-use-override,\
-modernize-use-trailing-return-type,\
-modernize-use-transparent-functors,\
-modernize-use-using,\
performance-*,\
-performance-faster-string-find,\
-performance-for-range-copy,\
-performance-inefficient-algorithm,\
-performance-inefficient-string-concatenation,\
-performance-inefficient-vector-operation,\
-performance-move-const-arg,\
-performance-no-automatic-move,\
-performance-noexcept-move-constructor,\
-performance-no-int-to-ptr,\
-performance-trivially-destructible,\
-performance-unnecessary-copy-initialization,\
-performance-unnecessary-value-param,\
portability-*,\
readability-*,\
-readability-avoid-const-params-in-decls,\
-readability-braces-around-statements,\
-readability-const-return-type,\
-readability-container-data-pointer,\
-readability-container-size-empty,\
-readability-convert-member-functions-to-static,\
-readability-else-after-return,\
-readability-function-cognitive-complexity,\
-readability-identifier-length,\
-readability-implicit-bool-conversion,\
-readability-inconsistent-declaration-parameter-name,\
-readability-isolate-declaration,\
-readability-magic-numbers,\
-readability-make-member-function-const,\
-readability-named-parameter,\
-readability-non-const-parameter,\
-readability-qualified-auto,\
-readability-redundant-access-specifiers,\
-readability-redundant-control-flow,\
-readability-redundant-declaration,\
-readability-redundant-member-init,\
-readability-redundant-smartptr-get,\
-readability-redundant-string-cstr,\
-readability-redundant-string-init,\
-readability-simplify-boolean-expr,\
-readability-static-accessed-through-instance,\
-readability-static-definition-in-anonymous-namespace,\
-readability-suspicious-call-argument,\
-readability-uppercase-literal-suffix,\
-readability-use-anyofallof
"

2
.gitattributes vendored
View File

@ -7,3 +7,5 @@
*.sh eol=lf
*.spvasm eol=lf
*.wgsl eol=lf
*.h eol=lf
*.cpp eol=lf

6
.gitignore vendored
View File

@ -4,6 +4,7 @@
/.cipd
/.gclient
/.gclient_entries
/.gclient_previous_sync_commits
/build
/buildtools
/testing
@ -97,4 +98,9 @@ coverage.summary
default.profraw
lcov.info
/cmake-build-*/
/build-*/
/testing
### Clang-Tidy files
all_findings.json

6
.gn
View File

@ -23,6 +23,7 @@ default_args = {
angle_enable_abseil = false
angle_standalone = false
angle_build_all = false
angle_build_tests = false
angle_has_rapidjson = false
angle_use_wayland = false
angle_vulkan_headers_dir = "//third_party/vulkan-deps/vulkan-headers/src"
@ -33,8 +34,3 @@ default_args = {
vma_vulkan_headers_dir = "//third_party/vulkan-deps/vulkan-headers/src"
}
no_check_targets = [
# TODO(crbug.com/dawn/1404): Issue with the Absl headers
"//src/dawn/tests:dawn_unittests",
]

View File

@ -20,10 +20,9 @@ group("all") {
"src/dawn/fuzzers",
"src/dawn/native:webgpu_dawn",
"src/dawn/tests",
"src/fuzzers/dawn:dawn_fuzzers",
"src/tint:libtint",
"src/tint:tint_unittests",
"src/tint/fuzzers",
"test/tint:tint_unittests",
]
if (dawn_standalone) {
deps += [

View File

@ -82,6 +82,7 @@ set(ENABLE_METAL OFF)
set(ENABLE_OPENGLES OFF)
set(ENABLE_DESKTOP_GL OFF)
set(ENABLE_VULKAN OFF)
set(USE_WAYLAND OFF)
set(USE_X11 OFF)
set(BUILD_SAMPLES OFF)
if (WIN32)
@ -113,8 +114,9 @@ if (DAWN_SUPPORTS_GLFW_FOR_WINDOWING)
set(BUILD_SAMPLES ON)
endif()
option_if_not_defined(DAWN_ENABLE_MSAN "Enable memory sanitizer" OFF)
option_if_not_defined(DAWN_ENABLE_ASAN "Enable address sanitizer" OFF)
option_if_not_defined(DAWN_ENABLE_TSAN "Enable thread sanitizer" OFF)
option_if_not_defined(DAWN_ENABLE_MSAN "Enable memory sanitizer" OFF)
option_if_not_defined(DAWN_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF)
option_if_not_defined(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12})
@ -123,7 +125,9 @@ option_if_not_defined(DAWN_ENABLE_NULL "Enable compilation of the Null backend"
option_if_not_defined(DAWN_ENABLE_DESKTOP_GL "Enable compilation of the OpenGL backend" ${ENABLE_DESKTOP_GL})
option_if_not_defined(DAWN_ENABLE_OPENGLES "Enable compilation of the OpenGL ES backend" ${ENABLE_OPENGLES})
option_if_not_defined(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN})
option_if_not_defined(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
option_if_not_defined(DAWN_USE_WAYLAND "Enable support for Wayland surface" ${USE_WAYLAND})
option_if_not_defined(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
option_if_not_defined(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" ${BUILD_SAMPLES})
@ -132,14 +136,46 @@ option_if_not_defined(DAWN_ENABLE_SWIFTSHADER "Enables building Swiftshader as p
option_if_not_defined(DAWN_ENABLE_PIC "Build with Position-Independent-Code enabled" OFF)
set_if_not_defined(DAWN_THIRD_PARTY_DIR "${Dawn_SOURCE_DIR}/third_party" "Directory in which to find third-party dependencies.")
if (DAWN_ENABLE_OPENGLES OR DAWN_ENABLE_DESKTOP_GL)
set(TINT_DEFAULT_GLSL ON)
else()
set(TINT_DEFAULT_GLSL OFF)
endif()
option_if_not_defined(TINT_BUILD_SAMPLES "Build samples" ${DAWN_BUILD_SAMPLES})
option_if_not_defined(TINT_BUILD_DOCS "Build documentation" ON)
option_if_not_defined(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF)
option_if_not_defined(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ${DAWN_ENABLE_VULKAN})
option_if_not_defined(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
option_if_not_defined(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ${TINT_DEFAULT_GLSL})
option_if_not_defined(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ${DAWN_ENABLE_D3D12})
option_if_not_defined(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ${DAWN_ENABLE_METAL})
option_if_not_defined(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN})
option_if_not_defined(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
option_if_not_defined(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
option_if_not_defined(TINT_BUILD_SPIRV_TOOLS_FUZZER "Build SPIRV-Tools fuzzer" OFF)
option_if_not_defined(TINT_BUILD_AST_FUZZER "Build AST fuzzer" OFF)
option_if_not_defined(TINT_BUILD_REGEX_FUZZER "Build regex fuzzer" OFF)
option_if_not_defined(TINT_BUILD_BENCHMARKS "Build benchmarks" OFF)
option_if_not_defined(TINT_BUILD_TESTS "Build tests" ON)
option_if_not_defined(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF)
option_if_not_defined(TINT_BUILD_REMOTE_COMPILE "Build the remote-compile tool for validating shaders on a remote machine" OFF)
option_if_not_defined(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF)
option_if_not_defined(TINT_EMIT_COVERAGE "Emit code coverage information" OFF)
option_if_not_defined(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF)
option_if_not_defined(TINT_SYMBOL_STORE_DEBUG_NAME "Enable storing of name in tint::ast::Symbol to help debugging the AST" OFF)
# Recommended setting for compability with future abseil releases.
set(ABSL_PROPAGATE_CXX_STD ON)
set_if_not_defined(DAWN_THIRD_PARTY_DIR "${Dawn_SOURCE_DIR}/third_party" "Directory in which to find third-party dependencies.")
set_if_not_defined(DAWN_ABSEIL_DIR "${DAWN_THIRD_PARTY_DIR}/abseil-cpp" "Directory in which to find Abseil")
set_if_not_defined(DAWN_GLFW_DIR "${DAWN_THIRD_PARTY_DIR}/glfw" "Directory in which to find GLFW")
set_if_not_defined(DAWN_JINJA2_DIR "${DAWN_THIRD_PARTY_DIR}/jinja2" "Directory in which to find Jinja2")
set_if_not_defined(DAWN_KHRONOS_DIR "${DAWN_THIRD_PARTY_DIR}/khronos" "Directory in which to find Khronos GL headers")
set_if_not_defined(DAWN_SPIRV_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-headers/src" "Directory in which to find SPIRV-Headers")
set_if_not_defined(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/src" "Directory in which to find SPIRV-Tools")
set_if_not_defined(DAWN_SWIFTSHADER_DIR "${DAWN_THIRD_PARTY_DIR}/swiftshader" "Directory in which to find swiftshader")
@ -163,160 +199,6 @@ if(DAWN_ENABLE_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
################################################################################
# common_compile_options - sets compiler and linker options common for dawn and
# tint on the given target
################################################################################
function(common_compile_options TARGET)
if (COMPILER_IS_LIKE_GNU)
target_compile_options(${TARGET} PRIVATE
-fno-exceptions
-fno-rtti
)
if (${DAWN_ENABLE_MSAN})
target_compile_options(${TARGET} PRIVATE -fsanitize=memory)
target_link_options(${TARGET} PRIVATE -fsanitize=memory)
elseif (${DAWN_ENABLE_ASAN})
target_compile_options(${TARGET} PRIVATE -fsanitize=address)
target_link_options(${TARGET} PRIVATE -fsanitize=address)
elseif (${DAWN_ENABLE_UBSAN})
target_compile_options(${TARGET} PRIVATE -fsanitize=undefined)
target_link_options(${TARGET} PRIVATE -fsanitize=undefined)
endif()
endif(COMPILER_IS_LIKE_GNU)
endfunction()
################################################################################
# Dawn's public and internal "configs"
################################################################################
# The public config contains only the include paths for the Dawn headers.
add_library(dawn_public_config INTERFACE)
target_include_directories(dawn_public_config INTERFACE
"${DAWN_INCLUDE_DIR}"
"${DAWN_BUILD_GEN_DIR}/include"
)
# The internal config conatins additional path but includes the dawn_public_config include paths
add_library(dawn_internal_config INTERFACE)
target_include_directories(dawn_internal_config INTERFACE
"${DAWN_SRC_DIR}"
"${DAWN_BUILD_GEN_DIR}/src"
)
target_link_libraries(dawn_internal_config INTERFACE dawn_public_config)
# Compile definitions for the internal config
if (DAWN_ALWAYS_ASSERT OR CMAKE_BUILD_TYPE STREQUAL Debug)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_ASSERTS")
endif()
if (DAWN_ENABLE_D3D12)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D12")
endif()
if (DAWN_ENABLE_METAL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_METAL")
endif()
if (DAWN_ENABLE_NULL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL")
endif()
if (DAWN_ENABLE_DESKTOP_GL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_DESKTOP_GL")
endif()
if (DAWN_ENABLE_OPENGLES)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGLES")
endif()
if (DAWN_ENABLE_OPENGL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL")
endif()
if (DAWN_ENABLE_VULKAN)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN")
endif()
if (DAWN_USE_X11)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11")
endif()
if (WIN32)
target_compile_definitions(dawn_internal_config INTERFACE "NOMINMAX" "WIN32_LEAN_AND_MEAN")
endif()
set(CMAKE_CXX_STANDARD "17")
################################################################################
# Tint
################################################################################
# TINT_IS_SUBPROJECT is 1 if added via add_subdirectory() from another project.
get_directory_property(TINT_IS_SUBPROJECT PARENT_DIRECTORY)
if(TINT_IS_SUBPROJECT)
set(TINT_IS_SUBPROJECT 1)
# If tint is used as a subproject, default to disabling the building of
# documentation and tests. These are unlikely to be desirable, but can be
# enabled.
set(TINT_BUILD_DOCS_DEFAULT OFF)
set(TINT_BUILD_TESTS_DEFAULT OFF)
else()
set(TINT_BUILD_DOCS_DEFAULT OFF)
set(TINT_BUILD_TESTS_DEFAULT OFF)
endif()
option_if_not_defined(TINT_BUILD_SAMPLES "Build samples" OFF)
option_if_not_defined(TINT_BUILD_DOCS "Build documentation" ${TINT_BUILD_DOCS_DEFAULT})
option_if_not_defined(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF)
option_if_not_defined(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ON)
option_if_not_defined(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
option_if_not_defined(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ON)
option_if_not_defined(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ON)
option_if_not_defined(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ON)
option_if_not_defined(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ON)
option_if_not_defined(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
option_if_not_defined(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
option_if_not_defined(TINT_BUILD_SPIRV_TOOLS_FUZZER "Build SPIRV-Tools fuzzer" OFF)
option_if_not_defined(TINT_BUILD_AST_FUZZER "Build AST fuzzer" OFF)
option_if_not_defined(TINT_BUILD_REGEX_FUZZER "Build regex fuzzer" OFF)
option_if_not_defined(TINT_BUILD_BENCHMARKS "Build benchmarks" OFF)
option_if_not_defined(TINT_BUILD_TESTS "Build tests" ${TINT_BUILD_TESTS_DEFAULT})
option_if_not_defined(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF)
option_if_not_defined(TINT_BUILD_REMOTE_COMPILE "Build the remote-compile tool for validating shaders on a remote machine" OFF)
set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used")
option_if_not_defined(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF)
option_if_not_defined(TINT_EMIT_COVERAGE "Emit code coverage information" OFF)
option_if_not_defined(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF)
option_if_not_defined(TINT_SYMBOL_STORE_DEBUG_NAME "Enable storing of name in tint::ast::Symbol to help debugging the AST" OFF)
message(STATUS "Tint build samples: ${TINT_BUILD_SAMPLES}")
message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}")
message(STATUS "Tint build docs with warn as error: ${TINT_DOCS_WARN_AS_ERROR}")
message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}")
message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}")
message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}")
message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}")
message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
message(STATUS "Tint build SPIRV-Tools fuzzer: ${TINT_BUILD_SPIRV_TOOLS_FUZZER}")
message(STATUS "Tint build AST fuzzer: ${TINT_BUILD_AST_FUZZER}")
message(STATUS "Tint build regex fuzzer: ${TINT_BUILD_REGEX_FUZZER}")
message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}")
message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}")
message(STATUS "Tint build with ASAN: ${DAWN_ENABLE_ASAN}")
message(STATUS "Tint build with MSAN: ${DAWN_ENABLE_MSAN}")
message(STATUS "Tint build with UBSAN: ${DAWN_ENABLE_UBSAN}")
message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}")
message(STATUS "Tint build remote-compile tool: ${TINT_BUILD_REMOTE_COMPILE}")
if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "")
message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}")
endif()
message(STATUS "Using python3")
find_package(PythonInterp 3 REQUIRED)
if (${TINT_BUILD_SPIRV_TOOLS_FUZZER})
message(STATUS "TINT_BUILD_SPIRV_TOOLS_FUZZER is ON - setting
TINT_BUILD_FUZZERS
@ -373,6 +255,150 @@ if (${TINT_BUILD_REGEX_FUZZER})
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
endif()
message(STATUS "Dawn build D3D12 backend: ${DAWN_ENABLE_D3D12}")
message(STATUS "Dawn build Metal backend: ${DAWN_ENABLE_METAL}")
message(STATUS "Dawn build Vulkan backend: ${DAWN_ENABLE_VULKAN}")
message(STATUS "Dawn build OpenGL backend: ${DAWN_ENABLE_DESKTOP_GL}")
message(STATUS "Dawn build OpenGL ES backend: ${DAWN_ENABLE_OPENGLES}")
message(STATUS "Dawn build Null backend: ${DAWN_ENABLE_NULL}")
message(STATUS "Dawn build with asserts in all configurations: ${DAWN_ALWAYS_ASSERT}")
message(STATUS "Dawn build Wayland support: ${DAWN_USE_WAYLAND}")
message(STATUS "Dawn build X11 support: ${DAWN_USE_X11}")
message(STATUS "Dawn build samples: ${DAWN_BUILD_SAMPLES}")
message(STATUS "Dawn build Node bindings: ${DAWN_BUILD_NODE_BINDINGS}")
message(STATUS "Dawn build Swiftshader: ${DAWN_ENABLE_SWIFTSHADER}")
message(STATUS "Dawn build PIC: ${DAWN_ENABLE_PIC}")
message(STATUS "Dawn build with ASAN: ${DAWN_ENABLE_ASAN}")
message(STATUS "Dawn build with TSAN: ${DAWN_ENABLE_TSAN}")
message(STATUS "Dawn build with MSAN: ${DAWN_ENABLE_MSAN}")
message(STATUS "Dawn build with UBSAN: ${DAWN_ENABLE_UBSAN}")
message(STATUS "Tint build samples: ${TINT_BUILD_SAMPLES}")
message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}")
message(STATUS "Tint build docs with warn as error: ${TINT_DOCS_WARN_AS_ERROR}")
message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}")
message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}")
message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}")
message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}")
message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
message(STATUS "Tint build SPIRV-Tools fuzzer: ${TINT_BUILD_SPIRV_TOOLS_FUZZER}")
message(STATUS "Tint build AST fuzzer: ${TINT_BUILD_AST_FUZZER}")
message(STATUS "Tint build regex fuzzer: ${TINT_BUILD_REGEX_FUZZER}")
message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}")
message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}")
message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}")
message(STATUS "Tint build remote-compile tool: ${TINT_BUILD_REMOTE_COMPILE}")
if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "")
message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}")
endif()
message(STATUS "Using python3")
find_package(PythonInterp 3 REQUIRED)
################################################################################
# common_compile_options - sets compiler and linker options common for dawn and
# tint on the given target
################################################################################
function(common_compile_options TARGET)
if (COMPILER_IS_LIKE_GNU)
target_compile_options(${TARGET} PRIVATE
-fno-exceptions
-fno-rtti
-fvisibility-inlines-hidden
)
if (${DAWN_ENABLE_MSAN})
target_compile_options(${TARGET} PUBLIC -fsanitize=memory)
target_link_options(${TARGET} PUBLIC -fsanitize=memory)
elseif (${DAWN_ENABLE_ASAN})
target_compile_options(${TARGET} PUBLIC -fsanitize=address)
target_link_options(${TARGET} PUBLIC -fsanitize=address)
elseif (${DAWN_ENABLE_TSAN})
target_compile_options(${TARGET} PUBLIC -fsanitize=thread)
target_link_options(${TARGET} PUBLIC -fsanitize=thread)
elseif (${DAWN_ENABLE_UBSAN})
target_compile_options(${TARGET} PUBLIC -fsanitize=undefined)
target_link_options(${TARGET} PUBLIC -fsanitize=undefined)
endif()
endif(COMPILER_IS_LIKE_GNU)
endfunction()
if (${DAWN_ENABLE_TSAN})
add_compile_options(-stdlib=libc++)
add_link_options(-stdlib=libc++)
endif()
################################################################################
# Dawn's public and internal "configs"
################################################################################
# The public config contains only the include paths for the Dawn headers.
add_library(dawn_public_config INTERFACE)
target_include_directories(dawn_public_config INTERFACE
"${DAWN_INCLUDE_DIR}"
"${DAWN_BUILD_GEN_DIR}/include"
)
# The internal config conatins additional path but includes the dawn_public_config include paths
add_library(dawn_internal_config INTERFACE)
target_include_directories(dawn_internal_config INTERFACE
"${DAWN_SRC_DIR}"
"${DAWN_BUILD_GEN_DIR}/src"
)
target_link_libraries(dawn_internal_config INTERFACE dawn_public_config)
# Compile definitions for the internal config
if (DAWN_ALWAYS_ASSERT OR CMAKE_BUILD_TYPE STREQUAL Debug)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_ASSERTS")
endif()
if (DAWN_ENABLE_D3D12)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D12")
endif()
if (DAWN_ENABLE_METAL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_METAL")
endif()
if (DAWN_ENABLE_NULL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL")
endif()
if (DAWN_ENABLE_DESKTOP_GL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_DESKTOP_GL")
endif()
if (DAWN_ENABLE_OPENGLES)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGLES")
endif()
if (DAWN_ENABLE_OPENGL)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL")
endif()
if (DAWN_ENABLE_VULKAN)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN")
endif()
if (DAWN_USE_WAYLAND)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WAYLAND")
endif()
if (DAWN_USE_X11)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11")
endif()
if (WIN32)
target_compile_definitions(dawn_internal_config INTERFACE "NOMINMAX" "WIN32_LEAN_AND_MEAN")
endif()
set(CMAKE_CXX_STANDARD "17")
################################################################################
# Tint
################################################################################
set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used")
set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR})
# CMake < 3.15 sets /W3 in CMAKE_CXX_FLAGS. Remove it if it's there.
@ -564,7 +590,14 @@ endfunction()
################################################################################
add_subdirectory(third_party)
# TODO(crbug.com/tint/455): Tint does not currently build with CMake when
# BUILD_SHARED_LIBS=1, so always build it as static for now.
set(BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS 0)
add_subdirectory(src/tint)
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVED})
add_subdirectory(generator)
add_subdirectory(src/dawn)

53
DEPS
View File

@ -14,10 +14,10 @@ vars = {
'dawn_standalone': True,
'dawn_node': False, # Also fetches dependencies required for building NodeJS bindings.
'dawn_cmake_version': 'version:3.13.5',
'dawn_cmake_version': 'version:2@3.23.3',
'dawn_cmake_win32_sha1': 'b106d66bcdc8a71ea2cdf5446091327bfdb1bcd7',
'dawn_gn_version': 'git_revision:bd99dbf98cbdefe18a4128189665c5761263bcfb',
'dawn_go_version': 'version:1.16',
'dawn_go_version': 'version:2@1.18.4',
'node_darwin_arm64_sha': '31859fc1fa0994a95f44f09c367d6ff63607cfde',
'node_darwin_x64_sha': '16dfd094763b71988933a31735f9dea966f9abd6',
@ -26,20 +26,23 @@ vars = {
# GN variable required by //testing that will be output in the gclient_args.gni
'generate_location_tags': False,
# Fetch clang-tidy into the same bin/ directory as our clang binary.
'checkout_clang_tidy': False,
}
deps = {
# Dependencies required to use GN/Clang in standalone
'build': {
'url': '{chromium_git}/chromium/src/build@87b04ad66530e4a571cef36d6e71ef737d23a887',
'url': '{chromium_git}/chromium/src/build@f14f6d206b9a0c81a0fefba487bcba0d90ddb5fe',
'condition': 'dawn_standalone',
},
'buildtools': {
'url': '{chromium_git}/chromium/src/buildtools@f0d740e4e2f803e39dfd5d8d11f7d87bdf489514',
'url': '{chromium_git}/chromium/src/buildtools@fe57e98eeb2172d7517f6dec1072ca641a019893',
'condition': 'dawn_standalone',
},
'buildtools/clang_format/script': {
'url': '{chromium_git}/external/github.com/llvm/llvm-project/clang/tools/clang-format.git@99803d74e35962f63a775f29477882afd4d57d94',
'url': '{chromium_git}/external/github.com/llvm/llvm-project/clang/tools/clang-format.git@8b525d2747f2584fc35d8c7e612e66f377858df7',
'condition': 'dawn_standalone',
},
'buildtools/linux64': {
@ -68,17 +71,17 @@ deps = {
},
'buildtools/third_party/libc++/trunk': {
'url': '{chromium_git}/external/github.com/llvm/llvm-project/libcxx.git@79a2e924d96e2fc1e4b937c42efd08898fa472d7',
'url': '{chromium_git}/external/github.com/llvm/llvm-project/libcxx.git@eb79671bfbedd77b747d01dee8c0479ff1693f88',
'condition': 'dawn_standalone',
},
'buildtools/third_party/libc++abi/trunk': {
'url': '{chromium_git}/external/github.com/llvm/llvm-project/libcxxabi.git@edde7bbc4049ae4a32257d9f16451312c763c601',
'url': '{chromium_git}/external/github.com/llvm/llvm-project/libcxxabi.git@b954e3e65634a9e2f7b595598a30c455f5f2eb26',
'condition': 'dawn_standalone',
},
'tools/clang': {
'url': '{chromium_git}/chromium/src/tools/clang@3c4a622d9f0b0ce5ec2a438189d46c695216b324',
'url': '{chromium_git}/chromium/src/tools/clang@3d8d88e8bb600789ba3e798f38ff314521aac524',
'condition': 'dawn_standalone',
},
'tools/clang/dsymutil': {
@ -92,11 +95,11 @@ deps = {
# Testing, GTest and GMock
'testing': {
'url': '{chromium_git}/chromium/src/testing@d485ae97b7900c1fb7edfbe2901ae5adcb120865',
'url': '{chromium_git}/chromium/src/testing@1f497ac0b0afc242222780a4789d13fbf00073eb',
'condition': 'dawn_standalone',
},
'third_party/googletest': {
'url': '{chromium_git}/external/github.com/google/googletest@6b74da4757a549563d7c37c8fae3e704662a043b',
'url': '{chromium_git}/external/github.com/google/googletest@bda85449f48f2d80a494c8c07766b6aba3170f3b',
'condition': 'dawn_standalone',
},
# This is a dependency of //testing
@ -117,8 +120,7 @@ deps = {
# GLFW for tests and samples
'third_party/glfw': {
'url': '{chromium_git}/external/github.com/glfw/glfw@94773111300fee0453844a4c9407af7e880b4df8',
'condition': 'dawn_standalone',
'url': '{chromium_git}/external/github.com/glfw/glfw@62e175ef9fae75335575964c845a302447c012c7',
},
'third_party/vulkan_memory_allocator': {
@ -127,33 +129,33 @@ deps = {
},
'third_party/angle': {
'url': '{chromium_git}/angle/angle@e316203a6a2f07b865fe6808d4fc8528cf0199fa',
'url': '{chromium_git}/angle/angle@5ef3960bc1f10d180331a8134b0d11139fa1f913',
'condition': 'dawn_standalone',
},
'third_party/swiftshader': {
'url': '{swiftshader_git}/SwiftShader@1dd93361b1d9a1755f73faac4cb2db8feb83a871',
'url': '{swiftshader_git}/SwiftShader@476165cc7c0c7247869c13f7f80dd25ec1fd2b03',
'condition': 'dawn_standalone',
},
'third_party/vulkan-deps': {
'url': '{chromium_git}/vulkan-deps@626b2fd72bdeabfee53df69a1831f3f4b0e75e8b',
'url': '{chromium_git}/vulkan-deps@c5f01bfc31ec5b7165eebf9f241890744edc7789',
'condition': 'dawn_standalone',
},
'third_party/zlib': {
'url': '{chromium_git}/chromium/src/third_party/zlib@c29ee8c9c3824ca013479bf8115035527967fe02',
'url': '{chromium_git}/chromium/src/third_party/zlib@64bbf988543996eb8df9a86877b32917187eba8f',
'condition': 'dawn_standalone',
},
'third_party/abseil-cpp': {
'url': '{chromium_git}/chromium/src/third_party/abseil-cpp@789af048b388657987c59d4da406859034fe310f',
'url': '{chromium_git}/chromium/src/third_party/abseil-cpp@bc3ab29356a081d0b5dd4ac55e30f4b45d8794cc',
'condition': 'dawn_standalone',
},
# WebGPU CTS - not used directly by Dawn, only transitively by Chromium.
'third_party/webgpu-cts': {
'url': '{chromium_git}/external/github.com/gpuweb/cts@ecf4804228d1473df8596c3c87e5b7e32649e2de',
'url': '{chromium_git}/external/github.com/gpuweb/cts@27dc745ca167d1e9eb956947f2109441dca0b4f7',
'condition': 'build_with_chromium',
},
@ -167,13 +169,9 @@ deps = {
'condition': 'dawn_node',
},
'third_party/gpuweb': {
'url': '{github_git}/gpuweb/gpuweb.git@16df823c91c9045b7cdf9bd0f2c0ef6d43ac95e7',
'url': '{github_git}/gpuweb/gpuweb.git@3c4734b09c68eb800b15da5e9ecefeca735fa7df',
'condition': 'dawn_node',
},
'third_party/gpuweb-cts': {
'url': '{chromium_git}/external/github.com/gpuweb/cts@ecf4804228d1473df8596c3c87e5b7e32649e2de',
'condition': 'dawn_standalone',
},
'tools/golang': {
'condition': 'dawn_node',
@ -242,6 +240,15 @@ hooks = [
'action': ['python3', 'tools/clang/scripts/update.py'],
'condition': 'dawn_standalone',
},
{
# This is also supposed to support the same set of platforms as 'clang'
# above. LLVM ToT support isn't provided at the moment.
'name': 'clang_tidy',
'pattern': '.',
'condition': 'dawn_standalone and checkout_clang_tidy',
'action': ['python3', 'tools/clang/scripts/update.py',
'--package=clang-tidy'],
},
{
# Pull rc binaries using checked-in hashes.
'name': 'rc_win',

View File

@ -2078,7 +2078,8 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED = DOXYGEN
PREDEFINED = DOXYGEN \
TESTING_LIBFUZZER_LIBFUZZER_EXPORTS_H_ # See: crbug.com/tint/1647
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The

1
OWNERS
View File

@ -1,4 +1,5 @@
# Top level owners, if you can, try to look at more targeted OWNERS
bclayton@chromium.org
bclayton@google.com
cwallez@chromium.org
dneto@google.com

View File

@ -117,6 +117,7 @@ def _NonInclusiveFileFilter(file):
"src/dawn/node/tools/src/cmd/run-cts/main.go", # Terminal type name
"src/dawn/samples/ComputeBoids.cpp", # External URL
"src/dawn/tests/end2end/DepthBiasTests.cpp", # External URL
"src/tint/transform/canonicalize_entry_point_io.cc", # External URL
"test/tint/samples/compute_boids.wgsl", # External URL
"third_party/khronos/KHR/khrplatform.h", # Third party file
"tools/roll-all", # Branch name

View File

@ -10,13 +10,9 @@ Dawn provides several WebGPU building blocks:
- **WebGPU C/C++ headers** that applications and other building blocks use.
- The `webgpu.h` version that Dawn implements.
- A C++ wrapper for the `webgpu.h`.
- **A "native" implementation of WebGPU** using platforms' GPU APIs:
- **D3D12** on Windows 10
- **Metal** on macOS and iOS
- **Vulkan** on Windows, Linux, ChromeOS, Android and Fuchsia
- OpenGL as best effort where available
- **A "native" implementation of WebGPU** using platforms' GPU APIs: D3D12, Metal, Vulkan and OpenGL. See [per API support](docs/support.md) for more details.
- **A client-server implementation of WebGPU** for applications that are in a sandbox without access to native drivers
- **Tint** is a compiler for the WebGPU Shader Language (WGSL).
- **Tint** is a compiler for the WebGPU Shader Language (WGSL) that can be used in standalone to convert shaders from and to WGSL.
Helpful links:

View File

@ -37,3 +37,7 @@ dawn_swiftshader_dir = "//third_party/swiftshader"
dawn_vulkan_loader_dir = "//third_party/vulkan-deps/vulkan-loader/src"
dawn_vulkan_validation_layers_dir =
"//third_party/vulkan-deps/vulkan-validation-layers/src"
# Optional path to a one-liner version file. Default is empty path indicating
# that git should be used to figure out the version.
dawn_version_file = ""

View File

@ -19,3 +19,5 @@ tint_build_spv_reader = true
tint_build_spv_writer = true
tint_build_wgsl_reader = true
tint_build_wgsl_writer = true
tint_build_unittests = true

View File

@ -0,0 +1,19 @@
# Copyright 2022 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/config/ozone.gni")
# Dawn has no wayland third-party dir
use_system_libwayland = true
wayland_gn_dir = ""

307
dawn.json
View File

@ -108,7 +108,7 @@
{
"name": "request device",
"args": [
{"name": "descriptor", "type": "device descriptor", "annotation": "const*"},
{"name": "descriptor", "type": "device descriptor", "annotation": "const*", "optional": true, "no_default": true},
{"name": "callback", "type": "request device callback"},
{"name": "userdata", "type": "void", "annotation": "*"}
]
@ -118,7 +118,7 @@
"tags": ["dawn"],
"returns": "device",
"args": [
{"name": "descriptor", "type": "device descriptor", "annotation": "const*", "optional": "true"}
{"name": "descriptor", "type": "device descriptor", "annotation": "const*", "optional": true}
]
}
]
@ -128,6 +128,8 @@
"extensible": "out",
"members": [
{"name": "vendor ID", "type": "uint32_t"},
{"name": "vendor name", "type": "char", "annotation": "const*", "length": "strlen"},
{"name": "architecture", "type": "char", "annotation": "const*", "length": "strlen"},
{"name": "device ID", "type": "uint32_t"},
{"name": "name", "type": "char", "annotation": "const*", "length": "strlen"},
{"name": "driver description", "type": "char", "annotation": "const*", "length": "strlen"},
@ -160,6 +162,7 @@
"tags": ["dawn", "native"],
"category": "structure",
"chained": "in",
"chain roots": ["device descriptor"],
"members": [
{"name": "force enabled toggles count", "type": "uint32_t", "default": 0},
{"name": "force enabled toggles", "type": "char", "annotation": "const*const*", "length": "force enabled toggles count"},
@ -171,6 +174,7 @@
"tags": ["dawn", "native"],
"category": "structure",
"chained": "in",
"chain roots": ["device descriptor"],
"members": [
{"name": "isolation key", "type": "char", "annotation": "const*", "length": "strlen", "default": "\"\""}
]
@ -304,6 +308,7 @@
"external texture binding entry": {
"category": "structure",
"chained": "in",
"chain roots": ["bind group entry"],
"tags": ["dawn"],
"members": [
{"name": "external texture", "type": "external texture"}
@ -313,6 +318,7 @@
"external texture binding layout": {
"category": "structure",
"chained": "in",
"chain roots": ["bind group layout entry"],
"tags": ["dawn"],
"members": []
},
@ -431,6 +437,14 @@
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
},
{
"name": "get usage",
"returns": "buffer usage"
},
{
"name": "get size",
"returns": "uint64_t"
},
{
"name": "unmap"
},
@ -894,7 +908,8 @@
"tags": ["dawn"],
"values": [
{"value": 0, "name": "premultiplied"},
{"value": 1, "name": "unpremultiplied"}
{"value": 1, "name": "unpremultiplied"},
{"value": 2, "name": "opaque"}
]
},
"copy texture for browser options": {
@ -912,7 +927,8 @@
"length": 9, "optional": true},
{"name": "dst transfer function parameters", "type": "float", "annotation": "const*",
"length": 7, "optional": true},
{"name": "dst alpha mode", "type": "alpha mode", "default": "unpremultiplied"}
{"name": "dst alpha mode", "type": "alpha mode", "default": "unpremultiplied"},
{"name": "internal usage", "type": "bool", "default": "false"}
]
},
"create compute pipeline async callback": {
@ -1012,6 +1028,11 @@
{"name": "external texture descriptor", "type": "external texture descriptor", "annotation": "const*"}
]
},
{
"name": "create error external texture",
"returns": "external texture",
"tags": ["dawn"]
},
{
"name": "create pipeline layout",
"returns": "pipeline layout",
@ -1065,12 +1086,22 @@
},
{
"name": "create swap chain",
"tags": ["dawn"],
"returns": "swap chain",
"args": [
{"name": "surface", "type": "surface", "optional": true},
{"name": "descriptor", "type": "swap chain descriptor", "annotation": "const*"}
]
},
{
"name": "create swap chain",
"tags": ["upstream", "emscripten"],
"returns": "swap chain",
"args": [
{"name": "surface", "type": "surface"},
{"name": "descriptor", "type": "swap chain descriptor", "annotation": "const*"}
]
},
{
"name": "create texture",
"returns": "texture",
@ -1078,6 +1109,14 @@
{"name": "descriptor", "type": "texture descriptor", "annotation": "const*"}
]
},
{
"name": "create error texture",
"returns": "texture",
"tags": ["dawn"],
"args": [
{"name": "descriptor", "type": "texture descriptor", "annotation": "const*"}
]
},
{
"name": "destroy"
},
@ -1102,6 +1141,11 @@
{"name": "features", "type": "feature name", "annotation": "*"}
]
},
{
"name": "get adapter",
"returns": "adapter",
"tags": ["dawn"]
},
{
"name": "get queue",
"returns": "queue"
@ -1183,30 +1227,6 @@
{"value": 1, "name": "destroyed"}
]
},
"device properties": {
"category": "structure",
"extensible": false,
"tags": ["dawn"],
"members": [
{"name": "device ID", "type": "uint32_t"},
{"name": "vendor ID", "type": "uint32_t"},
{"name": "adapter type", "type": "adapter type"},
{"name": "texture compression BC", "type": "bool", "default": "false"},
{"name": "texture compression ETC2", "type": "bool", "default": "false"},
{"name": "texture compression ASTC", "type": "bool", "default": "false"},
{"name": "shader float16", "type": "bool", "default": "false"},
{"name": "pipeline statistics query", "type": "bool", "default": "false"},
{"name": "timestamp query", "type": "bool", "default": "false"},
{"name": "multi planar formats", "type": "bool", "default": "false"},
{"name": "depth clamping", "type": "bool", "default": "false"},
{"name": "depth24 unorm stencil8", "type": "bool", "default": "false"},
{"name": "depth32 float stencil8", "type": "bool", "default": "false"},
{"name": "invalid feature", "type": "bool", "default": "false"},
{"name": "dawn internal usages", "type": "bool", "default": "false"},
{"name": "dawn native", "type": "bool", "default": "false"},
{"name": "limits", "type": "supported limits"}
]
},
"double": {
"category": "native"
},
@ -1241,6 +1261,8 @@
{"name": "max vertex attributes", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"},
{"name": "max vertex buffer array stride", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"},
{"name": "max inter stage shader components", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"},
{"name": "max inter stage shader variables", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"},
{"name": "max color attachments", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"},
{"name": "max compute workgroup storage size", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"},
{"name": "max compute invocations per workgroup", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"},
{"name": "max compute workgroup size x", "type": "uint32_t", "default": "WGPU_LIMIT_U32_UNDEFINED"},
@ -1333,35 +1355,34 @@
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true},
{"name": "plane 0", "type": "texture view"},
{"name": "plane 1", "type": "texture view", "optional": true},
{"name": "do yuv to rgb conversion only", "type": "bool", "default": "false"},
{"name": "yuv to rgb conversion matrix", "type": "float", "annotation": "const*",
"length": 12, "optional": true},
{"name": "src transfer function parameters", "type": "float", "annotation": "const*",
"length": 7, "optional": true},
"length": 7},
{"name": "dst transfer function parameters", "type": "float", "annotation": "const*",
"length": 7, "optional": true},
"length": 7},
{"name": "gamut conversion matrix", "type": "float", "annotation": "const*",
"length": 9, "optional": true},
{"name": "color space", "type": "predefined color space", "default": "srgb"}
"length": 9}
]
},
"feature name": {
"category": "enum",
"values": [
{"value": 0, "name": "undefined", "jsrepr": "undefined"},
{"value": 1, "name": "depth clip control", "tags": ["upstream", "emscripten"]},
{"value": 2, "name": "depth24 unorm stencil8"},
{"value": 3, "name": "depth32 float stencil8"},
{"value": 4, "name": "timestamp query"},
{"value": 5, "name": "pipeline statistics query"},
{"value": 6, "name": "texture compression BC"},
{"value": 7, "name": "texture compression ETC2"},
{"value": 8, "name": "texture compression ASTC"},
{"value": 9, "name": "indirect first instance"},
{"value": 1000, "name": "depth clamping", "tags": ["emscripten", "dawn"]},
{"value": 1, "name": "depth clip control"},
{"value": 2, "name": "depth32 float stencil8"},
{"value": 3, "name": "timestamp query"},
{"value": 4, "name": "pipeline statistics query"},
{"value": 5, "name": "texture compression BC"},
{"value": 6, "name": "texture compression ETC2"},
{"value": 7, "name": "texture compression ASTC"},
{"value": 8, "name": "indirect first instance"},
{"value": 1001, "name": "dawn shader float 16", "tags": ["dawn"]},
{"value": 1002, "name": "dawn internal usages", "tags": ["dawn"]},
{"value": 1003, "name": "dawn multi planar formats", "tags": ["dawn"]},
{"value": 1004, "name": "dawn native", "tags": ["dawn", "native"]}
{"value": 1004, "name": "dawn native", "tags": ["dawn", "native"]},
{"value": 1005, "name": "chromium experimental dp4a", "tags": ["dawn"]}
]
},
"filter mode": {
@ -1424,7 +1445,7 @@
{
"name": "request adapter",
"args": [
{"name": "options", "type": "request adapter options", "annotation": "const*"},
{"name": "options", "type": "request adapter options", "annotation": "const*", "optional": true, "no_default": true},
{"name": "callback", "type": "request adapter callback"},
{"name": "userdata", "type": "void", "annotation": "*"}
]
@ -1440,6 +1461,7 @@
"tags": ["dawn", "native"],
"category": "structure",
"chained": "in",
"chain roots": ["instance descriptor"],
"members": [
{"name": "additional runtime search paths count", "type": "uint32_t", "default": 0},
{"name": "additional runtime search paths", "type": "char", "annotation": "const*const*", "length": "additional runtime search paths count"}
@ -1468,7 +1490,8 @@
"category": "enum",
"values": [
{"value": 0, "name": "vertex"},
{"value": 1, "name": "instance"}
{"value": 1, "name": "instance"},
{"value": 2, "name": "vertex buffer not used", "jsrepr": "undefined", "valid": true}
]
},
"load op": {
@ -1550,13 +1573,6 @@
{"value": 2, "name": "high performance"}
]
},
"predefined color space": {
"category": "enum",
"values": [
{"value": 0, "name": "undefined", "jsrepr": "undefined"},
{"value": 1, "name": "srgb"}
]
},
"present mode": {
"category": "enum",
"emscripten_no_enum_table": true,
@ -1596,6 +1612,14 @@
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
},
{
"name": "get type",
"returns": "query type"
},
{
"name": "get count",
"returns": "uint32_t"
},
{
"name": "destroy"
}
@ -1881,6 +1905,14 @@
{"name": "timestamp writes", "type": "render pass timestamp write", "annotation": "const*", "length": "timestamp write count"}
]
},
"render pass descriptor max draw count": {
"category": "structure",
"chained": "in",
"chain roots": ["render pass descriptor"],
"members": [
{"name": "max draw count", "type": "uint64_t", "default": 50000000}
]
},
"render pass encoder": {
"category": "object",
"methods": [
@ -2130,19 +2162,10 @@
]
},
"primitive depth clamping state": {
"category": "structure",
"chained": "in",
"tags": ["dawn", "emscripten"],
"members": [
{"name": "clamp depth", "type": "bool", "default": "false"}
]
},
"primitive depth clip control": {
"category": "structure",
"chained": "in",
"tags": ["upstream", "emscripten"],
"chain roots": ["primitive state"],
"members": [
{"name": "unclipped depth", "type": "bool", "default": "false"}
]
@ -2289,6 +2312,7 @@
"shader module SPIRV descriptor": {
"category": "structure",
"chained": "in",
"chain roots": ["shader module descriptor"],
"members": [
{"name": "code size", "type": "uint32_t"},
{"name": "code", "type": "uint32_t", "annotation": "const*", "length": "code size"}
@ -2297,6 +2321,7 @@
"shader module WGSL descriptor": {
"category": "structure",
"chained": "in",
"chain roots": ["shader module descriptor"],
"members": [
{"name": "source", "type": "char", "annotation": "const*", "length": "strlen", "tags": ["dawn", "emscripten"]},
{"name": "code", "type": "char", "annotation": "const*", "length": "strlen", "tags": ["upstream"]}
@ -2357,6 +2382,7 @@
"surface descriptor from android native window": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"tags": ["native"],
"members": [
{"name": "window", "type": "void", "annotation": "*"}
@ -2365,6 +2391,7 @@
"surface descriptor from canvas HTML selector": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"members": [
{"name": "selector", "type": "char", "annotation": "const*", "length": "strlen"}
]
@ -2372,6 +2399,7 @@
"surface descriptor from metal layer": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"tags": ["native"],
"members": [
{"name": "layer", "type": "void", "annotation": "*"}
@ -2380,6 +2408,7 @@
"surface descriptor from windows HWND": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"tags": ["native"],
"members": [
{"name": "hinstance", "type": "void", "annotation": "*"},
@ -2389,6 +2418,7 @@
"surface descriptor from xcb window": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"tags": ["upstream"],
"members": [
{"name": "connection", "type": "void", "annotation": "*"},
@ -2398,6 +2428,7 @@
"surface descriptor from xlib window": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"tags": ["native"],
"members": [
{"name": "display", "type": "void", "annotation": "*"},
@ -2407,6 +2438,7 @@
"surface descriptor from wayland surface": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"tags": ["native"],
"members": [
{"name": "display", "type": "void", "annotation": "*"},
@ -2416,6 +2448,7 @@
"surface descriptor from windows core window": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"tags": ["dawn"],
"members": [
{"name": "core window", "type": "void", "annotation": "*"}
@ -2424,6 +2457,7 @@
"surface descriptor from windows swap chain panel": {
"category": "structure",
"chained": "in",
"chain roots": ["surface descriptor"],
"tags": ["dawn"],
"members": [
{"name": "swap chain panel", "type": "void", "annotation": "*"}
@ -2470,7 +2504,7 @@
{"value": 4, "name": "surface descriptor from canvas HTML selector"},
{"value": 5, "name": "shader module SPIRV descriptor"},
{"value": 6, "name": "shader module WGSL descriptor"},
{"value": 7, "name": "primitive depth clip control", "tags": ["upstream", "emscripten"]},
{"value": 7, "name": "primitive depth clip control"},
{"value": 8, "name": "surface descriptor from wayland surface", "tags": ["native"]},
{"value": 9, "name": "surface descriptor from android native window", "tags": ["native"]},
{"value": 10, "name": "surface descriptor from xcb window", "tags": ["upstream"]},
@ -2478,8 +2512,8 @@
{"value": 12, "name": "external texture binding entry", "tags": ["dawn"]},
{"value": 13, "name": "external texture binding layout", "tags": ["dawn"]},
{"value": 14, "name": "surface descriptor from windows swap chain panel", "tags": ["dawn"]},
{"value": 15, "name": "render pass descriptor max draw count"},
{"value": 1000, "name": "dawn texture internal usage descriptor", "tags": ["dawn"]},
{"value": 1001, "name": "primitive depth clamping state", "tags": ["dawn", "emscripten"]},
{"value": 1002, "name": "dawn toggles device descriptor", "tags": ["dawn", "native"]},
{"value": 1003, "name": "dawn encoder internal usage descriptor", "tags": ["dawn"]},
{"value": 1004, "name": "dawn instance descriptor", "tags": ["dawn", "native"]},
@ -2503,6 +2537,38 @@
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
},
{
"name": "get width",
"returns": "uint32_t"
},
{
"name": "get height",
"returns": "uint32_t"
},
{
"name": "get depth or array layers",
"returns": "uint32_t"
},
{
"name": "get mip level count",
"returns": "uint32_t"
},
{
"name": "get sample count",
"returns": "uint32_t"
},
{
"name": "get dimension",
"returns": "texture dimension"
},
{
"name": "get format",
"returns": "texture format"
},
{
"name": "get usage",
"returns": "texture usage"
},
{
"name": "destroy"
}
@ -2609,66 +2675,65 @@
{"value": 38, "name": "depth16 unorm"},
{"value": 39, "name": "depth24 plus"},
{"value": 40, "name": "depth24 plus stencil8"},
{"value": 41, "name": "depth24 unorm stencil8"},
{"value": 42, "name": "depth32 float"},
{"value": 43, "name": "depth32 float stencil8"},
{"value": 41, "name": "depth32 float"},
{"value": 42, "name": "depth32 float stencil8"},
{"value": 44, "name": "BC1 RGBA unorm", "jsrepr": "'bc1-rgba-unorm'"},
{"value": 45, "name": "BC1 RGBA unorm srgb", "jsrepr": "'bc1-rgba-unorm-srgb'"},
{"value": 46, "name": "BC2 RGBA unorm", "jsrepr": "'bc2-rgba-unorm'"},
{"value": 47, "name": "BC2 RGBA unorm srgb", "jsrepr": "'bc2-rgba-unorm-srgb'"},
{"value": 48, "name": "BC3 RGBA unorm", "jsrepr": "'bc3-rgba-unorm'"},
{"value": 49, "name": "BC3 RGBA unorm srgb", "jsrepr": "'bc3-rgba-unorm-srgb'"},
{"value": 50, "name": "BC4 R unorm", "jsrepr": "'bc4-r-unorm'"},
{"value": 51, "name": "BC4 R snorm", "jsrepr": "'bc4-r-snorm'"},
{"value": 52, "name": "BC5 RG unorm", "jsrepr": "'bc5-rg-unorm'"},
{"value": 53, "name": "BC5 RG snorm", "jsrepr": "'bc5-rg-snorm'"},
{"value": 54, "name": "BC6H RGB ufloat", "jsrepr": "'bc6h-rgb-ufloat'"},
{"value": 55, "name": "BC6H RGB float", "jsrepr": "'bc6h-rgb-float'"},
{"value": 56, "name": "BC7 RGBA unorm", "jsrepr": "'bc7-rgba-unorm'"},
{"value": 57, "name": "BC7 RGBA unorm srgb", "jsrepr": "'bc7-rgba-unorm-srgb'"},
{"value": 43, "name": "BC1 RGBA unorm", "jsrepr": "'bc1-rgba-unorm'"},
{"value": 44, "name": "BC1 RGBA unorm srgb", "jsrepr": "'bc1-rgba-unorm-srgb'"},
{"value": 45, "name": "BC2 RGBA unorm", "jsrepr": "'bc2-rgba-unorm'"},
{"value": 46, "name": "BC2 RGBA unorm srgb", "jsrepr": "'bc2-rgba-unorm-srgb'"},
{"value": 47, "name": "BC3 RGBA unorm", "jsrepr": "'bc3-rgba-unorm'"},
{"value": 48, "name": "BC3 RGBA unorm srgb", "jsrepr": "'bc3-rgba-unorm-srgb'"},
{"value": 49, "name": "BC4 R unorm", "jsrepr": "'bc4-r-unorm'"},
{"value": 50, "name": "BC4 R snorm", "jsrepr": "'bc4-r-snorm'"},
{"value": 51, "name": "BC5 RG unorm", "jsrepr": "'bc5-rg-unorm'"},
{"value": 52, "name": "BC5 RG snorm", "jsrepr": "'bc5-rg-snorm'"},
{"value": 53, "name": "BC6H RGB ufloat", "jsrepr": "'bc6h-rgb-ufloat'"},
{"value": 54, "name": "BC6H RGB float", "jsrepr": "'bc6h-rgb-float'"},
{"value": 55, "name": "BC7 RGBA unorm", "jsrepr": "'bc7-rgba-unorm'"},
{"value": 56, "name": "BC7 RGBA unorm srgb", "jsrepr": "'bc7-rgba-unorm-srgb'"},
{"value": 58, "name": "ETC2 RGB8 unorm", "jsrepr": "'etc2-rgb8unorm'"},
{"value": 59, "name": "ETC2 RGB8 unorm srgb", "jsrepr": "'etc2-rgb8unorm-srgb'"},
{"value": 60, "name": "ETC2 RGB8A1 unorm", "jsrepr": "'etc2-rgb8a1unorm'"},
{"value": 61, "name": "ETC2 RGB8A1 unorm srgb", "jsrepr": "'etc2-rgb8a1unorm-srgb'"},
{"value": 62, "name": "ETC2 RGBA8 unorm", "jsrepr": "'etc2-rgba8unorm'"},
{"value": 63, "name": "ETC2 RGBA8 unorm srgb", "jsrepr": "'etc2-rgba8unorm-srgb'"},
{"value": 64, "name": "EAC R11 unorm", "jsrepr": "'eac-r11unorm'"},
{"value": 65, "name": "EAC R11 snorm", "jsrepr": "'eac-r11snorm'"},
{"value": 66, "name": "EAC RG11 unorm", "jsrepr": "'eac-rg11unorm'"},
{"value": 67, "name": "EAC RG11 snorm", "jsrepr": "'eac-rg11snorm'"},
{"value": 57, "name": "ETC2 RGB8 unorm", "jsrepr": "'etc2-rgb8unorm'"},
{"value": 58, "name": "ETC2 RGB8 unorm srgb", "jsrepr": "'etc2-rgb8unorm-srgb'"},
{"value": 59, "name": "ETC2 RGB8A1 unorm", "jsrepr": "'etc2-rgb8a1unorm'"},
{"value": 60, "name": "ETC2 RGB8A1 unorm srgb", "jsrepr": "'etc2-rgb8a1unorm-srgb'"},
{"value": 61, "name": "ETC2 RGBA8 unorm", "jsrepr": "'etc2-rgba8unorm'"},
{"value": 62, "name": "ETC2 RGBA8 unorm srgb", "jsrepr": "'etc2-rgba8unorm-srgb'"},
{"value": 63, "name": "EAC R11 unorm", "jsrepr": "'eac-r11unorm'"},
{"value": 64, "name": "EAC R11 snorm", "jsrepr": "'eac-r11snorm'"},
{"value": 65, "name": "EAC RG11 unorm", "jsrepr": "'eac-rg11unorm'"},
{"value": 66, "name": "EAC RG11 snorm", "jsrepr": "'eac-rg11snorm'"},
{"value": 68, "name": "ASTC 4x4 unorm", "jsrepr": "'astc-4x4-unorm'"},
{"value": 69, "name": "ASTC 4x4 unorm srgb", "jsrepr": "'astc-4x4-unorm-srgb'"},
{"value": 70, "name": "ASTC 5x4 unorm", "jsrepr": "'astc-5x4-unorm'"},
{"value": 71, "name": "ASTC 5x4 unorm srgb", "jsrepr": "'astc-5x4-unorm-srgb'"},
{"value": 72, "name": "ASTC 5x5 unorm", "jsrepr": "'astc-5x5-unorm'"},
{"value": 73, "name": "ASTC 5x5 unorm srgb", "jsrepr": "'astc-5x5-unorm-srgb'"},
{"value": 74, "name": "ASTC 6x5 unorm", "jsrepr": "'astc-6x5-unorm'"},
{"value": 75, "name": "ASTC 6x5 unorm srgb", "jsrepr": "'astc-6x5-unorm-srgb'"},
{"value": 76, "name": "ASTC 6x6 unorm", "jsrepr": "'astc-6x6-unorm'"},
{"value": 77, "name": "ASTC 6x6 unorm srgb", "jsrepr": "'astc-6x6-unorm-srgb'"},
{"value": 78, "name": "ASTC 8x5 unorm", "jsrepr": "'astc-8x5-unorm'"},
{"value": 79, "name": "ASTC 8x5 unorm srgb", "jsrepr": "'astc-8x5-unorm-srgb'"},
{"value": 80, "name": "ASTC 8x6 unorm", "jsrepr": "'astc-8x6-unorm'"},
{"value": 81, "name": "ASTC 8x6 unorm srgb", "jsrepr": "'astc-8x6-unorm-srgb'"},
{"value": 82, "name": "ASTC 8x8 unorm", "jsrepr": "'astc-8x8-unorm'"},
{"value": 83, "name": "ASTC 8x8 unorm srgb", "jsrepr": "'astc-8x8-unorm-srgb'"},
{"value": 84, "name": "ASTC 10x5 unorm", "jsrepr": "'astc-10x5-unorm'"},
{"value": 85, "name": "ASTC 10x5 unorm srgb", "jsrepr": "'astc-10x5-unorm-srgb'"},
{"value": 86, "name": "ASTC 10x6 unorm", "jsrepr": "'astc-10x6-unorm'"},
{"value": 87, "name": "ASTC 10x6 unorm srgb", "jsrepr": "'astc-10x6-unorm-srgb'"},
{"value": 88, "name": "ASTC 10x8 unorm", "jsrepr": "'astc-10x8-unorm'"},
{"value": 89, "name": "ASTC 10x8 unorm srgb", "jsrepr": "'astc-10x8-unorm-srgb'"},
{"value": 90, "name": "ASTC 10x10 unorm", "jsrepr": "'astc-10x10-unorm'"},
{"value": 91, "name": "ASTC 10x10 unorm srgb", "jsrepr": "'astc-10x10-unorm-srgb'"},
{"value": 92, "name": "ASTC 12x10 unorm", "jsrepr": "'astc-12x10-unorm'"},
{"value": 93, "name": "ASTC 12x10 unorm srgb", "jsrepr": "'astc-12x10-unorm-srgb'"},
{"value": 94, "name": "ASTC 12x12 unorm", "jsrepr": "'astc-12x12-unorm'"},
{"value": 95, "name": "ASTC 12x12 unorm srgb", "jsrepr": "'astc-12x12-unorm-srgb'"},
{"value": 67, "name": "ASTC 4x4 unorm", "jsrepr": "'astc-4x4-unorm'"},
{"value": 68, "name": "ASTC 4x4 unorm srgb", "jsrepr": "'astc-4x4-unorm-srgb'"},
{"value": 69, "name": "ASTC 5x4 unorm", "jsrepr": "'astc-5x4-unorm'"},
{"value": 70, "name": "ASTC 5x4 unorm srgb", "jsrepr": "'astc-5x4-unorm-srgb'"},
{"value": 71, "name": "ASTC 5x5 unorm", "jsrepr": "'astc-5x5-unorm'"},
{"value": 72, "name": "ASTC 5x5 unorm srgb", "jsrepr": "'astc-5x5-unorm-srgb'"},
{"value": 73, "name": "ASTC 6x5 unorm", "jsrepr": "'astc-6x5-unorm'"},
{"value": 74, "name": "ASTC 6x5 unorm srgb", "jsrepr": "'astc-6x5-unorm-srgb'"},
{"value": 75, "name": "ASTC 6x6 unorm", "jsrepr": "'astc-6x6-unorm'"},
{"value": 76, "name": "ASTC 6x6 unorm srgb", "jsrepr": "'astc-6x6-unorm-srgb'"},
{"value": 77, "name": "ASTC 8x5 unorm", "jsrepr": "'astc-8x5-unorm'"},
{"value": 78, "name": "ASTC 8x5 unorm srgb", "jsrepr": "'astc-8x5-unorm-srgb'"},
{"value": 79, "name": "ASTC 8x6 unorm", "jsrepr": "'astc-8x6-unorm'"},
{"value": 80, "name": "ASTC 8x6 unorm srgb", "jsrepr": "'astc-8x6-unorm-srgb'"},
{"value": 81, "name": "ASTC 8x8 unorm", "jsrepr": "'astc-8x8-unorm'"},
{"value": 82, "name": "ASTC 8x8 unorm srgb", "jsrepr": "'astc-8x8-unorm-srgb'"},
{"value": 83, "name": "ASTC 10x5 unorm", "jsrepr": "'astc-10x5-unorm'"},
{"value": 84, "name": "ASTC 10x5 unorm srgb", "jsrepr": "'astc-10x5-unorm-srgb'"},
{"value": 85, "name": "ASTC 10x6 unorm", "jsrepr": "'astc-10x6-unorm'"},
{"value": 86, "name": "ASTC 10x6 unorm srgb", "jsrepr": "'astc-10x6-unorm-srgb'"},
{"value": 87, "name": "ASTC 10x8 unorm", "jsrepr": "'astc-10x8-unorm'"},
{"value": 88, "name": "ASTC 10x8 unorm srgb", "jsrepr": "'astc-10x8-unorm-srgb'"},
{"value": 89, "name": "ASTC 10x10 unorm", "jsrepr": "'astc-10x10-unorm'"},
{"value": 90, "name": "ASTC 10x10 unorm srgb", "jsrepr": "'astc-10x10-unorm-srgb'"},
{"value": 91, "name": "ASTC 12x10 unorm", "jsrepr": "'astc-12x10-unorm'"},
{"value": 92, "name": "ASTC 12x10 unorm srgb", "jsrepr": "'astc-12x10-unorm-srgb'"},
{"value": 93, "name": "ASTC 12x12 unorm", "jsrepr": "'astc-12x12-unorm'"},
{"value": 94, "name": "ASTC 12x12 unorm srgb", "jsrepr": "'astc-12x12-unorm-srgb'"},
{"value": 96, "name": "R8 BG8 Biplanar 420 unorm", "tags": ["dawn"]}
{"value": 95, "name": "R8 BG8 Biplanar 420 unorm", "tags": ["dawn"]}
]
},
"texture usage": {
@ -2841,6 +2906,7 @@
"dawn texture internal usage descriptor": {
"category": "structure",
"chained": "in",
"chain roots": ["texture descriptor"],
"tags": ["dawn"],
"members": [
{"name": "internal usage", "type": "texture usage", "default": "none"}
@ -2849,6 +2915,7 @@
"dawn encoder internal usage descriptor": {
"category": "structure",
"chained": "in",
"chain roots": ["command encoder descriptor"],
"tags": ["dawn"],
"members": [
{"name": "use internal usages", "type": "bool", "default": "false"}

View File

@ -189,6 +189,8 @@
"BufferMapAsync",
"BufferGetConstMappedRange",
"BufferGetMappedRange",
"BufferGetSize",
"BufferGetUsage",
"DeviceCreateBuffer",
"DeviceCreateComputePipelineAsync",
"DeviceCreateRenderPipelineAsync",
@ -201,14 +203,28 @@
"DeviceSetLoggingCallback",
"InstanceRequestAdapter",
"ShaderModuleGetCompilationInfo",
"QuerySetGetType",
"QuerySetGetCount",
"QueueOnSubmittedWorkDone",
"QueueWriteBuffer",
"QueueWriteTexture"
"QueueWriteTexture",
"TextureGetWidth",
"TextureGetHeight",
"TextureGetDepthOrArrayLayers",
"TextureGetMipLevelCount",
"TextureGetSampleCount",
"TextureGetDimension",
"TextureGetFormat",
"TextureGetUsage"
],
"client_handwritten_commands": [
"BufferDestroy",
"BufferUnmap",
"DeviceCreateErrorBuffer",
"DeviceCreateQuerySet",
"DeviceCreateTexture",
"DeviceCreateErrorTexture",
"DeviceGetAdapter",
"DeviceGetQueue",
"DeviceInjectError"
],
@ -217,8 +233,10 @@
"Buffer",
"Device",
"Instance",
"QuerySet",
"Queue",
"ShaderModule"
"ShaderModule",
"Texture"
],
"server_custom_pre_handler_commands": [
"BufferDestroy",

37
docs/clang-tidy.md Normal file
View File

@ -0,0 +1,37 @@
# Running clang-tidy
* Add `"checkout_clang_tidy": True` to `.gclient` file in the `custom_vars`.
```
{
"custom_vars": {
"checkout_clang_tidy": True,
}
}
```
* `gclient sync`
There should now be `third_party/llvm-build/Release+Asserts/bin/clang-tidy`
* `cd out`
* `git clone https://chromium.googlesource.com/chromium/tools/build`
The Chromium build folder contains the `tricium` files used to run `clang-tidy`
Running clang-tidy over all the source can be done with:
```
cd ..
out/build/recipes/recipe_modules/tricium_clang_tidy/resources/tricium_clang_tidy_script.py \
--base_path $PWD \
--out_dir out/Debug \
--findings_file all_findings.json \
--clang_tidy_binary $PWD/third_party/llvm-build/Release+Asserts/bin/clang-tidy \
--all
```
`--all` can be replaced by specific files if desired to run on individual source
files.
## References
* https://chromium.googlesource.com/chromium/src.git/+/HEAD/docs/clang_tidy.md

View File

@ -42,7 +42,7 @@ A **record** is a list of **record members**, each of which is a dictionary with
- `"type"` a string, the name of the base type for this member
- `"annotation"` a string, default to "value". Define the C annotation to apply to the base type. Allowed annotations are `"value"` (the default), `"*"`, `"const*"`
- `"length"` (default to 1 if not set), a string. Defines length of the array pointed to for pointer arguments. If not set the length is implicitly 1 (so not an array), but otherwise it can be set to the name of another member in the same record that will contain the length of the array (this is heavily used in the `fooCount` `foos` pattern in the API). As a special case `"strlen"` can be used for `const char*` record members to denote that the length should be determined with `strlen`.
- `"optional"` (default to false) a boolean that says whether this member is optional. Member records can be optional if they are pointers (otherwise dawn_wire will always try to dereference them), objects (otherwise dawn_wire will always try to encode their ID and crash), or if they have a `"default"` key. Optional pointers and objects will always default to `nullptr`.
- `"optional"` (default to false) a boolean that says whether this member is optional. Member records can be optional if they are pointers (otherwise dawn_wire will always try to dereference them), objects (otherwise dawn_wire will always try to encode their ID and crash), or if they have a `"default"` key. Optional pointers and objects will always default to `nullptr` (unless `"no_default"` is set to `true`).
- `"default"` (optional) a number or string. If set the record member will use that value as default value. Depending on the member's category it can be a number, a string containing a number, or the name of an enum/bitmask value.
- `"wire_is_data_only"` (default to false) a boolean that says whether it is safe to directly return a pointer of this member that is pointing to a piece of memory in the transfer buffer into dawn_wire. To prevent TOCTOU attacks, by default in dawn_wire we must ensure every single value returned to dawn_native a copy of what's in the wire, so `"wire_is_data_only"` is set to true only when the member is data-only and don't impact control flow.
@ -68,7 +68,8 @@ A **record** is a list of **record members**, each of which is a dictionary with
**`"structure"`**
- `"members"` a **record**, so an array of **record members**
- `"extensible"` (defaults to false) a boolean defining if this is an "extensible" WebGPU structure (i.e. has `nextInChain`). "descriptor" structures should usually have this set to true.
- `"chained"` (defaults to false) a boolean defining if this is a structure that can be "chained" in a WebGPU structure (i.e. has `nextInChain` and `sType`)
- `"chained"` (defaults to None) a string defining if this is a structure that can be "chained" in a WebGPU structure (i.e. has `nextInChain` and `sType`) and in which direction ('in' for inputs to WebGPU, 'out' for outputs)
- `"chain roots"` (defaults to []) a list of strings that are the canonical names of structures that can be extended by this structure.
**`"object"`**
- `**methods**` an array of methods for this object. Note that "release" and "reference" don't need to be specified. Each method is a dictionary containing:

54
docs/support.md Normal file
View File

@ -0,0 +1,54 @@
# Platform and API support for Dawn/Tint
## Khronos's Vulkan
Vulkan is supported with minimal features, limits and extensions being required (what's required has been measured to be wildly available).
Vulkan is the preferred target API on platforms that don't have other "modern" GPU APIs.
Vulkan is supported as best effort on other platforms (e.g. Windows and macOS).
**Required version**: Vulkan 1.0 is supported with some required extensions (`VK_KHR_maintenance1`), or Vulkan 1.1 and above without extensions.
**Required features**: `depthBiasClamp`, `fragmentStoresAndAtomics`, `fullDrawIndexUint32`, `imageCubeArray`, `independentBlend`, `sampleRateShading`, and either `textureCompressionBC` or both of `textureCompressionETC` and `textureCompressionASTC_LDR`.
**Required limites**: they are too detailed to describe here, but in general should be wildly supported.
See the [WebGPU limits](https://gpuweb.github.io/gpuweb/#limits) that mostly correspond to Vulkan limits.
**Operating system support**:
- Linux: Supported.
- ChromeOS: Supported.
- Android: Work in progress.
- Fuchsia: Work in progress.
## Microsoft's D3D12
D3D12 is supported with feature level 11.1, or feature level 11.0 with Resource Binding Tier 2.
This is the vast majority of D3D12 devices.
Supported shader models are 5.1 and above. It is the preferred target API when available.
**Windows flavor support**:
- Win32: Supported.
- UWP: Supported, best effort.
- Xbox: Not supported, contributions welcome.
## Apple's Metal
Metal is supported and is the preferred target API when available.
**Apple OS support:**
- macOS: supported.
- iOS: supported, best effort.
- tvOS/ipadOS/...: Not supported, contributions welcome.
## Khronos's OpenGL family
Support for OpenGL is in progress with the aim to make OpenGL ES 3.1 (with extensions and limits) supported through EGL.
Other flavors of OpenGL (desktop OpenGL) or binding APIs (GLX, WGL, EAGL, CGL) are supported as best effort with contributions welcome.
## Microsoft's D3D12
Dawn doesn't have a D3D11 backend at the moment, but D3D11 support can be achieved with the OpenGL ES backend through ANGLE's OpenGL ES to D3D11 translation.
There might be a D3D11 backend in the future.

View File

@ -16,13 +16,13 @@
┏━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━┓
┃ ProgramBuilder ┃
┃ (mutable) ┃
┏━━━━━━━━━━━━►┫ ┏━━━━━┓ ┏━━━━━━━┓ ┏━━━━━━━━━┓
┃ ┃ ┃ AST ┃ Types ┃ ┃ Symbols ┃ ┃
┃ ┃ ┗━━━━━┛ ┗━━━━━━━┛ ┗━━━━━━━━━┛
┏━━━━━━━━━━━━►┫ ┏━━━━━┓ ┏━━━━━━━━━┓
┃ ┃ ┃ AST ┃ ┃ Symbols ┃
┃ ┃ ┗━━━━━┛ ┗━━━━━━━━━┛
┃ ┗━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┛
┃ ▼
┃ ┌┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┃┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┐
▲ ┆ Build ▼ ┆
▲ ┆ Resolve ▼ ┆
┏━━━┻━━━┓ ┆ ┏━━━━━━━━┻━━━━━━━━┓ ┆
┃ Clone ┃ ┆ ┃ Resolver ┃ ┆
┗━━━┳━━━┛ ┆ ┗━━━━━━━━━━━━━━━━━┛ ┆
@ -31,9 +31,9 @@
┃ ┏━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃ Program ┃
┃ ┃ (immutable) ┃
┣━━━━━━◄┫ ┏━━━━━┓ ┏━━━━━━━┓ ┏━━━━━━━━━━┓ ┏━━━━━━━━━┓ ┃
┃ ┃ ┃ AST ┃ ┃ Types ┃ ┃ Semantic ┃ ┃ Symbols ┃
┃ ┃ ┗━━━━━┛ ┗━━━━━━━┛ ┗━━━━━━━━━━┛ ┗━━━━━━━━━┛ ┃
┣━━━━━━◄┫ ━━━━━┓ ┏━━━━━━━━━━┓ ┏━━━━━━━━━┓
┃ ┃ ┃ AST ┃ ┃ Semantic ┃ ┃ Symbols ┃
┃ ┃ ━━━━━┛ ┗━━━━━━━━━━┛ ┗━━━━━━━━━┛
┃ ┗━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┛
▲ ▼
┏━━━━━┻━━━━━┓ ┃ ┏━━━━━━━━━━━┓
@ -56,16 +56,16 @@
## Reader
Readers are responsible for parsing a shader program and populating a
`ProgramBuilder` with the parsed AST, type and symbol information.
`ProgramBuilder` with the parsed AST and symbol information.
The WGSL reader is a recursive descent parser. It closely follows the WGSL
grammar in the naming of the parse methods.
## ProgramBuilder
A `ProgramBuilder` is the primary interface to construct an immutable `Program`.
There are a number of methods exposed which make creating of the `Program`
simpler. A `ProgramBuilder` can only be used once, and must be discarded after
A `ProgramBuilder` is the interface to construct an immutable `Program`.
There are a large number of helper methods for simplifying the creation of the
AST nodes. A `ProgramBuilder` can only be used once, and must be discarded after
the `Program` is constructed.
A `Program` is built from the `ProgramBuilder` by `std::move()`ing the
@ -73,8 +73,9 @@ A `Program` is built from the `ProgramBuilder` by `std::move()`ing the
so the produced `Program` will contain all the needed semantic information.
At any time before building the `Program`, `ProgramBuilder::IsValid()` may be
called to ensure the AST is **structurally** correct. This checks that things
like `if` statements have a condition and body attached.
called to ensure that no error diagnostics have been raised during the
construction of the AST. This includes parser syntax errors, but not semantic
validation which happens during the `Resolve` phase.
If further changes to the `Program` are needed (say via a `Transform`) then a
new `ProgramBuilder` can be produced by cloning the `Program` into a new
@ -88,30 +89,14 @@ The Abstract Syntax Tree is a directed acyclic graph of `ast::Node`s which
encode the syntactic structure of the WGSL program.
The root of the AST is the `ast::Module` class which holds each of the declared
functions, variables and user defined types (type aliases and structures).
functions, variables and user declared types (type aliases and structures).
Each `ast::Node` represents a **single** part of the program's source, and so
`ast::Node`s are not shared.
The AST does not perform any verification of its content. For example, the
`ast::StrideAttribute` node has numeric stride parameter, which is a count of
the number of bytes from the start of one array element to the start of the
next. The AST node itself does not constrain the set of stride values that you
can set, aside from storing it as an unsigned integer.
## Types
Types are constructed during the Reader and resolution phases, and are
held by the `Program` or `ProgramBuilder`. AST and semantic nodes can both
reference types.
Each `type::Type` node **uniquely** represents a particular spelling of a WGSL
type within the program, so you can compare `type::Type*` pointers to check for
equivalence of type expressions.
For example, there is only one `type::Type` node for the `i32` type, no matter
how many times it is mentioned in the source program.
However, if `MyI32` is a type alias for `i32`, then they will have two different
type nodes.
`ast::Array` node has numeric size parameter, which is not validated to be
within the WGSL specification limits until validation of the `Resolver`.
## Semantic information
@ -133,6 +118,32 @@ and so the `sem::Variable` does not have a single corresponding
Unlike `ast::Node`s, semantic nodes may not necessarily form a directed acyclic
graph, and the semantic graph may contain diamonds.
## Types
AST types are regular AST nodes, in that they uniquely represent a single part
of the parsed source code. Unlike semantic types, identical AST types are not
de-duplicated as they refer to the source usage of the type.
Semantic types are constructed during the `Resolver` phase, and are held by
the `Program` or `ProgramBuilder`.
Each `sem::Type` node **uniquely** represents a particular WGSL type within the
program, so you can compare `type::Type*` pointers to check for type
equivalence. For example, a `Program` will only hold one instance of the
`sem::I32` semantic type, no matter how many times an `i32` is mentioned in the
source program.
WGSL type aliases resolve to their target semantic type. For example, given:
```wgsl
type MyI32 = i32;
const a : i32 = 1;
const b : MyI32 = 2;
```
The **semantic** types for the variables `a` and `b` will both be the same
`sem::I32` node pointer.
## Symbols
Symbols represent a unique string identifier in the source program. These string
@ -157,9 +168,9 @@ A `Program` holds an immutable version of the information from the
`ProgramBuilder` along with semantic information generated by the
`Resolver`.
Like `ProgramBuilder`, `Program::IsValid()` may be called to ensure the AST is
structurally correct and semantically valid, and that the `Resolver` did not
report any errors.
`Program::IsValid()` may be called to ensure the program is structurally correct
**and** semantically valid, and that the `Resolver` did not report any errors
during validation.
Unlike the `ProgramBuilder`, a `Program` is fully immutable, and is part of the
public Tint API. The immutable nature of `Program`s make these entirely safe

View File

@ -58,6 +58,26 @@ sem::ForLoopStatement {
}
```
## while
WGSL:
```
while (condition) {
statement;
}
```
Semantic tree:
```
sem::WhileStatement {
sem::Expression condition
sem::LoopBlockStatement {
sem::Statement statement
}
}
```
## loop
WGSL:

View File

@ -0,0 +1,28 @@
# Chromium Experimental Push Constant
The `chromium_experimental_push_constant` extension adds support for push constant global variables to WGSL.
Push constants are small amounts of data that are passed to the shader and are expected to be more lightweight to set / modify than uniform buffer bindings.
The concept of push constant comes from Vulkan but D3D12 has similar "root constants".
Metal doesn't have the same concept but push constants can be efficiently implemented with the `setBytes` family of command encoder methods.
## Status
Push constant support in Tint is highly experimental and only meant to be used in internal transforms at this stage.
Specification work in the WebGPU group hasn't started.
## Pseudo-specification
This extension adds a new `push_constant` storage class that's only allowed on global variable declarations.
Push constant variables must only contain 32bit data types (or aggregates of such types).
Push constant variable declarations must not have an initializer.
It is an error for a entry point to statically use more than one `push_constant` variable.
## Example usage
```
var<push_constant> draw_id : u32;
@fragment fn main() -> u32 {
return draw_id;
}
```

View File

@ -1,5 +1,55 @@
# Tint changes during Origin Trial
## Changes for M106
### New features
* `array()` constructor can now infer type and count. [tint:1628](crbug.com/tint/1628)
* `static_assert` statement has been added. [tint:1625](crbug.com/tint/1625)
### Deprecated Features
* The list of reserved words has been sync'd to the WGSL specification. [tint:1463](crbug.com/tint/1463)
## Changes for M105
### New features
* Module-scope `var<private>` can now infer the storage type, like function-scope `var`. [tint:1584](crbug.com/tint/1584)
* The `acosh`, `asinh`, and `atanh` builtin functions are now supported [tint:1465](crbug.com/tint/1465)
### Breaking changes
* The `smoothStep()` builtin has been removed (use `smoothstep` instead). [tint:1483](crbug.com/tint/1483)
* Module-scope `let` has been replaced with module-scope `const`. [tint:1580](crbug.com/tint/1584)
* Note: Module-scope `const` does not support structure types. Use `var<private>` if you need a module-scope structure type.
* Struct members can no longer be separated with semicolons (use commas instead). [tint:1475](crbug.com/tint/1475)
* Single scalar matrix constructors have been removed. These were never part of the WGSL spec. [tint:1597](crbug.com/tint/1597)
### Deprecated Features
* The `@stage` attribute has been deprecated. The short forms should be used
instead (`@vertex`, `@fragment`, or `@compute`). [tint:1503](crbug.com/tint/1503)
## Changes for M104
### New features
* Tint now supports abstract-numerics, removing the need to always suffix unsigned integers with `u` [tint:1504](crbug.com/tint/1504)
* Parsing of `@compute`, `@fragment` and `@vertex` added.
## Changes for M103
### New features
* Produce warnings for when calling barriers, textureSample, and derivative
builtins in non-uniform control flow [tint:880](crbug.com/tint/880)
* Matrix identity constructors and constructors for a single scalar value are now supported [tint:1545](crbug.com/tint/1545)
### Breaking changes
* Builtin `atomicCompareExchangeWeak` returns a struct instead of a vec2. [tint:1185](crbug.com/tint/1185)
## Changes for M102
### New Features

View File

@ -94,7 +94,7 @@ Current translation, through SPIR-V, SPIR-V reader, WGSL writer:
return;
}
@stage(fragment)
@fragment
fn main() -> void {
bar_();
return;
@ -126,7 +126,7 @@ Proposed translation, through SPIR-V, SPIR-V reader, WGSL writer:
@location(0) frag_color : vec4<f32>;
};
@stage(fragment)
@fragment
fn main(
// 'in' variables are entry point parameters

View File

@ -26,7 +26,7 @@ if (NOT DAWN_JINJA2_DIR)
message(FATAL_ERROR "Dawn: Missing dependencies for code generation, please ensure you have python-jinja2 installed.")
endif()
else()
message(STATUS "Dawn: Using jinja2 at ${DAWN_JINJA2_DIR}")
message(STATUS "Dawn: using jinja2 at ${DAWN_JINJA2_DIR}")
endif()
# Function to invoke a generator_lib.py generator.

View File

@ -0,0 +1,228 @@
#!/usr/bin/env python3
# Copyright 2022 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json, os, sys
from collections import namedtuple
from generator_lib import Generator, run_generator, FileRender
def parse_mask(mask):
if mask:
return int(mask, 0)
return 0xffffffff
class Name:
def __init__(self, name):
self.name = name
self.chunks = name.split(' ')
def get(self):
return self.name
def CamelChunk(self, chunk):
return chunk[0].upper() + chunk[1:]
def canonical_case(self):
return (' '.join(self.chunks)).lower()
def concatcase(self):
return ''.join(self.chunks)
def camelCase(self):
return self.chunks[0] + ''.join(
[self.CamelChunk(chunk) for chunk in self.chunks[1:]])
def CamelCase(self):
return ''.join([self.CamelChunk(chunk) for chunk in self.chunks])
def SNAKE_CASE(self):
return '_'.join([chunk.upper() for chunk in self.chunks])
def snake_case(self):
return '_'.join(self.chunks)
def js_enum_case(self):
result = self.chunks[0].lower()
for chunk in self.chunks[1:]:
if not result[-1].isdigit():
result += '-'
result += chunk.lower()
return result
class Architecture:
def __init__(self, name, json_data, mask):
self.name = Name(name)
self.devices = []
mask_num = parse_mask(mask)
for device in json_data:
device_num = int(device, 0)
# Don't allow duplicate entries
assert device not in self.devices, 'Architecture "{}" contained duplicate deviceID "{}"'.format(
self.name.get(), device)
# Ensure that all device IDs don't contain bits outside the mask
assert device_num & mask_num == device_num, 'Architecture "{}" contained deviceID "{}" which doesn\'t match the given mask of "{}"'.format(
self.name.get(), device, mask)
self.devices.append(device)
class DeviceSet:
def __init__(self, json_data):
self.mask = None
self.internal = False
if 'mask' in json_data:
self.mask = json_data['mask']
if 'internal' in json_data:
self.internal = json_data['internal']
self.architectures = []
if 'architecture' in json_data:
for (arch_name, arch_data) in json_data['architecture'].items():
# Skip any entries that start with an underscore. Used for comments.
if arch_name[0] == '_':
continue
architecture = Architecture(arch_name, arch_data, self.mask)
# Validate that deviceIDs are only allowed to be in one Architecture at a time
for other_architecture in self.architectures:
for device in architecture.devices:
assert device not in other_architecture.devices, 'Architectures "{}" and "{}" both contain deviceID "{}"'.format(
architecture.name.get(),
other_architecture.name.get(), device)
self.architectures.append(architecture)
def validate_devices(self, other_devices, other_mask):
combined_mask = parse_mask(self.mask) & parse_mask(other_mask)
for other_device in other_devices:
other_device_num = int(other_device, 0) & combined_mask
for architecture in self.architectures:
for device in architecture.devices:
device_num = int(device, 0) & combined_mask
assert device_num != other_device_num, 'DeviceID "{}" & mask "{}" conflicts with deviceId "{}" & mask "{}" in architecture "{}"'.format(
other_device, other_mask, device, self.mask,
architecture.name.get())
def maskDeviceId(self):
if not self.mask:
return ''
return ' & ' + self.mask
class Vendor:
def __init__(self, name, json_data):
self.name = Name(name)
self.id = json_data['id']
architecture_dict = {}
internal_architecture_dict = {}
self.device_sets = []
if 'devices' in json_data:
for device_data in json_data['devices']:
device_set = DeviceSet(device_data)
for architecture in device_set.architectures:
# Validate that deviceIDs are unique across device sets
for other_device_set in self.device_sets:
# Only validate device IDs between internal and public device sets.
if other_device_set.internal == device_set.internal:
assert device_set.mask != other_device_set.mask, 'Vendor "{}" contained duplicate device masks "{}"'.format(
self.name.get(), device_set.mask)
other_device_set.validate_devices(
architecture.devices, device_set.mask)
# Validate that architecture names are unique between internal and public device sets.
else:
for other_architecture in other_device_set.architectures:
assert architecture.name.canonical_case(
) != other_architecture.name.canonical_case(
), '"{}" is defined as both an internal and public architecture'.format(
architecture.name.get())
if device_set.internal:
internal_architecture_dict[
architecture.name.canonical_case(
)] = architecture.name
else:
architecture_dict[architecture.name.canonical_case(
)] = architecture.name
self.device_sets.append(device_set)
# List of unique architecture names under this vendor
self.architecture_names = architecture_dict.values()
self.internal_architecture_names = internal_architecture_dict.values()
def parse_json(json):
vendors = []
internal_architecture_count = 0
for (vendor_name, vendor_data) in json['vendors'].items():
# Skip vendors that have a leading underscore. Those are intended to be "comments".
if vendor_name[0] == '_':
continue
vendor = Vendor(vendor_name, vendor_data)
vendors.append(vendor)
internal_architecture_count += len(vendor.internal_architecture_names)
return {
'vendors': vendors,
'has_internal': internal_architecture_count > 0
}
class DawnGpuInfoGenerator(Generator):
def get_description(self):
return "Generates GPU Info Dawn code."
def add_commandline_arguments(self, parser):
parser.add_argument('--gpu-info-json',
required=True,
type=str,
help='The GPU Info JSON definition to use.')
def get_dependencies(self, args):
return [os.path.abspath(args.gpu_info_json)]
def get_file_renders(self, args):
with open(args.gpu_info_json) as f:
loaded_json = json.loads(f.read())
params = parse_json(loaded_json)
return [
FileRender("dawn/common/GPUInfo.h",
"src/dawn/common/GPUInfo_autogen.h", [params]),
FileRender("dawn/common/GPUInfo.cpp",
"src/dawn/common/GPUInfo_autogen.cpp", [params]),
]
if __name__ == "__main__":
sys.exit(run_generator(DawnGpuInfoGenerator()))

View File

@ -237,12 +237,13 @@ class StructureType(Record, Type):
m for m in json_data['members'] if is_enabled(m)
]
Type.__init__(self, name, dict(json_data, **json_data_override))
self.chained = json_data.get("chained", None)
self.extensible = json_data.get("extensible", None)
self.chained = json_data.get('chained', None)
self.extensible = json_data.get('extensible', None)
if self.chained:
assert (self.chained == "in" or self.chained == "out")
assert self.chained == 'in' or self.chained == 'out'
assert 'chain roots' in json_data
if self.extensible:
assert (self.extensible == "in" or self.extensible == "out")
assert self.extensible == 'in' or self.extensible == 'out'
# Chained structs inherit from wgpu::ChainedStruct, which has
# nextInChain, so setting both extensible and chained would result in
# two nextInChain members.
@ -348,6 +349,8 @@ def link_object(obj, types):
def link_structure(struct, types):
struct.members = linked_record_members(struct.json_data['members'], types)
struct.chain_roots = [types[root] for root in struct.json_data.get('chain roots', [])]
assert all((root.category == 'structure' for root in struct.chain_roots))
def link_function_pointer(function_pointer, types):
@ -947,6 +950,10 @@ class MultiGeneratorFromDawnJSON(Generator):
FileRender('dawn/native/api_absl_format.cpp',
'src/' + native_dir + '/' + api + '_absl_format_autogen.cpp',
frontend_params))
renders.append(
FileRender(
'dawn/native/api_StreamImpl.cpp', 'src/' + native_dir +
'/' + api + '_StreamImpl_autogen.cpp', frontend_params))
renders.append(
FileRender('dawn/native/ObjectType.h',
'src/' + native_dir + '/ObjectType_autogen.h',
@ -955,10 +962,6 @@ class MultiGeneratorFromDawnJSON(Generator):
FileRender('dawn/native/ObjectType.cpp',
'src/' + native_dir + '/ObjectType_autogen.cpp',
frontend_params))
renders.append(
FileRender('dawn/native/CacheKey.cpp',
'src/' + native_dir + '/CacheKey_autogen.cpp',
frontend_params))
if 'wire' in targets:
params_dawn_wire = parse_json(loaded_json,

View File

@ -26,11 +26,11 @@ def get_git():
return git_exec
def get_gitHash(dawnDir):
def get_git_hash(dawn_dir):
try:
result = subprocess.run([get_git(), "rev-parse", "HEAD"],
stdout=subprocess.PIPE,
cwd=dawnDir)
cwd=dawn_dir)
if result.returncode == 0:
return result.stdout.decode("utf-8").strip()
except Exception:
@ -40,15 +40,15 @@ def get_gitHash(dawnDir):
return ""
def get_gitHead(dawnDir):
return os.path.join(dawnDir, ".git", "HEAD")
def get_git_head(dawn_dir):
return os.path.join(dawn_dir, ".git", "HEAD")
def gitExists(dawnDir):
return os.path.exists(get_gitHead(dawnDir))
def git_exists(dawn_dir):
return os.path.exists(get_git_head(dawn_dir))
def unpackGitRef(packed, resolved):
def unpack_git_ref(packed, resolved):
with open(packed) as fin:
refs = fin.read().strip().split("\n")
@ -64,20 +64,20 @@ def unpackGitRef(packed, resolved):
return False
def get_gitResolvedHead(dawnDir):
def get_git_resolved_head(dawn_dir):
result = subprocess.run(
[get_git(), "rev-parse", "--symbolic-full-name", "HEAD"],
stdout=subprocess.PIPE,
cwd=dawnDir)
cwd=dawn_dir)
if result.returncode != 0:
raise Exception("Failed to execute git rev-parse to resolve git head:", result.stdout)
resolved = os.path.join(dawnDir, ".git",
resolved = os.path.join(dawn_dir, ".git",
result.stdout.decode("utf-8").strip())
# Check a packed-refs file exists. If so, we need to potentially unpack and include it as a dep.
packed = os.path.join(dawnDir, ".git", "packed-refs")
if os.path.exists(packed) and unpackGitRef(packed, resolved):
packed = os.path.join(dawn_dir, ".git", "packed-refs")
if os.path.exists(packed) and unpack_git_ref(packed, resolved):
return [packed, resolved]
if not os.path.exists(resolved):
@ -85,15 +85,25 @@ def get_gitResolvedHead(dawnDir):
return [resolved]
def get_version(args):
version_file = args.version_file
if version_file:
with open(version_file) as f:
return f.read()
return get_git_hash(os.path.abspath(args.dawn_dir))
def compute_params(args):
return {
"get_gitHash": lambda: get_gitHash(os.path.abspath(args.dawn_dir)),
"get_version": lambda: get_version(args),
}
class DawnVersionGenerator(Generator):
def get_description(self):
return "Generates version dependent Dawn code. Currently regenerated dependent on git hash."
return (
"Generates version dependent Dawn code. Currently regenerated dependent on the version "
"header (if available), otherwise tries to use git hash.")
def add_commandline_arguments(self, parser):
parser.add_argument(
@ -102,12 +112,24 @@ class DawnVersionGenerator(Generator):
type=str,
help="The Dawn root directory path to use",
)
parser.add_argument(
"--version-file",
required=False,
type=str,
help=
("Path to one-liner version string file used when git may not be present. "
"In general the version string is a git hash."))
def get_dependencies(self, args):
dawnDir = os.path.abspath(args.dawn_dir)
if gitExists(dawnDir):
dawn_dir = os.path.abspath(args.dawn_dir)
version_file = args.version_file
if version_file:
return [version_file]
if git_exists(dawn_dir):
try:
return [get_gitHead(dawnDir)] + get_gitResolvedHead(dawnDir)
return [get_git_head(dawn_dir)
] + get_git_resolved_head(dawn_dir)
except Exception:
return []
return []

View File

@ -78,7 +78,6 @@ def run():
for candidate in get_all_files_in_dir(stale_dir):
if not check_is_allowed(candidate, allowed_dirs):
print("Warning: remove_files.py removed " + candidate)
os.remove(candidate)
# Finished! Write the stamp file so ninja knows to not run this again.

View File

@ -89,6 +89,9 @@ typedef struct {{c_prefix}}ChainedStructOut {
} {{c_prefix}}ChainedStructOut;
{% for type in by_category["structure"] %}
{% for root in type.chain_roots %}
// Can be chained in {{as_cType(root.name)}}
{% endfor %}
typedef struct {{as_cType(type.name)}} {
{% set Out = "Out" if type.output else "" %}
{% set const = "const " if not type.output else "" %}
@ -100,6 +103,7 @@ typedef struct {{c_prefix}}ChainedStructOut {
{% endif %}
{% for member in type.members %}
{{as_annotated_cType(member)}};
{%- if member.optional %} // nullable{% endif %}{{""}}
{% endfor %}
} {{as_cType(type.name)}};
@ -143,6 +147,7 @@ extern "C" {
{{-as_cType(type.name)}} {{as_varName(type.name)}}
{%- for arg in method.arguments -%}
, {{as_annotated_cType(arg)}}
{%- if arg.optional %} /* nullable */{% endif %}
{%- endfor -%}
);
{% endfor %}
@ -167,6 +172,7 @@ extern "C" {
{{-as_cType(type.name)}} {{as_varName(type.name)}}
{%- for arg in method.arguments -%}
, {{as_annotated_cType(arg)}}
{%- if arg.optional %} /* nullable */{% endif %}
{%- endfor -%}
);
{% endfor %}

View File

@ -27,6 +27,12 @@
namespace {{metadata.namespace}} {
namespace detail {
constexpr size_t ConstexprMax(size_t a, size_t b) {
return a > b ? a : b;
}
} // namespace detail
{% set c_prefix = metadata.c_prefix %}
{% for constant in by_category["constant"] %}
{% set type = as_cppType(constant.type.name) %}
@ -146,7 +152,8 @@ namespace {{metadata.namespace}} {
};
{% macro render_cpp_default_value(member, is_struct=True) -%}
{%- if member.annotation in ["*", "const*"] and member.optional or member.default_value == "nullptr" -%}
{%- if member.json_data.get("no_default", false) -%}
{%- elif member.annotation in ["*", "const*"] and member.optional or member.default_value == "nullptr" -%}
{{" "}}= nullptr
{%- elif member.type.category == "object" and member.optional and is_struct -%}
{{" "}}= nullptr
@ -219,6 +226,9 @@ namespace {{metadata.namespace}} {
{% set Out = "Out" if type.output else "" %}
{% set const = "const" if not type.output else "" %}
{% if type.chained %}
{% for root in type.chain_roots %}
// Can be chained in {{as_cppType(root.name)}}
{% endfor %}
struct {{as_cppType(type.name)}} : ChainedStruct{{Out}} {
{{as_cppType(type.name)}}() {
sType = SType::{{type.name.CamelCase()}};
@ -232,8 +242,10 @@ namespace {{metadata.namespace}} {
{% for member in type.members %}
{% set member_declaration = as_annotated_cppType(member) + render_cpp_default_value(member) %}
{% if type.chained and loop.first %}
//* Align the first member to ChainedStruct to match the C struct layout.
alignas(ChainedStruct{{Out}}) {{member_declaration}};
//* Align the first member after ChainedStruct to match the C struct layout.
//* It has to be aligned both to its natural and ChainedStruct's alignment.
static constexpr size_t kFirstMemberAlignment = detail::ConstexprMax(alignof(ChainedStruct{{out}}), alignof({{decorate("", as_cppType(member.type.name), member)}}));
alignas(kFirstMemberAlignment) {{member_declaration}};
{% else %}
{{member_declaration}};
{% endif %}

View File

@ -0,0 +1,154 @@
// Copyright 2022 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <algorithm>
#include <array>
#include <sstream>
#include <iomanip>
#include "dawn/common/GPUInfo_autogen.h"
#include "dawn/common/Assert.h"
namespace gpu_info {
namespace {
enum class Architecture {
Unknown,
{% for vendor in vendors %}
{% for architecture_name in vendor.architecture_names %}
{{vendor.name.CamelCase()}}_{{architecture_name.CamelCase()}},
{% endfor %}
{% endfor %}
};
Architecture GetArchitecture(PCIVendorID vendorId, PCIDeviceID deviceId) {
switch(vendorId) {
{% for vendor in vendors %}
{% if len(vendor.device_sets) %}
case kVendorID_{{vendor.name.CamelCase()}}: {
{% for device_set in vendor.device_sets %}
{% if not device_set.internal %}
switch (deviceId{{device_set.maskDeviceId()}}) {
{% for architecture in device_set.architectures %}
{% for device in architecture.devices %}
case {{device}}:
{% endfor %}
return Architecture::{{vendor.name.CamelCase()}}_{{architecture.name.CamelCase()}};
{% endfor %}
}
{% endif %}
{% endfor %}
} break;
{% endif %}
{% endfor %}
}
return Architecture::Unknown;
}
{% if has_internal %}
enum class InternalArchitecture {
Unknown,
{% for vendor in vendors %}
{% for architecture_name in vendor.internal_architecture_names %}
{{vendor.name.CamelCase()}}_{{architecture_name.CamelCase()}},
{% endfor %}
{% endfor %}
};
InternalArchitecture GetInternalArchitecture(PCIVendorID vendorId, PCIDeviceID deviceId) {
switch(vendorId) {
{% for vendor in vendors %}
{% if len(vendor.device_sets) %}
case kVendorID_{{vendor.name.CamelCase()}}: {
{% for device_set in vendor.device_sets %}
{% if device_set.internal %}
switch (deviceId{{device_set.maskDeviceId()}}) {
{% for architecture in device_set.architectures %}
{% for device in architecture.devices %}
case {{device}}:
{% endfor %}
return InternalArchitecture::{{vendor.name.CamelCase()}}_{{architecture.name.CamelCase()}};
{% endfor %}
}
{% endif %}
{% endfor %}
} break;
{% endif %}
{% endfor %}
}
return InternalArchitecture::Unknown;
}
{% endif %}
} // namespace
// Vendor checks
{% for vendor in vendors %}
bool Is{{vendor.name.CamelCase()}}(PCIVendorID vendorId) {
return vendorId == kVendorID_{{vendor.name.CamelCase()}};
}
{% endfor %}
// Architecture checks
{% for vendor in vendors %}
{% if len(vendor.architecture_names) %}
// {{vendor.name.get()}} architectures
{% for architecture_name in vendor.architecture_names %}
bool Is{{vendor.name.CamelCase()}}{{architecture_name.CamelCase()}}(PCIVendorID vendorId, PCIDeviceID deviceId) {
return GetArchitecture(vendorId, deviceId) == Architecture::{{vendor.name.CamelCase()}}_{{architecture_name.CamelCase()}};
}
{% endfor %}
{% for architecture_name in vendor.internal_architecture_names %}
bool Is{{vendor.name.CamelCase()}}{{architecture_name.CamelCase()}}(PCIVendorID vendorId, PCIDeviceID deviceId) {
return GetInternalArchitecture(vendorId, deviceId) == InternalArchitecture::{{vendor.name.CamelCase()}}_{{architecture_name.CamelCase()}};
}
{% endfor %}
{% endif %}
{% endfor %}
// GPUAdapterInfo fields
std::string GetVendorName(PCIVendorID vendorId) {
switch(vendorId) {
{% for vendor in vendors %}
case kVendorID_{{vendor.name.CamelCase()}}: return "{{vendor.name.js_enum_case()}}";
{% endfor %}
}
return "";
}
std::string GetArchitectureName(PCIVendorID vendorId, PCIDeviceID deviceId) {
Architecture arch = GetArchitecture(vendorId, deviceId);
switch(arch) {
case Architecture::Unknown:
return "";
{% for vendor in vendors %}
{% for architecture_name in vendor.architecture_names %}
case Architecture::{{vendor.name.CamelCase()}}_{{architecture_name.CamelCase()}}:
return "{{architecture_name.js_enum_case()}}";
{% endfor %}
{% endfor %}
}
return "";
}
} // namespace gpu_info

View File

@ -0,0 +1,55 @@
// Copyright 2022 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_DAWN_COMMON_GPUINFO_AUTOGEN_H_
#define SRC_DAWN_COMMON_GPUINFO_AUTOGEN_H_
#include <cstdint>
#include <string>
using PCIVendorID = uint32_t;
using PCIDeviceID = uint32_t;
namespace gpu_info {
// Vendor IDs
{% for vendor in vendors %}
static constexpr PCIVendorID kVendorID_{{vendor.name.CamelCase()}} = {{vendor.id}};
{% endfor %}
// Vendor checks
{% for vendor in vendors %}
bool Is{{vendor.name.CamelCase()}}(PCIVendorID vendorId);
{% endfor %}
// Architecture checks
{% for vendor in vendors %}
{% if len(vendor.architecture_names) %}
// {{vendor.name.get()}} architectures
{% for architecture_name in vendor.architecture_names %}
bool Is{{vendor.name.CamelCase()}}{{architecture_name.CamelCase()}}(PCIVendorID vendorId, PCIDeviceID deviceId);
{% endfor %}
{% for architecture_name in vendor.internal_architecture_names %}
bool Is{{vendor.name.CamelCase()}}{{architecture_name.CamelCase()}}(PCIVendorID vendorId, PCIDeviceID deviceId);
{% endfor %}
{% endif %}
{% endfor %}
// GPUAdapterInfo fields
std::string GetVendorName(PCIVendorID vendorId);
std::string GetArchitectureName(PCIVendorID vendorId, PCIDeviceID deviceId);
} // namespace gpu_info
#endif // SRC_DAWN_COMMON_GPUINFO_AUTOGEN_H_

View File

@ -15,9 +15,13 @@
#ifndef COMMON_VERISON_AUTOGEN_H_
#define COMMON_VERISON_AUTOGEN_H_
#include <string_view>
namespace dawn {
static constexpr char kGitHash[] = "{{get_gitHash()}}";
// The version string should either be a valid git hash or empty.
static constexpr std::string_view kDawnVersion("{{get_version()}}");
static_assert(kDawnVersion.size() == 40 || kDawnVersion.size() == 0);
} // namespace dawn

View File

@ -1,68 +0,0 @@
//* Copyright 2022 The Dawn Authors
//*
//* Licensed under the Apache License, Version 2.0 (the "License");
//* you may not use this file except in compliance with the License.
//* You may obtain a copy of the License at
//*
//* http://www.apache.org/licenses/LICENSE-2.0
//*
//* Unless required by applicable law or agreed to in writing, software
//* distributed under the License is distributed on an "AS IS" BASIS,
//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//* See the License for the specific language governing permissions and
//* limitations under the License.
{% set impl_dir = metadata.impl_dir + "/" if metadata.impl_dir else "" %}
{% set namespace_name = Name(metadata.native_namespace) %}
{% set native_namespace = namespace_name.namespace_case() %}
{% set native_dir = impl_dir + namespace_name.Dirs() %}
{% set prefix = metadata.proc_table_prefix.lower() %}
#include "{{native_dir}}/CacheKey.h"
#include "{{native_dir}}/{{prefix}}_platform.h"
#include <cstring>
namespace {{native_namespace}} {
//
// Cache key serializers for wgpu structures used in caching.
//
{% macro render_serializer(member) %}
{%- set name = member.name.camelCase() -%}
{% if member.length == None %}
key->Record(t.{{name}});
{% elif member.length == "strlen" %}
key->RecordIterable(t.{{name}}, strlen(t.{{name}}));
{% else %}
key->RecordIterable(t.{{name}}, t.{{member.length.name.camelCase()}});
{% endif %}
{% endmacro %}
{# Helper macro to render serializers. Should be used in a call block to provide additional custom
handling when necessary. The optional `omit` field can be used to omit fields that are either
handled in the custom code, or unnecessary in the serialized output.
Example:
{% call render_cache_key_serializer("struct name", omits=["omit field"]) %}
// Custom C++ code to handle special types/members that are hard to generate code for
{% endcall %}
#}
{% macro render_cache_key_serializer(json_type, omits=[]) %}
{%- set cpp_type = types[json_type].name.CamelCase() -%}
template <>
void CacheKeySerializer<{{cpp_type}}>::Serialize(CacheKey* key, const {{cpp_type}}& t) {
{{ caller() }}
{% for member in types[json_type].members %}
{%- if not member.name.get() in omits %}
{{render_serializer(member)}}
{%- endif %}
{% endfor %}
}
{% endmacro %}
{% call render_cache_key_serializer("adapter properties") %}
{% endcall %}
{% call render_cache_key_serializer("dawn cache device descriptor") %}
{% endcall %}
} // namespace {{native_namespace}}

View File

@ -66,7 +66,7 @@ namespace {{native_namespace}} {
{%- endfor -%}
);
{% if method.return_type.name.canonical_case() != "void" %}
{% if method.return_type.category == "object" %}
{% if method.return_type.category in ["object", "enum", "bitmask"] %}
return ToAPI(result);
{% else %}
return result;
@ -104,7 +104,7 @@ namespace {{native_namespace}} {
{%- endfor -%}
);
{% if function.return_type.name.canonical_case() != "void" %}
{% if function.return_type.category == "object" %}
{% if function.return_type.category in ["object", "enum", "bitmask"] %}
return ToAPI(result);
{% else %}
return result;

View File

@ -0,0 +1,68 @@
//* Copyright 2022 The Dawn Authors
//*
//* Licensed under the Apache License, Version 2.0 (the "License");
//* you may not use this file except in compliance with the License.
//* You may obtain a copy of the License at
//*
//* http://www.apache.org/licenses/LICENSE-2.0
//*
//* Unless required by applicable law or agreed to in writing, software
//* distributed under the License is distributed on an "AS IS" BASIS,
//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//* See the License for the specific language governing permissions and
//* limitations under the License.
{% set impl_dir = metadata.impl_dir + "/" if metadata.impl_dir else "" %}
{% set namespace_name = Name(metadata.native_namespace) %}
{% set native_namespace = namespace_name.namespace_case() %}
{% set native_dir = impl_dir + namespace_name.Dirs() %}
{% set prefix = metadata.proc_table_prefix.lower() %}
#include "{{native_dir}}/CacheKey.h"
#include "{{native_dir}}/{{prefix}}_platform.h"
#include <cstring>
namespace {{native_namespace}} {
//
// Cache key writers for wgpu structures used in caching.
//
{% macro render_writer(member) %}
{%- set name = member.name.camelCase() -%}
{% if member.length == None %}
StreamIn(sink, t.{{name}});
{% elif member.length == "strlen" %}
StreamIn(sink, Iterable(t.{{name}}, strlen(t.{{name}})));
{% else %}
StreamIn(sink, Iterable(t.{{name}}, t.{{member.length.name.camelCase()}}));
{% endif %}
{% endmacro %}
{# Helper macro to render writers. Should be used in a call block to provide additional custom
handling when necessary. The optional `omit` field can be used to omit fields that are either
handled in the custom code, or unnecessary in the serialized output.
Example:
{% call render_cache_key_writer("struct name", omits=["omit field"]) %}
// Custom C++ code to handle special types/members that are hard to generate code for
{% endcall %}
#}
{% macro render_cache_key_writer(json_type, omits=[]) %}
{%- set cpp_type = types[json_type].name.CamelCase() -%}
template <>
void stream::Stream<{{cpp_type}}>::Write(stream::Sink* sink, const {{cpp_type}}& t) {
{{ caller() }}
{% for member in types[json_type].members %}
{%- if not member.name.get() in omits %}
{{render_writer(member)}}
{%- endif %}
{% endfor %}
}
{% endmacro %}
{% call render_cache_key_writer("adapter properties") %}
{% endcall %}
{% call render_cache_key_writer("dawn cache device descriptor") %}
{% endcall %}
} // namespace {{native_namespace}}

View File

@ -64,8 +64,9 @@ namespace {{native_namespace}} {
{% for member in type.members %}
{% set member_declaration = as_annotated_frontendType(member) + render_cpp_default_value(member) %}
{% if type.chained and loop.first %}
//* Align the first member to ChainedStruct to match the C struct layout.
alignas(ChainedStruct) {{member_declaration}};
//* Align the first member after ChainedStruct to match the C struct layout.
//* It has to be aligned both to its natural and ChainedStruct's alignment.
alignas({{namespace}}::{{as_cppType(type.name)}}::kFirstMemberAlignment) {{member_declaration}};
{% else %}
{{member_declaration}};
{% endif %}

View File

@ -77,6 +77,16 @@ namespace {{native_namespace}} {
static constexpr uint32_t value = {{len(e.values)}};
};
{% endfor %}
{% for type in by_category["enum"] + by_category["bitmask"] %}
inline {{as_cType(type.name)}} ToAPI({{namespace}}::{{as_cppType(type.name)}} rhs) {
return static_cast<{{as_cType(type.name)}}>(rhs);
}
inline {{namespace}}::{{as_cppType(type.name)}} FromAPI({{as_cType(type.name)}} rhs) {
return static_cast<{{namespace}}::{{as_cppType(type.name)}}>(rhs);
}
{% endfor %}
}
#endif // {{NATIVE_DIR}}_{{PREFIX}}_PLATFORM_AUTOGEN_H_

View File

@ -651,31 +651,6 @@
namespace dawn::wire {
ObjectHandle::ObjectHandle() = default;
ObjectHandle::ObjectHandle(ObjectId id, ObjectGeneration generation)
: id(id), generation(generation) {
}
ObjectHandle::ObjectHandle(const volatile ObjectHandle& rhs)
: id(rhs.id), generation(rhs.generation) {
}
ObjectHandle& ObjectHandle::operator=(const volatile ObjectHandle& rhs) {
id = rhs.id;
generation = rhs.generation;
return *this;
}
ObjectHandle& ObjectHandle::AssignFrom(const ObjectHandle& rhs) {
id = rhs.id;
generation = rhs.generation;
return *this;
}
ObjectHandle& ObjectHandle::AssignFrom(const volatile ObjectHandle& rhs) {
id = rhs.id;
generation = rhs.generation;
return *this;
}
namespace {
// Allocates enough space from allocator to countain T[count] and return it in out.
// Return FatalError if the allocator couldn't allocate the memory.
@ -784,72 +759,4 @@ namespace dawn::wire {
{{ write_command_serialization_methods(command, True) }}
{% endfor %}
// Implementations of serialization/deserialization of WPGUDeviceProperties.
size_t SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties) {
return sizeof(WGPUDeviceProperties) +
WGPUDevicePropertiesGetExtraRequiredSize(*deviceProperties);
}
void SerializeWGPUDeviceProperties(const WGPUDeviceProperties* deviceProperties,
char* buffer) {
SerializeBuffer serializeBuffer(buffer, SerializedWGPUDevicePropertiesSize(deviceProperties));
WGPUDevicePropertiesTransfer* transfer;
WireResult result = serializeBuffer.Next(&transfer);
ASSERT(result == WireResult::Success);
ErrorObjectIdProvider provider;
result = WGPUDevicePropertiesSerialize(*deviceProperties, transfer, &serializeBuffer, provider);
ASSERT(result == WireResult::Success);
}
bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties,
const volatile char* buffer,
size_t size) {
const volatile WGPUDevicePropertiesTransfer* transfer;
DeserializeBuffer deserializeBuffer(buffer, size);
if (deserializeBuffer.Read(&transfer) != WireResult::Success) {
return false;
}
ErrorObjectIdResolver resolver;
return WGPUDevicePropertiesDeserialize(deviceProperties, transfer, &deserializeBuffer,
nullptr, resolver) == WireResult::Success;
}
size_t SerializedWGPUSupportedLimitsSize(const WGPUSupportedLimits* supportedLimits) {
return sizeof(WGPUSupportedLimits) +
WGPUSupportedLimitsGetExtraRequiredSize(*supportedLimits);
}
void SerializeWGPUSupportedLimits(
const WGPUSupportedLimits* supportedLimits,
char* buffer) {
SerializeBuffer serializeBuffer(buffer, SerializedWGPUSupportedLimitsSize(supportedLimits));
WGPUSupportedLimitsTransfer* transfer;
WireResult result = serializeBuffer.Next(&transfer);
ASSERT(result == WireResult::Success);
ErrorObjectIdProvider provider;
result = WGPUSupportedLimitsSerialize(*supportedLimits, transfer, &serializeBuffer, provider);
ASSERT(result == WireResult::Success);
}
bool DeserializeWGPUSupportedLimits(WGPUSupportedLimits* supportedLimits,
const volatile char* buffer,
size_t size) {
const volatile WGPUSupportedLimitsTransfer* transfer;
DeserializeBuffer deserializeBuffer(buffer, size);
if (deserializeBuffer.Read(&transfer) != WireResult::Success) {
return false;
}
ErrorObjectIdResolver resolver;
return WGPUSupportedLimitsDeserialize(supportedLimits, transfer, &deserializeBuffer,
nullptr, resolver) == WireResult::Success;
}
} // namespace dawn::wire

View File

@ -19,32 +19,11 @@
#include "dawn/wire/BufferConsumer.h"
#include "dawn/wire/ObjectType_autogen.h"
#include "dawn/wire/ObjectHandle.h"
#include "dawn/wire/WireResult.h"
namespace dawn::wire {
using ObjectId = uint32_t;
using ObjectGeneration = uint32_t;
struct ObjectHandle {
ObjectId id;
ObjectGeneration generation;
ObjectHandle();
ObjectHandle(ObjectId id, ObjectGeneration generation);
ObjectHandle(const volatile ObjectHandle& rhs);
ObjectHandle& operator=(const volatile ObjectHandle& rhs);
// MSVC has a bug where it thinks the volatile copy assignment is a duplicate.
// Workaround this by forwarding to a different function AssignFrom.
template <typename T>
ObjectHandle& operator=(const T& rhs) {
return AssignFrom(rhs);
}
ObjectHandle& AssignFrom(const ObjectHandle& rhs);
ObjectHandle& AssignFrom(const volatile ObjectHandle& rhs);
};
// Interface to allocate more space to deserialize pointed-to data.
// nullptr is treated as an error.
class DeserializeAllocator {

View File

@ -20,10 +20,8 @@
namespace dawn::wire::client {
template <typename T>
struct ObjectTypeToTypeEnum {
static constexpr ObjectType value = static_cast<ObjectType>(-1);
};
template<typename T>
inline constexpr ObjectType ObjectTypeToTypeEnum = static_cast<ObjectType>(-1);
{% for type in by_category["object"] %}
{% set Type = type.name.CamelCase() %}
@ -43,9 +41,7 @@ namespace dawn::wire::client {
}
template <>
struct ObjectTypeToTypeEnum<{{Type}}> {
static constexpr ObjectType value = ObjectType::{{Type}};
};
inline constexpr ObjectType ObjectTypeToTypeEnum<{{Type}}> = ObjectType::{{Type}};
{% endfor %}
} // namespace dawn::wire::client

View File

@ -58,8 +58,8 @@ namespace dawn::wire::client {
//* For object creation, store the object ID the client will use for the result.
{% if method.return_type.category == "object" %}
auto* allocation = self->client->{{method.return_type.name.CamelCase()}}Allocator().New(self->client);
cmd.result = ObjectHandle{allocation->object->id, allocation->generation};
auto* returnObject = self->GetClient()->Make<{{method.return_type.name.CamelCase()}}>();
cmd.result = returnObject->GetWireHandle();
{% endif %}
{% for arg in method.arguments %}
@ -69,10 +69,10 @@ namespace dawn::wire::client {
{% endfor %}
//* Allocate space to send the command and copy the value args over.
self->client->SerializeCommand(cmd);
self->GetClient()->SerializeCommand(cmd);
{% if method.return_type.category == "object" %}
return reinterpret_cast<{{as_cType(method.return_type.name)}}>(allocation->object.get());
return ToAPI(returnObject);
{% endif %}
{% else %}
return self->{{method.name.CamelCase()}}(
@ -86,23 +86,22 @@ namespace dawn::wire::client {
//* When an object's refcount reaches 0, notify the server side of it and delete it.
void Client{{as_MethodSuffix(type.name, Name("release"))}}({{cType}} cObj) {
{{Type}}* obj = reinterpret_cast<{{Type}}*>(cObj);
obj->refcount --;
if (obj->refcount > 0) {
if (!obj->Release()) {
return;
}
DestroyObjectCmd cmd;
cmd.objectType = ObjectType::{{type.name.CamelCase()}};
cmd.objectId = obj->id;
cmd.objectId = obj->GetWireId();
obj->client->SerializeCommand(cmd);
obj->client->{{type.name.CamelCase()}}Allocator().Free(obj);
Client* client = obj->GetClient();
client->SerializeCommand(cmd);
client->Free(obj);
}
void Client{{as_MethodSuffix(type.name, Name("reference"))}}({{cType}} cObj) {
{{Type}}* obj = reinterpret_cast<{{Type}}*>(cObj);
obj->refcount ++;
reinterpret_cast<{{Type}}*>(cObj)->Reference();
}
{% endfor %}

View File

@ -18,33 +18,13 @@
#include "dawn/wire/ChunkedCommandHandler.h"
#include "dawn/wire/WireCmd_autogen.h"
#include "dawn/wire/client/ApiObjects.h"
#include "dawn/wire/client/ObjectAllocator.h"
namespace dawn::wire::client {
class ClientBase : public ChunkedCommandHandler, public ObjectIdProvider {
public:
ClientBase() = default;
virtual ~ClientBase() = default;
{% for type in by_category["object"] %}
const ObjectAllocator<{{type.name.CamelCase()}}>& {{type.name.CamelCase()}}Allocator() const {
return m{{type.name.CamelCase()}}Allocator;
}
ObjectAllocator<{{type.name.CamelCase()}}>& {{type.name.CamelCase()}}Allocator() {
return m{{type.name.CamelCase()}}Allocator;
}
{% endfor %}
void FreeObject(ObjectType objectType, ObjectBase* obj) {
switch (objectType) {
{% for type in by_category["object"] %}
case ObjectType::{{type.name.CamelCase()}}:
m{{type.name.CamelCase()}}Allocator.Free(static_cast<{{type.name.CamelCase()}}*>(obj));
break;
{% endfor %}
}
}
~ClientBase() override = default;
private:
// Implementation of the ObjectIdProvider interface
@ -54,19 +34,15 @@ namespace dawn::wire::client {
if (object == nullptr) {
return WireResult::FatalError;
}
*out = reinterpret_cast<{{as_wireType(type)}}>(object)->id;
*out = reinterpret_cast<{{as_wireType(type)}}>(object)->GetWireId();
return WireResult::Success;
}
WireResult GetOptionalId({{as_cType(type.name)}} object, ObjectId* out) const final {
ASSERT(out != nullptr);
*out = (object == nullptr ? 0 : reinterpret_cast<{{as_wireType(type)}}>(object)->id);
*out = (object == nullptr ? 0 : reinterpret_cast<{{as_wireType(type)}}>(object)->GetWireId());
return WireResult::Success;
}
{% endfor %}
{% for type in by_category["object"] %}
ObjectAllocator<{{type.name.CamelCase()}}> m{{type.name.CamelCase()}}Allocator;
{% endfor %}
};
} // namespace dawn::wire::client

View File

@ -21,7 +21,7 @@ namespace dawn::wire::client {
{% for command in cmd_records["return command"] %}
bool Client::Handle{{command.name.CamelCase()}}(DeserializeBuffer* deserializeBuffer) {
Return{{command.name.CamelCase()}}Cmd cmd;
WireResult deserializeResult = cmd.Deserialize(deserializeBuffer, &mAllocator);
WireResult deserializeResult = cmd.Deserialize(deserializeBuffer, &mWireCommandAllocator);
if (deserializeResult == WireResult::FatalError) {
return false;
@ -32,9 +32,8 @@ namespace dawn::wire::client {
{% set name = as_varName(member.name) %}
{% if member.type.dict_name == "ObjectHandle" %}
{{Type}}* {{name}} = {{Type}}Allocator().GetObject(cmd.{{name}}.id);
uint32_t {{name}}Generation = {{Type}}Allocator().GetGeneration(cmd.{{name}}.id);
if ({{name}}Generation != cmd.{{name}}.generation) {
{{Type}}* {{name}} = Get<{{Type}}>(cmd.{{name}}.id);
if ({{name}} != nullptr && {{name}}->GetWireGeneration() != cmd.{{name}}.generation) {
{{name}} = nullptr;
}
{% endif %}
@ -85,7 +84,7 @@ namespace dawn::wire::client {
if (!success) {
return nullptr;
}
mAllocator.Reset();
mWireCommandAllocator.Reset();
}
if (deserializeBuffer.AvailableSize() != 0) {

View File

@ -27,7 +27,7 @@ namespace dawn::wire::server {
class ServerBase : public ChunkedCommandHandler, public ObjectIdResolver {
public:
ServerBase() = default;
virtual ~ServerBase() = default;
~ServerBase() override = default;
protected:
void DestroyAllObjects(const DawnProcTable& procs) {

View File

@ -77,11 +77,6 @@ namespace dawn::wire::server {
if (data == nullptr) {
return false;
}
if (data->deviceInfo != nullptr) {
if (!UntrackDeviceChild(data->deviceInfo, objectType, objectId)) {
return false;
}
}
if (data->state == AllocationState::Allocated) {
ASSERT(data->handle != nullptr);
{% if type.name.CamelCase() in server_reverse_lookup_objects %}
@ -89,17 +84,6 @@ namespace dawn::wire::server {
{% endif %}
{% if type.name.get() == "device" %}
//* TODO(crbug.com/dawn/384): This is a hack to make sure that all child objects
//* are destroyed before their device. We should have a solution in
//* Dawn native that makes all child objects internally null if their
//* Device is destroyed.
while (data->info->childObjectTypesAndIds.size() > 0) {
auto [childObjectType, childObjectId] = UnpackObjectTypeAndId(
*data->info->childObjectTypesAndIds.begin());
if (!DoDestroyObject(childObjectType, childObjectId)) {
return false;
}
}
if (data->handle != nullptr) {
//* Deregisters uncaptured error and device lost callbacks since
//* they should not be forwarded if the device no longer exists on the wire.

View File

@ -52,24 +52,6 @@ namespace dawn::wire::server {
return false;
}
{{name}}Data->generation = cmd.{{name}}.generation;
//* TODO(crbug.com/dawn/384): This is a hack to make sure that all child objects
//* are destroyed before their device. The dawn_native device needs to track all child objects so
//* it can destroy them if the device is destroyed first.
{% if command.derived_object %}
{% set type = command.derived_object %}
{% if type.name.get() == "device" %}
{{name}}Data->deviceInfo = DeviceObjects().Get(cmd.selfId)->info.get();
{% else %}
auto* selfData = {{type.name.CamelCase()}}Objects().Get(cmd.selfId);
{{name}}Data->deviceInfo = selfData->deviceInfo;
{% endif %}
if ({{name}}Data->deviceInfo != nullptr) {
if (!TrackDeviceChild({{name}}Data->deviceInfo, ObjectType::{{Type}}, cmd.{{name}}.id)) {
return false;
}
}
{% endif %}
{% endfor %}
//* Do command

View File

@ -67,18 +67,5 @@ config("public") {
include_dirs = [
"${target_gen_dir}/../../include",
"${dawn_root}/include",
"${dawn_root}/src/include", # TODO(crbug.com/dawn/1275) - remove
]
}
################################################################################
# Build target aliases
# TODO(crbug.com/dawn/1275) - remove these
################################################################################
group("dawncpp_headers") {
public_deps = [ ":cpp_headers" ]
}
group("dawn_headers") {
public_deps = [ ":headers" ]
}

View File

@ -31,6 +31,8 @@ struct ID3D12Resource;
namespace dawn::native::d3d12 {
class D3D11on12ResourceCache;
class Device;
class ExternalImageDXGIImpl;
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device);
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(WGPUDevice device,
@ -52,51 +54,67 @@ struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImag
ExternalImageDescriptorDXGISharedHandle();
// Note: SharedHandle must be a handle to a texture object.
HANDLE sharedHandle;
// TODO(dawn:576): Remove after changing Chromium code to set textureSharedHandle.
HANDLE sharedHandle = nullptr;
HANDLE textureSharedHandle = nullptr;
// Optional shared handle to a D3D11/12 fence which can be used to synchronize using wait/signal
// values specified in the access descriptor below. If null, the texture will be assumed to have
// an associated DXGI keyed mutex which will be used with a fixed key of 0 for synchronization.
HANDLE fenceSharedHandle = nullptr;
};
// Keyed mutex acquire/release uses a fixed key of 0 to match Chromium behavior.
constexpr UINT64 kDXGIKeyedMutexAcquireReleaseKey = 0;
struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptorDXGIKeyedMutex
struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptorDXGISharedHandle
: ExternalImageAccessDescriptor {
public:
// Value used for fence wait. A value of 0 is valid, but essentially a no-op since the fence
// lifetime starts with the 0 value signaled. A value of UINT64_MAX is ignored since it's also
// used by the D3D runtime to indicate that the device was removed.
uint64_t fenceWaitValue = 0;
// Value to signal the fence with after the texture is destroyed. A value of 0 means the fence
// will not be signaled.
uint64_t fenceSignalValue = 0;
// Whether the texture is for a WebGPU swap chain.
bool isSwapChainTexture = false;
};
// TODO(dawn:576): Remove after changing Chromium code to use the new struct name.
struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptorDXGIKeyedMutex
: ExternalImageAccessDescriptorDXGISharedHandle {
public:
// TODO(chromium:1241533): Remove deprecated keyed mutex params after removing associated
// code from Chromium - we use a fixed key of 0 for acquire and release everywhere now.
uint64_t acquireMutexKey;
uint64_t releaseMutexKey;
bool isSwapChainTexture = false;
};
class DAWN_NATIVE_EXPORT ExternalImageDXGI {
public:
~ExternalImageDXGI();
// Note: SharedHandle must be a handle to a texture object.
static std::unique_ptr<ExternalImageDXGI> Create(
WGPUDevice device,
const ExternalImageDescriptorDXGISharedHandle* descriptor);
// Returns true if the external image resources are still valid, otherwise ProduceTexture() is
// guaranteed to fail e.g. after device destruction.
bool IsValid() const;
// TODO(sunnyps): |device| is ignored - remove after Chromium migrates to single parameter call.
WGPUTexture ProduceTexture(WGPUDevice device,
const ExternalImageAccessDescriptorDXGIKeyedMutex* descriptor);
const ExternalImageAccessDescriptorDXGISharedHandle* descriptor);
WGPUTexture ProduceTexture(const ExternalImageAccessDescriptorDXGISharedHandle* descriptor);
private:
ExternalImageDXGI(Microsoft::WRL::ComPtr<ID3D12Resource> d3d12Resource,
const WGPUTextureDescriptor* descriptor);
explicit ExternalImageDXGI(std::unique_ptr<ExternalImageDXGIImpl> impl);
Microsoft::WRL::ComPtr<ID3D12Resource> mD3D12Resource;
// Contents of WGPUTextureDescriptor are stored individually since the descriptor
// could outlive this image.
WGPUTextureUsageFlags mUsage;
WGPUTextureUsageFlags mUsageInternal = WGPUTextureUsage_None;
WGPUTextureDimension mDimension;
WGPUExtent3D mSize;
WGPUTextureFormat mFormat;
uint32_t mMipLevelCount;
uint32_t mSampleCount;
std::unique_ptr<D3D11on12ResourceCache> mD3D11on12ResourceCache;
std::unique_ptr<ExternalImageDXGIImpl> mImpl;
};
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {

View File

@ -39,6 +39,9 @@ class AdapterBase;
// An optional parameter of Adapter::CreateDevice() to send additional information when creating
// a Device. For example, we can use it to enable a workaround, optimization or feature.
struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
DawnDeviceDescriptor();
~DawnDeviceDescriptor();
std::vector<const char*> requiredFeatures;
std::vector<const char*> forceEnabledToggles;
std::vector<const char*> forceDisabledToggles;
@ -83,7 +86,6 @@ class DAWN_NATIVE_EXPORT Adapter {
std::vector<const char*> GetSupportedExtensions() const;
std::vector<const char*> GetSupportedFeatures() const;
WGPUDeviceProperties GetAdapterProperties() const;
bool GetLimits(WGPUSupportedLimits* limits) const;
void SetUseTieredLimits(bool useTieredLimits);
@ -167,6 +169,8 @@ class DAWN_NATIVE_EXPORT Instance {
// TODO(dawn:1374) Deprecate this once it is passed via the descriptor.
void SetPlatform(dawn::platform::Platform* platform);
uint64_t GetDeviceCountForTesting() const;
// Returns the underlying WGPUInstance object.
WGPUInstance Get() const;
@ -186,6 +190,9 @@ DAWN_NATIVE_EXPORT size_t GetLazyClearCountForTesting(WGPUDevice device);
// Backdoor to get the number of deprecation warnings for testing
DAWN_NATIVE_EXPORT size_t GetDeprecationWarningCountForTesting(WGPUDevice device);
// Backdoor to get the number of adapters an instance knows about for testing
DAWN_NATIVE_EXPORT size_t GetAdapterCountForTesting(WGPUInstance instance);
// Query if texture has been initialized
DAWN_NATIVE_EXPORT bool IsTextureSubresourceInitialized(
WGPUTexture texture,
@ -232,13 +239,13 @@ struct DAWN_NATIVE_EXPORT ExternalImageDescriptor {
struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptor {
public:
bool isInitialized; // Whether the texture is initialized on import
WGPUTextureUsageFlags usage;
bool isInitialized = false; // Whether the texture is initialized on import
WGPUTextureUsageFlags usage = WGPUTextureUsage_None;
};
struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
public:
bool isInitialized; // Whether the texture is initialized after export
bool isInitialized = false; // Whether the texture is initialized after export
ExternalImageType GetType() const;
protected:
@ -248,6 +255,8 @@ struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
ExternalImageType mType;
};
DAWN_NATIVE_EXPORT bool CheckIsErrorForTesting(void* objectHandle);
DAWN_NATIVE_EXPORT const char* GetObjectLabelForTesting(void* objectHandle);
DAWN_NATIVE_EXPORT uint64_t GetAllocatedSizeForTesting(WGPUBuffer buffer);

View File

@ -60,14 +60,6 @@ DAWN_NATIVE_EXPORT void WaitForCommandsToBeScheduled(WGPUDevice device);
} // namespace dawn::native::metal
#ifdef __OBJC__
namespace dawn::native::metal {
DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(WGPUDevice device);
} // namespace dawn::native::metal
#endif // __OBJC__
#pragma clang diagnostic pop
#endif // INCLUDE_DAWN_NATIVE_METALBACKEND_H_

View File

@ -23,15 +23,14 @@ typedef void* EGLImage;
namespace dawn::native::opengl {
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public AdapterDiscoveryOptionsBase {
AdapterDiscoveryOptions();
explicit AdapterDiscoveryOptions(WGPUBackendType type);
void* (*getProc)(const char*);
};
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsES : public AdapterDiscoveryOptionsBase {
// TODO(crbug.com/dawn/810): This struct can be removed once Chrome is no longer using it.
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptionsES : public AdapterDiscoveryOptions {
AdapterDiscoveryOptionsES();
void* (*getProc)(const char*);
};
using PresentCallback = void (*)(void*);

View File

@ -17,6 +17,7 @@
#include <vulkan/vulkan.h>
#include <array>
#include <vector>
#include "dawn/dawn_wsi.h"
@ -68,7 +69,7 @@ struct ExternalImageExportInfoVk : ExternalImageExportInfo {
using ExternalImageExportInfo::ExternalImageExportInfo;
};
// Can't use DAWN_PLATFORM_LINUX since header included in both Dawn and Chrome
// Can't use DAWN_PLATFORM_IS(LINUX) since header included in both Dawn and Chrome
#ifdef __linux__
// Common properties of external images represented by FDs. On successful import the file
@ -92,11 +93,18 @@ struct DAWN_NATIVE_EXPORT ExternalImageDescriptorOpaqueFD : ExternalImageDescrip
uint32_t memoryTypeIndex; // Must match VkMemoryAllocateInfo from image creation
};
// The plane-wise offset and stride.
struct DAWN_NATIVE_EXPORT PlaneLayout {
uint64_t offset;
uint32_t stride;
};
// Descriptor for dma-buf file descriptor image import
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD {
ExternalImageDescriptorDmaBuf();
uint32_t stride; // Stride of the buffer in bytes
static constexpr uint32_t kMaxPlanes = 3;
std::array<PlaneLayout, kMaxPlanes> planeLayouts;
uint64_t drmModifier; // DRM modifier of the buffer
};

View File

@ -93,10 +93,10 @@ class DAWN_PLATFORM_EXPORT Platform {
const uint64_t* argValues,
unsigned char flags);
// The |fingerprint| is provided by Dawn to inform the client to discard the Dawn caches
// when the fingerprint changes. The returned CachingInterface is expected to outlive the
// device which uses it to persistently cache objects.
virtual CachingInterface* GetCachingInterface(const void* fingerprint, size_t fingerprintSize);
// The returned CachingInterface is expected to outlive the device which uses it to persistently
// cache objects.
virtual CachingInterface* GetCachingInterface();
virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
private:

View File

@ -50,26 +50,6 @@ class DAWN_WIRE_EXPORT CommandHandler {
virtual const volatile char* HandleCommands(const volatile char* commands, size_t size) = 0;
};
DAWN_WIRE_EXPORT size_t
SerializedWGPUDevicePropertiesSize(const WGPUDeviceProperties* deviceProperties);
DAWN_WIRE_EXPORT void SerializeWGPUDeviceProperties(const WGPUDeviceProperties* deviceProperties,
char* serializeBuffer);
DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(WGPUDeviceProperties* deviceProperties,
const volatile char* deserializeBuffer,
size_t deserializeBufferSize);
DAWN_WIRE_EXPORT size_t
SerializedWGPUSupportedLimitsSize(const WGPUSupportedLimits* supportedLimits);
DAWN_WIRE_EXPORT void SerializeWGPUSupportedLimits(const WGPUSupportedLimits* supportedLimits,
char* serializeBuffer);
DAWN_WIRE_EXPORT bool DeserializeWGPUSupportedLimits(WGPUSupportedLimits* supportedLimits,
const volatile char* deserializeBuffer,
size_t deserializeBufferSize);
} // namespace dawn::wire
// TODO(dawn:824): Remove once the deprecation period is passed.

View File

@ -68,9 +68,10 @@ class DAWN_WIRE_EXPORT WireClient : public CommandHandler {
explicit WireClient(const WireClientDescriptor& descriptor);
~WireClient() override;
const volatile char* HandleCommands(const volatile char* commands, size_t size) final;
const volatile char* HandleCommands(const volatile char* commands, size_t size) override;
ReservedTexture ReserveTexture(WGPUDevice device);
ReservedTexture ReserveTexture(WGPUDevice device,
const WGPUTextureDescriptor* descriptor);
ReservedSwapChain ReserveSwapChain(WGPUDevice device);
ReservedDevice ReserveDevice();
ReservedInstance ReserveInstance();

View File

@ -39,7 +39,7 @@ class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
explicit WireServer(const WireServerDescriptor& descriptor);
~WireServer() override;
const volatile char* HandleCommands(const volatile char* commands, size_t size) final;
const volatile char* HandleCommands(const volatile char* commands, size_t size) override;
bool InjectTexture(WGPUTexture texture,
uint32_t id,
@ -65,6 +65,11 @@ class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
// previously injected devices, and observing if GetDevice(id, generation) returns non-null.
WGPUDevice GetDevice(uint32_t id, uint32_t generation);
// Check if a device handle is known by the wire.
// In Chrome, we need to know the list of live devices so we can call device.Tick() on all of
// them periodically to ensure progress on asynchronous work is made.
bool IsDeviceKnown(WGPUDevice device) const;
private:
std::unique_ptr<server::Server> mImpl;
};

View File

@ -0,0 +1,60 @@
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_TINT_OVERRIDE_ID_H_
#define SRC_TINT_OVERRIDE_ID_H_
#include <stdint.h>
namespace tint {
/// OverrideId is a numerical identifier for an override variable, unique per program.
struct OverrideId {
uint16_t value = 0;
};
/// Equality operator for OverrideId
/// @param lhs the OverrideId on the left of the '=' operator
/// @param rhs the OverrideId on the right of the '=' operator
/// @returns true if `lhs` is equal to `rhs`
inline bool operator==(OverrideId lhs, OverrideId rhs) {
return lhs.value == rhs.value;
}
/// Less-than operator for OverrideId
/// @param lhs the OverrideId on the left of the '<' operator
/// @param rhs the OverrideId on the right of the '<' operator
/// @returns true if `lhs` comes before `rhs`
inline bool operator<(OverrideId lhs, OverrideId rhs) {
return lhs.value < rhs.value;
}
} // namespace tint
namespace std {
/// Custom std::hash specialization for tint::OverrideId.
template <>
class hash<tint::OverrideId> {
public:
/// @param id the override identifier
/// @return the hash of the override identifier
inline std::size_t operator()(tint::OverrideId id) const {
return std::hash<decltype(tint::OverrideId::value)>()(id.value);
}
};
} // namespace std
#endif // SRC_TINT_OVERRIDE_ID_H_

View File

@ -18,7 +18,6 @@
// TODO(tint:88): When implementing support for an install target, all of these
// headers will need to be moved to include/tint/.
#include "src/tint/ast/pipeline_stage.h"
#include "src/tint/demangler.h"
#include "src/tint/diagnostic/printer.h"
#include "src/tint/inspector/inspector.h"
@ -32,7 +31,9 @@
#include "src/tint/transform/renamer.h"
#include "src/tint/transform/robustness.h"
#include "src/tint/transform/single_entry_point.h"
#include "src/tint/transform/substitute_override.h"
#include "src/tint/transform/vertex_pulling.h"
#include "src/tint/writer/flatten_bindings.h"
#include "src/tint/writer/writer.h"
#if TINT_BUILD_SPV_READER

View File

@ -0,0 +1,58 @@
// Copyright 2022 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef INCLUDE_WEBGPU_WEBGPU_GLFW_H_
#define INCLUDE_WEBGPU_WEBGPU_GLFW_H_
#include <memory>
#include "webgpu/webgpu_cpp.h"
#if defined(WGPU_GLFW_SHARED_LIBRARY)
#if defined(_WIN32)
#if defined(WGPU_GLFW_IMPLEMENTATION)
#define WGPU_GLFW_EXPORT __declspec(dllexport)
#else
#define WGPU_GLFW_EXPORT __declspec(dllimport)
#endif
#else // defined(_WIN32)
#if defined(WGPU_GLFW_IMPLEMENTATION)
#define WGPU_GLFW_EXPORT __attribute__((visibility("default")))
#else
#define WGPU_GLFW_EXPORT
#endif
#endif // defined(_WIN32)
#else // defined(WGPU_GLFW_SHARED_LIBRARY)
#define WGPU_GLFW_EXPORT
#endif // defined(WGPU_GLFW_SHARED_LIBRARY)
struct GLFWwindow;
namespace wgpu::glfw {
// Does the necessary setup on the GLFWwindow to allow creating a wgpu::Surface with it and
// calls `instance.CreateSurface` with the correct descriptor for this window.
// Returns a null wgpu::Surface on failure.
WGPU_GLFW_EXPORT wgpu::Surface CreateSurfaceForWindow(const wgpu::Instance& instance,
GLFWwindow* window);
// Use for testing only. Does everything that CreateSurfaceForWindow does except the call to
// CreateSurface. Useful to be able to modify the descriptor for testing, or when trying to
// avoid using the global proc table.
WGPU_GLFW_EXPORT std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(
GLFWwindow* window);
} // namespace wgpu::glfw
#endif // INCLUDE_WEBGPU_WEBGPU_GLFW_H_

View File

@ -20,7 +20,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
properties_j: "gen_fuzz_corpus:true"
@ -42,7 +42,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
properties_j: "target_cpu:\"x64\""
@ -63,7 +63,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
properties_j: "target_cpu:\"x86\""
@ -84,7 +84,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
properties_j: "target_cpu:\"x64\""
@ -105,7 +105,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
properties_j: "target_cpu:\"x86\""
@ -126,7 +126,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
properties_j: "target_cpu:\"x64\""
@ -151,7 +151,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
properties_j: "target_cpu:\"x64\""
@ -176,7 +176,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
properties_j: "target_cpu:\"x64\""
@ -201,7 +201,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
properties_j: "target_cpu:\"x86\""
@ -226,7 +226,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
properties_j: "target_cpu:\"x64\""
@ -251,7 +251,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
properties_j: "target_cpu:\"x86\""
@ -332,7 +332,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
@ -354,7 +354,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
@ -376,7 +376,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
@ -398,7 +398,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
@ -420,7 +420,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
@ -446,7 +446,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
@ -492,7 +492,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
@ -518,7 +518,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:true"
@ -544,7 +544,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:false"
@ -570,7 +570,7 @@ buckets {
name: "dawn"
cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
cipd_version: "refs/heads/main"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}"
properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\",\"use_luci_auth\":true}"
properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
properties_j: "clang:true"
properties_j: "debug:false"

View File

@ -7,7 +7,7 @@
name: "dawn"
access: "group:all"
lucicfg {
version: "1.30.11"
version: "1.31.3"
package_dir: ".."
config_dir: "generated"
entry_point: "main.star"

View File

@ -226,6 +226,7 @@ def get_default_properties(os, clang, debug, cpu, fuzzer):
goma_props.update({
"server_host": "goma.chromium.org",
"rpc_extra_params": "?prod",
"use_luci_auth": True,
})
if os.category != os_category.MAC:
goma_props["enable_ats"] = True

View File

@ -30,6 +30,12 @@ else
TMP_DIR=/tmp
fi
echo "*****************************************************************"
echo "* build.sh"
echo "*"
echo "* df:"
df
echo "*****************************************************************"
# --privileged is required for some sanitizer builds, as they seem to require PTRACE privileges
docker run --rm -i \

View File

@ -50,6 +50,9 @@ function status {
echo ""
echo "*****************************************************************"
echo "* $@"
echo "*"
echo "* df:"
df
echo "*****************************************************************"
echo ""
task_begin $@
@ -119,6 +122,13 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then
COMMON_CMAKE_FLAGS+=" -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
COMMON_CMAKE_FLAGS+=" -DTINT_DOCS_WARN_AS_ERROR=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_BENCHMARKS=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_SPV_READER=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_WGSL_READER=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_GLSL_WRITER=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_HLSL_WRITER=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_MSL_WRITER=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_SPV_WRITER=1"
COMMON_CMAKE_FLAGS+=" -DTINT_BUILD_WGSL_WRITER=1"
if [ "$BUILD_TOOLCHAIN" == "clang" ]; then
using clang-10.0.0

View File

@ -62,18 +62,11 @@ mkdir %TEMP_DIR% || goto :error
call :status "Fetching and installing DXC"
@echo on
set DXC_RELEASE="https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.6.2112/dxc_2021_12_08.zip"
set DXC_RELEASE="https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.7.2207/dxc_2022_07_18.zip"
curl -k -L %DXC_RELEASE% --output "%TEMP_DIR%\dxc_release.zip" || goto :error
powershell.exe -Command "Expand-Archive -LiteralPath '%TEMP_DIR%\dxc_release.zip' -DestinationPath '%TEMP_DIR%\dxc'" || goto :error
set DXC_PATH=%TEMP_DIR%\dxc\bin\x64
rem Patch with artifact build that contains fixes not present in the release build
set DXC_ARTIFACT="https://ci.appveyor.com/api/projects/dnovillo/directxshadercompiler/artifacts/build%%2FRelease%%2Fdxc-artifacts.zip?branch=master&pr=false&job=image%%3A%%20Visual%%20Studio%%202019"
curl -k -L %DXC_ARTIFACT% --output "%TEMP_DIR%\dxc_artifact.zip" || goto :error
powershell.exe -Command "Expand-Archive -Force -LiteralPath '%TEMP_DIR%\dxc_artifact.zip' -DestinationPath '%TEMP_DIR%\dxc_artifact'" || goto :error
move /Y %TEMP_DIR%\dxc_artifact\bin\* %DXC_PATH%
@echo off
call :status "Fetching and installing Windows SDK for d3dcompiler DLL"
@echo on
set WINSDK_DLL_INSTALLER=https://go.microsoft.com/fwlink/?linkid=2164145
@ -116,7 +109,7 @@ call :status "Configuring build system"
@echo on
mkdir %BUILD_DIR%
cd /d %BUILD_DIR%
set COMMON_CMAKE_FLAGS=-DTINT_BUILD_DOCS=O -DTINT_BUILD_BENCHMARKS=1 -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
set COMMON_CMAKE_FLAGS=-DTINT_BUILD_DOCS=O -DTINT_BUILD_BENCHMARKS=1 -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DTINT_BUILD_BENCHMARKS=1 -DTINT_BUILD_SPV_READER=1 -DTINT_BUILD_WGSL_READER=1 -DTINT_BUILD_GLSL_WRITER=1 -DTINT_BUILD_HLSL_WRITER=1 -DTINT_BUILD_MSL_WRITER=1 -DTINT_BUILD_SPV_WRITER=1 -DTINT_BUILD_WGSL_WRITER=1
@echo off
call :status "Building dawn"
@ -142,20 +135,12 @@ tint_unittests.exe || goto :error
call :status "Testing test/tint/test-all.sh"
@echo on
cd /d %SRC_DIR% || goto :error
rem Run tests with DXC and Metal validation
rem Run tests with DXC, FXC and Metal validation
set OLD_PATH=%PATH%
set PATH=C:\Program Files\Metal Developer Tools\macos\bin;%PATH%
where metal.exe
set PATH=%DXC_PATH%;%OLD_PATH%
where dxc.exe dxil.dll
set PATH=%DXC_PATH%;%D3DCOMPILER_PATH%;%OLD_PATH%
call git bash -- ./test/tint/test-all.sh ../dawn-build/tint.exe --verbose || goto :error
@echo on
set PATH=%OLD_PATH%
rem Run again to test with FXC validation
set PATH=%D3DCOMPILER_PATH%;%OLD_PATH%
where d3dcompiler_47.dll
call git bash -- ./test/tint/test-all.sh ../dawn-build/tint.exe --verbose --format hlsl --fxc || goto :error
@echo on
set PATH=%OLD_PATH%
@echo off

View File

@ -19,10 +19,12 @@ if (build_with_chromium) {
import("//build/config/sanitizers/sanitizers.gni")
dawn_use_x11 = ozone_platform_x11
dawn_use_wayland = false
} else {
declare_args() {
# Whether Dawn should enable X11 support.
dawn_use_x11 = is_linux && !is_chromeos
dawn_use_wayland = false
}
}

View File

@ -85,3 +85,7 @@ if (!defined(dawn_vulkan_validation_layers_dir)) {
if (!defined(dawn_abseil_dir)) {
dawn_abseil_dir = "//third_party/abseil-cpp"
}
if (!defined(dawn_version_file)) {
dawn_version_file = ""
}

View File

@ -77,23 +77,3 @@ dawn_json_generator("emscripten_bits_gen") {
"emscripten-bits/library_webgpu_enum_tables.js",
]
}
################################################################################
# Build target aliases
# TODO(crbug.com/dawn/1275) - remove these
################################################################################
group("dawncpp") {
public_deps = [ ":cpp" ]
}
group("dawncpp_headers") {
public_deps = [ "${dawn_root}/include/dawn:cpp_headers" ]
}
group("dawn_proc") {
public_deps = [ ":proc" ]
}
group("dawn_headers") {
public_deps = [ "${dawn_root}/include/dawn:headers" ]
}
group("dawn_cpp") {
public_deps = [ ":cpp" ]
}

View File

@ -22,6 +22,7 @@ add_subdirectory(native)
add_subdirectory(wire)
# TODO(dawn:269): Remove once the implementation-based swapchains are removed.
add_subdirectory(utils)
add_subdirectory(glfw)
if (DAWN_BUILD_SAMPLES)
#TODO(dawn:269): Add this once implementation-based swapchains are removed.
@ -112,6 +113,8 @@ common_compile_options(dawncpp)
target_sources(dawncpp PRIVATE ${DAWNCPP_GEN_SOURCES})
target_link_libraries(dawncpp PUBLIC dawncpp_headers)
add_library(webgpu_cpp ALIAS dawncpp)
###############################################################################
# libdawn_proc
###############################################################################

View File

@ -3,4 +3,4 @@ cwallez@chromium.org
enga@chromium.org
kainino@chromium.org
jiawei.shao@intel.com
lokokun@google.com
lokokung@google.com

View File

@ -20,9 +20,9 @@
template <typename T>
T* AllocNoThrow(size_t count) {
#if defined(ADDRESS_SANITIZER)
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER)
if (count * sizeof(T) >= 0x70000000) {
// std::nothrow isn't implemented on ASAN and it has a 2GB allocation limit.
// std::nothrow isn't implemented in sanitizers and they often have a 2GB allocation limit.
// Catch large allocations and error out so fuzzers make progress.
return nullptr;
}

View File

@ -17,6 +17,38 @@
#include <cstdlib>
#include "dawn/common/Log.h"
#include "dawn/common/Platform.h"
#if DAWN_COMPILER_IS(CLANG) || DAWN_COMPILER_IS(GCC)
void BreakPoint() {
#if DAWN_PLATFORM_IS(X86)
__asm__ __volatile__("int $3\n\t");
#elif DAWN_PLATFORM_IS(ARM32)
__asm__ __volatile__("bkpt 0");
#elif DAWN_PLATFORM_IS(ARM64)
__asm__ __volatile__("brk 0");
#elif DAWN_PLATFORM_IS(RISCV)
__asm__ __volatile__("ebreak");
#elif DAWN_PLATFORM_IS(MIPS)
__asm__ __volatile__("break");
#elif DAWN_PLATFORM_IS(S390) || DAWN_PLATFORM_IS_(S390X)
__asm__ __volatile__(".word 0x0001");
#elif DAWN_PLATFORM_IS(PPC) || DAWN_PLATFORM_IS_(PPC64)
__asm__ __volatile__("twge 2,2");
#else
#error "Unsupported platform"
#endif
}
#elif DAWN_COMPILER_IS(MSVC)
extern void __cdecl __debugbreak(void);
void BreakPoint() {
__debugbreak();
}
#else
#error "Unsupported compiler"
#endif
void HandleAssertionFailure(const char* file,
const char* function,
@ -27,6 +59,6 @@ void HandleAssertionFailure(const char* file,
#if defined(DAWN_ABORT_ON_ASSERT)
abort();
#else
DAWN_BREAKPOINT();
BreakPoint();
#endif
}

View File

@ -31,7 +31,7 @@
// MSVC triggers a warning in /W4 for do {} while(0). SDL worked around this by using (0,0) and
// points out that it looks like an owl face.
#if defined(DAWN_COMPILER_MSVC)
#if DAWN_COMPILER_IS(MSVC)
#define DAWN_ASSERT_LOOP_CONDITION (0, 0)
#else
#define DAWN_ASSERT_LOOP_CONDITION (0)
@ -48,9 +48,9 @@
} \
} while (DAWN_ASSERT_LOOP_CONDITION)
#else
#if defined(DAWN_COMPILER_MSVC)
#if DAWN_COMPILER_IS(MSVC)
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition)
#elif defined(DAWN_COMPILER_CLANG) && defined(__builtin_assume)
#elif DAWN_COMPILER_IS(CLANG) && defined(__builtin_assume)
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __builtin_assume(condition)
#else
#define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \

View File

@ -49,8 +49,13 @@ config("internal_config") {
}
if (use_fuzzing_engine) {
# Does a hard abort when an assertion fails so that fuzzers catch and parse the failure.
defines += [ "DAWN_ABORT_ON_ASSERT" ]
defines += [
# Does a hard abort when an assertion fails so that fuzzers catch and parse the failure.
"DAWN_ABORT_ON_ASSERT",
# Disable logging to make fuzzing more efficient.
"DAWN_DISABLE_LOGGING",
]
}
if (dawn_enable_d3d12) {
@ -75,6 +80,9 @@ config("internal_config") {
defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ]
}
if (dawn_use_wayland) {
defines += [ "DAWN_USE_WAYLAND" ]
}
if (dawn_use_x11) {
defines += [ "DAWN_USE_X11" ]
}
@ -107,6 +115,7 @@ config("internal_config") {
"-Wdeprecated-copy",
"-Wdeprecated-copy-dtor",
"-Wduplicate-enum",
"-Wextra-semi",
"-Wextra-semi-stmt",
"-Wimplicit-fallthrough",
"-Winconsistent-missing-destructor-override",
@ -118,9 +127,12 @@ config("internal_config") {
"-Wredundant-move",
"-Wshadow-field",
"-Wstrict-prototypes",
"-Wsuggest-destructor-override",
"-Wsuggest-override",
"-Wtautological-unsigned-zero-compare",
"-Wunreachable-code-aggressive",
"-Wunused-but-set-variable",
"-Wunused-macros",
]
if (is_win) {
@ -174,9 +186,31 @@ dawn_generator("dawn_version_gen") {
"--dawn-dir",
rebase_path("${dawn_root}", root_build_dir),
]
# We can use the explicit version file if it is generated instead of relying
# on the existence of git.
if (dawn_version_file != "") {
args += [
"--version-file",
rebase_path(dawn_version_file, root_build_dir),
]
}
outputs = [ "src/dawn/common/Version_autogen.h" ]
}
dawn_generator("dawn_gpu_info_gen") {
script = "${dawn_root}/generator/dawn_gpu_info_generator.py"
args = [
"--gpu-info-json",
rebase_path("${dawn_root}/src/dawn/gpu_info.json", root_build_dir),
]
outputs = [
"src/dawn/common/GPUInfo_autogen.h",
"src/dawn/common/GPUInfo_autogen.cpp",
]
}
# This GN file is discovered by all Chromium builds, but common doesn't support
# all of Chromium's OSes so we explicitly make the target visible only on
# systems we know Dawn is able to compile on.
@ -233,13 +267,20 @@ if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android) {
"vulkan_platform.h",
"xlib_with_undefs.h",
]
sources += get_target_outputs(":dawn_gpu_info_gen")
public_deps = [ ":dawn_version_gen" ]
public_deps = [
":dawn_gpu_info_gen",
":dawn_version_gen",
]
if (is_mac) {
sources += [ "SystemUtils_mac.mm" ]
}
# Note that while this doesn't make `internal_config` a public config of
# Dawn libraries because `:common` is only used as a private deps of Dawn
# targets, so `internal_config` doesn't leak out of Dawn.
public_configs = [ ":internal_config" ]
deps = [
"${dawn_root}/include/dawn:cpp_headers",

View File

@ -20,10 +20,19 @@ DawnGenerator(
RESULT_VARIABLE "DAWN_VERSION_AUTOGEN_SOURCES"
)
DawnGenerator(
SCRIPT "${Dawn_SOURCE_DIR}/generator/dawn_gpu_info_generator.py"
PRINT_NAME "Dawn GPU info utilities"
ARGS "--gpu-info-json"
"${Dawn_SOURCE_DIR}/src/dawn/gpu_info.json"
RESULT_VARIABLE "DAWN_GPU_INFO_AUTOGEN_SOURCES"
)
add_library(dawn_common STATIC ${DAWN_PLACEHOLDER_FILE})
common_compile_options(dawn_common)
target_sources(dawn_common PRIVATE
${DAWN_VERSION_AUTOGEN_SOURCES}
${DAWN_GPU_INFO_AUTOGEN_SOURCES}
"Alloc.h"
"Assert.cpp"
"Assert.h"

View File

@ -16,8 +16,7 @@
#define SRC_DAWN_COMMON_COMPILER_H_
// Defines macros for compiler-specific functionality
// - DAWN_COMPILER_[CLANG|GCC|MSVC]: Compiler detection
// - DAWN_BREAKPOINT(): Raises an exception and breaks in the debugger
// - DAWN_COMPILER_IS(CLANG|GCC|MSVC): Compiler detection
// - DAWN_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable
// - DAWN_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
// (resp. false) to help it generate code that leads to better branch prediction.
@ -30,16 +29,9 @@
// Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
#if defined(__GNUC__) || defined(__clang__)
#if defined(__clang__)
#define DAWN_COMPILER_CLANG
#define DAWN_COMPILER_IS_CLANG 1
#else
#define DAWN_COMPILER_GCC
#endif
#if defined(__i386__) || defined(__x86_64__)
#define DAWN_BREAKPOINT() __asm__ __volatile__("int $3\n\t")
#else
// TODO(cwallez@chromium.org): Implement breakpoint on all supported architectures
#define DAWN_BREAKPOINT()
#define DAWN_COMPILER_IS_GCC 1
#endif
#define DAWN_BUILTIN_UNREACHABLE() __builtin_unreachable()
@ -58,10 +50,7 @@
// MSVC
#elif defined(_MSC_VER)
#define DAWN_COMPILER_MSVC
extern void __cdecl __debugbreak(void);
#define DAWN_BREAKPOINT() __debugbreak()
#define DAWN_COMPILER_IS_MSVC 1
#define DAWN_BUILTIN_UNREACHABLE() __assume(false)
@ -75,6 +64,23 @@ extern void __cdecl __debugbreak(void);
#error "Unsupported compiler"
#endif
// This section defines other compiler macros to 0 to avoid undefined macro usage error.
#if !defined(DAWN_COMPILER_IS_CLANG)
#define DAWN_COMPILER_IS_CLANG 0
#endif
#if !defined(DAWN_COMPILER_IS_GCC)
#define DAWN_COMPILER_IS_GCC 0
#endif
#if !defined(DAWN_COMPILER_IS_MSVC)
#define DAWN_COMPILER_IS_MSVC 0
#endif
// Use #if DAWN_COMPILER_IS(XXX) for compiler specific code.
// Do not use #ifdef or the naked macro DAWN_COMPILER_IS_XXX.
// This can help avoid common mistakes like not including "Compiler.h" and falling into unwanted
// code block as usage of undefined macro "function" will be blocked by the compiler.
#define DAWN_COMPILER_IS(X) (1 == DAWN_COMPILER_IS_##X)
// It seems that (void) EXPR works on all compilers to silence the unused variable warning.
#define DAWN_UNUSED(EXPR) (void)EXPR
// Likewise using static asserting on sizeof(&FUNC) seems to make it tagged as used

View File

@ -18,12 +18,12 @@
#include "dawn/common/Platform.h"
#if DAWN_PLATFORM_WINDOWS
#if DAWN_PLATFORM_IS(WINDOWS)
#include "dawn/common/windows_with_undefs.h"
#if DAWN_PLATFORM_WINUWP
#if DAWN_PLATFORM_IS(WINUWP)
#include "dawn/common/WindowsUtils.h"
#endif
#elif DAWN_PLATFORM_POSIX
#elif DAWN_PLATFORM_IS(POSIX)
#include <dlfcn.h>
#else
#error "Unsupported platform for DynamicLib"
@ -47,8 +47,8 @@ bool DynamicLib::Valid() const {
}
bool DynamicLib::Open(const std::string& filename, std::string* error) {
#if DAWN_PLATFORM_WINDOWS
#if DAWN_PLATFORM_WINUWP
#if DAWN_PLATFORM_IS(WINDOWS)
#if DAWN_PLATFORM_IS(WINUWP)
mHandle = LoadPackagedLibrary(UTF8ToWStr(filename.c_str()).c_str(), 0);
#else
mHandle = LoadLibraryA(filename.c_str());
@ -56,7 +56,7 @@ bool DynamicLib::Open(const std::string& filename, std::string* error) {
if (mHandle == nullptr && error != nullptr) {
*error = "Windows Error: " + std::to_string(GetLastError());
}
#elif DAWN_PLATFORM_POSIX
#elif DAWN_PLATFORM_IS(POSIX)
mHandle = dlopen(filename.c_str(), RTLD_NOW);
if (mHandle == nullptr && error != nullptr) {
@ -74,9 +74,9 @@ void DynamicLib::Close() {
return;
}
#if DAWN_PLATFORM_WINDOWS
#if DAWN_PLATFORM_IS(WINDOWS)
FreeLibrary(static_cast<HMODULE>(mHandle));
#elif DAWN_PLATFORM_POSIX
#elif DAWN_PLATFORM_IS(POSIX)
dlclose(mHandle);
#else
#error "Unsupported platform for DynamicLib"
@ -88,13 +88,13 @@ void DynamicLib::Close() {
void* DynamicLib::GetProc(const std::string& procName, std::string* error) const {
void* proc = nullptr;
#if DAWN_PLATFORM_WINDOWS
#if DAWN_PLATFORM_IS(WINDOWS)
proc = reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(mHandle), procName.c_str()));
if (proc == nullptr && error != nullptr) {
*error = "Windows Error: " + std::to_string(GetLastError());
}
#elif DAWN_PLATFORM_POSIX
#elif DAWN_PLATFORM_IS(POSIX)
proc = reinterpret_cast<void*>(dlsym(mHandle, procName.c_str()));
if (proc == nullptr && error != nullptr) {

View File

@ -12,34 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <algorithm>
#include <array>
#include "dawn/common/GPUInfo.h"
#include <algorithm>
#include "dawn/common/Assert.h"
namespace gpu_info {
namespace {
// Intel
// Referenced from the following Mesa source code:
// https://github.com/mesa3d/mesa/blob/master/include/pci_ids/i965_pci_ids.h
// https://github.com/mesa3d/mesa/blob/main/include/pci_ids/iris_pci_ids.h
// gen9
const std::array<uint32_t, 25> Skylake = {{0x1902, 0x1906, 0x190A, 0x190B, 0x190E, 0x1912, 0x1913,
0x1915, 0x1916, 0x1917, 0x191A, 0x191B, 0x191D, 0x191E,
0x1921, 0x1923, 0x1926, 0x1927, 0x192A, 0x192B, 0x192D,
0x1932, 0x193A, 0x193B, 0x193D}};
// gen9p5
const std::array<uint32_t, 20> Kabylake = {{0x5916, 0x5913, 0x5906, 0x5926, 0x5921, 0x5915, 0x590E,
0x591E, 0x5912, 0x5917, 0x5902, 0x591B, 0x593B, 0x590B,
0x591A, 0x590A, 0x591D, 0x5908, 0x5923, 0x5927}};
const std::array<uint32_t, 17> Coffeelake = {{0x87CA, 0x3E90, 0x3E93, 0x3E99, 0x3E9C, 0x3E91,
0x3E92, 0x3E96, 0x3E98, 0x3E9A, 0x3E9B, 0x3E94,
0x3EA9, 0x3EA5, 0x3EA6, 0x3EA7, 0x3EA8}};
const std::array<uint32_t, 5> Whiskylake = {{0x3EA1, 0x3EA4, 0x3EA0, 0x3EA3, 0x3EA2}};
const std::array<uint32_t, 21> Cometlake = {
{0x9B21, 0x9BA0, 0x9BA2, 0x9BA4, 0x9BA5, 0x9BA8, 0x9BAA, 0x9BAB, 0x9BAC, 0x9B41, 0x9BC0,
0x9BC2, 0x9BC4, 0x9BC5, 0x9BC6, 0x9BC8, 0x9BCA, 0x9BCB, 0x9BCC, 0x9BE6, 0x9BF6}};
// According to Intel graphics driver version schema, build number is generated from the
// last two fields.
@ -51,34 +39,6 @@ uint32_t GetIntelD3DDriverBuildNumber(const D3DDriverVersion& driverVersion) {
} // anonymous namespace
bool IsAMD(PCIVendorID vendorId) {
return vendorId == kVendorID_AMD;
}
bool IsARM(PCIVendorID vendorId) {
return vendorId == kVendorID_ARM;
}
bool IsImgTec(PCIVendorID vendorId) {
return vendorId == kVendorID_ImgTec;
}
bool IsIntel(PCIVendorID vendorId) {
return vendorId == kVendorID_Intel;
}
bool IsMesa(PCIVendorID vendorId) {
return vendorId == kVendorID_Mesa;
}
bool IsNvidia(PCIVendorID vendorId) {
return vendorId == kVendorID_Nvidia;
}
bool IsQualcomm(PCIVendorID vendorId) {
return vendorId == kVendorID_Qualcomm;
}
bool IsSwiftshader(PCIVendorID vendorId, PCIDeviceID deviceId) {
return vendorId == kVendorID_Google && deviceId == kDeviceID_Swiftshader;
}
bool IsWARP(PCIVendorID vendorId, PCIDeviceID deviceId) {
return vendorId == kVendorID_Microsoft && deviceId == kDeviceID_WARP;
}
int CompareD3DDriverVersion(PCIVendorID vendorId,
const D3DDriverVersion& version1,
const D3DDriverVersion& version2) {
@ -97,12 +57,5 @@ int CompareD3DDriverVersion(PCIVendorID vendorId,
bool IsSkylake(PCIDeviceID deviceId) {
return std::find(Skylake.cbegin(), Skylake.cend(), deviceId) != Skylake.cend();
}
bool IsKabylake(PCIDeviceID deviceId) {
return std::find(Kabylake.cbegin(), Kabylake.cend(), deviceId) != Kabylake.cend();
}
bool IsCoffeelake(PCIDeviceID deviceId) {
return (std::find(Coffeelake.cbegin(), Coffeelake.cend(), deviceId) != Coffeelake.cend()) ||
(std::find(Whiskylake.cbegin(), Whiskylake.cend(), deviceId) != Whiskylake.cend()) ||
(std::find(Cometlake.cbegin(), Cometlake.cend(), deviceId) != Cometlake.cend());
}
} // namespace gpu_info

View File

@ -15,37 +15,12 @@
#ifndef SRC_DAWN_COMMON_GPUINFO_H_
#define SRC_DAWN_COMMON_GPUINFO_H_
#include <array>
#include <cstdint>
#include "dawn/common/GPUInfo_autogen.h"
using PCIVendorID = uint32_t;
using PCIDeviceID = uint32_t;
#include <array>
namespace gpu_info {
static constexpr PCIVendorID kVendorID_AMD = 0x1002;
static constexpr PCIVendorID kVendorID_ARM = 0x13B5;
static constexpr PCIVendorID kVendorID_ImgTec = 0x1010;
static constexpr PCIVendorID kVendorID_Intel = 0x8086;
static constexpr PCIVendorID kVendorID_Mesa = 0x10005;
static constexpr PCIVendorID kVendorID_Nvidia = 0x10DE;
static constexpr PCIVendorID kVendorID_Qualcomm = 0x5143;
static constexpr PCIVendorID kVendorID_Google = 0x1AE0;
static constexpr PCIVendorID kVendorID_Microsoft = 0x1414;
static constexpr PCIDeviceID kDeviceID_Swiftshader = 0xC0DE;
static constexpr PCIDeviceID kDeviceID_WARP = 0x8c;
bool IsAMD(PCIVendorID vendorId);
bool IsARM(PCIVendorID vendorId);
bool IsImgTec(PCIVendorID vendorId);
bool IsIntel(PCIVendorID vendorId);
bool IsMesa(PCIVendorID vendorId);
bool IsNvidia(PCIVendorID vendorId);
bool IsQualcomm(PCIVendorID vendorId);
bool IsSwiftshader(PCIVendorID vendorId, PCIDeviceID deviceId);
bool IsWARP(PCIVendorID vendorId, PCIDeviceID deviceId);
using D3DDriverVersion = std::array<uint16_t, 4>;
// Do comparison between two driver versions. Currently we only support the comparison between
@ -59,8 +34,6 @@ int CompareD3DDriverVersion(PCIVendorID vendorId,
// Intel architectures
bool IsSkylake(PCIDeviceID deviceId);
bool IsKabylake(PCIDeviceID deviceId);
bool IsCoffeelake(PCIDeviceID deviceId);
} // namespace gpu_info
#endif // SRC_DAWN_COMMON_GPUINFO_H_

View File

@ -45,9 +45,9 @@ size_t Hash(const TypedInteger<Tag, T>& value) {
// return hash;
template <typename T>
void HashCombine(size_t* hash, const T& value) {
#if defined(DAWN_PLATFORM_64_BIT)
#if DAWN_PLATFORM_IS(64_BIT)
const size_t offset = 0x9e3779b97f4a7c16;
#elif defined(DAWN_PLATFORM_32_BIT)
#elif DAWN_PLATFORM_IS(32_BIT)
const size_t offset = 0x9e3779b9;
#else
#error "Unsupported platform"

View File

@ -20,7 +20,7 @@
#include "dawn/common/Assert.h"
#include "dawn/common/Platform.h"
#if defined(DAWN_PLATFORM_ANDROID)
#if DAWN_PLATFORM_IS(ANDROID)
#include <android/log.h>
#endif
@ -28,6 +28,7 @@ namespace dawn {
namespace {
#if !defined(DAWN_DISABLE_LOGGING)
const char* SeverityName(LogSeverity severity) {
switch (severity) {
case LogSeverity::Debug:
@ -43,8 +44,9 @@ const char* SeverityName(LogSeverity severity) {
return "";
}
}
#endif
#if defined(DAWN_PLATFORM_ANDROID)
#if DAWN_PLATFORM_IS(ANDROID)
android_LogPriority AndroidLogPriority(LogSeverity severity) {
switch (severity) {
case LogSeverity::Debug:
@ -60,12 +62,24 @@ android_LogPriority AndroidLogPriority(LogSeverity severity) {
return ANDROID_LOG_ERROR;
}
}
#endif // defined(DAWN_PLATFORM_ANDROID)
#endif // DAWN_PLATFORM_IS(ANDROID)
} // anonymous namespace
LogMessage::LogMessage(LogSeverity severity) : mSeverity(severity) {}
LogMessage::LogMessage(LogMessage&& other) = default;
LogMessage& LogMessage::operator=(LogMessage&& other) = default;
#if defined(DAWN_DISABLE_LOGGING)
LogMessage::~LogMessage() {
(void)mSeverity;
// Don't print logs to make fuzzing more efficient. Implemented as
// an early return to avoid warnings about unused member variables.
return;
}
#else // defined(DAWN_DISABLE_LOGGING)
LogMessage::~LogMessage() {
std::string fullMessage = mStream.str();
@ -76,10 +90,10 @@ LogMessage::~LogMessage() {
const char* severityName = SeverityName(mSeverity);
#if defined(DAWN_PLATFORM_ANDROID)
#if DAWN_PLATFORM_IS(ANDROID)
android_LogPriority androidPriority = AndroidLogPriority(mSeverity);
__android_log_print(androidPriority, "Dawn", "%s: %s\n", severityName, fullMessage.c_str());
#else // defined(DAWN_PLATFORM_ANDROID)
#else // DAWN_PLATFORM_IS(ANDROID)
FILE* outputStream = stdout;
if (mSeverity == LogSeverity::Warning || mSeverity == LogSeverity::Error) {
outputStream = stderr;
@ -88,8 +102,9 @@ LogMessage::~LogMessage() {
// Note: we use fprintf because <iostream> includes static initializers.
fprintf(outputStream, "%s: %s\n", severityName, fullMessage.c_str());
fflush(outputStream);
#endif // defined(DAWN_PLATFORM_ANDROID)
#endif // DAWN_PLATFORM_IS(ANDROID)
}
#endif // defined(DAWN_DISABLE_LOGGING)
LogMessage DebugLog() {
return LogMessage(LogSeverity::Debug);

View File

@ -62,8 +62,8 @@ class LogMessage {
explicit LogMessage(LogSeverity severity);
~LogMessage();
LogMessage(LogMessage&& other) = default;
LogMessage& operator=(LogMessage&& other) = default;
LogMessage(LogMessage&& other);
LogMessage& operator=(LogMessage&& other);
template <typename T>
LogMessage& operator<<(T&& value) {

View File

@ -21,13 +21,13 @@
#include "dawn/common/Assert.h"
#include "dawn/common/Platform.h"
#if defined(DAWN_COMPILER_MSVC)
#if DAWN_COMPILER_IS(MSVC)
#include <intrin.h>
#endif
uint32_t ScanForward(uint32_t bits) {
ASSERT(bits != 0);
#if defined(DAWN_COMPILER_MSVC)
#if DAWN_COMPILER_IS(MSVC)
// NOLINTNEXTLINE(runtime/int)
unsigned long firstBitIndex = 0ul;
unsigned char ret = _BitScanForward(&firstBitIndex, bits);
@ -40,7 +40,7 @@ uint32_t ScanForward(uint32_t bits) {
uint32_t Log2(uint32_t value) {
ASSERT(value != 0);
#if defined(DAWN_COMPILER_MSVC)
#if DAWN_COMPILER_IS(MSVC)
// NOLINTNEXTLINE(runtime/int)
unsigned long firstBitIndex = 0ul;
unsigned char ret = _BitScanReverse(&firstBitIndex, value);
@ -53,14 +53,14 @@ uint32_t Log2(uint32_t value) {
uint32_t Log2(uint64_t value) {
ASSERT(value != 0);
#if defined(DAWN_COMPILER_MSVC)
#if defined(DAWN_PLATFORM_64_BIT)
#if DAWN_COMPILER_IS(MSVC)
#if DAWN_PLATFORM_IS(64_BIT)
// NOLINTNEXTLINE(runtime/int)
unsigned long firstBitIndex = 0ul;
unsigned char ret = _BitScanReverse64(&firstBitIndex, value);
ASSERT(ret != 0);
return firstBitIndex;
#else // defined(DAWN_PLATFORM_64_BIT)
#else // DAWN_PLATFORM_IS(64_BIT)
// NOLINTNEXTLINE(runtime/int)
unsigned long firstBitIndex = 0ul;
if (_BitScanReverse(&firstBitIndex, value >> 32)) {
@ -69,10 +69,10 @@ uint32_t Log2(uint64_t value) {
unsigned char ret = _BitScanReverse(&firstBitIndex, value & 0xFFFFFFFF);
ASSERT(ret != 0);
return firstBitIndex;
#endif // defined(DAWN_PLATFORM_64_BIT)
#else // defined(DAWN_COMPILER_MSVC)
#endif // DAWN_PLATFORM_IS(64_BIT)
#else // DAWN_COMPILER_IS(MSVC)
return 63 - static_cast<uint32_t>(__builtin_clzll(value));
#endif // defined(DAWN_COMPILER_MSVC)
#endif // DAWN_COMPILER_IS(MSVC)
}
uint64_t NextPowerOfTwo(uint64_t n) {

View File

@ -15,6 +15,7 @@
#ifndef SRC_DAWN_COMMON_NUMERIC_H_
#define SRC_DAWN_COMMON_NUMERIC_H_
#include <cstdint>
#include <limits>
#include <type_traits>

View File

@ -15,71 +15,250 @@
#ifndef SRC_DAWN_COMMON_PLATFORM_H_
#define SRC_DAWN_COMMON_PLATFORM_H_
// Use #if DAWN_PLATFORM_IS(X) for platform specific code.
// Do not use #ifdef or the naked macro DAWN_PLATFORM_IS_X.
// This can help avoid common mistakes like not including "Platform.h" and falling into unwanted
// code block as usage of undefined macro "function" will be blocked by the compiler.
#define DAWN_PLATFORM_IS(X) (1 == DAWN_PLATFORM_IS_##X)
// Define platform macros for OSes:
//
// - WINDOWS
// - WIN32
// - WINUWP
// - POSIX
// - LINUX
// - ANDROID
// - APPLE
// - IOS
// - MACOS
// - TVOS
// - FUCHSIA
// - EMSCRIPTEN
#if defined(_WIN32) || defined(_WIN64)
#include <winapifamily.h>
#define DAWN_PLATFORM_WINDOWS 1
#define DAWN_PLATFORM_IS_WINDOWS 1
#if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
#define DAWN_PLATFORM_WIN32 1
#define DAWN_PLATFORM_IS_WIN32 1
#elif WINAPI_FAMILY == WINAPI_FAMILY_PC_APP
#define DAWN_PLATFORM_WINUWP 1
#define DAWN_PLATFORM_IS_WINUWP 1
#else
#error "Unsupported Windows platform."
#endif
#elif defined(__linux__)
#define DAWN_PLATFORM_LINUX 1
#define DAWN_PLATFORM_POSIX 1
#define DAWN_PLATFORM_IS_LINUX 1
#define DAWN_PLATFORM_IS_POSIX 1
#if defined(__ANDROID__)
#define DAWN_PLATFORM_ANDROID 1
#define DAWN_PLATFORM_IS_ANDROID 1
#endif
#elif defined(__APPLE__)
#define DAWN_PLATFORM_APPLE 1
#define DAWN_PLATFORM_POSIX 1
#define DAWN_PLATFORM_IS_APPLE 1
#define DAWN_PLATFORM_IS_POSIX 1
#include <TargetConditionals.h>
#if TARGET_OS_TV
#define DAWN_PLATFORM_TVOS
#define DAWN_PLATFORM_IOS
#define DAWN_PLATFORM_IS_TVOS 1
#define DAWN_PLATFORM_IS_IOS 1
#elif TARGET_OS_IPHONE
#define DAWN_PLATFORM_IOS
#define DAWN_PLATFORM_IS_IOS 1
#elif TARGET_OS_MAC
#define DAWN_PLATFORM_MACOS
#define DAWN_PLATFORM_IS_MACOS 1
#else
#error "Unsupported Apple platform."
#endif
#elif defined(__Fuchsia__)
#define DAWN_PLATFORM_FUCHSIA 1
#define DAWN_PLATFORM_POSIX 1
#define DAWN_PLATFORM_IS_FUCHSIA 1
#define DAWN_PLATFORM_IS_POSIX 1
#elif defined(__EMSCRIPTEN__)
#define DAWN_PLATFORM_EMSCRIPTEN 1
#define DAWN_PLATFORM_POSIX 1
#define DAWN_PLATFORM_IS_EMSCRIPTEN 1
#define DAWN_PLATFORM_IS_POSIX 1
#else
#error "Unsupported platform."
#endif
// Distinguish mips32.
#if defined(__mips__) && (_MIPS_SIM == _ABIO32) && !defined(__mips32__)
#define __mips32__
// Define platform macros for CPU architectures:
//
// - X86
// - I386
// - X86_64
// - ARM
// - ARM32
// - ARM64
// - RISCV
// - RISCV32
// - RISCV64
// - MIPS
// - MIPS32
// - MIPS64
// - S390
// - S390X
// - PPC
// - PPC64
#if defined(__i386__) || defined(_M_IX86)
#define DAWN_PLATFORM_IS_X86 1
#define DAWN_PLATFORM_IS_I386 1
#elif defined(__x86_64__) || defined(_M_X64)
#define DAWN_PLATFORM_IS_X86 1
#define DAWN_PLATFORM_IS_X86_64 1
#elif defined(__arm__) || defined(_M_ARM)
#define DAWN_PLATFORM_IS_ARM 1
#define DAWN_PLATFORM_IS_ARM32 1
#elif defined(__aarch64__) || defined(_M_ARM64)
#define DAWN_PLATFORM_IS_ARM 1
#define DAWN_PLATFORM_IS_ARM64 1
#elif defined(__riscv)
#define DAWN_PLATFORM_IS_RISCV 1
#if __riscv_xlen == 32
#define DAWN_PLATFORM_IS_RISCV32 1
#else
#define DAWN_PLATFORM_IS_RISCV64 1
#endif
// Distinguish mips64.
#if defined(__mips__) && (_MIPS_SIM == _ABI64) && !defined(__mips64__)
#define __mips64__
#elif defined(__mips__)
#define DAWN_PLATFORM_IS_MIPS 1
#if _MIPS_SIM == _ABIO32
#define DAWN_PLATFORM_IS_MIPS32 1
#else
#define DAWN_PLATFORM_IS_MIPS64 1
#endif
#if defined(_WIN64) || defined(__aarch64__) || defined(__x86_64__) || defined(__mips64__) || \
defined(__s390x__) || defined(__PPC64__)
#define DAWN_PLATFORM_64_BIT 1
#elif defiend(__s390__)
#define DAWN_PLATFORM_IS_S390 1
#elif defiend(__s390x__)
#define DAWN_PLATFORM_IS_S390X 1
#elif defined(__PPC__)
#define DAWN_PLATFORM_IS_PPC 1
#elif defined(__PPC64__)
#define DAWN_PLATFORM_IS_PPC64 1
#else
#error "Unsupported platform."
#endif
// Define platform macros for pointer width:
//
// - 64_BIT
// - 32_BIT
#if defined(DAWN_PLATFORM_IS_X86_64) || defined(DAWN_PLATFORM_IS_ARM64) || \
defined(DAWN_PLATFORM_IS_RISCV64) || defined(DAWN_PLATFORM_IS_MIPS64) || \
defined(DAWN_PLATFORM_IS_S390X) || defined(DAWN_PLATFORM_IS_PPC64)
#define DAWN_PLATFORM_IS_64_BIT 1
static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8");
#elif defined(_WIN32) || defined(__arm__) || defined(__i386__) || defined(__mips32__) || \
defined(__s390__) || defined(__EMSCRIPTEN__)
#define DAWN_PLATFORM_32_BIT 1
#elif defined(DAWN_PLATFORM_IS_I386) || defined(DAWN_PLATFORM_IS_ARM32) || \
defined(DAWN_PLATFORM_IS_RISCV32) || defined(DAWN_PLATFORM_IS_MIPS32) || \
defined(DAWN_PLATFORM_IS_S390) || defined(DAWN_PLATFORM_IS_PPC32) || \
defined(DAWN_PLATFORM_IS_EMSCRIPTEN)
#define DAWN_PLATFORM_IS_32_BIT 1
static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
#else
#error "Unsupported platform"
#endif
// This section define other platform macros to 0 to avoid undefined macro usage error.
#if !defined(DAWN_PLATFORM_IS_WINDOWS)
#define DAWN_PLATFORM_IS_WINDOWS 0
#endif
#if !defined(DAWN_PLATFORM_IS_WIN32)
#define DAWN_PLATFORM_IS_WIN32 0
#endif
#if !defined(DAWN_PLATFORM_IS_WINUWP)
#define DAWN_PLATFORM_IS_WINUWP 0
#endif
#if !defined(DAWN_PLATFORM_IS_POSIX)
#define DAWN_PLATFORM_IS_POSIX 0
#endif
#if !defined(DAWN_PLATFORM_IS_LINUX)
#define DAWN_PLATFORM_IS_LINUX 0
#endif
#if !defined(DAWN_PLATFORM_IS_ANDROID)
#define DAWN_PLATFORM_IS_ANDROID 0
#endif
#if !defined(DAWN_PLATFORM_IS_APPLE)
#define DAWN_PLATFORM_IS_APPLE 0
#endif
#if !defined(DAWN_PLATFORM_IS_IOS)
#define DAWN_PLATFORM_IS_IOS 0
#endif
#if !defined(DAWN_PLATFORM_IS_MACOS)
#define DAWN_PLATFORM_IS_MACOS 0
#endif
#if !defined(DAWN_PLATFORM_IS_FUCHSIA)
#define DAWN_PLATFORM_IS_FUCHSIA 0
#endif
#if !defined(DAWN_PLATFORM_IS_EMSCRIPTEN)
#define DAWN_PLATFORM_IS_EMSCRIPTEN 0
#endif
#if !defined(DAWN_PLATFORM_IS_X86)
#define DAWN_PLATFORM_IS_X86 0
#endif
#if !defined(DAWN_PLATFORM_IS_I386)
#define DAWN_PLATFORM_IS_I386 0
#endif
#if !defined(DAWN_PLATFORM_IS_X86_64)
#define DAWN_PLATFORM_IS_X86_64 0
#endif
#if !defined(DAWN_PLATFORM_IS_ARM)
#define DAWN_PLATFORM_IS_ARM 0
#endif
#if !defined(DAWN_PLATFORM_IS_ARM32)
#define DAWN_PLATFORM_IS_ARM32 0
#endif
#if !defined(DAWN_PLATFORM_IS_ARM64)
#define DAWN_PLATFORM_IS_ARM64 0
#endif
#if !defined(DAWN_PLATFORM_IS_RISCV)
#define DAWN_PLATFORM_IS_RISCV 0
#endif
#if !defined(DAWN_PLATFORM_IS_RISCV32)
#define DAWN_PLATFORM_IS_RISCV32 0
#endif
#if !defined(DAWN_PLATFORM_IS_RISCV64)
#define DAWN_PLATFORM_IS_RISCV64 0
#endif
#if !defined(DAWN_PLATFORM_IS_MIPS)
#define DAWN_PLATFORM_IS_MIPS 0
#endif
#if !defined(DAWN_PLATFORM_IS_MIPS32)
#define DAWN_PLATFORM_IS_MIPS32 0
#endif
#if !defined(DAWN_PLATFORM_IS_MIPS64)
#define DAWN_PLATFORM_IS_MIPS64 0
#endif
#if !defined(DAWN_PLATFORM_IS_S390)
#define DAWN_PLATFORM_IS_S390 0
#endif
#if !defined(DAWN_PLATFORM_IS_S390X)
#define DAWN_PLATFORM_IS_S390X 0
#endif
#if !defined(DAWN_PLATFORM_IS_PPC)
#define DAWN_PLATFORM_IS_PPC 0
#endif
#if !defined(DAWN_PLATFORM_IS_PPC64)
#define DAWN_PLATFORM_IS_PPC64 0
#endif
#if !defined(DAWN_PLATFORM_IS_64_BIT)
#define DAWN_PLATFORM_IS_64_BIT 0
#endif
#if !defined(DAWN_PLATFORM_IS_32_BIT)
#define DAWN_PLATFORM_IS_32_BIT 0
#endif
#endif // SRC_DAWN_COMMON_PLATFORM_H_

View File

@ -22,15 +22,15 @@ static constexpr size_t kPayloadBits = 1;
static constexpr uint64_t kPayloadMask = (uint64_t(1) << kPayloadBits) - 1;
static constexpr uint64_t kRefCountIncrement = (uint64_t(1) << kPayloadBits);
RefCounted::RefCounted(uint64_t payload) : mRefCount(kRefCountIncrement + payload) {
RefCount::RefCount(uint64_t payload) : mRefCount(kRefCountIncrement + payload) {
ASSERT((payload & kPayloadMask) == payload);
}
uint64_t RefCounted::GetRefCountForTesting() const {
uint64_t RefCount::GetValueForTesting() const {
return mRefCount >> kPayloadBits;
}
uint64_t RefCounted::GetRefCountPayload() const {
uint64_t RefCount::GetPayload() const {
// We only care about the payload bits of the refcount. These never change after
// initialization so we can use the relaxed memory order. The order doesn't guarantee
// anything except the atomicity of the load, which is enough since any past values of the
@ -38,7 +38,7 @@ uint64_t RefCounted::GetRefCountPayload() const {
return kPayloadMask & mRefCount.load(std::memory_order_relaxed);
}
void RefCounted::Reference() {
void RefCount::Increment() {
ASSERT((mRefCount & ~kPayloadMask) != 0);
// The relaxed ordering guarantees only the atomicity of the update, which is enough here
@ -49,7 +49,7 @@ void RefCounted::Reference() {
mRefCount.fetch_add(kRefCountIncrement, std::memory_order_relaxed);
}
void RefCounted::Release() {
bool RefCount::Decrement() {
ASSERT((mRefCount & ~kPayloadMask) != 0);
// The release fence here is to make sure all accesses to the object on a thread A
@ -69,18 +69,32 @@ void RefCounted::Release() {
// memory barrier, when an acquire load on mRefCount (using the `ldar` instruction)
// should be enough and could end up being faster.
std::atomic_thread_fence(std::memory_order_acquire);
return true;
}
return false;
}
RefCounted::RefCounted(uint64_t payload) : mRefCount(payload) {}
RefCounted::~RefCounted() = default;
uint64_t RefCounted::GetRefCountForTesting() const {
return mRefCount.GetValueForTesting();
}
uint64_t RefCounted::GetRefCountPayload() const {
return mRefCount.GetPayload();
}
void RefCounted::Reference() {
mRefCount.Increment();
}
void RefCounted::Release() {
if (mRefCount.Decrement()) {
DeleteThis();
}
}
void RefCounted::APIReference() {
Reference();
}
void RefCounted::APIRelease() {
Release();
}
void RefCounted::DeleteThis() {
delete this;
}

View File

@ -20,6 +20,24 @@
#include "dawn/common/RefBase.h"
class RefCount {
public:
// Create a refcount with a payload. The refcount starts initially at one.
explicit RefCount(uint64_t payload = 0);
uint64_t GetValueForTesting() const;
uint64_t GetPayload() const;
// Add a reference.
void Increment();
// Remove a reference. Returns true if this was the last reference.
bool Decrement();
private:
std::atomic<uint64_t> mRefCount;
};
class RefCounted {
public:
explicit RefCounted(uint64_t payload = 0);
@ -30,16 +48,17 @@ class RefCounted {
void Reference();
void Release();
void APIReference();
void APIRelease();
void APIReference() { Reference(); }
void APIRelease() { Release(); }
protected:
virtual ~RefCounted() = default;
virtual ~RefCounted();
// A Derived class may override this if they require a custom deleter.
virtual void DeleteThis();
private:
std::atomic<uint64_t> mRefCount;
RefCount mRefCount;
};
template <typename T>

View File

@ -51,7 +51,7 @@ class StackAllocator : public std::allocator<T> {
// constructors and destructors to be automatically called. Define a POD
// buffer of the right size instead.
alignas(T) char stack_buffer_[sizeof(T[stack_capacity])];
#if defined(DAWN_COMPILER_GCC) && !defined(__x86_64__) && !defined(__i386__)
#if DAWN_COMPILER_IS(GCC) && !defined(__x86_64__) && !defined(__i386__)
static_assert(alignof(T) <= 16, "http://crbug.com/115612");
#endif
@ -103,10 +103,11 @@ class StackAllocator : public std::allocator<T> {
// Free: when trying to free the stack buffer, just mark it as free. For
// non-stack-buffer pointers, just fall though to the standard allocator.
void deallocate(pointer p, size_type n) {
if (source_ && p == source_->stack_buffer())
if (source_ && p == source_->stack_buffer()) {
source_->used_stack_buffer_ = false;
else
} else {
std::allocator<T>::deallocate(p, n);
}
}
private:

View File

@ -17,15 +17,15 @@
#include "dawn/common/Assert.h"
#include "dawn/common/Log.h"
#if defined(DAWN_PLATFORM_WINDOWS)
#if DAWN_PLATFORM_IS(WINDOWS)
#include <Windows.h>
#include <vector>
#elif defined(DAWN_PLATFORM_LINUX)
#elif DAWN_PLATFORM_IS(LINUX)
#include <dlfcn.h>
#include <limits.h>
#include <unistd.h>
#include <cstdlib>
#elif defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
#elif DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
#include <dlfcn.h>
#include <mach-o/dyld.h>
#include <vector>
@ -33,7 +33,7 @@
#include <array>
#if defined(DAWN_PLATFORM_WINDOWS)
#if DAWN_PLATFORM_IS(WINDOWS)
const char* GetPathSeparator() {
return "\\";
}
@ -66,7 +66,7 @@ std::pair<std::string, bool> GetEnvironmentVar(const char* variableName) {
bool SetEnvironmentVar(const char* variableName, const char* value) {
return SetEnvironmentVariableA(variableName, value) == TRUE;
}
#elif defined(DAWN_PLATFORM_POSIX)
#elif DAWN_PLATFORM_IS(POSIX)
const char* GetPathSeparator() {
return "/";
}
@ -87,7 +87,7 @@ bool SetEnvironmentVar(const char* variableName, const char* value) {
#error "Implement Get/SetEnvironmentVar for your platform."
#endif
#if defined(DAWN_PLATFORM_WINDOWS)
#if DAWN_PLATFORM_IS(WINDOWS)
std::optional<std::string> GetHModulePath(HMODULE module) {
std::array<char, MAX_PATH> executableFileBuf;
DWORD executablePathLen = GetModuleFileNameA(nullptr, executableFileBuf.data(),
@ -100,7 +100,7 @@ std::optional<std::string> GetHModulePath(HMODULE module) {
std::optional<std::string> GetExecutablePath() {
return GetHModulePath(nullptr);
}
#elif defined(DAWN_PLATFORM_LINUX)
#elif DAWN_PLATFORM_IS(LINUX)
std::optional<std::string> GetExecutablePath() {
std::array<char, PATH_MAX> path;
ssize_t result = readlink("/proc/self/exe", path.data(), PATH_MAX - 1);
@ -111,7 +111,7 @@ std::optional<std::string> GetExecutablePath() {
path[result] = '\0';
return path.data();
}
#elif defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
#elif DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
std::optional<std::string> GetExecutablePath() {
uint32_t size = 0;
_NSGetExecutablePath(nullptr, &size);
@ -124,12 +124,12 @@ std::optional<std::string> GetExecutablePath() {
buffer[size] = '\0';
return buffer.data();
}
#elif defined(DAWN_PLATFORM_FUCHSIA)
#elif DAWN_PLATFORM_IS(FUCHSIA)
std::optional<std::string> GetExecutablePath() {
// UNIMPLEMENTED
return {};
}
#elif defined(DAWN_PLATFORM_EMSCRIPTEN)
#elif DAWN_PLATFORM_IS(EMSCRIPTEN)
std::optional<std::string> GetExecutablePath() {
return {};
}
@ -149,7 +149,7 @@ std::optional<std::string> GetExecutableDirectory() {
return exePath->substr(0, lastPathSepLoc + 1);
}
#if defined(DAWN_PLATFORM_LINUX) || defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
std::optional<std::string> GetModulePath() {
static int placeholderSymbol = 0;
Dl_info dlInfo;
@ -163,7 +163,7 @@ std::optional<std::string> GetModulePath() {
}
return absolutePath.data();
}
#elif defined(DAWN_PLATFORM_WINDOWS)
#elif DAWN_PLATFORM_IS(WINDOWS)
std::optional<std::string> GetModulePath() {
static int placeholderSymbol = 0;
HMODULE module = nullptr;
@ -179,11 +179,11 @@ std::optional<std::string> GetModulePath() {
#endif
return GetHModulePath(module);
}
#elif defined(DAWN_PLATFORM_FUCHSIA)
#elif DAWN_PLATFORM_IS(FUCHSIA)
std::optional<std::string> GetModulePath() {
return {};
}
#elif defined(DAWN_PLATFORM_EMSCRIPTEN)
#elif DAWN_PLATFORM_IS(EMSCRIPTEN)
std::optional<std::string> GetModulePath() {
return {};
}
@ -205,6 +205,8 @@ std::optional<std::string> GetModuleDirectory() {
// ScopedEnvironmentVar
ScopedEnvironmentVar::ScopedEnvironmentVar() = default;
ScopedEnvironmentVar::ScopedEnvironmentVar(const char* variableName, const char* value)
: mName(variableName),
mOriginalValue(GetEnvironmentVar(variableName)),

View File

@ -33,14 +33,14 @@ bool SetEnvironmentVar(const char* variableName, const char* value);
std::optional<std::string> GetExecutableDirectory();
std::optional<std::string> GetModuleDirectory();
#ifdef DAWN_PLATFORM_MACOS
#if DAWN_PLATFORM_IS(MACOS)
void GetMacOSVersion(int32_t* majorVersion, int32_t* minorVersion = nullptr);
bool IsMacOSVersionAtLeast(uint32_t majorVersion, uint32_t minorVersion = 0);
#endif
class ScopedEnvironmentVar {
public:
ScopedEnvironmentVar() = default;
ScopedEnvironmentVar();
ScopedEnvironmentVar(const char* variableName, const char* value);
~ScopedEnvironmentVar();

View File

@ -16,6 +16,7 @@
#define SRC_DAWN_COMMON_ITYP_BITSET_H_
#include "dawn/common/BitSetIterator.h"
#include "dawn/common/Platform.h"
#include "dawn/common/TypedInteger.h"
#include "dawn/common/UnderlyingType.h"
@ -124,9 +125,9 @@ class bitset : private std::bitset<N> {
template <typename Index, size_t N>
Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
using I = UnderlyingType<Index>;
#if defined(DAWN_COMPILER_MSVC)
#if DAWN_COMPILER_IS(MSVC)
if constexpr (N > 32) {
#if defined(DAWN_PLATFORM_64_BIT)
#if DAWN_PLATFORM_IS(64_BIT)
// NOLINTNEXTLINE(runtime/int)
unsigned long firstBitIndex = 0ul;
unsigned char ret = _BitScanReverse64(&firstBitIndex, bitset.to_ullong());
@ -134,7 +135,7 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
return Index(static_cast<I>(0));
}
return Index(static_cast<I>(firstBitIndex + 1));
#else // defined(DAWN_PLATFORM_64_BIT)
#else // DAWN_PLATFORM_IS(64_BIT)
if (bitset.none()) {
return Index(static_cast<I>(0));
}
@ -144,7 +145,7 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
}
}
UNREACHABLE();
#endif // defined(DAWN_PLATFORM_64_BIT)
#endif // DAWN_PLATFORM_IS(64_BIT)
} else {
// NOLINTNEXTLINE(runtime/int)
unsigned long firstBitIndex = 0ul;
@ -154,7 +155,7 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
}
return Index(static_cast<I>(firstBitIndex + 1));
}
#else // defined(DAWN_COMPILER_MSVC)
#else // DAWN_COMPILER_IS(MSVC)
if (bitset.none()) {
return Index(static_cast<I>(0));
}
@ -164,7 +165,7 @@ Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
} else {
return Index(static_cast<I>(32 - static_cast<uint32_t>(__builtin_clz(bitset.to_ulong()))));
}
#endif // defined(DAWN_COMPILER_MSVC)
#endif // DAWN_COMPILER_IS(MSVC)
}
#endif // SRC_DAWN_COMMON_ITYP_BITSET_H_

View File

@ -35,7 +35,7 @@
// redefined to be nullptr). This keeps the type-safety of having the handles be different types
// (like vulkan.h on 64 bit) but makes sure the types are different on 32 bit architectures.
#if defined(DAWN_PLATFORM_64_BIT)
#if DAWN_PLATFORM_IS(64_BIT)
#define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = struct object##_T*;
// This function is needed because MSVC doesn't accept reinterpret_cast from uint64_t from uint64_t
// TODO(cwallez@chromium.org): Remove this once we rework vulkan_platform.h
@ -43,7 +43,7 @@ template <typename T>
T NativeNonDispatachableHandleFromU64(uint64_t u64) {
return reinterpret_cast<T>(u64);
}
#elif defined(DAWN_PLATFORM_32_BIT)
#elif DAWN_PLATFORM_IS(32_BIT)
#define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = uint64_t;
template <typename T>
T NativeNonDispatachableHandleFromU64(uint64_t u64) {
@ -138,12 +138,12 @@ HandleType* AsVkArray(detail::VkHandle<Tag, HandleType>* handle) {
// headers that vulkan.h includes that we have "undefs" for. Note that some of the VK_USE_PLATFORM_*
// defines are defined already in the Vulkan-Header BUILD.gn, but are needed when building with
// CMake, hence they cannot be removed at the moment.
#if defined(DAWN_PLATFORM_WINDOWS)
#if DAWN_PLATFORM_IS(WINDOWS)
#ifndef VK_USE_PLATFORM_WIN32_KHR
#define VK_USE_PLATFORM_WIN32_KHR
#endif
#include "dawn/common/windows_with_undefs.h"
#endif // DAWN_PLATFORM_WINDOWS
#endif // DAWN_PLATFORM_IS(WINDOWS)
#if defined(DAWN_USE_X11)
#define VK_USE_PLATFORM_XLIB_KHR
@ -153,23 +153,29 @@ HandleType* AsVkArray(detail::VkHandle<Tag, HandleType>* handle) {
#include "dawn/common/xlib_with_undefs.h"
#endif // defined(DAWN_USE_X11)
#if defined(DAWN_USE_WAYLAND)
#ifndef VK_USE_PLATFORM_WAYLAND_KHR
#define VK_USE_PLATFORM_WAYLAND_KHR
#endif
#endif // defined(DAWN_USE_WAYLAND)
#if defined(DAWN_ENABLE_BACKEND_METAL)
#ifndef VK_USE_PLATFORM_METAL_EXT
#define VK_USE_PLATFORM_METAL_EXT
#endif
#endif // defined(DAWN_ENABLE_BACKEND_METAL)
#if defined(DAWN_PLATFORM_ANDROID)
#if DAWN_PLATFORM_IS(ANDROID)
#ifndef VK_USE_PLATFORM_ANDROID_KHR
#define VK_USE_PLATFORM_ANDROID_KHR
#endif
#endif // defined(DAWN_PLATFORM_ANDROID)
#endif // DAWN_PLATFORM_IS(ANDROID)
#if defined(DAWN_PLATFORM_FUCHSIA)
#if DAWN_PLATFORM_IS(FUCHSIA)
#ifndef VK_USE_PLATFORM_FUCHSIA
#define VK_USE_PLATFORM_FUCHSIA
#endif
#endif // defined(DAWN_PLATFORM_FUCHSIA)
#endif // DAWN_PLATFORM_IS(FUCHSIA)
// The actual inclusion of vulkan.h!
#define VK_NO_PROTOTYPES

View File

@ -17,7 +17,7 @@
#include "dawn/common/Platform.h"
#if !defined(DAWN_PLATFORM_WINDOWS)
#if !DAWN_PLATFORM_IS(WINDOWS)
#error "windows_with_undefs.h included on non-Windows"
#endif

View File

@ -17,7 +17,7 @@
#include "dawn/common/Platform.h"
#if !defined(DAWN_PLATFORM_LINUX)
#if !DAWN_PLATFORM_IS(LINUX)
#error "xlib_with_undefs.h included on non-Linux"
#endif

View File

@ -25,21 +25,11 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return DawnWireServerFuzzer::Run(
data, size,
[](dawn::native::Instance* instance) {
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();
wgpu::Device device;
for (dawn::native::Adapter adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
if (properties.backendType == wgpu::BackendType::D3D12 &&
properties.adapterType == wgpu::AdapterType::CPU) {
device = wgpu::Device::Acquire(adapter.CreateDevice());
break;
}
}
return device;
[](const dawn::native::Adapter& adapter) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
return properties.backendType == wgpu::BackendType::D3D12 &&
properties.adapterType == wgpu::AdapterType::CPU;
},
true /* supportsErrorInjection */);
}

View File

@ -26,22 +26,10 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return DawnWireServerFuzzer::Run(
data, size,
[](dawn::native::Instance* instance) {
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();
wgpu::Device nullDevice;
for (dawn::native::Adapter adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
if (properties.backendType == wgpu::BackendType::Null) {
nullDevice = wgpu::Device::Acquire(adapter.CreateDevice());
break;
}
}
ASSERT(nullDevice.Get() != nullptr);
return nullDevice;
[](const dawn::native::Adapter& adapter) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
return properties.backendType == wgpu::BackendType::Null;
},
false /* supportsErrorInjection */);
}

View File

@ -15,6 +15,7 @@
#include <vector>
#include "DawnWireServerFuzzer.h"
#include "dawn/common/GPUInfo.h"
#include "dawn/native/DawnNative.h"
#include "testing/libfuzzer/libfuzzer_exports.h"
@ -25,21 +26,11 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return DawnWireServerFuzzer::Run(
data, size,
[](dawn::native::Instance* instance) {
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();
[](const dawn::native::Adapter& adapter) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
wgpu::Device device;
for (dawn::native::Adapter adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
if (properties.backendType == wgpu::BackendType::Vulkan &&
properties.adapterType == wgpu::AdapterType::CPU) {
device = wgpu::Device::Acquire(adapter.CreateDevice());
break;
}
}
return device;
return gpu_info::IsGoogleSwiftshader(properties.vendorID, properties.deviceID);
},
true /* supportsErrorInjection */);
}

Some files were not shown because too many files have changed in this diff Show More