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