Nuke SPIRV-Cross.
Change-Id: I1fc58d50ba3999e3a9b6f4e30a0799be301893de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79481
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0a6fb80..3813bfe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -127,7 +127,6 @@
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_SPIRV_CROSS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-cross/src" "Directory in which to find SPIRV-Cross")
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_TINT_DIR "${DAWN_THIRD_PARTY_DIR}/tint" "Directory in which to find Tint")
@@ -143,12 +142,6 @@
set(DAWN_ENABLE_OPENGL ON)
endif()
-# OpenGL backend requires SPIRV-Cross
-set(DAWN_REQUIRES_SPIRV_CROSS OFF)
-if (DAWN_ENABLE_OPENGL)
- set(DAWN_REQUIRES_SPIRV_CROSS ON)
-endif()
-
if(DAWN_ENABLE_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
diff --git a/build_overrides/dawn.gni b/build_overrides/dawn.gni
index 12d9ffa..bbded06 100644
--- a/build_overrides/dawn.gni
+++ b/build_overrides/dawn.gni
@@ -33,7 +33,6 @@
dawn_glfw_dir = "//third_party/glfw"
dawn_googletest_dir = "//third_party/googletest"
dawn_spirv_tools_dir = "//third_party/vulkan-deps/spirv-tools/src"
-dawn_spirv_cross_dir = "//third_party/vulkan-deps/spirv-cross/src"
dawn_swiftshader_dir = "//third_party/swiftshader"
dawn_tint_dir = "//third_party/tint"
dawn_vulkan_loader_dir = "//third_party/vulkan-deps/vulkan-loader/src"
diff --git a/docs/dawn/overview.md b/docs/dawn/overview.md
index 50907b8..acb3848 100644
--- a/docs/dawn/overview.md
+++ b/docs/dawn/overview.md
@@ -34,7 +34,7 @@
The largest library in Dawn is `dawn_native` which implements the WebGPU API by translating to native graphics APIs such as D3D12, Metal or Vulkan. It is composed of a frontend that does all the state-tracking and validation, and backends that do the actual translation to the native graphics APIs.
-`dawn_native` hosts the [spirv-val](https://github.com/KhronosGroup/SPIRV-Tools) for validation of SPIR-V shaders and uses [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross) shader translator to convert SPIR-V shaders to an equivalent shader for use in the native graphics API (HLSL for D3D12, MSL for Metal or Vulkan SPIR-V for Vulkan).
+`dawn_native` hosts the [spirv-val](https://github.com/KhronosGroup/SPIRV-Tools) for validation of SPIR-V shaders and uses [Tint](https://dawn.googlesource.com/tint/) shader translator to convert WGSL shaders to an equivalent shader for use in the native graphics API (HLSL for D3D12, MSL for Metal or Vulkan SPIR-V for Vulkan).
## Dawn Wire (`dawn_wire`)
diff --git a/scripts/dawn_features.gni b/scripts/dawn_features.gni
index d00ab62..228c727 100644
--- a/scripts/dawn_features.gni
+++ b/scripts/dawn_features.gni
@@ -71,13 +71,6 @@
dawn_enable_vulkan = is_linux || is_chromeos || (is_win && !dawn_is_winuwp) ||
is_fuchsia || is_android || dawn_use_swiftshader
- # Enable use of reflection compiler in spirv-cross. This is needed
- # if performing reflection on systems that the platform language
- # shader is SPIR-V, since there isn't an instance of the
- # GLSL/HLSL/MSL compiler. This implicitly pulls in the GLSL
- # compiler, since it is a sub-class of it.
- dawn_enable_cross_reflection = false
-
# Enables error injection for faking failures to native API calls
dawn_enable_error_injection =
is_debug || (build_with_chromium && use_fuzzing_engine)
@@ -103,7 +96,3 @@
# Much of the GL backend code is shared, so define a convenience var.
dawn_enable_opengl = dawn_enable_opengles || dawn_enable_desktop_gl
-
-# The GL backends are the last to use SPIRV-Cross, so only compile it in
-# if they are enabled.
-dawn_use_spirv_cross = dawn_enable_opengl
diff --git a/scripts/dawn_overrides_with_defaults.gni b/scripts/dawn_overrides_with_defaults.gni
index 58df933..35a8baf 100644
--- a/scripts/dawn_overrides_with_defaults.gni
+++ b/scripts/dawn_overrides_with_defaults.gni
@@ -45,10 +45,6 @@
dawn_googletest_dir = "//third_party/googletest"
}
-if (!defined(dawn_spirv_cross_dir)) {
- dawn_spirv_cross_dir = "//third_party/vulkan-deps/spirv-cross/src"
-}
-
if (!defined(dawn_spirv_tools_dir)) {
dawn_spirv_tools_dir = "//third_party/vulkan-deps/spirv-tools/src"
}
diff --git a/scripts/roll-shader-deps.sh b/scripts/roll-shader-deps.sh
deleted file mode 100755
index 8fbcac5..0000000
--- a/scripts/roll-shader-deps.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright 2019 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.
-
-# Attempts to roll all entries in DEPS to tip-of-tree and create a commit.
-#
-# Depends on roll-dep from depot_path being in PATH.
-
-spirv_cross_dir="third_party/spirv-cross/"
-spirv_cross_trunk="origin/master"
-spirv_headers_dir="third_party/spirv-headers/"
-spirv_headers_trunk="origin/master"
-spirv_tools_dir="third_party/SPIRV-Tools/"
-spirv_tools_trunk="origin/master"
-tint_dir="third_party/tint/"
-tint_trunk="origin/main"
-
-# This script assumes it's parent directory is the repo root.
-repo_path=$(dirname "$0")/..
-
-cd "$repo_path"
-
-if [[ $(git diff --stat) != '' ]]; then
- echo "Working tree is dirty, commit changes before attempting to roll DEPS"
- exit 1
-fi
-
-old_head=$(git rev-parse HEAD)
-
-roll-dep --ignore-dirty-tree --roll-to="${spirv_cross_trunk}" "${spirv_cross_dir}"
-roll-dep --ignore-dirty-tree --roll-to="${spirv_headers_trunk}" "${spirv_headers_dir}"
-roll-dep --ignore-dirty-tree --roll-to="${spirv_tools_trunk}" "${spirv_tools_dir}"
-roll-dep --ignore-dirty-tree --roll-to="${tint_trunk}" "${tint_dir}"
-
-git rebase --interactive "${old_head}"
diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn
index d76a813..d70cdbf 100644
--- a/src/dawn/native/BUILD.gn
+++ b/src/dawn/native/BUILD.gn
@@ -165,9 +165,6 @@
"${dawn_spirv_tools_dir}:spvtools_val",
"${dawn_tint_dir}/src:libtint",
]
- if (dawn_use_spirv_cross) {
- deps += [ "${dawn_root}/third_party/gn/spirv_cross:spirv_cross" ]
- }
defines = []
libs = []
data_deps = []
@@ -561,8 +558,6 @@
"opengl/SamplerGL.h",
"opengl/ShaderModuleGL.cpp",
"opengl/ShaderModuleGL.h",
- "opengl/SpirvUtils.cpp",
- "opengl/SpirvUtils.h",
"opengl/SwapChainGL.cpp",
"opengl/SwapChainGL.h",
"opengl/TextureGL.cpp",
diff --git a/src/dawn/native/CMakeLists.txt b/src/dawn/native/CMakeLists.txt
index be1db1e..38b63d8 100644
--- a/src/dawn/native/CMakeLists.txt
+++ b/src/dawn/native/CMakeLists.txt
@@ -192,13 +192,6 @@
absl_str_format_internal
)
-if (DAWN_REQUIRES_SPIRV_CROSS)
- target_link_libraries(dawn_native PRIVATE spirv-cross-core)
- if (DAWN_ENABLE_OPENGL)
- target_link_libraries(dawn_native PRIVATE spirv-cross-glsl)
- endif()
-endif()
-
target_include_directories(dawn_native PRIVATE ${DAWN_ABSEIL_DIR})
if (DAWN_USE_X11)
@@ -434,8 +427,6 @@
"opengl/SamplerGL.h"
"opengl/ShaderModuleGL.cpp"
"opengl/ShaderModuleGL.h"
- "opengl/SpirvUtils.cpp"
- "opengl/SpirvUtils.h"
"opengl/SwapChainGL.cpp"
"opengl/SwapChainGL.h"
"opengl/TextureGL.cpp"
diff --git a/src/dawn/native/d3d12/BindGroupD3D12.cpp b/src/dawn/native/d3d12/BindGroupD3D12.cpp
index 8594455..f169345 100644
--- a/src/dawn/native/d3d12/BindGroupD3D12.cpp
+++ b/src/dawn/native/d3d12/BindGroupD3D12.cpp
@@ -81,7 +81,7 @@
}
case wgpu::BufferBindingType::Storage:
case kInternalStorageBufferBinding: {
- // Since SPIRV-Cross outputs HLSL shaders with RWByteAddressBuffer,
+ // Since Tint outputs HLSL shaders with RWByteAddressBuffer,
// we must use D3D12_BUFFER_UAV_FLAG_RAW when making the
// UNORDERED_ACCESS_VIEW_DESC. Using D3D12_BUFFER_UAV_FLAG_RAW requires
// that we use DXGI_FORMAT_R32_TYPELESS as the format of the view.
@@ -104,7 +104,7 @@
break;
}
case wgpu::BufferBindingType::ReadOnlyStorage: {
- // Like StorageBuffer, SPIRV-Cross outputs HLSL shaders for readonly
+ // Like StorageBuffer, Tint outputs HLSL shaders for readonly
// storage buffer with ByteAddressBuffer. So we must use
// D3D12_BUFFER_SRV_FLAG_RAW when making the SRV descriptor. And it has
// similar requirement for format, element size, etc.
diff --git a/src/dawn/native/metal/CommandBufferMTL.mm b/src/dawn/native/metal/CommandBufferMTL.mm
index b9a4960..86b88a8 100644
--- a/src/dawn/native/metal/CommandBufferMTL.mm
+++ b/src/dawn/native/metal/CommandBufferMTL.mm
@@ -295,7 +295,7 @@
// Metal uses a physical addressing mode which means buffers in the shading language are
// just pointers to the virtual address of their start. This means there is no way to know
// the length of a buffer to compute the length() of unsized arrays at the end of storage
- // buffers. SPIRV-Cross implements the length() of unsized arrays by requiring an extra
+ // buffers. Tint implements the length() of unsized arrays by requiring an extra
// buffer that contains the length of other buffers. This structure that keeps track of the
// length of storage buffers and can apply them to the reserved "buffer length buffer" when
// needed for a draw or a dispatch.
@@ -303,7 +303,7 @@
wgpu::ShaderStage dirtyStages = wgpu::ShaderStage::None;
// The lengths of buffers are stored as 32bit integers because that is the width the
- // MSL code generated by SPIRV-Cross expects.
+ // MSL code generated by Tint expects.
// UBOs require we align the max buffer count to 4 elements (16 bytes).
static constexpr size_t MaxBufferCount = ((kGenericMetalBufferSlots + 3) / 4) * 4;
PerStage<std::array<uint32_t, MaxBufferCount>> data;
diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp
index b155093..6bda26b 100644
--- a/src/dawn/native/opengl/ShaderModuleGL.cpp
+++ b/src/dawn/native/opengl/ShaderModuleGL.cpp
@@ -14,25 +14,14 @@
#include "dawn/native/opengl/ShaderModuleGL.h"
-#include "dawn/common/Assert.h"
-#include "dawn/common/Platform.h"
#include "dawn/native/BindGroupLayout.h"
-#include "dawn/native/SpirvValidation.h"
#include "dawn/native/TintUtils.h"
#include "dawn/native/opengl/DeviceGL.h"
#include "dawn/native/opengl/PipelineLayoutGL.h"
-#include "dawn/native/opengl/SpirvUtils.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
-#include <spirv_glsl.hpp>
-
-// Tint include must be after spirv_glsl.hpp, because spirv-cross has its own
-// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
-// is at 3 while spirv-headers is at 4.
-#undef SPV_REVISION
#include <tint/tint.h>
-#include <spirv-tools/libspirv.hpp>
#include <sstream>
@@ -68,151 +57,6 @@
return o.str();
}
- ResultOrError<std::unique_ptr<BindingInfoArray>> ExtractSpirvInfo(
- const DeviceBase* device,
- const spirv_cross::Compiler& compiler,
- const std::string& entryPointName,
- SingleShaderStage stage) {
- const auto& resources = compiler.get_shader_resources();
-
- // Fill in bindingInfo with the SPIRV bindings
- auto ExtractResourcesBinding =
- [](const DeviceBase* device,
- const spirv_cross::SmallVector<spirv_cross::Resource>& resources,
- const spirv_cross::Compiler& compiler, BindingInfoType bindingType,
- BindingInfoArray* bindings, bool isStorageBuffer = false) -> MaybeError {
- for (const auto& resource : resources) {
- DAWN_INVALID_IF(
- !compiler.get_decoration_bitset(resource.id).get(spv::DecorationBinding),
- "No Binding decoration set for resource");
-
- DAWN_INVALID_IF(
- !compiler.get_decoration_bitset(resource.id).get(spv::DecorationDescriptorSet),
- "No Descriptor Decoration set for resource");
-
- BindingNumber bindingNumber(
- compiler.get_decoration(resource.id, spv::DecorationBinding));
- BindGroupIndex bindGroupIndex(
- compiler.get_decoration(resource.id, spv::DecorationDescriptorSet));
-
- DAWN_INVALID_IF(bindGroupIndex >= kMaxBindGroupsTyped,
- "Bind group index over limits in the SPIRV");
-
- const auto& [entry, inserted] =
- (*bindings)[bindGroupIndex].emplace(bindingNumber, ShaderBindingInfo{});
- DAWN_INVALID_IF(!inserted, "Shader has duplicate bindings");
-
- ShaderBindingInfo* info = &entry->second;
- info->id = resource.id;
- info->base_type_id = resource.base_type_id;
- info->bindingType = bindingType;
-
- switch (bindingType) {
- case BindingInfoType::Texture: {
- spirv_cross::SPIRType::ImageType imageType =
- compiler.get_type(info->base_type_id).image;
- spirv_cross::SPIRType::BaseType textureComponentType =
- compiler.get_type(imageType.type).basetype;
-
- info->texture.viewDimension =
- SpirvDimToTextureViewDimension(imageType.dim, imageType.arrayed);
- info->texture.multisampled = imageType.ms;
- info->texture.compatibleSampleTypes =
- SpirvBaseTypeToSampleTypeBit(textureComponentType);
-
- if (imageType.depth) {
- DAWN_INVALID_IF(
- (info->texture.compatibleSampleTypes & SampleTypeBit::Float) == 0,
- "Depth textures must have a float type");
- info->texture.compatibleSampleTypes = SampleTypeBit::Depth;
- }
-
- DAWN_INVALID_IF(imageType.ms && imageType.arrayed,
- "Multisampled array textures aren't supported");
- break;
- }
- case BindingInfoType::Buffer: {
- // Determine buffer size, with a minimum of 1 element in the runtime
- // array
- spirv_cross::SPIRType type = compiler.get_type(info->base_type_id);
- info->buffer.minBindingSize =
- compiler.get_declared_struct_size_runtime_array(type, 1);
-
- // Differentiate between readonly storage bindings and writable ones
- // based on the NonWritable decoration.
- // TODO(dawn:527): Could isStorageBuffer be determined by calling
- // compiler.get_storage_class(resource.id)?
- if (isStorageBuffer) {
- spirv_cross::Bitset flags =
- compiler.get_buffer_block_flags(resource.id);
- if (flags.get(spv::DecorationNonWritable)) {
- info->buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
- } else {
- info->buffer.type = wgpu::BufferBindingType::Storage;
- }
- } else {
- info->buffer.type = wgpu::BufferBindingType::Uniform;
- }
- break;
- }
- case BindingInfoType::StorageTexture: {
- spirv_cross::Bitset flags = compiler.get_decoration_bitset(resource.id);
- DAWN_INVALID_IF(!flags.get(spv::DecorationNonReadable),
- "Read-write storage textures are not supported.");
- info->storageTexture.access = wgpu::StorageTextureAccess::WriteOnly;
-
- spirv_cross::SPIRType::ImageType imageType =
- compiler.get_type(info->base_type_id).image;
- wgpu::TextureFormat storageTextureFormat =
- SpirvImageFormatToTextureFormat(imageType.format);
- DAWN_INVALID_IF(storageTextureFormat == wgpu::TextureFormat::Undefined,
- "Invalid image format declaration on storage image.");
-
- const Format& format = device->GetValidInternalFormat(storageTextureFormat);
- DAWN_INVALID_IF(!format.supportsStorageUsage,
- "The storage texture format (%s) is not supported.",
- storageTextureFormat);
-
- DAWN_INVALID_IF(imageType.ms,
- "Multisampled storage textures aren't supported.");
-
- DAWN_INVALID_IF(imageType.depth,
- "Depth storage textures aren't supported.");
-
- info->storageTexture.format = storageTextureFormat;
- info->storageTexture.viewDimension =
- SpirvDimToTextureViewDimension(imageType.dim, imageType.arrayed);
- break;
- }
- case BindingInfoType::Sampler: {
- info->sampler.isComparison = false;
- break;
- }
- case BindingInfoType::ExternalTexture: {
- return DAWN_FORMAT_VALIDATION_ERROR("External textures are not supported.");
- }
- }
- }
- return {};
- };
-
- std::unique_ptr<BindingInfoArray> resultBindings = std::make_unique<BindingInfoArray>();
- BindingInfoArray* bindings = resultBindings.get();
- DAWN_TRY(ExtractResourcesBinding(device, resources.uniform_buffers, compiler,
- BindingInfoType::Buffer, bindings));
- DAWN_TRY(ExtractResourcesBinding(device, resources.separate_images, compiler,
- BindingInfoType::Texture, bindings));
- DAWN_TRY(ExtractResourcesBinding(device, resources.separate_samplers, compiler,
- BindingInfoType::Sampler, bindings));
- DAWN_TRY(ExtractResourcesBinding(device, resources.storage_buffers, compiler,
- BindingInfoType::Buffer, bindings, true));
- // ReadonlyStorageTexture is used as a tag to do general storage texture handling.
- DAWN_TRY(ExtractResourcesBinding(device, resources.storage_images, compiler,
- BindingInfoType::StorageTexture, resultBindings.get()));
-
- return {std::move(resultBindings)};
- }
-
// static
ResultOrError<Ref<ShaderModule>> ShaderModule::Create(Device* device,
const ShaderModuleDescriptor* descriptor,
@@ -226,38 +70,10 @@
: ShaderModuleBase(device, descriptor) {
}
- // static
- ResultOrError<BindingInfoArrayTable> ShaderModule::ReflectShaderUsingSPIRVCross(
- DeviceBase* device,
- const std::vector<uint32_t>& spirv) {
- BindingInfoArrayTable result;
- spirv_cross::Compiler compiler(spirv);
- for (const spirv_cross::EntryPoint& entryPoint : compiler.get_entry_points_and_stages()) {
- ASSERT(result.count(entryPoint.name) == 0);
-
- SingleShaderStage stage = ExecutionModelToShaderStage(entryPoint.execution_model);
- compiler.set_entry_point(entryPoint.name, entryPoint.execution_model);
-
- std::unique_ptr<BindingInfoArray> bindings;
- DAWN_TRY_ASSIGN(bindings, ExtractSpirvInfo(device, compiler, entryPoint.name, stage));
- result[entryPoint.name] = std::move(bindings);
- }
- return std::move(result);
- }
-
MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult) {
ScopedTintICEHandler scopedICEHandler(GetDevice());
DAWN_TRY(InitializeBase(parseResult));
- // Tint currently does not support emitting GLSL, so when provided a Tint program need to
- // generate SPIRV and SPIRV-Cross reflection data to be used in this backend.
- tint::writer::spirv::Options options;
- options.disable_workgroup_init = GetDevice()->IsToggleEnabled(Toggle::DisableWorkgroupInit);
- auto result = tint::writer::spirv::Generate(GetTintProgram(), options);
- DAWN_INVALID_IF(!result.success, "An error occured while generating SPIR-V: %s.",
- result.error);
-
- DAWN_TRY_ASSIGN(mGLBindings, ReflectShaderUsingSPIRVCross(GetDevice(), result.spirv));
return {};
}
diff --git a/src/dawn/native/opengl/ShaderModuleGL.h b/src/dawn/native/opengl/ShaderModuleGL.h
index 4fd178b..44cd0d4 100644
--- a/src/dawn/native/opengl/ShaderModuleGL.h
+++ b/src/dawn/native/opengl/ShaderModuleGL.h
@@ -63,11 +63,6 @@
ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor);
~ShaderModule() override = default;
MaybeError Initialize(ShaderModuleParseResult* parseResult);
- static ResultOrError<BindingInfoArrayTable> ReflectShaderUsingSPIRVCross(
- DeviceBase* device,
- const std::vector<uint32_t>& spirv);
-
- BindingInfoArrayTable mGLBindings;
};
} // namespace dawn::native::opengl
diff --git a/src/dawn/native/opengl/SpirvUtils.cpp b/src/dawn/native/opengl/SpirvUtils.cpp
deleted file mode 100644
index e1861bb..0000000
--- a/src/dawn/native/opengl/SpirvUtils.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2020 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 "dawn/native/opengl/SpirvUtils.h"
-
-namespace dawn::native {
-
- spv::ExecutionModel ShaderStageToExecutionModel(SingleShaderStage stage) {
- switch (stage) {
- case SingleShaderStage::Vertex:
- return spv::ExecutionModelVertex;
- case SingleShaderStage::Fragment:
- return spv::ExecutionModelFragment;
- case SingleShaderStage::Compute:
- return spv::ExecutionModelGLCompute;
- }
- UNREACHABLE();
- }
-
- SingleShaderStage ExecutionModelToShaderStage(spv::ExecutionModel model) {
- switch (model) {
- case spv::ExecutionModelVertex:
- return SingleShaderStage::Vertex;
- case spv::ExecutionModelFragment:
- return SingleShaderStage::Fragment;
- case spv::ExecutionModelGLCompute:
- return SingleShaderStage::Compute;
- default:
- UNREACHABLE();
- }
- }
-
- wgpu::TextureViewDimension SpirvDimToTextureViewDimension(spv::Dim dim, bool arrayed) {
- switch (dim) {
- case spv::Dim::Dim1D:
- return wgpu::TextureViewDimension::e1D;
- case spv::Dim::Dim2D:
- if (arrayed) {
- return wgpu::TextureViewDimension::e2DArray;
- } else {
- return wgpu::TextureViewDimension::e2D;
- }
- case spv::Dim::Dim3D:
- return wgpu::TextureViewDimension::e3D;
- case spv::Dim::DimCube:
- if (arrayed) {
- return wgpu::TextureViewDimension::CubeArray;
- } else {
- return wgpu::TextureViewDimension::Cube;
- }
- default:
- UNREACHABLE();
- }
- }
-
- wgpu::TextureFormat SpirvImageFormatToTextureFormat(spv::ImageFormat format) {
- switch (format) {
- case spv::ImageFormatR8:
- return wgpu::TextureFormat::R8Unorm;
- case spv::ImageFormatR8Snorm:
- return wgpu::TextureFormat::R8Snorm;
- case spv::ImageFormatR8ui:
- return wgpu::TextureFormat::R8Uint;
- case spv::ImageFormatR8i:
- return wgpu::TextureFormat::R8Sint;
- case spv::ImageFormatR16ui:
- return wgpu::TextureFormat::R16Uint;
- case spv::ImageFormatR16i:
- return wgpu::TextureFormat::R16Sint;
- case spv::ImageFormatR16f:
- return wgpu::TextureFormat::R16Float;
- case spv::ImageFormatRg8:
- return wgpu::TextureFormat::RG8Unorm;
- case spv::ImageFormatRg8Snorm:
- return wgpu::TextureFormat::RG8Snorm;
- case spv::ImageFormatRg8ui:
- return wgpu::TextureFormat::RG8Uint;
- case spv::ImageFormatRg8i:
- return wgpu::TextureFormat::RG8Sint;
- case spv::ImageFormatR32f:
- return wgpu::TextureFormat::R32Float;
- case spv::ImageFormatR32ui:
- return wgpu::TextureFormat::R32Uint;
- case spv::ImageFormatR32i:
- return wgpu::TextureFormat::R32Sint;
- case spv::ImageFormatRg16ui:
- return wgpu::TextureFormat::RG16Uint;
- case spv::ImageFormatRg16i:
- return wgpu::TextureFormat::RG16Sint;
- case spv::ImageFormatRg16f:
- return wgpu::TextureFormat::RG16Float;
- case spv::ImageFormatRgba8:
- return wgpu::TextureFormat::RGBA8Unorm;
- case spv::ImageFormatRgba8Snorm:
- return wgpu::TextureFormat::RGBA8Snorm;
- case spv::ImageFormatRgba8ui:
- return wgpu::TextureFormat::RGBA8Uint;
- case spv::ImageFormatRgba8i:
- return wgpu::TextureFormat::RGBA8Sint;
- case spv::ImageFormatRgb10A2:
- return wgpu::TextureFormat::RGB10A2Unorm;
- case spv::ImageFormatR11fG11fB10f:
- return wgpu::TextureFormat::RG11B10Ufloat;
- case spv::ImageFormatRg32f:
- return wgpu::TextureFormat::RG32Float;
- case spv::ImageFormatRg32ui:
- return wgpu::TextureFormat::RG32Uint;
- case spv::ImageFormatRg32i:
- return wgpu::TextureFormat::RG32Sint;
- case spv::ImageFormatRgba16ui:
- return wgpu::TextureFormat::RGBA16Uint;
- case spv::ImageFormatRgba16i:
- return wgpu::TextureFormat::RGBA16Sint;
- case spv::ImageFormatRgba16f:
- return wgpu::TextureFormat::RGBA16Float;
- case spv::ImageFormatRgba32f:
- return wgpu::TextureFormat::RGBA32Float;
- case spv::ImageFormatRgba32ui:
- return wgpu::TextureFormat::RGBA32Uint;
- case spv::ImageFormatRgba32i:
- return wgpu::TextureFormat::RGBA32Sint;
- default:
- return wgpu::TextureFormat::Undefined;
- }
- }
-
- wgpu::TextureComponentType SpirvBaseTypeToTextureComponentType(
- spirv_cross::SPIRType::BaseType spirvBaseType) {
- switch (spirvBaseType) {
- case spirv_cross::SPIRType::Float:
- return wgpu::TextureComponentType::Float;
- case spirv_cross::SPIRType::Int:
- return wgpu::TextureComponentType::Sint;
- case spirv_cross::SPIRType::UInt:
- return wgpu::TextureComponentType::Uint;
- default:
- UNREACHABLE();
- }
- }
-
- SampleTypeBit SpirvBaseTypeToSampleTypeBit(spirv_cross::SPIRType::BaseType spirvBaseType) {
- switch (spirvBaseType) {
- case spirv_cross::SPIRType::Float:
- return SampleTypeBit::Float | SampleTypeBit::UnfilterableFloat;
- case spirv_cross::SPIRType::Int:
- return SampleTypeBit::Sint;
- case spirv_cross::SPIRType::UInt:
- return SampleTypeBit::Uint;
- default:
- UNREACHABLE();
- }
- }
-
- VertexFormatBaseType SpirvBaseTypeToVertexFormatBaseType(
- spirv_cross::SPIRType::BaseType spirvBaseType) {
- switch (spirvBaseType) {
- case spirv_cross::SPIRType::Float:
- return VertexFormatBaseType::Float;
- case spirv_cross::SPIRType::Int:
- return VertexFormatBaseType::Sint;
- case spirv_cross::SPIRType::UInt:
- return VertexFormatBaseType::Uint;
- default:
- UNREACHABLE();
- }
- }
-
-} // namespace dawn::native
diff --git a/src/dawn/native/opengl/SpirvUtils.h b/src/dawn/native/opengl/SpirvUtils.h
deleted file mode 100644
index 2bdaff5..0000000
--- a/src/dawn/native/opengl/SpirvUtils.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2020 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.
-
-// This file contains utilities to convert from-to spirv.hpp datatypes without polluting other
-// headers with spirv.hpp
-
-#ifndef DAWNNATIVE_OPENGL_SPIRV_UTILS_H_
-#define DAWNNATIVE_OPENGL_SPIRV_UTILS_H_
-
-#include "dawn/native/Format.h"
-#include "dawn/native/PerStage.h"
-#include "dawn/native/VertexFormat.h"
-#include "dawn/native/dawn_platform.h"
-
-#include <spirv_cross.hpp>
-
-namespace dawn::native {
-
- // Returns the spirv_cross equivalent for this shader stage and vice-versa.
- spv::ExecutionModel ShaderStageToExecutionModel(SingleShaderStage stage);
- SingleShaderStage ExecutionModelToShaderStage(spv::ExecutionModel model);
-
- // Returns the texture view dimension for corresponding to (dim, arrayed).
- wgpu::TextureViewDimension SpirvDimToTextureViewDimension(spv::Dim dim, bool arrayed);
-
- // Returns the texture format corresponding to format.
- wgpu::TextureFormat SpirvImageFormatToTextureFormat(spv::ImageFormat format);
-
- // Returns the format "component type" corresponding to the SPIRV base type.
- wgpu::TextureComponentType SpirvBaseTypeToTextureComponentType(
- spirv_cross::SPIRType::BaseType spirvBaseType);
- SampleTypeBit SpirvBaseTypeToSampleTypeBit(spirv_cross::SPIRType::BaseType spirvBaseType);
-
- // Returns the VertexFormatBaseType corresponding to the SPIRV base type.
- VertexFormatBaseType SpirvBaseTypeToVertexFormatBaseType(
- spirv_cross::SPIRType::BaseType spirvBaseType);
-
-} // namespace dawn::native
-
-#endif // DAWNNATIVE_OPENGL_SPIRV_UTILS_H_
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index e8e1d26..7c8619f 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -15,15 +15,6 @@
# Don't build testing in third_party dependencies
set(BUILD_TESTING OFF)
-if (DAWN_REQUIRES_SPIRV_CROSS AND NOT TARGET spirv-cross)
- set(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS ON CACHE BOOL "" FORCE)
- set(SPIRV_CROSS_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
- set(SPIRV_CROSS_SKIP_INSTALL ON CACHE BOOL "" FORCE)
-
- message(STATUS "Dawn: using spirv-cross at ${DAWN_SPIRV_CROSS_DIR}")
- add_subdirectory(${DAWN_SPIRV_CROSS_DIR} "${CMAKE_CURRENT_BINARY_DIR}/spirv-cross")
-endif()
-
if (NOT TARGET SPIRV-Headers)
set(SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE BOOL "" FORCE)
set(SPIRV_HEADERS_SKIP_INSTALL ON CACHE BOOL "" FORCE)
diff --git a/third_party/gn/spirv_cross/BUILD.gn b/third_party/gn/spirv_cross/BUILD.gn
deleted file mode 100644
index e3cfcc3..0000000
--- a/third_party/gn/spirv_cross/BUILD.gn
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2020 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("../../../scripts/dawn_overrides_with_defaults.gni")
-
-import("//build_overrides/build.gni")
-
-# SPIRV_Cross does not have BUILD.gn rules, so implement our own.
-is_msvc = is_win && !is_clang
-
-config("spirv_cross_public") {
- include_dirs = [
- "${dawn_spirv_cross_dir}",
- "${dawn_spirv_cross_dir}/..",
- ]
- defines = [ "SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" ]
-}
-
-config("spirv_cross_internal") {
- if (!is_msvc) {
- cflags_cc = [
- "-Wno-implicit-fallthrough",
- "-Wno-return-type",
- "-Wno-sign-compare",
- ]
- } else {
- # Disable "not all control paths return a value" warning.
- cflags_cc = [ "/wd4715" ]
- }
-}
-
-source_set("spirv_cross") {
- public_configs = [ ":spirv_cross_public" ]
- configs += [ ":spirv_cross_internal" ]
-
- sources = [
- "${dawn_spirv_cross_dir}/GLSL.std.450.h",
- "${dawn_spirv_cross_dir}/spirv.hpp",
- "${dawn_spirv_cross_dir}/spirv_cfg.cpp",
- "${dawn_spirv_cross_dir}/spirv_cfg.hpp",
- "${dawn_spirv_cross_dir}/spirv_common.hpp",
- "${dawn_spirv_cross_dir}/spirv_cross.cpp",
- "${dawn_spirv_cross_dir}/spirv_cross.hpp",
- "${dawn_spirv_cross_dir}/spirv_cross_containers.hpp",
- "${dawn_spirv_cross_dir}/spirv_cross_error_handling.hpp",
- "${dawn_spirv_cross_dir}/spirv_cross_parsed_ir.cpp",
- "${dawn_spirv_cross_dir}/spirv_cross_parsed_ir.hpp",
- "${dawn_spirv_cross_dir}/spirv_glsl.cpp",
- "${dawn_spirv_cross_dir}/spirv_glsl.hpp",
- "${dawn_spirv_cross_dir}/spirv_hlsl.cpp",
- "${dawn_spirv_cross_dir}/spirv_hlsl.hpp",
- "${dawn_spirv_cross_dir}/spirv_msl.cpp",
- "${dawn_spirv_cross_dir}/spirv_msl.hpp",
- "${dawn_spirv_cross_dir}/spirv_parser.cpp",
- "${dawn_spirv_cross_dir}/spirv_parser.hpp",
- "${dawn_spirv_cross_dir}/spirv_reflect.cpp",
- "${dawn_spirv_cross_dir}/spirv_reflect.hpp",
- ]
-}