mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-15 16:16:08 +00:00
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:
committed by
Commit Bot service account
parent
be08000cb5
commit
3966eb1175
@@ -750,11 +750,11 @@ TEST_P(BindGroupTests, DrawThenChangePipelineAndBindGroup) {
|
||||
TEST_P(BindGroupTests, BindGroupLayoutVisibilityCanBeNone) {
|
||||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::None,
|
||||
wgpu::BindingType::UniformBuffer};
|
||||
wgpu::BindGroupLayoutEntry entry = {0, wgpu::ShaderStage::None,
|
||||
wgpu::BindingType::UniformBuffer};
|
||||
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &entry;
|
||||
wgpu::BindGroupLayout layout = device.CreateBindGroupLayout(&descriptor);
|
||||
|
||||
wgpu::RenderPipeline pipeline = MakeTestPipeline(renderPass, {}, {layout});
|
||||
|
||||
@@ -79,8 +79,8 @@ TEST_P(DeprecationTests, BGLEntryTextureDimensionIsDeprecated) {
|
||||
};
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
.entryCount = 1,
|
||||
.entries = &entryDesc,
|
||||
};
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateBindGroupLayout(&bglDesc));
|
||||
}
|
||||
@@ -92,8 +92,8 @@ TEST_P(DeprecationTests, BGLEntryTextureDimensionAndViewUndefinedEmitsNoWarning)
|
||||
};
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
.entryCount = 1,
|
||||
.entries = &entryDesc,
|
||||
};
|
||||
device.CreateBindGroupLayout(&bglDesc);
|
||||
}
|
||||
@@ -106,8 +106,8 @@ TEST_P(DeprecationTests, BGLEntryTextureAndViewDimensionIsInvalid) {
|
||||
};
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
.entryCount = 1,
|
||||
.entries = &entryDesc,
|
||||
};
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&bglDesc));
|
||||
}
|
||||
@@ -121,8 +121,8 @@ TEST_P(DeprecationTests, BGLEntryTextureDimensionStateTracking) {
|
||||
};
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
.entryCount = 1,
|
||||
.entries = &entryDesc,
|
||||
};
|
||||
wgpu::BindGroupLayout layout;
|
||||
EXPECT_DEPRECATION_WARNING(layout = device.CreateBindGroupLayout(&bglDesc));
|
||||
@@ -152,6 +152,161 @@ TEST_P(DeprecationTests, BGLEntryTextureDimensionStateTracking) {
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, arrayView}}));
|
||||
}
|
||||
|
||||
// Test for BindGroupLayout::bindings/bindingCount -> entries/entryCount
|
||||
|
||||
// Test that creating a BGL with bindings emits a deprecation warning.
|
||||
TEST_P(DeprecationTests, BGLDescBindingIsDeprecated) {
|
||||
wgpu::BindGroupLayoutEntry entryDesc = {
|
||||
.type = wgpu::BindingType::Sampler,
|
||||
};
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
};
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateBindGroupLayout(&bglDesc));
|
||||
}
|
||||
|
||||
// Test that creating a BGL with both entries and bindings is an error
|
||||
TEST_P(DeprecationTests, BGLDescBindingAndEntriesIsInvalid) {
|
||||
wgpu::BindGroupLayoutEntry entryDesc = {
|
||||
.type = wgpu::BindingType::Sampler,
|
||||
};
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
.entryCount = 1,
|
||||
.entries = &entryDesc,
|
||||
};
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&bglDesc));
|
||||
}
|
||||
|
||||
// Test that creating a BGL with both entries and bindings to 0 doesn't emit warnings
|
||||
TEST_P(DeprecationTests, BGLDescBindingAndEntriesBothZeroEmitsNoWarning) {
|
||||
// TODO(cwallez@chromium.org): In Vulkan it is disallowed to create 0-sized descriptor pools
|
||||
// but the Vulkan backend doesn't special case it yet.
|
||||
DAWN_SKIP_TEST_IF(IsVulkan());
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {
|
||||
.bindingCount = 0,
|
||||
.bindings = nullptr,
|
||||
.entryCount = 0,
|
||||
.entries = nullptr,
|
||||
};
|
||||
device.CreateBindGroupLayout(&bglDesc);
|
||||
}
|
||||
|
||||
// Test that creating a BGL with bindings still does correct state tracking
|
||||
TEST_P(DeprecationTests, BGLDescBindingStateTracking) {
|
||||
wgpu::BindGroupLayoutEntry entryDesc = {
|
||||
.binding = 0,
|
||||
.type = wgpu::BindingType::Sampler,
|
||||
};
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
};
|
||||
wgpu::BindGroupLayout layout;
|
||||
EXPECT_DEPRECATION_WARNING(layout = device.CreateBindGroupLayout(&bglDesc));
|
||||
|
||||
// Test a case where if |bindings| wasn't taken into account, no validation error would happen
|
||||
// because the layout would be empty
|
||||
wgpu::BindGroupDescriptor badBgDesc = {
|
||||
.layout = layout,
|
||||
.entryCount = 0,
|
||||
.entries = nullptr,
|
||||
};
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&badBgDesc));
|
||||
}
|
||||
|
||||
// Test for BindGroup::bindings/bindingCount -> entries/entryCount
|
||||
|
||||
// Test that creating a BG with bindings emits a deprecation warning.
|
||||
TEST_P(DeprecationTests, BGDescBindingIsDeprecated) {
|
||||
wgpu::SamplerDescriptor samplerDesc = {};
|
||||
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
|
||||
|
||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
|
||||
|
||||
wgpu::BindGroupEntry entryDesc = {
|
||||
.binding = 0,
|
||||
.sampler = sampler,
|
||||
};
|
||||
|
||||
wgpu::BindGroupDescriptor bgDesc = {
|
||||
.layout = layout,
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
};
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateBindGroup(&bgDesc));
|
||||
}
|
||||
|
||||
// Test that creating a BG with both entries and bindings is an error
|
||||
TEST_P(DeprecationTests, BGDescBindingAndEntriesIsInvalid) {
|
||||
wgpu::SamplerDescriptor samplerDesc = {};
|
||||
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
|
||||
|
||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
|
||||
|
||||
wgpu::BindGroupEntry entryDesc = {
|
||||
.binding = 0,
|
||||
.sampler = sampler,
|
||||
};
|
||||
|
||||
wgpu::BindGroupDescriptor bgDesc = {
|
||||
.layout = layout,
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
.entryCount = 1,
|
||||
.entries = &entryDesc,
|
||||
};
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&bgDesc));
|
||||
}
|
||||
|
||||
// Test that creating a BG with both entries and bindings to 0 doesn't emit warnings
|
||||
TEST_P(DeprecationTests, BGDescBindingAndEntriesBothZeroEmitsNoWarning) {
|
||||
// TODO(cwallez@chromium.org): In Vulkan it is disallowed to create 0-sized descriptor pools
|
||||
// but the Vulkan backend doesn't special case it yet.
|
||||
DAWN_SKIP_TEST_IF(IsVulkan());
|
||||
|
||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
|
||||
|
||||
wgpu::BindGroupDescriptor bgDesc = {
|
||||
.layout = layout,
|
||||
.bindingCount = 0,
|
||||
.bindings = nullptr,
|
||||
.entryCount = 0,
|
||||
.entries = nullptr,
|
||||
};
|
||||
device.CreateBindGroup(&bgDesc);
|
||||
}
|
||||
|
||||
// Test that creating a BG with bindings still does correct state tracking
|
||||
TEST_P(DeprecationTests, BGDescBindingStateTracking) {
|
||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
|
||||
|
||||
// Test a case where if |bindings| wasn't taken into account, no validation error would happen
|
||||
// because it would match the empty layout.
|
||||
wgpu::SamplerDescriptor samplerDesc = {};
|
||||
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
|
||||
|
||||
wgpu::BindGroupEntry entryDesc = {
|
||||
.binding = 0,
|
||||
.sampler = sampler,
|
||||
};
|
||||
|
||||
wgpu::BindGroupDescriptor bgDesc = {
|
||||
.layout = layout,
|
||||
.bindingCount = 1,
|
||||
.bindings = &entryDesc,
|
||||
};
|
||||
EXPECT_DEPRECATION_WARNING(ASSERT_DEVICE_ERROR(device.CreateBindGroup(&bgDesc)));
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(DeprecationTests,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
|
||||
@@ -105,11 +105,11 @@ TEST_P(DeviceLostTest, SubmitFails) {
|
||||
TEST_P(DeviceLostTest, CreateBindGroupLayoutFails) {
|
||||
SetCallbackAndLoseForTesting();
|
||||
|
||||
wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::None,
|
||||
wgpu::BindingType::UniformBuffer};
|
||||
wgpu::BindGroupLayoutEntry entry = {0, wgpu::ShaderStage::None,
|
||||
wgpu::BindingType::UniformBuffer};
|
||||
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &entry;
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor));
|
||||
}
|
||||
|
||||
@@ -139,18 +139,18 @@ TEST_P(DeviceLostTest, GetBindGroupLayoutFails) {
|
||||
TEST_P(DeviceLostTest, CreateBindGroupFails) {
|
||||
SetCallbackAndLoseForTesting();
|
||||
|
||||
wgpu::BindGroupEntry binding;
|
||||
binding.binding = 0;
|
||||
binding.sampler = nullptr;
|
||||
binding.textureView = nullptr;
|
||||
binding.buffer = nullptr;
|
||||
binding.offset = 0;
|
||||
binding.size = 0;
|
||||
wgpu::BindGroupEntry entry;
|
||||
entry.binding = 0;
|
||||
entry.sampler = nullptr;
|
||||
entry.textureView = nullptr;
|
||||
entry.buffer = nullptr;
|
||||
entry.offset = 0;
|
||||
entry.size = 0;
|
||||
|
||||
wgpu::BindGroupDescriptor descriptor;
|
||||
descriptor.layout = nullptr;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &entry;
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,24 +23,24 @@ TEST_P(StorageTextureTests, BindGroupLayoutWithStorageTextureBindingType) {
|
||||
// wgpu::BindingType::ReadonlyStorageTexture is a valid binding type to create a bind group
|
||||
// layout.
|
||||
{
|
||||
wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::Compute,
|
||||
wgpu::BindingType::ReadonlyStorageTexture};
|
||||
binding.storageTextureFormat = wgpu::TextureFormat::R32Float;
|
||||
wgpu::BindGroupLayoutEntry entry = {0, wgpu::ShaderStage::Compute,
|
||||
wgpu::BindingType::ReadonlyStorageTexture};
|
||||
entry.storageTextureFormat = wgpu::TextureFormat::R32Float;
|
||||
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &entry;
|
||||
device.CreateBindGroupLayout(&descriptor);
|
||||
}
|
||||
|
||||
// wgpu::BindingType::WriteonlyStorageTexture is a valid binding type to create a bind group
|
||||
// layout.
|
||||
{
|
||||
wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::Compute,
|
||||
wgpu::BindingType::WriteonlyStorageTexture};
|
||||
binding.storageTextureFormat = wgpu::TextureFormat::R32Float;
|
||||
wgpu::BindGroupLayoutEntry entry = {0, wgpu::ShaderStage::Compute,
|
||||
wgpu::BindingType::WriteonlyStorageTexture};
|
||||
entry.storageTextureFormat = wgpu::TextureFormat::R32Float;
|
||||
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &entry;
|
||||
device.CreateBindGroupLayout(&descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ TEST_F(BindGroupValidationTest, NextInChainNullptr) {
|
||||
|
||||
wgpu::BindGroupDescriptor descriptor;
|
||||
descriptor.layout = layout;
|
||||
descriptor.bindingCount = 0;
|
||||
descriptor.bindings = nullptr;
|
||||
descriptor.entryCount = 0;
|
||||
descriptor.entries = nullptr;
|
||||
|
||||
// Control case: check that nextInChain = nullptr is valid
|
||||
descriptor.nextInChain = nullptr;
|
||||
@@ -88,15 +88,15 @@ TEST_F(BindGroupValidationTest, NextInChainNullptr) {
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||
}
|
||||
|
||||
// Check constraints on bindingCount
|
||||
TEST_F(BindGroupValidationTest, bindingCountMismatch) {
|
||||
// Check constraints on entryCount
|
||||
TEST_F(BindGroupValidationTest, EntryCountMismatch) {
|
||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
|
||||
|
||||
// Control case: check that a descriptor with one binding is ok
|
||||
utils::MakeBindGroup(device, layout, {{0, mSampler}});
|
||||
|
||||
// Check that bindingCount != layout.bindingCount fails.
|
||||
// Check that entryCount != layout.entryCount fails.
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {}));
|
||||
}
|
||||
|
||||
@@ -149,8 +149,8 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) {
|
||||
|
||||
wgpu::BindGroupDescriptor descriptor;
|
||||
descriptor.layout = layout;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &binding;
|
||||
|
||||
// Not setting anything fails
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||
@@ -198,8 +198,8 @@ TEST_F(BindGroupValidationTest, TextureBindingType) {
|
||||
|
||||
wgpu::BindGroupDescriptor descriptor;
|
||||
descriptor.layout = layout;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &binding;
|
||||
|
||||
// Not setting anything fails
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||
@@ -252,8 +252,8 @@ TEST_F(BindGroupValidationTest, BufferBindingType) {
|
||||
|
||||
wgpu::BindGroupDescriptor descriptor;
|
||||
descriptor.layout = layout;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &binding;
|
||||
|
||||
// Not setting anything fails
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||
@@ -473,8 +473,8 @@ class BindGroupLayoutValidationTest : public ValidationTest {
|
||||
bool expected) {
|
||||
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||
|
||||
descriptor.bindingCount = count;
|
||||
descriptor.bindings = binding;
|
||||
descriptor.entryCount = count;
|
||||
descriptor.entries = binding;
|
||||
|
||||
if (!expected) {
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor));
|
||||
@@ -526,23 +526,23 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutEntryUnbounded) {
|
||||
|
||||
// Test that there can't be more than kMaxBindingPerGroup bindings per group
|
||||
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutMaxBindings) {
|
||||
wgpu::BindGroupLayoutEntry bindings[kMaxBindingsPerGroup + 1];
|
||||
wgpu::BindGroupLayoutEntry entries[kMaxBindingsPerGroup + 1];
|
||||
|
||||
for (uint32_t i = 0; i < kMaxBindingsPerGroup + 1; i++) {
|
||||
bindings[i].type = wgpu::BindingType::UniformBuffer;
|
||||
bindings[i].binding = i;
|
||||
bindings[i].visibility = wgpu::ShaderStage::Compute;
|
||||
entries[i].type = wgpu::BindingType::UniformBuffer;
|
||||
entries[i].binding = i;
|
||||
entries[i].visibility = wgpu::ShaderStage::Compute;
|
||||
}
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc;
|
||||
desc.bindings = bindings;
|
||||
desc.entries = entries;
|
||||
|
||||
// Control case: kMaxBindingsPerGroup bindings is allowed.
|
||||
desc.bindingCount = kMaxBindingsPerGroup;
|
||||
desc.entryCount = kMaxBindingsPerGroup;
|
||||
device.CreateBindGroupLayout(&desc);
|
||||
|
||||
// Error case: kMaxBindingsPerGroup + 1 bindings is not allowed.
|
||||
desc.bindingCount = kMaxBindingsPerGroup + 1;
|
||||
desc.entryCount = kMaxBindingsPerGroup + 1;
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc));
|
||||
}
|
||||
|
||||
@@ -594,8 +594,8 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
|
||||
wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::None,
|
||||
wgpu::BindingType::UniformBuffer};
|
||||
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &binding;
|
||||
device.CreateBindGroupLayout(&descriptor);
|
||||
}
|
||||
|
||||
@@ -642,8 +642,8 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
|
||||
auto MakeBindGroupLayout = [&](wgpu::BindGroupLayoutEntry* binding,
|
||||
uint32_t count) -> wgpu::BindGroupLayout {
|
||||
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||
descriptor.bindingCount = count;
|
||||
descriptor.bindings = binding;
|
||||
descriptor.entryCount = count;
|
||||
descriptor.entries = binding;
|
||||
return device.CreateBindGroupLayout(&descriptor);
|
||||
};
|
||||
|
||||
@@ -1055,8 +1055,8 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
|
||||
|
||||
// Create the bind group layout.
|
||||
wgpu::BindGroupLayoutDescriptor bglDescriptor;
|
||||
bglDescriptor.bindingCount = static_cast<uint32_t>(bindings.size());
|
||||
bglDescriptor.bindings = bindings.data();
|
||||
bglDescriptor.entryCount = static_cast<uint32_t>(bindings.size());
|
||||
bglDescriptor.entries = bindings.data();
|
||||
bindGroupLayouts[l] = device.CreateBindGroupLayout(&bglDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,8 +108,8 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
|
||||
binding.multisampled = false;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||
desc.bindingCount = 1;
|
||||
desc.bindings = &binding;
|
||||
desc.entryCount = 1;
|
||||
desc.entries = &binding;
|
||||
|
||||
// Check that visibility and dynamic offsets match
|
||||
binding.hasDynamicOffset = false;
|
||||
@@ -157,8 +157,8 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
|
||||
binding.hasDynamicOffset = false;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||
desc.bindingCount = 1;
|
||||
desc.bindings = &binding;
|
||||
desc.entryCount = 1;
|
||||
desc.entries = &binding;
|
||||
|
||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||
}
|
||||
@@ -171,8 +171,8 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
||||
binding.multisampled = false;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||
desc.bindingCount = 1;
|
||||
desc.bindings = &binding;
|
||||
desc.entryCount = 1;
|
||||
desc.entries = &binding;
|
||||
|
||||
{
|
||||
// Storage buffer binding is not supported in vertex shader.
|
||||
@@ -243,8 +243,8 @@ TEST_F(GetBindGroupLayoutTests, Multisampled) {
|
||||
binding.hasDynamicOffset = false;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||
desc.bindingCount = 1;
|
||||
desc.bindings = &binding;
|
||||
desc.entryCount = 1;
|
||||
desc.entries = &binding;
|
||||
|
||||
{
|
||||
binding.multisampled = false;
|
||||
@@ -281,8 +281,8 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
|
||||
binding.multisampled = false;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||
desc.bindingCount = 1;
|
||||
desc.bindings = &binding;
|
||||
desc.entryCount = 1;
|
||||
desc.entries = &binding;
|
||||
|
||||
{
|
||||
binding.viewDimension = wgpu::TextureViewDimension::e1D;
|
||||
@@ -355,8 +355,8 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
|
||||
binding.multisampled = false;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||
desc.bindingCount = 1;
|
||||
desc.bindings = &binding;
|
||||
desc.entryCount = 1;
|
||||
desc.entries = &binding;
|
||||
|
||||
{
|
||||
binding.textureComponentType = wgpu::TextureComponentType::Float;
|
||||
@@ -398,8 +398,8 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
|
||||
binding.multisampled = false;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||
desc.bindingCount = 1;
|
||||
desc.bindings = &binding;
|
||||
desc.entryCount = 1;
|
||||
desc.entries = &binding;
|
||||
|
||||
{
|
||||
binding.binding = 0;
|
||||
@@ -605,8 +605,8 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
|
||||
void main() {})");
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||
desc.bindingCount = 0;
|
||||
desc.bindings = nullptr;
|
||||
desc.entryCount = 0;
|
||||
desc.entries = nullptr;
|
||||
|
||||
wgpu::BindGroupLayout emptyBindGroupLayout = device.CreateBindGroupLayout(&desc);
|
||||
|
||||
@@ -625,8 +625,8 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
|
||||
binding.visibility = wgpu::ShaderStage::Vertex;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc = {};
|
||||
bglDesc.bindingCount = 1;
|
||||
bglDesc.bindings = &binding;
|
||||
bglDesc.entryCount = 1;
|
||||
bglDesc.entries = &binding;
|
||||
|
||||
wgpu::BindGroupLayout bindGroupLayout = device.CreateBindGroupLayout(&bglDesc);
|
||||
|
||||
@@ -663,8 +663,8 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
|
||||
|
||||
{
|
||||
wgpu::BindGroupLayoutDescriptor emptyDesc = {};
|
||||
emptyDesc.bindingCount = 0;
|
||||
emptyDesc.bindings = nullptr;
|
||||
emptyDesc.entryCount = 0;
|
||||
emptyDesc.entries = nullptr;
|
||||
|
||||
wgpu::BindGroupLayout emptyBindGroupLayout = device.CreateBindGroupLayout(&emptyDesc);
|
||||
|
||||
|
||||
@@ -381,11 +381,12 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutWithStorageTextureBindingTy
|
||||
{wgpu::ShaderStage::Compute, wgpu::BindingType::StorageTexture, false}}};
|
||||
|
||||
for (const auto& testSpec : kTestSpecs) {
|
||||
wgpu::BindGroupLayoutEntry binding = {0, testSpec.stage, testSpec.type};
|
||||
binding.storageTextureFormat = wgpu::TextureFormat::R32Uint;
|
||||
wgpu::BindGroupLayoutEntry entry = {0, testSpec.stage, testSpec.type};
|
||||
entry.storageTextureFormat = wgpu::TextureFormat::R32Uint;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||
descriptor.bindingCount = 1;
|
||||
descriptor.bindings = &binding;
|
||||
descriptor.entryCount = 1;
|
||||
descriptor.entries = &entry;
|
||||
|
||||
if (testSpec.valid) {
|
||||
device.CreateBindGroupLayout(&descriptor);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user