Conversion to use Fastbuild + -Wall and warning as errors. WIP

This commit is contained in:
2026-01-06 21:33:15 -05:00
parent 76848ab4e3
commit b5c72649db
79 changed files with 6839 additions and 1508 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -57,10 +57,9 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;JULIET_EXPORT;JULIET_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>DEBUG;JULIET_EXPORT;JULIET_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp20</LanguageStandard>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
@@ -144,13 +143,13 @@
<ClInclude Include="include\Engine\Engine.h"/>
<ClInclude Include="include\Graphics\Colors.h"/>
<ClInclude Include="include\Graphics\Graphics.h"/>
<ClInclude Include="include\Graphics\GraphicsBuffer.h" />
<ClInclude Include="include\Graphics\GraphicsConfig.h"/>
<ClInclude Include="include\Graphics\GraphicsPipeline.h" />
<ClInclude Include="include\Graphics\RenderPass.h"/>
<ClInclude Include="include\Graphics\Shader.h" />
<ClInclude Include="include\Graphics\Texture.h"/>
<ClInclude Include="include\Juliet.h"/>
<ClInclude Include="include\pch.h"/>
<ClInclude Include="src\Core\HAL\Display\DisplayDevice.h"/>
<ClInclude Include="src\Core\HAL\Display\Display_Private.h"/>
<ClInclude Include="src\Core\HAL\Display\Win32\Win32DisplayEvent.h"/>
@@ -186,6 +185,7 @@
<ClInclude Include="src\Graphics\D3D12\AgilitySDK\d3dx12\d3dx12_root_signature.h" />
<ClInclude Include="src\Graphics\D3D12\AgilitySDK\d3dx12\d3dx12_state_object.h" />
<ClInclude Include="src\Graphics\D3D12\AgilitySDK\dxgiformat.h" />
<ClInclude Include="src\Graphics\D3D12\D3D12Buffer.h" />
<ClInclude Include="src\Graphics\D3D12\D3D12Common.h"/>
<ClInclude Include="src\Graphics\D3D12\D3D12DescriptorHeap.h" />
<ClInclude Include="src\Graphics\D3D12\D3D12GraphicsPipeline.h" />
@@ -231,6 +231,7 @@
<ClCompile Include="src\Core\Networking\Win32\Win32SocketPlatformImpl.cpp" />
<ClCompile Include="src\Engine\Engine.cpp" />
<ClCompile Include="src\Graphics\D3D12\AgilitySDK\d3dx12\d3dx12_property_format_table.cpp" />
<ClCompile Include="src\Graphics\D3D12\D3D12Buffer.cpp" />
<ClCompile Include="src\Graphics\D3D12\D3D12Common.cpp" />
<ClCompile Include="src\Graphics\D3D12\D3D12DescriptorHeap.cpp" />
<ClCompile Include="src\Graphics\D3D12\D3D12GraphicsPipeline.cpp" />
@@ -242,64 +243,7 @@
<ClCompile Include="src\Graphics\D3D12\D3D12GraphicsDevice.cpp" />
<ClCompile Include="src\Graphics\D3D12\D3D12SwapChain.cpp" />
<ClCompile Include="src\Graphics\D3D12\D3D12Utils.cpp" />
<ClCompile Include="src\Graphics\Graphics.cpp">
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
<Optimization>Disabled</Optimization>
<SupportJustMyCode>true</SupportJustMyCode>
<AssemblerOutput>NoListing</AssemblerOutput>
<AssemblerListingLocation>W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\</AssemblerListingLocation>
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
<BrowseInformationFile>W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\</BrowseInformationFile>
<CompileAs>Default</CompileAs>
<ConformanceMode>Default</ConformanceMode>
<DiagnosticsFormat>Column</DiagnosticsFormat>
<ExceptionHandling>false</ExceptionHandling>
<EnableASAN>false</EnableASAN>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<IntrinsicFunctions>false</IntrinsicFunctions>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>Default</LanguageStandard_C>
<ModuleDependenciesFile>W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\</ModuleDependenciesFile>
<OmitDefaultLibName>false</OmitDefaultLibName>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<ObjectFileName>W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\</ObjectFileName>
<CallingConvention>Cdecl</CallingConvention>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\Juliet.pch</PrecompiledHeaderOutputFile>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessKeepComments>false</PreprocessKeepComments>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
<ShowIncludes>false</ShowIncludes>
<SourceDependenciesFile>W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\</SourceDependenciesFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<BufferSecurityCheck>true</BufferSecurityCheck>
<SmallerTypeCheck>false</SmallerTypeCheck>
<StructMemberAlignment>Default</StructMemberAlignment>
<TrackerLogDirectory>W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\Juliet.tlog\</TrackerLogDirectory>
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
<TreatWarningAsError>false</TreatWarningAsError>
<WarningLevel>Level3</WarningLevel>
<XMLDocumentationFileName>W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\</XMLDocumentationFileName>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<IntelJCCErratum>false</IntelJCCErratum>
<BuildStlModules>false</BuildStlModules>
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
<PreprocessorDefinitions>_DEBUG;_LIB;JULIET_WIN32;_UNICODE;UNICODE;</PreprocessorDefinitions>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<LibCompiled>true</LibCompiled>
<ClangClMode>true</ClangClMode>
<MSCVersion>Default</MSCVersion>
<AdditionalOptions>--target=amd64-pc-windows-msvc</AdditionalOptions>
</ClCompile>
<ClCompile Include="src\pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="src\Graphics\Graphics.cpp" />
</ItemGroup>
<ItemGroup>
<Content Include="include\Core\Thread\Mutex.h" />

View File

@@ -1,6 +1,8 @@
#pragma once
#include <Core/Application/IApplication.h>
#include <Core/Common/CoreTypes.h>
#include <Juliet.h>
namespace Juliet
{

View File

@@ -4,34 +4,53 @@
#include <Juliet.h>
#include <algorithm>
#include <source_location>
namespace Juliet
{
#if _DEBUG
#define Assert(expression) \
do \
#if JULIET_DEBUG
#define JULIET_ASSERT_INTERNAL(expression, message) \
__pragma(warning(push)) __pragma(warning(disable : 4127)) __pragma(warning(disable : 4548)) do \
{ \
if (!(expression)) \
{ \
Juliet::JulietAssert("Assertion Failed: " #expression); \
Juliet::JulietAssert(#expression, message); \
} \
} \
while (0) \
__pragma(warning(pop))
#define AssertHR(hr_expression, message) \
do \
{ \
long hr_val = (hr_expression); \
if (hr_val < 0) \
{ \
Juliet::JulietAssert(#hr_expression, message, std::source_location::current(), hr_val); \
} \
} \
while (0)
#define GET_ASSERT_MACRO(_1, _2, NAME, ...) NAME
#define Assert(...) GET_ASSERT_MACRO(__VA_ARGS__, JULIET_ASSERT_INTERNAL, JULIET_ASSERT_NO_MSG)(__VA_ARGS__)
#define JULIET_ASSERT_NO_MSG(expression) JULIET_ASSERT_INTERNAL(expression, "No additional information provided.")
#define Unimplemented() \
do \
{ \
Juliet::JulietAssert("Unimplemented!"); \
Juliet::JulietAssert("UNIMPLEMENTED", "This code path is not yet functional."); \
} \
while (0)
#else
#define Assert(Expression)
#define Unimplemented()
#define Assert(...) ((void)0)
#define AssertHR(hr_expression, message) ((void)(hr_expression))
#define Unimplemented() ((void)0)
#endif
extern void JULIET_API JulietAssert(const char* expression);
JULIET_API extern void JulietAssert(const char* expression, const char* message,
std::source_location location = std::source_location::current(), long handleResult = 0);
#define ZeroStruct(structInstance) ZeroSize(sizeof(structInstance), &(structInstance))
#define ZeroArray(array) ZeroSize(sizeof((array)), (array))

View File

@@ -4,87 +4,87 @@
namespace Juliet
{
template <typename T>
concept IsEnum = std::is_enum_v<T>;
template <typename E>
requires std::is_enum_v<E>
E operator~(E lhs)
template <IsEnum E>
constexpr E operator~(E lhs) noexcept
{
using underlying = std::underlying_type_t<E>;
return static_cast<E>(~static_cast<underlying>(lhs));
return static_cast<E>(~static_cast<std::underlying_type_t<E>>(lhs));
}
template <typename E>
requires std::is_enum_v<E>
E operator|(E lhs, E rhs)
template <IsEnum E>
constexpr E operator|(E lhs, E rhs) noexcept
{
using underlying = std::underlying_type_t<E>;
return static_cast<E>(static_cast<underlying>(lhs) | static_cast<underlying>(rhs));
return static_cast<E>(static_cast<std::underlying_type_t<E>>(lhs) | static_cast<std::underlying_type_t<E>>(rhs));
}
template <typename E>
requires std::is_enum_v<E>
E& operator|=(E& lhs, E rhs)
template <IsEnum E>
constexpr E& operator|=(E& lhs, E rhs) noexcept
{
return lhs = lhs | rhs;
return lhs = (lhs | rhs);
}
template <typename E>
requires std::is_enum_v<E>
E operator&(E lhs, E rhs)
template <IsEnum E>
constexpr E operator&(E lhs, E rhs) noexcept
{
using underlying = std::underlying_type_t<E>;
return static_cast<E>(static_cast<underlying>(lhs) & static_cast<underlying>(rhs));
return static_cast<E>(static_cast<std::underlying_type_t<E>>(lhs) & static_cast<std::underlying_type_t<E>>(rhs));
}
template <typename E>
requires std::is_enum_v<E>
E& operator&=(E& lhs, E rhs)
template <IsEnum E>
constexpr E& operator&=(E& lhs, E rhs) noexcept
{
return lhs = lhs & rhs;
return lhs = (lhs & rhs);
}
template <typename E>
requires std::is_enum_v<E>
E operator+(const E& lhs, const E& rhs)
template <IsEnum E>
constexpr E operator^(E lhs, E rhs) noexcept
{
using underlying = std::underlying_type_t<E>;
return static_cast<E>(static_cast<underlying>(lhs) + static_cast<underlying>(rhs));
return static_cast<E>(static_cast<std::underlying_type_t<E>>(lhs) ^ static_cast<std::underlying_type_t<E>>(rhs));
}
template <typename E>
requires std::is_enum_v<E>
E operator-(const E& lhs, const E& rhs)
template <IsEnum E>
constexpr E& operator^=(E& lhs, E rhs) noexcept
{
using underlying = std::underlying_type_t<E>;
return static_cast<E>(static_cast<underlying>(lhs) - static_cast<underlying>(rhs));
return lhs = (lhs ^ rhs);
}
template <typename E>
requires std::is_enum_v<E>
E operator^(const E& lhs, const E& rhs)
template <IsEnum E>
constexpr std::underlying_type_t<E> operator-(E lhs, E rhs) noexcept
{
using underlying = std::underlying_type_t<E>;
return static_cast<E>(static_cast<underlying>(lhs) ^ static_cast<underlying>(rhs));
using T = std::underlying_type_t<E>;
return static_cast<T>(static_cast<T>(lhs) - static_cast<T>(rhs));
}
template <typename E>
requires std::is_enum_v<E>
E& operator^=(E& lhs, const E& rhs)
template <IsEnum E>
constexpr std::underlying_type_t<E> operator+(E lhs, E rhs) noexcept
{
return lhs = lhs ^ rhs;
using T = std::underlying_type_t<E>;
return static_cast<T>(static_cast<T>(lhs) + static_cast<T>(rhs));
}
template <typename E>
requires std::is_enum_v<E>
constexpr std::underlying_type_t<E> ToUnderlying(E enm)
template <IsEnum E>
constexpr E operator-(E lhs, std::underlying_type_t<E> rhs) noexcept
{
using underlying = std::underlying_type_t<E>;
return static_cast<underlying>(enm);
using T = std::underlying_type_t<E>;
return static_cast<E>(static_cast<T>(static_cast<T>(lhs) - rhs));
}
template <typename E>
requires std::is_enum_v<E>
constexpr E ToEnum(std::underlying_type_t<E> value)
template <IsEnum E>
constexpr E operator+(E lhs, std::underlying_type_t<E> rhs) noexcept
{
using T = std::underlying_type_t<E>;
return static_cast<E>(static_cast<T>(static_cast<T>(lhs) + rhs));
}
template <IsEnum E>
constexpr std::underlying_type_t<E> ToUnderlying(E enm) noexcept
{
return static_cast<std::underlying_type_t<E>>(enm);
}
template <IsEnum E>
constexpr E ToEnum(std::underlying_type_t<E> value) noexcept
{
return static_cast<E>(value);
}

View File

@@ -100,7 +100,7 @@ namespace Juliet
return *this;
}
explicit operator bool() const { return true; };
explicit operator bool() const { return true; }
private:
Type* InternalPtr;

View File

@@ -50,7 +50,7 @@ namespace Juliet
extern JULIET_API IOStream* IOFromFile(String filename, String mode);
// Let you use an interface to open any io. Is used internally by IOFromFile
extern JULIET_API IOStream* IOFromInterface(NonNullPtr<const IOStreamInterface> interface, NonNullPtr<IOStreamDataPayload> payload);
extern JULIET_API IOStream* IOFromInterface(NonNullPtr<const IOStreamInterface> streamInterface, NonNullPtr<IOStreamDataPayload> payload);
// Write formatted string into the stream.
extern JULIET_API size_t IOPrintf(NonNullPtr<IOStream> stream, _Printf_format_string_ const char* format, ...);

View File

@@ -1,5 +1,7 @@
#pragma once
#include <Core/Common/CoreTypes.h>
namespace Juliet
{
// Represents a Virtual Key corresponding to the Physical key, but localized using the keyboard layout

View File

@@ -2,6 +2,7 @@
#include <Core/HAL/Keyboard/KeyCode.h>
#include <Core/HAL/Keyboard/ScanCode.h>
#include <Juliet.h>
namespace Juliet
{

View File

@@ -6,6 +6,7 @@
// TODO : Juliet strings
#include <string>
// TODO Juliet Containers + Allocators...
#include <chrono>
#include <deque>
namespace Juliet
@@ -25,10 +26,10 @@ namespace Juliet
private:
struct Entry
{
std::string Value;
uint64_t Time;
LogLevel Level;
LogCategory Category;
std::string Value;
std::chrono::system_clock::time_point Time;
LogLevel Level;
LogCategory Category;
Entry(std::string& value, LogLevel level, LogCategory category);
};

View File

@@ -9,7 +9,7 @@ namespace Juliet
inline int32 LRoundF(float value)
{
return RoundF(value);
return static_cast<int32>(RoundF(value));
}
template <typename Type>

View File

@@ -1,6 +1,7 @@
#pragma once
#include <Juliet.h>
#include <Core/Common/CoreUtils.h>
#include <cstdlib>

View File

@@ -1,6 +1,6 @@
#pragma once
#include <core/Common/CoreTypes.h>
#include <Core/Common/CoreTypes.h>
#include <Core/Container/Vector.h>
namespace Juliet

View File

@@ -13,6 +13,9 @@ namespace Juliet
Socket(Socket&& other) noexcept;
Socket& operator=(Socket&& socket) noexcept;
Socket(const Socket&) = delete;
Socket& operator=(const Socket&) = delete;
bool IsValid() const;
enum class Status : uint8

View File

@@ -11,6 +11,9 @@ namespace Juliet
public:
TcpListener();
TcpListener(const TcpListener&) = delete;
TcpListener& operator=(const TcpListener&) = delete;
Status Listen(uint16 port, uint32 address = kAnyIp);
Status Accept(TcpSocket& socket);
void Close();

View File

@@ -11,6 +11,9 @@ namespace Juliet
public:
TcpSocket();
TcpSocket(const TcpSocket&) = delete;
TcpSocket& operator=(const TcpSocket&) = delete;
RequestStatus Send(NetworkPacket& packet);
RequestStatus Send(ByteBuffer buffer);
Status Receive(NetworkPacket& outPacket);

View File

@@ -4,14 +4,17 @@
#include <Core/Common/String.h>
#include <Core/HAL/Display/Display.h>
#include <Core/Math/Shape.h>
#include <Graphics/GraphicsBuffer.h>
#include <Graphics/GraphicsConfig.h>
#include <Graphics/GraphicsPipeline.h>
#include <Graphics/RenderPass.h>
#include <Graphics/Shader.h>
#include <Juliet.h>
#ifdef JULIET_DEBUG
#if JULIET_DEBUG
#define ALLOW_SHADER_HOT_RELOAD 1
#else
#define ALLOW_SHADER_HOT_RELOAD 0
#endif
// Graphics Interface
@@ -138,4 +141,10 @@ namespace Juliet
Shader* optional_vertexShader, Shader* optional_fragmentShader);
#endif
// Buffers
extern GraphicsBuffer* CreateGraphicsBuffer(NonNullPtr<GraphicsDevice> device, const BufferCreateInfo& createInfo);
extern GraphicsTransferBuffer* CreateGraphicsTransferBuffer(NonNullPtr<GraphicsDevice> device,
const TransferBufferCreateInfo& createInfo);
extern void ReleaseGraphicsBuffer(NonNullPtr<GraphicsDevice> device, NonNullPtr<GraphicsBuffer> buffer);
extern void ReleaseGraphicsTransferBuffer(NonNullPtr<GraphicsDevice> device, NonNullPtr<GraphicsTransferBuffer> buffer);
} // namespace Juliet

View File

@@ -0,0 +1,34 @@
#pragma once
namespace Juliet
{
enum class BufferUsage : uint8
{
None = 0,
IndexBuffer = 1 << 0,
ConstantBuffer = 1 << 1,
StructuredBuffer = 1 << 2,
};
enum class TransferBufferUsage : uint8
{
Download,
Upload
};
struct BufferCreateInfo
{
size_t Size;
BufferUsage Usage;
};
struct TransferBufferCreateInfo
{
size_t Size;
TransferBufferUsage Usage;
};
// Opaque
struct GraphicsBuffer;
struct GraphicsTransferBuffer;
} // namespace Juliet

View File

@@ -19,7 +19,9 @@
# endif
#endif
#if _DEBUG
#ifdef DEBUG
#define JULIET_DEBUG 1
#else
#define JULIET_DEBUG 0
#endif
// clang-format on

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Application/ApplicationManager.h>
#include <Core/JulietInit.h>

View File

@@ -1,13 +1,39 @@
#include <pch.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
#include <comdef.h> // For _com_error to decode HRESULTs
#include <intrin.h> // For __debugbreak
namespace Juliet
{
void JulietAssert(const char* expression)
void JulietAssert(const char* expression, const char* message, std::source_location location, long handleResult)
{
Log(LogLevel::Error, LogCategory::Core, expression);
__debugbreak();
Log(LogLevel::Error, LogCategory::Core, "--- ASSERTION FAILED ---");
Log(LogLevel::Error, LogCategory::Core, "Expression: %s", expression);
Log(LogLevel::Error, LogCategory::Core, "Message: %s", message);
Log(LogLevel::Error, LogCategory::Core, "Location: %s(%u): %s",
location.file_name(),
location.line(),
location.function_name());
if (handleResult < 0)
{
_com_error err(handleResult);
// Using %ls because ErrorMessage() returns a wide string (wchar_t*)
Log(LogLevel::Error, LogCategory::Graphics, "HRESULT: 0x%08X (%ls)", handleResult, err.ErrorMessage());
}
Log(LogLevel::Error, LogCategory::Core, "-------------------------");
if (IsDebuggerPresent())
{
__debugbreak();
}
else
{
exit(1);
}
}
void Free(ByteBuffer& buffer)

View File

@@ -1,6 +1,7 @@
#include <pch.h>
#include <Core/Common/CoreUtils.h>
#include <Core/Common/String.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Utils.h>
namespace Juliet
@@ -222,13 +223,13 @@ namespace Juliet
{
{
uint32 leftFolded[3];
int8 num_folded = CaseFoldUnicode(StepUTF8(str1), leftFolded);
[[maybe_unused]] int8 num_folded = CaseFoldUnicode(StepUTF8(str1), leftFolded);
Assert(num_folded == 1); // Only one uint32 codepoint supported for now (low ascii)
left = leftFolded[0];
}
{
uint32 rightFolded[3];
int8 num_folded = CaseFoldUnicode(StepUTF8(str2), rightFolded);
[[maybe_unused]] int8 num_folded = CaseFoldUnicode(StepUTF8(str2), rightFolded);
Assert(num_folded == 1); // Only one uint32 codepoint supported for now (low ascii)
right = rightFolded[0];
}
@@ -357,13 +358,13 @@ namespace Juliet
}
break;
}
case StringEncoding::Unknown: Assert(false && "ConvertString: Invalid Source Format: Unknown"); break;
case StringEncoding::Unknown: Assert(false, "ConvertString: Invalid Source Format: Unknown"); break;
case StringEncoding::ASCII:
case StringEncoding::LATIN1:
case StringEncoding::UTF16:
case StringEncoding::UTF32:
case StringEncoding::UCS2:
case StringEncoding::UCS4: Assert(false && "ConvertString: Unsupported Source Format"); break;
case StringEncoding::UCS4: Assert(false, "ConvertString: Unsupported Source Format"); break;
}
// Encode out character
@@ -398,8 +399,8 @@ namespace Juliet
return false;
}
character = character - 0x10000;
uint16 word1 = 0xD800 | static_cast<uint16>((character >> 10) & 0x3FF);
uint16 word2 = 0xDC00 | static_cast<uint16>(character & 0x3FF);
uint16 word1 = 0xD800U | static_cast<uint16>((character >> 10) & 0x3FF);
uint16 word2 = 0xDC00U | static_cast<uint16>(character & 0x3FF);
p[1] = static_cast<uint8>(word1 >> 8);
p[0] = static_cast<uint8>(word1);
p[3] = static_cast<uint8>(word2 >> 8);
@@ -411,13 +412,13 @@ namespace Juliet
}
break;
}
case StringEncoding::Unknown: Assert(false && "ConvertString: Invalid Source Format: Unknown"); break;
case StringEncoding::Unknown: Assert(false, "ConvertString: Invalid Source Format: Unknown"); break;
case StringEncoding::ASCII:
case StringEncoding::LATIN1:
case StringEncoding::UTF8:
case StringEncoding::UTF32:
case StringEncoding::UCS2:
case StringEncoding::UCS4: Assert(false && "ConvertString: Unsupported Destination Format"); break;
case StringEncoding::UCS4: Assert(false, "ConvertString: Unsupported Destination Format"); break;
}
}
return true;

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Common/CoreTypes.h>
#include <Core/HAL/Display/Display_Private.h>
#include <Core/HAL/Display/DisplayDevice.h>
@@ -67,7 +65,7 @@ namespace Juliet
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);
@@ -79,6 +77,14 @@ namespace Juliet
window->Width = width;
window->Height = height;
// TODO String creator that copy
auto titleLen = StringLength(title);
auto buffer = static_cast<char*>(Calloc(titleLen, sizeof(char)));
MemCopy(buffer, title, titleLen);
window->Title.Data = buffer;
window->Title.Size = titleLen;
CurrentDisplayDevice->MainWindow = window;
if (!CurrentDisplayDevice->CreatePlatformWindow(CurrentDisplayDevice, window))
{
@@ -98,6 +104,10 @@ namespace Juliet
HideWindow(window);
// TODO : Free string function
SafeFree(window->Title.Data);
window->Title.Size = 0;
CurrentDisplayDevice->DestroyPlatformWindow(CurrentDisplayDevice, window);
Free(window.Get());

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/HAL/Display/DisplayDevice.h>
#include <Core/HAL/Display/Win32/Win32DisplayEvent.h>
#include <Core/HAL/Display/Win32/Win32Window.h>
@@ -9,11 +7,11 @@ namespace Juliet::Win32
{
namespace
{
bool Initialize(NonNullPtr<DisplayDevice> self)
bool Initialize(NonNullPtr<DisplayDevice> /*self*/)
{
return true;
}
void Shutdown(NonNullPtr<DisplayDevice> self) {}
void Shutdown(NonNullPtr<DisplayDevice> /*self*/) {}
void Free(NonNullPtr<DisplayDevice> self)
{
Juliet::Free(self.Get());

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Common/EnumUtils.h>
#include <Core/HAL/Display/DisplayDevice.h>
#include <Core/HAL/Display/Win32/Win32DisplayEvent.h>
@@ -33,7 +31,7 @@ namespace Juliet::Win32
{
if (window)
{
auto state = reinterpret_cast<Window32State*>(window->State);
auto state = static_cast<Window32State*>(window->State);
if (state && state->Handle == handle)
{
return state;
@@ -46,7 +44,7 @@ namespace Juliet::Win32
}
// Win32 Keyboard Utils
Key GetScanScodeFromWinScanCode(WPARAM wParam, LPARAM lParam)
Key GetScanScodeFromWinScanCode(WPARAM /*wParam*/, LPARAM lParam)
{
Key key = {};
@@ -70,14 +68,14 @@ namespace Juliet::Win32
}
else
{
Assert(false && "Virtual Key : Unimplemented");
Assert(false, "Virtual Key : Unimplemented");
// uint16 virtualKey = LOWORD(wParam);
}
// Pack the scancode to have everything within one byte.
// Because scancode low byte are never bigger than 0x7F
// We can use the most significant bit to store anything that is in the High Byte of the scancode
uint8 index = LOBYTE(scanCode) | (HIBYTE(scanCode) ? 0x80 : 0x00);
uint8 index = static_cast<uint8>(LOBYTE(scanCode) | (HIBYTE(scanCode) ? 0x80 : 0x00));
key.ScanCode = Win32ToHIDUsagePageTable[index];
key.Raw = scanCode;
@@ -111,7 +109,7 @@ namespace Juliet::Win32
}
}
WPARAM LastFrameButtonState = -1;
WPARAM LastFrameButtonState = static_cast<WPARAM>(-1);
void ExtractAllMouseButtonState(uint64 timestamp, WPARAM wParam, NonNullPtr<Window32State> windowState, MouseID mouseID)
{
if (wParam != LastFrameButtonState)
@@ -130,7 +128,7 @@ namespace Juliet::Win32
}
} // namespace
void PumpEvents(NonNullPtr<DisplayDevice> self)
void PumpEvents(NonNullPtr<DisplayDevice> /*self*/)
{
uint8 peekedMessageCount = 0;
MSG message = {};
@@ -211,7 +209,8 @@ namespace Juliet::Win32
windowState->IsMouseTracked = true;
}
SendMouseMotion(1, windowState->Window, kGlobalMouseID, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
SendMouseMotion(1, windowState->Window, kGlobalMouseID, static_cast<float>(GET_X_LPARAM(lParam)),
static_cast<float>(GET_Y_LPARAM(lParam)));
break;
}

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/HAL/Display/Win32/Win32DisplayEvent.h>
#include <Core/HAL/Display/Win32/Win32Window.h>
#include <Core/HAL/Display/Window.h>
@@ -12,7 +10,7 @@ namespace Juliet::Win32
constexpr auto WindowClassName = "JulietWindowClass";
constexpr LPCSTR WindowClassPtr = WindowClassName;
bool SetupWindowState(NonNullPtr<DisplayDevice> self, NonNullPtr<Window> window, HWND handle)
bool SetupWindowState(NonNullPtr<DisplayDevice> /*self*/, NonNullPtr<Window> window, HWND handle)
{
auto state = static_cast<Window32State*>(Calloc(1, sizeof(Window32State)));
window->State = state;
@@ -27,9 +25,9 @@ namespace Juliet::Win32
return true;
}
void CleanUpWindowState(NonNullPtr<DisplayDevice> self, NonNullPtr<Window> window)
void CleanUpWindowState(NonNullPtr<DisplayDevice> /*self*/, NonNullPtr<Window> window)
{
if (auto* state = reinterpret_cast<Window32State*>(window->State))
if (auto* state = static_cast<Window32State*>(window->State))
{
ReleaseDC(state->Handle, state->HDC);
DestroyWindow(state->Handle);
@@ -51,7 +49,7 @@ namespace Juliet::Win32
WindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
WindowClass.lpfnWndProc = Win32MainWindowCallback;
WindowClass.hInstance = instance;
WindowClass.hCursor = LoadCursor(0, IDC_ARROW);
WindowClass.hCursor = LoadCursor(nullptr, IDC_ARROW);
WindowClass.hbrBackground = static_cast<HBRUSH>(GetStockObject(LTGRAY_BRUSH));
WindowClass.lpszClassName = WindowClassName;
if (!RegisterClassExA(&WindowClass))
@@ -83,18 +81,18 @@ namespace Juliet::Win32
CleanUpWindowState(self, window);
}
void ShowWindow(NonNullPtr<DisplayDevice> self, NonNullPtr<Window> window)
void ShowWindow(NonNullPtr<DisplayDevice> /*self*/, NonNullPtr<Window> window)
{
Assert(window);
Assert(window->State);
auto& win32State = reinterpret_cast<Window32State&>(*window->State);
auto& win32State = static_cast<Window32State&>(*window->State);
::ShowWindow(win32State.Handle, SW_SHOW);
}
void HideWindow(NonNullPtr<DisplayDevice> self, NonNullPtr<Window> window)
void HideWindow(NonNullPtr<DisplayDevice> /*self*/, NonNullPtr<Window> window)
{
auto& win32State = reinterpret_cast<Window32State&>(*window->State);
auto& win32State = static_cast<Window32State&>(*window->State);
::ShowWindow(win32State.Handle, SW_HIDE);
}
} // namespace Juliet::Win32

View File

@@ -1,5 +1,6 @@
#pragma once
#include <Core/Common/String.h>
#include <Core/HAL/Display/Display.h>
namespace Juliet
@@ -17,5 +18,6 @@ namespace Juliet
int32 Width;
int32 Height;
String Title;
};
} // namespace Juliet

View File

@@ -1,7 +1,7 @@
#include <pch.h>
#include <Core/HAL/DynLib/DynamicLibrary.h>
#include <Core/HAL/Win32.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
namespace Juliet
{
@@ -26,12 +26,15 @@ namespace Juliet
FunctionPtr LoadFunction(NonNullPtr<DynamicLibrary> lib, const char* functionName)
{
#pragma warning(push)
#pragma warning(disable: 4191) // Disable "unsafe conversion from FARPROC"
auto function = reinterpret_cast<FunctionPtr>(GetProcAddress(reinterpret_cast<HMODULE>(lib.Get()), functionName));
if (!function)
{
Log(LogLevel::Error, LogCategory::Core, "Failed loading %s", functionName);
}
return function;
#pragma warning(pop)
}
void UnloadDynamicLibrary(NonNullPtr<DynamicLibrary> lib)

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Common/EnumUtils.h>
#include <Core/HAL/Event/Keyboard_Private.h>
#include <Core/HAL/Event/KeyboardMapping.h>
@@ -17,7 +15,7 @@ namespace Juliet
KeyMod KeyModState;
} KeyboardState;
bool SendKeyboardKey_Internal(uint64 timestamp, KeyboardID ID, Key key, KeyState keyState)
bool SendKeyboardKey_Internal(uint64 timestamp, KeyboardID /*ID*/, Key key, KeyState keyState)
{
Assert(key.KeyCode == KeyCode::Unknown); // At this point Keycode is not yet extracted

View File

@@ -1,5 +1,4 @@
#include <pch.h>
#include <Core/Common/CoreUtils.h>
#include <Core/Common/EnumUtils.h>
#include <Core/HAL/Event/KeyboardMapping.h>
#include <Core/HAL/Keyboard/KeyCode.h>
@@ -161,7 +160,7 @@ namespace Juliet
{
if (scanCode <= ScanCode::Unknown || scanCode > ScanCode::Count)
{
Assert(false && "Unsupported KeyCode (out of bounds)");
Assert(false , "Unsupported KeyCode (out of bounds)");
return KeyCode::Unknown;
}
@@ -173,7 +172,7 @@ namespace Juliet
// Handles A-Z characters
if (scanCode <= ScanCode::Z)
{
const auto index = ToUnderlying(scanCode - ScanCode::A);
const auto index = scanCode - ScanCode::A;
bool isShiftPressed = (keyModState & KeyMod::Shift) != KeyMod::None;
if ((keyModState & KeyMod::CapsLock) != KeyMod::None)
{
@@ -182,15 +181,15 @@ namespace Juliet
if (isShiftPressed)
{
return ToEnum<KeyCode>('A' + index);
return ToEnum<KeyCode>(static_cast<uint32>('A') + index);
}
return ToEnum<KeyCode>('a' + index);
return ToEnum<KeyCode>(static_cast<uint32>('a') + index);
}
// Handles Num1 to Num0
if (scanCode <= ScanCode::Num0)
{
const auto index = ToUnderlying<>(scanCode - ScanCode::Num1);
const auto index = scanCode - ScanCode::Num1;
const bool isShiftPressed = (keyModState & KeyMod::Shift) != KeyMod::None;
if (isShiftPressed)
{

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Common/EnumUtils.h>
#include <Core/HAL/Display/Window.h>
#include <Core/HAL/Event/Mouse_Private.h>

View File

@@ -1,4 +1,4 @@
#include <pch.h>
#include <chrono>
#include <queue>
#include <Core/HAL/Display/DisplayDevice.h>
@@ -36,25 +36,44 @@ namespace Juliet
return WaitEvent(event, 0);
}
// TODO : use chrono to tag the timeout correctly with nanosec
// timeout == -1 means wait for any event before pursuing
// timeout == 0 means checking once for the frame and getting out
// timeout > 0 means wait until time is out
bool WaitEvent(SystemEvent& event, int32 timeoutInNS /* = -1 */)
{
PumpEvents();
using namespace std::chrono;
if (eventQueue.empty())
// Handle the "Infinite Wait" and "Timed Wait" logic
const bool isInfinite = (timeoutInNS < 0);
const nanoseconds timeout(timeoutInNS);
const auto startTime = steady_clock::now();
while (true)
{
// TODO : Infinite loop here to wait for event if timeout > 0
PumpEvents();
return false;
if (!eventQueue.empty())
{
event = eventQueue.front();
eventQueue.pop();
return true;
}
// If timeout is 0, we only check once (PumpEvents already ran)
if (timeoutInNS == 0)
{
break;
}
// Check if we have exceeded our time limit
if (!isInfinite)
{
auto elapsed = steady_clock::now() - startTime;
if (elapsed >= timeout)
{
break;
}
}
}
event = eventQueue.front();
eventQueue.pop();
return true;
return false;
}
bool AddEvent(SystemEvent& event)

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/HAL/Display/Window.h>
#include <Core/HAL/Event/SystemEvent.h>
#include <Core/HAL/Event/WindowEvent.h>

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Common/String.h>
#include <Core/HAL/Filesystem/Filesystem.h>
#include <Core/HAL/Filesystem/Filesystem_Platform.h>

View File

@@ -1,8 +1,8 @@
#include <pch.h>
#include <Core/Common/String.h>
#include <Core/HAL/Filesystem/Filesystem_Platform.h>
#include <Core/HAL/Win32.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
namespace Juliet::Platform

View File

@@ -1,8 +1,9 @@
#include <pch.h>
#include <Core/HAL/IO/IOStream.h>
#include <Core/Common/String.h>
#include <Core/HAL/IO/IOStream.h>
#include <Core/HAL/IO/IOStream_Private.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
#include <Core/Thread/Thread.h>
#include <cstdarg>
@@ -25,15 +26,15 @@ namespace Juliet
return Internal::IOFromFile(filename, mode);
}
IOStream* IOFromInterface(NonNullPtr<const IOStreamInterface> interface, NonNullPtr<IOStreamDataPayload> payload)
IOStream* IOFromInterface(NonNullPtr<const IOStreamInterface> streamInterface, NonNullPtr<IOStreamDataPayload> payload)
{
Assert(interface->Version >= sizeof(*interface.Get()));
Assert(streamInterface->Version >= sizeof(*streamInterface.Get()));
auto stream = static_cast<IOStream*>(Calloc(1, sizeof(IOStream)));
if (stream)
{
IOStreamInterface* dstInterface = &stream->Interface;
const IOStreamInterface* srcInterface = interface.Get();
const IOStreamInterface* srcInterface = streamInterface.Get();
static_assert(sizeof(*(dstInterface)) == sizeof(*(srcInterface)), "Source and Destination type mismatch");
MemCopy(dstInterface, srcInterface, sizeof(*srcInterface));
stream->Data = payload.Get();
@@ -54,7 +55,7 @@ namespace Juliet
Assert(writtenSize >= 0);
ByteBuffer buffer = {.Data = reinterpret_cast<Byte*>(formattedBuffer), .Size = static_cast<size_t>(writtenSize) };
ByteBuffer buffer = { .Data = reinterpret_cast<Byte*>(formattedBuffer), .Size = static_cast<size_t>(writtenSize) };
return IOWrite(stream, buffer);
}
@@ -161,13 +162,14 @@ namespace Juliet
// Try reading the size from the stream, if failing we'll try to read it chunk by chunk
bool loadChunks = false;
int64 size = IOSize(stream);
if (size < 0)
int64 ssize = IOSize(stream);
if (ssize < 0)
{
size = kFileChunkSize;
ssize = kFileChunkSize;
loadChunks = true;
}
data = static_cast<uint8*>(Malloc(static_cast<size_t>(size + 1)));
size_t size = static_cast<size_t>(ssize);
data = static_cast<uint8*>(Malloc(static_cast<size_t>(size + 1)));
if (!data)
{
return {};
@@ -179,7 +181,7 @@ namespace Juliet
{
if ((totalSize + kFileChunkSize) > size)
{
size = static_cast<int64>(totalSize + kFileChunkSize);
size = totalSize + kFileChunkSize;
newData = static_cast<uint8*>(Realloc(data, static_cast<size_t>(size + 1)));
if (!newData)
{

View File

@@ -1,9 +1,9 @@
#include <pch.h>
#include <Core/Common/EnumUtils.h>
#include <Core/Common/String.h>
#include <Core/HAL/IO/IOStream.h>
#include <Core/HAL/Win32.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
namespace Juliet::Internal
@@ -197,7 +197,7 @@ namespace Juliet::Internal
// "a+"= append + read, file may not exist
// "w+" = read, write, truncate. file may not exist
#if _DEBUG
#if JULIET_DEBUG
// Making sure the mode is valid
size_t modeLength = StringLength(mode);
Assert((modeLength <= 2) &&

View File

@@ -15,11 +15,20 @@
#endif
// Only Supports Win10 and greater
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#endif
#undef WINVER
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0A00
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#define WINVER _WIN32_WINNT
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#define NOIME
#define NOWINRES
#define NOGDICAPMASKS

View File

@@ -1,7 +1,7 @@
#include <pch.h>
#include <Core/HAL/Filesystem/Filesystem.h>
#include <Core/HotReload/HotReload.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
#include <Core/Thread/Thread.h>
@@ -29,7 +29,7 @@ namespace Juliet
Log(LogLevel::Error, LogCategory::Core, "Cannot create DLL Full Path");
return;
}
code.DLLFullPath.Size = writtenSize;
code.DLLFullPath.Size = static_cast<size_t>(writtenSize);
// Lock filename path
const size_t lockPathLength = basePathLength + StringLength(lockFilename) + 1; // Need +1 because snprintf needs 0 terminated strings
@@ -42,7 +42,7 @@ namespace Juliet
Log(LogLevel::Error, LogCategory::Core, "Cannot create lock file full path");
return;
}
code.LockFullPath.Size = writtenSize;
code.LockFullPath.Size = static_cast<size_t>(writtenSize);
LoadCode(code);
}

View File

@@ -1,9 +1,9 @@
#include <pch.h>
#include <Core/HAL/DynLib/DynamicLibrary.h>
#include <Core/HAL/Filesystem/Filesystem.h>
#include <Core/HAL/Win32.h>
#include <Core/HotReload/HotReload.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
namespace Juliet
@@ -59,10 +59,23 @@ namespace Juliet
// int to char
char idToStr[kTempDLLBufferSizeForID + 1];
int idLength = snprintf(idToStr, sizeof(idToStr), "%u", code.UniqueID);
if (idLength < 0)
{
SafeFree(tempDllPath);
Log(LogLevel::Error, LogCategory::Core, "Cannot create temp full path");
return;
}
int writtenSize = snprintf(tempDllPath, tempDllMaxBufferSize, "%s%s_%s", CStr(basePath), idToStr,
CStr(code.TransientDLLName));
if (writtenSize < static_cast<int>(basePathLength + idLength + code.TransientDLLName.Size) - 1)
if (writtenSize < 0)
{
SafeFree(tempDllPath);
Log(LogLevel::Error, LogCategory::Core, "Cannot create temp full path");
return;
}
if (static_cast<size_t>(writtenSize) + 1 < basePathLength + static_cast<size_t>(idLength) + code.TransientDLLName.Size)
{
SafeFree(tempDllPath);
Log(LogLevel::Error, LogCategory::Core, "Cannot create temp full path");

View File

@@ -1,5 +1,4 @@
#include <pch.h>
#include <Core/Common/CoreUtils.h>
#include <Core/Common/EnumUtils.h>
#include <Core/HAL/Display/Display_Private.h>
#include <Core/HAL/Filesystem/Filesystem_Private.h>

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
@@ -29,7 +27,7 @@ namespace Juliet
, Category(category)
{
// TODO Juliet clock
Time = std::chrono::system_clock::now().time_since_epoch().count();
Time = std::chrono::system_clock::now();
}
LogManager::LogManager()
@@ -66,10 +64,15 @@ namespace Juliet
void LogManager::OutputLog(Entry& entry)
{
// TODO Juliet Output io for each platform
// {:%F} is YYYY-MM-DD, {:%T} is HH:MM:SS.ffffff
std::string timestamp = std::format("[{:%F %T}] ", entry.Time);
std::string fullMessage = timestamp + entry.Value + "\n";
#ifdef JULIET_WIN32
OutputDebugStringA((entry.Value + "\n").c_str());
OutputDebugStringA(fullMessage.c_str());
#endif
printf("%s", (entry.Value + "\n").c_str());
printf("%s", fullMessage.c_str());
}
void InitializeLogManager()

View File

@@ -1,32 +1,41 @@
#include <pch.h>
#include <Core/Common/CoreTypes.h>
#include <Core/Math/Math_Private.h>
#include <cfloat>
namespace Juliet
{
// From MUSL lib https://github.com/rofl0r/musl
#if FLT_EVAL_METHOD == 0
#define EPS FLT_EPSILON
#elif FLT_EVAL_METHOD == 1
#define EPS DBL_EPSILON
#elif FLT_EVAL_METHOD == 2
#define EPS LDBL_EPSILON
#endif
namespace
{
const float_t toint = 1 / EPS;
}
consteval float GetEps()
{
#if defined(__FLT_EVAL_METHOD__)
if constexpr (__FLT_EVAL_METHOD__ == 1)
{
return static_cast<float>(DBL_EPSILON);
}
if constexpr (__FLT_EVAL_METHOD__ == 2)
{
return static_cast<float>(LDBL_EPSILON);
}
#endif
return FLT_EPSILON;
}
constexpr float EPS = GetEps();
constexpr float toint = 1.0f / EPS;
} // namespace
float RoundF(float value)
{
union
{
float f;
uint32_t i;
} u = { value };
int e = u.i >> 23 & 0xff;
float_t y;
float f;
uint32 i;
} u = { value };
auto e = u.i >> 23 & 0xff;
float y = 0.0f;
if (e >= 0x7f + 23)
{
@@ -38,7 +47,7 @@ namespace Juliet
}
if (e < 0x7f - 1)
{
FORCE_EVAL(value + toint);
ForceEval(value + toint);
return 0 * u.f;
}
y = value + toint - toint - value;

View File

@@ -9,6 +9,7 @@ namespace Juliet
{
volatile float y;
y = x;
(void)y;
}
#endif
@@ -18,6 +19,7 @@ namespace Juliet
{
volatile double y;
y = x;
(void)y;
}
#endif
@@ -27,25 +29,25 @@ namespace Juliet
{
volatile long double y;
y = x;
(void)y;
}
#endif
#define FORCE_EVAL(x) \
do \
{ \
if (sizeof(x) == sizeof(float)) \
{ \
fp_force_evalf(x); \
} \
else if (sizeof(x) == sizeof(double)) \
{ \
fp_force_eval(x); \
} \
else \
{ \
fp_force_evall(x); \
} \
} \
while (0)
template <typename T>
inline void ForceEval(T x)
{
if constexpr (std::is_same_v<T, float>)
{
fp_force_evalf(x);
}
else if constexpr (std::is_same_v<T, double>)
{
fp_force_eval(x);
}
else
{
fp_force_evall(x);
}
}
} // namespace Juliet

View File

@@ -1,6 +1,4 @@
#include <pch.h>
#include <core/Memory/Allocator.h>
#include <Core/Memory/Allocator.h>
namespace Juliet
{
@@ -34,7 +32,7 @@ namespace Juliet
return retMemory;
}
\
void* Realloc(void* memory, size_t newSize)
{
if (!newSize)
@@ -47,6 +45,4 @@ namespace Juliet
return retMemory;
}
void Free(void* memory) {}
} // namespace Juliet

View File

@@ -1,5 +1,4 @@
#include <pch.h>
#include <Core/Common/CoreUtils.h>
#include <Core/Networking/NetworkPacket.h>
#include <Core/Networking/SocketPlatformImpl.h>

View File

@@ -1,5 +1,4 @@
#include <pch.h>
#include <Core/Common/CoreUtils.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Networking/Socket.h>
@@ -18,14 +17,14 @@ namespace Juliet
Close();
}
Socket::Socket(Socket&& other) noexcept
Socket::Socket(Socket&& /*other*/) noexcept
{
Assert(false); // Unimplemented
Unimplemented();
}
Socket& Socket::operator=(Socket&& socket) noexcept
Socket& Socket::operator=(Socket&& /*socket*/) noexcept
{
Assert(false); // Unimplemented
Unimplemented();
return *this;
}

View File

@@ -7,7 +7,7 @@
// TODO : implement for other platforms
#if JULIET_WIN32
#include <winsock2.h>
#include <WinSock2.h>
#else
// UNIMPLEMENT_SOCKETS

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Networking/SocketPlatformImpl.h>

View File

@@ -1,9 +1,7 @@
#include <pch.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Networking/NetworkPacket.h>
#include <core/Networking/SocketPlatformImpl.h>
#include <Core/Networking/SocketPlatformImpl.h>
#include <Core/Networking/TcpSocket.h>
namespace Juliet
@@ -65,7 +63,9 @@ namespace Juliet
for (request.Length = 0; request.Length < buffer.Size; request.Length += static_cast<size_t>(result))
{
result = ::send(GetHandle(), reinterpret_cast<const char*>(buffer.Data + request.Length),
static_cast<SocketImpl::MessageLenghtType>(buffer.Size) - request.Length, sendFlags);
static_cast<SocketImpl::MessageLenghtType>(buffer.Size) -
static_cast<SocketImpl::MessageLenghtType>(request.Length),
sendFlags);
// Results is -1 when an error occured.
// https://pubs.opengroup.org/onlinepubs/000095399/functions/send.html
@@ -85,7 +85,7 @@ namespace Juliet
return request;
}
Socket::Status TcpSocket::Receive(NetworkPacket& outPacket)
Socket::Status TcpSocket::Receive(NetworkPacket& /*outPacket*/)
{
return Status::Done;
}

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Networking/Socket.h>

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Logging/LogManager.h>
#include <Engine/Engine.h>

View File

@@ -4,8 +4,8 @@
// Licensed under the MIT License (MIT).
//
//*********************************************************
#ifndef __D3D12_PROPERTY_LAYOUT_FORMAT_TABLE_H__
#define __D3D12_PROPERTY_LAYOUT_FORMAT_TABLE_H__
#pragma once
#include "d3d12.h"
#define MAP_ALIGN_REQUIREMENT 16 // Map is required to return 16-byte aligned addresses
@@ -124,5 +124,3 @@ private:
static const FORMAT_DETAIL* GetFormatDetail (DXGI_FORMAT Format);
};
#endif

View File

@@ -0,0 +1,166 @@
#include <Core/Memory/Allocator.h>
#include <Graphics/D3D12/D3D12Buffer.h>
#include <Graphics/D3D12/D3D12DescriptorHeap.h>
#include <Graphics/D3D12/D3D12GraphicsDevice.h>
#include <Graphics/D3D12/D3D12Utils.h>
namespace Juliet::D3D12
{
namespace
{
struct D3D12Buffer
{
ID3D12Resource* Handle;
int32 ReferenceCount;
Internal::D3D12DescriptorHeap CBVDescriptorHeap;
Internal::D3D12DescriptorHeap SRVDescriptorHeap;
Internal::D3D12DescriptorHeap UAVDescriptorHeap;
};
enum class D3D12BufferType : uint8
{
Base,
TransferDownload,
TransferUpload,
};
void DestroyBuffer(NonNullPtr<D3D12Driver> /*d3d12Driver*/, D3D12Buffer* buffer)
{
if (!buffer)
{
return;
}
if (buffer->Handle)
{
ID3D12Resource_Release(buffer->Handle);
}
Free(buffer);
}
D3D12Buffer* CreateBuffer(NonNullPtr<D3D12Driver> d3d12Driver, size_t size, BufferUsage usage, D3D12BufferType type)
{
auto buffer = static_cast<D3D12Buffer*>(Calloc(1, sizeof(D3D12Buffer)));
if (!buffer)
{
return nullptr;
}
D3D12_RESOURCE_STATES initialState = D3D12_RESOURCE_STATE_COMMON;
D3D12_HEAP_PROPERTIES heapProperties = {};
D3D12_HEAP_FLAGS heapFlags = D3D12_HEAP_FLAG_NONE;
switch (type)
{
case D3D12BufferType::Base:
{
switch (usage)
{
case BufferUsage::None:
{
Assert(false , "Creating buffer with invalid usage");
DestroyBuffer(d3d12Driver, buffer);
return nullptr;
}
case BufferUsage::IndexBuffer:
case BufferUsage::StructuredBuffer:
{
heapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;
heapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
heapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
heapFlags = D3D12_HEAP_FLAG_NONE;
break;
}
case BufferUsage::ConstantBuffer:
{
if (d3d12Driver->GPUUploadHeapSupported)
{
heapProperties.Type = D3D12_HEAP_TYPE_GPU_UPLOAD;
heapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
heapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
}
else
{
heapProperties.Type = D3D12_HEAP_TYPE_UPLOAD;
heapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
heapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
initialState = D3D12_RESOURCE_STATE_GENERIC_READ;
}
heapFlags = D3D12_HEAP_FLAG_NONE;
break;
}
}
break;
}
case D3D12BufferType::TransferDownload:
{
heapProperties.Type = D3D12_HEAP_TYPE_READBACK;
heapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
heapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
heapFlags = D3D12_HEAP_FLAG_NONE;
initialState = D3D12_RESOURCE_STATE_COPY_DEST;
break;
}
case D3D12BufferType::TransferUpload:
{
heapProperties.Type = D3D12_HEAP_TYPE_UPLOAD;
heapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
heapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
heapFlags = D3D12_HEAP_FLAG_NONE;
initialState = D3D12_RESOURCE_STATE_GENERIC_READ;
break;
}
}
// D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc;
// D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;
// D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc;
D3D12_RESOURCE_DESC desc = {};
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
desc.Width = size;
desc.Height = 1;
desc.DepthOrArraySize = 1;
desc.MipLevels = 1;
desc.Format = DXGI_FORMAT_UNKNOWN;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
ID3D12Resource* handle = nullptr;
HRESULT result = ID3D12Device_CreateCommittedResource(d3d12Driver->D3D12Device, &heapProperties, heapFlags,
&desc, initialState, NULL, IID_ID3D12Resource,
reinterpret_cast<void**>(&handle));
if (FAILED(result))
{
LogError(d3d12Driver->D3D12Device, "Could not create buffer!", result);
DestroyBuffer(d3d12Driver, buffer);
return nullptr;
}
buffer->ReferenceCount = 0;
buffer->Handle = handle;
return nullptr;
}
} // namespace
GraphicsBuffer* CreateGraphicsBuffer(NonNullPtr<GPUDriver> driver, size_t size, BufferUsage usage)
{
auto d3d12Driver = static_cast<D3D12Driver*>(driver.Get());
return reinterpret_cast<GraphicsBuffer*>(CreateBuffer(d3d12Driver, size, usage, D3D12BufferType::Base));
}
GraphicsTransferBuffer* CreateGraphicsTransferBuffer(NonNullPtr<GPUDriver> driver, size_t size, TransferBufferUsage usage)
{
auto d3d12Driver = static_cast<D3D12Driver*>(driver.Get());
return reinterpret_cast<GraphicsTransferBuffer*>(
CreateBuffer(d3d12Driver, size, BufferUsage::None,
usage == TransferBufferUsage::Upload ? D3D12BufferType::TransferUpload : D3D12BufferType::TransferDownload));
}
} // namespace Juliet::D3D12

View File

@@ -0,0 +1,14 @@
#pragma once
#include <Core/Common/NonNullPtr.h>
#include <Graphics/GraphicsBuffer.h>
namespace Juliet
{
struct GPUDriver;
}
namespace Juliet::D3D12
{
extern GraphicsBuffer* CreateGraphicsBuffer(NonNullPtr<GPUDriver> driver, size_t size, BufferUsage usage);
extern GraphicsTransferBuffer* CreateGraphicsTransferBuffer(NonNullPtr<GPUDriver> driver, size_t size, TransferBufferUsage usage);
}

View File

@@ -1,12 +1,13 @@
#include <D3D12CommandList.h>
#include <pch.h>
#include <Core/Memory/Allocator.h>
#include <Graphics/D3D12/D3D12CommandList.h>
#include <Graphics/D3D12/D3D12GraphicsDevice.h>
#include <Graphics/D3D12/D3D12Synchronization.h>
#include <Graphics/D3D12/D3D12Utils.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <string>
namespace Juliet::D3D12
{
namespace
@@ -29,7 +30,7 @@ namespace Juliet::D3D12
reinterpret_cast<void**>(&baseData->Allocator));
if (FAILED(result))
{
Assert(false && "Error not implemented: cannot create ID3D12CommandAllocator");
Assert(false, "Error not implemented: cannot create ID3D12CommandAllocator");
return false;
}
@@ -58,8 +59,8 @@ namespace Juliet::D3D12
reinterpret_cast<void**>(&d3d12GraphicsCommandList));
if (FAILED(result))
{
Assert(false && "Error not implemented: cannot create ID3D12GraphicsCommandList6 (graphics or "
"compute command list");
Assert(false, "Error not implemented: cannot create ID3D12GraphicsCommandList6 (graphics or "
"compute command list");
return false;
}
@@ -79,8 +80,8 @@ namespace Juliet::D3D12
reinterpret_cast<void**>(&d3d12GraphicsCommandList));
if (FAILED(result))
{
Assert(false && "Error not implemented: cannot create ID3D12GraphicsCommandList6 (graphics or "
"compute command list");
Assert(false, "Error not implemented: cannot create ID3D12GraphicsCommandList6 (graphics or "
"compute command list");
return false;
}
@@ -267,9 +268,11 @@ namespace Juliet::D3D12
}
// Mark the command list as submitted
if (d3d12Driver->SubmittedCommandListCount + 1 >= d3d12Driver->SubmittedCommandListCapacity)
const uint32 newValue = static_cast<uint32>(d3d12Driver->SubmittedCommandListCount) + 1U;
Assert(newValue <= 0xFF && "Command List count exceeded uint8 capacity!");
if (newValue >= d3d12Driver->SubmittedCommandListCapacity)
{
d3d12Driver->SubmittedCommandListCapacity = d3d12Driver->SubmittedCommandListCount + 1;
d3d12Driver->SubmittedCommandListCapacity = static_cast<uint8>(newValue);
d3d12Driver->SubmittedCommandLists = static_cast<D3D12CommandList**>(
Realloc(d3d12Driver->SubmittedCommandLists, sizeof(D3D12CommandList*) * d3d12Driver->SubmittedCommandListCapacity));
@@ -299,7 +302,7 @@ namespace Juliet::D3D12
result = IDXGISwapChain_Present(windowData->SwapChain, syncInterval, presentFlags);
if (FAILED(result))
{
result = false;
success = false;
}
ID3D12Resource_Release(
@@ -317,7 +320,7 @@ namespace Juliet::D3D12
uint64 fenceValue = ID3D12Fence_GetCompletedValue(d3d12Driver->SubmittedCommandLists[i]->InFlightFence->Handle);
if (fenceValue == D3D12_FENCE_SIGNAL_VALUE)
{
result &= Internal::CleanCommandList(d3d12Driver, d3d12Driver->SubmittedCommandLists[i], false);
success &= Internal::CleanCommandList(d3d12Driver, d3d12Driver->SubmittedCommandLists[i], false);
}
}
@@ -426,7 +429,7 @@ namespace Juliet::D3D12
ReturnDescriptorHeapToPool(driver, commandList->CRB_SRV_UAV_Heap);
ReturnDescriptorHeapToPool(driver, commandList->RTV_Heap);
commandList->CRB_SRV_UAV_Heap = nullptr;
commandList->RTV_Heap = nullptr;
commandList->RTV_Heap = nullptr;
// Clean up resource tracking
for (uint32 idx = 0; idx < commandList->UsedTextureCount; ++idx)

View File

@@ -2,8 +2,8 @@
#include <Core/Common/NonNullPtr.h>
#include <Core/Math/Shape.h>
#include <D3D12Common.h>
#include <D3D12GraphicsPipeline.h>
#include <Graphics/D3D12/D3D12Common.h>
#include <Graphics/D3D12/D3D12GraphicsPipeline.h>
#include <Graphics/D3D12/D3D12Includes.h>
#include <Graphics/GraphicsDevice.h>

View File

@@ -1,6 +1,4 @@
#include <pch.h>
#include <Core/Memory/Allocator.h>
#include <Core/Memory/Utils.h>
#include <Graphics/D3D12/D3D12Common.h>
@@ -95,7 +93,7 @@ namespace Juliet::D3D12::Internal
return true;
}
void ReleaseStagingDescriptor(NonNullPtr<D3D12Driver> driver, D3D12StagingDescriptor& cpuDescriptor)
void ReleaseStagingDescriptor(NonNullPtr<D3D12Driver> /*driver*/, D3D12StagingDescriptor& cpuDescriptor)
{
D3D12StagingDescriptorPool* pool = cpuDescriptor.Pool;

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Memory/Allocator.h>
#include <Graphics/D3D12/D3D12DescriptorHeap.h>
#include <Graphics/D3D12/D3D12GraphicsDevice.h>

View File

@@ -1,8 +1,9 @@
#include <pch.h>
#include <Core/Common/NonNullPtr.h>
#include <Core/HAL/DynLib/DynamicLibrary.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
#include <Graphics/D3D12/D3D12Buffer.h>
#include <Graphics/D3D12/D3D12CommandList.h>
#include <Graphics/D3D12/D3D12DescriptorHeap.h>
#include <Graphics/D3D12/D3D12GraphicsDevice.h>
@@ -19,9 +20,6 @@
#define D3D12_DLL "d3d12.dll"
#define D3D12_CREATEDEVICE_FUNC "D3D12CreateDevice"
#define D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE_FUNC "D3D12SerializeVersionedRootSignature"
#define DXGIDEBUG_DLL "dxgidebug.dll"
#define DXGI_GET_DEBUG_INTERFACE_FUNC "DXGIGetDebugInterface"
#define D3D12_GET_DEBUG_INTERFACE_FUNC "D3D12GetDebugInterface"
extern "C" {
// Used to enable the "Agility SDK" components
@@ -122,7 +120,7 @@ namespace Juliet::D3D12
}
auto* D3D12CreateDeviceFuncPtr =
reinterpret_cast<PFN_D3D12_CREATE_DEVICE>(LoadFunction(d3d12_dll, D3D12_CREATEDEVICE_FUNC));
TOD3D12FuncPtr(PFN_D3D12_CREATE_DEVICE, LoadFunction(d3d12_dll, D3D12_CREATEDEVICE_FUNC));
if (D3D12CreateDeviceFuncPtr == nullptr)
{
Log(LogLevel::Warning, LogCategory::Graphics, "DX12: Couldn't find function " D3D12_CREATEDEVICE_FUNC " in " D3D12_DLL);
@@ -304,6 +302,10 @@ namespace Juliet::D3D12
}
#ifdef IDXGIINFOQUEUE_SUPPORTED
#define DXGIDEBUG_DLL "dxgidebug.dll"
#define DXGI_GET_DEBUG_INTERFACE_FUNC "DXGIGetDebugInterface"
void InitializeDXGIDebug(NonNullPtr<D3D12Driver> driver)
{
// See https://github.com/microsoft/DirectX-Graphics-Samples/blob/7aa24663f26e547a5bc437db028dfcfdb4b3c8f3/TechniqueDemos/D3D12MemoryManagement/src/Framework.cpp#L957
@@ -314,7 +316,8 @@ namespace Juliet::D3D12
if (driver->DXGIDebugDLL)
{
auto dxgiGetDebugInterface =
reinterpret_cast<LPDXGIGETDEBUGINTERFACE>(LoadFunction(driver->DXGIDebugDLL, DXGI_GET_DEBUG_INTERFACE_FUNC));
TOD3D12FuncPtr(LPDXGIGETDEBUGINTERFACE, LoadFunction(driver->DXGIDebugDLL, DXGI_GET_DEBUG_INTERFACE_FUNC));
HRESULT result = dxgiGetDebugInterface(IID_IDXGIDebug, (void**)&driver->DXGIDebug);
if (FAILED(result))
{
@@ -356,11 +359,15 @@ namespace Juliet::D3D12
}
#endif
#ifdef JULIET_DEBUG
#if JULIET_DEBUG
#define D3D12_GET_DEBUG_INTERFACE_FUNC "D3D12GetDebugInterface"
void InitializeD3D12DebugLayer(NonNullPtr<D3D12Driver> driver)
{
auto D3D12GetDebugInterfaceFunc =
reinterpret_cast<PFN_D3D12_GET_DEBUG_INTERFACE>(LoadFunction(driver->D3D12DLL, D3D12_GET_DEBUG_INTERFACE_FUNC));
TOD3D12FuncPtr(PFN_D3D12_GET_DEBUG_INTERFACE, LoadFunction(driver->D3D12DLL, D3D12_GET_DEBUG_INTERFACE_FUNC));
if (D3D12GetDebugInterfaceFunc == nullptr)
{
LogWarning(LogCategory::Graphics, "Could not load function: " D3D12_GET_DEBUG_INTERFACE_FUNC);
@@ -402,7 +409,7 @@ namespace Juliet::D3D12
#ifdef ID3D12InfoQueue1_SUPPORTED
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;
switch (category)
@@ -579,7 +586,7 @@ namespace Juliet::D3D12
// TODO : Support more than one window
if (d3d12Driver->WindowData)
{
Assert(false && "D3D12 renderer already attached to the window. Right now we handle only one Window.");
Assert(false, "D3D12 renderer already attached to the window. Right now we handle only one Window.");
return false;
}
@@ -605,7 +612,7 @@ namespace Juliet::D3D12
return true;
}
void DetachFromWindow(NonNullPtr<GPUDriver> driver, NonNullPtr<Window> window)
void DetachFromWindow(NonNullPtr<GPUDriver> driver, NonNullPtr<Window> /*window*/)
{
auto* d3d12Driver = static_cast<D3D12Driver*>(driver.Get());
auto* windowData = d3d12Driver->WindowData;
@@ -652,7 +659,7 @@ namespace Juliet::D3D12
if (FAILED(result))
{
DestroyDriver_Internal(driver);
Assert(false && "DX12: Cannot create DXGIFactory1");
Assert(false, "DX12: Cannot create DXGIFactory1");
return nullptr;
}
@@ -660,8 +667,8 @@ namespace Juliet::D3D12
if (FAILED(result))
{
DestroyDriver_Internal(driver);
Assert(false && "DX12: Cannot create DXGIFactory4. Need DXGI1.4 support. Weird because it has been "
"checked in CheckDriver");
Assert(false, "DX12: Cannot create DXGIFactory4. Need DXGI1.4 support. Weird because it has been "
"checked in CheckDriver");
return nullptr;
}
IDXGIFactory1_Release(factory1);
@@ -706,7 +713,7 @@ namespace Juliet::D3D12
if (FAILED(result))
{
DestroyDriver_Internal(driver);
Assert(false && "Could not find adapter for D3D12Device");
Assert(false, "Could not find adapter for D3D12Device");
return nullptr;
}
@@ -716,7 +723,7 @@ namespace Juliet::D3D12
if (FAILED(result))
{
DestroyDriver_Internal(driver);
Assert(false && "Could not get DXGIAdapter description");
Assert(false, "Could not get DXGIAdapter description");
return nullptr;
}
@@ -726,7 +733,7 @@ namespace Juliet::D3D12
if (FAILED(result))
{
DestroyDriver_Internal(driver);
Assert(false && "Could not get DXGIAdapter driver version");
Assert(false, "Could not get DXGIAdapter driver version");
return nullptr;
}
@@ -743,7 +750,7 @@ namespace Juliet::D3D12
}
auto* D3D12CreateDeviceFuncPtr =
reinterpret_cast<PFN_D3D12_CREATE_DEVICE>(LoadFunction(driver->D3D12DLL, D3D12_CREATEDEVICE_FUNC));
TOD3D12FuncPtr(PFN_D3D12_CREATE_DEVICE, LoadFunction(driver->D3D12DLL, D3D12_CREATEDEVICE_FUNC));
if (D3D12CreateDeviceFuncPtr == nullptr)
{
Log(LogLevel::Error, LogCategory::Graphics, "DX12: Couldn't Load function " D3D12_CREATEDEVICE_FUNC " in " D3D12_DLL);
@@ -751,8 +758,9 @@ namespace Juliet::D3D12
return nullptr;
}
driver->D3D12SerializeVersionedRootSignatureFct = reinterpret_cast<PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE>(
LoadFunction(driver->D3D12DLL, D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE_FUNC));
driver->D3D12SerializeVersionedRootSignatureFct =
TOD3D12FuncPtr(PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE,
LoadFunction(driver->D3D12DLL, D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE_FUNC));
if (driver->D3D12SerializeVersionedRootSignatureFct == nullptr)
{
Log(LogLevel::Error, LogCategory::Graphics,
@@ -761,7 +769,7 @@ namespace Juliet::D3D12
return nullptr;
}
#ifdef JULIET_DEBUG
#if JULIET_DEBUG
if (enableDebug)
{
InitializeD3D12DebugLayer(driver);
@@ -777,7 +785,7 @@ namespace Juliet::D3D12
return nullptr;
}
#ifdef JULIET_DEBUG
#if JULIET_DEBUG
if (enableDebug)
{
if (!InitializeD3D12DebugInfoQueue(driver))
@@ -920,7 +928,8 @@ namespace Juliet::D3D12
{
heapPool.Capacity = 4;
heapPool.Count = 4;
heapPool.Heaps = static_cast<Internal::D3D12DescriptorHeap**>(Calloc(heapPool.Capacity, sizeof(Internal::D3D12DescriptorHeap*)));
heapPool.Heaps = static_cast<Internal::D3D12DescriptorHeap**>(
Calloc(heapPool.Capacity, sizeof(Internal::D3D12DescriptorHeap*)));
for (uint32 i = 0; i < heapPool.Capacity; ++i)
{
@@ -992,7 +1001,12 @@ namespace Juliet::D3D12
device->DestroyShader = DestroyShader;
device->CreateGraphicsPipeline = CreateGraphicsPipeline;
device->DestroyGraphicsPipeline = DestroyGraphicsPipeline;
device->UpdateGraphicsPipelineShaders = UpdateGraphicsPipelineShaders;
device->CreateGraphicsBuffer = CreateGraphicsBuffer;
device->CreateGraphicsTransferBuffer = CreateGraphicsTransferBuffer;
#if ALLOW_SHADER_HOT_RELOAD
device->UpdateGraphicsPipelineShaders = UpdateGraphicsPipelineShaders;
#endif
device->Driver = driver;
device->DebugEnabled = enableDebug;
@@ -1008,7 +1022,8 @@ namespace Juliet::D3D12
void DisposePendingResourcces(NonNullPtr<D3D12Driver> driver)
{
// TODO Destroy anything (buffer, texture, etc...)
for (int32 idx = driver->GraphicsPipelinesToDisposeCount - 1; idx >= 0; --idx)
uint32 idx = 0;
while (idx < driver->GraphicsPipelinesToDisposeCount)
{
if (driver->GraphicsPipelinesToDispose[idx]->ReferenceCount == 0)
{
@@ -1018,6 +1033,10 @@ namespace Juliet::D3D12
driver->GraphicsPipelinesToDispose[driver->GraphicsPipelinesToDisposeCount - 1];
driver->GraphicsPipelinesToDisposeCount -= 1;
}
else
{
idx++;
}
}
}
} // namespace Internal

View File

@@ -54,7 +54,7 @@ namespace Juliet::D3D12
PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE D3D12SerializeVersionedRootSignatureFct;
ID3D12CommandQueue* GraphicsQueue;
D3D12_COMMAND_QUEUE_DESC QueueDesc[ToUnderlying(QueueType::Copy)];
#ifdef JULIET_DEBUG
#if JULIET_DEBUG
ID3D12Debug1* D3D12Debug;
#endif

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Graphics/D3D12/D3D12GraphicsDevice.h>
#include <Graphics/D3D12/D3D12GraphicsPipeline.h>
#include <Graphics/D3D12/D3D12Shader.h>

View File

@@ -1,8 +1,8 @@
#pragma once
#include <Core/Common/NonNullPtr.h>
#include <D3D12Shader.h>
#include <Graphics/D3D12/D3D12Includes.h>
#include <Graphics/D3D12/D3D12Shader.h>
#include <Graphics/GraphicsDevice.h>
#include <Graphics/GraphicsPipeline.h>
@@ -15,6 +15,8 @@ namespace Juliet
namespace Juliet::D3D12
{
struct D3D12Shader;
struct D3D12GraphicsRootSignature
{
ID3D12RootSignature* Handle;
@@ -29,8 +31,8 @@ namespace Juliet::D3D12
// Keeping shaders byte code to make it easier to recreate the ID3D12PipelineState
// Those will be freed when the pipeline is destroyed or updated
D3D12Shader * VertexShaderCache;
D3D12Shader * FragmentShaderCache;
D3D12Shader* VertexShaderCache;
D3D12Shader* FragmentShaderCache;
#endif
ID3D12PipelineState* PipelineState;

View File

@@ -5,17 +5,26 @@
// #include <wrl.h>
// namespace wrl = Microsoft::WRL;
// 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"
#endif
// We will use the C interface of DX12.
// Those define disable the C++ API.
// It also prevents using d3dx12 because it only supports C++ :(
#define COBJMACROS
#define CINTERFACE ;
#define CINTERFACE
#include <Graphics/D3D12/AgilitySDK/d3d12.h>
//#include <Graphics/D3D12/AgilitySDK/d3dx12/d3dx12_check_feature_support.h>
#include <dxgi1_6.h>
#ifdef _DEBUG
#if JULIET_DEBUG
#include <dxgidebug.h>
#endif
@@ -31,3 +40,7 @@
#undef min
#undef max
#ifdef __clang__
#pragma clang diagnostic pop
#endif

View File

@@ -1,5 +1,3 @@
#include <pch.h>
#include <Core/Common/EnumUtils.h>
#include <Graphics/D3D12/D3D12GraphicsPipeline.h>
#include <Graphics/D3D12/D3D12RenderPass.h>

View File

@@ -1,6 +1,6 @@
#pragma once
#include <core/Common/NonNullPtr.h>
#include <Core/Common/NonNullPtr.h>
#include <Graphics/D3D12/D3D12CommandList.h>
#include <Graphics/RenderPass.h>

View File

@@ -1,11 +1,11 @@
#include <pch.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
#include <Graphics/D3D12/D3D12Shader.h>
namespace Juliet::D3D12
{
Shader* CreateShader(NonNullPtr<GPUDriver> driver, ByteBuffer shaderByteCode, ShaderCreateInfo& shaderCreateInfo)
Shader* CreateShader(NonNullPtr<GPUDriver> /*driver*/, ByteBuffer shaderByteCode, ShaderCreateInfo& /*shaderCreateInfo*/)
{
if (!IsValid(shaderByteCode))
{
@@ -38,7 +38,7 @@ namespace Juliet::D3D12
return reinterpret_cast<Shader*>(shader);
}
void DestroyShader(NonNullPtr<GPUDriver> driver, NonNullPtr<Shader> shader)
void DestroyShader(NonNullPtr<GPUDriver> /*driver*/, NonNullPtr<Shader> shader)
{
auto d3d12shader = reinterpret_cast<D3D12Shader*>(shader.Get());
Free(d3d12shader);

View File

@@ -1,16 +1,16 @@
#include <pch.h>
#include <Core/HAL/Display/Win32/Win32Window.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
#include <Graphics/D3D12/D3D12CommandList.h>
#include <Graphics/D3D12/D3D12GraphicsDevice.h>
#include <Graphics/D3D12/D3D12Includes.h>
#include <Graphics/D3D12/D3D12SwapChain.h>
#include <Graphics/D3D12/D3D12Synchronization.h>
#include <Graphics/D3D12/D3D12Texture.h>
#include <Graphics/D3D12/D3D12Utils.h>
#include <algorithm>
#include <D3D12Synchronization.h>
namespace Juliet::D3D12
{
@@ -208,7 +208,7 @@ namespace Juliet::D3D12
return AcquireSwapChainTexture(true, commandList, window, swapChainTexture);
}
bool WaitForSwapchain(NonNullPtr<GPUDriver> driver, NonNullPtr<Window> window)
bool WaitForSwapchain(NonNullPtr<GPUDriver> driver, NonNullPtr<Window> /*window*/)
{
auto* d3d12Driver = static_cast<D3D12Driver*>(driver.Get());
auto* windowData = d3d12Driver->WindowData;
@@ -253,7 +253,7 @@ namespace Juliet::D3D12
HWND windowHandle = windowWin32State->Handle;
if (!IsWindow(windowHandle))
{
Assert(false && "windowWin32State->Handle is not a window handle ???");
Assert(false, "windowWin32State->Handle is not a window handle ???");
return false;
}

View File

@@ -1,5 +1,5 @@
#include <pch.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
#include <Graphics/D3D12/D3D12CommandList.h>
#include <Graphics/D3D12/D3D12GraphicsDevice.h>
@@ -116,7 +116,7 @@ namespace Juliet::D3D12
return result;
}
bool QueryFence(NonNullPtr<GPUDriver> driver, NonNullPtr<Fence> fence)
bool QueryFence(NonNullPtr<GPUDriver> /*driver*/, NonNullPtr<Fence> /*fence*/)
{
Unimplemented();
return true;

View File

@@ -1,6 +1,6 @@
#include <pch.h>
#include <Core/Common/EnumUtils.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Graphics/D3D12/D3D12CommandList.h>
#include <Graphics/D3D12/D3D12Synchronization.h>
#include <Graphics/D3D12/D3D12Texture.h>

View File

@@ -1,11 +1,9 @@
#include <pch.h>
#include <Core/Common/NonNullPtr.h>
#include <D3D12GraphicsDevice.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Graphics/D3D12/D3D12GraphicsDevice.h>
#include <Graphics/D3D12/D3D12Utils.h>
#include <algorithm>
namespace Juliet::D3D12
{
// From SDLGPU
@@ -15,17 +13,17 @@ namespace Juliet::D3D12
#define MAX_ERROR_LEN 1024 // FIXME: Arbitrary!
// Buffer for text, ensure space for \0 terminator after buffer
char wszMsgBuff[MAX_ERROR_LEN + 1];
DWORD dwChars; // Number of chars returned.
char wszMsgBuff[MAX_ERROR_LEN + 1];
// Number of chars returned.
if (result == DXGI_ERROR_DEVICE_REMOVED)
{
result = ID3D12Device_GetDeviceRemovedReason(D3D12Device);
result = ID3D12Device_GetDeviceRemovedReason(D3D12Device);
}
// Try to get the message from the system errors.
dwChars = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, result, 0,
wszMsgBuff, MAX_ERROR_LEN, NULL);
DWORD dwChars = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr,
static_cast<DWORD>(result), 0, wszMsgBuff, MAX_ERROR_LEN, nullptr);
// No message? Screw it, just post the code.
if (dwChars == 0)

View File

@@ -8,6 +8,8 @@
#define HRESULT_FMT "(0x%08X)"
#endif
#define TOD3D12FuncPtr(type, ptr) reinterpret_cast<type>(reinterpret_cast<void*>(ptr))
namespace Juliet::D3D12
{
struct D3D12Driver;
@@ -21,7 +23,7 @@ namespace Juliet::D3D12
{
switch (hr)
{
case E_POINTER: Assert(false && "Invalid Pointer");
case E_POINTER: Assert(false, "Invalid Pointer");
}
}

View File

@@ -1,7 +1,7 @@
#include <pch.h>
#include <Core/HAL/Filesystem/Filesystem.h>
#include <Core/HAL/IO/IOStream.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Graphics/Graphics.h>
#include <Graphics/GraphicsDevice.h>
@@ -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)
@@ -324,4 +324,26 @@ namespace Juliet
return device->UpdateGraphicsPipelineShaders(device->Driver, graphicsPipeline, optional_vertexShader, optional_fragmentShader);
}
#endif
GraphicsBuffer* CreateGraphicsBuffer(NonNullPtr<GraphicsDevice> device, const BufferCreateInfo& createInfo)
{
return device->CreateGraphicsBuffer(device->Driver, createInfo.Size, createInfo.Usage);
}
GraphicsTransferBuffer* CreateGraphicsTransferBuffer(NonNullPtr<GraphicsDevice> device, const TransferBufferCreateInfo& createInfo)
{
return device->CreateGraphicsTransferBuffer(device->Driver, createInfo.Size, createInfo.Usage);
}
void ReleaseGraphicsBuffer(NonNullPtr<GraphicsDevice> device, NonNullPtr<GraphicsBuffer> buffer)
{
(void)device;
(void)buffer;
}
void ReleaseGraphicsTransferBuffer(NonNullPtr<GraphicsDevice> device, NonNullPtr<GraphicsTransferBuffer> buffer)
{
(void)device;
(void)buffer;
}
} // namespace Juliet

View File

@@ -86,6 +86,10 @@ namespace Juliet
bool (*UpdateGraphicsPipelineShaders)(NonNullPtr<GPUDriver> driver, NonNullPtr<GraphicsPipeline> graphicsPipeline,
Shader* optional_vertexShader, Shader* optional_fragmentShader);
// Buffers
GraphicsBuffer* (*CreateGraphicsBuffer)(NonNullPtr<GPUDriver> driver, size_t size, BufferUsage usage);
GraphicsTransferBuffer* (*CreateGraphicsTransferBuffer)(NonNullPtr<GPUDriver> driver, size_t size, TransferBufferUsage usage);
const char* Name = "Unknown";
GPUDriver* Driver = nullptr;
bool DebugEnabled : 1;

View File

@@ -1,5 +0,0 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include <pch.h>
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

View File

@@ -113,7 +113,7 @@ namespace
}
case ShaderStage::Invalid:
{
Assert(false && "Invalid shader stage");
Assert(false , "Invalid shader stage");
return {};
}
}

View File

@@ -213,12 +213,12 @@ int main(int argc, char* argv[])
}
break;
}
case ShaderFormat::Invalid: Assert(false && "Shader format is invalid"); return 1;
case ShaderFormat::Invalid: Assert(false , "Shader format is invalid"); return 1;
}
break;
}
case SourceLanguage::Invalid: Assert(false && "Source Language is invalid"); return 1;
case SourceLanguage::Invalid: Assert(false , "Source Language is invalid"); return 1;
}
return 0;