mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 00:47:13 +00:00
Add T->B copies.
This implements T->B copies on the Metal backend only and while it adds validation tests, end2end tests will be done in a follow-up commit.
This commit is contained in:
committed by
Corentin Wallez
parent
492cbe4a43
commit
e9d347e89e
@@ -209,6 +209,39 @@ namespace metal {
|
||||
}
|
||||
break;
|
||||
|
||||
case Command::CopyTextureToBuffer:
|
||||
{
|
||||
CopyTextureToBufferCmd* copy = commands.NextCommand<CopyTextureToBufferCmd>();
|
||||
auto& src = copy->source;
|
||||
auto& dst = copy->destination;
|
||||
Texture* texture = ToBackend(src.texture.Get());
|
||||
Buffer* buffer = ToBackend(dst.buffer.Get());
|
||||
|
||||
unsigned rowSize = src.width * TextureFormatPixelSize(texture->GetFormat());
|
||||
MTLOrigin origin;
|
||||
origin.x = src.x;
|
||||
origin.y = src.y;
|
||||
origin.z = src.z;
|
||||
|
||||
MTLSize size;
|
||||
size.width = src.width;
|
||||
size.height = src.height;
|
||||
size.depth = src.depth;
|
||||
|
||||
encoders.EnsureBlit(commandBuffer);
|
||||
[encoders.blit
|
||||
copyFromTexture:texture->GetMTLTexture()
|
||||
sourceSlice:0
|
||||
sourceLevel:src.level
|
||||
sourceOrigin:origin
|
||||
sourceSize:size
|
||||
toBuffer:buffer->GetMTLBuffer()
|
||||
destinationOffset:dst.offset
|
||||
destinationBytesPerRow:rowSize
|
||||
destinationBytesPerImage:rowSize * src.height];
|
||||
}
|
||||
break;
|
||||
|
||||
case Command::Dispatch:
|
||||
{
|
||||
DispatchCmd* dispatch = commands.NextCommand<DispatchCmd>();
|
||||
|
||||
Reference in New Issue
Block a user