2019-07-20 01:34:56 +00:00
|
|
|
// Copyright 2019 The Dawn Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "dawn_native/RenderEncoderBase.h"
|
|
|
|
|
|
|
|
#include "common/Constants.h"
|
2021-02-23 16:37:29 +00:00
|
|
|
#include "common/Log.h"
|
2019-07-20 01:34:56 +00:00
|
|
|
#include "dawn_native/Buffer.h"
|
2021-09-20 20:39:15 +00:00
|
|
|
#include "dawn_native/BufferLocation.h"
|
2019-07-20 01:34:56 +00:00
|
|
|
#include "dawn_native/CommandEncoder.h"
|
2021-01-22 09:57:38 +00:00
|
|
|
#include "dawn_native/CommandValidation.h"
|
2019-07-20 01:34:56 +00:00
|
|
|
#include "dawn_native/Commands.h"
|
|
|
|
#include "dawn_native/Device.h"
|
|
|
|
#include "dawn_native/RenderPipeline.h"
|
2020-09-01 18:32:49 +00:00
|
|
|
#include "dawn_native/ValidationUtils_autogen.h"
|
2019-07-20 01:34:56 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
2019-07-23 17:04:34 +00:00
|
|
|
#include <cstring>
|
2019-07-20 01:34:56 +00:00
|
|
|
|
|
|
|
namespace dawn_native {
|
|
|
|
|
2021-01-27 17:20:16 +00:00
|
|
|
RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
|
|
|
|
EncodingContext* encodingContext,
|
|
|
|
Ref<AttachmentState> attachmentState)
|
2021-05-05 19:55:23 +00:00
|
|
|
: ProgrammablePassEncoder(device, encodingContext),
|
2021-01-27 17:20:16 +00:00
|
|
|
mAttachmentState(std::move(attachmentState)),
|
2020-02-26 08:24:20 +00:00
|
|
|
mDisableBaseVertex(device->IsToggleEnabled(Toggle::DisableBaseVertex)),
|
|
|
|
mDisableBaseInstance(device->IsToggleEnabled(Toggle::DisableBaseInstance)) {
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
|
2019-07-24 18:15:24 +00:00
|
|
|
EncodingContext* encodingContext,
|
2019-07-20 01:34:56 +00:00
|
|
|
ErrorTag errorTag)
|
2021-05-05 19:55:23 +00:00
|
|
|
: ProgrammablePassEncoder(device, encodingContext, errorTag),
|
2020-02-26 08:24:20 +00:00
|
|
|
mDisableBaseVertex(device->IsToggleEnabled(Toggle::DisableBaseVertex)),
|
|
|
|
mDisableBaseInstance(device->IsToggleEnabled(Toggle::DisableBaseInstance)) {
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
2021-01-27 17:20:16 +00:00
|
|
|
const AttachmentState* RenderEncoderBase::GetAttachmentState() const {
|
|
|
|
ASSERT(!IsError());
|
|
|
|
ASSERT(mAttachmentState != nullptr);
|
|
|
|
return mAttachmentState.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<AttachmentState> RenderEncoderBase::AcquireAttachmentState() {
|
|
|
|
return std::move(mAttachmentState);
|
|
|
|
}
|
|
|
|
|
2021-03-29 14:02:05 +00:00
|
|
|
void RenderEncoderBase::APIDraw(uint32_t vertexCount,
|
|
|
|
uint32_t instanceCount,
|
|
|
|
uint32_t firstVertex,
|
|
|
|
uint32_t firstInstance) {
|
2019-07-24 18:15:24 +00:00
|
|
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
2021-01-23 00:07:46 +00:00
|
|
|
if (IsValidationEnabled()) {
|
2021-01-28 14:44:15 +00:00
|
|
|
DAWN_TRY(mCommandBufferState.ValidateCanDraw());
|
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(mDisableBaseInstance && firstInstance != 0,
|
|
|
|
"First instance (%u) must be zero.", firstInstance);
|
2021-07-16 03:22:58 +00:00
|
|
|
|
|
|
|
DAWN_TRY(mCommandBufferState.ValidateBufferInRangeForVertexBuffer(vertexCount,
|
|
|
|
firstVertex));
|
|
|
|
DAWN_TRY(mCommandBufferState.ValidateBufferInRangeForInstanceBuffer(instanceCount,
|
|
|
|
firstInstance));
|
2020-02-26 08:24:20 +00:00
|
|
|
}
|
|
|
|
|
2019-07-24 18:15:24 +00:00
|
|
|
DrawCmd* draw = allocator->Allocate<DrawCmd>(Command::Draw);
|
|
|
|
draw->vertexCount = vertexCount;
|
|
|
|
draw->instanceCount = instanceCount;
|
|
|
|
draw->firstVertex = firstVertex;
|
|
|
|
draw->firstInstance = firstInstance;
|
|
|
|
|
|
|
|
return {};
|
|
|
|
});
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 14:02:05 +00:00
|
|
|
void RenderEncoderBase::APIDrawIndexed(uint32_t indexCount,
|
|
|
|
uint32_t instanceCount,
|
|
|
|
uint32_t firstIndex,
|
|
|
|
int32_t baseVertex,
|
|
|
|
uint32_t firstInstance) {
|
2019-07-24 18:15:24 +00:00
|
|
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
2021-01-23 00:07:46 +00:00
|
|
|
if (IsValidationEnabled()) {
|
2021-01-28 14:44:15 +00:00
|
|
|
DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed());
|
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(mDisableBaseInstance && firstInstance != 0,
|
|
|
|
"First instance (%u) must be zero.", firstInstance);
|
|
|
|
|
|
|
|
DAWN_INVALID_IF(mDisableBaseVertex && baseVertex != 0,
|
|
|
|
"Base vertex (%u) must be zero.", baseVertex);
|
2020-02-26 08:24:20 +00:00
|
|
|
|
2021-07-16 03:22:58 +00:00
|
|
|
DAWN_TRY(mCommandBufferState.ValidateIndexBufferInRange(indexCount, firstIndex));
|
|
|
|
|
2021-08-25 01:30:03 +00:00
|
|
|
// Although we don't know actual vertex access range in CPU, we still call the
|
|
|
|
// ValidateBufferInRangeForVertexBuffer in order to deal with those vertex step mode
|
|
|
|
// vertex buffer with an array stride of zero.
|
|
|
|
DAWN_TRY(mCommandBufferState.ValidateBufferInRangeForVertexBuffer(0, 0));
|
2021-07-16 03:22:58 +00:00
|
|
|
DAWN_TRY(mCommandBufferState.ValidateBufferInRangeForInstanceBuffer(instanceCount,
|
|
|
|
firstInstance));
|
2021-02-23 16:37:29 +00:00
|
|
|
}
|
2021-07-16 03:22:58 +00:00
|
|
|
|
2019-07-24 18:15:24 +00:00
|
|
|
DrawIndexedCmd* draw = allocator->Allocate<DrawIndexedCmd>(Command::DrawIndexed);
|
|
|
|
draw->indexCount = indexCount;
|
|
|
|
draw->instanceCount = instanceCount;
|
|
|
|
draw->firstIndex = firstIndex;
|
|
|
|
draw->baseVertex = baseVertex;
|
|
|
|
draw->firstInstance = firstInstance;
|
|
|
|
|
|
|
|
return {};
|
|
|
|
});
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 14:02:05 +00:00
|
|
|
void RenderEncoderBase::APIDrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) {
|
2019-07-24 18:15:24 +00:00
|
|
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
2021-01-23 00:07:46 +00:00
|
|
|
if (IsValidationEnabled()) {
|
|
|
|
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
|
|
|
DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
|
2021-01-28 14:44:15 +00:00
|
|
|
DAWN_TRY(mCommandBufferState.ValidateCanDraw());
|
2019-07-24 18:15:24 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(indirectOffset % 4 != 0,
|
|
|
|
"Indirect offset (%u) is not a multiple of 4.", indirectOffset);
|
2020-10-10 00:06:30 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(
|
|
|
|
indirectOffset >= indirectBuffer->GetSize() ||
|
|
|
|
kDrawIndirectSize > indirectBuffer->GetSize() - indirectOffset,
|
|
|
|
"Indirect offset (%u) is out of bounds of indirect buffer %s size (%u).",
|
|
|
|
indirectOffset, indirectBuffer, indirectBuffer->GetSize());
|
2019-07-24 18:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawIndirectCmd* cmd = allocator->Allocate<DrawIndirectCmd>(Command::DrawIndirect);
|
|
|
|
cmd->indirectBuffer = indirectBuffer;
|
|
|
|
cmd->indirectOffset = indirectOffset;
|
|
|
|
|
2019-11-21 22:09:41 +00:00
|
|
|
mUsageTracker.BufferUsedAs(indirectBuffer, wgpu::BufferUsage::Indirect);
|
|
|
|
|
2019-07-24 18:15:24 +00:00
|
|
|
return {};
|
|
|
|
});
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 14:02:05 +00:00
|
|
|
void RenderEncoderBase::APIDrawIndexedIndirect(BufferBase* indirectBuffer,
|
|
|
|
uint64_t indirectOffset) {
|
2019-07-24 18:15:24 +00:00
|
|
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
2021-01-23 00:07:46 +00:00
|
|
|
if (IsValidationEnabled()) {
|
|
|
|
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
|
|
|
|
DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
|
2021-01-28 14:44:15 +00:00
|
|
|
DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed());
|
2021-01-23 00:07:46 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(indirectOffset % 4 != 0,
|
|
|
|
"Indirect offset (%u) is not a multiple of 4.", indirectOffset);
|
2020-10-10 00:06:30 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(
|
|
|
|
(indirectOffset >= indirectBuffer->GetSize() ||
|
|
|
|
kDrawIndexedIndirectSize > indirectBuffer->GetSize() - indirectOffset),
|
|
|
|
"Indirect offset (%u) is out of bounds of indirect buffer %s size (%u).",
|
|
|
|
indirectOffset, indirectBuffer, indirectBuffer->GetSize());
|
2019-07-24 18:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawIndexedIndirectCmd* cmd =
|
|
|
|
allocator->Allocate<DrawIndexedIndirectCmd>(Command::DrawIndexedIndirect);
|
2021-09-23 00:15:19 +00:00
|
|
|
if (IsValidationEnabled()) {
|
|
|
|
cmd->indirectBufferLocation = BufferLocation::New();
|
|
|
|
mIndirectDrawMetadata.AddIndexedIndirectDraw(
|
|
|
|
mCommandBufferState.GetIndexFormat(), mCommandBufferState.GetIndexBufferSize(),
|
|
|
|
indirectBuffer, indirectOffset, cmd->indirectBufferLocation.Get());
|
|
|
|
} else {
|
|
|
|
cmd->indirectBufferLocation = BufferLocation::New(indirectBuffer, indirectOffset);
|
|
|
|
}
|
2019-07-24 18:15:24 +00:00
|
|
|
|
2019-11-21 22:09:41 +00:00
|
|
|
mUsageTracker.BufferUsedAs(indirectBuffer, wgpu::BufferUsage::Indirect);
|
|
|
|
|
2019-07-24 18:15:24 +00:00
|
|
|
return {};
|
|
|
|
});
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 14:02:05 +00:00
|
|
|
void RenderEncoderBase::APISetPipeline(RenderPipelineBase* pipeline) {
|
2019-07-24 18:15:24 +00:00
|
|
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
2021-01-23 00:07:46 +00:00
|
|
|
if (IsValidationEnabled()) {
|
|
|
|
DAWN_TRY(GetDevice()->ValidateObject(pipeline));
|
2021-01-27 17:20:16 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
// TODO(dawn:563): More detail about why the states are incompatible would be nice.
|
|
|
|
DAWN_INVALID_IF(
|
|
|
|
pipeline->GetAttachmentState() != mAttachmentState.Get(),
|
|
|
|
"Attachment state of %s is not compatible with the attachment state of %s",
|
|
|
|
pipeline, this);
|
2021-01-23 00:07:46 +00:00
|
|
|
}
|
2019-07-24 18:15:24 +00:00
|
|
|
|
2021-01-28 14:44:15 +00:00
|
|
|
mCommandBufferState.SetRenderPipeline(pipeline);
|
|
|
|
|
2019-07-24 18:15:24 +00:00
|
|
|
SetRenderPipelineCmd* cmd =
|
|
|
|
allocator->Allocate<SetRenderPipelineCmd>(Command::SetRenderPipeline);
|
|
|
|
cmd->pipeline = pipeline;
|
|
|
|
|
|
|
|
return {};
|
|
|
|
});
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 14:02:05 +00:00
|
|
|
void RenderEncoderBase::APISetIndexBuffer(BufferBase* buffer,
|
|
|
|
wgpu::IndexFormat format,
|
|
|
|
uint64_t offset,
|
|
|
|
uint64_t size) {
|
2019-07-24 18:15:24 +00:00
|
|
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
2021-01-23 00:07:46 +00:00
|
|
|
if (IsValidationEnabled()) {
|
|
|
|
DAWN_TRY(GetDevice()->ValidateObject(buffer));
|
|
|
|
DAWN_TRY(ValidateCanUseAs(buffer, wgpu::BufferUsage::Index));
|
2020-11-25 08:54:14 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(format == wgpu::IndexFormat::Undefined,
|
|
|
|
"Index format must be specified");
|
2020-04-24 09:42:03 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(offset % uint64_t(IndexFormatSize(format)) != 0,
|
|
|
|
"Index buffer offset (%u) is not a multiple of the size (%u)"
|
|
|
|
"of %s.",
|
|
|
|
offset, IndexFormatSize(format), format);
|
2021-06-17 17:48:45 +00:00
|
|
|
|
2021-01-23 00:07:46 +00:00
|
|
|
uint64_t bufferSize = buffer->GetSize();
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(offset > bufferSize,
|
|
|
|
"Index buffer offset (%u) is larger than the size (%u) of %s.",
|
|
|
|
offset, bufferSize, buffer);
|
|
|
|
|
2021-01-23 00:07:46 +00:00
|
|
|
uint64_t remainingSize = bufferSize - offset;
|
|
|
|
|
2021-09-28 02:05:00 +00:00
|
|
|
// Temporarily treat 0 as undefined for size, and give a warning
|
|
|
|
// TODO(dawn:1058): Remove this if block
|
2021-01-23 00:07:46 +00:00
|
|
|
if (size == 0) {
|
2021-09-28 02:05:00 +00:00
|
|
|
size = wgpu::kWholeSize;
|
|
|
|
GetDevice()->EmitDeprecationWarning(
|
|
|
|
"Using size=0 to indicate default binding size for setIndexBuffer "
|
|
|
|
"is deprecated. In the future it will result in a zero-size binding. "
|
|
|
|
"Use `undefined` (wgpu::kWholeSize) or just omit the parameter instead.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size == wgpu::kWholeSize) {
|
2021-01-23 00:07:46 +00:00
|
|
|
size = remainingSize;
|
|
|
|
} else {
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(
|
|
|
|
size > remainingSize,
|
|
|
|
"Index buffer range (offset: %u, size: %u) doesn't fit in the size (%u) of "
|
|
|
|
"%s.",
|
|
|
|
offset, size, bufferSize, buffer);
|
2021-01-23 00:07:46 +00:00
|
|
|
}
|
2020-04-24 09:42:03 +00:00
|
|
|
} else {
|
2021-09-28 02:05:00 +00:00
|
|
|
if (size == wgpu::kWholeSize) {
|
|
|
|
DAWN_ASSERT(buffer->GetSize() >= offset);
|
2021-01-23 00:07:46 +00:00
|
|
|
size = buffer->GetSize() - offset;
|
2020-04-24 09:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-23 16:37:29 +00:00
|
|
|
mCommandBufferState.SetIndexBuffer(format, size);
|
2021-01-28 14:44:15 +00:00
|
|
|
|
2019-07-24 18:15:24 +00:00
|
|
|
SetIndexBufferCmd* cmd =
|
|
|
|
allocator->Allocate<SetIndexBufferCmd>(Command::SetIndexBuffer);
|
|
|
|
cmd->buffer = buffer;
|
2020-08-27 01:13:35 +00:00
|
|
|
cmd->format = format;
|
2019-07-24 18:15:24 +00:00
|
|
|
cmd->offset = offset;
|
2020-04-24 09:42:03 +00:00
|
|
|
cmd->size = size;
|
2019-07-24 18:15:24 +00:00
|
|
|
|
2019-11-21 22:09:41 +00:00
|
|
|
mUsageTracker.BufferUsedAs(buffer, wgpu::BufferUsage::Index);
|
|
|
|
|
2019-07-24 18:15:24 +00:00
|
|
|
return {};
|
|
|
|
});
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 14:02:05 +00:00
|
|
|
void RenderEncoderBase::APISetVertexBuffer(uint32_t slot,
|
|
|
|
BufferBase* buffer,
|
|
|
|
uint64_t offset,
|
|
|
|
uint64_t size) {
|
2019-07-24 18:15:24 +00:00
|
|
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
2021-01-23 00:07:46 +00:00
|
|
|
if (IsValidationEnabled()) {
|
|
|
|
DAWN_TRY(GetDevice()->ValidateObject(buffer));
|
|
|
|
DAWN_TRY(ValidateCanUseAs(buffer, wgpu::BufferUsage::Vertex));
|
2019-07-20 01:34:56 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(slot >= kMaxVertexBuffers,
|
|
|
|
"Vertex buffer slot (%u) is larger the maximum (%u)", slot,
|
|
|
|
kMaxVertexBuffers - 1);
|
2020-04-24 09:42:03 +00:00
|
|
|
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(offset % 4 != 0, "Vertex buffer offset (%u) is not a multiple of 4",
|
|
|
|
offset);
|
2021-06-17 17:48:45 +00:00
|
|
|
|
2021-01-23 00:07:46 +00:00
|
|
|
uint64_t bufferSize = buffer->GetSize();
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(offset > bufferSize,
|
|
|
|
"Vertex buffer offset (%u) is larger than the size (%u) of %s.",
|
|
|
|
offset, bufferSize, buffer);
|
|
|
|
|
2021-01-23 00:07:46 +00:00
|
|
|
uint64_t remainingSize = bufferSize - offset;
|
|
|
|
|
2021-09-28 02:05:00 +00:00
|
|
|
// Temporarily treat 0 as undefined for size, and give a warning
|
|
|
|
// TODO(dawn:1058): Remove this if block
|
2021-01-23 00:07:46 +00:00
|
|
|
if (size == 0) {
|
2021-09-28 02:05:00 +00:00
|
|
|
size = wgpu::kWholeSize;
|
|
|
|
GetDevice()->EmitDeprecationWarning(
|
|
|
|
"Using size=0 to indicate default binding size for setVertexBuffer "
|
|
|
|
"is deprecated. In the future it will result in a zero-size binding. "
|
|
|
|
"Use `undefined` (wgpu::kWholeSize) or just omit the parameter instead.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size == wgpu::kWholeSize) {
|
2021-01-23 00:07:46 +00:00
|
|
|
size = remainingSize;
|
|
|
|
} else {
|
2021-09-28 21:35:43 +00:00
|
|
|
DAWN_INVALID_IF(
|
|
|
|
size > remainingSize,
|
|
|
|
"Vertex buffer range (offset: %u, size: %u) doesn't fit in the size (%u) "
|
|
|
|
"of %s.",
|
|
|
|
offset, size, bufferSize, buffer);
|
2021-01-23 00:07:46 +00:00
|
|
|
}
|
2020-04-24 09:42:03 +00:00
|
|
|
} else {
|
2021-09-28 02:05:00 +00:00
|
|
|
if (size == wgpu::kWholeSize) {
|
|
|
|
DAWN_ASSERT(buffer->GetSize() >= offset);
|
2021-01-23 00:07:46 +00:00
|
|
|
size = buffer->GetSize() - offset;
|
2020-04-24 09:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-16 03:22:58 +00:00
|
|
|
mCommandBufferState.SetVertexBuffer(VertexBufferSlot(uint8_t(slot)), size);
|
2021-01-28 14:44:15 +00:00
|
|
|
|
2019-10-10 07:29:58 +00:00
|
|
|
SetVertexBufferCmd* cmd =
|
|
|
|
allocator->Allocate<SetVertexBufferCmd>(Command::SetVertexBuffer);
|
2020-09-17 19:07:00 +00:00
|
|
|
cmd->slot = VertexBufferSlot(static_cast<uint8_t>(slot));
|
2019-10-10 07:29:58 +00:00
|
|
|
cmd->buffer = buffer;
|
|
|
|
cmd->offset = offset;
|
2020-04-24 09:42:03 +00:00
|
|
|
cmd->size = size;
|
2019-07-20 01:34:56 +00:00
|
|
|
|
2019-11-21 22:09:41 +00:00
|
|
|
mUsageTracker.BufferUsedAs(buffer, wgpu::BufferUsage::Vertex);
|
|
|
|
|
2019-07-24 18:15:24 +00:00
|
|
|
return {};
|
|
|
|
});
|
2019-07-20 01:34:56 +00:00
|
|
|
}
|
|
|
|
|
2021-05-05 19:55:23 +00:00
|
|
|
void RenderEncoderBase::APISetBindGroup(uint32_t groupIndexIn,
|
|
|
|
BindGroupBase* group,
|
|
|
|
uint32_t dynamicOffsetCount,
|
|
|
|
const uint32_t* dynamicOffsets) {
|
|
|
|
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
|
|
|
|
BindGroupIndex groupIndex(groupIndexIn);
|
|
|
|
|
|
|
|
if (IsValidationEnabled()) {
|
|
|
|
DAWN_TRY(
|
|
|
|
ValidateSetBindGroup(groupIndex, group, dynamicOffsetCount, dynamicOffsets));
|
|
|
|
}
|
|
|
|
|
|
|
|
RecordSetBindGroup(allocator, groupIndex, group, dynamicOffsetCount, dynamicOffsets);
|
|
|
|
mCommandBufferState.SetBindGroup(groupIndex, group);
|
|
|
|
mUsageTracker.AddBindGroup(group);
|
|
|
|
|
|
|
|
return {};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-20 01:34:56 +00:00
|
|
|
} // namespace dawn_native
|