summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c7
-rw-r--r--src/mesa/pipe/i915simple/i915_state_sampler.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_texture.c30
-rw-r--r--src/mesa/pipe/i965simple/brw_tex_layout.c8
-rw-r--r--src/mesa/pipe/i965simple/brw_wm_surface_state.c2
-rw-r--r--src/mesa/pipe/p_state.h14
-rw-r--r--src/mesa/pipe/softpipe/sp_state_sampler.c4
-rw-r--r--src/mesa/pipe/softpipe/sp_tex_sample.c18
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.c4
9 files changed, 44 insertions, 45 deletions
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 950ea52d60..abd5571b88 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -250,6 +250,13 @@ i915_create_sampler_state(struct pipe_context *pipe,
if (sampler->normalized_coords)
cso->state[1] |= SS3_NORMALIZED_COORDS;
+ if (0) /* XXX not tested yet */
+ {
+ int minlod = (int) (16.0 * sampler->min_lod);
+ minlod = CLAMP(minlod, 0, 16 * 11);
+ cso->state[1] |= (minlod << SS3_MIN_LOD_SHIFT);
+ }
+
{
ubyte r = float_to_ubyte(sampler->border_color[0]);
ubyte g = float_to_ubyte(sampler->border_color[1]);
diff --git a/src/mesa/pipe/i915simple/i915_state_sampler.c b/src/mesa/pipe/i915simple/i915_state_sampler.c
index 0dbbc5241d..9c1a5bbbd6 100644
--- a/src/mesa/pipe/i915simple/i915_state_sampler.c
+++ b/src/mesa/pipe/i915simple/i915_state_sampler.c
@@ -185,7 +185,7 @@ i915_update_texture(struct i915_context *i915, uint unit,
const struct pipe_texture *pt = &tex->base;
uint format, pitch;
const uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
- const uint num_levels = pt->last_level - pt->first_level;
+ const uint num_levels = pt->last_level;
assert(tex);
assert(width);
diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c
index 6faeab134a..6d37ae3d74 100644
--- a/src/mesa/pipe/i915simple/i915_texture.c
+++ b/src/mesa/pipe/i915simple/i915_texture.c
@@ -118,11 +118,11 @@ i945_miptree_layout_2d( struct i915_texture *tex )
tex->pitch = pt->width[0];
/* May need to adjust pitch to accomodate the placement of
- * the 2nd mipmap. This occurs when the alignment
+ * the 2nd mipmap level. This occurs when the alignment
* constraints of mipmap placement push the right edge of the
- * 2nd mipmap out past the width of its parent.
+ * 2nd mipmap level out past the width of its parent.
*/
- if (pt->first_level != pt->last_level) {
+ if (pt->last_level > 0) {
unsigned mip1_width = align_int(minify(pt->width[0]), align_w)
+ minify(minify(pt->width[0]));
@@ -136,7 +136,7 @@ i945_miptree_layout_2d( struct i915_texture *tex )
tex->pitch = align_int(tex->pitch * pt->cpp, 4) / pt->cpp;
tex->total_height = 0;
- for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
+ for (level = 0; level <= pt->last_level; level++) {
unsigned img_height;
i915_miptree_set_level_info(tex, level, 1, x, y, width, height, 1);
@@ -152,9 +152,9 @@ i945_miptree_layout_2d( struct i915_texture *tex )
*/
tex->total_height = MAX2(tex->total_height, y + img_height);
- /* Layout_below: step right after second mipmap.
+ /* Layout_below: step right after second mipmap level.
*/
- if (level == pt->first_level + 1) {
+ if (level == 1) {
x += align_int(width, align_w);
}
else {
@@ -204,7 +204,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
tex->pitch = ((dim * pt->cpp * 2 + 3) & ~3) / pt->cpp;
tex->total_height = dim * 4;
- for (level = pt->first_level; level <= pt->last_level; level++) {
+ for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_level_info(tex, level, 6,
0, 0,
/*OLD: tex->pitch, tex->total_height,*/
@@ -219,7 +219,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
unsigned y = initial_offsets[face][1] * dim;
unsigned d = dim;
- for (level = pt->first_level; level <= pt->last_level; level++) {
+ for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_image_offset(tex, level, face, x, y);
d >>= 1;
x += step_offsets[face][0] * d;
@@ -240,7 +240,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
/* XXX: hardware expects/requires 9 levels at minimum.
*/
- for (level = pt->first_level; level <= MAX2(8, pt->last_level);
+ for (level = 0; level <= MAX2(8, pt->last_level);
level++) {
i915_miptree_set_level_info(tex, level, depth, 0, tex->total_height,
width, height, depth);
@@ -256,7 +256,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
/* Fixup depth image_offsets:
*/
depth = pt->depth[0];
- for (level = pt->first_level; level <= pt->last_level; level++) {
+ for (level = 0; level <= pt->last_level; level++) {
unsigned i;
for (i = 0; i < depth; i++)
i915_miptree_set_image_offset(tex, level, i,
@@ -282,7 +282,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
tex->pitch = ((pt->width[0] * pt->cpp + 3) & ~3) / pt->cpp;
tex->total_height = 0;
- for (level = pt->first_level; level <= pt->last_level; level++) {
+ for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_level_info(tex, level, 1,
0, tex->total_height,
width, height, 1);
@@ -337,7 +337,7 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
/* Set all the levels to effectively occupy the whole rectangular region.
*/
- for (level = pt->first_level; level <= pt->last_level; level++) {
+ for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_level_info(tex, level, 6,
0, 0,
lvlWidth, lvlHeight, 1);
@@ -355,12 +355,12 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
y = tex->total_height - 4;
x = (face - 4) * 8;
}
- else if (dim < 4 && (face > 0 || pt->first_level > 0)) {
+ else if (dim < 4 && (face > 0)) {
y = tex->total_height - 4;
x = face * 8;
}
- for (level = pt->first_level; level <= pt->last_level; level++) {
+ for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_image_offset(tex, level, face, x, y);
d >>= 1;
@@ -418,7 +418,7 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
pack_x_pitch = tex->pitch;
pack_x_nr = 1;
- for (level = pt->first_level; level <= pt->last_level; level++) {
+ for (level = 0; level <= pt->last_level; level++) {
unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6;
int x = 0;
int y = 0;
diff --git a/src/mesa/pipe/i965simple/brw_tex_layout.c b/src/mesa/pipe/i965simple/brw_tex_layout.c
index 405fd1f794..90561f1307 100644
--- a/src/mesa/pipe/i965simple/brw_tex_layout.c
+++ b/src/mesa/pipe/i965simple/brw_tex_layout.c
@@ -146,7 +146,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
* constraints of mipmap placement push the right edge of the
* 2nd mipmap out past the width of its parent.
*/
- if (pt->first_level != pt->last_level) {
+ if (pt->last_level > 0) {
unsigned mip1_width;
if (pt->compressed) {
@@ -168,7 +168,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
tex->pitch = align(tex->pitch * pt->cpp, 4) / pt->cpp;
tex->total_height = 0;
- for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
+ for (level = 0; level <= pt->last_level; level++) {
unsigned img_height;
intel_miptree_set_level_info(tex, level, 1, x, y, width,
@@ -187,7 +187,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
/* Layout_below: step right after second mipmap.
*/
- if (level == pt->first_level + 1) {
+ if (level == 1) {
x += align(width, align_w);
}
else {
@@ -234,7 +234,7 @@ static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture
pack_x_pitch = tex->pitch;
pack_x_nr = 1;
- for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
+ for (level = 0; level <= pt->last_level; level++) {
unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6;
int x = 0;
int y = 0;
diff --git a/src/mesa/pipe/i965simple/brw_wm_surface_state.c b/src/mesa/pipe/i965simple/brw_wm_surface_state.c
index cbb4f2efd3..d16d919bce 100644
--- a/src/mesa/pipe/i965simple/brw_wm_surface_state.c
+++ b/src/mesa/pipe/i965simple/brw_wm_surface_state.c
@@ -154,7 +154,7 @@ void brw_update_texture_surface( struct brw_context *brw,
/* Updated in emit_reloc */
surf.ss1.base_addr = brw_buffer_offset( brw, tObj->buffer );
- surf.ss2.mip_count = tObj->base.last_level - tObj->base.first_level;
+ surf.ss2.mip_count = tObj->base.last_level;
surf.ss2.width = tObj->base.width[0] - 1;
surf.ss2.height = tObj->base.height[0] - 1;
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 83ca43f678..4d3a6b2f41 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -234,14 +234,9 @@ struct pipe_sampler_state
unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */
unsigned compare_func:3; /**< PIPE_FUNC_x */
unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */
- float shadow_ambient; /**< shadow test fail color/intensity */
- float min_lod;
- float max_lod;
- float lod_bias;
-#if 0 /* need these? */
- int BaseLevel; /**< min mipmap level, OpenGL 1.2 */
- int MaxLevel; /**< max mipmap level, OpenGL 1.2 */
-#endif
+ float shadow_ambient; /**< shadow test fail color/intensity */
+ float lod_bias; /**< LOD/lambda bias */
+ float min_lod, max_lod; /**< LOD clamp range, after bias */
float border_color[4];
float max_anisotropy;
};
@@ -277,8 +272,7 @@ struct pipe_texture
enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
enum pipe_format format; /**< PIPE_FORMAT_x */
- unsigned first_level;
- unsigned last_level;
+ unsigned last_level; /**< Index of last mipmap level present/defined */
unsigned width[PIPE_MAX_TEXTURE_LEVELS];
unsigned height[PIPE_MAX_TEXTURE_LEVELS];
diff --git a/src/mesa/pipe/softpipe/sp_state_sampler.c b/src/mesa/pipe/softpipe/sp_state_sampler.c
index 291bbc40ad..6a5a643c89 100644
--- a/src/mesa/pipe/softpipe/sp_state_sampler.c
+++ b/src/mesa/pipe/softpipe/sp_state_sampler.c
@@ -34,6 +34,8 @@
#include "sp_state.h"
#include "sp_texture.h"
#include "sp_tile_cache.h"
+#include "pipe/draw/draw_context.h"
+
void *
@@ -73,6 +75,8 @@ softpipe_set_sampler_texture(struct pipe_context *pipe,
{
struct softpipe_context *softpipe = softpipe_context(pipe);
+ draw_flush(softpipe->draw);
+
assert(unit < PIPE_MAX_SAMPLERS);
softpipe->texture[unit] = softpipe_texture(texture); /* ptr, not struct */
diff --git a/src/mesa/pipe/softpipe/sp_tex_sample.c b/src/mesa/pipe/softpipe/sp_tex_sample.c
index 5e215c433a..325bdb86da 100644
--- a/src/mesa/pipe/softpipe/sp_tex_sample.c
+++ b/src/mesa/pipe/softpipe/sp_tex_sample.c
@@ -449,7 +449,6 @@ compute_lambda(struct tgsi_sampler *sampler,
}
lambda = LOG2(rho);
-
lambda += lodbias + sampler->state->lod_bias;
lambda = CLAMP(lambda, sampler->state->min_lod, sampler->state->max_lod);
@@ -457,7 +456,6 @@ compute_lambda(struct tgsi_sampler *sampler,
}
-
/**
* Do several things here:
* 1. Compute lambda from the texcoords, if needed
@@ -477,7 +475,7 @@ choose_mipmap_levels(struct tgsi_sampler *sampler,
if (sampler->state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) {
/* no mipmap selection needed */
*imgFilter = sampler->state->mag_img_filter;
- *level0 = *level1 = sampler->texture->first_level;
+ *level0 = *level1 = (int) sampler->state->min_lod;
}
else {
float lambda;
@@ -492,7 +490,7 @@ choose_mipmap_levels(struct tgsi_sampler *sampler,
if (lambda < 0.0) { /* XXX threshold depends on the filter */
/* magnifying */
*imgFilter = sampler->state->mag_img_filter;
- *level0 = *level1 = sampler->texture->first_level;
+ *level0 = *level1 = 0;
}
else {
/* minifying */
@@ -503,19 +501,13 @@ choose_mipmap_levels(struct tgsi_sampler *sampler,
/* Nearest mipmap level */
const int lvl = (int) (lambda + 0.5);
*level0 =
- *level1 = CLAMP(lvl,
- (int) sampler->texture->first_level,
- (int) sampler->texture->last_level);
+ *level1 = CLAMP(lvl, 0, (int) sampler->texture->last_level);
}
else {
/* Linear interpolation between mipmap levels */
const int lvl = (int) lambda;
- *level0 = CLAMP(lvl,
- (int) sampler->texture->first_level,
- (int) sampler->texture->last_level);
- *level1 = CLAMP(lvl + 1,
- (int) sampler->texture->first_level,
- (int) sampler->texture->last_level);
+ *level0 = CLAMP(lvl, 0, (int) sampler->texture->last_level);
+ *level1 = CLAMP(lvl + 1, 0, (int) sampler->texture->last_level);
*levelBlend = FRAC(lambda); /* blending weight between levels */
}
}
diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c
index fd2cc3dbbb..6de7a9b543 100644
--- a/src/mesa/pipe/softpipe/sp_texture.c
+++ b/src/mesa/pipe/softpipe/sp_texture.c
@@ -61,7 +61,7 @@ softpipe_texture_layout(struct softpipe_texture * spt)
spt->buffer_size = 0;
- for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
+ for (level = 0; level <= pt->last_level; level++) {
pt->width[level] = width;
pt->height[level] = height;
pt->depth[level] = depth;
@@ -139,6 +139,8 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
struct softpipe_texture *spt = softpipe_texture(pt);
struct pipe_surface *ps;
+ assert(level <= pt->last_level);
+
ps = pipe->winsys->surface_alloc(pipe->winsys);
if (ps) {
assert(ps->refcount);