D3D12: Implement ASSERT_SUCCESS as macro instead of function

This patch implements ASSERT_SUCCESS(hr) as a macro instead of a
function so that when hr fails Dawn can print out the line number of the
expression that causes the failure.

For example, previously we will always get the following error message
because ASSERT_SUCCESS is a function:
Assertion failure at ../../src/dawn_native/d3d12/DeviceD3D12.cpp:43
(ASSERT_SUCCESS): (((HRESULT)(hr)) >= 0)

Now we can get more details about where the failure occurs because now
ASSERT_SUCCESS is a macro:
Assertion failure at ../../src/dawn_native/d3d12/DeviceD3D12.cpp:59
(Initialize): (((HRESULT)(mD3d12Device->CreateCommandQueue(&queueDesc,
__uuidof(**(&mFence)), IID_PPV_ARGS_Helper(&mFence)))) >= 0)

BUG=dawn:178

Change-Id: I435ee2f418658bca276f439fcabfabbfecbff998
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11700
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Jiawei Shao 2019-10-01 02:30:32 +00:00 committed by Commit Bot service account
parent e6b93e8706
commit deb28ea45d
2 changed files with 5 additions and 5 deletions

View File

@ -40,10 +40,6 @@
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
void ASSERT_SUCCESS(HRESULT hr) {
ASSERT(SUCCEEDED(hr));
}
Device::Device(Adapter* adapter, const DeviceDescriptor* descriptor) Device::Device(Adapter* adapter, const DeviceDescriptor* descriptor)
: DeviceBase(adapter, descriptor) { : DeviceBase(adapter, descriptor) {
if (descriptor != nullptr) { if (descriptor != nullptr) {

View File

@ -33,7 +33,11 @@ namespace dawn_native { namespace d3d12 {
class PlatformFunctions; class PlatformFunctions;
class ResourceAllocator; class ResourceAllocator;
void ASSERT_SUCCESS(HRESULT hr); #define ASSERT_SUCCESS(hr) \
{ \
HRESULT succeeded = hr; \
ASSERT(SUCCEEDED(succeeded)); \
}
// Definition of backend types // Definition of backend types
class Device : public DeviceBase { class Device : public DeviceBase {