summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/dri/drm/dri2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/dri/drm/dri2.c')
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 5ebe18480d8..7f4f2f00c77 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -187,12 +187,14 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
drawable->old_h == dri_drawable->h &&
memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * buffer_count) == 0)
return;
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;
templ.last_level = 0;
templ.width0 = dri_drawable->w;
templ.height0 = dri_drawable->h;
@@ -232,12 +234,31 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
whandle.handle = buf->name;
whandle.stride = buf->pitch;
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. */
for (i = 0; i < att_count; i++) {
if (atts[i] == ST_ATTACHMENT_DEPTH_STENCIL) {
alloc_depthstencil = TRUE;
@@ -253,14 +274,26 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
dri_drawable_get_format(drawable, ST_ATTACHMENT_DEPTH_STENCIL,
&format, &bind);
if (format) {
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]);
+ }
}
}
drawable->old_num = buffer_count;
drawable->old_w = dri_drawable->w;
drawable->old_h = dri_drawable->h;
@@ -377,16 +410,23 @@ dri2_flush_frontbuffer(struct dri_context *ctx,
struct dri_drawable *drawable,
enum st_attachment_type statt)
{
__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);
}
}
static void
dri2_update_tex_buffer(struct dri_drawable *drawable,