Browse Source

Add Qt6 and Update to Qt5.15

Changes:
- Add Qt6
- Upgrade Qt5.13 to Qt5.15.2
- Separate android files for each Qt major version
- Change DebugUtils to DebugReporter to work on old vulkan versions (still does not work on android 29)
- Some changes to includes to fix the vulkan surface extension issues
master
AliMehrabani 4 months ago
parent
commit
f0111f9a62
  1. 3
      .gitignore
  2. 9
      Resources.qrc
  3. 86
      VkTest.pro
  4. 723
      VkTest.pro.user
  5. 1175
      VkTest.pro.user.9e9cdaa
  6. 284
      VulkanTutorial1.0/ComputeAndGraphics.cpp
  7. 54
      VulkanTutorial1.0/ComputeAndGraphics.h
  8. 7
      VulkanTutorial1.0/Types.h
  9. 85
      VulkanTutorial1.0/VulkanWindow.cpp
  10. 19
      VulkanTutorial1.0/VulkanWindow.h
  11. 19
      android-qt5/AndroidManifest.xml
  12. 28
      android-qt5/build.gradle
  13. 11
      android-qt5/gradle.properties
  14. 0
      android-qt5/gradle/wrapper/gradle-wrapper.jar
  15. 2
      android-qt5/gradle/wrapper/gradle-wrapper.properties
  16. 0
      android-qt5/gradlew
  17. 0
      android-qt5/gradlew.bat
  18. BIN
      android-qt5/libs/arm64-v8a/libVkLayer_khronos_validation.so
  19. BIN
      android-qt5/libs/armeabi-v7a/libVkLayer_khronos_validation.so
  20. BIN
      android-qt5/libs/x86/libVkLayer_khronos_validation.so
  21. BIN
      android-qt5/libs/x86_64/libVkLayer_khronos_validation.so
  22. 15
      android-qt5/res/values/libs.xml
  23. 4
      android-qt5/res/xml/qtprovider_paths.xml
  24. 45
      android-qt5/src/VkTest/VulkanHelper.java
  25. 20
      android-qt6/AndroidManifest.xml
  26. 85
      android-qt6/build.gradle
  27. 18
      android-qt6/gradle.properties
  28. BIN
      android-qt6/gradle/wrapper/gradle-wrapper.jar
  29. 7
      android-qt6/gradle/wrapper/gradle-wrapper.properties
  30. 252
      android-qt6/gradlew
  31. 94
      android-qt6/gradlew.bat
  32. BIN
      android-qt6/libs/arm64-v8a/libVkLayer_khronos_validation.so
  33. BIN
      android-qt6/libs/armeabi-v7a/libVkLayer_khronos_validation.so
  34. BIN
      android-qt6/libs/x86/libVkLayer_khronos_validation.so
  35. BIN
      android-qt6/libs/x86_64/libVkLayer_khronos_validation.so
  36. 21
      android-qt6/res/values/libs.xml
  37. 4
      android-qt6/res/xml/qtprovider_paths.xml
  38. 45
      android-qt6/src/VkTest/VulkanHelper.java
  39. 7
      main.cpp

3
.gitignore

@ -2,3 +2,6 @@
build/
third_party/
glm/
build/
.qtc_clangd/
.idea/

9
Resources.qrc

@ -0,0 +1,9 @@
<RCC>
<qresource prefix="/">
<file>textures/texture.jpg</file>
<file>shaders/VulkanTutorial1.0/ComputeAndGraphics/vertComp.spv</file>
<file>shaders/VulkanTutorial1.0/ComputeAndGraphics/compComp.spv</file>
<file>shaders/VulkanTutorial1.0/ComputeAndGraphics/fragComp.spv</file>
<file>misc/TintMap.xml</file>
</qresource>
</RCC>

86
VkTest.pro

@ -1,6 +1,9 @@
QT += core xml gui
QT += core xml gui widgets
CONFIG += c++17
CONFIG += c++17 debug
QMAKE_CXXFLAGS += \
"-fno-sized-deallocation" \ # this line is here because with c++17 the project won't run.
INCLUDEPATH += \
$$PWD/third_party \
@ -16,6 +19,10 @@ LIBS += \
# -lSDL2main -lSDL2 -lvk-bootstrap \
# -L$$PWD/third_party/fmt/build -lfmt
DEFINES += \
# STB_IMAGE_IMPLEMENTATION \
# TINYOBJLOADER_IMPLEMENTATION \
SOURCES += \
VulkanTutorial1.0/ComputeAndGraphics.cpp \
VulkanTutorial1.0/VulkanWindow.cpp \
@ -45,40 +52,71 @@ DISTFILES += \
android {
QT += \
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
NDK_PATH = /home/ali-mehrabani/host-projects/Android/Sdk/ndk/21.0.6113669
INCLUDEPATH += \
# /usr/include/vulkan \
$$NDK_PATH/platforms/android-29/arch-arm64/usr/lib/
LIBS += -landroid -llog \
-L$$NDK_PATH/platforms/android-29/arch-arm64/usr/lib -lvulkan
DEFINES += \
VK_USE_PLATFORM_ANDROID_KHR
# ANDROID_ABIS = arm64-v8a armeabi-v7a
contains(QT_MAJOR_VERSION, 5) {
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-qt5
OTHER_FILES += android/src/Vulkan \
android-qt5/AndroidManifest.xml \
android-qt5/build.gradle \
android-qt5/gradle/wrapper/gradle-wrapper.jar \
android-qt5/gradle/wrapper/gradle-wrapper.properties \
android-qt5/gradlew \
android-qt5/gradlew.bat \
android-qt5/res/values/libs.xml \
android-qt5/src/VkTest/VulkanHelper.java \
NDK_Version = 23.2.8568313
API_Version = 30
}
contains(QT_MAJOR_VERSION, 6) {
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-qt6
OTHER_FILES += android/src/Vulkan \
android-qt6/AndroidManifest.xml \
android-qt6/build.gradle \
android-qt6/gradle/wrapper/gradle-wrapper.jar \
android-qt6/gradle/wrapper/gradle-wrapper.properties \
android-qt6/gradlew \
android-qt6/gradlew.bat \
android-qt6/res/values/libs.xml \
android-qt6/src/VkTest/VulkanHelper.java \
NDK_Version = 26.1.10909125
API_Version = 34
}
NDK_PATH = /home/ali-mehrabani/host-projects/Android/Sdk/ndk/$$NDK_Version
LIB_VULKAN_PATH = $$NDK_PATH/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android
INCLUDE_VULKAN_PATH = $$NDK_PATH/sources/third_party/vulkan/src/include/
# LIB_VULKAN_PATH = $$PWD/third_party/vulkan1.3/x86_64/lib
# INCLUDE_VULKAN_PATH = $$PWD/third_party/vulkan1.3/x86_64/include
INCLUDEPATH += \
$$INCLUDE_VULKAN_PATH \
# $$NDK_PATH/platforms/android-30/arch-arm64/usr/lib/
OTHER_FILES += android/src/Vulkan \
android/AndroidManifest.xml \
android/build.gradle \
android/gradle/wrapper/gradle-wrapper.jar \
android/gradle/wrapper/gradle-wrapper.properties \
android/gradlew \
android/gradlew.bat \
android/res/values/libs.xml
LIBS += -llog \
-L$$LIB_VULKAN_PATH/$$API_Version -lvulkan \
# -L$$NDK_PATH/platforms/android-30/arch-arm64/usr/lib -lvulkan
-landroid \
}
linux-g++* {
QT += x11extras
LIBS += \
-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi -lvulkan \
LIBS += -lvulkan \
-ldl -lpthread -lX11 \
# -lglfw -lXxf86vm -lXrandr -lXi \
DEFINES += \
VK_USE_PLATFORM_XCB_KHR
INCLUDEPATH += \
/usr/include/vulkan \
/usr/include \
}
RESOURCES += \
Resources.qrc

723
VkTest.pro.user

File diff suppressed because it is too large

1175
VkTest.pro.user.9e9cdaa

File diff suppressed because it is too large

284
VulkanTutorial1.0/ComputeAndGraphics.cpp

@ -3,39 +3,77 @@
#include <QDebug>
#include <set>
#include <random>
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo
, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
auto func = reinterpret_cast<PFN_vkCreateDebugUtilsMessengerEXT>(vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT"));
#include <QDir>
#include <QStandardPaths>
#define VKB_VALIDATION_LAYERS
// VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo
// , const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
// auto func = reinterpret_cast<PFN_vkCreateDebugUtilsMessengerEXT>(vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT"));
// if (func != nullptr) {
// return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
// } else {
// return VK_ERROR_EXTENSION_NOT_PRESENT;
// }
// }
// void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
// auto func = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT"));
// if (func != nullptr) {
// func(instance, debugMessenger, pAllocator);
// }
// }
VkResult CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo
, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pDebugReporter) {
auto func = reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT>(vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT"));
if (func != nullptr) {
return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
return func(instance, pCreateInfo, pAllocator, pDebugReporter);
} else {
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
}
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
auto func = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT"));
void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT debugReporter, const VkAllocationCallbacks* pAllocator) {
auto func = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT"));
if (func != nullptr) {
func(instance, debugMessenger, pAllocator);
func(instance, debugReporter, pAllocator);
}
}
std::vector<char> ComputeAndGraphics::readFile(const std::string& filename) {
const std::string& newFilename = "/home/ali-mehrabani/Qt_projects/VkTest/" + filename;
std::ifstream file(newFilename, std::ios::ate | std::ios::binary);
// const std::string& newFilename = "/home/ali-mehrabani/Qt_projects/VkTest/" + filename;
// std::ifstream file(filename, std::ios::ate | std::ios::binary);
if (!file.is_open()) {
throw std::runtime_error("failed to open file!");
}
// if (!file.is_open()) {
// throw std::runtime_error("failed to open file!");
// }
// size_t fileSize = static_cast<size_t>(file.tellg());
// std::vector<char> buffer(fileSize);
// file.seekg(0);
// file.read(buffer.data(), static_cast<std::streamsize>(fileSize));
// file.close();
const QString filePath = QString::fromUtf8(filename.c_str());
QFile file(filePath);
size_t fileSize = static_cast<size_t>(file.tellg());
std::vector<char> buffer(fileSize);
file.seekg(0);
file.read(buffer.data(), static_cast<std::streamsize>(fileSize));
if (!file.open(QIODevice::ReadOnly)) {
qWarning() << "Failed to open file:" << filePath << file.errorString();
return {};
}
// Read the entire file as binary
QByteArray fileData = file.readAll();
file.close();
// Convert to std::vector<char>
std::vector<char> buffer = std::vector<char>(fileData.begin(), fileData.end());
return buffer;
}
@ -75,15 +113,17 @@ void ComputeAndGraphics::initWindow(VulkanWindow* window)
//}
void ComputeAndGraphics::initVulkan()
{
// if (enableValidationLayers && !checkValidationLayerSupport()) {
// throw std::runtime_error("validation layers requested, but not available!");
// }
if (enableValidationLayers && !checkValidationLayerSupport()) {
throw std::runtime_error("validation layers requested, but not available!");
}
createInstance();
setupDebugMessenger();
// setupDebugMessenger();
setupDebugReporter();
createSurface();
pickPhysicalDevice();
createLogicalDevice();
@ -113,6 +153,8 @@ void ComputeAndGraphics::initVulkan()
createCommandBuffer();
createComputeCommandBuffers();
createSyncObjects();
qDebug() << "vulkan init is done!";
}
bool ComputeAndGraphics::checkValidationLayerSupport()
@ -146,32 +188,69 @@ VkApplicationInfo ComputeAndGraphics::createInstanceAppInfo()
VkApplicationInfo appInfo{};
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appInfo.pApplicationName = "Vulkan App";
appInfo.applicationVersion = VK_MAKE_VERSION(1, 1, 0);
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
appInfo.pEngineName = "No Engine";
appInfo.engineVersion = VK_MAKE_VERSION(1, 1, 0);
appInfo.apiVersion = VK_API_VERSION_1_1;
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
appInfo.apiVersion = VK_API_VERSION_1_0;
return appInfo;
}
VkDebugUtilsMessengerCreateInfoEXT ComputeAndGraphics::createInstanceDebugMessengerInfo()
{
VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
// VkDebugUtilsMessengerCreateInfoEXT ComputeAndGraphics::createInstanceDebugMessengerInfo()
// {
// VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
// createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
// createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT
// | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
// | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
// createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT
// | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT
// | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
createInfo.pfnUserCallback = debugCallback;
// createInfo.pfnUserCallback = debugCallback;
// return createInfo;
// }
VkDebugReportCallbackCreateInfoEXT ComputeAndGraphics::createInstanceDebugReporterInfo()
{
VkDebugReportCallbackCreateInfoEXT createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
createInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT |
VK_DEBUG_REPORT_DEBUG_BIT_EXT |
// VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT |
VK_DEBUG_REPORT_INFORMATION_BIT_EXT |
VK_DEBUG_REPORT_WARNING_BIT_EXT;
createInfo.pfnCallback = debugReportCallback;
return createInfo;
}
VkInstanceCreateInfo ComputeAndGraphics::createInstanceInfo(VkApplicationInfo* appInfo, std::vector<const char *>& extensions
, VkDebugUtilsMessengerCreateInfoEXT& debugCreateInfo)
// VkInstanceCreateInfo ComputeAndGraphics::createInstanceInfo(VkApplicationInfo* appInfo, std::vector<const char *>& extensions
// , VkDebugUtilsMessengerCreateInfoEXT& debugCreateInfo)
// {
// VkInstanceCreateInfo createInfo = {};
// createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
// createInfo.pApplicationInfo = appInfo;
// createInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size());
// createInfo.ppEnabledExtensionNames = extensions.data();
// if (enableValidationLayers) {
// createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
// createInfo.ppEnabledLayerNames = validationLayers.data();
// debugCreateInfo = createInstanceDebugMessengerInfo();
// createInfo.pNext = dynamic_cast<VkDebugUtilsMessengerCreateInfoEXT*>(&debugCreateInfo);
// } else {
// createInfo.enabledLayerCount = 0;
// createInfo.pNext = nullptr;
// }
// return createInfo;
// }
VkInstanceCreateInfo ComputeAndGraphics::createInstanceInfoOld(VkApplicationInfo* appInfo, std::vector<const char *>& extensions
, VkDebugReportCallbackCreateInfoEXT& debugCreateInfo)
{
VkInstanceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
@ -183,8 +262,8 @@ VkInstanceCreateInfo ComputeAndGraphics::createInstanceInfo(VkApplicationInfo* a
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
createInfo.ppEnabledLayerNames = validationLayers.data();
debugCreateInfo = createInstanceDebugMessengerInfo();
createInfo.pNext = dynamic_cast<VkDebugUtilsMessengerCreateInfoEXT*>(&debugCreateInfo);
debugCreateInfo = createInstanceDebugReporterInfo();
createInfo.pNext = dynamic_cast<VkDebugReportCallbackCreateInfoEXT*>(&debugCreateInfo);
} else {
createInfo.enabledLayerCount = 0;
createInfo.pNext = nullptr;
@ -198,8 +277,11 @@ void ComputeAndGraphics::createInstance()
VkApplicationInfo appInfo = createInstanceAppInfo();
auto extensions = getRequiredExtensions();
VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo{};
VkInstanceCreateInfo createInfo = createInstanceInfo(&appInfo, extensions, debugCreateInfo);
// VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo{};
// VkInstanceCreateInfo createInfo = createInstanceInfo(&appInfo, extensions, debugCreateInfo);
VkDebugReportCallbackCreateInfoEXT debugCreateInfo{};
VkInstanceCreateInfo createInfo = createInstanceInfoOld(&appInfo, extensions, debugCreateInfo);
if (vkCreateInstance(&createInfo, nullptr, &_instance) != VK_SUCCESS) {
throw std::runtime_error("failed to create instance!");
@ -211,6 +293,7 @@ std::vector<const char*> ComputeAndGraphics::getRequiredExtensions()
std::vector<const char*> extensions;
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
#if defined(Q_OS_ANDROID)
extensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
@ -219,26 +302,41 @@ std::vector<const char*> ComputeAndGraphics::getRequiredExtensions()
#endif
if (enableValidationLayers) {
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
// extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
}
return extensions;
}
void ComputeAndGraphics::setupDebugMessenger() {
void ComputeAndGraphics::setupDebugReporter() {
if (!enableValidationLayers)
{
return;
}
VkDebugUtilsMessengerCreateInfoEXT createInfo = createInstanceDebugMessengerInfo();
createInfo.pfnUserCallback = debugCallback;
VkDebugReportCallbackCreateInfoEXT createInfo = createInstanceDebugReporterInfo();
createInfo.pfnCallback = debugReportCallback;
if (CreateDebugUtilsMessengerEXT(_instance, &createInfo, nullptr, &_debugMessenger) != VK_SUCCESS) {
throw std::runtime_error("failed to set up debug messenger!");
if (CreateDebugReportCallbackEXT(_instance, &createInfo, nullptr, &_debugReporter) != VK_SUCCESS) {
throw std::runtime_error("failed to set up debug reporter!");
}
}
// void ComputeAndGraphics::setupDebugMessenger() {
// if (!enableValidationLayers)
// {
// return;
// }
// VkDebugUtilsMessengerCreateInfoEXT createInfo = createInstanceDebugMessengerInfo();
// createInfo.pfnUserCallback = debugCallback;
// if (CreateDebugUtilsMessengerEXT(_instance, &createInfo, nullptr, &_debugMessenger) != VK_SUCCESS) {
// throw std::runtime_error("failed to set up debug messenger!");
// }
// }
void ComputeAndGraphics::createSurface()
{
// if (glfwCreateWindowSurface(_instance, _window, nullptr, &_surface) != VK_SUCCESS) {
@ -297,8 +395,9 @@ bool ComputeAndGraphics::isDeviceSuitable(VkPhysicalDevice device) {
VkPhysicalDeviceFeatures supportedFeatures;
vkGetPhysicalDeviceFeatures(device, &supportedFeatures);
// supportedFeatures.samplerAnisotropy not supported on Galaxy S9
return indices.isComplete() && extensionsSupported && swapChainAdequate && supportedFeatures.samplerAnisotropy;
return indices.isComplete() && extensionsSupported && swapChainAdequate;
}
bool ComputeAndGraphics::checkDeviceExtensionSupport(VkPhysicalDevice device) {
@ -311,7 +410,6 @@ bool ComputeAndGraphics::checkDeviceExtensionSupport(VkPhysicalDevice device) {
std::set<std::string> requiredExtensions(deviceExtensions.begin(), deviceExtensions.end());
for (const auto& extension : availableExtensions) {
// qDebug() << extension.extensionName;
requiredExtensions.erase(extension.extensionName);
}
@ -416,7 +514,7 @@ VkDeviceQueueCreateInfo ComputeAndGraphics::createQueueInfo(uint32_t queueFamily
VkPhysicalDeviceFeatures ComputeAndGraphics::createDeviceCoreFeatures()
{
VkPhysicalDeviceFeatures deviceFeatures{};
deviceFeatures.samplerAnisotropy = VK_TRUE;
deviceFeatures.samplerAnisotropy = VK_FALSE;
return deviceFeatures;
}
@ -748,8 +846,8 @@ VkDescriptorSetLayoutBinding ComputeAndGraphics::createLayoutBindingInfo(uint32_
void ComputeAndGraphics::createGraphicsPipeline()
{
auto vertShaderCode = readFile("shaders/VulkanTutorial1.0/ComputeAndGraphics/vertComp.spv");
auto fragShaderCode = readFile("shaders/VulkanTutorial1.0/ComputeAndGraphics/fragComp.spv");
auto vertShaderCode = readFile(":/shaders/VulkanTutorial1.0/ComputeAndGraphics/vertComp.spv");
auto fragShaderCode = readFile(":/shaders/VulkanTutorial1.0/ComputeAndGraphics/fragComp.spv");
VkShaderModule vertShaderModule = createShaderModule(vertShaderCode);
VkShaderModule fragShaderModule = createShaderModule(fragShaderCode);
VkPipelineShaderStageCreateInfo vertShaderStageInfo = createPipelineShaderInfo(VK_SHADER_STAGE_VERTEX_BIT, vertShaderModule);
@ -958,7 +1056,7 @@ VkPipelineColorBlendStateCreateInfo ComputeAndGraphics::colorPipelineBlendStateI
void ComputeAndGraphics::createComputePipeline()
{
auto computeShaderCode = readFile("shaders/VulkanTutorial1.0/ComputeAndGraphics/compComp.spv");
auto computeShaderCode = readFile(":/shaders/VulkanTutorial1.0/ComputeAndGraphics/compComp.spv");
VkShaderModule computeShaderModule = createShaderModule(computeShaderCode);
VkPipelineShaderStageCreateInfo computeShaderStageInfo = createPipelineShaderInfo(VK_SHADER_STAGE_COMPUTE_BIT, computeShaderModule);
@ -1088,11 +1186,11 @@ bool ComputeAndGraphics::hasStencilComponent(VkFormat format) {
void ComputeAndGraphics::createTextureImage() {
int texWidth, texHeight, texChannels;
stbi_uc* pixels = stbi_load("/home/ali-mehrabani/Qt_projects/VkTest/textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
// stbi_uc* pixels = stbi_load("/home/ali-mehrabani/Qt_projects/VkTest/textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
const char* absPath = getResourceAbsolutePath(":/textures/texture.jpg");
stbi_uc* pixels = stbi_load(absPath, &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
VkDeviceSize imageSize = texWidth * texHeight * 4;
// qDebug() << imageSize;
// qDebug() << texWidth;
// qDebug() << texHeight;
if (!pixels) {
throw std::runtime_error("failed to load texture image!");
@ -1117,6 +1215,57 @@ void ComputeAndGraphics::createTextureImage() {
vkFreeMemory(_device, stagingBufferMemory, nullptr);
}
const char* ComputeAndGraphics::getResourceAbsolutePath(QString resourcePath)
{
const char* absolutePath;
#if defined(Q_OS_ANDROID)
QString inTempPath = resourcePath.mid(2);
absolutePath = copyToTemp(resourcePath, inTempPath).toUtf8().data();
#elif defined(Q_OS_LINUX)
QString linuxPath = "/home/ali-mehrabani/Qt_projects/VkTest/textures/texture.jpg";
absolutePath = linuxPath.toUtf8().data();
#endif
return absolutePath;
}
QString ComputeAndGraphics::copyToTemp(QString resourcePath, QString inTempPath)
{
QString writablePath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir().mkpath(writablePath);
QString outputPath = writablePath + "/" + inTempPath;
if (!QDir().exists(outputPath))
{
QDir().mkpath(outputPath.left(outputPath.lastIndexOf("/")));
QFile resourceFile(resourcePath);
if (!resourceFile.open(QIODevice::ReadOnly)) {
qWarning() << "Failed to open resource file:" << resourcePath << resourceFile.errorString();
return "";
}
QFile outFile(outputPath);
if (!outFile.open(QIODevice::WriteOnly)) {
qWarning() << "Failed to create output file:" << outputPath << outFile.errorString();
return "";
}
outFile.write(resourceFile.readAll());
outFile.flush();
outFile.close();
resourceFile.close();
}
return outputPath;
}
void ComputeAndGraphics::copyImageToStagingBuffer(VkBuffer& stagingBuffer, VkDeviceMemory& stagingBufferMemory, stbi_uc* pixels, VkDeviceSize imageSize)
{
createBuffer(imageSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
@ -1329,7 +1478,7 @@ void ComputeAndGraphics::createTextureSampler()
VkPhysicalDeviceProperties properties{};
vkGetPhysicalDeviceProperties(_physicalDevice, &properties);
samplerInfo.anisotropyEnable = VK_TRUE;
samplerInfo.anisotropyEnable = VK_FALSE;
samplerInfo.maxAnisotropy = properties.limits.maxSamplerAnisotropy;
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
@ -1499,7 +1648,9 @@ uint32_t ComputeAndGraphics::findMemoryType(uint32_t typeFilter, VkMemoryPropert
void ComputeAndGraphics::createShaderStorageBuffers() {
int texWidth, texHeight, texChannels;
stbi_uc* pixels = stbi_load("/home/ali-mehrabani/Qt_projects/VkTest/textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
// stbi_uc* pixels = stbi_load("/home/ali-mehrabani/Qt_projects/VkTest/textures/texture.jpg", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
const char* absPath = getResourceAbsolutePath(":/textures/texture.jpg");
stbi_uc* pixels = stbi_load(absPath, &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
_textureImageSize = texWidth * texHeight * 4;
_textureImageWidth = texWidth;
_textureImageHeight = texHeight;
@ -1538,7 +1689,8 @@ void ComputeAndGraphics::initShaderStorageBuffers(VkBuffer& stagingBuffer, VkDev
void ComputeAndGraphics::createComputeStorageBuffers()
{
QString filePath = "/home/ali-mehrabani/Qt_projects/VkTest/misc/TintMap.xml";
// QString filePath = "/home/ali-mehrabani/Qt_projects/VkTest/misc/TintMap.xml";
QString filePath = ":/misc/TintMap.xml";
QDomDocument doc = openTintMapXML(filePath);
QVector<uint8_t> tintMap = saveTintMapArrays(doc);
@ -1915,6 +2067,7 @@ void ComputeAndGraphics::copyTransformedBufferToTextureImage()
transitionImageLayout(_textureImage, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1);
copyBufferToImage(_shaderTransformedStorageBuffers[currentFrame], _textureImage, _textureImageWidth, _textureImageHeight);
transitionImageLayout(_textureImage, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 1);
// transitionImageLayout(_textureImage, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1);
}
void ComputeAndGraphics::computeSubmission()
@ -2142,10 +2295,10 @@ void ComputeAndGraphics::recordComputeCommandBuffer(VkCommandBuffer commandBuffe
}
void ComputeAndGraphics::updateUniformBuffer(uint32_t currentImage) {
static auto startTime = std::chrono::high_resolution_clock::now();
// static auto startTime = std::chrono::high_resolution_clock::now();
auto currentTime = std::chrono::high_resolution_clock::now();
float time = std::chrono::duration<float, std::chrono::seconds::period>(currentTime - startTime).count();
// auto currentTime = std::chrono::high_resolution_clock::now();
// float time = std::chrono::duration<float, std::chrono::seconds::period>(currentTime - startTime).count();
UniformBufferObject ubo{};
ubo.model = glm::rotate(glm::mat4(1.0f), glm::radians(0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
@ -2262,7 +2415,8 @@ void ComputeAndGraphics::cleanBase()
vkDestroySurfaceKHR(_instance, _surface, nullptr);
if (enableValidationLayers) {
DestroyDebugUtilsMessengerEXT(_instance, _debugMessenger, nullptr);
// DestroyDebugUtilsMessengerEXT(_instance, _debugMessenger, nullptr);
DestroyDebugReportCallbackEXT(_instance, _debugReporter, nullptr);
}
vkDestroyInstance(_instance, nullptr);

54
VulkanTutorial1.0/ComputeAndGraphics.h

@ -15,15 +15,13 @@
#include <chrono>
#include <optional>
#include <cstdint> // Necessary for uint32_t
#include <limits> // Necessary for std::numeric_limits
#include <algorithm> // Necessary for std::clamp
#include <fstream>
#include <array>
#include <QFile>
#include <QDomDocument>
#include <QString>
const int MAX_FRAMES_IN_FLIGHT = 2;
struct QueueFamilyIndices {
@ -93,17 +91,34 @@ public:
void initWindow(VulkanWindow* window);
// Message Callback
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT /*messageSeverity*/,
VkDebugUtilsMessageTypeFlagsEXT /*messageType*/,const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,void* /*pUserData*/) {
// static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT /*messageSeverity*/,
// VkDebugUtilsMessageTypeFlagsEXT /*messageType*/,
// const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
// void* /*pUserData*/) {
// qDebug() << "validation layer: " << pCallbackData->pMessage;
// return VK_FALSE;
// }
std::cerr << "validation layer: " << pCallbackData->pMessage << std::endl;
static VkBool32 VKAPI_PTR debugReportCallback(
VkDebugReportFlagsEXT /*flags*/,
VkDebugReportObjectTypeEXT /*objType*/,
uint64_t /*obj*/,
size_t /*location*/,
int32_t /*messageCode*/,
const char* /*pLayerPrefix*/,
const char* pMessage,
void* /*pUserData*/) {
std::cerr << "Validation Layer: " << pMessage << std::endl;
return VK_FALSE;
}
static std::vector<char> readFile(const std::string& filename);
// static void framebufferResizeCallback(GLFWwindow* window, int width, int height);
// static void framebufferResizeCallback(QQuickWindow* window, int width, int height);
private:
void initVulkan();
@ -193,10 +208,15 @@ private:
void createComputeUniformBuffers();
void updateComputeUniformBuffer(uint32_t currentImage);
void setupDebugReporter();
VkApplicationInfo createInstanceAppInfo();
VkDebugUtilsMessengerCreateInfoEXT createInstanceDebugMessengerInfo();
VkInstanceCreateInfo createInstanceInfo(VkApplicationInfo* appInfo, std::vector<const char*>& extensions
, VkDebugUtilsMessengerCreateInfoEXT& debugCreateInfo);
// VkDebugUtilsMessengerCreateInfoEXT createInstanceDebugMessengerInfo();
VkDebugReportCallbackCreateInfoEXT createInstanceDebugReporterInfo();
// VkInstanceCreateInfo createInstanceInfo(VkApplicationInfo* appInfo, std::vector<const char*>& extensions
// , VkDebugUtilsMessengerCreateInfoEXT& debugCreateInfo);
VkInstanceCreateInfo createInstanceInfoOld(VkApplicationInfo* appInfo, std::vector<const char *>& extensions
, VkDebugReportCallbackCreateInfoEXT& debugCreateInfo);
VkDeviceQueueCreateInfo createQueueInfo(uint32_t queueFamily, uint32_t queueCount, float* queuePriority);
VkPhysicalDeviceFeatures createDeviceCoreFeatures();
@ -285,6 +305,9 @@ private:
QVector<uint8_t> extractIntArrayFromString(QString input, QString delimiter);
void copyDataToStagingBuffer(VkBuffer& stagingBuffer, VkDeviceMemory& stagingBufferMemory, uint8_t* dataIn, VkDeviceSize dataSize);
const char* getResourceAbsolutePath(QString resourcePath);
QString copyToTemp(QString resourcePath, QString inTempPath);
const int32_t WIDTH = 800;
const int32_t HEIGHT = 600;
@ -293,8 +316,10 @@ private:
};
const std::vector<const char*> deviceExtensions = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
// VK_KHR_8BIT_STORAGE_EXTENSION_NAME,
// VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME
VK_KHR_8BIT_STORAGE_EXTENSION_NAME,
VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME,
VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME,
VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME,
};
const std::vector<Vertex> _vertices = {
{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f}, {1.0f, 0.0f}},
@ -318,7 +343,10 @@ private:
// GLFWwindow *_window;
VulkanWindow* _windowQt;
VkInstance _instance;
VkDebugUtilsMessengerEXT _debugMessenger;
// VkDebugUtilsMessengerEXT _debugMessenger;
VkDebugReportCallbackEXT _debugReporter;
VkPhysicalDevice _physicalDevice;
VkDevice _device;
VkQueue _graphicsQueue;

7
VulkanTutorial1.0/Types.h

@ -4,12 +4,6 @@
#include <vulkan/vulkan.h>
#include <iostream>
//#define VK_USE_PLATFORM_
//#define GLFW_INCLUDE_VULKAN
//#include <GLFW/glfw3.h>
//#define GLFW_EXPOSE_NATIVE_
//#include <GLFW/glfw3native.h>
#define GLM_FORCE_RADIANS
//#define GLM_FORCE_DEFAULT_ALIGNED_GENTYPES
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
@ -20,6 +14,7 @@
#include <tiny_obj_loader/tiny_obj_loader.h>
#include <QObject>
#include <QGuiApplication>
struct SwapChainSupportDetails {
VkSurfaceCapabilitiesKHR capabilities;

85
VulkanTutorial1.0/VulkanWindow.cpp

@ -1,45 +1,64 @@
#include "VulkanWindow.h"
// #include <vulkan/vulkan_android.h>
VulkanWindow::VulkanWindow()
{
// setSurfaceType(QWindow::VulkanSurface);
// if (!initVulkanInstance()) {
// qCritical() << "Failed to initialize Vulkan instance!";
// exit(EXIT_FAILURE);
// }
// createVulkanSurface();
setSurfaceType(QWindow::VulkanSurface);
}
VulkanWindow::~VulkanWindow() {
// cleanup();
}
VkSurfaceKHR VulkanWindow::createVulkanSurface(VkInstance instance, VkSurfaceKHR& surface) {
#if defined(Q_OS_ANDROID)
VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
surfaceCreateInfo.window = reinterpret_cast<ANativeWindow*>(winId());
if (vkCreateAndroidSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface) != VK_SUCCESS) {
qCritical() << "Failed to create Vulkan surface on Android.";
exit(EXIT_FAILURE);
}
#elif defined(Q_OS_LINUX)
VkXcbSurfaceCreateInfoKHR surfaceCreateInfo = {};
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
surfaceCreateInfo.connection = QX11Info::connection();
surfaceCreateInfo.window = static_cast<unsigned int>(winId());
if (vkCreateXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface) != VK_SUCCESS) {
qCritical() << "Failed to create Vulkan surface on Linux.";
exit(EXIT_FAILURE);
}
#endif
_surface = surface;
void VulkanWindow::createVulkanSurface(VkInstance instance, VkSurfaceKHR& surface) {
QVulkanInstance* vkInstance = new QVulkanInstance();
vkInstance->setVkInstance(instance);
vkInstance->create();
setVulkanInstance(vkInstance);
VkSurfaceKHR newSurface = QVulkanInstance::surfaceForWindow(this);
surface = newSurface;
qDebug() << "######" << surface << "######";
qDebug() << "######" << newSurface << "######";
if (!surface) {
qDebug() << "############## Failed to retrieve surface using Qt. ##############";
exit(EXIT_FAILURE);
}
// #if defined(Q_OS_ANDROID)
// VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo = {};
// surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
// surfaceCreateInfo.pNext = nullptr;
// surfaceCreateInfo.flags = 0;
// ANativeWindow* nativeWindow = reinterpret_cast<ANativeWindow*>(winId());
// if (!nativeWindow) {
// qCritical() << "Failed to retrieve ANativeWindow using JNI.";
// exit(EXIT_FAILURE);
// }
// surfaceCreateInfo.window = nativeWindow;
// if (vkCreateAndroidSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface) != VK_SUCCESS) {
// qCritical() << "Failed to create Vulkan surface on Android.";
// exit(EXIT_FAILURE);
// }
// #elif defined(Q_OS_LINUX)
// VkXcbSurfaceCreateInfoKHR surfaceCreateInfo = {};
// surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
// surfaceCreateInfo.connection = QX11Info::connection();
// surfaceCreateInfo.window = static_cast<unsigned int>(winId());
// if (vkCreateXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface) != VK_SUCCESS) {
// qCritical() << "Failed to create Vulkan surface on Linux.";
// exit(EXIT_FAILURE);
// }
// #endif
qDebug() << "Vulkan surface created successfully.";
return _surface;
}
void VulkanWindow::getWindowSize(int &width, int &height)
@ -49,7 +68,5 @@ void VulkanWindow::getWindowSize(int &width, int &height)
}
void VulkanWindow::cleanup() {
if (_surface != VK_NULL_HANDLE) {
vkDestroySurfaceKHR(_instance, _surface, nullptr);
}
}

19
VulkanTutorial1.0/VulkanWindow.h

@ -1,23 +1,26 @@
#ifndef VULKANWINDOW_H
#define VULKANWINDOW_H
#include "Types.h"
#include <QObject>
#include <QWindow>
#include <QDebug>
#include "Types.h"
// #include <QVulkanInstance>
#include <QVulkanWindow>
#if defined(Q_OS_ANDROID)
//#define VK_USE_PLATFORM_ANDROID_KHR // Enable Vulkan support for Android (added to qmake file)
#include <vulkan/vulkan_android.h>
// #define VK_USE_PLATFORM_ANDROID_KHR // Enable Vulkan support for Android (added to qmake file)
// #include <vulkan/vulkan_android.h>
#elif defined(Q_OS_LINUX)
#include <xcb/xcb.h>
// #include <xcb/xcb.h>
//#define VK_USE_PLATFORM_XCB_KHR // Enable Vulkan support for Linux (XCB) (added to qmake file)
#include <vulkan/vulkan_xcb.h>
// #include <vulkan/vulkan_xcb.h>
#include <QX11Info>
#endif
class VulkanWindow : public QWindow
class VulkanWindow : public QVulkanWindow
{
Q_OBJECT
@ -25,14 +28,12 @@ public:
VulkanWindow();
virtual ~VulkanWindow();
VkSurfaceKHR createVulkanSurface(VkInstance instance, VkSurfaceKHR& surface);
void createVulkanSurface(VkInstance instance, VkSurfaceKHR& surface);
void getWindowSize(int& width, int& height);
private:
void cleanup();
VkSurfaceKHR _surface;
VkInstance _instance;
};
#endif // VULKANWINDOW_H

19
android/AndroidManifest.xml → android-qt5/AndroidManifest.xml

@ -1,7 +1,5 @@
<?xml version="1.0"?>
<manifest package="src.Vulkan" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
<manifest package="src.VkTest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->
@ -11,18 +9,15 @@
<!-- %%INSERT_FEATURES -->
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:extractNativeLibs="true">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
@ -30,12 +25,10 @@
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Used to specify custom system library path to run with local system libs -->
@ -46,7 +39,6 @@
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- Orientation-specific (portrait/landscape) data is checked first. If not available for current orientation,
then android.app.splash_screen_drawable. For best results, use together with splash_screen_sticky and
@ -57,7 +49,6 @@
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
@ -65,11 +56,9 @@
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
@ -79,7 +68,7 @@
-->
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
</activity>
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->

28
android/build.gradle → android-qt5/build.gradle

@ -1,16 +1,18 @@
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:4.1.3'
}
}
repositories {
google()
mavenCentral()
jcenter()
}
@ -36,7 +38,7 @@ android {
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion '28.0.3'
buildToolsVersion '30.0.3'
sourceSets {
main {
@ -44,14 +46,34 @@ android {
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
tasks.withType(JavaCompile) {
options.incremental = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}
defaultConfig {
resConfig "en"
minSdkVersion = qtMinSdkVersion
targetSdkVersion = qtTargetSdkVersion
}
}

11
android-qt5/gradle.properties

@ -0,0 +1,11 @@
# Project-wide Gradle settings.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m
# Gradle caching allows reusing the build artifacts from a previous
# build with the same inputs. However, over time, the cache size will
# grow. Uncomment the following line to enable it.
#org.gradle.caching=true

0
android/gradle/wrapper/gradle-wrapper.jar → android-qt5/gradle/wrapper/gradle-wrapper.jar

2
android/gradle/wrapper/gradle-wrapper.properties → android-qt5/gradle/wrapper/gradle-wrapper.properties

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0
android/gradlew → android-qt5/gradlew

0
android/gradlew.bat → android-qt5/gradlew.bat

BIN
android-qt5/libs/arm64-v8a/libVkLayer_khronos_validation.so

Binary file not shown.

BIN
android-qt5/libs/armeabi-v7a/libVkLayer_khronos_validation.so

Binary file not shown.

BIN
android-qt5/libs/x86/libVkLayer_khronos_validation.so

Binary file not shown.

BIN
android-qt5/libs/x86_64/libVkLayer_khronos_validation.so

Binary file not shown.

15
android/res/values/libs.xml → android-qt5/res/values/libs.xml

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://download.qt.io/ministro/android/qt5/qt-5.9</item>
<item>https://download.qt.io/ministro/android/qt5/qt-5.14</item>
</array>
<!-- The following is handled automatically by the deployment tool. It should
@ -11,15 +11,12 @@
<!-- %%INSERT_EXTRA_LIBS%% -->
</array>
<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>
<array name="bundled_in_lib">
<!-- %%INSERT_BUNDLED_IN_LIB%% -->
<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>
<array name="bundled_in_assets">
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
<array name="load_local_libs">
<!-- %%INSERT_LOCAL_LIBS%% -->
</array>
</resources>

4
android-qt5/res/xml/qtprovider_paths.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="files_path" path="/"/>
</paths>

45
android-qt5/src/VkTest/VulkanHelper.java

@ -0,0 +1,45 @@
package VkTest;
import android.view.Surface;
import android.content.Context;
import android.app.Activity;
import android.view.SurfaceView;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.Window;
import android.view.View;
import android.widget.FrameLayout;
import android.view.ViewGroup;
public class VulkanHelper {
public static Surface getSurfaceFromNativeWindow(Activity activity) {
Surface surface = null;
// Context context = activity.getApplicationContext();
SurfaceView surfaceView = new SurfaceView(activity);
Window window = activity.getWindow();
View decorView = window.getDecorView();
// View rootView = activity.findViewById(android.R.id.content).getRootView();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
activity.setContentView(surfaceView, params);
surface = surfaceView.getHolder().getSurface();
// if (rootView instanceof SurfaceView) {
// System.out.println("It is a SurfaceView");
// SurfaceHolder holder = ((SurfaceView) rootView).getHolder();
// if (holder != null) {
// return holder.getSurface();
// }
// } else {
// System.out.println("It is not a SurfaceView");
// }
return surface;
}
}

20
android-qt6/AndroidManifest.xml

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="src.VkTest" android:installLocation="auto" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:versionName="-- %%INSERT_VERSION_NAME%% --">
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<application android:name="org.qtproject.qt.android.bindings.QtApplication" android:hardwareAccelerated="true" android:label="-- %%INSERT_APP_NAME%% --" android:requestLegacyExternalStorage="true" android:allowBackup="true" android:fullBackupOnly="false">
<activity android:name="org.qtproject.qt.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:launchMode="singleTop" android:screenOrientation="unspecified" android:exported="true" android:label="">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/>
</activity>
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.qtprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/qtprovider_paths"/>
</provider>
</application>
</manifest>

85
android-qt6/build.gradle

@ -0,0 +1,85 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.6.0'
}
}
repositories {
google()
mavenCentral()
}
apply plugin: qtGradlePluginType
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
//noinspection GradleDependency
implementation 'androidx.core:core:1.13.1'
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qtAndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
* - qtGradlePluginType - whether to build an app or a library
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
namespace androidPackageName
compileSdkVersion androidCompileSdkVersion
buildToolsVersion androidBuildToolsVersion
ndkVersion androidNdkVersion
// Extract native libraries from the APK
packagingOptions.jniLibs.useLegacyPackaging true
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qtAndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qtAndroidDir + '/res', 'res']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
tasks.withType(JavaCompile) {
options.incremental = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}
defaultConfig {
resConfig "en"
minSdkVersion qtMinSdkVersion
targetSdkVersion qtTargetSdkVersion
ndk.abiFilters = qtTargetAbiList.split(",")
}
}

18
android-qt6/gradle.properties

@ -0,0 +1,18 @@
# Project-wide Gradle settings.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2500m -XX:MaxMetaspaceSize=768m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# Enable building projects in parallel
org.gradle.parallel=true
# Gradle caching allows reusing the build artifacts from a previous
# build with the same inputs. However, over time, the cache size will
# grow. Uncomment the following line to enable it.
#org.gradle.caching=true
#org.gradle.configuration-cache=true
# Allow AndroidX usage
android.useAndroidX=true

BIN
android-qt6/gradle/wrapper/gradle-wrapper.jar

Binary file not shown.

7
android-qt6/gradle/wrapper/gradle-wrapper.properties

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

252
android-qt6/gradlew

@ -0,0 +1,252 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

94
android-qt6/gradlew.bat

@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

BIN
android-qt6/libs/arm64-v8a/libVkLayer_khronos_validation.so

Binary file not shown.

BIN
android-qt6/libs/armeabi-v7a/libVkLayer_khronos_validation.so

Binary file not shown.

BIN
android-qt6/libs/x86/libVkLayer_khronos_validation.so

Binary file not shown.

BIN
android-qt6/libs/x86_64/libVkLayer_khronos_validation.so

Binary file not shown.

21
android-qt6/res/values/libs.xml

@ -0,0 +1,21 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<!-- DO NOT EDIT THIS: This file is populated automatically by the deployment tool. -->
<array name="bundled_libs">
<!-- %%INSERT_EXTRA_LIBS%% -->
</array>
<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>
<array name="load_local_libs">
<!-- %%INSERT_LOCAL_LIBS%% -->
</array>
<string name="static_init_classes"><!-- %%INSERT_INIT_CLASSES%% --></string>
<string name="use_local_qt_libs"><!-- %%USE_LOCAL_QT_LIBS%% --></string>
<string name="bundle_local_qt_libs"><!-- %%BUNDLE_LOCAL_QT_LIBS%% --></string>
<string name="system_libs_prefix"><!-- %%SYSTEM_LIBS_PREFIX%% --></string>
</resources>

4
android-qt6/res/xml/qtprovider_paths.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="files_path" path="/"/>
</paths>

45
android-qt6/src/VkTest/VulkanHelper.java

@ -0,0 +1,45 @@
package VkTest;
import android.view.Surface;
import android.content.Context;
import android.app.Activity;
import android.view.SurfaceView;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.Window;
import android.view.View;
import android.widget.FrameLayout;
import android.view.ViewGroup;
public class VulkanHelper {
public static Surface getSurfaceFromNativeWindow(Activity activity) {
Surface surface = null;
// Context context = activity.getApplicationContext();
SurfaceView surfaceView = new SurfaceView(activity);
Window window = activity.getWindow();
View decorView = window.getDecorView();
// View rootView = activity.findViewById(android.R.id.content).getRootView();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
activity.setContentView(surfaceView, params);
surface = surfaceView.getHolder().getSurface();
// if (rootView instanceof SurfaceView) {
// System.out.println("It is a SurfaceView");
// SurfaceHolder holder = ((SurfaceView) rootView).getHolder();
// if (holder != null) {
// return holder.getSurface();
// }
// } else {
// System.out.println("It is not a SurfaceView");
// }
return surface;
}
}

7
main.cpp

@ -6,13 +6,16 @@
//#include <VkMain.h>
#include <iostream>
#include <stdexcept>
#include <cstdlib>
#include<QGuiApplication>
// #include <QAndroidJniObject>
int main(int argc, char *argv[]) {
// qDebug() << "Waiting for debugger...";
// QAndroidJniObject::callStaticMethod<void>("android/os/Debug", "waitForDebugger");
// qDebug() << "Debugger attached!";
QGuiApplication app(argc, argv);
// HelloTriangleApplication vulkanApp;

Loading…
Cancel
Save