mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Support BC formats as the first extension in Dawn
This patch refactors the current implementation of BC formats to treat it as the first extension in Dawn and adds all the related tests. Note that in Dawn all the extensions are disabled unless we enable them when we create the device, which means the BC formats can only be used when we enable the related extension on the creation of the device, and the creation of the device will fail if the adapter does not support the extension BUG=dawn:42 TEST=dawn_end2end_tests TEST=dawn_unittests Change-Id: I04d818b0218ebb3b1b7a70a4fea71779f308f85f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9520 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
56f3a7b90d
commit
574b951188
@@ -333,9 +333,31 @@ uint32_t DawnTest::GetVendorIdFilter() const {
|
||||
return gTestEnv->GetVendorIdFilter();
|
||||
}
|
||||
|
||||
std::vector<const char*> DawnTest::GetRequiredExtensions() {
|
||||
return {};
|
||||
}
|
||||
|
||||
// This function can only be called after SetUp() because it requires mBackendAdapter to be
|
||||
// initialized.
|
||||
bool DawnTest::SupportsExtensions(const std::vector<const char*>& extensions) {
|
||||
ASSERT(mBackendAdapter);
|
||||
|
||||
std::set<std::string> supportedExtensionsSet;
|
||||
for (const char* supportedExtensionName : mBackendAdapter.GetSupportedExtensions()) {
|
||||
supportedExtensionsSet.insert(supportedExtensionName);
|
||||
}
|
||||
|
||||
for (const char* extensionName : extensions) {
|
||||
if (supportedExtensionsSet.find(extensionName) == supportedExtensionsSet.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DawnTest::SetUp() {
|
||||
// Get an adapter for the backend to use, and create the device.
|
||||
dawn_native::Adapter backendAdapter;
|
||||
// Initialize mBackendAdapter, and create the device.
|
||||
const dawn_native::BackendType backendType = GetParam().backendType;
|
||||
{
|
||||
dawn_native::Instance* instance = gTestEnv->GetInstance();
|
||||
@@ -345,11 +367,11 @@ void DawnTest::SetUp() {
|
||||
if (adapter.GetBackendType() == backendType) {
|
||||
if (HasVendorIdFilter()) {
|
||||
if (adapter.GetPCIInfo().vendorId == GetVendorIdFilter()) {
|
||||
backendAdapter = adapter;
|
||||
mBackendAdapter = adapter;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
backendAdapter = adapter;
|
||||
mBackendAdapter = adapter;
|
||||
|
||||
// On Metal, select the last adapter so that the discrete GPU is tested on
|
||||
// multi-GPU systems.
|
||||
@@ -363,10 +385,10 @@ void DawnTest::SetUp() {
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(backendAdapter);
|
||||
ASSERT(mBackendAdapter);
|
||||
}
|
||||
|
||||
mPCIInfo = backendAdapter.GetPCIInfo();
|
||||
mPCIInfo = mBackendAdapter.GetPCIInfo();
|
||||
|
||||
for (const char* forceEnabledWorkaround : GetParam().forceEnabledWorkarounds) {
|
||||
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr);
|
||||
@@ -377,7 +399,9 @@ void DawnTest::SetUp() {
|
||||
dawn_native::DeviceDescriptor deviceDescriptor;
|
||||
deviceDescriptor.forceEnabledToggles = GetParam().forceEnabledWorkarounds;
|
||||
deviceDescriptor.forceDisabledToggles = GetParam().forceDisabledWorkarounds;
|
||||
backendDevice = backendAdapter.CreateDevice(&deviceDescriptor);
|
||||
deviceDescriptor.requiredExtensions = GetRequiredExtensions();
|
||||
backendDevice = mBackendAdapter.CreateDevice(&deviceDescriptor);
|
||||
ASSERT_NE(nullptr, backendDevice);
|
||||
|
||||
backendProcs = dawn_native::GetProcs();
|
||||
|
||||
|
||||
@@ -206,6 +206,14 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
||||
|
||||
void SwapBuffersForCapture();
|
||||
|
||||
bool SupportsExtensions(const std::vector<const char*>& extensions);
|
||||
|
||||
// Called in SetUp() to get the extensions required to be enabled in the tests. The tests must
|
||||
// check if the required extensions are supported by the adapter in this function and guarantee
|
||||
// the returned extensions are all supported by the adapter. The tests may provide different
|
||||
// code path to handle the situation when not all extensions are supported.
|
||||
virtual std::vector<const char*> GetRequiredExtensions();
|
||||
|
||||
private:
|
||||
// Things used to set up testing through the Wire.
|
||||
std::unique_ptr<dawn_wire::WireServer> mWireServer;
|
||||
@@ -263,6 +271,8 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
||||
std::unique_ptr<utils::BackendBinding> mBinding;
|
||||
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
|
||||
dawn_native::Adapter mBackendAdapter;
|
||||
};
|
||||
|
||||
// Instantiate the test once for each backend provided after the first argument. Use it like this:
|
||||
|
||||
@@ -67,9 +67,24 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
||||
{1, dawn::ShaderStageBit::Fragment, dawn::BindingType::SampledTexture}});
|
||||
}
|
||||
|
||||
std::vector<const char*> GetRequiredExtensions() override {
|
||||
mIsBCFormatSupported = SupportsExtensions({"texture_compression_bc"});
|
||||
if (!mIsBCFormatSupported) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {"texture_compression_bc"};
|
||||
}
|
||||
|
||||
bool IsBCFormatSupported() const {
|
||||
return mIsBCFormatSupported;
|
||||
}
|
||||
|
||||
// Copy the compressed texture data into the destination texture as is specified in copyConfig.
|
||||
void CopyDataIntoCompressedTexture(dawn::Texture bcCompressedTexture,
|
||||
const CopyConfig& copyConfig) {
|
||||
ASSERT(IsBCFormatSupported());
|
||||
|
||||
// Compute the upload buffer size with rowPitchAlignment and the copy region.
|
||||
uint32_t actualWidthAtLevel = copyConfig.textureWidthLevel0 >> copyConfig.baseMipmapLevel;
|
||||
uint32_t actualHeightAtLevel = copyConfig.textureHeightLevel0 >> copyConfig.baseMipmapLevel;
|
||||
@@ -121,6 +136,8 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
||||
dawn::TextureFormat bcFormat,
|
||||
uint32_t baseArrayLayer = 0,
|
||||
uint32_t baseMipLevel = 0) {
|
||||
ASSERT(IsBCFormatSupported());
|
||||
|
||||
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
||||
samplerDesc.minFilter = dawn::FilterMode::Nearest;
|
||||
samplerDesc.magFilter = dawn::FilterMode::Nearest;
|
||||
@@ -140,6 +157,8 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
||||
|
||||
// Create a render pipeline for sampling from a BC texture and rendering into the render target.
|
||||
dawn::RenderPipeline CreateRenderPipelineForTest() {
|
||||
ASSERT(IsBCFormatSupported());
|
||||
|
||||
dawn::PipelineLayout pipelineLayout =
|
||||
utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
|
||||
|
||||
@@ -183,6 +202,8 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
||||
const dawn::Origin3D& expectedOrigin,
|
||||
const dawn::Extent3D& expectedExtent,
|
||||
const std::vector<RGBA8>& expected) {
|
||||
ASSERT(IsBCFormatSupported());
|
||||
|
||||
ASSERT(expected.size() == renderTargetSize.width * renderTargetSize.height);
|
||||
utils::BasicRenderPass renderPass =
|
||||
utils::CreateBasicRenderPass(device, renderTargetSize.width, renderTargetSize.height);
|
||||
@@ -207,6 +228,8 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
||||
// Run the tests that copies pre-prepared BC format data into a BC texture and verifies if we
|
||||
// can render correctly with the pixel values sampled from the BC texture.
|
||||
void TestCopyRegionIntoBCFormatTextures(const CopyConfig& config) {
|
||||
ASSERT(IsBCFormatSupported());
|
||||
|
||||
dawn::Texture bcTexture = Create2DTexture(device, config.format, config.textureWidthLevel0,
|
||||
config.textureHeightLevel0,
|
||||
config.arrayLayerCount, config.mipmapLevelCount);
|
||||
@@ -416,10 +439,14 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
||||
static constexpr uint32_t kBCBlockHeightInTexels = 4;
|
||||
|
||||
dawn::BindGroupLayout mBindGroupLayout;
|
||||
|
||||
bool mIsBCFormatSupported = false;
|
||||
};
|
||||
|
||||
// Test copying into the whole BC texture with 2x2 blocks and sampling from it.
|
||||
TEST_P(CompressedTextureBCFormatTest, Basic) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureWidthLevel0 = 8;
|
||||
config.textureHeightLevel0 = 8;
|
||||
@@ -433,6 +460,8 @@ TEST_P(CompressedTextureBCFormatTest, Basic) {
|
||||
|
||||
// Test copying into a sub-region of a texture with BC formats works correctly.
|
||||
TEST_P(CompressedTextureBCFormatTest, CopyIntoSubRegion) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureHeightLevel0 = 8;
|
||||
config.textureWidthLevel0 = 8;
|
||||
@@ -451,6 +480,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyIntoSubRegion) {
|
||||
|
||||
// Test using rowPitch == 0 in the copies with BC formats works correctly.
|
||||
TEST_P(CompressedTextureBCFormatTest, CopyWithZeroRowPitch) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureHeightLevel0 = 8;
|
||||
|
||||
@@ -468,6 +499,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyWithZeroRowPitch) {
|
||||
|
||||
// Test copying into the non-zero layer of a 2D array texture with BC formats works correctly.
|
||||
TEST_P(CompressedTextureBCFormatTest, CopyIntoNonZeroArrayLayer) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureHeightLevel0 = 8;
|
||||
config.textureWidthLevel0 = 8;
|
||||
@@ -486,6 +519,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyIntoNonZeroArrayLayer) {
|
||||
|
||||
// Test copying into a non-zero mipmap level of a texture with BC texture formats.
|
||||
TEST_P(CompressedTextureBCFormatTest, CopyBufferIntoNonZeroMipmapLevel) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureHeightLevel0 = 60;
|
||||
config.textureWidthLevel0 = 60;
|
||||
@@ -517,6 +552,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyBufferIntoNonZeroMipmapLevel) {
|
||||
|
||||
// Test texture-to-texture whole-size copies with BC formats.
|
||||
TEST_P(CompressedTextureBCFormatTest, CopyWholeTextureSubResourceIntoNonZeroMipmapLevel) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
// TODO(cwallez@chromium.org): This consistently fails on with the 12th pixel being opaque black
|
||||
// instead of opaque red on Win10 FYI Release (NVIDIA GeForce GTX 1660). See
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=981393
|
||||
@@ -576,6 +613,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyWholeTextureSubResourceIntoNonZeroMipm
|
||||
|
||||
// Test BC format texture-to-texture partial copies.
|
||||
TEST_P(CompressedTextureBCFormatTest, CopyPartofTextureSubResourceIntoNonZeroMipmapLevel) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
// TODO(jiawei.shao@intel.com): add workaround on the T2T copies where Extent3D fits in one
|
||||
// subresource and does not fit in another one on Vulkan. Currently this test causes an error if
|
||||
// Vulkan validation layer is enabled.
|
||||
@@ -652,6 +691,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyPartofTextureSubResourceIntoNonZeroMip
|
||||
// Test the special case of the B2T copies on the D3D12 backend that the buffer offset and texture
|
||||
// extent exactly fit the RowPitch.
|
||||
TEST_P(CompressedTextureBCFormatTest, BufferOffsetAndExtentFitRowPitch) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureWidthLevel0 = 8;
|
||||
config.textureHeightLevel0 = 8;
|
||||
@@ -677,6 +718,8 @@ TEST_P(CompressedTextureBCFormatTest, BufferOffsetAndExtentFitRowPitch) {
|
||||
// backend the texelOffset.y will be greater than 0 after calcuting the texelOffset in the function
|
||||
// ComputeTexelOffsets().
|
||||
TEST_P(CompressedTextureBCFormatTest, BufferOffsetExceedsSlicePitch) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureWidthLevel0 = 8;
|
||||
config.textureHeightLevel0 = 8;
|
||||
@@ -703,6 +746,8 @@ TEST_P(CompressedTextureBCFormatTest, BufferOffsetExceedsSlicePitch) {
|
||||
// Test the special case of the B2T copies on the D3D12 backend that the buffer offset and texture
|
||||
// extent exceed the RowPitch. On D3D12 backend two copies are required for this case.
|
||||
TEST_P(CompressedTextureBCFormatTest, CopyWithBufferOffsetAndExtentExceedRowPitch) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureWidthLevel0 = 8;
|
||||
config.textureHeightLevel0 = 8;
|
||||
@@ -729,6 +774,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyWithBufferOffsetAndExtentExceedRowPitc
|
||||
// rowPitch. On D3D12 backend the texelOffset.z will be greater than 0 after calcuting the
|
||||
// texelOffset in the function ComputeTexelOffsets().
|
||||
TEST_P(CompressedTextureBCFormatTest, RowPitchEqualToSlicePitch) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureWidthLevel0 = 8;
|
||||
config.textureHeightLevel0 = kBCBlockHeightInTexels;
|
||||
@@ -755,6 +802,8 @@ TEST_P(CompressedTextureBCFormatTest, RowPitchEqualToSlicePitch) {
|
||||
// copyExtent.depth) on Metal backends. As copyExtent.depth can only be 1 for BC formats, on Metal
|
||||
// backend we will use two copies to implement such copy.
|
||||
TEST_P(CompressedTextureBCFormatTest, LargeImageHeight) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureWidthLevel0 = 8;
|
||||
config.textureHeightLevel0 = 8;
|
||||
@@ -771,6 +820,8 @@ TEST_P(CompressedTextureBCFormatTest, LargeImageHeight) {
|
||||
// Test the workaround in the B2T copies when (bufferSize - bufferOffset < bytesPerImage *
|
||||
// copyExtent.depth) and copyExtent needs to be clamped.
|
||||
TEST_P(CompressedTextureBCFormatTest, LargeImageHeightAndClampedCopyExtent) {
|
||||
DAWN_SKIP_TEST_IF(!IsBCFormatSupported());
|
||||
|
||||
CopyConfig config;
|
||||
config.textureHeightLevel0 = 56;
|
||||
config.textureWidthLevel0 = 56;
|
||||
@@ -803,4 +854,8 @@ TEST_P(CompressedTextureBCFormatTest, LargeImageHeightAndClampedCopyExtent) {
|
||||
}
|
||||
|
||||
// TODO(jiawei.shao@intel.com): support BC formats on OpenGL backend
|
||||
DAWN_INSTANTIATE_TEST(CompressedTextureBCFormatTest, D3D12Backend, MetalBackend, VulkanBackend);
|
||||
DAWN_INSTANTIATE_TEST(CompressedTextureBCFormatTest,
|
||||
D3D12Backend,
|
||||
MetalBackend,
|
||||
OpenGLBackend,
|
||||
VulkanBackend);
|
||||
|
||||
78
src/tests/unittests/ExtensionTests.cpp
Normal file
78
src/tests/unittests/ExtensionTests.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright 2019 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "dawn_native/Extensions.h"
|
||||
#include "dawn_native/Instance.h"
|
||||
#include "dawn_native/null/DeviceNull.h"
|
||||
|
||||
class ExtensionTests : public testing::Test {
|
||||
public:
|
||||
ExtensionTests() : testing::Test(), mInstanceBase(), mAdapterBase(&mInstanceBase) {
|
||||
}
|
||||
|
||||
std::vector<const char*> GetAllExtensionNames() {
|
||||
std::vector<const char*> allExtensionNames(kTotalExtensionsCount);
|
||||
for (size_t i = 0; i < kTotalExtensionsCount; ++i) {
|
||||
allExtensionNames[i] = ExtensionEnumToName(static_cast<dawn_native::Extension>(i));
|
||||
}
|
||||
return allExtensionNames;
|
||||
}
|
||||
|
||||
static constexpr size_t kTotalExtensionsCount =
|
||||
static_cast<size_t>(dawn_native::Extension::EnumCount);
|
||||
|
||||
protected:
|
||||
dawn_native::InstanceBase mInstanceBase;
|
||||
dawn_native::null::Adapter mAdapterBase;
|
||||
};
|
||||
|
||||
// Test the creation of a device will fail if the requested extension is not supported on the
|
||||
// Adapter.
|
||||
TEST_F(ExtensionTests, AdapterWithRequiredExtensionDisabled) {
|
||||
const std::vector<const char*> kAllExtensionNames = GetAllExtensionNames();
|
||||
for (size_t i = 0; i < kTotalExtensionsCount; ++i) {
|
||||
dawn_native::Extension notSupportedExtension = static_cast<dawn_native::Extension>(i);
|
||||
|
||||
std::vector<const char*> extensionNamesWithoutOne = kAllExtensionNames;
|
||||
extensionNamesWithoutOne.erase(extensionNamesWithoutOne.begin() + i);
|
||||
|
||||
mAdapterBase.SetSupportedExtensions(extensionNamesWithoutOne);
|
||||
dawn_native::Adapter adapterWithoutExtension(&mAdapterBase);
|
||||
|
||||
dawn_native::DeviceDescriptor deviceDescriptor;
|
||||
const char* extensionName = ExtensionEnumToName(notSupportedExtension);
|
||||
deviceDescriptor.requiredExtensions = std::vector<const char*>(1, extensionName);
|
||||
DawnDevice deviceWithExtension = adapterWithoutExtension.CreateDevice(&deviceDescriptor);
|
||||
ASSERT_EQ(nullptr, deviceWithExtension);
|
||||
}
|
||||
}
|
||||
|
||||
// Test Device.GetEnabledExtensions() can return the names of the enabled extensions correctly.
|
||||
TEST_F(ExtensionTests, GetEnabledExtensions) {
|
||||
dawn_native::Adapter adapter(&mAdapterBase);
|
||||
for (size_t i = 0; i < kTotalExtensionsCount; ++i) {
|
||||
dawn_native::Extension extension = static_cast<dawn_native::Extension>(i);
|
||||
const char* extensionName = ExtensionEnumToName(extension);
|
||||
|
||||
dawn_native::DeviceDescriptor deviceDescriptor;
|
||||
deviceDescriptor.requiredExtensions = {extensionName};
|
||||
dawn_native::DeviceBase* deviceBase =
|
||||
reinterpret_cast<dawn_native::DeviceBase*>(adapter.CreateDevice(&deviceDescriptor));
|
||||
std::vector<const char*> enabledExtensions = deviceBase->GetEnabledExtensions();
|
||||
ASSERT_EQ(1u, enabledExtensions.size());
|
||||
ASSERT_EQ(0, std::strcmp(extensionName, enabledExtensions[0]));
|
||||
}
|
||||
}
|
||||
@@ -1155,6 +1155,11 @@ TEST_F(CopyCommandTest_T2T, CopyToMipmapOfNonSquareTexture) {
|
||||
}
|
||||
|
||||
class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {
|
||||
public:
|
||||
CopyCommandTest_CompressedTextureFormats() : CopyCommandTest() {
|
||||
device = CreateDeviceFromAdapter(adapter, {"texture_compression_bc"});
|
||||
}
|
||||
|
||||
protected:
|
||||
dawn::Texture Create2DTexture(dawn::TextureFormat format,
|
||||
uint32_t mipmapLevels = 1,
|
||||
|
||||
@@ -250,10 +250,14 @@ TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
|
||||
// TODO(jiawei.shao@intel.com): use compressed texture formats as extensions.
|
||||
// TODO(jiawei.shao@intel.com): add tests to verify we cannot create 1D or 3D textures with
|
||||
// compressed texture formats.
|
||||
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||
public:
|
||||
CompressedTextureFormatsValidationTests() : TextureValidationTest() {
|
||||
device = CreateDeviceFromAdapter(adapter, {"texture_compression_bc"});
|
||||
}
|
||||
|
||||
protected:
|
||||
dawn::TextureDescriptor CreateDefaultTextureDescriptor() {
|
||||
dawn::TextureDescriptor descriptor =
|
||||
@@ -309,6 +313,18 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test the creation of a texture with BC format will fail when the extension textureCompressionBC
|
||||
// is not enabled.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtension) {
|
||||
const std::vector<const char*> kEmptyVector;
|
||||
dawn::Device deviceWithoutExtension = CreateDeviceFromAdapter(adapter, kEmptyVector);
|
||||
for (dawn::TextureFormat format : kBCFormats) {
|
||||
dawn::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
descriptor.format = format;
|
||||
ASSERT_DEVICE_ERROR(deviceWithoutExtension.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
// Test the validation of texture usages when creating textures in compressed texture formats.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
||||
// Test that only CopySrc, CopyDst and Sampled are accepted as the texture usage of the
|
||||
|
||||
@@ -35,12 +35,29 @@ ValidationTest::ValidationTest() {
|
||||
}
|
||||
|
||||
ASSERT(foundNullAdapter);
|
||||
device = dawn::Device::Acquire(adapter.CreateDevice());
|
||||
|
||||
DawnProcTable procs = dawn_native::GetProcs();
|
||||
dawnSetProcs(&procs);
|
||||
|
||||
device.SetErrorCallback(ValidationTest::OnDeviceError, this);
|
||||
device = CreateDeviceFromAdapter(adapter, std::vector<const char*>());
|
||||
}
|
||||
|
||||
dawn::Device ValidationTest::CreateDeviceFromAdapter(
|
||||
dawn_native::Adapter adapterToTest,
|
||||
const std::vector<const char*>& requiredExtensions) {
|
||||
dawn::Device deviceToTest;
|
||||
|
||||
// Always keep the code path to test creating a device without a device descriptor.
|
||||
if (requiredExtensions.empty()) {
|
||||
deviceToTest = dawn::Device::Acquire(adapterToTest.CreateDevice());
|
||||
} else {
|
||||
dawn_native::DeviceDescriptor descriptor;
|
||||
descriptor.requiredExtensions = requiredExtensions;
|
||||
deviceToTest = dawn::Device::Acquire(adapterToTest.CreateDevice(&descriptor));
|
||||
}
|
||||
|
||||
deviceToTest.SetErrorCallback(ValidationTest::OnDeviceError, this);
|
||||
return deviceToTest;
|
||||
}
|
||||
|
||||
ValidationTest::~ValidationTest() {
|
||||
|
||||
@@ -29,6 +29,9 @@ class ValidationTest : public testing::Test {
|
||||
ValidationTest();
|
||||
~ValidationTest();
|
||||
|
||||
dawn::Device CreateDeviceFromAdapter(dawn_native::Adapter adapter,
|
||||
const std::vector<const char*>& requiredExtensions);
|
||||
|
||||
void TearDown() override;
|
||||
|
||||
void StartExpectDeviceError();
|
||||
|
||||
Reference in New Issue
Block a user