mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 11:08:03 +02:00
st/dri: Add hooks for framebuffer functions
This commit is contained in:
parent
ab12d4f647
commit
ea6a52a1f8
10 changed files with 91 additions and 120 deletions
|
|
@ -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: */
|
||||
|
|
|
|||
|
|
@ -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: */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ 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)
|
||||
{
|
||||
|
|
@ -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) {
|
||||
templ.format = format;
|
||||
templ.bind = tex_usage;
|
||||
if (format == PIPE_FORMAT_NONE)
|
||||
continue;
|
||||
|
||||
drawable->textures[i] =
|
||||
screen->pipe_screen->resource_create(screen->pipe_screen, &templ);
|
||||
}
|
||||
templ.format = format;
|
||||
templ.bind = bind;
|
||||
|
||||
drawable->textures[statts[i]] =
|
||||
screen->pipe_screen->resource_create(screen->pipe_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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -346,7 +346,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)
|
||||
|
|
@ -358,7 +358,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)
|
||||
{
|
||||
|
|
@ -513,6 +513,8 @@ dri2_init_screen(__DRIscreen * sPriv)
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -34,13 +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);
|
||||
|
||||
#endif /* DRI2_H */
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ put_image(__DRIdrawable *dPriv, void *data, unsigned width, unsigned height)
|
|||
data, dPriv->loaderPrivate);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
drisw_update_drawable_info(struct dri_drawable *drawable)
|
||||
{
|
||||
__DRIdrawable *dPriv = drawable->dPriv;
|
||||
|
|
@ -147,7 +147,7 @@ drisw_swap_buffers(__DRIdrawable *dPriv)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
drisw_flush_frontbuffer(struct dri_drawable *drawable,
|
||||
enum st_attachment_type statt)
|
||||
{
|
||||
|
|
@ -175,9 +175,10 @@ drisw_flush_frontbuffer(struct dri_drawable *drawable,
|
|||
* seems a better seperation and safer for each DRI version to provide its own
|
||||
* function.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
drisw_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;
|
||||
|
|
@ -206,38 +207,25 @@ drisw_allocate_textures(struct dri_drawable *drawable,
|
|||
|
||||
for (i = 0; i < ST_ATTACHMENT_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))) {
|
||||
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) {
|
||||
templ.format = format;
|
||||
templ.bind = tex_usage;
|
||||
if (statts[i] != ST_ATTACHMENT_DEPTH_STENCIL)
|
||||
bind |= PIPE_BIND_DISPLAY_TARGET;
|
||||
|
||||
drawable->textures[i] =
|
||||
screen->pipe_screen->resource_create(screen->pipe_screen, &templ);
|
||||
}
|
||||
if (format == PIPE_FORMAT_NONE)
|
||||
continue;
|
||||
|
||||
templ.format = format;
|
||||
templ.bind = bind;
|
||||
|
||||
drawable->textures[statts[i]] =
|
||||
screen->pipe_screen->resource_create(screen->pipe_screen, &templ);
|
||||
}
|
||||
|
||||
drawable->old_w = width;
|
||||
|
|
@ -270,6 +258,9 @@ drisw_init_screen(__DRIscreen * sPriv)
|
|||
screen->api = NULL; /* not needed */
|
||||
screen->sPriv = sPriv;
|
||||
screen->fd = -1;
|
||||
screen->allocate_textures = drisw_allocate_textures;
|
||||
screen->update_drawable_info = drisw_update_drawable_info;
|
||||
screen->flush_frontbuffer = drisw_flush_frontbuffer;
|
||||
|
||||
sPriv->private = (void *)screen;
|
||||
sPriv->extensions = drisw_screen_extensions;
|
||||
|
|
|
|||
|
|
@ -38,17 +38,6 @@
|
|||
const __DRIconfig **
|
||||
drisw_init_screen(__DRIscreen * sPriv);
|
||||
|
||||
void
|
||||
drisw_update_drawable_info(struct dri_drawable *drawable);
|
||||
|
||||
void
|
||||
drisw_flush_frontbuffer(struct dri_drawable *drawable,
|
||||
enum st_attachment_type statt);
|
||||
|
||||
void
|
||||
drisw_allocate_textures(struct dri_drawable *drawable,
|
||||
unsigned mask);
|
||||
|
||||
void drisw_swap_buffers(__DRIdrawable * dPriv);
|
||||
|
||||
#endif /* DRISW_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue