Skip to content

Commit 26453ac

Browse files
[WebGPU, Dawn]: Upgrade Dawn and new features for WebGPU
1 parent da5189b commit 26453ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1057
-627
lines changed

BuildTools/CMake/BuildUtils.cmake

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,21 @@ function(set_common_target_properties TARGET)
245245
custom_post_configure_target(${TARGET})
246246
endif()
247247

248+
# Mark generated files as such to avoid "file not found" warnings in some IDEs in configuration stage
249+
if (WEBGPU_SUPPORTED AND (NOT PLATFORM_WEB))
250+
set(DAWN_GENERATED_HEADERS
251+
${DAWN_BUILD_GEN_DIR}/include/dawn/webgpu.h
252+
${DAWN_BUILD_GEN_DIR}/include/dawn/webgpu_cpp.h
253+
${DAWN_BUILD_GEN_DIR}/include/dawn/webgpu_cpp_print.h
254+
${DAWN_BUILD_GEN_DIR}/include/dawn/wire/client/webgpu.h
255+
${DAWN_BUILD_GEN_DIR}/include/dawn/wire/client/webgpu_cpp.h
256+
${DAWN_BUILD_GEN_DIR}/include/dawn/wire/client/webgpu_cpp_print.h
257+
${DAWN_BUILD_GEN_DIR}/include/dawn/dawn_proc_table.h
258+
${DAWN_BUILD_GEN_DIR}/include/webgpu/webgpu_cpp_chained_struct.h
259+
)
260+
set_source_files_properties(${DAWN_GENERATED_HEADERS} PROPERTIES GENERATED TRUE)
261+
endif()
262+
248263
endfunction()
249264

250265
function(find_targets_in_directory _RESULT _DIR)
@@ -466,24 +481,29 @@ function(add_format_validation_target MODULE_NAME MODULE_ROOT_PATH IDE_FOLDER)
466481

467482
endfunction()
468483

469-
# FetchContent's GIT_SHALLOW option is buggy and does not actually do a shallow
470-
# clone. This macro takes care of it.
471-
macro(FetchContent_DeclareShallowGit Name GIT_REPOSITORY GitRepository GIT_TAG GitTag)
484+
# The GIT_SHALLOW option in FetchContent is buggy and does not actually perform
485+
# a shallow clone. This macro fixes that. Also, we do not want to clone all
486+
# submodules to reduce download time, therefore we add an option GIT_SUBMODULES
487+
# to specify which submodules should be cloned (if any).
488+
macro(FetchContent_DeclareShallowGit Name GIT_REPOSITORY GitRepository GIT_TAG GitTag GIT_SUBMODULES GitSubmodules)
472489
include(FetchContent)
473-
FetchContent_Declare(
474-
"${Name}"
475490

476-
# This is what it'd look like if GIT_SHALLOW was indeed working:
477-
#GIT_REPOSITORY "${GitRepository}"
478-
#GIT_TAG "${GitTag}"
479-
#GIT_SHALLOW ON
491+
# This is what it'd look like if GIT_SHALLOW was indeed working:
492+
#GIT_REPOSITORY "${GitRepository}"
493+
#GIT_TAG "${GitTag}"
494+
#GIT_SHALLOW ON
495+
#GIT_SUBMODULES "${GitSubmodules}"
480496

481-
# Manual download mode instead:
497+
# Manual download mode instead:
498+
FetchContent_Declare(
499+
${Name}
482500
DOWNLOAD_COMMAND
483501
cd "${FETCHCONTENT_BASE_DIR}/${Name}-src" &&
484502
git init &&
485-
git fetch --depth=1 "${GitRepository}" "${GitTag}" &&
486-
git reset --hard FETCH_HEAD
503+
git remote add origin "${GitRepository}" &&
504+
git fetch --depth=1 origin "${GitTag}" &&
505+
git checkout FETCH_HEAD &&
506+
git submodule update --init --recursive --depth=1 ${GitSubmodules}
487507
)
488508
endmacro()
489509

Common/interface/ParsingTools.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ TokenIterType FindMatchingBracket(const TokenIterType& Start,
955955
ClosingBracketType = TokenType::OpenSquareBracket;
956956
SearchForward = false;
957957
break;
958-
959958
case TokenType::ClosingAngleBracket:
960959
ClosingBracketType = TokenType::OpenAngleBracket;
961960
SearchForward = false;

Graphics/GraphicsEngineWebGPU/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ PRIVATE
179179
)
180180

181181
if (PLATFORM_WEB)
182-
target_link_options(Diligent-GraphicsEngineWebGPU-static PUBLIC "SHELL: -s USE_WEBGPU=1 -s USE_PTHREADS=1")
182+
target_link_options(Diligent-GraphicsEngineWebGPU-static PUBLIC "SHELL: --use-port=emdawnwebgpu -s USE_PTHREADS=1")
183+
target_compile_options(Diligent-GraphicsEngineWebGPU-static PUBLIC "--use-port=emdawnwebgpu")
184+
# This is required only for IntelliSense to detect webgpu.h.
185+
target_include_directories(Diligent-GraphicsEngineWebGPU-static PUBLIC
186+
${EMSCRIPTEN_ROOT_PATH}/cache/ports/emdawnwebgpu/emdawnwebgpu_pkg/webgpu/include
187+
)
183188
endif()
184189

185190
target_compile_definitions(Diligent-GraphicsEngineWebGPU-shared PUBLIC DILIGENT_WEBGPU_SHARED=1)

Graphics/GraphicsEngineWebGPU/include/WebGPUStubs.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,5 @@
2929
#if PLATFORM_WEB
3030

3131
inline constexpr WGPUFeatureName WGPUFeatureName_ChromiumExperimentalTimestampQueryInsidePasses = static_cast<WGPUFeatureName>(0x000003EE);
32-
inline constexpr WGPUFeatureName WGPUFeatureName_Unorm16TextureFormats = static_cast<WGPUFeatureName>(0x000003FB);
33-
inline constexpr WGPUFeatureName WGPUFeatureName_Snorm16TextureFormats = static_cast<WGPUFeatureName>(0x000003FC);
34-
35-
inline constexpr WGPUTextureFormat WGPUTextureFormat_R16Unorm = static_cast<WGPUTextureFormat>(0x00000060);
36-
inline constexpr WGPUTextureFormat WGPUTextureFormat_R16Snorm = static_cast<WGPUTextureFormat>(0x00000063);
37-
inline constexpr WGPUTextureFormat WGPUTextureFormat_RG16Unorm = static_cast<WGPUTextureFormat>(0x00000061);
38-
inline constexpr WGPUTextureFormat WGPUTextureFormat_RG16Snorm = static_cast<WGPUTextureFormat>(0x00000064);
39-
inline constexpr WGPUTextureFormat WGPUTextureFormat_RGBA16Unorm = static_cast<WGPUTextureFormat>(0x00000062);
40-
inline constexpr WGPUTextureFormat WGPUTextureFormat_RGBA16Snorm = static_cast<WGPUTextureFormat>(0x00000065);
41-
42-
inline constexpr WGPUSurfaceGetCurrentTextureStatus WGPUSurfaceGetCurrentTextureStatus_Error = static_cast<WGPUSurfaceGetCurrentTextureStatus>(0x00000007);
4332

4433
#endif

Graphics/GraphicsEngineWebGPU/include/pch.h

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,45 +37,11 @@
3737

3838
#if PLATFORM_WEB
3939

40-
using WGPUOptionalBool = bool;
41-
using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor;
42-
using WGPUStringView = const char*;
43-
using WGPUSurfaceSourceCanvasHTMLSelector_Emscripten = WGPUSurfaceDescriptorFromCanvasHTMLSelector;
40+
using WGPUSurfaceSourceCanvasHTMLSelector_Emscripten = WGPUEmscriptenSurfaceSourceCanvasHTMLSelector;
4441

45-
constexpr bool WGPUOptionalBool_True = true;
46-
constexpr bool WGPUOptionalBool_False = false;
42+
constexpr WGPUSType WGPUSType_SurfaceSourceCanvasHTMLSelector_Emscripten = WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector;
4743

48-
constexpr WGPUSType WGPUSType_ShaderSourceWGSL = WGPUSType_ShaderModuleWGSLDescriptor;
49-
constexpr WGPUSType WGPUSType_SurfaceSourceCanvasHTMLSelector_Emscripten = WGPUSType_SurfaceDescriptorFromCanvasHTMLSelector;
50-
51-
constexpr WGPUBufferBindingType WGPUBufferBindingType_BindingNotUsed = WGPUBufferBindingType_Undefined;
52-
constexpr WGPUSamplerBindingType WGPUSamplerBindingType_BindingNotUsed = WGPUSamplerBindingType_Undefined;
53-
constexpr WGPUTextureSampleType WGPUTextureSampleType_BindingNotUsed = WGPUTextureSampleType_Undefined;
54-
constexpr WGPUStorageTextureAccess WGPUStorageTextureAccess_BindingNotUsed = WGPUStorageTextureAccess_Undefined;
55-
56-
constexpr WGPUFeatureName WGPUFeatureName_DualSourceBlending = static_cast<WGPUFeatureName>(0x00050008);
57-
58-
inline bool WGPUStringViewValid(WGPUStringView Str)
59-
{
60-
return Str != nullptr && Str[0] != '\0';
61-
}
62-
63-
inline const char* WGPUStringViewToString(WGPUStringView Str)
64-
{
65-
return Str;
66-
}
67-
68-
inline WGPUStringView GetWGPUStringView(const std::string& Str)
69-
{
70-
return Str.c_str();
71-
}
72-
73-
inline WGPUStringView GetWGPUStringView(const char* Str)
74-
{
75-
return Str;
76-
}
77-
78-
#else
44+
#endif
7945

8046
inline bool WGPUStringViewValid(const WGPUStringView& Str)
8147
{
@@ -102,5 +68,3 @@ inline WGPUStringView GetWGPUStringView(const char* Str)
10268
{
10369
return {Str, Str ? strlen(Str) : 0};
10470
}
105-
106-
#endif

0 commit comments

Comments
 (0)