Bug 1857841 - pt 3. Add a new page kind named "fresh" r=glandium
[gecko.git] / dom / webgpu / SupportedLimits.h
blob934feb9e2ead79cf1a021e9b1aa1c75f1e2c0dcf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GPU_SupportedLimits_H_
7 #define GPU_SupportedLimits_H_
9 #include "nsWrapperCache.h"
10 #include "ObjectModel.h"
12 #include <memory>
14 namespace mozilla::webgpu {
15 namespace ffi {
16 struct WGPULimits;
18 class Adapter;
20 enum class Limit : uint8_t {
21 MaxTextureDimension1D,
22 MaxTextureDimension2D,
23 MaxTextureDimension3D,
24 MaxTextureArrayLayers,
25 MaxBindGroups,
26 MaxBindGroupsPlusVertexBuffers,
27 MaxBindingsPerBindGroup,
28 MaxDynamicUniformBuffersPerPipelineLayout,
29 MaxDynamicStorageBuffersPerPipelineLayout,
30 MaxSampledTexturesPerShaderStage,
31 MaxSamplersPerShaderStage,
32 MaxStorageBuffersPerShaderStage,
33 MaxStorageTexturesPerShaderStage,
34 MaxUniformBuffersPerShaderStage,
35 MaxUniformBufferBindingSize,
36 MaxStorageBufferBindingSize,
37 MinUniformBufferOffsetAlignment,
38 MinStorageBufferOffsetAlignment,
39 MaxVertexBuffers,
40 MaxBufferSize,
41 MaxVertexAttributes,
42 MaxVertexBufferArrayStride,
43 MaxInterStageShaderComponents,
44 MaxInterStageShaderVariables,
45 MaxColorAttachments,
46 MaxColorAttachmentBytesPerSample,
47 MaxComputeWorkgroupStorageSize,
48 MaxComputeInvocationsPerWorkgroup,
49 MaxComputeWorkgroupSizeX,
50 MaxComputeWorkgroupSizeY,
51 MaxComputeWorkgroupSizeZ,
52 MaxComputeWorkgroupsPerDimension,
53 _LAST = MaxComputeWorkgroupsPerDimension,
56 uint64_t GetLimit(const ffi::WGPULimits&, Limit);
57 void SetLimit(ffi::WGPULimits*, Limit, double);
59 class SupportedLimits final : public nsWrapperCache, public ChildOf<Adapter> {
60 public:
61 const std::unique_ptr<ffi::WGPULimits> mFfi;
63 GPU_DECL_CYCLE_COLLECTION(SupportedLimits)
64 GPU_DECL_JS_WRAP(SupportedLimits)
66 #define _(X) \
67 auto X() const { return GetLimit(*mFfi, Limit::X); }
69 _(MaxTextureDimension1D)
70 _(MaxTextureDimension2D)
71 _(MaxTextureDimension3D)
72 _(MaxTextureArrayLayers)
73 _(MaxBindGroups)
74 _(MaxBindGroupsPlusVertexBuffers)
75 _(MaxBindingsPerBindGroup)
76 _(MaxDynamicUniformBuffersPerPipelineLayout)
77 _(MaxDynamicStorageBuffersPerPipelineLayout)
78 _(MaxSampledTexturesPerShaderStage)
79 _(MaxSamplersPerShaderStage)
80 _(MaxStorageBuffersPerShaderStage)
81 _(MaxStorageTexturesPerShaderStage)
82 _(MaxUniformBuffersPerShaderStage)
83 _(MaxUniformBufferBindingSize)
84 _(MaxStorageBufferBindingSize)
85 _(MinUniformBufferOffsetAlignment)
86 _(MinStorageBufferOffsetAlignment)
87 _(MaxVertexBuffers)
88 _(MaxBufferSize)
89 _(MaxVertexAttributes)
90 _(MaxVertexBufferArrayStride)
91 _(MaxInterStageShaderComponents)
92 _(MaxInterStageShaderVariables)
93 _(MaxColorAttachments)
94 _(MaxColorAttachmentBytesPerSample)
95 _(MaxComputeWorkgroupStorageSize)
96 _(MaxComputeInvocationsPerWorkgroup)
97 _(MaxComputeWorkgroupSizeX)
98 _(MaxComputeWorkgroupSizeY)
99 _(MaxComputeWorkgroupSizeZ)
100 _(MaxComputeWorkgroupsPerDimension)
102 #undef _
104 SupportedLimits(Adapter* const aParent, const ffi::WGPULimits&);
106 private:
107 ~SupportedLimits();
108 void Cleanup() {}
111 } // namespace mozilla::webgpu
113 #endif // GPU_SupportedLimits_H_