Change usage requirements for Buffer::SetSubData to require TransferDst
instead of MapWrite bit
This commit is contained in:
parent
5c92537418
commit
39c901d3dc
|
@ -80,8 +80,8 @@ void initBuffers() {
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
particleBuffers[i] = device.CreateBufferBuilder()
|
particleBuffers[i] = device.CreateBufferBuilder()
|
||||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Vertex | nxt::BufferUsageBit::Storage)
|
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Vertex | nxt::BufferUsageBit::Storage)
|
||||||
.SetInitialUsage(nxt::BufferUsageBit::MapWrite)
|
.SetInitialUsage(nxt::BufferUsageBit::TransferDst)
|
||||||
.SetSize(sizeof(Particle) * kNumParticles)
|
.SetSize(sizeof(Particle) * kNumParticles)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ void init() {
|
||||||
struct {uint32_t a; float b;} s;
|
struct {uint32_t a; float b;} s;
|
||||||
memset(&s, sizeof(s), 0);
|
memset(&s, sizeof(s), 0);
|
||||||
buffer = device.CreateBufferBuilder()
|
buffer = device.CreateBufferBuilder()
|
||||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform | nxt::BufferUsageBit::Storage)
|
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Uniform | nxt::BufferUsageBit::Storage)
|
||||||
.SetInitialUsage(nxt::BufferUsageBit::MapWrite)
|
.SetInitialUsage(nxt::BufferUsageBit::TransferDst)
|
||||||
.SetSize(sizeof(s))
|
.SetSize(sizeof(s))
|
||||||
.GetResult();
|
.GetResult();
|
||||||
buffer.SetSubData(0, sizeof(s) / sizeof(uint32_t), reinterpret_cast<uint32_t*>(&s));
|
buffer.SetSubData(0, sizeof(s) / sizeof(uint32_t), reinterpret_cast<uint32_t*>(&s));
|
||||||
|
|
|
@ -165,8 +165,8 @@ void init() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
cameraBuffer = device.CreateBufferBuilder()
|
cameraBuffer = device.CreateBufferBuilder()
|
||||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform)
|
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Uniform)
|
||||||
.SetInitialUsage(nxt::BufferUsageBit::MapWrite)
|
.SetInitialUsage(nxt::BufferUsageBit::TransferDst)
|
||||||
.SetSize(sizeof(CameraData))
|
.SetSize(sizeof(CameraData))
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ void frame() {
|
||||||
glm::vec3(0.0f, 1.0f, 0.0f)
|
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<uint32_t*>(&cameraData));
|
cameraBuffer.SetSubData(0, sizeof(CameraData) / sizeof(uint32_t), reinterpret_cast<uint32_t*>(&cameraData));
|
||||||
|
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
|
|
|
@ -66,8 +66,8 @@ void init() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
buffer = device.CreateBufferBuilder()
|
buffer = device.CreateBufferBuilder()
|
||||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform)
|
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Uniform)
|
||||||
.SetInitialUsage(nxt::BufferUsageBit::MapWrite)
|
.SetInitialUsage(nxt::BufferUsageBit::TransferDst)
|
||||||
.SetSize(sizeof(s))
|
.SetSize(sizeof(s))
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void frame() {
|
||||||
s.b += 0.02;
|
s.b += 0.02;
|
||||||
if (s.b >= 1.0f) {s.b = 0.0f;}
|
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<uint32_t*>(&s));
|
buffer.SetSubData(0, sizeof(s) / sizeof(uint32_t), reinterpret_cast<uint32_t*>(&s));
|
||||||
|
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
|
|
|
@ -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 CreateFrozenBufferFromData(const nxt::Device& device, const void* data, uint32_t size, nxt::BufferUsageBit usage) {
|
||||||
nxt::Buffer buffer = device.CreateBufferBuilder()
|
nxt::Buffer buffer = device.CreateBufferBuilder()
|
||||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | usage)
|
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | usage)
|
||||||
.SetInitialUsage(nxt::BufferUsageBit::MapWrite)
|
.SetInitialUsage(nxt::BufferUsageBit::TransferDst)
|
||||||
.SetSize(size)
|
.SetSize(size)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
buffer.SetSubData(0, size / sizeof(uint32_t), reinterpret_cast<const uint32_t*>(data));
|
buffer.SetSubData(0, size / sizeof(uint32_t), reinterpret_cast<const uint32_t*>(data));
|
||||||
|
|
|
@ -265,8 +265,8 @@ namespace {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
auto uniformBuffer = device.CreateBufferBuilder()
|
auto uniformBuffer = device.CreateBufferBuilder()
|
||||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform)
|
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Uniform)
|
||||||
.SetInitialUsage(nxt::BufferUsageBit::MapWrite)
|
.SetInitialUsage(nxt::BufferUsageBit::TransferDst)
|
||||||
.SetSize(sizeof(u_transform_block))
|
.SetSize(sizeof(u_transform_block))
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const MaterialInfo& material = getMaterial(iPrim.material, strides[0], strides[1], strides[2]);
|
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,
|
material.uniformBuffer.SetSubData(0,
|
||||||
sizeof(u_transform_block) / sizeof(uint32_t),
|
sizeof(u_transform_block) / sizeof(uint32_t),
|
||||||
reinterpret_cast<const uint32_t*>(&transforms));
|
reinterpret_cast<const uint32_t*>(&transforms));
|
||||||
|
|
|
@ -69,8 +69,8 @@ namespace backend {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(currentUsage & nxt::BufferUsageBit::MapWrite)) {
|
if (!(currentUsage & nxt::BufferUsageBit::TransferDst)) {
|
||||||
device->HandleError("Buffer needs the map write usage bit");
|
device->HandleError("Buffer needs the transfer dst usage bit");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace null {
|
||||||
|
|
||||||
Buffer::Buffer(BufferBuilder* builder)
|
Buffer::Buffer(BufferBuilder* builder)
|
||||||
: BufferBase(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<char[]>(new char[GetSize()]);
|
backingData = std::unique_ptr<char[]>(new char[GetSize()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ class BufferValidationTest : public ValidationTest {
|
||||||
nxt::Buffer CreateSetSubDataBuffer(uint32_t size) {
|
nxt::Buffer CreateSetSubDataBuffer(uint32_t size) {
|
||||||
return device.CreateBufferBuilder()
|
return device.CreateBufferBuilder()
|
||||||
.SetSize(size)
|
.SetSize(size)
|
||||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite)
|
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst)
|
||||||
.SetInitialUsage(nxt::BufferUsageBit::MapWrite)
|
.SetInitialUsage(nxt::BufferUsageBit::TransferDst)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ TEST_F(BufferValidationTest, SetSubDataOutOfBounds) {
|
||||||
TEST_F(BufferValidationTest, SetSubDataWrongUsage) {
|
TEST_F(BufferValidationTest, SetSubDataWrongUsage) {
|
||||||
nxt::Buffer buf = device.CreateBufferBuilder()
|
nxt::Buffer buf = device.CreateBufferBuilder()
|
||||||
.SetSize(4)
|
.SetSize(4)
|
||||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Vertex)
|
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::Vertex)
|
||||||
.SetInitialUsage(nxt::BufferUsageBit::Vertex)
|
.SetInitialUsage(nxt::BufferUsageBit::Vertex)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue