Deprecate BG[L]Desc::binding[s|Count] in favor of entr[ies|yCount]

Bug: dawn:22

Change-Id: I02188d70103a1bee25b9b2024a2ea9f785656236
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19862
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2020-04-21 07:36:30 +00:00
committed by Commit Bot service account
parent be08000cb5
commit 3966eb1175
18 changed files with 406 additions and 219 deletions

View File

@@ -49,8 +49,8 @@ TEST_F(WireArgumentTests, ValueArgument) {
TEST_F(WireArgumentTests, ValueArrayArgument) {
// Create a bindgroup.
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.bindingCount = 0;
bglDescriptor.bindings = nullptr;
bglDescriptor.entryCount = 0;
bglDescriptor.entries = nullptr;
WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDescriptor);
WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
@@ -58,8 +58,8 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
WGPUBindGroupDescriptor bindGroupDescriptor = {};
bindGroupDescriptor.layout = bgl;
bindGroupDescriptor.bindingCount = 0;
bindGroupDescriptor.bindings = nullptr;
bindGroupDescriptor.entryCount = 0;
bindGroupDescriptor.entries = nullptr;
WGPUBindGroup bindGroup = wgpuDeviceCreateBindGroup(device, &bindGroupDescriptor);
WGPUBindGroup apiBindGroup = api.GetNewBindGroup();
@@ -284,8 +284,8 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
// Test that the wire is able to send structures that contain objects
TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.bindingCount = 0;
bglDescriptor.bindings = nullptr;
bglDescriptor.entryCount = 0;
bglDescriptor.entries = nullptr;
WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDescriptor);
WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
@@ -313,7 +313,7 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
// Test that the wire is able to send structures that contain objects
TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
static constexpr int NUM_BINDINGS = 3;
WGPUBindGroupLayoutEntry bindings[NUM_BINDINGS]{
WGPUBindGroupLayoutEntry entries[NUM_BINDINGS]{
{0,
WGPUShaderStage_Vertex,
WGPUBindingType_Sampler,
@@ -343,24 +343,24 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
WGPUTextureFormat_RGBA8Unorm},
};
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.bindingCount = NUM_BINDINGS;
bglDescriptor.bindings = bindings;
bglDescriptor.entryCount = NUM_BINDINGS;
bglDescriptor.entries = entries;
wgpuDeviceCreateBindGroupLayout(device, &bglDescriptor);
WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
EXPECT_CALL(
api,
DeviceCreateBindGroupLayout(
apiDevice, MatchesLambda([bindings](const WGPUBindGroupLayoutDescriptor* desc) -> bool {
apiDevice, MatchesLambda([entries](const WGPUBindGroupLayoutDescriptor* desc) -> bool {
for (int i = 0; i < NUM_BINDINGS; ++i) {
const auto& a = desc->bindings[i];
const auto& b = bindings[i];
const auto& a = desc->entries[i];
const auto& b = entries[i];
if (a.binding != b.binding || a.visibility != b.visibility ||
a.type != b.type) {
return false;
}
}
return desc->nextInChain == nullptr && desc->bindingCount == 3;
return desc->nextInChain == nullptr && desc->entryCount == 3;
})))
.WillOnce(Return(apiBgl));

View File

@@ -166,11 +166,11 @@ TEST_F(WireMultipleDeviceTests, DifferentDeviceObjectCreationIsError) {
wireA.FlushClient();
std::array<WGPUBindGroupBinding, 2> bindings = {};
std::array<WGPUBindGroupBinding, 2> entries = {};
// Create a buffer on wire A.
WGPUBufferDescriptor bufferDesc = {};
bindings[0].buffer = wgpuDeviceCreateBuffer(wireA.ClientDevice(), &bufferDesc);
entries[0].buffer = wgpuDeviceCreateBuffer(wireA.ClientDevice(), &bufferDesc);
EXPECT_CALL(*wireA.Api(), DeviceCreateBuffer(wireA.ServerDevice(), _))
.WillOnce(Return(wireA.Api()->GetNewBuffer()));
@@ -178,7 +178,7 @@ TEST_F(WireMultipleDeviceTests, DifferentDeviceObjectCreationIsError) {
// Create a sampler on wire B.
WGPUSamplerDescriptor samplerDesc = {};
bindings[1].sampler = wgpuDeviceCreateSampler(wireB.ClientDevice(), &samplerDesc);
entries[1].sampler = wgpuDeviceCreateSampler(wireB.ClientDevice(), &samplerDesc);
EXPECT_CALL(*wireB.Api(), DeviceCreateSampler(wireB.ServerDevice(), _))
.WillOnce(Return(wireB.Api()->GetNewSampler()));
@@ -187,8 +187,8 @@ TEST_F(WireMultipleDeviceTests, DifferentDeviceObjectCreationIsError) {
// Create a bind group on wire A using the bgl (A), buffer (A), and sampler (B).
WGPUBindGroupDescriptor bgDesc = {};
bgDesc.layout = bglA;
bgDesc.bindingCount = bindings.size();
bgDesc.bindings = bindings.data();
bgDesc.entryCount = entries.size();
bgDesc.entries = entries.data();
WGPUBindGroup bindGroupA = wgpuDeviceCreateBindGroup(wireA.ClientDevice(), &bgDesc);
// It should inject an error because the sampler is from a different device.

View File

@@ -27,7 +27,7 @@ class WireOptionalTests : public WireTest {
// Test passing nullptr instead of objects - object as value version
TEST_F(WireOptionalTests, OptionalObjectValue) {
WGPUBindGroupLayoutDescriptor bglDesc = {};
bglDesc.bindingCount = 0;
bglDesc.entryCount = 0;
WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDesc);
WGPUBindGroupLayout apiBindGroupLayout = api.GetNewBindGroupLayout();
@@ -35,27 +35,27 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
.WillOnce(Return(apiBindGroupLayout));
// The `sampler`, `textureView` and `buffer` members of a binding are optional.
WGPUBindGroupEntry binding;
binding.binding = 0;
binding.sampler = nullptr;
binding.textureView = nullptr;
binding.buffer = nullptr;
WGPUBindGroupEntry entry;
entry.binding = 0;
entry.sampler = nullptr;
entry.textureView = nullptr;
entry.buffer = nullptr;
WGPUBindGroupDescriptor bgDesc = {};
bgDesc.layout = bgl;
bgDesc.bindingCount = 1;
bgDesc.bindings = &binding;
bgDesc.entryCount = 1;
bgDesc.entries = &entry;
wgpuDeviceCreateBindGroup(device, &bgDesc);
WGPUBindGroup apiDummyBindGroup = api.GetNewBindGroup();
EXPECT_CALL(api, DeviceCreateBindGroup(
apiDevice, MatchesLambda([](const WGPUBindGroupDescriptor* desc) -> bool {
return desc->nextInChain == nullptr && desc->bindingCount == 1 &&
desc->bindings[0].binding == 0 &&
desc->bindings[0].sampler == nullptr &&
desc->bindings[0].buffer == nullptr &&
desc->bindings[0].textureView == nullptr;
return desc->nextInChain == nullptr && desc->entryCount == 1 &&
desc->entries[0].binding == 0 &&
desc->entries[0].sampler == nullptr &&
desc->entries[0].buffer == nullptr &&
desc->entries[0].textureView == nullptr;
})))
.WillOnce(Return(apiDummyBindGroup));