Replace remainder of HRESULT checks with macro

Change-Id: Ice46fc0bc97d6dc00e707316647d04a3137ef9f4
Bug: skia:9935
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300212
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Jim Van Verth 2020-07-01 13:46:57 -04:00 committed by Skia Commit-Bot
parent d3fca6b96d
commit 8bf01945da
3 changed files with 29 additions and 42 deletions

View File

@ -127,25 +127,21 @@ void GrD3DCaps::init(const GrContextOptions& contextOptions, IDXGIAdapter1* adap
D3D12_FEATURE_DATA_FEATURE_LEVELS flDesc = {};
flDesc.NumFeatureLevels = _countof(featureLevels);
flDesc.pFeatureLevelsRequested = featureLevels;
SkDEBUGCODE(HRESULT hr =) device->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &flDesc,
sizeof(flDesc));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &flDesc,
sizeof(flDesc)));
// This had better be true
SkASSERT(flDesc.MaxSupportedFeatureLevel >= D3D_FEATURE_LEVEL_11_0);
DXGI_ADAPTER_DESC adapterDesc;
SkDEBUGCODE(hr =) adapter->GetDesc(&adapterDesc);
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(adapter->GetDesc(&adapterDesc));
D3D12_FEATURE_DATA_D3D12_OPTIONS optionsDesc;
SkDEBUGCODE(hr =) device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &optionsDesc,
sizeof(optionsDesc));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &optionsDesc,
sizeof(optionsDesc)));
D3D12_FEATURE_DATA_D3D12_OPTIONS2 options2Desc;
SkDEBUGCODE(hr =) device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS2, &options2Desc,
sizeof(options2Desc));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS2, &options2Desc,
sizeof(options2Desc)));
// See https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-support
if (D3D12_RESOURCE_BINDING_TIER_1 == optionsDesc.ResourceBindingTier) {
@ -267,10 +263,9 @@ void GrD3DCaps::applyDriverCorrectnessWorkarounds(int vendorID) {
bool stencil_format_supported(ID3D12Device* device, DXGI_FORMAT format) {
D3D12_FEATURE_DATA_FORMAT_SUPPORT formatSupportDesc;
formatSupportDesc.Format = format;
SkDEBUGCODE(HRESULT hr = ) device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT,
&formatSupportDesc,
sizeof(formatSupportDesc));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT,
&formatSupportDesc,
sizeof(formatSupportDesc)));
return SkToBool(D3D12_FORMAT_SUPPORT1_DEPTH_STENCIL & formatSupportDesc.Support1);
}
@ -736,9 +731,8 @@ static bool multisample_count_supported(ID3D12Device* device, DXGI_FORMAT format
D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS msqLevels;
msqLevels.Format = format;
msqLevels.SampleCount = sampleCount;
SkDEBUGCODE(HRESULT hr =) device->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS,
&msqLevels, sizeof(msqLevels));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS,
&msqLevels, sizeof(msqLevels)));
return msqLevels.NumQualityLevels > 0;
}
@ -777,10 +771,9 @@ void GrD3DCaps::FormatInfo::init(const DXGI_ADAPTER_DESC& adapterDesc, ID3D12Dev
DXGI_FORMAT format) {
D3D12_FEATURE_DATA_FORMAT_SUPPORT formatSupportDesc;
formatSupportDesc.Format = format;
SkDEBUGCODE(HRESULT hr =) device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT,
&formatSupportDesc,
sizeof(formatSupportDesc));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT,
&formatSupportDesc,
sizeof(formatSupportDesc)));
InitFormatFlags(formatSupportDesc, &fFlags);
if (fFlags & kRenderable_Flag) {

View File

@ -50,10 +50,8 @@ GrD3DCommandList::SubmitResult GrD3DCommandList::submit(ID3D12CommandQueue* queu
void GrD3DCommandList::reset() {
SkASSERT(!fIsActive);
SkDEBUGCODE(HRESULT hr = ) fAllocator->Reset();
SkASSERT(SUCCEEDED(hr));
SkDEBUGCODE(hr = ) fCommandList->Reset(fAllocator.get(), nullptr);
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(fAllocator->Reset());
GR_D3D_CALL_ERRCHECK(fCommandList->Reset(fAllocator.get(), nullptr));
this->onReset();
this->releaseResources();
@ -188,15 +186,13 @@ void GrD3DCommandList::addingWork() {
std::unique_ptr<GrD3DDirectCommandList> GrD3DDirectCommandList::Make(ID3D12Device* device) {
gr_cp<ID3D12CommandAllocator> allocator;
SkDEBUGCODE(HRESULT hr = ) device->CreateCommandAllocator(
D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CreateCommandAllocator(
D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator)));
gr_cp<ID3D12GraphicsCommandList> commandList;
SkDEBUGCODE(hr = ) device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT,
allocator.get(), nullptr,
IID_PPV_ARGS(&commandList));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT,
allocator.get(), nullptr,
IID_PPV_ARGS(&commandList)));
auto grCL = new GrD3DDirectCommandList(std::move(allocator), std::move(commandList));
return std::unique_ptr<GrD3DDirectCommandList>(grCL);
@ -447,14 +443,12 @@ void GrD3DDirectCommandList::addSampledTextureRef(GrD3DTexture* texture) {
std::unique_ptr<GrD3DCopyCommandList> GrD3DCopyCommandList::Make(ID3D12Device* device) {
gr_cp<ID3D12CommandAllocator> allocator;
SkDEBUGCODE(HRESULT hr = ) device->CreateCommandAllocator(
D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT,
IID_PPV_ARGS(&allocator)));
gr_cp<ID3D12GraphicsCommandList> commandList;
SkDEBUGCODE(hr = ) device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_COPY, allocator.get(),
nullptr, IID_PPV_ARGS(&commandList));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_COPY, allocator.get(),
nullptr, IID_PPV_ARGS(&commandList)));
auto grCL = new GrD3DCopyCommandList(std::move(allocator), std::move(commandList));
return std::unique_ptr<GrD3DCopyCommandList>(grCL);
}

View File

@ -21,6 +21,7 @@
#include "src/gpu/d3d/GrD3DGpu.h"
#include "src/gpu/d3d/GrD3DRenderTarget.h"
#include "src/gpu/d3d/GrD3DRootSignature.h"
#include "src/gpu/d3d/GrD3DUtil.h"
#include "src/sksl/SkSLCompiler.h"
#include <d3dcompiler.h>
@ -527,9 +528,8 @@ gr_cp<ID3D12PipelineState> create_pipeline_state(
psoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
gr_cp<ID3D12PipelineState> pipelineState;
SkDEBUGCODE(HRESULT hr = )gpu->device()->CreateGraphicsPipelineState(
&psoDesc, IID_PPV_ARGS(&pipelineState));
SkASSERT(SUCCEEDED(hr));
GR_D3D_CALL_ERRCHECK(gpu->device()->CreateGraphicsPipelineState(
&psoDesc, IID_PPV_ARGS(&pipelineState)));
return pipelineState;
}