diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp index d73eb5dd0c..a31cb95ba8 100644 --- a/examples/ComputeBoids.cpp +++ b/examples/ComputeBoids.cpp @@ -80,8 +80,8 @@ void initBuffers() { for (int i = 0; i < 2; i++) { particleBuffers[i] = device.CreateBufferBuilder() - .SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Vertex | nxt::BufferUsageBit::Storage) - .SetInitialUsage(nxt::BufferUsageBit::MapWrite) + .SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Vertex | nxt::BufferUsageBit::Storage) + .SetInitialUsage(nxt::BufferUsageBit::TransferDst) .SetSize(sizeof(Particle) * kNumParticles) .GetResult(); diff --git a/examples/HelloCompute.cpp b/examples/HelloCompute.cpp index 6d64e1a07d..440bd4e1e4 100644 --- a/examples/HelloCompute.cpp +++ b/examples/HelloCompute.cpp @@ -34,8 +34,8 @@ void init() { struct {uint32_t a; float b;} s; memset(&s, sizeof(s), 0); buffer = device.CreateBufferBuilder() - .SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform | nxt::BufferUsageBit::Storage) - .SetInitialUsage(nxt::BufferUsageBit::MapWrite) + .SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Uniform | nxt::BufferUsageBit::Storage) + .SetInitialUsage(nxt::BufferUsageBit::TransferDst) .SetSize(sizeof(s)) .GetResult(); buffer.SetSubData(0, sizeof(s) / sizeof(uint32_t), reinterpret_cast(&s)); diff --git a/examples/HelloDepthStencil.cpp b/examples/HelloDepthStencil.cpp index 287880f21d..0d66762096 100644 --- a/examples/HelloDepthStencil.cpp +++ b/examples/HelloDepthStencil.cpp @@ -165,8 +165,8 @@ void init() { .GetResult(); cameraBuffer = device.CreateBufferBuilder() - .SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform) - .SetInitialUsage(nxt::BufferUsageBit::MapWrite) + .SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Uniform) + .SetInitialUsage(nxt::BufferUsageBit::TransferDst) .SetSize(sizeof(CameraData)) .GetResult(); @@ -265,7 +265,7 @@ void frame() { glm::vec3(0.0f, 1.0f, 0.0f) ); - cameraBuffer.TransitionUsage(nxt::BufferUsageBit::MapWrite); + cameraBuffer.TransitionUsage(nxt::BufferUsageBit::TransferDst); cameraBuffer.SetSubData(0, sizeof(CameraData) / sizeof(uint32_t), reinterpret_cast(&cameraData)); nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() diff --git a/examples/HelloUBO.cpp b/examples/HelloUBO.cpp index 7ed0672398..06fdca395a 100644 --- a/examples/HelloUBO.cpp +++ b/examples/HelloUBO.cpp @@ -66,8 +66,8 @@ void init() { .GetResult(); buffer = device.CreateBufferBuilder() - .SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform) - .SetInitialUsage(nxt::BufferUsageBit::MapWrite) + .SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Uniform) + .SetInitialUsage(nxt::BufferUsageBit::TransferDst) .SetSize(sizeof(s)) .GetResult(); @@ -87,7 +87,7 @@ void frame() { s.b += 0.02; if (s.b >= 1.0f) {s.b = 0.0f;} - buffer.TransitionUsage(nxt::BufferUsageBit::MapWrite); + buffer.TransitionUsage(nxt::BufferUsageBit::TransferDst); buffer.SetSubData(0, sizeof(s) / sizeof(uint32_t), reinterpret_cast(&s)); nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() diff --git a/examples/Utils.cpp b/examples/Utils.cpp index fc7baa1774..cf129b3716 100644 --- a/examples/Utils.cpp +++ b/examples/Utils.cpp @@ -262,8 +262,8 @@ void CreateDefaultRenderPass(const nxt::Device& device, nxt::RenderPass* renderP nxt::Buffer CreateFrozenBufferFromData(const nxt::Device& device, const void* data, uint32_t size, nxt::BufferUsageBit usage) { nxt::Buffer buffer = device.CreateBufferBuilder() - .SetAllowedUsage(nxt::BufferUsageBit::MapWrite | usage) - .SetInitialUsage(nxt::BufferUsageBit::MapWrite) + .SetAllowedUsage(nxt::BufferUsageBit::TransferDst | usage) + .SetInitialUsage(nxt::BufferUsageBit::TransferDst) .SetSize(size) .GetResult(); buffer.SetSubData(0, size / sizeof(uint32_t), reinterpret_cast(data)); diff --git a/examples/glTFViewer/glTFViewer.cpp b/examples/glTFViewer/glTFViewer.cpp index c6fe580d92..a2a51486d1 100644 --- a/examples/glTFViewer/glTFViewer.cpp +++ b/examples/glTFViewer/glTFViewer.cpp @@ -265,8 +265,8 @@ namespace { .GetResult(); auto uniformBuffer = device.CreateBufferBuilder() - .SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform) - .SetInitialUsage(nxt::BufferUsageBit::MapWrite) + .SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Uniform) + .SetInitialUsage(nxt::BufferUsageBit::TransferDst) .SetSize(sizeof(u_transform_block)) .GetResult(); @@ -489,7 +489,7 @@ namespace { } } const MaterialInfo& material = getMaterial(iPrim.material, strides[0], strides[1], strides[2]); - material.uniformBuffer.TransitionUsage(nxt::BufferUsageBit::MapWrite); + material.uniformBuffer.TransitionUsage(nxt::BufferUsageBit::TransferDst); material.uniformBuffer.SetSubData(0, sizeof(u_transform_block) / sizeof(uint32_t), reinterpret_cast(&transforms)); diff --git a/src/backend/common/Buffer.cpp b/src/backend/common/Buffer.cpp index 8821e5c1da..5fc51154b0 100644 --- a/src/backend/common/Buffer.cpp +++ b/src/backend/common/Buffer.cpp @@ -69,8 +69,8 @@ namespace backend { return; } - if (!(currentUsage & nxt::BufferUsageBit::MapWrite)) { - device->HandleError("Buffer needs the map write usage bit"); + if (!(currentUsage & nxt::BufferUsageBit::TransferDst)) { + device->HandleError("Buffer needs the transfer dst usage bit"); return; } diff --git a/src/backend/null/NullBackend.cpp b/src/backend/null/NullBackend.cpp index 8f05813d21..599a2b708f 100644 --- a/src/backend/null/NullBackend.cpp +++ b/src/backend/null/NullBackend.cpp @@ -116,7 +116,7 @@ namespace null { Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) { - if (GetAllowedUsage() & (nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::MapWrite)) { + if (GetAllowedUsage() & (nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::MapWrite)) { backingData = std::unique_ptr(new char[GetSize()]); } } diff --git a/src/tests/unittests/validation/BufferValidationTests.cpp b/src/tests/unittests/validation/BufferValidationTests.cpp index 723f5a9f70..5048a0cbac 100644 --- a/src/tests/unittests/validation/BufferValidationTests.cpp +++ b/src/tests/unittests/validation/BufferValidationTests.cpp @@ -41,8 +41,8 @@ class BufferValidationTest : public ValidationTest { nxt::Buffer CreateSetSubDataBuffer(uint32_t size) { return device.CreateBufferBuilder() .SetSize(size) - .SetAllowedUsage(nxt::BufferUsageBit::MapWrite) - .SetInitialUsage(nxt::BufferUsageBit::MapWrite) + .SetAllowedUsage(nxt::BufferUsageBit::TransferDst) + .SetInitialUsage(nxt::BufferUsageBit::TransferDst) .GetResult(); } @@ -275,7 +275,7 @@ TEST_F(BufferValidationTest, SetSubDataOutOfBounds) { TEST_F(BufferValidationTest, SetSubDataWrongUsage) { nxt::Buffer buf = device.CreateBufferBuilder() .SetSize(4) - .SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Vertex) + .SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Vertex) .SetInitialUsage(nxt::BufferUsageBit::Vertex) .GetResult();