Rename NXTTest to DawnTest
Also formats the whole file for the first time.
This commit is contained in:
parent
ae187efc80
commit
a4da03249c
|
@ -87,8 +87,8 @@ add_executable(dawn_end2end_tests
|
|||
${END2END_TESTS_DIR}/SamplerTests.cpp
|
||||
${END2END_TESTS_DIR}/ViewportOrientationTests.cpp
|
||||
${TESTS_DIR}/End2EndTestsMain.cpp
|
||||
${TESTS_DIR}/NXTTest.cpp
|
||||
${TESTS_DIR}/NXTTest.h
|
||||
${TESTS_DIR}/DawnTest.cpp
|
||||
${TESTS_DIR}/DawnTest.h
|
||||
)
|
||||
target_link_libraries(dawn_end2end_tests dawn_common dawn_wire gtest utils)
|
||||
DawnInternalTarget("tests" dawn_end2end_tests)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/Constants.h"
|
||||
|
@ -29,7 +29,7 @@
|
|||
namespace {
|
||||
|
||||
utils::BackendType ParamToBackendType(BackendType type) {
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case D3D12Backend:
|
||||
return utils::BackendType::D3D12;
|
||||
case MetalBackend:
|
||||
|
@ -44,7 +44,7 @@ namespace {
|
|||
}
|
||||
|
||||
std::string ParamName(BackendType type) {
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case D3D12Backend:
|
||||
return "D3D12";
|
||||
case MetalBackend:
|
||||
|
@ -87,16 +87,16 @@ namespace {
|
|||
// End2end tests should test valid commands produce the expected result so no error
|
||||
// should happen. Failure cases should be tested in the validation tests.
|
||||
void DeviceErrorCauseTestFailure(const char* message, dawnCallbackUserdata) {
|
||||
FAIL() << "Device level failure: " << message;
|
||||
FAIL() << "Device level failure: " << message;
|
||||
}
|
||||
|
||||
struct MapReadUserdata {
|
||||
NXTTest* test;
|
||||
DawnTest* test;
|
||||
size_t slot;
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
NXTTest::~NXTTest() {
|
||||
DawnTest::~DawnTest() {
|
||||
// We need to destroy child objects before the Device
|
||||
mReadbackSlots.clear();
|
||||
queue = dawn::Queue();
|
||||
|
@ -109,25 +109,25 @@ NXTTest::~NXTTest() {
|
|||
dawnSetProcs(nullptr);
|
||||
}
|
||||
|
||||
bool NXTTest::IsD3D12() const {
|
||||
bool DawnTest::IsD3D12() const {
|
||||
return GetParam() == D3D12Backend;
|
||||
}
|
||||
|
||||
bool NXTTest::IsMetal() const {
|
||||
bool DawnTest::IsMetal() const {
|
||||
return GetParam() == MetalBackend;
|
||||
}
|
||||
|
||||
bool NXTTest::IsOpenGL() const {
|
||||
bool DawnTest::IsOpenGL() const {
|
||||
return GetParam() == OpenGLBackend;
|
||||
}
|
||||
|
||||
bool NXTTest::IsVulkan() const {
|
||||
bool DawnTest::IsVulkan() const {
|
||||
return GetParam() == VulkanBackend;
|
||||
}
|
||||
|
||||
bool gTestUsesWire = false;
|
||||
|
||||
void NXTTest::SetUp() {
|
||||
void DawnTest::SetUp() {
|
||||
mBinding = utils::CreateBinding(ParamToBackendType(GetParam()));
|
||||
DAWN_ASSERT(mBinding != nullptr);
|
||||
|
||||
|
@ -163,7 +163,7 @@ void NXTTest::SetUp() {
|
|||
cDevice = backendDevice;
|
||||
}
|
||||
|
||||
// Set up the device and queue because all tests need them, and NXTTest needs them too for the
|
||||
// Set up the device and queue because all tests need them, and DawnTest needs them too for the
|
||||
// deferred expectations.
|
||||
dawnSetProcs(&procs);
|
||||
device = dawn::Device::Acquire(cDevice);
|
||||
|
@ -172,16 +172,17 @@ void NXTTest::SetUp() {
|
|||
// The swapchain isn't used by tests but is useful when debugging with graphics debuggers that
|
||||
// capture at frame boundaries.
|
||||
swapchain = device.CreateSwapChainBuilder()
|
||||
.SetImplementation(mBinding->GetSwapChainImplementation())
|
||||
.GetResult();
|
||||
swapchain.Configure(static_cast<dawn::TextureFormat>(mBinding->GetPreferredSwapChainTextureFormat()),
|
||||
dawn::TextureUsageBit::OutputAttachment, 400, 400);
|
||||
.SetImplementation(mBinding->GetSwapChainImplementation())
|
||||
.GetResult();
|
||||
swapchain.Configure(
|
||||
static_cast<dawn::TextureFormat>(mBinding->GetPreferredSwapChainTextureFormat()),
|
||||
dawn::TextureUsageBit::OutputAttachment, 400, 400);
|
||||
|
||||
// The end2end tests should never cause validation errors. These should be tested in unittests.
|
||||
device.SetErrorCallback(DeviceErrorCauseTestFailure, 0);
|
||||
}
|
||||
|
||||
void NXTTest::TearDown() {
|
||||
void DawnTest::TearDown() {
|
||||
FlushWire();
|
||||
|
||||
MapSlotsSynchronously();
|
||||
|
@ -204,16 +205,22 @@ void NXTTest::TearDown() {
|
|||
}
|
||||
}
|
||||
|
||||
std::ostringstream& NXTTest::AddBufferExpectation(const char* file, int line, const dawn::Buffer& buffer, uint32_t offset, uint32_t size, detail::Expectation* expectation) {
|
||||
std::ostringstream& DawnTest::AddBufferExpectation(const char* file,
|
||||
int line,
|
||||
const dawn::Buffer& buffer,
|
||||
uint32_t offset,
|
||||
uint32_t size,
|
||||
detail::Expectation* expectation) {
|
||||
dawn::Buffer source = buffer.Clone();
|
||||
|
||||
auto readback = ReserveReadback(size);
|
||||
|
||||
// We need to enqueue the copy immediately because by the time we resolve the expectation,
|
||||
// the buffer might have been modified.
|
||||
dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||
.CopyBufferToBuffer(source, offset, readback.buffer, readback.offset, size)
|
||||
.GetResult();
|
||||
dawn::CommandBuffer commands =
|
||||
device.CreateCommandBufferBuilder()
|
||||
.CopyBufferToBuffer(source, offset, readback.buffer, readback.offset, size)
|
||||
.GetResult();
|
||||
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
|
@ -232,7 +239,16 @@ std::ostringstream& NXTTest::AddBufferExpectation(const char* file, int line, co
|
|||
return *(mDeferredExpectations.back().message.get());
|
||||
}
|
||||
|
||||
std::ostringstream& NXTTest::AddTextureExpectation(const char* file, int line, const dawn::Texture& texture, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t level, uint32_t pixelSize, detail::Expectation* expectation) {
|
||||
std::ostringstream& DawnTest::AddTextureExpectation(const char* file,
|
||||
int line,
|
||||
const dawn::Texture& texture,
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t level,
|
||||
uint32_t pixelSize,
|
||||
detail::Expectation* expectation) {
|
||||
dawn::Texture source = texture.Clone();
|
||||
uint32_t rowPitch = Align(width * pixelSize, kTextureRowPitchAlignment);
|
||||
uint32_t size = rowPitch * (height - 1) + width * pixelSize;
|
||||
|
@ -241,9 +257,11 @@ std::ostringstream& NXTTest::AddTextureExpectation(const char* file, int line, c
|
|||
|
||||
// We need to enqueue the copy immediately because by the time we resolve the expectation,
|
||||
// the texture might have been modified.
|
||||
dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||
.CopyTextureToBuffer(source, x, y, 0, width, height, 1, level, readback.buffer, readback.offset, rowPitch)
|
||||
.GetResult();
|
||||
dawn::CommandBuffer commands =
|
||||
device.CreateCommandBufferBuilder()
|
||||
.CopyTextureToBuffer(source, x, y, 0, width, height, 1, level, readback.buffer,
|
||||
readback.offset, rowPitch)
|
||||
.GetResult();
|
||||
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
|
@ -262,35 +280,36 @@ std::ostringstream& NXTTest::AddTextureExpectation(const char* file, int line, c
|
|||
return *(mDeferredExpectations.back().message.get());
|
||||
}
|
||||
|
||||
void NXTTest::WaitABit() {
|
||||
void DawnTest::WaitABit() {
|
||||
device.Tick();
|
||||
FlushWire();
|
||||
|
||||
utils::USleep(100);
|
||||
}
|
||||
|
||||
void NXTTest::SwapBuffersForCapture() {
|
||||
void DawnTest::SwapBuffersForCapture() {
|
||||
// Insert a frame boundary for API capture tools.
|
||||
dawn::Texture backBuffer = swapchain.GetNextTexture();
|
||||
swapchain.Present(backBuffer);
|
||||
}
|
||||
|
||||
void NXTTest::FlushWire() {
|
||||
void DawnTest::FlushWire() {
|
||||
if (gTestUsesWire) {
|
||||
ASSERT(mC2sBuf->Flush());
|
||||
ASSERT(mS2cBuf->Flush());
|
||||
}
|
||||
}
|
||||
|
||||
NXTTest::ReadbackReservation NXTTest::ReserveReadback(uint32_t readbackSize) {
|
||||
DawnTest::ReadbackReservation DawnTest::ReserveReadback(uint32_t readbackSize) {
|
||||
// For now create a new MapRead buffer for each readback
|
||||
// TODO(cwallez@chromium.org): eventually make bigger buffers and allocate linearly?
|
||||
ReadbackSlot slot;
|
||||
slot.bufferSize = readbackSize;
|
||||
slot.buffer = device.CreateBufferBuilder()
|
||||
.SetSize(readbackSize)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
|
||||
.GetResult();
|
||||
slot.buffer =
|
||||
device.CreateBufferBuilder()
|
||||
.SetSize(readbackSize)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
|
||||
.GetResult();
|
||||
|
||||
ReadbackReservation reservation;
|
||||
reservation.buffer = slot.buffer.Clone();
|
||||
|
@ -301,8 +320,9 @@ NXTTest::ReadbackReservation NXTTest::ReserveReadback(uint32_t readbackSize) {
|
|||
return reservation;
|
||||
}
|
||||
|
||||
void NXTTest::MapSlotsSynchronously() {
|
||||
// Initialize numPendingMapOperations before mapping, just in case the callback is called immediately.
|
||||
void DawnTest::MapSlotsSynchronously() {
|
||||
// Initialize numPendingMapOperations before mapping, just in case the callback is called
|
||||
// immediately.
|
||||
mNumPendingMapOperations = mReadbackSlots.size();
|
||||
|
||||
// Map all readback slots
|
||||
|
@ -310,7 +330,9 @@ void NXTTest::MapSlotsSynchronously() {
|
|||
auto userdata = new MapReadUserdata{this, i};
|
||||
|
||||
auto& slot = mReadbackSlots[i];
|
||||
slot.buffer.MapReadAsync(0, slot.bufferSize, SlotMapReadCallback, static_cast<dawn::CallbackUserdata>(reinterpret_cast<uintptr_t>(userdata)));
|
||||
slot.buffer.MapReadAsync(
|
||||
0, slot.bufferSize, SlotMapReadCallback,
|
||||
static_cast<dawn::CallbackUserdata>(reinterpret_cast<uintptr_t>(userdata)));
|
||||
}
|
||||
|
||||
// Busy wait until all map operations are done.
|
||||
|
@ -320,31 +342,33 @@ void NXTTest::MapSlotsSynchronously() {
|
|||
}
|
||||
|
||||
// static
|
||||
void NXTTest::SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
dawnCallbackUserdata userdata_) {
|
||||
void DawnTest::SlotMapReadCallback(dawnBufferMapAsyncStatus status,
|
||||
const void* data,
|
||||
dawnCallbackUserdata userdata_) {
|
||||
DAWN_ASSERT(status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS);
|
||||
|
||||
auto userdata = reinterpret_cast<MapReadUserdata*>(static_cast<uintptr_t>(userdata_));
|
||||
userdata->test->mReadbackSlots[userdata->slot].mappedData = data;
|
||||
userdata->test->mNumPendingMapOperations --;
|
||||
userdata->test->mNumPendingMapOperations--;
|
||||
|
||||
delete userdata;
|
||||
}
|
||||
|
||||
void NXTTest::ResolveExpectations() {
|
||||
void DawnTest::ResolveExpectations() {
|
||||
for (const auto& expectation : mDeferredExpectations) {
|
||||
DAWN_ASSERT(mReadbackSlots[expectation.readbackSlot].mappedData != nullptr);
|
||||
|
||||
// Get a pointer to the mapped copy of the data for the expectation.
|
||||
const char* data = reinterpret_cast<const char*>(mReadbackSlots[expectation.readbackSlot].mappedData);
|
||||
const char* data =
|
||||
reinterpret_cast<const char*>(mReadbackSlots[expectation.readbackSlot].mappedData);
|
||||
data += expectation.readbackOffset;
|
||||
|
||||
uint32_t size;
|
||||
std::vector<char> packedData;
|
||||
if (expectation.rowBytes != expectation.rowPitch) {
|
||||
DAWN_ASSERT(expectation.rowPitch > expectation.rowBytes);
|
||||
uint32_t rowCount = (expectation.size + expectation.rowPitch - 1) / expectation.rowPitch;
|
||||
uint32_t rowCount =
|
||||
(expectation.size + expectation.rowPitch - 1) / expectation.rowPitch;
|
||||
uint32_t packedSize = rowCount * expectation.rowBytes;
|
||||
packedData.resize(packedSize);
|
||||
for (uint32_t r = 0; r < rowCount; ++r) {
|
||||
|
@ -361,7 +385,8 @@ void NXTTest::ResolveExpectations() {
|
|||
// Get the result for the expectation and add context to failures
|
||||
testing::AssertionResult result = expectation.expectation->Check(data, size);
|
||||
if (!result) {
|
||||
result << " Expectation created at " << expectation.file << ":" << expectation.line << std::endl;
|
||||
result << " Expectation created at " << expectation.file << ":" << expectation.line
|
||||
<< std::endl;
|
||||
result << expectation.message->str();
|
||||
}
|
||||
|
||||
|
@ -377,33 +402,30 @@ bool RGBA8::operator!=(const RGBA8& other) const {
|
|||
return !(*this == other);
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& stream, const RGBA8& color) {
|
||||
return stream << "RGBA8(" <<
|
||||
static_cast<int>(color.r) << ", " <<
|
||||
static_cast<int>(color.g) << ", " <<
|
||||
static_cast<int>(color.b) << ", " <<
|
||||
static_cast<int>(color.a) << ")";
|
||||
std::ostream& operator<<(std::ostream& stream, const RGBA8& color) {
|
||||
return stream << "RGBA8(" << static_cast<int>(color.r) << ", " << static_cast<int>(color.g)
|
||||
<< ", " << static_cast<int>(color.b) << ", " << static_cast<int>(color.a) << ")";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream& stream, BackendType backend) {
|
||||
std::ostream& operator<<(std::ostream& stream, BackendType backend) {
|
||||
return stream << ParamName(backend);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
bool IsBackendAvailable(BackendType type) {
|
||||
switch (type) {
|
||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||
case D3D12Backend:
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
||||
case MetalBackend:
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||
case OpenGLBackend:
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||
case VulkanBackend:
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||
case D3D12Backend:
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
||||
case MetalBackend:
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||
case OpenGLBackend:
|
||||
#endif
|
||||
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||
case VulkanBackend:
|
||||
#endif
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -424,17 +446,17 @@ namespace detail {
|
|||
|
||||
// Helper classes to set expectations
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
ExpectEq<T>::ExpectEq(T singleValue) {
|
||||
mExpected.push_back(singleValue);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
ExpectEq<T>::ExpectEq(const T* values, const unsigned int count) {
|
||||
mExpected.assign(values, values + count);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
testing::AssertionResult ExpectEq<T>::Check(const void* data, size_t size) {
|
||||
DAWN_ASSERT(size == sizeof(T) * mExpected.size());
|
||||
|
||||
|
@ -443,7 +465,10 @@ namespace detail {
|
|||
testing::AssertionResult failure = testing::AssertionFailure();
|
||||
for (size_t i = 0; i < mExpected.size(); ++i) {
|
||||
if (actual[i] != mExpected[i]) {
|
||||
testing::AssertionResult result = testing::AssertionFailure() << "Expected data[" << i << "] to be " << mExpected[i] << ", actual " << actual[i] << std::endl;
|
||||
testing::AssertionResult result = testing::AssertionFailure()
|
||||
<< "Expected data[" << i << "] to be "
|
||||
<< mExpected[i] << ", actual " << actual[i]
|
||||
<< std::endl;
|
||||
|
||||
auto printBuffer = [&](const T* buffer) {
|
||||
static constexpr unsigned int kBytes = sizeof(T);
|
||||
|
@ -477,4 +502,4 @@ namespace detail {
|
|||
template class ExpectEq<uint8_t>;
|
||||
template class ExpectEq<uint32_t>;
|
||||
template class ExpectEq<RGBA8>;
|
||||
}
|
||||
} // namespace detail
|
|
@ -19,34 +19,40 @@
|
|||
|
||||
// Getting data back from NXT is done in an async manners so all expectations are "deferred"
|
||||
// until the end of the test. Also expectations use a copy to a MapRead buffer to get the data
|
||||
// so resources should have the TransferSrc allowed usage bit if you want to add expectations on them.
|
||||
#define EXPECT_BUFFER_U32_EQ(expected, buffer, offset) \
|
||||
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint32_t), new detail::ExpectEq<uint32_t>(expected))
|
||||
// so resources should have the TransferSrc allowed usage bit if you want to add expectations on
|
||||
// them.
|
||||
#define EXPECT_BUFFER_U32_EQ(expected, buffer, offset) \
|
||||
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint32_t), \
|
||||
new detail::ExpectEq<uint32_t>(expected))
|
||||
|
||||
#define EXPECT_BUFFER_U32_RANGE_EQ(expected, buffer, offset, count) \
|
||||
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint32_t) * count, new detail::ExpectEq<uint32_t>(expected, count))
|
||||
#define EXPECT_BUFFER_U32_RANGE_EQ(expected, buffer, offset, count) \
|
||||
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint32_t) * count, \
|
||||
new detail::ExpectEq<uint32_t>(expected, count))
|
||||
|
||||
#define EXPECT_BUFFER_U8_EQ(expected, buffer, offset) \
|
||||
AddBufferExpectation(__FILE__, __LINE__, buffer, offset, sizeof(uint8_t), \
|
||||
new detail::ExpectEq<uint8_t>(expected))
|
||||
|
||||
// Test a pixel of the mip level 0 of a 2D texture.
|
||||
#define EXPECT_PIXEL_RGBA8_EQ(expected, texture, x, y) \
|
||||
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, 1, 1, 0, sizeof(RGBA8), new detail::ExpectEq<RGBA8>(expected))
|
||||
#define EXPECT_PIXEL_RGBA8_EQ(expected, texture, x, y) \
|
||||
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, 1, 1, 0, sizeof(RGBA8), \
|
||||
new detail::ExpectEq<RGBA8>(expected))
|
||||
|
||||
#define EXPECT_TEXTURE_RGBA8_EQ(expected, texture, x, y, width, height, level) \
|
||||
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, width, height, level, sizeof(RGBA8), new detail::ExpectEq<RGBA8>(expected, (width) * (height)))
|
||||
#define EXPECT_TEXTURE_RGBA8_EQ(expected, texture, x, y, width, height, level) \
|
||||
AddTextureExpectation(__FILE__, __LINE__, texture, x, y, width, height, level, sizeof(RGBA8), \
|
||||
new detail::ExpectEq<RGBA8>(expected, (width) * (height)))
|
||||
|
||||
struct RGBA8 {
|
||||
constexpr RGBA8() : RGBA8(0,0,0,0) {}
|
||||
constexpr RGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a): r(r), g(g), b(b), a(a) {
|
||||
constexpr RGBA8() : RGBA8(0, 0, 0, 0) {
|
||||
}
|
||||
constexpr RGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a) {
|
||||
}
|
||||
bool operator==(const RGBA8& other) const;
|
||||
bool operator!=(const RGBA8& other) const;
|
||||
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
std::ostream& operator<< (std::ostream& stream, const RGBA8& color);
|
||||
std::ostream& operator<<(std::ostream& stream, const RGBA8& color);
|
||||
|
||||
// Backend types used in the DAWN_INSTANTIATE_TEST
|
||||
enum BackendType {
|
||||
|
@ -56,7 +62,7 @@ enum BackendType {
|
|||
VulkanBackend,
|
||||
NumBackendTypes,
|
||||
};
|
||||
std::ostream &operator<<(std::ostream& stream, BackendType backend);
|
||||
std::ostream& operator<<(std::ostream& stream, BackendType backend);
|
||||
|
||||
namespace utils {
|
||||
class BackendBinding;
|
||||
|
@ -71,9 +77,9 @@ namespace dawn { namespace wire {
|
|||
class TerribleCommandBuffer;
|
||||
}} // namespace dawn::wire
|
||||
|
||||
class NXTTest : public ::testing::TestWithParam<BackendType> {
|
||||
class DawnTest : public ::testing::TestWithParam<BackendType> {
|
||||
public:
|
||||
~NXTTest();
|
||||
~DawnTest();
|
||||
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
@ -164,11 +170,12 @@ class NXTTest : public ::testing::TestWithParam<BackendType> {
|
|||
|
||||
// Instantiate the test once for each backend provided after the first argument. Use it like this:
|
||||
// DAWN_INSTANTIATE_TEST(MyTestFixture, MetalBackend, OpenGLBackend)
|
||||
#define DAWN_INSTANTIATE_TEST(testName, firstParam, ...) \
|
||||
const decltype(firstParam) testName##params[] = { firstParam, ##__VA_ARGS__ }; \
|
||||
INSTANTIATE_TEST_CASE_P(, testName, \
|
||||
testing::ValuesIn(::detail::FilterBackends(testName##params, sizeof(testName##params) / sizeof(firstParam))), \
|
||||
testing::PrintToStringParamName());
|
||||
#define DAWN_INSTANTIATE_TEST(testName, firstParam, ...) \
|
||||
const decltype(firstParam) testName##params[] = {firstParam, ##__VA_ARGS__}; \
|
||||
INSTANTIATE_TEST_CASE_P(, testName, \
|
||||
testing::ValuesIn(::detail::FilterBackends( \
|
||||
testName##params, sizeof(testName##params) / sizeof(firstParam))), \
|
||||
testing::PrintToStringParamName());
|
||||
|
||||
namespace detail {
|
||||
// Helper functions used for DAWN_INSTANTIATE_TEST
|
||||
|
@ -177,27 +184,26 @@ namespace detail {
|
|||
|
||||
// All classes used to implement the deferred expectations should inherit from this.
|
||||
class Expectation {
|
||||
public:
|
||||
virtual ~Expectation() = default;
|
||||
public:
|
||||
virtual ~Expectation() = default;
|
||||
|
||||
// Will be called with the buffer or texture data the expectation should check.
|
||||
virtual testing::AssertionResult Check(const void* data, size_t size) = 0;
|
||||
// Will be called with the buffer or texture data the expectation should check.
|
||||
virtual testing::AssertionResult Check(const void* data, size_t size) = 0;
|
||||
};
|
||||
|
||||
// Expectation that checks the data is equal to some expected values.
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
class ExpectEq : public Expectation {
|
||||
public:
|
||||
ExpectEq(T singleValue);
|
||||
ExpectEq(const T* values, const unsigned int count);
|
||||
public:
|
||||
ExpectEq(T singleValue);
|
||||
ExpectEq(const T* values, const unsigned int count);
|
||||
|
||||
testing::AssertionResult Check(const void* data, size_t size) override;
|
||||
testing::AssertionResult Check(const void* data, size_t size) override;
|
||||
|
||||
private:
|
||||
std::vector<T> mExpected;
|
||||
private:
|
||||
std::vector<T> mExpected;
|
||||
};
|
||||
extern template class ExpectEq<uint8_t>;
|
||||
extern template class ExpectEq<uint32_t>;
|
||||
extern template class ExpectEq<RGBA8>;
|
||||
}
|
||||
|
||||
} // namespace detail
|
|
@ -12,11 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
class BasicTests : public NXTTest {
|
||||
class BasicTests : public DawnTest {
|
||||
};
|
||||
|
||||
// Test Buffer::SetSubData changes the content of the buffer, but really this is the most
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/Constants.h"
|
||||
|
@ -23,10 +23,10 @@
|
|||
|
||||
constexpr static unsigned int kRTSize = 64;
|
||||
|
||||
class BlendStateTest : public NXTTest {
|
||||
class BlendStateTest : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NXTTest::SetUp();
|
||||
DawnTest::SetUp();
|
||||
|
||||
vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
class BufferMapReadTests : public NXTTest {
|
||||
class BufferMapReadTests : public DawnTest {
|
||||
protected:
|
||||
|
||||
static void MapReadCallback(dawnBufferMapAsyncStatus status, const void* data, dawnCallbackUserdata userdata) {
|
||||
|
@ -112,7 +112,7 @@ TEST_P(BufferMapReadTests, LargeRead) {
|
|||
|
||||
DAWN_INSTANTIATE_TEST(BufferMapReadTests, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend)
|
||||
|
||||
class BufferMapWriteTests : public NXTTest {
|
||||
class BufferMapWriteTests : public DawnTest {
|
||||
protected:
|
||||
|
||||
static void MapWriteCallback(dawnBufferMapAsyncStatus status, void* data, dawnCallbackUserdata userdata) {
|
||||
|
@ -189,7 +189,7 @@ TEST_P(BufferMapWriteTests, LargeWrite) {
|
|||
|
||||
DAWN_INSTANTIATE_TEST(BufferMapWriteTests, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend)
|
||||
|
||||
class BufferSetSubDataTests : public NXTTest {
|
||||
class BufferSetSubDataTests : public DawnTest {
|
||||
};
|
||||
|
||||
// Test the simplest set sub data: setting one u8 at offset 0.
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
class ComputeCopyStorageBufferTests : public NXTTest {
|
||||
class ComputeCopyStorageBufferTests : public DawnTest {
|
||||
public:
|
||||
static constexpr int kInstances = 4;
|
||||
static constexpr int kUintsPerInstance = 4;
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include <array>
|
||||
#include "common/Constants.h"
|
||||
#include "common/Math.h"
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
class CopyTests : public NXTTest {
|
||||
class CopyTests : public DawnTest {
|
||||
protected:
|
||||
static constexpr unsigned int kBytesPerTexel = 4;
|
||||
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
constexpr static unsigned int kRTSize = 64;
|
||||
|
||||
class DepthStencilStateTest : public NXTTest {
|
||||
class DepthStencilStateTest : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NXTTest::SetUp();
|
||||
DawnTest::SetUp();
|
||||
|
||||
renderTarget = device.CreateTextureBuilder()
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
constexpr uint32_t kRTSize = 4;
|
||||
|
||||
class DrawElementsTest : public NXTTest {
|
||||
class DrawElementsTest : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NXTTest::SetUp();
|
||||
DawnTest::SetUp();
|
||||
|
||||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
constexpr uint32_t kRTSize = 400;
|
||||
|
||||
class IndexFormatTest : public NXTTest {
|
||||
class IndexFormatTest : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NXTTest::SetUp();
|
||||
DawnTest::SetUp();
|
||||
|
||||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
@ -32,10 +32,10 @@ constexpr static unsigned int kRTSize = 400;
|
|||
constexpr static unsigned int kRTCellOffset = 50;
|
||||
constexpr static unsigned int kRTCellSize = 100;
|
||||
|
||||
class InputStateTest : public NXTTest {
|
||||
class InputStateTest : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NXTTest::SetUp();
|
||||
DawnTest::SetUp();
|
||||
|
||||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
@ -142,10 +142,10 @@ constexpr static float kVertices[] = {
|
|||
};
|
||||
// clang-format on
|
||||
|
||||
class PrimitiveTopologyTest : public NXTTest {
|
||||
class PrimitiveTopologyTest : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NXTTest::SetUp();
|
||||
DawnTest::SetUp();
|
||||
|
||||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/Constants.h"
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include <array>
|
||||
|
||||
class PushConstantTest: public NXTTest {
|
||||
class PushConstantTest: public DawnTest {
|
||||
protected:
|
||||
// Layout, bind group and friends to store results for compute tests, can have an extra buffer
|
||||
// so that two different pipeline layout can be created.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
|
@ -50,10 +50,10 @@ class DrawQuad {
|
|||
dawn::PipelineLayout pipelineLayout = {};
|
||||
};
|
||||
|
||||
class RenderPassLoadOpTests : public NXTTest {
|
||||
class RenderPassLoadOpTests : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NXTTest::SetUp();
|
||||
DawnTest::SetUp();
|
||||
|
||||
renderTarget = device.CreateTextureBuilder()
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/Constants.h"
|
||||
|
@ -36,10 +36,10 @@ namespace {
|
|||
};
|
||||
}
|
||||
|
||||
class SamplerTest : public NXTTest {
|
||||
class SamplerTest : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NXTTest::SetUp();
|
||||
DawnTest::SetUp();
|
||||
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
mBindGroupLayout = utils::MakeBindGroupLayout(
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
class ScissorTest: public NXTTest {
|
||||
class ScissorTest: public DawnTest {
|
||||
protected:
|
||||
dawn::RenderPipeline CreateQuadPipeline(dawn::TextureFormat format) {
|
||||
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/NXTTest.h"
|
||||
#include "tests/DawnTest.h"
|
||||
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
class ViewportOrientationTests : public NXTTest {};
|
||||
class ViewportOrientationTests : public DawnTest {};
|
||||
|
||||
// Test that the pixel in viewport coordinate (-1, -1) matches texel (0, 0)
|
||||
TEST_P(ViewportOrientationTests, OriginAt0x0) {
|
||||
|
|
Loading…
Reference in New Issue