Validate that storage texture views have a single miplevel
Validate the storage texture views have a miplevel of 1 when creating bind group. This validation is added in https://github.com/gpuweb/gpuweb/pull/2285. Also fix a bug in unittest BindGroupValidationTest.TextureBindingType. Bug: dawn:1212 Change-Id: If32400ed1e4f3049b8b8979e6e6133bada36b45c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71380 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
parent
c871df0b19
commit
3a036ab698
|
@ -182,6 +182,10 @@ namespace dawn_native {
|
|||
"Dimension (%s) of %s doesn't match the expected dimension (%s).",
|
||||
entry.textureView->GetDimension(), entry.textureView,
|
||||
bindingInfo.storageTexture.viewDimension);
|
||||
|
||||
DAWN_INVALID_IF(entry.textureView->GetLevelCount() != 1,
|
||||
"mipLevelCount (%u) of %s expected to be 1.",
|
||||
entry.textureView->GetLevelCount(), entry.textureView);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -218,7 +218,7 @@ TEST_F(BindGroupValidationTest, TextureBindingType) {
|
|||
// Setting the sampler as well is an error
|
||||
binding.sampler = mSampler;
|
||||
ASSERT_DEVICE_ERROR(device.CreateBindGroup(&descriptor));
|
||||
binding.textureView = nullptr;
|
||||
binding.sampler = nullptr;
|
||||
|
||||
// Setting the buffer as well is an error
|
||||
binding.buffer = mUBO;
|
||||
|
@ -552,6 +552,71 @@ TEST_F(BindGroupValidationTest, TextureDimension) {
|
|||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, arrayTextureView}}));
|
||||
}
|
||||
|
||||
// Check that a storage texture binding must have a texture view with a mipLevelCount of 1
|
||||
TEST_F(BindGroupValidationTest, StorageTextureViewLayerCount) {
|
||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly,
|
||||
wgpu::TextureFormat::RGBA8Uint}});
|
||||
|
||||
wgpu::TextureDescriptor descriptor;
|
||||
descriptor.dimension = wgpu::TextureDimension::e2D;
|
||||
descriptor.size = {16, 16, 1};
|
||||
descriptor.sampleCount = 1;
|
||||
descriptor.mipLevelCount = 1;
|
||||
descriptor.usage = wgpu::TextureUsage::StorageBinding;
|
||||
descriptor.format = wgpu::TextureFormat::RGBA8Uint;
|
||||
|
||||
wgpu::Texture textureNoMip = device.CreateTexture(&descriptor);
|
||||
|
||||
descriptor.mipLevelCount = 3;
|
||||
wgpu::Texture textureMip = device.CreateTexture(&descriptor);
|
||||
|
||||
// Control case: setting a storage texture view on a texture with only one mip level works
|
||||
{
|
||||
wgpu::TextureView view = textureNoMip.CreateView();
|
||||
utils::MakeBindGroup(device, layout, {{0, view}});
|
||||
}
|
||||
|
||||
// Setting a storage texture view with mipLevelCount=1 on a texture of multiple mip levels is
|
||||
// valid
|
||||
{
|
||||
wgpu::TextureViewDescriptor viewDesc = {};
|
||||
viewDesc.aspect = wgpu::TextureAspect::All;
|
||||
viewDesc.dimension = wgpu::TextureViewDimension::e2D;
|
||||
viewDesc.format = wgpu::TextureFormat::RGBA8Uint;
|
||||
viewDesc.baseMipLevel = 0;
|
||||
viewDesc.mipLevelCount = 1;
|
||||
|
||||
// Setting texture view with lod 0 is valid
|
||||
wgpu::TextureView view = textureMip.CreateView(&viewDesc);
|
||||
utils::MakeBindGroup(device, layout, {{0, view}});
|
||||
|
||||
// Setting texture view with other lod is also valid
|
||||
viewDesc.baseMipLevel = 2;
|
||||
view = textureMip.CreateView(&viewDesc);
|
||||
utils::MakeBindGroup(device, layout, {{0, view}});
|
||||
}
|
||||
|
||||
// Texture view with mipLevelCount > 1 is invalid
|
||||
{
|
||||
wgpu::TextureViewDescriptor viewDesc = {};
|
||||
viewDesc.aspect = wgpu::TextureAspect::All;
|
||||
viewDesc.dimension = wgpu::TextureViewDimension::e2D;
|
||||
viewDesc.format = wgpu::TextureFormat::RGBA8Uint;
|
||||
viewDesc.baseMipLevel = 0;
|
||||
viewDesc.mipLevelCount = 2;
|
||||
|
||||
// Setting texture view with lod 0 and 1 is invalid
|
||||
wgpu::TextureView view = textureMip.CreateView(&viewDesc);
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, view}}));
|
||||
|
||||
// Setting texture view with lod 1 and 2 is invalid
|
||||
viewDesc.baseMipLevel = 1;
|
||||
view = textureMip.CreateView(&viewDesc);
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, view}}));
|
||||
}
|
||||
}
|
||||
|
||||
// Check that a UBO must have the correct usage
|
||||
TEST_F(BindGroupValidationTest, BufferUsageUBO) {
|
||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
|
||||
|
|
Loading…
Reference in New Issue