Update usage of CopyBufferToTexture and CopyTextureToBuffer to include row pitch

This commit is contained in:
Austin Eng 2017-07-13 11:19:14 -04:00 committed by Austin Eng
parent 359acd6e95
commit c5f8e7ae77
5 changed files with 41 additions and 41 deletions

View File

@ -69,7 +69,7 @@ void initTextures() {
nxt::Buffer stagingBuffer = utils::CreateFrozenBufferFromData(device, data.data(), static_cast<uint32_t>(data.size()), nxt::BufferUsageBit::TransferSrc);
nxt::CommandBuffer copy = device.CreateCommandBufferBuilder()
.TransitionTextureUsage(texture, nxt::TextureUsageBit::TransferDst)
.CopyBufferToTexture(stagingBuffer, 0, texture, 0, 0, 0, 1024, 1024, 1, 0)
.CopyBufferToTexture(stagingBuffer, 0, 0, texture, 0, 0, 0, 1024, 1024, 1, 0)
.GetResult();
queue.Submit(1, &copy);

View File

@ -378,7 +378,7 @@ namespace {
nxt::Buffer staging = utils::CreateFrozenBufferFromData(device, &white, sizeof(white), nxt::BufferUsageBit::TransferSrc);
auto cmdbuf = device.CreateCommandBufferBuilder()
.TransitionTextureUsage(oTexture, nxt::TextureUsageBit::TransferDst)
.CopyBufferToTexture(staging, 0, oTexture, 0, 0, 0, 1, 1, 1, 0)
.CopyBufferToTexture(staging, 0, 0, oTexture, 0, 0, 0, 1, 1, 1, 0)
.GetResult();
queue.Submit(1, &cmdbuf);
oTexture.FreezeUsage(nxt::TextureUsageBit::Sampled);
@ -432,7 +432,7 @@ namespace {
nxt::Buffer staging = utils::CreateFrozenBufferFromData(device, data, numPixels * 4, nxt::BufferUsageBit::TransferSrc);
auto cmdbuf = device.CreateCommandBufferBuilder()
.TransitionTextureUsage(oTexture, nxt::TextureUsageBit::TransferDst)
.CopyBufferToTexture(staging, 0, oTexture, 0, 0, 0, iImage.width, iImage.height, 1, 0)
.CopyBufferToTexture(staging, 0, 0, oTexture, 0, 0, 0, iImage.width, iImage.height, 1, 0)
.GetResult();
queue.Submit(1, &cmdbuf);
oTexture.FreezeUsage(nxt::TextureUsageBit::Sampled);

View File

@ -172,7 +172,7 @@ void NXTTest::AddTextureExpectation(const char* file, int line, const nxt::Textu
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
.TransitionTextureUsage(source, nxt::TextureUsageBit::TransferSrc)
.TransitionBufferUsage(readback.buffer, nxt::BufferUsageBit::TransferDst)
.CopyTextureToBuffer(source, x, y, 0, width, height, 1, 0, readback.buffer, readback.offset)
.CopyTextureToBuffer(source, x, y, 0, width, height, 1, 0, readback.buffer, readback.offset, 0)
.GetResult();
queue.Submit(1, &commands);

View File

@ -48,7 +48,7 @@ TEST_P(BasicTests, ReadPixelsTest) {
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
.TransitionTextureUsage(texture, nxt::TextureUsageBit::TransferDst)
.CopyBufferToTexture(buffer, 0, texture, 0, 0, 0, 1, 1, 1, 0)
.CopyBufferToTexture(buffer, 0, 0, texture, 0, 0, 0, 1, 1, 1, 0)
.GetResult();
queue.Submit(1, &commands);
@ -82,11 +82,11 @@ TEST_P(BasicTests, Buffer2Texture2Buffer) {
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
.TransitionTextureUsage(texture, nxt::TextureUsageBit::TransferDst)
.CopyBufferToTexture(srcBuffer, 0, texture, 0, 0, 0, kSize, kSize, 1, 0)
.CopyBufferToTexture(srcBuffer, 0, 0, texture, 0, 0, 0, kSize, kSize, 1, 0)
.TransitionTextureUsage(texture, nxt::TextureUsageBit::TransferSrc)
.TransitionBufferUsage(dstBuffer, nxt::BufferUsageBit::TransferDst)
.CopyTextureToBuffer(texture, 0, 0, 0, kSize, kSize, 1, 0, dstBuffer, 0)
.CopyTextureToBuffer(texture, 0, 0, 0, kSize, kSize, 1, 0, dstBuffer, 0, 0)
.GetResult();

View File

@ -122,13 +122,13 @@ TEST_F(CopyCommandTest_B2T, Success) {
{
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// Copy 4x4 block in corner of first mip.
.CopyBufferToTexture(source, 0, destination, 0, 0, 0, 4, 4, 1, 0)
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 4, 4, 1, 0)
// Copy 4x4 block in opposite corner of first mip.
.CopyBufferToTexture(source, 0, destination, 12, 12, 0, 4, 4, 1, 0)
.CopyBufferToTexture(source, 0, 0, destination, 12, 12, 0, 4, 4, 1, 0)
// Copy 4x4 block in the 4x4 mip.
.CopyBufferToTexture(source, 0, destination, 0, 0, 0, 4, 4, 1, 2)
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 4, 4, 1, 2)
// Copy with a buffer offset
.CopyBufferToTexture(source, 15 * 4, destination, 0, 0, 0, 1, 1, 1, 4)
.CopyBufferToTexture(source, 15 * 4, 0, destination, 0, 0, 0, 1, 1, 1, 4)
.GetResult();
}
@ -136,11 +136,11 @@ TEST_F(CopyCommandTest_B2T, Success) {
{
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// An empty copy
.CopyBufferToTexture(source, 0, destination, 0, 0, 0, 0, 0, 1, 0)
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 1, 0)
// An empty copy touching the end of the buffer
.CopyBufferToTexture(source, 16 * 4, destination, 0, 0, 0, 0, 0, 1, 0)
.CopyBufferToTexture(source, 16 * 4, 0, destination, 0, 0, 0, 0, 0, 1, 0)
// An empty copy touching the side of the texture
.CopyBufferToTexture(source, 0, destination, 16, 16, 0, 0, 0, 1, 0)
.CopyBufferToTexture(source, 0, 0, destination, 16, 16, 0, 0, 0, 1, 0)
.GetResult();
}
}
@ -154,14 +154,14 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
// OOB on the buffer because we copy too many pixels
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, destination, 0, 0, 0, 4, 5, 1, 0)
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 4, 5, 1, 0)
.GetResult();
}
// OOB on the buffer because of the offset
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 1, destination, 0, 0, 0, 4, 4, 1, 0)
.CopyBufferToTexture(source, 1, 0, destination, 0, 0, 0, 4, 4, 1, 0)
.GetResult();
}
}
@ -175,28 +175,28 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) {
// OOB on the texture because x + width overflows
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, destination, 13, 12, 0, 4, 4, 1, 0)
.CopyBufferToTexture(source, 0, 0, destination, 13, 12, 0, 4, 4, 1, 0)
.GetResult();
}
// OOB on the texture because y + width overflows
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, destination, 12, 13, 0, 4, 4, 1, 0)
.CopyBufferToTexture(source, 0, 0, destination, 12, 13, 0, 4, 4, 1, 0)
.GetResult();
}
// OOB on the texture because we overflow a non-zero mip
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, destination, 1, 0, 0, 4, 4, 1, 2)
.CopyBufferToTexture(source, 0, 0, destination, 1, 0, 0, 4, 4, 1, 2)
.GetResult();
}
// OOB on the texture even on an empty copy when we copy to a non-existent mip.
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, destination, 0, 0, 0, 0, 0, 1, 5)
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 1, 5)
.GetResult();
}
}
@ -210,14 +210,14 @@ TEST_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) {
// Z=1 on an empty copy still errors
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, destination, 0, 0, 1, 0, 0, 1, 0)
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 1, 0, 0, 1, 0)
.GetResult();
}
// Depth=0 on an empty copy still errors
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, destination, 0, 0, 0, 0, 0, 0, 0)
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 0, 0)
.GetResult();
}
}
@ -234,14 +234,14 @@ TEST_F(CopyCommandTest_B2T, IncorrectUsage) {
// Incorrect source usage
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(vertex, 0, destination, 0, 0, 0, 4, 4, 1, 0)
.CopyBufferToTexture(vertex, 0, 0, destination, 0, 0, 0, 4, 4, 1, 0)
.GetResult();
}
// Incorrect destination usage
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, sampled, 0, 0, 0, 4, 4, 1, 0)
.CopyBufferToTexture(source, 0, 0, sampled, 0, 0, 0, 4, 4, 1, 0)
.GetResult();
}
}
@ -259,13 +259,13 @@ TEST_F(CopyCommandTest_T2B, Success) {
{
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// Copy from 4x4 block in corner of first mip.
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 0)
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 0, 0)
// Copy from 4x4 block in opposite corner of first mip.
.CopyTextureToBuffer(source, 12, 12, 0, 4, 4, 1, 0, destination, 0)
.CopyTextureToBuffer(source, 12, 12, 0, 4, 4, 1, 0, destination, 0, 0)
// Copy from 4x4 block in the 4x4 mip.
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 2, destination, 0)
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 2, destination, 0, 0)
// Copy with a buffer offset
.CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 4, destination, 15 * 4)
.CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 4, destination, 15 * 4, 0)
.GetResult();
}
@ -273,11 +273,11 @@ TEST_F(CopyCommandTest_T2B, Success) {
{
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// An empty copy
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 0, destination, 0)
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 0, destination, 0, 0)
// An empty copy touching the end of the buffer
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 0, destination, 16 * 4)
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 0, destination, 16 * 4, 0)
// An empty copy touching the side of the texture
.CopyTextureToBuffer(source, 16, 16, 0, 0, 0, 1, 0, destination, 0)
.CopyTextureToBuffer(source, 16, 16, 0, 0, 0, 1, 0, destination, 0, 0)
.GetResult();
}
}
@ -291,28 +291,28 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
// OOB on the texture because x + width overflows
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 13, 12, 0, 4, 4, 1, 0, destination, 0)
.CopyTextureToBuffer(source, 13, 12, 0, 4, 4, 1, 0, destination, 0, 0)
.GetResult();
}
// OOB on the texture because y + width overflows
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 12, 13, 0, 4, 4, 1, 0, destination, 0)
.CopyTextureToBuffer(source, 12, 13, 0, 4, 4, 1, 0, destination, 0, 0)
.GetResult();
}
// OOB on the texture because we overflow a non-zero mip
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 1, 0, 0, 4, 4, 1, 2, destination, 0)
.CopyTextureToBuffer(source, 1, 0, 0, 4, 4, 1, 2, destination, 0, 0)
.GetResult();
}
// OOB on the texture even on an empty copy when we copy from a non-existent mip.
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 5, destination, 0)
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 5, destination, 0, 0)
.GetResult();
}
}
@ -326,14 +326,14 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
// OOB on the buffer because we copy too many pixels
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 4, 5, 1, 0, destination, 0)
.CopyTextureToBuffer(source, 0, 0, 0, 4, 5, 1, 0, destination, 0, 0)
.GetResult();
}
// OOB on the buffer because of the offset
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 1)
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 1, 0)
.GetResult();
}
}
@ -347,14 +347,14 @@ TEST_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) {
// Z=1 on an empty copy still errors
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 1, 0, 0, 1, 0, destination, 0)
.CopyTextureToBuffer(source, 0, 0, 1, 0, 0, 1, 0, destination, 0, 0)
.GetResult();
}
// Depth=0 on an empty copy still errors
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 0, 0, destination, 0)
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 0, 0, destination, 0, 0)
.GetResult();
}
}
@ -371,14 +371,14 @@ TEST_F(CopyCommandTest_T2B, IncorrectUsage) {
// Incorrect source usage
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(sampled, 0, 0, 0, 4, 4, 1, 0, destination, 0)
.CopyTextureToBuffer(sampled, 0, 0, 0, 4, 4, 1, 0, destination, 0, 0)
.GetResult();
}
// Incorrect destination usage
{
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, vertex, 0)
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, vertex, 0, 0)
.GetResult();
}
}