diff options
author | Jonathan Waddell <jwaddell@nvidia.com> | 2018-02-06 11:37:48 -0800 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2018-04-11 14:17:31 -0700 |
commit | 907b2e2ec8cd0b16590075c97270f32150bb0f50 (patch) | |
tree | e55387bb6b7f4b13ec8e370b071e423eb6f9272a | |
parent | e68451dd0aefbeed58fb033dadc3759755d82ebb (diff) |
Add EGL information to the OpenGL/GLX information page.
This change adds EGL information in a similar form to the already shown OpenGL and GLX information listed per display in nvidia-settings. This also adds a button to show available EGL Frame Buffer configurations in a popup window.
To properly format these additions, some changes are required on the existing OpenGL/GLX information page. First, the page has been renamed to "Graphics Information" but the "ctkglx" and name on top level functions and files has been left as is. Second, the layout of the page has been changed from a simple full list of GLX, Server GLX, Client GLX, and OpenGL information to an expanding view with each of the previously listed items as collapsible headers and adding an entry for EGL Information.
This change also adds the command line "--eglinfo" (and "-E") option to print the added EGL information and related Frame Buffer Configurations.
Includes PNG files for both the GLX -> Graphics page rename and for VDPAU to keep a consistent look. The following are the steps used to create the text images in GIMP.
==Instructions==
Create a Gradient
Split it into 3 parts, referred as 1, 2 and 3. Left to Right.
Segment 1, Left color #AAAAAA, Right color #EEEEEE, endpoints around 0.0 and 0.45
Segment 2, Left and right #EEEEEE, endpoints 0.45 to 0.55.
Segment 3, Reverse of 1, Left color #EEEEEE, Right color #AAAAAA, endpoints 0.55 to 1.0
Make the Text
Using DIN Pro font, the font NVIDIA uses for promo material, type in the text with text tool.
Right click on it, click "Path from Text"
Select it with Select -> From Path
Choose Gradient tool, using custom gradient made above, drag from above right of center to below left of center.
Then Filters -> Light and Shadow -> Drop Shadow. I used Offsets of 5, Blur radius 4, and Opacity 60.
Then select the text along with a bit of space around the text and then Image -> Crop to Selection
Then Image -> Scale Image so that image is now similar size to other text graphics.
From command line run> optipng -o7 -zm1-9 new_graphic.png
==End Instructions==
-rw-r--r-- | src/command-line.c | 1 | ||||
-rw-r--r-- | src/glxinfo.c | 255 | ||||
-rw-r--r-- | src/glxinfo.h | 5 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkbanner.c | 4 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkbanner.h | 2 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkglx.c | 869 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkglx.h | 2 | ||||
-rw-r--r-- | src/gtk+-2.x/ctkwindow.c | 4 | ||||
-rw-r--r-- | src/image_data/glx.png | bin | 4756 -> 0 bytes | |||
-rw-r--r-- | src/image_data/graphics.png | bin | 0 -> 8605 bytes | |||
-rw-r--r-- | src/image_data/vdpau.png | bin | 7489 -> 6036 bytes | |||
-rw-r--r-- | src/libXNVCtrlAttributes/NvCtrlAttributes.c | 28 | ||||
-rw-r--r-- | src/libXNVCtrlAttributes/NvCtrlAttributes.h | 68 | ||||
-rw-r--r-- | src/libXNVCtrlAttributes/NvCtrlAttributesEgl.c | 554 | ||||
-rw-r--r-- | src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h | 14 | ||||
-rw-r--r-- | src/option-table.h | 3 | ||||
-rw-r--r-- | src/src.mk | 3 |
17 files changed, 1598 insertions, 214 deletions
diff --git a/src/command-line.c b/src/command-line.c index 21dccaf..6eb6bb1 100644 --- a/src/command-line.c +++ b/src/command-line.c @@ -300,6 +300,7 @@ Options *parse_command_line(int argc, char *argv[], break; case CONFIG_FILE_OPTION: op->config = strval; break; case 'g': print_glxinfo(NULL, systems); exit(0); break; + case 'E': print_eglinfo(NULL, systems); exit(0); break; case 't': op->terse = NV_TRUE; break; case 'd': op->dpy_string = NV_TRUE; break; case 'e': print_attribute_help(strval); exit(0); break; diff --git a/src/glxinfo.c b/src/glxinfo.c index 00c9994..d791b3d 100644 --- a/src/glxinfo.c +++ b/src/glxinfo.c @@ -28,11 +28,12 @@ #include "glxinfo.h" #include <GL/glx.h> /* GLX #defines */ +#include <EGL/egl.h> /* * print_extension_list() - Formats OpenGL/GLX extension strings - * to contain commas and returns a pointer to the formated string. + * to contain commas and returns a pointer to the formatted string. * The user is responsible for freeing this buffer. * * If there is an error or there is not enough memory to create @@ -294,7 +295,7 @@ void print_glxinfo(const char *display_name, CtrlSystemList *systems) GLXFBConfigAttr *fbconfig_attribs = NULL; - char *formated_ext_str = NULL; + char *formatted_ext_str = NULL; system = NvCtrlConnectToSystem(display_name, systems); if (system == NULL) { @@ -323,10 +324,10 @@ void print_glxinfo(const char *display_name, CtrlSystemList *systems) if ( status != NvCtrlSuccess && status != NvCtrlNoAttribute ) { goto finish; } if ( glx_extensions != NULL ) { - formated_ext_str = format_extension_list(glx_extensions); - if ( formated_ext_str != NULL ) { + formatted_ext_str = format_extension_list(glx_extensions); + if ( formatted_ext_str != NULL ) { free(glx_extensions); - glx_extensions = formated_ext_str; + glx_extensions = formatted_ext_str; } } /* Get server GLX information */ @@ -346,10 +347,10 @@ void print_glxinfo(const char *display_name, CtrlSystemList *systems) if ( status != NvCtrlSuccess && status != NvCtrlNoAttribute ) { goto finish; } if ( server_extensions != NULL ) { - formated_ext_str = format_extension_list(server_extensions); - if ( formated_ext_str != NULL ) { + formatted_ext_str = format_extension_list(server_extensions); + if ( formatted_ext_str != NULL ) { free(server_extensions); - server_extensions = formated_ext_str; + server_extensions = formatted_ext_str; } } /* Get client GLX information */ @@ -369,10 +370,10 @@ void print_glxinfo(const char *display_name, CtrlSystemList *systems) if ( status != NvCtrlSuccess && status != NvCtrlNoAttribute ) { goto finish; } if ( client_extensions != NULL ) { - formated_ext_str = format_extension_list(client_extensions); - if ( formated_ext_str != NULL ) { + formatted_ext_str = format_extension_list(client_extensions); + if ( formatted_ext_str != NULL ) { free(client_extensions); - client_extensions = formated_ext_str; + client_extensions = formatted_ext_str; } } /* Get OpenGL information */ @@ -397,10 +398,10 @@ void print_glxinfo(const char *display_name, CtrlSystemList *systems) if ( status != NvCtrlSuccess && status != NvCtrlNoAttribute ) { goto finish; } if ( opengl_extensions != NULL ) { - formated_ext_str = format_extension_list(opengl_extensions); - if ( formated_ext_str != NULL ) { + formatted_ext_str = format_extension_list(opengl_extensions); + if ( formatted_ext_str != NULL ) { free(opengl_extensions); - opengl_extensions = formated_ext_str; + opengl_extensions = formatted_ext_str; } } @@ -489,3 +490,229 @@ void print_glxinfo(const char *display_name, CtrlSystemList *systems) NvCtrlFreeAllSystems(systems); } /* print_glxinfo() */ + + + +/* + * EGL information + * + */ + +const char *egl_color_buffer_type_abbrev(int type) +{ + switch (type) { + case EGL_RGB_BUFFER: + return "rgb"; + case EGL_LUMINANCE_BUFFER: + return "lum"; + default: + return "."; + } +} + +const char *egl_config_caveat_abbrev(int type) +{ + switch (type) { + case EGL_SLOW_CONFIG: + return "slo"; + case EGL_NON_CONFORMANT_CONFIG: + return "NoC"; + case EGL_NONE: + default: + return "."; + } +} + +const char *egl_transparent_type_abbrev(int type) +{ + switch (type) { + case EGL_TRANSPARENT_RGB: + return "rgb"; + case EGL_NONE: + default: + return "."; + } +} + +static void print_egl_config_attribs(const EGLConfigAttr *fbca) +{ + int i; + + if (fbca == NULL) { + return; + } + + printf("--fc- --vi- --vt-- buf lv rgb colorbuffer am lm dp st " + "-bind cfrm sb sm cav -----pbuffer----- swapin nv rn su " + "-transparent--\n"); + printf(" id id siz l lum r g b a sz sz th en " + " - a eat widt hght max-pxs mx mn rd ty ty " + "typ r g b \n"); + printf("------------------------------------------------------" + "-----------------------------------------------------------" + "--------------\n"); + + for (i = 0; fbca[i].config_id != 0; i++) { + + printf("0x%03x ", fbca[i].config_id); + if (fbca[i].native_visual_id) { + printf("0x%03x ", fbca[i].native_visual_id); + } else { + printf(" . "); + } + printf("0x%X %3d %2d %3s ", + fbca[i].native_visual_type, + fbca[i].buffer_size, + fbca[i].level, + egl_color_buffer_type_abbrev(fbca[i].color_buffer_type)); + printf("%2d %2d %2d %2d %2d %2d %2d %2d ", + fbca[i].red_size, + fbca[i].green_size, + fbca[i].blue_size, + fbca[i].alpha_size, + fbca[i].alpha_mask_size, + fbca[i].luminance_size, + fbca[i].depth_size, + fbca[i].stencil_size); + printf("%2c %2c ", + fbca[i].bind_to_texture_rgb ? 'y' : '.', + fbca[i].bind_to_texture_rgba ? 'y' : '.'); + printf("0x%02X %2d %2d ", + fbca[i].conformant, + fbca[i].sample_buffers, + fbca[i].samples); + printf("%3.3s %4x %4x %7x %2d %2d ", + egl_config_caveat_abbrev(fbca[i].config_caveat), + fbca[i].max_pbuffer_width, + fbca[i].max_pbuffer_height, + fbca[i].max_pbuffer_pixels, + fbca[i].max_swap_interval, + fbca[i].min_swap_interval); + printf("%2c %4x %4x ", + fbca[i].native_renderable ? 'y' : '.', + fbca[i].renderable_type, + fbca[i].surface_type); + printf("%3s %2d %2d %2d\n", + egl_transparent_type_abbrev(fbca[i].transparent_type), + fbca[i].transparent_red_value, + fbca[i].transparent_green_value, + fbca[i].transparent_blue_value); + } + +} /* print_egl_config_attribs() */ + + +/* + * print_eglinfo() - prints information about egl + * + */ + +void print_eglinfo(const char *display_name, CtrlSystemList *systems) +{ + CtrlSystem *system; + CtrlTargetNode *node; + ReturnStatus status = NvCtrlSuccess; + + char *egl_vendor = NULL; + char *egl_version = NULL; + char *egl_extensions = NULL; + char *formatted_ext_str = NULL; + + EGLConfigAttr *egl_config_attribs = NULL; + + + system = NvCtrlConnectToSystem(display_name, systems); + if (system == NULL) { + return; + } + + /* Print information for each screen */ + for (node = system->targets[X_SCREEN_TARGET]; node; node = node->next) { + + CtrlTarget *t = node->t; + + /* No screen, move on */ + if (!t->h) continue; + + nv_msg(NULL, "EGL Information for %s:", t->name); + + /* Get EGL information */ + status = NvCtrlGetStringAttribute(t, + NV_CTRL_STRING_EGL_VENDOR, + &egl_vendor); + if (status != NvCtrlSuccess && status != NvCtrlNoAttribute) { + goto finish; + } + + status = NvCtrlGetStringAttribute(t, + NV_CTRL_STRING_EGL_VERSION, + &egl_version); + if (status != NvCtrlSuccess && status != NvCtrlNoAttribute) { + goto finish; + } + + status = NvCtrlGetStringAttribute(t, + NV_CTRL_STRING_EGL_EXTENSIONS, + &egl_extensions); + if (status != NvCtrlSuccess && status != NvCtrlNoAttribute) { + goto finish; + } + + if (egl_extensions != NULL) { + formatted_ext_str = format_extension_list(egl_extensions); + if (formatted_ext_str != NULL) { + free(egl_extensions); + egl_extensions = formatted_ext_str; + } + } + + /* Get FBConfig information */ + status = NvCtrlGetVoidAttribute(t, + NV_CTRL_ATTR_EGL_CONFIG_ATTRIBS, + (void *)(&egl_config_attribs)); + if (status != NvCtrlSuccess && status != NvCtrlNoAttribute) { + goto finish; + } + + + /* Print results */ + nv_msg(TAB, "EGL vendor string: %s", NULL_TO_EMPTY(egl_vendor)); + nv_msg(TAB, "EGL version string: %s", NULL_TO_EMPTY(egl_version)); + nv_msg(TAB, "EGL extensions:"); + nv_msg(" ", "%s", NULL_TO_EMPTY(egl_extensions)); + nv_msg(" ", "\n"); + + if (egl_config_attribs != NULL) { + nv_msg(" ", "\n"); + print_egl_config_attribs(egl_config_attribs); + } + + fflush(stdout); + + /* Free memory used */ + SAFE_FREE(egl_vendor); + SAFE_FREE(egl_version); + SAFE_FREE(egl_extensions); + SAFE_FREE(egl_config_attribs); + + } /* Done looking at all screens */ + + + /* Fall through */ + finish: + if (status == NvCtrlError) { + nv_error_msg("Error fetching EGL Information: %s", + NvCtrlAttributesStrError(status) ); + } + + /* Free any leftover memory used */ + SAFE_FREE(egl_vendor); + SAFE_FREE(egl_version); + SAFE_FREE(egl_extensions); + SAFE_FREE(egl_config_attribs); + + NvCtrlFreeAllSystems(systems); + +} /* print_eglinfo() */ + + diff --git a/src/glxinfo.h b/src/glxinfo.h index c4f84ec..bc2f0be 100644 --- a/src/glxinfo.h +++ b/src/glxinfo.h @@ -32,9 +32,12 @@ const char * transparent_type_abbrev(int trans_type); const char * x_visual_type_abbrev(int x_visual_type); const char * caveat_abbrev(int caveat); #endif - +const char * egl_color_buffer_type_abbrev(int type); +const char * egl_config_caveat_abbrev(int type); +const char * egl_transparent_type_abbrev(int type); void print_glxinfo(const char *display_name, CtrlSystemList *systems); +void print_eglinfo(const char *display_name, CtrlSystemList *systems); #endif /* __GLXINFO_H__ */ diff --git a/src/gtk+-2.x/ctkbanner.c b/src/gtk+-2.x/ctkbanner.c index 034783a..8ea57f6 100644 --- a/src/gtk+-2.x/ctkbanner.c +++ b/src/gtk+-2.x/ctkbanner.c @@ -43,8 +43,8 @@ #include "dfp.png.h" #include "display_config.png.h" #include "framelock.png.h" -#include "glx.png.h" #include "gpu.png.h" +#include "graphics.png.h" #include "help.png.h" #include "opengl.png.h" #include "penguin.png.h" @@ -420,8 +420,8 @@ static GdkPixbuf* select_artwork(BannerArtworkType artwork, { BANNER_ARTWORK_DFP, FALSE, 16, PNG(dfp) }, { BANNER_ARTWORK_DISPLAY_CONFIG, FALSE, 16, PNG(display_config) }, { BANNER_ARTWORK_FRAMELOCK, FALSE, 16, PNG(framelock) }, - { BANNER_ARTWORK_GLX, FALSE, 16, PNG(glx) }, { BANNER_ARTWORK_GPU, FALSE, 16, PNG(gpu) }, + { BANNER_ARTWORK_GRAPHICS, FALSE, 16, PNG(graphics) }, { BANNER_ARTWORK_GVI, FALSE, 16, PNG(gvi) }, { BANNER_ARTWORK_HELP, FALSE, 16, PNG(help) }, { BANNER_ARTWORK_OPENGL, FALSE, 16, PNG(opengl) }, diff --git a/src/gtk+-2.x/ctkbanner.h b/src/gtk+-2.x/ctkbanner.h index f924bef..9cc5284 100644 --- a/src/gtk+-2.x/ctkbanner.h +++ b/src/gtk+-2.x/ctkbanner.h @@ -53,8 +53,8 @@ typedef enum { BANNER_ARTWORK_DFP, BANNER_ARTWORK_DISPLAY_CONFIG, BANNER_ARTWORK_FRAMELOCK, - BANNER_ARTWORK_GLX, BANNER_ARTWORK_GPU, + BANNER_ARTWORK_GRAPHICS, BANNER_ARTWORK_GVI, BANNER_ARTWORK_HELP, BANNER_ARTWORK_OPENGL, diff --git a/src/gtk+-2.x/ctkglx.c b/src/gtk+-2.x/ctkglx.c index 7652adc..098a081 100644 --- a/src/gtk+-2.x/ctkglx.c +++ b/src/gtk+-2.x/ctkglx.c @@ -37,11 +37,14 @@ /* Number of FBConfigs attributes reported in gui */ #define NUM_FBCONFIG_ATTRIBS 32 +#define NUM_EGL_FBCONFIG_ATTRIBS 32 /* FBConfig tooltips */ static const char * __show_fbc_help = "Show the GLX Frame Buffer Configurations table in a new window."; +static const char * __show_egl_fbc_help = + "Show the EGL Frame Buffer Configurations table in a new window."; static const char * __fid_help = "fid (Frame buffer ID) - Frame Buffer Configuration ID."; static const char * __vid_help = @@ -131,6 +134,89 @@ static const char * __tri_help = "tri (Transparency index value) - Color index value considered transparent."; +static const char * __egl_as_help = + "as (Alpha size) - Number of bits of alpha stored in the color buffer."; +static const char * __egl_ams_help = + "ams (Alpha mask size) - Number of bits in the alpha mask buffer."; +static const char * __egl_bt_help = + "bt (Bind to Texture RGB) - 'y' if color buffers can be bound " + "to an RGB texture, '.' otherwise."; +static const char * __egl_bta_help = + "bta (Bind to Texture RGBA) - 'y' if color buffers can be bound " + "to an RGBA texture, '.' otherwise."; +static const char * __egl_bs_help = + "bs (Blue size) - Number of bits of blue stored in the color buffer."; +static const char * __egl_bfs_help = + "bfs (Buffer size) - Depth of the color buffer. It is the sum of 'rs', 'gs', " + "'bs', and 'as'."; +static const char * __egl_cbt_help = + "cbt (Color buffer type) - Type of the color buffer. Possible types are " + "'rgb' for RGB color buffer and 'lum' for Luminance."; +static const char * __egl_cav_help = + "cav (Config caveat) - Caveats for the frame buffer configuration. Possible " + "caveat values are 'slo' for Slow Config, 'NoC' for a non-conformant " + "config, and '.' otherwise."; +static const char * __egl_id_help = + "id (Config ID) - ID of the frame buffer configuration."; +static const char * __egl_cfm_help = + "cfm (Conformant) - Bitmask indicating which client API contexts created " + "with respect to this config are conformant."; +static const char * __egl_dpt_help = + "dpt (Depth size) - Number of bits in the depth buffer."; +static const char * __egl_gs_help = + "gs (Green size) - Number of bits of green stored in the color buffer."; +static const char * __egl_lvl_help = + "lvl (Frame buffer level) - Level zero is the default frame buffer. Positive " + "levels correspond to frame buffers that overlay the default buffer and " + "negative levels correspond to frame buffers that underlay the default " + "buffer."; +static const char * __egl_lum_help = + "lum (Luminance size) - Number of bits of luminance stored in the luminance " + "buffer."; +static const char * __egl_pbw_help = + "pbw (Pbuffer max width) - Maximum width of a pixel buffer surface in " + "pixels."; +static const char * __egl_pbh_help = + "pdh (Pbuffer max height) - Maximum height of a pixel buffer surface in " + "pixels."; +static const char * __egl_pbp_help = + "pbp (Pbuffer max pixels) - Maximum size of a pixel buffer surface in " + "pixels."; +static const char * __egl_six_help = + "six (Swap interval max) - Maximum value that can be passed to " + "eglSwapInterval."; +static const char * __egl_sin_help = + "sin (Swap interval min) - Minimum value that can be passed to " + "eglSwapInterval."; +static const char * __egl_nrd_help = + "nrd (Native renderable) - 'y' if native rendering APIs can " + "render into the surface, '.' otherwise."; +static const char * __egl_vid_help = + "vid (Native visual ID) - ID of the associated native visual."; +static const char * __egl_nvt_help = + "nvt (Native visual type) - Type of the associated native visual."; +static const char * __egl_rs_help = + "rs (Red size) - Number of bits of red stored in the color buffer."; +static const char * __egl_rdt_help = + "rdt (Renderable type) - Bitmask indicating the types of supported client " + "API contexts."; +static const char * __egl_spb_help = + "spb (Sample buffers) - Number of multisample buffers."; +static const char * __egl_smp_help = + "smp (Samples) - Number of samples per pixel."; +static const char * __egl_stn_help = + "stn (Stencil size) - Number of bits in the stencil buffer."; +static const char * __egl_sur_help = + "sur (Surface type) - Bitmask indicating the types of supported EGL " + "surfaces."; +static const char * __egl_tpt_help = + "tpt (Transparent type) - Type of supported transparency. Possible " + "transparency values are: 'rgb' for Transparent RGB and '.' otherwise."; +static const char * __egl_trv_help = "trv (Transparent red value)"; +static const char * __egl_tgv_help = "tgv (Transparent green value)"; +static const char * __egl_tbv_help = "tbv (Transparent blue value)"; + + GType ctk_glx_get_type(void) { static GType ctk_glx_type = 0; @@ -179,13 +265,42 @@ static void show_fbc_toggled(GtkWidget *widget, gpointer user_data) } ctk_config_statusbar_message(ctk_glx->ctk_config, - "Show GLX Frame Buffer Configurations button %s.", + "Show GLX Frame Buffer Configurations " + "button %s.", enabled ? "enabled" : "disabled"); } /* show_fbc_toggled() */ /* + * show_egl_fbc_toggled() - called when the show EGL Frame Buffer Configurations + * button has been toggled. + */ + +static void show_egl_fbc_toggled(GtkWidget *widget, gpointer user_data) +{ + CtkGLX *ctk_glx = user_data; + gboolean enabled; + + /* get the enabled state */ + + enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + + if (enabled) { + gtk_widget_show_all(ctk_glx->egl_fbc_window); + } else { + gtk_widget_hide(ctk_glx->egl_fbc_window); + } + + ctk_config_statusbar_message(ctk_glx->ctk_config, + "Show EGL Frame Buffer Configurations " + "button %s.", + enabled ? "enabled" : "disabled"); + +} /* show_egl_fbc_toggled() */ + + +/* * fbc_window_destroy() - called when the window displaying the * GLX Frame Buffer Configurations table is closed. */ @@ -204,6 +319,24 @@ fbc_window_destroy(GtkWidget *widget, GdkEvent *event, gpointer user_data) /* + * egl_fbc_window_destroy() - called when the window displaying the + * EGL Frame Buffer Configurations table is closed. + */ +static gboolean +egl_fbc_window_destroy(GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + CtkGLX *ctk_glx = user_data; + + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON(ctk_glx->show_egl_fbc_button), + FALSE); + + return TRUE; + +} /* egl_fbc_window_destroy() */ + + +/* * create_fbconfig_model() - called to create and populate the model for * the GLX Frame Buffer Configurations table. */ @@ -335,9 +468,128 @@ static GtkTreeModel *create_fbconfig_model(GLXFBConfigAttr *fbconfig_attribs) return GTK_TREE_MODEL(model); } + +/* + * create_egl_fbconfig_model() - called to create and populate the model for + * the EGL Frame Buffer Configurations table. + */ +static GtkTreeModel* +create_egl_fbconfig_model(EGLConfigAttr *egl_fbconfig_attribs) +{ + GtkListStore *model; + GtkTreeIter iter; + int i; + GValue v = G_VALUE_INIT; + + if (!egl_fbconfig_attribs) { + return NULL; + } + + g_value_init(&v, G_TYPE_STRING); + + model = gtk_list_store_new(NUM_EGL_FBCONFIG_ATTRIBS, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + + /* Populate FBConfig table */ + i = 0; + while ( egl_fbconfig_attribs[i].config_id != 0 ) { + char str[NUM_EGL_FBCONFIG_ATTRIBS + 1][16]; + int cell = 0; + + snprintf((char*) (&(str[cell++])), 16, "0x%02X", + egl_fbconfig_attribs[i].config_id); + snprintf((char*) (&(str[cell++])), 16, "0x%02X", + egl_fbconfig_attribs[i].native_visual_id); + + snprintf((char*) (&(str[cell++])), 16, "0x%X", + egl_fbconfig_attribs[i].native_visual_type); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].buffer_size); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].level); + snprintf((char*) (&(str[cell++])), 16, "%s", + egl_color_buffer_type_abbrev( + egl_fbconfig_attribs[i].color_buffer_type)); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].red_size); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].green_size); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].blue_size); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].alpha_size); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].alpha_mask_size); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].luminance_size); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].depth_size); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].stencil_size); + snprintf((char*) (&(str[cell++])), 16, "%c", + egl_fbconfig_attribs[i].bind_to_texture_rgb ? 'y' : '.'); + snprintf((char*) (&(str[cell++])), 16, "%c", + egl_fbconfig_attribs[i].bind_to_texture_rgba ? 'y' : '.'); + snprintf((char*) (&(str[cell++])), 16, "0x%X", + egl_fbconfig_attribs[i].conformant); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].sample_buffers); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].samples); + snprintf((char*) (&(str[cell++])), 16, "%s", + egl_config_caveat_abbrev(egl_fbconfig_attribs[i].config_caveat)); + snprintf((char*) (&(str[cell++])), 16, "0x%04X", + egl_fbconfig_attribs[i].max_pbuffer_width); + snprintf((char*) (&(str[cell++])), 16, "0x%04X", + egl_fbconfig_attribs[i].max_pbuffer_height); + snprintf((char*) (&(str[cell++])), 16, "0x%07X", + egl_fbconfig_attribs[i].max_pbuffer_pixels); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].max_swap_interval); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].min_swap_interval); + snprintf((char*) (&(str[cell++])), 16, "%c", + egl_fbconfig_attribs[i].native_renderable ? 'y' : '.'); + snprintf((char*) (&(str[cell++])), 16, "0x%X", + egl_fbconfig_attribs[i].renderable_type); + snprintf((char*) (&(str[cell++])), 16, "0x%X", + egl_fbconfig_attribs[i].surface_type); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].transparent_type); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].transparent_red_value); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].transparent_green_value); + snprintf((char*) (&(str[cell++])), 16, "%d", + egl_fbconfig_attribs[i].transparent_blue_value); + + + str[NUM_EGL_FBCONFIG_ATTRIBS][0] = '\0'; + + /* Populate cells for this row */ + gtk_list_store_append (model, &iter); + for (cell=0; cell<NUM_EGL_FBCONFIG_ATTRIBS; cell++) { + g_value_set_string(&v, str[cell]); + gtk_list_store_set_value(model, &iter, cell, &v); + } + + i++; + + } /* Done - Populating FBconfig table */ + + return GTK_TREE_MODEL(model); +} + /* Creates the GLX information widget * - * NOTE: The GLX information other than the FBConfigs will + * NOTE: The Graphics information other than the FBConfigs will * be setup when this page is hooked up and the "parent-set" * signal is thrown. This will result in calling the * ctk_glx_probe_info() function. @@ -354,24 +606,30 @@ GtkWidget* ctk_glx_new(CtrlTarget *ctrl_target, { GObject *object; CtkGLX *ctk_glx; - GtkWidget *label; GtkWidget *banner; - GtkWidget *hseparator; GtkWidget *hbox; GtkWidget *vbox; - GtkWidget *scrollWin; GtkWidget *event; /* For setting the background color to white */ + GtkWidget *window; + GtkWidget *fbc_scroll_win; GtkWidget *fbc_view; GtkTreeModel *fbc_model; - GtkWidget *show_fbc_button, *window; + GtkWidget *show_fbc_button; + + GtkWidget *egl_fbc_scroll_win; + GtkWidget *egl_fbc_view; + GtkTreeModel *egl_fbc_model; + GtkWidget *show_egl_fbc_button; + ReturnStatus ret; + gboolean glx_fbconfigs_available; + gboolean egl_fbconfigs_available; - char * glx_info_str = NULL; /* Test if GLX supported */ - GLXFBConfigAttr *fbconfig_attribs = NULL; /* FBConfig data */ - int i; /* Iterator */ + GLXFBConfigAttr *fbconfig_attribs = NULL; /* FBConfig data */ + EGLConfigAttr *egl_fbconfig_attribs = NULL; /* EGL Configs data */ + int i; /* Iterator */ int num_fbconfigs = 0; - char *err_str = NULL; gchar *fbconfig_titles[NUM_FBCONFIG_ATTRIBS] = { "fid", "vid", "vt", "bfs", "lvl", @@ -398,6 +656,32 @@ GtkWidget* ctk_glx_new(CtrlTarget *ctrl_target, __trb_help, __tra_help, __tri_help }; + gchar *egl_fbconfig_titles[NUM_EGL_FBCONFIG_ATTRIBS] = { + "id", "vid", + "nvt", "bfs", "lvl", "cbt", + "rs", "gs", "bs", "as", + "ams", "lum", "dpt", "stn", + "bt", "bta", "cfm", + "spb", "smp", "cav", + "pbw", "pbh", "pbp", + "six", "sin", + "nrd", "rdt", "sur", + "tpt", "trv", "tgv", "tbv" + }; + + const char *egl_fbconfig_tooltips[NUM_EGL_FBCONFIG_ATTRIBS] = { + __egl_id_help, __egl_vid_help, + __egl_nvt_help, __egl_bfs_help, __egl_lvl_help, __egl_cbt_help, + __egl_rs_help, __egl_gs_help, __egl_bs_help, __egl_as_help, + __egl_ams_help, __egl_lum_help, __egl_dpt_help, __egl_stn_help, + __egl_bt_help, __egl_bta_help, __egl_cfm_help, + __egl_spb_help, __egl_smp_help, __egl_cav_help, + __egl_pbw_help, __egl_pbh_help, __egl_pbp_help, + __egl_six_help, __egl_sin_help, + __egl_nrd_help, __egl_rdt_help, __egl_sur_help, + __egl_tpt_help, __egl_trv_help, __egl_tgv_help, __egl_tbv_help + }; + /* Create the ctk glx object */ object = g_object_new(CTK_TYPE_GLX, NULL); @@ -413,160 +697,218 @@ GtkWidget* ctk_glx_new(CtrlTarget *ctrl_target, /* Image banner */ - banner = ctk_banner_image_new(BANNER_ARTWORK_GLX); + banner = ctk_banner_image_new(BANNER_ARTWORK_GRAPHICS); gtk_box_pack_start(GTK_BOX(ctk_glx), banner, FALSE, FALSE, 0); - /* Determine if GLX is supported */ - ret = NvCtrlGetStringAttribute(ctrl_target, - NV_CTRL_STRING_GLX_SERVER_VENDOR, - &glx_info_str); - free(glx_info_str); - if ( ret != NvCtrlSuccess ) { - err_str = "Failed to query the GLX server vendor."; - goto fail; - } - /* Information Scroll Box */ - scrollWin = gtk_scrolled_window_new(NULL, NULL); hbox = gtk_hbox_new(FALSE, 0); vbox = gtk_vbox_new(FALSE, 5); event = gtk_event_box_new(); ctk_force_text_colors_on_widget(event); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollWin), - GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_container_add(GTK_CONTAINER(event), hbox); - gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollWin), - event); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 5); ctk_glx->glxinfo_vpane = vbox; - gtk_widget_set_size_request(scrollWin, -1, 50); /* GLX 1.3 supports frame buffer configurations */ #ifdef GLX_VERSION_1_3 + glx_fbconfigs_available = TRUE; + /* Grab the FBConfigs */ ret = NvCtrlGetVoidAttribute(ctrl_target, NV_CTRL_ATTR_GLX_FBCONFIG_ATTRIBS, (void *)(&fbconfig_attribs)); - if ( ret != NvCtrlSuccess ) { - err_str = "Failed to query list of GLX frame buffer configurations."; - goto fail; - } - - /* Count the number of fbconfigs */ - if ( fbconfig_attribs ) { - for (num_fbconfigs = 0; - fbconfig_attribs[num_fbconfigs].fbconfig_id != 0; - num_fbconfigs++); - } - if ( ! num_fbconfigs ) { - err_str = "No frame buffer configurations found."; - - goto fail; + if (ret != NvCtrlSuccess) { + nv_warning_msg("Failed to query list of GLX frame buffer " + "configurations."); + glx_fbconfigs_available = FALSE; + } else { + /* Count the number of fbconfigs */ + if (fbconfig_attribs) { + for (num_fbconfigs = 0; + fbconfig_attribs[num_fbconfigs].fbconfig_id != 0; + num_fbconfigs++); + } + if (num_fbconfigs == 0) { + nv_warning_msg("No frame buffer configurations found."); + glx_fbconfigs_available = FALSE; + } } - show_fbc_button = gtk_toggle_button_new_with_label( - "Show GLX Frame Buffer Configurations"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_fbc_button), FALSE); - ctk_config_set_tooltip(ctk_config, show_fbc_button, __show_fbc_help); - g_signal_connect(G_OBJECT(show_fbc_button), - "clicked", G_CALLBACK(show_fbc_toggled), - (gpointer) ctk_glx); - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(window), "GLX Frame Buffer Configurations"); - gtk_container_set_border_width(GTK_CONTAINER(window), CTK_WINDOW_PAD); - gtk_window_set_default_size(GTK_WINDOW(window), 400, 200); - g_signal_connect(G_OBJECT(window), "destroy-event", - G_CALLBACK(fbc_window_destroy), - (gpointer) ctk_glx); - g_signal_connect(G_OBJECT(window), "delete-event", - G_CALLBACK(fbc_window_destroy), - (gpointer) ctk_glx); - - ctk_glx->fbc_window = window; - ctk_glx->show_fbc_button = show_fbc_button; - - hbox = gtk_hbox_new(FALSE, 0); - vbox = gtk_vbox_new(FALSE, 10); - - - /* Create fbconfig window */ - fbc_view = gtk_tree_view_new(); - - /* Create columns and column headers with tooltips */ - for ( i = 0; i < NUM_FBCONFIG_ATTRIBS; i++ ) { - GtkWidget *label; - GtkCellRenderer *renderer; - GtkTreeViewColumn *col; - - renderer = gtk_cell_renderer_text_new(); - ctk_cell_renderer_set_alignment(renderer, 0.5, 0.5); - - col = gtk_tree_view_column_new_with_attributes(fbconfig_titles[i], - renderer, - "text", i, - NULL); - - label = gtk_label_new(fbconfig_titles[i]); - ctk_config_set_tooltip(ctk_config, label, fbconfig_tooltips[i]); - gtk_widget_show(label); - - gtk_tree_view_column_set_widget(col, label); - gtk_tree_view_insert_column(GTK_TREE_VIEW(fbc_view), col, -1); - } + if (glx_fbconfigs_available) { + show_fbc_button = gtk_toggle_button_new_with_label( + "Show GLX Frame Buffer Configurations"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_fbc_button), FALSE); + ctk_config_set_tooltip(ctk_config, show_fbc_button, __show_fbc_help); + g_signal_connect(G_OBJECT(show_fbc_button), + "clicked", G_CALLBACK(show_fbc_toggled), + (gpointer) ctk_glx); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), "GLX Frame Buffer " + "Configurations"); + gtk_container_set_border_width(GTK_CONTAINER(window), CTK_WINDOW_PAD); + gtk_window_set_default_size(GTK_WINDOW(window), 400, 200); + g_signal_connect(G_OBJECT(window), "destroy-event", + G_CALLBACK(fbc_window_destroy), + (gpointer) ctk_glx); + g_signal_connect(G_OBJECT(window), "delete-event", + G_CALLBACK(fbc_window_destroy), + (gpointer) ctk_glx); + + ctk_glx->fbc_window = window; + ctk_glx->show_fbc_button = show_fbc_button; + + hbox = gtk_hbox_new(FALSE, 0); + vbox = gtk_vbox_new(FALSE, 10); + + + /* Create fbconfig window */ + fbc_view = gtk_tree_view_new(); + + /* Create columns and column headers with tooltips */ + for ( i = 0; i < NUM_FBCONFIG_ATTRIBS; i++ ) { + GtkWidget *label; + GtkCellRenderer *renderer; + GtkTreeViewColumn *col; + + renderer = gtk_cell_renderer_text_new(); + ctk_cell_renderer_set_alignment(renderer, 0.5, 0.5); + + col = gtk_tree_view_column_new_with_attributes(fbconfig_titles[i], + renderer, + "text", i, + NULL); + + label = gtk_label_new(fbconfig_titles[i]); + ctk_config_set_tooltip(ctk_config, label, fbconfig_tooltips[i]); + gtk_widget_show(label); + + gtk_tree_view_column_set_widget(col, label); + gtk_tree_view_insert_column(GTK_TREE_VIEW(fbc_view), col, -1); + } - /* Create data model and add view to the window */ - fbc_model = create_fbconfig_model(fbconfig_attribs); - free(fbconfig_attribs); + /* Create data model and add view to the window */ + fbc_model = create_fbconfig_model(fbconfig_attribs); + free(fbconfig_attribs); - gtk_tree_view_set_model(GTK_TREE_VIEW(fbc_view), fbc_model); - g_object_unref(fbc_model); + gtk_tree_view_set_model(GTK_TREE_VIEW(fbc_view), fbc_model); + g_object_unref(fbc_model); - fbc_scroll_win = gtk_scrolled_window_new(NULL, NULL); + fbc_scroll_win = gtk_scrolled_window_new(NULL, NULL); - gtk_container_add (GTK_CONTAINER (fbc_scroll_win), fbc_view); - gtk_container_add (GTK_CONTAINER (window), fbc_scroll_win); + gtk_container_add (GTK_CONTAINER (fbc_scroll_win), fbc_view); + gtk_container_add (GTK_CONTAINER (window), fbc_scroll_win); + } else { + free(fbconfig_attribs); + } - /* Create main page layout */ - vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), show_fbc_button, FALSE, FALSE, 0); - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); +#endif /* GLX_VERSION_1_3 */ - hseparator = gtk_hseparator_new(); - vbox = gtk_vbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), scrollWin, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hseparator, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(ctk_glx), vbox, TRUE, TRUE, 0); + /* EGL Configurations */ + egl_fbconfigs_available = TRUE; + ret = NvCtrlGetVoidAttribute(ctrl_target, + NV_CTRL_ATTR_EGL_CONFIG_ATTRIBS, + (void *)(&egl_fbconfig_attribs)); + if (ret != NvCtrlSuccess) { + nv_warning_msg("Failed to query list of EGL configurations."); + egl_fbconfigs_available = FALSE; + } else { + num_fbconfigs = 0; + if (egl_fbconfig_attribs) { + while (egl_fbconfig_attribs[num_fbconfigs].config_id != 0) { + num_fbconfigs++; + } + } -#endif /* GLX_VERSION_1_3 */ + if (egl_fbconfigs_available && num_fbconfigs == 0) { + nv_warning_msg("No EGL frame buffer configurations found."); + egl_fbconfigs_available = FALSE; + } + } + if (egl_fbconfigs_available) { + + show_egl_fbc_button = gtk_toggle_button_new_with_label( + "Show EGL Frame Buffer Configurations"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_egl_fbc_button), + FALSE); + ctk_config_set_tooltip(ctk_config, show_egl_fbc_button, + __show_egl_fbc_help); + g_signal_connect(G_OBJECT(show_egl_fbc_button), + "clicked", G_CALLBACK(show_egl_fbc_toggled), + (gpointer) ctk_glx); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), + "EGL Frame Buffer Configurations"); + gtk_container_set_border_width(GTK_CONTAINER(window), CTK_WINDOW_PAD); + gtk_window_set_default_size(GTK_WINDOW(window), 400, 200); + g_signal_connect(G_OBJECT(window), "destroy-event", + G_CALLBACK(egl_fbc_window_destroy), + (gpointer) ctk_glx); + g_signal_connect(G_OBJECT(window), "delete-event", + G_CALLBACK(egl_fbc_window_destroy), + (gpointer) ctk_glx); + + ctk_glx->egl_fbc_window = window; + ctk_glx->show_egl_fbc_button = show_egl_fbc_button; + + hbox = gtk_hbox_new(FALSE, 0); + vbox = gtk_vbox_new(FALSE, 10); + + + /* Create fbconfig window */ + egl_fbc_view = gtk_tree_view_new(); + + /* Create columns and column headers with tooltips */ + for ( i = 0; i < NUM_EGL_FBCONFIG_ATTRIBS; i++ ) { + GtkWidget *label; + GtkCellRenderer *renderer; + GtkTreeViewColumn *col; + + renderer = gtk_cell_renderer_text_new(); + ctk_cell_renderer_set_alignment(renderer, 0.5, 0.5); + + col = + gtk_tree_view_column_new_with_attributes(egl_fbconfig_titles[i], + renderer, + "text", i, + NULL); + + label = gtk_label_new(egl_fbconfig_titles[i]); + ctk_config_set_tooltip(ctk_config, label, egl_fbconfig_tooltips[i]); + gtk_widget_show(label); + + gtk_tree_view_column_set_widget(col, label); + gtk_tree_view_insert_column(GTK_TREE_VIEW(egl_fbc_view), col, -1); + } - gtk_widget_show_all(GTK_WIDGET(object)); + /* Create data model and add view to the window */ + egl_fbc_model = create_egl_fbconfig_model(egl_fbconfig_attribs); + free(egl_fbconfig_attribs); - return GTK_WIDGET(object); + gtk_tree_view_set_model(GTK_TREE_VIEW(egl_fbc_view), egl_fbc_model); + g_object_unref(egl_fbc_model); + egl_fbc_scroll_win = gtk_scrolled_window_new(NULL, NULL); - /* Failure (no GLX) */ - fail: - if (err_str) { - label = gtk_label_new(err_str); - gtk_label_set_selectable(GTK_LABEL(label), TRUE); + gtk_container_add(GTK_CONTAINER(egl_fbc_scroll_win), egl_fbc_view); + gtk_container_add(GTK_CONTAINER(window), egl_fbc_scroll_win); - gtk_container_add(GTK_CONTAINER(ctk_glx), label); + } else { + free(egl_fbconfig_attribs); } - /* Free memory that may have been allocated */ - free(fbconfig_attribs); + /* Set main page layout */ + gtk_box_pack_start(GTK_BOX(ctk_glx), event, TRUE, TRUE, 0); gtk_widget_show_all(GTK_WIDGET(object)); return GTK_WIDGET(object); @@ -574,9 +916,8 @@ GtkWidget* ctk_glx_new(CtrlTarget *ctrl_target, - -/* Probes for GLX information and sets up the results - * in the GLX widget. +/* Probes for Graphics information and sets up the results + * in the Graphics notebook widget. */ void ctk_glx_probe_info(GtkWidget *widget) { @@ -597,14 +938,17 @@ void ctk_glx_probe_info(GtkWidget *widget) char *opengl_renderer = NULL; char *opengl_version = NULL; char *opengl_extensions = NULL; + char *egl_vendor = NULL; + char *egl_version = NULL; + char *egl_extensions = NULL; char *ptr; - GtkWidget *hseparator; - GtkWidget *hbox, *hbox2; GtkWidget *vbox, *vbox2; - GtkWidget *label; GtkWidget *table; - + GtkWidget *notebook = gtk_notebook_new(); + GtkWidget *notebook_label; + GtkWidget *scroll_win; + int notebook_padding = 8; /* Make sure the widget was initialized and that glx information * has not yet been initialized. @@ -675,6 +1019,22 @@ void ctk_glx_probe_info(GtkWidget *widget) if ( ret != NvCtrlSuccess ) { goto done; } + /* Get EGL information */ + ret = NvCtrlGetStringAttribute(ctrl_target, + NV_CTRL_STRING_EGL_VENDOR, + &egl_vendor); + if ( ret != NvCtrlSuccess ) { goto done; } + ret = NvCtrlGetStringAttribute(ctrl_target, + NV_CTRL_STRING_EGL_VERSION, + &egl_version); + if ( ret != NvCtrlSuccess ) { goto done; } + ret = NvCtrlGetStringAttribute(ctrl_target, + NV_CTRL_STRING_EGL_EXTENSIONS, + &egl_extensions); + if ( ret != NvCtrlSuccess ) { goto done; } + + + /* Modify extension lists so they show only one name per line */ for ( ptr = glx_extensions; ptr != NULL && ptr[0] != '\0'; ptr++ ) { if ( ptr[0] == ' ' ) ptr[0] = '\n'; @@ -688,21 +1048,23 @@ void ctk_glx_probe_info(GtkWidget *widget) for ( ptr = opengl_extensions; ptr != NULL && ptr[0] != '\0'; ptr++ ) { if ( ptr[0] == ' ' ) ptr[0] = '\n'; } + for ( ptr = egl_extensions; ptr != NULL && ptr[0] != '\0'; ptr++ ) { + if ( ptr[0] == ' ' ) ptr[0] = '\n'; + } + + vbox = ctk_glx->glxinfo_vpane; + gtk_widget_set_size_request(notebook, -1, 50); + gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); /* Add (Shared) GLX information to widget */ - vbox = ctk_glx->glxinfo_vpane; - vbox2 = gtk_vbox_new(FALSE, 0); - hbox = gtk_hbox_new(FALSE, 0); - label = gtk_label_new("GLX Information"); - hseparator = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 2); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); - - hbox = gtk_hbox_new(FALSE, 0); - hbox2 = gtk_hbox_new(FALSE, 0); + notebook_label = gtk_label_new("GLX"); + vbox2 = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox2), notebook_padding); + scroll_win = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + table = gtk_table_new(2, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 3); gtk_table_set_col_spacings(GTK_TABLE(table), 15); @@ -712,21 +1074,30 @@ void ctk_glx_probe_info(GtkWidget *widget) add_table_row(table, 1, 0, 0, "GLX Extensions:", 0, 0, glx_extensions); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); + if (ctk_glx->show_fbc_button) { + GtkWidget *button_box = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox2), button_box, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(button_box), ctk_glx->show_fbc_button, + FALSE, FALSE, 0); + } + gtk_box_pack_start(GTK_BOX(vbox2), table, FALSE, FALSE, 0); - /* Add server GLX information to widget */ - hbox = gtk_hbox_new(FALSE, 0); - label = gtk_label_new("Server GLX Information"); - hseparator = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); + gtk_container_add(GTK_CONTAINER(scroll_win), vbox2); + + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scroll_win, + notebook_label); + gtk_widget_show(GTK_WIDGET(scroll_win)); + + + /* Add server GLX information to widget */ + notebook_label = gtk_label_new("Server GLX"); + vbox2 = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox2), notebook_padding); + scroll_win = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - hbox = gtk_hbox_new(FALSE, 0); - hbox2 = gtk_hbox_new(FALSE, 0); table = gtk_table_new(3, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 3); gtk_table_set_col_spacings(GTK_TABLE(table), 15); @@ -739,21 +1110,22 @@ void ctk_glx_probe_info(GtkWidget *widget) add_table_row(table, 2, 0, 0, "Extensions:", 0, 0, server_extensions); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); + + gtk_box_pack_start(GTK_BOX(vbox2), table, FALSE, FALSE, 0); + + gtk_container_add(GTK_CONTAINER(scroll_win), vbox2); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scroll_win, + notebook_label); /* Add client GLX information to widget */ - hbox = gtk_hbox_new(FALSE, 0); - label = gtk_label_new("Client GLX Information"); - hseparator = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); - - hbox = gtk_hbox_new(FALSE, 0); - hbox2 = gtk_hbox_new(FALSE, 0); + notebook_label = gtk_label_new("Client GLX"); + vbox2 = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox2), notebook_padding); + scroll_win = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + table = gtk_table_new(3, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 3); gtk_table_set_col_spacings(GTK_TABLE(table), 15); @@ -766,23 +1138,23 @@ void ctk_glx_probe_info(GtkWidget *widget) add_table_row(table, 2, 0, 0, "Extensions:", 0, 0, client_extensions); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); + + gtk_box_pack_start(GTK_BOX(vbox2), table, FALSE, FALSE, 0); + + gtk_container_add(GTK_CONTAINER(scroll_win), vbox2); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scroll_win, + notebook_label); /* Add OpenGL information to widget */ - hbox = gtk_hbox_new(FALSE, 0); - label = gtk_label_new("OpenGL Information"); - hseparator = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), hseparator, TRUE, TRUE, 5); - - hbox = gtk_hbox_new(FALSE, 0); - hbox2 = gtk_hbox_new(FALSE, 0); - table = gtk_table_new(4, 2, FALSE); + notebook_label = gtk_label_new("OpenGL"); vbox2 = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox2), notebook_padding); + scroll_win = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + + table = gtk_table_new(4, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 3); gtk_table_set_col_spacings(GTK_TABLE(table), 15); add_table_row(table, 0, @@ -797,10 +1169,46 @@ void ctk_glx_probe_info(GtkWidget *widget) add_table_row(table, 3, 0, 0, "Extensions:", 0, 0, opengl_extensions); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), hbox2, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 2); + + gtk_box_pack_start(GTK_BOX(vbox2), table, FALSE, FALSE, 0); + + gtk_container_add(GTK_CONTAINER(scroll_win), vbox2); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scroll_win, + notebook_label); + + + /* Add EGL information to widget */ + notebook_label = gtk_label_new("EGL"); + vbox2 = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox2), notebook_padding); + scroll_win = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + + table = gtk_table_new(3, 2, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(table), 3); + gtk_table_set_col_spacings(GTK_TABLE(table), 15); + add_table_row(table, 0, + 0, 0, "Vendor:", + 0, 0, egl_vendor); + add_table_row(table, 1, + 0, 0, "Version:", + 0, 0, egl_version); + add_table_row(table, 2, + 0, 0, "Extensions:", + 0, 0, egl_extensions); + + if (ctk_glx->show_egl_fbc_button) { + GtkWidget *button_box = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox2), button_box, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(button_box), ctk_glx->show_egl_fbc_button, + FALSE, FALSE, 0); + } + gtk_box_pack_start(GTK_BOX(vbox2), table, FALSE, FALSE, 0); + + gtk_container_add(GTK_CONTAINER(scroll_win), vbox2); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scroll_win, + notebook_label); /* Show the information */ @@ -824,6 +1232,9 @@ void ctk_glx_probe_info(GtkWidget *widget) free(opengl_renderer); free(opengl_version); free(opengl_extensions); + free(egl_vendor); + free(egl_version); + free(egl_extensions); } /* ctk_glx_probe_info() */ @@ -839,13 +1250,16 @@ GtkTextBuffer *ctk_glx_create_help(GtkTextTagTable *table, gtk_text_buffer_get_iter_at_offset(b, &i, 0); - ctk_help_title(b, &i, "GLX Help"); + ctk_help_title(b, &i, "Graphics Information Help"); ctk_help_para(b, &i, "This page in the NVIDIA X Server Control Panel describes " - "information about the OpenGL extension to the X Server " - "(GLX)." + "information about graphics libraries available on this X " + "screen." ); + ctk_help_heading(b, &i, "Show GLX Frame Buffer Configurations"); + ctk_help_para(b, &i, "%s", __show_fbc_help); + ctk_help_heading(b, &i, "Direct Rendering"); ctk_help_para(b, &i, "This will tell you if direct rendering is available. If " @@ -913,11 +1327,12 @@ GtkTextBuffer *ctk_glx_create_help(GtkTextTagTable *table, "by this driver." ); - ctk_help_heading(b, &i, "Show GLX Frame Buffer Configurations"); - ctk_help_para(b, &i, "%s", __show_fbc_help); + ctk_help_heading(b, &i, "Show EGL Frame Buffer Configurations"); + ctk_help_para(b, &i, "%s", __show_egl_fbc_help); + ctk_help_heading(b, &i, "GLX Frame Buffer Configurations"); - ctk_help_para(b, &i, "This table lists the supported frame buffer " + ctk_help_para(b, &i, "This table lists the supported GLX frame buffer " "configurations for the display."); ctk_help_para(b, &i, "\t%s\n\n" @@ -990,8 +1405,84 @@ GtkTextBuffer *ctk_glx_create_help(GtkTextTagTable *table, __tra_help, __tri_help ); + ctk_help_heading(b, &i, "EGL Frame Buffer Configurations"); + ctk_help_para(b, &i, "This table lists the supported EGL frame buffer " + "configurations for the display."); + ctk_help_para(b, &i, + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n" + "\t%s\n\n", + + __egl_id_help, + __egl_vid_help, + __egl_nvt_help, + __egl_bfs_help, + __egl_lvl_help, + __egl_cbt_help, + __egl_rs_help, + __egl_gs_help, + + __egl_bs_help, + __egl_as_help, + __egl_ams_help, + __egl_lum_help, + __egl_dpt_help, + __egl_stn_help, + __egl_bt_help, + __egl_bta_help, + + __egl_cfm_help, + __egl_spb_help, + __egl_smp_help, + __egl_cav_help, + __egl_pbw_help, + __egl_pbh_help, + __egl_pbp_help, + __egl_six_help, + + __egl_sin_help, + __egl_nrd_help, + __egl_rdt_help, + __egl_sur_help, + __egl_tpt_help, + __egl_trv_help, + __egl_tgv_help, + __egl_tbv_help + ); - ctk_help_finish(b); + ctk_help_finish(b); return b; diff --git a/src/gtk+-2.x/ctkglx.h b/src/gtk+-2.x/ctkglx.h index fe0d4e5..cdf26a0 100644 --- a/src/gtk+-2.x/ctkglx.h +++ b/src/gtk+-2.x/ctkglx.h @@ -56,7 +56,9 @@ struct _CtkGLX GtkWidget *glxinfo_vpane; Bool glxinfo_initialized; GtkWidget *show_fbc_button; + GtkWidget *show_egl_fbc_button; GtkWidget *fbc_window; + GtkWidget *egl_fbc_window; }; struct _CtkGLXClass diff --git a/src/gtk+-2.x/ctkwindow.c b/src/gtk+-2.x/ctkwindow.c index da06ddd..85cbe98 100644 --- a/src/gtk+-2.x/ctkwindow.c +++ b/src/gtk+-2.x/ctkwindow.c @@ -730,13 +730,13 @@ GtkWidget *ctk_window_new(ParsedAttribute *p, ConfigProperties *conf, } - /* GLX Information */ + /* Graphics Information */ child = ctk_glx_new(screen_target, ctk_config, ctk_event); if (child) { help = ctk_glx_create_help(tag_table, CTK_GLX(child)); add_page(child, help, ctk_window, &iter, NULL, - "OpenGL/GLX Information", NULL, ctk_glx_probe_info, NULL); + "Graphics Information", NULL, ctk_glx_probe_info, NULL); } diff --git a/src/image_data/glx.png b/src/image_data/glx.png Binary files differdeleted file mode 100644 index a2df4db..0000000 --- a/src/image_data/glx.png +++ /dev/null diff --git a/src/image_data/graphics.png b/src/image_data/graphics.png Binary files differnew file mode 100644 index 0000000..ef05aa2 --- /dev/null +++ b/src/image_data/graphics.png diff --git a/src/image_data/vdpau.png b/src/image_data/vdpau.png Binary files differindex e576e1f..f7f8e07 100644 --- a/src/image_data/vdpau.png +++ b/src/image_data/vdpau.png diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributes.c b/src/libXNVCtrlAttributes/NvCtrlAttributes.c index 4216b11..c3bf158 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributes.c +++ b/src/libXNVCtrlAttributes/NvCtrlAttributes.c @@ -237,6 +237,15 @@ NvCtrlAttributeHandle *NvCtrlAttributeInit(CtrlSystem *system, if (subsystems & NV_CTRL_ATTRIBUTES_GLX_SUBSYSTEM) { h->glx = NvCtrlInitGlxAttributes(h); } + + /* + * initialize the EGL extension and attributes; it is OK if + * this fails + */ + + if (subsystems & NV_CTRL_ATTRIBUTES_EGL_SUBSYSTEM) { + h->egl = NvCtrlInitEglAttributes(h); + } } /* X Screen target type attribute subsystems */ /* @@ -871,11 +880,19 @@ ReturnStatus NvCtrlGetVoidDisplayAttribute(const CtrlTarget *ctrl_target, } if ( attr >= NV_CTRL_ATTR_GLX_BASE && - attr >= NV_CTRL_ATTR_GLX_LAST_ATTRIBUTE ) { + attr <= NV_CTRL_ATTR_GLX_LAST_ATTRIBUTE ) { if ( !(h->glx) ) return NvCtrlMissingExtension; return NvCtrlGlxGetVoidAttribute(h, display_mask, attr, ptr); } + if ( attr >= NV_CTRL_ATTR_EGL_BASE && + attr <= NV_CTRL_ATTR_EGL_LAST_ATTRIBUTE ) { + if (!(h->egl)) { + return NvCtrlMissingExtension; + } + return NvCtrlEglGetVoidAttribute(h, display_mask, attr, ptr); + } + return NvCtrlNoAttribute; } /* NvCtrlGetVoidDisplayAttribute() */ @@ -1092,6 +1109,12 @@ ReturnStatus NvCtrlGetStringDisplayAttribute(const CtrlTarget *ctrl_target, return NvCtrlGlxGetStringAttribute(h, display_mask, attr, ptr); } + if ((attr >= NV_CTRL_STRING_EGL_BASE) && + (attr <= NV_CTRL_STRING_EGL_LAST_ATTRIBUTE)) { + if (!h->egl) return NvCtrlMissingExtension; + return NvCtrlEglGetStringAttribute(h, display_mask, attr, ptr); + } + if ((attr >= NV_CTRL_STRING_XRANDR_BASE) && (attr <= NV_CTRL_STRING_XRANDR_LAST_ATTRIBUTE)) { if (!h->xrandr) return NvCtrlMissingExtension; @@ -1267,6 +1290,9 @@ void NvCtrlAttributeClose(NvCtrlAttributeHandle *handle) if ( h->glx ) { NvCtrlGlxAttributesClose(h); } + if ( h->egl ) { + NvCtrlEglAttributesClose(h); + } if ( h->xrandr ) { NvCtrlXrandrAttributesClose(h); } diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributes.h b/src/libXNVCtrlAttributes/NvCtrlAttributes.h index 434aee8..636d7e2 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributes.h +++ b/src/libXNVCtrlAttributes/NvCtrlAttributes.h @@ -246,10 +246,18 @@ typedef enum { #define NV_CTRL_ATTR_GLX_LAST_ATTRIBUTE \ (NV_CTRL_ATTR_GLX_FBCONFIG_ATTRIBS) +/* EGL */ + +#define NV_CTRL_ATTR_EGL_BASE (NV_CTRL_ATTR_GLX_LAST_ATTRIBUTE + 1) + +#define NV_CTRL_ATTR_EGL_CONFIG_ATTRIBS (NV_CTRL_ATTR_EGL_BASE + 0) + +#define NV_CTRL_ATTR_EGL_LAST_ATTRIBUTE (NV_CTRL_ATTR_EGL_CONFIG_ATTRIBS) + /* RandR */ #define NV_CTRL_ATTR_RANDR_BASE \ - (NV_CTRL_ATTR_GLX_LAST_ATTRIBUTE + 1) + (NV_CTRL_ATTR_EGL_LAST_ATTRIBUTE + 1) #define NV_CTRL_ATTR_RANDR_GAMMA_AVAILABLE (NV_CTRL_ATTR_RANDR_BASE + 0) @@ -344,6 +352,44 @@ typedef struct GLXFBConfigAttrRec { } GLXFBConfigAttr; +typedef struct EGLConfigAttrRec { + + int config_id; + int native_visual_id; + + int alpha_size; + int alpha_mask_size; + int bind_to_texture_rgb; + int bind_to_texture_rgba; + int blue_size; + int buffer_size; + int color_buffer_type; + int config_caveat; + int conformant; + int depth_size; + int green_size; + int level; + int luminance_size; + int max_pbuffer_width; + int max_pbuffer_height; + int max_pbuffer_pixels; + int max_swap_interval; + int min_swap_interval; + int native_renderable; + int native_visual_type; + int red_size; + int renderable_type; + int sample_buffers; + int samples; + int stencil_size; + int surface_type; + int transparent_type; + int transparent_red_value; + int transparent_green_value; + int transparent_blue_value; + +} EGLConfigAttr; + /* * Used to pack CtrlAttributePerms.valid_targets */ @@ -481,11 +527,25 @@ typedef struct { #define NV_CTRL_STRING_GLX_LAST_ATTRIBUTE \ (NV_CTRL_STRING_GLX_OPENGL_EXTENSIONS) + +/* + * Additional EGL string attributes for NvCtrlGetStringDisplayAttribute(); + */ + +#define NV_CTRL_STRING_EGL_BASE (NV_CTRL_STRING_GLX_LAST_ATTRIBUTE + 1) + +#define NV_CTRL_STRING_EGL_VENDOR (NV_CTRL_STRING_EGL_BASE + 0) +#define NV_CTRL_STRING_EGL_VERSION (NV_CTRL_STRING_EGL_BASE + 1) +#define NV_CTRL_STRING_EGL_EXTENSIONS (NV_CTRL_STRING_EGL_BASE + 2) + +#define NV_CTRL_STRING_EGL_LAST_ATTRIBUTE (NV_CTRL_STRING_EGL_EXTENSIONS) + + /* * Additional XRANDR string attributes for NvCtrlGetStringDisplayAttribute(); */ -#define NV_CTRL_STRING_XRANDR_BASE (NV_CTRL_STRING_GLX_LAST_ATTRIBUTE + 1) +#define NV_CTRL_STRING_XRANDR_BASE (NV_CTRL_STRING_EGL_LAST_ATTRIBUTE + 1) #define NV_CTRL_STRING_XRANDR_VERSION (NV_CTRL_STRING_XRANDR_BASE) @@ -521,13 +581,15 @@ typedef struct { #define NV_CTRL_ATTRIBUTES_GLX_SUBSYSTEM 0x8 #define NV_CTRL_ATTRIBUTES_XRANDR_SUBSYSTEM 0x10 #define NV_CTRL_ATTRIBUTES_NVML_SUBSYSTEM 0x20 +#define NV_CTRL_ATTRIBUTES_EGL_SUBSYSTEM 0x40 #define NV_CTRL_ATTRIBUTES_ALL_SUBSYSTEMS \ (NV_CTRL_ATTRIBUTES_NV_CONTROL_SUBSYSTEM | \ NV_CTRL_ATTRIBUTES_XF86VIDMODE_SUBSYSTEM | \ NV_CTRL_ATTRIBUTES_XVIDEO_SUBSYSTEM | \ NV_CTRL_ATTRIBUTES_GLX_SUBSYSTEM | \ NV_CTRL_ATTRIBUTES_XRANDR_SUBSYSTEM | \ - NV_CTRL_ATTRIBUTES_NVML_SUBSYSTEM) + NV_CTRL_ATTRIBUTES_NVML_SUBSYSTEM | \ + NV_CTRL_ATTRIBUTES_EGL_SUBSYSTEM) diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesEgl.c b/src/libXNVCtrlAttributes/NvCtrlAttributesEgl.c new file mode 100644 index 0000000..0f7efe4 --- /dev/null +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesEgl.c @@ -0,0 +1,554 @@ +/* + * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix + * and Linux systems. + * + * Copyright (C) 2018 NVIDIA Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses>. + */ + +#include "NvCtrlAttributes.h" +#include "NvCtrlAttributesPrivate.h" + +#include "NVCtrlLib.h" + +#include "common-utils.h" +#include "msg.h" + +#include "parse.h" + +#include <X11/extensions/xf86vmode.h> +#include <X11/extensions/Xvlib.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <assert.h> + +#include <sys/utsname.h> + +#include <dlfcn.h> /* To dynamically load libEGL.so */ +#include <EGL/egl.h> + + +typedef struct __libEGLInfoRec { + + /* libEGL.so library handle */ + void *handle; + int ref_count; /* # users of the library */ + + /* EGL functions used */ + EGLBoolean (* eglInitialize) (EGLDisplay, + EGLint *, EGLint *); + EGLBoolean (* eglTerminate) (EGLDisplay); + EGLDisplay (* eglGetDisplay) (NativeDisplayType); + + const char * (* eglQueryString) (EGLDisplay, EGLint); + EGLBoolean (* eglGetConfigs) (EGLDisplay, EGLConfig, + EGLint, EGLint *); + EGLBoolean (* eglGetConfigAttrib) (EGLDisplay, EGLConfig, + EGLint, EGLint *); + +} __libEGLInfo; + +static __libEGLInfo *__libEGL = NULL; + + + +/**** + * + * Provides a way to communicate EGL settings. + * + * + * Currently available attributes: + * + * EGL -------------------------- + * + * egl_vendor_str - STR + * egl_version_str - STR + * egl_extensions - STR + * + * + * EGL Frame Buffer Information ---- + * + * fbconfigs_attrib - ARRAY of EGLConfigAttr + * + ****/ + + + +/****************************************************************************** + * + * Opens libEGL for usage + * + ****/ + +static Bool open_libegl(void) +{ + const char *error_str = NULL; + + + /* Initialize bookkeeping structure */ + if ( !__libEGL ) { + __libEGL = nvalloc(sizeof(__libEGLInfo)); + } + + + /* Library was already opened */ + if ( __libEGL->handle ) { + __libEGL->ref_count++; + return True; + } + + + /* We are the first to open the library */ + __libEGL->handle = dlopen("libEGL.so.1", RTLD_LAZY); + if ( !__libEGL->handle ) { + error_str = dlerror(); + goto fail; + } + + + /* Resolve EGL functions */ + __libEGL->eglInitialize = + NV_DLSYM(__libEGL->handle, "eglInitialize"); + if ((error_str = dlerror()) != NULL) goto fail; + + __libEGL->eglTerminate = + NV_DLSYM(__libEGL->handle, "eglTerminate"); + if ((error_str = dlerror()) != NULL) goto fail; + + __libEGL->eglGetDisplay = + NV_DLSYM(__libEGL->handle, "eglGetDisplay"); + if ((error_str = dlerror()) != NULL) goto fail; + + __libEGL->eglQueryString = + NV_DLSYM(__libEGL->handle, "eglQueryString"); + if ((error_str = dlerror()) != NULL) goto fail; + + __libEGL->eglGetConfigs = + NV_DLSYM(__libEGL->handle, "eglGetConfigs"); + if ((error_str = dlerror()) != NULL) goto fail; + + __libEGL->eglGetConfigAttrib = + NV_DLSYM(__libEGL->handle, "eglGetConfigAttrib"); + if ((error_str = dlerror()) != NULL) goto fail; + + + /* Up the ref count */ + __libEGL->ref_count++; + + return True; + + + /* Handle failures */ + fail: + if ( error_str ) { + nv_error_msg("libEGL setup error : %s\n", error_str); + } + if ( __libEGL ) { + if ( __libEGL->handle ) { + dlclose(__libEGL->handle); + __libEGL->handle = NULL; + } + free(__libEGL); + __libEGL = NULL; + } + return False; + +} /* open_libegl() */ + + + +/****************************************************************************** + * + * Closes libEGL - + * + ****/ + +static void close_libegl(void) +{ + if ( __libEGL && __libEGL->handle && __libEGL->ref_count ) { + __libEGL->ref_count--; + if ( __libEGL->ref_count == 0 ) { + dlclose(__libEGL->handle); + __libEGL->handle = NULL; + free(__libEGL); + __libEGL = NULL; + } + } +} /* close_libegl() */ + + + +/****************************************************************************** + * + * NvCtrlInitEglAttributes() + * + * Initializes the NvCtrlEglAttributes Extension by linking the libEGL.so.1 and + * resolving functions used to retrieve EGL information. + * + ****/ + +Bool NvCtrlInitEglAttributes (NvCtrlAttributePrivateHandle *h) +{ + int major, minor; + /* Check parameters */ + if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) { + return False; + } + + /* Open libEGL.so.1 */ + if ( !open_libegl() ) { + return False; + } + + h->egl_dpy = __libEGL->eglGetDisplay(h->dpy); + + if (!__libEGL->eglInitialize(h->egl_dpy, &major, &minor)) { + h->egl_dpy = NULL; + return False; + } + + return (h->egl_dpy != EGL_NO_DISPLAY); + +} /* NvCtrlInitEglAttributes() */ + + + +/****************************************************************************** + * + * NvCtrlEglAttributesClose() + * + * Frees and relinquishes any resource used by the NvCtrlEglAttributes + * extension. + * + ****/ + +void +NvCtrlEglAttributesClose (NvCtrlAttributePrivateHandle *h) +{ + if ( !h || !h->egl ) { + return; + } + + __libEGL->eglTerminate(h->egl_dpy); + + close_libegl(); + + h->egl_dpy = NULL; + h->egl = False; + +} /* NvCtrlEglAttributesClose() */ + + + +/****************************************************************************** + * + * get_configs() + * + * + * Returns an array of EGL Frame Buffer Configuration Attributes for the + * given Display/Screen. + * + ****/ + +static EGLConfigAttr *get_configs(const NvCtrlAttributePrivateHandle *h) +{ + EGLConfig *configs = NULL; + EGLConfigAttr *cas = NULL; + + int nconfigs; + int i; + EGLBoolean ret; /* Return value of eglGetConfigAttr */ + + + + assert(h->target_type == X_SCREEN_TARGET); + + + /* Get all fbconfigs for the display/screen */ + ret = (* (__libEGL->eglGetConfigs)) (h->egl_dpy, NULL, 0, &nconfigs); + if ( !ret ) { + goto fail; + } + + /* Allocate to hold the fbconfig attributes */ + configs = nvalloc((nconfigs + 1) * sizeof(EGLConfig)); + cas = nvalloc((nconfigs + 1) * sizeof(EGLConfigAttr)); + + ret = (* (__libEGL->eglGetConfigs))(h->egl_dpy, configs, nconfigs, + &nconfigs); + + + for (i = 0; i < nconfigs; i++) { + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_RED_SIZE, + &cas[i].red_size); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_BLUE_SIZE, + &cas[i].blue_size); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_GREEN_SIZE, + &cas[i].green_size); + if (!ret) goto fail; + + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_DEPTH_SIZE, + &cas[i].depth_size); + if (!ret) goto fail; + + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_MAX_PBUFFER_WIDTH, + &cas[i].max_pbuffer_width); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_MAX_PBUFFER_HEIGHT, + &cas[i].max_pbuffer_height); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_MAX_PBUFFER_PIXELS, + &cas[i].max_pbuffer_pixels); + if (!ret) goto fail; + + + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_ALPHA_SIZE, + &cas[i].alpha_size); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_ALPHA_MASK_SIZE, + &cas[i].alpha_mask_size); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_BIND_TO_TEXTURE_RGB, + &cas[i].bind_to_texture_rgb); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_BIND_TO_TEXTURE_RGBA, + &cas[i].bind_to_texture_rgba); + if (!ret) goto fail; + + + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_BUFFER_SIZE, + &cas[i].buffer_size); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_COLOR_BUFFER_TYPE, + &cas[i].color_buffer_type); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_CONFIG_CAVEAT, + &cas[i].config_caveat); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_CONFIG_ID, + &cas[i].config_id); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_CONFORMANT, + &cas[i].conformant); + if (!ret) goto fail; + + + + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_LEVEL, + &cas[i].level); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_LUMINANCE_SIZE, + &cas[i].luminance_size); + if (!ret) goto fail; + + + + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_MAX_SWAP_INTERVAL, + &cas[i].max_swap_interval); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_MIN_SWAP_INTERVAL, + &cas[i].min_swap_interval); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_NATIVE_RENDERABLE, + &cas[i].native_renderable); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_NATIVE_VISUAL_ID, + &cas[i].native_visual_id); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_NATIVE_VISUAL_TYPE, + &cas[i].native_visual_type); + if (!ret) goto fail; + + + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_RENDERABLE_TYPE, + &cas[i].renderable_type); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_SAMPLE_BUFFERS, + &cas[i].sample_buffers); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_SAMPLES, + &cas[i].samples); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_STENCIL_SIZE, + &cas[i].stencil_size); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_SURFACE_TYPE, + &cas[i].surface_type); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_TRANSPARENT_TYPE, + &cas[i].transparent_type); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_TRANSPARENT_RED_VALUE, + &cas[i].transparent_red_value); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_TRANSPARENT_GREEN_VALUE, + &cas[i].transparent_green_value); + if (!ret) goto fail; + ret = __libEGL->eglGetConfigAttrib(h->egl_dpy, configs[i], + EGL_TRANSPARENT_BLUE_VALUE, + &cas[i].transparent_blue_value); + if (!ret) goto fail; + } + + free(configs); + return cas; + + + /* Handle failures */ + fail: + free(configs); + free(cas); + + return NULL; +} /* get_configs() */ + + + +/****************************************************************************** + * + * NvCtrlEglGetVoidAttribute() + * + * Retrieves various EGL attributes (other than strings and ints) + * + ****/ + +ReturnStatus NvCtrlEglGetVoidAttribute(const NvCtrlAttributePrivateHandle *h, + unsigned int display_mask, + int attr, void **ptr) +{ + EGLConfigAttr *config_attribs = NULL; + + + /* Validate */ + if ( !h || !h->dpy || h->target_type != X_SCREEN_TARGET ) { + return NvCtrlBadHandle; + } + if ( !h->egl || !__libEGL ) { + return NvCtrlMissingExtension; + } + if ( !ptr ) { + return NvCtrlBadArgument; + } + + + /* Fetch the right attribute */ + switch ( attr ) { + + case NV_CTRL_ATTR_EGL_CONFIG_ATTRIBS: + config_attribs = get_configs(h); + *ptr = config_attribs; + break; + + default: + return NvCtrlNoAttribute; + } /* Done fetching attribute */ + + + if ( *ptr == NULL ) { + return NvCtrlError; + } + return NvCtrlSuccess; + +} /* NvCtrlEglGetAttribute */ + + + + +/****************************************************************************** + * + * NvCtrlEglGetStringAttribute() + * + * Retrieves a particular EGL information string by calling the appropriate + * function. + */ + +ReturnStatus NvCtrlEglGetStringAttribute(const NvCtrlAttributePrivateHandle *h, + unsigned int display_mask, + int attr, char **ptr) +{ + const char *str = NULL; + + /* Validate */ + if ( !h || !h->egl_dpy || h->target_type != X_SCREEN_TARGET ) { + return NvCtrlBadHandle; + } + if ( !h->egl || !__libEGL ) { + return NvCtrlMissingExtension; + } + if ( !ptr ) { + return NvCtrlBadArgument; + } + + + /* Get the right string */ + switch (attr) { + case NV_CTRL_STRING_EGL_VENDOR: + str = __libEGL->eglQueryString(h->egl_dpy, EGL_VENDOR); + break; + + case NV_CTRL_STRING_EGL_VERSION: + str = __libEGL->eglQueryString(h->egl_dpy, EGL_VERSION); + break; + + case NV_CTRL_STRING_EGL_EXTENSIONS: + str = __libEGL->eglQueryString(h->egl_dpy, EGL_EXTENSIONS); + break; + + default: + return NvCtrlNoAttribute; + } /* Done - Fetching corresponding string attribute */ + + + /* Copy the string and return it */ + if ( !str || (*ptr = strdup(str)) == NULL ) { + return NvCtrlError; + } + + return NvCtrlSuccess; + +} /* NvCtrlEglGetStringAttribute() */ diff --git a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h index 2a13861..407fc41 100644 --- a/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h +++ b/src/libXNVCtrlAttributes/NvCtrlAttributesPrivate.h @@ -23,6 +23,7 @@ #include "NvCtrlAttributes.h" #include "NVCtrl.h" #include <GL/glx.h> /* GLX #defines */ +#include <EGL/egl.h> #include <X11/extensions/Xrandr.h> /* Xrandr */ #include <nvml.h> @@ -201,6 +202,8 @@ struct __NvCtrlAttributePrivateHandle { NvCtrlVidModeAttributes *vm; /* XF86VidMode extension info */ NvCtrlXvAttributes *xv; /* XVideo info */ Bool glx; /* GLX extension available */ + Bool egl; /* EGL extension available */ + EGLDisplay egl_dpy; NvCtrlXrandrAttributes *xrandr; /* XRandR extension info */ /* NVML-specific attributes */ @@ -283,6 +286,17 @@ ReturnStatus NvCtrlGlxGetVoidAttribute(const NvCtrlAttributePrivateHandle *, ReturnStatus NvCtrlGlxGetStringAttribute(const NvCtrlAttributePrivateHandle *, unsigned int, int, char **); +/* EGL extension attribute functions */ + +Bool NvCtrlInitEglAttributes(NvCtrlAttributePrivateHandle *); + +void NvCtrlEglAttributesClose(NvCtrlAttributePrivateHandle *); + +ReturnStatus NvCtrlEglGetVoidAttribute(const NvCtrlAttributePrivateHandle *, + unsigned int, int, void **); + +ReturnStatus NvCtrlEglGetStringAttribute(const NvCtrlAttributePrivateHandle *, + unsigned int, int, char **); /* XRandR extension attribute functions */ diff --git a/src/option-table.h b/src/option-table.h index e7fd236..53a9a08 100644 --- a/src/option-table.h +++ b/src/option-table.h @@ -156,6 +156,9 @@ static const NVGetoptOption __options[] = { { "glxinfo", 'g', NVGETOPT_HELP_ALWAYS, NULL, "Print GLX Information for the X display and exit." }, + { "eglinfo", 'E', NVGETOPT_HELP_ALWAYS, NULL, + "Print EGL Information for the X display and exit." }, + { "describe", 'e', NVGETOPT_STRING_ARGUMENT | NVGETOPT_HELP_ALWAYS, NULL, "Prints information about a particular attribute. Specify 'all' to " "list the descriptions of all attributes. Specify 'list' to list the " @@ -53,8 +53,8 @@ IMAGE_FILES += image_data/crt.png IMAGE_FILES += image_data/dfp.png IMAGE_FILES += image_data/display_config.png IMAGE_FILES += image_data/framelock.png -IMAGE_FILES += image_data/glx.png IMAGE_FILES += image_data/gpu.png +IMAGE_FILES += image_data/graphics.png IMAGE_FILES += image_data/gvi.png IMAGE_FILES += image_data/help.png IMAGE_FILES += image_data/led_green.png @@ -94,6 +94,7 @@ LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesNvControl.c LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesVidMode.c LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesXv.c LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesGlx.c +LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesEgl.c LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesXrandr.c LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesUtils.c LIB_XNVCTRL_ATTRIBUTES_SRC += libXNVCtrlAttributes/NvCtrlAttributesNvml.c |