mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 07:36:15 +00:00
Implementing Queue::WriteTexture in Metal
Added implementation of writeTexture in Metal. It's using a staging buffer instead of writing directly from the CPU to the texture, because Dawn uses the private storage mode for most of the Metal textures. Bug: dawn:483 Change-Id: I6b85ee8bbe343881337bdb203a122dc1f1523177 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24581 Commit-Queue: Tomek Ponitka <tommek@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
212c5bd9b2
commit
9d66c5353f
@@ -269,9 +269,7 @@ namespace utils {
|
||||
uint32_t rowsPerImage) {
|
||||
wgpu::BufferCopyView bufferCopyView = {};
|
||||
bufferCopyView.buffer = buffer;
|
||||
bufferCopyView.layout.offset = offset;
|
||||
bufferCopyView.layout.bytesPerRow = bytesPerRow;
|
||||
bufferCopyView.layout.rowsPerImage = rowsPerImage;
|
||||
bufferCopyView.layout = CreateTextureDataLayout(offset, bytesPerRow, rowsPerImage);
|
||||
|
||||
return bufferCopyView;
|
||||
}
|
||||
@@ -287,6 +285,17 @@ namespace utils {
|
||||
return textureCopyView;
|
||||
}
|
||||
|
||||
wgpu::TextureDataLayout CreateTextureDataLayout(uint64_t offset,
|
||||
uint32_t bytesPerRow,
|
||||
uint32_t rowsPerImage) {
|
||||
wgpu::TextureDataLayout textureDataLayout;
|
||||
textureDataLayout.offset = offset;
|
||||
textureDataLayout.bytesPerRow = bytesPerRow;
|
||||
textureDataLayout.rowsPerImage = rowsPerImage;
|
||||
|
||||
return textureDataLayout;
|
||||
}
|
||||
|
||||
wgpu::SamplerDescriptor GetDefaultSamplerDescriptor() {
|
||||
wgpu::SamplerDescriptor desc = {};
|
||||
|
||||
@@ -391,12 +400,12 @@ namespace utils {
|
||||
}
|
||||
|
||||
// TODO(jiawei.shao@intel.com): support compressed texture formats
|
||||
BufferTextureCopyLayout GetBufferTextureCopyLayoutForTexture2DAtLevel(
|
||||
TextureDataCopyLayout GetTextureDataCopyLayoutForTexture2DAtLevel(
|
||||
wgpu::TextureFormat format,
|
||||
wgpu::Extent3D textureSizeAtLevel0,
|
||||
uint32_t mipmapLevel,
|
||||
uint32_t rowsPerImage) {
|
||||
BufferTextureCopyLayout layout;
|
||||
TextureDataCopyLayout layout;
|
||||
|
||||
layout.mipSize = {textureSizeAtLevel0.width >> mipmapLevel,
|
||||
textureSizeAtLevel0.height >> mipmapLevel, textureSizeAtLevel0.depth};
|
||||
|
||||
@@ -55,6 +55,9 @@ namespace utils {
|
||||
wgpu::TextureCopyView CreateTextureCopyView(wgpu::Texture texture,
|
||||
uint32_t level,
|
||||
wgpu::Origin3D origin);
|
||||
wgpu::TextureDataLayout CreateTextureDataLayout(uint64_t offset,
|
||||
uint32_t bytesPerRow,
|
||||
uint32_t rowsPerImage);
|
||||
|
||||
struct ComboRenderPassDescriptor : public wgpu::RenderPassDescriptor {
|
||||
public:
|
||||
@@ -130,7 +133,7 @@ namespace utils {
|
||||
const wgpu::BindGroupLayout& layout,
|
||||
std::initializer_list<BindingInitializationHelper> entriesInitializer);
|
||||
|
||||
struct BufferTextureCopyLayout {
|
||||
struct TextureDataCopyLayout {
|
||||
uint64_t byteLength;
|
||||
uint64_t texelBlockCount;
|
||||
uint32_t bytesPerRow;
|
||||
@@ -146,7 +149,7 @@ namespace utils {
|
||||
uint32_t bytesPerRow,
|
||||
uint32_t rowsPerImage,
|
||||
uint32_t copyArrayLayerCount);
|
||||
BufferTextureCopyLayout GetBufferTextureCopyLayoutForTexture2DAtLevel(
|
||||
TextureDataCopyLayout GetTextureDataCopyLayoutForTexture2DAtLevel(
|
||||
wgpu::TextureFormat format,
|
||||
wgpu::Extent3D textureSizeAtLevel0,
|
||||
uint32_t mipmapLevel,
|
||||
|
||||
Reference in New Issue
Block a user