[Mesa-dev] [PATCH v2 1/4] gallium: Make (num_)samples an unsigned int
Gert Wollny
gw.fossdev at gmail.com
Thu Jan 18 08:57:26 UTC 2018
According to the ARB_multisample num_samples is a non-negative integer.
Consequently define it as such, fail in glx/choose_visual if a negative
number is given.
v2: split patch into gallium and mesa part
Signed-off-by: Gert Wollny <gw.fossdev at gmail.com>
---
src/gallium/include/state_tracker/st_api.h | 2 +-
src/gallium/state_trackers/glx/xlib/glx_api.c | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index f95f65f156..ec6e7844b8 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -202,7 +202,7 @@ struct st_visual
enum pipe_format color_format;
enum pipe_format depth_stencil_format;
enum pipe_format accum_format;
- int samples;
+ unsigned samples;
/**
* Desired render buffer.
diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c
index c473a0fe54..bb8afe0e6f 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_api.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
@@ -181,7 +181,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
GLint depth_size, GLint stencil_size,
GLint accumRedSize, GLint accumGreenSize,
GLint accumBlueSize, GLint accumAlphaSize,
- GLint level, GLint numAuxBuffers, GLint num_samples )
+ GLint level, GLint numAuxBuffers, GLuint num_samples )
{
GLboolean ximageFlag = GL_TRUE;
XMesaVisual xmvis;
@@ -996,7 +996,11 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
(void) caveat;
-
+ if (num_samples < 0) {
+ _mesa_warning(NULL, "GLX_SAMPLES_ARB: number of samples must not be negative");
+ return NULL;
+ }
+
/*
* Since we're only simulating the GLX extension this function will never
* find any real GL visuals. Instead, all we can do is try to find an RGB
--
2.13.6
More information about the mesa-dev
mailing list