summaryrefslogtreecommitdiffstats
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_depth.c4
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c2
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c13
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c13
-rw-r--r--src/mesa/state_tracker/st_cb_program.c9
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c69
-rw-r--r--src/mesa/state_tracker/st_context.c2
-rw-r--r--src/mesa/state_tracker/st_draw.c12
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c82
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c11
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.h3
-rw-r--r--src/mesa/state_tracker/st_program.c2
-rw-r--r--src/mesa/state_tracker/st_texture.c3
13 files changed, 152 insertions, 73 deletions
diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c
index 0aa128f9479..88b80a07fc9 100644
--- a/src/mesa/state_tracker/st_atom_depth.c
+++ b/src/mesa/state_tracker/st_atom_depth.c
@@ -104,10 +104,6 @@ update_depth_stencil_alpha(struct st_context *st)
dsa->depth.func = st_compare_func_to_pipe(ctx->Depth.Func);
}
- if (ctx->Query.CurrentOcclusionObject &&
- ctx->Query.CurrentOcclusionObject->Active)
- dsa->depth.occlusion_count = 1;
-
if (ctx->Stencil.Enabled && ctx->DrawBuffer->Visual.stencilBits > 0) {
dsa->stencil[0].enabled = 1;
dsa->stencil[0].func = st_compare_func_to_pipe(ctx->Stencil.Function[0]);
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 95181578f63..3d1d0f71d53 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -241,7 +241,7 @@ accum_return(GLcontext *ctx, GLfloat value,
xpos, ypos,
width, height);
- if (usage != PIPE_TRANSFER_WRITE)
+ if (usage & PIPE_TRANSFER_READ)
pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf);
switch (acc_strb->format) {
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 902fb38d1a7..a22fa68299b 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -330,7 +330,18 @@ setup_bitmap_vertex_data(struct st_context *st,
const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0);
const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0);
const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0);
- const GLuint max_slots = 4096 / sizeof(st->bitmap.vertices);
+
+ /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
+ * no_flush) updates to buffers where we know there is no conflict
+ * with previous data. Currently using max_slots > 1 will cause
+ * synchronous rendering if the driver flushes its command buffers
+ * between one bitmap and the next. Our flush hook below isn't
+ * sufficient to catch this as the driver doesn't tell us when it
+ * flushes its own command buffers. Until this gets fixed, pay the
+ * price of allocating a new buffer for each bitmap cache-flush to
+ * avoid synchronous rendering.
+ */
+ const GLuint max_slots = 1; /* 4096 / sizeof(st->bitmap.vertices); */
GLuint i;
if (st->bitmap.vbuf_slot >= max_slots) {
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 8a8c99f7e17..36510720a4c 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -116,7 +116,18 @@ draw_quad(GLcontext *ctx,
{
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
- const GLuint max_slots = 1024 / sizeof(st->clear.vertices);
+
+ /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as
+ * no_flush) updates to buffers where we know there is no conflict
+ * with previous data. Currently using max_slots > 1 will cause
+ * synchronous rendering if the driver flushes its command buffers
+ * between one bitmap and the next. Our flush hook below isn't
+ * sufficient to catch this as the driver doesn't tell us when it
+ * flushes its own command buffers. Until this gets fixed, pay the
+ * price of allocating a new buffer for each bitmap cache-flush to
+ * avoid synchronous rendering.
+ */
+ const GLuint max_slots = 1; /* 1024 / sizeof(st->clear.vertices); */
GLuint i;
if (st->clear.vbuf_slot >= max_slots) {
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 4398ab28392..b2d5c39a3a0 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -45,6 +45,7 @@
#include "st_context.h"
#include "st_program.h"
#include "st_atom_shader.h"
+#include "st_mesa_to_tgsi.h"
#include "st_cb_program.h"
@@ -152,7 +153,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
}
if (stvp->state.tokens) {
- _mesa_free((void *) stvp->state.tokens);
+ st_free_tokens(stvp->state.tokens);
stvp->state.tokens = NULL;
}
}
@@ -167,7 +168,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
}
if (stfp->state.tokens) {
- _mesa_free((void *) stfp->state.tokens);
+ st_free_tokens(stfp->state.tokens);
stfp->state.tokens = NULL;
}
@@ -214,7 +215,7 @@ static void st_program_string_notify( GLcontext *ctx,
}
if (stfp->state.tokens) {
- _mesa_free((void *) stfp->state.tokens);
+ st_free_tokens(stfp->state.tokens);
stfp->state.tokens = NULL;
}
@@ -242,7 +243,7 @@ static void st_program_string_notify( GLcontext *ctx,
}
if (stvp->state.tokens) {
- _mesa_free((void *) stvp->state.tokens);
+ st_free_tokens(stvp->state.tokens);
stvp->state.tokens = NULL;
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 3520c986b47..9a634bb9302 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -328,10 +328,13 @@ guess_and_alloc_texture(struct st_context *st,
stObj->base.MinFilter == GL_LINEAR ||
stImage->base._BaseFormat == GL_DEPTH_COMPONENT ||
stImage->base._BaseFormat == GL_DEPTH_STENCIL_EXT) &&
+ !stObj->base.GenerateMipmap &&
stImage->level == firstLevel) {
+ /* only alloc space for a single mipmap level */
lastLevel = firstLevel;
}
else {
+ /* alloc space for a full mipmap */
GLuint l2width = util_logbase2(width);
GLuint l2height = util_logbase2(height);
GLuint l2depth = util_logbase2(depth);
@@ -1693,53 +1696,6 @@ st_CopyTexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
}
-/**
- * Compute which mipmap levels that really need to be sent to the hardware.
- * This depends on the base image size, GL_TEXTURE_MIN_LOD,
- * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
- */
-static void
-calculate_first_last_level(struct st_texture_object *stObj)
-{
- struct gl_texture_object *tObj = &stObj->base;
-
- /* These must be signed values. MinLod and MaxLod can be negative numbers,
- * and having firstLevel and lastLevel as signed prevents the need for
- * extra sign checks.
- */
- GLint firstLevel;
- GLint lastLevel;
-
- /* Yes, this looks overly complicated, but it's all needed.
- */
- switch (tObj->Target) {
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_3D:
- case GL_TEXTURE_CUBE_MAP:
- if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) {
- /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
- */
- firstLevel = lastLevel = tObj->BaseLevel;
- }
- else {
- firstLevel = 0;
- lastLevel = MIN2(tObj->MaxLevel,
- (int) tObj->Image[0][tObj->BaseLevel]->WidthLog2);
- }
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- case GL_TEXTURE_4D_SGIS:
- firstLevel = lastLevel = 0;
- break;
- default:
- return;
- }
-
- stObj->lastLevel = lastLevel;
-}
-
-
static void
copy_image_data_to_texture(struct st_context *st,
struct st_texture_object *stObj,
@@ -1803,13 +1759,20 @@ st_finalize_texture(GLcontext *ctx,
*needFlush = GL_FALSE;
- /* We know/require this is true by now:
- */
- assert(stObj->base._Complete);
+ if (stObj->base._Complete) {
+ /* The texture is complete and we know exactly how many mipmap levels
+ * are present/needed. This is conditional because we may be called
+ * from the st_generate_mipmap() function when the texture object is
+ * incomplete. In that case, we'll have set stObj->lastLevel before
+ * we get here.
+ */
+ if (stObj->base.MinFilter == GL_LINEAR ||
+ stObj->base.MinFilter == GL_NEAREST)
+ stObj->lastLevel = stObj->base.BaseLevel;
+ else
+ stObj->lastLevel = stObj->base._MaxLevel - stObj->base.BaseLevel;
+ }
- /* What levels must the texture include at a minimum?
- */
- calculate_first_last_level(stObj);
firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
/* If both firstImage and stObj point to a texture which can contain
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 8514b6b3756..96969c736c0 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -332,7 +332,7 @@ void st_init_driver_functions(struct dd_function_table *functions)
st_init_feedback_functions(functions);
#endif
st_init_program_functions(functions);
-#if FEATURE_ARB_occlusion_query
+#if FEATURE_queryobj
st_init_query_functions(functions);
#endif
st_init_readpixels_functions(functions);
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 503a5f34a3f..c76bff91819 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -328,23 +328,29 @@ get_arrays_bounds(const struct st_vertex_program *vp,
const GLubyte **low, const GLubyte **high)
{
const GLubyte *low_addr = NULL;
+ const GLubyte *high_addr = NULL;
GLuint attr;
- GLint stride;
for (attr = 0; attr < vp->num_inputs; attr++) {
const GLuint mesaAttr = vp->index_to_input[attr];
+ const GLint stride = arrays[mesaAttr]->StrideB;
const GLubyte *start = arrays[mesaAttr]->Ptr;
- stride = arrays[mesaAttr]->StrideB;
+ const unsigned sz = (arrays[mesaAttr]->Size *
+ _mesa_sizeof_type(arrays[mesaAttr]->Type));
+ const GLubyte *end = start + (max_index * stride) + sz;
+
if (attr == 0) {
low_addr = start;
+ high_addr = end;
}
else {
low_addr = MIN2(low_addr, start);
+ high_addr = MAX2(high_addr, end);
}
}
*low = low_addr;
- *high = low_addr + (max_index + 1) * stride;
+ *high = high_addr;
}
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 58f69336523..f75b2348b82 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -27,6 +27,7 @@
#include "main/imports.h"
+#include "main/macros.h"
#include "main/mipmap.h"
#include "main/teximage.h"
#include "main/texformat.h"
@@ -161,6 +162,43 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
}
+/**
+ * Compute the expected number of mipmap levels in the texture given
+ * the width/height/depth of the base image and the GL_TEXTURE_BASE_LEVEL/
+ * GL_TEXTURE_MAX_LEVEL settings. This will tell us how many mipmap
+ * level should be generated.
+ */
+static GLuint
+compute_num_levels(GLcontext *ctx,
+ struct gl_texture_object *texObj,
+ GLenum target)
+{
+ if (target == GL_TEXTURE_RECTANGLE_ARB) {
+ return 1;
+ }
+ else {
+ const GLuint maxLevels = texObj->MaxLevel - texObj->BaseLevel + 1;
+ const struct gl_texture_image *baseImage =
+ _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel);
+ GLuint size, numLevels;
+
+ size = MAX2(baseImage->Width2, baseImage->Height2);
+ size = MAX2(size, baseImage->Depth2);
+
+ numLevels = 0;
+
+ while (size > 0) {
+ numLevels++;
+ size >>= 1;
+ }
+
+ numLevels = MIN2(numLevels, maxLevels);
+
+ return numLevels;
+ }
+}
+
+
void
st_generate_mipmap(GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj)
@@ -174,9 +212,49 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
if (!pt)
return;
- lastLevel = pt->last_level;
+ /* find expected last mipmap level */
+ lastLevel = compute_num_levels(ctx, texObj, target) - 1;
+
+ if (pt->last_level < lastLevel) {
+ /* The current gallium texture doesn't have space for all the
+ * mipmap levels we need to generate. So allocate a new texture.
+ */
+ struct st_texture_object *stObj = st_texture_object(texObj);
+ struct pipe_texture *oldTex = stObj->pt;
+ GLboolean needFlush;
+
+ /* create new texture with space for more levels */
+ stObj->pt = st_texture_create(st,
+ oldTex->target,
+ oldTex->format,
+ lastLevel,
+ oldTex->width[0],
+ oldTex->height[0],
+ oldTex->depth[0],
+ oldTex->tex_usage);
+
+ /* The texture isn't in a "complete" state yet so set the expected
+ * lastLevel here, since it won't get done in st_finalize_texture().
+ */
+ stObj->lastLevel = lastLevel;
+
+ /* This will copy the old texture's base image into the new texture
+ * which we just allocated.
+ */
+ st_finalize_texture(ctx, st->pipe, texObj, &needFlush);
+
+ /* release the old tex (will likely be freed too) */
+ pipe_texture_reference(&oldTex, NULL);
+
+ pt = stObj->pt;
+ }
+
+ assert(lastLevel <= pt->last_level);
- if (!st_render_mipmap(st, target, pt, baseLevel, lastLevel)) {
+ /* Recall that the Mesa BaseLevel image is stored in the gallium
+ * texture's level[0] position. So pass baseLevel=0 here.
+ */
+ if (!st_render_mipmap(st, target, pt, 0, lastLevel)) {
fallback_generate_mipmap(ctx, target, texObj);
}
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 04be57f8ffa..b0a1b529f1e 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -869,3 +869,14 @@ out:
return tokens;
}
+
+
+/**
+ * Tokens cannot be free with _mesa_free otherwise the builtin gallium
+ * malloc debugging will get confused.
+ */
+void
+st_free_tokens(const struct tgsi_token *tokens)
+{
+ FREE((void *)tokens);
+}
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h
index 679d0ddd41b..c0d1ff59e1f 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.h
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h
@@ -56,6 +56,9 @@ st_translate_mesa_program(
const ubyte outputSemanticIndex[],
const GLbitfield outputFlags[] );
+void
+st_free_tokens(const struct tgsi_token *tokens);
+
#if defined __cplusplus
} /* extern "C" */
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 5f9d2a6dad9..927f60cc7e9 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -317,7 +317,7 @@ st_translate_vertex_program(struct st_context *st,
/* free old shader state, if any */
if (stvp->state.tokens) {
- _mesa_free((void *) stvp->state.tokens);
+ st_free_tokens(stvp->state.tokens);
stvp->state.tokens = NULL;
}
if (stvp->driver_shader) {
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index bbc2830e694..ba8d1e8cc16 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -577,7 +577,6 @@ st_teximage_flush_before_map(struct st_context *st,
pipe->is_texture_referenced(pipe, pt, face, level);
if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
- usage == PIPE_TRANSFER_WRITE ||
- usage == PIPE_TRANSFER_READ_WRITE))
+ (usage & PIPE_TRANSFER_WRITE)))
st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
}