Rework GraphicBufferProducer

This commit makes GraphicBufferProducer significantly more accurate by matching the behavior of AOSP alongside mirroring the tweaks made by Nintendo. 

It eliminates a lot of the magic structures and enumerations used prior and replaces them with the correct values from AOSP or HOS. 

There was a lot of functional inaccuracy as well which was fixed, we emulate the exact subset of HOS behavior that we need to. A lot of the intermediate layers such as GraphicBufferConsumer or Gralloc/Sync are not emulated as they're pointless abstractions here.
This commit is contained in:
PixelyIon
2021-04-16 20:35:24 +05:30
committed by ◱ Mark
parent da7e18de4c
commit d8025e7178
21 changed files with 1035 additions and 243 deletions

View File

@ -5,6 +5,8 @@
#include <common/trace.h>
#include <kernel/types/KEvent.h>
#include <services/hosbinder/native_window.h>
#include <services/hosbinder/android_types.h>
#include "texture.h"
struct ANativeWindow;
@ -18,13 +20,15 @@ namespace skyline::gpu {
const DeviceState &state;
const GPU &gpu;
std::mutex mutex; //!< Synchronizes access to the surface objects
std::condition_variable surfaceCondition; //!< Allows us to efficiently wait for the window object to be set
std::condition_variable surfaceCondition; //!< Allows us to efficiently wait for Vulkan surface to be initialized
jobject surface{}; //!< The Surface object backing the ANativeWindow
std::optional<vk::raii::SurfaceKHR> vkSurface; //!< The Vulkan Surface object that is backed by ANativeWindow
std::optional<service::hosbinder::NativeWindowTransform> transformHint; //!< The optimal transform for the application to render as
std::optional<vk::raii::SwapchainKHR> vkSwapchain; //!< The Vulkan swapchain and the properties associated with it
struct SwapchainContext {
u32 imageCount{};
u16 imageCount{};
i32 dequeuedCount{};
vk::Format imageFormat{};
vk::Extent2D imageExtent{};
} swapchain; //!< The properties of the currently created swapchain
@ -32,7 +36,7 @@ namespace skyline::gpu {
u64 frameTimestamp{}; //!< The timestamp of the last frame being shown
perfetto::Track presentationTrack; //!< Perfetto track used for presentation events
void UpdateSwapchain(u32 imageCount, vk::Format imageFormat, vk::Extent2D imageExtent);
void UpdateSwapchain(u16 imageCount, vk::Format imageFormat, vk::Extent2D imageExtent);
public:
texture::Dimensions resolution{};
@ -55,13 +59,19 @@ namespace skyline::gpu {
std::shared_ptr<Texture> CreatePresentationTexture(const std::shared_ptr<GuestTexture> &texture, u32 slot);
/**
* @return The slot of the texture that's available to write into
* @param async If to return immediately when a texture is not available
* @param slot The slot the freed texture is in is written into this, it is untouched if there's an error
*/
u32 GetFreeTexture();
service::hosbinder::AndroidStatus GetFreeTexture(bool async, i32& slot);
/**
* @brief Send the supplied texture to the presentation queue to be displayed
* @brief Send a texture from a slot to the presentation queue to be displayed
*/
void Present(const std::shared_ptr<Texture> &texture);
void Present(i32 slot);
/**
* @return A transform that the application should render with to elide costly transforms later
*/
service::hosbinder::NativeWindowTransform GetTransformHint();
};
}