mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-24 00:40:14 +00:00
spirv-fuzz: Fix vector width issue in 'add equation instructions' pass (#3223)
Fixes #3213.
This commit is contained in:
parent
dd3d91691f
commit
1af1df3b23
@ -201,9 +201,12 @@ FuzzerPassAddEquationInstructions::RestrictToVectorWidth(
|
||||
std::vector<opt::Instruction*> result;
|
||||
for (auto& inst : instructions) {
|
||||
auto type = GetIRContext()->get_type_mgr()->GetType(inst->type_id());
|
||||
if ((vector_width == 1 && !type->AsVector()) ||
|
||||
(vector_width > 1 &&
|
||||
type->AsVector()->element_count() == vector_width)) {
|
||||
// Get the vector width of |inst|, which is 1 if |inst| is a scalar and is
|
||||
// otherwise derived from its vector type.
|
||||
uint32_t other_vector_width =
|
||||
type->AsVector() ? type->AsVector()->element_count() : 1;
|
||||
// Keep |inst| if the vector widths match.
|
||||
if (vector_width == other_vector_width) {
|
||||
result.push_back(inst);
|
||||
}
|
||||
}
|
||||
|
@ -1515,6 +1515,44 @@ const std::string kTestShader4 = R"(
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
// The SPIR-V comes from the following GLSL:
|
||||
//
|
||||
// #version 310 es
|
||||
// precision highp float;
|
||||
//
|
||||
// layout(location = 0) out vec4 color;
|
||||
//
|
||||
// void main()
|
||||
// {
|
||||
// color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
// }
|
||||
|
||||
const std::string kTestShader5 = R"(
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %4 "main" %9
|
||||
OpExecutionMode %4 OriginUpperLeft
|
||||
OpSource ESSL 310
|
||||
OpName %4 "main"
|
||||
OpName %9 "color"
|
||||
OpDecorate %9 Location 0
|
||||
%2 = OpTypeVoid
|
||||
%3 = OpTypeFunction %2
|
||||
%6 = OpTypeFloat 32
|
||||
%7 = OpTypeVector %6 4
|
||||
%8 = OpTypePointer Output %7
|
||||
%9 = OpVariable %8 Output
|
||||
%10 = OpConstant %6 1
|
||||
%11 = OpConstant %6 0
|
||||
%12 = OpConstantComposite %7 %10 %11 %11 %10
|
||||
%4 = OpFunction %2 None %3
|
||||
%5 = OpLabel
|
||||
OpStore %9 %12
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
void AddConstantUniformFact(protobufs::FactSequence* facts,
|
||||
uint32_t descriptor_set, uint32_t binding,
|
||||
std::vector<uint32_t>&& indices, uint32_t value) {
|
||||
@ -1552,8 +1590,8 @@ void RunFuzzerAndReplayer(const std::string& shader,
|
||||
ASSERT_TRUE(t.Validate(binary_in));
|
||||
|
||||
std::vector<fuzzerutil::ModuleSupplier> donor_suppliers;
|
||||
for (auto donor :
|
||||
{&kTestShader1, &kTestShader2, &kTestShader3, &kTestShader4}) {
|
||||
for (auto donor : {&kTestShader1, &kTestShader2, &kTestShader3, &kTestShader4,
|
||||
&kTestShader5}) {
|
||||
donor_suppliers.emplace_back([donor]() {
|
||||
return BuildModule(env, kConsoleMessageConsumer, *donor,
|
||||
kFuzzAssembleOption);
|
||||
@ -1636,6 +1674,13 @@ TEST(FuzzerReplayerTest, Miscellaneous4) {
|
||||
RunFuzzerAndReplayer(kTestShader4, facts, 14, kNumFuzzerRuns);
|
||||
}
|
||||
|
||||
TEST(FuzzerReplayerTest, Miscellaneous5) {
|
||||
// Do some fuzzer runs, starting from an initial seed of 29 (seed value chosen
|
||||
// arbitrarily).
|
||||
RunFuzzerAndReplayer(kTestShader5, protobufs::FactSequence(), 29,
|
||||
kNumFuzzerRuns);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace fuzz
|
||||
} // namespace spvtools
|
||||
|
Loading…
Reference in New Issue
Block a user