Fix default viewDimension in deprecated BGLEntry path.
The handling of the default view dimension in the deprecated bind group layout entry path was checking the viewDimension of the new sub-descriptor instead of the deprecated viewDimension member. This meant that viewDimension was always defaulted and "2D". This commit fixes the issue by looking at the correct viewDimension member and adds a regression deprecation test. Bug: dawn:620 Change-Id: Icc133b6d80ba3d88bae30dc9138f1d74e14d12c7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/36841 Auto-Submit: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
400a5e2710
commit
00fcab636a
|
@ -443,8 +443,7 @@ namespace dawn_native {
|
|||
case wgpu::BindingType::SampledTexture:
|
||||
bindingInfo.bindingType = BindingInfoType::Texture;
|
||||
bindingInfo.texture.viewDimension = binding.viewDimension;
|
||||
if (binding.texture.viewDimension ==
|
||||
wgpu::TextureViewDimension::Undefined) {
|
||||
if (binding.viewDimension == wgpu::TextureViewDimension::Undefined) {
|
||||
bindingInfo.texture.viewDimension = wgpu::TextureViewDimension::e2D;
|
||||
}
|
||||
|
||||
|
@ -469,8 +468,7 @@ namespace dawn_native {
|
|||
bindingInfo.storageTexture.access = wgpu::StorageTextureAccess::ReadOnly;
|
||||
bindingInfo.storageTexture.format = binding.storageTextureFormat;
|
||||
bindingInfo.storageTexture.viewDimension = binding.viewDimension;
|
||||
if (binding.storageTexture.viewDimension ==
|
||||
wgpu::TextureViewDimension::Undefined) {
|
||||
if (binding.viewDimension == wgpu::TextureViewDimension::Undefined) {
|
||||
bindingInfo.storageTexture.viewDimension =
|
||||
wgpu::TextureViewDimension::e2D;
|
||||
}
|
||||
|
@ -480,8 +478,7 @@ namespace dawn_native {
|
|||
bindingInfo.storageTexture.access = wgpu::StorageTextureAccess::WriteOnly;
|
||||
bindingInfo.storageTexture.format = binding.storageTextureFormat;
|
||||
bindingInfo.storageTexture.viewDimension = binding.viewDimension;
|
||||
if (binding.storageTexture.viewDimension ==
|
||||
wgpu::TextureViewDimension::Undefined) {
|
||||
if (binding.viewDimension == wgpu::TextureViewDimension::Undefined) {
|
||||
bindingInfo.storageTexture.viewDimension =
|
||||
wgpu::TextureViewDimension::e2D;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,51 @@ TEST_P(DeprecationTests, BindGroupLayoutEntryTypeConflict) {
|
|||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor));
|
||||
}
|
||||
|
||||
// Test that the deprecated BGLEntry path correctly handles the defaulting of viewDimension.
|
||||
// This is a regression test for crbug.com/dawn/620
|
||||
TEST_P(DeprecationTests, BindGroupLayoutEntryViewDimensionDefaulting) {
|
||||
wgpu::BindGroupLayoutEntry binding;
|
||||
binding.binding = 0;
|
||||
binding.visibility = wgpu::ShaderStage::Vertex;
|
||||
binding.type = wgpu::BindingType::SampledTexture;
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bglDesc;
|
||||
bglDesc.entryCount = 1;
|
||||
bglDesc.entries = &binding;
|
||||
|
||||
// Check that the default viewDimension is 2D.
|
||||
{
|
||||
binding.viewDimension = wgpu::TextureViewDimension::Undefined;
|
||||
wgpu::BindGroupLayout bgl = device.CreateBindGroupLayout(&bglDesc);
|
||||
|
||||
wgpu::TextureDescriptor desc;
|
||||
desc.usage = wgpu::TextureUsage::Sampled;
|
||||
desc.size = {1, 1, 1};
|
||||
desc.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||
desc.dimension = wgpu::TextureDimension::e2D;
|
||||
wgpu::Texture texture = device.CreateTexture(&desc);
|
||||
|
||||
// Success, the default is 2D and we give it a 2D view.
|
||||
utils::MakeBindGroup(device, bgl, {{0, texture.CreateView()}});
|
||||
}
|
||||
|
||||
// Check that setting a non-default viewDimension works.
|
||||
{
|
||||
binding.viewDimension = wgpu::TextureViewDimension::e2DArray;
|
||||
wgpu::BindGroupLayout bgl = device.CreateBindGroupLayout(&bglDesc);
|
||||
|
||||
wgpu::TextureDescriptor desc;
|
||||
desc.usage = wgpu::TextureUsage::Sampled;
|
||||
desc.size = {1, 1, 4};
|
||||
desc.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||
desc.dimension = wgpu::TextureDimension::e2D;
|
||||
wgpu::Texture texture = device.CreateTexture(&desc);
|
||||
|
||||
// Success, the view will be 2DArray and the BGL expects a 2DArray.
|
||||
utils::MakeBindGroup(device, bgl, {{0, texture.CreateView()}});
|
||||
}
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(DeprecationTests,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
|
|
Loading…
Reference in New Issue