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.
|
// alive.
|
||||||
mState = State::Alive;
|
mState = State::Alive;
|
||||||
|
|
||||||
|
DAWN_TRY_ASSIGN(mEmptyBindGroupLayout, CreateEmptyBindGroupLayout());
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,21 +392,22 @@ namespace dawn_native {
|
||||||
return mFormatTable[index];
|
return mFormatTable[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<BindGroupLayoutBase*> DeviceBase::GetOrCreateBindGroupLayout(
|
ResultOrError<Ref<BindGroupLayoutBase>> DeviceBase::GetOrCreateBindGroupLayout(
|
||||||
const BindGroupLayoutDescriptor* descriptor) {
|
const BindGroupLayoutDescriptor* descriptor) {
|
||||||
BindGroupLayoutBase blueprint(this, descriptor);
|
BindGroupLayoutBase blueprint(this, descriptor);
|
||||||
|
|
||||||
|
Ref<BindGroupLayoutBase> result = nullptr;
|
||||||
auto iter = mCaches->bindGroupLayouts.find(&blueprint);
|
auto iter = mCaches->bindGroupLayouts.find(&blueprint);
|
||||||
if (iter != mCaches->bindGroupLayouts.end()) {
|
if (iter != mCaches->bindGroupLayouts.end()) {
|
||||||
(*iter)->Reference();
|
result = *iter;
|
||||||
return *iter;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
BindGroupLayoutBase* backendObj;
|
BindGroupLayoutBase* backendObj;
|
||||||
DAWN_TRY_ASSIGN(backendObj, CreateBindGroupLayoutImpl(descriptor));
|
DAWN_TRY_ASSIGN(backendObj, CreateBindGroupLayoutImpl(descriptor));
|
||||||
backendObj->SetIsCachedReference();
|
backendObj->SetIsCachedReference();
|
||||||
mCaches->bindGroupLayouts.insert(backendObj);
|
mCaches->bindGroupLayouts.insert(backendObj);
|
||||||
return backendObj;
|
result = AcquireRef(backendObj);
|
||||||
|
}
|
||||||
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::UncacheBindGroupLayout(BindGroupLayoutBase* obj) {
|
void DeviceBase::UncacheBindGroupLayout(BindGroupLayoutBase* obj) {
|
||||||
|
@ -413,23 +416,19 @@ namespace dawn_native {
|
||||||
ASSERT(removedCount == 1);
|
ASSERT(removedCount == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<BindGroupLayoutBase*> DeviceBase::GetOrCreateEmptyBindGroupLayout() {
|
// Private function used at initialization
|
||||||
if (!mEmptyBindGroupLayout) {
|
ResultOrError<Ref<BindGroupLayoutBase>> DeviceBase::CreateEmptyBindGroupLayout() {
|
||||||
BindGroupLayoutDescriptor desc = {};
|
BindGroupLayoutDescriptor desc = {};
|
||||||
desc.entryCount = 0;
|
desc.entryCount = 0;
|
||||||
desc.entries = nullptr;
|
desc.entries = nullptr;
|
||||||
|
|
||||||
BindGroupLayoutBase* bgl = nullptr;
|
return GetOrCreateBindGroupLayout(&desc);
|
||||||
if (ConsumedError(GetOrCreateBindGroupLayout(&desc), &bgl)) {
|
|
||||||
return BindGroupLayoutBase::MakeError(this);
|
|
||||||
}
|
}
|
||||||
mEmptyBindGroupLayout = bgl;
|
|
||||||
return bgl;
|
BindGroupLayoutBase* DeviceBase::GetEmptyBindGroupLayout() {
|
||||||
} else {
|
ASSERT(mEmptyBindGroupLayout);
|
||||||
mEmptyBindGroupLayout->Reference();
|
|
||||||
return mEmptyBindGroupLayout.Get();
|
return mEmptyBindGroupLayout.Get();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ResultOrError<ComputePipelineBase*> DeviceBase::GetOrCreateComputePipeline(
|
ResultOrError<ComputePipelineBase*> DeviceBase::GetOrCreateComputePipeline(
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
|
@ -871,7 +870,9 @@ namespace dawn_native {
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor));
|
DAWN_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor));
|
||||||
}
|
}
|
||||||
DAWN_TRY_ASSIGN(*result, GetOrCreateBindGroupLayout(descriptor));
|
Ref<BindGroupLayoutBase> bgl;
|
||||||
|
DAWN_TRY_ASSIGN(bgl, GetOrCreateBindGroupLayout(descriptor));
|
||||||
|
*result = bgl.Detach();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,11 +108,11 @@ namespace dawn_native {
|
||||||
// the created object will be, the "blueprint". The blueprint is just a FooBase object
|
// 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
|
// 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.
|
// cache, then the descriptor is used to make a new object.
|
||||||
ResultOrError<BindGroupLayoutBase*> GetOrCreateBindGroupLayout(
|
ResultOrError<Ref<BindGroupLayoutBase>> GetOrCreateBindGroupLayout(
|
||||||
const BindGroupLayoutDescriptor* descriptor);
|
const BindGroupLayoutDescriptor* descriptor);
|
||||||
void UncacheBindGroupLayout(BindGroupLayoutBase* obj);
|
void UncacheBindGroupLayout(BindGroupLayoutBase* obj);
|
||||||
|
|
||||||
ResultOrError<BindGroupLayoutBase*> GetOrCreateEmptyBindGroupLayout();
|
BindGroupLayoutBase* GetEmptyBindGroupLayout();
|
||||||
|
|
||||||
ResultOrError<ComputePipelineBase*> GetOrCreateComputePipeline(
|
ResultOrError<ComputePipelineBase*> GetOrCreateComputePipeline(
|
||||||
const ComputePipelineDescriptor* descriptor);
|
const ComputePipelineDescriptor* descriptor);
|
||||||
|
@ -266,6 +266,8 @@ namespace dawn_native {
|
||||||
TextureBase* texture,
|
TextureBase* texture,
|
||||||
const TextureViewDescriptor* descriptor) = 0;
|
const TextureViewDescriptor* descriptor) = 0;
|
||||||
|
|
||||||
|
ResultOrError<Ref<BindGroupLayoutBase>> CreateEmptyBindGroupLayout();
|
||||||
|
|
||||||
MaybeError CreateBindGroupInternal(BindGroupBase** result,
|
MaybeError CreateBindGroupInternal(BindGroupBase** result,
|
||||||
const BindGroupDescriptor* descriptor);
|
const BindGroupDescriptor* descriptor);
|
||||||
MaybeError CreateBindGroupLayoutInternal(BindGroupLayoutBase** result,
|
MaybeError CreateBindGroupLayoutInternal(BindGroupLayoutBase** result,
|
||||||
|
|
|
@ -92,15 +92,12 @@ namespace dawn_native {
|
||||||
|
|
||||||
BindGroupIndex groupIndex(groupIndexIn);
|
BindGroupIndex groupIndex(groupIndexIn);
|
||||||
|
|
||||||
if (!mLayout->GetBindGroupLayoutsMask()[groupIndex]) {
|
|
||||||
BindGroupLayoutBase* bgl = nullptr;
|
BindGroupLayoutBase* bgl = nullptr;
|
||||||
if (GetDevice()->ConsumedError(GetDevice()->GetOrCreateEmptyBindGroupLayout(), &bgl)) {
|
if (!mLayout->GetBindGroupLayoutsMask()[groupIndex]) {
|
||||||
return BindGroupLayoutBase::MakeError(GetDevice());
|
bgl = GetDevice()->GetEmptyBindGroupLayout();
|
||||||
|
} else {
|
||||||
|
bgl = mLayout->GetBindGroupLayout(groupIndex);
|
||||||
}
|
}
|
||||||
return bgl;
|
|
||||||
}
|
|
||||||
|
|
||||||
BindGroupLayoutBase* bgl = mLayout->GetBindGroupLayout(groupIndex);
|
|
||||||
bgl->Reference();
|
bgl->Reference();
|
||||||
return bgl;
|
return bgl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,7 +222,10 @@ namespace dawn_native {
|
||||||
|
|
||||||
// We should never produce a bad descriptor.
|
// We should never produce a bad descriptor.
|
||||||
ASSERT(!ValidateBindGroupLayoutDescriptor(device, &desc).IsError());
|
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 = {};
|
PipelineLayoutDescriptor desc = {};
|
||||||
|
|
Loading…
Reference in New Issue