Remove deprecated SetIndexBuffer (without format).

This also simplifies a bunch of code in backends that was used to handle
getting the indexFormat from the pipeline "late".

Bug: dawn:502

Change-Id: Ibae50c8df21323fd391515f6036552e9fb868d93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32023
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez 2020-11-25 08:54:14 +00:00 committed by Commit Bot service account
parent 33f29ea9b2
commit 5fad85bbd9
22 changed files with 145 additions and 352 deletions

View File

@ -1150,6 +1150,7 @@
"name": "set index buffer",
"args": [
{"name": "buffer", "type": "buffer"},
{"name": "format", "type": "index format"},
{"name": "offset", "type": "uint64_t", "default": "0"},
{"name": "size", "type": "uint64_t", "default": "0"}
]
@ -1349,6 +1350,7 @@
"name": "set index buffer",
"args": [
{"name": "buffer", "type": "buffer"},
{"name": "format", "type": "index format"},
{"name": "offset", "type": "uint64_t", "default": "0"},
{"name": "size", "type": "uint64_t", "default": "0"}
]

View File

@ -163,7 +163,7 @@ void frame() {
pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bindGroup);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexed(3);
pass.EndPass();
}

View File

@ -251,7 +251,7 @@ void frame() {
pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bindGroup[0]);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexed(36);
pass.SetStencilReference(0x1);

View File

@ -126,21 +126,13 @@ namespace dawn_native {
}
}
if (aspects[VALIDATION_ASPECT_INDEX_BUFFER]) {
if (mIndexBufferSet) {
if (aspects[VALIDATION_ASPECT_INDEX_BUFFER] && mIndexBufferSet) {
wgpu::IndexFormat pipelineIndexFormat =
mLastRenderPipeline->GetVertexStateDescriptor()->indexFormat;
if (mIndexFormat != wgpu::IndexFormat::Undefined) {
if (!IsStripPrimitiveTopology(mLastRenderPipeline->GetPrimitiveTopology()) ||
mIndexFormat == pipelineIndexFormat) {
mAspects.set(VALIDATION_ASPECT_INDEX_BUFFER);
}
} else if (pipelineIndexFormat != wgpu::IndexFormat::Undefined) {
// TODO(crbug.com/dawn/502): Deprecated path. Remove once setIndexFormat always
// requires an index format.
mAspects.set(VALIDATION_ASPECT_INDEX_BUFFER);
}
}
}
}
@ -154,17 +146,10 @@ namespace dawn_native {
mLastRenderPipeline->GetVertexStateDescriptor()->indexFormat;
if (!mIndexBufferSet) {
return DAWN_VALIDATION_ERROR("Missing index buffer");
} else if (mIndexFormat != wgpu::IndexFormat::Undefined &&
IsStripPrimitiveTopology(mLastRenderPipeline->GetPrimitiveTopology()) &&
} else if (IsStripPrimitiveTopology(mLastRenderPipeline->GetPrimitiveTopology()) &&
mIndexFormat != pipelineIndexFormat) {
return DAWN_VALIDATION_ERROR(
"Pipeline strip index format does not match index buffer format");
} else if (mIndexFormat == wgpu::IndexFormat::Undefined &&
pipelineIndexFormat == wgpu::IndexFormat::Undefined) {
// TODO(crbug.com/dawn/502): Deprecated path. Remove once setIndexFormat always
// requires an index format.
return DAWN_VALIDATION_ERROR(
"Index format must be specified on the pipeline or in setIndexBuffer");
}
// The chunk of code above should be similar to the one in |RecomputeLazyAspects|.

View File

@ -153,24 +153,25 @@ namespace dawn_native {
});
}
void RenderEncoderBase::SetIndexBuffer(BufferBase* buffer, uint64_t offset, uint64_t size) {
GetDevice()->EmitDeprecationWarning(
"RenderEncoderBase::SetIndexBuffer is deprecated. Use RenderEncoderBase::SetIndexBufferWithFormat instead");
SetIndexBufferCommon(buffer, wgpu::IndexFormat::Undefined, offset, size, false);
}
void RenderEncoderBase::SetIndexBufferWithFormat(BufferBase* buffer, wgpu::IndexFormat format,
uint64_t offset, uint64_t size) {
SetIndexBufferCommon(buffer, format, offset, size, true);
GetDevice()->EmitDeprecationWarning(
"RenderEncoderBase::SetIndexBufferWithFormat is deprecated. Use "
"RenderEncoderBase::SetIndexBuffer instead.");
SetIndexBuffer(buffer, format, offset, size);
}
void RenderEncoderBase::SetIndexBufferCommon(BufferBase* buffer, wgpu::IndexFormat format,
uint64_t offset, uint64_t size,
bool requireFormat) {
void RenderEncoderBase::SetIndexBuffer(BufferBase* buffer,
wgpu::IndexFormat format,
uint64_t offset,
uint64_t size) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
DAWN_TRY(GetDevice()->ValidateObject(buffer));
DAWN_TRY(ValidateIndexFormat(format));
if (format == wgpu::IndexFormat::Undefined) {
return DAWN_VALIDATION_ERROR("Index format must be specified");
}
uint64_t bufferSize = buffer->GetSize();
if (offset > bufferSize) {
@ -186,12 +187,6 @@ namespace dawn_native {
}
}
if (requireFormat && format == wgpu::IndexFormat::Undefined) {
return DAWN_VALIDATION_ERROR("Index format must be specified");
} else if (!requireFormat) {
ASSERT(format == wgpu::IndexFormat::Undefined);
}
SetIndexBufferCmd* cmd =
allocator->Allocate<SetIndexBufferCmd>(Command::SetIndexBuffer);
cmd->buffer = buffer;

View File

@ -40,7 +40,10 @@ namespace dawn_native {
void SetPipeline(RenderPipelineBase* pipeline);
void SetVertexBuffer(uint32_t slot, BufferBase* buffer, uint64_t offset, uint64_t size);
void SetIndexBuffer(BufferBase* buffer, uint64_t offset, uint64_t size);
void SetIndexBuffer(BufferBase* buffer,
wgpu::IndexFormat format,
uint64_t offset,
uint64_t size);
void SetIndexBufferWithFormat(BufferBase* buffer, wgpu::IndexFormat format, uint64_t offset,
uint64_t size);
@ -49,9 +52,6 @@ namespace dawn_native {
RenderEncoderBase(DeviceBase* device, EncodingContext* encodingContext, ErrorTag errorTag);
private:
void SetIndexBufferCommon(BufferBase* buffer, wgpu::IndexFormat format, uint64_t offset,
uint64_t size, bool requireFormat);
const bool mDisableBaseVertex;
const bool mDisableBaseInstance;
};

View File

@ -94,15 +94,16 @@ namespace dawn_native {
}
DAWN_TRY(ValidateIndexFormat(descriptor->indexFormat));
// Pipeline descriptors using strip topologies must not have an undefined index format.
// Pipeline descriptors must have indexFormat != undefined IFF they are using strip
// topologies.
if (IsStripPrimitiveTopology(primitiveTopology)) {
if (descriptor->indexFormat == wgpu::IndexFormat::Undefined) {
return DAWN_VALIDATION_ERROR(
"indexFormat must not be undefined when using strip primitive topologies");
}
} else if (descriptor->indexFormat != wgpu::IndexFormat::Undefined) {
device->EmitDeprecationWarning(
"Specifying an indexFormat when using list primitive topologies is deprecated");
return DAWN_VALIDATION_ERROR(
"indexFormat must be undefined when using non-strip primitive topologies");
}
if (descriptor->vertexBufferCount > kMaxVertexBuffers) {

View File

@ -505,46 +505,6 @@ namespace dawn_native { namespace d3d12 {
mD3D12BufferViews = {};
};
class IndexBufferTracker {
public:
void OnSetIndexBuffer(Buffer* buffer,
wgpu::IndexFormat format,
uint64_t offset,
uint64_t size) {
mD3D12BufferView.BufferLocation = buffer->GetVA() + offset;
mD3D12BufferView.SizeInBytes = size;
mBufferIndexFormat = DXGIIndexFormat(format);
// We don't need to dirty the state unless BufferLocation or SizeInBytes
// change, but most of the time this will always be the case.
mLastAppliedIndexFormat = DXGI_FORMAT_UNKNOWN;
}
void OnSetPipeline(const RenderPipelineBase* pipeline) {
mPipelineIndexFormat =
DXGIIndexFormat(pipeline->GetVertexStateDescriptor()->indexFormat);
}
void Apply(ID3D12GraphicsCommandList* commandList) {
DXGI_FORMAT newIndexFormat = mBufferIndexFormat;
if (newIndexFormat == DXGI_FORMAT_UNKNOWN) {
newIndexFormat = mPipelineIndexFormat;
}
if (newIndexFormat != mLastAppliedIndexFormat) {
mD3D12BufferView.Format = newIndexFormat;
commandList->IASetIndexBuffer(&mD3D12BufferView);
mLastAppliedIndexFormat = newIndexFormat;
}
}
private:
DXGI_FORMAT mBufferIndexFormat = DXGI_FORMAT_UNKNOWN;
DXGI_FORMAT mPipelineIndexFormat = DXGI_FORMAT_UNKNOWN;
DXGI_FORMAT mLastAppliedIndexFormat = DXGI_FORMAT_UNKNOWN;
D3D12_INDEX_BUFFER_VIEW mD3D12BufferView = {};
};
void ResolveMultisampledRenderPass(CommandRecordingContext* commandContext,
BeginRenderPassCmd* renderPass) {
ASSERT(renderPass != nullptr);
@ -1269,7 +1229,6 @@ namespace dawn_native { namespace d3d12 {
RenderPipeline* lastPipeline = nullptr;
PipelineLayout* lastLayout = nullptr;
VertexBufferTracker vertexBufferTracker = {};
IndexBufferTracker indexBufferTracker = {};
auto EncodeRenderBundleCommand = [&](CommandIterator* iter, Command type) -> MaybeError {
switch (type) {
@ -1287,7 +1246,6 @@ namespace dawn_native { namespace d3d12 {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
DAWN_TRY(bindingTracker->Apply(commandContext));
indexBufferTracker.Apply(commandList);
vertexBufferTracker.Apply(commandList, lastPipeline);
commandList->DrawIndexedInstanced(draw->indexCount, draw->instanceCount,
draw->firstIndex, draw->baseVertex,
@ -1312,7 +1270,6 @@ namespace dawn_native { namespace d3d12 {
DrawIndexedIndirectCmd* draw = iter->NextCommand<DrawIndexedIndirectCmd>();
DAWN_TRY(bindingTracker->Apply(commandContext));
indexBufferTracker.Apply(commandList);
vertexBufferTracker.Apply(commandList, lastPipeline);
Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
ComPtr<ID3D12CommandSignature> signature =
@ -1371,7 +1328,6 @@ namespace dawn_native { namespace d3d12 {
commandList->IASetPrimitiveTopology(pipeline->GetD3D12PrimitiveTopology());
bindingTracker->OnSetPipeline(pipeline);
indexBufferTracker.OnSetPipeline(pipeline);
lastPipeline = pipeline;
lastLayout = layout;
@ -1395,8 +1351,12 @@ namespace dawn_native { namespace d3d12 {
case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
indexBufferTracker.OnSetIndexBuffer(ToBackend(cmd->buffer.Get()), cmd->format,
cmd->offset, cmd->size);
D3D12_INDEX_BUFFER_VIEW bufferView;
bufferView.Format = DXGIIndexFormat(cmd->format);
bufferView.BufferLocation = ToBackend(cmd->buffer)->GetVA() + cmd->offset;
bufferView.SizeInBytes = cmd->size;
commandList->IASetIndexBuffer(&bufferView);
break;
}

View File

@ -1030,7 +1030,9 @@ namespace dawn_native { namespace metal {
RenderPipeline* lastPipeline = nullptr;
id<MTLBuffer> indexBuffer = nullptr;
uint32_t indexBufferBaseOffset = 0;
wgpu::IndexFormat indexBufferFormat = wgpu::IndexFormat::Undefined;
MTLIndexType indexBufferType;
uint64_t indexTypeSize = 0;
StorageBufferLengthTracker storageBufferLengths = {};
VertexBufferTracker vertexBuffers(&storageBufferLengths);
BindGroupTracker bindGroups(&storageBufferLengths);
@ -1072,15 +1074,6 @@ namespace dawn_native { namespace metal {
bindGroups.Apply(encoder);
storageBufferLengths.Apply(encoder, lastPipeline, enableVertexPulling);
// If a index format was specified in setIndexBuffer always use it.
wgpu::IndexFormat indexFormat = indexBufferFormat;
if (indexFormat == wgpu::IndexFormat::Undefined) {
// Otherwise use the pipeline's index format.
// TODO(crbug.com/dawn/502): This path is deprecated.
indexFormat = lastPipeline->GetVertexStateDescriptor()->indexFormat;
}
size_t formatSize = IndexFormatSize(indexFormat);
// The index and instance count must be non-zero, otherwise no-op
if (draw->indexCount != 0 && draw->instanceCount != 0) {
// MTLFeatureSet_iOS_GPUFamily3_v1 does not support baseInstance and
@ -1088,18 +1081,18 @@ namespace dawn_native { namespace metal {
if (draw->baseVertex == 0 && draw->firstInstance == 0) {
[encoder drawIndexedPrimitives:lastPipeline->GetMTLPrimitiveTopology()
indexCount:draw->indexCount
indexType:MTLIndexFormat(indexFormat)
indexType:indexBufferType
indexBuffer:indexBuffer
indexBufferOffset:indexBufferBaseOffset +
draw->firstIndex * formatSize
draw->firstIndex * indexTypeSize
instanceCount:draw->instanceCount];
} else {
[encoder drawIndexedPrimitives:lastPipeline->GetMTLPrimitiveTopology()
indexCount:draw->indexCount
indexType:MTLIndexFormat(indexFormat)
indexType:indexBufferType
indexBuffer:indexBuffer
indexBufferOffset:indexBufferBaseOffset +
draw->firstIndex * formatSize
draw->firstIndex * indexTypeSize
instanceCount:draw->instanceCount
baseVertex:draw->baseVertex
baseInstance:draw->firstInstance];
@ -1130,18 +1123,10 @@ namespace dawn_native { namespace metal {
bindGroups.Apply(encoder);
storageBufferLengths.Apply(encoder, lastPipeline, enableVertexPulling);
// If a index format was specified in setIndexBuffer always use it.
wgpu::IndexFormat indexFormat = indexBufferFormat;
if (indexFormat == wgpu::IndexFormat::Undefined) {
// Otherwise use the pipeline's index format.
// TODO(crbug.com/dawn/502): This path is deprecated.
indexFormat = lastPipeline->GetVertexStateDescriptor()->indexFormat;
}
Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
id<MTLBuffer> indirectBuffer = buffer->GetMTLBuffer();
[encoder drawIndexedPrimitives:lastPipeline->GetMTLPrimitiveTopology()
indexType:MTLIndexFormat(indexFormat)
indexType:indexBufferType
indexBuffer:indexBuffer
indexBufferOffset:indexBufferBaseOffset
indirectBuffer:indirectBuffer
@ -1210,9 +1195,8 @@ namespace dawn_native { namespace metal {
auto b = ToBackend(cmd->buffer.Get());
indexBuffer = b->GetMTLBuffer();
indexBufferBaseOffset = cmd->offset;
// TODO(crbug.com/dawn/502): Once setIndexBuffer is required to specify an
// index buffer format store as an MTLIndexType.
indexBufferFormat = cmd->format;
indexBufferType = MTLIndexFormat(cmd->format);
indexTypeSize = IndexFormatSize(cmd->format);
break;
}

View File

@ -1009,7 +1009,8 @@ namespace dawn_native { namespace opengl {
RenderPipeline* lastPipeline = nullptr;
uint64_t indexBufferBaseOffset = 0;
wgpu::IndexFormat indexBufferFormat;
GLenum indexBufferFormat;
uint32_t indexFormatSize;
VertexStateBufferBindingTracker vertexStateBufferBindingTracker;
BindGroupTracker bindGroupTracker = {};
@ -1039,20 +1040,11 @@ namespace dawn_native { namespace opengl {
vertexStateBufferBindingTracker.Apply(gl);
bindGroupTracker.Apply(gl);
// If a index format was specified in setIndexBuffer always use it.
wgpu::IndexFormat indexFormat = indexBufferFormat;
if (indexFormat == wgpu::IndexFormat::Undefined) {
// Otherwise use the pipeline's index format.
// TODO(crbug.com/dawn/502): This path is deprecated.
indexFormat = lastPipeline->GetVertexStateDescriptor()->indexFormat;
}
size_t formatSize = IndexFormatSize(indexFormat);
if (draw->firstInstance > 0) {
gl.DrawElementsInstancedBaseVertexBaseInstance(
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount,
IndexFormatType(indexFormat),
reinterpret_cast<void*>(draw->firstIndex * formatSize +
indexBufferFormat,
reinterpret_cast<void*>(draw->firstIndex * indexFormatSize +
indexBufferBaseOffset),
draw->instanceCount, draw->baseVertex, draw->firstInstance);
} else {
@ -1060,16 +1052,16 @@ namespace dawn_native { namespace opengl {
if (draw->baseVertex != 0) {
gl.DrawElementsInstancedBaseVertex(
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount,
IndexFormatType(indexFormat),
reinterpret_cast<void*>(draw->firstIndex * formatSize +
indexBufferFormat,
reinterpret_cast<void*>(draw->firstIndex * indexFormatSize +
indexBufferBaseOffset),
draw->instanceCount, draw->baseVertex);
} else {
// This branch is only needed on OpenGL < 3.2; ES < 3.2
gl.DrawElementsInstanced(
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount,
IndexFormatType(indexFormat),
reinterpret_cast<void*>(draw->firstIndex * formatSize +
indexBufferFormat,
reinterpret_cast<void*>(draw->firstIndex * indexFormatSize +
indexBufferBaseOffset),
draw->instanceCount);
}
@ -1100,17 +1092,9 @@ namespace dawn_native { namespace opengl {
uint64_t indirectBufferOffset = draw->indirectOffset;
Buffer* indirectBuffer = ToBackend(draw->indirectBuffer.Get());
// If a index format was specified in setIndexBuffer always use it.
wgpu::IndexFormat indexFormat = indexBufferFormat;
if (indexFormat == wgpu::IndexFormat::Undefined) {
// Otherwise use the pipeline's index format.
// TODO(crbug.com/dawn/502): This path is deprecated.
indexFormat = lastPipeline->GetVertexStateDescriptor()->indexFormat;
}
gl.BindBuffer(GL_DRAW_INDIRECT_BUFFER, indirectBuffer->GetHandle());
gl.DrawElementsIndirect(
lastPipeline->GetGLPrimitiveTopology(), IndexFormatType(indexFormat),
lastPipeline->GetGLPrimitiveTopology(), indexBufferFormat,
reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset)));
break;
}
@ -1147,10 +1131,10 @@ namespace dawn_native { namespace opengl {
case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
// TODO(crbug.com/dawn/502): Once setIndexBuffer is required to specify an
// index buffer format store as an GLenum.
indexBufferFormat = cmd->format;
indexBufferBaseOffset = cmd->offset;
indexBufferFormat = IndexFormatType(cmd->format);
indexFormatSize = IndexFormatSize(cmd->format);
vertexStateBufferBindingTracker.OnSetIndexBuffer(cmd->buffer.Get());
break;
}

View File

@ -224,41 +224,6 @@ namespace dawn_native { namespace vulkan {
}
};
class IndexBufferTracker {
public:
void OnSetIndexBuffer(VkBuffer buffer, wgpu::IndexFormat format, VkDeviceSize offset) {
mIndexBuffer = buffer;
mOffset = offset;
mBufferIndexFormat = format;
mLastAppliedIndexFormat = wgpu::IndexFormat::Undefined;
}
void OnSetPipeline(RenderPipeline* pipeline) {
mPipelineIndexFormat = pipeline->GetVertexStateDescriptor()->indexFormat;
}
void Apply(Device* device, VkCommandBuffer commands) {
wgpu::IndexFormat newIndexFormat = mBufferIndexFormat;
if (newIndexFormat == wgpu::IndexFormat::Undefined) {
newIndexFormat = mPipelineIndexFormat;
}
if (newIndexFormat != mLastAppliedIndexFormat) {
device->fn.CmdBindIndexBuffer(commands, mIndexBuffer, mOffset,
VulkanIndexType(newIndexFormat));
mLastAppliedIndexFormat = newIndexFormat;
}
}
private:
wgpu::IndexFormat mBufferIndexFormat = wgpu::IndexFormat::Undefined;
wgpu::IndexFormat mPipelineIndexFormat = wgpu::IndexFormat::Undefined;
wgpu::IndexFormat mLastAppliedIndexFormat = wgpu::IndexFormat::Undefined;
VkBuffer mIndexBuffer = VK_NULL_HANDLE;
VkDeviceSize mOffset;
};
MaybeError RecordBeginRenderPass(CommandRecordingContext* recordingContext,
Device* device,
BeginRenderPassCmd* renderPass) {
@ -1000,7 +965,6 @@ namespace dawn_native { namespace vulkan {
}
RenderDescriptorSetTracker descriptorSets = {};
IndexBufferTracker indexBufferTracker = {};
RenderPipeline* lastPipeline = nullptr;
auto EncodeRenderBundleCommand = [&](CommandIterator* iter, Command type) {
@ -1018,7 +982,6 @@ namespace dawn_native { namespace vulkan {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_GRAPHICS);
indexBufferTracker.Apply(device, commands);
device->fn.CmdDrawIndexed(commands, draw->indexCount, draw->instanceCount,
draw->firstIndex, draw->baseVertex,
draw->firstInstance);
@ -1041,7 +1004,6 @@ namespace dawn_native { namespace vulkan {
VkBuffer indirectBuffer = ToBackend(draw->indirectBuffer)->GetHandle();
descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_GRAPHICS);
indexBufferTracker.Apply(device, commands);
device->fn.CmdDrawIndexedIndirect(
commands, indirectBuffer, static_cast<VkDeviceSize>(draw->indirectOffset),
1, 0);
@ -1115,8 +1077,8 @@ namespace dawn_native { namespace vulkan {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
VkBuffer indexBuffer = ToBackend(cmd->buffer)->GetHandle();
indexBufferTracker.OnSetIndexBuffer(indexBuffer, cmd->format,
static_cast<VkDeviceSize>(cmd->offset));
device->fn.CmdBindIndexBuffer(commands, indexBuffer, cmd->offset,
VulkanIndexType(cmd->format));
break;
}
@ -1129,7 +1091,6 @@ namespace dawn_native { namespace vulkan {
lastPipeline = pipeline;
descriptorSets.OnSetPipeline(pipeline);
indexBufferTracker.OnSetPipeline(pipeline);
break;
}

View File

@ -321,8 +321,8 @@ class BufferZeroInitTest : public DawnTest {
// Bind the buffer with offset == indexBufferOffset and size sizeof(uint32_t) as the index
// buffer.
renderPass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16,
indexBufferOffset, sizeof(uint32_t));
renderPass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16, indexBufferOffset,
sizeof(uint32_t));
renderPass.DrawIndexed(1);
renderPass.EndPass();
@ -401,7 +401,7 @@ class BufferZeroInitTest : public DawnTest {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor);
renderPass.SetPipeline(renderPipeline);
renderPass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16);
renderPass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
renderPass.DrawIndexedIndirect(indirectBuffer, indirectBufferOffset);
renderPass.EndPass();

View File

@ -32,6 +32,22 @@ class DeprecationTests : public DawnTest {
}
};
// Test that SetIndexBufferWithFormat is deprecated.
TEST_P(DeprecationTests, SetIndexBufferWithFormat) {
wgpu::BufferDescriptor bufferDesc;
bufferDesc.size = 4;
bufferDesc.usage = wgpu::BufferUsage::Index;
wgpu::Buffer indexBuffer = device.CreateBuffer(&bufferDesc);
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
EXPECT_DEPRECATION_WARNING(
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32));
pass.EndPass();
}
// Test that using BGLEntry.multisampled = true emits a deprecation warning.
TEST_P(DeprecationTests, BGLEntryMultisampledDeprecated) {
wgpu::BindGroupLayoutEntry entry{};
@ -160,108 +176,3 @@ class BufferCopyViewDeprecationTests : public DeprecationTests {
wgpu::Extent3D copySize = {1, 1, 1};
};
constexpr uint32_t kRTSize = 400;
class SetIndexBufferDeprecationTests : public DeprecationTests {
protected:
void SetUp() override {
DeprecationTests::SetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
}
utils::BasicRenderPass renderPass;
wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format) {
wgpu::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
gl_Position = pos;
})");
wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexState.indexFormat = format;
descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
descriptor.cColorStates[0].format = renderPass.colorFormat;
return device.CreateRenderPipeline(&descriptor);
}
};
// Test that the Uint32 index format is correctly interpreted
TEST_P(SetIndexBufferDeprecationTests, Uint32) {
wgpu::RenderPipeline pipeline = MakeTestPipeline(wgpu::IndexFormat::Uint32);
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
device, wgpu::BufferUsage::Vertex,
{-1.0f, -1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
wgpu::Buffer indexBuffer =
utils::CreateBufferFromData<uint32_t>(device, wgpu::BufferUsage::Index, {1, 2, 3});
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
EXPECT_DEPRECATION_WARNING(pass.SetIndexBuffer(indexBuffer));
pass.DrawIndexed(3);
pass.EndPass();
}
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, renderPass.color, 100, 300);
}
// Test that the Uint16 index format is correctly interpreted
TEST_P(SetIndexBufferDeprecationTests, Uint16) {
wgpu::RenderPipeline pipeline = MakeTestPipeline(wgpu::IndexFormat::Uint16);
wgpu::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
device, wgpu::BufferUsage::Vertex,
{-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
// If this is interpreted as uint32, it will have index 1 and 2 be both 0 and render nothing
wgpu::Buffer indexBuffer =
utils::CreateBufferFromData<uint16_t>(device, wgpu::BufferUsage::Index, {1, 2, 0, 0, 0, 0});
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
EXPECT_DEPRECATION_WARNING(pass.SetIndexBuffer(indexBuffer));
pass.DrawIndexed(3);
pass.EndPass();
}
wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, renderPass.color, 100, 300);
}
DAWN_INSTANTIATE_TEST(SetIndexBufferDeprecationTests,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -89,7 +89,7 @@ class DrawIndexedIndirectTest : public DawnTest {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32, indexOffset);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32, indexOffset);
pass.DrawIndexedIndirect(indirectBuffer, indirectOffset);
pass.EndPass();
}

View File

@ -89,7 +89,7 @@ class DrawIndexedTest : public DawnTest {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32, bufferOffset);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32, bufferOffset);
pass.DrawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
pass.EndPass();
}

View File

@ -552,7 +552,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
wgpu::RenderPassEncoder pass1 = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass1.SetPipeline(rp);
pass1.SetVertexBuffer(0, vertexBuffer);
pass1.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32, 0);
pass1.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32, 0);
pass1.SetBindGroup(0, bindGroup1);
pass1.DrawIndexed(6);
pass1.EndPass();
@ -676,7 +676,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
wgpu::RenderPassEncoder pass1 = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass1.SetPipeline(rp);
pass1.SetVertexBuffer(0, buffer);
pass1.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, offsetof(Data, indices));
pass1.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, offsetof(Data, indices));
pass1.SetBindGroup(0, bindGroup1);
pass1.DrawIndexed(6);
pass1.EndPass();

View File

@ -80,7 +80,7 @@ TEST_P(IndexFormatTest, Uint32) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexed(3);
pass.EndPass();
}
@ -107,7 +107,7 @@ TEST_P(IndexFormatTest, Uint16) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
pass.DrawIndexed(3);
pass.EndPass();
}
@ -157,7 +157,7 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexed(7);
pass.EndPass();
}
@ -199,7 +199,7 @@ TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
pass.DrawIndexed(7);
pass.EndPass();
}
@ -232,7 +232,7 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline16);
pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetPipeline(pipeline32);
pass.DrawIndexed(3);
pass.EndPass();
@ -247,8 +247,6 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
// Test that setting the index buffer before the pipeline works, this is important
// for backends where the index format is passed inside the call to SetIndexBuffer
// because it needs to be done lazily (to query the format from the last pipeline).
// TODO(cwallez@chromium.org): This is currently disallowed by the validation but
// we want to support eventually.
TEST_P(IndexFormatTest, SetIndexBufferBeforeSetPipeline) {
wgpu::RenderPipeline pipeline = MakeTestPipeline(wgpu::IndexFormat::Uint32);
@ -261,7 +259,7 @@ TEST_P(IndexFormatTest, SetIndexBufferBeforeSetPipeline) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.DrawIndexed(3);
@ -291,7 +289,7 @@ TEST_P(IndexFormatTest, SetIndexBufferDifferentFormats) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetIndexBufferWithFormat(indexBuffer32, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer32, wgpu::IndexFormat::Uint32);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.DrawIndexed(3);
@ -306,7 +304,7 @@ TEST_P(IndexFormatTest, SetIndexBufferDifferentFormats) {
encoder = device.CreateCommandEncoder();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetIndexBufferWithFormat(indexBuffer16, wgpu::IndexFormat::Uint16);
pass.SetIndexBuffer(indexBuffer16, wgpu::IndexFormat::Uint16);
pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer);
pass.DrawIndexed(3);

View File

@ -84,7 +84,7 @@ class DrawIndirectValidationTest : public ValidationTest {
uint32_t zeros[100] = {};
wgpu::Buffer indexBuffer =
utils::CreateBufferFromData(device, zeros, sizeof(zeros), wgpu::BufferUsage::Index);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexedIndirect(indirectBuffer, indirectOffset);
} else {
pass.DrawIndirect(indirectBuffer, indirectOffset);

View File

@ -48,6 +48,21 @@ class IndexBufferValidationTest : public ValidationTest {
}
};
// Test that IndexFormat::Undefined is disallowed.
TEST_F(IndexBufferValidationTest, UndefinedIndexFormat) {
wgpu::BufferDescriptor bufferDesc;
bufferDesc.usage = wgpu::BufferUsage::Index;
bufferDesc.size = 256;
wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
DummyRenderPass renderPass(device);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Undefined);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Test that for OOB validation of index buffer offset and size.
TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
wgpu::BufferDescriptor bufferDesc;
@ -61,13 +76,13 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
// Explicit size
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 0, 256);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 0, 256);
// Implicit size
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 0, 0);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256 - 4, 0);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 4, 0);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 0, 0);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256 - 4, 0);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 4, 0);
// Implicit size of zero
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256, 0);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256, 0);
pass.EndPass();
encoder.Finish();
}
@ -76,7 +91,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
{
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 4, 256);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 4, 256);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
@ -85,7 +100,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
{
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256 + 4, 0);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256 + 4, 0);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
@ -98,27 +113,27 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
{
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
// Explicit size
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 0, 256);
encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 0, 256);
// Implicit size
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 0, 0);
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256 - 4, 0);
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 4, 0);
encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 0, 0);
encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256 - 4, 0);
encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 4, 0);
// Implicit size of zero
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256, 0);
encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256, 0);
encoder.Finish();
}
// Bad case, offset + size is larger than the buffer
{
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 4, 256);
encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 4, 256);
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Bad case, size is 0 but the offset is larger than the buffer
{
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256 + 4, 0);
encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256 + 4, 0);
ASSERT_DEVICE_ERROR(encoder.Finish());
}
}
@ -141,7 +156,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
// Expected to fail because pipeline and index formats don't match.
{
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16);
encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
encoder.SetPipeline(pipeline32);
encoder.DrawIndexed(3);
ASSERT_DEVICE_ERROR(encoder.Finish());
@ -149,7 +164,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
{
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.SetPipeline(pipeline16);
encoder.DrawIndexed(3);
ASSERT_DEVICE_ERROR(encoder.Finish());
@ -158,7 +173,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
// Expected to succeed because pipeline and index formats match.
{
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16);
encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
encoder.SetPipeline(pipeline16);
encoder.DrawIndexed(3);
encoder.Finish();
@ -166,7 +181,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
{
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.SetPipeline(pipeline32);
encoder.DrawIndexed(3);
encoder.Finish();

View File

@ -582,10 +582,7 @@ TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) {
// primitive topology isn't a strip type.
device.CreateRenderPipeline(&descriptor);
} else {
// TODO(crbug.com/dawn/502): Once setIndexBuffer requires an
// indexFormat. this should fail. For now it succeeds to allow
// backwards compatibility during the deprecation period.
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}
}
}

View File

@ -91,7 +91,7 @@ namespace {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
DummyRenderPass dummyRenderPass(device);
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32);
pass.SetVertexBuffer(0, buffer);
pass.EndPass();
encoder.Finish();
@ -135,7 +135,7 @@ namespace {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
DummyRenderPass dummyRenderPass(device);
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32);
pass.SetBindGroup(0, bg);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
@ -258,12 +258,12 @@ namespace {
DummyRenderPass dummyRenderPass(device);
wgpu::RenderPassEncoder pass0 = encoder.BeginRenderPass(&dummyRenderPass);
pass0.SetIndexBufferWithFormat(buffer0, wgpu::IndexFormat::Uint32);
pass0.SetIndexBuffer(buffer0, wgpu::IndexFormat::Uint32);
pass0.SetBindGroup(0, bg1);
pass0.EndPass();
wgpu::RenderPassEncoder pass1 = encoder.BeginRenderPass(&dummyRenderPass);
pass1.SetIndexBufferWithFormat(buffer1, wgpu::IndexFormat::Uint32);
pass1.SetIndexBuffer(buffer1, wgpu::IndexFormat::Uint32);
pass1.SetBindGroup(0, bg0);
pass1.EndPass();
@ -349,7 +349,7 @@ namespace {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetPipeline(rp);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32);
pass.Draw(3);
pass.SetBindGroup(0, bg);
@ -414,7 +414,7 @@ namespace {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetPipeline(rp);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32);
pass.SetBindGroup(0, writeBG);
pass.Draw(3);
@ -514,8 +514,8 @@ namespace {
{
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBufferWithFormat(buffer0, wgpu::IndexFormat::Uint32);
pass.SetIndexBufferWithFormat(buffer1, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer0, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer1, wgpu::IndexFormat::Uint32);
pass.SetBindGroup(0, bg);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
@ -526,8 +526,8 @@ namespace {
{
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBufferWithFormat(buffer1, wgpu::IndexFormat::Uint32);
pass.SetIndexBufferWithFormat(buffer0, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer1, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer0, wgpu::IndexFormat::Uint32);
pass.SetBindGroup(0, bg);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
@ -584,7 +584,7 @@ namespace {
{
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBufferWithFormat(buffer0, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer0, wgpu::IndexFormat::Uint32);
pass.SetBindGroup(0, bg0);
pass.SetBindGroup(0, bg1);
pass.EndPass();
@ -596,7 +596,7 @@ namespace {
{
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBufferWithFormat(buffer0, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer0, wgpu::IndexFormat::Uint32);
pass.SetBindGroup(0, bg1);
pass.SetBindGroup(0, bg0);
pass.EndPass();
@ -724,7 +724,7 @@ namespace {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
DummyRenderPass dummyRenderPass(device);
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32);
pass.SetBindGroup(0, bg);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());

View File

@ -60,7 +60,7 @@ TEST_F(UnsafeAPIValidationTest, DrawIndexedIndirectDisallowed) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexed(1);
pass.DrawIndirect(indirectBuffer, 0);
@ -73,7 +73,7 @@ TEST_F(UnsafeAPIValidationTest, DrawIndexedIndirectDisallowed) {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&bundleDesc);
encoder.SetPipeline(pipeline);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.DrawIndexed(1);
encoder.DrawIndirect(indirectBuffer, 0);
@ -86,7 +86,7 @@ TEST_F(UnsafeAPIValidationTest, DrawIndexedIndirectDisallowed) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexedIndirect(indirectBuffer, 0);
pass.EndPass();
@ -98,7 +98,7 @@ TEST_F(UnsafeAPIValidationTest, DrawIndexedIndirectDisallowed) {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&bundleDesc);
encoder.SetPipeline(pipeline);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.DrawIndexedIndirect(indirectBuffer, 0);
ASSERT_DEVICE_ERROR(encoder.Finish());