GLSL samples: add empty entry point if needed.

If a WGSL test contains no entry points, add an empty one.
In that case, do not pass its name to the generator, so we
generate code for all functions, so they aren't culled for
reachability.

Add new test results for formerly empty tests.

Bug: tint:1376
Change-Id: Ibf371b943fb273d44712dfcc9dc1b7bb4ab071db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White
2022-01-21 18:40:18 +00:00
committed by Tint LUCI CQ
parent b4cd255c6e
commit 671d9703f0
212 changed files with 4671 additions and 32 deletions

View File

@@ -17,6 +17,7 @@
#include <utility>
#include "src/program_builder.h"
#include "src/transform/add_empty_entry_point.h"
#include "src/transform/add_spirv_block_decoration.h"
#include "src/transform/calculate_array_length.h"
#include "src/transform/canonicalize_entry_point_io.h"
@@ -67,7 +68,7 @@ Output Glsl::Run(const Program* in, const DataMap& inputs) {
// referenced only by phonies from being optimized out. Strictly
// speaking, that optimization isn't incorrect, but it prevents some
// tests (e.g., types/texture/*) from producing useful results.
if (cfg) {
if (cfg && !cfg->entry_point.empty()) {
manager.Add<SingleEntryPoint>();
data.Add<SingleEntryPoint::Config>(cfg->entry_point);
}
@@ -76,6 +77,7 @@ Output Glsl::Run(const Program* in, const DataMap& inputs) {
manager.Add<ExternalTextureTransform>();
manager.Add<PromoteInitializersToConstVar>();
manager.Add<PadArrayElements>();
manager.Add<AddEmptyEntryPoint>();
manager.Add<AddSpirvBlockDecoration>();
// For now, canonicalize to structs for all IO, as in HLSL.
@@ -90,24 +92,11 @@ Output Glsl::Run(const Program* in, const DataMap& inputs) {
ProgramBuilder builder;
CloneContext ctx(&builder, &out.program);
AddEmptyEntryPoint(ctx);
ctx.Clone();
builder.SetTransformApplied(this);
return Output{Program(std::move(builder))};
}
void Glsl::AddEmptyEntryPoint(CloneContext& ctx) const {
for (auto* func : ctx.src->AST().Functions()) {
if (func->IsEntryPoint()) {
return;
}
}
ctx.dst->Func(ctx.dst->Symbols().New("unused_entry_point"), {},
ctx.dst->ty.void_(), {},
{ctx.dst->Stage(ast::PipelineStage::kCompute),
ctx.dst->WorkgroupSize(1)});
}
Glsl::Config::Config(const std::string& ep, bool disable_wi)
: entry_point(ep), disable_workgroup_init(disable_wi) {}
Glsl::Config::Config(const Config&) = default;

View File

@@ -62,10 +62,6 @@ class Glsl : public Castable<Glsl, Transform> {
/// @param data optional extra transform-specific data
/// @returns the transformation result
Output Run(const Program* program, const DataMap& data = {}) override;
private:
/// Add an empty shader entry point if none exist in the module.
void AddEmptyEntryPoint(CloneContext& ctx) const;
};
} // namespace transform