diff options
Diffstat (limited to 'src/mesa/state_tracker')
37 files changed, 682 insertions, 440 deletions
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index a8f2b879d5..28439103b2 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -44,7 +44,6 @@ #include "st_atom.h" #include "st_atom_constbuf.h" #include "st_program.h" -#include "st_inlines.h" /** @@ -84,7 +83,7 @@ void st_upload_constants( struct st_context *st, } /* load Mesa constants into the constant buffer */ - st_no_flush_pipe_buffer_write(st, *cbuf, + pipe_buffer_write(st->pipe, *cbuf, 0, paramBytes, params->ParameterValues); diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 323de8a8bd..b8644faaf8 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -44,10 +44,10 @@ #include "st_context.h" #include "st_format.h" #include "st_texture.h" -#include "st_inlines.h" #include "pipe/p_screen.h" #include "pipe/p_context.h" +#include "util/u_inlines.h" #include "util/u_pack_color.h" @@ -149,7 +149,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt) uint *dest; uint i, j; - transfer = st_cond_flush_get_tex_transfer(st_context(ctx), + transfer = pipe_get_transfer(st_context(ctx)->pipe, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, texSize, texSize); dest = (uint *) pipe_transfer_map(pipe, transfer); diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 5669b1f82a..2599bd5ca0 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -53,21 +53,6 @@ static GLuint translate_fill( GLenum mode ) } } -static GLboolean get_offset_flag( GLuint fill_mode, - const struct gl_polygon_attrib *p ) -{ - switch (fill_mode) { - case PIPE_POLYGON_MODE_POINT: - return p->OffsetPoint; - case PIPE_POLYGON_MODE_LINE: - return p->OffsetLine; - case PIPE_POLYGON_MODE_FILL: - return p->OffsetFill; - default: - assert(0); - return 0; - } -} static void update_raster_state( struct st_context *st ) @@ -82,10 +67,7 @@ static void update_raster_state( struct st_context *st ) /* _NEW_POLYGON, _NEW_BUFFERS */ { - if (ctx->Polygon.FrontFace == GL_CCW) - raster->front_winding = PIPE_WINDING_CCW; - else - raster->front_winding = PIPE_WINDING_CW; + raster->front_ccw = (ctx->Polygon.FrontFace == GL_CCW); /* XXX * I think the intention here is that user-created framebuffer objects @@ -94,7 +76,7 @@ static void update_raster_state( struct st_context *st ) * But this is an implementation/driver-specific artifact - remove... */ if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) - raster->front_winding ^= PIPE_WINDING_BOTH; + raster->front_ccw ^= 1; } /* _NEW_LIGHT @@ -131,40 +113,36 @@ static void update_raster_state( struct st_context *st ) /* _NEW_POLYGON */ if (ctx->Polygon.CullFlag) { - if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - raster->cull_mode = PIPE_WINDING_BOTH; - } - else if (ctx->Polygon.CullFaceMode == GL_FRONT) { - raster->cull_mode = raster->front_winding; - } - else { - raster->cull_mode = raster->front_winding ^ PIPE_WINDING_BOTH; + switch (ctx->Polygon.CullFaceMode) { + case GL_FRONT: + raster->cull_face = PIPE_FACE_FRONT; + break; + case GL_BACK: + raster->cull_face = PIPE_FACE_BACK; + break; + case GL_FRONT_AND_BACK: + raster->cull_face = PIPE_FACE_FRONT_AND_BACK; + break; } } + else { + raster->cull_face = PIPE_FACE_NONE; + } /* _NEW_POLYGON */ { - GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); - GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); - - if (raster->front_winding == PIPE_WINDING_CW) { - raster->fill_cw = fill_front; - raster->fill_ccw = fill_back; - } - else { - raster->fill_cw = fill_back; - raster->fill_ccw = fill_front; - } + raster->fill_front = translate_fill( ctx->Polygon.FrontMode ); + raster->fill_back = translate_fill( ctx->Polygon.BackMode ); /* Simplify when culling is active: */ - if (raster->cull_mode & PIPE_WINDING_CW) { - raster->fill_cw = raster->fill_ccw; + if (raster->cull_face & PIPE_FACE_FRONT) { + raster->fill_front = raster->fill_back; } - if (raster->cull_mode & PIPE_WINDING_CCW) { - raster->fill_ccw = raster->fill_cw; + if (raster->cull_face & PIPE_FACE_BACK) { + raster->fill_back = raster->fill_front; } } @@ -172,8 +150,14 @@ static void update_raster_state( struct st_context *st ) */ if (ctx->Polygon.OffsetUnits != 0.0 || ctx->Polygon.OffsetFactor != 0.0) { - raster->offset_cw = get_offset_flag( raster->fill_cw, &ctx->Polygon ); - raster->offset_ccw = get_offset_flag( raster->fill_ccw, &ctx->Polygon ); + raster->offset_point = ctx->Polygon.OffsetPoint; + raster->offset_line = ctx->Polygon.OffsetLine; + raster->offset_tri = ctx->Polygon.OffsetFill; + } + + if (ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill) { raster->offset_units = ctx->Polygon.OffsetUnits; raster->offset_scale = ctx->Polygon.OffsetFactor; } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 0101837f99..425e7987d3 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -39,13 +39,14 @@ #include "st_cb_accum.h" #include "st_cb_fbo.h" #include "st_texture.h" -#include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "util/u_tile.h" +#if FEATURE_accum + /** * For hardware that supports deep color buffers, we could accelerate * most/all the accum operations with blending/texturing. @@ -136,7 +137,7 @@ accum_accum(struct st_context *st, GLfloat value, if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); - color_trans = st_cond_flush_get_tex_transfer(st, + color_trans = pipe_get_transfer(st->pipe, color_strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, xpos, ypos, @@ -185,7 +186,7 @@ accum_load(struct st_context *st, GLfloat value, if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); - color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture, + color_trans = pipe_get_transfer(st->pipe, color_strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, xpos, ypos, width, height); @@ -241,7 +242,7 @@ accum_return(GLcontext *ctx, GLfloat value, else usage = PIPE_TRANSFER_WRITE; - color_trans = st_cond_flush_get_tex_transfer(st_context(ctx), + color_trans = pipe_get_transfer(st_context(ctx)->pipe, color_strb->texture, 0, 0, 0, usage, xpos, ypos, @@ -301,9 +302,6 @@ st_Accum(GLcontext *ctx, GLenum op, GLfloat value) if(!acc_strb->data) return; - /* make sure color bufs aren't cached */ - st_flush( st, PIPE_FLUSH_RENDER_CACHE, NULL ); - switch (op) { case GL_ADD: if (value != 0.0F) { @@ -337,3 +335,5 @@ void st_init_accum_functions(struct dd_function_table *functions) { functions->Accum = st_Accum; } + +#endif /* FEATURE_accum */ diff --git a/src/mesa/state_tracker/st_cb_accum.h b/src/mesa/state_tracker/st_cb_accum.h index ed9b7dab94..7d52481c82 100644 --- a/src/mesa/state_tracker/st_cb_accum.h +++ b/src/mesa/state_tracker/st_cb_accum.h @@ -30,10 +30,28 @@ #define ST_CB_ACCUM_H +#include "main/mtypes.h" + +#if FEATURE_accum + extern void st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb); extern void st_init_accum_functions(struct dd_function_table *functions); +#else + +static INLINE void +st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +{ + ASSERT_NO_FEATURE(); +} + +static INLINE void +st_init_accum_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_accum */ #endif /* ST_CB_ACCUM_H */ diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 1b3787828e..5aca1105ee 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -43,7 +43,6 @@ #include "st_program.h" #include "st_cb_bitmap.h" #include "st_texture.h" -#include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -54,6 +53,7 @@ #include "cso_cache/cso_context.h" +#if FEATURE_drawpix /** * glBitmaps are drawn as textured quads. The user's bitmap pattern @@ -282,7 +282,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, return NULL; } - transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0, + transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, width, height); @@ -382,7 +382,7 @@ setup_bitmap_vertex_data(struct st_context *st, } /* put vertex data into vbuf */ - st_no_flush_pipe_buffer_write_nooverlap(st, + pipe_buffer_write_nooverlap(st->pipe, st->bitmap.vbuf, st->bitmap.vbuf_slot * sizeof st->bitmap.vertices, sizeof st->bitmap.vertices, @@ -579,7 +579,7 @@ create_cache_trans(struct st_context *st) /* Map the texture transfer. * Subsequent glBitmap calls will write into the texture image. */ - cache->trans = st_no_flush_get_tex_transfer(st, cache->texture, 0, 0, 0, + cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT); @@ -860,3 +860,5 @@ st_destroy_bitmap(struct st_context *st) st->bitmap.cache = NULL; } } + +#endif /* FEATURE_drawpix */ diff --git a/src/mesa/state_tracker/st_cb_bitmap.h b/src/mesa/state_tracker/st_cb_bitmap.h index 81cf61981d..8af975b74f 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.h +++ b/src/mesa/state_tracker/st_cb_bitmap.h @@ -30,6 +30,10 @@ #define ST_CB_BITMAP_H +#include "main/mtypes.h" + +#if FEATURE_drawpix + extern void st_init_bitmap_functions(struct dd_function_table *functions); @@ -48,5 +52,33 @@ st_flush_bitmap_cache(struct st_context *st); extern void st_flush_bitmap(struct st_context *st); +#else + +static INLINE void +st_init_bitmap_functions(struct dd_function_table *functions) +{ +} + +static INLINE void +st_init_bitmap(struct st_context *st) +{ +} + +static INLINE void +st_destroy_bitmap(struct st_context *st) +{ +} + +static INLINE void +st_flush_bitmap_cache(struct st_context *st) +{ +} + +static INLINE void +st_flush_bitmap(struct st_context *st) +{ +} + +#endif /* FEATURE_drawpix */ #endif /* ST_CB_BITMAP_H */ diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index 3a34bdfe9a..fb7b48a7bf 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -60,6 +60,7 @@ st_destroy_blit(struct st_context *st) #if FEATURE_EXT_framebuffer_blit + static void st_BlitFramebuffer(GLcontext *ctx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, @@ -205,14 +206,12 @@ st_BlitFramebuffer(GLcontext *ctx, } } } -#endif /* FEATURE_EXT_framebuffer_blit */ - void st_init_blit_functions(struct dd_function_table *functions) { -#if FEATURE_EXT_framebuffer_blit functions->BlitFramebuffer = st_BlitFramebuffer; -#endif } + +#endif /* FEATURE_EXT_framebuffer_blit */ diff --git a/src/mesa/state_tracker/st_cb_blit.h b/src/mesa/state_tracker/st_cb_blit.h index ed22986b53..7ab9a54df9 100644 --- a/src/mesa/state_tracker/st_cb_blit.h +++ b/src/mesa/state_tracker/st_cb_blit.h @@ -29,18 +29,28 @@ #define ST_CB_BLIT_H +#include "main/mtypes.h" #include "st_context.h" - extern void st_init_blit(struct st_context *st); extern void st_destroy_blit(struct st_context *st); +#if FEATURE_EXT_framebuffer_blit + extern void st_init_blit_functions(struct dd_function_table *functions); +#else + +static INLINE void +st_init_blit_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_EXT_framebuffer_blit */ #endif /* ST_CB_BLIT_H */ diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index b883c071f7..7991a93a1e 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -36,7 +36,6 @@ #include "main/arrayobj.h" #include "main/bufferobj.h" -#include "st_inlines.h" #include "st_context.h" #include "st_cb_bufferobjects.h" @@ -202,7 +201,7 @@ st_bufferobj_data(GLcontext *ctx, } if (data) - st_no_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer, 0, + pipe_buffer_write(st_context(ctx)->pipe, st_obj->buffer, 0, size, data); return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 736180ddc6..7e3b87351f 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -43,7 +43,6 @@ #include "st_cb_clear.h" #include "st_cb_fbo.h" #include "st_program.h" -#include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_state.h" @@ -163,7 +162,7 @@ draw_quad(struct st_context *st, } /* put vertex data into vbuf */ - st_no_flush_pipe_buffer_write_nooverlap(st, st->clear.vbuf, + pipe_buffer_write_nooverlap(st->pipe, st->clear.vbuf, st->clear.vbuf_slot * sizeof(st->clear.vertices), sizeof(st->clear.vertices), diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index ad20004d36..f74d8cd42d 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -49,7 +49,6 @@ #include "st_cb_fbo.h" #include "st_format.h" #include "st_texture.h" -#include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -63,6 +62,8 @@ #include "cso_cache/cso_context.h" +#if FEATURE_drawpix + /** * Check if the given program is: * 0: MOVE result.color, fragment.color; @@ -384,7 +385,7 @@ make_texture(struct st_context *st, /* we'll do pixel transfer in a fragment shader */ ctx->_ImageTransferState = 0x0; - transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0, + transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, width, height); @@ -508,7 +509,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, buf = pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER, sizeof(verts)); - st_no_flush_pipe_buffer_write(st, buf, 0, sizeof(verts), verts); + pipe_buffer_write(st->pipe, buf, 0, sizeof(verts), verts); util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_QUADS, @@ -685,7 +686,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, else usage = PIPE_TRANSFER_WRITE; - pt = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, 0, 0, 0, + pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, usage, x, y, width, height); @@ -885,7 +886,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, dsty = rbDraw->Base.Height - dsty - height; } - ptDraw = st_cond_flush_get_tex_transfer(st_context(ctx), + ptDraw = pipe_get_transfer(st_context(ctx)->pipe, rbDraw->texture, 0, 0, 0, usage, dstx, dsty, width, height); @@ -971,8 +972,6 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, GLuint sample_count; struct gl_pixelstore_attrib pack = ctx->DefaultPacking; - pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - st_validate_state(st); if (type == GL_STENCIL) { @@ -1075,7 +1074,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, else { /* CPU-based fallback/conversion */ struct pipe_transfer *ptRead = - st_cond_flush_get_tex_transfer(st, rbRead->texture, 0, 0, 0, + pipe_get_transfer(st->pipe, rbRead->texture, 0, 0, 0, PIPE_TRANSFER_READ, readX, readY, readW, readH); struct pipe_transfer *ptTex; @@ -1089,7 +1088,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, else transfer_usage = PIPE_TRANSFER_WRITE; - ptTex = st_cond_flush_get_tex_transfer(st, pt, 0, 0, 0, transfer_usage, + ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, 0, transfer_usage, 0, 0, width, height); /* copy image from ptRead surface to ptTex surface */ @@ -1143,7 +1142,9 @@ st_destroy_drawpix(struct st_context *st) st_reference_fragprog(st, &st->drawpix.z_shader, NULL); st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL); if (st->drawpix.vert_shaders[0]) - free(st->drawpix.vert_shaders[0]); + ureg_free_tokens(st->drawpix.vert_shaders[0]); if (st->drawpix.vert_shaders[1]) - free(st->drawpix.vert_shaders[1]); + ureg_free_tokens(st->drawpix.vert_shaders[1]); } + +#endif /* FEATURE_drawpix */ diff --git a/src/mesa/state_tracker/st_cb_drawpixels.h b/src/mesa/state_tracker/st_cb_drawpixels.h index 26fe864d18..7d5e901ccc 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.h +++ b/src/mesa/state_tracker/st_cb_drawpixels.h @@ -30,10 +30,27 @@ #define ST_CB_DRAWPIXELS_H +#include "main/mtypes.h" + +#if FEATURE_drawpix + extern void st_init_drawpixels_functions(struct dd_function_table *functions); extern void st_destroy_drawpix(struct st_context *st); +#else + +static INLINE void +st_init_drawpixels_functions(struct dd_function_table *functions) +{ +} + +static INLINE void +st_destroy_drawpix(struct st_context *st) +{ +} + +#endif /* FEATURE_drawpix */ #endif /* ST_CB_DRAWPIXELS_H */ diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c index 6d387d5ccf..3d99d6c8a1 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.c +++ b/src/mesa/state_tracker/st_cb_drawtex.c @@ -15,34 +15,29 @@ #include "main/imports.h" #include "main/image.h" #include "main/bufferobj.h" -#include "main/drawtex.h" #include "main/macros.h" -#include "main/state.h" -#include "main/texformat.h" #include "shader/program.h" -#include "shader/prog_parameter.h" #include "shader/prog_print.h" #include "st_context.h" #include "st_atom.h" -#include "st_atom_constbuf.h" -#include "st_draw.h" #include "st_cb_drawtex.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "pipe/p_shader_tokens.h" -#include "util/u_tile.h" #include "util/u_draw_quad.h" #include "util/u_simple_shaders.h" #include "cso_cache/cso_context.h" +#if FEATURE_OES_draw_texture + + struct cached_shader { - //struct pipe_shader_state shader; void *handle; uint num_attribs; @@ -60,9 +55,6 @@ static struct cached_shader CachedShaders[MAX_SHADERS]; static GLuint NumCachedShaders = 0; -#if FEATURE_OES_draw_texture - - static void * lookup_shader(struct pipe_context *pipe, uint num_attribs, @@ -288,13 +280,10 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, } -#endif /* FEATURE_OES_draw_texture */ - - void st_init_drawtex_functions(struct dd_function_table *functions) { - _MESA_INIT_DRAWTEX_FUNCTIONS(functions, st_); + functions->DrawTex = st_DrawTex; } @@ -310,3 +299,6 @@ st_destroy_drawtex(struct st_context *st) } NumCachedShaders = 0; } + + +#endif /* FEATURE_OES_draw_texture */ diff --git a/src/mesa/state_tracker/st_cb_drawtex.h b/src/mesa/state_tracker/st_cb_drawtex.h index 7b0da70279..a3f54a349c 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.h +++ b/src/mesa/state_tracker/st_cb_drawtex.h @@ -9,10 +9,29 @@ #ifndef ST_CB_DRAWTEX_H #define ST_CB_DRAWTEX_H + +#include "main/mtypes.h" + +#if FEATURE_OES_draw_texture + extern void st_init_drawtex_functions(struct dd_function_table *functions); extern void st_destroy_drawtex(struct st_context *st); +#else + +static INLINE void +st_init_drawtex_functions(struct dd_function_table *functions) +{ +} + +static INLINE void +st_destroy_drawtex(struct st_context *st) +{ +} + +#endif /* FEATURE_OES_draw_texture */ + #endif /* ST_CB_DRAWTEX_H */ diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index 91a42fafd1..4aaf91d5a1 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -129,6 +129,10 @@ st_bind_surface(GLcontext *ctx, GLenum target, /* FIXME create a non-default sampler view from the pipe_surface? */ pipe_resource_reference(&stImage->pt, ps->texture); + stObj->width0 = ps->width; + stObj->height0 = ps->height; + stObj->depth0 = 1; + _mesa_dirty_texobj(ctx, texObj, GL_TRUE); } diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index c85d3da84a..e57730b5ec 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -54,6 +54,8 @@ #include "draw/draw_pipe.h" +#if FEATURE_feedback + /** * This is actually used for both feedback and selection. */ @@ -302,3 +304,5 @@ void st_init_feedback_functions(struct dd_function_table *functions) { functions->RenderMode = st_RenderMode; } + +#endif /* FEATURE_feedback */ diff --git a/src/mesa/state_tracker/st_cb_feedback.h b/src/mesa/state_tracker/st_cb_feedback.h index 2559ba3817..706d84960f 100644 --- a/src/mesa/state_tracker/st_cb_feedback.h +++ b/src/mesa/state_tracker/st_cb_feedback.h @@ -30,8 +30,20 @@ #define ST_CB_FEEDBACK_H +#include "main/mtypes.h" + +#if FEATURE_feedback + extern void st_init_feedback_functions(struct dd_function_table *functions); +#else + +static INLINE void +st_init_feedback_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_feedback */ #endif /* ST_CB_FEEDBACK_H */ diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index 1896663932..e423d9d8a5 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -43,6 +43,8 @@ #include "st_cb_queryobj.h" +#if FEATURE_queryobj + static struct gl_query_object * st_NewQueryObject(GLcontext *ctx, GLuint id) { @@ -51,6 +53,7 @@ st_NewQueryObject(GLcontext *ctx, GLuint id) stq->base.Id = id; stq->base.Ready = GL_TRUE; stq->pq = NULL; + stq->type = PIPE_QUERY_TYPES; /* an invalid value */ return &stq->base; } return NULL; @@ -78,17 +81,41 @@ st_BeginQuery(GLcontext *ctx, struct gl_query_object *q) { struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); + unsigned type; + /* convert GL query type to Gallium query type */ switch (q->Target) { case GL_SAMPLES_PASSED_ARB: - if (!stq->pq) - stq->pq = pipe->create_query( pipe, PIPE_QUERY_OCCLUSION_COUNTER ); + type = PIPE_QUERY_OCCLUSION_COUNTER; + break; + case GL_PRIMITIVES_GENERATED: + type = PIPE_QUERY_PRIMITIVES_GENERATED; + break; + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + type = PIPE_QUERY_PRIMITIVES_EMITTED; + break; + case GL_TIME_ELAPSED_EXT: + type = PIPE_QUERY_TIME_ELAPSED; break; default: - assert(0); + assert(0 && "unexpected query target in st_BeginQuery()"); return; } + if (stq->pq && stq->type != type) { + /* free old query of different type */ + pipe->destroy_query(pipe, stq->pq); + stq->pq = NULL; + stq->type = PIPE_QUERY_TYPES; /* an invalid value */ + } + + if (!stq->pq) { + stq->pq = pipe->create_query(pipe, type); + stq->type = type; + } + + assert(stq->type == type); + pipe->begin_query(pipe, stq->pq); } @@ -146,3 +173,5 @@ void st_init_query_functions(struct dd_function_table *functions) functions->WaitQuery = st_WaitQuery; functions->CheckQuery = st_CheckQuery; } + +#endif /* FEATURE_queryobj */ diff --git a/src/mesa/state_tracker/st_cb_queryobj.h b/src/mesa/state_tracker/st_cb_queryobj.h index fa256b7182..017471b0b0 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.h +++ b/src/mesa/state_tracker/st_cb_queryobj.h @@ -29,6 +29,8 @@ #define ST_CB_QUERYOBJ_H +#include "main/mtypes.h" + /** * Subclass of gl_query_object */ @@ -36,6 +38,7 @@ struct st_query_object { struct gl_query_object base; struct pipe_query *pq; + unsigned type; /**< PIPE_QUERY_x */ }; @@ -49,9 +52,18 @@ st_query_object(struct gl_query_object *q) } +#if FEATURE_queryobj extern void st_init_query_functions(struct dd_function_table *functions); +#else + +static INLINE void +st_init_query_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_queryobj */ #endif diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 843f320027..7b2eb8012d 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -50,6 +50,7 @@ #include "vbo/vbo.h" +#if FEATURE_rastpos /** * Our special drawing pipeline stage (replaces rasterization). @@ -267,3 +268,5 @@ void st_init_rasterpos_functions(struct dd_function_table *functions) { functions->RasterPos = st_RasterPos; } + +#endif /* FEATURE_rastpos */ diff --git a/src/mesa/state_tracker/st_cb_rasterpos.h b/src/mesa/state_tracker/st_cb_rasterpos.h index 2b992e1405..d2ed7297f1 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.h +++ b/src/mesa/state_tracker/st_cb_rasterpos.h @@ -28,6 +28,20 @@ #ifndef ST_CB_RASTERPOS_H #define ST_CB_RASTERPOS_H + +#include "main/mtypes.h" + +#if FEATURE_rastpos + extern void st_init_rasterpos_functions(struct dd_function_table *functions); -#endif +#else + +static INLINE void +st_init_rasterpos_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_rastpos */ + +#endif /* ST_CB_RASTERPOS_H */ diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 69950ac44b..b8493dab93 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -46,10 +46,9 @@ #include "st_debug.h" #include "st_context.h" #include "st_atom.h" +#include "st_cb_bitmap.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" -#include "st_texture.h" -#include "st_inlines.h" /** * Special case for reading stencil buffer. @@ -75,7 +74,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* Create a read transfer from the renderbuffer's texture */ - pt = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, + pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, x, y, width, height); @@ -231,7 +230,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, y = strb->texture->height0 - y - height; } - trans = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, + trans = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, x, y, width, height); @@ -346,12 +345,12 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, return; } + st_flush_bitmap_cache(st); + dest = _mesa_map_pbo_dest(ctx, &clippedPacking, dest); if (!dest) return; - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - if (format == GL_STENCIL_INDEX || format == GL_DEPTH_STENCIL) { st_read_stencil_pixels(ctx, x, y, width, height, @@ -395,7 +394,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } /* Create a read transfer from the renderbuffer's texture */ - trans = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, + trans = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, x, y, width, height); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 92342167d9..647898ef7c 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -44,11 +44,11 @@ #include "state_tracker/st_debug.h" #include "state_tracker/st_context.h" #include "state_tracker/st_cb_fbo.h" +#include "state_tracker/st_cb_flush.h" #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 "state_tracker/st_inlines.h" #include "state_tracker/st_atom.h" #include "pipe/p_context.h" @@ -255,8 +255,10 @@ get_texture_dims(GLenum target) * * We use the given st_texture_image as a clue to determine the size of the * mipmap image at level=0. + * + * \return GL_TRUE for success, GL_FALSE if out of memory. */ -static void +static GLboolean guess_and_alloc_texture(struct st_context *st, struct st_texture_object *stObj, const struct st_texture_image *stImage) @@ -287,7 +289,8 @@ guess_and_alloc_texture(struct st_context *st, (dims >= 3 && depth == 1) ) { /* we can't determine the image size at level=0 */ stObj->width0 = stObj->height0 = stObj->depth0 = 0; - return; + /* this is not an out of memory error */ + return GL_TRUE; } } @@ -349,7 +352,9 @@ guess_and_alloc_texture(struct st_context *st, depth, bindings); - DBG("%s - success\n", __FUNCTION__); + DBG("%s returning %d\n", __FUNCTION__, (stObj->pt != NULL)); + + return stObj->pt != NULL; } @@ -459,7 +464,7 @@ compress_with_blit(GLcontext * ctx, /* Put user's tex data into the temporary texture */ - tex_xfer = st_cond_flush_get_tex_transfer(st_context(ctx), src_tex, + tex_xfer = pipe_get_transfer(st_context(ctx)->pipe, src_tex, 0, 0, 0, /* face, level are zero */ PIPE_TRANSFER_WRITE, 0, 0, width, height); /* x, y, w, h */ @@ -597,14 +602,12 @@ st_TexImage(GLcontext * ctx, } if (!stObj->pt) { - guess_and_alloc_texture(st, stObj, stImage); - if (!stObj->pt) { + if (!guess_and_alloc_texture(st, stObj, stImage)) { /* Probably out of memory. * Try flushing any pending rendering, then retry. */ st_finish(st); - guess_and_alloc_texture(st, stObj, stImage); - if (!stObj->pt) { + if (!guess_and_alloc_texture(st, stObj, stImage)) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); return; } @@ -871,7 +874,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, PIPE_TEX_MIPFILTER_NEAREST); /* map the dst_surface so we can read from it */ - tex_xfer = st_cond_flush_get_tex_transfer(st_context(ctx), + tex_xfer = pipe_get_transfer(st_context(ctx)->pipe, dst_texture, 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, width, height); @@ -957,11 +960,6 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, /* Image is stored in hardware format in a buffer managed by the * kernel. Need to explicitly map and unmap it. */ - unsigned face = _mesa_tex_target_to_face(target); - - st_teximage_flush_before_map(st, stImage->pt, face, level, - PIPE_TRANSFER_READ); - texImage->Data = st_texture_image_map(st, stImage, 0, PIPE_TRANSFER_READ, 0, 0, stImage->base.Width, @@ -1093,16 +1091,12 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, * from uploading the buffer under us. */ if (stImage->pt) { - unsigned face = _mesa_tex_target_to_face(target); - if (format == GL_DEPTH_COMPONENT && util_format_is_depth_and_stencil(stImage->pt->format)) transfer_usage = PIPE_TRANSFER_READ_WRITE; else transfer_usage = PIPE_TRANSFER_WRITE; - st_teximage_flush_before_map(st, stImage->pt, face, level, - transfer_usage); texImage->Data = st_texture_image_map(st, stImage, zoffset, transfer_usage, xoffset, yoffset, @@ -1225,11 +1219,8 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, enum pipe_format pformat; if (stImage->pt) { - unsigned face = _mesa_tex_target_to_face(target); pformat = stImage->pt->format; - st_teximage_flush_before_map(st, stImage->pt, face, level, - PIPE_TRANSFER_WRITE); texImage->Data = st_texture_image_map(st, stImage, 0, PIPE_TRANSFER_WRITE, xoffset, yoffset, @@ -1313,7 +1304,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, srcY = strb->Base.Height - srcY - height; } - src_trans = st_cond_flush_get_tex_transfer( st_context(ctx), + src_trans = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, @@ -1327,9 +1318,6 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, else transfer_usage = PIPE_TRANSFER_WRITE; - st_teximage_flush_before_map(st, stImage->pt, 0, 0, - transfer_usage); - texDest = st_texture_image_map(st, stImage, 0, transfer_usage, destX, destY, width, height); @@ -1511,9 +1499,6 @@ st_copy_texsubimage(GLcontext *ctx, struct pipe_surface *dest_surface = NULL; GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP); - /* any rendering in progress must flushed before we grab the fb image */ - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - /* make sure finalize_textures has been called? */ if (0) st_validate_state(st); @@ -1787,17 +1772,12 @@ copy_image_data_to_texture(struct st_context *st, */ st_texture_image_copy(st->pipe, stObj->pt, dstLevel, /* dest texture, level */ - stImage->pt, /* src texture */ + stImage->pt, stImage->level, /* src texture, level */ stImage->face); pipe_resource_reference(&stImage->pt, NULL); } else if (stImage->base.Data) { - /* More straightforward upload. - */ - st_teximage_flush_before_map(st, stObj->pt, stImage->face, dstLevel, - PIPE_TRANSFER_WRITE); - st_texture_image_data(st, stObj->pt, stImage->face, @@ -1909,7 +1889,7 @@ st_finalize_texture(GLcontext *ctx, */ for (face = 0; face < nr_faces; face++) { GLuint level; - for (level = 0; level <= stObj->lastLevel; level++) { + for (level = stObj->base.BaseLevel; level <= stObj->lastLevel; level++) { struct st_texture_image *stImage = st_texture_image(stObj->base.Image[face][level]); diff --git a/src/mesa/state_tracker/st_cb_xformfb.c b/src/mesa/state_tracker/st_cb_xformfb.c new file mode 100644 index 0000000000..749e88e8db --- /dev/null +++ b/src/mesa/state_tracker/st_cb_xformfb.c @@ -0,0 +1,133 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 THE AUTHORS 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. + * + **************************************************************************/ + + +/** + * Transform feedback functions. + * + * \author Brian Paul + */ + + +#include "main/imports.h" +#include "main/context.h" +#include "main/transformfeedback.h" + +#include "st_cb_xformfb.h" + + +#if FEATURE_EXT_transform_feedback + +#if 0 +static struct gl_transform_feedback_object * +st_new_transform_feedback(GLcontext *ctx, GLuint name) +{ + struct gl_transform_feedback_object *obj; + obj = CALLOC_STRUCT(gl_transform_feedback_object); + if (obj) { + obj->Name = name; + obj->RefCount = 1; + } + return obj; +} +#endif + +#if 0 +static void +st_delete_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + GLuint i; + + for (i = 0; i < Elements(obj->Buffers); i++) { + _mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL); + } + + free(obj); +} +#endif + + +static void +st_begin_transform_feedback(GLcontext *ctx, GLenum mode, + struct gl_transform_feedback_object *obj) +{ + /* to-do */ +} + + +static void +st_end_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* to-do */ +} + + +static void +st_pause_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* to-do */ +} + + +static void +st_resume_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* to-do */ +} + + +static void +st_draw_transform_feedback(GLcontext *ctx, GLenum mode, + struct gl_transform_feedback_object *obj) +{ + /* XXX to do */ + /* + * Get number of vertices in obj's feedback buffer. + * Call ctx->Exec.DrawArrays(mode, 0, count); + */ +} + + +void +st_init_xformfb_functions(struct dd_function_table *functions) +{ + /* let core Mesa plug in its functions */ + _mesa_init_transform_feedback_functions(functions); + + /* then override a few: */ + functions->BeginTransformFeedback = st_begin_transform_feedback; + functions->EndTransformFeedback = st_end_transform_feedback; + functions->PauseTransformFeedback = st_pause_transform_feedback; + functions->ResumeTransformFeedback = st_resume_transform_feedback; + functions->DrawTransformFeedback = st_draw_transform_feedback; +} + +#endif /* FEATURE_EXT_transform_feedback */ diff --git a/src/mesa/state_tracker/st_cb_xformfb.h b/src/mesa/state_tracker/st_cb_xformfb.h new file mode 100644 index 0000000000..50efcb9293 --- /dev/null +++ b/src/mesa/state_tracker/st_cb_xformfb.h @@ -0,0 +1,46 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 THE AUTHORS 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_CB_XFORMFB_H +#define ST_CB_XFORMFB_H + + +#if FEATURE_EXT_transform_feedback + +extern void +st_init_xformfb_functions(struct dd_function_table *functions); + +#else + +static INLINE void +st_init_xformfb_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_EXT_transform_feedback */ + +#endif /* ST_CB_XFORMFB_H */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index d4ea593e3f..2070f14a5a 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -38,22 +38,17 @@ #include "st_cb_bufferobjects.h" #include "st_cb_clear.h" #include "st_cb_condrender.h" -#if FEATURE_drawpix #include "st_cb_drawpixels.h" #include "st_cb_rasterpos.h" -#endif -#if FEATURE_OES_draw_texture #include "st_cb_drawtex.h" -#endif #include "st_cb_eglimage.h" #include "st_cb_fbo.h" -#if FEATURE_feedback #include "st_cb_feedback.h" -#endif #include "st_cb_program.h" #include "st_cb_queryobj.h" #include "st_cb_readpixels.h" #include "st_cb_texture.h" +#include "st_cb_xformfb.h" #include "st_cb_flush.h" #include "st_cb_strings.h" #include "st_atom.h" @@ -65,7 +60,6 @@ #include "util/u_inlines.h" #include "util/u_rect.h" #include "util/u_surface.h" -#include "draw/draw_context.h" #include "cso_cache/cso_context.h" @@ -116,18 +110,6 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) /* state tracker needs the VBO module */ _vbo_CreateContext(ctx); -#if FEATURE_feedback || FEATURE_drawpix - st->draw = draw_create(pipe); /* for selection/feedback */ - - /* Disable draw options that might convert points/lines to tris, etc. - * as that would foul-up feedback/selection mode. - */ - draw_wide_line_threshold(st->draw, 1000.0f); - draw_wide_point_threshold(st->draw, 1000.0f); - draw_enable_line_stipple(st->draw, FALSE); - draw_enable_point_sprites(st->draw, FALSE); -#endif - st->dirty.mesa = ~0; st->dirty.st = ~0; @@ -208,23 +190,14 @@ static void st_destroy_context_priv( struct st_context *st ) { uint i; -#if FEATURE_feedback || FEATURE_drawpix - draw_destroy(st->draw); -#endif st_destroy_atoms( st ); st_destroy_draw( st ); st_destroy_generate_mipmap(st); -#if FEATURE_EXT_framebuffer_blit st_destroy_blit(st); -#endif st_destroy_clear(st); -#if FEATURE_drawpix st_destroy_bitmap(st); st_destroy_drawpix(st); -#endif -#if FEATURE_OES_draw_texture st_destroy_drawtex(st); -#endif for (i = 0; i < Elements(st->state.sampler_views); i++) { pipe_sampler_view_reference(&st->state.sampler_views[i], NULL); @@ -284,39 +257,29 @@ void st_init_driver_functions(struct dd_function_table *functions) { _mesa_init_glsl_driver_functions(functions); -#if FEATURE_accum st_init_accum_functions(functions); -#endif -#if FEATURE_EXT_framebuffer_blit st_init_blit_functions(functions); -#endif st_init_bufferobject_functions(functions); st_init_clear_functions(functions); -#if FEATURE_drawpix st_init_bitmap_functions(functions); st_init_drawpixels_functions(functions); st_init_rasterpos_functions(functions); -#endif -#if FEATURE_OES_draw_texture st_init_drawtex_functions(functions); -#endif st_init_eglimage_functions(functions); st_init_fbo_functions(functions); -#if FEATURE_feedback st_init_feedback_functions(functions); -#endif st_init_program_functions(functions); -#if FEATURE_queryobj st_init_query_functions(functions); -#endif st_init_cond_render_functions(functions); st_init_readpixels_functions(functions); st_init_texture_functions(functions); st_init_flush_functions(functions); st_init_string_functions(functions); + st_init_xformfb_functions(functions); + functions->UpdateState = st_invalidate_state; } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4137596bd4..eb2e5b2bbf 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -57,6 +57,7 @@ #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "util/u_format.h" +#include "draw/draw_context.h" #include "cso_cache/cso_context.h" @@ -741,11 +742,26 @@ void st_init_draw( struct st_context *st ) GLcontext *ctx = st->ctx; vbo_set_draw_func(ctx, st_draw_vbo); + +#if FEATURE_feedback || FEATURE_rastpos + st->draw = draw_create(st->pipe); /* for selection/feedback */ + + /* Disable draw options that might convert points/lines to tris, etc. + * as that would foul-up feedback/selection mode. + */ + draw_wide_line_threshold(st->draw, 1000.0f); + draw_wide_point_threshold(st->draw, 1000.0f); + draw_enable_line_stipple(st->draw, FALSE); + draw_enable_point_sprites(st->draw, FALSE); +#endif } void st_destroy_draw( struct st_context *st ) { +#if FEATURE_feedback || FEATURE_rastpos + draw_destroy(st->draw); +#endif } diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index a1f70e8693..5cf2666334 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -45,7 +45,7 @@ #include "draw/draw_context.h" -#if FEATURE_feedback || FEATURE_drawpix +#if FEATURE_feedback || FEATURE_rastpos /** * Set the (private) draw module's post-transformed vertex format when in @@ -279,5 +279,5 @@ st_feedback_draw_vbo(GLcontext *ctx, } } -#endif /* FEATURE_feedback || FEATURE_drawpix */ +#endif /* FEATURE_feedback || FEATURE_rastpos */ diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 9ada38aa48..810a0635b5 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -67,6 +67,7 @@ void st_init_limits(struct st_context *st) { struct pipe_screen *screen = st->pipe->screen; struct gl_constants *c = &st->ctx->Const; + struct gl_program_constants *pc; c->MaxTextureLevels = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), @@ -140,6 +141,26 @@ void st_init_limits(struct st_context *st) /* Quads always follow GL provoking rules. */ c->QuadsFollowProvokingVertexConvention = GL_FALSE; + + pc = &c->FragmentProgram; + pc->MaxNativeInstructions = screen->get_param(screen, PIPE_CAP_MAX_FS_INSTRUCTIONS); + pc->MaxNativeAluInstructions = screen->get_param(screen, PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS); + pc->MaxNativeTexInstructions = screen->get_param(screen, PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS); + pc->MaxNativeTexIndirections = screen->get_param(screen, PIPE_CAP_MAX_FS_TEX_INDIRECTIONS); + pc->MaxNativeAttribs = screen->get_param(screen, PIPE_CAP_MAX_FS_INPUTS); + pc->MaxNativeTemps = screen->get_param(screen, PIPE_CAP_MAX_FS_TEMPS); + pc->MaxNativeAddressRegs = screen->get_param(screen, PIPE_CAP_MAX_FS_ADDRS); + pc->MaxNativeParameters = screen->get_param(screen, PIPE_CAP_MAX_FS_CONSTS); + + pc = &c->VertexProgram; + pc->MaxNativeInstructions = screen->get_param(screen, PIPE_CAP_MAX_VS_INSTRUCTIONS); + pc->MaxNativeAluInstructions = screen->get_param(screen, PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS); + pc->MaxNativeTexInstructions = screen->get_param(screen, PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS); + pc->MaxNativeTexIndirections = screen->get_param(screen, PIPE_CAP_MAX_VS_TEX_INDIRECTIONS); + pc->MaxNativeAttribs = screen->get_param(screen, PIPE_CAP_MAX_VS_INPUTS); + pc->MaxNativeTemps = screen->get_param(screen, PIPE_CAP_MAX_VS_TEMPS); + pc->MaxNativeAddressRegs = screen->get_param(screen, PIPE_CAP_MAX_VS_ADDRS); + pc->MaxNativeParameters = screen->get_param(screen, PIPE_CAP_MAX_VS_CONSTS); } @@ -275,6 +296,9 @@ void st_init_extensions(struct st_context *st) if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) { ctx->Extensions.ARB_occlusion_query = GL_TRUE; } + if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) { + ctx->Extensions.EXT_timer_query = GL_TRUE; + } if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) { ctx->Extensions.ARB_depth_texture = GL_TRUE; diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 5cf8b4a881..2d587df605 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -39,9 +39,9 @@ #include "st_debug.h" #include "st_context.h" +#include "st_texture.h" #include "st_gen_mipmap.h" #include "st_cb_texture.h" -#include "st_inlines.h" /** @@ -79,6 +79,7 @@ st_render_mipmap(struct st_context *st, struct pipe_sampler_view *psv = st_get_texture_sampler_view(stObj, pipe); const uint face = _mesa_tex_target_to_face(target); + assert(psv->texture == stObj->pt); assert(target != GL_TEXTURE_3D); /* not done yet */ /* check if we can render in the texture's format */ @@ -104,10 +105,32 @@ decompress_image(enum pipe_format format, unsigned width, unsigned height) { const struct util_format_description *desc = util_format_description(format); - const uint dst_stride = 4 * width; + const uint bw = util_format_get_blockwidth(format); + const uint bh = util_format_get_blockheight(format); + const uint dst_stride = 4 * MAX2(width, bw); const uint src_stride = util_format_get_stride(format, width); desc->unpack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height); + + if (width < bw || height < bh) { + /* We're decompressing an image smaller than the compression + * block size. We don't want garbage pixel values in the region + * outside (width x height) so replicate pixels from the (width + * x height) region to fill out the (bw x bh) block size. + */ + uint x, y; + for (y = 0; y < bh; y++) { + for (x = 0; x < bw; x++) { + if (x >= width || y >= height) { + uint p = (y * bw + x) * 4; + dst[p + 0] = dst[0]; + dst[p + 1] = dst[1]; + dst[p + 2] = dst[2]; + dst[p + 3] = dst[3]; + } + } + } + } } @@ -176,13 +199,13 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, ubyte *dstData; int srcStride, dstStride; - srcTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face, + srcTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face, srcLevel, zslice, PIPE_TRANSFER_READ, 0, 0, srcWidth, srcHeight); - dstTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face, + dstTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face, dstLevel, zslice, PIPE_TRANSFER_WRITE, 0, 0, dstWidth, dstHeight); @@ -221,7 +244,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, dstWidth2); /* stride in texels */ /* compress the new image: dstTemp -> dstData */ - compress_image(format, dstTemp, dstData, dstWidth2, dstHeight2); + compress_image(format, dstTemp, dstData, dstWidth, dstHeight); free(srcTemp); free(dstTemp); @@ -261,7 +284,6 @@ compute_num_levels(GLcontext *ctx, 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; @@ -269,14 +291,16 @@ compute_num_levels(GLcontext *ctx, size = MAX2(baseImage->Width2, baseImage->Height2); size = MAX2(size, baseImage->Depth2); - numLevels = 0; + numLevels = texObj->BaseLevel; while (size > 0) { numLevels++; size >>= 1; } - numLevels = MIN2(numLevels, maxLevels); + numLevels = MIN2(numLevels, texObj->MaxLevel + 1); + + assert(numLevels >= 1); return numLevels; } @@ -304,7 +328,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, but we're not supporting multisampled textures yet. */ assert(pt->nr_samples < 2); - /* find expected last mipmap level */ + /* find expected last mipmap level to generate*/ lastLevel = compute_num_levels(ctx, texObj, target) - 1; if (lastLevel == 0) @@ -343,7 +367,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, pt = stObj->pt; } - assert(lastLevel <= pt->last_level); + assert(pt->last_level >= lastLevel); /* Try to generate the mipmap by rendering/texturing. If that fails, * use the software fallback. diff --git a/src/mesa/state_tracker/st_inlines.h b/src/mesa/state_tracker/st_inlines.h deleted file mode 100644 index 3bf7ba185e..0000000000 --- a/src/mesa/state_tracker/st_inlines.h +++ /dev/null @@ -1,159 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * 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 VMWARE 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. - * - **************************************************************************/ - -/** - * Functions for checking if buffers/textures are referenced when we need - * to read/write from/to them. Flush when needed. - */ - -#ifndef ST_INLINES_H -#define ST_INLINES_H - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" -#include "pipe/p_defines.h" -#include "util/u_inlines.h" -#include "util/u_box.h" -#include "pipe/p_state.h" - -#include "st_context.h" -#include "st_texture.h" -#include "st_cb_flush.h" - -static INLINE struct pipe_transfer * -st_cond_flush_get_tex_transfer(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - unsigned int zslice, - enum pipe_transfer_usage usage, - unsigned int x, unsigned int y, - unsigned int w, unsigned int h) -{ - struct pipe_context *context = st->pipe; - struct pipe_subresource subresource; - struct pipe_box box; - - subresource.face = face; - subresource.level = level; - - u_box_2d_zslice(x, y, zslice, w, h, &box); - - st_teximage_flush_before_map(st, pt, face, level, usage); - - return context->get_transfer(context, - pt, - subresource, - usage, - &box); -} - -static INLINE struct pipe_transfer * -st_no_flush_get_tex_transfer(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - unsigned int zslice, - enum pipe_transfer_usage usage, - unsigned int x, unsigned int y, - unsigned int w, unsigned int h) -{ - struct pipe_context *context = st->pipe; - struct pipe_box box; - struct pipe_subresource subresource = u_subresource( face, level ); - - u_box_2d_zslice( x, y, zslice, - w, h, - &box ); - - return context->get_transfer(context, - pt, - subresource, - usage, - &box); -} - - -static INLINE void -st_cond_flush_pipe_buffer_write(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - const void * data) -{ - struct pipe_context *pipe = st->pipe; - - pipe_buffer_write(pipe, buf, offset, size, data); -} - -static INLINE void -st_no_flush_pipe_buffer_write(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - const void * data) -{ - pipe_buffer_write(st->pipe, buf, offset, size, data); -} - -static INLINE void -st_no_flush_pipe_buffer_write_nooverlap(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - const void * data) -{ - pipe_buffer_write_nooverlap(st->pipe, buf, offset, size, data); -} - -static INLINE void -st_cond_flush_pipe_buffer_read(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - void * data) -{ - struct pipe_context *pipe = st->pipe; - - if (pipe->is_resource_referenced(pipe, buf, 0, 0) & PIPE_REFERENCED_FOR_WRITE) - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - - pipe_buffer_read(pipe, buf, offset, size, data); -} - -static INLINE void -st_no_flush_pipe_buffer_read(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - void * data) -{ - pipe_buffer_read(st->pipe, buf, offset, size, data); -} - -#endif - diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 44d59d4476..869196941c 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -508,6 +508,7 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target struct st_texture_object *stObj; struct st_texture_image *stImage; GLenum internalFormat; + GLuint width, height, depth; switch (target) { case ST_TEXTURE_1D: @@ -527,12 +528,6 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target break; } - if (util_format_get_component_bits(internal_format, - UTIL_FORMAT_COLORSPACE_RGB, 3) > 0) - internalFormat = GL_RGBA; - else - internalFormat = GL_RGB; - texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); @@ -546,17 +541,51 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target texImage = _mesa_get_tex_image(ctx, texObj, target, level); stImage = st_texture_image(texImage); if (tex) { + /* + * XXX When internal_format and tex->format differ, st_finalize_texture + * needs to allocate a new texture with internal_format and copy the + * texture here into the new one. It will result in surface_copy being + * called on surfaces whose formats differ. + * + * To avoid that, internal_format is (wrongly) ignored here. A sane fix + * is to use a sampler view. + */ + if (util_format_get_component_bits(tex->format, + UTIL_FORMAT_COLORSPACE_RGB, 3) > 0) + internalFormat = GL_RGBA; + else + internalFormat = GL_RGB; + _mesa_init_teximage_fields(ctx, target, texImage, tex->width0, tex->height0, 1, 0, internalFormat); texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat, GL_RGBA, GL_UNSIGNED_BYTE); _mesa_set_fetch_functions(texImage, 2); + + width = tex->width0; + height = tex->height0; + depth = tex->depth0; + + /* grow the image size until we hit level = 0 */ + while (level > 0) { + if (width != 1) + width <<= 1; + if (height != 1) + height <<= 1; + if (depth != 1) + depth <<= 1; + level--; + } } else { _mesa_clear_texture_image(ctx, texImage); + width = height = depth = 0; } pipe_resource_reference(&stImage->pt, tex); + stObj->width0 = width; + stObj->height0 = height; + stObj->depth0 = depth; _mesa_dirty_texobj(ctx, texObj, GL_TRUE); _mesa_unlock_texture(ctx, texObj); diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index e8eb9ec390..6df6cdfe03 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -62,10 +62,12 @@ struct st_translate { struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS]; struct ureg_dst address[1]; struct ureg_src samplers[PIPE_MAX_SAMPLERS]; - struct ureg_dst psizregreal; - struct ureg_src pointSizeConst; - GLint psizoutindex; - GLboolean prevInstWrotePsiz; + + /* Extra info for handling point size clamping in vertex shader */ + struct ureg_dst pointSizeResult; /**< Actual point size output register */ + struct ureg_src pointSizeConst; /**< Point size range constant register */ + GLint pointSizeOutIndex; /**< Temp point size output register */ + GLboolean prevInstWrotePointSize; const GLuint *inputMapping; const GLuint *outputMapping; @@ -92,6 +94,12 @@ struct st_translate { }; +/** + * Make note of a branch to a label in the TGSI code. + * After we've emitted all instructions, we'll go over the list + * of labels built here and patch the TGSI code with the actual + * location of each label. + */ static unsigned *get_label( struct st_translate *t, unsigned branch_target ) { @@ -116,6 +124,12 @@ static unsigned *get_label( struct st_translate *t, } +/** + * Called prior to emitting the TGSI code for each Mesa instruction. + * Allocate additional space for instructions if needed. + * Update the insn[] array so the next Mesa instruction points to + * the next TGSI instruction. + */ static void set_insn_start( struct st_translate *t, unsigned start ) { @@ -135,8 +149,8 @@ static void set_insn_start( struct st_translate *t, } -/* - * Map mesa register file to TGSI register file. +/** + * Map a Mesa dst register to a TGSI ureg_dst register. */ static struct ureg_dst dst_register( struct st_translate *t, @@ -154,8 +168,18 @@ dst_register( struct st_translate *t, return t->temps[index]; case PROGRAM_OUTPUT: - if (index == t->psizoutindex) - t->prevInstWrotePsiz = GL_TRUE; + if (t->procType == TGSI_PROCESSOR_VERTEX && index == VERT_RESULT_PSIZ) + t->prevInstWrotePointSize = GL_TRUE; + + if (t->procType == TGSI_PROCESSOR_VERTEX) + assert(index < VERT_RESULT_MAX); + else if (t->procType == TGSI_PROCESSOR_FRAGMENT) + assert(index < FRAG_RESULT_MAX); + else + assert(0 && "geom shaders not handled in dst_register() yet"); + + assert(t->outputMapping[index] < Elements(t->outputs)); + return t->outputs[t->outputMapping[index]]; case PROGRAM_ADDRESS: @@ -168,6 +192,9 @@ dst_register( struct st_translate *t, } +/** + * Map a Mesa src register to a TGSI ureg_src register. + */ static struct ureg_src src_register( struct st_translate *t, gl_register_file file, @@ -244,6 +271,9 @@ translate_texture_target( GLuint textarget, } +/** + * Create a TGSI ureg_dst register from a Mesa dest register. + */ static struct ureg_dst translate_dst( struct st_translate *t, const struct prog_dst_register *DstReg, @@ -266,6 +296,9 @@ translate_dst( struct st_translate *t, } +/** + * Create a TGSI ureg_src register from a Mesa src register. + */ static struct ureg_src translate_src( struct st_translate *t, const struct prog_src_register *SrcReg ) @@ -675,6 +708,7 @@ compile_instruction( } } + /** * Emit the TGSI instructions to adjust the WPOS pixel center convention */ @@ -686,12 +720,14 @@ emit_adjusted_wpos( struct st_translate *t, struct ureg_dst wpos_temp = ureg_DECL_temporary(ureg); struct ureg_src wpos_input = t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]]; - ureg_ADD(ureg, ureg_writemask(wpos_temp, TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y), - wpos_input, ureg_imm1f(ureg, value)); + ureg_ADD(ureg, + ureg_writemask(wpos_temp, TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y), + wpos_input, ureg_imm1f(ureg, value)); t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]] = ureg_src(wpos_temp); } + /** * Emit the TGSI instructions for inverting the WPOS y coordinate. */ @@ -884,8 +920,8 @@ st_translate_mesa_program( t->inputMapping = inputMapping; t->outputMapping = outputMapping; t->ureg = ureg; - t->psizoutindex = -1; - t->prevInstWrotePsiz = GL_FALSE; + t->pointSizeOutIndex = -1; + t->prevInstWrotePointSize = GL_FALSE; /*_mesa_print_program(program);*/ @@ -954,6 +990,9 @@ st_translate_mesa_program( outputSemanticName[i], outputSemanticIndex[i] ); if ((outputSemanticName[i] == TGSI_SEMANTIC_PSIZE) && program->Id) { + /* Writing to the point size result register requires special + * handling to implement clamping. + */ static const gl_state_index pointSizeClampState[STATE_LENGTH] = { STATE_INTERNAL, STATE_POINT_SIZE_IMPL_CLAMP, 0, 0, 0 }; /* XXX: note we are modifying the incoming shader here! Need to @@ -965,8 +1004,8 @@ st_translate_mesa_program( pointSizeClampState); struct ureg_dst psizregtemp = ureg_DECL_temporary( ureg ); t->pointSizeConst = ureg_DECL_constant( ureg, pointSizeClampConst ); - t->psizregreal = t->outputs[i]; - t->psizoutindex = i; + t->pointSizeResult = t->outputs[i]; + t->pointSizeOutIndex = i; t->outputs[i] = psizregtemp; } } @@ -1035,19 +1074,24 @@ st_translate_mesa_program( set_insn_start( t, ureg_get_instruction_number( ureg )); compile_instruction( t, &program->Instructions[i] ); - /* note can't do that easily at the end of prog due to - possible early return */ - if (t->prevInstWrotePsiz && program->Id) { + if (t->prevInstWrotePointSize && program->Id) { + /* The previous instruction wrote to the (fake) vertex point size + * result register. Now we need to clamp that value to the min/max + * point size range, putting the result into the real point size + * register. + * Note that we can't do this easily at the end of program due to + * possible early return. + */ set_insn_start( t, ureg_get_instruction_number( ureg )); ureg_MAX( t->ureg, - ureg_writemask(t->outputs[t->psizoutindex], WRITEMASK_X), - ureg_src(t->outputs[t->psizoutindex]), + ureg_writemask(t->outputs[t->pointSizeOutIndex], WRITEMASK_X), + ureg_src(t->outputs[t->pointSizeOutIndex]), ureg_swizzle(t->pointSizeConst, 1,1,1,1)); - ureg_MIN( t->ureg, ureg_writemask(t->psizregreal, WRITEMASK_X), - ureg_src(t->outputs[t->psizoutindex]), + ureg_MIN( t->ureg, ureg_writemask(t->pointSizeResult, WRITEMASK_X), + ureg_src(t->outputs[t->pointSizeOutIndex]), ureg_swizzle(t->pointSizeConst, 2,2,2,2)); } - t->prevInstWrotePsiz = GL_FALSE; + t->prevInstWrotePointSize = GL_FALSE; } /* Fix up all emitted labels: diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 772a2ee17c..3c865028a7 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -65,8 +65,10 @@ st_vp_release_varients( struct st_context *st, if (vpv->driver_shader) cso_delete_vertex_shader(st->cso_context, vpv->driver_shader); +#if FEATURE_feedback || FEATURE_rastpos if (vpv->draw_shader) draw_delete_vertex_shader( st->draw, vpv->draw_shader ); +#endif if (vpv->tgsi.tokens) st_free_tokens(vpv->tgsi.tokens); diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index d0d1c5c315..dbdf1ea1ad 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -29,7 +29,6 @@ #include "st_format.h" #include "st_texture.h" #include "st_cb_fbo.h" -#include "st_inlines.h" #include "main/enums.h" #undef Elements /* fix re-defined macro warning */ @@ -66,6 +65,9 @@ st_texture_create(struct st_context *st, struct pipe_screen *screen = st->pipe->screen; assert(target <= PIPE_TEXTURE_CUBE); + assert(width0 > 0); + assert(height0 > 0); + assert(depth0 > 0); DBG("%s target %s format %s last_level %d\n", __FUNCTION__, _mesa_lookup_enum_by_nr(target), @@ -142,7 +144,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, DBG("%s \n", __FUNCTION__); - stImage->transfer = st_no_flush_get_tex_transfer(st, pt, stImage->face, + stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->face, stImage->level, zoffset, usage, x, y, w, h); @@ -217,7 +219,7 @@ st_texture_image_data(struct st_context *st, DBG("%s\n", __FUNCTION__); for (i = 0; i < depth; i++) { - dst_transfer = st_no_flush_get_tex_transfer(st, dst, face, level, i, + dst_transfer = pipe_get_transfer(st->pipe, dst, face, level, i, PIPE_TRANSFER_WRITE, 0, 0, u_minify(dst->width0, level), u_minify(dst->height0, level)); @@ -237,12 +239,47 @@ st_texture_image_data(struct st_context *st, } -/* Copy mipmap image between textures +/** + * For debug only: get/print center pixel in the src resource. + */ +static void +print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src) +{ + struct pipe_subresource rect; + struct pipe_transfer *xfer; + struct pipe_box region; + ubyte *map; + + rect.face = 0; + rect.level = 0; + + region.x = src->width0 / 2; + region.y = src->height0 / 2; + region.z = 0; + region.width = 1; + region.height = 1; + region.depth = 1; + + xfer = pipe->get_transfer(pipe, src, rect, PIPE_TRANSFER_READ, ®ion); + map = pipe->transfer_map(pipe, xfer); + + printf("center pixel: %d %d %d %d\n", map[0], map[1], map[2], map[3]); + + pipe->transfer_unmap(pipe, xfer); + pipe->transfer_destroy(pipe, xfer); +} + + +/** + * Copy the image at level=0 in 'src' to the 'dst' resource at 'dstLevel'. + * This is used to copy mipmap images from one texture buffer to another. + * This typically happens when our initial guess at the total texture size + * is incorrect (see the guess_and_alloc_texture() function). */ void st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *dst, GLuint dstLevel, - struct pipe_resource *src, + struct pipe_resource *src, GLuint srcLevel, GLuint face) { GLuint width = u_minify(dst->width0, dstLevel); @@ -251,43 +288,20 @@ st_texture_image_copy(struct pipe_context *pipe, struct pipe_subresource dstsub, srcsub; GLuint i; - assert(src->width0 == dst->width0); - assert(src->height0 == dst->height0); + assert(u_minify(src->width0, srcLevel) == width); + assert(u_minify(src->height0, srcLevel) == height); + assert(u_minify(src->depth0, srcLevel) == depth); dstsub.face = face; dstsub.level = dstLevel; srcsub.face = face; - + srcsub.level = srcLevel; + /* Loop over 3D image slices */ for (i = 0; i < depth; i++) { - GLuint srcLevel; - - /* find src texture level of needed size */ - for (srcLevel = 0; srcLevel <= src->last_level; srcLevel++) { - if (u_minify(src->width0, srcLevel) == width && - u_minify(src->height0, srcLevel) == height) { - break; - } - } - assert(u_minify(src->width0, srcLevel) == width); - assert(u_minify(src->height0, srcLevel) == height); - -#if 0 - { - struct pipe_screen *screen = pipe->screen; - src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, - PIPE_BUFFER_USAGE_CPU_READ); - ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ); - map += src_surface->width * src_surface->height * 4 / 2; - printf("%s center pixel: %d %d %d %d (pt %p[%d] -> %p[%d])\n", - __FUNCTION__, - map[0], map[1], map[2], map[3], - src, srcLevel, dst, dstLevel); - - screen->surface_unmap(screen, src_surface); - pipe_surface_reference(&src_surface, NULL); + + if (0) { + print_center_pixel(pipe, src); } -#endif - srcsub.level = srcLevel; pipe->resource_copy_region(pipe, dst, @@ -300,19 +314,3 @@ st_texture_image_copy(struct pipe_context *pipe, } } - -void -st_teximage_flush_before_map(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - enum pipe_transfer_usage usage) -{ - struct pipe_context *pipe = st->pipe; - unsigned referenced = - pipe->is_resource_referenced(pipe, pt, face, level); - - if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) || - (usage & PIPE_TRANSFER_WRITE))) - st->pipe->flush(st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); -} diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 447f091db1..ed5d271597 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -205,13 +205,7 @@ st_texture_image_data(struct st_context *st, extern void st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *dst, GLuint dstLevel, - struct pipe_resource *src, + struct pipe_resource *src, GLuint srcLevel, GLuint face); -extern void -st_teximage_flush_before_map(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - enum pipe_transfer_usage usage); #endif |