1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
gpu / command_buffer / common / webgpu_cmd_format_test_autogen.h [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is auto-generated from
// gpu/command_buffer/build_webgpu_cmd_buffer.py
// It's formatted by clang-format using chromium coding style:
// clang-format -i -style=chromium filename
// DO NOT EDIT!
// This file contains unit tests for webgpu commands
// It is included by webgpu_cmd_format_test.cc
#ifndef GPU_COMMAND_BUFFER_COMMON_WEBGPU_CMD_FORMAT_TEST_AUTOGEN_H_
#define GPU_COMMAND_BUFFER_COMMON_WEBGPU_CMD_FORMAT_TEST_AUTOGEN_H_
TEST_F(WebGPUFormatTest, DawnCommands) {
cmds::DawnCommands& cmd = *GetBufferAs<cmds::DawnCommands>();
void* next_cmd =
cmd.Set(&cmd, static_cast<uint32_t>(11), static_cast<uint32_t>(12),
static_cast<uint32_t>(13), static_cast<uint32_t>(14),
static_cast<uint32_t>(15));
EXPECT_EQ(static_cast<uint32_t>(cmds::DawnCommands::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<uint32_t>(11), cmd.trace_id_high);
EXPECT_EQ(static_cast<uint32_t>(12), cmd.trace_id_low);
EXPECT_EQ(static_cast<uint32_t>(13), cmd.commands_shm_id);
EXPECT_EQ(static_cast<uint32_t>(14), cmd.commands_shm_offset);
EXPECT_EQ(static_cast<uint32_t>(15), cmd.size);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(WebGPUFormatTest, AssociateMailboxImmediate) {
const int kSomeBaseValueToTestWith = 51;
static GLuint data[] = {
static_cast<GLuint>(kSomeBaseValueToTestWith + 0),
static_cast<GLuint>(kSomeBaseValueToTestWith + 1),
static_cast<GLuint>(kSomeBaseValueToTestWith + 2),
static_cast<GLuint>(kSomeBaseValueToTestWith + 3),
static_cast<GLuint>(kSomeBaseValueToTestWith + 4),
static_cast<GLuint>(kSomeBaseValueToTestWith + 5),
static_cast<GLuint>(kSomeBaseValueToTestWith + 6),
static_cast<GLuint>(kSomeBaseValueToTestWith + 7),
static_cast<GLuint>(kSomeBaseValueToTestWith + 8),
};
cmds::AssociateMailboxImmediate& cmd =
*GetBufferAs<cmds::AssociateMailboxImmediate>();
const GLsizei kNumElements = 9;
const size_t kExpectedCmdSize =
sizeof(cmd) + kNumElements * sizeof(GLuint) * 1;
void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(1), static_cast<GLuint>(2),
static_cast<GLuint>(3), static_cast<GLuint>(4),
static_cast<uint64_t>(5), static_cast<uint64_t>(6),
static_cast<MailboxFlags>(7), static_cast<GLuint>(8),
static_cast<GLuint>(9), data);
EXPECT_EQ(static_cast<uint32_t>(cmds::AssociateMailboxImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(1), cmd.device_id);
EXPECT_EQ(static_cast<GLuint>(2), cmd.device_generation);
EXPECT_EQ(static_cast<GLuint>(3), cmd.id);
EXPECT_EQ(static_cast<GLuint>(4), cmd.generation);
EXPECT_EQ(static_cast<uint64_t>(5), cmd.usage);
EXPECT_EQ(static_cast<uint64_t>(6), cmd.internal_usage);
EXPECT_EQ(static_cast<MailboxFlags>(7), cmd.flags);
EXPECT_EQ(static_cast<GLuint>(8), cmd.view_format_count);
EXPECT_EQ(static_cast<GLuint>(9), cmd.count);
CheckBytesWrittenMatchesExpectedSize(
next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
}
TEST_F(WebGPUFormatTest, AssociateMailboxForBufferImmediate) {
const int kSomeBaseValueToTestWith = 51;
static GLuint data[] = {
static_cast<GLuint>(kSomeBaseValueToTestWith + 0),
static_cast<GLuint>(kSomeBaseValueToTestWith + 1),
static_cast<GLuint>(kSomeBaseValueToTestWith + 2),
static_cast<GLuint>(kSomeBaseValueToTestWith + 3),
};
cmds::AssociateMailboxForBufferImmediate& cmd =
*GetBufferAs<cmds::AssociateMailboxForBufferImmediate>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12),
static_cast<GLuint>(13), static_cast<GLuint>(14),
static_cast<uint64_t>(15), data);
EXPECT_EQ(
static_cast<uint32_t>(cmds::AssociateMailboxForBufferImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.device_id);
EXPECT_EQ(static_cast<GLuint>(12), cmd.device_generation);
EXPECT_EQ(static_cast<GLuint>(13), cmd.id);
EXPECT_EQ(static_cast<GLuint>(14), cmd.generation);
EXPECT_EQ(static_cast<uint64_t>(15), cmd.usage);
CheckBytesWrittenMatchesExpectedSize(
next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
}
TEST_F(WebGPUFormatTest, DissociateMailbox) {
cmds::DissociateMailbox& cmd = *GetBufferAs<cmds::DissociateMailbox>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12));
EXPECT_EQ(static_cast<uint32_t>(cmds::DissociateMailbox::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.texture_id);
EXPECT_EQ(static_cast<GLuint>(12), cmd.texture_generation);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(WebGPUFormatTest, DissociateMailboxForBuffer) {
cmds::DissociateMailboxForBuffer& cmd =
*GetBufferAs<cmds::DissociateMailboxForBuffer>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12));
EXPECT_EQ(static_cast<uint32_t>(cmds::DissociateMailboxForBuffer::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.buffer_id);
EXPECT_EQ(static_cast<GLuint>(12), cmd.buffer_generation);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(WebGPUFormatTest, DissociateMailboxForPresent) {
cmds::DissociateMailboxForPresent& cmd =
*GetBufferAs<cmds::DissociateMailboxForPresent>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12),
static_cast<GLuint>(13), static_cast<GLuint>(14));
EXPECT_EQ(static_cast<uint32_t>(cmds::DissociateMailboxForPresent::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.device_id);
EXPECT_EQ(static_cast<GLuint>(12), cmd.device_generation);
EXPECT_EQ(static_cast<GLuint>(13), cmd.texture_id);
EXPECT_EQ(static_cast<GLuint>(14), cmd.texture_generation);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(WebGPUFormatTest, SetWebGPUExecutionContextToken) {
cmds::SetWebGPUExecutionContextToken& cmd =
*GetBufferAs<cmds::SetWebGPUExecutionContextToken>();
void* next_cmd =
cmd.Set(&cmd, static_cast<uint32_t>(11), static_cast<uint32_t>(12),
static_cast<uint32_t>(13), static_cast<uint32_t>(14),
static_cast<uint32_t>(15));
EXPECT_EQ(static_cast<uint32_t>(cmds::SetWebGPUExecutionContextToken::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<uint32_t>(11), cmd.type);
EXPECT_EQ(static_cast<uint32_t>(12), cmd.high_high);
EXPECT_EQ(static_cast<uint32_t>(13), cmd.high_low);
EXPECT_EQ(static_cast<uint32_t>(14), cmd.low_high);
EXPECT_EQ(static_cast<uint32_t>(15), cmd.low_low);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
#endif // GPU_COMMAND_BUFFER_COMMON_WEBGPU_CMD_FORMAT_TEST_AUTOGEN_H_