├── .clang-format ├── .dummy-root ├── .dummy.cpp ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── Sample.cmake ├── VERSION.txt ├── build_documentation.sh ├── doxygen ├── Doxyfile ├── building_the_samples.dox ├── footer.html ├── getting_started_guide.dox ├── header.html ├── images │ ├── astc.png │ ├── basic_compute.png │ ├── hello_triangle.png │ ├── mipmapping_auto_generated.gif │ ├── mipmapping_manually_generated.gif │ ├── multipass_final.png │ ├── multipass_gbuffer.png │ ├── multisampling.png │ ├── multithreading.png │ ├── rotating_texture.png │ ├── spinning_cube.png │ └── vulkan.png ├── main_page.dox ├── stylesheet.css ├── top_banner.bmp ├── tutorials.dox └── tutorials │ ├── astc.dox │ ├── basic_compute.dox │ ├── creating_vulkan_window.dox │ ├── hellotriangle.dox │ ├── introduction.dox │ ├── mipmapping.dox │ ├── multipass.dox │ ├── multisampling.dox │ ├── multithreading.dox │ ├── rotating_texture.dox │ ├── spinning_cube.dox │ └── validation_layers.dox ├── format_all.sh ├── framework ├── CMakeLists.txt ├── application.hpp ├── assets.cpp ├── assets.hpp ├── command_buffer_manager.cpp ├── command_buffer_manager.hpp ├── common.hpp ├── context.cpp ├── context.hpp ├── fence_manager.cpp ├── fence_manager.hpp ├── math.hpp ├── semaphore_manager.cpp ├── semaphore_manager.hpp ├── thread_pool.cpp └── thread_pool.hpp ├── include └── vulkan │ ├── vk_platform.h │ └── vulkan.h ├── platform ├── CMakeLists.txt ├── android │ ├── CMakeLists.txt │ ├── android.cpp │ ├── android.hpp │ ├── android_assets.cpp │ └── android_assets.hpp ├── asset_manager.cpp ├── asset_manager.hpp ├── display │ ├── CMakeLists.txt │ ├── display.cpp │ └── display.hpp ├── os.hpp ├── os │ ├── linux.cpp │ ├── linux.hpp │ ├── windows.cpp │ └── windows.hpp ├── platform.hpp ├── png │ ├── CMakeLists.txt │ ├── png.cpp │ ├── png.hpp │ ├── png_swapchain.cpp │ └── png_swapchain.hpp ├── read_write_lock.hpp ├── wayland │ ├── CMakeLists.txt │ ├── wayland.cpp │ └── wayland.hpp ├── wsi │ ├── wsi.cpp │ └── wsi.hpp └── xcb │ ├── CMakeLists.txt │ ├── xcb.cpp │ └── xcb.hpp ├── samples ├── CMakeLists.txt ├── astc │ ├── CMakeLists.txt │ ├── app │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── assets │ │ └── textures │ │ │ ├── icon-astc-12x12.astc │ │ │ ├── icon-astc-12x12.png │ │ │ ├── icon-astc-4x4.astc │ │ │ ├── icon-astc-4x4.png │ │ │ ├── icon-astc-6x6.astc │ │ │ ├── icon-astc-6x6.png │ │ │ ├── icon-astc-8x8.astc │ │ │ ├── icon-astc-8x8.png │ │ │ ├── icon-fallback.png │ │ │ └── icon.png │ ├── astc.cpp │ ├── build.gradle │ ├── settings.gradle │ └── shaders │ │ ├── textured.frag │ │ └── textured.vert ├── basic_compute │ ├── CMakeLists.txt │ ├── app │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── assets │ │ └── textures │ │ │ └── icon.png │ ├── basic_compute.cpp │ ├── build.gradle │ ├── settings.gradle │ └── shaders │ │ ├── particle.comp │ │ ├── particle.frag │ │ └── particle.vert ├── hellotriangle │ ├── CMakeLists.txt │ ├── app │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── build.gradle │ ├── hellotriangle.cpp │ ├── settings.gradle │ └── shaders │ │ ├── triangle.frag │ │ └── triangle.vert ├── mipmapping │ ├── CMakeLists.txt │ ├── app │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── assets │ │ └── textures │ │ │ ├── T_Pedestal_512.png │ │ │ ├── T_Speaker_1.png │ │ │ ├── T_Speaker_128.png │ │ │ ├── T_Speaker_16.png │ │ │ ├── T_Speaker_2.png │ │ │ ├── T_Speaker_256.png │ │ │ ├── T_Speaker_32.png │ │ │ ├── T_Speaker_4.png │ │ │ ├── T_Speaker_512.png │ │ │ ├── T_Speaker_64.png │ │ │ ├── T_Speaker_8.png │ │ │ └── labels.png │ ├── build.gradle │ ├── mipmapping.cpp │ ├── settings.gradle │ └── shaders │ │ ├── textured.frag │ │ └── textured.vert ├── multipass │ ├── CMakeLists.txt │ ├── app │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── assets │ │ └── textures │ │ │ └── texture.png │ ├── build.gradle │ ├── multipass.cpp │ ├── settings.gradle │ └── shaders │ │ ├── debug.frag │ │ ├── debug.vert │ │ ├── geometry.frag │ │ ├── geometry.vert │ │ ├── light.frag │ │ └── light.vert ├── multisampling │ ├── CMakeLists.txt │ ├── app │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── assets │ │ └── textures │ │ │ └── icon.png │ ├── build.gradle │ ├── multisampling.cpp │ ├── settings.gradle │ └── shaders │ │ ├── textured.frag │ │ └── textured.vert ├── multithreading │ ├── CMakeLists.txt │ ├── app │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── assets │ │ └── textures │ │ │ └── icon.png │ ├── build.gradle │ ├── multithreading.cpp │ ├── settings.gradle │ └── shaders │ │ ├── textured.frag │ │ └── textured.vert ├── rotating_texture │ ├── CMakeLists.txt │ ├── app │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── strings.xml │ ├── assets │ │ └── textures │ │ │ └── icon.png │ ├── build.gradle │ ├── rotating_texture.cpp │ ├── settings.gradle │ └── shaders │ │ ├── textured.frag │ │ └── textured.vert └── spinning_cube │ ├── CMakeLists.txt │ ├── app │ ├── AndroidManifest.xml │ ├── build.gradle │ └── res │ │ ├── drawable-hdpi │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ │ ├── drawable-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── strings.xml │ ├── assets │ └── textures │ │ └── icon.png │ ├── build.gradle │ ├── settings.gradle │ ├── shaders │ ├── textured.frag │ └── textured.vert │ └── spinning_cube.cpp ├── stub ├── CMakeLists.txt ├── libvulkan-stub.cpp └── libvulkan-stub.h └── toolchains └── armhf.cmake /.dummy-root: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/.dummy-root -------------------------------------------------------------------------------- /.dummy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/.dummy.cpp -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.so 3 | *.d 4 | *.o 5 | *swp 6 | /test 7 | libs 8 | build 9 | gen 10 | bin 11 | .gradle 12 | .idea 13 | *.iml 14 | *.apk 15 | /*.png 16 | .externalNativeBuild 17 | local.properties 18 | gradlew 19 | gradlew.bat 20 | gradle 21 | /samples/*/app/assets 22 | /samples/hellotriangle/hellotriangle 23 | /samples/rotating_texture/rotating_texture 24 | /samples/basic_compute/basic_compute 25 | /samples/multithreading/multithreading 26 | /samples/multisampling/multisampling 27 | /samples/spinning_cube/spinning_cube 28 | /samples/mipmapping/mipmapping 29 | /docs 30 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "framework/glm"] 2 | path = framework/glm 3 | url = https://github.com/g-truc/glm.git 4 | [submodule "framework/stb"] 5 | path = framework/stb 6 | url = https://github.com/nothings/stb.git 7 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if(TOOLCHAIN_PREFIX) 4 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) 5 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) 6 | endif(TOOLCHAIN_PREFIX) 7 | 8 | if(NOT CMAKE_BUILD_TYPE) 9 | set(CMAKE_BUILD_TYPE RelWithDebInfo) 10 | endif(NOT CMAKE_BUILD_TYPE) 11 | 12 | set(CMAKE_CXX_STANDARD 11) 13 | 14 | project(vulkan-sdk VERSION 1.0 LANGUAGES CXX C) 15 | 16 | if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")) 17 | message("Compiler is GNU compatible.") 18 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-function -Wno-unused-variable -DVK_PROTOTYPES=1 -pthread") 19 | elseif(MSVC) 20 | message("Compiler is MSVC.") 21 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /wd4267 /wd4244 /wd4146") 22 | endif() 23 | 24 | if(NOT PLATFORM) 25 | set(PLATFORM png) 26 | endif(NOT PLATFORM) 27 | 28 | add_subdirectory(framework) 29 | add_subdirectory(platform) 30 | add_subdirectory(stub) 31 | 32 | set(sources-os) 33 | if (UNIX AND (NOT ANDROID)) 34 | set(sources-os platform/os/linux.cpp platform/os/linux.hpp) 35 | elseif(WIN32) 36 | set(sources-os platform/os/windows.cpp platform/os/windows.hpp) 37 | endif(UNIX AND (NOT ANDROID)) 38 | 39 | add_library(vulkan-sdk STATIC .dummy.cpp ${sources-os}) 40 | target_link_libraries(vulkan-sdk platform) 41 | 42 | if (UNIX) 43 | target_link_libraries(vulkan-sdk -ldl -pthread) 44 | endif(UNIX) 45 | 46 | include(Sample.cmake) 47 | enable_testing() 48 | add_subdirectory(samples) 49 | 50 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2017, ARM Limited and Contributors 2 | 3 | SPDX-License-Identifier: MIT 4 | 5 | Permission is hereby granted, free of charge, 6 | to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /Sample.cmake: -------------------------------------------------------------------------------- 1 | function(add_shader TARGET SHADER) 2 | 3 | # Find glslc shader compiler. 4 | # On Android, the NDK includes the binary, so no external dependency. 5 | if(ANDROID) 6 | file(GLOB glslc-folders ${ANDROID_NDK}/shader-tools/*) 7 | find_program(GLSLC glslc HINTS ${glslc-folders}) 8 | else() 9 | find_program(GLSLC glslc) 10 | endif() 11 | 12 | # All shaders for a sample are found here. 13 | set(current-shader-path ${CMAKE_CURRENT_SOURCE_DIR}/shaders/${SHADER}) 14 | 15 | # For Android, write SPIR-V files to app/assets which is then packaged into the APK. 16 | # Otherwise, output in the binary directory. 17 | if(ANDROID) 18 | set(current-output-path ${CMAKE_CURRENT_SOURCE_DIR}/app/assets/shaders/${SHADER}.spv) 19 | else(ANDROID) 20 | set(current-output-path ${CMAKE_BINARY_DIR}/samples/${TARGET}/assets/shaders/${SHADER}.spv) 21 | endif(ANDROID) 22 | 23 | # Add a custom command to compile GLSL to SPIR-V. 24 | get_filename_component(current-output-dir ${current-output-path} DIRECTORY) 25 | file(MAKE_DIRECTORY ${current-output-dir}) 26 | add_custom_command( 27 | OUTPUT ${current-output-path} 28 | COMMAND ${GLSLC} -o ${current-output-path} ${current-shader-path} 29 | DEPENDS ${current-shader-path} 30 | IMPLICIT_DEPENDS CXX ${current-shader-path} 31 | VERBATIM) 32 | 33 | # Make sure our native build depends on this output. 34 | set_source_files_properties(${current-output-path} PROPERTIES GENERATED TRUE) 35 | target_sources(${TARGET} PRIVATE ${current-output-path}) 36 | endfunction(add_shader) 37 | 38 | function(add_sample_inner TARGET SOURCES) 39 | # For Android, always emit libnative.so since we only build one sample per APK. 40 | # Otherwise, we want to control our output folder so we can pick up assets without any problems. 41 | if(ANDROID) 42 | add_library(${TARGET} SHARED ${SOURCES}) 43 | target_link_libraries(${TARGET} vulkan-sdk) 44 | set_target_properties(${TARGET} PROPERTIES LIBRARY_OUTPUT_NAME native) 45 | else(ANDROID) 46 | add_executable(${TARGET} ${SOURCES}) 47 | target_link_libraries(${TARGET} vulkan-sdk) 48 | set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/samples/${TARGET}") 49 | endif(ANDROID) 50 | 51 | # Find all shaders. 52 | file(GLOB vertex-shaders ${CMAKE_CURRENT_SOURCE_DIR}/shaders/*.vert) 53 | file(GLOB fragment-shaders ${CMAKE_CURRENT_SOURCE_DIR}/shaders/*.frag) 54 | file(GLOB compute-shaders ${CMAKE_CURRENT_SOURCE_DIR}/shaders/*.comp) 55 | 56 | # Add them to the build. 57 | foreach(vertex-shader ${vertex-shaders}) 58 | get_filename_component(p ${vertex-shader} NAME) 59 | add_shader(${TARGET} ${p}) 60 | endforeach(vertex-shader) 61 | 62 | foreach(fragment-shader ${fragment-shaders}) 63 | get_filename_component(p ${fragment-shader} NAME) 64 | add_shader(${TARGET} ${p}) 65 | endforeach(fragment-shader) 66 | 67 | foreach(compute-shader ${compute-shaders}) 68 | get_filename_component(p ${compute-shader} NAME) 69 | add_shader(${TARGET} ${p}) 70 | endforeach(compute-shader) 71 | 72 | if(ANDROID) 73 | set(output-assets ${CMAKE_CURRENT_SOURCE_DIR}/app/assets) 74 | else(ANDROID) 75 | set(output-assets ${CMAKE_BINARY_DIR}/samples/${TARGET}/assets) 76 | endif(ANDROID) 77 | 78 | # Copy assets from sample to the appropriate location. 79 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/assets/textures) 80 | file(MAKE_DIRECTORY ${output-assets}) 81 | add_custom_command(TARGET ${TARGET} POST_BUILD 82 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets/textures ${output-assets}/textures) 83 | endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/assets/textures) 84 | 85 | # Make a test out of every sample if not on Android. 86 | if(NOT ANDROID) 87 | add_test(NAME ${TARGET} COMMAND $ 200) 88 | endif(NOT ANDROID) 89 | endfunction(add_sample_inner) 90 | 91 | function(add_sample TARGET SOURCES) 92 | # If FILTER_TARGET is used, we only build a particular sample, this is used for Android. 93 | if (FILTER_TARGET) 94 | if (${FILTER_TARGET} STREQUAL ${TARGET}) 95 | add_sample_inner(${TARGET} "${SOURCES}") 96 | endif(${FILTER_TARGET} STREQUAL ${TARGET}) 97 | else(FILTER_TARGET) 98 | add_sample_inner(${TARGET} "${SOURCES}") 99 | endif(FILTER_TARGET) 100 | endfunction(add_sample) 101 | -------------------------------------------------------------------------------- /VERSION.txt: -------------------------------------------------------------------------------- 1 | 1.1.1 -------------------------------------------------------------------------------- /build_documentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSTRING=`cat VERSION.txt` 4 | VERSION=$VERSTRING 5 | export VERSION 6 | echo $VERSION 7 | 8 | cd doxygen 9 | exec doxygen 10 | -------------------------------------------------------------------------------- /doxygen/building_the_samples.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \page buildingTheSamples Building The Samples 3 | \brief Shows how to build the Vulkan samples included in the Vulkan SDK for Android. 4 | 5 | It is assumed that you have set up Android Studio and NDK appropriately as mentioned in the \ref gettingStartedGuide. 6 | 7 | \section buildingSamplesAndroidStudio Building samples in Android Studio 8 | 9 | Make sure you have checked out submodules before building. 10 | 11 | \code 12 | git submodule init 13 | git submodule update 14 | \endcode 15 | 16 | -# Open Android Studio 2.2 or newer 17 | -# Open an existing Android Studio project 18 | -# Import a sample project, for example samples/hellotriangle 19 | -# You might be prompted to update or install the Gradle wrapper. Do so if asked. 20 | -# You might be prompted to download and/or update Android SDK tools if Android Studio has not downloaded these before 21 | -# Under Tools -> Android -> SDK manager, install cmake, lldb and NDK components. 22 | -# In the top menu, run Build -> Make Project 23 | -# In the bottom of the screen, the Messages tab should display a build log which shows that libnative.so has been built and that build was successful 24 | -# Run the app on the device by pressing the Play button on the top toolbar 25 | -# To debug the code, Run -> Debug app. In the project view, you will find app/cpp/native/hellotriangle.cpp or similar. You can set breakpoints and step through the code. 26 | 27 | \section buildingSamplesEmbedded Building samples for ARM Linux and Linux desktop 28 | 29 | It is possible to build samples to run on ARM Linux or Linux desktop. 30 | shaderc (binary name: glslc) must be installed on your system to build shaders to SPIR-V. 31 | 32 | \code 33 | git submodule init 34 | git submodule update 35 | 36 | mkdir build 37 | cd build 38 | 39 | # For desktop Linux 40 | cmake .. -DPLATFORM=xcb -DTESTS:BOOL=ON 41 | # For ARMv7 hardfloat Linux 42 | cmake .. -DPLATFORM=display -DTESTS:BOOL=ON -DCMAKE_TOOLCHAIN_FILE=../toolchains/armhf.cmake 43 | # Other platforms include wayland, xcb, png (default). 44 | 45 | make -j8 46 | ctest # Runs all samples for a few seconds. 47 | \endcode 48 | 49 | */ 50 | -------------------------------------------------------------------------------- /doxygen/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /doxygen/getting_started_guide.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \page gettingStartedGuide Getting Started Guide 3 | \brief Everything you need to know to go from scratch to building Android Vulkan applications. 4 | 5 | \section gettingStartedGuideIntroduction Introduction 6 | 7 | This guide helps you get up and running with developing for your Mali GPU 8 | based platform running Android. It helps you to download and configure the 9 | tools so you can begin to develop apps for your platform. 10 | It is assumed you are either running Linux or Windows as your host platform. 11 | 12 | \section gettingStartedGuideGettingAppropriateTools Getting the Appropriate Tools 13 | 14 | You require a few tools for Android Development. Most of these are in one place. 15 | Download Android Studio here and install it. 16 | Once you have installed the Android Studio, install CMake, LLDB and the NDK from the SDK manager. 17 | 18 | \section connecting Connecting your Device 19 | 20 | Connect your device to your host machine. Make sure to enable USB debugging on the device so that you can push built APKs onto the device. To verify that you have the proper access to a device, you can use adb to verify this. 21 | 22 | \code 23 | $ adb devices 24 | XXXXXXXXXXXXXXX device 25 | \endcode 26 | 27 | If you are having problems with ADB, please consult this page. 28 | 29 | \section gettingStartedGuideBuildingAProject Building and Running Your Application 30 | 31 | To build a sample, see \ref buildingTheSamples. 32 | 33 | */ 34 | -------------------------------------------------------------------------------- /doxygen/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $projectname: $title 7 | $title 8 | 9 | 18 | 19 | 20 | $treeview 21 | $search 22 | $mathjax 23 | 24 | $extrastylesheet 25 | 26 | 27 |
28 | 29 | 30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |
39 |
$projectname 40 |  $projectnumber 41 | ARM Developer Center 42 |
43 |
$projectbrief
44 |
49 |
$projectbrief
50 |
$searchbox
61 |
62 | 63 | 64 | -------------------------------------------------------------------------------- /doxygen/images/astc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/astc.png -------------------------------------------------------------------------------- /doxygen/images/basic_compute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/basic_compute.png -------------------------------------------------------------------------------- /doxygen/images/hello_triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/hello_triangle.png -------------------------------------------------------------------------------- /doxygen/images/mipmapping_auto_generated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/mipmapping_auto_generated.gif -------------------------------------------------------------------------------- /doxygen/images/mipmapping_manually_generated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/mipmapping_manually_generated.gif -------------------------------------------------------------------------------- /doxygen/images/multipass_final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/multipass_final.png -------------------------------------------------------------------------------- /doxygen/images/multipass_gbuffer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/multipass_gbuffer.png -------------------------------------------------------------------------------- /doxygen/images/multisampling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/multisampling.png -------------------------------------------------------------------------------- /doxygen/images/multithreading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/multithreading.png -------------------------------------------------------------------------------- /doxygen/images/rotating_texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/rotating_texture.png -------------------------------------------------------------------------------- /doxygen/images/spinning_cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/spinning_cube.png -------------------------------------------------------------------------------- /doxygen/images/vulkan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/images/vulkan.png -------------------------------------------------------------------------------- /doxygen/main_page.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \mainpage 3 | Welcome to Vulkan SDK for Android $(VERSION). 4 | 5 | \section about About 6 | 7 | The Vulkan SDK is a collection of resources to help you build Vulkan applications 8 | for a platform with a Mali GPU and an ARM processor. You can use it for creating new applications, 9 | training, and exploration of implementation possibilities. 10 | 11 | You can use the Mali SDK to produce applications that will run on any devices that run Android and Vulkan on an ARM processor. 12 | 13 | \section requirements Requirements 14 | To build and run the Vulkan sample applications you will need: 15 | - An ARM based device with a Mali GPU running Android which supports Vulkan. 16 | - The latest Android Studio. 17 | 18 | \section gettingStarted Getting Started 19 | - See the \ref gettingStartedGuide for information on how to get started. 20 | - Have a look at some \ref tutorials. 21 | - Look at \ref buildingTheSamples for how to build the samples. 22 | 23 | \section changeLog Change Log 24 | Summary of changes between versions of the Vulkan SDK. 25 | 26 | \subsection v111 Changes in version 1.1.1 27 | - Added Mipmapping sample 28 | 29 | \subsection v110 Changes in version 1.1.0 30 | - Added Multipass sample 31 | - Added ASTC sample 32 | - Added validation layer integration 33 | - Added backend for VK_KHR_display 34 | - Added backend for VK_KHR_xcb_surface 35 | - Rewrote build system for Android Studio 2.2+ and CMake 36 | - Various improvements to existing samples 37 | - Changed license to MIT 38 | 39 | \subsection v100 Changes in version 1.0.0 40 | - First release of the Vulkan SDK. 41 | 42 | \section contents Contents 43 | Directory | Contents 44 | ------------- | ------------- 45 | docs | Documentation for the SDK including tutorials. 46 | samples | Sample Vulkan applications. 47 | framework | Simple framework used by samples. 48 | platform | Platform specific implementations. 49 | */ 50 | -------------------------------------------------------------------------------- /doxygen/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Changes to tabs.css */ 2 | 3 | .tabs, .tabs2, .tabs3 { 4 | /* box-shadow: 0px 5px 30px rgba(0, 0, 0, 0.3); */ 5 | position: relative; 6 | } 7 | 8 | .tablist li { 9 | line-height: 32px; 10 | } 11 | 12 | .tablist a { 13 | color: #FFFFFF; 14 | text-shadow: none; 15 | } 16 | 17 | .tablist a:hover { 18 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 19 | text-decoration: none; 20 | background-repeat: no-repeat; 21 | background-image: url('tab_s.png');; 22 | } 23 | 24 | .tablist li.current a { 25 | text-shadow: none; 26 | } 27 | 28 | /* Changes to navtree.css */ 29 | 30 | #nav-tree .selected { 31 | background-image: url('tab_a_nav.png'); 32 | border-radius: 15px; 33 | text-shadow: none; 34 | } 35 | 36 | #nav-tree .label a { 37 | color: #444444; 38 | } 39 | 40 | #nav-tree .selected a { 41 | color: #f68a33; 42 | } 43 | 44 | #nav-tree { 45 | background-color: #EEE; 46 | } 47 | 48 | #doc-content { 49 | background-color: #EEE; 50 | } 51 | 52 | .ui-resizable-e { 53 | background: none; 54 | background-color : lightgray; 55 | width:4px; 56 | } 57 | 58 | #nav-tree { 59 | background-image: none; 60 | background-color: #EEE; 61 | } 62 | 63 | 64 | /* Changes to doxygen.css */ 65 | 66 | h2.groupheader { 67 | border-bottom: 1px solid #979797; 68 | color: #4C4C4C; 69 | } 70 | 71 | h1, h2, h3, h4, h5, h6 { 72 | font-weight : normal; 73 | } 74 | 75 | h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { 76 | text-shadow: 0 0 15px orange; 77 | } 78 | 79 | div.qindex, div.navtab{ 80 | background-color: #EBEBEB; 81 | border: 1px solid #B4B4B4; 82 | } 83 | 84 | div.qindex, div.navpath { 85 | /* box-shadow: 0px -5px 30px rgba(0, 0, 0, 0.3); */ 86 | position : relative; 87 | } 88 | 89 | a { 90 | color: #444444; 91 | } 92 | 93 | .contents a:visited { 94 | color: #666666; 95 | } 96 | 97 | a.qindexHL { 98 | background-color: #AFAFAf; 99 | border: 1px double #9D9D9D; 100 | } 101 | 102 | a.code, a.code:visited { 103 | color: #444444; 104 | } 105 | 106 | a.codeRef, a.codeRef:visited { 107 | color: #444444; 108 | } 109 | 110 | div.fragment { 111 | background-color: #FCFCFC; 112 | border: 1px solid #CFCFCF; 113 | } 114 | 115 | div.line.glow { 116 | background-color: orange; 117 | /* box-shadow: 0 0 10px orange; */ 118 | } 119 | 120 | body { 121 | background-color: #EEE; 122 | } 123 | 124 | .memberdecls td.glow, .fieldtable tr.glow { 125 | background-color: orange; 126 | /* box-shadow: 0 0 15px orange; */ 127 | } 128 | 129 | .memitem.glow { 130 | /* box-shadow: 0 0 15px orange; */ 131 | } 132 | 133 | .memproto, dl.reflist dt { 134 | border-top: 1px solid #B8B8B8; 135 | border-left: 1px solid #B8B8B8; 136 | border-right: 1px solid #B8B8B8; 137 | color: #333333; 138 | background-color: #E2E2E2; 139 | } 140 | 141 | .memdoc, dl.reflist dd { 142 | border-bottom: 1px solid #B8B8B8; 143 | border-left: 1px solid #B8B8B8; 144 | border-right: 1px solid #B8B8B8; 145 | background-color: #FCFCFC; 146 | } 147 | 148 | table.doxtable td, table.doxtable th { 149 | border: 1px solid #2D2D2D; 150 | } 151 | 152 | table.doxtable th { 153 | background-color: #373737; 154 | } 155 | 156 | .navpath li.navelem a 157 | { 158 | color: white; 159 | text-shadow: none; 160 | } 161 | 162 | .navpath li.navelem a:hover 163 | { 164 | color:white; 165 | text-shadow : 0px 1px 1px rgba(0, 0, 0, 1.0); 166 | } 167 | 168 | dl.note 169 | { 170 | border-color: #f68a33; 171 | } 172 | 173 | #projectlogo 174 | { 175 | width:150px; 176 | text-align:left; 177 | } 178 | 179 | #projectname 180 | { 181 | font: 200% Tahoma, Arial,sans-serif; 182 | color : #676767; 183 | overflow:hidden; 184 | } 185 | 186 | #projectname #armdevcenter 187 | { 188 | float:right; 189 | padding-right: 20px; 190 | } 191 | 192 | #eula 193 | { 194 | font-size: 80%; 195 | font-weight: bold; 196 | } 197 | 198 | #titlearea 199 | { 200 | background-color : white; 201 | border-top: 5px solid #f68a33; 202 | border-bottom: none; 203 | /* box-shadow : 0px 5px 30px rgba(0, 0, 0, 0.3); */ 204 | } 205 | 206 | a.copyright { 207 | color: #FFFFFF; 208 | } 209 | 210 | a.copyright:hover { 211 | color: #FFFFFF; 212 | } 213 | 214 | a.copyright:visited { 215 | color: #FFFFFF; 216 | } 217 | -------------------------------------------------------------------------------- /doxygen/top_banner.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/doxygen/top_banner.bmp -------------------------------------------------------------------------------- /doxygen/tutorials.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \page tutorials Tutorials 3 | \brief Tutorials on how to get the best out of Vulkan on Mali GPUs. 4 | 5 | \note 6 | Finished versions of all of the tutorials listed are included in the SDK. 7 | See \ref buildingTheSamples for instructions on how to use them. 8 | 9 | Tutorials 10 | --------------- 11 | These tutorials introduce the basics of a Vulkan application. 12 | The source for these samples can be found in the *samples* 13 | folder of the SDK. 14 | 15 | -# \subpage vulkanIntro 16 | 17 | \copybrief vulkanIntro 18 | -# \subpage creatingVulkanWindow 19 | 20 | \copybrief creatingVulkanWindow 21 | -# \subpage validationLayer 22 | 23 | \copybrief validationLayer 24 | -# \subpage helloTriangle 25 | 26 | \copybrief helloTriangle 27 | -# \subpage rotatingTexture 28 | 29 | \copybrief rotatingTexture 30 | -# \subpage multithreading 31 | 32 | \copybrief multithreading 33 | -# \subpage basicCompute 34 | 35 | \copybrief basicCompute 36 | -# \subpage multisampling 37 | 38 | \copybrief multisampling 39 | -# \subpage spinning_cube 40 | 41 | \copybrief spinning_cube 42 | -# \subpage multipass 43 | 44 | \copybrief multipass 45 | -# \subpage astc 46 | 47 | \copybrief astc 48 | -# \subpage mipmapping 49 | 50 | \copybrief mipmapping 51 | */ 52 | -------------------------------------------------------------------------------- /format_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for file in framework/*.{cpp,hpp} framework/device/*.{cpp,hpp} platform/*.{hpp,cpp} platform/*/*.{hpp,cpp} samples/*/*.cpp 4 | do 5 | echo "Formatting file: $file ..." 6 | clang-format -style=file -i $file 7 | done 8 | -------------------------------------------------------------------------------- /framework/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | file(GLOB sources-headers *.hpp) 3 | file(GLOB device-sources device/*.cpp) 4 | file(GLOB device-sources-headers device/*.hpp) 5 | add_library(framework STATIC 6 | ${sources} 7 | ${sources-headers} 8 | ${device-sources} 9 | ${device-sources-headers}) 10 | 11 | if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/glm/glm/glm.hpp) 12 | message(FATAL_ERROR "GLM submodule has not been checked out in framework/glm, please run git submodule init and git submodule update first.") 13 | endif() 14 | if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/stb/stb_image.h) 15 | message(FATAL_ERROR "STB submodule has not been checked out in framework/stb, please run git submodule init and git submodule update first.") 16 | endif() 17 | 18 | target_include_directories(framework PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/glm PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) 19 | target_link_libraries(framework vulkan-stub) 20 | 21 | -------------------------------------------------------------------------------- /framework/application.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef FRAMEWORK_APPLICATION_HPP 22 | #define FRAMEWORK_APPLICATION_HPP 23 | 24 | #include "platform/platform.hpp" 25 | 26 | namespace MaliSDK 27 | { 28 | class Context; 29 | 30 | /// @brief VulkanApplication is inherited by all samples. 31 | /// The common platform code will run the main loop and take care of application 32 | /// lifecycle. 33 | class VulkanApplication 34 | { 35 | public: 36 | /// @brief Destructor 37 | virtual ~VulkanApplication() = default; 38 | 39 | /// @brief This function is called when the context is brought up and is 40 | /// the constructor of this class. 41 | /// 42 | /// @param pContext The Vulkan context 43 | /// @returns true if initialization succeeded. If initialization fails, the 44 | /// application will terminate. 45 | virtual bool initialize(Context *pContext) = 0; 46 | 47 | /// @brief Called when the swapchain has been initialized. 48 | /// 49 | /// updateSwapchain is always called after the first initialize. 50 | /// 51 | /// If the swapchain for some reason is lost or recreated, 52 | /// this can be called several times during the lifetime of the application. 53 | /// 54 | /// @param backbuffers A vector containing all the backbuffers in the current 55 | /// swapchain 56 | /// @param dimensions The dimensions of the swapchain, along with the VkFormat 57 | /// needed to create render passes 58 | virtual void updateSwapchain(const std::vector &backbuffers, 59 | const Platform::SwapchainDimensions &dimensions) = 0; 60 | 61 | /// @brief Render a frame 62 | /// 63 | /// @param swapchainIndex The swapchain index to render into, previously 64 | /// obtained by backbuffers 65 | /// parameter in updateSwapchain. 66 | /// @param deltaTime The time in seconds since last call to render. 67 | virtual void render(unsigned swapchainIndex, float deltaTime) = 0; 68 | 69 | /// @brief Destructor for the class. 70 | /// 71 | /// After this call returns, initialize can be called again. 72 | virtual void terminate() = 0; 73 | }; 74 | 75 | /// @brief Creates a new application instance 76 | /// 77 | /// This function must be implemented by all samples. 78 | /// The function is called from the common platform code. 79 | /// Each sample will live in its own binary, so there is no need to consider 80 | /// symbol clashing. 81 | /// \code 82 | /// VulkanApplication *MaliSDK::createApplication() 83 | /// { 84 | /// return new MyApplication; 85 | /// } 86 | /// \endcode 87 | VulkanApplication *createApplication(); 88 | } 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /framework/assets.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef FRAMEWORK_ASSETS_HPP 22 | #define FRAMEWORK_ASSETS_HPP 23 | 24 | #include "common.hpp" 25 | #include "libvulkan-stub.h" 26 | #include 27 | #include 28 | 29 | namespace MaliSDK 30 | { 31 | /// @brief Loads a SPIR-V shader module from assets. 32 | /// @param device The Vulkan device. 33 | /// @param path Path to the SPIR-V shader. 34 | /// @returns A newly allocated shader module or VK_NULL_HANDLE on error. 35 | VkShaderModule loadShaderModule(VkDevice device, const char *pPath); 36 | 37 | /// @brief Loads texture data from assets. 38 | /// 39 | /// @param pPath Path to texture. 40 | /// @param[out] pBuffer Output buffer where VK_FORMAT_R8G8B8A8_UNORM is placed. 41 | /// @param[out] pWidth Width of the loaded texture. 42 | /// @param[out] pHeight Height of the loaded texture. 43 | /// 44 | /// @returns Error code. 45 | Result loadRgba8888TextureFromAsset(const char *pPath, std::vector *pBuffer, unsigned *pWidth, 46 | unsigned *pHeight); 47 | 48 | /// @brief Loads an ASTC texture from assets. 49 | /// 50 | /// Loads files created by astcenc tool. 51 | /// 52 | /// @param pPath Path to texture. 53 | /// @param[out] pBuffer Output buffer where an ASTC payload is placed. 54 | /// @param[out] pWidth Width of the loaded texture. 55 | /// @param[out] pHeight Height of the loaded texture. 56 | /// @param[out] pFormat The format of the loaded texture. 57 | Result loadASTCTextureFromAsset(const char *pPath, std::vector *pBuffer, unsigned *pWidth, unsigned *pHeight, 58 | VkFormat *pFormat); 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /framework/command_buffer_manager.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #include "command_buffer_manager.hpp" 22 | 23 | namespace MaliSDK 24 | { 25 | CommandBufferManager::CommandBufferManager(VkDevice vkDevice, VkCommandBufferLevel bufferLevel, 26 | unsigned graphicsQueueIndex) 27 | : device(vkDevice) 28 | , commandBufferLevel(bufferLevel) 29 | , count(0) 30 | { 31 | VkCommandPoolCreateInfo info = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }; 32 | info.queueFamilyIndex = graphicsQueueIndex; 33 | info.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT; 34 | VK_CHECK(vkCreateCommandPool(device, &info, nullptr, &pool)); 35 | } 36 | 37 | CommandBufferManager::~CommandBufferManager() 38 | { 39 | if (!buffers.empty()) 40 | vkFreeCommandBuffers(device, pool, buffers.size(), buffers.data()); 41 | vkDestroyCommandPool(device, pool, nullptr); 42 | } 43 | 44 | void CommandBufferManager::beginFrame() 45 | { 46 | count = 0; 47 | vkResetCommandPool(device, pool, 0); 48 | } 49 | 50 | VkCommandBuffer CommandBufferManager::requestCommandBuffer() 51 | { 52 | // Either we recycle a previously allocated command buffer, or create a new 53 | // one. 54 | VkCommandBuffer ret = VK_NULL_HANDLE; 55 | if (count < buffers.size()) 56 | { 57 | ret = buffers[count++]; 58 | } 59 | else 60 | { 61 | VkCommandBufferAllocateInfo info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO }; 62 | info.commandPool = pool; 63 | info.level = commandBufferLevel; 64 | info.commandBufferCount = 1; 65 | VK_CHECK(vkAllocateCommandBuffers(device, &info, &ret)); 66 | buffers.push_back(ret); 67 | 68 | count++; 69 | } 70 | 71 | return ret; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /framework/command_buffer_manager.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef FRAMEWORK_COMMAND_BUFFER_MANAGER_HPP 22 | #define FRAMEWORK_COMMAND_BUFFER_MANAGER_HPP 23 | 24 | #include "common.hpp" 25 | #include 26 | 27 | namespace MaliSDK 28 | { 29 | /// @brief The command buffer allocates command buffers and recycles them for 30 | /// us. 31 | /// This gives us a convenient interface where we can request command buffers 32 | /// for use when rendering. 33 | /// The manager is not thread-safe and for rendering in multiple threads, 34 | /// multiple per-thread managers 35 | /// should be used. 36 | class CommandBufferManager 37 | { 38 | public: 39 | /// @brief Constructor 40 | /// @param device The Vulkan device 41 | /// @param bufferLevel The command buffer level to use, 42 | /// either `VK_COMMAND_BUFFER_LEVEL_PRIMARY` or 43 | /// `VK_COMMAND_BUFFER_LEVEL_SECONDARY`. 44 | /// @param graphicsQueueIndex The Vulkan queue family index for where we can 45 | /// submit graphics work. 46 | CommandBufferManager(VkDevice device, VkCommandBufferLevel bufferLevel, unsigned graphicsQueueIndex); 47 | 48 | /// @brief Destructor 49 | ~CommandBufferManager(); 50 | 51 | /// @brief Requests a fresh or recycled command buffer which is in the reset 52 | /// state. 53 | VkCommandBuffer requestCommandBuffer(); 54 | 55 | /// @brief Begins the frame. When this is called, 56 | /// all command buffers managed by this class are assumed to be recycleable. 57 | void beginFrame(); 58 | 59 | private: 60 | VkDevice device = VK_NULL_HANDLE; 61 | VkCommandPool pool = VK_NULL_HANDLE; 62 | std::vector buffers; 63 | VkCommandBufferLevel commandBufferLevel; 64 | unsigned count = 0; 65 | }; 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /framework/common.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef FRAMEWORK_COMMON_HPP 22 | #define FRAMEWORK_COMMON_HPP 23 | 24 | #include "libvulkan-stub.h" 25 | #include 26 | #include 27 | 28 | #ifdef ANDROID 29 | #include 30 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "MaliSDK", __VA_ARGS__) 31 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "MaliSDK", __VA_ARGS__) 32 | #else 33 | #define LOGE(...) fprintf(stderr, "ERROR: " __VA_ARGS__) 34 | #define LOGI(...) fprintf(stderr, "INFO: " __VA_ARGS__) 35 | #endif 36 | 37 | /// @brief Helper macro to test the result of Vulkan calls which can return an 38 | /// error. 39 | #define VK_CHECK(x) \ 40 | do \ 41 | { \ 42 | VkResult err = x; \ 43 | if (err) \ 44 | { \ 45 | LOGE("Detected Vulkan error %d at %s:%d.\n", int(err), __FILE__, __LINE__); \ 46 | abort(); \ 47 | } \ 48 | } while (0) 49 | 50 | #define ASSERT_VK_HANDLE(handle) \ 51 | do \ 52 | { \ 53 | if ((handle) == VK_NULL_HANDLE) \ 54 | { \ 55 | LOGE("Handle is NULL at %s:%d.\n", __FILE__, __LINE__); \ 56 | abort(); \ 57 | } \ 58 | } while (0) 59 | 60 | namespace MaliSDK 61 | { 62 | 63 | /// @brief Generic error codes used throughout the framework and platform. 64 | enum Result 65 | { 66 | /// Success 67 | RESULT_SUCCESS = 0, 68 | 69 | /// Generic error without any particular information 70 | RESULT_ERROR_GENERIC = -1, 71 | 72 | /// Returned by the swapchain when the swapchain is invalid and should be 73 | /// recreated 74 | RESULT_ERROR_OUTDATED_SWAPCHAIN = -2, 75 | 76 | /// Generic input/output errors 77 | RESULT_ERROR_IO = -3, 78 | 79 | /// Memory allocation errors 80 | RESULT_ERROR_OUT_OF_MEMORY = -4 81 | }; 82 | 83 | /// @brief Helper macro to determine success of a call. 84 | #define SUCCEEDED(x) ((x) == RESULT_SUCCESS) 85 | /// @brief Helper macro to determine failure of a call. 86 | #define FAILED(x) ((x) != RESULT_SUCCESS) 87 | } 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /framework/fence_manager.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #include "fence_manager.hpp" 22 | 23 | namespace MaliSDK 24 | { 25 | FenceManager::FenceManager(VkDevice vkDevice) 26 | : device(vkDevice) 27 | , count(0) 28 | { 29 | } 30 | 31 | FenceManager::~FenceManager() 32 | { 33 | beginFrame(); 34 | for (auto &fence : fences) 35 | vkDestroyFence(device, fence, nullptr); 36 | } 37 | 38 | void FenceManager::beginFrame() 39 | { 40 | // If we have outstanding fences for this swapchain image, wait for them to 41 | // complete first. 42 | // Normally, this doesn't really block at all, 43 | // since we're waiting for old frames to have been completed, but just in 44 | // case. 45 | if (count != 0) 46 | { 47 | vkWaitForFences(device, count, fences.data(), true, UINT64_MAX); 48 | vkResetFences(device, count, fences.data()); 49 | } 50 | count = 0; 51 | } 52 | 53 | VkFence FenceManager::requestClearedFence() 54 | { 55 | if (count < fences.size()) 56 | return fences[count++]; 57 | 58 | VkFence fence; 59 | VkFenceCreateInfo info = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; 60 | VK_CHECK(vkCreateFence(device, &info, nullptr, &fence)); 61 | fences.push_back(fence); 62 | count++; 63 | return fence; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /framework/fence_manager.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef FRAMEWORK_FENCE_MANAGER_HPP 22 | #define FRAMEWORK_FENCE_MANAGER_HPP 23 | 24 | #include "framework/common.hpp" 25 | #include 26 | 27 | namespace MaliSDK 28 | { 29 | /// @brief The FenceManager keeps track of fences which in turn are used to keep 30 | /// track of GPU progress. 31 | /// 32 | /// Whenever we submit work to the GPU, it is our responsibility to make sure 33 | /// that the GPU is done 34 | /// using our resources before we modify or delete them. 35 | /// To implement this, we therefore use VkFences to keep track of all 36 | /// vkQueueSubmits. 37 | class FenceManager 38 | { 39 | public: 40 | /// @brief Constructor 41 | /// @param device The Vulkan device 42 | FenceManager(VkDevice device); 43 | 44 | /// @brief Destructor 45 | ~FenceManager(); 46 | 47 | /// @brief Begins the frame. Waits for GPU to trigger all outstanding fences. 48 | /// After begin frame returns, it is safe to reuse or delete resources which 49 | /// were used previously. 50 | /// 51 | /// We wait for fences which completes N frames earlier, so we do not stall, 52 | /// waiting 53 | /// for all GPU work to complete before this returns. 54 | void beginFrame(); 55 | 56 | /// @brief Called internally by the Context whenever submissions to GPU 57 | /// happens. 58 | VkFence requestClearedFence(); 59 | 60 | /// @brief Gets the number of fences which are inFlight on the GPU. 61 | /// @returns The number of fences which can be waited for. 62 | unsigned getActiveFenceCount() const 63 | { 64 | return count; 65 | } 66 | 67 | /// @brief Gets an array for the fences which are inFlight on the GPU. 68 | /// @returns Array of waitable fences. Call @ref getActiveFenceCount for the 69 | /// number of fences. 70 | VkFence *getActiveFences() 71 | { 72 | return fences.data(); 73 | } 74 | 75 | private: 76 | VkDevice device = VK_NULL_HANDLE; 77 | std::vector fences; 78 | unsigned count = 0; 79 | }; 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /framework/math.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef FRAMEWORK_MATH_HPP 22 | #define FRAMEWORK_MATH_HPP 23 | 24 | #define GLM_FORCE_SWIZZLE 25 | #define GLM_FORCE_RADIANS 26 | #define GLM_ENABLE_EXPERIMENTAL 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace MaliSDK 35 | { 36 | /// @brief Converts an OpenGL style projection matrix to Vulkan style projection 37 | /// matrix. 38 | /// 39 | /// Vulkan has a topLeft clipSpace with [0, 1] depth range instead of [-1, 1]. 40 | /// 41 | /// GLM outputs projection matrices in GL style clipSpace, 42 | /// perform a simple fix-up step to change the projection to VulkanStyle. 43 | /// 44 | /// @param proj Projection matrix 45 | /// 46 | /// @returns A Vulkan compatible projection matrix. 47 | inline glm::mat4 vulkanStyleProjection(const glm::mat4 &proj) 48 | { 49 | using namespace glm; 50 | 51 | // Flip Y in clipspace. X = -1, Y = -1 is topLeft in Vulkan. 52 | auto mat = scale(mat4(1.0f), vec3(1.0f, -1.0f, 1.0f)); 53 | 54 | // Z depth is [0, 1] range instead of [-1, 1]. 55 | mat = scale(mat, vec3(1.0f, 1.0f, 0.5f)); 56 | return translate(mat, vec3(0.0f, 0.0f, 1.0f)) * proj; 57 | } 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /framework/semaphore_manager.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #include "semaphore_manager.hpp" 22 | 23 | namespace MaliSDK 24 | { 25 | SemaphoreManager::SemaphoreManager(VkDevice vkDevice) 26 | : device(vkDevice) 27 | { 28 | } 29 | 30 | SemaphoreManager::~SemaphoreManager() 31 | { 32 | for (auto &semaphore : recycledSemaphores) 33 | vkDestroySemaphore(device, semaphore, nullptr); 34 | } 35 | 36 | void SemaphoreManager::addClearedSemaphore(VkSemaphore semaphore) 37 | { 38 | recycledSemaphores.push_back(semaphore); 39 | } 40 | 41 | VkSemaphore SemaphoreManager::getClearedSemaphore() 42 | { 43 | if (recycledSemaphores.empty()) 44 | { 45 | VkSemaphoreCreateInfo info = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }; 46 | VkSemaphore semaphore; 47 | VK_CHECK(vkCreateSemaphore(device, &info, nullptr, &semaphore)); 48 | return semaphore; 49 | } 50 | else 51 | { 52 | auto semaphore = recycledSemaphores.back(); 53 | recycledSemaphores.pop_back(); 54 | return semaphore; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /framework/semaphore_manager.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef FRAMEWORK_SEMAPHORE_MANAGER_HPP 22 | #define FRAMEWORK_SEMAPHORE_MANAGER_HPP 23 | 24 | #include "framework/common.hpp" 25 | #include 26 | 27 | namespace MaliSDK 28 | { 29 | /// @brief The SemaphoreManager keeps track of semaphores 30 | /// 31 | /// This class is mostly used by the WSI implementation so we can recycle 32 | /// semaphores. 33 | class SemaphoreManager 34 | { 35 | public: 36 | /// @brief Constructor 37 | /// @param device The Vulkan device 38 | SemaphoreManager(VkDevice device); 39 | 40 | /// @brief Destructor 41 | ~SemaphoreManager(); 42 | 43 | /// @brief Takes ownership of a recycled semaphore or creates a new one. 44 | /// @returns A VkSemaphore. This semaphore is owned by the API user and must 45 | /// be destroyed or given back to the semaphore manager. 46 | VkSemaphore getClearedSemaphore(); 47 | 48 | /// @brief Gives ownership of a cleared semaphore to the semaphore manager. 49 | /// @param semaphore A cleared semaphore. The API user relinquishes ownership 50 | /// of the semaphore. 51 | void addClearedSemaphore(VkSemaphore semaphore); 52 | 53 | private: 54 | VkDevice device = VK_NULL_HANDLE; 55 | std::vector recycledSemaphores; 56 | }; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /framework/thread_pool.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #include "thread_pool.hpp" 22 | #include 23 | 24 | using namespace std; 25 | 26 | namespace MaliSDK 27 | { 28 | void ThreadPool::setWorkerThreadCount(unsigned workerThreadCount) 29 | { 30 | workerThreads.clear(); 31 | for (unsigned i = 0; i < workerThreadCount; i++) 32 | workerThreads.emplace_back(new Worker); 33 | } 34 | 35 | void ThreadPool::pushWorkToThread(unsigned threadIndex, std::function func) 36 | { 37 | workerThreads[threadIndex]->pushWork(move(func)); 38 | } 39 | 40 | void ThreadPool::waitIdle() 41 | { 42 | for (auto &worker : workerThreads) 43 | worker->waitIdle(); 44 | } 45 | 46 | ThreadPool::Worker::Worker() 47 | { 48 | workerThread = thread(&ThreadPool::Worker::threadEntry, this); 49 | } 50 | 51 | ThreadPool::Worker::~Worker() 52 | { 53 | if (workerThread.joinable()) 54 | { 55 | waitIdle(); 56 | 57 | lock.lock(); 58 | threadIsAlive = false; 59 | cond.notify_one(); 60 | lock.unlock(); 61 | 62 | workerThread.join(); 63 | } 64 | } 65 | 66 | void ThreadPool::Worker::pushWork(std::function func) 67 | { 68 | lock_guard holder{ lock }; 69 | workQueue.push(move(func)); 70 | cond.notify_one(); 71 | } 72 | 73 | void ThreadPool::Worker::waitIdle() 74 | { 75 | unique_lock holder{ lock }; 76 | cond.wait(holder, [this] { return workQueue.empty(); }); 77 | } 78 | 79 | void ThreadPool::Worker::threadEntry() 80 | { 81 | for (;;) 82 | { 83 | function *pWork = nullptr; 84 | { 85 | unique_lock holder{ lock }; 86 | cond.wait(holder, [this] { return !workQueue.empty() || !threadIsAlive; }); 87 | if (!threadIsAlive) 88 | break; 89 | 90 | pWork = &workQueue.front(); 91 | } 92 | 93 | (*pWork)(); 94 | 95 | { 96 | lock_guard holder{ lock }; 97 | workQueue.pop(); 98 | cond.notify_one(); 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /framework/thread_pool.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef FRAMEWORK_THREAD_POOL_HPP 22 | #define FRAMEWORK_THREAD_POOL_HPP 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace MaliSDK 32 | { 33 | 34 | /// @brief Implements a simple thread pool which can be used to submit rendering 35 | /// work to multiple 36 | /// threads. It does not aim to distribute chunks of work dynamically to 37 | /// threads, but API users 38 | /// must submit work to particular worker threads. 39 | class ThreadPool 40 | { 41 | public: 42 | /// @brief Sets the number of worker threads to spawn. 43 | /// 44 | /// This call is heavyweight and should not be called more than once during 45 | /// initialization. 46 | /// To get a platform specific optimal count to use, use 47 | /// `MaliSDK::OS::getNumberOfCpuThreads`. 48 | /// @param workerThreadCount The number of worker threads. 49 | void setWorkerThreadCount(unsigned workerThreadCount); 50 | 51 | /// @brief Gets the current number of worker threads. 52 | unsigned getWorkerThreadCount() const 53 | { 54 | return workerThreads.size(); 55 | } 56 | 57 | /// @brief Pushes a bundle of work to a thread. 58 | /// @param threadIndex The worker thread to push work to. 59 | /// @param func A generic function object which will be executed by the 60 | /// thread. 61 | /// Using C++11 lambdas is the intended way to create these objects. 62 | void pushWorkToThread(unsigned threadIndex, std::function func); 63 | 64 | /// @brief Waits for all worker threads to complete all work they have been 65 | /// assigned. 66 | void waitIdle(); 67 | 68 | private: 69 | class Worker 70 | { 71 | public: 72 | Worker(); 73 | ~Worker(); 74 | 75 | void pushWork(std::function func); 76 | void waitIdle(); 77 | 78 | private: 79 | std::thread workerThread; 80 | std::mutex lock; 81 | std::condition_variable cond; 82 | 83 | std::queue> workQueue; 84 | bool threadIsAlive = true; 85 | 86 | void threadEntry(); 87 | }; 88 | 89 | std::vector> workerThreads; 90 | }; 91 | } 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /include/vulkan/vk_platform.h: -------------------------------------------------------------------------------- 1 | // 2 | // File: vk_platform.h 3 | // 4 | /* 5 | ** Copyright (c) 2014-2015 The Khronos Group Inc. 6 | ** 7 | ** Licensed under the Apache License, Version 2.0 (the "License"); 8 | ** you may not use this file except in compliance with the License. 9 | ** You may obtain a copy of the License at 10 | ** 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** 13 | ** Unless required by applicable law or agreed to in writing, software 14 | ** distributed under the License is distributed on an "AS IS" BASIS, 15 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | ** See the License for the specific language governing permissions and 17 | ** limitations under the License. 18 | */ 19 | 20 | 21 | #ifndef VK_PLATFORM_H_ 22 | #define VK_PLATFORM_H_ 23 | 24 | #ifdef __cplusplus 25 | extern "C" 26 | { 27 | #endif // __cplusplus 28 | 29 | /* 30 | *************************************************************************************************** 31 | * Platform-specific directives and type declarations 32 | *************************************************************************************************** 33 | */ 34 | 35 | /* Platform-specific calling convention macros. 36 | * 37 | * Platforms should define these so that Vulkan clients call Vulkan commands 38 | * with the same calling conventions that the Vulkan implementation expects. 39 | * 40 | * VKAPI_ATTR - Placed before the return type in function declarations. 41 | * Useful for C++11 and GCC/Clang-style function attribute syntax. 42 | * VKAPI_CALL - Placed after the return type in function declarations. 43 | * Useful for MSVC-style calling convention syntax. 44 | * VKAPI_PTR - Placed between the '(' and '*' in function pointer types. 45 | * 46 | * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); 47 | * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); 48 | */ 49 | #if defined(_WIN32) 50 | // On Windows, Vulkan commands use the stdcall convention 51 | #define VKAPI_ATTR 52 | #define VKAPI_CALL __stdcall 53 | #define VKAPI_PTR VKAPI_CALL 54 | #elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 55 | #error "Vulkan isn't supported for the 'armeabi' NDK ABI" 56 | #elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) 57 | // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" 58 | // calling convention, i.e. float parameters are passed in registers. This 59 | // is true even if the rest of the application passes floats on the stack, 60 | // as it does by default when compiling for the armeabi-v7a NDK ABI. 61 | #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) 62 | #define VKAPI_CALL 63 | #define VKAPI_PTR VKAPI_ATTR 64 | #else 65 | // On other platforms, use the default calling convention 66 | #define VKAPI_ATTR 67 | #define VKAPI_CALL 68 | #define VKAPI_PTR 69 | #endif 70 | 71 | #include 72 | 73 | #if !defined(VK_NO_STDINT_H) 74 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 75 | typedef signed __int8 int8_t; 76 | typedef unsigned __int8 uint8_t; 77 | typedef signed __int16 int16_t; 78 | typedef unsigned __int16 uint16_t; 79 | typedef signed __int32 int32_t; 80 | typedef unsigned __int32 uint32_t; 81 | typedef signed __int64 int64_t; 82 | typedef unsigned __int64 uint64_t; 83 | #else 84 | #include 85 | #endif 86 | #endif // !defined(VK_NO_STDINT_H) 87 | 88 | #ifdef __cplusplus 89 | } // extern "C" 90 | #endif // __cplusplus 91 | 92 | // Platform-specific headers required by platform window system extensions. 93 | // These are enabled prior to #including "vulkan.h". The same enable then 94 | // controls inclusion of the extension interfaces in vulkan.h. 95 | 96 | #ifdef VK_USE_PLATFORM_ANDROID_KHR 97 | #include 98 | #endif 99 | 100 | #ifdef VK_USE_PLATFORM_MIR_KHR 101 | #include 102 | #endif 103 | 104 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR 105 | #include 106 | #endif 107 | 108 | #ifdef VK_USE_PLATFORM_WIN32_KHR 109 | #include 110 | #endif 111 | 112 | #ifdef VK_USE_PLATFORM_XLIB_KHR 113 | #include 114 | #endif 115 | 116 | #ifdef VK_USE_PLATFORM_XCB_KHR 117 | #include 118 | #endif 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources-headers *.hpp) 2 | 3 | add_library(platform STATIC ../.dummy.cpp 4 | ${sources-headers}) 5 | 6 | add_library(platform-wsi STATIC 7 | wsi/wsi.cpp 8 | wsi/wsi.hpp) 9 | 10 | add_library(platform-asset-manager STATIC 11 | asset_manager.cpp 12 | asset_manager.hpp) 13 | 14 | if (${CMAKE_BUILD_TYPE} MATCHES "Rel") 15 | target_compile_definitions(platform-wsi PRIVATE FORCE_NO_VALIDATION=1) 16 | endif() 17 | 18 | add_subdirectory(${PLATFORM}) 19 | 20 | target_include_directories(platform 21 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR} 22 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) 23 | 24 | target_link_libraries(platform framework platform-${PLATFORM}) 25 | target_link_libraries(platform-wsi vulkan-stub) 26 | target_link_libraries(platform-asset-manager framework) 27 | -------------------------------------------------------------------------------- /platform/android/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | file(GLOB sources-headers *.hpp) 3 | 4 | add_library(platform-android STATIC 5 | ${sources} 6 | ${sources-headers} 7 | ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c 8 | ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) 9 | 10 | find_library(log-lib log) 11 | find_library(android-lib android) 12 | target_link_libraries(platform-android framework platform-wsi platform-asset-manager ${log-lib} ${android-lib}) 13 | target_include_directories(platform-android 14 | PRIVATE 15 | ${ANDROID_NDK}/sources/android/native_app_glue 16 | ${ANDROID_NDK}/sources/android/cpufeatures) 17 | 18 | # Include Validation layers in the APK 19 | set(layer-files ${ANDROID_NDK}/sources/third_party/vulkan/src/build-android/jniLibs/${ANDROID_ABI}) 20 | file(GLOB layers ${layer-files}/*.so) 21 | file(MAKE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 22 | foreach(layer ${layers}) 23 | get_filename_component(layer-basename ${layer} NAME) 24 | add_custom_command(TARGET platform-android POST_BUILD 25 | COMMAND ${CMAKE_COMMAND} -E copy ${layer} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${layer-basename}) 26 | endforeach() 27 | -------------------------------------------------------------------------------- /platform/android/android.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef PLATFORM_ANDROID_HPP 22 | #define PLATFORM_ANDROID_HPP 23 | 24 | #define VK_USE_PLATFORM_ANDROID_KHR 25 | #include "android_assets.hpp" 26 | #include "android_native_app_glue.h" 27 | #include "cpu-features.h" 28 | #include "framework/application.hpp" 29 | #include "platform.hpp" 30 | #include "platform/os.hpp" 31 | #include "platform/wsi/wsi.hpp" 32 | #include 33 | 34 | namespace MaliSDK 35 | { 36 | /// @brief State used for the android mainloop. 37 | struct AndroidState 38 | { 39 | /// The ANativeActivity handle. 40 | struct android_app *pApp; 41 | 42 | /// The Vulkan application. 43 | VulkanApplication *pVulkanApp; 44 | 45 | /// The application is in focus and running. 46 | bool active; 47 | }; 48 | 49 | /// @brief The Android specific platform. 50 | class AndroidPlatform : public WSIPlatform 51 | { 52 | public: 53 | /// @brief Sets the native window used to create Vulkan swapchain. 54 | /// Called by the mainloop. 55 | /// @param pWindow The native window. 56 | void setNativeWindow(ANativeWindow *pWindow) 57 | { 58 | pNativeWindow = pWindow; 59 | } 60 | 61 | /// @brief Gets the preferred swapchain size. 62 | /// @returns Error code. 63 | virtual SwapchainDimensions getPreferredSwapchain() override; 64 | 65 | /// @brief Creates a window with desired swapchain dimensions. 66 | /// 67 | /// The swapchain parameters might not necessarily be honored by the platform. 68 | /// Use @ref getCurrentSwapchain to query the dimensions we actually 69 | /// initialized. 70 | /// @returns Error code. 71 | virtual Result createWindow(const SwapchainDimensions &swapchain) override; 72 | 73 | /// @brief Gets current window status. 74 | /// @returns Window status. 75 | virtual Status getWindowStatus() override; 76 | 77 | /// @brief Terminates the Android platform. 78 | /// Called by the mainloop on `APP_CMD_INIT_WINDOW` from ANativeActivity. 79 | void terminate() override; 80 | 81 | /// @brief Called on APP_CMD_ON_PAUSE. Tears down swapchain. 82 | void onPause(); 83 | /// @brief Called on APP_CMD_ON_RESUME. Reinitializes swapchain. 84 | /// @param swapchain The swapchain parameters. 85 | void onResume(const SwapchainDimensions &swapchain); 86 | 87 | private: 88 | Result initConnection(); 89 | Result initWindow(); 90 | 91 | ANativeWindow *pNativeWindow = nullptr; 92 | virtual VkSurfaceKHR createSurface() override; 93 | }; 94 | } 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /platform/android/android_assets.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #include "android_assets.hpp" 22 | 23 | using namespace std; 24 | 25 | namespace MaliSDK 26 | { 27 | Result AndroidAssetManager::readBinaryFile(const char *pPath, void **ppData, size_t *pSize) 28 | { 29 | if (!pManager) 30 | { 31 | LOGE("Asset manager does not exist."); 32 | return RESULT_ERROR_GENERIC; 33 | } 34 | 35 | AAsset *asset = AAssetManager_open(pManager, pPath, AASSET_MODE_BUFFER); 36 | if (!asset) 37 | { 38 | LOGE("AAssetManager_open() failed to load file: %s.", pPath); 39 | return RESULT_ERROR_IO; 40 | } 41 | 42 | const void *buffer = AAsset_getBuffer(asset); 43 | if (buffer) 44 | { 45 | *pSize = AAsset_getLength(asset); 46 | *ppData = malloc(*pSize); 47 | if (!*ppData) 48 | { 49 | LOGE("Failed to allocate buffer for asset: %s.", pPath); 50 | AAsset_close(asset); 51 | return RESULT_ERROR_OUT_OF_MEMORY; 52 | } 53 | 54 | memcpy(*ppData, buffer, *pSize); 55 | AAsset_close(asset); 56 | return RESULT_SUCCESS; 57 | } 58 | else 59 | { 60 | LOGE("Failed to obtain buffer for asset: %s.", pPath); 61 | AAsset_close(asset); 62 | return RESULT_ERROR_IO; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /platform/android/android_assets.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef PLATFORM_ANDROID_ASSETS 22 | #define PLATFORM_ANDROID_ASSETS 23 | 24 | #include "../asset_manager.hpp" 25 | #include 26 | #include 27 | 28 | namespace MaliSDK 29 | { 30 | 31 | /// @brief An asset manager implementation for Android. Uses AAssetManager to 32 | /// load assets. 33 | class AndroidAssetManager : public AssetManager 34 | { 35 | public: 36 | /// @brief Reads a binary file as a raw blob. 37 | /// @param pPath The path of the asset. 38 | /// @param[out] ppData allocated output data. Must be freed with `free()`. 39 | /// @param[out] pSize The size of the allocated data. 40 | /// @returns Error code 41 | virtual Result readBinaryFile(const char *pPath, void **ppData, size_t *pSize) override; 42 | 43 | /// @brief Sets the asset manager to use. Called from platform. 44 | /// @param pAssetManager The asset manager. 45 | void setAssetManager(AAssetManager *pAssetManager) 46 | { 47 | pManager = pAssetManager; 48 | } 49 | 50 | private: 51 | AAssetManager *pManager = nullptr; 52 | }; 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /platform/asset_manager.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #include "asset_manager.hpp" 22 | #include 23 | 24 | using namespace std; 25 | 26 | namespace MaliSDK 27 | { 28 | Result AssetManager::readBinaryFile(const char *pPath, void **pData, size_t *pSize) 29 | { 30 | FILE *file = fopen(pPath, "rb"); 31 | if (!file) 32 | return RESULT_ERROR_IO; 33 | 34 | fseek(file, 0, SEEK_END); 35 | long len = ftell(file); 36 | rewind(file); 37 | 38 | *pData = malloc(len); 39 | if (!*pData) 40 | { 41 | fclose(file); 42 | return RESULT_ERROR_OUT_OF_MEMORY; 43 | } 44 | 45 | *pSize = len; 46 | if (fread(*pData, 1, *pSize, file) != *pSize) 47 | { 48 | free(pData); 49 | fclose(file); 50 | return RESULT_ERROR_IO; 51 | } 52 | 53 | fclose(file); 54 | return RESULT_SUCCESS; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /platform/asset_manager.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef PLATFORM_ASSET_MANAGER_HPP 22 | #define PLATFORM_ASSET_MANAGER_HPP 23 | 24 | #include "framework/common.hpp" 25 | #include 26 | #include 27 | #include 28 | 29 | namespace MaliSDK 30 | { 31 | 32 | /// @brief The asset manager reads data from a platform specific location. 33 | /// This class is used internally to load binary data from disk. 34 | class AssetManager 35 | { 36 | public: 37 | virtual ~AssetManager() = default; 38 | 39 | /// @brief Reads a binary file into typed container. 40 | /// @param[out] pOutput Output vector to write data into. 41 | /// The vector will be cleared before adding any data to the container. 42 | /// @param[out] pPath The path to read. 43 | /// @returns Error code 44 | template 45 | inline Result readBinaryFile(std::vector *pOutput, const char *pPath) 46 | { 47 | void *pData; 48 | size_t size; 49 | Result error = readBinaryFile(pPath, &pData, &size); 50 | if (error != RESULT_SUCCESS) 51 | return error; 52 | 53 | size_t numElements = size / sizeof(T); 54 | 55 | pOutput->clear(); 56 | pOutput->insert(end(*pOutput), reinterpret_cast(pData), reinterpret_cast(pData) + numElements); 57 | free(pData); 58 | return RESULT_SUCCESS; 59 | } 60 | 61 | /// @brief Reads a binary file as a raw blob. 62 | /// @param pPath The path of the asset. 63 | /// @param[out] ppData allocated output data. Must be freed with `free()`. 64 | /// @param[out] pSize The size of the allocated data. 65 | /// @returns Error code 66 | virtual Result readBinaryFile(const char *pPath, void **ppData, size_t *pSize); 67 | }; 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /platform/display/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | file(GLOB sources-headers *.hpp) 3 | 4 | add_library(platform-display STATIC 5 | ${sources} 6 | ${sources-headers}) 7 | 8 | target_link_libraries(platform-display framework platform-wsi platform-asset-manager) 9 | 10 | -------------------------------------------------------------------------------- /platform/display/display.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef PLATFORM_DISPLAY_HPP 22 | #define PLATFORM_DISPLAY_HPP 23 | 24 | #include "platform.hpp" 25 | #include "platform/os/linux.hpp" 26 | #include "platform/wsi/wsi.hpp" 27 | 28 | namespace MaliSDK 29 | { 30 | 31 | /// @brief The generic embedded platform, which makes use of VK_KHR_display 32 | /// extension. Inherits from WSIPlatform. 33 | class DisplayPlatform : public WSIPlatform 34 | { 35 | public: 36 | DisplayPlatform() = default; 37 | 38 | /// @brief Gets the preferred swapchain size. 39 | /// @returns Error code. 40 | virtual SwapchainDimensions getPreferredSwapchain() override; 41 | 42 | /// @brief Creates a window with desired swapchain dimensions. 43 | /// 44 | /// The swapchain parameters might not necessarily be honored by the platform. 45 | /// Use @ref getCurrentSwapchain to query the dimensions we actually 46 | /// initialized. 47 | /// @returns Error code. 48 | virtual Result createWindow(const SwapchainDimensions &swapchain) override; 49 | 50 | /// @brief Gets current window status. 51 | /// @returns Window status. 52 | virtual Status getWindowStatus() override; 53 | 54 | private: 55 | Platform::Status status = STATUS_RUNNING; 56 | LinuxAssetManager assetManager; 57 | virtual VkSurfaceKHR createSurface() override; 58 | 59 | unsigned preferredWidth = 0; 60 | unsigned preferredHeight = 0; 61 | }; 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /platform/os.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef PLATFORM_OS_HPP 22 | #define PLATFORM_OS_HPP 23 | 24 | #include "asset_manager.hpp" 25 | 26 | namespace MaliSDK 27 | { 28 | namespace OS 29 | { 30 | 31 | /// @brief Get the current monotonic time in seconds. 32 | /// @returns Current time. 33 | double getCurrentTime(); 34 | 35 | /// @brief Get the asset manager for the platform. 36 | /// @returns The asset manager. 37 | AssetManager &getAssetManager(); 38 | 39 | /// @brief Returns number of threads the CPU supports executing concurrently. 40 | /// @returns Number of CPU threads. 41 | unsigned getNumberOfCpuThreads(); 42 | } 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /platform/os/linux.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef PLATFORM_LINUX_HPP 22 | #define PLATFORM_LINUX_HPP 23 | 24 | #include "asset_manager.hpp" 25 | #include 26 | 27 | namespace MaliSDK 28 | { 29 | 30 | /// @brief The Linux asset manager. 31 | /// It is based on regular fopen(), with the exception that all paths passed to 32 | /// it are relative to 33 | /// the path of the binary. The path to the binary are Linux specific due to 34 | /// parsing /proc interface. 35 | class LinuxAssetManager : public AssetManager 36 | { 37 | public: 38 | /// @brief Constructor 39 | LinuxAssetManager(); 40 | 41 | /// @brief Reads a binary file as a raw blob. 42 | /// @param pPath The path of the asset. 43 | /// @param[out] ppData allocated output data. Must be freed with `free()`. 44 | /// @param[out] pSize The size of the allocated data. 45 | /// @returns Error code 46 | virtual Result readBinaryFile(const char *pPath, void **ppData, size_t *pSize) override; 47 | 48 | private: 49 | std::string basePath; 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /platform/os/windows.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.hpp" 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | #undef SUCCEEDED 5 | #undef FAILED 6 | 7 | #include "asset_manager.hpp" 8 | #include "platform/os.hpp" 9 | 10 | // Stub implementation. 11 | 12 | namespace MaliSDK 13 | { 14 | AssetManager &OS::getAssetManager() 15 | { 16 | return *static_cast(nullptr); 17 | } 18 | 19 | unsigned OS::getNumberOfCpuThreads() 20 | { 21 | return 1; 22 | } 23 | 24 | double OS::getCurrentTime() 25 | { 26 | return 0.0; 27 | } 28 | } 29 | 30 | int main() 31 | { 32 | } -------------------------------------------------------------------------------- /platform/os/windows.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/platform/os/windows.hpp -------------------------------------------------------------------------------- /platform/png/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | file(GLOB sources-headers *.hpp) 3 | 4 | add_library(platform-png STATIC 5 | ${sources} 6 | ${sources-headers}) 7 | 8 | if (${CMAKE_BUILD_TYPE} MATCHES "Rel") 9 | target_compile_definitions(platform-png PRIVATE FORCE_NO_VALIDATION=1) 10 | endif() 11 | 12 | target_link_libraries(platform-png framework platform-asset-manager) 13 | -------------------------------------------------------------------------------- /platform/png/png_swapchain.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef DMABUF_SWAPCHAIN_HPP 22 | #define DMABUF_SWAPCHAIN_HPP 23 | 24 | #include "libvulkan-stub.h" 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "framework/common.hpp" 32 | 33 | namespace MaliSDK 34 | { 35 | 36 | /// @brief This class implements a swapchain outside the Vulkan API. 37 | /// Its main purpose is debugging without a screen since the swapchain will dump 38 | /// output 39 | /// directly to PNG files instead of displaying on-screen. 40 | class PNGSwapchain 41 | { 42 | public: 43 | /// @brief Initialize the swapchain. 44 | /// @param pBasePath The base path that will be used for all PNG images. 45 | /// @param swapchainImagesCount The number of swapchain images to create in 46 | /// the internal queue. 47 | /// @returns Error code. 48 | Result init(const char *pBasePath, unsigned swapchainImagesCount); 49 | 50 | /// @brief Destructor 51 | ~PNGSwapchain(); 52 | 53 | /// @brief Gets number of images in the swapchain. 54 | /// @returns Number of swapchain images. 55 | inline unsigned getNumImages() const 56 | { 57 | return swapchainImagesCount; 58 | } 59 | 60 | /// @brief Dump image for a swapchain index to disk. 61 | /// @param index Index to present. 62 | /// @param device Vulkan device. 63 | /// @param memory The VkDeviceMemory associated with the swapchain image. The 64 | /// memory must be tightly packed in VK_FORMAT_R8G8B8A8_UNORM format. 65 | /// @param width The width of the swapchain image. 66 | /// @param height The height of the swapchain image. 67 | /// @param numFences The number of VkFences to wait on before dumping the 68 | /// texture. 69 | /// @param[in] fences Fences to wait for. 70 | /// @param coherent If the swapchain memory is coherent, i.e. does not need to 71 | /// invalidate caches. 72 | void present(unsigned index, VkDevice device, VkDeviceMemory memory, unsigned width, unsigned height, 73 | unsigned numFences, VkFence *fences, bool coherent); 74 | 75 | /// @brief Acquire a new swapchain index. 76 | /// When acquire returns the image is ready to be presented into, so no 77 | /// semaphores 78 | /// are required. 79 | unsigned acquire(); 80 | 81 | private: 82 | std::thread worker; 83 | unsigned swapchainImagesCount; 84 | std::string basePath; 85 | 86 | struct Command 87 | { 88 | VkDevice device; 89 | VkDeviceMemory memory; 90 | VkFence *fences; 91 | unsigned numFences; 92 | unsigned index; 93 | unsigned width; 94 | unsigned height; 95 | bool coherent; 96 | }; 97 | 98 | std::queue vacant; 99 | std::queue ready; 100 | 101 | std::condition_variable cond; 102 | std::mutex lock; 103 | bool dead = false; 104 | 105 | void join(); 106 | 107 | unsigned displayed = 0; 108 | 109 | void threadEntry(); 110 | 111 | void dump(const Command &cmd, unsigned sequenceCount); 112 | }; 113 | } 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /platform/read_write_lock.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef PLATFORM_READ_WRITE_LOCK_HPP 22 | #define PLATFORM_READ_WRITE_LOCK_HPP 23 | 24 | #include 25 | 26 | namespace MaliSDK 27 | { 28 | 29 | /// @brief Implements a read-write lock. 30 | /// 31 | /// This is a mutex optimized for cases where we almost always have readers 32 | /// locking a data structure, 33 | /// but very rarely writers. 34 | /// On Linux, this is implemented with pthread rw lock. 35 | class ReadWriteLock 36 | { 37 | public: 38 | /// @brief Constructor 39 | ReadWriteLock(); 40 | /// @brief Destructor 41 | ~ReadWriteLock(); 42 | 43 | /// Locks for readers. Multiple readers can lock without blocking each other. 44 | void lockRead(); 45 | /// Unlocks for readers. 46 | void unlockRead(); 47 | /// Locks for writes. Only one writer (and no readers) can be inside critical 48 | /// regions at the same time. 49 | void lockWrite(); 50 | /// Unlocks for writes. 51 | void unlockWrite(); 52 | 53 | private: 54 | /// Pimpl idiom. Hides implementation details. 55 | struct Impl; 56 | /// The pimpl. 57 | std::unique_ptr pImpl; 58 | }; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /platform/wayland/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | file(GLOB sources-headers *.hpp) 3 | 4 | add_library(platform-wayland STATIC 5 | ${sources} 6 | ${sources-headers}) 7 | 8 | target_link_libraries(platform-wayland platform) 9 | 10 | if (WAYLAND_LIB_DIR) 11 | set(WAYLAND_LIB_DIR "-L${WAYLAND_LIB_DIR}") 12 | endif(WAYLAND_LIB_DIR) 13 | 14 | target_link_libraries(platform-wayland framework platform-wsi platform-asset-manager ${WAYLAND_LIB_DIR} -lwayland-client) 15 | 16 | if(WAYLAND_INCLUDE_DIR) 17 | target_include_directories(platform-wayland PUBLIC ${WAYLAND_INCLUDE_DIR}) 18 | endif(WAYLAND_INCLUDE_DIR) 19 | 20 | -------------------------------------------------------------------------------- /platform/wayland/wayland.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 2 | * 3 | * SPDX-License-Identifier: MIT 4 | * 5 | * Permission is hereby granted, free of charge, 6 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #ifndef PLATFORM_WAYLAND_HPP 22 | #define PLATFORM_WAYLAND_HPP 23 | 24 | #include "platform.hpp" 25 | #include "platform/os/linux.hpp" 26 | #include "platform/wsi/wsi.hpp" 27 | 28 | namespace MaliSDK 29 | { 30 | 31 | /// @brief Wayland specific data 32 | struct WaylandData 33 | { 34 | /// The display 35 | wl_display *dpy; 36 | 37 | /// The surface 38 | wl_surface *surf; 39 | 40 | /// The registry 41 | wl_registry *registry; 42 | 43 | /// The compositor 44 | wl_compositor *compositor; 45 | 46 | /// The shell surface 47 | wl_shell_surface *shellSurf; 48 | 49 | /// The shell 50 | wl_shell *shell; 51 | 52 | /// The status, set to TearDown when user exits. 53 | Platform::Status status; 54 | 55 | /// The wayland file descriptor. 56 | int fd; 57 | }; 58 | 59 | /// @brief The Wayland specific platform. Inherits from WSIPlatform. 60 | class WaylandPlatform : public WSIPlatform 61 | { 62 | public: 63 | WaylandPlatform(); 64 | virtual ~WaylandPlatform(); 65 | 66 | /// @brief Initialize the platform. 67 | /// @returns Error code 68 | virtual Result initialize() override; 69 | 70 | /// @brief Gets the preferred swapchain size. 71 | /// @returns Error code. 72 | virtual SwapchainDimensions getPreferredSwapchain() override; 73 | 74 | /// @brief Creates a window with desired swapchain dimensions. 75 | /// 76 | /// The swapchain parameters might not necessarily be honored by the platform. 77 | /// Use @ref getCurrentSwapchain to query the dimensions we actually 78 | /// initialized. 79 | /// @returns Error code. 80 | virtual Result createWindow(const SwapchainDimensions &swapchain) override; 81 | 82 | /// @brief Gets current window status. 83 | /// @returns Window status. 84 | virtual Status getWindowStatus() override; 85 | 86 | /// @brief Presents an image to the swapchain. 87 | /// @param index The swapchain index previously obtained from @ref 88 | /// acquireNextImage. 89 | /// @returns Error code. 90 | virtual Result presentImage(unsigned index) override; 91 | 92 | /// @brief Terminates the platform. 93 | virtual void terminate() override; 94 | 95 | private: 96 | struct WaylandData waylandData; 97 | 98 | Result initWindow(); 99 | void flushWaylandFd(); 100 | 101 | LinuxAssetManager assetManager; 102 | virtual VkSurfaceKHR createSurface() override; 103 | }; 104 | } 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /platform/xcb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | file(GLOB sources-headers *.hpp) 3 | 4 | add_library(platform-xcb STATIC 5 | ${sources} 6 | ${sources-headers}) 7 | 8 | target_link_libraries(platform-xcb platform) 9 | 10 | if (XCB_LIB_DIR) 11 | set(XCB_LIB_DIR "-L${XCB_LIB_DIR}") 12 | endif(XCB_LIB_DIR) 13 | 14 | target_link_libraries(platform-xcb framework platform-wsi platform-asset-manager ${XCB_LIB_DIR} -lxcb-util -lxcb) 15 | 16 | if(XCB_INCLUDE_DIR) 17 | target_include_directories(platform-xcb PUBLIC ${XCB_INCLUDE_DIR}) 18 | endif(XCB_INCLUDE_DIR) 19 | 20 | -------------------------------------------------------------------------------- /platform/xcb/xcb.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_XCB_HPP 2 | #define PLATFORM_XCB_HPP 3 | 4 | #include "platform.hpp" 5 | #include "platform/os/linux.hpp" 6 | #include "platform/wsi/wsi.hpp" 7 | 8 | namespace MaliSDK 9 | { 10 | 11 | /// @brief The XCB specific platform. Inherits from WSIPlatform. 12 | class XCBPlatform : public WSIPlatform 13 | { 14 | public: 15 | XCBPlatform(); 16 | virtual ~XCBPlatform(); 17 | 18 | /// @brief Initialize the platform. 19 | /// @returns Error code. 20 | virtual Result initialize() override; 21 | 22 | /// @brief Gets the preferred swapchain size. 23 | /// @returns Error code. 24 | virtual SwapchainDimensions getPreferredSwapchain() override; 25 | 26 | /// @brief Creates a window with desired swapchain dimensions. 27 | /// 28 | /// The swapchain parameters might not necessarily be honored by the platform. 29 | /// Use @ref getCurrentSwapchain to query the dimensions we actually 30 | /// initialized. 31 | /// @returns Error code. 32 | virtual Result createWindow(const SwapchainDimensions &swapchain) override; 33 | 34 | /// @brief Gets current window status. 35 | /// @returns Window status. 36 | virtual Status getWindowStatus() override; 37 | 38 | /// @brief Presents an image to the swapchain. 39 | /// @param index The swapchain index previously obtained from @ref 40 | /// acquireNextImage. 41 | /// @returns Error code. 42 | virtual Result presentImage(unsigned index) override; 43 | 44 | /// @brief Terminates the platform. 45 | virtual void terminate() override; 46 | 47 | private: 48 | xcb_connection_t *connection; 49 | xcb_window_t window; 50 | Platform::Status status; 51 | xcb_intern_atom_reply_t *atom_delete_window; 52 | 53 | void handleEvents(); 54 | 55 | LinuxAssetManager assetManager; 56 | virtual VkSurfaceKHR createSurface() override; 57 | }; 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(hellotriangle) 2 | add_subdirectory(rotating_texture) 3 | add_subdirectory(basic_compute) 4 | add_subdirectory(multithreading) 5 | add_subdirectory(multisampling) 6 | add_subdirectory(spinning_cube) 7 | add_subdirectory(multipass) 8 | add_subdirectory(astc) 9 | add_subdirectory(mipmapping) 10 | -------------------------------------------------------------------------------- /samples/astc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(astc "${sources}") 3 | -------------------------------------------------------------------------------- /samples/astc/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/astc/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/astc/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/astc/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/astc/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/astc/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/astc/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/astc/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ ASTC 4 | 5 | -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-astc-12x12.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-astc-12x12.astc -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-astc-12x12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-astc-12x12.png -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-astc-4x4.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-astc-4x4.astc -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-astc-4x4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-astc-4x4.png -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-astc-6x6.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-astc-6x6.astc -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-astc-6x6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-astc-6x6.png -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-astc-8x8.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-astc-8x8.astc -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-astc-8x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-astc-8x8.png -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon-fallback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon-fallback.png -------------------------------------------------------------------------------- /samples/astc/assets/textures/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/astc/assets/textures/icon.png -------------------------------------------------------------------------------- /samples/astc/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/astc/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/astc/shaders/textured.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 FragColor; 25 | layout(location = 0) in highp vec2 vTexCoord; 26 | 27 | layout(set = 0, binding = 0) uniform sampler2D sTexture; 28 | 29 | void main() 30 | { 31 | FragColor = texture(sTexture, vTexCoord); 32 | } 33 | -------------------------------------------------------------------------------- /samples/astc/shaders/textured.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec2 Position; 23 | layout(location = 1) in vec2 TexCoord; 24 | 25 | layout(location = 0) out highp vec2 vTexCoord; 26 | 27 | layout(set = 0, binding = 1, std140) uniform UBO 28 | { 29 | mat4 MVP; 30 | }; 31 | 32 | void main() 33 | { 34 | gl_Position = MVP * vec4(Position, 0.0, 1.0); 35 | vTexCoord = TexCoord; 36 | 37 | // astcenc Y-flips input PNG textures, so compensate for that here. 38 | vTexCoord.y = 1.0 - vTexCoord.y; 39 | } 40 | -------------------------------------------------------------------------------- /samples/basic_compute/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(basic_compute "${sources}") 3 | -------------------------------------------------------------------------------- /samples/basic_compute/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/basic_compute/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/basic_compute/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/basic_compute/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic_compute/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/basic_compute/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic_compute/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/basic_compute/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic_compute/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/basic_compute/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic_compute/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/basic_compute/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/basic_compute/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ Basic Compute 4 | 5 | -------------------------------------------------------------------------------- /samples/basic_compute/assets/textures/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/basic_compute/assets/textures/icon.png -------------------------------------------------------------------------------- /samples/basic_compute/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/basic_compute/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/basic_compute/shaders/particle.comp: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(local_size_x = 64) in; 23 | 24 | layout(set = 0, binding = 0, std430) buffer Positions 25 | { 26 | vec2 pos[]; 27 | } positions; 28 | 29 | layout(set = 0, binding = 1, std430) readonly buffer Velocity 30 | { 31 | vec2 vel[]; 32 | } velocities; 33 | 34 | void main() 35 | { 36 | vec2 current_pos = positions.pos[gl_GlobalInvocationID.x]; 37 | vec2 velocity = velocities.vel[gl_GlobalInvocationID.x]; 38 | current_pos += velocity; 39 | 40 | if (current_pos.x > 0.95 || 41 | current_pos.x < -0.95 || 42 | current_pos.y > 0.95 || 43 | current_pos.y < -0.95) 44 | { 45 | current_pos = -2.0 * velocity + current_pos * 0.05; 46 | } 47 | 48 | positions.pos[gl_GlobalInvocationID.x] = current_pos; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /samples/basic_compute/shaders/particle.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 FragColor; 25 | layout(location = 0) in mediump vec4 vColor; 26 | 27 | float falloff(vec2 point_coord) 28 | { 29 | vec2 center_dist = point_coord - 0.5; 30 | float dist_sqr = dot(center_dist, center_dist); 31 | return exp2(-dist_sqr * 15.0); 32 | } 33 | 34 | void main() 35 | { 36 | vec2 coord = gl_PointCoord.xy; 37 | FragColor = vec4(falloff(coord) * vColor.rgb, vColor.a); 38 | } 39 | -------------------------------------------------------------------------------- /samples/basic_compute/shaders/particle.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec2 Position; 23 | layout(location = 1) in vec4 Color; 24 | 25 | layout(location = 0) out mediump vec4 vColor; 26 | 27 | void main() 28 | { 29 | gl_Position = vec4(Position, 0.0, 1.0); 30 | gl_PointSize = 10.0 * exp2(dot(Position, Position) * -3.0); 31 | vColor = Color; 32 | } 33 | -------------------------------------------------------------------------------- /samples/hellotriangle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(hellotriangle "${sources}") 3 | -------------------------------------------------------------------------------- /samples/hellotriangle/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/hellotriangle/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/hellotriangle/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/hellotriangle/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/hellotriangle/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/hellotriangle/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/hellotriangle/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/hellotriangle/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/hellotriangle/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/hellotriangle/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/hellotriangle/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/hellotriangle/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/hellotriangle/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ HelloTriangle 4 | 5 | -------------------------------------------------------------------------------- /samples/hellotriangle/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/hellotriangle/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/hellotriangle/shaders/triangle.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 FragColor; 25 | layout(location = 0) in mediump vec4 vColor; 26 | 27 | void main() 28 | { 29 | FragColor = vColor; 30 | } 31 | -------------------------------------------------------------------------------- /samples/hellotriangle/shaders/triangle.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec4 Position; 23 | layout(location = 1) in vec4 Color; 24 | 25 | layout(location = 0) out mediump vec4 vColor; 26 | 27 | void main() 28 | { 29 | gl_Position = Position; 30 | vColor = Color; 31 | } 32 | -------------------------------------------------------------------------------- /samples/mipmapping/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(mipmapping "${sources}") 3 | -------------------------------------------------------------------------------- /samples/mipmapping/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/mipmapping/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/mipmapping/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/mipmapping/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/mipmapping/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/mipmapping/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/mipmapping/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/mipmapping/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ Mipmapping 4 | 5 | -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Pedestal_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Pedestal_512.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_1.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_128.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_16.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_2.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_256.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_32.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_4.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_512.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_64.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/T_Speaker_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/T_Speaker_8.png -------------------------------------------------------------------------------- /samples/mipmapping/assets/textures/labels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/mipmapping/assets/textures/labels.png -------------------------------------------------------------------------------- /samples/mipmapping/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/mipmapping/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/mipmapping/shaders/textured.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) in highp vec2 vTexCoord; 25 | layout(location = 1) flat in mediump int textureIndex; 26 | layout(location = 2) flat in mediump int highlightSize; 27 | layout(location = 3) flat in mediump int fixedMipLevel; 28 | 29 | layout(location = 0) out vec4 FragColor; 30 | 31 | layout(set = 0, binding = 0) uniform sampler2D sTexture; 32 | layout(set = 0, binding = 1) uniform sampler2D sSizeLabelTexture; 33 | 34 | void main() 35 | { 36 | // Check the texture to be sampled. 37 | if (textureIndex == 1) 38 | { 39 | // If it's the auxiliary one, just sample it. 40 | FragColor = texture(sSizeLabelTexture, vTexCoord); 41 | } 42 | else 43 | { 44 | // Get the hightlight size relative to the normalized texture coordinates. 45 | float normHighlightSize = 0.02 * float(highlightSize); 46 | 47 | // Sample the texture with a fixed mip level. 48 | vec4 sampledColor = textureLod(sTexture, vTexCoord, float(fixedMipLevel)); 49 | 50 | if (vTexCoord.x < normHighlightSize || vTexCoord.x > (1.0 - normHighlightSize) || 51 | vTexCoord.y < normHighlightSize || vTexCoord.y > (1.0 - normHighlightSize)) 52 | { 53 | // Draw the red highlight. 54 | FragColor = vec4(1.0, 0.0, 0.0, 1.0); 55 | } 56 | else 57 | { 58 | // Use the sampled color. 59 | FragColor = sampledColor; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /samples/mipmapping/shaders/textured.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec2 Position; 23 | layout(location = 1) in vec2 TexCoord; 24 | 25 | layout(location = 0) out highp vec2 vTexCoord; 26 | layout(location = 1) flat out mediump int textureIndex; 27 | layout(location = 2) flat out mediump int highlightSize; 28 | layout(location = 3) flat out mediump int fixedMipLevel; 29 | 30 | layout(set = 0, binding = 2, std140) uniform UBO 31 | { 32 | mat4 MVP; 33 | int highlightedQuad; 34 | int mipmapType; 35 | }; 36 | 37 | void main() 38 | { 39 | gl_Position = MVP * vec4(Position, 0.0, 1.0); 40 | vTexCoord = TexCoord; 41 | 42 | // Set the highlighted status. 43 | if (gl_VertexIndex >> 2 == highlightedQuad) 44 | { 45 | // If the vertex is part of the currently highlighted quad, 46 | // set its highlightSize to a non-zero value. 47 | // We also exploit the specific value of this parameter to 48 | // pass some information about the size of the quad to the 49 | // fragment shader: the highlight will need to be larger 50 | // for smaller quads, in proportion. 51 | highlightSize = highlightedQuad + 1; 52 | } 53 | else 54 | { 55 | // No highlight. 56 | highlightSize = 0; 57 | } 58 | 59 | // Set the mip level. 60 | if (gl_VertexIndex < 40) 61 | { 62 | // For the set of quads of decreasing sizes the mip level 63 | // corresponds to the index of the quad. 64 | fixedMipLevel = gl_VertexIndex >> 2; 65 | } 66 | else 67 | { 68 | // The large, fixed size quad is used to showcase the 69 | // stretching of smaller mip layers, so we'll fix its 70 | // mip level to the one of the currently highlighted quad. 71 | fixedMipLevel = highlightedQuad; 72 | } 73 | 74 | // Set the texture index and coordinates: 75 | // - index 0: the main texture; 76 | // - index 1: the auxiliary texture for labels. 77 | // 78 | // The auxiliary texture is split in 12 horizontal sections, 79 | // the first 10 corresponding to the quad sizes 80 | // and the last 2 corresponding to the mipmap types. 81 | if (gl_VertexIndex >= 48) 82 | { 83 | // Set the auxiliary texture and rescale the y coordinate to 84 | // pick the current mipmap type. 85 | textureIndex = 1; 86 | vTexCoord.y = (10.0 + vTexCoord.y + float(mipmapType)) / 12.0; 87 | } 88 | else if (gl_VertexIndex >= 44) 89 | { 90 | // Set the auxiliary texture and rescale the y coordinate to 91 | // pick the currently highlighted quad size. 92 | textureIndex = 1; 93 | vTexCoord.y = (vTexCoord.y + float(highlightedQuad)) / 12.0; 94 | } 95 | else 96 | { 97 | // Set the main texture. 98 | textureIndex = 0; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /samples/multipass/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(multipass "${sources}") 3 | -------------------------------------------------------------------------------- /samples/multipass/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/multipass/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/multipass/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multipass/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multipass/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multipass/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multipass/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multipass/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multipass/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multipass/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multipass/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multipass/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multipass/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ Multipass 4 | 5 | -------------------------------------------------------------------------------- /samples/multipass/assets/textures/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multipass/assets/textures/texture.png -------------------------------------------------------------------------------- /samples/multipass/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/multipass/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/multipass/shaders/debug.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 outLight; 25 | 26 | layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput albedo; 27 | layout(input_attachment_index = 1, set = 0, binding = 1) uniform highp subpassInput depth; 28 | layout(input_attachment_index = 2, set = 0, binding = 2) uniform mediump subpassInput normals; 29 | 30 | layout(push_constant, std430) uniform Registers 31 | { 32 | mat4 inv_view_proj; 33 | vec4 color; 34 | vec4 position; 35 | vec2 inv_resolution; 36 | } registers; 37 | 38 | void main() 39 | { 40 | float x = gl_FragCoord.x * registers.inv_resolution.x; 41 | vec4 color; 42 | if (x < 0.333) 43 | color = vec4(subpassLoad(albedo).rgb, 1.0); 44 | else if (x < 0.666) 45 | color = vec4(subpassLoad(normals).rgb, 1.0); 46 | else 47 | color = vec4(subpassLoad(depth).xxx, 1.0); 48 | outLight = color; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /samples/multipass/shaders/debug.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec4 Position; 23 | 24 | void main() 25 | { 26 | gl_Position = Position; 27 | } 28 | -------------------------------------------------------------------------------- /samples/multipass/shaders/geometry.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) in mediump vec2 vTexCoord; 25 | layout(location = 1) in mediump vec3 vNormal; 26 | 27 | // glslc complains about too few render targets, this is a workaround. 28 | layout(location = 0) out vec4 outputs[3]; 29 | 30 | layout(set = 0, binding = 0) uniform sampler2D tex; 31 | 32 | void main() 33 | { 34 | vec3 albedo = texture(tex, vTexCoord).rgb; 35 | 36 | // Emissive. Make the ARM logo emissive blue. 37 | vec3 graydiff = albedo - dot(albedo, vec3(0.29, 0.60, 0.11)); 38 | float emissive = 3.0 * smoothstep(0.02, 0.1, dot(graydiff, graydiff)); 39 | outputs[0] = vec4(emissive * albedo, 1.0); 40 | 41 | // Albedo 42 | outputs[1] = vec4(albedo, 1.0); 43 | // Normals, pack -1, +1 range to 0, 1. 44 | outputs[2] = vec4(0.5 * normalize(vNormal) + 0.5, 1.0); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /samples/multipass/shaders/geometry.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec3 Position; 23 | layout(location = 1) in vec2 TexCoord; 24 | layout(location = 2) in vec3 Normal; 25 | layout(location = 3) in vec3 InstanceOffset; 26 | 27 | layout(location = 0) out mediump vec2 vTexCoord; 28 | layout(location = 1) out mediump vec3 vNormal; 29 | 30 | layout(std430, push_constant) uniform PushConstants 31 | { 32 | mat4 model; 33 | mat4 vp; 34 | } constants; 35 | 36 | void main() 37 | { 38 | vec3 pos = Position + InstanceOffset; 39 | vec4 rotated = constants.model * vec4(pos, 1.0); 40 | vTexCoord = TexCoord; 41 | vNormal = mat3(constants.model) * Normal; 42 | 43 | gl_Position = constants.vp * rotated; 44 | } 45 | -------------------------------------------------------------------------------- /samples/multipass/shaders/light.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 outLight; 25 | 26 | layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput albedo; 27 | layout(input_attachment_index = 1, set = 0, binding = 1) uniform highp subpassInput depth; 28 | layout(input_attachment_index = 2, set = 0, binding = 2) uniform mediump subpassInput normals; 29 | 30 | layout(push_constant, std430) uniform Registers 31 | { 32 | mat4 inv_view_proj; 33 | vec4 color; 34 | vec4 position; 35 | vec2 inv_resolution; 36 | } registers; 37 | 38 | void main() 39 | { 40 | // Load G-Buffer albedo from tile buffer. 41 | vec4 color = subpassLoad(albedo); 42 | 43 | // Load depth from tile buffer and reconstruct world position. 44 | vec4 clip = vec4(gl_FragCoord.xy * registers.inv_resolution * 2.0 - 1.0, subpassLoad(depth).x, 1.0); 45 | highp vec4 world_w = registers.inv_view_proj * clip; 46 | highp vec3 world = world_w.xyz / world_w.w; 47 | 48 | // Load normal from tile buffer. 49 | vec3 normal = 2.0 * subpassLoad(normals).xyz - 1.0; 50 | 51 | // Basic point light shading. 52 | vec3 world_to_light = registers.position.xyz - world; 53 | float dist = length(world_to_light); 54 | float atten = 1.0 - smoothstep(0.5 * registers.position.w, registers.position.w, dist); 55 | world_to_light = normalize(world_to_light); 56 | float ndotl = clamp(dot(normal, world_to_light), 0.0, 1.0); 57 | 58 | outLight = ndotl * atten * registers.color * color; 59 | } 60 | -------------------------------------------------------------------------------- /samples/multipass/shaders/light.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec3 position; 23 | 24 | // Use a uniform here instead of push constants are we have exhausted the push constant space in fragment. 25 | // Fragment processing is much heavier than vertex for these lights, so we favor fragment performance here. 26 | layout(std140, set = 1, binding = 0) uniform UBO 27 | { 28 | mat4 MVP; 29 | }; 30 | 31 | layout(push_constant, std430) uniform Registers 32 | { 33 | mat4 inv_view_proj; 34 | vec4 color; 35 | vec4 position; 36 | vec2 inv_resolution; 37 | } registers; 38 | 39 | void main() 40 | { 41 | gl_Position = MVP * vec4(registers.position.w * position + registers.position.xyz, 1.0); 42 | } 43 | -------------------------------------------------------------------------------- /samples/multisampling/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(multisampling "${sources}") 3 | -------------------------------------------------------------------------------- /samples/multisampling/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/multisampling/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/multisampling/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multisampling/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multisampling/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multisampling/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multisampling/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multisampling/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multisampling/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multisampling/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multisampling/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multisampling/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multisampling/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ Multisampling 4 | 5 | -------------------------------------------------------------------------------- /samples/multisampling/assets/textures/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multisampling/assets/textures/icon.png -------------------------------------------------------------------------------- /samples/multisampling/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/multisampling/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/multisampling/shaders/textured.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 FragColor; 25 | layout(location = 0) in highp vec2 vTexCoord; 26 | 27 | layout(set = 0, binding = 0) uniform sampler2D sTexture; 28 | 29 | void main() 30 | { 31 | FragColor = texture(sTexture, vTexCoord); 32 | } 33 | -------------------------------------------------------------------------------- /samples/multisampling/shaders/textured.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec2 Position; 23 | layout(location = 1) in vec2 TexCoord; 24 | 25 | layout(location = 0) out highp vec2 vTexCoord; 26 | 27 | layout(set = 0, binding = 1, std140) uniform UBO 28 | { 29 | mat4 MVP; 30 | }; 31 | 32 | void main() 33 | { 34 | gl_Position = MVP * vec4(Position, 0.0, 1.0); 35 | vTexCoord = TexCoord; 36 | } 37 | -------------------------------------------------------------------------------- /samples/multithreading/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(multithreading "${sources}") 3 | -------------------------------------------------------------------------------- /samples/multithreading/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/multithreading/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/multithreading/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multithreading/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multithreading/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multithreading/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multithreading/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multithreading/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multithreading/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multithreading/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multithreading/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multithreading/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/multithreading/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ Multithreading 4 | 5 | -------------------------------------------------------------------------------- /samples/multithreading/assets/textures/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/multithreading/assets/textures/icon.png -------------------------------------------------------------------------------- /samples/multithreading/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/multithreading/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/multithreading/shaders/textured.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 FragColor; 25 | layout(location = 0) in highp vec2 vTexCoord; 26 | 27 | layout(set = 0, binding = 0) uniform sampler2D sTexture; 28 | 29 | void main() 30 | { 31 | FragColor = texture(sTexture, vTexCoord); 32 | } 33 | -------------------------------------------------------------------------------- /samples/multithreading/shaders/textured.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec2 Position; 23 | layout(location = 1) in vec2 TexCoord; 24 | 25 | // Per-instance attribute. 26 | layout(location = 2) in vec4 OffsetScale; 27 | 28 | layout(location = 0) out highp vec2 vTexCoord; 29 | 30 | layout(set = 0, binding = 1, std140) uniform UBO 31 | { 32 | mat4 MVP; 33 | }; 34 | 35 | void main() 36 | { 37 | vec4 ClipPos = MVP * vec4(Position * OffsetScale.zw, 0.0, 1.0); 38 | // We're using an orthographic projection, so no need to take w into account. 39 | ClipPos.xy += OffsetScale.xy; 40 | gl_Position = ClipPos; 41 | vTexCoord = TexCoord; 42 | } 43 | -------------------------------------------------------------------------------- /samples/rotating_texture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(rotating_texture "${sources}") 3 | -------------------------------------------------------------------------------- /samples/rotating_texture/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/rotating_texture/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/rotating_texture/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/rotating_texture/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/rotating_texture/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/rotating_texture/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/rotating_texture/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/rotating_texture/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/rotating_texture/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/rotating_texture/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/rotating_texture/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/rotating_texture/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/rotating_texture/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ Rotating Texture 4 | 5 | -------------------------------------------------------------------------------- /samples/rotating_texture/assets/textures/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/rotating_texture/assets/textures/icon.png -------------------------------------------------------------------------------- /samples/rotating_texture/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/rotating_texture/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/rotating_texture/shaders/textured.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 FragColor; 25 | layout(location = 0) in highp vec2 vTexCoord; 26 | 27 | layout(set = 0, binding = 0) uniform sampler2D sTexture; 28 | 29 | void main() 30 | { 31 | FragColor = texture(sTexture, vTexCoord); 32 | } 33 | -------------------------------------------------------------------------------- /samples/rotating_texture/shaders/textured.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec2 Position; 23 | layout(location = 1) in vec2 TexCoord; 24 | 25 | layout(location = 0) out highp vec2 vTexCoord; 26 | 27 | layout(set = 0, binding = 1, std140) uniform UBO 28 | { 29 | mat4 MVP; 30 | }; 31 | 32 | void main() 33 | { 34 | gl_Position = MVP * vec4(Position, 0.0, 1.0); 35 | vTexCoord = TexCoord; 36 | } 37 | -------------------------------------------------------------------------------- /samples/spinning_cube/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | add_sample(spinning_cube "${sources}") 3 | -------------------------------------------------------------------------------- /samples/spinning_cube/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/spinning_cube/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def parent = new File(project.buildFile.absolutePath).parent 4 | parent = new File(parent).parent 5 | def sample = new File(parent).getName() 6 | 7 | android { 8 | compileSdkVersion 23 9 | buildToolsVersion "28.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 23 14 | 15 | ndk { 16 | abiFilters 'armeabi-v7a', 'arm64-v8a' 17 | } 18 | } 19 | 20 | buildTypes { 21 | debug { 22 | externalNativeBuild { 23 | cmake { 24 | arguments "-DANDROID_TOOLCHAIN=clang", 25 | "-DANDROID_STL=c++_static", 26 | "-DPLATFORM=android", 27 | "-DANDROID_ARM_MODE=arm", 28 | "-DANDROID_CPP_FEATURES=exceptions", 29 | "-DFILTER_TARGET=${sample}".toString(), 30 | "-DCMAKE_BUILD_TYPE=Debug" 31 | 32 | targets "${sample}".toString() 33 | } 34 | } 35 | jniDebuggable true 36 | } 37 | release { 38 | externalNativeBuild { 39 | cmake { 40 | arguments "-DANDROID_TOOLCHAIN=clang", 41 | "-DANDROID_STL=c++_static", 42 | "-DPLATFORM=android", 43 | "-DANDROID_ARM_MODE=arm", 44 | "-DANDROID_CPP_FEATURES=exceptions", 45 | "-DFILTER_TARGET=${sample}".toString(), 46 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo" 47 | 48 | targets "${sample}".toString() 49 | } 50 | } 51 | debuggable true 52 | signingConfig signingConfigs.debug 53 | jniDebuggable true 54 | } 55 | } 56 | 57 | sourceSets { 58 | main { 59 | manifest.srcFile 'AndroidManifest.xml' 60 | resources.srcDirs = ['res'] 61 | res.srcDirs = ['res'] 62 | assets.srcDirs = ['assets'] 63 | } 64 | } 65 | 66 | externalNativeBuild { 67 | cmake { 68 | path "../../../CMakeLists.txt" 69 | } 70 | } 71 | } 72 | 73 | dependencies { 74 | } 75 | -------------------------------------------------------------------------------- /samples/spinning_cube/app/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/spinning_cube/app/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/spinning_cube/app/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/spinning_cube/app/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/spinning_cube/app/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/spinning_cube/app/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/spinning_cube/app/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/spinning_cube/app/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/spinning_cube/app/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/spinning_cube/app/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/spinning_cube/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ARM® Mali™ Spinning Cube 4 | 5 | -------------------------------------------------------------------------------- /samples/spinning_cube/assets/textures/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/vulkan-sdk/5611a75d77a739fcf0d7c1223e7ffbcee63c8079/samples/spinning_cube/assets/textures/icon.png -------------------------------------------------------------------------------- /samples/spinning_cube/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /samples/spinning_cube/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /samples/spinning_cube/shaders/textured.frag: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | precision mediump float; 23 | 24 | layout(location = 0) out vec4 FragColor; 25 | layout(location = 0) in highp vec2 vTexCoord; 26 | 27 | layout(set = 0, binding = 0) uniform sampler2D sTexture; 28 | 29 | void main() 30 | { 31 | FragColor = texture(sTexture, vTexCoord); 32 | } 33 | -------------------------------------------------------------------------------- /samples/spinning_cube/shaders/textured.vert: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | /* Copyright (c) 2016-2017, ARM Limited and Contributors 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, 7 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation the rights to 9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | layout(location = 0) in vec3 Position; 23 | layout(location = 1) in vec2 TexCoord; 24 | 25 | layout(location = 0) out highp vec2 vTexCoord; 26 | 27 | layout(std430, push_constant) uniform PushConstants 28 | { 29 | mat4 MVP; 30 | } constants; 31 | 32 | void main() 33 | { 34 | gl_Position = constants.MVP * vec4(Position, 1.0); 35 | vTexCoord = TexCoord; 36 | } 37 | -------------------------------------------------------------------------------- /stub/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | file(GLOB sources-headers *.hpp) 3 | add_library(vulkan-stub STATIC 4 | ${sources} 5 | ${sources-headers}) 6 | 7 | target_include_directories(vulkan-stub PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include) 8 | target_link_libraries(vulkan-stub platform) 9 | 10 | -------------------------------------------------------------------------------- /toolchains/armhf.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR arm) 3 | set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) 4 | set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) 5 | --------------------------------------------------------------------------------