Commit 8f1f9115 authored by Andreas Beckmann's avatar Andreas Beckmann

New upstream version 390.12

parents e1f25cc2 7bcf8ff2
NVIDIA_VERSION = 387.34 NVIDIA_VERSION = 390.12
...@@ -70,6 +70,7 @@ int main(int ac, char **av) ...@@ -70,6 +70,7 @@ int main(int ac, char **av)
Pixmap blendPixmap; Pixmap blendPixmap;
vertexDataRec warpData[6]; vertexDataRec warpData[6];
int nvDpyId; int nvDpyId;
Bool blendAfterWarp = False;
if (!xDpy) { if (!xDpy) {
fprintf (stderr, "Could not open X Display %s!\n", XDisplayName(NULL)); fprintf (stderr, "Could not open X Display %s!\n", XDisplayName(NULL));
...@@ -78,12 +79,16 @@ int main(int ac, char **av) ...@@ -78,12 +79,16 @@ int main(int ac, char **av)
screenId = XDefaultScreen(xDpy); screenId = XDefaultScreen(xDpy);
if (ac != 2) { if ((ac != 2) && (ac != 3)) {
fprintf (stderr, "Usage: ./nv-control-warpblend nvDpyId\n"); fprintf (stderr, "Usage: ./nv-control-warpblend nvDpyId [--blend-after-warp]\n");
fprintf (stderr, "See 'nvidia-settings -q CurrentMetaMode' for currently connected DPYs.\n"); fprintf (stderr, "See 'nvidia-settings -q CurrentMetaMode' for currently connected DPYs.\n");
return 1; return 1;
} }
if (ac == 3) {
blendAfterWarp = (strcmp("--blend-after-warp", av[2]) == 0);
}
nvDpyId = atoi(av[1]); nvDpyId = atoi(av[1]);
// Start with two screen-aligned triangles, and warp them using the sample // Start with two screen-aligned triangles, and warp them using the sample
...@@ -166,7 +171,7 @@ int main(int ac, char **av) ...@@ -166,7 +171,7 @@ int main(int ac, char **av)
screenId, screenId,
nvDpyId, nvDpyId,
blendPixmap, blendPixmap,
False); blendAfterWarp);
return 0; return 0;
} }
NVIDIA_VERSION = 387.34 NVIDIA_VERSION = 390.12
/*
* nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
* and Linux systems.
*
* Copyright (C) 2017 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 "ctkutils.h"
#include "ctkglstereo.h"
#ifdef CTK_GTK3
#include <GL/gl.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "right.png.h"
#include "left.png.h"
#include "nvlogo.png.h"
#include "matrix_utils.h"
#include "opengl_loading.h"
#include "ctkglwidget.h"
#endif
#ifdef CTK_GTK3
const unsigned int animateDiv = 1000;
static void animate(StereoAppData *appData, int eye)
{
float x;
int op;
float delta = 0.2;
GLfloat tm[16]; // Temporary matrix
GLfloat *mvp; // Model-View-Projection matrix
mvp = appData->cube->mvp;
if (eye == GL_LEFT) {
op = 1;
} else {
op = -1;
}
x = 2 * M_PI / animateDiv * appData->animationCounter;
genIdentityMatrix(mvp);
genRotateMatrixX(M_PI / 4, tm);
matrixMult(mvp, tm);
genRotateMatrixZ(M_PI / 4, tm);
matrixMult(mvp, tm);
// Apply the calculated rotation for this
// frame along axis X and Y to generate the
// animated effect
genRotateMatrixX(x, tm);
matrixMult(mvp, tm);
genRotateMatrixY(x, tm);
matrixMult(mvp, tm);
// Translates depending on eye
// and locates the object away from zero in the z-axis so
// that is viewable in the fov we define in the next step.
genTranslateMatrix(op * delta, 0, -1.5, tm);
matrixMult(mvp, tm);
genPerspectiveMatrix(M_PI / 2 , 1, 0.5, 5, tm);
matrixMult(mvp, tm);
}
static void produceFrameStereoTest(void *_appData)
{
StereoAppData *appData = _appData;
dGL.glDrawBuffer(GL_BACK_LEFT);
dGL.glClearColor(206.0/255, 206.0/255, 206.0/255, 1);
dGL.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
animate(appData, GL_LEFT);
drawModel(appData->cube);
drawModel(appData->labelLeft);
dGL.glDrawBuffer(GL_BACK_RIGHT);
dGL.glClearColor(206.0/255, 206.0/255, 206.0/255, 1);
dGL.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
animate(appData, GL_RIGHT);
drawModel(appData->cube);
drawModel(appData->labelRight);
appData->animationCounter++;
appData->animationCounter %= animateDiv;
}
static int verifyOpenglForStereo(void)
{
GLint majorVer = 0;
dGL.glGetIntegerv(GL_MAJOR_VERSION, &majorVer);
if (majorVer < 3) {
return -1;
}
return 0;
}
static int setupStereoTest(void *_appData)
{
StereoAppData *appData = _appData;
GdkPixbuf *nvidiaLogo = CTK_LOAD_PIXBUF(nvlogo);
GdkPixbuf *imageLeft = CTK_LOAD_PIXBUF(left);
GdkPixbuf *imageRight = CTK_LOAD_PIXBUF(right);
if (verifyOpenglForStereo() != 0) {
return -2;
}
dGL.glViewport(0, 0, 200, 200);
dGL.glEnable(GL_DEPTH_TEST);
dGL.glEnable(GL_BLEND);
dGL.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
dGL.glEnable(GL_TEXTURE_2D);
dGL.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
appData->animationCounter = 0;
appData->cube = cubeSetup(nvidiaLogo);
appData->labelLeft = labelSetup(-0.75, 0.90, // x and y
0.5, 0.20, // width and height
1, 0, 0, // rgb
imageLeft // GdkPixbuf *
);
appData->labelRight = labelSetup(0.70, 0.85, // x and y
0.6, 0.20, // width and height
0, 0, 1, // rgb
imageRight // GdkPixbuf *
);
g_object_unref(nvidiaLogo);
g_object_unref(imageLeft);
g_object_unref(imageRight);
if (appData->cube == NULL ||
appData->labelLeft == NULL ||
appData->labelRight == NULL) {
return -1;
}
return 0;
}
#endif
GtkWidget *ctk_glstereo_new(void)
{
#ifdef CTK_GTK3
GtkWidget *gtk_widget;
CtkGLWidget *ctk_glwidget;
int glx_attributes[] = {
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DOUBLEBUFFER, 1,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_ALPHA_SIZE, 1,
GLX_DEPTH_SIZE, 1,
GLX_STEREO, 1,
None
};
void *app_data;
app_data = malloc(sizeof(StereoAppData));
gtk_widget = ctk_glwidget_new(glx_attributes,
app_data,
setupStereoTest,
produceFrameStereoTest);
ctk_glwidget = CTK_GLWIDGET(gtk_widget);
if (ctk_glwidget) {
ctk_glwidget->timer_interval = 10; // In milliseconds
gtk_widget_set_size_request(GTK_WIDGET(ctk_glwidget), 200, 200);
return GTK_WIDGET(ctk_glwidget);
}
free(app_data);
#endif
return NULL;
}
/*
* nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
* and Linux systems.
*
* Copyright (C) 2017 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>.
*/
#ifndef __CTK_GLSTEREO_H__
#define __CTK_GLSTEREO_H__
#include "ctkutils.h"
#ifdef CTK_GTK3
#include "opengl_wrappers.h"
#endif
GtkWidget *ctk_glstereo_new(void);
#ifdef CTK_GTK3
typedef struct _StereoAppData StereoAppData;
struct _StereoAppData
{
OpenGLModelData *cube;
OpenGLModelData *labelLeft;
OpenGLModelData *labelRight;
unsigned int animationCounter;
};
#endif
#endif
/*
* nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
* and Linux systems.
*
* Copyright (C) 2017 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 "ctkutils.h"
#include "ctkglwidget.h"
#include <assert.h>
#include <gtk/gtk.h>
#include <GL/glx.h>
#include <gdk/gdkx.h>
#include <stdlib.h>
#include "opengl_loading.h"
GtkWidget *ctk_glwidget_new(int glx_attributes[],
void *app_data,
int (*app_setup_callback) (void *app_data),
void (*draw_frame_callback) (void *app_data) )
{
#ifdef CTK_GTK3
GObject *object;
CtkGLWidget *ctk_glwidget;
GLXFBConfig *fb_configs;
int n_elements;
int x_visual_id;
GdkDisplay *gdk_display;
Display *display;
GLXContext glx_context;
GdkVisual *gdk_visual;
gdk_display = gdk_display_get_default();
display = gdk_x11_display_get_xdisplay(gdk_display);
if (!loadGL()) {
return NULL;
}
fb_configs = dGL.glXChooseFBConfig(display,
DefaultScreen(display),
glx_attributes, &n_elements);
if (n_elements == 0) {
return NULL;
}
dGL.glXGetFBConfigAttrib(display,
fb_configs[0],
GLX_VISUAL_ID,
&x_visual_id);
gdk_visual = gdk_x11_screen_lookup_visual(gdk_screen_get_default(),
x_visual_id);
if (gdk_visual == NULL) {
XFree(fb_configs);
return NULL;
}
gdk_x11_display_error_trap_push(gdk_display);
glx_context = dGL.glXCreateNewContext(display,
fb_configs[0],
GLX_RGBA_TYPE,
NULL,
GL_TRUE);
if (gdk_x11_display_error_trap_pop(gdk_display) != 0) {
glx_context = NULL;
}
XFree(fb_configs);
if (glx_context == NULL) {
return NULL;
}
object = g_object_new(CTK_TYPE_GLWIDGET, NULL);
ctk_glwidget = CTK_GLWIDGET(object);
ctk_glwidget->app_data = app_data;
ctk_glwidget->app_setup_callback = app_setup_callback;
ctk_glwidget->draw_frame_callback = draw_frame_callback;
ctk_glwidget->gdk_display = gdk_display;
ctk_glwidget->gdk_window = NULL;
ctk_glwidget->display = display;
ctk_glwidget->is_error = FALSE;
ctk_glwidget->timer_interval = 100;
ctk_glwidget->glx_context = glx_context;
ctk_glwidget->gdk_visual = gdk_visual;
return GTK_WIDGET(ctk_glwidget);
#else
return NULL;
#endif
}
#ifdef CTK_GTK3
static void on_error(CtkGLWidget *ctk_glwidget);
static gboolean draw_frame_in_glwidget(gpointer p);
static void ctk_glwidget_realize(GtkWidget *gtk_widget)
{
CtkGLWidget *ctk_glwidget;
GdkWindowAttr gdk_attributes;
gint attributes_mask;
GtkAllocation allocation;
ctk_glwidget = CTK_GLWIDGET(gtk_widget);
gtk_widget_set_realized(gtk_widget, TRUE);
gtk_widget_set_has_window(gtk_widget, TRUE);
if (ctk_glwidget->is_error) {
return;
}
if (ctk_glwidget->gdk_window) {
gdk_window_set_user_data(ctk_glwidget->gdk_window,
gtk_widget);
return;
}
gtk_widget_get_allocation(gtk_widget, &allocation);
gdk_attributes.x = allocation.x;
gdk_attributes.y = allocation.y;
gdk_attributes.width = allocation.width;
gdk_attributes.height = allocation.height;
gdk_attributes.wclass = GDK_INPUT_OUTPUT;
gdk_attributes.window_type = GDK_WINDOW_CHILD;
gdk_attributes.event_mask = gtk_widget_get_events(gtk_widget);
gdk_attributes.visual = ctk_glwidget->gdk_visual;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
ctk_glwidget->gdk_window =
gdk_window_new(gtk_widget_get_parent_window(gtk_widget),
&gdk_attributes, attributes_mask);
if (ctk_glwidget->gdk_window == NULL) {
on_error(ctk_glwidget);
return;
}
ctk_glwidget->window = gdk_x11_window_get_xid(ctk_glwidget->gdk_window);
gdk_window_set_user_data(ctk_glwidget->gdk_window, gtk_widget);
gtk_widget_set_window(gtk_widget, ctk_glwidget->gdk_window);
dGL.glXMakeContextCurrent(ctk_glwidget->display, ctk_glwidget->window,
ctk_glwidget->window, ctk_glwidget->glx_context);
if (ctk_glwidget->app_setup_callback(ctk_glwidget->app_data) != 0) {
on_error(ctk_glwidget);
return;
}
g_timeout_add_full(G_PRIORITY_LOW,
ctk_glwidget->timer_interval,
draw_frame_in_glwidget,
ctk_glwidget,
0);
}
static void ctk_glwidget_unrealize(GtkWidget *gtk_widget)
{
if (CTK_GLWIDGET(gtk_widget)->is_error) {
return;
}
if (gtk_widget_get_has_window(gtk_widget)) {
gdk_window_set_user_data(CTK_GLWIDGET(gtk_widget)->gdk_window, NULL);
}
gtk_selection_remove_all(gtk_widget);
gtk_widget_set_realized(gtk_widget, FALSE);
}
static void ctk_glwidget_finalize(GObject *gobject)
{
assert(!"unimplemented");
}
static void ctk_glwidget_class_init(CtkGLWidgetClass *klass)
{
GtkWidgetClass *widget_class;
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
widget_class = (GtkWidgetClass *) klass;
widget_class->realize = ctk_glwidget_realize;
widget_class->unrealize = ctk_glwidget_unrealize;
gobject_class->finalize = ctk_glwidget_finalize;
}
GType ctk_glwidget_get_type(void)
{
static GType ctk_glwidget_type = 0;
if (!ctk_glwidget_type) {
static const GTypeInfo info_ctk_glwidget = {
sizeof (CtkGLWidgetClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) ctk_glwidget_class_init, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (CtkGLWidget),
0, /* n_preallocs */
NULL, /* instance_init */
NULL /* value_table */
};
ctk_glwidget_type = g_type_register_static(GTK_TYPE_WIDGET,
"CtkGLWidget", &info_ctk_glwidget, 0);
}
return ctk_glwidget_type;
}
static gboolean draw_frame_in_glwidget(gpointer p)
{
CtkGLWidget *ctk_glwidget = CTK_GLWIDGET(p);
if (ctk_glwidget->is_error) {
return FALSE;
}
if (!gtk_widget_get_realized(GTK_WIDGET(p))) {
return TRUE;
}
if (ctk_widget_is_drawable(GTK_WIDGET(ctk_glwidget))) {
ctk_glwidget_make_current(ctk_glwidget);
ctk_glwidget->draw_frame_callback(ctk_glwidget->app_data);
ctk_glwidget_swap(ctk_glwidget);
}
return TRUE;
}
static void on_error(CtkGLWidget *ctk_glwidget)
{
ctk_glwidget->is_error = TRUE;
gtk_widget_set_size_request(GTK_WIDGET(ctk_glwidget), 0, 0);
if (ctk_glwidget->gdk_window) {
gdk_window_set_user_data(ctk_glwidget->gdk_window, NULL);
}
}
void ctk_glwidget_make_current(CtkGLWidget *ctk_glwidget)
{
dGL.glXMakeContextCurrent(ctk_glwidget->display,
ctk_glwidget->window,
ctk_glwidget->window,
ctk_glwidget->glx_context);
}
void ctk_glwidget_swap(CtkGLWidget *ctk_glwidget)
{
dGL.glXSwapBuffers(ctk_glwidget->display, ctk_glwidget->window);
}
#endif
/*
* nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
* and Linux systems.
*
* Copyright (C) 2017 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>.
*/
#ifndef __CTK_GLWIDGET_H__
#define __CTK_GLWIDGET_H__
#include <gtk/gtk.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <gdk/gdkx.h>
#include "ctkconfig.h"
G_BEGIN_DECLS
#define CTK_TYPE_GLWIDGET (ctk_glwidget_get_type())
#define CTK_GLWIDGET(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), CTK_TYPE_GLWIDGET, CtkGLWidget))
#define CTK_GLWIDGET_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), CTK_TYPE_GLWIDGET, CtkGLWidgetClass))
#define CTK_IS_GLWIDGET(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), CTK_TYPE_GLWIDGET))
#define CTK_IS_GLWIDGET_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), CTK_TYPE_GLWIDGET))
#define CTK_GLWIDGET_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), CTK_TYPE_GLWIDGET, CtkGLWidgetClass))
typedef struct _CtkGLWidget CtkGLWidget;
typedef struct _CtkGLWidgetClass CtkGLWidgetClass;
struct _CtkGLWidget
{
GtkWidget parent;
GdkDisplay *gdk_display;
GdkWindow *gdk_window;
Display *display;
Window window;
GLXContext glx_context;
GdkVisual *gdk_visual;
gboolean is_error;
int timer_interval;
void *app_data;
int (*app_setup_callback) (void *app_data);
void (*draw_frame_callback) (void *app_data);
};
struct _CtkGLWidgetClass
{
GtkWidgetClass parent_class;
};
GType ctk_glwidget_get_type (void);
GtkWidget *ctk_glwidget_new(int glx_attributes[],
void *app_data,
int (*app_setup_callback) (void *app_data),
void (*draw_frame_callback) (void *app_data));
#ifdef CTK_GTK3
void ctk_glwidget_make_current(CtkGLWidget *ctk_glwidget);
void ctk_glwidget_swap(CtkGLWidget *ctk_glwidget);
#endif
G_END_DECLS
#endif
This diff is collapsed.
...@@ -20,11 +20,6 @@ ...@@ -20,11 +20,6 @@
#ifndef __CTK_MANAGE_GRID_LICENSE_H__ #ifndef __CTK_MANAGE_GRID_LICENSE_H__
#define __CTK_MANAGE_GRID_LICENSE_H__ #define __CTK_MANAGE_GRID_LICENSE_H__
// Licensed feature types
#define GRID_LICENSED_FEATURE_TYPE_TESLA 0
#define GRID_LICENSED_FEATURE_TYPE_VGPU 1
#define GRID_LICENSED_FEATURE_TYPE_GVW 2
G_BEGIN_DECLS G_BEGIN_DECLS
#define CTK_TYPE_MANAGE_GRID_LICENSE (ctk_manage_grid_license_get_type()) #define CTK_TYPE_MANAGE_GRID_LICENSE (ctk_manage_grid_license_get_type())
...@@ -66,10 +61,29 @@ struct _CtkManageGridLicense ...@@ -66,10 +61,29 @@ struct _CtkManageGridLicense
DbusData *dbusData; DbusData *dbusData;
gint license_edition_state; gint license_edition_state;
gboolean license_edition_gvw_selected; gint feature_type; // Feature type from UI/gridd.conf.
gint feature_type; int gridd_feature_type; // Feature type fetched from nvidia-gridd.
}; };
/*
* Status related to GRID licensing
*/
typedef enum
{
NV_GRID_UNLICENSED_VGPU = 0,
NV_GRID_UNLICENSED_VAPP,
NV_GRID_UNLICENSED_QDWS_SELECTED,
NV_GRID_LICENSE_ACQUIRED_VGPU,
NV_GRID_LICENSE_ACQUIRED_QDWS,
NV_GRID_LICENSE_REQUESTING_VGPU,
NV_GRID_LICENSE_REQUESTING_QDWS,
NV_GRID_LICENSE_FAILED_VGPU,
NV_GRID_LICENSE_FAILED_QDWS,
NV_GRID_LICENSE_EXPIRED_VGPU,
NV_GRID_LICENSE_EXPIRED_QDWS,
NV_GRID_LICENSE_RESTART_REQUIRED,
} licenseStatus;
struct _CtkManageGridLicenseClass struct _CtkManageGridLicenseClass
{ {
GtkVBoxClass parent_class; GtkVBoxClass parent_class;
......
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
#include "ctkutils.h" #include "ctkutils.h" <