dawn-cmake/src/inspector/test_inspector_runner.cc
Ryan Harrison dee93c6b9a Handle complex cases in Inspector::GenerateSamplerTargets
This code was implicitly assuming that all resources it was looking
for would be directly referenced at the intrinsic callsite, and not
passed via function parameters.

This was causing a crash in more complex cases.

The inspector code has been updated to handle cases where the
resources are not being directly referenced.

Unneeded calls to GenerateSamplerTargets() are removed.

Utility function GetOriginatingResources() is added to handle walking up
call sites to resolve resources.

Text shader based test runner is added to the Inspector tests to make
expressing complex tests easier.

BUG=tint:967

Change-Id: I2ecb6d57c518003da59f38b261bae4d62ce7e6ac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59340
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-27 15:42:51 +00:00

40 lines
1.2 KiB
C++

// Copyright 2021 The Tint 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 "src/inspector/test_inspector_runner.h"
namespace tint {
namespace inspector {
InspectorRunner::InspectorRunner() = default;
InspectorRunner::~InspectorRunner() = default;
Inspector& InspectorRunner::Initialize(std::string shader) {
if (inspector_) {
return *inspector_;
}
file_ = std::make_unique<Source::File>("test", shader);
program_ = std::make_unique<Program>(reader::wgsl::Parse(file_.get()));
[&]() {
ASSERT_TRUE(program_->IsValid())
<< diag::Formatter().format(program_->Diagnostics());
}();
inspector_ = std::make_unique<Inspector>(program_.get());
return *inspector_;
}
} // namespace inspector
} // namespace tint