st_texture.h File Reference

Include dependency graph for st_texture.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  st_texture_image
struct  st_texture_object

Functions

static struct st_texture_imagest_texture_image (struct gl_texture_image *img)
static struct st_texture_objectst_texture_object (struct gl_texture_object *obj)
static struct pipe_texturest_get_texobj_texture (struct gl_texture_object *texObj)
static struct pipe_texturest_get_stobj_texture (struct st_texture_object *stObj)
static GLboolean pf_is_depth_stencil (enum pipe_format format)
struct pipe_texturest_texture_create (struct st_context *st, enum pipe_texture_target target, enum pipe_format format, GLuint last_level, GLuint width0, GLuint height0, GLuint depth0, GLuint compress_byte, GLuint tex_usage)
 Allocate a new pipe_texture object width0, height0, depth0 are the dimensions of the level 0 image (the highest resolution).
GLboolean st_texture_match_image (const struct pipe_texture *pt, const struct gl_texture_image *image, GLuint face, GLuint level)
 Check if a texture image be pulled into a unified mipmap texture.
GLubyte * st_texture_image_map (struct st_context *st, struct st_texture_image *stImage, GLuint zoffset, GLuint flags)
 Map a teximage in a mipmap texture.
void st_texture_image_unmap (struct st_context *st, struct st_texture_image *stImage)
const GLuint * st_texture_depth_offsets (struct pipe_texture *pt, GLuint level)
GLuint st_texture_image_offset (const struct pipe_texture *pt, GLuint face, GLuint level)
GLuint st_texture_texel_offset (const struct pipe_texture *pt, GLuint face, GLuint level, GLuint col, GLuint row, GLuint img)
void st_texture_image_data (struct pipe_context *pipe, struct pipe_texture *dst, GLuint face, GLuint level, void *src, GLuint src_row_pitch, GLuint src_image_pitch)
void st_texture_image_copy (struct pipe_context *pipe, struct pipe_texture *dst, GLuint dstLevel, struct pipe_texture *src, GLuint face)


Function Documentation

static GLboolean pf_is_depth_stencil ( enum pipe_format  format  )  [static]

Definition at line 102 of file st_texture.h.

References pf_get_component_bits(), PIPE_FORMAT_COMP_S, and PIPE_FORMAT_COMP_Z.

00103 {
00104    return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
00105            pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
00106 }

static struct pipe_texture* st_get_stobj_texture ( struct st_texture_object stObj  )  [static, read]

Definition at line 97 of file st_texture.h.

References st_texture_object::pt.

00098 {
00099    return stObj ? stObj->pt : NULL;
00100 }

static struct pipe_texture* st_get_texobj_texture ( struct gl_texture_object *  texObj  )  [static, read]

Definition at line 89 of file st_texture.h.

References st_texture_object::pt, and st_texture_object().

00090 {
00091    struct st_texture_object *stObj = st_texture_object(texObj);
00092    return stObj ? stObj->pt : NULL;
00093 }

struct pipe_texture* st_texture_create ( struct st_context st,
enum pipe_texture_target  target,
enum pipe_format  format,
GLuint  last_level,
GLuint  width0,
GLuint  height0,
GLuint  depth0,
GLuint  compress_byte,
GLuint  usage 
) [read]

Allocate a new pipe_texture object width0, height0, depth0 are the dimensions of the level 0 image (the highest resolution).

last_level indicates how many mipmap levels to allocate storage for. For non-mipmapped textures, this will be zero.

Definition at line 74 of file st_texture.c.

References assert, pipe_texture::block, pipe_texture::compressed, DBG, pipe_texture::depth, pipe_texture::format, pipe_texture::height, pipe_screen::is_format_supported, pipe_texture::last_level, pf_get_block(), st_context::pipe, PIPE_TEXTURE_CUBE, PIPE_TEXTURE_USAGE_SAMPLER, pipe_texture::refcount, pipe_context::screen, pipe_texture::target, pipe_texture::tex_usage, pipe_screen::texture_create, and pipe_texture::width.

00083 {
00084    struct pipe_texture pt, *newtex;
00085    struct pipe_screen *screen = st->pipe->screen;
00086 
00087    assert(target <= PIPE_TEXTURE_CUBE);
00088 
00089    DBG("%s target %s format %s last_level %d\n", __FUNCTION__,
00090        _mesa_lookup_enum_by_nr(target),
00091        _mesa_lookup_enum_by_nr(format), last_level);
00092 
00093    assert(format);
00094    assert(screen->is_format_supported(screen, format, target, 
00095                                       PIPE_TEXTURE_USAGE_SAMPLER, 0));
00096 
00097    memset(&pt, 0, sizeof(pt));
00098    pt.target = target;
00099    pt.format = format;
00100    pt.last_level = last_level;
00101    pt.width[0] = width0;
00102    pt.height[0] = height0;
00103    pt.depth[0] = depth0;
00104    pt.compressed = compress_byte ? 1 : 0;
00105    pf_get_block(format, &pt.block);
00106    pt.tex_usage = usage;
00107 
00108    newtex = screen->texture_create(screen, &pt);
00109 
00110    assert(!newtex || newtex->refcount == 1);
00111 
00112    return newtex;
00113 }

const GLuint* st_texture_depth_offsets ( struct pipe_texture pt,
GLuint  level 
)

static struct st_texture_image* st_texture_image ( struct gl_texture_image *  img  )  [static, read]

Definition at line 76 of file st_texture.h.

00077 {
00078    return (struct st_texture_image *) img;
00079 }

void st_texture_image_copy ( struct pipe_context pipe,
struct pipe_texture dst,
GLuint  dstLevel,
struct pipe_texture src,
GLuint  face 
)

Definition at line 292 of file st_texture.c.

References assert, pipe_texture::depth, FALSE, pipe_screen::get_tex_surface, pipe_surface::height, pipe_texture::height, pipe_texture::last_level, PIPE_BUFFER_USAGE_CPU_READ, PIPE_BUFFER_USAGE_GPU_READ, PIPE_BUFFER_USAGE_GPU_WRITE, pipe_surface_reference(), pipe_context::screen, pipe_context::surface_copy, pipe_screen::surface_map, pipe_screen::surface_unmap, pipe_screen::tex_surface_release, pipe_surface::width, and pipe_texture::width.

00298 {
00299    struct pipe_screen *screen = pipe->screen;
00300    GLuint width = dst->width[dstLevel];
00301    GLuint height = dst->height[dstLevel];
00302    GLuint depth = dst->depth[dstLevel];
00303    struct pipe_surface *src_surface;
00304    struct pipe_surface *dst_surface;
00305    GLuint i;
00306 
00307    for (i = 0; i < depth; i++) {
00308       GLuint srcLevel;
00309 
00310       /* find src texture level of needed size */
00311       for (srcLevel = 0; srcLevel <= src->last_level; srcLevel++) {
00312          if (src->width[srcLevel] == width &&
00313              src->height[srcLevel] == height) {
00314             break;
00315          }
00316       }
00317       assert(src->width[srcLevel] == width);
00318       assert(src->height[srcLevel] == height);
00319 
00320 #if 0
00321       {
00322          src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
00323                                                PIPE_BUFFER_USAGE_CPU_READ);
00324          ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ);
00325          map += src_surface->width * src_surface->height * 4 / 2;
00326          printf("%s center pixel: %d %d %d %d (pt %p[%d] -> %p[%d])\n",
00327                 __FUNCTION__,
00328                 map[0], map[1], map[2], map[3],
00329                 src, srcLevel, dst, dstLevel);
00330 
00331          screen->surface_unmap(screen, src_surface);
00332          pipe_surface_reference(&src_surface, NULL);
00333       }
00334 #endif
00335 
00336       dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i,
00337                                             PIPE_BUFFER_USAGE_GPU_WRITE);
00338 
00339       src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
00340                                             PIPE_BUFFER_USAGE_GPU_READ);
00341 
00342       pipe->surface_copy(pipe,
00343                          FALSE,
00344                          dst_surface,
00345                          0, 0, /* destX, Y */
00346                          src_surface,
00347                          0, 0, /* srcX, Y */
00348                          width, height);
00349 
00350       screen->tex_surface_release(screen, &src_surface);
00351       screen->tex_surface_release(screen, &dst_surface);

void st_texture_image_data ( struct pipe_context pipe,
struct pipe_texture dst,
GLuint  face,
GLuint  level,
void *  src,
GLuint  src_row_pitch,
GLuint  src_image_pitch 
)

Definition at line 257 of file st_texture.c.

References DBG, pipe_texture::depth, pipe_screen::get_tex_surface, pipe_texture::height, PIPE_BUFFER_USAGE_CPU_WRITE, pipe_context::screen, st_surface_data(), pipe_screen::tex_surface_release, and pipe_texture::width.

00265 {
00266    struct pipe_screen *screen = pipe->screen;
00267    GLuint depth = dst->depth[level];
00268    GLuint i;
00269    const GLubyte *srcUB = src;
00270    struct pipe_surface *dst_surface;
00271 
00272    DBG("%s\n", __FUNCTION__);
00273    for (i = 0; i < depth; i++) {
00274       dst_surface = screen->get_tex_surface(screen, dst, face, level, i,
00275                                             PIPE_BUFFER_USAGE_CPU_WRITE);
00276 
00277       st_surface_data(pipe, dst_surface,
00278                       0, 0,                             /* dstx, dsty */
00279                       srcUB,
00280                       src_row_stride,
00281                       0, 0,                             /* source x, y */
00282                       dst->width[level], dst->height[level]);       /* width, height */
00283 
00284       screen->tex_surface_release(screen, &dst_surface);
00285 
00286       srcUB += src_image_stride;

GLubyte* st_texture_image_map ( struct st_context st,
struct st_texture_image stImage,
GLuint  zoffset,
GLuint  flags 
)

Map a teximage in a mipmap texture.

Parameters:
row_stride returns row stride in bytes
image_stride returns image stride in bytes (for 3D textures).
Returns:
address of mapping

Definition at line 190 of file st_texture.c.

00195 {
00196    struct pipe_screen *screen = st->pipe->screen;
00197    struct pipe_texture *pt = stImage->pt;
00198    DBG("%s \n", __FUNCTION__);
00199 
00200    stImage->surface = screen->get_tex_surface(screen, pt, stImage->face,
00201                                               stImage->level, zoffset, 
00202                                               flags);
00203 
00204    if (stImage->surface)
00205       return screen->surface_map(screen, stImage->surface, flags);
00206    else

GLuint st_texture_image_offset ( const struct pipe_texture pt,
GLuint  face,
GLuint  level 
)

void st_texture_image_unmap ( struct st_context st,
struct st_texture_image stImage 
)

Definition at line 210 of file st_texture.c.

References DBG, st_context::pipe, pipe_surface_reference(), pipe_context::screen, st_texture_image::surface, and pipe_screen::surface_unmap.

00214 {
00215    struct pipe_screen *screen = st->pipe->screen;
00216 
00217    DBG("%s\n", __FUNCTION__);
00218 
00219    screen->surface_unmap(screen, stImage->surface);
00220 

GLboolean st_texture_match_image ( const struct pipe_texture pt,
const struct gl_texture_image *  image,
GLuint  face,
GLuint  level 
)

Check if a texture image be pulled into a unified mipmap texture.

This mirrors the completeness test in a lot of ways.

Not sure whether I want to pass gl_texture_image here.

Definition at line 123 of file st_texture.c.

References pipe_texture::compressed, pipe_texture::depth, pipe_texture::format, pipe_texture::height, st_mesa_format_to_pipe_format(), and pipe_texture::width.

00126 {
00127    /* Images with borders are never pulled into mipmap textures. 
00128     */
00129    if (image->Border) 
00130       return GL_FALSE;
00131 
00132    if (st_mesa_format_to_pipe_format(image->TexFormat->MesaFormat) != pt->format ||
00133        image->IsCompressed != pt->compressed)
00134       return GL_FALSE;
00135 
00136    /* Test image dimensions against the base level image adjusted for
00137     * minification.  This will also catch images not present in the
00138     * texture, changed targets, etc.
00139     */
00140    if (image->Width != pt->width[level] ||
00141        image->Height != pt->height[level] ||
00142        image->Depth != pt->depth[level])
00143       return GL_FALSE;
00144 
00145    return GL_TRUE;
00146 }

static struct st_texture_object* st_texture_object ( struct gl_texture_object *  obj  )  [static, read]

Definition at line 82 of file st_texture.h.

00083 {
00084    return (struct st_texture_object *) obj;
00085 }

GLuint st_texture_texel_offset ( const struct pipe_texture pt,
GLuint  face,
GLuint  level,
GLuint  col,
GLuint  row,
GLuint  img 
)


Generated on Tue Sep 29 06:25:55 2009 for Gallium3D by  doxygen 1.5.4