mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 10:51:35 +00:00
Use Tint/WGSL unconditionally
Bug: dawn:706 Change-Id: I102c37e67e7833bb7441ed8a355a4411bd7b9fb9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/45421 Auto-Submit: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
b00de7f8e8
commit
a9439199b7
@ -69,7 +69,6 @@ option(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_META
|
|||||||
option(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON)
|
option(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON)
|
||||||
option(DAWN_ENABLE_OPENGL "Enable compilation of the OpenGL backend" ${ENABLE_OPENGL})
|
option(DAWN_ENABLE_OPENGL "Enable compilation of the OpenGL backend" ${ENABLE_OPENGL})
|
||||||
option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN})
|
option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN})
|
||||||
option(DAWN_ENABLE_WGSL "Enable WGSL support" ON)
|
|
||||||
option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
|
option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
|
||||||
option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
|
option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
|
||||||
|
|
||||||
@ -125,9 +124,6 @@ endif()
|
|||||||
if (DAWN_ENABLE_VULKAN)
|
if (DAWN_ENABLE_VULKAN)
|
||||||
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN")
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN")
|
||||||
endif()
|
endif()
|
||||||
if (DAWN_ENABLE_WGSL)
|
|
||||||
target_compile_definitions(dawn_internal_config INTERFACE "-DDAWN_ENABLE_WGSL=1")
|
|
||||||
endif()
|
|
||||||
if (DAWN_USE_X11)
|
if (DAWN_USE_X11)
|
||||||
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11")
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11")
|
||||||
endif()
|
endif()
|
||||||
|
@ -65,9 +65,6 @@ declare_args() {
|
|||||||
dawn_enable_vulkan = is_linux || is_chromeos || is_win || is_fuchsia ||
|
dawn_enable_vulkan = is_linux || is_chromeos || is_win || is_fuchsia ||
|
||||||
is_android || dawn_use_swiftshader
|
is_android || dawn_use_swiftshader
|
||||||
|
|
||||||
# Enable support WGSL for shaders.
|
|
||||||
dawn_enable_wgsl = true
|
|
||||||
|
|
||||||
# Enable use of reflection compiler in spirv-cross. This is needed
|
# Enable use of reflection compiler in spirv-cross. This is needed
|
||||||
# if performing reflection on systems that the platform language
|
# if performing reflection on systems that the platform language
|
||||||
# shader is SPIR-V, since there isn't an instance of the
|
# shader is SPIR-V, since there isn't an instance of the
|
||||||
|
@ -75,10 +75,6 @@ config("dawn_internal") {
|
|||||||
defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ]
|
defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dawn_enable_wgsl) {
|
|
||||||
defines += [ "DAWN_ENABLE_WGSL" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dawn_use_x11) {
|
if (dawn_use_x11) {
|
||||||
defines += [ "DAWN_USE_X11" ]
|
defines += [ "DAWN_USE_X11" ]
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,7 @@ source_set("dawn_native_sources") {
|
|||||||
"${dawn_root}/third_party/gn/spirv_cross:spirv_cross",
|
"${dawn_root}/third_party/gn/spirv_cross:spirv_cross",
|
||||||
"${dawn_spirv_tools_dir}:spvtools_opt",
|
"${dawn_spirv_tools_dir}:spvtools_opt",
|
||||||
"${dawn_spirv_tools_dir}:spvtools_val",
|
"${dawn_spirv_tools_dir}:spvtools_val",
|
||||||
|
"${dawn_tint_dir}/src:libtint",
|
||||||
]
|
]
|
||||||
defines = []
|
defines = []
|
||||||
libs = []
|
libs = []
|
||||||
@ -625,10 +626,6 @@ source_set("dawn_native_sources") {
|
|||||||
"${dawn_angle_dir}:libGLESv2",
|
"${dawn_angle_dir}:libGLESv2",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dawn_enable_wgsl) {
|
|
||||||
deps += [ "${dawn_tint_dir}/src:libtint" ]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# The static and shared libraries for dawn_native. Most of the files are
|
# The static and shared libraries for dawn_native. Most of the files are
|
||||||
|
@ -25,10 +25,6 @@ if(BUILD_SHARED_LIBS)
|
|||||||
target_compile_definitions(dawn_native PRIVATE "DAWN_NATIVE_SHARED_LIBRARY")
|
target_compile_definitions(dawn_native PRIVATE "DAWN_NATIVE_SHARED_LIBRARY")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DAWN_ENABLE_WGSL)
|
|
||||||
target_link_libraries(dawn_native PRIVATE libtint)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_sources(dawn_native PRIVATE
|
target_sources(dawn_native PRIVATE
|
||||||
"${DAWN_INCLUDE_DIR}/dawn_native/DawnNative.h"
|
"${DAWN_INCLUDE_DIR}/dawn_native/DawnNative.h"
|
||||||
"${DAWN_INCLUDE_DIR}/dawn_native/dawn_native_export.h"
|
"${DAWN_INCLUDE_DIR}/dawn_native/dawn_native_export.h"
|
||||||
@ -169,6 +165,7 @@ target_link_libraries(dawn_native
|
|||||||
PRIVATE dawn_common
|
PRIVATE dawn_common
|
||||||
dawn_platform
|
dawn_platform
|
||||||
dawn_internal_config
|
dawn_internal_config
|
||||||
|
libtint
|
||||||
spirv-cross-core
|
spirv-cross-core
|
||||||
spirv-cross-glsl
|
spirv-cross-glsl
|
||||||
spirv-cross-hlsl
|
spirv-cross-hlsl
|
||||||
|
@ -27,13 +27,11 @@
|
|||||||
#include <spirv-tools/optimizer.hpp>
|
#include <spirv-tools/optimizer.hpp>
|
||||||
#include <spirv_cross.hpp>
|
#include <spirv_cross.hpp>
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// Tint include must be after spirv_cross.hpp, because spirv-cross has its own
|
// Tint include must be after spirv_cross.hpp, because spirv-cross has its own
|
||||||
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
||||||
// is at 3 while spirv-headers is at 4.
|
// is at 3 while spirv-headers is at 4.
|
||||||
#undef SPV_REVISION
|
#undef SPV_REVISION
|
||||||
#include <tint/tint.h>
|
#include <tint/tint.h>
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -48,7 +46,6 @@ namespace dawn_native {
|
|||||||
return ostream.str();
|
return ostream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
tint::transform::VertexFormat ToTintVertexFormat(wgpu::VertexFormat format) {
|
tint::transform::VertexFormat ToTintVertexFormat(wgpu::VertexFormat format) {
|
||||||
format = dawn::NormalizeVertexFormat(format);
|
format = dawn::NormalizeVertexFormat(format);
|
||||||
switch (format) {
|
switch (format) {
|
||||||
@ -191,8 +188,6 @@ namespace dawn_native {
|
|||||||
"Attempted to convert unexpected component type from Tint");
|
"Attempted to convert unexpected component type from Tint");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
MaybeError ValidateSpirv(const uint32_t* code, uint32_t codeSize) {
|
MaybeError ValidateSpirv(const uint32_t* code, uint32_t codeSize) {
|
||||||
spvtools::SpirvTools spirvTools(SPV_ENV_VULKAN_1_1);
|
spvtools::SpirvTools spirvTools(SPV_ENV_VULKAN_1_1);
|
||||||
|
|
||||||
@ -235,7 +230,6 @@ namespace dawn_native {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
ResultOrError<tint::Program> ParseWGSL(const tint::Source::File* file) {
|
ResultOrError<tint::Program> ParseWGSL(const tint::Source::File* file) {
|
||||||
std::ostringstream errorStream;
|
std::ostringstream errorStream;
|
||||||
errorStream << "Tint WGSL reader failure:" << std::endl;
|
errorStream << "Tint WGSL reader failure:" << std::endl;
|
||||||
@ -293,7 +287,6 @@ namespace dawn_native {
|
|||||||
std::vector<uint32_t> spirv = generator.result();
|
std::vector<uint32_t> spirv = generator.result();
|
||||||
return std::move(spirv);
|
return std::move(spirv);
|
||||||
}
|
}
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
std::vector<uint64_t> GetBindGroupMinBufferSizes(
|
std::vector<uint64_t> GetBindGroupMinBufferSizes(
|
||||||
const EntryPointMetadata::BindingGroupInfoMap& shaderBindings,
|
const EntryPointMetadata::BindingGroupInfoMap& shaderBindings,
|
||||||
@ -722,7 +715,6 @@ namespace dawn_native {
|
|||||||
return {std::move(metadata)};
|
return {std::move(metadata)};
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// Currently only partially populated the reflection data, needs to be
|
// Currently only partially populated the reflection data, needs to be
|
||||||
// completed using PopulateMetadataUsingSPIRVCross. In the future, once
|
// completed using PopulateMetadataUsingSPIRVCross. In the future, once
|
||||||
// this function is complete, ReflectShaderUsingSPIRVCross and
|
// this function is complete, ReflectShaderUsingSPIRVCross and
|
||||||
@ -835,7 +827,6 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
// Uses SPIRV-Cross, which is planned for removal, but until
|
// Uses SPIRV-Cross, which is planned for removal, but until
|
||||||
// ReflectShaderUsingTint is completed, will be kept as a
|
// ReflectShaderUsingTint is completed, will be kept as a
|
||||||
@ -860,7 +851,6 @@ namespace dawn_native {
|
|||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// Temporary utility method that allows for polyfilling like behaviour,
|
// Temporary utility method that allows for polyfilling like behaviour,
|
||||||
// specifically data missing from the Tint implementation is filled in
|
// specifically data missing from the Tint implementation is filled in
|
||||||
// using the SPIRV-Cross implementation. Once the Tint implementation is
|
// using the SPIRV-Cross implementation. Once the Tint implementation is
|
||||||
@ -933,7 +923,6 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
@ -965,16 +954,12 @@ namespace dawn_native {
|
|||||||
static_cast<const ShaderModuleSPIRVDescriptor*>(chainedDescriptor);
|
static_cast<const ShaderModuleSPIRVDescriptor*>(chainedDescriptor);
|
||||||
std::vector<uint32_t> spirv(spirvDesc->code, spirvDesc->code + spirvDesc->codeSize);
|
std::vector<uint32_t> spirv(spirvDesc->code, spirvDesc->code + spirvDesc->codeSize);
|
||||||
if (device->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
if (device->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
tint::Program program;
|
tint::Program program;
|
||||||
DAWN_TRY_ASSIGN(program, ParseSPIRV(spirv));
|
DAWN_TRY_ASSIGN(program, ParseSPIRV(spirv));
|
||||||
if (device->IsValidationEnabled()) {
|
if (device->IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateModule(&program));
|
DAWN_TRY(ValidateModule(&program));
|
||||||
}
|
}
|
||||||
parseResult.tintProgram = std::make_unique<tint::Program>(std::move(program));
|
parseResult.tintProgram = std::make_unique<tint::Program>(std::move(program));
|
||||||
#else
|
|
||||||
return DAWN_VALIDATION_ERROR("Using Tint is not enabled in this build.");
|
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
} else {
|
} else {
|
||||||
if (device->IsValidationEnabled()) {
|
if (device->IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateSpirv(spirv.data(), spirv.size()));
|
DAWN_TRY(ValidateSpirv(spirv.data(), spirv.size()));
|
||||||
@ -985,7 +970,6 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case wgpu::SType::ShaderModuleWGSLDescriptor: {
|
case wgpu::SType::ShaderModuleWGSLDescriptor: {
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
const auto* wgslDesc =
|
const auto* wgslDesc =
|
||||||
static_cast<const ShaderModuleWGSLDescriptor*>(chainedDescriptor);
|
static_cast<const ShaderModuleWGSLDescriptor*>(chainedDescriptor);
|
||||||
|
|
||||||
@ -1017,9 +1001,6 @@ namespace dawn_native {
|
|||||||
parseResult.spirv = std::move(spirv);
|
parseResult.spirv = std::move(spirv);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#else
|
|
||||||
return DAWN_VALIDATION_ERROR("Using Tint is not enabled in this build.");
|
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return DAWN_VALIDATION_ERROR("Unsupported sType");
|
return DAWN_VALIDATION_ERROR("Unsupported sType");
|
||||||
@ -1039,7 +1020,6 @@ namespace dawn_native {
|
|||||||
return bufferSizes;
|
return bufferSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
ResultOrError<tint::Program> RunTransforms(tint::transform::Transform* transform,
|
ResultOrError<tint::Program> RunTransforms(tint::transform::Transform* transform,
|
||||||
const tint::Program* program) {
|
const tint::Program* program) {
|
||||||
tint::transform::Transform::Output output = transform->Run(program);
|
tint::transform::Transform::Output output = transform->Run(program);
|
||||||
@ -1077,7 +1057,6 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
return std::make_unique<tint::transform::VertexPulling>(cfg);
|
return std::make_unique<tint::transform::VertexPulling>(cfg);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
MaybeError ValidateCompatibilityWithPipelineLayout(DeviceBase* device,
|
MaybeError ValidateCompatibilityWithPipelineLayout(DeviceBase* device,
|
||||||
const EntryPointMetadata& entryPoint,
|
const EntryPointMetadata& entryPoint,
|
||||||
@ -1167,7 +1146,6 @@ namespace dawn_native {
|
|||||||
return mSpirv;
|
return mSpirv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
const tint::Program* ShaderModuleBase::GetTintProgram() const {
|
const tint::Program* ShaderModuleBase::GetTintProgram() const {
|
||||||
ASSERT(GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator));
|
ASSERT(GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator));
|
||||||
return mTintProgram.get();
|
return mTintProgram.get();
|
||||||
@ -1214,12 +1192,9 @@ namespace dawn_native {
|
|||||||
DAWN_TRY(ValidateSpirv(spirv.data(), spirv.size()));
|
DAWN_TRY(ValidateSpirv(spirv.data(), spirv.size()));
|
||||||
return std::move(spirv);
|
return std::move(spirv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
MaybeError ShaderModuleBase::InitializeBase(ShaderModuleParseResult* parseResult) {
|
MaybeError ShaderModuleBase::InitializeBase(ShaderModuleParseResult* parseResult) {
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
mTintProgram = std::move(parseResult->tintProgram);
|
mTintProgram = std::move(parseResult->tintProgram);
|
||||||
#endif
|
|
||||||
mSpirv = std::move(parseResult->spirv);
|
mSpirv = std::move(parseResult->spirv);
|
||||||
|
|
||||||
// If not using Tint to generate backend code, run the robust buffer access pass now since
|
// If not using Tint to generate backend code, run the robust buffer access pass now since
|
||||||
@ -1231,7 +1206,6 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// We still need the spirv for reflection. Remove this when we use the Tint inspector
|
// We still need the spirv for reflection. Remove this when we use the Tint inspector
|
||||||
// completely.
|
// completely.
|
||||||
std::vector<uint32_t> reflectionSpirv;
|
std::vector<uint32_t> reflectionSpirv;
|
||||||
@ -1242,9 +1216,6 @@ namespace dawn_native {
|
|||||||
DAWN_TRY_ASSIGN(table, ReflectShaderUsingTint(GetDevice(), mTintProgram.get()));
|
DAWN_TRY_ASSIGN(table, ReflectShaderUsingTint(GetDevice(), mTintProgram.get()));
|
||||||
DAWN_TRY(PopulateMetadataUsingSPIRVCross(GetDevice(), reflectionSpirv, &table));
|
DAWN_TRY(PopulateMetadataUsingSPIRVCross(GetDevice(), reflectionSpirv, &table));
|
||||||
mEntryPoints = std::move(table);
|
mEntryPoints = std::move(table);
|
||||||
#else
|
|
||||||
UNREACHABLE();
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
DAWN_TRY_ASSIGN(mEntryPoints, ReflectShaderUsingSPIRVCross(GetDevice(), mSpirv));
|
DAWN_TRY_ASSIGN(mEntryPoints, ReflectShaderUsingSPIRVCross(GetDevice(), mSpirv));
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,7 @@ namespace dawn_native {
|
|||||||
ShaderModuleParseResult(ShaderModuleParseResult&& rhs);
|
ShaderModuleParseResult(ShaderModuleParseResult&& rhs);
|
||||||
ShaderModuleParseResult& operator=(ShaderModuleParseResult&& rhs);
|
ShaderModuleParseResult& operator=(ShaderModuleParseResult&& rhs);
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
std::unique_ptr<tint::Program> tintProgram;
|
std::unique_ptr<tint::Program> tintProgram;
|
||||||
#endif
|
|
||||||
std::vector<uint32_t> spirv;
|
std::vector<uint32_t> spirv;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,7 +73,6 @@ namespace dawn_native {
|
|||||||
|
|
||||||
RequiredBufferSizes ComputeRequiredBufferSizesForLayout(const EntryPointMetadata& entryPoint,
|
RequiredBufferSizes ComputeRequiredBufferSizesForLayout(const EntryPointMetadata& entryPoint,
|
||||||
const PipelineLayoutBase* layout);
|
const PipelineLayoutBase* layout);
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
ResultOrError<tint::Program> RunTransforms(tint::transform::Transform* transform,
|
ResultOrError<tint::Program> RunTransforms(tint::transform::Transform* transform,
|
||||||
const tint::Program* program);
|
const tint::Program* program);
|
||||||
|
|
||||||
@ -83,7 +80,6 @@ namespace dawn_native {
|
|||||||
const VertexStateDescriptor& vertexState,
|
const VertexStateDescriptor& vertexState,
|
||||||
const std::string& entryPoint,
|
const std::string& entryPoint,
|
||||||
BindGroupIndex pullingBufferBindingSet);
|
BindGroupIndex pullingBufferBindingSet);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Contains all the reflection data for a valid (ShaderModule, entryPoint, stage). They are
|
// Contains all the reflection data for a valid (ShaderModule, entryPoint, stage). They are
|
||||||
// stored in the ShaderModuleBase and destroyed only when the shader program is destroyed so
|
// stored in the ShaderModuleBase and destroyed only when the shader program is destroyed so
|
||||||
@ -145,8 +141,6 @@ namespace dawn_native {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<uint32_t>& GetSpirv() const;
|
const std::vector<uint32_t>& GetSpirv() const;
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
const tint::Program* GetTintProgram() const;
|
const tint::Program* GetTintProgram() const;
|
||||||
|
|
||||||
ResultOrError<std::vector<uint32_t>> GeneratePullingSpirv(
|
ResultOrError<std::vector<uint32_t>> GeneratePullingSpirv(
|
||||||
@ -160,7 +154,6 @@ namespace dawn_native {
|
|||||||
const VertexStateDescriptor& vertexState,
|
const VertexStateDescriptor& vertexState,
|
||||||
const std::string& entryPoint,
|
const std::string& entryPoint,
|
||||||
BindGroupIndex pullingBufferBindingSet) const;
|
BindGroupIndex pullingBufferBindingSet) const;
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MaybeError InitializeBase(ShaderModuleParseResult* parseResult);
|
MaybeError InitializeBase(ShaderModuleParseResult* parseResult);
|
||||||
@ -178,9 +171,7 @@ namespace dawn_native {
|
|||||||
// mTintProgram is set iff UseTintGenerator.
|
// mTintProgram is set iff UseTintGenerator.
|
||||||
EntryPointMetadataTable mEntryPoints;
|
EntryPointMetadataTable mEntryPoints;
|
||||||
std::vector<uint32_t> mSpirv;
|
std::vector<uint32_t> mSpirv;
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
std::unique_ptr<tint::Program> mTintProgram;
|
std::unique_ptr<tint::Program> mTintProgram;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
@ -29,13 +29,11 @@
|
|||||||
|
|
||||||
#include <spirv_hlsl.hpp>
|
#include <spirv_hlsl.hpp>
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// Tint include must be after spirv_hlsl.hpp, because spirv-cross has its own
|
// Tint include must be after spirv_hlsl.hpp, because spirv-cross has its own
|
||||||
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
||||||
// is at 3 while spirv-headers is at 4.
|
// is at 3 while spirv-headers is at 4.
|
||||||
#undef SPV_REVISION
|
#undef SPV_REVISION
|
||||||
#include <tint/tint.h>
|
#include <tint/tint.h>
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
@ -197,7 +195,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
FirstOffsetInfo* firstOffsetInfo) const {
|
FirstOffsetInfo* firstOffsetInfo) const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
std::ostringstream errorStream;
|
std::ostringstream errorStream;
|
||||||
errorStream << "Tint HLSL failure:" << std::endl;
|
errorStream << "Tint HLSL failure:" << std::endl;
|
||||||
|
|
||||||
@ -249,9 +246,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return generator.result();
|
return generator.result();
|
||||||
#else
|
|
||||||
return DAWN_VALIDATION_ERROR("Using Tint to generate HLSL is not supported.");
|
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<std::string> ShaderModule::TranslateToHLSLWithSPIRVCross(
|
ResultOrError<std::string> ShaderModule::TranslateToHLSLWithSPIRVCross(
|
||||||
|
@ -22,13 +22,11 @@
|
|||||||
|
|
||||||
#include <spirv_msl.hpp>
|
#include <spirv_msl.hpp>
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// Tint include must be after spirv_msl.hpp, because spirv-cross has its own
|
// Tint include must be after spirv_msl.hpp, because spirv-cross has its own
|
||||||
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
||||||
// is at 3 while spirv-headers is at 4.
|
// is at 3 while spirv-headers is at 4.
|
||||||
#undef SPV_REVISION
|
#undef SPV_REVISION
|
||||||
#include <tint/tint.h>
|
#include <tint/tint.h>
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -60,7 +58,6 @@ namespace dawn_native { namespace metal {
|
|||||||
const RenderPipeline* renderPipeline,
|
const RenderPipeline* renderPipeline,
|
||||||
std::string* remappedEntryPointName,
|
std::string* remappedEntryPointName,
|
||||||
bool* needsStorageBufferLength) {
|
bool* needsStorageBufferLength) {
|
||||||
#if DAWN_ENABLE_WGSL
|
|
||||||
// TODO(crbug.com/tint/256): Set this accordingly if arrayLength(..) is used.
|
// TODO(crbug.com/tint/256): Set this accordingly if arrayLength(..) is used.
|
||||||
*needsStorageBufferLength = false;
|
*needsStorageBufferLength = false;
|
||||||
|
|
||||||
@ -113,9 +110,6 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
std::string msl = generator.result();
|
std::string msl = generator.result();
|
||||||
return std::move(msl);
|
return std::move(msl);
|
||||||
#else
|
|
||||||
UNREACHABLE();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<std::string> ShaderModule::TranslateToMSLWithSPIRVCross(
|
ResultOrError<std::string> ShaderModule::TranslateToMSLWithSPIRVCross(
|
||||||
@ -129,7 +123,6 @@ namespace dawn_native { namespace metal {
|
|||||||
const std::vector<uint32_t>* spirv = &GetSpirv();
|
const std::vector<uint32_t>* spirv = &GetSpirv();
|
||||||
spv::ExecutionModel executionModel = ShaderStageToExecutionModel(stage);
|
spv::ExecutionModel executionModel = ShaderStageToExecutionModel(stage);
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
std::vector<uint32_t> pullingSpirv;
|
std::vector<uint32_t> pullingSpirv;
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::MetalEnableVertexPulling) &&
|
if (GetDevice()->IsToggleEnabled(Toggle::MetalEnableVertexPulling) &&
|
||||||
stage == SingleShaderStage::Vertex) {
|
stage == SingleShaderStage::Vertex) {
|
||||||
@ -146,7 +139,6 @@ namespace dawn_native { namespace metal {
|
|||||||
}
|
}
|
||||||
spirv = &pullingSpirv;
|
spirv = &pullingSpirv;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// If these options are changed, the values in DawnSPIRVCrossMSLFastFuzzer.cpp need to
|
// If these options are changed, the values in DawnSPIRVCrossMSLFastFuzzer.cpp need to
|
||||||
// be updated.
|
// be updated.
|
||||||
@ -202,7 +194,6 @@ namespace dawn_native { namespace metal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// Add vertex buffers bound as storage buffers
|
// Add vertex buffers bound as storage buffers
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::MetalEnableVertexPulling) &&
|
if (GetDevice()->IsToggleEnabled(Toggle::MetalEnableVertexPulling) &&
|
||||||
stage == SingleShaderStage::Vertex) {
|
stage == SingleShaderStage::Vertex) {
|
||||||
@ -219,7 +210,6 @@ namespace dawn_native { namespace metal {
|
|||||||
compiler.add_msl_resource_binding(mslBinding);
|
compiler.add_msl_resource_binding(mslBinding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// SPIRV-Cross also supports re-ordering attributes but it seems to do the correct thing
|
// SPIRV-Cross also supports re-ordering attributes but it seems to do the correct thing
|
||||||
// by default.
|
// by default.
|
||||||
|
@ -23,13 +23,11 @@
|
|||||||
|
|
||||||
#include <spirv_glsl.hpp>
|
#include <spirv_glsl.hpp>
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// Tint include must be after spirv_glsl.hpp, because spirv-cross has its own
|
// 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
|
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
||||||
// is at 3 while spirv-headers is at 4.
|
// is at 3 while spirv-headers is at 4.
|
||||||
#undef SPV_REVISION
|
#undef SPV_REVISION
|
||||||
#include <tint/tint.h>
|
#include <tint/tint.h>
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -80,7 +78,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
|
|
||||||
MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult) {
|
MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult) {
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
std::ostringstream errorStream;
|
std::ostringstream errorStream;
|
||||||
errorStream << "Tint SPIR-V (for GLSL) writer failure:" << std::endl;
|
errorStream << "Tint SPIR-V (for GLSL) writer failure:" << std::endl;
|
||||||
|
|
||||||
@ -107,9 +104,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
transformedParseResult.spirv = mSpirv;
|
transformedParseResult.spirv = mSpirv;
|
||||||
|
|
||||||
DAWN_TRY(InitializeBase(&transformedParseResult));
|
DAWN_TRY(InitializeBase(&transformedParseResult));
|
||||||
#else
|
|
||||||
UNREACHABLE();
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
DAWN_TRY(InitializeBase(parseResult));
|
DAWN_TRY(InitializeBase(parseResult));
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,11 @@
|
|||||||
|
|
||||||
#include <spirv_cross.hpp>
|
#include <spirv_cross.hpp>
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
// Tint include must be after spirv_hlsl.hpp, because spirv-cross has its own
|
// Tint include must be after spirv_hlsl.hpp, because spirv-cross has its own
|
||||||
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
// version of spirv_headers. We also need to undef SPV_REVISION because SPIRV-Cross
|
||||||
// is at 3 while spirv-headers is at 4.
|
// is at 3 while spirv-headers is at 4.
|
||||||
#undef SPV_REVISION
|
#undef SPV_REVISION
|
||||||
#include <tint/tint.h>
|
#include <tint/tint.h>
|
||||||
#endif // DAWN_ENABLE_WGSL
|
|
||||||
|
|
||||||
namespace dawn_native { namespace vulkan {
|
namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
@ -51,7 +49,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
const std::vector<uint32_t>* spirvPtr;
|
const std::vector<uint32_t>* spirvPtr;
|
||||||
|
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) {
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
std::ostringstream errorStream;
|
std::ostringstream errorStream;
|
||||||
errorStream << "Tint SPIR-V writer failure:" << std::endl;
|
errorStream << "Tint SPIR-V writer failure:" << std::endl;
|
||||||
|
|
||||||
@ -79,9 +76,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
transformedParseResult.spirv = spirv;
|
transformedParseResult.spirv = spirv;
|
||||||
|
|
||||||
DAWN_TRY(InitializeBase(&transformedParseResult));
|
DAWN_TRY(InitializeBase(&transformedParseResult));
|
||||||
#else
|
|
||||||
UNREACHABLE();
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
DAWN_TRY(InitializeBase(parseResult));
|
DAWN_TRY(InitializeBase(parseResult));
|
||||||
spirvPtr = &GetSpirv();
|
spirvPtr = &GetSpirv();
|
||||||
|
@ -337,6 +337,7 @@ source_set("dawn_end2end_tests_sources") {
|
|||||||
"end2end/TextureSubresourceTests.cpp",
|
"end2end/TextureSubresourceTests.cpp",
|
||||||
"end2end/TextureViewTests.cpp",
|
"end2end/TextureViewTests.cpp",
|
||||||
"end2end/TextureZeroInitTests.cpp",
|
"end2end/TextureZeroInitTests.cpp",
|
||||||
|
"end2end/VertexBufferRobustnessTests.cpp",
|
||||||
"end2end/VertexFormatTests.cpp",
|
"end2end/VertexFormatTests.cpp",
|
||||||
"end2end/VertexStateTests.cpp",
|
"end2end/VertexStateTests.cpp",
|
||||||
"end2end/ViewportOrientationTests.cpp",
|
"end2end/ViewportOrientationTests.cpp",
|
||||||
@ -368,10 +369,6 @@ source_set("dawn_end2end_tests_sources") {
|
|||||||
frameworks = [ "IOSurface.framework" ]
|
frameworks = [ "IOSurface.framework" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dawn_enable_wgsl) {
|
|
||||||
sources += [ "end2end/VertexBufferRobustnessTests.cpp" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dawn_enable_opengl) {
|
if (dawn_enable_opengl) {
|
||||||
assert(dawn_supports_glfw_for_windowing)
|
assert(dawn_supports_glfw_for_windowing)
|
||||||
}
|
}
|
||||||
|
@ -788,14 +788,6 @@ bool DawnTestBase::IsBackendValidationEnabled() const {
|
|||||||
return gTestEnv->GetBackendValidationLevel() != dawn_native::BackendValidationLevel::Disabled;
|
return gTestEnv->GetBackendValidationLevel() != dawn_native::BackendValidationLevel::Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::HasWGSL() const {
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DawnTestBase::IsAsan() const {
|
bool DawnTestBase::IsAsan() const {
|
||||||
#if defined(ADDRESS_SANITIZER)
|
#if defined(ADDRESS_SANITIZER)
|
||||||
return true;
|
return true;
|
||||||
|
@ -281,7 +281,6 @@ class DawnTestBase {
|
|||||||
|
|
||||||
bool UsesWire() const;
|
bool UsesWire() const;
|
||||||
bool IsBackendValidationEnabled() const;
|
bool IsBackendValidationEnabled() const;
|
||||||
bool HasWGSL() const;
|
|
||||||
|
|
||||||
bool IsAsan() const;
|
bool IsAsan() const;
|
||||||
|
|
||||||
|
@ -555,8 +555,6 @@ TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) {
|
|||||||
|
|
||||||
// Test that the entryPoint names must be present for the correct stage in the shader module.
|
// Test that the entryPoint names must be present for the correct stage in the shader module.
|
||||||
TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
|
TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
|
||||||
DAWN_SKIP_TEST_IF(!HasWGSL());
|
|
||||||
|
|
||||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
[[builtin(position)]] var<out> position : vec4<f32>;
|
[[builtin(position)]] var<out> position : vec4<f32>;
|
||||||
[[stage(vertex)]] fn vertex_main() -> void {
|
[[stage(vertex)]] fn vertex_main() -> void {
|
||||||
@ -607,8 +605,6 @@ TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
|
|||||||
|
|
||||||
// Test that vertex attrib validation is for the correct entryPoint
|
// Test that vertex attrib validation is for the correct entryPoint
|
||||||
TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
|
TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
|
||||||
DAWN_SKIP_TEST_IF(!HasWGSL());
|
|
||||||
|
|
||||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
[[builtin(position)]] var<out> position : vec4<f32>;
|
[[builtin(position)]] var<out> position : vec4<f32>;
|
||||||
[[location(0)]] var<in> attrib0 : vec4<f32>;
|
[[location(0)]] var<in> attrib0 : vec4<f32>;
|
||||||
@ -655,8 +651,6 @@ TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
|
|||||||
|
|
||||||
// Test that fragment output validation is for the correct entryPoint
|
// Test that fragment output validation is for the correct entryPoint
|
||||||
TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
|
TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
|
||||||
DAWN_SKIP_TEST_IF(!HasWGSL());
|
|
||||||
|
|
||||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
[[location(0)]] var<out> colorFloat : vec4<f32>;
|
[[location(0)]] var<out> colorFloat : vec4<f32>;
|
||||||
[[location(0)]] var<out> colorUint : vec4<u32>;
|
[[location(0)]] var<out> colorUint : vec4<u32>;
|
||||||
@ -697,8 +691,6 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
|
|||||||
// Test that fragment output validation is for the correct entryPoint
|
// Test that fragment output validation is for the correct entryPoint
|
||||||
// TODO(dawn:216): Re-enable when we correctly reflect which bindings are used for an entryPoint.
|
// TODO(dawn:216): Re-enable when we correctly reflect which bindings are used for an entryPoint.
|
||||||
TEST_F(RenderPipelineValidationTest, DISABLED_BindingsFromCorrectEntryPoint) {
|
TEST_F(RenderPipelineValidationTest, DISABLED_BindingsFromCorrectEntryPoint) {
|
||||||
DAWN_SKIP_TEST_IF(!HasWGSL());
|
|
||||||
|
|
||||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
[[block]] struct Uniforms {
|
[[block]] struct Uniforms {
|
||||||
data : vec4<f32>;
|
data : vec4<f32>;
|
||||||
|
@ -148,14 +148,6 @@ void ValidationTest::WaitForAllOperations(const wgpu::Device& device) {
|
|||||||
FlushWire();
|
FlushWire();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValidationTest::HasWGSL() const {
|
|
||||||
#ifdef DAWN_ENABLE_WGSL
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValidationTest::HasToggleEnabled(const char* toggle) const {
|
bool ValidationTest::HasToggleEnabled(const char* toggle) const {
|
||||||
auto toggles = dawn_native::GetTogglesUsed(backendDevice);
|
auto toggles = dawn_native::GetTogglesUsed(backendDevice);
|
||||||
return std::find_if(toggles.begin(), toggles.end(), [toggle](const char* name) {
|
return std::find_if(toggles.begin(), toggles.end(), [toggle](const char* name) {
|
||||||
|
@ -92,7 +92,6 @@ class ValidationTest : public testing::Test {
|
|||||||
wgpu::RenderPassColorAttachmentDescriptor mColorAttachment;
|
wgpu::RenderPassColorAttachmentDescriptor mColorAttachment;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool HasWGSL() const;
|
|
||||||
bool HasToggleEnabled(const char* toggle) const;
|
bool HasToggleEnabled(const char* toggle) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
2
third_party/CMakeLists.txt
vendored
2
third_party/CMakeLists.txt
vendored
@ -78,12 +78,10 @@ if (DAWN_BUILD_EXAMPLES)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (DAWN_ENABLE_WGSL)
|
|
||||||
if (NOT TARGET libtint)
|
if (NOT TARGET libtint)
|
||||||
message(STATUS "Dawn: using Tint at ${DAWN_TINT_DIR}")
|
message(STATUS "Dawn: using Tint at ${DAWN_TINT_DIR}")
|
||||||
add_subdirectory(${DAWN_TINT_DIR})
|
add_subdirectory(${DAWN_TINT_DIR})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
# Header-only library for khrplatform.h
|
# Header-only library for khrplatform.h
|
||||||
add_library(dawn_khronos_platform INTERFACE)
|
add_library(dawn_khronos_platform INTERFACE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user