mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-03 13:11:34 +00:00
RefBase: remove implicit conversion to bool.
This helps push for comparing against nullptr more consistently. Also replaces .Get() == nullptr and .Get() != nullptr with just == nullptr and != nullptr. Bug: dawn:89 Change-Id: I884a4819f97305a73c11bad84391d1d2113ab7e2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32922 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
a0758a1aef
commit
55f251dffe
@ -134,10 +134,6 @@ class RefBase {
|
||||
return mValue != other;
|
||||
}
|
||||
|
||||
operator bool() {
|
||||
return mValue != kNullValue;
|
||||
}
|
||||
|
||||
const T operator->() const {
|
||||
return mValue;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ namespace dawn_native {
|
||||
// next loop iteration.
|
||||
|
||||
if (entry.buffer != nullptr) {
|
||||
ASSERT(mBindingData.bindings[bindingIndex].Get() == nullptr);
|
||||
ASSERT(mBindingData.bindings[bindingIndex] == nullptr);
|
||||
mBindingData.bindings[bindingIndex] = entry.buffer;
|
||||
mBindingData.bufferData[bindingIndex].offset = entry.offset;
|
||||
uint64_t bufferSize = (entry.size == wgpu::kWholeSize)
|
||||
@ -289,13 +289,13 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
if (entry.textureView != nullptr) {
|
||||
ASSERT(mBindingData.bindings[bindingIndex].Get() == nullptr);
|
||||
ASSERT(mBindingData.bindings[bindingIndex] == nullptr);
|
||||
mBindingData.bindings[bindingIndex] = entry.textureView;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.sampler != nullptr) {
|
||||
ASSERT(mBindingData.bindings[bindingIndex].Get() == nullptr);
|
||||
ASSERT(mBindingData.bindings[bindingIndex] == nullptr);
|
||||
mBindingData.bindings[bindingIndex] = entry.sampler;
|
||||
continue;
|
||||
}
|
||||
@ -313,7 +313,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
BindGroupBase::~BindGroupBase() {
|
||||
if (mLayout) {
|
||||
if (mLayout != nullptr) {
|
||||
ASSERT(!IsError());
|
||||
for (BindingIndex i{0}; i < mLayout->GetBindingCount(); ++i) {
|
||||
mBindingData.bindings[i].~Ref<ObjectBase>();
|
||||
|
@ -89,7 +89,7 @@ namespace dawn_native {
|
||||
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
auto& attachmentInfo = renderPass->colorAttachments[i];
|
||||
TextureViewBase* view = attachmentInfo.view.Get();
|
||||
bool hasResolveTarget = attachmentInfo.resolveTarget.Get() != nullptr;
|
||||
bool hasResolveTarget = attachmentInfo.resolveTarget != nullptr;
|
||||
|
||||
ASSERT(view->GetLayerCount() == 1);
|
||||
ASSERT(view->GetLevelCount() == 1);
|
||||
|
@ -190,7 +190,7 @@ namespace dawn_native {
|
||||
mState = State::Disconnected;
|
||||
|
||||
// mCurrentErrorScope can be null if we failed device initialization.
|
||||
if (mCurrentErrorScope.Get() != nullptr) {
|
||||
if (mCurrentErrorScope != nullptr) {
|
||||
mCurrentErrorScope->UnlinkForShutdown();
|
||||
}
|
||||
mErrorScopeTracker = nullptr;
|
||||
@ -295,7 +295,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
ErrorScope* DeviceBase::GetCurrentErrorScope() {
|
||||
ASSERT(mCurrentErrorScope.Get() != nullptr);
|
||||
ASSERT(mCurrentErrorScope != nullptr);
|
||||
return mCurrentErrorScope.Get();
|
||||
}
|
||||
|
||||
@ -459,7 +459,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
BindGroupLayoutBase* DeviceBase::GetEmptyBindGroupLayout() {
|
||||
ASSERT(mEmptyBindGroupLayout);
|
||||
ASSERT(mEmptyBindGroupLayout != nullptr);
|
||||
return mEmptyBindGroupLayout.Get();
|
||||
}
|
||||
|
||||
@ -639,7 +639,7 @@ namespace dawn_native {
|
||||
BufferBase* DeviceBase::CreateBuffer(const BufferDescriptor* descriptor) {
|
||||
Ref<BufferBase> result = nullptr;
|
||||
if (ConsumedError(CreateBufferInternal(descriptor), &result)) {
|
||||
ASSERT(result.Get() == nullptr);
|
||||
ASSERT(result == nullptr);
|
||||
return BufferBase::MakeError(this, descriptor);
|
||||
}
|
||||
|
||||
@ -837,7 +837,7 @@ namespace dawn_native {
|
||||
|
||||
QueueBase* DeviceBase::GetDefaultQueue() {
|
||||
// Backends gave the default queue during initialization.
|
||||
ASSERT(mDefaultQueue.Get() != nullptr);
|
||||
ASSERT(mDefaultQueue != nullptr);
|
||||
|
||||
// Returns a new reference to the queue.
|
||||
mDefaultQueue->Reference();
|
||||
|
@ -23,7 +23,7 @@ namespace dawn_native {
|
||||
|
||||
ErrorScope::ErrorScope(wgpu::ErrorFilter errorFilter, ErrorScope* parent)
|
||||
: RefCounted(), mErrorFilter(errorFilter), mParent(parent), mIsRoot(false) {
|
||||
ASSERT(mParent.Get() != nullptr);
|
||||
ASSERT(mParent != nullptr);
|
||||
}
|
||||
|
||||
ErrorScope::~ErrorScope() {
|
||||
@ -124,9 +124,9 @@ namespace dawn_native {
|
||||
Ref<ErrorScope> parentScope = nullptr;
|
||||
for (; !currentScope->IsRoot(); currentScope = parentScope.Get()) {
|
||||
ASSERT(!currentScope->IsRoot());
|
||||
ASSERT(currentScope.Get() != nullptr);
|
||||
ASSERT(currentScope != nullptr);
|
||||
parentScope = std::move(currentScope->mParent);
|
||||
ASSERT(parentScope.Get() != nullptr);
|
||||
ASSERT(parentScope != nullptr);
|
||||
|
||||
// On shutdown, error scopes that have yet to have a status get Unknown.
|
||||
if (currentScope->mErrorType == wgpu::ErrorType::NoError) {
|
||||
|
@ -167,7 +167,7 @@ namespace dawn_native {
|
||||
ASSERT(!IsError());
|
||||
|
||||
// Return the same current texture view until Present is called.
|
||||
if (mCurrentTextureView.Get() != nullptr) {
|
||||
if (mCurrentTextureView != nullptr) {
|
||||
// Calling GetCurrentTextureView always returns a new reference so add it even when
|
||||
// reuse the existing texture view.
|
||||
mCurrentTextureView->Reference();
|
||||
@ -247,7 +247,7 @@ namespace dawn_native {
|
||||
DAWN_TRY(GetDevice()->ValidateIsAlive());
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
|
||||
if (mCurrentTextureView.Get() == nullptr) {
|
||||
if (mCurrentTextureView == nullptr) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"Cannot call present without a GetCurrentTextureView call for this frame");
|
||||
}
|
||||
@ -271,7 +271,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
NewSwapChainBase::~NewSwapChainBase() {
|
||||
if (mCurrentTextureView.Get() != nullptr) {
|
||||
if (mCurrentTextureView != nullptr) {
|
||||
ASSERT(mCurrentTextureView->GetTexture()->GetTextureState() ==
|
||||
TextureBase::TextureState::Destroyed);
|
||||
}
|
||||
@ -304,7 +304,7 @@ namespace dawn_native {
|
||||
return TextureViewBase::MakeError(GetDevice());
|
||||
}
|
||||
|
||||
if (mCurrentTextureView.Get() != nullptr) {
|
||||
if (mCurrentTextureView != nullptr) {
|
||||
// Calling GetCurrentTextureView always returns a new reference so add it even when
|
||||
// reusing the existing texture view.
|
||||
mCurrentTextureView->Reference();
|
||||
@ -384,7 +384,7 @@ namespace dawn_native {
|
||||
return DAWN_VALIDATION_ERROR("Presenting on detached swapchain");
|
||||
}
|
||||
|
||||
if (mCurrentTextureView.Get() == nullptr) {
|
||||
if (mCurrentTextureView == nullptr) {
|
||||
return DAWN_VALIDATION_ERROR("Presenting without prior GetCurrentTextureView");
|
||||
}
|
||||
|
||||
|
@ -182,13 +182,13 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE BindGroup::GetBaseSamplerDescriptor() const {
|
||||
ASSERT(mSamplerAllocationEntry.Get() != nullptr);
|
||||
ASSERT(mSamplerAllocationEntry != nullptr);
|
||||
return mSamplerAllocationEntry->GetBaseDescriptor();
|
||||
}
|
||||
|
||||
bool BindGroup::PopulateSamplers(Device* device,
|
||||
ShaderVisibleDescriptorAllocator* samplerAllocator) {
|
||||
if (mSamplerAllocationEntry.Get() == nullptr) {
|
||||
if (mSamplerAllocationEntry == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return mSamplerAllocationEntry->Populate(device, samplerAllocator);
|
||||
|
@ -1102,7 +1102,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
i, attachmentInfo.loadOp, attachmentInfo.clearColor, view->GetD3D12Format());
|
||||
|
||||
// Set color store operation.
|
||||
if (attachmentInfo.resolveTarget.Get() != nullptr) {
|
||||
if (attachmentInfo.resolveTarget != nullptr) {
|
||||
TextureView* resolveDestinationView = ToBackend(attachmentInfo.resolveTarget.Get());
|
||||
Texture* resolveDestinationTexture =
|
||||
ToBackend(resolveDestinationView->GetTexture());
|
||||
|
@ -102,7 +102,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
// the device before calling.
|
||||
ID3D12GraphicsCommandList4* CommandRecordingContext::GetCommandList4() const {
|
||||
ASSERT(IsOpen());
|
||||
ASSERT(mD3d12CommandList.Get() != nullptr);
|
||||
ASSERT(mD3d12CommandList != nullptr);
|
||||
return mD3d12CommandList4.Get();
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace dawn_native { namespace metal {
|
||||
descriptor.colorAttachments[i].level = attachmentInfo.view->GetBaseMipLevel();
|
||||
descriptor.colorAttachments[i].slice = attachmentInfo.view->GetBaseArrayLayer();
|
||||
|
||||
bool hasResolveTarget = attachmentInfo.resolveTarget.Get() != nullptr;
|
||||
bool hasResolveTarget = attachmentInfo.resolveTarget != nullptr;
|
||||
|
||||
switch (attachmentInfo.storeOp) {
|
||||
case wgpu::StoreOp::Store:
|
||||
|
@ -133,9 +133,9 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
|
||||
void SwapChain::DetachFromSurfaceImpl() {
|
||||
ASSERT((mTexture.Get() == nullptr) == (mCurrentDrawable == nullptr));
|
||||
ASSERT((mTexture == nullptr) == (mCurrentDrawable == nullptr));
|
||||
|
||||
if (mTexture.Get() != nullptr) {
|
||||
if (mTexture != nullptr) {
|
||||
mTexture->Destroy();
|
||||
mTexture = nullptr;
|
||||
|
||||
|
@ -387,7 +387,7 @@ namespace dawn_native { namespace null {
|
||||
}
|
||||
|
||||
void SwapChain::DetachFromSurfaceImpl() {
|
||||
if (mTexture.Get() != nullptr) {
|
||||
if (mTexture != nullptr) {
|
||||
mTexture->Destroy();
|
||||
mTexture = nullptr;
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
for (ColorAttachmentIndex i :
|
||||
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
if (renderPass->colorAttachments[i].resolveTarget.Get() != nullptr) {
|
||||
if (renderPass->colorAttachments[i].resolveTarget != nullptr) {
|
||||
if (readFbo == 0) {
|
||||
ASSERT(writeFbo == 0);
|
||||
gl.GenFramebuffers(1, &readFbo);
|
||||
|
@ -273,7 +273,7 @@ namespace dawn_native { namespace vulkan {
|
||||
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
const auto& attachmentInfo = renderPass->colorAttachments[i];
|
||||
|
||||
bool hasResolveTarget = attachmentInfo.resolveTarget.Get() != nullptr;
|
||||
bool hasResolveTarget = attachmentInfo.resolveTarget != nullptr;
|
||||
wgpu::LoadOp loadOp = attachmentInfo.loadOp;
|
||||
|
||||
query.SetColor(i, attachmentInfo.view->GetFormat().format, loadOp,
|
||||
@ -355,7 +355,7 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
for (ColorAttachmentIndex i :
|
||||
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
if (renderPass->colorAttachments[i].resolveTarget.Get() != nullptr) {
|
||||
if (renderPass->colorAttachments[i].resolveTarget != nullptr) {
|
||||
TextureView* view =
|
||||
ToBackend(renderPass->colorAttachments[i].resolveTarget.Get());
|
||||
|
||||
|
@ -26,8 +26,9 @@ namespace dawn_native { namespace vulkan {
|
||||
ResultOrError<ShaderModule*> ShaderModule::Create(Device* device,
|
||||
const ShaderModuleDescriptor* descriptor) {
|
||||
Ref<ShaderModule> module = AcquireRef(new ShaderModule(device, descriptor));
|
||||
if (!module)
|
||||
if (module == nullptr) {
|
||||
return DAWN_VALIDATION_ERROR("Unable to create ShaderModule");
|
||||
}
|
||||
DAWN_TRY(module->Initialize());
|
||||
return module.Detach();
|
||||
}
|
||||
|
@ -602,12 +602,12 @@ namespace dawn_native { namespace vulkan {
|
||||
}
|
||||
|
||||
void SwapChain::DetachFromSurfaceImpl() {
|
||||
if (mTexture) {
|
||||
if (mTexture != nullptr) {
|
||||
mTexture->Destroy();
|
||||
mTexture = nullptr;
|
||||
}
|
||||
|
||||
if (mBlitTexture) {
|
||||
if (mBlitTexture != nullptr) {
|
||||
mBlitTexture->Destroy();
|
||||
mBlitTexture = nullptr;
|
||||
}
|
||||
|
@ -129,17 +129,6 @@ TEST(Ref, DefaultsToNull) {
|
||||
EXPECT_EQ(test->GetThis(), nullptr);
|
||||
}
|
||||
|
||||
// Test Refs can be used inside ifs
|
||||
TEST(Ref, BoolConversion) {
|
||||
Ref<RCTest> empty;
|
||||
Ref<RCTest> full(new RCTest);
|
||||
full->Release();
|
||||
|
||||
if (!full || empty) {
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Test Ref's copy constructor
|
||||
TEST(Ref, CopyConstructor) {
|
||||
bool deleted = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user