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
{
DisplayDevice* CurrentDisplayDevice = nullptr;
DisplayDevice* g_CurrentDisplayDevice = nullptr;
}
namespace Internal::Display
{
// TODO : IfDef new factories that are not compatible
constexpr DisplayDeviceFactory* Factories[] = { &Win32DisplayDeviceFactory, nullptr };
} // namespace
void InitializeDisplaySystem()
{
Assert(!CurrentDisplayDevice);
Assert(!g_CurrentDisplayDevice);
DisplayDevice* candidateDevice = nullptr;
DisplayDeviceFactory* candidateFactory = nullptr;
for (DisplayDeviceFactory* factory : Factories)
for (DisplayDeviceFactory* factory : Internal::Display::Factories)
{
if (factory)
{
@@ -36,10 +39,10 @@ namespace Juliet
// TODO : handle error instead of crashing
Assert(candidateDevice);
CurrentDisplayDevice = candidateDevice;
CurrentDisplayDevice->Name = candidateFactory->Name;
g_CurrentDisplayDevice = candidateDevice;
g_CurrentDisplayDevice->Name = candidateFactory->Name;
if (!CurrentDisplayDevice->Initialize(CurrentDisplayDevice))
if (!g_CurrentDisplayDevice->Initialize(g_CurrentDisplayDevice))
{
ShutdownDisplaySystem();
}
@@ -47,27 +50,27 @@ namespace Juliet
void ShutdownDisplaySystem()
{
if (!CurrentDisplayDevice)
if (!g_CurrentDisplayDevice)
{
return;
}
// 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
// no op for now
CurrentDisplayDevice->Free(CurrentDisplayDevice);
CurrentDisplayDevice = nullptr;
g_CurrentDisplayDevice->Free(g_CurrentDisplayDevice);
g_CurrentDisplayDevice = nullptr;
}
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)));
if (!window)
@@ -85,22 +88,22 @@ namespace Juliet
window->Title.Data = buffer;
window->Title.Size = titleLen;
CurrentDisplayDevice->MainWindow = window;
if (!CurrentDisplayDevice->CreatePlatformWindow(CurrentDisplayDevice, window))
g_CurrentDisplayDevice->MainWindow = window;
if (!g_CurrentDisplayDevice->CreatePlatformWindow(g_CurrentDisplayDevice, window))
{
// TODO : Destroy
return nullptr;
}
// TODO : make SHOW optional on creation with a flag
CurrentDisplayDevice->ShowWindow(CurrentDisplayDevice, window);
g_CurrentDisplayDevice->ShowWindow(g_CurrentDisplayDevice, window);
return window;
}
void DestroyPlatformWindow(NonNullPtr<Window> window)
{
Assert(CurrentDisplayDevice->MainWindow == window.Get());
Assert(g_CurrentDisplayDevice->MainWindow == window.Get());
HideWindow(window);
@@ -108,20 +111,20 @@ namespace Juliet
SafeFree(window->Title.Data);
window->Title.Size = 0;
CurrentDisplayDevice->DestroyPlatformWindow(CurrentDisplayDevice, window);
g_CurrentDisplayDevice->DestroyPlatformWindow(g_CurrentDisplayDevice, window);
Free(window.Get());
CurrentDisplayDevice->MainWindow = nullptr;
g_CurrentDisplayDevice->MainWindow = nullptr;
}
void ShowWindow(NonNullPtr<Window> window)
{
CurrentDisplayDevice->ShowWindow(CurrentDisplayDevice, window);
g_CurrentDisplayDevice->ShowWindow(g_CurrentDisplayDevice, window);
}
void HideWindow(NonNullPtr<Window> window)
{
CurrentDisplayDevice->HideWindow(CurrentDisplayDevice, window);
g_CurrentDisplayDevice->HideWindow(g_CurrentDisplayDevice, window);
}
WindowID GetWindowID(NonNullPtr<Window> window)
@@ -132,6 +135,6 @@ namespace Juliet
// Display Device Utils. Not exposed in the API
DisplayDevice* GetDisplayDevice()
{
return CurrentDisplayDevice;
return g_CurrentDisplayDevice;
}
} // namespace Juliet

View File

@@ -7,12 +7,10 @@
// Because Microsoft respects nothing
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wnonportable-system-include-path"
#pragma clang diagnostic ignored "-Wmicrosoft-enum-value"
#pragma clang diagnostic ignored "-Wnested-anon-types"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wall"
#pragma clang diagnostic ignored "-Wextra"
#pragma clang diagnostic ignored "-Weverything"
#endif
#ifndef WIN32_LEAN_AND_MEAN
@@ -5992,7 +5990,7 @@ BOOL D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::Opaque(DXGI_FORMAT Format)
// FormatExists
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;
HRESULT result = ID3D12Device_CreateCommittedResource(d3d12Driver->D3D12Device, &heapProperties, heapFlags,
&desc, initialState, NULL, IID_ID3D12Resource,
&desc, initialState, nullptr, IID_ID3D12Resource,
reinterpret_cast<void**>(&handle));
if (FAILED(result))
{

View File

@@ -98,10 +98,10 @@ namespace Juliet::D3D12
HRESULT result = ID3D12Device5_CreateCommandList1(driver->D3D12Device, queueDesc.NodeMask, queueDesc.Type,
D3D12_COMMAND_LIST_FLAG_NONE, IID_ID3D12GraphicsCommandList,
reinterpret_cast<void**>(&d3d12CopyCommandList));
if (FAILED(result))
{
Assert(false &&
"Error not implemented: cannot create ID3D12GraphicsCommandList (copy command list)");
AssertHR(result, "Error not implemented: cannot create ID3D12GraphicsCommandList (copy command list)");
return false;
}
commandList->CopyCommandList.CommandList = d3d12CopyCommandList;
@@ -418,7 +418,7 @@ namespace Juliet::D3D12
}
result = ID3D12GraphicsCommandList_Reset(commandList->GraphicsCommandList.CommandList,
commandList->GraphicsCommandList.Allocator, NULL);
commandList->GraphicsCommandList.Allocator, nullptr);
if (FAILED(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,
.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
.MipLODBias = 0.0f,
.MaxAnisotropy = 0,
.ComparisonFunc = D3D12_COMPARISON_FUNC_NONE,
.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK,
.MinLOD = 0.0f,
.MaxLOD = D3D12_FLOAT32_MAX,
.ShaderRegister = 0,
@@ -300,6 +303,7 @@ namespace Juliet::D3D12
d3d12GraphicsRootSignature->Handle = rootSignature;
return d3d12GraphicsRootSignature;
}
#if JULIET_DEBUG
#ifdef IDXGIINFOQUEUE_SUPPORTED
@@ -359,8 +363,6 @@ namespace Juliet::D3D12
}
#endif
#if JULIET_DEBUG
#define D3D12_GET_DEBUG_INTERFACE_FUNC "D3D12GetDebugInterface"
void InitializeD3D12DebugLayer(NonNullPtr<D3D12Driver> driver)
@@ -411,7 +413,7 @@ namespace Juliet::D3D12
void WINAPI OnD3D12DebugInfoMsg(D3D12_MESSAGE_CATEGORY category, D3D12_MESSAGE_SEVERITY severity,
D3D12_MESSAGE_ID id, LPCSTR description, void* /*context*/)
{
String catStr;
String catStr = WrapString("UNKNOWN");
switch (category)
{
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_EXECUTION: catStr = WrapString("EXECUTION"); break;
case D3D12_MESSAGE_CATEGORY_SHADER: catStr = WrapString("SHADER"); break;
default: catStr = WrapString("UNKNOWN"); break;
}
String severityStr;
String severityStr = WrapString("UNKNOWN");
switch (severity)
{
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_INFO: severityStr = WrapString("INFO"); break;
case D3D12_MESSAGE_SEVERITY_MESSAGE: severityStr = WrapString("MESSAGE"); break;
default: severityStr = WrapString("UNKNOWN"); break;
}
if (severity <= D3D12_MESSAGE_SEVERITY_ERROR)
@@ -461,10 +461,11 @@ namespace Juliet::D3D12
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);
}
#endif
#endif
void DestroyDriver_Internal(NonNullPtr<D3D12Driver> driver)
@@ -566,7 +567,9 @@ namespace Juliet::D3D12
driver->DXGIFactory = nullptr;
}
#if JULIET_DEBUG
ShutdownDXGIDebug(driver);
#endif
if (driver->D3D12DLL)
{
@@ -647,13 +650,14 @@ namespace Juliet::D3D12
{
auto driver = static_cast<D3D12Driver*>(Calloc(1, sizeof(D3D12Driver)));
#if JULIET_DEBUG
#ifdef IDXGIINFOQUEUE_SUPPORTED
if (enableDebug)
{
InitializeDXGIDebug(driver);
}
#endif
#endif
IDXGIFactory1* factory1 = nullptr;
HRESULT result = CreateDXGIFactory1(IID_IDXGIFactory1, reinterpret_cast<void**>(&factory1));
if (FAILED(result))
@@ -853,7 +857,7 @@ namespace Juliet::D3D12
commandSignatureDesc.ByteStride = sizeof(IndirectDrawCommand);
commandSignatureDesc.NumArgumentDescs = 1;
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));
if (FAILED(result))
{
@@ -866,7 +870,7 @@ namespace Juliet::D3D12
commandSignatureDesc.ByteStride = sizeof(IndexedIndirectDrawCommand);
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));
if (FAILED(result))
{
@@ -880,7 +884,7 @@ namespace Juliet::D3D12
commandSignatureDesc.ByteStride = sizeof(IndirectDispatchCommand);
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));
if (FAILED(result))
{

View File

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

View File

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

View File

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

View File

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

View File

@@ -131,6 +131,8 @@ namespace Juliet::D3D12
Assert(driver->WindowData);
// 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;
Assert(windowData->Window == window.Get());
@@ -229,7 +231,7 @@ namespace Juliet::D3D12
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());

View File

@@ -14,18 +14,5 @@ namespace Juliet::D3D12
{
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);
} // namespace Juliet::D3D12

View File

@@ -7,18 +7,18 @@
namespace Juliet
{
namespace
namespace Internal::Graphics
{
// 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
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.
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 (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
for (GraphicsDeviceFactory* factory : Factories)
for (const GraphicsDeviceFactory* factory : Factories)
{
if (factory->Type == config.PreferredDriver)
{
@@ -49,11 +49,11 @@ namespace Juliet
Log(LogLevel::Error, LogCategory::Graphics, "CreateGraphicsDevice::ChooseFactory: No valid driver found");
return nullptr;
}
} // namespace
} // namespace Internal::Graphics
GraphicsDevice* CreateGraphicsDevice(GraphicsConfig config)
{
if (GraphicsDeviceFactory* chosenFactory = ChooseFactory(config))
if (const GraphicsDeviceFactory* chosenFactory = Internal::Graphics::ChooseFactory(config))
{
if (GraphicsDevice* newDevice = chosenFactory->CreateGraphicsDevice(config.EnableDebug))
{
@@ -91,13 +91,13 @@ namespace Juliet
if (header->Submitted)
{
error = true;
Assert(false , "Cannot submit command list twice");
Assert(false, "Cannot submit command list twice");
}
if (header->RenderPass.IsInProgress)
{
error = true;
Assert(false , "Cannot submit command list twice");
Assert(false, "Cannot submit command list twice");
}
if (error)
@@ -125,13 +125,13 @@ namespace Juliet
if (header->Submitted)
{
error = true;
Assert(false , "Cannot submit command list twice");
Assert(false, "Cannot submit command list twice");
}
if (header->RenderPass.IsInProgress)
{
error = true;
Assert(false , "Cannot submit command list twice");
Assert(false, "Cannot submit command list twice");
}
if (error)