summaryrefslogtreecommitdiff
path: root/glx
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-10-29 09:37:30 -0700
committerKeith Packard <keithp@keithp.com>2013-10-29 09:37:30 -0700
commitb32a4c91ccd479638c2bd2c0143b6ea170c717d1 (patch)
tree6fe82e8edeba911311efd01784fa129bb0c7e873 /glx
parentbe6680967a479eedbcab2fe1718c5f981e1029c7 (diff)
parentc671e935e7c44d4711ba9588ee96cb9796b879e6 (diff)
Merge remote-tracking branch 'idr/glx-float-fbconfig'
Diffstat (limited to 'glx')
-rw-r--r--glx/createcontext.c2
-rw-r--r--glx/extension_string.c5
-rw-r--r--glx/extension_string.h1
-rw-r--r--glx/glxdri2.c11
-rw-r--r--glx/glxdricommon.c42
-rw-r--r--glx/glxext.h16
6 files changed, 74 insertions, 3 deletions
diff --git a/glx/createcontext.c b/glx/createcontext.c
index 78792dab6..cbeddec26 100644
--- a/glx/createcontext.c
+++ b/glx/createcontext.c
@@ -68,6 +68,8 @@ validate_render_type(uint32_t render_type)
switch (render_type) {
case GLX_RGBA_TYPE:
case GLX_COLOR_INDEX_TYPE:
+ case GLX_RGBA_FLOAT_TYPE_ARB:
+ case GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT:
return True;
default:
return False;
diff --git a/glx/extension_string.c b/glx/extension_string.c
index 58f930f75..4bef96f0b 100644
--- a/glx/extension_string.c
+++ b/glx/extension_string.c
@@ -65,12 +65,17 @@ struct extension_info {
unsigned char driver_support;
};
+/**
+ * List of known GLX Extensions.
+ * The last Y/N switch informs whether the support of this extension is always enabled.
+ */
static const struct extension_info known_glx_extensions[] = {
/* GLX_ARB_get_proc_address is implemented on the client. */
/* *INDENT-OFF* */
{ GLX(ARB_create_context), VER(0,0), N, },
{ GLX(ARB_create_context_profile), VER(0,0), N, },
{ GLX(ARB_create_context_robustness), VER(0,0), N, },
+ { GLX(ARB_fbconfig_float), VER(0,0), N, },
{ GLX(ARB_framebuffer_sRGB), VER(0,0), N, },
{ GLX(ARB_multisample), VER(1,4), Y, },
diff --git a/glx/extension_string.h b/glx/extension_string.h
index 81b7de372..e7d393297 100644
--- a/glx/extension_string.h
+++ b/glx/extension_string.h
@@ -39,6 +39,7 @@ enum {
ARB_create_context_bit = 0,
ARB_create_context_profile_bit,
ARB_create_context_robustness_bit,
+ ARB_fbconfig_float_bit,
ARB_framebuffer_sRGB_bit,
ARB_multisample_bit,
EXT_create_context_es2_profile_bit,
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index f6a7c06db..1d74c8f5a 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -841,6 +841,11 @@ glxDRILeaveVT(ScrnInfoPtr scrn)
scrn->LeaveVT = glxDRILeaveVT;
}
+/**
+ * Initialize extension flags in glx_enable_bits when a new screen is created
+ *
+ * @param screen The screen where glx_enable_bits are to be set.
+ */
static void
initializeExtensions(__GLXDRIscreen * screen)
{
@@ -885,6 +890,12 @@ initializeExtensions(__GLXDRIscreen * screen)
LogMessage(X_INFO, "AIGLX: enabled GLX_EXT_framebuffer_sRGB\n");
}
+ /* enable ARB_fbconfig_float extension (even if there are no float fbconfigs) */
+ {
+ __glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_fbconfig_float");
+ LogMessage(X_INFO, "AIGLX: enabled GLX_ARB_fbconfig_float\n");
+ }
+
for (i = 0; extensions[i]; i++) {
#ifdef __DRI_READ_DRAWABLE
if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index 0ab3e3071..48f0bce21 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -36,6 +36,7 @@
#include <GL/internal/dri_interface.h>
#include <os.h>
#include "glxserver.h"
+#include "glxext.h"
#include "glxcontext.h"
#include "glxscreens.h"
#include "glxdricommon.h"
@@ -127,6 +128,7 @@ createModeFromConfig(const __DRIcoreExtension * core,
unsigned int visualType, unsigned int drawableType)
{
__GLXDRIconfig *config;
+ GLint renderType = 0;
unsigned int attrib, value;
int i;
@@ -138,11 +140,14 @@ createModeFromConfig(const __DRIcoreExtension * core,
while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
switch (attrib) {
case __DRI_ATTRIB_RENDER_TYPE:
- config->config.renderType = 0;
if (value & __DRI_ATTRIB_RGBA_BIT)
- config->config.renderType |= GLX_RGBA_BIT;
+ renderType |= GLX_RGBA_BIT;
if (value & __DRI_ATTRIB_COLOR_INDEX_BIT)
- config->config.renderType |= GLX_COLOR_INDEX_BIT;
+ renderType |= GLX_COLOR_INDEX_BIT;
+ if (value & __DRI_ATTRIB_FLOAT_BIT)
+ renderType |= GLX_RGBA_FLOAT_BIT_ARB;
+ if (value & __DRI_ATTRIB_UNSIGNED_FLOAT_BIT)
+ renderType |= GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT;
break;
case __DRI_ATTRIB_CONFIG_CAVEAT:
if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
@@ -171,11 +176,26 @@ createModeFromConfig(const __DRIcoreExtension * core,
config->config.next = NULL;
config->config.xRenderable = GL_TRUE;
config->config.visualType = visualType;
+ config->config.renderType = renderType;
config->config.drawableType = drawableType;
return &config->config;
}
+static Bool
+render_type_is_pbuffer_only(unsigned renderType)
+{
+ /* The GL_ARB_color_buffer_float spec says:
+ *
+ * "Note that floating point rendering is only supported for
+ * GLXPbuffer drawables. The GLX_DRAWABLE_TYPE attribute of the
+ * GLXFBConfig must have the GLX_PBUFFER_BIT bit set and the
+ * GLX_RENDER_TYPE attribute must have the GLX_RGBA_FLOAT_BIT set."
+ */
+ return !!(renderType & (__DRI_ATTRIB_UNSIGNED_FLOAT_BIT
+ | __DRI_ATTRIB_FLOAT_BIT));
+}
+
__GLXconfig *
glxConvertConfigs(const __DRIcoreExtension * core,
const __DRIconfig ** configs, unsigned int drawableType)
@@ -187,6 +207,14 @@ glxConvertConfigs(const __DRIcoreExtension * core,
head.next = NULL;
for (i = 0; configs[i]; i++) {
+ unsigned renderType = 0;
+ if (core->getConfigAttrib(configs[i], __DRI_ATTRIB_RENDER_TYPE,
+ &renderType)) {
+ if (render_type_is_pbuffer_only(renderType) &&
+ !(drawableType & GLX_PBUFFER_BIT))
+ continue;
+ }
+ /* Add all the others */
tail->next = createModeFromConfig(core,
configs[i], GLX_TRUE_COLOR,
drawableType);
@@ -197,6 +225,14 @@ glxConvertConfigs(const __DRIcoreExtension * core,
}
for (i = 0; configs[i]; i++) {
+ int renderType = 0;
+ if (core->getConfigAttrib(configs[i], __DRI_ATTRIB_RENDER_TYPE,
+ &renderType)) {
+ if (render_type_is_pbuffer_only(renderType) &&
+ !(drawableType & GLX_PBUFFER_BIT))
+ continue;
+ }
+ /* Add all the others */
tail->next = createModeFromConfig(core,
configs[i], GLX_DIRECT_COLOR,
drawableType);
diff --git a/glx/glxext.h b/glx/glxext.h
index 9b0978b93..3f2dee696 100644
--- a/glx/glxext.h
+++ b/glx/glxext.h
@@ -35,6 +35,22 @@
* Silicon Graphics, Inc.
*/
+/* doing #include <GL/glx.h> & #include <GL/glxext.h> could cause problems
+ * with overlapping definitions, so let's use the easy way
+ */
+#ifndef GLX_RGBA_FLOAT_BIT_ARB
+#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004
+#endif
+#ifndef GLX_RGBA_FLOAT_TYPE_ARB
+#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9
+#endif
+#ifndef GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
+#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008
+#endif
+#ifndef GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
+#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1
+#endif
+
extern GLboolean __glXFreeContext(__GLXcontext * glxc);
extern void __glXFlushContextCache(void);