Add RenderEncoderBase to match WebGPU class hierarchy.
This is needed so that RenderBundleEncoder and RenderPassEncoder can share code. This patch also moves EndPass out of ProgrammablePassEncoder and into both RenderPassEncoder and ComputePassEncoder. Render bundles do not have EndPass. Bug: dawn:154 Change-Id: Ib7126b2ba718b0b93e3d6f15c429ac910c0d5d31 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9180 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
c0b8132f55
commit
69f1db7248
2
BUILD.gn
2
BUILD.gn
|
@ -153,6 +153,8 @@ source_set("libdawn_native_sources") {
|
||||||
"src/dawn_native/Queue.h",
|
"src/dawn_native/Queue.h",
|
||||||
"src/dawn_native/RefCounted.cpp",
|
"src/dawn_native/RefCounted.cpp",
|
||||||
"src/dawn_native/RefCounted.h",
|
"src/dawn_native/RefCounted.h",
|
||||||
|
"src/dawn_native/RenderEncoderBase.cpp",
|
||||||
|
"src/dawn_native/RenderEncoderBase.h",
|
||||||
"src/dawn_native/RenderPassEncoder.cpp",
|
"src/dawn_native/RenderPassEncoder.cpp",
|
||||||
"src/dawn_native/RenderPassEncoder.h",
|
"src/dawn_native/RenderPassEncoder.h",
|
||||||
"src/dawn_native/RenderPipeline.cpp",
|
"src/dawn_native/RenderPipeline.cpp",
|
||||||
|
|
|
@ -39,6 +39,15 @@ namespace dawn_native {
|
||||||
return new ComputePassEncoderBase(device, topLevelEncoder, ObjectBase::kError);
|
return new ComputePassEncoderBase(device, topLevelEncoder, ObjectBase::kError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComputePassEncoderBase::EndPass() {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mTopLevelEncoder->PassEnded();
|
||||||
|
mAllocator = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void ComputePassEncoderBase::Dispatch(uint32_t x, uint32_t y, uint32_t z) {
|
void ComputePassEncoderBase::Dispatch(uint32_t x, uint32_t y, uint32_t z) {
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -33,6 +33,8 @@ namespace dawn_native {
|
||||||
static ComputePassEncoderBase* MakeError(DeviceBase* device,
|
static ComputePassEncoderBase* MakeError(DeviceBase* device,
|
||||||
CommandEncoderBase* topLevelEncoder);
|
CommandEncoderBase* topLevelEncoder);
|
||||||
|
|
||||||
|
void EndPass();
|
||||||
|
|
||||||
void Dispatch(uint32_t x, uint32_t y, uint32_t z);
|
void Dispatch(uint32_t x, uint32_t y, uint32_t z);
|
||||||
void DispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
void DispatchIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
||||||
void SetPipeline(ComputePipelineBase* pipeline);
|
void SetPipeline(ComputePipelineBase* pipeline);
|
||||||
|
|
|
@ -38,15 +38,6 @@ namespace dawn_native {
|
||||||
: ObjectBase(device, errorTag), mTopLevelEncoder(topLevelEncoder), mAllocator(nullptr) {
|
: ObjectBase(device, errorTag), mTopLevelEncoder(topLevelEncoder), mAllocator(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgrammablePassEncoder::EndPass() {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mTopLevelEncoder->PassEnded();
|
|
||||||
mAllocator = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProgrammablePassEncoder::InsertDebugMarker(const char* groupLabel) {
|
void ProgrammablePassEncoder::InsertDebugMarker(const char* groupLabel) {
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -33,8 +33,6 @@ namespace dawn_native {
|
||||||
CommandEncoderBase* topLevelEncoder,
|
CommandEncoderBase* topLevelEncoder,
|
||||||
CommandAllocator* allocator);
|
CommandAllocator* allocator);
|
||||||
|
|
||||||
void EndPass();
|
|
||||||
|
|
||||||
void InsertDebugMarker(const char* groupLabel);
|
void InsertDebugMarker(const char* groupLabel);
|
||||||
void PopDebugGroup();
|
void PopDebugGroup();
|
||||||
void PushDebugGroup(const char* groupLabel);
|
void PushDebugGroup(const char* groupLabel);
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
// 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"
|
||||||
|
#include "dawn_native/Buffer.h"
|
||||||
|
#include "dawn_native/CommandEncoder.h"
|
||||||
|
#include "dawn_native/Commands.h"
|
||||||
|
#include "dawn_native/Device.h"
|
||||||
|
#include "dawn_native/RenderPipeline.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace dawn_native {
|
||||||
|
|
||||||
|
RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
|
||||||
|
CommandEncoderBase* topLevelEncoder,
|
||||||
|
CommandAllocator* allocator)
|
||||||
|
: ProgrammablePassEncoder(device, topLevelEncoder, allocator) {
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderEncoderBase::RenderEncoderBase(DeviceBase* device,
|
||||||
|
CommandEncoderBase* topLevelEncoder,
|
||||||
|
ErrorTag errorTag)
|
||||||
|
: ProgrammablePassEncoder(device, topLevelEncoder, errorTag) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderEncoderBase::Draw(uint32_t vertexCount,
|
||||||
|
uint32_t instanceCount,
|
||||||
|
uint32_t firstVertex,
|
||||||
|
uint32_t firstInstance) {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawCmd* draw = mAllocator->Allocate<DrawCmd>(Command::Draw);
|
||||||
|
draw->vertexCount = vertexCount;
|
||||||
|
draw->instanceCount = instanceCount;
|
||||||
|
draw->firstVertex = firstVertex;
|
||||||
|
draw->firstInstance = firstInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderEncoderBase::DrawIndexed(uint32_t indexCount,
|
||||||
|
uint32_t instanceCount,
|
||||||
|
uint32_t firstIndex,
|
||||||
|
int32_t baseVertex,
|
||||||
|
uint32_t firstInstance) {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawIndexedCmd* draw = mAllocator->Allocate<DrawIndexedCmd>(Command::DrawIndexed);
|
||||||
|
draw->indexCount = indexCount;
|
||||||
|
draw->instanceCount = instanceCount;
|
||||||
|
draw->firstIndex = firstIndex;
|
||||||
|
draw->baseVertex = baseVertex;
|
||||||
|
draw->firstInstance = firstInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderEncoderBase::DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands()) ||
|
||||||
|
mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(indirectBuffer))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indirectOffset >= indirectBuffer->GetSize() ||
|
||||||
|
indirectOffset + kDrawIndirectSize > indirectBuffer->GetSize()) {
|
||||||
|
mTopLevelEncoder->HandleError("Indirect offset out of bounds");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawIndirectCmd* cmd = mAllocator->Allocate<DrawIndirectCmd>(Command::DrawIndirect);
|
||||||
|
cmd->indirectBuffer = indirectBuffer;
|
||||||
|
cmd->indirectOffset = indirectOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderEncoderBase::DrawIndexedIndirect(BufferBase* indirectBuffer,
|
||||||
|
uint64_t indirectOffset) {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands()) ||
|
||||||
|
mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(indirectBuffer))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indirectOffset >= indirectBuffer->GetSize() ||
|
||||||
|
indirectOffset + kDrawIndexedIndirectSize > indirectBuffer->GetSize()) {
|
||||||
|
mTopLevelEncoder->HandleError("Indirect offset out of bounds");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawIndexedIndirectCmd* cmd =
|
||||||
|
mAllocator->Allocate<DrawIndexedIndirectCmd>(Command::DrawIndexedIndirect);
|
||||||
|
cmd->indirectBuffer = indirectBuffer;
|
||||||
|
cmd->indirectOffset = indirectOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderEncoderBase::SetPipeline(RenderPipelineBase* pipeline) {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands()) ||
|
||||||
|
mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(pipeline))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetRenderPipelineCmd* cmd =
|
||||||
|
mAllocator->Allocate<SetRenderPipelineCmd>(Command::SetRenderPipeline);
|
||||||
|
cmd->pipeline = pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderEncoderBase::SetIndexBuffer(BufferBase* buffer, uint64_t offset) {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands()) ||
|
||||||
|
mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(buffer))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetIndexBufferCmd* cmd = mAllocator->Allocate<SetIndexBufferCmd>(Command::SetIndexBuffer);
|
||||||
|
cmd->buffer = buffer;
|
||||||
|
cmd->offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderEncoderBase::SetVertexBuffers(uint32_t startSlot,
|
||||||
|
uint32_t count,
|
||||||
|
BufferBase* const* buffers,
|
||||||
|
uint64_t const* offsets) {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
if (mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(buffers[i]))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetVertexBuffersCmd* cmd =
|
||||||
|
mAllocator->Allocate<SetVertexBuffersCmd>(Command::SetVertexBuffers);
|
||||||
|
cmd->startSlot = startSlot;
|
||||||
|
cmd->count = count;
|
||||||
|
|
||||||
|
Ref<BufferBase>* cmdBuffers = mAllocator->AllocateData<Ref<BufferBase>>(count);
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
cmdBuffers[i] = buffers[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t* cmdOffsets = mAllocator->AllocateData<uint64_t>(count);
|
||||||
|
memcpy(cmdOffsets, offsets, count * sizeof(uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dawn_native
|
|
@ -0,0 +1,67 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef DAWNNATIVE_RENDERENCODERBASE_H_
|
||||||
|
#define DAWNNATIVE_RENDERENCODERBASE_H_
|
||||||
|
|
||||||
|
#include "dawn_native/Error.h"
|
||||||
|
#include "dawn_native/ProgrammablePassEncoder.h"
|
||||||
|
|
||||||
|
namespace dawn_native {
|
||||||
|
|
||||||
|
class RenderEncoderBase : public ProgrammablePassEncoder {
|
||||||
|
public:
|
||||||
|
RenderEncoderBase(DeviceBase* device,
|
||||||
|
CommandEncoderBase* topLevelEncoder,
|
||||||
|
CommandAllocator* allocator);
|
||||||
|
|
||||||
|
void Draw(uint32_t vertexCount,
|
||||||
|
uint32_t instanceCount,
|
||||||
|
uint32_t firstVertex,
|
||||||
|
uint32_t firstInstance);
|
||||||
|
void DrawIndexed(uint32_t vertexCount,
|
||||||
|
uint32_t instanceCount,
|
||||||
|
uint32_t firstIndex,
|
||||||
|
int32_t baseVertex,
|
||||||
|
uint32_t firstInstance);
|
||||||
|
|
||||||
|
void DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
||||||
|
void DrawIndexedIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
||||||
|
|
||||||
|
void SetPipeline(RenderPipelineBase* pipeline);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SetVertexBuffers(uint32_t startSlot,
|
||||||
|
uint32_t count,
|
||||||
|
T* const* buffers,
|
||||||
|
uint64_t const* offsets) {
|
||||||
|
static_assert(std::is_base_of<BufferBase, T>::value, "");
|
||||||
|
SetVertexBuffers(startSlot, count, buffers, offsets);
|
||||||
|
}
|
||||||
|
void SetVertexBuffers(uint32_t startSlot,
|
||||||
|
uint32_t count,
|
||||||
|
BufferBase* const* buffers,
|
||||||
|
uint64_t const* offsets);
|
||||||
|
void SetIndexBuffer(BufferBase* buffer, uint64_t offset);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Construct an "error" render encoder base.
|
||||||
|
RenderEncoderBase(DeviceBase* device,
|
||||||
|
CommandEncoderBase* topLevelEncoder,
|
||||||
|
ErrorTag errorTag);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dawn_native
|
||||||
|
|
||||||
|
#endif // DAWNNATIVE_RENDERENCODERBASE_H_
|
|
@ -29,13 +29,13 @@ namespace dawn_native {
|
||||||
RenderPassEncoderBase::RenderPassEncoderBase(DeviceBase* device,
|
RenderPassEncoderBase::RenderPassEncoderBase(DeviceBase* device,
|
||||||
CommandEncoderBase* topLevelEncoder,
|
CommandEncoderBase* topLevelEncoder,
|
||||||
CommandAllocator* allocator)
|
CommandAllocator* allocator)
|
||||||
: ProgrammablePassEncoder(device, topLevelEncoder, allocator) {
|
: RenderEncoderBase(device, topLevelEncoder, allocator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPassEncoderBase::RenderPassEncoderBase(DeviceBase* device,
|
RenderPassEncoderBase::RenderPassEncoderBase(DeviceBase* device,
|
||||||
CommandEncoderBase* topLevelEncoder,
|
CommandEncoderBase* topLevelEncoder,
|
||||||
ErrorTag errorTag)
|
ErrorTag errorTag)
|
||||||
: ProgrammablePassEncoder(device, topLevelEncoder, errorTag) {
|
: RenderEncoderBase(device, topLevelEncoder, errorTag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPassEncoderBase* RenderPassEncoderBase::MakeError(DeviceBase* device,
|
RenderPassEncoderBase* RenderPassEncoderBase::MakeError(DeviceBase* device,
|
||||||
|
@ -43,83 +43,13 @@ namespace dawn_native {
|
||||||
return new RenderPassEncoderBase(device, topLevelEncoder, ObjectBase::kError);
|
return new RenderPassEncoderBase(device, topLevelEncoder, ObjectBase::kError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoderBase::Draw(uint32_t vertexCount,
|
void RenderPassEncoderBase::EndPass() {
|
||||||
uint32_t instanceCount,
|
|
||||||
uint32_t firstVertex,
|
|
||||||
uint32_t firstInstance) {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawCmd* draw = mAllocator->Allocate<DrawCmd>(Command::Draw);
|
mTopLevelEncoder->PassEnded();
|
||||||
draw->vertexCount = vertexCount;
|
mAllocator = nullptr;
|
||||||
draw->instanceCount = instanceCount;
|
|
||||||
draw->firstVertex = firstVertex;
|
|
||||||
draw->firstInstance = firstInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderPassEncoderBase::DrawIndexed(uint32_t indexCount,
|
|
||||||
uint32_t instanceCount,
|
|
||||||
uint32_t firstIndex,
|
|
||||||
int32_t baseVertex,
|
|
||||||
uint32_t firstInstance) {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawIndexedCmd* draw = mAllocator->Allocate<DrawIndexedCmd>(Command::DrawIndexed);
|
|
||||||
draw->indexCount = indexCount;
|
|
||||||
draw->instanceCount = instanceCount;
|
|
||||||
draw->firstIndex = firstIndex;
|
|
||||||
draw->baseVertex = baseVertex;
|
|
||||||
draw->firstInstance = firstInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderPassEncoderBase::DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset) {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands()) ||
|
|
||||||
mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(indirectBuffer))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (indirectOffset >= indirectBuffer->GetSize() ||
|
|
||||||
indirectOffset + kDrawIndirectSize > indirectBuffer->GetSize()) {
|
|
||||||
mTopLevelEncoder->HandleError("Indirect offset out of bounds");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawIndirectCmd* cmd = mAllocator->Allocate<DrawIndirectCmd>(Command::DrawIndirect);
|
|
||||||
cmd->indirectBuffer = indirectBuffer;
|
|
||||||
cmd->indirectOffset = indirectOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderPassEncoderBase::DrawIndexedIndirect(BufferBase* indirectBuffer,
|
|
||||||
uint64_t indirectOffset) {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands()) ||
|
|
||||||
mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(indirectBuffer))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (indirectOffset >= indirectBuffer->GetSize() ||
|
|
||||||
indirectOffset + kDrawIndexedIndirectSize > indirectBuffer->GetSize()) {
|
|
||||||
mTopLevelEncoder->HandleError("Indirect offset out of bounds");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawIndexedIndirectCmd* cmd =
|
|
||||||
mAllocator->Allocate<DrawIndexedIndirectCmd>(Command::DrawIndexedIndirect);
|
|
||||||
cmd->indirectBuffer = indirectBuffer;
|
|
||||||
cmd->indirectOffset = indirectOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderPassEncoderBase::SetPipeline(RenderPipelineBase* pipeline) {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands()) ||
|
|
||||||
mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(pipeline))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetRenderPipelineCmd* cmd =
|
|
||||||
mAllocator->Allocate<SetRenderPipelineCmd>(Command::SetRenderPipeline);
|
|
||||||
cmd->pipeline = pipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoderBase::SetStencilReference(uint32_t reference) {
|
void RenderPassEncoderBase::SetStencilReference(uint32_t reference) {
|
||||||
|
@ -198,43 +128,4 @@ namespace dawn_native {
|
||||||
cmd->height = height;
|
cmd->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPassEncoderBase::SetIndexBuffer(BufferBase* buffer, uint64_t offset) {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands()) ||
|
|
||||||
mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(buffer))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetIndexBufferCmd* cmd = mAllocator->Allocate<SetIndexBufferCmd>(Command::SetIndexBuffer);
|
|
||||||
cmd->buffer = buffer;
|
|
||||||
cmd->offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderPassEncoderBase::SetVertexBuffers(uint32_t startSlot,
|
|
||||||
uint32_t count,
|
|
||||||
BufferBase* const* buffers,
|
|
||||||
uint64_t const* offsets) {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(ValidateCanRecordCommands())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < count; ++i) {
|
|
||||||
if (mTopLevelEncoder->ConsumedError(GetDevice()->ValidateObject(buffers[i]))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetVertexBuffersCmd* cmd =
|
|
||||||
mAllocator->Allocate<SetVertexBuffersCmd>(Command::SetVertexBuffers);
|
|
||||||
cmd->startSlot = startSlot;
|
|
||||||
cmd->count = count;
|
|
||||||
|
|
||||||
Ref<BufferBase>* cmdBuffers = mAllocator->AllocateData<Ref<BufferBase>>(count);
|
|
||||||
for (size_t i = 0; i < count; ++i) {
|
|
||||||
cmdBuffers[i] = buffers[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t* cmdOffsets = mAllocator->AllocateData<uint64_t>(count);
|
|
||||||
memcpy(cmdOffsets, offsets, count * sizeof(uint64_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define DAWNNATIVE_RENDERPASSENCODER_H_
|
#define DAWNNATIVE_RENDERPASSENCODER_H_
|
||||||
|
|
||||||
#include "dawn_native/Error.h"
|
#include "dawn_native/Error.h"
|
||||||
#include "dawn_native/ProgrammablePassEncoder.h"
|
#include "dawn_native/RenderEncoderBase.h"
|
||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace dawn_native {
|
||||||
// is a pure frontend type to record in its parent CommandEncoder and never has a backend
|
// is a pure frontend type to record in its parent CommandEncoder and never has a backend
|
||||||
// implementation.
|
// implementation.
|
||||||
// TODO(cwallez@chromium.org): Remove that generator limitation and rename to ComputePassEncoder
|
// TODO(cwallez@chromium.org): Remove that generator limitation and rename to ComputePassEncoder
|
||||||
class RenderPassEncoderBase : public ProgrammablePassEncoder {
|
class RenderPassEncoderBase : public RenderEncoderBase {
|
||||||
public:
|
public:
|
||||||
RenderPassEncoderBase(DeviceBase* device,
|
RenderPassEncoderBase(DeviceBase* device,
|
||||||
CommandEncoderBase* topLevelEncoder,
|
CommandEncoderBase* topLevelEncoder,
|
||||||
|
@ -33,20 +33,7 @@ namespace dawn_native {
|
||||||
static RenderPassEncoderBase* MakeError(DeviceBase* device,
|
static RenderPassEncoderBase* MakeError(DeviceBase* device,
|
||||||
CommandEncoderBase* topLevelEncoder);
|
CommandEncoderBase* topLevelEncoder);
|
||||||
|
|
||||||
void Draw(uint32_t vertexCount,
|
void EndPass();
|
||||||
uint32_t instanceCount,
|
|
||||||
uint32_t firstVertex,
|
|
||||||
uint32_t firstInstance);
|
|
||||||
void DrawIndexed(uint32_t vertexCount,
|
|
||||||
uint32_t instanceCount,
|
|
||||||
uint32_t firstIndex,
|
|
||||||
int32_t baseVertex,
|
|
||||||
uint32_t firstInstance);
|
|
||||||
|
|
||||||
void DrawIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
|
||||||
void DrawIndexedIndirect(BufferBase* indirectBuffer, uint64_t indirectOffset);
|
|
||||||
|
|
||||||
void SetPipeline(RenderPipelineBase* pipeline);
|
|
||||||
|
|
||||||
void SetStencilReference(uint32_t reference);
|
void SetStencilReference(uint32_t reference);
|
||||||
void SetBlendColor(const Color* color);
|
void SetBlendColor(const Color* color);
|
||||||
|
@ -58,20 +45,6 @@ namespace dawn_native {
|
||||||
float maxDepth);
|
float maxDepth);
|
||||||
void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
|
void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SetVertexBuffers(uint32_t startSlot,
|
|
||||||
uint32_t count,
|
|
||||||
T* const* buffers,
|
|
||||||
uint64_t const* offsets) {
|
|
||||||
static_assert(std::is_base_of<BufferBase, T>::value, "");
|
|
||||||
SetVertexBuffers(startSlot, count, buffers, offsets);
|
|
||||||
}
|
|
||||||
void SetVertexBuffers(uint32_t startSlot,
|
|
||||||
uint32_t count,
|
|
||||||
BufferBase* const* buffers,
|
|
||||||
uint64_t const* offsets);
|
|
||||||
void SetIndexBuffer(BufferBase* buffer, uint64_t offset);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RenderPassEncoderBase(DeviceBase* device,
|
RenderPassEncoderBase(DeviceBase* device,
|
||||||
CommandEncoderBase* topLevelEncoder,
|
CommandEncoderBase* topLevelEncoder,
|
||||||
|
|
Loading…
Reference in New Issue