Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ jobs:
-DGFX_ENABLE_${{ matrix.enable-glfw }}
-DGFX_ENABLE_${{ matrix.enable-imgui }}
-DGFX_BUILD_${{ matrix.build-examples }}
-DGFX_BUILD_TESTS=ON

- name: Build
run: cmake --build build --config ${{ matrix.build-type }} --parallel

- name: Test
run: ctest --test-dir build
4 changes: 4 additions & 0 deletions .github/workflows/macos-both.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
-DGFX_ENABLE_${{ matrix.enable-glfw }}
-DGFX_ENABLE_${{ matrix.enable-imgui }}
-DGFX_BUILD_${{ matrix.build-examples }}
-DGFX_BUILD_TESTS=ON

- name: Build
run: cmake --build build --config ${{ matrix.build-type }} --parallel

- name: Test
run: ctest --test-dir build
4 changes: 4 additions & 0 deletions .github/workflows/macos-metal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
-DGFX_ENABLE_${{ matrix.enable-glfw }}
-DGFX_ENABLE_${{ matrix.enable-imgui }}
-DGFX_BUILD_${{ matrix.build-examples }}
-DGFX_BUILD_TESTS=ON

- name: Build
run: cmake --build build --config ${{ matrix.build-type }} --parallel

- name: Test
run: ctest --test-dir build
4 changes: 4 additions & 0 deletions .github/workflows/macos-vulkan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
-DGFX_ENABLE_${{ matrix.enable-glfw }}
-DGFX_ENABLE_${{ matrix.enable-imgui }}
-DGFX_BUILD_${{ matrix.build-examples }}
-DGFX_BUILD_TESTS=ON

- name: Build
run: cmake --build build --config ${{ matrix.build-type }} --parallel

- name: Test
run: ctest --test-dir build
4 changes: 4 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
-DGFX_ENABLE_${{ matrix.enable-glfw }}
-DGFX_ENABLE_${{ matrix.enable-imgui }}
-DGFX_BUILD_${{ matrix.build-examples }}
-DGFX_BUILD_TESTS=ON

- name: Build
run: cmake --build build --config ${{ matrix.build-type }} --parallel

- name: Test
run: ctest --test-dir build
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ option(GFX_ENABLE_IMGUI "Build with imgui capabilities" OFF)
option(GFX_ENABLE_GLFW "Build with glfw capabilities" OFF)
option(GFX_BUILD_EXAMPLES "Build Graphics examples executables" OFF)
option(GFX_BUILD_TRACY "Build the tracy client" OFF)
option(GFX_BUILD_TESTS "Build the tests" OFF)
option(GFX_INSTALL "Enable the install command" ON)

if(GFX_BUILD_EXAMPLES)
Expand Down Expand Up @@ -216,6 +217,11 @@ if(GFX_BUILD_EXAMPLES)
add_subdirectory("examples")
endif()

if (GFX_BUILD_TESTS)
enable_testing() # need to be in the top level cmakelists
add_subdirectory("tests")
endif()

if(GFX_INSTALL)
install(TARGETS Graphics
RUNTIME DESTINATION "bin"
Expand Down
2 changes: 2 additions & 0 deletions include/Graphics/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Buffer
size_t size = 0;
BufferUsages usages = BufferUsage::uniformBuffer;
ResourceStorageMode storageMode = ResourceStorageMode::hostVisible;

auto operator<=>(const Descriptor&) const = default;
};

public:
Expand Down
1 change: 1 addition & 0 deletions include/Graphics/Device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Device
struct Descriptor
{
QueueCapabilities queueCaps;
auto operator<=>(const Descriptor&) const = default;
};

public:
Expand Down
5 changes: 2 additions & 3 deletions include/Graphics/Enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <type_traits>
#include <cstdint>
#include <stdexcept>
#include <compare> // IWYU pragma: keep

namespace gfx
{
Expand All @@ -29,9 +30,7 @@ class Flags

[[nodiscard]] constexpr inline T value() const { return m_value; }

[[nodiscard]] constexpr inline bool operator==(const Flags& rhs) const { return m_value == rhs.m_value; }
[[nodiscard]] constexpr inline bool operator!=(const Flags& rhs) const { return m_value != rhs.m_value; }
[[nodiscard]] constexpr inline bool operator<(const Flags& rhs) const { return m_value < rhs.m_value; }
[[nodiscard]] constexpr inline auto operator<=>(const Flags& rhs) const = default;

[[nodiscard]] constexpr inline Flags operator|(const Flags& rhs) const { return Flags(m_value | rhs.m_value); }
[[nodiscard]] constexpr inline Flags operator&(const Flags& rhs) const { return Flags(m_value & rhs.m_value); }
Expand Down
3 changes: 2 additions & 1 deletion include/Graphics/GraphicsPipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#ifndef GRAPHICSPIPELINE_HPP
#define GRAPHICSPIPELINE_HPP

#include "Graphics/ParameterBlock.hpp"
#include "Graphics/ShaderFunction.hpp"
#include "Graphics/Enums.hpp"
#include "Graphics/VertexLayout.hpp"
Expand Down Expand Up @@ -40,6 +39,8 @@ class GraphicsPipeline
CullMode cullMode = CullMode::none;

std::vector<std::shared_ptr<ParameterBlockLayout>> parameterBlockLayouts;

auto operator<=>(const Descriptor&) const = default;
};

public:
Expand Down
2 changes: 2 additions & 0 deletions include/Graphics/Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Instance
std::array<int, 3> appVersion;
std::string engineName;
std::array<int, 3> engineVersion;

auto operator<=>(const Descriptor&) const = default;
};

public:
Expand Down
1 change: 0 additions & 1 deletion include/Graphics/ParameterBlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#ifndef PARAMETERBLOCK_HPP
#define PARAMETERBLOCK_HPP

#include "Graphics/Enums.hpp"
#include "Graphics/Buffer.hpp"
#include "Graphics/Texture.hpp"
#include "Graphics/Sampler.hpp"
Expand Down
4 changes: 3 additions & 1 deletion include/Graphics/ParameterBlockLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct ParameterBlockBinding
{
BindingType type = BindingType::uniformBuffer;
BindingUsages usages = BindingUsage::vertexRead | BindingUsage::fragmentRead;
auto operator<=>(const ParameterBlockBinding&) const = default;
};

class ParameterBlockLayout
Expand All @@ -29,12 +30,13 @@ class ParameterBlockLayout
struct Descriptor
{
std::vector<ParameterBlockBinding> bindings;
auto operator<=>(const Descriptor&) const = default;
};

public:
ParameterBlockLayout(const ParameterBlockLayout&) = delete;
ParameterBlockLayout(ParameterBlockLayout&&) = delete;

virtual const std::vector<ParameterBlockBinding>& bindings() const = 0;

virtual ~ParameterBlockLayout() = default;
Expand Down
1 change: 1 addition & 0 deletions include/Graphics/ParameterBlockPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ParameterBlockPool
uint32_t maxUniformBuffers = 16;
uint32_t maxTextures = 4;
uint32_t maxSamplers = 4;
auto operator<=>(const Descriptor&) const = default;
};

ParameterBlockPool(const ParameterBlockPool&) = delete;
Expand Down
2 changes: 2 additions & 0 deletions include/Graphics/QueueCapabilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct QueueCapabilities
bool compute;
bool transfer;
std::vector<Surface*> present;

auto operator<=>(const QueueCapabilities&) const = default;
};

}
Expand Down
1 change: 1 addition & 0 deletions include/Graphics/Sampler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Sampler
SamplerAddressMode rAddressMode = SamplerAddressMode::ClampToEdge;
SamplerMinMagFilter minFilter = SamplerMinMagFilter::Nearest;
SamplerMinMagFilter magFilter = SamplerMinMagFilter::Nearest;
auto operator<=>(const Descriptor&) const = default;
};

public:
Expand Down
1 change: 1 addition & 0 deletions include/Graphics/Swapchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Swapchain
uint32_t drawableCount = 3;
PixelFormat pixelFormat = PixelFormat::BGRA8Unorm;
PresentMode presentMode = PresentMode::fifo;
auto operator<=>(const Descriptor&) const = default;
};

public:
Expand Down
1 change: 1 addition & 0 deletions include/Graphics/Texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Texture
PixelFormat pixelFormat = PixelFormat::RGBA8Unorm;
TextureUsages usages = TextureUsage::shaderRead;
ResourceStorageMode storageMode = ResourceStorageMode::deviceLocal;
auto operator<=>(const Descriptor&) const = default;
};

public:
Expand Down
3 changes: 3 additions & 0 deletions include/Graphics/VertexLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct VertexAttribute
VertexAttributeFormat format;
size_t offset;
// bufferIndex
auto operator<=>(const VertexAttribute&) const = default;
};

struct VertexLayout
Expand All @@ -31,6 +32,8 @@ struct VertexLayout
// stepFunction
// stepRate
std::vector<VertexAttribute> attributes;

auto operator<=>(const VertexLayout&) const = default;
};

}
Expand Down
35 changes: 35 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ---------------------------------------------------
# CMakeLists.txt
#
# Author: Thomas Choquet <semoir.dense-0h@icloud.com>
# ---------------------------------------------------

include(FetchContent)
include(GoogleTest)


add_executable(gfx_test)

# test file only require 11, will be higher when linking to something that need higher
target_compile_features(gfx_test PUBLIC cxx_std_11)
set_target_properties(gfx_test PROPERTIES FOLDER "tests")

file(GLOB_RECURSE SRC "*.cpp")
target_sources(gfx_test PRIVATE ${SRC})

target_include_directories(gfx_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
GIT_SHALLOW v1.15.2
)
set(BUILD_GMOCK OFF)
set(INSTALL_GTEST OFF)
FetchContent_MakeAvailable(googletest)
set_target_properties(gtest PROPERTIES FOLDER "dependencies")
set_target_properties(gtest_main PROPERTIES FOLDER "dependencies")

target_link_libraries(gfx_test PRIVATE Graphics GTest::gtest_main)

gtest_discover_tests(gfx_test)
Loading