wgsl: Fixes for new validation failures

Values of array and matrix can now only be indexed by a constant value.
Dynamic indexing requires the value to be held in memory.

See: https://github.com/gpuweb/gpuweb/issues/1782

Bug: tint:867
Change-Id: I2b9ad6e40fc8121e7aca3a71c190639b39b0b862
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/54652
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-06-17 11:25:09 +00:00 committed by Dawn LUCI CQ
parent dcb82432fb
commit 36edf8d850
32 changed files with 103 additions and 111 deletions

View File

@ -36,23 +36,23 @@ void init() {
swapChainFormat = static_cast<WGPUTextureFormat>(GetPreferredSwapChainTextureFormat());
wgpuSwapChainConfigure(swapchain, swapChainFormat, WGPUTextureUsage_RenderAttachment, 640, 480);
const char* vs =
"let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n"
" vec2<f32>( 0.0, 0.5),\n"
" vec2<f32>(-0.5, -0.5),\n"
" vec2<f32>( 0.5, -0.5)\n"
");\n"
"[[stage(vertex)]] fn main(\n"
" [[builtin(vertex_index)]] VertexIndex : u32\n"
") -> [[builtin(position)]] vec4<f32> {\n"
" return vec4<f32>(pos[VertexIndex], 0.0, 1.0);\n"
"}\n";
const char* vs = R"(
[[stage(vertex)]] fn main(
[[builtin(vertex_index)]] VertexIndex : u32
) -> [[builtin(position)]] vec4<f32> {
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>( 0.0, 0.5),
vec2<f32>(-0.5, -0.5),
vec2<f32>( 0.5, -0.5)
);
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})";
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
const char* fs =
"[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {\n"
" return vec4<f32>(1.0, 0.0, 0.0, 1.0);\n"
"}\n";
const char* fs = R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
})";
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).Release();
{

View File

@ -313,13 +313,13 @@ int main(int argc, const char* argv[]) {
// The hacky pipeline to render a triangle.
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32)
-> [[builtin(position)]] vec4<f32> {
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>( 0.0, 0.5),
vec2<f32>(-0.5, -0.5),
vec2<f32>( 0.5, -0.5)
);
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32)
-> [[builtin(position)]] vec4<f32> {
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(

View File

@ -40,11 +40,6 @@ namespace dawn_native {
};
[[binding(0), group(0)]] var<uniform> uniforms : Uniforms;
let texcoord : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-0.5, 0.0),
vec2<f32>( 1.5, 0.0),
vec2<f32>( 0.5, 2.0));
struct VertexOutputs {
[[location(0)]] texcoords : vec2<f32>;
[[builtin(position)]] position : vec4<f32>;
@ -53,6 +48,11 @@ namespace dawn_native {
[[stage(vertex)]] fn main(
[[builtin(vertex_index)]] VertexIndex : u32
) -> VertexOutputs {
var texcoord : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-0.5, 0.0),
vec2<f32>( 1.5, 0.0),
vec2<f32>( 0.5, 2.0));
var output : VertexOutputs;
output.position = vec4<f32>((texcoord[VertexIndex] * 2.0 - vec2<f32>(1.0, 1.0)), 0.0, 1.0);

View File

@ -1197,7 +1197,7 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 3.0, -1.0),
vec2<f32>(-1.0, 3.0));

View File

@ -48,7 +48,7 @@ class BindGroupTests : public DawnTest {
return utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0));
@ -165,7 +165,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0));
@ -242,7 +242,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0));
@ -353,7 +353,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0));
@ -939,7 +939,7 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0));
@ -1091,7 +1091,7 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0));

View File

@ -26,16 +26,15 @@ class ClipSpaceTest : public DawnTest {
// 1. The depth value of the top-left one is >= 0.5
// 2. The depth value of the bottom-right one is <= 0.5
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
let pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
var pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>(
vec3<f32>(-1.0, 1.0, 1.0),
vec3<f32>(-1.0, -1.0, 0.5),
vec3<f32>( 1.0, 1.0, 0.5),
vec3<f32>( 1.0, 1.0, 0.5),
vec3<f32>(-1.0, -1.0, 0.5),
vec3<f32>( 1.0, -1.0, 0.0));
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
return vec4<f32>(pos[VertexIndex], 1.0);
})");

View File

@ -37,7 +37,7 @@ class ColorStateTest : public DawnTest {
vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0),
vec2<f32>(3.0, -1.0),
vec2<f32>(-1.0, 3.0));

View File

@ -147,7 +147,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-3.0, 1.0),
vec2<f32>( 3.0, 1.0),
vec2<f32>( 0.0, -2.0)

View File

@ -26,16 +26,15 @@ class CullingTest : public DawnTest {
// 1. The top-left one is counterclockwise (CCW)
// 2. The bottom-right one is clockwise (CW)
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, 0.0),
vec2<f32>( 0.0, 1.0),
vec2<f32>( 0.0, -1.0),
vec2<f32>( 1.0, 0.0),
vec2<f32>( 1.0, -1.0));
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");

View File

@ -238,7 +238,7 @@ namespace {
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>(1.0, -1.0),

View File

@ -38,7 +38,7 @@ class DepthBiasTests : public DawnTest {
vertexSource = R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>(-1.0, 1.0),
@ -54,7 +54,7 @@ class DepthBiasTests : public DawnTest {
vertexSource = R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>(
var pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>(
vec3<f32>(-1.0, -1.0, 0.0),
vec3<f32>( 1.0, -1.0, 0.0),
vec3<f32>(-1.0, 1.0, 0.5),

View File

@ -31,7 +31,7 @@ class DepthStencilCopyTests : public DawnTest {
mVertexModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 0.0, -1.0),
vec2<f32>(-1.0, 0.0),

View File

@ -64,7 +64,7 @@ class DepthStencilStateTest : public DawnTest {
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0), // front-facing

View File

@ -96,7 +96,7 @@ class DynamicBufferOffsetTests : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 0.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 0.0, 1.0));

View File

@ -64,13 +64,11 @@ TEST_P(ExternalTextureTests, CreateExternalTextureSuccess) {
TEST_P(ExternalTextureTests, SampleExternalTexture) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main([[builtin(vertex_idx)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
vec4<f32>(-1.0, 1.0, 0.0, 1.0),
vec4<f32>(-1.0, -1.0, 0.0, 1.0),
vec4<f32>(1.0, 1.0, 0.0, 1.0)
);
return positions[VertexIndex];
})");

View File

@ -255,7 +255,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-2.0, -2.0),
vec2<f32>(-2.0, 2.0),
vec2<f32>( 2.0, -2.0),
@ -263,7 +263,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
vec2<f32>( 2.0, -2.0),
vec2<f32>( 2.0, 2.0));
let texCoord : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var texCoord : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(0.0, 0.0),
vec2<f32>(0.0, 1.0),
vec2<f32>(1.0, 0.0),

View File

@ -225,7 +225,7 @@ class MultisampledRenderingTest : public DawnTest {
const char* vs = R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>( 1.0, -1.0)
@ -237,7 +237,7 @@ class MultisampledRenderingTest : public DawnTest {
const char* vsFlipped = R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0)

View File

@ -83,7 +83,7 @@ class OcclusionQueryTests : public QueryTests {
vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0));

View File

@ -79,7 +79,7 @@ class RenderPassLoadOpTests : public DawnTest {
const char* vsSource = R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>( 0.0, -1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 0.0, 1.0),

View File

@ -29,7 +29,7 @@ class RenderPassTest : public DawnTest {
mVSModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>(-1.0, -1.0));

View File

@ -57,7 +57,7 @@ class SamplerTest : public DawnTest {
auto vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-2.0, -2.0),
vec2<f32>(-2.0, 2.0),
vec2<f32>( 2.0, -2.0),

View File

@ -21,16 +21,15 @@ class ScissorTest : public DawnTest {
protected:
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0));
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
return vec4<f32>(pos[VertexIndex], 0.5, 1.0);
})");

View File

@ -101,7 +101,7 @@ TEST_P(ShaderTests, WGSLParamIO) {
std::string vertexShader = R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>( 0.0, -1.0));

View File

@ -145,7 +145,7 @@ class TextureFormatTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-3.0, -1.0),
vec2<f32>( 3.0, -1.0),
vec2<f32>( 0.0, 2.0));

View File

@ -52,7 +52,7 @@ class TextureSubresourceTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0));
@ -89,7 +89,7 @@ class TextureSubresourceTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, 1.0),

View File

@ -69,14 +69,14 @@ namespace {
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
var output : VertexOut;
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-2., -2.),
vec2<f32>(-2., 2.),
vec2<f32>( 2., -2.),
vec2<f32>(-2., 2.),
vec2<f32>( 2., -2.),
vec2<f32>( 2., 2.));
let texCoord : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
var texCoord : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(0., 0.),
vec2<f32>(0., 1.),
vec2<f32>(1., 0.),

View File

@ -83,7 +83,9 @@ class TextureZeroInitTest : public DawnTest {
}
wgpu::ShaderModule CreateBasicVertexShaderForTest(float depth = 0.f) {
std::string source = R"(
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
@ -91,9 +93,6 @@ class TextureZeroInitTest : public DawnTest {
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0)
);
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
return vec4<f32>(pos[VertexIndex], )" +
std::to_string(depth) + R"(, 1.0);
})";

View File

@ -266,7 +266,7 @@ class VertexFormatTest : public DawnTest {
[[stage(vertex)]]
fn main(input : VertexIn) -> VertexOut {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 2.0, 0.0),
vec2<f32>( 0.0, 2.0));

View File

@ -96,7 +96,7 @@ class VertexStateTest : public DawnTest {
// Hard code the triangle in the shader so that we don't have to add a vertex input for it.
// Also this places the triangle in the grid based on its VertexID and InstanceID
vs << " let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n"
vs << " var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n"
" vec2<f32>(0.5, 1.0), vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 0.0));\n";
vs << " var offset : vec2<f32> = vec2<f32>(f32(input.VertexIndex / 3u), "
"f32(input.InstanceIndex));\n";

View File

@ -23,16 +23,15 @@ class ViewportTest : public DawnTest {
DawnTest::SetUp();
mQuadVS = utils::CreateShaderModule(device, R"(
let pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
var pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0));
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
@ -93,13 +92,12 @@ class ViewportTest : public DawnTest {
// Create a pipeline drawing 3 points at depth 1.0, 0.5 and 0.0.
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
let points : array<vec3<f32>, 3> = array<vec3<f32>, 3>(
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
var points : array<vec3<f32>, 3> = array<vec3<f32>, 3>(
vec3<f32>(-0.9, 0.0, 1.0),
vec3<f32>( 0.0, 0.0, 0.5),
vec3<f32>( 0.9, 0.0, 0.0));
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
return vec4<f32>(points[VertexIndex], 1.0);
})");
pipelineDesc.cFragment.module = mQuadFS;

View File

@ -44,7 +44,7 @@ class D3D12DescriptorHeapTests : public DawnTest {
[[stage(vertex)]] fn main(
[[builtin(vertex_index)]] VertexIndex : u32
) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0)
@ -785,7 +785,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
[[stage(vertex)]] fn main(
[[builtin(vertex_index)]] VertexIndex : u32
) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0)

View File

@ -342,7 +342,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
[[stage(vertex)]] fn main(
[[builtin(vertex_index)]] VertexIndex : u32
) -> [[builtin(position)]] vec4<f32> {
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0)