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", "name": "set index buffer",
"args": [ "args": [
{"name": "buffer", "type": "buffer"}, {"name": "buffer", "type": "buffer"},
{"name": "format", "type": "index format"},
{"name": "offset", "type": "uint64_t", "default": "0"}, {"name": "offset", "type": "uint64_t", "default": "0"},
{"name": "size", "type": "uint64_t", "default": "0"} {"name": "size", "type": "uint64_t", "default": "0"}
] ]
@ -1349,6 +1350,7 @@
"name": "set index buffer", "name": "set index buffer",
"args": [ "args": [
{"name": "buffer", "type": "buffer"}, {"name": "buffer", "type": "buffer"},
{"name": "format", "type": "index format"},
{"name": "offset", "type": "uint64_t", "default": "0"}, {"name": "offset", "type": "uint64_t", "default": "0"},
{"name": "size", "type": "uint64_t", "default": "0"} {"name": "size", "type": "uint64_t", "default": "0"}
] ]

View File

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

View File

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

View File

@ -126,21 +126,13 @@ namespace dawn_native {
} }
} }
if (aspects[VALIDATION_ASPECT_INDEX_BUFFER]) { if (aspects[VALIDATION_ASPECT_INDEX_BUFFER] && mIndexBufferSet) {
if (mIndexBufferSet) {
wgpu::IndexFormat pipelineIndexFormat = wgpu::IndexFormat pipelineIndexFormat =
mLastRenderPipeline->GetVertexStateDescriptor()->indexFormat; mLastRenderPipeline->GetVertexStateDescriptor()->indexFormat;
if (mIndexFormat != wgpu::IndexFormat::Undefined) {
if (!IsStripPrimitiveTopology(mLastRenderPipeline->GetPrimitiveTopology()) || if (!IsStripPrimitiveTopology(mLastRenderPipeline->GetPrimitiveTopology()) ||
mIndexFormat == pipelineIndexFormat) { mIndexFormat == pipelineIndexFormat) {
mAspects.set(VALIDATION_ASPECT_INDEX_BUFFER); 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; mLastRenderPipeline->GetVertexStateDescriptor()->indexFormat;
if (!mIndexBufferSet) { if (!mIndexBufferSet) {
return DAWN_VALIDATION_ERROR("Missing index buffer"); return DAWN_VALIDATION_ERROR("Missing index buffer");
} else if (mIndexFormat != wgpu::IndexFormat::Undefined && } else if (IsStripPrimitiveTopology(mLastRenderPipeline->GetPrimitiveTopology()) &&
IsStripPrimitiveTopology(mLastRenderPipeline->GetPrimitiveTopology()) &&
mIndexFormat != pipelineIndexFormat) { mIndexFormat != pipelineIndexFormat) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"Pipeline strip index format does not match index buffer format"); "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|. // 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, void RenderEncoderBase::SetIndexBufferWithFormat(BufferBase* buffer, wgpu::IndexFormat format,
uint64_t offset, uint64_t size) { 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, void RenderEncoderBase::SetIndexBuffer(BufferBase* buffer,
uint64_t offset, uint64_t size, wgpu::IndexFormat format,
bool requireFormat) { uint64_t offset,
uint64_t size) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
DAWN_TRY(GetDevice()->ValidateObject(buffer)); DAWN_TRY(GetDevice()->ValidateObject(buffer));
DAWN_TRY(ValidateIndexFormat(format)); DAWN_TRY(ValidateIndexFormat(format));
if (format == wgpu::IndexFormat::Undefined) {
return DAWN_VALIDATION_ERROR("Index format must be specified");
}
uint64_t bufferSize = buffer->GetSize(); uint64_t bufferSize = buffer->GetSize();
if (offset > bufferSize) { 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 = SetIndexBufferCmd* cmd =
allocator->Allocate<SetIndexBufferCmd>(Command::SetIndexBuffer); allocator->Allocate<SetIndexBufferCmd>(Command::SetIndexBuffer);
cmd->buffer = buffer; cmd->buffer = buffer;

View File

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

View File

@ -94,15 +94,16 @@ namespace dawn_native {
} }
DAWN_TRY(ValidateIndexFormat(descriptor->indexFormat)); 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 (IsStripPrimitiveTopology(primitiveTopology)) {
if (descriptor->indexFormat == wgpu::IndexFormat::Undefined) { if (descriptor->indexFormat == wgpu::IndexFormat::Undefined) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"indexFormat must not be undefined when using strip primitive topologies"); "indexFormat must not be undefined when using strip primitive topologies");
} }
} else if (descriptor->indexFormat != wgpu::IndexFormat::Undefined) { } else if (descriptor->indexFormat != wgpu::IndexFormat::Undefined) {
device->EmitDeprecationWarning( return DAWN_VALIDATION_ERROR(
"Specifying an indexFormat when using list primitive topologies is deprecated"); "indexFormat must be undefined when using non-strip primitive topologies");
} }
if (descriptor->vertexBufferCount > kMaxVertexBuffers) { if (descriptor->vertexBufferCount > kMaxVertexBuffers) {

View File

@ -505,46 +505,6 @@ namespace dawn_native { namespace d3d12 {
mD3D12BufferViews = {}; 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, void ResolveMultisampledRenderPass(CommandRecordingContext* commandContext,
BeginRenderPassCmd* renderPass) { BeginRenderPassCmd* renderPass) {
ASSERT(renderPass != nullptr); ASSERT(renderPass != nullptr);
@ -1269,7 +1229,6 @@ namespace dawn_native { namespace d3d12 {
RenderPipeline* lastPipeline = nullptr; RenderPipeline* lastPipeline = nullptr;
PipelineLayout* lastLayout = nullptr; PipelineLayout* lastLayout = nullptr;
VertexBufferTracker vertexBufferTracker = {}; VertexBufferTracker vertexBufferTracker = {};
IndexBufferTracker indexBufferTracker = {};
auto EncodeRenderBundleCommand = [&](CommandIterator* iter, Command type) -> MaybeError { auto EncodeRenderBundleCommand = [&](CommandIterator* iter, Command type) -> MaybeError {
switch (type) { switch (type) {
@ -1287,7 +1246,6 @@ namespace dawn_native { namespace d3d12 {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>(); DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
DAWN_TRY(bindingTracker->Apply(commandContext)); DAWN_TRY(bindingTracker->Apply(commandContext));
indexBufferTracker.Apply(commandList);
vertexBufferTracker.Apply(commandList, lastPipeline); vertexBufferTracker.Apply(commandList, lastPipeline);
commandList->DrawIndexedInstanced(draw->indexCount, draw->instanceCount, commandList->DrawIndexedInstanced(draw->indexCount, draw->instanceCount,
draw->firstIndex, draw->baseVertex, draw->firstIndex, draw->baseVertex,
@ -1312,7 +1270,6 @@ namespace dawn_native { namespace d3d12 {
DrawIndexedIndirectCmd* draw = iter->NextCommand<DrawIndexedIndirectCmd>(); DrawIndexedIndirectCmd* draw = iter->NextCommand<DrawIndexedIndirectCmd>();
DAWN_TRY(bindingTracker->Apply(commandContext)); DAWN_TRY(bindingTracker->Apply(commandContext));
indexBufferTracker.Apply(commandList);
vertexBufferTracker.Apply(commandList, lastPipeline); vertexBufferTracker.Apply(commandList, lastPipeline);
Buffer* buffer = ToBackend(draw->indirectBuffer.Get()); Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
ComPtr<ID3D12CommandSignature> signature = ComPtr<ID3D12CommandSignature> signature =
@ -1371,7 +1328,6 @@ namespace dawn_native { namespace d3d12 {
commandList->IASetPrimitiveTopology(pipeline->GetD3D12PrimitiveTopology()); commandList->IASetPrimitiveTopology(pipeline->GetD3D12PrimitiveTopology());
bindingTracker->OnSetPipeline(pipeline); bindingTracker->OnSetPipeline(pipeline);
indexBufferTracker.OnSetPipeline(pipeline);
lastPipeline = pipeline; lastPipeline = pipeline;
lastLayout = layout; lastLayout = layout;
@ -1395,8 +1351,12 @@ namespace dawn_native { namespace d3d12 {
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>(); SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
indexBufferTracker.OnSetIndexBuffer(ToBackend(cmd->buffer.Get()), cmd->format, D3D12_INDEX_BUFFER_VIEW bufferView;
cmd->offset, cmd->size); bufferView.Format = DXGIIndexFormat(cmd->format);
bufferView.BufferLocation = ToBackend(cmd->buffer)->GetVA() + cmd->offset;
bufferView.SizeInBytes = cmd->size;
commandList->IASetIndexBuffer(&bufferView);
break; break;
} }

View File

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

View File

@ -1009,7 +1009,8 @@ namespace dawn_native { namespace opengl {
RenderPipeline* lastPipeline = nullptr; RenderPipeline* lastPipeline = nullptr;
uint64_t indexBufferBaseOffset = 0; uint64_t indexBufferBaseOffset = 0;
wgpu::IndexFormat indexBufferFormat; GLenum indexBufferFormat;
uint32_t indexFormatSize;
VertexStateBufferBindingTracker vertexStateBufferBindingTracker; VertexStateBufferBindingTracker vertexStateBufferBindingTracker;
BindGroupTracker bindGroupTracker = {}; BindGroupTracker bindGroupTracker = {};
@ -1039,20 +1040,11 @@ namespace dawn_native { namespace opengl {
vertexStateBufferBindingTracker.Apply(gl); vertexStateBufferBindingTracker.Apply(gl);
bindGroupTracker.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) { if (draw->firstInstance > 0) {
gl.DrawElementsInstancedBaseVertexBaseInstance( gl.DrawElementsInstancedBaseVertexBaseInstance(
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount, lastPipeline->GetGLPrimitiveTopology(), draw->indexCount,
IndexFormatType(indexFormat), indexBufferFormat,
reinterpret_cast<void*>(draw->firstIndex * formatSize + reinterpret_cast<void*>(draw->firstIndex * indexFormatSize +
indexBufferBaseOffset), indexBufferBaseOffset),
draw->instanceCount, draw->baseVertex, draw->firstInstance); draw->instanceCount, draw->baseVertex, draw->firstInstance);
} else { } else {
@ -1060,16 +1052,16 @@ namespace dawn_native { namespace opengl {
if (draw->baseVertex != 0) { if (draw->baseVertex != 0) {
gl.DrawElementsInstancedBaseVertex( gl.DrawElementsInstancedBaseVertex(
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount, lastPipeline->GetGLPrimitiveTopology(), draw->indexCount,
IndexFormatType(indexFormat), indexBufferFormat,
reinterpret_cast<void*>(draw->firstIndex * formatSize + reinterpret_cast<void*>(draw->firstIndex * indexFormatSize +
indexBufferBaseOffset), indexBufferBaseOffset),
draw->instanceCount, draw->baseVertex); draw->instanceCount, draw->baseVertex);
} else { } else {
// This branch is only needed on OpenGL < 3.2; ES < 3.2 // This branch is only needed on OpenGL < 3.2; ES < 3.2
gl.DrawElementsInstanced( gl.DrawElementsInstanced(
lastPipeline->GetGLPrimitiveTopology(), draw->indexCount, lastPipeline->GetGLPrimitiveTopology(), draw->indexCount,
IndexFormatType(indexFormat), indexBufferFormat,
reinterpret_cast<void*>(draw->firstIndex * formatSize + reinterpret_cast<void*>(draw->firstIndex * indexFormatSize +
indexBufferBaseOffset), indexBufferBaseOffset),
draw->instanceCount); draw->instanceCount);
} }
@ -1100,17 +1092,9 @@ namespace dawn_native { namespace opengl {
uint64_t indirectBufferOffset = draw->indirectOffset; uint64_t indirectBufferOffset = draw->indirectOffset;
Buffer* indirectBuffer = ToBackend(draw->indirectBuffer.Get()); 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.BindBuffer(GL_DRAW_INDIRECT_BUFFER, indirectBuffer->GetHandle());
gl.DrawElementsIndirect( gl.DrawElementsIndirect(
lastPipeline->GetGLPrimitiveTopology(), IndexFormatType(indexFormat), lastPipeline->GetGLPrimitiveTopology(), indexBufferFormat,
reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset))); reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset)));
break; break;
} }
@ -1147,10 +1131,10 @@ namespace dawn_native { namespace opengl {
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>(); 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; indexBufferBaseOffset = cmd->offset;
indexBufferFormat = IndexFormatType(cmd->format);
indexFormatSize = IndexFormatSize(cmd->format);
vertexStateBufferBindingTracker.OnSetIndexBuffer(cmd->buffer.Get()); vertexStateBufferBindingTracker.OnSetIndexBuffer(cmd->buffer.Get());
break; 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, MaybeError RecordBeginRenderPass(CommandRecordingContext* recordingContext,
Device* device, Device* device,
BeginRenderPassCmd* renderPass) { BeginRenderPassCmd* renderPass) {
@ -1000,7 +965,6 @@ namespace dawn_native { namespace vulkan {
} }
RenderDescriptorSetTracker descriptorSets = {}; RenderDescriptorSetTracker descriptorSets = {};
IndexBufferTracker indexBufferTracker = {};
RenderPipeline* lastPipeline = nullptr; RenderPipeline* lastPipeline = nullptr;
auto EncodeRenderBundleCommand = [&](CommandIterator* iter, Command type) { auto EncodeRenderBundleCommand = [&](CommandIterator* iter, Command type) {
@ -1018,7 +982,6 @@ namespace dawn_native { namespace vulkan {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>(); DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_GRAPHICS); descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_GRAPHICS);
indexBufferTracker.Apply(device, commands);
device->fn.CmdDrawIndexed(commands, draw->indexCount, draw->instanceCount, device->fn.CmdDrawIndexed(commands, draw->indexCount, draw->instanceCount,
draw->firstIndex, draw->baseVertex, draw->firstIndex, draw->baseVertex,
draw->firstInstance); draw->firstInstance);
@ -1041,7 +1004,6 @@ namespace dawn_native { namespace vulkan {
VkBuffer indirectBuffer = ToBackend(draw->indirectBuffer)->GetHandle(); VkBuffer indirectBuffer = ToBackend(draw->indirectBuffer)->GetHandle();
descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_GRAPHICS); descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_GRAPHICS);
indexBufferTracker.Apply(device, commands);
device->fn.CmdDrawIndexedIndirect( device->fn.CmdDrawIndexedIndirect(
commands, indirectBuffer, static_cast<VkDeviceSize>(draw->indirectOffset), commands, indirectBuffer, static_cast<VkDeviceSize>(draw->indirectOffset),
1, 0); 1, 0);
@ -1115,8 +1077,8 @@ namespace dawn_native { namespace vulkan {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>(); SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
VkBuffer indexBuffer = ToBackend(cmd->buffer)->GetHandle(); VkBuffer indexBuffer = ToBackend(cmd->buffer)->GetHandle();
indexBufferTracker.OnSetIndexBuffer(indexBuffer, cmd->format, device->fn.CmdBindIndexBuffer(commands, indexBuffer, cmd->offset,
static_cast<VkDeviceSize>(cmd->offset)); VulkanIndexType(cmd->format));
break; break;
} }
@ -1129,7 +1091,6 @@ namespace dawn_native { namespace vulkan {
lastPipeline = pipeline; lastPipeline = pipeline;
descriptorSets.OnSetPipeline(pipeline); descriptorSets.OnSetPipeline(pipeline);
indexBufferTracker.OnSetPipeline(pipeline);
break; 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 // Bind the buffer with offset == indexBufferOffset and size sizeof(uint32_t) as the index
// buffer. // buffer.
renderPass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16, renderPass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16, indexBufferOffset,
indexBufferOffset, sizeof(uint32_t)); sizeof(uint32_t));
renderPass.DrawIndexed(1); renderPass.DrawIndexed(1);
renderPass.EndPass(); renderPass.EndPass();
@ -401,7 +401,7 @@ class BufferZeroInitTest : public DawnTest {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor); wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor);
renderPass.SetPipeline(renderPipeline); renderPass.SetPipeline(renderPipeline);
renderPass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16); renderPass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
renderPass.DrawIndexedIndirect(indirectBuffer, indirectBufferOffset); renderPass.DrawIndexedIndirect(indirectBuffer, indirectBufferOffset);
renderPass.EndPass(); 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 that using BGLEntry.multisampled = true emits a deprecation warning.
TEST_P(DeprecationTests, BGLEntryMultisampledDeprecated) { TEST_P(DeprecationTests, BGLEntryMultisampledDeprecated) {
wgpu::BindGroupLayoutEntry entry{}; wgpu::BindGroupLayoutEntry entry{};
@ -160,108 +176,3 @@ class BufferCopyViewDeprecationTests : public DeprecationTests {
wgpu::Extent3D copySize = {1, 1, 1}; 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); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32, indexOffset); pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32, indexOffset);
pass.DrawIndexedIndirect(indirectBuffer, indirectOffset); pass.DrawIndexedIndirect(indirectBuffer, indirectOffset);
pass.EndPass(); pass.EndPass();
} }

View File

@ -89,7 +89,7 @@ class DrawIndexedTest : public DawnTest {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); 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.DrawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
pass.EndPass(); pass.EndPass();
} }

View File

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

View File

@ -80,7 +80,7 @@ TEST_P(IndexFormatTest, Uint32) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32); pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexed(3); pass.DrawIndexed(3);
pass.EndPass(); pass.EndPass();
} }
@ -107,7 +107,7 @@ TEST_P(IndexFormatTest, Uint16) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16); pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
pass.DrawIndexed(3); pass.DrawIndexed(3);
pass.EndPass(); pass.EndPass();
} }
@ -157,7 +157,7 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32); pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.DrawIndexed(7); pass.DrawIndexed(7);
pass.EndPass(); pass.EndPass();
} }
@ -199,7 +199,7 @@ TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16); pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
pass.DrawIndexed(7); pass.DrawIndexed(7);
pass.EndPass(); pass.EndPass();
} }
@ -232,7 +232,7 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetPipeline(pipeline16); pass.SetPipeline(pipeline16);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32); pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetPipeline(pipeline32); pass.SetPipeline(pipeline32);
pass.DrawIndexed(3); pass.DrawIndexed(3);
pass.EndPass(); pass.EndPass();
@ -247,8 +247,6 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
// Test that setting the index buffer before the pipeline works, this is important // 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 // 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). // 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) { TEST_P(IndexFormatTest, SetIndexBufferBeforeSetPipeline) {
wgpu::RenderPipeline pipeline = MakeTestPipeline(wgpu::IndexFormat::Uint32); wgpu::RenderPipeline pipeline = MakeTestPipeline(wgpu::IndexFormat::Uint32);
@ -261,7 +259,7 @@ TEST_P(IndexFormatTest, SetIndexBufferBeforeSetPipeline) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32); pass.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.DrawIndexed(3); pass.DrawIndexed(3);
@ -291,7 +289,7 @@ TEST_P(IndexFormatTest, SetIndexBufferDifferentFormats) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetIndexBufferWithFormat(indexBuffer32, wgpu::IndexFormat::Uint32); pass.SetIndexBuffer(indexBuffer32, wgpu::IndexFormat::Uint32);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.DrawIndexed(3); pass.DrawIndexed(3);
@ -306,7 +304,7 @@ TEST_P(IndexFormatTest, SetIndexBufferDifferentFormats) {
encoder = device.CreateCommandEncoder(); encoder = device.CreateCommandEncoder();
{ {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
pass.SetIndexBufferWithFormat(indexBuffer16, wgpu::IndexFormat::Uint16); pass.SetIndexBuffer(indexBuffer16, wgpu::IndexFormat::Uint16);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.DrawIndexed(3); pass.DrawIndexed(3);

View File

@ -84,7 +84,7 @@ class DrawIndirectValidationTest : public ValidationTest {
uint32_t zeros[100] = {}; uint32_t zeros[100] = {};
wgpu::Buffer indexBuffer = wgpu::Buffer indexBuffer =
utils::CreateBufferFromData(device, zeros, sizeof(zeros), wgpu::BufferUsage::Index); 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); pass.DrawIndexedIndirect(indirectBuffer, indirectOffset);
} else { } else {
pass.DrawIndirect(indirectBuffer, indirectOffset); 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 that for OOB validation of index buffer offset and size.
TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) { TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
wgpu::BufferDescriptor bufferDesc; wgpu::BufferDescriptor bufferDesc;
@ -61,13 +76,13 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
// Explicit size // Explicit size
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 0, 256); pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 0, 256);
// Implicit size // Implicit size
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 0, 0); pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 0, 0);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256 - 4, 0); pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256 - 4, 0);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 4, 0); pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 4, 0);
// Implicit size of zero // Implicit size of zero
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256, 0); pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256, 0);
pass.EndPass(); pass.EndPass();
encoder.Finish(); encoder.Finish();
} }
@ -76,7 +91,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
{ {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 4, 256); pass.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 4, 256);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
} }
@ -85,7 +100,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
{ {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); 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(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
} }
@ -98,27 +113,27 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
{ {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc); wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
// Explicit size // Explicit size
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 0, 256); encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 0, 256);
// Implicit size // Implicit size
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 0, 0); encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 0, 0);
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256 - 4, 0); encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256 - 4, 0);
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 4, 0); encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 4, 0);
// Implicit size of zero // Implicit size of zero
encoder.SetIndexBufferWithFormat(buffer, wgpu::IndexFormat::Uint32, 256, 0); encoder.SetIndexBuffer(buffer, wgpu::IndexFormat::Uint32, 256, 0);
encoder.Finish(); encoder.Finish();
} }
// Bad case, offset + size is larger than the buffer // Bad case, offset + size is larger than the buffer
{ {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc); 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()); ASSERT_DEVICE_ERROR(encoder.Finish());
} }
// Bad case, size is 0 but the offset is larger than the buffer // Bad case, size is 0 but the offset is larger than the buffer
{ {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc); 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()); ASSERT_DEVICE_ERROR(encoder.Finish());
} }
} }
@ -141,7 +156,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
// Expected to fail because pipeline and index formats don't match. // Expected to fail because pipeline and index formats don't match.
{ {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc); wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16); encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
encoder.SetPipeline(pipeline32); encoder.SetPipeline(pipeline32);
encoder.DrawIndexed(3); encoder.DrawIndexed(3);
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -149,7 +164,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
{ {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc); wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32); encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.SetPipeline(pipeline16); encoder.SetPipeline(pipeline16);
encoder.DrawIndexed(3); encoder.DrawIndexed(3);
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -158,7 +173,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
// Expected to succeed because pipeline and index formats match. // Expected to succeed because pipeline and index formats match.
{ {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc); wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint16); encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
encoder.SetPipeline(pipeline16); encoder.SetPipeline(pipeline16);
encoder.DrawIndexed(3); encoder.DrawIndexed(3);
encoder.Finish(); encoder.Finish();
@ -166,7 +181,7 @@ TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
{ {
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc); wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
encoder.SetIndexBufferWithFormat(indexBuffer, wgpu::IndexFormat::Uint32); encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
encoder.SetPipeline(pipeline32); encoder.SetPipeline(pipeline32);
encoder.DrawIndexed(3); encoder.DrawIndexed(3);
encoder.Finish(); encoder.Finish();

View File

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

View File

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

View File

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