mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +00:00
dawn_native: deduplicate pipeline layouts
This is the first step to do pipeline deduplication. It also introduces tests for deduplication. BUG=dawn:143 Change-Id: Ib22496f543f8d1f9cfde04f725612504132c7d72 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6861 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
cc141797df
commit
0ee9859c91
@@ -166,7 +166,7 @@ void DawnTestEnvironment::SetUp() {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
bool DawnTestEnvironment::UseWire() const {
|
||||
bool DawnTestEnvironment::UsesWire() const {
|
||||
return mUseWire;
|
||||
}
|
||||
|
||||
@@ -266,6 +266,10 @@ bool DawnTest::IsMacOS() const {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DawnTest::UsesWire() const {
|
||||
return gTestEnv->UsesWire();
|
||||
}
|
||||
|
||||
void DawnTest::SetUp() {
|
||||
// Get an adapter for the backend to use, and create the device.
|
||||
dawn_native::Adapter backendAdapter;
|
||||
@@ -314,7 +318,7 @@ void DawnTest::SetUp() {
|
||||
DawnDevice cDevice = nullptr;
|
||||
DawnProcTable procs;
|
||||
|
||||
if (gTestEnv->UseWire()) {
|
||||
if (gTestEnv->UsesWire()) {
|
||||
mC2sBuf = std::make_unique<utils::TerribleCommandBuffer>();
|
||||
mS2cBuf = std::make_unique<utils::TerribleCommandBuffer>();
|
||||
|
||||
@@ -473,7 +477,7 @@ void DawnTest::SwapBuffersForCapture() {
|
||||
}
|
||||
|
||||
void DawnTest::FlushWire() {
|
||||
if (gTestEnv->UseWire()) {
|
||||
if (gTestEnv->UsesWire()) {
|
||||
bool C2SFlushed = mC2sBuf->Flush();
|
||||
bool S2CFlushed = mS2cBuf->Flush();
|
||||
ASSERT(C2SFlushed);
|
||||
|
||||
@@ -106,7 +106,7 @@ class DawnTestEnvironment : public testing::Environment {
|
||||
|
||||
void SetUp() override;
|
||||
|
||||
bool UseWire() const;
|
||||
bool UsesWire() const;
|
||||
dawn_native::Instance* GetInstance() const;
|
||||
GLFWwindow* GetWindowForBackend(dawn_native::BackendType type) const;
|
||||
|
||||
@@ -146,6 +146,8 @@ class DawnTest : public ::testing::TestWithParam<DawnTestParam> {
|
||||
bool IsLinux() const;
|
||||
bool IsMacOS() const;
|
||||
|
||||
bool UsesWire() const;
|
||||
|
||||
void StartExpectDeviceError();
|
||||
bool EndExpectDeviceError();
|
||||
|
||||
|
||||
51
src/tests/end2end/ObjectCachingTests.cpp
Normal file
51
src/tests/end2end/ObjectCachingTests.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// 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/DawnHelpers.h"
|
||||
|
||||
class ObjectCachingTest : public DawnTest {};
|
||||
|
||||
// Test that BindGroupLayouts are correctly deduplicated.
|
||||
TEST_P(ObjectCachingTest, BindGroupLayoutDeduplication) {
|
||||
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device, {{1, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}});
|
||||
dawn::BindGroupLayout sameBgl = utils::MakeBindGroupLayout(
|
||||
device, {{1, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}});
|
||||
dawn::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
|
||||
device, {{1, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer}});
|
||||
|
||||
EXPECT_NE(bgl.Get(), otherBgl.Get());
|
||||
EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire());
|
||||
}
|
||||
|
||||
// Test that PipelineLayouts are correctly deduplicated.
|
||||
TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
|
||||
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device, {{1, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}});
|
||||
dawn::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
|
||||
device, {{1, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer}});
|
||||
|
||||
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||
dawn::PipelineLayout samePl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||
dawn::PipelineLayout otherPl1 = utils::MakeBasicPipelineLayout(device, nullptr);
|
||||
dawn::PipelineLayout otherPl2 = utils::MakeBasicPipelineLayout(device, &otherBgl);
|
||||
|
||||
EXPECT_NE(pl.Get(), otherPl1.Get());
|
||||
EXPECT_NE(pl.Get(), otherPl2.Get());
|
||||
EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire());
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(ObjectCachingTest, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);
|
||||
Reference in New Issue
Block a user