Skip to content

Commit

Permalink
libgui|OpenGL: Detect NVIDIA CSAA support, use it if available
Browse files Browse the repository at this point in the history
IssueID #1707
  • Loading branch information
skyjake committed Jan 6, 2014
1 parent 857ccef commit cb72a74
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
7 changes: 5 additions & 2 deletions doomsday/libgui/include/de/gui/glentrypoints.h
Expand Up @@ -120,8 +120,11 @@ LIBGUI_EXTERN_C PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;

// Extensions:

LIBGUI_EXTERN_C PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
LIBGUI_EXTERN_C PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT;
LIBGUI_EXTERN_C PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
LIBGUI_EXTERN_C PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT;
#ifdef GL_NV_framebuffer_multisample_coverage
LIBGUI_EXTERN_C PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENV glRenderbufferStorageMultisampleCoverageNV;
#endif

void getAllOpenGLEntryPoints();

Expand Down
1 change: 1 addition & 0 deletions doomsday/libgui/include/de/gui/glinfo.h
Expand Up @@ -44,6 +44,7 @@ class LIBGUI_PUBLIC GLInfo

// Vendor-specific extensions:
duint32 ATI_texture_env_combine3 : 1;
duint32 NV_framebuffer_multisample_coverage : 1;
duint32 NV_texture_env_combine4 : 1;
duint32 SGIS_generate_mipmap : 1;

Expand Down
10 changes: 8 additions & 2 deletions doomsday/libgui/src/glentrypoints.cpp
Expand Up @@ -99,8 +99,11 @@ PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;

// Extensions:

PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT;
PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT;
#ifdef GL_NV_framebuffer_multisample_coverage
PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENV glRenderbufferStorageMultisampleCoverageNV;
#endif

void getAllOpenGLEntryPoints()
{
Expand Down Expand Up @@ -178,6 +181,9 @@ void getAllOpenGLEntryPoints()

GET_PROC_EXT(glBlitFramebufferEXT);
GET_PROC_EXT(glRenderbufferStorageMultisampleEXT);
#ifdef GL_NV_framebuffer_multisample_coverage
GET_PROC_EXT(glRenderbufferStorageMultisampleCoverageNV);
#endif

haveProcs = true;
}
Expand Down
2 changes: 2 additions & 0 deletions doomsday/libgui/src/glinfo.cpp
Expand Up @@ -114,6 +114,8 @@ DENG2_PIMPL_NOREF(GLInfo)
ext.EXT_texture_filter_anisotropic = query("GL_EXT_texture_filter_anisotropic");

ext.ATI_texture_env_combine3 = query("GL_ATI_texture_env_combine3");
ext.NV_framebuffer_multisample_coverage
= query("GL_NV_framebuffer_multisample_coverage");
ext.NV_texture_env_combine4 = query("GL_NV_texture_env_combine4");
ext.SGIS_generate_mipmap = query("GL_SGIS_generate_mipmap");

Expand Down
23 changes: 18 additions & 5 deletions doomsday/libgui/src/gltarget.cpp
Expand Up @@ -186,12 +186,25 @@ DENG2_OBSERVES(Asset, Deletion)

if(sampleCount > 1)
{
LOG_DEBUG("FBO %i: renderbuffer %ix%i is multisampled with %i samples => attachment %i")
<< fbo << size.x << size.y << sampleCount
<< attachmentToId(attachment);
#ifdef GL_NV_framebuffer_multisample_coverage
if(GLInfo::extensions().NV_framebuffer_multisample_coverage)
{
LOG_DEBUG("FBO %i: renderbuffer %ix%i is multisampled with %i CSAA samples => attachment %i")
<< fbo << size.x << size.y << sampleCount
<< attachmentToId(attachment);

glRenderbufferStorageMultisampleCoverageNV(GL_RENDERBUFFER, 8, sampleCount, type, size.x, size.y);
}
else
#endif
{
LOG_DEBUG("FBO %i: renderbuffer %ix%i is multisampled with %i samples => attachment %i")
<< fbo << size.x << size.y << sampleCount
<< attachmentToId(attachment);

DENG2_ASSERT(GLInfo::extensions().EXT_framebuffer_multisample);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, sampleCount, type, size.x, size.y);
DENG2_ASSERT(GLInfo::extensions().EXT_framebuffer_multisample);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, sampleCount, type, size.x, size.y);
}
}
else
{
Expand Down

0 comments on commit cb72a74

Please sign in to comment.