WebGPU error handling 2: CommandEncoder for samples and end2end tests
CommandEncoder is the replacement for CommandBufferBuilder. This commit adds the dawn.json definition for it and an initial implementation that wraps CommandBufferBuilder. This is done so that the code can be ported to CommandEncoder gradually, otherwise the commit would be too big and would risk many merge conflicts. This converts all samples and end2end tests to use CommandEncoder. BUG=dawn:8 Change-Id: If4ce86e6fb39ba4e0c2af6328d40e63be17d18c1 Reviewed-on: https://dawn-review.googlesource.com/c/4741 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
7be2a71f2b
commit
e1f0d4e639
2
BUILD.gn
2
BUILD.gn
|
@ -443,6 +443,8 @@ source_set("libdawn_native_sources") {
|
|||
"src/dawn_native/CommandBuffer.h",
|
||||
"src/dawn_native/CommandBufferStateTracker.cpp",
|
||||
"src/dawn_native/CommandBufferStateTracker.h",
|
||||
"src/dawn_native/CommandEncoder.cpp",
|
||||
"src/dawn_native/CommandEncoder.h",
|
||||
"src/dawn_native/Commands.cpp",
|
||||
"src/dawn_native/Commands.h",
|
||||
"src/dawn_native/ComputePassEncoder.cpp",
|
||||
|
|
53
dawn.json
53
dawn.json
|
@ -320,6 +320,55 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"command encoder": {
|
||||
"category": "object",
|
||||
"methods": [
|
||||
{
|
||||
"name": "finish",
|
||||
"returns": "command buffer"
|
||||
},
|
||||
{
|
||||
"name": "begin compute pass",
|
||||
"returns": "compute pass encoder"
|
||||
},
|
||||
{
|
||||
"name": "begin render pass",
|
||||
"args": [
|
||||
{"name": "info", "type": "render pass descriptor"}
|
||||
],
|
||||
"returns": "render pass encoder"
|
||||
},
|
||||
{
|
||||
"name": "copy buffer to buffer",
|
||||
"args": [
|
||||
{"name": "source", "type": "buffer"},
|
||||
{"name": "source offset", "type": "uint32_t"},
|
||||
{"name": "destination", "type": "buffer"},
|
||||
{"name": "destination offset", "type": "uint32_t"},
|
||||
{"name": "size", "type": "uint32_t"}
|
||||
],
|
||||
"TODO": [
|
||||
"Restrictions on the alignment of the copy? Cf Metal on OSX"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "copy buffer to texture",
|
||||
"args": [
|
||||
{"name": "source", "type": "buffer copy view", "annotation": "const*"},
|
||||
{"name": "destination", "type": "texture copy view", "annotation": "const*"},
|
||||
{"name": "copy size", "type": "extent 3D", "annotation": "const*"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "copy texture to buffer",
|
||||
"args": [
|
||||
{"name": "source", "type": "texture copy view", "annotation": "const*"},
|
||||
{"name": "destination", "type": "buffer copy view", "annotation": "const*"},
|
||||
{"name": "copy size", "type": "extent 3D", "annotation": "const*"}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"compare function": {
|
||||
"category": "enum",
|
||||
"values": [
|
||||
|
@ -420,6 +469,10 @@
|
|||
"name": "create command buffer builder",
|
||||
"returns": "command buffer builder"
|
||||
},
|
||||
{
|
||||
"name": "create command encoder",
|
||||
"returns": "command encoder"
|
||||
},
|
||||
{
|
||||
"name": "create fence",
|
||||
"returns": "fence",
|
||||
|
|
|
@ -140,9 +140,9 @@ void frame() {
|
|||
|
||||
size_t i = 0;
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
pass.SetPipeline(pipeline);
|
||||
|
||||
for (int k = 0; k < 10000; k++) {
|
||||
|
@ -155,7 +155,7 @@ void frame() {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
swapchain.Present(backbuffer);
|
||||
DoFlush();
|
||||
|
|
|
@ -131,16 +131,16 @@ void frame() {
|
|||
}
|
||||
dawnCommandBuffer commands;
|
||||
{
|
||||
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device);
|
||||
dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
|
||||
|
||||
dawnRenderPassEncoder pass = dawnCommandBufferBuilderBeginRenderPass(builder, renderpassInfo);
|
||||
dawnRenderPassEncoder pass = dawnCommandEncoderBeginRenderPass(encoder, renderpassInfo);
|
||||
dawnRenderPassEncoderSetPipeline(pass, pipeline);
|
||||
dawnRenderPassEncoderDraw(pass, 3, 1, 0, 0);
|
||||
dawnRenderPassEncoderEndPass(pass);
|
||||
dawnRenderPassEncoderRelease(pass);
|
||||
|
||||
commands = dawnCommandBufferBuilderGetResult(builder);
|
||||
dawnCommandBufferBuilderRelease(builder);
|
||||
commands = dawnCommandEncoderFinish(encoder);
|
||||
dawnCommandEncoderRelease(encoder);
|
||||
}
|
||||
|
||||
dawnQueueSubmit(queue, 1, &commands);
|
||||
|
|
|
@ -280,10 +280,10 @@ void initSim() {
|
|||
dawn::CommandBuffer createCommandBuffer(const dawn::RenderPassDescriptor& renderPass, size_t i) {
|
||||
static const uint32_t zeroOffsets[1] = {0};
|
||||
auto& bufferDst = particleBuffers[(i + 1) % 2];
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPipeline(updatePipeline);
|
||||
pass.SetBindGroup(0, updateBGs[i]);
|
||||
pass.Dispatch(kNumParticles, 1, 1);
|
||||
|
@ -291,7 +291,7 @@ dawn::CommandBuffer createCommandBuffer(const dawn::RenderPassDescriptor& render
|
|||
}
|
||||
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
pass.SetPipeline(renderPipeline);
|
||||
pass.SetVertexBuffers(0, 1, &bufferDst, zeroOffsets);
|
||||
pass.SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets);
|
||||
|
@ -299,7 +299,7 @@ dawn::CommandBuffer createCommandBuffer(const dawn::RenderPassDescriptor& render
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
return builder.GetResult();
|
||||
return encoder.Finish();
|
||||
}
|
||||
|
||||
void init() {
|
||||
|
|
|
@ -74,11 +74,11 @@ void initTextures() {
|
|||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||
dawn::Extent3D copySize = {1024, 1024, 1};
|
||||
dawn::CommandBuffer copy =
|
||||
device.CreateCommandBufferBuilder()
|
||||
.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size)
|
||||
.GetResult();
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
|
||||
dawn::CommandBuffer copy = encoder.Finish();
|
||||
queue.Submit(1, ©);
|
||||
}
|
||||
|
||||
|
@ -165,9 +165,9 @@ void frame() {
|
|||
GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
|
||||
|
||||
static const uint32_t vertexBufferOffsets[1] = {0};
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
|
||||
|
@ -176,7 +176,7 @@ void frame() {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
swapchain.Present(backbuffer);
|
||||
DoFlush();
|
||||
|
|
|
@ -276,9 +276,9 @@ void frame() {
|
|||
dawn::RenderPassDescriptor renderPass;
|
||||
GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup[0]);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
|
||||
|
@ -299,7 +299,7 @@ void frame() {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
swapchain.Present(backbuffer);
|
||||
DoFlush();
|
||||
|
|
|
@ -471,9 +471,11 @@ namespace {
|
|||
dawn::TextureCopyView textureCopyView =
|
||||
utils::CreateTextureCopyView(oTexture, 0, 0, {0, 0, 0});
|
||||
dawn::Extent3D copySize = {iImage.width, iImage.height, 1};
|
||||
auto cmdbuf = device.CreateCommandBufferBuilder()
|
||||
.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size)
|
||||
.GetResult();
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
|
||||
dawn::CommandBuffer cmdbuf = encoder.Finish();
|
||||
queue.Submit(1, &cmdbuf);
|
||||
|
||||
textures[iTextureID] = oTexture.CreateDefaultTextureView();
|
||||
|
@ -603,9 +605,9 @@ namespace {
|
|||
GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
|
||||
|
||||
const auto& defaultSceneNodes = scene.scenes.at(scene.defaultScene);
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
for (const auto& n : defaultSceneNodes) {
|
||||
const auto& node = scene.nodes.at(n);
|
||||
drawNode(pass, node);
|
||||
|
@ -613,7 +615,7 @@ namespace {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
swapchain.Present(backbuffer);
|
||||
|
|
|
@ -303,6 +303,15 @@ namespace dawn_native {
|
|||
: ObjectBase(builder->GetDevice()), mResourceUsages(builder->AcquireResourceUsages()) {
|
||||
}
|
||||
|
||||
CommandBufferBase::CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
: ObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
// static
|
||||
CommandBufferBase* CommandBufferBase::MakeError(DeviceBase* device) {
|
||||
return new CommandBufferBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
const CommandBufferResourceUsage& CommandBufferBase::GetResourceUsages() const {
|
||||
return mResourceUsages;
|
||||
}
|
||||
|
|
|
@ -43,9 +43,13 @@ namespace dawn_native {
|
|||
public:
|
||||
CommandBufferBase(CommandBufferBuilder* builder);
|
||||
|
||||
static CommandBufferBase* MakeError(DeviceBase* device);
|
||||
|
||||
const CommandBufferResourceUsage& GetResourceUsages() const;
|
||||
|
||||
private:
|
||||
CommandBufferBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
|
||||
CommandBufferResourceUsage mResourceUsages;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
// 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/CommandEncoder.h"
|
||||
|
||||
#include "dawn_native/CommandBuffer.h"
|
||||
#include "dawn_native/Device.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
CommandEncoderBase::CommandEncoderBase(DeviceBase* device) : ObjectBase(device) {
|
||||
// Create a builder with an external reference count of 1. We don't use Ref<> because we
|
||||
// want to release the external reference when the encoder is destroyed.
|
||||
mBuilder = GetDevice()->CreateCommandBufferBuilder();
|
||||
mBuilder->SetErrorCallback(
|
||||
HandleBuilderError,
|
||||
static_cast<dawnCallbackUserdata>(reinterpret_cast<uintptr_t>(this)), 0);
|
||||
}
|
||||
|
||||
CommandEncoderBase::~CommandEncoderBase() {
|
||||
// Release the single external reference of the builder
|
||||
mBuilder->Release();
|
||||
mBuilder = nullptr;
|
||||
}
|
||||
|
||||
ComputePassEncoderBase* CommandEncoderBase::BeginComputePass() {
|
||||
return mBuilder->BeginComputePass();
|
||||
}
|
||||
|
||||
RenderPassEncoderBase* CommandEncoderBase::BeginRenderPass(RenderPassDescriptorBase* info) {
|
||||
return mBuilder->BeginRenderPass(info);
|
||||
}
|
||||
|
||||
void CommandEncoderBase::CopyBufferToBuffer(BufferBase* source,
|
||||
uint32_t sourceOffset,
|
||||
BufferBase* destination,
|
||||
uint32_t destinationOffset,
|
||||
uint32_t size) {
|
||||
return mBuilder->CopyBufferToBuffer(source, sourceOffset, destination, destinationOffset,
|
||||
size);
|
||||
}
|
||||
|
||||
void CommandEncoderBase::CopyBufferToTexture(const BufferCopyView* source,
|
||||
const TextureCopyView* destination,
|
||||
const Extent3D* copySize) {
|
||||
return mBuilder->CopyBufferToTexture(source, destination, copySize);
|
||||
}
|
||||
|
||||
void CommandEncoderBase::CopyTextureToBuffer(const TextureCopyView* source,
|
||||
const BufferCopyView* destination,
|
||||
const Extent3D* copySize) {
|
||||
return mBuilder->CopyTextureToBuffer(source, destination, copySize);
|
||||
}
|
||||
|
||||
CommandBufferBase* CommandEncoderBase::Finish() {
|
||||
if (GetDevice()->ConsumedError(ValidateFinish())) {
|
||||
return CommandBufferBase::MakeError(GetDevice());
|
||||
}
|
||||
ASSERT(!IsError());
|
||||
|
||||
CommandBufferBase* result = mBuilder->GetResult();
|
||||
if (result == nullptr) {
|
||||
ASSERT(mGotError);
|
||||
GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR(mErrorMessage));
|
||||
return CommandBufferBase::MakeError(GetDevice());
|
||||
}
|
||||
|
||||
ASSERT(result != nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
MaybeError CommandEncoderBase::ValidateFinish() {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
DAWN_TRY(mBuilder->ValidateGetResult());
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
void CommandEncoderBase::HandleBuilderError(dawnBuilderErrorStatus status,
|
||||
const char* message,
|
||||
dawnCallbackUserdata userdata1,
|
||||
dawnCallbackUserdata) {
|
||||
CommandEncoderBase* self =
|
||||
reinterpret_cast<CommandEncoderBase*>(static_cast<uintptr_t>(userdata1));
|
||||
|
||||
if (status != DAWN_BUILDER_ERROR_STATUS_SUCCESS && !self->mGotError) {
|
||||
self->mGotError = true;
|
||||
self->mErrorMessage = message;
|
||||
}
|
||||
}
|
||||
|
||||
} // 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_COMMANDENCODER_H_
|
||||
#define DAWNNATIVE_COMMANDENCODER_H_
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
class CommandBufferBuilder;
|
||||
|
||||
// CommandEncoder is temporarily a wrapper around CommandBufferBuilder so the two can coexist
|
||||
// while code is migrated to the new shiny CommandEncoder interface. It captures any command
|
||||
// buffer builder error and defers to trigger a device error when "Finish" is called.
|
||||
class CommandEncoderBase : public ObjectBase {
|
||||
public:
|
||||
CommandEncoderBase(DeviceBase* device);
|
||||
~CommandEncoderBase();
|
||||
|
||||
// Dawn API
|
||||
ComputePassEncoderBase* BeginComputePass();
|
||||
RenderPassEncoderBase* BeginRenderPass(RenderPassDescriptorBase* info);
|
||||
void CopyBufferToBuffer(BufferBase* source,
|
||||
uint32_t sourceOffset,
|
||||
BufferBase* destination,
|
||||
uint32_t destinationOffset,
|
||||
uint32_t size);
|
||||
void CopyBufferToTexture(const BufferCopyView* source,
|
||||
const TextureCopyView* destination,
|
||||
const Extent3D* copySize);
|
||||
void CopyTextureToBuffer(const TextureCopyView* source,
|
||||
const BufferCopyView* destination,
|
||||
const Extent3D* copySize);
|
||||
CommandBufferBase* Finish();
|
||||
|
||||
private:
|
||||
MaybeError ValidateFinish();
|
||||
static void HandleBuilderError(dawnBuilderErrorStatus status,
|
||||
const char* message,
|
||||
dawnCallbackUserdata userdata1,
|
||||
dawnCallbackUserdata userdata2);
|
||||
|
||||
CommandBufferBuilder* mBuilder = nullptr;
|
||||
bool mGotError = false;
|
||||
std::string mErrorMessage;
|
||||
};
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
#endif // DAWNNATIVE_COMMANDENCODER_H_
|
|
@ -19,6 +19,7 @@
|
|||
#include "dawn_native/BindGroupLayout.h"
|
||||
#include "dawn_native/Buffer.h"
|
||||
#include "dawn_native/CommandBuffer.h"
|
||||
#include "dawn_native/CommandEncoder.h"
|
||||
#include "dawn_native/ComputePipeline.h"
|
||||
#include "dawn_native/ErrorData.h"
|
||||
#include "dawn_native/Fence.h"
|
||||
|
@ -145,6 +146,9 @@ namespace dawn_native {
|
|||
CommandBufferBuilder* DeviceBase::CreateCommandBufferBuilder() {
|
||||
return new CommandBufferBuilder(this);
|
||||
}
|
||||
CommandEncoderBase* DeviceBase::CreateCommandEncoder() {
|
||||
return new CommandEncoderBase(this);
|
||||
}
|
||||
ComputePipelineBase* DeviceBase::CreateComputePipeline(
|
||||
const ComputePipelineDescriptor* descriptor) {
|
||||
ComputePipelineBase* result = nullptr;
|
||||
|
|
|
@ -91,6 +91,7 @@ namespace dawn_native {
|
|||
BindGroupLayoutBase* CreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor);
|
||||
BufferBase* CreateBuffer(const BufferDescriptor* descriptor);
|
||||
CommandBufferBuilder* CreateCommandBufferBuilder();
|
||||
CommandEncoderBase* CreateCommandEncoder();
|
||||
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
|
||||
FenceBase* CreateFence(const FenceDescriptor* descriptor);
|
||||
InputStateBuilder* CreateInputStateBuilder();
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace dawn_native {
|
|||
class ComputePipelineBase;
|
||||
class CommandBufferBase;
|
||||
class CommandBufferBuilder;
|
||||
class CommandEncoderBase;
|
||||
class ComputePassEncoderBase;
|
||||
class FenceBase;
|
||||
class InputStateBase;
|
||||
|
|
|
@ -267,11 +267,10 @@ std::ostringstream& DawnTest::AddBufferExpectation(const char* file,
|
|||
|
||||
// We need to enqueue the copy immediately because by the time we resolve the expectation,
|
||||
// the buffer might have been modified.
|
||||
dawn::CommandBuffer commands =
|
||||
device.CreateCommandBufferBuilder()
|
||||
.CopyBufferToBuffer(buffer, offset, readback.buffer, readback.offset, size)
|
||||
.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(buffer, offset, readback.buffer, readback.offset, size);
|
||||
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
DeferredExpectation deferred;
|
||||
|
@ -312,11 +311,11 @@ std::ostringstream& DawnTest::AddTextureExpectation(const char* file,
|
|||
dawn::BufferCopyView bufferCopyView =
|
||||
utils::CreateBufferCopyView(readback.buffer, readback.offset, rowPitch, 0);
|
||||
dawn::Extent3D copySize = {width, height, 1};
|
||||
dawn::CommandBuffer commands =
|
||||
device.CreateCommandBufferBuilder()
|
||||
.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, ©Size)
|
||||
.GetResult();
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, ©Size);
|
||||
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
DeferredExpectation deferred;
|
||||
|
|
|
@ -24,13 +24,13 @@ class BindGroupTests : public DawnTest {
|
|||
protected:
|
||||
dawn::CommandBuffer CreateSimpleComputeCommandBuffer(
|
||||
const dawn::ComputePipeline& pipeline, const dawn::BindGroup& bindGroup) {
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
pass.Dispatch(1, 1, 1);
|
||||
pass.EndPass();
|
||||
return builder.GetResult();
|
||||
return encoder.Finish();
|
||||
}
|
||||
|
||||
dawn::PipelineLayout MakeBasicPipelineLayout(
|
||||
|
@ -152,14 +152,14 @@ TEST_P(BindGroupTests, ReusedUBO) {
|
|||
{1, buffer, 256, sizeof(Data::color)}
|
||||
});
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
RGBA8 filled(0, 255, 0, 255);
|
||||
|
@ -267,19 +267,19 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||
{2, textureView}
|
||||
});
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::BufferCopyView bufferCopyView =
|
||||
utils::CreateBufferCopyView(stagingBuffer, 0, widthInBytes, 0);
|
||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||
dawn::Extent3D copySize = {width, height, 1};
|
||||
builder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
RGBA8 filled(0, 255, 0, 255);
|
||||
|
@ -367,15 +367,15 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
|
|||
{1, buffers[i], 256, sizeof(Data::color)}}));
|
||||
}
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroups[0]);
|
||||
pass.SetBindGroup(1, bindGroups[1]);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
RGBA8 filled(255, 255, 0, 255);
|
||||
|
@ -434,8 +434,8 @@ TEST_P(BindGroupTests, DrawTwiceInSamePipelineWithFourBindGroupSets)
|
|||
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat;
|
||||
|
||||
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor);
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
|
||||
pass.SetPipeline(pipeline);
|
||||
|
||||
|
@ -455,7 +455,7 @@ TEST_P(BindGroupTests, DrawTwiceInSamePipelineWithFourBindGroupSets)
|
|||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
RGBA8 filled(255, 0, 0, 255);
|
||||
|
|
|
@ -106,9 +106,9 @@ class BlendStateTest : public DawnTest {
|
|||
void DoSingleSourceTest(RGBA8 base, const TriangleSpec& triangle, const RGBA8& expected) {
|
||||
dawn::Color blendColor{triangle.blendFactor[0], triangle.blendFactor[1], triangle.blendFactor[2], triangle.blendFactor[3]};
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
// First use the base pipeline to draw a triangle with no blending
|
||||
pass.SetPipeline(basePipeline);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { base } })));
|
||||
|
@ -122,7 +122,7 @@ class BlendStateTest : public DawnTest {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(expected, renderPass.color, kRTSize / 2, kRTSize / 2);
|
||||
|
@ -689,16 +689,16 @@ TEST_P(BlendStateTest, ColorWriteMaskBlendingDisabled) {
|
|||
RGBA8 base(32, 64, 128, 192);
|
||||
RGBA8 expected(32, 0, 0, 0);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(testPipeline);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { base } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
EXPECT_PIXEL_RGBA8_EQ(expected, renderPass.color, kRTSize / 2, kRTSize / 2);
|
||||
}
|
||||
|
@ -815,9 +815,9 @@ TEST_P(BlendStateTest, IndependentBlendState) {
|
|||
RGBA8 expected2 = color2;
|
||||
RGBA8 expected3 = min(color3, base);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetPipeline(basePipeline);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 4>({ { base, base, base, base } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
|
@ -828,7 +828,7 @@ TEST_P(BlendStateTest, IndependentBlendState) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(expected0, renderTargets[0], kRTSize / 2, kRTSize / 2) << "Attachment slot 0 should have been " << color0 << " + " << base << " = " << expected0;
|
||||
|
@ -879,9 +879,9 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
|
||||
// Check that the initial blend color is (0,0,0,0)
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(basePipeline);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
|
@ -891,7 +891,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 0, 0, 0), renderPass.color, kRTSize / 2, kRTSize / 2);
|
||||
|
@ -899,9 +899,9 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
|
||||
// Check that setting the blend color works
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(basePipeline);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
|
@ -912,7 +912,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(255, 255, 255, 255), renderPass.color, kRTSize / 2, kRTSize / 2);
|
||||
|
@ -920,9 +920,9 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
|
||||
// Check that the blend color is not inherited between render passes
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(basePipeline);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
|
@ -933,7 +933,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
pass.EndPass();
|
||||
}
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(basePipeline);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
|
@ -943,7 +943,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 0, 0, 0), renderPass.color, kRTSize / 2, kRTSize / 2);
|
||||
|
|
|
@ -76,14 +76,14 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
|
|||
|
||||
dawn::CommandBuffer commands;
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
pass.Dispatch(kInstances, 1, 1);
|
||||
pass.EndPass();
|
||||
|
||||
commands = builder.GetResult();
|
||||
commands = encoder.Finish();
|
||||
}
|
||||
|
||||
queue.Submit(1, &commands);
|
||||
|
|
|
@ -91,7 +91,7 @@ class CopyTests_T2B : public CopyTests {
|
|||
uint32_t texelsPerRow = rowPitch / kBytesPerTexel;
|
||||
uint32_t texelCountPerLayer = texelsPerRow * (height - 1) + width;
|
||||
|
||||
dawn::CommandBufferBuilder cmdBuilder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
std::vector<std::vector<RGBA8>> textureArrayData(textureSpec.arraySize);
|
||||
for (uint32_t slice = 0; slice < textureSpec.arraySize; ++slice) {
|
||||
|
@ -106,7 +106,7 @@ class CopyTests_T2B : public CopyTests {
|
|||
dawn::TextureCopyView textureCopyView =
|
||||
utils::CreateTextureCopyView(texture, textureSpec.level, slice, {0, 0, 0});
|
||||
dawn::Extent3D copySize = {width, height, 1};
|
||||
cmdBuilder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
}
|
||||
|
||||
// Create a buffer of size `size * textureSpec.arrayLayer` and populate it with empty data (0,0,0,0)
|
||||
|
@ -127,11 +127,11 @@ class CopyTests_T2B : public CopyTests {
|
|||
dawn::BufferCopyView bufferCopyView =
|
||||
utils::CreateBufferCopyView(buffer, bufferOffset, bufferSpec.rowPitch, 0);
|
||||
dawn::Extent3D copySize = {textureSpec.copyWidth, textureSpec.copyHeight, 1};
|
||||
cmdBuilder.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, ©Size);
|
||||
encoder.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, ©Size);
|
||||
bufferOffset += bufferSpec.size;
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = cmdBuilder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
bufferOffset = bufferSpec.offset;
|
||||
|
@ -195,7 +195,7 @@ protected:
|
|||
descriptor.usage = dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::TransferSrc;
|
||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||
|
||||
dawn::CommandBufferBuilder cmdBuilder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
// Create an upload buffer filled with empty data and use it to populate the `level` mip of the texture
|
||||
// Note: Prepopulating the texture with empty data ensures that there is not random data in the expectation
|
||||
|
@ -214,7 +214,7 @@ protected:
|
|||
dawn::TextureCopyView textureCopyView =
|
||||
utils::CreateTextureCopyView(texture, textureSpec.level, 0, {0, 0, 0});
|
||||
dawn::Extent3D copySize = {width, height, 1};
|
||||
cmdBuilder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
}
|
||||
|
||||
// Copy to the region [(`x`, `y`), (`x + copyWidth, `y + copyWidth`)] at the `level` mip from the buffer at the specified `offset` and `rowPitch`
|
||||
|
@ -224,10 +224,10 @@ protected:
|
|||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(
|
||||
texture, textureSpec.level, 0, {textureSpec.x, textureSpec.y, 0});
|
||||
dawn::Extent3D copySize = {textureSpec.copyWidth, textureSpec.copyHeight, 1};
|
||||
cmdBuilder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = cmdBuilder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
// Pack the data used to create the buffer in the specified copy region to have the same format as the expected texture data.
|
||||
|
|
|
@ -266,14 +266,14 @@ class DepthStencilStateTest : public DawnTest {
|
|||
// Each test param represents a pair of triangles with a color, depth, stencil value, and depthStencil state, one frontfacing, one backfacing
|
||||
// Draw the triangles in order and check the expected colors for the frontfaces and backfaces
|
||||
void DoTest(const std::vector<TestSpec> &testParams, const RGBA8& expectedFront, const RGBA8& expectedBack) {
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
struct TriangleData {
|
||||
float color[3];
|
||||
float depth;
|
||||
};
|
||||
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
|
||||
for (size_t i = 0; i < testParams.size(); ++i) {
|
||||
const TestSpec& test = testParams[i];
|
||||
|
@ -307,7 +307,7 @@ class DepthStencilStateTest : public DawnTest {
|
|||
}
|
||||
pass.EndPass();
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(expectedFront, renderTarget, kRTSize / 4, kRTSize / 2) << "Front face check failed";
|
||||
|
|
|
@ -95,9 +95,9 @@ class DrawIndexedTest : public DawnTest {
|
|||
uint32_t baseVertex, uint32_t firstInstance, RGBA8 bottomLeftExpected,
|
||||
RGBA8 topRightExpected) {
|
||||
uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
|
@ -105,7 +105,7 @@ class DrawIndexedTest : public DawnTest {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(bottomLeftExpected, renderPass.color, 1, 3);
|
||||
|
|
|
@ -86,16 +86,16 @@ class DrawTest : public DawnTest {
|
|||
RGBA8 bottomLeftExpected,
|
||||
RGBA8 topRightExpected) {
|
||||
uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.Draw(vertexCount, instanceCount, firstIndex, firstInstance);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(bottomLeftExpected, renderPass.color, 1, 3);
|
||||
|
|
|
@ -91,9 +91,9 @@ TEST_P(IndexFormatTest, Uint32) {
|
|||
});
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
|
@ -101,7 +101,7 @@ TEST_P(IndexFormatTest, Uint32) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 100, 300);
|
||||
|
@ -122,9 +122,9 @@ TEST_P(IndexFormatTest, Uint16) {
|
|||
});
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
|
@ -132,7 +132,7 @@ TEST_P(IndexFormatTest, Uint16) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 100, 300);
|
||||
|
@ -166,9 +166,9 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
|
|||
});
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
|
@ -176,7 +176,7 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 190, 190); // A
|
||||
|
@ -200,9 +200,9 @@ TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
|
|||
});
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
|
@ -210,7 +210,7 @@ TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 190, 190); // A
|
||||
|
@ -239,9 +239,9 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
|
|||
});
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline16);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
|
@ -250,7 +250,7 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 100, 300);
|
||||
|
@ -274,9 +274,9 @@ TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) {
|
|||
});
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetIndexBuffer(indexBuffer, 0);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
|
@ -284,7 +284,7 @@ TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 100, 300);
|
||||
|
|
|
@ -178,9 +178,9 @@ class InputStateTest : public DawnTest {
|
|||
EXPECT_LE(triangles, 4u);
|
||||
EXPECT_LE(instances, 4u);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
|
@ -191,7 +191,7 @@ class InputStateTest : public DawnTest {
|
|||
pass.Draw(triangles * 3, instances, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
CheckResult(triangles, instances);
|
||||
|
@ -452,9 +452,9 @@ TEST_P(InputStateTest, UnusedVertexSlot) {
|
|||
3, 4, 5, 6,
|
||||
});
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
pass.SetVertexBuffers(0, 1, &buffer, &zeroOffset);
|
||||
|
@ -465,7 +465,7 @@ TEST_P(InputStateTest, UnusedVertexSlot) {
|
|||
|
||||
pass.EndPass();
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
CheckResult(1, 4);
|
||||
|
@ -497,9 +497,9 @@ TEST_P(InputStateTest, MultiplePipelinesMixedInputState) {
|
|||
3, 4, 5, 6,
|
||||
});
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
|
||||
uint32_t zeroOffset = 0;
|
||||
pass.SetVertexBuffers(0, 1, &buffer, &zeroOffset);
|
||||
|
@ -513,7 +513,7 @@ TEST_P(InputStateTest, MultiplePipelinesMixedInputState) {
|
|||
|
||||
pass.EndPass();
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
CheckResult(1, 4);
|
||||
|
|
|
@ -208,16 +208,16 @@ class PrimitiveTopologyTest : public DawnTest {
|
|||
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
|
||||
static const uint32_t zeroOffset = 0;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
for (auto& locationSpec : locationSpecs) {
|
||||
|
|
|
@ -210,9 +210,9 @@ TEST_P(PushConstantTest, ComputePassDefaultsToZero) {
|
|||
dawn::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, MakeAllZeroSpec());
|
||||
|
||||
uint32_t notZero = 42;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
|
||||
// Test compute push constants are set to zero by default.
|
||||
pass.SetPipeline(pipeline);
|
||||
|
@ -225,7 +225,7 @@ TEST_P(PushConstantTest, ComputePassDefaultsToZero) {
|
|||
pass.EndPass();
|
||||
}
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, binding.bindGroup);
|
||||
|
@ -234,7 +234,7 @@ TEST_P(PushConstantTest, ComputePassDefaultsToZero) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_BUFFER_U32_EQ(1, binding.resultBuffer, 0);
|
||||
|
@ -249,16 +249,16 @@ TEST_P(PushConstantTest, RenderPassDefaultsToZero) {
|
|||
dawn::PipelineLayout layout = MakeEmptyLayout();
|
||||
dawn::RenderPipeline pipeline = MakeTestRenderPipeline(layout, MakeAllZeroSpec(), MakeAllZeroSpec());
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
// Test render push constants are set to zero by default.
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.Draw(1, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 1, 0, 0), renderPass.color, 0, 0);
|
||||
|
@ -279,9 +279,9 @@ TEST_P(PushConstantTest, VariousConstantTypes) {
|
|||
dawn::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, spec);
|
||||
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 3, reinterpret_cast<uint32_t*>(&values));
|
||||
pass.SetPipeline(pipeline);
|
||||
|
@ -291,7 +291,7 @@ TEST_P(PushConstantTest, VariousConstantTypes) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_BUFFER_U32_EQ(1, binding.resultBuffer, 0);
|
||||
|
@ -309,9 +309,9 @@ TEST_P(PushConstantTest, InheritThroughPipelineLayoutChange) {
|
|||
|
||||
uint32_t one = 1;
|
||||
uint32_t two = 2;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
|
||||
// Set Push constant before there is a pipeline set
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, &one);
|
||||
|
@ -327,7 +327,7 @@ TEST_P(PushConstantTest, InheritThroughPipelineLayoutChange) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_BUFFER_U32_EQ(1, binding1.resultBuffer, 0);
|
||||
|
@ -346,9 +346,9 @@ TEST_P(PushConstantTest, SetAllConstantsToNonZero) {
|
|||
auto binding = MakeTestBindings(false);
|
||||
dawn::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, spec);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, &values[0]);
|
||||
pass.SetPipeline(pipeline);
|
||||
|
@ -358,7 +358,7 @@ TEST_P(PushConstantTest, SetAllConstantsToNonZero) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_BUFFER_U32_EQ(1, binding.resultBuffer, 0);
|
||||
|
@ -376,9 +376,9 @@ TEST_P(PushConstantTest, SeparateVertexAndFragmentConstants) {
|
|||
|
||||
uint32_t one = 1;
|
||||
uint32_t two = 2;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, &one);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Fragment, 0, 1, &two);
|
||||
pass.SetPipeline(pipeline);
|
||||
|
@ -386,7 +386,7 @@ TEST_P(PushConstantTest, SeparateVertexAndFragmentConstants) {
|
|||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 1, 0, 0), renderPass.color, 0, 0);
|
||||
|
@ -402,16 +402,16 @@ TEST_P(PushConstantTest, SimultaneousVertexAndFragmentConstants) {
|
|||
dawn::RenderPipeline pipeline = MakeTestRenderPipeline(layout, spec, spec);
|
||||
|
||||
uint32_t two = 2;
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, &two);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.Draw(1, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(1, 1, 0, 0), renderPass.color, 0, 0);
|
||||
|
|
|
@ -124,10 +124,10 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
|
|||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
|
||||
auto commandsClearZeroBuilder = device.CreateCommandBufferBuilder();
|
||||
auto clearZeroPass = commandsClearZeroBuilder.BeginRenderPass(renderPassClearZero);
|
||||
auto commandsClearZeroEncoder = device.CreateCommandEncoder();
|
||||
auto clearZeroPass = commandsClearZeroEncoder.BeginRenderPass(renderPassClearZero);
|
||||
clearZeroPass.EndPass();
|
||||
auto commandsClearZero = commandsClearZeroBuilder.GetResult();
|
||||
auto commandsClearZero = commandsClearZeroEncoder.Finish();
|
||||
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachmentGreen = colorAttachment;
|
||||
colorAttachmentGreen.clearColor = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
|
@ -135,10 +135,10 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
|
|||
.SetColorAttachments(1, &colorAttachmentGreen)
|
||||
.GetResult();
|
||||
|
||||
auto commandsClearGreenBuilder = device.CreateCommandBufferBuilder();
|
||||
auto clearGreenPass = commandsClearGreenBuilder.BeginRenderPass(renderPassClearGreen);
|
||||
auto commandsClearGreenEncoder = device.CreateCommandEncoder();
|
||||
auto clearGreenPass = commandsClearGreenEncoder.BeginRenderPass(renderPassClearGreen);
|
||||
clearGreenPass.EndPass();
|
||||
auto commandsClearGreen = commandsClearGreenBuilder.GetResult();
|
||||
auto commandsClearGreen = commandsClearGreenEncoder.Finish();
|
||||
|
||||
queue.Submit(1, &commandsClearZero);
|
||||
EXPECT_TEXTURE_RGBA8_EQ(expectZero.data(), renderTarget, 0, 0, kRTSize, kRTSize, 0, 0);
|
||||
|
@ -155,11 +155,11 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
|
|||
|
||||
dawn::CommandBuffer commandsLoad;
|
||||
{
|
||||
auto builder = device.CreateCommandBufferBuilder();
|
||||
auto pass = builder.BeginRenderPass(renderPassLoad);
|
||||
auto encoder = device.CreateCommandEncoder();
|
||||
auto pass = encoder.BeginRenderPass(renderPassLoad);
|
||||
blueQuad.Draw(&pass);
|
||||
pass.EndPass();
|
||||
commandsLoad = builder.GetResult();
|
||||
commandsLoad = encoder.Finish();
|
||||
}
|
||||
|
||||
queue.Submit(1, &commandsLoad);
|
||||
|
|
|
@ -80,7 +80,7 @@ TEST_P(RenderPassTest, TwoRenderPassesInOneCommandBuffer) {
|
|||
|
||||
dawn::Texture renderTarget1 = CreateDefault2DTexture();
|
||||
dawn::Texture renderTarget2 = CreateDefault2DTexture();
|
||||
dawn::CommandBufferBuilder commandBufferBuilder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
|
@ -97,7 +97,7 @@ TEST_P(RenderPassTest, TwoRenderPassesInOneCommandBuffer) {
|
|||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
|
||||
dawn::RenderPassEncoder pass = commandBufferBuilder.BeginRenderPass(renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
|
@ -112,13 +112,13 @@ TEST_P(RenderPassTest, TwoRenderPassesInOneCommandBuffer) {
|
|||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
|
||||
dawn::RenderPassEncoder pass = commandBufferBuilder.BeginRenderPass(renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = commandBufferBuilder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(kBlue, renderTarget1, 1, kRTSize - 1);
|
||||
|
|
|
@ -106,12 +106,13 @@ protected:
|
|||
dawn::TextureCopyView textureCopyView =
|
||||
utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||
dawn::Extent3D copySize = {2, 2, 1};
|
||||
dawn::CommandBuffer copy =
|
||||
device.CreateCommandBufferBuilder()
|
||||
.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size)
|
||||
.GetResult();
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
|
||||
dawn::CommandBuffer copy = encoder.Finish();
|
||||
queue.Submit(1, ©);
|
||||
|
||||
mTextureView = texture.CreateDefaultTextureView();
|
||||
}
|
||||
|
||||
|
@ -137,16 +138,16 @@ protected:
|
|||
{1, mTextureView}
|
||||
});
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(mRenderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(mRenderPass.renderPassInfo);
|
||||
pass.SetPipeline(mPipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
RGBA8 expectedU2(u.mExpected2, u.mExpected2, u.mExpected2, 255);
|
||||
|
|
|
@ -51,15 +51,15 @@ TEST_P(ScissorTest, DefaultsToWholeRenderTarget) {
|
|||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100);
|
||||
dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 0, 0);
|
||||
|
@ -73,16 +73,16 @@ TEST_P(ScissorTest, LargerThanAttachment) {
|
|||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100);
|
||||
dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetScissorRect(0, 0, 200, 200);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 0, 0);
|
||||
|
@ -99,16 +99,16 @@ TEST_P(ScissorTest, EmptyRect) {
|
|||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
|
||||
dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetScissorRect(0, 0, 0, 0);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 0, 0, 0), renderPass.color, 0, 0);
|
||||
|
@ -127,16 +127,16 @@ TEST_P(ScissorTest, PartialRect) {
|
|||
constexpr uint32_t kW = 5;
|
||||
constexpr uint32_t kH = 13;
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetScissorRect(kX, kY, kW, kH);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
// Test the two opposite corners of the scissor box. With one pixel inside and on outside
|
||||
|
@ -152,22 +152,22 @@ TEST_P(ScissorTest, NoInheritanceBetweenRenderPass) {
|
|||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100);
|
||||
dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
// RenderPass 1 set the scissor
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetScissorRect(0, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
// RenderPass 2 draw a full quad, it shouldn't be scissored
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 0, 0);
|
||||
|
|
|
@ -134,7 +134,7 @@ protected:
|
|||
constexpr uint32_t kPixelsPerRowPitch = kTextureRowPitchAlignment / sizeof(RGBA8);
|
||||
ASSERT_LE(textureWidthLevel0, kPixelsPerRowPitch);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
for (uint32_t layer = 0; layer < layerCount; ++layer) {
|
||||
for (uint32_t level = 0; level < levelCount; ++level) {
|
||||
const uint32_t texWidth = textureWidthLevel0 >> level;
|
||||
|
@ -152,10 +152,10 @@ protected:
|
|||
dawn::TextureCopyView textureCopyView =
|
||||
utils::CreateTextureCopyView(mTexture, level, layer, {0, 0, 0});
|
||||
dawn::Extent3D copySize = {texWidth, texHeight, 1};
|
||||
builder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||
}
|
||||
}
|
||||
dawn::CommandBuffer copy = builder.GetResult();
|
||||
dawn::CommandBuffer copy = encoder.Finish();
|
||||
queue.Submit(1, ©);
|
||||
}
|
||||
|
||||
|
@ -176,16 +176,16 @@ protected:
|
|||
|
||||
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(mRenderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(mRenderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
RGBA8 expectedPixel(0, 0, 0, expected);
|
||||
|
@ -520,16 +520,16 @@ class TextureViewRenderingTest : public DawnTest {
|
|||
|
||||
dawn::RenderPipeline oneColorPipeline = device.CreateRenderPipeline(&pipelineDescriptor);
|
||||
|
||||
dawn::CommandBufferBuilder commandBufferBuilder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass =
|
||||
commandBufferBuilder.BeginRenderPass(renderPassInfo);
|
||||
encoder.BeginRenderPass(renderPassInfo);
|
||||
pass.SetPipeline(oneColorPipeline);
|
||||
pass.Draw(6, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = commandBufferBuilder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
// Check if the right pixels (Green) have been written into the right part of the texture.
|
||||
|
|
|
@ -44,15 +44,15 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
|
|||
|
||||
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.Draw(1, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 0, 0);
|
||||
|
|
|
@ -614,9 +614,9 @@ TEST_F(BufferValidationTest, SubmitBufferWithMapUsage) {
|
|||
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
||||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
builder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
}
|
||||
|
||||
|
@ -635,9 +635,9 @@ TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
|||
|
||||
bufA.MapWriteAsync(ToMockBufferMapWriteCallback, 40329);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
builder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
|
@ -647,9 +647,9 @@ TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
|||
|
||||
bufB.MapReadAsync(ToMockBufferMapReadCallback, 11329);
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
builder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
||||
queue.Submit(0, nullptr);
|
||||
}
|
||||
|
@ -669,9 +669,9 @@ TEST_F(BufferValidationTest, SubmitDestroyedBuffer) {
|
|||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||
|
||||
bufA.Destroy();
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
builder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
dawn::CommandBuffer commands = builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue