summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--progs/tests/copypixrate.c63
-rw-r--r--src/gallium/auxiliary/draw/draw_aaline.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pstipple.c6
-rw-r--r--src/gallium/auxiliary/util/u_handle_table.c18
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c30
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_per_fragment.c135
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_per_fragment.h3
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.c21
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.h2
-rw-r--r--src/gallium/drivers/cell/spu/spu_tri.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_state_sampler.c6
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c20
-rw-r--r--src/gallium/include/pipe/p_format.h72
-rw-r--r--src/gallium/include/pipe/p_screen.h1
-rw-r--r--src/mesa/SConscript3
-rw-r--r--src/mesa/main/bufferobj.c141
-rw-r--r--src/mesa/main/bufferobj.h33
-rw-r--r--src/mesa/main/context.c4
-rw-r--r--src/mesa/main/drawpix.c62
-rw-r--r--src/mesa/main/teximage.c3
-rw-r--r--src/mesa/shader/program.c2
-rw-r--r--src/mesa/shader/shader_api.c6
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c7
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c43
-rw-r--r--src/mesa/state_tracker/st_atom_shader.h6
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c21
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c20
-rw-r--r--src/mesa/state_tracker/st_cb_program.c57
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c17
-rw-r--r--src/mesa/state_tracker/st_extensions.c15
-rw-r--r--src/mesa/state_tracker/st_program.c10
-rw-r--r--src/mesa/swrast/s_bitmap.c32
-rw-r--r--src/mesa/swrast/s_drawpix.c29
-rw-r--r--src/mesa/swrast/s_readpix.c28
35 files changed, 572 insertions, 355 deletions
diff --git a/progs/tests/copypixrate.c b/progs/tests/copypixrate.c
index e9a42a1c8c..142315364c 100644
--- a/progs/tests/copypixrate.c
+++ b/progs/tests/copypixrate.c
@@ -73,6 +73,32 @@ Rand(int max)
}
+static void
+BlitOne(void)
+{
+ int x, y;
+
+ do {
+ x = Rand(WinWidth);
+ y = Rand(WinHeight);
+ } while (x <= ImgWidth && y <= ImgHeight);
+
+#ifdef GL_EXT_framebuffer_blit
+ if (UseBlit)
+ {
+ glBlitFramebufferEXT_func(0, 0, ImgWidth, ImgHeight,
+ x, y, x + ImgWidth, y + ImgHeight,
+ GL_COLOR_BUFFER_BIT, GL_LINEAR);
+ }
+ else
+#endif
+ {
+ glWindowPos2iARB(x, y);
+ glCopyPixels(0, 0, ImgWidth, ImgHeight, GL_COLOR);
+ }
+}
+
+
/**
* Measure glCopyPixels rate
*/
@@ -96,30 +122,14 @@ RunTest(void)
bpp = (r + g + b + a) / 8;
do {
- int x, y;
- x = Rand(WinWidth);
- y = Rand(WinHeight);
+ BlitOne();
- if (x > ImgWidth || y > ImgHeight) {
-#ifdef GL_EXT_framebuffer_blit
- if (UseBlit)
- {
- glBlitFramebufferEXT_func(0, 0, ImgWidth, ImgHeight,
- x, y, x + ImgWidth, y + ImgHeight,
- GL_COLOR_BUFFER_BIT, GL_LINEAR);
- }
- else
-#endif
- {
- glWindowPos2iARB(x, y);
- glCopyPixels(0, 0, ImgWidth, ImgHeight, GL_COLOR);
- }
- glFinish(); /* XXX OK? */
+ if (Buffer == GL_FRONT)
+ glFinish(); /* XXX to view progress */
- iters++;
+ iters++;
- t1 = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
- }
+ t1 = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
} while (t1 - t0 < 5.0);
glDisable(GL_ALPHA_TEST);
@@ -151,8 +161,10 @@ Draw(void)
else
glutSwapBuffers();
+#if 1
printf("exiting\n");
exit(0);
+#endif
}
@@ -175,9 +187,12 @@ Key(unsigned char key, int x, int y)
(void) x;
(void) y;
switch (key) {
- case 27:
- exit(0);
- break;
+ case 'b':
+ BlitOne();
+ break;
+ case 27:
+ exit(0);
+ break;
}
glutPostRedisplay();
}
diff --git a/src/gallium/auxiliary/draw/draw_aaline.c b/src/gallium/auxiliary/draw/draw_aaline.c
index b4fa6bd967..6742f7f4b9 100644
--- a/src/gallium/auxiliary/draw/draw_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_aaline.c
@@ -665,7 +665,14 @@ aaline_reset_stipple_counter(struct draw_stage *stage)
static void
aaline_destroy(struct draw_stage *stage)
{
+ struct aaline_stage *aaline = aaline_stage(stage);
+
+ aaline->pipe->delete_sampler_state(aaline->pipe, aaline->sampler_cso);
+
+ pipe_texture_release(&aaline->texture);
+
draw_free_temp_verts( stage );
+
FREE( stage );
}
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 4cca965ac1..41da93cdf8 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -113,6 +113,8 @@ void draw_destroy( struct draw_context *draw )
draw->pipeline.aaline->destroy( draw->pipeline.aaline );
if (draw->pipeline.aapoint)
draw->pipeline.aapoint->destroy( draw->pipeline.aapoint );
+ if (draw->pipeline.pstipple)
+ draw->pipeline.pstipple->destroy( draw->pipeline.pstipple );
if (draw->pipeline.rasterize)
draw->pipeline.rasterize->destroy( draw->pipeline.rasterize );
tgsi_exec_machine_free_data(&draw->machine);
diff --git a/src/gallium/auxiliary/draw/draw_pstipple.c b/src/gallium/auxiliary/draw/draw_pstipple.c
index 9d154a6838..bd8d3a76ae 100644
--- a/src/gallium/auxiliary/draw/draw_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pstipple.c
@@ -534,6 +534,12 @@ pstip_reset_stipple_counter(struct draw_stage *stage)
static void
pstip_destroy(struct draw_stage *stage)
{
+ struct pstip_stage *pstip = pstip_stage(stage);
+
+ pstip->pipe->delete_sampler_state(pstip->pipe, pstip->sampler_cso);
+
+ pipe_texture_release(&pstip->texture);
+
draw_free_temp_verts( stage );
FREE( stage );
}
diff --git a/src/gallium/auxiliary/util/u_handle_table.c b/src/gallium/auxiliary/util/u_handle_table.c
index 5a731a6b96..2176a00959 100644
--- a/src/gallium/auxiliary/util/u_handle_table.c
+++ b/src/gallium/auxiliary/util/u_handle_table.c
@@ -170,7 +170,7 @@ handle_table_set(struct handle_table *ht,
unsigned index;
assert(ht);
- assert(handle > 0);
+ assert(handle);
if(!handle)
return 0;
@@ -184,7 +184,9 @@ handle_table_set(struct handle_table *ht,
if(!handle_table_resize(ht, index))
return 0;
- assert(!ht->objects[index]);
+ if(ht->objects[index] && ht->destroy)
+ ht->destroy(ht->objects[index]);
+
ht->objects[index] = object;
return handle;
@@ -198,13 +200,11 @@ handle_table_get(struct handle_table *ht,
void *object;
assert(ht);
- assert(handle > 0);
- assert(handle <= ht->size);
+ assert(handle);
if(!handle || handle > ht->size)
return NULL;
object = ht->objects[handle - 1];
- assert(object);
return object;
}
@@ -218,18 +218,14 @@ handle_table_remove(struct handle_table *ht,
unsigned index;
assert(ht);
- assert(handle > 0);
- assert(handle <= ht->size);
+ assert(handle);
if(!handle || handle > ht->size)
return;
index = handle - 1;
object = ht->objects[index];
- if(!object) {
- /* XXX: this warning may be noisy for legitimate use -- remove later */
- debug_warning("removing empty handle");
+ if(!object)
return;
- }
if(ht->destroy)
ht->destroy(object);
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index 86fcdcff1f..00f4be7401 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -1,5 +1,5 @@
/**************************************************************************
- *
+ *
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
@@ -10,11 +10,11 @@
* 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.
@@ -22,7 +22,7 @@
* 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.
- *
+ *
**************************************************************************/
/* Authors:
@@ -47,7 +47,7 @@ cell_create_blend_state(struct pipe_context *pipe,
struct cell_blend_state *cb = MALLOC(sizeof(struct cell_blend_state));
(void) memcpy(cb, blend, sizeof(*blend));
- cb->code.store = NULL;
+ cell_generate_alpha_blend(cb);
return cb;
}
@@ -57,16 +57,10 @@ static void
cell_bind_blend_state(struct pipe_context *pipe, void *state)
{
struct cell_context *cell = cell_context(pipe);
- struct cell_blend_state *blend = (struct cell_blend_state *) state;
-
draw_flush(cell->draw);
- if ((blend != NULL) && (blend->code.store == NULL)) {
- cell_generate_alpha_blend(blend, &cell->blend_color);
- }
-
- cell->blend = blend;
+ cell->blend = (struct cell_blend_state *) state;
cell->dirty |= CELL_NEW_BLEND;
}
@@ -105,7 +99,7 @@ cell_create_depth_stencil_alpha_state(struct pipe_context *pipe,
MALLOC(sizeof(struct cell_depth_stencil_alpha_state));
(void) memcpy(cdsa, depth_stencil, sizeof(*depth_stencil));
- cdsa->code.store = NULL;
+ cell_generate_depth_stencil_test(cdsa);
return cdsa;
}
@@ -116,16 +110,11 @@ cell_bind_depth_stencil_alpha_state(struct pipe_context *pipe,
void *depth_stencil)
{
struct cell_context *cell = cell_context(pipe);
- struct cell_depth_stencil_alpha_state *cdsa =
- (struct cell_depth_stencil_alpha_state *) depth_stencil;
draw_flush(cell->draw);
- if ((cdsa != NULL) && (cdsa->code.store == NULL)) {
- cell_generate_depth_stencil_test(cdsa);
- }
-
- cell->depth_stencil = cdsa;
+ cell->depth_stencil =
+ (struct cell_depth_stencil_alpha_state *) depth_stencil;
cell->dirty |= CELL_NEW_DEPTH_STENCIL;
}
@@ -362,4 +351,3 @@ cell_init_state_functions(struct cell_context *cell)
cell->pipe.set_scissor_state = cell_set_scissor_state;
cell->pipe.set_viewport_state = cell_set_viewport_state;
}
-
diff --git a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c
index 988c251e20..c750b1d89d 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c
@@ -72,8 +72,8 @@ emit_alpha_test(struct pipe_depth_stencil_alpha_state *dsa,
int tmp_a = spe_allocate_available_register(f);
int tmp_b = spe_allocate_available_register(f);
union {
- float f;
- unsigned u;
+ float f;
+ unsigned u;
} ref_val;
boolean complement = FALSE;
@@ -84,42 +84,42 @@ emit_alpha_test(struct pipe_depth_stencil_alpha_state *dsa,
switch (dsa->alpha.func) {
case PIPE_FUNC_NOTEQUAL:
- complement = TRUE;
- /* FALLTHROUGH */
+ complement = TRUE;
+ /* FALLTHROUGH */
case PIPE_FUNC_EQUAL:
- spe_fceq(f, tmp_a, ref, alphas);
- break;
+ spe_fceq(f, tmp_a, ref, alphas);
+ break;
case PIPE_FUNC_LEQUAL:
- complement = TRUE;
- /* FALLTHROUGH */
+ complement = TRUE;
+ /* FALLTHROUGH */
case PIPE_FUNC_GREATER:
- spe_fcgt(f, tmp_a, ref, alphas);
- break;
+ spe_fcgt(f, tmp_a, ref, alphas);
+ break;
case PIPE_FUNC_LESS:
- complement = TRUE;
- /* FALLTHROUGH */
+ complement = TRUE;
+ /* FALLTHROUGH */
case PIPE_FUNC_GEQUAL:
- spe_fcgt(f, tmp_a, ref, alphas);
- spe_fceq(f, tmp_b, ref, alphas);
- spe_or(f, tmp_a, tmp_b, tmp_a);
- break;
+ spe_fcgt(f, tmp_a, ref, alphas);
+ spe_fceq(f, tmp_b, ref, alphas);
+ spe_or(f, tmp_a, tmp_b, tmp_a);
+ break;
case PIPE_FUNC_ALWAYS:
case PIPE_FUNC_NEVER:
default:
- assert(0);
- break;
+ assert(0);
+ break;
}
if (complement) {
- spe_andc(f, mask, mask, tmp_a);
+ spe_andc(f, mask, mask, tmp_a);
} else {
- spe_and(f, mask, mask, tmp_a);
+ spe_and(f, mask, mask, tmp_a);
}
spe_release_register(f, ref);
@@ -588,19 +588,13 @@ cell_generate_depth_stencil_test(struct cell_depth_stencil_alpha_state *cdsa)
*/
static int
emit_alpha_factor_calculation(struct spe_function *f,
- unsigned factor, float const_alpha,
- int src_alpha, int dst_alpha)
+ unsigned factor,
+ int src_alpha, int dst_alpha, int const_alpha)
{
- union {
- float f;
- unsigned u;
- } alpha;
int factor_reg;
int tmp;
- alpha.f = const_alpha;
-
switch (factor) {
case PIPE_BLENDFACTOR_ONE:
factor_reg = -1;
@@ -621,13 +615,17 @@ emit_alpha_factor_calculation(struct spe_function *f,
break;
case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- const_alpha = 1.0 - const_alpha;
- /* FALLTHROUGH */
- case PIPE_BLENDFACTOR_CONST_ALPHA:
factor_reg = spe_allocate_available_register(f);
- spe_il(f, factor_reg, alpha.u & 0x0ffff);
- spe_ilh(f, factor_reg, alpha.u >> 16);
+ tmp = spe_allocate_available_register(f);
+ spe_il(f, tmp, 1);
+ spe_cuflt(f, tmp, tmp, 0);
+ spe_fs(f, factor_reg, tmp, const_alpha);
+ spe_release_register(f, tmp);
+ break;
+
+ case PIPE_BLENDFACTOR_CONST_ALPHA:
+ factor_reg = const_alpha;
break;
case PIPE_BLENDFACTOR_ZERO:
@@ -674,24 +672,15 @@ emit_alpha_factor_calculation(struct spe_function *f,
static void
emit_color_factor_calculation(struct spe_function *f,
unsigned sF, unsigned mask,
- const struct pipe_blend_color *blend_color,
const int *src,
const int *dst,
+ const int *const_color,
int *factor)
{
- union {
- float f[4];
- unsigned u[4];
- } color;
int tmp;
unsigned i;
- color.f[0] = blend_color->color[0];
- color.f[1] = blend_color->color[1];
- color.f[2] = blend_color->color[2];
- color.f[3] = blend_color->color[3];
-
factor[0] = -1;
factor[1] = -1;
factor[2] = -1;
@@ -748,29 +737,40 @@ emit_color_factor_calculation(struct spe_function *f,
break;
case PIPE_BLENDFACTOR_INV_CONST_COLOR:
- color.f[0] = 1.0 - color.f[0];
- color.f[1] = 1.0 - color.f[1];
- color.f[2] = 1.0 - color.f[2];
- /* FALLTHROUGH */
- case PIPE_BLENDFACTOR_CONST_COLOR:
+ tmp = spe_allocate_available_register(f);
+ spe_il(f, tmp, 1);
+ spe_cuflt(f, tmp, tmp, 0);
+
for (i = 0; i < 3; i++) {
- factor[i] = spe_allocate_available_register(f);
+ factor[i] = spe_allocate_available_register(f);
+
+ spe_fs(f, factor[i], tmp, const_color[i]);
+ }
+ spe_release_register(f, tmp);
+ break;
- spe_il(f, factor[i], color.u[i] & 0x0ffff);
- spe_ilh(f, factor[i], color.u[i] >> 16);
+ case PIPE_BLENDFACTOR_CONST_COLOR:
+ for (i = 0; i < 3; i++) {
+ factor[i] = const_color[i];
}
break;
case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- color.f[3] = 1.0 - color.f[3];
- /* FALLTHROUGH */
- case PIPE_BLENDFACTOR_CONST_ALPHA:
factor[0] = spe_allocate_available_register(f);
factor[1] = factor[0];
factor[2] = factor[0];
- spe_il(f, factor[0], color.u[3] & 0x0ffff);
- spe_ilh(f, factor[0], color.u[3] >> 16);
+ tmp = spe_allocate_available_register(f);
+ spe_il(f, tmp, 1);
+ spe_cuflt(f, tmp, tmp, 0);
+ spe_fs(f, factor[0], tmp, const_color[3]);
+ spe_release_register(f, tmp);
+ break;
+
+ case PIPE_BLENDFACTOR_CONST_ALPHA:
+ factor[0] = const_color[3];
+ factor[1] = factor[0];
+ factor[2] = factor[0];
break;
case PIPE_BLENDFACTOR_ZERO:
@@ -945,8 +945,7 @@ emit_blend_calculation(struct spe_function *f,
* Generate code to perform alpha blending on the SPE
*/
void
-cell_generate_alpha_blend(struct cell_blend_state *cb,
- const struct pipe_blend_color *blend_color)
+cell_generate_alpha_blend(struct cell_blend_state *cb)
{
struct pipe_blend_state *const b = &cb->base;
struct spe_function *const f = &cb->code;
@@ -972,7 +971,13 @@ cell_generate_alpha_blend(struct cell_blend_state *cb,
spe_allocate_register(f, 9),
spe_allocate_register(f, 10),
};
- const int mask = spe_allocate_register(f, 11);
+ const int const_color[4] = {
+ spe_allocate_register(f, 11),
+ spe_allocate_register(f, 12),
+ spe_allocate_register(f, 13),
+ spe_allocate_register(f, 14),
+ };
+ const int mask = spe_allocate_register(f, 15);
unsigned func[4];
unsigned sF[4];
unsigned dF[4];
@@ -1053,8 +1058,7 @@ cell_generate_alpha_blend(struct cell_blend_state *cb,
* the alpha factor, calculate the alpha factor.
*/
if (((b->colormask & 8) != 0) && need_alpha_factor) {
- src_factor[3] = emit_alpha_factor_calculation(f, sF[3],
- blend_color->color[3],
+ src_factor[3] = emit_alpha_factor_calculation(f, sF[3], const_color[3],
frag[3], pixel[3]);
/* If the alpha destination blend factor is the same as the alpha source
@@ -1062,8 +1066,7 @@ cell_generate_alpha_blend(struct cell_blend_state *cb,
*/
dst_factor[3] = (dF[3] == sF[3])
? src_factor[3]
- : emit_alpha_factor_calculation(f, dF[3],
- blend_color->color[3],
+ : emit_alpha_factor_calculation(f, dF[3], const_color[3],
frag[3], pixel[3]);
}
@@ -1080,8 +1083,7 @@ cell_generate_alpha_blend(struct cell_blend_state *cb,
emit_color_factor_calculation(f,
b->rgb_src_factor,
b->colormask,
- blend_color,
- frag, pixel, src_factor);
+ frag, pixel, const_color, src_factor);
}
@@ -1101,8 +1103,7 @@ cell_generate_alpha_blend(struct cell_blend_state *cb,
emit_color_factor_calculation(f,
b->rgb_dst_factor,
b->colormask,
- blend_color,
- frag, pixel, dst_factor);
+ frag, pixel, const_color, dst_factor);
}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.h b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.h
index 541c3b3be0..f699247f9e 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.h
+++ b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.h
@@ -29,7 +29,6 @@ extern void
cell_generate_depth_stencil_test(struct cell_depth_stencil_alpha_state *cdsa);
extern void
-cell_generate_alpha_blend(struct cell_blend_state *cb,
- const struct pipe_blend_color *blend_color);
+cell_generate_alpha_blend(struct cell_blend_state *cb);
#endif /* CELL_STATE_PER_FRAGMENT_H */
diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c
index 41bebf5362..0a490ab277 100644
--- a/src/gallium/drivers/cell/spu/spu_main.c
+++ b/src/gallium/drivers/cell/spu/spu_main.c
@@ -64,21 +64,6 @@ static unsigned char depth_stencil_code_buffer[4 * 64]
static unsigned char fb_blend_code_buffer[4 * 64]
ALIGN16_ATTRIB;
-static struct spu_blend_results
-default_blend(qword frag_r, qword frag_g, qword frag_b, qword frag_a,
- qword pixel_r, qword pixel_g, qword pixel_b, qword pixel_a,
- qword frag_mask)
-{
- struct spu_blend_results result;
-
- result.r = si_selb(pixel_r, frag_r, frag_mask);
- result.g = si_selb(pixel_g, frag_g, frag_mask);
- result.b = si_selb(pixel_b, frag_b, frag_mask);
- result.a = si_selb(pixel_a, frag_a, frag_mask);
-
- return result;
-}
-
/**
* Tell the PPU that this SPU has finished copying a buffer to
@@ -285,9 +270,6 @@ cmd_state_blend(const struct cell_command_blend *state)
spu.blend = (blend_func) fb_blend_code_buffer;
spu.read_fb = state->read_fb;
} else {
- /* If there is no code, use the default;
- */
- spu.blend = default_blend;
spu.read_fb = FALSE;
}
}
@@ -622,9 +604,6 @@ one_time_init(void)
memset(spu.ctile_status, TILE_STATUS_DEFINED, sizeof(spu.ctile_status));
memset(spu.ztile_status, TILE_STATUS_DEFINED, sizeof(spu.ztile_status));
invalidate_tex_cache();
-
- spu.blend = default_blend;
- spu.read_fb = FALSE;
}
diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h
index 56d0968676..49f5d99674 100644
--- a/src/gallium/drivers/cell/spu/spu_main.h
+++ b/src/gallium/drivers/cell/spu/spu_main.h
@@ -77,6 +77,7 @@ struct spu_blend_results {
typedef struct spu_blend_results (*blend_func)(
qword frag_r, qword frag_g, qword frag_b, qword frag_a,
qword pixel_r, qword pixel_g, qword pixel_b, qword pixel_a,
+ qword const_r, qword const_g, qword const_b, qword const_a,
qword frag_mask);
struct spu_framebuffer {
@@ -108,6 +109,7 @@ struct spu_global
boolean read_fb;
blend_func blend;
+ qword const_blend_color[4] ALIGN16_ATTRIB;
struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS];
struct cell_command_texture texture;
diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c
index c4272d6e93..e6a1ce01df 100644
--- a/src/gallium/drivers/cell/spu/spu_tri.c
+++ b/src/gallium/drivers/cell/spu/spu_tri.c
@@ -356,6 +356,8 @@ emit_quad( int x, int y, mask_t mask )
const struct spu_blend_results result =
(*spu.blend)(soa_frag[0], soa_frag[1], soa_frag[2], soa_frag[3],
soa_pix[0], soa_pix[1], soa_pix[2], soa_pix[3],
+ spu.const_blend_color[0], spu.const_blend_color[1],
+ spu.const_blend_color[2], spu.const_blend_color[3],
(qword) mask);
diff --git a/src/gallium/drivers/i915simple/i915_state_sampler.c b/src/gallium/drivers/i915simple/i915_state_sampler.c
index 9dbb1b1b23..84f6529a3a 100644
--- a/src/gallium/drivers/i915simple/i915_state_sampler.c
+++ b/src/gallium/drivers/i915simple/i915_state_sampler.c
@@ -206,6 +206,12 @@ i915_update_texture(struct i915_context *i915, uint unit,
| format
| MS3_USE_FENCE_REGS);
+ /*
+ * XXX sampler->max_lod should be used to program the MAX_LOD field below.
+ * Also, when min_filter != mag_filter and there's just one mipmap level,
+ * set max_lod = 1 to make sure i915 chooses between min/mag filtering.
+ */
+
/* MS4 state */
state[1] =
((((pitch / 4) - 1) << MS4_PITCH_SHIFT)
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index a98b3b1a4a..256586ec88 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -81,8 +81,8 @@ softpipe_texture_layout(struct softpipe_texture * spt)
static struct pipe_texture *
-softpipe_texture_create_screen(struct pipe_screen *screen,
- const struct pipe_texture *templat)
+softpipe_texture_create(struct pipe_screen *screen,
+ const struct pipe_texture *templat)
{
struct pipe_winsys *ws = screen->winsys;
struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture);
@@ -110,8 +110,8 @@ softpipe_texture_create_screen(struct pipe_screen *screen,
static void
-softpipe_texture_release_screen(struct pipe_screen *screen,
- struct pipe_texture **pt)
+softpipe_texture_release(struct pipe_screen *screen,
+ struct pipe_texture **pt)
{
if (!*pt)
return;
@@ -136,9 +136,9 @@ softpipe_texture_release_screen(struct pipe_screen *screen,
static struct pipe_surface *
-softpipe_get_tex_surface_screen(struct pipe_screen *screen,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
+softpipe_get_tex_surface(struct pipe_screen *screen,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice)
{
struct pipe_winsys *ws = screen->winsys;
struct softpipe_texture *spt = softpipe_texture(pt);
@@ -197,7 +197,7 @@ softpipe_init_texture_funcs( struct softpipe_context *softpipe )
void
softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
{
- screen->texture_create = softpipe_texture_create_screen;
- screen->texture_release = softpipe_texture_release_screen;
- screen->get_tex_surface = softpipe_get_tex_surface_screen;
+ screen->texture_create = softpipe_texture_create;
+ screen->texture_release = softpipe_texture_release;
+ screen->get_tex_surface = softpipe_get_tex_surface;
}
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index f90087b3c9..3238b152b6 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -38,16 +38,19 @@ extern "C" {
#endif
/**
- * The PIPE_FORMAT is a 32-bit wide bitfield that encodes all the information
- * needed to uniquely describe a pixel format.
+ * The pipe_format enum is a 32-bit wide bitfield that encodes all the
+ * information needed to uniquely describe a pixel format.
*/
/**
- * Possible format layouts -- occupy first 2 bits. The interpretation of
- * the remaining 30 bits depends on a particual format layout.
+ * Possible format layouts are encoded in the first 2 bits.
+ * The interpretation of the remaining 30 bits depends on a particular
+ * format layout.
*/
#define PIPE_FORMAT_LAYOUT_RGBAZS 0
#define PIPE_FORMAT_LAYOUT_YCBCR 1
+#define PIPE_FORMAT_LAYOUT_DXT 2 /**< XXX temporary? */
+
static INLINE uint pf_layout(uint f) /**< PIPE_FORMAT_LAYOUT_ */
{
@@ -74,11 +77,13 @@ static INLINE uint pf_layout(uint f) /**< PIPE_FORMAT_LAYOUT_ */
* Format types for RGBAZS layout.
*/
#define PIPE_FORMAT_TYPE_UNKNOWN 0
-#define PIPE_FORMAT_TYPE_FLOAT 1
-#define PIPE_FORMAT_TYPE_UNORM 2
-#define PIPE_FORMAT_TYPE_SNORM 3
-#define PIPE_FORMAT_TYPE_USCALED 4
-#define PIPE_FORMAT_TYPE_SSCALED 5
+#define PIPE_FORMAT_TYPE_FLOAT 1 /**< 16/32/64-bit/channel formats */
+#define PIPE_FORMAT_TYPE_UNORM 2 /**< uints, normalized to [0,1] */
+#define PIPE_FORMAT_TYPE_SNORM 3 /**< ints, normalized to [-1,1] */
+#define PIPE_FORMAT_TYPE_USCALED 4 /**< uints, not normalized */
+#define PIPE_FORMAT_TYPE_SSCALED 5 /**< ints, not normalized */
+#define PIPE_FORMAT_TYPE_SRGB 6 /**< sRGB colorspace */
+
/**
* Because the destination vector is assumed to be RGBA FLOAT, we
@@ -196,6 +201,20 @@ static INLINE uint pf_rev(pipe_format_ycbcr_t f)
return (f >> 2) & 0x1;
}
+
+/**
+ * Compresssed format layouts (this will probably change)
+ */
+#define _PIPE_FORMAT_DXT( LEVEL, RSIZE, GSIZE, BSIZE, ASIZE ) \
+ ((PIPE_FORMAT_LAYOUT_DXT << 0) | \
+ ((LEVEL) << 2) | \
+ ((RSIZE) << 5) | \
+ ((GSIZE) << 8) | \
+ ((BSIZE) << 11) | \
+ ((ASIZE) << 14) )
+
+
+
/**
* Texture/surface image formats (preliminary)
*/
@@ -281,11 +300,23 @@ enum pipe_format {
PIPE_FORMAT_R8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
PIPE_FORMAT_R8G8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 1, 1, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
PIPE_FORMAT_R8G8B8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R8G8B8A8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED )
+ PIPE_FORMAT_R8G8B8A8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED ),
+ /* sRGB formats */
+ PIPE_FORMAT_L8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
+ PIPE_FORMAT_A8_L8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
+ PIPE_FORMAT_R8G8B8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SRGB ),
+ PIPE_FORMAT_R8G8B8A8_SRGB = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SRGB ),
+
+ /* compressed formats */
+ PIPE_FORMAT_DXT1_RGB = _PIPE_FORMAT_DXT( 1, 8, 8, 8, 0 ),
+ PIPE_FORMAT_DXT1_RGBA = _PIPE_FORMAT_DXT( 1, 8, 8, 8, 8 ),
+ PIPE_FORMAT_DXT3_RGBA = _PIPE_FORMAT_DXT( 3, 8, 8, 8, 8 ),
+ PIPE_FORMAT_DXT5_RGBA = _PIPE_FORMAT_DXT( 5, 8, 8, 8, 8 )
};
/**
+ * Unsigned 8-bit stencil format.
* XXX should remove this, but S8_UNORM is a poor name
*/
#define PIPE_FORMAT_U_S8 PIPE_FORMAT_S8_UNORM
@@ -294,11 +325,12 @@ enum pipe_format {
/**
* Builds pipe format name from format token.
*/
-static INLINE char *pf_sprint_name( char *str, uint format )
+static INLINE char *pf_sprint_name( char *str, enum pipe_format format )
{
strcpy( str, "PIPE_FORMAT_" );
switch (pf_layout( format )) {
- case PIPE_FORMAT_LAYOUT_RGBAZS: {
+ case PIPE_FORMAT_LAYOUT_RGBAZS:
+ {
pipe_format_rgbazs_t rgbazs = (pipe_format_rgbazs_t) format;
uint i;
uint scale = 1 << (pf_exp8( rgbazs ) * 3);
@@ -362,7 +394,8 @@ static INLINE char *pf_sprint_name( char *str, uint format )
}
}
break;
- case PIPE_FORMAT_LAYOUT_YCBCR: {
+ case PIPE_FORMAT_LAYOUT_YCBCR:
+ {
pipe_format_ycbcr_t ycbcr = (pipe_format_ycbcr_t) format;
strcat( str, "YCBCR" );
@@ -375,6 +408,10 @@ static INLINE char *pf_sprint_name( char *str, uint format )
return str;
}
+/**
+ * Return bits for a particular component.
+ * \param comp component index, starting at 0
+ */
static INLINE uint pf_get_component_bits( enum pipe_format format, uint comp )
{
uint size;
@@ -397,6 +434,9 @@ static INLINE uint pf_get_component_bits( enum pipe_format format, uint comp )
return size << (pf_exp8(format) * 3);
}
+/**
+ * Return total bits needed for the pixel format.
+ */
static INLINE uint pf_get_bits( enum pipe_format format )
{
if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) {
@@ -417,7 +457,11 @@ static INLINE uint pf_get_bits( enum pipe_format format )
}
}
-static INLINE uint pf_get_size( enum pipe_format format ) {
+/**
+ * Return bytes per pixel for the given format.
+ */
+static INLINE uint pf_get_size( enum pipe_format format )
+{
assert(pf_get_bits(format) % 8 == 0);
return pf_get_bits(format) / 8;
}
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 6be9a82b68..35bd46d691 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -69,6 +69,7 @@ struct pipe_screen {
float (*get_paramf)( struct pipe_screen *, int param );
+ /**< type is one of PIPE_TEXTURE, PIPE_SURFACE */
boolean (*is_format_supported)( struct pipe_screen *,
enum pipe_format format,
uint type );
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 678e4ad0e8..b816a21b38 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -142,6 +142,8 @@ STATETRACKER_SOURCES = [
'state_tracker/st_atom_texture.c',
'state_tracker/st_atom_viewport.c',
'state_tracker/st_cb_accum.c',
+ 'state_tracker/st_cb_bitmap.c',
+ 'state_tracker/st_cb_blit.c',
'state_tracker/st_cb_bufferobjects.c',
'state_tracker/st_cb_clear.c',
'state_tracker/st_cb_flush.c',
@@ -154,7 +156,6 @@ STATETRACKER_SOURCES = [
'state_tracker/st_cb_readpixels.c',
'state_tracker/st_cb_strings.c',
'state_tracker/st_cb_texture.c',
- 'state_tracker/st_cache.c',
'state_tracker/st_context.c',
'state_tracker/st_debug.c',
'state_tracker/st_draw.c',
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 009055a6ab..e762eb3b63 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul 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"),
@@ -470,6 +470,143 @@ _mesa_validate_pbo_access(GLuint dimensions,
/**
+ * If the source of glBitmap data is a PBO, check that we won't read out
+ * of buffer bounds, then map the buffer.
+ * If not sourcing from a PBO, just return the bitmap pointer.
+ * This is a helper function for (some) drivers.
+ * Return NULL if error.
+ * If non-null return, must call _mesa_unmap_bitmap_pbo() when done.
+ */
+const GLubyte *
+_mesa_map_bitmap_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap)
+{
+ const GLubyte *buf;
+
+ if (unpack->BufferObj->Name) {
+ /* unpack from PBO */
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ unpack->BufferObj);
+ if (!buf)
+ return NULL;
+
+ buf = ADD_POINTERS(buf, bitmap);
+ }
+ else {
+ /* unpack from normal memory */
+ buf = bitmap;
+ }
+
+ return buf;
+}
+
+
+/**
+ * Counterpart to _mesa_map_bitmap_pbo()
+ * This is a helper function for (some) drivers.
+ */
+void
+_mesa_unmap_bitmap_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack)
+{
+ if (unpack->BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
+}
+
+
+/**
+ * \sa _mesa_map_bitmap_pbo
+ */
+const GLvoid *
+_mesa_map_drawpix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels)
+{
+ const GLvoid *buf;
+
+ if (unpack->BufferObj->Name) {
+ /* unpack from PBO */
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ unpack->BufferObj);
+ if (!buf)
+ return NULL;
+
+ buf = ADD_POINTERS(buf, pixels);
+ }
+ else {
+ /* unpack from normal memory */
+ buf = pixels;
+ }
+
+ return buf;
+}
+
+
+/**
+ * \sa _mesa_unmap_bitmap_pbo
+ */
+void
+_mesa_unmap_drapix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack)
+{
+ if (unpack->BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
+}
+
+
+/**
+ * If PBO is bound, map the buffer, return dest pointer in mapped buffer.
+ * Call _mesa_unmap_readpix_pbo() when finished
+ * \return NULL if error
+ */
+void *
+_mesa_map_readpix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *dest)
+{
+ void *buf;
+
+ if (pack->BufferObj->Name) {
+ /* pack into PBO */
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ pack->BufferObj);
+ if (!buf)
+ return NULL;
+
+ buf = ADD_POINTERS(buf, dest);
+ }
+ else {
+ /* pack to normal memory */
+ buf = dest;
+ }
+
+ return buf;
+}
+
+
+/**
+ * Counterpart to _mesa_map_readpix_pbo()
+ */
+void
+_mesa_unmap_readpix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *pack)
+{
+ if (pack->BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, pack->BufferObj);
+ }
+}
+
+
+
+/**
* Return the gl_buffer_object for the given ID.
* Always return NULL for ID 0.
*/
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index f54f9e9ff0..46525f08ae 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 7.1
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul 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"),
@@ -86,6 +86,35 @@ _mesa_validate_pbo_access(GLuint dimensions,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *ptr);
+extern const GLubyte *
+_mesa_map_bitmap_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap);
+
+extern void
+_mesa_unmap_bitmap_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack);
+
+extern const GLvoid *
+_mesa_map_drawpix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels);
+
+extern void
+_mesa_unmap_drapix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack);
+
+
+extern void *
+_mesa_map_readpix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *dest);
+
+extern void
+_mesa_unmap_readpix_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *pack);
+
+
extern void
_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index a9f9bd9da4..d06644f65d 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -695,10 +695,10 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
_mesa_DeleteHashTable(ss->Programs);
#endif
#if FEATURE_ARB_vertex_program
- _mesa_delete_program(ctx, ss->DefaultVertexProgram);
+ ctx->Driver.DeleteProgram(ctx, ss->DefaultVertexProgram);
#endif
#if FEATURE_ARB_fragment_program
- _mesa_delete_program(ctx, ss->DefaultFragmentProgram);
+ ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentProgram);
#endif
#if FEATURE_ATI_fragment_shader
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index ae9c7e29a1..0f64f1c1c0 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul 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"),
@@ -24,6 +24,7 @@
#include "glheader.h"
#include "imports.h"
+#include "bufferobj.h"
#include "context.h"
#include "drawpix.h"
#include "feedback.h"
@@ -183,6 +184,23 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
/* Round, to satisfy conformance tests (matches SGI's OpenGL) */
GLint x = IROUND(ctx->Current.RasterPos[0]);
GLint y = IROUND(ctx->Current.RasterPos[1]);
+
+ if (ctx->Unpack.BufferObj->Name) {
+ /* unpack from PBO */
+ if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(invalid PBO access)");
+ return;
+ }
+ if (ctx->Unpack.BufferObj->Pointer) {
+ /* buffer is mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(PBO is mapped)");
+ return;
+ }
+ }
+
ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type,
&ctx->Unpack, pixels);
}
@@ -303,6 +321,21 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
return;
}
+ if (ctx->Pack.BufferObj->Name) {
+ if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glReadPixels(invalid PBO access)");
+ return;
+ }
+
+ if (ctx->Pack.BufferObj->Pointer) {
+ /* buffer is mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)");
+ return;
+ }
+ }
+
ctx->Driver.ReadPixels(ctx, x, y, width, height,
format, type, &ctx->Pack, pixels);
}
@@ -343,12 +376,27 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
}
if (ctx->RenderMode == GL_RENDER) {
- if (bitmap && width && height) {
- /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
- GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig);
- GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig);
- ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap );
+ /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
+ GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig);
+ GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig);
+
+ if (ctx->Unpack.BufferObj->Name) {
+ /* unpack from PBO */
+ if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
+ GL_COLOR_INDEX, GL_BITMAP,
+ (GLvoid *) bitmap)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBitmap(invalid PBO access)");
+ return;
+ }
+ if (ctx->Unpack.BufferObj->Pointer) {
+ /* buffer is mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
+ return;
+ }
}
+
+ ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap );
}
#if _HAVE_FULL_GL
else if (ctx->RenderMode == GL_FEEDBACK) {
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index f15e404527..384e145520 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2323,9 +2323,6 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
return;
}
- if (!pixels)
- return;
-
_mesa_lock_texture(ctx, texObj);
{
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 3869e31714..39c4ca1dd5 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -354,7 +354,7 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog)
clone->Format = prog->Format;
clone->Instructions = _mesa_alloc_instructions(prog->NumInstructions);
if (!clone->Instructions) {
- _mesa_delete_program(ctx, clone);
+ ctx->Driver.DeleteProgram(ctx, clone);
return NULL;
}
_mesa_copy_instructions(clone->Instructions, prog->Instructions,
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 4470a87af0..4cb8bb8ed1 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -79,7 +79,7 @@ _mesa_clear_shader_program_data(GLcontext *ctx,
/* to prevent a double-free in the next call */
shProg->VertexProgram->Base.Parameters = NULL;
}
- _mesa_delete_program(ctx, &shProg->VertexProgram->Base);
+ ctx->Driver.DeleteProgram(ctx, &shProg->VertexProgram->Base);
shProg->VertexProgram = NULL;
}
@@ -88,7 +88,7 @@ _mesa_clear_shader_program_data(GLcontext *ctx,
/* to prevent a double-free in the next call */
shProg->FragmentProgram->Base.Parameters = NULL;
}
- _mesa_delete_program(ctx, &shProg->FragmentProgram->Base);
+ ctx->Driver.DeleteProgram(ctx, &shProg->FragmentProgram->Base);
shProg->FragmentProgram = NULL;
}
@@ -246,7 +246,7 @@ _mesa_free_shader(GLcontext *ctx, struct gl_shader *sh)
_mesa_free(sh->InfoLog);
for (i = 0; i < sh->NumPrograms; i++) {
assert(sh->Programs[i]);
- _mesa_delete_program(ctx, sh->Programs[i]);
+ ctx->Driver.DeleteProgram(ctx, sh->Programs[i]);
}
if (sh->Programs)
_mesa_free(sh->Programs);
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 21416da2e0..cd7372902b 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -66,7 +66,8 @@ void st_upload_constants( struct st_context *st,
/* Update our own dependency flags. This works because this
* function will also be called whenever the program changes.
*/
- st->constants.tracked_state[id].dirty.mesa = params->StateFlags;
+ st->constants.tracked_state[id].dirty.mesa =
+ (params->StateFlags | _NEW_PROGRAM);
_mesa_load_state_parameters(st->ctx, params);
@@ -115,7 +116,7 @@ static void update_vs_constants(struct st_context *st )
const struct st_tracked_state st_update_vs_constants = {
.name = "st_update_vs_constants",
.dirty = {
- .mesa = 0,
+ .mesa = 0, /* set dynamically above */
.st = ST_NEW_VERTEX_PROGRAM,
},
.update = update_vs_constants
@@ -134,7 +135,7 @@ static void update_fs_constants(struct st_context *st )
const struct st_tracked_state st_update_fs_constants = {
.name = "st_update_fs_constants",
.dirty = {
- .mesa = 0,
+ .mesa = 0, /* set dynamically above */
.st = ST_NEW_FRAGMENT_PROGRAM,
},
.update = update_fs_constants
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 0726688493..ec39026eb3 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -78,34 +78,6 @@ struct translated_vertex_program
/**
- * Free data hanging off the st vert prog.
- */
-void
-st_remove_vertex_program(struct st_context *st, struct st_vertex_program *stvp)
-{
- /* no-op, for now? */
-}
-
-
-/**
- * Free data hanging off the st frag prog.
- */
-void
-st_remove_fragment_program(struct st_context *st,
- struct st_fragment_program *stfp)
-{
- struct translated_vertex_program *xvp, *next;
-
- for (xvp = stfp->vertex_programs; xvp; xvp = next) {
- next = xvp->next;
- /* XXX free xvp->vs */
- free(xvp);
- }
-}
-
-
-
-/**
* Given a vertex program output attribute, return the corresponding
* fragment program input attribute.
* \return -1 for vertex outputs that have no corresponding fragment input
@@ -265,6 +237,21 @@ find_translated_vp(struct st_context *st,
}
+void
+st_free_translated_vertex_programs(struct st_context *st,
+ struct translated_vertex_program *xvp)
+{
+ struct translated_vertex_program *next;
+
+ while (xvp) {
+ next = xvp->next;
+ free(xvp);
+ xvp = next;
+ }
+}
+
+
+
static void
update_linkage( struct st_context *st )
{
diff --git a/src/mesa/state_tracker/st_atom_shader.h b/src/mesa/state_tracker/st_atom_shader.h
index f3124d87c0..8403bc66c9 100644
--- a/src/mesa/state_tracker/st_atom_shader.h
+++ b/src/mesa/state_tracker/st_atom_shader.h
@@ -31,10 +31,8 @@
extern void
-st_remove_vertex_program(struct st_context *, struct st_vertex_program *);
-
-extern void
-st_remove_fragment_program(struct st_context *, struct st_fragment_program *);
+st_free_translated_vertex_programs(struct st_context *st,
+ struct translated_vertex_program *xvp);
#endif /* ST_ATOM_SHADER_H */
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 33256196bb..acc22d4323 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -32,6 +32,7 @@
#include "main/imports.h"
#include "main/image.h"
+#include "main/bufferobj.h"
#include "main/macros.h"
#include "main/texformat.h"
#include "shader/program.h"
@@ -191,7 +192,6 @@ combined_bitmap_fragment_program(GLcontext *ctx)
}
-
/**
* Create a texture which represents a bitmap image.
*/
@@ -224,19 +224,20 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
assert( 0 );
}
+ /* PBO source... */
+ bitmap = _mesa_map_bitmap_pbo(ctx, unpack, bitmap);
+ if (!bitmap) {
+ return NULL;
+ }
+
/**
- * Create a texture.
+ * Create texture to hold bitmap pattern.
*/
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, width, height,
1, 0);
- if (!pt)
+ if (!pt) {
+ _mesa_unmap_bitmap_pbo(ctx, unpack);
return NULL;
-
- if (unpack->BufferObj && unpack->BufferObj->Name) {
- /*
- pt->region = buffer_object_region(unpack->BufferObj);
- */
- printf("st_Bitmap (sourcing from PBO not implemented yet)\n");
}
surface = screen->get_tex_surface(screen, pt, 0, 0, 0);
@@ -301,6 +302,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
} /* row */
+ _mesa_unmap_bitmap_pbo(ctx, unpack);
+
/* Release surface */
pipe_surface_unmap(surface);
pipe_surface_reference(&surface, NULL);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index b4cd93cd54..2ebaf8a2c3 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -32,6 +32,7 @@
#include "main/imports.h"
#include "main/image.h"
+#include "main/bufferobj.h"
#include "main/macros.h"
#include "main/texformat.h"
#include "shader/program.h"
@@ -334,16 +335,15 @@ make_texture(struct st_context *st,
assert(pipeFormat);
cpp = st_sizeof_format(pipeFormat);
+ pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels);
+ if (!pixels)
+ return NULL;
+
pt = st_texture_create(st, PIPE_TEXTURE_2D, pipeFormat, 0, width, height,
1, 0);
- if (!pt)
+ if (!pt) {
+ _mesa_unmap_drapix_pbo(ctx, unpack);
return NULL;
-
- if (unpack->BufferObj && unpack->BufferObj->Name) {
- /*
- pt->region = buffer_object_region(unpack->BufferObj);
- */
- printf("st_DrawPixels (sourcing from PBO not implemented yet)\n");
}
{
@@ -388,6 +388,8 @@ make_texture(struct st_context *st,
ctx->_ImageTransferState = imageTransferStateSave;
}
+ _mesa_unmap_drapix_pbo(ctx, unpack);
+
return pt;
}
@@ -836,9 +838,9 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
bufferFormat = ps->format;
- if (any_fragment_ops(st) ||
+ if (1/*any_fragment_ops(st) ||
any_pixel_transfer_ops(st) ||
- !compatible_formats(format, type, ps->format)) {
+ !compatible_formats(format, type, ps->format)*/) {
/* textured quad */
struct pipe_texture *pt
= make_texture(ctx->st, width, height, format, type, unpack, pixels);
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 0a62e20e0c..a739fcd336 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -126,19 +126,39 @@ static void st_delete_program( GLcontext *ctx,
struct gl_program *prog )
{
struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
switch( prog->Target ) {
case GL_VERTEX_PROGRAM_ARB:
{
struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
- st_remove_vertex_program(st, stvp);
+
+ if (stvp->driver_shader) {
+ pipe->delete_vs_state(pipe, stvp->driver_shader);
+ stvp->driver_shader = NULL;
+ }
+
+ if (stvp->state.tokens) {
+ FREE((void *) stvp->state.tokens);
+ stvp->state.tokens = NULL;
+ }
}
break;
case GL_FRAGMENT_PROGRAM_ARB:
{
- struct st_fragment_program *stfp
- = (struct st_fragment_program *) prog;
- st_remove_fragment_program(st, stfp);
+ struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
+
+ if (stfp->driver_shader) {
+ pipe->delete_fs_state(pipe, stfp->driver_shader);
+ stfp->driver_shader = NULL;
+ }
+
+ if (stfp->state.tokens) {
+ FREE((void *) stfp->state.tokens);
+ stfp->state.tokens = NULL;
+ }
+
+ st_free_translated_vertex_programs(st, stfp->vertex_programs);
}
break;
default:
@@ -162,27 +182,25 @@ static void st_program_string_notify( GLcontext *ctx,
struct gl_program *prog )
{
struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
if (target == GL_FRAGMENT_PROGRAM_ARB) {
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
stfp->serialNo++;
-#if 0
- if (stfp->cso) {
- /* free the TGSI code */
- // cso_delete(stfp->vs);
- stfp->cso = NULL;
+ if (stfp->driver_shader) {
+ pipe->delete_fs_state(pipe, stfp->driver_shader);
+ stfp->driver_shader = NULL;
}
-#endif
-
- stfp->param_state = stfp->Base.Base.Parameters->StateFlags;
if (stfp->state.tokens) {
FREE((void *) stfp->state.tokens);
stfp->state.tokens = NULL;
}
+ stfp->param_state = stfp->Base.Base.Parameters->StateFlags;
+
if (st->fp == stfp)
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
}
@@ -191,26 +209,23 @@ static void st_program_string_notify( GLcontext *ctx,
stvp->serialNo++;
-#if 0
- if (stvp->cso) {
- /* free the CSO data */
- st->pipe->delete_vs_state(st->pipe, stvp->cso->data);
- FREE((void *) stvp->cso);
- stvp->cso = NULL;
+ if (stvp->driver_shader) {
+ pipe->delete_vs_state(pipe, stvp->driver_shader);
+ stvp->driver_shader = NULL;
}
-#endif
+
if (stvp->draw_shader) {
draw_delete_vertex_shader(st->draw, stvp->draw_shader);
stvp->draw_shader = NULL;
}
- stvp->param_state = stvp->Base.Base.Parameters->StateFlags;
-
if (stvp->state.tokens) {
FREE((void *) stvp->state.tokens);
stvp->state.tokens = NULL;
}
+ stvp->param_state = stvp->Base.Base.Parameters->StateFlags;
+
if (st->vp == stvp)
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
}
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index c89c74229e..4cf9adcd28 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -34,6 +34,7 @@
#include "main/imports.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/image.h"
@@ -126,7 +127,6 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
}
-
/**
* Do glReadPixels by getting rows from the framebuffer surface with
* get_tile(). Convert to requested format/type with Mesa image routines.
@@ -155,18 +155,13 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
return;
}
+ dest = _mesa_map_readpix_pbo(ctx, &clippedPacking, dest);
+ if (!dest)
+ return;
+
/* make sure rendering has completed */
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE);
- if (pack->BufferObj && pack->BufferObj->Name) {
- /* reading into a PBO */
-
- }
- else {
- /* reading into user memory/buffer */
-
- }
-
if (format == GL_STENCIL_INDEX) {
st_read_stencil_pixels(ctx, x, y, width, height, type, pack, dest);
return;
@@ -285,6 +280,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
}
}
+
+ _mesa_unmap_readpix_pbo(ctx, &clippedPacking);
}
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 0962b5f74c..7fab4d041d 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -155,7 +155,6 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
- ctx->Extensions.EXT_texture_sRGB = GL_TRUE; /* XXX temp */
ctx->Extensions.NV_blend_square = GL_TRUE;
ctx->Extensions.NV_texgen_reflection = GL_TRUE;
@@ -190,10 +189,6 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.ATI_separate_stencil = GL_TRUE;
}
- if (screen->get_param(screen, PIPE_CAP_S3TC)) {
- ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
- }
-
if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) {
ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
}
@@ -214,4 +209,14 @@ void st_init_extensions(struct st_context *st)
/*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/
}
+ if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB,
+ PIPE_TEXTURE)) {
+ ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
+ }
+
+ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
+ PIPE_TEXTURE)) {
+ ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
+ }
+
}
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index d9d11ee0e8..101a6a48af 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -260,6 +260,16 @@ st_translate_vertex_program(struct st_context *st,
outputMapping = defaultOutputMapping;
}
+ /* free old shader state, if any */
+ if (stvp->state.tokens) {
+ FREE((void *) stvp->state.tokens);
+ stvp->state.tokens = NULL;
+ }
+ if (stvp->driver_shader) {
+ pipe->delete_vs_state(pipe, stvp->driver_shader);
+ stvp->driver_shader = NULL;
+ }
+
/* XXX: fix static allocation of tokens:
*/
num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX,
diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c
index 1e7f6c18e6..f3dda12e25 100644
--- a/src/mesa/swrast/s_bitmap.c
+++ b/src/mesa/swrast/s_bitmap.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.2
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul 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"),
@@ -57,25 +57,9 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
ASSERT(ctx->RenderMode == GL_RENDER);
- if (unpack->BufferObj->Name) {
- /* unpack from PBO */
- GLubyte *buf;
- if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
- GL_COLOR_INDEX, GL_BITMAP,
- (GLvoid *) bitmap)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)");
- return;
- }
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- GL_READ_ONLY_ARB,
- unpack->BufferObj);
- if (!buf) {
- /* buffer is already mapped - that's an error */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
- return;
- }
- bitmap = ADD_POINTERS(buf, bitmap);
- }
+ bitmap = _mesa_map_bitmap_pbo(ctx, unpack, bitmap);
+ if (!bitmap)
+ return;
RENDER_START(swrast,ctx);
@@ -150,11 +134,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
RENDER_FINISH(swrast,ctx);
- if (unpack->BufferObj->Name) {
- /* done with PBO so unmap it now */
- ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- unpack->BufferObj);
- }
+ _mesa_unmap_bitmap_pbo(ctx, unpack);
}
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 0cf425e1c6..fb04d9f746 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -812,7 +812,6 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
}
-
/**
* Execute software-based glDrawPixels.
* By time we get here, all error checking will have been done.
@@ -835,25 +834,9 @@ _swrast_DrawPixels( GLcontext *ctx,
if (swrast->NewState)
_swrast_validate_derived( ctx );
- if (unpack->BufferObj->Name) {
- /* unpack from PBO */
- GLubyte *buf;
- if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
- format, type, pixels)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawPixels(invalid PBO access)");
- goto end;
- }
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- GL_READ_ONLY_ARB,
- unpack->BufferObj);
- if (!buf) {
- /* buffer is already mapped - that's an error */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(PBO is mapped)");
- goto end;
- }
- pixels = ADD_POINTERS(buf, pixels);
- }
+ pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels);
+ if (!pixels)
+ return;
switch (format) {
case GL_STENCIL_INDEX:
@@ -894,11 +877,7 @@ end:
RENDER_FINISH(swrast,ctx);
- if (unpack->BufferObj->Name) {
- /* done with PBO so unmap it now */
- ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- unpack->BufferObj);
- }
+ _mesa_unmap_drapix_pbo(ctx, unpack);
}
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index fe9a70f4ea..2f155d0b70 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -572,25 +572,9 @@ _swrast_ReadPixels( GLcontext *ctx,
goto end;
}
- if (clippedPacking.BufferObj->Name) {
- /* pack into PBO */
- GLubyte *buf;
- if (!_mesa_validate_pbo_access(2, &clippedPacking, width, height, 1,
- format, type, pixels)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glReadPixels(invalid PBO access)");
- goto end;
- }
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
- GL_WRITE_ONLY_ARB,
- clippedPacking.BufferObj);
- if (!buf) {
- /* buffer is already mapped - that's an error */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)");
- goto end;
- }
- pixels = ADD_POINTERS(buf, pixels);
- }
+ pixels = _mesa_map_readpix_pbo(ctx, &clippedPacking, pixels);
+ if (!pixels)
+ return;
switch (format) {
case GL_COLOR_INDEX:
@@ -632,9 +616,5 @@ _swrast_ReadPixels( GLcontext *ctx,
end:
RENDER_FINISH(swrast, ctx);
- if (clippedPacking.BufferObj->Name) {
- /* done with PBO so unmap it now */
- ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
- clippedPacking.BufferObj);
- }
+ _mesa_unmap_readpix_pbo(ctx, &clippedPacking);
}