Query API: QuerySet

- Add QuerySet w/o backends implementation.
- Add validation tests

Bug: dawn:434
Change-Id: Id9fed4e42fac464b1254cd2e9cf5337a1d803089
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp
index 01fc874..73bbcf9 100644
--- a/src/dawn_native/Device.cpp
+++ b/src/dawn_native/Device.cpp
@@ -32,6 +32,7 @@
 #include "dawn_native/Instance.h"
 #include "dawn_native/MapRequestTracker.h"
 #include "dawn_native/PipelineLayout.h"
+#include "dawn_native/QuerySet.h"
 #include "dawn_native/Queue.h"
 #include "dawn_native/RenderBundleEncoder.h"
 #include "dawn_native/RenderPipeline.h"
@@ -647,6 +648,15 @@
 
         return result;
     }
+    QuerySetBase* DeviceBase::CreateQuerySet(const QuerySetDescriptor* descriptor) {
+        QuerySetBase* result = nullptr;
+
+        if (ConsumedError(CreateQuerySetInternal(&result, descriptor))) {
+            return QuerySetBase::MakeError(this);
+        }
+
+        return result;
+    }
     QueueBase* DeviceBase::CreateQueue() {
         // TODO(dawn:22): Remove this once users use GetDefaultQueue
         EmitDeprecationWarning(
@@ -884,6 +894,16 @@
         return {};
     }
 
+    MaybeError DeviceBase::CreateQuerySetInternal(QuerySetBase** result,
+                                                  const QuerySetDescriptor* descriptor) {
+        DAWN_TRY(ValidateIsAlive());
+        if (IsValidationEnabled()) {
+            DAWN_TRY(ValidateQuerySetDescriptor(this, descriptor));
+        }
+        DAWN_TRY_ASSIGN(*result, CreateQuerySetImpl(descriptor));
+        return {};
+    }
+
     MaybeError DeviceBase::CreateRenderBundleEncoderInternal(
         RenderBundleEncoder** result,
         const RenderBundleEncoderDescriptor* descriptor) {