Skip to content

Commit f792d3c

Browse files
[WebGPU, Dawn]: Upgrade Dawn and new features for WebGPU
1 parent 6dbc11a commit f792d3c

Some content is hidden

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

50 files changed

+1064
-635
lines changed

BuildTools/CMake/BuildUtils.cmake

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,21 @@ function(set_common_target_properties TARGET)
295295
custom_post_configure_target(${TARGET})
296296
endif()
297297

298+
# Mark generated files as such to avoid "file not found" warnings in some IDEs in configuration stage
299+
if (WEBGPU_SUPPORTED AND (NOT PLATFORM_WEB))
300+
set(DAWN_GENERATED_HEADERS
301+
${DAWN_BUILD_GEN_DIR}/include/dawn/webgpu.h
302+
${DAWN_BUILD_GEN_DIR}/include/dawn/webgpu_cpp.h
303+
${DAWN_BUILD_GEN_DIR}/include/dawn/webgpu_cpp_print.h
304+
${DAWN_BUILD_GEN_DIR}/include/dawn/wire/client/webgpu.h
305+
${DAWN_BUILD_GEN_DIR}/include/dawn/wire/client/webgpu_cpp.h
306+
${DAWN_BUILD_GEN_DIR}/include/dawn/wire/client/webgpu_cpp_print.h
307+
${DAWN_BUILD_GEN_DIR}/include/dawn/dawn_proc_table.h
308+
${DAWN_BUILD_GEN_DIR}/include/webgpu/webgpu_cpp_chained_struct.h
309+
)
310+
set_source_files_properties(${DAWN_GENERATED_HEADERS} PROPERTIES GENERATED TRUE)
311+
endif()
312+
298313
endfunction()
299314

300315
function(find_targets_in_directory _RESULT _DIR)
@@ -516,24 +531,29 @@ function(add_format_validation_target MODULE_NAME MODULE_ROOT_PATH IDE_FOLDER)
516531

517532
endfunction()
518533

519-
# FetchContent's GIT_SHALLOW option is buggy and does not actually do a shallow
520-
# clone. This macro takes care of it.
521-
macro(FetchContent_DeclareShallowGit Name GIT_REPOSITORY GitRepository GIT_TAG GitTag)
534+
# The GIT_SHALLOW option in FetchContent is buggy and does not actually perform
535+
# a shallow clone. This macro fixes that. Also, we do not want to clone all
536+
# submodules to reduce download time, therefore we add an option GIT_SUBMODULES
537+
# to specify which submodules should be cloned (if any).
538+
macro(FetchContent_DeclareShallowGit Name GIT_REPOSITORY GitRepository GIT_TAG GitTag GIT_SUBMODULES GitSubmodules)
522539
include(FetchContent)
523-
FetchContent_Declare(
524-
"${Name}"
525540

526-
# This is what it'd look like if GIT_SHALLOW was indeed working:
527-
#GIT_REPOSITORY "${GitRepository}"
528-
#GIT_TAG "${GitTag}"
529-
#GIT_SHALLOW ON
541+
# This is what it'd look like if GIT_SHALLOW was indeed working:
542+
#GIT_REPOSITORY "${GitRepository}"
543+
#GIT_TAG "${GitTag}"
544+
#GIT_SHALLOW ON
545+
#GIT_SUBMODULES "${GitSubmodules}"
530546

531-
# Manual download mode instead:
547+
# Manual download mode instead:
548+
FetchContent_Declare(
549+
${Name}
532550
DOWNLOAD_COMMAND
533551
cd "${FETCHCONTENT_BASE_DIR}/${Name}-src" &&
534552
git init &&
535-
git fetch --depth=1 "${GitRepository}" "${GitTag}" &&
536-
git reset --hard FETCH_HEAD
553+
git remote add origin "${GitRepository}" &&
554+
git fetch --depth=1 origin "${GitTag}" &&
555+
git checkout FETCH_HEAD &&
556+
git submodule update --init --recursive --depth=1 ${GitSubmodules}
537557
)
538558
endmacro()
539559

Common/interface/ParsingTools.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,6 @@ TokenIterType FindMatchingBracket(const TokenIterType& Start,
956956
ClosingBracketType = TokenType::OpenSquareBracket;
957957
SearchForward = false;
958958
break;
959-
960959
case TokenType::ClosingAngleBracket:
961960
ClosingBracketType = TokenType::OpenAngleBracket;
962961
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)