Make unittests and fuzzers use webgpu.h

BUG=dawn:22

Change-Id: Iff5465ad7a9456f9c6b2ee380af748b3afc129b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12741
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2019-10-28 22:15:47 +00:00 committed by Commit Bot service account
parent cab352c2f6
commit 45b51f5df7
40 changed files with 2200 additions and 2200 deletions

View File

@ -740,11 +740,11 @@ static_library("dawn_bindings") {
# Dawn test targets # Dawn test targets
############################################################################### ###############################################################################
dawn_json_generator("mock_dawn_gen") { dawn_json_generator("mock_webgpu_gen") {
target = "mock_dawn" target = "mock_webgpu"
outputs = [ outputs = [
"src/dawn/mock_dawn.h", "src/dawn/mock_webgpu.h",
"src/dawn/mock_dawn.cpp", "src/dawn/mock_webgpu.cpp",
] ]
} }
@ -756,7 +756,7 @@ test("dawn_unittests") {
":libdawn_native", ":libdawn_native",
":libdawn_native_sources", ":libdawn_native_sources",
":libdawn_wire", ":libdawn_wire",
":mock_dawn_gen", ":mock_webgpu_gen",
"${dawn_root}/src/common", "${dawn_root}/src/common",
"${dawn_root}/src/dawn:dawncpp", "${dawn_root}/src/dawn:dawncpp",
"${dawn_root}/src/dawn:libdawn_proc", "${dawn_root}/src/dawn:libdawn_proc",
@ -767,7 +767,7 @@ test("dawn_unittests") {
deps += [ ":libdawn_native_headers" ] deps += [ ":libdawn_native_headers" ]
configs += [ ":libdawn_native_internal" ] configs += [ ":libdawn_native_internal" ]
sources = get_target_outputs(":mock_dawn_gen") sources = get_target_outputs(":mock_webgpu_gen")
sources += [ sources += [
"src/dawn_wire/client/ClientMemoryTransferService_mock.cpp", "src/dawn_wire/client/ClientMemoryTransferService_mock.cpp",
"src/dawn_wire/client/ClientMemoryTransferService_mock.h", "src/dawn_wire/client/ClientMemoryTransferService_mock.h",

View File

@ -482,7 +482,7 @@ class MultiGeneratorFromDawnJSON(Generator):
return 'Generates code for various target from Dawn.json.' return 'Generates code for various target from Dawn.json.'
def add_commandline_arguments(self, parser): def add_commandline_arguments(self, parser):
allowed_targets = ['dawn_headers', 'dawncpp_headers', 'dawncpp', 'dawn_proc', 'mock_dawn', 'dawn_wire', "dawn_native_utils"] allowed_targets = ['dawn_headers', 'dawncpp_headers', 'dawncpp', 'dawn_proc', 'mock_webgpu', 'dawn_wire', "dawn_native_utils"]
parser.add_argument('--dawn-json', required=True, type=str, help ='The DAWN JSON definition to use.') parser.add_argument('--dawn-json', required=True, type=str, help ='The DAWN JSON definition to use.')
parser.add_argument('--wire-json', default=None, type=str, help='The DAWN WIRE JSON definition to use.') parser.add_argument('--wire-json', default=None, type=str, help='The DAWN WIRE JSON definition to use.')
@ -542,9 +542,9 @@ class MultiGeneratorFromDawnJSON(Generator):
if 'dawncpp' in targets: if 'dawncpp' in targets:
renders.append(FileRender('webgpu_cpp.cpp', 'src/dawn/webgpu_cpp.cpp', [base_params, api_params, cpp_params])) renders.append(FileRender('webgpu_cpp.cpp', 'src/dawn/webgpu_cpp.cpp', [base_params, api_params, cpp_params]))
if 'mock_dawn' in targets: if 'mock_webgpu' in targets:
renders.append(FileRender('mock_api.h', 'src/dawn/mock_dawn.h', [base_params, api_params, c_params])) renders.append(FileRender('mock_webgpu.h', 'src/dawn/mock_webgpu.h', [base_params, api_params, c_params]))
renders.append(FileRender('mock_api.cpp', 'src/dawn/mock_dawn.cpp', [base_params, api_params, c_params])) renders.append(FileRender('mock_webgpu.cpp', 'src/dawn/mock_webgpu.cpp', [base_params, api_params, c_params]))
if 'dawn_native_utils' in targets: if 'dawn_native_utils' in targets:
frontend_params = [ frontend_params = [

View File

@ -12,7 +12,7 @@
//* See the License for the specific language governing permissions and //* See the License for the specific language governing permissions and
//* limitations under the License. //* limitations under the License.
#include "mock_dawn.h" #include "mock_webgpu.h"
using namespace testing; using namespace testing;
@ -40,7 +40,7 @@ namespace {
ProcTableAsClass::~ProcTableAsClass() { ProcTableAsClass::~ProcTableAsClass() {
} }
void ProcTableAsClass::GetProcTableAndDevice(DawnProcTable* table, DawnDevice* device) { void ProcTableAsClass::GetProcTableAndDevice(DawnProcTable* table, WGPUDevice* device) {
*device = GetNewDevice(); *device = GetNewDevice();
{% for type in by_category["object"] %} {% for type in by_category["object"] %}
@ -50,9 +50,9 @@ void ProcTableAsClass::GetProcTableAndDevice(DawnProcTable* table, DawnDevice* d
{% endfor %} {% endfor %}
} }
void ProcTableAsClass::DeviceSetUncapturedErrorCallback(DawnDevice self, void ProcTableAsClass::DeviceSetUncapturedErrorCallback(WGPUDevice self,
DawnErrorCallback callback, WGPUErrorCallback callback,
void* userdata) { void* userdata) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self); auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
object->deviceErrorCallback = callback; object->deviceErrorCallback = callback;
object->userdata1 = userdata; object->userdata1 = userdata;
@ -60,13 +60,15 @@ void ProcTableAsClass::DeviceSetUncapturedErrorCallback(DawnDevice self,
OnDeviceSetUncapturedErrorCallback(self, callback, userdata); OnDeviceSetUncapturedErrorCallback(self, callback, userdata);
} }
bool ProcTableAsClass::DevicePopErrorScope(DawnDevice self, DawnErrorCallback callback, void* userdata) { bool ProcTableAsClass::DevicePopErrorScope(WGPUDevice self,
WGPUErrorCallback callback,
void* userdata) {
return OnDevicePopErrorScopeCallback(self, callback, userdata); return OnDevicePopErrorScopeCallback(self, callback, userdata);
} }
void ProcTableAsClass::DeviceCreateBufferMappedAsync(DawnDevice self, void ProcTableAsClass::DeviceCreateBufferMappedAsync(WGPUDevice self,
const DawnBufferDescriptor* descriptor, const WGPUBufferDescriptor* descriptor,
DawnBufferCreateMappedCallback callback, WGPUBufferCreateMappedCallback callback,
void* userdata) { void* userdata) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self); auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
object->createBufferMappedCallback = callback; object->createBufferMappedCallback = callback;
@ -75,8 +77,8 @@ void ProcTableAsClass::DeviceCreateBufferMappedAsync(DawnDevice self,
OnDeviceCreateBufferMappedAsyncCallback(self, descriptor, callback, userdata); OnDeviceCreateBufferMappedAsyncCallback(self, descriptor, callback, userdata);
} }
void ProcTableAsClass::BufferMapReadAsync(DawnBuffer self, void ProcTableAsClass::BufferMapReadAsync(WGPUBuffer self,
DawnBufferMapReadCallback callback, WGPUBufferMapReadCallback callback,
void* userdata) { void* userdata) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self); auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
object->mapReadCallback = callback; object->mapReadCallback = callback;
@ -85,8 +87,8 @@ void ProcTableAsClass::BufferMapReadAsync(DawnBuffer self,
OnBufferMapReadAsyncCallback(self, callback, userdata); OnBufferMapReadAsyncCallback(self, callback, userdata);
} }
void ProcTableAsClass::BufferMapWriteAsync(DawnBuffer self, void ProcTableAsClass::BufferMapWriteAsync(WGPUBuffer self,
DawnBufferMapWriteCallback callback, WGPUBufferMapWriteCallback callback,
void* userdata) { void* userdata) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self); auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
object->mapWriteCallback = callback; object->mapWriteCallback = callback;
@ -95,9 +97,9 @@ void ProcTableAsClass::BufferMapWriteAsync(DawnBuffer self,
OnBufferMapWriteAsyncCallback(self, callback, userdata); OnBufferMapWriteAsyncCallback(self, callback, userdata);
} }
void ProcTableAsClass::FenceOnCompletion(DawnFence self, void ProcTableAsClass::FenceOnCompletion(WGPUFence self,
uint64_t value, uint64_t value,
DawnFenceOnCompletionCallback callback, WGPUFenceOnCompletionCallback callback,
void* userdata) { void* userdata) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self); auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
object->fenceOnCompletionCallback = callback; object->fenceOnCompletionCallback = callback;
@ -106,26 +108,36 @@ void ProcTableAsClass::FenceOnCompletion(DawnFence self,
OnFenceOnCompletionCallback(self, value, callback, userdata); OnFenceOnCompletionCallback(self, value, callback, userdata);
} }
void ProcTableAsClass::CallDeviceErrorCallback(DawnDevice device, DawnErrorType type, const char* message) { void ProcTableAsClass::CallDeviceErrorCallback(WGPUDevice device,
WGPUErrorType type,
const char* message) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device); auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
object->deviceErrorCallback(type, message, object->userdata1); object->deviceErrorCallback(type, message, object->userdata1);
} }
void ProcTableAsClass::CallCreateBufferMappedCallback(DawnDevice device, DawnBufferMapAsyncStatus status, DawnCreateBufferMappedResult result) { void ProcTableAsClass::CallCreateBufferMappedCallback(WGPUDevice device,
WGPUBufferMapAsyncStatus status,
WGPUCreateBufferMappedResult result) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device); auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
object->createBufferMappedCallback(status, result, object->userdata1); object->createBufferMappedCallback(status, result, object->userdata1);
} }
void ProcTableAsClass::CallMapReadCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, const void* data, uint64_t dataLength) { void ProcTableAsClass::CallMapReadCallback(WGPUBuffer buffer,
WGPUBufferMapAsyncStatus status,
const void* data,
uint64_t dataLength) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer); auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
object->mapReadCallback(status, data, dataLength, object->userdata1); object->mapReadCallback(status, data, dataLength, object->userdata1);
} }
void ProcTableAsClass::CallMapWriteCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, void* data, uint64_t dataLength) { void ProcTableAsClass::CallMapWriteCallback(WGPUBuffer buffer,
WGPUBufferMapAsyncStatus status,
void* data,
uint64_t dataLength) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer); auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
object->mapWriteCallback(status, data, dataLength, object->userdata1); object->mapWriteCallback(status, data, dataLength, object->userdata1);
} }
void ProcTableAsClass::CallFenceOnCompletionCallback(DawnFence fence, void ProcTableAsClass::CallFenceOnCompletionCallback(WGPUFence fence,
DawnFenceCompletionStatus status) { WGPUFenceCompletionStatus status) {
auto object = reinterpret_cast<ProcTableAsClass::Object*>(fence); auto object = reinterpret_cast<ProcTableAsClass::Object*>(fence);
object->fenceOnCompletionCallback(status, object->userdata1); object->fenceOnCompletionCallback(status, object->userdata1);
} }

View File

@ -12,11 +12,11 @@
//* See the License for the specific language governing permissions and //* See the License for the specific language governing permissions and
//* limitations under the License. //* limitations under the License.
#ifndef MOCK_DAWN_H #ifndef MOCK_WEBGPU_H
#define MOCK_DAWN_H #define MOCK_WEBGPU_H
#include <dawn/dawn.h>
#include <dawn/dawn_proc_table.h> #include <dawn/dawn_proc_table.h>
#include <dawn/webgpu.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <memory> #include <memory>
@ -28,7 +28,7 @@ class ProcTableAsClass {
public: public:
virtual ~ProcTableAsClass(); virtual ~ProcTableAsClass();
void GetProcTableAndDevice(DawnProcTable* table, DawnDevice* device); void GetProcTableAndDevice(DawnProcTable* table, WGPUDevice* device);
// Creates an object that can be returned by a mocked call as in WillOnce(Return(foo)). // Creates an object that can be returned by a mocked call as in WillOnce(Return(foo)).
// It returns an object of the write type that isn't equal to any previously returned object. // It returns an object of the write type that isn't equal to any previously returned object.
@ -52,61 +52,61 @@ class ProcTableAsClass {
{% endfor %} {% endfor %}
// Stores callback and userdata and calls the On* methods // Stores callback and userdata and calls the On* methods
void DeviceSetUncapturedErrorCallback(DawnDevice self, void DeviceSetUncapturedErrorCallback(WGPUDevice self,
DawnErrorCallback callback, WGPUErrorCallback callback,
void* userdata); void* userdata);
bool DevicePopErrorScope(DawnDevice self, DawnErrorCallback callback, void* userdata); bool DevicePopErrorScope(WGPUDevice self, WGPUErrorCallback callback, void* userdata);
void DeviceCreateBufferMappedAsync(DawnDevice self, void DeviceCreateBufferMappedAsync(WGPUDevice self,
const DawnBufferDescriptor* descriptor, const WGPUBufferDescriptor* descriptor,
DawnBufferCreateMappedCallback callback, WGPUBufferCreateMappedCallback callback,
void* userdata); void* userdata);
void BufferMapReadAsync(DawnBuffer self, void BufferMapReadAsync(WGPUBuffer self,
DawnBufferMapReadCallback callback, WGPUBufferMapReadCallback callback,
void* userdata); void* userdata);
void BufferMapWriteAsync(DawnBuffer self, void BufferMapWriteAsync(WGPUBuffer self,
DawnBufferMapWriteCallback callback, WGPUBufferMapWriteCallback callback,
void* userdata); void* userdata);
void FenceOnCompletion(DawnFence self, void FenceOnCompletion(WGPUFence self,
uint64_t value, uint64_t value,
DawnFenceOnCompletionCallback callback, WGPUFenceOnCompletionCallback callback,
void* userdata); void* userdata);
// Special cased mockable methods // Special cased mockable methods
virtual void OnDeviceSetUncapturedErrorCallback(DawnDevice device, virtual void OnDeviceSetUncapturedErrorCallback(WGPUDevice device,
DawnErrorCallback callback, WGPUErrorCallback callback,
void* userdata) = 0; void* userdata) = 0;
virtual bool OnDevicePopErrorScopeCallback(DawnDevice device, virtual bool OnDevicePopErrorScopeCallback(WGPUDevice device,
DawnErrorCallback callback, WGPUErrorCallback callback,
void* userdata) = 0; void* userdata) = 0;
virtual void OnDeviceCreateBufferMappedAsyncCallback(DawnDevice self, virtual void OnDeviceCreateBufferMappedAsyncCallback(WGPUDevice self,
const DawnBufferDescriptor* descriptor, const WGPUBufferDescriptor* descriptor,
DawnBufferCreateMappedCallback callback, WGPUBufferCreateMappedCallback callback,
void* userdata) = 0; void* userdata) = 0;
virtual void OnBufferMapReadAsyncCallback(DawnBuffer buffer, virtual void OnBufferMapReadAsyncCallback(WGPUBuffer buffer,
DawnBufferMapReadCallback callback, WGPUBufferMapReadCallback callback,
void* userdata) = 0; void* userdata) = 0;
virtual void OnBufferMapWriteAsyncCallback(DawnBuffer buffer, virtual void OnBufferMapWriteAsyncCallback(WGPUBuffer buffer,
DawnBufferMapWriteCallback callback, WGPUBufferMapWriteCallback callback,
void* userdata) = 0; void* userdata) = 0;
virtual void OnFenceOnCompletionCallback(DawnFence fence, virtual void OnFenceOnCompletionCallback(WGPUFence fence,
uint64_t value, uint64_t value,
DawnFenceOnCompletionCallback callback, WGPUFenceOnCompletionCallback callback,
void* userdata) = 0; void* userdata) = 0;
// Calls the stored callbacks // Calls the stored callbacks
void CallDeviceErrorCallback(DawnDevice device, DawnErrorType type, const char* message); void CallDeviceErrorCallback(WGPUDevice device, WGPUErrorType type, const char* message);
void CallCreateBufferMappedCallback(DawnDevice device, DawnBufferMapAsyncStatus status, DawnCreateBufferMappedResult result); void CallCreateBufferMappedCallback(WGPUDevice device, WGPUBufferMapAsyncStatus status, WGPUCreateBufferMappedResult result);
void CallMapReadCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, const void* data, uint64_t dataLength); void CallMapReadCallback(WGPUBuffer buffer, WGPUBufferMapAsyncStatus status, const void* data, uint64_t dataLength);
void CallMapWriteCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, void* data, uint64_t dataLength); void CallMapWriteCallback(WGPUBuffer buffer, WGPUBufferMapAsyncStatus status, void* data, uint64_t dataLength);
void CallFenceOnCompletionCallback(DawnFence fence, DawnFenceCompletionStatus status); void CallFenceOnCompletionCallback(WGPUFence fence, WGPUFenceCompletionStatus status);
struct Object { struct Object {
ProcTableAsClass* procs = nullptr; ProcTableAsClass* procs = nullptr;
DawnErrorCallback deviceErrorCallback = nullptr; WGPUErrorCallback deviceErrorCallback = nullptr;
DawnBufferCreateMappedCallback createBufferMappedCallback = nullptr; WGPUBufferCreateMappedCallback createBufferMappedCallback = nullptr;
DawnBufferMapReadCallback mapReadCallback = nullptr; WGPUBufferMapReadCallback mapReadCallback = nullptr;
DawnBufferMapWriteCallback mapWriteCallback = nullptr; WGPUBufferMapWriteCallback mapWriteCallback = nullptr;
DawnFenceOnCompletionCallback fenceOnCompletionCallback = nullptr; WGPUFenceOnCompletionCallback fenceOnCompletionCallback = nullptr;
void* userdata1 = 0; void* userdata1 = 0;
void* userdata2 = 0; void* userdata2 = 0;
}; };
@ -138,16 +138,16 @@ class MockProcTable : public ProcTableAsClass {
MOCK_METHOD1({{as_MethodSuffix(type.name, Name("release"))}}, void({{as_cType(type.name)}} self)); MOCK_METHOD1({{as_MethodSuffix(type.name, Name("release"))}}, void({{as_cType(type.name)}} self));
{% endfor %} {% endfor %}
MOCK_METHOD3(OnDeviceSetUncapturedErrorCallback, void(DawnDevice device, DawnErrorCallback callback, void* userdata)); MOCK_METHOD3(OnDeviceSetUncapturedErrorCallback, void(WGPUDevice device, WGPUErrorCallback callback, void* userdata));
MOCK_METHOD3(OnDevicePopErrorScopeCallback, bool(DawnDevice device, DawnErrorCallback callback, void* userdata)); MOCK_METHOD3(OnDevicePopErrorScopeCallback, bool(WGPUDevice device, WGPUErrorCallback callback, void* userdata));
MOCK_METHOD4(OnDeviceCreateBufferMappedAsyncCallback, void(DawnDevice device, const DawnBufferDescriptor* descriptor, DawnBufferCreateMappedCallback callback, void* userdata)); MOCK_METHOD4(OnDeviceCreateBufferMappedAsyncCallback, void(WGPUDevice device, const WGPUBufferDescriptor* descriptor, WGPUBufferCreateMappedCallback callback, void* userdata));
MOCK_METHOD3(OnBufferMapReadAsyncCallback, void(DawnBuffer buffer, DawnBufferMapReadCallback callback, void* userdata)); MOCK_METHOD3(OnBufferMapReadAsyncCallback, void(WGPUBuffer buffer, WGPUBufferMapReadCallback callback, void* userdata));
MOCK_METHOD3(OnBufferMapWriteAsyncCallback, void(DawnBuffer buffer, DawnBufferMapWriteCallback callback, void* userdata)); MOCK_METHOD3(OnBufferMapWriteAsyncCallback, void(WGPUBuffer buffer, WGPUBufferMapWriteCallback callback, void* userdata));
MOCK_METHOD4(OnFenceOnCompletionCallback, MOCK_METHOD4(OnFenceOnCompletionCallback,
void(DawnFence fence, void(WGPUFence fence,
uint64_t value, uint64_t value,
DawnFenceOnCompletionCallback callback, WGPUFenceOnCompletionCallback callback,
void* userdata)); void* userdata));
}; };
#endif // MOCK_DAWN_H #endif // MOCK_WEBGPU_H

View File

@ -14,7 +14,7 @@
#include "common/Assert.h" #include "common/Assert.h"
#include "dawn/dawn_proc.h" #include "dawn/dawn_proc.h"
#include "dawn/dawncpp.h" #include "dawn/webgpu_cpp.h"
#include "dawn_native/DawnNative.h" #include "dawn_native/DawnNative.h"
#include "dawn_wire/WireServer.h" #include "dawn_wire/WireServer.h"
@ -36,10 +36,10 @@ class DevNull : public dawn_wire::CommandSerializer {
std::vector<char> buf; std::vector<char> buf;
}; };
static DawnProcDeviceCreateSwapChain originalDeviceCreateSwapChain = nullptr; static WGPUProcDeviceCreateSwapChain originalDeviceCreateSwapChain = nullptr;
DawnSwapChain ErrorDeviceCreateSwapChain(DawnDevice device, const DawnSwapChainDescriptor*) { WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device, const WGPUSwapChainDescriptor*) {
DawnSwapChainDescriptor desc; WGPUSwapChainDescriptor desc;
desc.nextInChain = nullptr; desc.nextInChain = nullptr;
desc.label = nullptr; desc.label = nullptr;
// A 0 implementation will trigger a swapchain creation error. // A 0 implementation will trigger a swapchain creation error.
@ -65,10 +65,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
std::vector<dawn_native::Adapter> adapters = instance->GetAdapters(); std::vector<dawn_native::Adapter> adapters = instance->GetAdapters();
dawn::Device nullDevice; wgpu::Device nullDevice;
for (dawn_native::Adapter adapter : adapters) { for (dawn_native::Adapter adapter : adapters) {
if (adapter.GetBackendType() == dawn_native::BackendType::Null) { if (adapter.GetBackendType() == dawn_native::BackendType::Null) {
nullDevice = dawn::Device::Acquire(adapter.CreateDevice()); nullDevice = wgpu::Device::Acquire(adapter.CreateDevice());
break; break;
} }
} }

View File

@ -14,7 +14,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "dawn/dawncpp.h" #include "dawn/webgpu_cpp.h"
class Object : public wgpu::ObjectBase<Object, int*> { class Object : public wgpu::ObjectBase<Object, int*> {
public: public:

View File

@ -24,48 +24,48 @@ class BindGroupValidationTest : public ValidationTest {
void SetUp() override { void SetUp() override {
// Create objects to use as resources inside test bind groups. // Create objects to use as resources inside test bind groups.
{ {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 1024; descriptor.size = 1024;
descriptor.usage = dawn::BufferUsage::Uniform; descriptor.usage = wgpu::BufferUsage::Uniform;
mUBO = device.CreateBuffer(&descriptor); mUBO = device.CreateBuffer(&descriptor);
} }
{ {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 1024; descriptor.size = 1024;
descriptor.usage = dawn::BufferUsage::Storage; descriptor.usage = wgpu::BufferUsage::Storage;
mSSBO = device.CreateBuffer(&descriptor); mSSBO = device.CreateBuffer(&descriptor);
} }
{ {
dawn::SamplerDescriptor descriptor = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor descriptor = utils::GetDefaultSamplerDescriptor();
mSampler = device.CreateSampler(&descriptor); mSampler = device.CreateSampler(&descriptor);
} }
{ {
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size = {16, 16, 1}; descriptor.size = {16, 16, 1};
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
descriptor.sampleCount = 1; descriptor.sampleCount = 1;
descriptor.format = dawn::TextureFormat::RGBA8Unorm; descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
descriptor.usage = dawn::TextureUsage::Sampled; descriptor.usage = wgpu::TextureUsage::Sampled;
mSampledTexture = device.CreateTexture(&descriptor); mSampledTexture = device.CreateTexture(&descriptor);
mSampledTextureView = mSampledTexture.CreateView(); mSampledTextureView = mSampledTexture.CreateView();
} }
} }
protected: protected:
dawn::Buffer mUBO; wgpu::Buffer mUBO;
dawn::Buffer mSSBO; wgpu::Buffer mSSBO;
dawn::Sampler mSampler; wgpu::Sampler mSampler;
dawn::Texture mSampledTexture; wgpu::Texture mSampledTexture;
dawn::TextureView mSampledTextureView; wgpu::TextureView mSampledTextureView;
}; };
// Test the validation of BindGroupDescriptor::nextInChain // Test the validation of BindGroupDescriptor::nextInChain
TEST_F(BindGroupValidationTest, NextInChainNullptr) { TEST_F(BindGroupValidationTest, NextInChainNullptr) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {}); wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
dawn::BindGroupDescriptor descriptor; wgpu::BindGroupDescriptor descriptor;
descriptor.layout = layout; descriptor.layout = layout;
descriptor.bindingCount = 0; descriptor.bindingCount = 0;
descriptor.bindings = nullptr; descriptor.bindings = nullptr;
@ -81,8 +81,8 @@ TEST_F(BindGroupValidationTest, NextInChainNullptr) {
// Check constraints on bindingCount // Check constraints on bindingCount
TEST_F(BindGroupValidationTest, bindingCountMismatch) { TEST_F(BindGroupValidationTest, bindingCountMismatch) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
// Control case: check that a descriptor with one binding is ok // Control case: check that a descriptor with one binding is ok
utils::MakeBindGroup(device, layout, {{0, mSampler}}); utils::MakeBindGroup(device, layout, {{0, mSampler}});
@ -93,8 +93,8 @@ TEST_F(BindGroupValidationTest, bindingCountMismatch) {
// Check constraints on BindGroupBinding::binding // Check constraints on BindGroupBinding::binding
TEST_F(BindGroupValidationTest, WrongBindings) { TEST_F(BindGroupValidationTest, WrongBindings) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
// Control case: check that a descriptor with a binding matching the layout's is ok // Control case: check that a descriptor with a binding matching the layout's is ok
utils::MakeBindGroup(device, layout, {{0, mSampler}}); utils::MakeBindGroup(device, layout, {{0, mSampler}});
@ -108,9 +108,9 @@ TEST_F(BindGroupValidationTest, WrongBindings) {
// Check that the same binding cannot be set twice // Check that the same binding cannot be set twice
TEST_F(BindGroupValidationTest, BindingSetTwice) { TEST_F(BindGroupValidationTest, BindingSetTwice) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler}, device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler},
{1, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler}}); {1, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
// Control case: check that different bindings work // Control case: check that different bindings work
utils::MakeBindGroup(device, layout, { utils::MakeBindGroup(device, layout, {
@ -127,10 +127,10 @@ TEST_F(BindGroupValidationTest, BindingSetTwice) {
// Check that a sampler binding must contain exactly one sampler // Check that a sampler binding must contain exactly one sampler
TEST_F(BindGroupValidationTest, SamplerBindingType) { TEST_F(BindGroupValidationTest, SamplerBindingType) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
dawn::BindGroupBinding binding; wgpu::BindGroupBinding binding;
binding.binding = 0; binding.binding = 0;
binding.sampler = nullptr; binding.sampler = nullptr;
binding.textureView = nullptr; binding.textureView = nullptr;
@ -138,7 +138,7 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) {
binding.offset = 0; binding.offset = 0;
binding.size = 0; binding.size = 0;
dawn::BindGroupDescriptor descriptor; wgpu::BindGroupDescriptor descriptor;
descriptor.layout = layout; descriptor.layout = layout;
descriptor.bindingCount = 1; descriptor.bindingCount = 1;
descriptor.bindings = &binding; descriptor.bindings = &binding;
@ -162,10 +162,10 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) {
// Setting the sampler to an error sampler is an error. // Setting the sampler to an error sampler is an error.
{ {
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.minFilter = static_cast<dawn::FilterMode>(0xFFFFFFFF); samplerDesc.minFilter = static_cast<wgpu::FilterMode>(0xFFFFFFFF);
dawn::Sampler errorSampler; wgpu::Sampler errorSampler;
ASSERT_DEVICE_ERROR(errorSampler = device.CreateSampler(&samplerDesc)); ASSERT_DEVICE_ERROR(errorSampler = device.CreateSampler(&samplerDesc));
binding.sampler = errorSampler; binding.sampler = errorSampler;
@ -176,10 +176,10 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) {
// Check that a texture binding must contain exactly a texture view // Check that a texture binding must contain exactly a texture view
TEST_F(BindGroupValidationTest, TextureBindingType) { TEST_F(BindGroupValidationTest, TextureBindingType) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}});
dawn::BindGroupBinding binding; wgpu::BindGroupBinding binding;
binding.binding = 0; binding.binding = 0;
binding.sampler = nullptr; binding.sampler = nullptr;
binding.textureView = nullptr; binding.textureView = nullptr;
@ -187,7 +187,7 @@ TEST_F(BindGroupValidationTest, TextureBindingType) {
binding.offset = 0; binding.offset = 0;
binding.size = 0; binding.size = 0;
dawn::BindGroupDescriptor descriptor; wgpu::BindGroupDescriptor descriptor;
descriptor.layout = layout; descriptor.layout = layout;
descriptor.bindingCount = 1; descriptor.bindingCount = 1;
descriptor.bindings = &binding; descriptor.bindings = &binding;
@ -211,15 +211,15 @@ TEST_F(BindGroupValidationTest, TextureBindingType) {
// Setting the texture view to an error texture view is an error. // Setting the texture view to an error texture view is an error.
{ {
dawn::TextureViewDescriptor viewDesc; wgpu::TextureViewDescriptor viewDesc;
viewDesc.format = dawn::TextureFormat::RGBA8Unorm; viewDesc.format = wgpu::TextureFormat::RGBA8Unorm;
viewDesc.dimension = dawn::TextureViewDimension::e2D; viewDesc.dimension = wgpu::TextureViewDimension::e2D;
viewDesc.baseMipLevel = 0; viewDesc.baseMipLevel = 0;
viewDesc.mipLevelCount = 0; viewDesc.mipLevelCount = 0;
viewDesc.baseArrayLayer = 0; viewDesc.baseArrayLayer = 0;
viewDesc.arrayLayerCount = 1000; viewDesc.arrayLayerCount = 1000;
dawn::TextureView errorView; wgpu::TextureView errorView;
ASSERT_DEVICE_ERROR(errorView = mSampledTexture.CreateView(&viewDesc)); ASSERT_DEVICE_ERROR(errorView = mSampledTexture.CreateView(&viewDesc));
binding.textureView = errorView; binding.textureView = errorView;
@ -230,10 +230,10 @@ TEST_F(BindGroupValidationTest, TextureBindingType) {
// Check that a buffer binding must contain exactly a buffer // Check that a buffer binding must contain exactly a buffer
TEST_F(BindGroupValidationTest, BufferBindingType) { TEST_F(BindGroupValidationTest, BufferBindingType) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}});
dawn::BindGroupBinding binding; wgpu::BindGroupBinding binding;
binding.binding = 0; binding.binding = 0;
binding.sampler = nullptr; binding.sampler = nullptr;
binding.textureView = nullptr; binding.textureView = nullptr;
@ -241,7 +241,7 @@ TEST_F(BindGroupValidationTest, BufferBindingType) {
binding.offset = 0; binding.offset = 0;
binding.size = 0; binding.size = 0;
dawn::BindGroupDescriptor descriptor; wgpu::BindGroupDescriptor descriptor;
descriptor.layout = layout; descriptor.layout = layout;
descriptor.bindingCount = 1; descriptor.bindingCount = 1;
descriptor.bindings = &binding; descriptor.bindings = &binding;
@ -265,11 +265,11 @@ TEST_F(BindGroupValidationTest, BufferBindingType) {
// Setting the buffer to an error buffer is an error. // Setting the buffer to an error buffer is an error.
{ {
dawn::BufferDescriptor bufferDesc; wgpu::BufferDescriptor bufferDesc;
bufferDesc.size = 1024; bufferDesc.size = 1024;
bufferDesc.usage = static_cast<dawn::BufferUsage>(0xFFFFFFFF); bufferDesc.usage = static_cast<wgpu::BufferUsage>(0xFFFFFFFF);
dawn::Buffer errorBuffer; wgpu::Buffer errorBuffer;
ASSERT_DEVICE_ERROR(errorBuffer = device.CreateBuffer(&bufferDesc)); ASSERT_DEVICE_ERROR(errorBuffer = device.CreateBuffer(&bufferDesc));
binding.buffer = errorBuffer; binding.buffer = errorBuffer;
@ -280,78 +280,78 @@ TEST_F(BindGroupValidationTest, BufferBindingType) {
// Check that a texture must have the correct usage // Check that a texture must have the correct usage
TEST_F(BindGroupValidationTest, TextureUsage) { TEST_F(BindGroupValidationTest, TextureUsage) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}});
// Control case: setting a sampleable texture view works. // Control case: setting a sampleable texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}}); utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});
// Make an output attachment texture and try to set it for a SampledTexture binding // Make an output attachment texture and try to set it for a SampledTexture binding
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size = {16, 16, 1}; descriptor.size = {16, 16, 1};
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
descriptor.sampleCount = 1; descriptor.sampleCount = 1;
descriptor.format = dawn::TextureFormat::RGBA8Unorm; descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
descriptor.usage = dawn::TextureUsage::OutputAttachment; descriptor.usage = wgpu::TextureUsage::OutputAttachment;
dawn::Texture outputTexture = device.CreateTexture(&descriptor); wgpu::Texture outputTexture = device.CreateTexture(&descriptor);
dawn::TextureView outputTextureView = outputTexture.CreateView(); wgpu::TextureView outputTextureView = outputTexture.CreateView();
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, outputTextureView}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, outputTextureView}}));
} }
// Check that a texture must have the correct component type // Check that a texture must have the correct component type
TEST_F(BindGroupValidationTest, TextureComponentType) { TEST_F(BindGroupValidationTest, TextureComponentType) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::SampledTexture, false, false, device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
dawn::TextureViewDimension::e2D, dawn::TextureComponentType::Float}}); wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
// Control case: setting a Float typed texture view works. // Control case: setting a Float typed texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}}); utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});
// Make a Uint component typed texture and try to set it to a Float component binding. // Make a Uint component typed texture and try to set it to a Float component binding.
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size = {16, 16, 1}; descriptor.size = {16, 16, 1};
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
descriptor.sampleCount = 1; descriptor.sampleCount = 1;
descriptor.format = dawn::TextureFormat::RGBA8Uint; descriptor.format = wgpu::TextureFormat::RGBA8Uint;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
descriptor.usage = dawn::TextureUsage::Sampled; descriptor.usage = wgpu::TextureUsage::Sampled;
dawn::Texture uintTexture = device.CreateTexture(&descriptor); wgpu::Texture uintTexture = device.CreateTexture(&descriptor);
dawn::TextureView uintTextureView = uintTexture.CreateView(); wgpu::TextureView uintTextureView = uintTexture.CreateView();
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, uintTextureView}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, uintTextureView}}));
} }
// Check that a texture must have the correct dimension // Check that a texture must have the correct dimension
TEST_F(BindGroupValidationTest, TextureDimension) { TEST_F(BindGroupValidationTest, TextureDimension) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::SampledTexture, false, false, device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
dawn::TextureViewDimension::e2D, dawn::TextureComponentType::Float}}); wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
// Control case: setting a 2D texture view works. // Control case: setting a 2D texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}}); utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});
// Make a 2DArray texture and try to set it to a 2D binding. // Make a 2DArray texture and try to set it to a 2D binding.
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size = {16, 16, 1}; descriptor.size = {16, 16, 1};
descriptor.arrayLayerCount = 2; descriptor.arrayLayerCount = 2;
descriptor.sampleCount = 1; descriptor.sampleCount = 1;
descriptor.format = dawn::TextureFormat::RGBA8Uint; descriptor.format = wgpu::TextureFormat::RGBA8Uint;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
descriptor.usage = dawn::TextureUsage::Sampled; descriptor.usage = wgpu::TextureUsage::Sampled;
dawn::Texture arrayTexture = device.CreateTexture(&descriptor); wgpu::Texture arrayTexture = device.CreateTexture(&descriptor);
dawn::TextureView arrayTextureView = arrayTexture.CreateView(); wgpu::TextureView arrayTextureView = arrayTexture.CreateView();
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, arrayTextureView}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, arrayTextureView}}));
} }
// Check that a UBO must have the correct usage // Check that a UBO must have the correct usage
TEST_F(BindGroupValidationTest, BufferUsageUBO) { TEST_F(BindGroupValidationTest, BufferUsageUBO) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}});
// Control case: using a buffer with the uniform usage works // Control case: using a buffer with the uniform usage works
utils::MakeBindGroup(device, layout, {{0, mUBO, 0, 256}}); utils::MakeBindGroup(device, layout, {{0, mUBO, 0, 256}});
@ -362,8 +362,8 @@ TEST_F(BindGroupValidationTest, BufferUsageUBO) {
// Check that a SSBO must have the correct usage // Check that a SSBO must have the correct usage
TEST_F(BindGroupValidationTest, BufferUsageSSBO) { TEST_F(BindGroupValidationTest, BufferUsageSSBO) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}});
// Control case: using a buffer with the storage usage works // Control case: using a buffer with the storage usage works
utils::MakeBindGroup(device, layout, {{0, mSSBO, 0, 256}}); utils::MakeBindGroup(device, layout, {{0, mSSBO, 0, 256}});
@ -374,9 +374,9 @@ TEST_F(BindGroupValidationTest, BufferUsageSSBO) {
// Tests constraints on the buffer offset for bind groups. // Tests constraints on the buffer offset for bind groups.
TEST_F(BindGroupValidationTest, BufferOffsetAlignment) { TEST_F(BindGroupValidationTest, BufferOffsetAlignment) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
}); });
// Check that offset 0 is valid // Check that offset 0 is valid
@ -393,15 +393,15 @@ TEST_F(BindGroupValidationTest, BufferOffsetAlignment) {
// Tests constraints to be sure the buffer binding fits in the buffer // Tests constraints to be sure the buffer binding fits in the buffer
TEST_F(BindGroupValidationTest, BufferBindingOOB) { TEST_F(BindGroupValidationTest, BufferBindingOOB) {
dawn::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
}); });
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 1024; descriptor.size = 1024;
descriptor.usage = dawn::BufferUsage::Uniform; descriptor.usage = wgpu::BufferUsage::Uniform;
dawn::Buffer buffer = device.CreateBuffer(&descriptor); wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
// Success case, touching the start of the buffer works // Success case, touching the start of the buffer works
utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256}}); utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256}});
@ -412,7 +412,7 @@ TEST_F(BindGroupValidationTest, BufferBindingOOB) {
// Success case, touching the full buffer works // Success case, touching the full buffer works
utils::MakeBindGroup(device, layout, {{0, buffer, 0, 1024}}); utils::MakeBindGroup(device, layout, {{0, buffer, 0, 1024}});
utils::MakeBindGroup(device, layout, {{0, buffer, 0, dawn::kWholeSize}}); utils::MakeBindGroup(device, layout, {{0, buffer, 0, wgpu::kWholeSize}});
// Error case, offset is OOB // Error case, offset is OOB
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256*5, 0}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256*5, 0}}));
@ -422,7 +422,7 @@ TEST_F(BindGroupValidationTest, BufferBindingOOB) {
// Error case, offset+size is OOB // Error case, offset+size is OOB
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 256}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 256}}));
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256, dawn::kWholeSize}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256, wgpu::kWholeSize}}));
// Error case, offset+size overflows to be 0 // Error case, offset+size overflows to be 0
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256, uint32_t(0) - uint32_t(256)}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256, uint32_t(0) - uint32_t(256)}}));
@ -430,17 +430,17 @@ TEST_F(BindGroupValidationTest, BufferBindingOOB) {
// Test what happens when the layout is an error. // Test what happens when the layout is an error.
TEST_F(BindGroupValidationTest, ErrorLayout) { TEST_F(BindGroupValidationTest, ErrorLayout) {
dawn::BindGroupLayout goodLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout goodLayout = utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
}); });
dawn::BindGroupLayout errorLayout; wgpu::BindGroupLayout errorLayout;
ASSERT_DEVICE_ERROR( ASSERT_DEVICE_ERROR(
errorLayout = utils::MakeBindGroupLayout( errorLayout = utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
})); }));
// Control case, creating with the good layout works // Control case, creating with the good layout works
@ -452,10 +452,10 @@ TEST_F(BindGroupValidationTest, ErrorLayout) {
class BindGroupLayoutValidationTest : public ValidationTest { class BindGroupLayoutValidationTest : public ValidationTest {
public: public:
void TestCreateBindGroupLayout(dawn::BindGroupLayoutBinding* binding, void TestCreateBindGroupLayout(wgpu::BindGroupLayoutBinding* binding,
uint32_t count, uint32_t count,
bool expected) { bool expected) {
dawn::BindGroupLayoutDescriptor descriptor; wgpu::BindGroupLayoutDescriptor descriptor;
descriptor.bindingCount = count; descriptor.bindingCount = count;
descriptor.bindings = binding; descriptor.bindings = binding;
@ -467,8 +467,8 @@ class BindGroupLayoutValidationTest : public ValidationTest {
} }
} }
void TestCreatePipelineLayout(dawn::BindGroupLayout* bgl, uint32_t count, bool expected) { void TestCreatePipelineLayout(wgpu::BindGroupLayout* bgl, uint32_t count, bool expected) {
dawn::PipelineLayoutDescriptor descriptor; wgpu::PipelineLayoutDescriptor descriptor;
descriptor.bindGroupLayoutCount = count; descriptor.bindGroupLayoutCount = count;
descriptor.bindGroupLayouts = bgl; descriptor.bindGroupLayouts = bgl;
@ -484,13 +484,13 @@ class BindGroupLayoutValidationTest : public ValidationTest {
// Tests setting OOB checks for kMaxBindingsPerGroup in bind group layouts. // Tests setting OOB checks for kMaxBindingsPerGroup in bind group layouts.
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutBindingOOB) { TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutBindingOOB) {
// Checks that kMaxBindingsPerGroup - 1 is valid. // Checks that kMaxBindingsPerGroup - 1 is valid.
utils::MakeBindGroupLayout(device, {{kMaxBindingsPerGroup - 1, dawn::ShaderStage::Vertex, utils::MakeBindGroupLayout(device, {{kMaxBindingsPerGroup - 1, wgpu::ShaderStage::Vertex,
dawn::BindingType::UniformBuffer}}); wgpu::BindingType::UniformBuffer}});
// Checks that kMaxBindingsPerGroup is OOB // Checks that kMaxBindingsPerGroup is OOB
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, device,
{{kMaxBindingsPerGroup, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}})); {{kMaxBindingsPerGroup, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}));
} }
// This test verifies that the BindGroupLayout bindings are correctly validated, even if the // This test verifies that the BindGroupLayout bindings are correctly validated, even if the
@ -498,8 +498,8 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutBindingOOB) {
TEST_F(BindGroupLayoutValidationTest, BindGroupBinding) { TEST_F(BindGroupLayoutValidationTest, BindGroupBinding) {
utils::MakeBindGroupLayout(device, utils::MakeBindGroupLayout(device,
{ {
{1, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}, {1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
}); });
} }
@ -507,22 +507,22 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupBinding) {
TEST_F(BindGroupLayoutValidationTest, DynamicAndTypeCompatibility) { TEST_F(BindGroupLayoutValidationTest, DynamicAndTypeCompatibility) {
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Compute, dawn::BindingType::UniformBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer, true},
}); });
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Compute, dawn::BindingType::StorageBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer, true},
}); });
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Compute, dawn::BindingType::SampledTexture, true}, {0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, true},
})); }));
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Compute, dawn::BindingType::Sampler, true}, {0, wgpu::ShaderStage::Compute, wgpu::BindingType::Sampler, true},
})); }));
} }
@ -530,12 +530,12 @@ TEST_F(BindGroupLayoutValidationTest, DynamicAndTypeCompatibility) {
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) { TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
utils::MakeBindGroupLayout(device, utils::MakeBindGroupLayout(device,
{ {
{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
}); });
dawn::BindGroupLayoutBinding binding = {0, dawn::ShaderStage::None, wgpu::BindGroupLayoutBinding binding = {0, wgpu::ShaderStage::None,
dawn::BindingType::UniformBuffer}; wgpu::BindingType::UniformBuffer};
dawn::BindGroupLayoutDescriptor descriptor; wgpu::BindGroupLayoutDescriptor descriptor;
descriptor.bindingCount = 1; descriptor.bindingCount = 1;
descriptor.bindings = &binding; descriptor.bindings = &binding;
device.CreateBindGroupLayout(&descriptor); device.CreateBindGroupLayout(&descriptor);
@ -543,23 +543,23 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
// Check that dynamic buffer numbers exceed maximum value in one bind group layout. // Check that dynamic buffer numbers exceed maximum value in one bind group layout.
TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) { TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
dawn::BindGroupLayout bgl[2]; wgpu::BindGroupLayout bgl[2];
std::vector<dawn::BindGroupLayoutBinding> maxUniformDB; std::vector<wgpu::BindGroupLayoutBinding> maxUniformDB;
std::vector<dawn::BindGroupLayoutBinding> maxStorageDB; std::vector<wgpu::BindGroupLayoutBinding> maxStorageDB;
for (uint32_t i = 0; i < kMaxDynamicUniformBufferCount; ++i) { for (uint32_t i = 0; i < kMaxDynamicUniformBufferCount; ++i) {
maxUniformDB.push_back( maxUniformDB.push_back(
{i, dawn::ShaderStage::Compute, dawn::BindingType::UniformBuffer, true}); {i, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer, true});
} }
for (uint32_t i = 0; i < kMaxDynamicStorageBufferCount; ++i) { for (uint32_t i = 0; i < kMaxDynamicStorageBufferCount; ++i) {
maxStorageDB.push_back( maxStorageDB.push_back(
{i, dawn::ShaderStage::Compute, dawn::BindingType::StorageBuffer, true}); {i, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer, true});
} }
auto MakeBindGroupLayout = [&](dawn::BindGroupLayoutBinding* binding, auto MakeBindGroupLayout = [&](wgpu::BindGroupLayoutBinding* binding,
uint32_t count) -> dawn::BindGroupLayout { uint32_t count) -> wgpu::BindGroupLayout {
dawn::BindGroupLayoutDescriptor descriptor; wgpu::BindGroupLayoutDescriptor descriptor;
descriptor.bindingCount = count; descriptor.bindingCount = count;
descriptor.bindings = binding; descriptor.bindings = binding;
return device.CreateBindGroupLayout(&descriptor); return device.CreateBindGroupLayout(&descriptor);
@ -577,7 +577,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
bgl[0] = MakeBindGroupLayout(maxUniformDB.data(), maxUniformDB.size()); bgl[0] = MakeBindGroupLayout(maxUniformDB.data(), maxUniformDB.size());
bgl[1] = utils::MakeBindGroupLayout( bgl[1] = utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Compute, dawn::BindingType::UniformBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer, true},
}); });
TestCreatePipelineLayout(bgl, 2, false); TestCreatePipelineLayout(bgl, 2, false);
@ -588,7 +588,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
bgl[0] = MakeBindGroupLayout(maxStorageDB.data(), maxStorageDB.size()); bgl[0] = MakeBindGroupLayout(maxStorageDB.data(), maxStorageDB.size());
bgl[1] = utils::MakeBindGroupLayout( bgl[1] = utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Compute, dawn::BindingType::StorageBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer, true},
}); });
TestCreatePipelineLayout(bgl, 2, false); TestCreatePipelineLayout(bgl, 2, false);
@ -596,15 +596,15 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
// Check dynamic uniform buffers exceed maximum in bind group layout. // Check dynamic uniform buffers exceed maximum in bind group layout.
{ {
maxUniformDB.push_back({kMaxDynamicUniformBufferCount, dawn::ShaderStage::Compute, maxUniformDB.push_back({kMaxDynamicUniformBufferCount, wgpu::ShaderStage::Compute,
dawn::BindingType::UniformBuffer, true}); wgpu::BindingType::UniformBuffer, true});
TestCreateBindGroupLayout(maxUniformDB.data(), maxUniformDB.size(), false); TestCreateBindGroupLayout(maxUniformDB.data(), maxUniformDB.size(), false);
} }
// Check dynamic storage buffers exceed maximum in bind group layout. // Check dynamic storage buffers exceed maximum in bind group layout.
{ {
maxStorageDB.push_back({kMaxDynamicStorageBufferCount, dawn::ShaderStage::Compute, maxStorageDB.push_back({kMaxDynamicStorageBufferCount, wgpu::ShaderStage::Compute,
dawn::BindingType::StorageBuffer, true}); wgpu::BindingType::StorageBuffer, true});
TestCreateBindGroupLayout(maxStorageDB.data(), maxStorageDB.size(), false); TestCreateBindGroupLayout(maxStorageDB.data(), maxStorageDB.size(), false);
} }
} }
@ -616,32 +616,32 @@ class SetBindGroupValidationTest : public ValidationTest {
public: public:
void SetUp() override { void SetUp() override {
mBindGroupLayout = utils::MakeBindGroupLayout( mBindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Compute | dawn::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
dawn::BindingType::UniformBuffer, true}, wgpu::BindingType::UniformBuffer, true},
{1, dawn::ShaderStage::Compute | dawn::ShaderStage::Fragment, {1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
dawn::BindingType::StorageBuffer, true}}); wgpu::BindingType::StorageBuffer, true}});
} }
dawn::Buffer CreateBuffer(uint64_t bufferSize, dawn::BufferUsage usage) { wgpu::Buffer CreateBuffer(uint64_t bufferSize, wgpu::BufferUsage usage) {
dawn::BufferDescriptor bufferDescriptor; wgpu::BufferDescriptor bufferDescriptor;
bufferDescriptor.size = bufferSize; bufferDescriptor.size = bufferSize;
bufferDescriptor.usage = usage; bufferDescriptor.usage = usage;
return device.CreateBuffer(&bufferDescriptor); return device.CreateBuffer(&bufferDescriptor);
} }
dawn::BindGroupLayout mBindGroupLayout; wgpu::BindGroupLayout mBindGroupLayout;
dawn::Buffer mUniformBuffer; wgpu::Buffer mUniformBuffer;
dawn::Buffer mStorageBuffer; wgpu::Buffer mStorageBuffer;
dawn::RenderPipeline CreateRenderPipeline() { wgpu::RenderPipeline CreateRenderPipeline() {
dawn::ShaderModule vsModule = wgpu::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450 #version 450
void main() { void main() {
})"); })");
dawn::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450 #version 450
layout(std140, set = 0, binding = 0) uniform uBuffer { layout(std140, set = 0, binding = 0) uniform uBuffer {
@ -657,14 +657,14 @@ class SetBindGroupValidationTest : public ValidationTest {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragmentStage.module = fsModule;
dawn::PipelineLayout pipelineLayout = wgpu::PipelineLayout pipelineLayout =
utils::MakeBasicPipelineLayout(device, &mBindGroupLayout); utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.layout = pipelineLayout;
return device.CreateRenderPipeline(&pipelineDescriptor); return device.CreateRenderPipeline(&pipelineDescriptor);
} }
dawn::ComputePipeline CreateComputePipeline() { wgpu::ComputePipeline CreateComputePipeline() {
dawn::ShaderModule csModule = wgpu::ShaderModule csModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
#version 450 #version 450
const uint kTileSize = 4; const uint kTileSize = 4;
@ -681,10 +681,10 @@ class SetBindGroupValidationTest : public ValidationTest {
void main() { void main() {
})"); })");
dawn::PipelineLayout pipelineLayout = wgpu::PipelineLayout pipelineLayout =
utils::MakeBasicPipelineLayout(device, &mBindGroupLayout); utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
dawn::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.layout = pipelineLayout; csDesc.layout = pipelineLayout;
csDesc.computeStage.module = csModule; csDesc.computeStage.module = csModule;
csDesc.computeStage.entryPoint = "main"; csDesc.computeStage.entryPoint = "main";
@ -692,15 +692,15 @@ class SetBindGroupValidationTest : public ValidationTest {
return device.CreateComputePipeline(&csDesc); return device.CreateComputePipeline(&csDesc);
} }
void TestRenderPassBindGroup(dawn::BindGroup bindGroup, void TestRenderPassBindGroup(wgpu::BindGroup bindGroup,
uint64_t* offsets, uint64_t* offsets,
uint32_t count, uint32_t count,
bool expectation) { bool expectation) {
dawn::RenderPipeline renderPipeline = CreateRenderPipeline(); wgpu::RenderPipeline renderPipeline = CreateRenderPipeline();
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(&renderPass);
renderPassEncoder.SetPipeline(renderPipeline); renderPassEncoder.SetPipeline(renderPipeline);
renderPassEncoder.SetBindGroup(0, bindGroup, count, offsets); renderPassEncoder.SetBindGroup(0, bindGroup, count, offsets);
renderPassEncoder.Draw(3, 1, 0, 0); renderPassEncoder.Draw(3, 1, 0, 0);
@ -712,14 +712,14 @@ class SetBindGroupValidationTest : public ValidationTest {
} }
} }
void TestComputePassBindGroup(dawn::BindGroup bindGroup, void TestComputePassBindGroup(wgpu::BindGroup bindGroup,
uint64_t* offsets, uint64_t* offsets,
uint32_t count, uint32_t count,
bool expectation) { bool expectation) {
dawn::ComputePipeline computePipeline = CreateComputePipeline(); wgpu::ComputePipeline computePipeline = CreateComputePipeline();
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder computePassEncoder = commandEncoder.BeginComputePass(); wgpu::ComputePassEncoder computePassEncoder = commandEncoder.BeginComputePass();
computePassEncoder.SetPipeline(computePipeline); computePassEncoder.SetPipeline(computePipeline);
computePassEncoder.SetBindGroup(0, bindGroup, count, offsets); computePassEncoder.SetBindGroup(0, bindGroup, count, offsets);
computePassEncoder.Dispatch(1, 1, 1); computePassEncoder.Dispatch(1, 1, 1);
@ -735,9 +735,9 @@ class SetBindGroupValidationTest : public ValidationTest {
// This is the test case that should work. // This is the test case that should work.
TEST_F(SetBindGroupValidationTest, Basic) { TEST_F(SetBindGroupValidationTest, Basic) {
// Set up the bind group. // Set up the bind group.
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, mBindGroupLayout, device, mBindGroupLayout,
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
@ -751,9 +751,9 @@ TEST_F(SetBindGroupValidationTest, Basic) {
// Test cases that test dynamic offsets count mismatch with bind group layout. // Test cases that test dynamic offsets count mismatch with bind group layout.
TEST_F(SetBindGroupValidationTest, DynamicOffsetsMismatch) { TEST_F(SetBindGroupValidationTest, DynamicOffsetsMismatch) {
// Set up bind group. // Set up bind group.
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, mBindGroupLayout, device, mBindGroupLayout,
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
@ -768,9 +768,9 @@ TEST_F(SetBindGroupValidationTest, DynamicOffsetsMismatch) {
// Test cases that test dynamic offsets not aligned // Test cases that test dynamic offsets not aligned
TEST_F(SetBindGroupValidationTest, DynamicOffsetsNotAligned) { TEST_F(SetBindGroupValidationTest, DynamicOffsetsNotAligned) {
// Set up bind group. // Set up bind group.
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, mBindGroupLayout, device, mBindGroupLayout,
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
@ -785,9 +785,9 @@ TEST_F(SetBindGroupValidationTest, DynamicOffsetsNotAligned) {
// Test cases that test dynamic uniform buffer out of bound situation. // Test cases that test dynamic uniform buffer out of bound situation.
TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicUniformBuffer) { TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicUniformBuffer) {
// Set up bind group. // Set up bind group.
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, mBindGroupLayout, device, mBindGroupLayout,
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
@ -802,9 +802,9 @@ TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicUniformBuffer) {
// Test cases that test dynamic storage buffer out of bound situation. // Test cases that test dynamic storage buffer out of bound situation.
TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicStorageBuffer) { TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicStorageBuffer) {
// Set up bind group. // Set up bind group.
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, mBindGroupLayout, device, mBindGroupLayout,
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
@ -819,9 +819,9 @@ TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicStorageBuffer) {
// Test cases that test dynamic uniform buffer out of bound situation because of binding size. // Test cases that test dynamic uniform buffer out of bound situation because of binding size.
TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicUniformBuffer) { TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicUniformBuffer) {
// Set up bind group, but binding size is larger than // Set up bind group, but binding size is larger than
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, mBindGroupLayout, device, mBindGroupLayout,
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
@ -836,9 +836,9 @@ TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicUniformBuffer) {
// Test cases that test dynamic storage buffer out of bound situation because of binding size. // Test cases that test dynamic storage buffer out of bound situation because of binding size.
TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicStorageBuffer) { TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicStorageBuffer) {
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, mBindGroupLayout, device, mBindGroupLayout,
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
// Dynamic offset + offset isn't larger than buffer size. // Dynamic offset + offset isn't larger than buffer size.
@ -854,7 +854,7 @@ TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicStorageBuffer) {
// SetBindGroup // SetBindGroup
TEST_F(SetBindGroupValidationTest, ErrorBindGroup) { TEST_F(SetBindGroupValidationTest, ErrorBindGroup) {
// Bindgroup creation fails because not all bindings are specified. // Bindgroup creation fails because not all bindings are specified.
dawn::BindGroup bindGroup; wgpu::BindGroup bindGroup;
ASSERT_DEVICE_ERROR(bindGroup = utils::MakeBindGroup(device, mBindGroupLayout, {})); ASSERT_DEVICE_ERROR(bindGroup = utils::MakeBindGroup(device, mBindGroupLayout, {}));
TestRenderPassBindGroup(bindGroup, nullptr, 0, false); TestRenderPassBindGroup(bindGroup, nullptr, 0, false);
@ -871,8 +871,8 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
})"); })");
} }
dawn::Buffer CreateBuffer(uint64_t bufferSize, dawn::BufferUsage usage) { wgpu::Buffer CreateBuffer(uint64_t bufferSize, wgpu::BufferUsage usage) {
dawn::BufferDescriptor bufferDescriptor; wgpu::BufferDescriptor bufferDescriptor;
bufferDescriptor.size = bufferSize; bufferDescriptor.size = bufferSize;
bufferDescriptor.usage = usage; bufferDescriptor.usage = usage;
@ -880,34 +880,34 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
} }
// Generates bind group layouts and a pipeline from a 2D list of binding types. // Generates bind group layouts and a pipeline from a 2D list of binding types.
std::tuple<std::vector<dawn::BindGroupLayout>, dawn::RenderPipeline> SetUpLayoutsAndPipeline( std::tuple<std::vector<wgpu::BindGroupLayout>, wgpu::RenderPipeline> SetUpLayoutsAndPipeline(
std::vector<std::vector<dawn::BindingType>> layouts) { std::vector<std::vector<wgpu::BindingType>> layouts) {
std::vector<dawn::BindGroupLayout> bindGroupLayouts(layouts.size()); std::vector<wgpu::BindGroupLayout> bindGroupLayouts(layouts.size());
// Iterate through the desired bind group layouts. // Iterate through the desired bind group layouts.
for (uint32_t l = 0; l < layouts.size(); ++l) { for (uint32_t l = 0; l < layouts.size(); ++l) {
const auto& layout = layouts[l]; const auto& layout = layouts[l];
std::vector<dawn::BindGroupLayoutBinding> bindings(layout.size()); std::vector<wgpu::BindGroupLayoutBinding> bindings(layout.size());
// Iterate through binding types and populate a list of BindGroupLayoutBindings. // Iterate through binding types and populate a list of BindGroupLayoutBindings.
for (uint32_t b = 0; b < layout.size(); ++b) { for (uint32_t b = 0; b < layout.size(); ++b) {
bindings[b] = {b, dawn::ShaderStage::Fragment, layout[b], false}; bindings[b] = {b, wgpu::ShaderStage::Fragment, layout[b], false};
} }
// Create the bind group layout. // Create the bind group layout.
dawn::BindGroupLayoutDescriptor bglDescriptor; wgpu::BindGroupLayoutDescriptor bglDescriptor;
bglDescriptor.bindingCount = static_cast<uint32_t>(bindings.size()); bglDescriptor.bindingCount = static_cast<uint32_t>(bindings.size());
bglDescriptor.bindings = bindings.data(); bglDescriptor.bindings = bindings.data();
bindGroupLayouts[l] = device.CreateBindGroupLayout(&bglDescriptor); bindGroupLayouts[l] = device.CreateBindGroupLayout(&bglDescriptor);
} }
// Create a pipeline layout from the list of bind group layouts. // Create a pipeline layout from the list of bind group layouts.
dawn::PipelineLayoutDescriptor pipelineLayoutDescriptor; wgpu::PipelineLayoutDescriptor pipelineLayoutDescriptor;
pipelineLayoutDescriptor.bindGroupLayoutCount = pipelineLayoutDescriptor.bindGroupLayoutCount =
static_cast<uint32_t>(bindGroupLayouts.size()); static_cast<uint32_t>(bindGroupLayouts.size());
pipelineLayoutDescriptor.bindGroupLayouts = bindGroupLayouts.data(); pipelineLayoutDescriptor.bindGroupLayouts = bindGroupLayouts.data();
dawn::PipelineLayout pipelineLayout = wgpu::PipelineLayout pipelineLayout =
device.CreatePipelineLayout(&pipelineLayoutDescriptor); device.CreatePipelineLayout(&pipelineLayoutDescriptor);
std::stringstream ss; std::stringstream ss;
@ -918,13 +918,13 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
const auto& layout = layouts[l]; const auto& layout = layouts[l];
for (uint32_t b = 0; b < layout.size(); ++b) { for (uint32_t b = 0; b < layout.size(); ++b) {
dawn::BindingType binding = layout[b]; wgpu::BindingType binding = layout[b];
ss << "layout(std140, set = " << l << ", binding = " << b << ") "; ss << "layout(std140, set = " << l << ", binding = " << b << ") ";
switch (binding) { switch (binding) {
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
ss << "buffer SBuffer"; ss << "buffer SBuffer";
break; break;
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
ss << "uniform UBuffer"; ss << "uniform UBuffer";
break; break;
default: default:
@ -937,51 +937,51 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
ss << "layout(location = 0) out vec4 fragColor;\n"; ss << "layout(location = 0) out vec4 fragColor;\n";
ss << "void main() { fragColor = vec4(0.0, 1.0, 0.0, 1.0); }\n"; ss << "void main() { fragColor = vec4(0.0, 1.0, 0.0, 1.0); }\n";
dawn::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, ss.str().c_str()); utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, ss.str().c_str());
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = mVsModule; pipelineDescriptor.vertexStage.module = mVsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragmentStage.module = fsModule;
pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.layout = pipelineLayout;
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor);
return std::make_tuple(bindGroupLayouts, pipeline); return std::make_tuple(bindGroupLayouts, pipeline);
} }
private: private:
dawn::ShaderModule mVsModule; wgpu::ShaderModule mVsModule;
}; };
// Test it is valid to set bind groups before setting the pipeline. // Test it is valid to set bind groups before setting the pipeline.
TEST_F(SetBindGroupPersistenceValidationTest, BindGroupBeforePipeline) { TEST_F(SetBindGroupPersistenceValidationTest, BindGroupBeforePipeline) {
std::vector<dawn::BindGroupLayout> bindGroupLayouts; std::vector<wgpu::BindGroupLayout> bindGroupLayouts;
dawn::RenderPipeline pipeline; wgpu::RenderPipeline pipeline;
std::tie(bindGroupLayouts, pipeline) = SetUpLayoutsAndPipeline({{ std::tie(bindGroupLayouts, pipeline) = SetUpLayoutsAndPipeline({{
{{ {{
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
}}, }},
{{ {{
dawn::BindingType::StorageBuffer, wgpu::BindingType::StorageBuffer,
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
}}, }},
}}); }});
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroup0 = utils::MakeBindGroup( wgpu::BindGroup bindGroup0 = utils::MakeBindGroup(
device, bindGroupLayouts[0], device, bindGroupLayouts[0],
{{0, uniformBuffer, 0, kBindingSize}, {1, uniformBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, uniformBuffer, 0, kBindingSize}});
dawn::BindGroup bindGroup1 = utils::MakeBindGroup( wgpu::BindGroup bindGroup1 = utils::MakeBindGroup(
device, bindGroupLayouts[1], device, bindGroupLayouts[1],
{{0, storageBuffer, 0, kBindingSize}, {1, uniformBuffer, 0, kBindingSize}}); {{0, storageBuffer, 0, kBindingSize}, {1, uniformBuffer, 0, kBindingSize}});
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(&renderPass);
renderPassEncoder.SetBindGroup(0, bindGroup0); renderPassEncoder.SetBindGroup(0, bindGroup0);
renderPassEncoder.SetBindGroup(1, bindGroup1); renderPassEncoder.SetBindGroup(1, bindGroup1);
@ -996,50 +996,50 @@ TEST_F(SetBindGroupPersistenceValidationTest, BindGroupBeforePipeline) {
// Test that it is valid to draw with bind groups that are not "inherited". They persist // Test that it is valid to draw with bind groups that are not "inherited". They persist
// after a pipeline change. // after a pipeline change.
TEST_F(SetBindGroupPersistenceValidationTest, NotVulkanInheritance) { TEST_F(SetBindGroupPersistenceValidationTest, NotVulkanInheritance) {
std::vector<dawn::BindGroupLayout> bindGroupLayoutsA; std::vector<wgpu::BindGroupLayout> bindGroupLayoutsA;
dawn::RenderPipeline pipelineA; wgpu::RenderPipeline pipelineA;
std::tie(bindGroupLayoutsA, pipelineA) = SetUpLayoutsAndPipeline({{ std::tie(bindGroupLayoutsA, pipelineA) = SetUpLayoutsAndPipeline({{
{{ {{
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
dawn::BindingType::StorageBuffer, wgpu::BindingType::StorageBuffer,
}}, }},
{{ {{
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
}}, }},
}}); }});
std::vector<dawn::BindGroupLayout> bindGroupLayoutsB; std::vector<wgpu::BindGroupLayout> bindGroupLayoutsB;
dawn::RenderPipeline pipelineB; wgpu::RenderPipeline pipelineB;
std::tie(bindGroupLayoutsB, pipelineB) = SetUpLayoutsAndPipeline({{ std::tie(bindGroupLayoutsB, pipelineB) = SetUpLayoutsAndPipeline({{
{{ {{
dawn::BindingType::StorageBuffer, wgpu::BindingType::StorageBuffer,
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
}}, }},
{{ {{
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
dawn::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer,
}}, }},
}}); }});
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform); wgpu::Buffer uniformBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage); wgpu::Buffer storageBuffer = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
dawn::BindGroup bindGroupA0 = utils::MakeBindGroup( wgpu::BindGroup bindGroupA0 = utils::MakeBindGroup(
device, bindGroupLayoutsA[0], device, bindGroupLayoutsA[0],
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
dawn::BindGroup bindGroupA1 = utils::MakeBindGroup( wgpu::BindGroup bindGroupA1 = utils::MakeBindGroup(
device, bindGroupLayoutsA[1], device, bindGroupLayoutsA[1],
{{0, uniformBuffer, 0, kBindingSize}, {1, uniformBuffer, 0, kBindingSize}}); {{0, uniformBuffer, 0, kBindingSize}, {1, uniformBuffer, 0, kBindingSize}});
dawn::BindGroup bindGroupB0 = utils::MakeBindGroup( wgpu::BindGroup bindGroupB0 = utils::MakeBindGroup(
device, bindGroupLayoutsB[0], device, bindGroupLayoutsB[0],
{{0, storageBuffer, 0, kBindingSize}, {1, uniformBuffer, 0, kBindingSize}}); {{0, storageBuffer, 0, kBindingSize}, {1, uniformBuffer, 0, kBindingSize}});
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(&renderPass);
renderPassEncoder.SetPipeline(pipelineA); renderPassEncoder.SetPipeline(pipelineA);
renderPassEncoder.SetBindGroup(0, bindGroupA0); renderPassEncoder.SetBindGroup(0, bindGroupA0);

View File

@ -23,14 +23,14 @@ using namespace testing;
class MockBufferMapReadCallback { class MockBufferMapReadCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD4(Call,
void(DawnBufferMapAsyncStatus status, void(WGPUBufferMapAsyncStatus status,
const uint32_t* ptr, const uint32_t* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata)); void* userdata));
}; };
static std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback; static std::unique_ptr<MockBufferMapReadCallback> mockBufferMapReadCallback;
static void ToMockBufferMapReadCallback(DawnBufferMapAsyncStatus status, static void ToMockBufferMapReadCallback(WGPUBufferMapAsyncStatus status,
const void* ptr, const void* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata) { void* userdata) {
@ -42,14 +42,14 @@ static void ToMockBufferMapReadCallback(DawnBufferMapAsyncStatus status,
class MockBufferMapWriteCallback { class MockBufferMapWriteCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD4(Call,
void(DawnBufferMapAsyncStatus status, void(WGPUBufferMapAsyncStatus status,
uint32_t* ptr, uint32_t* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata)); void* userdata));
}; };
static std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback; static std::unique_ptr<MockBufferMapWriteCallback> mockBufferMapWriteCallback;
static void ToMockBufferMapWriteCallback(DawnBufferMapAsyncStatus status, static void ToMockBufferMapWriteCallback(WGPUBufferMapAsyncStatus status,
void* ptr, void* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata) { void* userdata) {
@ -60,37 +60,37 @@ static void ToMockBufferMapWriteCallback(DawnBufferMapAsyncStatus status,
class BufferValidationTest : public ValidationTest { class BufferValidationTest : public ValidationTest {
protected: protected:
dawn::Buffer CreateMapReadBuffer(uint64_t size) { wgpu::Buffer CreateMapReadBuffer(uint64_t size) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = size; descriptor.size = size;
descriptor.usage = dawn::BufferUsage::MapRead; descriptor.usage = wgpu::BufferUsage::MapRead;
return device.CreateBuffer(&descriptor); return device.CreateBuffer(&descriptor);
} }
dawn::Buffer CreateMapWriteBuffer(uint64_t size) { wgpu::Buffer CreateMapWriteBuffer(uint64_t size) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = size; descriptor.size = size;
descriptor.usage = dawn::BufferUsage::MapWrite; descriptor.usage = wgpu::BufferUsage::MapWrite;
return device.CreateBuffer(&descriptor); return device.CreateBuffer(&descriptor);
} }
dawn::Buffer CreateSetSubDataBuffer(uint64_t size) { wgpu::Buffer CreateSetSubDataBuffer(uint64_t size) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = size; descriptor.size = size;
descriptor.usage = dawn::BufferUsage::CopyDst; descriptor.usage = wgpu::BufferUsage::CopyDst;
return device.CreateBuffer(&descriptor); return device.CreateBuffer(&descriptor);
} }
dawn::CreateBufferMappedResult CreateBufferMapped(uint64_t size, dawn::BufferUsage usage) { wgpu::CreateBufferMappedResult CreateBufferMapped(uint64_t size, wgpu::BufferUsage usage) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = size; descriptor.size = size;
descriptor.usage = usage; descriptor.usage = usage;
return device.CreateBufferMapped(&descriptor); return device.CreateBufferMapped(&descriptor);
} }
dawn::Queue queue; wgpu::Queue queue;
private: private:
void SetUp() override { void SetUp() override {
@ -114,9 +114,9 @@ class BufferValidationTest : public ValidationTest {
TEST_F(BufferValidationTest, CreationSuccess) { TEST_F(BufferValidationTest, CreationSuccess) {
// Success // Success
{ {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::Uniform; descriptor.usage = wgpu::BufferUsage::Uniform;
device.CreateBuffer(&descriptor); device.CreateBuffer(&descriptor);
} }
@ -126,36 +126,36 @@ TEST_F(BufferValidationTest, CreationSuccess) {
TEST_F(BufferValidationTest, CreationMapUsageRestrictions) { TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
// MapRead with CopyDst is ok // MapRead with CopyDst is ok
{ {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::CopyDst; descriptor.usage = wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst;
device.CreateBuffer(&descriptor); device.CreateBuffer(&descriptor);
} }
// MapRead with something else is an error // MapRead with something else is an error
{ {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::Uniform; descriptor.usage = wgpu::BufferUsage::MapRead | wgpu::BufferUsage::Uniform;
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
} }
// MapWrite with CopySrc is ok // MapWrite with CopySrc is ok
{ {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc; descriptor.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
device.CreateBuffer(&descriptor); device.CreateBuffer(&descriptor);
} }
// MapWrite with something else is an error // MapWrite with something else is an error
{ {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::Uniform; descriptor.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::Uniform;
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
} }
@ -163,12 +163,12 @@ TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
// Test the success case for mapping buffer for reading // Test the success case for mapping buffer for reading
TEST_F(BufferValidationTest, MapReadSuccess) { TEST_F(BufferValidationTest, MapReadSuccess) {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, _))
.Times(1); .Times(1);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
@ -177,12 +177,12 @@ TEST_F(BufferValidationTest, MapReadSuccess) {
// Test the success case for mapping buffer for writing // Test the success case for mapping buffer for writing
TEST_F(BufferValidationTest, MapWriteSuccess) { TEST_F(BufferValidationTest, MapWriteSuccess) {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, _))
.Times(1); .Times(1);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
@ -191,7 +191,7 @@ TEST_F(BufferValidationTest, MapWriteSuccess) {
// Test the success case for CreateBufferMapped // Test the success case for CreateBufferMapped
TEST_F(BufferValidationTest, CreateBufferMappedSuccess) { TEST_F(BufferValidationTest, CreateBufferMappedSuccess) {
dawn::CreateBufferMappedResult result = CreateBufferMapped(4, dawn::BufferUsage::MapWrite); wgpu::CreateBufferMappedResult result = CreateBufferMapped(4, wgpu::BufferUsage::MapWrite);
ASSERT_NE(result.data, nullptr); ASSERT_NE(result.data, nullptr);
ASSERT_EQ(result.dataLength, 4u); ASSERT_EQ(result.dataLength, 4u);
result.buffer.Unmap(); result.buffer.Unmap();
@ -199,7 +199,7 @@ TEST_F(BufferValidationTest, CreateBufferMappedSuccess) {
// Test the success case for non-mappable CreateBufferMapped // Test the success case for non-mappable CreateBufferMapped
TEST_F(BufferValidationTest, NonMappableCreateBufferMappedSuccess) { TEST_F(BufferValidationTest, NonMappableCreateBufferMappedSuccess) {
dawn::CreateBufferMappedResult result = CreateBufferMapped(4, dawn::BufferUsage::CopySrc); wgpu::CreateBufferMappedResult result = CreateBufferMapped(4, wgpu::BufferUsage::CopySrc);
ASSERT_NE(result.data, nullptr); ASSERT_NE(result.data, nullptr);
ASSERT_EQ(result.dataLength, 4u); ASSERT_EQ(result.dataLength, 4u);
result.buffer.Unmap(); result.buffer.Unmap();
@ -207,14 +207,13 @@ TEST_F(BufferValidationTest, NonMappableCreateBufferMappedSuccess) {
// Test map reading a buffer with wrong current usage // Test map reading a buffer with wrong current usage
TEST_F(BufferValidationTest, MapReadWrongUsage) { TEST_F(BufferValidationTest, MapReadWrongUsage) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::CopyDst; descriptor.usage = wgpu::BufferUsage::CopyDst;
dawn::Buffer buf = device.CreateBuffer(&descriptor); wgpu::Buffer buf = device.CreateBuffer(&descriptor);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0u, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, _))
.Times(1); .Times(1);
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr)); ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
@ -222,14 +221,13 @@ TEST_F(BufferValidationTest, MapReadWrongUsage) {
// Test map writing a buffer with wrong current usage // Test map writing a buffer with wrong current usage
TEST_F(BufferValidationTest, MapWriteWrongUsage) { TEST_F(BufferValidationTest, MapWriteWrongUsage) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::CopySrc; descriptor.usage = wgpu::BufferUsage::CopySrc;
dawn::Buffer buf = device.CreateBuffer(&descriptor); wgpu::Buffer buf = device.CreateBuffer(&descriptor);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0u, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, _))
.Times(1); .Times(1);
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr)); ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
@ -237,15 +235,15 @@ TEST_F(BufferValidationTest, MapWriteWrongUsage) {
// Test map reading a buffer that is already mapped // Test map reading a buffer that is already mapped
TEST_F(BufferValidationTest, MapReadAlreadyMapped) { TEST_F(BufferValidationTest, MapReadAlreadyMapped) {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0); buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, this + 0)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, this + 0))
.Times(1); .Times(1);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, this + 1)) Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0u, this + 1))
.Times(1); .Times(1);
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, this + 1)); ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, this + 1));
@ -254,15 +252,15 @@ TEST_F(BufferValidationTest, MapReadAlreadyMapped) {
// Test map writing a buffer that is already mapped // Test map writing a buffer that is already mapped
TEST_F(BufferValidationTest, MapWriteAlreadyMapped) { TEST_F(BufferValidationTest, MapWriteAlreadyMapped) {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 0); buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 0);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, this + 0)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, this + 0))
.Times(1); .Times(1);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0u, this + 1)) Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0u, this + 1))
.Times(1); .Times(1);
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1)); ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1));
@ -272,12 +270,11 @@ TEST_F(BufferValidationTest, MapWriteAlreadyMapped) {
// Test unmapping before having the result gives UNKNOWN - for reading // Test unmapping before having the result gives UNKNOWN - for reading
TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) { TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, _))
.Times(1); .Times(1);
buf.Unmap(); buf.Unmap();
@ -288,12 +285,11 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) {
// Test unmapping before having the result gives UNKNOWN - for writing // Test unmapping before having the result gives UNKNOWN - for writing
TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) { TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, _))
.Times(1); .Times(1);
buf.Unmap(); buf.Unmap();
@ -307,12 +303,12 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) {
// when its external ref count reaches 0. // when its external ref count reaches 0.
TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) { TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, _)) Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u, _))
.Times(1); .Times(1);
} }
@ -326,12 +322,12 @@ TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) {
// when its external ref count reaches 0. // when its external ref count reaches 0.
TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) { TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) {
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, _)) Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u, _))
.Times(1); .Times(1);
} }
@ -343,19 +339,19 @@ TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) {
// When a MapRead is cancelled with Unmap it might still be in flight, test doing a new request // When a MapRead is cancelled with Unmap it might still be in flight, test doing a new request
// works as expected and we don't get the cancelled request's data. // works as expected and we don't get the cancelled request's data.
TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) { TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0); buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, this + 0)) Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u, this + 0))
.Times(1); .Times(1);
buf.Unmap(); buf.Unmap();
buf.MapReadAsync(ToMockBufferMapReadCallback, this + 1); buf.MapReadAsync(ToMockBufferMapReadCallback, this + 1);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, this + 1)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, this + 1))
.Times(1); .Times(1);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
@ -364,31 +360,31 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
// When a MapWrite is cancelled with Unmap it might still be in flight, test doing a new request // When a MapWrite is cancelled with Unmap it might still be in flight, test doing a new request
// works as expected and we don't get the cancelled request's data. // works as expected and we don't get the cancelled request's data.
TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) { TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 0); buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 0);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0u, this + 0)) Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0u, this + 0))
.Times(1); .Times(1);
buf.Unmap(); buf.Unmap();
buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1); buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, this + 1)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, this + 1))
.Times(1); .Times(1);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
// Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback // Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback
TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) { TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, _))
.WillOnce(InvokeWithoutArgs([&]() { buf.Unmap(); })); .WillOnce(InvokeWithoutArgs([&]() { buf.Unmap(); }));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
@ -396,12 +392,12 @@ TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) {
// Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback // Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback
TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) { TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, _))
.WillOnce(InvokeWithoutArgs([&]() { buf.Unmap(); })); .WillOnce(InvokeWithoutArgs([&]() { buf.Unmap(); }));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
@ -409,33 +405,33 @@ TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
// Test that the MapReadCallback isn't fired twice the buffer external refcount reaches 0 in the callback // Test that the MapReadCallback isn't fired twice the buffer external refcount reaches 0 in the callback
TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) { TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, _))
.WillOnce(InvokeWithoutArgs([&]() { buf = dawn::Buffer(); })); .WillOnce(InvokeWithoutArgs([&]() { buf = wgpu::Buffer(); }));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
// Test that the MapWriteCallback isn't fired twice the buffer external refcount reaches 0 in the callback // Test that the MapWriteCallback isn't fired twice the buffer external refcount reaches 0 in the callback
TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) { TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), 4u, _)) Call(WGPUBufferMapAsyncStatus_Success, Ne(nullptr), 4u, _))
.WillOnce(InvokeWithoutArgs([&]() { buf = dawn::Buffer(); })); .WillOnce(InvokeWithoutArgs([&]() { buf = wgpu::Buffer(); }));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
// Test the success case for Buffer::SetSubData // Test the success case for Buffer::SetSubData
TEST_F(BufferValidationTest, SetSubDataSuccess) { TEST_F(BufferValidationTest, SetSubDataSuccess) {
dawn::Buffer buf = CreateSetSubDataBuffer(4); wgpu::Buffer buf = CreateSetSubDataBuffer(4);
uint32_t foo = 0x01020304; uint32_t foo = 0x01020304;
buf.SetSubData(0, sizeof(foo), &foo); buf.SetSubData(0, sizeof(foo), &foo);
@ -443,7 +439,7 @@ TEST_F(BufferValidationTest, SetSubDataSuccess) {
// Test error case for SetSubData out of bounds // Test error case for SetSubData out of bounds
TEST_F(BufferValidationTest, SetSubDataOutOfBounds) { TEST_F(BufferValidationTest, SetSubDataOutOfBounds) {
dawn::Buffer buf = CreateSetSubDataBuffer(1); wgpu::Buffer buf = CreateSetSubDataBuffer(1);
uint8_t foo[2] = {0, 0}; uint8_t foo[2] = {0, 0};
ASSERT_DEVICE_ERROR(buf.SetSubData(0, 2, foo)); ASSERT_DEVICE_ERROR(buf.SetSubData(0, 2, foo));
@ -451,7 +447,7 @@ TEST_F(BufferValidationTest, SetSubDataOutOfBounds) {
// Test error case for SetSubData out of bounds with an overflow // Test error case for SetSubData out of bounds with an overflow
TEST_F(BufferValidationTest, SetSubDataOutOfBoundsOverflow) { TEST_F(BufferValidationTest, SetSubDataOutOfBoundsOverflow) {
dawn::Buffer buf = CreateSetSubDataBuffer(1000); wgpu::Buffer buf = CreateSetSubDataBuffer(1000);
uint8_t foo[2] = {0, 0}; uint8_t foo[2] = {0, 0};
@ -464,11 +460,11 @@ TEST_F(BufferValidationTest, SetSubDataOutOfBoundsOverflow) {
// Test error case for SetSubData with the wrong usage // Test error case for SetSubData with the wrong usage
TEST_F(BufferValidationTest, SetSubDataWrongUsage) { TEST_F(BufferValidationTest, SetSubDataWrongUsage) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::Vertex; descriptor.usage = wgpu::BufferUsage::Vertex;
dawn::Buffer buf = device.CreateBuffer(&descriptor); wgpu::Buffer buf = device.CreateBuffer(&descriptor);
uint8_t foo = 0; uint8_t foo = 0;
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo)); ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
@ -476,11 +472,11 @@ TEST_F(BufferValidationTest, SetSubDataWrongUsage) {
// Test SetSubData with unaligned size // Test SetSubData with unaligned size
TEST_F(BufferValidationTest, SetSubDataWithUnalignedSize) { TEST_F(BufferValidationTest, SetSubDataWithUnalignedSize) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst; descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
dawn::Buffer buf = device.CreateBuffer(&descriptor); wgpu::Buffer buf = device.CreateBuffer(&descriptor);
uint8_t value = 123; uint8_t value = 123;
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(value), &value)); ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(value), &value));
@ -488,11 +484,11 @@ TEST_F(BufferValidationTest, SetSubDataWithUnalignedSize) {
// Test SetSubData with unaligned offset // Test SetSubData with unaligned offset
TEST_F(BufferValidationTest, SetSubDataWithUnalignedOffset) { TEST_F(BufferValidationTest, SetSubDataWithUnalignedOffset) {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4000; descriptor.size = 4000;
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst; descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
dawn::Buffer buf = device.CreateBuffer(&descriptor); wgpu::Buffer buf = device.CreateBuffer(&descriptor);
uint64_t kOffset = 2999; uint64_t kOffset = 2999;
uint32_t value = 0x01020304; uint32_t value = 0x01020304;
@ -502,11 +498,11 @@ TEST_F(BufferValidationTest, SetSubDataWithUnalignedOffset) {
// Test that it is valid to destroy an unmapped buffer // Test that it is valid to destroy an unmapped buffer
TEST_F(BufferValidationTest, DestroyUnmappedBuffer) { TEST_F(BufferValidationTest, DestroyUnmappedBuffer) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.Destroy(); buf.Destroy();
} }
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.Destroy(); buf.Destroy();
} }
} }
@ -514,12 +510,12 @@ TEST_F(BufferValidationTest, DestroyUnmappedBuffer) {
// Test that it is valid to destroy a mapped buffer // Test that it is valid to destroy a mapped buffer
TEST_F(BufferValidationTest, DestroyMappedBuffer) { TEST_F(BufferValidationTest, DestroyMappedBuffer) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
buf.Destroy(); buf.Destroy();
} }
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
buf.Destroy(); buf.Destroy();
} }
@ -528,21 +524,21 @@ TEST_F(BufferValidationTest, DestroyMappedBuffer) {
// Test that destroying a buffer implicitly unmaps it // Test that destroying a buffer implicitly unmaps it
TEST_F(BufferValidationTest, DestroyMappedBufferCausesImplicitUnmap) { TEST_F(BufferValidationTest, DestroyMappedBufferCausesImplicitUnmap) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0); buf.MapReadAsync(ToMockBufferMapReadCallback, this + 0);
// Buffer is destroyed. Callback should be called with UNKNOWN status // Buffer is destroyed. Callback should be called with UNKNOWN status
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, this + 0)) Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, this + 0))
.Times(1); .Times(1);
buf.Destroy(); buf.Destroy();
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1); buf.MapWriteAsync(ToMockBufferMapWriteCallback, this + 1);
// Buffer is destroyed. Callback should be called with UNKNOWN status // Buffer is destroyed. Callback should be called with UNKNOWN status
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, this + 1)) Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, this + 1))
.Times(1); .Times(1);
buf.Destroy(); buf.Destroy();
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
@ -551,7 +547,7 @@ TEST_F(BufferValidationTest, DestroyMappedBufferCausesImplicitUnmap) {
// Test that it is valid to Destroy a destroyed buffer // Test that it is valid to Destroy a destroyed buffer
TEST_F(BufferValidationTest, DestroyDestroyedBuffer) { TEST_F(BufferValidationTest, DestroyDestroyedBuffer) {
dawn::Buffer buf = CreateSetSubDataBuffer(4); wgpu::Buffer buf = CreateSetSubDataBuffer(4);
buf.Destroy(); buf.Destroy();
buf.Destroy(); buf.Destroy();
} }
@ -559,12 +555,12 @@ TEST_F(BufferValidationTest, DestroyDestroyedBuffer) {
// Test that it is invalid to Unmap a destroyed buffer // Test that it is invalid to Unmap a destroyed buffer
TEST_F(BufferValidationTest, UnmapDestroyedBuffer) { TEST_F(BufferValidationTest, UnmapDestroyedBuffer) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.Destroy(); buf.Destroy();
ASSERT_DEVICE_ERROR(buf.Unmap()); ASSERT_DEVICE_ERROR(buf.Unmap());
} }
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.Destroy(); buf.Destroy();
ASSERT_DEVICE_ERROR(buf.Unmap()); ASSERT_DEVICE_ERROR(buf.Unmap());
} }
@ -573,12 +569,12 @@ TEST_F(BufferValidationTest, UnmapDestroyedBuffer) {
// Test that it is invalid to map a destroyed buffer // Test that it is invalid to map a destroyed buffer
TEST_F(BufferValidationTest, MapDestroyedBuffer) { TEST_F(BufferValidationTest, MapDestroyedBuffer) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.Destroy(); buf.Destroy();
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr)); ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
} }
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.Destroy(); buf.Destroy();
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr)); ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
} }
@ -586,7 +582,7 @@ TEST_F(BufferValidationTest, MapDestroyedBuffer) {
// Test that it is invalid to call SetSubData on a destroyed buffer // Test that it is invalid to call SetSubData on a destroyed buffer
TEST_F(BufferValidationTest, SetSubDataDestroyedBuffer) { TEST_F(BufferValidationTest, SetSubDataDestroyedBuffer) {
dawn::Buffer buf = CreateSetSubDataBuffer(4); wgpu::Buffer buf = CreateSetSubDataBuffer(4);
buf.Destroy(); buf.Destroy();
uint8_t foo = 0; uint8_t foo = 0;
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo)); ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
@ -595,13 +591,13 @@ TEST_F(BufferValidationTest, SetSubDataDestroyedBuffer) {
// Test that is is invalid to Map a mapped buffer // Test that is is invalid to Map a mapped buffer
TEST_F(BufferValidationTest, MapMappedBuffer) { TEST_F(BufferValidationTest, MapMappedBuffer) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr)); ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr)); ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
@ -611,12 +607,12 @@ TEST_F(BufferValidationTest, MapMappedBuffer) {
// Test that is is invalid to Map a CreateBufferMapped buffer // Test that is is invalid to Map a CreateBufferMapped buffer
TEST_F(BufferValidationTest, MapCreateBufferMappedBuffer) { TEST_F(BufferValidationTest, MapCreateBufferMappedBuffer) {
{ {
dawn::Buffer buf = CreateBufferMapped(4, dawn::BufferUsage::MapRead).buffer; wgpu::Buffer buf = CreateBufferMapped(4, wgpu::BufferUsage::MapRead).buffer;
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr)); ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
{ {
dawn::Buffer buf = CreateBufferMapped(4, dawn::BufferUsage::MapWrite).buffer; wgpu::Buffer buf = CreateBufferMapped(4, wgpu::BufferUsage::MapWrite).buffer;
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr)); ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
@ -625,14 +621,14 @@ TEST_F(BufferValidationTest, MapCreateBufferMappedBuffer) {
// Test that it is invalid to call SetSubData on a mapped buffer // Test that it is invalid to call SetSubData on a mapped buffer
TEST_F(BufferValidationTest, SetSubDataMappedBuffer) { TEST_F(BufferValidationTest, SetSubDataMappedBuffer) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
uint8_t foo = 0; uint8_t foo = 0;
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo)); ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
uint8_t foo = 0; uint8_t foo = 0;
ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo)); ASSERT_DEVICE_ERROR(buf.SetSubData(0, sizeof(foo), &foo));
@ -642,73 +638,73 @@ TEST_F(BufferValidationTest, SetSubDataMappedBuffer) {
// Test that it is valid to submit a buffer in a queue with a map usage if it is unmapped // Test that it is valid to submit a buffer in a queue with a map usage if it is unmapped
TEST_F(BufferValidationTest, SubmitBufferWithMapUsage) { TEST_F(BufferValidationTest, SubmitBufferWithMapUsage) {
dawn::BufferDescriptor descriptorA; wgpu::BufferDescriptor descriptorA;
descriptorA.size = 4; descriptorA.size = 4;
descriptorA.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::MapWrite; descriptorA.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::MapWrite;
dawn::BufferDescriptor descriptorB; wgpu::BufferDescriptor descriptorB;
descriptorB.size = 4; descriptorB.size = 4;
descriptorB.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::MapRead; descriptorB.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::MapRead;
dawn::Buffer bufA = device.CreateBuffer(&descriptorA); wgpu::Buffer bufA = device.CreateBuffer(&descriptorA);
dawn::Buffer bufB = device.CreateBuffer(&descriptorB); wgpu::Buffer bufB = device.CreateBuffer(&descriptorB);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4); encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
dawn::CommandBuffer commands = encoder.Finish(); wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands); queue.Submit(1, &commands);
} }
// Test that it is invalid to submit a mapped buffer in a queue // Test that it is invalid to submit a mapped buffer in a queue
TEST_F(BufferValidationTest, SubmitMappedBuffer) { TEST_F(BufferValidationTest, SubmitMappedBuffer) {
dawn::BufferDescriptor descriptorA; wgpu::BufferDescriptor descriptorA;
descriptorA.size = 4; descriptorA.size = 4;
descriptorA.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::MapWrite; descriptorA.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::MapWrite;
dawn::BufferDescriptor descriptorB; wgpu::BufferDescriptor descriptorB;
descriptorB.size = 4; descriptorB.size = 4;
descriptorB.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::MapRead; descriptorB.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::MapRead;
{ {
dawn::Buffer bufA = device.CreateBuffer(&descriptorA); wgpu::Buffer bufA = device.CreateBuffer(&descriptorA);
dawn::Buffer bufB = device.CreateBuffer(&descriptorB); wgpu::Buffer bufB = device.CreateBuffer(&descriptorB);
bufA.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); bufA.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4); encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
dawn::CommandBuffer commands = encoder.Finish(); wgpu::CommandBuffer commands = encoder.Finish();
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands)); ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
{ {
dawn::Buffer bufA = device.CreateBuffer(&descriptorA); wgpu::Buffer bufA = device.CreateBuffer(&descriptorA);
dawn::Buffer bufB = device.CreateBuffer(&descriptorB); wgpu::Buffer bufB = device.CreateBuffer(&descriptorB);
bufB.MapReadAsync(ToMockBufferMapReadCallback, nullptr); bufB.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4); encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
dawn::CommandBuffer commands = encoder.Finish(); wgpu::CommandBuffer commands = encoder.Finish();
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands)); ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
{ {
dawn::Buffer bufA = device.CreateBufferMapped(&descriptorA).buffer; wgpu::Buffer bufA = device.CreateBufferMapped(&descriptorA).buffer;
dawn::Buffer bufB = device.CreateBuffer(&descriptorB); wgpu::Buffer bufB = device.CreateBuffer(&descriptorB);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4); encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
dawn::CommandBuffer commands = encoder.Finish(); wgpu::CommandBuffer commands = encoder.Finish();
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands)); ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
{ {
dawn::Buffer bufA = device.CreateBuffer(&descriptorA); wgpu::Buffer bufA = device.CreateBuffer(&descriptorA);
dawn::Buffer bufB = device.CreateBufferMapped(&descriptorB).buffer; wgpu::Buffer bufB = device.CreateBufferMapped(&descriptorB).buffer;
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4); encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
dawn::CommandBuffer commands = encoder.Finish(); wgpu::CommandBuffer commands = encoder.Finish();
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands)); ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} }
@ -716,34 +712,34 @@ TEST_F(BufferValidationTest, SubmitMappedBuffer) {
// Test that it is invalid to submit a destroyed buffer in a queue // Test that it is invalid to submit a destroyed buffer in a queue
TEST_F(BufferValidationTest, SubmitDestroyedBuffer) { TEST_F(BufferValidationTest, SubmitDestroyedBuffer) {
dawn::BufferDescriptor descriptorA; wgpu::BufferDescriptor descriptorA;
descriptorA.size = 4; descriptorA.size = 4;
descriptorA.usage = dawn::BufferUsage::CopySrc; descriptorA.usage = wgpu::BufferUsage::CopySrc;
dawn::BufferDescriptor descriptorB; wgpu::BufferDescriptor descriptorB;
descriptorB.size = 4; descriptorB.size = 4;
descriptorB.usage = dawn::BufferUsage::CopyDst; descriptorB.usage = wgpu::BufferUsage::CopyDst;
dawn::Buffer bufA = device.CreateBuffer(&descriptorA); wgpu::Buffer bufA = device.CreateBuffer(&descriptorA);
dawn::Buffer bufB = device.CreateBuffer(&descriptorB); wgpu::Buffer bufB = device.CreateBuffer(&descriptorB);
bufA.Destroy(); bufA.Destroy();
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4); encoder.CopyBufferToBuffer(bufA, 0, bufB, 0, 4);
dawn::CommandBuffer commands = encoder.Finish(); wgpu::CommandBuffer commands = encoder.Finish();
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands)); ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
} }
// Test that a map usage is required to call Unmap // Test that a map usage is required to call Unmap
TEST_F(BufferValidationTest, UnmapWithoutMapUsage) { TEST_F(BufferValidationTest, UnmapWithoutMapUsage) {
dawn::Buffer buf = CreateSetSubDataBuffer(4); wgpu::Buffer buf = CreateSetSubDataBuffer(4);
ASSERT_DEVICE_ERROR(buf.Unmap()); ASSERT_DEVICE_ERROR(buf.Unmap());
} }
// Test that it is valid to call Unmap on a buffer that is not mapped // Test that it is valid to call Unmap on a buffer that is not mapped
TEST_F(BufferValidationTest, UnmapUnmappedBuffer) { TEST_F(BufferValidationTest, UnmapUnmappedBuffer) {
{ {
dawn::Buffer buf = CreateMapReadBuffer(4); wgpu::Buffer buf = CreateMapReadBuffer(4);
// Buffer starts unmapped. Unmap should succeed. // Buffer starts unmapped. Unmap should succeed.
buf.Unmap(); buf.Unmap();
buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr); buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr);
@ -752,7 +748,7 @@ TEST_F(BufferValidationTest, UnmapUnmappedBuffer) {
buf.Unmap(); buf.Unmap();
} }
{ {
dawn::Buffer buf = CreateMapWriteBuffer(4); wgpu::Buffer buf = CreateMapWriteBuffer(4);
// Buffer starts unmapped. Unmap should succeed. // Buffer starts unmapped. Unmap should succeed.
buf.Unmap(); buf.Unmap();
buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr); buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr);

View File

@ -30,24 +30,24 @@ TEST_F(CommandBufferValidationTest, EndedMidRenderPass) {
// Control case, command buffer ended after the pass is ended. // Control case, command buffer ended after the pass is ended.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.EndPass(); pass.EndPass();
encoder.Finish(); encoder.Finish();
} }
// Error case, command buffer ended mid-pass. // Error case, command buffer ended mid-pass.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
} }
// Error case, command buffer ended mid-pass. Trying to use encoders after Finish // Error case, command buffer ended mid-pass. Trying to use encoders after Finish
// should fail too. // should fail too.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
ASSERT_DEVICE_ERROR(pass.EndPass()); ASSERT_DEVICE_ERROR(pass.EndPass());
} }
@ -57,24 +57,24 @@ TEST_F(CommandBufferValidationTest, EndedMidRenderPass) {
TEST_F(CommandBufferValidationTest, EndedMidComputePass) { TEST_F(CommandBufferValidationTest, EndedMidComputePass) {
// Control case, command buffer ended after the pass is ended. // Control case, command buffer ended after the pass is ended.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.EndPass(); pass.EndPass();
encoder.Finish(); encoder.Finish();
} }
// Error case, command buffer ended mid-pass. // Error case, command buffer ended mid-pass.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
} }
// Error case, command buffer ended mid-pass. Trying to use encoders after Finish // Error case, command buffer ended mid-pass. Trying to use encoders after Finish
// should fail too. // should fail too.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
ASSERT_DEVICE_ERROR(pass.EndPass()); ASSERT_DEVICE_ERROR(pass.EndPass());
} }
@ -86,16 +86,16 @@ TEST_F(CommandBufferValidationTest, RenderPassEndedTwice) {
// Control case, pass is ended once // Control case, pass is ended once
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.EndPass(); pass.EndPass();
encoder.Finish(); encoder.Finish();
} }
// Error case, pass ended twice // Error case, pass ended twice
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.EndPass(); pass.EndPass();
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -106,16 +106,16 @@ TEST_F(CommandBufferValidationTest, RenderPassEndedTwice) {
TEST_F(CommandBufferValidationTest, ComputePassEndedTwice) { TEST_F(CommandBufferValidationTest, ComputePassEndedTwice) {
// Control case, pass is ended once. // Control case, pass is ended once.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.EndPass(); pass.EndPass();
encoder.Finish(); encoder.Finish();
} }
// Error case, pass ended twice // Error case, pass ended twice
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.EndPass(); pass.EndPass();
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -128,9 +128,9 @@ TEST_F(CommandBufferValidationTest, BeginComputePassBeforeEndPreviousPass) {
// Beginning a compute pass before ending a render pass causes an error. // Beginning a compute pass before ending a render pass causes an error.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = encoder.BeginRenderPass(&dummyRenderPass); wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&dummyRenderPass);
dawn::ComputePassEncoder computePass = encoder.BeginComputePass(); wgpu::ComputePassEncoder computePass = encoder.BeginComputePass();
computePass.EndPass(); computePass.EndPass();
renderPass.EndPass(); renderPass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -138,9 +138,9 @@ TEST_F(CommandBufferValidationTest, BeginComputePassBeforeEndPreviousPass) {
// Beginning a compute pass before ending a compute pass causes an error. // Beginning a compute pass before ending a compute pass causes an error.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder computePass1 = encoder.BeginComputePass(); wgpu::ComputePassEncoder computePass1 = encoder.BeginComputePass();
dawn::ComputePassEncoder computePass2 = encoder.BeginComputePass(); wgpu::ComputePassEncoder computePass2 = encoder.BeginComputePass();
computePass2.EndPass(); computePass2.EndPass();
computePass1.EndPass(); computePass1.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -150,12 +150,12 @@ TEST_F(CommandBufferValidationTest, BeginComputePassBeforeEndPreviousPass) {
// Test that encoding command after a successful finish produces an error // Test that encoding command after a successful finish produces an error
TEST_F(CommandBufferValidationTest, CallsAfterASuccessfulFinish) { TEST_F(CommandBufferValidationTest, CallsAfterASuccessfulFinish) {
// A buffer that can be used in CopyBufferToBuffer // A buffer that can be used in CopyBufferToBuffer
dawn::BufferDescriptor copyBufferDesc; wgpu::BufferDescriptor copyBufferDesc;
copyBufferDesc.size = 16; copyBufferDesc.size = 16;
copyBufferDesc.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst; copyBufferDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
dawn::Buffer copyBuffer = device.CreateBuffer(&copyBufferDesc); wgpu::Buffer copyBuffer = device.CreateBuffer(&copyBufferDesc);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.Finish(); encoder.Finish();
ASSERT_DEVICE_ERROR(encoder.CopyBufferToBuffer(copyBuffer, 0, copyBuffer, 0, 0)); ASSERT_DEVICE_ERROR(encoder.CopyBufferToBuffer(copyBuffer, 0, copyBuffer, 0, 0));
@ -164,18 +164,18 @@ TEST_F(CommandBufferValidationTest, CallsAfterASuccessfulFinish) {
// Test that encoding command after a failed finish produces an error // Test that encoding command after a failed finish produces an error
TEST_F(CommandBufferValidationTest, CallsAfterAFailedFinish) { TEST_F(CommandBufferValidationTest, CallsAfterAFailedFinish) {
// A buffer that can be used in CopyBufferToBuffer // A buffer that can be used in CopyBufferToBuffer
dawn::BufferDescriptor copyBufferDesc; wgpu::BufferDescriptor copyBufferDesc;
copyBufferDesc.size = 16; copyBufferDesc.size = 16;
copyBufferDesc.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst; copyBufferDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
dawn::Buffer copyBuffer = device.CreateBuffer(&copyBufferDesc); wgpu::Buffer copyBuffer = device.CreateBuffer(&copyBufferDesc);
// A buffer that can't be used in CopyBufferToBuffer // A buffer that can't be used in CopyBufferToBuffer
dawn::BufferDescriptor bufferDesc; wgpu::BufferDescriptor bufferDesc;
bufferDesc.size = 16; bufferDesc.size = 16;
bufferDesc.usage = dawn::BufferUsage::Uniform; bufferDesc.usage = wgpu::BufferUsage::Uniform;
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc); wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(buffer, 0, buffer, 0, 0); encoder.CopyBufferToBuffer(buffer, 0, buffer, 0, 0);
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -185,15 +185,15 @@ TEST_F(CommandBufferValidationTest, CallsAfterAFailedFinish) {
// Test that using a single buffer in multiple read usages in the same pass is allowed. // Test that using a single buffer in multiple read usages in the same pass is allowed.
TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) { TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
// Create a buffer used as both vertex and index buffer. // Create a buffer used as both vertex and index buffer.
dawn::BufferDescriptor bufferDescriptor; wgpu::BufferDescriptor bufferDescriptor;
bufferDescriptor.usage = dawn::BufferUsage::Vertex | dawn::BufferUsage::Index; bufferDescriptor.usage = wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Index;
bufferDescriptor.size = 4; bufferDescriptor.size = 4;
dawn::Buffer buffer = device.CreateBuffer(&bufferDescriptor); wgpu::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
// Use the buffer as both index and vertex in the same pass // Use the buffer as both index and vertex in the same pass
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
DummyRenderPass dummyRenderPass(device); DummyRenderPass dummyRenderPass(device);
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBuffer(buffer); pass.SetIndexBuffer(buffer);
pass.SetVertexBuffer(0, buffer); pass.SetVertexBuffer(0, buffer);
pass.EndPass(); pass.EndPass();
@ -203,20 +203,20 @@ TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
// Test that using the same buffer as both readable and writable in the same pass is disallowed // Test that using the same buffer as both readable and writable in the same pass is disallowed
TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) { TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) {
// Create a buffer that will be used as an index buffer and as a storage buffer // Create a buffer that will be used as an index buffer and as a storage buffer
dawn::BufferDescriptor bufferDescriptor; wgpu::BufferDescriptor bufferDescriptor;
bufferDescriptor.usage = dawn::BufferUsage::Storage | dawn::BufferUsage::Index; bufferDescriptor.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index;
bufferDescriptor.size = 4; bufferDescriptor.size = 4;
dawn::Buffer buffer = device.CreateBuffer(&bufferDescriptor); wgpu::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
// Create the bind group to use the buffer as storage // Create the bind group to use the buffer as storage
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Vertex, dawn::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::StorageBuffer}});
dawn::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}});
// Use the buffer as both index and storage in the same pass // Use the buffer as both index and storage in the same pass
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
DummyRenderPass dummyRenderPass(device); DummyRenderPass dummyRenderPass(device);
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
pass.SetIndexBuffer(buffer); pass.SetIndexBuffer(buffer);
pass.SetBindGroup(0, bg); pass.SetBindGroup(0, bg);
pass.EndPass(); pass.EndPass();
@ -226,28 +226,28 @@ TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) {
// Test that using the same texture as both readable and writable in the same pass is disallowed // Test that using the same texture as both readable and writable in the same pass is disallowed
TEST_F(CommandBufferValidationTest, TextureWithReadAndWriteUsage) { TEST_F(CommandBufferValidationTest, TextureWithReadAndWriteUsage) {
// Create a texture that will be used both as a sampled texture and a render target // Create a texture that will be used both as a sampled texture and a render target
dawn::TextureDescriptor textureDescriptor; wgpu::TextureDescriptor textureDescriptor;
textureDescriptor.usage = dawn::TextureUsage::Sampled | dawn::TextureUsage::OutputAttachment; textureDescriptor.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::OutputAttachment;
textureDescriptor.format = dawn::TextureFormat::RGBA8Unorm; textureDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
textureDescriptor.dimension = dawn::TextureDimension::e2D; textureDescriptor.dimension = wgpu::TextureDimension::e2D;
textureDescriptor.size = {1, 1, 1}; textureDescriptor.size = {1, 1, 1};
textureDescriptor.arrayLayerCount = 1; textureDescriptor.arrayLayerCount = 1;
textureDescriptor.sampleCount = 1; textureDescriptor.sampleCount = 1;
textureDescriptor.mipLevelCount = 1; textureDescriptor.mipLevelCount = 1;
dawn::Texture texture = device.CreateTexture(&textureDescriptor); wgpu::Texture texture = device.CreateTexture(&textureDescriptor);
dawn::TextureView view = texture.CreateView(); wgpu::TextureView view = texture.CreateView();
// Create the bind group to use the texture as sampled // Create the bind group to use the texture as sampled
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Vertex, dawn::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::SampledTexture}});
dawn::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}});
// Create the render pass that will use the texture as an output attachment // Create the render pass that will use the texture as an output attachment
utils::ComboRenderPassDescriptor renderPass({view}); utils::ComboRenderPassDescriptor renderPass({view});
// Use the texture as both sampeld and output attachment in the same pass // Use the texture as both sampeld and output attachment in the same pass
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetBindGroup(0, bg); pass.SetBindGroup(0, bg);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());

View File

@ -22,7 +22,7 @@ class ComputeIndirectValidationTest : public ValidationTest {
void SetUp() override { void SetUp() override {
ValidationTest::SetUp(); ValidationTest::SetUp();
dawn::ShaderModule computeModule = wgpu::ShaderModule computeModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
#version 450 #version 450
layout(local_size_x = 1) in; layout(local_size_x = 1) in;
@ -30,16 +30,16 @@ class ComputeIndirectValidationTest : public ValidationTest {
})"); })");
// Set up compute pipeline // Set up compute pipeline
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr); wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr);
dawn::ComputePipelineDescriptor csDesc; wgpu::ComputePipelineDescriptor csDesc;
csDesc.layout = pl; csDesc.layout = pl;
csDesc.computeStage.module = computeModule; csDesc.computeStage.module = computeModule;
csDesc.computeStage.entryPoint = "main"; csDesc.computeStage.entryPoint = "main";
pipeline = device.CreateComputePipeline(&csDesc); pipeline = device.CreateComputePipeline(&csDesc);
} }
void ValidateExpectation(dawn::CommandEncoder encoder, utils::Expectation expectation) { void ValidateExpectation(wgpu::CommandEncoder encoder, utils::Expectation expectation) {
if (expectation == utils::Expectation::Success) { if (expectation == utils::Expectation::Success) {
encoder.Finish(); encoder.Finish();
} else { } else {
@ -50,11 +50,11 @@ class ComputeIndirectValidationTest : public ValidationTest {
void TestIndirectOffset(utils::Expectation expectation, void TestIndirectOffset(utils::Expectation expectation,
std::initializer_list<uint32_t> bufferList, std::initializer_list<uint32_t> bufferList,
uint64_t indirectOffset) { uint64_t indirectOffset) {
dawn::Buffer indirectBuffer = wgpu::Buffer indirectBuffer =
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList); utils::CreateBufferFromData<uint32_t>(device, wgpu::BufferUsage::Indirect, bufferList);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.DispatchIndirect(indirectBuffer, indirectOffset); pass.DispatchIndirect(indirectBuffer, indirectOffset);
pass.EndPass(); pass.EndPass();
@ -62,7 +62,7 @@ class ComputeIndirectValidationTest : public ValidationTest {
ValidateExpectation(encoder, expectation); ValidateExpectation(encoder, expectation);
} }
dawn::ComputePipeline pipeline; wgpu::ComputePipeline pipeline;
}; };
// Verify out of bounds indirect dispatch calls are caught early // Verify out of bounds indirect dispatch calls are caught early

View File

@ -20,12 +20,12 @@ class ComputePassValidationTest : public ValidationTest {};
// Test that it is invalid to use a buffer with both read and write usages in a compute pass. // Test that it is invalid to use a buffer with both read and write usages in a compute pass.
TEST_F(ComputePassValidationTest, ReadWriteUsage) { TEST_F(ComputePassValidationTest, ReadWriteUsage) {
dawn::BufferDescriptor bufferDesc = {}; wgpu::BufferDescriptor bufferDesc = {};
bufferDesc.usage = dawn::BufferUsage::Storage | dawn::BufferUsage::Uniform; bufferDesc.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform;
bufferDesc.size = 4; bufferDesc.size = 4;
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc); wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
dawn::ShaderModule module = wgpu::ShaderModule module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
#version 450 #version 450
layout(std430, set = 0, binding = 0) buffer BufA { uint bufA; }; layout(std430, set = 0, binding = 0) buffer BufA { uint bufA; };
@ -33,26 +33,26 @@ TEST_F(ComputePassValidationTest, ReadWriteUsage) {
void main() {} void main() {}
)"); )");
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Compute, dawn::BindingType::StorageBuffer}, device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer},
{1, dawn::ShaderStage::Compute, dawn::BindingType::UniformBuffer}}); {1, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer}});
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl,
{ {
{0, buffer, 0, 4}, {0, buffer, 0, 4},
{1, buffer, 0, 4}, {1, buffer, 0, 4},
}); });
dawn::PipelineLayout layout = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout layout = utils::MakeBasicPipelineLayout(device, &bgl);
dawn::ComputePipelineDescriptor pipelineDesc = {}; wgpu::ComputePipelineDescriptor pipelineDesc = {};
pipelineDesc.layout = layout; pipelineDesc.layout = layout;
pipelineDesc.computeStage.module = module; pipelineDesc.computeStage.module = module;
pipelineDesc.computeStage.entryPoint = "main"; pipelineDesc.computeStage.entryPoint = "main";
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc); wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bindGroup); pass.SetBindGroup(0, bindGroup);
@ -65,33 +65,33 @@ TEST_F(ComputePassValidationTest, ReadWriteUsage) {
// Test that it is valid to use a buffer with a single write usage multiple times in a compute pass. // Test that it is valid to use a buffer with a single write usage multiple times in a compute pass.
TEST_F(ComputePassValidationTest, MultipleWrites) { TEST_F(ComputePassValidationTest, MultipleWrites) {
dawn::BufferDescriptor bufferDesc = {}; wgpu::BufferDescriptor bufferDesc = {};
bufferDesc.usage = dawn::BufferUsage::Storage; bufferDesc.usage = wgpu::BufferUsage::Storage;
bufferDesc.size = 4; bufferDesc.size = 4;
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc); wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
dawn::ShaderModule module = wgpu::ShaderModule module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
#version 450 #version 450
layout(std430, set = 0, binding = 0) buffer Buf { uint buf; }; layout(std430, set = 0, binding = 0) buffer Buf { uint buf; };
void main() {} void main() {}
)"); )");
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Compute, dawn::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}});
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}}); wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}});
dawn::PipelineLayout layout = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout layout = utils::MakeBasicPipelineLayout(device, &bgl);
dawn::ComputePipelineDescriptor pipelineDesc = {}; wgpu::ComputePipelineDescriptor pipelineDesc = {};
pipelineDesc.layout = layout; pipelineDesc.layout = layout;
pipelineDesc.computeStage.module = module; pipelineDesc.computeStage.module = module;
pipelineDesc.computeStage.entryPoint = "main"; pipelineDesc.computeStage.entryPoint = "main";
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc); wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bindGroup); pass.SetBindGroup(0, bindGroup);
@ -105,12 +105,12 @@ TEST_F(ComputePassValidationTest, MultipleWrites) {
// Test that it is valid to use a buffer with a single write usage multiple times in a compute pass, // Test that it is valid to use a buffer with a single write usage multiple times in a compute pass,
// even if the buffer is referenced in separate bind groups. // even if the buffer is referenced in separate bind groups.
TEST_F(ComputePassValidationTest, MultipleWritesSeparateBindGroups) { TEST_F(ComputePassValidationTest, MultipleWritesSeparateBindGroups) {
dawn::BufferDescriptor bufferDesc = {}; wgpu::BufferDescriptor bufferDesc = {};
bufferDesc.usage = dawn::BufferUsage::Storage; bufferDesc.usage = wgpu::BufferUsage::Storage;
bufferDesc.size = 4; bufferDesc.size = 4;
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc); wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
dawn::ShaderModule module = wgpu::ShaderModule module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
#version 450 #version 450
#define kNumValues 100 #define kNumValues 100
@ -118,22 +118,22 @@ TEST_F(ComputePassValidationTest, MultipleWritesSeparateBindGroups) {
void main() {} void main() {}
)"); )");
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Compute, dawn::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}});
dawn::BindGroup bindGroupA = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}}); wgpu::BindGroup bindGroupA = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}});
dawn::BindGroup bindGroupB = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}}); wgpu::BindGroup bindGroupB = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}});
dawn::PipelineLayout layout = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout layout = utils::MakeBasicPipelineLayout(device, &bgl);
dawn::ComputePipelineDescriptor pipelineDesc = {}; wgpu::ComputePipelineDescriptor pipelineDesc = {};
pipelineDesc.layout = layout; pipelineDesc.layout = layout;
pipelineDesc.computeStage.module = module; pipelineDesc.computeStage.module = module;
pipelineDesc.computeStage.entryPoint = "main"; pipelineDesc.computeStage.entryPoint = "main";
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc); wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bindGroupA); pass.SetBindGroup(0, bindGroupA);

View File

@ -22,9 +22,9 @@ class DebugMarkerValidationTest : public ValidationTest {};
TEST_F(DebugMarkerValidationTest, RenderSuccess) { TEST_F(DebugMarkerValidationTest, RenderSuccess) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
@ -40,9 +40,9 @@ TEST_F(DebugMarkerValidationTest, RenderSuccess) {
TEST_F(DebugMarkerValidationTest, RenderUnbalancedPush) { TEST_F(DebugMarkerValidationTest, RenderUnbalancedPush) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
@ -57,9 +57,9 @@ TEST_F(DebugMarkerValidationTest, RenderUnbalancedPush) {
TEST_F(DebugMarkerValidationTest, RenderUnbalancedPop) { TEST_F(DebugMarkerValidationTest, RenderUnbalancedPop) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
pass.PopDebugGroup(); pass.PopDebugGroup();
@ -72,9 +72,9 @@ TEST_F(DebugMarkerValidationTest, RenderUnbalancedPop) {
// Correct usage of debug markers should succeed in compute pass. // Correct usage of debug markers should succeed in compute pass.
TEST_F(DebugMarkerValidationTest, ComputeSuccess) { TEST_F(DebugMarkerValidationTest, ComputeSuccess) {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
@ -88,9 +88,9 @@ TEST_F(DebugMarkerValidationTest, ComputeSuccess) {
// A PushDebugGroup call without a following PopDebugGroup produces an error in compute pass. // A PushDebugGroup call without a following PopDebugGroup produces an error in compute pass.
TEST_F(DebugMarkerValidationTest, ComputeUnbalancedPush) { TEST_F(DebugMarkerValidationTest, ComputeUnbalancedPush) {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
@ -103,9 +103,9 @@ TEST_F(DebugMarkerValidationTest, ComputeUnbalancedPush) {
// A PopDebugGroup call without a preceding PushDebugGroup produces an error in compute pass. // A PopDebugGroup call without a preceding PushDebugGroup produces an error in compute pass.
TEST_F(DebugMarkerValidationTest, ComputeUnbalancedPop) { TEST_F(DebugMarkerValidationTest, ComputeUnbalancedPop) {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
pass.PopDebugGroup(); pass.PopDebugGroup();
@ -118,7 +118,7 @@ TEST_F(DebugMarkerValidationTest, ComputeUnbalancedPop) {
// Correct usage of debug markers should succeed in command encoder. // Correct usage of debug markers should succeed in command encoder.
TEST_F(DebugMarkerValidationTest, CommandEncoderSuccess) { TEST_F(DebugMarkerValidationTest, CommandEncoderSuccess) {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
encoder.InsertDebugMarker("Marker"); encoder.InsertDebugMarker("Marker");
@ -129,7 +129,7 @@ TEST_F(DebugMarkerValidationTest, CommandEncoderSuccess) {
// A PushDebugGroup call without a following PopDebugGroup produces an error in command encoder. // A PushDebugGroup call without a following PopDebugGroup produces an error in command encoder.
TEST_F(DebugMarkerValidationTest, CommandEncoderUnbalancedPush) { TEST_F(DebugMarkerValidationTest, CommandEncoderUnbalancedPush) {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
encoder.InsertDebugMarker("Marker"); encoder.InsertDebugMarker("Marker");
@ -139,7 +139,7 @@ TEST_F(DebugMarkerValidationTest, CommandEncoderUnbalancedPush) {
// A PopDebugGroup call without a preceding PushDebugGroup produces an error in command encoder. // A PopDebugGroup call without a preceding PushDebugGroup produces an error in command encoder.
TEST_F(DebugMarkerValidationTest, CommandEncoderUnbalancedPop) { TEST_F(DebugMarkerValidationTest, CommandEncoderUnbalancedPop) {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
encoder.InsertDebugMarker("Marker"); encoder.InsertDebugMarker("Marker");
encoder.PopDebugGroup(); encoder.PopDebugGroup();
@ -149,10 +149,10 @@ TEST_F(DebugMarkerValidationTest, CommandEncoderUnbalancedPop) {
// It is possible to nested pushes in a compute pass in a command encoder. // It is possible to nested pushes in a compute pass in a command encoder.
TEST_F(DebugMarkerValidationTest, NestedComputeInCommandEncoder) { TEST_F(DebugMarkerValidationTest, NestedComputeInCommandEncoder) {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
{ {
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
pass.PopDebugGroup(); pass.PopDebugGroup();
@ -164,10 +164,10 @@ TEST_F(DebugMarkerValidationTest, NestedComputeInCommandEncoder) {
// Command encoder and compute pass pushes must be balanced independently. // Command encoder and compute pass pushes must be balanced independently.
TEST_F(DebugMarkerValidationTest, NestedComputeInCommandEncoderIndependent) { TEST_F(DebugMarkerValidationTest, NestedComputeInCommandEncoderIndependent) {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
{ {
dawn::ComputePassEncoder pass = encoder.BeginComputePass(); wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
pass.PopDebugGroup(); pass.PopDebugGroup();
pass.EndPass(); pass.EndPass();
@ -179,10 +179,10 @@ TEST_F(DebugMarkerValidationTest, NestedComputeInCommandEncoderIndependent) {
TEST_F(DebugMarkerValidationTest, NestedRenderInCommandEncoder) { TEST_F(DebugMarkerValidationTest, NestedRenderInCommandEncoder) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.PushDebugGroup("Event Start"); pass.PushDebugGroup("Event Start");
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
pass.PopDebugGroup(); pass.PopDebugGroup();
@ -196,10 +196,10 @@ TEST_F(DebugMarkerValidationTest, NestedRenderInCommandEncoder) {
TEST_F(DebugMarkerValidationTest, NestedRenderInCommandEncoderIndependent) { TEST_F(DebugMarkerValidationTest, NestedRenderInCommandEncoderIndependent) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.PushDebugGroup("Event Start"); encoder.PushDebugGroup("Event Start");
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.InsertDebugMarker("Marker"); pass.InsertDebugMarker("Marker");
pass.PopDebugGroup(); pass.PopDebugGroup();
pass.EndPass(); pass.EndPass();

View File

@ -23,14 +23,14 @@ class DrawIndirectValidationTest : public ValidationTest {
void SetUp() override { void SetUp() override {
ValidationTest::SetUp(); ValidationTest::SetUp();
dawn::ShaderModule vsModule = wgpu::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450 #version 450
void main() { void main() {
gl_Position = vec4(0.0); gl_Position = vec4(0.0);
})"); })");
dawn::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
@ -39,7 +39,7 @@ class DrawIndirectValidationTest : public ValidationTest {
})"); })");
// Set up render pipeline // Set up render pipeline
dawn::PipelineLayout pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr); wgpu::PipelineLayout pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.layout = pipelineLayout; descriptor.layout = pipelineLayout;
@ -49,7 +49,7 @@ class DrawIndirectValidationTest : public ValidationTest {
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline(&descriptor);
} }
void ValidateExpectation(dawn::CommandEncoder encoder, utils::Expectation expectation) { void ValidateExpectation(wgpu::CommandEncoder encoder, utils::Expectation expectation) {
if (expectation == utils::Expectation::Success) { if (expectation == utils::Expectation::Success) {
encoder.Finish(); encoder.Finish();
} else { } else {
@ -73,17 +73,17 @@ class DrawIndirectValidationTest : public ValidationTest {
std::initializer_list<uint32_t> bufferList, std::initializer_list<uint32_t> bufferList,
uint64_t indirectOffset, uint64_t indirectOffset,
bool indexed) { bool indexed) {
dawn::Buffer indirectBuffer = wgpu::Buffer indirectBuffer =
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList); utils::CreateBufferFromData<uint32_t>(device, wgpu::BufferUsage::Indirect, bufferList);
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
if (indexed) { if (indexed) {
uint32_t zeros[100] = {}; uint32_t zeros[100] = {};
dawn::Buffer indexBuffer = wgpu::Buffer indexBuffer =
utils::CreateBufferFromData(device, zeros, sizeof(zeros), dawn::BufferUsage::Index); utils::CreateBufferFromData(device, zeros, sizeof(zeros), wgpu::BufferUsage::Index);
pass.SetIndexBuffer(indexBuffer); pass.SetIndexBuffer(indexBuffer);
pass.DrawIndexedIndirect(indirectBuffer, indirectOffset); pass.DrawIndexedIndirect(indirectBuffer, indirectOffset);
} else { } else {
@ -94,7 +94,7 @@ class DrawIndirectValidationTest : public ValidationTest {
ValidateExpectation(encoder, expectation); ValidateExpectation(encoder, expectation);
} }
dawn::RenderPipeline pipeline; wgpu::RenderPipeline pipeline;
}; };
// Verify out of bounds indirect draw calls are caught early // Verify out of bounds indirect draw calls are caught early

View File

@ -22,9 +22,9 @@ class SetViewportTest : public ValidationTest {};
TEST_F(SetViewportTest, Success) { TEST_F(SetViewportTest, Success) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.0, 1.0); pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
} }
@ -37,8 +37,8 @@ TEST_F(SetViewportTest, ViewportParameterNaN) {
// x or y is NaN. // x or y is NaN.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(NAN, 0.0, 1.0, 1.0, 0.0, 1.0); pass.SetViewport(NAN, 0.0, 1.0, 1.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -46,8 +46,8 @@ TEST_F(SetViewportTest, ViewportParameterNaN) {
// width or height is NaN. // width or height is NaN.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, NAN, 1.0, 0.0, 1.0); pass.SetViewport(0.0, 0.0, NAN, 1.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -55,8 +55,8 @@ TEST_F(SetViewportTest, ViewportParameterNaN) {
// minDepth or maxDepth is NaN. // minDepth or maxDepth is NaN.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 1.0, NAN, 1.0); pass.SetViewport(0.0, 0.0, 1.0, 1.0, NAN, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -69,8 +69,8 @@ TEST_F(SetViewportTest, EmptyViewport) {
// Width of viewport is zero. // Width of viewport is zero.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 0.0, 1.0, 0.0, 1.0); pass.SetViewport(0.0, 0.0, 0.0, 1.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -78,8 +78,8 @@ TEST_F(SetViewportTest, EmptyViewport) {
// Height of viewport is zero. // Height of viewport is zero.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 0.0, 0.0, 1.0); pass.SetViewport(0.0, 0.0, 1.0, 0.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -87,8 +87,8 @@ TEST_F(SetViewportTest, EmptyViewport) {
// Both width and height of viewport are zero. // Both width and height of viewport are zero.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 0.0, 0.0, 0.0, 1.0); pass.SetViewport(0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -99,9 +99,9 @@ TEST_F(SetViewportTest, EmptyViewport) {
TEST_F(SetViewportTest, ViewportLargerThanFramebuffer) { TEST_F(SetViewportTest, ViewportLargerThanFramebuffer) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, renderPass.width + 1, renderPass.height + 1, 0.0, 1.0); pass.SetViewport(0.0, 0.0, renderPass.width + 1, renderPass.height + 1, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
} }
@ -112,9 +112,9 @@ TEST_F(SetViewportTest, ViewportLargerThanFramebuffer) {
TEST_F(SetViewportTest, NegativeX) { TEST_F(SetViewportTest, NegativeX) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(-1.0, 0.0, 1.0, 1.0, 0.0, 1.0); pass.SetViewport(-1.0, 0.0, 1.0, 1.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
} }
@ -125,9 +125,9 @@ TEST_F(SetViewportTest, NegativeX) {
TEST_F(SetViewportTest, NegativeY) { TEST_F(SetViewportTest, NegativeY) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, -1.0, 1.0, 1.0, 0.0, 1.0); pass.SetViewport(0.0, -1.0, 1.0, 1.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
} }
@ -138,9 +138,9 @@ TEST_F(SetViewportTest, NegativeY) {
TEST_F(SetViewportTest, NegativeWidth) { TEST_F(SetViewportTest, NegativeWidth) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, -1.0, 1.0, 0.0, 1.0); pass.SetViewport(0.0, 0.0, -1.0, 1.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -151,9 +151,9 @@ TEST_F(SetViewportTest, NegativeWidth) {
TEST_F(SetViewportTest, NegativeHeight) { TEST_F(SetViewportTest, NegativeHeight) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 0.0, -1.0, 0.0, 1.0); pass.SetViewport(0.0, 0.0, 0.0, -1.0, 0.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -165,16 +165,16 @@ TEST_F(SetViewportTest, MinDepthOutOfRange) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 1.0, -1.0, 1.0); pass.SetViewport(0.0, 0.0, 1.0, 1.0, -1.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
} }
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 1.0, 2.0, 1.0); pass.SetViewport(0.0, 0.0, 1.0, 1.0, 2.0, 1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -186,16 +186,16 @@ TEST_F(SetViewportTest, MaxDepthOutOfRange) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.0, -1.0); pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.0, -1.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
} }
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.0, 2.0); pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.0, 2.0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -207,16 +207,16 @@ TEST_F(SetViewportTest, MinDepthEqualOrLessThanMaxDepth) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.5, 0.5); pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.5, 0.5);
pass.EndPass(); pass.EndPass();
encoder.Finish(); encoder.Finish();
} }
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.8, 0.5); pass.SetViewport(0.0, 0.0, 1.0, 1.0, 0.8, 0.5);
pass.EndPass(); pass.EndPass();
encoder.Finish(); encoder.Finish();
@ -230,9 +230,9 @@ class SetScissorRectTest : public ValidationTest {
TEST_F(SetScissorRectTest, Success) { TEST_F(SetScissorRectTest, Success) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetScissorRect(0, 0, 1, 1); pass.SetScissorRect(0, 0, 1, 1);
pass.EndPass(); pass.EndPass();
} }
@ -245,8 +245,8 @@ TEST_F(SetScissorRectTest, EmptyScissor) {
// Width of scissor rect is zero. // Width of scissor rect is zero.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetScissorRect(0, 0, 0, 1); pass.SetScissorRect(0, 0, 0, 1);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -254,8 +254,8 @@ TEST_F(SetScissorRectTest, EmptyScissor) {
// Height of scissor rect is zero. // Height of scissor rect is zero.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetScissorRect(0, 0, 1, 0); pass.SetScissorRect(0, 0, 1, 0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -263,8 +263,8 @@ TEST_F(SetScissorRectTest, EmptyScissor) {
// Both width and height of scissor rect are zero. // Both width and height of scissor rect are zero.
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetScissorRect(0, 0, 0, 0); pass.SetScissorRect(0, 0, 0, 0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
@ -275,9 +275,9 @@ TEST_F(SetScissorRectTest, EmptyScissor) {
TEST_F(SetScissorRectTest, ScissorLargerThanFramebuffer) { TEST_F(SetScissorRectTest, ScissorLargerThanFramebuffer) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetScissorRect(0, 0, renderPass.width + 1, renderPass.height + 1); pass.SetScissorRect(0, 0, renderPass.width + 1, renderPass.height + 1);
pass.EndPass(); pass.EndPass();
} }
@ -291,10 +291,10 @@ class SetBlendColorTest : public ValidationTest {
TEST_F(SetBlendColorTest, Success) { TEST_F(SetBlendColorTest, Success) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
constexpr dawn::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f}; constexpr wgpu::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f};
pass.SetBlendColor(&kTransparentBlack); pass.SetBlendColor(&kTransparentBlack);
pass.EndPass(); pass.EndPass();
} }
@ -305,10 +305,10 @@ TEST_F(SetBlendColorTest, Success) {
TEST_F(SetBlendColorTest, AnyValueAllowed) { TEST_F(SetBlendColorTest, AnyValueAllowed) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
constexpr dawn::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f}; constexpr wgpu::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f};
pass.SetBlendColor(&kAnyColorValue); pass.SetBlendColor(&kAnyColorValue);
pass.EndPass(); pass.EndPass();
} }
@ -322,9 +322,9 @@ class SetStencilReferenceTest : public ValidationTest {
TEST_F(SetStencilReferenceTest, Success) { TEST_F(SetStencilReferenceTest, Success) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetStencilReference(0); pass.SetStencilReference(0);
pass.EndPass(); pass.EndPass();
} }
@ -335,9 +335,9 @@ TEST_F(SetStencilReferenceTest, Success) {
TEST_F(SetStencilReferenceTest, AllBitsAllowed) { TEST_F(SetStencilReferenceTest, AllBitsAllowed) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetStencilReference(0xFFFFFFFF); pass.SetStencilReference(0xFFFFFFFF);
pass.EndPass(); pass.EndPass();
} }

View File

@ -20,11 +20,11 @@ using namespace testing;
class MockDevicePopErrorScopeCallback { class MockDevicePopErrorScopeCallback {
public: public:
MOCK_METHOD3(Call, void(DawnErrorType type, const char* message, void* userdata)); MOCK_METHOD3(Call, void(WGPUErrorType type, const char* message, void* userdata));
}; };
static std::unique_ptr<MockDevicePopErrorScopeCallback> mockDevicePopErrorScopeCallback; static std::unique_ptr<MockDevicePopErrorScopeCallback> mockDevicePopErrorScopeCallback;
static void ToMockDevicePopErrorScopeCallback(DawnErrorType type, static void ToMockDevicePopErrorScopeCallback(WGPUErrorType type,
const char* message, const char* message,
void* userdata) { void* userdata) {
mockDevicePopErrorScopeCallback->Call(type, message, userdata); mockDevicePopErrorScopeCallback->Call(type, message, userdata);
@ -46,73 +46,71 @@ class ErrorScopeValidationTest : public ValidationTest {
// Test the simple success case. // Test the simple success case.
TEST_F(ErrorScopeValidationTest, Success) { TEST_F(ErrorScopeValidationTest, Success) {
device.PushErrorScope(dawn::ErrorFilter::Validation); device.PushErrorScope(wgpu::ErrorFilter::Validation);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this)).Times(1);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
} }
// Test the simple case where the error scope catches an error. // Test the simple case where the error scope catches an error.
TEST_F(ErrorScopeValidationTest, CatchesError) { TEST_F(ErrorScopeValidationTest, CatchesError) {
device.PushErrorScope(dawn::ErrorFilter::Validation); device.PushErrorScope(wgpu::ErrorFilter::Validation);
dawn::BufferDescriptor desc = {}; wgpu::BufferDescriptor desc = {};
desc.usage = static_cast<dawn::BufferUsage>(DAWN_BUFFER_USAGE_FORCE32); desc.usage = static_cast<wgpu::BufferUsage>(WGPUBufferUsage_Force32);
device.CreateBuffer(&desc); device.CreateBuffer(&desc);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_VALIDATION, _, this)) EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_Validation, _, this)).Times(1);
.Times(1);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
} }
// Test that errors bubble to the parent scope if not handled by the current scope. // Test that errors bubble to the parent scope if not handled by the current scope.
TEST_F(ErrorScopeValidationTest, ErrorBubbles) { TEST_F(ErrorScopeValidationTest, ErrorBubbles) {
device.PushErrorScope(dawn::ErrorFilter::Validation); device.PushErrorScope(wgpu::ErrorFilter::Validation);
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
dawn::BufferDescriptor desc = {}; wgpu::BufferDescriptor desc = {};
desc.usage = static_cast<dawn::BufferUsage>(DAWN_BUFFER_USAGE_FORCE32); desc.usage = static_cast<wgpu::BufferUsage>(WGPUBufferUsage_Force32);
device.CreateBuffer(&desc); device.CreateBuffer(&desc);
// OutOfMemory does not match Validation error. // OutOfMemory does not match Validation error.
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this)).Times(1);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
// Parent validation error scope captures the error. // Parent validation error scope captures the error.
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_VALIDATION, _, this + 1)) EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_Validation, _, this + 1))
.Times(1); .Times(1);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1);
} }
// Test that if an error scope matches an error, it does not bubble to the parent scope. // Test that if an error scope matches an error, it does not bubble to the parent scope.
TEST_F(ErrorScopeValidationTest, HandledErrorsStopBubbling) { TEST_F(ErrorScopeValidationTest, HandledErrorsStopBubbling) {
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
device.PushErrorScope(dawn::ErrorFilter::Validation); device.PushErrorScope(wgpu::ErrorFilter::Validation);
dawn::BufferDescriptor desc = {}; wgpu::BufferDescriptor desc = {};
desc.usage = static_cast<dawn::BufferUsage>(DAWN_BUFFER_USAGE_FORCE32); desc.usage = static_cast<wgpu::BufferUsage>(WGPUBufferUsage_Force32);
device.CreateBuffer(&desc); device.CreateBuffer(&desc);
// Inner scope catches the error. // Inner scope catches the error.
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_VALIDATION, _, this)) EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_Validation, _, this)).Times(1);
.Times(1);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
// Parent scope does not see the error. // Parent scope does not see the error.
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this + 1)) EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this + 1))
.Times(1); .Times(1);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1);
} }
// Test that if no error scope handles an error, it goes to the device UncapturedError callback // Test that if no error scope handles an error, it goes to the device UncapturedError callback
TEST_F(ErrorScopeValidationTest, UnhandledErrorsMatchUncapturedErrorCallback) { TEST_F(ErrorScopeValidationTest, UnhandledErrorsMatchUncapturedErrorCallback) {
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
dawn::BufferDescriptor desc = {}; wgpu::BufferDescriptor desc = {};
desc.usage = static_cast<dawn::BufferUsage>(DAWN_BUFFER_USAGE_FORCE32); desc.usage = static_cast<wgpu::BufferUsage>(WGPUBufferUsage_Force32);
ASSERT_DEVICE_ERROR(device.CreateBuffer(&desc)); ASSERT_DEVICE_ERROR(device.CreateBuffer(&desc));
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this)).Times(1);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
} }
@ -123,9 +121,9 @@ TEST_F(ErrorScopeValidationTest, PushPopBalanced) {
// Too many pops // Too many pops
{ {
device.PushErrorScope(dawn::ErrorFilter::Validation); device.PushErrorScope(wgpu::ErrorFilter::Validation);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this + 1)) EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this + 1))
.Times(1); .Times(1);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1);
@ -136,13 +134,13 @@ TEST_F(ErrorScopeValidationTest, PushPopBalanced) {
// Test that error scopes do not call their callbacks until after an enclosed Queue::Submit // Test that error scopes do not call their callbacks until after an enclosed Queue::Submit
// completes // completes
TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmit) { TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmit) {
dawn::Queue queue = device.CreateQueue(); wgpu::Queue queue = device.CreateQueue();
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this)).Times(1);
// Side effects of Queue::Submit only are seen after Tick() // Side effects of Queue::Submit only are seen after Tick()
device.Tick(); device.Tick();
@ -151,16 +149,16 @@ TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmit) {
// Test that parent error scopes do not call their callbacks until after an enclosed Queue::Submit // Test that parent error scopes do not call their callbacks until after an enclosed Queue::Submit
// completes // completes
TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmitNested) { TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmitNested) {
dawn::Queue queue = device.CreateQueue(); wgpu::Queue queue = device.CreateQueue();
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this)).Times(1);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this + 1)) EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this + 1))
.Times(1); .Times(1);
// Side effects of Queue::Submit only are seen after Tick() // Side effects of Queue::Submit only are seen after Tick()
@ -169,18 +167,18 @@ TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmitNested) {
// Test a callback that returns asynchronously followed by a synchronous one // Test a callback that returns asynchronously followed by a synchronous one
TEST_F(ErrorScopeValidationTest, AsynchronousThenSynchronous) { TEST_F(ErrorScopeValidationTest, AsynchronousThenSynchronous) {
dawn::Queue queue = device.CreateQueue(); wgpu::Queue queue = device.CreateQueue();
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this + 1)) EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this + 1))
.Times(1); .Times(1);
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this + 1);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_NO_ERROR, _, this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_NoError, _, this)).Times(1);
// Side effects of Queue::Submit only are seen after Tick() // Side effects of Queue::Submit only are seen after Tick()
device.Tick(); device.Tick();
@ -188,12 +186,12 @@ TEST_F(ErrorScopeValidationTest, AsynchronousThenSynchronous) {
// Test that if the device is destroyed before the callback occurs, it is called with UNKNOWN. // Test that if the device is destroyed before the callback occurs, it is called with UNKNOWN.
TEST_F(ErrorScopeValidationTest, DeviceDestroyedBeforeCallback) { TEST_F(ErrorScopeValidationTest, DeviceDestroyedBeforeCallback) {
dawn::Queue queue = device.CreateQueue(); wgpu::Queue queue = device.CreateQueue();
device.PushErrorScope(dawn::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this); device.PopErrorScope(ToMockDevicePopErrorScopeCallback, this);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_UNKNOWN, _, this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(WGPUErrorType_Unknown, _, this)).Times(1);
device = nullptr; device = nullptr;
} }

View File

@ -20,23 +20,23 @@ using namespace testing;
class MockFenceOnCompletionCallback { class MockFenceOnCompletionCallback {
public: public:
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, void* userdata)); MOCK_METHOD2(Call, void(WGPUFenceCompletionStatus status, void* userdata));
}; };
struct FenceOnCompletionExpectation { struct FenceOnCompletionExpectation {
dawn::Fence fence; wgpu::Fence fence;
uint64_t value; uint64_t value;
DawnFenceCompletionStatus status; WGPUFenceCompletionStatus status;
}; };
static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback; static std::unique_ptr<MockFenceOnCompletionCallback> mockFenceOnCompletionCallback;
static void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status, void* userdata) { static void ToMockFenceOnCompletionCallback(WGPUFenceCompletionStatus status, void* userdata) {
mockFenceOnCompletionCallback->Call(status, userdata); mockFenceOnCompletionCallback->Call(status, userdata);
} }
class FenceValidationTest : public ValidationTest { class FenceValidationTest : public ValidationTest {
protected: protected:
void TestOnCompletion(dawn::Fence fence, uint64_t value, DawnFenceCompletionStatus status) { void TestOnCompletion(wgpu::Fence fence, uint64_t value, WGPUFenceCompletionStatus status) {
FenceOnCompletionExpectation* expectation = new FenceOnCompletionExpectation; FenceOnCompletionExpectation* expectation = new FenceOnCompletionExpectation;
expectation->fence = fence; expectation->fence = fence;
expectation->value = value; expectation->value = value;
@ -50,7 +50,7 @@ class FenceValidationTest : public ValidationTest {
device.Tick(); device.Tick();
} }
dawn::Queue queue; wgpu::Queue queue;
private: private:
void SetUp() override { void SetUp() override {
@ -72,7 +72,7 @@ class FenceValidationTest : public ValidationTest {
TEST_F(FenceValidationTest, CreationSuccess) { TEST_F(FenceValidationTest, CreationSuccess) {
// Success // Success
{ {
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 0; descriptor.initialValue = 0;
queue.CreateFence(&descriptor); queue.CreateFence(&descriptor);
} }
@ -81,9 +81,9 @@ TEST_F(FenceValidationTest, CreationSuccess) {
TEST_F(FenceValidationTest, GetCompletedValue) { TEST_F(FenceValidationTest, GetCompletedValue) {
// Starts at initial value // Starts at initial value
{ {
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
EXPECT_EQ(fence.GetCompletedValue(), 1u); EXPECT_EQ(fence.GetCompletedValue(), 1u);
} }
} }
@ -91,35 +91,33 @@ TEST_F(FenceValidationTest, GetCompletedValue) {
// Test that OnCompletion handlers are called immediately for // Test that OnCompletion handlers are called immediately for
// already completed fence values // already completed fence values
TEST_F(FenceValidationTest, OnCompletionImmediate) { TEST_F(FenceValidationTest, OnCompletionImmediate) {
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
EXPECT_CALL(*mockFenceOnCompletionCallback, EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 0))
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 0))
.Times(1); .Times(1);
fence.OnCompletion(0u, ToMockFenceOnCompletionCallback, this + 0); fence.OnCompletion(0u, ToMockFenceOnCompletionCallback, this + 0);
EXPECT_CALL(*mockFenceOnCompletionCallback, EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 1))
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 1))
.Times(1); .Times(1);
fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 1); fence.OnCompletion(1u, ToMockFenceOnCompletionCallback, this + 1);
} }
// Test setting OnCompletion handlers for values > signaled value // Test setting OnCompletion handlers for values > signaled value
TEST_F(FenceValidationTest, OnCompletionLargerThanSignaled) { TEST_F(FenceValidationTest, OnCompletionLargerThanSignaled) {
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
// Cannot signal for values > signaled value // Cannot signal for values > signaled value
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_ERROR, nullptr)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Error, nullptr))
.Times(1); .Times(1);
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr)); ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr));
// Can set handler after signaling // Can set handler after signaling
queue.Signal(fence, 2); queue.Signal(fence, 2);
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, nullptr)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, nullptr))
.Times(1); .Times(1);
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr); fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
@ -127,14 +125,14 @@ TEST_F(FenceValidationTest, OnCompletionLargerThanSignaled) {
} }
TEST_F(FenceValidationTest, GetCompletedValueInsideCallback) { TEST_F(FenceValidationTest, GetCompletedValueInsideCallback) {
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
queue.Signal(fence, 3); queue.Signal(fence, 3);
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr); fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, nullptr)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, nullptr))
.WillOnce(Invoke([&](DawnFenceCompletionStatus status, void* userdata) { .WillOnce(Invoke([&](WGPUFenceCompletionStatus status, void* userdata) {
EXPECT_EQ(fence.GetCompletedValue(), 3u); EXPECT_EQ(fence.GetCompletedValue(), 3u);
})); }));
@ -142,13 +140,13 @@ TEST_F(FenceValidationTest, GetCompletedValueInsideCallback) {
} }
TEST_F(FenceValidationTest, GetCompletedValueAfterCallback) { TEST_F(FenceValidationTest, GetCompletedValueAfterCallback) {
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
queue.Signal(fence, 2); queue.Signal(fence, 2);
fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr); fence.OnCompletion(2u, ToMockFenceOnCompletionCallback, nullptr);
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, nullptr)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, nullptr))
.Times(1); .Times(1);
Flush(); Flush();
@ -156,9 +154,9 @@ TEST_F(FenceValidationTest, GetCompletedValueAfterCallback) {
} }
TEST_F(FenceValidationTest, SignalError) { TEST_F(FenceValidationTest, SignalError) {
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
// value < fence signaled value // value < fence signaled value
ASSERT_DEVICE_ERROR(queue.Signal(fence, 0)); ASSERT_DEVICE_ERROR(queue.Signal(fence, 0));
@ -168,9 +166,9 @@ TEST_F(FenceValidationTest, SignalError) {
} }
TEST_F(FenceValidationTest, SignalSuccess) { TEST_F(FenceValidationTest, SignalSuccess) {
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
// Success // Success
queue.Signal(fence, 2); queue.Signal(fence, 2);
@ -185,22 +183,22 @@ TEST_F(FenceValidationTest, SignalSuccess) {
// Test it is invalid to signal a fence on a different queue than it was created on // Test it is invalid to signal a fence on a different queue than it was created on
TEST_F(FenceValidationTest, SignalWrongQueue) { TEST_F(FenceValidationTest, SignalWrongQueue) {
dawn::Queue queue2 = device.CreateQueue(); wgpu::Queue queue2 = device.CreateQueue();
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
ASSERT_DEVICE_ERROR(queue2.Signal(fence, 2)); ASSERT_DEVICE_ERROR(queue2.Signal(fence, 2));
} }
// Test that signaling a fence on a wrong queue does not update fence signaled value // Test that signaling a fence on a wrong queue does not update fence signaled value
TEST_F(FenceValidationTest, SignalWrongQueueDoesNotUpdateValue) { TEST_F(FenceValidationTest, SignalWrongQueueDoesNotUpdateValue) {
dawn::Queue queue2 = device.CreateQueue(); wgpu::Queue queue2 = device.CreateQueue();
dawn::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
dawn::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence = queue.CreateFence(&descriptor);
ASSERT_DEVICE_ERROR(queue2.Signal(fence, 2)); ASSERT_DEVICE_ERROR(queue2.Signal(fence, 2));

View File

@ -21,7 +21,7 @@ namespace {
class QueueSubmitValidationTest : public ValidationTest { class QueueSubmitValidationTest : public ValidationTest {
}; };
static void StoreTrueMapWriteCallback(DawnBufferMapAsyncStatus status, static void StoreTrueMapWriteCallback(WGPUBufferMapAsyncStatus status,
void*, void*,
uint64_t, uint64_t,
void* userdata) { void* userdata) {
@ -31,24 +31,24 @@ static void StoreTrueMapWriteCallback(DawnBufferMapAsyncStatus status,
// Test submitting with a mapped buffer is disallowed // Test submitting with a mapped buffer is disallowed
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) { TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
// Create a map-write buffer. // Create a map-write buffer.
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc; descriptor.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
descriptor.size = 4; descriptor.size = 4;
dawn::Buffer buffer = device.CreateBuffer(&descriptor); wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
// Create a fake copy destination buffer // Create a fake copy destination buffer
descriptor.usage = dawn::BufferUsage::CopyDst; descriptor.usage = wgpu::BufferUsage::CopyDst;
dawn::Buffer targetBuffer = device.CreateBuffer(&descriptor); wgpu::Buffer targetBuffer = device.CreateBuffer(&descriptor);
// Create a command buffer that reads from the mappable buffer. // Create a command buffer that reads from the mappable buffer.
dawn::CommandBuffer commands; wgpu::CommandBuffer commands;
{ {
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.CopyBufferToBuffer(buffer, 0, targetBuffer, 0, 4); encoder.CopyBufferToBuffer(buffer, 0, targetBuffer, 0, 4);
commands = encoder.Finish(); commands = encoder.Finish();
} }
dawn::Queue queue = device.CreateQueue(); wgpu::Queue queue = device.CreateQueue();
// Submitting when the buffer has never been mapped should succeed // Submitting when the buffer has never been mapped should succeed
queue.Submit(1, &commands); queue.Submit(1, &commands);

View File

@ -47,16 +47,16 @@ namespace {
void main() { void main() {
})"); })");
dawn::BindGroupLayout bgls[] = { wgpu::BindGroupLayout bgls[] = {
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}}), device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}),
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, { device, {
{0, dawn::ShaderStage::Fragment, dawn::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer},
{1, dawn::ShaderStage::Fragment, dawn::BindingType::StorageBuffer}, {1, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer},
})}; })};
dawn::PipelineLayoutDescriptor pipelineLayoutDesc = {}; wgpu::PipelineLayoutDescriptor pipelineLayoutDesc = {};
pipelineLayoutDesc.bindGroupLayoutCount = 2; pipelineLayoutDesc.bindGroupLayoutCount = 2;
pipelineLayoutDesc.bindGroupLayouts = bgls; pipelineLayoutDesc.bindGroupLayouts = bgls;
@ -67,22 +67,22 @@ namespace {
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline(&descriptor);
float data[4]; float data[4];
dawn::Buffer buffer = utils::CreateBufferFromData(device, data, 4 * sizeof(float), wgpu::Buffer buffer = utils::CreateBufferFromData(device, data, 4 * sizeof(float),
dawn::BufferUsage::Uniform); wgpu::BufferUsage::Uniform);
constexpr static float kVertices[] = {-1.f, 1.f, 1.f, -1.f, -1.f, 1.f}; constexpr static float kVertices[] = {-1.f, 1.f, 1.f, -1.f, -1.f, 1.f};
vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
dawn::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
// Dummy storage buffer. // Dummy storage buffer.
dawn::Buffer storageBuffer = utils::CreateBufferFromData( wgpu::Buffer storageBuffer = utils::CreateBufferFromData(
device, kVertices, sizeof(kVertices), dawn::BufferUsage::Storage); device, kVertices, sizeof(kVertices), wgpu::BufferUsage::Storage);
// Vertex buffer with storage usage for testing read+write error usage. // Vertex buffer with storage usage for testing read+write error usage.
vertexStorageBuffer = vertexStorageBuffer =
utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
dawn::BufferUsage::Vertex | dawn::BufferUsage::Storage); wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Storage);
bg0 = utils::MakeBindGroup(device, bgls[0], {{0, buffer, 0, 4 * sizeof(float)}}); bg0 = utils::MakeBindGroup(device, bgls[0], {{0, buffer, 0, 4 * sizeof(float)}});
bg1 = utils::MakeBindGroup( bg1 = utils::MakeBindGroup(
@ -101,19 +101,19 @@ namespace {
descriptor->cVertexInput.bufferCount = 1; descriptor->cVertexInput.bufferCount = 1;
descriptor->cVertexInput.cBuffers[0].stride = 2 * sizeof(float); descriptor->cVertexInput.cBuffers[0].stride = 2 * sizeof(float);
descriptor->cVertexInput.cBuffers[0].attributeCount = 1; descriptor->cVertexInput.cBuffers[0].attributeCount = 1;
descriptor->cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float2; descriptor->cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float2;
descriptor->cVertexInput.cAttributes[0].shaderLocation = 0; descriptor->cVertexInput.cAttributes[0].shaderLocation = 0;
} }
dawn::ShaderModule vsModule; wgpu::ShaderModule vsModule;
dawn::ShaderModule fsModule; wgpu::ShaderModule fsModule;
dawn::PipelineLayout pipelineLayout; wgpu::PipelineLayout pipelineLayout;
dawn::RenderPipeline pipeline; wgpu::RenderPipeline pipeline;
dawn::Buffer vertexBuffer; wgpu::Buffer vertexBuffer;
dawn::Buffer vertexStorageBuffer; wgpu::Buffer vertexStorageBuffer;
dawn::BindGroup bg0; wgpu::BindGroup bg0;
dawn::BindGroup bg1; wgpu::BindGroup bg1;
dawn::BindGroup bg1Vertex; wgpu::BindGroup bg1Vertex;
}; };
} // anonymous namespace } // anonymous namespace
@ -126,11 +126,11 @@ TEST_F(RenderBundleValidationTest, Empty) {
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = renderPass.attachmentFormat; desc.cColorFormats[0] = renderPass.attachmentFormat;
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
commandEncoder.Finish(); commandEncoder.Finish();
@ -140,8 +140,8 @@ TEST_F(RenderBundleValidationTest, Empty) {
TEST_F(RenderBundleValidationTest, ZeroBundles) { TEST_F(RenderBundleValidationTest, ZeroBundles) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(0, nullptr); pass.ExecuteBundles(0, nullptr);
pass.EndPass(); pass.EndPass();
commandEncoder.Finish(); commandEncoder.Finish();
@ -155,16 +155,16 @@ TEST_F(RenderBundleValidationTest, SimpleSuccess) {
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = renderPass.attachmentFormat; desc.cColorFormats[0] = renderPass.attachmentFormat;
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.SetBindGroup(0, bg0); renderBundleEncoder.SetBindGroup(0, bg0);
renderBundleEncoder.SetBindGroup(1, bg1); renderBundleEncoder.SetBindGroup(1, bg1);
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer); renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
renderBundleEncoder.Draw(3, 0, 0, 0); renderBundleEncoder.Draw(3, 0, 0, 0);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
commandEncoder.Finish(); commandEncoder.Finish();
@ -180,7 +180,7 @@ TEST_F(RenderBundleValidationTest, DebugGroups) {
// Test a single debug group works. // Test a single debug group works.
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.PushDebugGroup("group"); renderBundleEncoder.PushDebugGroup("group");
renderBundleEncoder.PopDebugGroup(); renderBundleEncoder.PopDebugGroup();
renderBundleEncoder.Finish(); renderBundleEncoder.Finish();
@ -188,7 +188,7 @@ TEST_F(RenderBundleValidationTest, DebugGroups) {
// Test nested debug groups work. // Test nested debug groups work.
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.PushDebugGroup("group"); renderBundleEncoder.PushDebugGroup("group");
renderBundleEncoder.PushDebugGroup("group2"); renderBundleEncoder.PushDebugGroup("group2");
renderBundleEncoder.PopDebugGroup(); renderBundleEncoder.PopDebugGroup();
@ -198,14 +198,14 @@ TEST_F(RenderBundleValidationTest, DebugGroups) {
// Test popping when no group is pushed is invalid. // Test popping when no group is pushed is invalid.
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.PopDebugGroup(); renderBundleEncoder.PopDebugGroup();
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
} }
// Test popping too many times is invalid. // Test popping too many times is invalid.
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.PushDebugGroup("group"); renderBundleEncoder.PushDebugGroup("group");
renderBundleEncoder.PopDebugGroup(); renderBundleEncoder.PopDebugGroup();
renderBundleEncoder.PopDebugGroup(); renderBundleEncoder.PopDebugGroup();
@ -214,14 +214,14 @@ TEST_F(RenderBundleValidationTest, DebugGroups) {
// Test that a single debug group must be popped. // Test that a single debug group must be popped.
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.PushDebugGroup("group"); renderBundleEncoder.PushDebugGroup("group");
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
} }
// Test that all debug groups must be popped. // Test that all debug groups must be popped.
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.PushDebugGroup("group"); renderBundleEncoder.PushDebugGroup("group");
renderBundleEncoder.PushDebugGroup("group2"); renderBundleEncoder.PushDebugGroup("group2");
renderBundleEncoder.PopDebugGroup(); renderBundleEncoder.PopDebugGroup();
@ -239,9 +239,9 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
// Render bundle does not inherit pipeline so the draw is invalid. // Render bundle does not inherit pipeline so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
@ -249,7 +249,7 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
renderBundleEncoder.SetBindGroup(1, bg1); renderBundleEncoder.SetBindGroup(1, bg1);
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer); renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
renderBundleEncoder.Draw(3, 0, 0, 0); renderBundleEncoder.Draw(3, 0, 0, 0);
ASSERT_DEVICE_ERROR(dawn::RenderBundle renderBundle = renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish());
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
@ -258,9 +258,9 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
// Render bundle does not inherit bind groups so the draw is invalid. // Render bundle does not inherit bind groups so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
pass.SetBindGroup(0, bg0); pass.SetBindGroup(0, bg0);
pass.SetBindGroup(1, bg1); pass.SetBindGroup(1, bg1);
@ -268,7 +268,7 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer); renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
renderBundleEncoder.Draw(3, 0, 0, 0); renderBundleEncoder.Draw(3, 0, 0, 0);
ASSERT_DEVICE_ERROR(dawn::RenderBundle renderBundle = renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish());
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
@ -277,9 +277,9 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
// Render bundle does not inherit pipeline and bind groups so the draw is invalid. // Render bundle does not inherit pipeline and bind groups so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bg0); pass.SetBindGroup(0, bg0);
@ -287,7 +287,7 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer); renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
renderBundleEncoder.Draw(3, 0, 0, 0); renderBundleEncoder.Draw(3, 0, 0, 0);
ASSERT_DEVICE_ERROR(dawn::RenderBundle renderBundle = renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish());
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
@ -296,9 +296,9 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
// Render bundle does not inherit buffers so the draw is invalid. // Render bundle does not inherit buffers so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
@ -306,7 +306,7 @@ TEST_F(RenderBundleValidationTest, StateInheritance) {
renderBundleEncoder.SetBindGroup(0, bg0); renderBundleEncoder.SetBindGroup(0, bg0);
renderBundleEncoder.SetBindGroup(1, bg1); renderBundleEncoder.SetBindGroup(1, bg1);
renderBundleEncoder.Draw(3, 0, 0, 0); renderBundleEncoder.Draw(3, 0, 0, 0);
ASSERT_DEVICE_ERROR(dawn::RenderBundle renderBundle = renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish());
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
@ -324,12 +324,12 @@ TEST_F(RenderBundleValidationTest, StatePersistence) {
// Render bundle does not persist pipeline so the draw is invalid. // Render bundle does not persist pipeline so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.SetBindGroup(0, bg0); pass.SetBindGroup(0, bg0);
@ -343,13 +343,13 @@ TEST_F(RenderBundleValidationTest, StatePersistence) {
// Render bundle does not persist bind groups so the draw is invalid. // Render bundle does not persist bind groups so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetBindGroup(0, bg0); renderBundleEncoder.SetBindGroup(0, bg0);
renderBundleEncoder.SetBindGroup(1, bg1); renderBundleEncoder.SetBindGroup(1, bg1);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
@ -362,14 +362,14 @@ TEST_F(RenderBundleValidationTest, StatePersistence) {
// Render bundle does not persist pipeline and bind groups so the draw is invalid. // Render bundle does not persist pipeline and bind groups so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.SetBindGroup(0, bg0); renderBundleEncoder.SetBindGroup(0, bg0);
renderBundleEncoder.SetBindGroup(1, bg1); renderBundleEncoder.SetBindGroup(1, bg1);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
@ -381,12 +381,12 @@ TEST_F(RenderBundleValidationTest, StatePersistence) {
// Render bundle does not persist buffers so the draw is invalid. // Render bundle does not persist buffers so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer); renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
@ -407,13 +407,13 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = renderPass.attachmentFormat; desc.cColorFormats[0] = renderPass.attachmentFormat;
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
// Render bundle clears pipeline so the draw is invalid. // Render bundle clears pipeline so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
@ -428,8 +428,8 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
// Render bundle clears bind groups so the draw is invalid. // Render bundle clears bind groups so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetBindGroup(0, bg0); pass.SetBindGroup(0, bg0);
pass.SetBindGroup(1, bg1); pass.SetBindGroup(1, bg1);
@ -444,8 +444,8 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
// Render bundle clears pipeline and bind groups so the draw is invalid. // Render bundle clears pipeline and bind groups so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bg0); pass.SetBindGroup(0, bg0);
@ -460,8 +460,8 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
// Render bundle clears buffers so the draw is invalid. // Render bundle clears buffers so the draw is invalid.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetVertexBuffer(0, vertexBuffer); pass.SetVertexBuffer(0, vertexBuffer);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
@ -476,8 +476,8 @@ TEST_F(RenderBundleValidationTest, ClearsState) {
// Test executing 0 bundles does not clear command buffer state. // Test executing 0 bundles does not clear command buffer state.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bg0); pass.SetBindGroup(0, bg0);
@ -499,9 +499,9 @@ TEST_F(RenderBundleValidationTest, MultipleBundles) {
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = renderPass.attachmentFormat; desc.cColorFormats[0] = renderPass.attachmentFormat;
dawn::RenderBundle renderBundles[2] = {}; wgpu::RenderBundle renderBundles[2] = {};
dawn::RenderBundleEncoder renderBundleEncoder0 = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder0 = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder0.SetPipeline(pipeline); renderBundleEncoder0.SetPipeline(pipeline);
renderBundleEncoder0.SetBindGroup(0, bg0); renderBundleEncoder0.SetBindGroup(0, bg0);
renderBundleEncoder0.SetBindGroup(1, bg1); renderBundleEncoder0.SetBindGroup(1, bg1);
@ -509,7 +509,7 @@ TEST_F(RenderBundleValidationTest, MultipleBundles) {
renderBundleEncoder0.Draw(3, 1, 0, 0); renderBundleEncoder0.Draw(3, 1, 0, 0);
renderBundles[0] = renderBundleEncoder0.Finish(); renderBundles[0] = renderBundleEncoder0.Finish();
dawn::RenderBundleEncoder renderBundleEncoder1 = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder1 = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder1.SetPipeline(pipeline); renderBundleEncoder1.SetPipeline(pipeline);
renderBundleEncoder1.SetBindGroup(0, bg0); renderBundleEncoder1.SetBindGroup(0, bg0);
renderBundleEncoder1.SetBindGroup(1, bg1); renderBundleEncoder1.SetBindGroup(1, bg1);
@ -517,8 +517,8 @@ TEST_F(RenderBundleValidationTest, MultipleBundles) {
renderBundleEncoder1.Draw(3, 1, 0, 0); renderBundleEncoder1.Draw(3, 1, 0, 0);
renderBundles[1] = renderBundleEncoder1.Finish(); renderBundles[1] = renderBundleEncoder1.Finish();
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(2, renderBundles); pass.ExecuteBundles(2, renderBundles);
pass.EndPass(); pass.EndPass();
commandEncoder.Finish(); commandEncoder.Finish();
@ -532,16 +532,16 @@ TEST_F(RenderBundleValidationTest, ExecuteMultipleTimes) {
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = renderPass.attachmentFormat; desc.cColorFormats[0] = renderPass.attachmentFormat;
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.SetBindGroup(0, bg0); renderBundleEncoder.SetBindGroup(0, bg0);
renderBundleEncoder.SetBindGroup(1, bg1); renderBundleEncoder.SetBindGroup(1, bg1);
renderBundleEncoder.SetVertexBuffer(0, vertexBuffer); renderBundleEncoder.SetVertexBuffer(0, vertexBuffer);
renderBundleEncoder.Draw(3, 1, 0, 0); renderBundleEncoder.Draw(3, 1, 0, 0);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
@ -553,9 +553,9 @@ TEST_F(RenderBundleValidationTest, ExecuteMultipleTimes) {
TEST_F(RenderBundleValidationTest, FinishTwice) { TEST_F(RenderBundleValidationTest, FinishTwice) {
utils::ComboRenderBundleEncoderDescriptor desc = {}; utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = dawn::TextureFormat::RGBA8Uint; desc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Uint;
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.Finish(); renderBundleEncoder.Finish();
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
} }
@ -572,14 +572,14 @@ TEST_F(RenderBundleValidationTest, RequiresAtLeastOneTextureFormat) {
{ {
utils::ComboRenderBundleEncoderDescriptor desc = {}; utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = dawn::TextureFormat::RGBA8Uint; desc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Uint;
device.CreateRenderBundleEncoder(&desc); device.CreateRenderBundleEncoder(&desc);
} }
// Test success with a depth stencil format. // Test success with a depth stencil format.
{ {
utils::ComboRenderBundleEncoderDescriptor desc = {}; utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.depthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8; desc.depthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
device.CreateRenderBundleEncoder(&desc); device.CreateRenderBundleEncoder(&desc);
} }
} }
@ -588,14 +588,14 @@ TEST_F(RenderBundleValidationTest, RequiresAtLeastOneTextureFormat) {
TEST_F(RenderBundleValidationTest, ColorFormatUndefined) { TEST_F(RenderBundleValidationTest, ColorFormatUndefined) {
utils::ComboRenderBundleEncoderDescriptor desc = {}; utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = dawn::TextureFormat::Undefined; desc.cColorFormats[0] = wgpu::TextureFormat::Undefined;
ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc)); ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc));
} }
// Test that the render bundle depth stencil format cannot be set to undefined. // Test that the render bundle depth stencil format cannot be set to undefined.
TEST_F(RenderBundleValidationTest, DepthStencilFormatUndefined) { TEST_F(RenderBundleValidationTest, DepthStencilFormatUndefined) {
utils::ComboRenderBundleEncoderDescriptor desc = {}; utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.depthStencilFormat = dawn::TextureFormat::Undefined; desc.depthStencilFormat = wgpu::TextureFormat::Undefined;
ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc)); ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc));
} }
@ -607,12 +607,12 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = renderPass.attachmentFormat; desc.cColorFormats[0] = renderPass.attachmentFormat;
dawn::RenderBundle renderBundle0; wgpu::RenderBundle renderBundle0;
dawn::RenderBundle renderBundle1; wgpu::RenderBundle renderBundle1;
// First base case is successful. |bg1Vertex| does not reference |vertexBuffer|. // First base case is successful. |bg1Vertex| does not reference |vertexBuffer|.
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.SetBindGroup(0, bg0); renderBundleEncoder.SetBindGroup(0, bg0);
renderBundleEncoder.SetBindGroup(1, bg1Vertex); renderBundleEncoder.SetBindGroup(1, bg1Vertex);
@ -623,7 +623,7 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
// Second base case is successful. |bg1| does not reference |vertexStorageBuffer| // Second base case is successful. |bg1| does not reference |vertexStorageBuffer|
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.SetBindGroup(0, bg0); renderBundleEncoder.SetBindGroup(0, bg0);
renderBundleEncoder.SetBindGroup(1, bg1); renderBundleEncoder.SetBindGroup(1, bg1);
@ -635,7 +635,7 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
// Test that a render bundle which sets a buffer as both vertex and storage is invalid. // Test that a render bundle which sets a buffer as both vertex and storage is invalid.
// |bg1Vertex| references |vertexStorageBuffer| // |bg1Vertex| references |vertexStorageBuffer|
{ {
dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc); wgpu::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.SetBindGroup(0, bg0); renderBundleEncoder.SetBindGroup(0, bg0);
renderBundleEncoder.SetBindGroup(1, bg1Vertex); renderBundleEncoder.SetBindGroup(1, bg1Vertex);
@ -649,8 +649,8 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
// renderBundle0 uses |vertexStorageBuffer| as a storage buffer. // renderBundle0 uses |vertexStorageBuffer| as a storage buffer.
// renderBundle1 uses |vertexStorageBuffer| as a vertex buffer. // renderBundle1 uses |vertexStorageBuffer| as a vertex buffer.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle0); pass.ExecuteBundles(1, &renderBundle0);
pass.ExecuteBundles(1, &renderBundle1); pass.ExecuteBundles(1, &renderBundle1);
pass.EndPass(); pass.EndPass();
@ -661,8 +661,8 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
// The render pass uses |vertexStorageBuffer| as a storage buffer. // The render pass uses |vertexStorageBuffer| as a storage buffer.
// renderBundle1 uses |vertexStorageBuffer| as a vertex buffer. // renderBundle1 uses |vertexStorageBuffer| as a vertex buffer.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bg0); pass.SetBindGroup(0, bg0);
@ -679,8 +679,8 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
// renderBundle0 uses |vertexStorageBuffer| as a storage buffer. // renderBundle0 uses |vertexStorageBuffer| as a storage buffer.
// The render pass uses |vertexStorageBuffer| as a vertex buffer. // The render pass uses |vertexStorageBuffer| as a vertex buffer.
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle0); pass.ExecuteBundles(1, &renderBundle0);
@ -699,16 +699,16 @@ TEST_F(RenderBundleValidationTest, UsageTracking) {
TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) { TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) {
utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {}; utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {};
renderBundleDesc.colorFormatsCount = 3; renderBundleDesc.colorFormatsCount = 3;
renderBundleDesc.cColorFormats[0] = dawn::TextureFormat::RGBA8Unorm; renderBundleDesc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
renderBundleDesc.cColorFormats[1] = dawn::TextureFormat::RG16Float; renderBundleDesc.cColorFormats[1] = wgpu::TextureFormat::RG16Float;
renderBundleDesc.cColorFormats[2] = dawn::TextureFormat::R16Sint; renderBundleDesc.cColorFormats[2] = wgpu::TextureFormat::R16Sint;
auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) { auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) {
InitializeRenderPipelineDescriptor(desc); InitializeRenderPipelineDescriptor(desc);
desc->colorStateCount = 3; desc->colorStateCount = 3;
desc->cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; desc->cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
desc->cColorStates[1].format = dawn::TextureFormat::RG16Float; desc->cColorStates[1].format = wgpu::TextureFormat::RG16Float;
desc->cColorStates[2].format = dawn::TextureFormat::R16Sint; desc->cColorStates[2].format = wgpu::TextureFormat::R16Sint;
}; };
// Test the success case. // Test the success case.
@ -716,9 +716,9 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc); SetupRenderPipelineDescForTest(&desc);
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.Finish(); renderBundleEncoder.Finish();
} }
@ -727,11 +727,11 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) {
{ {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc); SetupRenderPipelineDescForTest(&desc);
desc.cColorStates[1].format = dawn::TextureFormat::RGBA8Unorm; desc.cColorStates[1].format = wgpu::TextureFormat::RGBA8Unorm;
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
} }
@ -742,9 +742,9 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) {
SetupRenderPipelineDescForTest(&desc); SetupRenderPipelineDescForTest(&desc);
desc.colorStateCount = 2; desc.colorStateCount = 2;
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
} }
@ -754,15 +754,15 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) {
TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) { TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) {
utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {}; utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {};
renderBundleDesc.colorFormatsCount = 1; renderBundleDesc.colorFormatsCount = 1;
renderBundleDesc.cColorFormats[0] = dawn::TextureFormat::RGBA8Unorm; renderBundleDesc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
renderBundleDesc.depthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8; renderBundleDesc.depthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) { auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) {
InitializeRenderPipelineDescriptor(desc); InitializeRenderPipelineDescriptor(desc);
desc->colorStateCount = 1; desc->colorStateCount = 1;
desc->cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; desc->cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
desc->depthStencilState = &desc->cDepthStencilState; desc->depthStencilState = &desc->cDepthStencilState;
desc->cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8; desc->cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
}; };
// Test the success case. // Test the success case.
@ -770,9 +770,9 @@ TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc); SetupRenderPipelineDescForTest(&desc);
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.Finish(); renderBundleEncoder.Finish();
} }
@ -781,11 +781,11 @@ TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) {
{ {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc); SetupRenderPipelineDescForTest(&desc);
desc.cDepthStencilState.format = dawn::TextureFormat::Depth24Plus; desc.cDepthStencilState.format = wgpu::TextureFormat::Depth24Plus;
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
} }
@ -796,9 +796,9 @@ TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) {
SetupRenderPipelineDescForTest(&desc); SetupRenderPipelineDescForTest(&desc);
desc.depthStencilState = nullptr; desc.depthStencilState = nullptr;
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
} }
@ -808,20 +808,20 @@ TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) {
TEST_F(RenderBundleValidationTest, PipelineSampleCountMismatch) { TEST_F(RenderBundleValidationTest, PipelineSampleCountMismatch) {
utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {}; utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {};
renderBundleDesc.colorFormatsCount = 1; renderBundleDesc.colorFormatsCount = 1;
renderBundleDesc.cColorFormats[0] = dawn::TextureFormat::RGBA8Unorm; renderBundleDesc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
renderBundleDesc.sampleCount = 4; renderBundleDesc.sampleCount = 4;
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); utils::ComboRenderPipelineDescriptor renderPipelineDesc(device);
InitializeRenderPipelineDescriptor(&renderPipelineDesc); InitializeRenderPipelineDescriptor(&renderPipelineDesc);
renderPipelineDesc.colorStateCount = 1; renderPipelineDesc.colorStateCount = 1;
renderPipelineDesc.cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; renderPipelineDesc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
renderPipelineDesc.sampleCount = 4; renderPipelineDesc.sampleCount = 4;
// Test the success case. // Test the success case.
{ {
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.Finish(); renderBundleEncoder.Finish();
} }
@ -830,9 +830,9 @@ TEST_F(RenderBundleValidationTest, PipelineSampleCountMismatch) {
{ {
renderPipelineDesc.sampleCount = 1; renderPipelineDesc.sampleCount = 1;
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish()); ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
} }
@ -842,26 +842,26 @@ TEST_F(RenderBundleValidationTest, PipelineSampleCountMismatch) {
TEST_F(RenderBundleValidationTest, RenderPassColorFormatMismatch) { TEST_F(RenderBundleValidationTest, RenderPassColorFormatMismatch) {
utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {}; utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {};
renderBundleDesc.colorFormatsCount = 3; renderBundleDesc.colorFormatsCount = 3;
renderBundleDesc.cColorFormats[0] = dawn::TextureFormat::RGBA8Unorm; renderBundleDesc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
renderBundleDesc.cColorFormats[1] = dawn::TextureFormat::RG16Float; renderBundleDesc.cColorFormats[1] = wgpu::TextureFormat::RG16Float;
renderBundleDesc.cColorFormats[2] = dawn::TextureFormat::R16Sint; renderBundleDesc.cColorFormats[2] = wgpu::TextureFormat::R16Sint;
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
dawn::TextureDescriptor textureDesc = {}; wgpu::TextureDescriptor textureDesc = {};
textureDesc.usage = dawn::TextureUsage::OutputAttachment; textureDesc.usage = wgpu::TextureUsage::OutputAttachment;
textureDesc.size = dawn::Extent3D({400, 400, 1}); textureDesc.size = wgpu::Extent3D({400, 400, 1});
textureDesc.format = dawn::TextureFormat::RGBA8Unorm; textureDesc.format = wgpu::TextureFormat::RGBA8Unorm;
dawn::Texture tex0 = device.CreateTexture(&textureDesc); wgpu::Texture tex0 = device.CreateTexture(&textureDesc);
textureDesc.format = dawn::TextureFormat::RG16Float; textureDesc.format = wgpu::TextureFormat::RG16Float;
dawn::Texture tex1 = device.CreateTexture(&textureDesc); wgpu::Texture tex1 = device.CreateTexture(&textureDesc);
textureDesc.format = dawn::TextureFormat::R16Sint; textureDesc.format = wgpu::TextureFormat::R16Sint;
dawn::Texture tex2 = device.CreateTexture(&textureDesc); wgpu::Texture tex2 = device.CreateTexture(&textureDesc);
// Test the success case // Test the success case
{ {
@ -871,8 +871,8 @@ TEST_F(RenderBundleValidationTest, RenderPassColorFormatMismatch) {
tex2.CreateView(), tex2.CreateView(),
}); });
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
commandEncoder.Finish(); commandEncoder.Finish();
@ -886,8 +886,8 @@ TEST_F(RenderBundleValidationTest, RenderPassColorFormatMismatch) {
tex0.CreateView(), tex0.CreateView(),
}); });
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(commandEncoder.Finish()); ASSERT_DEVICE_ERROR(commandEncoder.Finish());
@ -900,8 +900,8 @@ TEST_F(RenderBundleValidationTest, RenderPassColorFormatMismatch) {
tex1.CreateView(), tex1.CreateView(),
}); });
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(commandEncoder.Finish()); ASSERT_DEVICE_ERROR(commandEncoder.Finish());
@ -913,32 +913,32 @@ TEST_F(RenderBundleValidationTest, RenderPassColorFormatMismatch) {
TEST_F(RenderBundleValidationTest, RenderPassDepthStencilFormatMismatch) { TEST_F(RenderBundleValidationTest, RenderPassDepthStencilFormatMismatch) {
utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {}; utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {};
renderBundleDesc.colorFormatsCount = 1; renderBundleDesc.colorFormatsCount = 1;
renderBundleDesc.cColorFormats[0] = dawn::TextureFormat::RGBA8Unorm; renderBundleDesc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
renderBundleDesc.depthStencilFormat = dawn::TextureFormat::Depth24Plus; renderBundleDesc.depthStencilFormat = wgpu::TextureFormat::Depth24Plus;
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
dawn::TextureDescriptor textureDesc = {}; wgpu::TextureDescriptor textureDesc = {};
textureDesc.usage = dawn::TextureUsage::OutputAttachment; textureDesc.usage = wgpu::TextureUsage::OutputAttachment;
textureDesc.size = dawn::Extent3D({400, 400, 1}); textureDesc.size = wgpu::Extent3D({400, 400, 1});
textureDesc.format = dawn::TextureFormat::RGBA8Unorm; textureDesc.format = wgpu::TextureFormat::RGBA8Unorm;
dawn::Texture tex0 = device.CreateTexture(&textureDesc); wgpu::Texture tex0 = device.CreateTexture(&textureDesc);
textureDesc.format = dawn::TextureFormat::Depth24Plus; textureDesc.format = wgpu::TextureFormat::Depth24Plus;
dawn::Texture tex1 = device.CreateTexture(&textureDesc); wgpu::Texture tex1 = device.CreateTexture(&textureDesc);
textureDesc.format = dawn::TextureFormat::Depth32Float; textureDesc.format = wgpu::TextureFormat::Depth32Float;
dawn::Texture tex2 = device.CreateTexture(&textureDesc); wgpu::Texture tex2 = device.CreateTexture(&textureDesc);
// Test the success case // Test the success case
{ {
utils::ComboRenderPassDescriptor renderPass({tex0.CreateView()}, tex1.CreateView()); utils::ComboRenderPassDescriptor renderPass({tex0.CreateView()}, tex1.CreateView());
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
commandEncoder.Finish(); commandEncoder.Finish();
@ -948,8 +948,8 @@ TEST_F(RenderBundleValidationTest, RenderPassDepthStencilFormatMismatch) {
{ {
utils::ComboRenderPassDescriptor renderPass({tex0.CreateView()}, tex2.CreateView()); utils::ComboRenderPassDescriptor renderPass({tex0.CreateView()}, tex2.CreateView());
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(commandEncoder.Finish()); ASSERT_DEVICE_ERROR(commandEncoder.Finish());
@ -959,8 +959,8 @@ TEST_F(RenderBundleValidationTest, RenderPassDepthStencilFormatMismatch) {
{ {
utils::ComboRenderPassDescriptor renderPass({tex0.CreateView()}); utils::ComboRenderPassDescriptor renderPass({tex0.CreateView()});
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(commandEncoder.Finish()); ASSERT_DEVICE_ERROR(commandEncoder.Finish());
@ -971,28 +971,28 @@ TEST_F(RenderBundleValidationTest, RenderPassDepthStencilFormatMismatch) {
TEST_F(RenderBundleValidationTest, RenderPassSampleCountMismatch) { TEST_F(RenderBundleValidationTest, RenderPassSampleCountMismatch) {
utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {}; utils::ComboRenderBundleEncoderDescriptor renderBundleDesc = {};
renderBundleDesc.colorFormatsCount = 1; renderBundleDesc.colorFormatsCount = 1;
renderBundleDesc.cColorFormats[0] = dawn::TextureFormat::RGBA8Unorm; renderBundleDesc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
dawn::RenderBundleEncoder renderBundleEncoder = wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish(); wgpu::RenderBundle renderBundle = renderBundleEncoder.Finish();
dawn::TextureDescriptor textureDesc = {}; wgpu::TextureDescriptor textureDesc = {};
textureDesc.usage = dawn::TextureUsage::OutputAttachment; textureDesc.usage = wgpu::TextureUsage::OutputAttachment;
textureDesc.size = dawn::Extent3D({400, 400, 1}); textureDesc.size = wgpu::Extent3D({400, 400, 1});
textureDesc.format = dawn::TextureFormat::RGBA8Unorm; textureDesc.format = wgpu::TextureFormat::RGBA8Unorm;
dawn::Texture tex0 = device.CreateTexture(&textureDesc); wgpu::Texture tex0 = device.CreateTexture(&textureDesc);
textureDesc.sampleCount = 4; textureDesc.sampleCount = 4;
dawn::Texture tex1 = device.CreateTexture(&textureDesc); wgpu::Texture tex1 = device.CreateTexture(&textureDesc);
// Test the success case // Test the success case
{ {
utils::ComboRenderPassDescriptor renderPass({tex0.CreateView()}); utils::ComboRenderPassDescriptor renderPass({tex0.CreateView()});
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
commandEncoder.Finish(); commandEncoder.Finish();
@ -1002,8 +1002,8 @@ TEST_F(RenderBundleValidationTest, RenderPassSampleCountMismatch) {
{ {
utils::ComboRenderPassDescriptor renderPass({tex1.CreateView()}); utils::ComboRenderPassDescriptor renderPass({tex1.CreateView()});
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.ExecuteBundles(1, &renderBundle); pass.ExecuteBundles(1, &renderBundle);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(commandEncoder.Finish()); ASSERT_DEVICE_ERROR(commandEncoder.Finish());
@ -1017,7 +1017,7 @@ TEST_F(RenderBundleValidationTest, TextureFormats) {
{ {
utils::ComboRenderBundleEncoderDescriptor desc = {}; utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = dawn::TextureFormat::Depth24PlusStencil8; desc.cColorFormats[0] = wgpu::TextureFormat::Depth24PlusStencil8;
ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc)); ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc));
} }
@ -1025,14 +1025,14 @@ TEST_F(RenderBundleValidationTest, TextureFormats) {
{ {
utils::ComboRenderBundleEncoderDescriptor desc = {}; utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.colorFormatsCount = 1; desc.colorFormatsCount = 1;
desc.cColorFormats[0] = dawn::TextureFormat::RGBA8Snorm; desc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Snorm;
ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc)); ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc));
} }
// Test that depth/stencil formats are validated as depth/stencil. // Test that depth/stencil formats are validated as depth/stencil.
{ {
utils::ComboRenderBundleEncoderDescriptor desc = {}; utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.depthStencilFormat = dawn::TextureFormat::RGBA8Unorm; desc.depthStencilFormat = wgpu::TextureFormat::RGBA8Unorm;
ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc)); ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc));
} }

View File

@ -22,34 +22,34 @@ namespace {
class RenderPassDescriptorValidationTest : public ValidationTest { class RenderPassDescriptorValidationTest : public ValidationTest {
public: public:
void AssertBeginRenderPassSuccess(const dawn::RenderPassDescriptor* descriptor) { void AssertBeginRenderPassSuccess(const wgpu::RenderPassDescriptor* descriptor) {
dawn::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor); wgpu::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor);
commandEncoder.Finish(); commandEncoder.Finish();
} }
void AssertBeginRenderPassError(const dawn::RenderPassDescriptor* descriptor) { void AssertBeginRenderPassError(const wgpu::RenderPassDescriptor* descriptor) {
dawn::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor); wgpu::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor);
ASSERT_DEVICE_ERROR(commandEncoder.Finish()); ASSERT_DEVICE_ERROR(commandEncoder.Finish());
} }
private: private:
dawn::CommandEncoder TestBeginRenderPass(const dawn::RenderPassDescriptor* descriptor) { wgpu::CommandEncoder TestBeginRenderPass(const wgpu::RenderPassDescriptor* descriptor) {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(descriptor); wgpu::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(descriptor);
renderPassEncoder.EndPass(); renderPassEncoder.EndPass();
return commandEncoder; return commandEncoder;
} }
}; };
dawn::Texture CreateTexture(dawn::Device& device, wgpu::Texture CreateTexture(wgpu::Device& device,
dawn::TextureDimension dimension, wgpu::TextureDimension dimension,
dawn::TextureFormat format, wgpu::TextureFormat format,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
uint32_t arrayLayerCount, uint32_t arrayLayerCount,
uint32_t mipLevelCount, uint32_t mipLevelCount,
uint32_t sampleCount = 1, uint32_t sampleCount = 1,
dawn::TextureUsage usage = dawn::TextureUsage::OutputAttachment) { wgpu::TextureUsage usage = wgpu::TextureUsage::OutputAttachment) {
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.dimension = dimension; descriptor.dimension = dimension;
descriptor.size.width = width; descriptor.size.width = width;
descriptor.size.height = height; descriptor.size.height = height;
@ -63,12 +63,12 @@ dawn::Texture CreateTexture(dawn::Device& device,
return device.CreateTexture(&descriptor); return device.CreateTexture(&descriptor);
} }
dawn::TextureView Create2DAttachment(dawn::Device& device, wgpu::TextureView Create2DAttachment(wgpu::Device& device,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
dawn::TextureFormat format) { wgpu::TextureFormat format) {
dawn::Texture texture = CreateTexture( wgpu::Texture texture =
device, dawn::TextureDimension::e2D, format, width, height, 1, 1); CreateTexture(device, wgpu::TextureDimension::e2D, format, width, height, 1, 1);
return texture.CreateView(); return texture.CreateView();
} }
@ -82,15 +82,15 @@ TEST_F(RenderPassDescriptorValidationTest, Empty) {
TEST_F(RenderPassDescriptorValidationTest, OneAttachment) { TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
// One color attachment // One color attachment
{ {
dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
utils::ComboRenderPassDescriptor renderPass({color}); utils::ComboRenderPassDescriptor renderPass({color});
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// One depth-stencil attachment // One depth-stencil attachment
{ {
dawn::TextureView depthStencil = wgpu::TextureView depthStencil =
Create2DAttachment(device, 1, 1, dawn::TextureFormat::Depth24PlusStencil8); Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
utils::ComboRenderPassDescriptor renderPass({}, depthStencil); utils::ComboRenderPassDescriptor renderPass({}, depthStencil);
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
@ -99,10 +99,10 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
// Test OOB color attachment indices are handled // Test OOB color attachment indices are handled
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) { TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
dawn::TextureView color0 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color0 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
dawn::TextureView color1 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color1 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
dawn::TextureView color2 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color2 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
dawn::TextureView color3 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color3 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
// For setting the color attachment, control case // For setting the color attachment, control case
{ {
utils::ComboRenderPassDescriptor renderPass({color0, color1, color2, color3}); utils::ComboRenderPassDescriptor renderPass({color0, color1, color2, color3});
@ -112,12 +112,12 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
{ {
// We cannot use utils::ComboRenderPassDescriptor here because it only supports at most // We cannot use utils::ComboRenderPassDescriptor here because it only supports at most
// kMaxColorAttachments(4) color attachments. // kMaxColorAttachments(4) color attachments.
std::array<dawn::RenderPassColorAttachmentDescriptor, 5> colorAttachments; std::array<wgpu::RenderPassColorAttachmentDescriptor, 5> colorAttachments;
colorAttachments[0].attachment = color0; colorAttachments[0].attachment = color0;
colorAttachments[0].resolveTarget = nullptr; colorAttachments[0].resolveTarget = nullptr;
colorAttachments[0].clearColor = {0.0f, 0.0f, 0.0f, 0.0f}; colorAttachments[0].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
colorAttachments[0].loadOp = dawn::LoadOp::Clear; colorAttachments[0].loadOp = wgpu::LoadOp::Clear;
colorAttachments[0].storeOp = dawn::StoreOp::Store; colorAttachments[0].storeOp = wgpu::StoreOp::Store;
colorAttachments[1] = colorAttachments[0]; colorAttachments[1] = colorAttachments[0];
colorAttachments[1].attachment = color1; colorAttachments[1].attachment = color1;
@ -130,9 +130,9 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
colorAttachments[4] = colorAttachments[0]; colorAttachments[4] = colorAttachments[0];
colorAttachments[4].attachment = colorAttachments[4].attachment =
Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
dawn::RenderPassDescriptor renderPass; wgpu::RenderPassDescriptor renderPass;
renderPass.colorAttachmentCount = 5; renderPass.colorAttachmentCount = 5;
renderPass.colorAttachments = colorAttachments.data(); renderPass.colorAttachments = colorAttachments.data();
renderPass.depthStencilAttachment = nullptr; renderPass.depthStencilAttachment = nullptr;
@ -142,14 +142,14 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
// Attachments must have the same size // Attachments must have the same size
TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) { TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
dawn::TextureView color1x1A = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color1x1A = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
dawn::TextureView color1x1B = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color1x1B = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
dawn::TextureView color2x2 = Create2DAttachment(device, 2, 2, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color2x2 = Create2DAttachment(device, 2, 2, wgpu::TextureFormat::RGBA8Unorm);
dawn::TextureView depthStencil1x1 = wgpu::TextureView depthStencil1x1 =
Create2DAttachment(device, 1, 1, dawn::TextureFormat::Depth24PlusStencil8); Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
dawn::TextureView depthStencil2x2 = wgpu::TextureView depthStencil2x2 =
Create2DAttachment(device, 2, 2, dawn::TextureFormat::Depth24PlusStencil8); Create2DAttachment(device, 2, 2, wgpu::TextureFormat::Depth24PlusStencil8);
// Control case: all the same size (1x1) // Control case: all the same size (1x1)
{ {
@ -172,9 +172,9 @@ TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
// Attachments formats must match whether they are used for color or depth-stencil // Attachments formats must match whether they are used for color or depth-stencil
TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) { TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm); wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
dawn::TextureView depthStencil = wgpu::TextureView depthStencil =
Create2DAttachment(device, 1, 1, dawn::TextureFormat::Depth24PlusStencil8); Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
// Using depth-stencil for color // Using depth-stencil for color
{ {
@ -194,45 +194,45 @@ TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
constexpr uint32_t kArrayLayers = 1; constexpr uint32_t kArrayLayers = 1;
constexpr uint32_t kLevelCount = 1; constexpr uint32_t kLevelCount = 1;
constexpr uint32_t kSize = 32; constexpr uint32_t kSize = 32;
constexpr dawn::TextureFormat kColorFormat = dawn::TextureFormat::RGBA8Unorm; constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
constexpr dawn::TextureFormat kDepthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8; constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
dawn::Texture colorTexture = CreateTexture(device, dawn::TextureDimension::e2D, kColorFormat, wgpu::Texture colorTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
kSize, kSize, kArrayLayers, kLevelCount); kSize, kSize, kArrayLayers, kLevelCount);
dawn::Texture depthStencilTexture = wgpu::Texture depthStencilTexture =
CreateTexture(device, dawn::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize, CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kArrayLayers, kLevelCount); kArrayLayers, kLevelCount);
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.dimension = dawn::TextureViewDimension::e2D; descriptor.dimension = wgpu::TextureViewDimension::e2D;
descriptor.baseArrayLayer = 0; descriptor.baseArrayLayer = 0;
descriptor.arrayLayerCount = kArrayLayers; descriptor.arrayLayerCount = kArrayLayers;
descriptor.baseMipLevel = 0; descriptor.baseMipLevel = 0;
descriptor.mipLevelCount = kLevelCount; descriptor.mipLevelCount = kLevelCount;
dawn::TextureView colorTextureView = colorTexture.CreateView(&descriptor); wgpu::TextureView colorTextureView = colorTexture.CreateView(&descriptor);
dawn::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor); wgpu::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor);
// StoreOps mismatch causing the render pass to error // StoreOps mismatch causing the render pass to error
{ {
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
renderPass.cDepthStencilAttachmentInfo.stencilStoreOp = dawn::StoreOp::Store; renderPass.cDepthStencilAttachmentInfo.stencilStoreOp = wgpu::StoreOp::Store;
renderPass.cDepthStencilAttachmentInfo.depthStoreOp = dawn::StoreOp::Clear; renderPass.cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Clear;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
// StoreOps match so render pass is a success // StoreOps match so render pass is a success
{ {
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
renderPass.cDepthStencilAttachmentInfo.stencilStoreOp = dawn::StoreOp::Store; renderPass.cDepthStencilAttachmentInfo.stencilStoreOp = wgpu::StoreOp::Store;
renderPass.cDepthStencilAttachmentInfo.depthStoreOp = dawn::StoreOp::Store; renderPass.cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Store;
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// StoreOps match so render pass is a success // StoreOps match so render pass is a success
{ {
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
renderPass.cDepthStencilAttachmentInfo.stencilStoreOp = dawn::StoreOp::Clear; renderPass.cDepthStencilAttachmentInfo.stencilStoreOp = wgpu::StoreOp::Clear;
renderPass.cDepthStencilAttachmentInfo.depthStoreOp = dawn::StoreOp::Clear; renderPass.cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Clear;
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
} }
@ -242,19 +242,19 @@ TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepthStencil) { TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepthStencil) {
constexpr uint32_t kLevelCount = 1; constexpr uint32_t kLevelCount = 1;
constexpr uint32_t kSize = 32; constexpr uint32_t kSize = 32;
constexpr dawn::TextureFormat kColorFormat = dawn::TextureFormat::RGBA8Unorm; constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
constexpr dawn::TextureFormat kDepthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8; constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
constexpr uint32_t kArrayLayers = 10; constexpr uint32_t kArrayLayers = 10;
dawn::Texture colorTexture = CreateTexture( wgpu::Texture colorTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, kLevelCount); kSize, kSize, kArrayLayers, kLevelCount);
dawn::Texture depthStencilTexture = CreateTexture( wgpu::Texture depthStencilTexture =
device, dawn::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize, kArrayLayers, CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kLevelCount); kArrayLayers, kLevelCount);
dawn::TextureViewDescriptor baseDescriptor; wgpu::TextureViewDescriptor baseDescriptor;
baseDescriptor.dimension = dawn::TextureViewDimension::e2DArray; baseDescriptor.dimension = wgpu::TextureViewDimension::e2DArray;
baseDescriptor.baseArrayLayer = 0; baseDescriptor.baseArrayLayer = 0;
baseDescriptor.arrayLayerCount = kArrayLayers; baseDescriptor.arrayLayerCount = kArrayLayers;
baseDescriptor.baseMipLevel = 0; baseDescriptor.baseMipLevel = 0;
@ -262,70 +262,70 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
// Using 2D array texture view with arrayLayerCount > 1 is not allowed for color // Using 2D array texture view with arrayLayerCount > 1 is not allowed for color
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kColorFormat; descriptor.format = kColorFormat;
descriptor.arrayLayerCount = 5; descriptor.arrayLayerCount = 5;
dawn::TextureView colorTextureView = colorTexture.CreateView(&descriptor); wgpu::TextureView colorTextureView = colorTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({colorTextureView}); utils::ComboRenderPassDescriptor renderPass({colorTextureView});
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
// Using 2D array texture view with arrayLayerCount > 1 is not allowed for depth stencil // Using 2D array texture view with arrayLayerCount > 1 is not allowed for depth stencil
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kDepthStencilFormat; descriptor.format = kDepthStencilFormat;
descriptor.arrayLayerCount = 5; descriptor.arrayLayerCount = 5;
dawn::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor); wgpu::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
// Using 2D array texture view that covers the first layer of the texture is OK for color // Using 2D array texture view that covers the first layer of the texture is OK for color
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kColorFormat; descriptor.format = kColorFormat;
descriptor.baseArrayLayer = 0; descriptor.baseArrayLayer = 0;
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
dawn::TextureView colorTextureView = colorTexture.CreateView(&descriptor); wgpu::TextureView colorTextureView = colorTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({colorTextureView}); utils::ComboRenderPassDescriptor renderPass({colorTextureView});
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// Using 2D array texture view that covers the first layer is OK for depth stencil // Using 2D array texture view that covers the first layer is OK for depth stencil
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kDepthStencilFormat; descriptor.format = kDepthStencilFormat;
descriptor.baseArrayLayer = 0; descriptor.baseArrayLayer = 0;
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
dawn::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor); wgpu::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// Using 2D array texture view that covers the last layer is OK for color // Using 2D array texture view that covers the last layer is OK for color
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kColorFormat; descriptor.format = kColorFormat;
descriptor.baseArrayLayer = kArrayLayers - 1; descriptor.baseArrayLayer = kArrayLayers - 1;
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
dawn::TextureView colorTextureView = colorTexture.CreateView(&descriptor); wgpu::TextureView colorTextureView = colorTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({colorTextureView}); utils::ComboRenderPassDescriptor renderPass({colorTextureView});
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// Using 2D array texture view that covers the last layer is OK for depth stencil // Using 2D array texture view that covers the last layer is OK for depth stencil
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kDepthStencilFormat; descriptor.format = kDepthStencilFormat;
descriptor.baseArrayLayer = kArrayLayers - 1; descriptor.baseArrayLayer = kArrayLayers - 1;
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
dawn::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor); wgpu::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
@ -335,19 +335,19 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepthStencil) { TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepthStencil) {
constexpr uint32_t kArrayLayers = 1; constexpr uint32_t kArrayLayers = 1;
constexpr uint32_t kSize = 32; constexpr uint32_t kSize = 32;
constexpr dawn::TextureFormat kColorFormat = dawn::TextureFormat::RGBA8Unorm; constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
constexpr dawn::TextureFormat kDepthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8; constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
constexpr uint32_t kLevelCount = 4; constexpr uint32_t kLevelCount = 4;
dawn::Texture colorTexture = CreateTexture( wgpu::Texture colorTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, kLevelCount); kSize, kSize, kArrayLayers, kLevelCount);
dawn::Texture depthStencilTexture = CreateTexture( wgpu::Texture depthStencilTexture =
device, dawn::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize, kArrayLayers, CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kLevelCount); kArrayLayers, kLevelCount);
dawn::TextureViewDescriptor baseDescriptor; wgpu::TextureViewDescriptor baseDescriptor;
baseDescriptor.dimension = dawn::TextureViewDimension::e2D; baseDescriptor.dimension = wgpu::TextureViewDimension::e2D;
baseDescriptor.baseArrayLayer = 0; baseDescriptor.baseArrayLayer = 0;
baseDescriptor.arrayLayerCount = kArrayLayers; baseDescriptor.arrayLayerCount = kArrayLayers;
baseDescriptor.baseMipLevel = 0; baseDescriptor.baseMipLevel = 0;
@ -355,70 +355,70 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
// Using 2D texture view with mipLevelCount > 1 is not allowed for color // Using 2D texture view with mipLevelCount > 1 is not allowed for color
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kColorFormat; descriptor.format = kColorFormat;
descriptor.mipLevelCount = 2; descriptor.mipLevelCount = 2;
dawn::TextureView colorTextureView = colorTexture.CreateView(&descriptor); wgpu::TextureView colorTextureView = colorTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({colorTextureView}); utils::ComboRenderPassDescriptor renderPass({colorTextureView});
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
// Using 2D texture view with mipLevelCount > 1 is not allowed for depth stencil // Using 2D texture view with mipLevelCount > 1 is not allowed for depth stencil
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kDepthStencilFormat; descriptor.format = kDepthStencilFormat;
descriptor.mipLevelCount = 2; descriptor.mipLevelCount = 2;
dawn::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor); wgpu::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
// Using 2D texture view that covers the first level of the texture is OK for color // Using 2D texture view that covers the first level of the texture is OK for color
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kColorFormat; descriptor.format = kColorFormat;
descriptor.baseMipLevel = 0; descriptor.baseMipLevel = 0;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
dawn::TextureView colorTextureView = colorTexture.CreateView(&descriptor); wgpu::TextureView colorTextureView = colorTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({colorTextureView}); utils::ComboRenderPassDescriptor renderPass({colorTextureView});
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// Using 2D texture view that covers the first level is OK for depth stencil // Using 2D texture view that covers the first level is OK for depth stencil
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kDepthStencilFormat; descriptor.format = kDepthStencilFormat;
descriptor.baseMipLevel = 0; descriptor.baseMipLevel = 0;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
dawn::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor); wgpu::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// Using 2D texture view that covers the last level is OK for color // Using 2D texture view that covers the last level is OK for color
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kColorFormat; descriptor.format = kColorFormat;
descriptor.baseMipLevel = kLevelCount - 1; descriptor.baseMipLevel = kLevelCount - 1;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
dawn::TextureView colorTextureView = colorTexture.CreateView(&descriptor); wgpu::TextureView colorTextureView = colorTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({colorTextureView}); utils::ComboRenderPassDescriptor renderPass({colorTextureView});
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// Using 2D texture view that covers the last level is OK for depth stencil // Using 2D texture view that covers the last level is OK for depth stencil
{ {
dawn::TextureViewDescriptor descriptor = baseDescriptor; wgpu::TextureViewDescriptor descriptor = baseDescriptor;
descriptor.format = kDepthStencilFormat; descriptor.format = kDepthStencilFormat;
descriptor.baseMipLevel = kLevelCount - 1; descriptor.baseMipLevel = kLevelCount - 1;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
dawn::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor); wgpu::TextureView depthStencilView = depthStencilTexture.CreateView(&descriptor);
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView); utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
@ -430,16 +430,16 @@ TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget
static constexpr uint32_t kLevelCount = 1; static constexpr uint32_t kLevelCount = 1;
static constexpr uint32_t kSize = 32; static constexpr uint32_t kSize = 32;
static constexpr uint32_t kSampleCount = 1; static constexpr uint32_t kSampleCount = 1;
static constexpr dawn::TextureFormat kColorFormat = dawn::TextureFormat::RGBA8Unorm; static constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
dawn::Texture colorTexture = CreateTexture( wgpu::Texture colorTexture =
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
kLevelCount, kSampleCount); kLevelCount, kSampleCount);
dawn::Texture resolveTargetTexture = CreateTexture( wgpu::Texture resolveTargetTexture =
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
kLevelCount, kSampleCount); kLevelCount, kSampleCount);
dawn::TextureView colorTextureView = colorTexture.CreateView(); wgpu::TextureView colorTextureView = colorTexture.CreateView();
dawn::TextureView resolveTargetTextureView = resolveTargetTexture.CreateView(); wgpu::TextureView resolveTargetTextureView = resolveTargetTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass({colorTextureView}); utils::ComboRenderPassDescriptor renderPass({colorTextureView});
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
@ -452,11 +452,11 @@ class MultisampledRenderPassDescriptorValidationTest : public RenderPassDescript
return utils::ComboRenderPassDescriptor({CreateMultisampledColorTextureView()}); return utils::ComboRenderPassDescriptor({CreateMultisampledColorTextureView()});
} }
dawn::TextureView CreateMultisampledColorTextureView() { wgpu::TextureView CreateMultisampledColorTextureView() {
return CreateColorTextureView(kSampleCount); return CreateColorTextureView(kSampleCount);
} }
dawn::TextureView CreateNonMultisampledColorTextureView() { wgpu::TextureView CreateNonMultisampledColorTextureView() {
return CreateColorTextureView(1); return CreateColorTextureView(1);
} }
@ -464,13 +464,13 @@ class MultisampledRenderPassDescriptorValidationTest : public RenderPassDescript
static constexpr uint32_t kLevelCount = 1; static constexpr uint32_t kLevelCount = 1;
static constexpr uint32_t kSize = 32; static constexpr uint32_t kSize = 32;
static constexpr uint32_t kSampleCount = 4; static constexpr uint32_t kSampleCount = 4;
static constexpr dawn::TextureFormat kColorFormat = dawn::TextureFormat::RGBA8Unorm; static constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
private: private:
dawn::TextureView CreateColorTextureView(uint32_t sampleCount) { wgpu::TextureView CreateColorTextureView(uint32_t sampleCount) {
dawn::Texture colorTexture = CreateTexture( wgpu::Texture colorTexture =
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kLevelCount, sampleCount); kArrayLayers, kLevelCount, sampleCount);
return colorTexture.CreateView(); return colorTexture.CreateView();
} }
@ -478,9 +478,9 @@ class MultisampledRenderPassDescriptorValidationTest : public RenderPassDescript
// Tests on the use of multisampled textures as color attachments // Tests on the use of multisampled textures as color attachments
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachments) { TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachments) {
dawn::TextureView colorTextureView = CreateNonMultisampledColorTextureView(); wgpu::TextureView colorTextureView = CreateNonMultisampledColorTextureView();
dawn::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView(); wgpu::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
dawn::TextureView multisampledColorTextureView = CreateMultisampledColorTextureView(); wgpu::TextureView multisampledColorTextureView = CreateMultisampledColorTextureView();
// It is allowed to use a multisampled color attachment without setting resolve target. // It is allowed to use a multisampled color attachment without setting resolve target.
{ {
@ -498,7 +498,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachme
// It is not allowed to use a multisampled resolve target. // It is not allowed to use a multisampled resolve target.
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget) { TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget) {
dawn::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView(); wgpu::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = multisampledResolveTargetView; renderPass.cColorAttachments[0].resolveTarget = multisampledResolveTargetView;
@ -508,10 +508,9 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget
// It is not allowed to use a resolve target with array layer count > 1. // It is not allowed to use a resolve target with array layer count > 1.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMoreThanOne) { TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMoreThanOne) {
constexpr uint32_t kArrayLayers2 = 2; constexpr uint32_t kArrayLayers2 = 2;
dawn::Texture resolveTexture = CreateTexture( wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers2, kSize, kSize, kArrayLayers2, kLevelCount);
kLevelCount); wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
@ -521,10 +520,9 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMo
// It is not allowed to use a resolve target with mipmap level count > 1. // It is not allowed to use a resolve target with mipmap level count > 1.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelMoreThanOne) { TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelMoreThanOne) {
constexpr uint32_t kLevelCount2 = 2; constexpr uint32_t kLevelCount2 = 2;
dawn::Texture resolveTexture = CreateTexture( wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, kSize, kSize, kArrayLayers, kLevelCount2);
kLevelCount2); wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
@ -532,13 +530,13 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelM
} }
// It is not allowed to use a resolve target which is created from a texture whose usage does not // It is not allowed to use a resolve target which is created from a texture whose usage does not
// include dawn::TextureUsage::OutputAttachment. // include wgpu::TextureUsage::OutputAttachment.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutputAttachment) { TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutputAttachment) {
constexpr dawn::TextureUsage kUsage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::CopySrc; constexpr wgpu::TextureUsage kUsage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc;
dawn::Texture nonColorUsageResolveTexture = CreateTexture( wgpu::Texture nonColorUsageResolveTexture =
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
kLevelCount, 1, kUsage); kLevelCount, 1, kUsage);
dawn::TextureView nonColorUsageResolveTextureView = nonColorUsageResolveTexture.CreateView(); wgpu::TextureView nonColorUsageResolveTextureView = nonColorUsageResolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = nonColorUsageResolveTextureView; renderPass.cColorAttachments[0].resolveTarget = nonColorUsageResolveTextureView;
@ -547,16 +545,14 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutpu
// It is not allowed to use a resolve target which is in error state. // It is not allowed to use a resolve target which is in error state.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState) { TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState) {
dawn::Texture resolveTexture = CreateTexture( wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, kSize, kSize, kArrayLayers, kLevelCount);
kLevelCount); wgpu::TextureViewDescriptor errorTextureView;
dawn::TextureViewDescriptor errorTextureView; errorTextureView.dimension = wgpu::TextureViewDimension::e2D;
errorTextureView.dimension = dawn::TextureViewDimension::e2D;
errorTextureView.format = kColorFormat; errorTextureView.format = kColorFormat;
errorTextureView.baseArrayLayer = kArrayLayers + 1; errorTextureView.baseArrayLayer = kArrayLayers + 1;
ASSERT_DEVICE_ERROR( ASSERT_DEVICE_ERROR(wgpu::TextureView errorResolveTarget =
dawn::TextureView errorResolveTarget = resolveTexture.CreateView(&errorTextureView));
resolveTexture.CreateView(&errorTextureView));
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = errorResolveTarget; renderPass.cColorAttachments[0].resolveTarget = errorResolveTarget;
@ -565,7 +561,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState
// It is allowed to use a multisampled color attachment and a non-multisampled resolve target. // It is allowed to use a multisampled color attachment and a non-multisampled resolve target.
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithResolveTarget) { TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithResolveTarget) {
dawn::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView(); wgpu::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
@ -574,11 +570,10 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithReso
// It is not allowed to use a resolve target in a format different from the color attachment. // It is not allowed to use a resolve target in a format different from the color attachment.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFormat) { TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFormat) {
constexpr dawn::TextureFormat kColorFormat2 = dawn::TextureFormat::BGRA8Unorm; constexpr wgpu::TextureFormat kColorFormat2 = wgpu::TextureFormat::BGRA8Unorm;
dawn::Texture resolveTexture = CreateTexture( wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat2,
device, dawn::TextureDimension::e2D, kColorFormat2, kSize, kSize, kArrayLayers, kSize, kSize, kArrayLayers, kLevelCount);
kLevelCount); wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
@ -588,24 +583,22 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFor
// Tests on the size of the resolve target. // Tests on the size of the resolve target.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTargetCompatibility) { TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTargetCompatibility) {
constexpr uint32_t kSize2 = kSize * 2; constexpr uint32_t kSize2 = kSize * 2;
dawn::Texture resolveTexture = CreateTexture( wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
device, dawn::TextureDimension::e2D, kColorFormat, kSize2, kSize2, kArrayLayers, kSize2, kSize2, kArrayLayers, kLevelCount + 1);
kLevelCount + 1);
dawn::TextureViewDescriptor textureViewDescriptor; wgpu::TextureViewDescriptor textureViewDescriptor;
textureViewDescriptor.nextInChain = nullptr; textureViewDescriptor.nextInChain = nullptr;
textureViewDescriptor.dimension = dawn::TextureViewDimension::e2D; textureViewDescriptor.dimension = wgpu::TextureViewDimension::e2D;
textureViewDescriptor.format = kColorFormat; textureViewDescriptor.format = kColorFormat;
textureViewDescriptor.mipLevelCount = 1; textureViewDescriptor.mipLevelCount = 1;
textureViewDescriptor.baseArrayLayer = 0; textureViewDescriptor.baseArrayLayer = 0;
textureViewDescriptor.arrayLayerCount = 1; textureViewDescriptor.arrayLayerCount = 1;
{ {
dawn::TextureViewDescriptor firstMipLevelDescriptor = textureViewDescriptor; wgpu::TextureViewDescriptor firstMipLevelDescriptor = textureViewDescriptor;
firstMipLevelDescriptor.baseMipLevel = 0; firstMipLevelDescriptor.baseMipLevel = 0;
dawn::TextureView resolveTextureView = wgpu::TextureView resolveTextureView = resolveTexture.CreateView(&firstMipLevelDescriptor);
resolveTexture.CreateView(&firstMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
@ -613,11 +606,10 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
} }
{ {
dawn::TextureViewDescriptor secondMipLevelDescriptor = textureViewDescriptor; wgpu::TextureViewDescriptor secondMipLevelDescriptor = textureViewDescriptor;
secondMipLevelDescriptor.baseMipLevel = 1; secondMipLevelDescriptor.baseMipLevel = 1;
dawn::TextureView resolveTextureView = wgpu::TextureView resolveTextureView = resolveTexture.CreateView(&secondMipLevelDescriptor);
resolveTexture.CreateView(&secondMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
@ -627,20 +619,20 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
// Tests on the sample count of depth stencil attachment. // Tests on the sample count of depth stencil attachment.
TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSampleCount) { TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSampleCount) {
constexpr dawn::TextureFormat kDepthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8; constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
dawn::Texture multisampledDepthStencilTexture = CreateTexture( wgpu::Texture multisampledDepthStencilTexture =
device, dawn::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize, kArrayLayers, CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kLevelCount, kSampleCount); kArrayLayers, kLevelCount, kSampleCount);
dawn::TextureView multisampledDepthStencilTextureView = wgpu::TextureView multisampledDepthStencilTextureView =
multisampledDepthStencilTexture.CreateView(); multisampledDepthStencilTexture.CreateView();
// It is not allowed to use a depth stencil attachment whose sample count is different from the // It is not allowed to use a depth stencil attachment whose sample count is different from the
// one of the color attachment. // one of the color attachment.
{ {
dawn::Texture depthStencilTexture = CreateTexture( wgpu::Texture depthStencilTexture =
device, dawn::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize, kArrayLayers, CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kLevelCount); kArrayLayers, kLevelCount);
dawn::TextureView depthStencilTextureView = depthStencilTexture.CreateView(); wgpu::TextureView depthStencilTextureView = depthStencilTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass( utils::ComboRenderPassDescriptor renderPass(
{CreateMultisampledColorTextureView()}, depthStencilTextureView); {CreateMultisampledColorTextureView()}, depthStencilTextureView);

View File

@ -25,7 +25,7 @@ class RenderPassValidationTest : public ValidationTest {};
// Test that it is invalid to draw in a render pass with missing bind groups // Test that it is invalid to draw in a render pass with missing bind groups
TEST_F(RenderPassValidationTest, MissingBindGroup) { TEST_F(RenderPassValidationTest, MissingBindGroup) {
dawn::ShaderModule vsModule = wgpu::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450 #version 450
layout (set = 0, binding = 0) uniform vertexUniformBuffer { layout (set = 0, binding = 0) uniform vertexUniformBuffer {
@ -36,7 +36,7 @@ void main() {
gl_Position = vec4(transform * pos[gl_VertexIndex], 0.f, 1.f); gl_Position = vec4(transform * pos[gl_VertexIndex], 0.f, 1.f);
})"); })");
dawn::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450 #version 450
layout (set = 1, binding = 0) uniform fragmentUniformBuffer { layout (set = 1, binding = 0) uniform fragmentUniformBuffer {
@ -47,38 +47,38 @@ void main() {
fragColor = color; fragColor = color;
})"); })");
dawn::BindGroupLayout bgls[] = { wgpu::BindGroupLayout bgls[] = {
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer}}), device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}),
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::UniformBuffer}})}; device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}})};
dawn::PipelineLayoutDescriptor pipelineLayoutDesc; wgpu::PipelineLayoutDescriptor pipelineLayoutDesc;
pipelineLayoutDesc.bindGroupLayoutCount = 2; pipelineLayoutDesc.bindGroupLayoutCount = 2;
pipelineLayoutDesc.bindGroupLayouts = bgls; pipelineLayoutDesc.bindGroupLayouts = bgls;
dawn::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&pipelineLayoutDesc); wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&pipelineLayoutDesc);
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.layout = pipelineLayout; descriptor.layout = pipelineLayout;
descriptor.vertexStage.module = vsModule; descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragmentStage.module = fsModule;
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
float data[4]; float data[4];
dawn::Buffer buffer = wgpu::Buffer buffer =
utils::CreateBufferFromData(device, data, 4 * sizeof(float), dawn::BufferUsage::Uniform); utils::CreateBufferFromData(device, data, 4 * sizeof(float), wgpu::BufferUsage::Uniform);
dawn::BindGroup bg1 = wgpu::BindGroup bg1 =
utils::MakeBindGroup(device, bgls[0], {{0, buffer, 0, 4 * sizeof(float)}}); utils::MakeBindGroup(device, bgls[0], {{0, buffer, 0, 4 * sizeof(float)}});
dawn::BindGroup bg2 = wgpu::BindGroup bg2 =
utils::MakeBindGroup(device, bgls[1], {{0, buffer, 0, 4 * sizeof(float)}}); utils::MakeBindGroup(device, bgls[1], {{0, buffer, 0, 4 * sizeof(float)}});
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bg1); pass.SetBindGroup(0, bg1);
pass.SetBindGroup(1, bg2); pass.SetBindGroup(1, bg2);
@ -87,16 +87,16 @@ void main() {
commandEncoder.Finish(); commandEncoder.Finish();
} }
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.Draw(3, 0, 0, 0); pass.Draw(3, 0, 0, 0);
pass.EndPass(); pass.EndPass();
ASSERT_DEVICE_ERROR(commandEncoder.Finish()); ASSERT_DEVICE_ERROR(commandEncoder.Finish());
} }
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(1, bg2); pass.SetBindGroup(1, bg2);
pass.Draw(3, 0, 0, 0); pass.Draw(3, 0, 0, 0);
@ -104,8 +104,8 @@ void main() {
ASSERT_DEVICE_ERROR(commandEncoder.Finish()); ASSERT_DEVICE_ERROR(commandEncoder.Finish());
} }
{ {
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
pass.SetBindGroup(0, bg1); pass.SetBindGroup(0, bg1);
pass.Draw(3, 0, 0, 0); pass.Draw(3, 0, 0, 0);

View File

@ -39,8 +39,8 @@ class RenderPipelineValidationTest : public ValidationTest {
})"); })");
} }
dawn::ShaderModule vsModule; wgpu::ShaderModule vsModule;
dawn::ShaderModule fsModule; wgpu::ShaderModule fsModule;
}; };
// Test cases where creation should succeed // Test cases where creation should succeed
@ -100,7 +100,7 @@ TEST_F(RenderPipelineValidationTest, NonRenderableFormat) {
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule; descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragmentStage.module = fsModule;
descriptor.cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; descriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
device.CreateRenderPipeline(&descriptor); device.CreateRenderPipeline(&descriptor);
} }
@ -110,7 +110,7 @@ TEST_F(RenderPipelineValidationTest, NonRenderableFormat) {
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule; descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragmentStage.module = fsModule;
descriptor.cColorStates[0].format = dawn::TextureFormat::RG11B10Float; descriptor.cColorStates[0].format = wgpu::TextureFormat::RG11B10Float;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
} }
@ -120,9 +120,9 @@ TEST_F(RenderPipelineValidationTest, NonRenderableFormat) {
TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) { TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) {
constexpr uint32_t kNumTextureFormatBaseType = 3u; constexpr uint32_t kNumTextureFormatBaseType = 3u;
std::array<const char*, kNumTextureFormatBaseType> kVecPreFix = {{"", "i", "u"}}; std::array<const char*, kNumTextureFormatBaseType> kVecPreFix = {{"", "i", "u"}};
std::array<dawn::TextureFormat, kNumTextureFormatBaseType> kColorFormats = { std::array<wgpu::TextureFormat, kNumTextureFormatBaseType> kColorFormats = {
{dawn::TextureFormat::RGBA8Unorm, dawn::TextureFormat::RGBA8Sint, {wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureFormat::RGBA8Sint,
dawn::TextureFormat::RGBA8Uint}}; wgpu::TextureFormat::RGBA8Uint}};
for (size_t i = 0; i < kNumTextureFormatBaseType; ++i) { for (size_t i = 0; i < kNumTextureFormatBaseType; ++i) {
for (size_t j = 0; j < kNumTextureFormatBaseType; ++j) { for (size_t j = 0; j < kNumTextureFormatBaseType; ++j) {
@ -174,56 +174,56 @@ TEST_F(RenderPipelineValidationTest, SampleCount) {
// in the render pass. // in the render pass.
TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) { TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
constexpr uint32_t kMultisampledCount = 4; constexpr uint32_t kMultisampledCount = 4;
constexpr dawn::TextureFormat kColorFormat = dawn::TextureFormat::RGBA8Unorm; constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
constexpr dawn::TextureFormat kDepthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8; constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
dawn::TextureDescriptor baseTextureDescriptor; wgpu::TextureDescriptor baseTextureDescriptor;
baseTextureDescriptor.size.width = 4; baseTextureDescriptor.size.width = 4;
baseTextureDescriptor.size.height = 4; baseTextureDescriptor.size.height = 4;
baseTextureDescriptor.size.depth = 1; baseTextureDescriptor.size.depth = 1;
baseTextureDescriptor.arrayLayerCount = 1; baseTextureDescriptor.arrayLayerCount = 1;
baseTextureDescriptor.mipLevelCount = 1; baseTextureDescriptor.mipLevelCount = 1;
baseTextureDescriptor.dimension = dawn::TextureDimension::e2D; baseTextureDescriptor.dimension = wgpu::TextureDimension::e2D;
baseTextureDescriptor.usage = dawn::TextureUsage::OutputAttachment; baseTextureDescriptor.usage = wgpu::TextureUsage::OutputAttachment;
utils::ComboRenderPipelineDescriptor nonMultisampledPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor nonMultisampledPipelineDescriptor(device);
nonMultisampledPipelineDescriptor.sampleCount = 1; nonMultisampledPipelineDescriptor.sampleCount = 1;
nonMultisampledPipelineDescriptor.vertexStage.module = vsModule; nonMultisampledPipelineDescriptor.vertexStage.module = vsModule;
nonMultisampledPipelineDescriptor.cFragmentStage.module = fsModule; nonMultisampledPipelineDescriptor.cFragmentStage.module = fsModule;
dawn::RenderPipeline nonMultisampledPipeline = wgpu::RenderPipeline nonMultisampledPipeline =
device.CreateRenderPipeline(&nonMultisampledPipelineDescriptor); device.CreateRenderPipeline(&nonMultisampledPipelineDescriptor);
nonMultisampledPipelineDescriptor.colorStateCount = 0; nonMultisampledPipelineDescriptor.colorStateCount = 0;
nonMultisampledPipelineDescriptor.depthStencilState = nonMultisampledPipelineDescriptor.depthStencilState =
&nonMultisampledPipelineDescriptor.cDepthStencilState; &nonMultisampledPipelineDescriptor.cDepthStencilState;
dawn::RenderPipeline nonMultisampledPipelineWithDepthStencilOnly = wgpu::RenderPipeline nonMultisampledPipelineWithDepthStencilOnly =
device.CreateRenderPipeline(&nonMultisampledPipelineDescriptor); device.CreateRenderPipeline(&nonMultisampledPipelineDescriptor);
utils::ComboRenderPipelineDescriptor multisampledPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor multisampledPipelineDescriptor(device);
multisampledPipelineDescriptor.sampleCount = kMultisampledCount; multisampledPipelineDescriptor.sampleCount = kMultisampledCount;
multisampledPipelineDescriptor.vertexStage.module = vsModule; multisampledPipelineDescriptor.vertexStage.module = vsModule;
multisampledPipelineDescriptor.cFragmentStage.module = fsModule; multisampledPipelineDescriptor.cFragmentStage.module = fsModule;
dawn::RenderPipeline multisampledPipeline = wgpu::RenderPipeline multisampledPipeline =
device.CreateRenderPipeline(&multisampledPipelineDescriptor); device.CreateRenderPipeline(&multisampledPipelineDescriptor);
multisampledPipelineDescriptor.colorStateCount = 0; multisampledPipelineDescriptor.colorStateCount = 0;
multisampledPipelineDescriptor.depthStencilState = multisampledPipelineDescriptor.depthStencilState =
&multisampledPipelineDescriptor.cDepthStencilState; &multisampledPipelineDescriptor.cDepthStencilState;
dawn::RenderPipeline multisampledPipelineWithDepthStencilOnly = wgpu::RenderPipeline multisampledPipelineWithDepthStencilOnly =
device.CreateRenderPipeline(&multisampledPipelineDescriptor); device.CreateRenderPipeline(&multisampledPipelineDescriptor);
// It is not allowed to use multisampled render pass and non-multisampled render pipeline. // It is not allowed to use multisampled render pass and non-multisampled render pipeline.
{ {
{ {
dawn::TextureDescriptor textureDescriptor = baseTextureDescriptor; wgpu::TextureDescriptor textureDescriptor = baseTextureDescriptor;
textureDescriptor.format = kColorFormat; textureDescriptor.format = kColorFormat;
textureDescriptor.sampleCount = kMultisampledCount; textureDescriptor.sampleCount = kMultisampledCount;
dawn::Texture multisampledColorTexture = device.CreateTexture(&textureDescriptor); wgpu::Texture multisampledColorTexture = device.CreateTexture(&textureDescriptor);
utils::ComboRenderPassDescriptor renderPassDescriptor( utils::ComboRenderPassDescriptor renderPassDescriptor(
{multisampledColorTexture.CreateView()}); {multisampledColorTexture.CreateView()});
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor); wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor);
renderPass.SetPipeline(nonMultisampledPipeline); renderPass.SetPipeline(nonMultisampledPipeline);
renderPass.EndPass(); renderPass.EndPass();
@ -231,16 +231,16 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
} }
{ {
dawn::TextureDescriptor textureDescriptor = baseTextureDescriptor; wgpu::TextureDescriptor textureDescriptor = baseTextureDescriptor;
textureDescriptor.sampleCount = kMultisampledCount; textureDescriptor.sampleCount = kMultisampledCount;
textureDescriptor.format = kDepthStencilFormat; textureDescriptor.format = kDepthStencilFormat;
dawn::Texture multisampledDepthStencilTexture = wgpu::Texture multisampledDepthStencilTexture =
device.CreateTexture(&textureDescriptor); device.CreateTexture(&textureDescriptor);
utils::ComboRenderPassDescriptor renderPassDescriptor( utils::ComboRenderPassDescriptor renderPassDescriptor(
{}, multisampledDepthStencilTexture.CreateView()); {}, multisampledDepthStencilTexture.CreateView());
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor); wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor);
renderPass.SetPipeline(nonMultisampledPipelineWithDepthStencilOnly); renderPass.SetPipeline(nonMultisampledPipelineWithDepthStencilOnly);
renderPass.EndPass(); renderPass.EndPass();
@ -251,15 +251,15 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
// It is allowed to use multisampled render pass and multisampled render pipeline. // It is allowed to use multisampled render pass and multisampled render pipeline.
{ {
{ {
dawn::TextureDescriptor textureDescriptor = baseTextureDescriptor; wgpu::TextureDescriptor textureDescriptor = baseTextureDescriptor;
textureDescriptor.format = kColorFormat; textureDescriptor.format = kColorFormat;
textureDescriptor.sampleCount = kMultisampledCount; textureDescriptor.sampleCount = kMultisampledCount;
dawn::Texture multisampledColorTexture = device.CreateTexture(&textureDescriptor); wgpu::Texture multisampledColorTexture = device.CreateTexture(&textureDescriptor);
utils::ComboRenderPassDescriptor renderPassDescriptor( utils::ComboRenderPassDescriptor renderPassDescriptor(
{multisampledColorTexture.CreateView()}); {multisampledColorTexture.CreateView()});
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor); wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor);
renderPass.SetPipeline(multisampledPipeline); renderPass.SetPipeline(multisampledPipeline);
renderPass.EndPass(); renderPass.EndPass();
@ -267,16 +267,16 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
} }
{ {
dawn::TextureDescriptor textureDescriptor = baseTextureDescriptor; wgpu::TextureDescriptor textureDescriptor = baseTextureDescriptor;
textureDescriptor.sampleCount = kMultisampledCount; textureDescriptor.sampleCount = kMultisampledCount;
textureDescriptor.format = kDepthStencilFormat; textureDescriptor.format = kDepthStencilFormat;
dawn::Texture multisampledDepthStencilTexture = wgpu::Texture multisampledDepthStencilTexture =
device.CreateTexture(&textureDescriptor); device.CreateTexture(&textureDescriptor);
utils::ComboRenderPassDescriptor renderPassDescriptor( utils::ComboRenderPassDescriptor renderPassDescriptor(
{}, multisampledDepthStencilTexture.CreateView()); {}, multisampledDepthStencilTexture.CreateView());
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor); wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor);
renderPass.SetPipeline(multisampledPipelineWithDepthStencilOnly); renderPass.SetPipeline(multisampledPipelineWithDepthStencilOnly);
renderPass.EndPass(); renderPass.EndPass();
@ -287,15 +287,15 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
// It is not allowed to use non-multisampled render pass and multisampled render pipeline. // It is not allowed to use non-multisampled render pass and multisampled render pipeline.
{ {
{ {
dawn::TextureDescriptor textureDescriptor = baseTextureDescriptor; wgpu::TextureDescriptor textureDescriptor = baseTextureDescriptor;
textureDescriptor.format = kColorFormat; textureDescriptor.format = kColorFormat;
textureDescriptor.sampleCount = 1; textureDescriptor.sampleCount = 1;
dawn::Texture nonMultisampledColorTexture = device.CreateTexture(&textureDescriptor); wgpu::Texture nonMultisampledColorTexture = device.CreateTexture(&textureDescriptor);
utils::ComboRenderPassDescriptor nonMultisampledRenderPassDescriptor( utils::ComboRenderPassDescriptor nonMultisampledRenderPassDescriptor(
{nonMultisampledColorTexture.CreateView()}); {nonMultisampledColorTexture.CreateView()});
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = wgpu::RenderPassEncoder renderPass =
encoder.BeginRenderPass(&nonMultisampledRenderPassDescriptor); encoder.BeginRenderPass(&nonMultisampledRenderPassDescriptor);
renderPass.SetPipeline(multisampledPipeline); renderPass.SetPipeline(multisampledPipeline);
renderPass.EndPass(); renderPass.EndPass();
@ -304,16 +304,16 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
} }
{ {
dawn::TextureDescriptor textureDescriptor = baseTextureDescriptor; wgpu::TextureDescriptor textureDescriptor = baseTextureDescriptor;
textureDescriptor.sampleCount = 1; textureDescriptor.sampleCount = 1;
textureDescriptor.format = kDepthStencilFormat; textureDescriptor.format = kDepthStencilFormat;
dawn::Texture multisampledDepthStencilTexture = wgpu::Texture multisampledDepthStencilTexture =
device.CreateTexture(&textureDescriptor); device.CreateTexture(&textureDescriptor);
utils::ComboRenderPassDescriptor renderPassDescriptor( utils::ComboRenderPassDescriptor renderPassDescriptor(
{}, multisampledDepthStencilTexture.CreateView()); {}, multisampledDepthStencilTexture.CreateView());
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor); wgpu::RenderPassEncoder renderPass = encoder.BeginRenderPass(&renderPassDescriptor);
renderPass.SetPipeline(multisampledPipelineWithDepthStencilOnly); renderPass.SetPipeline(multisampledPipelineWithDepthStencilOnly);
renderPass.EndPass(); renderPass.EndPass();

View File

@ -25,22 +25,22 @@ namespace {
// Test NaN and INFINITY values are not allowed // Test NaN and INFINITY values are not allowed
TEST_F(SamplerValidationTest, InvalidLOD) { TEST_F(SamplerValidationTest, InvalidLOD) {
{ {
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.lodMinClamp = NAN; samplerDesc.lodMinClamp = NAN;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc)); ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
} }
{ {
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.lodMaxClamp = NAN; samplerDesc.lodMaxClamp = NAN;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc)); ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
} }
{ {
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.lodMinClamp = INFINITY; samplerDesc.lodMinClamp = INFINITY;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc)); ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
} }
{ {
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor(); wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
samplerDesc.lodMaxClamp = INFINITY; samplerDesc.lodMaxClamp = INFINITY;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc)); ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
} }

View File

@ -22,21 +22,21 @@ namespace {
class TextureValidationTest : public ValidationTest { class TextureValidationTest : public ValidationTest {
protected: protected:
dawn::TextureDescriptor CreateDefaultTextureDescriptor() { wgpu::TextureDescriptor CreateDefaultTextureDescriptor() {
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.size.width = kWidth; descriptor.size.width = kWidth;
descriptor.size.height = kHeight; descriptor.size.height = kHeight;
descriptor.size.depth = 1; descriptor.size.depth = 1;
descriptor.arrayLayerCount = kDefaultArraySize; descriptor.arrayLayerCount = kDefaultArraySize;
descriptor.mipLevelCount = kDefaultMipLevels; descriptor.mipLevelCount = kDefaultMipLevels;
descriptor.sampleCount = kDefaultSampleCount; descriptor.sampleCount = kDefaultSampleCount;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.format = kDefaultTextureFormat; descriptor.format = kDefaultTextureFormat;
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::Sampled; descriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::Sampled;
return descriptor; return descriptor;
} }
dawn::Queue queue = device.CreateQueue(); wgpu::Queue queue = device.CreateQueue();
private: private:
static constexpr uint32_t kWidth = 32; static constexpr uint32_t kWidth = 32;
@ -45,16 +45,16 @@ class TextureValidationTest : public ValidationTest {
static constexpr uint32_t kDefaultMipLevels = 1; static constexpr uint32_t kDefaultMipLevels = 1;
static constexpr uint32_t kDefaultSampleCount = 1; static constexpr uint32_t kDefaultSampleCount = 1;
static constexpr dawn::TextureFormat kDefaultTextureFormat = dawn::TextureFormat::RGBA8Unorm; static constexpr wgpu::TextureFormat kDefaultTextureFormat = wgpu::TextureFormat::RGBA8Unorm;
}; };
// Test the validation of sample count // Test the validation of sample count
TEST_F(TextureValidationTest, SampleCount) { TEST_F(TextureValidationTest, SampleCount) {
dawn::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
// sampleCount == 1 is allowed. // sampleCount == 1 is allowed.
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.sampleCount = 1; descriptor.sampleCount = 1;
device.CreateTexture(&descriptor); device.CreateTexture(&descriptor);
@ -62,7 +62,7 @@ TEST_F(TextureValidationTest, SampleCount) {
// sampleCount == 4 is allowed. // sampleCount == 4 is allowed.
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.sampleCount = 4; descriptor.sampleCount = 4;
device.CreateTexture(&descriptor); device.CreateTexture(&descriptor);
@ -70,7 +70,7 @@ TEST_F(TextureValidationTest, SampleCount) {
// It is an error to create a texture with an invalid sampleCount. // It is an error to create a texture with an invalid sampleCount.
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.sampleCount = 3; descriptor.sampleCount = 3;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
@ -78,7 +78,7 @@ TEST_F(TextureValidationTest, SampleCount) {
// It is an error to create a multisampled texture with mipLevelCount > 1. // It is an error to create a multisampled texture with mipLevelCount > 1.
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.sampleCount = 4; descriptor.sampleCount = 4;
descriptor.mipLevelCount = 2; descriptor.mipLevelCount = 2;
@ -87,7 +87,7 @@ TEST_F(TextureValidationTest, SampleCount) {
// Currently we do not support multisampled 2D array textures. // Currently we do not support multisampled 2D array textures.
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.sampleCount = 4; descriptor.sampleCount = 4;
descriptor.arrayLayerCount = 2; descriptor.arrayLayerCount = 2;
@ -97,11 +97,11 @@ TEST_F(TextureValidationTest, SampleCount) {
// Test the validation of the mip level count // Test the validation of the mip level count
TEST_F(TextureValidationTest, MipLevelCount) { TEST_F(TextureValidationTest, MipLevelCount) {
dawn::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
// mipLevelCount == 1 is allowed // mipLevelCount == 1 is allowed
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.size.width = 32; descriptor.size.width = 32;
descriptor.size.height = 32; descriptor.size.height = 32;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
@ -111,7 +111,7 @@ TEST_F(TextureValidationTest, MipLevelCount) {
// mipLevelCount == 0 is an error // mipLevelCount == 0 is an error
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.size.width = 32; descriptor.size.width = 32;
descriptor.size.height = 32; descriptor.size.height = 32;
descriptor.mipLevelCount = 0; descriptor.mipLevelCount = 0;
@ -121,7 +121,7 @@ TEST_F(TextureValidationTest, MipLevelCount) {
// Full mip chains are allowed // Full mip chains are allowed
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.size.width = 32; descriptor.size.width = 32;
descriptor.size.height = 32; descriptor.size.height = 32;
// Mip level sizes: 32, 16, 8, 4, 2, 1 // Mip level sizes: 32, 16, 8, 4, 2, 1
@ -132,7 +132,7 @@ TEST_F(TextureValidationTest, MipLevelCount) {
// Too big mip chains on width are disallowed // Too big mip chains on width are disallowed
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.size.width = 31; descriptor.size.width = 31;
descriptor.size.height = 32; descriptor.size.height = 32;
// Mip level width: 31, 15, 7, 3, 1, 1 // Mip level width: 31, 15, 7, 3, 1, 1
@ -143,7 +143,7 @@ TEST_F(TextureValidationTest, MipLevelCount) {
// Too big mip chains on height are disallowed // Too big mip chains on height are disallowed
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.size.width = 32; descriptor.size.width = 32;
descriptor.size.height = 31; descriptor.size.height = 31;
// Mip level height: 31, 15, 7, 3, 1, 1 // Mip level height: 31, 15, 7, 3, 1, 1
@ -154,7 +154,7 @@ TEST_F(TextureValidationTest, MipLevelCount) {
// Undefined shift check if miplevel is bigger than the integer bit width. // Undefined shift check if miplevel is bigger than the integer bit width.
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.size.width = 32; descriptor.size.width = 32;
descriptor.size.height = 32; descriptor.size.height = 32;
descriptor.mipLevelCount = 100; descriptor.mipLevelCount = 100;
@ -164,7 +164,7 @@ TEST_F(TextureValidationTest, MipLevelCount) {
// Non square mip map halves the resolution until a 1x1 dimension. // Non square mip map halves the resolution until a 1x1 dimension.
{ {
dawn::TextureDescriptor descriptor = defaultDescriptor; wgpu::TextureDescriptor descriptor = defaultDescriptor;
descriptor.size.width = 32; descriptor.size.width = 32;
descriptor.size.height = 8; descriptor.size.height = 8;
// Mip maps: 32 * 8, 16 * 4, 8 * 2, 4 * 1, 2 * 1, 1 * 1 // Mip maps: 32 * 8, 16 * 4, 8 * 2, 4 * 1, 2 * 1, 1 * 1
@ -176,15 +176,15 @@ TEST_F(TextureValidationTest, MipLevelCount) {
// Test that it is valid to destroy a texture // Test that it is valid to destroy a texture
TEST_F(TextureValidationTest, DestroyTexture) { TEST_F(TextureValidationTest, DestroyTexture) {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
dawn::Texture texture = device.CreateTexture(&descriptor); wgpu::Texture texture = device.CreateTexture(&descriptor);
texture.Destroy(); texture.Destroy();
} }
// Test that it's valid to destroy a destroyed texture // Test that it's valid to destroy a destroyed texture
TEST_F(TextureValidationTest, DestroyDestroyedTexture) { TEST_F(TextureValidationTest, DestroyDestroyedTexture) {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
dawn::Texture texture = device.CreateTexture(&descriptor); wgpu::Texture texture = device.CreateTexture(&descriptor);
texture.Destroy(); texture.Destroy();
texture.Destroy(); texture.Destroy();
} }
@ -192,21 +192,21 @@ TEST_F(TextureValidationTest, DestroyDestroyedTexture) {
// Test that it's invalid to submit a destroyed texture in a queue // Test that it's invalid to submit a destroyed texture in a queue
// in the case of destroy, encode, submit // in the case of destroy, encode, submit
TEST_F(TextureValidationTest, DestroyEncodeSubmit) { TEST_F(TextureValidationTest, DestroyEncodeSubmit) {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
dawn::Texture texture = device.CreateTexture(&descriptor); wgpu::Texture texture = device.CreateTexture(&descriptor);
dawn::TextureView textureView = texture.CreateView(); wgpu::TextureView textureView = texture.CreateView();
utils::ComboRenderPassDescriptor renderPass({textureView}); utils::ComboRenderPassDescriptor renderPass({textureView});
// Destroy the texture // Destroy the texture
texture.Destroy(); texture.Destroy();
dawn::CommandEncoder encoder_post_destroy = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder_post_destroy = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder_post_destroy.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder_post_destroy.BeginRenderPass(&renderPass);
pass.EndPass(); pass.EndPass();
} }
dawn::CommandBuffer commands = encoder_post_destroy.Finish(); wgpu::CommandBuffer commands = encoder_post_destroy.Finish();
// Submit should fail due to destroyed texture // Submit should fail due to destroyed texture
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands)); ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
@ -215,18 +215,18 @@ TEST_F(TextureValidationTest, DestroyEncodeSubmit) {
// Test that it's invalid to submit a destroyed texture in a queue // Test that it's invalid to submit a destroyed texture in a queue
// in the case of encode, destroy, submit // in the case of encode, destroy, submit
TEST_F(TextureValidationTest, EncodeDestroySubmit) { TEST_F(TextureValidationTest, EncodeDestroySubmit) {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
dawn::Texture texture = device.CreateTexture(&descriptor); wgpu::Texture texture = device.CreateTexture(&descriptor);
dawn::TextureView textureView = texture.CreateView(); wgpu::TextureView textureView = texture.CreateView();
utils::ComboRenderPassDescriptor renderPass({textureView}); utils::ComboRenderPassDescriptor renderPass({textureView});
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.EndPass(); pass.EndPass();
} }
dawn::CommandBuffer commands = encoder.Finish(); wgpu::CommandBuffer commands = encoder.Finish();
// Destroy the texture // Destroy the texture
texture.Destroy(); texture.Destroy();
@ -237,20 +237,22 @@ TEST_F(TextureValidationTest, EncodeDestroySubmit) {
// Test it is an error to create an OutputAttachment texture with a non-renderable format. // Test it is an error to create an OutputAttachment texture with a non-renderable format.
TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) { TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.size = {1, 1, 1}; descriptor.size = {1, 1, 1};
descriptor.usage = dawn::TextureUsage::OutputAttachment; descriptor.usage = wgpu::TextureUsage::OutputAttachment;
// Succeeds because RGBA8Unorm is renderable // Succeeds because RGBA8Unorm is renderable
descriptor.format = dawn::TextureFormat::RGBA8Unorm; descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
device.CreateTexture(&descriptor); device.CreateTexture(&descriptor);
dawn::TextureFormat nonRenderableFormats[] = { wgpu::TextureFormat nonRenderableFormats[] = {
dawn::TextureFormat::RG11B10Float, dawn::TextureFormat::R8Snorm, wgpu::TextureFormat::RG11B10Float,
dawn::TextureFormat::RG8Snorm, dawn::TextureFormat::RGBA8Snorm, wgpu::TextureFormat::R8Snorm,
wgpu::TextureFormat::RG8Snorm,
wgpu::TextureFormat::RGBA8Snorm,
}; };
for (dawn::TextureFormat format : nonRenderableFormats) { for (wgpu::TextureFormat format : nonRenderableFormats) {
// Fails because `format` is non-renderable // Fails because `format` is non-renderable
descriptor.format = format; descriptor.format = format;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
@ -259,8 +261,8 @@ TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
// Test it is an error to create a texture with format "Undefined". // Test it is an error to create a texture with format "Undefined".
TEST_F(TextureValidationTest, TextureFormatUndefined) { TEST_F(TextureValidationTest, TextureFormatUndefined) {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = dawn::TextureFormat::Undefined; descriptor.format = wgpu::TextureFormat::Undefined;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
} }
@ -273,52 +275,52 @@ class CompressedTextureFormatsValidationTests : public TextureValidationTest {
} }
protected: protected:
dawn::TextureDescriptor CreateDefaultTextureDescriptor() { wgpu::TextureDescriptor CreateDefaultTextureDescriptor() {
dawn::TextureDescriptor descriptor = wgpu::TextureDescriptor descriptor =
TextureValidationTest::CreateDefaultTextureDescriptor(); TextureValidationTest::CreateDefaultTextureDescriptor();
descriptor.usage = descriptor.usage =
dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled; wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled;
return descriptor; return descriptor;
} }
const std::array<dawn::TextureFormat, 14> kBCFormats = { const std::array<wgpu::TextureFormat, 14> kBCFormats = {
dawn::TextureFormat::BC1RGBAUnorm, dawn::TextureFormat::BC1RGBAUnormSrgb, wgpu::TextureFormat::BC1RGBAUnorm, wgpu::TextureFormat::BC1RGBAUnormSrgb,
dawn::TextureFormat::BC2RGBAUnorm, dawn::TextureFormat::BC2RGBAUnormSrgb, wgpu::TextureFormat::BC2RGBAUnorm, wgpu::TextureFormat::BC2RGBAUnormSrgb,
dawn::TextureFormat::BC3RGBAUnorm, dawn::TextureFormat::BC3RGBAUnormSrgb, wgpu::TextureFormat::BC3RGBAUnorm, wgpu::TextureFormat::BC3RGBAUnormSrgb,
dawn::TextureFormat::BC4RUnorm, dawn::TextureFormat::BC4RSnorm, wgpu::TextureFormat::BC4RUnorm, wgpu::TextureFormat::BC4RSnorm,
dawn::TextureFormat::BC5RGUnorm, dawn::TextureFormat::BC5RGSnorm, wgpu::TextureFormat::BC5RGUnorm, wgpu::TextureFormat::BC5RGSnorm,
dawn::TextureFormat::BC6HRGBUfloat, dawn::TextureFormat::BC6HRGBSfloat, wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBSfloat,
dawn::TextureFormat::BC7RGBAUnorm, dawn::TextureFormat::BC7RGBAUnormSrgb}; wgpu::TextureFormat::BC7RGBAUnorm, wgpu::TextureFormat::BC7RGBAUnormSrgb};
}; };
// Test the validation of texture size when creating textures in compressed texture formats. // Test the validation of texture size when creating textures in compressed texture formats.
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) { TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
// Test that it is invalid to use a number that is not a multiple of 4 (the compressed block // Test that it is invalid to use a number that is not a multiple of 4 (the compressed block
// width and height of all BC formats) as the width or height of textures in BC formats. // width and height of all BC formats) as the width or height of textures in BC formats.
for (dawn::TextureFormat format : kBCFormats) { for (wgpu::TextureFormat format : kBCFormats) {
{ {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
ASSERT_TRUE(descriptor.size.width % 4 == 0 && descriptor.size.height % 4 == 0); ASSERT_TRUE(descriptor.size.width % 4 == 0 && descriptor.size.height % 4 == 0);
device.CreateTexture(&descriptor); device.CreateTexture(&descriptor);
} }
{ {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
descriptor.size.width = 31; descriptor.size.width = 31;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
} }
{ {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
descriptor.size.height = 31; descriptor.size.height = 31;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
} }
{ {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
descriptor.size.width = 12; descriptor.size.width = 12;
descriptor.size.height = 32; descriptor.size.height = 32;
@ -331,9 +333,9 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
// is not enabled. // is not enabled.
TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtension) { TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtension) {
const std::vector<const char*> kEmptyVector; const std::vector<const char*> kEmptyVector;
dawn::Device deviceWithoutExtension = CreateDeviceFromAdapter(adapter, kEmptyVector); wgpu::Device deviceWithoutExtension = CreateDeviceFromAdapter(adapter, kEmptyVector);
for (dawn::TextureFormat format : kBCFormats) { for (wgpu::TextureFormat format : kBCFormats) {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
ASSERT_DEVICE_ERROR(deviceWithoutExtension.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(deviceWithoutExtension.CreateTexture(&descriptor));
} }
@ -343,25 +345,25 @@ TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtens
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) { TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
// Test that only CopySrc, CopyDst and Sampled are accepted as the texture usage of the // Test that only CopySrc, CopyDst and Sampled are accepted as the texture usage of the
// textures in BC formats. // textures in BC formats.
for (dawn::TextureFormat format : kBCFormats) { for (wgpu::TextureFormat format : kBCFormats) {
{ {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
descriptor.usage = dawn::TextureUsage::OutputAttachment; descriptor.usage = wgpu::TextureUsage::OutputAttachment;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
} }
{ {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
descriptor.usage = dawn::TextureUsage::Storage; descriptor.usage = wgpu::TextureUsage::Storage;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
} }
{ {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
descriptor.usage = dawn::TextureUsage::Present; descriptor.usage = wgpu::TextureUsage::Present;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
} }
} }
@ -370,8 +372,8 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
// Test the validation of sample count when creating textures in compressed texture formats. // Test the validation of sample count when creating textures in compressed texture formats.
TEST_F(CompressedTextureFormatsValidationTests, SampleCount) { TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {
// Test that it is invalid to specify SampleCount > 1 when we create a texture in BC formats. // Test that it is invalid to specify SampleCount > 1 when we create a texture in BC formats.
for (dawn::TextureFormat format : kBCFormats) { for (wgpu::TextureFormat format : kBCFormats) {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
descriptor.sampleCount = 4; descriptor.sampleCount = 4;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
@ -381,8 +383,8 @@ TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {
// Test the validation of creating 2D array textures in compressed texture formats. // Test the validation of creating 2D array textures in compressed texture formats.
TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) { TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) {
// Test that it is allowed to create a 2D array texture in BC formats. // Test that it is allowed to create a 2D array texture in BC formats.
for (dawn::TextureFormat format : kBCFormats) { for (wgpu::TextureFormat format : kBCFormats) {
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format; descriptor.format = format;
descriptor.arrayLayerCount = 6; descriptor.arrayLayerCount = 6;
device.CreateTexture(&descriptor); device.CreateTexture(&descriptor);

View File

@ -23,16 +23,16 @@ constexpr uint32_t kWidth = 32u;
constexpr uint32_t kHeight = 32u; constexpr uint32_t kHeight = 32u;
constexpr uint32_t kDefaultMipLevels = 6u; constexpr uint32_t kDefaultMipLevels = 6u;
constexpr dawn::TextureFormat kDefaultTextureFormat = dawn::TextureFormat::RGBA8Unorm; constexpr wgpu::TextureFormat kDefaultTextureFormat = wgpu::TextureFormat::RGBA8Unorm;
dawn::Texture Create2DArrayTexture(dawn::Device& device, wgpu::Texture Create2DArrayTexture(wgpu::Device& device,
uint32_t arrayLayerCount, uint32_t arrayLayerCount,
uint32_t width = kWidth, uint32_t width = kWidth,
uint32_t height = kHeight, uint32_t height = kHeight,
uint32_t mipLevelCount = kDefaultMipLevels, uint32_t mipLevelCount = kDefaultMipLevels,
uint32_t sampleCount = 1) { uint32_t sampleCount = 1) {
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size.width = width; descriptor.size.width = width;
descriptor.size.height = height; descriptor.size.height = height;
descriptor.size.depth = 1; descriptor.size.depth = 1;
@ -40,12 +40,12 @@ dawn::Texture Create2DArrayTexture(dawn::Device& device,
descriptor.sampleCount = sampleCount; descriptor.sampleCount = sampleCount;
descriptor.format = kDefaultTextureFormat; descriptor.format = kDefaultTextureFormat;
descriptor.mipLevelCount = mipLevelCount; descriptor.mipLevelCount = mipLevelCount;
descriptor.usage = dawn::TextureUsage::Sampled; descriptor.usage = wgpu::TextureUsage::Sampled;
return device.CreateTexture(&descriptor); return device.CreateTexture(&descriptor);
} }
dawn::TextureViewDescriptor CreateDefaultViewDescriptor(dawn::TextureViewDimension dimension) { wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimension dimension) {
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.format = kDefaultTextureFormat; descriptor.format = kDefaultTextureFormat;
descriptor.dimension = dimension; descriptor.dimension = dimension;
descriptor.baseMipLevel = 0; descriptor.baseMipLevel = 0;
@ -57,36 +57,36 @@ dawn::TextureViewDescriptor CreateDefaultViewDescriptor(dawn::TextureViewDimensi
// Test creating texture view on a 2D non-array texture // Test creating texture view on a 2D non-array texture
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) { TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
dawn::Texture texture = Create2DArrayTexture(device, 1); wgpu::Texture texture = Create2DArrayTexture(device, 1);
dawn::TextureViewDescriptor base2DTextureViewDescriptor = wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
CreateDefaultViewDescriptor(dawn::TextureViewDimension::e2D); CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
// It is OK to create a 2D texture view on a 2D texture. // It is OK to create a 2D texture view on a 2D texture.
{ {
dawn::TextureViewDescriptor descriptor = base2DTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
} }
// It is an error to view a layer past the end of the texture. // It is an error to view a layer past the end of the texture.
{ {
dawn::TextureViewDescriptor descriptor = base2DTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.arrayLayerCount = 2; descriptor.arrayLayerCount = 2;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
// It is OK to create a 1-layer 2D array texture view on a 2D texture. // It is OK to create a 1-layer 2D array texture view on a 2D texture.
{ {
dawn::TextureViewDescriptor descriptor = base2DTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::e2DArray; descriptor.dimension = wgpu::TextureViewDimension::e2DArray;
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
} }
// baseMipLevel == k && mipLevelCount == 0 means to use levels k..end. // baseMipLevel == k && mipLevelCount == 0 means to use levels k..end.
{ {
dawn::TextureViewDescriptor descriptor = base2DTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.mipLevelCount = 0; descriptor.mipLevelCount = 0;
descriptor.baseMipLevel = 0; descriptor.baseMipLevel = 0;
@ -101,7 +101,7 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
// It is an error to make the mip level out of range. // It is an error to make the mip level out of range.
{ {
dawn::TextureViewDescriptor descriptor = base2DTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.baseMipLevel = 0; descriptor.baseMipLevel = 0;
descriptor.mipLevelCount = kDefaultMipLevels + 1; descriptor.mipLevelCount = kDefaultMipLevels + 1;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
@ -121,29 +121,29 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) { TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
constexpr uint32_t kDefaultArrayLayers = 6; constexpr uint32_t kDefaultArrayLayers = 6;
dawn::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers); wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
dawn::TextureViewDescriptor base2DArrayTextureViewDescriptor = wgpu::TextureViewDescriptor base2DArrayTextureViewDescriptor =
CreateDefaultViewDescriptor(dawn::TextureViewDimension::e2DArray); CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2DArray);
// It is OK to create a 2D texture view on a 2D array texture. // It is OK to create a 2D texture view on a 2D array texture.
{ {
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::e2D; descriptor.dimension = wgpu::TextureViewDimension::e2D;
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
} }
// It is OK to create a 2D array texture view on a 2D array texture. // It is OK to create a 2D array texture view on a 2D array texture.
{ {
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.arrayLayerCount = kDefaultArrayLayers; descriptor.arrayLayerCount = kDefaultArrayLayers;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
} }
// baseArrayLayer == k && arrayLayerCount == 0 means to use layers k..end. // baseArrayLayer == k && arrayLayerCount == 0 means to use layers k..end.
{ {
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.arrayLayerCount = 0; descriptor.arrayLayerCount = 0;
descriptor.baseArrayLayer = 0; descriptor.baseArrayLayer = 0;
@ -158,7 +158,7 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
// It is an error for the array layer range of the view to exceed that of the texture. // It is an error for the array layer range of the view to exceed that of the texture.
{ {
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.baseArrayLayer = 0; descriptor.baseArrayLayer = 0;
descriptor.arrayLayerCount = kDefaultArrayLayers + 1; descriptor.arrayLayerCount = kDefaultArrayLayers + 1;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
@ -179,35 +179,35 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
// Variant for a texture with more than 1 array layer. // Variant for a texture with more than 1 array layer.
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) { TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) {
constexpr uint32_t kDefaultArrayLayers = 6; constexpr uint32_t kDefaultArrayLayers = 6;
dawn::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers); wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
{ texture.CreateView(); } { texture.CreateView(); }
{ {
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.format = dawn::TextureFormat::Undefined; descriptor.format = wgpu::TextureFormat::Undefined;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.format = dawn::TextureFormat::RGBA8Unorm; descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.format = dawn::TextureFormat::R8Unorm; descriptor.format = wgpu::TextureFormat::R8Unorm;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
{ {
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.dimension = dawn::TextureViewDimension::Undefined; descriptor.dimension = wgpu::TextureViewDimension::Undefined;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.dimension = dawn::TextureViewDimension::e2DArray; descriptor.dimension = wgpu::TextureViewDimension::e2DArray;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.dimension = dawn::TextureViewDimension::e2D; descriptor.dimension = wgpu::TextureViewDimension::e2D;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
{ {
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
// Setting array layers to non-0 means the dimensionality will // Setting array layers to non-0 means the dimensionality will
// default to 2D so by itself it causes an error. // default to 2D so by itself it causes an error.
descriptor.arrayLayerCount = kDefaultArrayLayers; descriptor.arrayLayerCount = kDefaultArrayLayers;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
descriptor.dimension = dawn::TextureViewDimension::e2DArray; descriptor.dimension = wgpu::TextureViewDimension::e2DArray;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.mipLevelCount = kDefaultMipLevels; descriptor.mipLevelCount = kDefaultMipLevels;
@ -220,29 +220,29 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) {
// Variant for a texture with only 1 array layer. // Variant for a texture with only 1 array layer.
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) { TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
constexpr uint32_t kDefaultArrayLayers = 1; constexpr uint32_t kDefaultArrayLayers = 1;
dawn::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers); wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
{ texture.CreateView(); } { texture.CreateView(); }
{ {
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.format = dawn::TextureFormat::Undefined; descriptor.format = wgpu::TextureFormat::Undefined;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.format = dawn::TextureFormat::RGBA8Unorm; descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.format = dawn::TextureFormat::R8Unorm; descriptor.format = wgpu::TextureFormat::R8Unorm;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
{ {
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.dimension = dawn::TextureViewDimension::Undefined; descriptor.dimension = wgpu::TextureViewDimension::Undefined;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.dimension = dawn::TextureViewDimension::e2D; descriptor.dimension = wgpu::TextureViewDimension::e2D;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.dimension = dawn::TextureViewDimension::e2DArray; descriptor.dimension = wgpu::TextureViewDimension::e2DArray;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
} }
{ {
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.arrayLayerCount = 0; descriptor.arrayLayerCount = 0;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.arrayLayerCount = 1; descriptor.arrayLayerCount = 1;
@ -251,7 +251,7 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
{ {
dawn::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.mipLevelCount = kDefaultMipLevels; descriptor.mipLevelCount = kDefaultMipLevels;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
descriptor.arrayLayerCount = kDefaultArrayLayers; descriptor.arrayLayerCount = kDefaultArrayLayers;
@ -263,59 +263,59 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) { TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
constexpr uint32_t kDefaultArrayLayers = 16; constexpr uint32_t kDefaultArrayLayers = 16;
dawn::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers); wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
dawn::TextureViewDescriptor base2DArrayTextureViewDescriptor = wgpu::TextureViewDescriptor base2DArrayTextureViewDescriptor =
CreateDefaultViewDescriptor(dawn::TextureViewDimension::e2DArray); CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2DArray);
// It is OK to create a cube map texture view with arrayLayerCount == 6. // It is OK to create a cube map texture view with arrayLayerCount == 6.
{ {
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::Cube; descriptor.dimension = wgpu::TextureViewDimension::Cube;
descriptor.arrayLayerCount = 6; descriptor.arrayLayerCount = 6;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
} }
// It is an error to create a cube map texture view with arrayLayerCount != 6. // It is an error to create a cube map texture view with arrayLayerCount != 6.
{ {
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::Cube; descriptor.dimension = wgpu::TextureViewDimension::Cube;
descriptor.arrayLayerCount = 3; descriptor.arrayLayerCount = 3;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
// It is OK to create a cube map array texture view with arrayLayerCount % 6 == 0. // It is OK to create a cube map array texture view with arrayLayerCount % 6 == 0.
{ {
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::CubeArray; descriptor.dimension = wgpu::TextureViewDimension::CubeArray;
descriptor.arrayLayerCount = 12; descriptor.arrayLayerCount = 12;
texture.CreateView(&descriptor); texture.CreateView(&descriptor);
} }
// It is an error to create a cube map array texture view with arrayLayerCount % 6 != 0. // It is an error to create a cube map array texture view with arrayLayerCount % 6 != 0.
{ {
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::CubeArray; descriptor.dimension = wgpu::TextureViewDimension::CubeArray;
descriptor.arrayLayerCount = 11; descriptor.arrayLayerCount = 11;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
// It is an error to create a cube map texture view with width != height. // It is an error to create a cube map texture view with width != height.
{ {
dawn::Texture nonSquareTexture = Create2DArrayTexture(device, 18, 32, 16, 5); wgpu::Texture nonSquareTexture = Create2DArrayTexture(device, 18, 32, 16, 5);
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::Cube; descriptor.dimension = wgpu::TextureViewDimension::Cube;
descriptor.arrayLayerCount = 6; descriptor.arrayLayerCount = 6;
ASSERT_DEVICE_ERROR(nonSquareTexture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(nonSquareTexture.CreateView(&descriptor));
} }
// It is an error to create a cube map array texture view with width != height. // It is an error to create a cube map array texture view with width != height.
{ {
dawn::Texture nonSquareTexture = Create2DArrayTexture(device, 18, 32, 16, 5); wgpu::Texture nonSquareTexture = Create2DArrayTexture(device, 18, 32, 16, 5);
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::CubeArray; descriptor.dimension = wgpu::TextureViewDimension::CubeArray;
descriptor.arrayLayerCount = 12; descriptor.arrayLayerCount = 12;
ASSERT_DEVICE_ERROR(nonSquareTexture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(nonSquareTexture.CreateView(&descriptor));
} }
@ -324,41 +324,41 @@ TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
// Test the format compatibility rules when creating a texture view. // Test the format compatibility rules when creating a texture view.
// TODO(jiawei.shao@intel.com): add more tests when the rules are fully implemented. // TODO(jiawei.shao@intel.com): add more tests when the rules are fully implemented.
TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) { TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) {
dawn::Texture texture = Create2DArrayTexture(device, 1); wgpu::Texture texture = Create2DArrayTexture(device, 1);
dawn::TextureViewDescriptor base2DTextureViewDescriptor = wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
CreateDefaultViewDescriptor(dawn::TextureViewDimension::e2D); CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
// It is an error to create a texture view in depth-stencil format on a RGBA texture. // It is an error to create a texture view in depth-stencil format on a RGBA texture.
{ {
dawn::TextureViewDescriptor descriptor = base2DTextureViewDescriptor; wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.format = dawn::TextureFormat::Depth24PlusStencil8; descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
} }
// Test that it's invalid to create a texture view from a destroyed texture // Test that it's invalid to create a texture view from a destroyed texture
TEST_F(TextureViewValidationTest, DestroyCreateTextureView) { TEST_F(TextureViewValidationTest, DestroyCreateTextureView) {
dawn::Texture texture = Create2DArrayTexture(device, 1); wgpu::Texture texture = Create2DArrayTexture(device, 1);
dawn::TextureViewDescriptor descriptor = wgpu::TextureViewDescriptor descriptor =
CreateDefaultViewDescriptor(dawn::TextureViewDimension::e2D); CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
texture.Destroy(); texture.Destroy();
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
} }
// Test that only TextureAspect::All is supported // Test that only TextureAspect::All is supported
TEST_F(TextureViewValidationTest, AspectMustBeAll) { TEST_F(TextureViewValidationTest, AspectMustBeAll) {
dawn::TextureDescriptor descriptor = {}; wgpu::TextureDescriptor descriptor = {};
descriptor.size = {1, 1, 1}; descriptor.size = {1, 1, 1};
descriptor.format = dawn::TextureFormat::Depth32Float; descriptor.format = wgpu::TextureFormat::Depth32Float;
descriptor.usage = dawn::TextureUsage::Sampled | dawn::TextureUsage::OutputAttachment; descriptor.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::OutputAttachment;
dawn::Texture texture = device.CreateTexture(&descriptor); wgpu::Texture texture = device.CreateTexture(&descriptor);
dawn::TextureViewDescriptor viewDescriptor = {}; wgpu::TextureViewDescriptor viewDescriptor = {};
viewDescriptor.aspect = dawn::TextureAspect::All; viewDescriptor.aspect = wgpu::TextureAspect::All;
texture.CreateView(&viewDescriptor); texture.CreateView(&viewDescriptor);
viewDescriptor.aspect = dawn::TextureAspect::DepthOnly; viewDescriptor.aspect = wgpu::TextureAspect::DepthOnly;
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDescriptor)); ASSERT_DEVICE_ERROR(texture.CreateView(&viewDescriptor));
} }

View File

@ -47,7 +47,7 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kValidToggleName); descriptor.forceEnabledToggles.push_back(kValidToggleName);
DawnDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);
bool validToggleExists = false; bool validToggleExists = false;
for (const char* toggle : toggleNames) { for (const char* toggle : toggleNames) {
@ -64,7 +64,7 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kInvalidToggleName); descriptor.forceEnabledToggles.push_back(kInvalidToggleName);
DawnDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);
bool InvalidToggleExists = false; bool InvalidToggleExists = false;
for (const char* toggle : toggleNames) { for (const char* toggle : toggleNames) {
@ -81,7 +81,7 @@ TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.forceEnabledToggles.push_back(kValidToggleName); descriptor.forceEnabledToggles.push_back(kValidToggleName);
DawnDevice deviceWithToggle = adapter.CreateDevice(&descriptor); WGPUDevice deviceWithToggle = adapter.CreateDevice(&descriptor);
std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle); std::vector<const char*> toggleNames = dawn_native::GetTogglesUsed(deviceWithToggle);
bool validToggleExists = false; bool validToggleExists = false;
for (const char* toggle : toggleNames) { for (const char* toggle : toggleNames) {

View File

@ -15,8 +15,8 @@
#include "tests/unittests/validation/ValidationTest.h" #include "tests/unittests/validation/ValidationTest.h"
#include "common/Assert.h" #include "common/Assert.h"
#include "dawn/dawn.h"
#include "dawn/dawn_proc.h" #include "dawn/dawn_proc.h"
#include "dawn/webgpu.h"
#include "dawn_native/NullBackend.h" #include "dawn_native/NullBackend.h"
ValidationTest::ValidationTest() { ValidationTest::ValidationTest() {
@ -43,18 +43,18 @@ ValidationTest::ValidationTest() {
device = CreateDeviceFromAdapter(adapter, std::vector<const char*>()); device = CreateDeviceFromAdapter(adapter, std::vector<const char*>());
} }
dawn::Device ValidationTest::CreateDeviceFromAdapter( wgpu::Device ValidationTest::CreateDeviceFromAdapter(
dawn_native::Adapter adapterToTest, dawn_native::Adapter adapterToTest,
const std::vector<const char*>& requiredExtensions) { const std::vector<const char*>& requiredExtensions) {
dawn::Device deviceToTest; wgpu::Device deviceToTest;
// Always keep the code path to test creating a device without a device descriptor. // Always keep the code path to test creating a device without a device descriptor.
if (requiredExtensions.empty()) { if (requiredExtensions.empty()) {
deviceToTest = dawn::Device::Acquire(adapterToTest.CreateDevice()); deviceToTest = wgpu::Device::Acquire(adapterToTest.CreateDevice());
} else { } else {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = requiredExtensions; descriptor.requiredExtensions = requiredExtensions;
deviceToTest = dawn::Device::Acquire(adapterToTest.CreateDevice(&descriptor)); deviceToTest = wgpu::Device::Acquire(adapterToTest.CreateDevice(&descriptor));
} }
deviceToTest.SetUncapturedErrorCallback(ValidationTest::OnDeviceError, this); deviceToTest.SetUncapturedErrorCallback(ValidationTest::OnDeviceError, this);
@ -64,7 +64,7 @@ dawn::Device ValidationTest::CreateDeviceFromAdapter(
ValidationTest::~ValidationTest() { ValidationTest::~ValidationTest() {
// We need to destroy Dawn objects before setting the procs to null otherwise the dawn*Release // We need to destroy Dawn objects before setting the procs to null otherwise the dawn*Release
// will call a nullptr // will call a nullptr
device = dawn::Device(); device = wgpu::Device();
dawnProcSetProcs(nullptr); dawnProcSetProcs(nullptr);
} }
@ -85,8 +85,8 @@ std::string ValidationTest::GetLastDeviceErrorMessage() const {
} }
// static // static
void ValidationTest::OnDeviceError(DawnErrorType type, const char* message, void* userdata) { void ValidationTest::OnDeviceError(WGPUErrorType type, const char* message, void* userdata) {
ASSERT(type != DAWN_ERROR_TYPE_NO_ERROR); ASSERT(type != WGPUErrorType_NoError);
auto self = static_cast<ValidationTest*>(userdata); auto self = static_cast<ValidationTest*>(userdata);
self->mDeviceErrorMessage = message; self->mDeviceErrorMessage = message;
@ -95,10 +95,10 @@ void ValidationTest::OnDeviceError(DawnErrorType type, const char* message, void
self->mError = true; self->mError = true;
} }
ValidationTest::DummyRenderPass::DummyRenderPass(const dawn::Device& device) ValidationTest::DummyRenderPass::DummyRenderPass(const wgpu::Device& device)
: attachmentFormat(dawn::TextureFormat::RGBA8Unorm), width(400), height(400) { : attachmentFormat(wgpu::TextureFormat::RGBA8Unorm), width(400), height(400) {
dawn::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size.width = width; descriptor.size.width = width;
descriptor.size.height = height; descriptor.size.height = height;
descriptor.size.depth = 1; descriptor.size.depth = 1;
@ -106,15 +106,15 @@ ValidationTest::DummyRenderPass::DummyRenderPass(const dawn::Device& device)
descriptor.sampleCount = 1; descriptor.sampleCount = 1;
descriptor.format = attachmentFormat; descriptor.format = attachmentFormat;
descriptor.mipLevelCount = 1; descriptor.mipLevelCount = 1;
descriptor.usage = dawn::TextureUsage::OutputAttachment; descriptor.usage = wgpu::TextureUsage::OutputAttachment;
attachment = device.CreateTexture(&descriptor); attachment = device.CreateTexture(&descriptor);
dawn::TextureView view = attachment.CreateView(); wgpu::TextureView view = attachment.CreateView();
mColorAttachment.attachment = view; mColorAttachment.attachment = view;
mColorAttachment.resolveTarget = nullptr; mColorAttachment.resolveTarget = nullptr;
mColorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f }; mColorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
mColorAttachment.loadOp = dawn::LoadOp::Clear; mColorAttachment.loadOp = wgpu::LoadOp::Clear;
mColorAttachment.storeOp = dawn::StoreOp::Store; mColorAttachment.storeOp = wgpu::StoreOp::Store;
colorAttachmentCount = 1; colorAttachmentCount = 1;
colorAttachments = &mColorAttachment; colorAttachments = &mColorAttachment;

View File

@ -15,9 +15,9 @@
#ifndef TESTS_UNITTESTS_VALIDATIONTEST_H_ #ifndef TESTS_UNITTESTS_VALIDATIONTEST_H_
#define TESTS_UNITTESTS_VALIDATIONTEST_H_ #define TESTS_UNITTESTS_VALIDATIONTEST_H_
#include "gtest/gtest.h" #include "dawn/webgpu_cpp.h"
#include "dawn/dawncpp.h"
#include "dawn_native/DawnNative.h" #include "dawn_native/DawnNative.h"
#include "gtest/gtest.h"
#define ASSERT_DEVICE_ERROR(statement) \ #define ASSERT_DEVICE_ERROR(statement) \
StartExpectDeviceError(); \ StartExpectDeviceError(); \
@ -29,7 +29,7 @@ class ValidationTest : public testing::Test {
ValidationTest(); ValidationTest();
~ValidationTest(); ~ValidationTest();
dawn::Device CreateDeviceFromAdapter(dawn_native::Adapter adapter, wgpu::Device CreateDeviceFromAdapter(dawn_native::Adapter adapter,
const std::vector<const char*>& requiredExtensions); const std::vector<const char*>& requiredExtensions);
void TearDown() override; void TearDown() override;
@ -40,25 +40,25 @@ class ValidationTest : public testing::Test {
// Helper functions to create objects to test validation. // Helper functions to create objects to test validation.
struct DummyRenderPass : public dawn::RenderPassDescriptor { struct DummyRenderPass : public wgpu::RenderPassDescriptor {
public: public:
DummyRenderPass(const dawn::Device& device); DummyRenderPass(const wgpu::Device& device);
dawn::Texture attachment; wgpu::Texture attachment;
dawn::TextureFormat attachmentFormat; wgpu::TextureFormat attachmentFormat;
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
private: private:
dawn::RenderPassColorAttachmentDescriptor mColorAttachment; wgpu::RenderPassColorAttachmentDescriptor mColorAttachment;
}; };
protected: protected:
dawn::Device device; wgpu::Device device;
dawn_native::Adapter adapter; dawn_native::Adapter adapter;
std::unique_ptr<dawn_native::Instance> instance; std::unique_ptr<dawn_native::Instance> instance;
private: private:
static void OnDeviceError(DawnErrorType type, const char* message, void* userdata); static void OnDeviceError(WGPUErrorType type, const char* message, void* userdata);
std::string mDeviceErrorMessage; std::string mDeviceErrorMessage;
bool mExpectError = false; bool mExpectError = false;
bool mError = false; bool mError = false;

View File

@ -32,15 +32,15 @@ class VertexBufferValidationTest : public ValidationTest {
})"); })");
} }
dawn::Buffer MakeVertexBuffer() { wgpu::Buffer MakeVertexBuffer() {
dawn::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 256; descriptor.size = 256;
descriptor.usage = dawn::BufferUsage::Vertex; descriptor.usage = wgpu::BufferUsage::Vertex;
return device.CreateBuffer(&descriptor); return device.CreateBuffer(&descriptor);
} }
dawn::ShaderModule MakeVertexShader(unsigned int bufferCount) { wgpu::ShaderModule MakeVertexShader(unsigned int bufferCount) {
std::ostringstream vs; std::ostringstream vs;
vs << "#version 450\n"; vs << "#version 450\n";
for (unsigned int i = 0; i < bufferCount; ++i) { for (unsigned int i = 0; i < bufferCount; ++i) {
@ -63,7 +63,7 @@ class VertexBufferValidationTest : public ValidationTest {
vs.str().c_str()); vs.str().c_str());
} }
dawn::RenderPipeline MakeRenderPipeline(const dawn::ShaderModule& vsModule, wgpu::RenderPipeline MakeRenderPipeline(const wgpu::ShaderModule& vsModule,
unsigned int bufferCount) { unsigned int bufferCount) {
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule; descriptor.vertexStage.module = vsModule;
@ -74,14 +74,14 @@ class VertexBufferValidationTest : public ValidationTest {
descriptor.cVertexInput.cBuffers[i].attributes = descriptor.cVertexInput.cBuffers[i].attributes =
&descriptor.cVertexInput.cAttributes[i]; &descriptor.cVertexInput.cAttributes[i];
descriptor.cVertexInput.cAttributes[i].shaderLocation = i; descriptor.cVertexInput.cAttributes[i].shaderLocation = i;
descriptor.cVertexInput.cAttributes[i].format = dawn::VertexFormat::Float3; descriptor.cVertexInput.cAttributes[i].format = wgpu::VertexFormat::Float3;
} }
descriptor.cVertexInput.bufferCount = bufferCount; descriptor.cVertexInput.bufferCount = bufferCount;
return device.CreateRenderPipeline(&descriptor); return device.CreateRenderPipeline(&descriptor);
} }
dawn::ShaderModule fsModule; wgpu::ShaderModule fsModule;
}; };
TEST_F(VertexBufferValidationTest, VertexBuffersInheritedBetweenPipelines) { TEST_F(VertexBufferValidationTest, VertexBuffersInheritedBetweenPipelines) {
@ -96,9 +96,9 @@ TEST_F(VertexBufferValidationTest, VertexBuffersInheritedBetweenPipelines) {
auto vertexBuffer2 = MakeVertexBuffer(); auto vertexBuffer2 = MakeVertexBuffer();
// Check failure when vertex buffer is not set // Check failure when vertex buffer is not set
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline1); pass.SetPipeline(pipeline1);
pass.Draw(3, 1, 0, 0); pass.Draw(3, 1, 0, 0);
pass.EndPass(); pass.EndPass();
@ -108,7 +108,7 @@ TEST_F(VertexBufferValidationTest, VertexBuffersInheritedBetweenPipelines) {
// Check success when vertex buffer is inherited from previous pipeline // Check success when vertex buffer is inherited from previous pipeline
encoder = device.CreateCommandEncoder(); encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline2); pass.SetPipeline(pipeline2);
pass.SetVertexBuffer(0, vertexBuffer1); pass.SetVertexBuffer(0, vertexBuffer1);
pass.SetVertexBuffer(1, vertexBuffer2); pass.SetVertexBuffer(1, vertexBuffer2);
@ -132,9 +132,9 @@ TEST_F(VertexBufferValidationTest, VertexBuffersNotInheritedBetweenRendePasses)
auto vertexBuffer2 = MakeVertexBuffer(); auto vertexBuffer2 = MakeVertexBuffer();
// Check success when vertex buffer is set for each render pass // Check success when vertex buffer is set for each render pass
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline2); pass.SetPipeline(pipeline2);
pass.SetVertexBuffer(0, vertexBuffer1); pass.SetVertexBuffer(0, vertexBuffer1);
pass.SetVertexBuffer(1, vertexBuffer2); pass.SetVertexBuffer(1, vertexBuffer2);
@ -142,7 +142,7 @@ TEST_F(VertexBufferValidationTest, VertexBuffersNotInheritedBetweenRendePasses)
pass.EndPass(); pass.EndPass();
} }
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline1); pass.SetPipeline(pipeline1);
pass.SetVertexBuffer(0, vertexBuffer1); pass.SetVertexBuffer(0, vertexBuffer1);
pass.Draw(3, 1, 0, 0); pass.Draw(3, 1, 0, 0);
@ -153,7 +153,7 @@ TEST_F(VertexBufferValidationTest, VertexBuffersNotInheritedBetweenRendePasses)
// Check failure because vertex buffer is not inherited in second subpass // Check failure because vertex buffer is not inherited in second subpass
encoder = device.CreateCommandEncoder(); encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline2); pass.SetPipeline(pipeline2);
pass.SetVertexBuffer(0, vertexBuffer1); pass.SetVertexBuffer(0, vertexBuffer1);
pass.SetVertexBuffer(1, vertexBuffer2); pass.SetVertexBuffer(1, vertexBuffer2);
@ -161,7 +161,7 @@ TEST_F(VertexBufferValidationTest, VertexBuffersNotInheritedBetweenRendePasses)
pass.EndPass(); pass.EndPass();
} }
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline1); pass.SetPipeline(pipeline1);
pass.Draw(3, 1, 0, 0); pass.Draw(3, 1, 0, 0);
pass.EndPass(); pass.EndPass();

View File

@ -22,9 +22,9 @@ class VertexInputTest : public ValidationTest {
void CreatePipeline(bool success, void CreatePipeline(bool success,
const utils::ComboVertexInputDescriptor& state, const utils::ComboVertexInputDescriptor& state,
std::string vertexSource) { std::string vertexSource) {
dawn::ShaderModule vsModule = utils::CreateShaderModule( wgpu::ShaderModule vsModule = utils::CreateShaderModule(
device, utils::SingleShaderStage::Vertex, vertexSource.c_str()); device, utils::SingleShaderStage::Vertex, vertexSource.c_str());
dawn::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
@ -37,7 +37,7 @@ class VertexInputTest : public ValidationTest {
descriptor.vertexStage.module = vsModule; descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragmentStage.module = fsModule;
descriptor.vertexInput = &state; descriptor.vertexInput = &state;
descriptor.cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; descriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
if (!success) { if (!success) {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
@ -400,7 +400,7 @@ TEST_F(VertexInputTest, SetAttributeOffsetOutOfBounds) {
utils::ComboVertexInputDescriptor state; utils::ComboVertexInputDescriptor state;
state.bufferCount = 1; state.bufferCount = 1;
state.cBuffers[0].attributeCount = 1; state.cBuffers[0].attributeCount = 1;
state.cAttributes[0].offset = kMaxVertexAttributeEnd - sizeof(dawn::VertexFormat::Float); state.cAttributes[0].offset = kMaxVertexAttributeEnd - sizeof(wgpu::VertexFormat::Float);
CreatePipeline(true, state, R"( CreatePipeline(true, state, R"(
#version 450 #version 450
void main() { void main() {
@ -462,7 +462,7 @@ TEST_F(VertexInputTest, VertexFormatLargerThanNonZeroStride) {
state.bufferCount = 1; state.bufferCount = 1;
state.cBuffers[0].stride = 4; state.cBuffers[0].stride = 4;
state.cBuffers[0].attributeCount = 1; state.cBuffers[0].attributeCount = 1;
state.cAttributes[0].format = dawn::VertexFormat::Float4; state.cAttributes[0].format = wgpu::VertexFormat::Float4;
CreatePipeline(false, state, R"( CreatePipeline(false, state, R"(
#version 450 #version 450
void main() { void main() {

View File

@ -30,14 +30,14 @@ class WireArgumentTests : public WireTest {
// Test that the wire is able to send numerical values // Test that the wire is able to send numerical values
TEST_F(WireArgumentTests, ValueArgument) { TEST_F(WireArgumentTests, ValueArgument) {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr); WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder, nullptr); WGPUComputePassEncoder pass = wgpuCommandEncoderBeginComputePass(encoder, nullptr);
dawnComputePassEncoderDispatch(pass, 1, 2, 3); wgpuComputePassEncoderDispatch(pass, 1, 2, 3);
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
DawnComputePassEncoder apiPass = api.GetNewComputePassEncoder(); WGPUComputePassEncoder apiPass = api.GetNewComputePassEncoder();
EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder, nullptr)).WillOnce(Return(apiPass)); EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder, nullptr)).WillOnce(Return(apiPass));
EXPECT_CALL(api, ComputePassEncoderDispatch(apiPass, 1, 2, 3)).Times(1); EXPECT_CALL(api, ComputePassEncoderDispatch(apiPass, 1, 2, 3)).Times(1);
@ -48,36 +48,36 @@ TEST_F(WireArgumentTests, ValueArgument) {
// Test that the wire is able to send arrays of numerical values // Test that the wire is able to send arrays of numerical values
TEST_F(WireArgumentTests, ValueArrayArgument) { TEST_F(WireArgumentTests, ValueArrayArgument) {
// Create a bindgroup. // Create a bindgroup.
DawnBindGroupLayoutDescriptor bglDescriptor; WGPUBindGroupLayoutDescriptor bglDescriptor;
bglDescriptor.nextInChain = nullptr; bglDescriptor.nextInChain = nullptr;
bglDescriptor.bindingCount = 0; bglDescriptor.bindingCount = 0;
bglDescriptor.bindings = nullptr; bglDescriptor.bindings = nullptr;
DawnBindGroupLayout bgl = dawnDeviceCreateBindGroupLayout(device, &bglDescriptor); WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDescriptor);
DawnBindGroupLayout apiBgl = api.GetNewBindGroupLayout(); WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl)); EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl));
DawnBindGroupDescriptor bindGroupDescriptor; WGPUBindGroupDescriptor bindGroupDescriptor;
bindGroupDescriptor.nextInChain = nullptr; bindGroupDescriptor.nextInChain = nullptr;
bindGroupDescriptor.layout = bgl; bindGroupDescriptor.layout = bgl;
bindGroupDescriptor.bindingCount = 0; bindGroupDescriptor.bindingCount = 0;
bindGroupDescriptor.bindings = nullptr; bindGroupDescriptor.bindings = nullptr;
DawnBindGroup bindGroup = dawnDeviceCreateBindGroup(device, &bindGroupDescriptor); WGPUBindGroup bindGroup = wgpuDeviceCreateBindGroup(device, &bindGroupDescriptor);
DawnBindGroup apiBindGroup = api.GetNewBindGroup(); WGPUBindGroup apiBindGroup = api.GetNewBindGroup();
EXPECT_CALL(api, DeviceCreateBindGroup(apiDevice, _)).WillOnce(Return(apiBindGroup)); EXPECT_CALL(api, DeviceCreateBindGroup(apiDevice, _)).WillOnce(Return(apiBindGroup));
// Use the bindgroup in SetBindGroup that takes an array of value offsets. // Use the bindgroup in SetBindGroup that takes an array of value offsets.
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr); WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
DawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder, nullptr); WGPUComputePassEncoder pass = wgpuCommandEncoderBeginComputePass(encoder, nullptr);
std::array<uint64_t, 4> testOffsets = {0, 42, 0xDEAD'BEEF'DEAD'BEEFu, 0xFFFF'FFFF'FFFF'FFFFu}; std::array<uint64_t, 4> testOffsets = {0, 42, 0xDEAD'BEEF'DEAD'BEEFu, 0xFFFF'FFFF'FFFF'FFFFu};
dawnComputePassEncoderSetBindGroup(pass, 0, bindGroup, testOffsets.size(), testOffsets.data()); wgpuComputePassEncoderSetBindGroup(pass, 0, bindGroup, testOffsets.size(), testOffsets.data());
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
DawnComputePassEncoder apiPass = api.GetNewComputePassEncoder(); WGPUComputePassEncoder apiPass = api.GetNewComputePassEncoder();
EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder, nullptr)).WillOnce(Return(apiPass)); EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder, nullptr)).WillOnce(Return(apiPass));
EXPECT_CALL(api, ComputePassEncoderSetBindGroup( EXPECT_CALL(api, ComputePassEncoderSetBindGroup(
@ -97,76 +97,76 @@ TEST_F(WireArgumentTests, ValueArrayArgument) {
// Test that the wire is able to send C strings // Test that the wire is able to send C strings
TEST_F(WireArgumentTests, CStringArgument) { TEST_F(WireArgumentTests, CStringArgument) {
// Create shader module // Create shader module
DawnShaderModuleDescriptor vertexDescriptor; WGPUShaderModuleDescriptor vertexDescriptor;
vertexDescriptor.nextInChain = nullptr; vertexDescriptor.nextInChain = nullptr;
vertexDescriptor.codeSize = 0; vertexDescriptor.codeSize = 0;
DawnShaderModule vsModule = dawnDeviceCreateShaderModule(device, &vertexDescriptor); WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
DawnShaderModule apiVsModule = api.GetNewShaderModule(); WGPUShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
// Create the color state descriptor // Create the color state descriptor
DawnBlendDescriptor blendDescriptor; WGPUBlendDescriptor blendDescriptor;
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD; blendDescriptor.operation = WGPUBlendOperation_Add;
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE; blendDescriptor.srcFactor = WGPUBlendFactor_One;
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE; blendDescriptor.dstFactor = WGPUBlendFactor_One;
DawnColorStateDescriptor colorStateDescriptor; WGPUColorStateDescriptor colorStateDescriptor;
colorStateDescriptor.nextInChain = nullptr; colorStateDescriptor.nextInChain = nullptr;
colorStateDescriptor.format = DAWN_TEXTURE_FORMAT_RGBA8_UNORM; colorStateDescriptor.format = WGPUTextureFormat_RGBA8Unorm;
colorStateDescriptor.alphaBlend = blendDescriptor; colorStateDescriptor.alphaBlend = blendDescriptor;
colorStateDescriptor.colorBlend = blendDescriptor; colorStateDescriptor.colorBlend = blendDescriptor;
colorStateDescriptor.writeMask = DAWN_COLOR_WRITE_MASK_ALL; colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
// Create the input state // Create the input state
DawnVertexInputDescriptor vertexInput; WGPUVertexInputDescriptor vertexInput;
vertexInput.nextInChain = nullptr; vertexInput.nextInChain = nullptr;
vertexInput.indexFormat = DAWN_INDEX_FORMAT_UINT32; vertexInput.indexFormat = WGPUIndexFormat_Uint32;
vertexInput.bufferCount = 0; vertexInput.bufferCount = 0;
vertexInput.buffers = nullptr; vertexInput.buffers = nullptr;
// Create the rasterization state // Create the rasterization state
DawnRasterizationStateDescriptor rasterizationState; WGPURasterizationStateDescriptor rasterizationState;
rasterizationState.nextInChain = nullptr; rasterizationState.nextInChain = nullptr;
rasterizationState.frontFace = DAWN_FRONT_FACE_CCW; rasterizationState.frontFace = WGPUFrontFace_CCW;
rasterizationState.cullMode = DAWN_CULL_MODE_NONE; rasterizationState.cullMode = WGPUCullMode_None;
rasterizationState.depthBias = 0; rasterizationState.depthBias = 0;
rasterizationState.depthBiasSlopeScale = 0.0; rasterizationState.depthBiasSlopeScale = 0.0;
rasterizationState.depthBiasClamp = 0.0; rasterizationState.depthBiasClamp = 0.0;
// Create the depth-stencil state // Create the depth-stencil state
DawnStencilStateFaceDescriptor stencilFace; WGPUStencilStateFaceDescriptor stencilFace;
stencilFace.compare = DAWN_COMPARE_FUNCTION_ALWAYS; stencilFace.compare = WGPUCompareFunction_Always;
stencilFace.failOp = DAWN_STENCIL_OPERATION_KEEP; stencilFace.failOp = WGPUStencilOperation_Keep;
stencilFace.depthFailOp = DAWN_STENCIL_OPERATION_KEEP; stencilFace.depthFailOp = WGPUStencilOperation_Keep;
stencilFace.passOp = DAWN_STENCIL_OPERATION_KEEP; stencilFace.passOp = WGPUStencilOperation_Keep;
DawnDepthStencilStateDescriptor depthStencilState; WGPUDepthStencilStateDescriptor depthStencilState;
depthStencilState.nextInChain = nullptr; depthStencilState.nextInChain = nullptr;
depthStencilState.format = DAWN_TEXTURE_FORMAT_DEPTH24_PLUS_STENCIL8; depthStencilState.format = WGPUTextureFormat_Depth24PlusStencil8;
depthStencilState.depthWriteEnabled = false; depthStencilState.depthWriteEnabled = false;
depthStencilState.depthCompare = DAWN_COMPARE_FUNCTION_ALWAYS; depthStencilState.depthCompare = WGPUCompareFunction_Always;
depthStencilState.stencilBack = stencilFace; depthStencilState.stencilBack = stencilFace;
depthStencilState.stencilFront = stencilFace; depthStencilState.stencilFront = stencilFace;
depthStencilState.stencilReadMask = 0xff; depthStencilState.stencilReadMask = 0xff;
depthStencilState.stencilWriteMask = 0xff; depthStencilState.stencilWriteMask = 0xff;
// Create the pipeline layout // Create the pipeline layout
DawnPipelineLayoutDescriptor layoutDescriptor; WGPUPipelineLayoutDescriptor layoutDescriptor;
layoutDescriptor.nextInChain = nullptr; layoutDescriptor.nextInChain = nullptr;
layoutDescriptor.bindGroupLayoutCount = 0; layoutDescriptor.bindGroupLayoutCount = 0;
layoutDescriptor.bindGroupLayouts = nullptr; layoutDescriptor.bindGroupLayouts = nullptr;
DawnPipelineLayout layout = dawnDeviceCreatePipelineLayout(device, &layoutDescriptor); WGPUPipelineLayout layout = wgpuDeviceCreatePipelineLayout(device, &layoutDescriptor);
DawnPipelineLayout apiLayout = api.GetNewPipelineLayout(); WGPUPipelineLayout apiLayout = api.GetNewPipelineLayout();
EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout)); EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout));
// Create pipeline // Create pipeline
DawnRenderPipelineDescriptor pipelineDescriptor; WGPURenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.nextInChain = nullptr; pipelineDescriptor.nextInChain = nullptr;
pipelineDescriptor.vertexStage.nextInChain = nullptr; pipelineDescriptor.vertexStage.nextInChain = nullptr;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertexStage.entryPoint = "main";
DawnProgrammableStageDescriptor fragmentStage; WGPUProgrammableStageDescriptor fragmentStage;
fragmentStage.nextInChain = nullptr; fragmentStage.nextInChain = nullptr;
fragmentStage.module = vsModule; fragmentStage.module = vsModule;
fragmentStage.entryPoint = "main"; fragmentStage.entryPoint = "main";
@ -180,16 +180,16 @@ TEST_F(WireArgumentTests, CStringArgument) {
pipelineDescriptor.alphaToCoverageEnabled = false; pipelineDescriptor.alphaToCoverageEnabled = false;
pipelineDescriptor.layout = layout; pipelineDescriptor.layout = layout;
pipelineDescriptor.vertexInput = &vertexInput; pipelineDescriptor.vertexInput = &vertexInput;
pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; pipelineDescriptor.primitiveTopology = WGPUPrimitiveTopology_TriangleList;
pipelineDescriptor.rasterizationState = &rasterizationState; pipelineDescriptor.rasterizationState = &rasterizationState;
pipelineDescriptor.depthStencilState = &depthStencilState; pipelineDescriptor.depthStencilState = &depthStencilState;
dawnDeviceCreateRenderPipeline(device, &pipelineDescriptor); wgpuDeviceCreateRenderPipeline(device, &pipelineDescriptor);
DawnRenderPipeline apiDummyPipeline = api.GetNewRenderPipeline(); WGPURenderPipeline apiDummyPipeline = api.GetNewRenderPipeline();
EXPECT_CALL(api, EXPECT_CALL(api,
DeviceCreateRenderPipeline( DeviceCreateRenderPipeline(
apiDevice, MatchesLambda([](const DawnRenderPipelineDescriptor* desc) -> bool { apiDevice, MatchesLambda([](const WGPURenderPipelineDescriptor* desc) -> bool {
return desc->vertexStage.entryPoint == std::string("main"); return desc->vertexStage.entryPoint == std::string("main");
}))) })))
.WillOnce(Return(apiDummyPipeline)); .WillOnce(Return(apiDummyPipeline));
@ -200,23 +200,23 @@ TEST_F(WireArgumentTests, CStringArgument) {
// Test that the wire is able to send objects as value arguments // Test that the wire is able to send objects as value arguments
TEST_F(WireArgumentTests, ObjectAsValueArgument) { TEST_F(WireArgumentTests, ObjectAsValueArgument) {
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device, nullptr); WGPUCommandEncoder cmdBufEncoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
DawnCommandEncoder apiEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)).WillOnce(Return(apiEncoder));
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.size = 8; descriptor.size = 8;
descriptor.usage = descriptor.usage =
static_cast<DawnBufferUsage>(DAWN_BUFFER_USAGE_COPY_SRC | DAWN_BUFFER_USAGE_COPY_DST); static_cast<WGPUBufferUsage>(WGPUBufferUsage_CopySrc | WGPUBufferUsage_CopyDst);
DawnBuffer buffer = dawnDeviceCreateBuffer(device, &descriptor); WGPUBuffer buffer = wgpuDeviceCreateBuffer(device, &descriptor);
DawnBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _))
.WillOnce(Return(apiBuffer)) .WillOnce(Return(apiBuffer))
.RetiresOnSaturation(); .RetiresOnSaturation();
dawnCommandEncoderCopyBufferToBuffer(cmdBufEncoder, buffer, 0, buffer, 4, 4); wgpuCommandEncoderCopyBufferToBuffer(cmdBufEncoder, buffer, 0, buffer, 4, 4);
EXPECT_CALL(api, CommandEncoderCopyBufferToBuffer(apiEncoder, apiBuffer, 0, apiBuffer, 4, 4)); EXPECT_CALL(api, CommandEncoderCopyBufferToBuffer(apiEncoder, apiBuffer, 0, apiBuffer, 4, 4));
FlushClient(); FlushClient();
@ -224,17 +224,17 @@ TEST_F(WireArgumentTests, ObjectAsValueArgument) {
// Test that the wire is able to send array of objects // Test that the wire is able to send array of objects
TEST_F(WireArgumentTests, ObjectsAsPointerArgument) { TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
DawnCommandBuffer cmdBufs[2]; WGPUCommandBuffer cmdBufs[2];
DawnCommandBuffer apiCmdBufs[2]; WGPUCommandBuffer apiCmdBufs[2];
// Create two command buffers we need to use a GMock sequence otherwise the order of the // Create two command buffers we need to use a GMock sequence otherwise the order of the
// CreateCommandEncoder might be swapped since they are equivalent in term of matchers // CreateCommandEncoder might be swapped since they are equivalent in term of matchers
Sequence s; Sequence s;
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
DawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device, nullptr); WGPUCommandEncoder cmdBufEncoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
cmdBufs[i] = dawnCommandEncoderFinish(cmdBufEncoder, nullptr); cmdBufs[i] = wgpuCommandEncoderFinish(cmdBufEncoder, nullptr);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.InSequence(s) .InSequence(s)
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
@ -245,15 +245,15 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
} }
// Create queue // Create queue
DawnQueue queue = dawnDeviceCreateQueue(device); WGPUQueue queue = wgpuDeviceCreateQueue(device);
DawnQueue apiQueue = api.GetNewQueue(); WGPUQueue apiQueue = api.GetNewQueue();
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue)); EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue));
// Submit command buffer and check we got a call with both API-side command buffers // Submit command buffer and check we got a call with both API-side command buffers
dawnQueueSubmit(queue, 2, cmdBufs); wgpuQueueSubmit(queue, 2, cmdBufs);
EXPECT_CALL( EXPECT_CALL(
api, QueueSubmit(apiQueue, 2, MatchesLambda([=](const DawnCommandBuffer* cmdBufs) -> bool { api, QueueSubmit(apiQueue, 2, MatchesLambda([=](const WGPUCommandBuffer* cmdBufs) -> bool {
return cmdBufs[0] == apiCmdBufs[0] && cmdBufs[1] == apiCmdBufs[1]; return cmdBufs[0] == apiCmdBufs[0] && cmdBufs[1] == apiCmdBufs[1];
}))); })));
@ -262,31 +262,31 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
// Test that the wire is able to send structures that contain pure values (non-objects) // Test that the wire is able to send structures that contain pure values (non-objects)
TEST_F(WireArgumentTests, StructureOfValuesArgument) { TEST_F(WireArgumentTests, StructureOfValuesArgument) {
DawnSamplerDescriptor descriptor; WGPUSamplerDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.magFilter = DAWN_FILTER_MODE_LINEAR; descriptor.magFilter = WGPUFilterMode_Linear;
descriptor.minFilter = DAWN_FILTER_MODE_NEAREST; descriptor.minFilter = WGPUFilterMode_Nearest;
descriptor.mipmapFilter = DAWN_FILTER_MODE_LINEAR; descriptor.mipmapFilter = WGPUFilterMode_Linear;
descriptor.addressModeU = DAWN_ADDRESS_MODE_CLAMP_TO_EDGE; descriptor.addressModeU = WGPUAddressMode_ClampToEdge;
descriptor.addressModeV = DAWN_ADDRESS_MODE_REPEAT; descriptor.addressModeV = WGPUAddressMode_Repeat;
descriptor.addressModeW = DAWN_ADDRESS_MODE_MIRROR_REPEAT; descriptor.addressModeW = WGPUAddressMode_MirrorRepeat;
descriptor.lodMinClamp = kLodMin; descriptor.lodMinClamp = kLodMin;
descriptor.lodMaxClamp = kLodMax; descriptor.lodMaxClamp = kLodMax;
descriptor.compare = DAWN_COMPARE_FUNCTION_NEVER; descriptor.compare = WGPUCompareFunction_Never;
dawnDeviceCreateSampler(device, &descriptor); wgpuDeviceCreateSampler(device, &descriptor);
DawnSampler apiDummySampler = api.GetNewSampler(); WGPUSampler apiDummySampler = api.GetNewSampler();
EXPECT_CALL(api, DeviceCreateSampler( EXPECT_CALL(api, DeviceCreateSampler(
apiDevice, MatchesLambda([](const DawnSamplerDescriptor* desc) -> bool { apiDevice, MatchesLambda([](const WGPUSamplerDescriptor* desc) -> bool {
return desc->nextInChain == nullptr && return desc->nextInChain == nullptr &&
desc->magFilter == DAWN_FILTER_MODE_LINEAR && desc->magFilter == WGPUFilterMode_Linear &&
desc->minFilter == DAWN_FILTER_MODE_NEAREST && desc->minFilter == WGPUFilterMode_Nearest &&
desc->mipmapFilter == DAWN_FILTER_MODE_LINEAR && desc->mipmapFilter == WGPUFilterMode_Linear &&
desc->addressModeU == DAWN_ADDRESS_MODE_CLAMP_TO_EDGE && desc->addressModeU == WGPUAddressMode_ClampToEdge &&
desc->addressModeV == DAWN_ADDRESS_MODE_REPEAT && desc->addressModeV == WGPUAddressMode_Repeat &&
desc->addressModeW == DAWN_ADDRESS_MODE_MIRROR_REPEAT && desc->addressModeW == WGPUAddressMode_MirrorRepeat &&
desc->compare == DAWN_COMPARE_FUNCTION_NEVER && desc->compare == WGPUCompareFunction_Never &&
desc->lodMinClamp == kLodMin && desc->lodMaxClamp == kLodMax; desc->lodMinClamp == kLodMin && desc->lodMaxClamp == kLodMax;
}))) })))
.WillOnce(Return(apiDummySampler)); .WillOnce(Return(apiDummySampler));
@ -296,26 +296,26 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
// Test that the wire is able to send structures that contain objects // Test that the wire is able to send structures that contain objects
TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) { TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
DawnBindGroupLayoutDescriptor bglDescriptor; WGPUBindGroupLayoutDescriptor bglDescriptor;
bglDescriptor.nextInChain = nullptr; bglDescriptor.nextInChain = nullptr;
bglDescriptor.bindingCount = 0; bglDescriptor.bindingCount = 0;
bglDescriptor.bindings = nullptr; bglDescriptor.bindings = nullptr;
DawnBindGroupLayout bgl = dawnDeviceCreateBindGroupLayout(device, &bglDescriptor); WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDescriptor);
DawnBindGroupLayout apiBgl = api.GetNewBindGroupLayout(); WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl)); EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)).WillOnce(Return(apiBgl));
DawnPipelineLayoutDescriptor descriptor; WGPUPipelineLayoutDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.bindGroupLayoutCount = 1; descriptor.bindGroupLayoutCount = 1;
descriptor.bindGroupLayouts = &bgl; descriptor.bindGroupLayouts = &bgl;
dawnDeviceCreatePipelineLayout(device, &descriptor); wgpuDeviceCreatePipelineLayout(device, &descriptor);
DawnPipelineLayout apiDummyLayout = api.GetNewPipelineLayout(); WGPUPipelineLayout apiDummyLayout = api.GetNewPipelineLayout();
EXPECT_CALL(api, DeviceCreatePipelineLayout( EXPECT_CALL(api, DeviceCreatePipelineLayout(
apiDevice, apiDevice,
MatchesLambda([apiBgl](const DawnPipelineLayoutDescriptor* desc) -> bool { MatchesLambda([apiBgl](const WGPUPipelineLayoutDescriptor* desc) -> bool {
return desc->nextInChain == nullptr && return desc->nextInChain == nullptr &&
desc->bindGroupLayoutCount == 1 && desc->bindGroupLayoutCount == 1 &&
desc->bindGroupLayouts[0] == apiBgl; desc->bindGroupLayouts[0] == apiBgl;
@ -328,25 +328,25 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
// Test that the wire is able to send structures that contain objects // Test that the wire is able to send structures that contain objects
TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) { TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
static constexpr int NUM_BINDINGS = 3; static constexpr int NUM_BINDINGS = 3;
DawnBindGroupLayoutBinding bindings[NUM_BINDINGS]{ WGPUBindGroupLayoutBinding bindings[NUM_BINDINGS]{
{0, DAWN_SHADER_STAGE_VERTEX, DAWN_BINDING_TYPE_SAMPLER, false, false, {0, WGPUShaderStage_Vertex, WGPUBindingType_Sampler, false, false,
DAWN_TEXTURE_VIEW_DIMENSION_2D, DAWN_TEXTURE_COMPONENT_TYPE_FLOAT}, WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float},
{1, DAWN_SHADER_STAGE_VERTEX, DAWN_BINDING_TYPE_SAMPLED_TEXTURE, false, false, {1, WGPUShaderStage_Vertex, WGPUBindingType_SampledTexture, false, false,
DAWN_TEXTURE_VIEW_DIMENSION_2D, DAWN_TEXTURE_COMPONENT_TYPE_FLOAT}, WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float},
{2, static_cast<DawnShaderStage>(DAWN_SHADER_STAGE_VERTEX | DAWN_SHADER_STAGE_FRAGMENT), {2, static_cast<WGPUShaderStage>(WGPUShaderStage_Vertex | WGPUShaderStage_Fragment),
DAWN_BINDING_TYPE_UNIFORM_BUFFER, false, false, DAWN_TEXTURE_VIEW_DIMENSION_2D, WGPUBindingType_UniformBuffer, false, false, WGPUTextureViewDimension_2D,
DAWN_TEXTURE_COMPONENT_TYPE_FLOAT}, WGPUTextureComponentType_Float},
}; };
DawnBindGroupLayoutDescriptor bglDescriptor; WGPUBindGroupLayoutDescriptor bglDescriptor;
bglDescriptor.bindingCount = NUM_BINDINGS; bglDescriptor.bindingCount = NUM_BINDINGS;
bglDescriptor.bindings = bindings; bglDescriptor.bindings = bindings;
dawnDeviceCreateBindGroupLayout(device, &bglDescriptor); wgpuDeviceCreateBindGroupLayout(device, &bglDescriptor);
DawnBindGroupLayout apiBgl = api.GetNewBindGroupLayout(); WGPUBindGroupLayout apiBgl = api.GetNewBindGroupLayout();
EXPECT_CALL( EXPECT_CALL(
api, api,
DeviceCreateBindGroupLayout( DeviceCreateBindGroupLayout(
apiDevice, MatchesLambda([bindings](const DawnBindGroupLayoutDescriptor* desc) -> bool { apiDevice, MatchesLambda([bindings](const WGPUBindGroupLayoutDescriptor* desc) -> bool {
for (int i = 0; i < NUM_BINDINGS; ++i) { for (int i = 0; i < NUM_BINDINGS; ++i) {
const auto& a = desc->bindings[i]; const auto& a = desc->bindings[i];
const auto& b = bindings[i]; const auto& b = bindings[i];
@ -364,17 +364,17 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
// Test passing nullptr instead of objects - array of objects version // Test passing nullptr instead of objects - array of objects version
TEST_F(WireArgumentTests, DISABLED_NullptrInArray) { TEST_F(WireArgumentTests, DISABLED_NullptrInArray) {
DawnBindGroupLayout nullBGL = nullptr; WGPUBindGroupLayout nullBGL = nullptr;
DawnPipelineLayoutDescriptor descriptor; WGPUPipelineLayoutDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.bindGroupLayoutCount = 1; descriptor.bindGroupLayoutCount = 1;
descriptor.bindGroupLayouts = &nullBGL; descriptor.bindGroupLayouts = &nullBGL;
dawnDeviceCreatePipelineLayout(device, &descriptor); wgpuDeviceCreatePipelineLayout(device, &descriptor);
EXPECT_CALL(api, EXPECT_CALL(api,
DeviceCreatePipelineLayout( DeviceCreatePipelineLayout(
apiDevice, MatchesLambda([](const DawnPipelineLayoutDescriptor* desc) -> bool { apiDevice, MatchesLambda([](const WGPUPipelineLayoutDescriptor* desc) -> bool {
return desc->nextInChain == nullptr && desc->bindGroupLayoutCount == 1 && return desc->nextInChain == nullptr && desc->bindGroupLayoutCount == 1 &&
desc->bindGroupLayouts[0] == nullptr; desc->bindGroupLayouts[0] == nullptr;
}))) })))

View File

@ -26,9 +26,9 @@ class WireBasicTests : public WireTest {
// One call gets forwarded correctly. // One call gets forwarded correctly.
TEST_F(WireBasicTests, CallForwarded) { TEST_F(WireBasicTests, CallForwarded) {
dawnDeviceCreateCommandEncoder(device, nullptr); wgpuDeviceCreateCommandEncoder(device, nullptr);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
@ -37,14 +37,14 @@ TEST_F(WireBasicTests, CallForwarded) {
// Test that calling methods on a new object works as expected. // Test that calling methods on a new object works as expected.
TEST_F(WireBasicTests, CreateThenCall) { TEST_F(WireBasicTests, CreateThenCall) {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr); WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
dawnCommandEncoderFinish(encoder, nullptr); wgpuCommandEncoderFinish(encoder, nullptr);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
DawnCommandBuffer apiCmdBuf = api.GetNewCommandBuffer(); WGPUCommandBuffer apiCmdBuf = api.GetNewCommandBuffer();
EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder, nullptr)).WillOnce(Return(apiCmdBuf)); EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder, nullptr)).WillOnce(Return(apiCmdBuf));
FlushClient(); FlushClient();
@ -52,12 +52,12 @@ TEST_F(WireBasicTests, CreateThenCall) {
// Test that client reference/release do not call the backend API. // Test that client reference/release do not call the backend API.
TEST_F(WireBasicTests, RefCountKeptInClient) { TEST_F(WireBasicTests, RefCountKeptInClient) {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr); WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
dawnCommandEncoderReference(encoder); wgpuCommandEncoderReference(encoder);
dawnCommandEncoderRelease(encoder); wgpuCommandEncoderRelease(encoder);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));
@ -66,11 +66,11 @@ TEST_F(WireBasicTests, RefCountKeptInClient) {
// Test that client reference/release do not call the backend API. // Test that client reference/release do not call the backend API.
TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) { TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) {
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr); WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
dawnCommandEncoderRelease(encoder); wgpuCommandEncoderRelease(encoder);
DawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder(); WGPUCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
.WillOnce(Return(apiCmdBufEncoder)); .WillOnce(Return(apiCmdBufEncoder));

View File

@ -23,14 +23,14 @@ namespace {
class MockBufferMapReadCallback { class MockBufferMapReadCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD4(Call,
void(DawnBufferMapAsyncStatus status, void(WGPUBufferMapAsyncStatus status,
const uint32_t* ptr, const uint32_t* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata)); void* userdata));
}; };
std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback; std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback;
void ToMockBufferMapReadCallback(DawnBufferMapAsyncStatus status, void ToMockBufferMapReadCallback(WGPUBufferMapAsyncStatus status,
const void* ptr, const void* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata) { void* userdata) {
@ -42,7 +42,7 @@ namespace {
class MockBufferMapWriteCallback { class MockBufferMapWriteCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD4(Call,
void(DawnBufferMapAsyncStatus status, void(WGPUBufferMapAsyncStatus status,
uint32_t* ptr, uint32_t* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata)); void* userdata));
@ -50,7 +50,7 @@ namespace {
std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback; std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback;
uint32_t* lastMapWritePointer = nullptr; uint32_t* lastMapWritePointer = nullptr;
void ToMockBufferMapWriteCallback(DawnBufferMapAsyncStatus status, void ToMockBufferMapWriteCallback(WGPUBufferMapAsyncStatus status,
void* ptr, void* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata) { void* userdata) {
@ -62,8 +62,8 @@ namespace {
class MockBufferCreateMappedCallback { class MockBufferCreateMappedCallback {
public: public:
MOCK_METHOD5(Call, MOCK_METHOD5(Call,
void(DawnBufferMapAsyncStatus status, void(WGPUBufferMapAsyncStatus status,
DawnBuffer buffer, WGPUBuffer buffer,
uint32_t* ptr, uint32_t* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata)); void* userdata));
@ -71,12 +71,12 @@ namespace {
std::unique_ptr<StrictMock<MockBufferCreateMappedCallback>> mockCreateBufferMappedCallback; std::unique_ptr<StrictMock<MockBufferCreateMappedCallback>> mockCreateBufferMappedCallback;
uint32_t* lastCreateMappedPointer = nullptr; uint32_t* lastCreateMappedPointer = nullptr;
void ToMockCreateBufferMappedCallback(DawnBufferMapAsyncStatus status, void ToMockCreateBufferMappedCallback(WGPUBufferMapAsyncStatus status,
DawnCreateBufferMappedResult result, WGPUCreateBufferMappedResult result,
void* userdata) { void* userdata) {
// Assume the data is uint32_t to make writing matchers easier // Assume the data is uint32_t to make writing matchers easier
lastCreateMappedPointer = static_cast<uint32_t*>(result.data); lastCreateMappedPointer = static_cast<uint32_t*>(result.data);
// Unpack DawnCreateBufferMappedResult to make writing matchers easier // Unpack WGPUCreateBufferMappedResult to make writing matchers easier
mockCreateBufferMappedCallback->Call(status, result.buffer, lastCreateMappedPointer, mockCreateBufferMappedCallback->Call(status, result.buffer, lastCreateMappedPointer,
result.dataLength, userdata); result.dataLength, userdata);
} }
@ -97,13 +97,13 @@ class WireBufferMappingTests : public WireTest {
mockCreateBufferMappedCallback = mockCreateBufferMappedCallback =
std::make_unique<StrictMock<MockBufferCreateMappedCallback>>(); std::make_unique<StrictMock<MockBufferCreateMappedCallback>>();
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
apiBuffer = api.GetNewBuffer(); apiBuffer = api.GetNewBuffer();
buffer = dawnDeviceCreateBuffer(device, &descriptor); buffer = wgpuDeviceCreateBuffer(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _))
.WillOnce(Return(apiBuffer)) .WillOnce(Return(apiBuffer))
@ -131,32 +131,32 @@ class WireBufferMappingTests : public WireTest {
protected: protected:
static constexpr uint64_t kBufferSize = sizeof(uint32_t); static constexpr uint64_t kBufferSize = sizeof(uint32_t);
// A successfully created buffer // A successfully created buffer
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
}; };
// MapRead-specific tests // MapRead-specific tests
// Check mapping for reading a succesfully created buffer // Check mapping for reading a succesfully created buffer
TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) { TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent, api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
kBufferSize); kBufferSize);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, EXPECT_CALL(*mockBufferMapReadCallback,
Pointee(Eq(bufferContent)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(bufferContent)), kBufferSize, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
FlushClient(); FlushClient();
@ -165,16 +165,16 @@ TEST_F(WireBufferMappingTests, MappingForReadSuccessBuffer) {
// Check that things work correctly when a validation error happens when mapping the buffer for // Check that things work correctly when a validation error happens when mapping the buffer for
// reading // reading
TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) { TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0); api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _)) EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
@ -183,19 +183,18 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
// Check that the map read callback is called with UNKNOWN when the buffer is destroyed before the // Check that the map read callback is called with UNKNOWN when the buffer is destroyed before the
// request is finished // request is finished
TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) { TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
// Return success // Return success
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, nullptr, 0); api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, nullptr, 0);
})); }));
// Destroy before the client gets the success, so the callback is called with unknown. // Destroy before the client gets the success, so the callback is called with unknown.
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
.Times(1); .Times(1);
dawnBufferRelease(buffer); wgpuBufferRelease(buffer);
EXPECT_CALL(api, BufferRelease(apiBuffer)); EXPECT_CALL(api, BufferRelease(apiBuffer));
FlushClient(); FlushClient();
@ -205,22 +204,21 @@ TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
// Check the map read callback is called with UNKNOWN when the map request would have worked, but // Check the map read callback is called with UNKNOWN when the map request would have worked, but
// Unmap was called // Unmap was called
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) { TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent, api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
kBufferSize); kBufferSize);
})); }));
FlushClient(); FlushClient();
// Oh no! We are calling Unmap too early! // Oh no! We are calling Unmap too early!
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
.Times(1); .Times(1);
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
// The callback shouldn't get called, even when the request succeeded on the server side // The callback shouldn't get called, even when the request succeeded on the server side
FlushServer(); FlushServer();
@ -229,34 +227,34 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForRead) {
// Check that an error map read callback gets nullptr while a buffer is already mapped // Check that an error map read callback gets nullptr while a buffer is already mapped
TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullptr) { TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullptr) {
// Successful map // Successful map
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent, api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
kBufferSize); kBufferSize);
})) }))
.RetiresOnSaturation(); .RetiresOnSaturation();
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, EXPECT_CALL(*mockBufferMapReadCallback,
Pointee(Eq(bufferContent)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(bufferContent)), kBufferSize, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
// Map failure while the buffer is already mapped // Map failure while the buffer is already mapped
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0); api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _)) EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
@ -264,20 +262,20 @@ TEST_F(WireBufferMappingTests, MappingForReadingErrorWhileAlreadyMappedGetsNullp
// Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback // Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback
TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) { TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent, api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
kBufferSize); kBufferSize);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, EXPECT_CALL(*mockBufferMapReadCallback,
Pointee(Eq(bufferContent)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(bufferContent)), kBufferSize, _))
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); })); .WillOnce(InvokeWithoutArgs([&]() { wgpuBufferUnmap(buffer); }));
FlushServer(); FlushServer();
@ -289,20 +287,20 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapReadCallback) {
// Test that the MapReadCallback isn't fired twice the buffer external refcount reaches 0 in the // Test that the MapReadCallback isn't fired twice the buffer external refcount reaches 0 in the
// callback // callback
TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) { TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &bufferContent, api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
kBufferSize); kBufferSize);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, EXPECT_CALL(*mockBufferMapReadCallback,
Pointee(Eq(bufferContent)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(bufferContent)), kBufferSize, _))
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); })); .WillOnce(InvokeWithoutArgs([&]() { wgpuBufferRelease(buffer); }));
FlushServer(); FlushServer();
@ -315,7 +313,7 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapReadCallback) {
// Check mapping for writing a succesfully created buffer // Check mapping for writing a succesfully created buffer
TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) { TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
uint32_t serverBufferContent = 31337; uint32_t serverBufferContent = 31337;
uint32_t updatedContent = 4242; uint32_t updatedContent = 4242;
@ -323,7 +321,7 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
&serverBufferContent, kBufferSize); &serverBufferContent, kBufferSize);
})); }));
@ -331,7 +329,7 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
// The map write callback always gets a buffer full of zeroes. // The map write callback always gets a buffer full of zeroes.
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(zero)), kBufferSize, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
@ -339,7 +337,7 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
// Write something to the mapped pointer // Write something to the mapped pointer
*lastMapWritePointer = updatedContent; *lastMapWritePointer = updatedContent;
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
FlushClient(); FlushClient();
@ -351,17 +349,16 @@ TEST_F(WireBufferMappingTests, MappingForWriteSuccessBuffer) {
// Check that things work correctly when a validation error happens when mapping the buffer for // Check that things work correctly when a validation error happens when mapping the buffer for
// writing // writing
TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) { TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0); api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
@ -370,19 +367,18 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
// Check that the map write callback is called with UNKNOWN when the buffer is destroyed before the // Check that the map write callback is called with UNKNOWN when the buffer is destroyed before the
// request is finished // request is finished
TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) { TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
// Return success // Return success
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, nullptr, 0); api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, nullptr, 0);
})); }));
// Destroy before the client gets the success, so the callback is called with unknown. // Destroy before the client gets the success, so the callback is called with unknown.
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
.Times(1); .Times(1);
dawnBufferRelease(buffer); wgpuBufferRelease(buffer);
EXPECT_CALL(api, BufferRelease(apiBuffer)); EXPECT_CALL(api, BufferRelease(apiBuffer));
FlushClient(); FlushClient();
@ -392,22 +388,21 @@ TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
// Check the map read callback is called with UNKNOWN when the map request would have worked, but // Check the map read callback is called with UNKNOWN when the map request would have worked, but
// Unmap was called // Unmap was called
TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) { TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
&bufferContent, kBufferSize); kBufferSize);
})); }));
FlushClient(); FlushClient();
// Oh no! We are calling Unmap too early! // Oh no! We are calling Unmap too early!
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
.Times(1); .Times(1);
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
// The callback shouldn't get called, even when the request succeeded on the server side // The callback shouldn't get called, even when the request succeeded on the server side
FlushServer(); FlushServer();
@ -416,36 +411,35 @@ TEST_F(WireBufferMappingTests, UnmapCalledTooEarlyForWrite) {
// Check that an error map read callback gets nullptr while a buffer is already mapped // Check that an error map read callback gets nullptr while a buffer is already mapped
TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullptr) { TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullptr) {
// Successful map // Successful map
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
uint32_t zero = 0; uint32_t zero = 0;
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
&bufferContent, kBufferSize); kBufferSize);
})) }))
.RetiresOnSaturation(); .RetiresOnSaturation();
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(zero)), kBufferSize, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
// Map failure while the buffer is already mapped // Map failure while the buffer is already mapped
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0); api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
@ -453,21 +447,21 @@ TEST_F(WireBufferMappingTests, MappingForWritingErrorWhileAlreadyMappedGetsNullp
// Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback // Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback
TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) { TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
uint32_t zero = 0; uint32_t zero = 0;
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
&bufferContent, kBufferSize); kBufferSize);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(zero)), kBufferSize, _))
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); })); .WillOnce(InvokeWithoutArgs([&]() { wgpuBufferUnmap(buffer); }));
FlushServer(); FlushServer();
@ -479,21 +473,21 @@ TEST_F(WireBufferMappingTests, UnmapInsideMapWriteCallback) {
// Test that the MapWriteCallback isn't fired twice the buffer external refcount reaches 0 in the // Test that the MapWriteCallback isn't fired twice the buffer external refcount reaches 0 in the
// callback // callback
TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) { TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
uint32_t bufferContent = 31337; uint32_t bufferContent = 31337;
uint32_t zero = 0; uint32_t zero = 0;
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &bufferContent,
&bufferContent, kBufferSize); kBufferSize);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(zero)), kBufferSize, _))
.WillOnce(InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); })); .WillOnce(InvokeWithoutArgs([&]() { wgpuBufferRelease(buffer); }));
FlushServer(); FlushServer();
@ -504,19 +498,19 @@ TEST_F(WireBufferMappingTests, DestroyInsideMapWriteCallback) {
// Test successful CreateBufferMapped // Test successful CreateBufferMapped
TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) { TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = 4; descriptor.size = 4;
DawnBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
uint32_t apiBufferData = 1234; uint32_t apiBufferData = 1234;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&apiBufferData); apiResult.data = reinterpret_cast<uint8_t*>(&apiBufferData);
apiResult.dataLength = 4; apiResult.dataLength = 4;
DawnCreateBufferMappedResult result = dawnDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -524,7 +518,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) {
FlushClient(); FlushClient();
dawnBufferUnmap(result.buffer); wgpuBufferUnmap(result.buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
FlushClient(); FlushClient();
@ -532,19 +526,19 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedSuccess) {
// Test that releasing after CreateBufferMapped does not call Unmap // Test that releasing after CreateBufferMapped does not call Unmap
TEST_F(WireBufferMappingTests, ReleaseAfterCreateBufferMapped) { TEST_F(WireBufferMappingTests, ReleaseAfterCreateBufferMapped) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = 4; descriptor.size = 4;
DawnBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
uint32_t apiBufferData = 1234; uint32_t apiBufferData = 1234;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&apiBufferData); apiResult.data = reinterpret_cast<uint8_t*>(&apiBufferData);
apiResult.dataLength = 4; apiResult.dataLength = 4;
DawnCreateBufferMappedResult result = dawnDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -552,7 +546,7 @@ TEST_F(WireBufferMappingTests, ReleaseAfterCreateBufferMapped) {
FlushClient(); FlushClient();
dawnBufferRelease(result.buffer); wgpuBufferRelease(result.buffer);
EXPECT_CALL(api, BufferRelease(apiBuffer)).Times(1); EXPECT_CALL(api, BufferRelease(apiBuffer)).Times(1);
FlushClient(); FlushClient();
@ -560,19 +554,19 @@ TEST_F(WireBufferMappingTests, ReleaseAfterCreateBufferMapped) {
// Test that it is valid to map a buffer after CreateBufferMapped and Unmap // Test that it is valid to map a buffer after CreateBufferMapped and Unmap
TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) { TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = 4; descriptor.size = 4;
DawnBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
uint32_t apiBufferData = 9863; uint32_t apiBufferData = 9863;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&apiBufferData); apiResult.data = reinterpret_cast<uint8_t*>(&apiBufferData);
apiResult.dataLength = 4; apiResult.dataLength = 4;
DawnCreateBufferMappedResult result = dawnDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -580,24 +574,24 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
FlushClient(); FlushClient();
dawnBufferUnmap(result.buffer); wgpuBufferUnmap(result.buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
FlushClient(); FlushClient();
dawnBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr);
uint32_t zero = 0; uint32_t zero = 0;
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &apiBufferData,
&apiBufferData, kBufferSize); kBufferSize);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, Pointee(Eq(zero)), kBufferSize, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
@ -605,19 +599,19 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapSuccess) {
// Test that it is invalid to map a buffer after CreateBufferMapped before Unmap // Test that it is invalid to map a buffer after CreateBufferMapped before Unmap
TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) { TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = 4; descriptor.size = 4;
DawnBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
uint32_t apiBufferData = 9863; uint32_t apiBufferData = 9863;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&apiBufferData); apiResult.data = reinterpret_cast<uint8_t*>(&apiBufferData);
apiResult.dataLength = 4; apiResult.dataLength = 4;
DawnCreateBufferMappedResult result = dawnDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -625,22 +619,21 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
FlushClient(); FlushClient();
dawnBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(result.buffer, ToMockBufferMapWriteCallback, nullptr);
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0); api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
})); }));
FlushClient(); FlushClient();
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
.Times(1); .Times(1);
FlushServer(); FlushServer();
dawnBufferUnmap(result.buffer); wgpuBufferUnmap(result.buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
FlushClient(); FlushClient();
@ -648,12 +641,12 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
// Test successful CreateBufferMappedAsync // Test successful CreateBufferMappedAsync
TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) { TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
uint32_t serverBufferContent = 31337; uint32_t serverBufferContent = 31337;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&serverBufferContent); apiResult.data = reinterpret_cast<uint8_t*>(&serverBufferContent);
@ -662,7 +655,8 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
uint32_t updatedContent = 4242; uint32_t updatedContent = 4242;
uint32_t zero = 0; uint32_t zero = 0;
dawnDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback, nullptr); wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
nullptr);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -670,10 +664,10 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
FlushClient(); FlushClient();
DawnBuffer buffer; WGPUBuffer buffer;
// The callback always gets a buffer full of zeroes. // The callback always gets a buffer full of zeroes.
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, _, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, _, Pointee(Eq(zero)), kBufferSize, _))
.WillOnce(::testing::SaveArg<1>(&buffer)); .WillOnce(::testing::SaveArg<1>(&buffer));
FlushServer(); FlushServer();
@ -681,7 +675,7 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
// Write something to the mapped pointer // Write something to the mapped pointer
*lastCreateMappedPointer = updatedContent; *lastCreateMappedPointer = updatedContent;
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
FlushClient(); FlushClient();
@ -692,16 +686,17 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncSuccess) {
// Test CreateBufferMappedAsync with map error // Test CreateBufferMappedAsync with map error
TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncMapError) { TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncMapError) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = nullptr; // error mapping apiResult.data = nullptr; // error mapping
apiResult.dataLength = kBufferSize; apiResult.dataLength = kBufferSize;
dawnDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback, nullptr); wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
nullptr);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -709,14 +704,14 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncMapError) {
FlushClient(); FlushClient();
DawnBuffer buffer; WGPUBuffer buffer;
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, _, nullptr, 0, _)) Call(WGPUBufferMapAsyncStatus_Error, _, nullptr, 0, _))
.WillOnce(::testing::SaveArg<1>(&buffer)); .WillOnce(::testing::SaveArg<1>(&buffer));
FlushServer(); FlushServer();
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
FlushClient(); FlushClient();
@ -725,12 +720,12 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedAsyncMapError) {
// Test that the CreateBufferMappedCallback isn't fired twice when unmap() is called inside the // Test that the CreateBufferMappedCallback isn't fired twice when unmap() is called inside the
// callback // callback
TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) { TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
uint32_t serverBufferContent = 31337; uint32_t serverBufferContent = 31337;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&serverBufferContent); apiResult.data = reinterpret_cast<uint8_t*>(&serverBufferContent);
@ -738,7 +733,8 @@ TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) {
uint32_t zero = 0; uint32_t zero = 0;
dawnDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback, nullptr); wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
nullptr);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -746,12 +742,12 @@ TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) {
FlushClient(); FlushClient();
DawnBuffer buffer; WGPUBuffer buffer;
// The callback always gets a buffer full of zeroes. // The callback always gets a buffer full of zeroes.
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, _, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, _, Pointee(Eq(zero)), kBufferSize, _))
.WillOnce(DoAll(::testing::SaveArg<1>(&buffer), .WillOnce(DoAll(::testing::SaveArg<1>(&buffer),
InvokeWithoutArgs([&]() { dawnBufferUnmap(buffer); }))); InvokeWithoutArgs([&]() { wgpuBufferUnmap(buffer); })));
FlushServer(); FlushServer();
@ -763,12 +759,12 @@ TEST_F(WireBufferMappingTests, UnmapInsideCreateBufferMappedAsyncCallback) {
// Test that the CreateBufferMappedCallback isn't fired twice when the buffer is deleted inside // Test that the CreateBufferMappedCallback isn't fired twice when the buffer is deleted inside
// the callback // the callback
TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) { TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
uint32_t serverBufferContent = 31337; uint32_t serverBufferContent = 31337;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&serverBufferContent); apiResult.data = reinterpret_cast<uint8_t*>(&serverBufferContent);
@ -776,7 +772,8 @@ TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) {
uint32_t zero = 0; uint32_t zero = 0;
dawnDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback, nullptr); wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
nullptr);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -784,12 +781,12 @@ TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) {
FlushClient(); FlushClient();
DawnBuffer buffer; WGPUBuffer buffer;
// The callback always gets a buffer full of zeroes. // The callback always gets a buffer full of zeroes.
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, _, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, _, Pointee(Eq(zero)), kBufferSize, _))
.WillOnce(DoAll(::testing::SaveArg<1>(&buffer), .WillOnce(DoAll(::testing::SaveArg<1>(&buffer),
InvokeWithoutArgs([&]() { dawnBufferRelease(buffer); }))); InvokeWithoutArgs([&]() { wgpuBufferRelease(buffer); })));
FlushServer(); FlushServer();
@ -801,12 +798,12 @@ TEST_F(WireBufferMappingTests, ReleaseInsideCreateBufferMappedAsyncCallback) {
// Test that the CreateBufferMappedCallback isn't fired twice when the buffer is destroyed inside // Test that the CreateBufferMappedCallback isn't fired twice when the buffer is destroyed inside
// the callback // the callback
TEST_F(WireBufferMappingTests, DestroyInsideCreateBufferMappedAsyncCallback) { TEST_F(WireBufferMappingTests, DestroyInsideCreateBufferMappedAsyncCallback) {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = kBufferSize; descriptor.size = kBufferSize;
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
uint32_t serverBufferContent = 31337; uint32_t serverBufferContent = 31337;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&serverBufferContent); apiResult.data = reinterpret_cast<uint8_t*>(&serverBufferContent);
@ -814,7 +811,8 @@ TEST_F(WireBufferMappingTests, DestroyInsideCreateBufferMappedAsyncCallback) {
uint32_t zero = 0; uint32_t zero = 0;
dawnDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback, nullptr); wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
nullptr);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -822,12 +820,12 @@ TEST_F(WireBufferMappingTests, DestroyInsideCreateBufferMappedAsyncCallback) {
FlushClient(); FlushClient();
DawnBuffer buffer; WGPUBuffer buffer;
// The callback always gets a buffer full of zeroes. // The callback always gets a buffer full of zeroes.
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, _, Pointee(Eq(zero)), kBufferSize, _)) Call(WGPUBufferMapAsyncStatus_Success, _, Pointee(Eq(zero)), kBufferSize, _))
.WillOnce(DoAll(::testing::SaveArg<1>(&buffer), .WillOnce(DoAll(::testing::SaveArg<1>(&buffer),
InvokeWithoutArgs([&]() { dawnBufferDestroy(buffer); }))); InvokeWithoutArgs([&]() { wgpuBufferDestroy(buffer); })));
FlushServer(); FlushServer();

View File

@ -22,21 +22,23 @@ namespace {
// Mock classes to add expectations on the wire calling callbacks // Mock classes to add expectations on the wire calling callbacks
class MockDeviceErrorCallback { class MockDeviceErrorCallback {
public: public:
MOCK_METHOD3(Call, void(DawnErrorType type, const char* message, void* userdata)); MOCK_METHOD3(Call, void(WGPUErrorType type, const char* message, void* userdata));
}; };
std::unique_ptr<StrictMock<MockDeviceErrorCallback>> mockDeviceErrorCallback; std::unique_ptr<StrictMock<MockDeviceErrorCallback>> mockDeviceErrorCallback;
void ToMockDeviceErrorCallback(DawnErrorType type, const char* message, void* userdata) { void ToMockDeviceErrorCallback(WGPUErrorType type, const char* message, void* userdata) {
mockDeviceErrorCallback->Call(type, message, userdata); mockDeviceErrorCallback->Call(type, message, userdata);
} }
class MockDevicePopErrorScopeCallback { class MockDevicePopErrorScopeCallback {
public: public:
MOCK_METHOD3(Call, void(DawnErrorType type, const char* message, void* userdata)); MOCK_METHOD3(Call, void(WGPUErrorType type, const char* message, void* userdata));
}; };
std::unique_ptr<StrictMock<MockDevicePopErrorScopeCallback>> mockDevicePopErrorScopeCallback; std::unique_ptr<StrictMock<MockDevicePopErrorScopeCallback>> mockDevicePopErrorScopeCallback;
void ToMockDevicePopErrorScopeCallback(DawnErrorType type, const char* message, void* userdata) { void ToMockDevicePopErrorScopeCallback(WGPUErrorType type,
const char* message,
void* userdata) {
mockDevicePopErrorScopeCallback->Call(type, message, userdata); mockDevicePopErrorScopeCallback->Call(type, message, userdata);
} }
@ -72,38 +74,42 @@ class WireErrorCallbackTests : public WireTest {
// Test the return wire for device error callbacks // Test the return wire for device error callbacks
TEST_F(WireErrorCallbackTests, DeviceErrorCallback) { TEST_F(WireErrorCallbackTests, DeviceErrorCallback) {
dawnDeviceSetUncapturedErrorCallback(device, ToMockDeviceErrorCallback, this); wgpuDeviceSetUncapturedErrorCallback(device, ToMockDeviceErrorCallback, this);
// Setting the error callback should stay on the client side and do nothing // Setting the error callback should stay on the client side and do nothing
FlushClient(); FlushClient();
// Calling the callback on the server side will result in the callback being called on the // Calling the callback on the server side will result in the callback being called on the
// client side // client side
api.CallDeviceErrorCallback(apiDevice, DAWN_ERROR_TYPE_VALIDATION, "Some error message"); api.CallDeviceErrorCallback(apiDevice, WGPUErrorType_Validation, "Some error message");
EXPECT_CALL(*mockDeviceErrorCallback, Call(DAWN_ERROR_TYPE_VALIDATION, StrEq("Some error message"), this)).Times(1); EXPECT_CALL(*mockDeviceErrorCallback,
Call(WGPUErrorType_Validation, StrEq("Some error message"), this))
.Times(1);
FlushServer(); FlushServer();
} }
// Test the return wire for error scopes. // Test the return wire for error scopes.
TEST_F(WireErrorCallbackTests, PushPopErrorScopeCallback) { TEST_F(WireErrorCallbackTests, PushPopErrorScopeCallback) {
dawnDevicePushErrorScope(device, DAWN_ERROR_FILTER_VALIDATION); wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
EXPECT_CALL(api, DevicePushErrorScope(apiDevice, DAWN_ERROR_FILTER_VALIDATION)).Times(1); EXPECT_CALL(api, DevicePushErrorScope(apiDevice, WGPUErrorFilter_Validation)).Times(1);
FlushClient(); FlushClient();
dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this); wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
DawnErrorCallback callback; WGPUErrorCallback callback;
void* userdata; void* userdata;
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)) EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
.WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata), Return(true))); .WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata), Return(true)));
FlushClient(); FlushClient();
callback(DAWN_ERROR_TYPE_VALIDATION, "Some error message", userdata); callback(WGPUErrorType_Validation, "Some error message", userdata);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_VALIDATION, StrEq("Some error message"), this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback,
Call(WGPUErrorType_Validation, StrEq("Some error message"), this))
.Times(1);
FlushServer(); FlushServer();
} }
@ -112,17 +118,17 @@ TEST_F(WireErrorCallbackTests, PushPopErrorScopeCallback) {
TEST_F(WireErrorCallbackTests, PopErrorScopeCallbackOrdering) { TEST_F(WireErrorCallbackTests, PopErrorScopeCallbackOrdering) {
// Two error scopes are popped, and the first one returns first. // Two error scopes are popped, and the first one returns first.
{ {
dawnDevicePushErrorScope(device, DAWN_ERROR_FILTER_VALIDATION); wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
dawnDevicePushErrorScope(device, DAWN_ERROR_FILTER_VALIDATION); wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
EXPECT_CALL(api, DevicePushErrorScope(apiDevice, DAWN_ERROR_FILTER_VALIDATION)).Times(2); EXPECT_CALL(api, DevicePushErrorScope(apiDevice, WGPUErrorFilter_Validation)).Times(2);
FlushClient(); FlushClient();
dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this); wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this + 1); wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this + 1);
DawnErrorCallback callback1; WGPUErrorCallback callback1;
DawnErrorCallback callback2; WGPUErrorCallback callback2;
void* userdata1; void* userdata1;
void* userdata2; void* userdata2;
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)) EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
@ -131,32 +137,32 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeCallbackOrdering) {
FlushClient(); FlushClient();
callback1(DAWN_ERROR_TYPE_VALIDATION, "First error message", userdata1); callback1(WGPUErrorType_Validation, "First error message", userdata1);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, EXPECT_CALL(*mockDevicePopErrorScopeCallback,
Call(DAWN_ERROR_TYPE_VALIDATION, Call(WGPUErrorType_Validation, StrEq("First error message"), this))
StrEq("First error message"), this)).Times(1); .Times(1);
FlushServer(); FlushServer();
callback2(DAWN_ERROR_TYPE_VALIDATION, "Second error message", userdata2); callback2(WGPUErrorType_Validation, "Second error message", userdata2);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, EXPECT_CALL(*mockDevicePopErrorScopeCallback,
Call(DAWN_ERROR_TYPE_VALIDATION, Call(WGPUErrorType_Validation, StrEq("Second error message"), this + 1))
StrEq("Second error message"), this + 1)).Times(1); .Times(1);
FlushServer(); FlushServer();
} }
// Two error scopes are popped, and the second one returns first. // Two error scopes are popped, and the second one returns first.
{ {
dawnDevicePushErrorScope(device, DAWN_ERROR_FILTER_VALIDATION); wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
dawnDevicePushErrorScope(device, DAWN_ERROR_FILTER_VALIDATION); wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
EXPECT_CALL(api, DevicePushErrorScope(apiDevice, DAWN_ERROR_FILTER_VALIDATION)).Times(2); EXPECT_CALL(api, DevicePushErrorScope(apiDevice, WGPUErrorFilter_Validation)).Times(2);
FlushClient(); FlushClient();
dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this); wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this + 1); wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this + 1);
DawnErrorCallback callback1; WGPUErrorCallback callback1;
DawnErrorCallback callback2; WGPUErrorCallback callback2;
void* userdata1; void* userdata1;
void* userdata2; void* userdata2;
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)) EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
@ -165,61 +171,63 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeCallbackOrdering) {
FlushClient(); FlushClient();
callback2(DAWN_ERROR_TYPE_VALIDATION, "Second error message", userdata2); callback2(WGPUErrorType_Validation, "Second error message", userdata2);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, EXPECT_CALL(*mockDevicePopErrorScopeCallback,
Call(DAWN_ERROR_TYPE_VALIDATION, Call(WGPUErrorType_Validation, StrEq("Second error message"), this + 1))
StrEq("Second error message"), this + 1)).Times(1); .Times(1);
FlushServer(); FlushServer();
callback1(DAWN_ERROR_TYPE_VALIDATION, "First error message", userdata1); callback1(WGPUErrorType_Validation, "First error message", userdata1);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, EXPECT_CALL(*mockDevicePopErrorScopeCallback,
Call(DAWN_ERROR_TYPE_VALIDATION, Call(WGPUErrorType_Validation, StrEq("First error message"), this))
StrEq("First error message"), this)).Times(1); .Times(1);
FlushServer(); FlushServer();
} }
} }
// Test the return wire for error scopes in flight when the device is destroyed. // Test the return wire for error scopes in flight when the device is destroyed.
TEST_F(WireErrorCallbackTests, PopErrorScopeDeviceDestroyed) { TEST_F(WireErrorCallbackTests, PopErrorScopeDeviceDestroyed) {
dawnDevicePushErrorScope(device, DAWN_ERROR_FILTER_VALIDATION); wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
EXPECT_CALL(api, DevicePushErrorScope(apiDevice, DAWN_ERROR_FILTER_VALIDATION)).Times(1); EXPECT_CALL(api, DevicePushErrorScope(apiDevice, WGPUErrorFilter_Validation)).Times(1);
FlushClient(); FlushClient();
EXPECT_TRUE(dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this)); EXPECT_TRUE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)) EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
.WillOnce(Return(true)); .WillOnce(Return(true));
FlushClient(); FlushClient();
// Incomplete callback called in Device destructor. // Incomplete callback called in Device destructor.
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_UNKNOWN, ValidStringMessage(), this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback,
Call(WGPUErrorType_Unknown, ValidStringMessage(), this))
.Times(1);
} }
// Test that PopErrorScope returns false if there are no error scopes. // Test that PopErrorScope returns false if there are no error scopes.
TEST_F(WireErrorCallbackTests, PopErrorScopeEmptyStack) { TEST_F(WireErrorCallbackTests, PopErrorScopeEmptyStack) {
// Empty stack // Empty stack
{ { EXPECT_FALSE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this)); }
EXPECT_FALSE(dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
}
// Pop too many times // Pop too many times
{ {
dawnDevicePushErrorScope(device, DAWN_ERROR_FILTER_VALIDATION); wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
EXPECT_CALL(api, DevicePushErrorScope(apiDevice, DAWN_ERROR_FILTER_VALIDATION)).Times(1); EXPECT_CALL(api, DevicePushErrorScope(apiDevice, WGPUErrorFilter_Validation)).Times(1);
EXPECT_TRUE(dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this)); EXPECT_TRUE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
EXPECT_FALSE(dawnDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this + 1)); EXPECT_FALSE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this + 1));
DawnErrorCallback callback; WGPUErrorCallback callback;
void* userdata; void* userdata;
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)) EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
.WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata), Return(true))); .WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata), Return(true)));
FlushClient(); FlushClient();
callback(DAWN_ERROR_TYPE_VALIDATION, "Some error message", userdata); callback(WGPUErrorType_Validation, "Some error message", userdata);
EXPECT_CALL(*mockDevicePopErrorScopeCallback, Call(DAWN_ERROR_TYPE_VALIDATION, StrEq("Some error message"), this)).Times(1); EXPECT_CALL(*mockDevicePopErrorScopeCallback,
Call(WGPUErrorType_Validation, StrEq("Some error message"), this))
.Times(1);
FlushServer(); FlushServer();
} }

View File

@ -21,11 +21,11 @@ namespace {
class MockFenceOnCompletionCallback { class MockFenceOnCompletionCallback {
public: public:
MOCK_METHOD2(Call, void(DawnFenceCompletionStatus status, void* userdata)); MOCK_METHOD2(Call, void(WGPUFenceCompletionStatus status, void* userdata));
}; };
std::unique_ptr<StrictMock<MockFenceOnCompletionCallback>> mockFenceOnCompletionCallback; std::unique_ptr<StrictMock<MockFenceOnCompletionCallback>> mockFenceOnCompletionCallback;
void ToMockFenceOnCompletionCallback(DawnFenceCompletionStatus status, void* userdata) { void ToMockFenceOnCompletionCallback(WGPUFenceCompletionStatus status, void* userdata) {
mockFenceOnCompletionCallback->Call(status, userdata); mockFenceOnCompletionCallback->Call(status, userdata);
} }
@ -44,19 +44,19 @@ class WireFenceTests : public WireTest {
std::make_unique<StrictMock<MockFenceOnCompletionCallback>>(); std::make_unique<StrictMock<MockFenceOnCompletionCallback>>();
{ {
queue = dawnDeviceCreateQueue(device); queue = wgpuDeviceCreateQueue(device);
apiQueue = api.GetNewQueue(); apiQueue = api.GetNewQueue();
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue)); EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue));
FlushClient(); FlushClient();
} }
{ {
DawnFenceDescriptor descriptor; WGPUFenceDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.initialValue = 1; descriptor.initialValue = 1;
apiFence = api.GetNewFence(); apiFence = api.GetNewFence();
fence = dawnQueueCreateFence(queue, &descriptor); fence = wgpuQueueCreateFence(queue, &descriptor);
EXPECT_CALL(api, QueueCreateFence(apiQueue, _)).WillOnce(Return(apiFence)); EXPECT_CALL(api, QueueCreateFence(apiQueue, _)).WillOnce(Return(apiFence));
FlushClient(); FlushClient();
@ -77,23 +77,23 @@ class WireFenceTests : public WireTest {
protected: protected:
void DoQueueSignal(uint64_t signalValue) { void DoQueueSignal(uint64_t signalValue) {
dawnQueueSignal(queue, fence, signalValue); wgpuQueueSignal(queue, fence, signalValue);
EXPECT_CALL(api, QueueSignal(apiQueue, apiFence, signalValue)).Times(1); EXPECT_CALL(api, QueueSignal(apiQueue, apiFence, signalValue)).Times(1);
// This callback is generated to update the completedValue of the fence // This callback is generated to update the completedValue of the fence
// on the client // on the client
EXPECT_CALL(api, OnFenceOnCompletionCallback(apiFence, signalValue, _, _)) EXPECT_CALL(api, OnFenceOnCompletionCallback(apiFence, signalValue, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallFenceOnCompletionCallback(apiFence, DAWN_FENCE_COMPLETION_STATUS_SUCCESS); api.CallFenceOnCompletionCallback(apiFence, WGPUFenceCompletionStatus_Success);
})); }));
} }
// A successfully created fence // A successfully created fence
DawnFence fence; WGPUFence fence;
DawnFence apiFence; WGPUFence apiFence;
DawnQueue queue; WGPUQueue queue;
DawnQueue apiQueue; WGPUQueue apiQueue;
}; };
// Check that signaling a fence succeeds // Check that signaling a fence succeeds
@ -107,19 +107,22 @@ TEST_F(WireFenceTests, QueueSignalSuccess) {
// Errors should be generated when signaling a value less // Errors should be generated when signaling a value less
// than or equal to the current signaled value // than or equal to the current signaled value
TEST_F(WireFenceTests, QueueSignalValidationError) { TEST_F(WireFenceTests, QueueSignalValidationError) {
dawnQueueSignal(queue, fence, 0u); // Error wgpuQueueSignal(queue, fence, 0u); // Error
EXPECT_CALL(api, DeviceInjectError(apiDevice, DAWN_ERROR_TYPE_VALIDATION, ValidStringMessage())).Times(1); EXPECT_CALL(api, DeviceInjectError(apiDevice, WGPUErrorType_Validation, ValidStringMessage()))
.Times(1);
FlushClient(); FlushClient();
dawnQueueSignal(queue, fence, 1u); // Error wgpuQueueSignal(queue, fence, 1u); // Error
EXPECT_CALL(api, DeviceInjectError(apiDevice, DAWN_ERROR_TYPE_VALIDATION, ValidStringMessage())).Times(1); EXPECT_CALL(api, DeviceInjectError(apiDevice, WGPUErrorType_Validation, ValidStringMessage()))
.Times(1);
FlushClient(); FlushClient();
DoQueueSignal(4u); // Success DoQueueSignal(4u); // Success
FlushClient(); FlushClient();
dawnQueueSignal(queue, fence, 3u); // Error wgpuQueueSignal(queue, fence, 3u); // Error
EXPECT_CALL(api, DeviceInjectError(apiDevice, DAWN_ERROR_TYPE_VALIDATION, ValidStringMessage())).Times(1); EXPECT_CALL(api, DeviceInjectError(apiDevice, WGPUErrorType_Validation, ValidStringMessage()))
.Times(1);
FlushClient(); FlushClient();
} }
@ -127,16 +130,16 @@ TEST_F(WireFenceTests, QueueSignalValidationError) {
TEST_F(WireFenceTests, OnCompletionImmediate) { TEST_F(WireFenceTests, OnCompletionImmediate) {
// Can call on value < (initial) signaled value happens immediately // Can call on value < (initial) signaled value happens immediately
{ {
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, _)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, _))
.Times(1); .Times(1);
dawnFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, nullptr); wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, nullptr);
} }
// Can call on value == (initial) signaled value happens immediately // Can call on value == (initial) signaled value happens immediately
{ {
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, _)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, _))
.Times(1); .Times(1);
dawnFenceOnCompletion(fence, 1, ToMockFenceOnCompletionCallback, nullptr); wgpuFenceOnCompletion(fence, 1, ToMockFenceOnCompletionCallback, nullptr);
} }
} }
@ -148,26 +151,22 @@ TEST_F(WireFenceTests, OnCompletionMultiple) {
// Add callbacks in a non-monotonic order. They should still be called // Add callbacks in a non-monotonic order. They should still be called
// in order of increasing fence value. // in order of increasing fence value.
// Add multiple callbacks for the same value. // Add multiple callbacks for the same value.
dawnFenceOnCompletion(fence, 6, ToMockFenceOnCompletionCallback, this + 0); wgpuFenceOnCompletion(fence, 6, ToMockFenceOnCompletionCallback, this + 0);
dawnFenceOnCompletion(fence, 2, ToMockFenceOnCompletionCallback, this + 1); wgpuFenceOnCompletion(fence, 2, ToMockFenceOnCompletionCallback, this + 1);
dawnFenceOnCompletion(fence, 3, ToMockFenceOnCompletionCallback, this + 2); wgpuFenceOnCompletion(fence, 3, ToMockFenceOnCompletionCallback, this + 2);
dawnFenceOnCompletion(fence, 2, ToMockFenceOnCompletionCallback, this + 3); wgpuFenceOnCompletion(fence, 2, ToMockFenceOnCompletionCallback, this + 3);
Sequence s1, s2; Sequence s1, s2;
EXPECT_CALL(*mockFenceOnCompletionCallback, EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 1))
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 1))
.Times(1) .Times(1)
.InSequence(s1); .InSequence(s1);
EXPECT_CALL(*mockFenceOnCompletionCallback, EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 3))
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 3))
.Times(1) .Times(1)
.InSequence(s2); .InSequence(s2);
EXPECT_CALL(*mockFenceOnCompletionCallback, EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 2))
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 2))
.Times(1) .Times(1)
.InSequence(s1, s2); .InSequence(s1, s2);
EXPECT_CALL(*mockFenceOnCompletionCallback, EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 0))
Call(DAWN_FENCE_COMPLETION_STATUS_SUCCESS, this + 0))
.Times(1) .Times(1)
.InSequence(s1, s2); .InSequence(s1, s2);
@ -178,30 +177,31 @@ TEST_F(WireFenceTests, OnCompletionMultiple) {
// Without any flushes, it is valid to wait on a value less than or equal to // Without any flushes, it is valid to wait on a value less than or equal to
// the last signaled value // the last signaled value
TEST_F(WireFenceTests, OnCompletionSynchronousValidationSuccess) { TEST_F(WireFenceTests, OnCompletionSynchronousValidationSuccess) {
dawnQueueSignal(queue, fence, 4u); wgpuQueueSignal(queue, fence, 4u);
dawnFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, 0); wgpuFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, 0);
dawnFenceOnCompletion(fence, 3u, ToMockFenceOnCompletionCallback, 0); wgpuFenceOnCompletion(fence, 3u, ToMockFenceOnCompletionCallback, 0);
dawnFenceOnCompletion(fence, 4u, ToMockFenceOnCompletionCallback, 0); wgpuFenceOnCompletion(fence, 4u, ToMockFenceOnCompletionCallback, 0);
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, _)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Unknown, _))
.Times(3); .Times(3);
} }
// Errors should be generated when waiting on a value greater // Errors should be generated when waiting on a value greater
// than the last signaled value // than the last signaled value
TEST_F(WireFenceTests, OnCompletionValidationError) { TEST_F(WireFenceTests, OnCompletionValidationError) {
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_ERROR, this + 0)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Error, this + 0))
.Times(1); .Times(1);
dawnFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, this + 0); wgpuFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, this + 0);
EXPECT_CALL(api, DeviceInjectError(apiDevice, DAWN_ERROR_TYPE_VALIDATION, ValidStringMessage())).Times(1); EXPECT_CALL(api, DeviceInjectError(apiDevice, WGPUErrorType_Validation, ValidStringMessage()))
.Times(1);
FlushClient(); FlushClient();
} }
// Check that the fence completed value is initialized // Check that the fence completed value is initialized
TEST_F(WireFenceTests, GetCompletedValueInitialization) { TEST_F(WireFenceTests, GetCompletedValueInitialization) {
EXPECT_EQ(dawnFenceGetCompletedValue(fence), 1u); EXPECT_EQ(wgpuFenceGetCompletedValue(fence), 1u);
} }
// Check that the fence completed value updates after signaling the fence // Check that the fence completed value updates after signaling the fence
@ -210,55 +210,57 @@ TEST_F(WireFenceTests, GetCompletedValueUpdate) {
FlushClient(); FlushClient();
FlushServer(); FlushServer();
EXPECT_EQ(dawnFenceGetCompletedValue(fence), 3u); EXPECT_EQ(wgpuFenceGetCompletedValue(fence), 3u);
} }
// Check that the fence completed value does not update without a flush // Check that the fence completed value does not update without a flush
TEST_F(WireFenceTests, GetCompletedValueNoUpdate) { TEST_F(WireFenceTests, GetCompletedValueNoUpdate) {
dawnQueueSignal(queue, fence, 3u); wgpuQueueSignal(queue, fence, 3u);
EXPECT_EQ(dawnFenceGetCompletedValue(fence), 1u); EXPECT_EQ(wgpuFenceGetCompletedValue(fence), 1u);
} }
// Check that the callback is called with UNKNOWN when the fence is destroyed // Check that the callback is called with UNKNOWN when the fence is destroyed
// before the completed value is updated // before the completed value is updated
TEST_F(WireFenceTests, DestroyBeforeOnCompletionEnd) { TEST_F(WireFenceTests, DestroyBeforeOnCompletionEnd) {
dawnQueueSignal(queue, fence, 3u); wgpuQueueSignal(queue, fence, 3u);
dawnFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, nullptr); wgpuFenceOnCompletion(fence, 2u, ToMockFenceOnCompletionCallback, nullptr);
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(DAWN_FENCE_COMPLETION_STATUS_UNKNOWN, _)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Unknown, _))
.Times(1); .Times(1);
} }
// Test that signaling a fence on a wrong queue is invalid // Test that signaling a fence on a wrong queue is invalid
TEST_F(WireFenceTests, SignalWrongQueue) { TEST_F(WireFenceTests, SignalWrongQueue) {
DawnQueue queue2 = dawnDeviceCreateQueue(device); WGPUQueue queue2 = wgpuDeviceCreateQueue(device);
DawnQueue apiQueue2 = api.GetNewQueue(); WGPUQueue apiQueue2 = api.GetNewQueue();
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue2)); EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue2));
FlushClient(); FlushClient();
dawnQueueSignal(queue2, fence, 2u); // error wgpuQueueSignal(queue2, fence, 2u); // error
EXPECT_CALL(api, DeviceInjectError(apiDevice, DAWN_ERROR_TYPE_VALIDATION, ValidStringMessage())).Times(1); EXPECT_CALL(api, DeviceInjectError(apiDevice, WGPUErrorType_Validation, ValidStringMessage()))
.Times(1);
FlushClient(); FlushClient();
} }
// Test that signaling a fence on a wrong queue does not update fence signaled value // Test that signaling a fence on a wrong queue does not update fence signaled value
TEST_F(WireFenceTests, SignalWrongQueueDoesNotUpdateValue) { TEST_F(WireFenceTests, SignalWrongQueueDoesNotUpdateValue) {
DawnQueue queue2 = dawnDeviceCreateQueue(device); WGPUQueue queue2 = wgpuDeviceCreateQueue(device);
DawnQueue apiQueue2 = api.GetNewQueue(); WGPUQueue apiQueue2 = api.GetNewQueue();
EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue2)); EXPECT_CALL(api, DeviceCreateQueue(apiDevice)).WillOnce(Return(apiQueue2));
FlushClient(); FlushClient();
dawnQueueSignal(queue2, fence, 2u); // error wgpuQueueSignal(queue2, fence, 2u); // error
EXPECT_CALL(api, DeviceInjectError(apiDevice, DAWN_ERROR_TYPE_VALIDATION, ValidStringMessage())).Times(1); EXPECT_CALL(api, DeviceInjectError(apiDevice, WGPUErrorType_Validation, ValidStringMessage()))
.Times(1);
FlushClient(); FlushClient();
// Fence value should be unchanged. // Fence value should be unchanged.
FlushClient(); FlushClient();
FlushServer(); FlushServer();
EXPECT_EQ(dawnFenceGetCompletedValue(fence), 1u); EXPECT_EQ(wgpuFenceGetCompletedValue(fence), 1u);
// Signaling with 2 on the correct queue should succeed // Signaling with 2 on the correct queue should succeed
DoQueueSignal(2u); // success DoQueueSignal(2u); // success
FlushClient(); FlushClient();
FlushServer(); FlushServer();
EXPECT_EQ(dawnFenceGetCompletedValue(fence), 2u); EXPECT_EQ(wgpuFenceGetCompletedValue(fence), 2u);
} }

View File

@ -32,12 +32,12 @@ class WireInjectTextureTests : public WireTest {
TEST_F(WireInjectTextureTests, CallAfterReserveInject) { TEST_F(WireInjectTextureTests, CallAfterReserveInject) {
ReservedTexture reservation = GetWireClient()->ReserveTexture(device); ReservedTexture reservation = GetWireClient()->ReserveTexture(device);
DawnTexture apiTexture = api.GetNewTexture(); WGPUTexture apiTexture = api.GetNewTexture();
EXPECT_CALL(api, TextureReference(apiTexture)); EXPECT_CALL(api, TextureReference(apiTexture));
ASSERT_TRUE(GetWireServer()->InjectTexture(apiTexture, reservation.id, reservation.generation)); ASSERT_TRUE(GetWireServer()->InjectTexture(apiTexture, reservation.id, reservation.generation));
dawnTextureCreateView(reservation.texture, nullptr); wgpuTextureCreateView(reservation.texture, nullptr);
DawnTextureView apiDummyView = api.GetNewTextureView(); WGPUTextureView apiDummyView = api.GetNewTextureView();
EXPECT_CALL(api, TextureCreateView(apiTexture, nullptr)).WillOnce(Return(apiDummyView)); EXPECT_CALL(api, TextureCreateView(apiTexture, nullptr)).WillOnce(Return(apiDummyView));
FlushClient(); FlushClient();
} }
@ -55,7 +55,7 @@ TEST_F(WireInjectTextureTests, ReserveDifferentIDs) {
TEST_F(WireInjectTextureTests, InjectExistingID) { TEST_F(WireInjectTextureTests, InjectExistingID) {
ReservedTexture reservation = GetWireClient()->ReserveTexture(device); ReservedTexture reservation = GetWireClient()->ReserveTexture(device);
DawnTexture apiTexture = api.GetNewTexture(); WGPUTexture apiTexture = api.GetNewTexture();
EXPECT_CALL(api, TextureReference(apiTexture)); EXPECT_CALL(api, TextureReference(apiTexture));
ASSERT_TRUE(GetWireServer()->InjectTexture(apiTexture, reservation.id, reservation.generation)); ASSERT_TRUE(GetWireServer()->InjectTexture(apiTexture, reservation.id, reservation.generation));
@ -69,12 +69,12 @@ TEST_F(WireInjectTextureTests, InjectedTextureLifetime) {
ReservedTexture reservation = GetWireClient()->ReserveTexture(device); ReservedTexture reservation = GetWireClient()->ReserveTexture(device);
// Injecting the texture adds a reference // Injecting the texture adds a reference
DawnTexture apiTexture = api.GetNewTexture(); WGPUTexture apiTexture = api.GetNewTexture();
EXPECT_CALL(api, TextureReference(apiTexture)); EXPECT_CALL(api, TextureReference(apiTexture));
ASSERT_TRUE(GetWireServer()->InjectTexture(apiTexture, reservation.id, reservation.generation)); ASSERT_TRUE(GetWireServer()->InjectTexture(apiTexture, reservation.id, reservation.generation));
// Releasing the texture removes a single reference. // Releasing the texture removes a single reference.
dawnTextureRelease(reservation.texture); wgpuTextureRelease(reservation.texture);
EXPECT_CALL(api, TextureRelease(apiTexture)); EXPECT_CALL(api, TextureRelease(apiTexture));
FlushClient(); FlushClient();

View File

@ -26,14 +26,14 @@ namespace {
class MockBufferMapReadCallback { class MockBufferMapReadCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD4(Call,
void(DawnBufferMapAsyncStatus status, void(WGPUBufferMapAsyncStatus status,
const uint32_t* ptr, const uint32_t* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata)); void* userdata));
}; };
std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback; std::unique_ptr<StrictMock<MockBufferMapReadCallback>> mockBufferMapReadCallback;
void ToMockBufferMapReadCallback(DawnBufferMapAsyncStatus status, void ToMockBufferMapReadCallback(WGPUBufferMapAsyncStatus status,
const void* ptr, const void* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata) { void* userdata) {
@ -45,14 +45,14 @@ namespace {
class MockBufferMapWriteCallback { class MockBufferMapWriteCallback {
public: public:
MOCK_METHOD4(Call, MOCK_METHOD4(Call,
void(DawnBufferMapAsyncStatus status, void(WGPUBufferMapAsyncStatus status,
uint32_t* ptr, uint32_t* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata)); void* userdata));
}; };
std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback; std::unique_ptr<StrictMock<MockBufferMapWriteCallback>> mockBufferMapWriteCallback;
void ToMockBufferMapWriteCallback(DawnBufferMapAsyncStatus status, void ToMockBufferMapWriteCallback(WGPUBufferMapAsyncStatus status,
void* ptr, void* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata) { void* userdata) {
@ -63,16 +63,16 @@ namespace {
class MockBufferCreateMappedCallback { class MockBufferCreateMappedCallback {
public: public:
MOCK_METHOD5(Call, MOCK_METHOD5(Call,
void(DawnBufferMapAsyncStatus status, void(WGPUBufferMapAsyncStatus status,
DawnBuffer buffer, WGPUBuffer buffer,
uint32_t* ptr, uint32_t* ptr,
uint64_t dataLength, uint64_t dataLength,
void* userdata)); void* userdata));
}; };
std::unique_ptr<StrictMock<MockBufferCreateMappedCallback>> mockCreateBufferMappedCallback; std::unique_ptr<StrictMock<MockBufferCreateMappedCallback>> mockCreateBufferMappedCallback;
void ToMockCreateBufferMappedCallback(DawnBufferMapAsyncStatus status, void ToMockCreateBufferMappedCallback(WGPUBufferMapAsyncStatus status,
DawnCreateBufferMappedResult result, WGPUCreateBufferMappedResult result,
void* userdata) { void* userdata) {
// Assume the data is uint32_t to make writing matchers easier // Assume the data is uint32_t to make writing matchers easier
mockCreateBufferMappedCallback->Call(status, result.buffer, mockCreateBufferMappedCallback->Call(status, result.buffer,
@ -154,14 +154,14 @@ class WireMemoryTransferServiceTests : public WireTest {
using ClientWriteHandle = client::MockMemoryTransferService::MockWriteHandle; using ClientWriteHandle = client::MockMemoryTransferService::MockWriteHandle;
using ServerWriteHandle = server::MockMemoryTransferService::MockWriteHandle; using ServerWriteHandle = server::MockMemoryTransferService::MockWriteHandle;
std::pair<DawnBuffer, DawnBuffer> CreateBuffer() { std::pair<WGPUBuffer, WGPUBuffer> CreateBuffer() {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
DawnBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
DawnBuffer buffer = dawnDeviceCreateBuffer(device, &descriptor); WGPUBuffer buffer = wgpuDeviceCreateBuffer(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _))
.WillOnce(Return(apiBuffer)) .WillOnce(Return(apiBuffer))
@ -170,20 +170,20 @@ class WireMemoryTransferServiceTests : public WireTest {
return std::make_pair(apiBuffer, buffer); return std::make_pair(apiBuffer, buffer);
} }
std::pair<DawnCreateBufferMappedResult, DawnCreateBufferMappedResult> CreateBufferMapped() { std::pair<WGPUCreateBufferMappedResult, WGPUCreateBufferMappedResult> CreateBufferMapped() {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
DawnBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&mMappedBufferContent); apiResult.data = reinterpret_cast<uint8_t*>(&mMappedBufferContent);
apiResult.dataLength = sizeof(mMappedBufferContent); apiResult.dataLength = sizeof(mMappedBufferContent);
DawnCreateBufferMappedResult result = dawnDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBufferMapped(apiDevice, _))
.WillOnce(Return(apiResult)) .WillOnce(Return(apiResult))
@ -192,18 +192,18 @@ class WireMemoryTransferServiceTests : public WireTest {
return std::make_pair(apiResult, result); return std::make_pair(apiResult, result);
} }
DawnCreateBufferMappedResult CreateBufferMappedAsync() { WGPUCreateBufferMappedResult CreateBufferMappedAsync() {
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
dawnDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback, wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
nullptr); nullptr);
DawnBuffer apiBuffer = api.GetNewBuffer(); WGPUBuffer apiBuffer = api.GetNewBuffer();
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
apiResult.buffer = apiBuffer; apiResult.buffer = apiBuffer;
apiResult.data = reinterpret_cast<uint8_t*>(&mMappedBufferContent); apiResult.data = reinterpret_cast<uint8_t*>(&mMappedBufferContent);
apiResult.dataLength = sizeof(mMappedBufferContent); apiResult.dataLength = sizeof(mMappedBufferContent);
@ -416,8 +416,8 @@ uint32_t WireMemoryTransferServiceTests::mSerializeFlushInfo = 1235;
// Test successful MapRead. // Test successful MapRead.
TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) { TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
@ -425,7 +425,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) {
ClientReadHandle* clientHandle = ExpectReadHandleCreation(); ClientReadHandle* clientHandle = ExpectReadHandleCreation();
ExpectReadHandleSerialization(clientHandle); ExpectReadHandleSerialization(clientHandle);
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
// The server should deserialize the MapRead handle from the client and then serialize // The server should deserialize the MapRead handle from the client and then serialize
// an initialization message. // an initialization message.
@ -435,7 +435,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) {
// Mock a successful callback // Mock a successful callback
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &mBufferContent, api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &mBufferContent,
sizeof(mBufferContent)); sizeof(mBufferContent));
})); }));
@ -443,8 +443,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) {
// The client receives a successful callback. // The client receives a successful callback.
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &mBufferContent, Call(WGPUBufferMapAsyncStatus_Success, &mBufferContent, sizeof(mBufferContent), _))
sizeof(mBufferContent), _))
.Times(1); .Times(1);
// The client should receive the handle initialization message from the server. // The client should receive the handle initialization message from the server.
@ -454,7 +453,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) {
// The handle is destroyed once the buffer is unmapped. // The handle is destroyed once the buffer is unmapped.
EXPECT_CALL(clientMemoryTransferService, OnReadHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnReadHandleDestroy(clientHandle)).Times(1);
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
EXPECT_CALL(serverMemoryTransferService, OnReadHandleDestroy(serverHandle)).Times(1); EXPECT_CALL(serverMemoryTransferService, OnReadHandleDestroy(serverHandle)).Times(1);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
@ -464,8 +463,8 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadSuccess) {
// Test unsuccessful MapRead. // Test unsuccessful MapRead.
TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) { TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
@ -473,7 +472,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) {
ClientReadHandle* clientHandle = ExpectReadHandleCreation(); ClientReadHandle* clientHandle = ExpectReadHandleCreation();
ExpectReadHandleSerialization(clientHandle); ExpectReadHandleSerialization(clientHandle);
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
// The server should deserialize the ReadHandle from the client. // The server should deserialize the ReadHandle from the client.
ServerReadHandle* serverHandle = ExpectServerReadHandleDeserialize(); ServerReadHandle* serverHandle = ExpectServerReadHandleDeserialize();
@ -481,7 +480,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) {
// Mock a failed callback. // Mock a failed callback.
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0); api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
})); }));
// Since the mapping failed, the handle is immediately destroyed. // Since the mapping failed, the handle is immediately destroyed.
@ -490,7 +489,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) {
FlushClient(); FlushClient();
// The client receives an error callback. // The client receives an error callback.
EXPECT_CALL(*mockBufferMapReadCallback, Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _)) EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0, _))
.Times(1); .Times(1);
// The client receives the map failure and destroys the handle. // The client receives the map failure and destroys the handle.
@ -498,7 +497,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) {
FlushServer(); FlushServer();
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
@ -507,8 +506,8 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadError) {
// Test MapRead ReadHandle creation failure. // Test MapRead ReadHandle creation failure.
TEST_F(WireMemoryTransferServiceTests, BufferMapReadHandleCreationFailure) { TEST_F(WireMemoryTransferServiceTests, BufferMapReadHandleCreationFailure) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
@ -518,16 +517,16 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadHandleCreationFailure) {
// Failed creation of a ReadHandle is a fatal failure and the client synchronously receives a // Failed creation of a ReadHandle is a fatal failure and the client synchronously receives a
// DEVICE_LOST callback. // DEVICE_LOST callback.
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, nullptr, 0, _)) Call(WGPUBufferMapAsyncStatus_DeviceLost, nullptr, 0, _))
.Times(1); .Times(1);
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
} }
// Test MapRead DeserializeReadHandle failure. // Test MapRead DeserializeReadHandle failure.
TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeReadHandleFailure) { TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeReadHandleFailure) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
@ -535,7 +534,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeReadHandleFailure
ClientReadHandle* clientHandle = ExpectReadHandleCreation(); ClientReadHandle* clientHandle = ExpectReadHandleCreation();
ExpectReadHandleSerialization(clientHandle); ExpectReadHandleSerialization(clientHandle);
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
// Mock a Deserialization failure. // Mock a Deserialization failure.
MockServerReadHandleDeserializeFailure(); MockServerReadHandleDeserializeFailure();
@ -544,8 +543,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeReadHandleFailure
// The server received a fatal failure and the client callback was never returned. // The server received a fatal failure and the client callback was never returned.
// It is called when the wire is destructed. // It is called when the wire is destructed.
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
.Times(1); .Times(1);
EXPECT_CALL(clientMemoryTransferService, OnReadHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnReadHandleDestroy(clientHandle)).Times(1);
@ -553,8 +551,8 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeReadHandleFailure
// Test MapRead DeserializeInitialData failure. // Test MapRead DeserializeInitialData failure.
TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeInitialDataFailure) { TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeInitialDataFailure) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
@ -562,7 +560,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeInitialDataFailur
ClientReadHandle* clientHandle = ExpectReadHandleCreation(); ClientReadHandle* clientHandle = ExpectReadHandleCreation();
ExpectReadHandleSerialization(clientHandle); ExpectReadHandleSerialization(clientHandle);
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr); wgpuBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, nullptr);
// The server should deserialize the MapRead handle from the client and then serialize // The server should deserialize the MapRead handle from the client and then serialize
// an initialization message. // an initialization message.
@ -572,7 +570,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeInitialDataFailur
// Mock a successful callback // Mock a successful callback
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &mBufferContent, api.CallMapReadCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success, &mBufferContent,
sizeof(mBufferContent)); sizeof(mBufferContent));
})); }));
@ -585,7 +583,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeInitialDataFailur
// Failed deserialization is a fatal failure and the client synchronously receives a // Failed deserialization is a fatal failure and the client synchronously receives a
// DEVICE_LOST callback. // DEVICE_LOST callback.
EXPECT_CALL(*mockBufferMapReadCallback, EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, nullptr, 0, _)) Call(WGPUBufferMapAsyncStatus_DeviceLost, nullptr, 0, _))
.Times(1); .Times(1);
// The handle will be destroyed since deserializing failed. // The handle will be destroyed since deserializing failed.
@ -598,15 +596,15 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapReadDeserializeInitialDataFailur
// Test successful MapWrite. // Test successful MapWrite.
TEST_F(WireMemoryTransferServiceTests, BufferMapWriteSuccess) { TEST_F(WireMemoryTransferServiceTests, BufferMapWriteSuccess) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization(); ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
@ -614,7 +612,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteSuccess) {
// Mock a successful callback. // Mock a successful callback.
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
&mMappedBufferContent, sizeof(mMappedBufferContent)); &mMappedBufferContent, sizeof(mMappedBufferContent));
})); }));
@ -622,7 +620,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteSuccess) {
// The client receives a successful callback. // The client receives a successful callback.
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &mMappedBufferContent, Call(WGPUBufferMapAsyncStatus_Success, &mMappedBufferContent,
sizeof(mMappedBufferContent), _)) sizeof(mMappedBufferContent), _))
.Times(1); .Times(1);
@ -638,7 +636,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteSuccess) {
ExpectClientWriteHandleSerializeFlush(clientHandle); ExpectClientWriteHandleSerializeFlush(clientHandle);
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
// The server deserializes the Flush message. // The server deserializes the Flush message.
ExpectServerWriteHandleDeserializeFlush(serverHandle, mUpdatedBufferContent); ExpectServerWriteHandleDeserializeFlush(serverHandle, mUpdatedBufferContent);
@ -652,8 +650,8 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteSuccess) {
// Test unsuccessful MapWrite. // Test unsuccessful MapWrite.
TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) { TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
@ -661,7 +659,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) {
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization(); ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
@ -669,7 +667,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) {
// Mock an error callback. // Mock an error callback.
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0); api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Error, nullptr, 0);
})); }));
// Since the mapping fails, the handle is immediately destroyed because it won't be written. // Since the mapping fails, the handle is immediately destroyed because it won't be written.
@ -678,8 +676,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) {
FlushClient(); FlushClient();
// The client receives an error callback. // The client receives an error callback.
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Error, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, _))
.Times(1); .Times(1);
// Client receives the map failure and destroys the handle. // Client receives the map failure and destroys the handle.
@ -687,7 +684,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) {
FlushServer(); FlushServer();
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1); EXPECT_CALL(api, BufferUnmap(apiBuffer)).Times(1);
@ -696,8 +693,8 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteError) {
// Test MapRead WriteHandle creation failure. // Test MapRead WriteHandle creation failure.
TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleCreationFailure) { TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleCreationFailure) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
@ -707,16 +704,16 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleCreationFailure) {
// Failed creation of a WriteHandle is a fatal failure and the client synchronously receives a // Failed creation of a WriteHandle is a fatal failure and the client synchronously receives a
// DEVICE_LOST callback. // DEVICE_LOST callback.
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, nullptr, 0, _)) Call(WGPUBufferMapAsyncStatus_DeviceLost, nullptr, 0, _))
.Times(1); .Times(1);
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
} }
// Test MapWrite DeserializeWriteHandle failure. // Test MapWrite DeserializeWriteHandle failure.
TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeWriteHandleFailure) { TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeWriteHandleFailure) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
@ -724,7 +721,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeWriteHandleFailu
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
// Mock a deserialization failure. // Mock a deserialization failure.
MockServerWriteHandleDeserializeFailure(); MockServerWriteHandleDeserializeFailure();
@ -733,8 +730,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeWriteHandleFailu
// The server hit a fatal failure and never returned the callback. The client callback is // The server hit a fatal failure and never returned the callback. The client callback is
// called when the wire is destructed. // called when the wire is destructed.
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback, Call(WGPUBufferMapAsyncStatus_Unknown, nullptr, 0, _))
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, _))
.Times(1); .Times(1);
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
@ -742,15 +738,15 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeWriteHandleFailu
// Test MapWrite handle Open failure. // Test MapWrite handle Open failure.
TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleOpenFailure) { TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleOpenFailure) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization(); ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
@ -758,7 +754,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleOpenFailure) {
// Mock a successful callback. // Mock a successful callback.
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
&mMappedBufferContent, sizeof(mMappedBufferContent)); &mMappedBufferContent, sizeof(mMappedBufferContent));
})); }));
@ -770,7 +766,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleOpenFailure) {
// Failing to open a handle is a fatal failure and the client receives a DEVICE_LOST callback. // Failing to open a handle is a fatal failure and the client receives a DEVICE_LOST callback.
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, nullptr, 0, _)) Call(WGPUBufferMapAsyncStatus_DeviceLost, nullptr, 0, _))
.Times(1); .Times(1);
// Since opening the handle fails, it gets destroyed immediately. // Since opening the handle fails, it gets destroyed immediately.
@ -783,15 +779,15 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteHandleOpenFailure) {
// Test MapWrite DeserializeFlush failure. // Test MapWrite DeserializeFlush failure.
TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeFlushFailure) { TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeFlushFailure) {
DawnBuffer buffer; WGPUBuffer buffer;
DawnBuffer apiBuffer; WGPUBuffer apiBuffer;
std::tie(apiBuffer, buffer) = CreateBuffer(); std::tie(apiBuffer, buffer) = CreateBuffer();
FlushClient(); FlushClient();
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr); wgpuBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, nullptr);
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization(); ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
@ -799,7 +795,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeFlushFailure) {
// Mock a successful callback. // Mock a successful callback.
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _)) EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, api.CallMapWriteCallback(apiBuffer, WGPUBufferMapAsyncStatus_Success,
&mMappedBufferContent, sizeof(mMappedBufferContent)); &mMappedBufferContent, sizeof(mMappedBufferContent));
})); }));
@ -807,7 +803,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeFlushFailure) {
// The client receives a success callback. // The client receives a success callback.
EXPECT_CALL(*mockBufferMapWriteCallback, EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, &mMappedBufferContent, Call(WGPUBufferMapAsyncStatus_Success, &mMappedBufferContent,
sizeof(mMappedBufferContent), _)) sizeof(mMappedBufferContent), _))
.Times(1); .Times(1);
@ -823,7 +819,7 @@ TEST_F(WireMemoryTransferServiceTests, BufferMapWriteDeserializeFlushFailure) {
ExpectClientWriteHandleSerializeFlush(clientHandle); ExpectClientWriteHandleSerializeFlush(clientHandle);
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
// The server deserializes the Flush message. Mock a deserialization failure. // The server deserializes the Flush message. Mock a deserialization failure.
MockServerWriteHandleDeserializeFlushFailure(serverHandle); MockServerWriteHandleDeserializeFlushFailure(serverHandle);
@ -839,7 +835,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncSuccess) {
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
DawnCreateBufferMappedResult apiResult = CreateBufferMappedAsync(); WGPUCreateBufferMappedResult apiResult = CreateBufferMappedAsync();
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization(); ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
@ -847,9 +843,9 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncSuccess) {
FlushClient(); FlushClient();
// The client receives a success callback. Save the buffer argument so we can call Unmap. // The client receives a success callback. Save the buffer argument so we can call Unmap.
DawnBuffer buffer; WGPUBuffer buffer;
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, _, &mMappedBufferContent, Call(WGPUBufferMapAsyncStatus_Success, _, &mMappedBufferContent,
sizeof(mMappedBufferContent), _)) sizeof(mMappedBufferContent), _))
.WillOnce(SaveArg<1>(&buffer)); .WillOnce(SaveArg<1>(&buffer));
@ -866,7 +862,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncSuccess) {
ExpectClientWriteHandleSerializeFlush(clientHandle); ExpectClientWriteHandleSerializeFlush(clientHandle);
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
// The server deserializes the Flush message. // The server deserializes the Flush message.
ExpectServerWriteHandleDeserializeFlush(serverHandle, mUpdatedBufferContent); ExpectServerWriteHandleDeserializeFlush(serverHandle, mUpdatedBufferContent);
@ -883,7 +879,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncWriteHandleCreatio
// Mock a WriteHandle creation failure // Mock a WriteHandle creation failure
MockWriteHandleCreationFailure(); MockWriteHandleCreationFailure();
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
@ -891,10 +887,11 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncWriteHandleCreatio
// Failed creation of a WriteHandle is a fatal failure. The client synchronously receives // Failed creation of a WriteHandle is a fatal failure. The client synchronously receives
// a DEVICE_LOST callback. // a DEVICE_LOST callback.
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, _, nullptr, 0, _)) Call(WGPUBufferMapAsyncStatus_DeviceLost, _, nullptr, 0, _))
.Times(1); .Times(1);
dawnDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback, nullptr); wgpuDeviceCreateBufferMappedAsync(device, &descriptor, ToMockCreateBufferMappedCallback,
nullptr);
} }
// Test CreateBufferMappedAsync DeserializeWriteHandle failure. // Test CreateBufferMappedAsync DeserializeWriteHandle failure.
@ -903,7 +900,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncDeserializeWriteHa
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
DawnCreateBufferMappedResult apiResult = CreateBufferMappedAsync(); WGPUCreateBufferMappedResult apiResult = CreateBufferMappedAsync();
DAWN_UNUSED(apiResult); DAWN_UNUSED(apiResult);
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
@ -915,7 +912,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncDeserializeWriteHa
// The server hit a fatal failure and never returned the callback. It is called when the // The server hit a fatal failure and never returned the callback. It is called when the
// wire is destructed. // wire is destructed.
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, _, nullptr, 0, _)) Call(WGPUBufferMapAsyncStatus_Unknown, _, nullptr, 0, _))
.Times(1); .Times(1);
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
@ -927,7 +924,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncHandleOpenFailure)
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
DawnCreateBufferMappedResult apiResult = CreateBufferMappedAsync(); WGPUCreateBufferMappedResult apiResult = CreateBufferMappedAsync();
DAWN_UNUSED(apiResult); DAWN_UNUSED(apiResult);
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
@ -940,7 +937,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncHandleOpenFailure)
// Failing to open a handle is a fatal failure. The client receives a DEVICE_LOST callback. // Failing to open a handle is a fatal failure. The client receives a DEVICE_LOST callback.
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_DEVICE_LOST, _, nullptr, 0, _)) Call(WGPUBufferMapAsyncStatus_DeviceLost, _, nullptr, 0, _))
.Times(1); .Times(1);
// Since opening the handle fails, it is destroyed immediately. // Since opening the handle fails, it is destroyed immediately.
@ -957,7 +954,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncDeserializeFlushFa
ClientWriteHandle* clientHandle = ExpectWriteHandleCreation(); ClientWriteHandle* clientHandle = ExpectWriteHandleCreation();
ExpectWriteHandleSerialization(clientHandle); ExpectWriteHandleSerialization(clientHandle);
DawnCreateBufferMappedResult apiResult = CreateBufferMappedAsync(); WGPUCreateBufferMappedResult apiResult = CreateBufferMappedAsync();
DAWN_UNUSED(apiResult); DAWN_UNUSED(apiResult);
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
@ -966,9 +963,9 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncDeserializeFlushFa
FlushClient(); FlushClient();
// The client receives a success callback. Save the buffer argument so we can call Unmap. // The client receives a success callback. Save the buffer argument so we can call Unmap.
DawnBuffer buffer; WGPUBuffer buffer;
EXPECT_CALL(*mockCreateBufferMappedCallback, EXPECT_CALL(*mockCreateBufferMappedCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, _, &mMappedBufferContent, Call(WGPUBufferMapAsyncStatus_Success, _, &mMappedBufferContent,
sizeof(mMappedBufferContent), _)) sizeof(mMappedBufferContent), _))
.WillOnce(SaveArg<1>(&buffer)); .WillOnce(SaveArg<1>(&buffer));
@ -985,7 +982,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedAsyncDeserializeFlushFa
ExpectClientWriteHandleSerializeFlush(clientHandle); ExpectClientWriteHandleSerializeFlush(clientHandle);
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
dawnBufferUnmap(buffer); wgpuBufferUnmap(buffer);
// The server deserializes the Flush message. // The server deserializes the Flush message.
// Mock a deserialization failure. // Mock a deserialization failure.
@ -1009,8 +1006,8 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedSuccess) {
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization(); ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
DawnCreateBufferMappedResult result; WGPUCreateBufferMappedResult result;
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
std::tie(apiResult, result) = CreateBufferMapped(); std::tie(apiResult, result) = CreateBufferMapped();
FlushClient(); FlushClient();
@ -1021,7 +1018,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedSuccess) {
ExpectClientWriteHandleSerializeFlush(clientHandle); ExpectClientWriteHandleSerializeFlush(clientHandle);
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
dawnBufferUnmap(result.buffer); wgpuBufferUnmap(result.buffer);
// The server deserializes the Flush message. // The server deserializes the Flush message.
ExpectServerWriteHandleDeserializeFlush(serverHandle, mUpdatedBufferContent); ExpectServerWriteHandleDeserializeFlush(serverHandle, mUpdatedBufferContent);
@ -1038,12 +1035,12 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedWriteHandleCreationFail
// Mock a WriteHandle creation failure // Mock a WriteHandle creation failure
MockWriteHandleCreationFailure(); MockWriteHandleCreationFailure();
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
DawnCreateBufferMappedResult result = dawnDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
// TODO(enga): Check that the client generated a context lost. // TODO(enga): Check that the client generated a context lost.
EXPECT_EQ(result.data, nullptr); EXPECT_EQ(result.data, nullptr);
@ -1063,8 +1060,8 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedDeserializeWriteHandleF
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
MockServerWriteHandleDeserializeFailure(); MockServerWriteHandleDeserializeFailure();
DawnCreateBufferMappedResult result; WGPUCreateBufferMappedResult result;
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
std::tie(apiResult, result) = CreateBufferMapped(); std::tie(apiResult, result) = CreateBufferMapped();
FlushClient(false); FlushClient(false);
@ -1084,12 +1081,12 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedHandleOpenFailure) {
// Note: The handle is not serialized because sychronously opening it failed. // Note: The handle is not serialized because sychronously opening it failed.
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
DawnBufferDescriptor descriptor; WGPUBufferDescriptor descriptor;
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.label = nullptr; descriptor.label = nullptr;
descriptor.size = sizeof(mBufferContent); descriptor.size = sizeof(mBufferContent);
DawnCreateBufferMappedResult result = dawnDeviceCreateBufferMapped(device, &descriptor); WGPUCreateBufferMappedResult result = wgpuDeviceCreateBufferMapped(device, &descriptor);
// TODO(enga): Check that the client generated a context lost. // TODO(enga): Check that the client generated a context lost.
EXPECT_EQ(result.data, nullptr); EXPECT_EQ(result.data, nullptr);
@ -1109,8 +1106,8 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedDeserializeFlushFailure
// The server should then deserialize the WriteHandle from the client. // The server should then deserialize the WriteHandle from the client.
ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization(); ServerWriteHandle* serverHandle = ExpectServerWriteHandleDeserialization();
DawnCreateBufferMappedResult result; WGPUCreateBufferMappedResult result;
DawnCreateBufferMappedResult apiResult; WGPUCreateBufferMappedResult apiResult;
std::tie(apiResult, result) = CreateBufferMapped(); std::tie(apiResult, result) = CreateBufferMapped();
FlushClient(); FlushClient();
@ -1121,7 +1118,7 @@ TEST_F(WireMemoryTransferServiceTests, CreateBufferMappedDeserializeFlushFailure
ExpectClientWriteHandleSerializeFlush(clientHandle); ExpectClientWriteHandleSerializeFlush(clientHandle);
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1); EXPECT_CALL(clientMemoryTransferService, OnWriteHandleDestroy(clientHandle)).Times(1);
dawnBufferUnmap(result.buffer); wgpuBufferUnmap(result.buffer);
// The server deserializes the Flush message. Mock a deserialization failure. // The server deserializes the Flush message. Mock a deserialization failure.
MockServerWriteHandleDeserializeFlushFailure(serverHandle); MockServerWriteHandleDeserializeFlushFailure(serverHandle);

View File

@ -26,35 +26,35 @@ class WireOptionalTests : public WireTest {
// Test passing nullptr instead of objects - object as value version // Test passing nullptr instead of objects - object as value version
TEST_F(WireOptionalTests, OptionalObjectValue) { TEST_F(WireOptionalTests, OptionalObjectValue) {
DawnBindGroupLayoutDescriptor bglDesc; WGPUBindGroupLayoutDescriptor bglDesc;
bglDesc.nextInChain = nullptr; bglDesc.nextInChain = nullptr;
bglDesc.label = nullptr; bglDesc.label = nullptr;
bglDesc.bindingCount = 0; bglDesc.bindingCount = 0;
DawnBindGroupLayout bgl = dawnDeviceCreateBindGroupLayout(device, &bglDesc); WGPUBindGroupLayout bgl = wgpuDeviceCreateBindGroupLayout(device, &bglDesc);
DawnBindGroupLayout apiBindGroupLayout = api.GetNewBindGroupLayout(); WGPUBindGroupLayout apiBindGroupLayout = api.GetNewBindGroupLayout();
EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _)) EXPECT_CALL(api, DeviceCreateBindGroupLayout(apiDevice, _))
.WillOnce(Return(apiBindGroupLayout)); .WillOnce(Return(apiBindGroupLayout));
// The `sampler`, `textureView` and `buffer` members of a binding are optional. // The `sampler`, `textureView` and `buffer` members of a binding are optional.
DawnBindGroupBinding binding; WGPUBindGroupBinding binding;
binding.binding = 0; binding.binding = 0;
binding.sampler = nullptr; binding.sampler = nullptr;
binding.textureView = nullptr; binding.textureView = nullptr;
binding.buffer = nullptr; binding.buffer = nullptr;
DawnBindGroupDescriptor bgDesc; WGPUBindGroupDescriptor bgDesc;
bgDesc.nextInChain = nullptr; bgDesc.nextInChain = nullptr;
bgDesc.label = nullptr; bgDesc.label = nullptr;
bgDesc.layout = bgl; bgDesc.layout = bgl;
bgDesc.bindingCount = 1; bgDesc.bindingCount = 1;
bgDesc.bindings = &binding; bgDesc.bindings = &binding;
dawnDeviceCreateBindGroup(device, &bgDesc); wgpuDeviceCreateBindGroup(device, &bgDesc);
DawnBindGroup apiDummyBindGroup = api.GetNewBindGroup(); WGPUBindGroup apiDummyBindGroup = api.GetNewBindGroup();
EXPECT_CALL(api, DeviceCreateBindGroup( EXPECT_CALL(api, DeviceCreateBindGroup(
apiDevice, MatchesLambda([](const DawnBindGroupDescriptor* desc) -> bool { apiDevice, MatchesLambda([](const WGPUBindGroupDescriptor* desc) -> bool {
return desc->nextInChain == nullptr && desc->bindingCount == 1 && return desc->nextInChain == nullptr && desc->bindingCount == 1 &&
desc->bindings[0].binding == 0 && desc->bindings[0].binding == 0 &&
desc->bindings[0].sampler == nullptr && desc->bindings[0].sampler == nullptr &&
@ -69,71 +69,71 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
// Test that the wire is able to send optional pointers to structures // Test that the wire is able to send optional pointers to structures
TEST_F(WireOptionalTests, OptionalStructPointer) { TEST_F(WireOptionalTests, OptionalStructPointer) {
// Create shader module // Create shader module
DawnShaderModuleDescriptor vertexDescriptor; WGPUShaderModuleDescriptor vertexDescriptor;
vertexDescriptor.nextInChain = nullptr; vertexDescriptor.nextInChain = nullptr;
vertexDescriptor.label = nullptr; vertexDescriptor.label = nullptr;
vertexDescriptor.codeSize = 0; vertexDescriptor.codeSize = 0;
DawnShaderModule vsModule = dawnDeviceCreateShaderModule(device, &vertexDescriptor); WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
DawnShaderModule apiVsModule = api.GetNewShaderModule(); WGPUShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule)); EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
// Create the color state descriptor // Create the color state descriptor
DawnBlendDescriptor blendDescriptor; WGPUBlendDescriptor blendDescriptor;
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD; blendDescriptor.operation = WGPUBlendOperation_Add;
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE; blendDescriptor.srcFactor = WGPUBlendFactor_One;
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE; blendDescriptor.dstFactor = WGPUBlendFactor_One;
DawnColorStateDescriptor colorStateDescriptor; WGPUColorStateDescriptor colorStateDescriptor;
colorStateDescriptor.nextInChain = nullptr; colorStateDescriptor.nextInChain = nullptr;
colorStateDescriptor.format = DAWN_TEXTURE_FORMAT_RGBA8_UNORM; colorStateDescriptor.format = WGPUTextureFormat_RGBA8Unorm;
colorStateDescriptor.alphaBlend = blendDescriptor; colorStateDescriptor.alphaBlend = blendDescriptor;
colorStateDescriptor.colorBlend = blendDescriptor; colorStateDescriptor.colorBlend = blendDescriptor;
colorStateDescriptor.writeMask = DAWN_COLOR_WRITE_MASK_ALL; colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
// Create the input state // Create the input state
DawnVertexInputDescriptor vertexInput; WGPUVertexInputDescriptor vertexInput;
vertexInput.nextInChain = nullptr; vertexInput.nextInChain = nullptr;
vertexInput.indexFormat = DAWN_INDEX_FORMAT_UINT32; vertexInput.indexFormat = WGPUIndexFormat_Uint32;
vertexInput.bufferCount = 0; vertexInput.bufferCount = 0;
vertexInput.buffers = nullptr; vertexInput.buffers = nullptr;
// Create the rasterization state // Create the rasterization state
DawnRasterizationStateDescriptor rasterizationState; WGPURasterizationStateDescriptor rasterizationState;
rasterizationState.nextInChain = nullptr; rasterizationState.nextInChain = nullptr;
rasterizationState.frontFace = DAWN_FRONT_FACE_CCW; rasterizationState.frontFace = WGPUFrontFace_CCW;
rasterizationState.cullMode = DAWN_CULL_MODE_NONE; rasterizationState.cullMode = WGPUCullMode_None;
rasterizationState.depthBias = 0; rasterizationState.depthBias = 0;
rasterizationState.depthBiasSlopeScale = 0.0; rasterizationState.depthBiasSlopeScale = 0.0;
rasterizationState.depthBiasClamp = 0.0; rasterizationState.depthBiasClamp = 0.0;
// Create the depth-stencil state // Create the depth-stencil state
DawnStencilStateFaceDescriptor stencilFace; WGPUStencilStateFaceDescriptor stencilFace;
stencilFace.compare = DAWN_COMPARE_FUNCTION_ALWAYS; stencilFace.compare = WGPUCompareFunction_Always;
stencilFace.failOp = DAWN_STENCIL_OPERATION_KEEP; stencilFace.failOp = WGPUStencilOperation_Keep;
stencilFace.depthFailOp = DAWN_STENCIL_OPERATION_KEEP; stencilFace.depthFailOp = WGPUStencilOperation_Keep;
stencilFace.passOp = DAWN_STENCIL_OPERATION_KEEP; stencilFace.passOp = WGPUStencilOperation_Keep;
DawnDepthStencilStateDescriptor depthStencilState; WGPUDepthStencilStateDescriptor depthStencilState;
depthStencilState.nextInChain = nullptr; depthStencilState.nextInChain = nullptr;
depthStencilState.format = DAWN_TEXTURE_FORMAT_DEPTH24_PLUS_STENCIL8; depthStencilState.format = WGPUTextureFormat_Depth24PlusStencil8;
depthStencilState.depthWriteEnabled = false; depthStencilState.depthWriteEnabled = false;
depthStencilState.depthCompare = DAWN_COMPARE_FUNCTION_ALWAYS; depthStencilState.depthCompare = WGPUCompareFunction_Always;
depthStencilState.stencilBack = stencilFace; depthStencilState.stencilBack = stencilFace;
depthStencilState.stencilFront = stencilFace; depthStencilState.stencilFront = stencilFace;
depthStencilState.stencilReadMask = 0xff; depthStencilState.stencilReadMask = 0xff;
depthStencilState.stencilWriteMask = 0xff; depthStencilState.stencilWriteMask = 0xff;
// Create the pipeline layout // Create the pipeline layout
DawnPipelineLayoutDescriptor layoutDescriptor; WGPUPipelineLayoutDescriptor layoutDescriptor;
layoutDescriptor.nextInChain = nullptr; layoutDescriptor.nextInChain = nullptr;
layoutDescriptor.label = nullptr; layoutDescriptor.label = nullptr;
layoutDescriptor.bindGroupLayoutCount = 0; layoutDescriptor.bindGroupLayoutCount = 0;
layoutDescriptor.bindGroupLayouts = nullptr; layoutDescriptor.bindGroupLayouts = nullptr;
DawnPipelineLayout layout = dawnDeviceCreatePipelineLayout(device, &layoutDescriptor); WGPUPipelineLayout layout = wgpuDeviceCreatePipelineLayout(device, &layoutDescriptor);
DawnPipelineLayout apiLayout = api.GetNewPipelineLayout(); WGPUPipelineLayout apiLayout = api.GetNewPipelineLayout();
EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout)); EXPECT_CALL(api, DeviceCreatePipelineLayout(apiDevice, _)).WillOnce(Return(apiLayout));
// Create pipeline // Create pipeline
DawnRenderPipelineDescriptor pipelineDescriptor; WGPURenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.nextInChain = nullptr; pipelineDescriptor.nextInChain = nullptr;
pipelineDescriptor.label = nullptr; pipelineDescriptor.label = nullptr;
@ -141,7 +141,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.vertexStage.entryPoint = "main"; pipelineDescriptor.vertexStage.entryPoint = "main";
DawnProgrammableStageDescriptor fragmentStage; WGPUProgrammableStageDescriptor fragmentStage;
fragmentStage.nextInChain = nullptr; fragmentStage.nextInChain = nullptr;
fragmentStage.module = vsModule; fragmentStage.module = vsModule;
fragmentStage.entryPoint = "main"; fragmentStage.entryPoint = "main";
@ -155,36 +155,33 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
pipelineDescriptor.alphaToCoverageEnabled = false; pipelineDescriptor.alphaToCoverageEnabled = false;
pipelineDescriptor.layout = layout; pipelineDescriptor.layout = layout;
pipelineDescriptor.vertexInput = &vertexInput; pipelineDescriptor.vertexInput = &vertexInput;
pipelineDescriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; pipelineDescriptor.primitiveTopology = WGPUPrimitiveTopology_TriangleList;
pipelineDescriptor.rasterizationState = &rasterizationState; pipelineDescriptor.rasterizationState = &rasterizationState;
// First case: depthStencilState is not null. // First case: depthStencilState is not null.
pipelineDescriptor.depthStencilState = &depthStencilState; pipelineDescriptor.depthStencilState = &depthStencilState;
dawnDeviceCreateRenderPipeline(device, &pipelineDescriptor); wgpuDeviceCreateRenderPipeline(device, &pipelineDescriptor);
DawnRenderPipeline apiDummyPipeline = api.GetNewRenderPipeline(); WGPURenderPipeline apiDummyPipeline = api.GetNewRenderPipeline();
EXPECT_CALL( EXPECT_CALL(
api, api,
DeviceCreateRenderPipeline( DeviceCreateRenderPipeline(
apiDevice, MatchesLambda([](const DawnRenderPipelineDescriptor* desc) -> bool { apiDevice, MatchesLambda([](const WGPURenderPipelineDescriptor* desc) -> bool {
return desc->depthStencilState != nullptr && return desc->depthStencilState != nullptr &&
desc->depthStencilState->nextInChain == nullptr && desc->depthStencilState->nextInChain == nullptr &&
desc->depthStencilState->depthWriteEnabled == false && desc->depthStencilState->depthWriteEnabled == false &&
desc->depthStencilState->depthCompare == DAWN_COMPARE_FUNCTION_ALWAYS && desc->depthStencilState->depthCompare == WGPUCompareFunction_Always &&
desc->depthStencilState->stencilBack.compare == desc->depthStencilState->stencilBack.compare == WGPUCompareFunction_Always &&
DAWN_COMPARE_FUNCTION_ALWAYS && desc->depthStencilState->stencilBack.failOp == WGPUStencilOperation_Keep &&
desc->depthStencilState->stencilBack.failOp == DAWN_STENCIL_OPERATION_KEEP &&
desc->depthStencilState->stencilBack.depthFailOp == desc->depthStencilState->stencilBack.depthFailOp ==
DAWN_STENCIL_OPERATION_KEEP && WGPUStencilOperation_Keep &&
desc->depthStencilState->stencilBack.passOp == DAWN_STENCIL_OPERATION_KEEP && desc->depthStencilState->stencilBack.passOp == WGPUStencilOperation_Keep &&
desc->depthStencilState->stencilFront.compare == desc->depthStencilState->stencilFront.compare ==
DAWN_COMPARE_FUNCTION_ALWAYS && WGPUCompareFunction_Always &&
desc->depthStencilState->stencilFront.failOp == desc->depthStencilState->stencilFront.failOp == WGPUStencilOperation_Keep &&
DAWN_STENCIL_OPERATION_KEEP &&
desc->depthStencilState->stencilFront.depthFailOp == desc->depthStencilState->stencilFront.depthFailOp ==
DAWN_STENCIL_OPERATION_KEEP && WGPUStencilOperation_Keep &&
desc->depthStencilState->stencilFront.passOp == desc->depthStencilState->stencilFront.passOp == WGPUStencilOperation_Keep &&
DAWN_STENCIL_OPERATION_KEEP &&
desc->depthStencilState->stencilReadMask == 0xff && desc->depthStencilState->stencilReadMask == 0xff &&
desc->depthStencilState->stencilWriteMask == 0xff; desc->depthStencilState->stencilWriteMask == 0xff;
}))) })))
@ -194,10 +191,10 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
// Second case: depthStencilState is null. // Second case: depthStencilState is null.
pipelineDescriptor.depthStencilState = nullptr; pipelineDescriptor.depthStencilState = nullptr;
dawnDeviceCreateRenderPipeline(device, &pipelineDescriptor); wgpuDeviceCreateRenderPipeline(device, &pipelineDescriptor);
EXPECT_CALL(api, EXPECT_CALL(api,
DeviceCreateRenderPipeline( DeviceCreateRenderPipeline(
apiDevice, MatchesLambda([](const DawnRenderPipelineDescriptor* desc) -> bool { apiDevice, MatchesLambda([](const WGPURenderPipelineDescriptor* desc) -> bool {
return desc->depthStencilState == nullptr; return desc->depthStencilState == nullptr;
}))) })))
.WillOnce(Return(apiDummyPipeline)); .WillOnce(Return(apiDummyPipeline));

View File

@ -38,7 +38,7 @@ server::MemoryTransferService* WireTest::GetServerMemoryTransferService() {
void WireTest::SetUp() { void WireTest::SetUp() {
DawnProcTable mockProcs; DawnProcTable mockProcs;
DawnDevice mockDevice; WGPUDevice mockDevice;
api.GetProcTableAndDevice(&mockProcs, &mockDevice); api.GetProcTableAndDevice(&mockProcs, &mockDevice);
// This SetCallback call cannot be ignored because it is done as soon as we start the server // This SetCallback call cannot be ignored because it is done as soon as we start the server

View File

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "dawn/mock_webgpu.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "dawn/mock_dawn.h"
#include <memory> #include <memory>
@ -122,8 +122,8 @@ class WireTest : public testing::Test {
void FlushServer(bool success = true); void FlushServer(bool success = true);
testing::StrictMock<MockProcTable> api; testing::StrictMock<MockProcTable> api;
DawnDevice apiDevice; WGPUDevice apiDevice;
DawnDevice device; WGPUDevice device;
dawn_wire::WireServer* GetWireServer(); dawn_wire::WireServer* GetWireServer();
dawn_wire::WireClient* GetWireClient(); dawn_wire::WireClient* GetWireClient();