Fix EntryPointTests WGSL shaders for Tint roll

Should fix Chromium FYI and Dawn CQ.

Followup to https://dawn-review.googlesource.com/c/dawn/+/29521

Change-Id: I62ba98ff234d3aceb6cc429d1e23c28f3a1adcbf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29760
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Kai Ninomiya 2020-10-07 21:54:56 +00:00 committed by Commit Bot service account
parent 4171134daf
commit 6b4a4a85df
2 changed files with 36 additions and 32 deletions

View File

@ -25,19 +25,21 @@ TEST_P(EntryPointTests, FragAndVertexSameModule) {
DAWN_SKIP_TEST_IF(IsVulkan()); DAWN_SKIP_TEST_IF(IsVulkan());
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 { fn vertex_main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0); Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return; return;
} }
entry_point vertex = vertex_main;
[[location 0]] var<out> outColor : vec4<f32>; [[location(0)]] var<out> outColor : vec4<f32>;
[[stage(fragment)]]
fn fragment_main() -> void { fn fragment_main() -> void {
outColor = vec4<f32>(1.0, 0.0, 0.0, 1.0); outColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
return; return;
} }
entry_point fragment = fragment_main;
)"); )");
// Create a point pipeline from the module. // Create a point pipeline from the module.
@ -71,19 +73,21 @@ TEST_P(EntryPointTests, FragAndVertexSameModuleSameName) {
DAWN_SKIP_TEST_IF(IsVulkan()); DAWN_SKIP_TEST_IF(IsVulkan());
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>;
fn vertex_main() -> void {
[[stage(vertex)]]
fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0); Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
return; return;
} }
entry_point vertex as "main" = vertex_main;
[[location 0]] var<out> outColor : vec4<f32>; [[location(0)]] var<out> outColor : vec4<f32>;
fn fragment_main() -> void {
[[stage(fragment)]]
fn main() -> void {
outColor = vec4<f32>(1.0, 0.0, 0.0, 1.0); outColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
return; return;
} }
entry_point fragment as "main" = fragment_main;
)"); )");
// Create a point pipeline from the module. // Create a point pipeline from the module.
@ -118,20 +122,21 @@ TEST_P(EntryPointTests, TwoComputeInModule) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
type Data = [[block]] struct { type Data = [[block]] struct {
[[offset 0]] data : u32; [[offset(0)]] data : u32;
}; };
[[binding 0, set 0]] var<storage_buffer> data : Data; [[binding(0), set(0)]] var<storage_buffer> data : Data;
[[stage(compute)]]
fn write1() -> void { fn write1() -> void {
data.data = 1u; data.data = 1u;
return; return;
} }
[[stage(compute)]]
fn write42() -> void { fn write42() -> void {
data.data = 42u; data.data = 42u;
return; return;
} }
entry_point compute = write1;
entry_point compute = write42;
)"); )");
// Create both pipelines from the module. // Create both pipelines from the module.

View File

@ -32,13 +32,11 @@ class VertexBufferRobustnessTest : public DawnTest {
// viewport. // viewport.
wgpu::ShaderModule CreateVertexModule(const std::string& attributes, wgpu::ShaderModule CreateVertexModule(const std::string& attributes,
const std::string& successExpression) { const std::string& successExpression) {
return utils::CreateShaderModuleFromWGSL(device, (R"( return utils::CreateShaderModuleFromWGSL(device, (attributes + R"(
entry_point vertex as "main" = vtx_main; [[builtin(position)]] var<out> Position : vec4<f32>;
)" + attributes + R"( [[stage(vertex)]]
[[builtin position]] var<out> Position : vec4<f32>; fn main() -> void {
fn vtx_main() -> void {
if ()" + successExpression + R"() { if ()" + successExpression + R"() {
# Success case, move the vertex out of the viewport # Success case, move the vertex out of the viewport
Position = vec4<f32>(-10.0, 0.0, 0.0, 1.0); Position = vec4<f32>(-10.0, 0.0, 0.0, 1.0);
@ -61,9 +59,10 @@ class VertexBufferRobustnessTest : public DawnTest {
bool expectation) { bool expectation) {
wgpu::ShaderModule vsModule = CreateVertexModule(attributes, successExpression); wgpu::ShaderModule vsModule = CreateVertexModule(attributes, successExpression);
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
entry_point fragment as "main" = frag_main; [[location(0)]] var<out> outColor : vec4<f32>;
[[location 0]] var<out> outColor : vec4<f32>;
fn frag_main() -> void { [[stage(fragment)]]
fn main() -> void {
outColor = vec4<f32>(1.0, 1.0, 1.0, 1.0); outColor = vec4<f32>(1.0, 1.0, 1.0, 1.0);
return; return;
} }
@ -111,8 +110,8 @@ TEST_P(VertexBufferRobustnessTest, DetectInvalidValues) {
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
wgpu::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
DoTest("[[location 0]] var<in> a : f32;", "a == 473.0", std::move(vertexState), vertexBuffer, 0, DoTest("[[location(0)]] var<in> a : f32;", "a == 473.0", std::move(vertexState), vertexBuffer,
false); 0, false);
} }
TEST_P(VertexBufferRobustnessTest, FloatClamp) { TEST_P(VertexBufferRobustnessTest, FloatClamp) {
@ -129,8 +128,8 @@ TEST_P(VertexBufferRobustnessTest, FloatClamp) {
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
wgpu::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
DoTest("[[location 0]] var<in> a : f32;", "a == 473.0", std::move(vertexState), vertexBuffer, 4, DoTest("[[location(0)]] var<in> a : f32;", "a == 473.0", std::move(vertexState), vertexBuffer,
true); 4, true);
} }
TEST_P(VertexBufferRobustnessTest, IntClamp) { TEST_P(VertexBufferRobustnessTest, IntClamp) {
@ -147,7 +146,7 @@ TEST_P(VertexBufferRobustnessTest, IntClamp) {
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
wgpu::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
DoTest("[[location 0]] var<in> a : i32;", "a == 473", std::move(vertexState), vertexBuffer, 4, DoTest("[[location(0)]] var<in> a : i32;", "a == 473", std::move(vertexState), vertexBuffer, 4,
true); true);
} }
@ -165,7 +164,7 @@ TEST_P(VertexBufferRobustnessTest, UIntClamp) {
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
wgpu::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
DoTest("[[location 0]] var<in> a : u32;", "a == 473", std::move(vertexState), vertexBuffer, 4, DoTest("[[location(0)]] var<in> a : u32;", "a == 473", std::move(vertexState), vertexBuffer, 4,
true); true);
} }
@ -183,7 +182,7 @@ TEST_P(VertexBufferRobustnessTest, Float2Clamp) {
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
wgpu::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
DoTest("[[location 0]] var<in> a : vec2<f32>;", "a[0] == 473.0 && a[1] == 473.0", DoTest("[[location(0)]] var<in> a : vec2<f32>;", "a[0] == 473.0 && a[1] == 473.0",
std::move(vertexState), vertexBuffer, 8, true); std::move(vertexState), vertexBuffer, 8, true);
} }
@ -201,7 +200,7 @@ TEST_P(VertexBufferRobustnessTest, Float3Clamp) {
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
wgpu::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
DoTest("[[location 0]] var<in> a : vec3<f32>;", DoTest("[[location(0)]] var<in> a : vec3<f32>;",
"a[0] == 473.0 && a[1] == 473.0 && a[2] == 473.0", std::move(vertexState), vertexBuffer, "a[0] == 473.0 && a[1] == 473.0 && a[2] == 473.0", std::move(vertexState), vertexBuffer,
12, true); 12, true);
} }
@ -220,7 +219,7 @@ TEST_P(VertexBufferRobustnessTest, Float4Clamp) {
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), wgpu::Buffer vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
wgpu::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
DoTest("[[location 0]] var<in> a : vec4<f32>;", DoTest("[[location(0)]] var<in> a : vec4<f32>;",
"a[0] == 473.0 && a[1] == 473.0 && a[2] == 473.0 && a[3] == 473.0", "a[0] == 473.0 && a[1] == 473.0 && a[2] == 473.0 && a[3] == 473.0",
std::move(vertexState), vertexBuffer, 16, true); std::move(vertexState), vertexBuffer, 16, true);
} }