mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 22:56:09 +00:00
Add an internal ASSERT macro
This macro has some advantages over the standard library one: - It prints the place where the macro was triggered - It "references" the condition even in Release to avoid warnings - In release, if possible, it gives compiler hints It is basically is stripped down version of the ASSERT macros I wrote for the Daemon engine in src/common/Assert.h This commit also removes the stray "backend" namespaces for common/ code.
This commit is contained in:
committed by
Corentin Wallez
parent
bd0594bab8
commit
fd589f3919
@@ -18,6 +18,7 @@
|
||||
#include "backend/Buffer.h"
|
||||
#include "backend/Device.h"
|
||||
#include "backend/Texture.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "backend/Buffer.h"
|
||||
|
||||
#include "backend/Device.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
#include <utility>
|
||||
#include <cstdio>
|
||||
@@ -146,7 +147,7 @@ namespace backend {
|
||||
}
|
||||
|
||||
void BufferBase::UpdateUsageInternal(nxt::BufferUsageBit usage) {
|
||||
assert(IsTransitionPossible(usage));
|
||||
ASSERT(IsTransitionPossible(usage));
|
||||
currentUsage = usage;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "backend/Builder.h"
|
||||
|
||||
#include "backend/Device.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -14,13 +14,12 @@
|
||||
|
||||
#include "backend/CommandAllocator.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/Math.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#define ASSERT assert
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "backend/PipelineLayout.h"
|
||||
#include "backend/RenderPass.h"
|
||||
#include "backend/Texture.h"
|
||||
#include "common/Assert.h"
|
||||
#include "common/BitSetIterator.h"
|
||||
|
||||
namespace backend {
|
||||
@@ -487,7 +488,7 @@ namespace backend {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,8 @@
|
||||
#ifndef BACKEND_FORWARD_H_
|
||||
#define BACKEND_FORWARD_H_
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
#define ASSERT assert
|
||||
|
||||
namespace backend {
|
||||
|
||||
class BindGroupBase;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "backend/Device.h"
|
||||
#include "backend/RenderPass.h"
|
||||
#include "backend/Texture.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "backend/InputState.h"
|
||||
|
||||
#include "backend/Device.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
#ifndef BACKEND_PERSTAGE_H_
|
||||
#define BACKEND_PERSTAGE_H_
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/BitSetIterator.h"
|
||||
#include "common/Constants.h"
|
||||
|
||||
#include "nxt/nxtcpp.h"
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#define ASSERT assert
|
||||
|
||||
namespace backend {
|
||||
|
||||
@@ -43,22 +42,22 @@ namespace backend {
|
||||
class PerStage {
|
||||
public:
|
||||
T& operator[](nxt::ShaderStage stage) {
|
||||
ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
NXT_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
return data[static_cast<uint32_t>(stage)];
|
||||
}
|
||||
const T& operator[](nxt::ShaderStage stage) const {
|
||||
ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
NXT_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
|
||||
return data[static_cast<uint32_t>(stage)];
|
||||
}
|
||||
|
||||
T& operator[](nxt::ShaderStageBit stageBit) {
|
||||
uint32_t bit = static_cast<uint32_t>(stageBit);
|
||||
ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
NXT_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
return data[Log2(bit)];
|
||||
}
|
||||
const T& operator[](nxt::ShaderStageBit stageBit) const {
|
||||
uint32_t bit = static_cast<uint32_t>(stageBit);
|
||||
ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
NXT_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
return data[Log2(bit)];
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "backend/BindGroupLayout.h"
|
||||
#include "backend/Device.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
|
||||
#include "backend/RefCounted.h"
|
||||
|
||||
#include <cassert>
|
||||
#define ASSERT assert
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "backend/Buffer.h"
|
||||
#include "backend/Device.h"
|
||||
#include "backend/Texture.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "backend/Texture.h"
|
||||
|
||||
#include "backend/Device.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
@@ -88,7 +89,7 @@ namespace backend {
|
||||
}
|
||||
|
||||
void TextureBase::UpdateUsageInternal(nxt::TextureUsageBit usage) {
|
||||
assert(IsTransitionPossible(usage));
|
||||
ASSERT(IsTransitionPossible(usage));
|
||||
currentUsage = usage;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "backend/d3d12/D3D12Backend.h"
|
||||
#include "backend/d3d12/ResourceAllocator.h"
|
||||
#include "backend/d3d12/ResourceUploader.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
namespace d3d12 {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "backend/d3d12/D3D12Backend.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "common/BitSetIterator.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
#include "backend/d3d12/InputStateD3D12.h"
|
||||
#include "backend/d3d12/PipelineD3D12.h"
|
||||
#include "backend/d3d12/PipelineLayoutD3D12.h"
|
||||
#include "backend/d3d12/ResourceAllocator.h"
|
||||
#include "backend/d3d12/SamplerD3D12.h"
|
||||
#include "backend/d3d12/TextureD3D12.h"
|
||||
|
||||
#include "backend/d3d12/ResourceAllocator.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
namespace d3d12 {
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
#include "backend/d3d12/BindGroupD3D12.h"
|
||||
#include "backend/d3d12/BindGroupLayoutD3D12.h"
|
||||
#include "backend/d3d12/BufferD3D12.h"
|
||||
#include "backend/d3d12/CommandAllocatorManager.h"
|
||||
#include "backend/d3d12/CommandBufferD3D12.h"
|
||||
#include "backend/d3d12/DescriptorHeapAllocator.h"
|
||||
#include "backend/d3d12/InputStateD3D12.h"
|
||||
#include "backend/d3d12/PipelineD3D12.h"
|
||||
#include "backend/d3d12/PipelineLayoutD3D12.h"
|
||||
#include "backend/d3d12/QueueD3D12.h"
|
||||
#include "backend/d3d12/ResourceAllocator.h"
|
||||
#include "backend/d3d12/ResourceUploader.h"
|
||||
#include "backend/d3d12/SamplerD3D12.h"
|
||||
#include "backend/d3d12/ShaderModuleD3D12.h"
|
||||
#include "backend/d3d12/TextureD3D12.h"
|
||||
|
||||
#include "backend/d3d12/CommandAllocatorManager.h"
|
||||
#include "backend/d3d12/DescriptorHeapAllocator.h"
|
||||
#include "backend/d3d12/ResourceAllocator.h"
|
||||
#include "backend/d3d12/ResourceUploader.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
namespace d3d12 {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "backend/d3d12/DescriptorHeapAllocator.h"
|
||||
|
||||
#include "backend/d3d12/D3D12Backend.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
namespace backend {
|
||||
namespace d3d12 {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "backend/d3d12/InputStateD3D12.h"
|
||||
#include "backend/d3d12/ShaderModuleD3D12.h"
|
||||
#include "backend/d3d12/PipelineLayoutD3D12.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
#include <d3dcompiler.h>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "backend/d3d12/D3D12Backend.h"
|
||||
#include "backend/d3d12/BindGroupLayoutD3D12.h"
|
||||
#include "common/Assert.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user