Make fragment stage optional in RenderPipeline

This CL makes fragment stage optional but still raises a validation
error if set to null in a RenderPipeline.

Bug: dawn:136
Change-Id: Ie900d2e768d251db1e0c4a90738f80b2de15dc2f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9641
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
diff --git a/dawn.json b/dawn.json
index 0e338a7..c4de765 100644
--- a/dawn.json
+++ b/dawn.json
@@ -893,7 +893,7 @@
         "members": [
             {"name": "layout", "type": "pipeline layout"},
             {"name": "vertex stage", "type": "pipeline stage descriptor", "annotation": "const*"},
-            {"name": "fragment stage", "type": "pipeline stage descriptor", "annotation": "const*"},
+            {"name": "fragment stage", "type": "pipeline stage descriptor", "annotation": "const*", "optional": true},
             {"name": "vertex input", "type": "vertex input descriptor", "annotation": "const*"},
             {"name": "primitive topology", "type": "primitive topology"},
             {"name": "rasterization state", "type": "rasterization state descriptor", "annotation": "const*", "optional": true},
diff --git a/src/dawn_native/RenderPipeline.cpp b/src/dawn_native/RenderPipeline.cpp
index db022c7..a9fd5d7 100644
--- a/src/dawn_native/RenderPipeline.cpp
+++ b/src/dawn_native/RenderPipeline.cpp
@@ -271,6 +271,11 @@
             return DAWN_VALIDATION_ERROR("Input state must not be null");
         }
 
+        // TODO(crbug.com/dawn/136): Support vertex-only pipelines.
+        if (descriptor->fragmentStage == nullptr) {
+            return DAWN_VALIDATION_ERROR("Null fragment stage is not supported (yet)");
+        }
+
         std::bitset<kMaxVertexAttributes> attributesSetMask;
         DAWN_TRY(ValidateVertexInputDescriptor(descriptor->vertexInput, &attributesSetMask));
         DAWN_TRY(ValidatePrimitiveTopology(descriptor->primitiveTopology));