mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +00:00
Create nonzero_clear_resources_on_creation_for_testing toggle
Created toggle to force texture clearing to 1 bits in order to test the logic of lazy clearing. Bug: dawn:145 Change-Id: I83bc32f046159c709c426b77458fbdf115f7bfd0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7120 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Natasha Lee <natlee@microsoft.com>
This commit is contained in:
committed by
Commit Bot service account
parent
efef0e4b1f
commit
97f08fa2e6
@@ -293,6 +293,7 @@ void DawnTest::SetUp() {
|
||||
DawnDevice backendDevice;
|
||||
const char* forceEnabledWorkaround = GetParam().forceEnabledWorkaround;
|
||||
if (forceEnabledWorkaround != nullptr) {
|
||||
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr);
|
||||
dawn_native::DeviceDescriptor deviceDescriptor = InitWorkaround(forceEnabledWorkaround);
|
||||
backendDevice = backendAdapter.CreateDevice(&deviceDescriptor);
|
||||
} else {
|
||||
|
||||
99
src/tests/end2end/NonzeroTextureCreationTests.cpp
Normal file
99
src/tests/end2end/NonzeroTextureCreationTests.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
// 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 "tests/DawnTest.h"
|
||||
|
||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
class NonzeroTextureCreationTests : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
DawnTest::SetUp();
|
||||
}
|
||||
|
||||
constexpr static uint32_t kSize = 128;
|
||||
};
|
||||
|
||||
// Test that texture clears to 1's because toggle is enabled.
|
||||
TEST_P(NonzeroTextureCreationTests, TextureCreationClearsOneBits) {
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.size.width = kSize;
|
||||
descriptor.size.height = kSize;
|
||||
descriptor.size.depth = 1;
|
||||
descriptor.arrayLayerCount = 1;
|
||||
descriptor.sampleCount = 1;
|
||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
descriptor.mipLevelCount = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||
|
||||
RGBA8 filledWithOnes(255, 255, 255, 255);
|
||||
EXPECT_PIXEL_RGBA8_EQ(filledWithOnes, texture, 0, 0);
|
||||
}
|
||||
|
||||
// Test that non-zero mip level clears to 1's because toggle is enabled.
|
||||
TEST_P(NonzeroTextureCreationTests, MipMapClears) {
|
||||
constexpr uint32_t mipLevels = 4;
|
||||
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.size.width = kSize;
|
||||
descriptor.size.height = kSize;
|
||||
descriptor.size.depth = 1;
|
||||
descriptor.arrayLayerCount = 1;
|
||||
descriptor.sampleCount = 1;
|
||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
descriptor.mipLevelCount = mipLevels;
|
||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||
|
||||
std::vector<RGBA8> expected;
|
||||
RGBA8 filledWithOnes(255, 255, 255, 255);
|
||||
for (uint32_t i = 0; i < kSize * kSize; ++i) {
|
||||
expected.push_back(filledWithOnes);
|
||||
}
|
||||
uint32_t mipSize = kSize >> 2;
|
||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, mipSize, mipSize, 2, 0);
|
||||
}
|
||||
|
||||
// Test that non-zero array layers clears to 1's because toggle is enabled.
|
||||
TEST_P(NonzeroTextureCreationTests, ArrayLayerClears) {
|
||||
constexpr uint32_t arrayLayers = 4;
|
||||
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.size.width = kSize;
|
||||
descriptor.size.height = kSize;
|
||||
descriptor.size.depth = 1;
|
||||
descriptor.arrayLayerCount = arrayLayers;
|
||||
descriptor.sampleCount = 1;
|
||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
descriptor.mipLevelCount = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
|
||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||
|
||||
std::vector<RGBA8> expected;
|
||||
RGBA8 filledWithOnes(255, 255, 255, 255);
|
||||
for (uint32_t i = 0; i < kSize * kSize; ++i) {
|
||||
expected.push_back(filledWithOnes);
|
||||
}
|
||||
|
||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, kSize, kSize, 0, 2);
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(NonzeroTextureCreationTests,
|
||||
ForceWorkaround(VulkanBackend,
|
||||
"nonzero_clear_resources_on_creation_for_testing"));
|
||||
Reference in New Issue
Block a user