Skip to content

Commit

Permalink
Code improvements, bug fixes, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cfnptr committed Oct 13, 2024
1 parent 31fd2b9 commit 7769c91
Show file tree
Hide file tree
Showing 107 changed files with 1,035 additions and 755 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install macOS packages
if: matrix.os == 'macos-latest'
run: |
brew update && brew install zlib
brew update && brew install zlib openssl
curl -O https://sdk.lunarg.com/sdk/download/latest/mac/vulkan_sdk.dmg
volumeInfo=$(hdiutil attach vulkan_sdk.dmg | grep Volumes)
volume=$(echo "$volumeInfo" | cut -f 3)
Expand Down
35 changes: 26 additions & 9 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [macOS (14/15)](BUILDING.md#macos-1415)
* [Build Project](BUILDING.md#build-project)


# Windows (10/11)

## 1. Install Visual Studio Community (Or any other IDE)
Expand All @@ -33,19 +34,35 @@ You may use default Git install options or chose any other default Git editor in

* Download and install latest version from [vulkan.lunarg.com](https://vulkan.lunarg.com) for **Windows**

To build the engine you will only need **The Vulkan SDK Core** components.
To build the project you will only need **The Vulkan SDK Core** components.

## 5. Clone Repository

1. Open **Terminal** or **CMD** app to execute following commands
2. Change current working directory using ```cd``` command where to clone repository. (Google it)
3. Run ```git clone --recursive https://github.com/cfnptr/garden``` command to download repository
4. Run ```cd garden/``` to enter repository directory

Note! Use appropriate github link if Garden engine is used as a third-party library.

## 5. Install vcpkg package manager
## 6. Install vcpkg package manager

1. Follow installation steps from [learn.microsoft.com](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started)
2. Run ```vcpkg integrate install``` using **Terminal** or **CMD** app to make packages available user-wide
1. Open **CMD** or **Terminal** app as Administrator. (Right click the app)
2. Run ```scripts/update-vcpkg.bat``` command from the repository *scripts/* directory

Better to choose C:\vcpkg path. Don't forget to add **vcpkg** to the System Environment Variables!
Or

1. Follow installation steps from [learn.microsoft.com](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started) (Better to choose C:\vcpkg path)
2. Run ```vcpkg integrate install``` command using **Terminal** or **CMD** app to make packages available user-wide
3. Add **vcpkg** to the System Environment Variables. (Google it)

## 6. Install required packages

1. Run ```vcpkg install zlib:x64-windows-static openssl:x64-windows-static``` using **Terminal** or **CMD** app

Alternatively run ```install-packages.bat``` from the repository **scripts/** directory


# Ubuntu (22.04/24.04)

## 1. Install Visual Studio Code (Or any other IDE)
Expand All @@ -55,7 +72,7 @@ Better to choose C:\vcpkg path. Don't forget to add **vcpkg** to the System Envi

## 2. Install required packages

1. Run ```sudo apt-get update``` using **Terminal** app
1. Run ```sudo apt-get update``` command using **Terminal** app
2. And ```sudo apt-get install git gcc g++ gdb cmake clang zlib1g-dev libssl-dev xorg-dev```

## 3. Install Vulkan SDK
Expand All @@ -70,20 +87,20 @@ Use "Ubuntu Packages" tab and "Latest Supported Release" instructions for that.
## 1. Install Xcode (Or any other IDE)

1. Download and install latest version from **App Store** app
2. Run ```xcode-select --install``` using **Terminal** app to install Xcode tools
2. Run ```xcode-select --install``` command using **Terminal** app to install Xcode tools

## 2. Install required packages

1. Install **Homebrew** package manager from [brew.sh](https://brew.sh)
2. Run ```brew update``` using **Terminal** app
2. Run ```brew update``` command using **Terminal** app
3. And ```brew install git cmake zlib openssl```

## 3. Install Vulkan SDK

1. Download latest version from [vulkan.lunarg.com](https://vulkan.lunarg.com) for **macOS**
2. During **Select Components** screen "System Global Installation" should be checked

To build the engine you will only need The Vulkan SDK Core components.
To build the project you will only need The Vulkan SDK Core components.


# Build Project
Expand Down
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GARDEN ![CI](https://github.com/cfnptr/garden/actions/workflows/cmake.yml/badge.svg)
# Garden

![Engine screenshot](docs/engine-screenshot.png)

Expand All @@ -12,8 +12,8 @@ graphics APIs. See the [features](FEATURES.md) list.
## Supported operating systems

* Windows (10/11)
* Ubuntu (22.04 LTS)
* macOS (Ventura 13)
* Ubuntu (22.04/24.04)
* macOS (14/15)

This list includes only those systems on which functionality testing is conducted.
However, you can also compile it under any other Linux distribution or operating system.
Expand All @@ -35,7 +35,7 @@ However, you can also compile it under any other Linux distribution or operating
These requirements are based on the support of the **AVX2** instruction set.
If you want, you can freely disable it and compile for any other architecture, including **ARM**.

## Build requirements
## Build requirements ![CI](https://github.com/cfnptr/garden/actions/workflows/cmake.yml/badge.svg)

* C++17 compiler
* [Git 2.39+](https://git-scm.com)
Expand Down Expand Up @@ -79,6 +79,12 @@ Use building [instructions](BUILDING.md) to install all required tools and libra
| garden | Static Garden library | `.lib` | `.a` | `.a` |
| {name} | Application executable | `.exe` | `.app` | |

## Cloning

```
git clone --recursive https://github.com/cfnptr/garden
```

## Garden Shading Language (GSL)

Documentation with all GLSL changes is located [here](docs/gsl.md).
Expand All @@ -90,19 +96,21 @@ You can install **Visual Studio Code** [extension](https://marketplace.visualstu
* [ECSM](https://github.com/cfnptr/ecsm) (Apache-2.0 license)
* [FastNoise2](https://github.com/Auburn/FastNoise2) (MIT license)
* [FreeType](https://github.com/freetype/freetype) (FreeType license)
* [GLFW](https://github.com/glfw/glfw) (Zlib license)
* [GLFW](https://github.com/glfw/glfw) (zlib license)
* [ImGui](https://github.com/ocornut/imgui) (MIT license)
* [JoltPhysics](https://github.com/jrouwe/JoltPhysics) (MIT license)
* [JSON](https://github.com/nlohmann/json) (MIT license)
* [Logy](https://github.com/cfnptr/logy) (Apache-2.0 license)
* [Math](https://github.com/cfnptr/math) (Apache-2.0 license)
* [Nets](https://github.com/cfnptr/nets) (Apache-2.0 license)
* [OpenSSL](https://github.com/openssl/openssl) (Apache-2.0 license)
* [Pack](https://github.com/cfnptr/pack) (Apache-2.0 license)
* [PNG](https://github.com/pnggroup/libpng) (PNG-2 license)
* [stb](https://github.com/nothings/stb) (MIT license)
* [TinyEXR](https://github.com/syoyo/tinyexr) (BSD-3-Clause license)
* [VulkanMemoryAllocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) (MIT license)
* [Vulkan SDK](https://github.com/KhronosGroup) (Apache-2.0 license)
* [Voxy](https://github.com/cfnptr/voxy) (Apache-2.0 license)
* [WebP](https://github.com/webmproject/libwebp) (BSD-3-Clause license)
* [xxHash](https://github.com/Cyan4973/xxHash) (BSD-2-Clause license)
* [Vulkan SDK](https://github.com/KhronosGroup) (Apache-2.0 license)
* [zlib](https://github.com/madler/zlib) (zlib license)
20 changes: 10 additions & 10 deletions cmake/app-defines.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ using namespace std;
using namespace math;
using namespace garden;

const string appName = "@GARDEN_APP_NAME@";
const string appNameLowercase = "@GARDEN_APP_NAME_LOWERCASE@";
const string appDescription = "@GARDEN_APP_DESCRIPTION@";
const string appCreator = "@GARDEN_APP_CREATOR@";
const string appCopyright = "@GARDEN_APP_COPYRIGHT@";
const uint8 appVersionMajor = @GARDEN_APP_VERSION_MAJOR@;
const uint8 appVersionMinor = @GARDEN_APP_VERSION_MINOR@;
const uint8 appVersionPatch = @GARDEN_APP_VERSION_PATCH@;
const Version appVersion = Version(@GARDEN_APP_VERSION_MAJOR@, @GARDEN_APP_VERSION_MINOR@, @GARDEN_APP_VERSION_PATCH@);
const string appVersionString = "@GARDEN_APP_VERSION@";
constexpr string_view appName = "@GARDEN_APP_NAME@";
constexpr string_view appNameLowercase = "@GARDEN_APP_NAME_LOWERCASE@";
constexpr string_view appDescription = "@GARDEN_APP_DESCRIPTION@";
constexpr string_view appCreator = "@GARDEN_APP_CREATOR@";
constexpr string_view appCopyright = "@GARDEN_APP_COPYRIGHT@";
constexpr uint8 appVersionMajor = @GARDEN_APP_VERSION_MAJOR@;
constexpr uint8 appVersionMinor = @GARDEN_APP_VERSION_MINOR@;
constexpr uint8 appVersionPatch = @GARDEN_APP_VERSION_PATCH@;
constexpr Version appVersion = Version(@GARDEN_APP_VERSION_MAJOR@, @GARDEN_APP_VERSION_MINOR@, @GARDEN_APP_VERSION_PATCH@);
constexpr string_view appVersionString = "@GARDEN_APP_VERSION@";

#if GARDEN_DEBUG
const fs::path appCachesPath = fs::path("@GARDEN_APP_CACHES_DIR@");
Expand Down
4 changes: 4 additions & 0 deletions cmake/compile-options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

# Based on Steam survey instruction set support.
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

add_compile_options(/MP /nologo /utf-8 /arch:AVX2)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_options(/GL)
Expand Down
4 changes: 0 additions & 4 deletions cmake/package-managers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(VCPKG_TARGET_TRIPLET "${VCPKG_ARCH}-windows-static")
message(STATUS "VCPKG_TARGET_TRIPLET: " ${VCPKG_TARGET_TRIPLET})
endif()

if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
if(NOT DEFINED HOMEBREW_PREFIX)
set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX})
Expand Down
16 changes: 8 additions & 8 deletions include/garden/arch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
#pragma once

#if defined(__x86_64__) || defined(_M_X64)
#define GARDEN_ARCH "x86-64"
#define GARDEN_ARCH_X86_64
#define GARDEN_CPU_ARCH "x86-64"
#define GARDEN_CPU_ARCH_X86_64
#elif defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
#define GARDEN_ARCH "x86-32"
#define GARDEN_ARCH_X86_32
#define GARDEN_CPU_ARCH "x86-32"
#define GARDEN_CPU_ARCH_X86_32
#elif defined(__aarch64__) || defined(_M_ARM64)
#define GARDEN_ARCH "ARM64"
#define GARDEN_ARCH_ARM64
#define GARDEN_CPU_ARCH "ARM64"
#define GARDEN_CPU_ARCH_ARM64
#elif defined(__arm__) || defined(_M_ARM)
#define GARDEN_ARCH "ARM32"
#define GARDEN_ARCH_ARM32
#define GARDEN_CPU_ARCH "ARM32"
#define GARDEN_CPU_ARCH_ARM32
#else
#error "Unknown CPU architecture"
#endif
2 changes: 1 addition & 1 deletion include/garden/editor/system/graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace garden
class GraphicsEditorSystem final : public System
{
public:
inline static const psize sampleBufferSize = 512;
static constexpr psize sampleBufferSize = 512;
private:
float* cpuFpsBuffer = nullptr;
float* gpuFpsBuffer = nullptr;
Expand Down
2 changes: 0 additions & 2 deletions include/garden/editor/system/render/9-slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
namespace garden
{

using namespace garden::graphics;

class NineSliceRenderEditorSystem final : public System
{
NineSliceRenderEditorSystem();
Expand Down
10 changes: 10 additions & 0 deletions include/garden/editor/system/render/infinite-grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ namespace garden

class InfiniteGridEditorSystem final : public System
{
public:
struct PushConstants final
{
float4 gridColor;
float4 axisColorX;
float4 axisColorY;
float gridScale;
int32 isHorizontal;
};
private:
ID<GraphicsPipeline> pipeline;
ID<DescriptorSet> descriptorSet;

Expand Down
3 changes: 0 additions & 3 deletions include/garden/editor/system/render/lighting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
namespace garden
{

using namespace garden::graphics;

class LightingRenderEditorSystem final : public System
{
LightingRenderEditorSystem();
Expand All @@ -30,7 +28,6 @@ class LightingRenderEditorSystem final : public System
void deinit();

void onEntityInspector(ID<Entity> entity, bool isOpened);

friend class ecsm::Manager;
public:
float inspectorPriority = -0.1f;
Expand Down
10 changes: 8 additions & 2 deletions include/garden/editor/system/render/mesh-gizmos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@
namespace garden
{

using namespace garden::graphics;

class MeshGizmosEditorSystem final : public System
{
public:
struct PushConstants final
{
float4x4 mvp;
float4 color;
float renderScale;
};
private:
ID<GraphicsPipeline> frontGizmosPipeline = {};
ID<GraphicsPipeline> backGizmosPipeline = {};
ID<Buffer> fullArrowVertices = {};
Expand Down
2 changes: 0 additions & 2 deletions include/garden/editor/system/render/shadow-mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
namespace garden
{

using namespace garden::graphics;

class ShadowMappingEditor final
{
ID<GraphicsPipeline> cascadesPipeline = {};
Expand Down
19 changes: 12 additions & 7 deletions include/garden/editor/system/render/skybox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@
// limitations under the License.

#pragma once
#include "garden/system/render/skybox.hpp"
#include "garden/system/render/editor.hpp"

#if GARDEN_EDITOR
namespace garden
{

using namespace garden::graphics;

class SkyboxEditor final
class SkyboxRenderEditorSystem final : public System
{
SkyboxEditor(SkyboxRenderSystem* system);
void onEntityInspector(ID<Entity> entity);
friend class SkyboxRenderSystem;
SkyboxRenderEditorSystem();
~SkyboxRenderEditorSystem() final;

void init();
void deinit();

void onEntityInspector(ID<Entity> entity, bool isOpened);
friend class ecsm::Manager;
public:
float inspectorPriority = -0.1f;
};

} // namespace garden
Expand Down
2 changes: 0 additions & 2 deletions include/garden/editor/system/render/sprite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
namespace garden
{

using namespace garden::graphics;

class SpriteRenderEditorSystem final : public System
{
SpriteRenderEditorSystem();
Expand Down
2 changes: 0 additions & 2 deletions include/garden/editor/system/render/ssao.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
namespace garden
{

using namespace garden::graphics;

class SsaoEditor final
{
bool showWindow = false;
Expand Down
2 changes: 0 additions & 2 deletions include/garden/editor/system/render/tone-mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
namespace garden
{

using namespace garden::graphics;

class ToneMappingEditor final
{
int toneMapperType = 0;
Expand Down
3 changes: 1 addition & 2 deletions include/garden/graphics/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GraphicsAPI final
/**
* @brief Minimal DLSS output size
*/
inline static const int32 minFramebufferSize = 32;
static constexpr int32 minFramebufferSize = 32;

enum class DestroyResourceType : uint32
{
Expand All @@ -68,7 +68,6 @@ class GraphicsAPI final

static string appDataName;
static Version appVersion;
static Hash128::State hashState;
static void* window;
static LinearPool<Buffer> bufferPool;
static LinearPool<Image> imagePool;
Expand Down
Loading

0 comments on commit 7769c91

Please sign in to comment.