i915g: Reorg texture code a bit
This commit is contained in:
@@ -44,10 +44,12 @@
|
|||||||
#include "i915_screen.h"
|
#include "i915_screen.h"
|
||||||
#include "i915_winsys.h"
|
#include "i915_winsys.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function and arrays
|
* Helper function and arrays
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial offset for Cube map.
|
* Initial offset for Cube map.
|
||||||
*/
|
*/
|
||||||
@@ -487,7 +489,6 @@ i915_miptree_layout(struct i915_texture * tex)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
i945_miptree_layout(struct i915_texture * tex)
|
i945_miptree_layout(struct i915_texture * tex)
|
||||||
{
|
{
|
||||||
@@ -575,6 +576,11 @@ i945_miptree_layout(struct i915_texture * tex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Screen texture functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
static struct pipe_texture *
|
static struct pipe_texture *
|
||||||
i915_texture_create(struct pipe_screen *screen,
|
i915_texture_create(struct pipe_screen *screen,
|
||||||
const struct pipe_texture *templat)
|
const struct pipe_texture *templat)
|
||||||
@@ -629,6 +635,39 @@ fail:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct pipe_texture *
|
||||||
|
i915_texture_blanket(struct pipe_screen * screen,
|
||||||
|
const struct pipe_texture *base,
|
||||||
|
const unsigned *stride,
|
||||||
|
struct pipe_buffer *buffer)
|
||||||
|
{
|
||||||
|
struct i915_texture *tex;
|
||||||
|
assert(screen);
|
||||||
|
|
||||||
|
/* Only supports one type */
|
||||||
|
if (base->target != PIPE_TEXTURE_2D ||
|
||||||
|
base->last_level != 0 ||
|
||||||
|
base->depth[0] != 1) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tex = CALLOC_STRUCT(i915_texture);
|
||||||
|
if (!tex)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
tex->base = *base;
|
||||||
|
pipe_reference_init(&tex->base.reference, 1);
|
||||||
|
tex->base.screen = screen;
|
||||||
|
|
||||||
|
tex->stride = stride[0];
|
||||||
|
|
||||||
|
i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
|
||||||
|
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
pipe_buffer_reference(&tex->buffer, buffer);
|
||||||
|
|
||||||
|
return &tex->base;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
i915_texture_destroy(struct pipe_texture *pt)
|
i915_texture_destroy(struct pipe_texture *pt)
|
||||||
@@ -649,6 +688,12 @@ i915_texture_destroy(struct pipe_texture *pt)
|
|||||||
FREE(tex);
|
FREE(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Screen surface functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
static struct pipe_surface *
|
static struct pipe_surface *
|
||||||
i915_get_tex_surface(struct pipe_screen *screen,
|
i915_get_tex_surface(struct pipe_screen *screen,
|
||||||
struct pipe_texture *pt,
|
struct pipe_texture *pt,
|
||||||
@@ -684,40 +729,6 @@ i915_get_tex_surface(struct pipe_screen *screen,
|
|||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pipe_texture *
|
|
||||||
i915_texture_blanket(struct pipe_screen * screen,
|
|
||||||
const struct pipe_texture *base,
|
|
||||||
const unsigned *stride,
|
|
||||||
struct pipe_buffer *buffer)
|
|
||||||
{
|
|
||||||
struct i915_texture *tex;
|
|
||||||
assert(screen);
|
|
||||||
|
|
||||||
/* Only supports one type */
|
|
||||||
if (base->target != PIPE_TEXTURE_2D ||
|
|
||||||
base->last_level != 0 ||
|
|
||||||
base->depth[0] != 1) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tex = CALLOC_STRUCT(i915_texture);
|
|
||||||
if (!tex)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
tex->base = *base;
|
|
||||||
pipe_reference_init(&tex->base.reference, 1);
|
|
||||||
tex->base.screen = screen;
|
|
||||||
|
|
||||||
tex->stride = stride[0];
|
|
||||||
|
|
||||||
i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
|
|
||||||
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
pipe_buffer_reference(&tex->buffer, buffer);
|
|
||||||
|
|
||||||
return &tex->base;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
i915_tex_surface_destroy(struct pipe_surface *surf)
|
i915_tex_surface_destroy(struct pipe_surface *surf)
|
||||||
{
|
{
|
||||||
@@ -725,13 +736,19 @@ i915_tex_surface_destroy(struct pipe_surface *surf)
|
|||||||
FREE(surf);
|
FREE(surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Other texture functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
i915_init_screen_texture_functions(struct i915_screen *is)
|
i915_init_screen_texture_functions(struct i915_screen *is)
|
||||||
{
|
{
|
||||||
is->base.texture_create = i915_texture_create;
|
is->base.texture_create = i915_texture_create;
|
||||||
|
is->base.texture_blanket = i915_texture_blanket;
|
||||||
is->base.texture_destroy = i915_texture_destroy;
|
is->base.texture_destroy = i915_texture_destroy;
|
||||||
is->base.get_tex_surface = i915_get_tex_surface;
|
is->base.get_tex_surface = i915_get_tex_surface;
|
||||||
is->base.texture_blanket = i915_texture_blanket;
|
|
||||||
is->base.tex_surface_destroy = i915_tex_surface_destroy;
|
is->base.tex_surface_destroy = i915_tex_surface_destroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user