Add BGLBinding::textureComponentType

This is a new compatibility constraint that the texture component type
must match between what's declared in the shader and the bind group.

 - Format is updated to include the component type of the format.
 - Validation and state tracking is updated to reflect the new
BGLBinding member.
 - TextureFormat tests are updated to pass with the added validation and
to remove a redundant enum definition.
 - BGLBinding::multisampled validation is added because it was next to
modified code for the BGLBinding::textureComponentType validation.
 - A redundant BGL caching test was removed.

BUG=dawn:128

Change-Id: I9c4ae92062769c3ecf74caf46f27415344dfad77
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10281
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2019-08-21 12:16:33 +00:00
committed by Commit Bot service account
parent ae2b9f4720
commit f463a20291
10 changed files with 240 additions and 150 deletions

View File

@@ -306,6 +306,30 @@ TEST_F(BindGroupValidationTest, TextureUsage) {
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, outputTextureView}}));
}
// Check that a texture must have the correct component type
TEST_F(BindGroupValidationTest, TextureComponentType) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::SampledTexture, false,
false, dawn::TextureComponentType::Float}});
// Control case: setting a Float typed texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});
// Make an output attachment texture and try to set it for a SampledTexture binding
dawn::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D;
descriptor.size = {16, 16, 1};
descriptor.arrayLayerCount = 1;
descriptor.sampleCount = 1;
descriptor.format = dawn::TextureFormat::RGBA8Uint;
descriptor.mipLevelCount = 1;
descriptor.usage = dawn::TextureUsageBit::Sampled;
dawn::Texture uintTexture = device.CreateTexture(&descriptor);
dawn::TextureView uintTextureView = uintTexture.CreateDefaultView();
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, uintTextureView}}));
}
// Check that a UBO must have the correct usage
TEST_F(BindGroupValidationTest, BufferUsageUBO) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {
@@ -482,24 +506,6 @@ TEST_F(BindGroupLayoutValidationTest, DynamicAndTypeCompatibility) {
}));
}
// This test verifies that the BindGroupLayout cache is successfully caching/deduplicating objects.
//
// NOTE: This test only works currently because unittests are run without the wire - so the returned
// BindGroupLayout pointers are actually visibly equivalent. With the wire, this would not be true.
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutCache) {
auto layout1 = utils::MakeBindGroupLayout(
device, {
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
});
auto layout2 = utils::MakeBindGroupLayout(
device, {
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
});
// Caching should cause these to be the same.
ASSERT_EQ(layout1.Get(), layout2.Get());
}
// This test verifies that visibility of bindings in BindGroupLayout can't be none
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
utils::MakeBindGroupLayout(