mirror of
https://github.com/azahar-emu/azahar.git
synced 2025-04-28 13:47:59 +03:00
Merge a03b258521
into 4a34bcfcbf
This commit is contained in:
commit
f5a8899ec6
4 changed files with 40 additions and 8 deletions
|
@ -495,7 +495,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="lb_opacity_second_layer">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Bottom Screen Opacity % (OpenGL Only)</p></body></html></string>
|
||||
<string><html><head/><body><p>Bottom Screen Opacity %</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -698,8 +698,7 @@ void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool f
|
|||
void RendererOpenGL::ApplySecondLayerOpacity(bool isPortrait) {
|
||||
// TODO: Allow for second layer opacity in portrait mode android
|
||||
|
||||
if (!isPortrait &&
|
||||
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout) &&
|
||||
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout &&
|
||||
Settings::values.custom_second_layer_opacity.GetValue() < 100) {
|
||||
state.blend.src_rgb_func = GL_CONSTANT_ALPHA;
|
||||
state.blend.src_a_func = GL_CONSTANT_ALPHA;
|
||||
|
@ -710,8 +709,7 @@ void RendererOpenGL::ApplySecondLayerOpacity(bool isPortrait) {
|
|||
}
|
||||
|
||||
void RendererOpenGL::ResetSecondLayerOpacity(bool isPortrait) {
|
||||
if (!isPortrait &&
|
||||
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout) &&
|
||||
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout &&
|
||||
Settings::values.custom_second_layer_opacity.GetValue() < 100) {
|
||||
state.blend.src_rgb_func = GL_ONE;
|
||||
state.blend.dst_rgb_func = GL_ZERO;
|
||||
|
|
|
@ -316,7 +316,13 @@ void RendererVulkan::BuildPipelines() {
|
|||
};
|
||||
|
||||
const vk::PipelineColorBlendAttachmentState colorblend_attachment = {
|
||||
.blendEnable = false,
|
||||
.blendEnable = true,
|
||||
.srcColorBlendFactor = vk::BlendFactor::eConstantAlpha,
|
||||
.dstColorBlendFactor = vk::BlendFactor::eOneMinusConstantAlpha,
|
||||
.colorBlendOp = vk::BlendOp::eAdd,
|
||||
.srcAlphaBlendFactor = vk::BlendFactor::eConstantAlpha,
|
||||
.dstAlphaBlendFactor = vk::BlendFactor::eOneMinusConstantAlpha,
|
||||
.alphaBlendOp = vk::BlendOp::eAdd,
|
||||
.colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG |
|
||||
vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA,
|
||||
};
|
||||
|
@ -325,7 +331,6 @@ void RendererVulkan::BuildPipelines() {
|
|||
.logicOpEnable = false,
|
||||
.attachmentCount = 1,
|
||||
.pAttachments = &colorblend_attachment,
|
||||
.blendConstants = std::array{1.0f, 1.0f, 1.0f, 1.0f},
|
||||
};
|
||||
|
||||
const vk::Viewport placeholder_viewport = vk::Viewport{0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f};
|
||||
|
@ -338,6 +343,7 @@ void RendererVulkan::BuildPipelines() {
|
|||
};
|
||||
|
||||
const std::array dynamic_states = {
|
||||
vk::DynamicState::eBlendConstants,
|
||||
vk::DynamicState::eViewport,
|
||||
vk::DynamicState::eScissor,
|
||||
};
|
||||
|
@ -670,6 +676,13 @@ void RendererVulkan::DrawSingleScreenStereo(u32 screen_id_l, u32 screen_id_r, fl
|
|||
});
|
||||
}
|
||||
|
||||
void RendererVulkan::ApplySecondLayerOpacity(float alpha) {
|
||||
scheduler.Record([alpha](vk::CommandBuffer cmdbuf) {
|
||||
const std::array<float, 4> blend_constants = {0.0f, 0.0f, 0.0f, alpha};
|
||||
cmdbuf.setBlendConstants(blend_constants.data());
|
||||
});
|
||||
}
|
||||
|
||||
void RendererVulkan::DrawTopScreen(const Layout::FramebufferLayout& layout,
|
||||
const Common::Rectangle<u32>& top_screen) {
|
||||
if (!layout.top_screen_enabled) {
|
||||
|
@ -808,13 +821,30 @@ void RendererVulkan::DrawScreens(Frame* frame, const Layout::FramebufferLayout&
|
|||
draw_info.modelview = MakeOrthographicMatrix(layout.width, layout.height);
|
||||
|
||||
draw_info.layer = 0;
|
||||
|
||||
// Apply the initial default opacity value; Needed to avoid flickering
|
||||
ApplySecondLayerOpacity(1.0f);
|
||||
|
||||
bool use_custom_opacity =
|
||||
Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout &&
|
||||
Settings::values.custom_second_layer_opacity.GetValue() < 100;
|
||||
float second_alpha = use_custom_opacity
|
||||
? Settings::values.custom_second_layer_opacity.GetValue() / 100.0f
|
||||
: 1.0f;
|
||||
|
||||
if (!Settings::values.swap_screen.GetValue()) {
|
||||
DrawTopScreen(layout, top_screen);
|
||||
draw_info.layer = 0;
|
||||
if (use_custom_opacity) {
|
||||
ApplySecondLayerOpacity(second_alpha);
|
||||
}
|
||||
DrawBottomScreen(layout, bottom_screen);
|
||||
} else {
|
||||
DrawBottomScreen(layout, bottom_screen);
|
||||
draw_info.layer = 0;
|
||||
if (use_custom_opacity) {
|
||||
ApplySecondLayerOpacity(second_alpha);
|
||||
}
|
||||
DrawTopScreen(layout, top_screen);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2023 Citra Emulator Project
|
||||
// Copyright Citra Emulator Project / Azahar Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
@ -101,12 +101,16 @@ private:
|
|||
void DrawScreens(Frame* frame, const Layout::FramebufferLayout& layout, bool flipped);
|
||||
void DrawBottomScreen(const Layout::FramebufferLayout& layout,
|
||||
const Common::Rectangle<u32>& bottom_screen);
|
||||
|
||||
void DrawTopScreen(const Layout::FramebufferLayout& layout,
|
||||
const Common::Rectangle<u32>& top_screen);
|
||||
void DrawSingleScreen(u32 screen_id, float x, float y, float w, float h,
|
||||
Layout::DisplayOrientation orientation);
|
||||
void DrawSingleScreenStereo(u32 screen_id_l, u32 screen_id_r, float x, float y, float w,
|
||||
float h, Layout::DisplayOrientation orientation);
|
||||
|
||||
void ApplySecondLayerOpacity(float alpha);
|
||||
|
||||
void LoadFBToScreenInfo(const Pica::FramebufferConfig& framebuffer, ScreenInfo& screen_info,
|
||||
bool right_eye);
|
||||
void FillScreen(Common::Vec3<u8> color, const TextureInfo& texture);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue