Skip to content

Commit

Permalink
Merge pull request #9 from MethanePowered/develop
Browse files Browse the repository at this point in the history
Methane Asteroids v0.7.2: upgrade Methane Kit, migrate from PerlinNoise to FastNoise2
  • Loading branch information
egorodet committed Jun 3, 2023
2 parents fb72476 + 4371f14 commit cd4e972
Show file tree
Hide file tree
Showing 21 changed files with 316 additions and 452 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ on:
env:
product_ver_major: 0
product_ver_minor: 7
product_ver_patch: 1
product_ver_patch: 2
product_ver_build: ${{ github.run_number }}
tracy_release_version: "0.9"
tracy_release_version: "0.9.1"

jobs:
build-asteroids:
Expand Down Expand Up @@ -113,16 +113,30 @@ jobs:

- os: macos-latest
os_name: MacOS
name: "MacOS_MTL_Release"
config_preset: "Xcode-Mac-MTL-Default"
build_preset: "Xcode-Mac-MTL-Release"
name: "MacOS_Arm64_MTL_Release"
config_preset: "Xcode-Mac-Arm64-MTL-Default"
build_preset: "Xcode-Mac-Arm64-MTL-Release"
add_tracy_app: false

- os: macos-latest
os_name: MacOS
name: "MacOS_MTL_Profile"
config_preset: "Xcode-Mac-MTL-Profile"
build_preset: "Xcode-Mac-MTL-Profile"
name: "MacOS_Arm64_MTL_Profile"
config_preset: "Xcode-Mac-Arm64-MTL-Profile"
build_preset: "Xcode-Mac-Arm64-MTL-Profile"
add_tracy_app: true

- os: macos-latest
os_name: MacOS
name: "MacOS_x86-64_MTL_Release"
config_preset: "Xcode-Mac-x86-64-MTL-Default"
build_preset: "Xcode-Mac-x86-64-MTL-Release"
add_tracy_app: false

- os: macos-latest
os_name: MacOS
name: "MacOS_x86-64_MTL_Profile"
config_preset: "Xcode-Mac-x86-64-MTL-Profile"
build_preset: "Xcode-Mac-x86-64-MTL-Profile"
add_tracy_app: true

- os: macos-latest
Expand Down
10 changes: 5 additions & 5 deletions App/AsteroidsApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ void AsteroidsApp::Init()
// Create constants buffer for frame rendering
m_const_buffer = context.CreateBuffer(rhi::BufferSettings::ForConstantBuffer(constants_data_size));
m_const_buffer.SetName("Constants Buffer");
m_const_buffer.SetData(
{ { reinterpret_cast<Data::ConstRawPtr>(&m_scene_constants), sizeof(m_scene_constants) } }, // NOSONAR
render_cmd_queue
);
m_const_buffer.SetData(render_cmd_queue, {
reinterpret_cast<Data::ConstRawPtr>(&m_scene_constants),
sizeof(m_scene_constants)
});

// ========= Per-Frame Data =========
for(AsteroidsFrame& frame : GetFrames())
Expand Down Expand Up @@ -436,7 +436,7 @@ bool AsteroidsApp::Render()
// Upload uniform buffers to GPU
const AsteroidsFrame& frame = GetCurrentFrame();
rhi::CommandQueue render_cmd_queue = GetRenderContext().GetRenderCommandKit().GetQueue();
frame.scene_uniforms_buffer.SetData(m_scene_uniforms_subresources, render_cmd_queue);
frame.scene_uniforms_buffer.SetData(render_cmd_queue, m_scene_uniforms_subresource);

// Asteroids rendering in parallel or in main thread
if (m_is_parallel_rendering_enabled)
Expand Down
4 changes: 2 additions & 2 deletions App/AsteroidsApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class AsteroidsApp final
uint32_t m_asteroids_complexity = 0U;
bool m_is_parallel_rendering_enabled = true;
hlslpp::SceneUniforms m_scene_uniforms{ };
rhi::SubResources m_scene_uniforms_subresources{
{ reinterpret_cast<Data::ConstRawPtr>(&m_scene_uniforms), sizeof(hlslpp::SceneUniforms) } // NOSONAR
rhi::SubResource m_scene_uniforms_subresource{
reinterpret_cast<Data::ConstRawPtr>(&m_scene_uniforms), sizeof(hlslpp::SceneUniforms)
};

rhi::RenderPattern m_asteroids_render_pattern;
Expand Down
12 changes: 6 additions & 6 deletions Build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
sudo apt-get update && sudo apt-get install build-essential git cmake lcov xcb libx11-dev libx11-xcb-dev libxcb-sync-dev libxcb-randr0-dev
```
- **MacOS**
- MacOS 10.15 "Catalina" or later
- XCode 11 or later with command-line tools
- MacOS 13 "Ventura" or later
- XCode 14 or later with command-line tools
- **iOS / tvOS**
- All MacOS prerequisites from above
- iOS or tvOS simulator for running app in virtual environment
Expand Down Expand Up @@ -122,13 +122,13 @@ Start Terminal, go to `MethaneAsteroids` root directory, generate XCode workspac

```console
OUTPUT_DIR=Build/Output/XCode/macOS
cmake -S . -B $OUTPUT_DIR/Build -G Xcode -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_INSTALL_PREFIX="$(pwd)/$OUTPUT_DIR/Install"
cmake -S . -B $OUTPUT_DIR/Build -G Xcode -DCMAKE_OSX_ARCHITECTURES="[arm64|x86_64]" -DCMAKE_INSTALL_PREFIX="$(pwd)/$OUTPUT_DIR/Install"
cmake --build $OUTPUT_DIR/Build --config Release --target install
```

Note that starting with XCode 12 and Clang 12 build architectures have to be specified explicitly
using CMake generator command line option `-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"` to build the fat binary.
This option should be omitted with earlier versions of Clang on macOS.
using CMake generator command line option `-DCMAKE_OSX_ARCHITECTURES="[arm64|x86_64]"` (multiple architecture are not supported by Asteroids sample)
to build the fat binary. This option should be omitted with earlier versions of Clang on macOS.

Auxiliary build script [Build/Unix/Build.sh](/Build/Unix/Build.sh) can make it more simple for you:

Expand All @@ -152,7 +152,7 @@ Start Terminal, go to `MethaneAsteroids` root directory, generate XCode workspac

```console
OUTPUT_DIR=Build/Output/XCode/iOS
cmake -S . -B $OUTPUT_DIR/Build -G Xcode -DCMAKE_TOOLCHAIN_FILE="Externals/iOS-Toolchain.cmake" -DPLATFORM=[SIMULATORARM64|OS64|SIMULATOR_TVOS|TVOS] -DDEPLOYMENT_TARGET=15.0 -DENABLE_ARC:BOOL=ON [-DAPPLE_DEVELOPMENT_TEAM=12345X6ABC] -DCMAKE_INSTALL_PREFIX="$(pwd)/$OUTPUT_DIR/Install"
cmake -S . -B $OUTPUT_DIR/Build -G Xcode -DCMAKE_TOOLCHAIN_FILE="Externals/iOS-Toolchain.cmake" -DPLATFORM=[SIMULATORARM64|OS64|SIMULATOR_TVOS|TVOS] -DDEPLOYMENT_TARGET=16.0 -DENABLE_ARC:BOOL=ON [-DAPPLE_DEVELOPMENT_TEAM=12345X6ABC] -DCMAKE_INSTALL_PREFIX="$(pwd)/$OUTPUT_DIR/Install"
cmake --build $OUTPUT_DIR/Build --config Release --target install -- -allowProvisioningUpdates
```

Expand Down
58 changes: 36 additions & 22 deletions Build/Unix/Build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

BUILD_VERSION_MAJOR=0
BUILD_VERSION_MINOR=7
BUILD_VERSION=$BUILD_VERSION_MAJOR.$BUILD_VERSION_MINOR
BUILD_VERSION_PATCH=2
BUILD_VERSION=$BUILD_VERSION_MAJOR.$BUILD_VERSION_MINOR.$BUILD_VERSION_PATCH

SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
SOURCE_DIR=$SCRIPT_DIR/../..
OUTPUT_DIR=$SCRIPT_DIR/../Output
APPLE_DEPLOYMENT_TARGET="15.0"
PRECOMPILED_HEADERS_ENABLED="ON"

# Parse command line arguments
while [ $# -ne 0 ]
Expand Down Expand Up @@ -54,36 +55,48 @@ done
# Choose CMake generator depending on operating system
ARCH_NAME="$(uname -m)"
OS_NAME="$(uname -s)"
case "${OS_NAME}" in
case "$OS_NAME" in
Linux*)
CMAKE_GENERATOR=Unix\ Makefiles
PLATFORM_NAME=Linux
;;
Darwin*)
CMAKE_GENERATOR=Xcode
PLATFORM_NAME=MacOS
if [ "$APPLE_PLATFORM" != "" ]; then
# Disable tests cause unbundled console executables can not be built with iOS toolchain
TESTS_BUILD_ENABLED="OFF"
CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$SOURCE_DIR/Externals/iOS-Toolchain.cmake \
-DPLATFORM=$APPLE_PLATFORM \
-DDEPLOYMENT_TARGET=$APPLE_DEPLOYMENT_TARGET \
-DENABLE_ARC:BOOL=ON \
-DENABLE_VISIBILITY:BOOL=ON \
-DENABLE_BITCODE:BOOL=OFF \
-DENABLE_STRICT_TRY_COMPILE:BOOL=OFF"
if [ "$APPLE_DEVELOPMENT_TEAM" != "" ]; then
CMAKE_FLAGS="$CMAKE_FLAGS \
-DAPPLE_DEVELOPMENT_TEAM=${APPLE_DEVELOPMENT_TEAM}"
CMAKE_BUID_OPTIONS="-- -allowProvisioningUpdates"
PRECOMPILED_HEADERS_ENABLED="OFF"
if [ "$APPLE_PLATFORM" == "" ]; then
case "$ARCH_NAME" in
arm64*)
APPLE_PLATFORM=MAC_ARM64
;;
*)
APPLE_PLATFORM=MAC
;;
esac
fi
if [ "$APPLE_DEPLOYMENT_TARGET" == "" ]; then
if [[ "$APPLE_PLATFORM" =~ ^MAC.*$ ]]; then
APPLE_DEPLOYMENT_TARGET="13.0"
else
APPLE_DEPLOYMENT_TARGET="16.0"
fi
else
APPLE_PLATFORM=MacOS_$ARCH_NAME
fi
CMAKE_FLAGS="-DCMAKE_TOOLCHAIN_FILE=$SOURCE_DIR/Externals/iOS-Toolchain.cmake \
-DPLATFORM=$APPLE_PLATFORM \
-DDEPLOYMENT_TARGET=$APPLE_DEPLOYMENT_TARGET \
-DENABLE_ARC:BOOL=ON \
-DENABLE_VISIBILITY:BOOL=ON \
-DENABLE_BITCODE:BOOL=OFF \
-DENABLE_STRICT_TRY_COMPILE:BOOL=OFF"
if [ "$APPLE_DEVELOPMENT_TEAM" != "" ]; then
CMAKE_FLAGS="$CMAKE_FLAGS \
-DAPPLE_DEVELOPMENT_TEAM=${APPLE_DEVELOPMENT_TEAM}"
CMAKE_BUID_OPTIONS="-- -allowProvisioningUpdates"
fi
;;
*)
echo "Unsupported operating system!" 1>&2 && exit 1
;;
echo "Unsupported operating system!" 1>&2 && exit 1
;;
esac

if [ "$IS_DEBUG_BUILD" == true ]; then
Expand Down Expand Up @@ -124,10 +137,11 @@ fi
CMAKE_FLAGS="$CMAKE_FLAGS \
-DMETHANE_VERSION_MAJOR=$BUILD_VERSION_MAJOR \
-DMETHANE_VERSION_MINOR=$BUILD_VERSION_MINOR \
-DMETHANE_VERSION_PATCH=$BUILD_VERSION_PATCH \
-DMETHANE_GFX_VULKAN_ENABLED:BOOL=$VULKAN_BUILD_FLAG \
-DMETHANE_SHADERS_CODEVIEW_ENABLED:BOOL=ON \
-DMETHANE_RHI_PIMPL_INLINE_ENABLED:BOOL=ON \
-DMETHANE_PRECOMPILED_HEADERS_ENABLED:BOOL=ON \
-DMETHANE_PRECOMPILED_HEADERS_ENABLED:BOOL=$PRECOMPILED_HEADERS_ENABLED \
-DMETHANE_RUN_TESTS_DURING_BUILD:BOOL=OFF \
-DMETHANE_COMMAND_DEBUG_GROUPS_ENABLED:BOOL=ON \
-DMETHANE_LOGGING_ENABLED:BOOL=OFF \
Expand Down
4 changes: 3 additions & 1 deletion Build/Windows/Build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ SETLOCAL ENABLEDELAYEDEXPANSION

SET BUILD_VERSION_MAJOR=0
SET BUILD_VERSION_MINOR=7
SET BUILD_VERSION=%BUILD_VERSION_MAJOR%.%BUILD_VERSION_MINOR%
SET BUILD_VERSION_PATCH=2
SET BUILD_VERSION=%BUILD_VERSION_MAJOR%.%BUILD_VERSION_MINOR%.%BUILD_VERSION_PATCH%

SET OUTPUT_DIR=%~dp0..\Output
SET SOURCE_DIR=%~dp0..\..
Expand Down Expand Up @@ -71,6 +72,7 @@ SET CMAKE_FLAGS= ^
-A %ARCH_TYPE% ^
-DASTEROIDS_VERSION_MAJOR=%BUILD_VERSION_MAJOR% ^
-DASTEROIDS_VERSION_MINOR=%BUILD_VERSION_MINOR% ^
-DASTEROIDS_VERSION_PATCH=%BUILD_VERSION_PATCH% ^
-DMETHANE_GFX_VULKAN_ENABLED:BOOL=%VULKAN_API_ENABLED% ^
-DMETHANE_SHADERS_CODEVIEW_ENABLED:BOOL=ON ^
-DMETHANE_RHI_PIMPL_INLINE_ENABLED:BOOL=ON ^
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.18.0)
cmake_minimum_required(VERSION 3.21.0)

# Methane version, build & product info
set(ASTEROIDS_VERSION_MAJOR 0 CACHE STRING "Asteroids major version")
set(ASTEROIDS_VERSION_MINOR 7 CACHE STRING "Asteroids minor version")
set(ASTEROIDS_VERSION_PATCH 1 CACHE STRING "Asteroids patch version")
set(ASTEROIDS_VERSION_PATCH 2 CACHE STRING "Asteroids patch version")
set(ASTEROIDS_VERSION_BUILD 0 CACHE STRING "Asteroids build version")

project(METHANE_ASTEROIDS
Expand Down
Loading

0 comments on commit cd4e972

Please sign in to comment.