mirror of
https://github.com/rive-app/rive-cpp.git
synced 2026-01-18 13:11:19 +01:00
fix(vk): Actually apply a workaround for the Android overflow texture (#11273) e6c21bf6fd
We had a nice comment describing why we shouldn't create the overflow texture with VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, but then we went ahead and accidentally created it as an input attachment anyway. This PR actually applies the workaround described in the comment. Also apply the "teardown after every GM" workaround to Adreno pre 1.3 GPUs, since those also experience sporadic crashes and this appears to help. Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
37439d5fb6388d0315fdea9b9772f0213ef1dfbc
|
||||
e6c21bf6fda1caa73297d0cddac565324c9c487c
|
||||
|
||||
@@ -139,28 +139,25 @@ public:
|
||||
makeDeviceAndRenderContext();
|
||||
}
|
||||
|
||||
m_renderTarget =
|
||||
impl()->makeRenderTarget(m_width,
|
||||
m_height,
|
||||
m_swapchain->imageFormat(),
|
||||
m_swapchain->imageUsageFlags());
|
||||
VkImageUsageFlags renderTargetUsageFlags =
|
||||
m_swapchain->imageUsageFlags();
|
||||
if (m_alwaysUseOffscreenTexture || m_width > m_androidWindowWidth ||
|
||||
m_height > m_androidWindowHeight)
|
||||
{
|
||||
VkImageUsageFlags overflowTextureUsageFlags =
|
||||
m_swapchain->imageUsageFlags();
|
||||
// Some ARM Mali GPUs experience a device loss when rendering to the
|
||||
// overflow texture as an input attachment. The current assumption
|
||||
// is that it has to do with some combination of input attachment
|
||||
// usage and pixel readbacks. For now, just don't enable the input
|
||||
// attachment flag on the overflow texture.
|
||||
overflowTextureUsageFlags &= ~VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
|
||||
// This also helps us get stronger testing coverage on the codepath
|
||||
// that works without input attachments.
|
||||
renderTargetUsageFlags &= ~VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
|
||||
m_overflowTexture = vk()->makeTexture2D(
|
||||
{
|
||||
.format = m_swapchain->imageFormat(),
|
||||
.extent = {static_cast<uint32_t>(m_width),
|
||||
static_cast<uint32_t>(m_height)},
|
||||
.usage = m_swapchain->imageUsageFlags(),
|
||||
.usage = renderTargetUsageFlags,
|
||||
},
|
||||
"overflow texture");
|
||||
}
|
||||
@@ -168,6 +165,10 @@ public:
|
||||
{
|
||||
m_overflowTexture.reset();
|
||||
}
|
||||
m_renderTarget = impl()->makeRenderTarget(m_width,
|
||||
m_height,
|
||||
m_swapchain->imageFormat(),
|
||||
renderTargetUsageFlags);
|
||||
}
|
||||
|
||||
rcp<rive_tests::OffscreenRenderTarget> makeOffscreenRenderTarget(
|
||||
@@ -323,9 +324,14 @@ public:
|
||||
// Mali devices with a driver version before 50 have been known to run
|
||||
// out of memory, so for these devices, tear down the device between
|
||||
// GMs.
|
||||
// Adreno devices pre 1.3 (specifically Galaxy A11, Adreno 506, running
|
||||
// Vulkan 1.1) also have sporadic crashes, and tearing down the device
|
||||
// appears to help.
|
||||
if (m_device != nullptr &&
|
||||
strstr(m_device->name().c_str(), "Mali") != nullptr &&
|
||||
m_device->driverVersion().major < 50)
|
||||
((strstr(m_device->name().c_str(), "Mali") != nullptr &&
|
||||
m_device->driverVersion().major < 50) ||
|
||||
(strstr(m_device->name().c_str(), "Adreno") != nullptr &&
|
||||
m_device->vulkanFeatures().apiVersion < VK_API_VERSION_1_3)))
|
||||
{
|
||||
destroyRenderContext();
|
||||
}
|
||||
|
||||
@@ -259,15 +259,10 @@ int main(int argc, const char* argv[])
|
||||
: TestingWindow::Visibility::window;
|
||||
void* platformWindow = nullptr;
|
||||
#if defined(RIVE_ANDROID) && !defined(RIVE_UNREAL)
|
||||
// Only render directly to the main window on GL. Vulkan is experiencing
|
||||
// device losses on Pixel 6 when we render to the main window.
|
||||
if (backend == TestingWindow::Backend::gl)
|
||||
platformWindow = rive_android_app_wait_for_window();
|
||||
if (platformWindow != nullptr)
|
||||
{
|
||||
platformWindow = rive_android_app_wait_for_window();
|
||||
if (platformWindow != nullptr)
|
||||
{
|
||||
visibility = TestingWindow::Visibility::fullscreen;
|
||||
}
|
||||
visibility = TestingWindow::Visibility::fullscreen;
|
||||
}
|
||||
#endif
|
||||
TestingWindow::Init(backend, backendParams, visibility, platformWindow);
|
||||
|
||||
Reference in New Issue
Block a user