From 359acd6e95e622a4ad9e400663652d7cf943913b Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Thu, 13 Jul 2017 10:04:23 -0400 Subject: [PATCH] Add row pitch to Texture->Buffer and Buffer->Texture copy commands --- next.json | 6 +++--- src/backend/CommandBuffer.cpp | 6 ++++-- src/backend/CommandBuffer.h | 4 ++-- src/backend/Commands.h | 2 ++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/next.json b/next.json index 0ccad020ac..27f48a4fe2 100644 --- a/next.json +++ b/next.json @@ -278,6 +278,7 @@ "args": [ {"name": "buffer", "type": "buffer"}, {"name": "buffer offset", "type": "uint32_t"}, + {"name": "row pitch", "type": "uint32_t"}, {"name": "texture", "type": "texture"}, {"name": "x", "type": "uint32_t"}, {"name": "y", "type": "uint32_t"}, @@ -291,7 +292,6 @@ "Make pretty with Offset and Extents structures", "Allow choosing the aspect (depth vs. stencil)?", "Add these arguments too", - {"name": "row length", "type": "uint32_t"}, {"name": "image height", "type": "uint32_t"} ] }, @@ -307,13 +307,13 @@ {"name": "depth", "type": "uint32_t"}, {"name": "level", "type": "uint32_t"}, {"name": "buffer", "type": "buffer"}, - {"name": "buffer offset", "type": "uint32_t"} + {"name": "buffer offset", "type": "uint32_t"}, + {"name": "row pitch", "type": "uint32_t"} ], "TODO": [ "Make pretty with Offset and Extents structures", "Allow choosing the aspect (depth vs. stencil)?", "Add these arguments too", - {"name": "row length", "type": "uint32_t"}, {"name": "image height", "type": "uint32_t"} ] }, diff --git a/src/backend/CommandBuffer.cpp b/src/backend/CommandBuffer.cpp index 023dc24140..e5f060f954 100644 --- a/src/backend/CommandBuffer.cpp +++ b/src/backend/CommandBuffer.cpp @@ -630,7 +630,7 @@ namespace backend { copy->size = size; } - void CommandBufferBuilder::CopyBufferToTexture(BufferBase* buffer, uint32_t bufferOffset, + void CommandBufferBuilder::CopyBufferToTexture(BufferBase* buffer, uint32_t bufferOffset, uint32_t rowPitch, TextureBase* texture, uint32_t x, uint32_t y, uint32_t z, uint32_t width, uint32_t height, uint32_t depth, uint32_t level) { CopyBufferToTextureCmd* copy = allocator.Allocate(Command::CopyBufferToTexture); @@ -645,11 +645,12 @@ namespace backend { copy->destination.height = height; copy->destination.depth = depth; copy->destination.level = level; + copy->rowPitch = rowPitch; } void CommandBufferBuilder::CopyTextureToBuffer(TextureBase* texture, uint32_t x, uint32_t y, uint32_t z, uint32_t width, uint32_t height, uint32_t depth, uint32_t level, - BufferBase* buffer, uint32_t bufferOffset) { + BufferBase* buffer, uint32_t bufferOffset, uint32_t rowPitch) { CopyTextureToBufferCmd* copy = allocator.Allocate(Command::CopyTextureToBuffer); new(copy) CopyTextureToBufferCmd; copy->source.texture = texture; @@ -662,6 +663,7 @@ namespace backend { copy->source.level = level; copy->destination.buffer = buffer; copy->destination.offset = bufferOffset; + copy->rowPitch = rowPitch; } void CommandBufferBuilder::Dispatch(uint32_t x, uint32_t y, uint32_t z) { diff --git a/src/backend/CommandBuffer.h b/src/backend/CommandBuffer.h index 019a2fd2e1..eea029058f 100644 --- a/src/backend/CommandBuffer.h +++ b/src/backend/CommandBuffer.h @@ -65,12 +65,12 @@ namespace backend { void BeginRenderPass(RenderPassBase* renderPass, FramebufferBase* framebuffer); void BeginRenderSubpass(); void CopyBufferToBuffer(BufferBase* source, uint32_t sourceOffset, BufferBase* destination, uint32_t destinationOffset, uint32_t size); - void CopyBufferToTexture(BufferBase* buffer, uint32_t bufferOffset, + void CopyBufferToTexture(BufferBase* buffer, uint32_t bufferOffset, uint32_t rowPitch, TextureBase* texture, uint32_t x, uint32_t y, uint32_t z, uint32_t width, uint32_t height, uint32_t depth, uint32_t level); void CopyTextureToBuffer(TextureBase* texture, uint32_t x, uint32_t y, uint32_t z, uint32_t width, uint32_t height, uint32_t depth, uint32_t level, - BufferBase* buffer, uint32_t bufferOffset); + BufferBase* buffer, uint32_t bufferOffset, uint32_t rowPitch); void Dispatch(uint32_t x, uint32_t y, uint32_t z); void DrawArrays(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); void DrawElements(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstIndex, uint32_t firstInstance); diff --git a/src/backend/Commands.h b/src/backend/Commands.h index 0285973513..49715b29ce 100644 --- a/src/backend/Commands.h +++ b/src/backend/Commands.h @@ -83,11 +83,13 @@ namespace backend { struct CopyBufferToTextureCmd { BufferCopyLocation source; TextureCopyLocation destination; + uint32_t rowPitch; }; struct CopyTextureToBufferCmd { TextureCopyLocation source; BufferCopyLocation destination; + uint32_t rowPitch; }; struct DispatchCmd {