boolean new_stamp;
int i;
unsigned int lastStamp;
+ struct pipe_resource **textures =
+ drawable->stvis.samples > 1 ? drawable->msaa_textures
+ : drawable->textures;
statt_mask = 0x0;
for (i = 0; i < count; i++)
/* add existing textures */
for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
- if (drawable->textures[i])
+ if (textures[i])
statt_mask |= (1 << i);
}
if (!out)
return TRUE;
+ /* Set the window-system buffers for the state tracker. */
for (i = 0; i < count; i++) {
out[i] = NULL;
- pipe_resource_reference(&out[i], drawable->textures[statts[i]]);
+ pipe_resource_reference(&out[i], textures[statts[i]]);
}
return TRUE;
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
pipe_resource_reference(&drawable->textures[i], NULL);
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+ pipe_resource_reference(&drawable->msaa_textures[i], NULL);
swap_fences_unref(drawable);
}
}
+void
+dri_msaa_resolve(struct dri_context *ctx,
+ struct dri_drawable *drawable,
+ enum st_attachment_type att)
+{
+ struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_resource *dst = drawable->textures[att];
+ struct pipe_resource *src = drawable->msaa_textures[att];
+ struct pipe_blit_info blit;
+
+ if (!dst || !src)
+ return;
+
+ memset(&blit, 0, sizeof(blit));
+ blit.dst.resource = dst;
+ blit.dst.box.width = dst->width0;
+ blit.dst.box.height = dst->width0;
+ blit.dst.box.depth = 1;
+ blit.dst.format = util_format_linear(dst->format);
+ blit.src.resource = src;
+ blit.src.box.width = src->width0;
+ blit.src.box.height = src->width0;
+ blit.src.box.depth = 1;
+ blit.src.format = util_format_linear(src->format);
+ blit.mask = PIPE_MASK_RGBA;
+ blit.filter = PIPE_TEX_FILTER_NEAREST;
+
+ pipe->blit(pipe, &blit);
+}
+
+static void
+dri_postprocessing(struct dri_context *ctx,
+ struct dri_drawable *drawable,
+ enum st_attachment_type att)
+{
+ struct pipe_resource *src = drawable->textures[att];
+ struct pipe_resource *zsbuf = drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL];
+
+ if (ctx->pp && src && zsbuf)
+ pp_run(ctx->pp, src, src, zsbuf);
+}
+
/**
* DRI2 flush extension, the flush_with_flags function.
*
/* Flush the drawable. */
if (flags & __DRI2_FLUSH_DRAWABLE) {
- struct pipe_resource *ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
+ /* Resolve MSAA buffers. */
+ if (drawable->stvis.samples > 1) {
+ dri_msaa_resolve(ctx, drawable, ST_ATTACHMENT_BACK_LEFT);
+ /* FRONT_LEFT is resolved in drawable->flush_frontbuffer. */
+ }
- if (ptex && ctx->pp && drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
- pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
+ dri_postprocessing(ctx, drawable, ST_ATTACHMENT_BACK_LEFT);
}
flush_flags = 0;
unsigned old_h;
struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
+ struct pipe_resource *msaa_textures[ST_ATTACHMENT_COUNT];
unsigned int texture_mask, texture_stamp;
struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX];
enum pipe_format *format,
unsigned *bind);
+void
+dri_msaa_resolve(struct dri_context *ctx,
+ struct dri_drawable *drawable,
+ enum st_attachment_type att);
+
void
dri_flush(__DRIcontext *cPriv,
__DRIdrawable *dPriv,
stencil_bits_array[0] = 0;
depth_buffer_factor = 1;
- msaa_samples_max = (screen->st_api->feature_mask & ST_API_FEATURE_MS_VISUALS)
+ msaa_samples_max = (screen->st_api->feature_mask & ST_API_FEATURE_MS_VISUALS_MASK)
? MSAA_VISUAL_MAX_SAMPLES : 1;
pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,
if (!mode)
return;
- stvis->samples = mode->samples;
+ if (mode->sampleBuffers) {
+ stvis->samples = mode->samples;
+ }
if (mode->redBits == 8) {
if (mode->alphaBits == 8)
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
pipe_resource_reference(&drawable->textures[i], NULL);
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+ pipe_resource_reference(&drawable->msaa_textures[i], NULL);
memset(&templ, 0, sizeof(templ));
templ.target = screen->target;
drawable->textures[statt] =
screen->base.screen->resource_from_handle(screen->base.screen,
&templ, &whandle);
+ assert(drawable->textures[statt]);
+ }
+
+ /* Allocate private MSAA colorbuffers. */
+ if (drawable->stvis.samples > 1) {
+ for (i = 0; i < att_count; i++) {
+ enum st_attachment_type att = atts[i];
+
+ if (drawable->textures[att]) {
+ templ.format = drawable->textures[att]->format;
+ templ.bind = drawable->textures[att]->bind;
+ templ.nr_samples = drawable->stvis.samples;
+
+ drawable->msaa_textures[att] =
+ screen->base.screen->resource_create(screen->base.screen,
+ &templ);
+ assert(drawable->msaa_textures[att]);
+ }
+ }
}
/* See if we need a depth-stencil buffer. */
templ.format = format;
templ.bind = bind;
- drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL] =
- screen->base.screen->resource_create(screen->base.screen, &templ);
+ if (drawable->stvis.samples > 1) {
+ templ.nr_samples = drawable->stvis.samples;
+ drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL] =
+ screen->base.screen->resource_create(screen->base.screen,
+ &templ);
+ assert(drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL]);
+ }
+ else {
+ templ.nr_samples = 0;
+ drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL] =
+ screen->base.screen->resource_create(screen->base.screen,
+ &templ);
+ assert(drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
+ }
}
}
__DRIdrawable *dri_drawable = drawable->dPriv;
struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader;
- if (loader->flushFrontBuffer == NULL)
+ if (statt != ST_ATTACHMENT_FRONT_LEFT)
return;
- if (statt == ST_ATTACHMENT_FRONT_LEFT) {
+ if (drawable->stvis.samples > 1) {
+ struct pipe_context *pipe = ctx->st->pipe;
+
+ dri_msaa_resolve(ctx, drawable, ST_ATTACHMENT_FRONT_LEFT);
+ pipe->flush(pipe, NULL);
+ }
+
+ if (loader->flushFrontBuffer) {
loader->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate);
}
}
UTIL_FORMAT_COLORSPACE_RGB, 3);
}
- if (visual->samples) {
+ if (visual->samples > 1) {
mode->sampleBuffers = 1;
mode->samples = visual->samples;
}
ST_PROFILE_OPENGL_ES2_MASK |
#endif
0,
- 0,
+ ST_API_FEATURE_MS_VISUALS_MASK,
st_api_destroy,
st_api_get_proc_address,
st_api_create_context,