summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c2
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.c13
-rw-r--r--src/gallium/state_trackers/egl_g3d/common/egl_g3d.c240
-rw-r--r--src/gallium/state_trackers/egl_g3d/common/egl_g3d.h5
-rw-r--r--src/gallium/state_trackers/egl_g3d/common/native.h51
-rw-r--r--src/gallium/state_trackers/egl_g3d/kms/native_kms.c58
-rw-r--r--src/gallium/state_trackers/egl_g3d/kms/native_kms.h1
-rw-r--r--src/gallium/state_trackers/egl_g3d/x11/native_dri2.c142
-rw-r--r--src/gallium/state_trackers/egl_g3d/x11/native_x11.c7
-rw-r--r--src/gallium/state_trackers/egl_g3d/x11/native_x11.h8
-rw-r--r--src/gallium/state_trackers/egl_g3d/x11/native_ximage.c100
-rw-r--r--src/gallium/state_trackers/egl_g3d/x11/x11_screen.c36
-rw-r--r--src/gallium/state_trackers/egl_g3d/x11/x11_screen.h3
-rw-r--r--src/gallium/state_trackers/glx/xlib/glx_getproc.c2
-rw-r--r--src/gallium/state_trackers/python/gallium.i1
-rw-r--r--src/gallium/state_trackers/python/p_context.i5
-rwxr-xr-xsrc/gallium/state_trackers/python/retrace/interpreter.py8
-rw-r--r--src/gallium/state_trackers/python/st_softpipe_winsys.c219
-rw-r--r--src/gallium/state_trackers/python/tests/regress/fragment-shader/.gitignore1
-rw-r--r--src/gallium/state_trackers/python/tests/regress/vertex-shader/.gitignore1
-rw-r--r--src/gallium/state_trackers/vega/api_filters.c16
-rw-r--r--src/gallium/state_trackers/vega/api_masks.c5
-rw-r--r--src/gallium/state_trackers/vega/mask.c32
-rw-r--r--src/gallium/state_trackers/vega/paint.c3
-rw-r--r--src/gallium/state_trackers/vega/polygon.c1
-rw-r--r--src/gallium/state_trackers/vega/shader.c16
-rw-r--r--src/gallium/state_trackers/vega/vg_context.c24
-rw-r--r--src/gallium/state_trackers/vega/vg_context.h8
-rw-r--r--src/gallium/state_trackers/vega/vg_tracker.c11
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c28
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.h4
-rw-r--r--src/gallium/state_trackers/xorg/xorg_xv.c9
32 files changed, 530 insertions, 530 deletions
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index f131e77..0fdfa96 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -180,6 +180,7 @@ dri_get_buffers(__DRIdrawable * dPriv)
switch (buffers[i].attachment) {
case __DRI_BUFFER_FRONT_LEFT:
+ continue;
case __DRI_BUFFER_FAKE_FRONT_LEFT:
index = ST_SURFACE_FRONT_LEFT;
format = drawable->color_format;
@@ -372,6 +373,7 @@ dri_create_buffer(__DRIscreen * sPriv,
/* TODO incase of double buffer visual, delay fake creation */
i = 0;
drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+ drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
if (visual->doubleBufferMode)
drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT;
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 793db08..d8c0543 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -83,7 +83,7 @@ dri_fill_in_modes(struct dri_screen *screen,
unsigned num_modes;
uint8_t depth_bits_array[5];
uint8_t stencil_bits_array[5];
- uint8_t msaa_samples_array[1];
+ uint8_t msaa_samples_array[2];
unsigned depth_buffer_factor;
unsigned back_buffer_factor;
unsigned msaa_samples_factor;
@@ -147,8 +147,9 @@ dri_fill_in_modes(struct dri_screen *screen,
}
msaa_samples_array[0] = 0;
+ msaa_samples_array[1] = 4;
back_buffer_factor = 3;
- msaa_samples_factor = 1;
+ msaa_samples_factor = 2;
num_modes =
depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
@@ -158,7 +159,7 @@ dri_fill_in_modes(struct dri_screen *screen,
depth_bits_array, stencil_bits_array,
depth_buffer_factor, back_buffer_modes,
back_buffer_factor,
- msaa_samples_array, 1);
+ msaa_samples_array, msaa_samples_factor);
} else {
__DRIconfig **configs_a8r8g8b8 = NULL;
__DRIconfig **configs_x8r8g8b8 = NULL;
@@ -170,7 +171,8 @@ dri_fill_in_modes(struct dri_screen *screen,
depth_buffer_factor,
back_buffer_modes,
back_buffer_factor,
- msaa_samples_array, 1);
+ msaa_samples_array,
+ msaa_samples_factor);
if (pf_x8r8g8b8)
configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
depth_bits_array,
@@ -178,7 +180,8 @@ dri_fill_in_modes(struct dri_screen *screen,
depth_buffer_factor,
back_buffer_modes,
back_buffer_factor,
- msaa_samples_array, 1);
+ msaa_samples_array,
+ msaa_samples_factor);
if (configs_a8r8g8b8 && configs_x8r8g8b8)
configs = driConcatConfigs(configs_x8r8g8b8, configs_a8r8g8b8);
diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
index 8b2e3b5..042e951 100644
--- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
@@ -24,7 +24,9 @@
#include <assert.h>
#include <string.h>
+#include "pipe/p_screen.h"
#include "util/u_memory.h"
+#include "util/u_rect.h"
#include "egldriver.h"
#include "eglcurrent.h"
#include "eglconfigutil.h"
@@ -43,8 +45,13 @@ egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx)
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
struct pipe_screen *screen = gdpy->native->screen;
struct egl_g3d_context *gctx = egl_g3d_context(ctx);
- EGLint num_surfaces;
- EGLint s, i;
+ const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = {
+ ST_SURFACE_FRONT_LEFT,
+ ST_SURFACE_BACK_LEFT,
+ ST_SURFACE_FRONT_RIGHT,
+ ST_SURFACE_BACK_RIGHT,
+ };
+ EGLint num_surfaces, s;
/* validate draw and/or read buffers */
num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2;
@@ -52,6 +59,7 @@ egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx)
struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
struct egl_g3d_surface *gsurf;
struct egl_g3d_buffer *gbuf;
+ EGLint att;
if (s == 0) {
gsurf = egl_g3d_surface(gctx->base.DrawSurface);
@@ -63,35 +71,33 @@ egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx)
}
if (!gctx->force_validate) {
- EGLint cur_w, cur_h;
-
- cur_w = gsurf->base.Width;
- cur_h = gsurf->base.Height;
- gsurf->native->validate(gsurf->native,
- gbuf->native_atts, gbuf->num_atts,
- NULL,
- &gsurf->base.Width, &gsurf->base.Height);
- /* validate only when the geometry changed */
- if (gsurf->base.Width == cur_w && gsurf->base.Height == cur_h)
+ unsigned int seq_num;
+
+ gsurf->native->validate(gsurf->native, gbuf->attachment_mask,
+ &seq_num, NULL, NULL, NULL);
+ /* skip validation */
+ if (gsurf->sequence_number == seq_num)
continue;
}
- gsurf->native->validate(gsurf->native,
- gbuf->native_atts, gbuf->num_atts,
- (struct pipe_texture **) textures,
+ pipe_surface_reference(&gsurf->render_surface, NULL);
+ memset(textures, 0, sizeof(textures));
+
+ gsurf->native->validate(gsurf->native, gbuf->attachment_mask,
+ &gsurf->sequence_number, textures,
&gsurf->base.Width, &gsurf->base.Height);
- for (i = 0; i < gbuf->num_atts; i++) {
- struct pipe_texture *pt = textures[i];
+ for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
+ struct pipe_texture *pt = textures[att];
struct pipe_surface *ps;
- if (pt) {
+ if (native_attachment_mask_test(gbuf->attachment_mask, att) && pt) {
ps = screen->get_tex_surface(screen, pt, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_READ |
PIPE_BUFFER_USAGE_GPU_WRITE);
gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb,
- gbuf->st_atts[i], ps);
+ st_att_map[att], ps);
- if (gbuf->native_atts[i] == gsurf->render_att)
+ if (gsurf->render_att == att)
pipe_surface_reference(&gsurf->render_surface, ps);
pipe_surface_reference(&ps, NULL);
@@ -130,13 +136,7 @@ static void
egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx)
{
struct egl_g3d_context *gctx = egl_g3d_context(ctx);
- const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = {
- ST_SURFACE_FRONT_LEFT,
- ST_SURFACE_BACK_LEFT,
- ST_SURFACE_FRONT_RIGHT,
- ST_SURFACE_BACK_RIGHT,
- };
- EGLint s, i;
+ EGLint s;
/* route draw and read buffers' attachments */
for (s = 0; s < 2; s++) {
@@ -152,11 +152,7 @@ egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx)
gbuf = &gctx->read;
}
- gbuf->native_atts[0] = gsurf->render_att;
- gbuf->num_atts = 1;
-
- for (i = 0; i < gbuf->num_atts; i++)
- gbuf->st_atts[i] = st_att_map[gbuf->native_atts[i]];
+ gbuf->attachment_mask = (1 << gsurf->render_att);
/* FIXME OpenGL defaults to draw the front or back buffer when the
* context is single-buffered or double-buffered respectively. In EGL,
@@ -198,19 +194,19 @@ egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx)
if (!gdraw || priv != (void *) &gdraw->base) {
gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb);
gctx->draw.st_fb = NULL;
- gctx->draw.num_atts = 0;
+ gctx->draw.attachment_mask = 0x0;
}
if (is_equal) {
gctx->read.st_fb = NULL;
- gctx->draw.num_atts = 0;
+ gctx->draw.attachment_mask = 0x0;
}
else {
priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb);
if (!gread || priv != (void *) &gread->base) {
gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb);
gctx->read.st_fb = NULL;
- gctx->draw.num_atts = 0;
+ gctx->draw.attachment_mask = 0x0;
}
}
}
@@ -459,16 +455,30 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id)
* Flush the front buffer of the context's draw surface.
*/
static void
-egl_g3d_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
- void *context_private)
+egl_g3d_flush_frontbuffer(struct pipe_screen *screen,
+ struct pipe_surface *surf, void *context_private)
{
struct egl_g3d_context *gctx = egl_g3d_context(context_private);
struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface);
- if (gsurf) {
+ if (gsurf)
gsurf->native->flush_frontbuffer(gsurf->native);
- egl_g3d_validate_context(gctx->base.Display, &gctx->base);
- }
+}
+
+/**
+ * Re-validate the context.
+ */
+static void
+egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private)
+{
+ struct egl_g3d_context *gctx = egl_g3d_context(context_private);
+
+ /**
+ * It is likely that the surface has changed when this function is called.
+ * Set force_validate to skip an unnecessary check.
+ */
+ gctx->force_validate = EGL_TRUE;
+ egl_g3d_validate_context(gctx->base.Display, &gctx->base);
}
static EGLBoolean
@@ -512,13 +522,15 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
}
dpy->DriverData = gdpy;
- gdpy->native =
- native_create_display(dpy->NativeDisplay, egl_g3d_flush_frontbuffer);
+ gdpy->native = native_create_display(dpy->NativeDisplay);
if (!gdpy->native) {
_eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)");
goto fail;
}
+ gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer;
+ gdpy->native->screen->update_buffer = egl_g3d_update_buffer;
+
dpy->ClientAPIsMask = gdrv->api_mask;
if (egl_g3d_add_configs(drv, dpy, 1) == 1) {
@@ -550,7 +562,7 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
_EGLContext *share, const EGLint *attribs)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
- struct egl_g3d_context *xshare = egl_g3d_context(share);
+ struct egl_g3d_context *gshare = egl_g3d_context(share);
struct egl_g3d_config *gconf = egl_g3d_config(conf);
struct egl_g3d_context *gctx;
const __GLcontextModes *mode;
@@ -575,8 +587,18 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
mode = &gconf->native->mode;
gctx->pipe =
gdpy->native->create_context(gdpy->native, (void *) &gctx->base);
+ if (!gctx->pipe) {
+ free(gctx);
+ return NULL;
+ }
+
gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode,
- (xshare) ? xshare->st_ctx : NULL);
+ (gshare) ? gshare->st_ctx : NULL);
+ if (!gctx->st_ctx) {
+ gctx->pipe->destroy(gctx->pipe);
+ free(gctx);
+ return NULL;
+ }
return &gctx->base;
}
@@ -599,6 +621,16 @@ egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
return EGL_TRUE;
}
+static EGLBoolean
+init_surface_geometry(_EGLSurface *surf)
+{
+ struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+
+ return gsurf->native->validate(gsurf->native, 0x0,
+ &gsurf->sequence_number, NULL,
+ &gsurf->base.Width, &gsurf->base.Height);
+}
+
static _EGLSurface *
egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLConfig *conf, EGLNativeWindowType win,
@@ -626,8 +658,7 @@ egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
- if (!gsurf->native->validate(gsurf->native, NULL, 0, NULL,
- &gsurf->base.Width, &gsurf->base.Height)) {
+ if (!init_surface_geometry(&gsurf->base)) {
gsurf->native->destroy(gsurf->native);
free(gsurf);
return NULL;
@@ -667,8 +698,7 @@ egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
- if (!gsurf->native->validate(gsurf->native, NULL, 0, NULL,
- &gsurf->base.Width, &gsurf->base.Height)) {
+ if (!init_surface_geometry(&gsurf->base)) {
gsurf->native->destroy(gsurf->native);
free(gsurf);
return NULL;
@@ -706,6 +736,12 @@ egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
+ if (!init_surface_geometry(&gsurf->base)) {
+ gsurf->native->destroy(gsurf->native);
+ free(gsurf);
+ return NULL;
+ }
+
gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ?
NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT;
@@ -817,14 +853,110 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config);
/* force validation if the swap method is not copy */
- if (gconf->native->mode.swapMethod != GLX_SWAP_COPY_OML)
+ if (gconf->native->mode.swapMethod != GLX_SWAP_COPY_OML) {
gctx->force_validate = EGL_TRUE;
- egl_g3d_validate_context(dpy, &gctx->base);
+ egl_g3d_validate_context(dpy, &gctx->base);
+ }
}
return EGL_TRUE;
}
+/**
+ * Find a config that supports the pixmap.
+ */
+static _EGLConfig *
+find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix)
+{
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+ struct egl_g3d_config *gconf;
+ EGLint i;
+
+ for (i = 0; i < dpy->NumConfigs; i++) {
+ gconf = egl_g3d_config(dpy->Configs[i]);
+ if (gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native))
+ break;
+ }
+
+ return (i < dpy->NumConfigs) ? &gconf->base : NULL;
+}
+
+/**
+ * Get the pipe surface of the given attachment of the native surface.
+ */
+static struct pipe_surface *
+get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf,
+ enum native_attachment natt)
+{
+ struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+ struct pipe_surface *psurf;
+
+ textures[natt] = NULL;
+ nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL);
+ if (!textures[natt])
+ return NULL;
+
+ psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt],
+ 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE);
+ pipe_texture_reference(&textures[natt], NULL);
+
+ return psurf;
+}
+
+static EGLBoolean
+egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+ NativePixmapType target)
+{
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+ struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+ _EGLContext *ctx = _eglGetCurrentContext();
+ struct egl_g3d_config *gconf;
+ struct native_surface *nsurf;
+ struct pipe_screen *screen = gdpy->native->screen;
+ struct pipe_surface *psurf;
+
+ if (!gsurf->render_surface)
+ return EGL_TRUE;
+
+ gconf = egl_g3d_config(find_pixmap_config(dpy, target));
+ if (!gconf)
+ return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers");
+
+ nsurf = gdpy->native->create_pixmap_surface(gdpy->native,
+ target, gconf->native);
+ if (!nsurf)
+ return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers");
+
+ /* flush if the surface is current */
+ if (ctx && ctx->DrawSurface == &gsurf->base) {
+ struct egl_g3d_context *gctx = egl_g3d_context(ctx);
+ gctx->stapi->st_flush(gctx->st_ctx,
+ PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
+ }
+
+ psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
+ if (psurf) {
+ struct pipe_context pipe;
+
+ /**
+ * XXX This is hacky. If we might allow the EGLDisplay to create a pipe
+ * context of its own and use the blitter context for this.
+ */
+ memset(&pipe, 0, sizeof(pipe));
+ pipe.screen = screen;
+
+ util_surface_copy(&pipe, FALSE, psurf, 0, 0,
+ gsurf->render_surface, 0, 0, psurf->width, psurf->height);
+
+ pipe_surface_reference(&psurf, NULL);
+ nsurf->flush_frontbuffer(nsurf);
+ }
+
+ nsurf->destroy(nsurf);
+
+ return EGL_TRUE;
+}
+
static EGLBoolean
egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
{
@@ -849,15 +981,14 @@ egl_g3d_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
}
static _EGLProc
-egl_g3d_get_proc_address(const char *procname)
+egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname)
{
- /* FIXME how come _EGLDriver is not passed? */
- const struct egl_g3d_st *stapi;
+ struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
_EGLProc proc;
EGLint i;
for (i = 0; i < NUM_EGL_G3D_STS; i++) {
- stapi = egl_g3d_get_st(i);
+ const struct egl_g3d_st *stapi = gdrv->stapis[i];
if (stapi) {
proc = (_EGLProc) stapi->st_get_proc_address(procname);
if (proc)
@@ -1079,6 +1210,7 @@ _eglMain(const char *args)
gdrv->base.API.DestroySurface = egl_g3d_destroy_surface;
gdrv->base.API.MakeCurrent = egl_g3d_make_current;
gdrv->base.API.SwapBuffers = egl_g3d_swap_buffers;
+ gdrv->base.API.CopyBuffers = egl_g3d_copy_buffers;
gdrv->base.API.WaitClient = egl_g3d_wait_client;
gdrv->base.API.WaitNative = egl_g3d_wait_native;
gdrv->base.API.GetProcAddress = egl_g3d_get_proc_address;
diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h
index 33894b6..1da8af4 100644
--- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h
+++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h
@@ -52,9 +52,7 @@ struct egl_g3d_display {
struct egl_g3d_buffer {
struct st_framebuffer *st_fb;
- EGLint num_atts;
- enum native_attachment native_atts[NUM_NATIVE_ATTACHMENTS];
- uint st_atts[NUM_NATIVE_ATTACHMENTS];
+ uint attachment_mask;
};
struct egl_g3d_context {
@@ -73,6 +71,7 @@ struct egl_g3d_surface {
struct native_surface *native;
enum native_attachment render_att;
struct pipe_surface *render_surface;
+ unsigned int sequence_number;
};
struct egl_g3d_config {
diff --git a/src/gallium/state_trackers/egl_g3d/common/native.h b/src/gallium/state_trackers/egl_g3d/common/native.h
index 88d87c6..f374f2e 100644
--- a/src/gallium/state_trackers/egl_g3d/common/native.h
+++ b/src/gallium/state_trackers/egl_g3d/common/native.h
@@ -64,13 +64,19 @@ struct native_surface {
boolean (*flush_frontbuffer)(struct native_surface *nsurf);
/**
- * Validate the buffers of the surface. Those not listed in the attachments
- * will be destroyed. The returned textures are owned by the caller.
+ * Validate the buffers of the surface. textures, if not NULL, points to an
+ * array of size NUM_NATIVE_ATTACHMENTS and the returned textures are owned
+ * by the caller. A sequence number is also returned. The caller can use
+ * it to check if anything has changed since the last call. Any of the
+ * pointers may be NULL and it indicates the caller has no interest in those
+ * values.
+ *
+ * If this function is called multiple times with different attachment
+ * masks, those not listed in the latest call might be destroyed. This
+ * behavior might change in the future.
*/
- boolean (*validate)(struct native_surface *nsurf,
- const enum native_attachment *natts,
- unsigned num_natts,
- struct pipe_texture **textures,
+ boolean (*validate)(struct native_surface *nsurf, uint attachment_mask,
+ unsigned int *seq_num, struct pipe_texture **textures,
int *width, int *height);
/**
@@ -80,6 +86,7 @@ struct native_surface {
};
struct native_config {
+ /* __GLcontextModes should go away some day */
__GLcontextModes mode;
enum pipe_format color_format;
enum pipe_format depth_format;
@@ -107,7 +114,14 @@ struct native_display_modeset;
* the native display server.
*/
struct native_display {
+ /**
+ * The pipe screen of the native display.
+ *
+ * Note that the "flush_frontbuffer" and "update_buffer" callbacks will be
+ * overridden.
+ */
struct pipe_screen *screen;
+
void (*destroy)(struct native_display *ndpy);
/**
@@ -122,6 +136,17 @@ struct native_display {
int *num_configs);
/**
+ * Test if a pixmap is supported by the given config. Required unless no
+ * config has GLX_PIXMAP_BIT set.
+ *
+ * This function is usually called to find a config that supports a given
+ * pixmap. Thus, it is usually called with the same pixmap in a row.
+ */
+ boolean (*is_pixmap_supported)(struct native_display *ndpy,
+ EGLNativePixmapType pix,
+ const struct native_config *nconf);
+
+ /**
* Create a pipe context.
*/
struct pipe_context *(*create_context)(struct native_display *ndpy,
@@ -197,15 +222,19 @@ struct native_display_modeset {
const struct native_mode *nmode);
};
-typedef void (*native_flush_frontbuffer)(void *dummy,
- struct pipe_surface *surf,
- void *context_private);
+/**
+ * Test whether an attachment is set in the mask.
+ */
+static INLINE boolean
+native_attachment_mask_test(uint mask, enum native_attachment att)
+{
+ return !!(mask & (1 << att));
+}
const char *
native_get_name(void);
struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- native_flush_frontbuffer flush_frontbuffer);
+native_create_display(EGLNativeDisplayType dpy);
#endif /* _NATIVE_H_ */
diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c
index 0e0babd..dc66436 100644
--- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c
+++ b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c
@@ -33,22 +33,17 @@
#include "native_kms.h"
static boolean
-kms_surface_validate(struct native_surface *nsurf,
- const enum native_attachment *natts,
- unsigned num_natts,
- struct pipe_texture **textures,
+kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
+ unsigned int *seq_num, struct pipe_texture **textures,
int *width, int *height)
{
struct kms_surface *ksurf = kms_surface(nsurf);
struct kms_display *kdpy = ksurf->kdpy;
struct pipe_screen *screen = kdpy->base.screen;
struct pipe_texture templ, *ptex;
- int i;
-
- if (num_natts) {
- if (textures)
- memset(textures, 0, sizeof(*textures) * num_natts);
+ int att;
+ if (attachment_mask) {
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
@@ -62,19 +57,25 @@ kms_surface_validate(struct native_surface *nsurf,
}
/* create textures */
- for (i = 0; i < num_natts; i++) {
- enum native_attachment natt = natts[i];
+ for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
+ /* delay the allocation */
+ if (!native_attachment_mask_test(attachment_mask, att))
+ continue;
- ptex = ksurf->textures[natt];
+ ptex = ksurf->textures[att];
if (!ptex) {
ptex = screen->texture_create(screen, &templ);
- ksurf->textures[natt] = ptex;
+ ksurf->textures[att] = ptex;
}
- if (textures)
- pipe_texture_reference(&textures[i], ptex);
+ if (textures) {
+ textures[att] = NULL;
+ pipe_texture_reference(&textures[att], ptex);
+ }
}
+ if (seq_num)
+ *seq_num = ksurf->sequence_number;
if (width)
*width = ksurf->width;
if (height)
@@ -111,7 +112,7 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
if (!fb->texture) {
/* make sure the texture has been allocated */
- kms_surface_validate(&ksurf->base, &natt, 1, NULL, NULL, NULL);
+ kms_surface_validate(&ksurf->base, 1 << natt, NULL, NULL, NULL, NULL);
if (!ksurf->textures[natt])
return FALSE;
@@ -196,6 +197,9 @@ kms_surface_swap_buffers(struct native_surface *nsurf)
ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT];
ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT] = tmp_texture;
+ /* the front/back textures are swapped */
+ ksurf->sequence_number++;
+
return TRUE;
}
@@ -764,8 +768,7 @@ static struct native_display_modeset kms_display_modeset = {
};
static struct native_display *
-kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api,
- native_flush_frontbuffer flush_frontbuffer)
+kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api)
{
struct kms_display *kdpy;
@@ -807,10 +810,6 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api,
return NULL;
}
- kdpy->base.screen->flush_frontbuffer =
- (void (*)(struct pipe_screen *, struct pipe_surface *, void *))
- flush_frontbuffer;
-
kdpy->base.destroy = kms_display_destroy;
kdpy->base.get_configs = kms_display_get_configs;
kdpy->base.create_context = kms_display_create_context;
@@ -821,13 +820,6 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api,
return &kdpy->base;
}
-static void
-dummy_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
- void *context_private)
-{
- _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied");
-}
-
/* the api is destroyed with the native display */
static struct drm_api *drm_api;
@@ -848,19 +840,15 @@ native_get_name(void)
}
struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- native_flush_frontbuffer flush_frontbuffer)
+native_create_display(EGLNativeDisplayType dpy)
{
struct native_display *ndpy = NULL;
if (!drm_api)
drm_api = drm_api_create();
- if (!flush_frontbuffer)
- flush_frontbuffer = dummy_flush_frontbuffer;
-
if (drm_api)
- ndpy = kms_create_display(dpy, drm_api, flush_frontbuffer);
+ ndpy = kms_create_display(dpy, drm_api);
return ndpy;
}
diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.h b/src/gallium/state_trackers/egl_g3d/kms/native_kms.h
index 3f869b2..095186e 100644
--- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.h
+++ b/src/gallium/state_trackers/egl_g3d/kms/native_kms.h
@@ -81,6 +81,7 @@ struct kms_surface {
int width, height;
struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+ unsigned int sequence_number;
struct kms_framebuffer front_fb, back_fb;
boolean is_shown;
diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c
index 0dda786..07f82d8 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c
@@ -64,6 +64,7 @@ struct dri2_surface {
struct pipe_texture *pbuffer_textures[NUM_NATIVE_ATTACHMENTS];
boolean have_back, have_fake;
int width, height;
+ unsigned int sequence_number;
};
struct dri2_config {
@@ -133,21 +134,18 @@ dri2_surface_swap_buffers(struct native_surface *nsurf)
}
static boolean
-dri2_surface_validate(struct native_surface *nsurf,
- const enum native_attachment *natts,
- unsigned num_natts,
- struct pipe_texture **textures,
- int *width, int *height)
+dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask,
+ unsigned int *seq_num, struct pipe_texture **textures,
+ int *width, int *height)
{
struct dri2_surface *dri2surf = dri2_surface(nsurf);
struct dri2_display *dri2dpy = dri2surf->dri2dpy;
unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS];
- EGLint texture_indices[NUM_NATIVE_ATTACHMENTS];
struct pipe_texture templ;
struct x11_drawable_buffer *xbufs;
- int num_ins, num_outs, i;
+ int num_ins, num_outs, att, i;
- if (num_natts) {
+ if (attachment_mask) {
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
@@ -158,26 +156,31 @@ dri2_surface_validate(struct native_surface *nsurf,
templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
if (textures)
- memset(textures, 0, sizeof(*textures) * num_natts);
+ memset(textures, 0, sizeof(*textures) * NUM_NATIVE_ATTACHMENTS);
}
/* create textures for pbuffer */
if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) {
struct pipe_screen *screen = dri2dpy->base.screen;
- for (i = 0; i < num_natts; i++) {
- enum native_attachment natt = natts[i];
- struct pipe_texture *ptex = dri2surf->pbuffer_textures[natt];
+ for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
+ struct pipe_texture *ptex = dri2surf->pbuffer_textures[att];
+
+ /* delay the allocation */
+ if (!native_attachment_mask_test(attachment_mask, att))
+ continue;
if (!ptex) {
ptex = screen->texture_create(screen, &templ);
- dri2surf->pbuffer_textures[natt] = ptex;
+ dri2surf->pbuffer_textures[att] = ptex;
}
if (textures)
- pipe_texture_reference(&textures[i], ptex);
+ pipe_texture_reference(&textures[att], ptex);
}
+ if (seq_num)
+ *seq_num = dri2surf->sequence_number;
if (width)
*width = dri2surf->width;
if (height)
@@ -186,48 +189,56 @@ dri2_surface_validate(struct native_surface *nsurf,
return TRUE;
}
- for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
- texture_indices[i] = -1;
-
/* prepare the attachments */
- num_ins = num_natts;
- for (i = 0; i < num_natts; i++) {
- unsigned int dri2att;
+ num_ins = 0;
+ for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
+ if (native_attachment_mask_test(attachment_mask, att)) {
+ unsigned int dri2att;
+
+ switch (att) {
+ case NATIVE_ATTACHMENT_FRONT_LEFT:
+ dri2att = DRI2BufferFrontLeft;
+ break;
+ case NATIVE_ATTACHMENT_BACK_LEFT:
+ dri2att = DRI2BufferBackLeft;
+ break;
+ case NATIVE_ATTACHMENT_FRONT_RIGHT:
+ dri2att = DRI2BufferFrontRight;
+ break;
+ case NATIVE_ATTACHMENT_BACK_RIGHT:
+ dri2att = DRI2BufferBackRight;
+ break;
+ default:
+ assert(0);
+ dri2att = 0;
+ break;
+ }
- switch (natts[i]) {
- case NATIVE_ATTACHMENT_FRONT_LEFT:
- dri2att = DRI2BufferFrontLeft;
- break;
- case NATIVE_ATTACHMENT_BACK_LEFT:
- dri2att = DRI2BufferBackLeft;
- break;
- case NATIVE_ATTACHMENT_FRONT_RIGHT:
- dri2att = DRI2BufferFrontRight;
- break;
- case NATIVE_ATTACHMENT_BACK_RIGHT:
- dri2att = DRI2BufferBackRight;
- break;
- default:
- assert(0);
- dri2att = 0;
- break;
+ dri2atts[num_ins] = dri2att;
+ num_ins++;
}
- dri2atts[i] = dri2att;
- texture_indices[natts[i]] = i;
}
dri2surf->have_back = FALSE;
dri2surf->have_fake = FALSE;
+ /* remember old geometry */
+ templ.width0 = dri2surf->width;
+ templ.height0 = dri2surf->height;
+
xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable,
&dri2surf->width, &dri2surf->height,
dri2atts, FALSE, num_ins, &num_outs);
if (!xbufs)
return FALSE;
- /* update width and height */
- templ.width0 = dri2surf->width;
- templ.height0 = dri2surf->height;
+ if (templ.width0 != dri2surf->width || templ.height0 != dri2surf->height) {
+ /* are there cases where the buffers change and the geometry doesn't? */
+ dri2surf->sequence_number++;
+
+ templ.width0 = dri2surf->width;
+ templ.height0 = dri2surf->height;
+ }
for (i = 0; i < num_outs; i++) {
struct x11_drawable_buffer *xbuf = &xbufs[i];
@@ -254,13 +265,13 @@ dri2_surface_validate(struct native_surface *nsurf,
break;
}
- if (!desc || texture_indices[natt] < 0 ||
- (textures && textures[texture_indices[natt]])) {
+ if (!desc || !native_attachment_mask_test(attachment_mask, natt) ||
+ (textures && textures[natt])) {
if (!desc)
_eglLog(_EGL_WARNING, "unknown buffer %d", xbuf->attachment);
- else if (texture_indices[natt] < 0)
+ else if (!native_attachment_mask_test(attachment_mask, natt))
_eglLog(_EGL_WARNING, "unexpected buffer %d", xbuf->attachment);
- else if (textures && textures[texture_indices[natt]])
+ else
_eglLog(_EGL_WARNING, "both real and fake front buffers are listed");
continue;
}
@@ -272,13 +283,15 @@ dri2_surface_validate(struct native_surface *nsurf,
desc, xbuf->pitch, xbuf->name);
if (ptex) {
/* the caller owns the textures */
- textures[texture_indices[natt]] = ptex;
+ textures[natt] = ptex;
}
}
}
free(xbufs);
+ if (seq_num)
+ *seq_num = dri2surf->sequence_number;
if (width)
*width = dri2surf->width;
if (height)
@@ -575,6 +588,21 @@ dri2_display_get_configs(struct native_display *ndpy, int *num_configs)
return configs;
}
+static boolean
+dri2_display_is_pixmap_supported(struct native_display *ndpy,
+ EGLNativePixmapType pix,
+ const struct native_config *nconf)
+{
+ struct dri2_display *dri2dpy = dri2_display(ndpy);
+ uint depth, nconf_depth;
+
+ depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix);
+ nconf_depth = util_format_get_blocksizebits(nconf->color_format);
+
+ /* simple depth match for now */
+ return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth));
+}
+
static void
dri2_display_destroy(struct native_display *ndpy)
{
@@ -627,18 +655,8 @@ dri2_display_init_screen(struct native_display *ndpy)
return TRUE;
}
-static void
-dri2_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
- void *context_private)
-{
- /* TODO get native surface from context private, and remove the callback */
- _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied");
-}
-
struct native_display *
-x11_create_dri2_display(EGLNativeDisplayType dpy,
- struct drm_api *api,
- native_flush_frontbuffer flush_frontbuffer)
+x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api)
{
struct dri2_display *dri2dpy;
@@ -675,15 +693,9 @@ x11_create_dri2_display(EGLNativeDisplayType dpy,
return NULL;
}
- if (!flush_frontbuffer)
- flush_frontbuffer = dri2_display_flush_frontbuffer;
-
- dri2dpy->base.screen->flush_frontbuffer =
- (void (*)(struct pipe_screen *, struct pipe_surface *, void *))
- flush_frontbuffer;
-
dri2dpy->base.destroy = dri2_display_destroy;
dri2dpy->base.get_configs = dri2_display_get_configs;
+ dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;
dri2dpy->base.create_context = dri2_display_create_context;
dri2dpy->base.create_window_surface = dri2_display_create_window_surface;
dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface;
diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c
index a4f36e9..583ce3d 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c
+++ b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c
@@ -48,8 +48,7 @@ native_get_name(void)
}
struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- native_flush_frontbuffer flush_frontbuffer)
+native_create_display(EGLNativeDisplayType dpy)
{
struct native_display *ndpy = NULL;
boolean force_sw;
@@ -59,14 +58,14 @@ native_create_display(EGLNativeDisplayType dpy,
force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE);
if (api && !force_sw) {
- ndpy = x11_create_dri2_display(dpy, api, flush_frontbuffer);
+ ndpy = x11_create_dri2_display(dpy, api);
}
if (!ndpy) {
EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING;
_eglLog(level, "use software fallback");
- ndpy = x11_create_ximage_display(dpy, TRUE, flush_frontbuffer);
+ ndpy = x11_create_ximage_display(dpy, TRUE);
}
return ndpy;
diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h b/src/gallium/state_trackers/egl_g3d/x11/native_x11.h
index 9217eb6..622ddac 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h
+++ b/src/gallium/state_trackers/egl_g3d/x11/native_x11.h
@@ -29,13 +29,9 @@
#include "common/native.h"
struct native_display *
-x11_create_ximage_display(EGLNativeDisplayType dpy,
- boolean use_xshm,
- native_flush_frontbuffer flush_frontbuffer);
+x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm);
struct native_display *
-x11_create_dri2_display(EGLNativeDisplayType dpy,
- struct drm_api *api,
- native_flush_frontbuffer flush_frontbuffer);
+x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api);
#endif /* _NATIVE_X11_H_ */
diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c
index e02faa9..d76107c 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c
+++ b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c
@@ -83,6 +83,7 @@ struct ximage_surface {
GC gc;
struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS];
+ unsigned int sequence_number;
};
struct ximage_config {
@@ -260,6 +261,9 @@ ximage_surface_swap_buffers(struct native_surface *nsurf)
*xfront = *xback;
*xback = xtmp;
+ /* the front/back textures are swapped */
+ xsurf->sequence_number++;
+
return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
}
@@ -285,33 +289,29 @@ ximage_surface_update_geometry(struct native_surface *nsurf)
}
static boolean
-ximage_surface_validate(struct native_surface *nsurf,
- const enum native_attachment *natts,
- unsigned num_natts,
- struct pipe_texture **textures,
- int *width, int *height)
+ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask,
+ unsigned int *seq_num, struct pipe_texture **textures,
+ int *width, int *height)
{
struct ximage_surface *xsurf = ximage_surface(nsurf);
- boolean error = FALSE;
- unsigned i;
+ boolean new_buffers = FALSE;
+ int att;
ximage_surface_update_geometry(&xsurf->base);
- if (textures)
- memset(textures, 0, sizeof(*textures) * num_natts);
-
- for (i = 0; i < num_natts; i++) {
- enum native_attachment natt = natts[i];
- struct ximage_buffer *xbuf = &xsurf->buffers[natt];
+ for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
+ struct ximage_buffer *xbuf = &xsurf->buffers[att];
- if (!xbuf)
+ /* delay the allocation */
+ if (!native_attachment_mask_test(attachment_mask, att))
continue;
/* reallocate the texture */
if (!xbuf->texture ||
xsurf->width != xbuf->texture->width0 ||
xsurf->height != xbuf->texture->height0) {
- if (ximage_surface_alloc_buffer(&xsurf->base, natt)) {
+ new_buffers = TRUE;
+ if (ximage_surface_alloc_buffer(&xsurf->base, att)) {
/* update ximage */
if (xbuf->ximage) {
xbuf->ximage->width = xbuf->transfer->width;
@@ -321,27 +321,24 @@ ximage_surface_validate(struct native_surface *nsurf,
}
}
- /* allocation failed */
- if (!xbuf->texture) {
- unsigned j;
- for (j = 0; j < i; j++)
- pipe_texture_reference(&textures[j], NULL);
- for (j = i; j < num_natts; j++)
- textures[j] = NULL;
- error = TRUE;
- break;
+ if (textures) {
+ textures[att] = NULL;
+ pipe_texture_reference(&textures[att], xbuf->texture);
}
-
- if (textures)
- pipe_texture_reference(&textures[i], xbuf->texture);
}
+ /* increase the sequence number so that caller knows */
+ if (new_buffers)
+ xsurf->sequence_number++;
+
+ if (seq_num)
+ *seq_num = xsurf->sequence_number;
if (width)
*width = xsurf->width;
if (height)
*height = xsurf->height;
- return !error;
+ return TRUE;
}
static void
@@ -603,6 +600,34 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs)
return configs;
}
+static boolean
+ximage_display_is_pixmap_supported(struct native_display *ndpy,
+ EGLNativePixmapType pix,
+ const struct native_config *nconf)
+{
+ struct ximage_display *xdpy = ximage_display(ndpy);
+ enum pipe_format fmt;
+ uint depth;
+
+ depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix);
+ switch (depth) {
+ case 32:
+ fmt = PIPE_FORMAT_A8R8G8B8_UNORM;
+ break;
+ case 24:
+ fmt = PIPE_FORMAT_X8R8G8B8_UNORM;
+ break;
+ case 16:
+ fmt = PIPE_FORMAT_R5G6B5_UNORM;
+ break;
+ default:
+ fmt = PIPE_FORMAT_NONE;
+ break;
+ }
+
+ return (fmt == nconf->color_format);
+}
+
static void
ximage_display_destroy(struct native_display *ndpy)
{
@@ -620,18 +645,8 @@ ximage_display_destroy(struct native_display *ndpy)
free(xdpy);
}
-static void
-ximage_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf,
- void *context_private)
-{
- /* TODO get native surface from context private, and remove the callback */
- _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied");
-}
-
struct native_display *
-x11_create_ximage_display(EGLNativeDisplayType dpy,
- boolean use_xshm,
- native_flush_frontbuffer flush_frontbuffer)
+x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm)
{
struct ximage_display *xdpy;
@@ -660,17 +675,12 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
(use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM));
xdpy->winsys = create_sw_winsys();
- if (!flush_frontbuffer)
- flush_frontbuffer = ximage_display_flush_frontbuffer;
- xdpy->winsys->flush_frontbuffer =
- (void (*)(struct pipe_winsys *, struct pipe_surface *, void *))
- flush_frontbuffer;
-
xdpy->base.screen = softpipe_create_screen(xdpy->winsys);
xdpy->base.destroy = ximage_display_destroy;
xdpy->base.get_configs = ximage_display_get_configs;
+ xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported;
xdpy->base.create_context = ximage_display_create_context;
xdpy->base.create_window_surface = ximage_display_create_window_surface;
xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface;
diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c
index 1e98943..4d68a88 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c
@@ -30,6 +30,7 @@
#include <X11/extensions/XShm.h>
#include "util/u_memory.h"
#include "util/u_math.h"
+#include "util/u_format.h"
#include "xf86drm.h"
#include "egllog.h"
@@ -50,6 +51,10 @@ struct x11_screen {
XVisualInfo *visuals;
int num_visuals;
+
+ /* cached values for x11_drawable_get_depth */
+ Drawable last_drawable;
+ unsigned int last_depth;
};
@@ -351,6 +356,37 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable,
}
/**
+ * Return the depth of a drawable.
+ *
+ * Unlike other drawable functions, the drawable needs not be a DRI2 drawable.
+ */
+uint
+x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable)
+{
+ unsigned int depth;
+
+ if (drawable != xscr->last_drawable) {
+ Window root;
+ int x, y;
+ unsigned int w, h, border;
+ Status ok;
+
+ ok = XGetGeometry(xscr->dpy, drawable, &root,
+ &x, &y, &w, &h, &border, &depth);
+ if (!ok)
+ depth = 0;
+
+ xscr->last_drawable = drawable;
+ xscr->last_depth = depth;
+ }
+ else {
+ depth = xscr->last_depth;
+ }
+
+ return depth;
+}
+
+/**
* Create a mode list of the given size.
*/
__GLcontextModes *
diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h
index 86e8e05..bf48218 100644
--- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h
+++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h
@@ -96,4 +96,7 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable,
int *width, int *height, unsigned int *attachments,
boolean with_format, int num_ins, int *num_outs);
+uint
+x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable);
+
#endif /* _X11_SCREEN_H_ */
diff --git a/src/gallium/state_trackers/glx/xlib/glx_getproc.c b/src/gallium/state_trackers/glx/xlib/glx_getproc.c
index 84d47b1..bd4a85c 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_getproc.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_getproc.c
@@ -193,7 +193,7 @@ _glxapi_get_proc_address(const char *funcName)
}
-__GLXextFuncPtr
+PUBLIC __GLXextFuncPtr
glXGetProcAddressARB(const GLubyte *procName)
{
__GLXextFuncPtr f;
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index 96b13c2..6879722 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -76,7 +76,6 @@
%rename(BlendColor) pipe_blend_color;
%rename(Blend) pipe_blend_state;
%rename(Clip) pipe_clip_state;
-%rename(ConstantBuffer) pipe_constant_buffer;
%rename(Depth) pipe_depth_state;
%rename(Stencil) pipe_stencil_state;
%rename(Alpha) pipe_alpha_state;
diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i
index 84ce1a4..ce893da 100644
--- a/src/gallium/state_trackers/python/p_context.i
+++ b/src/gallium/state_trackers/python/p_context.i
@@ -142,10 +142,7 @@ struct st_context {
void set_constant_buffer(unsigned shader, unsigned index,
struct pipe_buffer *buffer )
{
- struct pipe_constant_buffer state;
- memset(&state, 0, sizeof(state));
- state.buffer = buffer;
- $self->pipe->set_constant_buffer($self->pipe, shader, index, &state);
+ $self->pipe->set_constant_buffer($self->pipe, shader, index, buffer);
}
void set_framebuffer(const struct pipe_framebuffer_state *state )
diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py
index a68709f..b61d47d 100755
--- a/src/gallium/state_trackers/python/retrace/interpreter.py
+++ b/src/gallium/state_trackers/python/retrace/interpreter.py
@@ -94,7 +94,7 @@ struct_factories = {
"pipe_blend_color": gallium.BlendColor,
"pipe_blend_state": gallium.Blend,
#"pipe_clip_state": gallium.Clip,
- #"pipe_constant_buffer": gallium.ConstantBuffer,
+ #"pipe_buffer": gallium.Buffer,
"pipe_depth_state": gallium.Depth,
"pipe_stencil_state": gallium.Stencil,
"pipe_alpha_state": gallium.Alpha,
@@ -462,10 +462,10 @@ class Context(Object):
sys.stdout.flush()
def set_constant_buffer(self, shader, index, buffer):
- if buffer is not None and buffer.buffer is not None:
- self.real.set_constant_buffer(shader, index, buffer.buffer)
+ if buffer is not None:
+ self.real.set_constant_buffer(shader, index, buffer)
- self.dump_constant_buffer(buffer.buffer)
+ self.dump_constant_buffer(buffer)
def set_framebuffer_state(self, state):
_state = gallium.Framebuffer()
diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c
index a3294e8..dfe3e46 100644
--- a/src/gallium/state_trackers/python/st_softpipe_winsys.c
+++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c
@@ -35,225 +35,10 @@
* @author Jose Fonseca
*/
-
-#include "pipe/internal/p_winsys_screen.h"/* port to just p_screen */
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
#include "st_winsys.h"
-
-struct st_softpipe_buffer
-{
- struct pipe_buffer base;
- boolean userBuffer; /** Is this a user-space buffer? */
- void *data;
- void *mapped;
-};
-
-
-/** Cast wrapper */
-static INLINE struct st_softpipe_buffer *
-st_softpipe_buffer( struct pipe_buffer *buf )
-{
- return (struct st_softpipe_buffer *)buf;
-}
-
-
-static void *
-st_softpipe_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags)
-{
- struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf);
- st_softpipe_buf->mapped = st_softpipe_buf->data;
- return st_softpipe_buf->mapped;
-}
-
-
-static void
-st_softpipe_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf);
- st_softpipe_buf->mapped = NULL;
-}
-
-
-static void
-st_softpipe_buffer_destroy(struct pipe_buffer *buf)
-{
- struct st_softpipe_buffer *oldBuf = st_softpipe_buffer(buf);
-
- if (oldBuf->data) {
- if (!oldBuf->userBuffer)
- align_free(oldBuf->data);
-
- oldBuf->data = NULL;
- }
-
- FREE(oldBuf);
-}
-
-
-static void
-st_softpipe_flush_frontbuffer(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
-{
-}
-
-
-
-static const char *
-st_softpipe_get_name(struct pipe_winsys *winsys)
-{
- return "softpipe";
-}
-
-
-static struct pipe_buffer *
-st_softpipe_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct st_softpipe_buffer *buffer = CALLOC_STRUCT(st_softpipe_buffer);
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- buffer->data = align_malloc(size, alignment);
-
- return &buffer->base;
-}
-
-
-/**
- * Create buffer which wraps user-space data.
- */
-static struct pipe_buffer *
-st_softpipe_user_buffer_create(struct pipe_winsys *winsys,
- void *ptr,
- unsigned bytes)
-{
- struct st_softpipe_buffer *buffer;
-
- buffer = CALLOC_STRUCT(st_softpipe_buffer);
- if(!buffer)
- return NULL;
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.size = bytes;
- buffer->userBuffer = TRUE;
- buffer->data = ptr;
-
- return &buffer->base;
-}
-
-
-static struct pipe_buffer *
-st_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride)
-{
- const unsigned alignment = 64;
- unsigned nblocksy;
-
- nblocksy = util_format_get_nblocksy(format, height);
- *stride = align(util_format_get_stride(format, width), alignment);
-
- return winsys->buffer_create(winsys, alignment,
- usage,
- *stride * nblocksy);
-}
-
-
-static void
-st_softpipe_fence_reference(struct pipe_winsys *winsys,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
-}
-
-
-static int
-st_softpipe_fence_signalled(struct pipe_winsys *winsys,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- return 0;
-}
-
-
-static int
-st_softpipe_fence_finish(struct pipe_winsys *winsys,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- return 0;
-}
-
-
-static void
-st_softpipe_destroy(struct pipe_winsys *winsys)
-{
- FREE(winsys);
-}
-
-
-static struct pipe_screen *
-st_softpipe_screen_create(void)
-{
- static struct pipe_winsys *winsys;
- struct pipe_screen *screen;
-
- winsys = CALLOC_STRUCT(pipe_winsys);
- if(!winsys)
- return NULL;
-
- winsys->destroy = st_softpipe_destroy;
-
- winsys->buffer_create = st_softpipe_buffer_create;
- winsys->user_buffer_create = st_softpipe_user_buffer_create;
- winsys->buffer_map = st_softpipe_buffer_map;
- winsys->buffer_unmap = st_softpipe_buffer_unmap;
- winsys->buffer_destroy = st_softpipe_buffer_destroy;
-
- winsys->surface_buffer_create = st_softpipe_surface_buffer_create;
-
- winsys->fence_reference = st_softpipe_fence_reference;
- winsys->fence_signalled = st_softpipe_fence_signalled;
- winsys->fence_finish = st_softpipe_fence_finish;
-
- winsys->flush_frontbuffer = st_softpipe_flush_frontbuffer;
- winsys->get_name = st_softpipe_get_name;
-
- screen = softpipe_create_screen(winsys);
- if(!screen)
- st_softpipe_destroy(winsys);
-
- return screen;
-}
-
-
-static struct pipe_context *
-st_softpipe_context_create(struct pipe_screen *screen)
-{
- return softpipe_create(screen);
-}
-
-
const struct st_winsys st_softpipe_winsys = {
- &st_softpipe_screen_create,
- &st_softpipe_context_create,
+ &softpipe_create_screen_malloc,
+ &softpipe_create,
};
diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/.gitignore b/src/gallium/state_trackers/python/tests/regress/fragment-shader/.gitignore
new file mode 100644
index 0000000..e33609d
--- /dev/null
+++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/.gitignore
@@ -0,0 +1 @@
+*.png
diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/.gitignore b/src/gallium/state_trackers/python/tests/regress/vertex-shader/.gitignore
new file mode 100644
index 0000000..e33609d
--- /dev/null
+++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/.gitignore
@@ -0,0 +1 @@
+*.png
diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c
index 2f984fb..8f69ee0 100644
--- a/src/gallium/state_trackers/vega/api_filters.c
+++ b/src/gallium/state_trackers/vega/api_filters.c
@@ -147,22 +147,22 @@ static void setup_constant_buffer(struct vg_context *ctx, const void *buffer,
VGint param_bytes)
{
struct pipe_context *pipe = ctx->pipe;
- struct pipe_constant_buffer *cbuf = &ctx->filter.buffer;
+ struct pipe_buffer **cbuf = &ctx->filter.buffer;
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization. */
- pipe_buffer_reference(&cbuf->buffer, NULL);
+ pipe_buffer_reference(cbuf, NULL);
- cbuf->buffer = pipe_buffer_create(pipe->screen, 16,
- PIPE_BUFFER_USAGE_CONSTANT,
- param_bytes);
+ *cbuf = pipe_buffer_create(pipe->screen, 16,
+ PIPE_BUFFER_USAGE_CONSTANT,
+ param_bytes);
- if (cbuf->buffer) {
- st_no_flush_pipe_buffer_write(ctx, cbuf->buffer,
+ if (*cbuf) {
+ st_no_flush_pipe_buffer_write(ctx, *cbuf,
0, param_bytes, buffer);
}
- ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
+ ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
}
static void setup_samplers(struct vg_context *ctx, struct filter_info *info)
diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c
index 4f9f3da..97cbe69 100644
--- a/src/gallium/state_trackers/vega/api_masks.c
+++ b/src/gallium/state_trackers/vega/api_masks.c
@@ -32,7 +32,6 @@
#include "vg_context.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
-#include "pipe/internal/p_winsys_screen.h" /* for winsys->update_buffer */
#include "util/u_pack_color.h"
#include "util/u_draw_quad.h"
@@ -116,8 +115,8 @@ clear_with_quad(struct vg_context *st, float x0, float y0,
x1, y1);
*/
- if (st->pipe->winsys && st->pipe->winsys->update_buffer)
- st->pipe->winsys->update_buffer( st->pipe->winsys,
+ if (st->pipe->screen && st->pipe->screen->update_buffer)
+ st->pipe->screen->update_buffer( st->pipe->screen,
st->pipe->priv );
cso_save_blend(st->cso_context);
diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c
index 42300bb..3e260e7 100644
--- a/src/gallium/state_trackers/vega/mask.c
+++ b/src/gallium/state_trackers/vega/mask.c
@@ -217,7 +217,7 @@ static void setup_mask_framebuffer(struct pipe_surface *surf,
static void setup_mask_operation(VGMaskOperation operation)
{
struct vg_context *ctx = vg_current_context();
- struct pipe_constant_buffer *cbuf = &ctx->mask.cbuf;
+ struct pipe_buffer **cbuf = &ctx->mask.cbuf;
const VGint param_bytes = 4 * sizeof(VGfloat);
const VGfloat ones[4] = {1.f, 1.f, 1.f, 1.f};
void *shader = 0;
@@ -225,17 +225,17 @@ static void setup_mask_operation(VGMaskOperation operation)
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization.
*/
- pipe_buffer_reference(&cbuf->buffer, NULL);
+ pipe_buffer_reference(cbuf, NULL);
- cbuf->buffer = pipe_buffer_create(ctx->pipe->screen, 1,
- PIPE_BUFFER_USAGE_CONSTANT,
- param_bytes);
- if (cbuf->buffer) {
- st_no_flush_pipe_buffer_write(ctx, cbuf->buffer,
+ *cbuf = pipe_buffer_create(ctx->pipe->screen, 1,
+ PIPE_BUFFER_USAGE_CONSTANT,
+ param_bytes);
+ if (*cbuf) {
+ st_no_flush_pipe_buffer_write(ctx, *cbuf,
0, param_bytes, ones);
}
- ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
+ ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
switch (operation) {
case VG_UNION_MASK: {
if (!ctx->mask.union_fs) {
@@ -320,22 +320,22 @@ static void setup_mask_samplers(struct pipe_texture *umask)
static void setup_mask_fill(const VGfloat color[4])
{
struct vg_context *ctx = vg_current_context();
- struct pipe_constant_buffer *cbuf = &ctx->mask.cbuf;
+ struct pipe_buffer **cbuf = &ctx->mask.cbuf;
const VGint param_bytes = 4 * sizeof(VGfloat);
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization.
*/
- pipe_buffer_reference(&cbuf->buffer, NULL);
+ pipe_buffer_reference(cbuf, NULL);
- cbuf->buffer = pipe_buffer_create(ctx->pipe->screen, 1,
- PIPE_BUFFER_USAGE_CONSTANT,
- param_bytes);
- if (cbuf->buffer) {
- st_no_flush_pipe_buffer_write(ctx, cbuf->buffer, 0, param_bytes, color);
+ *cbuf = pipe_buffer_create(ctx->pipe->screen, 1,
+ PIPE_BUFFER_USAGE_CONSTANT,
+ param_bytes);
+ if (*cbuf) {
+ st_no_flush_pipe_buffer_write(ctx, *cbuf, 0, param_bytes, color);
}
- ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
+ ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
cso_set_fragment_shader_handle(ctx->cso_context,
shaders_cache_fill(ctx->sc,
VEGA_SOLID_FILL_SHADER));
diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c
index cc73771..d8f6299 100644
--- a/src/gallium/state_trackers/vega/paint.c
+++ b/src/gallium/state_trackers/vega/paint.c
@@ -77,7 +77,8 @@ struct vg_paint {
struct pipe_sampler_state sampler;
} pattern;
- struct pipe_constant_buffer cbuf;
+ /* XXX next 3 all unneded? */
+ struct pipe_buffer *cbuf;
struct pipe_shader_state fs_state;
void *fs;
};
diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c
index b6d282d..d385ee5 100644
--- a/src/gallium/state_trackers/vega/polygon.c
+++ b/src/gallium/state_trackers/vega/polygon.c
@@ -293,6 +293,7 @@ static void draw_polygon(struct vg_context *ctx,
/* tell pipe about the vertex attributes */
velement.src_offset = 0;
+ velement.instance_divisor = 0;
velement.vertex_buffer_index = 0;
velement.src_format = PIPE_FORMAT_R32G32_FLOAT;
velement.nr_components = COMPONENTS;
diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c
index d9074a3..bd5ae79 100644
--- a/src/gallium/state_trackers/vega/shader.c
+++ b/src/gallium/state_trackers/vega/shader.c
@@ -51,7 +51,7 @@ struct shader {
VGImageMode image_mode;
float constants[MAX_CONSTANTS];
- struct pipe_constant_buffer cbuf;
+ struct pipe_buffer *cbuf;
struct pipe_shader_state fs_state;
void *fs;
};
@@ -96,25 +96,25 @@ static void setup_constant_buffer(struct shader *shader)
{
struct vg_context *ctx = shader->context;
struct pipe_context *pipe = shader->context->pipe;
- struct pipe_constant_buffer *cbuf = &shader->cbuf;
+ struct pipe_buffer **cbuf = &shader->cbuf;
VGint param_bytes = paint_constant_buffer_size(shader->paint);
float temp_buf[MAX_CONSTANTS];
assert(param_bytes <= sizeof(temp_buf));
paint_fill_constant_buffer(shader->paint, temp_buf);
- if (cbuf->buffer == NULL ||
+ if (*cbuf == NULL ||
memcmp(temp_buf, shader->constants, param_bytes) != 0)
{
- pipe_buffer_reference(&cbuf->buffer, NULL);
+ pipe_buffer_reference(cbuf, NULL);
memcpy(shader->constants, temp_buf, param_bytes);
- cbuf->buffer = pipe_user_buffer_create(pipe->screen,
- &shader->constants,
- sizeof(shader->constants));
+ *cbuf = pipe_user_buffer_create(pipe->screen,
+ &shader->constants,
+ sizeof(shader->constants));
}
- ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, cbuf);
+ ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
}
static VGint blend_bind_samplers(struct vg_context *ctx,
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c
index 00d23f5..c16ac03 100644
--- a/src/gallium/state_trackers/vega/vg_context.c
+++ b/src/gallium/state_trackers/vega/vg_context.c
@@ -122,8 +122,8 @@ struct vg_context * vg_create_context(struct pipe_context *pipe,
void vg_destroy_context(struct vg_context *ctx)
{
- struct pipe_constant_buffer *cbuf = &ctx->mask.cbuf;
- struct pipe_constant_buffer *vsbuf = &ctx->vs_const_buffer;
+ struct pipe_buffer **cbuf = &ctx->mask.cbuf;
+ struct pipe_buffer **vsbuf = &ctx->vs_const_buffer;
util_destroy_blit(ctx->blit);
renderer_destroy(ctx->renderer);
@@ -131,11 +131,11 @@ void vg_destroy_context(struct vg_context *ctx)
shader_destroy(ctx->shader);
paint_destroy(ctx->default_paint);
- if (cbuf && cbuf->buffer)
- pipe_buffer_reference(&cbuf->buffer, NULL);
+ if (*cbuf)
+ pipe_buffer_reference(cbuf, NULL);
- if (vsbuf && vsbuf->buffer)
- pipe_buffer_reference(&vsbuf->buffer, NULL);
+ if (*vsbuf)
+ pipe_buffer_reference(vsbuf, NULL);
if (ctx->clear.fs) {
cso_delete_fragment_shader(ctx->cso_context, ctx->clear.fs);
@@ -371,20 +371,20 @@ void vg_validate_state(struct vg_context *ctx)
2.f/fb->width, 2.f/fb->height, 1, 1,
-1, -1, 0, 0
};
- struct pipe_constant_buffer *cbuf = &ctx->vs_const_buffer;
+ struct pipe_buffer **cbuf = &ctx->vs_const_buffer;
vg_set_viewport(ctx, VEGA_Y0_BOTTOM);
- pipe_buffer_reference(&cbuf->buffer, NULL);
- cbuf->buffer = pipe_buffer_create(ctx->pipe->screen, 16,
+ pipe_buffer_reference(cbuf, NULL);
+ *cbuf = pipe_buffer_create(ctx->pipe->screen, 16,
PIPE_BUFFER_USAGE_CONSTANT,
param_bytes);
- if (cbuf->buffer) {
- st_no_flush_pipe_buffer_write(ctx, cbuf->buffer,
+ if (*cbuf) {
+ st_no_flush_pipe_buffer_write(ctx, *cbuf,
0, param_bytes, vs_consts);
}
- ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, cbuf);
+ ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, *cbuf);
}
if ((ctx->state.dirty & VS_DIRTY)) {
cso_set_vertex_shader_handle(ctx->cso_context,
diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h
index ccc8889..bc88c8d 100644
--- a/src/gallium/state_trackers/vega/vg_context.h
+++ b/src/gallium/state_trackers/vega/vg_context.h
@@ -50,7 +50,7 @@ struct st_renderbuffer {
};
struct st_framebuffer {
- VGint init_width, init_height;
+ VGint width, height;
struct st_renderbuffer *strb;
struct st_renderbuffer *dsrb;
@@ -113,7 +113,7 @@ struct vg_context
} clear;
struct {
- struct pipe_constant_buffer cbuf;
+ struct pipe_buffer *cbuf;
struct pipe_sampler_state sampler;
struct vg_shader *union_fs;
@@ -135,7 +135,7 @@ struct vg_context
struct pipe_sampler_state blend_sampler;
struct {
- struct pipe_constant_buffer buffer;
+ struct pipe_buffer *buffer;
void *color_matrix_fs;
} filter;
struct vg_paint *default_paint;
@@ -145,7 +145,7 @@ struct vg_context
struct vg_shader *plain_vs;
struct vg_shader *clear_vs;
struct vg_shader *texture_vs;
- struct pipe_constant_buffer vs_const_buffer;
+ struct pipe_buffer *vs_const_buffer;
};
struct vg_object {
diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c
index ff80aab..617c174 100644
--- a/src/gallium/state_trackers/vega/vg_tracker.c
+++ b/src/gallium/state_trackers/vega/vg_tracker.c
@@ -193,8 +193,8 @@ struct st_framebuffer * st_create_framebuffer(const void *visual,
*/
stfb->alpha_mask = 0;
- stfb->init_width = width;
- stfb->init_height = height;
+ stfb->width = width;
+ stfb->height = height;
stfb->privateData = privateData;
}
@@ -282,11 +282,14 @@ void st_resize_framebuffer(struct st_framebuffer *stfb,
/* If this is a noop, exit early and don't do the clear, etc below.
*/
- if (strb->width == width &&
- strb->height == height &&
+ if (stfb->width == width &&
+ stfb->height == height &&
state->zsbuf)
return;
+ stfb->width = width;
+ stfb->height = height;
+
if (strb->width != width || strb->height != height)
st_renderbuffer_alloc_storage(ctx, strb,
width, height);
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index d80f341..8f729b5 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -379,14 +379,14 @@ struct xorg_renderer * renderer_create(struct pipe_context *pipe)
void renderer_destroy(struct xorg_renderer *r)
{
- struct pipe_constant_buffer *vsbuf = &r->vs_const_buffer;
- struct pipe_constant_buffer *fsbuf = &r->fs_const_buffer;
+ struct pipe_buffer **vsbuf = &r->vs_const_buffer;
+ struct pipe_buffer **fsbuf = &r->fs_const_buffer;
- if (vsbuf && vsbuf->buffer)
- pipe_buffer_reference(&vsbuf->buffer, NULL);
+ if (*vsbuf)
+ pipe_buffer_reference(vsbuf, NULL);
- if (fsbuf && fsbuf->buffer)
- pipe_buffer_reference(&fsbuf->buffer, NULL);
+ if (*fsbuf)
+ pipe_buffer_reference(fsbuf, NULL);
if (r->shaders) {
xorg_shaders_destroy(r->shaders);
@@ -409,20 +409,20 @@ void renderer_set_constants(struct xorg_renderer *r,
const float *params,
int param_bytes)
{
- struct pipe_constant_buffer *cbuf =
+ struct pipe_buffer **cbuf =
(shader_type == PIPE_SHADER_VERTEX) ? &r->vs_const_buffer :
&r->fs_const_buffer;
- pipe_buffer_reference(&cbuf->buffer, NULL);
- cbuf->buffer = pipe_buffer_create(r->pipe->screen, 16,
- PIPE_BUFFER_USAGE_CONSTANT,
- param_bytes);
+ pipe_buffer_reference(cbuf, NULL);
+ *cbuf = pipe_buffer_create(r->pipe->screen, 16,
+ PIPE_BUFFER_USAGE_CONSTANT,
+ param_bytes);
- if (cbuf->buffer) {
- pipe_buffer_write(r->pipe->screen, cbuf->buffer,
+ if (*cbuf) {
+ pipe_buffer_write(r->pipe->screen, *cbuf,
0, param_bytes, params);
}
- r->pipe->set_constant_buffer(r->pipe, shader_type, 0, cbuf);
+ r->pipe->set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
}
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h
index 5272cde..af6aa05 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.h
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.h
@@ -23,8 +23,8 @@ struct xorg_renderer {
int fb_width;
int fb_height;
- struct pipe_constant_buffer vs_const_buffer;
- struct pipe_constant_buffer fs_const_buffer;
+ struct pipe_buffer *vs_const_buffer;
+ struct pipe_buffer *fs_const_buffer;
float buffer[BUF_SIZE];
int buffer_size;
diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index 6b5a41a..5bf0e94 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -486,8 +486,11 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
int dxo, dyo;
Bool hdtv;
int x, y, w, h;
- struct exa_pixmap_priv *dst = exaGetPixmapDriverPrivate(pPixmap);
- struct pipe_surface *dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
+ struct exa_pixmap_priv *dst;
+ struct pipe_surface *dst_surf = NULL;
+
+ exaMoveInPixmap(pPixmap);
+ dst = exaGetPixmapDriverPrivate(pPixmap);
if (dst && !dst->tex) {
xorg_exa_set_shared_usage(pPixmap);
@@ -497,6 +500,7 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
if (!dst || !dst->tex)
XORG_FALLBACK("Xv destination %s", !dst ? "!dst" : "!dst->tex");
+ dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y));
REGION_TRANSLATE(pScrn->pScreen, dstRegion, -pPixmap->screen_x,
@@ -516,7 +520,6 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
bind_samplers(pPriv);
setup_fs_video_constants(pPriv->r, hdtv);
- exaMoveInPixmap(pPixmap);
DamageDamageRegion(&pPixmap->drawable, dstRegion);
while (nbox--) {