Clean up CopyTests
This patch does several clean-ups in CopyTests as a preparation of supporting buffer-to-texture and texture-to-buffer copies with multiple texture array layers. 1. Remove the zero-initialization of textures in CopyTests_B2T 2. Use a big buffer that contains the pixel data in all the texture array layers instead of several small ones that only contains one texture array layer. 3. Make CopyTests_T2T::DoTest() also use CopyTests::TextureSpec as its input parameter. 4. Add tests for the copies with multiple texture array layers. In this patch we just copy the data once per texture array layer, while in the next patch we will be able to copy the data for all the related texture array layers in one copy command. 5. Move some helper functions for copy tests to WGPUHelpers.cpp BUG=dawn:453 TEST=dawn_end2end_tests Change-Id: Ia0150a6c55fffce3e24dda2cd45fd920b0873dc9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23120 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
fefb452f29
commit
59cfe3ea03
File diff suppressed because it is too large
Load Diff
|
@ -17,6 +17,8 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Log.h"
|
#include "common/Log.h"
|
||||||
|
#include "common/Math.h"
|
||||||
|
#include "utils/TextureFormatUtils.h"
|
||||||
|
|
||||||
#include <shaderc/shaderc.hpp>
|
#include <shaderc/shaderc.hpp>
|
||||||
|
|
||||||
|
@ -372,4 +374,44 @@ namespace utils {
|
||||||
return device.CreateBindGroup(&descriptor);
|
return device.CreateBindGroup(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t GetMinimumBytesPerRow(wgpu::TextureFormat format, uint32_t width) {
|
||||||
|
const uint32_t bytesPerTexel = utils::GetTexelBlockSizeInBytes(format);
|
||||||
|
return Align(bytesPerTexel * width, kTextureBytesPerRowAlignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t GetBytesInBufferTextureCopy(wgpu::TextureFormat format,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t bytesPerRow,
|
||||||
|
uint32_t rowsPerImage,
|
||||||
|
uint32_t copyArrayLayerCount) {
|
||||||
|
const uint32_t bytesPerTexel = utils::GetTexelBlockSizeInBytes(format);
|
||||||
|
const uint32_t bytesAtLastImage = bytesPerRow * (rowsPerImage - 1) + bytesPerTexel * width;
|
||||||
|
return bytesPerRow * rowsPerImage * (copyArrayLayerCount - 1) + bytesAtLastImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(jiawei.shao@intel.com): support compressed texture formats
|
||||||
|
BufferTextureCopyLayout GetBufferTextureCopyLayoutForTexture2DAtLevel(
|
||||||
|
wgpu::TextureFormat format,
|
||||||
|
wgpu::Extent3D textureSizeAtLevel0,
|
||||||
|
uint32_t mipmapLevel,
|
||||||
|
uint32_t rowsPerImage) {
|
||||||
|
BufferTextureCopyLayout layout;
|
||||||
|
|
||||||
|
layout.mipSize = {textureSizeAtLevel0.width >> mipmapLevel,
|
||||||
|
textureSizeAtLevel0.height >> mipmapLevel, textureSizeAtLevel0.depth};
|
||||||
|
|
||||||
|
layout.bytesPerRow = GetMinimumBytesPerRow(format, layout.mipSize.width);
|
||||||
|
layout.bytesPerImage = layout.bytesPerRow * rowsPerImage;
|
||||||
|
|
||||||
|
layout.byteLength =
|
||||||
|
GetBytesInBufferTextureCopy(format, layout.mipSize.width, layout.bytesPerRow,
|
||||||
|
layout.mipSize.height, textureSizeAtLevel0.depth);
|
||||||
|
|
||||||
|
const uint32_t bytesPerTexel = utils::GetTexelBlockSizeInBytes(format);
|
||||||
|
layout.texelBlocksPerRow = layout.bytesPerRow / bytesPerTexel;
|
||||||
|
layout.texelBlocksPerImage = layout.bytesPerImage / bytesPerTexel;
|
||||||
|
layout.texelBlockCount = layout.byteLength / bytesPerTexel;
|
||||||
|
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
|
@ -129,6 +129,28 @@ namespace utils {
|
||||||
const wgpu::BindGroupLayout& layout,
|
const wgpu::BindGroupLayout& layout,
|
||||||
std::initializer_list<BindingInitializationHelper> entriesInitializer);
|
std::initializer_list<BindingInitializationHelper> entriesInitializer);
|
||||||
|
|
||||||
|
struct BufferTextureCopyLayout {
|
||||||
|
uint64_t byteLength;
|
||||||
|
uint64_t texelBlockCount;
|
||||||
|
uint32_t bytesPerRow;
|
||||||
|
uint32_t texelBlocksPerRow;
|
||||||
|
uint32_t bytesPerImage;
|
||||||
|
uint32_t texelBlocksPerImage;
|
||||||
|
wgpu::Extent3D mipSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t GetMinimumBytesPerRow(wgpu::TextureFormat format, uint32_t width);
|
||||||
|
uint32_t GetBytesInBufferTextureCopy(wgpu::TextureFormat format,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t bytesPerRow,
|
||||||
|
uint32_t rowsPerImage,
|
||||||
|
uint32_t copyArrayLayerCount);
|
||||||
|
BufferTextureCopyLayout GetBufferTextureCopyLayoutForTexture2DAtLevel(
|
||||||
|
wgpu::TextureFormat format,
|
||||||
|
wgpu::Extent3D textureSizeAtLevel0,
|
||||||
|
uint32_t mipmapLevel,
|
||||||
|
uint32_t rowsPerImage);
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
||||||
#endif // UTILS_DAWNHELPERS_H_
|
#endif // UTILS_DAWNHELPERS_H_
|
||||||
|
|
Loading…
Reference in New Issue