Implement 3D texture read/write via storage usage on D3D12

The main part of this change is to add a few end2end tests, with
some renaming stuff like arrayLayerCount to sliceCount in order to
include both 2DArray and 3D textures.

The implementation is quite simple: just set UAV descriptor on D3D12.

The new tests can pass on Vulkan and Metal, which indicates the
implementation has been done on them.

The new tests fail on OpenGL and OpenGLES. I will take a look and
submit separate patch for GL and GLES.

Bug: dawn:547

Change-Id: Ic03eab6b06654c48341c935f64f4885be544985c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57160
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Yunchao He
2021-07-08 23:33:37 +00:00
committed by Dawn LUCI CQ
parent c5aae6e095
commit 3185d9ce1f
2 changed files with 254 additions and 96 deletions

View File

@@ -1182,11 +1182,30 @@ namespace dawn_native { namespace d3d12 {
uavDesc.Format = GetD3D12Format();
ASSERT(!GetTexture()->IsMultisampledTexture());
uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
uavDesc.Texture2DArray.FirstArraySlice = GetBaseArrayLayer();
uavDesc.Texture2DArray.ArraySize = GetLayerCount();
uavDesc.Texture2DArray.MipSlice = GetBaseMipLevel();
uavDesc.Texture2DArray.PlaneSlice = 0;
switch (GetDimension()) {
case wgpu::TextureViewDimension::e2D:
case wgpu::TextureViewDimension::e2DArray:
uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
uavDesc.Texture2DArray.FirstArraySlice = GetBaseArrayLayer();
uavDesc.Texture2DArray.ArraySize = GetLayerCount();
uavDesc.Texture2DArray.MipSlice = GetBaseMipLevel();
uavDesc.Texture2DArray.PlaneSlice = 0;
break;
case wgpu::TextureViewDimension::e3D:
uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D;
uavDesc.Texture3D.FirstWSlice = 0;
uavDesc.Texture3D.WSize = GetTexture()->GetDepth() >> GetBaseMipLevel();
uavDesc.Texture3D.MipSlice = GetBaseMipLevel();
break;
// TODO(crbug.com/dawn/814): support 1D textures.
case wgpu::TextureViewDimension::e1D:
// Cube and Cubemap can't be used as storage texture. So there is no need to create UAV
// descriptor for them.
case wgpu::TextureViewDimension::Cube:
case wgpu::TextureViewDimension::CubeArray:
case wgpu::TextureViewDimension::Undefined:
UNREACHABLE();
}
return uavDesc;
}