Juliet lib now builds with fastbuild

This commit is contained in:
2026-01-07 15:33:55 -05:00
parent 2710d29b62
commit bfd3648344
12 changed files with 69 additions and 69 deletions

View File

@@ -8,19 +8,22 @@ namespace Juliet
{ {
namespace namespace
{ {
DisplayDevice* CurrentDisplayDevice = nullptr; DisplayDevice* g_CurrentDisplayDevice = nullptr;
}
namespace Internal::Display
{
// TODO : IfDef new factories that are not compatible // TODO : IfDef new factories that are not compatible
constexpr DisplayDeviceFactory* Factories[] = { &Win32DisplayDeviceFactory, nullptr }; constexpr DisplayDeviceFactory* Factories[] = { &Win32DisplayDeviceFactory, nullptr };
} // namespace } // namespace
void InitializeDisplaySystem() void InitializeDisplaySystem()
{ {
Assert(!CurrentDisplayDevice); Assert(!g_CurrentDisplayDevice);
DisplayDevice* candidateDevice = nullptr; DisplayDevice* candidateDevice = nullptr;
DisplayDeviceFactory* candidateFactory = nullptr; DisplayDeviceFactory* candidateFactory = nullptr;
for (DisplayDeviceFactory* factory : Factories) for (DisplayDeviceFactory* factory : Internal::Display::Factories)
{ {
if (factory) if (factory)
{ {
@@ -36,10 +39,10 @@ namespace Juliet
// TODO : handle error instead of crashing // TODO : handle error instead of crashing
Assert(candidateDevice); Assert(candidateDevice);
CurrentDisplayDevice = candidateDevice; g_CurrentDisplayDevice = candidateDevice;
CurrentDisplayDevice->Name = candidateFactory->Name; g_CurrentDisplayDevice->Name = candidateFactory->Name;
if (!CurrentDisplayDevice->Initialize(CurrentDisplayDevice)) if (!g_CurrentDisplayDevice->Initialize(g_CurrentDisplayDevice))
{ {
ShutdownDisplaySystem(); ShutdownDisplaySystem();
} }
@@ -47,27 +50,27 @@ namespace Juliet
void ShutdownDisplaySystem() void ShutdownDisplaySystem()
{ {
if (!CurrentDisplayDevice) if (!g_CurrentDisplayDevice)
{ {
return; return;
} }
// Destroy all Windows that are still alive // Destroy all Windows that are still alive
if (CurrentDisplayDevice->MainWindow) if (g_CurrentDisplayDevice->MainWindow)
{ {
DestroyPlatformWindow(CurrentDisplayDevice->MainWindow); DestroyPlatformWindow(g_CurrentDisplayDevice->MainWindow);
} }
CurrentDisplayDevice->Shutdown(CurrentDisplayDevice); g_CurrentDisplayDevice->Shutdown(g_CurrentDisplayDevice);
// Free anything that was freed by the shutdown and then free the display // Free anything that was freed by the shutdown and then free the display
// no op for now // no op for now
CurrentDisplayDevice->Free(CurrentDisplayDevice); g_CurrentDisplayDevice->Free(g_CurrentDisplayDevice);
CurrentDisplayDevice = nullptr; g_CurrentDisplayDevice = nullptr;
} }
Window* CreatePlatformWindow(const char* title, uint16 width, uint16 height, int /*flags*/ /* = 0 unused */) Window* CreatePlatformWindow(const char* title, uint16 width, uint16 height, int /*flags*/ /* = 0 unused */)
{ {
Assert(CurrentDisplayDevice->CreatePlatformWindow); Assert(g_CurrentDisplayDevice->CreatePlatformWindow);
auto window = static_cast<Window*>(Calloc(1, sizeof(Window))); auto window = static_cast<Window*>(Calloc(1, sizeof(Window)));
if (!window) if (!window)
@@ -85,22 +88,22 @@ namespace Juliet
window->Title.Data = buffer; window->Title.Data = buffer;
window->Title.Size = titleLen; window->Title.Size = titleLen;
CurrentDisplayDevice->MainWindow = window; g_CurrentDisplayDevice->MainWindow = window;
if (!CurrentDisplayDevice->CreatePlatformWindow(CurrentDisplayDevice, window)) if (!g_CurrentDisplayDevice->CreatePlatformWindow(g_CurrentDisplayDevice, window))
{ {
// TODO : Destroy // TODO : Destroy
return nullptr; return nullptr;
} }
// TODO : make SHOW optional on creation with a flag // TODO : make SHOW optional on creation with a flag
CurrentDisplayDevice->ShowWindow(CurrentDisplayDevice, window); g_CurrentDisplayDevice->ShowWindow(g_CurrentDisplayDevice, window);
return window; return window;
} }
void DestroyPlatformWindow(NonNullPtr<Window> window) void DestroyPlatformWindow(NonNullPtr<Window> window)
{ {
Assert(CurrentDisplayDevice->MainWindow == window.Get()); Assert(g_CurrentDisplayDevice->MainWindow == window.Get());
HideWindow(window); HideWindow(window);
@@ -108,20 +111,20 @@ namespace Juliet
SafeFree(window->Title.Data); SafeFree(window->Title.Data);
window->Title.Size = 0; window->Title.Size = 0;
CurrentDisplayDevice->DestroyPlatformWindow(CurrentDisplayDevice, window); g_CurrentDisplayDevice->DestroyPlatformWindow(g_CurrentDisplayDevice, window);
Free(window.Get()); Free(window.Get());
CurrentDisplayDevice->MainWindow = nullptr; g_CurrentDisplayDevice->MainWindow = nullptr;
} }
void ShowWindow(NonNullPtr<Window> window) void ShowWindow(NonNullPtr<Window> window)
{ {
CurrentDisplayDevice->ShowWindow(CurrentDisplayDevice, window); g_CurrentDisplayDevice->ShowWindow(g_CurrentDisplayDevice, window);
} }
void HideWindow(NonNullPtr<Window> window) void HideWindow(NonNullPtr<Window> window)
{ {
CurrentDisplayDevice->HideWindow(CurrentDisplayDevice, window); g_CurrentDisplayDevice->HideWindow(g_CurrentDisplayDevice, window);
} }
WindowID GetWindowID(NonNullPtr<Window> window) WindowID GetWindowID(NonNullPtr<Window> window)
@@ -132,6 +135,6 @@ namespace Juliet
// Display Device Utils. Not exposed in the API // Display Device Utils. Not exposed in the API
DisplayDevice* GetDisplayDevice() DisplayDevice* GetDisplayDevice()
{ {
return CurrentDisplayDevice; return g_CurrentDisplayDevice;
} }
} // namespace Juliet } // namespace Juliet

View File

@@ -8,11 +8,9 @@
// Because Microsoft respects nothing // Because Microsoft respects nothing
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-macro-identifier" #pragma clang diagnostic ignored "-Wall"
#pragma clang diagnostic ignored "-Wreserved-identifier" #pragma clang diagnostic ignored "-Wextra"
#pragma clang diagnostic ignored "-Wnonportable-system-include-path" #pragma clang diagnostic ignored "-Weverything"
#pragma clang diagnostic ignored "-Wmicrosoft-enum-value"
#pragma clang diagnostic ignored "-Wnested-anon-types"
#endif #endif
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
@@ -5992,7 +5990,7 @@ BOOL D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::Opaque(DXGI_FORMAT Format)
// FormatExists // FormatExists
bool D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::FormatExists(DXGI_FORMAT Format) bool D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::FormatExists(DXGI_FORMAT Format)
{ {
return GetFormat(Format) != (DXGI_FORMAT)-1 ? true : false; return GetFormat(static_cast<size_t>(Format)) != static_cast<DXGI_FORMAT>(-1) ? true : false;
} }
//--------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------

View File

@@ -133,7 +133,7 @@ namespace Juliet::D3D12
ID3D12Resource* handle = nullptr; ID3D12Resource* handle = nullptr;
HRESULT result = ID3D12Device_CreateCommittedResource(d3d12Driver->D3D12Device, &heapProperties, heapFlags, HRESULT result = ID3D12Device_CreateCommittedResource(d3d12Driver->D3D12Device, &heapProperties, heapFlags,
&desc, initialState, NULL, IID_ID3D12Resource, &desc, initialState, nullptr, IID_ID3D12Resource,
reinterpret_cast<void**>(&handle)); reinterpret_cast<void**>(&handle));
if (FAILED(result)) if (FAILED(result))
{ {

View File

@@ -98,10 +98,10 @@ namespace Juliet::D3D12
HRESULT result = ID3D12Device5_CreateCommandList1(driver->D3D12Device, queueDesc.NodeMask, queueDesc.Type, HRESULT result = ID3D12Device5_CreateCommandList1(driver->D3D12Device, queueDesc.NodeMask, queueDesc.Type,
D3D12_COMMAND_LIST_FLAG_NONE, IID_ID3D12GraphicsCommandList, D3D12_COMMAND_LIST_FLAG_NONE, IID_ID3D12GraphicsCommandList,
reinterpret_cast<void**>(&d3d12CopyCommandList)); reinterpret_cast<void**>(&d3d12CopyCommandList));
if (FAILED(result)) if (FAILED(result))
{ {
Assert(false && AssertHR(result, "Error not implemented: cannot create ID3D12GraphicsCommandList (copy command list)");
"Error not implemented: cannot create ID3D12GraphicsCommandList (copy command list)");
return false; return false;
} }
commandList->CopyCommandList.CommandList = d3d12CopyCommandList; commandList->CopyCommandList.CommandList = d3d12CopyCommandList;
@@ -418,7 +418,7 @@ namespace Juliet::D3D12
} }
result = ID3D12GraphicsCommandList_Reset(commandList->GraphicsCommandList.CommandList, result = ID3D12GraphicsCommandList_Reset(commandList->GraphicsCommandList.CommandList,
commandList->GraphicsCommandList.Allocator, NULL); commandList->GraphicsCommandList.Allocator, nullptr);
if (FAILED(result)) if (FAILED(result))
{ {
LogError(driver->D3D12Device, "Could not reset command list", result); LogError(driver->D3D12Device, "Could not reset command list", result);

View File

@@ -236,6 +236,9 @@ namespace Juliet::D3D12
.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, .AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, .AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
.MipLODBias = 0.0f, .MipLODBias = 0.0f,
.MaxAnisotropy = 0,
.ComparisonFunc = D3D12_COMPARISON_FUNC_NONE,
.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK,
.MinLOD = 0.0f, .MinLOD = 0.0f,
.MaxLOD = D3D12_FLOAT32_MAX, .MaxLOD = D3D12_FLOAT32_MAX,
.ShaderRegister = 0, .ShaderRegister = 0,
@@ -300,6 +303,7 @@ namespace Juliet::D3D12
d3d12GraphicsRootSignature->Handle = rootSignature; d3d12GraphicsRootSignature->Handle = rootSignature;
return d3d12GraphicsRootSignature; return d3d12GraphicsRootSignature;
} }
#if JULIET_DEBUG
#ifdef IDXGIINFOQUEUE_SUPPORTED #ifdef IDXGIINFOQUEUE_SUPPORTED
@@ -359,8 +363,6 @@ namespace Juliet::D3D12
} }
#endif #endif
#if JULIET_DEBUG
#define D3D12_GET_DEBUG_INTERFACE_FUNC "D3D12GetDebugInterface" #define D3D12_GET_DEBUG_INTERFACE_FUNC "D3D12GetDebugInterface"
void InitializeD3D12DebugLayer(NonNullPtr<D3D12Driver> driver) void InitializeD3D12DebugLayer(NonNullPtr<D3D12Driver> driver)
@@ -411,7 +413,7 @@ namespace Juliet::D3D12
void WINAPI OnD3D12DebugInfoMsg(D3D12_MESSAGE_CATEGORY category, D3D12_MESSAGE_SEVERITY severity, void WINAPI OnD3D12DebugInfoMsg(D3D12_MESSAGE_CATEGORY category, D3D12_MESSAGE_SEVERITY severity,
D3D12_MESSAGE_ID id, LPCSTR description, void* /*context*/) D3D12_MESSAGE_ID id, LPCSTR description, void* /*context*/)
{ {
String catStr; String catStr = WrapString("UNKNOWN");
switch (category) switch (category)
{ {
case D3D12_MESSAGE_CATEGORY_APPLICATION_DEFINED: catStr = WrapString("APPLICATION_DEFINED"); break; case D3D12_MESSAGE_CATEGORY_APPLICATION_DEFINED: catStr = WrapString("APPLICATION_DEFINED"); break;
@@ -425,10 +427,9 @@ namespace Juliet::D3D12
case D3D12_MESSAGE_CATEGORY_RESOURCE_MANIPULATION: catStr = WrapString("RESOURCE_MANIPULATION"); break; case D3D12_MESSAGE_CATEGORY_RESOURCE_MANIPULATION: catStr = WrapString("RESOURCE_MANIPULATION"); break;
case D3D12_MESSAGE_CATEGORY_EXECUTION: catStr = WrapString("EXECUTION"); break; case D3D12_MESSAGE_CATEGORY_EXECUTION: catStr = WrapString("EXECUTION"); break;
case D3D12_MESSAGE_CATEGORY_SHADER: catStr = WrapString("SHADER"); break; case D3D12_MESSAGE_CATEGORY_SHADER: catStr = WrapString("SHADER"); break;
default: catStr = WrapString("UNKNOWN"); break;
} }
String severityStr; String severityStr = WrapString("UNKNOWN");
switch (severity) switch (severity)
{ {
case D3D12_MESSAGE_SEVERITY_CORRUPTION: severityStr = WrapString("CORRUPTION"); break; case D3D12_MESSAGE_SEVERITY_CORRUPTION: severityStr = WrapString("CORRUPTION"); break;
@@ -436,7 +437,6 @@ namespace Juliet::D3D12
case D3D12_MESSAGE_SEVERITY_WARNING: severityStr = WrapString("WARNING"); break; case D3D12_MESSAGE_SEVERITY_WARNING: severityStr = WrapString("WARNING"); break;
case D3D12_MESSAGE_SEVERITY_INFO: severityStr = WrapString("INFO"); break; case D3D12_MESSAGE_SEVERITY_INFO: severityStr = WrapString("INFO"); break;
case D3D12_MESSAGE_SEVERITY_MESSAGE: severityStr = WrapString("MESSAGE"); break; case D3D12_MESSAGE_SEVERITY_MESSAGE: severityStr = WrapString("MESSAGE"); break;
default: severityStr = WrapString("UNKNOWN"); break;
} }
if (severity <= D3D12_MESSAGE_SEVERITY_ERROR) if (severity <= D3D12_MESSAGE_SEVERITY_ERROR)
@@ -461,10 +461,11 @@ namespace Juliet::D3D12
return; return;
} }
ID3D12InfoQueue1_RegisterMessageCallback(infoQueue, OnD3D12DebugInfoMsg, D3D12_MESSAGE_CALLBACK_FLAG_NONE, NULL, NULL); ID3D12InfoQueue1_RegisterMessageCallback(infoQueue, OnD3D12DebugInfoMsg, D3D12_MESSAGE_CALLBACK_FLAG_NONE, nullptr, nullptr);
ID3D12InfoQueue1_Release(infoQueue); ID3D12InfoQueue1_Release(infoQueue);
} }
#endif #endif
#endif #endif
void DestroyDriver_Internal(NonNullPtr<D3D12Driver> driver) void DestroyDriver_Internal(NonNullPtr<D3D12Driver> driver)
@@ -566,7 +567,9 @@ namespace Juliet::D3D12
driver->DXGIFactory = nullptr; driver->DXGIFactory = nullptr;
} }
#if JULIET_DEBUG
ShutdownDXGIDebug(driver); ShutdownDXGIDebug(driver);
#endif
if (driver->D3D12DLL) if (driver->D3D12DLL)
{ {
@@ -647,13 +650,14 @@ namespace Juliet::D3D12
{ {
auto driver = static_cast<D3D12Driver*>(Calloc(1, sizeof(D3D12Driver))); auto driver = static_cast<D3D12Driver*>(Calloc(1, sizeof(D3D12Driver)));
#if JULIET_DEBUG
#ifdef IDXGIINFOQUEUE_SUPPORTED #ifdef IDXGIINFOQUEUE_SUPPORTED
if (enableDebug) if (enableDebug)
{ {
InitializeDXGIDebug(driver); InitializeDXGIDebug(driver);
} }
#endif #endif
#endif
IDXGIFactory1* factory1 = nullptr; IDXGIFactory1* factory1 = nullptr;
HRESULT result = CreateDXGIFactory1(IID_IDXGIFactory1, reinterpret_cast<void**>(&factory1)); HRESULT result = CreateDXGIFactory1(IID_IDXGIFactory1, reinterpret_cast<void**>(&factory1));
if (FAILED(result)) if (FAILED(result))
@@ -853,7 +857,7 @@ namespace Juliet::D3D12
commandSignatureDesc.ByteStride = sizeof(IndirectDrawCommand); commandSignatureDesc.ByteStride = sizeof(IndirectDrawCommand);
commandSignatureDesc.NumArgumentDescs = 1; commandSignatureDesc.NumArgumentDescs = 1;
commandSignatureDesc.pArgumentDescs = &indirectArgumentDesc; commandSignatureDesc.pArgumentDescs = &indirectArgumentDesc;
result = ID3D12Device5_CreateCommandSignature(driver->D3D12Device, &commandSignatureDesc, NULL, IID_ID3D12CommandSignature, result = ID3D12Device5_CreateCommandSignature(driver->D3D12Device, &commandSignatureDesc, nullptr, IID_ID3D12CommandSignature,
reinterpret_cast<void**>(&driver->IndirectDrawCommandSignature)); reinterpret_cast<void**>(&driver->IndirectDrawCommandSignature));
if (FAILED(result)) if (FAILED(result))
{ {
@@ -866,7 +870,7 @@ namespace Juliet::D3D12
commandSignatureDesc.ByteStride = sizeof(IndexedIndirectDrawCommand); commandSignatureDesc.ByteStride = sizeof(IndexedIndirectDrawCommand);
commandSignatureDesc.pArgumentDescs = &indirectArgumentDesc; commandSignatureDesc.pArgumentDescs = &indirectArgumentDesc;
result = ID3D12Device5_CreateCommandSignature(driver->D3D12Device, &commandSignatureDesc, NULL, IID_ID3D12CommandSignature, result = ID3D12Device5_CreateCommandSignature(driver->D3D12Device, &commandSignatureDesc, nullptr, IID_ID3D12CommandSignature,
reinterpret_cast<void**>(&driver->IndirectIndexedDrawCommandSignature)); reinterpret_cast<void**>(&driver->IndirectIndexedDrawCommandSignature));
if (FAILED(result)) if (FAILED(result))
{ {
@@ -880,7 +884,7 @@ namespace Juliet::D3D12
commandSignatureDesc.ByteStride = sizeof(IndirectDispatchCommand); commandSignatureDesc.ByteStride = sizeof(IndirectDispatchCommand);
commandSignatureDesc.pArgumentDescs = &indirectArgumentDesc; commandSignatureDesc.pArgumentDescs = &indirectArgumentDesc;
result = ID3D12Device5_CreateCommandSignature(driver->D3D12Device, &commandSignatureDesc, NULL, IID_ID3D12CommandSignature, result = ID3D12Device5_CreateCommandSignature(driver->D3D12Device, &commandSignatureDesc, nullptr, IID_ID3D12CommandSignature,
reinterpret_cast<void**>(&driver->IndirectDispatchCommandSignature)); reinterpret_cast<void**>(&driver->IndirectDispatchCommandSignature));
if (FAILED(result)) if (FAILED(result))
{ {

View File

@@ -66,10 +66,12 @@ namespace Juliet::D3D12
// DXGI // DXGI
IDXGIFactory4* DXGIFactory; IDXGIFactory4* DXGIFactory;
IDXGIAdapter1* DXGIAdapter; IDXGIAdapter1* DXGIAdapter;
#if JULIET_DEBUG
DynamicLibrary* DXGIDebugDLL; DynamicLibrary* DXGIDebugDLL;
IDXGIDebug* DXGIDebug; IDXGIDebug* DXGIDebug;
#ifdef IDXGIINFOQUEUE_SUPPORTED #ifdef IDXGIINFOQUEUE_SUPPORTED
IDXGIInfoQueue* DXGIInfoQueue; IDXGIInfoQueue* DXGIInfoQueue;
#endif
#endif #endif
// Windows // Windows

View File

@@ -317,6 +317,7 @@ namespace Juliet::D3D12
return true; return true;
} }
#if ALLOW_SHADER_HOT_RELOAD
void CopyShader(NonNullPtr<D3D12Shader> destination, NonNullPtr<D3D12Shader> source) void CopyShader(NonNullPtr<D3D12Shader> destination, NonNullPtr<D3D12Shader> source)
{ {
D3D12Shader* src = source.Get(); D3D12Shader* src = source.Get();
@@ -335,6 +336,7 @@ namespace Juliet::D3D12
MemCopy(dst->ByteCode.Data, src->ByteCode.Data, src->ByteCode.Size); MemCopy(dst->ByteCode.Data, src->ByteCode.Data, src->ByteCode.Size);
} }
#endif
} // namespace } // namespace
GraphicsPipeline* CreateGraphicsPipeline(NonNullPtr<GPUDriver> driver, const GraphicsPipelineCreateInfo& createInfo) GraphicsPipeline* CreateGraphicsPipeline(NonNullPtr<GPUDriver> driver, const GraphicsPipelineCreateInfo& createInfo)

View File

@@ -6,6 +6,7 @@
// namespace wrl = Microsoft::WRL; // namespace wrl = Microsoft::WRL;
// Because Microsoft respects nothing // Because Microsoft respects nothing
// TODO: Create an external dependency with its one fbuild.bff
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-macro-identifier" #pragma clang diagnostic ignored "-Wreserved-macro-identifier"
@@ -13,6 +14,7 @@
#pragma clang diagnostic ignored "-Wnonportable-system-include-path" #pragma clang diagnostic ignored "-Wnonportable-system-include-path"
#pragma clang diagnostic ignored "-Wmicrosoft-enum-value" #pragma clang diagnostic ignored "-Wmicrosoft-enum-value"
#pragma clang diagnostic ignored "-Wnested-anon-types" #pragma clang diagnostic ignored "-Wnested-anon-types"
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
#endif #endif
// We will use the C interface of DX12. // We will use the C interface of DX12.

View File

@@ -162,7 +162,7 @@ namespace Juliet::D3D12
// TODO : Write Depth stencil // TODO : Write Depth stencil
d3d12CommandList->CurrentGraphicsPipeline = nullptr; d3d12CommandList->CurrentGraphicsPipeline = nullptr;
ID3D12GraphicsCommandList_OMSetRenderTargets(d3d12CommandList->GraphicsCommandList.CommandList, 0, NULL, false, NULL); ID3D12GraphicsCommandList_OMSetRenderTargets(d3d12CommandList->GraphicsCommandList.CommandList, 0, nullptr, false, nullptr);
// Reset bind states // Reset bind states
ZeroArray(d3d12CommandList->ColorTargetSubresources); ZeroArray(d3d12CommandList->ColorTargetSubresources);

View File

@@ -131,6 +131,8 @@ namespace Juliet::D3D12
Assert(driver->WindowData); Assert(driver->WindowData);
// TODO: Find a way to fetch window data more smoothly from the window ptr // TODO: Find a way to fetch window data more smoothly from the window ptr
// In the mean time i will just void it or the variable is unused and cause a warning
(void)window;
auto* windowData = driver->WindowData; auto* windowData = driver->WindowData;
Assert(windowData->Window == window.Get()); Assert(windowData->Window == window.Get());
@@ -229,7 +231,7 @@ namespace Juliet::D3D12
return true; return true;
} }
TextureFormat GetSwapChainTextureFormat(NonNullPtr<GPUDriver> driver, NonNullPtr<Window> window) TextureFormat GetSwapChainTextureFormat(NonNullPtr<GPUDriver> driver, [[maybe_unused]] NonNullPtr<Window> window)
{ {
auto* d3d12Driver = static_cast<D3D12Driver*>(driver.Get()); auto* d3d12Driver = static_cast<D3D12Driver*>(driver.Get());

View File

@@ -14,18 +14,5 @@ namespace Juliet::D3D12
{ {
struct D3D12Driver; struct D3D12Driver;
inline void AssertOnFailure(HRESULT hr)
{
Assert(!!FAILED(hr));
}
inline void CheckFailure(HRESULT hr)
{
switch (hr)
{
case E_POINTER: Assert(false, "Invalid Pointer");
}
}
extern void LogError(NonNullPtr<ID3D12Device5> D3D12Device, const char* errorMessage, HRESULT result); extern void LogError(NonNullPtr<ID3D12Device5> D3D12Device, const char* errorMessage, HRESULT result);
} // namespace Juliet::D3D12 } // namespace Juliet::D3D12

View File

@@ -7,18 +7,18 @@
namespace Juliet namespace Juliet
{ {
namespace namespace Internal::Graphics
{ {
// TODO : IfDef new factories that are not compatible // TODO : IfDef new factories that are not compatible
// Low chance of porting on something else than windows though. May be linux but will use vulkan that works on windows // Low chance of porting on something else than windows though. May be linux but will use vulkan that works on windows
constexpr GraphicsDeviceFactory* Factories[] = { &DX12DeviceFactory }; constexpr GraphicsDeviceFactory* Factories[] = { &DX12DeviceFactory };
GraphicsDeviceFactory* ChooseFactory(GraphicsConfig config) const GraphicsDeviceFactory* ChooseFactory(GraphicsConfig config)
{ {
// First try to check the preferred renderer from the config if any. // First try to check the preferred renderer from the config if any.
if (config.PreferredDriver != DriverType::Any) if (config.PreferredDriver != DriverType::Any)
{ {
for (GraphicsDeviceFactory* factory : Factories) for (const GraphicsDeviceFactory* factory : Factories)
{ {
// If the config has a preferred renderer, immediately pick it up. // If the config has a preferred renderer, immediately pick it up.
if (factory->Type == config.PreferredDriver) if (factory->Type == config.PreferredDriver)
@@ -32,7 +32,7 @@ namespace Juliet
} }
// If not preferred renderer was set, use the first one that works in the list // If not preferred renderer was set, use the first one that works in the list
for (GraphicsDeviceFactory* factory : Factories) for (const GraphicsDeviceFactory* factory : Factories)
{ {
if (factory->Type == config.PreferredDriver) if (factory->Type == config.PreferredDriver)
{ {
@@ -49,11 +49,11 @@ namespace Juliet
Log(LogLevel::Error, LogCategory::Graphics, "CreateGraphicsDevice::ChooseFactory: No valid driver found"); Log(LogLevel::Error, LogCategory::Graphics, "CreateGraphicsDevice::ChooseFactory: No valid driver found");
return nullptr; return nullptr;
} }
} // namespace } // namespace Internal::Graphics
GraphicsDevice* CreateGraphicsDevice(GraphicsConfig config) GraphicsDevice* CreateGraphicsDevice(GraphicsConfig config)
{ {
if (GraphicsDeviceFactory* chosenFactory = ChooseFactory(config)) if (const GraphicsDeviceFactory* chosenFactory = Internal::Graphics::ChooseFactory(config))
{ {
if (GraphicsDevice* newDevice = chosenFactory->CreateGraphicsDevice(config.EnableDebug)) if (GraphicsDevice* newDevice = chosenFactory->CreateGraphicsDevice(config.EnableDebug))
{ {