Change setVertexBuffers to setVertexBuffer
Following WebGPU spec change at https://github.com/gpuweb/gpuweb/pull/468, this CL changes all occurrences of setVertexBuffers to setVertexBuffer. Bug: dawn:22 Change-Id: I48b551a89dc0934dfa61e661e9546a2b7eafd2fc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12020 Commit-Queue: François Beaufort <beaufort.francois@gmail.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
e16a901fb8
commit
91b2142ee4
18
dawn.json
18
dawn.json
|
@ -880,12 +880,11 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "set vertex buffers",
|
||||
"name": "set vertex buffer",
|
||||
"args": [
|
||||
{"name": "start slot", "type": "uint32_t"},
|
||||
{"name": "count", "type": "uint32_t"},
|
||||
{"name": "buffers", "type": "buffer", "annotation": "const*", "length": "count"},
|
||||
{"name": "offsets", "type": "uint64_t", "annotation": "const*", "length": "count"}
|
||||
{"name": "slot", "type": "uint32_t"},
|
||||
{"name": "buffer", "type": "buffer"},
|
||||
{"name": "offset", "type": "uint64_t", "default": "0"}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1066,12 +1065,11 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "set vertex buffers",
|
||||
"name": "set vertex buffer",
|
||||
"args": [
|
||||
{"name": "start slot", "type": "uint32_t"},
|
||||
{"name": "count", "type": "uint32_t"},
|
||||
{"name": "buffers", "type": "buffer", "annotation": "const*", "length": "count"},
|
||||
{"name": "offsets", "type": "uint64_t", "annotation": "const*", "length": "count"}
|
||||
{"name": "slot", "type": "uint32_t"},
|
||||
{"name": "buffer", "type": "buffer"},
|
||||
{"name": "offset", "type": "uint64_t", "default": "0"}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -262,7 +262,6 @@ void initSim() {
|
|||
}
|
||||
|
||||
dawn::CommandBuffer createCommandBuffer(const dawn::Texture backbuffer, size_t i) {
|
||||
static const uint64_t zeroOffsets[1] = {0};
|
||||
auto& bufferDst = particleBuffers[(i + 1) % 2];
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
|
@ -278,8 +277,8 @@ dawn::CommandBuffer createCommandBuffer(const dawn::Texture backbuffer, size_t i
|
|||
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(renderPipeline);
|
||||
pass.SetVertexBuffers(0, 1, &bufferDst, zeroOffsets);
|
||||
pass.SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets);
|
||||
pass.SetVertexBuffer(0, bufferDst);
|
||||
pass.SetVertexBuffer(1, modelBuffer);
|
||||
pass.Draw(3, kNumParticles, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
|
|
@ -156,13 +156,12 @@ void frame() {
|
|||
dawn::Texture backbuffer = swapchain.GetNextTexture();
|
||||
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
|
||||
|
||||
static const uint64_t vertexBufferOffsets[1] = {0};
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.DrawIndexed(3, 1, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
|
|
@ -255,7 +255,6 @@ void frame() {
|
|||
s.a = (s.a + 1) % 256;
|
||||
s.b += 0.01f;
|
||||
if (s.b >= 1.0f) {s.b = 0.0f;}
|
||||
static const uint64_t vertexBufferOffsets[1] = {0};
|
||||
|
||||
cameraData.view = glm::lookAt(
|
||||
glm::vec3(8.f * std::sin(glm::radians(s.b * 360.f)), 2.f, 8.f * std::cos(glm::radians(s.b * 360.f))),
|
||||
|
@ -273,18 +272,18 @@ void frame() {
|
|||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup[0]);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.DrawIndexed(36, 1, 0, 0, 0);
|
||||
|
||||
pass.SetStencilReference(0x1);
|
||||
pass.SetPipeline(planePipeline);
|
||||
pass.SetBindGroup(0, bindGroup[0]);
|
||||
pass.SetVertexBuffers(0, 1, &planeBuffer, vertexBufferOffsets);
|
||||
pass.SetVertexBuffer(0, planeBuffer);
|
||||
pass.DrawIndexed(6, 1, 0, 0, 0);
|
||||
|
||||
pass.SetPipeline(reflectionPipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetBindGroup(0, bindGroup[1]);
|
||||
pass.DrawIndexed(36, 1, 0, 0, 0);
|
||||
|
||||
|
|
|
@ -152,10 +152,8 @@ namespace dawn_native {
|
|||
mAspects.set(VALIDATION_ASPECT_INDEX_BUFFER);
|
||||
}
|
||||
|
||||
void CommandBufferStateTracker::SetVertexBuffer(uint32_t start, uint32_t count) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
mInputsSet.set(start + i);
|
||||
}
|
||||
void CommandBufferStateTracker::SetVertexBuffer(uint32_t slot) {
|
||||
mInputsSet.set(slot);
|
||||
}
|
||||
|
||||
void CommandBufferStateTracker::SetPipelineCommon(PipelineBase* pipeline) {
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace dawn_native {
|
|||
void SetRenderPipeline(RenderPipelineBase* pipeline);
|
||||
void SetBindGroup(uint32_t index, BindGroupBase* bindgroup);
|
||||
void SetIndexBuffer();
|
||||
void SetVertexBuffer(uint32_t start, uint32_t count);
|
||||
void SetVertexBuffer(uint32_t slot);
|
||||
|
||||
static constexpr size_t kNumAspects = 4;
|
||||
using ValidationAspects = std::bitset<kNumAspects>;
|
||||
|
|
|
@ -136,15 +136,11 @@ namespace dawn_native {
|
|||
commandBufferState->SetIndexBuffer();
|
||||
} break;
|
||||
|
||||
case Command::SetVertexBuffers: {
|
||||
SetVertexBuffersCmd* cmd = commands->NextCommand<SetVertexBuffersCmd>();
|
||||
auto buffers = commands->NextData<Ref<BufferBase>>(cmd->count);
|
||||
commands->NextData<uint64_t>(cmd->count);
|
||||
case Command::SetVertexBuffer: {
|
||||
SetVertexBufferCmd* cmd = commands->NextCommand<SetVertexBufferCmd>();
|
||||
|
||||
for (uint32_t i = 0; i < cmd->count; ++i) {
|
||||
usageTracker->BufferUsedAs(buffers[i].Get(), dawn::BufferUsage::Vertex);
|
||||
}
|
||||
commandBufferState->SetVertexBuffer(cmd->startSlot, cmd->count);
|
||||
usageTracker->BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsage::Vertex);
|
||||
commandBufferState->SetVertexBuffer(cmd->slot);
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -144,14 +144,9 @@ namespace dawn_native {
|
|||
SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>();
|
||||
cmd->~SetIndexBufferCmd();
|
||||
} break;
|
||||
case Command::SetVertexBuffers: {
|
||||
SetVertexBuffersCmd* cmd = commands->NextCommand<SetVertexBuffersCmd>();
|
||||
auto buffers = commands->NextData<Ref<BufferBase>>(cmd->count);
|
||||
for (size_t i = 0; i < cmd->count; ++i) {
|
||||
(&buffers[i])->~Ref<BufferBase>();
|
||||
}
|
||||
commands->NextData<uint64_t>(cmd->count);
|
||||
cmd->~SetVertexBuffersCmd();
|
||||
case Command::SetVertexBuffer: {
|
||||
SetVertexBufferCmd* cmd = commands->NextCommand<SetVertexBufferCmd>();
|
||||
cmd->~SetVertexBufferCmd();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
@ -267,10 +262,8 @@ namespace dawn_native {
|
|||
commands->NextCommand<SetIndexBufferCmd>();
|
||||
break;
|
||||
|
||||
case Command::SetVertexBuffers: {
|
||||
auto* cmd = commands->NextCommand<SetVertexBuffersCmd>();
|
||||
commands->NextData<Ref<BufferBase>>(cmd->count);
|
||||
commands->NextData<uint64_t>(cmd->count);
|
||||
case Command::SetVertexBuffer: {
|
||||
commands->NextCommand<SetVertexBufferCmd>();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace dawn_native {
|
|||
SetBlendColor,
|
||||
SetBindGroup,
|
||||
SetIndexBuffer,
|
||||
SetVertexBuffers,
|
||||
SetVertexBuffer,
|
||||
};
|
||||
|
||||
struct BeginComputePassCmd {};
|
||||
|
@ -220,9 +220,10 @@ namespace dawn_native {
|
|||
uint64_t offset;
|
||||
};
|
||||
|
||||
struct SetVertexBuffersCmd {
|
||||
uint32_t startSlot;
|
||||
uint32_t count;
|
||||
struct SetVertexBufferCmd {
|
||||
uint32_t slot;
|
||||
Ref<BufferBase> buffer;
|
||||
uint64_t offset;
|
||||
};
|
||||
|
||||
// This needs to be called before the CommandIterator is freed so that the Ref<> present in
|
||||
|
|
|
@ -129,27 +129,15 @@ namespace dawn_native {
|
|||
});
|
||||
}
|
||||
|
||||
void RenderEncoderBase::SetVertexBuffers(uint32_t startSlot,
|
||||
uint32_t count,
|
||||
BufferBase* const* buffers,
|
||||
uint64_t const* offsets) {
|
||||
void RenderEncoderBase::SetVertexBuffer(uint32_t slot, BufferBase* buffer, uint64_t offset) {
|
||||
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(buffers[i]));
|
||||
}
|
||||
DAWN_TRY(GetDevice()->ValidateObject(buffer));
|
||||
|
||||
SetVertexBuffersCmd* cmd =
|
||||
allocator->Allocate<SetVertexBuffersCmd>(Command::SetVertexBuffers);
|
||||
cmd->startSlot = startSlot;
|
||||
cmd->count = count;
|
||||
|
||||
Ref<BufferBase>* cmdBuffers = allocator->AllocateData<Ref<BufferBase>>(count);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
cmdBuffers[i] = buffers[i];
|
||||
}
|
||||
|
||||
uint64_t* cmdOffsets = allocator->AllocateData<uint64_t>(count);
|
||||
memcpy(cmdOffsets, offsets, count * sizeof(uint64_t));
|
||||
SetVertexBufferCmd* cmd =
|
||||
allocator->Allocate<SetVertexBufferCmd>(Command::SetVertexBuffer);
|
||||
cmd->slot = slot;
|
||||
cmd->buffer = buffer;
|
||||
cmd->offset = offset;
|
||||
|
||||
return {};
|
||||
});
|
||||
|
|
|
@ -39,18 +39,7 @@ namespace dawn_native {
|
|||
|
||||
void SetPipeline(RenderPipelineBase* pipeline);
|
||||
|
||||
template <typename T>
|
||||
void SetVertexBuffers(uint32_t startSlot,
|
||||
uint32_t count,
|
||||
T* const* buffers,
|
||||
uint64_t const* offsets) {
|
||||
static_assert(std::is_base_of<BufferBase, T>::value, "");
|
||||
SetVertexBuffers(startSlot, count, buffers, offsets);
|
||||
}
|
||||
void SetVertexBuffers(uint32_t startSlot,
|
||||
uint32_t count,
|
||||
BufferBase* const* buffers,
|
||||
uint64_t const* offsets);
|
||||
void SetVertexBuffer(uint32_t slot, BufferBase* buffer, uint64_t offset);
|
||||
void SetIndexBuffer(BufferBase* buffer, uint64_t offset);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -358,20 +358,14 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
class VertexBufferTracker {
|
||||
public:
|
||||
void OnSetVertexBuffers(uint32_t startSlot,
|
||||
uint32_t count,
|
||||
Ref<BufferBase>* buffers,
|
||||
uint64_t* offsets) {
|
||||
mStartSlot = std::min(mStartSlot, startSlot);
|
||||
mEndSlot = std::max(mEndSlot, startSlot + count);
|
||||
void OnSetVertexBuffer(uint32_t slot, Buffer* buffer, uint64_t offset) {
|
||||
mStartSlot = std::min(mStartSlot, slot);
|
||||
mEndSlot = std::max(mEndSlot, slot + 1);
|
||||
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
Buffer* buffer = ToBackend(buffers[i].Get());
|
||||
auto* d3d12BufferView = &mD3D12BufferViews[startSlot + i];
|
||||
d3d12BufferView->BufferLocation = buffer->GetVA() + offsets[i];
|
||||
d3d12BufferView->SizeInBytes = buffer->GetSize() - offsets[i];
|
||||
// The bufferView stride is set based on the input state before a draw.
|
||||
}
|
||||
auto* d3d12BufferView = &mD3D12BufferViews[slot];
|
||||
d3d12BufferView->BufferLocation = buffer->GetVA() + offset;
|
||||
d3d12BufferView->SizeInBytes = buffer->GetSize() - offset;
|
||||
// The bufferView stride is set based on the input state before a draw.
|
||||
}
|
||||
|
||||
void Apply(ID3D12GraphicsCommandList* commandList,
|
||||
|
@ -402,7 +396,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
}
|
||||
|
||||
// mD3D12BufferViews is kept up to date with the most recent data passed
|
||||
// to SetVertexBuffers. This makes it correct to only track the start
|
||||
// to SetVertexBuffer. This makes it correct to only track the start
|
||||
// and end of the dirty range. When Apply is called,
|
||||
// we will at worst set non-dirty vertex buffers in duplicate.
|
||||
uint32_t count = endSlot - startSlot;
|
||||
|
@ -414,7 +408,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
private:
|
||||
// startSlot and endSlot indicate the range of dirty vertex buffers.
|
||||
// If there are multiple calls to SetVertexBuffers, the start and end
|
||||
// If there are multiple calls to SetVertexBuffer, the start and end
|
||||
// represent the union of the dirty ranges (the union may have non-dirty
|
||||
// data in the middle of the range).
|
||||
const RenderPipeline* mLastAppliedRenderPipeline = nullptr;
|
||||
|
@ -1133,13 +1127,11 @@ namespace dawn_native { namespace d3d12 {
|
|||
indexBufferTracker.OnSetIndexBuffer(ToBackend(cmd->buffer.Get()), cmd->offset);
|
||||
} break;
|
||||
|
||||
case Command::SetVertexBuffers: {
|
||||
SetVertexBuffersCmd* cmd = iter->NextCommand<SetVertexBuffersCmd>();
|
||||
Ref<BufferBase>* buffers = iter->NextData<Ref<BufferBase>>(cmd->count);
|
||||
uint64_t* offsets = iter->NextData<uint64_t>(cmd->count);
|
||||
case Command::SetVertexBuffer: {
|
||||
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
|
||||
|
||||
vertexBufferTracker.OnSetVertexBuffers(cmd->startSlot, cmd->count, buffers,
|
||||
offsets);
|
||||
vertexBufferTracker.OnSetVertexBuffer(cmd->slot, ToBackend(cmd->buffer.Get()),
|
||||
cmd->offset);
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -550,19 +550,13 @@ namespace dawn_native { namespace metal {
|
|||
// all the relevant state.
|
||||
class VertexInputBufferTracker {
|
||||
public:
|
||||
void OnSetVertexBuffers(uint32_t startSlot,
|
||||
uint32_t count,
|
||||
const Ref<BufferBase>* buffers,
|
||||
const uint64_t* offsets) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
uint32_t slot = startSlot + i;
|
||||
mVertexBuffers[slot] = ToBackend(buffers[i].Get())->GetMTLBuffer();
|
||||
mVertexBufferOffsets[slot] = offsets[i];
|
||||
}
|
||||
void OnSetVertexBuffer(uint32_t slot, Buffer* buffer, uint64_t offset) {
|
||||
mVertexBuffers[slot] = buffer->GetMTLBuffer();
|
||||
mVertexBufferOffsets[slot] = offset;
|
||||
|
||||
// Use 64 bit masks and make sure there are no shift UB
|
||||
static_assert(kMaxVertexBuffers <= 8 * sizeof(unsigned long long) - 1, "");
|
||||
mDirtyVertexBuffers |= ((1ull << count) - 1ull) << startSlot;
|
||||
mDirtyVertexBuffers |= 1ull << slot;
|
||||
}
|
||||
|
||||
void OnSetPipeline(RenderPipeline* lastPipeline, RenderPipeline* pipeline) {
|
||||
|
@ -1047,13 +1041,11 @@ namespace dawn_native { namespace metal {
|
|||
indexBufferBaseOffset = cmd->offset;
|
||||
} break;
|
||||
|
||||
case Command::SetVertexBuffers: {
|
||||
SetVertexBuffersCmd* cmd = iter->NextCommand<SetVertexBuffersCmd>();
|
||||
const Ref<BufferBase>* buffers = iter->NextData<Ref<BufferBase>>(cmd->count);
|
||||
const uint64_t* offsets = iter->NextData<uint64_t>(cmd->count);
|
||||
case Command::SetVertexBuffer: {
|
||||
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
|
||||
|
||||
vertexInputBuffers.OnSetVertexBuffers(cmd->startSlot, cmd->count, buffers,
|
||||
offsets);
|
||||
vertexInputBuffers.OnSetVertexBuffer(cmd->slot, ToBackend(cmd->buffer.Get()),
|
||||
cmd->offset);
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -142,19 +142,13 @@ namespace dawn_native { namespace opengl {
|
|||
mIndexBuffer = ToBackend(buffer);
|
||||
}
|
||||
|
||||
void OnSetVertexBuffers(uint32_t startSlot,
|
||||
uint32_t count,
|
||||
Ref<BufferBase>* buffers,
|
||||
uint64_t* offsets) {
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
uint32_t slot = startSlot + i;
|
||||
mVertexBuffers[slot] = ToBackend(buffers[i].Get());
|
||||
mVertexBufferOffsets[slot] = offsets[i];
|
||||
}
|
||||
void OnSetVertexBuffer(uint32_t slot, BufferBase* buffer, uint64_t offset) {
|
||||
mVertexBuffers[slot] = ToBackend(buffer);
|
||||
mVertexBufferOffsets[slot] = offset;
|
||||
|
||||
// Use 64 bit masks and make sure there are no shift UB
|
||||
static_assert(kMaxVertexBuffers <= 8 * sizeof(unsigned long long) - 1, "");
|
||||
mDirtyVertexBuffers |= ((1ull << count) - 1ull) << startSlot;
|
||||
mDirtyVertexBuffers |= 1ull << slot;
|
||||
}
|
||||
|
||||
void OnSetPipeline(RenderPipelineBase* pipeline) {
|
||||
|
@ -974,11 +968,9 @@ namespace dawn_native { namespace opengl {
|
|||
inputBuffers.OnSetIndexBuffer(cmd->buffer.Get());
|
||||
} break;
|
||||
|
||||
case Command::SetVertexBuffers: {
|
||||
SetVertexBuffersCmd* cmd = iter->NextCommand<SetVertexBuffersCmd>();
|
||||
auto buffers = iter->NextData<Ref<BufferBase>>(cmd->count);
|
||||
auto offsets = iter->NextData<uint64_t>(cmd->count);
|
||||
inputBuffers.OnSetVertexBuffers(cmd->startSlot, cmd->count, buffers, offsets);
|
||||
case Command::SetVertexBuffer: {
|
||||
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
|
||||
inputBuffers.OnSetVertexBuffer(cmd->slot, cmd->buffer.Get(), cmd->offset);
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -814,22 +814,12 @@ namespace dawn_native { namespace vulkan {
|
|||
descriptorSets.OnSetPipeline(pipeline);
|
||||
} break;
|
||||
|
||||
case Command::SetVertexBuffers: {
|
||||
SetVertexBuffersCmd* cmd = iter->NextCommand<SetVertexBuffersCmd>();
|
||||
auto buffers = iter->NextData<Ref<BufferBase>>(cmd->count);
|
||||
auto offsets = iter->NextData<uint64_t>(cmd->count);
|
||||
case Command::SetVertexBuffer: {
|
||||
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
|
||||
VkBuffer buffer = ToBackend(cmd->buffer)->GetHandle();
|
||||
VkDeviceSize offset = static_cast<VkDeviceSize>(cmd->offset);
|
||||
|
||||
std::array<VkBuffer, kMaxVertexBuffers> vkBuffers;
|
||||
std::array<VkDeviceSize, kMaxVertexBuffers> vkOffsets;
|
||||
|
||||
for (uint32_t i = 0; i < cmd->count; ++i) {
|
||||
Buffer* buffer = ToBackend(buffers[i].Get());
|
||||
vkBuffers[i] = buffer->GetHandle();
|
||||
vkOffsets[i] = static_cast<VkDeviceSize>(offsets[i]);
|
||||
}
|
||||
|
||||
device->fn.CmdBindVertexBuffers(commands, cmd->startSlot, cmd->count,
|
||||
vkBuffers.data(), vkOffsets.data());
|
||||
device->fn.CmdBindVertexBuffers(commands, cmd->slot, 1, &buffer, &offset);
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -70,12 +70,11 @@ class DestroyTest : public DawnTest {
|
|||
dawn::Buffer vertexBuffer;
|
||||
|
||||
dawn::CommandBuffer CreateTriangleCommandBuffer() {
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
|
|
@ -83,12 +83,11 @@ class DrawIndexedIndirectTest : public DawnTest {
|
|||
dawn::Buffer indirectBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList);
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, indexOffset);
|
||||
pass.DrawIndexedIndirect(indirectBuffer, indirectOffset);
|
||||
pass.EndPass();
|
||||
|
|
|
@ -83,13 +83,12 @@ class DrawIndexedTest : public DawnTest {
|
|||
uint64_t bufferOffset,
|
||||
RGBA8 bottomLeftExpected,
|
||||
RGBA8 topRightExpected) {
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(
|
||||
&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, bufferOffset);
|
||||
pass.DrawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
|
||||
pass.EndPass();
|
||||
|
|
|
@ -74,12 +74,11 @@ class DrawIndirectTest : public DawnTest {
|
|||
dawn::Buffer indirectBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList);
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.DrawIndirect(indirectBuffer, indirectOffset);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
|
|
@ -73,12 +73,11 @@ class DrawTest : public DawnTest {
|
|||
uint32_t firstInstance,
|
||||
RGBA8 bottomLeftExpected,
|
||||
RGBA8 topRightExpected) {
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(vertexCount, instanceCount, firstIndex, firstInstance);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
|
|
@ -74,12 +74,11 @@ TEST_P(IndexFormatTest, Uint32) {
|
|||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {1, 2, 3});
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.DrawIndexed(3, 1, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
@ -102,12 +101,11 @@ TEST_P(IndexFormatTest, Uint16) {
|
|||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsage::Index, {1, 2, 0, 0, 0, 0});
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.DrawIndexed(3, 1, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
@ -153,12 +151,11 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
|
|||
2,
|
||||
});
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.DrawIndexed(7, 1, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
@ -196,12 +193,11 @@ TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
|
|||
0xFFFFu,
|
||||
});
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.DrawIndexed(7, 1, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
@ -232,12 +228,11 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
|
|||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {1, 2, 3});
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline16);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.SetPipeline(pipeline32);
|
||||
pass.DrawIndexed(3, 1, 0, 0, 0);
|
||||
|
@ -264,13 +259,12 @@ TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) {
|
|||
dawn::Buffer indexBuffer =
|
||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {0, 1, 2});
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.DrawIndexed(3, 1, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
|
|
@ -194,13 +194,12 @@ class PrimitiveTopologyTest : public DawnTest {
|
|||
|
||||
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
|
||||
static const uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(
|
||||
&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
|
|
@ -108,9 +108,8 @@ TEST_P(RenderBundleTest, Basic) {
|
|||
|
||||
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.SetBindGroup(0, bindGroups[0]);
|
||||
renderBundleEncoder.Draw(6, 1, 0, 0);
|
||||
|
||||
|
@ -136,12 +135,11 @@ TEST_P(RenderBundleTest, MultipleBundles) {
|
|||
desc.cColorFormats[0] = renderPass.colorFormat;
|
||||
|
||||
dawn::RenderBundle renderBundles[2];
|
||||
uint64_t zeroOffset = 0;
|
||||
{
|
||||
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
|
||||
|
||||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.SetBindGroup(0, bindGroups[0]);
|
||||
renderBundleEncoder.Draw(3, 1, 0, 0);
|
||||
|
||||
|
@ -151,7 +149,7 @@ TEST_P(RenderBundleTest, MultipleBundles) {
|
|||
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
|
||||
|
||||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.SetBindGroup(0, bindGroups[1]);
|
||||
renderBundleEncoder.Draw(3, 1, 3, 0);
|
||||
|
||||
|
@ -179,9 +177,8 @@ TEST_P(RenderBundleTest, BundleAndRenderPassCommands) {
|
|||
|
||||
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.SetBindGroup(0, bindGroups[0]);
|
||||
renderBundleEncoder.Draw(3, 1, 0, 0);
|
||||
|
||||
|
@ -193,7 +190,7 @@ TEST_P(RenderBundleTest, BundleAndRenderPassCommands) {
|
|||
pass.ExecuteBundles(1, &renderBundle);
|
||||
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.SetBindGroup(0, bindGroups[1]);
|
||||
pass.Draw(3, 1, 3, 0);
|
||||
|
||||
|
|
|
@ -378,12 +378,11 @@ class VertexFormatTest : public DawnTest {
|
|||
dawn::RenderPipeline pipeline = MakeTestPipeline(format, expectedData);
|
||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData(
|
||||
device, vertex.data(), vertex.size() * sizeof(VertexType), dawn::BufferUsage::Vertex);
|
||||
uint64_t zeroOffset = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
|
|
@ -199,9 +199,8 @@ class VertexInputTest : public DawnTest {
|
|||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
for (const auto& buffer : vertexBuffers) {
|
||||
pass.SetVertexBuffers(buffer.location, 1, buffer.buffer, &zeroOffset);
|
||||
for (const DrawVertexBuffer& buffer : vertexBuffers) {
|
||||
pass.SetVertexBuffer(buffer.location, *buffer.buffer);
|
||||
}
|
||||
|
||||
pass.Draw(triangles * 3, instances, 0, 0);
|
||||
|
@ -426,9 +425,8 @@ TEST_P(VertexInputTest, UnusedVertexSlot) {
|
|||
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
pass.SetVertexBuffers(0, 1, &buffer, &zeroOffset);
|
||||
pass.SetVertexBuffers(1, 1, &buffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, buffer);
|
||||
pass.SetVertexBuffer(1, buffer);
|
||||
|
||||
pass.SetPipeline(instancePipeline);
|
||||
pass.Draw(1 * 3, 4, 0, 0);
|
||||
|
@ -442,9 +440,9 @@ TEST_P(VertexInputTest, UnusedVertexSlot) {
|
|||
}
|
||||
|
||||
// Test setting a different pipeline with a different input state.
|
||||
// This was a problem with the D3D12 backend where SetVertexBuffers
|
||||
// This was a problem with the D3D12 backend where SetVertexBuffer
|
||||
// was getting the input from the last set pipeline, not the current.
|
||||
// SetVertexBuffers should be reapplied when the input state changes.
|
||||
// SetVertexBuffer should be reapplied when the input state changes.
|
||||
TEST_P(VertexInputTest, MultiplePipelinesMixedVertexInput) {
|
||||
// Basic input state, using slot 0
|
||||
utils::ComboVertexInputDescriptor vertexVertexInput = MakeVertexInput(
|
||||
|
@ -470,9 +468,8 @@ TEST_P(VertexInputTest, MultiplePipelinesMixedVertexInput) {
|
|||
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
|
||||
uint64_t zeroOffset = 0;
|
||||
pass.SetVertexBuffers(0, 1, &buffer, &zeroOffset);
|
||||
pass.SetVertexBuffers(1, 1, &buffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, buffer);
|
||||
pass.SetVertexBuffer(1, buffer);
|
||||
|
||||
pass.SetPipeline(vertexPipeline);
|
||||
pass.Draw(1 * 3, 1, 0, 0);
|
||||
|
|
|
@ -191,12 +191,11 @@ TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
|
|||
dawn::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
|
||||
|
||||
// Use the buffer as both index and vertex in the same pass
|
||||
uint64_t zero = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
DummyRenderPass dummyRenderPass(device);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.SetIndexBuffer(buffer, 0);
|
||||
pass.SetVertexBuffers(0, 1, &buffer, &zero);
|
||||
pass.SetVertexBuffer(0, buffer);
|
||||
pass.EndPass();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
|
|
@ -111,7 +111,6 @@ namespace {
|
|||
dawn::RenderPipeline pipeline;
|
||||
dawn::Buffer vertexBuffer;
|
||||
dawn::Buffer vertexStorageBuffer;
|
||||
const uint64_t zeroOffset = 0;
|
||||
dawn::BindGroup bg0;
|
||||
dawn::BindGroup bg1;
|
||||
dawn::BindGroup bg1Vertex;
|
||||
|
@ -160,7 +159,7 @@ TEST_F(RenderBundleValidationTest, SimpleSuccess) {
|
|||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetBindGroup(0, bg0);
|
||||
renderBundleEncoder.SetBindGroup(1, bg1);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.Draw(3, 0, 0, 0);
|
||||
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
||||
|
||||
|
@ -248,7 +247,7 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
|
|||
|
||||
renderBundleEncoder.SetBindGroup(0, bg0);
|
||||
renderBundleEncoder.SetBindGroup(1, bg1);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.Draw(3, 0, 0, 0);
|
||||
ASSERT_DEVICE_ERROR(dawn::RenderBundle renderBundle = renderBundleEncoder.Finish());
|
||||
|
||||
|
@ -267,7 +266,7 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
|
|||
pass.SetBindGroup(1, bg1);
|
||||
|
||||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.Draw(3, 0, 0, 0);
|
||||
ASSERT_DEVICE_ERROR(dawn::RenderBundle renderBundle = renderBundleEncoder.Finish());
|
||||
|
||||
|
@ -286,7 +285,7 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
|
|||
pass.SetBindGroup(0, bg0);
|
||||
pass.SetBindGroup(1, bg1);
|
||||
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.Draw(3, 0, 0, 0);
|
||||
ASSERT_DEVICE_ERROR(dawn::RenderBundle renderBundle = renderBundleEncoder.Finish());
|
||||
|
||||
|
@ -301,7 +300,7 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
|
|||
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
|
||||
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
|
||||
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
|
||||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetBindGroup(0, bg0);
|
||||
|
@ -335,7 +334,7 @@ TEST_F(RenderBundleValidationTest, StatePersistence) {
|
|||
pass.ExecuteBundles(1, &renderBundle);
|
||||
pass.SetBindGroup(0, bg0);
|
||||
pass.SetBindGroup(1, bg1);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
|
@ -354,7 +353,7 @@ TEST_F(RenderBundleValidationTest, StatePersistence) {
|
|||
|
||||
pass.ExecuteBundles(1, &renderBundle);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
|
@ -373,7 +372,7 @@ TEST_F(RenderBundleValidationTest, StatePersistence) {
|
|||
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
||||
|
||||
pass.ExecuteBundles(1, &renderBundle);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
|
@ -386,7 +385,7 @@ TEST_F(RenderBundleValidationTest, StatePersistence) {
|
|||
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
|
||||
|
||||
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
||||
|
||||
pass.ExecuteBundles(1, &renderBundle);
|
||||
|
@ -420,7 +419,7 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
|
|||
pass.ExecuteBundles(1, &renderBundle);
|
||||
pass.SetBindGroup(0, bg0);
|
||||
pass.SetBindGroup(1, bg1);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
|
@ -436,7 +435,7 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
|
|||
pass.SetBindGroup(1, bg1);
|
||||
pass.ExecuteBundles(1, &renderBundle);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
|
@ -452,7 +451,7 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
|
|||
pass.SetBindGroup(0, bg0);
|
||||
pass.SetBindGroup(1, bg1);
|
||||
pass.ExecuteBundles(1, &renderBundle);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
|
@ -464,7 +463,7 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
|
|||
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
|
||||
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.ExecuteBundles(1, &renderBundle);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bg0);
|
||||
|
@ -483,7 +482,7 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
|
|||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bg0);
|
||||
pass.SetBindGroup(1, bg1);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.ExecuteBundles(0, nullptr);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
|
||||
|
@ -506,7 +505,7 @@ TEST_F(RenderBundleValidationTest, MultipleBundles) {
|
|||
renderBundleEncoder0.SetPipeline(pipeline);
|
||||
renderBundleEncoder0.SetBindGroup(0, bg0);
|
||||
renderBundleEncoder0.SetBindGroup(1, bg1);
|
||||
renderBundleEncoder0.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder0.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder0.Draw(3, 1, 0, 0);
|
||||
renderBundles[0] = renderBundleEncoder0.Finish();
|
||||
|
||||
|
@ -514,7 +513,7 @@ TEST_F(RenderBundleValidationTest, MultipleBundles) {
|
|||
renderBundleEncoder1.SetPipeline(pipeline);
|
||||
renderBundleEncoder1.SetBindGroup(0, bg0);
|
||||
renderBundleEncoder1.SetBindGroup(1, bg1);
|
||||
renderBundleEncoder1.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder1.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder1.Draw(3, 1, 0, 0);
|
||||
renderBundles[1] = renderBundleEncoder1.Finish();
|
||||
|
||||
|
@ -537,7 +536,7 @@ TEST_F(RenderBundleValidationTest, ExecuteMultipleTimes) {
|
|||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetBindGroup(0, bg0);
|
||||
renderBundleEncoder.SetBindGroup(1, bg1);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.Draw(3, 1, 0, 0);
|
||||
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
||||
|
||||
|
@ -617,7 +616,7 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
|
|||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetBindGroup(0, bg0);
|
||||
renderBundleEncoder.SetBindGroup(1, bg1Vertex);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
|
||||
renderBundleEncoder.Draw(3, 0, 0, 0);
|
||||
renderBundle0 = renderBundleEncoder.Finish();
|
||||
}
|
||||
|
@ -628,7 +627,7 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
|
|||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetBindGroup(0, bg0);
|
||||
renderBundleEncoder.SetBindGroup(1, bg1);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexStorageBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexStorageBuffer);
|
||||
renderBundleEncoder.Draw(3, 0, 0, 0);
|
||||
renderBundle1 = renderBundleEncoder.Finish();
|
||||
}
|
||||
|
@ -640,7 +639,7 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
|
|||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.SetBindGroup(0, bg0);
|
||||
renderBundleEncoder.SetBindGroup(1, bg1Vertex);
|
||||
renderBundleEncoder.SetVertexBuffers(0, 1, &vertexStorageBuffer, &zeroOffset);
|
||||
renderBundleEncoder.SetVertexBuffer(0, vertexStorageBuffer);
|
||||
renderBundleEncoder.Draw(3, 0, 0, 0);
|
||||
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
|
||||
}
|
||||
|
@ -668,7 +667,7 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
|
|||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bg0);
|
||||
pass.SetBindGroup(1, bg1Vertex);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexBuffer);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
|
||||
pass.ExecuteBundles(1, &renderBundle1);
|
||||
|
@ -688,7 +687,7 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
|
|||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bg0);
|
||||
pass.SetBindGroup(1, bg1);
|
||||
pass.SetVertexBuffers(0, 1, &vertexStorageBuffer, &zeroOffset);
|
||||
pass.SetVertexBuffer(0, vertexStorageBuffer);
|
||||
pass.Draw(3, 0, 0, 0);
|
||||
|
||||
pass.EndPass();
|
||||
|
|
|
@ -32,17 +32,12 @@ class VertexBufferValidationTest : public ValidationTest {
|
|||
})");
|
||||
}
|
||||
|
||||
template <unsigned int N>
|
||||
std::array<dawn::Buffer, N> MakeVertexBuffers() {
|
||||
std::array<dawn::Buffer, N> buffers;
|
||||
for (auto& buffer : buffers) {
|
||||
dawn::BufferDescriptor descriptor;
|
||||
descriptor.size = 256;
|
||||
descriptor.usage = dawn::BufferUsage::Vertex;
|
||||
dawn::Buffer MakeVertexBuffer() {
|
||||
dawn::BufferDescriptor descriptor;
|
||||
descriptor.size = 256;
|
||||
descriptor.usage = dawn::BufferUsage::Vertex;
|
||||
|
||||
buffer = device.CreateBuffer(&descriptor);
|
||||
}
|
||||
return buffers;
|
||||
return device.CreateBuffer(&descriptor);
|
||||
}
|
||||
|
||||
dawn::ShaderModule MakeVertexShader(unsigned int bufferCount) {
|
||||
|
@ -97,8 +92,8 @@ TEST_F(VertexBufferValidationTest, VertexBuffersInheritedBetweenPipelines) {
|
|||
auto pipeline2 = MakeRenderPipeline(vsModule2, 2);
|
||||
auto pipeline1 = MakeRenderPipeline(vsModule1, 1);
|
||||
|
||||
auto vertexBuffers = MakeVertexBuffers<2>();
|
||||
uint64_t offsets[] = { 0, 0 };
|
||||
auto vertexBuffer1 = MakeVertexBuffer();
|
||||
auto vertexBuffer2 = MakeVertexBuffer();
|
||||
|
||||
// Check failure when vertex buffer is not set
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
@ -115,7 +110,8 @@ TEST_F(VertexBufferValidationTest, VertexBuffersInheritedBetweenPipelines) {
|
|||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.SetVertexBuffer(0, vertexBuffer1);
|
||||
pass.SetVertexBuffer(1, vertexBuffer2);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.SetPipeline(pipeline1);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
|
@ -132,22 +128,23 @@ TEST_F(VertexBufferValidationTest, VertexBuffersNotInheritedBetweenRendePasses)
|
|||
auto pipeline2 = MakeRenderPipeline(vsModule2, 2);
|
||||
auto pipeline1 = MakeRenderPipeline(vsModule1, 1);
|
||||
|
||||
auto vertexBuffers = MakeVertexBuffers<2>();
|
||||
uint64_t offsets[] = { 0, 0 };
|
||||
auto vertexBuffer1 = MakeVertexBuffer();
|
||||
auto vertexBuffer2 = MakeVertexBuffer();
|
||||
|
||||
// Check success when vertex buffer is set for each render pass
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.SetVertexBuffer(0, vertexBuffer1);
|
||||
pass.SetVertexBuffer(1, vertexBuffer2);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline1);
|
||||
pass.SetVertexBuffers(0, 1, vertexBuffers.data(), offsets);
|
||||
pass.SetVertexBuffer(0, vertexBuffer1);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
@ -158,7 +155,8 @@ TEST_F(VertexBufferValidationTest, VertexBuffersNotInheritedBetweenRendePasses)
|
|||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.SetVertexBuffer(0, vertexBuffer1);
|
||||
pass.SetVertexBuffer(1, vertexBuffer2);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue