[dawn] Assert to Check for simple expressions This is part 2 of original change. This change is for the backend. Documentation: docs/dawn/asserts-vs-check.md Bug: 442860471 Change-Id: Ie13463766a562efc99c589422e31144597aa962a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/304815 Commit-Queue: Peter McNeeley <petermcneeley@google.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org>
diff --git a/src/dawn/native/d3d12/BackendD3D12.cpp b/src/dawn/native/d3d12/BackendD3D12.cpp index 005fa02..d2348ce 100644 --- a/src/dawn/native/d3d12/BackendD3D12.cpp +++ b/src/dawn/native/d3d12/BackendD3D12.cpp
@@ -119,17 +119,17 @@ } ComPtr<IDxcLibrary> Backend::GetDxcLibrary() const { - DAWN_ASSERT(mDxcLibrary != nullptr); + DAWN_CHECK(mDxcLibrary != nullptr); return mDxcLibrary; } ComPtr<IDxcCompiler3> Backend::GetDxcCompiler() const { - DAWN_ASSERT(mDxcCompiler != nullptr); + DAWN_CHECK(mDxcCompiler != nullptr); return mDxcCompiler; } ComPtr<IDxcValidator> Backend::GetDxcValidator() const { - DAWN_ASSERT(mDxcValidator != nullptr); + DAWN_CHECK(mDxcValidator != nullptr); return mDxcValidator; }
diff --git a/src/dawn/native/d3d12/CommandBufferD3D12.cpp b/src/dawn/native/d3d12/CommandBufferD3D12.cpp index 28f9822..f613efc 100644 --- a/src/dawn/native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn/native/d3d12/CommandBufferD3D12.cpp
@@ -88,9 +88,9 @@ const TextureCopy& dst, const TexelExtent3D& copySize) { // Checked by validation - DAWN_ASSERT(src.texture->GetSampleCount() == dst.texture->GetSampleCount()); - DAWN_ASSERT(src.texture->GetFormat().CopyCompatibleWith(dst.texture->GetFormat())); - DAWN_ASSERT(src.aspect == dst.aspect); + DAWN_CHECK(src.texture->GetSampleCount() == dst.texture->GetSampleCount()); + DAWN_CHECK(src.texture->GetFormat().CopyCompatibleWith(dst.texture->GetFormat())); + DAWN_CHECK(src.aspect == dst.aspect); const TexelExtent3D& srcSize = src.texture->GetSize(src.aspect); const TexelExtent3D& dstSize = dst.texture->GetSize(dst.aspect); @@ -121,7 +121,7 @@ void RecordWriteTimestampCmd(ID3D12GraphicsCommandList* commandList, QuerySetBase* querySet, uint32_t queryIndex) { - DAWN_ASSERT(D3D12QueryType(ToBackend(querySet)->GetQueryType()) == D3D12_QUERY_TYPE_TIMESTAMP); + DAWN_CHECK(D3D12QueryType(ToBackend(querySet)->GetQueryType()) == D3D12_QUERY_TYPE_TIMESTAMP); commandList->EndQuery(ToBackend(querySet)->GetQueryHeap(), D3D12_QUERY_TYPE_TIMESTAMP, queryIndex); } @@ -193,7 +193,7 @@ if (device->IsToggleEnabled( Toggle::UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel)) { bool copyToLesserLevel = srcCopy.mipLevel > dstCopy.mipLevel; - DAWN_ASSERT(srcCopy.texture->GetFormat().CopyCompatibleWith(dstCopy.texture->GetFormat())); + DAWN_CHECK(srcCopy.texture->GetFormat().CopyCompatibleWith(dstCopy.texture->GetFormat())); // GetAspectInfo(aspect) requires HasOneBit(aspect) == true, plus the texel block // sizes of depth stencil formats are always no less than 4 bytes. @@ -212,8 +212,8 @@ const TextureCopy& srcCopy, const TextureCopy& dstCopy, const BlockExtent3D& copySize) { - DAWN_ASSERT(srcCopy.texture->GetFormat().format == dstCopy.texture->GetFormat().format); - DAWN_ASSERT(srcCopy.aspect == dstCopy.aspect); + DAWN_CHECK(srcCopy.texture->GetFormat().format == dstCopy.texture->GetFormat().format); + DAWN_CHECK(srcCopy.aspect == dstCopy.aspect); const TypedTexelBlockInfo& blockInfo = GetBlockInfo(srcCopy); // Create tempBuffer @@ -294,7 +294,7 @@ // D3D12 aligns the entire buffer to at least 64KB, so the virtual address of tempBuffer will // always be aligned to D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT (512). Ref<Buffer> tempBuffer = ToBackend(std::move(tempBufferBase)); - DAWN_ASSERT(tempBuffer->GetVA() % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT == 0); + DAWN_CHECK(tempBuffer->GetVA() % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT == 0); auto scopedUseStaging = tempBuffer->UseInternal(); DAWN_TRY(tempBuffer->EnsureDataInitialized(recordingContext)); @@ -425,7 +425,7 @@ // Calling this after BindGroupTrackerBase::Apply() to update root signature. void Apply(CommandRecordingContext* commandContext) { - DAWN_ASSERT(this->mLastPipeline != nullptr); + DAWN_CHECK(this->mLastPipeline != nullptr); auto* lastPipeline = this->mLastPipeline; ImmediateConstantMask pipelineMask = lastPipeline->GetImmediateMask(); @@ -508,7 +508,7 @@ populatedSamplers = populatedSamplers && group->PopulateSamplers(samplerAllocator); } if (usesResourceTable) { - DAWN_ASSERT(mResourceTable); + DAWN_CHECK(mResourceTable); // We don't track resource table dirtiness like we do for BindGroups, so always call // PopulateViews/Samplers. We also do this after bind groups because resource tables are // more likely to make the largest GPU sub-allocation, so if it returns false, we don't @@ -554,14 +554,14 @@ BindGroup* group = ToBackend(mBindGroups[index]); populatedViews = group->PopulateViews(viewAllocator); populatedSamplers = group->PopulateSamplers(samplerAllocator); - DAWN_ASSERT(populatedViews); - DAWN_ASSERT(populatedSamplers); + DAWN_CHECK(populatedViews); + DAWN_CHECK(populatedSamplers); } if (usesResourceTable) { populatedViews = mResourceTable->PopulateViews(viewAllocator); populatedSamplers = mResourceTable->PopulateSamplers(samplerAllocator); - DAWN_ASSERT(populatedViews); - DAWN_ASSERT(populatedSamplers); + DAWN_CHECK(populatedViews); + DAWN_CHECK(populatedSamplers); } } @@ -681,7 +681,7 @@ void ApplyResourceTable(ID3D12GraphicsCommandList* commandList, const PipelineLayout* pipelineLayout) { - DAWN_ASSERT(mPipelineLayout->UsesResourceTable() && mResourceTable); + DAWN_CHECK(mPipelineLayout->UsesResourceTable() && mResourceTable); // Set the root descriptor table that contains both the metadata buffer and textures/buffers { @@ -705,7 +705,7 @@ BindGroupIndex index, BindGroup* group, const ityp::span<BindingIndex, uint32_t>& dynamicOffsets) { - DAWN_ASSERT(dynamicOffsets.size() == group->GetLayout()->GetDynamicBufferCount()); + DAWN_CHECK(dynamicOffsets.size() == group->GetLayout()->GetDynamicBufferCount()); // Usually, the application won't set the same offsets many times, // so always try to apply dynamic offsets even if the offsets stay the same. @@ -818,12 +818,12 @@ mGraphicsBindingTracker(device, this) {} void SetID3D12DescriptorHeaps(ID3D12GraphicsCommandList* commandList) { - DAWN_ASSERT(commandList != nullptr); + DAWN_CHECK(commandList != nullptr); std::array<ID3D12DescriptorHeap*, 2> descriptorHeaps = { mDevice->GetViewShaderVisibleDescriptorAllocator()->GetShaderVisibleHeap(), mDevice->GetSamplerShaderVisibleDescriptorAllocator()->GetShaderVisibleHeap()}; - DAWN_ASSERT(descriptorHeaps[0] != nullptr); - DAWN_ASSERT(descriptorHeaps[1] != nullptr); + DAWN_CHECK(descriptorHeaps[0] != nullptr); + DAWN_CHECK(descriptorHeaps[1] != nullptr); commandList->SetDescriptorHeaps(static_cast<uint32_t>(descriptorHeaps.size()), descriptorHeaps.data()); @@ -868,7 +868,7 @@ } void Apply(ID3D12GraphicsCommandList* commandList, const RenderPipeline* renderPipeline) { - DAWN_ASSERT(renderPipeline != nullptr); + DAWN_CHECK(renderPipeline != nullptr); VertexBufferSlot startSlot = mStartSlot; VertexBufferSlot endSlot = mEndSlot; @@ -1179,17 +1179,16 @@ // When there are overlapped subresources, the layout of the overlapped // subresources should all be COMMON instead of what we set now. Currently // it is not allowed to copy with overlapped subresources, but we still - // add the DAWN_ASSERT here as a reminder for this possible misuse. - DAWN_ASSERT(!IsRangeOverlapped(copy->source.origin.z, - copy->destination.origin.z, - copy->copySize.depthOrArrayLayers)); + // add the DAWN_CHECK here as a reminder for this possible misuse. + DAWN_CHECK(!IsRangeOverlapped(copy->source.origin.z, copy->destination.origin.z, + copy->copySize.depthOrArrayLayers)); } source->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopySrc, srcRange); destination->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopyDst, dstRange); - DAWN_ASSERT(srcRange.aspects == dstRange.aspects); + DAWN_CHECK(srcRange.aspects == dstRange.aspects); if (ShouldCopyUsingTemporaryBuffer(GetDevice(), copy->source, copy->destination)) { const TypedTexelBlockInfo& blockInfo = GetBlockInfo(copy->destination); DAWN_TRY(RecordCopyTextureWithTemporaryBuffer( @@ -1232,7 +1231,7 @@ case wgpu::TextureDimension::Undefined: DAWN_UNREACHABLE(); case wgpu::TextureDimension::e1D: - DAWN_ASSERT(copy->source.origin.z == TexelCount{0}); + DAWN_CHECK(copy->source.origin.z == TexelCount{0}); break; case wgpu::TextureDimension::e2D: sourceLayer = static_cast<uint32_t>(copy->source.origin.z + z); @@ -1248,7 +1247,7 @@ case wgpu::TextureDimension::Undefined: DAWN_UNREACHABLE(); case wgpu::TextureDimension::e1D: - DAWN_ASSERT(copy->destination.origin.z == TexelCount{0}); + DAWN_CHECK(copy->destination.origin.z == TexelCount{0}); break; case wgpu::TextureDimension::e2D: destinationLayer = @@ -1521,7 +1520,7 @@ case Command::SetImmediates: { SetImmediatesCmd* cmd = mCommands.NextCommand<SetImmediatesCmd>(); - DAWN_ASSERT(cmd->size > 0); + DAWN_CHECK(cmd->size > 0); uint8_t* value = mCommands.NextData<uint8_t>(cmd->size); immediates.SetImmediates(cmd->offset, value, cmd->size); break; @@ -1978,7 +1977,7 @@ case Command::SetImmediates: { SetImmediatesCmd* cmd = iter->NextCommand<SetImmediatesCmd>(); - DAWN_ASSERT(cmd->size > 0); + DAWN_CHECK(cmd->size > 0); uint8_t* value = iter->NextData<uint8_t>(cmd->size); immediates.SetImmediates(cmd->offset, value, cmd->size); break; @@ -2107,8 +2106,8 @@ case Command::BeginOcclusionQuery: { BeginOcclusionQueryCmd* cmd = mCommands.NextCommand<BeginOcclusionQueryCmd>(); QuerySet* querySet = ToBackend(cmd->querySet.Get()); - DAWN_ASSERT(D3D12QueryType(querySet->GetQueryType()) == - D3D12_QUERY_TYPE_BINARY_OCCLUSION); + DAWN_CHECK(D3D12QueryType(querySet->GetQueryType()) == + D3D12_QUERY_TYPE_BINARY_OCCLUSION); commandList->BeginQuery(querySet->GetQueryHeap(), D3D12_QUERY_TYPE_BINARY_OCCLUSION, cmd->queryIndex); break; @@ -2117,8 +2116,8 @@ case Command::EndOcclusionQuery: { EndOcclusionQueryCmd* cmd = mCommands.NextCommand<EndOcclusionQueryCmd>(); QuerySet* querySet = ToBackend(cmd->querySet.Get()); - DAWN_ASSERT(D3D12QueryType(querySet->GetQueryType()) == - D3D12_QUERY_TYPE_BINARY_OCCLUSION); + DAWN_CHECK(D3D12QueryType(querySet->GetQueryType()) == + D3D12_QUERY_TYPE_BINARY_OCCLUSION); commandList->EndQuery(querySet->GetQueryHeap(), D3D12_QUERY_TYPE_BINARY_OCCLUSION, cmd->queryIndex); break;
diff --git a/src/dawn/native/d3d12/CommandRecordingContext.cpp b/src/dawn/native/d3d12/CommandRecordingContext.cpp index 8852016..430a46e 100644 --- a/src/dawn/native/d3d12/CommandRecordingContext.cpp +++ b/src/dawn/native/d3d12/CommandRecordingContext.cpp
@@ -60,7 +60,7 @@ MaybeError CommandRecordingContext::ExecuteCommandList(Device* device, ID3D12CommandQueue* commandQueue) { - DAWN_ASSERT(mD3d12CommandList != nullptr); + DAWN_CHECK(mD3d12CommandList != nullptr); // Make sure to always Release when this call completes. This is especially important for // KeyedMutexes to ensure other users of SharedTextureMemory can rely on them being unlocked @@ -135,19 +135,19 @@ } ID3D12GraphicsCommandList* CommandRecordingContext::GetCommandList() const { - DAWN_ASSERT(mD3d12CommandList != nullptr); + DAWN_CHECK(mD3d12CommandList != nullptr); return mD3d12CommandList.Get(); } ID3D12GraphicsCommandList1* CommandRecordingContext::GetCommandList1() const { - DAWN_ASSERT(mD3d12CommandList != nullptr); + DAWN_CHECK(mD3d12CommandList != nullptr); return mD3d12CommandList1.Get(); } // This function will fail on Windows versions prior to 1809. Support must be queried through // the device before calling. ID3D12GraphicsCommandList4* CommandRecordingContext::GetCommandList4() const { - DAWN_ASSERT(mD3d12CommandList != nullptr); + DAWN_CHECK(mD3d12CommandList != nullptr); return mD3d12CommandList4.Get(); }
diff --git a/src/dawn/native/d3d12/DeviceD3D12.cpp b/src/dawn/native/d3d12/DeviceD3D12.cpp index 02f2b5b..d8416c3 100644 --- a/src/dawn/native/d3d12/DeviceD3D12.cpp +++ b/src/dawn/native/d3d12/DeviceD3D12.cpp
@@ -98,7 +98,7 @@ ComPtr<ID3D12DebugDevice> d3d12DebugDevice; mIsDebugLayerEnabled = SUCCEEDED(mD3d12Device.As(&d3d12DebugDevice)); - DAWN_ASSERT(mD3d12Device != nullptr); + DAWN_CHECK(mD3d12Device != nullptr); Ref<Queue> queue; DAWN_TRY_ASSIGN(queue, Queue::Create(this, &descriptor->defaultQueue)); @@ -244,7 +244,7 @@ ComPtr<ID3D11On12Device> d3d11on12Device; d3d11Device.As(&d3d11on12Device); - DAWN_ASSERT(d3d11on12Device); + DAWN_CHECK(d3d11on12Device); mD3d11On12Device = std::move(d3d11on12Device); } @@ -252,22 +252,22 @@ } void Device::Flush11On12DeviceToAvoidLeaks() { - DAWN_ASSERT(mD3d11On12Device); + DAWN_CHECK(mD3d11On12Device); ComPtr<ID3D11Device> d3d11Device; mD3d11On12Device.As(&d3d11Device); - DAWN_ASSERT(d3d11Device); + DAWN_CHECK(d3d11Device); ComPtr<ID3D11DeviceContext> d3d11DeviceContext; d3d11Device->GetImmediateContext(&d3d11DeviceContext); - DAWN_ASSERT(d3d11DeviceContext); + DAWN_CHECK(d3d11DeviceContext); // 11on12 has a bug where D3D12 resources used only for keyed shared mutexes are not released // until work is submitted to the device context and flushed. The most minimal work we can get // away with is issuing a TiledResourceBarrier. ComPtr<ID3D11DeviceContext2> d3d11DeviceContext2; d3d11DeviceContext.As(&d3d11DeviceContext2); - DAWN_ASSERT(d3d11DeviceContext2); + DAWN_CHECK(d3d11DeviceContext2); d3d11DeviceContext2->TiledResourceBarrier(nullptr, nullptr); d3d11DeviceContext2->Flush(); @@ -683,8 +683,8 @@ void AppendDebugLayerMessagesToError(ID3D12InfoQueue* infoQueue, uint64_t totalErrors, ErrorData* error) { - DAWN_ASSERT(totalErrors > 0); - DAWN_ASSERT(error != nullptr); + DAWN_CHECK(totalErrors > 0); + DAWN_CHECK(error != nullptr); uint64_t errorsToPrint = std::min(kMaxDebugMessagesToPrint, totalErrors); for (uint64_t i = 0; i < errorsToPrint; ++i) { @@ -771,7 +771,7 @@ } void Device::DestroyImpl(DestroyReason reason) { - DAWN_ASSERT(GetState() == State::Disconnected); + DAWN_CHECK(GetState() == State::Disconnected); // TODO(crbug.com/dawn/831): DestroyImpl is called from two places. // - It may be called if the device is explicitly destroyed with APIDestroy. @@ -792,7 +792,7 @@ // We need to handle clearing up com object refs that were enqeued after TickImpl mUsedComObjectRefs->ClearUpTo(std::numeric_limits<ExecutionSerial>::max()); - DAWN_ASSERT(mUsedComObjectRefs->Empty()); + DAWN_CHECK(mUsedComObjectRefs->Empty()); } ShaderVisibleDescriptorAllocator* Device::GetViewShaderVisibleDescriptorAllocator() const { @@ -805,8 +805,8 @@ MutexProtected<StagingDescriptorAllocator>* Device::GetViewStagingDescriptorAllocator( uint32_t descriptorCount) const { - DAWN_ASSERT(descriptorCount <= kMaxViewDescriptorsPerBindGroup); - DAWN_ASSERT(descriptorCount > 0); + DAWN_CHECK(descriptorCount <= kMaxViewDescriptorsPerBindGroup); + DAWN_CHECK(descriptorCount > 0); // This is Log2 of the next power of two, plus 1. uint32_t allocatorIndex = Log2Ceil(descriptorCount) + 1; return mViewAllocators[allocatorIndex].get(); @@ -814,8 +814,8 @@ MutexProtected<StagingDescriptorAllocator>* Device::GetSamplerStagingDescriptorAllocator( uint32_t descriptorCount) const { - DAWN_ASSERT(descriptorCount <= kMaxSamplerDescriptorsPerBindGroup); - DAWN_ASSERT(descriptorCount > 0); + DAWN_CHECK(descriptorCount <= kMaxSamplerDescriptorsPerBindGroup); + DAWN_CHECK(descriptorCount > 0); // This is Log2 of the next power of two, plus 1. uint32_t allocatorIndex = Log2Ceil(descriptorCount) + 1; return mSamplerAllocators[allocatorIndex].get();
diff --git a/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp b/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp index fc93403..1295a7c 100644 --- a/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp +++ b/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp
@@ -306,7 +306,7 @@ // Make sure that we added exactly the number of elements we expected. If we added more, // |ranges| will have resized and the pointers in the |rootParameter|s will be invalid. - DAWN_ASSERT(rangeIndex == rangesCount); + DAWN_CHECK(rangeIndex == rangesCount); D3D12_ROOT_PARAMETER1 renderOrComputeInternalConstants{}; renderOrComputeInternalConstants.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; @@ -352,7 +352,7 @@ dynamicStorageBufferInfoShaderRegisterOffset++}); } } - DAWN_ASSERT(info.bindingAndRegisterOffsets.size() == dynamicStorageBufferCount); + DAWN_CHECK(info.bindingAndRegisterOffsets.size() == dynamicStorageBufferCount); mDynamicStorageBufferInfo[group] = std::move(info); } @@ -469,13 +469,13 @@ } uint32_t PipelineLayout::GetResourceTableCbvUavSrvRootParameterIndex() const { - DAWN_ASSERT(mResourceTableCbvUavSrvRootParameterIndex != - kInvalidResourceTableRootParameterIndex); + DAWN_CHECK(mResourceTableCbvUavSrvRootParameterIndex != + kInvalidResourceTableRootParameterIndex); return mResourceTableCbvUavSrvRootParameterIndex; } uint32_t PipelineLayout::GetResourceTableSamplerRootParameterIndex() const { - DAWN_ASSERT(mResourceTableSamplerRootParameterIndex != kInvalidResourceTableRootParameterIndex); + DAWN_CHECK(mResourceTableSamplerRootParameterIndex != kInvalidResourceTableRootParameterIndex); return mResourceTableSamplerRootParameterIndex; } @@ -484,12 +484,12 @@ } uint32_t PipelineLayout::GetCbvUavSrvRootParameterIndex(BindGroupIndex group) const { - DAWN_ASSERT(group < kMaxBindGroupsTyped); + DAWN_CHECK(group < kMaxBindGroupsTyped); return mCbvUavSrvRootParameterIndices[group]; } uint32_t PipelineLayout::GetSamplerRootParameterIndex(BindGroupIndex group) const { - DAWN_ASSERT(group < kMaxBindGroupsTyped); + DAWN_CHECK(group < kMaxBindGroupsTyped); return mSamplerRootParameterIndices[group]; } @@ -508,15 +508,15 @@ uint32_t PipelineLayout::GetDynamicUniformRootParameterIndex(BindGroupIndex group, BindingIndex bindingIndex) const { - DAWN_ASSERT(group < kMaxBindGroupsTyped); - DAWN_ASSERT(std::get<BufferBindingInfo>( - GetBindGroupLayout(group)->GetBindingInfo(bindingIndex).bindingLayout) - .hasDynamicOffset); - DAWN_ASSERT(GetBindGroupLayout(group)->GetBindingInfo(bindingIndex).visibility != - wgpu::ShaderStage::None); - DAWN_ASSERT(std::get<BufferBindingInfo>( - GetBindGroupLayout(group)->GetBindingInfo(bindingIndex).bindingLayout) - .type == wgpu::BufferBindingType::Uniform); + DAWN_CHECK(group < kMaxBindGroupsTyped); + DAWN_CHECK(std::get<BufferBindingInfo>( + GetBindGroupLayout(group)->GetBindingInfo(bindingIndex).bindingLayout) + .hasDynamicOffset); + DAWN_CHECK(GetBindGroupLayout(group)->GetBindingInfo(bindingIndex).visibility != + wgpu::ShaderStage::None); + DAWN_CHECK(std::get<BufferBindingInfo>( + GetBindGroupLayout(group)->GetBindingInfo(bindingIndex).bindingLayout) + .type == wgpu::BufferBindingType::Uniform); return mDynamicUniformRootParameterIndices[group][bindingIndex]; } @@ -554,8 +554,8 @@ } uint32_t PipelineLayout::GetDynamicStorageBufferLengthsParameterIndex() const { - DAWN_ASSERT(mDynamicStorageBufferLengthsParameterIndex != - kInvalidDynamicStorageBufferLengthsParameterIndex); + DAWN_CHECK(mDynamicStorageBufferLengthsParameterIndex != + kInvalidDynamicStorageBufferLengthsParameterIndex); return mDynamicStorageBufferLengthsParameterIndex; } @@ -568,8 +568,8 @@ } uint32_t PipelineLayout::GetDynamicStorageBufferOffsetsParameterIndex() const { - DAWN_ASSERT(mDynamicStorageBufferOffsetsParameterIndex != - kInvalidDynamicStorageBufferOffsetsParameterIndex); + DAWN_CHECK(mDynamicStorageBufferOffsetsParameterIndex != + kInvalidDynamicStorageBufferOffsetsParameterIndex); return mDynamicStorageBufferOffsetsParameterIndex; } @@ -582,7 +582,7 @@ } uint32_t PipelineLayout::GetImmediatesParameterIndex() const { - DAWN_ASSERT(mImmediatesParameterIndex != kInvalidImmediatesParameterIndex); + DAWN_CHECK(mImmediatesParameterIndex != kInvalidImmediatesParameterIndex); return mImmediatesParameterIndex; }
diff --git a/src/dawn/native/d3d12/SamplerHeapCacheD3D12.cpp b/src/dawn/native/d3d12/SamplerHeapCacheD3D12.cpp index def257e..2e2a817 100644 --- a/src/dawn/native/d3d12/SamplerHeapCacheD3D12.cpp +++ b/src/dawn/native/d3d12/SamplerHeapCacheD3D12.cpp
@@ -49,14 +49,14 @@ std::vector<Sampler*> samplers, CPUDescriptorHeapAllocation allocation) : mCPUAllocation(std::move(allocation)), mSamplers(std::move(samplers)), mCache(cache) { - DAWN_ASSERT(mCache != nullptr); - DAWN_ASSERT(mCPUAllocation.IsValid()); - DAWN_ASSERT(!mSamplers.empty()); + DAWN_CHECK(mCache != nullptr); + DAWN_CHECK(mCPUAllocation.IsValid()); + DAWN_CHECK(!mSamplers.empty()); } std::vector<Sampler*>&& SamplerHeapCacheEntry::AcquireSamplers() { // This function should only be called when SamplerHeapCacheEntry is created for blueprint. - DAWN_ASSERT(!mCPUAllocation.IsValid()); + DAWN_CHECK(!mCPUAllocation.IsValid()); return std::move(mSamplers); } @@ -64,14 +64,14 @@ // If this is a blueprint then the CPU allocation cannot exist and has no entry to remove. if (mCPUAllocation.IsValid()) { mCache->RemoveCacheEntry(this); - DAWN_ASSERT(!mSamplers.empty()); + DAWN_CHECK(!mSamplers.empty()); auto* allocator = mCache->GetDevice()->GetSamplerStagingDescriptorAllocator( static_cast<uint32_t>(mSamplers.size())); - DAWN_ASSERT(allocator != nullptr); + DAWN_CHECK(allocator != nullptr); (*allocator)->Deallocate(&mCPUAllocation); } - DAWN_ASSERT(!mCPUAllocation.IsValid()); + DAWN_CHECK(!mCPUAllocation.IsValid()); } bool SamplerHeapCacheEntry::Populate(ShaderVisibleDescriptorAllocator* allocator) { @@ -79,7 +79,7 @@ return true; } - DAWN_ASSERT(!mSamplers.empty()); + DAWN_CHECK(!mSamplers.empty()); Device* device = allocator->GetDevice(); @@ -126,10 +126,9 @@ } } // All visible samplers should have been added - DAWN_ASSERT(samplers.size() == samplerCount); + DAWN_CHECK(samplers.size() == samplerCount); // Check the cache if there exists a sampler heap allocation that corresponds to the - // samplers. SamplerHeapCacheEntry blueprint(std::move(samplers)); auto iter = mCache.find(&blueprint); if (iter != mCache.end()) { @@ -166,7 +165,7 @@ SamplerHeapCache::SamplerHeapCache(Device* device) : mDevice(device) {} SamplerHeapCache::~SamplerHeapCache() { - DAWN_ASSERT(mCache.empty()); + DAWN_CHECK(mCache.empty()); } Device* SamplerHeapCache::GetDevice() const { @@ -174,9 +173,9 @@ } void SamplerHeapCache::RemoveCacheEntry(SamplerHeapCacheEntry* entry) { - DAWN_ASSERT(entry->GetRefCountForTesting() == 0); + DAWN_CHECK(entry->GetRefCountForTesting() == 0); size_t removedCount = mCache.erase(entry); - DAWN_ASSERT(removedCount == 1); + DAWN_CHECK(removedCount == 1); } size_t SamplerHeapCacheEntry::HashFunc::operator()(const SamplerHeapCacheEntry* entry) const {
diff --git a/src/dawn/native/d3d12/TextureCopySplitter.cpp b/src/dawn/native/d3d12/TextureCopySplitter.cpp index 477cd95..23f4df0 100644 --- a/src/dawn/native/d3d12/TextureCopySplitter.cpp +++ b/src/dawn/native/d3d12/TextureCopySplitter.cpp
@@ -37,7 +37,7 @@ BlockOrigin3D ComputeBlockOffsets(const TypedTexelBlockInfo& blockInfo, uint32_t offset, BlockCount blocksPerRow) { - DAWN_ASSERT(blocksPerRow != BlockCount{0}); + DAWN_CHECK(blocksPerRow != BlockCount{0}); BlockCount offsetInBlocks = blockInfo.BytesToBlocks(offset); BlockCount blockOffsetX = offsetInBlocks % blocksPerRow; BlockCount blockOffsetY = offsetInBlocks / blocksPerRow; @@ -48,7 +48,7 @@ BlockCount blocksPerRow, uint64_t alignedOffset, BlockOrigin3D bufferOffset) { - DAWN_ASSERT(bufferOffset.z == BlockCount{0}); + DAWN_CHECK(bufferOffset.z == BlockCount{0}); uint64_t offset = alignedOffset + blockInfo.ToBytes(bufferOffset.x + blocksPerRow * bufferOffset.y); return offset; @@ -199,7 +199,7 @@ copy2->copySize.depthOrArrayLayers = BlockCount{1}; copy2->bufferOffset = blockOffsetForLastRowOfLastImage; copy2->bufferSize.width = copy1->bufferSize.width; - DAWN_ASSERT(copy2->copySize.height == BlockCount{1}); + DAWN_CHECK(copy2->copySize.height == BlockCount{1}); copy2->bufferSize.height = copy2->bufferOffset.y + copy2->copySize.height; copy2->bufferSize.depthOrArrayLayers = BlockCount{1}; } @@ -229,10 +229,10 @@ // Copy 1: copy the rest depth slices in one shot TextureCopySubresource::CopyInfo* copy1 = copy.AddCopy(); *copy1 = copy0; - DAWN_ASSERT(copySize.height % BlockCount{2} == BlockCount{1}); + DAWN_CHECK(copySize.height % BlockCount{2} == BlockCount{1}); copy1->alignedOffset += blockInfo.ToBytes((copySize.height + BlockCount{1}) * blocksPerRow); - DAWN_ASSERT(copy1->alignedOffset % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT == 0); + DAWN_CHECK(copy1->alignedOffset % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT == 0); // textureOffset1.z should add one because the first slice has already been copied in copy0. copy1->textureOffset.z++; // bufferOffset1.y should be 0 because we skipped the first depth slice and there is no empty @@ -267,8 +267,8 @@ return copy; } - DAWN_ASSERT(alignedOffset < offset); - DAWN_ASSERT(offset - alignedOffset < D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT); + DAWN_CHECK(alignedOffset < offset); + DAWN_CHECK(offset - alignedOffset < D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT); // We must reinterpret our aligned offset into X and Y offsets with respect to the row // pitch. @@ -293,8 +293,8 @@ BlockOrigin3D blockOffset = ComputeBlockOffsets(blockInfo, static_cast<uint32_t>(offset - alignedOffset), blocksPerRow); - DAWN_ASSERT(blockOffset.y <= BlockCount{1}); - DAWN_ASSERT(blockOffset.z == BlockCount{0}); + DAWN_CHECK(blockOffset.y <= BlockCount{1}); + DAWN_CHECK(blockOffset.z == BlockCount{0}); BlockCount copyBlocksPerRowPitch = copySize.width; BlockCount blockOffsetInRowPitch = blockOffset.x; @@ -367,7 +367,7 @@ // |---------| // Copy 0 - DAWN_ASSERT(blocksPerRow > blockOffsetInRowPitch); + DAWN_CHECK(blocksPerRow > blockOffsetInRowPitch); const BlockExtent3D copySize0 = {blocksPerRow - blockOffset.x, copySize.height, copySize.depthOrArrayLayers}; @@ -385,12 +385,12 @@ const BlockOrigin3D blockOffsetForCopy1 = ComputeBlockOffsets( blockInfo, static_cast<uint32_t>(offsetForCopy1 - alignedOffsetForCopy1), blocksPerRow); - DAWN_ASSERT(blockOffsetForCopy1.y <= BlockCount{1}); - DAWN_ASSERT(blockOffsetForCopy1.z == BlockCount{0}); + DAWN_CHECK(blockOffsetForCopy1.y <= BlockCount{1}); + DAWN_CHECK(blockOffsetForCopy1.z == BlockCount{0}); const BlockOrigin3D textureOffset1 = {origin.x + copySize0.width, origin.y, origin.z}; - DAWN_ASSERT(copySize.width > copySize0.width); + DAWN_CHECK(copySize.width > copySize0.width); const BlockExtent3D copySize1 = {copySize.width - copySize0.width, copySize.height, copySize.depthOrArrayLayers}; @@ -459,7 +459,7 @@ TextureCopySubresource copySubresource = Compute2DTextureCopySubresourceAligned(origin, copySize, blockInfo, offset, blocksPerRow); - DAWN_ASSERT(copySubresource.count <= 2); + DAWN_CHECK(copySubresource.count <= 2); // If copySize.depthOrArrayLayers is 1, we can return copySubresource. Because we don't need to // extend the copy region(s) to other depth slice(s). if (copySize.depthOrArrayLayers == BlockCount{1}) { @@ -473,7 +473,7 @@ for (uint32_t i = 0; i < originalCopyCount; ++i) { // There can be one empty row at most in a copy region. BlockCount bufferHeight = copySubresource.copies[i].bufferSize.height; - DAWN_ASSERT(bufferHeight <= rowsPerImage + BlockCount{1}); + DAWN_CHECK(bufferHeight <= rowsPerImage + BlockCount{1}); if (bufferHeight == rowsPerImage) { // If the copy region's bufferHeight equals to rowsPerImage, we can use this @@ -493,8 +493,8 @@ // Otherwise, bufferHeight won't be greater than rowsPerImage and there won't be // an empty row at the beginning of this copy region. uint64_t bytesPerRow = blockInfo.ToBytes(blocksPerRow); - DAWN_ASSERT(bytesPerRow == D3D12_TEXTURE_DATA_PITCH_ALIGNMENT); - DAWN_ASSERT(copySize.height == rowsPerImage); + DAWN_CHECK(bytesPerRow == D3D12_TEXTURE_DATA_PITCH_ALIGNMENT); + DAWN_CHECK(copySize.height == rowsPerImage); const BlockCount copyHeight = copySize.height; if (static_cast<uint32_t>(copyHeight) % 2 == 0) { @@ -581,7 +581,7 @@ // ^ // End of all buffer data // - DAWN_ASSERT(copySize.depthOrArrayLayers >= BlockCount{1}); + DAWN_CHECK(copySize.depthOrArrayLayers >= BlockCount{1}); constexpr BlockCount depthInCopy2{1}; const BlockCount rowsPerImageInTexels2 = copySize.height; @@ -600,7 +600,7 @@ } // namespace TextureCopySubresource::CopyInfo* TextureCopySubresource::AddCopy() { - DAWN_ASSERT(this->count < kMaxTextureCopyRegions); + DAWN_CHECK(this->count < kMaxTextureCopyRegions); return &this->copies[this->count++]; }
diff --git a/src/dawn/native/d3d12/TextureD3D12.cpp b/src/dawn/native/d3d12/TextureD3D12.cpp index 71f147a..b93244e 100644 --- a/src/dawn/native/d3d12/TextureD3D12.cpp +++ b/src/dawn/native/d3d12/TextureD3D12.cpp
@@ -65,11 +65,11 @@ D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON; // D3D12 doesn't need special acquire operations for presentable textures. - DAWN_ASSERT(!(usage & kPresentAcquireTextureUsage)); + DAWN_CHECK(!(usage & kPresentAcquireTextureUsage)); if (usage & kPresentReleaseTextureUsage) { // The present usage is only used internally by the swapchain and is never used in // combination with other usages. - DAWN_ASSERT(usage == kPresentReleaseTextureUsage); + DAWN_CHECK(usage == kPresentReleaseTextureUsage); return D3D12_RESOURCE_STATE_PRESENT; } @@ -125,8 +125,8 @@ } } - DAWN_ASSERT(!(flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) || - flags == D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL); + DAWN_CHECK(!(flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) || + flags == D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL); return flags; } @@ -223,7 +223,7 @@ D3D12_RESOURCE_DESC desc = d3d12Texture->GetDesc(); mD3D12ResourceFlags = desc.Flags; - DAWN_ASSERT(mD3D12ResourceFlags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS); + DAWN_CHECK(mD3D12ResourceFlags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS); AllocationInfo info; info.mMethod = AllocationMethod::kExternal; @@ -355,7 +355,7 @@ } MaybeError Texture::PinImpl(wgpu::TextureUsage usage) { - DAWN_ASSERT(!HasPinnedUsage()); + DAWN_CHECK(!HasPinnedUsage()); SubresourceRange pinnedSubresources = GetAllSubresources(); CommandRecordingContext* commandContext = @@ -372,7 +372,7 @@ } void Texture::UnpinImpl() { - DAWN_ASSERT(HasPinnedUsage()); + DAWN_CHECK(HasPinnedUsage()); // TODO(https://issues.chromium.org/473444516): Investigate what to do for imported textures. // Should we consider a pin/unpin pair similar to an access on a queue such that we need to @@ -392,7 +392,7 @@ } DXGI_FORMAT Texture::GetD3D12CopyableSubresourceFormat(Aspect aspect) const { - DAWN_ASSERT(GetFormat().aspects & aspect); + DAWN_CHECK(GetFormat().aspects & aspect); wgpu::TextureFormat format = GetFormat().format; switch (format) { @@ -404,7 +404,7 @@ // The depth24 part of a D24_UNORM_S8_UINT texture cannot be copied with D3D and // is also not supported by WebGPU. // See https://gpuweb.github.io/gpuweb/#depth-formats - DAWN_ASSERT(format == wgpu::TextureFormat::Depth32FloatStencil8); + DAWN_CHECK(format == wgpu::TextureFormat::Depth32FloatStencil8); return DXGI_FORMAT_R32_FLOAT; case Aspect::Stencil: return DXGI_FORMAT_R8_UINT; @@ -412,7 +412,7 @@ DAWN_UNREACHABLE(); } default: - DAWN_ASSERT(HasOneBit(GetFormat().aspects)); + DAWN_CHECK(HasOneBit(GetFormat().aspects)); return GetD3D12Format(); } } @@ -606,8 +606,8 @@ // state at all times that read accesses are happening; otherwise, the // texture can enter a state where it could be modified by one read access // (e.g., to be compressed or decrompessed) while being read by another. - DAWN_ASSERT(state->isValidToDecay || mSharedResourceMemoryContents->HasWriteAccess() || - mSharedResourceMemoryContents->HasExclusiveReadAccess()); + DAWN_CHECK(state->isValidToDecay || mSharedResourceMemoryContents->HasWriteAccess() || + mSharedResourceMemoryContents->HasExclusiveReadAccess()); } D3D12_RESOURCE_BARRIER barrier; @@ -703,7 +703,7 @@ } D3D12_RESOURCE_STATES Texture::GetCurrentStateForSwapChain() const { - DAWN_ASSERT(GetFormat().aspects == Aspect::Color); + DAWN_CHECK(GetFormat().aspects == Aspect::Color); return mSubresourceStateAndDecay.Get(Aspect::Color, 0, 0).lastState; } @@ -726,11 +726,11 @@ D3D12_RENDER_TARGET_VIEW_DESC rtvDesc; rtvDesc.Format = d3d::DXGITextureFormat(GetDevice(), format.format); if (IsMultisampledTexture()) { - DAWN_ASSERT(GetDimension() == wgpu::TextureDimension::e2D); - DAWN_ASSERT(GetNumMipLevels() == 1); - DAWN_ASSERT(sliceCount == 1); - DAWN_ASSERT(baseSlice == 0); - DAWN_ASSERT(mipLevel == 0); + DAWN_CHECK(GetDimension() == wgpu::TextureDimension::e2D); + DAWN_CHECK(GetNumMipLevels() == 1); + DAWN_CHECK(sliceCount == 1); + DAWN_CHECK(baseSlice == 0); + DAWN_CHECK(mipLevel == 0); rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMS; return rtvDesc; } @@ -779,10 +779,10 @@ } if (IsMultisampledTexture()) { - DAWN_ASSERT(GetNumMipLevels() == 1); - DAWN_ASSERT(layerCount == 1); - DAWN_ASSERT(baseArrayLayer == 0); - DAWN_ASSERT(mipLevel == 0); + DAWN_CHECK(GetNumMipLevels() == 1); + DAWN_CHECK(layerCount == 1); + DAWN_CHECK(baseArrayLayer == 0); + DAWN_CHECK(mipLevel == 0); dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DMS; } else { dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DARRAY; @@ -856,7 +856,7 @@ const float clearColorRGBA[4] = {fClearColor, fClearColor, fClearColor, fClearColor}; - DAWN_ASSERT(range.aspects == Aspect::Color); + DAWN_CHECK(range.aspects == Aspect::Color); for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount; ++level) { for (uint32_t layer = range.baseArrayLayer; @@ -890,7 +890,7 @@ } } } else { - DAWN_ASSERT(!IsMultisampledTexture()); + DAWN_CHECK(!IsMultisampledTexture()); // create temp buffer with clear color to copy to the texture image TrackUsageAndTransitionNow(commandContext, D3D12_RESOURCE_STATE_COPY_DEST, range); @@ -1027,10 +1027,10 @@ if (GetTexture()->IsMultisampledTexture()) { switch (descriptor->dimension) { case wgpu::TextureViewDimension::e2DArray: - DAWN_ASSERT(texture->GetArrayLayers() == 1); + DAWN_CHECK(texture->GetArrayLayers() == 1); [[fallthrough]]; case wgpu::TextureViewDimension::e2D: - DAWN_ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D); + DAWN_CHECK(texture->GetDimension() == wgpu::TextureDimension::e2D); mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS; break; @@ -1048,7 +1048,7 @@ case wgpu::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2DArray: - DAWN_ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D); + DAWN_CHECK(texture->GetDimension() == wgpu::TextureDimension::e2D); mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; mSrvDesc.Texture2DArray.ArraySize = descriptor->arrayLayerCount; mSrvDesc.Texture2DArray.FirstArraySlice = descriptor->baseArrayLayer; @@ -1059,8 +1059,8 @@ break; case wgpu::TextureViewDimension::Cube: case wgpu::TextureViewDimension::CubeArray: - DAWN_ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D); - DAWN_ASSERT(descriptor->arrayLayerCount % 6 == 0); + DAWN_CHECK(texture->GetDimension() == wgpu::TextureDimension::e2D); + DAWN_CHECK(descriptor->arrayLayerCount % 6 == 0); mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY; mSrvDesc.TextureCubeArray.First2DArrayFace = descriptor->baseArrayLayer; mSrvDesc.TextureCubeArray.NumCubes = descriptor->arrayLayerCount / 6; @@ -1069,7 +1069,7 @@ mSrvDesc.TextureCubeArray.ResourceMinLODClamp = 0; break; case wgpu::TextureViewDimension::e3D: - DAWN_ASSERT(texture->GetDimension() == wgpu::TextureDimension::e3D); + DAWN_CHECK(texture->GetDimension() == wgpu::TextureDimension::e3D); mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D; mSrvDesc.Texture3D.MostDetailedMip = descriptor->baseMipLevel; mSrvDesc.Texture3D.MipLevels = descriptor->mipLevelCount; @@ -1088,12 +1088,12 @@ } const D3D12_SHADER_RESOURCE_VIEW_DESC& TextureView::GetSRVDescriptor() const { - DAWN_ASSERT(mSrvDesc.Format != DXGI_FORMAT_UNKNOWN); + DAWN_CHECK(mSrvDesc.Format != DXGI_FORMAT_UNKNOWN); return mSrvDesc; } D3D12_RENDER_TARGET_VIEW_DESC TextureView::GetRTVDescriptor(uint32_t depthSlice) const { - DAWN_ASSERT(depthSlice < GetSingleSubresourceVirtualSize().depthOrArrayLayers); + DAWN_CHECK(depthSlice < GetSingleSubresourceVirtualSize().depthOrArrayLayers); // We have validated that the depthSlice in render pass's colorAttachments must be undefined for // 2d RTVs, which value is set to 0. For 3d RTVs, the baseArrayLayer must be 0. So here we can // simply use baseArrayLayer + depthSlice to specify the slice in RTVs without checking the @@ -1105,7 +1105,7 @@ D3D12_DEPTH_STENCIL_VIEW_DESC TextureView::GetDSVDescriptor(bool depthReadOnly, bool stencilReadOnly) const { - DAWN_ASSERT(GetLevelCount() == 1); + DAWN_CHECK(GetLevelCount() == 1); return ToBackend(GetTexture()) ->GetDSVDescriptor(GetBaseMipLevel(), GetBaseArrayLayer(), GetLayerCount(), GetAspects(), depthReadOnly, stencilReadOnly); @@ -1115,7 +1115,7 @@ D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc; uavDesc.Format = GetD3D12Format(); - DAWN_ASSERT(!GetTexture()->IsMultisampledTexture()); + DAWN_CHECK(!GetTexture()->IsMultisampledTexture()); switch (GetDimension()) { case wgpu::TextureViewDimension::e1D: uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1D;
diff --git a/src/dawn/native/null/DeviceNull.cpp b/src/dawn/native/null/DeviceNull.cpp index 98890bd..2469f51 100644 --- a/src/dawn/native/null/DeviceNull.cpp +++ b/src/dawn/native/null/DeviceNull.cpp
@@ -270,7 +270,7 @@ } void Device::DestroyImpl(DestroyReason reason) { - DAWN_ASSERT(GetState() == State::Disconnected); + DAWN_CHECK(GetState() == State::Disconnected); // TODO(crbug.com/dawn/831): DestroyImpl is called from two places. // - It may be called if the device is explicitly destroyed with APIDestroy. // This case is NOT thread-safe and needs proper synchronization with other @@ -282,7 +282,7 @@ // Clear pending operations before checking mMemoryUsage because some operations keep a // reference to Buffers. mPendingOperations.clear(); - DAWN_ASSERT(mMemoryUsage == 0); + DAWN_CHECK(mMemoryUsage == 0); } void Device::ForgetPendingOperations() {
diff --git a/src/dawn/native/opengl/BufferGL.cpp b/src/dawn/native/opengl/BufferGL.cpp index c428c3c..e34381e 100644 --- a/src/dawn/native/opengl/BufferGL.cpp +++ b/src/dawn/native/opengl/BufferGL.cpp
@@ -178,7 +178,7 @@ } MaybeError Buffer::InitializeToZero() { - DAWN_ASSERT(NeedsInitialization()); + DAWN_CHECK(NeedsInitialization()); Device* device = ToBackend(GetDevice()); @@ -255,7 +255,7 @@ mappedData = DAWN_GL_TRY_ALWAYS_CHECK( gl, MapBufferRange(GL_ARRAY_BUFFER, offset, size, GL_MAP_READ_BIT)); } else { - DAWN_ASSERT(mode & wgpu::MapMode::Write); + DAWN_CHECK(mode & wgpu::MapMode::Write); mappedData = DAWN_GL_TRY_ALWAYS_CHECK( gl, MapBufferRange(GL_ARRAY_BUFFER, offset, size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT));
diff --git a/src/dawn/native/opengl/CommandBufferGL.cpp b/src/dawn/native/opengl/CommandBufferGL.cpp index 6d14648..42bfc88 100644 --- a/src/dawn/native/opengl/CommandBufferGL.cpp +++ b/src/dawn/native/opengl/CommandBufferGL.cpp
@@ -407,7 +407,7 @@ if (ToBackend(view->GetTexture())->GetGLFormat().format == GL_DEPTH_STENCIL) { Aspect aspect = view->GetAspects(); - DAWN_ASSERT(HasOneBit(aspect)); + DAWN_CHECK(HasOneBit(aspect)); switch (aspect) { case Aspect::None: case Aspect::Color: @@ -555,7 +555,7 @@ const Buffer* internalUniformBuffer = ToBackend(mPipelineLayout->GetDevice())->GetInternalTextureBuiltinsUniformBuffer(); - DAWN_ASSERT(internalUniformBuffer); + DAWN_CHECK(internalUniformBuffer); GLuint internalUniformBufferHandle = internalUniformBuffer->GetHandle(); DAWN_GL_TRY( @@ -587,7 +587,7 @@ const Buffer* internalUniformBuffer = ToBackend(mPipelineLayout->GetDevice())->GetInternalArrayLengthUniformBuffer(); - DAWN_ASSERT(internalUniformBuffer); + DAWN_CHECK(internalUniformBuffer); GLuint internalUniformBufferHandle = internalUniformBuffer->GetHandle(); DAWN_GL_TRY(gl, @@ -678,7 +678,7 @@ for (auto i : renderPass->attachmentState->GetColorAttachmentsMask()) { if (renderPass->colorAttachments[i].resolveTarget != nullptr) { if (readFbo == 0) { - DAWN_ASSERT(writeFbo == 0); + DAWN_CHECK(writeFbo == 0); DAWN_GL_TRY(gl, GenFramebuffers(1, &readFbo)); DAWN_GL_TRY(gl, GenFramebuffers(1, &writeFbo)); } @@ -714,14 +714,14 @@ const TextureBase* texture = textureCopy.texture.Get(); TexelExtent3D virtualSizeAtLevel = texture->GetMipLevelSingleSubresourceVirtualSize(textureCopy.mipLevel, textureCopy.aspect); - DAWN_ASSERT(textureCopy.origin.x <= virtualSizeAtLevel.width); - DAWN_ASSERT(textureCopy.origin.y <= virtualSizeAtLevel.height); + DAWN_CHECK(textureCopy.origin.x <= virtualSizeAtLevel.width); + DAWN_CHECK(textureCopy.origin.y <= virtualSizeAtLevel.height); if (copySize.width > virtualSizeAtLevel.width - textureCopy.origin.x) { - DAWN_ASSERT(texture->GetFormat().isCompressed); + DAWN_CHECK(texture->GetFormat().isCompressed); validTextureCopyExtent.width = virtualSizeAtLevel.width - textureCopy.origin.x; } if (copySize.height > virtualSizeAtLevel.height - textureCopy.origin.y) { - DAWN_ASSERT(texture->GetFormat().isCompressed); + DAWN_CHECK(texture->GetFormat().isCompressed); validTextureCopyExtent.height = virtualSizeAtLevel.height - textureCopy.origin.y; } @@ -734,7 +734,7 @@ ImmediateConstantTracker() = default; MaybeError Apply(const OpenGLFunctions& gl) { - DAWN_ASSERT(this->mLastPipeline != nullptr); + DAWN_CHECK(this->mLastPipeline != nullptr); auto* lastPipeline = this->mLastPipeline; ImmediateConstantMask pipelineMask = lastPipeline->GetImmediateMask(); @@ -966,7 +966,7 @@ case wgpu::TextureDimension::e1D: case wgpu::TextureDimension::e2D: { if (target == GL_TEXTURE_2D) { - DAWN_ASSERT(texture->GetArrayLayers() == 1); + DAWN_CHECK(texture->GetArrayLayers() == 1); DAWN_GL_TRY( gl, FramebufferTexture2D(GL_READ_FRAMEBUFFER, glAttachment, target, texture->GetHandle(), src.mipLevel)); @@ -977,7 +977,7 @@ glFormat, glType, offset)); break; } else if (target == GL_TEXTURE_CUBE_MAP) { - DAWN_ASSERT(texture->GetArrayLayers() == 6); + DAWN_CHECK(texture->GetArrayLayers() == 6); const uint64_t bytesPerImage = blockInfo.ToBytes(dst.blocksPerRow * dst.rowsPerImage); for (TexelCount z{0}; z < copySize.depthOrArrayLayers; ++z) { @@ -1709,7 +1709,7 @@ static_cast<uint32_t>(y), static_cast<uint32_t>(width), static_cast<uint32_t>(height), format.internalFormat, imageSize, data)); } else if (target == GL_TEXTURE_CUBE_MAP) { - DAWN_ASSERT(texture->GetArrayLayers() == 6); + DAWN_CHECK(texture->GetArrayLayers() == 6); const uint8_t* pointer = static_cast<const uint8_t*>(data); TexelCount baseLayer = destination.origin.z; for (TexelCount l{0}; l < copySize.depthOrArrayLayers; ++l) { @@ -1754,7 +1754,7 @@ d += bytesPerRow; } } else if (target == GL_TEXTURE_CUBE_MAP) { - DAWN_ASSERT(texture->GetArrayLayers() == 6); + DAWN_CHECK(texture->GetArrayLayers() == 6); const uint8_t* pointer = static_cast<const uint8_t*>(data); TexelCount baseLayer = destination.origin.z; for (TexelCount l{0}; l < copySize.depthOrArrayLayers; ++l) { @@ -1774,8 +1774,8 @@ } } } else { - DAWN_ASSERT(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY || - target == GL_TEXTURE_CUBE_MAP_ARRAY); + DAWN_CHECK(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY || + target == GL_TEXTURE_CUBE_MAP_ARRAY); const uint8_t* slice = static_cast<const uint8_t*>(data); for (; z < destination.origin.z + copySize.depthOrArrayLayers; ++z) { @@ -1802,8 +1802,8 @@ TexelCount height = copySize.height; GLenum adjustedFormat = format.format; if (format.format == GL_STENCIL) { - DAWN_ASSERT(gl.GetVersion().IsDesktop() || - gl.IsGLExtensionSupported("GL_OES_texture_stencil8")); + DAWN_CHECK(gl.GetVersion().IsDesktop() || + gl.IsGLExtensionSupported("GL_OES_texture_stencil8")); adjustedFormat = GL_STENCIL_INDEX; } if (bytesPerRow % blockInfo.byteSize == 0) { @@ -1821,7 +1821,7 @@ static_cast<uint32_t>(height), adjustedFormat, format.type, data)); } else if (target == GL_TEXTURE_CUBE_MAP) { - DAWN_ASSERT(texture->GetArrayLayers() == 6); + DAWN_CHECK(texture->GetArrayLayers() == 6); const uint8_t* pointer = static_cast<const uint8_t*>(data); TexelCount baseLayer = destination.origin.z; for (TexelCount l{0}; l < copySize.depthOrArrayLayers; ++l) { @@ -1835,8 +1835,8 @@ pointer += bytesPerImage; } } else { - DAWN_ASSERT(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY || - target == GL_TEXTURE_CUBE_MAP_ARRAY); + DAWN_CHECK(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY || + target == GL_TEXTURE_CUBE_MAP_ARRAY); DAWN_GL_TRY( gl, PixelStorei(GL_UNPACK_IMAGE_HEIGHT, static_cast<uint32_t>(blockInfo.ToTexelHeight(rowsPerImage)))); @@ -1861,7 +1861,7 @@ d += bytesPerRow; } } else if (target == GL_TEXTURE_CUBE_MAP) { - DAWN_ASSERT(texture->GetArrayLayers() == 6); + DAWN_CHECK(texture->GetArrayLayers() == 6); const uint8_t* pointer = static_cast<const uint8_t*>(data); TexelCount baseLayer = destination.origin.z; for (TexelCount l{0}; l < copySize.depthOrArrayLayers; ++l) { @@ -1879,8 +1879,8 @@ pointer += bytesPerImage; } } else { - DAWN_ASSERT(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY || - target == GL_TEXTURE_CUBE_MAP_ARRAY); + DAWN_CHECK(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY || + target == GL_TEXTURE_CUBE_MAP_ARRAY); const uint8_t* slice = static_cast<const uint8_t*>(data); for (; z < destination.origin.z + copySize.depthOrArrayLayers; ++z) { const uint8_t* d = slice;
diff --git a/src/dawn/native/opengl/DeviceGL.cpp b/src/dawn/native/opengl/DeviceGL.cpp index 2d1b299..b46d578 100644 --- a/src/dawn/native/opengl/DeviceGL.cpp +++ b/src/dawn/native/opengl/DeviceGL.cpp
@@ -241,11 +241,11 @@ } const GLFormat& Device::GetGLFormat(const Format& format) { - DAWN_ASSERT(format.IsSupported()); - DAWN_ASSERT(format.GetIndex() < mFormatTable.size()); + DAWN_CHECK(format.IsSupported()); + DAWN_CHECK(format.GetIndex() < mFormatTable.size()); const GLFormat& result = mFormatTable[format.GetIndex()]; - DAWN_ASSERT(result.isSupportedOnBackend); + DAWN_CHECK(result.isSupportedOnBackend); return result; } @@ -401,7 +401,7 @@ // The EGLImage was created from outside of Dawn so it must be on the same display that was // provided to create the device. The best check we can do is that we indeed have // EGL_KHR_image_base. - DAWN_ASSERT(GetEGL(false).HasExt(EGLExt::ImageBase)); + DAWN_CHECK(GetEGL(false).HasExt(EGLExt::ImageBase)); GLuint tex; DAWN_GL_TRY(gl, GenTextures(1, &tex));
diff --git a/src/dawn/native/opengl/RenderPipelineGL.cpp b/src/dawn/native/opengl/RenderPipelineGL.cpp index a6a74f9..9e72141 100644 --- a/src/dawn/native/opengl/RenderPipelineGL.cpp +++ b/src/dawn/native/opengl/RenderPipelineGL.cpp
@@ -283,7 +283,7 @@ } VertexAttributeMask RenderPipeline::GetAttributesUsingVertexBuffer(VertexBufferSlot slot) const { - DAWN_ASSERT(!IsError()); + DAWN_CHECK(!IsError()); return mAttributesUsingVertexBuffer[slot]; } @@ -323,7 +323,7 @@ PersistentPipelineState& persistentPipelineState) { DAWN_TRY(PipelineGL::ApplyNow(gl, ToBackend(GetLayout()))); - DAWN_ASSERT(mVertexArrayObject); + DAWN_CHECK(mVertexArrayObject); DAWN_GL_TRY(gl, BindVertexArray(mVertexArrayObject)); DAWN_TRY(ApplyFrontFaceAndCulling(gl, GetFrontFace(), GetCullMode()));
diff --git a/src/dawn/native/opengl/TextureGL.cpp b/src/dawn/native/opengl/TextureGL.cpp index 783fa92..0edc026 100644 --- a/src/dawn/native/opengl/TextureGL.cpp +++ b/src/dawn/native/opengl/TextureGL.cpp
@@ -58,16 +58,16 @@ if (sampleCount > 1) { return GL_TEXTURE_2D_MULTISAMPLE; } - DAWN_ASSERT(sampleCount == 1); + DAWN_CHECK(sampleCount == 1); return GL_TEXTURE_2D_ARRAY; case wgpu::TextureViewDimension::Cube: - DAWN_ASSERT(sampleCount == 1); + DAWN_CHECK(sampleCount == 1); return GL_TEXTURE_CUBE_MAP; case wgpu::TextureViewDimension::CubeArray: - DAWN_ASSERT(sampleCount == 1); + DAWN_CHECK(sampleCount == 1); return GL_TEXTURE_CUBE_MAP_ARRAY; case wgpu::TextureViewDimension::e3D: - DAWN_ASSERT(sampleCount == 1); + DAWN_CHECK(sampleCount == 1); return GL_TEXTURE_3D; case wgpu::TextureViewDimension::Undefined: @@ -243,7 +243,7 @@ break; } default: - DAWN_ASSERT(textarget == GL_TEXTURE_2D || textarget == GL_TEXTURE_2D_MULTISAMPLE); + DAWN_CHECK(textarget == GL_TEXTURE_2D || textarget == GL_TEXTURE_2D_MULTISAMPLE); DAWN_GL_TRY( gl, FramebufferTexture2D(target, attachment, textarget, textureHandle, mipLevel)); break; @@ -414,7 +414,7 @@ DAWN_GL_TRY(gl, Enable(GL_SCISSOR_TEST)); DAWN_GL_TRY(gl, DeleteFramebuffers(1, &framebuffer)); } else { - DAWN_ASSERT(range.aspects == Aspect::Color); + DAWN_CHECK(range.aspects == Aspect::Color); // For gl.ClearBufferiv/uiv calls constexpr std::array<GLuint, 4> kClearColorDataUint0 = {0u, 0u, 0u, 0u}; @@ -430,7 +430,7 @@ static constexpr uint32_t MAX_TEXEL_SIZE = 16; const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(Aspect::Color).block; - DAWN_ASSERT(blockInfo.byteSize <= MAX_TEXEL_SIZE); + DAWN_CHECK(blockInfo.byteSize <= MAX_TEXEL_SIZE); // For gl.ClearTexSubImage calls constexpr std::array<GLbyte, MAX_TEXEL_SIZE> kClearColorDataBytes0 = { @@ -527,11 +527,11 @@ } } } else { - DAWN_ASSERT(range.aspects == Aspect::Color); + DAWN_CHECK(range.aspects == Aspect::Color); // create temp buffer with clear color to copy to the texture image const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(Aspect::Color).block; - DAWN_ASSERT(kTextureBytesPerRowAlignment % blockInfo.byteSize == 0); + DAWN_CHECK(kTextureBytesPerRowAlignment % blockInfo.byteSize == 0); Extent3D largestMipSize = GetMipLevelSingleSubresourcePhysicalSize(range.baseMipLevel, Aspect::Color); @@ -539,8 +539,8 @@ Align((largestMipSize.width / blockInfo.width) * blockInfo.byteSize, 4); // Make sure that we are not rounding - DAWN_ASSERT(bytesPerRow % blockInfo.byteSize == 0); - DAWN_ASSERT(largestMipSize.height % blockInfo.height == 0); + DAWN_CHECK(bytesPerRow % blockInfo.byteSize == 0); + DAWN_CHECK(largestMipSize.height % blockInfo.height == 0); uint64_t bufferSize64 = static_cast<uint64_t>(bytesPerRow) * (largestMipSize.height / blockInfo.height) * @@ -648,7 +648,7 @@ view->mHandle = 0; } else if (view->mOwnsHandle == OwnsHandle::Yes) { GLuint handle = 0; - DAWN_ASSERT(gl.IsAtLeastGL(4, 3)); + DAWN_CHECK(gl.IsAtLeastGL(4, 3)); DAWN_GL_TRY(gl, GenTextures(1, &handle)); DAWN_GL_TRY(gl, TextureView(handle, view->GetGLTarget(), texture->GetHandle(), @@ -685,7 +685,7 @@ } GLuint TextureView::GetHandle() const { - DAWN_ASSERT(mHandle != 0); + DAWN_CHECK(mHandle != 0); return mHandle; } @@ -697,8 +697,8 @@ GLenum target, GLenum attachment, GLuint depthSlice) { - DAWN_ASSERT(depthSlice < - static_cast<GLuint>(GetSingleSubresourceVirtualSize().depthOrArrayLayers)); + DAWN_CHECK(depthSlice < + static_cast<GLuint>(GetSingleSubresourceVirtualSize().depthOrArrayLayers)); // Use the base texture where possible to minimize the amount of copying required on GLES. bool useOwnView = GetFormat().format != GetTexture()->GetFormat().format && @@ -726,7 +726,7 @@ arrayLayer = GetBaseArrayLayer() + depthSlice; } - DAWN_ASSERT(textureHandle != 0); + DAWN_CHECK(textureHandle != 0); return FramebufferTextureHelper(gl, textarget, target, attachment, textureHandle, mipLevel, arrayLayer);
diff --git a/src/dawn/native/opengl/UtilsEGL.cpp b/src/dawn/native/opengl/UtilsEGL.cpp index 1648fe5..f68c864 100644 --- a/src/dawn/native/opengl/UtilsEGL.cpp +++ b/src/dawn/native/opengl/UtilsEGL.cpp
@@ -114,7 +114,7 @@ if (egl.HasExt(EGLExt::FenceSync)) { sync = egl.CreateSyncKHR(display->GetDisplay(), type, attribs); } else { - DAWN_ASSERT(egl.IsAtLeastVersion(1, 5)); + DAWN_CHECK(egl.IsAtLeastVersion(1, 5)); std::vector<EGLAttrib> convertedAttribs = ConvertEGLIntParameterListToEGLAttrib(attribs); sync = egl.CreateSync(display->GetDisplay(), type, convertedAttribs.data()); } @@ -135,7 +135,7 @@ EGLint syncType = 0; queryResult = egl.GetSyncAttribKHR(display->GetDisplay(), sync, EGL_SYNC_TYPE, &syncType); } else { - DAWN_ASSERT(egl.IsAtLeastVersion(1, 5)); + DAWN_CHECK(egl.IsAtLeastVersion(1, 5)); EGLAttrib syncType = 0; queryResult = egl.GetSyncAttrib(display->GetDisplay(), sync, EGL_SYNC_TYPE, &syncType); } @@ -147,8 +147,8 @@ WrappedEGLSync::WrappedEGLSync(DisplayEGL* display, EGLSync sync, bool ownsSync) : mDisplay(display), mSync(sync), mOwnsSync(ownsSync) { - DAWN_ASSERT(mDisplay != nullptr); - DAWN_ASSERT(mSync != EGL_NO_SYNC); + DAWN_CHECK(mDisplay != nullptr); + DAWN_CHECK(mSync != EGL_NO_SYNC); } WrappedEGLSync::~WrappedEGLSync() { @@ -157,7 +157,7 @@ if (egl.HasExt(EGLExt::FenceSync)) { egl.DestroySyncKHR(mDisplay->GetDisplay(), mSync); } else { - DAWN_ASSERT(egl.IsAtLeastVersion(1, 5)); + DAWN_CHECK(egl.IsAtLeastVersion(1, 5)); egl.DestroySync(mDisplay->GetDisplay(), mSync); } } @@ -169,7 +169,7 @@ MaybeError WrappedEGLSync::Signal(const OpenGLFunctions&, EGLenum mode) { const EGLFunctions& egl = mDisplay->egl.get(); - DAWN_ASSERT(egl.HasExt(EGLExt::ReusableSync)); + DAWN_CHECK(egl.HasExt(EGLExt::ReusableSync)); DAWN_TRY(CheckEGL(egl, egl.SignalSync(mDisplay->GetDisplay(), mSync, mode), "eglSignalSync")); return {}; @@ -184,7 +184,7 @@ if (egl.HasExt(EGLExt::FenceSync)) { result = egl.ClientWaitSyncKHR(mDisplay->GetDisplay(), mSync, flags, uint64_t(timeout)); } else { - DAWN_ASSERT(egl.IsAtLeastVersion(1, 5)); + DAWN_CHECK(egl.IsAtLeastVersion(1, 5)); result = egl.ClientWaitSync(mDisplay->GetDisplay(), mSync, flags, uint64_t(timeout)); } @@ -194,7 +194,7 @@ MaybeError WrappedEGLSync::Wait(const OpenGLFunctions&) { const EGLFunctions& egl = mDisplay->egl.get(); - DAWN_ASSERT(egl.HasExt(EGLExt::WaitSync)); + DAWN_CHECK(egl.HasExt(EGLExt::WaitSync)); constexpr EGLint flags = 0; DAWN_TRY(CheckEGL(egl, egl.WaitSync(mDisplay->GetDisplay(), mSync, flags), "eglWaitSync")); @@ -203,7 +203,7 @@ ResultOrError<EGLint> WrappedEGLSync::DupFD(const OpenGLFunctions&) { const EGLFunctions& egl = mDisplay->egl.get(); - DAWN_ASSERT(egl.HasExt(EGLExt::NativeFenceSync)); + DAWN_CHECK(egl.HasExt(EGLExt::NativeFenceSync)); EGLint fd = egl.DupNativeFenceFD(mDisplay->GetDisplay(), mSync); DAWN_TRY(CheckEGL(egl, fd != EGL_NO_NATIVE_FENCE_FD_ANDROID, "eglDupNativeFenceFDANDROID"));
diff --git a/src/dawn/native/vulkan/BackendVk.cpp b/src/dawn/native/vulkan/BackendVk.cpp index c34bd57..f22a52a 100644 --- a/src/dawn/native/vulkan/BackendVk.cpp +++ b/src/dawn/native/vulkan/BackendVk.cpp
@@ -310,7 +310,7 @@ VulkanInstance::VulkanInstance() = default; VulkanInstance::~VulkanInstance() { - DAWN_ASSERT(mMessageListenerDevices.empty()); + DAWN_CHECK(mMessageListenerDevices.empty()); if (mDebugUtilsMessenger != VK_NULL_HANDLE) { mFunctions.DestroyDebugUtilsMessengerEXT(mInstance, mDebugUtilsMessenger, nullptr);
diff --git a/src/dawn/native/vulkan/BufferVk.cpp b/src/dawn/native/vulkan/BufferVk.cpp index 3764aee..12c0ed5 100644 --- a/src/dawn/native/vulkan/BufferVk.cpp +++ b/src/dawn/native/vulkan/BufferVk.cpp
@@ -195,7 +195,7 @@ size_t offset, size_t size, size_t nonCoherentAtomSize) { - DAWN_ASSERT(IsAligned(allocation.GetOffset(), nonCoherentAtomSize)); + DAWN_CHECK(IsAligned(allocation.GetOffset(), nonCoherentAtomSize)); // `offset` must always be a multiple of nonCoherentAtomSize. `size` must either be a multiple // of nonCoherentAtomSize or offset+size must be equal to the size of the allocation. @@ -629,7 +629,7 @@ void* Buffer::GetMappedPointerImpl() { uint8_t* memory = mMemoryAllocation.GetMappedPointer(); - DAWN_ASSERT(memory != nullptr); + DAWN_CHECK(memory != nullptr); return memory; } @@ -665,7 +665,7 @@ return MapMemoryAndPerformOperation(mapOffset, mapSize, [&](std::span<uint8_t> mapped) { uint64_t dstOffset = 0; if (needsZeroInitialization) { - DAWN_ASSERT(mapped.size() == mAllocatedSize); + DAWN_CHECK(mapped.size() == mAllocatedSize); std::ranges::fill(mapped, 0x0); GetDevice()->IncrementLazyClearCountForTesting(); dstOffset = bufferOffset; @@ -674,7 +674,7 @@ // above or memcpy below. SetInitialized(true); - DAWN_ASSERT(mapped.size() >= dstOffset + size); + DAWN_CHECK(mapped.size() >= dstOffset + size); memcpy(mapped.data() + dstOffset, data, size); }); } @@ -686,8 +686,8 @@ Device* device = ToBackend(GetDevice()); const bool isMappable = GetInternalUsage() & kMappableBufferUsages; - DAWN_ASSERT(mHostVisible); - DAWN_ASSERT(GetLastUsageSerial() <= device->GetQueue()->GetCompletedCommandSerial()); + DAWN_CHECK(mHostVisible); + DAWN_CHECK(GetLastUsageSerial() <= device->GetQueue()->GetCompletedCommandSerial()); VkDeviceMemory deviceMemory = ToBackend(mMemoryAllocation.GetResourceHeap())->GetMemory(); uint8_t* memory = nullptr; @@ -831,7 +831,7 @@ void Buffer::TransitionMappableBuffersEagerly(Device* device, CommandRecordingContext* recordingContext, const absl::flat_hash_set<Ref<Buffer>>& buffers) { - DAWN_ASSERT(!buffers.empty()); + DAWN_CHECK(!buffers.empty()); size_t originalBufferCount = buffers.size(); @@ -841,7 +841,7 @@ barrier.Merge(buffer->TrackUsageAndGetResourceBarrier(mapUsage, wgpu::ShaderStage::None)); } // TrackUsageAndGetResourceBarrier() should not modify recordingContext for map usages. - DAWN_ASSERT(buffers.size() == originalBufferCount); + DAWN_CHECK(buffers.size() == originalBufferCount); recordingContext->EmitBufferBarrierIfNecessary(device, barrier); } @@ -851,7 +851,7 @@ } void Buffer::InitializeToZero(CommandRecordingContext* recordingContext) { - DAWN_ASSERT(NeedsInitialization()); + DAWN_CHECK(NeedsInitialization()); ClearBuffer(recordingContext, 0u); GetDevice()->IncrementLazyClearCountForTesting(); @@ -862,16 +862,16 @@ uint32_t clearValue, uint64_t offset, uint64_t size) { - DAWN_ASSERT(recordingContext != nullptr); + DAWN_CHECK(recordingContext != nullptr); size = size > 0 ? size : GetAllocatedSize(); - DAWN_ASSERT(size > 0); + DAWN_CHECK(size > 0); TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst); Device* device = ToBackend(GetDevice()); // VK_WHOLE_SIZE doesn't work on old Windows Intel Vulkan drivers, so we don't use it. // Note: Allocated size must be a multiple of 4. - DAWN_ASSERT(size % 4 == 0); + DAWN_CHECK(size % 4 == 0); device->fn.CmdFillBuffer(recordingContext->commandBuffer, mHandle, offset, size, clearValue); }
diff --git a/src/dawn/native/vulkan/CommandBufferVk.cpp b/src/dawn/native/vulkan/CommandBufferVk.cpp index 60438f4..690a1f2 100644 --- a/src/dawn/native/vulkan/CommandBufferVk.cpp +++ b/src/dawn/native/vulkan/CommandBufferVk.cpp
@@ -151,7 +151,7 @@ break; } - DAWN_ASSERT(HasSameTextureCopyExtent(srcCopy, dstCopy, copySize)); + DAWN_CHECK(HasSameTextureCopyExtent(srcCopy, dstCopy, copySize)); TexelExtent3D imageExtent = ComputeTextureCopyExtent(dstCopy, copySize); region.extent.width = static_cast<uint32_t>(imageExtent.width); region.extent.height = static_cast<uint32_t>(imageExtent.height); @@ -309,7 +309,7 @@ void DirtyAll() { this->mDirty.set(); } void Apply(const VulkanFunctions& vk, VkCommandBuffer commandBuffer) { - DAWN_ASSERT(this->mLastPipeline != nullptr); + DAWN_CHECK(this->mLastPipeline != nullptr); Apply(vk, commandBuffer, ToBackend(this->mLastPipeline)->GetVkLayout(), this->mLastPipeline->GetImmediateMask()); } @@ -450,7 +450,7 @@ VkCommandBuffer commands, QuerySetBase* querySet, const std::vector<bool>& availability) { - DAWN_ASSERT(availability.size() == querySet->GetQueryAvailability().size()); + DAWN_CHECK(availability.size() == querySet->GetQueryAvailability().size()); auto currentIt = availability.begin(); auto lastIt = availability.end(); @@ -625,11 +625,11 @@ const auto& bindingInfo = etBindGroup->GetLayout()->GetAPIBindingInfo(etBindPoint.binding); const auto& etInfo = std::get<ExternalTextureBindingInfo>(bindingInfo.bindingLayout); - DAWN_ASSERT(etInfo.staticSampler.has_value()); + DAWN_CHECK(etInfo.staticSampler.has_value()); const TextureView* view = ToBackend(etBindGroup->GetBindingAsTextureView(etInfo.plane0)); - DAWN_ASSERT(view != nullptr); + DAWN_CHECK(view != nullptr); // Use static samplers for YCbCr external textures. However when the toggle is enabled, // we use a static sampler for all the single-planar external textures, which helps with @@ -668,8 +668,8 @@ DirtyAll(); // At the moment the only specialization is for using static samplers in ExternalTextures. - DAWN_ASSERT(lastPipeline->GetDevice()->NeedsStaticSamplerForExternalTexture() && - lastPipeline->GetLayout()->HasExternalTextures()); + DAWN_CHECK(lastPipeline->GetDevice()->NeedsStaticSamplerForExternalTexture() && + lastPipeline->GetLayout()->HasExternalTextures()); PipelineSpecialization specialization = ComputeSpecializationBaseOnState(); // Recreate the descriptor sets using the specialized VkDescriptorSetLayout. @@ -816,7 +816,7 @@ if (renderPass->attachmentState->HasDepthStencilAttachment()) { const auto& attachmentInfo = renderPass->depthStencilAttachment; TextureView* view = ToBackend(attachmentInfo.view.Get()); - DAWN_ASSERT(view); + DAWN_CHECK(view); const Format& dsFormat = view->GetTexture()->GetFormat(); VkImageLayout imageLayout = VulkanImageLayoutForDepthStencilAttachment( @@ -1020,8 +1020,8 @@ const TextureCopy& srcCopy, const TextureCopy& dstCopy, const TexelExtent3D& texelCopySize) { - DAWN_ASSERT(srcCopy.texture->GetFormat().CopyCompatibleWith(dstCopy.texture->GetFormat())); - DAWN_ASSERT(srcCopy.aspect == dstCopy.aspect); + DAWN_CHECK(srcCopy.texture->GetFormat().CopyCompatibleWith(dstCopy.texture->GetFormat())); + DAWN_CHECK(srcCopy.aspect == dstCopy.aspect); const TypedTexelBlockInfo& blockInfo = GetBlockInfo(srcCopy); const BlockExtent3D copySize = blockInfo.ToBlock(texelCopySize); BlockCount widthInBlocks = copySize.width; @@ -1237,9 +1237,9 @@ // When there are overlapped subresources, the layout of the overlapped // subresources should all be GENERAL instead of what we set now. Currently // it is not allowed to copy with overlapped subresources, but we still - // add the DAWN_ASSERT here as a reminder for this possible misuse. - DAWN_ASSERT(!IsRangeOverlapped(src.origin.z, dst.origin.z, - copy->copySize.depthOrArrayLayers)); + // add the DAWN_CHECK here as a reminder for this possible misuse. + DAWN_CHECK(!IsRangeOverlapped(src.origin.z, dst.origin.z, + copy->copySize.depthOrArrayLayers)); } ToBackend(src.texture) @@ -1637,7 +1637,7 @@ case Command::SetImmediates: { SetImmediatesCmd* cmd = mCommands.NextCommand<SetImmediatesCmd>(); - DAWN_ASSERT(cmd->size > 0); + DAWN_CHECK(cmd->size > 0); uint8_t* value = nullptr; value = mCommands.NextData<uint8_t>(cmd->size); state.immediates.SetImmediates(cmd->offset, value, cmd->size); @@ -1911,7 +1911,7 @@ case Command::SetImmediates: { SetImmediatesCmd* cmd = iter->NextCommand<SetImmediatesCmd>(); - DAWN_ASSERT(cmd->size > 0); + DAWN_CHECK(cmd->size > 0); uint8_t* value = nullptr; value = iter->NextData<uint8_t>(cmd->size); state.immediates.SetImmediates(cmd->offset, value, cmd->size);
diff --git a/src/dawn/native/vulkan/DescriptorSetAllocator.cpp b/src/dawn/native/vulkan/DescriptorSetAllocator.cpp index c81d6b7..6c83bf4 100644 --- a/src/dawn/native/vulkan/DescriptorSetAllocator.cpp +++ b/src/dawn/native/vulkan/DescriptorSetAllocator.cpp
@@ -68,7 +68,7 @@ // that at least one descriptor set can be made (bindings with visibility none can force giant // sets to be made). mMaxSets = std::max(kMaxDescriptorsPerPool / totalDescriptorCount, 1u); - DAWN_ASSERT(mMaxSets > 0); + DAWN_CHECK(mMaxSets > 0); // Grow the number of descriptors in the pool to fit the computed |mMaxSets|. for (auto& poolSize : mPoolSizes) { @@ -93,12 +93,12 @@ DAWN_TRY(AllocateDescriptorPool(dsLayout)); } - DAWN_ASSERT(!mAvailableDescriptorPoolIndices.empty()); + DAWN_CHECK(!mAvailableDescriptorPoolIndices.empty()); const PoolIndex poolIndex = mAvailableDescriptorPoolIndices.back(); DescriptorPool* pool = &mDescriptorPools[poolIndex]; - DAWN_ASSERT(!pool->freeSetIndices.empty()); + DAWN_CHECK(!pool->freeSetIndices.empty()); SetIndex setIndex = pool->freeSetIndices.back(); pool->freeSetIndices.pop_back(); @@ -117,7 +117,7 @@ Mutex::AutoLock lock(&mMutex); DAWN_ASSERT(allocationInfo != nullptr); - DAWN_ASSERT(allocationInfo->set != VK_NULL_HANDLE); + DAWN_CHECK(allocationInfo->set != VK_NULL_HANDLE); // We can't reuse the descriptor set right away because the Vulkan spec says in the // documentation for vkCmdBindDescriptorSets that the set may be consumed any time between @@ -148,7 +148,7 @@ Mutex::AutoLock lock(&mMutex); for (const Deallocation& dealloc : mPendingDeallocations.IterateUpTo(completedSerial)) { - DAWN_ASSERT(dealloc.poolIndex < mDescriptorPools.size()); + DAWN_CHECK(dealloc.poolIndex < mDescriptorPools.size()); auto& freeSetIndices = mDescriptorPools[dealloc.poolIndex].freeSetIndices; if (freeSetIndices.empty()) {
diff --git a/src/dawn/native/vulkan/DeviceVk.cpp b/src/dawn/native/vulkan/DeviceVk.cpp index 1fe3dbc..08e7872 100644 --- a/src/dawn/native/vulkan/DeviceVk.cpp +++ b/src/dawn/native/vulkan/DeviceVk.cpp
@@ -397,7 +397,7 @@ } const VkDescriptorSetLayout& Device::GetResourceTableLayout() const { - DAWN_ASSERT(HasFeature(Feature::ChromiumExperimentalSamplingResourceTable)); + DAWN_CHECK(HasFeature(Feature::ChromiumExperimentalSamplingResourceTable)); return mResourceTableLayout; } @@ -471,7 +471,7 @@ // tight bounds checking when enabled on buffers (instead of potentially extending by 16 // bytes or a vertex stride). It also exposes driver support for image robustness. if (mDeviceInfo.HasExt(DeviceExt::Robustness2)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::Robustness2)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::Robustness2)); usedKnobs.robustness2Features = mDeviceInfo.robustness2Features; featuresChain.Add(&usedKnobs.robustness2Features); @@ -479,7 +479,7 @@ // Enable pipelineRobustness to better control where robustness happens. if (mDeviceInfo.HasExt(DeviceExt::PipelineRobustness)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::PipelineRobustness)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::PipelineRobustness)); usedKnobs.pipelineRobustnessFeatures = mDeviceInfo.pipelineRobustnessFeatures; featuresChain.Add(&usedKnobs.pipelineRobustnessFeatures); @@ -493,14 +493,14 @@ usedKnobs.features.robustBufferAccess = VK_FALSE; usedKnobs.robustness2Features.robustBufferAccess2 = VK_FALSE; - DAWN_ASSERT(!IsToggleEnabled(Toggle::VulkanUseBufferRobustAccess2)); - DAWN_ASSERT(mDeviceInfo.HasExt(DeviceExt::PipelineRobustness) && - mDeviceInfo.pipelineRobustnessFeatures.pipelineRobustness); + DAWN_CHECK(!IsToggleEnabled(Toggle::VulkanUseBufferRobustAccess2)); + DAWN_CHECK(mDeviceInfo.HasExt(DeviceExt::PipelineRobustness) && + mDeviceInfo.pipelineRobustnessFeatures.pipelineRobustness); } } if (mDeviceInfo.HasExt(DeviceExt::SubgroupSizeControl)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::SubgroupSizeControl)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::SubgroupSizeControl)); // Always request all the features from VK_EXT_subgroup_size_control when available. usedKnobs.subgroupSizeControlFeatures = mDeviceInfo.subgroupSizeControlFeatures; @@ -508,7 +508,7 @@ } if (mDeviceInfo.HasExt(DeviceExt::ZeroInitializeWorkgroupMemory)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::ZeroInitializeWorkgroupMemory)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::ZeroInitializeWorkgroupMemory)); // Always allow initializing workgroup memory with OpConstantNull when available. // Note that the driver still won't initialize workgroup memory unless the workgroup @@ -519,13 +519,13 @@ } if (mDeviceInfo.HasExt(DeviceExt::DemoteToHelperInvocation)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::DemoteToHelperInvocation)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::DemoteToHelperInvocation)); usedKnobs.demoteToHelperInvocationFeatures = mDeviceInfo.demoteToHelperInvocationFeatures; featuresChain.Add(&usedKnobs.demoteToHelperInvocationFeatures); } if (mDeviceInfo.HasExt(DeviceExt::ShaderIntegerDotProduct)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::ShaderIntegerDotProduct)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::ShaderIntegerDotProduct)); usedKnobs.shaderIntegerDotProductFeatures = mDeviceInfo.shaderIntegerDotProductFeatures; featuresChain.Add(&usedKnobs.shaderIntegerDotProductFeatures); @@ -536,23 +536,23 @@ } if (IsToggleEnabled(Toggle::UseVulkanMemoryModel)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::VulkanMemoryModel)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::VulkanMemoryModel)); usedKnobs.vulkanMemoryModelFeatures = mDeviceInfo.vulkanMemoryModelFeatures; featuresChain.Add(&usedKnobs.vulkanMemoryModelFeatures); } if (HasFeature(Feature::TextureCompressionBC)) { - DAWN_ASSERT(mDeviceInfo.features.textureCompressionBC == VK_TRUE); + DAWN_CHECK(mDeviceInfo.features.textureCompressionBC == VK_TRUE); usedKnobs.features.textureCompressionBC = VK_TRUE; } if (HasFeature(Feature::TextureCompressionETC2)) { - DAWN_ASSERT(mDeviceInfo.features.textureCompressionETC2 == VK_TRUE); + DAWN_CHECK(mDeviceInfo.features.textureCompressionETC2 == VK_TRUE); usedKnobs.features.textureCompressionETC2 = VK_TRUE; } if (HasFeature(Feature::TextureCompressionASTC)) { - DAWN_ASSERT(mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE); + DAWN_CHECK(mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE); usedKnobs.features.textureCompressionASTC_LDR = VK_TRUE; } @@ -561,18 +561,18 @@ } if (HasFeature(Feature::PrimitiveIndex)) { - DAWN_ASSERT(mDeviceInfo.features.geometryShader == VK_TRUE); + DAWN_CHECK(mDeviceInfo.features.geometryShader == VK_TRUE); usedKnobs.features.geometryShader = VK_TRUE; } bool shaderFloat16Int8FeaturesAdded = false; if (HasFeature(Feature::ShaderF16)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::ShaderFloat16Int8) && - mDeviceInfo.shaderFloat16Int8Features.shaderFloat16 == VK_TRUE && - mDeviceInfo._16BitStorageFeatures.storageBuffer16BitAccess == VK_TRUE); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::ShaderFloat16Int8) && + mDeviceInfo.shaderFloat16Int8Features.shaderFloat16 == VK_TRUE && + mDeviceInfo._16BitStorageFeatures.storageBuffer16BitAccess == VK_TRUE); if (!IsToggleEnabled(Toggle::DecomposeUniformBuffers)) { - DAWN_ASSERT(mDeviceInfo._16BitStorageFeatures.uniformAndStorageBuffer16BitAccess == - VK_TRUE); + DAWN_CHECK(mDeviceInfo._16BitStorageFeatures.uniformAndStorageBuffer16BitAccess == + VK_TRUE); } usedKnobs.shaderFloat16Int8Features.shaderFloat16 = VK_TRUE; @@ -593,8 +593,8 @@ // Set device feature for subgroups with f16 types. if (HasFeature(Feature::ShaderF16) && HasFeature(Feature::Subgroups)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::ShaderSubgroupExtendedTypes) && - mDeviceInfo.shaderSubgroupExtendedTypes.shaderSubgroupExtendedTypes == VK_TRUE); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::ShaderSubgroupExtendedTypes) && + mDeviceInfo.shaderSubgroupExtendedTypes.shaderSubgroupExtendedTypes == VK_TRUE); usedKnobs.shaderSubgroupExtendedTypes = mDeviceInfo.shaderSubgroupExtendedTypes; featuresChain.Add(&usedKnobs.shaderSubgroupExtendedTypes); @@ -627,14 +627,14 @@ } if (HasFeature(Feature::MultiDrawIndirect)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::DrawIndirectCount) && - mDeviceInfo.features.multiDrawIndirect == VK_TRUE); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::DrawIndirectCount) && + mDeviceInfo.features.multiDrawIndirect == VK_TRUE); usedKnobs.features.multiDrawIndirect = VK_TRUE; } if (HasFeature(Feature::ChromiumExperimentalSubgroupMatrix)) { - DAWN_ASSERT(IsToggleEnabled(Toggle::UseVulkanMemoryModel)); - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::CooperativeMatrix)); + DAWN_CHECK(IsToggleEnabled(Toggle::UseVulkanMemoryModel)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::CooperativeMatrix)); usedKnobs.cooperativeMatrixFeatures = mDeviceInfo.cooperativeMatrixFeatures; featuresChain.Add(&usedKnobs.cooperativeMatrixFeatures); @@ -661,7 +661,7 @@ // by the Dynamic Rendering path. if (IsToggleEnabled(Toggle::VulkanUseDynamicRendering) && !HasFeature(Feature::DawnLoadResolveTexture)) { - DAWN_ASSERT(usedKnobs.HasExt(DeviceExt::DynamicRendering)); + DAWN_CHECK(usedKnobs.HasExt(DeviceExt::DynamicRendering)); usedKnobs.dynamicRenderingFeatures = mDeviceInfo.dynamicRenderingFeatures; featuresChain.Add(&usedKnobs.dynamicRenderingFeatures); mRenderPassType = VulkanRenderPassType::DynamicRendering; @@ -748,7 +748,7 @@ uint64_t size) { // It is a validation error to do a 0-sized copy in Vulkan, check it is skipped prior to // calling this function. - DAWN_ASSERT(size != 0); + DAWN_CHECK(size != 0); CommandRecordingContext* recordingContext = ToBackend(GetQueue())->GetPendingRecordingContext(Queue::SubmitMode::Passive); @@ -996,7 +996,7 @@ } void Device::DestroyImpl(DestroyReason reason) { - DAWN_ASSERT(GetState() == State::Disconnected); + DAWN_CHECK(GetState() == State::Disconnected); // We failed during initialization so early that we don't even have a VkDevice. There is // nothing to do. @@ -1062,7 +1062,7 @@ // VkQueues are destroyed when the VkDevice is destroyed // The VkDevice is needed to destroy child objects, so it must be destroyed last after all // child objects have been deleted. - DAWN_ASSERT(mVkDevice != VK_NULL_HANDLE); + DAWN_CHECK(mVkDevice != VK_NULL_HANDLE); fn.DestroyDevice(mVkDevice, nullptr); mVkDevice = VK_NULL_HANDLE;
diff --git a/src/dawn/native/vulkan/RenderPipelineVk.cpp b/src/dawn/native/vulkan/RenderPipelineVk.cpp index ed4727de..e055c5e 100644 --- a/src/dawn/native/vulkan/RenderPipelineVk.cpp +++ b/src/dawn/native/vulkan/RenderPipelineVk.cpp
@@ -343,10 +343,10 @@ uint16_t PackStencilOpState(VkStencilOpState state, VkBool32 enabled) { // Both VkStencilOp and VkCompareOp have values ranging from 0-7, so they fit in 3 bits. // So we can encode the full dynamic stencil state in 12 bits. - DAWN_ASSERT(static_cast<uint32_t>(state.failOp) < 8); - DAWN_ASSERT(static_cast<uint32_t>(state.passOp) < 8); - DAWN_ASSERT(static_cast<uint32_t>(state.depthFailOp) < 8); - DAWN_ASSERT(static_cast<uint32_t>(state.compareOp) < 8); + DAWN_CHECK(static_cast<uint32_t>(state.failOp) < 8); + DAWN_CHECK(static_cast<uint32_t>(state.passOp) < 8); + DAWN_CHECK(static_cast<uint32_t>(state.depthFailOp) < 8); + DAWN_CHECK(static_cast<uint32_t>(state.compareOp) < 8); uint16_t packed = state.failOp | state.passOp << 3 | state.depthFailOp << 6 | state.compareOp << 9 | (enabled ? 0x8000 : 0); // Set high bit if stencil is enabled. @@ -399,7 +399,7 @@ } if (GetDevice()->NeedsStaticSamplerForExternalTexture() && GetLayout()->HasExternalTextures()) { - DAWN_ASSERT(!GetLayout()->HasAPIStaticSamplers()); + DAWN_CHECK(!GetLayout()->HasAPIStaticSamplers()); mRequiresSpecialization = true; } @@ -567,7 +567,7 @@ // VkPipelineMultisampleStateCreateInfo.pSampleMask is an array of length // ceil(rasterizationSamples / 32) and since we're passing a single uint32_t // we have to assert that this length is indeed 1. - DAWN_ASSERT(multisample.rasterizationSamples <= 32); + DAWN_CHECK(multisample.rasterizationSamples <= 32); VkSampleMask sampleMask = GetSampleMask(); multisample.pSampleMask = &sampleMask; multisample.alphaToCoverageEnable = IsAlphaToCoverageEnabled() ? VK_TRUE : VK_FALSE; @@ -1016,12 +1016,12 @@ } VkPipeline RenderPipeline::GetHandle() const { - DAWN_ASSERT(mHandles.pipeline != VK_NULL_HANDLE); + DAWN_CHECK(mHandles.pipeline != VK_NULL_HANDLE); return mHandles.pipeline; } VkPipelineLayout RenderPipeline::GetVkLayout() const { - DAWN_ASSERT(mHandles.layout != nullptr); + DAWN_CHECK(mHandles.layout != nullptr); return mHandles.layout; }
diff --git a/src/dawn/native/vulkan/TextureVk.cpp b/src/dawn/native/vulkan/TextureVk.cpp index 2cc076c..74219ee 100644 --- a/src/dawn/native/vulkan/TextureVk.cpp +++ b/src/dawn/native/vulkan/TextureVk.cpp
@@ -96,10 +96,10 @@ // check if we are in one of the RenderAttachment + (ReadOnlyAttachment|readonly usage) cases // and know only the aspect with the readonly attachment might contain extra usages like // TextureBinding. - DAWN_ASSERT(depth == wgpu::TextureUsage::RenderAttachment || - IsSubset(depth, ~wgpu::TextureUsage::RenderAttachment)); - DAWN_ASSERT(stencil == wgpu::TextureUsage::RenderAttachment || - IsSubset(stencil, ~wgpu::TextureUsage::RenderAttachment)); + DAWN_CHECK(depth == wgpu::TextureUsage::RenderAttachment || + IsSubset(depth, ~wgpu::TextureUsage::RenderAttachment)); + DAWN_CHECK(stencil == wgpu::TextureUsage::RenderAttachment || + IsSubset(stencil, ~wgpu::TextureUsage::RenderAttachment)); if (depth == wgpu::TextureUsage::RenderAttachment && stencil & kReadOnlyRenderAttachment) { return kDepthWritableStencilReadOnlyAttachment | (stencil & ~kReadOnlyRenderAttachment); @@ -119,8 +119,8 @@ VkAccessFlags VulkanAccessFlags(wgpu::TextureUsage usage, const Format& format) { if (usage & kReservedTextureUsage) { // Handle the special readonly usages for mixed depth-stencil. - DAWN_ASSERT(IsSubset(kDepthReadOnlyStencilWritableAttachment, usage) || - IsSubset(kDepthWritableStencilReadOnlyAttachment, usage)); + DAWN_CHECK(IsSubset(kDepthReadOnlyStencilWritableAttachment, usage) || + IsSubset(kDepthWritableStencilReadOnlyAttachment, usage)); // Add any additional access flags for the non-attachment part of the usage. const wgpu::TextureUsage nonAttachmentUsages = @@ -170,7 +170,7 @@ if (usage & kPresentAcquireTextureUsage) { // The present acquire usage is only used internally by the swapchain and is never used in // combination with other usages. - DAWN_ASSERT(usage == kPresentAcquireTextureUsage); + DAWN_CHECK(usage == kPresentAcquireTextureUsage); // The Vulkan spec has the following note: // // When the presentable image will be accessed by some stage S, the recommended idiom @@ -190,7 +190,7 @@ if (usage & kPresentReleaseTextureUsage) { // The present release usage is only used internally by the swapchain and is never used in // combination with other usages. - DAWN_ASSERT(usage == kPresentReleaseTextureUsage); + DAWN_CHECK(usage == kPresentReleaseTextureUsage); // The Vulkan spec has the following note: // // When transitioning the image to VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR or @@ -215,8 +215,8 @@ const Format& format) { if (usage & kReservedTextureUsage) { // Handle the special readonly usages for mixed depth-stencil. - DAWN_ASSERT(IsSubset(kDepthReadOnlyStencilWritableAttachment, usage) || - IsSubset(kDepthWritableStencilReadOnlyAttachment, usage)); + DAWN_CHECK(IsSubset(kDepthReadOnlyStencilWritableAttachment, usage) || + IsSubset(kDepthWritableStencilReadOnlyAttachment, usage)); // Convert all the reserved attachment usages into just RenderAttachment. const wgpu::TextureUsage nonAttachmentUsages = @@ -267,7 +267,7 @@ if (usage & kPresentAcquireTextureUsage) { // The present acquire usage is only used internally by the swapchain and is never used in // combination with other usages. - DAWN_ASSERT(usage == kPresentAcquireTextureUsage); + DAWN_CHECK(usage == kPresentAcquireTextureUsage); // The vkAcquireNextImageKHR method is a read operation in Vulkan which completes // before the semaphore/fence out parameters are signaled. This means that future uses // of the texture must performs a memory barriers that synchronizes with that @@ -291,7 +291,7 @@ if (usage & kPresentReleaseTextureUsage) { // The present release usage is only used internally by the swapchain and is never used in // combination with other usages. - DAWN_ASSERT(usage == kPresentReleaseTextureUsage); + DAWN_CHECK(usage == kPresentReleaseTextureUsage); // The Vulkan spec has the following note: // // When transitioning the image to VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR or @@ -308,7 +308,7 @@ } // A zero value isn't a valid pipeline stage mask - DAWN_ASSERT(flags != 0); + DAWN_CHECK(flags != 0); return flags; } @@ -669,8 +669,7 @@ } if (usage & wgpu::TextureUsage::StorageBinding) { // Storage bit should only be included if the format actually supports a storage uage. - DAWN_ASSERT(format.SupportsReadOnlyStorageUsage() || - format.SupportsWriteOnlyStorageUsage()); + DAWN_CHECK(format.SupportsReadOnlyStorageUsage() || format.SupportsWriteOnlyStorageUsage()); flags |= VK_IMAGE_USAGE_STORAGE_BIT; } if (usage & wgpu::TextureUsage::RenderAttachment) { @@ -692,7 +691,7 @@ // Choosing Vulkan image usages should not know about kReadOnlyRenderAttachment because that's // a property of when the image is used, not of the creation. - DAWN_ASSERT(!(usage & kReadOnlyRenderAttachment)); + DAWN_CHECK(!(usage & kReadOnlyRenderAttachment)); return flags; } @@ -736,10 +735,10 @@ // if more appear we will need additional special-casing. if (format.HasDepthOrStencil()) { - DAWN_ASSERT(IsSubset(usage, wgpu::TextureUsage::TextureBinding | - kDepthReadOnlyStencilWritableAttachment | - kDepthWritableStencilReadOnlyAttachment | - kReadOnlyRenderAttachment)); + DAWN_CHECK(IsSubset(usage, wgpu::TextureUsage::TextureBinding | + kDepthReadOnlyStencilWritableAttachment | + kDepthWritableStencilReadOnlyAttachment | + kReadOnlyRenderAttachment)); if (IsSubset(kDepthReadOnlyStencilWritableAttachment, usage)) { return VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL; @@ -751,7 +750,7 @@ DAWN_UNREACHABLE(); } else { - DAWN_ASSERT( + DAWN_CHECK( IsSubset(usage, wgpu::TextureUsage::TextureBinding | kReadOnlyStorageTexture)); if (usage & kReadOnlyStorageTexture) { @@ -881,7 +880,7 @@ bool IsSampleCountSupported(const dawn::native::vulkan::Device* device, const VkImageCreateInfo& imageCreateInfo) { - DAWN_ASSERT(device); + DAWN_CHECK(device); VkPhysicalDevice vkPhysicalDevice = ToBackend(device->GetPhysicalDevice())->GetVkPhysicalDevice(); @@ -1009,7 +1008,7 @@ combinedInfo->usage = MergeDepthStencilUsage(combinedInfo->usage, syncInfo.usage); } else { - DAWN_ASSERT(aspectsToMerge == (Aspect::Depth | Aspect::Stencil)); + DAWN_CHECK(aspectsToMerge == (Aspect::Depth | Aspect::Stencil)); combinedInfo->usage = syncInfo.usage; } combinedInfo->shaderStages |= syncInfo.shaderStages; @@ -1108,7 +1107,7 @@ TweakTransition(recordingContext, &barriers, 0); if (!barriers.empty()) { - DAWN_ASSERT(srcStages != 0 && dstStages != 0); + DAWN_CHECK(srcStages != 0 && dstStages != 0); ToBackend(GetDevice()) ->fn.CmdPipelineBarrier(recordingContext->commandBuffer, srcStages, dstStages, 0, 0, nullptr, 0, nullptr, barriers.size(), barriers.data()); @@ -1153,7 +1152,7 @@ std::vector<VkImageMemoryBarrier>* imageBarriers, VkPipelineStageFlags* srcStages, VkPipelineStageFlags* dstStages) { - DAWN_ASSERT(imageBarriers != nullptr); + DAWN_CHECK(imageBarriers != nullptr); const Format& format = GetFormat(); if (shaderStages == wgpu::ShaderStage::None) { @@ -1247,7 +1246,7 @@ case wgpu::TextureDimension::e3D: viewDesc.dimension = wgpu::TextureViewDimension::e3D; depthSliceCount = mipSize.depthOrArrayLayers; - DAWN_ASSERT(layer == 0); + DAWN_CHECK(layer == 0); break; case wgpu::TextureDimension::e1D: case wgpu::TextureDimension::Undefined: @@ -1338,8 +1337,8 @@ range); // need to clear the texture with a copy from buffer - DAWN_ASSERT(range.aspects == Aspect::Color || range.aspects == Aspect::Plane0 || - range.aspects == Aspect::Plane1 || range.aspects == Aspect::Plane2); + DAWN_CHECK(range.aspects == Aspect::Color || range.aspects == Aspect::Plane0 || + range.aspects == Aspect::Plane1 || range.aspects == Aspect::Plane2); const TypedTexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(range.aspects).block; BlockExtent3D largestMipSize = blockInfo.ToBlock( @@ -1406,7 +1405,7 @@ // Pinning means that until unpinned, the texture will have specific usage and can be used // freely in shaders without any further check or memory barrier tracking. Ensure all // subresources are cleared and transitioned to the usage. - DAWN_ASSERT(!HasPinnedUsage()); + DAWN_CHECK(!HasPinnedUsage()); SubresourceRange pinnedSubresources = GetAllSubresources(); CommandRecordingContext* recordingContext = @@ -1422,7 +1421,7 @@ } void Texture::UnpinImpl() { - DAWN_ASSERT(HasPinnedUsage()); + DAWN_CHECK(HasPinnedUsage()); // TODO(https://issues.chromium.org/473444516): Investigate what to do for imported textures. // Should we consider a pin/unpin pair similar to an access on a queue such that we need to @@ -1445,7 +1444,7 @@ VkImageLayout Texture::GetCurrentLayout(Aspect aspect, uint32_t arrayLayer, uint32_t mipLevel) const { - DAWN_ASSERT(GetFormat().aspects == Aspect::Color); + DAWN_CHECK(GetFormat().aspects == Aspect::Color); return VulkanImageLayout(mSubresourceLastSyncInfos.Get(aspect, arrayLayer, mipLevel).usage); } @@ -1491,7 +1490,7 @@ // If this triggers, it means it's time to add tests and implement support for readonly // depth-stencil attachments that are also used as readonly storage bindings in the pass. // Have fun! :) - DAWN_ASSERT( + DAWN_CHECK( !(GetFormat().HasDepthOrStencil() && (GetUsage() & wgpu::TextureUsage::StorageBinding))); // Create the Vulkan image "container". We don't need to check that the format supports the @@ -1693,7 +1692,7 @@ mExternalState = ExternalState::EagerlyTransitioned; // Get any usage, ideally the last one to do nothing - DAWN_ASSERT(GetNumMipLevels() == 1 && GetArrayLayers() == 1); + DAWN_CHECK(GetNumMipLevels() == 1 && GetArrayLayers() == 1); const SubresourceRange range = {GetDisjointVulkanAspects(), {0, 1}, {0, 1}}; const TextureSyncInfo syncInfo = mSubresourceLastSyncInfos.Get(range.aspects, 0, 0); @@ -1705,7 +1704,7 @@ TransitionUsageAndGetResourceBarrier(syncInfo.usage, syncInfo.shaderStages, range, &barriers, &srcStages, &dstStages); - DAWN_ASSERT(barriers.size() == 1); + DAWN_CHECK(barriers.size() == 1); VkImageMemoryBarrier& barrier = barriers[0]; // The barrier must be paired with another barrier that will specify the dst access mask on the // importing queue. @@ -1739,14 +1738,14 @@ void ImportedTextureBase::TweakTransition(CommandRecordingContext* recordingContext, std::vector<VkImageMemoryBarrier>* barriers, size_t transitionBarrierStart) { - DAWN_ASSERT(GetNumMipLevels() == 1 && GetArrayLayers() == 1); + DAWN_CHECK(GetNumMipLevels() == 1 && GetArrayLayers() == 1); mLastSharedTextureMemoryUsageSerial = GetDevice()->GetQueue()->GetPendingCommandSerial(); // transitionBarrierStart specify the index where barriers for current transition start in // the vector. barriers->size() - transitionBarrierStart is the number of barriers that we // have already added into the vector during current transition. - DAWN_ASSERT(barriers->size() - transitionBarrierStart <= 1); + DAWN_CHECK(barriers->size() - transitionBarrierStart <= 1); if (mExternalState == ExternalState::PendingAcquire || mExternalState == ExternalState::EagerlyTransitioned) { @@ -1827,7 +1826,7 @@ MaybeError ImportedTextureBase::EndAccess(ExternalSemaphoreHandle* handle, VkImageLayout* releasedOldLayout, VkImageLayout* releasedNewLayout) { - DAWN_ASSERT(GetNumMipLevels() == 1 && GetArrayLayers() == 1); + DAWN_CHECK(GetNumMipLevels() == 1 && GetArrayLayers() == 1); // Release the texture mExternalState = ExternalState::Released; @@ -1857,7 +1856,7 @@ currentLayout = targetLayout; } - DAWN_ASSERT(mExternalSemaphoreHandle != kNullExternalSemaphoreHandle); + DAWN_CHECK(mExternalSemaphoreHandle != kNullExternalSemaphoreHandle); // Write out the layouts and signal semaphore *releasedOldLayout = currentLayout; @@ -1955,7 +1954,7 @@ // the combined aspect without checking for disjoint support. // TODO(dawn:1548): Support multi-planar images with the DISJOINT feature and potentially allow // acting on planes individually? Always using Color is valid even for disjoint images. - DAWN_ASSERT(!GetFormat().IsMultiPlanar() || mCombinedAspect == Aspect::Color); + DAWN_CHECK(!GetFormat().IsMultiPlanar() || mCombinedAspect == Aspect::Color); mExternalState = ExternalState::PendingAcquire; mLastExternalState = ExternalState::Released; @@ -2087,7 +2086,7 @@ void SharedTexture::SetPendingAcquire(VkImageLayout pendingAcquireOldLayout, VkImageLayout pendingAcquireNewLayout) { - DAWN_ASSERT(GetSharedResourceMemoryContents() != nullptr); + DAWN_CHECK(GetSharedResourceMemoryContents() != nullptr); mExternalState = ExternalState::PendingAcquire; mLastExternalState = ExternalState::PendingAcquire; @@ -2104,7 +2103,7 @@ for (const auto& fence : fences) { // All semaphores are binary semaphores. - DAWN_ASSERT(fence.signaledValue == 1u); + DAWN_CHECK(fence.signaledValue == 1u); ExternalSemaphoreHandle semaphoreHandle = ToBackend(fence.object)->GetHandle().Get(); VkSemaphore semaphore; @@ -2162,7 +2161,7 @@ if (auto* yCbCrVkDescriptor = descriptor.Get<YCbCrVkDescriptor>()) { // The YCbCr conversion can be specified by the user with the YCbCrVulkanSamplers // feature. - DAWN_ASSERT(device->HasFeature(Feature::YCbCrVulkanSamplers)); + DAWN_CHECK(device->HasFeature(Feature::YCbCrVulkanSamplers)); yCbCr = yCbCrVkDescriptor->WithTrivialFrontendDefaults(); yCbCr.nextInChain = nullptr; @@ -2172,7 +2171,7 @@ // TODO(https://crbug.com/497675620): Specialize the conversion at the same time as all // the other state, in order to take advantage of hardware YCbCr to RGB conversion when // present. - DAWN_ASSERT(device->HasFeature(Feature::OpaqueYCbCrAndroidForExternalTexture)); + DAWN_CHECK(device->HasFeature(Feature::OpaqueYCbCrAndroidForExternalTexture)); yCbCr = StaticSamplerSpecialization::GetYCbCrForTextureView( static_cast<VkFormat>(stmContents->GetYCbCrVkDesc().vkFormat), @@ -2187,7 +2186,7 @@ samplerYCbCrInfo.conversion = mSamplerYCbCrConversion; createInfo.pNext = &samplerYCbCrInfo; } else { - DAWN_ASSERT(!descriptor.Has<YCbCrVkDescriptor>()); + DAWN_CHECK(!descriptor.Has<YCbCrVkDescriptor>()); } DAWN_TRY(CheckVkSuccess( @@ -2303,8 +2302,8 @@ } ResultOrError<VkImageView> TextureView::GetOrCreate2DViewOn3D(uint32_t depthSlice) { - DAWN_ASSERT(GetTexture()->GetDimension() == wgpu::TextureDimension::e3D); - DAWN_ASSERT(depthSlice < GetSingleSubresourceVirtualSize().depthOrArrayLayers); + DAWN_CHECK(GetTexture()->GetDimension() == wgpu::TextureDimension::e3D); + DAWN_CHECK(depthSlice < GetSingleSubresourceVirtualSize().depthOrArrayLayers); if (mHandlesFor2DViewOn3D.empty()) { mHandlesFor2DViewOn3D.resize(GetSingleSubresourceVirtualSize().depthOrArrayLayers); @@ -2329,7 +2328,7 @@ } bool TextureView::IsYCbCrFilterable() const { - DAWN_ASSERT(IsYCbCr()); + DAWN_CHECK(IsYCbCr()); return mIsYCbCrFilterable; }
diff --git a/src/dawn/native/vulkan/VulkanExtensions.cpp b/src/dawn/native/vulkan/VulkanExtensions.cpp index 0f20c15..88471a7 100644 --- a/src/dawn/native/vulkan/VulkanExtensions.cpp +++ b/src/dawn/native/vulkan/VulkanExtensions.cpp
@@ -57,8 +57,8 @@ const InstanceExtInfo& GetInstanceExtInfo(InstanceExt ext) { uint32_t index = static_cast<uint32_t>(ext); - DAWN_ASSERT(index < sInstanceExtInfos.size()); - DAWN_ASSERT(sInstanceExtInfos[index].index == ext); + DAWN_CHECK(index < sInstanceExtInfos.size()); + DAWN_CHECK(sInstanceExtInfos[index].index == ext); return sInstanceExtInfos[index]; } @@ -80,7 +80,7 @@ InstanceExtSet trimmedSet; auto HasDep = [&](InstanceExt ext) -> bool { - DAWN_ASSERT(visitedSet[ext]); + DAWN_CHECK(visitedSet[ext]); return trimmedSet[ext]; }; @@ -169,8 +169,8 @@ const DeviceExtInfo& GetDeviceExtInfo(DeviceExt ext) { uint32_t index = static_cast<uint32_t>(ext); - DAWN_ASSERT(index < sDeviceExtInfos.size()); - DAWN_ASSERT(sDeviceExtInfos[index].index == ext); + DAWN_CHECK(index < sDeviceExtInfos.size()); + DAWN_CHECK(sDeviceExtInfos[index].index == ext); return sDeviceExtInfos[index]; } @@ -191,10 +191,10 @@ DeviceExtSet trimmedSet; // Dawn requires at least Vulkan 1.1 - DAWN_ASSERT(version >= VK_API_VERSION_1_1); + DAWN_CHECK(version >= VK_API_VERSION_1_1); auto HasDep = [&](DeviceExt ext) -> bool { - DAWN_ASSERT(visitedSet[ext]); + DAWN_CHECK(visitedSet[ext]); return trimmedSet[ext]; }; @@ -306,8 +306,8 @@ const VulkanLayerInfo& GetVulkanLayerInfo(VulkanLayer layer) { uint32_t index = static_cast<uint32_t>(layer); - DAWN_ASSERT(index < sVulkanLayerInfos.size()); - DAWN_ASSERT(sVulkanLayerInfos[index].layer == layer); + DAWN_CHECK(index < sVulkanLayerInfos.size()); + DAWN_CHECK(sVulkanLayerInfos[index].layer == layer); return sVulkanLayerInfos[index]; }
diff --git a/src/dawn/native/webgpu/TextureWGPU.cpp b/src/dawn/native/webgpu/TextureWGPU.cpp index 996b23c..14bcf5c 100644 --- a/src/dawn/native/webgpu/TextureWGPU.cpp +++ b/src/dawn/native/webgpu/TextureWGPU.cpp
@@ -120,7 +120,7 @@ mInnerHandle = device->wgpu->deviceCreateTexture(device->GetInnerHandle(), &comboDesc.desc); - DAWN_ASSERT(mInnerHandle); + DAWN_CHECK(mInnerHandle); } Texture::Texture(Device* device, @@ -139,7 +139,7 @@ // to all platform and use that to indicate if it's a SwapChain texture (assigning // mIsSurfaceTexture) and mark frame boundary. - DAWN_ASSERT(mInnerHandle); + DAWN_CHECK(mInnerHandle); } Texture::Texture(Device* device, @@ -151,7 +151,7 @@ mInnerHandle = surfaceTexture.texture; mIsSurfaceTexture = true; - DAWN_ASSERT(mInnerHandle); + DAWN_CHECK(mInnerHandle); } void Texture::DestroyImpl(DestroyReason reason) { @@ -176,7 +176,7 @@ if (mPendingBeginAccess) { auto srm = contents->GetSharedResourceMemory().Promote(); - DAWN_ASSERT(srm != nullptr); + DAWN_CHECK(srm != nullptr); auto* stm = static_cast<SharedTextureMemory*>(srm.Get()); WGPUSharedTextureMemoryBeginAccessDescriptor innerDesc = @@ -199,7 +199,7 @@ const DawnProcTable& wgpu = ToBackend(GetDevice())->wgpu.get(); WGPUStatus status = wgpu.sharedTextureMemoryBeginAccess(stm->GetInnerHandle(), GetInnerHandle(), &innerDesc); - DAWN_ASSERT(status == WGPUStatus_Success); + DAWN_CHECK(status == WGPUStatus_Success); mPendingBeginAccess = false; } @@ -226,7 +226,7 @@ WGPUTextureView innerView = device->wgpu->textureCreateView(ToBackend(texture)->GetInnerHandle(), desc); - DAWN_ASSERT(innerView); + DAWN_CHECK(innerView); return AcquireRef(new TextureView(texture, descriptor, innerView)); } @@ -304,7 +304,7 @@ CaptureContext::kCopyBufferSize, innerCallbackInfo); wgpu->instanceWaitAny(device->GetInnerInstance(), 1, &waitInfo, UINT64_MAX); - DAWN_ASSERT(mapAsyncResult.status == WGPUMapAsyncStatus_Success); + DAWN_CHECK(mapAsyncResult.status == WGPUMapAsyncStatus_Success); if (mapAsyncResult.status != WGPUMapAsyncStatus_Success) { return DAWN_INTERNAL_ERROR(mapAsyncResult.message); @@ -363,7 +363,7 @@ // This is because there really is no size for depth24plus but it's conveniently // set to 4 in Format.cpp. The code below relies on this as it's going to use // r32float as a substitute for depth24plus and r32float has a size of 4. - DAWN_ASSERT(!IsDepthAspectDepth24Plus(format, aspect) || blockInfo.byteSize == 4); + DAWN_CHECK(!IsDepthAspectDepth24Plus(format, aspect) || blockInfo.byteSize == 4); // For each mip level copy the texture to a buffer, map it, and write the buffer data for // that level. @@ -401,7 +401,7 @@ uint32_t alignedBytesPerRow = Align(usedBytesPerRow, 256); BlockCount maxBlockRowsPerRead{CaptureContext::kCopyBufferSize / alignedBytesPerRow}; - DAWN_ASSERT(maxBlockRowsPerRead > BlockCount{0}); + DAWN_CHECK(maxBlockRowsPerRead > BlockCount{0}); for (BlockCount z{0}; z < blockSize.depthOrArrayLayers; ++z) { for (BlockCount y{0}; y < blockSize.height; y += maxBlockRowsPerRead) {