Skip to content

Commit 00ac3ac

Browse files
committed
update common errors
1 parent 4e36458 commit 00ac3ac

16 files changed

+233
-244
lines changed

src/common/command_buffers/gpu/gpu_adapter.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace commandbuffers
1111
{
1212
class GPUInstanceBase;
1313
class GPUPhysicalDeviceBase;
14+
struct GPUDeviceDescriptor;
1415

1516
class GPUAdapterInfo
1617
{

src/common/command_buffers/gpu/gpu_base.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ using namespace std;
66

77
namespace commandbuffers
88
{
9+
bool GPUExtent2D::operator==(const GPUExtent2D &rhs) const
10+
{
11+
const auto &lhs = std::tie(width, height);
12+
return lhs == std::tie(rhs.width, rhs.height);
13+
}
14+
15+
bool GPUExtent3D::operator==(const GPUExtent3D &rhs) const
16+
{
17+
const auto &lhs = std::tie(width, height, depthOrArrayLayers);
18+
return lhs == std::tie(rhs.width,
19+
rhs.height,
20+
rhs.depthOrArrayLayers);
21+
}
22+
923
//
1024
// ErrorMonad Implementation
1125
//
@@ -76,7 +90,7 @@ namespace commandbuffers
7690

7791
GPUInstanceBase *GPUObject::instance() const
7892
{
79-
return device_->instance();
93+
return device_->getInstance();
8094
}
8195

8296
shared_ptr<GPUDeviceBase> GPUObject::device() const
@@ -90,7 +104,7 @@ namespace commandbuffers
90104

91105
GPUHandle::GPUHandle(shared_ptr<GPUDeviceBase> device, string_view label)
92106
: GPUObject(device)
93-
, id_(Ids.get())
107+
, id(Ids.get())
94108
, label_(string(label))
95109
{
96110
}
@@ -99,7 +113,7 @@ namespace commandbuffers
99113
ErrorTag tag,
100114
string_view label)
101115
: GPUObject(device, tag)
102-
, id_(Ids.get())
116+
, id(Ids.get())
103117
, label_(string(label))
104118
{
105119
}
@@ -108,14 +122,14 @@ namespace commandbuffers
108122
DelayedInitializationTag tag,
109123
string_view label)
110124
: GPUObject(device, tag)
111-
, id_(Ids.get())
125+
, id(Ids.get())
112126
, label_(string(label))
113127
{
114128
}
115129

116130
GPUHandle::GPUHandle(shared_ptr<GPUDeviceBase> device, LabelNotImplementedTag tag)
117131
: GPUObject(device)
118-
, id_(Ids.get())
132+
, id(Ids.get())
119133
{
120134
}
121135

src/common/command_buffers/gpu/gpu_base.hpp

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,47 @@ namespace commandbuffers
4747
using GPUBindGroupIndex = uint32_t;
4848
constexpr GPUBindGroupIndex kMaxBindGroupsTyped = GPUBindGroupIndex(gpu_constants::kMaxBindGroups);
4949

50+
struct GPUExtent2D
51+
{
52+
uint32_t width;
53+
uint32_t height;
54+
55+
// Equality operators, mostly for testing. Note that this tests
56+
// strict pointer-pointer equality if the struct contains member pointers.
57+
bool operator==(const GPUExtent2D &rhs) const;
58+
};
59+
60+
struct GPUExtent3D
61+
{
62+
uint32_t width;
63+
uint32_t height = 1;
64+
uint32_t depthOrArrayLayers = 1;
65+
66+
// Equality operators, mostly for testing. Note that this tests
67+
// strict pointer-pointer equality if the struct contains member pointers.
68+
bool operator==(const GPUExtent3D &rhs) const;
69+
};
70+
71+
enum class GPUComponentSwizzle : uint32_t
72+
{
73+
kUndefined,
74+
kZero,
75+
kOne,
76+
kR,
77+
kG,
78+
kB,
79+
kA,
80+
};
81+
82+
enum class GPUCompositeAlphaMode : uint32_t
83+
{
84+
kAuto,
85+
kOpaque,
86+
kPremultiplied,
87+
kUnpremultiplied,
88+
kInherit,
89+
};
90+
5091
enum class GPUHandleType : uint32_t
5192
{
5293
kAdapter,
@@ -135,6 +176,29 @@ namespace commandbuffers
135176
kComparison,
136177
};
137178

179+
enum class GPUTextureAspect : uint32_t
180+
{
181+
kUndefined,
182+
kAll,
183+
kStencilOnly,
184+
kDepthOnly,
185+
kPlane0Only,
186+
kPlane1Only,
187+
kPlane2Only,
188+
};
189+
190+
enum class GPUTextureUsage : uint64_t
191+
{
192+
kNone,
193+
kCopySrc,
194+
kCopyDst,
195+
kTextureBinding,
196+
kStorageBinding,
197+
kRenderAttachment,
198+
kTransientAttachment,
199+
kStorageAttachment,
200+
};
201+
138202
enum class GPUTextureSampleType : uint32_t
139203
{
140204
kBindingNotUsed,
@@ -146,6 +210,14 @@ namespace commandbuffers
146210
kUint,
147211
};
148212

213+
enum class GPUTextureDimension : uint32_t
214+
{
215+
kUndefined,
216+
k1D,
217+
k2D,
218+
k3D,
219+
};
220+
149221
enum class GPUTextureViewDimension : uint32_t
150222
{
151223
kUndefined,
@@ -277,6 +349,14 @@ namespace commandbuffers
277349
kExternal,
278350
};
279351

352+
struct GPUTextureComponentSwizzle
353+
{
354+
GPUComponentSwizzle r = GPUComponentSwizzle::kUndefined;
355+
GPUComponentSwizzle g = GPUComponentSwizzle::kUndefined;
356+
GPUComponentSwizzle b = GPUComponentSwizzle::kUndefined;
357+
GPUComponentSwizzle a = GPUComponentSwizzle::kUndefined;
358+
};
359+
280360
enum class GPUStorageTextureAccess : uint32_t
281361
{
282362
kBindingNotUsed,
@@ -435,8 +515,10 @@ namespace commandbuffers
435515
void setLabel(std::string label);
436516
const std::string &getLabel() const;
437517

518+
public:
519+
const GPUIdentifier id;
520+
438521
private:
439522
std::string label_ = "";
440-
const GPUIdentifier id_;
441523
};
442524
}

src/common/command_buffers/gpu/gpu_bind_group_layout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace commandbuffers
2525
}
2626

2727
bool GPUBindGroupLayoutBase::equal(const GPUBindGroupLayoutBase *other,
28-
bool excludePipelineCompatibiltyToken = false) const
28+
bool excludePipelineCompatibiltyToken) const
2929
{
3030
return getInternalBindGroupLayout() == other->getInternalBindGroupLayout();
3131
}

src/common/command_buffers/gpu/gpu_command_buffer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#include <common/command_buffers/gpu/gpu_command_buffer.hpp>
2+
#include <common/command_buffers/gpu/gpu_command_encoder.hpp>
23

34
using namespace std;
45

56
namespace commandbuffers
67
{
7-
GPUCommandBufferBase::GPUCommandBufferBase(GPUCommandEncoderBase *encoder,
8+
GPUCommandBufferBase::GPUCommandBufferBase(GPUCommandEncoder *encoder,
89
const GPUCommandBufferDescriptor *descriptor)
910
: GPUHandle(encoder->device(), descriptor->label)
1011
{
@@ -27,12 +28,12 @@ namespace commandbuffers
2728
encoder_label_ = move(encoderLabel);
2829
}
2930

30-
const GPUCommandBufferResourceUsage &GPUCommandBufferBase::getResourceUsages() const
31+
const gpu::CommandBufferResourceUsage &GPUCommandBufferBase::getResourceUsages() const
3132
{
3233
return resource_usages_;
3334
}
3435

35-
const vector<GPUIndirectDrawMetadata> &GPUCommandBufferBase::getIndirectDrawMetadata()
36+
const vector<gpu::IndirectDrawMetadata> &GPUCommandBufferBase::getIndirectDrawMetadata()
3637
{
3738
return indirect_draw_metadata_;
3839
}

src/common/command_buffers/gpu/gpu_command_buffer.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
#include <common/command_buffers/gpu/gpu_buffer.hpp>
1010
#include <common/command_buffers/gpu/gpu_pipeline.hpp>
1111
#include <common/command_buffers/gpu/gpu_commands.hpp>
12-
#include <common/command_buffers/gpu/gpu_command_encoder.hpp>
1312
#include <common/command_buffers/gpu/command_allocator.hpp>
1413
#include <common/command_buffers/gpu/indirect_draw_metadata.hpp>
1514
#include <common/command_buffers/gpu/pass_resource_usage.hpp>
1615

1716
namespace commandbuffers
1817
{
18+
class GPUCommandEncoder;
1919
struct GPUCommandBufferDescriptor
2020
{
2121
std::string_view label;
@@ -27,7 +27,7 @@ namespace commandbuffers
2727
friend class GPURenderPassEncoderBase;
2828

2929
public:
30-
GPUCommandBufferBase(GPUCommandEncoderBase *encoder,
30+
GPUCommandBufferBase(GPUCommandEncoder *encoder,
3131
const GPUCommandBufferDescriptor *descriptor);
3232
virtual ~GPUCommandBufferBase() = default;
3333

@@ -39,8 +39,8 @@ namespace commandbuffers
3939
const std::string &getEncoderLabel() const;
4040
void setEncoderLabel(std::string encoderLabel);
4141

42-
const GPUCommandBufferResourceUsage &getResourceUsages() const;
43-
const std::vector<GPUIndirectDrawMetadata> &getIndirectDrawMetadata();
42+
const gpu::CommandBufferResourceUsage &getResourceUsages() const;
43+
const std::vector<gpu::IndirectDrawMetadata> &getIndirectDrawMetadata();
4444

4545
template <typename F>
4646
auto useCommands(F func) -> auto
@@ -58,8 +58,8 @@ namespace commandbuffers
5858
GPUHandle::ErrorTag tag,
5959
std::string_view label);
6060

61-
GPUCommandBufferResourceUsage resource_usages_;
62-
std::vector<GPUIndirectDrawMetadata> indirect_draw_metadata_;
61+
gpu::CommandBufferResourceUsage resource_usages_;
62+
std::vector<gpu::IndirectDrawMetadata> indirect_draw_metadata_;
6363
std::string encoder_label_;
6464
};
6565
}

src/common/command_buffers/gpu/gpu_command_encoder.hpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
#include <memory>
44
#include <string_view>
55

6-
#include "./gpu_base.hpp"
7-
#include "./gpu_command_buffer.hpp"
8-
#include "./gpu_pass_encoder_base.hpp"
9-
#include "./gpu_renderpass_encoder.hpp"
6+
#include <common/command_buffers/gpu/gpu_base.hpp>
7+
#include <common/command_buffers/gpu/gpu_command_buffer.hpp>
8+
#include <common/command_buffers/gpu/gpu_pass_encoder_base.hpp>
9+
#include <common/command_buffers/gpu/gpu_renderpass_encoder.hpp>
10+
#include <common/command_buffers/gpu/encoding_context.hpp>
1011

1112
namespace commandbuffers
1213
{
@@ -24,17 +25,15 @@ namespace commandbuffers
2425
class GPUCommandEncoder final : public GPUHandle
2526
{
2627
public:
27-
virtual ~GPUCommandEncoder() = default;
28-
2928
GPUHandleType type() const override
3029
{
3130
return GPUHandleType::kCommandEncoder;
3231
}
3332

3433
public:
3534
// TODO(yorkie): begineComputePass
36-
virtual GPURenderPassEncoderBase beginRenderPass(GPURenderPassDescriptor &) = 0;
37-
virtual std::unique_ptr<GPUCommandBufferBase> finish(std::optional<std::string> label = std::nullopt) const = 0;
35+
GPURenderPassEncoderBase beginRenderPass(GPURenderPassDescriptor &);
36+
std::unique_ptr<GPUCommandBufferBase> finish(std::optional<std::string> label = std::nullopt) const;
3837

3938
private:
4039
GPUCommandEncoder(std::shared_ptr<GPUDeviceBase> device, const GPUCommandEncoderDescriptor &descriptor);
@@ -44,7 +43,7 @@ namespace commandbuffers
4443

4544
bool validateFinish() const;
4645

47-
GPUEncodingContext encoding_context_;
46+
gpu::EncodingContext encoding_context_;
4847
std::unordered_set<GPUBufferBase *> top_level_buffers_;
4948
std::unordered_set<GPUTextureBase *> top_level_textures_;
5049
// std::unordered_set<GPUQuerySetBase *> used_query_sets_;

src/common/command_buffers/gpu/gpu_constants.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@
2929

3030
#include <cstdint>
3131

32+
#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (UINT32_MAX)
33+
#define WGPU_COPY_STRIDE_UNDEFINED (UINT32_MAX)
34+
#define WGPU_DEPTH_CLEAR_VALUE_UNDEFINED (NAN)
35+
#define WGPU_DEPTH_SLICE_UNDEFINED (UINT32_MAX)
36+
#define WGPU_LIMIT_U32_UNDEFINED (UINT32_MAX)
37+
#define WGPU_LIMIT_U64_UNDEFINED (UINT64_MAX)
38+
#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (UINT32_MAX)
39+
#define WGPU_QUERY_SET_INDEX_UNDEFINED (UINT32_MAX)
40+
#define WGPU_STRLEN (SIZE_MAX)
41+
#define WGPU_WHOLE_MAP_SIZE (SIZE_MAX)
42+
#define WGPU_WHOLE_SIZE (UINT64_MAX)
43+
3244
namespace commandbuffers::gpu_constants
3345
{
3446
static constexpr uint32_t kMaxBindGroups = 4u;
@@ -43,4 +55,16 @@ namespace commandbuffers::gpu_constants
4355
static constexpr uint32_t kQueryResolveAlignment = 256u;
4456
static constexpr uint32_t kMaxInterStageShaderVariables = 16u;
4557
static constexpr uint64_t kAssumedMaxBufferSize = 0x80000000u; // Use 2 GB when the limit is unavailable
58+
59+
static constexpr uint32_t kArrayLayerCountUndefined = WGPU_ARRAY_LAYER_COUNT_UNDEFINED;
60+
static constexpr uint32_t kCopyStrideUndefined = WGPU_COPY_STRIDE_UNDEFINED;
61+
static constexpr float kDepthClearValueUndefined = std::numeric_limits<float>::quiet_NaN();
62+
static constexpr uint32_t kDepthSliceUndefined = WGPU_DEPTH_SLICE_UNDEFINED;
63+
static constexpr uint32_t kLimitU32Undefined = WGPU_LIMIT_U32_UNDEFINED;
64+
static constexpr uint64_t kLimitU64Undefined = WGPU_LIMIT_U64_UNDEFINED;
65+
static constexpr uint32_t kMipLevelCountUndefined = WGPU_MIP_LEVEL_COUNT_UNDEFINED;
66+
static constexpr uint32_t kQuerySetIndexUndefined = WGPU_QUERY_SET_INDEX_UNDEFINED;
67+
static constexpr size_t kStrlen = WGPU_STRLEN;
68+
static constexpr size_t kWholeMapSize = WGPU_WHOLE_MAP_SIZE;
69+
static constexpr uint64_t kWholeSize = WGPU_WHOLE_SIZE;
4670
};

src/common/command_buffers/gpu/gpu_device.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace commandbuffers
2424
GPUSupportedLimits *requiredLimits = nullptr;
2525
};
2626

27-
class GPUDeviceBase : public GPUHandle
27+
class GPUDeviceBase
2828
{
2929
public:
3030
GPUDeviceBase(GPUAdapterBase *adapter,

src/common/command_buffers/gpu/gpu_instance.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ using namespace std;
44

55
namespace commandbuffers
66
{
7-
unique_ptr<GPUInstanceBase> GPUInstanceBase::Create(const GPUInstanceDescriptor *descriptor)
7+
unique_ptr<GPUInstanceBase, GPUInstanceBase::Deleter> GPUInstanceBase::Create(const GPUInstanceDescriptor *descriptor)
88
{
99
static constexpr GPUInstanceDescriptor kDefaultDesc = {};
1010
if (descriptor == nullptr)
1111
{
1212
descriptor = &kDefaultDesc;
1313
}
1414

15-
auto instance = make_unique<GPUInstanceBase>();
15+
auto instance = unique_ptr<GPUInstanceBase, Deleter>(new GPUInstanceBase());
1616
instance->initialize(*descriptor);
1717
return instance;
1818
}

0 commit comments

Comments
 (0)