<div dir="ltr">On 1 March 2013 15:14, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Since last September I've been gradually working on an extension to let applications query information about the renderer before (and after) creating a context. I've talked it over with a few ISVs and with various other folks. I also gathered some input from folks at FOSDEM after my talk there. After going through several iterations of review and modification, I think it's finally ready for wider input.<br>
<br>
Some of the earliest feedback that I got was that many ISVs really like the interface that fills this niche on Mac OS. It's a pretty nice API, and this API is modeled after it. There are, however, some differences.<br>
<br>
I've pasted the spec below so that people can provide in-line comments. I've also pushed a branch with the spec and the initial implementation. There are a few things potentially provided by the spec that are not included in the initial implementation. I've implemented a couple unit tests, and I have some piglit tests in-progress.<br>
<br>
<a href="http://cgit.freedesktop.org/~idr/mesa/log/?h=query-renderer" target="_blank">http://cgit.freedesktop.org/~<u></u>idr/mesa/log/?h=query-renderer</a><br>
<br>
I'm mostly looking for input on the specification itself. Once this is good, I will also add EGL support.<br>
<br>
<br>
Name<br>
<br>
MESA_query_renderer<br>
<br>
Name Strings<br>
<br>
GLX_MESA_query_renderer<br>
<br>
Contact<br>
<br>
Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
<br>
IP Status<br>
<br>
No known IP claims.<br>
<br>
Status<br>
<br>
Incomplete. DO NOT SHIP.<br>
<br>
Version<br>
<br>
Version 5, 14-February-2013<br>
<br>
Number<br>
<br>
TBD.<br>
<br>
Dependencies<br>
<br>
GLX 1.4 is required.<br>
<br>
GLX_ARB_create_context and GLX_ARB_create_context_profile are required.<br>
<br>
This extension interacts with GLX_EXT_create_context_es2_<u></u>profile and<br>
GLX_EXT_create_context_es_<u></u>profile.<br>
<br>
Overview<br>
<br>
In many situations, applications want to detect characteristics of a<br>
rendering device before creating a context for that device. Information<br>
gathered at this stage may guide choices the application makes about<br>
color depth, number of samples per-pixel, texture quality, and so on.<br>
In addition, versions of supported APIs and implementation API<br>
preference may also guide start-up decisions made by the application.<br>
For example, one implementation may prefer vertex data be supplied using<br>
methods only available in a compatibility profile, but another<br>
implementation may only support the desired version in a core profile.<br>
<br>
There are also cases where more than one renderer may be available per<br>
display. For example, there is typically a hardware implementation and<br>
a software based implementation. There are cases where an application<br>
may want to pick one over the other. One such situation is when the<br>
software implementation supports more features than the hardware<br>
implementation. Another situation is when a particular version of the<br>
hardware implementation is blacklisted due to known bugs.<br>
<br>
This extension provides a mechanism for the application to query all of<br>
the available renderers for a particular display and screen. In<br>
addition, this extension provides a mechanism for applications to create<br>
contexts with respect to a specific renderer.<br>
<br>
New Procedures and Functions<br>
<br>
Bool glXQueryRendererIntegerMESA(<u></u>Display *dpy, int screen,<br>
int renderer, int attribute,<br>
unsigned int *value);<br>
Bool glXQueryCurrentRendererInteger<u></u>MESA(int attribute, unsigned int *value);<br>
<br>
const char *glXQueryRendererStringMESA(<u></u>Display *dpy, int screen,<br>
int renderer, int attribute);<br>
<br>
const char *<u></u>glXQueryCurrentRendererStringM<u></u>ESA(int attribute);<br>
<br>
New Tokens<br>
<br>
Accepted as an <attribute> in glXQueryRendererIntegerMESA:<br>
<br>
GLX_RENDERER_VENDOR_ID_MESA 0xXXXX<br>
GLX_RENDERER_DEVICE_ID_MESA 0xXXXX<br>
GLX_RENDERER_VERSION_MESA 0xXXXX<br>
GLX_RENDERER_ACCELERATED_MESA 0xXXXX<br>
GLX_RENDERER_VIDEO_MEMORY_MESA 0xXXXX<br>
GLX_RENDERER_UNIFIED_MEMORY_<u></u>ARCHITECTURE_MESA 0xXXXX<br>
GLX_RENDERER_PREFERRED_<u></u>PROFILE_MESA 0xXXXX<br>
GLX_RENDERER_OPENGL_CORE_<u></u>PROFILE_VERSION_MESA 0xXXXX<br>
GLX_RENDERER_OPENGL_<u></u>COMPATIBILITY_PROFILE_VERSION_<u></u>MESA 0xXXXX<br>
GLX_RENDERER_OPENGL_ES_<u></u>PROFILE_VERSION_MESA 0xXXXX<br>
GLX_RENDERER_OPENGL_ES2_<u></u>PROFILE_VERSION_MESA 0xXXXX<br>
<br>
Accepted as an <attribute> in glXQueryRendererStringMESA:<br>
<br>
GLX_RENDERER_VENDOR_ID_MESA<br>
GLX_RENDERER_DEVICE_ID_MESA<br>
<br>
Accepted as an attribute name in <*attrib_list> in<br>
glXCreateContextAttribsARB:<br>
<br>
GLX_RENDERER_ID_MESA 0xXXXX<br>
<br>
Additions to the OpenGL / WGL Specifications<br>
<br>
None. This specification is written for GLX.<br>
<br>
Additions to the GLX 1.4 Specification<br>
<br>
[Add the following to Section X.Y.Z of the GLX Specification]<br>
<br>
To obtain information about the available renderers for a particular<br>
display and screen,<br>
<br>
void glXQueryRendererIntegerMESA(<u></u>Display *dpy, int screen, int renderer,<br>
int attribute, unsigned int *value);<br>
<br>
can be used. The value for <attribute> will be returned in one or more<br>
integers specified by <value>. The values, data sizes, and descriptions<br>
of each renderer attribute are listed in the table below.<br>
<br>
GLX renderer attribute number description<br>
of values<br>
---------------------- --------- -----------<br>
GLX_RENDERER_VENDOR_ID_MESA 1 PCI ID of the device vendor<br>
GLX_RENDERER_DEVICE_ID_MESA 1 PCI ID of the device<br>
GLX_RENDERER_VERSION_MESA 3 Major, minor, and patch level of<br>
the renderer implementation<br>
GLX_RENDERER_ACCELERATED_MESA 1 Boolean indicating whether or<br>
not the renderer is hardware<br>
accelerated<br>
GLX_RENDERER_VIDEO_MEMORY_MESA 1 Number of megabytes of video<br>
memory available to the renderer<br>
GLX_RENDERER_UNIFIED_MEMORY_<u></u>ARCHITECTURE_MESA<br>
1 Boolean indicating whether or<br>
not the renderer uses a unified<br>
memory architecture or has<br>
separate "on-card" and GART<br>
memory.<br>
GLX_RENDERER_PREFERRED_<u></u>PROFILE_MESA<br>
1 Bitmask of the preferred context<br>
profile for this renderer. This<br>
value is suitable to be supplied<br>
with the<br>
GLX_CONTEXT_PROFILE_MASK_ARB<br>
attribute to<br>
glXCreateContextAttribsARB<br>
GLX_RENDERER_OPENGL_CORE_<u></u>PROFILE_VERSION_MESA<br>
2 Maximum core profile major and<br>
minor version supported by the<br>
renderer<br>
GLX_RENDERER_OPENGL_<u></u>COMPATIBILITY_PROFILE_VERSION_<u></u>MESA<br>
2 Maximum compatibility profile<br>
major and minor version<br>
supported by the renderer<br>
GLX_RENDERER_OPENGL_ES_<u></u>PROFILE_VERSION_MESA<br>
2 Maximum OpenGL ES 1.x<br>
major and minor version<br>
supported by the renderer<br>
GLX_RENDERER_OPENGL_ES2_<u></u>PROFILE_VERSION_MESA<br>
2 Maximum OpenGL ES 2.x or 3.x<br>
major and minor version<br>
supported by the renderer<br>
<br>
In the table, boolean attributes will have either the value 0 or 1.<br>
<br>
GLX_RENDERER_OPENGL_CORE_<u></u>PROFILE_VERSION_MESA,<br>
GLX_RENDERER_OPENGL_<u></u>COMAPTIBILITY_PROFILE_VERSION_<u></u>MESA,<br>
GLX_RENDERER_OPENGL_ES_<u></u>PROFILE_VERSION_MESA, and<br>
GLX_RENDERER_OPENGL_ES2_<u></u>PROFILE_VERSION_MESA each return <0, 0> in<br>
*value if no version of that profile is supported.<br>
<br>
If <attribute> is not a recognized value, False is returned, but no GLX<br>
error is generated. Otherwise, True is returned.<br></blockquote><div><br></div><div>It would be nice to clarify (a) what happens to <value> if <attribute> is unrecognized, and (b) that no error is generated if <attribute> is recognized. Here's a possibility that clarifies these things and I suspect matches your intent: "If <attribute> is not a recognized value, False is returned and no data is written to <value>. Otherwise, True is returned. Regardless of whether <attribute> is a recognized value, no GLX error is generated.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
String versions of some attributes may also be queried using<br>
<br>
const char *glXQueryRendererStringMESA(<u></u>Display *dpy, int screen,<br>
int renderer, int attribute);<br>
<br>
The value for <attribute> will be returned in one or more<br>
integers specified by <value>. The values, data sizes, and descriptions<br>
of each renderer attribute are listed in the table below.<br>
<br>
GLX renderer attribute description<br>
---------------------- -----------<br>
GLX_RENDERER_VENDOR_ID_MESA Name of the renderer provider. This may<br>
differ from the vendor name of the<br>
underlying hardware.<br>
GLX_RENDERER_DEVICE_ID_MESA Name of the renderer. This may differ from<br>
the name of the underlying hardware (e.g.,<br>
for a software renderer).<br>
<br>
If <attribute> is not a recognized value, NULL is returned, but no GLX<br>
error is generated.<br>
<br>
The string returned for GLX_RENDERER_VENDOR_ID_MESA will have the same<br>
format as the string that would be returned by glGetString of GL_VENDOR.<br>
It may, however, have a different value.<br>
<br>
The string returned for GLX_RENDERER_DEVICE_ID_MESA will have the same<br>
format as the string that would be returned by glGetString of GL_RENDERER.<br>
It may, however, have a different value.<br></blockquote><div><br></div><div>It's not obvious to me why these two queries might return different values than the corresponding glGetString calls. It might be nice to have a "for example".<br>
<br></div><div>(Issue #15 looks like it's trying to address this question, but I'm afraid I don't understand.)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
[Add to section section 3.3.7 "Rendering Contexts"]<br>
<br>
The attribute name GLX_RENDERER_ID_MESA specified the index of the render<br></blockquote><div><br></div><div>I think you mean "specifies".<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
against which the context should be created. The default value of<br>
GLX_RENDER_ID_MESA is 0.<br>
<br>
<br>
[Add to list of errors for glXCreateContextAttribsARB in section section<br>
3.3.7 "Rendering Contexts"]<br>
<br>
* If the value of GLX_RENDERER_ID_MESA specifies a non-existent<br>
renderer, BadMatch is generated.<br>
<br>
Dependencies on GLX_EXT_create_context_es_<u></u>profile and<br>
GLX_EXT_create_context_es2_<u></u>profile<br>
<br>
If neither extension is supported, remove all mention of<br>
GLX_RENDERER_OPENGL_ES2_<u></u>PROFILE_VERSION_MESA from the spec.<br>
<br>
If GLX_EXT_create_context_es_<u></u>profile is not supported, remove all mention of<br>
GLX_RENDERER_OPENGL_ES_<u></u>PROFILE_VERSION_MESA from the spec.<br>
<br>
Issues<br>
<br>
1) How should the difference between on-card and GART memory be exposed?<br>
<br>
UNRESOLVED.<br>
<br>
2) How should memory limitations of unified memory architecture (UMA)<br>
systems be exposed?<br>
<br>
UNRESOLVED. Some hardware has different per-process and global<br>
limits for memory that can be accessed within a single draw call.<br>
<br>
3) How should the renderer's API preference be advertised?<br>
<br>
UNRESOLVED. The common case for desktop renderers is to prefer<br>
either core or compatibility. However, some renderers may actually<br>
prefer an ES context. This leaves the application in a tough spot<br>
if it can only support core or compatibility and the renderer says it<br>
wants ES.<br>
<br>
4) Should OpenGL ES 2.0 and OpenGL ES 3.0 be treated separately?<br>
<br>
RESOLVED. No. OpenGL ES 3.0 is backwards compatible with OpenGL ES<br>
2.0. Applications can detect OpenGL ES 3.0 support by querying<br>
GLX_RENDERER_OPENGL_ES2_<u></u>PROFILE_VERSION_MESA.<br>
<br>
5) How can applications tell the difference between different hardware<br>
renderers for the same device? For example, whether the renderer is the<br>
open-source driver or the closed-source driver.<br>
<br>
RESOLVED. Assuming this extension is ever implemented outside Mesa,<br>
applications can query GLX_RENDERER_VENDOR_ID_MESA from<br>
glXQueryRendererStringMESA. This will almost certainly return<br>
different strings for open-source and closed-source drivers.<br>
<br>
6) What is the value of GLX_RENDERER_UNIFIED_MEMORY_<u></u>ARCHITECTURE_MESA for<br>
software renderers?<br>
<br>
UNRESOLVED. Video (display) memory and texture memory is not unified<br>
for software implementations, so it seems reasonable for this to be<br>
False.<br>
<br>
7) How does an application determine the number of available renderers?<br>
<br>
UNRESOLVED.<br>
<br>
8) What happens if a fbconfig is used to create context on a renderer<br>
that cannot support it? For example, if a multisampled config is used<br>
with a software renderer that does not support multisampling.<br>
<br>
RESOLVED. The language for glXCreateContextAttribsARB already covers<br>
this case. Context creation will fail, and BadMatch is generated.<br>
<br>
9) In addition to being able to query the supported versions, should<br>
applications also be able to query the supported extensions?<br>
<br>
RESOLVED. No. Desktop OpenGL core profiles and OpenGL ES 3.0 have<br>
moved away from the monolithic string returned by glGetString of<br>
GL_EXTENSIONS. Providing the newer indexed query would require adding<br>
a lot of extra infrastructure, and it would probably provide little<br>
benefit to applications.<br>
<br>
10) What combination of values for GLX_RENDERER_PREFERRED_<u></u>PROFILE_MESA,<br>
GLX_RENDERER_OPENGL_<u></u>COMPATIBILITY_PROFILE_VERSION_<u></u>MESA, and<br>
GLX_RENDERER_OPENGL_CORE_<u></u>PROFILE_VERSION_MESA should be returned<br>
for a renderer that only supports OpenGL 3.1 without the<br>
GL_ARB_compatibility extension?<br>
<br>
RESOLVED. The renderer will return GLX_CONTEXT_CORE_PROFILE_BIT_<u></u>ARB<br>
for GLX_RENDERER_PREFERRED_<u></u>PROFILE_MESA.<br>
<br>
Further, the renderer will return <3,0> for<br>
GLX_RENDERER_OPENGL_<u></u>COMPATIBILITY_PROFILE_VERSION_<u></u>MESA because OpenGL<br>
3.1 without GL_ARB_compatibility is not backwards compatible with<br>
previous versions of OpenGL. The render will return <3,1> for<br>
GLX_RENDERER_OPENGL_CORE_<u></u>PROFILE_VERSION_MESA indicating that support<br>
for OpenGL 3.1 is available.<br>
<br>
Even though there is no OpenGL 3.1 core profile, the values<br>
returned for GLX_RENDERER_PREFERRED_<u></u>PROFILE_MESA and<br>
GLX_RENDERER_OPENGL_CORE_<u></u>PROFILE_VERSION_MESA can be supplied<br>
with the GLX_CONTEXT_PROFILE_MASK_ARB and<br>
GLX_CONTEXT_{MAJOR,MINOR}_<u></u>VERSION_ARB attributes of<br>
glXCreateContextAttribsARB without error. If the requested<br>
OpenGL version is less than 3.2, the<br>
GLX_CONTEXT_PROFILE_MASK_ARB attribute is ignored by<br>
glXCreateContextAttribsARB.<br>
<br>
11) How can application learn about multi-GPU (e.g., SLI, CrossFireX,<br>
etc.) configurations?<br>
<br>
UNRESOLVED. Based on ISV feedback, this is important information to<br>
provide to the application. Given the variety of possible hardware<br>
configurations (e.g., Hybrid CrossFireX) and different rendering<br>
modes (e.g., split-frame rendering vs. alternate-frame rendering),<br>
it's not clear how this information can be communicated.<br>
<br>
It is likely that this will be left to a layered extension.<br>
<br>
12) Should capability queries similar to those in<br>
GL_ARB_internalformat_query or GL_ARB_internalformat_query2 be added?<br>
<br>
RESOLVED. No. With the possible exception of the texture size<br>
queries, it seems unlikely that applications would ever use this<br>
information before creating a context.<br>
<br>
13) Existing GL extensions (e.g., GL_ATI_meminfo and<br>
GL_NVX_gpu_memory_info) allow easy queries after context creation. With<br>
this extension it is a bit of a pain for a portable application to query<br>
the information after context creation.<br>
<br>
RESOLVED. Add versions of the queries that implicitly take the<br>
display, screen, and renderer from the currently bound context.<br>
<br>
14) Why not make the queries from issue #14 GL functions (instead of GLX)?<br></blockquote><div><br></div><div>I'm assuming this is a typo and issue #14 isn't trying to refer to itself :)<br></div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
RESOLVED. It is fairly compelling for the post-creation queries to<br>
just use glGetInteger and glGetString. However, the GL enums and<br>
the GLX enums would have different names and would almost certainly<br>
have different values. It seems like this would cause more problems<br>
than it would solve.<br>
<br>
15) Should the string queries be required to return the same values as<br>
glGetString(GL_VENDOR) and glGetString(GL_RENDERER)?<br>
<br>
UNRESOLVED. This may be useful for applications that already do<br>
device detection based on these strings.<br>
<br>
16) What type should the value parameter of glXQueryRendererIntegerMESA<br>
and glXQueryCurrentRendererInteger<u></u>MESA be?<br>
<br>
UNRESOLVED. Other similar GLX query functions just use int or<br>
unsigned int, so that's what this extension uses for now. However,<br>
an expeclitly sized value, such as uint32_t or uint64_t, seems<br>
preferable.<br>
<br>
Revision History<br>
<br>
Version 1, 2012/08/27 - Initial version<br>
<br>
Version 2, 2012/09/04 - Specify behavior of implementations that<br>
do not support certain profiles.<br>
Change wording of issue #8 to be more<br>
clear.<br>
Make some wording changes to issue #10 to<br>
clarify the resolution a bit.<br>
<br>
Version 3, 2012/09/23 - Add issue #11 regarding multi-GPU systems.<br>
<br>
Version 4, 2013/02/01 - Add issue #12 regarding texture / renderbuffer<br>
format queries.<br>
<br>
Version 5, 2013/02/14 - Add issues #13 and #14 regarding simpler queires<br>
after the context is created and made current.<br>
Add issue #15 regarding the string query.<br>
Add issue #16 regarding the value type returned<br>
by the Integer functions.<br>
______________________________<u></u>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>