dawn_native: don't uncache error objects

Error objects that are cached still have mIsBlueprint to false and would
try to uncache themselves, which isn't valid.

Also adds a regression test.

BUG=dawn:143

Change-Id: Icd8bab52982b8520519d52296fffa6ed85088b8e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6900
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2019-05-01 15:49:07 +00:00 committed by Commit Bot service account
parent 1152bbaf8e
commit 00f6b1af41
5 changed files with 12 additions and 8 deletions

View File

@ -98,8 +98,7 @@ namespace dawn_native {
BindGroupLayoutBase::~BindGroupLayoutBase() {
// Do not uncache the actual cached object if we are a blueprint
if (!mIsBlueprint) {
ASSERT(!IsError());
if (!mIsBlueprint && !IsError()) {
GetDevice()->UncacheBindGroupLayout(this);
}
}

View File

@ -49,8 +49,7 @@ namespace dawn_native {
ComputePipelineBase::~ComputePipelineBase() {
// Do not uncache the actual cached object if we are a blueprint
if (!mIsBlueprint) {
ASSERT(!IsError());
if (!mIsBlueprint && !IsError()) {
GetDevice()->UncacheComputePipeline(this);
}
}

View File

@ -57,8 +57,7 @@ namespace dawn_native {
PipelineLayoutBase::~PipelineLayoutBase() {
// Do not uncache the actual cached object if we are a blueprint
if (!mIsBlueprint) {
ASSERT(!IsError());
if (!mIsBlueprint && !IsError()) {
GetDevice()->UncachePipelineLayout(this);
}
}

View File

@ -82,8 +82,7 @@ namespace dawn_native {
ShaderModuleBase::~ShaderModuleBase() {
// Do not uncache the actual cached object if we are a blueprint
if (!mIsBlueprint) {
ASSERT(!IsError());
if (!mIsBlueprint && !IsError()) {
GetDevice()->UncacheShaderModule(this);
}
}

View File

@ -31,6 +31,14 @@ TEST_P(ObjectCachingTest, BindGroupLayoutDeduplication) {
EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire());
}
// Test that an error object doesn't try to uncache itself
TEST_P(ObjectCachingTest, ErrorObjectDoesntUncache) {
ASSERT_DEVICE_ERROR(
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer},
{0, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer}}));
}
// Test that PipelineLayouts are correctly deduplicated.
TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(