aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/dri/drm
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/dri/drm')
-rw-r--r--src/gallium/state_trackers/dri/drm/Makefile1
-rw-r--r--src/gallium/state_trackers/dri/drm/SConscript1
-rw-r--r--src/gallium/state_trackers/dri/drm/dri1.c65
-rw-r--r--src/gallium/state_trackers/dri/drm/dri1.h8
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c50
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.h12
l---------src/gallium/state_trackers/dri/drm/dri_st_api.c1
7 files changed, 54 insertions, 84 deletions
diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile
index 7a236da0c0f..d9a973e3c3e 100644
--- a/src/gallium/state_trackers/dri/drm/Makefile
+++ b/src/gallium/state_trackers/dri/drm/Makefile
@@ -16,7 +16,6 @@ C_SOURCES = \
dri_context.c \
dri_screen.c \
dri_drawable.c \
- dri_st_api.c \
dri1_helper.c \
dri1.c \
dri2.c
diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript
index 1dfaa402f2d..8800b655343 100644
--- a/src/gallium/state_trackers/dri/drm/SConscript
+++ b/src/gallium/state_trackers/dri/drm/SConscript
@@ -20,7 +20,6 @@ if env['dri']:
source = [ 'dri_context.c',
'dri_drawable.c',
'dri_screen.c',
- 'dri_st_api.c',
'dri1_helper.c',
'dri1.c',
'dri2.c',
diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c
index e216e46a87e..23c21ed8398 100644
--- a/src/gallium/state_trackers/dri/drm/dri1.c
+++ b/src/gallium/state_trackers/dri/drm/dri1.c
@@ -104,13 +104,13 @@ dri1_propagate_drawable_change(struct dri_context *ctx)
if (dPriv && draw->texture_stamp != dPriv->lastStamp) {
ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
flushed = TRUE;
- ctx->st->notify_invalid_framebuffer(ctx->st, draw->stfb);
+ ctx->st->notify_invalid_framebuffer(ctx->st, &draw->base);
}
if (rPriv && dPriv != rPriv && read->texture_stamp != rPriv->lastStamp) {
if (!flushed)
ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
- ctx->st->notify_invalid_framebuffer(ctx->st, read->stfb);
+ ctx->st->notify_invalid_framebuffer(ctx->st, &read->base);
}
}
@@ -253,13 +253,13 @@ dri1_copy_to_front(struct dri_context *ctx,
* Backend functions for st_framebuffer interface and swap_buffers.
*/
-void
+static void
dri1_flush_frontbuffer(struct dri_drawable *draw,
enum st_attachment_type statt)
{
- struct dri_context *ctx = dri_get_current();
+ struct dri_context *ctx = dri_get_current(draw->sPriv);
struct dri_screen *screen = dri_screen(draw->sPriv);
- struct pipe_screen *pipe_screen = screen->pipe_screen;
+ struct pipe_screen *pipe_screen = screen->base.screen;
struct pipe_fence_handle *dummy_fence;
struct pipe_resource *ptex;
@@ -280,10 +280,10 @@ dri1_flush_frontbuffer(struct dri_drawable *draw,
void
dri1_swap_buffers(__DRIdrawable * dPriv)
{
- struct dri_context *ctx = dri_get_current();
struct dri_drawable *draw = dri_drawable(dPriv);
+ struct dri_context *ctx = dri_get_current(draw->sPriv);
struct dri_screen *screen = dri_screen(draw->sPriv);
- struct pipe_screen *pipe_screen = screen->pipe_screen;
+ struct pipe_screen *pipe_screen = screen->base.screen;
struct pipe_fence_handle *fence;
struct pipe_resource *ptex;
@@ -309,9 +309,9 @@ dri1_swap_buffers(__DRIdrawable * dPriv)
void
dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h)
{
- struct dri_context *ctx = dri_get_current();
+ struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv);
struct dri_screen *screen = dri_screen(dPriv->driScreenPriv);
- struct pipe_screen *pipe_screen = screen->pipe_screen;
+ struct pipe_screen *pipe_screen = screen->base.screen;
struct drm_clip_rect sub_bbox;
struct dri_drawable *draw = dri_drawable(dPriv);
struct pipe_fence_handle *dummy_fence;
@@ -342,9 +342,10 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h)
* as they are requested. Unused attachments are not removed, not until the
* framebuffer is resized or destroyed.
*/
-void
+static void
dri1_allocate_textures(struct dri_drawable *drawable,
- unsigned mask)
+ const enum st_attachment_type *statts,
+ unsigned count)
{
struct dri_screen *screen = dri_screen(drawable->sPriv);
struct pipe_resource templ;
@@ -371,40 +372,24 @@ dri1_allocate_textures(struct dri_drawable *drawable,
templ.depth0 = 1;
templ.last_level = 0;
- for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+ for (i = 0; i < count; i++) {
enum pipe_format format;
- unsigned tex_usage;
+ unsigned bind;
- /* the texture already exists or not requested */
- if (drawable->textures[i] || !(mask & (1 << i))) {
+ /* the texture already exists */
+ if (drawable->textures[statts[i]])
continue;
- }
- switch (i) {
- case ST_ATTACHMENT_FRONT_LEFT:
- case ST_ATTACHMENT_BACK_LEFT:
- case ST_ATTACHMENT_FRONT_RIGHT:
- case ST_ATTACHMENT_BACK_RIGHT:
- format = drawable->stvis.color_format;
- tex_usage = PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_RENDER_TARGET;
- break;
- case ST_ATTACHMENT_DEPTH_STENCIL:
- format = drawable->stvis.depth_stencil_format;
- tex_usage = PIPE_BIND_DEPTH_STENCIL;
- break;
- default:
- format = PIPE_FORMAT_NONE;
- break;
- }
+ dri_drawable_get_format(drawable, statts[i], &format, &bind);
+
+ if (format == PIPE_FORMAT_NONE)
+ continue;
- if (format != PIPE_FORMAT_NONE) {
- templ.format = format;
- templ.bind = tex_usage;
+ templ.format = format;
+ templ.bind = bind;
- drawable->textures[i] =
- screen->pipe_screen->resource_create(screen->pipe_screen, &templ);
- }
+ drawable->textures[statts[i]] =
+ screen->base.screen->resource_create(screen->base.screen, &templ);
}
drawable->old_w = width;
@@ -489,6 +474,8 @@ dri1_init_screen(__DRIscreen * sPriv)
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
screen->drmLock = (drmLock *) & sPriv->pSAREA->lock;
+ screen->allocate_textures = dri1_allocate_textures;
+ screen->flush_frontbuffer = dri1_flush_frontbuffer;
sPriv->private = (void *)screen;
sPriv->extensions = dri1_screen_extensions;
diff --git a/src/gallium/state_trackers/dri/drm/dri1.h b/src/gallium/state_trackers/dri/drm/dri1.h
index f7441f98abc..a50188b3682 100644
--- a/src/gallium/state_trackers/dri/drm/dri1.h
+++ b/src/gallium/state_trackers/dri/drm/dri1.h
@@ -43,14 +43,6 @@ extern struct dri1_api *__dri1_api_hooks;
const __DRIconfig **
dri1_init_screen(__DRIscreen * sPriv);
-void
-dri1_flush_frontbuffer(struct dri_drawable *drawable,
- enum st_attachment_type statt);
-
-void
-dri1_allocate_textures(struct dri_drawable *drawable,
- unsigned mask);
-
void dri1_swap_buffers(__DRIdrawable * dPriv);
void
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 0d15b5c9b85..e1216f14c0e 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -38,9 +38,10 @@
#include "dri_screen.h"
#include "dri_context.h"
#include "dri_drawable.h"
-#include "dri_st_api.h"
#include "dri2.h"
+#include "GL/internal/dri_interface.h"
+
/**
* DRI2 flush extension.
*/
@@ -59,7 +60,7 @@ dri2_invalidate_drawable(__DRIdrawable *dPriv)
drawable->dPriv->lastStamp = *drawable->dPriv->pStamp;
if (ctx)
- ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb);
+ ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base);
}
static const __DRI2flushExtension dri2FlushExtension = {
@@ -79,7 +80,7 @@ dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
struct dri_drawable *drawable = dri_drawable(dPriv);
struct pipe_resource *pt;
- dri_st_framebuffer_validate_att(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT);
+ dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT);
pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
@@ -120,30 +121,31 @@ static const __DRItexBufferExtension dri2TexBufferExtension = {
};
/**
- * Get the format of an attachment.
+ * Get the format and binding of an attachment.
*/
-static INLINE enum pipe_format
+static INLINE void
dri2_drawable_get_format(struct dri_drawable *drawable,
- enum st_attachment_type statt)
+ enum st_attachment_type statt,
+ enum pipe_format *format,
+ unsigned *bind)
{
- enum pipe_format format;
-
switch (statt) {
case ST_ATTACHMENT_FRONT_LEFT:
case ST_ATTACHMENT_BACK_LEFT:
case ST_ATTACHMENT_FRONT_RIGHT:
case ST_ATTACHMENT_BACK_RIGHT:
- format = drawable->stvis.color_format;
+ *format = drawable->stvis.color_format;
+ *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
break;
case ST_ATTACHMENT_DEPTH_STENCIL:
- format = drawable->stvis.depth_stencil_format;
+ *format = drawable->stvis.depth_stencil_format;
+ *bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
break;
default:
- format = PIPE_FORMAT_NONE;
+ *format = PIPE_FORMAT_NONE;
+ *bind = 0;
break;
}
-
- return format;
}
@@ -174,9 +176,10 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
for (i = 0; i < *count; i++) {
enum pipe_format format;
+ unsigned bind;
int att, bpp;
- format = dri2_drawable_get_format(drawable, statts[i]);
+ dri2_drawable_get_format(drawable, statts[i], &format, &bind);
if (format == PIPE_FORMAT_NONE)
continue;
@@ -263,7 +266,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
struct pipe_resource templ;
struct winsys_handle whandle;
boolean have_depth = FALSE;
- unsigned i;
+ unsigned i, bind;
if (drawable->old_num == count &&
drawable->old_w == dri_drawable->w &&
@@ -275,7 +278,6 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
pipe_resource_reference(&drawable->textures[i], NULL);
memset(&templ, 0, sizeof(templ));
- templ.bind = PIPE_BIND_RENDER_TARGET;
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
templ.width0 = dri_drawable->w;
@@ -319,16 +321,17 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
break;
}
- format = dri2_drawable_get_format(drawable, statt);
+ dri2_drawable_get_format(drawable, statt, &format, &bind);
if (statt == ST_ATTACHMENT_INVALID || format == PIPE_FORMAT_NONE)
continue;
templ.format = format;
+ templ.bind = bind;
whandle.handle = buf->name;
whandle.stride = buf->pitch;
drawable->textures[statt] =
- screen->pipe_screen->resource_from_handle(screen->pipe_screen,
+ screen->base.screen->resource_from_handle(screen->base.screen,
&templ, &whandle);
}
@@ -342,7 +345,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
* Backend functions for st_framebuffer interface.
*/
-void
+static void
dri2_allocate_textures(struct dri_drawable *drawable,
const enum st_attachment_type *statts,
unsigned count)
@@ -354,7 +357,7 @@ dri2_allocate_textures(struct dri_drawable *drawable,
dri2_drawable_process_buffers(drawable, buffers, num_buffers);
}
-void
+static void
dri2_flush_frontbuffer(struct dri_drawable *drawable,
enum st_attachment_type statt)
{
@@ -369,7 +372,7 @@ dri2_flush_frontbuffer(struct dri_drawable *drawable,
}
}
-__DRIimage *
+static __DRIimage *
dri2_lookup_egl_image(struct dri_context *ctx, void *handle)
{
__DRIimageLookupExtension *loader = ctx->sPriv->dri2.image;
@@ -431,7 +434,7 @@ dri2_create_image_from_name(__DRIcontext *context,
whandle.handle = name;
whandle.stride = pitch * util_format_get_blocksize(pf);
- img->texture = screen->pipe_screen->resource_from_handle(screen->pipe_screen,
+ img->texture = screen->base.screen->resource_from_handle(screen->base.screen,
&templ, &whandle);
if (!img->texture) {
FREE(img);
@@ -508,6 +511,9 @@ dri2_init_screen(__DRIscreen * sPriv)
screen->api = drm_api_create();
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
+ screen->lookup_egl_image = dri2_lookup_egl_image;
+ screen->allocate_textures = dri2_allocate_textures;
+ screen->flush_frontbuffer = dri2_flush_frontbuffer;
sPriv->private = (void *)screen;
sPriv->extensions = dri_screen_extensions;
diff --git a/src/gallium/state_trackers/dri/drm/dri2.h b/src/gallium/state_trackers/dri/drm/dri2.h
index 5b28850000b..07adfe4f6c5 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.h
+++ b/src/gallium/state_trackers/dri/drm/dri2.h
@@ -34,16 +34,4 @@
const __DRIconfig **
dri2_init_screen(__DRIscreen * sPriv);
-void
-dri2_flush_frontbuffer(struct dri_drawable *drawable,
- enum st_attachment_type statt);
-
-void
-dri2_allocate_textures(struct dri_drawable *drawable,
- const enum st_attachment_type *statts,
- unsigned count);
-
-__DRIimage *
-dri2_lookup_egl_image(struct dri_context *ctx, void *handle);
-
#endif /* DRI2_H */
diff --git a/src/gallium/state_trackers/dri/drm/dri_st_api.c b/src/gallium/state_trackers/dri/drm/dri_st_api.c
deleted file mode 120000
index a8f6bd06b09..00000000000
--- a/src/gallium/state_trackers/dri/drm/dri_st_api.c
+++ /dev/null
@@ -1 +0,0 @@
-../common/dri_st_api.c \ No newline at end of file