Commit e9569775 authored by Jakob Bornecrantz's avatar Jakob Bornecrantz

i915: Create a texture and surface for shared frontbuffer

parent 19dad109
...@@ -38,10 +38,69 @@ ...@@ -38,10 +38,69 @@
#include "intel_drm/ws_dri_bufpool.h" #include "intel_drm/ws_dri_bufpool.h"
#include "pipe/p_context.h" #include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "pipe/p_inlines.h"
#include "state_tracker/st_public.h" #include "state_tracker/st_public.h"
#include "state_tracker/st_cb_fbo.h" #include "state_tracker/st_cb_fbo.h"
static void
intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys, unsigned handle);
static void
intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys, unsigned handle)
{
struct intel_be_buffer *be_buf = malloc(sizeof(*be_buf));
struct pipe_screen *screen = intelScreen->base.screen;
struct pipe_texture *texture;
struct pipe_texture templat;
struct pipe_surface *surface;
struct pipe_buffer *buffer = &be_buf->base;
unsigned pitch;
assert(intelScreen->front.cpp == 4);
/* XXX create a intel_be function for this */
{
driGenBuffers(intelScreen->base.staticPool, "front", 1, &intelScreen->front.buffer, 0, 0, 0);
driBOSetReferenced(intelScreen->front.buffer, handle);
memset(be_buf, 0, sizeof(*be_buf));
buffer->refcount = 1;
buffer->alignment = 0;
buffer->usage = 0;
buffer->size = driBOSize(intelScreen->front.buffer);
be_buf->driBO = intelScreen->front.buffer;
}
memset(&templat, 0, sizeof(templat));
templat.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
templat.target = PIPE_TEXTURE_2D;
templat.last_level = 0;
templat.depth[0] = 1;
templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
templat.cpp = intelScreen->front.cpp;
templat.width[0] = intelScreen->front.width;
templat.height[0] = intelScreen->front.height;
pitch = intelScreen->front.pitch / intelScreen->front.cpp;
texture = screen->texture_blanket(screen,
&templat,
&pitch,
buffer);
/* Unref the buffer we don't need it anyways */
pipe_buffer_reference(screen->winsys, &buffer, NULL);
surface = screen->get_tex_surface(screen,
texture,
0,
0,
0,
PIPE_BUFFER_USAGE_GPU_WRITE);
intelScreen->front.texture = texture;
intelScreen->front.surface = surface;
}
PUBLIC const char __driConfigOptions[] = PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
...@@ -157,10 +216,12 @@ intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea) ...@@ -157,10 +216,12 @@ intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea)
} }
#else #else
if (intelScreen->base.staticPool) { if (intelScreen->base.staticPool) {
if (intelScreen->front.buffer) if (intelScreen->front.buffer) {
driBOUnReference(intelScreen->front.buffer); driBOUnReference(intelScreen->front.buffer);
driGenBuffers(intelScreen->base.staticPool, "front", 1, &intelScreen->front.buffer, 0, 0, 0); pipe_surface_reference(&intelScreen->front.surface, NULL);
driBOSetReferenced(intelScreen->front.buffer, sarea->front_bo_handle); pipe_texture_reference(&intelScreen->front.texture, NULL);
}
intelCreateSurface(intelScreen, &intelScreen->base.base, sarea->front_bo_handle);
} }
#endif #endif
} }
......
...@@ -47,6 +47,8 @@ struct intel_screen ...@@ -47,6 +47,8 @@ struct intel_screen
/* We create a static dri buffer for the frontbuffer. /* We create a static dri buffer for the frontbuffer.
*/ */
struct _DriBufferObject *buffer; struct _DriBufferObject *buffer;
struct pipe_surface *surface;
struct pipe_texture *texture;
char *map; /* memory map */ char *map; /* memory map */
int offset; /* from start of video mem, in bytes */ int offset; /* from start of video mem, in bytes */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment