Re: [Mesa-dev] [PATCH 09/10] vbo: fix GL_LINE_LOOP stray line bug
>From: Brian Paul >Sent: Friday, October 16, 2015 2:25 PM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee; Jose Fonseca; Sinclair Yeh >Subject: [PATCH 09/10] vbo: fix GL_LINE_LOOP stray line bug >When long GL_LINE_LOOP primitives don't fit in one vertex buffer they >have to be split across buffers. The code to do this was basically correct >but drivers had to pay special attention to the _mesa_prim::begin,end flags >in order to draw the sections of the line loop properly. Apparently, the >only drivers to do this were those using the old 'tnl' module for software >vertex processing. >Now we convert the split pieces of GL_LINE_LOOP prims into GL_LINE_STRIP >primitives so that drivers don't have to worry about the special begin/end >flags. The only time a driver will get a GL_LINE_LOOP prim is when the >whole thing fits in one vertex buffer. >Most fixes bug 81174, but not completely. There's another bug somewhere >in the src/gallium/auxiliary/draw/ code. If the piglit lineloop test is >run with -count 4096, rendering is correct, but with -count 4097 there are >stray lines. 4096 is a magic number in the draw code (search for "4096"). >Also note that this does not fix long line loops in display lists. The >next patch fixes that. >Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81174 >--- > src/mesa/vbo/vbo_context.h | 5 - > src/mesa/vbo/vbo_exec_api.c | 38 +- > src/mesa/vbo/vbo_exec_draw.c | 12 > 3 files changed, 53 insertions(+), 2 deletions(-) >diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h >index 1e85335..28f43b4 100644 >--- a/src/mesa/vbo/vbo_context.h >+++ b/src/mesa/vbo/vbo_context.h >@@ -205,7 +205,10 @@ vbo_get_default_vals_as_union(GLenum format) > static inline unsigned > vbo_compute_max_verts(const struct vbo_exec_context *exec) > { >- return (VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / >+ /* Subtract one so we're always sure to have room for an extra >+* vertex for GL_LINE_LOOP -> GL_LINE_STRIP conversion. >+*/ >+ return (VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used - 1) / > (exec->vtx.vertex_size * sizeof(GLfloat)); Shouldn't this be (VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / (exec->vtx.vertex_size *sizeof(GLfloat)) - 1; -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: add switch case for PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT
Reviewed-by: Charmaine Lee From: mesa-dev on behalf of Brian Paul Sent: Tuesday, October 20, 2015 5:23 PM To: mesa-dev@lists.freedesktop.org Subject: [Mesa-dev] [PATCH] svga: add switch case for PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT A third instance of this was needed but missed in the previous commit. Return 32 as for the two other cases. --- src/gallium/drivers/svga/svga_screen.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 17b042e..f6fafca 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -605,6 +605,8 @@ vgpu10_get_shader_param(struct pipe_screen *screen, unsigned shader, case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: return 0; + case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT: + return 32; default: debug_printf("Unexpected vgpu10 shader query %u\n", param); return 0; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: fix clip plane regression after recent tgsi_scan change
A minor nit, please change "num_written_culldistance field was a multiple of four" comment in the commit message to "num_written_clipdistance field was a " Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, October 21, 2015 3:25 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: fix clip plane regression after recent tgsi_scan change Before the change "tgsi/scan: use properties for clip/cull distance writemasks", the tgsi_shader_info::num_written_culldistance field was a multiple of four, now it's an accurate count. In the svga driver, we need a minor change to the loop test. --- src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c index d62f2bb..332904f 100644 --- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c +++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c @@ -3097,7 +3097,7 @@ emit_clip_distance_instructions(struct svga_shader_emitter_v10 *emit) unsigned i; unsigned clip_plane_enable = emit->key.clip_plane_enable; unsigned clip_dist_tmp_index = emit->clip_dist_tmp_index; - unsigned num_written_clipdist = emit->info.num_written_clipdistance; + int num_written_clipdist = emit->info.num_written_clipdistance; assert(emit->clip_dist_out_index != INVALID_INDEX); assert(emit->clip_dist_tmp_index != INVALID_INDEX); @@ -3109,7 +3109,7 @@ emit_clip_distance_instructions(struct svga_shader_emitter_v10 *emit) */ emit->clip_dist_tmp_index = INVALID_INDEX; - for (i = 0; i < 2 && num_written_clipdist; i++, num_written_clipdist-=4) { + for (i = 0; i < 2 && num_written_clipdist > 0; i++, num_written_clipdist-=4) { tmp_clip_dist_src = make_src_temp_reg(clip_dist_tmp_index + i); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] svga: use new enum indices_mode type
Reviewed-by: Charmaine Lee From: mesa-dev on behalf of Brian Paul Sent: Saturday, October 31, 2015 6:46 AM To: mesa-dev@lists.freedesktop.org Subject: [Mesa-dev] [PATCH 2/2] svga: use new enum indices_mode type --- src/gallium/drivers/svga/svga_draw_arrays.c | 3 ++- src/gallium/drivers/svga/svga_draw_elements.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c index caf4b17..acb2e95 100644 --- a/src/gallium/drivers/svga/svga_draw_arrays.c +++ b/src/gallium/drivers/svga/svga_draw_arrays.c @@ -204,7 +204,8 @@ svga_hwtnl_draw_arrays(struct svga_hwtnl *hwtnl, unsigned prim, unsigned start, unsigned count, unsigned start_instance, unsigned instance_count) { - unsigned gen_prim, gen_size, gen_nr, gen_type; + unsigned gen_prim, gen_size, gen_nr; + enum indices_mode gen_type; u_generate_func gen_func; enum pipe_error ret = PIPE_OK; unsigned api_pv = hwtnl->api_pv; diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index 9df8f6e..0213409 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -133,7 +133,8 @@ svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl, unsigned prim, unsigned start, unsigned count, unsigned start_instance, unsigned instance_count) { - unsigned gen_prim, gen_size, gen_nr, gen_type; + unsigned gen_prim, gen_size, gen_nr; + enum indices_mode gen_type; u_translate_func gen_func; enum pipe_error ret = PIPE_OK; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] vbo: fix another GL_LINE_LOOP bug
I concur with Sinclair and Roland that the vbo code is quite tricky. I do have a question, so when the line loop spans multiple vertex buffers, where is 0th vertex stored exactly? In vbo_exec_End, you are changing src = exec->vtx.buffer_map + last_prim->start * exec->vtx.vertex_size; If the 0th vertex is always copied to the beginning of the buffer, why do you need this change? If it was not copied to the beginning of the buffer, couldn't it be overwritten by the subsequent vertices? -Charmaine From: mesa-dev on behalf of Brian Paul Sent: Saturday, October 31, 2015 6:38 AM To: mesa-dev@lists.freedesktop.org Subject: [Mesa-dev] [PATCH] vbo: fix another GL_LINE_LOOP bug Very long line loops which spanned 3 or more vertex buffers were not handled correctly and could result in stray lines. The piglit lineloop test draws 1 vertices by default, and is not long enough to trigger this. Even 'lineloop -count 10' doesn't trigger the bug. For future reference, the issue can be reproduced by changing Mesa's VBO_VERT_BUFFER_SIZE to 4096 and changing the piglit lineloop test to use glVertex2f(), draw 3 loops instead of 1, and specifying -count 1023. --- src/mesa/vbo/vbo_exec_api.c | 11 +-- src/mesa/vbo/vbo_exec_draw.c | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index a614b26..7534599 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -114,6 +114,7 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) if (_mesa_inside_begin_end(exec->ctx)) { exec->vtx.prim[0].mode = exec->ctx->Driver.CurrentExecPrimitive; exec->vtx.prim[0].begin = 0; + exec->vtx.prim[0].end = 0; exec->vtx.prim[0].start = 0; exec->vtx.prim[0].count = 0; exec->vtx.prim_count++; @@ -846,17 +847,23 @@ static void GLAPIENTRY vbo_exec_End( void ) /* We're finishing drawing a line loop. Append 0th vertex onto * end of vertex buffer so we can draw it as a line strip. */ - const fi_type *src = exec->vtx.buffer_map; + const fi_type *src = exec->vtx.buffer_map + +last_prim->start * exec->vtx.vertex_size; fi_type *dst = exec->vtx.buffer_map + exec->vtx.vert_count * exec->vtx.vertex_size; /* copy 0th vertex to end of buffer */ memcpy(dst, src, exec->vtx.vertex_size * sizeof(fi_type)); - assert(last_prim->start == 0); last_prim->start++; /* skip vertex0 */ /* note that last_prim->count stays unchanged */ last_prim->mode = GL_LINE_STRIP; + + /* Increment the vertex count so the next primitive doesn't + * overwrite the last vertex which we just added. + */ + exec->vtx.vert_count++; + exec->vtx.buffer_ptr += exec->vtx.vertex_size; } try_vbo_merge(exec); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index ed5d9e9..0d42618 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -117,6 +117,7 @@ vbo_copy_vertices( struct vbo_exec_context *exec ) * subtract one from last_prim->start) so that we copy the 0th vertex * to the next vertex buffer. */ + assert(last_prim->start > 0); src -= sz; } /* fall-through */ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] vbo: fix another GL_LINE_LOOP bug
> >From: Brian Paul >Sent: Wednesday, November 4, 2015 12:03 PM >To: Charmaine Lee; mesa-dev@lists.freedesktop.org >Subject: Re: [Mesa-dev] [PATCH] vbo: fix another GL_LINE_LOOP bug >On 11/04/2015 12:40 PM, Charmaine Lee wrote: >> >> I concur with Sinclair and Roland that the vbo code is quite tricky. >> I do have a question, so when the line loop spans multiple vertex buffers, >> where is 0th vertex stored exactly? >It depends. If the line loop started in a new/empty VB, the 0th vertex >is at the start of the buffer. But if the line loop started later in >the buffer (because another primitive before it), the 0th vertex will be >at the prim->start position. >I didn't find the bug that this patch fixes earlier, because my test >programs all hit the first case. We have to draw at least two >primitives to hit some of the corner cases. >> In vbo_exec_End, you are changing src = exec->vtx.buffer_map + >> last_prim->start * exec->vtx.vertex_size; >> If the 0th vertex is always copied to the beginning of the buffer, why do >> you need this change? >To account for the second case, above. >> If it was not copied to the beginning of the buffer, couldn't it be >> overwritten by the subsequent vertices? >This patch actually fixes a case where subsequent vertices _were_ >overwriting previous vertices when another primitive followed the line >loop. That's the change at line 846. So if last_prim->start is 100, and if the line loop spans 3 vertex buffers, so at the second vbo_exec_wrap_buffers(), can't the original vertex 0 which is at buffer_map + 100 * vertex_size be already overwritten by the vertices that are now in the second vertex buffer? -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 00/11] Gallium common uploaders (v2)
Series tested with vmware svga driver. Changes looks good. Tested-by: Charmaine Lee From: mesa-dev on behalf of Marek Olšák Sent: Wednesday, February 8, 2017 4:11:01 PM To: mesa-dev@lists.freedesktop.org Subject: [Mesa-dev] [PATCH 00/11] Gallium common uploaders (v2) Hi, Since the last version, I added pipe_context::const_uploader and documentation. Changed patches: 1, 3, 9. New patch: 11. Please review. Thanks, Marek ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ang1qmMo4GwCmRUnLE-f31kqPa6AOnoS-OAMUzQyM0M&m=XSJrU78OKHut9MP5JzTo6E_q9zUryi8toIq7t-vPBMs&s=QXqaX6b025NySDn7FRrLOOs6w2aXs4qV_Yb47UZSODg&e= ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] st/wgl: flush with ST_FLUSH_WAIT before releasing shared contexts
Before releasing a shared context, flush the context with ST_FLUSH_WAIT to make sure all commands are executed. This ensures that rendering to any shared resources is completed before they will be referenced by another context. Fixes an intermittent flickering with Photoshop. (VMware bug# 1779340) --- src/gallium/state_trackers/wgl/stw_context.c | 16 ++-- src/gallium/state_trackers/wgl/stw_context.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index b1e5f5e..85cffa6 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -104,8 +104,11 @@ DrvShareLists(DHGLRC dhglrc1, DHGLRC dhglrc2) ctx1 = stw_lookup_context_locked( dhglrc1 ); ctx2 = stw_lookup_context_locked( dhglrc2 ); - if (ctx1 && ctx2 && ctx2->st->share) + if (ctx1 && ctx2 && ctx2->st->share) { ret = ctx2->st->share(ctx2->st, ctx1->st); + ctx1->shared = TRUE; + ctx2->shared = TRUE; + } stw_unlock_contexts(stw_dev); @@ -175,6 +178,7 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext, if (hShareContext != 0) { stw_lock_contexts(stw_dev); shareCtx = stw_lookup_context_locked( hShareContext ); + shareCtx->shared = TRUE; stw_unlock_contexts(stw_dev); } @@ -184,6 +188,7 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext, ctx->hdc = hdc; ctx->iPixelFormat = iPixelFormat; + ctx->shared = shareCtx != NULL; memset(&attribs, 0, sizeof(attribs)); attribs.visual = pfi->stvis; @@ -403,7 +408,14 @@ stw_make_current(HDC hdc, DHGLRC dhglrc) return TRUE; } } else { - old_ctx->st->flush(old_ctx->st, ST_FLUSH_FRONT, NULL); + if (old_ctx->shared) { +struct pipe_fence_handle *fence = NULL; +old_ctx->st->flush(old_ctx->st, + ST_FLUSH_FRONT | ST_FLUSH_WAIT, &fence); + } + else { +old_ctx->st->flush(old_ctx->st, ST_FLUSH_FRONT, NULL); + } } } diff --git a/src/gallium/state_trackers/wgl/stw_context.h b/src/gallium/state_trackers/wgl/stw_context.h index 6bfa715..0f180c8 100644 --- a/src/gallium/state_trackers/wgl/stw_context.h +++ b/src/gallium/state_trackers/wgl/stw_context.h @@ -40,6 +40,7 @@ struct stw_context DHGLRC dhglrc; int iPixelFormat; HDC hdc; + BOOL shared; struct stw_framebuffer *current_framebuffer; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] st: add ST_FLUSH_WAIT to st_context_flush()
When st_context_flush() is called with ST_FLUSH_WAIT, the function will return after the fence is completed. --- src/gallium/include/state_tracker/st_api.h | 1 + src/mesa/state_tracker/st_manager.c| 7 +++ 2 files changed, 8 insertions(+) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index daa1f23..a999774 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -160,6 +160,7 @@ enum st_context_resource_type { */ #define ST_FLUSH_FRONT(1 << 0) #define ST_FLUSH_END_OF_FRAME (1 << 1) +#define ST_FLUSH_WAIT (1 << 2) /** * Value to st_manager->get_param function. diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index c3d8286..e663b01 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -504,6 +504,13 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags, } st_flush(st, fence, pipe_flags); + + if ((flags & ST_FLUSH_WAIT) && fence) { + st->pipe->screen->fence_finish(st->pipe->screen, NULL, *fence, + PIPE_TIMEOUT_INFINITE); + st->pipe->screen->fence_reference(st->pipe->screen, fence, NULL); + } + if (flags & ST_FLUSH_FRONT) st_manager_flush_frontbuffer(st); } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa: check for no matrix change in _mesa_LoadMatrixf()
Looks good. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, September 15, 2016 8:34 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] mesa: check for no matrix change in _mesa_LoadMatrixf() Some apps issue redundant glLoadMatrixf() calls with the same matrix. Try to avoid setting dirty state in that situation. This reduces the number of constant buffer updates by about half in ET Quake Wars. Tested with Piglit, ETQW, Sauerbraten, Google Earth, etc. --- src/mesa/main/matrix.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index b30b983..83f081e 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -356,9 +356,11 @@ _mesa_LoadMatrixf( const GLfloat *m ) m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]); - FLUSH_VERTICES(ctx, 0); - _math_matrix_loadf( ctx->CurrentStack->Top, m ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; + if (memcmp(m, ctx->CurrentStack->Top->m, 16 * sizeof(GLfloat)) != 0) { + FLUSH_VERTICES(ctx, 0); + _math_matrix_loadf( ctx->CurrentStack->Top, m ); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; + } } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] svga: minor simplification in svga_validate_surface_view()
For the series, Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, September 21, 2016 8:25 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 2/2] svga: minor simplification in svga_validate_surface_view() Get rid of unneeded local var. --- src/gallium/drivers/svga/svga_surface.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index 42636bc..7cc7ef1 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -405,9 +405,9 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s) { enum pipe_error ret = PIPE_OK; enum pipe_shader_type shader; - struct pipe_surface *surf = NULL; assert(svga_have_vgpu10(svga)); + assert(s); SVGA_STATS_TIME_PUSH(svga_sws(svga), SVGA_STATS_TIME_VALIDATESURFACEVIEW); @@ -481,12 +481,11 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s) goto done; } } - surf = &s->base; done: SVGA_STATS_TIME_POP(svga_sws(svga)); - return surf; + return &s->base; } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/8] svga: eliminate unneeded gotos in svga_validate_surface_view()
>From: Brian Paul >Sent: Friday, September 23, 2016 8:48 AM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee >Subject: [PATCH 1/8] svga: eliminate unneeded gotos in >svga_validate_surface_view() >--- > src/gallium/drivers/svga/svga_surface.c | 9 +++-- > 1 file changed, 3 insertions(+), 6 deletions(-) >diff --git a/src/gallium/drivers/svga/svga_surface.c >b/src/gallium/drivers/svga/svga_surface.c >index 7cc7ef1..91bd4ca 100644 >--- a/src/gallium/drivers/svga/svga_surface.c >+++ b/src/gallium/drivers/svga/svga_surface.c >@@ -426,14 +426,12 @@ svga_validate_surface_view(struct svga_context *svga, >struct >svga_surface *s) > "same resource used in shaderResource and renderTarget > 0x%x\n", > s->handle); > s = create_backed_surface_view(svga, s); >- if (!s) >-goto done; >- >+ /* s may be null here if the function failed */ > break; > } >} >- if (s->view_id == SVGA3D_INVALID_ID) { >+ if (s && s->view_id == SVGA3D_INVALID_ID) { > SVGA3dResourceType resType; > SVGA3dRenderTargetViewDesc desc; >@@ -478,11 +476,10 @@ svga_validate_surface_view(struct svga_context *svga, >struct >svga_surface *s) > if (ret != PIPE_OK) { > util_bitmask_clear(svga->surface_view_id_bm, s->view_id); > s->view_id = SVGA3D_INVALID_ID; >- goto done; >+ s = NULL; > } >} >-done: >SVGA_STATS_TIME_POP(svga_sws(svga)); >return &s->base; We want to return NULL when we fail to create RenderTargetView. -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/8] svga: eliminate unneeded gotos in svga_validate_surface_view()
>From: Brian Paul >Sent: Friday, September 23, 2016 8:48 AM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee >Subject: [PATCH 1/8] svga: eliminate unneeded gotos in >svga_validate_surface_view() >--- > src/gallium/drivers/svga/svga_surface.c | 9 +++-- > 1 file changed, 3 insertions(+), 6 deletions(-) >diff --git a/src/gallium/drivers/svga/svga_surface.c >b/src/gallium/drivers/svga/svga_surface.c >index 7cc7ef1..91bd4ca 100644 >--- a/src/gallium/drivers/svga/svga_surface.c >+++ b/src/gallium/drivers/svga/svga_surface.c >@@ -426,14 +426,12 @@ svga_validate_surface_view(struct svga_context *svga, >struct >svga_surface *s) > "same resource used in shaderResource and renderTarget > 0x%x\n", > s->handle); > s = create_backed_surface_view(svga, s); >- if (!s) >-goto done; >- >+ /* s may be null here if the function failed */ > break; > } >} >- if (s->view_id == SVGA3D_INVALID_ID) { >+ if (s && s->view_id == SVGA3D_INVALID_ID) { > SVGA3dResourceType resType; > SVGA3dRenderTargetViewDesc desc; >@@ -478,11 +476,10 @@ svga_validate_surface_view(struct svga_context *svga, >struct >svga_surface *s) > if (ret != PIPE_OK) { > util_bitmask_clear(svga->surface_view_id_bm, s->view_id); > s->view_id = SVGA3D_INVALID_ID; >- goto done; >+ s = NULL; > } >} >-done: >SVGA_STATS_TIME_POP(svga_sws(svga)); >return &s->base; We want to return NULL when we fail to create RenderTargetView. -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 8/8] st/mesa: small optimization in swizzle_swizzle()
Series looks good to me. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, September 23, 2016 8:48 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 8/8] st/mesa: small optimization in swizzle_swizzle() Usually, there's no user-specified texture swizzle so we can optimize the swizzle_swizzle() function and skip the loop/switch. --- src/mesa/state_tracker/st_atom_texture.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index a613533..19df662 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -59,6 +59,11 @@ swizzle_swizzle(unsigned swizzle1, unsigned swizzle2) { unsigned i, swz[4]; + if (swizzle1 == SWIZZLE_XYZW) { + /* identity swizzle, no change to swizzle2 */ + return swizzle2; + } + for (i = 0; i < 4; i++) { unsigned s = GET_SWZ(swizzle1, i); switch (s) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: remove incorrect buffer invalidation code
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Monday, August 15, 2016 3:43:22 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: remove incorrect buffer invalidation code Fixes regression with team_fortress_2 trace. This change has been in our in-house tree for some time. --- src/gallium/drivers/svga/svga_screen_cache.c | 5 - 1 file changed, 5 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_cache.c b/src/gallium/drivers/svga/svga_screen_cache.c index bce46df..86a0413 100644 --- a/src/gallium/drivers/svga/svga_screen_cache.c +++ b/src/gallium/drivers/svga/svga_screen_cache.c @@ -558,11 +558,6 @@ svga_screen_surface_destroy(struct svga_screen *svgascreen, * that case. */ if (SVGA_SURFACE_CACHE_ENABLED && key->cachable) { - - /* Invalidate the surface before putting it into the recycle pool */ - if (key->format != SVGA3D_BUFFER) - sws->surface_invalidate(sws, *p_handle); - svga_screen_cache_add(svgascreen, key, p_handle); } else { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] svga: fix src/dst typo in can_blit_via_copy_region_vgpu10()
Series looks good to me. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, August 17, 2016 7:40:13 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH 2/2] svga: fix src/dst typo in can_blit_via_copy_region_vgpu10() The function was always returning false because of this typo. Retested with piglit. There's some sRGB-related blit failures, but that seems unrelated. --- src/gallium/drivers/svga/svga_pipe_blit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/svga/svga_pipe_blit.c b/src/gallium/drivers/svga/svga_pipe_blit.c index 1f6382e..9d8c4fe 100644 --- a/src/gallium/drivers/svga/svga_pipe_blit.c +++ b/src/gallium/drivers/svga/svga_pipe_blit.c @@ -223,7 +223,7 @@ can_blit_via_copy_region_vgpu10(struct svga_context *svga, return false; stex = svga_texture(blit_info->src.resource); - dtex = svga_texture(blit_info->src.resource); + dtex = svga_texture(blit_info->dst.resource); // can't copy within one resource if (stex->handle == dtex->handle) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: s/unsigned/enum pipe_shader_type/
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Monday, August 29, 2016 9:16:09 AM To: mesa-dev@lists.freedesktop.org Cc: Neha Bhende; Charmaine Lee Subject: [PATCH] svga: s/unsigned/enum pipe_shader_type/ --- src/gallium/drivers/svga/svga_draw.c| 4 ++-- src/gallium/drivers/svga/svga_pipe_sampler.c| 2 +- src/gallium/drivers/svga/svga_sampler_view.h| 2 +- src/gallium/drivers/svga/svga_shader.c | 3 ++- src/gallium/drivers/svga/svga_shader.h | 5 +++-- src/gallium/drivers/svga/svga_state_constants.c | 12 ++-- src/gallium/drivers/svga/svga_state_fs.c| 2 +- src/gallium/drivers/svga/svga_state_sampler.c | 6 +++--- src/gallium/drivers/svga/svga_state_tss.c | 6 +++--- src/gallium/drivers/svga/svga_state_vs.c| 2 +- src/gallium/drivers/svga/svga_surface.c | 2 +- 11 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c index 9e0dfe5..f8d3ae5 100644 --- a/src/gallium/drivers/svga/svga_draw.c +++ b/src/gallium/drivers/svga/svga_draw.c @@ -311,7 +311,7 @@ xlate_index_format(unsigned indexWidth) static enum pipe_error validate_sampler_resources(struct svga_context *svga) { - unsigned shader; + enum pipe_shader_type shader; assert(svga_have_vgpu10(svga)); @@ -376,7 +376,7 @@ validate_sampler_resources(struct svga_context *svga) static enum pipe_error validate_constant_buffers(struct svga_context *svga) { - unsigned shader; + enum pipe_shader_type shader; assert(svga_have_vgpu10(svga)); diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index 4a2b3c3..5d7af70 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -529,7 +529,7 @@ done: void svga_cleanup_sampler_state(struct svga_context *svga) { - unsigned shader; + enum pipe_shader_type shader; if (!svga_have_vgpu10(svga)) return; diff --git a/src/gallium/drivers/svga/svga_sampler_view.h b/src/gallium/drivers/svga/svga_sampler_view.h index b36f089..7521a82 100644 --- a/src/gallium/drivers/svga/svga_sampler_view.h +++ b/src/gallium/drivers/svga/svga_sampler_view.h @@ -102,7 +102,7 @@ svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_ boolean svga_check_sampler_view_resource_collision(struct svga_context *svga, struct svga_winsys_surface *res, - unsigned shader); + enum pipe_shader_type shader); boolean svga_check_sampler_framebuffer_resource_collision(struct svga_context *svga, diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c index 9ba6055..55f7922 100644 --- a/src/gallium/drivers/svga/svga_shader.c +++ b/src/gallium/drivers/svga/svga_shader.c @@ -166,7 +166,8 @@ svga_remap_generic_index(int8_t remap_table[MAX_GENERIC_VARYING], * state. This is basically the texture-related state. */ void -svga_init_shader_key_common(const struct svga_context *svga, unsigned shader, +svga_init_shader_key_common(const struct svga_context *svga, +enum pipe_shader_type shader, struct svga_compile_key *key) { unsigned i, idx = 0; diff --git a/src/gallium/drivers/svga/svga_shader.h b/src/gallium/drivers/svga/svga_shader.h index b53a4bf..ec116c0 100644 --- a/src/gallium/drivers/svga/svga_shader.h +++ b/src/gallium/drivers/svga/svga_shader.h @@ -253,7 +253,8 @@ svga_remap_generic_index(int8_t remap_table[MAX_GENERIC_VARYING], int generic_index); void -svga_init_shader_key_common(const struct svga_context *svga, unsigned shader, +svga_init_shader_key_common(const struct svga_context *svga, +enum pipe_shader_type shader, struct svga_compile_key *key); struct svga_shader_variant * @@ -310,7 +311,7 @@ svga_shader_too_large(const struct svga_context *svga, * Convert from PIPE_SHADER_* to SVGA3D_SHADERTYPE_* */ static inline SVGA3dShaderType -svga_shader_type(unsigned shader) +svga_shader_type(enum pipe_shader_type shader) { switch (shader) { case PIPE_SHADER_VERTEX: diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index 8784f47..dc80edf 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -65,7 +65,7 @@ static unsigned svga_get_extra_constants_common(struct svga_context *svga, const struct svga_shader_variant *variant, -unsigned shader, float *dest) +enum pipe_shader_type shader, float *dest) { uint32_t *dest_u
Re: [Mesa-dev] [PATCH] svga: minor code improvements in svga_validate_pipe_sampler_view()
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Tuesday, October 18, 2016 9:36 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: minor code improvements in svga_validate_pipe_sampler_view() Use the 'texture' local var in more places. Rename 'pFormat' to 'viewFormat'. --- src/gallium/drivers/svga/svga_state_sampler.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/svga/svga_state_sampler.c b/src/gallium/drivers/svga/svga_state_sampler.c index 53bb80f..445afcc 100644 --- a/src/gallium/drivers/svga/svga_state_sampler.c +++ b/src/gallium/drivers/svga/svga_state_sampler.c @@ -135,21 +135,21 @@ svga_validate_pipe_sampler_view(struct svga_context *svga, SVGA3dSurfaceFormat format; SVGA3dResourceType resourceDim; SVGA3dShaderResourceViewDesc viewDesc; - enum pipe_format pformat = sv->base.format; + enum pipe_format viewFormat = sv->base.format; /* vgpu10 cannot create a BGRX view for a BGRA resource, so force it to * create a BGRA view (and vice versa). */ - if (pformat == PIPE_FORMAT_B8G8R8X8_UNORM && - sv->base.texture->format == PIPE_FORMAT_B8G8R8A8_UNORM) { - pformat = PIPE_FORMAT_B8G8R8A8_UNORM; + if (viewFormat == PIPE_FORMAT_B8G8R8X8_UNORM && + texture->format == PIPE_FORMAT_B8G8R8A8_UNORM) { + viewFormat = PIPE_FORMAT_B8G8R8A8_UNORM; } - else if (pformat == PIPE_FORMAT_B8G8R8A8_UNORM && - sv->base.texture->format == PIPE_FORMAT_B8G8R8X8_UNORM) { - pformat = PIPE_FORMAT_B8G8R8X8_UNORM; + else if (viewFormat == PIPE_FORMAT_B8G8R8A8_UNORM && + texture->format == PIPE_FORMAT_B8G8R8X8_UNORM) { + viewFormat = PIPE_FORMAT_B8G8R8X8_UNORM; } - format = svga_translate_format(ss, pformat, + format = svga_translate_format(ss, viewFormat, PIPE_BIND_SAMPLER_VIEW); assert(format != SVGA3D_FORMAT_INVALID); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/6] vbo: clean up with 'indent', whitespace fixes, etc in vbo_exec_array.c
Series looks fine to me. Some minor nit below. Reviewed-by: Charmaine Lee >From: Brian Paul >Sent: Wednesday, October 19, 2016 3:07 PM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee >Subject: [PATCH 6/6] vbo: clean up with 'indent', whitespace fixes, etc in >vbo_exec_array.c >--- > src/mesa/vbo/vbo_exec_array.c | 537 ++ > 1 file changed, 281 insertions(+), 256 deletions(-) >diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c >@@ -687,12 +688,13 @@ vbo_exec_DrawArraysInstancedBaseInstance(GLenum mode, >GLint first, GLsizei count > static void > dump_element_buffer(struct gl_context *ctx, GLenum type) > { >- const GLvoid *map = >- ctx->Driver.MapBufferRange(ctx, 0, >-ctx->Array.VAO->IndexBufferObj->Size, >-GL_MAP_READ_BIT, >- ctx->Array.VAO->IndexBufferObj, >- MAP_INTERNAL); >+ const GLvoid *map = ctx->Driver.MapBufferRange(ctx, 0, >+ ctx->Array.VAO-> >+ IndexBufferObj->Size, I prefer not to break up this line. It makes it less readable. >+ GL_MAP_READ_BIT, >+ ctx->Array.VAO-> >+ IndexBufferObj, Same here. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] gallium/hud: call fflush() after printing error messages
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, November 2, 2016 3:08 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] gallium/hud: call fflush() after printing error messages For Windows. Otherwise, we don't see the message until the program exits. --- src/gallium/auxiliary/hud/hud_context.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 3772f3c..ceb157a 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -875,9 +875,12 @@ parse_string(const char *s, char *out) *out = 0; - if (*s && !i) + if (*s && !i) { fprintf(stderr, "gallium_hud: syntax error: unexpected '%c' (%i) while " "parsing a string\n", *s, *s); + fflush(stderr); + } + return i; } @@ -937,6 +940,7 @@ read_pane_settings(char *str, unsigned * const x, unsigned * const y, default: fprintf(stderr, "gallium_hud: syntax error: unexpected '%c'\n", *str); + fflush(stderr); } } @@ -1139,6 +1143,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) if (!hud_driver_query_install(&hud->batch_query, pane, hud->pipe, name)) { fprintf(stderr, "gallium_hud: unknown driver query '%s'\n", name); + fflush(stderr); } } } @@ -1149,6 +1154,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) if (!pane) { fprintf(stderr, "gallium_hud: syntax error: unexpected ':', " "expected a name\n"); +fflush(stderr); break; } @@ -1162,6 +1168,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) else { fprintf(stderr, "gallium_hud: syntax error: unexpected '%c' (%i) " "after ':'\n", *env, *env); +fflush(stderr); } } @@ -1205,6 +1212,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) default: fprintf(stderr, "gallium_hud: syntax error: unexpected '%c'\n", *env); + fflush(stderr); } /* Reset to defaults for the next pane in case these were modified. */ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] util: fix missing swizzle components in the SINT <-> UINT conversion string
Fixes tgsi error introduced in commit 3817a7a. The error complains missing swizzle component in the conversion string "UMIN TEMP[0], TEMP[0], IMM[0].x". --- src/gallium/auxiliary/util/u_simple_shaders.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index 8be31be..7342b3d 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -633,14 +633,14 @@ util_make_fs_blit_msaa_color(struct pipe_context *pipe, if (dtype == TGSI_RETURN_TYPE_SINT) { conversion_decl = "IMM[0] UINT32 {2147483647, 0, 0, 0}\n"; - conversion = "UMIN TEMP[0], TEMP[0], IMM[0].x\n"; + conversion = "UMIN TEMP[0], TEMP[0], IMM[0].\n"; } } else if (stype == TGSI_RETURN_TYPE_SINT) { samp_type = "SINT"; if (dtype == TGSI_RETURN_TYPE_UINT) { conversion_decl = "IMM[0] INT32 {0, 0, 0, 0}\n"; - conversion = "IMAX TEMP[0], TEMP[0], IMM[0].x\n"; + conversion = "IMAX TEMP[0], TEMP[0], IMM[0].\n"; } } else { assert(dtype == TGSI_RETURN_TYPE_FLOAT); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] util: fix memory leak from the fragment shaders for SINT <-> UINT blits
This patch deletes those fragment shaders in util_blitter_destroy(). --- src/gallium/auxiliary/util/u_blitter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 98b5421..45dc033 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -453,7 +453,7 @@ void util_blitter_destroy(struct blitter_context *blitter) } for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) { - for (unsigned type = 0; type < 3; ++type) { + for (unsigned type = 0; type < ARRAY_SIZE(ctx->fs_texfetch_col); ++type) { if (ctx->fs_texfetch_col[type][i]) ctx->delete_fs_state(pipe, ctx->fs_texfetch_col[type][i]); if (ctx->fs_texfetch_col_msaa[type][i]) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 2/3] svga: Fix a strict-aliasing violation in shader dumper
Change looks fine to me. Thanks. Reviewed-by: Charmaine Lee From: Roland Scheidegger Sent: Tuesday, December 13, 2016 10:38 AM To: Edward O'Callaghan; mesa-dev@lists.freedesktop.org Cc: Brian Paul; Charmaine Lee Subject: Re: [Mesa-dev] [PATCH v3 2/3] svga: Fix a strict-aliasing violation in shader dumper adding CC: Charmaine Am 12.12.2016 um 06:23 schrieb Edward O'Callaghan: > Brian/Roland ping? > > On 12/07/2016 10:30 AM, Edward O'Callaghan wrote: >> As per the C spec, it is illegal to alias pointers to different >> types. This results in undefined behaviour after optimization >> passes, resulting in very subtle bugs that happen only on a >> full moon.. >> >> Use a memcpy() as a well defined coercion between the isomorphic >> bit-field interpretations of memory. >> >> V.2: Use C99 compat STATIC_ASSERT() over C11 static_assert(). >> >> Signed-off-by: Edward O'Callaghan >> --- >> src/gallium/drivers/svga/svgadump/svga_shader_dump.c | 10 +- >> 1 file changed, 9 insertions(+), 1 deletion(-) >> >> diff --git a/src/gallium/drivers/svga/svgadump/svga_shader_dump.c >> b/src/gallium/drivers/svga/svgadump/svga_shader_dump.c >> index 4ee1bf2..46126a5 100644 >> --- a/src/gallium/drivers/svga/svgadump/svga_shader_dump.c >> +++ b/src/gallium/drivers/svga/svgadump/svga_shader_dump.c >> @@ -30,6 +30,9 @@ >> * @author Michal Krol >> */ >> >> +#include >> +#include >> + >> #include "svga_shader.h" >> #include "svga_shader_dump.h" >> #include "svga_shader_op.h" >> @@ -413,6 +416,11 @@ dump_dstreg(struct sh_dstreg dstreg, >> >> static void dump_srcreg( struct sh_srcreg srcreg, struct sh_srcreg *indreg, >> const struct dump_info *di ) >> { >> + struct sh_reg srcreg_sh = {0}; >> + /* bit-fields carefully aligned, ensure they stay that way. */ >> + STATIC_ASSERT(sizeof(struct sh_reg) == sizeof(struct sh_srcreg)); >> + memcpy(&srcreg_sh, &srcreg, sizeof(srcreg_sh)); >> + >> switch (srcreg.modifier) { >> case SVGA3DSRCMOD_NEG: >> case SVGA3DSRCMOD_BIASNEG: >> @@ -427,7 +435,7 @@ static void dump_srcreg( struct sh_srcreg srcreg, struct >> sh_srcreg *indreg, cons >> case SVGA3DSRCMOD_NOT: >>_debug_printf( "!" ); >> } >> - dump_reg( *(struct sh_reg *) &srcreg, indreg, di ); >> + dump_reg(srcreg_sh, indreg, di ); >> switch (srcreg.modifier) { >> case SVGA3DSRCMOD_NONE: >> case SVGA3DSRCMOD_NEG: >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Mesa commit a5e733c
>From: Rob Clark >On Wed, Dec 21, 2016 at 12:32 PM, Charmaine Lee wrote: >> >> Hi Rob, >> >> Your mesa commit a5e733c mesa: drop current draw/read buffer when ctx is >> released >> is causing rendering issue when running with vmware svga driver. >> >> The problem is when the winsys draw/read buffers are unreferenced, the whole >> object >> including the underlying resource can be prematurely destroyed. When the >> buffers are bound >> to a context again, the whole object hierarchy is recreated but we already >> lost the previous >> content, hence causing rendering corruption. >It's possible perhaps that something else needs to be holding a >reference to the corresponding EGL level object? IIRC the EGL level >object was freed but not mesa/st level object, leading to new EGL >surface being allocated w/ same ptr address and confusing mesa/st. >Which *definitely* seems wrong. Dangling object is dangerous. >> I believe the winsys draw/read buffers are purposely there to be not >> unreferenced at >> context unbind time. There are timestamps in st_framebuffer and >> st_framebuffer_iface >> to keep track of when the frame buffer needs to be re-validated. Could it be >> somehow those stamps are out-of-sync in your case? Is there a better fix >> to your original problem? >*Maybe* but I don't totally understand how the timestamp thing is >expected to work. But it is already a couple months ago that I was >debugging it and I won't really have the android setup again for a >while. >But somehow we either need to hold reference to the EGL surface while >we have a ptr to it or drop the reference so we don't have a stale ptr >that we can be confused by after a new EGL surface is created. It will be ideal if st_framebuffer_iface object can hold a ptr to the associated st_framebuffer object. So when an EGL surface is destroyed, it can follow the chain to free the st objects as well. But since st_framebuffer object is context specific, there can be multiple st_framebuffer objects for an st_framebuffer_iface object, so currently the mapping of st_framebuffer to st_framebuffer_iface is kept in the st_framebuffer object, causing it difficult to drop the reference when st_framebuffer_iface for the EGL surface is deleted. We can probably move the mapping to st_manager itself which already knows the st_framebuffer_iface objects bound to a context, so when a st_framebuffer_iface for an EGL surface is destroyed, we can notify the st_manager to unreference the st_framebuffer_iface object from any of the st_framebuffer_iface to context mapping. -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 11/16] svga: use copy_region_vgpu10() for region copies when possible
>From: Brian Paul >Sent: Tuesday, June 28, 2016 4:52 PM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee; Neha Bhende; Jose Fonseca; Roland Scheidegger >Subject: [PATCH 11/16] svga: use copy_region_vgpu10() for region copies when >possible > >--- > src/gallium/drivers/svga/svga_pipe_blit.c | 42 --- > 1 file changed, 38 insertions(+), 4 deletions(-) >diff --git a/src/gallium/drivers/svga/svga_pipe_blit.c >b/src/gallium/drivers/svga/svga_pipe_blit.c >index 564af51..ad54dc5 100644 >--- a/src/gallium/drivers/svga/svga_pipe_blit.c >+++ b/src/gallium/drivers/svga/svga_pipe_blit.c >@@ -138,7 +138,6 @@ svga_resource_copy_region(struct pipe_context *pipe, > src_z = src_box->z; >} > >- /* different src/dst type???*/ >if (dst_tex->target == PIPE_TEXTURE_CUBE || >dst_tex->target == PIPE_TEXTURE_1D_ARRAY) { > dst_face_layer = dstz; >@@ -150,14 +149,49 @@ svga_resource_copy_region(struct pipe_context *pipe, > dst_z = dstz; >} > >- svga_texture_copy_handle(svga, >-stex->handle, >+ stex = svga_texture(src_tex); >+ dtex = svga_texture(dst_tex); >+ >+ if (svga_have_vgpu10(svga)) { >+ /* vgpu10 */ >+ if (util_format_is_compressed(src_tex->format) == >+ util_format_is_compressed(dst_tex->format) && >+ !util_format_is_depth_and_stencil(src_tex->format) && >+ stex->handle != dtex->handle && >+ src_tex->target == dst_tex->target) { >+ copy_region_vgpu10(svga, >+src_tex, > src_box->x, src_box->y, src_z, > src_level, src_face_layer, >-dtex->handle, >+dst_tex, > dstx, dsty, dst_z, > dst_level, dst_face_layer, > src_box->width, src_box->height, src_box->depth); >+ } >+ else { >+ util_resource_copy_region(pipe, dst_tex, dst_level, dstx, dsty, dstz, >+ src_tex, src_level, src_box); >+ } >+ } >+ else { >+ /* vgpu9 */ >+ if (src_tex->format == dst_tex->format) { >+ svga_texture_copy_handle(svga, >+ stex->handle, >+ src_box->x, src_box->y, src_z, >+ src_level, src_face_layer, >+ dtex->handle, >+ dstx, dsty, dst_z, >+ dst_level, dst_face_layer, >+ src_box->width, src_box->height, >+ src_box->depth); >+ svga_define_texture_level(dtex, dst_face_layer, dst_level); No need to call svga_define_texture_level() here since it is called at the end of the function. >+ } >+ else { >+ util_resource_copy_region(pipe, dst_tex, dst_level, dstx, dsty, dstz, >+ src_tex, src_level, src_box); >+ } >+ } > >/* Mark the destination image as being defined */ >svga_define_texture_level(dtex, dst_face_layer, dst_level); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] st/mesa: fix geometry shader memory leak
Changes looks good. Tested with svga driver. Reviewed-by: Charmaine Lee From: mesa-dev on behalf of Brian Paul Sent: Tuesday, July 8, 2014 3:32 PM To: mesa-dev@lists.freedesktop.org Cc: 10.2 Subject: [Mesa-dev] [PATCH 2/2] st/mesa: fix geometry shader memory leak Spotted by Charmaine Lee. Cc: "10.2" --- src/mesa/state_tracker/st_context.c |1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index c7f3ec6..c805a09 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -307,6 +307,7 @@ void st_destroy_context( struct st_context *st ) cso_release_all(st->cso_context); st_reference_fragprog(st, &st->fp, NULL); + st_reference_geomprog(st, &st->gp, NULL); st_reference_vertprog(st, &st->vp, NULL); /* release framebuffer surfaces */ -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=iVNYIcCaC9TDvyNBQU%2F5q5NVsC01tSgJb3oX27T14ck%3D%0A&m=PGTeI%2BoujnkFXc9mu71bomZEroIqI0JU%2FWsluOF9vs4%3D%0A&s=f6d160459d8d239933fc9e34ab65f560b5b06adc65b8c4ad0e1a4acacedda314 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: move draw debug code into separate function
const SVGA3dPrimitiveRange * range, > @@ -296,129 +430,7 @@ svga_hwtnl_prim(struct svga_hwtnl *hwtnl, > enum pipe_error ret = PIPE_OK; > > #ifdef DEBUG > - { > - unsigned i; > - for (i = 0; i < hwtnl->cmd.vdecl_count; i++) { > - struct pipe_resource *vb = hwtnl->cmd.vdecl_vb[i]; > - unsigned size = vb ? vb->width0 : 0; > - unsigned offset = hwtnl->cmd.vdecl[i].array.offset; > - unsigned stride = hwtnl->cmd.vdecl[i].array.stride; > - int index_bias = (int) range->indexBias + hwtnl->index_bias; > - unsigned width; > - > - assert(vb); > - assert(size); > - assert(offset < size); > - assert(min_index <= max_index); > - > - switch (hwtnl->cmd.vdecl[i].identity.type) { > - case SVGA3D_DECLTYPE_FLOAT1: > -width = 4; > -break; > - case SVGA3D_DECLTYPE_FLOAT2: > -width = 4 * 2; > -break; > - case SVGA3D_DECLTYPE_FLOAT3: > -width = 4 * 3; > -break; > - case SVGA3D_DECLTYPE_FLOAT4: > -width = 4 * 4; > -break; > - case SVGA3D_DECLTYPE_D3DCOLOR: > -width = 4; > -break; > - case SVGA3D_DECLTYPE_UBYTE4: > -width = 1 * 4; > -break; > - case SVGA3D_DECLTYPE_SHORT2: > -width = 2 * 2; > -break; > - case SVGA3D_DECLTYPE_SHORT4: > -width = 2 * 4; > -break; > - case SVGA3D_DECLTYPE_UBYTE4N: > -width = 1 * 4; > -break; > - case SVGA3D_DECLTYPE_SHORT2N: > -width = 2 * 2; > -break; > - case SVGA3D_DECLTYPE_SHORT4N: > -width = 2 * 4; > -break; > - case SVGA3D_DECLTYPE_USHORT2N: > -width = 2 * 2; > -break; > - case SVGA3D_DECLTYPE_USHORT4N: > -width = 2 * 4; > -break; > - case SVGA3D_DECLTYPE_UDEC3: > -width = 4; > -break; > - case SVGA3D_DECLTYPE_DEC3N: > -width = 4; > -break; > - case SVGA3D_DECLTYPE_FLOAT16_2: > -width = 2 * 2; > -break; > - case SVGA3D_DECLTYPE_FLOAT16_4: > -width = 2 * 4; > -break; > - default: > -assert(0); > -width = 0; > -break; > - } > - > - if (index_bias >= 0) { > -assert(offset + index_bias * stride + width <= size); > - } > - > - /* > - * min_index/max_index are merely conservative guesses, so we can't > - * make buffer overflow detection based on their values. > - */ > - } > - > - assert(range->indexWidth == range->indexArray.stride); > - > - if (ib) { > - unsigned size = ib->width0; > - unsigned offset = range->indexArray.offset; > - unsigned stride = range->indexArray.stride; > - unsigned count; > - > - assert(size); > - assert(offset < size); > - assert(stride); > - > - switch (range->primType) { > - case SVGA3D_PRIMITIVE_POINTLIST: > -count = range->primitiveCount; > -break; > - case SVGA3D_PRIMITIVE_LINELIST: > -count = range->primitiveCount * 2; > -break; > - case SVGA3D_PRIMITIVE_LINESTRIP: > -count = range->primitiveCount + 1; > -break; > - case SVGA3D_PRIMITIVE_TRIANGLELIST: > -count = range->primitiveCount * 3; > -break; > - case SVGA3D_PRIMITIVE_TRIANGLESTRIP: > -count = range->primitiveCount + 2; > -break; > - case SVGA3D_PRIMITIVE_TRIANGLEFAN: > -count = range->primitiveCount + 2; > -break; > - default: > -assert(0); > -count = 0; > -break; > - } > - > - assert(offset + count * stride <= size); > - } > - } > + check_draw_params(hwtnl, range, min_index, max_index, ib); > #endif > > if (hwtnl->cmd.prim_count + 1 >= QSZ) { > -- > 1.7.10.4 > Reviewed-by: Charmaine Lee ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/4] svga: clean up the compile_vs/gs/fs() functions
For the series, Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, September 10, 2015 8:04 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Brian Paul Subject: [PATCH 4/4] svga: clean up the compile_vs/gs/fs() functions Simplify structure and remove gotos. --- src/gallium/drivers/svga/svga_state_fs.c | 29 ++--- src/gallium/drivers/svga/svga_state_gs.c | 19 +++ src/gallium/drivers/svga/svga_state_vs.c | 28 ++-- 3 files changed, 27 insertions(+), 49 deletions(-) diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c index 5d39100..c244d53 100644 --- a/src/gallium/drivers/svga/svga_state_fs.c +++ b/src/gallium/drivers/svga/svga_state_fs.c @@ -136,13 +136,8 @@ compile_fs(struct svga_context *svga, debug_printf("Failed to compile fragment shader," " using dummy shader instead.\n"); variant = get_compiled_dummy_shader(svga, fs, key); - if (!variant) { - ret = PIPE_ERROR; - goto fail; - } } - - if (svga_shader_too_large(svga, variant)) { + else if (svga_shader_too_large(svga, variant)) { /* too big, use dummy shader */ debug_printf("Shader too large (%u bytes)," " using dummy shader instead.\n", @@ -152,29 +147,25 @@ compile_fs(struct svga_context *svga, svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant); /* Use simple pass-through shader instead */ variant = get_compiled_dummy_shader(svga, fs, key); - if (!variant) { - ret = PIPE_ERROR; - goto fail; - } + } + + if (!variant) { + return PIPE_ERROR; } ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_PS, variant); - if (ret != PIPE_OK) - goto fail; + if (ret != PIPE_OK) { + svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant); + return ret; + } *out_variant = variant; - /* insert variants at head of linked list */ + /* insert variant at head of linked list */ variant->next = fs->base.variants; fs->base.variants = variant; return PIPE_OK; - -fail: - if (variant) { - svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant); - } - return ret; } diff --git a/src/gallium/drivers/svga/svga_state_gs.c b/src/gallium/drivers/svga/svga_state_gs.c index 9f6885b..7f75410 100644 --- a/src/gallium/drivers/svga/svga_state_gs.c +++ b/src/gallium/drivers/svga/svga_state_gs.c @@ -80,34 +80,29 @@ compile_gs(struct svga_context *svga, /* some problem during translation, try the dummy shader */ const struct tgsi_token *dummy = get_dummy_geometry_shader(); if (!dummy) { - ret = PIPE_ERROR_OUT_OF_MEMORY; - goto fail; + return PIPE_ERROR_OUT_OF_MEMORY; } debug_printf("Failed to compile geometry shader, using dummy shader instead.\n"); FREE((void *) gs->base.tokens); gs->base.tokens = dummy; variant = translate_geometry_program(svga, gs, key); if (variant == NULL) { - ret = PIPE_ERROR; - goto fail; + return PIPE_ERROR; } } ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_GS, variant); - if (ret != PIPE_OK) - goto fail; + if (ret != PIPE_OK) { + svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_GS, variant); + return ret; + } *out_variant = variant; return PIPE_OK; - -fail: - if (variant) { - svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_GS, variant); - } - return ret; } + static void make_gs_key(struct svga_context *svga, struct svga_compile_key *key) { diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c index de41519..a846b77 100644 --- a/src/gallium/drivers/svga/svga_state_vs.c +++ b/src/gallium/drivers/svga/svga_state_vs.c @@ -127,13 +127,8 @@ compile_vs(struct svga_context *svga, debug_printf("Failed to compile vertex shader," " using dummy shader instead.\n"); variant = get_compiled_dummy_vertex_shader(svga, vs, key); - if (!variant) { - ret = PIPE_ERROR; - goto fail; - } } - - if (svga_shader_too_large(svga, variant)) { + else if (svga_shader_too_large(svga, variant)) { /* too big, use dummy shader */ debug_printf("Shader too large (%u bytes)," " using dummy shader instead.\n", @@ -143,27 +138,24 @@ compile_vs(struct svga_context *svga, svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant); /* Use simple pass-through shader instead */ variant = get_compiled_dummy_vertex_shader(svga, vs, key); - if (!variant) { - ret = PIPE_ERROR; - goto fail; - } + } + + if (!var
Re: [Mesa-dev] [PATCH 8/8] mesa: minor clean-up of some memcpy/sizeof() calls in m_matrix.c
This series looks fine to me. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Monday, January 4, 2016 4:49 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 8/8] mesa: minor clean-up of some memcpy/sizeof() calls in m_matrix.c --- src/mesa/math/m_matrix.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c index 6522200..b3cfcd2 100644 --- a/src/mesa/math/m_matrix.c +++ b/src/mesa/math/m_matrix.c @@ -654,7 +654,7 @@ static GLboolean invert_matrix_3d_no_rot( GLmatrix *mat ) if (MAT(in,0,0) == 0 || MAT(in,1,1) == 0 || MAT(in,2,2) == 0 ) return GL_FALSE; - memcpy( out, Identity, 16 * sizeof(GLfloat) ); + memcpy( out, Identity, sizeof(Identity) ); MAT(out,0,0) = 1.0F / MAT(in,0,0); MAT(out,1,1) = 1.0F / MAT(in,1,1); MAT(out,2,2) = 1.0F / MAT(in,2,2); @@ -687,7 +687,7 @@ static GLboolean invert_matrix_2d_no_rot( GLmatrix *mat ) if (MAT(in,0,0) == 0 || MAT(in,1,1) == 0) return GL_FALSE; - memcpy( out, Identity, 16 * sizeof(GLfloat) ); + memcpy( out, Identity, sizeof(Identity) ); MAT(out,0,0) = 1.0F / MAT(in,0,0); MAT(out,1,1) = 1.0F / MAT(in,1,1); @@ -709,7 +709,7 @@ static GLboolean invert_matrix_perspective( GLmatrix *mat ) if (MAT(in,2,3) == 0) return GL_FALSE; - memcpy( out, Identity, 16 * sizeof(GLfloat) ); + memcpy( out, Identity, sizeof(Identity) ); MAT(out,0,0) = 1.0F / MAT(in,0,0); MAT(out,1,1) = 1.0F / MAT(in,1,1); @@ -802,7 +802,7 @@ _math_matrix_rotate( GLmatrix *mat, s = sinf( angle * M_PI / 180.0 ); c = cosf( angle * M_PI / 180.0 ); - memcpy(m, Identity, sizeof(GLfloat)*16); + memcpy(m, Identity, sizeof(Identity)); optimized = GL_FALSE; #define M(row,col) m[col*4+row] @@ -1136,8 +1136,8 @@ _math_matrix_viewport(GLmatrix *m, const float scale[3], void _math_matrix_set_identity( GLmatrix *mat ) { - memcpy( mat->m, Identity, 16*sizeof(GLfloat) ); - memcpy( mat->inv, Identity, 16*sizeof(GLfloat) ); + memcpy( mat->m, Identity, sizeof(Identity) ); + memcpy( mat->inv, Identity, sizeof(Identity) ); mat->type = MATRIX_IDENTITY; mat->flags &= ~(MAT_DIRTY_FLAGS| @@ -1437,7 +1437,7 @@ _math_matrix_is_dirty( const GLmatrix *m ) void _math_matrix_copy( GLmatrix *to, const GLmatrix *from ) { - memcpy( to->m, from->m, sizeof(Identity) ); + memcpy(to->m, from->m, 16 * sizeof(GLfloat)); memcpy(to->inv, from->inv, 16 * sizeof(GLfloat)); to->flags = from->flags; to->type = from->type; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] svga: add num-generate-mipmap HUD query
The actual increment of the num-generate-mipmap counter will be done in a subsequent patch when hw generate mipmap is supported. --- src/gallium/drivers/svga/svga_context.h| 4 +++- src/gallium/drivers/svga/svga_pipe_query.c | 7 +++ src/gallium/drivers/svga/svga_screen.c | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index e4f29b8..f1a2041 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -59,8 +59,9 @@ #define SVGA_QUERY_NUM_RESOURCES (PIPE_QUERY_DRIVER_SPECIFIC + 9) #define SVGA_QUERY_NUM_STATE_OBJECTS (PIPE_QUERY_DRIVER_SPECIFIC + 10) #define SVGA_QUERY_NUM_SURFACE_VIEWS (PIPE_QUERY_DRIVER_SPECIFIC + 11) +#define SVGA_QUERY_NUM_GENERATE_MIPMAP (PIPE_QUERY_DRIVER_SPECIFIC + 12) /*SVGA_QUERY_MAX has to be last because it is size of an array*/ -#define SVGA_QUERY_MAX (PIPE_QUERY_DRIVER_SPECIFIC + 12) +#define SVGA_QUERY_MAX (PIPE_QUERY_DRIVER_SPECIFIC + 13) /** * Maximum supported number of constant buffers per shader @@ -505,6 +506,7 @@ struct svga_context uint64_t num_state_objects;/**< SVGA_QUERY_NUM_STATE_OBJECTS */ uint64_t num_surface_views;/**< SVGA_QUERY_NUM_SURFACE_VIEWS */ uint64_t num_bytes_uploaded; /**< SVGA_QUERY_NUM_BYTES_UPLOADED */ + uint64_t num_generate_mipmap; /**< SVGA_QUERY_NUM_GENERATE_MIPMAP */ } hud; /** The currently bound stream output targets */ diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index b67d56c..255494a 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -732,6 +732,7 @@ svga_create_query(struct pipe_context *pipe, case SVGA_QUERY_NUM_SURFACE_VIEWS: case SVGA_QUERY_NUM_RESOURCES_MAPPED: case SVGA_QUERY_NUM_BYTES_UPLOADED: + case SVGA_QUERY_NUM_GENERATE_MIPMAP: break; default: assert(!"unexpected query type in svga_create_query()"); @@ -800,6 +801,7 @@ svga_destroy_query(struct pipe_context *pipe, struct pipe_query *q) case SVGA_QUERY_NUM_SURFACE_VIEWS: case SVGA_QUERY_NUM_RESOURCES_MAPPED: case SVGA_QUERY_NUM_BYTES_UPLOADED: + case SVGA_QUERY_NUM_GENERATE_MIPMAP: /* nothing */ break; default: @@ -887,6 +889,7 @@ svga_begin_query(struct pipe_context *pipe, struct pipe_query *q) case SVGA_QUERY_NUM_RESOURCES: case SVGA_QUERY_NUM_STATE_OBJECTS: case SVGA_QUERY_NUM_SURFACE_VIEWS: + case SVGA_QUERY_NUM_GENERATE_MIPMAP: /* nothing */ break; default: @@ -980,6 +983,7 @@ svga_end_query(struct pipe_context *pipe, struct pipe_query *q) case SVGA_QUERY_NUM_RESOURCES: case SVGA_QUERY_NUM_STATE_OBJECTS: case SVGA_QUERY_NUM_SURFACE_VIEWS: + case SVGA_QUERY_NUM_GENERATE_MIPMAP: /* nothing */ break; default: @@ -1090,6 +1094,9 @@ svga_get_query_result(struct pipe_context *pipe, case SVGA_QUERY_NUM_SURFACE_VIEWS: vresult->u64 = svga->hud.num_surface_views; break; + case SVGA_QUERY_NUM_GENERATE_MIPMAP: + vresult->u64 = svga->hud.num_generate_mipmap; + break; default: assert(!"unexpected query type in svga_get_query_result"); } diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 0f41e4e..8b724b6 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -821,6 +821,8 @@ svga_get_driver_query_info(struct pipe_screen *screen, PIPE_DRIVER_QUERY_TYPE_UINT64), QUERY("num-surface-views", SVGA_QUERY_NUM_SURFACE_VIEWS, PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("num-generate-mipmap", SVGA_QUERY_NUM_GENERATE_MIPMAP, +PIPE_DRIVER_QUERY_TYPE_UINT64), }; #undef QUERY -- 1.8.1.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: fix incorrect buffer token passed to _mesa_BindFramebuffer()
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Monday, January 11, 2016 5:24 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Jose Fonseca Subject: [PATCH] st/mesa: fix incorrect buffer token passed to _mesa_BindFramebuffer() I added this code right at the end, and got it wrong. Only used by the WGL_ARB_render_texture code. --- src/mesa/state_tracker/st_copytex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_copytex.c b/src/mesa/state_tracker/st_copytex.c index d246d8b..4e0fd79 100644 --- a/src/mesa/state_tracker/st_copytex.c +++ b/src/mesa/state_tracker/st_copytex.c @@ -59,7 +59,7 @@ st_copy_framebuffer_to_texture(GLenum srcBuffer, _mesa_GetIntegerv(GL_READ_BUFFER, &readBufSave); /* Read from the winsys buffer */ - _mesa_BindFramebuffer(GL_READ_BUFFER, 0); + _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, 0); _mesa_ReadBuffer(srcBuffer); /* copy image from pbuffer to texture */ @@ -136,5 +136,5 @@ st_copy_framebuffer_to_texture(GLenum srcBuffer, /* restore readbuffer */ _mesa_ReadBuffer(readBufSave); - _mesa_BindFramebuffer(GL_READ_BUFFER, readFBOSave); + _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, readFBOSave); } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] gallium/st: add pipe_context::generate_mipmap()
This patch adds a new interface to support hardware mipmap generation. PIPE_CAP_GENERATE_MIPMAP is added to allow a driver to specify if this new interface is supported; if not supported, the state tracker will fallback to mipmap generation by rendering/texturing. --- src/gallium/docs/source/context.rst| 10 ++ src/gallium/docs/source/screen.rst | 2 ++ src/gallium/drivers/trace/tr_context.c | 30 ++ src/gallium/include/pipe/p_context.h | 11 +++ src/gallium/include/pipe/p_defines.h | 1 + src/mesa/state_tracker/st_gen_mipmap.c | 17 - 6 files changed, 66 insertions(+), 5 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 9a32716..e33e7a2 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -648,3 +648,13 @@ In addition, normal texture sampling is allowed from the compute program: ``bind_sampler_states`` may be used to set up texture samplers for the compute stage and ``set_sampler_views`` may be used to bind a number of sampler views to it. + +Mipmap generation +^ + +If PIPE_CAP_GENERATE_MIPMAP is true, ``generate_mipmap`` can be used +to generate mipmaps for the specified texture resource. +It replaces texel image levels base_level+1 through +last_level for layers range from first_layer through last_layer. +It returns TRUE if mipmap generation succeeds, otherwise it +returns FALSE. diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index c8f5f6a..b8d8de5 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -301,6 +301,8 @@ The integer capabilities: alignment for pipe_shader_buffer::buffer_offset, in bytes. Maximum value allowed is 256 (for GL conformance). 0 is only allowed if shader buffers are not supported. +* ``PIPE_CAP_GENERATE_MIPMAP``: Whether `generate_mipmap` will be + available in contexts. .. _pipe_capf: diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index d4c88c9..17da64e 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1292,6 +1292,35 @@ trace_context_flush(struct pipe_context *_pipe, static inline void +trace_context_generate_mipmap(struct pipe_context *_pipe, + struct pipe_resource *res, + unsigned base_level, + unsigned last_level, + unsigned first_layer, + unsigned last_layer) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + + res = trace_resource_unwrap(tr_ctx, res); + + trace_dump_call_begin("pipe_context", "generate_mipmap"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(ptr, res); + + trace_dump_arg(uint, base_level); + trace_dump_arg(uint, last_level); + trace_dump_arg(uint, first_layer); + trace_dump_arg(uint, last_layer); + + pipe->generate_mipmap(pipe, res, base_level, last_level, first_layer, last_layer); + + trace_dump_call_end(); +} + + +static inline void trace_context_destroy(struct pipe_context *_pipe) { struct trace_context *tr_ctx = trace_context(_pipe); @@ -1620,6 +1649,7 @@ trace_context_create(struct trace_screen *tr_scr, TR_CTX_INIT(clear_render_target); TR_CTX_INIT(clear_depth_stencil); TR_CTX_INIT(flush); + TR_CTX_INIT(generate_mipmap); TR_CTX_INIT(texture_barrier); TR_CTX_INIT(memory_barrier); TR_CTX_INIT(set_tess_state); diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index be7447d..a0774c7 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -673,6 +673,17 @@ struct pipe_context { */ void (*dump_debug_state)(struct pipe_context *ctx, FILE *stream, unsigned flags); + + /** +* Generate mipmap. +* \return TRUE if mipmap generation succeeds, FALSE otherwise +*/ + boolean (*generate_mipmap)(struct pipe_context *ctx, + struct pipe_resource *resource, + unsigned base_level, + unsigned last_level, + unsigned first_layer, + unsigned last_layer); }; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index dd76fe5..40f114f 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -642,6 +642,7 @@ enum pipe_cap PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL, PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL, PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT, + PIPE_CAP_GENERATE_MIPMAP, }; #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0) diff --git a/src/mesa/state_tracker/st_gen_mip
[Mesa-dev] [PATCH 3/3] svga: add DXGenMips command support
For those formats that support hw mipmap generation, use the DXGenMips command. Otherwise fallback to the mipmap generation utility. Tested with piglit, OpenGL apps (Heaven, Turbine, Cinebench) --- src/gallium/drivers/svga/svga_cmd.h | 4 ++ src/gallium/drivers/svga/svga_cmd_vgpu10.c | 21 + src/gallium/drivers/svga/svga_format.c | 53 +-- src/gallium/drivers/svga/svga_format.h | 7 +++ src/gallium/drivers/svga/svga_resource.c | 6 +++ src/gallium/drivers/svga/svga_resource_texture.c | 54 src/gallium/drivers/svga/svga_resource_texture.h | 8 +++- src/gallium/drivers/svga/svga_sampler_view.h | 5 +++ src/gallium/drivers/svga/svga_screen.c | 3 ++ src/gallium/drivers/svga/svga_state_sampler.c| 2 +- 10 files changed, 138 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/svga/svga_cmd.h b/src/gallium/drivers/svga/svga_cmd.h index 271ee8e..26e4690 100644 --- a/src/gallium/drivers/svga/svga_cmd.h +++ b/src/gallium/drivers/svga/svga_cmd.h @@ -638,4 +638,8 @@ SVGA3D_vgpu10_UpdateSubResource(struct svga_winsys_context *swc, const SVGA3dBox *box, unsigned subResource); +enum pipe_error +SVGA3D_vgpu10_GenMips(struct svga_winsys_context *swc, + const SVGA3dShaderResourceViewId shaderResourceViewId, + struct svga_winsys_surface *view); #endif /* __SVGA3D_H__ */ diff --git a/src/gallium/drivers/svga/svga_cmd_vgpu10.c b/src/gallium/drivers/svga/svga_cmd_vgpu10.c index 4cd9d5b..0c07b26 100644 --- a/src/gallium/drivers/svga/svga_cmd_vgpu10.c +++ b/src/gallium/drivers/svga/svga_cmd_vgpu10.c @@ -1293,3 +1293,24 @@ SVGA3D_vgpu10_UpdateSubResource(struct svga_winsys_context *swc, swc->commit(swc); return PIPE_OK; } + +enum pipe_error +SVGA3D_vgpu10_GenMips(struct svga_winsys_context *swc, + SVGA3dShaderResourceViewId shaderResourceViewId, + struct svga_winsys_surface *view) +{ + SVGA3dCmdDXGenMips *cmd; + + cmd = SVGA3D_FIFOReserve(swc, SVGA_3D_CMD_DX_GENMIPS, +sizeof(SVGA3dCmdDXGenMips), 1); + + if (!cmd) + return PIPE_ERROR_OUT_OF_MEMORY; + + swc->surface_relocation(swc, &cmd->shaderResourceViewId, NULL, view, + SVGA_RELOC_READ); + cmd->shaderResourceViewId = shaderResourceViewId; + + swc->commit(swc); + return PIPE_OK; +} diff --git a/src/gallium/drivers/svga/svga_format.c b/src/gallium/drivers/svga/svga_format.c index 2b549df..0186736 100644 --- a/src/gallium/drivers/svga/svga_format.c +++ b/src/gallium/drivers/svga/svga_format.c @@ -48,16 +48,16 @@ static const struct vgpu10_format_entry format_conversion_table[] = { /* Gallium formatSVGA3D vertex formatSVGA3D pixel format Flags */ { PIPE_FORMAT_NONE, SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, 0 }, - { PIPE_FORMAT_B8G8R8A8_UNORM,SVGA3D_B8G8R8A8_UNORM, SVGA3D_B8G8R8A8_UNORM, 0 }, - { PIPE_FORMAT_B8G8R8X8_UNORM,SVGA3D_FORMAT_INVALID, SVGA3D_B8G8R8X8_UNORM, 0 }, + { PIPE_FORMAT_B8G8R8A8_UNORM,SVGA3D_B8G8R8A8_UNORM, SVGA3D_B8G8R8A8_UNORM, TF_GEN_MIPS }, + { PIPE_FORMAT_B8G8R8X8_UNORM,SVGA3D_FORMAT_INVALID, SVGA3D_B8G8R8X8_UNORM, TF_GEN_MIPS }, { PIPE_FORMAT_A8R8G8B8_UNORM,SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, 0 }, { PIPE_FORMAT_X8R8G8B8_UNORM,SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, 0 }, - { PIPE_FORMAT_B5G5R5A1_UNORM,SVGA3D_FORMAT_INVALID, SVGA3D_B5G5R5A1_UNORM, 0 }, + { PIPE_FORMAT_B5G5R5A1_UNORM,SVGA3D_FORMAT_INVALID, SVGA3D_B5G5R5A1_UNORM, TF_GEN_MIPS }, { PIPE_FORMAT_B4G4R4A4_UNORM,SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, 0 }, - { PIPE_FORMAT_B5G6R5_UNORM, SVGA3D_FORMAT_INVALID, SVGA3D_B5G6R5_UNORM, 0 }, - { PIPE_FORMAT_R10G10B10A2_UNORM, SVGA3D_R10G10B10A2_UNORM, SVGA3D_R10G10B10A2_UNORM,0 }, + { PIPE_FORMAT_B5G6R5_UNORM, SVGA3D_FORMAT_INVALID, SVGA3D_B5G6R5_UNORM, TF_GEN_MIPS }, + { PIPE_FORMAT_R10G10B10A2_UNORM, SVGA3D_R10G10B10A2_UNORM, SVGA3D_R10G10B10A2_UNORM,TF_GEN_MIPS }, { PIPE_FORMAT_L8_UNORM, SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, 0 }, - { PIPE_FORMAT_A8_UNORM, SVGA3D_FORMAT_INVALID, SVGA3D_A8_UNORM, 0 }, + { PIPE_FORMAT_A8_UNORM, SVGA3D_FORMAT_INVALID, SVGA3D_A8_UNORM, TF_GEN_MIPS }, { PIPE_FORMAT_I8_UNORM, SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, 0 }, { PIPE_FORMAT_L8A8_UNORM,SVGA3D_FORMAT_INVALID, SVGA3D_FORMAT_INVALID, 0 }, { PIPE_FORMAT_L16_UN
Re: [Mesa-dev] [PATCH 1/3] gallium/st: add pipe_context::generate_mipmap()
>From: ibmir...@gmail.com on behalf of Ilia Mirkin > >Sent: Monday, January 11, 2016 7:12 PM >To: Charmaine Lee >Cc: mesa-dev@lists.freedesktop.org >Subject: Re: [Mesa-dev] [PATCH 1/3] gallium/st: add >pipe_context::generate_mipmap() >On Mon, Jan 11, 2016 at 9:31 PM, Charmaine Lee wrote: >> This patch adds a new interface to support hardware mipmap generation. >> PIPE_CAP_GENERATE_MIPMAP is added to allow a driver to specify >> if this new interface is supported; if not supported, the state tracker will >> fallback to mipmap generation by rendering/texturing. >> --- >> src/gallium/docs/source/context.rst| 10 ++ >> src/gallium/docs/source/screen.rst | 2 ++ >> src/gallium/drivers/trace/tr_context.c | 30 ++ >> src/gallium/include/pipe/p_context.h | 11 +++ >> src/gallium/include/pipe/p_defines.h | 1 + >> src/mesa/state_tracker/st_gen_mipmap.c | 17 - >> 6 files changed, 66 insertions(+), 5 deletions(-) ... >> diff --git a/src/mesa/state_tracker/st_gen_mipmap.c >> b/src/mesa/state_tracker/st_gen_mipmap.c >> index b370040..94c1171 100644 >> --- a/src/mesa/state_tracker/st_gen_mipmap.c >> +++ b/src/mesa/state_tracker/st_gen_mipmap.c >> @@ -149,12 +149,19 @@ st_generate_mipmap(struct gl_context *ctx, GLenum >> target, >>last_layer = util_max_layer(pt, baseLevel); >> } >> >> - /* Try to generate the mipmap by rendering/texturing. If that fails, >> -* use the software fallback. >> + /* First see if the driver supports hardware mipmap generation, >> +* if not then generate the mipmap by rendering/texturing. >> +* If that fails, use the software fallback. >> */ >> - if (!util_gen_mipmap(st->pipe, pt, pt->format, baseLevel, lastLevel, >> -first_layer, last_layer, PIPE_TEX_FILTER_LINEAR)) { >> - _mesa_generate_mipmap(ctx, target, texObj); >> + if (!st->pipe->screen->get_param(st->pipe->screen, >> +PIPE_CAP_GENERATE_MIPMAP) || >This will cause errors to get logged on every driver. You have to go >in and update every driver to add the cap to the disabled section. A >little annoying, but that's how we've been doing everything. Grep for >a recently-added cap and add below it -- works for most drivers. > Oh ya, I will fix it. Thanks for reviewing. > -ilia -Charmaine > + !st->pipe->generate_mipmap(st->pipe, pt, baseLevel, lastLevel, > + first_layer, last_layer)) { > + > + if (!util_gen_mipmap(st->pipe, pt, pt->format, baseLevel, lastLevel, > + first_layer, last_layer, PIPE_TEX_FILTER_LINEAR)) > { > + _mesa_generate_mipmap(ctx, target, texObj); > + } > } > > /* Fill in the Mesa gl_texture_image fields */ > -- > 1.8.1.2 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=BQIBaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=dMTqrakxe895Y1JgK2Fm6G2IzlobZfMtVdJTlRk8YUY&m=KR0ZO91gNpu112oW_a8nEd3uGB96VPu_y8tjNUpqlFE&s=An_Ey25TOIQUQz0TyBaMuZgAdNrSLb6K6ERQ2MjlUZs&e= ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] gallium/st: add pipe_context::generate_mipmap()
This patch adds a new interface to support hardware mipmap generation. PIPE_CAP_GENERATE_MIPMAP is added to allow a driver to specify if this new interface is supported; if not supported, the state tracker will fallback to mipmap generation by rendering/texturing. v2: add PIPE_CAP_GENERATE_MIPMAP to the disabled section for all drivers --- src/gallium/docs/source/context.rst | 10 src/gallium/docs/source/screen.rst | 2 ++ src/gallium/drivers/freedreno/freedreno_screen.c | 1 + src/gallium/drivers/i915/i915_screen.c | 1 + src/gallium/drivers/ilo/ilo_screen.c | 1 + src/gallium/drivers/llvmpipe/lp_screen.c | 1 + src/gallium/drivers/nouveau/nv30/nv30_screen.c | 1 + src/gallium/drivers/nouveau/nv50/nv50_screen.c | 1 + src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 + src/gallium/drivers/r300/r300_screen.c | 1 + src/gallium/drivers/r600/r600_pipe.c | 1 + src/gallium/drivers/radeonsi/si_pipe.c | 1 + src/gallium/drivers/softpipe/sp_screen.c | 1 + src/gallium/drivers/svga/svga_screen.c | 1 + src/gallium/drivers/trace/tr_context.c | 30 src/gallium/drivers/vc4/vc4_screen.c | 1 + src/gallium/drivers/virgl/virgl_screen.c | 1 + src/gallium/include/pipe/p_context.h | 11 + src/gallium/include/pipe/p_defines.h | 1 + src/mesa/state_tracker/st_gen_mipmap.c | 17 ++ 20 files changed, 80 insertions(+), 5 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 9a32716..e33e7a2 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -648,3 +648,13 @@ In addition, normal texture sampling is allowed from the compute program: ``bind_sampler_states`` may be used to set up texture samplers for the compute stage and ``set_sampler_views`` may be used to bind a number of sampler views to it. + +Mipmap generation +^ + +If PIPE_CAP_GENERATE_MIPMAP is true, ``generate_mipmap`` can be used +to generate mipmaps for the specified texture resource. +It replaces texel image levels base_level+1 through +last_level for layers range from first_layer through last_layer. +It returns TRUE if mipmap generation succeeds, otherwise it +returns FALSE. diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index c8f5f6a..b8d8de5 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -301,6 +301,8 @@ The integer capabilities: alignment for pipe_shader_buffer::buffer_offset, in bytes. Maximum value allowed is 256 (for GL conformance). 0 is only allowed if shader buffers are not supported. +* ``PIPE_CAP_GENERATE_MIPMAP``: Whether `generate_mipmap` will be + available in contexts. .. _pipe_capf: diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 9d0cdd8..4969774 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -245,6 +245,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_MAX_VIEWPORTS: diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index e2a493b..5e6262b 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -259,6 +259,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index d5a82ce..d483cd6 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -483,6 +483,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_VENDOR_ID: diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index e29b008..ed10c46 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -308,6 +308,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TG
Re: [Mesa-dev] [PATCH 1/3] gallium/st: add pipe_context::generate_mipmap()
>From: Michel Dänzer >Sent: Monday, January 11, 2016 11:37 PM >To: Charmaine Lee >Cc: mesa-dev@lists.freedesktop.org >Subject: Re: [Mesa-dev] [PATCH 1/3] gallium/st: add >pipe_context::generate_mipmap() >On 12.01.2016 15:18, Charmaine Lee wrote: >> This patch adds a new interface to support hardware mipmap generation. >> PIPE_CAP_GENERATE_MIPMAP is added to allow a driver to specify >> if this new interface is supported; if not supported, the state tracker will >> fallback to mipmap generation by rendering/texturing. >> >> v2: add PIPE_CAP_GENERATE_MIPMAP to the disabled section for all drivers >[...] >> diff --git a/src/gallium/drivers/trace/tr_context.c >> b/src/gallium/drivers/trace/tr_context.c >> index d4c88c9..17da64e 100644 >> --- a/src/gallium/drivers/trace/tr_context.c >> +++ b/src/gallium/drivers/trace/tr_context.c >> @@ -1292,6 +1292,35 @@ trace_context_flush(struct pipe_context *_pipe, >> >> >> static inline void >> +trace_context_generate_mipmap(struct pipe_context *_pipe, >> + struct pipe_resource *res, >> + unsigned base_level, >> + unsigned last_level, >> + unsigned first_layer, >> + unsigned last_layer) >> +{ >> + struct trace_context *tr_ctx = trace_context(_pipe); >> + struct pipe_context *pipe = tr_ctx->pipe; >> + >> + res = trace_resource_unwrap(tr_ctx, res); >> + >> + trace_dump_call_begin("pipe_context", "generate_mipmap"); >> + >> + trace_dump_arg(ptr, pipe); >> + trace_dump_arg(ptr, res); >> + >> + trace_dump_arg(uint, base_level); >> + trace_dump_arg(uint, last_level); >> + trace_dump_arg(uint, first_layer); >> + trace_dump_arg(uint, last_layer); >> + >> + pipe->generate_mipmap(pipe, res, base_level, last_level, first_layer, >> last_layer); >> + >> + trace_dump_call_end(); >> +} >> + >> + >> +static inline void >> trace_context_destroy(struct pipe_context *_pipe) >> { >> struct trace_context *tr_ctx = trace_context(_pipe); >[...] >> diff --git a/src/gallium/include/pipe/p_context.h >> b/src/gallium/include/pipe/p_context.h >> index be7447d..a0774c7 100644 >> --- a/src/gallium/include/pipe/p_context.h >> +++ b/src/gallium/include/pipe/p_context.h >> @@ -673,6 +673,17 @@ struct pipe_context { >> */ >> void (*dump_debug_state)(struct pipe_context *ctx, FILE *stream, >> unsigned flags); >> + >> + /** >> +* Generate mipmap. >> +* \return TRUE if mipmap generation succeeds, FALSE otherwise >> +*/ >> + boolean (*generate_mipmap)(struct pipe_context *ctx, >> + struct pipe_resource *resource, >> + unsigned base_level, >> + unsigned last_level, >> + unsigned first_layer, >> + unsigned last_layer); >> }; >Maybe I'm missing something, but the prototypes of the pipe_context >field and trace driver implementation don't match. Hmm. I don't know what you mean. They look correct to me. >> diff --git a/src/mesa/state_tracker/st_gen_mipmap.c >> b/src/mesa/state_tracker/st_gen_mipmap.c >> index b370040..94c1171 100644 >> --- a/src/mesa/state_tracker/st_gen_mipmap.c >> +++ b/src/mesa/state_tracker/st_gen_mipmap.c >> @@ -149,12 +149,19 @@ st_generate_mipmap(struct gl_context *ctx, GLenum >> target, >>last_layer = util_max_layer(pt, baseLevel); >> } >> >> - /* Try to generate the mipmap by rendering/texturing. If that fails, >> -* use the software fallback. >> + /* First see if the driver supports hardware mipmap generation, >> +* if not then generate the mipmap by rendering/texturing. >> +* If that fails, use the software fallback. >> */ >> - if (!util_gen_mipmap(st->pipe, pt, pt->format, baseLevel, lastLevel, >> -first_layer, last_layer, PIPE_TEX_FILTER_LINEAR)) { >> - _mesa_generate_mipmap(ctx, target, texObj); >> + if (!st->pipe->screen->get_param(st->pipe->screen, >> +PIPE_CAP_GENERATE_MIPMAP) || >> + !st->pipe->generate_mipmap(st->pipe, pt, baseLevel, lastLevel, >> + first_layer, last_layer)) { >> + >> + if (!ut
[Mesa-dev] [PATCH v3 1/3] gallium/st: add pipe_context::generate_mipmap()
This patch adds a new interface to support hardware mipmap generation. PIPE_CAP_GENERATE_MIPMAP is added to allow a driver to specify if this new interface is supported; if not supported, the state tracker will fallback to mipmap generation by rendering/texturing. v2: add PIPE_CAP_GENERATE_MIPMAP to the disabled section for all drivers v3: add format to the generate_mipmap interface to allow mipmap generation using a format other than the resource format --- src/gallium/docs/source/context.rst | 11 src/gallium/docs/source/screen.rst | 2 ++ src/gallium/drivers/freedreno/freedreno_screen.c | 1 + src/gallium/drivers/i915/i915_screen.c | 1 + src/gallium/drivers/ilo/ilo_screen.c | 1 + src/gallium/drivers/llvmpipe/lp_screen.c | 1 + src/gallium/drivers/nouveau/nv30/nv30_screen.c | 1 + src/gallium/drivers/nouveau/nv50/nv50_screen.c | 1 + src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 + src/gallium/drivers/r300/r300_screen.c | 1 + src/gallium/drivers/r600/r600_pipe.c | 1 + src/gallium/drivers/radeonsi/si_pipe.c | 1 + src/gallium/drivers/softpipe/sp_screen.c | 1 + src/gallium/drivers/svga/svga_screen.c | 1 + src/gallium/drivers/trace/tr_context.c | 33 src/gallium/drivers/vc4/vc4_screen.c | 1 + src/gallium/drivers/virgl/virgl_screen.c | 1 + src/gallium/include/pipe/p_context.h | 12 + src/gallium/include/pipe/p_defines.h | 1 + src/mesa/state_tracker/st_gen_mipmap.c | 17 20 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 9a32716..4c03e00 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -648,3 +648,14 @@ In addition, normal texture sampling is allowed from the compute program: ``bind_sampler_states`` may be used to set up texture samplers for the compute stage and ``set_sampler_views`` may be used to bind a number of sampler views to it. + +Mipmap generation +^ + +If PIPE_CAP_GENERATE_MIPMAP is true, ``generate_mipmap`` can be used +to generate mipmaps for the specified texture resource. +It replaces texel image levels base_level+1 through +last_level for layers range from first_layer through last_layer. +It returns TRUE if mipmap generation succeeds, otherwise it +returns FALSE. Mipmap generation may fail when it is not supported +for particular texture types or formats. diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index c8f5f6a..291e917 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -301,6 +301,8 @@ The integer capabilities: alignment for pipe_shader_buffer::buffer_offset, in bytes. Maximum value allowed is 256 (for GL conformance). 0 is only allowed if shader buffers are not supported. +* ``PIPE_CAP_GENERATE_MIPMAP``: Indicates whether pipe_context::generate_mipmap + is supported. .. _pipe_capf: diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 9d0cdd8..4969774 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -245,6 +245,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_MAX_VIEWPORTS: diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index e2a493b..5e6262b 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -259,6 +259,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index d5a82ce..d483cd6 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -483,6 +483,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_VENDOR_ID: diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index e29b008..ed10c46 100644 --- a/src/gallium/drivers/l
[Mesa-dev] [PATCH v4 1/3] gallium/st: add pipe_context::generate_mipmap()
This patch adds a new interface to support hardware mipmap generation. PIPE_CAP_GENERATE_MIPMAP is added to allow a driver to specify if this new interface is supported; if not supported, the state tracker will fallback to mipmap generation by rendering/texturing. v2: add PIPE_CAP_GENERATE_MIPMAP to the disabled section for all drivers v3: add format to the generate_mipmap interface to allow mipmap generation using a format other than the resource format v4: fix return type of trace_context_generate_mipmap() --- src/gallium/docs/source/context.rst | 11 src/gallium/docs/source/screen.rst | 2 ++ src/gallium/drivers/freedreno/freedreno_screen.c | 1 + src/gallium/drivers/i915/i915_screen.c | 1 + src/gallium/drivers/ilo/ilo_screen.c | 1 + src/gallium/drivers/llvmpipe/lp_screen.c | 1 + src/gallium/drivers/nouveau/nv30/nv30_screen.c | 1 + src/gallium/drivers/nouveau/nv50/nv50_screen.c | 1 + src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 + src/gallium/drivers/r300/r300_screen.c | 1 + src/gallium/drivers/r600/r600_pipe.c | 1 + src/gallium/drivers/radeonsi/si_pipe.c | 1 + src/gallium/drivers/softpipe/sp_screen.c | 1 + src/gallium/drivers/svga/svga_screen.c | 1 + src/gallium/drivers/trace/tr_context.c | 36 src/gallium/drivers/vc4/vc4_screen.c | 1 + src/gallium/drivers/virgl/virgl_screen.c | 1 + src/gallium/include/pipe/p_context.h | 12 src/gallium/include/pipe/p_defines.h | 1 + src/mesa/state_tracker/st_gen_mipmap.c | 17 +++ 20 files changed, 88 insertions(+), 5 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 9a32716..4c03e00 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -648,3 +648,14 @@ In addition, normal texture sampling is allowed from the compute program: ``bind_sampler_states`` may be used to set up texture samplers for the compute stage and ``set_sampler_views`` may be used to bind a number of sampler views to it. + +Mipmap generation +^ + +If PIPE_CAP_GENERATE_MIPMAP is true, ``generate_mipmap`` can be used +to generate mipmaps for the specified texture resource. +It replaces texel image levels base_level+1 through +last_level for layers range from first_layer through last_layer. +It returns TRUE if mipmap generation succeeds, otherwise it +returns FALSE. Mipmap generation may fail when it is not supported +for particular texture types or formats. diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index c8f5f6a..291e917 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -301,6 +301,8 @@ The integer capabilities: alignment for pipe_shader_buffer::buffer_offset, in bytes. Maximum value allowed is 256 (for GL conformance). 0 is only allowed if shader buffers are not supported. +* ``PIPE_CAP_GENERATE_MIPMAP``: Indicates whether pipe_context::generate_mipmap + is supported. .. _pipe_capf: diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 9d0cdd8..4969774 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -245,6 +245,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_MAX_VIEWPORTS: diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index e2a493b..5e6262b 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -259,6 +259,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index d5a82ce..d483cd6 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -483,6 +483,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL: case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT: + case PIPE_CAP_GENERATE_MIPMAP: return 0; case PIPE_CAP_VENDOR_ID: diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c inde
Re: [Mesa-dev] [PATCH] st/mesa: fix memleak in glDrawPixels cache code
Looks good to me too. Reviewed-by: Charmaine Lee From: mesa-dev on behalf of Jose Fonseca Sent: Tuesday, April 12, 2016 9:24 AM To: Brian Paul; mesa-dev@lists.freedesktop.org Cc: 11.2 Subject: Re: [Mesa-dev] [PATCH] st/mesa: fix memleak in glDrawPixels cache code On 12/04/16 16:15, Brian Paul wrote: > If the glDrawPixels size changed, we leaked the previously cached > texture, if there was one. This patch fixes the reference counting, > adds a refcount assertion check, and better handles potential malloc() > failures. > > Tested with a modified version of the drawpix Mesa demo which changed > the image size for each glDrawPixels call. > > Cc: "11.2" > --- > src/mesa/state_tracker/st_cb_drawpixels.c | 23 ++- > 1 file changed, 18 insertions(+), 5 deletions(-) > > diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c > b/src/mesa/state_tracker/st_cb_drawpixels.c > index 01ed544..3c7bc0c 100644 > --- a/src/mesa/state_tracker/st_cb_drawpixels.c > +++ b/src/mesa/state_tracker/st_cb_drawpixels.c > @@ -384,7 +384,7 @@ make_texture(struct st_context *st, > struct gl_context *ctx = st->ctx; > struct pipe_context *pipe = st->pipe; > mesa_format mformat; > - struct pipe_resource *pt; > + struct pipe_resource *pt = NULL; > enum pipe_format pipeFormat; > GLenum baseInternalFormat; > > @@ -403,10 +403,18 @@ make_texture(struct st_context *st, > unpack->SkipRows == 0 && > unpack->SwapBytes == GL_FALSE && > st->drawpix_cache.image) { > + assert(st->drawpix_cache.texture); > + > /* check if the pixel data is the same */ > if (memcmp(pixels, st->drawpix_cache.image, width * height * bpp) == > 0) { >/* OK, re-use the cached texture */ > - return st->drawpix_cache.texture; > + pipe_resource_reference(&pt, st->drawpix_cache.texture); > + /* refcount of returned texture should be at least two here. One > + * reference for the cache to hold on to, one for the caller (which > + * it will release), and possibly more held by the driver. > + */ > + assert(pt->reference.count >= 2); > + return pt; > } > } > > @@ -525,8 +533,14 @@ make_texture(struct st_context *st, > st->drawpix_cache.image = malloc(width * height * bpp); > if (st->drawpix_cache.image) { >memcpy(st->drawpix_cache.image, pixels, width * height * bpp); > + pipe_resource_reference(&st->drawpix_cache.texture, pt); > + } > + else { > + /* out of memory, free/disable cached texture */ > + st->drawpix_cache.width = 0; > + st->drawpix_cache.height = 0; > + pipe_resource_reference(&st->drawpix_cache.texture, NULL); > } > - st->drawpix_cache.texture = pt; > } > #endif > > @@ -1160,9 +1174,8 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y, > if (num_sampler_view > 1) > pipe_sampler_view_reference(&sv[1], NULL); > > -#if !USE_DRAWPIXELS_CACHE > + /* free the texture (but may persist in the cache) */ > pipe_resource_reference(&pt, NULL); > -#endif > } > > Looks good AFAICT. Reviewed-by: Jose Fonseca ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: fix sampler view leak in st_DrawAtlasBitmaps()
Looks good to me. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, April 14, 2016 2:12 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; 11.1 11.2 Subject: [PATCH] st/mesa: fix sampler view leak in st_DrawAtlasBitmaps() I neglected to free the sampler view which was created earlier in the function. So for each glCallLists() command that used the bitmap atlas to draw text, we'd leak a smpler view object. Also, check for st_create_texture_sampler_view() failure and record GL_OUT_OF_MEMORY. Cc: "11.1 11.2" --- src/mesa/state_tracker/st_cb_bitmap.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 4fd2dfe..b4d04b4 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -704,6 +704,10 @@ st_DrawAtlasBitmaps(struct gl_context *ctx, st_validate_state(st, ST_PIPELINE_RENDER); sv = st_create_texture_sampler_view(pipe, stObj->pt); + if (!sv) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCallLists(bitmap text)"); + return; + } setup_render_state(ctx, sv, color, true); @@ -793,6 +797,8 @@ st_DrawAtlasBitmaps(struct gl_context *ctx, pipe_resource_reference(&vb.buffer, NULL); + pipe_sampler_view_reference(&sv, NULL); + /* We uploaded modified constants, need to invalidate them. */ st->dirty.mesa |= _NEW_PROGRAM_CONSTANTS; } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: separate HUD counters for state objects
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, April 15, 2016 2:41 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: separate HUD counters for state objects Count depth/stencil, blend, sampler, etc. state objects separately but just report the sum for the HUD. This change lets us use gdb to see the breakdown of state objects in more detail. Also, count sampler views too. --- src/gallium/drivers/svga/svga_context.h | 10 +- src/gallium/drivers/svga/svga_pipe_blend.c| 4 ++-- src/gallium/drivers/svga/svga_pipe_depthstencil.c | 4 ++-- src/gallium/drivers/svga/svga_pipe_query.c| 7 ++- src/gallium/drivers/svga/svga_pipe_rasterizer.c | 4 ++-- src/gallium/drivers/svga/svga_pipe_sampler.c | 8 ++-- src/gallium/drivers/svga/svga_pipe_vertex.c | 4 ++-- 7 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index ead47c0..b485485 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -519,7 +519,15 @@ struct svga_context uint64_t num_const_buf_updates; /**< SVGA_QUERY_NUM_CONST_BUF_UPDATES */ uint64_t num_const_updates; /**< SVGA_QUERY_NUM_CONST_UPDATES */ uint64_t num_shaders; /**< SVGA_QUERY_NUM_SHADERS */ - uint64_t num_state_objects; /**< SVGA_QUERY_NUM_STATE_OBJECTS */ + + /** The following are summed for SVGA_QUERY_NUM_STATE_OBJECTS */ + uint64_t num_blend_objects; + uint64_t num_depthstencil_objects; + uint64_t num_rasterizer_objects; + uint64_t num_sampler_objects; + uint64_t num_samplerview_objects; + uint64_t num_vertexelement_objects; + uint64_t num_surface_views; /**< SVGA_QUERY_NUM_SURFACE_VIEWS */ uint64_t num_bytes_uploaded; /**< SVGA_QUERY_NUM_BYTES_UPLOADED */ uint64_t num_generate_mipmap; /**< SVGA_QUERY_NUM_GENERATE_MIPMAP */ diff --git a/src/gallium/drivers/svga/svga_pipe_blend.c b/src/gallium/drivers/svga/svga_pipe_blend.c index 0ba9313..9a4fcc3 100644 --- a/src/gallium/drivers/svga/svga_pipe_blend.c +++ b/src/gallium/drivers/svga/svga_pipe_blend.c @@ -333,7 +333,7 @@ svga_create_blend_state(struct pipe_context *pipe, define_blend_state_object(svga, blend); } - svga->hud.num_state_objects++; + svga->hud.num_blend_objects++; return blend; } @@ -373,7 +373,7 @@ static void svga_delete_blend_state(struct pipe_context *pipe, } FREE(blend); - svga->hud.num_state_objects--; + svga->hud.num_blend_objects--; } static void svga_set_blend_color( struct pipe_context *pipe, diff --git a/src/gallium/drivers/svga/svga_pipe_depthstencil.c b/src/gallium/drivers/svga/svga_pipe_depthstencil.c index c5d83c3..9ebb5d4 100644 --- a/src/gallium/drivers/svga/svga_pipe_depthstencil.c +++ b/src/gallium/drivers/svga/svga_pipe_depthstencil.c @@ -205,7 +205,7 @@ svga_create_depth_stencil_state(struct pipe_context *pipe, define_depth_stencil_state_object(svga, ds); } - svga->hud.num_state_objects++; + svga->hud.num_depthstencil_objects++; return ds; } @@ -253,7 +253,7 @@ static void svga_delete_depth_stencil_state(struct pipe_context *pipe, } FREE(depth_stencil); - svga->hud.num_state_objects--; + svga->hud.num_depthstencil_objects--; } diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index 75bc9ce..4a06647 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -1164,7 +1164,12 @@ svga_get_query_result(struct pipe_context *pipe, vresult->u64 = svgascreen->hud.num_resources; break; case SVGA_QUERY_NUM_STATE_OBJECTS: - vresult->u64 = svga->hud.num_state_objects; + vresult->u64 = (svga->hud.num_blend_objects + + svga->hud.num_depthstencil_objects + + svga->hud.num_rasterizer_objects + + svga->hud.num_sampler_objects + + svga->hud.num_samplerview_objects + + svga->hud.num_vertexelement_objects); break; case SVGA_QUERY_NUM_SURFACE_VIEWS: vresult->u64 = svga->hud.num_surface_views; diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c index d397c95..968770c 100644 --- a/src/gallium/drivers/svga/svga_pipe_rasterizer.c +++ b/src/gallium/drivers/svga/svga_pipe_rasterizer.c @@ -360,7 +360,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe, "GL_POLYGON_SMOOTH not supported"); } - svga->hud.num_state_objects++; + svga->hud.num_rasterizer_objects++; return rast; } @@ -405,7 +405,7 @@ sv
Re: [Mesa-dev] [PATCH] svga: s/Elements/ARRAY_SIZE/
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Monday, April 25, 2016 8:48 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: s/Elements/ARRAY_SIZE/ Standardize on the later macro rather than a mix of both. --- src/gallium/drivers/svga/svga_cmd_vgpu10.c | 2 +- src/gallium/drivers/svga/svga_context.c | 6 +++--- src/gallium/drivers/svga/svga_format.c | 20 ++-- src/gallium/drivers/svga/svga_link.c | 6 +++--- src/gallium/drivers/svga/svga_pipe_constants.c | 2 +- src/gallium/drivers/svga/svga_pipe_sampler.c | 2 +- src/gallium/drivers/svga/svga_pipe_vs.c | 2 +- src/gallium/drivers/svga/svga_resource_texture.h | 2 +- src/gallium/drivers/svga/svga_sampler_view.c | 2 +- src/gallium/drivers/svga/svga_screen.c | 4 ++-- src/gallium/drivers/svga/svga_shader.c | 2 +- src/gallium/drivers/svga/svga_state_constants.c | 2 +- src/gallium/drivers/svga/svga_state_rss.c| 4 ++-- src/gallium/drivers/svga/svga_state_sampler.c| 2 +- src/gallium/drivers/svga/svga_state_tss.c| 10 +- src/gallium/drivers/svga/svga_swtnl_draw.c | 4 ++-- src/gallium/drivers/svga/svga_tgsi_decl_sm30.c | 8 src/gallium/drivers/svga/svga_tgsi_insn.c| 10 +- src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 20 ++-- 19 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/gallium/drivers/svga/svga_cmd_vgpu10.c b/src/gallium/drivers/svga/svga_cmd_vgpu10.c index 99c9add..2729655 100644 --- a/src/gallium/drivers/svga/svga_cmd_vgpu10.c +++ b/src/gallium/drivers/svga/svga_cmd_vgpu10.c @@ -1112,7 +1112,7 @@ SVGA3D_vgpu10_DefineStreamOutput(struct svga_winsys_context *swc, cmd->soid = soid; cmd->numOutputStreamEntries = numOutputStreamEntries; - for (i = 0; i < Elements(cmd->streamOutputStrideInBytes); i++) + for (i = 0; i < ARRAY_SIZE(cmd->streamOutputStrideInBytes); i++) cmd->streamOutputStrideInBytes[i] = streamOutputStrideInBytes[i]; memcpy(cmd->decl, decl, diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index 896dcdf..32dc209 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -61,7 +61,7 @@ static void svga_destroy( struct pipe_context *pipe ) unsigned shader, i; /* free any alternate rasterizer states used for point sprite */ - for (i = 0; i < Elements(svga->rasterizer_no_cull); i++) { + for (i = 0; i < ARRAY_SIZE(svga->rasterizer_no_cull); i++) { if (svga->rasterizer_no_cull[i]) { pipe->delete_rasterizer_state(pipe, svga->rasterizer_no_cull[i]); } @@ -78,7 +78,7 @@ static void svga_destroy( struct pipe_context *pipe ) pipe_resource_reference(&svga->polygon_stipple.texture, NULL); /* free HW constant buffers */ - for (shader = 0; shader < Elements(svga->state.hw_draw.constbuf); shader++) { + for (shader = 0; shader < ARRAY_SIZE(svga->state.hw_draw.constbuf); shader++) { pipe_resource_reference(&svga->state.hw_draw.constbuf[shader], NULL); } @@ -116,7 +116,7 @@ static void svga_destroy( struct pipe_context *pipe ) /* free user's constant buffers */ for (shader = 0; shader < PIPE_SHADER_TYPES; ++shader) { - for (i = 0; i < Elements(svga->curr.constbufs[shader]); ++i) { + for (i = 0; i < ARRAY_SIZE(svga->curr.constbufs[shader]); ++i) { pipe_resource_reference(&svga->curr.constbufs[shader][i].buffer, NULL); } } diff --git a/src/gallium/drivers/svga/svga_format.c b/src/gallium/drivers/svga/svga_format.c index 0186736..2fc920a 100644 --- a/src/gallium/drivers/svga/svga_format.c +++ b/src/gallium/drivers/svga/svga_format.c @@ -366,8 +366,8 @@ svga_translate_vertex_format_vgpu10(enum pipe_format format, SVGA3dSurfaceFormat *svga_format, unsigned *vf_flags) { - assert(format < Elements(format_conversion_table)); - if (format >= Elements(format_conversion_table)) { + assert(format < ARRAY_SIZE(format_conversion_table)); + if (format >= ARRAY_SIZE(format_conversion_table)) { format = PIPE_FORMAT_NONE; } *svga_format = format_conversion_table[format].vertex_format; @@ -1838,13 +1838,13 @@ check_format_tables(void) if (first_call) { unsigned i; - STATIC_ASSERT(Elements(format_cap_table) == SVGA3D_FORMAT_MAX); - for (i = 0; i < Elements(format_cap_table); i++) { + STATIC_ASSERT(ARRAY_SIZE(format_cap_table) == SVGA3D_FORMAT_MAX); + for (i = 0; i < ARRAY_SIZE(format_cap_table); i++) { assert(format_cap_table[i].format == i); } - STATIC_ASSERT(Elements(format_conversion_table) ==
Re: [Mesa-dev] [PATCH 3/9] draw: use tgsi transform prolog/epilog callbacks in AA point code
This series looks good. One nit below. >From: mesa-dev on behalf of Brian >Paul >Sent: Monday, September 22, 2014 8:44 AM >To: mesa-dev@lists.freedesktop.org >Subject: [Mesa-dev] [PATCH 3/9] draw: use tgsi transform prolog/epilog >callbacks in AA point code >This simplifies the code and makes it a little easier to understand. >--- > src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 621 > 1 file changed, 316 insertions(+), 305 deletions(-) >diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c >b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c ... > >+/** >+ * TGSI transform callback. >+ * Insert new instructions before the END instruction. >+ */ >+static void >+aa_transform_epilog(struct tgsi_transform_context *ctx) >+{ >+ /* emit our new declarations before the first instruction */ Please remove this comment. It's not relevant in aa_transform_epilog. Reviewed-by: Charmaine Lee ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=iVNYIcCaC9TDvyNBQU%2F5q5NVsC01tSgJb3oX27T14ck%3D%0A&m=WgIxyFTTxM%2BE0jPoNIA%2BgSV62SjHkS7A3w%2B0jxpKY08%3D%0A&s=c72fc3620bd437c978970304ed52bb176594a46d3730767e9ed7af9bb3374354 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] tgsi: fix Semantic.Name assignment in tgsi_transform_input_decl()
Reviewed-by: Charmaine Lee From: mesa-dev on behalf of Brian Paul Sent: Tuesday, September 30, 2014 9:31 AM To: mesa-dev@lists.freedesktop.org Subject: [Mesa-dev] [PATCH] tgsi: fix Semantic.Name assignment in tgsi_transform_input_decl() Assign the sem_name parameter, not TGSI_SEMANTIC_GENERIC. Fixes polygon stipple regression. --- src/gallium/auxiliary/tgsi/tgsi_transform.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.h b/src/gallium/auxiliary/tgsi/tgsi_transform.h index bfcdd56..921aa90 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_transform.h +++ b/src/gallium/auxiliary/tgsi/tgsi_transform.h @@ -120,7 +120,7 @@ tgsi_transform_input_decl(struct tgsi_transform_context *ctx, decl.Declaration.File = TGSI_FILE_INPUT; decl.Declaration.Interpolate = 1; decl.Declaration.Semantic = 1; - decl.Semantic.Name = TGSI_SEMANTIC_GENERIC; + decl.Semantic.Name = sem_name; decl.Semantic.Index = sem_index; decl.Range.First = decl.Range.Last = index; -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=iVNYIcCaC9TDvyNBQU%2F5q5NVsC01tSgJb3oX27T14ck%3D%0A&m=kdSMDzhhfBB7r7%2BtTT8ZJLsLWFgmZ6ruSleqmdygkOs%3D%0A&s=b935ac45947463251948f10239ee0f3612e74bc5601c500e5141ffdec63d0f32 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: use PIPE_BIND_DISPLAY_TARGET when checking for sRGB capability
Reviewed-by: Charmaine Lee From: mesa-dev on behalf of Brian Paul Sent: Monday, October 27, 2014 2:04 PM To: mesa-dev@lists.freedesktop.org Subject: [Mesa-dev] [PATCH] st/mesa: use PIPE_BIND_DISPLAY_TARGET when checking for sRGB capability When we're checking if the framebuffer is sRGB capable, call is_format_supported() with the PIPE_BIND_DISPLAY_TARGET flag. --- src/mesa/state_tracker/st_manager.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index df6de73..606d678 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -452,7 +452,8 @@ st_framebuffer_create(struct st_context *st, st_pipe_format_to_mesa_format(srgb_format) != MESA_FORMAT_NONE && screen->is_format_supported(screen, srgb_format, PIPE_TEXTURE_2D, stfbi->visual->samples, - PIPE_BIND_RENDER_TARGET)) + (PIPE_BIND_DISPLAY_TARGET | + PIPE_BIND_RENDER_TARGET))) mode.sRGBCapable = GL_TRUE; } -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=iVNYIcCaC9TDvyNBQU%2F5q5NVsC01tSgJb3oX27T14ck%3D%0A&m=CrIGk2ntPz44fnQBsxSY6VhHZNmuyJDOmQqvD52bwXU%3D%0A&s=731def1578a3e3879d2f8175ea73c078bd2f2208959d246d03c6a0a5da4a0653 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/7] util: simplify temp register selection in u_pstipple.c
The series looks good. Just a minor comment below. Reviewed-by: Charmaine Lee >From: mesa-dev on behalf of Brian >Paul >Sent: Thursday, October 30, 2014 8:04 PM >To: mesa-dev@lists.freedesktop.org >Subject: [Mesa-dev] [PATCH 4/7] util: simplify temp register selection in > u_pstipple.c >--- > src/gallium/auxiliary/util/u_pstipple.c | 30 -- > 1 file changed, 12 insertions(+), 18 deletions(-) >diff --git a/src/gallium/auxiliary/util/u_pstipple.c >b/src/gallium/auxiliary/util/u_pstipple.c index 5c6c8fc..ba80956 100644 >--- a/src/gallium/auxiliary/util/u_pstipple.c >+++ b/src/gallium/auxiliary/util/u_pstipple.c >@@ -267,7 +267,6 @@ pstip_transform_inst(struct tgsi_transform_context *ctx, > struct tgsi_full_declaration decl; > struct tgsi_full_instruction newInst; >- uint i; > int wincoordInput; > /* find free texture sampler */ >@@ -280,17 +279,10 @@ pstip_transform_inst(struct tgsi_transform_context *ctx, > else > wincoordInput = pctx->wincoordInput; >- /* find one free temp register */ >- for (i = 0; i < 32; i++) { >- if ((pctx->tempsUsed & (1 << i)) == 0) { >-/* found a free temp */ >-if (pctx->texTemp < 0) >- pctx->texTemp = i; >-else >- break; >- } >- } >- assert(pctx->texTemp >= 0); >+ /* We can always use temp[0] since this code is before >+ * the rest of the shader. >+ */ >+ pctx->texTemp = 0; Since texTemp is only used in this function, how about change it to a local variable. > if (pctx->wincoordInput < 0) { > /* declare new position input reg */ >@@ -313,12 +305,14 @@ pstip_transform_inst(struct tgsi_transform_context *ctx, > decl.Range.Last = pctx->freeSampler; > ctx->emit_declaration(ctx, &decl); >- /* declare new temp regs */ >- decl = tgsi_default_full_declaration(); >- decl.Declaration.File = TGSI_FILE_TEMPORARY; >- decl.Range.First = >- decl.Range.Last = pctx->texTemp; >- ctx->emit_declaration(ctx, &decl); >+ /* declare temp[0] reg if not already declared */ >+ if ((pctx->tempsUsed & 0x1) == 0) { >+ decl = tgsi_default_full_declaration(); >+ decl.Declaration.File = TGSI_FILE_TEMPORARY; >+ decl.Range.First = >+decl.Range.Last = pctx->texTemp; >+ ctx->emit_declaration(ctx, &decl); >+ } > /* emit immediate = {1/32, 1/32, 1, 1} >* The index/position of this immediate will be pctx->numImmed >-- >1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=dMTqrakxe895Y1JgK2Fm6G2IzlobZfMtVdJTlRk8YUY&m=D0L1pFoh8D-Bfo98T41gkzc5BsANmFzMe_KB7YgC2mo&s=jQkRRvIGaqEBbd_God8cylqHDWK4ikqLXfG5t3eP4zk&e= ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: implement a simple cache for glDrawPixels
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, February 18, 2016 7:52 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] st/mesa: implement a simple cache for glDrawPixels Instead of discarding the texture we created, keep it around in case the next glDrawPixels draws the same image again. This is intended to help application which draw the same image several times in a row, either within a frame or subsequent frames. --- src/mesa/state_tracker/st_cb_drawpixels.c | 85 +++ src/mesa/state_tracker/st_context.c | 4 ++ src/mesa/state_tracker/st_context.h | 8 +++ 3 files changed, 97 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index d1fe330..51d4ae5 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -73,6 +73,37 @@ /** + * We have a simple glDrawPixels cache to try to optimize the case where the + * same image is drawn over and over again. It basically works as follows: + * + * 1. After we construct a texture map with the image and draw it, we do + *not discard the texture. We keep it around, plus we note the + *glDrawPixels width, height, format, etc. parameters and keep a copy + *of the image in a malloc'd buffer. + * + * 2. On the next glDrawPixels we check if the parameters match the previous + *call. If those match, we check if the image matches the previous image + *via a memcmp() call. If everything matches, we re-use the previous + *texture, thereby avoiding the cost creating a new texture and copying + *the image to it. + * + * The effectiveness of this cache depends upon: + * 1. If the memcmp() finds a difference, it happens relatively quickly. + Hopefully, not just the last pixels differ! + * 2. If the memcmp() finds no difference, doing that check is faster than + *creating and loading a texture. + * + * Notes: + * 1. We don't support any pixel unpacking parameters. + * 2. We don't try to cache images in Pixel Buffer Objects. + * 3. Instead of saving the whole image, perhaps some sort of reliable + *checksum function could be used instead. + */ +#define USE_DRAWPIXELS_CACHE 1 + + + +/** * Create fragment program that does a TEX() instruction to get a Z and/or * stencil value value, then writes to FRAG_RESULT_DEPTH/FRAG_RESULT_STENCIL. * Used for glDrawPixels(GL_DEPTH_COMPONENT / GL_STENCIL_INDEX). @@ -347,6 +378,39 @@ make_texture(struct st_context *st, enum pipe_format pipeFormat; GLenum baseInternalFormat; +#if USE_DRAWPIXELS_CACHE + const GLint bpp = _mesa_bytes_per_pixel(format, type); + + /* Check if the glDrawPixels() parameters and state matches the cache */ + if (width == st->drawpix_cache.width && + height == st->drawpix_cache.height && + format == st->drawpix_cache.format && + type == st->drawpix_cache.type && + pixels == st->drawpix_cache.user_pointer && + !_mesa_is_bufferobj(unpack->BufferObj) && + (unpack->RowLength == 0 || unpack->RowLength == width) && + unpack->SkipPixels == 0 && + unpack->SkipRows == 0 && + unpack->SwapBytes == GL_FALSE && + st->drawpix_cache.image) { + /* check if the pixel data is the same */ + if (memcmp(pixels, st->drawpix_cache.image, width * height * bpp) == 0) { + /* OK, re-use the cached texture */ + return st->drawpix_cache.texture; + } + } + + /* discard the cached image and texture (if there is one) */ + st->drawpix_cache.width = 0; + st->drawpix_cache.height = 0; + st->drawpix_cache.user_pointer = NULL; + if (st->drawpix_cache.image) { + free(st->drawpix_cache.image); + st->drawpix_cache.image = NULL; + } + pipe_resource_reference(&st->drawpix_cache.texture, NULL); +#endif + /* Choose a pixel format for the temp texture which will hold the * image to draw. */ @@ -437,6 +501,25 @@ make_texture(struct st_context *st, _mesa_unmap_pbo_source(ctx, unpack); +#if USE_DRAWPIXELS_CACHE + /* Save the glDrawPixels parameter and image in the cache */ + if ((unpack->RowLength == 0 || unpack->RowLength == width) && + unpack->SkipPixels == 0 && + unpack->SkipRows == 0) { + st->drawpix_cache.width = width; + st->drawpix_cache.height = height; + st->drawpix_cache.format = format; + st->drawpix_cache.type = type; + st->drawpix_cache.user_pointer = pixels; + assert(!st->drawpix_cache.image); + st->drawpix_cache.image = malloc(width * height * bpp); + if (st->drawpix_cache.image) { + memcpy(st->drawpix_cache.image, pix
Re: [Mesa-dev] [PATCH] svga: allow non-contiguous VS input declarations
>From: Brian Paul >Sent: Thursday, February 18, 2016 7:51 AM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee >Subject: [PATCH] svga: allow non-contiguous VS input declarations > >This fixes a glDrawPixels regression since b63fe0552b5f. The new >quad-drawing utility code uses 3 vertex attributes (xyz, rgba, st). >For glDrawPixels path we don't use the rgba attribute so there's a >gap in the TGSI VS input declarations (INPUT[0] = pos, INPUT[2] = >texcoord). The TGSI->VGPU10 translations code did not handle this >correctly. I missed this because my VM was configured for HWv11 >while testing. > >Another way to fix this would be to change the tgsi_scan.c code so >that the tgsi_shader_info::num_inputs (and num_outputs) included >the unused inputs/outputs. These counts would then actually be >"max input register index + 1" rather than "number of used inputs". >But that change could impact all drivers so put it off for now. > >No regressions found with piglit or typical GL apps. >--- > src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c >b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c >index 1223e44..384fb9e 100644 >--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c >+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c >@@ -2446,7 +2446,7 @@ emit_input_declarations(struct svga_shader_emitter_v10 >*emit) >else { > assert(emit->unit == PIPE_SHADER_VERTEX); >> >- for (i = 0; i < emit->info.num_inputs; i++) { >+ for (i = 0; i < emit->info.file_max[TGSI_FILE_INPUT] + 1; i++) { > unsigned usage_mask = emit->info.input_usage_mask[i]; > unsigned index = i; num_inputs are referenced in other functions as well such as svga_get_generic_inputs_mask, don't we need to fix those as well? -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: allow non-contiguous VS input declarations
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, February 18, 2016 12:30 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: allow non-contiguous VS input declarations This fixes a glDrawPixels regression since b63fe0552b5f. The new quad-drawing utility code uses 3 vertex attributes (xyz, rgba, st). For glDrawPixels path we don't use the rgba attribute so there's a gap in the TGSI VS input declarations (INPUT[0] = pos, INPUT[2] = texcoord). The TGSI->VGPU10 translations code did not handle this correctly. I missed this because my VM was configured for HWv11 while testing. Another way to fix this would be to change the tgsi_scan.c code so that the tgsi_shader_info::num_inputs (and num_outputs) included the unused inputs/outputs. These counts would then actually be "max input register index + 1" rather than "number of used inputs". But that change could impact all drivers so put it off for now. No regressions found with piglit or typical GL apps. v2: also update alloc_system_value_index() to use info.file_max[] --- src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c index 1223e44..0c5afeb 100644 --- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c +++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c @@ -1782,7 +1782,7 @@ alloc_immediate_int4(struct svga_shader_emitter_v10 *emit, static unsigned alloc_system_value_index(struct svga_shader_emitter_v10 *emit, unsigned index) { - const unsigned n = emit->info.num_inputs + index; + const unsigned n = emit->info.file_max[TGSI_FILE_INPUT] + 1 + index; assert(index < Elements(emit->system_value_indexes)); emit->system_value_indexes[index] = n; return n; @@ -2446,7 +2446,7 @@ emit_input_declarations(struct svga_shader_emitter_v10 *emit) else { assert(emit->unit == PIPE_SHADER_VERTEX); - for (i = 0; i < emit->info.num_inputs; i++) { + for (i = 0; i < emit->info.file_max[TGSI_FILE_INPUT] + 1; i++) { unsigned usage_mask = emit->info.input_usage_mask[i]; unsigned index = i; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] svga: add new svga_winsys_context::get_command_buffer_size()
>From: Brian Paul >Sent: Monday, February 29, 2016 1:28 PM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee >Subject: [PATCH 2/3] svga: add new >svga_winsys_context::get_command_buffer_size() >To ask how large the current command buffer is. Will be used for >a new GALLIUM_HUD graph. >--- > src/gallium/drivers/svga/svga_winsys.h| 6 ++ > src/gallium/winsys/svga/drm/vmw_context.c | 8 > 2 files changed, 14 insertions(+) >diff --git a/src/gallium/drivers/svga/svga_winsys.h >b/src/gallium/drivers/svga/svga_winsys.h >index 2238d18..7da2c4e 100644 >--- a/src/gallium/drivers/svga/svga_winsys.h >+++ b/src/gallium/drivers/svga/svga_winsys.h >@@ -109,6 +109,12 @@ struct svga_winsys_context > uint32_t nr_bytes, uint32_t nr_relocs ); > >/** >+* Returns current size of command buffer, in bytes. >+*/ >+ unsigned >+ (*get_command_buffer_size)(struct svga_winsys_context *swc); >+ >+ /** > * Emit a relocation for a host surface. > * > * @param flags bitmask of SVGA_RELOC_* flags >diff --git a/src/gallium/winsys/svga/drm/vmw_context.c >b/src/gallium/winsys/svga/drm/vmw_context.c >index dae121e..3944733 100644 >--- a/src/gallium/winsys/svga/drm/vmw_context.c >+++ b/src/gallium/winsys/svga/drm/vmw_context.c >@@ -315,6 +315,13 @@ vmw_swc_reserve(struct svga_winsys_context *swc, >return vswc->command.buffer + vswc->command.used; > } > >+static unsigned >+vmw_wddm_swc_get_command_buffer_size(struct svga_winsys_context *swc) >+{ >+ const struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc); >+ return vswc->command.used; >+} >+ > static void > vmw_swc_context_relocation(struct svga_winsys_context *swc, > uint32 *cid) >@@ -761,6 +768,7 @@ vmw_svga_winsys_context_create(struct svga_winsys_screen >*sws) > >vswc->base.destroy = vmw_swc_destroy; >vswc->base.reserve = vmw_swc_reserve; >+ vswc->base.get_command_buffer_size = vmw_wddm_swc_get_command_buffer_size; >vswc->base.surface_relocation = vmw_swc_surface_relocation; >vswc->base.region_relocation = vmw_swc_region_relocation; >vswc->base.mob_relocation = vmw_swc_mob_relocation; >-- >1.9.1 Rename vmw_wddm_swc_get_command_buffer_size to vmw_swc_get_command_buffer_size. Other than that, the series looks fine to me. Reviewed-by: Charmaine Lee ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] svga: add new surface-write-flushes HUD query
For this series, Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, March 4, 2016 5:17 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 3/3] svga: add new surface-write-flushes HUD query To know when we're flushing the command buffer because we need to write to surface in the command buffer. --- src/gallium/drivers/svga/svga_context.h | 16 +--- src/gallium/drivers/svga/svga_pipe_query.c | 9 + src/gallium/drivers/svga/svga_resource_texture.c | 4 +++- src/gallium/drivers/svga/svga_screen.c | 2 ++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 61e82a2..1976f98 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -54,16 +54,17 @@ #define SVGA_QUERY_NUM_BYTES_UPLOADED (PIPE_QUERY_DRIVER_SPECIFIC + 6) #define SVGA_QUERY_COMMAND_BUFFER_SIZE (PIPE_QUERY_DRIVER_SPECIFIC + 7) #define SVGA_QUERY_FLUSH_TIME (PIPE_QUERY_DRIVER_SPECIFIC + 8) +#define SVGA_QUERY_SURFACE_WRITE_FLUSHES (PIPE_QUERY_DRIVER_SPECIFIC + 9) /* running total counters */ -#define SVGA_QUERY_MEMORY_USED (PIPE_QUERY_DRIVER_SPECIFIC + 9) -#define SVGA_QUERY_NUM_SHADERS (PIPE_QUERY_DRIVER_SPECIFIC + 10) -#define SVGA_QUERY_NUM_RESOURCES (PIPE_QUERY_DRIVER_SPECIFIC + 11) -#define SVGA_QUERY_NUM_STATE_OBJECTS (PIPE_QUERY_DRIVER_SPECIFIC + 12) -#define SVGA_QUERY_NUM_SURFACE_VIEWS (PIPE_QUERY_DRIVER_SPECIFIC + 13) -#define SVGA_QUERY_NUM_GENERATE_MIPMAP (PIPE_QUERY_DRIVER_SPECIFIC + 14) +#define SVGA_QUERY_MEMORY_USED (PIPE_QUERY_DRIVER_SPECIFIC + 10) +#define SVGA_QUERY_NUM_SHADERS (PIPE_QUERY_DRIVER_SPECIFIC + 11) +#define SVGA_QUERY_NUM_RESOURCES (PIPE_QUERY_DRIVER_SPECIFIC + 12) +#define SVGA_QUERY_NUM_STATE_OBJECTS (PIPE_QUERY_DRIVER_SPECIFIC + 13) +#define SVGA_QUERY_NUM_SURFACE_VIEWS (PIPE_QUERY_DRIVER_SPECIFIC + 14) +#define SVGA_QUERY_NUM_GENERATE_MIPMAP (PIPE_QUERY_DRIVER_SPECIFIC + 15) /*SVGA_QUERY_MAX has to be last because it is size of an array*/ -#define SVGA_QUERY_MAX (PIPE_QUERY_DRIVER_SPECIFIC + 15) +#define SVGA_QUERY_MAX (PIPE_QUERY_DRIVER_SPECIFIC + 16) /** * Maximum supported number of constant buffers per shader @@ -506,6 +507,7 @@ struct svga_context uint64_t num_resources_mapped; /**< SVGA_QUERY_NUM_RESOURCES_MAPPED */ uint64_t command_buffer_size; /**< SVGA_QUERY_COMMAND_BUFFER_SIZE */ uint64_t flush_time; /**< SVGA_QUERY_FLUSH_TIME */ + uint64_t surface_write_flushes; /**< SVGA_QUERY_SURFACE_WRITE_FLUSHES */ uint64_t num_shaders; /**< SVGA_QUERY_NUM_SHADERS */ uint64_t num_state_objects;/**< SVGA_QUERY_NUM_STATE_OBJECTS */ uint64_t num_surface_views;/**< SVGA_QUERY_NUM_SURFACE_VIEWS */ diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index 15decd4..845f4ef 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -729,6 +729,7 @@ svga_create_query(struct pipe_context *pipe, case SVGA_QUERY_NUM_BYTES_UPLOADED: case SVGA_QUERY_COMMAND_BUFFER_SIZE: case SVGA_QUERY_FLUSH_TIME: + case SVGA_QUERY_SURFACE_WRITE_FLUSHES: case SVGA_QUERY_MEMORY_USED: case SVGA_QUERY_NUM_SHADERS: case SVGA_QUERY_NUM_RESOURCES: @@ -800,6 +801,7 @@ svga_destroy_query(struct pipe_context *pipe, struct pipe_query *q) case SVGA_QUERY_NUM_BYTES_UPLOADED: case SVGA_QUERY_COMMAND_BUFFER_SIZE: case SVGA_QUERY_FLUSH_TIME: + case SVGA_QUERY_SURFACE_WRITE_FLUSHES: case SVGA_QUERY_MEMORY_USED: case SVGA_QUERY_NUM_SHADERS: case SVGA_QUERY_NUM_RESOURCES: @@ -894,6 +896,9 @@ svga_begin_query(struct pipe_context *pipe, struct pipe_query *q) case SVGA_QUERY_FLUSH_TIME: sq->begin_count = svga->hud.flush_time; break; + case SVGA_QUERY_SURFACE_WRITE_FLUSHES: + sq->begin_count = svga->hud.surface_write_flushes; + break; case SVGA_QUERY_MEMORY_USED: case SVGA_QUERY_NUM_SHADERS: case SVGA_QUERY_NUM_RESOURCES: @@ -994,6 +999,9 @@ svga_end_query(struct pipe_context *pipe, struct pipe_query *q) case SVGA_QUERY_FLUSH_TIME: sq->end_count = svga->hud.flush_time; break; + case SVGA_QUERY_SURFACE_WRITE_FLUSHES: + sq->end_count = svga->hud.surface_write_flushes; + break; case SVGA_QUERY_MEMORY_USED: case SVGA_QUERY_NUM_SHADERS: case SVGA_QUERY_NUM_RESOURCES: @@ -1094,6 +1102,7 @@ svga_get_query_result(struct pipe_context *pipe, case SVGA_QUERY_NUM_BYTES_UPLOADED: case SVGA_QUERY_COMMAND_BUFFER_SIZE: case SVGA_QUERY_FLUSH_TIME: + case SVGA_QUERY_SURFACE_WRITE
Re: [Mesa-dev] [PATCH] st/mesa: 78-column wrapping in st_extensions.c
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, March 4, 2016 5:17 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] st/mesa: 78-column wrapping in st_extensions.c --- src/mesa/state_tracker/st_extensions.c | 175 - 1 file changed, 107 insertions(+), 68 deletions(-) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 24c6444..063daae 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -109,23 +109,20 @@ void st_init_limits(struct pipe_screen *screen, _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), 1, MAX_DRAW_BUFFERS); - c->MaxDualSourceDrawBuffers - = _clamp(screen->get_param(screen, PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS), - 0, MAX_DRAW_BUFFERS); - - c->MaxLineWidth - = _maxf(1.0f, screen->get_paramf(screen, - PIPE_CAPF_MAX_LINE_WIDTH)); - c->MaxLineWidthAA - = _maxf(1.0f, screen->get_paramf(screen, - PIPE_CAPF_MAX_LINE_WIDTH_AA)); - - c->MaxPointSize - = _maxf(1.0f, screen->get_paramf(screen, - PIPE_CAPF_MAX_POINT_WIDTH)); - c->MaxPointSizeAA - = _maxf(1.0f, screen->get_paramf(screen, - PIPE_CAPF_MAX_POINT_WIDTH_AA)); + c->MaxDualSourceDrawBuffers = + _clamp(screen->get_param(screen, + PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS), + 0, MAX_DRAW_BUFFERS); + + c->MaxLineWidth = + _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_LINE_WIDTH)); + c->MaxLineWidthAA = + _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_LINE_WIDTH_AA)); + + c->MaxPointSize = + _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_POINT_WIDTH)); + c->MaxPointSizeAA = + _maxf(1.0f, screen->get_paramf(screen, PIPE_CAPF_MAX_POINT_WIDTH_AA)); /* these are not queryable. Note that GL basically mandates a 1.0 minimum * for non-aa sizes, but we can go down to 0.0 for aa points. @@ -133,15 +130,16 @@ void st_init_limits(struct pipe_screen *screen, c->MinPointSize = 1.0f; c->MinPointSizeAA = 0.0f; - c->MaxTextureMaxAnisotropy - = _maxf(2.0f, screen->get_paramf(screen, - PIPE_CAPF_MAX_TEXTURE_ANISOTROPY)); + c->MaxTextureMaxAnisotropy = + _maxf(2.0f, +screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY)); - c->MaxTextureLodBias - = screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_LOD_BIAS); + c->MaxTextureLodBias = + screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_LOD_BIAS); - c->QuadsFollowProvokingVertexConvention = screen->get_param( - screen, PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION); + c->QuadsFollowProvokingVertexConvention = + screen->get_param(screen, +PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION); c->MaxUniformBlockSize = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, @@ -195,21 +193,31 @@ void st_init_limits(struct pipe_screen *screen, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS), MAX_TEXTURE_IMAGE_UNITS); - pc->MaxInstructions= pc->MaxNativeInstructions= + pc->MaxInstructions = + pc->MaxNativeInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS); - pc->MaxAluInstructions = pc->MaxNativeAluInstructions = - screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS); - pc->MaxTexInstructions = pc->MaxNativeTexInstructions = - screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS); - pc->MaxTexIndirections = pc->MaxNativeTexIndirections = - screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS); - pc->MaxAttribs = pc->MaxNativeAttribs = + pc->MaxAluInstructions = + pc->MaxNativeAluInstructions = + screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS); + pc->MaxTexInstructions = + pc->MaxNativeTexInstructions = + screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS); + pc->MaxTexIndirections = + pc->MaxNativeTexIndirections = + screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS); + pc->MaxAttribs = + pc->MaxNativeAttribs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX
Re: [Mesa-dev] [PATCH 4/4] st/mesa: clean up st_translate_texture_target()
For the series: Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, March 16, 2016 5:43 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 4/4] st/mesa: clean up st_translate_texture_target() Reformat code. Improve assertion. --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 69 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 8772efb..8a12ce4 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -241,37 +241,56 @@ src_register( struct st_translate *t, * Map mesa texture target to TGSI texture target. */ unsigned -st_translate_texture_target( GLuint textarget, - GLboolean shadow ) +st_translate_texture_target(GLuint textarget, GLboolean shadow) { if (shadow) { - switch( textarget ) { - case TEXTURE_1D_INDEX: return TGSI_TEXTURE_SHADOW1D; - case TEXTURE_2D_INDEX: return TGSI_TEXTURE_SHADOW2D; - case TEXTURE_RECT_INDEX: return TGSI_TEXTURE_SHADOWRECT; - case TEXTURE_1D_ARRAY_INDEX: return TGSI_TEXTURE_SHADOW1D_ARRAY; - case TEXTURE_2D_ARRAY_INDEX: return TGSI_TEXTURE_SHADOW2D_ARRAY; - case TEXTURE_CUBE_INDEX: return TGSI_TEXTURE_SHADOWCUBE; - case TEXTURE_CUBE_ARRAY_INDEX: return TGSI_TEXTURE_SHADOWCUBE_ARRAY; - default: break; + switch (textarget) { + case TEXTURE_1D_INDEX: + return TGSI_TEXTURE_SHADOW1D; + case TEXTURE_2D_INDEX: + return TGSI_TEXTURE_SHADOW2D; + case TEXTURE_RECT_INDEX: + return TGSI_TEXTURE_SHADOWRECT; + case TEXTURE_1D_ARRAY_INDEX: + return TGSI_TEXTURE_SHADOW1D_ARRAY; + case TEXTURE_2D_ARRAY_INDEX: + return TGSI_TEXTURE_SHADOW2D_ARRAY; + case TEXTURE_CUBE_INDEX: + return TGSI_TEXTURE_SHADOWCUBE; + case TEXTURE_CUBE_ARRAY_INDEX: + return TGSI_TEXTURE_SHADOWCUBE_ARRAY; + default: + break; } } - switch( textarget ) { - case TEXTURE_2D_MULTISAMPLE_INDEX: return TGSI_TEXTURE_2D_MSAA; - case TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX: return TGSI_TEXTURE_2D_ARRAY_MSAA; - case TEXTURE_BUFFER_INDEX: return TGSI_TEXTURE_BUFFER; - case TEXTURE_1D_INDEX: return TGSI_TEXTURE_1D; - case TEXTURE_2D_INDEX: return TGSI_TEXTURE_2D; - case TEXTURE_3D_INDEX: return TGSI_TEXTURE_3D; - case TEXTURE_CUBE_INDEX: return TGSI_TEXTURE_CUBE; - case TEXTURE_CUBE_ARRAY_INDEX: return TGSI_TEXTURE_CUBE_ARRAY; - case TEXTURE_RECT_INDEX: return TGSI_TEXTURE_RECT; - case TEXTURE_1D_ARRAY_INDEX: return TGSI_TEXTURE_1D_ARRAY; - case TEXTURE_2D_ARRAY_INDEX: return TGSI_TEXTURE_2D_ARRAY; - case TEXTURE_EXTERNAL_INDEX: return TGSI_TEXTURE_2D; + switch (textarget) { + case TEXTURE_2D_MULTISAMPLE_INDEX: + return TGSI_TEXTURE_2D_MSAA; + case TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX: + return TGSI_TEXTURE_2D_ARRAY_MSAA; + case TEXTURE_BUFFER_INDEX: + return TGSI_TEXTURE_BUFFER; + case TEXTURE_1D_INDEX: + return TGSI_TEXTURE_1D; + case TEXTURE_2D_INDEX: + return TGSI_TEXTURE_2D; + case TEXTURE_3D_INDEX: + return TGSI_TEXTURE_3D; + case TEXTURE_CUBE_INDEX: + return TGSI_TEXTURE_CUBE; + case TEXTURE_CUBE_ARRAY_INDEX: + return TGSI_TEXTURE_CUBE_ARRAY; + case TEXTURE_RECT_INDEX: + return TGSI_TEXTURE_RECT; + case TEXTURE_1D_ARRAY_INDEX: + return TGSI_TEXTURE_1D_ARRAY; + case TEXTURE_2D_ARRAY_INDEX: + return TGSI_TEXTURE_2D_ARRAY; + case TEXTURE_EXTERNAL_INDEX: + return TGSI_TEXTURE_2D; default: - debug_assert( 0 ); + debug_assert(!"unexpected texture target index"); return TGSI_TEXTURE_1D; } } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 11/11] svga: use shader sampler view declarations
Series looks good to me. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, March 18, 2016 4:49 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 11/11] svga: use shader sampler view declarations Previously, we looked at the bound textures (via the pipe_sampler_views) to determine texture dimensions (1D/2D/3D/etc) and datatype (float vs. int). But this could fail in out of memory conditions. If we failed to allocate a texture and didn't create a pipe_sampler_view, we'd default to using 0 (PIPE_BUFFER) as the texture type. This led to device errors because of inconsistent shader code. This change relies on all TGSI shaders having an SVIEW declaration for each SAMP declaration. The previous patch series does that. --- src/gallium/drivers/svga/svga_shader.c | 16 +++--- src/gallium/drivers/svga/svga_shader.h | 3 +- src/gallium/drivers/svga/svga_tgsi_decl_sm30.c | 20 +-- src/gallium/drivers/svga/svga_tgsi_emit.h | 2 + src/gallium/drivers/svga/svga_tgsi_insn.c | 2 +- src/gallium/drivers/svga/svga_tgsi_vgpu10.c| 78 -- 6 files changed, 74 insertions(+), 47 deletions(-) diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c index 5c99e16..78eb3f6 100644 --- a/src/gallium/drivers/svga/svga_shader.c +++ b/src/gallium/drivers/svga/svga_shader.c @@ -180,18 +180,18 @@ svga_init_shader_key_common(const struct svga_context *svga, unsigned shader, assert(view->texture); assert(view->texture->target < (1 << 4)); /* texture_target:4 */ - key->tex[i].texture_target = view->texture->target; - /* 1D/2D array textures with one slice are treated as non-arrays * by the SVGA3D device. Convert the texture type here so that * we emit the right TEX/SAMPLE instruction in the shader. */ - if (view->texture->array_size == 1) { -if (view->texture->target == PIPE_TEXTURE_1D_ARRAY) { - key->tex[i].texture_target = PIPE_TEXTURE_1D; + if (view->texture->target == PIPE_TEXTURE_1D_ARRAY || + view->texture->target == PIPE_TEXTURE_2D_ARRAY) { +if (view->texture->array_size == 1) { + key->tex[i].is_array = 0; } -else if (view->texture->target == PIPE_TEXTURE_2D_ARRAY) { - key->tex[i].texture_target = PIPE_TEXTURE_2D; +else { + assert(view->texture->array_size > 1); + key->tex[i].is_array = 1; } } @@ -207,8 +207,6 @@ svga_init_shader_key_common(const struct svga_context *svga, unsigned shader, key->tex[i].swizzle_g = view->swizzle_g; key->tex[i].swizzle_b = view->swizzle_b; key->tex[i].swizzle_a = view->swizzle_a; - - key->tex[i].return_type = svga_get_texture_datatype(view->format); } } key->num_textures = svga->curr.num_sampler_views[shader]; diff --git a/src/gallium/drivers/svga/svga_shader.h b/src/gallium/drivers/svga/svga_shader.h index f49fdb4..3f91574 100644 --- a/src/gallium/drivers/svga/svga_shader.h +++ b/src/gallium/drivers/svga/svga_shader.h @@ -98,14 +98,13 @@ struct svga_compile_key unsigned compare_func:3; unsigned unnormalized:1; unsigned width_height_idx:5; /**< texture unit */ - unsigned texture_target:4; /**< PIPE_TEXTURE_x */ + unsigned is_array:1; unsigned texture_msaa:1;/**< A multisample texture? */ unsigned sprite_texgen:1; unsigned swizzle_r:3; unsigned swizzle_g:3; unsigned swizzle_b:3; unsigned swizzle_a:3; - unsigned return_type:3; /**< TGSI_RETURN_TYPE_x */ } tex[PIPE_MAX_SAMPLERS]; /* Note: svga_compile_keys_equal() depends on the variable-size * tex[] array being at the end of this structure. diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c index ca4009b..204b814 100644 --- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c +++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c @@ -517,15 +517,15 @@ vs30_output(struct svga_shader_emitter *emit, static ubyte svga_tgsi_sampler_type(const struct svga_shader_emitter *emit, int idx) { - switch (emit->key.tex[idx].texture_target) { - case PIPE_TEXTURE_1D: + switch (emit->sampler_target[idx]) { + case TGSI_TEXTURE_1D: return SVGA3DSAMP_2D; - case PIPE_TEXTURE_2D: - case PIPE_TEXTURE_RECT: + case TGSI_TEXTURE_2D: + case TGSI_TEXTURE_RECT: return SVGA3DSAMP_2D; - case PIPE_TEXTURE_3D: + case TGSI_TEXTURE_3D: return SVGA3DSAMP_VOLUME; - case PIPE_TEXTURE_CUBE: + case TGSI_TEXTURE_CUBE: return SVGA3DSAMP_CUBE; } @@ -585,6 +585
Re: [Mesa-dev] [PATCH] st/xa: emit sampler view declarations in shaders
Tested and Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, March 25, 2016 1:08 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] st/xa: emit sampler view declarations in shaders Fixes recent regressions with the VMware gallium driver. --- src/gallium/state_trackers/xa/xa_tgsi.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/src/gallium/state_trackers/xa/xa_tgsi.c b/src/gallium/state_trackers/xa/xa_tgsi.c index 5d8b807..a50393d 100644 --- a/src/gallium/state_trackers/xa/xa_tgsi.c +++ b/src/gallium/state_trackers/xa/xa_tgsi.c @@ -339,6 +339,16 @@ create_yuv_shader(struct pipe_context *pipe, struct ureg_program *ureg) u_sampler = ureg_DECL_sampler(ureg, 1); v_sampler = ureg_DECL_sampler(ureg, 2); +ureg_DECL_sampler_view(ureg, 0, TGSI_TEXTURE_2D, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT); +ureg_DECL_sampler_view(ureg, 1, TGSI_TEXTURE_2D, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT); +ureg_DECL_sampler_view(ureg, 2, TGSI_TEXTURE_2D, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT); + matrow0 = ureg_DECL_constant(ureg, 0); matrow1 = ureg_DECL_constant(ureg, 1); matrow2 = ureg_DECL_constant(ureg, 2); @@ -475,6 +485,9 @@ create_fs(struct pipe_context *pipe, unsigned fs_traits) } if (is_composite) { src_sampler = ureg_DECL_sampler(ureg, 0); +ureg_DECL_sampler_view(ureg, 0, TGSI_TEXTURE_2D, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT); src_input = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_GENERIC, 0, TGSI_INTERPOLATE_PERSPECTIVE); @@ -494,12 +507,18 @@ create_fs(struct pipe_context *pipe, unsigned fs_traits) if (has_mask) { mask_sampler = ureg_DECL_sampler(ureg, 1); +ureg_DECL_sampler_view(ureg, 1, TGSI_TEXTURE_2D, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT); mask_pos = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_GENERIC, 1, TGSI_INTERPOLATE_PERSPECTIVE); } #if 0 /* unused right now */ dst_sampler = ureg_DECL_sampler(ureg, 2); +ureg_DECL_sampler_view(ureg, 2, TGSI_TEXTURE_2D, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT, + TGSI_RETURN_TYPE_FLOAT, TGSI_RETURN_TYPE_FLOAT); dst_pos = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_POSITION, 2, TGSI_INTERPOLATE_PERSPECTIVE); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] svga: fix test for unfilled triangles fallback
This series looks good to me. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, May 26, 2016 7:09 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Roland Scheidegger Subject: [PATCH 2/2] svga: fix test for unfilled triangles fallback VGPU10 actually supports line-mode triangles. We failed to make use of that before. --- src/gallium/drivers/svga/svga_draw_arrays.c | 8 -- src/gallium/drivers/svga/svga_draw_elements.c | 3 +-- src/gallium/drivers/svga/svga_draw_private.h | 38 +-- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c index c056772..43d7a97 100644 --- a/src/gallium/drivers/svga/svga_draw_arrays.c +++ b/src/gallium/drivers/svga/svga_draw_arrays.c @@ -212,6 +212,11 @@ svga_hwtnl_draw_arrays(struct svga_hwtnl *hwtnl, unsigned api_pv = hwtnl->api_pv; struct svga_context *svga = hwtnl->svga; + if (svga->curr.rast->templ.fill_front != + svga->curr.rast->templ.fill_back) { + assert(hwtnl->api_fillmode == PIPE_POLYGON_MODE_FILL); + } + if (svga->curr.rast->templ.flatshade && svga->state.hw_draw.fs->constant_color_output) { /* The fragment color is a constant, not per-vertex so the whole @@ -236,8 +241,7 @@ svga_hwtnl_draw_arrays(struct svga_hwtnl *hwtnl, } } - if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL && - u_reduced_prim(prim) == PIPE_PRIM_TRIANGLES) { + if (svga_need_unfilled_fallback(hwtnl, prim)) { /* Convert unfilled polygons into points, lines, triangles */ gen_type = u_unfilled_generator(prim, start, diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index a987b92..b74c745 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -138,8 +138,7 @@ svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl, u_translate_func gen_func; enum pipe_error ret = PIPE_OK; - if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL && - u_reduced_prim(prim) == PIPE_PRIM_TRIANGLES) { + if (svga_need_unfilled_fallback(hwtnl, prim)) { gen_type = u_unfilled_translator(prim, index_size, count, diff --git a/src/gallium/drivers/svga/svga_draw_private.h b/src/gallium/drivers/svga/svga_draw_private.h index 48e0b60..da5d60e 100644 --- a/src/gallium/drivers/svga/svga_draw_private.h +++ b/src/gallium/drivers/svga/svga_draw_private.h @@ -29,6 +29,8 @@ #include "pipe/p_compiler.h" #include "pipe/p_defines.h" #include "indices/u_indices.h" +#include "util/u_prim.h" +#include "svga_context.h" #include "svga_hw_reg.h" #include "svga3d_shaderdefs.h" @@ -182,9 +184,41 @@ struct svga_hwtnl { -/*** - * Internal functions +/** + * Do we need to use the gallium 'indices' helper to render unfilled + * triangles? */ +static inline boolean +svga_need_unfilled_fallback(const struct svga_hwtnl *hwtnl, unsigned prim) +{ + const struct svga_context *svga = hwtnl->svga; + + if (u_reduced_prim(prim) != PIPE_PRIM_TRIANGLES) { + /* if we're drawing points or lines, no fallback needed */ + return FALSE; + } + + if (svga_have_vgpu10(svga)) { + /* vgpu10 supports polygon fill and line modes */ + if ((prim == PIPE_PRIM_QUADS || + prim == PIPE_PRIM_QUAD_STRIP || + prim == PIPE_PRIM_POLYGON) && + hwtnl->api_fillmode == PIPE_POLYGON_MODE_LINE) { + /* VGPU10 doesn't directly render quads or polygons. They're + * converted to triangles. If we let the device draw the triangle + * outlines we'll get an extra, stray lines in the interiors. + * So, to draw unfilled quads correctly, we need the fallback. + */ + return true; + } + return hwtnl->api_fillmode == PIPE_POLYGON_MODE_POINT; + } else { + /* vgpu9 doesn't support line or point fill modes */ + return hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL; + } +} + + enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl, const SVGA3dPrimitiveRange *range, -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] svga: remove unneeded casts in get_query_result_vgpu9() calls
Looks good. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, May 26, 2016 5:59 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 2/2] svga: remove unneeded casts in get_query_result_vgpu9() calls --- src/gallium/drivers/svga/svga_pipe_query.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index c1bd8ec..4febf9b 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -1078,7 +1078,7 @@ svga_get_query_result(struct pipe_context *pipe, (void *)&occResult, sizeof(occResult)); *result = (uint64_t)occResult.samplesRendered; } else { - ret = get_query_result_vgpu9(svga, sq, wait, (uint64_t *)result); + ret = get_query_result_vgpu9(svga, sq, wait, result); } break; case PIPE_QUERY_OCCLUSION_PREDICATE: { @@ -1089,7 +1089,7 @@ svga_get_query_result(struct pipe_context *pipe, vresult->b = occResult.anySamplesRendered != 0; } else { uint64_t count; - ret = get_query_result_vgpu9(svga, sq, wait, (uint64_t *)&count); + ret = get_query_result_vgpu9(svga, sq, wait, &count); vresult->b = count != 0; } break; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 6/6] llvmpipe: turn on pipe cap for GL_ARB_copy_image support
For the series: Reviewed-by: Charmaine Lee From: Brian Paul Sent: Tuesday, June 7, 2016 12:03 PM To: mesa-dev@lists.freedesktop.org Cc: Neha Bhende; Charmaine Lee Subject: [PATCH 6/6] llvmpipe: turn on pipe cap for GL_ARB_copy_image support --- src/gallium/drivers/llvmpipe/lp_screen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 50a6513..d252c7a 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -293,6 +293,8 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) return 1; case PIPE_CAP_CULL_DISTANCE: return 1; + case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS: + return 1; case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: @@ -301,7 +303,6 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_TGSI_TXQS: case PIPE_CAP_FORCE_PERSAMPLE_INTERP: case PIPE_CAP_SHAREABLE_SHADERS: - case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS: case PIPE_CAP_CLEAR_TEXTURE: case PIPE_CAP_DRAW_PARAMETERS: case PIPE_CAP_TGSI_PACK_HALF_FLOAT: -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: initialize pipe_driver_query_info entries with a macro
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Tuesday, December 8, 2015 4:35 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: initialize pipe_driver_query_info entries with a macro To be safe, set all the fields in case the enums ordering/values ever change. --- src/gallium/drivers/svga/svga_screen.c | 43 ++ 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 09a3d33..fca501b 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -780,26 +780,39 @@ svga_get_driver_query_info(struct pipe_screen *screen, unsigned index, struct pipe_driver_query_info *info) { +#define QUERY(NAME, ENUM, UNITS) \ + {NAME, ENUM, {0}, UNITS, PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE, 0, 0x0} + static const struct pipe_driver_query_info queries[] = { /* per-frame counters */ - {"num-draw-calls", SVGA_QUERY_NUM_DRAW_CALLS, {0}}, - {"num-fallbacks", SVGA_QUERY_NUM_FALLBACKS, {0}}, - {"num-flushes", SVGA_QUERY_NUM_FLUSHES, {0}}, - {"num-validations", SVGA_QUERY_NUM_VALIDATIONS, {0}}, - {"map-buffer-time", SVGA_QUERY_MAP_BUFFER_TIME, {0}, - PIPE_DRIVER_QUERY_TYPE_MICROSECONDS}, - {"num-resources-mapped", SVGA_QUERY_NUM_RESOURCES_MAPPED, {0}}, - {"num-bytes-uploaded", SVGA_QUERY_NUM_BYTES_UPLOADED, {0}, - PIPE_DRIVER_QUERY_TYPE_BYTES, PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE}, + QUERY("num-draw-calls", SVGA_QUERY_NUM_DRAW_CALLS, +PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("num-fallbacks", SVGA_QUERY_NUM_FALLBACKS, +PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("num-flushes", SVGA_QUERY_NUM_FLUSHES, +PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("num-validations", SVGA_QUERY_NUM_VALIDATIONS, +PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("map-buffer-time", SVGA_QUERY_MAP_BUFFER_TIME, +PIPE_DRIVER_QUERY_TYPE_MICROSECONDS), + QUERY("num-resources-mapped", SVGA_QUERY_NUM_RESOURCES_MAPPED, +PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("num-bytes-uploaded", SVGA_QUERY_NUM_BYTES_UPLOADED, +PIPE_DRIVER_QUERY_TYPE_BYTES), /* running total counters */ - {"memory-used", SVGA_QUERY_MEMORY_USED, {0}, - PIPE_DRIVER_QUERY_TYPE_BYTES}, - {"num-shaders", SVGA_QUERY_NUM_SHADERS, {0}}, - {"num-resources", SVGA_QUERY_NUM_RESOURCES, {0}}, - {"num-state-objects", SVGA_QUERY_NUM_STATE_OBJECTS, {0}}, - {"num-surface-views", SVGA_QUERY_NUM_SURFACE_VIEWS, {0}}, + QUERY("memory-used", SVGA_QUERY_MEMORY_USED, +PIPE_DRIVER_QUERY_TYPE_BYTES), + QUERY("num-shaders", SVGA_QUERY_NUM_SHADERS, +PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("num-resources", SVGA_QUERY_NUM_RESOURCES, +PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("num-state-objects", SVGA_QUERY_NUM_STATE_OBJECTS, +PIPE_DRIVER_QUERY_TYPE_UINT64), + QUERY("num-surface-views", SVGA_QUERY_NUM_SURFACE_VIEWS, +PIPE_DRIVER_QUERY_TYPE_UINT64), }; +#undef QUERY if (!info) return Elements(queries); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: avoid emitting redundant SetIndexBuffer commands
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, December 10, 2015 1:09 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Jose Fonseca Subject: [PATCH] svga: avoid emitting redundant SetIndexBuffer commands --- src/gallium/drivers/svga/svga_context.h | 4 src/gallium/drivers/svga/svga_draw.c| 17 - 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index c4284cc..db9491b 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -343,6 +343,10 @@ struct svga_hw_draw_state SVGA3dElementLayoutId layout_id; SVGA3dPrimitiveType topology; + struct svga_winsys_surface *ib; /**< index buffer for drawing */ + SVGA3dSurfaceFormat ib_format; + unsigned ib_offset; + /* used for rebinding */ unsigned num_sampler_views[PIPE_SHADER_TYPES]; unsigned default_constbuf_size[PIPE_SHADER_TYPES]; diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c index cca499a..2d3631d 100644 --- a/src/gallium/drivers/svga/svga_draw.c +++ b/src/gallium/drivers/svga/svga_draw.c @@ -539,11 +539,18 @@ draw_vgpu10(struct svga_hwtnl *hwtnl, SVGA3dSurfaceFormat indexFormat = xlate_index_format(range->indexWidth); /* setup index buffer */ - ret = SVGA3D_vgpu10_SetIndexBuffer(svga->swc, ib_handle, - indexFormat, - range->indexArray.offset); - if (ret != PIPE_OK) - return ret; + if (ib_handle != svga->state.hw_draw.ib || + indexFormat != svga->state.hw_draw.ib_format || + range->indexArray.offset != svga->state.hw_draw.ib_offset) { + ret = SVGA3D_vgpu10_SetIndexBuffer(svga->swc, ib_handle, +indexFormat, +range->indexArray.offset); + if (ret != PIPE_OK) +return ret; + svga->state.hw_draw.ib = ib_handle; + svga->state.hw_draw.ib_format = indexFormat; + svga->state.hw_draw.ib_offset = range->indexArray.offset; + } if (instance_count > 1) { ret = SVGA3D_vgpu10_DrawIndexedInstanced(svga->swc, -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: avoid emitting redundant SetSamplers() commands
>From: Brian Paul >Sent: Thursday, December 10, 2015 2:05 PM >To: mesa-dev@lists.freedesktop.org >Cc: Jose Fonseca; Charmaine Lee >Subject: [PATCH] svga: avoid emitting redundant SetSamplers() commands >This greatly reduces the number of SetSamplers() commands for some >applications. >--- > src/gallium/drivers/svga/svga_context.h | 3 +++ > src/gallium/drivers/svga/svga_state_sampler.c | 22 +++--- > 2 files changed, 18 insertions(+), 7 deletions(-) >diff --git a/src/gallium/drivers/svga/svga_context.h >b/src/gallium/drivers/svga/svga_context.h >index db9491b..78e346a 100644 >--- a/src/gallium/drivers/svga/svga_context.h >+++ b/src/gallium/drivers/svga/svga_context.h >@@ -347,6 +347,9 @@ struct svga_hw_draw_state >SVGA3dSurfaceFormat ib_format; >unsigned ib_offset; > >+ unsigned num_samplers[PIPE_SHADER_TYPES]; >+ SVGA3dSamplerId samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; >+ >/* used for rebinding */ >unsigned num_sampler_views[PIPE_SHADER_TYPES]; >unsigned default_constbuf_size[PIPE_SHADER_TYPES]; >diff --git a/src/gallium/drivers/svga/svga_state_sampler.c >b/src/gallium/drivers/svga/svga_state_sampler.c >index c5d52bb..b070f65 100644 >--- a/src/gallium/drivers/svga/svga_state_sampler.c >+++ b/src/gallium/drivers/svga/svga_state_sampler.c >@@ -301,13 +301,21 @@ update_samplers(struct svga_context *svga, unsigned >dirty ) > } > > if (count > 0) { >- ret = SVGA3D_vgpu10_SetSamplers(svga->swc, >- count, >- 0,/* start */ >- svga_shader_type(shader), /* type */ >- ids); >- if (ret != PIPE_OK) >-return ret; >+ if (count != svga->state.hw_draw.num_samplers[shader] || >+ memcmp(ids, svga->state.hw_draw.samplers[shader], >+count * sizeof(ids[0])) != 0) { >+/* HW state is really changing */ >+ret = SVGA3D_vgpu10_SetSamplers(svga->swc, >+count, >+0, /* start >*/ >+svga_shader_type(shader), /* type >*/ >+ids); >+if (ret != PIPE_OK) >+ return ret; >+memcpy(svga->state.hw_draw.samplers[shader], ids, >+ count * sizeof(ids[0])); >+svga->state.hw_draw.num_samplers[shader] = count; >+ } > } >} Don't we need to call SVGA3D_vgpu10_SetSamplers() to unbind the to-be-unbind sampler states? We should also remove the check for (count > 0). -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [Mesa-stable] [PATCH] mesa: fix prog_optimize.c assertions triggered by SWZ opcode
Reviewed-by: Charmaine Lee From: mesa-dev on behalf of Brian Paul Sent: Wednesday, September 17, 2014 2:56 PM To: mesa-dev@lists.freedesktop.org Subject: Re: [Mesa-dev] [Mesa-stable] [PATCH] mesa: fix prog_optimize.c assertions triggered by SWZ opcode Ping. Anyone? On 09/16/2014 03:19 PM, Brian Paul wrote: > The SWZ instruction can have swizzle terms >4 (SWIZZLE_ZERO, SWIZZLE_ONE). > These swizzle terms caused a few assertions to fail. > This started happening after the commit "mesa: Actually use the Mesa IR > optimizer for ARB programs." when replaying some apitrace files. > > A new piglit test (tests/asmparsertest/shaders/ARBfp1.0/swz-08.txt) > exercises this. > > Cc: "10.3" > --- > src/mesa/program/prog_optimize.c |9 - > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/src/mesa/program/prog_optimize.c > b/src/mesa/program/prog_optimize.c > index 08c1c30..60530eb 100644 > --- a/src/mesa/program/prog_optimize.c > +++ b/src/mesa/program/prog_optimize.c > @@ -114,7 +114,6 @@ get_src_arg_mask(const struct prog_instruction *inst, > read_mask = 0x0; > for (comp = 0; comp < 4; ++comp) { > const GLuint coord = GET_SWZ(inst->SrcReg[arg].Swizzle, comp); > - ASSERT(coord < 4); > if (channel_mask & (1 << comp) && coord <= SWIZZLE_W) >read_mask |= 1 << coord; > } > @@ -284,11 +283,11 @@ _mesa_remove_dead_code_global(struct gl_program *prog) > > for (comp = 0; comp < 4; comp++) { > const GLuint swz = GET_SWZ(inst->SrcReg[j].Swizzle, comp); > -ASSERT(swz < 4); > - if ((read_mask & (1 << swz)) == 0) > - continue; > - if (swz <= SWIZZLE_W) > + if (swz <= SWIZZLE_W) { > + if ((read_mask & (1 << swz)) == 0) > + continue; > tempRead[index][swz] = GL_TRUE; > + } > } >} > } > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=iVNYIcCaC9TDvyNBQU%2F5q5NVsC01tSgJb3oX27T14ck%3D%0A&m=3uQ%2FzrBnEVvp%2F4BkUGoEv2m55qILfsqhq8w4nNqOrq0%3D%0A&s=be2156d4b7ae5e1a5a5145845aa0b152da9a86515439487a65a1769bf9430df5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] gallium: increase pipe_sampler_view::target bitfield size for MSVC
Nice catch. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, November 1, 2017 7:45:29 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] gallium: increase pipe_sampler_view::target bitfield size for MSVC MSVC treats enums as being signed. The 4-bit target field isn't large enough to correctly store the value 8 (for PIPE_TEXTURE_CUBE_ARRAY). The bitfield value 0x8 was being interpreted as -8 so matching the target with PIPE_TEXTURE_CUBE_ARRAY in switch statements, etc. was failing. To keep the structure size the same, we reduce the format field from 16 bits to 15. There don't appear to be any other enum bitfields which need to be adjusted. This fixes a number of Piglit cube map array tests. --- src/gallium/include/pipe/p_state.h | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 10bf678..90dc561 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -34,6 +34,10 @@ * Basic notes: * 1. Want compact representations, so we use bitfields. * 2. Put bitfields before other (GLfloat) fields. + * 3. enum bitfields need to be at least one bit extra in size so the most + * significant bit is zero. MSVC treats enums as signed so if the high + * bit is set, the value will be interpreted as a negative number. + * That causes trouble in various places. */ @@ -436,8 +440,8 @@ struct pipe_surface struct pipe_sampler_view { struct pipe_reference reference; - enum pipe_format format:16; /**< typed PIPE_FORMAT_x */ - enum pipe_texture_target target:4; /**< PIPE_TEXTURE_x */ + enum pipe_format format:15; /**< typed PIPE_FORMAT_x */ + enum pipe_texture_target target:5; /**< PIPE_TEXTURE_x */ unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */ unsigned swizzle_g:3; /**< PIPE_SWIZZLE_x for green component */ unsigned swizzle_b:3; /**< PIPE_SWIZZLE_x for blue component */ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: use enum types instead of int/unsigned
For this series, Reviewed-by: Charmaine Lee From: Brian Paul Sent: Monday, November 6, 2017 1:00:30 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 1/2] st/mesa: use enum types instead of int/unsigned Use the proper enum types for various variables. Makes life in gdb a little nicer. --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 --- src/mesa/state_tracker/st_glsl_to_tgsi_private.h | 6 +++--- src/mesa/state_tracker/st_mesa_to_tgsi.c | 6 +++--- src/mesa/state_tracker/st_mesa_to_tgsi.h | 7 --- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 54e1961..2048b59 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -179,10 +179,10 @@ public: int num_address_regs; uint32_t samplers_used; glsl_base_type sampler_types[PIPE_MAX_SAMPLERS]; - int sampler_targets[PIPE_MAX_SAMPLERS]; /**< One of TGSI_TEXTURE_* */ + enum tgsi_texture_type sampler_targets[PIPE_MAX_SAMPLERS]; int images_used; int image_targets[PIPE_MAX_SHADER_IMAGES]; - unsigned image_formats[PIPE_MAX_SHADER_IMAGES]; + enum pipe_format image_formats[PIPE_MAX_SHADER_IMAGES]; bool indirect_addr_consts; int wpos_transform_const; @@ -6489,7 +6489,8 @@ st_translate_program( /* texture samplers */ for (i = 0; i < frag_const->MaxTextureImageUnits; i++) { if (program->samplers_used & (1u << i)) { - unsigned type = st_translate_texture_type(program->sampler_types[i]); + enum tgsi_return_type type = +st_translate_texture_type(program->sampler_types[i]); t->samplers[i] = ureg_DECL_sampler(ureg, i); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h index d57525d..bdc7448 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h @@ -127,13 +127,13 @@ public: unsigned is_64bit_expanded:1; unsigned sampler_base:5; unsigned sampler_array_size:6; /**< 1-based size of sampler array, 1 if not array */ - unsigned tex_target:4; /**< One of TEXTURE_*_INDEX */ + gl_texture_index tex_target:5; glsl_base_type tex_type:5; unsigned tex_shadow:1; - unsigned image_format:9; + enum pipe_format image_format:9; unsigned tex_offset_num_offset:3; unsigned dead_mask:4; /**< Used in dead code elimination */ - unsigned buffer_access:3; /**< buffer access type */ + unsigned buffer_access:3; /**< bitmask of TGSI_MEMORY_x bits */ const struct tgsi_opcode_info *info; }; diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index fa9fa44..8a61776 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -166,8 +166,8 @@ src_register( struct st_translate *t, /** * Map mesa texture target to TGSI texture target. */ -unsigned -st_translate_texture_target(GLuint textarget, GLboolean shadow) +enum tgsi_texture_type +st_translate_texture_target(gl_texture_index textarget, GLboolean shadow) { if (shadow) { switch (textarget) { @@ -225,7 +225,7 @@ st_translate_texture_target(GLuint textarget, GLboolean shadow) /** * Map GLSL base type to TGSI return type. */ -unsigned +enum tgsi_return_type st_translate_texture_type(enum glsl_base_type type) { switch (type) { diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index 106cf85..06e8b70 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -30,6 +30,7 @@ #define ST_MESA_TO_TGSI_H #include "main/glheader.h" +#include "main/mtypes.h" #include "pipe/p_compiler.h" #include "pipe/p_defines.h" @@ -62,10 +63,10 @@ st_translate_mesa_program( const ubyte outputSemanticName[], const ubyte outputSemanticIndex[]); -unsigned -st_translate_texture_target(GLuint textarget, GLboolean shadow); +enum tgsi_texture_type +st_translate_texture_target(gl_texture_index textarget, GLboolean shadow); -unsigned +enum tgsi_return_type st_translate_texture_type(enum glsl_base_type type); #if defined __cplusplus -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: Handle st_framebuffer_create returning NULL
Reviewed-by: Charmaine Lee From: Michel Dänzer Sent: Thursday, July 13, 2017 12:21 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Brian Paul Subject: [PATCH] st/mesa: Handle st_framebuffer_create returning NULL From: Michel Dänzer st_framebuffer_create returns NULL if stfbi == NULL or st_framebuffer_add_renderbuffer returns false for the colour buffer. Fixes Xorg crashing on startup using glamor on radeonsi. Fixes: 147d7fb772a7 ("st/mesa: add a winsys buffers list in st_context") Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D101775&d=DwIDaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ang1qmMo4GwCmRUnLE-f31kqPa6AOnoS-OAMUzQyM0M&m=UEU3ibcz-_bgA7gbDqxCJ-TuosvjQ-3MVZhk0YlAaHM&s=m4MMnUdTtDoBav5jZlfidkkA0ORGokAl9-djnste8Hw&e= Signed-off-by: Michel Dänzer --- src/mesa/state_tracker/st_manager.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index de16a3a2cf..348b456c4d 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -802,10 +802,12 @@ st_framebuffer_reuse_or_create(struct st_context *st, if (stfb == NULL) { cur = st_framebuffer_create(st, stfbi); - /* add to the context's winsys buffers list */ - LIST_ADD(&cur->head, &st->winsys_buffers); + if (cur) { + /* add to the context's winsys buffers list */ + LIST_ADD(&cur->head, &st->winsys_buffers); - st_framebuffer_reference(&stfb, cur); + st_framebuffer_reference(&stfb, cur); + } } return stfb; -- 2.13.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: handle stfbi being NULL on entry of st_framebuffer_reuse_or_create
Reviewed-by: Charmaine Lee From: Lucas Stach Sent: Thursday, July 13, 2017 10:01 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Brian Paul Subject: [PATCH] st/mesa: handle stfbi being NULL on entry of st_framebuffer_reuse_or_create Apparently this can happen. Just bail out early in that case, as all the called functions return NULL in that case. Fixes weston-terminal for me. Fixes: 147d7fb772a7 ("st/mesa: add a winsys buffers list in st_context") Signed-off-by: Lucas Stach --- src/mesa/state_tracker/st_manager.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 348b456c4d1d..d910eec00a16 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -788,6 +788,9 @@ st_framebuffer_reuse_or_create(struct st_context *st, { struct st_framebuffer *cur = NULL, *stfb = NULL; + if (!stfbi) + return NULL; + /* Check if there is already a framebuffer object for the specified * framebuffer interface in this context. If there is one, use it. */ -- 2.11.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/mesa: init winsys buffers list only if context creation succeeds
Fixes piglit test crash when context creation fails. --- src/mesa/state_tracker/st_context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 560d94e..8eccad6 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -574,11 +574,11 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe, st = st_create_context_priv(ctx, pipe, options, no_error); if (!st) { _mesa_destroy_context(ctx); + } else { + /* Initialize context's winsys buffers list */ + LIST_INITHEAD(&st->winsys_buffers); } - /* Initialize context's winsys buffers list */ - LIST_INITHEAD(&st->winsys_buffers); - return st; } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/mesa: init winsys buffers list only if context creation succeeds
Fixes piglit test crash when context creation fails. v2: As suggested by Brian, move the init to st_create_context_priv() --- src/mesa/state_tracker/st_context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 560d94e..381ff9d 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -476,6 +476,9 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, _mesa_initialize_vbo_vtxfmt(ctx); st_init_driver_flags(st); + /* Initialize context's winsys buffers list */ + LIST_INITHEAD(&st->winsys_buffers); + return st; } @@ -576,9 +579,6 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe, _mesa_destroy_context(ctx); } - /* Initialize context's winsys buffers list */ - LIST_INITHEAD(&st->winsys_buffers); - return st; } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/mesa: add destroy_drawable interface
With this patch, the st manager will maintain a hash table for the active framebuffer interface objects. A destroy_drawable interface is added to allow the state tracker to notify the st manager to remove the associated framebuffer interface object from the hash table, so the associated framebuffer and its resources can be deleted at framebuffers purge time. Fixes bug 101829 "read-after-free in st_framebuffer_validate" Tested-by: Brad King Tested-by: Gert Wollny --- src/gallium/include/state_tracker/st_api.h| 7 ++ src/gallium/state_trackers/dri/dri_drawable.c | 6 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 5 ++ src/gallium/state_trackers/glx/xlib/xm_st.c | 2 + src/gallium/state_trackers/wgl/stw_st.c | 6 +- src/mesa/state_tracker/st_manager.c | 95 ++- src/mesa/state_tracker/st_manager.h | 5 ++ 7 files changed, 123 insertions(+), 3 deletions(-) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 30a4866..9b660f7 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -552,6 +552,13 @@ struct st_api * Get the currently bound context in the calling thread. */ struct st_context_iface *(*get_current)(struct st_api *stapi); + + /** +* Notify the st manager the framebuffer interface object +* is no longer valid. +*/ + void (*destroy_drawable)(struct st_api *stapi, +struct st_framebuffer_iface *stfbi); }; /** diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 0cfdc30..c7df0f6 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -169,6 +169,8 @@ void dri_destroy_buffer(__DRIdrawable * dPriv) { struct dri_drawable *drawable = dri_drawable(dPriv); + struct dri_screen *screen = drawable->screen; + struct st_api *stapi = screen->st_api; int i; pipe_surface_reference(&drawable->drisw_surface, NULL); @@ -180,7 +182,9 @@ dri_destroy_buffer(__DRIdrawable * dPriv) swap_fences_unref(drawable); - drawable->base.ID = 0; + /* Notify the st manager that this drawable is no longer valid */ + stapi->destroy_drawable(stapi, &drawable->base); + FREE(drawable); } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 881dd44..e4b1e9d 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -595,6 +595,11 @@ xmesa_free_buffer(XMesaBuffer buffer) */ b->ws.drawable = 0; + /* Notify the st manager that the associated framebuffer interface + * object is no longer valid. + */ + stapi->destroy_drawable(stapi, buffer->stfb); + /* XXX we should move the buffer to a delete-pending list and destroy * the buffer until it is no longer current. */ diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index 9e30efa..6a0f4aa 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -273,6 +273,7 @@ xmesa_st_framebuffer_flush_front(struct st_context_iface *stctx, return ret; } +static uint32_t xmesa_stfbi_ID = 0; struct st_framebuffer_iface * xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b) @@ -302,6 +303,7 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b) stfbi->visual = &xstfb->stvis; stfbi->flush_front = xmesa_st_framebuffer_flush_front; stfbi->validate = xmesa_st_framebuffer_validate; + stfbi->ID = p_atomic_inc_return(&xmesa_stfbi_ID); p_atomic_set(&stfbi->stamp, 1); stfbi->st_manager_private = (void *) xstfb; diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c index c2844b0..85a8b17 100644 --- a/src/gallium/state_trackers/wgl/stw_st.c +++ b/src/gallium/state_trackers/wgl/stw_st.c @@ -256,7 +256,11 @@ stw_st_destroy_framebuffer_locked(struct st_framebuffer_iface *stfb) for (i = 0; i < ST_ATTACHMENT_COUNT; i++) pipe_resource_reference(&stwfb->textures[i], NULL); - stwfb->base.ID = 0; + /* Notify the st manager that the framebuffer interface is no +* longer valid. +*/ + stw_dev->stapi->destroy_drawable(stw_dev->stapi, &stwfb->base); + FREE(stwfb); } diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index cb816de..ebc7ca8 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -38,6 +38,7 @@ #include "main/fbobject.h" #include "main/renderbuffer.h" #include "main/version.h" +#include "util/hash_table.h" #include "st_texture.h" #include "st_context.h" @@ -59,6 +60,10 @@ #include "util/u_surface.h" #include "util/list.h
Re: [Mesa-dev] [PATCH] svga: only support 4x, 8x, 16x msaa
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, July 20, 2017 1:54 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH] svga: only support 4x, 8x, 16x msaa Skip 2x MSAA, for example, since it's seldom used and just bloats the list of pixel formats. --- src/gallium/drivers/svga/svga_screen.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 1ec91e5..77223c9 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -1116,6 +1116,11 @@ svga_screen_create(struct svga_winsys_screen *sws) get_uint_cap(sws, SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES, 0); } + /* We only support 4x, 8x, 16x MSAA */ + svgascreen->ms_samples &= ((1 << (4-1)) | + (1 << (8-1)) | + (1 << (16-1))); + /* Maximum number of constant buffers */ svgascreen->max_const_buffers = get_uint_cap(sws, SVGA3D_DEVCAP_DX_MAX_CONSTANT_BUFFERS, 1); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: add destroy_drawable interface
Hi Christoph, Can you provide an apitrace of the test that crashes? Thanks. -Charmaine From: mesa-dev on behalf of Christoph Haag Sent: Friday, July 21, 2017 4:52:41 PM To: mesa-dev@lists.freedesktop.org Subject: Re: [Mesa-dev] [PATCH] st/mesa: add destroy_drawable interface This patch breaks steam for me. Segfault backtrace: #0 0x0023 in ?? () No symbol table info available. #1 0xf6b1a417 in _mesa_hash_table_search (ht=0x585bb7e8, key=0x5820ee88) at hash_table.c:246 __PRETTY_FUNCTION__ = "_mesa_hash_table_search" #2 0xf6a4488e in st_framebuffer_iface_remove (stfbi=0x5820ee88) at state_tracker/st_manager.c:545 entry = 0xf6bb3038 #3 0xf6a448e5 in st_api_destroy_drawable (stapi=0xf7212bc0 , stfbi=0x5820ee88) at state_tracker/st_manager.c:564 No locals. #4 0xf6bb2b64 in dri_destroy_buffer (dPriv=0x57d62560) at dri_drawable.c:186 drawable = 0x5820ee88 screen = 0x57e1a0a8 stapi = 0xf7212bc0 i = 7 #5 0xf6bb132c in dri_put_drawable (pdp=0x57d62560) at dri_util.c:642 No locals. #6 0xf6bb145c in driDestroyDrawable (pdp=0x57d62560) at dri_util.c:695 No locals. #7 0xf759249a in loader_dri3_drawable_fini (draw=0x581fb0f0) at loader_dri3_helper.c:109 i = 1478471608 #8 0xf758ca73 in dri3_destroy_drawable (base=0x581fb0d0) at dri3_glx.c:366 pdraw = 0x581fb0d0 #9 0xf7583b5a in driReleaseDrawables (gc=0x57e19ef8) at dri_common.c:452 priv = 0x57e082d0 pdraw = 0x581fb0d0 #10 0xf758c679 in dri3_bind_context (context=0x57e19ef8, old=0x57e19ef8, draw=165675047, read=165675047) at dri3_glx.c:223 pcp = 0x57e19ef8 psc = 0x57e07608 pdraw = 0x5866eb28 pread = 0x5866eb28 dri_draw = 0x0 dri_read = 0x0 #11 0xf754cd12 in MakeContextCurrent (dpy=0x57c16f30, draw=165675047, read=165675047, gc_user=0x57e19ef8) at glxcurrent.c:228 gc = 0x57e19ef8 oldGC = 0x57e19ef8 #12 0xf754ce75 in glXMakeCurrent (dpy=0x57c16f30, draw=165675047, gc=0x57e19ef8) at glxcurrent.c:274 No locals. #13 0xeb48addb in ?? () from /home/chris/.local/share/Steam/ubuntu12_32/vgui2_s.so No symbol table info available. #14 0xeb48dd0e in ?? () from /home/chris/.local/share/Steam/ubuntu12_32/vgui2_s.so No symbol table info available. #15 0xeb49d81d in ?? () from /home/chris/.local/share/Steam/ubuntu12_32/vgui2_s.so No symbol table info available. #16 0xefd74193 in ?? () from /home/chris/.local/share/Steam/ubuntu12_32/steamui.so No symbol table info available. #17 0xefd76946 in ?? () from /home/chris/.local/share/Steam/ubuntu12_32/steamui.so No symbol table info available. #18 0xefd77f16 in ?? () from /home/chris/.local/share/Steam/ubuntu12_32/steamui.so No symbol table info available. #19 0x5663d660 in RunSteam(int, char**, bool) () No symbol table info available. #20 0x5663e5f3 in ?? () No symbol table info available. #21 0x56629aac in ?? () No symbol table info available. #22 0xf799a1d3 in __libc_start_main () from /usr/lib32/libc.so.6 No symbol table info available. #23 0x5662d159 in _start () No symbol table info available. On 20.07.2017 20:26, Charmaine Lee wrote: > With this patch, the st manager will maintain a hash table for > the active framebuffer interface objects. A destroy_drawable interface > is added to allow the state tracker to notify the st manager to remove > the associated framebuffer interface object from the hash table, > so the associated framebuffer and its resources can be deleted > at framebuffers purge time. > > Fixes bug 101829 "read-after-free in st_framebuffer_validate" > > Tested-by: Brad King > Tested-by: Gert Wollny > --- > src/gallium/include/state_tracker/st_api.h| 7 ++ > src/gallium/state_trackers/dri/dri_drawable.c | 6 +- > src/gallium/state_trackers/glx/xlib/xm_api.c | 5 ++ > src/gallium/state_trackers/glx/xlib/xm_st.c | 2 + > src/gallium/state_trackers/wgl/stw_st.c | 6 +- > src/mesa/state_tracker/st_manager.c | 95 > ++- > src/mesa/state_tracker/st_manager.h | 5 ++ > 7 files changed, 123 insertions(+), 3 deletions(-) > > diff --git a/src/gallium/include/state_tracker/st_api.h > b/src/gallium/include/state_tracker/st_api.h > index 30a4866..9b660f7 100644 > --- a/src/gallium/include/state_tracker/st_api.h > +++ b/src/gallium/include/state_tracker/st_api.h > @@ -552,6 +552,13 @@ struct st_api > * Get the currently bound context in the calling thread. > */ > struct st_context_iface *(*get_current)(struct st_api *stapi); > + > + /** > +* Notify the st manager the framebuffer interface object > +* is no longer valid. > +*/ > + void (*destroy_drawable)(struct st_api *stapi, > +struct st_framebuffer_iface *stfbi); > }; > > /** > diff --git a/sr
[Mesa-dev] [PATCH] st/mesa: create framebuffer iface hash table per st manager
With this patch, framebuffer interface hash table is created per state tracker manager. Fixes crash with steam. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101876 Fixes: 5124bf98239 ("st/mesa: add destroy_drawable interface") Tested-by: Christoph Haag --- src/gallium/include/state_tracker/st_api.h| 21 + src/gallium/state_trackers/dri/dri_drawable.c | 1 + src/gallium/state_trackers/dri/dri_screen.c | 3 + src/gallium/state_trackers/glx/xlib/xm_api.c | 3 + src/gallium/state_trackers/glx/xlib/xm_st.c | 1 + src/gallium/state_trackers/wgl/stw_device.c | 3 + src/gallium/state_trackers/wgl/stw_st.c | 1 + src/mesa/state_tracker/st_manager.c | 107 +++--- 8 files changed, 113 insertions(+), 27 deletions(-) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 9b660f7..bc62a69 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -284,6 +284,7 @@ struct st_context_attribs }; struct st_context_iface; +struct st_manager; /** * Represent a windowing system drawable. @@ -317,6 +318,11 @@ struct st_framebuffer_iface uint32_t ID; /** +* The state tracker manager that manages this object. +*/ + struct st_manager *state_manager; + + /** * Available for the state tracker manager to use. */ void *st_manager_private; @@ -376,6 +382,11 @@ struct st_context_iface void *st_manager_private; /** +* The state tracker manager that manages this object. +*/ + struct st_manager *state_manager; + + /** * The CSO context associated with this context in case we need to draw * something before swap buffers. */ @@ -483,6 +494,16 @@ struct st_manager */ void (*set_background_context)(struct st_context_iface *stctxi, struct util_queue_monitoring *queue_info); + + /** +* Destroy any private data used by the state tracker manager. +*/ + void (*destroy)(struct st_manager *smapi); + + /** +* Available for the state tracker manager to use. +*/ + void *st_manager_private; }; /** diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index c7df0f6..9e0dd6b 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -158,6 +158,7 @@ dri_create_buffer(__DRIscreen * sPriv, dPriv->driverPrivate = (void *)drawable; p_atomic_set(&drawable->base.stamp, 1); drawable->base.ID = p_atomic_inc_return(&drifb_ID); + drawable->base.state_manager = &screen->base; return GL_TRUE; fail: diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 1dd7bd3..59a850b 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -457,6 +457,9 @@ dri_destroy_option_cache(struct dri_screen * screen) void dri_destroy_screen_helper(struct dri_screen * screen) { + if (screen->base.destroy) + screen->base.destroy(&screen->base); + if (screen->st_api && screen->st_api->destroy) screen->st_api->destroy(screen->st_api); diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index e4b1e9d..828253b 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -181,6 +181,9 @@ xmesa_close_display(Display *display) *xmdpy->screen->destroy(xmdpy->screen); * } */ + + if (xmdpy->smapi->destroy) + xmdpy->smapi->destroy(xmdpy->smapi); free(xmdpy->smapi); XFree((char *) info); diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index 6a0f4aa..0c42e65 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -304,6 +304,7 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b) stfbi->flush_front = xmesa_st_framebuffer_flush_front; stfbi->validate = xmesa_st_framebuffer_validate; stfbi->ID = p_atomic_inc_return(&xmesa_stfbi_ID); + stfbi->state_manager = xmdpy->smapi; p_atomic_set(&stfbi->stamp, 1); stfbi->st_manager_private = (void *) xstfb; diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index 6c0f14d..b88e110 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -199,6 +199,9 @@ stw_cleanup(void) DeleteCriticalSection(&stw_dev->fb_mutex); DeleteCriticalSection(&stw_dev->ctx_mutex); + if (stw_dev->smapi->destroy) + stw_dev->smapi->destroy(stw_dev->smapi); + FREE(stw_dev->smapi); stw_dev->stapi->destroy(stw_dev->stapi); diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/
Re: [Mesa-dev] [PATCH 2/2] svga: implement MSAA alpha_to_one feature
>From: Brian Paul >Sent: Saturday, July 22, 2017 12:24 PM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee; Neha Bhende >Subject: [PATCH 2/2] svga: implement MSAA alpha_to_one feature >The device doesn't directly support this feature so we implement it with >additional shader code which sets the color output(s) w component to >1.0 (or max_int or max_uint). >Fixes 16 Piglit ext_framebuffer_multisample/*alpha-to-one* tests. >--- > src/gallium/drivers/svga/svga_context.h | 1 + > src/gallium/drivers/svga/svga_pipe_blend.c | 1 + > src/gallium/drivers/svga/svga_shader.h | 3 ++ > src/gallium/drivers/svga/svga_state_fs.c| 18 + > src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 61 - > 5 files changed, 83 insertions(+), 1 deletion(-) ... >diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c >b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c >index 9f5cd4b..8984ce5 100644 >--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c >+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c ... @@ -6378,6 +6393,47 @@ emit_pre_helpers(struct svga_shader_emitter_v10 *emit) > /** >+ * The device has no direct support for the pipe_blend_state::alpha_to_one >+ * option so we implement it here with shader code. >+ */ >+static void >+emit_alpha_to_one_instructions(struct svga_shader_emitter_v10 *emit, >+ unsigned fs_color_tmp_index) >+{ >+ unsigned i; >+ >+ for (i = 0; i < emit->fs.num_color_outputs; i++) { >+ struct tgsi_full_dst_register color_dst; >+ >+ if (fs_color_tmp_index != INVALID_INDEX && i == 0) { >+ /* write to the temp color register */ >+ color_dst = make_dst_temp_reg(fs_color_tmp_index); >+ } >+ else { >+ /* write directly to the color[i] output */ >+ color_dst = make_dst_output_reg(emit->fs.color_out_index[i]); >+ } >+ >+ color_dst = writemask_dst(&color_dst, TGSI_WRITEMASK_W); >+ >+ /* Depending on type of the render target, we either set alpha/w to >+ * 1.0f, or max(int) or max(uint). >+ */ >+ struct tgsi_full_src_register one; >+ if (emit->key.fs.int_render_target_mask & (1 << i)) { >+ one = make_immediate_reg_int(emit, 0x8fff); >+ } else if (emit->key.fs.uint_render_target_mask & (1 << i)) { >+ one = make_immediate_reg_int(emit, 0x); >+ } else { >+ one = make_immediate_reg_float(emit, 1.0f); >+ } How about moving the various "make one immediate" outside of the loop? No need to repeatedly looking for the same immediate. -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: add destroy_drawable interface
Hi Marek, I have pushed the fix for Steam. Commit bbc29393d3beaf6344c7188547b4ff61b63946ae should fix the problem. Can you please try? -Charmaine From: Marek Olšák Sent: Monday, July 24, 2017 3:16:07 PM To: Charmaine Lee Cc: Christoph Haag; mesa-dev@lists.freedesktop.org Subject: Re: [Mesa-dev] [PATCH] st/mesa: add destroy_drawable interface Hi Charmaine, Which commits do I need to revert in 17.2 to unbreak Steam on Mesa? I guess it's more than one. Thanks, Marek On Sat, Jul 22, 2017 at 3:05 AM, Charmaine Lee wrote: > > Hi Christoph, > > Can you provide an apitrace of the test that crashes? > > Thanks. > -Charmaine > > > From: mesa-dev on behalf of > Christoph Haag > Sent: Friday, July 21, 2017 4:52:41 PM > To: mesa-dev@lists.freedesktop.org > Subject: Re: [Mesa-dev] [PATCH] st/mesa: add destroy_drawable interface > > This patch breaks steam for me. Segfault backtrace: > > #0 0x0023 in ?? () > No symbol table info available. > #1 0xf6b1a417 in _mesa_hash_table_search (ht=0x585bb7e8, key=0x5820ee88) at > hash_table.c:246 > __PRETTY_FUNCTION__ = "_mesa_hash_table_search" > #2 0xf6a4488e in st_framebuffer_iface_remove (stfbi=0x5820ee88) at > state_tracker/st_manager.c:545 > entry = 0xf6bb3038 > #3 0xf6a448e5 in st_api_destroy_drawable (stapi=0xf7212bc0 , > stfbi=0x5820ee88) at state_tracker/st_manager.c:564 > No locals. > #4 0xf6bb2b64 in dri_destroy_buffer (dPriv=0x57d62560) at dri_drawable.c:186 > drawable = 0x5820ee88 > screen = 0x57e1a0a8 > stapi = 0xf7212bc0 > i = 7 > #5 0xf6bb132c in dri_put_drawable (pdp=0x57d62560) at dri_util.c:642 > No locals. > #6 0xf6bb145c in driDestroyDrawable (pdp=0x57d62560) at dri_util.c:695 > No locals. > #7 0xf759249a in loader_dri3_drawable_fini (draw=0x581fb0f0) at > loader_dri3_helper.c:109 > i = 1478471608 > #8 0xf758ca73 in dri3_destroy_drawable (base=0x581fb0d0) at dri3_glx.c:366 > pdraw = 0x581fb0d0 > #9 0xf7583b5a in driReleaseDrawables (gc=0x57e19ef8) at dri_common.c:452 > priv = 0x57e082d0 > pdraw = 0x581fb0d0 > #10 0xf758c679 in dri3_bind_context (context=0x57e19ef8, old=0x57e19ef8, > draw=165675047, read=165675047) at dri3_glx.c:223 > pcp = 0x57e19ef8 > psc = 0x57e07608 > pdraw = 0x5866eb28 > pread = 0x5866eb28 > dri_draw = 0x0 > dri_read = 0x0 > #11 0xf754cd12 in MakeContextCurrent (dpy=0x57c16f30, draw=165675047, > read=165675047, gc_user=0x57e19ef8) at glxcurrent.c:228 > gc = 0x57e19ef8 > oldGC = 0x57e19ef8 > #12 0xf754ce75 in glXMakeCurrent (dpy=0x57c16f30, draw=165675047, > gc=0x57e19ef8) at glxcurrent.c:274 > No locals. > #13 0xeb48addb in ?? () from > /home/chris/.local/share/Steam/ubuntu12_32/vgui2_s.so > No symbol table info available. > #14 0xeb48dd0e in ?? () from > /home/chris/.local/share/Steam/ubuntu12_32/vgui2_s.so > No symbol table info available. > #15 0xeb49d81d in ?? () from > /home/chris/.local/share/Steam/ubuntu12_32/vgui2_s.so > No symbol table info available. > #16 0xefd74193 in ?? () from > /home/chris/.local/share/Steam/ubuntu12_32/steamui.so > No symbol table info available. > #17 0xefd76946 in ?? () from > /home/chris/.local/share/Steam/ubuntu12_32/steamui.so > No symbol table info available. > #18 0xefd77f16 in ?? () from > /home/chris/.local/share/Steam/ubuntu12_32/steamui.so > No symbol table info available. > #19 0x5663d660 in RunSteam(int, char**, bool) () > No symbol table info available. > #20 0x5663e5f3 in ?? () > No symbol table info available. > #21 0x56629aac in ?? () > No symbol table info available. > #22 0xf799a1d3 in __libc_start_main () from /usr/lib32/libc.so.6 > No symbol table info available. > #23 0x5662d159 in _start () > No symbol table info available. > > > On 20.07.2017 20:26, Charmaine Lee wrote: >> With this patch, the st manager will maintain a hash table for >> the active framebuffer interface objects. A destroy_drawable interface >> is added to allow the state tracker to notify the st manager to remove >> the associated framebuffer interface object from the hash table, >> so the associated framebuffer and its resources can be deleted >> at framebuffers purge time. >> >> Fixes bug 101829 "read-after-free in st_framebuffer_validate" >> >> Tested-by: Brad King >> Tested-by: Gert Wollny >> --- >> src/gallium/include/state_tracker/st_api.h| 7 ++ >> src/gallium/state_trackers/dri/dri_drawable.c | 6 +- >> src/gallium/state_trackers/glx/xlib/xm_api.c | 5 +
Re: [Mesa-dev] [PATCH] st/mesa: create framebuffer iface hash table per st manager
>From: James Legg >Sent: Tuesday, July 25, 2017 6:24 AM >To: mesa-dev@lists.freedesktop.org; Charmaine Lee >Subject: Re: [Mesa-dev] [PATCH] st/mesa: create framebuffer iface hash table >per st manager >On Sun, 2017-07-23 at 16:37 -0700, Charmaine Lee wrote: >> With this patch, framebuffer interface hash table is created >> per state tracker manager. >> >> Fixes crash with steam. >> >> Bugzilla: >> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid->3D101876&d=DwICaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ang1qmMo4GwCmRUnLE-f31kqPa6AOnoS->OAMUzQyM0M&m=2ysMQPCeR_vf9ch72ej4wehfJ99Mtt9hBTroMbybY_o&s=xmTbTiDE9mV_SwkzVM08KH23S6vuWlerjRkqriB3>QOg&e= >> Fixes: 5124bf98239 ("st/mesa: add destroy_drawable interface") >> Tested-by: Christoph Haag >> --- a/src/mesa/state_tracker/st_manager.c >> >> @@ -511,45 +515,63 @@ st_framebuffer_iface_equal(const void *a, const void >> *b) >> >> >> static boolean >> -st_framebuffer_iface_lookup(const struct st_framebuffer_iface *stfbi) >> +st_framebuffer_iface_lookup(struct st_manager *smapi, >> +const struct st_framebuffer_iface *stfbi) >> { >> + struct st_manager_private *smPriv = >> + (struct st_manager_private *)smapi->st_manager_private; >> struct hash_entry *entry; >> >> - mtx_lock(&st_mutex); >> - entry = _mesa_hash_table_search(st_fbi_ht, stfbi); >> - mtx_unlock(&st_mutex); >> + assert(smPriv); >> + assert(smPriv->stfbi_ht); >> + >> + mtx_lock(&smPriv->st_mutex); >> + entry = _mesa_hash_table_search(smPriv->stfbi_ht, stfbi); >> + mtx_unlock(&smPriv->st_mutex); >> >> return entry != NULL; >> } >> >> >> static boolean >> -st_framebuffer_iface_insert(struct st_framebuffer_iface *stfbi) >> +st_framebuffer_iface_insert(struct st_manager *smapi, >> +struct st_framebuffer_iface *stfbi) >> { >> + struct st_manager_private *smPriv = >> + (struct st_manager_private *)smapi->st_manager_private; >> struct hash_entry *entry; >> >> - mtx_lock(&st_mutex); >> - entry = _mesa_hash_table_insert(st_fbi_ht, stfbi, stfbi); >> - mtx_unlock(&st_mutex); >> + assert(smPriv); >> + assert(smPriv->stfbi_ht); >> + >> + mtx_lock(&smPriv->st_mutex); >> + entry = _mesa_hash_table_insert(smPriv->stfbi_ht, stfbi, stfbi); >> + mtx_unlock(&smPriv->st_mutex); >> >> return entry != NULL; >> } >> >> >> static void >> -st_framebuffer_iface_remove(struct st_framebuffer_iface *stfbi) >> +st_framebuffer_iface_remove(struct st_manager *smapi, >> +struct st_framebuffer_iface *stfbi) >> { >> + struct st_manager_private *smPriv = >> + (struct st_manager_private *)smapi->st_manager_private; >> struct hash_entry *entry; >> >> - mtx_lock(&st_mutex); >> - entry = _mesa_hash_table_search(st_fbi_ht, stfbi); >> + if (!smPriv || !smPriv->stfbi_ht); >> + return; >The semicolon after the if causes the return to execute >unconditionally. Ah, good catch. Thanks. Will fix it. -Charmaine ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/mesa: fix the unconditional return in st_framebuffer_iface_remove
Fixes: bbc29393d3beaf6344c7188547b4ff61b63946ae Tested-by: Christoph Haag --- src/mesa/state_tracker/st_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 834bcc9..6447403 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -560,7 +560,7 @@ st_framebuffer_iface_remove(struct st_manager *smapi, (struct st_manager_private *)smapi->st_manager_private; struct hash_entry *entry; - if (!smPriv || !smPriv->stfbi_ht); + if (!smPriv || !smPriv->stfbi_ht) return; mtx_lock(&smPriv->st_mutex); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [Mesa-stable] [PATCH] st/mesa: add osmesa framebuffer iface hash table per st manager
Change looks good. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, August 2, 2017 8:30 PM To: Bruce Cherniak; mesa-dev@lists.freedesktop.org Cc: 17 . 2; Charmaine Lee Subject: Re: [Mesa-stable] [PATCH] st/mesa: add osmesa framebuffer iface hash table per st manager I'll let Charmaine review, but the subject line prefix should probably be "st/osmesa". -Brian On 08/02/2017 05:28 PM, Bruce Cherniak wrote: > Commit bbc29393d3 didn't include osmesa state_tracker. This patch adds > necessary initialization. > > Fixes crash in OSMesa initialization. > > Created-by: Charmaine Lee > Tested-by: Bruce Cherniak > > Cc: Charmaine Lee > Cc: 17.2 > --- > src/gallium/state_trackers/osmesa/osmesa.c | 11 +++ > 1 file changed, 11 insertions(+) > > diff --git a/src/gallium/state_trackers/osmesa/osmesa.c > b/src/gallium/state_trackers/osmesa/osmesa.c > index 18f1b88128..751d255c54 100644 > --- a/src/gallium/state_trackers/osmesa/osmesa.c > +++ b/src/gallium/state_trackers/osmesa/osmesa.c > @@ -439,6 +439,7 @@ osmesa_st_framebuffer_validate(struct st_context_iface > *stctx, > return TRUE; > } > > +static uint32_t osmesa_fb_ID = 0; > > static struct st_framebuffer_iface * > osmesa_create_st_framebuffer(void) > @@ -448,6 +449,8 @@ osmesa_create_st_framebuffer(void) > stfbi->flush_front = osmesa_st_framebuffer_flush_front; > stfbi->validate = osmesa_st_framebuffer_validate; > p_atomic_set(&stfbi->stamp, 1); > + stfbi->ID = p_atomic_inc_return(&osmesa_fb_ID); > + stfbi->state_manager = get_st_manager(); > } > return stfbi; > } > @@ -508,6 +511,14 @@ osmesa_find_buffer(enum pipe_format color_format, > static void > osmesa_destroy_buffer(struct osmesa_buffer *osbuffer) > { > + struct st_api *stapi = get_st_api(); > + > + /* > +* Notify the state manager that the associated framebuffer interface > +* is no longer valid. > +*/ > + stapi->destroy_drawable(stapi, osbuffer->stfb); > + > FREE(osbuffer->stfb); > FREE(osbuffer); > } > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] wglgears.c: add -srgb option
Series looks good. One typo below: >From: Brian Paul >Sent: Thursday, April 27, 2017 10:19 AM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee; Neha Bhende >Subject: [PATCH 1/2] wglgears.c: add -srgb option >To test sRGB pixel format selection and sRGB rendering. >This involves choosing a new pixel format, creating a new context, etc. >--- > src/wgl/wglgears.c | 91 -- > 1 file changed, 88 insertions(+), 3 deletions(-) >diff --git a/src/wgl/wglgears.c b/src/wgl/wglgears.c >index d90d603..7d43822 100644 >--- a/src/wgl/wglgears.c >+++ b/src/wgl/wglgears.c >@@ -30,6 +30,7 @@ > * 25th October 2004 > */ ... >+ if (use_srgb) { >+ /* For sRGB we need to use the wglChoosePixelFormatARB() function, >+ * and then create a new context, window, etc. >+ * >+ * Note: we can't query/use extension functions until after we've >+ * creatend and bound a rendering context. s/creatend/created BTW, can you also add a comment that we can only set the pixel format of the window once, so we need to create a new device context in order to use the pixel format returned from wglChoosePixelFormatARB. Other than that, Reviewed-by: Charmaine Lee ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] wglgears: fix up wglChoosePixelFormatARB() attribute list
Looks great. For the series, Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, May 3, 2017 12:49:40 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH 2/2] wglgears: fix up wglChoosePixelFormatARB() attribute list Specify WGL_DRAW_TO_WINDOW_ARB and WGL_COLOR_BITS_ARB. Improve some comments, per Charmaine. --- src/wgl/wglgears.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/wgl/wglgears.c b/src/wgl/wglgears.c index 7d43822..d673143 100644 --- a/src/wgl/wglgears.c +++ b/src/wgl/wglgears.c @@ -421,11 +421,12 @@ make_window(const char *name, int x, int y, int width, int height) } if (use_srgb) { - /* For sRGB we need to use the wglChoosePixelFormatARB() function, - * and then create a new context, window, etc. + /* We can't query/use extension functions until after we've + * created and bound a rendering context (done above). * - * Note: we can't query/use extension functions until after we've - * creatend and bound a rendering context. + * We can only set the pixel format of the window once, so we need to + * create a new device context in order to use the pixel format returned + * from wglChoosePixelFormatARB, and then create a new window. */ PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB_func = (PFNWGLCHOOSEPIXELFORMATARBPROC) @@ -434,8 +435,8 @@ make_window(const char *name, int x, int y, int width, int height) static const int int_attribs[] = { WGL_SUPPORT_OPENGL_ARB, TRUE, - //WGL_COLOR_BITS_ARB, 24, - //WGL_ALPHA_BITS_ARB, 8, + WGL_DRAW_TO_WINDOW_ARB, TRUE, + WGL_COLOR_BITS_ARB, 24, // at least 24-bits of RGB WGL_DEPTH_BITS_ARB, 24, WGL_DOUBLE_BUFFER_ARB, TRUE, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, TRUE, -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] mesa: s/GLint/gl_buffer_index/ for _ColorDrawBufferIndexes
For this series, Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, November 9, 2017 11:31:42 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH 3/3] mesa: s/GLint/gl_buffer_index/ for _ColorDrawBufferIndexes Also fix local variable declarations and replace -1 with BUFFER_NONE. No Piglit changes. --- src/mesa/drivers/common/meta.c | 2 +- src/mesa/main/buffers.c | 16 src/mesa/main/clear.c| 9 + src/mesa/main/framebuffer.c | 4 ++-- src/mesa/main/mtypes.h | 2 +- src/mesa/state_tracker/st_cb_clear.c | 4 ++-- src/mesa/state_tracker/st_cb_fbo.c | 4 ++-- src/mesa/swrast/s_blit.c | 8 src/mesa/swrast/s_renderbuffer.c | 4 ++-- 9 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index bae04be..1cc736c 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1655,7 +1655,7 @@ _mesa_meta_drawbuffers_and_colormask(struct gl_context *ctx, GLbitfield mask) enums[0] = GL_NONE; for (int i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { - int b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; + gl_buffer_index b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; int colormask_idx = ctx->Extensions.EXT_draw_buffers2 ? i : 0; if (b < 0 || !(mask & (1 << b)) || is_color_disabled(ctx, colormask_idx)) diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 5c37f0f..d364047 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -170,7 +170,7 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer) * Helper routine used by glReadBuffer. * Given a GLenum naming a color buffer, return the index of the corresponding * renderbuffer (a BUFFER_* value). - * return -1 for an invalid buffer. + * return BUFFER_NONE for an invalid buffer. */ static gl_buffer_index read_buffer_enum_to_index(const struct gl_context *ctx, GLenum buffer) @@ -719,7 +719,7 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, if (n > 0 && _mesa_bitcount(destMask[0]) > 1) { GLuint count = 0, destMask0 = destMask[0]; while (destMask0) { - const int bufIndex = u_bit_scan(&destMask0); + const gl_buffer_index bufIndex = u_bit_scan(&destMask0); if (fb->_ColorDrawBufferIndexes[count] != bufIndex) { updated_drawbuffers(ctx, fb); fb->_ColorDrawBufferIndexes[count] = bufIndex; @@ -733,7 +733,7 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, GLuint count = 0; for (buf = 0; buf < n; buf++ ) { if (destMask[buf]) { -GLint bufIndex = ffs(destMask[buf]) - 1; +gl_buffer_index bufIndex = ffs(destMask[buf]) - 1; /* only one bit should be set in the destMask[buf] field */ assert(_mesa_bitcount(destMask[buf]) == 1); if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) { @@ -743,9 +743,9 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, count = buf + 1; } else { -if (fb->_ColorDrawBufferIndexes[buf] != -1) { +if (fb->_ColorDrawBufferIndexes[buf] != BUFFER_NONE) { updated_drawbuffers(ctx, fb); - fb->_ColorDrawBufferIndexes[buf] = -1; + fb->_ColorDrawBufferIndexes[buf] = BUFFER_NONE; } } fb->ColorDrawBuffer[buf] = buffers[buf]; @@ -753,11 +753,11 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, fb->_NumColorDrawBuffers = count; } - /* set remaining outputs to -1 (GL_NONE) */ + /* set remaining outputs to BUFFER_NONE */ for (buf = fb->_NumColorDrawBuffers; buf < ctx->Const.MaxDrawBuffers; buf++) { - if (fb->_ColorDrawBufferIndexes[buf] != -1) { + if (fb->_ColorDrawBufferIndexes[buf] != BUFFER_NONE) { updated_drawbuffers(ctx, fb); - fb->_ColorDrawBufferIndexes[buf] = -1; + fb->_ColorDrawBufferIndexes[buf] = BUFFER_NONE; } } for (buf = n; buf < ctx->Const.MaxDrawBuffers; buf++) { diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c index c5e7f13..be60442 100644 --- a/src/mesa/main/clear.c +++ b/src/mesa/main/clear.c @@ -194,9 +194,9 @@ clear(struct gl_context *ctx, GLbitfield mask, bool no_error) if (mask & GL_COLOR_BUFFER_BIT) { GLuint i; for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { -GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; +gl_buffer_index buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; -if (buf >= 0 &a
Re: [Mesa-dev] [PATCH] st/mesa: remove 'struct' keyword on function parameter
Reviewed-by; Charmaine Lee From: Brian Paul Sent: Thursday, November 9, 2017 11:31:16 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] st/mesa: remove 'struct' keyword on function parameter st_src_reg is a class, not a struct. Simply remove 'struct' to silence a MSVC compiler warning (class vs. struct mismatch). --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index ca04765..3dc0237 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4590,8 +4590,7 @@ glsl_to_tgsi_visitor::simplify_cmp(void) } static void -rename_temp_handle_src(struct rename_reg_pair *renames, - struct st_src_reg *src) +rename_temp_handle_src(struct rename_reg_pair *renames, st_src_reg *src) { if (src && src->file == PROGRAM_TEMPORARY) { int old_idx = src->index; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: issue debug warning for unsupported two-sided stencil state
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, November 10, 2017 6:40:26 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: issue debug warning for unsupported two-sided stencil state We only have a single stencil read mask and write mask. Issue a warning if different front/back values are used. The Piglit gl-2.0-two-sided-stencil test hits this. --- src/gallium/drivers/svga/svga_pipe_depthstencil.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/src/gallium/drivers/svga/svga_pipe_depthstencil.c b/src/gallium/drivers/svga/svga_pipe_depthstencil.c index 1b62290..e5caa4b 100644 --- a/src/gallium/drivers/svga/svga_pipe_depthstencil.c +++ b/src/gallium/drivers/svga/svga_pipe_depthstencil.c @@ -172,6 +172,21 @@ svga_create_depth_stencil_state(struct pipe_context *pipe, ds->stencil_mask = templ->stencil[1].valuemask & 0xff; ds->stencil_writemask = templ->stencil[1].writemask & 0xff; + + if (templ->stencil[1].valuemask != templ->stencil[0].valuemask) { + pipe_debug_message(&svga->debug.callback, CONFORMANCE, +"two-sided stencil mask not supported " +"(front=0x%x, back=0x%x)", +templ->stencil[0].valuemask, +templ->stencil[1].valuemask); + } + if (templ->stencil[1].writemask != templ->stencil[0].writemask) { + pipe_debug_message(&svga->debug.callback, CONFORMANCE, +"two-sided stencil writemask not supported " +"(front=0x%x, back=0x%x)", +templ->stencil[0].writemask, +templ->stencil[1].writemask); + } } else { /* back face state is same as front-face state */ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] tgsi: s/unsigned/enum tgsi_texture_type/
>From: Brian Paul >Sent: Tuesday, November 14, 2017 3:42 PM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee; Neha Bhende >Subject: [PATCH 1/2] tgsi: s/unsigned/enum tgsi_texture_type/ ... >diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.h >b/src/gallium/auxiliary/tgsi/tgsi_util.h >index 534b5f7..6d56c5b 100644 >--- a/src/gallium/auxiliary/tgsi/tgsi_util.h >+++ b/src/gallium/auxiliary/tgsi/tgsi_util.h >@@ -82,24 +82,24 @@ struct tgsi_src_register > tgsi_util_get_src_from_ind(const struct tgsi_ind_register *reg); > int >-tgsi_util_get_texture_coord_dim(unsigned tgsi_tex); >+tgsi_util_get_texture_coord_dim(enum tgsi_texture_type tgsi_tex); > int >-tgsi_util_get_shadow_ref_src_index(unsigned tgsi_tex); >+tgsi_util_get_shadow_ref_src_index(enum tgsi_texture_type tgsi_tex); > boolean >-tgsi_is_shadow_target(unsigned target); >+tgsi_is_shadow_target(enum tgsi_texture_type); Lets add the argument name "target" back to be consistent with the rest. Other than that, this series looks good to me. Reviewed-by: Charmaine Lee ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: add missing PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER* cases
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, November 16, 2017 3:36:15 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH] svga: add missing PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER* cases --- src/gallium/drivers/svga/svga_screen.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 8621640..ab604b9 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -708,6 +708,8 @@ vgpu10_get_shader_param(struct pipe_screen *screen, case PIPE_SHADER_CAP_LOWER_IF_THRESHOLD: case PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS: case PIPE_SHADER_CAP_INT64_ATOMICS: + case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: + case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: return 0; case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT: return 32; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] tgsi: bump tgsi_opcode_info::output_mode size to 4 bits
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, November 17, 2017 2:40:01 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende; Roland Scheidegger Subject: [PATCH] tgsi: bump tgsi_opcode_info::output_mode size to 4 bits To avoid problems with MSVC. And verify size with ASSERT_BITFIELD_SIZE(). --- src/gallium/auxiliary/tgsi/tgsi_info.c | 2 ++ src/gallium/auxiliary/tgsi/tgsi_info.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index c39de0e..2baed5b 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -56,6 +56,8 @@ tgsi_get_opcode_info( uint opcode ) static boolean firsttime = 1; ASSERT_BITFIELD_SIZE(struct tgsi_opcode_info, opcode, TGSI_OPCODE_LAST - 1); + ASSERT_BITFIELD_SIZE(struct tgsi_opcode_info, output_mode, +TGSI_OUTPUT_OTHER); if (firsttime) { unsigned i; diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.h b/src/gallium/auxiliary/tgsi/tgsi_info.h index 8d32f47..bbd86c6 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.h +++ b/src/gallium/auxiliary/tgsi/tgsi_info.h @@ -78,7 +78,7 @@ struct tgsi_opcode_info unsigned is_branch:1; unsigned pre_dedent:1; unsigned post_indent:1; - enum tgsi_output_mode output_mode:3; + enum tgsi_output_mode output_mode:4; unsigned opcode:8; }; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] svga: move svga_is_format_supported() to svga_format.c
Series looks good. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Tuesday, November 21, 2017 6:33:22 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH 2/2] svga: move svga_is_format_supported() to svga_format.c where the other format-related functions live. --- src/gallium/drivers/svga/svga_format.c | 119 src/gallium/drivers/svga/svga_format.h | 10 +++ src/gallium/drivers/svga/svga_screen.c | 121 - 3 files changed, 129 insertions(+), 121 deletions(-) diff --git a/src/gallium/drivers/svga/svga_format.c b/src/gallium/drivers/svga/svga_format.c index f5265a1..964923f 100644 --- a/src/gallium/drivers/svga/svga_format.c +++ b/src/gallium/drivers/svga/svga_format.c @@ -2070,3 +2070,122 @@ svga_linear_to_srgb(SVGA3dSurfaceFormat format) return format; } } + + +/** + * Implement pipe_screen::is_format_supported(). + * \param bindings bitmask of PIPE_BIND_x flags + */ +boolean +svga_is_format_supported(struct pipe_screen *screen, + enum pipe_format format, + enum pipe_texture_target target, + unsigned sample_count, + unsigned bindings) +{ + struct svga_screen *ss = svga_screen(screen); + SVGA3dSurfaceFormat svga_format; + SVGA3dSurfaceFormatCaps caps; + SVGA3dSurfaceFormatCaps mask; + + assert(bindings); + + if (sample_count > 1) { + /* In ms_samples, if bit N is set it means that we support + * multisample with N+1 samples per pixel. + */ + if ((ss->ms_samples & (1 << (sample_count - 1))) == 0) { + return FALSE; + } + } + + svga_format = svga_translate_format(ss, format, bindings); + if (svga_format == SVGA3D_FORMAT_INVALID) { + return FALSE; + } + + if (!ss->sws->have_vgpu10 && + util_format_is_srgb(format) && + (bindings & PIPE_BIND_DISPLAY_TARGET)) { + /* We only support sRGB rendering with vgpu10 */ + return FALSE; + } + + /* +* For VGPU10 vertex formats, skip querying host capabilities +*/ + + if (ss->sws->have_vgpu10 && (bindings & PIPE_BIND_VERTEX_BUFFER)) { + SVGA3dSurfaceFormat svga_format; + unsigned flags; + svga_translate_vertex_format_vgpu10(format, &svga_format, &flags); + return svga_format != SVGA3D_FORMAT_INVALID; + } + + /* +* Override host capabilities, so that we end up with the same +* visuals for all virtual hardware implementations. +*/ + if (bindings & PIPE_BIND_DISPLAY_TARGET) { + switch (svga_format) { + case SVGA3D_A8R8G8B8: + case SVGA3D_X8R8G8B8: + case SVGA3D_R5G6B5: + break; + + /* VGPU10 formats */ + case SVGA3D_B8G8R8A8_UNORM: + case SVGA3D_B8G8R8X8_UNORM: + case SVGA3D_B5G6R5_UNORM: + case SVGA3D_B8G8R8X8_UNORM_SRGB: + case SVGA3D_B8G8R8A8_UNORM_SRGB: + case SVGA3D_R8G8B8A8_UNORM_SRGB: + break; + + /* Often unsupported/problematic. This means we end up with the same + * visuals for all virtual hardware implementations. + */ + case SVGA3D_A4R4G4B4: + case SVGA3D_A1R5G5B5: + return FALSE; + + default: + return FALSE; + } + } + + /* +* Query the host capabilities. +*/ + svga_get_format_cap(ss, svga_format, &caps); + + if (bindings & PIPE_BIND_RENDER_TARGET) { + /* Check that the color surface is blendable, unless it's an + * integer format. + */ + if (!svga_format_is_integer(svga_format) && + (caps.value & SVGA3DFORMAT_OP_NOALPHABLEND)) { + return FALSE; + } + } + + mask.value = 0; + if (bindings & PIPE_BIND_RENDER_TARGET) { + mask.value |= SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET; + } + if (bindings & PIPE_BIND_DEPTH_STENCIL) { + mask.value |= SVGA3DFORMAT_OP_ZSTENCIL; + } + if (bindings & PIPE_BIND_SAMPLER_VIEW) { + mask.value |= SVGA3DFORMAT_OP_TEXTURE; + } + + if (target == PIPE_TEXTURE_CUBE) { + mask.value |= SVGA3DFORMAT_OP_CUBETEXTURE; + } + else if (target == PIPE_TEXTURE_3D) { + mask.value |= SVGA3DFORMAT_OP_VOLUMETEXTURE; + } + + return (caps.value & mask.value) == mask.value; +} diff --git a/src/gallium/drivers/svga/svga_format.h b/src/gallium/drivers/svga/svga_format.h index 55d89ed..c063589 100644 --- a/src/gallium/drivers/svga/svga_format.h +++ b/src/gallium/drivers/svga/svga_format.h @@ -120,4 +120,14 @@ svga_format_is_shareable(const struct svga_screen *ss, SVGA3dSurfaceFormat svga_linear_to_srgb(SVGA3dSurfaceFormat format); + + +boolean +svga_is_format_supported(struct pipe_screen *screen, + enum pipe_format format, + enum pipe_texture_target target, + u
Re: [Mesa-dev] [PATCH 2/2] draw: check for line_width != 1.0f in validate_pipeline()
For the series, Reviewed-by: Charmaine Lee From: Brian Paul Sent: Thursday, June 15, 2017 10:42:00 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH 2/2] draw: check for line_width != 1.0f in validate_pipeline() We shouldn't use the wide line stage if the line width is 1. This check isn't strictly needed because all drivers are (now) specifying a line wide threshold of at least 1.0 pixels, but let's play it safe. --- src/gallium/auxiliary/draw/draw_pipe_validate.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c index 01d0759..846cd4d 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_validate.c +++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c @@ -156,9 +156,10 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) */ stage->next = next; - /* drawing wide lines? */ - wide_lines = (roundf(rast->line_width) > draw->pipeline.wide_line_threshold - && !rast->line_smooth); + /* drawing wide, non-AA lines? */ + wide_lines = rast->line_width != 1.0f && +roundf(rast->line_width) > draw->pipeline.wide_line_threshold && +!rast->line_smooth; /* drawing large/sprite points (but not AA points)? */ if (rast->sprite_coord_enable && draw->pipeline.point_sprite) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: add some missing SVGA_STATS_* enum values, prefix strings
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, June 16, 2017 12:21 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH] svga: add some missing SVGA_STATS_* enum values, prefix strings To fix the build when VMX86_STATS is defined. Also, some minor whitespace changes to match upstream code. --- src/gallium/drivers/svga/svga_winsys.h | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h index 376707d..8b8b45b 100644 --- a/src/gallium/drivers/svga/svga_winsys.h +++ b/src/gallium/drivers/svga/svga_winsys.h @@ -35,7 +35,6 @@ #ifndef SVGA_WINSYS_H_ #define SVGA_WINSYS_H_ - #include "svga_types.h" #include "svga_reg.h" #include "svga3d_reg.h" @@ -101,6 +100,7 @@ struct svga_winsys_stats_timeframe { enum svga_stats_count { SVGA_STATS_COUNT_BLENDSTATE, + SVGA_STATS_COUNT_BLITBLITTERCOPY, SVGA_STATS_COUNT_DEPTHSTENCILSTATE, SVGA_STATS_COUNT_RASTERIZERSTATE, SVGA_STATS_COUNT_SAMPLER, @@ -112,11 +112,16 @@ enum svga_stats_count { }; enum svga_stats_time { + SVGA_STATS_TIME_BLIT, + SVGA_STATS_TIME_BLITBLITTER, + SVGA_STATS_TIME_BLITFALLBACK, SVGA_STATS_TIME_BUFFERSFLUSH, SVGA_STATS_TIME_BUFFERTRANSFERMAP, SVGA_STATS_TIME_BUFFERTRANSFERUNMAP, SVGA_STATS_TIME_CONTEXTFINISH, SVGA_STATS_TIME_CONTEXTFLUSH, + SVGA_STATS_TIME_COPYREGION, + SVGA_STATS_TIME_COPYREGIONFALLBACK, SVGA_STATS_TIME_CREATEBACKEDSURFACEVIEW, SVGA_STATS_TIME_CREATEBUFFER, SVGA_STATS_TIME_CREATECONTEXT, @@ -134,6 +139,7 @@ enum svga_stats_time { SVGA_STATS_TIME_EMITFS, SVGA_STATS_TIME_EMITGS, SVGA_STATS_TIME_EMITVS, + SVGA_STATS_TIME_EMULATESURFACEVIEW, SVGA_STATS_TIME_FENCEFINISH, SVGA_STATS_TIME_GENERATEINDICES, SVGA_STATS_TIME_HWTNLDRAWARRAYS, @@ -165,20 +171,26 @@ enum svga_stats_time { #define SVGA_STATS_COUNT_NAMES\ SVGA_STATS_PREFIX "BlendState",\ + SVGA_STATS_PREFIX "BlitBlitterCopy", \ SVGA_STATS_PREFIX "DepthStencilState", \ SVGA_STATS_PREFIX "RasterizerState", \ SVGA_STATS_PREFIX "Sampler", \ SVGA_STATS_PREFIX "SamplerView", \ SVGA_STATS_PREFIX "SurfaceWriteFlush", \ SVGA_STATS_PREFIX "TextureReadback", \ - SVGA_STATS_PREFIX "VertexElement" + SVGA_STATS_PREFIX "VertexElement" \ #define SVGA_STATS_TIME_NAMES \ + SVGA_STATS_PREFIX "Blit",\ + SVGA_STATS_PREFIX "BlitBlitter", \ + SVGA_STATS_PREFIX "BlitFallback",\ SVGA_STATS_PREFIX "BuffersFlush",\ SVGA_STATS_PREFIX "BufferTransferMap", \ SVGA_STATS_PREFIX "BufferTransferUnmap", \ SVGA_STATS_PREFIX "ContextFinish", \ SVGA_STATS_PREFIX "ContextFlush",\ + SVGA_STATS_PREFIX "CopyRegion", \ + SVGA_STATS_PREFIX "CopyRegionFallback", \ SVGA_STATS_PREFIX "CreateBackedSurfaceView", \ SVGA_STATS_PREFIX "CreateBuffer",\ SVGA_STATS_PREFIX "CreateContext", \ @@ -196,6 +208,7 @@ enum svga_stats_time { SVGA_STATS_PREFIX "EmitFS", \ SVGA_STATS_PREFIX "EmitGS", \ SVGA_STATS_PREFIX "EmitVS", \ + SVGA_STATS_PREFIX "EmulateSurfaceView", \ SVGA_STATS_PREFIX "FenceFinish", \ SVGA_STATS_PREFIX "GenerateIndices", \ SVGA_STATS_PREFIX "HWtnlDrawArrays", \ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: add texture size/levels sanity check code in svga_texture_create()
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, June 28, 2017 3:13 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH] svga: add texture size/levels sanity check code in svga_texture_create() The state tracker should never ask us to create a texture with invalid dimensions / mipmap levels. Do some assertions to check that. No Piglit regressions. --- src/gallium/drivers/svga/svga_resource_texture.c | 33 1 file changed, 33 insertions(+) diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index 670100c..84441d1 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -916,6 +916,39 @@ svga_texture_create(struct pipe_screen *screen, goto fail_notex; } + /* Verify the number of mipmap levels isn't impossibly large. For example, +* if the base 2D image is 16x16, we can't have 8 mipmap levels. +* The state tracker should never ask us to create a resource with invalid +* parameters. +*/ + { + unsigned max_dim = template->width0; + + switch (template->target) { + case PIPE_TEXTURE_1D: + case PIPE_TEXTURE_1D_ARRAY: + // nothing + break; + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_CUBE: + case PIPE_TEXTURE_CUBE_ARRAY: + case PIPE_TEXTURE_2D_ARRAY: + max_dim = MAX2(max_dim, template->height0); + break; + case PIPE_TEXTURE_3D: + max_dim = MAX3(max_dim, template->height0, template->depth0); + break; + case PIPE_TEXTURE_RECT: + case PIPE_BUFFER: + assert(template->last_level == 0); + /* the assertion below should always pass */ + break; + default: + debug_printf("Unexpected texture target type\n"); + } + assert(1 << template->last_level <= max_dim); + } + tex = CALLOC_STRUCT(svga_texture); if (!tex) { goto fail_notex; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] wglcontext: assorted updates
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Sunday, July 2, 2017 8:07 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] wglcontext: assorted updates Print context flags, vendor, renderer strings. Default to not setting the WGL_CONTEXT_PROFILE_MASK_ARB attribute so we can test that scenario. Fix profile_mask_to_string() to use GL_*_BIT instead of WGL_*_BIT flags. Try calling glGenLists() to see if it generates an error. This helps to check if core/forward compatible profile error checking is realy working. Restructure some context setup code. --- src/wgl/wglcontext.c | 107 +-- 1 file changed, 86 insertions(+), 21 deletions(-) diff --git a/src/wgl/wglcontext.c b/src/wgl/wglcontext.c index 92df7cc..b116270 100644 --- a/src/wgl/wglcontext.c +++ b/src/wgl/wglcontext.c @@ -24,6 +24,19 @@ #include #include #include +#include + +#ifndef GL_CONTEXT_FLAG_DEBUG_BIT +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x0002 +#endif +#ifndef GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x0004 +#endif + +#ifndef GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x0008 +#endif + static LRESULT CALLBACK WndProc(HWND hWnd, @@ -61,28 +74,59 @@ static char * profile_mask_to_string(GLint profileMask) { switch (profileMask) { - case WGL_CONTEXT_CORE_PROFILE_BIT_ARB: - return "WGL_CONTEXT_CORE_PROFILE_BIT_ARB"; - case WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: - return "WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB"; + case GL_CONTEXT_CORE_PROFILE_BIT: + return "GL_CONTEXT_CORE_PROFILE_BIT"; + case GL_CONTEXT_COMPATIBILITY_PROFILE_BIT: + return "GL_CONTEXT_COMPATIBILITY_PROFILE_BIT"; default: return "0"; } } +static char * +context_flags_to_string(GLint flags) +{ + static char buf[1000] = {0}; + if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) + strcat(buf, "GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT | "); + if (flags & GL_CONTEXT_FLAG_DEBUG_BIT) + strcat(buf, "GL_CONTEXT_FLAG_DEBUG_BIT | "); + if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT) + strcat(buf, "GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT | "); + if (flags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR) + strcat(buf, "GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR | "); + + int n = strlen(buf); + if (n >= 3) { + /* rm the trailing " | " */ + buf[n-3] = 0; + } + else { + strcat(buf, "(none)"); + } + + return buf; +} + static void print_context_infos(void) { GLint majorVersion; GLint minorVersion; - GLint profileMask; - const char *version; + GLint profileMask, flags; + const char *version, *vendor, *renderer; fprintf(stdout, "Context Informations\n"); version = (const char *)glGetString(GL_VERSION); fprintf(stdout, "GL_VERSION: %s\n", version); + vendor = (const char *)glGetString(GL_VENDOR); + fprintf(stdout, "GL_VENDOR: %s\n", vendor); + + renderer = (const char *)glGetString(GL_RENDERER); + fprintf(stdout, "GL_RENDERER: %s\n", renderer); + // Request informations with the new 3.x features. if (sscanf(version, "%d.%d", &majorVersion, &minorVersion) != 2) return; @@ -90,10 +134,28 @@ print_context_infos(void) if (majorVersion >= 3) { glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); glGetIntegerv(GL_MINOR_VERSION, &minorVersion); - glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMask); fprintf(stdout, "GL_MAJOR_VERSION: %d\n", majorVersion); fprintf(stdout, "GL_MINOR_VERSION: %d\n", minorVersion); - fprintf(stdout, "GL_CONTEXT_PROFILE_MASK: %s\n", profile_mask_to_string(profileMask)); + } + if (majorVersion * 10 + minorVersion >= 32) { + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMask); + glGetIntegerv(GL_CONTEXT_FLAGS, &flags); + fprintf(stdout, "GL_CONTEXT_PROFILE_MASK: %s\n", + profile_mask_to_string(profileMask)); + fprintf(stdout, "GL_CONTEXT_FLAGS: %s\n", + context_flags_to_string(flags)); + } + + /* Test if deprecated features work or generate an error */ + while (glGetError() != GL_NO_ERROR) + ; + + (void) glGenLists(1); + if (glGetError()) { + fprintf(stdout, "glGenLists generated an error.\n"); + } + else { + fprintf(stdout, "glGenLists generated no error.\n"); } } @@ -107,13 +169,6 @@ create_context(int majorVersion, int minorVersion, int profileMask, int contextF int pixelFormat; HGLRC tmp, ctx; PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; - int attribsList[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 1, -
Re: [Mesa-dev] [PATCH 1/4] svga: fix buffer binding flags initialization
>From: Brian Paul >Sent: Sunday, July 2, 2017 8:12 AM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee >Subject: [PATCH 1/4] svga: fix buffer binding flags initialization >If a buffer is created/initialized with glNamedBufferData we will >have no target (GL_ARRAY_BUFFER, GL_UNIFORM_BUFFER, etc) >so the >svga_buffer::bind_flags will be zero until we try to get the buffer handle. >This patch initializes the svga_buffer::bind_flags field when it's zero. >This fixes the Piglit arb_uniform_buffer_object-rendering-dsa test. >Note that there's still issues in this area that'll have to be >addressed in the future. For example, creating a buffer object >as GL_UNIFORM_BUFFER and later using it as a vertex buffer will >fail. Since we are creating two separate host surfaces for such buffer object when it is used as both constant buffer and vertex buffer, we are probably missing a surface update when the buffer object is updated. Which piglit fails? >--- > src/gallium/drivers/svga/svga_resource_buffer_upload.c | 6 ++ > 1 file changed, 6 insertions(+) >diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c >>b/src/gallium/drivers/svga/svga_resource_buffer_upload.c >index 61f6fb0..104cb6d 100644 >--- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c >+++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c >@@ -1003,6 +1003,12 @@ svga_buffer_handle(struct svga_context *svga, struct >pipe_resource *buf, > return NULL; > } >} else { >+ if (!sbuf->bind_flags) { >+ sbuf->bind_flags = tobind_flags; >+ } >+ >+ assert((sbuf->bind_flags & tobind_flags) == tobind_flags); >+ > /* This call will set sbuf->handle */ > if (svga_have_gb_objects(svga)) { > ret = svga_buffer_update_hw(svga, sbuf, sbuf->bind_flags); >-- >1.9.1 Series looks good to me. Reviewed-by: Charmaine Lee ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/3] st/mesa: find proper mipmap level in st_ClearTexSubImage()
>From: Brian Paul >To: >CC: Neha Bhende >The Piglit arb_clear_texture-error test creates a texture with only >a 1x1 image at level=1, then tries to clear level 0 (non-existant) s/non-existant/non-existent/ >and level 1 (exists). The test only checks that the former generates >an error but the later doesn't. The test passes, but when we try >to clear the level=1 image we're passing an invalid level to >pipe_context::clear_texture(). level=1, but since there's only one >mipmap level in the texture, it should be zero. >This fixes the code to search the gallium texture resource for the >correct mipmap level. Also, add an assertion to make sure we're not >passing an invalid level to pipe_context::clear_texture(). >Fixes device errors with VMware driver. No Piglit regressions. >v2: don't do the level search when using immutable textures. >--- > src/mesa/state_tracker/st_cb_texture.c | 60 >+++--- > 1 file changed, 56 insertions(+), 4 deletions(-) >diff --git a/src/mesa/state_tracker/st_cb_texture.c >b/src/mesa/state_tracker/st_cb_texture.c >index 1847cc3..c6a5e63 100644 >--- a/src/mesa/state_tracker/st_cb_texture.c >+++ b/src/mesa/state_tracker/st_cb_texture.c >@@ -2836,6 +2836,42 @@ st_TextureView(struct gl_context *ctx, > return GL_TRUE; > } >+ >+/** >+ * Find the mipmap level in 'pt' which matches the level described by >+ * 'texImage'. >+ */ >+static unsigned >+find_mipmap_level(const struct gl_texture_image *texImage, >+ const struct pipe_resource *pt) >+{ >+ const GLenum target = texImage->TexObject->Target; >+ GLint texWidth = texImage->Width; >+ GLint texHeight = texImage->Height; >+ GLint texDepth = texImage->Depth; >+ unsigned level, w; >+ uint16_t h, d, layers; >+ >+ st_gl_texture_dims_to_pipe_dims(target, texWidth, texHeight, texDepth, >+ &w, &h, &d, &layers); >+ >+ for (level = 0; level <= pt->last_level; level++) { >+ if (u_minify(pt->width0, level) == w && >+ u_minify(pt->height0, level) == h && >+ u_minify(pt->depth0, level) == d) { >+ return level; >+ } >+ } >+ >+ /* If we get here, there must be some sort of inconsistency between >+* the Mesa texture object/images and the gallium resource. >+*/ >+ debug_printf("Inconsistent textures in find_mipmap_level()\n"); >+ >+ return texImage->Level; >+} >+ >+ > static void > st_ClearTexSubImage(struct gl_context *ctx, > struct gl_texture_image *texImage, >@@ -2844,11 +2880,12 @@ st_ClearTexSubImage(struct gl_context *ctx, > const void *clearValue) > { > static const char zeros[16] = {0}; >+ struct gl_texture_object *texObj = texImage->TexObject; > struct st_texture_image *stImage = st_texture_image(texImage); > struct pipe_resource *pt = stImage->pt; > struct st_context *st = st_context(ctx); > struct pipe_context *pipe = st->pipe; >- unsigned level = texImage->Level; >+ unsigned level; > struct pipe_box box; > > if (!pt) >@@ -2859,10 +2896,25 @@ st_ClearTexSubImage(struct gl_context *ctx, > > u_box_3d(xoffset, yoffset, zoffset + texImage->Face, > width, height, depth, &box); >- if (texImage->TexObject->Immutable) { >- level += texImage->TexObject->MinLevel; >- box.z += texImage->TexObject->MinLayer; >+ if (texObj->Immutable) { >+ /* The texture object has to be consistent (no "loose", per-image >+ * gallium resources). If this texture is a view into another >+ * texture, we have to apply the MinLevel/Layer offsets. If this is >+ * not a texture view, the offsets will be zero. >+ */ >+ assert(stImage->pt == st_texture_object(texObj)->pt); >+ level = texImage->Level + texObj->MinLevel; >+ box.z += texObj->MinLayer; > } >+ else { >+ /* Texture level sizes may be inconsistent. We my have "loose", >+ * per-image gallium resources. The texImage->Level may not match >+ * the gallium resource texture level. >+ */ >+ level = find_mipmap_level(texImage, pt); >+ } >+ >+ assert(level <= pt->last_level); > pipe->clear_texture(pipe, pt, level, &box, clearValue ? clearValue >: zeros); > } >-- >1.9.1 Series looks good to me. Reviewed-by: Charmaine Lee ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: remove unused st_framebuffer::Private field
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, July 7, 2017 7:11 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH] st/mesa: remove unused st_framebuffer::Private field --- src/mesa/state_tracker/st_context.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 5c7c58d..af9149e 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -295,7 +295,6 @@ static inline struct st_context *st_context(struct gl_context *ctx) struct st_framebuffer { struct gl_framebuffer Base; - void *Private; struct st_framebuffer_iface *iface; enum st_attachment_type statts[ST_ATTACHMENT_COUNT]; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] vbo: rename target->index in loopback code
Series looks good. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Friday, July 7, 2017 7:11 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH 3/3] vbo: rename target->index in loopback code Because it's a vertex attribute index. --- src/mesa/vbo/vbo_save_loopback.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c index 773af93..1dae91b 100644 --- a/src/mesa/vbo/vbo_save_loopback.c +++ b/src/mesa/vbo/vbo_save_loopback.c @@ -37,7 +37,7 @@ #include "vbo_context.h" -typedef void (*attr_func)(struct gl_context *ctx, GLint target, const GLfloat *); +typedef void (*attr_func)(struct gl_context *ctx, GLint index, const GLfloat *); /* This file makes heavy use of the aliasing of NV vertex attributes @@ -45,30 +45,30 @@ typedef void (*attr_func)(struct gl_context *ctx, GLint target, const GLfloat *) * attributes as currently implemented. */ static void -VertexAttrib1fvNV(struct gl_context *ctx, GLint target, const GLfloat *v) +VertexAttrib1fvNV(struct gl_context *ctx, GLint index, const GLfloat *v) { - CALL_VertexAttrib1fvNV(ctx->Exec, (target, v)); + CALL_VertexAttrib1fvNV(ctx->Exec, (index, v)); } static void -VertexAttrib2fvNV(struct gl_context *ctx, GLint target, const GLfloat *v) +VertexAttrib2fvNV(struct gl_context *ctx, GLint index, const GLfloat *v) { - CALL_VertexAttrib2fvNV(ctx->Exec, (target, v)); + CALL_VertexAttrib2fvNV(ctx->Exec, (index, v)); } static void -VertexAttrib3fvNV(struct gl_context *ctx, GLint target, const GLfloat *v) +VertexAttrib3fvNV(struct gl_context *ctx, GLint index, const GLfloat *v) { - CALL_VertexAttrib3fvNV(ctx->Exec, (target, v)); + CALL_VertexAttrib3fvNV(ctx->Exec, (index, v)); } static void -VertexAttrib4fvNV(struct gl_context *ctx, GLint target, const GLfloat *v) +VertexAttrib4fvNV(struct gl_context *ctx, GLint index, const GLfloat *v) { - CALL_VertexAttrib4fvNV(ctx->Exec, (target, v)); + CALL_VertexAttrib4fvNV(ctx->Exec, (index, v)); } @@ -81,7 +81,7 @@ static attr_func vert_attrfunc[4] = { struct loopback_attr { - GLint target; + GLint index; GLint sz; attr_func func; }; @@ -127,7 +127,7 @@ loopback_prim(struct gl_context *ctx, const GLfloat *tmp = data + la[0].sz; for (k = 1; k < nr; k++) { - la[k].func(ctx, la[k].target, tmp); + la[k].func(ctx, la[k].index, tmp); tmp += la[k].sz; } @@ -184,7 +184,7 @@ vbo_loopback_vertex_list(struct gl_context *ctx, */ for (i = 0; i < VBO_ATTRIB_MAX; i++) { if (attrsz[i]) { - la[nr].target = i; + la[nr].index = i; la[nr].sz = attrsz[i]; la[nr].func = vert_attrfunc[attrsz[i]-1]; nr++; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: adjust line subpixel position for HWv8
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Wednesday, July 5, 2017 7:56 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH] svga: adjust line subpixel position for HWv8 This fixes two regressions on HWv8: Piglit gl-1.0-ortho-pos Piglit/glean fbo This was caused by commit c2b92dada076a "svga: clamp device line width to at least 1 to fix HWv8 line stippling" This also fixes two conform tests: Vertex Order and Polygon Face No Piglit/conform changes with HWv9 or later. VMware bug 1905053 --- src/gallium/drivers/svga/svga_state_framebuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index bb92c54..c52b7ee 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -561,7 +561,7 @@ emit_viewport( struct svga_context *svga, break; case PIPE_PRIM_LINES: adjust_x = -0.5; -adjust_y = 0; +adjust_y = -0.125; break; case PIPE_PRIM_TRIANGLES: adjust_x = -0.5; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] mesa: finish implementing glPrimitiveRestartNV() for display lists
>From: Brian Paul >Sent: Friday, July 7, 2017 7:10 AM >To: mesa-dev@lists.freedesktop.org >Cc: Charmaine Lee; Neha Bhende; Olivier Lauffenburger >Subject: [PATCH 2/2] mesa: finish implementing glPrimitiveRestartNV() for >display lists >If we try to build a display list with just a glPrimitiveRestartNV() >call, we'd crash because of a null GLvertexformat::PrimitiveRestartNV >pointer. This change fixes that case. >The previous patch fixed the case of calling glPrimitiveRestartNV() >inside a glBegin/End pair. >--- > src/mesa/main/dlist.c | 27 ++- > 1 file changed, 26 insertions(+), 1 deletion(-) >diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 9e817be..6e334fd 100644 >--- a/src/mesa/main/dlist.c >+++ b/src/mesa/main/dlist.c >@@ -325,7 +325,8 @@ typedef enum >OPCODE_STENCIL_FUNC_SEPARATE, >OPCODE_STENCIL_OP_SEPARATE, >OPCODE_STENCIL_MASK_SEPARATE, >- >+ /* GL_NV_primitive_restart */ >+ OPCODE_PRIMITIVE_RESTART_NV, >/* GL_ARB_shader_objects */ >OPCODE_USE_PROGRAM, >OPCODE_UNIFORM_1F, >@@ -6095,6 +6096,24 @@ save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) > } > static void GLAPIENTRY >+save_PrimitiveRestartNV(void) >+{ >+ /* Note: this is used when outside a glBegin/End pair in a display list */ >+ GET_CURRENT_CONTEXT(ctx); >+ Node *n; >+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); >+ n = alloc_instruction(ctx, OPCODE_PRIMITIVE_RESTART_NV, 0); >+ if (n) { >+ /* nothing */ >+ } Can you remove this if clause since it is not doing anything? >+ if (ctx->ExecuteFlag) { >+ CALL_PrimitiveRestartNV(ctx->Exec, ()); >+ } >+ >+} >+ >+ >+static void GLAPIENTRY > save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, >GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, > GLbitfield mask, GLenum filter) >@@ -8670,6 +8689,10 @@ execute_list(struct gl_context *ctx, GLuint list) > n[5].i, n[6].i, n[7].i, > n[8].i, > n[9].i, n[10].e)); > break; >+ case OPCODE_PRIMITIVE_RESTART_NV: >+CALL_PrimitiveRestartNV(ctx->Exec, ()); >+break; >+ > case OPCODE_USE_PROGRAM: > CALL_UseProgram(ctx->Exec, (n[1].ui)); > break; >@@ -10460,6 +10483,8 @@ save_vtxfmt_init(GLvertexformat * vfmt) >vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB; > vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; >vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; >+ >+ vfmt->PrimitiveRestartNV = save_PrimitiveRestartNV; > } For this series, Reviewed-by: Charmaine Lee ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: fix breakage in create_backed_surface_view()
Reviewed-by: Charmaine Lee From: Brian Paul Sent: Sunday, July 9, 2017 1:00 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee Subject: [PATCH] svga: fix breakage in create_backed_surface_view() This fixes a regression in some piglit tests since commit 5e5d5f1a2eb. I think I mis-resolved the merge conflict when cherry-picking that commit to master. --- src/gallium/drivers/svga/svga_surface.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index 1f50b9c..d7c9850 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -446,6 +446,8 @@ create_backed_surface_view(struct svga_context *svga, struct svga_surface *s) goto done; s->backed = svga_surface(backed_view); + + SVGA_STATS_TIME_POP(svga_sws(svga)); } else if (s->backed->age < tex->age) { /* @@ -474,12 +476,9 @@ create_backed_surface_view(struct svga_context *svga, struct svga_surface *s) bs->key.numMipLevels, bs->key.numFaces * bs->key.arraySize, zslice, s->base.u.tex.level, layer); - - svga_mark_surface_dirty(&s->backed->base); - - SVGA_STATS_TIME_POP(svga_sws(svga)); } + svga_mark_surface_dirty(&s->backed->base); s->backed->age = tex->age; done: -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: fix PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE value
Reviewed-by :Charmaine Lee From: Brian Paul Sent: Monday, July 10, 2017 7:40 AM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; mesa-sta...@lists.freedesktop.org Subject: [PATCH] svga: fix PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE value This query is supposed to return the max texture buffer size/width in texels, not size in bytes. Divide by 16 (the largest format size) to return texels. Fixes Piglit arb_texture_buffer_object-max-size test. Cc: mesa-sta...@lists.freedesktop.org --- src/gallium/drivers/svga/svga_screen.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 0b63525..f40d151 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -312,7 +312,10 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) return svgascreen->ms_samples ? 1 : 0; case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: - return SVGA3D_DX_MAX_RESOURCE_SIZE; + /* convert bytes to texels for the case of the largest texel + * size: float[4]. + */ + return SVGA3D_DX_MAX_RESOURCE_SIZE / (4 * sizeof(float)); case PIPE_CAP_MIN_TEXEL_OFFSET: return sws->have_vgpu10 ? VGPU10_MIN_TEXEL_FETCH_OFFSET : 0; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 5/5] svga: s/unsigned/enum tgsi_texture_type/
Series looks good. Reviewed-by: Charmaine Lee From: Brian Paul Sent: Monday, July 10, 2017 2:50:25 PM To: mesa-dev@lists.freedesktop.org Cc: Charmaine Lee; Neha Bhende Subject: [PATCH 5/5] svga: s/unsigned/enum tgsi_texture_type/ --- src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c index bbaad20..d29ac28 100644 --- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c +++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c @@ -2955,7 +2955,8 @@ emit_sampler_declarations(struct svga_shader_emitter_v10 *emit) * Translate TGSI_TEXTURE_x to VGAPU10_RESOURCE_DIMENSION_x. */ static unsigned -tgsi_texture_to_resource_dimension(unsigned target, boolean is_array) +tgsi_texture_to_resource_dimension(enum tgsi_texture_type target, + boolean is_array) { switch (target) { case TGSI_TEXTURE_BUFFER: @@ -4867,7 +4868,7 @@ setup_texcoord(struct svga_shader_emitter_v10 *emit, */ static void emit_tex_compare_refcoord(struct svga_shader_emitter_v10 *emit, - unsigned target, + enum tgsi_texture_type target, const struct tgsi_full_src_register *coord) { struct tgsi_full_src_register coord_src_ref; @@ -4901,7 +4902,7 @@ struct tex_swizzle_info boolean swizzled; boolean shadow_compare; unsigned unit; - unsigned texture_target; /**< TGSI_TEXTURE_x */ + enum tgsi_texture_type texture_target; /**< TGSI_TEXTURE_x */ struct tgsi_full_src_register tmp_src; struct tgsi_full_dst_register tmp_dst; const struct tgsi_full_dst_register *inst_dst; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/mesa: add a winsys buffers list in st_context
Commit a5e733c6b52e93de3000647d075f5ca2f55fcb71 fixes the dangling framebuffer object by unreferencing the window system draw/read buffers when context is released. However this can prematurely destroy the resources associated with these window system buffers. The problem is reproducible with Turbine Demo running with VMware driver. In this case, the depth buffer content was lost when the context is rebound to a drawable. To prevent premature destroy of the resources associated with window system buffers, this patch maintains a list of these buffers in the context, making sure the reference counts of these buffers will not reach zero until the associated framebuffer interface objects no longer exist. This also helps to avoid unnecessary destruction and re-construction of the resources associated with the framebuffer. Fixes VMware bug 1909807. --- src/gallium/include/state_tracker/st_api.h| 5 +++ src/gallium/state_trackers/dri/dri_drawable.c | 4 ++ src/gallium/state_trackers/wgl/stw_st.c | 4 +- src/mesa/state_tracker/st_context.c | 22 ++ src/mesa/state_tracker/st_context.h | 7 src/mesa/state_tracker/st_manager.c | 59 ++- src/mesa/state_tracker/st_manager.h | 4 ++ 7 files changed, 94 insertions(+), 11 deletions(-) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index d641092..3fd5f01 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -311,6 +311,11 @@ struct st_framebuffer_iface int32_t stamp; /** +* Identifier that uniquely identifies the framebuffer interface object. +*/ + uint32_t ID; + + /** * Available for the state tracker manager to use. */ void *st_manager_private; diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 3c2e307..0cfdc30 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -38,6 +38,8 @@ #include "util/u_memory.h" #include "util/u_inlines.h" +static uint32_t drifb_ID = 0; + static void swap_fences_unref(struct dri_drawable *draw); @@ -155,6 +157,7 @@ dri_create_buffer(__DRIscreen * sPriv, dPriv->driverPrivate = (void *)drawable; p_atomic_set(&drawable->base.stamp, 1); + drawable->base.ID = p_atomic_inc_return(&drifb_ID); return GL_TRUE; fail: @@ -177,6 +180,7 @@ dri_destroy_buffer(__DRIdrawable * dPriv) swap_fences_unref(drawable); + drawable->base.ID = 0; FREE(drawable); } diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c index 7806a2a..c2844b0 100644 --- a/src/gallium/state_trackers/wgl/stw_st.c +++ b/src/gallium/state_trackers/wgl/stw_st.c @@ -46,7 +46,7 @@ struct stw_st_framebuffer { unsigned texture_mask; }; - +static uint32_t stwfb_ID = 0; /** * Is the given mutex held by the calling thread? @@ -234,6 +234,7 @@ stw_st_create_framebuffer(struct stw_framebuffer *fb) stwfb->fb = fb; stwfb->stvis = fb->pfi->stvis; + stwfb->base.ID = p_atomic_inc_return(&stwfb_ID); stwfb->base.visual = &stwfb->stvis; p_atomic_set(&stwfb->base.stamp, 1); @@ -255,6 +256,7 @@ stw_st_destroy_framebuffer_locked(struct st_framebuffer_iface *stfb) for (i = 0; i < ST_ATTACHMENT_COUNT; i++) pipe_resource_reference(&stwfb->textures[i], NULL); + stwfb->base.ID = 0; FREE(stwfb); } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index f535139..fb0182f 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -38,6 +38,7 @@ #include "program/prog_cache.h" #include "vbo/vbo.h" #include "glapi/glapi.h" +#include "st_manager.h" #include "st_context.h" #include "st_debug.h" #include "st_cb_bitmap.h" @@ -571,6 +572,9 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe, _mesa_destroy_context(ctx); } + /* Initialize context's winsys buffers list */ + LIST_INITHEAD(&st->winsys_buffers); + return st; } @@ -591,6 +595,19 @@ destroy_tex_sampler_cb(GLuint id, void *data, void *userData) void st_destroy_context( struct st_context *st ) { struct gl_context *ctx = st->ctx; + struct st_framebuffer *stfb, *next; + + GET_CURRENT_CONTEXT(curctx); + if (curctx == NULL) { + boolean ret; + + /* No current context, but we need one to release + * renderbuffer surface when we release framebuffer. + * So temporarily bind the context. + */ + ret = _mesa_make_current(ctx, NULL, NULL); + (void) ret; + } /* This must be called first so that glthread has a chance to finish */ _mesa_glthread_destroy(ctx); @@ -604,6 +621,11 @@ void st_destroy_context( struct st_context *st ) st_reference_prog(st, &st->tep, NULL); st_reference_compprog(st, &