• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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_QUERYSET_H_
16 #define DAWNNATIVE_QUERYSET_H_
17 
18 #include "dawn_native/Error.h"
19 #include "dawn_native/Forward.h"
20 #include "dawn_native/ObjectBase.h"
21 
22 #include "dawn_native/dawn_platform.h"
23 
24 namespace dawn_native {
25 
26     MaybeError ValidateQuerySetDescriptor(DeviceBase* device, const QuerySetDescriptor* descriptor);
27 
28     class QuerySetBase : public ApiObjectBase {
29       public:
30         QuerySetBase(DeviceBase* device, const QuerySetDescriptor* descriptor);
31 
32         static QuerySetBase* MakeError(DeviceBase* device);
33 
34         ObjectType GetType() const override;
35 
36         wgpu::QueryType GetQueryType() const;
37         uint32_t GetQueryCount() const;
38         const std::vector<wgpu::PipelineStatisticName>& GetPipelineStatistics() const;
39 
40         const std::vector<bool>& GetQueryAvailability() const;
41         void SetQueryAvailability(uint32_t index, bool available);
42 
43         MaybeError ValidateCanUseInSubmitNow() const;
44 
45         void APIDestroy();
46 
47       protected:
48         QuerySetBase(DeviceBase* device, ObjectBase::ErrorTag tag);
49 
50         // Constructor used only for mocking and testing.
51         QuerySetBase(DeviceBase* device);
52         void DestroyImpl() override;
53 
54         ~QuerySetBase() override;
55 
56       private:
57         MaybeError ValidateDestroy() const;
58 
59         wgpu::QueryType mQueryType;
60         uint32_t mQueryCount;
61         std::vector<wgpu::PipelineStatisticName> mPipelineStatistics;
62 
63         enum class QuerySetState { Unavailable, Available, Destroyed };
64         QuerySetState mState = QuerySetState::Unavailable;
65 
66         // Indicates the available queries on the query set for resolving
67         std::vector<bool> mQueryAvailability;
68     };
69 
70 }  // namespace dawn_native
71 
72 #endif  // DAWNNATIVE_QUERYSET_H_
73