GLint depth_size, GLint stencil_size,
GLint accumRedSize, GLint accumGreenSize,
GLint accumBlueSize, GLint accumAlphaSize,
- GLint level, GLint numAuxBuffers )
+ GLint level, GLint numAuxBuffers, GLint num_samples )
{
GLboolean ximageFlag = GL_TRUE;
XMesaVisual xmvis;
if (v->display == dpy
&& v->mesa_visual.level == level
&& v->mesa_visual.numAuxBuffers == numAuxBuffers
+ && v->mesa_visual.samples == num_samples
&& v->ximage_flag == ximageFlag
&& v->mesa_visual.rgbMode == rgbFlag
&& v->mesa_visual.doubleBufferMode == dbFlag
stereoFlag, ximageFlag,
depth_size, stencil_size,
accumRedSize, accumBlueSize,
- accumBlueSize, accumAlphaSize, 0, level,
+ accumBlueSize, accumAlphaSize, num_samples, level,
GLX_NONE_EXT );
if (xmvis) {
/* Save a copy of the pointer now so we can find this visual again
accBits, /* b */
accBits, /* a */
0, /* level */
- 0 /* numAux */
+ 0, /* numAux */
+ 0 /* numSamples */
);
}
else {
XMesaVisual xmvis = NULL;
int desiredVisualID = -1;
int numAux = 0;
+ GLint num_samples = 0;
xmesa_init( dpy );
* GLX_ARB_multisample
*/
case GLX_SAMPLE_BUFFERS_ARB:
+ /* ignore */
+ parselist++;
+ parselist++;
+ break;
case GLX_SAMPLES_ARB:
parselist++;
- if (*parselist++ != 0) {
- /* ms not supported */
- return NULL;
- }
+ num_samples = *parselist++;
break;
/*
xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
stereo_flag, depth_size, stencil_size,
accumRedSize, accumGreenSize,
- accumBlueSize, accumAlphaSize, level, numAux );
+ accumBlueSize, accumAlphaSize, level, numAux,
+ num_samples );
}
return xmvis;
* GLX_ARB_multisample
*/
case GLX_SAMPLE_BUFFERS_ARB:
- *value = 0;
+ *value = xmvis->mesa_visual.sampleBuffers;
return 0;
case GLX_SAMPLES_ARB:
- *value = 0;
+ *value = xmvis->mesa_visual.samples;
return 0;
/*
* stencil sizes.
*/
static enum pipe_format
-choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil)
+choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil,
+ int sample_count)
{
const enum pipe_texture_target target = PIPE_TEXTURE_2D;
const unsigned tex_usage = PIPE_BIND_DEPTH_STENCIL;
- const unsigned sample_count = 0;
enum pipe_format formats[8], fmt;
int count, i;
vis->numAuxBuffers = 0;
vis->level = 0;
- vis->sampleBuffers = 0;
- vis->samples = 0;
+ vis->sampleBuffers = num_samples > 1;
+ vis->samples = num_samples;
}
v->stvis.buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK;
}
v->stvis.color_format = choose_pixel_format(v);
+
+ /* Check format support at requested num_samples (for multisample) */
+ if (!xmdpy->screen->is_format_supported(xmdpy->screen,
+ v->stvis.color_format,
+ PIPE_TEXTURE_2D, num_samples,
+ PIPE_BIND_RENDER_TARGET))
+ v->stvis.color_format = PIPE_FORMAT_NONE;
+
if (v->stvis.color_format == PIPE_FORMAT_NONE) {
free(v->visinfo);
free(v);
}
v->stvis.depth_stencil_format =
- choose_depth_stencil_format(xmdpy, depth_size, stencil_size);
+ choose_depth_stencil_format(xmdpy, depth_size, stencil_size,
+ num_samples);
v->stvis.accum_format = (accum_red_size +
accum_green_size + accum_blue_size + accum_alpha_size) ?