Skip to content

Commit

Permalink
Merge pull request #32 from ARM-software/develop
Browse files Browse the repository at this point in the history
Release v1.2.0
  • Loading branch information
ZandroFargnoli authored Sep 27, 2019
2 parents 356cf52 + cd497b0 commit dae28a6
Show file tree
Hide file tree
Showing 219 changed files with 9,409 additions and 5,087 deletions.
21 changes: 16 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ClangTidy:
- docker
script:
- cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -H. -Bbuild/clang
- python3 /usr/local/bin/run-clang-tidy.py -p build/clang -clang-tidy-binary=clang-tidy-8 -header-filter=.*,-third_party -checks=-*,google-*,-google-runtime-references -quiet framework samples app
- python3 /usr/local/bin/run-clang-tidy.py -j $(($(nproc)/2+1)) -p build/clang -clang-tidy-binary=clang-tidy-8 -header-filter=framework,samples,vulkan_best_practice -checks=-*,google-*,-google-runtime-references -quiet framework/* samples/* vulkan_best_practice/*

Linux:
stage: Build
Expand All @@ -75,7 +75,7 @@ Linux:
- docker
script:
- cmake -G "Unix Makefiles" -H. -Bbuild/linux -DCMAKE_BUILD_TYPE=Release -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON
- cmake --build build/linux --target vulkan_best_practice --config Release
- cmake --build build/linux --target vulkan_best_practice --config Release -- -j$(($(nproc)/2+1))

Windows:
stage: Build
Expand All @@ -98,7 +98,19 @@ Android:
- docker
script:
- cmake -G "Unix Makefiles" -H. -Bbuild/android -DCMAKE_TOOLCHAIN_FILE=bldsys/toolchain/android_gradle.cmake -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON
- cmake --build build/android --config Release --target vulkan_best_practice_package
- cmake --build build/android --config Release --target vulkan_best_practice_package -- -j$(($(nproc)/2+1))

GenerateSample:
stage: Test
variables:
GIT_SUBMODULE_STRATEGY: recursive
tags:
- windows
- shell
script:
- cd tests/generate_sample
- python generate_sample_test.py
allow_failure: true

SystemTest:
stage: Test
Expand All @@ -107,9 +119,8 @@ SystemTest:
tags:
- windows
- shell
before_script:
- xcopy D:\scenes\cookbook-models .\assets\ /s /y
script:
- python bldsys/scripts/download_assets.py
- cd tests/system_test
- python system_test.py -Bbuild/windows -Crelease -D -P

Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
[submodule "third_party/tinygltf"]
path = third_party/tinygltf
url = https://github.com/syoyo/tinygltf
[submodule "third_party/vulkan"]
path = third_party/vulkan
url = https://github.com/KhronosGroup/Vulkan-Docs
[submodule "third_party/glfw"]
path = third_party/glfw
url = https://github.com/glfw/glfw
Expand Down Expand Up @@ -46,3 +43,6 @@
[submodule "third_party/docopt"]
path = third_party/docopt
url = https://github.com/docopt/docopt.cpp
[submodule "third_party/vulkan"]
path = third_party/vulkan
url = https://github.com/KhronosGroup/Vulkan-Headers
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.10)

project(vulkan_best_practice)

Expand Down Expand Up @@ -51,4 +51,4 @@ if(VKB_BUILD_SAMPLES)

# Add vulkan app (runs all samples)
add_subdirectory(vulkan_best_practice)
endif()
endif()
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
- [Build](#build)
- [Supported Platforms](#supported-platforms)
- [Usage](#usage)
- [Testing](#testing)
- [Testing](#tests)
- [License](#license)
- [Trademarks](#trademarks)
- [Contributions](#contributions)
Expand All @@ -54,22 +54,26 @@ The Vulkan Best Practice for Mobile Developers is collection of resources to hel
## Tutorials
- **General**
- [Controls](./docs/controls.md)
- [Controls](./docs/misc.md#controls)
- [Debug window](./docs/misc.md#debug-window)
- [Driver version](./docs/misc.md#driver-version)
- [Create a Sample](./docs/create_sample.md)
- **Vulkan Essentials**
- [How does Vulkan compare to OpenGL ES? What should you expect when targeting Vulkan?](./samples/vulkan_basics.md)
- **Vulkan Swapchains**
More detailed look at swapchains, and how you might want to use them
- [Appropriate use of N-buffering](./samples/advanced/swapchain_images/swapchain_images_tutorial.md)
- [Appropriate use of surface rotation](./samples/advanced/surface_rotation/surface_rotation_tutorial.md)
- **Pipelines**
- [Use of pipeline caches to avoid startup latency](./samples/advanced/pipeline_cache/pipeline_cache_tutorial.md)
- **Descriptors**
- [Descriptor and buffer management](./samples/advanced/descriptor_management/descriptor_management_tutorial.md)
- **Render Passes**
- [Appropriate use of load/store operations, and use of transient attachments](./samples/advanced/render_passes/render_passes_tutorial.md)
- **Render Subpasses**
- [Benefits of subpasses over multiple render passes, use of transient attachments, and G-buffer recommended size](./samples/advanced/render_subpasses/render_subpasses_tutorial.md)
- **Command Buffers**
- [Allocation and management of command buffers](./samples/advanced/command_buffer_usage/command_buffer_usage_tutorial.md)
- [Allocation and management of command buffers](./samples/advanced/command_buffer_usage/command_buffer_usage_tutorial.md#Recycling-strategies)
- [Multi-threaded recording with secondary command buffers](./samples/advanced/command_buffer_usage/command_buffer_usage_tutorial.md#Multi-threaded-recording)
- **AFBC**
- [Appropriate use of AFBC](./samples/advanced/afbc/afbc_tutorial.md)

Expand All @@ -89,11 +93,9 @@ Follow build instructions for your platform below.
### Supported Platforms
- Windows - [Build Guide](./docs/build.md#windows "Windows Build Guide")
- Linux - [Build Guide](./docs/build.md#linux "Linux Build Guide")
- Mac OSX - [Build Guide](./docs/build.md#mac "Mac OSX Build Guide")
- macOS - [Build Guide](./docs/build.md#macos "macOS Build Guide")
- Android - [Build Guide](./docs/build.md#android "Android Build Guide")

> Tested on: Samsung Galaxy S9, Samsung Galaxy S10, Huawei Mate 20 Pro, OPPO R15
## Usage

The following shows some example command line usage on how to configure and run the Vulkan Best Practices.
Expand All @@ -103,7 +105,7 @@ The following shows some example command line usage on how to configure and run
vulkan_best_practice swapchain_images
# Run AFBC sample in benchmark mode for 5000 frames
vulkan_best_practice --sample afbc --benchmark 5000
vulkan_best_practice --sample afbc --benchmark 5000
# Run bonza test offscreen
vulkan_best_practice --test bonza --hide
Expand All @@ -113,9 +115,10 @@ vulkan_best_practice --batch advanced
```


## Testing
## Tests

- System Test - [Usage Guide](docs/testing.md#system-test "System Test Guide")
- Generate Sample - [Usage Guide](docs/testing.md#generate-sample-test "Generate Sample Test Guide")


## License
Expand All @@ -138,6 +141,7 @@ This project has some third-party dependencies, each of which may have independe
- [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross): Parses and converts SPIR-V to other shader languages
- [stb](https://github.com/nothings/stb): Single-file public domain (or MIT licensed) libraries
- [tinygltf](https://github.com/syoyo/tinygltf): Header only C++11 tiny glTF 2.0 library
- [nlohmann json](https://github.com/nlohmann/json): C++ JSON Library (included by [tinygltf](https://github.com/syoyo/tinygltf))
- [vma](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator): Vulkan Memory Allocator
- [volk](https://github.com/zeux/volk): Meta loader for Vulkan API
- [vulkan](https://github.com/KhronosGroup/Vulkan-Docs): Sources for the formal documentation of the Vulkan API
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.4
1.2.0
27 changes: 26 additions & 1 deletion bldsys/cmake/android_package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,29 @@ function(add_android_package_project)
bld.gradle.stamp
${TARGET_DEPENDS})

endfunction()
endfunction()

function(android_sync_folder)
set(options)
set(oneValueArgs PATH)
set(multiValueArgs)

cmake_parse_arguments(PARSE_ARGV 0 TARGET "${options}" "${oneValueArgs}" "${multiValueArgs}")
get_filename_component(FOLDER_NAME "${TARGET_PATH}" NAME)

set(SYNC_COMMAND ${CMAKE_COMMAND}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DFOLDER_DIR=${TARGET_PATH}/.
-DDEVICE_DIR=/sdcard/Android/data/com.arm.${PROJECT_NAME}/files/${FOLDER_NAME}/
-P "${SCRIPT_DIR}/android_sync_folder.cmake")

add_custom_target(
sync.${FOLDER_NAME}.stamp
COMMAND
${SYNC_COMMAND}
COMMENT
"Update ${FOLDER_NAME} in external storage"
VERBATIM)

add_dependencies(${PROJECT_NAME} sync.${FOLDER_NAME}.stamp)
endfunction()
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_MODULE_PATH}/module)
set(ASSETS_DIR ${ASSETS_DIR})
set(FOLDER_DIR ${FOLDER_DIR})
set(DEVICE_DIR ${DEVICE_DIR})

find_package(Adb 1.0.39 REQUIRED)
Expand All @@ -33,24 +33,24 @@ find_package(Adb 1.0.39 REQUIRED)
set(ADB_COMMAND ${ADB_EXECUTABLE} shell mkdir -p ${DEVICE_DIR})

execute_process(
COMMAND
${ADB_COMMAND})
COMMAND
${ADB_COMMAND})

# Sync files

set(ADB_COMMAND ${ADB_EXECUTABLE} push --sync ${ASSETS_DIR} ${DEVICE_DIR})
set(ADB_COMMAND ${ADB_EXECUTABLE} push --sync ${FOLDER_DIR} ${DEVICE_DIR})

execute_process(
COMMAND
${ADB_COMMAND}
RESULT_VARIABLE
ret_var
OUTPUT_VARIABLE
ret_msg
OUTPUT_STRIP_TRAILING_WHITESPACE)
COMMAND
${ADB_COMMAND}
RESULT_VARIABLE
ret_var
OUTPUT_VARIABLE
ret_msg
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT "${ret_var}" STREQUAL "0")
message(WARNING "Could not sync assets to device:\n${ret_msg}")
message(WARNING "Could not sync ${FOLDER_DIR} to device:\n${ret_msg}")
else()
message(STATUS "Updating assets:\n${ret_msg}")
message(STATUS "Updating ${FOLDER_DIR}:\n${ret_msg}")
endif()
2 changes: 1 addition & 1 deletion bldsys/cmake/create_gradle_project.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
]]

cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.10)

set(SCRIPT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(ROOT_DIR ${SCRIPT_DIR}/../..)
Expand Down
2 changes: 1 addition & 1 deletion bldsys/cmake/create_sample_project.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
]]

cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.10)

set(SCRIPT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(ROOT_DIR ${SCRIPT_DIR}/../..)
Expand Down
8 changes: 7 additions & 1 deletion bldsys/cmake/global_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/${CMAKE_BUILD_TYPE}/${TARGET_ARCH}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib/${CMAKE_BUILD_TYPE}/${TARGET_ARCH}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib/${CMAKE_BUILD_TYPE}/${TARGET_ARCH}")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

string(LENGTH "${CMAKE_SOURCE_DIR}/" ROOT_PATH_SIZE)
add_definitions(-DROOT_PATH_SIZE=${ROOT_PATH_SIZE})

set(CMAKE_C_FLAGS_DEBUG "-DDEBUG=0 ${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG=0 ${CMAKE_CXX_FLAGS_DEBUG}")
33 changes: 25 additions & 8 deletions bldsys/cmake/template/entrypoint_main.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

// Generated file by CMake. Don't edit.

#include "common/logging.h"
#include "platform/platform.h"

Expand All @@ -37,27 +38,43 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
vkb::WindowsPlatform platform{hInstance, hPrevInstance,
lpCmdLine, nCmdShow};
#else
# include "platform/linux/linux_platform.h"
# include "platform/unix/unix_platform.h"
int main(int argc, char *argv[])
{
vkb::LinuxPlatform platform{argc, argv};
#if defined(VK_USE_PLATFORM_MACOS_MVK)
vkb::UnixPlatform platform{vkb::UnixType::Mac, argc, argv};
#elif defined(VK_USE_PLATFORM_XCB_KHR)
vkb::UnixPlatform platform{vkb::UnixType::Linux, argc, argv};
#endif
#endif

#ifndef DEBUG
try
{
auto sample = create_@TARGET_CREATE_FUNC@();
sample->set_name("@TARGET_NAME@");
sample->parse_options(platform.get_arguments());
#endif
auto app = create_@TARGET_CREATE_FUNC@();
app->set_name("@TARGET_NAME@");
app->parse_options(platform.get_arguments());

if (platform.initialize(std::move(sample)))
if (platform.initialize(std::move(app)))
{
platform.main_loop();
platform.terminate(vkb::ExitCode::Success);
}
else
{
platform.terminate(vkb::ExitCode::UnableToRun);
}
platform.terminate(vkb::ExitCode::Success);
#ifndef DEBUG
}
catch (const std::exception &e)
{
LOGE(e.what());
platform.terminate(vkb::ExitCode::Fatal);
platform.terminate(vkb::ExitCode::FatalError);
}
#endif

#ifndef VK_USE_PLATFORM_ANDROID_KHR
return EXIT_SUCCESS;
#endif
}
28 changes: 16 additions & 12 deletions bldsys/cmake/template/sample/sample.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@

#include "@[email protected]"

#include "common/vk_common.h"
#include "gltf_loader.h"
#include "gui.h"
#include "platform/filesystem.h"
#include "platform/platform.h"
#include "rendering/subpasses/scene_subpass.h"
#include "stats.h"

#if defined(VK_USE_PLATFORM_ANDROID_KHR)
# include "platform/android/android_platform.h"
#endif

@SAMPLE_NAME@::@SAMPLE_NAME@()
{
}
Expand All @@ -30,14 +42,6 @@ bool @SAMPLE_NAME@::prepare(vkb::Platform &platform)
{
return false;
}

std::vector<const char *> extensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};

device = std::make_unique<vkb::Device>(get_gpu(), get_surface(), extensions);

auto swapchain = std::make_unique<vkb::Swapchain>(*device, get_surface());

render_context = std::make_unique<vkb::RenderContext>(std::move(swapchain));

// Load a scene from the assets folder
load_scene("scenes/sponza/Sponza01.gltf");
Expand All @@ -47,16 +51,16 @@ bool @SAMPLE_NAME@::prepare(vkb::Platform &platform)
auto camera = &camera_node.get_component<vkb::sg::Camera>();

// Example Scene Render Pipeline
vkb::ShaderSource vert_shader(vkb::file::read_asset("shaders/base.vert"));
vkb::ShaderSource frag_shader(vkb::file::read_asset("shaders/base.frag"));
auto scene_subpass = std::make_unique<vkb::SceneSubpass>(*render_context, std::move(vert_shader), std::move(frag_shader), *scene, *camera);
vkb::ShaderSource vert_shader(vkb::fs::read_shader("base.vert"));
vkb::ShaderSource frag_shader(vkb::fs::read_shader("base.frag"));
auto scene_subpass = std::make_unique<vkb::SceneSubpass>(get_render_context(), std::move(vert_shader), std::move(frag_shader), *scene, *camera);
auto render_pipeline = vkb::RenderPipeline();
render_pipeline.add_subpass(std::move(scene_subpass));
set_render_pipeline(std::move(render_pipeline));

// Add a GUI with the stats you want to monitor
stats = std::make_unique<vkb::Stats>(std::set<vkb::StatIndex>{vkb::StatIndex::frame_times});
gui = std::make_unique<vkb::Gui>(*render_context, platform.get_dpi_factor());
gui = std::make_unique<vkb::Gui>(*this, platform.get_dpi_factor());

return true;
}
Expand Down
Loading

0 comments on commit dae28a6

Please sign in to comment.