mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
TextureCache: Add "Mono EFB Depth Copy" stereoscopy option.
This commit is contained in:
parent
9994ccb342
commit
0f63186371
@ -153,6 +153,7 @@ static wxString stereo_3d_desc = wxTRANSLATE("Select the stereoscopic 3D mode,
|
|||||||
static wxString stereo_separation_desc = wxTRANSLATE("Control the interpupillary distance, this is the distance between the virtual eyes.");
|
static wxString stereo_separation_desc = wxTRANSLATE("Control the interpupillary distance, this is the distance between the virtual eyes.");
|
||||||
static wxString stereo_convergence_desc = wxTRANSLATE("Control the convergence distance, this controls the apparant distance of virtual objects.\nA lower value creates a stronger feeling of depth while a higher value is generally more comfortable.");
|
static wxString stereo_convergence_desc = wxTRANSLATE("Control the convergence distance, this controls the apparant distance of virtual objects.\nA lower value creates a stronger feeling of depth while a higher value is generally more comfortable.");
|
||||||
static wxString stereo_swap_desc = wxTRANSLATE("Swap the left and right eye, mostly useful if you want to view side-by-side cross-eyed.\n\nIf unsure, leave this unchecked.");
|
static wxString stereo_swap_desc = wxTRANSLATE("Swap the left and right eye, mostly useful if you want to view side-by-side cross-eyed.\n\nIf unsure, leave this unchecked.");
|
||||||
|
static wxString stereo_mono_depth_desc = wxTRANSLATE("Use the same depth buffer for both eyes in an EFB copy.\nThis is needed for games which use the depth buffer to calculate shadows.\n\nIf unsure, leave this unchecked.");
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
@ -473,6 +474,8 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
|
|||||||
|
|
||||||
szr_stereo->Add(CreateCheckBox(page_enh, _("Swap eyes"), wxGetTranslation(stereo_swap_desc), vconfig.bStereoSwapEyes));
|
szr_stereo->Add(CreateCheckBox(page_enh, _("Swap eyes"), wxGetTranslation(stereo_swap_desc), vconfig.bStereoSwapEyes));
|
||||||
|
|
||||||
|
szr_stereo->Add(CreateCheckBox(page_enh, _("Mono EFB Depth Copy"), wxGetTranslation(stereo_mono_depth_desc), vconfig.bStereoMonoEFBDepth));
|
||||||
|
|
||||||
wxStaticBoxSizer* const group_stereo = new wxStaticBoxSizer(wxVERTICAL, page_enh, _("Stereoscopy"));
|
wxStaticBoxSizer* const group_stereo = new wxStaticBoxSizer(wxVERTICAL, page_enh, _("Stereoscopy"));
|
||||||
group_stereo->Add(szr_stereo, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
group_stereo->Add(szr_stereo, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
||||||
szr_enh_main->Add(group_stereo, 0, wxEXPAND | wxALL, 5);
|
szr_enh_main->Add(group_stereo, 0, wxEXPAND | wxALL, 5);
|
||||||
|
@ -361,7 +361,7 @@ void TextureCache::CompileShaders()
|
|||||||
"out vec4 ocol0;\n"
|
"out vec4 ocol0;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void main(){\n"
|
"void main(){\n"
|
||||||
" vec4 texcol = texture(samp9, vec3(f_uv0.xy, 0));\n"
|
" vec4 texcol = texture(samp9, vec3(f_uv0.xy, %s));\n"
|
||||||
|
|
||||||
// 255.99998474121 = 16777215/16777216*256
|
// 255.99998474121 = 16777215/16777216*256
|
||||||
" float workspace = texcol.x * 255.99998474121;\n"
|
" float workspace = texcol.x * 255.99998474121;\n"
|
||||||
@ -387,30 +387,21 @@ void TextureCache::CompileShaders()
|
|||||||
" ocol0 = texcol * mat4(colmat[0], colmat[1], colmat[2], colmat[3]) + colmat[4];\n"
|
" ocol0 = texcol * mat4(colmat[0], colmat[1], colmat[2], colmat[3]) + colmat[4];\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
const char *VProgram = (g_ActiveConfig.iStereoMode > 0) ?
|
const char *VProgram =
|
||||||
"out vec2 v_uv0;\n"
|
"out vec3 %s_uv0;\n"
|
||||||
"SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n"
|
"SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n"
|
||||||
"uniform vec4 copy_position;\n" // left, top, right, bottom
|
"uniform vec4 copy_position;\n" // left, top, right, bottom
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n"
|
" vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n"
|
||||||
" v_uv0 = mix(copy_position.xy, copy_position.zw, rawpos) / vec2(textureSize(samp9, 0).xy);\n"
|
" %s_uv0 = vec3(mix(copy_position.xy, copy_position.zw, rawpos) / vec2(textureSize(samp9, 0).xy), 0.0);\n"
|
||||||
" gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n"
|
|
||||||
"}\n" :
|
|
||||||
"out vec3 f_uv0;\n"
|
|
||||||
"SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n"
|
|
||||||
"uniform vec4 copy_position;\n" // left, top, right, bottom
|
|
||||||
"void main()\n"
|
|
||||||
"{\n"
|
|
||||||
" vec2 rawpos = vec2(gl_VertexID&1, gl_VertexID&2);\n"
|
|
||||||
" f_uv0 = vec3(mix(copy_position.xy, copy_position.zw, rawpos) / vec2(textureSize(samp9, 0).xy), 0.0);\n"
|
|
||||||
" gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n"
|
" gl_Position = vec4(rawpos*2.0-1.0, 0.0, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
const char *GProgram = (g_ActiveConfig.iStereoMode > 0) ?
|
const char *GProgram = (g_ActiveConfig.iStereoMode > 0) ?
|
||||||
"layout(triangles) in;\n"
|
"layout(triangles) in;\n"
|
||||||
"layout(triangle_strip, max_vertices = 6) out;\n"
|
"layout(triangle_strip, max_vertices = 6) out;\n"
|
||||||
"in vec2 v_uv0[];\n"
|
"in vec3 v_uv0[];\n"
|
||||||
"out vec3 f_uv0;\n"
|
"out vec3 f_uv0;\n"
|
||||||
"SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n"
|
"SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
@ -418,7 +409,7 @@ void TextureCache::CompileShaders()
|
|||||||
" int layers = textureSize(samp9, 0).z;\n"
|
" int layers = textureSize(samp9, 0).z;\n"
|
||||||
" for (int layer = 0; layer < layers; ++layer) {\n"
|
" for (int layer = 0; layer < layers; ++layer) {\n"
|
||||||
" for (int i = 0; i < gl_in.length(); ++i) {\n"
|
" for (int i = 0; i < gl_in.length(); ++i) {\n"
|
||||||
" f_uv0 = vec3(v_uv0[i], layer);\n"
|
" f_uv0 = vec3(v_uv0[i].xy, layer);\n"
|
||||||
" gl_Position = gl_in[i].gl_Position;\n"
|
" gl_Position = gl_in[i].gl_Position;\n"
|
||||||
" gl_Layer = layer;\n"
|
" gl_Layer = layer;\n"
|
||||||
" EmitVertex();\n"
|
" EmitVertex();\n"
|
||||||
@ -427,8 +418,11 @@ void TextureCache::CompileShaders()
|
|||||||
" }\n"
|
" }\n"
|
||||||
"}\n" : nullptr;
|
"}\n" : nullptr;
|
||||||
|
|
||||||
ProgramShaderCache::CompileShader(s_ColorMatrixProgram, VProgram, pColorMatrixProg, GProgram);
|
const char* prefix = (GProgram == nullptr) ? "f" : "v";
|
||||||
ProgramShaderCache::CompileShader(s_DepthMatrixProgram, VProgram, pDepthMatrixProg, GProgram);
|
const char* depth_layer = (g_ActiveConfig.bStereoMonoEFBDepth) ? "0" : "f_uv0.z";
|
||||||
|
|
||||||
|
ProgramShaderCache::CompileShader(s_ColorMatrixProgram, StringFromFormat(VProgram, prefix, prefix).c_str(), pColorMatrixProg, GProgram);
|
||||||
|
ProgramShaderCache::CompileShader(s_DepthMatrixProgram, StringFromFormat(VProgram, prefix, prefix).c_str(), StringFromFormat(pDepthMatrixProg, depth_layer).c_str(), GProgram);
|
||||||
|
|
||||||
s_ColorMatrixUniform = glGetUniformLocation(s_ColorMatrixProgram.glprogid, "colmat");
|
s_ColorMatrixUniform = glGetUniformLocation(s_ColorMatrixProgram.glprogid, "colmat");
|
||||||
s_DepthMatrixUniform = glGetUniformLocation(s_DepthMatrixProgram.glprogid, "colmat");
|
s_DepthMatrixUniform = glGetUniformLocation(s_DepthMatrixProgram.glprogid, "colmat");
|
||||||
|
@ -116,7 +116,8 @@ void TextureCache::OnConfigChanged(VideoConfig& config)
|
|||||||
g_texture_cache->ClearRenderTargets();
|
g_texture_cache->ClearRenderTargets();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((config.iStereoMode > 0) != backup_config.s_stereo_3d)
|
if ((config.iStereoMode > 0) != backup_config.s_stereo_3d ||
|
||||||
|
config.bStereoMonoEFBDepth != backup_config.s_mono_efb_depth)
|
||||||
{
|
{
|
||||||
g_texture_cache->DeleteShaders();
|
g_texture_cache->DeleteShaders();
|
||||||
g_texture_cache->CompileShaders();
|
g_texture_cache->CompileShaders();
|
||||||
@ -133,6 +134,7 @@ void TextureCache::OnConfigChanged(VideoConfig& config)
|
|||||||
backup_config.s_hires_textures = config.bHiresTextures;
|
backup_config.s_hires_textures = config.bHiresTextures;
|
||||||
backup_config.s_copy_cache_enable = config.bEFBCopyCacheEnable;
|
backup_config.s_copy_cache_enable = config.bEFBCopyCacheEnable;
|
||||||
backup_config.s_stereo_3d = config.iStereoMode > 0;
|
backup_config.s_stereo_3d = config.iStereoMode > 0;
|
||||||
|
backup_config.s_mono_efb_depth = config.bStereoMonoEFBDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::Cleanup()
|
void TextureCache::Cleanup()
|
||||||
|
@ -146,6 +146,7 @@ private:
|
|||||||
bool s_hires_textures;
|
bool s_hires_textures;
|
||||||
bool s_copy_cache_enable;
|
bool s_copy_cache_enable;
|
||||||
bool s_stereo_3d;
|
bool s_stereo_3d;
|
||||||
|
bool s_mono_efb_depth;
|
||||||
} backup_config;
|
} backup_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ void VideoConfig::Load(const std::string& ini_file)
|
|||||||
settings->Get("StereoSeparation", &iStereoSeparation, 50);
|
settings->Get("StereoSeparation", &iStereoSeparation, 50);
|
||||||
settings->Get("StereoFocalLength", &iStereoFocalLength, 30);
|
settings->Get("StereoFocalLength", &iStereoFocalLength, 30);
|
||||||
settings->Get("StereoSwapEyes", &bStereoSwapEyes, false);
|
settings->Get("StereoSwapEyes", &bStereoSwapEyes, false);
|
||||||
|
settings->Get("StereoMonoEFBDepth", &bStereoMonoEFBDepth, false);
|
||||||
settings->Get("EnablePixelLighting", &bEnablePixelLighting, 0);
|
settings->Get("EnablePixelLighting", &bEnablePixelLighting, 0);
|
||||||
settings->Get("FastDepthCalc", &bFastDepthCalc, true);
|
settings->Get("FastDepthCalc", &bFastDepthCalc, true);
|
||||||
settings->Get("MSAA", &iMultisampleMode, 0);
|
settings->Get("MSAA", &iMultisampleMode, 0);
|
||||||
@ -145,6 +146,7 @@ void VideoConfig::GameIniLoad()
|
|||||||
CHECK_SETTING("Video_Settings", "StereoSeparation", iStereoSeparation);
|
CHECK_SETTING("Video_Settings", "StereoSeparation", iStereoSeparation);
|
||||||
CHECK_SETTING("Video_Settings", "StereoFocalLength", iStereoFocalLength);
|
CHECK_SETTING("Video_Settings", "StereoFocalLength", iStereoFocalLength);
|
||||||
CHECK_SETTING("Video_Settings", "StereoSwapEyes", bStereoSwapEyes);
|
CHECK_SETTING("Video_Settings", "StereoSwapEyes", bStereoSwapEyes);
|
||||||
|
CHECK_SETTING("Video_Settings", "StereoMonoEFBDepth", bStereoMonoEFBDepth);
|
||||||
CHECK_SETTING("Video_Settings", "EnablePixelLighting", bEnablePixelLighting);
|
CHECK_SETTING("Video_Settings", "EnablePixelLighting", bEnablePixelLighting);
|
||||||
CHECK_SETTING("Video_Settings", "FastDepthCalc", bFastDepthCalc);
|
CHECK_SETTING("Video_Settings", "FastDepthCalc", bFastDepthCalc);
|
||||||
CHECK_SETTING("Video_Settings", "MSAA", iMultisampleMode);
|
CHECK_SETTING("Video_Settings", "MSAA", iMultisampleMode);
|
||||||
@ -237,6 +239,7 @@ void VideoConfig::Save(const std::string& ini_file)
|
|||||||
settings->Set("StereoSeparation", iStereoSeparation);
|
settings->Set("StereoSeparation", iStereoSeparation);
|
||||||
settings->Set("StereoFocalLength", iStereoFocalLength);
|
settings->Set("StereoFocalLength", iStereoFocalLength);
|
||||||
settings->Set("StereoSwapEyes", bStereoSwapEyes);
|
settings->Set("StereoSwapEyes", bStereoSwapEyes);
|
||||||
|
settings->Set("StereoMonoEFBDepth", bStereoMonoEFBDepth);
|
||||||
settings->Set("EnablePixelLighting", bEnablePixelLighting);
|
settings->Set("EnablePixelLighting", bEnablePixelLighting);
|
||||||
settings->Set("FastDepthCalc", bFastDepthCalc);
|
settings->Set("FastDepthCalc", bFastDepthCalc);
|
||||||
settings->Set("ShowEFBCopyRegions", bShowEFBCopyRegions);
|
settings->Set("ShowEFBCopyRegions", bShowEFBCopyRegions);
|
||||||
|
@ -83,6 +83,7 @@ struct VideoConfig final
|
|||||||
int iStereoSeparation;
|
int iStereoSeparation;
|
||||||
int iStereoFocalLength;
|
int iStereoFocalLength;
|
||||||
bool bStereoSwapEyes;
|
bool bStereoSwapEyes;
|
||||||
|
bool bStereoMonoEFBDepth;
|
||||||
|
|
||||||
// Information
|
// Information
|
||||||
bool bShowFPS;
|
bool bShowFPS;
|
||||||
|
Loading…
Reference in New Issue
Block a user