From a52faa9325db178601811f4bdad6d9747de5f238 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Apr 2008 16:09:46 -0600 Subject: gallium: remove unneeded st->haveFramebufferSurfaces field. --- src/mesa/state_tracker/st_cb_drawpixels.c | 6 +----- src/mesa/state_tracker/st_context.c | 2 -- src/mesa/state_tracker/st_context.h | 6 ------ 3 files changed, 1 insertion(+), 13 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index c57e05312a..b1affc4a91 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1017,11 +1017,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, srcy = ctx->DrawBuffer->Height - srcy - height; } - /* For some drivers (like Xlib) it's not possible to treat the - * front/back color buffers as surfaces (they're XImages and Pixmaps). - * So, this var tells us if we can use surface_copy here... - */ - if (st->haveFramebufferSurfaces && srcFormat == texFormat) { + if (srcFormat == texFormat) { /* copy source framebuffer surface into mipmap/texture */ pipe->surface_copy(pipe, FALSE, diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 7511c28074..154327239d 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -128,8 +128,6 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; - st->haveFramebufferSurfaces = GL_TRUE; - st->pixel_xfer.cache = _mesa_new_program_cache(); /* GL limits and extensions */ diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index bcebbd4943..212687cf4a 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -111,12 +111,6 @@ struct st_context char vendor[100]; char renderer[100]; - /** Can we access the front/back color buffers as pipe_surfaces? - * We can't with the Xlib driver... - * This is a hack that should be fixed someday. - */ - GLboolean haveFramebufferSurfaces; - /* State to be validated: */ struct st_tracked_state **atoms; -- cgit v1.2.3 From 9c86c0e88b09370584f767747c52b7f352844ac5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Apr 2008 16:26:56 -0600 Subject: gallium: refactor code, new flush_front_buffer() function --- src/mesa/state_tracker/st_cb_flush.c | 42 +++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index c7efa40e38..1fc3a20d05 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -44,26 +44,12 @@ #include "pipe/p_winsys.h" -void st_flush( struct st_context *st, uint pipeFlushFlags, - struct pipe_fence_handle **fence ) -{ - FLUSH_VERTICES(st->ctx, 0); - - st_flush_bitmap_cache(st); - - st->pipe->flush( st->pipe, pipeFlushFlags, fence ); -} - - -static void st_gl_flush( struct st_context *st, uint pipeFlushFlags, - struct pipe_fence_handle **fence ) +static void +flush_front_buffer(struct st_context *st, uint pipeFlushFlags, + struct pipe_fence_handle **fence) { GLframebuffer *fb = st->ctx->DrawBuffer; - st_flush_bitmap_cache(st); - - FLUSH_VERTICES(st->ctx, 0); - if (!fb) return; @@ -105,6 +91,28 @@ static void st_gl_flush( struct st_context *st, uint pipeFlushFlags, } +void st_flush( struct st_context *st, uint pipeFlushFlags, + struct pipe_fence_handle **fence ) +{ + FLUSH_VERTICES(st->ctx, 0); + + st_flush_bitmap_cache(st); + + st->pipe->flush( st->pipe, pipeFlushFlags, fence ); +} + + +static void st_gl_flush( struct st_context *st, uint pipeFlushFlags, + struct pipe_fence_handle **fence ) +{ + st_flush_bitmap_cache(st); + + FLUSH_VERTICES(st->ctx, 0); + + flush_front_buffer(st, pipeFlushFlags, fence); +} + + /** * Called via ctx->Driver.Flush() */ -- cgit v1.2.3 From 574f964667c5ec35f4832c839a9dcc24f92e2aab Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Apr 2008 16:30:28 -0600 Subject: gallium: fold st_gl_flush() into st_glFlush() --- src/mesa/state_tracker/st_cb_flush.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 1fc3a20d05..d60ad7b82a 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -102,23 +102,16 @@ void st_flush( struct st_context *st, uint pipeFlushFlags, } -static void st_gl_flush( struct st_context *st, uint pipeFlushFlags, - struct pipe_fence_handle **fence ) -{ - st_flush_bitmap_cache(st); - - FLUSH_VERTICES(st->ctx, 0); - - flush_front_buffer(st, pipeFlushFlags, fence); -} - - /** * Called via ctx->Driver.Flush() */ static void st_glFlush(GLcontext *ctx) { - st_gl_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_flush_bitmap_cache(ctx->st); + + FLUSH_VERTICES(ctx, 0); + + flush_front_buffer(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); } -- cgit v1.2.3 From aade2f41b0d5cf0fb44e094c0b10cfaf1f621aec Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Apr 2008 16:32:22 -0600 Subject: gallium: call_flush_front_buffer() from st_glFinish() --- src/mesa/state_tracker/st_cb_flush.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index d60ad7b82a..167c7ccbe2 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -132,6 +132,8 @@ void st_finish( struct st_context *st ) static void st_glFinish(GLcontext *ctx) { st_finish( ctx->st ); + + flush_front_buffer(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); } -- cgit v1.2.3 From 4ecbd5a70fba3e7d5f8b56ede34867ea5964afc6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Apr 2008 16:32:46 -0600 Subject: gallium: reorder funcs --- src/mesa/state_tracker/st_cb_flush.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 167c7ccbe2..6bda877bb0 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -102,6 +102,18 @@ void st_flush( struct st_context *st, uint pipeFlushFlags, } +void st_finish( struct st_context *st ) +{ + struct pipe_fence_handle *fence = NULL; + + st_flush(st, PIPE_FLUSH_RENDER_CACHE, &fence); + + st->pipe->winsys->fence_finish(st->pipe->winsys, fence, 0); + st->pipe->winsys->fence_reference(st->pipe->winsys, &fence, NULL); +} + + + /** * Called via ctx->Driver.Flush() */ @@ -115,17 +127,6 @@ static void st_glFlush(GLcontext *ctx) } -void st_finish( struct st_context *st ) -{ - struct pipe_fence_handle *fence = NULL; - - st_flush(st, PIPE_FLUSH_RENDER_CACHE, &fence); - - st->pipe->winsys->fence_finish(st->pipe->winsys, fence, 0); - st->pipe->winsys->fence_reference(st->pipe->winsys, &fence, NULL); -} - - /** * Called via ctx->Driver.Finish() */ -- cgit v1.2.3 From 54d7c399a888283711bdc00f93cb54a3ce0b30eb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Apr 2008 16:59:14 -0600 Subject: gallium: more flush/finish changes New, separate is_front_buffer_dirty() function. --- src/mesa/state_tracker/st_cb_flush.c | 70 ++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 6bda877bb0..1bcd1b4cd9 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -44,14 +44,13 @@ #include "pipe/p_winsys.h" -static void -flush_front_buffer(struct st_context *st, uint pipeFlushFlags, - struct pipe_fence_handle **fence) +static GLboolean +is_front_buffer_dirty(struct st_context *st) { GLframebuffer *fb = st->ctx->DrawBuffer; if (!fb) - return; + return GL_FALSE; /* XXX: temporary hack. This flag should only be set if we do any * rendering to the front buffer. @@ -68,26 +67,26 @@ flush_front_buffer(struct st_context *st, uint pipeFlushFlags, st->flags.frontbuffer_dirty = (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT); - if (st->flags.frontbuffer_dirty) { - struct st_renderbuffer *strb - = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); - struct pipe_surface *front_surf = strb->surface; - - /* If we aren't rendering to the frontbuffer, this is a noop. - * This should be uncontroversial for glFlush, though people may - * feel more strongly about glFinish. - * - * Additionally, need to make sure that the frontbuffer_dirty - * flag really gets set on frontbuffer rendering. - */ - st->pipe->flush( st->pipe, pipeFlushFlags, fence ); - - /* Hook for copying "fake" frontbuffer if necessary: - */ - st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf, - st->pipe->priv ); - st->flags.frontbuffer_dirty = 0; - } + return st->flags.frontbuffer_dirty; +} + + +/** + * Tell the winsys to display the front color buffer on-screen. + */ +static void +display_front_buffer(struct st_context *st) +{ + GLframebuffer *fb = st->ctx->DrawBuffer; + struct st_renderbuffer *strb + = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + struct pipe_surface *front_surf = strb->surface; + + /* Hook for copying "fake" frontbuffer if necessary: + */ + st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf, + st->pipe->priv ); + st->flags.frontbuffer_dirty = 0; } @@ -102,6 +101,9 @@ void st_flush( struct st_context *st, uint pipeFlushFlags, } +/** + * Flush, and wait for completion. + */ void st_finish( struct st_context *st ) { struct pipe_fence_handle *fence = NULL; @@ -119,11 +121,15 @@ void st_finish( struct st_context *st ) */ static void st_glFlush(GLcontext *ctx) { - st_flush_bitmap_cache(ctx->st); - - FLUSH_VERTICES(ctx, 0); + struct st_context *st = ctx->st; - flush_front_buffer(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + if (is_front_buffer_dirty(st)) { + st_finish(st); + display_front_buffer(st); + } + else { + st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); + } } @@ -132,9 +138,13 @@ static void st_glFlush(GLcontext *ctx) */ static void st_glFinish(GLcontext *ctx) { - st_finish( ctx->st ); + struct st_context *st = ctx->st; - flush_front_buffer(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_finish(st); + + if (is_front_buffer_dirty(st)) { + display_front_buffer(st); + } } -- cgit v1.2.3 From 311e40268414649f047ee177ba22a17a2d437843 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 9 Apr 2008 18:39:51 -0600 Subject: gallium: more elaborate tracking of front color buffer state This fixes the case where the app calls SwapBuffers then calls glReadPixels to read the front color buffer. We now keep track of when the front buffer is a _logically_ copy of the back buffer (after SwapBuffers) and read from the back color buffer instead of the front. --- src/mesa/state_tracker/st_atom_framebuffer.c | 8 +++++++ src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_cb_flush.c | 27 ++++------------------- src/mesa/state_tracker/st_cb_readpixels.c | 33 ++++++++++++++++++++++++++-- src/mesa/state_tracker/st_cb_readpixels.h | 3 +++ src/mesa/state_tracker/st_context.h | 9 +++++--- src/mesa/state_tracker/st_framebuffer.c | 1 + 7 files changed, 54 insertions(+), 29 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 02573af8f0..8a95096ec9 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -81,6 +81,14 @@ update_framebuffer_state( struct st_context *st ) } cso_set_framebuffer(st->cso_context, framebuffer); + + if (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) { + if (st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) { + /* XXX copy back buf to front? */ + } + /* we're assuming we'll really draw to the front buffer */ + st->frontbuffer_status = FRONT_STATUS_DIRTY; + } } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index b1affc4a91..5f8c90cbba 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -961,7 +961,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, } if (type == GL_COLOR) { - rbRead = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); + rbRead = st_get_color_read_renderbuffer(ctx); color = NULL; stfp = combined_drawpix_fragment_program(ctx); stvp = st_make_passthrough_vertex_shader(ctx->st, GL_FALSE); diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 1bcd1b4cd9..1b3402cee2 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -44,30 +44,10 @@ #include "pipe/p_winsys.h" -static GLboolean +static INLINE GLboolean is_front_buffer_dirty(struct st_context *st) { - GLframebuffer *fb = st->ctx->DrawBuffer; - - if (!fb) - return GL_FALSE; - - /* XXX: temporary hack. This flag should only be set if we do any - * rendering to the front buffer. - * - * Further more, the scissor rectangle could be tracked to - * construct a dirty region of the front buffer, to avoid - * situations where it must be copied repeatedly. - * - * In the extreme case, some kind of timer could be set up to allow - * coalescing of multiple flushes to the frontbuffer, which can be - * quite a performance drain if there are a sufficient number of - * them. - */ - st->flags.frontbuffer_dirty - = (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT); - - return st->flags.frontbuffer_dirty; + return st->frontbuffer_status == FRONT_STATUS_DIRTY; } @@ -86,7 +66,8 @@ display_front_buffer(struct st_context *st) */ st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf, st->pipe->priv ); - st->flags.frontbuffer_dirty = 0; + + st->frontbuffer_status = FRONT_STATUS_UNDEFINED; } diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 2bcc8c99fb..29a06ffaa9 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -128,6 +128,34 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } +/** + * Return renderbuffer to use for reading color pixels for glRead/CopyPixel + * commands. + * Special care is needed for the front buffer. + */ +struct st_renderbuffer * +st_get_color_read_renderbuffer(GLcontext *ctx) +{ + struct gl_framebuffer *fb = ctx->ReadBuffer; + struct st_renderbuffer *strb = + st_renderbuffer(fb->_ColorReadBuffer); + struct st_renderbuffer *front = + st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + + if (strb == front + && ctx->st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) { + /* reading from front color buffer, which is a logical copy of the + * back color buffer. + */ + struct st_renderbuffer *back = + st_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + strb = back; + } + + return strb; +} + + /** * Do glReadPixels by getting rows from the framebuffer surface with * get_tile(). Convert to requested format/type with Mesa image routines. @@ -173,12 +201,13 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, strb = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer); } else { - strb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); + /* Read color buffer */ + strb = st_get_color_read_renderbuffer(ctx); } + if (!strb) return; - if (format == GL_RGBA && type == GL_FLOAT) { /* write tile(row) directly into user's buffer */ df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width, diff --git a/src/mesa/state_tracker/st_cb_readpixels.h b/src/mesa/state_tracker/st_cb_readpixels.h index 79acdad88e..9e151be51f 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.h +++ b/src/mesa/state_tracker/st_cb_readpixels.h @@ -29,6 +29,9 @@ #ifndef ST_CB_READPIXELS_H #define ST_CB_READPIXELS_H +extern struct st_renderbuffer * +st_get_color_read_renderbuffer(GLcontext *ctx); + extern void st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum type, diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 212687cf4a..d89e54c43c 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -45,6 +45,11 @@ struct blit_state; struct bitmap_cache; +#define FRONT_STATUS_UNDEFINED 0 +#define FRONT_STATUS_DIRTY 1 +#define FRONT_STATUS_COPY_OF_BACK 2 + + #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 #define ST_NEW_VERTEX_PROGRAM 0x4 @@ -104,9 +109,7 @@ struct st_context struct gl_fragment_program *fragment_program; } cb; - struct { - GLuint frontbuffer_dirty:1; - } flags; + GLuint frontbuffer_status; /**< one of FRONT_STATUS_ */ char vendor[100]; char renderer[100]; diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index ea09d9234c..47466c97d8 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -188,6 +188,7 @@ st_notify_swapbuffers(struct st_framebuffer *stfb) st_flush( ctx->st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_SWAPBUFFERS, NULL ); + ctx->st->frontbuffer_status = FRONT_STATUS_COPY_OF_BACK; } } -- cgit v1.2.3 From 7a8ad75c89b45520043693a37d9f0c7e0b24fc5d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 10 Apr 2008 10:30:46 -0600 Subject: gallium: fix readback of z16 values --- src/mesa/state_tracker/st_cb_readpixels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 29a06ffaa9..1fef55b844 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -269,7 +269,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } else if (strb->surface->format == PIPE_FORMAT_Z16_UNORM) { for (i = 0; i < height; i++) { - GLshort ztemp[MAX_WIDTH], j; + GLushort ztemp[MAX_WIDTH], j; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / 0xffff; pipe_get_tile_raw(pipe, strb->surface, x, y, width, 1, ztemp, 0); -- cgit v1.2.3 From d758479b9fbff803bdac15f3f39d32ef9064db71 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 11 Apr 2008 10:14:17 -0600 Subject: mesa: Fix glBegin-time test for invalid programs/shaders. Cherry-picked from master. --- src/mesa/vbo/vbo_exec.h | 3 +++ src/mesa/vbo/vbo_exec_api.c | 31 +++++++++++++++++++++++-------- src/mesa/vbo/vbo_exec_array.c | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 8 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index b7e8c9fe79..ddbcbe1181 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -162,4 +162,7 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, void vbo_exec_do_EvalCoord1f( struct vbo_exec_context *exec, GLfloat u); +extern GLboolean +vbo_validate_shaders(GLcontext *ctx); + #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index b7f4d8a307..98580170e3 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -477,6 +477,23 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j ) } +/** + * Check if programs/shaders are enabled and valid at glBegin time. + */ +GLboolean +vbo_validate_shaders(GLcontext *ctx) +{ + if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) || + (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) { + return GL_FALSE; + } + if (ctx->Shader.CurrentProgram && !ctx->Shader.CurrentProgram->LinkStatus) { + return GL_FALSE; + } + return GL_TRUE; +} + + /* Build a list of primitives on the fly. Keep * ctx->Driver.CurrentExecPrimitive uptodate as well. */ @@ -491,18 +508,16 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) if (ctx->NewState) { _mesa_update_state( ctx ); - /* XXX also need to check if shader enabled, but invalid */ - if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) || - (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBegin (invalid vertex/fragment program)"); - return; - } - CALL_Begin(ctx->Exec, (mode)); return; } + if (!vbo_validate_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBegin (invalid vertex/fragment program)"); + return; + } + /* Heuristic: attempt to isolate attributes occuring outside * begin/end pairs. */ diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 77f3cf1455..a52521db64 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -245,6 +245,11 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) if (ctx->NewState) _mesa_update_state( ctx ); + if (!vbo_validate_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawArrays(bad shader)"); + return; + } + bind_arrays( ctx ); prim[0].begin = 1; @@ -280,6 +285,11 @@ vbo_exec_DrawRangeElements(GLenum mode, if (ctx->NewState) _mesa_update_state( ctx ); + if (!vbo_validate_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawRangeElements(bad shader)"); + return; + } + bind_arrays( ctx ); ib.count = count; @@ -340,6 +350,11 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *ind if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices )) return; + if (!vbo_validate_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawElements(bad shader)"); + return; + } + if (ctx->Array.ElementArrayBufferObj->Name) { const GLvoid *map = ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, -- cgit v1.2.3 From 02250c855fbec5299a2d6118fefa0523ec73654c Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 11 Apr 2008 17:45:41 +0100 Subject: gallium: Flush render cache at the beginning of fallback_copy_texsubimage(). It may get stale bits otherwise. --- src/mesa/state_tracker/st_cb_texture.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 43b43ec14c..3db2790267 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -41,6 +41,7 @@ #include "state_tracker/st_cb_fbo.h" #include "state_tracker/st_cb_texture.h" #include "state_tracker/st_format.h" +#include "state_tracker/st_public.h" #include "state_tracker/st_texture.h" #include "state_tracker/st_gen_mipmap.h" @@ -1033,6 +1034,8 @@ fallback_copy_texsubimage(GLcontext *ctx, GLfloat *data; GLint row, yStep; + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + /* determine bottom-to-top vs. top-to-bottom order */ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { destY = height - 1 - destY; -- cgit v1.2.3 From 16900515214912557dfd35e3b333e0e312b8bc61 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 11 Apr 2008 13:21:22 -0600 Subject: mesa: fix broken x86_call() --- src/mesa/x86/rtasm/x86sse.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c index 39c0e9b851..7a91364ed8 100644 --- a/src/mesa/x86/rtasm/x86sse.c +++ b/src/mesa/x86/rtasm/x86sse.c @@ -1,3 +1,4 @@ +#ifdef USE_X86_ASM #if defined(__i386__) || defined(__386__) #include "imports.h" @@ -290,7 +291,7 @@ void x86_call( struct x86_function *p, void (*label)()) void x86_call( struct x86_function *p, struct x86_reg reg) { emit_1ub(p, 0xff); - emit_modrm(p, reg, reg); + emit_modrm_noreg(p, 2, reg); } #endif @@ -1191,3 +1192,9 @@ void x86sse_dummy( void ) } #endif + +#else /* USE_X86_ASM */ + +int x86sse_c_dummy_var; /* silence warning */ + +#endif /* USE_X86_ASM */ -- cgit v1.2.3 From 78852986e6379a615a5742951f0fc6470e7c9d12 Mon Sep 17 00:00:00 2001 From: David Flynn Date: Mon, 14 Apr 2008 12:56:10 -0600 Subject: mesa: define #extension GL_ARB_texture_rectangle --- src/mesa/shader/slang/slang_preprocess.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index 076e982f8f..cf8cd5f87a 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -483,6 +483,7 @@ pp_cond_stack_reevaluate (pp_cond_stack *self) typedef struct { GLboolean MESA_shader_debug; /* GL_MESA_shader_debug enable */ + GLboolean GL_ARB_texture_rectangle; /* GL_ARB_texture_rectangle enable */ } pp_ext; /* @@ -498,6 +499,7 @@ static GLvoid pp_ext_init (pp_ext *self) { pp_ext_disable_all (self); + self->GL_ARB_texture_rectangle = GL_TRUE; /* Other initialization code goes here. */ } @@ -506,6 +508,8 @@ pp_ext_set (pp_ext *self, const char *name, GLboolean enable) { if (_mesa_strcmp (name, "MESA_shader_debug") == 0) self->MESA_shader_debug = enable; + else if (_mesa_strcmp (name, "GL_ARB_texture_rectangle") == 0) + self->GL_ARB_texture_rectangle = enable; /* Next extension name tests go here. */ else return GL_FALSE; -- cgit v1.2.3 From 5807c0242c38742d96c7ada3503f3198070aa208 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 14 Apr 2008 14:38:11 -0600 Subject: fix GL_ARB_texture_rectangle breakage --- src/mesa/shader/slang/slang_preprocess.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index cf8cd5f87a..1645afcc18 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -483,7 +483,7 @@ pp_cond_stack_reevaluate (pp_cond_stack *self) typedef struct { GLboolean MESA_shader_debug; /* GL_MESA_shader_debug enable */ - GLboolean GL_ARB_texture_rectangle; /* GL_ARB_texture_rectangle enable */ + GLboolean ARB_texture_rectangle; /* GL_ARB_texture_rectangle enable */ } pp_ext; /* @@ -499,7 +499,7 @@ static GLvoid pp_ext_init (pp_ext *self) { pp_ext_disable_all (self); - self->GL_ARB_texture_rectangle = GL_TRUE; + self->ARB_texture_rectangle = GL_TRUE; /* Other initialization code goes here. */ } @@ -509,7 +509,7 @@ pp_ext_set (pp_ext *self, const char *name, GLboolean enable) if (_mesa_strcmp (name, "MESA_shader_debug") == 0) self->MESA_shader_debug = enable; else if (_mesa_strcmp (name, "GL_ARB_texture_rectangle") == 0) - self->GL_ARB_texture_rectangle = enable; + self->ARB_texture_rectangle = enable; /* Next extension name tests go here. */ else return GL_FALSE; -- cgit v1.2.3 From b54225ccd6d3bc1b678e27c2f00ebddf5bf1046d Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Apr 2008 20:56:08 -0600 Subject: gallium: set ctx->Const.MaxDrawBuffers --- src/mesa/state_tracker/st_extensions.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 47a50d40ca..2f7ac074da 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -111,6 +111,10 @@ void st_init_limits(struct st_context *st) st->bitmap_texcoord_bias = screen->get_paramf(screen, PIPE_CAP_BITMAP_TEXCOORD_BIAS); + + c->MaxDrawBuffers + = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), + 1, MAX_DRAW_BUFFERS); } -- cgit v1.2.3 From e4b3c13d7a7dbd716bdf4b4d2dda8c6e579bd2d1 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Apr 2008 20:57:15 -0600 Subject: gallium: fix multi drawbuffer fb state --- src/mesa/state_tracker/st_atom_framebuffer.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 8a95096ec9..14eeb58cc1 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -48,7 +48,7 @@ update_framebuffer_state( struct st_context *st ) struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer; struct gl_framebuffer *fb = st->ctx->DrawBuffer; struct st_renderbuffer *strb; - GLuint i; + GLuint i, j; memset(framebuffer, 0, sizeof(*framebuffer)); @@ -58,11 +58,14 @@ update_framebuffer_state( struct st_context *st ) /* Examine Mesa's ctx->DrawBuffer->_ColorDrawBuffers state * to determine which surfaces to draw to */ - framebuffer->num_cbufs = fb->_NumColorDrawBuffers[0]; - for (i = 0; i < framebuffer->num_cbufs; i++) { - strb = st_renderbuffer(fb->_ColorDrawBuffers[0][i]); - assert(strb->surface); - framebuffer->cbufs[i] = strb->surface; + framebuffer->num_cbufs = 0; + for (j = 0; j < MAX_DRAW_BUFFERS; j++) { + for (i = 0; i < fb->_NumColorDrawBuffers[j]; i++) { + strb = st_renderbuffer(fb->_ColorDrawBuffers[j][i]); + assert(strb->surface); + framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface; + framebuffer->num_cbufs++; + } } strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer); -- cgit v1.2.3 From 90b9a11a6d69f1cf6c837def0e8a9b598079ef1b Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 14 Apr 2008 20:58:05 -0600 Subject: gallium: fix semantic indexes for outputs --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 578fd2ecb0..524b5af50b 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -767,12 +767,14 @@ tgsi_translate_mesa_program( switch (outputSemanticName[i]) { case TGSI_SEMANTIC_POSITION: fulldecl = make_output_decl(i, - TGSI_SEMANTIC_POSITION, 0, /* Z / Depth */ + TGSI_SEMANTIC_POSITION, /* Z / Depth */ + outputSemanticIndex[i], TGSI_WRITEMASK_Z ); break; case TGSI_SEMANTIC_COLOR: fulldecl = make_output_decl(i, - TGSI_SEMANTIC_COLOR, 0, + TGSI_SEMANTIC_COLOR, + outputSemanticIndex[i], TGSI_WRITEMASK_XYZW ); break; default: -- cgit v1.2.3