Re: [Mesa-dev] i965: overwriting parts of a register and optimization passes
Hi Kenneth, El 2014-07-09 17:19, Kenneth Graunke escribió: On Tuesday, July 08, 2014 11:19:38 AM Iago Toral wrote: Hi, I have some code that first initializes a register and then overwrites a specific subregister. However, after the optimization passes in brw_vec4.cpp the initialization instruction goes away. I see that live intervals are computed for the destination register without considering if we are writing only to a specific subregister, so I guess that is the reason for this behaviour, but this strikes me as odd, as it defeats the purpose of overwriting only specific subregs, so I guess there is something else that I am missing. This an example of what is happening: mov(8) g6<1>.xUD g0<4,4,1>UD { align16 WE_all 1Q }; mov(1) g6.2<1>UD 0x0007UD { align1 WE_all compacted }; The first MOV is removed from the instruction set when I put the second MOV, however the second MOV should only be writing to subreg 6.2 and keep the rest of register 6 intact, or at least that is what I am trying to do... Can someone explain what is wrong with those two instructions? how should I overwrite only a specific subregister without causing this behavior? Thanks, Iago This sounds a lot like the bug I fixed in: commit d0575d98fc595dcc17706dc73d1eb461027ca17a Author: Kenneth Graunke Date: Sat Jun 14 03:53:07 2014 -0700 i965/vec4: Fix dead code elimination for VGRFs of size > 1. where it would see those two as the same register, and delete the first MOV. You probably already have that in your tree though, right? If not, update :) Yeah, I have it already, so I guess my problem was different. If so, you might try turning off other optimization passes in brw_vec4.cpp and see if it helps - sounds like a bug in one of them. The one causing that behaviour was the dead code elimination pass in brw_vec4.cpp. Anyway, this is not happening consistently, I have done some changes to my code that are unrelated to these two instructions and now this is not happening any more... Iago ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] nouveau: check if a fence has already been signalled
nouveau_fence_update does real work unconditionally. Avoid doing that if the fence we're checking on has already been signalled. Signed-off-by: Ilia Mirkin --- src/gallium/drivers/nouveau/nouveau_fence.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/nouveau/nouveau_fence.c b/src/gallium/drivers/nouveau/nouveau_fence.c index c686710..a9448a4 100644 --- a/src/gallium/drivers/nouveau/nouveau_fence.c +++ b/src/gallium/drivers/nouveau/nouveau_fence.c @@ -174,6 +174,9 @@ nouveau_fence_signalled(struct nouveau_fence *fence) { struct nouveau_screen *screen = fence->screen; + if (fence->state == NOUVEAU_FENCE_STATE_SIGNALLED) + return TRUE; + if (fence->state >= NOUVEAU_FENCE_STATE_EMITTED) nouveau_fence_update(screen, FALSE); -- 1.8.5.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] nvc0: add support for indirect drawing
From: Christoph Bumiller Reviewed-by: Ilia Mirkin --- docs/GL3.txt | 5 +- docs/relnotes/10.3.html| 1 + src/gallium/drivers/nouveau/nouveau_screen.c | 6 +- src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h | 2 +- src/gallium/drivers/nouveau/nv50/nv50_screen.c | 2 + src/gallium/drivers/nouveau/nvc0/mme/com9097.mme | 75 ++ src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h | 56 ++ src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h | 6 ++ src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 13 +++- src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c| 90 -- 10 files changed, 223 insertions(+), 33 deletions(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index 296e14c..8f41df0 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -98,7 +98,7 @@ GL 4.0: GLSL 4.0 not started GL_ARB_draw_buffers_blendDONE (i965, nv50, nvc0, r600, radeonsi, softpipe) - GL_ARB_draw_indirect DONE (i965) + GL_ARB_draw_indirect DONE (i965, nvc0) GL_ARB_gpu_shader5 started - 'precise' qualifierDONE - Dynamically uniform sampler array indices started (Chris) @@ -123,7 +123,6 @@ GL 4.0: GL_ARB_transform_feedback2 DONE (i965, nv50, nvc0, r600, radeonsi) GL_ARB_transform_feedback3 DONE (i965, nv50, nvc0, r600, radeonsi) - GL 4.1: GLSL 4.1 not started @@ -165,7 +164,7 @@ GL 4.3: GL_ARB_framebuffer_no_attachmentsnot started GL_ARB_internalformat_query2 not started GL_ARB_invalidate_subdataDONE (all drivers) - GL_ARB_multi_draw_indirect DONE (i965) + GL_ARB_multi_draw_indirect DONE (i965, nvc0) GL_ARB_program_interface_query not started GL_ARB_robust_buffer_access_behavior not started GL_ARB_shader_image_size not started diff --git a/docs/relnotes/10.3.html b/docs/relnotes/10.3.html index 2e718fc..7d4f533 100644 --- a/docs/relnotes/10.3.html +++ b/docs/relnotes/10.3.html @@ -56,6 +56,7 @@ Note: some of the new features are only available with certain drivers. GL_ARB_seamless_cubemap_per_texture on i965, llvmpipe, nvc0, r600, radeonsi, softpipe GL_ARB_fragment_layer_viewport on nv50, nvc0, llvmpipe, r600 GL_AMD_vertex_shader_viewport_index on i965/gen7+, r600 +GL_ARB_(multi_)draw_indirect on nvc0 diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 9d71bf7..517978d 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -194,12 +194,14 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) screen->lowmem_bindings = PIPE_BIND_GLOBAL; /* gallium limit */ screen->vidmem_bindings = PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL | - PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_CURSOR | + PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | + PIPE_BIND_CURSOR | PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE | PIPE_BIND_GLOBAL; screen->sysmem_bindings = - PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT; + PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT | + PIPE_BIND_COMMAND_ARGS_BUFFER; memset(&mm_config, 0, sizeof(mm_config)); diff --git a/src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h b/src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h index cc3a382..7523fdc 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h +++ b/src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h @@ -479,7 +479,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define NV50_3D_WATCHDOG_TIMER 0x0de4 -#define NV50_3D_UNK0DE8 0x0de8 +#define NV50_3D_PRIM_RESTART_WITH_DRAW_ARRAYS 0x0de8 #define NV50_3D_UNK0DEC 0x0dec diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index 17d8fa3..fd63819 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -437,6 +437,8 @@ nv50_screen_init_hwctx(struct nv50_screen *screen) PUSH_DATA (push, NV50_3D_MULTISAMPLE_MODE_MS1); BEGIN_NV04(push, NV50_3D(MULTISAMPLE_CTRL), 1); PUSH_DATA
[Mesa-dev] [PATCH 3/3] nvc0: fix translate path for PRIM_RESTART_WITH_DRAW_ARRAYS
From: Christoph Bumiller Reviewed-by: Ilia Mirkin --- .../drivers/nouveau/nvc0/nvc0_vbo_translate.c | 41 +++--- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c index fc578f2..f180087 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c @@ -253,7 +253,7 @@ disp_vertices_i08(struct push_context *ctx, unsigned start, unsigned count) } if (count) { BEGIN_NVC0(push, NVC0_3D(VB_ELEMENT_U32), 1); - PUSH_DATA (push, ctx->restart_index); + PUSH_DATA (push, 0x); ++elts; ctx->dest += ctx->vertex_size; ++pos; @@ -309,7 +309,7 @@ disp_vertices_i16(struct push_context *ctx, unsigned start, unsigned count) } if (count) { BEGIN_NVC0(push, NVC0_3D(VB_ELEMENT_U32), 1); - PUSH_DATA (push, ctx->restart_index); + PUSH_DATA (push, 0x); ++elts; ctx->dest += ctx->vertex_size; ++pos; @@ -365,7 +365,7 @@ disp_vertices_i32(struct push_context *ctx, unsigned start, unsigned count) } if (count) { BEGIN_NVC0(push, NVC0_3D(VB_ELEMENT_U32), 1); - PUSH_DATA (push, ctx->restart_index); + PUSH_DATA (push, 0x); ++elts; ctx->dest += ctx->vertex_size; ++pos; @@ -381,6 +381,9 @@ disp_vertices_seq(struct push_context *ctx, unsigned start, unsigned count) struct translate *translate = ctx->translate; unsigned pos = 0; + /* XXX: This will read the data corresponding to the primitive restart index, +* maybe we should avoid that ? +*/ translate->run(translate, start, count, 0, ctx->instance_id, ctx->dest); do { unsigned nr = count; @@ -444,25 +447,37 @@ nvc0_push_vbo(struct nvc0_context *nvc0, const struct pipe_draw_info *info) nvc0_vertex_configure_translate(nvc0, info->index_bias); + if (nvc0->state.index_bias) { + /* this is already taken care of by translate */ + IMMED_NVC0(ctx.push, NVC0_3D(VB_ELEMENT_BASE), 0); + nvc0->state.index_bias = 0; + } + if (unlikely(ctx.edgeflag.enabled)) nvc0_push_map_edgeflag(&ctx, nvc0, info->index_bias); ctx.prim_restart = info->primitive_restart; ctx.restart_index = info->restart_index; + if (info->primitive_restart) { + /* NOTE: I hope we won't ever need that last index (~0). + * If we do, we have to disable primitive restart here always and + * use END,BEGIN to restart. (XXX: would that affect PrimitiveID ?) + * We could also deactive PRIM_RESTART_WITH_DRAW_ARRAYS temporarily, + * and add manual restart to disp_vertices_seq. + */ + BEGIN_NVC0(ctx.push, NVC0_3D(PRIM_RESTART_ENABLE), 2); + PUSH_DATA (ctx.push, 1); + PUSH_DATA (ctx.push, info->indexed ? 0x : info->restart_index); + } else + if (nvc0->state.prim_restart) { + IMMED_NVC0(ctx.push, NVC0_3D(PRIM_RESTART_ENABLE), 0); + } + nvc0->state.prim_restart = info->primitive_restart; + if (info->indexed) { nvc0_push_map_idxbuf(&ctx, nvc0); index_size = nvc0->idxbuf.index_size; - - if (info->primitive_restart) { - BEGIN_NVC0(ctx.push, NVC0_3D(PRIM_RESTART_ENABLE), 2); - PUSH_DATA (ctx.push, 1); - PUSH_DATA (ctx.push, info->restart_index); - } else - if (nvc0->state.prim_restart) { - IMMED_NVC0(ctx.push, NVC0_3D(PRIM_RESTART_ENABLE), 0); - } - nvc0->state.prim_restart = info->primitive_restart; } else { if (unlikely(info->count_from_stream_output)) { struct pipe_context *pipe = &nvc0->base.pipe; -- 1.8.5.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 0/3] nvc0: ARB_(multi_)draw_indirect support
The main patches are from Christoph. Unfortunately they're a little beyond my understanding of all the vertex-related details, but they generally seemed fine. I'm just going to push these unless someone steps up to review them. Christoph Bumiller (2): nvc0: add support for indirect drawing nvc0: fix translate path for PRIM_RESTART_WITH_DRAW_ARRAYS Ilia Mirkin (1): nouveau: check if a fence has already been signalled docs/GL3.txt | 5 +- docs/relnotes/10.3.html| 1 + src/gallium/drivers/nouveau/nouveau_fence.c| 3 + src/gallium/drivers/nouveau/nouveau_screen.c | 6 +- src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h | 2 +- src/gallium/drivers/nouveau/nv50/nv50_screen.c | 2 + src/gallium/drivers/nouveau/nvc0/mme/com9097.mme | 75 ++ src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h | 56 ++ src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h | 6 ++ src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 13 +++- src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c| 90 -- .../drivers/nouveau/nvc0/nvc0_vbo_translate.c | 41 ++ 12 files changed, 254 insertions(+), 46 deletions(-) -- 1.8.5.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 81139] Rendering sometimes halts in waiting for back buffers with dri3 & xwayland
https://bugs.freedesktop.org/show_bug.cgi?id=81139 --- Comment #3 from Boyan Ding --- Created attachment 102515 --> https://bugs.freedesktop.org/attachment.cgi?id=102515&action=edit A simple program that can effectively trigger the halt on my machine The problem persists with that patch. This is a simple program which I accidentally find can trigger the halt effectively on my machine, and is the same after applying that patch. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 81139] Rendering sometimes halts in waiting for back buffers with dri3 & xwayland
https://bugs.freedesktop.org/show_bug.cgi?id=81139 --- Comment #2 from Boyan Ding --- (In reply to comment #1) > Could you tell which distribution you are using ? I'm using Arch Linux, in which almost everything is vanilla. > My guess it that it is a libxcb bug. > Debian packages have the fix (which is > http://cgit.freedesktop.org/xcb/libxcb/commit/ > ?id=3b72a2c9d1d656c74c691a45689e1d637f669e3a) Thanks, I'll give it a try. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 81139] Rendering sometimes halts in waiting for back buffers with dri3 & xwayland
https://bugs.freedesktop.org/show_bug.cgi?id=81139 --- Comment #1 from Axel Davy --- Could you tell which distribution you are using ? My guess it that it is a libxcb bug. Debian packages have the fix (which is http://cgit.freedesktop.org/xcb/libxcb/commit/?id=3b72a2c9d1d656c74c691a45689e1d637f669e3a) -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 81139] New: Rendering sometimes halts in waiting for back buffers with dri3 & xwayland
https://bugs.freedesktop.org/show_bug.cgi?id=81139 Priority: medium Bug ID: 81139 Assignee: mesa-dev@lists.freedesktop.org Summary: Rendering sometimes halts in waiting for back buffers with dri3 & xwayland Severity: normal Classification: Unclassified OS: All Reporter: stu_...@126.com Hardware: Other Status: NEW Version: unspecified Component: GLX Product: Mesa Xwayland now uses dri3 & glamor as means of acceleration, but rendering sometimes halts randomly in waiting for back buffers(See Bug 80963 in wayland). glxgears (and probably programs rendering in single buffer) is affected. Stacktrace when halted is listed below: at glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); #0 0x770bd800 in __poll_nocancel () from /usr/lib/libc.so.6 #1 0x755fc992 in ?? () from /usr/lib/libxcb.so.1 #2 0x755fddc9 in xcb_wait_for_special_event () from /usr/lib/libxcb.so.1 #3 0x77bbc495 in dri3_find_back (c=0x605790, priv=0xa346e0) at dri3_glx.c:1103 #4 0x77bbc51b in dri3_get_buffer (driDrawable=0x6a48e0, format=4107, buffer_type=dri3_buffer_back, loaderPrivate=0xa346e0) at dri3_glx.c:1127 #5 0x77bbc92e in dri3_get_buffers (driDrawable=0x6a48e0, format=4107, stamp=0x6a4910, loaderPrivate=0xa346e0, buffer_mask=1, buffers=0x7fffe640) at dri3_glx.c:1274 #6 0x73563c10 in intel_update_image_buffers (brw=0x77fd4040, drawable=0x6a48e0) at brw_context.c:1395 #7 0x73563436 in intel_update_renderbuffers (context=0x6a4020, drawable=0x6a48e0) at brw_context.c:1087 #8 0x735634cd in intel_prepare_render (brw=0x77fd4040) at brw_context.c:1108 #9 0x73556969 in brw_clear (ctx=0x77fd4040, mask=18) at brw_clear.c:234 #10 0x731b875e in _mesa_Clear (mask=16640) at main/clear.c:226 #11 0x004027fa in draw () at gears.c:183 #12 0x776b1ac4 in ?? () from /usr/lib/libglut.so.3 #13 0x776b5329 in fgEnumWindows () from /usr/lib/libglut.so.3 #14 0x776b207d in glutMainLoopEvent () from /usr/lib/libglut.so.3 #15 0x776b28e5 in glutMainLoop () from /usr/lib/libglut.so.3 #16 0x004031af in main (argc=1, argv=0x7fffeb78) at gears.c:405 -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] i965: forward-declare struct brw_context in brw_reg.h
On Wednesday, July 09, 2014 09:26:49 PM Ilia Mirkin wrote: > Commit 54e91e7420 introduced a function declaration that uses > brw_context. While brw_context tends to get included in most files, it > is not when compiling intel_asm_annotation.c resulting in the following > warning: > > In file included from brw_shader.h:25:0, > from brw_cfg.h:32, > from intel_asm_annotation.c:24: > brw_reg.h:122:39: warning: 'struct brw_context' declared inside > parameter list [enabled by default] > brw_reg.h:122:39: warning: its scope is only this definition or > declaration, which is probably not what you want [enabled by default] > > Add a forward-declaration for struct brw_context to avoid the issue. > > Signed-off-by: Ilia Mirkin > --- > src/mesa/drivers/dri/i965/brw_reg.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h > index 494ce8c..28d3d94 100644 > --- a/src/mesa/drivers/dri/i965/brw_reg.h > +++ b/src/mesa/drivers/dri/i965/brw_reg.h > @@ -52,6 +52,8 @@ > extern "C" { > #endif > > +struct brw_context; > + > /** Number of general purpose registers (VS, WM, etc) */ > #define BRW_MAX_GRF 128 Thanks for fixing this. Reviewed-by: Kenneth Graunke signature.asc Description: This is a digitally signed message part. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCHv2 08/13] mesa: add infrastructure for threaded shader compilation
On Wed, Jul 9, 2014 at 10:42 PM, Brian Paul wrote: > On 07/09/2014 01:47 AM, Chia-I Wu wrote: >> >> Add _mesa_enable_glsl_threadpool to enable the thread pool for a context, >> and >> add ctx->Const.DeferCompileShader and ctx->Const.DeferLinkProgram to >> fine-control what gets threaded. >> >> Setting DeferCompileShader to true will make _mesa_glsl_compile_shader be >> executed in a worker thread. The function is thread-safe so there is no >> restriction on DeferCompileShader. >> >> Setting DeferLinkProgram to true will make _mesa_glsl_link_shader be >> executed >> in a worker thread. The function is thread-safe only when certain driver >> functions (as documented in struct gl_constants) are thread-safe. It is >> drivers' responsibility to fix those driver functions before setting >> DeferLinkProgram. >> >> When DeferLinkProgram is set, drivers are not supposed to inspect the >> context >> in their LinkShader callbacks. Instead, NotifyLinkShader is added. >> Drivers >> should inspect the context in NotifyLinkShader and save what they need for >> LinkShader in gl_shader_program. >> >> As a final note, most applications will not benefit from threaded shader >> compilation because they check GL_COMPILE_STATUS/GL_LINK_STATUS >> immediately, >> giving the worker threads no time to do their jobs. A possible >> improvement is >> to split LinkShader into two parts: the first part links and error checks >> while the second part optimizes and generates the machine code. With the >> split, we can always defer the second part to the thread pool. >> >> Signed-off-by: Chia-I Wu >> --- >> src/mesa/main/context.c | 29 +++ >> src/mesa/main/context.h | 3 ++ >> src/mesa/main/dd.h | 8 +++ >> src/mesa/main/mtypes.h | 34 >> src/mesa/main/pipelineobj.c | 18 +++ >> src/mesa/main/shaderapi.c | 122 >> +++- >> src/mesa/main/shaderobj.c | 74 +-- >> src/mesa/main/shaderobj.h | 55 ++-- >> 8 files changed, 322 insertions(+), 21 deletions(-) >> >> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c >> index b082159..e27450c 100644 >> --- a/src/mesa/main/context.c >> +++ b/src/mesa/main/context.c >> @@ -112,6 +112,7 @@ >> #include "points.h" >> #include "polygon.h" >> #include "queryobj.h" >> +#include "shaderapi.h" >> #include "syncobj.h" >> #include "rastpos.h" >> #include "remap.h" >> @@ -139,6 +140,7 @@ >> #endif >> >> #include "glsl_parser_extras.h" >> +#include "threadpool.h" >> #include >> >> >> @@ -1187,6 +1189,27 @@ _mesa_create_context(gl_api api, >> } >> } >> >> +void >> +_mesa_enable_glsl_threadpool(struct gl_context *ctx, int max_threads) >> +{ >> + if (!ctx->ThreadPool) >> + ctx->ThreadPool = _mesa_glsl_get_threadpool(max_threads); >> +} >> + >> +static void >> +wait_shader_object_cb(GLuint id, void *data, void *userData) >> +{ >> + struct gl_context *ctx = (struct gl_context *) userData; >> + struct gl_shader *sh = (struct gl_shader *) data; >> + >> + if (_mesa_validate_shader_target(ctx, sh->Type)) { >> + _mesa_wait_shaders(ctx, &sh, 1); >> + } >> + else { >> + struct gl_shader_program *shProg = (struct gl_shader_program *) >> data; >> + _mesa_wait_shader_program(ctx, shProg); >> + } >> +} >> >> /** >>* Free the data associated with the given context. >> @@ -1205,6 +1228,12 @@ _mesa_free_context_data( struct gl_context *ctx ) >> _mesa_make_current(ctx, NULL, NULL); >> } >> >> + if (ctx->ThreadPool) { >> + _mesa_HashWalk(ctx->Shared->ShaderObjects, wait_shader_object_cb, >> ctx); >> + _mesa_threadpool_unref(ctx->ThreadPool); >> + ctx->ThreadPool = NULL; >> + } >> + >> /* unreference WinSysDraw/Read buffers */ >> _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL); >> _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL); >> diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h >> index 792ab4c..b23f9fa 100644 >> --- a/src/mesa/main/context.h >> +++ b/src/mesa/main/context.h >> @@ -118,6 +118,9 @@ _mesa_create_context(gl_api api, >>const struct dd_function_table *driverFunctions); >> >> extern void >> +_mesa_enable_glsl_threadpool(struct gl_context *ctx, int max_threads); >> + >> +extern void >> _mesa_free_context_data( struct gl_context *ctx ); >> >> extern void >> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h >> index 633ea2c..38f8c68 100644 >> --- a/src/mesa/main/dd.h >> +++ b/src/mesa/main/dd.h >> @@ -447,6 +447,14 @@ struct dd_function_table { >> */ >> /*@{*/ >> /** >> +* Called when a shader program is to be linked. >> +* >> +* This is optional and gives drivers an opportunity to inspect the >> context >> +* and prepare for LinkShader, which may be deferred to another >> thread. >> +*/ >> + void (*NotifyLinkShader)(struct gl_context *ctx, >
Re: [Mesa-dev] [PATCHv2 06/13] glsl: add a generic thread pool data structure
On Wed, Jul 9, 2014 at 10:42 PM, Brian Paul wrote: > On 07/09/2014 01:47 AM, Chia-I Wu wrote: >> >> It can be used to implement, for example, threaded glCompileShader and >> glLinkProgram. >> >> v2: allow tasks to "complete" other tasks >> >> Signed-off-by: Chia-I Wu >> --- >> src/glsl/Makefile.am | 12 +- >> src/glsl/Makefile.sources | 3 +- >> src/glsl/tests/threadpool_test.cpp | 137 +++ >> src/glsl/threadpool.c | 476 >> + >> src/glsl/threadpool.h | 67 ++ > > > Does the threadpool code have anything GLSL-specific in it? If not, maybe > these files should go in src/mesa/main/ No, there is no GLSL-specific code here. The following commit (patch 7) adds the singleton of the pool to GLSL. The code is here because the singleton is the only user of it, and it does not make much sense to have more than a pool. I do not have a preference where these files should reside. I will move them if you or others have a preference. > > > >> 5 files changed, 693 insertions(+), 2 deletions(-) >> create mode 100644 src/glsl/tests/threadpool_test.cpp >> create mode 100644 src/glsl/threadpool.c >> create mode 100644 src/glsl/threadpool.h >> >> diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am >> index 00261fd..3d07af3 100644 >> --- a/src/glsl/Makefile.am >> +++ b/src/glsl/Makefile.am >> @@ -35,6 +35,7 @@ TESTS = glcpp/tests/glcpp-test >> \ >> tests/general-ir-test \ >> tests/optimization-test \ >> tests/ralloc-test \ >> + tests/threadpool-test \ >> tests/sampler-types-test\ >> tests/uniform-initializer-test >> >> @@ -48,6 +49,7 @@ check_PROGRAMS = \ >> glsl_test \ >> tests/general-ir-test \ >> tests/ralloc-test \ >> + tests/threadpool-test \ >> tests/sampler-types-test\ >> tests/uniform-initializer-test >> >> @@ -95,6 +97,14 @@ tests_ralloc_test_LDADD =\ >> $(top_builddir)/src/gtest/libgtest.la \ >> $(PTHREAD_LIBS) >> >> +tests_threadpool_test_SOURCES =\ >> + tests/threadpool_test.cpp \ >> + $(top_builddir)/src/glsl/threadpool.c >> +tests_threadpool_test_CFLAGS = $(PTHREAD_CFLAGS) >> +tests_threadpool_test_LDADD = \ >> + $(top_builddir)/src/gtest/libgtest.la \ >> + $(PTHREAD_LIBS) >> + >> tests_sampler_types_test_SOURCES =\ >> $(top_srcdir)/src/mesa/program/prog_hash_table.c\ >> $(top_srcdir)/src/mesa/program/symbol_table.c \ >> @@ -120,7 +130,7 @@ glcpp_glcpp_LDADD = \ >> libglcpp.la \ >> -lm >> >> -libglsl_la_LIBADD = libglcpp.la >> +libglsl_la_LIBADD = libglcpp.la $(PTHREAD_LIBS) >> libglsl_la_SOURCES = \ >> glsl_lexer.cpp \ >> glsl_parser.cpp \ >> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources >> index 6fc94d6..bab2358 100644 >> --- a/src/glsl/Makefile.sources >> +++ b/src/glsl/Makefile.sources >> @@ -103,7 +103,8 @@ LIBGLSL_FILES = \ >> $(GLSL_SRCDIR)/opt_tree_grafting.cpp \ >> $(GLSL_SRCDIR)/opt_vectorize.cpp \ >> $(GLSL_SRCDIR)/s_expression.cpp \ >> - $(GLSL_SRCDIR)/strtod.cpp >> + $(GLSL_SRCDIR)/strtod.cpp \ >> + $(GLSL_SRCDIR)/threadpool.c >> >> # glsl_compiler >> >> diff --git a/src/glsl/tests/threadpool_test.cpp >> b/src/glsl/tests/threadpool_test.cpp >> new file mode 100644 >> index 000..63f55c5 >> --- /dev/null >> +++ b/src/glsl/tests/threadpool_test.cpp >> @@ -0,0 +1,137 @@ >> +/* >> + * Copyright © 2014 LunarG, Inc. >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining >> a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without >> limitation >> + * the rights to use, copy, modify, merge, publish, distribute, >> sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice (including the >> next >> + * paragraph) shall be included in all copies or substantial portions of >> the >> + * Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >> EXPRESS OR >> + * IMPLIED, INCLUDING BUT NOT LIMITE
Re: [Mesa-dev] [PATCH 2/2] r600g: remove unused base_vector_chan variable
On 10.07.2014 10:26, Ilia Mirkin wrote: > Signed-off-by: Ilia Mirkin > --- > > Happened to notice the warning when compiling r600. Perhaps the use got > removed in some LLVM version cleanup? I didn't think it was important to go > digging though. > > src/gallium/drivers/r600/r600_llvm.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/src/gallium/drivers/r600/r600_llvm.c > b/src/gallium/drivers/r600/r600_llvm.c > index 4fcca69..d1e3255 100644 > --- a/src/gallium/drivers/r600/r600_llvm.c > +++ b/src/gallium/drivers/r600/r600_llvm.c > @@ -366,7 +366,6 @@ static void llvm_emit_epilogue(struct > lp_build_tgsi_context * bld_base) > case TGSI_SEMANTIC_CLIPVERTEX: { > LLVMValueRef args[3]; > unsigned reg_index; > - unsigned base_vector_chan; > LLVMValueRef adjusted_elements[4]; > for (reg_index = 0; reg_index < 2; reg_index > ++) { > for (chan = 0; chan < > TGSI_NUM_CHANNELS; chan++) { > Reviewed-by: Michel Dänzer -- Earthling Michel Dänzer| http://www.amd.com Libre software enthusiast |Mesa and X developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] i965: forward-declare struct brw_context in brw_reg.h
Commit 54e91e7420 introduced a function declaration that uses brw_context. While brw_context tends to get included in most files, it is not when compiling intel_asm_annotation.c resulting in the following warning: In file included from brw_shader.h:25:0, from brw_cfg.h:32, from intel_asm_annotation.c:24: brw_reg.h:122:39: warning: 'struct brw_context' declared inside parameter list [enabled by default] brw_reg.h:122:39: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] Add a forward-declaration for struct brw_context to avoid the issue. Signed-off-by: Ilia Mirkin --- src/mesa/drivers/dri/i965/brw_reg.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h index 494ce8c..28d3d94 100644 --- a/src/mesa/drivers/dri/i965/brw_reg.h +++ b/src/mesa/drivers/dri/i965/brw_reg.h @@ -52,6 +52,8 @@ extern "C" { #endif +struct brw_context; + /** Number of general purpose registers (VS, WM, etc) */ #define BRW_MAX_GRF 128 -- 1.8.5.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] r600g: remove unused base_vector_chan variable
Signed-off-by: Ilia Mirkin --- Happened to notice the warning when compiling r600. Perhaps the use got removed in some LLVM version cleanup? I didn't think it was important to go digging though. src/gallium/drivers/r600/r600_llvm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/r600/r600_llvm.c b/src/gallium/drivers/r600/r600_llvm.c index 4fcca69..d1e3255 100644 --- a/src/gallium/drivers/r600/r600_llvm.c +++ b/src/gallium/drivers/r600/r600_llvm.c @@ -366,7 +366,6 @@ static void llvm_emit_epilogue(struct lp_build_tgsi_context * bld_base) case TGSI_SEMANTIC_CLIPVERTEX: { LLVMValueRef args[3]; unsigned reg_index; - unsigned base_vector_chan; LLVMValueRef adjusted_elements[4]; for (reg_index = 0; reg_index < 2; reg_index ++) { for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) { -- 1.8.5.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2] glsl: handle a switch where default is in the middle of cases
On Thu, Jun 19, 2014 at 6:11 AM, Tapani Pälli wrote: > This fixes following tests in es3conform: > >shaders.switch.default_not_last_dynamic_vertex >shaders.switch.default_not_last_dynamic_fragment > > and makes following tests in Piglit pass: > >glsl-1.30/execution/switch/fs-default-notlast-fallthrough >glsl-1.30/execution/switch/fs-default_notlast > > No Piglit regressions. > > v2: take away unnecessary ir_if, just use conditional assignment > Tried verifying es3conform fixes. Patch doesn't compile anymore with mesa master. > Signed-off-by: Tapani Pälli > --- > src/glsl/ast_to_hir.cpp | 84 > +-- > src/glsl/glsl_parser_extras.h | 3 ++ > 2 files changed, 84 insertions(+), 3 deletions(-) > > diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp > index 132a955..2a105c6 100644 > --- a/src/glsl/ast_to_hir.cpp > +++ b/src/glsl/ast_to_hir.cpp > @@ -4503,6 +4503,12 @@ ast_switch_statement::hir(exec_list *instructions, > instructions->push_tail(new(ctx) ir_assignment(deref_is_break_var, >is_break_val)); > > + state->switch_state.run_default = > + new(ctx) ir_variable(glsl_type::bool_type, > + "run_default_tmp", > + ir_var_temporary); > + instructions->push_tail(state->switch_state.run_default); > + > /* Cache test expression. > */ > test_to_hir(instructions, state); > @@ -4557,8 +4563,72 @@ ir_rvalue * > ast_case_statement_list::hir(exec_list *instructions, > struct _mesa_glsl_parse_state *state) > { > - foreach_list_typed (ast_case_statement, case_stmt, link, & this->cases) > - case_stmt->hir(instructions, state); > + exec_list default_case, after_default, tmp; > + > + foreach_list_typed (ast_case_statement, case_stmt, link, & this->cases) { > + case_stmt->hir(&tmp, state); > + > + /* Default case. */ > + if (state->switch_state.previous_default && default_case.is_empty()) { > + default_case.append_list(&tmp); > + continue; > + } > + > + /* If default case found, append 'after_default' list. */ > + if (!default_case.is_empty()) > + after_default.append_list(&tmp); > + else > + instructions->append_list(&tmp); > + } > + > + /* Handle the default case. This is done here because default might not be > +* the last case. We need to add checks against following cases first to > see > +* if default should be chosen or not. > +*/ > + if (!default_case.is_empty()) { > + > + /* Default case was the last one, no checks required. */ > + if (after_default.is_empty()) { > + instructions->append_list(&default_case); > + return NULL; > + } > + > + ir_rvalue *const true_val = new (state) ir_constant(true); > + ir_dereference_variable *deref_run_default_var = > + new(state) ir_dereference_variable(state->switch_state.run_default); > + > + /* Choose to run default case initially, following conditional > + * assignments might change this. > + */ > + ir_assignment *const init_var = > + new(state) ir_assignment(deref_run_default_var, true_val); > + instructions->push_tail(init_var); > + > + foreach_list(n, &after_default) { > + ir_instruction *ir = (ir_instruction *) n; > + ir_assignment *assign = ir->as_assignment(); > + > + if (!assign) > +continue; > + > + /* Clone the check between case label and init expression. */ > + ir_expression *exp = (ir_expression*) assign->condition; > + ir_expression *clone = exp->clone(state, NULL); > + > + ir_dereference_variable *deref_var = > +new(state) > ir_dereference_variable(state->switch_state.run_default); > + ir_rvalue *const false_val = new (state) ir_constant(false); > + > + ir_assignment *const set_false = > +new(state) ir_assignment(deref_var, false_val, clone); > + > + instructions->push_tail(set_false); > + } > + > + /* Append default case and all cases after it. */ > + instructions->append_list(&default_case); > + instructions->append_list(&after_default); > + } > > /* Case statements do not have r-values. */ > return NULL; > @@ -4718,9 +4788,17 @@ ast_case_label::hir(exec_list *instructions, >} >state->switch_state.previous_default = this; > > + /* Set fallthru condition on 'run_default' bool. */ > + ir_dereference_variable *deref_run_default = > + new(ctx) ir_dereference_variable(state->switch_state.run_default); > + ir_rvalue *const cond_true = new(ctx) ir_constant(true); > + ir_expression *test_cond = new(ctx) ir_expression(ir_binop_all_equal, > +cond_true, > +d
Re: [Mesa-dev] [PATCH 2/3] exec_list: add a function to count the size of a list
On Wed, Jul 9, 2014 at 4:00 PM, Connor Abbott wrote: > On Wednesday, July 09, 2014 03:56:41 PM Ian Romanick wrote: >> On 07/08/2014 12:20 PM, Connor Abbott wrote: >> > Signed-off-by: Connor Abbott >> > --- >> > >> > src/glsl/list.h | 20 >> > 1 file changed, 20 insertions(+) >> > >> > diff --git a/src/glsl/list.h b/src/glsl/list.h >> > index ca6ee9d..68ab3fd 100644 >> > --- a/src/glsl/list.h >> > +++ b/src/glsl/list.h >> > @@ -324,6 +324,8 @@ struct exec_list { >> > >> > const exec_node *get_tail() const; >> > exec_node *get_tail(); >> > >> > + >> > + unsigned get_size(); >> > >> > void push_head(exec_node *n); >> > void push_tail(exec_node *n); >> > >> > @@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list) >> > >> > return !exec_list_is_empty(list) ? list->tail_pred : NULL; >> > >> > } >> > >> > +static inline unsigned >> > +exec_list_get_size(struct exec_list *list) >> > +{ >> > + unsigned size = 0; >> > + >> > + for (struct exec_node *node = list->head; node->next != NULL; >> > + node = node->next) { >> >> Maybe use foreach_in_list? Since Matt was so nice to create it... :) > > I would, except first of all, it's doing some typecasting we don't need to do, > and second of all, it's defined after this point (at the end of the file) and > I > didn't bother to move it up. If you think it's worth it though, I'm fine with > changing it... Right.. I guess not much point if you don't need the cast. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl/glcpp: move macro declaration before code to fix MSVC build
Brian Paul writes: Thanks for the fix, Brian. Reviewed-by: Carl Worth -Carl pgpRbh_5gMWxy.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2] glsl: Fix aggregates with dynamic initializers.
On Wed, 2014-07-02 at 22:16 +1000, Timothy Arceri wrote: > On Tue, 2014-07-01 at 14:45 -0700, Kenneth Graunke wrote: > > From: Cody Northrop > > > > Vectors are falling in to the ir_dereference_array() path. > > > > Without this change, the following glsl aborts the debug driver, > > or gets the wrong answer in release: > > > > mat2x2 a = mat2( vec2( 1.0, vertex.x ), vec2( 0.0, 1.0 ) ); > > > > Also submitting piglit tests, will reference in bug. > > > > v2: Rebase on Mesa master. > > > > Signed-off-by: Cody Northrop > > Reviewed-by: Courtney Goeltzenleuchter > > Reviewed-by: Kenneth Graunke > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79373 > > --- > > src/glsl/ast_function.cpp | 16 +--- > > 1 file changed, 13 insertions(+), 3 deletions(-) > > > > Hi Cody, > > > > Your patch didn't apply to master due to Matt's foreach_list changes; > > I did the obvious rebase. Otherwise, it looks great. Thanks for fixing > > this and improving our tests! > > > > I'll plan to commit this tomorrow unless anyone else has objections. > > > > --Ken > > > > diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp > > index cdb34cc..98288d2 100644 > > --- a/src/glsl/ast_function.cpp > > +++ b/src/glsl/ast_function.cpp > > @@ -743,10 +743,20 @@ process_vec_mat_constructor(exec_list *instructions, > > > > int i = 0; > > foreach_in_list(ir_rvalue, rhs, &actual_parameters) { > > - ir_rvalue *lhs = new(ctx) ir_dereference_array(var, > > - new(ctx) > > ir_constant(i)); > > + ir_instruction *assignment = NULL; > > + > > + if (var->type->is_array() || var->type->is_matrix()) { > > Is this ever actually an array??? I didn't mean for my question to hold this up for so long. But I cant see where this would ever be an array, if my understanding is correct process_array_constructor() should process any arrays. When removing var->type->is_array() all arb_shading_language_420pack piglit tests (including the new ones) continue to pass. So I don't think the is_array() condition is needed. If I'm wrong could you please give an example of when this would be an array as it might affect my arrays of arrays work. > > > + ir_rvalue *lhs = new(ctx) ir_dereference_array(var, > > + new(ctx) ir_constant(i)); > > + assignment = new(ctx) ir_assignment(lhs, rhs, NULL); > > + } else { > > + /* use writemask rather than index for vector */ > > + assert(var->type->is_vector()); > > + assert(i < 4); > > + ir_dereference *lhs = new(ctx) ir_dereference_variable(var); > > + assignment = new(ctx) ir_assignment(lhs, rhs, NULL, (unsigned)(1 > > << i)); > > + } > > > > - ir_instruction *assignment = new(ctx) ir_assignment(lhs, rhs, NULL); > >instructions->push_tail(assignment); > > > >i++; > > > ___ > 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 2/3] exec_list: add a function to count the size of a list
On Wednesday, July 09, 2014 03:56:41 PM Ian Romanick wrote: > On 07/08/2014 12:20 PM, Connor Abbott wrote: > > Signed-off-by: Connor Abbott > > --- > > > > src/glsl/list.h | 20 > > 1 file changed, 20 insertions(+) > > > > diff --git a/src/glsl/list.h b/src/glsl/list.h > > index ca6ee9d..68ab3fd 100644 > > --- a/src/glsl/list.h > > +++ b/src/glsl/list.h > > @@ -324,6 +324,8 @@ struct exec_list { > > > > const exec_node *get_tail() const; > > exec_node *get_tail(); > > > > + > > + unsigned get_size(); > > > > void push_head(exec_node *n); > > void push_tail(exec_node *n); > > > > @@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list) > > > > return !exec_list_is_empty(list) ? list->tail_pred : NULL; > > > > } > > > > +static inline unsigned > > +exec_list_get_size(struct exec_list *list) > > +{ > > + unsigned size = 0; > > + > > + for (struct exec_node *node = list->head; node->next != NULL; > > + node = node->next) { > > Maybe use foreach_in_list? Since Matt was so nice to create it... :) I would, except first of all, it's doing some typecasting we don't need to do, and second of all, it's defined after this point (at the end of the file) and I didn't bother to move it up. If you think it's worth it though, I'm fine with changing it... > > > + size++; > > + } > > + > > + return size; > > +} > > + > > > > static inline void > > exec_list_push_head(struct exec_list *list, struct exec_node *n) > > { > > > > @@ -537,6 +552,11 @@ inline exec_node *exec_list::get_tail() > > > > return exec_list_get_tail(this); > > > > } > > > > +inline unsigned exec_list::get_size() > > +{ > > + return exec_list_get_size(this); > > +} > > + > > > > inline void exec_list::push_head(exec_node *n) > > { > > > > exec_list_push_head(this, n); ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] glsl/glcpp: move macro declaration before code to fix MSVC build
--- src/glsl/glcpp/glcpp-parse.y |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 21c85b4..084078e 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -265,13 +265,14 @@ control_line: | HASH_UNDEF { glcpp_parser_resolve_implicit_version(parser); } IDENTIFIER NEWLINE { + macro_t *macro; if (strcmp("__LINE__", $3) == 0 || strcmp("__FILE__", $3) == 0 || strcmp("__VERSION__", $3) == 0) glcpp_error(& @1, parser, "Built-in (pre-defined)" " macro names can not be undefined."); - macro_t *macro = hash_table_find (parser->defines, $3); + macro = hash_table_find (parser->defines, $3); if (macro) { hash_table_remove (parser->defines, $3); ralloc_free (macro); -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] exec_list: add a function to count the size of a list
On Tue, Jul 8, 2014 at 12:20 PM, Connor Abbott wrote: > Signed-off-by: Connor Abbott > --- > src/glsl/list.h | 20 > 1 file changed, 20 insertions(+) > > diff --git a/src/glsl/list.h b/src/glsl/list.h > index ca6ee9d..68ab3fd 100644 > --- a/src/glsl/list.h > +++ b/src/glsl/list.h > @@ -324,6 +324,8 @@ struct exec_list { > > const exec_node *get_tail() const; > exec_node *get_tail(); > + > + unsigned get_size(); > > void push_head(exec_node *n); > void push_tail(exec_node *n); > @@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list) > return !exec_list_is_empty(list) ? list->tail_pred : NULL; > } > > +static inline unsigned > +exec_list_get_size(struct exec_list *list) I'd probably name this _length(), and move the function below the macros so you can use foreach_in_list. Other than that, the series is Reviewed-by: Matt Turner ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] exec_list: make various places use the new get_size() method
Wow. It's surprising how many places that shows up! Reviewed-by: Ian Romanick On 07/08/2014 12:21 PM, Connor Abbott wrote: > Instead of hand-rolling it. > > Signed-off-by: Connor Abbott > --- > src/glsl/ast_to_hir.cpp | 4 +--- > src/glsl/ir_reader.cpp| 7 +++ > src/glsl/opt_function_inlining.cpp| 7 ++- > src/mesa/drivers/dri/i965/brw_fs.cpp | 5 + > src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 4 +--- > src/mesa/program/ir_to_mesa.cpp | 5 + > 6 files changed, 9 insertions(+), 23 deletions(-) > > diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp > index 885bee5..a2ab26b 100644 > --- a/src/glsl/ast_to_hir.cpp > +++ b/src/glsl/ast_to_hir.cpp > @@ -5007,9 +5007,7 @@ ast_process_structure_or_interface_block(exec_list > *instructions, > * 'declarations' list in each of the elements. > */ > foreach_list_typed (ast_declarator_list, decl_list, link, declarations) { > - foreach_list_typed (ast_declaration, decl, link, > &decl_list->declarations) { > - decl_count++; > - } > + decl_count += decl_list->declarations.get_size(); > } > > /* Allocate storage for the fields and process the field > diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp > index 4017bdd..4f141de 100644 > --- a/src/glsl/ir_reader.cpp > +++ b/src/glsl/ir_reader.cpp > @@ -723,10 +723,9 @@ ir_reader::read_expression(s_expression *expr) >ir_read_error(expr, "invalid operator: %s", s_op->value()); >return NULL; > } > - > - int num_operands = -3; /* skip "expression" */ > - foreach_in_list(s_expression, e, &((s_list *) expr)->subexpressions) > - ++num_operands; > + > + /* skip "expression" */ > + int num_operands = (int) ((s_list *) expr)->subexpressions.get_size() - 3; > > int expected_operands = ir_expression::get_num_operands(op); > if (num_operands != expected_operands) { > diff --git a/src/glsl/opt_function_inlining.cpp > b/src/glsl/opt_function_inlining.cpp > index b84bb8e..9626639 100644 > --- a/src/glsl/opt_function_inlining.cpp > +++ b/src/glsl/opt_function_inlining.cpp > @@ -100,16 +100,13 @@ ir_call::generate_inline(ir_instruction *next_ir) > { > void *ctx = ralloc_parent(this); > ir_variable **parameters; > - int num_parameters; > + unsigned num_parameters; > int i; > struct hash_table *ht; > > ht = hash_table_ctor(0, hash_table_pointer_hash, > hash_table_pointer_compare); > > - num_parameters = 0; > - foreach_in_list(ir_rvalue, param, &this->callee->parameters) > - num_parameters++; > - > + num_parameters = this->callee->parameters.get_size(); > parameters = new ir_variable *[num_parameters]; > > /* Generate the declarations for the parameters to our inlined code, > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp > b/src/mesa/drivers/dri/i965/brw_fs.cpp > index a3ad375..6ab82b9 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp > @@ -2957,10 +2957,7 @@ fs_visitor::calculate_register_pressure() > invalidate_live_intervals(); > calculate_live_intervals(); > > - int num_instructions = 0; > - foreach_in_list(fs_inst, inst, &instructions) { > - ++num_instructions; > - } > + unsigned num_instructions = instructions.get_size(); > > regs_live_at_ip = rzalloc_array(mem_ctx, int, num_instructions); > > diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp > b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp > index 28e59c6..ce8dc36 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp > @@ -106,9 +106,7 @@ fs_copy_prop_dataflow::fs_copy_prop_dataflow(void > *mem_ctx, cfg_t *cfg, > num_acp = 0; > for (int b = 0; b < cfg->num_blocks; b++) { >for (int i = 0; i < ACP_HASH_SIZE; i++) { > - foreach_in_list(acp_entry, entry, &out_acp[b][i]) { > -num_acp++; > - } > + num_acp += out_acp[b][i].get_size(); >} > } > > diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp > index 1109051..cc9c8ae 100644 > --- a/src/mesa/program/ir_to_mesa.cpp > +++ b/src/mesa/program/ir_to_mesa.cpp > @@ -2814,10 +2814,7 @@ get_mesa_program(struct gl_context *ctx, > > prog->NumTemporaries = v.next_temp; > > - int num_instructions = 0; > - foreach_in_list(ir_instruction, node, &v.instructions) { > - num_instructions++; > - } > + unsigned num_instructions = v.instructions.get_size(); > > mesa_instructions = >(struct prog_instruction *)calloc(num_instructions, > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/3] exec_list: add a prepend function
Reviewed-by: Ian Romanick On 07/08/2014 12:20 PM, Connor Abbott wrote: > This complements the existing append function. It's implemented in a > rather simple way right now; it could be changed if performance is a > concern. > > Signed-off-by: Connor Abbott > --- > src/glsl/list.h | 20 +++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/src/glsl/list.h b/src/glsl/list.h > index 922bd68..ca6ee9d 100644 > --- a/src/glsl/list.h > +++ b/src/glsl/list.h > @@ -345,9 +345,15 @@ struct exec_list { > void move_nodes_to(exec_list *target); > > /** > -* Append all nodes from the source list to the target list > +* Append all nodes from the source list to the end of the target list > */ > void append_list(exec_list *source); > + > + /** > +* Prepend all nodes from the source list to the beginning of the target > +* list > +*/ > + void prepend_list(exec_list *source); > #endif > }; > > @@ -479,6 +485,13 @@ exec_list_append(struct exec_list *list, struct > exec_list *source) > } > > static inline void > +exec_list_prepend(struct exec_list *list, struct exec_list *source) > +{ > + exec_list_append(source, list); > + exec_list_move_nodes_to(source, list); > +} > + > +static inline void > exec_node_insert_list_before(struct exec_node *n, struct exec_list *before) > { > if (exec_list_is_empty(before)) > @@ -554,6 +567,11 @@ inline void exec_list::append_list(exec_list *source) > exec_list_append(this, source); > } > > +inline void exec_list::prepend_list(exec_list *source) > +{ > + exec_list_prepend(this, source); > +} > + > inline void exec_node::insert_before(exec_list *before) > { > exec_node_insert_list_before(this, before); > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] exec_list: add a function to count the size of a list
On 07/08/2014 12:20 PM, Connor Abbott wrote: > Signed-off-by: Connor Abbott > --- > src/glsl/list.h | 20 > 1 file changed, 20 insertions(+) > > diff --git a/src/glsl/list.h b/src/glsl/list.h > index ca6ee9d..68ab3fd 100644 > --- a/src/glsl/list.h > +++ b/src/glsl/list.h > @@ -324,6 +324,8 @@ struct exec_list { > > const exec_node *get_tail() const; > exec_node *get_tail(); > + > + unsigned get_size(); > > void push_head(exec_node *n); > void push_tail(exec_node *n); > @@ -405,6 +407,19 @@ exec_list_get_tail(struct exec_list *list) > return !exec_list_is_empty(list) ? list->tail_pred : NULL; > } > > +static inline unsigned > +exec_list_get_size(struct exec_list *list) > +{ > + unsigned size = 0; > + > + for (struct exec_node *node = list->head; node->next != NULL; > + node = node->next) { Maybe use foreach_in_list? Since Matt was so nice to create it... :) > + size++; > + } > + > + return size; > +} > + > static inline void > exec_list_push_head(struct exec_list *list, struct exec_node *n) > { > @@ -537,6 +552,11 @@ inline exec_node *exec_list::get_tail() > return exec_list_get_tail(this); > } > > +inline unsigned exec_list::get_size() > +{ > + return exec_list_get_size(this); > +} > + > inline void exec_list::push_head(exec_node *n) > { > exec_list_push_head(this, n); > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 08/15] svga: implement pipe_screen::get_driver_query_group_info v3
Well, the array can always be moved outside of the function and be declared as static. Marek On Thu, Jul 10, 2014 at 12:27 AM, Samuel Pitoiset wrote: > On 07/09/2014 09:49 PM, Marek Olšák wrote: >> >> If the driver queries are defined as an array, you can also use the >> Elements macro on the array. > > > For sure, but we can't do that here since the array is local to the > get_driver_query_info() callback. > > >> >> Marek >> >> On Wed, Jul 9, 2014 at 3:41 PM, Samuel Pitoiset >> wrote: >>> >>> On 07/09/2014 03:00 PM, Brian Paul wrote: On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: > > This enables GL_AMD_performance_monitor for svga. > > V2: >- s/pipe_context/pipe_screen in the commit msg > > V3: >- use util_get_driver_query_group_info > > Signed-off-by: Samuel Pitoiset > --- >src/gallium/drivers/svga/svga_screen.c | 11 +++ >1 file changed, 11 insertions(+) > > diff --git a/src/gallium/drivers/svga/svga_screen.c > b/src/gallium/drivers/svga/svga_screen.c > index f34664d..29257ab 100644 > --- a/src/gallium/drivers/svga/svga_screen.c > +++ b/src/gallium/drivers/svga/svga_screen.c > @@ -28,6 +28,7 @@ >#include "util/u_inlines.h" >#include "util/u_string.h" >#include "util/u_math.h" > +#include "util/u_query.h" > >#include "svga_winsys.h" >#include "svga_public.h" > @@ -555,6 +556,15 @@ svga_get_driver_query_info(struct pipe_screen > *screen, >} > > > +static int > +svga_get_driver_query_group_info(struct pipe_screen *screen, > + unsigned index, > + struct pipe_driver_query_group_info > *info) > +{ > + return util_get_driver_query_group_info(index, 3, info); What does 3 indicate? Please add some documentation for this. >>> >>> >>> Yes, it's the number of driver-specific queries. >>> >>> I suspect it's the number of driver-specific queries supported. If so, it would be better to have a new #define SVGA_QUERY_COUNT 3 in svga_context.h so that if someone adds a new query they won't have to hunt down this magic number here. >>> >>> >>> Okay, I'll add SVGA_QUERY_COUNT and same for others drivers which use >>> that >>> extension (freedreno, radeon and nvc0). >>> >>> Thanks. >>> >>> Thanks. > +} > + > + >static void >svga_destroy_screen( struct pipe_screen *screen ) >{ > @@ -615,6 +625,7 @@ svga_screen_create(struct svga_winsys_screen *sws) > screen->fence_signalled = svga_fence_signalled; > screen->fence_finish = svga_fence_finish; > screen->get_driver_query_info = svga_get_driver_query_info; > + screen->get_driver_query_group_info = > svga_get_driver_query_group_info; > svgascreen->sws = sws; > > svga_init_screen_resource_functions(svgascreen); > ___ 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 > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 08/15] svga: implement pipe_screen::get_driver_query_group_info v3
On 07/09/2014 09:49 PM, Marek Olšák wrote: If the driver queries are defined as an array, you can also use the Elements macro on the array. For sure, but we can't do that here since the array is local to the get_driver_query_info() callback. Marek On Wed, Jul 9, 2014 at 3:41 PM, Samuel Pitoiset wrote: On 07/09/2014 03:00 PM, Brian Paul wrote: On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: This enables GL_AMD_performance_monitor for svga. V2: - s/pipe_context/pipe_screen in the commit msg V3: - use util_get_driver_query_group_info Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/svga/svga_screen.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index f34664d..29257ab 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -28,6 +28,7 @@ #include "util/u_inlines.h" #include "util/u_string.h" #include "util/u_math.h" +#include "util/u_query.h" #include "svga_winsys.h" #include "svga_public.h" @@ -555,6 +556,15 @@ svga_get_driver_query_info(struct pipe_screen *screen, } +static int +svga_get_driver_query_group_info(struct pipe_screen *screen, + unsigned index, + struct pipe_driver_query_group_info *info) +{ + return util_get_driver_query_group_info(index, 3, info); What does 3 indicate? Please add some documentation for this. Yes, it's the number of driver-specific queries. I suspect it's the number of driver-specific queries supported. If so, it would be better to have a new #define SVGA_QUERY_COUNT 3 in svga_context.h so that if someone adds a new query they won't have to hunt down this magic number here. Okay, I'll add SVGA_QUERY_COUNT and same for others drivers which use that extension (freedreno, radeon and nvc0). Thanks. Thanks. +} + + static void svga_destroy_screen( struct pipe_screen *screen ) { @@ -615,6 +625,7 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->fence_signalled = svga_fence_signalled; screen->fence_finish = svga_fence_finish; screen->get_driver_query_info = svga_get_driver_query_info; + screen->get_driver_query_group_info = svga_get_driver_query_group_info; svgascreen->sws = sws; svga_init_screen_resource_functions(svgascreen); ___ 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 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i915: Fix up intelInitScreen2 for DRI3
On Thu, Jul 3, 2014 at 22:13:53 +0200, Adel Gadllah wrote: > Commit 442442026eb updated both i915 and i965 for DRI3 support, > but one check in intelInitScreen2 was missed for i915 causing crashes > when trying to use i915 with DRI3. > > So fix that up. > > Reported-by: Igor Gnatenko > Tested-by: František Zatloukal > Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1115323 > Cc: "10.2" > Signed-off-by: Adel Gadllah https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754297 Tested-by: Dirk Griesbach Cheers, Julien ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 80848] [dri3] Building mesa fails with dri3 enabled
https://bugs.freedesktop.org/show_bug.cgi?id=80848 Emil Velikov changed: What|Removed |Added Assignee|mesa-dev@lists.freedesktop. |kei...@keithp.com |org | --- Comment #2 from Emil Velikov --- All of the missing symbols are coming from libxcb commit 7983bf0fbdc(Add support for receiving fds in replies). Commit is part of libxcb-1.9.2 and libxcb-1.10. Bryan, Seems like you're missing the PKG_CONFIG_PATH which leads to the lack to the $PREFIX/include (or similar) -I flags thus the build break. Juha-Pekka Heikkilä, Have you build libxcb 1.9.2 or newer in the customer prefix ? If so we'll just need a oneline fix following Keith's confirmation of the following. Keith Can you clarify if we need to link against libxcb.so _only_ when building with dri3 or if this requirement has been there for ages ? Current mesa does not check for the package thus it picks up the system include/libs. This may be the key for the issues you and/or others have noticed (steamos-mesa has all the dri3 patches reverted). Cheers Emil -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 08/15] svga: implement pipe_screen::get_driver_query_group_info v3
If the driver queries are defined as an array, you can also use the Elements macro on the array. Marek On Wed, Jul 9, 2014 at 3:41 PM, Samuel Pitoiset wrote: > On 07/09/2014 03:00 PM, Brian Paul wrote: >> >> On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: >>> >>> This enables GL_AMD_performance_monitor for svga. >>> >>> V2: >>> - s/pipe_context/pipe_screen in the commit msg >>> >>> V3: >>> - use util_get_driver_query_group_info >>> >>> Signed-off-by: Samuel Pitoiset >>> --- >>> src/gallium/drivers/svga/svga_screen.c | 11 +++ >>> 1 file changed, 11 insertions(+) >>> >>> diff --git a/src/gallium/drivers/svga/svga_screen.c >>> b/src/gallium/drivers/svga/svga_screen.c >>> index f34664d..29257ab 100644 >>> --- a/src/gallium/drivers/svga/svga_screen.c >>> +++ b/src/gallium/drivers/svga/svga_screen.c >>> @@ -28,6 +28,7 @@ >>> #include "util/u_inlines.h" >>> #include "util/u_string.h" >>> #include "util/u_math.h" >>> +#include "util/u_query.h" >>> >>> #include "svga_winsys.h" >>> #include "svga_public.h" >>> @@ -555,6 +556,15 @@ svga_get_driver_query_info(struct pipe_screen >>> *screen, >>> } >>> >>> >>> +static int >>> +svga_get_driver_query_group_info(struct pipe_screen *screen, >>> + unsigned index, >>> + struct pipe_driver_query_group_info >>> *info) >>> +{ >>> + return util_get_driver_query_group_info(index, 3, info); >> >> >> What does 3 indicate? Please add some documentation for this. > > > Yes, it's the number of driver-specific queries. > > >> >> I suspect it's the number of driver-specific queries supported. If so, it >> would be better to have a new #define SVGA_QUERY_COUNT 3 in svga_context.h >> so that if someone adds a new query they won't have to hunt down this magic >> number here. > > > Okay, I'll add SVGA_QUERY_COUNT and same for others drivers which use that > extension (freedreno, radeon and nvc0). > > Thanks. > > >> >> Thanks. >> >> >>> +} >>> + >>> + >>> static void >>> svga_destroy_screen( struct pipe_screen *screen ) >>> { >>> @@ -615,6 +625,7 @@ svga_screen_create(struct svga_winsys_screen *sws) >>> screen->fence_signalled = svga_fence_signalled; >>> screen->fence_finish = svga_fence_finish; >>> screen->get_driver_query_info = svga_get_driver_query_info; >>> + screen->get_driver_query_group_info = >>> svga_get_driver_query_group_info; >>> svgascreen->sws = sws; >>> >>> svga_init_screen_resource_functions(svgascreen); >>> >> >> ___ >> 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 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: add some missing MESA/PIPE_FORMAT_R10G10B10A2_UNORM switch cases
For the series: Reviewed-by: Marek Olšák Marek On Wed, Jul 9, 2014 at 8:51 PM, Brian Paul wrote: > --- > src/mesa/state_tracker/st_format.c |4 > 1 file changed, 4 insertions(+) > > diff --git a/src/mesa/state_tracker/st_format.c > b/src/mesa/state_tracker/st_format.c > index 38d4ccf..a821180 100644 > --- a/src/mesa/state_tracker/st_format.c > +++ b/src/mesa/state_tracker/st_format.c > @@ -83,6 +83,8 @@ st_mesa_format_to_pipe_format(mesa_format mesaFormat) >return PIPE_FORMAT_B2G3R3_UNORM; > case MESA_FORMAT_B10G10R10A2_UNORM: >return PIPE_FORMAT_B10G10R10A2_UNORM; > + case MESA_FORMAT_R10G10B10A2_UNORM: > + return PIPE_FORMAT_R10G10B10A2_UNORM; > case MESA_FORMAT_L4A4_UNORM: >return PIPE_FORMAT_L4A4_UNORM; > case MESA_FORMAT_L8A8_UNORM: > @@ -439,6 +441,8 @@ st_pipe_format_to_mesa_format(enum pipe_format format) >return MESA_FORMAT_B2G3R3_UNORM; > case PIPE_FORMAT_B10G10R10A2_UNORM: >return MESA_FORMAT_B10G10R10A2_UNORM; > + case PIPE_FORMAT_R10G10B10A2_UNORM: > + return MESA_FORMAT_R10G10B10A2_UNORM; > case PIPE_FORMAT_L4A4_UNORM: >return MESA_FORMAT_L4A4_UNORM; > case PIPE_FORMAT_L8A8_UNORM: > -- > 1.7.10.4 > > ___ > 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
[Mesa-dev] [PATCH] i965/fs: Relax interference check in register coalescing.
A similar attempt was made in commit 5ff1e446 and was reverted in commit a39428cf after causing a regression in an ES 3 conformance test. The test still passes after this commit. total instructions in shared programs: 1994827 -> 1992858 (-0.10%) instructions in affected programs: 128247 -> 126278 (-1.54%) GAINED:0 LOST: 1 --- .../drivers/dri/i965/brw_fs_register_coalesce.cpp | 23 +++--- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp index e242e4f..3e3aeca 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp @@ -118,24 +118,25 @@ can_coalesce_vars(brw::fs_live_variables *live_intervals, if (!live_intervals->vars_interfere(var_from, var_to)) return true; - /* We know that the live ranges of A (var_from) and B (var_to) -* interfere because of the ->vars_interfere() call above. If the end -* of B's live range is after the end of A's range, then we know two -* things: -* - the start of B's live range must be in A's live range (since we -*already know the two ranges interfere, this is the only remaining -*possibility) -* - the interference isn't of the form we're looking for (where B is -*entirely inside A) -*/ - if (live_intervals->end[var_to] > live_intervals->end[var_from]) + int start_to = live_intervals->start[var_to]; + int end_to = live_intervals->end[var_to]; + int start_from = live_intervals->start[var_from]; + int end_from = live_intervals->end[var_from]; + + /* Variables interfere and one line range isn't a subset of the other. */ + if ((end_to > end_from && start_from < start_to) || + (end_from > end_to && start_to < start_from)) return false; + int start_ip = MIN2(start_to, start_from); int scan_ip = -1; foreach_in_list(fs_inst, scan_inst, instructions) { scan_ip++; + if (scan_ip < start_ip) + continue; + if (scan_inst->is_control_flow()) return false; -- 1.8.5.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] i965: Initialize new chunks of realloc'd memory.
Otherwise we'd compare uninitialized pointers with NULL and dereference, leading to crashes. --- src/mesa/drivers/dri/i965/intel_asm_annotation.c | 4 1 file changed, 4 insertions(+) diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.c b/src/mesa/drivers/dri/i965/intel_asm_annotation.c index 4717baf..6a51d89 100644 --- a/src/mesa/drivers/dri/i965/intel_asm_annotation.c +++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.c @@ -96,11 +96,15 @@ void annotate(struct brw_context *brw, struct backend_instruction *inst, unsigned offset) { if (annotation->ann_size <= annotation->ann_count) { + int old_size = annotation->ann_size; annotation->ann_size = MAX2(1024, annotation->ann_size * 2); annotation->ann = reralloc(annotation->mem_ctx, annotation->ann, struct annotation, annotation->ann_size); if (!annotation->ann) return; + + memset(annotation->ann + old_size, 0, + (annotation->ann_size - old_size) * sizeof(struct annotation)); } struct annotation *ann = &annotation->ann[annotation->ann_count++]; -- 1.8.5.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] st/mesa: add PIPE_FORMAT_R10G10B10A2_UNORM to format_map table
as a candidate for the GL_RGB10_A2 internal texture format. --- src/mesa/state_tracker/st_format.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index a821180..409079b 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -861,7 +861,8 @@ static const struct format_mapping format_map[] = { }, { { GL_RGB10_A2, 0 }, - { PIPE_FORMAT_B10G10R10A2_UNORM, DEFAULT_RGBA_FORMATS } + { PIPE_FORMAT_B10G10R10A2_UNORM, PIPE_FORMAT_R10G10B10A2_UNORM, +DEFAULT_RGBA_FORMATS } }, { { 4, GL_RGBA, GL_RGBA8, 0 }, -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] st/mesa: add some missing MESA/PIPE_FORMAT_R10G10B10A2_UNORM switch cases
--- src/mesa/state_tracker/st_format.c |4 1 file changed, 4 insertions(+) diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 38d4ccf..a821180 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -83,6 +83,8 @@ st_mesa_format_to_pipe_format(mesa_format mesaFormat) return PIPE_FORMAT_B2G3R3_UNORM; case MESA_FORMAT_B10G10R10A2_UNORM: return PIPE_FORMAT_B10G10R10A2_UNORM; + case MESA_FORMAT_R10G10B10A2_UNORM: + return PIPE_FORMAT_R10G10B10A2_UNORM; case MESA_FORMAT_L4A4_UNORM: return PIPE_FORMAT_L4A4_UNORM; case MESA_FORMAT_L8A8_UNORM: @@ -439,6 +441,8 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_B2G3R3_UNORM; case PIPE_FORMAT_B10G10R10A2_UNORM: return MESA_FORMAT_B10G10R10A2_UNORM; + case PIPE_FORMAT_R10G10B10A2_UNORM: + return MESA_FORMAT_R10G10B10A2_UNORM; case PIPE_FORMAT_L4A4_UNORM: return MESA_FORMAT_L4A4_UNORM; case PIPE_FORMAT_L8A8_UNORM: -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 80933] Fullscreen OpenGL programs (e.g. games) crash if focus lost then regained, something to do with automatic compositing suspension
https://bugs.freedesktop.org/show_bug.cgi?id=80933 --- Comment #3 from Benjamin Bellec --- (In reply to comment #0) > See also: https://github.com/ValveSoftware/Dota-2/issues/886 In this thread, all the bugs reports have been done with a proprietary driver (NVIDIA mostly, and also AMD). -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] gallium/u_blitter: fix some shader memory leaks
Reviewed-by: Marek Olšák Marek On Wed, Jul 9, 2014 at 5:42 PM, Brian Paul wrote: > The _msaa shaders weren't getting freed. > Cc: "10.2" > --- > src/gallium/auxiliary/util/u_blitter.c |9 + > 1 file changed, 9 insertions(+) > > diff --git a/src/gallium/auxiliary/util/u_blitter.c > b/src/gallium/auxiliary/util/u_blitter.c > index db0d1b8..20fbd80 100644 > --- a/src/gallium/auxiliary/util/u_blitter.c > +++ b/src/gallium/auxiliary/util/u_blitter.c > @@ -383,6 +383,15 @@ void util_blitter_destroy(struct blitter_context > *blitter) >if (ctx->fs_texfetch_stencil[i]) > ctx->delete_fs_state(pipe, ctx->fs_texfetch_stencil[i]); > > + if (ctx->fs_texfetch_col_msaa[i]) > + ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa[i]); > + if (ctx->fs_texfetch_depth_msaa[i]) > + ctx->delete_fs_state(pipe, ctx->fs_texfetch_depth_msaa[i]); > + if (ctx->fs_texfetch_depthstencil_msaa[i]) > + ctx->delete_fs_state(pipe, ctx->fs_texfetch_depthstencil_msaa[i]); > + if (ctx->fs_texfetch_stencil_msaa[i]) > + ctx->delete_fs_state(pipe, ctx->fs_texfetch_stencil_msaa[i]); > + >for (j = 0; j< Elements(ctx->fs_resolve[i]); j++) > for (f = 0; f < 2; f++) > if (ctx->fs_resolve[i][j][f]) > -- > 1.7.10.4 > > ___ > 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
[Mesa-dev] [Bug 80848] [dri3] Building mesa fails with dri3 enabled
https://bugs.freedesktop.org/show_bug.cgi?id=80848 Bryan Cain changed: What|Removed |Added Hardware|x86-64 (AMD64) |All Assignee|i...@freedesktop.org |mesa-dev@lists.freedesktop. ||org QA Contact|intel-3d-bugs@lists.freedes | |ktop.org| CC||bryancain3+...@gmail.com Component|Drivers/DRI/i965|GLX --- Comment #1 from Bryan Cain --- I'm getting the same errors at make install even without compiling i965, with this as my autogen string: ./autogen.sh --enable-texture-float --with-dri-drivers= --disable-gallium-llvm --with-gallium-drivers=nouveau --prefix=/home/bryan/wayland --enable-debug --with-egl-platforms=x11,wayland,drm --enable-gbm This is just a guess, but maybe it's a problem with non-standard build prefixes? The XCB libraries in $PREFIX/lib are compiled from the latest git, but the version installed in /usr/lib on my machine is ancient. -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] i965: overwriting parts of a register and optimization passes
On Wed, Jul 9, 2014 at 8:19 AM, Kenneth Graunke wrote: > On Tuesday, July 08, 2014 11:19:38 AM Iago Toral wrote: > >> Hi, > >> > >> I have some code that first initializes a register and then overwrites a > >> specific subregister. However, after the optimization passes in > >> brw_vec4.cpp the initialization instruction goes away. I see that live > >> intervals are computed for the destination register without considering > >> if we are writing only to a specific subregister, so I guess that is the > >> reason for this behaviour, but this strikes me as odd, as it defeats the > >> purpose of overwriting only specific subregs, so I guess there is > >> something else that I am missing. > >> > >> This an example of what is happening: > >> > >> mov(8) g6<1>.xUD g0<4,4,1>UD { > >> align16 WE_all 1Q }; > >> mov(1) g6.2<1>UD 0x0007UD { align1 > >> WE_all compacted }; > >> > >> The first MOV is removed from the instruction set when I put the second > >> MOV, however the second MOV should only be writing to subreg 6.2 and > >> keep the rest of register 6 intact, or at least that is what I am trying > >> to do... > >> > >> Can someone explain what is wrong with those two instructions? how > >> should I overwrite only a specific subregister without causing this > >> behavior? > >> > >> Thanks, > >> Iago > > > > This sounds a lot like the bug I fixed in: > > > > commit d0575d98fc595dcc17706dc73d1eb461027ca17a > > Author: Kenneth Graunke > > Date: Sat Jun 14 03:53:07 2014 -0700 > > > > i965/vec4: Fix dead code elimination for VGRFs of size > 1. > > > > where it would see those two as the same register, and delete the first MOV. > > > > You probably already have that in your tree though, right? If not, update :) > > If so, you might try turning off other optimization passes in brw_vec4.cpp > and see if it helps - sounds like a bug in one of them. Or you could add something like Matts DEBUG_OPTIMIZER from brw_fs.cpp to also cover brw_vec4.cpp. Kristian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] gallium/u_blitter: fix some shader memory leaks
The _msaa shaders weren't getting freed. Cc: "10.2" --- src/gallium/auxiliary/util/u_blitter.c |9 + 1 file changed, 9 insertions(+) diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index db0d1b8..20fbd80 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -383,6 +383,15 @@ void util_blitter_destroy(struct blitter_context *blitter) if (ctx->fs_texfetch_stencil[i]) ctx->delete_fs_state(pipe, ctx->fs_texfetch_stencil[i]); + if (ctx->fs_texfetch_col_msaa[i]) + ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa[i]); + if (ctx->fs_texfetch_depth_msaa[i]) + ctx->delete_fs_state(pipe, ctx->fs_texfetch_depth_msaa[i]); + if (ctx->fs_texfetch_depthstencil_msaa[i]) + ctx->delete_fs_state(pipe, ctx->fs_texfetch_depthstencil_msaa[i]); + if (ctx->fs_texfetch_stencil_msaa[i]) + ctx->delete_fs_state(pipe, ctx->fs_texfetch_stencil_msaa[i]); + for (j = 0; j< Elements(ctx->fs_resolve[i]); j++) for (f = 0; f < 2; f++) if (ctx->fs_resolve[i][j][f]) -- 1.7.10.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] i965: overwriting parts of a register and optimization passes
On Tuesday, July 08, 2014 11:19:38 AM Iago Toral wrote: > Hi, > > I have some code that first initializes a register and then overwrites a > specific subregister. However, after the optimization passes in > brw_vec4.cpp the initialization instruction goes away. I see that live > intervals are computed for the destination register without considering > if we are writing only to a specific subregister, so I guess that is the > reason for this behaviour, but this strikes me as odd, as it defeats the > purpose of overwriting only specific subregs, so I guess there is > something else that I am missing. > > This an example of what is happening: > > mov(8) g6<1>.xUD g0<4,4,1>UD { > align16 WE_all 1Q }; > mov(1) g6.2<1>UD 0x0007UD{ align1 > WE_all compacted }; > > The first MOV is removed from the instruction set when I put the second > MOV, however the second MOV should only be writing to subreg 6.2 and > keep the rest of register 6 intact, or at least that is what I am trying > to do... > > Can someone explain what is wrong with those two instructions? how > should I overwrite only a specific subregister without causing this > behavior? > > Thanks, > Iago This sounds a lot like the bug I fixed in: commit d0575d98fc595dcc17706dc73d1eb461027ca17a Author: Kenneth Graunke Date: Sat Jun 14 03:53:07 2014 -0700 i965/vec4: Fix dead code elimination for VGRFs of size > 1. where it would see those two as the same register, and delete the first MOV. You probably already have that in your tree though, right? If not, update :) If so, you might try turning off other optimization passes in brw_vec4.cpp and see if it helps - sounds like a bug in one of them. --Ken signature.asc Description: This is a digitally signed message part. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] tgsi: properly parse indirect dimension references (e.g. for UBOs)
On Wed, Jul 9, 2014 at 12:29 AM, Ilia Mirkin wrote: > Signed-off-by: Ilia Mirkin > --- > src/gallium/auxiliary/tgsi/tgsi_text.c | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c > b/src/gallium/auxiliary/tgsi/tgsi_text.c > index c6134c5..6403344 100644 > --- a/src/gallium/auxiliary/tgsi/tgsi_text.c > +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c > @@ -804,6 +804,13 @@ parse_src_operand( >src->Dimension.Indirect = 0; >src->Dimension.Dimension = 0; >src->Dimension.Index = bracket[0].index; > + if (bracket[0].ind_file != TGSI_FILE_NULL) { > + src->Dimension.Indirect = 1; > + src->DimIndirect.File = bracket[0].ind_file; > + src->DimIndirect.Index = bracket[0].ind_index; > + src->DimIndirect.Swizzle = bracket[0].ind_comp; > + src->DimIndirect.ArrayID = bracket[0].ind_array; > + } >bracket[0] = bracket[1]; > } > src->Register.Index = bracket[0].index; > > Reviewed-by: Brian Paul ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCHv2 00/13] multithread GLSL compiler
On 07/09/2014 01:47 AM, Chia-I Wu wrote: Hi list, This is my second try to add multithread support for the GLSL compiler. Changes since v1 are - glLinkProgram can now be threaded - added ctx->Const.DeferCompileShader and ctx->Const.DeferLinkProgram to allow drivers to control what get threaded - minimal changes to i965 to enable DeferLinkProgram The most interesting patch should be patch 8, which makes the necessary changes to core mesa. Patch 13 touches i965 and is more a RFC patch. v2 still requires applications to "Do the Right Thing" to benefit from multithread compiler. But that can be changed as noted in patch 8. I am open to suggestions. A summary of the patches: Patch 1 makes our GL_KRH_debug implementation thread-safe. Patch 2~5 make the GLSL compiler thread-safe. These are mostly the same as v1, except for how locale_t is initialized. Patch 6~7 add a singleton thread pool to the compiler. Patch 8 adds the infrastructure to core mesa to enable multithread compiling/linkg, and patch 9 adds a dri option to enable DeferCompileShader for i965. Patch 10~12 refactor some code in i965 and patch 13 adds the necessary changes to enable DeferLinkProgram. Patches 1-8 look pretty good to me. Just minor comments on #6 and #8. Also, if this goes in, let's mention this feature in the 10.3 release notes file. For 1-8: Reviewed-by: Brian Paul -Brian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCHv2 08/13] mesa: add infrastructure for threaded shader compilation
On 07/09/2014 01:47 AM, Chia-I Wu wrote: Add _mesa_enable_glsl_threadpool to enable the thread pool for a context, and add ctx->Const.DeferCompileShader and ctx->Const.DeferLinkProgram to fine-control what gets threaded. Setting DeferCompileShader to true will make _mesa_glsl_compile_shader be executed in a worker thread. The function is thread-safe so there is no restriction on DeferCompileShader. Setting DeferLinkProgram to true will make _mesa_glsl_link_shader be executed in a worker thread. The function is thread-safe only when certain driver functions (as documented in struct gl_constants) are thread-safe. It is drivers' responsibility to fix those driver functions before setting DeferLinkProgram. When DeferLinkProgram is set, drivers are not supposed to inspect the context in their LinkShader callbacks. Instead, NotifyLinkShader is added. Drivers should inspect the context in NotifyLinkShader and save what they need for LinkShader in gl_shader_program. As a final note, most applications will not benefit from threaded shader compilation because they check GL_COMPILE_STATUS/GL_LINK_STATUS immediately, giving the worker threads no time to do their jobs. A possible improvement is to split LinkShader into two parts: the first part links and error checks while the second part optimizes and generates the machine code. With the split, we can always defer the second part to the thread pool. Signed-off-by: Chia-I Wu --- src/mesa/main/context.c | 29 +++ src/mesa/main/context.h | 3 ++ src/mesa/main/dd.h | 8 +++ src/mesa/main/mtypes.h | 34 src/mesa/main/pipelineobj.c | 18 +++ src/mesa/main/shaderapi.c | 122 +++- src/mesa/main/shaderobj.c | 74 +-- src/mesa/main/shaderobj.h | 55 ++-- 8 files changed, 322 insertions(+), 21 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index b082159..e27450c 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -112,6 +112,7 @@ #include "points.h" #include "polygon.h" #include "queryobj.h" +#include "shaderapi.h" #include "syncobj.h" #include "rastpos.h" #include "remap.h" @@ -139,6 +140,7 @@ #endif #include "glsl_parser_extras.h" +#include "threadpool.h" #include @@ -1187,6 +1189,27 @@ _mesa_create_context(gl_api api, } } +void +_mesa_enable_glsl_threadpool(struct gl_context *ctx, int max_threads) +{ + if (!ctx->ThreadPool) + ctx->ThreadPool = _mesa_glsl_get_threadpool(max_threads); +} + +static void +wait_shader_object_cb(GLuint id, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_shader *sh = (struct gl_shader *) data; + + if (_mesa_validate_shader_target(ctx, sh->Type)) { + _mesa_wait_shaders(ctx, &sh, 1); + } + else { + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + _mesa_wait_shader_program(ctx, shProg); + } +} /** * Free the data associated with the given context. @@ -1205,6 +1228,12 @@ _mesa_free_context_data( struct gl_context *ctx ) _mesa_make_current(ctx, NULL, NULL); } + if (ctx->ThreadPool) { + _mesa_HashWalk(ctx->Shared->ShaderObjects, wait_shader_object_cb, ctx); + _mesa_threadpool_unref(ctx->ThreadPool); + ctx->ThreadPool = NULL; + } + /* unreference WinSysDraw/Read buffers */ _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL); _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL); diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 792ab4c..b23f9fa 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -118,6 +118,9 @@ _mesa_create_context(gl_api api, const struct dd_function_table *driverFunctions); extern void +_mesa_enable_glsl_threadpool(struct gl_context *ctx, int max_threads); + +extern void _mesa_free_context_data( struct gl_context *ctx ); extern void diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 633ea2c..38f8c68 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -447,6 +447,14 @@ struct dd_function_table { */ /*@{*/ /** +* Called when a shader program is to be linked. +* +* This is optional and gives drivers an opportunity to inspect the context +* and prepare for LinkShader, which may be deferred to another thread. +*/ + void (*NotifyLinkShader)(struct gl_context *ctx, +struct gl_shader_program *shader); + /** * Called when a shader program is linked. * * This gives drivers an opportunity to clone the IR and make their diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 5964576..316da23 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -71,6 +71,8 @@ typedef GLuint64 GLbitfield64; */ /*@{*/ struct _mesa_HashTable; +struct _mesa_t
Re: [Mesa-dev] [PATCHv2 06/13] glsl: add a generic thread pool data structure
On 07/09/2014 01:47 AM, Chia-I Wu wrote: It can be used to implement, for example, threaded glCompileShader and glLinkProgram. v2: allow tasks to "complete" other tasks Signed-off-by: Chia-I Wu --- src/glsl/Makefile.am | 12 +- src/glsl/Makefile.sources | 3 +- src/glsl/tests/threadpool_test.cpp | 137 +++ src/glsl/threadpool.c | 476 + src/glsl/threadpool.h | 67 ++ Does the threadpool code have anything GLSL-specific in it? If not, maybe these files should go in src/mesa/main/ 5 files changed, 693 insertions(+), 2 deletions(-) create mode 100644 src/glsl/tests/threadpool_test.cpp create mode 100644 src/glsl/threadpool.c create mode 100644 src/glsl/threadpool.h diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am index 00261fd..3d07af3 100644 --- a/src/glsl/Makefile.am +++ b/src/glsl/Makefile.am @@ -35,6 +35,7 @@ TESTS = glcpp/tests/glcpp-test \ tests/general-ir-test \ tests/optimization-test \ tests/ralloc-test \ + tests/threadpool-test \ tests/sampler-types-test\ tests/uniform-initializer-test @@ -48,6 +49,7 @@ check_PROGRAMS = \ glsl_test \ tests/general-ir-test \ tests/ralloc-test \ + tests/threadpool-test \ tests/sampler-types-test\ tests/uniform-initializer-test @@ -95,6 +97,14 @@ tests_ralloc_test_LDADD =\ $(top_builddir)/src/gtest/libgtest.la \ $(PTHREAD_LIBS) +tests_threadpool_test_SOURCES =\ + tests/threadpool_test.cpp \ + $(top_builddir)/src/glsl/threadpool.c +tests_threadpool_test_CFLAGS = $(PTHREAD_CFLAGS) +tests_threadpool_test_LDADD = \ + $(top_builddir)/src/gtest/libgtest.la \ + $(PTHREAD_LIBS) + tests_sampler_types_test_SOURCES =\ $(top_srcdir)/src/mesa/program/prog_hash_table.c\ $(top_srcdir)/src/mesa/program/symbol_table.c \ @@ -120,7 +130,7 @@ glcpp_glcpp_LDADD = \ libglcpp.la \ -lm -libglsl_la_LIBADD = libglcpp.la +libglsl_la_LIBADD = libglcpp.la $(PTHREAD_LIBS) libglsl_la_SOURCES = \ glsl_lexer.cpp \ glsl_parser.cpp \ diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources index 6fc94d6..bab2358 100644 --- a/src/glsl/Makefile.sources +++ b/src/glsl/Makefile.sources @@ -103,7 +103,8 @@ LIBGLSL_FILES = \ $(GLSL_SRCDIR)/opt_tree_grafting.cpp \ $(GLSL_SRCDIR)/opt_vectorize.cpp \ $(GLSL_SRCDIR)/s_expression.cpp \ - $(GLSL_SRCDIR)/strtod.cpp + $(GLSL_SRCDIR)/strtod.cpp \ + $(GLSL_SRCDIR)/threadpool.c # glsl_compiler diff --git a/src/glsl/tests/threadpool_test.cpp b/src/glsl/tests/threadpool_test.cpp new file mode 100644 index 000..63f55c5 --- /dev/null +++ b/src/glsl/tests/threadpool_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright © 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include +#include +#include +#include "c11/threads.h" + +#include "threadpool.h" + +#define NUM_THREADS 10 +#define OPS_PER_THREAD 100 +#define MAX_TASKS 10 + +static void +race_cb(void *data) +{ + usleep(1000 * 5); +} + +static int +race_random_op(void *data) +{ + struct _
Re: [Mesa-dev] [PATCH 06/15] mesa/st: implement GL_AMD_performance_monitor v4
On 07/09/2014 03:00 PM, Brian Paul wrote: In the subject, we usually use "st/mesa:". Okay. On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: From: Christoph Bumiller This is based on the original patch of Christoph Bumiller. (source: http://people.freedesktop.org/~chrisbmr/perfmon.diff) Drivers must implement get_driver_query_group_info and get_driver_query_info in order to enable this extension. V2: (Samuel Pitoiset) - fix compilation - improve the original code - rewrite some parts of the original code V3: - do not use pipe_driver_query_info::min_value which is always set to 0 V4: - only enable AMD_performance_monitor if the driver implements pipe_screen::get_driver_query_group_info and get_driver_query_info - make use of PIPE_DRIVER_QUERY_TYPE_* - use of GL_UNSIGNED_INT in st_GetPerfMonitorResult() Signed-off-by: Samuel Pitoiset --- src/mesa/Makefile.sources | 1 + src/mesa/state_tracker/st_cb_perfmon.c | 375 + src/mesa/state_tracker/st_cb_perfmon.h | 63 ++ src/mesa/state_tracker/st_context.c| 3 + src/mesa/state_tracker/st_extensions.c | 3 + 5 files changed, 445 insertions(+) create mode 100644 src/mesa/state_tracker/st_cb_perfmon.c create mode 100644 src/mesa/state_tracker/st_cb_perfmon.h diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index f4904fb..0b020e2 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -234,6 +234,7 @@ STATETRACKER_FILES = \ $(SRCDIR)state_tracker/st_cb_fbo.c \ $(SRCDIR)state_tracker/st_cb_feedback.c \ $(SRCDIR)state_tracker/st_cb_msaa.c \ +$(SRCDIR)state_tracker/st_cb_perfmon.c \ $(SRCDIR)state_tracker/st_cb_program.c \ $(SRCDIR)state_tracker/st_cb_queryobj.c \ $(SRCDIR)state_tracker/st_cb_rasterpos.c \ diff --git a/src/mesa/state_tracker/st_cb_perfmon.c b/src/mesa/state_tracker/st_cb_perfmon.c new file mode 100644 index 000..1883dc2 --- /dev/null +++ b/src/mesa/state_tracker/st_cb_perfmon.c @@ -0,0 +1,375 @@ +/* + * Copyright 2014 Nouveau Project + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: Christoph Bumiller + * Samuel Pitoiset + */ + +/** + * Performance monitoring counters interface to gallium. + */ + +#include "st_context.h" +#include "st_cb_perfmon.h" +#include "st_cb_bitmap.h" + +#include "main/bitset.h" + +/* Avoid multiple definitions */ +#undef MALLOC_STRUCT +#undef CALLOC_STRUCT + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" +#include "util/u_math.h" +#include "util/u_memory.h" + Can you put some comments on this function to explain what it does? It returns a PIPE_QUERY_x type >= PIPE_QUERY_DRIVER_SPECIFIC, right? You're right. Yes, I'll document this function. +static int +find_query_type(struct pipe_screen *screen, const char *name) +{ + int num_counters; + int type = -1; + int i; + + num_counters = screen->get_driver_query_info(screen, 0, NULL); + if (!num_counters) + return type; + + for (i = 0; i < num_counters; i++) { + struct pipe_driver_query_info info; + + if (!screen->get_driver_query_info(screen, i, &info)) + continue; + + if (!strncmp(info.name, name, strlen(name))) { + type = info.query_type; + break; + } + } + return type; +} + Comments on this function too, please. Okay. Thanks. +static void +reinitialize_perf_monitor(struct st_perf_monitor_object *stm, + struct pipe_context *pipe) +{ + int i; + + for (i = 0; i < stm->num_queries; i++) { + if (stm->queries[i].pq) { + pipe->destroy_query(pipe, stm->queries[i].pq); + stm->queries[i].pq = NULL; + } + } + stm->num_queries = 0; + stm->ready = FALSE; +} + +static struct gl_perf_monitor_object * +st_NewPerfMonitor() +{ + struct st_perf_monitor_object *stq = ST_C
Re: [Mesa-dev] [PATCH 1/3] gallium: switch dedicated centroid field to interpolation location
Am 09.07.2014 02:37, schrieb Ilia Mirkin: > On Sat, Jul 5, 2014 at 5:20 PM, Roland Scheidegger wrote: >> Am 05.07.2014 06:07, schrieb Ilia Mirkin: >>> The new location field can be either center, centroid, or sample, which >>> indicates the location that the shader should interpolate at. >> Looks good though maybe it should be mentioned in the interpolator >> section in tgsi.rst (yeah centroid wasn't neither). > > I added this bit: > > """ > +The Location field specifies the location inside the pixel that the > +interpolation should be done at, one of ``TGSI_INTERPOLATE_LOC_*``. > """ > > Let me know if you want me to resend. No that's just fine - there's a reason I added Reviewed-by and still having some nitpicks... Roland > >> In any case, >> Reviewed-by: Roland Scheidegger >> >>> >>> Signed-off-by: Ilia Mirkin >>> --- >>> >>> I tried to make sure I hit all the uses, but I guess a bunch of drivers >>> don't >>> look at the Centroid field at all? >> Well drivers not doing msaa or just fake one like llvmpipe aren't >> interested in it. >> And, this wasn't exposed via d3d9, though r300 reportedly can do it (the >> docs even mention it for r5xx), I suspect using some of the crazy >> backdoor mechanisms of d3d9. Some very quick look at the docs though >> don't indicate how this could be done (if it's even possible per >> interpolator) for these chips, which is I guess why centroid isn't handled. >> >>> >>> src/gallium/auxiliary/tgsi/tgsi_build.c | 8 >>> src/gallium/auxiliary/tgsi/tgsi_dump.c| 5 +++-- >>> src/gallium/auxiliary/tgsi/tgsi_scan.c| 2 +- >>> src/gallium/auxiliary/tgsi/tgsi_scan.h| 2 +- >>> src/gallium/auxiliary/tgsi/tgsi_strings.c | 7 +++ >>> src/gallium/auxiliary/tgsi/tgsi_strings.h | 2 ++ >>> src/gallium/auxiliary/tgsi/tgsi_ureg.c| 12 ++-- >>> src/gallium/auxiliary/tgsi/tgsi_ureg.h| 2 +- >>> src/gallium/drivers/ilo/shader/toy_tgsi.c | 2 +- >>> src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 2 +- >>> src/gallium/drivers/r600/r600_shader.c| 4 ++-- >>> src/gallium/drivers/radeonsi/si_shader.c | 6 +++--- >>> src/gallium/include/pipe/p_shader_tokens.h| 9 +++-- >>> src/mesa/state_tracker/st_glsl_to_tgsi.cpp| 5 +++-- >>> src/mesa/state_tracker/st_glsl_to_tgsi.h | 2 +- >>> src/mesa/state_tracker/st_program.c | 13 >>> + >>> 16 files changed, 52 insertions(+), 31 deletions(-) >>> >>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c >>> b/src/gallium/auxiliary/tgsi/tgsi_build.c >>> index 7621b6a..bef5c75 100644 >>> --- a/src/gallium/auxiliary/tgsi/tgsi_build.c >>> +++ b/src/gallium/auxiliary/tgsi/tgsi_build.c >>> @@ -200,7 +200,7 @@ tgsi_default_declaration_interp( void ) >>> struct tgsi_declaration_interp di; >>> >>> di.Interpolate = TGSI_INTERPOLATE_CONSTANT; >>> - di.Centroid = 0; >>> + di.Location = TGSI_INTERPOLATE_LOC_CENTER; >>> di.CylindricalWrap = 0; >>> di.Padding = 0; >>> >>> @@ -209,7 +209,7 @@ tgsi_default_declaration_interp( void ) >>> >>> static struct tgsi_declaration_interp >>> tgsi_build_declaration_interp(unsigned interpolate, >>> - unsigned centroid, >>> + unsigned interpolate_location, >>>unsigned cylindrical_wrap, >>>struct tgsi_declaration *declaration, >>>struct tgsi_header *header) >>> @@ -217,7 +217,7 @@ tgsi_build_declaration_interp(unsigned interpolate, >>> struct tgsi_declaration_interp di; >>> >>> di.Interpolate = interpolate; >>> - di.Centroid = centroid; >>> + di.Location = interpolate_location; >>> di.CylindricalWrap = cylindrical_wrap; >>> di.Padding = 0; >>> >>> @@ -433,7 +433,7 @@ tgsi_build_full_declaration( >>>size++; >>> >>>*di = tgsi_build_declaration_interp(full_decl->Interp.Interpolate, >>> - full_decl->Interp.Centroid, >>> + full_decl->Interp.Location, >>> >>> full_decl->Interp.CylindricalWrap, >>>declaration, >>>header); >>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c >>> b/src/gallium/auxiliary/tgsi/tgsi_dump.c >>> index 8e09bac..884d8cf 100644 >>> --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c >>> +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c >>> @@ -349,8 +349,9 @@ iter_declaration( >>> ENM( decl->Interp.Interpolate, tgsi_interpolate_names ); >>>} >>> >>> - if (decl->Interp.Centroid) { >>> - TXT( ", CENTROID" ); >>> + if (decl->Interp.Loc
Re: [Mesa-dev] [PATCH 07/15] gallium: add util_get_driver_query_group_info
On 07/09/2014 03:00 PM, Brian Paul wrote: On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: This generic function will be used to get groups of queries. Signed-off-by: Samuel Pitoiset --- src/gallium/auxiliary/Makefile.sources | 1 + src/gallium/auxiliary/util/u_query.c | 46 ++ src/gallium/auxiliary/util/u_query.h | 44 3 files changed, 91 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_query.c create mode 100644 src/gallium/auxiliary/util/u_query.h diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index 8919783..1188c94 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -130,6 +130,7 @@ C_SOURCES := \ util/u_math.c \ util/u_mm.c \ util/u_pstipple.c \ +util/u_query.c \ util/u_ringbuffer.c \ util/u_sampler.c \ util/u_simple_shaders.c \ diff --git a/src/gallium/auxiliary/util/u_query.c b/src/gallium/auxiliary/util/u_query.c new file mode 100644 index 000..327cabc --- /dev/null +++ b/src/gallium/auxiliary/util/u_query.c @@ -0,0 +1,46 @@ +/** + * + * Copyright 2014 Samuel Pitoiset + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **/ + +#include "util/u_memory.h" +#include "util/u_query.h" + Please add comments to this function to explain what it's doing. Okay, I'll add some comments. +int util_get_driver_query_group_info(unsigned index, unsigned num_queries, + struct pipe_driver_query_group_info *info) We usually put the function name on the next line. Should the return type be unsigned? Okay. Not necessarily. For example, pipe_driver_query_info() also uses an integer. Though, I followed the current convention that's why I used an integer. +{ + struct pipe_driver_query_group_info list[] = { + {"Driver queries", num_queries, num_queries} + }; + + if (!info) + return Elements(list); + + if (index >= Elements(list)) + return 0; + + *info = list[index]; + return 1; +} diff --git a/src/gallium/auxiliary/util/u_query.h b/src/gallium/auxiliary/util/u_query.h new file mode 100644 index 000..84f57d1 --- /dev/null +++ b/src/gallium/auxiliary/util/u_query.h @@ -0,0 +1,44 @@ +/** + * + * Copyright 2014 Samuel Pitoiset + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **/ + +#ifndef U_QUER
Re: [Mesa-dev] [PATCH 08/15] svga: implement pipe_screen::get_driver_query_group_info v3
On 07/09/2014 03:00 PM, Brian Paul wrote: On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: This enables GL_AMD_performance_monitor for svga. V2: - s/pipe_context/pipe_screen in the commit msg V3: - use util_get_driver_query_group_info Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/svga/svga_screen.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index f34664d..29257ab 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -28,6 +28,7 @@ #include "util/u_inlines.h" #include "util/u_string.h" #include "util/u_math.h" +#include "util/u_query.h" #include "svga_winsys.h" #include "svga_public.h" @@ -555,6 +556,15 @@ svga_get_driver_query_info(struct pipe_screen *screen, } +static int +svga_get_driver_query_group_info(struct pipe_screen *screen, + unsigned index, + struct pipe_driver_query_group_info *info) +{ + return util_get_driver_query_group_info(index, 3, info); What does 3 indicate? Please add some documentation for this. Yes, it's the number of driver-specific queries. I suspect it's the number of driver-specific queries supported. If so, it would be better to have a new #define SVGA_QUERY_COUNT 3 in svga_context.h so that if someone adds a new query they won't have to hunt down this magic number here. Okay, I'll add SVGA_QUERY_COUNT and same for others drivers which use that extension (freedreno, radeon and nvc0). Thanks. Thanks. +} + + static void svga_destroy_screen( struct pipe_screen *screen ) { @@ -615,6 +625,7 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->fence_signalled = svga_fence_signalled; screen->fence_finish = svga_fence_finish; screen->get_driver_query_info = svga_get_driver_query_info; + screen->get_driver_query_group_info = svga_get_driver_query_group_info; svgascreen->sws = sws; svga_init_screen_resource_functions(svgascreen); ___ 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 12/15] docs: mark GL_AMD_performance_monitor for the 10.3 release
On 07/09/2014 03:10 PM, Marek Olšák wrote: Also radeonsi, because the query code shared between both drivers. Added, thanks. Marek On Wed, Jul 9, 2014 at 4:34 PM, Samuel Pitoiset wrote: GL_AMD_performance_monitor is supported by nvc0, svga, freedreno and radeon. Signed-off-by: Samuel Pitoiset --- docs/relnotes/10.3.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/relnotes/10.3.html b/docs/relnotes/10.3.html index 2e718fc..e73e078 100644 --- a/docs/relnotes/10.3.html +++ b/docs/relnotes/10.3.html @@ -56,6 +56,7 @@ Note: some of the new features are only available with certain drivers. GL_ARB_seamless_cubemap_per_texture on i965, llvmpipe, nvc0, r600, radeonsi, softpipe GL_ARB_fragment_layer_viewport on nv50, nvc0, llvmpipe, r600 GL_AMD_vertex_shader_viewport_index on i965/gen7+, r600 +GL_AMD_performance_monitor on nvc0, r600, svga, freedreno -- 2.0.0 ___ 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 12/15] docs: mark GL_AMD_performance_monitor for the 10.3 release
Also radeonsi, because the query code shared between both drivers. Marek On Wed, Jul 9, 2014 at 4:34 PM, Samuel Pitoiset wrote: > GL_AMD_performance_monitor is supported by nvc0, svga, freedreno and > radeon. > > Signed-off-by: Samuel Pitoiset > --- > docs/relnotes/10.3.html | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/docs/relnotes/10.3.html b/docs/relnotes/10.3.html > index 2e718fc..e73e078 100644 > --- a/docs/relnotes/10.3.html > +++ b/docs/relnotes/10.3.html > @@ -56,6 +56,7 @@ Note: some of the new features are only available with > certain drivers. > GL_ARB_seamless_cubemap_per_texture on i965, llvmpipe, nvc0, r600, > radeonsi, softpipe > GL_ARB_fragment_layer_viewport on nv50, nvc0, llvmpipe, r600 > GL_AMD_vertex_shader_viewport_index on i965/gen7+, r600 > +GL_AMD_performance_monitor on nvc0, r600, svga, freedreno > > > > -- > 2.0.0 > > ___ > 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] radeonsi: fix order of r600_need_dma_space and r600_context_bo_reloc
On Wed, Jul 9, 2014 at 8:38 AM, Christian König wrote: > From: Christian König > > Signed-off-by: Christian König CC stable? Alex > --- > src/gallium/drivers/radeonsi/si_dma.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/gallium/drivers/radeonsi/si_dma.c > b/src/gallium/drivers/radeonsi/si_dma.c > index dc8c609..26f1e1b 100644 > --- a/src/gallium/drivers/radeonsi/si_dma.c > +++ b/src/gallium/drivers/radeonsi/si_dma.c > @@ -91,12 +91,13 @@ static void si_dma_copy_buffer(struct si_context *ctx, > } > ncopy = (size / max_csize) + !!(size % max_csize); > > + r600_need_dma_space(&ctx->b, ncopy * 5); > + > r600_context_bo_reloc(&ctx->b, &ctx->b.rings.dma, rsrc, > RADEON_USAGE_READ, > RADEON_PRIO_MIN); > r600_context_bo_reloc(&ctx->b, &ctx->b.rings.dma, rdst, > RADEON_USAGE_WRITE, > RADEON_PRIO_MIN); > > - r600_need_dma_space(&ctx->b, ncopy * 5); > for (i = 0; i < ncopy; i++) { > csize = size < max_csize ? size : max_csize; > cs->buf[cs->cdw++] = SI_DMA_PACKET(SI_DMA_PACKET_COPY, > sub_cmd, csize); > -- > 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 1/2] mesa/st: add support for dynamic ubo selection
On 07/08/2014 08:40 PM, Ilia Mirkin wrote: Signed-off-by: Ilia Mirkin --- With ChrisF's patches to add support for this in core mesa, this generates code like: FRAG DCL OUT[0], COLOR DCL CONST[0] DCL CONST[1][0] DCL CONST[2][0] DCL CONST[3][0] DCL CONST[4][0] DCL TEMP[0], LOCAL DCL ADDR[0..1] IMM[0] UINT32 {0, 0, 0, 0} IMM[1] INT32 {1, 0, 0, 0} 0: UADD TEMP[0].x, CONST[0]., IMM[1]. 1: UARL ADDR[1].x, TEMP[0]. 2: UARL ADDR[1].x, TEMP[0]. 3: MOV TEMP[0], CONST[ADDR[1].x][0] 4: MOV OUT[0], TEMP[0] 5: END Not sure what the deal is with the two UARL's, but nouveau's backend removes one of them pretty easily. I assume others handle this too. Yeah, I noticed this too when I was doing some UBO work last week. I haven't had time to investigate yet. -Brian Unfortunately the core patches aren't quite ready yet, but this patch doesn't regress anything. src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9bc7500..3202c56 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1947,16 +1947,16 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) break; case ir_binop_ubo_load: { - ir_constant *uniform_block = ir->operands[0]->as_constant(); + ir_constant *const_uniform_block = ir->operands[0]->as_constant(); ir_constant *const_offset_ir = ir->operands[1]->as_constant(); unsigned const_offset = const_offset_ir ? const_offset_ir->value.u[0] : 0; + unsigned const_block = const_uniform_block ? const_uniform_block->value.u[0] + 1 : 0; st_src_reg index_reg = get_temp(glsl_type::uint_type); st_src_reg cbuf; cbuf.type = glsl_type::vec4_type->base_type; cbuf.file = PROGRAM_CONSTANT; cbuf.index = 0; - cbuf.index2D = uniform_block->value.u[0] + 1; cbuf.reladdr = NULL; cbuf.negate = 0; @@ -1966,7 +1966,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) /* Constant index into constant buffer */ cbuf.reladdr = NULL; cbuf.index = const_offset / 16; - cbuf.has_index2 = true; } else { /* Relative/variable index into constant buffer */ @@ -1976,6 +1975,21 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg)); } + if (const_uniform_block) { + /* Constant constant buffer */ + cbuf.reladdr2 = NULL; + cbuf.index2D = const_block; + cbuf.has_index2 = true; + } + else { + /* Relative/variable constant buffer */ + emit(ir, TGSI_OPCODE_UADD, st_dst_reg(index_reg), op[0], + st_src_reg_for_int(1)); + cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg); + memcpy(cbuf.reladdr2, &index_reg, sizeof(index_reg)); + cbuf.has_index2 = true; + } + cbuf.swizzle = swizzle_for_size(ir->type->vector_elements); cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 4, const_offset % 16 / 4, ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] radeonsi: fix order of r600_need_dma_space and r600_context_bo_reloc
Reviewed-by: Marek Olšák Marek On Wed, Jul 9, 2014 at 2:38 PM, Christian König wrote: > From: Christian König > > Signed-off-by: Christian König > --- > src/gallium/drivers/radeonsi/si_dma.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/gallium/drivers/radeonsi/si_dma.c > b/src/gallium/drivers/radeonsi/si_dma.c > index dc8c609..26f1e1b 100644 > --- a/src/gallium/drivers/radeonsi/si_dma.c > +++ b/src/gallium/drivers/radeonsi/si_dma.c > @@ -91,12 +91,13 @@ static void si_dma_copy_buffer(struct si_context *ctx, > } > ncopy = (size / max_csize) + !!(size % max_csize); > > + r600_need_dma_space(&ctx->b, ncopy * 5); > + > r600_context_bo_reloc(&ctx->b, &ctx->b.rings.dma, rsrc, > RADEON_USAGE_READ, > RADEON_PRIO_MIN); > r600_context_bo_reloc(&ctx->b, &ctx->b.rings.dma, rdst, > RADEON_USAGE_WRITE, > RADEON_PRIO_MIN); > > - r600_need_dma_space(&ctx->b, ncopy * 5); > for (i = 0; i < ncopy; i++) { > csize = size < max_csize ? size : max_csize; > cs->buf[cs->cdw++] = SI_DMA_PACKET(SI_DMA_PACKET_COPY, > sub_cmd, csize); > -- > 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 07/15] gallium: add util_get_driver_query_group_info
On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: This generic function will be used to get groups of queries. Signed-off-by: Samuel Pitoiset --- src/gallium/auxiliary/Makefile.sources | 1 + src/gallium/auxiliary/util/u_query.c | 46 ++ src/gallium/auxiliary/util/u_query.h | 44 3 files changed, 91 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_query.c create mode 100644 src/gallium/auxiliary/util/u_query.h diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index 8919783..1188c94 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -130,6 +130,7 @@ C_SOURCES := \ util/u_math.c \ util/u_mm.c \ util/u_pstipple.c \ + util/u_query.c \ util/u_ringbuffer.c \ util/u_sampler.c \ util/u_simple_shaders.c \ diff --git a/src/gallium/auxiliary/util/u_query.c b/src/gallium/auxiliary/util/u_query.c new file mode 100644 index 000..327cabc --- /dev/null +++ b/src/gallium/auxiliary/util/u_query.c @@ -0,0 +1,46 @@ +/** + * + * Copyright 2014 Samuel Pitoiset + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **/ + +#include "util/u_memory.h" +#include "util/u_query.h" + Please add comments to this function to explain what it's doing. +int util_get_driver_query_group_info(unsigned index, unsigned num_queries, + struct pipe_driver_query_group_info *info) We usually put the function name on the next line. Should the return type be unsigned? +{ + struct pipe_driver_query_group_info list[] = { + {"Driver queries", num_queries, num_queries} + }; + + if (!info) + return Elements(list); + + if (index >= Elements(list)) + return 0; + + *info = list[index]; + return 1; +} diff --git a/src/gallium/auxiliary/util/u_query.h b/src/gallium/auxiliary/util/u_query.h new file mode 100644 index 000..84f57d1 --- /dev/null +++ b/src/gallium/auxiliary/util/u_query.h @@ -0,0 +1,44 @@ +/** + * + * Copyright 2014 Samuel Pitoiset + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **/ + +#ifndef U_QUERY_H +#define U_QUERY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "pipe/p_state.h" + +int util_get_driver_query_group_info(unsigned index, unsigned num_queries, + struct pipe_driver_query_group_info *info); + +#ifde
Re: [Mesa-dev] [PATCH 06/15] mesa/st: implement GL_AMD_performance_monitor v4
In the subject, we usually use "st/mesa:". On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: From: Christoph Bumiller This is based on the original patch of Christoph Bumiller. (source: http://people.freedesktop.org/~chrisbmr/perfmon.diff) Drivers must implement get_driver_query_group_info and get_driver_query_info in order to enable this extension. V2: (Samuel Pitoiset) - fix compilation - improve the original code - rewrite some parts of the original code V3: - do not use pipe_driver_query_info::min_value which is always set to 0 V4: - only enable AMD_performance_monitor if the driver implements pipe_screen::get_driver_query_group_info and get_driver_query_info - make use of PIPE_DRIVER_QUERY_TYPE_* - use of GL_UNSIGNED_INT in st_GetPerfMonitorResult() Signed-off-by: Samuel Pitoiset --- src/mesa/Makefile.sources | 1 + src/mesa/state_tracker/st_cb_perfmon.c | 375 + src/mesa/state_tracker/st_cb_perfmon.h | 63 ++ src/mesa/state_tracker/st_context.c| 3 + src/mesa/state_tracker/st_extensions.c | 3 + 5 files changed, 445 insertions(+) create mode 100644 src/mesa/state_tracker/st_cb_perfmon.c create mode 100644 src/mesa/state_tracker/st_cb_perfmon.h diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index f4904fb..0b020e2 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -234,6 +234,7 @@ STATETRACKER_FILES = \ $(SRCDIR)state_tracker/st_cb_fbo.c \ $(SRCDIR)state_tracker/st_cb_feedback.c \ $(SRCDIR)state_tracker/st_cb_msaa.c \ + $(SRCDIR)state_tracker/st_cb_perfmon.c \ $(SRCDIR)state_tracker/st_cb_program.c \ $(SRCDIR)state_tracker/st_cb_queryobj.c \ $(SRCDIR)state_tracker/st_cb_rasterpos.c \ diff --git a/src/mesa/state_tracker/st_cb_perfmon.c b/src/mesa/state_tracker/st_cb_perfmon.c new file mode 100644 index 000..1883dc2 --- /dev/null +++ b/src/mesa/state_tracker/st_cb_perfmon.c @@ -0,0 +1,375 @@ +/* + * Copyright 2014 Nouveau Project + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: Christoph Bumiller + * Samuel Pitoiset + */ + +/** + * Performance monitoring counters interface to gallium. + */ + +#include "st_context.h" +#include "st_cb_perfmon.h" +#include "st_cb_bitmap.h" + +#include "main/bitset.h" + +/* Avoid multiple definitions */ +#undef MALLOC_STRUCT +#undef CALLOC_STRUCT + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" +#include "util/u_math.h" +#include "util/u_memory.h" + Can you put some comments on this function to explain what it does? It returns a PIPE_QUERY_x type >= PIPE_QUERY_DRIVER_SPECIFIC, right? +static int +find_query_type(struct pipe_screen *screen, const char *name) +{ + int num_counters; + int type = -1; + int i; + + num_counters = screen->get_driver_query_info(screen, 0, NULL); + if (!num_counters) + return type; + + for (i = 0; i < num_counters; i++) { + struct pipe_driver_query_info info; + + if (!screen->get_driver_query_info(screen, i, &info)) + continue; + + if (!strncmp(info.name, name, strlen(name))) { + type = info.query_type; + break; + } + } + return type; +} + Comments on this function too, please. +static void +reinitialize_perf_monitor(struct st_perf_monitor_object *stm, + struct pipe_context *pipe) +{ + int i; + + for (i = 0; i < stm->num_queries; i++) { + if (stm->queries[i].pq) { + pipe->destroy_query(pipe, stm->queries[i].pq); + stm->queries[i].pq = NULL; + } + } + stm->num_queries = 0; + stm->ready = FALSE; +} + +static struct gl_perf_monitor_object * +st_NewPerfMonitor() +{ + struct st_perf_monitor_object *stq = ST_CALLOC_STRUCT(st_perf_monitor_object); + if (stq) + return &stq->base; + return NULL; +} + +static void +st_DeletePerfMo
Re: [Mesa-dev] [PATCH 08/15] svga: implement pipe_screen::get_driver_query_group_info v3
On 07/09/2014 08:34 AM, Samuel Pitoiset wrote: This enables GL_AMD_performance_monitor for svga. V2: - s/pipe_context/pipe_screen in the commit msg V3: - use util_get_driver_query_group_info Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/svga/svga_screen.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index f34664d..29257ab 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -28,6 +28,7 @@ #include "util/u_inlines.h" #include "util/u_string.h" #include "util/u_math.h" +#include "util/u_query.h" #include "svga_winsys.h" #include "svga_public.h" @@ -555,6 +556,15 @@ svga_get_driver_query_info(struct pipe_screen *screen, } +static int +svga_get_driver_query_group_info(struct pipe_screen *screen, + unsigned index, + struct pipe_driver_query_group_info *info) +{ + return util_get_driver_query_group_info(index, 3, info); What does 3 indicate? Please add some documentation for this. I suspect it's the number of driver-specific queries supported. If so, it would be better to have a new #define SVGA_QUERY_COUNT 3 in svga_context.h so that if someone adds a new query they won't have to hunt down this magic number here. Thanks. +} + + static void svga_destroy_screen( struct pipe_screen *screen ) { @@ -615,6 +625,7 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->fence_signalled = svga_fence_signalled; screen->fence_finish = svga_fence_finish; screen->get_driver_query_info = svga_get_driver_query_info; + screen->get_driver_query_group_info = svga_get_driver_query_group_info; svgascreen->sws = sws; svga_init_screen_resource_functions(svgascreen); ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] radeonsi: fix order of r600_need_dma_space and r600_context_bo_reloc
From: Christian König Signed-off-by: Christian König --- src/gallium/drivers/radeonsi/si_dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_dma.c b/src/gallium/drivers/radeonsi/si_dma.c index dc8c609..26f1e1b 100644 --- a/src/gallium/drivers/radeonsi/si_dma.c +++ b/src/gallium/drivers/radeonsi/si_dma.c @@ -91,12 +91,13 @@ static void si_dma_copy_buffer(struct si_context *ctx, } ncopy = (size / max_csize) + !!(size % max_csize); + r600_need_dma_space(&ctx->b, ncopy * 5); + r600_context_bo_reloc(&ctx->b, &ctx->b.rings.dma, rsrc, RADEON_USAGE_READ, RADEON_PRIO_MIN); r600_context_bo_reloc(&ctx->b, &ctx->b.rings.dma, rdst, RADEON_USAGE_WRITE, RADEON_PRIO_MIN); - r600_need_dma_space(&ctx->b, ncopy * 5); for (i = 0; i < ncopy; i++) { csize = size < max_csize ? size : max_csize; cs->buf[cs->cdw++] = SI_DMA_PACKET(SI_DMA_PACKET_COPY, sub_cmd, csize); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 09/15] freedreno: implement pipe_screen::get_driver_query_group_info v3
This enables GL_AMD_performance_monitor for freedreno. V2: - s/pipe_context/pipe_screen in the commit msg V3: - use util_get_driver_query_group_info Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/freedreno/freedreno_query.c | 9 + 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_query.c b/src/gallium/drivers/freedreno/freedreno_query.c index db2683c..2175bf1 100644 --- a/src/gallium/drivers/freedreno/freedreno_query.c +++ b/src/gallium/drivers/freedreno/freedreno_query.c @@ -28,6 +28,7 @@ #include "pipe/p_state.h" #include "util/u_memory.h" +#include "util/u_query.h" #include "freedreno_query.h" #include "freedreno_query_sw.h" @@ -104,10 +105,18 @@ fd_get_driver_query_info(struct pipe_screen *pscreen, return 1; } +static int +fd_get_driver_query_group_info(struct pipe_screen *pscreen, + unsigned index, struct pipe_driver_query_group_info *info) +{ + return util_get_driver_query_group_info(index, 6, info); +} + void fd_query_screen_init(struct pipe_screen *pscreen) { pscreen->get_driver_query_info = fd_get_driver_query_info; + pscreen->get_driver_query_group_info = fd_get_driver_query_group_info; } void -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 15/15] nvc0: init all default values of pipe_driver_query_info
Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index fcca1cb..6f9a1e6 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -1409,6 +1409,14 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (!info) return count; + /* Init default values. */ + info->name = "this_is_not_the_query_you_are_looking_for"; + info->query_type = 0xdeadd01d; + info->group_id = 0; + info->max_value.u64 = 0; + info->uses_byte_units = FALSE; + info->type = PIPE_DRIVER_QUERY_TYPE_UINT64; + #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS if (id < NVC0_QUERY_DRV_STAT_COUNT) { info->name = nvc0_drv_stat_names[id]; @@ -1426,7 +1434,6 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, info->group_id = NVC0_QUERY_PM_GROUP; info->max_value.u64 = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? ~0ULL : 100; - info->uses_byte_units = FALSE; return 1; } else if (screen->compute) { @@ -1434,16 +1441,10 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, info->query_type = NVC0_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); info->group_id = NVC0_QUERY_PM_GROUP; info->max_value.u64 = ~0ULL; - info->uses_byte_units = FALSE; return 1; } } /* user asked for info about non-existing query */ - info->name = "this_is_not_the_query_you_are_looking_for"; - info->query_type = 0xdeadd01d; - info->group_id = 0; - info->max_value.u64 = 0; - info->uses_byte_units = FALSE; return 0; } -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/15] gallium: add util_get_driver_query_group_info
This generic function will be used to get groups of queries. Signed-off-by: Samuel Pitoiset --- src/gallium/auxiliary/Makefile.sources | 1 + src/gallium/auxiliary/util/u_query.c | 46 ++ src/gallium/auxiliary/util/u_query.h | 44 3 files changed, 91 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_query.c create mode 100644 src/gallium/auxiliary/util/u_query.h diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index 8919783..1188c94 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -130,6 +130,7 @@ C_SOURCES := \ util/u_math.c \ util/u_mm.c \ util/u_pstipple.c \ + util/u_query.c \ util/u_ringbuffer.c \ util/u_sampler.c \ util/u_simple_shaders.c \ diff --git a/src/gallium/auxiliary/util/u_query.c b/src/gallium/auxiliary/util/u_query.c new file mode 100644 index 000..327cabc --- /dev/null +++ b/src/gallium/auxiliary/util/u_query.c @@ -0,0 +1,46 @@ +/** + * + * Copyright 2014 Samuel Pitoiset + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **/ + +#include "util/u_memory.h" +#include "util/u_query.h" + +int util_get_driver_query_group_info(unsigned index, unsigned num_queries, + struct pipe_driver_query_group_info *info) +{ + struct pipe_driver_query_group_info list[] = { + {"Driver queries", num_queries, num_queries} + }; + + if (!info) + return Elements(list); + + if (index >= Elements(list)) + return 0; + + *info = list[index]; + return 1; +} diff --git a/src/gallium/auxiliary/util/u_query.h b/src/gallium/auxiliary/util/u_query.h new file mode 100644 index 000..84f57d1 --- /dev/null +++ b/src/gallium/auxiliary/util/u_query.h @@ -0,0 +1,44 @@ +/** + * + * Copyright 2014 Samuel Pitoiset + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **/ + +#ifndef U_QUERY_H +#define U_QUERY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "pipe/p_state.h" + +int util_get_driver_query_group_info(unsigned index, unsigned num_queries, + struct pipe_driver_query_group_info *info); + +#ifdef __cplusplus +} +#endif + +#endif -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/15] docs: mark GL_AMD_performance_monitor for the 10.3 release
GL_AMD_performance_monitor is supported by nvc0, svga, freedreno and radeon. Signed-off-by: Samuel Pitoiset --- docs/relnotes/10.3.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/relnotes/10.3.html b/docs/relnotes/10.3.html index 2e718fc..e73e078 100644 --- a/docs/relnotes/10.3.html +++ b/docs/relnotes/10.3.html @@ -56,6 +56,7 @@ Note: some of the new features are only available with certain drivers. GL_ARB_seamless_cubemap_per_texture on i965, llvmpipe, nvc0, r600, radeonsi, softpipe GL_ARB_fragment_layer_viewport on nv50, nvc0, llvmpipe, r600 GL_AMD_vertex_shader_viewport_index on i965/gen7+, r600 +GL_AMD_performance_monitor on nvc0, r600, svga, freedreno -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/15] svga: implement pipe_screen::get_driver_query_group_info v3
This enables GL_AMD_performance_monitor for svga. V2: - s/pipe_context/pipe_screen in the commit msg V3: - use util_get_driver_query_group_info Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/svga/svga_screen.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index f34664d..29257ab 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -28,6 +28,7 @@ #include "util/u_inlines.h" #include "util/u_string.h" #include "util/u_math.h" +#include "util/u_query.h" #include "svga_winsys.h" #include "svga_public.h" @@ -555,6 +556,15 @@ svga_get_driver_query_info(struct pipe_screen *screen, } +static int +svga_get_driver_query_group_info(struct pipe_screen *screen, + unsigned index, + struct pipe_driver_query_group_info *info) +{ + return util_get_driver_query_group_info(index, 3, info); +} + + static void svga_destroy_screen( struct pipe_screen *screen ) { @@ -615,6 +625,7 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->fence_signalled = svga_fence_signalled; screen->fence_finish = svga_fence_finish; screen->get_driver_query_info = svga_get_driver_query_info; + screen->get_driver_query_group_info = svga_get_driver_query_group_info; svgascreen->sws = sws; svga_init_screen_resource_functions(svgascreen); -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/15] nvc0: implement pipe_screen::get_driver_query_group_info v2
This enables GL_AMD_performance_monitor for nvc0. V2: - use util_get_driver_query_group_info Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 10 ++ src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 1 + src/gallium/drivers/nouveau/nvc0/nvc0_screen.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index 7bf592c..16e2a9d 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -24,6 +24,8 @@ #define NVC0_PUSH_EXPLICIT_SPACE_CHECKING +#include "util/u_query.h" + #include "nvc0/nvc0_context.h" #include "nv_object.xml.h" #include "nvc0/nve4_compute.xml.h" @@ -1440,6 +1442,14 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, return 0; } +int +nvc0_screen_get_driver_query_group_info(struct pipe_screen *pscreen, +unsigned id, +struct pipe_driver_query_group_info *info) +{ + return util_get_driver_query_group_info(id, 29, info); +} + void nvc0_init_query_functions(struct nvc0_context *nvc0) { diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index dc9b143..63924b4 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -620,6 +620,7 @@ nvc0_screen_create(struct nouveau_device *dev) pscreen->get_shader_param = nvc0_screen_get_shader_param; pscreen->get_paramf = nvc0_screen_get_paramf; pscreen->get_driver_query_info = nvc0_screen_get_driver_query_info; + pscreen->get_driver_query_group_info = nvc0_screen_get_driver_query_group_info; nvc0_screen_init_resource_functions(pscreen); diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h index 4802057..be9b1c8 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h @@ -245,6 +245,9 @@ nvc0_screen(struct pipe_screen *screen) int nvc0_screen_get_driver_query_info(struct pipe_screen *, unsigned, struct pipe_driver_query_info *); +int nvc0_screen_get_driver_query_group_info(struct pipe_screen *, unsigned, +struct pipe_driver_query_group_info *); + boolean nvc0_blitter_create(struct nvc0_screen *); void nvc0_blitter_destroy(struct nvc0_screen *); -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/15] radeon: implement pipe_screen::get_driver_query_group_info v3
This enables GL_AMD_performance_monitor for radeon. V2: - s/pipe_context/pipe_screen in the commit msg V3: - use util_get_driver_query_group_info Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/radeon/r600_pipe_common.c | 9 + 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index bcddde1..8345acc 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -30,6 +30,7 @@ #include "util/u_memory.h" #include "util/u_format_s3tc.h" #include "util/u_upload_mgr.h" +#include "util/u_query.h" #include "vl/vl_decoder.h" #include "vl/vl_video_buffer.h" #include "radeon/radeon_video.h" @@ -566,6 +567,13 @@ static int r600_get_driver_query_info(struct pipe_screen *screen, return 1; } +static int r600_get_driver_query_group_info(struct pipe_screen *screen, + unsigned index, + struct pipe_driver_query_group_info *info) +{ + return util_get_driver_query_group_info(index, 8, info); +} + static void r600_fence_reference(struct pipe_screen *screen, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence) @@ -724,6 +732,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen, rscreen->b.get_compute_param = r600_get_compute_param; rscreen->b.get_paramf = r600_get_paramf; rscreen->b.get_driver_query_info = r600_get_driver_query_info; + rscreen->b.get_driver_query_group_info = r600_get_driver_query_group_info; rscreen->b.get_timestamp = r600_get_timestamp; rscreen->b.fence_finish = r600_fence_finish; rscreen->b.fence_reference = r600_fence_reference; -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/15] gallium: replace pipe_driver_query_info::max_value by a union v2
This will be used to return different numeric types for driver queries. V2: - use float instead of double - reorder pipe_numeric_type_union to avoid bad initializers - rename ui to u64 and i to u32 according to gl_perf_monitor_counter_value - use uint32_t instead of int64_t according to gl_perf_monitor_counter_value Signed-off-by: Samuel Pitoiset --- src/gallium/auxiliary/hud/hud_driver_query.c| 2 +- src/gallium/drivers/freedreno/freedreno_query.c | 12 ++-- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 8 src/gallium/drivers/radeon/r600_pipe_common.c | 16 src/gallium/drivers/svga/svga_screen.c | 6 +++--- src/gallium/include/pipe/p_defines.h| 9 - 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c index b48708c..8448cb7 100644 --- a/src/gallium/auxiliary/hud/hud_driver_query.c +++ b/src/gallium/auxiliary/hud/hud_driver_query.c @@ -205,6 +205,6 @@ hud_driver_query_install(struct hud_pane *pane, struct pipe_context *pipe, return FALSE; hud_pipe_query_install(pane, pipe, query.name, query.query_type, 0, - query.max_value, query.uses_byte_units); + query.max_value.u64, query.uses_byte_units); return TRUE; } diff --git a/src/gallium/drivers/freedreno/freedreno_query.c b/src/gallium/drivers/freedreno/freedreno_query.c index cb3b49a..6f01e03 100644 --- a/src/gallium/drivers/freedreno/freedreno_query.c +++ b/src/gallium/drivers/freedreno/freedreno_query.c @@ -86,12 +86,12 @@ fd_get_driver_query_info(struct pipe_screen *pscreen, unsigned index, struct pipe_driver_query_info *info) { struct pipe_driver_query_info list[] = { - {"draw-calls", FD_QUERY_DRAW_CALLS, 0}, - {"batches", FD_QUERY_BATCH_TOTAL, 0}, - {"batches-sysmem", FD_QUERY_BATCH_SYSMEM, 0}, - {"batches-gmem", FD_QUERY_BATCH_GMEM, 0}, - {"restores", FD_QUERY_BATCH_RESTORE, 0}, - {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, 0}, + {"draw-calls", FD_QUERY_DRAW_CALLS, {0}}, + {"batches", FD_QUERY_BATCH_TOTAL, {0}}, + {"batches-sysmem", FD_QUERY_BATCH_SYSMEM, {0}}, + {"batches-gmem", FD_QUERY_BATCH_GMEM, {0}}, + {"restores", FD_QUERY_BATCH_RESTORE, {0}}, + {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, {0}}, }; if (!info) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index 50cef1e..c76cd43 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -1409,7 +1409,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (id < NVC0_QUERY_DRV_STAT_COUNT) { info->name = nvc0_drv_stat_names[id]; info->query_type = NVC0_QUERY_DRV_STAT(id); - info->max_value = ~0ULL; + info->max_value.u64 = ~0ULL; info->uses_byte_units = !!strstr(info->name, "bytes"); return 1; } else @@ -1418,7 +1418,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (screen->base.class_3d >= NVE4_3D_CLASS) { info->name = nve4_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; info->query_type = NVE4_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); - info->max_value = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? + info->max_value.u64 = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? ~0ULL : 100; info->uses_byte_units = FALSE; return 1; @@ -1426,7 +1426,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (screen->compute) { info->name = nvc0_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; info->query_type = NVC0_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); - info->max_value = ~0ULL; + info->max_value.u64 = ~0ULL; info->uses_byte_units = FALSE; return 1; } @@ -1434,7 +1434,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, /* user asked for info about non-existing query */ info->name = "this_is_not_the_query_you_are_looking_for"; info->query_type = 0xdeadd01d; - info->max_value = 0; + info->max_value.u64 = 0; info->uses_byte_units = FALSE; return 0; } diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index 46e8a79..bcddde1 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -546,14 +546,14 @@ static int r600_get_driver_query_info(struct pipe_screen *screen, { struct r600_common_screen *rscreen = (struct r600_common_screen*)scre
[Mesa-dev] [PATCH 06/15] mesa/st: implement GL_AMD_performance_monitor v4
From: Christoph Bumiller This is based on the original patch of Christoph Bumiller. (source: http://people.freedesktop.org/~chrisbmr/perfmon.diff) Drivers must implement get_driver_query_group_info and get_driver_query_info in order to enable this extension. V2: (Samuel Pitoiset) - fix compilation - improve the original code - rewrite some parts of the original code V3: - do not use pipe_driver_query_info::min_value which is always set to 0 V4: - only enable AMD_performance_monitor if the driver implements pipe_screen::get_driver_query_group_info and get_driver_query_info - make use of PIPE_DRIVER_QUERY_TYPE_* - use of GL_UNSIGNED_INT in st_GetPerfMonitorResult() Signed-off-by: Samuel Pitoiset --- src/mesa/Makefile.sources | 1 + src/mesa/state_tracker/st_cb_perfmon.c | 375 + src/mesa/state_tracker/st_cb_perfmon.h | 63 ++ src/mesa/state_tracker/st_context.c| 3 + src/mesa/state_tracker/st_extensions.c | 3 + 5 files changed, 445 insertions(+) create mode 100644 src/mesa/state_tracker/st_cb_perfmon.c create mode 100644 src/mesa/state_tracker/st_cb_perfmon.h diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index f4904fb..0b020e2 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -234,6 +234,7 @@ STATETRACKER_FILES = \ $(SRCDIR)state_tracker/st_cb_fbo.c \ $(SRCDIR)state_tracker/st_cb_feedback.c \ $(SRCDIR)state_tracker/st_cb_msaa.c \ + $(SRCDIR)state_tracker/st_cb_perfmon.c \ $(SRCDIR)state_tracker/st_cb_program.c \ $(SRCDIR)state_tracker/st_cb_queryobj.c \ $(SRCDIR)state_tracker/st_cb_rasterpos.c \ diff --git a/src/mesa/state_tracker/st_cb_perfmon.c b/src/mesa/state_tracker/st_cb_perfmon.c new file mode 100644 index 000..1883dc2 --- /dev/null +++ b/src/mesa/state_tracker/st_cb_perfmon.c @@ -0,0 +1,375 @@ +/* + * Copyright 2014 Nouveau Project + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: Christoph Bumiller + * Samuel Pitoiset + */ + +/** + * Performance monitoring counters interface to gallium. + */ + +#include "st_context.h" +#include "st_cb_perfmon.h" +#include "st_cb_bitmap.h" + +#include "main/bitset.h" + +/* Avoid multiple definitions */ +#undef MALLOC_STRUCT +#undef CALLOC_STRUCT + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" +#include "util/u_math.h" +#include "util/u_memory.h" + +static int +find_query_type(struct pipe_screen *screen, const char *name) +{ + int num_counters; + int type = -1; + int i; + + num_counters = screen->get_driver_query_info(screen, 0, NULL); + if (!num_counters) + return type; + + for (i = 0; i < num_counters; i++) { + struct pipe_driver_query_info info; + + if (!screen->get_driver_query_info(screen, i, &info)) + continue; + + if (!strncmp(info.name, name, strlen(name))) { + type = info.query_type; + break; + } + } + return type; +} + +static void +reinitialize_perf_monitor(struct st_perf_monitor_object *stm, + struct pipe_context *pipe) +{ + int i; + + for (i = 0; i < stm->num_queries; i++) { + if (stm->queries[i].pq) { + pipe->destroy_query(pipe, stm->queries[i].pq); + stm->queries[i].pq = NULL; + } + } + stm->num_queries = 0; + stm->ready = FALSE; +} + +static struct gl_perf_monitor_object * +st_NewPerfMonitor() +{ + struct st_perf_monitor_object *stq = ST_CALLOC_STRUCT(st_perf_monitor_object); + if (stq) + return &stq->base; + return NULL; +} + +static void +st_DeletePerfMonitor(struct gl_context *ctx, struct gl_perf_monitor_object *m) +{ + struct st_perf_monitor_object *stm = st_perf_monitor_object(m); + struct pipe_context *pipe = st_context(ctx)->pipe; + + reinitialize_perf_monitor(stm, pipe); + FREE(stm); +} + +static GLboolean +st_BeginPerfMonitor(stru
[Mesa-dev] [PATCH 13/15] nvc0: expose driver queries with two groups
This adds a new group for MP performance counters and requires to write our own implementation of get_driver_query_group_info. Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 52 -- src/gallium/drivers/nouveau/nvc0/nvc0_screen.h | 5 +++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index 16e2a9d..cd11774 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -24,8 +24,6 @@ #define NVC0_PUSH_EXPLICIT_SPACE_CHECKING -#include "util/u_query.h" - #include "nvc0/nvc0_context.h" #include "nv_object.xml.h" #include "nvc0/nve4_compute.xml.h" @@ -1412,6 +1410,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (id < NVC0_QUERY_DRV_STAT_COUNT) { info->name = nvc0_drv_stat_names[id]; info->query_type = NVC0_QUERY_DRV_STAT(id); + info->group_id = NVC0_QUERY_DRV_STAT_GROUP; info->max_value.u64 = ~0ULL; info->uses_byte_units = !!strstr(info->name, "bytes"); return 1; @@ -1421,6 +1420,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (screen->base.class_3d >= NVE4_3D_CLASS) { info->name = nve4_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; info->query_type = NVE4_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); + info->group_id = NVC0_QUERY_PM_GROUP; info->max_value.u64 = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? ~0ULL : 100; info->uses_byte_units = FALSE; @@ -1429,6 +1429,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (screen->compute) { info->name = nvc0_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; info->query_type = NVC0_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); + info->group_id = NVC0_QUERY_PM_GROUP; info->max_value.u64 = ~0ULL; info->uses_byte_units = FALSE; return 1; @@ -1437,6 +1438,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, /* user asked for info about non-existing query */ info->name = "this_is_not_the_query_you_are_looking_for"; info->query_type = 0xdeadd01d; + info->group_id = 0; info->max_value.u64 = 0; info->uses_byte_units = FALSE; return 0; @@ -1447,7 +1449,51 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned id, struct pipe_driver_query_group_info *info) { - return util_get_driver_query_group_info(id, 29, info); + struct nvc0_screen *screen = nvc0_screen(pscreen); + int count = 0; + +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + count++; +#endif + if (screen->base.device->drm_version >= 0x01000101) { + if (screen->base.class_3d >= NVE4_3D_CLASS) { + count++; + } else + if (screen->compute) { + count++; /* NVC0_COMPUTE is not always enabled */ + } + } + + if (!info) + return count; + +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + if (id == NVC0_QUERY_DRV_STAT_GROUP) { + info->name = "Driver statistics"; + info->max_active_queries = 8; + info->num_queries = NVC0_QUERY_DRV_STAT_COUNT; + return 1; + } else +#endif + if (id == NVC0_QUERY_PM_GROUP) { + info->name = "Performance counters"; + info->max_active_queries = 8; /* 8 MP counters for NVC0+ */ + + if (screen->base.class_3d >= NVE4_3D_CLASS) { + info->num_queries = NVE4_PM_QUERY_COUNT; + return 1; + } else + if (screen->compute) { + info->num_queries = NVC0_PM_QUERY_COUNT; + return 1; + } + } + + /* user asked for info about non-existing query group */ + info->name = "this_is_not_the_query_group_you_are_looking_for"; + info->max_active_queries = 0; + info->num_queries = 0; + return 0; } void diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h index be9b1c8..405187c 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h @@ -88,6 +88,11 @@ nvc0_screen(struct pipe_screen *screen) return (struct nvc0_screen *)screen; } +/* + * Performance counter groups: + */ +#define NVC0_QUERY_DRV_STAT_GROUP 0 +#define NVC0_QUERY_PM_GROUP 1 /* Performance counter queries: */ -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 14/15] nvc0: make begin_query return false when all MP counters are used v2
V2: - do not return immediately after nvc0_mp_pm_query_end() in order to set the current state of the given query Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index cd11774..fcca1cb 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -56,7 +56,8 @@ struct nvc0_query { #define NVC0_QUERY_ALLOC_SPACE 256 -static void nvc0_mp_pm_query_begin(struct nvc0_context *, struct nvc0_query *); +static boolean nvc0_mp_pm_query_begin(struct nvc0_context *, + struct nvc0_query *); static void nvc0_mp_pm_query_end(struct nvc0_context *, struct nvc0_query *); static boolean nvc0_mp_pm_query_result(struct nvc0_context *, struct nvc0_query *, void *, boolean); @@ -256,6 +257,7 @@ nvc0_query_begin(struct pipe_context *pipe, struct pipe_query *pq) struct nvc0_context *nvc0 = nvc0_context(pipe); struct nouveau_pushbuf *push = nvc0->base.pushbuf; struct nvc0_query *q = nvc0_query(pq); + boolean ret = true; /* For occlusion queries we have to change the storage, because a previous * query might set the initial render conition to FALSE even *after* we re- @@ -327,12 +329,12 @@ nvc0_query_begin(struct pipe_context *pipe, struct pipe_query *pq) #endif if ((q->type >= NVE4_PM_QUERY(0) && q->type <= NVE4_PM_QUERY_LAST) || (q->type >= NVC0_PM_QUERY(0) && q->type <= NVC0_PM_QUERY_LAST)) { - nvc0_mp_pm_query_begin(nvc0, q); + ret = nvc0_mp_pm_query_begin(nvc0, q); } break; } q->state = NVC0_QUERY_STATE_ACTIVE; - return true; + return ret; } static void @@ -1063,7 +1065,7 @@ nvc0_mp_pm_query_get_cfg(struct nvc0_context *nvc0, struct nvc0_query *q) return &nvc0_mp_pm_queries[q->type - NVC0_PM_QUERY(0)]; } -void +boolean nvc0_mp_pm_query_begin(struct nvc0_context *nvc0, struct nvc0_query *q) { struct nvc0_screen *screen = nvc0->screen; @@ -1082,7 +1084,7 @@ nvc0_mp_pm_query_begin(struct nvc0_context *nvc0, struct nvc0_query *q) if (screen->pm.num_mp_pm_active[0] + num_ab[0] > 4 || screen->pm.num_mp_pm_active[1] + num_ab[1] > 4) { NOUVEAU_ERR("Not enough free MP counter slots !\n"); - return; + return false; } assert(cfg->num_counters <= 4); @@ -1147,6 +1149,7 @@ nvc0_mp_pm_query_begin(struct nvc0_context *nvc0, struct nvc0_query *q) } } } + return true; } static void -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/15] gallium: make pipe_context::begin_query return a boolean
This can be used to check if a query is unable to start. Signed-off-by: Samuel Pitoiset --- src/gallium/drivers/freedreno/freedreno_query.c| 4 ++-- src/gallium/drivers/freedreno/freedreno_query.h| 2 +- src/gallium/drivers/freedreno/freedreno_query_hw.c | 3 ++- src/gallium/drivers/freedreno/freedreno_query_sw.c | 3 ++- src/gallium/drivers/galahad/glhd_context.c | 6 +++--- src/gallium/drivers/i915/i915_query.c | 3 ++- src/gallium/drivers/identity/id_context.c | 6 +++--- src/gallium/drivers/ilo/ilo_query.c| 3 ++- src/gallium/drivers/llvmpipe/lp_query.c| 3 ++- src/gallium/drivers/noop/noop_pipe.c | 3 ++- src/gallium/drivers/nouveau/nv30/nv30_query.c | 5 +++-- src/gallium/drivers/nouveau/nv50/nv50_query.c | 3 ++- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 3 ++- src/gallium/drivers/r300/r300_query.c | 9 + src/gallium/drivers/radeon/r600_query.c| 16 +--- src/gallium/drivers/rbug/rbug_context.c| 8 +--- src/gallium/drivers/softpipe/sp_query.c| 3 ++- src/gallium/drivers/svga/svga_pipe_query.c | 3 ++- src/gallium/drivers/trace/tr_context.c | 6 -- src/gallium/include/pipe/p_context.h | 2 +- 20 files changed, 56 insertions(+), 38 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_query.c b/src/gallium/drivers/freedreno/freedreno_query.c index 6f01e03..db2683c 100644 --- a/src/gallium/drivers/freedreno/freedreno_query.c +++ b/src/gallium/drivers/freedreno/freedreno_query.c @@ -59,11 +59,11 @@ fd_destroy_query(struct pipe_context *pctx, struct pipe_query *pq) q->funcs->destroy_query(fd_context(pctx), q); } -static void +static boolean fd_begin_query(struct pipe_context *pctx, struct pipe_query *pq) { struct fd_query *q = fd_query(pq); - q->funcs->begin_query(fd_context(pctx), q); + return q->funcs->begin_query(fd_context(pctx), q); } static void diff --git a/src/gallium/drivers/freedreno/freedreno_query.h b/src/gallium/drivers/freedreno/freedreno_query.h index bc9a7a2..c2c71da 100644 --- a/src/gallium/drivers/freedreno/freedreno_query.h +++ b/src/gallium/drivers/freedreno/freedreno_query.h @@ -37,7 +37,7 @@ struct fd_query; struct fd_query_funcs { void (*destroy_query)(struct fd_context *ctx, struct fd_query *q); - void (*begin_query)(struct fd_context *ctx, struct fd_query *q); + boolean (*begin_query)(struct fd_context *ctx, struct fd_query *q); void (*end_query)(struct fd_context *ctx, struct fd_query *q); boolean (*get_query_result)(struct fd_context *ctx, struct fd_query *q, boolean wait, diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index 38bd3de..d0df719 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -136,7 +136,7 @@ fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q) { struct fd_hw_query *hq = fd_hw_query(q); if (q->active) - return; + return true; /* begin_query() should clear previous results: */ destroy_periods(ctx, &hq->periods); @@ -149,6 +149,7 @@ fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q) /* add to active list: */ list_del(&hq->list); list_addtail(&hq->list, &ctx->active_queries); + return true; } static void diff --git a/src/gallium/drivers/freedreno/freedreno_query_sw.c b/src/gallium/drivers/freedreno/freedreno_query_sw.c index 8d81698..514df14 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_sw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_sw.c @@ -85,7 +85,7 @@ is_rate_query(struct fd_query *q) } } -static void +static boolean fd_sw_begin_query(struct fd_context *ctx, struct fd_query *q) { struct fd_sw_query *sq = fd_sw_query(q); @@ -93,6 +93,7 @@ fd_sw_begin_query(struct fd_context *ctx, struct fd_query *q) sq->begin_value = read_counter(ctx, q->type); if (is_rate_query(q)) sq->begin_time = os_time_get(); + return true; } static void diff --git a/src/gallium/drivers/galahad/glhd_context.c b/src/gallium/drivers/galahad/glhd_context.c index 79d5495..d02f13a 100644 --- a/src/gallium/drivers/galahad/glhd_context.c +++ b/src/gallium/drivers/galahad/glhd_context.c @@ -95,15 +95,15 @@ galahad_context_destroy_query(struct pipe_context *_pipe, query); } -static void +static boolean galahad_context_begin_query(struct pipe_context *_pipe, struct pipe_query *query) { struct galahad_context *glhd_pipe = galahad_context(_pipe); struct pipe_context *pipe = glhd_pipe->pipe; - pipe->begin_query(pipe, - qu
[Mesa-dev] [PATCH 02/15] gallium: add new fields to pipe_driver_query_info v2
According to the spec of GL_AMD_performance_monitor, valid type values returned are UNSIGNED_INT, UNSIGNED_INT64_AMD, PERCENTAGE_AMD, FLOAT. This also introduces the new field group_id in order to categorize queries into groups. V2: - add pipe_driver_query_type enum Signed-off-by: Samuel Pitoiset --- src/gallium/include/pipe/p_defines.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 8f20974..f0a1dda 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -727,12 +727,22 @@ union pipe_color_union unsigned int ui[4]; }; +enum pipe_driver_query_type +{ + PIPE_DRIVER_QUERY_TYPE_UINT64 = 0, + PIPE_DRIVER_QUERY_TYPE_UINT = 1, + PIPE_DRIVER_QUERY_TYPE_FLOAT = 2, + PIPE_DRIVER_QUERY_TYPE_PERCENTAGE = 3, +}; + struct pipe_driver_query_info { const char *name; unsigned query_type; /* PIPE_QUERY_DRIVER_SPECIFIC + i */ uint64_t max_value; /* max value that can be returned */ boolean uses_byte_units; /* whether the result is in bytes */ + enum pipe_driver_query_type type; + unsigned group_id; }; struct pipe_driver_query_group_info -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/15] gallium: add pipe_screen::get_driver_query_group_info v2
Driver queries are organized as a single hierarchy where queries are categorized into groups. Each goup has a list of queries and a maximum number of queries that can be sampled. This will be used by GL_AMD_performance monitor. V2: - add doc to src/gallium/docs/source/screen.rst - s/pipe_context/pipe_screen in the commit msg - rewrite commit message Signed-off-by: Samuel Pitoiset --- src/gallium/docs/source/screen.rst | 10 ++ src/gallium/include/pipe/p_defines.h | 7 +++ src/gallium/include/pipe/p_screen.h | 11 +++ 3 files changed, 28 insertions(+) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index ba583fe..9d94890 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -532,3 +532,13 @@ query at the specified **index** is returned in **info**. The function returns non-zero on success. The driver-specific query is described with the pipe_driver_query_info structure. + +get_driver_query_group_info +^^^ + +Return a driver-specific query group. If the **info** parameter is NULL, +the number of available groups is returned. Otherwise, the driver +query group at the specified **index** is returned in **info**. +The function returns non-zero on success. +The driver-specific query group is described with the +pipe_driver_query_group_info structure. diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index d9b6e5a..8f20974 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -735,6 +735,13 @@ struct pipe_driver_query_info boolean uses_byte_units; /* whether the result is in bytes */ }; +struct pipe_driver_query_group_info +{ + const char *name; + unsigned max_active_queries; + unsigned num_queries; +}; + #ifdef __cplusplus } #endif diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index cf958d2..8fc110e 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -220,6 +220,17 @@ struct pipe_screen { unsigned index, struct pipe_driver_query_info *info); + /** +* Returns a driver-specific query group. +* +* If \p info is NULL, the number of available groups is returned. +* Otherwise, the driver query group at the specified \p index is returned +* in \p info. The function returns non-zero on success. +*/ + int (*get_driver_query_group_info)(struct pipe_screen *screen, + unsigned index, + struct pipe_driver_query_group_info *info); + }; -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/15] gallium: add new numeric types to pipe_query_result v2
This will be used by GL_AMD_performance_monitor. V2: - add 'uint32_t u32' - rename 'float f32' to 'float f' - add some comments Signed-off-by: Samuel Pitoiset --- src/gallium/include/pipe/p_defines.h | 8 1 file changed, 8 insertions(+) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index f0a1dda..4a4408d 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -708,8 +708,16 @@ union pipe_query_result /* PIPE_QUERY_TIME_ELAPSED */ /* PIPE_QUERY_PRIMITIVES_GENERATED */ /* PIPE_QUERY_PRIMITIVES_EMITTED */ + /* PIPE_DRIVER_QUERY_TYPE_UINT64 */ uint64_t u64; + /* PIPE_DRIVER_QUERY_TYPE_UINT */ + uint32_t u32; + + /* PIPE_DRIVER_QUERY_TYPE_FLOAT */ + /* PIPE_DRIVER_QUERY_TYPE_PERCENTAGE */ + float f; + /* PIPE_QUERY_SO_STATISTICS */ struct pipe_query_data_so_statistics so_statistics; -- 2.0.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] GL_AMD_performance_monitor v3
Hello, This is the third version of GL_AMD_performance_monitor. V2 (global changes): - Fix radeon as pinpointed by Marek - Implement pipe_driver_query_group_info for svga, radeon and freedreno V3 (global changes): - Re-organize the series according to hints of Ilia Mirkin - Document pipe_driver_query_group_info - Re-order pipe_numeric_type_union to avoid bad initializers - Add pipe_driver_query_type enum - Only enable AMD_performance_monitor if the driver implements pipe_driver_query_info and pipe_driver_query_group_info GL_AMD_performance_monitor is now available for nvc0, svga, freedreno and radeon. Thanks in advance for your feedbacks. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 10/16] gallium: add is_percentage and is_float fields to pipe_driver_query_info
On 07/08/2014 06:27 PM, Marek Olšák wrote: It would be nicer to define all the types as enums, e.g. enum pipe_driver_query_type { PIPE_DRIVER_QUERY_TYPE_BYTES, PIPE_DRIVER_QUERY_TYPE_PERCENTAGE, PIPE_DRIVER_QUERY_TYPE_FLOAT, PIPE_DRIVER_QUERY_TYPE_UINT }; That would be nicer than a bunch of booleans. If that's not possible, please document how the booleans interact with each other. I'll take a look at this. Thanks. Marek On Mon, Jul 7, 2014 at 5:47 PM, Samuel Pitoiset wrote: This will be used by GL_AMD_performance_monitor. Signed-off-by: Samuel Pitoiset --- src/gallium/include/pipe/p_defines.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 501c1e2..db5c9bf 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -740,6 +740,8 @@ struct pipe_driver_query_info unsigned query_type; /* PIPE_QUERY_DRIVER_SPECIFIC + i */ union pipe_numeric_type_union max_value; /* max value that can be returned */ boolean uses_byte_units; /* whether the result is in bytes */ + boolean is_percentage; + boolean is_float; unsigned group_id; }; -- 2.0.0 ___ 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
[Mesa-dev] [PATCHv2 05/13] glsl: protect glsl_type with a mutex
glsl_type has several static hash tables and a static ralloc context. They need to be protected by a mutex as they are not thread-safe. Signed-off-by: Chia-I Wu --- src/glsl/glsl_types.cpp | 57 +++-- src/glsl/glsl_types.h | 15 + 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index f9cd258..a9261e4 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -29,6 +29,7 @@ extern "C" { #include "program/hash_table.h" } +mtx_t glsl_type::mutex = _MTX_INITIALIZER_NP; hash_table *glsl_type::array_types = NULL; hash_table *glsl_type::record_types = NULL; hash_table *glsl_type::interface_types = NULL; @@ -53,9 +54,14 @@ glsl_type::glsl_type(GLenum gl_type, vector_elements(vector_elements), matrix_columns(matrix_columns), length(0) { + mtx_lock(&glsl_type::mutex); + init_ralloc_type_ctx(); assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); + + mtx_unlock(&glsl_type::mutex); + /* Neither dimension is zero or both dimensions are zero. */ assert((vector_elements == 0) == (matrix_columns == 0)); @@ -71,9 +77,14 @@ glsl_type::glsl_type(GLenum gl_type, glsl_base_type base_type, sampler_array(array), sampler_type(type), interface_packing(0), length(0) { + mtx_lock(&glsl_type::mutex); + init_ralloc_type_ctx(); assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); + + mtx_unlock(&glsl_type::mutex); + memset(& fields, 0, sizeof(fields)); if (base_type == GLSL_TYPE_SAMPLER) { @@ -95,11 +106,14 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, { unsigned int i; + mtx_lock(&glsl_type::mutex); + init_ralloc_type_ctx(); assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); this->fields.structure = ralloc_array(this->mem_ctx, glsl_struct_field, length); + for (i = 0; i < length; i++) { this->fields.structure[i].type = fields[i].type; this->fields.structure[i].name = ralloc_strdup(this->fields.structure, @@ -110,6 +124,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, this->fields.structure[i].sample = fields[i].sample; this->fields.structure[i].row_major = fields[i].row_major; } + + mtx_unlock(&glsl_type::mutex); } glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, @@ -123,6 +139,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, { unsigned int i; + mtx_lock(&glsl_type::mutex); + init_ralloc_type_ctx(); assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); @@ -138,6 +156,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, this->fields.structure[i].sample = fields[i].sample; this->fields.structure[i].row_major = fields[i].row_major; } + + mtx_unlock(&glsl_type::mutex); } @@ -285,6 +305,8 @@ const glsl_type *glsl_type::get_scalar_type() const void _mesa_glsl_release_types(void) { + mtx_lock(&glsl_type::mutex); + if (glsl_type::array_types != NULL) { hash_table_dtor(glsl_type::array_types); glsl_type::array_types = NULL; @@ -294,6 +316,8 @@ _mesa_glsl_release_types(void) hash_table_dtor(glsl_type::record_types); glsl_type::record_types = NULL; } + + mtx_unlock(&glsl_type::mutex); } @@ -316,7 +340,10 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) : * NUL. */ const unsigned name_length = strlen(array->name) + 10 + 3; + + mtx_lock(&glsl_type::mutex); char *const n = (char *) ralloc_size(this->mem_ctx, name_length); + mtx_unlock(&glsl_type::mutex); if (length == 0) snprintf(n, name_length, "%s[]", array->name); @@ -452,12 +479,6 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) const glsl_type * glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) { - - if (array_types == NULL) { - array_types = hash_table_ctor(64, hash_table_string_hash, - hash_table_string_compare); - } - /* Generate a name using the base type pointer in the key. This is * done because the name of the base type may not be unique across * shaders. For example, two shaders may have different record types @@ -466,9 +487,19 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) char key[128]; snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size); + mtx_lock(&glsl_type::mutex); + + if (array_types == NULL) { + array_types = hash_table_ctor(64, hash_table_string_hash, + hash_table_string_compare); + } + const glsl_type *t = (glsl_type *) hash_table_find(array_types, key); + if (t == NULL)
[Mesa-dev] [PATCHv2 09/13] i965: add drirc option multithread_glsl_compiler
Setting it to a non-zero value N will cause shader compilation to be deferred to a thread pool. When N is greater than 1, it indicates the maximum number of threads in the pool. When N is 1, the number of threads is up to the driver (two for i965). Signed-off-by: Chia-I Wu --- src/mesa/drivers/dri/common/xmlpool/t_options.h | 4 src/mesa/drivers/dri/i965/brw_context.c | 15 +++ src/mesa/drivers/dri/i965/intel_screen.c| 2 ++ 3 files changed, 21 insertions(+) diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h index fc9e104..80abaf9 100644 --- a/src/mesa/drivers/dri/common/xmlpool/t_options.h +++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h @@ -293,6 +293,10 @@ DRI_CONF_OPT_BEGIN_V(texture_heaps,enum,def,"0:2") \ DRI_CONF_DESC_END \ DRI_CONF_OPT_END +#define DRI_CONF_MULTITHREAD_GLSL_COMPILER(def) \ +DRI_CONF_OPT_BEGIN(multithread_glsl_compiler, int, def) \ +DRI_CONF_DESC(en,gettext("Enable multithreading in the GLSL compiler")) \ +DRI_CONF_OPT_END /** diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index c47ad36..bd13ebf 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -570,6 +570,17 @@ brw_process_driconf_options(struct brw_context *brw) ctx->Const.DisableGLSLLineContinuations = driQueryOptionb(options, "disable_glsl_line_continuations"); + + const int multithread_glsl_compiler = + driQueryOptioni(options, "multithread_glsl_compiler"); + if (multithread_glsl_compiler > 0) { + const int max_threads = (multithread_glsl_compiler > 1) ? + multithread_glsl_compiler : 2; + + _mesa_enable_glsl_threadpool(ctx, max_threads); + ctx->Const.DeferCompileShader = GL_TRUE; + ctx->Const.DeferLinkProgram = GL_TRUE; + } } GLboolean @@ -773,6 +784,10 @@ brwCreateContext(gl_api api, if (INTEL_DEBUG & DEBUG_SHADER_TIME) brw_init_shader_time(brw); + /* brw_shader_precompile is not thread-safe */ + if (brw->precompile) + ctx->Const.DeferLinkProgram = GL_FALSE; + _mesa_compute_version(ctx); _mesa_initialize_dispatch_tables(ctx); diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 5b0cbf3..b91d1b1 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -48,6 +48,8 @@ static const __DRIconfigOptionsExtension brw_config_options = { DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC) + DRI_CONF_MULTITHREAD_GLSL_COMPILER(0) + /* Options correspond to DRI_CONF_BO_REUSE_DISABLED, * DRI_CONF_BO_REUSE_ALL */ -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCHv2 12/13] i965: refactor do_wm_prog
Split do_wm_prog into brw_wm_init_compile brw_wm_do_compile brw_wm_upload_compile brw_wm_clear_complile Add struct brw_wm_compile to be passed around them. Signed-off-by: Chia-I Wu --- src/mesa/drivers/dri/i965/brw_wm.c | 119 - src/mesa/drivers/dri/i965/brw_wm.h | 30 ++ 2 files changed, 107 insertions(+), 42 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index d716e6f..6849963 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -135,27 +135,30 @@ brw_wm_prog_data_compare(const void *in_a, const void *in_b) return true; } -/** - * All Mesa program -> GPU code generation goes through this function. - * Depending on the instructions used (i.e. flow control instructions) - * we'll use one of two code generators. - */ -bool do_wm_prog(struct brw_context *brw, - struct gl_shader_program *prog, - struct brw_fragment_program *fp, - struct brw_wm_prog_key *key) +void +brw_wm_init_compile(struct brw_context *brw, + struct gl_shader_program *prog, + struct brw_fragment_program *fp, + const struct brw_wm_prog_key *key, + struct brw_wm_compile *c) +{ + memset(c, 0, sizeof(*c)); + + c->shader_prog = prog; + c->fp = fp; + c->key = key; + c->mem_ctx = ralloc_context(NULL); +} + +bool +brw_wm_do_compile(struct brw_context *brw, + struct brw_wm_compile *c) { struct gl_context *ctx = &brw->ctx; - void *mem_ctx = ralloc_context(NULL); - struct brw_wm_prog_data prog_data; - const GLuint *program; struct gl_shader *fs = NULL; - GLuint program_size; - if (prog) - fs = prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; - - memset(&prog_data, 0, sizeof(prog_data)); + if (c->shader_prog) + fs = c->shader_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; /* Allocate the references to the uniforms that will end up in the * prog_data associated with the compiled program, and which will be freed @@ -165,42 +168,74 @@ bool do_wm_prog(struct brw_context *brw, if (fs) { param_count = fs->num_uniform_components; } else { - param_count = fp->program.Base.Parameters->NumParameters * 4; + param_count = c->fp->program.Base.Parameters->NumParameters * 4; } /* The backend also sometimes adds params for texture size. */ param_count += 2 * ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; - prog_data.base.param = rzalloc_array(NULL, const float *, param_count); - prog_data.base.pull_param = - rzalloc_array(NULL, const float *, param_count); - prog_data.base.nr_params = param_count; - - prog_data.barycentric_interp_modes = - brw_compute_barycentric_interp_modes(brw, key->flat_shade, - key->persample_shading, - &fp->program); - - program = brw_wm_fs_emit(brw, mem_ctx, key, &prog_data, -&fp->program, prog, &program_size); - if (program == NULL) { - ralloc_free(mem_ctx); + c->prog_data.base.param = rzalloc_array(NULL, const float *, param_count); + c->prog_data.base.pull_param = + rzalloc_array(NULL, const float *, param_count); + c->prog_data.base.nr_params = param_count; + + c->prog_data.barycentric_interp_modes = + brw_compute_barycentric_interp_modes(brw, c->key->flat_shade, + c->key->persample_shading, + &c->fp->program); + + c->program = brw_wm_fs_emit(brw, c->mem_ctx, c->key, &c->prog_data, + &c->fp->program, c->shader_prog, &c->program_size); + if (c->program == NULL) return false; - } - - if (prog_data.total_scratch) { - brw_get_scratch_bo(brw, &brw->wm.base.scratch_bo, -prog_data.total_scratch * brw->max_wm_threads); - } if (unlikely(INTEL_DEBUG & DEBUG_WM)) fprintf(stderr, "\n"); + return true; +} + +void +brw_wm_upload_compile(struct brw_context *brw, + const struct brw_wm_compile *c) +{ + if (c->prog_data.total_scratch) { + brw_get_scratch_bo(brw, &brw->wm.base.scratch_bo, +c->prog_data.total_scratch * brw->max_wm_threads); + } + brw_upload_cache(&brw->cache, BRW_WM_PROG, - key, sizeof(struct brw_wm_prog_key), - program, program_size, - &prog_data, sizeof(prog_data), + c->key, sizeof(struct brw_wm_prog_key), + c->program, c->program_size, + &c->prog_data, sizeof(c->prog_data), &brw->wm.base.prog_offset, &brw->wm.prog_data); +} + +void +brw_wm_clear_compile(struct brw_context *brw, + struct brw_wm_compile *c) +{ + ralloc_free(c->mem_ctx); +} + +/** + * A
[Mesa-dev] [PATCHv2 04/13] glsl: protect anonymous struct id with a mutex
There may be two contexts compiling shaders at the same time, and we want the anonymous struct id to be globally unique. Signed-off-by: Chia-I Wu --- src/glsl/glsl_parser_extras.cpp | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index b327c2b..ad31469 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -1347,9 +1347,15 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier, ast_declarator_list *declarator_list) { if (identifier == NULL) { + static mtx_t mutex = _MTX_INITIALIZER_NP; static unsigned anon_count = 1; - identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count); - anon_count++; + unsigned count; + + mtx_lock(&mutex); + count = anon_count++; + mtx_unlock(&mutex); + + identifier = ralloc_asprintf(this, "#anon_struct_%04x", count); } name = identifier; this->declarations.push_degenerate_list_at_head(&declarator_list->link); -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCHv2 13/13] i965: enable threaded precompile
Inherit gl_shader_program and add save/restore functions to save precompile results in the shader programs. When DeferLinkProgram is set, we will save the precompile results instead of uploading them immediately because we may be on a different thread. A few other modifications are also needed. brw_shader_program_precompile_key is introduced and initialized in NofityLinkShader for we cannot inspect the context during precompiling. Signed-off-by: Chia-I Wu --- src/mesa/drivers/dri/i965/brw_context.c | 4 +- src/mesa/drivers/dri/i965/brw_fs.cpp | 33 -- src/mesa/drivers/dri/i965/brw_program.c | 1 + src/mesa/drivers/dri/i965/brw_shader.cpp | 177 ++- src/mesa/drivers/dri/i965/brw_shader.h | 44 src/mesa/drivers/dri/i965/brw_vec4_gs.c | 37 +-- src/mesa/drivers/dri/i965/brw_vs.c | 36 +-- src/mesa/drivers/dri/i965/brw_wm.c | 23 ++-- src/mesa/drivers/dri/i965/brw_wm.h | 5 +- 9 files changed, 310 insertions(+), 50 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index bd13ebf..4a28766 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -784,8 +784,8 @@ brwCreateContext(gl_api api, if (INTEL_DEBUG & DEBUG_SHADER_TIME) brw_init_shader_time(brw); - /* brw_shader_precompile is not thread-safe */ - if (brw->precompile) + /* brw_shader_precompile is not thread-safe when debug flags are set */ + if (brw->precompile && (INTEL_DEBUG || brw->perf_debug)) ctx->Const.DeferLinkProgram = GL_FALSE; _mesa_compute_version(ctx); diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index a3ad375..61a0dff 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -3288,6 +3288,8 @@ bool brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog) { struct brw_context *brw = brw_context(ctx); + const struct brw_shader_program_precompile_key *pre_key = + brw_shader_program_get_precompile_key(prog); struct brw_wm_prog_key key; if (!prog->_LinkedShaders[MESA_SHADER_FRAGMENT]) @@ -3329,7 +3331,7 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog) } if (fp->Base.InputsRead & VARYING_BIT_POS) { - key.drawable_height = ctx->DrawBuffer->Height; + key.drawable_height = pre_key->fbo_height; } key.nr_color_regions = _mesa_bitcount_64(fp->Base.OutputsWritten & @@ -3337,7 +3339,7 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog) BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK))); if ((fp->Base.InputsRead & VARYING_BIT_POS) || program_uses_dfdy) { - key.render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer) || + key.render_to_fbo = pre_key->is_user_fbo || key.nr_color_regions > 1; } @@ -3349,13 +3351,28 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog) key.program_string_id = bfp->id; - uint32_t old_prog_offset = brw->wm.base.prog_offset; - struct brw_wm_prog_data *old_prog_data = brw->wm.prog_data; + struct brw_wm_compile c; - bool success = do_wm_prog(brw, prog, bfp, &key); + brw_wm_init_compile(brw, prog, bfp, &key, &c); + if (!brw_wm_do_compile(brw, &c)) { + brw_wm_clear_compile(brw, &c); + return false; + } + + if (brw->ctx.Const.DeferLinkProgram) { + brw_shader_program_save_wm_compile(prog, &c); + } + else { + uint32_t old_prog_offset = brw->wm.base.prog_offset; + struct brw_wm_prog_data *old_prog_data = brw->wm.prog_data; - brw->wm.base.prog_offset = old_prog_offset; - brw->wm.prog_data = old_prog_data; + brw_wm_upload_compile(brw, &c); - return success; + brw->wm.base.prog_offset = old_prog_offset; + brw->wm.prog_data = old_prog_data; + } + + brw_wm_clear_compile(brw, &c); + + return true; } diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index cff1188..2194640 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -259,6 +259,7 @@ void brwInitFragProgFuncs( struct dd_function_table *functions ) functions->NewShader = brw_new_shader; functions->NewShaderProgram = brw_new_shader_program; functions->LinkShader = brw_link_shader; + functions->NotifyLinkShader = brw_notify_link_shader; } void diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 318802b..3cf1f15 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -25,14 +25,52 @@ extern "C" { #include "main/macros.h" #include "brw_context.h" } +#include "brw_shader.h" #include "brw_vs.h" #include "brw_vec4_gs.h" +#include "brw_vec4_gs_visitor.h" #include "brw_fs.h" #include "brw_cfg.h" #i
[Mesa-dev] [PATCHv2 03/13] glsl: initialize locale_t with a static object
The compiler may be used by multiple contexts simultaneously and needs to be thread-safe. Signed-off-by: Chia-I Wu --- src/glsl/strtod.cpp | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/glsl/strtod.cpp b/src/glsl/strtod.cpp index 5d4346b..1ac29ec 100644 --- a/src/glsl/strtod.cpp +++ b/src/glsl/strtod.cpp @@ -35,6 +35,17 @@ #include "strtod.h" +#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ + !defined(__HAIKU__) && !defined(__UCLIBC__) +#define GLSL_HAVE_LOCALE_T +#endif + +#ifdef GLSL_HAVE_LOCALE_T +static struct locale_initializer { + locale_initializer() { loc = newlocale(LC_CTYPE_MASK, "C", NULL); } + locale_t loc; +} loc_init; +#endif /** @@ -44,13 +55,8 @@ double glsl_strtod(const char *s, char **end) { -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(__HAIKU__) && !defined(__UCLIBC__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtod_l(s, end, loc); +#ifdef GLSL_HAVE_LOCALE_T + return strtod_l(s, end, loc_init.loc); #else return strtod(s, end); #endif @@ -64,13 +70,8 @@ glsl_strtod(const char *s, char **end) float glsl_strtof(const char *s, char **end) { -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(__HAIKU__) && !defined(__UCLIBC__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtof_l(s, end, loc); +#ifdef GLSL_HAVE_LOCALE_T + return strtof_l(s, end, loc_init.loc); #elif _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE return strtof(s, end); #else -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCHv2 01/13] mesa: protect the debug state with a mutex
We are about to change mesa to spawn threads for deferred glCompileShader and glLinkProgram, and we need to make sure those threads can send compiler warnings/errors to the debug output safely. Signed-off-by: Chia-I Wu --- src/mesa/main/errors.c | 172 +++-- src/mesa/main/mtypes.h | 1 + 2 files changed, 126 insertions(+), 47 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index aa0ff50..156eb0d 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -676,22 +676,41 @@ debug_pop_group(struct gl_debug_state *debug) /** - * Return debug state for the context. The debug state will be allocated - * and initialized upon the first call. + * Lock and return debug state for the context. The debug state will be + * allocated and initialized upon the first call. When NULL is returned, the + * debug state is not locked. */ static struct gl_debug_state * -_mesa_get_debug_state(struct gl_context *ctx) +_mesa_lock_debug_state(struct gl_context *ctx) { + mtx_lock(&ctx->DebugMutex); + if (!ctx->Debug) { ctx->Debug = debug_create(); if (!ctx->Debug) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state"); + GET_CURRENT_CONTEXT(cur); + mtx_unlock(&ctx->DebugMutex); + + /* + * This function may be called from other threads. When that is the + * case, we cannot record this OOM error. + */ + if (ctx == cur) +_mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state"); + + return NULL; } } return ctx->Debug; } +static void +_mesa_unlock_debug_state(struct gl_context *ctx) +{ + mtx_unlock(&ctx->DebugMutex); +} + /** * Set the integer debug state specified by \p pname. This can be called from * _mesa_set_enable for example. @@ -699,7 +718,7 @@ _mesa_get_debug_state(struct gl_context *ctx) bool _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val) { - struct gl_debug_state *debug = _mesa_get_debug_state(ctx); + struct gl_debug_state *debug = _mesa_lock_debug_state(ctx); if (!debug) return false; @@ -716,6 +735,8 @@ _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val) break; } + _mesa_unlock_debug_state(ctx); + return true; } @@ -729,9 +750,12 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname) struct gl_debug_state *debug; GLint val; + mtx_lock(&ctx->DebugMutex); debug = ctx->Debug; - if (!debug) + if (!debug) { + mtx_unlock(&ctx->DebugMutex); return 0; + } switch (pname) { case GL_DEBUG_OUTPUT: @@ -756,6 +780,8 @@ _mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname) break; } + mtx_unlock(&ctx->DebugMutex); + return val; } @@ -769,9 +795,12 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname) struct gl_debug_state *debug; void *val; + mtx_lock(&ctx->DebugMutex); debug = ctx->Debug; - if (!debug) + if (!debug) { + mtx_unlock(&ctx->DebugMutex); return NULL; + } switch (pname) { case GL_DEBUG_CALLBACK_FUNCTION_ARB: @@ -786,9 +815,49 @@ _mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname) break; } + mtx_unlock(&ctx->DebugMutex); + return val; } +/** + * Insert a debug message. The mutex is assumed to be locked, and will be + * unlocked by this call. + */ +static void +log_msg_locked_and_unlock(struct gl_context *ctx, + enum mesa_debug_source source, + enum mesa_debug_type type, GLuint id, + enum mesa_debug_severity severity, + GLint len, const char *buf) +{ + struct gl_debug_state *debug = ctx->Debug; + + if (!debug_is_message_enabled(debug, source, type, id, severity)) { + _mesa_unlock_debug_state(ctx); + return; + } + + if (ctx->Debug->Callback) { + GLenum gl_source = debug_source_enums[source]; + GLenum gl_type = debug_type_enums[type]; + GLenum gl_severity = debug_severity_enums[severity]; + GLDEBUGPROC callback = ctx->Debug->Callback; + const void *data = ctx->Debug->CallbackData; + + /* + * When ctx->Debug->SyncOutput is GL_FALSE, the client is prepared for + * unsynchronous calls. When it is GL_TRUE, we will not spawn threads. + * In either case, we can call the callback unlocked. + */ + _mesa_unlock_debug_state(ctx); + callback(gl_source, gl_type, id, gl_severity, len, buf, data); + } + else { + debug_log_message(ctx->Debug, source, type, id, severity, len, buf); + _mesa_unlock_debug_state(ctx); + } +} /** * Log a client or driver debug message. @@ -798,24 +867,12 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source, enum mesa_debug_type type, GLuint id, enum mesa_debug_severity severit
[Mesa-dev] [PATCHv2 02/13] glsl: rename strtod.c to strtod.cpp
We want to add a static object to initialize locale_t in the following commit. Signed-off-by: Chia-I Wu --- src/glsl/Makefile.sources | 2 +- src/glsl/strtod.c | 79 --- src/glsl/strtod.cpp | 79 +++ 3 files changed, 80 insertions(+), 80 deletions(-) delete mode 100644 src/glsl/strtod.c create mode 100644 src/glsl/strtod.cpp diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources index b54eae7..6fc94d6 100644 --- a/src/glsl/Makefile.sources +++ b/src/glsl/Makefile.sources @@ -103,7 +103,7 @@ LIBGLSL_FILES = \ $(GLSL_SRCDIR)/opt_tree_grafting.cpp \ $(GLSL_SRCDIR)/opt_vectorize.cpp \ $(GLSL_SRCDIR)/s_expression.cpp \ - $(GLSL_SRCDIR)/strtod.c + $(GLSL_SRCDIR)/strtod.cpp # glsl_compiler diff --git a/src/glsl/strtod.c b/src/glsl/strtod.c deleted file mode 100644 index 5d4346b..000 --- a/src/glsl/strtod.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include - -#ifdef _GNU_SOURCE -#include -#ifdef __APPLE__ -#include -#endif -#endif - -#include "strtod.h" - - - -/** - * Wrapper around strtod which uses the "C" locale so the decimal - * point is always '.' - */ -double -glsl_strtod(const char *s, char **end) -{ -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(__HAIKU__) && !defined(__UCLIBC__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtod_l(s, end, loc); -#else - return strtod(s, end); -#endif -} - - -/** - * Wrapper around strtof which uses the "C" locale so the decimal - * point is always '.' - */ -float -glsl_strtof(const char *s, char **end) -{ -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(__HAIKU__) && !defined(__UCLIBC__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtof_l(s, end, loc); -#elif _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE - return strtof(s, end); -#else - return (float) strtod(s, end); -#endif -} diff --git a/src/glsl/strtod.cpp b/src/glsl/strtod.cpp new file mode 100644 index 000..5d4346b --- /dev/null +++ b/src/glsl/strtod.cpp @@ -0,0 +1,79 @@ +/* + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include + +#ifdef _GNU_SOURCE +#include +#ifdef __APPLE__ +#include +#endif +#endif + +#include "strtod.h" + + + +/** + * Wrapper around strtod which uses the "C" locale so the decimal + * point is always '.' + */ +double +glsl_strtod(const char *s, char **end) +{ +#if defined(_GNU_SOURCE) && !defined(_
[Mesa-dev] [PATCHv2 11/13] i965: refactor do_gs_prog
Split do_gs_prog into brw_gs_init_compile brw_gs_do_compile brw_gs_upload_compile brw_gs_clear_complile Signed-off-by: Chia-I Wu --- src/mesa/drivers/dri/i965/brw_vec4_gs.c | 153 1 file changed, 96 insertions(+), 57 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs.c b/src/mesa/drivers/dri/i965/brw_vec4_gs.c index 6428291..39ee507 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_gs.c +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs.c @@ -33,22 +33,29 @@ #include "brw_state.h" -static bool -do_gs_prog(struct brw_context *brw, - struct gl_shader_program *prog, - struct brw_geometry_program *gp, - struct brw_gs_prog_key *key) +static void +brw_gs_init_compile(struct brw_context *brw, +struct gl_shader_program *prog, +struct brw_geometry_program *gp, +const struct brw_gs_prog_key *key, +struct brw_gs_compile *c) { - struct brw_stage_state *stage_state = &brw->gs.base; - struct brw_gs_compile c; - memset(&c, 0, sizeof(c)); - c.key = *key; - c.gp = gp; + memset(c, 0, sizeof(*c)); - c.prog_data.include_primitive_id = - (gp->program.Base.InputsRead & VARYING_BIT_PRIMITIVE_ID) != 0; + c->key = *key; + c->gp = gp; + c->base.shader_prog = prog; + c->base.mem_ctx = ralloc_context(NULL); +} - c.prog_data.invocations = gp->program.Invocations; +static bool +brw_gs_do_compile(struct brw_context *brw, + struct brw_gs_compile *c) +{ + c->prog_data.include_primitive_id = + (c->gp->program.Base.InputsRead & VARYING_BIT_PRIMITIVE_ID) != 0; + + c->prog_data.invocations = c->gp->program.Invocations; /* Allocate the references to the uniforms that will end up in the * prog_data associated with the compiled program, and which will be freed @@ -58,34 +65,35 @@ do_gs_prog(struct brw_context *brw, * padding around uniform values below vec4 size, so the worst case is that * every uniform is a float which gets padded to the size of a vec4. */ - struct gl_shader *gs = prog->_LinkedShaders[MESA_SHADER_GEOMETRY]; + struct gl_shader *gs = + c->base.shader_prog->_LinkedShaders[MESA_SHADER_GEOMETRY]; int param_count = gs->num_uniform_components * 4; /* We also upload clip plane data as uniforms */ param_count += MAX_CLIP_PLANES * 4; - c.prog_data.base.base.param = + c->prog_data.base.base.param = rzalloc_array(NULL, const float *, param_count); - c.prog_data.base.base.pull_param = + c->prog_data.base.base.pull_param = rzalloc_array(NULL, const float *, param_count); /* Setting nr_params here NOT to the size of the param and pull_param * arrays, but to the number of uniform components vec4_visitor * needs. vec4_visitor::setup_uniforms() will set it back to a proper value. */ - c.prog_data.base.base.nr_params = ALIGN(param_count, 4) / 4 + gs->num_samplers; + c->prog_data.base.base.nr_params = ALIGN(param_count, 4) / 4 + gs->num_samplers; - if (gp->program.OutputType == GL_POINTS) { + if (c->gp->program.OutputType == GL_POINTS) { /* When the output type is points, the geometry shader may output data * to multiple streams, and EndPrimitive() has no effect. So we * configure the hardware to interpret the control data as stream ID. */ - c.prog_data.control_data_format = GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_SID; + c->prog_data.control_data_format = GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_SID; /* We only have to emit control bits if we are using streams */ - if (prog->Geom.UsesStreams) - c.control_data_bits_per_vertex = 2; + if (c->base.shader_prog->Geom.UsesStreams) + c->control_data_bits_per_vertex = 2; else - c.control_data_bits_per_vertex = 0; + c->control_data_bits_per_vertex = 0; } else { /* When the output type is triangle_strip or line_strip, EndPrimitive() * may be used to terminate the current strip and start a new one @@ -93,32 +101,33 @@ do_gs_prog(struct brw_context *brw, * streams is not supported. So we configure the hardware to interpret * the control data as EndPrimitive information (a.k.a. "cut bits"). */ - c.prog_data.control_data_format = GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_CUT; + c->prog_data.control_data_format = GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_CUT; /* We only need to output control data if the shader actually calls * EndPrimitive(). */ - c.control_data_bits_per_vertex = gp->program.UsesEndPrimitive ? 1 : 0; + c->control_data_bits_per_vertex = + c->gp->program.UsesEndPrimitive ? 1 : 0; } - c.control_data_header_size_bits = - gp->program.VerticesOut * c.control_data_bits_per_vertex; + c->control_data_header_size_bits = + c->gp->program.VerticesOut * c->control_data_bits_per_vertex; /* 1 HWOR
[Mesa-dev] [PATCHv2 08/13] mesa: add infrastructure for threaded shader compilation
Add _mesa_enable_glsl_threadpool to enable the thread pool for a context, and add ctx->Const.DeferCompileShader and ctx->Const.DeferLinkProgram to fine-control what gets threaded. Setting DeferCompileShader to true will make _mesa_glsl_compile_shader be executed in a worker thread. The function is thread-safe so there is no restriction on DeferCompileShader. Setting DeferLinkProgram to true will make _mesa_glsl_link_shader be executed in a worker thread. The function is thread-safe only when certain driver functions (as documented in struct gl_constants) are thread-safe. It is drivers' responsibility to fix those driver functions before setting DeferLinkProgram. When DeferLinkProgram is set, drivers are not supposed to inspect the context in their LinkShader callbacks. Instead, NotifyLinkShader is added. Drivers should inspect the context in NotifyLinkShader and save what they need for LinkShader in gl_shader_program. As a final note, most applications will not benefit from threaded shader compilation because they check GL_COMPILE_STATUS/GL_LINK_STATUS immediately, giving the worker threads no time to do their jobs. A possible improvement is to split LinkShader into two parts: the first part links and error checks while the second part optimizes and generates the machine code. With the split, we can always defer the second part to the thread pool. Signed-off-by: Chia-I Wu --- src/mesa/main/context.c | 29 +++ src/mesa/main/context.h | 3 ++ src/mesa/main/dd.h | 8 +++ src/mesa/main/mtypes.h | 34 src/mesa/main/pipelineobj.c | 18 +++ src/mesa/main/shaderapi.c | 122 +++- src/mesa/main/shaderobj.c | 74 +-- src/mesa/main/shaderobj.h | 55 ++-- 8 files changed, 322 insertions(+), 21 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index b082159..e27450c 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -112,6 +112,7 @@ #include "points.h" #include "polygon.h" #include "queryobj.h" +#include "shaderapi.h" #include "syncobj.h" #include "rastpos.h" #include "remap.h" @@ -139,6 +140,7 @@ #endif #include "glsl_parser_extras.h" +#include "threadpool.h" #include @@ -1187,6 +1189,27 @@ _mesa_create_context(gl_api api, } } +void +_mesa_enable_glsl_threadpool(struct gl_context *ctx, int max_threads) +{ + if (!ctx->ThreadPool) + ctx->ThreadPool = _mesa_glsl_get_threadpool(max_threads); +} + +static void +wait_shader_object_cb(GLuint id, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_shader *sh = (struct gl_shader *) data; + + if (_mesa_validate_shader_target(ctx, sh->Type)) { + _mesa_wait_shaders(ctx, &sh, 1); + } + else { + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + _mesa_wait_shader_program(ctx, shProg); + } +} /** * Free the data associated with the given context. @@ -1205,6 +1228,12 @@ _mesa_free_context_data( struct gl_context *ctx ) _mesa_make_current(ctx, NULL, NULL); } + if (ctx->ThreadPool) { + _mesa_HashWalk(ctx->Shared->ShaderObjects, wait_shader_object_cb, ctx); + _mesa_threadpool_unref(ctx->ThreadPool); + ctx->ThreadPool = NULL; + } + /* unreference WinSysDraw/Read buffers */ _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL); _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL); diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 792ab4c..b23f9fa 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -118,6 +118,9 @@ _mesa_create_context(gl_api api, const struct dd_function_table *driverFunctions); extern void +_mesa_enable_glsl_threadpool(struct gl_context *ctx, int max_threads); + +extern void _mesa_free_context_data( struct gl_context *ctx ); extern void diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 633ea2c..38f8c68 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -447,6 +447,14 @@ struct dd_function_table { */ /*@{*/ /** +* Called when a shader program is to be linked. +* +* This is optional and gives drivers an opportunity to inspect the context +* and prepare for LinkShader, which may be deferred to another thread. +*/ + void (*NotifyLinkShader)(struct gl_context *ctx, +struct gl_shader_program *shader); + /** * Called when a shader program is linked. * * This gives drivers an opportunity to clone the IR and make their diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 5964576..316da23 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -71,6 +71,8 @@ typedef GLuint64 GLbitfield64; */ /*@{*/ struct _mesa_HashTable; +struct _mesa_threadpool; +struct _mesa_threadpool_task; struct gl_attrib_node; struct g
[Mesa-dev] [PATCHv2 07/13] glsl: add a singleton GLSL thread pool
This thread pool will be used by contexts to queue compilation tasks. Signed-off-by: Chia-I Wu --- src/glsl/glsl_parser_extras.cpp | 4 +++ src/glsl/threadpool.c | 72 + src/glsl/threadpool.h | 9 ++ 3 files changed, 85 insertions(+) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index ad31469..cb7d59e 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -37,6 +37,7 @@ extern "C" { #include "glsl_parser.h" #include "ir_optimization.h" #include "loop_analysis.h" +#include "threadpool.h" /** * Format a short human-readable description of the given GLSL version. @@ -1599,6 +1600,8 @@ extern "C" { void _mesa_destroy_shader_compiler(void) { + _mesa_glsl_destroy_threadpool(); + _mesa_destroy_shader_compiler_caches(); _mesa_glsl_release_types(); @@ -1612,6 +1615,7 @@ _mesa_destroy_shader_compiler(void) void _mesa_destroy_shader_compiler_caches(void) { + _mesa_glsl_wait_threadpool(); _mesa_glsl_release_builtin_functions(); } diff --git a/src/glsl/threadpool.c b/src/glsl/threadpool.c index c069fd3..d6ed8c1 100644 --- a/src/glsl/threadpool.c +++ b/src/glsl/threadpool.c @@ -55,6 +55,7 @@ struct _mesa_threadpool_task { struct _mesa_threadpool { mtx_t mutex; int refcnt; + bool shutdown; enum _mesa_threadpool_control thread_control; thrd_t *threads; @@ -168,6 +169,12 @@ _mesa_threadpool_queue_task(struct _mesa_threadpool *pool, mtx_lock(&pool->mutex); + if (unlikely(pool->shutdown)) { + mtx_unlock(&pool->mutex); + free(task); + return NULL; + } + /* someone is joining with the threads */ while (unlikely(pool->thread_control != MESA_THREADPOOL_NORMAL)) cnd_wait(&pool->thread_joined, &pool->mutex); @@ -379,6 +386,17 @@ _mesa_threadpool_join(struct _mesa_threadpool *pool, bool graceful) } /** + * After this call, no task can be queued. + */ +static void +_mesa_threadpool_set_shutdown(struct _mesa_threadpool *pool) +{ + mtx_lock(&pool->mutex); + pool->shutdown = true; + mtx_unlock(&pool->mutex); +} + +/** * Decrease the reference count. Destroy \p pool when the reference count * reaches zero. */ @@ -474,3 +492,57 @@ _mesa_threadpool_create(int max_threads) return pool; } + +static mtx_t threadpool_lock = _MTX_INITIALIZER_NP; +static struct _mesa_threadpool *threadpool; + +/** + * Get the singleton GLSL thread pool. \p max_threads is honored only by the + * first call to this function. + */ +struct _mesa_threadpool * +_mesa_glsl_get_threadpool(int max_threads) +{ + mtx_lock(&threadpool_lock); + if (!threadpool) + threadpool = _mesa_threadpool_create(max_threads); + if (threadpool) + _mesa_threadpool_ref(threadpool); + mtx_unlock(&threadpool_lock); + + return threadpool; +} + +/** + * Wait until all tasks are completed and threads are joined. + */ +void +_mesa_glsl_wait_threadpool(void) +{ + mtx_lock(&threadpool_lock); + if (threadpool) + _mesa_threadpool_join(threadpool, true); + mtx_unlock(&threadpool_lock); +} + +/** + * Destroy the GLSL thread pool. + */ +void +_mesa_glsl_destroy_threadpool(void) +{ + mtx_lock(&threadpool_lock); + if (threadpool) { + /* + * This is called from _mesa_destroy_shader_compiler(). No new task is + * allowed since this point. But contexts, who also own references to + * the pool, can still complete tasks that have been queued. + */ + _mesa_threadpool_set_shutdown(threadpool); + + _mesa_threadpool_join(threadpool, false); + _mesa_threadpool_unref(threadpool); + threadpool = NULL; + } + mtx_unlock(&threadpool_lock); +} diff --git a/src/glsl/threadpool.h b/src/glsl/threadpool.h index 48e4a47..b1a8ea8 100644 --- a/src/glsl/threadpool.h +++ b/src/glsl/threadpool.h @@ -60,6 +60,15 @@ bool _mesa_threadpool_complete_task(struct _mesa_threadpool *pool, struct _mesa_threadpool_task *task); +struct _mesa_threadpool * +_mesa_glsl_get_threadpool(int max_threads); + +void +_mesa_glsl_wait_threadpool(void); + +void +_mesa_glsl_destroy_threadpool(void); + #ifdef __cplusplus } #endif -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCHv2 10/13] i965: refactor do_vs_prog
Split do_vs_prog into brw_vs_init_compile brw_vs_do_compile brw_vs_upload_compile brw_vs_clear_complile Signed-off-by: Chia-I Wu --- src/mesa/drivers/dri/i965/brw_vec4.h | 6 ++ src/mesa/drivers/dri/i965/brw_vs.c | 117 ++- src/mesa/drivers/dri/i965/brw_vs.h | 1 + 3 files changed, 81 insertions(+), 43 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 87247ea..dd66b6c 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -48,6 +48,12 @@ extern "C" { struct brw_vec4_compile { GLuint last_scratch; /**< measured in 32-byte (register size) units */ + + struct gl_shader_program *shader_prog; + + void *mem_ctx; + const unsigned *program; + unsigned program_size; }; diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index e0f32b3..22bc473 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -187,31 +187,31 @@ brw_vs_prog_data_compare(const void *in_a, const void *in_b) return true; } -static bool -do_vs_prog(struct brw_context *brw, - struct gl_shader_program *prog, - struct brw_vertex_program *vp, - struct brw_vs_prog_key *key) +static void +brw_vs_init_compile(struct brw_context *brw, + struct gl_shader_program *prog, + struct brw_vertex_program *vp, + const struct brw_vs_prog_key *key, + struct brw_vs_compile *c) { - GLuint program_size; - const GLuint *program; - struct brw_vs_compile c; - struct brw_vs_prog_data prog_data; - struct brw_stage_prog_data *stage_prog_data = &prog_data.base.base; - void *mem_ctx; - int i; - struct gl_shader *vs = NULL; - - if (prog) - vs = prog->_LinkedShaders[MESA_SHADER_VERTEX]; + memset(c, 0, sizeof(*c)); - memset(&c, 0, sizeof(c)); - memcpy(&c.key, key, sizeof(*key)); - memset(&prog_data, 0, sizeof(prog_data)); + memcpy(&c->key, key, sizeof(*key)); + c->vp = vp; + c->base.shader_prog = prog; + c->base.mem_ctx = ralloc_context(NULL); +} - mem_ctx = ralloc_context(NULL); +static bool +brw_vs_do_compile(struct brw_context *brw, + struct brw_vs_compile *c) +{ + struct brw_stage_prog_data *stage_prog_data = &c->prog_data.base.base; + struct gl_shader *vs = NULL; + int i; - c.vp = vp; + if (c->base.shader_prog) + vs = c->base.shader_prog->_LinkedShaders[MESA_SHADER_VERTEX]; /* Allocate the references to the uniforms that will end up in the * prog_data associated with the compiled program, and which will be freed @@ -226,12 +226,12 @@ do_vs_prog(struct brw_context *brw, param_count = vs->num_uniform_components * 4; } else { - param_count = vp->program.Base.Parameters->NumParameters * 4; + param_count = c->vp->program.Base.Parameters->NumParameters * 4; } /* vec4_visitor::setup_uniform_clipplane_values() also uploads user clip * planes as uniforms. */ - param_count += c.key.base.nr_userclip_plane_consts * 4; + param_count += c->key.base.nr_userclip_plane_consts * 4; stage_prog_data->param = rzalloc_array(NULL, const float *, param_count); stage_prog_data->pull_param = rzalloc_array(NULL, const float *, param_count); @@ -245,12 +245,12 @@ do_vs_prog(struct brw_context *brw, stage_prog_data->nr_params += vs->num_samplers; } - GLbitfield64 outputs_written = vp->program.Base.OutputsWritten; - prog_data.inputs_read = vp->program.Base.InputsRead; + GLbitfield64 outputs_written = c->vp->program.Base.OutputsWritten; + c->prog_data.inputs_read = c->vp->program.Base.InputsRead; - if (c.key.copy_edgeflag) { + if (c->key.copy_edgeflag) { outputs_written |= BITFIELD64_BIT(VARYING_SLOT_EDGE); - prog_data.inputs_read |= VERT_BIT_EDGEFLAG; + c->prog_data.inputs_read |= VERT_BIT_EDGEFLAG; } if (brw->gen < 6) { @@ -261,7 +261,7 @@ do_vs_prog(struct brw_context *brw, * coords, which would be a pain to handle. */ for (i = 0; i < 8; i++) { - if (c.key.point_coord_replace & (1 << i)) + if (c->key.point_coord_replace & (1 << i)) outputs_written |= BITFIELD64_BIT(VARYING_SLOT_TEX0 + i); } @@ -276,45 +276,76 @@ do_vs_prog(struct brw_context *brw, * distance varying slots whenever clipping is enabled, even if the vertex * shader doesn't write to gl_ClipDistance. */ - if (c.key.base.userclip_active) { + if (c->key.base.userclip_active) { outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0); outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1); } - brw_compute_vue_map(brw, &prog_data.base.vue_map, outputs_written); + brw_compute_vue_map(brw, &c->prog_data.base.vue_map, outputs_written); if (0) { - _mesa_fprint_program_opt(stderr, &c.vp->progr
[Mesa-dev] [PATCHv2 06/13] glsl: add a generic thread pool data structure
It can be used to implement, for example, threaded glCompileShader and glLinkProgram. v2: allow tasks to "complete" other tasks Signed-off-by: Chia-I Wu --- src/glsl/Makefile.am | 12 +- src/glsl/Makefile.sources | 3 +- src/glsl/tests/threadpool_test.cpp | 137 +++ src/glsl/threadpool.c | 476 + src/glsl/threadpool.h | 67 ++ 5 files changed, 693 insertions(+), 2 deletions(-) create mode 100644 src/glsl/tests/threadpool_test.cpp create mode 100644 src/glsl/threadpool.c create mode 100644 src/glsl/threadpool.h diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am index 00261fd..3d07af3 100644 --- a/src/glsl/Makefile.am +++ b/src/glsl/Makefile.am @@ -35,6 +35,7 @@ TESTS = glcpp/tests/glcpp-test \ tests/general-ir-test \ tests/optimization-test \ tests/ralloc-test \ + tests/threadpool-test \ tests/sampler-types-test\ tests/uniform-initializer-test @@ -48,6 +49,7 @@ check_PROGRAMS = \ glsl_test \ tests/general-ir-test \ tests/ralloc-test \ + tests/threadpool-test \ tests/sampler-types-test\ tests/uniform-initializer-test @@ -95,6 +97,14 @@ tests_ralloc_test_LDADD =\ $(top_builddir)/src/gtest/libgtest.la \ $(PTHREAD_LIBS) +tests_threadpool_test_SOURCES =\ + tests/threadpool_test.cpp \ + $(top_builddir)/src/glsl/threadpool.c +tests_threadpool_test_CFLAGS = $(PTHREAD_CFLAGS) +tests_threadpool_test_LDADD = \ + $(top_builddir)/src/gtest/libgtest.la \ + $(PTHREAD_LIBS) + tests_sampler_types_test_SOURCES = \ $(top_srcdir)/src/mesa/program/prog_hash_table.c\ $(top_srcdir)/src/mesa/program/symbol_table.c \ @@ -120,7 +130,7 @@ glcpp_glcpp_LDADD = \ libglcpp.la \ -lm -libglsl_la_LIBADD = libglcpp.la +libglsl_la_LIBADD = libglcpp.la $(PTHREAD_LIBS) libglsl_la_SOURCES = \ glsl_lexer.cpp \ glsl_parser.cpp \ diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources index 6fc94d6..bab2358 100644 --- a/src/glsl/Makefile.sources +++ b/src/glsl/Makefile.sources @@ -103,7 +103,8 @@ LIBGLSL_FILES = \ $(GLSL_SRCDIR)/opt_tree_grafting.cpp \ $(GLSL_SRCDIR)/opt_vectorize.cpp \ $(GLSL_SRCDIR)/s_expression.cpp \ - $(GLSL_SRCDIR)/strtod.cpp + $(GLSL_SRCDIR)/strtod.cpp \ + $(GLSL_SRCDIR)/threadpool.c # glsl_compiler diff --git a/src/glsl/tests/threadpool_test.cpp b/src/glsl/tests/threadpool_test.cpp new file mode 100644 index 000..63f55c5 --- /dev/null +++ b/src/glsl/tests/threadpool_test.cpp @@ -0,0 +1,137 @@ +/* + * Copyright © 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include +#include +#include +#include "c11/threads.h" + +#include "threadpool.h" + +#define NUM_THREADS 10 +#define OPS_PER_THREAD 100 +#define MAX_TASKS 10 + +static void +race_cb(void *data) +{ + usleep(1000 * 5); +} + +static int +race_random_op(void *data) +{ + struct _mesa_threadpool *pool = (struct _mesa_threadpool *) data; + struct _mesa_threadpool_task *tasks[MAX_TASKS]; + int num_tasks = 0; + int num_ops = 0; + int i; + +
[Mesa-dev] [PATCHv2 00/13] multithread GLSL compiler
Hi list, This is my second try to add multithread support for the GLSL compiler. Changes since v1 are - glLinkProgram can now be threaded - added ctx->Const.DeferCompileShader and ctx->Const.DeferLinkProgram to allow drivers to control what get threaded - minimal changes to i965 to enable DeferLinkProgram The most interesting patch should be patch 8, which makes the necessary changes to core mesa. Patch 13 touches i965 and is more a RFC patch. v2 still requires applications to "Do the Right Thing" to benefit from multithread compiler. But that can be changed as noted in patch 8. I am open to suggestions. A summary of the patches: Patch 1 makes our GL_KRH_debug implementation thread-safe. Patch 2~5 make the GLSL compiler thread-safe. These are mostly the same as v1, except for how locale_t is initialized. Patch 6~7 add a singleton thread pool to the compiler. Patch 8 adds the infrastructure to core mesa to enable multithread compiling/linkg, and patch 9 adds a dri option to enable DeferCompileShader for i965. Patch 10~12 refactor some code in i965 and patch 13 adds the necessary changes to enable DeferLinkProgram. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 77449] Tracker bug for all bugs related to Steam titles
https://bugs.freedesktop.org/show_bug.cgi?id=77449 Bug 77449 depends on bug 79948, which changed state. Bug 79948 Summary: [i965] Incorrect pixels when using discard and uniform loads https://bugs.freedesktop.org/show_bug.cgi?id=79948 What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev