Skip to content

Commit

Permalink
Merge pull request #401 from tannergooding/main
Browse files Browse the repository at this point in the history
Apply various code style cleanups and improvements
  • Loading branch information
tannergooding authored Nov 12, 2024
2 parents 51a51fb + 5c72642 commit 3c5ff4e
Show file tree
Hide file tree
Showing 255 changed files with 692 additions and 623 deletions.
147 changes: 142 additions & 5 deletions exclusion.dic
Original file line number Diff line number Diff line change
@@ -1,46 +1,163 @@
abst
addr
amvideo
aniso
antialias
antialiased
apdu
applicationmodel
appmodel
appointmentsprovider
appservice
atapi
barycentrics
bezier
bluetooth
bstr
cbr
cmyk
comcat
comctl
cpst
cpuaccess
datatransfer
daudio
dcommon
derr
descs
deserializer
dest
devicetopology
dinput
directx
disp
documenttarget
dont
drivebay
dwrite
dxcapi
dxcore
dxgi
dxgicommon
dxgiformat
dxgitype
dxil
excep
fmin
gatt
gdiplus
gdipluscolor
gdipluseffects
gdiplusenums
gdiplusmetaheader
gdipluspixelformats
gdiplustypes
genericattributeprofile
geobounding
geocircle
geopath
geopoint
geoposition
geoshape
geovisit
gpio
gpso
grfdex
guiddef
gyrometer
handleapi
hidpi
hidsdi
hlsl
hmenu
horz
hrtf
hstring
hwnd
IID_DirectML
IID_OpenCL
IID_OpenGL
iclient
iids
iid_directml
iid_opencl
iid_opengl
iid_winrt_i
infos
intracoded
gdiplus
intsafe
ipdef
ipmib
iterable
kfid
ksmedia
lpfn
lpsz
lresource
luid
memcpy
mfapi
mfcaptureengine
mfidl
mfobjects
mfreadwrite
microsoft
minwinbase
minwindef
mips
mmdeviceapi
mmeapi
mmsyscom
movc
msaa
msports
msxml
multisample
noexcept
nothrow
nuget
nums
offsetted
oleaut
oleauto
pbstr
pcch
pclsid
pctinfo
pdisp
pgrfdex
phhk
pidl
pinnable
pixfmt
plib
postbuild
ppropvar
ppsz
ppunk
preparsed
prerolled
proj
propsys
propvar
propvarutil
pvar
rclsid
rects
rfcomm
rgmio
rgmios
rgsz
riid
roapi
roparameterizediid
sapi
sdklayers
seeked
segmenter
sharetarget
shellapi
stdcall
stringable
strmif
strsafe
subobject
subobjects
subresource
Expand All @@ -49,12 +166,32 @@ swapchain
tessellator
texels
tilings
unmap
tpcshrd
unknwnbase
unmap
userdataaccounts
userdatatasks
uuid
uuidof
uuids
uxtheme
voip
vtbl
wchar
wincodec
wincred
wincrypt
windef
winerror
wingdi
winhttp
winioctl
winnt
winreg
winrt
winuser
xapo
xaudio
xffff
xfffffff
xfffffffe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
using static TerraFX.Interop.DirectX.DXGI;
using static TerraFX.Interop.DirectX.DXGI_SWAP_EFFECT;
using static TerraFX.Interop.Windows.Windows;
using static TerraFX.Samples.DirectX.DXSampleHelper;

namespace TerraFX.Samples.DirectX.D3D11;

public abstract unsafe class DX11Sample : DXSample
public abstract unsafe class DX11Sample(string name) : DXSample(name)
{
private ID3D11Device* _d3dDevice;
private IDXGIAdapter1* _dxgiAdapter;
Expand All @@ -26,10 +25,6 @@ public abstract unsafe class DX11Sample : DXSample
private D3D11_VIEWPORT _viewport;
private RECT _scissorRect;

protected DX11Sample(string name) : base(name)
{
}

public ID3D11Device* D3DDevice => _d3dDevice;

public IDXGIAdapter1* DxgiAdapter => _dxgiAdapter;
Expand Down
7 changes: 1 addition & 6 deletions samples/DirectX/D3D11/HelloTriangle11.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,16 @@
using static TerraFX.Interop.DirectX.DirectX;
using static TerraFX.Interop.DirectX.DXGI_FORMAT;
using static TerraFX.Interop.Windows.Windows;
using static TerraFX.Samples.DirectX.DXSampleHelper;

namespace TerraFX.Samples.DirectX.D3D11;

public unsafe class HelloTriangle11 : HelloWindow11
public unsafe class HelloTriangle11(string name) : HelloWindow11(name)
{
private ID3D11VertexShader* _vertexShader;
private ID3D11InputLayout* _inputLayout;
private ID3D11PixelShader* _pixelShader;
private ID3D11Buffer* _vertexBuffer;

public HelloTriangle11(string name) : base(name)
{
}

protected override void CreateAssets()
{
_inputLayout = CreateInputLayout();
Expand Down
6 changes: 1 addition & 5 deletions samples/DirectX/D3D11/HelloWindow11.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@

namespace TerraFX.Samples.DirectX.D3D11;

public unsafe class HelloWindow11 : DX11Sample
public unsafe class HelloWindow11(string name) : DX11Sample(name)
{
public HelloWindow11(string name) : base(name)
{
}

public override void OnUpdate(TimeSpan delta)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@
using static TerraFX.Interop.DirectX.DXGI;
using static TerraFX.Interop.DirectX.DXGI_SWAP_EFFECT;
using static TerraFX.Interop.Windows.Windows;
using static TerraFX.Samples.DirectX.DXSampleHelper;

namespace TerraFX.Samples.DirectX.D3D12;

[SupportedOSPlatform("windows10.0")]
public abstract unsafe class DX12Sample : DXSample
public abstract unsafe class DX12Sample(string name) : DXSample(name)
{
private readonly ID3D12CommandAllocator*[] _commandAllocators;
private readonly ID3D12CommandAllocator*[] _commandAllocators = new ID3D12CommandAllocator*[2];

private ID3D12Device2* _d3dDevice;
private IDXGIAdapter1* _dxgiAdapter;
private IDXGIFactory4* _dxgiFactory;
private IDXGISwapChain3* _swapChain;
private ID3D12Resource*[] _renderTargets;
private ID3D12Resource*[] _renderTargets = new ID3D12Resource*[2];
private ID3D12Resource* _depthStencil;
private ID3D12DescriptorHeap* _rtvHeap;
private ID3D12DescriptorHeap* _dsvHeap;
Expand All @@ -43,21 +42,13 @@ public abstract unsafe class DX12Sample : DXSample
private uint _rtvDescriptorSize;

private ID3D12Fence* _fence;
private ulong[] _fenceValues;
private ulong[] _fenceValues = new ulong[2];
private HANDLE _fenceEvent;

private ID3D12GraphicsCommandList*[] _graphicsCommandLists;
private ID3D12GraphicsCommandList*[] _graphicsCommandLists = new ID3D12GraphicsCommandList*[2];
private ID3D12RootSignature* _rootSignature;
private ID3D12PipelineState* _pipelineState;

protected DX12Sample(string name) : base(name)
{
_renderTargets = new ID3D12Resource*[2];
_commandAllocators = new ID3D12CommandAllocator*[2];
_fenceValues = new ulong[2];
_graphicsCommandLists = new ID3D12GraphicsCommandList*[2];
}

public ID3D12CommandAllocator* CommandAllocator => _commandAllocators[FrameIndex];

public ID3D12CommandQueue* CommandQueue => _commandQueue;
Expand Down Expand Up @@ -321,16 +312,16 @@ ulong[] CreateFenceValues()
bool TryEnableDebugLayer()
{
#if DEBUG
// Enable the debug layer (requires the Graphics Tools "optional feature").
// NOTE: Enabling the debug layer after device creation will invalidate the active device.
// Enable the debug layer (requires the Graphics Tools "optional feature").
// NOTE: Enabling the debug layer after device creation will invalidate the active device.

using ComPtr<ID3D12Debug> debugController = null;
using ComPtr<ID3D12Debug> debugController = null;

if (D3D12GetDebugInterface(__uuidof<ID3D12Debug>(), (void**)&debugController).SUCCEEDED)
{
debugController.Get()->EnableDebugLayer();
return true;
}
if (D3D12GetDebugInterface(__uuidof<ID3D12Debug>(), (void**)&debugController).SUCCEEDED)
{
debugController.Get()->EnableDebugLayer();
return true;
}
#endif

return false;
Expand Down
7 changes: 1 addition & 6 deletions samples/DirectX/D3D12/HelloBundles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,17 @@
using TerraFX.Interop.DirectX;
using static TerraFX.Interop.DirectX.D3D_PRIMITIVE_TOPOLOGY;
using static TerraFX.Interop.DirectX.D3D12_COMMAND_LIST_TYPE;
using static TerraFX.Samples.DirectX.DXSampleHelper;
using static TerraFX.Interop.Windows.Windows;

namespace TerraFX.Samples.DirectX.D3D12;

[SupportedOSPlatform("windows10.0")]
public unsafe class HelloBundles12 : HelloTriangle12
public unsafe class HelloBundles12(string name) : HelloTriangle12(name)
{
// Pipeline objects
private ID3D12CommandAllocator* _bundleAllocator;
private ID3D12GraphicsCommandList* _bundle;

public HelloBundles12(string name) : base(name)
{
}

protected override void CreateAssets()
{
base.CreateAssets();
Expand Down
Loading

0 comments on commit 3c5ff4e

Please sign in to comment.