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++) {
|
||||
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();
|
||||
|
||||
|
|
|
@ -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<uint32_t*>(&s));
|
||||
|
|
|
@ -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<uint32_t*>(&cameraData));
|
||||
|
||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||
|
|
|
@ -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<uint32_t*>(&s));
|
||||
|
||||
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 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<const uint32_t*>(data));
|
||||
|
|
|
@ -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<const uint32_t*>(&transforms));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<char[]>(new char[GetSize()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue