mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-23 05:25:38 +00:00
nvnflinger/gpu: implement blending
This commit is contained in:
parent
06fd7f2012
commit
962c82540c
|
@ -130,9 +130,9 @@ enum class AppletProgramId : u64 {
|
||||||
|
|
||||||
enum class LibraryAppletMode : u32 {
|
enum class LibraryAppletMode : u32 {
|
||||||
AllForeground = 0,
|
AllForeground = 0,
|
||||||
Background = 1,
|
PartialForeground = 1,
|
||||||
NoUI = 2,
|
NoUi = 2,
|
||||||
BackgroundIndirectDisplay = 3,
|
PartialForegroundIndirectDisplay = 3,
|
||||||
AllForegroundInitiallyHidden = 4,
|
AllForegroundInitiallyHidden = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,9 @@ void SoftwareKeyboard::Initialize() {
|
||||||
case LibraryAppletMode::AllForeground:
|
case LibraryAppletMode::AllForeground:
|
||||||
InitializeForeground();
|
InitializeForeground();
|
||||||
break;
|
break;
|
||||||
case LibraryAppletMode::Background:
|
case LibraryAppletMode::PartialForeground:
|
||||||
case LibraryAppletMode::BackgroundIndirectDisplay:
|
case LibraryAppletMode::PartialForegroundIndirectDisplay:
|
||||||
InitializeBackground(applet_mode);
|
InitializePartialForeground(applet_mode);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT_MSG(false, "Invalid LibraryAppletMode={}", applet_mode);
|
ASSERT_MSG(false, "Invalid LibraryAppletMode={}", applet_mode);
|
||||||
|
@ -243,7 +243,7 @@ void SoftwareKeyboard::InitializeForeground() {
|
||||||
InitializeFrontendNormalKeyboard();
|
InitializeFrontendNormalKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareKeyboard::InitializeBackground(LibraryAppletMode library_applet_mode) {
|
void SoftwareKeyboard::InitializePartialForeground(LibraryAppletMode library_applet_mode) {
|
||||||
LOG_INFO(Service_AM, "Initializing Inline Software Keyboard Applet.");
|
LOG_INFO(Service_AM, "Initializing Inline Software Keyboard Applet.");
|
||||||
|
|
||||||
is_background = true;
|
is_background = true;
|
||||||
|
@ -258,9 +258,9 @@ void SoftwareKeyboard::InitializeBackground(LibraryAppletMode library_applet_mod
|
||||||
swkbd_inline_initialize_arg.size());
|
swkbd_inline_initialize_arg.size());
|
||||||
|
|
||||||
if (swkbd_initialize_arg.library_applet_mode_flag) {
|
if (swkbd_initialize_arg.library_applet_mode_flag) {
|
||||||
ASSERT(library_applet_mode == LibraryAppletMode::Background);
|
ASSERT(library_applet_mode == LibraryAppletMode::PartialForeground);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(library_applet_mode == LibraryAppletMode::BackgroundIndirectDisplay);
|
ASSERT(library_applet_mode == LibraryAppletMode::PartialForegroundIndirectDisplay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ private:
|
||||||
void InitializeForeground();
|
void InitializeForeground();
|
||||||
|
|
||||||
/// Initializes the inline software keyboard.
|
/// Initializes the inline software keyboard.
|
||||||
void InitializeBackground(LibraryAppletMode library_applet_mode);
|
void InitializePartialForeground(LibraryAppletMode library_applet_mode);
|
||||||
|
|
||||||
/// Processes the text check sent by the application.
|
/// Processes the text check sent by the application.
|
||||||
void ProcessTextCheck();
|
void ProcessTextCheck();
|
||||||
|
|
|
@ -87,7 +87,7 @@ AppletProgramId AppletIdToProgramId(AppletId applet_id) {
|
||||||
// Set focus state
|
// Set focus state
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case LibraryAppletMode::AllForeground:
|
case LibraryAppletMode::AllForeground:
|
||||||
case LibraryAppletMode::NoUI:
|
case LibraryAppletMode::NoUi:
|
||||||
applet->focus_state = FocusState::InFocus;
|
applet->focus_state = FocusState::InFocus;
|
||||||
applet->hid_registration.EnableAppletToGetInput(true);
|
applet->hid_registration.EnableAppletToGetInput(true);
|
||||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
|
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::ChangeIntoForeground);
|
||||||
|
@ -99,8 +99,8 @@ AppletProgramId AppletIdToProgramId(AppletId applet_id) {
|
||||||
applet->hid_registration.EnableAppletToGetInput(false);
|
applet->hid_registration.EnableAppletToGetInput(false);
|
||||||
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
|
applet->message_queue.PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
|
||||||
break;
|
break;
|
||||||
case LibraryAppletMode::Background:
|
case LibraryAppletMode::PartialForeground:
|
||||||
case LibraryAppletMode::BackgroundIndirectDisplay:
|
case LibraryAppletMode::PartialForegroundIndirectDisplay:
|
||||||
default:
|
default:
|
||||||
applet->focus_state = FocusState::Background;
|
applet->focus_state = FocusState::Background;
|
||||||
applet->hid_registration.EnableAppletToGetInput(true);
|
applet->hid_registration.EnableAppletToGetInput(true);
|
||||||
|
|
|
@ -288,7 +288,8 @@ void ISelfController::GetSystemSharedBufferHandle(HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ISelfController::EnsureBufferSharingEnabled(Kernel::KProcess* process) {
|
Result ISelfController::EnsureBufferSharingEnabled(Kernel::KProcess* process) {
|
||||||
if (applet->system_buffer_manager.Initialize(&nvnflinger, process, applet->applet_id)) {
|
if (applet->system_buffer_manager.Initialize(&nvnflinger, process, applet->applet_id,
|
||||||
|
applet->library_applet_mode)) {
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,12 @@ SystemBufferManager::~SystemBufferManager() {
|
||||||
|
|
||||||
// Clean up shared layers.
|
// Clean up shared layers.
|
||||||
if (m_buffer_sharing_enabled) {
|
if (m_buffer_sharing_enabled) {
|
||||||
|
m_nvnflinger->GetSystemBufferManager().Finalize(m_process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemBufferManager::Initialize(Nvnflinger::Nvnflinger* nvnflinger, Kernel::KProcess* process,
|
bool SystemBufferManager::Initialize(Nvnflinger::Nvnflinger* nvnflinger, Kernel::KProcess* process,
|
||||||
AppletId applet_id) {
|
AppletId applet_id, LibraryAppletMode mode) {
|
||||||
if (m_nvnflinger) {
|
if (m_nvnflinger) {
|
||||||
return m_buffer_sharing_enabled;
|
return m_buffer_sharing_enabled;
|
||||||
}
|
}
|
||||||
|
@ -36,9 +37,14 @@ bool SystemBufferManager::Initialize(Nvnflinger::Nvnflinger* nvnflinger, Kernel:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Nvnflinger::LayerBlending blending = Nvnflinger::LayerBlending::None;
|
||||||
|
if (mode == LibraryAppletMode::PartialForeground) {
|
||||||
|
blending = Nvnflinger::LayerBlending::Coverage;
|
||||||
|
}
|
||||||
|
|
||||||
const auto display_id = m_nvnflinger->OpenDisplay("Default").value();
|
const auto display_id = m_nvnflinger->OpenDisplay("Default").value();
|
||||||
const auto res = m_nvnflinger->GetSystemBufferManager().Initialize(
|
const auto res = m_nvnflinger->GetSystemBufferManager().Initialize(
|
||||||
&m_system_shared_buffer_id, &m_system_shared_layer_id, display_id);
|
m_process, &m_system_shared_buffer_id, &m_system_shared_layer_id, display_id, blending);
|
||||||
|
|
||||||
if (res.IsSuccess()) {
|
if (res.IsSuccess()) {
|
||||||
m_buffer_sharing_enabled = true;
|
m_buffer_sharing_enabled = true;
|
||||||
|
|
|
@ -27,7 +27,8 @@ public:
|
||||||
SystemBufferManager();
|
SystemBufferManager();
|
||||||
~SystemBufferManager();
|
~SystemBufferManager();
|
||||||
|
|
||||||
bool Initialize(Nvnflinger::Nvnflinger* flinger, Kernel::KProcess* process, AppletId applet_id);
|
bool Initialize(Nvnflinger::Nvnflinger* flinger, Kernel::KProcess* process, AppletId applet_id,
|
||||||
|
LibraryAppletMode mode);
|
||||||
|
|
||||||
void GetSystemSharedLayerHandle(u64* out_system_shared_buffer_id,
|
void GetSystemSharedLayerHandle(u64* out_system_shared_buffer_id,
|
||||||
u64* out_system_shared_layer_id) {
|
u64* out_system_shared_layer_id) {
|
||||||
|
|
|
@ -15,6 +15,22 @@
|
||||||
|
|
||||||
namespace Service::Nvidia::Devices {
|
namespace Service::Nvidia::Devices {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
Tegra::BlendMode ConvertBlending(Service::Nvnflinger::LayerBlending blending) {
|
||||||
|
switch (blending) {
|
||||||
|
case Service::Nvnflinger::LayerBlending::None:
|
||||||
|
default:
|
||||||
|
return Tegra::BlendMode::Opaque;
|
||||||
|
case Service::Nvnflinger::LayerBlending::Premultiplied:
|
||||||
|
return Tegra::BlendMode::Premultiplied;
|
||||||
|
case Service::Nvnflinger::LayerBlending::Coverage:
|
||||||
|
return Tegra::BlendMode::Coverage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
nvdisp_disp0::nvdisp_disp0(Core::System& system_, NvCore::Container& core)
|
nvdisp_disp0::nvdisp_disp0(Core::System& system_, NvCore::Container& core)
|
||||||
: nvdevice{system_}, container{core}, nvmap{core.GetNvMapFile()} {}
|
: nvdevice{system_}, container{core}, nvmap{core.GetNvMapFile()} {}
|
||||||
nvdisp_disp0::~nvdisp_disp0() = default;
|
nvdisp_disp0::~nvdisp_disp0() = default;
|
||||||
|
@ -56,6 +72,7 @@ void nvdisp_disp0::Composite(std::span<const Nvnflinger::HwcLayer> sorted_layers
|
||||||
.pixel_format = layer.format,
|
.pixel_format = layer.format,
|
||||||
.transform_flags = layer.transform,
|
.transform_flags = layer.transform,
|
||||||
.crop_rect = layer.crop_rect,
|
.crop_rect = layer.crop_rect,
|
||||||
|
.blending = ConvertBlending(layer.blending),
|
||||||
});
|
});
|
||||||
|
|
||||||
for (size_t i = 0; i < layer.acquire_fence.num_fences; i++) {
|
for (size_t i = 0; i < layer.acquire_fence.num_fences; i++) {
|
||||||
|
|
|
@ -14,24 +14,19 @@
|
||||||
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
||||||
#include "core/hle/service/vi/layer/vi_layer.h"
|
#include "core/hle/service/vi/layer/vi_layer.h"
|
||||||
#include "core/hle/service/vi/vi_results.h"
|
#include "core/hle/service/vi/vi_results.h"
|
||||||
|
#include "video_core/gpu.h"
|
||||||
|
|
||||||
namespace Service::Nvnflinger {
|
namespace Service::Nvnflinger {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Result AllocateIoForProcessAddressSpace(Common::ProcessAddress* out_map_address,
|
Result AllocateSharedBufferMemory(std::unique_ptr<Kernel::KPageGroup>* out_page_group,
|
||||||
std::unique_ptr<Kernel::KPageGroup>* out_page_group,
|
Core::System& system, u32 size) {
|
||||||
Core::System& system, u32 size) {
|
|
||||||
using Core::Memory::YUZU_PAGESIZE;
|
using Core::Memory::YUZU_PAGESIZE;
|
||||||
|
|
||||||
// Allocate memory for the system shared buffer.
|
// Allocate memory for the system shared buffer.
|
||||||
// FIXME: Because the gmmu can only point to cpu addresses, we need
|
|
||||||
// to map this in the application space to allow it to be used.
|
|
||||||
// FIXME: Add proper smmu emulation.
|
|
||||||
// FIXME: This memory belongs to vi's .data section.
|
// FIXME: This memory belongs to vi's .data section.
|
||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
auto* process = system.ApplicationProcess();
|
|
||||||
auto& page_table = process->GetPageTable();
|
|
||||||
|
|
||||||
// Hold a temporary page group reference while we try to map it.
|
// Hold a temporary page group reference while we try to map it.
|
||||||
auto pg = std::make_unique<Kernel::KPageGroup>(
|
auto pg = std::make_unique<Kernel::KPageGroup>(
|
||||||
|
@ -43,6 +38,30 @@ Result AllocateIoForProcessAddressSpace(Common::ProcessAddress* out_map_address,
|
||||||
Kernel::KMemoryManager::EncodeOption(Kernel::KMemoryManager::Pool::Secure,
|
Kernel::KMemoryManager::EncodeOption(Kernel::KMemoryManager::Pool::Secure,
|
||||||
Kernel::KMemoryManager::Direction::FromBack)));
|
Kernel::KMemoryManager::Direction::FromBack)));
|
||||||
|
|
||||||
|
// Fill the output data with red.
|
||||||
|
for (auto& block : *pg) {
|
||||||
|
u32* start = system.DeviceMemory().GetPointer<u32>(block.GetAddress());
|
||||||
|
u32* end = system.DeviceMemory().GetPointer<u32>(block.GetAddress() + block.GetSize());
|
||||||
|
|
||||||
|
for (; start < end; start++) {
|
||||||
|
*start = 0xFF0000FF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the mapped page group.
|
||||||
|
*out_page_group = std::move(pg);
|
||||||
|
|
||||||
|
// We succeeded.
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result MapSharedBufferIntoProcessAddressSpace(Common::ProcessAddress* out_map_address,
|
||||||
|
std::unique_ptr<Kernel::KPageGroup>& pg,
|
||||||
|
Kernel::KProcess* process, Core::System& system) {
|
||||||
|
using Core::Memory::YUZU_PAGESIZE;
|
||||||
|
|
||||||
|
auto& page_table = process->GetPageTable();
|
||||||
|
|
||||||
// Get bounds of where mapping is possible.
|
// Get bounds of where mapping is possible.
|
||||||
const VAddr alias_code_begin = GetInteger(page_table.GetAliasCodeRegionStart());
|
const VAddr alias_code_begin = GetInteger(page_table.GetAliasCodeRegionStart());
|
||||||
const VAddr alias_code_size = page_table.GetAliasCodeRegionSize() / YUZU_PAGESIZE;
|
const VAddr alias_code_size = page_table.GetAliasCodeRegionSize() / YUZU_PAGESIZE;
|
||||||
|
@ -64,9 +83,6 @@ Result AllocateIoForProcessAddressSpace(Common::ProcessAddress* out_map_address,
|
||||||
// Return failure, if necessary
|
// Return failure, if necessary
|
||||||
R_UNLESS(i < 64, res);
|
R_UNLESS(i < 64, res);
|
||||||
|
|
||||||
// Return the mapped page group.
|
|
||||||
*out_page_group = std::move(pg);
|
|
||||||
|
|
||||||
// We succeeded.
|
// We succeeded.
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
@ -135,6 +151,13 @@ Result AllocateHandleForBuffer(u32* out_handle, Nvidia::Module& nvdrv, Nvidia::D
|
||||||
R_RETURN(AllocNvMapHandle(*nvmap, *out_handle, buffer, size, nvmap_fd));
|
R_RETURN(AllocNvMapHandle(*nvmap, *out_handle, buffer, size, nvmap_fd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FreeHandle(u32 handle, Nvidia::Module& nvdrv, Nvidia::DeviceFD nvmap_fd) {
|
||||||
|
auto nvmap = nvdrv.GetDevice<Nvidia::Devices::nvmap>(nvmap_fd);
|
||||||
|
ASSERT(nvmap != nullptr);
|
||||||
|
|
||||||
|
R_ASSERT(FreeNvMapHandle(*nvmap, handle, nvmap_fd));
|
||||||
|
}
|
||||||
|
|
||||||
constexpr auto SharedBufferBlockLinearFormat = android::PixelFormat::Rgba8888;
|
constexpr auto SharedBufferBlockLinearFormat = android::PixelFormat::Rgba8888;
|
||||||
constexpr u32 SharedBufferBlockLinearBpp = 4;
|
constexpr u32 SharedBufferBlockLinearBpp = 4;
|
||||||
|
|
||||||
|
@ -186,53 +209,97 @@ FbShareBufferManager::FbShareBufferManager(Core::System& system, Nvnflinger& fli
|
||||||
|
|
||||||
FbShareBufferManager::~FbShareBufferManager() = default;
|
FbShareBufferManager::~FbShareBufferManager() = default;
|
||||||
|
|
||||||
Result FbShareBufferManager::Initialize(u64* out_buffer_id, u64* out_layer_id, u64 display_id) {
|
Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id,
|
||||||
|
u64* out_layer_handle, u64 display_id,
|
||||||
|
LayerBlending blending) {
|
||||||
std::scoped_lock lk{m_guard};
|
std::scoped_lock lk{m_guard};
|
||||||
|
|
||||||
// Ensure we have not already created a buffer.
|
// Ensure we haven't already created.
|
||||||
R_UNLESS(m_buffer_id == 0, VI::ResultOperationFailed);
|
const u64 aruid = owner_process->GetProcessId();
|
||||||
|
R_UNLESS(!m_sessions.contains(aruid), VI::ResultPermissionDenied);
|
||||||
|
|
||||||
// Allocate memory and space for the shared buffer.
|
// Allocate memory for the shared buffer if needed.
|
||||||
Common::ProcessAddress map_address;
|
if (!m_buffer_page_group) {
|
||||||
R_TRY(AllocateIoForProcessAddressSpace(std::addressof(map_address),
|
R_TRY(AllocateSharedBufferMemory(std::addressof(m_buffer_page_group), m_system,
|
||||||
std::addressof(m_buffer_page_group), m_system,
|
SharedBufferSize));
|
||||||
SharedBufferSize));
|
|
||||||
|
// Record buffer id.
|
||||||
|
m_buffer_id = m_next_buffer_id++;
|
||||||
|
|
||||||
|
// Record display id.
|
||||||
|
m_display_id = display_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map into process.
|
||||||
|
Common::ProcessAddress map_address{};
|
||||||
|
R_TRY(MapSharedBufferIntoProcessAddressSpace(std::addressof(map_address), m_buffer_page_group,
|
||||||
|
owner_process, m_system));
|
||||||
|
|
||||||
|
// Create new session.
|
||||||
|
auto [it, was_emplaced] = m_sessions.emplace(aruid, FbShareSession{});
|
||||||
|
auto& session = it->second;
|
||||||
|
|
||||||
auto& container = m_nvdrv->GetContainer();
|
auto& container = m_nvdrv->GetContainer();
|
||||||
m_session_id = container.OpenSession(m_system.ApplicationProcess());
|
session.session_id = container.OpenSession(owner_process);
|
||||||
m_nvmap_fd = m_nvdrv->Open("/dev/nvmap", m_session_id);
|
session.nvmap_fd = m_nvdrv->Open("/dev/nvmap", session.session_id);
|
||||||
|
|
||||||
// Create an nvmap handle for the buffer and assign the memory to it.
|
// Create an nvmap handle for the buffer and assign the memory to it.
|
||||||
R_TRY(AllocateHandleForBuffer(std::addressof(m_buffer_nvmap_handle), *m_nvdrv, m_nvmap_fd,
|
R_TRY(AllocateHandleForBuffer(std::addressof(session.buffer_nvmap_handle), *m_nvdrv,
|
||||||
map_address, SharedBufferSize));
|
session.nvmap_fd, map_address, SharedBufferSize));
|
||||||
|
|
||||||
// Record the display id.
|
|
||||||
m_display_id = display_id;
|
|
||||||
|
|
||||||
// Create and open a layer for the display.
|
// Create and open a layer for the display.
|
||||||
m_layer_id = m_flinger.CreateLayer(m_display_id).value();
|
session.layer_id = m_flinger.CreateLayer(m_display_id, blending).value();
|
||||||
m_flinger.OpenLayer(m_layer_id);
|
m_flinger.OpenLayer(session.layer_id);
|
||||||
|
|
||||||
// Set up the buffer.
|
|
||||||
m_buffer_id = m_next_buffer_id++;
|
|
||||||
|
|
||||||
// Get the layer.
|
// Get the layer.
|
||||||
VI::Layer* layer = m_flinger.FindLayer(m_display_id, m_layer_id);
|
VI::Layer* layer = m_flinger.FindLayer(m_display_id, session.layer_id);
|
||||||
ASSERT(layer != nullptr);
|
ASSERT(layer != nullptr);
|
||||||
|
|
||||||
// Get the producer and set preallocated buffers.
|
// Get the producer and set preallocated buffers.
|
||||||
auto& producer = layer->GetBufferQueue();
|
auto& producer = layer->GetBufferQueue();
|
||||||
MakeGraphicBuffer(producer, 0, m_buffer_nvmap_handle);
|
MakeGraphicBuffer(producer, 0, session.buffer_nvmap_handle);
|
||||||
MakeGraphicBuffer(producer, 1, m_buffer_nvmap_handle);
|
MakeGraphicBuffer(producer, 1, session.buffer_nvmap_handle);
|
||||||
|
|
||||||
// Assign outputs.
|
// Assign outputs.
|
||||||
*out_buffer_id = m_buffer_id;
|
*out_buffer_id = m_buffer_id;
|
||||||
*out_layer_id = m_layer_id;
|
*out_layer_handle = session.layer_id;
|
||||||
|
|
||||||
// We succeeded.
|
// We succeeded.
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FbShareBufferManager::Finalize(Kernel::KProcess* owner_process) {
|
||||||
|
std::scoped_lock lk{m_guard};
|
||||||
|
|
||||||
|
if (m_buffer_id == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const u64 aruid = owner_process->GetProcessId();
|
||||||
|
const auto it = m_sessions.find(aruid);
|
||||||
|
if (it == m_sessions.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& session = it->second;
|
||||||
|
|
||||||
|
// Destroy the layer.
|
||||||
|
m_flinger.DestroyLayer(session.layer_id);
|
||||||
|
|
||||||
|
// Close nvmap handle.
|
||||||
|
FreeHandle(session.buffer_nvmap_handle, *m_nvdrv, session.nvmap_fd);
|
||||||
|
|
||||||
|
// Close nvmap device.
|
||||||
|
m_nvdrv->Close(session.nvmap_fd);
|
||||||
|
|
||||||
|
// Close session.
|
||||||
|
auto& container = m_nvdrv->GetContainer();
|
||||||
|
container.CloseSession(session.session_id);
|
||||||
|
|
||||||
|
// Erase.
|
||||||
|
m_sessions.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
Result FbShareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size,
|
Result FbShareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size,
|
||||||
s32* out_nvmap_handle,
|
s32* out_nvmap_handle,
|
||||||
SharedMemoryPoolLayout* out_pool_layout,
|
SharedMemoryPoolLayout* out_pool_layout,
|
||||||
|
@ -242,17 +309,18 @@ Result FbShareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size,
|
||||||
|
|
||||||
R_UNLESS(m_buffer_id > 0, VI::ResultNotFound);
|
R_UNLESS(m_buffer_id > 0, VI::ResultNotFound);
|
||||||
R_UNLESS(buffer_id == m_buffer_id, VI::ResultNotFound);
|
R_UNLESS(buffer_id == m_buffer_id, VI::ResultNotFound);
|
||||||
|
R_UNLESS(m_sessions.contains(applet_resource_user_id), VI::ResultNotFound);
|
||||||
|
|
||||||
*out_pool_layout = SharedBufferPoolLayout;
|
*out_pool_layout = SharedBufferPoolLayout;
|
||||||
*out_buffer_size = SharedBufferSize;
|
*out_buffer_size = SharedBufferSize;
|
||||||
*out_nvmap_handle = m_buffer_nvmap_handle;
|
*out_nvmap_handle = m_sessions[applet_resource_user_id].buffer_nvmap_handle;
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FbShareBufferManager::GetLayerFromId(VI::Layer** out_layer, u64 layer_id) {
|
Result FbShareBufferManager::GetLayerFromId(VI::Layer** out_layer, u64 layer_id) {
|
||||||
// Ensure the layer id is valid.
|
// Ensure the layer id is valid.
|
||||||
R_UNLESS(m_layer_id > 0 && layer_id == m_layer_id, VI::ResultNotFound);
|
R_UNLESS(layer_id > 0, VI::ResultNotFound);
|
||||||
|
|
||||||
// Get the layer.
|
// Get the layer.
|
||||||
VI::Layer* layer = m_flinger.FindLayer(m_display_id, layer_id);
|
VI::Layer* layer = m_flinger.FindLayer(m_display_id, layer_id);
|
||||||
|
@ -309,6 +377,10 @@ Result FbShareBufferManager::PresentSharedFrameBuffer(android::Fence fence,
|
||||||
android::Status::NoError,
|
android::Status::NoError,
|
||||||
VI::ResultOperationFailed);
|
VI::ResultOperationFailed);
|
||||||
|
|
||||||
|
ON_RESULT_FAILURE {
|
||||||
|
producer.CancelBuffer(static_cast<s32>(slot), fence);
|
||||||
|
};
|
||||||
|
|
||||||
// Queue the buffer to the producer.
|
// Queue the buffer to the producer.
|
||||||
android::QueueBufferInput input{};
|
android::QueueBufferInput input{};
|
||||||
android::QueueBufferOutput output{};
|
android::QueueBufferOutput output{};
|
||||||
|
@ -342,4 +414,12 @@ Result FbShareBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadab
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result FbShareBufferManager::WriteAppletCaptureBuffer(bool* out_was_written,
|
||||||
|
s32* out_layer_index) {
|
||||||
|
// TODO
|
||||||
|
*out_was_written = true;
|
||||||
|
*out_layer_index = 1;
|
||||||
|
R_SUCCEED();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Service::Nvnflinger
|
} // namespace Service::Nvnflinger
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "common/math_util.h"
|
#include "common/math_util.h"
|
||||||
#include "core/hle/service/nvdrv/core/container.h"
|
#include "core/hle/service/nvdrv/core/container.h"
|
||||||
#include "core/hle/service/nvdrv/nvdata.h"
|
#include "core/hle/service/nvdrv/nvdata.h"
|
||||||
|
#include "core/hle/service/nvnflinger/hwc_layer.h"
|
||||||
#include "core/hle/service/nvnflinger/nvnflinger.h"
|
#include "core/hle/service/nvnflinger/nvnflinger.h"
|
||||||
#include "core/hle/service/nvnflinger/ui/fence.h"
|
#include "core/hle/service/nvnflinger/ui/fence.h"
|
||||||
|
|
||||||
|
@ -29,13 +32,18 @@ struct SharedMemoryPoolLayout {
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SharedMemoryPoolLayout) == 0x188, "SharedMemoryPoolLayout has wrong size");
|
static_assert(sizeof(SharedMemoryPoolLayout) == 0x188, "SharedMemoryPoolLayout has wrong size");
|
||||||
|
|
||||||
|
struct FbShareSession;
|
||||||
|
|
||||||
class FbShareBufferManager final {
|
class FbShareBufferManager final {
|
||||||
public:
|
public:
|
||||||
explicit FbShareBufferManager(Core::System& system, Nvnflinger& flinger,
|
explicit FbShareBufferManager(Core::System& system, Nvnflinger& flinger,
|
||||||
std::shared_ptr<Nvidia::Module> nvdrv);
|
std::shared_ptr<Nvidia::Module> nvdrv);
|
||||||
~FbShareBufferManager();
|
~FbShareBufferManager();
|
||||||
|
|
||||||
Result Initialize(u64* out_buffer_id, u64* out_layer_handle, u64 display_id);
|
Result Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id, u64* out_layer_handle,
|
||||||
|
u64 display_id, LayerBlending blending);
|
||||||
|
void Finalize(Kernel::KProcess* owner_process);
|
||||||
|
|
||||||
Result GetSharedBufferMemoryHandleId(u64* out_buffer_size, s32* out_nvmap_handle,
|
Result GetSharedBufferMemoryHandleId(u64* out_buffer_size, s32* out_nvmap_handle,
|
||||||
SharedMemoryPoolLayout* out_pool_layout, u64 buffer_id,
|
SharedMemoryPoolLayout* out_pool_layout, u64 buffer_id,
|
||||||
u64 applet_resource_user_id);
|
u64 applet_resource_user_id);
|
||||||
|
@ -45,6 +53,8 @@ public:
|
||||||
u32 transform, s32 swap_interval, u64 layer_id, s64 slot);
|
u32 transform, s32 swap_interval, u64 layer_id, s64 slot);
|
||||||
Result GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event, u64 layer_id);
|
Result GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event, u64 layer_id);
|
||||||
|
|
||||||
|
Result WriteAppletCaptureBuffer(bool* out_was_written, s32* out_layer_index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Result GetLayerFromId(VI::Layer** out_layer, u64 layer_id);
|
Result GetLayerFromId(VI::Layer** out_layer, u64 layer_id);
|
||||||
|
|
||||||
|
@ -52,11 +62,8 @@ private:
|
||||||
u64 m_next_buffer_id = 1;
|
u64 m_next_buffer_id = 1;
|
||||||
u64 m_display_id = 0;
|
u64 m_display_id = 0;
|
||||||
u64 m_buffer_id = 0;
|
u64 m_buffer_id = 0;
|
||||||
u64 m_layer_id = 0;
|
|
||||||
u32 m_buffer_nvmap_handle = 0;
|
|
||||||
SharedMemoryPoolLayout m_pool_layout = {};
|
SharedMemoryPoolLayout m_pool_layout = {};
|
||||||
Nvidia::DeviceFD m_nvmap_fd = {};
|
std::map<u64, FbShareSession> m_sessions;
|
||||||
Nvidia::NvCore::SessionId m_session_id = {};
|
|
||||||
std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group;
|
std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group;
|
||||||
|
|
||||||
std::mutex m_guard;
|
std::mutex m_guard;
|
||||||
|
@ -65,4 +72,11 @@ private:
|
||||||
std::shared_ptr<Nvidia::Module> m_nvdrv;
|
std::shared_ptr<Nvidia::Module> m_nvdrv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FbShareSession {
|
||||||
|
Nvidia::DeviceFD nvmap_fd = {};
|
||||||
|
Nvidia::NvCore::SessionId session_id = {};
|
||||||
|
u64 layer_id = {};
|
||||||
|
u32 buffer_nvmap_handle = 0;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Service::Nvnflinger
|
} // namespace Service::Nvnflinger
|
||||||
|
|
|
@ -86,6 +86,7 @@ u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, VI::Display& display,
|
||||||
.height = igbp_buffer.Height(),
|
.height = igbp_buffer.Height(),
|
||||||
.stride = igbp_buffer.Stride(),
|
.stride = igbp_buffer.Stride(),
|
||||||
.z_index = 0,
|
.z_index = 0,
|
||||||
|
.blending = layer.GetBlending(),
|
||||||
.transform = static_cast<android::BufferTransformFlags>(item.transform),
|
.transform = static_cast<android::BufferTransformFlags>(item.transform),
|
||||||
.crop_rect = item.crop,
|
.crop_rect = item.crop,
|
||||||
.acquire_fence = item.fence,
|
.acquire_fence = item.fence,
|
||||||
|
|
|
@ -11,6 +11,18 @@
|
||||||
|
|
||||||
namespace Service::Nvnflinger {
|
namespace Service::Nvnflinger {
|
||||||
|
|
||||||
|
// hwc_layer_t::blending values
|
||||||
|
enum class LayerBlending : u32 {
|
||||||
|
// No blending
|
||||||
|
None = 0x100,
|
||||||
|
|
||||||
|
// ONE / ONE_MINUS_SRC_ALPHA
|
||||||
|
Premultiplied = 0x105,
|
||||||
|
|
||||||
|
// SRC_ALPHA / ONE_MINUS_SRC_ALPHA
|
||||||
|
Coverage = 0x405,
|
||||||
|
};
|
||||||
|
|
||||||
struct HwcLayer {
|
struct HwcLayer {
|
||||||
u32 buffer_handle;
|
u32 buffer_handle;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
|
@ -19,6 +31,7 @@ struct HwcLayer {
|
||||||
u32 height;
|
u32 height;
|
||||||
u32 stride;
|
u32 stride;
|
||||||
s32 z_index;
|
s32 z_index;
|
||||||
|
LayerBlending blending;
|
||||||
android::BufferTransformFlags transform;
|
android::BufferTransformFlags transform;
|
||||||
Common::Rectangle<int> crop_rect;
|
Common::Rectangle<int> crop_rect;
|
||||||
android::Fence acquire_fence;
|
android::Fence acquire_fence;
|
||||||
|
|
|
@ -157,7 +157,7 @@ bool Nvnflinger::CloseDisplay(u64 display_id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<u64> Nvnflinger::CreateLayer(u64 display_id) {
|
std::optional<u64> Nvnflinger::CreateLayer(u64 display_id, LayerBlending blending) {
|
||||||
const auto lock_guard = Lock();
|
const auto lock_guard = Lock();
|
||||||
auto* const display = FindDisplay(display_id);
|
auto* const display = FindDisplay(display_id);
|
||||||
|
|
||||||
|
@ -166,13 +166,14 @@ std::optional<u64> Nvnflinger::CreateLayer(u64 display_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const u64 layer_id = next_layer_id++;
|
const u64 layer_id = next_layer_id++;
|
||||||
CreateLayerAtId(*display, layer_id);
|
CreateLayerAtId(*display, layer_id, blending);
|
||||||
return layer_id;
|
return layer_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nvnflinger::CreateLayerAtId(VI::Display& display, u64 layer_id) {
|
void Nvnflinger::CreateLayerAtId(VI::Display& display, u64 layer_id, LayerBlending blending) {
|
||||||
const auto buffer_id = next_buffer_queue_id++;
|
const auto buffer_id = next_buffer_queue_id++;
|
||||||
display.CreateLayer(layer_id, buffer_id, nvdrv->container);
|
display.CreateLayer(layer_id, buffer_id, nvdrv->container);
|
||||||
|
display.FindLayer(layer_id)->SetBlending(blending);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Nvnflinger::OpenLayer(u64 layer_id) {
|
bool Nvnflinger::OpenLayer(u64 layer_id) {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/kernel_helpers.h"
|
#include "core/hle/service/kernel_helpers.h"
|
||||||
|
#include "core/hle/service/nvnflinger/hwc_layer.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
class Event;
|
class Event;
|
||||||
|
@ -72,7 +73,8 @@ public:
|
||||||
/// Creates a layer on the specified display and returns the layer ID.
|
/// Creates a layer on the specified display and returns the layer ID.
|
||||||
///
|
///
|
||||||
/// If an invalid display ID is specified, then an empty optional is returned.
|
/// If an invalid display ID is specified, then an empty optional is returned.
|
||||||
[[nodiscard]] std::optional<u64> CreateLayer(u64 display_id);
|
[[nodiscard]] std::optional<u64> CreateLayer(u64 display_id,
|
||||||
|
LayerBlending blending = LayerBlending::None);
|
||||||
|
|
||||||
/// Opens a layer on all displays for the given layer ID.
|
/// Opens a layer on all displays for the given layer ID.
|
||||||
bool OpenLayer(u64 layer_id);
|
bool OpenLayer(u64 layer_id);
|
||||||
|
@ -128,7 +130,7 @@ private:
|
||||||
[[nodiscard]] VI::Layer* FindLayer(u64 display_id, u64 layer_id);
|
[[nodiscard]] VI::Layer* FindLayer(u64 display_id, u64 layer_id);
|
||||||
|
|
||||||
/// Creates a layer with the specified layer ID in the desired display.
|
/// Creates a layer with the specified layer ID in the desired display.
|
||||||
void CreateLayerAtId(VI::Display& display, u64 layer_id);
|
void CreateLayerAtId(VI::Display& display, u64 layer_id, LayerBlending blending);
|
||||||
|
|
||||||
void SplitVSync(std::stop_token stop_token);
|
void SplitVSync(std::stop_token stop_token);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "core/hle/service/nvnflinger/hwc_layer.h"
|
||||||
#include "core/hle/service/vi/layer/vi_layer.h"
|
#include "core/hle/service/vi/layer/vi_layer.h"
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
@ -8,8 +9,9 @@ namespace Service::VI {
|
||||||
Layer::Layer(u64 layer_id_, u32 binder_id_, android::BufferQueueCore& core_,
|
Layer::Layer(u64 layer_id_, u32 binder_id_, android::BufferQueueCore& core_,
|
||||||
android::BufferQueueProducer& binder_,
|
android::BufferQueueProducer& binder_,
|
||||||
std::shared_ptr<android::BufferItemConsumer>&& consumer_)
|
std::shared_ptr<android::BufferItemConsumer>&& consumer_)
|
||||||
: layer_id{layer_id_}, binder_id{binder_id_}, core{core_}, binder{binder_},
|
: layer_id{layer_id_}, binder_id{binder_id_}, core{core_}, binder{binder_}, consumer{std::move(
|
||||||
consumer{std::move(consumer_)}, open{false}, visible{true} {}
|
consumer_)},
|
||||||
|
blending{Nvnflinger::LayerBlending::None}, open{false}, visible{true} {}
|
||||||
|
|
||||||
Layer::~Layer() = default;
|
Layer::~Layer() = default;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@ class BufferQueueCore;
|
||||||
class BufferQueueProducer;
|
class BufferQueueProducer;
|
||||||
} // namespace Service::android
|
} // namespace Service::android
|
||||||
|
|
||||||
|
namespace Service::Nvnflinger {
|
||||||
|
enum class LayerBlending : u32;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
/// Represents a single display layer.
|
/// Represents a single display layer.
|
||||||
|
@ -92,12 +96,21 @@ public:
|
||||||
return !std::exchange(open, true);
|
return !std::exchange(open, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Nvnflinger::LayerBlending GetBlending() {
|
||||||
|
return blending;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBlending(Nvnflinger::LayerBlending b) {
|
||||||
|
blending = b;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const u64 layer_id;
|
const u64 layer_id;
|
||||||
const u32 binder_id;
|
const u32 binder_id;
|
||||||
android::BufferQueueCore& core;
|
android::BufferQueueCore& core;
|
||||||
android::BufferQueueProducer& binder;
|
android::BufferQueueProducer& binder;
|
||||||
std::shared_ptr<android::BufferItemConsumer> consumer;
|
std::shared_ptr<android::BufferItemConsumer> consumer;
|
||||||
|
Service::Nvnflinger::LayerBlending blending;
|
||||||
bool open;
|
bool open;
|
||||||
bool visible;
|
bool visible;
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
|
|
||||||
|
enum class BlendMode {
|
||||||
|
Opaque,
|
||||||
|
Premultiplied,
|
||||||
|
Coverage,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Struct describing framebuffer configuration
|
* Struct describing framebuffer configuration
|
||||||
*/
|
*/
|
||||||
|
@ -23,6 +29,7 @@ struct FramebufferConfig {
|
||||||
Service::android::PixelFormat pixel_format{};
|
Service::android::PixelFormat pixel_format{};
|
||||||
Service::android::BufferTransformFlags transform_flags{};
|
Service::android::BufferTransformFlags transform_flags{};
|
||||||
Common::Rectangle<int> crop_rect{};
|
Common::Rectangle<int> crop_rect{};
|
||||||
|
BlendMode blending{};
|
||||||
};
|
};
|
||||||
|
|
||||||
Common::Rectangle<f32> NormalizeCrop(const FramebufferConfig& framebuffer, u32 texture_width,
|
Common::Rectangle<f32> NormalizeCrop(const FramebufferConfig& framebuffer, u32 texture_width,
|
||||||
|
|
|
@ -37,6 +37,7 @@ layout(set=0,binding=0) uniform sampler2D InputTexture;
|
||||||
|
|
||||||
#define A_GPU 1
|
#define A_GPU 1
|
||||||
#define A_GLSL 1
|
#define A_GLSL 1
|
||||||
|
#define FSR_RCAS_PASSTHROUGH_ALPHA 1
|
||||||
|
|
||||||
#ifndef YUZU_USE_FP16
|
#ifndef YUZU_USE_FP16
|
||||||
#include "ffx_a.h"
|
#include "ffx_a.h"
|
||||||
|
@ -71,9 +72,7 @@ layout(set=0,binding=0) uniform sampler2D InputTexture;
|
||||||
|
|
||||||
#include "ffx_fsr1.h"
|
#include "ffx_fsr1.h"
|
||||||
|
|
||||||
#if USE_RCAS
|
layout (location = 0) in vec2 frag_texcoord;
|
||||||
layout(location = 0) in vec2 frag_texcoord;
|
|
||||||
#endif
|
|
||||||
layout (location = 0) out vec4 frag_color;
|
layout (location = 0) out vec4 frag_color;
|
||||||
|
|
||||||
void CurrFilter(AU2 pos) {
|
void CurrFilter(AU2 pos) {
|
||||||
|
@ -81,22 +80,22 @@ void CurrFilter(AU2 pos) {
|
||||||
#ifndef YUZU_USE_FP16
|
#ifndef YUZU_USE_FP16
|
||||||
AF3 c;
|
AF3 c;
|
||||||
FsrEasuF(c, pos, Const0, Const1, Const2, Const3);
|
FsrEasuF(c, pos, Const0, Const1, Const2, Const3);
|
||||||
frag_color = AF4(c, 1.0);
|
frag_color = AF4(c, texture(InputTexture, frag_texcoord).a);
|
||||||
#else
|
#else
|
||||||
AH3 c;
|
AH3 c;
|
||||||
FsrEasuH(c, pos, Const0, Const1, Const2, Const3);
|
FsrEasuH(c, pos, Const0, Const1, Const2, Const3);
|
||||||
frag_color = AH4(c, 1.0);
|
frag_color = AH4(c, texture(InputTexture, frag_texcoord).a);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if USE_RCAS
|
#if USE_RCAS
|
||||||
#ifndef YUZU_USE_FP16
|
#ifndef YUZU_USE_FP16
|
||||||
AF3 c;
|
AF4 c;
|
||||||
FsrRcasF(c.r, c.g, c.b, pos, Const0);
|
FsrRcasF(c.r, c.g, c.b, c.a, pos, Const0);
|
||||||
frag_color = AF4(c, 1.0);
|
frag_color = c;
|
||||||
#else
|
#else
|
||||||
AH3 c;
|
AH4 c;
|
||||||
FsrRcasH(c.r, c.g, c.b, pos, Const0);
|
FsrRcasH(c.r, c.g, c.b, c.a, pos, Const0);
|
||||||
frag_color = AH4(c, 1.0);
|
frag_color = c;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,5 +71,5 @@ vec3 FxaaPixelShader(vec4 posPos, sampler2D tex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
frag_color = vec4(FxaaPixelShader(posPos, input_texture), 1.0);
|
frag_color = vec4(FxaaPixelShader(posPos, input_texture), texture(input_texture, posPos.xy).a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ layout (location = 0) uniform uvec4 constants[4];
|
||||||
|
|
||||||
#define A_GPU 1
|
#define A_GPU 1
|
||||||
#define A_GLSL 1
|
#define A_GLSL 1
|
||||||
|
#define FSR_RCAS_PASSTHROUGH_ALPHA 1
|
||||||
|
|
||||||
#ifdef YUZU_USE_FP16
|
#ifdef YUZU_USE_FP16
|
||||||
#define A_HALF
|
#define A_HALF
|
||||||
|
@ -67,9 +68,7 @@ layout (location = 0) uniform uvec4 constants[4];
|
||||||
|
|
||||||
#include "ffx_fsr1.h"
|
#include "ffx_fsr1.h"
|
||||||
|
|
||||||
#if USE_RCAS
|
layout (location = 0) in vec2 frag_texcoord;
|
||||||
layout(location = 0) in vec2 frag_texcoord;
|
|
||||||
#endif
|
|
||||||
layout (location = 0) out vec4 frag_color;
|
layout (location = 0) out vec4 frag_color;
|
||||||
|
|
||||||
void CurrFilter(AU2 pos)
|
void CurrFilter(AU2 pos)
|
||||||
|
@ -78,22 +77,22 @@ void CurrFilter(AU2 pos)
|
||||||
#ifndef YUZU_USE_FP16
|
#ifndef YUZU_USE_FP16
|
||||||
AF3 c;
|
AF3 c;
|
||||||
FsrEasuF(c, pos, constants[0], constants[1], constants[2], constants[3]);
|
FsrEasuF(c, pos, constants[0], constants[1], constants[2], constants[3]);
|
||||||
frag_color = AF4(c, 1.0);
|
frag_color = AF4(c, texture(InputTexture, frag_texcoord).a);
|
||||||
#else
|
#else
|
||||||
AH3 c;
|
AH3 c;
|
||||||
FsrEasuH(c, pos, constants[0], constants[1], constants[2], constants[3]);
|
FsrEasuH(c, pos, constants[0], constants[1], constants[2], constants[3]);
|
||||||
frag_color = AH4(c, 1.0);
|
frag_color = AH4(c, texture(InputTexture, frag_texcoord).a);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if USE_RCAS
|
#if USE_RCAS
|
||||||
#ifndef YUZU_USE_FP16
|
#ifndef YUZU_USE_FP16
|
||||||
AF3 c;
|
AF4 c;
|
||||||
FsrRcasF(c.r, c.g, c.b, pos, constants[0]);
|
FsrRcasF(c.r, c.g, c.b, c.a, pos, constants[0]);
|
||||||
frag_color = AF4(c, 1.0);
|
frag_color = c;
|
||||||
#else
|
#else
|
||||||
AH3 c;
|
AH3 c;
|
||||||
FsrRcasH(c.r, c.g, c.b, pos, constants[0]);
|
FsrRcasH(c.r, c.g, c.b, c.a, pos, constants[0]);
|
||||||
frag_color = AH4(c, 1.0);
|
frag_color = c;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@ layout (location = 0) out vec4 color;
|
||||||
layout (binding = 0) uniform sampler2D color_texture;
|
layout (binding = 0) uniform sampler2D color_texture;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
color = vec4(texture(color_texture, frag_tex_coord).rgb, 1.0f);
|
color = vec4(texture(color_texture, frag_tex_coord));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,5 +52,5 @@ vec4 textureBicubic( sampler2D textureSampler, vec2 texCoords ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
color = vec4(textureBicubic(color_texture, frag_tex_coord).rgb, 1.0f);
|
color = textureBicubic(color_texture, frag_tex_coord);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,14 @@ vec4 blurDiagonal(sampler2D textureSampler, vec2 coord, vec2 norm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 base = texture(color_texture, vec2(frag_tex_coord)).rgb * weight[0];
|
vec4 base = texture(color_texture, vec2(frag_tex_coord)) * weight[0];
|
||||||
vec2 tex_offset = 1.0f / textureSize(color_texture, 0);
|
vec2 tex_offset = 1.0f / textureSize(color_texture, 0);
|
||||||
|
|
||||||
// TODO(Blinkhawk): This code can be optimized through shader group instructions.
|
// TODO(Blinkhawk): This code can be optimized through shader group instructions.
|
||||||
vec3 horizontal = blurHorizontal(color_texture, frag_tex_coord, tex_offset).rgb;
|
vec4 horizontal = blurHorizontal(color_texture, frag_tex_coord, tex_offset);
|
||||||
vec3 vertical = blurVertical(color_texture, frag_tex_coord, tex_offset).rgb;
|
vec4 vertical = blurVertical(color_texture, frag_tex_coord, tex_offset);
|
||||||
vec3 diagonalA = blurDiagonal(color_texture, frag_tex_coord, tex_offset).rgb;
|
vec4 diagonalA = blurDiagonal(color_texture, frag_tex_coord, tex_offset);
|
||||||
vec3 diagonalB = blurDiagonal(color_texture, frag_tex_coord, tex_offset * vec2(1.0, -1.0)).rgb;
|
vec4 diagonalB = blurDiagonal(color_texture, frag_tex_coord, tex_offset * vec2(1.0, -1.0));
|
||||||
vec3 combination = mix(mix(horizontal, vertical, 0.5f), mix(diagonalA, diagonalB, 0.5f), 0.5f);
|
vec4 combination = mix(mix(horizontal, vertical, 0.5f), mix(diagonalA, diagonalB, 0.5f), 0.5f);
|
||||||
color = vec4(combination + base, 1.0f);
|
color = combination + base;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
|
|
||||||
#define YUZU_USE_FP16
|
#define YUZU_USE_FP16
|
||||||
#define USE_EASU 1
|
#define USE_EASU 1
|
||||||
|
#define VERSION 1
|
||||||
|
|
||||||
#include "fidelityfx_fsr.frag"
|
#include "fidelityfx_fsr.frag"
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
#extension GL_GOOGLE_include_directive : enable
|
#extension GL_GOOGLE_include_directive : enable
|
||||||
|
|
||||||
#define USE_EASU 1
|
#define USE_EASU 1
|
||||||
|
#define VERSION 1
|
||||||
|
|
||||||
#include "fidelityfx_fsr.frag"
|
#include "fidelityfx_fsr.frag"
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
|
|
||||||
#define YUZU_USE_FP16
|
#define YUZU_USE_FP16
|
||||||
#define USE_RCAS 1
|
#define USE_RCAS 1
|
||||||
|
#define VERSION 1
|
||||||
|
|
||||||
#include "fidelityfx_fsr.frag"
|
#include "fidelityfx_fsr.frag"
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
#extension GL_GOOGLE_include_directive : enable
|
#extension GL_GOOGLE_include_directive : enable
|
||||||
|
|
||||||
#define USE_RCAS 1
|
#define USE_RCAS 1
|
||||||
|
#define VERSION 1
|
||||||
|
|
||||||
#include "fidelityfx_fsr.frag"
|
#include "fidelityfx_fsr.frag"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#extension GL_GOOGLE_include_directive : enable
|
#extension GL_GOOGLE_include_directive : enable
|
||||||
|
|
||||||
#define VERSION 1
|
#define VERSION 2
|
||||||
#define YUZU_USE_FP16
|
#define YUZU_USE_FP16
|
||||||
|
|
||||||
#include "opengl_present_scaleforce.frag"
|
#include "opengl_present_scaleforce.frag"
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
|
|
||||||
#extension GL_GOOGLE_include_directive : enable
|
#extension GL_GOOGLE_include_directive : enable
|
||||||
|
|
||||||
#define VERSION 1
|
#define VERSION 2
|
||||||
|
|
||||||
#include "opengl_present_scaleforce.frag"
|
#include "opengl_present_scaleforce.frag"
|
||||||
|
|
|
@ -92,6 +92,21 @@ void WindowAdaptPass::DrawToFramebuffer(ProgramManager& program_manager, std::li
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
for (size_t i = 0; i < layer_count; i++) {
|
for (size_t i = 0; i < layer_count; i++) {
|
||||||
|
switch (framebuffers[i].blending) {
|
||||||
|
case Tegra::BlendMode::Opaque:
|
||||||
|
default:
|
||||||
|
glDisablei(GL_BLEND, 0);
|
||||||
|
break;
|
||||||
|
case Tegra::BlendMode::Premultiplied:
|
||||||
|
glEnablei(GL_BLEND, 0);
|
||||||
|
glBlendFuncSeparatei(0, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
|
break;
|
||||||
|
case Tegra::BlendMode::Coverage:
|
||||||
|
glEnablei(GL_BLEND, 0);
|
||||||
|
glBlendFuncSeparatei(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
glBindTextureUnit(0, textures[i]);
|
glBindTextureUnit(0, textures[i]);
|
||||||
glProgramUniformMatrix3x2fv(vert.handle, ModelViewMatrixLocation, 1, GL_FALSE,
|
glProgramUniformMatrix3x2fv(vert.handle, ModelViewMatrixLocation, 1, GL_FALSE,
|
||||||
matrices[i].data());
|
matrices[i].data());
|
||||||
|
|
|
@ -362,10 +362,10 @@ vk::PipelineLayout CreateWrappedPipelineLayout(const Device& device,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::Pipeline CreateWrappedPipeline(const Device& device, vk::RenderPass& renderpass,
|
static vk::Pipeline CreateWrappedPipelineImpl(
|
||||||
vk::PipelineLayout& layout,
|
const Device& device, vk::RenderPass& renderpass, vk::PipelineLayout& layout,
|
||||||
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders,
|
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders,
|
||||||
bool enable_blending) {
|
VkPipelineColorBlendAttachmentState blending) {
|
||||||
const std::array<VkPipelineShaderStageCreateInfo, 2> shader_stages{{
|
const std::array<VkPipelineShaderStageCreateInfo, 2> shader_stages{{
|
||||||
{
|
{
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||||
|
@ -443,30 +443,6 @@ vk::Pipeline CreateWrappedPipeline(const Device& device, vk::RenderPass& renderp
|
||||||
.alphaToOneEnable = VK_FALSE,
|
.alphaToOneEnable = VK_FALSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr VkPipelineColorBlendAttachmentState color_blend_attachment_disabled{
|
|
||||||
.blendEnable = VK_FALSE,
|
|
||||||
.srcColorBlendFactor = VK_BLEND_FACTOR_ZERO,
|
|
||||||
.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO,
|
|
||||||
.colorBlendOp = VK_BLEND_OP_ADD,
|
|
||||||
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
|
|
||||||
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
|
|
||||||
.alphaBlendOp = VK_BLEND_OP_ADD,
|
|
||||||
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
|
||||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr VkPipelineColorBlendAttachmentState color_blend_attachment_enabled{
|
|
||||||
.blendEnable = VK_TRUE,
|
|
||||||
.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA,
|
|
||||||
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
|
||||||
.colorBlendOp = VK_BLEND_OP_ADD,
|
|
||||||
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE,
|
|
||||||
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
|
|
||||||
.alphaBlendOp = VK_BLEND_OP_ADD,
|
|
||||||
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
|
||||||
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
|
||||||
};
|
|
||||||
|
|
||||||
const VkPipelineColorBlendStateCreateInfo color_blend_ci{
|
const VkPipelineColorBlendStateCreateInfo color_blend_ci{
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
|
@ -474,8 +450,7 @@ vk::Pipeline CreateWrappedPipeline(const Device& device, vk::RenderPass& renderp
|
||||||
.logicOpEnable = VK_FALSE,
|
.logicOpEnable = VK_FALSE,
|
||||||
.logicOp = VK_LOGIC_OP_COPY,
|
.logicOp = VK_LOGIC_OP_COPY,
|
||||||
.attachmentCount = 1,
|
.attachmentCount = 1,
|
||||||
.pAttachments =
|
.pAttachments = &blending,
|
||||||
enable_blending ? &color_blend_attachment_enabled : &color_blend_attachment_disabled,
|
|
||||||
.blendConstants = {0.0f, 0.0f, 0.0f, 0.0f},
|
.blendConstants = {0.0f, 0.0f, 0.0f, 0.0f},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -515,6 +490,63 @@ vk::Pipeline CreateWrappedPipeline(const Device& device, vk::RenderPass& renderp
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vk::Pipeline CreateWrappedPipeline(const Device& device, vk::RenderPass& renderpass,
|
||||||
|
vk::PipelineLayout& layout,
|
||||||
|
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders) {
|
||||||
|
constexpr VkPipelineColorBlendAttachmentState color_blend_attachment_disabled{
|
||||||
|
.blendEnable = VK_FALSE,
|
||||||
|
.srcColorBlendFactor = VK_BLEND_FACTOR_ZERO,
|
||||||
|
.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO,
|
||||||
|
.colorBlendOp = VK_BLEND_OP_ADD,
|
||||||
|
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
|
||||||
|
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
|
||||||
|
.alphaBlendOp = VK_BLEND_OP_ADD,
|
||||||
|
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||||
|
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
||||||
|
};
|
||||||
|
|
||||||
|
return CreateWrappedPipelineImpl(device, renderpass, layout, shaders,
|
||||||
|
color_blend_attachment_disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
vk::Pipeline CreateWrappedPremultipliedBlendingPipeline(
|
||||||
|
const Device& device, vk::RenderPass& renderpass, vk::PipelineLayout& layout,
|
||||||
|
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders) {
|
||||||
|
constexpr VkPipelineColorBlendAttachmentState color_blend_attachment_premultiplied{
|
||||||
|
.blendEnable = VK_TRUE,
|
||||||
|
.srcColorBlendFactor = VK_BLEND_FACTOR_ONE,
|
||||||
|
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||||
|
.colorBlendOp = VK_BLEND_OP_ADD,
|
||||||
|
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE,
|
||||||
|
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
|
||||||
|
.alphaBlendOp = VK_BLEND_OP_ADD,
|
||||||
|
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||||
|
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
||||||
|
};
|
||||||
|
|
||||||
|
return CreateWrappedPipelineImpl(device, renderpass, layout, shaders,
|
||||||
|
color_blend_attachment_premultiplied);
|
||||||
|
}
|
||||||
|
|
||||||
|
vk::Pipeline CreateWrappedCoverageBlendingPipeline(
|
||||||
|
const Device& device, vk::RenderPass& renderpass, vk::PipelineLayout& layout,
|
||||||
|
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders) {
|
||||||
|
constexpr VkPipelineColorBlendAttachmentState color_blend_attachment_coverage{
|
||||||
|
.blendEnable = VK_TRUE,
|
||||||
|
.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA,
|
||||||
|
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||||
|
.colorBlendOp = VK_BLEND_OP_ADD,
|
||||||
|
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE,
|
||||||
|
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
|
||||||
|
.alphaBlendOp = VK_BLEND_OP_ADD,
|
||||||
|
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||||
|
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
||||||
|
};
|
||||||
|
|
||||||
|
return CreateWrappedPipelineImpl(device, renderpass, layout, shaders,
|
||||||
|
color_blend_attachment_coverage);
|
||||||
|
}
|
||||||
|
|
||||||
VkWriteDescriptorSet CreateWriteDescriptorSet(std::vector<VkDescriptorImageInfo>& images,
|
VkWriteDescriptorSet CreateWriteDescriptorSet(std::vector<VkDescriptorImageInfo>& images,
|
||||||
VkSampler sampler, VkImageView view,
|
VkSampler sampler, VkImageView view,
|
||||||
VkDescriptorSet set, u32 binding) {
|
VkDescriptorSet set, u32 binding) {
|
||||||
|
|
|
@ -42,8 +42,13 @@ vk::PipelineLayout CreateWrappedPipelineLayout(const Device& device,
|
||||||
vk::DescriptorSetLayout& layout);
|
vk::DescriptorSetLayout& layout);
|
||||||
vk::Pipeline CreateWrappedPipeline(const Device& device, vk::RenderPass& renderpass,
|
vk::Pipeline CreateWrappedPipeline(const Device& device, vk::RenderPass& renderpass,
|
||||||
vk::PipelineLayout& layout,
|
vk::PipelineLayout& layout,
|
||||||
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders,
|
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders);
|
||||||
bool enable_blending = false);
|
vk::Pipeline CreateWrappedPremultipliedBlendingPipeline(
|
||||||
|
const Device& device, vk::RenderPass& renderpass, vk::PipelineLayout& layout,
|
||||||
|
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders);
|
||||||
|
vk::Pipeline CreateWrappedCoverageBlendingPipeline(
|
||||||
|
const Device& device, vk::RenderPass& renderpass, vk::PipelineLayout& layout,
|
||||||
|
std::tuple<vk::ShaderModule&, vk::ShaderModule&> shaders);
|
||||||
VkWriteDescriptorSet CreateWriteDescriptorSet(std::vector<VkDescriptorImageInfo>& images,
|
VkWriteDescriptorSet CreateWriteDescriptorSet(std::vector<VkDescriptorImageInfo>& images,
|
||||||
VkSampler sampler, VkImageView view,
|
VkSampler sampler, VkImageView view,
|
||||||
VkDescriptorSet set, u32 binding);
|
VkDescriptorSet set, u32 binding);
|
||||||
|
|
|
@ -22,7 +22,7 @@ WindowAdaptPass::WindowAdaptPass(const Device& device_, VkFormat frame_format,
|
||||||
CreatePipelineLayout();
|
CreatePipelineLayout();
|
||||||
CreateVertexShader();
|
CreateVertexShader();
|
||||||
CreateRenderPass(frame_format);
|
CreateRenderPass(frame_format);
|
||||||
CreatePipeline();
|
CreatePipelines();
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowAdaptPass::~WindowAdaptPass() = default;
|
WindowAdaptPass::~WindowAdaptPass() = default;
|
||||||
|
@ -34,7 +34,6 @@ void WindowAdaptPass::Draw(RasterizerVulkan& rasterizer, Scheduler& scheduler, s
|
||||||
|
|
||||||
const VkFramebuffer host_framebuffer{*dst->framebuffer};
|
const VkFramebuffer host_framebuffer{*dst->framebuffer};
|
||||||
const VkRenderPass renderpass{*render_pass};
|
const VkRenderPass renderpass{*render_pass};
|
||||||
const VkPipeline graphics_pipeline{*pipeline};
|
|
||||||
const VkPipelineLayout graphics_pipeline_layout{*pipeline_layout};
|
const VkPipelineLayout graphics_pipeline_layout{*pipeline_layout};
|
||||||
const VkExtent2D render_area{
|
const VkExtent2D render_area{
|
||||||
.width = dst->width,
|
.width = dst->width,
|
||||||
|
@ -44,9 +43,23 @@ void WindowAdaptPass::Draw(RasterizerVulkan& rasterizer, Scheduler& scheduler, s
|
||||||
const size_t layer_count = configs.size();
|
const size_t layer_count = configs.size();
|
||||||
std::vector<PresentPushConstants> push_constants(layer_count);
|
std::vector<PresentPushConstants> push_constants(layer_count);
|
||||||
std::vector<VkDescriptorSet> descriptor_sets(layer_count);
|
std::vector<VkDescriptorSet> descriptor_sets(layer_count);
|
||||||
|
std::vector<VkPipeline> graphics_pipelines(layer_count);
|
||||||
|
|
||||||
auto layer_it = layers.begin();
|
auto layer_it = layers.begin();
|
||||||
for (size_t i = 0; i < layer_count; i++) {
|
for (size_t i = 0; i < layer_count; i++) {
|
||||||
|
switch (configs[i].blending) {
|
||||||
|
case Tegra::BlendMode::Opaque:
|
||||||
|
default:
|
||||||
|
graphics_pipelines[i] = *opaque_pipeline;
|
||||||
|
break;
|
||||||
|
case Tegra::BlendMode::Premultiplied:
|
||||||
|
graphics_pipelines[i] = *premultiplied_pipeline;
|
||||||
|
break;
|
||||||
|
case Tegra::BlendMode::Coverage:
|
||||||
|
graphics_pipelines[i] = *coverage_pipeline;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
layer_it->ConfigureDraw(&push_constants[i], &descriptor_sets[i], rasterizer, *sampler,
|
layer_it->ConfigureDraw(&push_constants[i], &descriptor_sets[i], rasterizer, *sampler,
|
||||||
image_index, configs[i], layout);
|
image_index, configs[i], layout);
|
||||||
layer_it++;
|
layer_it++;
|
||||||
|
@ -77,8 +90,8 @@ void WindowAdaptPass::Draw(RasterizerVulkan& rasterizer, Scheduler& scheduler, s
|
||||||
BeginRenderPass(cmdbuf, renderpass, host_framebuffer, render_area);
|
BeginRenderPass(cmdbuf, renderpass, host_framebuffer, render_area);
|
||||||
cmdbuf.ClearAttachments({clear_attachment}, {clear_rect});
|
cmdbuf.ClearAttachments({clear_attachment}, {clear_rect});
|
||||||
|
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, graphics_pipeline);
|
|
||||||
for (size_t i = 0; i < layer_count; i++) {
|
for (size_t i = 0; i < layer_count; i++) {
|
||||||
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, graphics_pipelines[i]);
|
||||||
cmdbuf.PushConstants(graphics_pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT,
|
cmdbuf.PushConstants(graphics_pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT,
|
||||||
push_constants[i]);
|
push_constants[i]);
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, graphics_pipeline_layout, 0,
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, graphics_pipeline_layout, 0,
|
||||||
|
@ -129,9 +142,13 @@ void WindowAdaptPass::CreateRenderPass(VkFormat frame_format) {
|
||||||
render_pass = CreateWrappedRenderPass(device, frame_format, VK_IMAGE_LAYOUT_UNDEFINED);
|
render_pass = CreateWrappedRenderPass(device, frame_format, VK_IMAGE_LAYOUT_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowAdaptPass::CreatePipeline() {
|
void WindowAdaptPass::CreatePipelines() {
|
||||||
pipeline = CreateWrappedPipeline(device, render_pass, pipeline_layout,
|
opaque_pipeline = CreateWrappedPipeline(device, render_pass, pipeline_layout,
|
||||||
std::tie(vertex_shader, fragment_shader), false);
|
std::tie(vertex_shader, fragment_shader));
|
||||||
|
premultiplied_pipeline = CreateWrappedPremultipliedBlendingPipeline(
|
||||||
|
device, render_pass, pipeline_layout, std::tie(vertex_shader, fragment_shader));
|
||||||
|
coverage_pipeline = CreateWrappedCoverageBlendingPipeline(
|
||||||
|
device, render_pass, pipeline_layout, std::tie(vertex_shader, fragment_shader));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -42,7 +42,7 @@ private:
|
||||||
void CreatePipelineLayout();
|
void CreatePipelineLayout();
|
||||||
void CreateVertexShader();
|
void CreateVertexShader();
|
||||||
void CreateRenderPass(VkFormat frame_format);
|
void CreateRenderPass(VkFormat frame_format);
|
||||||
void CreatePipeline();
|
void CreatePipelines();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Device& device;
|
const Device& device;
|
||||||
|
@ -52,7 +52,9 @@ private:
|
||||||
vk::ShaderModule vertex_shader;
|
vk::ShaderModule vertex_shader;
|
||||||
vk::ShaderModule fragment_shader;
|
vk::ShaderModule fragment_shader;
|
||||||
vk::RenderPass render_pass;
|
vk::RenderPass render_pass;
|
||||||
vk::Pipeline pipeline;
|
vk::Pipeline opaque_pipeline;
|
||||||
|
vk::Pipeline premultiplied_pipeline;
|
||||||
|
vk::Pipeline coverage_pipeline;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -101,8 +101,10 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
|
||||||
surface),
|
surface),
|
||||||
blit_swapchain(device_memory, device, memory_allocator, present_manager, scheduler),
|
blit_swapchain(device_memory, device, memory_allocator, present_manager, scheduler),
|
||||||
blit_screenshot(device_memory, device, memory_allocator, present_manager, scheduler),
|
blit_screenshot(device_memory, device, memory_allocator, present_manager, scheduler),
|
||||||
|
blit_application_layer(device_memory, device, memory_allocator, present_manager, scheduler),
|
||||||
rasterizer(render_window, gpu, device_memory, device, memory_allocator, state_tracker,
|
rasterizer(render_window, gpu, device_memory, device, memory_allocator, state_tracker,
|
||||||
scheduler) {
|
scheduler),
|
||||||
|
application_frame() {
|
||||||
if (Settings::values.renderer_force_max_clock.GetValue() && device.ShouldBoostClocks()) {
|
if (Settings::values.renderer_force_max_clock.GetValue() && device.ShouldBoostClocks()) {
|
||||||
turbo_mode.emplace(instance, dld);
|
turbo_mode.emplace(instance, dld);
|
||||||
scheduler.RegisterOnSubmit([this] { turbo_mode->QueueSubmitted(); });
|
scheduler.RegisterOnSubmit([this] { turbo_mode->QueueSubmitted(); });
|
||||||
|
|
|
@ -80,8 +80,11 @@ private:
|
||||||
PresentManager present_manager;
|
PresentManager present_manager;
|
||||||
BlitScreen blit_swapchain;
|
BlitScreen blit_swapchain;
|
||||||
BlitScreen blit_screenshot;
|
BlitScreen blit_screenshot;
|
||||||
|
BlitScreen blit_application_layer;
|
||||||
RasterizerVulkan rasterizer;
|
RasterizerVulkan rasterizer;
|
||||||
std::optional<TurboMode> turbo_mode;
|
std::optional<TurboMode> turbo_mode;
|
||||||
|
|
||||||
|
Frame application_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -746,7 +746,13 @@ std::pair<typename P::ImageView*, bool> TextureCache<P>::TryFindFramebufferImage
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const auto GetImageViewForFramebuffer = [&](ImageId image_id) {
|
const auto GetImageViewForFramebuffer = [&](ImageId image_id) {
|
||||||
const ImageViewInfo info{ImageViewType::e2D, view_format};
|
ImageViewInfo info{ImageViewType::e2D, view_format};
|
||||||
|
if (config.blending == Tegra::BlendMode::Opaque) {
|
||||||
|
info.x_source = static_cast<u8>(SwizzleSource::R);
|
||||||
|
info.y_source = static_cast<u8>(SwizzleSource::G);
|
||||||
|
info.z_source = static_cast<u8>(SwizzleSource::B);
|
||||||
|
info.w_source = static_cast<u8>(SwizzleSource::OneFloat);
|
||||||
|
}
|
||||||
return std::make_pair(&slot_image_views[FindOrEmplaceImageView(image_id, info)],
|
return std::make_pair(&slot_image_views[FindOrEmplaceImageView(image_id, info)],
|
||||||
slot_images[image_id].IsRescaled());
|
slot_images[image_id].IsRescaled());
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue