Changing pointers to Ref<> in GetOrCreateBGL
DeviceBase::GetOrCreateBindGroupLayout and DeviceBase::GetOrCreateEmptyBindGroupLayout are now returning ResultOrError<Ref<BindGroupLayoutBase>> instead of ResultOrError<BindGroupLayoutBase*>. Bug: dawn:466 Change-Id: I223864325aba9011b0ba6dc67589ead48d930309 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24082 Commit-Queue: Tomek Ponitka <tommek@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
5191adc58c
commit
5fb974cf47
|
@ -112,6 +112,8 @@ namespace dawn_native {
|
|||
// alive.
|
||||
mState = State::Alive;
|
||||
|
||||
DAWN_TRY_ASSIGN(mEmptyBindGroupLayout, CreateEmptyBindGroupLayout());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -390,21 +392,22 @@ namespace dawn_native {
|
|||
return mFormatTable[index];
|
||||
}
|
||||
|
||||
ResultOrError<BindGroupLayoutBase*> DeviceBase::GetOrCreateBindGroupLayout(
|
||||
ResultOrError<Ref<BindGroupLayoutBase>> DeviceBase::GetOrCreateBindGroupLayout(
|
||||
const BindGroupLayoutDescriptor* descriptor) {
|
||||
BindGroupLayoutBase blueprint(this, descriptor);
|
||||
|
||||
Ref<BindGroupLayoutBase> result = nullptr;
|
||||
auto iter = mCaches->bindGroupLayouts.find(&blueprint);
|
||||
if (iter != mCaches->bindGroupLayouts.end()) {
|
||||
(*iter)->Reference();
|
||||
return *iter;
|
||||
result = *iter;
|
||||
} else {
|
||||
BindGroupLayoutBase* backendObj;
|
||||
DAWN_TRY_ASSIGN(backendObj, CreateBindGroupLayoutImpl(descriptor));
|
||||
backendObj->SetIsCachedReference();
|
||||
mCaches->bindGroupLayouts.insert(backendObj);
|
||||
result = AcquireRef(backendObj);
|
||||
}
|
||||
|
||||
BindGroupLayoutBase* backendObj;
|
||||
DAWN_TRY_ASSIGN(backendObj, CreateBindGroupLayoutImpl(descriptor));
|
||||
backendObj->SetIsCachedReference();
|
||||
mCaches->bindGroupLayouts.insert(backendObj);
|
||||
return backendObj;
|
||||
return std::move(result);
|
||||
}
|
||||
|
||||
void DeviceBase::UncacheBindGroupLayout(BindGroupLayoutBase* obj) {
|
||||
|
@ -413,22 +416,18 @@ namespace dawn_native {
|
|||
ASSERT(removedCount == 1);
|
||||
}
|
||||
|
||||
ResultOrError<BindGroupLayoutBase*> DeviceBase::GetOrCreateEmptyBindGroupLayout() {
|
||||
if (!mEmptyBindGroupLayout) {
|
||||
BindGroupLayoutDescriptor desc = {};
|
||||
desc.entryCount = 0;
|
||||
desc.entries = nullptr;
|
||||
// Private function used at initialization
|
||||
ResultOrError<Ref<BindGroupLayoutBase>> DeviceBase::CreateEmptyBindGroupLayout() {
|
||||
BindGroupLayoutDescriptor desc = {};
|
||||
desc.entryCount = 0;
|
||||
desc.entries = nullptr;
|
||||
|
||||
BindGroupLayoutBase* bgl = nullptr;
|
||||
if (ConsumedError(GetOrCreateBindGroupLayout(&desc), &bgl)) {
|
||||
return BindGroupLayoutBase::MakeError(this);
|
||||
}
|
||||
mEmptyBindGroupLayout = bgl;
|
||||
return bgl;
|
||||
} else {
|
||||
mEmptyBindGroupLayout->Reference();
|
||||
return mEmptyBindGroupLayout.Get();
|
||||
}
|
||||
return GetOrCreateBindGroupLayout(&desc);
|
||||
}
|
||||
|
||||
BindGroupLayoutBase* DeviceBase::GetEmptyBindGroupLayout() {
|
||||
ASSERT(mEmptyBindGroupLayout);
|
||||
return mEmptyBindGroupLayout.Get();
|
||||
}
|
||||
|
||||
ResultOrError<ComputePipelineBase*> DeviceBase::GetOrCreateComputePipeline(
|
||||
|
@ -871,7 +870,9 @@ namespace dawn_native {
|
|||
if (IsValidationEnabled()) {
|
||||
DAWN_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor));
|
||||
}
|
||||
DAWN_TRY_ASSIGN(*result, GetOrCreateBindGroupLayout(descriptor));
|
||||
Ref<BindGroupLayoutBase> bgl;
|
||||
DAWN_TRY_ASSIGN(bgl, GetOrCreateBindGroupLayout(descriptor));
|
||||
*result = bgl.Detach();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -108,11 +108,11 @@ namespace dawn_native {
|
|||
// the created object will be, the "blueprint". The blueprint is just a FooBase object
|
||||
// instead of a backend Foo object. If the blueprint doesn't match an object in the
|
||||
// cache, then the descriptor is used to make a new object.
|
||||
ResultOrError<BindGroupLayoutBase*> GetOrCreateBindGroupLayout(
|
||||
ResultOrError<Ref<BindGroupLayoutBase>> GetOrCreateBindGroupLayout(
|
||||
const BindGroupLayoutDescriptor* descriptor);
|
||||
void UncacheBindGroupLayout(BindGroupLayoutBase* obj);
|
||||
|
||||
ResultOrError<BindGroupLayoutBase*> GetOrCreateEmptyBindGroupLayout();
|
||||
BindGroupLayoutBase* GetEmptyBindGroupLayout();
|
||||
|
||||
ResultOrError<ComputePipelineBase*> GetOrCreateComputePipeline(
|
||||
const ComputePipelineDescriptor* descriptor);
|
||||
|
@ -266,6 +266,8 @@ namespace dawn_native {
|
|||
TextureBase* texture,
|
||||
const TextureViewDescriptor* descriptor) = 0;
|
||||
|
||||
ResultOrError<Ref<BindGroupLayoutBase>> CreateEmptyBindGroupLayout();
|
||||
|
||||
MaybeError CreateBindGroupInternal(BindGroupBase** result,
|
||||
const BindGroupDescriptor* descriptor);
|
||||
MaybeError CreateBindGroupLayoutInternal(BindGroupLayoutBase** result,
|
||||
|
|
|
@ -92,15 +92,12 @@ namespace dawn_native {
|
|||
|
||||
BindGroupIndex groupIndex(groupIndexIn);
|
||||
|
||||
BindGroupLayoutBase* bgl = nullptr;
|
||||
if (!mLayout->GetBindGroupLayoutsMask()[groupIndex]) {
|
||||
BindGroupLayoutBase* bgl = nullptr;
|
||||
if (GetDevice()->ConsumedError(GetDevice()->GetOrCreateEmptyBindGroupLayout(), &bgl)) {
|
||||
return BindGroupLayoutBase::MakeError(GetDevice());
|
||||
}
|
||||
return bgl;
|
||||
bgl = GetDevice()->GetEmptyBindGroupLayout();
|
||||
} else {
|
||||
bgl = mLayout->GetBindGroupLayout(groupIndex);
|
||||
}
|
||||
|
||||
BindGroupLayoutBase* bgl = mLayout->GetBindGroupLayout(groupIndex);
|
||||
bgl->Reference();
|
||||
return bgl;
|
||||
}
|
||||
|
|
|
@ -222,7 +222,10 @@ namespace dawn_native {
|
|||
|
||||
// We should never produce a bad descriptor.
|
||||
ASSERT(!ValidateBindGroupLayoutDescriptor(device, &desc).IsError());
|
||||
DAWN_TRY_ASSIGN(bindGroupLayouts[group], device->GetOrCreateBindGroupLayout(&desc));
|
||||
|
||||
Ref<BindGroupLayoutBase> bgl;
|
||||
DAWN_TRY_ASSIGN(bgl, device->GetOrCreateBindGroupLayout(&desc));
|
||||
bindGroupLayouts[group] = bgl.Detach();
|
||||
}
|
||||
|
||||
PipelineLayoutDescriptor desc = {};
|
||||
|
|
Loading…
Reference in New Issue