Skip to content

Commit

Permalink
Merge pull request #135 from crud89/static-linking
Browse files Browse the repository at this point in the history
Allow static library linkage.
  • Loading branch information
crud89 authored Jul 17, 2024
2 parents 3c9bdda + 7a45ee8 commit 9cbc969
Show file tree
Hide file tree
Showing 71 changed files with 957 additions and 770 deletions.
1 change: 1 addition & 0 deletions docs/release-logs/0.4.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Builders are now `constexpr` where possible and are implemented using `deducing this` in place of CRTP, which makes them more lightweight.
- New exceptions with support for `stacktrace` and `source_location`.
- Replace `fmt` with `std::format`. ([See PR #128](https://github.com/crud89/LiteFX/pull/128))
- Allow static linking to the engine libraries. ([See PR #135](https://github.com/crud89/LiteFX/pull/135))
- The namespace `rtti` has been renamed to `meta`. ([See PR #121](https://github.com/crud89/LiteFX/pull/121))
- Improvements to C++ core guideline conformance. ([See PR #103](https://github.com/crud89/LiteFX/pull/103))
- New event infrastructure. ([See PR #81](https://github.com/crud89/LiteFX/pull/81))
Expand Down
7 changes: 6 additions & 1 deletion src/AppModel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SET(APP_MODEL_SOURCES
"src/appversion.cpp"
)

ADD_LIBRARY(${PROJECT_NAME} SHARED
ADD_LIBRARY(${PROJECT_NAME}
${APP_MODEL_HEADERS}
${APP_MODEL_SOURCES}
)
Expand Down Expand Up @@ -50,6 +50,11 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME}
PUBLIC LiteFX.Core LiteFX.Logging
)

# Pre-define export specifier, to prevent dllimport/dllexport from being be emitted.
IF(NOT BUILD_SHARED_LIBS)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PUBLIC -DLITEFX_APPMODEL_API=)
ENDIF(NOT BUILD_SHARED_LIBS)

# Re-use pre-compiled core header.
IF(LITEFX_BUILD_PRECOMPILED_HEADERS)
TARGET_PRECOMPILE_HEADERS(${PROJECT_NAME} REUSE_FROM LiteFX.Core)
Expand Down
12 changes: 6 additions & 6 deletions src/AppModel/include/litefx/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ namespace LiteFX {
/// </summary>
/// <param name="...args">The arguments passed to the function.</param>
/// <returns>The result of the delegate function call.</returns>
TResult inline invoke(TArgs... args) const {
inline TResult invoke(TArgs... args) const {
return m_target(args...);
}

/// <summary>
/// Returns the unique token of the delegate.
/// </summary>
/// <returns>The unique token of the delegate.</returns>
token_type inline token() const {
inline token_type token() const {
return m_token;
}

Expand All @@ -134,7 +134,7 @@ namespace LiteFX {
/// </summary>
/// <param name="...args">The arguments passed to the function.</param>
/// <returns>The result of the delegate function call.</returns>
TResult inline operator()(TArgs... args) const {
inline TResult operator()(TArgs... args) const {
return this->invoke(args...);
}
};
Expand Down Expand Up @@ -642,14 +642,14 @@ namespace LiteFX {

public:
/// <inheritdoc />
constexpr inline void use(UniquePtr<IBackend>&& backend);
void use(UniquePtr<IBackend>&& backend);

/// <summary>
/// Registers a sink for logging.
/// </summary>
template <typename TSink, typename ...TArgs> requires
std::convertible_to<TSink*, ISink*>
constexpr inline AppBuilder& logTo(TArgs&&... args) {
AppBuilder& logTo(TArgs&&... args) {
auto sink = makeUnique<TSink>(std::forward<TArgs>(args)...);
Logger::sinkTo(sink.get());
return *this;
Expand All @@ -660,7 +660,7 @@ namespace LiteFX {
/// </summary>
template <typename TBackend, typename ...TArgs> requires
meta::implements<TBackend, IBackend>
constexpr inline AppBuilder& useBackend(TArgs&&... args) {
AppBuilder& useBackend(TArgs&&... args) {
this->use(makeUnique<TBackend>(*this->instance(), std::forward<TArgs>(args)...));
return *this;
}
Expand Down
4 changes: 3 additions & 1 deletion src/AppModel/include/litefx/app_api.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <litefx/config.h>

#if !defined (LITEFX_APPMODEL_API)
# if defined(LiteFX_AppModel_EXPORTS) && (defined _WIN32 || defined WINCE)
# define LITEFX_APPMODEL_API __declspec(dllexport)
Expand All @@ -8,7 +10,7 @@
# elif !defined(LiteFX_AppModel_EXPORTS) && (defined _WIN32 || defined WINCE)
# define LITEFX_APPMODEL_API __declspec(dllimport)
# endif
#endif
#endif

#ifndef LITEFX_APPMODEL_API
# define LITEFX_APPMODEL_API
Expand Down
2 changes: 1 addition & 1 deletion src/AppModel/src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void App::resize(int width, int height)
// Builder interface.
// ------------------------------------------------------------------------------------------------

constexpr void AppBuilder::use(UniquePtr<IBackend>&& backend)
void AppBuilder::use(UniquePtr<IBackend>&& backend)
{
this->instance()->use(std::move(backend));
}
7 changes: 6 additions & 1 deletion src/Backends/DirectX12/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SET(DIRECTX12_BACKEND_SOURCES
)

# Add shared library project.
ADD_LIBRARY(${PROJECT_NAME} SHARED
ADD_LIBRARY(${PROJECT_NAME}
${DIRECTX12_BACKEND_HEADERS}
${DIRECTX12_BACKEND_SOURCES}
)
Expand Down Expand Up @@ -91,6 +91,11 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME}
PRIVATE unofficial::d3d12-memory-allocator
)

# Pre-define export specifier, to prevent dllimport/dllexport from being be emitted.
IF(NOT BUILD_SHARED_LIBS)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PUBLIC -DLITEFX_DIRECTX12_API=)
ENDIF(NOT BUILD_SHARED_LIBS)

# Link PIX runtime, if available.
IF(LITEFX_BUILD_WITH_PIX_RUNTIME)
FIND_PACKAGE(WinPixEventRuntime CONFIG REQUIRED)
Expand Down
30 changes: 15 additions & 15 deletions src/Backends/DirectX12/include/litefx/backends/dx12.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,52 +331,52 @@ namespace LiteFX::Rendering::Backends {
/// </summary>
/// <param name="syncBefore">The pipeline stage(s) all previous commands have to finish before the barrier is executed.</param>
/// <param name="syncAfter">The pipeline stage(s) all subsequent commands are blocked at until the barrier is executed.</param>
constexpr inline explicit DirectX12Barrier(PipelineStage syncBefore, PipelineStage syncAfter) noexcept;
explicit DirectX12Barrier(PipelineStage syncBefore, PipelineStage syncAfter) noexcept;
DirectX12Barrier(const DirectX12Barrier&) = delete;
DirectX12Barrier(DirectX12Barrier&&) = delete;
constexpr inline virtual ~DirectX12Barrier() noexcept;
virtual ~DirectX12Barrier() noexcept;

private:
constexpr inline explicit DirectX12Barrier() noexcept;
constexpr inline PipelineStage& syncBefore() noexcept;
constexpr inline PipelineStage& syncAfter() noexcept;
explicit DirectX12Barrier() noexcept;
PipelineStage& syncBefore() noexcept;
PipelineStage& syncAfter() noexcept;

// Barrier interface.
public:
/// <inheritdoc />
constexpr inline PipelineStage syncBefore() const noexcept override;
PipelineStage syncBefore() const noexcept override;

/// <inheritdoc />
constexpr inline PipelineStage syncAfter() const noexcept override;
PipelineStage syncAfter() const noexcept override;

/// <inheritdoc />
constexpr inline void wait(ResourceAccess accessBefore, ResourceAccess accessAfter) noexcept override;
void wait(ResourceAccess accessBefore, ResourceAccess accessAfter) noexcept override;

/// <inheritdoc />
constexpr inline void transition(const IDirectX12Buffer& buffer, ResourceAccess accessBefore, ResourceAccess accessAfter) override;
void transition(const IDirectX12Buffer& buffer, ResourceAccess accessBefore, ResourceAccess accessAfter) override;

/// <inheritdoc />
constexpr inline void transition(const IDirectX12Buffer& buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter) override;
void transition(const IDirectX12Buffer& buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter) override;

/// <inheritdoc />
constexpr inline void transition(const IDirectX12Image& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) override;
void transition(const IDirectX12Image& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) override;

/// <inheritdoc />
constexpr inline void transition(const IDirectX12Image& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) override;
void transition(const IDirectX12Image& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) override;

/// <inheritdoc />
constexpr inline void transition(const IDirectX12Image& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) override;
void transition(const IDirectX12Image& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) override;

/// <inheritdoc />
constexpr inline void transition(const IDirectX12Image& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) override;
void transition(const IDirectX12Image& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) override;

public:
/// <summary>
/// Adds the barrier to a command buffer and updates the resource target states.
/// </summary>
/// <param name="commandBuffer">The command buffer to add the barriers to.</param>
/// <exception cref="RuntimeException">Thrown, if any of the contained barriers is a image barrier that targets a sub-resource range that does not share the same <see cref="ImageLayout" /> in all sub-resources.</exception>
inline void execute(const DirectX12CommandBuffer& commandBuffer) const noexcept;
void execute(const DirectX12CommandBuffer& commandBuffer) const noexcept;
};

/// <summary>
Expand Down
46 changes: 24 additions & 22 deletions src/Backends/DirectX12/include/litefx/backends/dx12_api.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <litefx/config.h>

#if !defined (LITEFX_DIRECTX12_API)
# if defined(LiteFX_Backends_DirectX12_EXPORTS) && (defined _WIN32 || defined WINCE)
# define LITEFX_DIRECTX12_API __declspec(dllexport)
Expand All @@ -8,7 +10,7 @@
# elif !defined(LiteFX_Backends_DirectX12_EXPORTS) && (defined _WIN32 || defined WINCE)
# define LITEFX_DIRECTX12_API __declspec(dllimport)
# endif
#endif
#endif

#ifndef LITEFX_DIRECTX12_API
# define LITEFX_DIRECTX12_API
Expand Down Expand Up @@ -113,109 +115,109 @@ namespace LiteFX::Rendering::Backends {
/// <summary>
///
/// </summary>
constexpr inline Format LITEFX_DIRECTX12_API getFormat(const DXGI_FORMAT& format);
Format LITEFX_DIRECTX12_API getFormat(const DXGI_FORMAT& format);

/// <summary>
///
/// </summary>
constexpr inline DXGI_FORMAT LITEFX_DIRECTX12_API getFormat(Format format);
DXGI_FORMAT LITEFX_DIRECTX12_API getFormat(Format format);

/// <summary>
///
/// </summary>
constexpr inline DXGI_FORMAT LITEFX_DIRECTX12_API getFormat(BufferFormat format);
DXGI_FORMAT LITEFX_DIRECTX12_API getFormat(BufferFormat format);

/// <summary>
///
/// </summary>
constexpr inline bool LITEFX_DIRECTX12_API isSRGB(Format format);
bool LITEFX_DIRECTX12_API isSRGB(Format format);

/// <summary>
///
/// </summary>
constexpr inline D3D12_RESOURCE_DIMENSION LITEFX_DIRECTX12_API getImageType(ImageDimensions dimensions);
D3D12_RESOURCE_DIMENSION LITEFX_DIRECTX12_API getImageType(ImageDimensions dimensions);

/// <summary>
///
/// </summary>
constexpr inline PolygonMode LITEFX_DIRECTX12_API getPolygonMode(const D3D12_FILL_MODE& mode);
PolygonMode LITEFX_DIRECTX12_API getPolygonMode(const D3D12_FILL_MODE& mode);

/// <summary>
///
/// </summary>
constexpr inline D3D12_FILL_MODE LITEFX_DIRECTX12_API getPolygonMode(PolygonMode mode);
D3D12_FILL_MODE LITEFX_DIRECTX12_API getPolygonMode(PolygonMode mode);

/// <summary>
///
/// </summary>
constexpr inline CullMode LITEFX_DIRECTX12_API getCullMode(const D3D12_CULL_MODE& mode);
CullMode LITEFX_DIRECTX12_API getCullMode(const D3D12_CULL_MODE& mode);

/// <summary>
///
/// </summary>
constexpr inline D3D12_CULL_MODE LITEFX_DIRECTX12_API getCullMode(CullMode mode);
D3D12_CULL_MODE LITEFX_DIRECTX12_API getCullMode(CullMode mode);

/// <summary>
///
/// </summary>
constexpr inline PrimitiveTopology LITEFX_DIRECTX12_API getPrimitiveTopology(const D3D12_PRIMITIVE_TOPOLOGY& topology);
PrimitiveTopology LITEFX_DIRECTX12_API getPrimitiveTopology(const D3D12_PRIMITIVE_TOPOLOGY& topology);

/// <summary>
///
/// </summary>
constexpr inline D3D12_PRIMITIVE_TOPOLOGY LITEFX_DIRECTX12_API getPrimitiveTopology(PrimitiveTopology topology);
D3D12_PRIMITIVE_TOPOLOGY LITEFX_DIRECTX12_API getPrimitiveTopology(PrimitiveTopology topology);

/// <summary>
///
/// </summary>
constexpr inline D3D12_PRIMITIVE_TOPOLOGY_TYPE LITEFX_DIRECTX12_API getPrimitiveTopologyType(PrimitiveTopology topology);
D3D12_PRIMITIVE_TOPOLOGY_TYPE LITEFX_DIRECTX12_API getPrimitiveTopologyType(PrimitiveTopology topology);

/// <summary>
///
/// </summary>
constexpr inline LPCTSTR LITEFX_DIRECTX12_API getSemanticName(AttributeSemantic semantic);
LPCTSTR LITEFX_DIRECTX12_API getSemanticName(AttributeSemantic semantic);

/// <summary>
///
/// </summary>
/// <param name="vendorId"></param>
/// <returns></returns>
constexpr inline String LITEFX_DIRECTX12_API getVendorName(UInt32 vendorId);
String LITEFX_DIRECTX12_API getVendorName(UInt32 vendorId);

/// <summary>
///
/// </summary>
constexpr inline D3D12_COMPARISON_FUNC LITEFX_DIRECTX12_API getCompareOp(CompareOperation compareOp);
D3D12_COMPARISON_FUNC LITEFX_DIRECTX12_API getCompareOp(CompareOperation compareOp);

/// <summary>
///
/// </summary>
constexpr inline D3D12_STENCIL_OP LITEFX_DIRECTX12_API getStencilOp(StencilOperation stencilOp);
D3D12_STENCIL_OP LITEFX_DIRECTX12_API getStencilOp(StencilOperation stencilOp);

/// <summary>
///
/// </summary>
constexpr inline D3D12_BLEND LITEFX_DIRECTX12_API getBlendFactor(BlendFactor blendFactor);
D3D12_BLEND LITEFX_DIRECTX12_API getBlendFactor(BlendFactor blendFactor);

/// <summary>
///
/// </summary>
constexpr inline D3D12_BLEND_OP LITEFX_DIRECTX12_API getBlendOperation(BlendOperation blendOperation);
D3D12_BLEND_OP LITEFX_DIRECTX12_API getBlendOperation(BlendOperation blendOperation);

/// <summary>
///
/// </summary>
constexpr inline D3D12_BARRIER_SYNC LITEFX_DIRECTX12_API getPipelineStage(PipelineStage pipelineStage);
D3D12_BARRIER_SYNC LITEFX_DIRECTX12_API getPipelineStage(PipelineStage pipelineStage);

/// <summary>
///
/// </summary>
constexpr inline D3D12_BARRIER_ACCESS LITEFX_DIRECTX12_API getResourceAccess(ResourceAccess resourceAccess);
D3D12_BARRIER_ACCESS LITEFX_DIRECTX12_API getResourceAccess(ResourceAccess resourceAccess);

/// <summary>
///
/// </summary>
constexpr inline D3D12_BARRIER_LAYOUT LITEFX_DIRECTX12_API getImageLayout(ImageLayout imageLayout);
D3D12_BARRIER_LAYOUT LITEFX_DIRECTX12_API getImageLayout(ImageLayout imageLayout);
}

/// <summary>
Expand Down
Loading

0 comments on commit 9cbc969

Please sign in to comment.