2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2017 The Dawn Authors
|
2017-06-16 22:34:35 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-07-18 13:18:25 +00:00
|
|
|
#include "tests/DawnTest.h"
|
2017-06-16 22:34:35 +00:00
|
|
|
|
2019-10-25 11:36:47 +00:00
|
|
|
#include "utils/WGPUHelpers.h"
|
2017-06-27 04:11:16 +00:00
|
|
|
|
2020-07-10 20:33:08 +00:00
|
|
|
class BasicTests : public DawnTest {};
|
2017-06-16 22:34:35 +00:00
|
|
|
|
2019-10-16 09:24:55 +00:00
|
|
|
// Test adapter filter by vendor id.
|
|
|
|
TEST_P(BasicTests, VendorIdFilter) {
|
|
|
|
DAWN_SKIP_TEST_IF(!HasVendorIdFilter());
|
|
|
|
|
2020-01-10 13:28:18 +00:00
|
|
|
ASSERT_EQ(GetAdapterProperties().vendorID, GetVendorIdFilter());
|
2019-10-16 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2020-06-02 09:24:39 +00:00
|
|
|
// Test Queue::WriteBuffer changes the content of the buffer, but really this is the most
|
2017-06-16 22:34:35 +00:00
|
|
|
// basic test possible, and tests the test harness
|
2020-06-02 09:24:39 +00:00
|
|
|
TEST_P(BasicTests, QueueWriteBuffer) {
|
2019-10-28 13:27:36 +00:00
|
|
|
wgpu::BufferDescriptor descriptor;
|
2018-08-22 13:37:29 +00:00
|
|
|
descriptor.size = 4;
|
2019-10-28 13:27:36 +00:00
|
|
|
descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
|
|
|
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
|
2017-06-16 22:34:35 +00:00
|
|
|
|
2019-02-27 02:46:27 +00:00
|
|
|
uint32_t value = 0x01020304;
|
2020-06-02 09:24:39 +00:00
|
|
|
queue.WriteBuffer(buffer, 0, &value, sizeof(value));
|
2017-06-16 22:34:35 +00:00
|
|
|
|
2019-02-27 02:46:27 +00:00
|
|
|
EXPECT_BUFFER_U32_EQ(value, buffer, 0);
|
2017-06-16 22:34:35 +00:00
|
|
|
}
|
|
|
|
|
2020-06-02 09:24:39 +00:00
|
|
|
// Test a validation error for Queue::WriteBuffer but really this is the most basic test possible
|
2019-02-28 09:45:48 +00:00
|
|
|
// for ASSERT_DEVICE_ERROR
|
2020-06-02 09:24:39 +00:00
|
|
|
TEST_P(BasicTests, QueueWriteBufferError) {
|
2019-10-28 13:27:36 +00:00
|
|
|
wgpu::BufferDescriptor descriptor;
|
2019-02-28 09:45:48 +00:00
|
|
|
descriptor.size = 4;
|
2019-10-28 13:27:36 +00:00
|
|
|
descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
|
|
|
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
|
2019-02-28 09:45:48 +00:00
|
|
|
|
|
|
|
uint8_t value = 187;
|
2020-06-02 09:24:39 +00:00
|
|
|
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buffer, 1000, &value, sizeof(value)));
|
2019-02-28 09:45:48 +00:00
|
|
|
}
|
|
|
|
|
2020-02-25 16:23:17 +00:00
|
|
|
DAWN_INSTANTIATE_TEST(BasicTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
|