mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 05:57:51 +00:00
Remove usages of SPVC
Remove all usages of SPVC from the code and update the fuzzers. Some of the include paths and deps came transitively from spvc, so needed to update build rules. This patch does NOT remove the flags related to spvc usage, they are just no-ops as the moment. After this patch lands I will remove the usage of those flags from the bots, then remove the flags. BUG=dawn:521 Change-Id: I0d7c3e28f79354c78f00c48b6a383b823094a069 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/27900 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
a1758eef07
commit
c35e2ba379
@@ -74,7 +74,10 @@ static_library("dawn_spirv_cross_fuzzer_common") {
|
||||
"DawnSPIRVCrossFuzzer.cpp",
|
||||
"DawnSPIRVCrossFuzzer.h",
|
||||
]
|
||||
public_deps = [ "${dawn_shaderc_dir}:libshaderc_spvc" ]
|
||||
public_deps = [
|
||||
"${dawn_root}/third_party/gn/spirv_cross:spirv_cross",
|
||||
"${dawn_spirv_tools_dir}:spvtools_val",
|
||||
]
|
||||
}
|
||||
|
||||
static_library("dawn_wire_server_fuzzer_common") {
|
||||
@@ -119,21 +122,6 @@ dawn_fuzzer_test("dawn_spirv_cross_msl_fast_fuzzer") {
|
||||
asan_options = [ "allow_user_segv_handler=1" ]
|
||||
}
|
||||
|
||||
dawn_fuzzer_test("dawn_spvc_glsl_fast_fuzzer") {
|
||||
sources = [ "DawnSPVCglslFastFuzzer.cpp" ]
|
||||
deps = [ "${dawn_shaderc_dir}:libshaderc_spvc" ]
|
||||
}
|
||||
|
||||
dawn_fuzzer_test("dawn_spvc_hlsl_fast_fuzzer") {
|
||||
sources = [ "DawnSPVChlslFastFuzzer.cpp" ]
|
||||
deps = [ "${dawn_shaderc_dir}:libshaderc_spvc" ]
|
||||
}
|
||||
|
||||
dawn_fuzzer_test("dawn_spvc_msl_fast_fuzzer") {
|
||||
sources = [ "DawnSPVCmslFastFuzzer.cpp" ]
|
||||
deps = [ "${dawn_shaderc_dir}:libshaderc_spvc" ]
|
||||
}
|
||||
|
||||
dawn_fuzzer_test("dawn_wire_server_and_frontend_fuzzer") {
|
||||
sources = [ "DawnWireServerAndFrontendFuzzer.cpp" ]
|
||||
|
||||
@@ -167,9 +155,6 @@ group("dawn_fuzzers") {
|
||||
":dawn_spirv_cross_glsl_fast_fuzzer",
|
||||
":dawn_spirv_cross_hlsl_fast_fuzzer",
|
||||
":dawn_spirv_cross_msl_fast_fuzzer",
|
||||
":dawn_spvc_glsl_fast_fuzzer",
|
||||
":dawn_spvc_hlsl_fast_fuzzer",
|
||||
":dawn_spvc_msl_fast_fuzzer",
|
||||
":dawn_wire_server_and_frontend_fuzzer",
|
||||
":dawn_wire_server_and_vulkan_backend_fuzzer",
|
||||
]
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
#include <csetjmp>
|
||||
#include <csignal>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <spirv-tools/libspirv.hpp>
|
||||
|
||||
#include "DawnSPIRVCrossFuzzer.h"
|
||||
|
||||
namespace {
|
||||
@@ -26,12 +29,8 @@ namespace {
|
||||
void (*old_signal_handler)(int);
|
||||
|
||||
// Handler to trap signals, so that it doesn't crash the fuzzer when running
|
||||
// the code under test. Currently the
|
||||
// code being fuzzed uses abort() to report errors like bad input instead of
|
||||
// returning an error code. This will be changing in the future.
|
||||
//
|
||||
// TODO(rharrison): Remove all of this signal trapping once SPIRV-Cross has
|
||||
// been changed to not use abort() for reporting errors.
|
||||
// the code under test. The code being fuzzed uses abort() to report errors
|
||||
// like bad input instead of returning an error code.
|
||||
[[noreturn]] static void sigabrt_trap(int sig) {
|
||||
std::longjmp(jump_buffer, 1);
|
||||
}
|
||||
@@ -69,6 +68,16 @@ namespace DawnSPIRVCrossFuzzer {
|
||||
const uint32_t* u32Data = reinterpret_cast<const uint32_t*>(data);
|
||||
std::vector<uint32_t> input(u32Data, u32Data + sizeInU32);
|
||||
|
||||
spvtools::SpirvTools spirvTools(SPV_ENV_VULKAN_1_1);
|
||||
spirvTools.SetMessageConsumer(
|
||||
[](spv_message_level_t, const char*, const spv_position_t&, const char*) {});
|
||||
|
||||
// Dawn is responsible to validating input before it goes into
|
||||
// SPIRV-Cross.
|
||||
if (!spirvTools.Validate(input.data(), input.size())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (input.size() != 0) {
|
||||
task(input);
|
||||
}
|
||||
|
||||
@@ -16,13 +16,9 @@
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "spvc/spvc.hpp"
|
||||
|
||||
namespace DawnSPIRVCrossFuzzer {
|
||||
|
||||
using Task = std::function<int(const std::vector<uint32_t>&)>;
|
||||
using TaskWithOptions =
|
||||
std::function<int(const std::vector<uint32_t>&, shaderc_spvc::CompileOptions)>;
|
||||
|
||||
// Used to wrap code that may fire a SIGABRT. Do not allocate anything local within |exec|, as
|
||||
// it is not guaranteed to return.
|
||||
|
||||
@@ -16,29 +16,25 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <spirv_glsl.hpp>
|
||||
|
||||
#include "DawnSPIRVCrossFuzzer.h"
|
||||
|
||||
namespace {
|
||||
int GLSLFastFuzzTask(const std::vector<uint32_t>& input) {
|
||||
shaderc_spvc::Context context;
|
||||
if (!context.IsValid()) {
|
||||
return 0;
|
||||
}
|
||||
// Values come from ShaderModuleGL.cpp
|
||||
spirv_cross::CompilerGLSL::Options options;
|
||||
options.vertex.flip_vert_y = true;
|
||||
options.vertex.fixup_clipspace = true;
|
||||
#if defined(DAWN_PLATFORM_APPLE)
|
||||
options.version = 410;
|
||||
#else
|
||||
options.version = 440;
|
||||
#endif
|
||||
|
||||
DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&context, &input]() {
|
||||
shaderc_spvc::CompilationResult result;
|
||||
shaderc_spvc::CompileOptions options;
|
||||
options.SetSourceEnvironment(shaderc_target_env_webgpu, shaderc_env_version_webgpu);
|
||||
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
|
||||
|
||||
// Using the options that are used by Dawn, they appear in ShaderModuleGL.cpp
|
||||
options.SetGLSLLanguageVersion(440);
|
||||
options.SetFixupClipspace(true);
|
||||
if (context.InitializeForGlsl(input.data(), input.size(), options) ==
|
||||
shaderc_spvc_status_success) {
|
||||
context.CompileShader(&result);
|
||||
}
|
||||
});
|
||||
spirv_cross::CompilerGLSL compiler(input);
|
||||
compiler.set_common_options(options);
|
||||
compiler.compile();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,40 +16,32 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <spirv_hlsl.hpp>
|
||||
|
||||
#include "DawnSPIRVCrossFuzzer.h"
|
||||
|
||||
namespace {
|
||||
|
||||
int FuzzTask(const std::vector<uint32_t>& input) {
|
||||
shaderc_spvc::Context context;
|
||||
if (!context.IsValid()) {
|
||||
return 0;
|
||||
}
|
||||
// Values come from ShaderModuleD3D12.cpp
|
||||
spirv_cross::CompilerGLSL::Options options_glsl;
|
||||
// Force all uninitialized variables to be 0, otherwise they will fail to compile
|
||||
// by FXC.
|
||||
options_glsl.force_zero_initialized_variables = true;
|
||||
|
||||
DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&context, &input]() {
|
||||
shaderc_spvc::CompilationResult result;
|
||||
shaderc_spvc::CompileOptions options;
|
||||
options.SetSourceEnvironment(shaderc_target_env_webgpu, shaderc_env_version_webgpu);
|
||||
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
|
||||
spirv_cross::CompilerHLSL::Options options_hlsl;
|
||||
options_hlsl.shader_model = 51;
|
||||
options_hlsl.point_coord_compat = true;
|
||||
options_hlsl.point_size_compat = true;
|
||||
options_hlsl.nonwritable_uav_texture_as_srv = true;
|
||||
|
||||
// Using the options that are used by Dawn, they appear in ShaderModuleD3D12.cpp
|
||||
options.SetForceZeroInitializedVariables(true);
|
||||
options.SetHLSLShaderModel(51);
|
||||
// TODO (hao.x.li@intel.com): The HLSLPointCoordCompat and HLSLPointSizeCompat are
|
||||
// required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,
|
||||
// but should be removed once WebGPU requires there is no gl_PointSize builtin.
|
||||
// See https://github.com/gpuweb/gpuweb/issues/332
|
||||
options.SetHLSLPointCoordCompat(true);
|
||||
options.SetHLSLPointSizeCompat(true);
|
||||
if (context.InitializeForHlsl(input.data(), input.size(), options) ==
|
||||
shaderc_spvc_status_success) {
|
||||
context.CompileShader(&result);
|
||||
}
|
||||
});
|
||||
spirv_cross::CompilerHLSL compiler(input);
|
||||
compiler.set_common_options(options_glsl);
|
||||
compiler.set_hlsl_options(options_hlsl);
|
||||
compiler.compile();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||
|
||||
@@ -16,28 +16,21 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <spirv_msl.hpp>
|
||||
|
||||
#include "DawnSPIRVCrossFuzzer.h"
|
||||
|
||||
namespace {
|
||||
|
||||
int FuzzTask(const std::vector<uint32_t>& input) {
|
||||
shaderc_spvc::Context context;
|
||||
if (!context.IsValid()) {
|
||||
return 0;
|
||||
}
|
||||
// Values come from ShaderModuleMTL.mm
|
||||
spirv_cross::CompilerMSL::Options options_msl;
|
||||
options_msl.enable_point_size_builtin = false;
|
||||
options_msl.buffer_size_buffer_index = 30;
|
||||
|
||||
DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&context, &input]() {
|
||||
shaderc_spvc::CompilationResult result;
|
||||
shaderc_spvc::CompileOptions options;
|
||||
options.SetSourceEnvironment(shaderc_target_env_webgpu, shaderc_env_version_webgpu);
|
||||
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
|
||||
|
||||
// Using the options that are used by Dawn, they appear in ShaderModuleMTL.mm
|
||||
if (context.InitializeForMsl(input.data(), input.size(), options) ==
|
||||
shaderc_spvc_status_success) {
|
||||
context.CompileShader(&result);
|
||||
}
|
||||
});
|
||||
spirv_cross::CompilerMSL compiler(input);
|
||||
compiler.set_msl_options(options_msl);
|
||||
compiler.compile();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "spvc/spvc.hpp"
|
||||
|
||||
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
shaderc_spvc::Context context;
|
||||
if (!context.IsValid()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
shaderc_spvc::CompilationResult result;
|
||||
shaderc_spvc::CompileOptions options;
|
||||
options.SetSourceEnvironment(shaderc_target_env_webgpu, shaderc_env_version_webgpu);
|
||||
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
|
||||
// Using the options that are used by Dawn, they appear in ShaderModuleGL.cpp
|
||||
// TODO(sarahM0): double check these option after completion of spvc integration
|
||||
options.SetFlipVertY(true);
|
||||
options.SetFixupClipspace(true);
|
||||
#if defined(DAWN_PLATFORM_APPLE)
|
||||
options.SetGLSLLanguageVersion(410);
|
||||
#else
|
||||
options.SetGLSLLanguageVersion(440);
|
||||
#endif
|
||||
|
||||
size_t sizeInU32 = size / sizeof(uint32_t);
|
||||
const uint32_t* u32Data = reinterpret_cast<const uint32_t*>(data);
|
||||
std::vector<uint32_t> input(u32Data, u32Data + sizeInU32);
|
||||
|
||||
if (input.size() != 0) {
|
||||
if (context.InitializeForGlsl(input.data(), input.size(), options) ==
|
||||
shaderc_spvc_status_success) {
|
||||
context.SetUseSpvcParser(true);
|
||||
context.CompileShader(&result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "spvc/spvc.hpp"
|
||||
|
||||
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
shaderc_spvc::Context context;
|
||||
if (!context.IsValid()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
shaderc_spvc::CompilationResult result;
|
||||
shaderc_spvc::CompileOptions options;
|
||||
options.SetSourceEnvironment(shaderc_target_env_webgpu, shaderc_env_version_webgpu);
|
||||
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
|
||||
|
||||
// Using the options that are used by Dawn, they appear in ShaderModuleD3D12.cpp
|
||||
// TODO(sarahM0): double check these option after completion of spvc integration
|
||||
options.SetHLSLShaderModel(51);
|
||||
// TODO (hao.x.li@intel.com): The HLSLPointCoordCompat and HLSLPointSizeCompat are
|
||||
// required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,
|
||||
// but should be removed once WebGPU requires there is no gl_PointSize builtin.
|
||||
// See https://github.com/gpuweb/gpuweb/issues/332
|
||||
options.SetHLSLPointCoordCompat(true);
|
||||
options.SetHLSLPointSizeCompat(true);
|
||||
|
||||
size_t sizeInU32 = size / sizeof(uint32_t);
|
||||
const uint32_t* u32Data = reinterpret_cast<const uint32_t*>(data);
|
||||
std::vector<uint32_t> input(u32Data, u32Data + sizeInU32);
|
||||
|
||||
if (input.size() != 0) {
|
||||
if (context.InitializeForHlsl(input.data(), input.size(), options) ==
|
||||
shaderc_spvc_status_success) {
|
||||
context.CompileShader(&result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "spvc/spvc.hpp"
|
||||
|
||||
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
shaderc_spvc::Context context;
|
||||
if (!context.IsValid()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
shaderc_spvc::CompilationResult result;
|
||||
shaderc_spvc::CompileOptions options;
|
||||
options.SetSourceEnvironment(shaderc_target_env_webgpu, shaderc_env_version_webgpu);
|
||||
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
|
||||
|
||||
// Using the options that are used by Dawn, they appear in ShaderModuleMTL.mm
|
||||
// TODO(sarahM0): double check these option after completion of spvc integration
|
||||
size_t sizeInU32 = size / sizeof(uint32_t);
|
||||
const uint32_t* u32Data = reinterpret_cast<const uint32_t*>(data);
|
||||
std::vector<uint32_t> input(u32Data, u32Data + sizeInU32);
|
||||
|
||||
if (input.size() != 0) {
|
||||
if (context.InitializeForMsl(input.data(), input.size(), options) ==
|
||||
shaderc_spvc_status_success) {
|
||||
context.CompileShader(&result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user