Avoid redundant creation of ComputePipelineBase in GetCachedComputePipeline
This patch removes a redundant creation of ComputePipelineBase object
in GetCachedComputePipeline(). Instead, we directly compute the blueprint
hash from the uninitialized backend compute pipeline object.
BUG=dawn:529
TEST=dawn_end2end_tests
Change-Id: I9b982664aa140ab385418a202270b9988cfcb9f3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/66221
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
diff --git a/src/dawn_native/ComputePipeline.cpp b/src/dawn_native/ComputePipeline.cpp
index f789235..d79d4a0 100644
--- a/src/dawn_native/ComputePipeline.cpp
+++ b/src/dawn_native/ComputePipeline.cpp
@@ -46,6 +46,7 @@
{{SingleShaderStage::Compute, descriptor->compute.module,
descriptor->compute.entryPoint, descriptor->compute.constantCount,
descriptor->compute.constants}}) {
+ SetContentHash(ComputeContentHash());
}
ComputePipelineBase::ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag)
@@ -59,13 +60,21 @@
}
}
- MaybeError ComputePipelineBase::Initialize() {
- return {};
- }
-
// static
ComputePipelineBase* ComputePipelineBase::MakeError(DeviceBase* device) {
- return new ComputePipelineBase(device, ObjectBase::kError);
+ class ErrorComputePipeline final : public ComputePipelineBase {
+ public:
+ ErrorComputePipeline(DeviceBase* device)
+ : ComputePipelineBase(device, ObjectBase::kError) {
+ }
+
+ MaybeError Initialize() override {
+ UNREACHABLE();
+ return {};
+ }
+ };
+
+ return new ErrorComputePipeline(device);
}
ObjectType ComputePipelineBase::GetType() const {