Fix Emulated OOB Index In Primitive Restart Tests

Recognizes an OOB vertex index to show consistent behavior when trying
to emulate an OOB index across backends.

Bug: dawn:575
Change-Id: Ie06d6706614843c75c217f7b3b144dc25996cd0b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/34924
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
diff --git a/src/tests/end2end/IndexFormatTests.cpp b/src/tests/end2end/IndexFormatTests.cpp
index b9953e1..4bcc5e3 100644
--- a/src/tests/end2end/IndexFormatTests.cpp
+++ b/src/tests/end2end/IndexFormatTests.cpp
@@ -34,9 +34,15 @@
         wgpu::PrimitiveTopology primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip) {
         wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
             [[location(0)]] var<in> pos : vec4<f32>;
+            [[builtin(vertex_idx)]] var<in> idx : u32;
             [[builtin(position)]] var<out> Position : vec4<f32>;
             [[stage(vertex)]] fn main() -> void {
-                Position = pos;
+                # 0xFFFFFFFE is a designated invalid index used by some tests.
+                if (idx == 0xFFFFFFFEu) {
+                    Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
+                } else {
+                    Position = pos;
+                }
             })");
 
         wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
@@ -287,13 +293,6 @@
 // Same as the above test, but uses an OOB index to emulate primitive restart being disabled,
 // causing point C to be written to.
 TEST_P(TriangleStripPrimitiveRestartTests, Uint32WithoutPrimitiveRestart) {
-    // TODO: Re-enable for all backends after robust vertex access is implemented.
-    // The behavior of OOB indexes is not strictly defined on non-D3D12 platforms.
-    DAWN_SKIP_TEST_IF(!IsD3D12());
-    // OOB indexes should return a (0,0,0,1) vertex in D3D12, however this does not occur on Intel
-    // GPUs, so we must skip this test on Intel for now.
-    DAWN_SKIP_TEST_IF(IsIntel() && IsD3D12());
-
     wgpu::RenderPipeline pipeline = MakeTestPipeline(wgpu::IndexFormat::Uint32);
     wgpu::Buffer indexBuffer =
         utils::CreateBufferFromData<uint32_t>(device, wgpu::BufferUsage::Index,
@@ -419,13 +418,6 @@
 // Same as the above test, but uses an OOB index to emulate primitive restart being disabled,
 // causing point A to be written to.
 TEST_P(LineStripPrimitiveRestartTests, Uint32WithoutPrimitiveRestart) {
-    // TODO: Re-enable for all backends after robust vertex access is implemented.
-    // The behavior of OOB indexes is not strictly defined on non-D3D12 platforms.
-    DAWN_SKIP_TEST_IF(!IsD3D12());
-    // OOB indexes should return a (0,0,0,1) vertex in D3D12, however this does not occur on Intel
-    // GPUs, so we must skip this test on Intel for now.
-    DAWN_SKIP_TEST_IF(IsIntel() && IsD3D12());
-
     wgpu::RenderPipeline pipeline =
         MakeTestPipeline(wgpu::IndexFormat::Uint32, wgpu::PrimitiveTopology::LineStrip);