Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update webgpu and support all platforms/archs #63

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,20 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(SLANG_RHI_HAS_VULKAN ON)
set(SLANG_RHI_HAS_METAL OFF)
set(SLANG_RHI_HAS_CUDA ON)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64|AMD64")
set(SLANG_RHI_HAS_WGPU ON)
else()
set(SLANG_RHI_HAS_WGPU OFF)
endif()
set(SLANG_RHI_HAS_WGPU ON)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(SLANG_RHI_HAS_D3D11 OFF)
set(SLANG_RHI_HAS_D3D12 OFF)
set(SLANG_RHI_HAS_VULKAN ON)
set(SLANG_RHI_HAS_METAL OFF)
set(SLANG_RHI_HAS_CUDA ON)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64|AMD64")
set(SLANG_RHI_HAS_WGPU ON)
else()
set(SLANG_RHI_HAS_WGPU OFF)
endif()
set(SLANG_RHI_HAS_WGPU ON)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(SLANG_RHI_HAS_D3D11 OFF)
set(SLANG_RHI_HAS_D3D12 OFF)
set(SLANG_RHI_HAS_VULKAN ON)
set(SLANG_RHI_HAS_METAL ON)
set(SLANG_RHI_HAS_CUDA OFF)
set(SLANG_RHI_HAS_WGPU ON)
endif()

Expand Down Expand Up @@ -121,15 +114,22 @@ unset(SLANG_RHI_SLANG_BINARY_DIR)

# Fetch and setup Google Dawn library (WebGPU implementation)
if(SLANG_RHI_ENABLE_WGPU)
set(DAWN_VERSION "129.0.6728")
set(DAWN_URL "https://github.com/skallweitNV/webgpu-dawn-binaries/releases/download/v${DAWN_VERSION}.0/webgpu-dawn-${DAWN_VERSION}")
set(DAWN_VERSION "131.0.6738.0")
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(DAWN_URL "${DAWN_URL}-win64.zip")
set(DAWN_OS "windows")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(DAWN_URL "${DAWN_URL}-Linux.zip")
set(DAWN_OS "linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(DAWN_URL "${DAWN_URL}-Darwin.zip")
set(DAWN_OS "macos")
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
set(DAWN_ARCH "x86_64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
set(DAWN_ARCH "aarch64")
else()
message(FATAL_ERROR "Unsupported processor architecture")
endif()
set(DAWN_URL "https://github.com/shader-slang/webgpu-dawn-binaries/releases/download/v${DAWN_VERSION}/webgpu-dawn-${DAWN_VERSION}-${DAWN_OS}-${DAWN_ARCH}.zip")
FetchPackage(dawn URL ${DAWN_URL})
set(SLANG_RHI_DAWN_INCLUDE_DIR ${dawn_SOURCE_DIR}/include CACHE STRING "Dawn include directory")
set(SLANG_RHI_DAWN_LIB_DIR ${dawn_SOURCE_DIR}/lib CACHE STRING "Dawn lib directory")
Expand Down
3 changes: 2 additions & 1 deletion src/wgpu/wgpu-shader-program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Result ShaderProgramImpl::createShaderModule(slang::EntryPointReflection* entryP

WGPUShaderModuleWGSLDescriptor wgslDesc = {};
wgslDesc.chain.sType = WGPUSType_ShaderSourceWGSL;
wgslDesc.code = module.code.c_str();
wgslDesc.code.data = module.code.c_str();
wgslDesc.code.length = module.code.size();
WGPUShaderModuleDescriptor desc = {};
desc.nextInChain = (WGPUChainedStruct*)&wgslDesc;

Expand Down