Commit Graph

23 Commits

Author SHA1 Message Date
Erik Kurzinger 95b79aa907 GLX: fix context render type queries
Querying the GLX_RENDER_TYPE of a GLX context via glXQueryContext will
currently return the render type of the context's FB config, which is
a bitmask of GLX_RGBA_BIT / GLX_COLOR_INDEX_BIT / ... values. However,
this query should really return the render type that was specified
when creating the context, which is one of GLX_RGBA_TYPE /
GLX_COLOR_INDEX_TYPE / .... To enable this, save the render type when
creating a new context (defaulting to GLX_RGBA_TYPE if unspecified),
and then include this value in the context attributes sent to clients.
2020-11-26 20:07:55 +00:00
Peter Harris 1626e9fa77 glx: set errorValue when returning GLXBadFBConfig
client->errorValue is already set in validGlxFBConfig. Set it in
__glXDisp_CreateContextAttribsARB for consistency.

Signed-off-by: Peter Harris <pharris@opentext.com>
2020-09-30 16:07:36 -04:00
Adam Jackson 007d812a83 glx: Fix GLX_CONTEXT_RELEASE_BEHAVIOR_ARB handling
None of this was getting compiled because we hadn't defined the macro
(and aren't getting them from <GL/glxext.h> because reasons). Fix that.

Fixes: xorg/xserver#684
2019-05-01 14:38:09 +00:00
Olivier Fourdan 75448671ab glx: check for indirect context in CreateContextAttribsARB()
Commit 99f0365b "Add a command line argument for disabling indirect GLX"
added a test to check if indirect context are enabled in
`DoCreateContext()` but `__glXDisp_CreateContextAttribsARB()` doesn't
use `DoCreateContext()` and doesn't check if indirect context is
enabled.

As a result, clients can still manage to create indirect contexts using
`glXCreateContextAttribsARB()` even if indirect contexts are disabled,
which can possibly crash Xservers such as Xwayland or Xephyr when the
context is destroyed.

To avoid the issue, check for `enableIndirectGLX` in
`__glXDisp_CreateContextAttribsARB()` as well.

Fixes: 99f0365b "Add a command line argument for disabling indirect GLX"
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107508
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2018-09-10 14:54:23 +00:00
Adam Jackson a63ab81f6b glx: Enable GLX_ARB_create_context_no_error (v2)
This is mostly for the client library's convenience, if this extension
is listed then it can know the attribute won't be rejected. Note that we
don't honor this attribute for indirect contexts. That's fine, we don't
want to introduce undefined behavior into a potentially privileged
process.

v2: Remember to ignore the attribute (Eric Anholt)

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-02-26 10:18:58 -05:00
Adam Jackson d8ec33fe05 glx: Use vnd layer for dispatch (v4)
The big change here is MakeCurrent and context tag tracking. We now
delegate context tags entirely to the vnd layer, and simply store a
pointer to the context state as the tag data. If a context is deleted
while it's current, we allocate a fake ID for the context and move the
context state there, so the tag data still points to a real context. As
a result we can stop trying so hard to detach the client from contexts
at disconnect time and just let resource destruction handle it.

Since vnd handles all the MakeCurrent protocol now, our request handlers
for it can just be return BadImplementation. We also remove a bunch of
LEGAL_NEW_RESOURCE, because now by the time we're called vnd has already
allocated its tracking resource on that XID.

v2: Update to match v2 of the vnd import, and remove more redundant work
like request length checks.

v3: Add/remove the XID map from the vendor private thunk, not the
backend. (Kyle Brenneman)

v4: Fix deletion of ghost contexts (Kyle Brenneman)

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-02-14 17:04:44 -05:00
Adam Jackson a4c1e29082 glx: Implement GLX_EXT_no_config_context (v2)
Only enabled for the DRI backends at the moment. In principle WGL/CGL
could support this - it's sort of implied by GL 3.0 support - but in
practice their implementations back GLX drawables with native drawables
(and not anonymous FBOs), so they would need either a corresponding
window system binding extension or significant implementation work.

v2: Require that the two screen numbers match, per v4 of spec.

Khronos: https://github.com/KhronosGroup/OpenGL-Registry/pull/102
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-12-04 11:22:44 -05:00
Adam Jackson 51bab63b73 glx: Remove True/False defines
Those are xlib spellings, we say TRUE/FALSE pretty consistently
elsewhere in the server.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2017-08-21 10:12:54 -04:00
Adam Jackson db0dd06ddf glx: Allow arbitrary context attributes for direct contexts
For direct contexts, most context attributes don't require any
particular awareness on the part of the server. Examples include
GLX_ARB_create_context_no_error and GLX_ARB_context_flush_control, where
all of the behavior change lives in the renderer; since that's on the
client side for a direct context, there's no reason for the X server to
validate the attribute.

The context attributes will still be validated on the client side, and
we still validate attributes for indirect contexts since the server
implementation might need to handle them. For example, the indirect
code might internally use ARB_context_flush_control for all contexts, in
which case it would need to manually emit glFlush when the client
switches between two indirect contexts that didn't request the no-flush
attribute.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-07-31 10:59:09 -04:00
Adam Jackson 0ebb58f6b6 glx: Remove some redundant zero-init of GLX context state
The context is already calloc'd.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-05-11 11:23:20 -04:00
Adam Jackson bc415fb1e0 glx: Fix GLX_EXT_create_context_es2_profile support
As of v4 of this extension, any GLES version number may be requested (to
enable GLES3 and later). To comply with this, simply remove the API
version checks and leave it to the DRI driver to validate. This happens
to also enable using GLES1 in direct contexts, so if that's the dire
situation you find yourself in, your client driver at least stands a
chance of working.

v4 also specifies that both extension strings should be advertised for
compatibility with clients written against v1 of the extension spec, so
add the es_profile bit to the extension list and enable it whenever we
would enable es2_profile.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-01-21 10:11:07 -05:00
Adam Jackson 995ff11422 glx: Implement GLX_ARB_context_flush_control
This extension allows clients to opt out of the implicit glFlush on
context release, which is quite nice for performance for clients using
multiple contexts.  The server doesn't really need to be aware of the
client's decision, at least for direct contexts, but it does need to not
reject the context attribute out of hand.

This patch won't do anything unless built against a Mesa that defines
the __DRI2_FLUSH_CONTROL extension (and a new enough glxext.h, but
that's been there since 10.3 at least).

Reviewed-by: James Jones <jajones@nvidia.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2015-07-08 16:41:28 -04:00
Keith Packard b32a4c91cc Merge remote-tracking branch 'idr/glx-float-fbconfig' 2013-10-29 09:37:30 -07:00
Adam Jackson 276d8057aa glx: Fix memory leak in context garbage collection (v2)
I broke this, back in:

    commit a48dadc98a
    Author: Adam Jackson <ajax@redhat.com>
    Date:   Mon Mar 21 11:59:29 2011 -0400

	glx: Reimplement context tags

In that, I changed the glx client state to not explicitly track the list
of current contexts for the client (since that was what we were deriving
tags from).  The bug was that I removed the code for same from
glxClientCallback without noticing that it had the side effect of
effectively de-currenting those contexts, so that ContextGone could free
them.  So, if you had a client exit with a context still current, the
context's memory would leak.  Not a huge deal for direct clients, but
viciously bad for indirect, since the swrast context state at the bottom
of Mesa is like 15M.

Fix this by promoting Bool isCurrent to ClientPtr currentClient, so that
we have a back-pointer to chase when walking the list of contexts when
ClientStateGone happens.

v2: Explicitly call __glXFreeContext on the ClientStateGone path.  Our
current context might be one we got from EXT_import_context and whose
creating client has since died.  Without the explicit call, the creating
client's FreeClientResources would not free the context because it's
still current, and the using client's FreeClientResources would not free
the context because it's not an XID it created.  This matches the logic
from a48dadc.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-10-29 10:30:43 -04:00
Daniel Czarnowski eabb523aa4 glx: Allow float renderType in glXCreateContextAttribsARB
This enables GLX_RGBA_FLOAT_TYPE_ARB and
GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT as valid renderType parameters to
glXCreateContextAttribsARB.

v2 (idr) : Use C-style comments and fix word wrapping.  Re-write commit
message.

Signed-off-by: Daniel Czarnowski <daniel.czarnowski@intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-10-24 11:16:27 -07:00
Ian Romanick 90aa2486e3 glx: Allow attributes and flags from GLX_ARB_create_context_robustness
The assumtion is that if the underlying provider (e.g., glxdri2.c) doesn't
support this extension, it will generate BadMatch for these flags and
attributes.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-05 11:45:32 -07:00
Ian Romanick aef0b4593e glx: Track the reset notification strategy for a context
Also require that the reset notification for a new context and the other
context in the share group match.  There isn't yet any way to specify a
non-default reset notification strategy, but that will come.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-05 11:45:15 -07:00
Ian Romanick 4ffbc984ea glx: Reject creations of indirect contexts with unsupportable versions.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-05 11:44:20 -07:00
Ian Romanick 41d5120eaf glx: Implement GLX_EXT_create_context_es2_profile
This patch builds on the infrastucture put in place for
GLX_ARB_create_context_profile.  If GLX_CONTEXT_ES2_PROFILE_BIT_EXT is
specified and the requested version is 2.0, create a context with the
__DRI_API_GLES2 API.

This change assumes that any DRI2 driver can handle (possibly by saying "no
seeing an API setting other than __DRI_API_OPENGL or __DRI_API_OPENGL_CORE.
This allows enabling the extension any time GLX_ARB_create_context (and
GLX_ARB_create_context_profile) is enabled.

v2: Clean up some comments.  Note that our behavior for
GLX_CONTEXT_ES2_PROFILE_BIT_EXT w/version != 2.0 matches NVIDIA's.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-05 11:44:17 -07:00
Ian Romanick cef0b808d3 glx: Implement GLX_ARB_create_context_profile
Most of the infrastructure was already in place.  This just adds:

    * Validate values specified with the GLX_CONTEXT_PROFILE_MASK_ARB
      attribute.

    * Select a DRI2 "api" based on the setting of
      GLX_CONTEXT_PROFILE_MASK_ARB.

    * Enable GLX_ARB_create_context_profile extension.

This change assumes that any DRI2 driver can handle (possibly by saying "no")
seeing an API setting other than __DRI_API_OPENGL.  This allows enabling this
extension any time GLX_ARB_create_context is enabled.

Also, the validation code in __glXDisp_CreateContextAttribsARB is structured
in a very verbose manner (using a switch-statement) to ease the addition of
GLX_EXT_create_context_es2_profile.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-05 11:44:13 -07:00
Ian Romanick b840ba5f54 glx: Implement protocol for glXCreateContextAttribsARB
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2012-05-23 13:08:12 -07:00
Keith Packard 9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Ian Romanick e8485768c1 glx: Add stub implementations of next GLX extension functions
Generated code from Mesa contains dispatch for GLX_ARB_create_context
and GLX_ARB_create_context_profile.  Provide stub implementations of
these functions so that the GLX extension will link.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2011-12-19 13:38:49 -08:00