Title: [290253] trunk/Source/WebGPU
Revision
290253
Author
mmaxfi...@apple.com
Date
2022-02-21 10:57:52 -0800 (Mon, 21 Feb 2022)

Log Message

[WebGPU] Tracer bullet part 3: Tweak WGSL API
https://bugs.webkit.org/show_bug.cgi?id=236889

Reviewed by Dean Jackson.

- Give SuccessfulCheck a move constructor
- Use UniqueRef instead of std::unique_ptr
- Allow specialization constants to be looked up by name
- Model missing pipeline layouts as absent from the HashMap, rather than using an optional type

* WGSL/WGSL.cpp:
(WGSL::prepare):
(WGSL::SuccessfulCheck::~SuccessfulCheck): Deleted.
* WGSL/WGSL.h:

Modified Paths

Diff

Modified: trunk/Source/WebGPU/ChangeLog (290252 => 290253)


--- trunk/Source/WebGPU/ChangeLog	2022-02-21 18:55:08 UTC (rev 290252)
+++ trunk/Source/WebGPU/ChangeLog	2022-02-21 18:57:52 UTC (rev 290253)
@@ -1,5 +1,22 @@
 2022-02-21  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        [WebGPU] Tracer bullet part 3: Tweak WGSL API
+        https://bugs.webkit.org/show_bug.cgi?id=236889
+
+        Reviewed by Dean Jackson.
+
+        - Give SuccessfulCheck a move constructor
+        - Use UniqueRef instead of std::unique_ptr
+        - Allow specialization constants to be looked up by name
+        - Model missing pipeline layouts as absent from the HashMap, rather than using an optional type
+
+        * WGSL/WGSL.cpp:
+        (WGSL::prepare):
+        (WGSL::SuccessfulCheck::~SuccessfulCheck): Deleted.
+        * WGSL/WGSL.h:
+
+2022-02-21  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         [WebGPU] WebGPU.xcodeproj cannot be opened on Big Sur's Xcode
         https://bugs.webkit.org/show_bug.cgi?id=236982
 

Modified: trunk/Source/WebGPU/WGSL/WGSL.cpp (290252 => 290253)


--- trunk/Source/WebGPU/WGSL/WGSL.cpp	2022-02-21 18:55:08 UTC (rev 290252)
+++ trunk/Source/WebGPU/WGSL/WGSL.cpp	2022-02-21 18:57:52 UTC (rev 290253)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Apple Inc. All rights reserved.
+ * Copyright (c) 2021-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,8 +39,23 @@
     return FailedCheck { { }, { } };
 }
 
-SuccessfulCheck::~SuccessfulCheck()
+SuccessfulCheck::SuccessfulCheck(SuccessfulCheck&&) = default;
+
+SuccessfulCheck::~SuccessfulCheck() = default;
+
+PrepareResult prepare(const AST& ast, const HashMap<String, PipelineLayout>& pipelineLayouts)
 {
+    UNUSED_PARAM(ast);
+    UNUSED_PARAM(pipelineLayouts);
+    return { String(), { } };
 }
 
+PrepareResult prepare(const AST& ast, const String& entryPointName, const std::optional<PipelineLayout>& pipelineLayouts)
+{
+    UNUSED_PARAM(ast);
+    UNUSED_PARAM(entryPointName);
+    UNUSED_PARAM(pipelineLayouts);
+    return { String(), { } };
 }
+
+}

Modified: trunk/Source/WebGPU/WGSL/WGSL.h (290252 => 290253)


--- trunk/Source/WebGPU/WGSL/WGSL.h	2022-02-21 18:55:08 UTC (rev 290252)
+++ trunk/Source/WebGPU/WGSL/WGSL.h	2022-02-21 18:57:52 UTC (rev 290253)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Apple Inc. All rights reserved.
+ * Copyright (c) 2021-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -31,6 +31,7 @@
 #include <variant>
 #include <wtf/HashMap.h>
 #include <wtf/OptionSet.h>
+#include <wtf/UniqueRef.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -57,9 +58,11 @@
 class AST;
 
 struct SuccessfulCheck {
+    SuccessfulCheck() = delete;
+    SuccessfulCheck(SuccessfulCheck&&);
     ~SuccessfulCheck();
     Vector<CompilationMessage> warnings;
-    std::unique_ptr<AST> ast;
+    UniqueRef<AST> ast;
 };
 
 struct FailedCheck {
@@ -193,10 +196,12 @@
 };
 
 struct EntryPointInformation {
+    // FIXME: This can probably be factored better.
     String mangledName;
     std::optional<PipelineLayout> defaultLayout; // If the input PipelineLayout is nullopt, the compiler computes a layout and returns it. https://gpuweb.github.io/gpuweb/#default-pipeline-layout
     HashMap<std::pair<size_t, size_t>, size_t> bufferLengthLocations; // Metal buffer identity -> offset within helper buffer where its size needs to lie
-    Vector<SpecializationConstant> specializationConstants;
+    HashMap<size_t, SpecializationConstant> specializationConstants;
+    HashMap<String, size_t> specializationConstantIndices; // Points into specializationConstantsByIndex
     std::variant<Vertex, Fragment, Compute> typedEntryPoint;
 };
 
@@ -209,7 +214,7 @@
 
 // These are not allowed to fail.
 // All failures must have already been caught in check().
-PrepareResult prepare(const AST&, const HashMap<String, std::optional<PipelineLayout>>&);
+PrepareResult prepare(const AST&, const HashMap<String, PipelineLayout>&);
 PrepareResult prepare(const AST&, const String& entryPointName, const std::optional<PipelineLayout>&);
 
 } // namespace WGSL
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to