<div dir="ltr">Thank you.<br><div><br>I will rename the function to validate_renderType_against_config and make it return bool.<br></div><div>I will fix the brace.<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/7/15 Ian Romanick <span dir="ltr"><<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 07/15/2013 07:28 AM, Tomasz Lis wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The change is to correctly handle the value of renderType in GLX context.<br>
In case of the value being incorrect, context creation fails.<br>
---<br>
src/glx/dri2_glx.c | 11 +++++++++++<br>
src/glx/dri_glx.c | 6 ++++++<br>
src/glx/drisw_glx.c | 12 ++++++++++++<br>
src/glx/glxclient.h | 2 ++<br>
src/glx/glxcmds.c | 25 +++++++++++++++++++++++++<br>
src/glx/indirect_glx.c | 6 ++++++<br>
src/mesa/drivers/x11/fakeglx.c | 5 ++++-<br>
7 files changed, 66 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c<br>
index d60c675..539e7f1 100644<br>
--- a/src/glx/dri2_glx.c<br>
+++ b/src/glx/dri2_glx.c<br>
@@ -205,6 +205,12 @@ dri2_create_context(struct glx_screen *base,<br>
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;<br>
__DRIcontext *shared = NULL;<br>
<br>
+ /* Check the renderType value */<br>
+ renderType = verifyContextRenderTypeGLX(<u></u>config_base, renderType);<br>
+ if (!renderType) {<br>
+ return NULL;<br>
+ }<br>
+<br>
</blockquote>
<br></div></div>
Every place that uses verifyConextRenderTypeGLX should be:<br>
<br>
if (!verifyContextRenderTypeGLX(<u></u>config_base, renderType))<br>
return NULL;<br>
<br>
And see blow.<div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
if (shareList) {<br>
/* If the shareList context is not a DRI2 context, we cannot possibly<br>
* create a DRI2 context that shares it.<br>
@@ -277,6 +283,11 @@ dri2_create_context_attribs(<u></u>struct glx_screen *base,<br>
error))<br>
goto error_exit;<br>
<br>
+ /* Check the renderType value */<br>
+ renderType = verifyContextRenderTypeGLX(<u></u>config_base, renderType);<br>
+ if (!renderType)<br>
+ goto error_exit;<br>
+<br>
if (shareList) {<br>
pcp_shared = (struct dri2_context *) shareList;<br>
shared = pcp_shared->driContext;<br>
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c<br>
index cc45734..de44451 100644<br>
--- a/src/glx/dri_glx.c<br>
+++ b/src/glx/dri_glx.c<br>
@@ -581,6 +581,12 @@ dri_create_context(struct glx_screen *base,<br>
if (!psc->base.driScreen)<br>
return NULL;<br>
<br>
+ /* Check the renderType value */<br>
+ renderType = verifyContextRenderTypeGLX(<u></u>config_base, renderType);<br>
+ if (!renderType) {<br>
+ return NULL;<br>
+ }<br>
+<br>
if (shareList) {<br>
/* If the shareList context is not a DRI context, we cannot possibly<br>
* create a DRI context that shares it.<br>
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c<br>
index ef0e52b..0e45607 100644<br>
--- a/src/glx/drisw_glx.c<br>
+++ b/src/glx/drisw_glx.c<br>
@@ -380,6 +380,12 @@ drisw_create_context(struct glx_screen *base,<br>
if (!psc->base.driScreen)<br>
return NULL;<br>
<br>
+ /* Check the renderType value */<br>
+ renderType = verifyContextRenderTypeGLX(<u></u>config_base, renderType);<br>
+ if (!renderType) {<br>
+ return NULL;<br>
+ }<br>
+<br>
if (shareList) {<br>
/* If the shareList context is not a DRISW context, we cannot possibly<br>
* create a DRISW context that shares it.<br>
@@ -451,6 +457,12 @@ drisw_create_context_attribs(<u></u>struct glx_screen *base,<br>
error))<br>
return NULL;<br>
<br>
+ /* Check the renderType value */<br>
+ renderType = verifyContextRenderTypeGLX(<u></u>config_base, renderType);<br>
+ if (!renderType) {<br>
+ return NULL;<br>
+ }<br>
+<br>
if (reset != __DRI_CTX_RESET_NO_<u></u>NOTIFICATION)<br>
return NULL;<br>
<br>
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h<br>
index fc8f31c..0e78584 100644<br>
--- a/src/glx/glxclient.h<br>
+++ b/src/glx/glxclient.h<br>
@@ -803,6 +803,8 @@ extern int<br>
applegl_create_display(struct glx_display *display);<br>
#endif<br>
<br>
+extern int verifyContextRenderTypeGLX(<u></u>const struct glx_config *config, int renderType);<br>
+<br>
<br>
extern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable);<br>
extern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw,<br>
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c<br>
index 99b0218..e5ae7f8 100644<br>
--- a/src/glx/glxcmds.c<br>
+++ b/src/glx/glxcmds.c<br>
@@ -224,6 +224,31 @@ ValidateGLXFBConfig(Display * dpy, GLXFBConfig fbconfig)<br>
return NULL;<br>
}<br>
<br>
+/**<br>
+ * Verifies context's GLX_RENDER_TYPE value with config.<br>
+ * \param config GLX FBConfig which will support the returned renderType.<br>
+ * \param renderType The context render type to be verified.<br>
+ * \return Gives the approved value of context renderType, or 0 if no valid value was found.<br>
+ */<br>
</blockquote>
<br></div></div>
The users of this function only care that it returns 0 or non-0. Have it return type Bool instead.<br>
<br>
I also think this function could use a better name. validate_renderType_against_<u></u>config seems more descriptive.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+int<br>
+verifyContextRenderTypeGLX(<u></u>const struct glx_config *config, int renderType)<br>
+{<br>
+ switch (renderType)<br>
+ {<br>
</blockquote>
<br></div>
Opening curly brace should be on the same line with the switch.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ case GLX_RGBA_TYPE:<br>
+ return (config->renderType & GLX_RGBA_BIT) ? GLX_RGBA_TYPE : 0;<br>
</blockquote>
<br></div>
return (config->renderType & GLX_RGBA_BIT) != 0;<br>
<br>
etc.<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ case GLX_COLOR_INDEX_TYPE:<br>
+ return (config->renderType & GLX_COLOR_INDEX_BIT) ? GLX_COLOR_INDEX_TYPE : 0;<br>
+ case GLX_RGBA_FLOAT_TYPE_ARB:<br>
+ return (config->renderType & GLX_RGBA_FLOAT_BIT_ARB) ? GLX_RGBA_FLOAT_TYPE_ARB : 0;<br>
+ case GLX_RGBA_UNSIGNED_FLOAT_TYPE_<u></u>EXT:<br>
+ return (config->renderType & GLX_RGBA_UNSIGNED_FLOAT_BIT_<u></u>EXT) ? GLX_RGBA_UNSIGNED_FLOAT_TYPE_<u></u>EXT : 0;<br>
+ default:<br>
+ break;<br>
+ }<br>
+ return 0;<br>
+}<br>
+<br>
_X_HIDDEN Bool<br>
glx_context_init(struct glx_context *gc,<br>
struct glx_screen *psc, struct glx_config *config)<br>
diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c<br>
index fc5107d..c1a81d5 100644<br>
--- a/src/glx/indirect_glx.c<br>
+++ b/src/glx/indirect_glx.c<br>
@@ -352,6 +352,12 @@ indirect_create_context(struct glx_screen *psc,<br>
return NULL;<br>
}<br>
<br>
+ /* Check the renderType value */<br>
+ renderType = verifyContextRenderTypeGLX(<u></u>mode, renderType);<br>
+ if (!renderType) {<br>
+ return NULL;<br>
+ }<br>
+<br>
/* Allocate our context record */<br>
gc = calloc(1, sizeof *gc);<br>
if (!gc) {<br>
diff --git a/src/mesa/drivers/x11/<u></u>fakeglx.c b/src/mesa/drivers/x11/<u></u>fakeglx.c<br>
index 7a2cfbe..c48fc40 100644<br>
--- a/src/mesa/drivers/x11/<u></u>fakeglx.c<br>
+++ b/src/mesa/drivers/x11/<u></u>fakeglx.c<br>
@@ -2325,7 +2325,10 @@ Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config,<br>
XMesaVisual xmvis = (XMesaVisual) config;<br>
<br>
if (!dpy || !config ||<br>
- (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))<br>
+ (renderType != GLX_RGBA_TYPE &&<br>
+ renderType != GLX_COLOR_INDEX_TYPE &&<br>
+ renderType != GLX_RGBA_FLOAT_TYPE_ARB &&<br>
+ renderType != GLX_RGBA_UNSIGNED_FLOAT_TYPE_<u></u>EXT))<br>
return 0;<br>
<br>
glxCtx = CALLOC_STRUCT(fake_glx_<u></u>context);<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>