struct pipe_fence_handle *
dri1_swap_fences_pop_front(struct dri_drawable *draw)
{
- struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
+ struct pipe_screen *screen = dri_screen(draw->sPriv)->base.screen;
struct pipe_fence_handle *fence = NULL;
if (draw->cur_fences >= draw->desired_fences) {
dri1_swap_fences_push_back(struct dri_drawable *draw,
struct pipe_fence_handle *fence)
{
- struct pipe_screen *screen = dri_screen(draw->sPriv)->pipe_screen;
+ struct pipe_screen *screen = dri_screen(draw->sPriv)->base.screen;
if (!fence)
return;
void
dri1_swap_fences_clear(struct dri_drawable *drawable)
{
- struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
+ struct pipe_screen *screen = dri_screen(drawable->sPriv)->base.screen;
struct pipe_fence_handle *fence;
while (drawable->cur_fences) {
struct pipe_surface *
dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_resource *ptex)
{
- struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen;
+ struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->base.screen;
struct pipe_surface *psurf = drawable->dri1_surface;
if (!psurf || psurf->texture != ptex) {
if (!pipe) {
screen->dri1_pipe =
- screen->pipe_screen->context_create(screen->pipe_screen, NULL);
+ screen->base.screen->context_create(screen->base.screen, NULL);
pipe = screen->dri1_pipe;
}
#include "dri_screen.h"
#include "dri_drawable.h"
#include "dri_context.h"
-#include "dri_st_api.h"
#include "pipe/p_context.h"
#include "state_tracker/st_context.h"
#include "dri_screen.h"
#include "dri_context.h"
#include "dri_drawable.h"
-#include "dri_st_api.h"
#include "dri1_helper.h"
#include "pipe/p_screen.h"
#include "util/u_format.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
+
+static boolean
+dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
+ const enum st_attachment_type *statts,
+ unsigned count,
+ struct pipe_resource **out)
+{
+ 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;
+
+ statt_mask = 0x0;
+ for (i = 0; i < count; i++)
+ statt_mask |= (1 << statts[i]);
+
+ /* record newly allocated textures */
+ new_mask = (statt_mask & ~drawable->texture_mask);
+
+ /*
+ * dPriv->pStamp is the server stamp. It should be accessed with a lock, at
+ * least for DRI1. dPriv->lastStamp is the client stamp. It has the value
+ * of the server stamp when last checked.
+ */
+ 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);
+
+ screen->allocate_textures(drawable, statts, count);
+
+ /* add existing textures */
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+ if (drawable->textures[i])
+ statt_mask |= (1 << i);
+ }
+
+ drawable->texture_stamp = drawable->dPriv->lastStamp;
+ drawable->texture_mask = statt_mask;
+ }
+
+ if (!out)
+ return TRUE;
+
+ for (i = 0; i < count; i++) {
+ out[i] = NULL;
+ pipe_resource_reference(&out[i], drawable->textures[statts[i]]);
+ }
+
+ return TRUE;
+}
+
+static boolean
+dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
+ enum st_attachment_type statt)
+{
+ struct dri_drawable *drawable =
+ (struct dri_drawable *) stfbi->st_manager_private;
+ struct dri_screen *screen = dri_screen(drawable->sPriv);
+
+ /* XXX remove this and just set the correct one on the framebuffer */
+ screen->flush_frontbuffer(drawable, statt);
+
+ return TRUE;
+}
+
/**
* This is called when we need to set up GL rendering to a new X window.
*/
goto fail;
dri_fill_st_visual(&drawable->stvis, screen, visual);
- dri_init_st_framebuffer(drawable);
+
+ /* setup the st_framebuffer_iface */
+ drawable->base.visual = &drawable->stvis;
+ drawable->base.flush_front = dri_st_framebuffer_flush_front;
+ drawable->base.validate = dri_st_framebuffer_validate;
+ drawable->base.st_manager_private = (void *) drawable;
drawable->sPriv = sPriv;
drawable->dPriv = dPriv;
dri_destroy_buffer(__DRIdrawable * dPriv)
{
struct dri_drawable *drawable = dri_drawable(dPriv);
+ int i;
dri1_swap_fences_clear(drawable);
dri1_destroy_pipe_surface(drawable);
- dri_close_st_framebuffer(drawable);
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+ pipe_resource_reference(&drawable->textures[i], NULL);
drawable->desired_fences = 0;
FREE(drawable);
}
+/**
+ * Validate the texture at an attachment. Allocate the texture if it does not
+ * exist.
+ */
+void
+dri_drawable_validate_att(struct dri_drawable *drawable,
+ enum st_attachment_type statt)
+{
+ enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
+ unsigned i, count = 0;
+
+ /* check if buffer already exists */
+ if (drawable->texture_mask & (1 << statt))
+ return;
+
+ /* make sure DRI2 does not destroy existing buffers */
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+ if (drawable->texture_mask & (1 << i)) {
+ statts[count++] = i;
+ }
+ }
+ statts[count++] = statt;
+
+ drawable->texture_stamp = drawable->dPriv->lastStamp - 1;
+
+ /* this calles into the manager */
+ drawable->base.validate(&drawable->base, statts, count, NULL);
+}
+
/**
* Get the format and binding of an attachment.
*/
enum pipe_format *format,
unsigned *bind);
+void
+dri_drawable_validate_att(struct dri_drawable *drawable,
+ enum st_attachment_type statt);
+
#endif
/* vim: set sw=3 ts=8 sts=3 expandtab: */
#include "dri_screen.h"
#include "dri_context.h"
#include "dri_drawable.h"
-#include "dri_st_api.h"
#include "dri1_helper.h"
#ifndef __NOT_HAVE_DRM_H
#include "dri1.h"
#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#include "pipe/p_format.h"
+#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
#include "util/u_debug.h"
unsigned depth_buffer_factor;
unsigned back_buffer_factor;
unsigned msaa_samples_factor;
- struct pipe_screen *p_screen = screen->pipe_screen;
+ struct pipe_screen *p_screen = screen->base.screen;
boolean pf_r5g6b5, pf_a8r8g8b8, pf_x8r8g8b8;
boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32;
#endif
+static boolean
+dri_get_egl_image(struct st_manager *smapi,
+ struct st_egl_image *stimg)
+{
+ struct dri_context *ctx =
+ (struct dri_context *)stimg->stctxi->st_manager_private;
+ struct dri_screen *screen = dri_screen(ctx->sPriv);
+ __DRIimage *img = NULL;
+
+ if (screen->lookup_egl_image) {
+ img = screen->lookup_egl_image(ctx, stimg->egl_image);
+ }
+
+ if (!img)
+ return FALSE;
+
+ stimg->texture = NULL;
+ pipe_resource_reference(&stimg->texture, img->texture);
+ stimg->face = img->face;
+ stimg->level = img->level;
+ stimg->zslice = img->zslice;
+
+ return TRUE;
+}
+
static void
dri_destroy_option_cache(struct dri_screen * screen)
{
{
dri1_destroy_pipe_context(screen);
- if (screen->pipe_screen)
- screen->pipe_screen->destroy(screen->pipe_screen);
+ if (screen->st_api && screen->st_api->destroy)
+ screen->st_api->destroy(screen->st_api);
+
+ if (screen->base.screen)
+ screen->base.screen->destroy(screen->base.screen);
dri_destroy_option_cache(screen);
}
struct pipe_screen *pscreen,
unsigned pixel_bits)
{
- screen->pipe_screen = pscreen;
- if (!screen->pipe_screen) {
+ screen->base.screen = pscreen;
+ if (!screen->base.screen) {
debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
return NULL;
}
- if (!dri_init_st_manager(screen))
+ screen->base.get_egl_image = dri_get_egl_image;
+ screen->st_api = st_gl_api_create();
+
+ if (!screen->st_api)
return NULL;
driParseOptionInfo(&screen->optionCache,
/* gallium */
struct drm_api *api;
- struct pipe_winsys *pipe_winsys;
- struct pipe_screen *pipe_screen;
boolean d_depth_bits_last;
boolean sd_depth_bits_last;
boolean auto_fake_front;
return (struct dri_screen *)sPriv->private;
}
+struct __DRIimageRec {
+ struct pipe_resource *texture;
+ unsigned face;
+ unsigned level;
+ unsigned zslice;
+
+ void *loader_private;
+};
+
#ifndef __NOT_HAVE_DRM_H
static INLINE boolean
+++ /dev/null
-/*
- * Mesa 3-D graphics library
- * Version: 7.9
- *
- * Copyright (C) 2010 LunarG Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Chia-I Wu <olv@lunarg.com>
- */
-
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_debug.h"
-#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
-
-#include "dri_screen.h"
-#include "dri_context.h"
-#include "dri_drawable.h"
-#include "dri_st_api.h"
-
-static boolean
-dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
- const enum st_attachment_type *statts,
- unsigned count,
- struct pipe_resource **out)
-{
- 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;
-
- statt_mask = 0x0;
- for (i = 0; i < count; i++)
- statt_mask |= (1 << statts[i]);
-
- /* record newly allocated textures */
- new_mask = (statt_mask & ~drawable->texture_mask);
-
- /*
- * dPriv->pStamp is the server stamp. It should be accessed with a lock, at
- * least for DRI1. dPriv->lastStamp is the client stamp. It has the value
- * of the server stamp when last checked.
- */
- 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);
-
- screen->allocate_textures(drawable, statts, count);
-
- /* add existing textures */
- for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
- if (drawable->textures[i])
- statt_mask |= (1 << i);
- }
-
- drawable->texture_stamp = drawable->dPriv->lastStamp;
- drawable->texture_mask = statt_mask;
- }
-
- if (!out)
- return TRUE;
-
- for (i = 0; i < count; i++) {
- out[i] = NULL;
- pipe_resource_reference(&out[i], drawable->textures[statts[i]]);
- }
-
- return TRUE;
-}
-
-static boolean
-dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
- enum st_attachment_type statt)
-{
- struct dri_drawable *drawable =
- (struct dri_drawable *) stfbi->st_manager_private;
- struct dri_screen *screen = dri_screen(drawable->sPriv);
-
- /* XXX remove this and just set the correct one on the framebuffer */
- screen->flush_frontbuffer(drawable, statt);
-
- return TRUE;
-}
-
-/**
- * Init a framebuffer from the given drawable.
- */
-void
-dri_init_st_framebuffer(struct dri_drawable *drawable)
-{
- drawable->base.visual = &drawable->stvis;
- drawable->base.flush_front = dri_st_framebuffer_flush_front;
- drawable->base.validate = dri_st_framebuffer_validate;
- drawable->base.st_manager_private = (void *) drawable;
-}
-
-/**
- * Destroy a framebuffer.
- */
-void
-dri_close_st_framebuffer(struct dri_drawable *drawable)
-{
- int i;
-
- for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_resource_reference(&drawable->textures[i], NULL);
-}
-
-/**
- * Validate the texture at an attachment. Allocate the texture if it does not
- * exist.
- */
-void
-dri_st_framebuffer_validate_att(struct dri_drawable *drawable,
- enum st_attachment_type statt)
-{
- enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
- unsigned i, count = 0;
-
- /* check if buffer already exists */
- if (drawable->texture_mask & (1 << statt))
- return;
-
- /* make sure DRI2 does not destroy existing buffers */
- for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
- if (drawable->texture_mask & (1 << i)) {
- statts[count++] = i;
- }
- }
- statts[count++] = statt;
-
- drawable->texture_stamp = drawable->dPriv->lastStamp - 1;
-
- /* this calles into the manager */
- drawable->base.validate(&drawable->base, statts, count, NULL);
-}
-
-static boolean
-dri_st_manager_get_egl_image(struct st_manager *smapi,
- struct st_egl_image *stimg)
-{
- struct dri_context *ctx =
- (struct dri_context *)stimg->stctxi->st_manager_private;
- struct dri_screen *screen = dri_screen(ctx->sPriv);
- __DRIimage *img = NULL;
-
- if (screen->lookup_egl_image) {
- img = screen->lookup_egl_image(ctx, stimg->egl_image);
- }
-
- if (!img)
- return FALSE;
-
- stimg->texture = NULL;
- pipe_resource_reference(&stimg->texture, img->texture);
- stimg->face = img->face;
- stimg->level = img->level;
- stimg->zslice = img->zslice;
-
- return TRUE;
-}
-
-/**
- * Create a state tracker manager from the given screen.
- */
-boolean
-dri_init_st_manager(struct dri_screen *screen)
-{
- screen->base.screen = screen->pipe_screen;
- screen->base.get_egl_image = dri_st_manager_get_egl_image;
- screen->st_api = st_gl_api_create();
-
- if (!screen->st_api)
- return FALSE;
-
- return TRUE;
-}
-
-void
-dri_close_st_manager(struct dri_screen *screen)
-{
- if (screen->st_api && screen->st_api->destroy)
- screen->st_api->destroy(screen->st_api);
-}
+++ /dev/null
-/*
- * Mesa 3-D graphics library
- * Version: 7.9
- *
- * Copyright (C) 2010 LunarG Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Chia-I Wu <olv@lunarg.com>
- */
-
-#ifndef _DRI_ST_API_H_
-#define _DRI_ST_API_H_
-
-#include "state_tracker/st_api.h"
-
-struct dri_screen;
-struct dri_drawable;
-
-struct __DRIimageRec {
- struct pipe_resource *texture;
- unsigned face;
- unsigned level;
- unsigned zslice;
-
- void *loader_private;
-};
-
-boolean
-dri_init_st_manager(struct dri_screen *screen);
-
-void
-dri_close_st_manager(struct dri_screen *screen);
-
-void
-dri_init_st_framebuffer(struct dri_drawable *drawable);
-
-void
-dri_close_st_framebuffer(struct dri_drawable *drawable);
-
-void
-dri_st_framebuffer_validate_att(struct dri_drawable *drawable,
- enum st_attachment_type statt);
-
-#endif /* _DRI_ST_API_H_ */
dri_context.c \
dri_screen.c \
dri_drawable.c \
- dri_st_api.c \
dri1_helper.c \
dri1.c \
dri2.c
source = [ 'dri_context.c',
'dri_drawable.c',
'dri_screen.c',
- 'dri_st_api.c',
'dri1_helper.c',
'dri1.c',
'dri2.c',
{
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;
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;
{
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;
templ.bind = bind;
drawable->textures[statts[i]] =
- screen->pipe_screen->resource_create(screen->pipe_screen, &templ);
+ screen->base.screen->resource_create(screen->base.screen, &templ);
}
drawable->old_w = width;
#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"
struct dri_drawable *drawable = dri_drawable(dPriv);
struct pipe_resource *pt;
- dri_st_framebuffer_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT);
+ dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT);
pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
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);
}
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);
+++ /dev/null
-../common/dri_st_api.c
\ No newline at end of file
dri_context.c \
dri_screen.c \
dri_drawable.c \
- dri_st_api.c \
dri1_helper.c \
drisw.c
source = [ 'dri_context.c',
'dri_drawable.c',
'dri_screen.c',
- 'dri_st_api.c',
'dri1_helper.c',
'drisw.c',
]
+++ /dev/null
-../common/dri_st_api.c
\ No newline at end of file
if (!psurf)
return;
- screen->pipe_screen->flush_frontbuffer(screen->pipe_screen, psurf, drawable);
+ screen->base.screen->flush_frontbuffer(screen->base.screen, psurf, drawable);
}
static INLINE void
templ.bind = bind;
drawable->textures[statts[i]] =
- screen->pipe_screen->resource_create(screen->pipe_screen, &templ);
+ screen->base.screen->resource_create(screen->base.screen, &templ);
}
drawable->old_w = width;