diff --git a/app/src/main/cpp/skyline/gpu/presentation_engine.cpp b/app/src/main/cpp/skyline/gpu/presentation_engine.cpp index 39043d4e..71353df3 100644 --- a/app/src/main/cpp/skyline/gpu/presentation_engine.cpp +++ b/app/src/main/cpp/skyline/gpu/presentation_engine.cpp @@ -96,9 +96,10 @@ namespace skyline::gpu { frame.fence.Wait(state.soc->host1x); - std::scoped_lock textureLock(*frame.texture); - if (frame.texture->format != swapchainFormat || frame.texture->dimensions != swapchainExtent) - UpdateSwapchain(frame.texture->format, frame.texture->dimensions); + std::scoped_lock textureLock(*frame.textureView); + auto texture{frame.textureView->texture}; + if (frame.textureView->format != swapchainFormat || texture->dimensions != swapchainExtent) + UpdateSwapchain(frame.textureView->format, texture->dimensions); int result; if (frame.crop && frame.crop != windowCrop) { @@ -131,8 +132,8 @@ namespace skyline::gpu { std::ignore = gpu.vkDevice.waitForFences(*acquireFence, true, std::numeric_limits::max()); - frame.texture->SynchronizeHost(); - images.at(nextImage.second)->CopyFrom(frame.texture, vk::ImageSubresourceRange{ + texture->SynchronizeHost(); + images.at(nextImage.second)->CopyFrom(texture, vk::ImageSubresourceRange{ .aspectMask = vk::ImageAspectFlagBits::eColor, .levelCount = 1, .layerCount = 1, @@ -373,7 +374,7 @@ namespace skyline::gpu { } } - u64 PresentationEngine::Present(const std::shared_ptr &texture, i64 timestamp, i64 swapInterval, AndroidRect crop, NativeWindowScalingMode scalingMode, NativeWindowTransform transform, skyline::service::hosbinder::AndroidFence fence, const std::function& presentCallback) { + u64 PresentationEngine::Present(const std::shared_ptr &texture, i64 timestamp, i64 swapInterval, AndroidRect crop, NativeWindowScalingMode scalingMode, NativeWindowTransform transform, skyline::service::hosbinder::AndroidFence fence, const std::function& presentCallback) { if (!vkSurface.has_value()) { // We want this function to generally (not necessarily always) block when a surface is not present to implicitly pause the game std::unique_lock lock(mutex); diff --git a/app/src/main/cpp/skyline/gpu/presentation_engine.h b/app/src/main/cpp/skyline/gpu/presentation_engine.h index 7886d789..97e22eb1 100644 --- a/app/src/main/cpp/skyline/gpu/presentation_engine.h +++ b/app/src/main/cpp/skyline/gpu/presentation_engine.h @@ -54,7 +54,7 @@ namespace skyline::gpu { bool choreographerStop{}; //!< If the Choreographer thread should stop on the next ALooper_wake() struct PresentableFrame { - std::shared_ptr texture{}; + std::shared_ptr textureView{}; skyline::service::hosbinder::AndroidFence fence{}; //!< The fence that must be waited on prior to using the texture i64 timestamp{}; //!< The earliest timestamp (relative to ARM CPU timer) that this frame must be presented at i64 swapInterval{}; //!< The interval between frames in terms of 60Hz display refreshes (1/60th of a second) @@ -120,7 +120,7 @@ namespace skyline::gpu { * @return The ID of this frame for correlating it with presentation timing readouts * @note The texture **must** be locked prior to calling this */ - u64 Present(const std::shared_ptr &texture, i64 timestamp, i64 swapInterval, service::hosbinder::AndroidRect crop, service::hosbinder::NativeWindowScalingMode scalingMode, service::hosbinder::NativeWindowTransform transform, skyline::service::hosbinder::AndroidFence fence, const std::function& presentCallback); + u64 Present(const std::shared_ptr &texture, i64 timestamp, i64 swapInterval, service::hosbinder::AndroidRect crop, service::hosbinder::NativeWindowScalingMode scalingMode, service::hosbinder::NativeWindowTransform transform, skyline::service::hosbinder::AndroidFence fence, const std::function& presentCallback); /** * @return A transform that the application should render with to elide costly transforms later diff --git a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp index a3e307d4..413fda96 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp +++ b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp @@ -348,7 +348,7 @@ namespace skyline::service::hosbinder { guestTexture.mappings[0] = span(nvMapHandleObj->GetPointer() + surface.offset, guestTexture.GetLayerStride()); std::scoped_lock textureLock{state.gpu->texture}; - buffer.texture = state.gpu->texture.FindOrCreate(guestTexture)->texture; + buffer.texture = state.gpu->texture.FindOrCreate(guestTexture); } switch (transform) { diff --git a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h index 6b116eac..da52070e 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h +++ b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h @@ -11,7 +11,7 @@ #include "native_window.h" namespace skyline::gpu { - class Texture; + class TextureView; } namespace skyline::service::nvdrv::core { @@ -44,7 +44,7 @@ namespace skyline::service::hosbinder { u64 frameNumber{}; //!< The amount of frames that have been queued using this slot bool wasBufferRequested{}; //!< If GraphicBufferProducer::RequestBuffer has been called with this buffer bool isPreallocated{}; //!< If this slot's graphic buffer has been preallocated or attached - std::shared_ptr texture{}; + std::shared_ptr texture{}; std::unique_ptr graphicBuffer{}; };