1 // Copyright 2017 The Dawn Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef DAWNNATIVE_COMPUTEPIPELINE_H_ 16 #define DAWNNATIVE_COMPUTEPIPELINE_H_ 17 18 #include "dawn_native/Pipeline.h" 19 20 namespace dawn_native { 21 22 class DeviceBase; 23 24 MaybeError ValidateComputePipelineDescriptor(DeviceBase* device, 25 const ComputePipelineDescriptor* descriptor); 26 27 class ComputePipelineBase : public PipelineBase { 28 public: 29 ComputePipelineBase(DeviceBase* device, 30 const ComputePipelineDescriptor* descriptor, 31 bool blueprint = false); 32 ~ComputePipelineBase() override; 33 34 static ComputePipelineBase* MakeError(DeviceBase* device); 35 36 // Functors necessary for the unordered_set<ComputePipelineBase*>-based cache. 37 struct HashFunc { 38 size_t operator()(const ComputePipelineBase* pipeline) const; 39 }; 40 struct EqualityFunc { 41 bool operator()(const ComputePipelineBase* a, const ComputePipelineBase* b) const; 42 }; 43 44 private: 45 ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag); 46 47 // TODO(cwallez@chromium.org): Store a crypto hash of the module instead. 48 Ref<ShaderModuleBase> mModule; 49 std::string mEntryPoint; 50 bool mIsBlueprint = false; 51 }; 52 53 } // namespace dawn_native 54 55 #endif // DAWNNATIVE_COMPUTEPIPELINE_H_ 56