Apply clang-format across the whole tree
Run clang-format (the repo's .clang-format: LLVM base, 120 cols, tabs, Allman functions) over every source file so the tree is formatter-clean. Whitespace only -- no behavior change; full x64 + x86 suites pass. Also set SortIncludes: false in .clang-format. Windows include order is load-bearing (windows.h must precede tlhelp32.h / mmreg.h / xinput.h / dinput.h; winsock2.h must precede windows.h), and the default alphabetical sort reorders tlhelp32.h ahead of windows.h -- a build break. Leaving order alone keeps the manual, correct grouping.
This commit is contained in:
@@ -9,13 +9,10 @@
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
namespace coop::mock
|
||||
{
|
||||
namespace
|
||||
{
|
||||
class Dx11Backend : public RenderBackend
|
||||
{
|
||||
public:
|
||||
namespace coop::mock {
|
||||
namespace {
|
||||
class Dx11Backend : public RenderBackend {
|
||||
public:
|
||||
bool init(HWND hwnd, std::uint32_t width, std::uint32_t height) override
|
||||
{
|
||||
width_ = width;
|
||||
@@ -24,9 +21,8 @@ public:
|
||||
const D3D_FEATURE_LEVEL levels[] = {D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0};
|
||||
ComPtr<ID3D11DeviceContext> ctx0;
|
||||
if (FAILED(D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, levels,
|
||||
static_cast<UINT>(std::size(levels)), D3D11_SDK_VERSION,
|
||||
device_.GetAddressOf(), nullptr, ctx0.GetAddressOf())))
|
||||
{
|
||||
static_cast<UINT>(std::size(levels)), D3D11_SDK_VERSION, device_.GetAddressOf(),
|
||||
nullptr, ctx0.GetAddressOf()))) {
|
||||
return false;
|
||||
}
|
||||
if (FAILED(ctx0.As(&ctx_))) // ClearView needs ID3D11DeviceContext1
|
||||
@@ -37,9 +33,8 @@ public:
|
||||
ComPtr<IDXGIDevice> dxgi_device;
|
||||
ComPtr<IDXGIAdapter> adapter;
|
||||
ComPtr<IDXGIFactory2> factory;
|
||||
if (FAILED(device_.As(&dxgi_device)) || FAILED(dxgi_device->GetAdapter(adapter.GetAddressOf())) ||
|
||||
FAILED(adapter->GetParent(IID_PPV_ARGS(factory.GetAddressOf()))))
|
||||
{
|
||||
if (FAILED(device_.As(&dxgi_device)) || FAILED(dxgi_device->GetAdapter(adapter.GetAddressOf()))
|
||||
|| FAILED(adapter->GetParent(IID_PPV_ARGS(factory.GetAddressOf())))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,8 +42,7 @@ public:
|
||||
// game) -- a flip-model swapchain only tears free of vsync with ALLOW_TEARING, so require it.
|
||||
ComPtr<IDXGIFactory5> factory5;
|
||||
BOOL tearing = FALSE;
|
||||
if (SUCCEEDED(factory.As(&factory5)))
|
||||
{
|
||||
if (SUCCEEDED(factory.As(&factory5))) {
|
||||
factory5->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &tearing, sizeof(tearing));
|
||||
}
|
||||
tearing_ = tearing != 0;
|
||||
@@ -62,18 +56,16 @@ public:
|
||||
desc.BufferCount = 2;
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
desc.Flags = tearing_ ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0u;
|
||||
if (FAILED(factory->CreateSwapChainForHwnd(device_.Get(), hwnd, &desc, nullptr, nullptr,
|
||||
swap_.GetAddressOf())))
|
||||
{
|
||||
if (FAILED(
|
||||
factory->CreateSwapChainForHwnd(device_.Get(), hwnd, &desc, nullptr, nullptr, swap_.GetAddressOf()))) {
|
||||
return false;
|
||||
}
|
||||
factory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);
|
||||
|
||||
// D3D11 flip-model: GetBuffer(0) stays the live back buffer, so one RTV is reused.
|
||||
ComPtr<ID3D11Texture2D> back;
|
||||
if (FAILED(swap_->GetBuffer(0, IID_PPV_ARGS(back.GetAddressOf()))) ||
|
||||
FAILED(device_->CreateRenderTargetView(back.Get(), nullptr, rtv_.GetAddressOf())))
|
||||
{
|
||||
if (FAILED(swap_->GetBuffer(0, IID_PPV_ARGS(back.GetAddressOf())))
|
||||
|| FAILED(device_->CreateRenderTargetView(back.Get(), nullptr, rtv_.GetAddressOf()))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -98,12 +90,9 @@ public:
|
||||
swap_->Present(0, tearing_ ? DXGI_PRESENT_ALLOW_TEARING : 0u); // uncapped: the mock must be fast
|
||||
}
|
||||
|
||||
[[nodiscard]] const char* name() const override
|
||||
{
|
||||
return "dx11";
|
||||
}
|
||||
[[nodiscard]] const char* name() const override { return "dx11"; }
|
||||
|
||||
private:
|
||||
private:
|
||||
std::uint32_t width_ = 0;
|
||||
std::uint32_t height_ = 0;
|
||||
bool tearing_ = false;
|
||||
|
||||
Reference in New Issue
Block a user