mirror of https://github.com/auygun/kaliber.git
Fix for vulkan renderer
This commit is contained in:
parent
0454bf6a18
commit
41bb5e286a
|
@ -25,5 +25,5 @@ cd build/android
|
||||||
[glslang](https://github.com/KhronosGroup/glslang),
|
[glslang](https://github.com/KhronosGroup/glslang),
|
||||||
[spirv-reflect](https://github.com/KhronosGroup/SPIRV-Reflect),
|
[spirv-reflect](https://github.com/KhronosGroup/SPIRV-Reflect),
|
||||||
[vma](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator),
|
[vma](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator),
|
||||||
[vulkan-sdk](https://vulkan.lunarg.com)
|
[vulkan-sdk](https://vulkan.lunarg.com),
|
||||||
[volk](https://github.com/zeux/volk)
|
[volk](https://github.com/zeux/volk)
|
||||||
|
|
|
@ -17,11 +17,6 @@ namespace {
|
||||||
bool g_showing_interstitial_ad = false;
|
bool g_showing_interstitial_ad = false;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_com_kaliber_base_KaliberActivity_onShowAdResult(JNIEnv* env,
|
|
||||||
jobject obj,
|
|
||||||
jboolean succeeded);
|
|
||||||
};
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_kaliber_base_KaliberActivity_onShowAdResult(JNIEnv* env,
|
Java_com_kaliber_base_KaliberActivity_onShowAdResult(JNIEnv* env,
|
||||||
|
@ -30,6 +25,8 @@ Java_com_kaliber_base_KaliberActivity_onShowAdResult(JNIEnv* env,
|
||||||
g_showing_interstitial_ad = !!succeeded;
|
g_showing_interstitial_ad = !!succeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::string GetApkPath(ANativeActivity* activity) {
|
std::string GetApkPath(ANativeActivity* activity) {
|
||||||
JNIEnv* env = nullptr;
|
JNIEnv* env = nullptr;
|
||||||
activity->vm->AttachCurrentThread(&env, nullptr);
|
activity->vm->AttachCurrentThread(&env, nullptr);
|
||||||
|
|
|
@ -708,23 +708,33 @@ bool VulkanContext::InitializeQueues(VkSurfaceKHR surface) {
|
||||||
// If the format list includes just one entry of VK_FORMAT_UNDEFINED, the
|
// If the format list includes just one entry of VK_FORMAT_UNDEFINED, the
|
||||||
// surface has no preferred format. Otherwise, at least one supported format
|
// surface has no preferred format. Otherwise, at least one supported format
|
||||||
// will be returned.
|
// will be returned.
|
||||||
if (true ||
|
if (format_count == 1 && surf_formats[0].format == VK_FORMAT_UNDEFINED) {
|
||||||
(format_count == 1 && surf_formats[0].format == VK_FORMAT_UNDEFINED)) {
|
|
||||||
format_ = desired_format;
|
format_ = desired_format;
|
||||||
|
color_space_ = surf_formats[0].colorSpace;
|
||||||
|
} else if (format_count < 1) {
|
||||||
|
DLOG << "Format count less than 1.";
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (format_count < 1) {
|
// Find the first format that we support.
|
||||||
DLOG << "Format count less than 1.";
|
format_ = VK_FORMAT_UNDEFINED;
|
||||||
return false;
|
const VkFormat allowed_formats[] = {VK_FORMAT_B8G8R8A8_UNORM,
|
||||||
}
|
VK_FORMAT_R8G8B8A8_UNORM};
|
||||||
format_ = surf_formats[0].format;
|
for (uint32_t afi = 0; afi < std::size(allowed_formats); afi++) {
|
||||||
for (unsigned i = 0; i < format_count; ++i) {
|
for (uint32_t sfi = 0; sfi < format_count; sfi++) {
|
||||||
if (surf_formats[i].format == desired_format) {
|
if (surf_formats[sfi].format == allowed_formats[afi]) {
|
||||||
format_ = desired_format;
|
format_ = surf_formats[sfi].format;
|
||||||
break;
|
color_space_ = surf_formats[sfi].colorSpace;
|
||||||
|
goto end_of_find_format;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end_of_find_format:
|
||||||
|
if (format_ == VK_FORMAT_UNDEFINED) {
|
||||||
|
DLOG << "No usable surface format found.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
color_space_ = surf_formats[0].colorSpace;
|
|
||||||
|
|
||||||
if (!CreateSemaphores())
|
if (!CreateSemaphores())
|
||||||
return false;
|
return false;
|
||||||
|
@ -972,10 +982,10 @@ bool VulkanContext::UpdateSwapChain(Window* window) {
|
||||||
VkCompositeAlphaFlagBitsKHR composite_alpha =
|
VkCompositeAlphaFlagBitsKHR composite_alpha =
|
||||||
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||||
VkCompositeAlphaFlagBitsKHR composite_alpha_flags[4] = {
|
VkCompositeAlphaFlagBitsKHR composite_alpha_flags[4] = {
|
||||||
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
|
||||||
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR,
|
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR,
|
||||||
VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR,
|
VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR,
|
||||||
VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR,
|
VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR,
|
||||||
|
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
||||||
};
|
};
|
||||||
for (uint32_t i = 0; i < std::size(composite_alpha_flags); i++) {
|
for (uint32_t i = 0; i < std::size(composite_alpha_flags); i++) {
|
||||||
if (surf_capabilities.supportedCompositeAlpha & composite_alpha_flags[i]) {
|
if (surf_capabilities.supportedCompositeAlpha & composite_alpha_flags[i]) {
|
||||||
|
@ -1019,7 +1029,7 @@ bool VulkanContext::UpdateSwapChain(Window* window) {
|
||||||
err = GetSwapchainImagesKHR(device_, window->swapchain, &sp_image_count,
|
err = GetSwapchainImagesKHR(device_, window->swapchain, &sp_image_count,
|
||||||
nullptr);
|
nullptr);
|
||||||
if (err) {
|
if (err) {
|
||||||
DLOG << "CreateSwapchainKHR failed. Error: " << string_VkResult(err);
|
DLOG << "GetSwapchainImagesKHR failed. Error: " << string_VkResult(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue