mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-26 15:49:50 -06:00
Merge pull request #331 from degasus/kill_csaa
OpenGL: Use a sample-able texture as EFB instead of renderbuffer.
This commit is contained in:
@ -18,38 +18,39 @@ namespace OGL
|
|||||||
int FramebufferManager::m_targetWidth;
|
int FramebufferManager::m_targetWidth;
|
||||||
int FramebufferManager::m_targetHeight;
|
int FramebufferManager::m_targetHeight;
|
||||||
int FramebufferManager::m_msaaSamples;
|
int FramebufferManager::m_msaaSamples;
|
||||||
int FramebufferManager::m_msaaCoverageSamples;
|
|
||||||
|
GLenum FramebufferManager::m_textureType;
|
||||||
|
|
||||||
GLuint FramebufferManager::m_efbFramebuffer;
|
GLuint FramebufferManager::m_efbFramebuffer;
|
||||||
GLuint FramebufferManager::m_efbColor; // Renderbuffer in MSAA mode; Texture otherwise
|
GLuint FramebufferManager::m_xfbFramebuffer;
|
||||||
GLuint FramebufferManager::m_efbDepth; // Renderbuffer in MSAA mode; Texture otherwise
|
GLuint FramebufferManager::m_efbColor;
|
||||||
|
GLuint FramebufferManager::m_efbDepth;
|
||||||
|
GLuint FramebufferManager::m_efbColorSwap; // for hot swap when reinterpreting EFB pixel formats
|
||||||
|
|
||||||
// Only used in MSAA mode.
|
// Only used in MSAA mode.
|
||||||
GLuint FramebufferManager::m_resolvedFramebuffer;
|
GLuint FramebufferManager::m_resolvedFramebuffer;
|
||||||
GLuint FramebufferManager::m_resolvedColorTexture;
|
GLuint FramebufferManager::m_resolvedColorTexture;
|
||||||
GLuint FramebufferManager::m_resolvedDepthTexture;
|
GLuint FramebufferManager::m_resolvedDepthTexture;
|
||||||
|
|
||||||
GLuint FramebufferManager::m_xfbFramebuffer;
|
|
||||||
|
|
||||||
// reinterpret pixel format
|
// reinterpret pixel format
|
||||||
SHADER FramebufferManager::m_pixel_format_shaders[2];
|
SHADER FramebufferManager::m_pixel_format_shaders[2];
|
||||||
|
|
||||||
|
|
||||||
FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int msaaSamples, int msaaCoverageSamples)
|
FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int msaaSamples)
|
||||||
{
|
{
|
||||||
m_efbFramebuffer = 0;
|
m_efbFramebuffer = 0;
|
||||||
|
m_xfbFramebuffer = 0;
|
||||||
m_efbColor = 0;
|
m_efbColor = 0;
|
||||||
m_efbDepth = 0;
|
m_efbDepth = 0;
|
||||||
|
m_efbColorSwap = 0;
|
||||||
m_resolvedFramebuffer = 0;
|
m_resolvedFramebuffer = 0;
|
||||||
m_resolvedColorTexture = 0;
|
m_resolvedColorTexture = 0;
|
||||||
m_resolvedDepthTexture = 0;
|
m_resolvedDepthTexture = 0;
|
||||||
m_xfbFramebuffer = 0;
|
|
||||||
|
|
||||||
m_targetWidth = targetWidth;
|
m_targetWidth = targetWidth;
|
||||||
m_targetHeight = targetHeight;
|
m_targetHeight = targetHeight;
|
||||||
|
|
||||||
m_msaaSamples = msaaSamples;
|
m_msaaSamples = msaaSamples;
|
||||||
m_msaaCoverageSamples = msaaCoverageSamples;
|
|
||||||
|
|
||||||
// The EFB can be set to different pixel formats by the game through the
|
// The EFB can be set to different pixel formats by the game through the
|
||||||
// BPMEM_ZCOMPARE register (which should probably have a different name).
|
// BPMEM_ZCOMPARE register (which should probably have a different name).
|
||||||
@ -62,87 +63,56 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
|||||||
// The distinction becomes important for certain operations, i.e. the
|
// The distinction becomes important for certain operations, i.e. the
|
||||||
// alpha channel should be ignored if the EFB does not have one.
|
// alpha channel should be ignored if the EFB does not have one.
|
||||||
|
|
||||||
// Create EFB target.
|
|
||||||
glGenFramebuffers(1, &m_efbFramebuffer);
|
|
||||||
glActiveTexture(GL_TEXTURE0 + 9);
|
glActiveTexture(GL_TEXTURE0 + 9);
|
||||||
|
|
||||||
if (m_msaaSamples <= 1)
|
|
||||||
{
|
|
||||||
// EFB targets will be textures in non-MSAA mode.
|
|
||||||
|
|
||||||
GLuint glObj[3];
|
GLuint glObj[3];
|
||||||
glGenTextures(3, glObj);
|
glGenTextures(3, glObj);
|
||||||
m_efbColor = glObj[0];
|
m_efbColor = glObj[0];
|
||||||
m_efbDepth = glObj[1];
|
m_efbDepth = glObj[1];
|
||||||
m_resolvedColorTexture = glObj[2]; // needed for pixel format convertion
|
m_efbColorSwap = glObj[2];
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_efbColor);
|
// OpenGL MSAA textures are a different kind of texture type and must be allocated
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
// with a different function, so we create them separately.
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
if (m_msaaSamples <= 1)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
{
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_targetWidth, m_targetHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
m_textureType = GL_TEXTURE_2D;
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_efbDepth);
|
glBindTexture(m_textureType, m_efbColor);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
glTexImage2D(m_textureType, 0, GL_RGBA, m_targetWidth, m_targetHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_resolvedColorTexture);
|
glBindTexture(m_textureType, m_efbDepth);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_targetWidth, m_targetHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
glTexImage2D(m_textureType, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
||||||
|
|
||||||
// Bind target textures to the EFB framebuffer.
|
glBindTexture(m_textureType, m_efbColorSwap);
|
||||||
|
glTexParameteri(m_textureType, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer);
|
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(m_textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_efbColor, 0);
|
glTexImage2D(m_textureType, 0, GL_RGBA, m_targetWidth, m_targetHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_efbDepth, 0);
|
|
||||||
|
|
||||||
GL_REPORT_FBO_ERROR();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// EFB targets will be renderbuffers in MSAA mode (required by OpenGL).
|
m_textureType = GL_TEXTURE_2D_MULTISAMPLE;
|
||||||
// Resolve targets will be created to transfer EFB to RAM textures.
|
|
||||||
// XFB framebuffer will be created to transfer EFB to XFB texture.
|
|
||||||
|
|
||||||
// Create EFB target renderbuffers.
|
glBindTexture(m_textureType, m_efbColor);
|
||||||
|
glTexImage2DMultisample(m_textureType, m_msaaSamples, GL_RGBA, m_targetWidth, m_targetHeight, false);
|
||||||
|
|
||||||
GLuint glObj[2];
|
glBindTexture(m_textureType, m_efbDepth);
|
||||||
glGenRenderbuffers(2, glObj);
|
glTexImage2DMultisample(m_textureType, m_msaaSamples, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, false);
|
||||||
m_efbColor = glObj[0];
|
|
||||||
m_efbDepth = glObj[1];
|
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_efbColor);
|
glBindTexture(m_textureType, m_efbColorSwap);
|
||||||
if (m_msaaCoverageSamples)
|
glTexImage2DMultisample(m_textureType, m_msaaSamples, GL_RGBA, m_targetWidth, m_targetHeight, false);
|
||||||
glRenderbufferStorageMultisampleCoverageNV(GL_RENDERBUFFER, m_msaaCoverageSamples, m_msaaSamples, GL_RGBA, m_targetWidth, m_targetHeight);
|
glBindTexture(m_textureType, 0);
|
||||||
else
|
|
||||||
glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_msaaSamples, GL_RGBA, m_targetWidth, m_targetHeight);
|
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_efbDepth);
|
|
||||||
if (m_msaaCoverageSamples)
|
|
||||||
glRenderbufferStorageMultisampleCoverageNV(GL_RENDERBUFFER, m_msaaCoverageSamples, m_msaaSamples, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight);
|
|
||||||
else
|
|
||||||
glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_msaaSamples, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight);
|
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
|
||||||
|
|
||||||
// Bind target renderbuffers to EFB framebuffer.
|
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer);
|
|
||||||
|
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_efbColor);
|
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_efbDepth);
|
|
||||||
|
|
||||||
GL_REPORT_FBO_ERROR();
|
|
||||||
|
|
||||||
// Create resolved targets for transferring multisampled EFB to texture.
|
|
||||||
|
|
||||||
glGenFramebuffers(1, &m_resolvedFramebuffer);
|
|
||||||
|
|
||||||
|
// Although we are able to access the multisampled texture directly, we don't do it everywhere.
|
||||||
|
// The old way is to "resolve" this multisampled texture by copying it into a non-sampled texture.
|
||||||
|
// This would lead to an unneeded copy of the EFB, so we are going to avoid it.
|
||||||
|
// But as this job isn't done right now, we do need that texture for resolving:
|
||||||
glGenTextures(2, glObj);
|
glGenTextures(2, glObj);
|
||||||
m_resolvedColorTexture = glObj[0];
|
m_resolvedColorTexture = glObj[0];
|
||||||
m_resolvedDepthTexture = glObj[1];
|
m_resolvedDepthTexture = glObj[1];
|
||||||
@ -160,22 +130,23 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
|||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, m_targetWidth, m_targetHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
|
||||||
|
|
||||||
// Bind resolved textures to resolved framebuffer.
|
// Bind resolved textures to resolved framebuffer.
|
||||||
|
glGenFramebuffers(1, &m_resolvedFramebuffer);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_resolvedFramebuffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_resolvedFramebuffer);
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_resolvedColorTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_resolvedColorTexture, 0);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_resolvedDepthTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_resolvedDepthTexture, 0);
|
||||||
|
|
||||||
GL_REPORT_FBO_ERROR();
|
GL_REPORT_FBO_ERROR();
|
||||||
|
|
||||||
// Return to EFB framebuffer.
|
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer);
|
|
||||||
}
|
}
|
||||||
// Create XFB framebuffer; targets will be created elsewhere.
|
|
||||||
|
|
||||||
|
// Create XFB framebuffer; targets will be created elsewhere.
|
||||||
glGenFramebuffers(1, &m_xfbFramebuffer);
|
glGenFramebuffers(1, &m_xfbFramebuffer);
|
||||||
|
|
||||||
|
// Bind target textures to EFB framebuffer.
|
||||||
|
glGenFramebuffers(1, &m_efbFramebuffer);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer);
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_textureType, m_efbColor, 0);
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_textureType, m_efbDepth, 0);
|
||||||
|
GL_REPORT_FBO_ERROR();
|
||||||
|
|
||||||
// EFB framebuffer is currently bound, make sure to clear its alpha value to 1.f
|
// EFB framebuffer is currently bound, make sure to clear its alpha value to 1.f
|
||||||
glViewport(0, 0, m_targetWidth, m_targetHeight);
|
glViewport(0, 0, m_targetWidth, m_targetHeight);
|
||||||
glScissor(0, 0, m_targetWidth, m_targetHeight);
|
glScissor(0, 0, m_targetWidth, m_targetHeight);
|
||||||
@ -190,12 +161,50 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
|||||||
" 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";
|
||||||
|
|
||||||
char ps_rgba6_to_rgb8[] =
|
// The way to sample the EFB is based on the on the current configuration.
|
||||||
|
// As we use the same sampling way for both interpreting shaders, the sampling
|
||||||
|
// shader are generated first:
|
||||||
|
std::string sampler;
|
||||||
|
if (m_msaaSamples <= 1)
|
||||||
|
{
|
||||||
|
// non-msaa, so just fetch the pixel
|
||||||
|
sampler =
|
||||||
"uniform sampler2D samp9;\n"
|
"uniform sampler2D samp9;\n"
|
||||||
|
"vec4 sampleEFB(ivec2 pos) {\n"
|
||||||
|
" return texelFetch(samp9, pos, 0);\n"
|
||||||
|
"}\n";
|
||||||
|
}
|
||||||
|
else if (g_ogl_config.bSupportSampleShading)
|
||||||
|
{
|
||||||
|
// msaa + sample shading available, so just fetch the sample
|
||||||
|
// This will lead to sample shading, but it's the only way to not loose
|
||||||
|
// the values of each sample.
|
||||||
|
sampler =
|
||||||
|
"uniform sampler2DMS samp9;\n"
|
||||||
|
"vec4 sampleEFB(ivec2 pos) {\n"
|
||||||
|
" return texelFetch(samp9, pos, gl_SampleID);\n"
|
||||||
|
"}\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// msaa without sample shading: calculate the mean value of the pixel
|
||||||
|
std::stringstream samples;
|
||||||
|
samples << m_msaaSamples;
|
||||||
|
sampler =
|
||||||
|
"uniform sampler2DMS samp9;\n"
|
||||||
|
"vec4 sampleEFB(ivec2 pos) {\n"
|
||||||
|
" vec4 color = vec4(0.0, 0.0, 0.0, 0.0);\n"
|
||||||
|
" for(int i=0; i<" + samples.str() + "; i++)\n"
|
||||||
|
" color += texelFetch(samp9, pos, i);\n"
|
||||||
|
" return color / " + samples.str() + ";\n"
|
||||||
|
"}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ps_rgba6_to_rgb8 = sampler +
|
||||||
"out vec4 ocol0;\n"
|
"out vec4 ocol0;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" ivec4 src6 = ivec4(round(texelFetch(samp9, ivec2(gl_FragCoord.xy), 0) * 63.f));\n"
|
" ivec4 src6 = ivec4(round(sampleEFB(ivec2(gl_FragCoord.xy)) * 63.f));\n"
|
||||||
" ivec4 dst8;\n"
|
" ivec4 dst8;\n"
|
||||||
" dst8.r = (src6.r << 2) | (src6.g >> 4);\n"
|
" dst8.r = (src6.r << 2) | (src6.g >> 4);\n"
|
||||||
" dst8.g = ((src6.g & 0xF) << 4) | (src6.b >> 2);\n"
|
" dst8.g = ((src6.g & 0xF) << 4) | (src6.b >> 2);\n"
|
||||||
@ -204,12 +213,11 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
|||||||
" ocol0 = float4(dst8) / 255.f;\n"
|
" ocol0 = float4(dst8) / 255.f;\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
char ps_rgb8_to_rgba6[] =
|
std::string ps_rgb8_to_rgba6 = sampler +
|
||||||
"uniform sampler2D samp9;\n"
|
|
||||||
"out vec4 ocol0;\n"
|
"out vec4 ocol0;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" ivec4 src8 = ivec4(round(texelFetch(samp9, ivec2(gl_FragCoord.xy), 0) * 255.f));\n"
|
" ivec4 src8 = ivec4(round(sampleEFB(ivec2(gl_FragCoord.xy)) * 255.f));\n"
|
||||||
" ivec4 dst6;\n"
|
" ivec4 dst6;\n"
|
||||||
" dst6.r = src8.r >> 2;\n"
|
" dst6.r = src8.r >> 2;\n"
|
||||||
" dst6.g = ((src8.r & 0x3) << 4) | (src8.g >> 4);\n"
|
" dst6.g = ((src8.r & 0x3) << 4) | (src8.g >> 4);\n"
|
||||||
@ -218,8 +226,8 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
|||||||
" ocol0 = float4(dst6) / 63.f;\n"
|
" ocol0 = float4(dst6) / 63.f;\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
ProgramShaderCache::CompileShader(m_pixel_format_shaders[0], vs, ps_rgb8_to_rgba6);
|
ProgramShaderCache::CompileShader(m_pixel_format_shaders[0], vs, ps_rgb8_to_rgba6.c_str());
|
||||||
ProgramShaderCache::CompileShader(m_pixel_format_shaders[1], vs, ps_rgba6_to_rgb8);
|
ProgramShaderCache::CompileShader(m_pixel_format_shaders[1], vs, ps_rgba6_to_rgb8.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
FramebufferManager::~FramebufferManager()
|
FramebufferManager::~FramebufferManager()
|
||||||
@ -231,11 +239,12 @@ FramebufferManager::~FramebufferManager()
|
|||||||
// Note: OpenGL deletion functions silently ignore parameters of "0".
|
// Note: OpenGL deletion functions silently ignore parameters of "0".
|
||||||
|
|
||||||
glObj[0] = m_efbFramebuffer;
|
glObj[0] = m_efbFramebuffer;
|
||||||
glObj[1] = m_resolvedFramebuffer;
|
glObj[1] = m_xfbFramebuffer;
|
||||||
glObj[2] = m_xfbFramebuffer;
|
glObj[2] = m_resolvedFramebuffer;
|
||||||
glDeleteFramebuffers(3, glObj);
|
glDeleteFramebuffers(3, glObj);
|
||||||
m_efbFramebuffer = 0;
|
m_efbFramebuffer = 0;
|
||||||
m_xfbFramebuffer = 0;
|
m_xfbFramebuffer = 0;
|
||||||
|
m_resolvedFramebuffer = 0;
|
||||||
|
|
||||||
glObj[0] = m_resolvedColorTexture;
|
glObj[0] = m_resolvedColorTexture;
|
||||||
glObj[1] = m_resolvedDepthTexture;
|
glObj[1] = m_resolvedDepthTexture;
|
||||||
@ -245,12 +254,11 @@ FramebufferManager::~FramebufferManager()
|
|||||||
|
|
||||||
glObj[0] = m_efbColor;
|
glObj[0] = m_efbColor;
|
||||||
glObj[1] = m_efbDepth;
|
glObj[1] = m_efbDepth;
|
||||||
if (m_msaaSamples <= 1)
|
glObj[2] = m_efbColorSwap;
|
||||||
glDeleteTextures(2, glObj);
|
glDeleteTextures(3, glObj);
|
||||||
else
|
|
||||||
glDeleteRenderbuffers(2, glObj);
|
|
||||||
m_efbColor = 0;
|
m_efbColor = 0;
|
||||||
m_efbDepth = 0;
|
m_efbDepth = 0;
|
||||||
|
m_efbColorSwap = 0;
|
||||||
|
|
||||||
// reinterpret pixel format
|
// reinterpret pixel format
|
||||||
m_pixel_format_shaders[0].Destroy();
|
m_pixel_format_shaders[0].Destroy();
|
||||||
@ -295,8 +303,7 @@ GLuint FramebufferManager::GetEFBDepthTexture(const EFBRectangle& sourceRc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Transfer the EFB to a resolved texture. EXT_framebuffer_blit is
|
// Transfer the EFB to a resolved texture.
|
||||||
// required.
|
|
||||||
|
|
||||||
TargetRectangle targetRc = g_renderer->ConvertEFBRectangle(sourceRc);
|
TargetRectangle targetRc = g_renderer->ConvertEFBRectangle(sourceRc);
|
||||||
targetRc.ClampLL(0, 0, m_targetWidth, m_targetHeight);
|
targetRc.ClampLL(0, 0, m_targetWidth, m_targetHeight);
|
||||||
@ -352,38 +359,22 @@ void FramebufferManager::ReinterpretPixelData(unsigned int convtype)
|
|||||||
|
|
||||||
GLuint src_texture = 0;
|
GLuint src_texture = 0;
|
||||||
|
|
||||||
if (m_msaaSamples > 1)
|
// We aren't allowed to render and sample the same texture in one draw call,
|
||||||
{
|
// so we have to create a new texture and overwrite it completely.
|
||||||
// MSAA mode, so resolve first
|
// To not allocate one big texture every time, we've allocated two on
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_efbFramebuffer);
|
// initialization and just swap them here:
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_resolvedFramebuffer);
|
|
||||||
glBlitFramebuffer(
|
|
||||||
0, 0, m_targetWidth, m_targetHeight,
|
|
||||||
0, 0, m_targetWidth, m_targetHeight,
|
|
||||||
GL_COLOR_BUFFER_BIT, GL_NEAREST
|
|
||||||
);
|
|
||||||
|
|
||||||
// Return to EFB.
|
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_efbFramebuffer);
|
|
||||||
|
|
||||||
src_texture = m_resolvedColorTexture;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// non-MSAA mode, so switch textures
|
|
||||||
src_texture = m_efbColor;
|
src_texture = m_efbColor;
|
||||||
m_efbColor = m_resolvedColorTexture;
|
m_efbColor = m_efbColorSwap;
|
||||||
m_resolvedColorTexture = src_texture;
|
m_efbColorSwap = src_texture;
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_textureType, m_efbColor, 0);
|
||||||
|
|
||||||
// also switch them on fbo
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_efbColor, 0);
|
|
||||||
}
|
|
||||||
glViewport(0,0, m_targetWidth, m_targetHeight);
|
glViewport(0,0, m_targetWidth, m_targetHeight);
|
||||||
glActiveTexture(GL_TEXTURE0 + 9);
|
glActiveTexture(GL_TEXTURE0 + 9);
|
||||||
glBindTexture(GL_TEXTURE_2D, src_texture);
|
glBindTexture(m_textureType, src_texture);
|
||||||
|
|
||||||
m_pixel_format_shaders[convtype ? 1 : 0].Bind();
|
m_pixel_format_shaders[convtype ? 1 : 0].Bind();
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
glBindTexture(m_textureType, 0);
|
||||||
|
|
||||||
g_renderer->RestoreAPIState();
|
g_renderer->RestoreAPIState();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ struct XFBSource : public XFBSourceBase
|
|||||||
class FramebufferManager : public FramebufferManagerBase
|
class FramebufferManager : public FramebufferManagerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FramebufferManager(int targetWidth, int targetHeight, int msaaSamples, int msaaCoverageSamples);
|
FramebufferManager(int targetWidth, int targetHeight, int msaaSamples);
|
||||||
~FramebufferManager();
|
~FramebufferManager();
|
||||||
|
|
||||||
// To get the EFB in texture form, these functions may have to transfer
|
// To get the EFB in texture form, these functions may have to transfer
|
||||||
@ -99,19 +99,20 @@ private:
|
|||||||
static int m_targetWidth;
|
static int m_targetWidth;
|
||||||
static int m_targetHeight;
|
static int m_targetHeight;
|
||||||
static int m_msaaSamples;
|
static int m_msaaSamples;
|
||||||
static int m_msaaCoverageSamples;
|
|
||||||
|
static GLenum m_textureType;
|
||||||
|
|
||||||
static GLuint m_efbFramebuffer;
|
static GLuint m_efbFramebuffer;
|
||||||
static GLuint m_efbColor; // Renderbuffer in MSAA mode; Texture otherwise
|
static GLuint m_xfbFramebuffer;
|
||||||
static GLuint m_efbDepth; // Renderbuffer in MSAA mode; Texture otherwise
|
static GLuint m_efbColor;
|
||||||
|
static GLuint m_efbDepth;
|
||||||
|
static GLuint m_efbColorSwap;// will be hot swapped with m_efbColor when reinterpreting EFB pixel formats
|
||||||
|
|
||||||
// Only used in MSAA mode and to convert pixel format
|
// Only used in MSAA mode, TODO: try to avoid them
|
||||||
static GLuint m_resolvedFramebuffer; // will be hot swapped with m_efbColor on non-msaa pixel format change
|
static GLuint m_resolvedFramebuffer;
|
||||||
static GLuint m_resolvedColorTexture;
|
static GLuint m_resolvedColorTexture;
|
||||||
static GLuint m_resolvedDepthTexture;
|
static GLuint m_resolvedDepthTexture;
|
||||||
|
|
||||||
static GLuint m_xfbFramebuffer; // Only used in MSAA mode
|
|
||||||
|
|
||||||
// For pixel format draw
|
// For pixel format draw
|
||||||
static SHADER m_pixel_format_shaders[2];
|
static SHADER m_pixel_format_shaders[2];
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright 2013 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "VideoBackends/OGL/GLExtensions/gl_common.h"
|
||||||
|
|
||||||
|
extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
|
||||||
|
extern PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample;
|
||||||
|
extern PFNGLGETMULTISAMPLEFVPROC glGetMultisamplefv;
|
||||||
|
extern PFNGLSAMPLEMASKIPROC glSampleMaski;
|
@ -711,6 +711,12 @@ PFNGLGETSYNCIVPROC glGetSynciv;
|
|||||||
PFNGLISSYNCPROC glIsSync;
|
PFNGLISSYNCPROC glIsSync;
|
||||||
PFNGLWAITSYNCPROC glWaitSync;
|
PFNGLWAITSYNCPROC glWaitSync;
|
||||||
|
|
||||||
|
// ARB_texture_multisample
|
||||||
|
PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
|
||||||
|
PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample;
|
||||||
|
PFNGLGETMULTISAMPLEFVPROC glGetMultisamplefv;
|
||||||
|
PFNGLSAMPLEMASKIPROC glSampleMaski;
|
||||||
|
|
||||||
// ARB_ES2_compatibility
|
// ARB_ES2_compatibility
|
||||||
PFNGLCLEARDEPTHFPROC glClearDepthf;
|
PFNGLCLEARDEPTHFPROC glClearDepthf;
|
||||||
PFNGLDEPTHRANGEFPROC glDepthRangef;
|
PFNGLDEPTHRANGEFPROC glDepthRangef;
|
||||||
@ -744,9 +750,6 @@ PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glDrawElementsInstancedBaseVertex;
|
|||||||
PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glDrawRangeElementsBaseVertex;
|
PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glDrawRangeElementsBaseVertex;
|
||||||
PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glMultiDrawElementsBaseVertex;
|
PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glMultiDrawElementsBaseVertex;
|
||||||
|
|
||||||
// NV_framebuffer_multisample_coverage
|
|
||||||
PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC glRenderbufferStorageMultisampleCoverageNV;
|
|
||||||
|
|
||||||
// ARB_sample_shading
|
// ARB_sample_shading
|
||||||
PFNGLMINSAMPLESHADINGARBPROC glMinSampleShadingARB;
|
PFNGLMINSAMPLESHADINGARBPROC glMinSampleShadingARB;
|
||||||
|
|
||||||
@ -1493,6 +1496,12 @@ const GLFunc gl_function_array[] =
|
|||||||
GLFUNC_REQUIRES(glIsSync, "GL_ARB_sync"),
|
GLFUNC_REQUIRES(glIsSync, "GL_ARB_sync"),
|
||||||
GLFUNC_REQUIRES(glWaitSync, "GL_ARB_sync"),
|
GLFUNC_REQUIRES(glWaitSync, "GL_ARB_sync"),
|
||||||
|
|
||||||
|
// ARB_texture_multisample
|
||||||
|
GLFUNC_REQUIRES(glTexImage2DMultisample, "GL_ARB_texture_multisample"),
|
||||||
|
GLFUNC_REQUIRES(glTexImage3DMultisample, "GL_ARB_texture_multisample"),
|
||||||
|
GLFUNC_REQUIRES(glGetMultisamplefv, "GL_ARB_texture_multisample"),
|
||||||
|
GLFUNC_REQUIRES(glSampleMaski, "GL_ARB_texture_multisample"),
|
||||||
|
|
||||||
// ARB_ES2_compatibility
|
// ARB_ES2_compatibility
|
||||||
GLFUNC_REQUIRES(glClearDepthf, "GL_ARB_ES2_compatibility"),
|
GLFUNC_REQUIRES(glClearDepthf, "GL_ARB_ES2_compatibility"),
|
||||||
GLFUNC_REQUIRES(glDepthRangef, "GL_ARB_ES2_compatibility"),
|
GLFUNC_REQUIRES(glDepthRangef, "GL_ARB_ES2_compatibility"),
|
||||||
@ -1526,9 +1535,6 @@ const GLFunc gl_function_array[] =
|
|||||||
GLFUNC_REQUIRES(glDrawRangeElementsBaseVertex, "GL_ARB_draw_elements_base_vertex"),
|
GLFUNC_REQUIRES(glDrawRangeElementsBaseVertex, "GL_ARB_draw_elements_base_vertex"),
|
||||||
GLFUNC_REQUIRES(glMultiDrawElementsBaseVertex, "GL_ARB_draw_elements_base_vertex"),
|
GLFUNC_REQUIRES(glMultiDrawElementsBaseVertex, "GL_ARB_draw_elements_base_vertex"),
|
||||||
|
|
||||||
// NV_framebuffer_multisample_coverage
|
|
||||||
GLFUNC_REQUIRES(glRenderbufferStorageMultisampleCoverageNV, "GL_NV_framebuffer_multisample_coverage"),
|
|
||||||
|
|
||||||
// ARB_sample_shading
|
// ARB_sample_shading
|
||||||
GLFUNC_REQUIRES(glMinSampleShadingARB, "GL_ARB_sample_shading"),
|
GLFUNC_REQUIRES(glMinSampleShadingARB, "GL_ARB_sample_shading"),
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "VideoBackends/OGL/GLExtensions/ARB_sample_shading.h"
|
#include "VideoBackends/OGL/GLExtensions/ARB_sample_shading.h"
|
||||||
#include "VideoBackends/OGL/GLExtensions/ARB_sampler_objects.h"
|
#include "VideoBackends/OGL/GLExtensions/ARB_sampler_objects.h"
|
||||||
#include "VideoBackends/OGL/GLExtensions/ARB_sync.h"
|
#include "VideoBackends/OGL/GLExtensions/ARB_sync.h"
|
||||||
|
#include "VideoBackends/OGL/GLExtensions/ARB_texture_multisample.h"
|
||||||
#include "VideoBackends/OGL/GLExtensions/ARB_uniform_buffer_object.h"
|
#include "VideoBackends/OGL/GLExtensions/ARB_uniform_buffer_object.h"
|
||||||
#include "VideoBackends/OGL/GLExtensions/ARB_vertex_array_object.h"
|
#include "VideoBackends/OGL/GLExtensions/ARB_vertex_array_object.h"
|
||||||
#include "VideoBackends/OGL/GLExtensions/ARB_viewport_array.h"
|
#include "VideoBackends/OGL/GLExtensions/ARB_viewport_array.h"
|
||||||
@ -30,7 +31,6 @@
|
|||||||
#include "VideoBackends/OGL/GLExtensions/gl_3_1.h"
|
#include "VideoBackends/OGL/GLExtensions/gl_3_1.h"
|
||||||
#include "VideoBackends/OGL/GLExtensions/gl_3_2.h"
|
#include "VideoBackends/OGL/GLExtensions/gl_3_2.h"
|
||||||
#include "VideoBackends/OGL/GLExtensions/KHR_debug.h"
|
#include "VideoBackends/OGL/GLExtensions/KHR_debug.h"
|
||||||
#include "VideoBackends/OGL/GLExtensions/NV_framebuffer_multisample_coverage.h"
|
|
||||||
#include "VideoBackends/OGL/GLExtensions/NV_primitive_restart.h"
|
#include "VideoBackends/OGL/GLExtensions/NV_primitive_restart.h"
|
||||||
|
|
||||||
namespace GLExtensions
|
namespace GLExtensions
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright 2013 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include "VideoBackends/OGL/GLExtensions/gl_common.h"
|
|
||||||
|
|
||||||
#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB
|
|
||||||
#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10
|
|
||||||
#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11
|
|
||||||
#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12
|
|
||||||
|
|
||||||
typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
|
|
||||||
|
|
||||||
extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC glRenderbufferStorageMultisampleCoverageNV;
|
|
||||||
|
|
@ -90,7 +90,6 @@
|
|||||||
<ClInclude Include="GLExtensions\gl_3_2.h" />
|
<ClInclude Include="GLExtensions\gl_3_2.h" />
|
||||||
<ClInclude Include="GLExtensions\gl_common.h" />
|
<ClInclude Include="GLExtensions\gl_common.h" />
|
||||||
<ClInclude Include="GLExtensions\KHR_debug.h" />
|
<ClInclude Include="GLExtensions\KHR_debug.h" />
|
||||||
<ClInclude Include="GLExtensions\NV_framebuffer_multisample_coverage.h" />
|
|
||||||
<ClInclude Include="GLExtensions\NV_primitive_restart.h" />
|
<ClInclude Include="GLExtensions\NV_primitive_restart.h" />
|
||||||
<ClInclude Include="GLUtil.h" />
|
<ClInclude Include="GLUtil.h" />
|
||||||
<ClInclude Include="main.h" />
|
<ClInclude Include="main.h" />
|
||||||
|
@ -174,9 +174,6 @@
|
|||||||
<ClInclude Include="GLExtensions\GLExtensions.h">
|
<ClInclude Include="GLExtensions\GLExtensions.h">
|
||||||
<Filter>GLExtensions</Filter>
|
<Filter>GLExtensions</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="GLExtensions\NV_framebuffer_multisample_coverage.h">
|
|
||||||
<Filter>GLExtensions</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="GLExtensions\NV_primitive_restart.h">
|
<ClInclude Include="GLExtensions\NV_primitive_restart.h">
|
||||||
<Filter>GLExtensions</Filter>
|
<Filter>GLExtensions</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -476,6 +476,8 @@ void ProgramShaderCache::CreateHeader ( void )
|
|||||||
"%s\n" // ubo
|
"%s\n" // ubo
|
||||||
"%s\n" // early-z
|
"%s\n" // early-z
|
||||||
"%s\n" // 420pack
|
"%s\n" // 420pack
|
||||||
|
"%s\n" // msaa
|
||||||
|
"%s\n" // sample shading
|
||||||
|
|
||||||
// Precision defines for GLSL ES
|
// Precision defines for GLSL ES
|
||||||
"%s\n"
|
"%s\n"
|
||||||
@ -504,6 +506,8 @@ void ProgramShaderCache::CreateHeader ( void )
|
|||||||
, v<GLSL_140 ? "#extension GL_ARB_uniform_buffer_object : enable" : ""
|
, v<GLSL_140 ? "#extension GL_ARB_uniform_buffer_object : enable" : ""
|
||||||
, g_ActiveConfig.backend_info.bSupportsEarlyZ ? "#extension GL_ARB_shader_image_load_store : enable" : ""
|
, g_ActiveConfig.backend_info.bSupportsEarlyZ ? "#extension GL_ARB_shader_image_load_store : enable" : ""
|
||||||
, (g_ActiveConfig.backend_info.bSupportsBindingLayout && v < GLSLES_310) ? "#extension GL_ARB_shading_language_420pack : enable" : ""
|
, (g_ActiveConfig.backend_info.bSupportsBindingLayout && v < GLSLES_310) ? "#extension GL_ARB_shading_language_420pack : enable" : ""
|
||||||
|
, (g_ogl_config.bSupportsMSAA && v < GLSL_150) ? "#extension GL_ARB_texture_multisample : enable" : ""
|
||||||
|
, (g_ogl_config.bSupportSampleShading) ? "#extension GL_ARB_sample_shading : enable" : ""
|
||||||
|
|
||||||
, v>=GLSLES_300 ? "precision highp float;" : ""
|
, v>=GLSLES_300 ? "precision highp float;" : ""
|
||||||
, v>=GLSLES_300 ? "precision highp int;" : ""
|
, v>=GLSLES_300 ? "precision highp int;" : ""
|
||||||
|
@ -78,10 +78,6 @@ enum MultisampleMode {
|
|||||||
MULTISAMPLE_2X,
|
MULTISAMPLE_2X,
|
||||||
MULTISAMPLE_4X,
|
MULTISAMPLE_4X,
|
||||||
MULTISAMPLE_8X,
|
MULTISAMPLE_8X,
|
||||||
MULTISAMPLE_CSAA_8X,
|
|
||||||
MULTISAMPLE_CSAA_8XQ,
|
|
||||||
MULTISAMPLE_CSAA_16X,
|
|
||||||
MULTISAMPLE_CSAA_16XQ,
|
|
||||||
MULTISAMPLE_SSAA_4X,
|
MULTISAMPLE_SSAA_4X,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -99,7 +95,6 @@ static RasterFont* s_pfont = nullptr;
|
|||||||
|
|
||||||
// 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA.
|
// 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA.
|
||||||
static int s_MSAASamples = 1;
|
static int s_MSAASamples = 1;
|
||||||
static int s_MSAACoverageSamples = 0;
|
|
||||||
static int s_LastMultisampleMode = 0;
|
static int s_LastMultisampleMode = 0;
|
||||||
|
|
||||||
static u32 s_blendMode;
|
static u32 s_blendMode;
|
||||||
@ -131,15 +126,11 @@ int GetNumMSAASamples(int MSAAMode)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MULTISAMPLE_4X:
|
case MULTISAMPLE_4X:
|
||||||
case MULTISAMPLE_CSAA_8X:
|
|
||||||
case MULTISAMPLE_CSAA_16X:
|
|
||||||
case MULTISAMPLE_SSAA_4X:
|
case MULTISAMPLE_SSAA_4X:
|
||||||
samples = 4;
|
samples = 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MULTISAMPLE_8X:
|
case MULTISAMPLE_8X:
|
||||||
case MULTISAMPLE_CSAA_8XQ:
|
|
||||||
case MULTISAMPLE_CSAA_16XQ:
|
|
||||||
samples = 8;
|
samples = 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -154,31 +145,6 @@ int GetNumMSAASamples(int MSAAMode)
|
|||||||
return g_ogl_config.max_samples;
|
return g_ogl_config.max_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetNumMSAACoverageSamples(int MSAAMode)
|
|
||||||
{
|
|
||||||
int samples;
|
|
||||||
switch (g_ActiveConfig.iMultisampleMode)
|
|
||||||
{
|
|
||||||
case MULTISAMPLE_CSAA_8X:
|
|
||||||
case MULTISAMPLE_CSAA_8XQ:
|
|
||||||
samples = 8;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MULTISAMPLE_CSAA_16X:
|
|
||||||
case MULTISAMPLE_CSAA_16XQ:
|
|
||||||
samples = 16;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
samples = 0;
|
|
||||||
}
|
|
||||||
if (g_ogl_config.bSupportCoverageMSAA || samples == 0) return samples;
|
|
||||||
|
|
||||||
// TODO: move this to InitBackendInfo
|
|
||||||
OSD::AddMessage("CSAA Anti Aliasing isn't supported by your GPU.", 10000);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ApplySSAASettings() {
|
void ApplySSAASettings() {
|
||||||
// GLES3 doesn't support SSAA
|
// GLES3 doesn't support SSAA
|
||||||
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
|
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
|
||||||
@ -489,7 +455,7 @@ Renderer::Renderer()
|
|||||||
g_ogl_config.bSupportsGLSync = GLExtensions::Supports("GL_ARB_sync");
|
g_ogl_config.bSupportsGLSync = GLExtensions::Supports("GL_ARB_sync");
|
||||||
g_ogl_config.bSupportsGLBaseVertex = GLExtensions::Supports("GL_ARB_draw_elements_base_vertex");
|
g_ogl_config.bSupportsGLBaseVertex = GLExtensions::Supports("GL_ARB_draw_elements_base_vertex");
|
||||||
g_ogl_config.bSupportsGLBufferStorage = GLExtensions::Supports("GL_ARB_buffer_storage");
|
g_ogl_config.bSupportsGLBufferStorage = GLExtensions::Supports("GL_ARB_buffer_storage");
|
||||||
g_ogl_config.bSupportCoverageMSAA = GLExtensions::Supports("GL_NV_framebuffer_multisample_coverage");
|
g_ogl_config.bSupportsMSAA = GLExtensions::Supports("GL_ARB_texture_multisample");
|
||||||
g_ogl_config.bSupportSampleShading = GLExtensions::Supports("GL_ARB_sample_shading");
|
g_ogl_config.bSupportSampleShading = GLExtensions::Supports("GL_ARB_sample_shading");
|
||||||
g_ogl_config.bSupportOGL31 = GLExtensions::Version() >= 310;
|
g_ogl_config.bSupportOGL31 = GLExtensions::Version() >= 310;
|
||||||
g_ogl_config.bSupportViewportFloat = GLExtensions::Supports("GL_ARB_viewport_array");
|
g_ogl_config.bSupportViewportFloat = GLExtensions::Supports("GL_ARB_viewport_array");
|
||||||
@ -565,7 +531,7 @@ Renderer::Renderer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_SAMPLES, &g_ogl_config.max_samples);
|
glGetIntegerv(GL_MAX_SAMPLES, &g_ogl_config.max_samples);
|
||||||
if (g_ogl_config.max_samples < 1)
|
if (g_ogl_config.max_samples < 1 || !g_ogl_config.bSupportsMSAA)
|
||||||
g_ogl_config.max_samples = 1;
|
g_ogl_config.max_samples = 1;
|
||||||
|
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
@ -584,13 +550,12 @@ Renderer::Renderer()
|
|||||||
g_ogl_config.bSupportsGLBaseVertex ? "" : "BaseVertex ",
|
g_ogl_config.bSupportsGLBaseVertex ? "" : "BaseVertex ",
|
||||||
g_ogl_config.bSupportsGLBufferStorage ? "" : "BufferStorage ",
|
g_ogl_config.bSupportsGLBufferStorage ? "" : "BufferStorage ",
|
||||||
g_ogl_config.bSupportsGLSync ? "" : "Sync ",
|
g_ogl_config.bSupportsGLSync ? "" : "Sync ",
|
||||||
g_ogl_config.bSupportCoverageMSAA ? "" : "CSAA ",
|
g_ogl_config.bSupportsMSAA ? "" : "MSAA ",
|
||||||
g_ogl_config.bSupportSampleShading ? "" : "SSAA "
|
g_ogl_config.bSupportSampleShading ? "" : "SSAA "
|
||||||
);
|
);
|
||||||
|
|
||||||
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
||||||
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
||||||
s_MSAACoverageSamples = GetNumMSAACoverageSamples(s_LastMultisampleMode);
|
|
||||||
ApplySSAASettings();
|
ApplySSAASettings();
|
||||||
|
|
||||||
// Decide framebuffer size
|
// Decide framebuffer size
|
||||||
@ -681,7 +646,7 @@ void Renderer::Init()
|
|||||||
{
|
{
|
||||||
// Initialize the FramebufferManager
|
// Initialize the FramebufferManager
|
||||||
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
|
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
|
||||||
s_MSAASamples, s_MSAACoverageSamples);
|
s_MSAASamples);
|
||||||
|
|
||||||
s_pfont = new RasterFont();
|
s_pfont = new RasterFont();
|
||||||
|
|
||||||
@ -1609,12 +1574,11 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl
|
|||||||
{
|
{
|
||||||
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
||||||
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
||||||
s_MSAACoverageSamples = GetNumMSAACoverageSamples(s_LastMultisampleMode);
|
|
||||||
ApplySSAASettings();
|
ApplySSAASettings();
|
||||||
|
|
||||||
delete g_framebuffer_manager;
|
delete g_framebuffer_manager;
|
||||||
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
|
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
|
||||||
s_MSAASamples, s_MSAACoverageSamples);
|
s_MSAASamples);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ extern struct VideoConfig {
|
|||||||
bool bSupportsGLSync;
|
bool bSupportsGLSync;
|
||||||
bool bSupportsGLBaseVertex;
|
bool bSupportsGLBaseVertex;
|
||||||
bool bSupportsGLBufferStorage;
|
bool bSupportsGLBufferStorage;
|
||||||
bool bSupportCoverageMSAA;
|
bool bSupportsMSAA;
|
||||||
bool bSupportSampleShading;
|
bool bSupportSampleShading;
|
||||||
GLSL_VERSION eSupportedGLSLVersion;
|
GLSL_VERSION eSupportedGLSLVersion;
|
||||||
bool bSupportOGL31;
|
bool bSupportOGL31;
|
||||||
|
@ -152,7 +152,7 @@ void InitBackendInfo()
|
|||||||
g_Config.backend_info.Adapters.clear();
|
g_Config.backend_info.Adapters.clear();
|
||||||
|
|
||||||
// aamodes
|
// aamodes
|
||||||
const char* caamodes[] = {_trans("None"), "2x", "4x", "8x", "8x CSAA", "8xQ CSAA", "16x CSAA", "16xQ CSAA", "4x SSAA"};
|
const char* caamodes[] = {_trans("None"), "2x", "4x", "8x", "4x SSAA"};
|
||||||
g_Config.backend_info.AAModes.assign(caamodes, caamodes + sizeof(caamodes)/sizeof(*caamodes));
|
g_Config.backend_info.AAModes.assign(caamodes, caamodes + sizeof(caamodes)/sizeof(*caamodes));
|
||||||
|
|
||||||
// pp shaders
|
// pp shaders
|
||||||
|
Reference in New Issue
Block a user