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"
14 namespace mozilla::webgpu
{
20 enum class Limit
: uint8_t {
21 MaxTextureDimension1D
,
22 MaxTextureDimension2D
,
23 MaxTextureDimension3D
,
24 MaxTextureArrayLayers
,
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
,
42 MaxVertexBufferArrayStride
,
43 MaxInterStageShaderComponents
,
44 MaxInterStageShaderVariables
,
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
> {
61 const std::unique_ptr
<ffi::WGPULimits
> mFfi
;
63 GPU_DECL_CYCLE_COLLECTION(SupportedLimits
)
64 GPU_DECL_JS_WRAP(SupportedLimits
)
67 auto X() const { return GetLimit(*mFfi, Limit::X); }
69 _(MaxTextureDimension1D
)
70 _(MaxTextureDimension2D
)
71 _(MaxTextureDimension3D
)
72 _(MaxTextureArrayLayers
)
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
)
89 _(MaxVertexAttributes
)
90 _(MaxVertexBufferArrayStride
)
91 _(MaxInterStageShaderComponents
)
92 _(MaxInterStageShaderVariables
)
93 _(MaxColorAttachments
)
94 _(MaxColorAttachmentBytesPerSample
)
95 _(MaxComputeWorkgroupStorageSize
)
96 _(MaxComputeInvocationsPerWorkgroup
)
97 _(MaxComputeWorkgroupSizeX
)
98 _(MaxComputeWorkgroupSizeY
)
99 _(MaxComputeWorkgroupSizeZ
)
100 _(MaxComputeWorkgroupsPerDimension
)
104 SupportedLimits(Adapter
* const aParent
, const ffi::WGPULimits
&);
111 } // namespace mozilla::webgpu
113 #endif // GPU_SupportedLimits_H_