mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
VideoBackends/D3D: Eliminate CHECK in favor of ASSERT_MSG
This commit is contained in:
@ -6,8 +6,10 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
|
||||
#include "VideoBackends/D3D/D3DState.h"
|
||||
#include "VideoBackends/D3DCommon/D3DCommon.h"
|
||||
|
||||
@ -33,7 +35,7 @@ bool D3DBoundingBox::Initialize()
|
||||
data.SysMemSlicePitch = 0;
|
||||
HRESULT hr;
|
||||
hr = D3D::device->CreateBuffer(&desc, &data, &m_buffer);
|
||||
CHECK(SUCCEEDED(hr), "Create BoundingBox Buffer.");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox Buffer");
|
||||
if (FAILED(hr))
|
||||
return false;
|
||||
D3DCommon::SetDebugObjectName(m_buffer.Get(), "BoundingBox Buffer");
|
||||
@ -43,7 +45,7 @@ bool D3DBoundingBox::Initialize()
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
desc.BindFlags = 0;
|
||||
hr = D3D::device->CreateBuffer(&desc, nullptr, &m_staging_buffer);
|
||||
CHECK(SUCCEEDED(hr), "Create BoundingBox Staging Buffer.");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox Staging Buffer");
|
||||
if (FAILED(hr))
|
||||
return false;
|
||||
D3DCommon::SetDebugObjectName(m_staging_buffer.Get(), "BoundingBox Staging Buffer");
|
||||
@ -56,7 +58,7 @@ bool D3DBoundingBox::Initialize()
|
||||
UAVdesc.Buffer.Flags = 0;
|
||||
UAVdesc.Buffer.NumElements = NUM_BBOX_VALUES;
|
||||
hr = D3D::device->CreateUnorderedAccessView(m_buffer.Get(), &UAVdesc, &m_uav);
|
||||
CHECK(SUCCEEDED(hr), "Create BoundingBox UAV.");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox UAV");
|
||||
if (FAILED(hr))
|
||||
return false;
|
||||
D3DCommon::SetDebugObjectName(m_uav.Get(), "BoundingBox UAV");
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/EnumMap.h"
|
||||
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
@ -182,7 +183,7 @@ ID3D11InputLayout* D3DVertexFormat::GetInputLayout(const void* vs_bytecode, size
|
||||
|
||||
HRESULT hr = D3D::device->CreateInputLayout(m_elems.data(), m_num_elems, vs_bytecode,
|
||||
vs_bytecode_size, &layout);
|
||||
CHECK(SUCCEEDED(hr), "Failed to create input layout");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create input layout");
|
||||
|
||||
// This method can be called from multiple threads, so ensure that only one thread sets the
|
||||
// cached input layout pointer. If another thread beats this thread, use the existing layout.
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/BitSet.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
@ -348,7 +349,7 @@ ID3D11SamplerState* StateCache::Get(SamplerState state)
|
||||
|
||||
ComPtr<ID3D11SamplerState> res;
|
||||
HRESULT hr = D3D::device->CreateSamplerState(&sampdc, res.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Creating D3D sampler state failed");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating D3D sampler state failed");
|
||||
return m_sampler.emplace(state, std::move(res)).first->second.Get();
|
||||
}
|
||||
|
||||
@ -425,7 +426,7 @@ ID3D11BlendState* StateCache::Get(BlendingState state)
|
||||
|
||||
ComPtr<ID3D11BlendState> res;
|
||||
HRESULT hr = D3D::device->CreateBlendState(&desc, res.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Creating D3D blend state failed");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating D3D blend state failed");
|
||||
return m_blend.emplace(state.hex, std::move(res)).first->second.Get();
|
||||
}
|
||||
|
||||
@ -446,7 +447,7 @@ ID3D11RasterizerState* StateCache::Get(RasterizationState state)
|
||||
|
||||
ComPtr<ID3D11RasterizerState> res;
|
||||
HRESULT hr = D3D::device->CreateRasterizerState(&desc, res.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Creating D3D rasterizer state failed");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating D3D rasterizer state failed");
|
||||
return m_raster.emplace(state.hex, std::move(res)).first->second.Get();
|
||||
}
|
||||
|
||||
@ -488,7 +489,7 @@ ID3D11DepthStencilState* StateCache::Get(DepthState state)
|
||||
|
||||
ComPtr<ID3D11DepthStencilState> res;
|
||||
HRESULT hr = D3D::device->CreateDepthStencilState(&depthdc, res.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Creating D3D depth stencil state failed");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating D3D depth stencil state failed");
|
||||
return m_depth.emplace(state.hex, std::move(res)).first->second.Get();
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "VideoBackends/D3D/D3DSwapChain.h"
|
||||
|
||||
#include "Common/Assert.h"
|
||||
|
||||
#include "VideoBackends/D3D/DXTexture.h"
|
||||
|
||||
namespace DX11
|
||||
@ -29,7 +31,7 @@ bool SwapChain::CreateSwapChainBuffers()
|
||||
{
|
||||
ComPtr<ID3D11Texture2D> texture;
|
||||
HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(&texture));
|
||||
CHECK(SUCCEEDED(hr), "Get swap chain buffer");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to get swap chain buffer");
|
||||
if (FAILED(hr))
|
||||
return false;
|
||||
|
||||
|
@ -34,7 +34,7 @@ static ComPtr<ID3D11Buffer> AllocateConstantBuffer(u32 size)
|
||||
D3D11_CPU_ACCESS_WRITE);
|
||||
ComPtr<ID3D11Buffer> cbuf;
|
||||
const HRESULT hr = D3D::device->CreateBuffer(&cbdesc, nullptr, &cbuf);
|
||||
CHECK(SUCCEEDED(hr), "shader constant buffer (size=%u)", cbsize);
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create shader constant buffer (size={})", cbsize);
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
@ -59,8 +59,8 @@ CreateTexelBufferView(ID3D11Buffer* buffer, TexelBufferFormat format, DXGI_FORMA
|
||||
CD3D11_SHADER_RESOURCE_VIEW_DESC srv_desc(buffer, srv_format, 0,
|
||||
VertexManager::TEXEL_STREAM_BUFFER_SIZE /
|
||||
VertexManager::GetTexelBufferElementSize(format));
|
||||
CHECK(SUCCEEDED(D3D::device->CreateShaderResourceView(buffer, &srv_desc, &srv)),
|
||||
"Create SRV for texel buffer");
|
||||
HRESULT hr = D3D::device->CreateShaderResourceView(buffer, &srv_desc, &srv);
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create SRV for texel buffer");
|
||||
return srv;
|
||||
}
|
||||
|
||||
@ -79,8 +79,8 @@ bool VertexManager::Initialize()
|
||||
|
||||
for (int i = 0; i < BUFFER_COUNT; i++)
|
||||
{
|
||||
CHECK(SUCCEEDED(D3D::device->CreateBuffer(&bufdesc, nullptr, &m_buffers[i])),
|
||||
"Failed to create buffer.");
|
||||
HRESULT hr = D3D::device->CreateBuffer(&bufdesc, nullptr, &m_buffers[i]);
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create buffer");
|
||||
if (m_buffers[i])
|
||||
D3DCommon::SetDebugObjectName(m_buffers[i].Get(), "Buffer of VertexManager");
|
||||
}
|
||||
@ -93,8 +93,8 @@ bool VertexManager::Initialize()
|
||||
|
||||
CD3D11_BUFFER_DESC texel_buf_desc(TEXEL_STREAM_BUFFER_SIZE, D3D11_BIND_SHADER_RESOURCE,
|
||||
D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
CHECK(SUCCEEDED(D3D::device->CreateBuffer(&texel_buf_desc, nullptr, &m_texel_buffer)),
|
||||
"Creating texel buffer failed");
|
||||
HRESULT hr = D3D::device->CreateBuffer(&texel_buf_desc, nullptr, &m_texel_buffer);
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating texel buffer failed");
|
||||
if (!m_texel_buffer)
|
||||
return false;
|
||||
|
||||
@ -132,7 +132,7 @@ bool VertexManager::MapTexelBuffer(u32 required_size, D3D11_MAPPED_SUBRESOURCE&
|
||||
{
|
||||
// Restart buffer.
|
||||
HRESULT hr = D3D::context->Map(m_texel_buffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &sr);
|
||||
CHECK(SUCCEEDED(hr), "Map texel buffer");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map texel buffer");
|
||||
if (FAILED(hr))
|
||||
return false;
|
||||
|
||||
@ -142,7 +142,7 @@ bool VertexManager::MapTexelBuffer(u32 required_size, D3D11_MAPPED_SUBRESOURCE&
|
||||
{
|
||||
// Don't overwrite the earlier-used space.
|
||||
HRESULT hr = D3D::context->Map(m_texel_buffer.Get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &sr);
|
||||
CHECK(SUCCEEDED(hr), "Map texel buffer");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map texel buffer");
|
||||
if (FAILED(hr))
|
||||
return false;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
|
||||
{
|
||||
ComPtr<ID3D11VertexShader> vs;
|
||||
HRESULT hr = D3D::device->CreateVertexShader(bytecode.data(), bytecode.size(), nullptr, &vs);
|
||||
CHECK(SUCCEEDED(hr), "Create vertex shader");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create vertex shader");
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
@ -66,7 +66,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
|
||||
{
|
||||
ComPtr<ID3D11GeometryShader> gs;
|
||||
HRESULT hr = D3D::device->CreateGeometryShader(bytecode.data(), bytecode.size(), nullptr, &gs);
|
||||
CHECK(SUCCEEDED(hr), "Create geometry shader");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create geometry shader");
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
@ -78,7 +78,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
|
||||
{
|
||||
ComPtr<ID3D11PixelShader> ps;
|
||||
HRESULT hr = D3D::device->CreatePixelShader(bytecode.data(), bytecode.size(), nullptr, &ps);
|
||||
CHECK(SUCCEEDED(hr), "Create pixel shader");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create pixel shader");
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
@ -90,7 +90,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
|
||||
{
|
||||
ComPtr<ID3D11ComputeShader> cs;
|
||||
HRESULT hr = D3D::device->CreateComputeShader(bytecode.data(), bytecode.size(), nullptr, &cs);
|
||||
CHECK(SUCCEEDED(hr), "Create compute shader");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create compute shader");
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
|
@ -207,7 +207,7 @@ std::unique_ptr<DXStagingTexture> DXStagingTexture::Create(StagingTextureType ty
|
||||
|
||||
ComPtr<ID3D11Texture2D> texture;
|
||||
HRESULT hr = D3D::device->CreateTexture2D(&desc, nullptr, texture.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Create staging texture");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create staging texture");
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
@ -298,7 +298,7 @@ bool DXStagingTexture::Map()
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE sr;
|
||||
HRESULT hr = D3D::context->Map(m_tex.Get(), 0, map_type, 0, &sr);
|
||||
CHECK(SUCCEEDED(hr), "Map readback texture");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map readback texture");
|
||||
if (FAILED(hr))
|
||||
return false;
|
||||
|
||||
@ -363,7 +363,7 @@ std::unique_ptr<DXFramebuffer> DXFramebuffer::Create(DXTexture* color_attachment
|
||||
color_attachment->GetLayers());
|
||||
HRESULT hr = D3D::device->CreateRenderTargetView(color_attachment->GetD3DTexture(), &desc,
|
||||
rtv.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Create render target view for framebuffer");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create render target view for framebuffer");
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
|
||||
@ -375,7 +375,8 @@ std::unique_ptr<DXFramebuffer> DXFramebuffer::Create(DXTexture* color_attachment
|
||||
desc.Format = integer_format;
|
||||
hr = D3D::device->CreateRenderTargetView(color_attachment->GetD3DTexture(), &desc,
|
||||
integer_rtv.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Create integer render target view for framebuffer");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr),
|
||||
"Failed to create integer render target view for framebuffer");
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,7 +390,7 @@ std::unique_ptr<DXFramebuffer> DXFramebuffer::Create(DXTexture* color_attachment
|
||||
depth_attachment->GetLayers(), 0);
|
||||
HRESULT hr = D3D::device->CreateDepthStencilView(depth_attachment->GetD3DTexture(), &desc,
|
||||
dsv.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Create depth stencil view for framebuffer");
|
||||
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create depth stencil view for framebuffer");
|
||||
if (FAILED(hr))
|
||||
return nullptr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user