summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/dri/common
diff options
context:
space:
mode:
authorJakob Bornecrantz <wallbraker@gmail.com>2010-04-24 13:36:09 +0100
committerJakob Bornecrantz <wallbraker@gmail.com>2010-04-26 00:40:17 +0100
commitea6a52a1f8e7fd72b5506218c31e58088131f1f5 (patch)
treed0eb24768f229a2ffe6b3cca4eb0ef356369d736 /src/gallium/state_trackers/dri/common
parentab12d4f647702f0063c41dd090cef762aa95a0f9 (diff)
st/dri: Add hooks for framebuffer functions
Diffstat (limited to 'src/gallium/state_trackers/dri/common')
-rw-r--r--src/gallium/state_trackers/dri/common/dri_drawable.c28
-rw-r--r--src/gallium/state_trackers/dri/common/dri_drawable.h6
-rw-r--r--src/gallium/state_trackers/dri/common/dri_screen.h7
-rw-r--r--src/gallium/state_trackers/dri/common/dri_st_api.c36
4 files changed, 48 insertions, 29 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c
index 88c17e81bf..6b551ea3f9 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -90,4 +90,32 @@ dri_destroy_buffer(__DRIdrawable * dPriv)
FREE(drawable);
}
+/**
+ * Get the format and binding of an attachment.
+ */
+void
+dri_drawable_get_format(struct dri_drawable *drawable,
+ enum st_attachment_type statt,
+ enum pipe_format *format,
+ unsigned *bind)
+{
+ 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;
+ *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ break;
+ case ST_ATTACHMENT_DEPTH_STENCIL:
+ *format = drawable->stvis.depth_stencil_format;
+ *bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
+ break;
+ default:
+ *format = PIPE_FORMAT_NONE;
+ *bind = 0;
+ break;
+ }
+}
+
/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h
index 315b778165..dad218bde2 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.h
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.h
@@ -84,6 +84,12 @@ dri_create_buffer(__DRIscreen * sPriv,
void dri_destroy_buffer(__DRIdrawable * dPriv);
+void
+dri_drawable_get_format(struct dri_drawable *drawable,
+ enum st_attachment_type statt,
+ enum pipe_format *format,
+ unsigned *bind);
+
#endif
/* vim: set sw=3 ts=8 sts=3 expandtab: */
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h
index d84ce1bf48..6e814af615 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.h
+++ b/src/gallium/state_trackers/dri/common/dri_screen.h
@@ -42,6 +42,7 @@
#include "state_tracker/drm_api.h"
struct dri_context;
+struct dri_drawable;
struct dri_screen
{
@@ -59,6 +60,12 @@ struct dri_screen
/* hooks filled in by dri1, dri2 & drisw */
__DRIimage * (*lookup_egl_image)(struct dri_context *ctx, void *handle);
+ void (*allocate_textures)(struct dri_drawable *drawable,
+ const enum st_attachment_type *statts,
+ unsigned count);
+ void (*update_drawable_info)(struct dri_drawable *drawable);
+ void (*flush_frontbuffer)(struct dri_drawable *drawable,
+ enum st_attachment_type statt);
/* gallium */
struct drm_api *api;
diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c
index cbcb149b0a..9702acea5c 100644
--- a/src/gallium/state_trackers/dri/common/dri_st_api.c
+++ b/src/gallium/state_trackers/dri/common/dri_st_api.c
@@ -36,12 +36,6 @@
#include "dri_context.h"
#include "dri_drawable.h"
#include "dri_st_api.h"
-#ifndef __NOT_HAVE_DRM_H
-#include "dri1.h"
-#include "dri2.h"
-#else
-#include "drisw.h"
-#endif
static boolean
dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
@@ -51,6 +45,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
{
struct dri_drawable *drawable =
(struct dri_drawable *) stfbi->st_manager_private;
+ struct dri_screen *screen = dri_screen(drawable->sPriv);
unsigned statt_mask, new_mask;
boolean new_stamp;
int i;
@@ -70,20 +65,10 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
new_stamp = (drawable->texture_stamp != drawable->dPriv->lastStamp);
if (new_stamp || new_mask) {
+ if (new_stamp && screen->update_drawable_info)
+ screen->update_drawable_info(drawable);
-#ifndef __NOT_HAVE_DRM_H
- if (__dri1_api_hooks) {
- dri1_allocate_textures(drawable, statt_mask);
- }
- else {
- dri2_allocate_textures(drawable, statts, count);
- }
-#else
- if (new_stamp)
- drisw_update_drawable_info(drawable);
-
- drisw_allocate_textures(drawable, statt_mask);
-#endif
+ screen->allocate_textures(drawable, statts, count);
/* add existing textures */
for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
@@ -112,17 +97,10 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
{
struct dri_drawable *drawable =
(struct dri_drawable *) stfbi->st_manager_private;
+ struct dri_screen *screen = dri_screen(drawable->sPriv);
-#ifndef __NOT_HAVE_DRM_H
- if (__dri1_api_hooks) {
- dri1_flush_frontbuffer(drawable, statt);
- }
- else {
- dri2_flush_frontbuffer(drawable, statt);
- }
-#else
- drisw_flush_frontbuffer(drawable, statt);
-#endif
+ /* XXX remove this and just set the correct one on the framebuffer */
+ screen->flush_frontbuffer(drawable, statt);
return TRUE;
}