Android changes (#1194)

* Update to latest MacOS image

* Minor android cleanup

Removed no longer required std functionality
This commit is contained in:
Sascha Willems 2025-02-28 18:02:15 +01:00 committed by GitHub
parent 495a135c64
commit 42fc44114a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 32 deletions

View file

@ -1,7 +1,7 @@
/* /*
* Android Vulkan function pointer loader * Android Vulkan function pointer loader
* *
* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de * Copyright (C) 2016-2025 by Sascha Willems - www.saschawillems.de
* *
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/ */
@ -359,7 +359,6 @@ namespace vks
jni->DeleteLocalRef(jmessage); jni->DeleteLocalRef(jmessage);
androidApp->activity->vm->DetachCurrentThread(); androidApp->activity->vm->DetachCurrentThread();
return;
} }
} }
} }

View file

@ -1,7 +1,7 @@
/* /*
* Android Vulkan function pointer prototypes * Android Vulkan function pointer prototypes
* *
* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de * Copyright (C) 2016-2025 by Sascha Willems - www.saschawillems.de
* *
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/ */
@ -29,16 +29,6 @@
#include <memory> #include <memory>
#include <string> #include <string>
// Missing from the NDK
namespace std
{
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}
// Global reference to android application object // Global reference to android application object
extern android_app* androidApp; extern android_app* androidApp;

View file

@ -40,7 +40,6 @@ public:
VkDeviceMemory memory{ VK_NULL_HANDLE }; VkDeviceMemory memory{ VK_NULL_HANDLE };
}; };
Image renderImage; Image renderImage;
Image depthStencilRenderImage;
VulkanExample() : VulkanExampleBase() VulkanExample() : VulkanExampleBase()
{ {
@ -67,7 +66,7 @@ public:
deviceCreatepNextChain = &enabledDynamicRenderingFeaturesKHR; deviceCreatepNextChain = &enabledDynamicRenderingFeaturesKHR;
} }
~VulkanExample() ~VulkanExample() override
{ {
if (device) { if (device) {
vkDestroyPipeline(device, pipeline, nullptr); vkDestroyPipeline(device, pipeline, nullptr);
@ -160,7 +159,7 @@ public:
} }
// Enable physical device features required for this example // Enable physical device features required for this example
virtual void getEnabledFeatures() void getEnabledFeatures() override
{ {
// Enable anisotropic filtering if supported // Enable anisotropic filtering if supported
if (deviceFeatures.samplerAnisotropy) { if (deviceFeatures.samplerAnisotropy) {
@ -174,7 +173,7 @@ public:
model.loadFromFile(getAssetPath() + "models/voyager.gltf", vulkanDevice, queue, glTFLoadingFlags); model.loadFromFile(getAssetPath() + "models/voyager.gltf", vulkanDevice, queue, glTFLoadingFlags);
} }
void buildCommandBuffers() void buildCommandBuffers() override
{ {
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
@ -365,7 +364,7 @@ public:
memcpy(uniformBuffer.mapped, &uniformData, sizeof(uniformData)); memcpy(uniformBuffer.mapped, &uniformData, sizeof(uniformData));
} }
void prepare() void prepare() override
{ {
VulkanExampleBase::prepare(); VulkanExampleBase::prepare();
@ -390,7 +389,7 @@ public:
VulkanExampleBase::submitFrame(); VulkanExampleBase::submitFrame();
} }
virtual void render() void render() override
{ {
if (!prepared) if (!prepared)
return; return;

View file

@ -6,7 +6,7 @@
* Contrary to the other examples, this one won't make use of helper functions or initializers * Contrary to the other examples, this one won't make use of helper functions or initializers
* Except in a few cases (swap chain setup e.g.) * Except in a few cases (swap chain setup e.g.)
* *
* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de * Copyright (C) 2016-2025 by Sascha Willems - www.saschawillems.de
* *
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/ */
@ -126,7 +126,7 @@ public:
// Values not set here are initialized in the base class constructor // Values not set here are initialized in the base class constructor
} }
~VulkanExample() ~VulkanExample() override
{ {
// Clean up used Vulkan resources // Clean up used Vulkan resources
// Note: Inherited destructor cleans up resources stored in base class // Note: Inherited destructor cleans up resources stored in base class
@ -452,7 +452,7 @@ public:
// Create the depth (and stencil) buffer attachments used by our framebuffers // Create the depth (and stencil) buffer attachments used by our framebuffers
// Note: Override of virtual function in the base class and called from within VulkanExampleBase::prepare // Note: Override of virtual function in the base class and called from within VulkanExampleBase::prepare
void setupDepthStencil() void setupDepthStencil() override
{ {
// Create an optimal image used as the depth stencil attachment // Create an optimal image used as the depth stencil attachment
VkImageCreateInfo imageCI{}; VkImageCreateInfo imageCI{};
@ -502,7 +502,7 @@ public:
// Create a frame buffer for each swap chain image // Create a frame buffer for each swap chain image
// Note: Override of virtual function in the base class and called from within VulkanExampleBase::prepare // Note: Override of virtual function in the base class and called from within VulkanExampleBase::prepare
void setupFrameBuffer() void setupFrameBuffer() override
{ {
// Create a frame buffer for every image in the swapchain // Create a frame buffer for every image in the swapchain
frameBuffers.resize(swapChain.images.size()); frameBuffers.resize(swapChain.images.size());
@ -533,7 +533,7 @@ public:
// This allows the driver to know up-front what the rendering will look like and is a good opportunity to optimize especially on tile-based renderers (with multiple subpasses) // This allows the driver to know up-front what the rendering will look like and is a good opportunity to optimize especially on tile-based renderers (with multiple subpasses)
// Using sub pass dependencies also adds implicit layout transitions for the attachment used, so we don't need to add explicit image memory barriers to transform them // Using sub pass dependencies also adds implicit layout transitions for the attachment used, so we don't need to add explicit image memory barriers to transform them
// Note: Override of virtual function in the base class and called from within VulkanExampleBase::prepare // Note: Override of virtual function in the base class and called from within VulkanExampleBase::prepare
void setupRenderPass() void setupRenderPass() override
{ {
// This example will use a single render pass with one subpass // This example will use a single render pass with one subpass
@ -622,7 +622,7 @@ public:
// Vulkan loads its shaders from an immediate binary representation called SPIR-V // Vulkan loads its shaders from an immediate binary representation called SPIR-V
// Shaders are compiled offline from e.g. GLSL using the reference glslang compiler // Shaders are compiled offline from e.g. GLSL using the reference glslang compiler
// This function loads such a shader from a binary file and returns a shader module structure // This function loads such a shader from a binary file and returns a shader module structure
VkShaderModule loadSPIRVShader(std::string filename) VkShaderModule loadSPIRVShader(const std::string& filename)
{ {
size_t shaderSize; size_t shaderSize;
char* shaderCode{ nullptr }; char* shaderCode{ nullptr };
@ -886,7 +886,7 @@ public:
} }
void prepare() void prepare() override
{ {
VulkanExampleBase::prepare(); VulkanExampleBase::prepare();
createSynchronizationPrimitives(); createSynchronizationPrimitives();
@ -900,7 +900,7 @@ public:
prepared = true; prepared = true;
} }
virtual void render() void render() override
{ {
if (!prepared) if (!prepared)
return; return;

View file

@ -117,7 +117,7 @@ public:
deviceCreatepNextChain = &enabledFeatures; deviceCreatepNextChain = &enabledFeatures;
} }
~VulkanExample() ~VulkanExample() override
{ {
// Clean up used Vulkan resources // Clean up used Vulkan resources
// Note: Inherited destructor cleans up resources stored in base class // Note: Inherited destructor cleans up resources stored in base class
@ -381,7 +381,7 @@ public:
// Create the depth (and stencil) buffer attachments // Create the depth (and stencil) buffer attachments
// While we don't do any depth testing in this sample, having depth testing is very common so it's a good idea to learn it from the very start // While we don't do any depth testing in this sample, having depth testing is very common so it's a good idea to learn it from the very start
void setupDepthStencil() void setupDepthStencil() override
{ {
// Create an optimal tiled image used as the depth stencil attachment // Create an optimal tiled image used as the depth stencil attachment
VkImageCreateInfo imageCI{ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; VkImageCreateInfo imageCI{ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
@ -428,7 +428,7 @@ public:
// Vulkan loads its shaders from an immediate binary representation called SPIR-V // Vulkan loads its shaders from an immediate binary representation called SPIR-V
// Shaders are compiled offline from e.g. GLSL using the reference glslang compiler // Shaders are compiled offline from e.g. GLSL using the reference glslang compiler
// This function loads such a shader from a binary file and returns a shader module structure // This function loads such a shader from a binary file and returns a shader module structure
VkShaderModule loadSPIRVShader(std::string filename) VkShaderModule loadSPIRVShader(const std::string& filename)
{ {
size_t shaderSize; size_t shaderSize;
char* shaderCode{ nullptr }; char* shaderCode{ nullptr };
@ -661,7 +661,7 @@ public:
} }
void prepare() void prepare() override
{ {
VulkanExampleBase::prepare(); VulkanExampleBase::prepare();
createSynchronizationPrimitives(); createSynchronizationPrimitives();
@ -673,7 +673,7 @@ public:
prepared = true; prepared = true;
} }
virtual void render() override void render() override
{ {
// Use a fence to wait until the command buffer has finished execution before using it again // Use a fence to wait until the command buffer has finished execution before using it again
vkWaitForFences(device, 1, &waitFences[currentFrame], VK_TRUE, UINT64_MAX); vkWaitForFences(device, 1, &waitFences[currentFrame], VK_TRUE, UINT64_MAX);