summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c10
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c20
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c6
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c25
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.h4
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c96
-rw-r--r--src/mesa/state_tracker/st_context.c2
-rw-r--r--src/mesa/state_tracker/st_context.h2
-rw-r--r--src/mesa/state_tracker/st_draw.c23
-rw-r--r--src/mesa/state_tracker/st_draw.h3
-rw-r--r--src/mesa/state_tracker/st_extensions.c3
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c363
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.h46
-rw-r--r--src/mesa/state_tracker/st_program.c22
-rw-r--r--src/mesa/state_tracker/st_texture.c61
-rw-r--r--src/mesa/state_tracker/st_texture.h8
16 files changed, 565 insertions, 129 deletions
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 1ed9333556..9196918509 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -226,9 +226,11 @@ find_translated_vp(struct st_context *st,
GLint fpInAttrib = vp_out_to_fp_in(outAttr);
if (fpInAttrib >= 0) {
GLuint fpInSlot = stfp->input_to_slot[fpInAttrib];
- GLuint vpOutSlot = stfp->fs->state.input_map[fpInSlot];
- xvp->output_to_slot[outAttr] = vpOutSlot;
- numVpOuts++;
+ if (fpInSlot != ~0) {
+ GLuint vpOutSlot = stfp->fs->state.input_map[fpInSlot];
+ xvp->output_to_slot[outAttr] = vpOutSlot;
+ numVpOuts++;
+ }
}
else if (outAttr == VERT_RESULT_PSIZ ||
outAttr == VERT_RESULT_BFC0 ||
@@ -247,7 +249,7 @@ find_translated_vp(struct st_context *st,
* We could use this info to do dead code elimination in the
* vertex program.
*/
- dummySlot = stfp->num_input_slots;
+ dummySlot = numVpOuts;
/* Map vert program outputs that aren't used to the dummy slot */
for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index fb21d29c40..2a836d630b 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -36,7 +36,6 @@
#include "st_atom.h"
#include "st_cb_texture.h"
#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
/**
@@ -46,24 +45,21 @@
static void
update_textures(struct st_context *st)
{
- GLuint s;
-
/* ST_NEW_FRAGMENT_PROGRAM
*/
struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
+ GLuint unit;
- for (s = 0; s < st->ctx->Const.MaxTextureCoordUnits; s++) {
- GLuint su = fprog->Base.SamplerUnits[s];
-
- struct gl_texture_object *texObj
- = st->ctx->Texture.Unit[su]._Current;
-
+ for (unit = 0; unit < st->ctx->Const.MaxTextureCoordUnits; unit++) {
+ const GLuint su = fprog->Base.SamplerUnits[unit];
+ struct gl_texture_object *texObj = st->ctx->Texture.Unit[su]._Current;
struct pipe_texture *pt;
if (texObj) {
GLboolean flush, retval;
retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
+ /* XXX retval indicates whether there's a texture border */
pt = st_get_texobj_texture(texObj);
}
@@ -75,9 +71,9 @@ update_textures(struct st_context *st)
* this table before being deleted, otherwise the pointer
* comparison below could fail.
*/
- if (st->state.sampler_texture[s] != pt) {
- st->state.sampler_texture[s] = pt;
- st->pipe->set_sampler_texture(st->pipe, s, pt);
+ if (st->state.sampler_texture[unit] != pt) {
+ st->state.sampler_texture[unit] = pt;
+ st->pipe->set_sampler_texture(st->pipe, unit, pt);
}
}
}
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 758d4a4086..ab98b54bab 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -251,7 +251,7 @@ draw_quad(GLcontext *ctx,
verts[i][1][3] = color[3];
}
- st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2);
+ st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_FALSE);
}
@@ -408,7 +408,9 @@ check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
const struct st_renderbuffer *strb = st_renderbuffer(rb);
const GLboolean isDS = is_depth_stencil_format(strb->surface->format);
return ctx->Scissor.Enabled
- || (isDS && ctx->DrawBuffer->Visual.stencilBits > 0);
+ || (isDS &&
+ strb->surface->status == PIPE_SURFACE_STATUS_DEFINED &&
+ ctx->DrawBuffer->Visual.stencilBits > 0);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 6b44cba2e4..07886e7982 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -355,8 +355,8 @@ make_fragment_shader_z(struct st_context *st)
* Create a simple vertex shader that just passes through the
* vertex position and texcoord (and optionally, color).
*/
-static struct st_vertex_program *
-make_vertex_shader(struct st_context *st, GLboolean passColor)
+struct st_vertex_program *
+st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor)
{
/* only make programs once and re-use */
static struct st_vertex_program *progs[2] = { NULL, NULL };
@@ -572,7 +572,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
verts[i][1][3] = 1.0; /*Q*/
}
- st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2);
+ st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_FALSE);
}
@@ -581,10 +581,13 @@ draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
GLfloat x1, GLfloat y1, const GLfloat *color,
GLboolean invertTex)
{
+ GLfloat bias = ctx->st->bitmap_texcoord_bias;
GLfloat verts[4][3][4]; /* four verts, three attribs, XYZW */
GLuint i;
- GLfloat sLeft = 0.0, sRight = 1.0;
- GLfloat tTop = invertTex, tBot = 1.0 - tTop;
+ GLfloat xBias = bias / (x1-x0);
+ GLfloat yBias = bias / (y1-y0);
+ GLfloat sLeft = 0.0 + xBias, sRight = 1.0 + xBias;
+ GLfloat tTop = invertTex - yBias, tBot = 1.0 - tTop - yBias;
/* upper-left */
verts[0][0][0] = x0; /* attr[0].x */
@@ -622,7 +625,7 @@ draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
verts[i][2][3] = 1.0; /*Q*/
}
- st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3);
+ st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3, GL_FALSE);
}
@@ -942,7 +945,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
if (format == GL_DEPTH_COMPONENT) {
ps = st->state.framebuffer.zsbuf;
stfp = make_fragment_shader_z(ctx->st);
- stvp = make_vertex_shader(ctx->st, GL_TRUE);
+ stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE);
color = ctx->Current.RasterColor;
}
else if (format == GL_STENCIL_INDEX) {
@@ -953,7 +956,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
else {
ps = st->state.framebuffer.cbufs[0];
stfp = combined_drawpix_fragment_program(ctx);
- stvp = make_vertex_shader(ctx->st, GL_FALSE);
+ stvp = st_make_passthrough_vertex_shader(ctx->st, GL_FALSE);
color = NULL;
}
@@ -1108,7 +1111,7 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
struct st_context *st = ctx->st;
struct pipe_texture *pt;
- stvp = make_vertex_shader(ctx->st, GL_TRUE);
+ stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE);
stfp = combined_bitmap_fragment_program(ctx);
st_validate_state(st);
@@ -1226,13 +1229,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
rbRead = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
color = NULL;
stfp = combined_drawpix_fragment_program(ctx);
- stvp = make_vertex_shader(ctx->st, GL_FALSE);
+ stvp = st_make_passthrough_vertex_shader(ctx->st, GL_FALSE);
}
else {
rbRead = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer);
color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
stfp = make_fragment_shader_z(ctx->st);
- stvp = make_vertex_shader(ctx->st, GL_TRUE);
+ stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE);
}
psRead = rbRead->surface;
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.h b/src/mesa/state_tracker/st_cb_drawpixels.h
index 71ba487020..b8b906f06b 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.h
+++ b/src/mesa/state_tracker/st_cb_drawpixels.h
@@ -30,6 +30,10 @@
#define ST_CB_DRAWPIXELS_H
+extern struct st_vertex_program *
+st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor);
+
+
extern void st_init_drawpixels_functions(struct dd_function_table *functions);
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index ba0950e295..3350254654 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -30,6 +30,7 @@
#include "main/enums.h"
#include "main/image.h"
#include "main/macros.h"
+#include "main/mipmap.h"
#include "main/texcompress.h"
#include "main/texformat.h"
#include "main/teximage.h"
@@ -41,6 +42,7 @@
#include "state_tracker/st_cb_texture.h"
#include "state_tracker/st_format.h"
#include "state_tracker/st_texture.h"
+#include "state_tracker/st_gen_mipmap.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -76,13 +78,13 @@ struct st_texture_object
-
static INLINE struct st_texture_object *
st_texture_object(struct gl_texture_object *obj)
{
return (struct st_texture_object *) obj;
}
+
static INLINE struct st_texture_image *
st_texture_image(struct gl_texture_image *img)
{
@@ -122,32 +124,28 @@ gl_target_to_pipe(GLenum target)
}
+/**
+ * Return nominal bytes per texel for a compressed format, 0 for non-compressed
+ * format.
+ */
static int
compressed_num_bytes(GLuint mesaFormat)
{
- int bytes = 0;
switch(mesaFormat) {
-
case MESA_FORMAT_RGB_FXT1:
case MESA_FORMAT_RGBA_FXT1:
case MESA_FORMAT_RGB_DXT1:
case MESA_FORMAT_RGBA_DXT1:
- bytes = 2;
- break;
-
+ return 2;
case MESA_FORMAT_RGBA_DXT3:
case MESA_FORMAT_RGBA_DXT5:
- bytes = 4;
+ return 4;
default:
- break;
+ return 0;
}
-
- return bytes;
}
-
-
static GLboolean
st_IsTextureResident(GLcontext * ctx, struct gl_texture_object *texObj)
{
@@ -164,7 +162,6 @@ st_IsTextureResident(GLcontext * ctx, struct gl_texture_object *texObj)
}
-
static struct gl_texture_image *
st_NewTextureImage(GLcontext * ctx)
{
@@ -216,8 +213,6 @@ st_FreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage)
}
-
-
/* ================================================================
* From linux kernel i386 header files, copes with odd sizes better
* than COPY_DWORDS would:
@@ -290,7 +285,12 @@ logbase2(int n)
}
-/* Otherwise, store it in memory if (Border != 0) or (any dimension ==
+/**
+ * Allocate a pipe_texture object for the given st_texture_object using
+ * the given st_texture_image to guess the mipmap size/levels.
+ *
+ * [comments...]
+ * Otherwise, store it in memory if (Border != 0) or (any dimension ==
* 1).
*
* Otherwise, if max_level >= level >= min_level, create texture with
@@ -302,18 +302,19 @@ logbase2(int n)
static void
guess_and_alloc_texture(struct st_context *st,
struct st_texture_object *stObj,
- struct st_texture_image *stImage)
+ const struct st_texture_image *stImage)
{
GLuint firstLevel;
GLuint lastLevel;
GLuint width = stImage->base.Width;
GLuint height = stImage->base.Height;
GLuint depth = stImage->base.Depth;
- GLuint l2width, l2height, l2depth;
GLuint i, comp_byte = 0;
DBG("%s\n", __FUNCTION__);
+ assert(!stObj->pt);
+
if (stImage->base.Border)
return;
@@ -355,15 +356,15 @@ guess_and_alloc_texture(struct st_context *st,
lastLevel = firstLevel;
}
else {
- l2width = logbase2(width);
- l2height = logbase2(height);
- l2depth = logbase2(depth);
+ GLuint l2width = logbase2(width);
+ GLuint l2height = logbase2(height);
+ GLuint l2depth = logbase2(depth);
lastLevel = firstLevel + MAX2(MAX2(l2width, l2height), l2depth);
}
- assert(!stObj->pt);
if (stImage->base.IsCompressed)
comp_byte = compressed_num_bytes(stImage->base.TexFormat->MesaFormat);
+
stObj->pt = st_texture_create(st,
gl_target_to_pipe(stObj->base.Target),
st_mesa_format_to_pipe_format(stImage->base.TexFormat->MesaFormat),
@@ -487,21 +488,18 @@ try_pbo_upload(GLcontext *ctx,
-
-
-
-
static void
st_TexImage(GLcontext * ctx,
- GLint dims,
- GLenum target, GLint level,
- GLint internalFormat,
- GLint width, GLint height, GLint depth,
- GLint border,
- GLenum format, GLenum type, const void *pixels,
- const struct gl_pixelstore_attrib *unpack,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage, GLsizei imageSize, int compressed)
+ GLint dims,
+ GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth,
+ GLint border,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *unpack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLsizei imageSize, int compressed)
{
struct st_texture_object *stObj = st_texture_object(texObj);
struct st_texture_image *stImage = st_texture_image(texImage);
@@ -524,7 +522,7 @@ st_TexImage(GLcontext * ctx,
/* choose the texture format */
texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
- format, type);
+ format, type);
_mesa_set_fetch_functions(texImage, dims);
@@ -536,7 +534,8 @@ st_TexImage(GLcontext * ctx,
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
texImage->TexFormat->MesaFormat);
- } else {
+ }
+ else {
texelBytes = texImage->TexFormat->TexelBytes;
/* Minimum pitch of 32 bytes */
@@ -669,7 +668,7 @@ st_TexImage(GLcontext * ctx,
* conversion and copy:
*/
if (compressed) {
- memcpy(texImage->Data, pixels, imageSize);
+ memcpy(texImage->Data, pixels, imageSize);
}
else {
GLuint srcImageStride = _mesa_image_image_stride(unpack, width, height,
@@ -705,13 +704,9 @@ st_TexImage(GLcontext * ctx,
texImage->Data = NULL;
}
-#if 0
- /* GL_SGIS_generate_mipmap -- this can be accelerated now.
- */
+#if 01
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- intel_generate_mipmap(ctx, target,
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
- texObj);
+ ctx->Driver.GenerateMipmap(ctx, target, texObj);
}
#endif
}
@@ -1401,7 +1396,10 @@ copy_image_data_to_texture(struct st_context *st,
}
-/*
+/**
+ * Called during state validation. When this function is finished,
+ * the texture object should be ready for rendering.
+ * \return GL_FALSE if a texture border is present, GL_TRUE otherwise
*/
GLboolean
st_finalize_texture(GLcontext *ctx,
@@ -1410,11 +1408,10 @@ st_finalize_texture(GLcontext *ctx,
GLboolean *needFlush)
{
struct st_texture_object *stObj = st_texture_object(tObj);
+ const GLuint nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
int comp_byte = 0;
int cpp;
-
GLuint face, i;
- GLuint nr_faces = 0;
struct st_texture_image *firstImage;
*needFlush = GL_FALSE;
@@ -1426,8 +1423,7 @@ st_finalize_texture(GLcontext *ctx,
/* What levels must the texture include at a minimum?
*/
calculate_first_last_level(stObj);
- firstImage =
- st_texture_image(stObj->base.Image[0][stObj->firstLevel]);
+ firstImage = st_texture_image(stObj->base.Image[0][stObj->firstLevel]);
/* Fallback case:
*/
@@ -1503,7 +1499,6 @@ st_finalize_texture(GLcontext *ctx,
/* Pull in any images not in the object's texture:
*/
- nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
for (face = 0; face < nr_faces; face++) {
for (i = stObj->firstLevel; i <= stObj->lastLevel; i++) {
struct st_texture_image *stImage =
@@ -1540,6 +1535,7 @@ st_init_texture_functions(struct dd_function_table *functions)
functions->CopyTexSubImage1D = st_CopyTexSubImage1D;
functions->CopyTexSubImage2D = st_CopyTexSubImage2D;
functions->CopyTexSubImage3D = st_CopyTexSubImage3D;
+ functions->GenerateMipmap = st_generate_mipmap;
functions->GetTexImage = st_GetTexImage;
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 9c206c057a..bf4618bed8 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -49,6 +49,7 @@
#include "st_atom.h"
#include "st_draw.h"
#include "st_extensions.h"
+#include "st_gen_mipmap.h"
#include "st_program.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
@@ -96,6 +97,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
st_init_atoms( st );
st_init_draw( st );
+ st_init_generate_mipmap(st);
/* we want all vertex data to be placed in buffer objects */
vbo_use_buffer_objects(ctx);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 2b6f8743f3..a756055898 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -143,6 +143,8 @@ struct st_context
GLfloat polygon_offset_scale; /* ?? */
+ GLfloat bitmap_texcoord_bias;
+
/** Mapping from VERT_RESULT_x to post-transformed vertex slot */
const GLuint *vertex_result_to_slot;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 8ef50ee768..ae9f5c8b11 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -298,6 +298,7 @@ st_draw_vbo(GLcontext *ctx,
break;
default:
assert(0);
+ return;
}
/* get/create the index buffer object */
@@ -353,7 +354,8 @@ st_draw_vbo(GLcontext *ctx,
void
st_draw_vertices(GLcontext *ctx, unsigned prim,
unsigned numVertex, float *verts,
- unsigned numAttribs)
+ unsigned numAttribs,
+ GLboolean inClipCoords)
{
const float width = ctx->DrawBuffer->Width;
const float height = ctx->DrawBuffer->Height;
@@ -366,14 +368,16 @@ st_draw_vertices(GLcontext *ctx, unsigned prim,
assert(numAttribs > 0);
- /* convert to clip coords */
- for (i = 0; i < numVertex; i++) {
- float x = verts[i * numAttribs * 4 + 0];
- float y = verts[i * numAttribs * 4 + 1];
- x = x / width * 2.0 - 1.0;
- y = y / height * 2.0 - 1.0;
- verts[i * numAttribs * 4 + 0] = x;
- verts[i * numAttribs * 4 + 1] = y;
+ if (!inClipCoords) {
+ /* convert to clip coords */
+ for (i = 0; i < numVertex; i++) {
+ float x = verts[i * numAttribs * 4 + 0];
+ float y = verts[i * numAttribs * 4 + 1];
+ x = x / width * 2.0 - 1.0;
+ y = y / height * 2.0 - 1.0;
+ verts[i * numAttribs * 4 + 0] = x;
+ verts[i * numAttribs * 4 + 1] = y;
+ }
}
/* XXX create one-time */
@@ -570,6 +574,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
break;
default:
assert(0);
+ return;
}
map = pipe->winsys->buffer_map(pipe->winsys,
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index 89ee790c57..171bde57e5 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -62,7 +62,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
void
st_draw_vertices(GLcontext *ctx, unsigned prim,
unsigned numVertex, float *verts,
- unsigned numAttribs);
+ unsigned numAttribs,
+ GLboolean inClipCoords);
#endif
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 0157bdd6b3..97d28d77c4 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -106,6 +106,9 @@ void st_init_limits(struct st_context *st)
c->MaxTextureLodBias
= pipe->get_paramf(pipe, PIPE_CAP_MAX_TEXTURE_LOD_BIAS);
+
+ st->bitmap_texcoord_bias
+ = pipe->get_paramf(pipe, PIPE_CAP_BITMAP_TEXCOORD_BIAS);
}
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
new file mode 100644
index 0000000000..a6ac9a55fb
--- /dev/null
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -0,0 +1,363 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+
+#include "main/imports.h"
+#include "main/mipmap.h"
+#include "main/teximage.h"
+
+#include "shader/prog_instruction.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/cso_cache/cso_cache.h"
+
+#include "st_context.h"
+#include "st_draw.h"
+#include "st_gen_mipmap.h"
+#include "st_program.h"
+#include "st_cb_drawpixels.h"
+#include "st_cb_texture.h"
+
+
+
+static void *blend_cso = NULL;
+static void *depthstencil_cso = NULL;
+static void *rasterizer_cso = NULL;
+static void *sampler_cso = NULL;
+
+static struct st_fragment_program *stfp = NULL;
+static struct st_vertex_program *stvp = NULL;
+
+
+
+static struct st_fragment_program *
+make_tex_fragment_program(GLcontext *ctx)
+{
+ struct st_fragment_program *stfp;
+ struct gl_program *p;
+ GLuint ic = 0;
+
+ p = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+ if (!p)
+ return NULL;
+
+ p->NumInstructions = 2;
+
+ p->Instructions = _mesa_alloc_instructions(p->NumInstructions);
+ if (!p->Instructions) {
+ ctx->Driver.DeleteProgram(ctx, p);
+ return NULL;
+ }
+ _mesa_init_instructions(p->Instructions, p->NumInstructions);
+
+ /* TEX result.color, fragment.texcoord[0], texture[0], 2D; */
+ p->Instructions[ic].Opcode = OPCODE_TEX;
+ p->Instructions[ic].DstReg.File = PROGRAM_OUTPUT;
+ p->Instructions[ic].DstReg.Index = FRAG_RESULT_COLR;
+ p->Instructions[ic].SrcReg[0].File = PROGRAM_INPUT;
+ p->Instructions[ic].SrcReg[0].Index = FRAG_ATTRIB_TEX0;
+ p->Instructions[ic].TexSrcUnit = 0;
+ p->Instructions[ic].TexSrcTarget = TEXTURE_2D_INDEX;
+ ic++;
+
+ /* END; */
+ p->Instructions[ic++].Opcode = OPCODE_END;
+
+ assert(ic == p->NumInstructions);
+
+ p->InputsRead = FRAG_BIT_TEX0;
+ p->OutputsWritten = (1 << FRAG_RESULT_COLR);
+
+ stfp = (struct st_fragment_program *) p;
+
+ st_translate_fragment_program(ctx->st, stfp, NULL,
+ stfp->tokens, ST_MAX_SHADER_TOKENS);
+
+ return stfp;
+}
+
+
+
+
+/**
+ * one-time init for generate mipmap
+ * XXX Note: there may be other times we need no-op/simple state like this.
+ * In that case, some code refactoring would be good.
+ */
+void
+st_init_generate_mipmap(struct st_context *st)
+{
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_blend_state blend;
+ struct pipe_rasterizer_state rasterizer;
+ struct pipe_sampler_state sampler;
+ struct pipe_depth_stencil_alpha_state depthstencil;
+
+ assert(!blend_cso);
+
+ memset(&blend, 0, sizeof(blend));
+ blend.colormask = PIPE_MASK_RGBA;
+ blend_cso = pipe->create_blend_state(pipe, &blend);
+
+ memset(&depthstencil, 0, sizeof(depthstencil));
+ depthstencil_cso = pipe->create_depth_stencil_alpha_state(pipe, &depthstencil);
+
+ memset(&rasterizer, 0, sizeof(rasterizer));
+ rasterizer_cso = pipe->create_rasterizer_state(pipe, &rasterizer);
+
+ memset(&sampler, 0, sizeof(sampler));
+ sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+ sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
+ sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
+ sampler.normalized_coords = 1;
+ sampler_cso = pipe->create_sampler_state(pipe, &sampler);
+
+ stfp = make_tex_fragment_program(st->ctx);
+ stvp = st_make_passthrough_vertex_shader(st, GL_FALSE);
+}
+
+
+void
+st_destroy_generate_mipmpap(struct st_context *st)
+{
+ struct pipe_context *pipe = st->pipe;
+
+ pipe->delete_blend_state(pipe, blend_cso);
+ pipe->delete_depth_stencil_alpha_state(pipe, depthstencil_cso);
+ pipe->delete_rasterizer_state(pipe, rasterizer_cso);
+ pipe->delete_sampler_state(pipe, sampler_cso);
+
+ /* XXX free stfp, stvp */
+
+ blend_cso = NULL;
+ depthstencil_cso = NULL;
+ rasterizer_cso = NULL;
+ sampler_cso = NULL;
+}
+
+
+static void
+simple_viewport(struct pipe_context *pipe, uint width, uint height)
+{
+ struct pipe_viewport_state vp;
+
+ vp.scale[0] = 0.5 * width;
+ vp.scale[1] = -0.5 * height;
+ vp.scale[2] = 1.0;
+ vp.scale[3] = 1.0;
+ vp.translate[0] = 0.5 * width;
+ vp.translate[1] = 0.5 * height;
+ vp.translate[2] = 0.0;
+ vp.translate[3] = 0.0;
+
+ pipe->set_viewport_state(pipe, &vp);
+}
+
+
+
+/*
+ * Draw simple [-1,1]x[-1,1] quad
+ */
+static void
+draw_quad(GLcontext *ctx)
+{
+ GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */
+ GLuint i;
+ GLfloat sLeft = 0.0, sRight = 1.0;
+ GLfloat tTop = 1.0, tBot = 0.0;
+ GLfloat x0 = -1.0, x1 = 1.0;
+ GLfloat y0 = -1.0, y1 = 1.0;
+
+ /* upper-left */
+ verts[0][0][0] = x0; /* attr[0].x */
+ verts[0][0][1] = y0; /* attr[0].y */
+ verts[0][1][0] = sLeft; /* attr[1].s */
+ verts[0][1][1] = tTop; /* attr[1].t */
+
+ /* upper-right */
+ verts[1][0][0] = x1;
+ verts[1][0][1] = y0;
+ verts[1][1][0] = sRight;
+ verts[1][1][1] = tTop;
+
+ /* lower-right */
+ verts[2][0][0] = x1;
+ verts[2][0][1] = y1;
+ verts[2][1][0] = sRight;
+ verts[2][1][1] = tBot;
+
+ /* lower-left */
+ verts[3][0][0] = x0;
+ verts[3][0][1] = y1;
+ verts[3][1][0] = sLeft;
+ verts[3][1][1] = tBot;
+
+ /* same for all verts: */
+ for (i = 0; i < 4; i++) {
+ verts[i][0][2] = 0.0; /*Z*/
+ verts[i][0][3] = 1.0; /*W*/
+ verts[i][1][2] = 0.0; /*R*/
+ verts[i][1][3] = 1.0; /*Q*/
+ }
+
+ st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_TRUE);
+}
+
+
+
+/**
+ * Generate mipmap levels using hardware rendering.
+ * \return TRUE if successful, FALSE if not possible
+ */
+static boolean
+st_render_mipmap(struct st_context *st,
+ struct pipe_texture *pt,
+ uint baseLevel, uint lastLevel)
+{
+ struct pipe_context *pipe = st->pipe;
+ struct pipe_framebuffer_state fb;
+ const uint face = 0, zslice = 0;
+ const uint first_level_save = pt->first_level;
+ uint dstLevel;
+
+ /* check if we can render in the texture's format */
+ if (!pipe->is_format_supported(pipe, pt->format, PIPE_SURFACE)) {
+ return FALSE;
+ }
+
+ /* init framebuffer state */
+ memset(&fb, 0, sizeof(fb));
+ fb.num_cbufs = 1;
+
+ /* bind CSOs */
+ pipe->bind_blend_state(pipe, blend_cso);
+ pipe->bind_depth_stencil_alpha_state(pipe, depthstencil_cso);
+ pipe->bind_rasterizer_state(pipe, rasterizer_cso);
+ pipe->bind_sampler_state(pipe, 0, sampler_cso);
+
+ /* bind shaders */
+ pipe->bind_fs_state(pipe, stfp->fs->data);
+ pipe->bind_vs_state(pipe, stvp->cso->data);
+
+ for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
+ const uint srcLevel = dstLevel - 1;
+
+ /*
+ * Setup framebuffer / dest surface
+ */
+ fb.cbufs[0] = pipe->get_tex_surface(pipe, pt, face, dstLevel, zslice);
+ pipe->set_framebuffer_state(pipe, &fb);
+
+ simple_viewport(pipe, pt->width[dstLevel], pt->height[dstLevel]);
+
+ /*
+ * Setup src texture, override pt->first_level so we sample from
+ * the right mipmap level.
+ */
+ pt->first_level = srcLevel;
+ pipe->set_sampler_texture(pipe, 0, pt);
+
+ draw_quad(st->ctx);
+ }
+
+ /* restore first_level */
+ pt->first_level = first_level_save;
+
+ /* restore pipe state */
+ if (st->state.rasterizer)
+ pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
+ if (st->state.fs)
+ pipe->bind_fs_state(pipe, st->state.fs->data);
+ if (st->state.vs)
+ pipe->bind_vs_state(pipe, st->state.vs->cso->data);
+ if (st->state.sampler[0])
+ pipe->bind_sampler_state(pipe, 0, st->state.sampler[0]->data);
+ pipe->set_sampler_texture(pipe, 0, st->state.sampler_texture[0]);
+ pipe->set_viewport_state(pipe, &st->state.viewport);
+
+ return TRUE;
+}
+
+
+
+void
+st_generate_mipmap(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj)
+{
+ struct st_context *st = ctx->st;
+ struct pipe_texture *pt = st_get_texobj_texture(texObj);
+ const uint baseLevel = texObj->BaseLevel;
+ const uint lastLevel = pt->last_level;
+ uint dstLevel;
+
+ if (!st_render_mipmap(st, pt, baseLevel, lastLevel)) {
+ abort();
+ /* XXX the following won't really work at this time */
+ _mesa_generate_mipmap(ctx, target, texObj);
+ return;
+ }
+
+ for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
+ const uint srcLevel = dstLevel - 1;
+ const struct gl_texture_image *srcImage
+ = _mesa_get_tex_image(ctx, texObj, target, srcLevel);
+ struct gl_texture_image *dstImage;
+ struct st_texture_image *stImage;
+ uint dstWidth = pt->width[dstLevel];
+ uint dstHeight = pt->height[dstLevel];
+ uint dstDepth = pt->depth[dstLevel];
+ uint border = srcImage->Border;
+
+
+ dstImage = _mesa_get_tex_image(ctx, texObj, target, dstLevel);
+ if (!dstImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
+ return;
+ }
+
+ if (dstImage->ImageOffsets)
+ _mesa_free(dstImage->ImageOffsets);
+
+ /* Free old image data */
+ if (dstImage->Data)
+ ctx->Driver.FreeTexImageData(ctx, dstImage);
+
+ /* initialize new image */
+ _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
+ dstDepth, border, srcImage->InternalFormat);
+
+ dstImage->TexFormat = srcImage->TexFormat;
+
+ stImage = (struct st_texture_image *) dstImage;
+ stImage->pt = pt;
+ }
+
+}
diff --git a/src/mesa/state_tracker/st_gen_mipmap.h b/src/mesa/state_tracker/st_gen_mipmap.h
new file mode 100644
index 0000000000..7668c1e44e
--- /dev/null
+++ b/src/mesa/state_tracker/st_gen_mipmap.h
@@ -0,0 +1,46 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+
+#ifndef ST_GEN_MIPMAP_H
+#define ST_GEN_MIPMAP_H
+
+
+extern void
+st_init_generate_mipmap(struct st_context *st);
+
+
+extern void
+st_destroy_generate_mipmpap(struct st_context *st);
+
+
+extern void
+st_generate_mipmap(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj);
+
+
+#endif /* ST_GEN_MIPMAP_H */
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 1f1e6500e0..84a9094001 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -33,6 +33,7 @@
#include "main/imports.h"
#include "main/mtypes.h"
+#include "shader/prog_print.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -68,6 +69,7 @@ st_translate_vertex_program(struct st_context *st,
struct pipe_shader_state vs;
const struct cso_vertex_shader *cso;
GLuint attr, i;
+ GLuint num_generic = 0;
memset(&vs, 0, sizeof(vs));
@@ -117,7 +119,7 @@ st_translate_vertex_program(struct st_context *st,
case VERT_ATTRIB_TEX6:
case VERT_ATTRIB_TEX7:
vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- vs.input_semantic_index[slot] = attr - VERT_ATTRIB_TEX0;
+ vs.input_semantic_index[slot] = num_generic++;
break;
case VERT_ATTRIB_GENERIC0:
case VERT_ATTRIB_GENERIC1:
@@ -129,7 +131,7 @@ st_translate_vertex_program(struct st_context *st,
case VERT_ATTRIB_GENERIC7:
assert(attr < VERT_ATTRIB_MAX);
vs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- vs.input_semantic_index[slot] = attr - VERT_ATTRIB_GENERIC0;
+ vs.input_semantic_index[slot] = num_generic++;
break;
default:
assert(0);
@@ -143,6 +145,7 @@ st_translate_vertex_program(struct st_context *st,
vs.output_semantic_index[i] = 0;
}
+ num_generic = 0;
/*
* Determine number of outputs, the (default) output register
* mapping and the semantic information for each output.
@@ -207,14 +210,14 @@ st_translate_vertex_program(struct st_context *st,
case VERT_RESULT_TEX6:
case VERT_RESULT_TEX7:
vs.output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- vs.output_semantic_index[slot] = attr - VERT_RESULT_TEX0;
+ vs.output_semantic_index[slot] = num_generic++;
break;
case VERT_RESULT_VAR0:
/* fall-through */
default:
assert(attr - VERT_RESULT_VAR0 < MAX_VARYING);
vs.output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- vs.output_semantic_index[slot] = attr - VERT_RESULT_VAR0;
+ vs.output_semantic_index[slot] = num_generic++;
}
}
}
@@ -258,6 +261,9 @@ st_translate_vertex_program(struct st_context *st,
cso = st_cached_vs_state(st, &vs);
stvp->cso = cso;
+ if (0)
+ _mesa_print_program(&stvp->Base.Base);
+
if (TGSI_DEBUG)
tgsi_dump( tokensOut, 0 );
}
@@ -286,6 +292,7 @@ st_translate_fragment_program(struct st_context *st,
GLuint attr;
const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
GLuint vslot = 0;
+ GLuint num_generic = 0;
memset(&fs, 0, sizeof(fs));
@@ -338,14 +345,14 @@ st_translate_fragment_program(struct st_context *st,
case FRAG_ATTRIB_TEX6:
case FRAG_ATTRIB_TEX7:
fs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- fs.input_semantic_index[slot] = attr - FRAG_ATTRIB_TEX0;
+ fs.input_semantic_index[slot] = num_generic++;
interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
break;
case FRAG_ATTRIB_VAR0:
/* fall-through */
default:
fs.input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- fs.input_semantic_index[slot] = attr - FRAG_ATTRIB_VAR0;
+ fs.input_semantic_index[slot] = num_generic++;
interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
}
}
@@ -415,6 +422,9 @@ st_translate_fragment_program(struct st_context *st,
cso = st_cached_fs_state(st, &fs);
stfp->fs = cso;
+ if (0)
+ _mesa_print_program(&stfp->Base.Base);
+
if (TGSI_DEBUG)
tgsi_dump( tokensOut, 0/*TGSI_DUMP_VERBOSE*/ );
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 15cc458be8..844a9f80d8 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -59,6 +59,10 @@ target_to_target(GLenum target)
}
#endif
+
+/**
+ * Allocate a new pipe_texture object
+ */
struct pipe_texture *
st_texture_create(struct st_context *st,
enum pipe_texture_target target,
@@ -70,7 +74,7 @@ st_texture_create(struct st_context *st,
GLuint depth0,
GLuint compress_byte)
{
- struct pipe_texture *pt = CALLOC_STRUCT(pipe_texture);
+ struct pipe_texture pt;
assert(target <= PIPE_TEXTURE_CUBE);
@@ -78,39 +82,33 @@ st_texture_create(struct st_context *st,
_mesa_lookup_enum_by_nr(target),
_mesa_lookup_enum_by_nr(format), first_level, last_level);
- if (!pt)
- return NULL;
-
assert(format);
- pt->target = target;
- pt->format = format;
- pt->first_level = first_level;
- pt->last_level = last_level;
- pt->width[0] = width0;
- pt->height[0] = height0;
- pt->depth[0] = depth0;
- pt->compressed = compress_byte ? 1 : 0;
- pt->cpp = pt->compressed ? compress_byte : st_sizeof_format(format);
- pt->refcount = 1;
-
- st->pipe->texture_create(st->pipe, &pt);
-
- return pt;
+ pt.target = target;
+ pt.format = format;
+ pt.first_level = first_level;
+ pt.last_level = last_level;
+ pt.width[0] = width0;
+ pt.height[0] = height0;
+ pt.depth[0] = depth0;
+ pt.compressed = compress_byte ? 1 : 0;
+ pt.cpp = pt.compressed ? compress_byte : st_sizeof_format(format);
+ pt.refcount = 1;
+
+ return st->pipe->texture_create(st->pipe, &pt);
}
-
-
-/* Can the image be pulled into a unified mipmap texture. This mirrors
- * the completeness test in a lot of ways.
+/**
+ * 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.
*/
GLboolean
-st_texture_match_image(struct pipe_texture *pt,
- struct gl_texture_image *image,
- GLuint face, GLuint level)
+st_texture_match_image(const struct pipe_texture *pt,
+ const struct gl_texture_image *image,
+ GLuint face, GLuint level)
{
/* Images with borders are never pulled into mipmap textures.
*/
@@ -189,6 +187,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
return pipe_surface_map(stImage->surface);
}
+
void
st_texture_image_unmap(struct st_texture_image *stImage)
{
@@ -201,7 +200,8 @@ st_texture_image_unmap(struct st_texture_image *stImage)
-/* Upload data to a rectangular sub-region. Lots of choices how to do this:
+/**
+ * Upload data to a rectangular sub-region. Lots of choices how to do this:
*
* - memcpy by span to current destination
* - upload data as new buffer and blit
@@ -261,13 +261,14 @@ st_texture_image_data(struct pipe_context *pipe,
}
}
+
/* Copy mipmap image between textures
*/
void
st_texture_image_copy(struct pipe_context *pipe,
- struct pipe_texture *dst,
- GLuint face, GLuint level,
- struct pipe_texture *src)
+ struct pipe_texture *dst,
+ GLuint face, GLuint level,
+ struct pipe_texture *src)
{
GLuint width = src->width[level];
GLuint height = src->height[level];
@@ -278,6 +279,7 @@ st_texture_image_copy(struct pipe_context *pipe,
if (dst->compressed)
height /= 4;
+
for (i = 0; i < depth; i++) {
dst_surface = pipe->get_tex_surface(pipe, dst, face, level, i);
src_surface = pipe->get_tex_surface(pipe, src, face, level, i);
@@ -292,5 +294,4 @@ st_texture_image_copy(struct pipe_context *pipe,
pipe_surface_reference(&dst_surface, NULL);
pipe_surface_reference(&src_surface, NULL);
}
-
}
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index d8b1bcad9d..0b87a494c3 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -47,11 +47,11 @@ st_texture_create(struct st_context *st,
GLuint compress_byte);
-/* Check if an image fits an existing texture
+/* Check if an image fits into an existing texture object.
*/
extern GLboolean
-st_texture_match_image(struct pipe_texture *pt,
- struct gl_texture_image *image,
+st_texture_match_image(const struct pipe_texture *pt,
+ const struct gl_texture_image *image,
GLuint face, GLuint level);
/* Return a pointer to an image within a texture. Return image stride as
@@ -73,7 +73,7 @@ extern const GLuint *
st_texture_depth_offsets(struct pipe_texture *pt, GLuint level);
-/* Return the linear offset of an image relative to the start of its region:
+/* Return the linear offset of an image relative to the start of its region.
*/
extern GLuint
st_texture_image_offset(const struct pipe_texture *pt,