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