mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Drop 3D Vision Support
This commit is contained in:
parent
e6ae204600
commit
ae83d02e54
@ -20,7 +20,7 @@
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
// clang-format off
|
||||
constexpr std::array<const char*, 134> s_hotkey_labels{{
|
||||
constexpr std::array<const char*, 133> s_hotkey_labels{{
|
||||
_trans("Open"),
|
||||
_trans("Change Disc"),
|
||||
_trans("Eject Disc"),
|
||||
@ -126,7 +126,6 @@ constexpr std::array<const char*, 134> s_hotkey_labels{{
|
||||
_trans("Toggle 3D Side-by-Side"),
|
||||
_trans("Toggle 3D Top-Bottom"),
|
||||
_trans("Toggle 3D Anaglyph"),
|
||||
_trans("Toggle 3D Vision"),
|
||||
_trans("Decrease Depth"),
|
||||
_trans("Increase Depth"),
|
||||
_trans("Decrease Convergence"),
|
||||
@ -291,7 +290,7 @@ constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
|
||||
{_trans("Internal Resolution"), HK_INCREASE_IR, HK_DECREASE_IR},
|
||||
{_trans("Freelook"), HK_FREELOOK_DECREASE_SPEED, HK_FREELOOK_RESET},
|
||||
// i18n: Stereoscopic 3D
|
||||
{_trans("3D"), HK_TOGGLE_STEREO_SBS, HK_TOGGLE_STEREO_3DVISION},
|
||||
{_trans("3D"), HK_TOGGLE_STEREO_SBS, HK_TOGGLE_STEREO_ANAGLYPH},
|
||||
// i18n: Stereoscopic 3D
|
||||
{_trans("3D Depth"), HK_DECREASE_DEPTH, HK_INCREASE_CONVERGENCE},
|
||||
{_trans("Load State"), HK_LOAD_STATE_SLOT_1, HK_LOAD_STATE_SLOT_SELECTED},
|
||||
|
@ -114,7 +114,6 @@ enum Hotkey
|
||||
HK_TOGGLE_STEREO_SBS,
|
||||
HK_TOGGLE_STEREO_TAB,
|
||||
HK_TOGGLE_STEREO_ANAGLYPH,
|
||||
HK_TOGGLE_STEREO_3DVISION,
|
||||
|
||||
HK_DECREASE_DEPTH,
|
||||
HK_INCREASE_DEPTH,
|
||||
|
@ -235,8 +235,7 @@ void AdvancedWidget::AddDescriptions()
|
||||
"Implements fullscreen mode with a borderless window spanning the whole screen instead of "
|
||||
"using exclusive mode. Allows for faster transitions between fullscreen and windowed mode, "
|
||||
"but slightly increases input latency, makes movement less smooth and slightly decreases "
|
||||
"performance.\n\nExclusive mode is required for Nvidia 3D Vision to work in the Direct3D "
|
||||
"backend.\n\nIf unsure, leave this unchecked.");
|
||||
"performance.\n\nIf unsure, leave this unchecked.");
|
||||
#endif
|
||||
|
||||
AddDescription(m_enable_wireframe, TR_WIREFRAME_DESCRIPTION);
|
||||
|
@ -110,10 +110,9 @@ void EnhancementsWidget::CreateWidgets()
|
||||
auto* stereoscopy_layout = new QGridLayout();
|
||||
stereoscopy_box->setLayout(stereoscopy_layout);
|
||||
|
||||
m_3d_mode =
|
||||
new GraphicsChoice({tr("Off"), tr("Side-by-Side"), tr("Top-and-Bottom"), tr("Anaglyph"),
|
||||
tr("HDMI 3D"), tr("Passive"), tr("NVIDIA 3D Vision")},
|
||||
Config::GFX_STEREO_MODE);
|
||||
m_3d_mode = new GraphicsChoice({tr("Off"), tr("Side-by-Side"), tr("Top-and-Bottom"),
|
||||
tr("Anaglyph"), tr("HDMI 3D"), tr("Passive")},
|
||||
Config::GFX_STEREO_MODE);
|
||||
m_3d_depth = new GraphicsSlider(0, 100, Config::GFX_STEREO_DEPTH);
|
||||
m_3d_convergence = new GraphicsSlider(0, 200, Config::GFX_STEREO_CONVERGENCE, 100);
|
||||
m_3d_swap_eyes = new GraphicsBool(tr("Swap Eyes"), Config::GFX_STEREO_SWAP_EYES);
|
||||
@ -227,18 +226,7 @@ void EnhancementsWidget::LoadSettings()
|
||||
LoadPPShaders();
|
||||
|
||||
// Stereoscopy
|
||||
bool supports_stereoscopy = g_Config.backend_info.bSupportsGeometryShaders;
|
||||
bool supports_3dvision = g_Config.backend_info.bSupports3DVision;
|
||||
|
||||
if (m_3d_mode->currentIndex() == int(StereoMode::Nvidia3DVision) && !supports_3dvision)
|
||||
{
|
||||
m_3d_mode->setCurrentIndex(int(StereoMode::Off));
|
||||
|
||||
ModalMessageBox::information(this, tr("NVIDIA 3D Vision"),
|
||||
tr("NVIDIA 3D Vision is unsupported by the selected backend. "
|
||||
"Stereoscopy has been disabled."));
|
||||
}
|
||||
|
||||
const bool supports_stereoscopy = g_Config.backend_info.bSupportsGeometryShaders;
|
||||
m_3d_mode->setEnabled(supports_stereoscopy);
|
||||
m_3d_convergence->setEnabled(supports_stereoscopy);
|
||||
m_3d_depth->setEnabled(supports_stereoscopy);
|
||||
|
@ -496,21 +496,6 @@ void HotkeyScheduler::Run()
|
||||
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, "");
|
||||
}
|
||||
}
|
||||
|
||||
if (IsHotkey(HK_TOGGLE_STEREO_3DVISION))
|
||||
{
|
||||
if (Config::Get(Config::GFX_STEREO_MODE) != StereoMode::Nvidia3DVision)
|
||||
{
|
||||
if (Config::Get(Config::GFX_ENHANCE_POST_SHADER) == DUBOIS_ALGORITHM_SHADER)
|
||||
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, "");
|
||||
|
||||
Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::Nvidia3DVision);
|
||||
}
|
||||
else
|
||||
{
|
||||
Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::Off);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto stereo_depth = Config::Get(Config::GFX_STEREO_DEPTH);
|
||||
|
@ -38,18 +38,6 @@
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
// Nvidia stereo blitting struct defined in "nvstereo.h" from the Nvidia SDK
|
||||
typedef struct _Nv_Stereo_Image_Header
|
||||
{
|
||||
unsigned int dwSignature;
|
||||
unsigned int dwWidth;
|
||||
unsigned int dwHeight;
|
||||
unsigned int dwBPP;
|
||||
unsigned int dwFlags;
|
||||
} NVSTEREOIMAGEHEADER, *LPNVSTEREOIMAGEHEADER;
|
||||
|
||||
#define NVSTEREO_IMAGE_SIGNATURE 0x4433564e
|
||||
|
||||
Renderer::Renderer(std::unique_ptr<SwapChain> swap_chain, float backbuffer_scale)
|
||||
: ::Renderer(swap_chain ? swap_chain->GetWidth() : 0, swap_chain ? swap_chain->GetHeight() : 0,
|
||||
backbuffer_scale,
|
||||
@ -60,35 +48,6 @@ Renderer::Renderer(std::unique_ptr<SwapChain> swap_chain, float backbuffer_scale
|
||||
|
||||
Renderer::~Renderer() = default;
|
||||
|
||||
void Renderer::Create3DVisionTexture(int width, int height)
|
||||
{
|
||||
// Create a staging texture for 3D vision with signature information in the last row.
|
||||
// Nvidia 3D Vision supports full SBS, so there is no loss in resolution during this process.
|
||||
NVSTEREOIMAGEHEADER header;
|
||||
header.dwSignature = NVSTEREO_IMAGE_SIGNATURE;
|
||||
header.dwWidth = static_cast<u32>(width * 2);
|
||||
header.dwHeight = static_cast<u32>(height + 1);
|
||||
header.dwBPP = 32;
|
||||
header.dwFlags = 0;
|
||||
|
||||
const u32 pitch = static_cast<u32>(4 * width * 2);
|
||||
const auto memory = std::make_unique<u8[]>((height + 1) * pitch);
|
||||
u8* image_header_location = &memory[height * pitch];
|
||||
std::memcpy(image_header_location, &header, sizeof(header));
|
||||
|
||||
D3D11_SUBRESOURCE_DATA sys_data;
|
||||
sys_data.SysMemPitch = pitch;
|
||||
sys_data.pSysMem = memory.get();
|
||||
|
||||
CD3D11_TEXTURE2D_DESC texture_desc(DXGI_FORMAT_R8G8B8A8_UNORM, width * 2, height + 1, 1, 1,
|
||||
D3D11_BIND_RENDER_TARGET, D3D11_USAGE_DEFAULT, 0, 1, 0, 0);
|
||||
ComPtr<ID3D11Texture2D> texture;
|
||||
HRESULT hr = D3D::device->CreateTexture2D(&texture_desc, &sys_data, texture.GetAddressOf());
|
||||
CHECK(SUCCEEDED(hr), "Create 3D Vision Texture");
|
||||
m_3d_vision_texture = DXTexture::CreateAdopted(std::move(texture));
|
||||
m_3d_vision_framebuffer = DXFramebuffer::Create(m_3d_vision_texture.get(), nullptr);
|
||||
}
|
||||
|
||||
bool Renderer::IsHeadless() const
|
||||
{
|
||||
return !m_swap_chain;
|
||||
@ -237,8 +196,6 @@ void Renderer::CheckForSwapChainChanges()
|
||||
|
||||
m_backbuffer_width = m_swap_chain->GetWidth();
|
||||
m_backbuffer_height = m_swap_chain->GetHeight();
|
||||
m_3d_vision_framebuffer.reset();
|
||||
m_3d_vision_texture.reset();
|
||||
}
|
||||
|
||||
void Renderer::SetFramebuffer(AbstractFramebuffer* framebuffer)
|
||||
@ -328,35 +285,6 @@ void Renderer::WaitForGPUIdle()
|
||||
D3D::context->Flush();
|
||||
}
|
||||
|
||||
void Renderer::RenderXFBToScreen(const MathUtil::Rectangle<int>& target_rc,
|
||||
const AbstractTexture* source_texture,
|
||||
const MathUtil::Rectangle<int>& source_rc)
|
||||
{
|
||||
if (g_ActiveConfig.stereo_mode != StereoMode::Nvidia3DVision)
|
||||
return ::Renderer::RenderXFBToScreen(target_rc, source_texture, source_rc);
|
||||
|
||||
if (!m_3d_vision_texture)
|
||||
Create3DVisionTexture(m_backbuffer_width, m_backbuffer_height);
|
||||
|
||||
// Render to staging texture which is double the width of the backbuffer
|
||||
SetAndClearFramebuffer(m_3d_vision_framebuffer.get());
|
||||
|
||||
m_post_processor->BlitFromTexture(target_rc, source_rc, source_texture, 0);
|
||||
m_post_processor->BlitFromTexture(
|
||||
MathUtil::Rectangle<int>(target_rc.left + m_backbuffer_width, target_rc.top,
|
||||
target_rc.right + m_backbuffer_width, target_rc.bottom),
|
||||
source_rc, source_texture, 1);
|
||||
|
||||
// Copy the left eye to the backbuffer, if Nvidia 3D Vision is enabled it should
|
||||
// recognize the signature and automatically include the right eye frame.
|
||||
const CD3D11_BOX box(0, 0, 0, m_swap_chain->GetWidth(), m_swap_chain->GetHeight(), 1);
|
||||
D3D::context->CopySubresourceRegion(m_swap_chain->GetTexture()->GetD3DTexture(), 0, 0, 0, 0,
|
||||
m_3d_vision_texture->GetD3DTexture(), 0, &box);
|
||||
|
||||
// Restore render target to backbuffer
|
||||
SetFramebuffer(m_swap_chain->GetFramebuffer());
|
||||
}
|
||||
|
||||
void Renderer::SetFullscreen(bool enable_fullscreen)
|
||||
{
|
||||
if (m_swap_chain)
|
||||
|
@ -67,19 +67,13 @@ public:
|
||||
void Flush() override;
|
||||
void WaitForGPUIdle() override;
|
||||
|
||||
void RenderXFBToScreen(const MathUtil::Rectangle<int>& target_rc,
|
||||
const AbstractTexture* source_texture,
|
||||
const MathUtil::Rectangle<int>& source_rc) override;
|
||||
void OnConfigChanged(u32 bits) override;
|
||||
|
||||
private:
|
||||
void Create3DVisionTexture(int width, int height);
|
||||
void CheckForSwapChainChanges();
|
||||
|
||||
StateCache m_state_cache;
|
||||
|
||||
std::unique_ptr<SwapChain> m_swap_chain;
|
||||
std::unique_ptr<DXTexture> m_3d_vision_texture;
|
||||
std::unique_ptr<DXFramebuffer> m_3d_vision_framebuffer;
|
||||
};
|
||||
} // namespace DX11
|
||||
|
@ -40,8 +40,7 @@ enum class StereoMode : int
|
||||
TAB,
|
||||
Anaglyph,
|
||||
QuadBuffer,
|
||||
Passive,
|
||||
Nvidia3DVision,
|
||||
Passive
|
||||
};
|
||||
|
||||
enum class ShaderCompilationMode : int
|
||||
|
Loading…
Reference in New Issue
Block a user