Mesa (master): freedreno/a3xx: fix generic clear path
Module: Mesa Branch: master Commit: 5def00875de4f0895e22de94cba29131a26c0430 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5def00875de4f0895e22de94cba29131a26c0430 Author: Rob Clark Date: Tue Aug 16 19:13:55 2016 -0400 freedreno/a3xx: fix generic clear path Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_draw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index efc1dd2..cfe13cd 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -256,6 +256,7 @@ fd_blitter_clear(struct pipe_context *pctx, unsigned buffers, struct pipe_draw_info info = { .mode = PIPE_PRIM_MAX,/* maps to DI_PT_RECTLIST */ .count = 2, + .max_index = 1, .instance_count = 1, }; ctx->draw_vbo(ctx, &info); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): gallium/u_blitter: split out a helper for common clear state
Module: Mesa Branch: master Commit: 142dd7b9c043fca81f8ef1d0bbd378968f9260df URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=142dd7b9c043fca81f8ef1d0bbd378968f9260df Author: Rob Clark Date: Sat Aug 13 10:51:51 2016 -0400 gallium/u_blitter: split out a helper for common clear state Signed-off-by: Rob Clark Reviewed-by: Marek Olšák --- src/gallium/auxiliary/util/u_blitter.c | 38 ++ src/gallium/auxiliary/util/u_blitter.h | 5 + 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 9fbef9b..e008100 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -1268,19 +1268,13 @@ static void *get_clear_blend_state(struct blitter_context_priv *ctx, return ctx->blend_clear[index]; } -static void util_blitter_clear_custom(struct blitter_context *blitter, - unsigned width, unsigned height, - unsigned num_layers, - unsigned clear_buffers, - const union pipe_color_union *color, - double depth, unsigned stencil, - void *custom_blend, void *custom_dsa) +void util_blitter_common_clear_setup(struct blitter_context *blitter, + unsigned width, unsigned height, + unsigned clear_buffers, + void *custom_blend, void *custom_dsa) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; - struct pipe_stencil_ref sr = { { 0 } }; - - assert(ctx->has_layered || num_layers <= 1); util_blitter_set_running_flag(blitter); blitter_check_saved_vertex_states(ctx); @@ -1306,14 +1300,32 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); } + pipe->set_sample_mask(pipe, ~0); + blitter_set_dst_dimensions(ctx, width, height); +} + +static void util_blitter_clear_custom(struct blitter_context *blitter, + unsigned width, unsigned height, + unsigned num_layers, + unsigned clear_buffers, + const union pipe_color_union *color, + double depth, unsigned stencil, + void *custom_blend, void *custom_dsa) +{ + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; + struct pipe_context *pipe = ctx->base.pipe; + struct pipe_stencil_ref sr = { { 0 } }; + + assert(ctx->has_layered || num_layers <= 1); + + util_blitter_common_clear_setup(blitter, width, height, clear_buffers, + custom_blend, custom_dsa); + sr.ref_value[0] = stencil & 0xff; pipe->set_stencil_ref(pipe, &sr); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); bind_fs_write_all_cbufs(ctx); - pipe->set_sample_mask(pipe, ~0); - - blitter_set_dst_dimensions(ctx, width, height); if (num_layers > 1 && ctx->has_layered) { blitter_set_common_draw_rect_state(ctx, FALSE, TRUE); diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 0f5da6b..d7d9f4a 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -542,6 +542,11 @@ util_blitter_save_render_condition(struct blitter_context *blitter, blitter->saved_render_cond_cond = condition; } +void util_blitter_common_clear_setup(struct blitter_context *blitter, + unsigned width, unsigned height, + unsigned clear_buffers, + void *custom_blend, void *custom_dsa); + void util_blitter_set_running_flag(struct blitter_context *blitter); void util_blitter_unset_running_flag(struct blitter_context *blitter); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: support for using generic clear path
Module: Mesa Branch: master Commit: a8e6734a83816df2a39e5c4c49721d762caee86b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a8e6734a83816df2a39e5c4c49721d762caee86b Author: Rob Clark Date: Thu Aug 11 11:57:28 2016 -0400 freedreno: support for using generic clear path Since clears are more or less just normal draws, there isn't that much benefit in having hand-rolled clear path. Add support to use u_blitter instead if gen specific backend doesn't implement ctx->clear(). Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_context.c | 3 + src/gallium/drivers/freedreno/freedreno_context.h | 1 + src/gallium/drivers/freedreno/freedreno_draw.c | 74 ++ src/gallium/drivers/freedreno/freedreno_resource.c | 20 +++--- src/gallium/drivers/freedreno/freedreno_resource.h | 4 ++ 5 files changed, 92 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index 402e88f..ad62fd6 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -115,6 +115,9 @@ fd_context_destroy(struct pipe_context *pctx) if (ctx->blitter) util_blitter_destroy(ctx->blitter); + if (ctx->clear_rs_state) + pctx->delete_rasterizer_state(pctx, ctx->clear_rs_state); + if (ctx->primconvert) util_primconvert_destroy(ctx->primconvert); diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index ffc4d9e..037c199 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -117,6 +117,7 @@ struct fd_context { struct util_queue flush_queue; struct blitter_context *blitter; + void *clear_rs_state; struct primconvert_context *primconvert; /* slab for pipe_transfer allocations: */ diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 715ad21..efc1dd2 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -203,6 +203,72 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) fd_batch_check_size(batch); } +/* Generic clear implementation (partially) using u_blitter: */ +static void +fd_blitter_clear(struct pipe_context *pctx, unsigned buffers, + const union pipe_color_union *color, double depth, unsigned stencil) +{ + struct fd_context *ctx = fd_context(pctx); + struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer; + struct blitter_context *blitter = ctx->blitter; + + fd_blitter_pipe_begin(ctx, false, true, FD_STAGE_CLEAR); + + util_blitter_common_clear_setup(blitter, pfb->width, pfb->height, + buffers, NULL, NULL); + + struct pipe_stencil_ref sr = { + .ref_value = { stencil & 0xff } + }; + pctx->set_stencil_ref(pctx, &sr); + + struct pipe_constant_buffer cb = { + .buffer_size = 16, + .user_buffer = &color->ui, + }; + pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 0, &cb); + + if (!ctx->clear_rs_state) { + const struct pipe_rasterizer_state tmpl = { + .cull_face = PIPE_FACE_NONE, + .half_pixel_center = 1, + .bottom_edge_rule = 1, + .flatshade = 1, + .depth_clip = 1, + }; + ctx->clear_rs_state = pctx->create_rasterizer_state(pctx, &tmpl); + } + pctx->bind_rasterizer_state(pctx, ctx->clear_rs_state); + + struct pipe_viewport_state vp = { + .scale = { 0.5f * pfb->width, -0.5f * pfb->height, depth }, + .translate = { 0.5f * pfb->width, 0.5f * pfb->height, 0.0f }, + }; + pctx->set_viewport_states(pctx, 0, 1, &vp); + + pctx->bind_vertex_elements_state(pctx, ctx->solid_vbuf_state.vtx); + pctx->set_vertex_buffers(pctx, blitter->vb_slot, 1, + &ctx->solid_vbuf_state.vertexbuf.vb[0]); + pctx->set_stream_output_targets(pctx, 0, NULL, NULL); + pctx->bind_vs_state(pctx, ctx->solid_prog.vp); + pctx->bind_fs_state(pctx, ctx->solid_prog.fp); + + struct pipe_draw_info info = { + .mode = PIPE_PRIM_MAX,/* maps to DI_PT_RECTLIST */ + .count = 2, + .instance_count = 1, + }; + ctx->draw_vbo(ctx, &info); + + util_blitter_restore_constant_buffer_state(blitter); + util_blitter_restore_vertex_states(blitte
Mesa (master): freedreno/a4xx: use generic clear path
Module: Mesa Branch: master Commit: 27f12dd8fd3626fe20ff2f5ea5371238631eaa20 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27f12dd8fd3626fe20ff2f5ea5371238631eaa20 Author: Rob Clark Date: Thu Aug 11 12:00:52 2016 -0400 freedreno/a4xx: use generic clear path Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_context.c | 3 +- src/gallium/drivers/freedreno/a4xx/fd4_draw.c| 216 +-- 2 files changed, 4 insertions(+), 215 deletions(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_context.c b/src/gallium/drivers/freedreno/a4xx/fd4_context.c index 8ef715f..291df2d 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_context.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_context.c @@ -54,7 +54,7 @@ fd4_context_destroy(struct pipe_context *pctx) fd_context_destroy(pctx); } -static const uint8_t primtypes[PIPE_PRIM_MAX] = { +static const uint8_t primtypes[] = { [PIPE_PRIM_POINTS] = DI_PT_POINTLIST, [PIPE_PRIM_LINES] = DI_PT_LINELIST, [PIPE_PRIM_LINE_STRIP] = DI_PT_LINESTRIP, @@ -62,6 +62,7 @@ static const uint8_t primtypes[PIPE_PRIM_MAX] = { [PIPE_PRIM_TRIANGLES] = DI_PT_TRILIST, [PIPE_PRIM_TRIANGLE_STRIP] = DI_PT_TRISTRIP, [PIPE_PRIM_TRIANGLE_FAN] = DI_PT_TRIFAN, + [PIPE_PRIM_MAX]= DI_PT_RECTLIST, /* internal clear blits */ }; struct pipe_context * diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c index 200e4f2..06d16fe 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c @@ -131,9 +131,8 @@ fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) .vclamp_color = ctx->rasterizer->clamp_vertex_color, .fclamp_color = ctx->rasterizer->clamp_fragment_color, .rasterflat = ctx->rasterizer->flatshade, - // TODO set .half_precision based on render target format, - // ie. float16 and smaller use half, float32 use full.. - .half_precision = !!(fd_mesa_debug & FD_DBG_FRAGHALF), + .half_precision = ctx->in_blit && + fd_half_precision(&ctx->batch->framebuffer), .ucp_enables = ctx->rasterizer->clip_plane_enable, .has_per_samp = (fd4_ctx->fsaturate || fd4_ctx->vsaturate || fd4_ctx->fastc_srgb || fd4_ctx->vastc_srgb), @@ -193,220 +192,9 @@ fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) return true; } -/* clear operations ignore viewport state, so we need to reset it - * based on framebuffer state: - */ -static void -reset_viewport(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb) -{ - float half_width = pfb->width * 0.5f; - float half_height = pfb->height * 0.5f; - - OUT_PKT0(ring, REG_A4XX_GRAS_CL_VPORT_XOFFSET_0, 4); - OUT_RING(ring, A4XX_GRAS_CL_VPORT_XOFFSET_0(half_width)); - OUT_RING(ring, A4XX_GRAS_CL_VPORT_XSCALE_0(half_width)); - OUT_RING(ring, A4XX_GRAS_CL_VPORT_YOFFSET_0(half_height)); - OUT_RING(ring, A4XX_GRAS_CL_VPORT_YSCALE_0(-half_height)); -} - -/* TODO maybe we should just migrate u_blitter for clear and do it in - * core (so we get normal draw pass state mgmt and binning).. That should - * work well enough for a3xx/a4xx (but maybe not a2xx?) - */ - -static void -fd4_clear_binning(struct fd_context *ctx, unsigned dirty) -{ - struct fd_ringbuffer *ring = ctx->batch->binning; - struct fd4_emit emit = { - .debug = &ctx->debug, - .vtx = &ctx->solid_vbuf_state, - .prog = &ctx->solid_prog, - .key = { - .binning_pass = true, - .half_precision = true, - }, - .dirty = dirty, - }; - - fd4_emit_state(ctx, ring, &emit); - fd4_emit_vertex_bufs(ring, &emit); - reset_viewport(ring, &ctx->batch->framebuffer); - - OUT_PKT0(ring, REG_A4XX_PC_PRIM_VTX_CNTL, 2); - OUT_RING(ring, A4XX_PC_PRIM_VTX_CNTL_VAROUT(0) | - A4XX_PC_PRIM_VTX_CNTL_PROVOKING_VTX_LAST); - OUT_RING(ring, A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE(PC_DRAW_TRIANGLES) | - A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE(PC_DRAW_TRIANGLES)); - - OUT_PKT0(ring, REG_A4XX_GRAS_ALPHA_CONTROL, 1); - OUT_RING(ring, 0x0002); - - fd4_draw(ctx->batch, ring, DI_PT_RECTLIST, IGNORE_VISIBILITY, - DI_SRC_SEL_AUTO_INDEX, 2, 1, INDEX_SIZE_IGN, 0, 0, NULL); -} - -s
Mesa (master): freedreno/a3xx: use generic clear path
Module: Mesa Branch: master Commit: f77e59e76c43625921da754239af806df58541e8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f77e59e76c43625921da754239af806df58541e8 Author: Rob Clark Date: Thu Aug 11 11:59:51 2016 -0400 freedreno/a3xx: use generic clear path Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_context.c | 3 +- src/gallium/drivers/freedreno/a3xx/fd3_draw.c| 201 +-- 2 files changed, 4 insertions(+), 200 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.c b/src/gallium/drivers/freedreno/a3xx/fd3_context.c index af5e60a..dac5941 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_context.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.c @@ -54,7 +54,7 @@ fd3_context_destroy(struct pipe_context *pctx) fd_context_destroy(pctx); } -static const uint8_t primtypes[PIPE_PRIM_MAX] = { +static const uint8_t primtypes[] = { [PIPE_PRIM_POINTS] = DI_PT_POINTLIST, [PIPE_PRIM_LINES] = DI_PT_LINELIST, [PIPE_PRIM_LINE_STRIP] = DI_PT_LINESTRIP, @@ -62,6 +62,7 @@ static const uint8_t primtypes[PIPE_PRIM_MAX] = { [PIPE_PRIM_TRIANGLES] = DI_PT_TRILIST, [PIPE_PRIM_TRIANGLE_STRIP] = DI_PT_TRISTRIP, [PIPE_PRIM_TRIANGLE_FAN] = DI_PT_TRIFAN, + [PIPE_PRIM_MAX]= DI_PT_RECTLIST, /* internal clear blits */ }; struct pipe_context * diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c index 9e6a8bc..a1594b6 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c @@ -141,9 +141,8 @@ fd3_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) .color_two_side = ctx->rasterizer->light_twoside, .vclamp_color = ctx->rasterizer->clamp_vertex_color, .fclamp_color = ctx->rasterizer->clamp_fragment_color, - // TODO set .half_precision based on render target format, - // ie. float16 and smaller use half, float32 use full.. - .half_precision = !!(fd_mesa_debug & FD_DBG_FRAGHALF), + .half_precision = ctx->in_blit && + fd_half_precision(&ctx->batch->framebuffer), .has_per_samp = (fd3_ctx->fsaturate || fd3_ctx->vsaturate), .vsaturate_s = fd3_ctx->vsaturate_s, .vsaturate_t = fd3_ctx->vsaturate_t, @@ -180,205 +179,9 @@ fd3_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info) return true; } -/* clear operations ignore viewport state, so we need to reset it - * based on framebuffer state: - */ -static void -reset_viewport(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb) -{ - float half_width = pfb->width * 0.5f; - float half_height = pfb->height * 0.5f; - - OUT_PKT0(ring, REG_A3XX_GRAS_CL_VPORT_XOFFSET, 4); - OUT_RING(ring, A3XX_GRAS_CL_VPORT_XOFFSET(half_width - 0.5)); - OUT_RING(ring, A3XX_GRAS_CL_VPORT_XSCALE(half_width)); - OUT_RING(ring, A3XX_GRAS_CL_VPORT_YOFFSET(half_height - 0.5)); - OUT_RING(ring, A3XX_GRAS_CL_VPORT_YSCALE(-half_height)); -} - -/* binning pass cmds for a clear: - * NOTE: newer blob drivers don't use binning for clear, which is probably - * preferable since it is low vtx count. However that doesn't seem to - * actually work for me. Not sure if it is depending on support for - * clear pass (rather than using solid-fill shader), or something else - * that newer blob is doing differently. Once that is figured out, we - * can remove fd3_clear_binning(). - */ -static void -fd3_clear_binning(struct fd_context *ctx, unsigned dirty) -{ - struct fd_ringbuffer *ring = ctx->batch->binning; - struct fd3_emit emit = { - .debug = &ctx->debug, - .vtx = &ctx->solid_vbuf_state, - .prog = &ctx->solid_prog, - .key = { - .binning_pass = true, - .half_precision = true, - }, - .dirty = dirty, - }; - - fd3_emit_state(ctx, ring, &emit); - fd3_emit_vertex_bufs(ring, &emit); - reset_viewport(ring, &ctx->batch->framebuffer); - - OUT_PKT0(ring, REG_A3XX_PC_PRIM_VTX_CNTL, 1); - OUT_RING(ring, A3XX_PC_PRIM_VTX_CNTL_STRIDE_IN_VPC(0) | - A3XX_PC_PRIM_VTX_CNTL_POLYMODE_FRONT_PTYPE(PC_DRAW_TRIANGLES) | - A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE(PC_DRAW_TRIANGLES) | - A3XX_PC_PRIM_VTX_CNTL_PROVOKING_VTX_LAST); - OUT_PKT0(ring, REG_A3XX_VFD_INDEX_MIN,
Mesa (master): gallium/u_blitter: export some functions
Module: Mesa Branch: master Commit: 433e12fea86eee7b88a166637d54b1e87bab0081 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=433e12fea86eee7b88a166637d54b1e87bab0081 Author: Rob Clark Date: Sat Aug 13 10:35:23 2016 -0400 gallium/u_blitter: export some functions Signed-off-by: Rob Clark Reviewed-by: Marek Olšák --- src/gallium/auxiliary/util/u_blitter.c | 145 + src/gallium/auxiliary/util/u_blitter.h | 9 ++ 2 files changed, 84 insertions(+), 70 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index d06b3a8..8e5ed45 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -510,26 +510,26 @@ void util_blitter_set_texture_multisample(struct blitter_context *blitter, ctx->has_texture_multisample = supported; } -static void blitter_set_running_flag(struct blitter_context_priv *ctx) +void util_blitter_set_running_flag(struct blitter_context *blitter) { - if (ctx->base.running) { + if (blitter->running) { _debug_printf("u_blitter:%i: Caught recursion. This is a driver bug.\n", __LINE__); } - ctx->base.running = TRUE; + blitter->running = TRUE; - ctx->base.pipe->set_active_query_state(ctx->base.pipe, false); + blitter->pipe->set_active_query_state(blitter->pipe, false); } -static void blitter_unset_running_flag(struct blitter_context_priv *ctx) +void util_blitter_unset_running_flag(struct blitter_context *blitter) { - if (!ctx->base.running) { + if (!blitter->running) { _debug_printf("u_blitter:%i: Caught recursion. This is a driver bug.\n", __LINE__); } - ctx->base.running = FALSE; + blitter->running = FALSE; - ctx->base.pipe->set_active_query_state(ctx->base.pipe, true); + blitter->pipe->set_active_query_state(blitter->pipe, true); } static void blitter_check_saved_vertex_states(struct blitter_context_priv *ctx) @@ -543,8 +543,9 @@ static void blitter_check_saved_vertex_states(struct blitter_context_priv *ctx) assert(ctx->base.saved_rs_state != INVALID_PTR); } -static void blitter_restore_vertex_states(struct blitter_context_priv *ctx) +void util_blitter_restore_vertex_states(struct blitter_context *blitter) { + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; unsigned i; @@ -601,8 +602,9 @@ static void blitter_check_saved_fragment_states(struct blitter_context_priv *ctx assert(ctx->base.saved_blend_state != INVALID_PTR); } -static void blitter_restore_fragment_states(struct blitter_context_priv *ctx) +void util_blitter_restore_fragment_states(struct blitter_context *blitter) { + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; /* Fragment shader. */ @@ -644,8 +646,9 @@ static void blitter_disable_render_cond(struct blitter_context_priv *ctx) } } -static void blitter_restore_render_cond(struct blitter_context_priv *ctx) +void util_blitter_restore_render_cond(struct blitter_context *blitter) { + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; if (ctx->base.saved_render_cond_query) { @@ -656,8 +659,9 @@ static void blitter_restore_render_cond(struct blitter_context_priv *ctx) } } -static void blitter_restore_fb_state(struct blitter_context_priv *ctx) +void util_blitter_restore_fb_state(struct blitter_context *blitter) { + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state); @@ -670,8 +674,9 @@ static void blitter_check_saved_textures(struct blitter_context_priv *ctx) assert(ctx->base.saved_num_sampler_views != ~0u); } -static void blitter_restore_textures(struct blitter_context_priv *ctx) +void util_blitter_restore_textures(struct blitter_context *blitter) { + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; unsigned i; @@ -1267,7 +1272,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, assert(ctx->has_layered || num_layers <= 1); - blitter_set_running_flag(ctx); + util_blitter_set_running_flag(blitter); blitter_check_saved_vertex_states(ctx); blitter_check_saved_fragment_states(ctx); blitter_disable_render_cond(ctx); @@ -1311,10 +1316,10 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, UTIL_BLITTER_ATTRIB_COLOR, color); } - blitter_restore_vertex_states(ctx); - blitter_restore_fragment_states(c
Mesa (master): gallium/u_blitter: add helper to save FS const buffer state
Module: Mesa Branch: master Commit: 2b2f436c696c4da9e1a45fb03406876340ae31ed URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b2f436c696c4da9e1a45fb03406876340ae31ed Author: Rob Clark Date: Sat Aug 13 10:36:00 2016 -0400 gallium/u_blitter: add helper to save FS const buffer state Not (currently) state that is overwridden by u_blitter itself, but drivers with custom blit/clear which are reusing part of the u_blitter infrastructure will use it. Signed-off-by: Rob Clark Reviewed-by: Marek Olšák --- src/gallium/auxiliary/util/u_blitter.c | 10 ++ src/gallium/auxiliary/util/u_blitter.h | 15 +++ 2 files changed, 25 insertions(+) diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 8e5ed45..9fbef9b 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -283,6 +283,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) ctx->rs_discard_state = pipe->create_rasterizer_state(pipe, &rs_state); } + ctx->base.cb_slot = 0; /* 0 for now */ ctx->base.vb_slot = 0; /* 0 for now */ /* vertex elements states */ @@ -698,6 +699,15 @@ void util_blitter_restore_textures(struct blitter_context *blitter) ctx->base.saved_num_sampler_views = ~0; } +void util_blitter_restore_constant_buffer_state(struct blitter_context *blitter) +{ + struct pipe_context *pipe = blitter->pipe; + + pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, blitter->cb_slot, +&blitter->saved_fs_constant_buffer); + pipe_resource_reference(&blitter->saved_fs_constant_buffer.buffer, NULL); +} + static void blitter_set_rectangle(struct blitter_context_priv *ctx, int x1, int y1, int x2, int y2, float depth) diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 06e21e6..0f5da6b 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -111,6 +111,9 @@ struct blitter_context unsigned saved_num_sampler_views; struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS]; + unsigned cb_slot; + struct pipe_constant_buffer saved_fs_constant_buffer; + unsigned vb_slot; struct pipe_vertex_buffer saved_vertex_buffer; @@ -486,6 +489,17 @@ util_blitter_save_fragment_sampler_views(struct blitter_context *blitter, } static inline void +util_blitter_save_fragment_constant_buffer_slot( + struct blitter_context *blitter, + struct pipe_constant_buffer *constant_buffers) +{ + pipe_resource_reference(&blitter->saved_fs_constant_buffer.buffer, + constant_buffers[blitter->cb_slot].buffer); + memcpy(&blitter->saved_fs_constant_buffer, &constant_buffers[blitter->cb_slot], + sizeof(struct pipe_constant_buffer)); +} + +static inline void util_blitter_save_vertex_buffer_slot(struct blitter_context *blitter, struct pipe_vertex_buffer *vertex_buffers) { @@ -536,6 +550,7 @@ void util_blitter_restore_fragment_states(struct blitter_context *blitter); void util_blitter_restore_render_cond(struct blitter_context *blitter); void util_blitter_restore_fb_state(struct blitter_context *blitter); void util_blitter_restore_textures(struct blitter_context *blitter); +void util_blitter_restore_constant_buffer_state(struct blitter_context *blitter); #ifdef __cplusplus } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a3xx+a4xx: move common VBOs to fd_context
Module: Mesa Branch: master Commit: 561fd226d421b8d6505b80bcb6c3d90fd3c9a007 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=561fd226d421b8d6505b80bcb6c3d90fd3c9a007 Author: Rob Clark Date: Sat Aug 13 11:39:25 2016 -0400 freedreno/a3xx+a4xx: move common VBOs to fd_context These are the same for a3xx and later. (a2xx could probably use them too, but due to limited hw support and ancient downstream kernels, it isn't so easy to test.) Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_context.c | 64 +-- src/gallium/drivers/freedreno/a3xx/fd3_context.h | 20 -- src/gallium/drivers/freedreno/a3xx/fd3_draw.c | 6 +- src/gallium/drivers/freedreno/a3xx/fd3_gmem.c | 13 ++-- src/gallium/drivers/freedreno/a4xx/fd4_context.c | 64 +-- src/gallium/drivers/freedreno/a4xx/fd4_context.h | 20 -- src/gallium/drivers/freedreno/a4xx/fd4_draw.c | 6 +- src/gallium/drivers/freedreno/a4xx/fd4_gmem.c | 8 +-- src/gallium/drivers/freedreno/freedreno_context.c | 76 +++ src/gallium/drivers/freedreno/freedreno_context.h | 24 +++ 10 files changed, 116 insertions(+), 185 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.c b/src/gallium/drivers/freedreno/a3xx/fd3_context.c index 2ffc2e0..af5e60a 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_context.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.c @@ -47,44 +47,13 @@ fd3_context_destroy(struct pipe_context *pctx) fd_bo_del(fd3_ctx->fs_pvt_mem); fd_bo_del(fd3_ctx->vsc_size_mem); - pctx->delete_vertex_elements_state(pctx, fd3_ctx->solid_vbuf_state.vtx); - pctx->delete_vertex_elements_state(pctx, fd3_ctx->blit_vbuf_state.vtx); - - pipe_resource_reference(&fd3_ctx->solid_vbuf, NULL); - pipe_resource_reference(&fd3_ctx->blit_texcoord_vbuf, NULL); + fd_context_cleanup_common_vbos(&fd3_ctx->base); u_upload_destroy(fd3_ctx->border_color_uploader); fd_context_destroy(pctx); } -/* TODO we could combine a few of these small buffers (solid_vbuf, - * blit_texcoord_vbuf, and vsc_size_mem, into a single buffer and - * save a tiny bit of memory - */ - -static struct pipe_resource * -create_solid_vertexbuf(struct pipe_context *pctx) -{ - static const float init_shader_const[] = { - -1.00, +1.00, +1.00, - +1.00, -1.00, +1.00, - }; - struct pipe_resource *prsc = pipe_buffer_create(pctx->screen, - PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, sizeof(init_shader_const)); - pipe_buffer_write(pctx, prsc, 0, - sizeof(init_shader_const), init_shader_const); - return prsc; -} - -static struct pipe_resource * -create_blit_texcoord_vertexbuf(struct pipe_context *pctx) -{ - struct pipe_resource *prsc = pipe_buffer_create(pctx->screen, - PIPE_BIND_CUSTOM, PIPE_USAGE_DYNAMIC, 16); - return prsc; -} - static const uint8_t primtypes[PIPE_PRIM_MAX] = { [PIPE_PRIM_POINTS] = DI_PT_POINTLIST, [PIPE_PRIM_LINES] = DI_PT_LINELIST, @@ -134,36 +103,7 @@ fd3_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) fd3_ctx->vsc_size_mem = fd_bo_new(screen->dev, 0x1000, DRM_FREEDRENO_GEM_TYPE_KMEM); - fd3_ctx->solid_vbuf = create_solid_vertexbuf(pctx); - fd3_ctx->blit_texcoord_vbuf = create_blit_texcoord_vertexbuf(pctx); - - /* setup solid_vbuf_state: */ - fd3_ctx->solid_vbuf_state.vtx = pctx->create_vertex_elements_state( - pctx, 1, (struct pipe_vertex_element[]){{ - .vertex_buffer_index = 0, - .src_offset = 0, - .src_format = PIPE_FORMAT_R32G32B32_FLOAT, - }}); - fd3_ctx->solid_vbuf_state.vertexbuf.count = 1; - fd3_ctx->solid_vbuf_state.vertexbuf.vb[0].stride = 12; - fd3_ctx->solid_vbuf_state.vertexbuf.vb[0].buffer = fd3_ctx->solid_vbuf; - - /* setup blit_vbuf_state: */ - fd3_ctx->blit_vbuf_state.vtx = pctx->create_vertex_elements_state( - pctx, 2, (struct pipe_vertex_element[]){{ - .vertex_buffer_index = 0, - .src_offset = 0, - .src_format = PIPE_FORMAT_R32G32_FLOAT, - }, { - .vertex_buffer_index = 1, - .src_offset = 0, - .src_format = PIPE_FORMAT_R32G32B32_FLOAT, - }}); - fd3_ctx->blit_vbuf_state.vertexbuf.count = 2; - fd3_ctx->blit_vbuf_state.vertexbuf.vb[0].stride = 8; -
Mesa (master): freedreno/ir3: fix issue with emit_tex()
Module: Mesa Branch: master Commit: 78ba262d004989c43b0a9e76c84b71bb16d4b333 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=78ba262d004989c43b0a9e76c84b71bb16d4b333 Author: Rob Clark Date: Thu Aug 11 13:27:37 2016 -0400 freedreno/ir3: fix issue with emit_tex() For various tex fetch instructions, coord's get fixed up in different ways. But modifying the array returned from get_src() has side-effects if the same SSA src is used again.. the later instruction will see the previous fixups. Fix this, and const'ify things to prevent this sort of mistake in the future. Noticed by Varad when adding support for txf_ms. Signed-off-by: Rob Clark --- .../drivers/freedreno/ir3/ir3_compiler_nir.c | 47 +- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index 14d5e50..2331901 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -282,7 +282,7 @@ get_dst_ssa(struct ir3_compile *ctx, nir_ssa_def *dst, unsigned n) return __get_dst(ctx, dst, n); } -static struct ir3_instruction ** +static struct ir3_instruction * const * get_src(struct ir3_compile *ctx, nir_src *src) { struct hash_entry *entry; @@ -1105,7 +1105,8 @@ emit_intrinsic_store_var(struct ir3_compile *ctx, nir_intrinsic_instr *intr) nir_deref_var *dvar = intr->variables[0]; nir_deref_array *darr = nir_deref_as_array(dvar->deref.child); struct ir3_array *arr = get_var(ctx, dvar->var); - struct ir3_instruction *addr, **src; + struct ir3_instruction *addr; + struct ir3_instruction * const *src; unsigned wrmask = nir_intrinsic_write_mask(intr); compile_assert(ctx, dvar->deref.child && @@ -1157,7 +1158,8 @@ static void emit_intrinsic(struct ir3_compile *ctx, nir_intrinsic_instr *intr) { const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic]; - struct ir3_instruction **dst, **src; + struct ir3_instruction **dst; + struct ir3_instruction * const *src; struct ir3_block *b = ctx->block; nir_const_value *const_offset; int idx; @@ -1385,7 +1387,8 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex) { struct ir3_block *b = ctx->block; struct ir3_instruction **dst, *sam, *src0[12], *src1[4]; - struct ir3_instruction **coord, *lod, *compare, *proj, **off, **ddx, **ddy; + struct ir3_instruction * const *coord, * const *off, * const *ddx, * const *ddy; + struct ir3_instruction *lod, *compare, *proj; bool has_bias = false, has_lod = false, has_proj = false, has_off = false; unsigned i, coords, flags; unsigned nsrc0 = 0, nsrc1 = 0; @@ -1455,17 +1458,6 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex) tex_info(tex, &flags, &coords); - /* scale up integer coords for TXF based on the LOD */ - if (ctx->unminify_coords && (opc == OPC_ISAML)) { - assert(has_lod); - for (i = 0; i < coords; i++) - coord[i] = ir3_SHL_B(b, coord[i], 0, lod, 0); - } - - /* the array coord for cube arrays needs 0.5 added to it */ - if (ctx->array_index_add_half && tex->is_array && (opc != OPC_ISAML)) - coord[coords] = ir3_ADD_F(b, coord[coords], 0, create_immed(b, fui(0.5)), 0); - /* * lay out the first argument in the proper order: * - actual coordinates first @@ -1479,7 +1471,16 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex) /* insert tex coords: */ for (i = 0; i < coords; i++) - src0[nsrc0++] = coord[i]; + src0[i] = coord[i]; + + nsrc0 = i; + + /* scale up integer coords for TXF based on the LOD */ + if (ctx->unminify_coords && (opc == OPC_ISAML)) { + assert(has_lod); + for (i = 0; i < coords; i++) + src0[i] = ir3_SHL_B(b, src0[i], 0, lod, 0); + } if (coords == 1) { /* hw doesn't do 1d, so we treat it as 2d with @@ -1492,8 +1493,15 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex) if (tex->is_shadow && tex->op != nir_texop_lod) src0[nsrc0++] = compare; - if (tex->is_array && tex->op != nir_texop_lod) - src0[nsrc0++] = coord[coords]; + if (tex->is_array && tex->op != nir_texop_lod) { + struct ir3_instruction *idx = coord[coords]; + + /* the array coord for cube arrays needs 0.5 added to it */ + if (ctx->array_index_add_half && (opc != OPC_ISAML)) + idx = ir3_ADD_F(b, idx, 0, c
Mesa (master): freedreno/a2xx: add missing casts to silence notices
Module: Mesa Branch: master Commit: a49fb4ab2d5b062a418e930dc46cb2c79380852e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a49fb4ab2d5b062a418e930dc46cb2c79380852e Author: franci...@gmail.com Date: Tue Aug 9 19:38:32 2016 +0200 freedreno/a2xx: add missing casts to silence notices Signed-off-by: Francesco Ansanelli Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a2xx/ir-a2xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/ir-a2xx.c b/src/gallium/drivers/freedreno/a2xx/ir-a2xx.c index 2b62b3a..163c282 100644 --- a/src/gallium/drivers/freedreno/a2xx/ir-a2xx.c +++ b/src/gallium/drivers/freedreno/a2xx/ir-a2xx.c @@ -403,7 +403,7 @@ static int instr_emit_alu(struct ir2_instruction *instr, uint32_t *dwords, assert((src2_reg->flags & IR2_REG_EXPORT) == 0); assert(!src2_reg->swizzle || (strlen(src2_reg->swizzle) == 4)); - if (instr->alu.vector_opc == ~0) { + if (instr->alu.vector_opc == (instr_vector_opc_t)~0) { alu->vector_opc = MAXv; alu->vector_write_mask = 0; } else { @@ -431,7 +431,7 @@ static int instr_emit_alu(struct ir2_instruction *instr, uint32_t *dwords, alu->vector_clamp= instr->alu.vector_clamp; alu->scalar_clamp= instr->alu.scalar_clamp; - if (instr->alu.scalar_opc != ~0) { + if (instr->alu.scalar_opc != (instr_scalar_opc_t)~0) { struct ir2_register *sdst_reg = instr->regs[reg++]; reg_update_stats(sdst_reg, info, true); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): u_vbuf: fix potentially bogus assert
Module: Mesa Branch: master Commit: 53b2b8bf6f12547a0dde25cfb8e6926ac144f5d8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=53b2b8bf6f12547a0dde25cfb8e6926ac144f5d8 Author: Rob Clark Date: Sat Jul 30 11:22:52 2016 -0400 u_vbuf: fix potentially bogus assert There are cases where we hit u_vbuf path due to alignment or pitch- alignment restrictions, but for an output-format that u_vbuf does not support translating (yet the driver does support natively). In which case we hit the memcpy() path and don't care that u_vbuf doesn't understand it. Fixes crash with debug build of mesa in: dEQP-GLES3.functional.vertex_arrays.single_attribute.strides.fixed.user_ptr_stride17_components2_quads1 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95000 Signed-off-by: Rob Clark Reviewed-by: Marek Olšák --- src/gallium/auxiliary/util/u_vbuf.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 5b4e527..532e7c0 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -627,6 +627,7 @@ u_vbuf_translate_begin(struct u_vbuf *mgr, for (i = 0; i < mgr->ve->count; i++) { struct translate_key *k; struct translate_element *te; + enum pipe_format output_format = mgr->ve->native_format[i]; unsigned bit, vb_index = mgr->ve->ve[i].vertex_buffer_index; bit = 1 << vb_index; @@ -644,7 +645,8 @@ u_vbuf_translate_begin(struct u_vbuf *mgr, } } assert(type < VB_NUM); - assert(translate_is_output_format_supported(mgr->ve->native_format[i])); + if (mgr->ve->ve[i].src_format != output_format) + assert(translate_is_output_format_supported(output_format)); /*printf("velem=%i type=%i\n", i, type);*/ /* Add the vertex element. */ @@ -657,7 +659,7 @@ u_vbuf_translate_begin(struct u_vbuf *mgr, te->input_buffer = vb_index; te->input_format = mgr->ve->ve[i].src_format; te->input_offset = mgr->ve->ve[i].src_offset; - te->output_format = mgr->ve->native_format[i]; + te->output_format = output_format; te->output_offset = k->output_stride; k->output_stride += mgr->ve->native_format_size[i]; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): 26 new commits
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e713a9e61311249dfd6f76f3ab73da951b81239d Author: franci...@gmail.com Date: Sat Jul 30 09:49:59 2016 +0200 freedreno/a4xx: fix comparison out of range warnings Signed-off-by: Francesco Ansanelli Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=43492c7f2c56b618903b0f802071a6462ea8a435 Author: franci...@gmail.com Date: Sat Jul 30 09:49:58 2016 +0200 freedreno/a3xx: fix comparison out of range warnings Signed-off-by: Francesco Ansanelli Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=089cc74b6a402432fc268ddd29eb4639f4b170c4 Author: franci...@gmail.com Date: Sat Jul 30 09:49:57 2016 +0200 freedreno/a2xx: fix comparison out of range warnings Signed-off-by: Francesco Ansanelli Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3fa68fdc90656048a8e51103f59502a3c6ab1a29 Author: franci...@gmail.com Date: Sat Jul 30 08:20:58 2016 +0200 freedreno/ir3: init ir3_shader_key with memset() To silence missing initializers warning Signed-off-by: Francesco Ansanelli Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a63bac9271cf4984b4b8c0158e99fffa7f78c8bb Author: Eric Engestrom Date: Sat Jul 30 01:33:56 2016 +0100 gallium/freedreno: move cast to avoid integer overflow Previously, the bitshift would be performed on a simple int (32 bits on most systems), overflow, and then be cast to 64 bits. CovID: 1362461 Signed-off-by: Eric Engestrom Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3563c4d16138360fd8756576e0c9c825ed6cec86 Author: Eric Engestrom Date: Sat Jul 30 01:23:09 2016 +0100 freedreno/a2xx: remove duplicate assignment CovID: 1362445, 1362446 Signed-off-by: Eric Engestrom Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d64a003c5059feebcb70b607311d380acc45962 Author: Rob Clark Date: Fri Jul 22 17:55:59 2016 -0400 freedreno: defer flush_queue allocation Some apps, like warsow, create a bazillion contexts but don't render on most of them. Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4175606474acda62775c41fa95a577e0796ff17f Author: Rob Clark Date: Wed Jul 20 14:50:14 2016 -0400 freedreno: add some hw query traces Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e684c32d2fdda204b79661ecf26881eae133d64a Author: Rob Clark Date: Tue Jul 19 18:24:57 2016 -0400 freedreno: some locking Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=010e4b2d52d5b5ab1eb866dfa0a2df5b984c343d Author: Rob Clark Date: Thu Jul 21 13:51:36 2016 -0400 os: add pipe_mutex_assert_locked() Would be nice if we could also have lockdep, like in the linux kernel. But this is better than nothing. Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f0eb6952790bffe2670f26d399f15acec199cac Author: Rob Clark Date: Tue Jul 19 13:22:01 2016 -0400 freedreno: drop needs_rb_fbd We need to emit RB_FRAME_BUFFER_DIMENSION once per batch.. tracking this in fd_context is wrong when the gmem code executes asynchronously from the flush_queue worker. But in fact we don't really need to track it at all. We cannot assume previous value at the beginning of the batch (because of other processes potentially using the GPU), so just drop the tracking and emit it in _tile_init(). Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6bfe1c7734cfbf41a763797527db6cb49fa1566 Author: Rob Clark Date: Tue Jul 19 12:08:42 2016 -0400 freedreno: move needs_wfi into batch This is also used in gmem code, which executes from the "bottom half" (ie. from the flush_queue worker thread), so it cannot be in fd_context. Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0739bbceecbb66ffbcf14e5b73e6df222794c264 Author: Rob Clark Date: Thu Jul 14 16:44:34 2016 -0400 freedreno: a bit of micro-optimization Signed-off-by: Rob Clark URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e1b10527006a03f1bd845f222f353496502c8d16 Author: Rob Clark Date: Thu Jul 14 13:27:32 2016 -0400 freedreno: drop mem2gmem/gmem2mem query stages They weren't really used, and it gets somewhat more complicated to deal with if batches are flushed asynchronously (on another thread). So just drop them, and move _query_set_state(NULL) call into batch (so it is not happening on background thread). Signed-off-by: Rob Clark URL: http://cgit.
Mesa (master): freedreno: limit non-user constant buffers to a4xx
Module: Mesa Branch: master Commit: 591eeb7d1c98d85142453d6ba2b8128c9a5a554e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=591eeb7d1c98d85142453d6ba2b8128c9a5a554e Author: Rob Clark Date: Fri Jul 29 14:58:39 2016 -0400 freedreno: limit non-user constant buffers to a4xx Seems to mostly work on a3xx. Except when it doesn't and kills gpu quite badly. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 568e6e2..222f288 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -172,7 +172,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return 1; case PIPE_CAP_USER_CONSTANT_BUFFERS: - return is_ir3(screen) ? 0 : 1; + return is_a4xx(screen) ? 0 : 1; case PIPE_CAP_SHADER_STENCIL_EXPORT: case PIPE_CAP_TGSI_TEXCOORD: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: fix uninitialized instance variable
Module: Mesa Branch: master Commit: 427771d1c71bfc43553d5e4b8a0683951b0b8d7a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=427771d1c71bfc43553d5e4b8a0683951b0b8d7a Author: Jan Ziak <0xe2.0x9a.0...@gmail.com> Date: Fri Jul 29 13:56:00 2016 +0200 glsl: fix uninitialized instance variable Valgrind detected that variable ir_copy_propagation_visitor::killed_all is uninitialized. Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0...@gmail.com> Signed-off-by: Rob Clark --- src/compiler/glsl/opt_copy_propagation.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/glsl/opt_copy_propagation.cpp b/src/compiler/glsl/opt_copy_propagation.cpp index 807ba8f..443905d 100644 --- a/src/compiler/glsl/opt_copy_propagation.cpp +++ b/src/compiler/glsl/opt_copy_propagation.cpp @@ -76,6 +76,7 @@ public: mem_ctx = ralloc_context(0); this->acp = new(mem_ctx) exec_list; this->kills = new(mem_ctx) exec_list; + killed_all = false; } ~ir_copy_propagation_visitor() { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a4xx: time-elapsed query should be active for clears
Module: Mesa Branch: master Commit: 2f57e578812f277c87966279a728dd2a60b4e9be URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f57e578812f277c87966279a728dd2a60b4e9be Author: Rob Clark Date: Sun Jul 24 09:32:09 2016 -0400 freedreno/a4xx: time-elapsed query should be active for clears Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_query.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_query.c b/src/gallium/drivers/freedreno/a4xx/fd4_query.c index baa3787..41e3e65 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_query.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_query.c @@ -253,7 +253,7 @@ static const struct fd_hw_sample_provider occlusion_predicate = { static const struct fd_hw_sample_provider time_elapsed = { .query_type = PIPE_QUERY_TIME_ELAPSED, - .active = FD_STAGE_DRAW, + .active = FD_STAGE_DRAW | FD_STAGE_CLEAR, .enable = time_elapsed_enable, .get_sample = time_elapsed_get_sample, .accumulate_result = time_elapsed_accumulate_result, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: hw timestamp support
Module: Mesa Branch: master Commit: b888d8e9372b671074844a208fd9cd499ef53c69 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b888d8e9372b671074844a208fd9cd499ef53c69 Author: Rob Clark Date: Tue Feb 23 12:03:43 2016 -0500 freedreno: hw timestamp support If the kernel supports it, use hw counter for timestamps. Signed-off-by: Rob Clark --- configure.ac | 2 +- src/gallium/drivers/freedreno/freedreno_screen.c | 16 ++-- src/gallium/drivers/freedreno/freedreno_screen.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index bbc3af4..5c196a9 100644 --- a/configure.ac +++ b/configure.ac @@ -74,7 +74,7 @@ LIBDRM_AMDGPU_REQUIRED=2.4.63 LIBDRM_INTEL_REQUIRED=2.4.61 LIBDRM_NVVIEUX_REQUIRED=2.4.66 LIBDRM_NOUVEAU_REQUIRED=2.4.66 -LIBDRM_FREEDRENO_REQUIRED=2.4.67 +LIBDRM_FREEDRENO_REQUIRED=2.4.68 LIBDRM_VC4_REQUIRED=2.4.69 DRI2PROTO_REQUIRED=2.6 DRI3PROTO_REQUIRED=1.0 diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 81fb2ad..0aaa4d0 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -109,8 +109,18 @@ fd_screen_get_device_vendor(struct pipe_screen *pscreen) static uint64_t fd_screen_get_timestamp(struct pipe_screen *pscreen) { - int64_t cpu_time = os_time_get() * 1000; - return cpu_time + fd_screen(pscreen)->cpu_gpu_time_delta; + struct fd_screen *screen = fd_screen(pscreen); + + if (screen->has_timestamp) { + uint64_t n; + fd_pipe_get_param(screen->pipe, FD_TIMESTAMP, &n); + debug_assert(screen->max_freq > 0); + return n * 10 / screen->max_freq; + } else { + int64_t cpu_time = os_time_get() * 1000; + return cpu_time + screen->cpu_gpu_time_delta; + } + } static void @@ -595,6 +605,8 @@ fd_screen_create(struct fd_device *dev) screen->max_freq = 0; } else { screen->max_freq = val; + if (fd_pipe_get_param(screen->pipe, FD_TIMESTAMP, &val) == 0) + screen->has_timestamp = true; } if (fd_pipe_get_param(screen->pipe, FD_GPU_ID, &val)) { diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h b/src/gallium/drivers/freedreno/freedreno_screen.h index a81c778..0c899d5 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.h +++ b/src/gallium/drivers/freedreno/freedreno_screen.h @@ -58,6 +58,7 @@ struct fd_screen { uint32_t chip_id;/* coreid:8 majorrev:8 minorrev:8 patch:8 */ uint32_t max_freq; uint32_t max_rts;/* max # of render targets */ + bool has_timestamp; void *compiler; /* currently unused for a2xx */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a4xx: timestamp queries
Module: Mesa Branch: master Commit: 9253dcde585042242614c4b6677d8f2b13bd2237 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9253dcde585042242614c4b6677d8f2b13bd2237 Author: Rob Clark Date: Sun Feb 14 11:14:06 2016 -0500 freedreno/a4xx: timestamp queries Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_query.c | 28 ++ src/gallium/drivers/freedreno/freedreno_query_hw.c | 5 src/gallium/drivers/freedreno/freedreno_screen.c | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_query.c b/src/gallium/drivers/freedreno/a4xx/fd4_query.c index 69decbc..baa3787 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_query.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_query.c @@ -224,6 +224,19 @@ time_elapsed_accumulate_result(struct fd_context *ctx, result->u64 += n * 10 / ctx->screen->max_freq; } +static void +timestamp_accumulate_result(struct fd_context *ctx, + const void *start, const void *end, + union pipe_query_result *result) +{ + /* just return the value from fist tile: */ + if (result->u64 != 0) + return; + uint64_t n = *(uint64_t *)start; + /* max_freq is in Hz, convert cycle count to ns: */ + result->u64 = n * 10 / ctx->screen->max_freq; +} + static const struct fd_hw_sample_provider occlusion_counter = { .query_type = PIPE_QUERY_OCCLUSION_COUNTER, .active = FD_STAGE_DRAW, @@ -246,9 +259,24 @@ static const struct fd_hw_sample_provider time_elapsed = { .accumulate_result = time_elapsed_accumulate_result, }; +/* NOTE: timestamp query isn't going to give terribly sensible results + * on a tiler. But it is needed by qapitrace profile heatmap. If you + * add in a binning pass, the results get even more non-sensical. So + * we just return the timestamp on the first tile and hope that is + * kind of good enough. + */ +static const struct fd_hw_sample_provider timestamp = { + .query_type = PIPE_QUERY_TIMESTAMP, + .active = FD_STAGE_ALL, + .enable = time_elapsed_enable, + .get_sample = time_elapsed_get_sample, + .accumulate_result = timestamp_accumulate_result, +}; + void fd4_query_context_init(struct pipe_context *pctx) { fd_hw_query_register_provider(pctx, &occlusion_counter); fd_hw_query_register_provider(pctx, &occlusion_predicate); fd_hw_query_register_provider(pctx, &time_elapsed); + fd_hw_query_register_provider(pctx, ×tamp); } diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index 141dc8a..7b528f5 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -47,8 +47,13 @@ static int pidx(unsigned query_type) return 0; case PIPE_QUERY_OCCLUSION_PREDICATE: return 1; + /* TODO currently queries only emitted in main pass (not in binning pass).. +* which is fine for occlusion query, but pretty much not anything else. +*/ case PIPE_QUERY_TIME_ELAPSED: return 2; + case PIPE_QUERY_TIMESTAMP: + return 3; default: return -1; } diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 0aaa4d0..568e6e2 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -332,11 +332,11 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return is_a3xx(screen) ? 1 : 0; /* Queries. */ - case PIPE_CAP_QUERY_TIMESTAMP: case PIPE_CAP_QUERY_BUFFER_OBJECT: return 0; case PIPE_CAP_OCCLUSION_QUERY: return is_a3xx(screen) || is_a4xx(screen); + case PIPE_CAP_QUERY_TIMESTAMP: case PIPE_CAP_QUERY_TIME_ELAPSED: /* only a4xx, requires new enough kernel so we know max_freq: */ return (screen->max_freq > 0) && is_a4xx(screen); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: prep work for timestamp queries
Module: Mesa Branch: master Commit: 6a4b052820a4553c536b08176795e3685f4a16e4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6a4b052820a4553c536b08176795e3685f4a16e4 Author: Rob Clark Date: Tue Mar 1 10:45:32 2016 -0500 freedreno: prep work for timestamp queries We need "NULL" state to be a valid bit in the bitmask, because timestamp queries are not restricted to draw/etc stages (ie. the only commands to submit may just be to read the timestamp). And just because there are no draws, isn't a reason to skip the flush and return zero. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_context.c | 2 ++ src/gallium/drivers/freedreno/freedreno_context.h | 13 +++-- src/gallium/drivers/freedreno/freedreno_query_hw.c | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index 52557d1..65c3891 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -244,6 +244,8 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, */ ctx->sample_mask = 0x; + ctx->stage = FD_STAGE_NULL; + pctx = &ctx->base; pctx->screen = pscreen; pctx->priv = priv; diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index 438c2e2..53b4e1d 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -116,18 +116,19 @@ struct fd_vertex_state { * is active across IB's (or between tile IB and draw IB) */ enum fd_render_stage { - FD_STAGE_NULL = 0x00, - FD_STAGE_DRAW = 0x01, - FD_STAGE_CLEAR= 0x02, + FD_STAGE_NULL = 0x01, + FD_STAGE_DRAW = 0x02, + FD_STAGE_CLEAR= 0x04, /* TODO before queries which include MEM2GMEM or GMEM2MEM will * work we will need to call fd_hw_query_prepare() from somewhere * appropriate so that queries in the tiling IB get backed with * memory to write results to. */ - FD_STAGE_MEM2GMEM = 0x04, - FD_STAGE_GMEM2MEM = 0x08, + FD_STAGE_MEM2GMEM = 0x08, + FD_STAGE_GMEM2MEM = 0x10, /* used for driver internal draws (ie. util_blitter_blit()): */ - FD_STAGE_BLIT = 0x10, + FD_STAGE_BLIT = 0x20, + FD_STAGE_ALL = 0xff, }; #define MAX_HW_SAMPLE_PROVIDERS 4 diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index 95fff3f..141dc8a 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -66,6 +66,7 @@ get_sample(struct fd_context *ctx, struct fd_ringbuffer *ring, if (!ctx->sample_cache[idx]) { ctx->sample_cache[idx] = ctx->sample_providers[idx]->get_sample(ctx, ring); + ctx->needs_flush = true; } fd_hw_sample_reference(ctx, &samp, ctx->sample_cache[idx]); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a2xx: silence missing case 'SHADER_COMPUTE' warning (v2)
Module: Mesa Branch: master Commit: c99cdd21756161eb26b703af983370b905df2c6a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c99cdd21756161eb26b703af983370b905df2c6a Author: franci...@gmail.com Date: Fri Jul 22 08:28:46 2016 +0200 freedreno/a2xx: silence missing case 'SHADER_COMPUTE' warning (v2) v2: no need for break after an unreachable (Matt Turner) Signed-off-by: Francesco Ansanelli Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c b/src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c index f00d5d4..fc309e8 100644 --- a/src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c +++ b/src/gallium/drivers/freedreno/a2xx/disasm-a2xx.c @@ -111,6 +111,8 @@ static void print_export_comment(uint32_t num, enum shader_t type) case 0: name = "gl_FragColor"; break; } break; + case SHADER_COMPUTE: + unreachable("not reached"); } /* if we had a symbol table here, we could look * up the name of the varying.. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/ir3: Add missing braces in initializer
Module: Mesa Branch: master Commit: abb2a865a49b0a4c3d2c0a4a0024d72784393188 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=abb2a865a49b0a4c3d2c0a4a0024d72784393188 Author: franci...@gmail.com Date: Wed Jul 20 09:49:34 2016 +0200 freedreno/ir3: Add missing braces in initializer Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_shader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index 9f39f9f..5d57c0b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -309,7 +309,7 @@ ir3_shader_create(struct ir3_compiler *compiler, * (as otherwise nothing will trigger the shader to be * actually compiled) */ - static struct ir3_shader_key key = {0}; + static struct ir3_shader_key key = {{0}}; ir3_shader_variant(shader, key, debug); } return shader; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): gallium/u_queue: add optional cleanup callback
Module: Mesa Branch: master Commit: 44bbfedbd9983c61f6a461cbfe2e0dc74eda6d37 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=44bbfedbd9983c61f6a461cbfe2e0dc74eda6d37 Author: Rob Clark Date: Wed Jul 13 12:17:05 2016 -0400 gallium/u_queue: add optional cleanup callback Adds a second optional cleanup callback, called after the fence is signaled. This is needed if, for example, the queue has the last reference to the object that embeds the util_queue_fence. In this case we cannot drop the ref in the main callback, since that would result in the fence being destroyed before it is signaled. Signed-off-by: Rob Clark Reviewed-by: Marek Olšák Reviewed-by: Nicolai Hähnle --- src/gallium/auxiliary/util/u_queue.c| 6 +- src/gallium/auxiliary/util/u_queue.h| 6 +- src/gallium/drivers/radeonsi/si_state_shaders.c | 3 ++- src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 2 +- src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c index ac3afa1..838464f 100644 --- a/src/gallium/auxiliary/util/u_queue.c +++ b/src/gallium/auxiliary/util/u_queue.c @@ -91,6 +91,8 @@ static PIPE_THREAD_ROUTINE(util_queue_thread_func, input) if (job.job) { job.execute(job.job, thread_index); util_queue_fence_signal(job.fence); + if (job.cleanup) +job.cleanup(job.job, thread_index); } } @@ -213,7 +215,8 @@ void util_queue_add_job(struct util_queue *queue, void *job, struct util_queue_fence *fence, - util_queue_execute_func execute) + util_queue_execute_func execute, + util_queue_execute_func cleanup) { struct util_queue_job *ptr; @@ -232,6 +235,7 @@ util_queue_add_job(struct util_queue *queue, ptr->job = job; ptr->fence = fence; ptr->execute = execute; + ptr->cleanup = cleanup; queue->write_idx = (queue->write_idx + 1) % queue->max_jobs; queue->num_queued++; diff --git a/src/gallium/auxiliary/util/u_queue.h b/src/gallium/auxiliary/util/u_queue.h index f70d646..59646cc 100644 --- a/src/gallium/auxiliary/util/u_queue.h +++ b/src/gallium/auxiliary/util/u_queue.h @@ -50,6 +50,7 @@ struct util_queue_job { void *job; struct util_queue_fence *fence; util_queue_execute_func execute; + util_queue_execute_func cleanup; }; /* Put this into your context. */ @@ -75,10 +76,13 @@ void util_queue_destroy(struct util_queue *queue); void util_queue_fence_init(struct util_queue_fence *fence); void util_queue_fence_destroy(struct util_queue_fence *fence); +/* optional cleanup callback is called after fence is signaled: */ void util_queue_add_job(struct util_queue *queue, void *job, struct util_queue_fence *fence, -util_queue_execute_func execute); +util_queue_execute_func execute, +util_queue_execute_func cleanup); + void util_queue_job_wait(struct util_queue_fence *fence); /* util_queue needs to be cleared to zeroes for this to work */ diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index c24130d..a423296 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -1330,7 +1330,8 @@ static void *si_create_shader_selector(struct pipe_context *ctx, si_init_shader_selector_async(sel, -1); else util_queue_add_job(&sscreen->shader_compiler_queue, sel, - &sel->ready, si_init_shader_selector_async); + &sel->ready, si_init_shader_selector_async, + NULL); return sel; } diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c index 1a094fd..fb517b9 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c @@ -1058,7 +1058,7 @@ static int amdgpu_cs_flush(struct radeon_winsys_cs *rcs, if ((flags & RADEON_FLUSH_ASYNC) && util_queue_is_initialized(&ws->cs_queue)) { util_queue_add_job(&ws->cs_queue, cs, &cs->flush_completed, -amdgpu_cs_submit_ib); +amdgpu_cs_submit_ib, NULL); } else { amdgpu_cs_submit_ib(cs, 0); error_code = cs->cst->error_code; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index 767c263..15c3e5c 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -587,7
Mesa (master): mesa/st: reduce size of state->st bitmask
Module: Mesa Branch: master Commit: cc46fc3c0921c86baa0fbe25ba6a9c4858f04ab3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc46fc3c0921c86baa0fbe25ba6a9c4858f04ab3 Author: Rob Clark Date: Thu Jul 14 16:08:31 2016 -0400 mesa/st: reduce size of state->st bitmask In d035d50 this changed to 64b.. which I'm pretty sure was unintentional. Revert it back to 32b so the entire state struct is a nice round 64b. (Note sure that it would actually be measurable, but I did notice that check_state() was hot in some benchmarks.) Signed-off-by: Rob Clark Reviewed-by: Marek Olšák --- src/mesa/state_tracker/st_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index cc25e06..18394eb 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -70,7 +70,7 @@ struct u_upload_mgr; struct st_state_flags { GLbitfield mesa; /**< Mask of _NEW_x flags */ - uint64_t st; /**< Mask of ST_NEW_x flags */ + uint32_t st; /**< Mask of ST_NEW_x flags */ }; struct st_tracked_state { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a4xx: Fix sign compare warnings
Module: Mesa Branch: master Commit: 3db7f3458ffbec51329d66f3bed8a3d8eaf35a3d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3db7f3458ffbec51329d66f3bed8a3d8eaf35a3d Author: franci...@gmail.com Date: Thu Jun 30 19:16:08 2016 +0200 freedreno/a4xx: Fix sign compare warnings Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_screen.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_screen.c b/src/gallium/drivers/freedreno/a4xx/fd4_screen.c index c193f36..57fecf1 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_screen.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_screen.c @@ -52,14 +52,14 @@ fd4_screen_is_format_supported(struct pipe_screen *pscreen, } if ((usage & PIPE_BIND_VERTEX_BUFFER) && - (fd4_pipe2vtx(format) != ~0)) { + (fd4_pipe2vtx(format) != ~0u)) { retval |= PIPE_BIND_VERTEX_BUFFER; } if ((usage & PIPE_BIND_SAMPLER_VIEW) && (target == PIPE_BUFFER || util_format_get_blocksize(format) != 12) && - (fd4_pipe2tex(format) != ~0)) { + (fd4_pipe2tex(format) != ~0u)) { retval |= PIPE_BIND_SAMPLER_VIEW; } @@ -67,8 +67,8 @@ fd4_screen_is_format_supported(struct pipe_screen *pscreen, PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)) && - (fd4_pipe2color(format) != ~0) && - (fd4_pipe2tex(format) != ~0)) { + (fd4_pipe2color(format) != ~0u) && + (fd4_pipe2tex(format) != ~0u)) { retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | @@ -76,13 +76,13 @@ fd4_screen_is_format_supported(struct pipe_screen *pscreen, } if ((usage & PIPE_BIND_DEPTH_STENCIL) && - (fd4_pipe2depth(format) != ~0) && - (fd4_pipe2tex(format) != ~0)) { + (fd4_pipe2depth(format) != ~0u) && + (fd4_pipe2tex(format) != ~0u)) { retval |= PIPE_BIND_DEPTH_STENCIL; } if ((usage & PIPE_BIND_INDEX_BUFFER) && - (fd_pipe2index(format) != ~0)) { + (fd_pipe2index(format) != ~0u)) { retval |= PIPE_BIND_INDEX_BUFFER; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a3xx: Fix sign compare warnings
Module: Mesa Branch: master Commit: 948822018fa36ef286197e8223a721f16a7146ff URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=948822018fa36ef286197e8223a721f16a7146ff Author: franci...@gmail.com Date: Thu Jun 30 19:16:07 2016 +0200 freedreno/a3xx: Fix sign compare warnings Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_screen.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_screen.c b/src/gallium/drivers/freedreno/a3xx/fd3_screen.c index 4aea2fe..013b0ca 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_screen.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_screen.c @@ -52,12 +52,12 @@ fd3_screen_is_format_supported(struct pipe_screen *pscreen, } if ((usage & PIPE_BIND_VERTEX_BUFFER) && - (fd3_pipe2vtx(format) != ~0)) { + (fd3_pipe2vtx(format) != ~0u)) { retval |= PIPE_BIND_VERTEX_BUFFER; } if ((usage & PIPE_BIND_SAMPLER_VIEW) && - (fd3_pipe2tex(format) != ~0)) { + (fd3_pipe2tex(format) != ~0u)) { retval |= PIPE_BIND_SAMPLER_VIEW; } @@ -66,8 +66,8 @@ fd3_screen_is_format_supported(struct pipe_screen *pscreen, PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_BLENDABLE)) && - (fd3_pipe2color(format) != ~0) && - (fd3_pipe2tex(format) != ~0)) { + (fd3_pipe2color(format) != ~0u) && + (fd3_pipe2tex(format) != ~0u)) { retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | @@ -77,13 +77,13 @@ fd3_screen_is_format_supported(struct pipe_screen *pscreen, } if ((usage & PIPE_BIND_DEPTH_STENCIL) && - (fd_pipe2depth(format) != ~0) && - (fd3_pipe2tex(format) != ~0)) { + (fd_pipe2depth(format) != ~0u) && + (fd3_pipe2tex(format) != ~0u)) { retval |= PIPE_BIND_DEPTH_STENCIL; } if ((usage & PIPE_BIND_INDEX_BUFFER) && - (fd_pipe2index(format) != ~0)) { + (fd_pipe2index(format) != ~0u)) { retval |= PIPE_BIND_INDEX_BUFFER; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a2xx: Fix sign compare warnings
Module: Mesa Branch: master Commit: cf2f34535625d597cc90d04d7fa7237f61f6a634 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf2f34535625d597cc90d04d7fa7237f61f6a634 Author: franci...@gmail.com Date: Thu Jun 30 19:16:06 2016 +0200 freedreno/a2xx: Fix sign compare warnings Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a2xx/fd2_screen.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c index c2baa6f..fe4849b 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c @@ -61,7 +61,7 @@ fd2_screen_is_format_supported(struct pipe_screen *pscreen, if ((usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_VERTEX_BUFFER)) && - (fd2_pipe2surface(format) != ~0)) { + (fd2_pipe2surface(format) != ~0u)) { retval |= usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_VERTEX_BUFFER); } @@ -70,7 +70,7 @@ fd2_screen_is_format_supported(struct pipe_screen *pscreen, PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)) && - (fd2_pipe2color(format) != ~0)) { + (fd2_pipe2color(format) != ~0u)) { retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | @@ -78,12 +78,12 @@ fd2_screen_is_format_supported(struct pipe_screen *pscreen, } if ((usage & PIPE_BIND_DEPTH_STENCIL) && - (fd_pipe2depth(format) != ~0)) { + (fd_pipe2depth(format) != ~0u)) { retval |= PIPE_BIND_DEPTH_STENCIL; } if ((usage & PIPE_BIND_INDEX_BUFFER) && - (fd_pipe2index(format) != ~0)) { + (fd_pipe2index(format) != ~0u)) { retval |= PIPE_BIND_INDEX_BUFFER; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: fix crash on smaller gpus and higher resolutions
Module: Mesa Branch: master Commit: 7295428e4183cca1840e7ed02159519734fdab0a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7295428e4183cca1840e7ed02159519734fdab0a Author: Rob Clark Date: Sun Jul 3 11:16:28 2016 -0400 freedreno: fix crash on smaller gpus and higher resolutions Devices with smaller GMEM size need more tiles. On db410c at 2048x1152, glmark2 shadow needed ~330 tiles for fullscreen. Lets bump it up to 512. (Maybe with MRT you could end up needing more, but at that point things are probably going to be painfully slow.) Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index fe2a94c..438c2e2 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -316,7 +316,7 @@ struct fd_context { */ struct fd_gmem_stateobj gmem; struct fd_vsc_pipe pipe[8]; - struct fd_tile tile[256]; + struct fd_tile tile[512]; /* which state objects need to be re-emit'd: */ enum { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: pass index buffer as a pipe_resource
Module: Mesa Branch: master Commit: 2c3b54c27820edcf2d74e96faa812f8dd29f56df URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c3b54c27820edcf2d74e96faa812f8dd29f56df Author: Rob Clark Date: Fri May 20 13:41:44 2016 -0400 freedreno: pass index buffer as a pipe_resource This will be useful in a following patch. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_draw.h | 16 src/gallium/drivers/freedreno/freedreno_draw.h | 16 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_draw.h b/src/gallium/drivers/freedreno/a4xx/fd4_draw.h index c850c24..5f5f6cd 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_draw.h +++ b/src/gallium/drivers/freedreno/a4xx/fd4_draw.h @@ -54,7 +54,7 @@ fd4_draw(struct fd_context *ctx, struct fd_ringbuffer *ring, enum pc_di_src_sel src_sel, uint32_t count, uint32_t instances, enum a4xx_index_size idx_type, uint32_t idx_size, uint32_t idx_offset, - struct fd_bo *idx_bo) + struct pipe_resource *idx_buffer) { /* for debug after a lock up, write a unique counter value * to scratch7 for each draw, to make it easier to match up @@ -64,7 +64,7 @@ fd4_draw(struct fd_context *ctx, struct fd_ringbuffer *ring, */ emit_marker(ring, 7); - OUT_PKT3(ring, CP_DRAW_INDX_OFFSET, idx_bo ? 6 : 3); + OUT_PKT3(ring, CP_DRAW_INDX_OFFSET, idx_buffer ? 6 : 3); if (vismode == USE_VISIBILITY) { /* leave vis mode blank for now, it will be patched up when * we know if we are binning or not @@ -76,9 +76,9 @@ fd4_draw(struct fd_context *ctx, struct fd_ringbuffer *ring, } OUT_RING(ring, instances); /* NumInstances */ OUT_RING(ring, count); /* NumIndices */ - if (idx_bo) { + if (idx_buffer) { OUT_RING(ring, 0x0); /* XXX */ - OUT_RELOC(ring, idx_bo, idx_offset, 0, 0); + OUT_RELOC(ring, fd_resource(idx_buffer)->bo, idx_offset, 0, 0); OUT_RING (ring, idx_size); } @@ -107,7 +107,7 @@ fd4_draw_emit(struct fd_context *ctx, struct fd_ringbuffer *ring, const struct pipe_draw_info *info) { struct pipe_index_buffer *idx = &ctx->indexbuf; - struct fd_bo *idx_bo = NULL; + struct pipe_resource *idx_buffer = NULL; enum a4xx_index_size idx_type; enum pc_di_src_sel src_sel; uint32_t idx_size, idx_offset; @@ -115,13 +115,13 @@ fd4_draw_emit(struct fd_context *ctx, struct fd_ringbuffer *ring, if (info->indexed) { assert(!idx->user_buffer); - idx_bo = fd_resource(idx->buffer)->bo; + idx_buffer = idx->buffer; idx_type = fd4_size2indextype(idx->index_size); idx_size = idx->index_size * info->count; idx_offset = idx->offset + (info->start * idx->index_size); src_sel = DI_SRC_SEL_DMA; } else { - idx_bo = NULL; + idx_buffer = NULL; idx_type = INDEX4_SIZE_32_BIT; idx_size = 0; idx_offset = 0; @@ -130,7 +130,7 @@ fd4_draw_emit(struct fd_context *ctx, struct fd_ringbuffer *ring, fd4_draw(ctx, ring, primtype, vismode, src_sel, info->count, info->instance_count, - idx_type, idx_size, idx_offset, idx_bo); + idx_type, idx_size, idx_offset, idx_buffer); } #endif /* FD4_DRAW_H_ */ diff --git a/src/gallium/drivers/freedreno/freedreno_draw.h b/src/gallium/drivers/freedreno/freedreno_draw.h index 3224fb1..7a970a2 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.h +++ b/src/gallium/drivers/freedreno/freedreno_draw.h @@ -49,7 +49,7 @@ fd_draw(struct fd_context *ctx, struct fd_ringbuffer *ring, uint8_t instances, enum pc_di_index_size idx_type, uint32_t idx_size, uint32_t idx_offset, - struct fd_bo *idx_bo) + struct pipe_resource *idx_buffer) { /* for debug after a lock up, write a unique counter value * to scratch7 for each draw, to make it easier to match up @@ -74,7 +74,7 @@ fd_draw(struct fd_context *ctx, struct fd_ringbuffer *ring, OUT_RING(ring, 0); } - OUT_PKT3(ring, CP_DRAW_INDX, idx_bo ? 5 : 3); + OUT_PKT3(ring, CP_DRAW_INDX, idx_buffer ? 5 : 3); OUT_RING(ring, 0x);/* viz query info. */ if (vismode == USE_VISIBILITY) { /* leave vis mode blank for now, it will be patched up when @@ -86,8 +86,8 @@ fd_draw(struct fd_context *ctx, struct fd_ringbuffer *ring, OUT_RING(ring, DRAW(primtype, src_sel, idx_type, vismode, in
Mesa (master): freedreno/ir3: support glsl linking for cmdline compiler
Module: Mesa Branch: master Commit: 202710d11057dfe4416770752cf5fd5b3f766999 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=202710d11057dfe4416770752cf5fd5b3f766999 Author: Rob Clark Date: Fri Jun 24 15:17:27 2016 -0400 freedreno/ir3: support glsl linking for cmdline compiler For .vert/.frag, now multiple can be specified on the cmdline for purposes of linking, and the last one specified is the one that is fed into the ir3 backend (and dumped along the way if --verbose is specified) Without this, varyings in frag shaders would appear as undefined. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 71 - 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index 3e97ca5..41532fc 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -60,7 +60,7 @@ static void dump_info(struct ir3_shader_variant *so, const char *str) int st_glsl_type_size(const struct glsl_type *type); static nir_shader * -load_glsl(const char *filename, gl_shader_stage stage) +load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage) { static const struct standalone_options options = { .glsl_version = 140, @@ -68,9 +68,9 @@ load_glsl(const char *filename, gl_shader_stage stage) }; struct gl_shader_program *prog; - prog = standalone_compile_shader(&options, 1, (char * const*)&filename); + prog = standalone_compile_shader(&options, num_files, files); if (!prog) - errx(1, "couldn't parse `%s'", filename); + errx(1, "couldn't parse `%s'", files[0]); nir_shader *nir = glsl_to_nir(prog, stage, ir3_get_compiler_options()); @@ -129,7 +129,7 @@ read_file(const char *filename, void **ptr, size_t *size) static void print_usage(void) { - printf("Usage: ir3_compiler [OPTIONS]... \n"); + printf("Usage: ir3_compiler [OPTIONS]... \n"); printf("--verbose - verbose compiler/debug messages\n"); printf("--binning-pass- generate binning pass shader (VERT)\n"); printf("--color-two-side - emulate two-sided color (FRAG)\n"); @@ -147,7 +147,9 @@ static void print_usage(void) int main(int argc, char **argv) { int ret = 0, n = 1; - const char *filename; + char *filenames[2]; + int num_files = 0; + unsigned stage = 0; struct ir3_shader_variant v; struct ir3_shader s; struct ir3_shader_key key = {}; @@ -264,38 +266,59 @@ int main(int argc, char **argv) } debug_printf("\n"); - filename = argv[n]; + while (n < argc) { + char *filename = argv[n]; + char *ext = rindex(filename, '.'); + + if (strcmp(ext, ".tgsi") == 0) { + if (num_files != 0) + errx(1, "in TGSI mode, only a single file may be specified"); + s.from_tgsi = true; + } else if (strcmp(ext, ".frag") == 0) { + if (s.from_tgsi) + errx(1, "cannot mix GLSL and TGSI"); + if (num_files >= ARRAY_SIZE(filenames)) + errx(1, "too many GLSL files"); + stage = MESA_SHADER_FRAGMENT; + } else if (strcmp(ext, ".vert") == 0) { + if (s.from_tgsi) + errx(1, "cannot mix GLSL and TGSI"); + if (num_files >= ARRAY_SIZE(filenames)) + errx(1, "too many GLSL files"); + stage = MESA_SHADER_VERTEX; + } else { + print_usage(); + return -1; + } - ret = read_file(filename, &ptr, &size); - if (ret) { - print_usage(); - return ret; - } + filenames[num_files++] = filename; - if (fd_mesa_debug & FD_DBG_OPTMSGS) - debug_printf("%s\n", (char *)ptr); + n++; + } nir_shader *nir; - char *ext = rindex(filename, '.'); - - if (strcmp(ext, ".tgsi") == 0) { + if (s.from_tgsi) { struct tgsi_token toks[65536]; + ret = read_file(filenames[0], &ptr, &size); + if (ret) { + print_usage(); + return ret; + } + + if (fd_mesa_debug & FD_DBG_OPTMSGS) + d
Mesa (master): freedreno: update valid_buffer_range for SO buffers
Module: Mesa Branch: master Commit: 1759eb1d197e9794cd43ef86261372da719f4f2b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1759eb1d197e9794cd43ef86261372da719f4f2b Author: Rob Clark Date: Thu Jun 30 22:52:23 2016 -0400 freedreno: update valid_buffer_range for SO buffers Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_state.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index 53ea39b..252d153 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -316,6 +316,7 @@ fd_create_stream_output_target(struct pipe_context *pctx, unsigned buffer_size) { struct pipe_stream_output_target *target; + struct fd_resource *rsc = fd_resource(prsc); target = CALLOC_STRUCT(pipe_stream_output_target); if (!target) @@ -328,6 +329,10 @@ fd_create_stream_output_target(struct pipe_context *pctx, target->buffer_offset = buffer_offset; target->buffer_size = buffer_size; + assert(rsc->base.b.target == PIPE_BUFFER); + util_range_add(&rsc->valid_buffer_range, + buffer_offset, buffer_offset + buffer_size); + return target; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: don't drop const initializers in vector splitting
Module: Mesa Branch: master Commit: 01ccb0d91e6f976716eb79cdb0fb11ad4d0b4fcf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=01ccb0d91e6f976716eb79cdb0fb11ad4d0b4fcf Author: Rob Clark Date: Fri Jun 24 20:03:37 2016 -0400 i965: don't drop const initializers in vector splitting Signed-off-by: Rob Clark Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp | 12 1 file changed, 12 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp index 5fe24de..5c05586 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_vector_splitting.cpp @@ -372,6 +372,18 @@ brw_do_vector_splitting(exec_list *instructions) ralloc_free(name); + if (entry->var->constant_initializer) { +ir_constant_data data = {0}; +assert(entry->var->data.has_initializer); +if (entry->var->type->is_double()) { + data.d[0] = entry->var->constant_initializer->value.d[i]; +} else { + data.u[0] = entry->var->constant_initializer->value.u[i]; +} +entry->components[i]->data.has_initializer = true; +entry->components[i]->constant_initializer = new(entry->components[i]) ir_constant(type, &data); + } + entry->var->insert_before(entry->components[i]); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: switch emit_const_bo() to take prsc's
Module: Mesa Branch: master Commit: 88cc11e971e8e84c2704a86b325a08cbe8ffc354 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=88cc11e971e8e84c2704a86b325a08cbe8ffc354 Author: Rob Clark Date: Fri May 20 12:54:29 2016 -0400 freedreno: switch emit_const_bo() to take prsc's We can push the unwrap of pipe_resource down. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_emit.c | 8 src/gallium/drivers/freedreno/a4xx/fd4_emit.c | 8 src/gallium/drivers/freedreno/freedreno_context.h | 3 ++- src/gallium/drivers/freedreno/ir3/ir3_shader.c| 16 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index dc557fa..03b9328 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -93,7 +93,7 @@ fd3_emit_const(struct fd_ringbuffer *ring, enum shader_t type, static void fd3_emit_const_bo(struct fd_ringbuffer *ring, enum shader_t type, boolean write, - uint32_t regid, uint32_t num, struct fd_bo **bos, uint32_t *offsets) + uint32_t regid, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets) { uint32_t i; @@ -109,11 +109,11 @@ fd3_emit_const_bo(struct fd_ringbuffer *ring, enum shader_t type, boolean write, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS)); for (i = 0; i < num; i++) { - if (bos[i]) { + if (prscs[i]) { if (write) { - OUT_RELOCW(ring, bos[i], offsets[i], 0, 0); + OUT_RELOCW(ring, fd_resource(prscs[i])->bo, offsets[i], 0, 0); } else { - OUT_RELOC(ring, bos[i], offsets[i], 0, 0); + OUT_RELOC(ring, fd_resource(prscs[i])->bo, offsets[i], 0, 0); } } else { OUT_RING(ring, 0xbad0 | (i << 16)); diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c index 7d602fc..c8658f0 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -93,7 +93,7 @@ fd4_emit_const(struct fd_ringbuffer *ring, enum shader_t type, static void fd4_emit_const_bo(struct fd_ringbuffer *ring, enum shader_t type, boolean write, - uint32_t regid, uint32_t num, struct fd_bo **bos, uint32_t *offsets) + uint32_t regid, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets) { uint32_t i; @@ -109,11 +109,11 @@ fd4_emit_const_bo(struct fd_ringbuffer *ring, enum shader_t type, boolean write, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS)); for (i = 0; i < num; i++) { - if (bos[i]) { + if (prscs[i]) { if (write) { - OUT_RELOCW(ring, bos[i], offsets[i], 0, 0); + OUT_RELOCW(ring, fd_resource(prscs[i])->bo, offsets[i], 0, 0); } else { - OUT_RELOC(ring, bos[i], offsets[i], 0, 0); + OUT_RELOC(ring, fd_resource(prscs[i])->bo, offsets[i], 0, 0); } } else { OUT_RING(ring, 0xbad0 | (i << 16)); diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index 7ce2920..fe2a94c 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -394,8 +394,9 @@ struct fd_context { void (*emit_const)(struct fd_ringbuffer *ring, enum shader_t type, uint32_t regid, uint32_t offset, uint32_t sizedwords, const uint32_t *dwords, struct pipe_resource *prsc); + /* emit bo addresses as constant: */ void (*emit_const_bo)(struct fd_ringbuffer *ring, enum shader_t type, boolean write, - uint32_t regid, uint32_t num, struct fd_bo **bos, uint32_t *offsets); + uint32_t regid, uint32_t num, struct pipe_resource **prscs, uint32_t *offsets); /* indirect-branch emit: */ void (*emit_ib)(struct fd_ringbuffer *ring, struct fd_ringmarker *start, diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index ee0018f..9f39f9f 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -525,7 +525,7 @@ emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v, if (v->constlen > offset) { uint32_t params = MIN2(4, v->constlen - o
Mesa (master): freedreno/ir3: support non-user_buffer consts
Module: Mesa Branch: master Commit: da39ac9c5126825418c979989ea7e017554a0aaa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=da39ac9c5126825418c979989ea7e017554a0aaa Author: Rob Clark Date: Wed Jun 22 14:45:25 2016 -0400 freedreno/ir3: support non-user_buffer consts Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_screen.c | 6 -- src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 93b70e0..5255c10 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -156,12 +156,14 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: - case PIPE_CAP_USER_CONSTANT_BUFFERS: case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: case PIPE_CAP_VERTEXID_NOBASE: case PIPE_CAP_STRING_MARKER: return 1; + case PIPE_CAP_USER_CONSTANT_BUFFERS: + return is_ir3(screen) ? 0 : 1; + case PIPE_CAP_SHADER_STENCIL_EXPORT: case PIPE_CAP_TGSI_TEXCOORD: case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: @@ -214,7 +216,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return is_a4xx(screen); case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: - return 256; + return 64; case PIPE_CAP_GLSL_FEATURE_LEVEL: if (glsl120) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index 04c99d1..5c7ad84 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -181,7 +181,7 @@ compile_init(struct ir3_compiler *compiler, nir_print_shader(ctx->s, stdout); } - so->first_driver_param = so->first_immediate = ctx->s->num_uniforms; + so->first_driver_param = so->first_immediate = align(ctx->s->num_uniforms, 4); /* Layout of constant registers: * ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl/standalone: initialize MaxUserAssignableUniformLocations
Module: Mesa Branch: master Commit: 07cfe4e6aa2af646445c3e0f6be5eea60c721094 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=07cfe4e6aa2af646445c3e0f6be5eea60c721094 Author: Rob Clark Date: Fri Jun 24 15:11:02 2016 -0400 glsl/standalone: initialize MaxUserAssignableUniformLocations Signed-off-by: Rob Clark --- src/compiler/glsl/standalone.cpp | 4 1 file changed, 4 insertions(+) diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp index 760fe8f..88fe5fd 100644 --- a/src/compiler/glsl/standalone.cpp +++ b/src/compiler/glsl/standalone.cpp @@ -222,6 +222,10 @@ initialize_context(struct gl_context *ctx, gl_api api) ctx->Const.GenerateTemporaryNames = true; ctx->Const.MaxPatchVertices = 32; + /* GL_ARB_explicit_uniform_location, GL_MAX_UNIFORM_LOCATIONS */ + ctx->Const.MaxUserAssignableUniformLocations = + 4 * MESA_SHADER_STAGES * MAX_UNIFORMS; + ctx->Driver.NewShader = _mesa_new_linked_shader; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a2xx: move setup/restore cmds into binning pass
Module: Mesa Branch: master Commit: 2081c1ecc00682302faa9555cc0551fc14a338f0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2081c1ecc00682302faa9555cc0551fc14a338f0 Author: Rob Clark Date: Fri May 20 16:00:26 2016 -0400 freedreno/a2xx: move setup/restore cmds into binning pass Rather than doing a separate submit at context create, move these cmds to before first tile, as is done on a3xx/a4xx. Otherwise state can be overwritten by other contexts. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a2xx/fd2_context.c | 2 -- src/gallium/drivers/freedreno/a2xx/fd2_emit.c| 7 +-- src/gallium/drivers/freedreno/a2xx/fd2_emit.h| 2 +- src/gallium/drivers/freedreno/a2xx/fd2_gmem.c| 2 ++ 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_context.c b/src/gallium/drivers/freedreno/a2xx/fd2_context.c index 058f821..ec76a22 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_context.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_context.c @@ -120,7 +120,5 @@ fd2_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) /* construct vertex state used for solid ops (clear, and gmem<->mem) */ fd2_ctx->solid_vertexbuf = create_solid_vertexbuf(pctx); - fd2_emit_setup(&fd2_ctx->base); - return pctx; } diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c index 4f667ab..f8d03ca 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c @@ -316,10 +316,8 @@ fd2_emit_state(struct fd_context *ctx, uint32_t dirty) /* emit per-context initialization: */ void -fd2_emit_setup(struct fd_context *ctx) +fd2_emit_restore(struct fd_context *ctx, struct fd_ringbuffer *ring) { - struct fd_ringbuffer *ring = ctx->ring; - OUT_PKT0(ring, REG_A2XX_TP0_CHICKEN, 1); OUT_RING(ring, 0x0002); @@ -442,9 +440,6 @@ fd2_emit_setup(struct fd_context *ctx) OUT_RING(ring, 0x);/* RB_BLEND_GREEN */ OUT_RING(ring, 0x);/* RB_BLEND_BLUE */ OUT_RING(ring, 0x00ff);/* RB_BLEND_ALPHA */ - - fd_ringbuffer_flush(ring); - fd_ringmarker_mark(ctx->draw_start); } static void diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_emit.h b/src/gallium/drivers/freedreno/a2xx/fd2_emit.h index 3c146c1..6a26c85 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_emit.h +++ b/src/gallium/drivers/freedreno/a2xx/fd2_emit.h @@ -43,7 +43,7 @@ struct fd2_vertex_buf { void fd2_emit_vertex_bufs(struct fd_ringbuffer *ring, uint32_t val, struct fd2_vertex_buf *vbufs, uint32_t n); void fd2_emit_state(struct fd_context *ctx, uint32_t dirty); -void fd2_emit_setup(struct fd_context *ctx); +void fd2_emit_restore(struct fd_context *ctx, struct fd_ringbuffer *ring); void fd2_emit_init(struct pipe_context *pctx); diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c index aa47267..eba2cec 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c @@ -336,6 +336,8 @@ fd2_emit_tile_init(struct fd_context *ctx) enum pipe_format format = pipe_surface_format(pfb->cbufs[0]); uint32_t reg; + fd2_emit_restore(ctx, ctx->ring); + OUT_PKT3(ring, CP_SET_CONSTANT, 4); OUT_RING(ring, CP_REG(REG_A2XX_RB_SURFACE_INFO)); OUT_RING(ring, gmem->bin_w); /* RB_SURFACE_INFO */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: add driconf to zero-init unintialized vars
Module: Mesa Branch: master Commit: f78a6b1ce398a537d77c25b1a93f156109086975 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f78a6b1ce398a537d77c25b1a93f156109086975 Author: Rob Clark Date: Fri Jun 24 14:28:51 2016 -0400 glsl: add driconf to zero-init unintialized vars Some games are sloppy.. perhaps because it is defined behavior for DX or perhaps because nv blob driver defaults things to zero. So add driconf param to force uninitialized variables to default to zero. This issue was observed with rust, from steam store. But has surfaced elsewhere in the past. Signed-off-by: Rob Clark Reviewed-by: Kenneth Graunke --- src/compiler/glsl/ast_to_hir.cpp| 8 src/compiler/glsl/glsl_parser_extras.cpp| 1 + src/compiler/glsl/glsl_parser_extras.h | 1 + src/gallium/include/state_tracker/st_api.h | 1 + src/gallium/state_trackers/dri/dri_screen.c | 2 ++ src/mesa/drivers/dri/common/drirc | 4 src/mesa/drivers/dri/common/xmlpool/t_options.h | 5 - src/mesa/drivers/dri/i965/brw_context.c | 2 ++ src/mesa/drivers/dri/i965/intel_screen.c| 4 src/mesa/main/mtypes.h | 5 + src/mesa/state_tracker/st_extensions.c | 2 ++ 11 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 0cfce68..8ddc084 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -4697,6 +4697,14 @@ ast_declarator_list::hir(exec_list *instructions, apply_layout_qualifier_to_variable(&this->type->qualifier, var, state, &loc); + if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_temporary) + && (var->type->is_numeric() || var->type->is_boolean()) + && state->zero_init) { + const ir_constant_data data = {0}; + var->data.has_initializer = true; + var->constant_initializer = new(var) ir_constant(var->type, &data); + } + if (this->type->qualifier.flags.q.invariant) { if (!is_varying_var(var, state->stage)) { _mesa_glsl_error(&loc, state, diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index fab64bb..9601424 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -74,6 +74,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, /* Set default language version and extensions */ this->language_version = 110; this->forced_language_version = ctx->Const.ForceGLSLVersion; + this->zero_init = ctx->Const.GLSLZeroInit; this->es_shader = false; this->ARB_texture_rectangle_enable = true; diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index 8c43292..669b3d1 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -306,6 +306,7 @@ struct _mesa_glsl_parse_state { bool es_shader; unsigned language_version; unsigned forced_language_version; + bool zero_init; gl_shader_stage stage; /** diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 41daa47..21d5177 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -242,6 +242,7 @@ struct st_config_options unsigned force_glsl_version; boolean force_s3tc_enable; boolean allow_glsl_extension_directive_midshader; + boolean glsl_zero_init; }; /** diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 2ac55c8..b16585a 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -74,6 +74,7 @@ const __DRIconfigOptionsExtension gallium_config_options = { DRI_CONF_SECTION_MISCELLANEOUS DRI_CONF_ALWAYS_HAVE_DEPTH_BUFFER("false") + DRI_CONF_GLSL_ZERO_INIT("false") DRI_CONF_SECTION_END DRI_CONF_END }; @@ -98,6 +99,7 @@ dri_fill_st_options(struct st_config_options *options, driQueryOptionb(optionCache, "force_s3tc_enable"); options->allow_glsl_extension_directive_midshader = driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader"); + options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init"); } static const __DRIconfig ** diff --git a/src/mesa/drivers/dri/common/drirc b/src/mesa/drivers/dri/common/drirc index 3912d8b..af84ee8 100644 --- a/src/mesa/drivers/dri/common/drirc +++ b/src/mesa/drivers/dri/common/drirc @@ -96,5 +96,9 @@ TODO: document the other workarounds. + + +
Mesa (master): nir: Add a NIR_VALIDATE environment variable
Module: Mesa Branch: master Commit: 81978c6febd43b8a88a4db09133f9659e15b492c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=81978c6febd43b8a88a4db09133f9659e15b492c Author: Jason Ekstrand Date: Thu Jun 23 14:22:03 2016 -0700 nir: Add a NIR_VALIDATE environment variable It defaults to true so default behavior doesn't change but it allows you to do NIR_VALIDATE=false if you don't want validation. Disabling validation can substantially speed up shader compiles so you frequently want to turn it off if compiler invariants aren't in question. Reviewed-by: Matt Turner Reviewed-by: Matt Turner Signed-off-by: Rob Clark --- src/compiler/nir/nir_validate.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index e5f5b8a..63e85cf 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -1124,6 +1124,12 @@ dump_errors(validate_state *state) void nir_validate_shader(nir_shader *shader) { + static int should_validate = -1; + if (should_validate < 0) + should_validate = env_var_as_boolean("NIR_VALIDATE", true); + if (!should_validate) + return; + validate_state state; init_validate_state(&state); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): gallium: make shader_buffers const
Module: Mesa Branch: master Commit: e1c1c40cbcf3eec91bef8b38df8057eac52ce1ab URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e1c1c40cbcf3eec91bef8b38df8057eac52ce1ab Author: Rob Clark Date: Tue Jun 7 12:49:37 2016 -0400 gallium: make shader_buffers const Be consistent with the rest of the "set_xyz" state interfaces. Signed-off-by: Rob Clark Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/ddebug/dd_context.c | 2 +- src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 6 +++--- src/gallium/drivers/radeonsi/si_descriptors.c | 4 ++-- src/gallium/drivers/softpipe/sp_state_image.c | 2 +- src/gallium/drivers/trace/tr_context.c| 2 +- src/gallium/include/pipe/p_context.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c index 0f8ef18..b88df92 100644 --- a/src/gallium/drivers/ddebug/dd_context.c +++ b/src/gallium/drivers/ddebug/dd_context.c @@ -504,7 +504,7 @@ dd_context_set_shader_images(struct pipe_context *_pipe, unsigned shader, static void dd_context_set_shader_buffers(struct pipe_context *_pipe, unsigned shader, unsigned start, unsigned num_buffers, - struct pipe_shader_buffer *buffers) + const struct pipe_shader_buffer *buffers) { struct dd_context *dctx = dd_context(_pipe); struct pipe_context *pipe = dctx->pipe; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index 7e42be7..2fbe817 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -1332,8 +1332,8 @@ nvc0_set_shader_images(struct pipe_context *pipe, unsigned shader, static bool nvc0_bind_buffers_range(struct nvc0_context *nvc0, const unsigned t, - unsigned start, unsigned nr, - struct pipe_shader_buffer *pbuffers) +unsigned start, unsigned nr, +const struct pipe_shader_buffer *pbuffers) { const unsigned end = start + nr; unsigned mask = 0; @@ -1383,7 +1383,7 @@ static void nvc0_set_shader_buffers(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned nr, -struct pipe_shader_buffer *buffers) +const struct pipe_shader_buffer *buffers) { const unsigned s = nvc0_shader_stage(shader); if (!nvc0_bind_buffers_range(nvc0_context(pipe), s, start, nr, buffers)) diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 2d780e6..5ad251f 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -1040,7 +1040,7 @@ si_shader_buffer_descriptors(struct si_context *sctx, unsigned shader) static void si_set_shader_buffers(struct pipe_context *ctx, unsigned shader, unsigned start_slot, unsigned count, - struct pipe_shader_buffer *sbuffers) + const struct pipe_shader_buffer *sbuffers) { struct si_context *sctx = (struct si_context *)ctx; struct si_buffer_resources *buffers = &sctx->shader_buffers[shader]; @@ -1050,7 +1050,7 @@ static void si_set_shader_buffers(struct pipe_context *ctx, unsigned shader, assert(start_slot + count <= SI_NUM_SHADER_BUFFERS); for (i = 0; i < count; ++i) { - struct pipe_shader_buffer *sbuffer = sbuffers ? &sbuffers[i] : NULL; + const struct pipe_shader_buffer *sbuffer = sbuffers ? &sbuffers[i] : NULL; struct r600_resource *buf; unsigned slot = start_slot + i; uint32_t *desc = descs->list + slot * 4; diff --git a/src/gallium/drivers/softpipe/sp_state_image.c b/src/gallium/drivers/softpipe/sp_state_image.c index b1810d3..81bb7ca 100644 --- a/src/gallium/drivers/softpipe/sp_state_image.c +++ b/src/gallium/drivers/softpipe/sp_state_image.c @@ -56,7 +56,7 @@ static void softpipe_set_shader_buffers(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned num, -struct pipe_shader_buffer *buffers) +const struct pipe_shader_buffer *buffers) { struct softpipe_context *softpipe = softpipe_context(pipe); unsigned i; diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 18c5c43..7ea5946 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1671,7 +1671,7 @@ trace_context_set_tess_state(struct
Mesa (master): gallium: make constant_buffer const
Module: Mesa Branch: master Commit: ef534b9389bc74b007d76d2a1776068d23e5b887 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef534b9389bc74b007d76d2a1776068d23e5b887 Author: Rob Clark Date: Tue Jun 7 14:29:01 2016 -0400 gallium: make constant_buffer const Signed-off-by: Rob Clark Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/ddebug/dd_context.c | 2 +- src/gallium/drivers/freedreno/freedreno_state.c | 2 +- src/gallium/drivers/i915/i915_state.c | 2 +- src/gallium/drivers/ilo/ilo_state.c | 2 +- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 +- src/gallium/drivers/noop/noop_state.c | 2 +- src/gallium/drivers/nouveau/nv30/nv30_state.c | 2 +- src/gallium/drivers/nouveau/nv50/nv50_state.c | 2 +- src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 2 +- src/gallium/drivers/r300/r300_state.c | 2 +- src/gallium/drivers/r600/r600_state_common.c| 2 +- src/gallium/drivers/radeonsi/si_descriptors.c | 6 +++--- src/gallium/drivers/radeonsi/si_state.h | 3 +-- src/gallium/drivers/rbug/rbug_context.c | 2 +- src/gallium/drivers/softpipe/sp_state_shader.c | 2 +- src/gallium/drivers/svga/svga_pipe_constants.c | 2 +- src/gallium/drivers/swr/swr_state.cpp | 2 +- src/gallium/drivers/trace/tr_context.c | 2 +- src/gallium/drivers/vc4/vc4_state.c | 2 +- src/gallium/drivers/virgl/virgl_context.c | 2 +- src/gallium/include/pipe/p_context.h| 2 +- 21 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c index b88df92..785dde7 100644 --- a/src/gallium/drivers/ddebug/dd_context.c +++ b/src/gallium/drivers/ddebug/dd_context.c @@ -343,7 +343,7 @@ DD_IMM_STATE(polygon_stipple, const struct pipe_poly_stipple, *state, state) static void dd_context_set_constant_buffer(struct pipe_context *_pipe, uint shader, uint index, - struct pipe_constant_buffer *constant_buffer) + const struct pipe_constant_buffer *constant_buffer) { struct dd_context *dctx = dd_context(_pipe); struct pipe_context *pipe = dctx->pipe; diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index e4df909..53ea39b 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -89,7 +89,7 @@ fd_set_sample_mask(struct pipe_context *pctx, unsigned sample_mask) */ static void fd_set_constant_buffer(struct pipe_context *pctx, uint shader, uint index, - struct pipe_constant_buffer *cb) + const struct pipe_constant_buffer *cb) { struct fd_context *ctx = fd_context(pctx); struct fd_constbuf_stateobj *so = &ctx->constbuf[shader]; diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 8fa2f42..2efa14e 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -675,7 +675,7 @@ static void i915_delete_vs_state(struct pipe_context *pipe, void *shader) static void i915_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_constant_buffer *cb) + const struct pipe_constant_buffer *cb) { struct i915_context *i915 = i915_context(pipe); struct pipe_resource *buf = cb ? cb->buffer : NULL; diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index 37234ec..53a5aca 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -1536,7 +1536,7 @@ ilo_set_clip_state(struct pipe_context *pipe, static void ilo_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, -struct pipe_constant_buffer *buf) +const struct pipe_constant_buffer *buf) { const struct ilo_dev *dev = ilo_context(pipe)->dev; struct ilo_state_vector *vec = &ilo_context(pipe)->state_vector; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 3a678e3..b110202 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -2836,7 +2836,7 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs) static void llvmpipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_constant_buffer *cb) + const struct pipe_constant_buffer *cb) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); struct pipe_resource *constants = cb ? cb->buffer : NULL; diff --git
Mesa (master): gallium: make image_view const
Module: Mesa Branch: master Commit: 64180de1bf0ab9afcb4e659daf3132aa5b37638c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=64180de1bf0ab9afcb4e659daf3132aa5b37638c Author: Rob Clark Date: Tue Jun 7 14:32:16 2016 -0400 gallium: make image_view const Signed-off-by: Rob Clark Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/ddebug/dd_context.c | 2 +- src/gallium/drivers/ilo/ilo_state.c | 2 +- src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 4 ++-- src/gallium/drivers/radeonsi/si_descriptors.c | 6 +++--- src/gallium/drivers/softpipe/sp_state_image.c | 2 +- src/gallium/drivers/trace/tr_context.c| 2 +- src/gallium/include/pipe/p_context.h | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c index 785dde7..f618f0c 100644 --- a/src/gallium/drivers/ddebug/dd_context.c +++ b/src/gallium/drivers/ddebug/dd_context.c @@ -491,7 +491,7 @@ dd_context_set_sampler_views(struct pipe_context *_pipe, unsigned shader, static void dd_context_set_shader_images(struct pipe_context *_pipe, unsigned shader, unsigned start, unsigned num, - struct pipe_image_view *views) + const struct pipe_image_view *views) { struct dd_context *dctx = dd_context(_pipe); struct pipe_context *pipe = dctx->pipe; diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index 53a5aca..4f1002e 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -1851,7 +1851,7 @@ ilo_set_sampler_views(struct pipe_context *pipe, unsigned shader, static void ilo_set_shader_images(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned count, - struct pipe_image_view *views) + const struct pipe_image_view *views) { #if 0 struct ilo_state_vector *vec = &ilo_context(pipe)->state_vector; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index 4173d06..b389a77 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -1250,7 +1250,7 @@ nvc0_set_compute_resources(struct pipe_context *pipe, static bool nvc0_bind_images_range(struct nvc0_context *nvc0, const unsigned s, unsigned start, unsigned nr, - struct pipe_image_view *pimages) + const struct pipe_image_view *pimages) { const unsigned end = start + nr; unsigned mask = 0; @@ -1318,7 +1318,7 @@ nvc0_bind_images_range(struct nvc0_context *nvc0, const unsigned s, static void nvc0_set_shader_images(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned nr, - struct pipe_image_view *images) + const struct pipe_image_view *images) { const unsigned s = nvc0_shader_stage(shader); if (!nvc0_bind_images_range(nvc0_context(pipe), s, start, nr, images)) diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 55686e8..e95556b 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -560,7 +560,7 @@ si_disable_shader_image(struct si_context *ctx, unsigned shader, unsigned slot) } static void -si_mark_image_range_valid(struct pipe_image_view *view) +si_mark_image_range_valid(const struct pipe_image_view *view) { struct r600_resource *res = (struct r600_resource *)view->resource; const struct util_format_description *desc; @@ -578,7 +578,7 @@ si_mark_image_range_valid(struct pipe_image_view *view) static void si_set_shader_image(struct si_context *ctx, unsigned shader, - unsigned slot, struct pipe_image_view *view) + unsigned slot, const struct pipe_image_view *view) { struct si_screen *screen = ctx->screen; struct si_images_info *images = &ctx->images[shader]; @@ -674,7 +674,7 @@ static void si_set_shader_image(struct si_context *ctx, static void si_set_shader_images(struct pipe_context *pipe, unsigned shader, unsigned start_slot, unsigned count, -struct pipe_image_view *views) +const struct pipe_image_view *views) { struct si_context *ctx = (struct si_context *)pipe; unsigned i, slot; diff --git a/src/gallium/drivers/softpipe/sp_state_image.c b/src/gallium/drivers/softpipe/sp_state_image.c index 81bb7ca..553a76a 100644 --- a/src/gallium/drivers/softpipe/sp_state_image.c +++ b/src/gallium/drivers/softpipe/sp_state_image.c @@ -30,7 +30,7 @@ static void softpipe_set_shader_images(str
Mesa (master): freedreno: use util_copy_constant_buffer() helper
Module: Mesa Branch: master Commit: 26d0efa9cea3fc2bd9985a3f36264ab6aeaaee32 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=26d0efa9cea3fc2bd9985a3f36264ab6aeaaee32 Author: Rob Clark Date: Tue Jun 7 14:35:09 2016 -0400 freedreno: use util_copy_constant_buffer() helper Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_state.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index 6c472d1..befd496 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -94,21 +94,17 @@ fd_set_constant_buffer(struct pipe_context *pctx, uint shader, uint index, struct fd_context *ctx = fd_context(pctx); struct fd_constbuf_stateobj *so = &ctx->constbuf[shader]; + util_copy_constant_buffer(&so->cb[index], cb); + /* Note that the state tracker can unbind constant buffers by * passing NULL here. */ if (unlikely(!cb)) { so->enabled_mask &= ~(1 << index); so->dirty_mask &= ~(1 << index); - pipe_resource_reference(&so->cb[index].buffer, NULL); return; } - pipe_resource_reference(&so->cb[index].buffer, cb->buffer); - so->cb[index].buffer_offset = cb->buffer_offset; - so->cb[index].buffer_size = cb->buffer_size; - so->cb[index].user_buffer = cb->user_buffer; - so->enabled_mask |= 1 << index; so->dirty_mask |= 1 << index; ctx->dirty |= FD_DIRTY_CONSTBUF; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: only do extra vertex-buffer state logic on a2xx
Module: Mesa Branch: master Commit: b8eb1493a9f4c6d5f1484269dc9553fb78066435 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8eb1493a9f4c6d5f1484269dc9553fb78066435 Author: Rob Clark Date: Fri Jun 10 11:42:56 2016 -0400 freedreno: only do extra vertex-buffer state logic on a2xx Possibly this should move into an fd2 wrapper fxn, similar to the texture state tracking done for fd3/fd4 (clamp emulation, etc) Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_state.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index befd496..e4df909 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -183,14 +183,16 @@ fd_set_vertex_buffers(struct pipe_context *pctx, * we need to mark VTXSTATE as dirty as well to trigger patching * and re-emitting the vtx shader: */ - for (i = 0; i < count; i++) { - bool new_enabled = vb && (vb[i].buffer || vb[i].user_buffer); - bool old_enabled = so->vb[i].buffer || so->vb[i].user_buffer; - uint32_t new_stride = vb ? vb[i].stride : 0; - uint32_t old_stride = so->vb[i].stride; - if ((new_enabled != old_enabled) || (new_stride != old_stride)) { - ctx->dirty |= FD_DIRTY_VTXSTATE; - break; + if (ctx->screen->gpu_id < 300) { + for (i = 0; i < count; i++) { + bool new_enabled = vb && (vb[i].buffer || vb[i].user_buffer); + bool old_enabled = so->vb[i].buffer || so->vb[i].user_buffer; + uint32_t new_stride = vb ? vb[i].stride : 0; + uint32_t old_stride = so->vb[i].stride; + if ((new_enabled != old_enabled) || (new_stride != old_stride)) { + ctx->dirty |= FD_DIRTY_VTXSTATE; + break; + } } } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: support start param for sampler views/states
Module: Mesa Branch: master Commit: 243417810bce6b4e0c466a8b1dbe3873b4f5562b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=243417810bce6b4e0c466a8b1dbe3873b4f5562b Author: Rob Clark Date: Sat Jun 11 12:59:00 2016 -0400 freedreno: support start param for sampler views/states Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_context.h | 3 +- src/gallium/drivers/freedreno/freedreno_texture.c | 53 +-- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index 5861fbe8..7ce2920 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -47,9 +47,10 @@ struct fd_vertex_stateobj; struct fd_texture_stateobj { struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS]; unsigned num_textures; + unsigned valid_textures; struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; unsigned num_samplers; - unsigned dirty_samplers; + unsigned valid_samplers; }; struct fd_program_stateobj { diff --git a/src/gallium/drivers/freedreno/freedreno_texture.c b/src/gallium/drivers/freedreno/freedreno_texture.c index a301811..b506595 100644 --- a/src/gallium/drivers/freedreno/freedreno_texture.c +++ b/src/gallium/drivers/freedreno/freedreno_texture.c @@ -50,45 +50,38 @@ fd_sampler_view_destroy(struct pipe_context *pctx, } static void bind_sampler_states(struct fd_texture_stateobj *tex, - unsigned nr, void **hwcso) + unsigned start, unsigned nr, void **hwcso) { unsigned i; - unsigned new_nr = 0; for (i = 0; i < nr; i++) { - if (hwcso[i]) - new_nr = i + 1; - tex->samplers[i] = hwcso[i]; - tex->dirty_samplers |= (1 << i); - } - - for (; i < tex->num_samplers; i++) { - tex->samplers[i] = NULL; - tex->dirty_samplers |= (1 << i); + unsigned p = i + start; + tex->samplers[p] = hwcso[i]; + if (tex->samplers[p]) + tex->valid_samplers |= (1 << p); + else + tex->valid_samplers &= ~(1 << p); } - tex->num_samplers = new_nr; + tex->num_samplers = util_last_bit(tex->valid_samplers); } static void set_sampler_views(struct fd_texture_stateobj *tex, - unsigned nr, struct pipe_sampler_view **views) + unsigned start, unsigned nr, struct pipe_sampler_view **views) { unsigned i; - unsigned new_nr = 0; for (i = 0; i < nr; i++) { - if (views[i]) - new_nr = i + 1; - pipe_sampler_view_reference(&tex->textures[i], views[i]); - tex->dirty_samplers |= (1 << i); + struct pipe_sampler_view *view = views ? views[i] : NULL; + unsigned p = i + start; + pipe_sampler_view_reference(&tex->textures[p], view); + if (tex->textures[p]) + tex->valid_textures |= (1 << p); + else + tex->valid_textures &= ~(1 << p); } - for (; i < tex->num_textures; i++) { - pipe_sampler_view_reference(&tex->textures[i], NULL); - tex->dirty_samplers |= (1 << i); - } - - tex->num_textures = new_nr; + tex->num_textures = util_last_bit(tex->valid_textures); } void @@ -98,14 +91,12 @@ fd_sampler_states_bind(struct pipe_context *pctx, { struct fd_context *ctx = fd_context(pctx); - assert(start == 0); - if (shader == PIPE_SHADER_FRAGMENT) { - bind_sampler_states(&ctx->fragtex, nr, hwcso); + bind_sampler_states(&ctx->fragtex, start, nr, hwcso); ctx->dirty |= FD_DIRTY_FRAGTEX; } else if (shader == PIPE_SHADER_VERTEX) { - bind_sampler_states(&ctx->verttex, nr, hwcso); + bind_sampler_states(&ctx->verttex, start, nr, hwcso); ctx->dirty |= FD_DIRTY_VERTTEX; } } @@ -117,8 +108,6 @@ fd_set_sampler_views(struct pipe_context *pctx, unsigned shader, { struct fd_context *ctx = fd_context(pctx); - assert(start == 0); - switch (shader) { case PIPE_SHADER_FRAGMENT: /* on a2xx, since there is a flat address space for textures/samplers, @@ -130,11 +119,11 @@ fd_set_sampler_views(struct pipe_context *pctx, unsigned shader, if (nr != ctx->fragtex.num_textures) ctx->dirty |= FD_DIRTY_TEXSTATE; - set_sampler_views(&
Mesa (master): nir/algebraic: support for power-of-two optimizations
Module: Mesa Branch: master Commit: dfbae7d64f4d563bc65af338cdcb217f10474c1c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfbae7d64f4d563bc65af338cdcb217f10474c1c Author: Rob Clark Date: Sat May 7 13:01:24 2016 -0400 nir/algebraic: support for power-of-two optimizations Some optimizations, like converting integer multiply/divide into left/ right shifts, have additional constraints on the search expression. Like requiring that a variable is a constant power of two. Support these cases by allowing a fxn name to be appended to the search var expression (ie. "a#32(is_power_of_two)"). Signed-off-by: Rob Clark Reviewed-by: Kenneth Graunke Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir.h| 3 ++ src/compiler/nir/nir_algebraic.py | 8 ++- src/compiler/nir/nir_opt_algebraic.py | 15 -- src/compiler/nir/nir_search.c | 3 ++ src/compiler/nir/nir_search.h | 10 src/compiler/nir/nir_search_helpers.h | 94 +++ 6 files changed, 128 insertions(+), 5 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 20f6520..3f9309c 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1651,6 +1651,9 @@ typedef struct nir_shader_compiler_options { /* lower {slt,sge,seq,sne} to {flt,fge,feq,fne} + b2f: */ bool lower_scmp; + /** enables rules to lower idiv by power-of-two: */ + bool lower_idiv; + /* Does the native fdot instruction replicate its result for four * components? If so, then opt_algebraic_late will turn all fdotN * instructions into fdot_replicatedN instructions. diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py index 285f853..19ac6ee 100644 --- a/src/compiler/nir/nir_algebraic.py +++ b/src/compiler/nir/nir_algebraic.py @@ -76,6 +76,7 @@ class Value(object): return Constant(val, name_base) __template = mako.template.Template(""" +#include "compiler/nir/nir_search_helpers.h" static const ${val.c_type} ${val.name} = { { ${val.type_enum}, ${val.bit_size} }, % if isinstance(val, Constant): @@ -84,6 +85,7 @@ static const ${val.c_type} ${val.name} = { ${val.index}, /* ${val.var_name} */ ${'true' if val.is_constant else 'false'}, ${val.type() or 'nir_type_invalid' }, + ${val.cond if val.cond else 'NULL'}, % elif isinstance(val, Expression): ${'true' if val.inexact else 'false'}, nir_op_${val.opcode}, @@ -113,7 +115,7 @@ static const ${val.c_type} ${val.name} = { Variable=Variable, Expression=Expression) -_constant_re = re.compile(r"(?P[^@]+)(?:@(?P\d+))?") +_constant_re = re.compile(r"(?P[^@\(]+)(?:@(?P\d+))?") class Constant(Value): def __init__(self, val, name): @@ -150,7 +152,8 @@ class Constant(Value): return "nir_type_float" _var_name_re = re.compile(r"(?P#)?(?P\w+)" - r"(?:@(?Pint|uint|bool|float)?(?P\d+)?)?") + r"(?:@(?Pint|uint|bool|float)?(?P\d+)?)?" + r"(?P\([^\)]+\))?") class Variable(Value): def __init__(self, val, name, varset): @@ -161,6 +164,7 @@ class Variable(Value): self.var_name = m.group('name') self.is_constant = m.group('const') is not None + self.cond = m.group('cond') self.required_type = m.group('type') self.bit_size = int(m.group('bits')) if m.group('bits') else 0 diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index f8db2b6..011263a 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -45,10 +45,11 @@ d = 'd' # however, be used for backend-requested lowering operations as those need to # happen regardless of precision. # -# Variable names are specified as "[#]name[@type]" where "#" inicates that -# the given variable will only match constants and the type indicates that +# Variable names are specified as "[#]name[@type][(cond)]" where "#" inicates +# that the given variable will only match constants and the type indicates that # the given variable will only match values from ALU instructions with the -# given output type. +# given output type, and (cond) specifies an additional condition function +# (see nir_search_helpers.h). # # For constants, you have to be careful to make sure that it is the right # type because python is unaware of the source and destination types of the @@ -62,6 +63,14 @@ d = 'd' # constructed value should have that bit-size. optimizations = [ + + (('imul', a, '#b@32(is_pos_power_of_two)'), ('ishl
Mesa (master): freedreno/ir3: do idiv lowering after main opt loop
Module: Mesa Branch: master Commit: 1535519e51af75c6860c07d4403c77f18634cb09 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1535519e51af75c6860c07d4403c77f18634cb09 Author: Rob Clark Date: Mon May 9 12:41:00 2016 -0400 freedreno/ir3: do idiv lowering after main opt loop Give algebraic-opt pass a chance to catch udiv by const power-of-two, before running lower-idiv pass. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_nir.c | 43 ++--- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_nir.c index 58bef16..023da3b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.c @@ -82,6 +82,27 @@ ir3_key_lowers_nir(const struct ir3_shader_key *key) #define OPT_V(nir, pass, ...) NIR_PASS_V(nir, pass, ##__VA_ARGS__) +static void +ir3_optimize_loop(nir_shader *s) +{ + bool progress; + do { + progress = false; + + OPT_V(s, nir_lower_vars_to_ssa); + OPT_V(s, nir_lower_alu_to_scalar); + OPT_V(s, nir_lower_phis_to_scalar); + + progress |= OPT(s, nir_copy_prop); + progress |= OPT(s, nir_opt_dce); + progress |= OPT(s, nir_opt_cse); + progress |= OPT(s, ir3_nir_lower_if_else); + progress |= OPT(s, nir_opt_algebraic); + progress |= OPT(s, nir_opt_constant_folding); + + } while (progress); +} + struct nir_shader * ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s, const struct ir3_shader_key *key) @@ -89,7 +110,6 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s, struct nir_lower_tex_options tex_options = { .lower_rect = 0, }; - bool progress; if (key) { switch (shader->type) { @@ -145,24 +165,15 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s, } OPT_V(s, nir_lower_tex, &tex_options); - OPT_V(s, nir_lower_idiv); OPT_V(s, nir_lower_load_const_to_scalar); - do { - progress = false; - - OPT_V(s, nir_lower_vars_to_ssa); - OPT_V(s, nir_lower_alu_to_scalar); - OPT_V(s, nir_lower_phis_to_scalar); + ir3_optimize_loop(s); - progress |= OPT(s, nir_copy_prop); - progress |= OPT(s, nir_opt_dce); - progress |= OPT(s, nir_opt_cse); - progress |= OPT(s, ir3_nir_lower_if_else); - progress |= OPT(s, nir_opt_algebraic); - progress |= OPT(s, nir_opt_constant_folding); - - } while (progress); + /* do idiv lowering after first opt loop to give a chance for +* divide by immed power-of-two to be caught first: +*/ + if (OPT(s, nir_lower_idiv)) + ir3_optimize_loop(s); OPT_V(s, nir_remove_dead_variables, nir_var_local); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: fix bad bitshift warnings
Module: Mesa Branch: master Commit: 94d8fbd21768987d1bde0e31bdcabf7004b8f9b8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=94d8fbd21768987d1bde0e31bdcabf7004b8f9b8 Author: Rob Clark Date: Thu Jun 2 16:23:36 2016 -0400 freedreno: fix bad bitshift warnings Coverity doesn't realize idx will never be negative. Throw in some assert()s to help it out. (Hopefully assert() isn't getting compiled out for coverity build.. but there seems to be just one way to find out. We might have to change these to assume()) Fixes CID 1362442, 1362443 Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_query_hw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index 04452ef..95fff3f 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -94,6 +94,7 @@ resume_query(struct fd_context *ctx, struct fd_hw_query *hq, struct fd_ringbuffer *ring) { int idx = pidx(hq->provider->query_type); + assert(idx >= 0); /* query never would have been created otherwise */ assert(!hq->period); ctx->active_providers |= (1 << idx); hq->period = util_slab_alloc(&ctx->sample_period_pool); @@ -108,6 +109,7 @@ pause_query(struct fd_context *ctx, struct fd_hw_query *hq, struct fd_ringbuffer *ring) { int idx = pidx(hq->provider->query_type); + assert(idx >= 0); /* query never would have been created otherwise */ assert(hq->period && !hq->period->end); assert(ctx->active_providers & (1 << idx)); hq->period->end = get_sample(ctx, ring, hq->base.type); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: assume builtin shaders do compile
Module: Mesa Branch: master Commit: 676c77a923d596cfeb393a780a3d6cb82898e71f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=676c77a923d596cfeb393a780a3d6cb82898e71f Author: Rob Clark Date: Thu Jun 2 16:17:16 2016 -0400 freedreno: assume builtin shaders do compile Maybe we should switch to ureg to build the builtin shaders. But at any rate, if they fail to compile it is because someone messed them up (or changed TGSI syntax?). CID 1362444 Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_program.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_program.c b/src/gallium/drivers/freedreno/freedreno_program.c index ae6c658..db6b258 100644 --- a/src/gallium/drivers/freedreno/freedreno_program.c +++ b/src/gallium/drivers/freedreno/freedreno_program.c @@ -81,7 +81,8 @@ static void * assemble_tgsi(struct pipe_context *pctx, .tokens = toks, }; - tgsi_text_translate(src, toks, ARRAY_SIZE(toks)); + bool ret = tgsi_text_translate(src, toks, ARRAY_SIZE(toks)); + assume(ret); if (frag) return pctx->create_fs_state(pctx, &cso); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/ir3: use nir_shader_get_entrypoint() helper
Module: Mesa Branch: master Commit: 374ad2e2bd14b4fd0c161d41e3627793ffabe468 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=374ad2e2bd14b4fd0c161d41e3627793ffabe468 Author: Rob Clark Date: Thu Jun 2 11:13:26 2016 -0400 freedreno/ir3: use nir_shader_get_entrypoint() helper Should also fix coverity warning: CID 1362454 Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index aa2d688..04c99d1 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -2188,16 +2188,7 @@ static void emit_instructions(struct ir3_compile *ctx) { unsigned ninputs, noutputs; - nir_function_impl *fxn = NULL; - - /* Find the main function: */ - nir_foreach_function(function, ctx->s) { - compile_assert(ctx, strcmp(function->name, "main") == 0); - compile_assert(ctx, function->impl); - fxn = function->impl; - break; - } - + nir_function_impl *fxn = nir_shader_get_entrypoint(ctx->s)->impl; ninputs = (max_drvloc(&ctx->s->inputs) + 1) * 4; noutputs = (max_drvloc(&ctx->s->outputs) + 1) * 4; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a4xx: silence coverity warning
Module: Mesa Branch: master Commit: 80c288603300a06ac1585769cc491711c3d1b4f0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80c288603300a06ac1585769cc491711c3d1b4f0 Author: Rob Clark Date: Thu Jun 2 11:47:11 2016 -0400 freedreno/a4xx: silence coverity warning CID 1362451 Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_program.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_program.c b/src/gallium/drivers/freedreno/a4xx/fd4_program.c index 9dc4ebb..4590c0e 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_program.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_program.c @@ -121,6 +121,12 @@ emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so) OUT_RELOC(ring, so->bo, 0, CP_LOAD_STATE_1_STATE_TYPE(ST_SHADER), 0); } + + /* for how clever coverity is, it is sometimes rather dull, and +* doesn't realize that the only case where bin==NULL, sz==0: +*/ + assume(bin || (sz == 0)); + for (i = 0; i < sz; i++) { OUT_RING(ring, bin[i]); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a4xx: only update/ emit bordercolor state when needed
Module: Mesa Branch: master Commit: 11f065240438728c36c777ff8fcedd3d32426c3c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=11f065240438728c36c777ff8fcedd3d32426c3c Author: Rob Clark Date: Wed Jun 1 12:23:58 2016 -0400 freedreno/a4xx: only update/emit bordercolor state when needed I noticed in stk that it was contributing to a lot of overhead. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_emit.c| 32 ++-- src/gallium/drivers/freedreno/a4xx/fd4_texture.c | 10 +--- src/gallium/drivers/freedreno/a4xx/fd4_texture.h | 1 + 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c index 00e985d..7d602fc 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -131,16 +131,8 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, [SB_FRAG_TEX] = REG_A4XX_TPL1_TP_FS_BORDER_COLOR_BASE_ADDR, }; struct fd4_context *fd4_ctx = fd4_context(ctx); - unsigned i, off; - void *ptr; - - u_upload_alloc(fd4_ctx->border_color_uploader, - 0, BORDER_COLOR_UPLOAD_SIZE, - BORDER_COLOR_UPLOAD_SIZE, &off, - &fd4_ctx->border_color_buf, - &ptr); - - fd_setup_border_colors(tex, ptr, 0); + bool needs_border = false; + unsigned i; if (tex->num_samplers > 0) { int num_samplers; @@ -166,6 +158,8 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, &dummy_sampler; OUT_RING(ring, sampler->texsamp0); OUT_RING(ring, sampler->texsamp1); + + needs_border |= sampler->needs_border; } for (; i < num_samplers; i++) { @@ -235,10 +229,22 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, debug_assert(v->astc_srgb.count == 0); } - OUT_PKT0(ring, bcolor_reg[sb], 1); - OUT_RELOC(ring, fd_resource(fd4_ctx->border_color_buf)->bo, off, 0, 0); + if (needs_border) { + unsigned off; + void *ptr; - u_upload_unmap(fd4_ctx->border_color_uploader); + u_upload_alloc(fd4_ctx->border_color_uploader, + 0, BORDER_COLOR_UPLOAD_SIZE, + BORDER_COLOR_UPLOAD_SIZE, &off, + &fd4_ctx->border_color_buf, + &ptr); + + fd_setup_border_colors(tex, ptr, 0); + OUT_PKT0(ring, bcolor_reg[sb], 1); + OUT_RELOC(ring, fd_resource(fd4_ctx->border_color_buf)->bo, off, 0, 0); + + u_upload_unmap(fd4_ctx->border_color_uploader); + } } /* emit texture state for mem->gmem restore operation.. eventually it would diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c index 6d9ecb7..da8c681 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c @@ -36,7 +36,7 @@ #include "fd4_format.h" static enum a4xx_tex_clamp -tex_clamp(unsigned wrap, bool clamp_to_edge) +tex_clamp(unsigned wrap, bool clamp_to_edge, bool *needs_border) { /* Hardware does not support _CLAMP, but we emulate it: */ if (wrap == PIPE_TEX_WRAP_CLAMP) { @@ -50,6 +50,7 @@ tex_clamp(unsigned wrap, bool clamp_to_edge) case PIPE_TEX_WRAP_CLAMP_TO_EDGE: return A4XX_TEX_CLAMP_TO_EDGE; case PIPE_TEX_WRAP_CLAMP_TO_BORDER: + *needs_border = true; return A4XX_TEX_CLAMP_TO_BORDER; case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: /* only works for PoT.. need to emulate otherwise! */ @@ -113,14 +114,15 @@ fd4_sampler_state_create(struct pipe_context *pctx, so->saturate_r = (cso->wrap_r == PIPE_TEX_WRAP_CLAMP); } + so->needs_border = false; so->texsamp0 = COND(miplinear, A4XX_TEX_SAMP_0_MIPFILTER_LINEAR_NEAR) | A4XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) | A4XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) | A4XX_TEX_SAMP_0_ANISO(aniso) | - A4XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge)) | - A4XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge)) | - A4XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge)); + A4XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge, &so->needs_border)) | + A4XX_TE
Mesa (master): freedreno/ir3: fix coverity warning
Module: Mesa Branch: master Commit: 27a97097e1a6d8f0a29393b2fcc6fdb0a500bf92 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27a97097e1a6d8f0a29393b2fcc6fdb0a500bf92 Author: Rob Clark Date: Thu Jun 2 11:19:43 2016 -0400 freedreno/ir3: fix coverity warning CID 1362453 Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.c b/src/gallium/drivers/freedreno/ir3/ir3.c index 1406856..a01df3b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.c +++ b/src/gallium/drivers/freedreno/ir3/ir3.c @@ -428,12 +428,14 @@ static int emit_cat5(struct ir3_instruction *instr, void *ptr, iassert(!((dst->flags ^ type_flags(instr->cat5.type)) & IR3_REG_HALF)); + assume(src1 || !src2); + assume(src2 || !src3); + if (src1) { cat5->full = ! (src1->flags & IR3_REG_HALF); cat5->src1 = reg(src1, info, instr->repeat, IR3_REG_HALF); } - if (instr->flags & IR3_INSTR_S2EN) { if (src2) { iassert(!((src1->flags ^ src2->flags) & IR3_REG_HALF)); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a4xx: fix incorrect enum type
Module: Mesa Branch: master Commit: df64cd68144c52476a2fc2dce4e18e30ce098213 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=df64cd68144c52476a2fc2dce4e18e30ce098213 Author: Rob Clark Date: Thu Jun 2 10:49:18 2016 -0400 freedreno/a4xx: fix incorrect enum type a4xx has it's own enum, different from a2xx/a3xx. Spotted by coverity: CID 1362458, 1362459 Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a4xx/fd4_draw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_draw.h b/src/gallium/drivers/freedreno/a4xx/fd4_draw.h index 2b23e33..c850c24 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_draw.h +++ b/src/gallium/drivers/freedreno/a4xx/fd4_draw.h @@ -88,7 +88,7 @@ fd4_draw(struct fd_context *ctx, struct fd_ringbuffer *ring, } -static inline enum pc_di_index_size +static inline enum a4xx_index_size fd4_size2indextype(unsigned index_size) { switch (index_size) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a3xx+a4xx: fix potential null ptr deref
Module: Mesa Branch: master Commit: 9b854ce53cb0550311d2252523fe088c281074d8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b854ce53cb0550311d2252523fe088c281074d8 Author: Rob Clark Date: Thu Jun 2 11:42:25 2016 -0400 freedreno/a3xx+a4xx: fix potential null ptr deref Coverity spotted the a3xx case (not sure why not the a4xx). CID 1362452 Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_gmem.c | 3 ++- src/gallium/drivers/freedreno/a4xx/fd4_gmem.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c index 81a613f..7b96d5e 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c @@ -79,7 +79,8 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, if (rsc->stencil) { rsc = rsc->stencil; pformat = rsc->base.b.format; - bases++; + if (bases) + bases++; } slice = fd_resource_slice(rsc, psurf->u.tex.level); format = fd3_pipe2color(pformat); diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c index c6fbf1c..e211545 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c @@ -80,7 +80,8 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, if (rsc->stencil) { rsc = rsc->stencil; pformat = rsc->base.b.format; - bases++; + if (bases) + bases++; } slice = fd_resource_slice(rsc, psurf->u.tex.level); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/a3xx: only update/ emit bordercolor state when needed
Module: Mesa Branch: master Commit: 18fb922faab145ea88533405bb64ed398c0e0138 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=18fb922faab145ea88533405bb64ed398c0e0138 Author: Rob Clark Date: Wed Jun 1 13:40:53 2016 -0400 freedreno/a3xx: only update/emit bordercolor state when needed Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_emit.c| 33 ++-- src/gallium/drivers/freedreno/a3xx/fd3_texture.c | 10 --- src/gallium/drivers/freedreno/a3xx/fd3_texture.h | 1 + 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index 4a5242a..dc557fa 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -142,16 +142,8 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, [SB_FRAG_TEX] = REG_A3XX_TPL1_TP_FS_BORDER_COLOR_BASE_ADDR, }; struct fd3_context *fd3_ctx = fd3_context(ctx); - unsigned i, j, off; - void *ptr; - - u_upload_alloc(fd3_ctx->border_color_uploader, - 0, BORDER_COLOR_UPLOAD_SIZE, - BORDER_COLOR_UPLOAD_SIZE, &off, - &fd3_ctx->border_color_buf, - &ptr); - - fd_setup_border_colors(tex, ptr, tex_off[sb]); + bool needs_border = false; + unsigned i, j; if (tex->num_samplers > 0) { /* output sampler state: */ @@ -170,6 +162,8 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, OUT_RING(ring, sampler->texsamp0); OUT_RING(ring, sampler->texsamp1); + + needs_border |= sampler->needs_border; } } @@ -233,10 +227,23 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, } } - OUT_PKT0(ring, bcolor_reg[sb], 1); - OUT_RELOC(ring, fd_resource(fd3_ctx->border_color_buf)->bo, off, 0, 0); + if (needs_border) { + unsigned off; + void *ptr; + + u_upload_alloc(fd3_ctx->border_color_uploader, + 0, BORDER_COLOR_UPLOAD_SIZE, + BORDER_COLOR_UPLOAD_SIZE, &off, + &fd3_ctx->border_color_buf, + &ptr); - u_upload_unmap(fd3_ctx->border_color_uploader); + fd_setup_border_colors(tex, ptr, tex_off[sb]); + + OUT_PKT0(ring, bcolor_reg[sb], 1); + OUT_RELOC(ring, fd_resource(fd3_ctx->border_color_buf)->bo, off, 0, 0); + + u_upload_unmap(fd3_ctx->border_color_uploader); + } } /* emit texture state for mem->gmem restore operation.. eventually it would diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c index 9d54d41..81336bf 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c @@ -36,7 +36,7 @@ #include "fd3_format.h" static enum a3xx_tex_clamp -tex_clamp(unsigned wrap, bool clamp_to_edge) +tex_clamp(unsigned wrap, bool clamp_to_edge, bool *needs_border) { /* Hardware does not support _CLAMP, but we emulate it: */ if (wrap == PIPE_TEX_WRAP_CLAMP) { @@ -50,6 +50,7 @@ tex_clamp(unsigned wrap, bool clamp_to_edge) case PIPE_TEX_WRAP_CLAMP_TO_EDGE: return A3XX_TEX_CLAMP_TO_EDGE; case PIPE_TEX_WRAP_CLAMP_TO_BORDER: + *needs_border = true; return A3XX_TEX_CLAMP_TO_BORDER; case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: /* only works for PoT.. need to emulate otherwise! */ @@ -113,6 +114,7 @@ fd3_sampler_state_create(struct pipe_context *pctx, so->saturate_r = (cso->wrap_r == PIPE_TEX_WRAP_CLAMP); } + so->needs_border = false; so->texsamp0 = COND(!cso->normalized_coords, A3XX_TEX_SAMP_0_UNNORM_COORDS) | COND(!cso->seamless_cube_map, A3XX_TEX_SAMP_0_CUBEMAPSEAMLESSFILTOFF) | @@ -120,9 +122,9 @@ fd3_sampler_state_create(struct pipe_context *pctx, A3XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) | A3XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) | A3XX_TEX_SAMP_0_ANISO(aniso) | - A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge)) | - A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge)) | - A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge)); + A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso-
Mesa (master): freedreno: fix coverity negative array index warning
Module: Mesa Branch: master Commit: 1632b0eac02cd8911c04115cb6b4693f7dcb16bb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1632b0eac02cd8911c04115cb6b4693f7dcb16bb Author: Rob Clark Date: Thu Jun 2 10:36:23 2016 -0400 freedreno: fix coverity negative array index warning Never can happen, since query would not have been created in the first place if pidx(query_type) return negative. Lets let coverity realize this. CID 1362460 Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_query_hw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index 2ac03f2..04452ef 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -61,6 +61,8 @@ get_sample(struct fd_context *ctx, struct fd_ringbuffer *ring, struct fd_hw_sample *samp = NULL; int idx = pidx(query_type); + assume(idx >= 0); /* query never would have been created otherwise */ + if (!ctx->sample_cache[idx]) { ctx->sample_cache[idx] = ctx->sample_providers[idx]->get_sample(ctx, ring); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): gallium/util: remove u_staging
Module: Mesa Branch: master Commit: 228b2b36f4574a362357270204a23ddaeb765465 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=228b2b36f4574a362357270204a23ddaeb765465 Author: Rob Clark Date: Sun May 29 12:25:32 2016 -0400 gallium/util: remove u_staging Unused, and fixes a couple of coverity warnings: CID 1362171, 1362170 Signed-off-by: Rob Clark Acked-by: Marek Olšák --- src/gallium/auxiliary/Makefile.sources | 2 - src/gallium/auxiliary/util/u_staging.c | 136 - src/gallium/auxiliary/util/u_staging.h | 67 3 files changed, 205 deletions(-) diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index 9b0c9a3..26a06b2 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -288,8 +288,6 @@ C_SOURCES := \ util/u_slab.h \ util/u_split_prim.h \ util/u_sse.h \ - util/u_staging.c \ - util/u_staging.h \ util/u_string.h \ util/u_suballoc.c \ util/u_suballoc.h \ diff --git a/src/gallium/auxiliary/util/u_staging.c b/src/gallium/auxiliary/util/u_staging.c deleted file mode 100644 index 5b61f5e..000 --- a/src/gallium/auxiliary/util/u_staging.c +++ /dev/null @@ -1,136 +0,0 @@ -/** - * - * Copyright 2010 Luca Barbieri - * - * 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 COPYRIGHT OWNER(S) 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 "util/u_staging.h" -#include "pipe/p_context.h" -#include "util/u_memory.h" -#include "util/u_inlines.h" - - -static void -util_staging_resource_template(struct pipe_resource *pt, unsigned width, - unsigned height, unsigned depth, - struct pipe_resource *template) -{ - memset(template, 0, sizeof(struct pipe_resource)); - if (pt->target != PIPE_BUFFER && depth <= 1) - template->target = PIPE_TEXTURE_RECT; - else - template->target = pt->target; - template->format = pt->format; - template->width0 = width; - template->height0 = height; - template->depth0 = depth; - template->array_size = 1; - template->last_level = 0; - template->nr_samples = pt->nr_samples; - template->bind = 0; - template->usage = PIPE_USAGE_STAGING; - template->flags = 0; -} - - -struct util_staging_transfer * -util_staging_transfer_init(struct pipe_context *pipe, - struct pipe_resource *pt, - unsigned level, enum pipe_resource_usage usage, - const struct pipe_box *box, - boolean direct, struct util_staging_transfer *tx) -{ - struct pipe_screen *pscreen = pipe->screen; - struct pipe_resource staging_resource_template; - - pipe_resource_reference(&tx->base.resource, pt); - tx->base.level = level; - tx->base.usage = usage; - tx->base.box = *box; - - if (direct) { - tx->staging_resource = pt; - return tx; - } - - util_staging_resource_template(pt, box->width, box->height, - box->depth, &staging_resource_template); - tx->staging_resource = pscreen->resource_create(pscreen, - &staging_resource_template); - if (!tx->staging_resource) { - pipe_resource_reference(&tx->base.resource, NULL); - FREE(tx); - return NULL; - } - - if (usage & PIPE_TRANSFER_READ) { - /* XXX this looks wrong dst is always the same but looping over src z? */ - int zi; - struct pipe_box sbox; - sbox.x = box->x; - sbox.y = box->y; -
Mesa (master): freedreno: fix dereference before null check
Module: Mesa Branch: master Commit: ba452d43e0f5ee6ceec5da031f55904f8144472c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ba452d43e0f5ee6ceec5da031f55904f8144472c Author: Rob Clark Date: Thu Jun 2 10:33:08 2016 -0400 freedreno: fix dereference before null check ptr can actually never be null so just drop the check. CID 1362464 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking ptr suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_query_hw.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.h b/src/gallium/drivers/freedreno/freedreno_query_hw.h index 8a5d114..095140e 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.h +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.h @@ -163,8 +163,7 @@ fd_hw_sample_reference(struct fd_context *ctx, if (pipe_reference(&(*ptr)->reference, &samp->reference)) __fd_hw_sample_destroy(ctx, old_samp); - if (ptr) - *ptr = samp; + *ptr = samp; } #endif /* FREEDRENO_QUERY_HW_H_ */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): gallium/util: fix build break
Module: Mesa Branch: master Commit: 4f98c94be7e56a535a6b84a5561ae071e052c1e2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f98c94be7e56a535a6b84a5561ae071e052c1e2 Author: Rob Clark Date: Thu May 26 20:59:08 2016 -0400 gallium/util: fix build break Missing #include caused build breaks after 21a3fb9cd. Signed-off-by: Rob Clark --- src/gallium/auxiliary/util/u_upload_mgr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/util/u_upload_mgr.h b/src/gallium/auxiliary/util/u_upload_mgr.h index 6c70723..b36e9e5 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.h +++ b/src/gallium/auxiliary/util/u_upload_mgr.h @@ -33,6 +33,7 @@ #define U_UPLOAD_MGR_H #include "pipe/p_compiler.h" +#include "pipe/p_defines.h" struct pipe_context; struct pipe_resource; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): tgsi: fix out of bounds access
Module: Mesa Branch: master Commit: 3d66ba971e984a1c58eda6a938a37f58ba6f8134 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d66ba971e984a1c58eda6a938a37f58ba6f8134 Author: Rob Clark Date: Thu May 26 10:22:33 2016 -0400 tgsi: fix out of bounds access Not sure why coverity calls this an out-of-bounds read vs out-of-bounds write. CID 1358920 (#1 of 1): Out-of-bounds read (OVERRUN)9. overrun-local: Overrunning array r of 3 16-byte elements at element index 3 (byte offset 48) using index chan (which evaluates to 3). Signed-off-by: Rob Clark Reviewed-by: Brian Paul --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index baf4a89..289fe04 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -3851,7 +3851,7 @@ static void exec_load_mem(struct tgsi_exec_machine *mach, const struct tgsi_full_instruction *inst) { - union tgsi_exec_channel r[3]; + union tgsi_exec_channel r[4]; uint chan; char *ptr = mach->LocalMem; uint32_t offset; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): tgsi: fix coverity out-of-bounds warning
Module: Mesa Branch: master Commit: 6e51fe75a4997328625753c9409b328f207d5e51 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e51fe75a4997328625753c9409b328f207d5e51 Author: Rob Clark Date: Thu May 26 11:11:32 2016 -0400 tgsi: fix coverity out-of-bounds warning CID 1271532 (#1 of 1): Out-of-bounds read (OVERRUN)34. overrun-local: Overrunning array of 2 16-byte elements at element index 2 (byte offset 32) by dereferencing pointer &inst.Dst[i]. Signed-off-by: Rob Clark Reviewed-by: Brian Paul --- src/gallium/auxiliary/tgsi/tgsi_text.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 955d042..8bdec06 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -1081,6 +1081,9 @@ parse_instruction( inst.Memory.Qualifier = 0; } + assume(info->num_dst <= TGSI_FULL_MAX_DST_REGISTERS); + assume(info->num_src <= TGSI_FULL_MAX_SRC_REGISTERS); + /* Parse instruction operands. */ for (i = 0; i < info->num_dst + info->num_src + info->is_tex; i++) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): android: drop build of standalone glsl_compiler
Module: Mesa Branch: master Commit: ec434d940d9ade664ed9ddf74760ce1dcc432718 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec434d940d9ade664ed9ddf74760ce1dcc432718 Author: Rob Clark Date: Wed May 25 09:59:02 2016 -0400 android: drop build of standalone glsl_compiler It's only a tool for debugging the glsl compiler, and should not be installed. Signed-off-by: Rob Clark Tested-by: Rob Herring Acked-by: Emil Velikov --- src/compiler/Android.glsl.mk | 22 -- 1 file changed, 22 deletions(-) diff --git a/src/compiler/Android.glsl.mk b/src/compiler/Android.glsl.mk index d9cf06d..8184d2d 100644 --- a/src/compiler/Android.glsl.mk +++ b/src/compiler/Android.glsl.mk @@ -51,25 +51,3 @@ include $(LOCAL_PATH)/Android.glsl.gen.mk include $(MESA_COMMON_MK) include $(BUILD_STATIC_LIBRARY) -# --- -# Build glsl_compiler -# --- - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - $(GLSL_COMPILER_CXX_FILES) - -LOCAL_C_INCLUDES := \ - $(MESA_TOP)/src/mapi \ - $(MESA_TOP)/src/mesa \ - $(MESA_TOP)/src/gallium/include \ - $(MESA_TOP)/src/gallium/auxiliary - -LOCAL_STATIC_LIBRARIES := libmesa_glsl libmesa_glsl_utils libmesa_util libmesa_compiler - -LOCAL_MODULE_TAGS := eng -LOCAL_MODULE := glsl_compiler - -include $(MESA_COMMON_MK) -include $(BUILD_EXECUTABLE) ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/ir3: cmdline compiler for glsl
Module: Mesa Branch: master Commit: 231dcb19f928858ca4143e8b91e4bdc4f220ac87 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=231dcb19f928858ca4143e8b91e4bdc4f220ac87 Author: Rob Clark Date: Sat May 14 13:38:13 2016 -0400 freedreno/ir3: cmdline compiler for glsl Use glsl/libstandalone.la to add support for taking glsl src files (in addition to .tgsi) as input. Then glsl->nir and feed the result into the ir3 backend as normal. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/Makefile.am | 2 + src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 89 + 2 files changed, 77 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/freedreno/Makefile.am b/src/gallium/drivers/freedreno/Makefile.am index 9c0ccdf..1af8dec 100644 --- a/src/gallium/drivers/freedreno/Makefile.am +++ b/src/gallium/drivers/freedreno/Makefile.am @@ -37,6 +37,8 @@ ir3_compiler_LDADD = \ libfreedreno.la \ $(top_builddir)/src/gallium/auxiliary/libgallium.la \ $(top_builddir)/src/compiler/nir/libnir.la \ + $(top_builddir)/src/compiler/glsl/libstandalone.la \ $(top_builddir)/src/util/libmesautil.la \ + $(top_builddir)/src/mesa/libmesagallium.la \ $(GALLIUM_COMMON_LIB_DEPS) \ $(FREEDRENO_LIBS) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index 42beb4d..7f5b483 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -44,6 +44,9 @@ #include "instr-a3xx.h" #include "ir3.h" +#include "compiler/glsl/standalone.h" +#include "compiler/nir/glsl_to_nir.h" + static void dump_info(struct ir3_shader_variant *so, const char *str) { uint32_t *bin; @@ -54,6 +57,47 @@ static void dump_info(struct ir3_shader_variant *so, const char *str) free(bin); } +int st_glsl_type_size(const struct glsl_type *type); + +static nir_shader * +load_glsl(const char *filename, gl_shader_stage stage) +{ + static const struct standalone_options options = { + .glsl_version = 140, + .do_link = true, + }; + struct gl_shader_program *prog; + + prog = standalone_compile_shader(&options, 1, (char * const*)&filename); + if (!prog) + errx(1, "couldn't parse `%s'", filename); + + nir_shader *nir = glsl_to_nir(prog, stage, ir3_get_compiler_options()); + + standalone_compiler_cleanup(prog); + + /* required NIR passes: */ + /* TODO cmdline args for some of the conditional lowering passes? */ + + NIR_PASS_V(nir, nir_lower_io_to_temporaries, + nir_shader_get_entrypoint(nir), + true, true); + NIR_PASS_V(nir, nir_lower_global_vars_to_local); + NIR_PASS_V(nir, nir_split_var_copies); + NIR_PASS_V(nir, nir_lower_var_copies); + + NIR_PASS_V(nir, nir_split_var_copies); + NIR_PASS_V(nir, nir_lower_var_copies); + NIR_PASS_V(nir, nir_lower_io_types); + + // TODO nir_assign_var_locations?? + + NIR_PASS_V(nir, nir_lower_system_values); + NIR_PASS_V(nir, nir_lower_io, nir_var_all, st_glsl_type_size); + NIR_PASS_V(nir, nir_lower_samplers, prog); + + return nir; +} static int read_file(const char *filename, void **ptr, size_t *size) @@ -85,7 +129,7 @@ read_file(const char *filename, void **ptr, size_t *size) static void print_usage(void) { - printf("Usage: ir3_compiler [OPTIONS]... FILE\n"); + printf("Usage: ir3_compiler [OPTIONS]... \n"); printf("--verbose - verbose compiler/debug messages\n"); printf("--binning-pass- generate binning pass shader (VERT)\n"); printf("--color-two-side - emulate two-sided color (FRAG)\n"); @@ -104,8 +148,6 @@ int main(int argc, char **argv) { int ret = 0, n = 1; const char *filename; - struct tgsi_token toks[65536]; - struct tgsi_parse_context parse; struct ir3_shader_variant v; struct ir3_shader s; struct ir3_shader_key key = {}; @@ -233,31 +275,50 @@ int main(int argc, char **argv) if (fd_mesa_debug & FD_DBG_OPTMSGS) debug_printf("%s\n", (char *)ptr); - if (!tgsi_text_translate(ptr, toks, ARRAY_SIZE(toks))) - errx(1, "could not parse `%s'", filename); + nir_shader *nir; - if (fd_mesa_debug & FD_DBG_OPTMSGS) - tgsi_dump(toks, 0); + char *ext = rindex(filename, '.'); + + if (strcmp(ext, ".tgsi") == 0) { + struct tgsi_token toks[65536]; + + if (!tgsi_text_translate(ptr, toks, ARRAY_SIZE(toks))) + errx(1, "could not parse `%s'", f
Mesa (master): glsl: split out libstandalone
Module: Mesa Branch: master Commit: 0f982bb67d64673f73096f7c536a5e29756c5c6f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f982bb67d64673f73096f7c536a5e29756c5c6f Author: Rob Clark Date: Sat May 14 11:59:26 2016 -0400 glsl: split out libstandalone Split standalone glsl_compiler into a libstandalone.la and a thin main.cpp. This way drivers can re-use the glsl standalone frontend in their own standalone compilers. Signed-off-by: Rob Clark Reviewed-by: Emil Velikov --- src/compiler/Makefile.glsl.am| 16 +- src/compiler/Makefile.sources| 3 +- src/compiler/SConscript.glsl | 2 + src/compiler/glsl/main.cpp | 380 ++ src/compiler/glsl/standalone.cpp | 433 +++ src/compiler/glsl/standalone.h | 51 + 6 files changed, 514 insertions(+), 371 deletions(-) diff --git a/src/compiler/Makefile.glsl.am b/src/compiler/Makefile.glsl.am index daf98f6..23c2a6b 100644 --- a/src/compiler/Makefile.glsl.am +++ b/src/compiler/Makefile.glsl.am @@ -57,7 +57,6 @@ glsl_tests_blob_test_LDADD = \ glsl/libglsl.la glsl_tests_general_ir_test_SOURCES = \ - glsl/standalone_scaffolding.cpp \ glsl/tests/builtin_variable_test.cpp\ glsl/tests/invalidate_locations_test.cpp\ glsl/tests/general_ir_test.cpp \ @@ -67,6 +66,7 @@ glsl_tests_general_ir_test_CFLAGS = \ glsl_tests_general_ir_test_LDADD = \ $(top_builddir)/src/gtest/libgtest.la \ glsl/libglsl.la \ + glsl/libstandalone.la \ $(top_builddir)/src/libglsl_util.la \ $(PTHREAD_LIBS) @@ -93,7 +93,7 @@ glsl_tests_sampler_types_test_LDADD = \ $(top_builddir)/src/libglsl_util.la \ $(PTHREAD_LIBS) -noinst_LTLIBRARIES += glsl/libglsl.la glsl/libglcpp.la +noinst_LTLIBRARIES += glsl/libglsl.la glsl/libglcpp.la glsl/libstandalone.la glsl_libglcpp_la_LIBADD = \ $(top_builddir)/src/util/libmesautil.la @@ -121,23 +121,29 @@ glsl_libglsl_la_SOURCES = \ $(LIBGLSL_FILES) -glsl_compiler_SOURCES = \ +glsl_libstandalone_la_SOURCES = \ $(GLSL_COMPILER_CXX_FILES) -glsl_compiler_LDADD = \ +glsl_libstandalone_la_LIBADD = \ glsl/libglsl.la \ $(top_builddir)/src/libglsl_util.la \ $(top_builddir)/src/util/libmesautil.la \ $(PTHREAD_LIBS) +glsl_compiler_SOURCES = \ + glsl/main.cpp + +glsl_compiler_LDADD = \ + glsl/libstandalone.la + glsl_glsl_test_SOURCES = \ - glsl/standalone_scaffolding.cpp \ glsl/test.cpp \ glsl/test_optpass.cpp \ glsl/test_optpass.h glsl_glsl_test_LDADD = \ glsl/libglsl.la \ + glsl/libstandalone.la \ $(top_builddir)/src/libglsl_util.la \ $(PTHREAD_LIBS) diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources index b8f2b49..ebc5953 100644 --- a/src/compiler/Makefile.sources +++ b/src/compiler/Makefile.sources @@ -138,7 +138,8 @@ LIBGLSL_FILES = \ GLSL_COMPILER_CXX_FILES = \ glsl/standalone_scaffolding.cpp \ glsl/standalone_scaffolding.h \ - glsl/main.cpp + glsl/standalone.cpp \ + glsl/standalone.h # libglsl generated sources LIBGLSL_GENERATED_CXX_FILES = \ diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl index 73abaf1..474df11 100644 --- a/src/compiler/SConscript.glsl +++ b/src/compiler/SConscript.glsl @@ -109,6 +109,8 @@ if env['platform'] == 'windows': env.Prepend(LIBS = [compiler, glsl]) +compiler_objs += env.StaticObject("glsl/main.cpp") + glsl_compiler = env.Program( target = 'glsl_compiler', source = compiler_objs, diff --git a/src/compiler/glsl/main.cpp b/src/compiler/glsl/main.cpp index d253575..f65b185 100644 --- a/src/compiler/glsl/main.cpp +++ b/src/compiler/glsl/main.cpp @@ -20,6 +20,8 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + +#include #include /** @file main.cpp @@ -31,255 +33,16 @@ * offline compile GLSL code and examine the resulting GLSL IR. */ -#include "ast.h" -#include "glsl_parser_extras.h" -#include "ir_optimization.h" -#include "program.h" -#include "program/hash_table.h" -#include "loop_analysis.h" -#include "standalone_scaffolding.h" - -static int glsl_version = 330; - -static void -initialize_context(struct gl_context *ctx, gl_api api) -{ -
Mesa (master): freedreno/ir3: disable cp for indirect src's
Module: Mesa Branch: master Commit: 46ff17559b1369f0fe7dca000f51f077ffd1dae5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=46ff17559b1369f0fe7dca000f51f077ffd1dae5 Author: Rob Clark Date: Mon May 23 15:53:23 2016 -0400 freedreno/ir3: disable cp for indirect src's The variable-indexing tests always had a few random fails, which I usually couldn't reproduce when running tests manually. Somehow recently this got a lot worse. I ported a couple of the shaders to GLES to see what blob does, and it also seems to be avoiding to cp indirect srcs. So I guess indirect w/ instructions other than cat1 (mov) are not totally reliable. Let's just switch that off until this is better understood. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_cp.c | 9 + 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cp.c b/src/gallium/drivers/freedreno/ir3/ir3_cp.c index 6e71bee..57c37e2 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cp.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cp.c @@ -102,6 +102,15 @@ static bool valid_flags(struct ir3_instruction *instr, unsigned n, (flags & IR3_REG_RELATIV)) return false; + /* TODO it seems to *mostly* work to cp RELATIV, except we get some +* intermittent piglit variable-indexing fails. Newer blob driver +* doesn't seem to cp these. Possibly this is hw workaround? Not +* sure, but until that is understood better, lets just switch off +* cp for indirect src's: +*/ + if (flags & IR3_REG_RELATIV) + return false; + /* clear flags that are 'ok' */ switch (opc_cat(instr->opc)) { case 1: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/validate: fix null deref coverity warning
Module: Mesa Branch: master Commit: 5245d845b6f77361f01a7f577e1471345df132de URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5245d845b6f77361f01a7f577e1471345df132de Author: Rob Clark Date: Wed May 18 11:40:34 2016 -0400 nir/validate: fix null deref coverity warning CID 1265536 (#1 of 2): Explicit null dereferenced (FORWARD_NULL)6. var_deref_op: Dereferencing null pointer parent. Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir_validate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 8ac55d5..35bb162 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -376,6 +376,7 @@ validate_deref_chain(nir_deref *deref, validate_state *state) break; case nir_deref_type_struct: + assume(parent); /* cannot happen: deref change starts w/ nir_deref_var */ validate_assert(state, deref->type == glsl_get_struct_field(parent->type, nir_deref_as_struct(deref)->index)); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/ir3: need to lower fmod too
Module: Mesa Branch: master Commit: 3a1bbd6a0a85f866e4325eeb5e18694c51d3d36b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a1bbd6a0a85f866e4325eeb5e18694c51d3d36b Author: Rob Clark Date: Tue May 17 09:52:24 2016 -0400 freedreno/ir3: need to lower fmod too Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_nir.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_nir.c index 9365e33..58bef16 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.c @@ -42,6 +42,8 @@ static const nir_shader_compiler_options options = { .lower_flrp32 = true, .lower_flrp64 = true, .lower_ffract = true, + .lower_fmod32 = true, + .lower_fmod64 = true, .lower_fdiv = true, .fuse_ffma = true, .native_integers = true, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: coverity sign-extension fix
Module: Mesa Branch: master Commit: 53c48feae086bbf5b17798fc1cd98ab14a17c7a8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=53c48feae086bbf5b17798fc1cd98ab14a17c7a8 Author: Rob Clark Date: Wed May 18 10:17:02 2016 -0400 nir: coverity sign-extension fix Not 100% sure, but I think being an unsigned literal will help: CID 1358505 (#1 of 1): Unintended sign extension (SIGN_EXTENSION)sign_extension: Suspicious implicit sign extension: load1->def.num_components with type unsigned char (8 bits, unsigned) is promoted in load1->def.num_components * (load1->def.bit_size / 8) to type int (32 bits, signed), then sign-extended to type unsigned long (64 bits, unsigned). If load1->def.num_components * (load1->def.bit_size / 8) is greater than 0x7FFF, the upper bits of the result will all be 1. Signed-off-by: Rob Clark Reviewed-by: Matt Turner --- src/compiler/nir/nir_instr_set.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index fe312a0..f93ec9d 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -334,7 +334,7 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2) return false; return memcmp(load1->value.f32, load2->value.f32, -load1->def.num_components * (load1->def.bit_size / 8)) == 0; +load1->def.num_components * (load1->def.bit_size / 8u)) == 0; } case nir_instr_type_phi: { nir_phi_instr *phi1 = nir_instr_as_phi(instr1); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: coverity unitialized pointer read
Module: Mesa Branch: master Commit: fcd6b3f42be904d162b78fe75ba14c6415cdb815 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fcd6b3f42be904d162b78fe75ba14c6415cdb815 Author: Rob Clark Date: Wed May 18 10:38:40 2016 -0400 nir: coverity unitialized pointer read Not sure how coverity arrives at the conclusion that we can read comp[j] unitialized (around line 204), other than not being aware that ncomp is greater than 1 so it won't underflow in the 'if (tex->is_array)' case. Signed-off-by: Rob Clark Reviewed-by: Matt Turner --- src/compiler/nir/nir_lower_tex.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index a080475..2086263 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -177,6 +177,8 @@ saturate_src(nir_builder *b, nir_tex_instr *tex, unsigned sat_mask) /* split src into components: */ nir_ssa_def *comp[4]; + assume(tex->coord_components >= 1); + for (unsigned j = 0; j < tex->coord_components; j++) comp[j] = nir_channel(b, src, j); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/glsl_to_nir: quell some uninit_member coverity errors
Module: Mesa Branch: master Commit: bb993da7959da07cbbbd0f8d41e07652263260e6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb993da7959da07cbbbd0f8d41e07652263260e6 Author: Rob Clark Date: Wed May 18 10:58:29 2016 -0400 nir/glsl_to_nir: quell some uninit_member coverity errors Signed-off-by: Rob Clark Acked-by: Matt Turner --- src/compiler/nir/glsl_to_nir.cpp | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp index b25f065..00e3fd5 100644 --- a/src/compiler/nir/glsl_to_nir.cpp +++ b/src/compiler/nir/glsl_to_nir.cpp @@ -213,6 +213,12 @@ nir_visitor::nir_visitor(nir_shader *shader) _mesa_key_pointer_equal); this->overload_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); + this->result = NULL; + this->impl = NULL; + this->var = NULL; + this->deref_head = NULL; + this->deref_tail = NULL; + memset(&this->b, 0, sizeof(this->b)); } nir_visitor::~nir_visitor() ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/validate: assume() that hashtable entry exists
Module: Mesa Branch: master Commit: df361fc58cb1aaf8c692c3aa6f545cf7f495b374 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=df361fc58cb1aaf8c692c3aa6f545cf7f495b374 Author: Rob Clark Date: Wed May 18 11:43:15 2016 -0400 nir/validate: assume() that hashtable entry exists At this point, it would require a logic error in nir_validate to not have already populated this hashtable entry, but coverity doesn't realize that: CID 1265547 (#1 of 1): Dereference null return value (NULL_RETURNS)3. dereference: Dereferencing a null pointer entry. CID 1271039 (#1 of 1): Dereference null return value (NULL_RETURNS)3. dereference: Dereferencing a null pointer entry. Signed-off-by: Rob Clark Reviewed-by: Matt Turner --- src/compiler/nir/nir_validate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index b186fd5..8ac55d5 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -879,6 +879,7 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state) { struct hash_entry *entry = _mesa_hash_table_search(state->regs, reg); + assume(entry); reg_validate_state *reg_state = (reg_validate_state *) entry->data; nir_foreach_use(src, reg) { @@ -955,6 +956,8 @@ postvalidate_ssa_def(nir_ssa_def *def, void *void_state) validate_state *state = void_state; struct hash_entry *entry = _mesa_hash_table_search(state->ssa_defs, def); + + assume(entry); ssa_def_validate_state *def_state = (ssa_def_validate_state *)entry->data; nir_foreach_use(src, def) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa/st: don't leak name
Module: Mesa Branch: master Commit: 5827a1dc4b3c2f51d45f4b1d6ccd080515ed2bcc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5827a1dc4b3c2f51d45f4b1d6ccd080515ed2bcc Author: Rob Clark Date: Wed May 18 09:19:00 2016 -0400 mesa/st: don't leak name Pointed out by coverity. Signed-off-by: Rob Clark --- src/mesa/state_tracker/st_nir_lower_builtin.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_nir_lower_builtin.c b/src/mesa/state_tracker/st_nir_lower_builtin.c index b4da901..20b04d1 100644 --- a/src/mesa/state_tracker/st_nir_lower_builtin.c +++ b/src/mesa/state_tracker/st_nir_lower_builtin.c @@ -128,9 +128,12 @@ get_variable(lower_builtin_state *state, nir_deref_var *deref, char *name = _mesa_program_state_string((gl_state_index *)tokens); - nir_foreach_variable(var, &shader->uniforms) - if (strcmp(var->name, name) == 0) + nir_foreach_variable(var, &shader->uniforms) { + if (strcmp(var->name, name) == 0) { + free(name); return var; + } + } /* variable doesn't exist yet, so create it: */ nir_variable *var = ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): android: fix building error in libmesa_st_mesa
Module: Mesa Branch: master Commit: 0e813365501d5580bbc2a93dc14f30b52e388c76 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e813365501d5580bbc2a93dc14f30b52e388c76 Author: Mauro Rossi Date: Tue May 17 22:48:36 2016 +0200 android: fix building error in libmesa_st_mesa Fixes the following building error due to libmesa_nir dependency: In file included from external/mesa/src/mesa/state_tracker/st_glsl_to_nir.cpp:44:0: external/mesa/src/compiler/nir/nir.h:42:25: fatal error: nir_opcodes.h: No such file or directory #include "nir_opcodes.h" ^ compilation terminated. build/core/binary.mk:706: recipe for target 'out/target/product/x86/obj/STATIC_LIBRARIES/libmesa_st_mesa_intermediates/state_tracker/st_glsl_to_nir.o' failed make: *** [out/target/product/x86/obj/STATIC_LIBRARIES/libmesa_st_mesa_intermediates/state_tracker/st_glsl_to_nir.o] Error 1 make: *** Waiting for unfinished jobs Reviewed-by: Rob Herring Signed-off-by: Rob Clark --- src/mesa/Android.libmesa_st_mesa.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/Android.libmesa_st_mesa.mk b/src/mesa/Android.libmesa_st_mesa.mk index bbd3956..785b6de 100644 --- a/src/mesa/Android.libmesa_st_mesa.mk +++ b/src/mesa/Android.libmesa_st_mesa.mk @@ -63,6 +63,8 @@ LOCAL_C_INCLUDES := \ LOCAL_WHOLE_STATIC_LIBRARIES += \ libmesa_program +LOCAL_STATIC_LIBRARIES += libmesa_nir + include $(LOCAL_PATH)/Android.gen.mk include $(MESA_COMMON_MK) include $(BUILD_STATIC_LIBRARY) ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa/st: move things around a bit in st_create_fp_variant()
Module: Mesa Branch: master Commit: 2bbb140be3cbc8e8428f21083b21abd7246ddc6e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2bbb140be3cbc8e8428f21083b21abd7246ddc6e Author: Rob Clark Date: Mon Mar 28 10:55:59 2016 -0400 mesa/st: move things around a bit in st_create_fp_variant() Prep work for next patch. Signed-off-by: Rob Clark Reviewed-by: Marek Olšák --- src/mesa/state_tracker/st_program.c | 20 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 4e37a17..252e440 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -870,6 +870,13 @@ st_create_fp_variant(struct st_context *st, struct pipe_context *pipe = st->pipe; struct st_fp_variant *variant = CALLOC_STRUCT(st_fp_variant); struct pipe_shader_state tgsi = {0}; + struct gl_program_parameter_list *params = stfp->Base.Base.Parameters; + static const gl_state_index texcoord_state[STATE_LENGTH] = + { STATE_INTERNAL, STATE_CURRENT_ATTRIB, VERT_ATTRIB_TEX0 }; + static const gl_state_index scale_state[STATE_LENGTH] = + { STATE_INTERNAL, STATE_PT_SCALE }; + static const gl_state_index bias_state[STATE_LENGTH] = + { STATE_INTERNAL, STATE_PT_BIAS }; if (!variant) return NULL; @@ -930,7 +937,6 @@ st_create_fp_variant(struct st_context *st, if (key->drawpixels) { const struct tgsi_token *tokens; unsigned scale_const = 0, bias_const = 0, texcoord_const = 0; - struct gl_program_parameter_list *params = stfp->Base.Base.Parameters; /* Find the first unused slot. */ variant->drawpix_sampler = ffs(~stfp->Base.Base.SamplersUsed) - 1; @@ -943,21 +949,11 @@ st_create_fp_variant(struct st_context *st, } if (key->scaleAndBias) { - static const gl_state_index scale_state[STATE_LENGTH] = -{ STATE_INTERNAL, STATE_PT_SCALE }; - static const gl_state_index bias_state[STATE_LENGTH] = -{ STATE_INTERNAL, STATE_PT_BIAS }; - scale_const = _mesa_add_state_reference(params, scale_state); bias_const = _mesa_add_state_reference(params, bias_state); } - { - static const gl_state_index state[STATE_LENGTH] = -{ STATE_INTERNAL, STATE_CURRENT_ATTRIB, VERT_ATTRIB_TEX0 }; - - texcoord_const = _mesa_add_state_reference(params, state); - } + texcoord_const = _mesa_add_state_reference(params, texcoord_state); tokens = st_get_drawpix_shader(tgsi.tokens, st->needs_texcoord_semantic, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa/st: add support for NIR as possible driver IR
Module: Mesa Branch: master Commit: 1e93b0caa10d9d9090eaa3bd517a5144930f28a4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e93b0caa10d9d9090eaa3bd517a5144930f28a4 Author: Rob Clark Date: Mon Dec 21 21:34:11 2015 -0500 mesa/st: add support for NIR as possible driver IR Signed-off-by: Rob Clark Acked-by: Eric Anholt --- src/mesa/Makefile.sources | 1 + src/mesa/SConscript| 1 + src/mesa/state_tracker/st_glsl_to_nir.cpp | 442 + src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 40 ++- src/mesa/state_tracker/st_glsl_to_tgsi.h | 5 + src/mesa/state_tracker/st_nir.h| 21 ++ src/mesa/state_tracker/st_program.c| 128 - src/mesa/state_tracker/st_program.h| 6 + 8 files changed, 632 insertions(+), 12 deletions(-) diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 81928c8..840a68e 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -489,6 +489,7 @@ STATETRACKER_FILES = \ state_tracker/st_gen_mipmap.c \ state_tracker/st_gen_mipmap.h \ state_tracker/st_gl_api.h \ + state_tracker/st_glsl_to_nir.cpp \ state_tracker/st_glsl_to_tgsi.cpp \ state_tracker/st_glsl_to_tgsi.h \ state_tracker/st_glsl_types.cpp \ diff --git a/src/mesa/SConscript b/src/mesa/SConscript index 7174101..434800e 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -13,6 +13,7 @@ env = env.Clone() env.MSVC2013Compat() env.Append(CPPPATH = [ +'../compiler/nir', # for generated nir_opcodes.h, etc '#/src', '#/src/mapi', '#/src/glsl', diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp new file mode 100644 index 000..6cfbb8e --- /dev/null +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -0,0 +1,442 @@ +/* + * Copyright © 2015 Red Hat + * + * 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 "st_nir.h" + +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" + +#include "program/program.h" +#include "program/prog_statevars.h" +#include "program/prog_parameter.h" +#include "program/ir_to_mesa.h" +#include "program/hash_table.h" +#include "main/mtypes.h" +#include "main/errors.h" +#include "main/shaderapi.h" +#include "main/uniforms.h" + +#include "st_context.h" +#include "st_program.h" +#include "st_glsl_types.h" + +#include "compiler/nir/nir.h" +#include "compiler/nir/glsl_to_nir.h" +#include "compiler/glsl_types.h" +#include "compiler/glsl/ir.h" + + +/* Depending on PIPE_CAP_TGSI_TEXCOORD (st->needs_texcoord_semantic) we + * may need to fix up varying slots so the glsl->nir path is aligned + * with the anything->tgsi->nir path. + */ +static void +st_nir_fixup_varying_slots(struct st_context *st, struct exec_list *var_list) +{ + if (st->needs_texcoord_semantic) + return; + + nir_foreach_variable(var, var_list) { + if (var->data.location >= VARYING_SLOT_VAR0) { + var->data.location += 9; + } else if ((var->data.location >= VARYING_SLOT_TEX0) && + (var->data.location <= VARYING_SLOT_TEX7)) { + var->data.location += VARYING_SLOT_VAR0 - VARYING_SLOT_TEX0; + } + } +} + +/* input location assignment for VS inputs must be handled specially, so + * that it is aligned w/ st's vbo state. + * (This isn't the case with, for ex, FS inputs, which only need to agree + * on varying-slot w/ the VS outputs) + */ +static void +st_nir_assign_vs_in_locations(struct gl_program *prog, +
Mesa (master): scons: gallium: link against nir as needed
Module: Mesa Branch: master Commit: 52addd90d1406f9b156a384fe8b98dee27aeddf6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=52addd90d1406f9b156a384fe8b98dee27aeddf6 Author: Emil Velikov Date: Mon May 16 18:55:08 2016 +0100 scons: gallium: link against nir as needed ... otherwise we'll produce uncomplete binaries with introduction of NIR as alternative IR with next commits. Signed-off-by: Emil Velikov Acked-by: Jose Fonseca --- src/gallium/targets/dri/SConscript| 1 + src/gallium/targets/haiku-softpipe/SConscript | 1 + src/gallium/targets/libgl-gdi/SConscript | 2 +- src/gallium/targets/libgl-xlib/SConscript | 1 + src/gallium/targets/osmesa/SConscript | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/targets/dri/SConscript b/src/gallium/targets/dri/SConscript index bf3baa7..d7a8cbd 100644 --- a/src/gallium/targets/dri/SConscript +++ b/src/gallium/targets/dri/SConscript @@ -44,6 +44,7 @@ env.Prepend(LIBS = [ compiler, mesa, glsl, +nir, gallium, megadrivers_stub, dri_common, diff --git a/src/gallium/targets/haiku-softpipe/SConscript b/src/gallium/targets/haiku-softpipe/SConscript index b7c1373..f80c167 100644 --- a/src/gallium/targets/haiku-softpipe/SConscript +++ b/src/gallium/targets/haiku-softpipe/SConscript @@ -9,6 +9,7 @@ env.Prepend(LIBS = [ compiler, mesa, glsl, +nir, gallium ]) diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 3a63e3e..53284e5 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -50,7 +50,7 @@ if env['gles']: opengl32 = env.SharedLibrary( target ='opengl32', source = sources, -LIBS = wgl + ws_gdi + glapi + compiler + mesa + drivers + gallium + glsl + env['LIBS'], +LIBS = wgl + ws_gdi + glapi + compiler + mesa + drivers + gallium + glsl + nir + env['LIBS'], ) env.Alias('opengl32', opengl32) diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 1c816ff..0a4f31b 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -32,6 +32,7 @@ env.Prepend(LIBS = [ compiler, mesa, glsl, +nir, gallium, ]) diff --git a/src/gallium/targets/osmesa/SConscript b/src/gallium/targets/osmesa/SConscript index eeaacbc..7a2a00c 100644 --- a/src/gallium/targets/osmesa/SConscript +++ b/src/gallium/targets/osmesa/SConscript @@ -17,6 +17,7 @@ env.Prepend(LIBS = [ gallium, trace, glsl, +nir, mesautil, softpipe ]) ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa/st: add nir pass for lowering builtin uniforms
Module: Mesa Branch: master Commit: 8f9a46dccb938e3f0fcdc0390fcb449ca1f52067 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f9a46dccb938e3f0fcdc0390fcb449ca1f52067 Author: Rob Clark Date: Fri Jan 29 12:16:23 2016 -0500 mesa/st: add nir pass for lowering builtin uniforms Signed-off-by: Rob Clark Reviewed-by: Eric Anholt --- src/mesa/Makefile.sources | 2 + src/mesa/state_tracker/st_nir.h | 31 src/mesa/state_tracker/st_nir_lower_builtin.c | 245 ++ 3 files changed, 278 insertions(+) diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 14022ad..81928c8 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -497,6 +497,8 @@ STATETRACKER_FILES = \ state_tracker/st_manager.h \ state_tracker/st_mesa_to_tgsi.c \ state_tracker/st_mesa_to_tgsi.h \ + state_tracker/st_nir.h \ + state_tracker/st_nir_lower_builtin.c \ state_tracker/st_program.c \ state_tracker/st_program.h \ state_tracker/st_texture.c \ diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h new file mode 100644 index 000..1192981 --- /dev/null +++ b/src/mesa/state_tracker/st_nir.h @@ -0,0 +1,31 @@ +/* + * Copyright © 2016 Red Hat + * + * 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. + */ + +#ifndef ST_NIR_H +#define ST_NIR_H + +typedef struct nir_shader nir_shader; + +void st_nir_lower_builtin(nir_shader *shader); + +#endif /* ST_NIR_H */ diff --git a/src/mesa/state_tracker/st_nir_lower_builtin.c b/src/mesa/state_tracker/st_nir_lower_builtin.c new file mode 100644 index 000..b4da901 --- /dev/null +++ b/src/mesa/state_tracker/st_nir_lower_builtin.c @@ -0,0 +1,245 @@ +/* + * Copyright © 2016 Red Hat + * + * 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. + */ + +/* Lowering pass that lowers accesses to built-in uniform variables. + * Built-in uniforms are not necessarily packed the same way that + * normal uniform structs are, for example: + * + *struct gl_FogParameters { + * vec4 color; + * float density; + * float start; + * float end; + * float scale; + *}; + * + * is packed into vec4[2], whereas the same struct would be packed + * (by gallium), as vec4[5] if it where not built-in. Because of + * this, we need to replace (for example) access like: + * + *vec1 ssa_1 = intrinsic load_var () (gl_Fog.start) () + * + * with: + * + *vec4 ssa_2 = intrinsic load_var () (fog.params) () + *vec1 ssa_1 = ssa_2.y + * + * with appropriate substitutions in the uniform variables list: + * + *decl_var uniform INTERP_QUALIFIER_NONE gl_FogParameters gl_Fog (0, 0) + * + * would become: + * + *decl_var uniform INTERP_QUALIFIER_NONE vec4 state.
Mesa (master): freedreno/ir3: fix compiler warning
Module: Mesa Branch: master Commit: b65bd3dee5d84f4bd7806518282299960d426dc1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b65bd3dee5d84f4bd7806518282299960d426dc1 Author: Rob Clark Date: Mon May 16 13:37:24 2016 -0400 freedreno/ir3: fix compiler warning Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index fc66d7c..aa2d688 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -1448,6 +1448,7 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex) case nir_texop_query_levels: case nir_texop_texture_samples: case nir_texop_samples_identical: + case nir_texop_txf_ms_mcs: compile_error(ctx, "Unhandled NIR tex type: %d\n", tex->op); return; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/print: add support for print annotations
Module: Mesa Branch: master Commit: a0ef26c1c2f0fcdebfa2699817cf63f644df8155 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0ef26c1c2f0fcdebfa2699817cf63f644df8155 Author: Rob Clark Date: Sat May 14 15:37:32 2016 -0400 nir/print: add support for print annotations Caller can pass a hashtable mapping NIR object (currently instr or var, but I guess others could be added as needed) to annotation msg to print inline with the shader dump. As the annotation msg is printed, it is removed from the hashtable to give the caller a way to know about any unassociated msgs. This is used in the next patch, for nir_validate to try to associate error msgs to nir_print dump. Signed-off-by: Rob Clark Reviewed-by: Eduardo Lima Mitev Reviewed-by: Connor Abbott --- src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_print.c | 35 ++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index d4edea7..a21a7bd 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2213,6 +2213,7 @@ unsigned nir_index_instrs(nir_function_impl *impl); void nir_index_blocks(nir_function_impl *impl); void nir_print_shader(nir_shader *shader, FILE *fp); +void nir_print_shader_annotated(nir_shader *shader, FILE *fp, struct hash_table *errors); void nir_print_instr(const nir_instr *instr, FILE *fp); nir_shader *nir_shader_clone(void *mem_ctx, const nir_shader *s); diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 583f66c..021f0d6 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -53,9 +53,31 @@ typedef struct { /* an index used to make new non-conflicting names */ unsigned index; + + /** +* Optional table of annotations mapping nir object +* (such as instr or var) to message to print. +*/ + struct hash_table *annotations; } print_state; static void +print_annotation(print_state *state, void *obj) +{ + if (!state->annotations) + return; + + struct hash_entry *entry = _mesa_hash_table_search(state->annotations, obj); + if (!entry) + return; + + const char *note = entry->data; + _mesa_hash_table_remove(state->annotations, entry); + + fprintf(stderr, "%s\n\n", note); +} + +static void print_register(nir_register *reg, print_state *state) { FILE *fp = state->fp; @@ -413,6 +435,7 @@ print_var_decl(nir_variable *var, print_state *state) } fprintf(fp, "\n"); + print_annotation(state, var); } static void @@ -924,6 +947,7 @@ print_block(nir_block *block, print_state *state, unsigned tabs) nir_foreach_instr(instr, block) { print_instr(instr, state, tabs); fprintf(fp, "\n"); + print_annotation(state, instr); } print_tabs(tabs, fp); @@ -1096,11 +1120,14 @@ destroy_print_state(print_state *state) } void -nir_print_shader(nir_shader *shader, FILE *fp) +nir_print_shader_annotated(nir_shader *shader, FILE *fp, + struct hash_table *annotations) { print_state state; init_print_state(&state, shader, fp); + state.annotations = annotations; + fprintf(fp, "shader: %s\n", gl_shader_stage_name(shader->stage)); if (shader->info.name) @@ -1150,6 +1177,12 @@ nir_print_shader(nir_shader *shader, FILE *fp) } void +nir_print_shader(nir_shader *shader, FILE *fp) +{ + nir_print_shader_annotated(shader, fp, NULL); +} + +void nir_print_instr(const nir_instr *instr, FILE *fp) { print_state state = { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/validate: assert() -> validate_assert()
Module: Mesa Branch: master Commit: 54ecfcc162fd1598e49c7f7aba9b0fde7f4a97e2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=54ecfcc162fd1598e49c7f7aba9b0fde7f4a97e2 Author: Rob Clark Date: Mon May 16 12:44:59 2016 -0400 nir/validate: assert() -> validate_assert() Prep work for next patch. Signed-off-by: Rob Clark Reviewed-by: Connor Abbott --- src/compiler/nir/nir_validate.c | 254 1 file changed, 128 insertions(+), 126 deletions(-) diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 84334d4..4e786d4 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -97,38 +97,40 @@ typedef struct { struct hash_table *var_defs; } validate_state; +#define validate_assert(state, cond) assert(cond) + static void validate_src(nir_src *src, validate_state *state); static void validate_reg_src(nir_src *src, validate_state *state) { - assert(src->reg.reg != NULL); + validate_assert(state, src->reg.reg != NULL); struct hash_entry *entry; entry = _mesa_hash_table_search(state->regs, src->reg.reg); - assert(entry); + validate_assert(state, entry); reg_validate_state *reg_state = (reg_validate_state *) entry->data; if (state->instr) { _mesa_set_add(reg_state->uses, src); } else { - assert(state->if_stmt); + validate_assert(state, state->if_stmt); _mesa_set_add(reg_state->if_uses, src); } if (!src->reg.reg->is_global) { - assert(reg_state->where_defined == state->impl && + validate_assert(state, reg_state->where_defined == state->impl && "using a register declared in a different function"); } - assert((src->reg.reg->num_array_elems == 0 || + validate_assert(state, (src->reg.reg->num_array_elems == 0 || src->reg.base_offset < src->reg.reg->num_array_elems) && "definitely out-of-bounds array access"); if (src->reg.indirect) { - assert(src->reg.reg->num_array_elems != 0); - assert((src->reg.indirect->is_ssa || + validate_assert(state, src->reg.reg->num_array_elems != 0); + validate_assert(state, (src->reg.indirect->is_ssa || src->reg.indirect->reg.indirect == NULL) && "only one level of indirection allowed"); validate_src(src->reg.indirect, state); @@ -138,21 +140,21 @@ validate_reg_src(nir_src *src, validate_state *state) static void validate_ssa_src(nir_src *src, validate_state *state) { - assert(src->ssa != NULL); + validate_assert(state, src->ssa != NULL); struct hash_entry *entry = _mesa_hash_table_search(state->ssa_defs, src->ssa); - assert(entry); + validate_assert(state, entry); ssa_def_validate_state *def_state = (ssa_def_validate_state *)entry->data; - assert(def_state->where_defined == state->impl && + validate_assert(state, def_state->where_defined == state->impl && "using an SSA value defined in a different function"); if (state->instr) { _mesa_set_add(def_state->uses, src); } else { - assert(state->if_stmt); + validate_assert(state, state->if_stmt); _mesa_set_add(def_state->if_uses, src); } @@ -163,9 +165,9 @@ static void validate_src(nir_src *src, validate_state *state) { if (state->instr) - assert(src->parent_instr == state->instr); + validate_assert(state, src->parent_instr == state->instr); else - assert(src->parent_if == state->if_stmt); + validate_assert(state, src->parent_if == state->if_stmt); if (src->is_ssa) validate_ssa_src(src, state); @@ -191,27 +193,27 @@ validate_alu_src(nir_alu_instr *instr, unsigned index, validate_state *state) num_components = src->src.reg.reg->num_components; } for (unsigned i = 0; i < 4; i++) { - assert(src->swizzle[i] < 4); + validate_assert(state, src->swizzle[i] < 4); if (nir_alu_instr_channel_used(instr, index, i)) - assert(src->swizzle[i] < num_components); + validate_assert(state, src->swizzle[i] < num_components); } nir_alu_type src_type = nir_op_infos[instr->op].input_types[index]; /* 8-bit float isn't a thing */ if (nir_alu_type_get_base_type(src_type) == nir_type_float) - assert(src_bit_size == 16 || src_bit_size == 32 || src_bit_size == 64); + validate_assert(state, src_bit_size == 16 || src_bit_size == 32 || src_bit_size == 64); if (nir_alu_type_get_type_size(src_type)) { /* This source has an explicit bit size */ - assert(nir_alu_type_get_type_size(src_type) == src_bit_size); + validate_assert(state, nir
Mesa (master): nir/validate: dump annotated shader with error msgs
Module: Mesa Branch: master Commit: e8beffb1b3e989035b49b79a76b58f8cbf446ea4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e8beffb1b3e989035b49b79a76b58f8cbf446ea4 Author: Rob Clark Date: Sat May 14 15:40:54 2016 -0400 nir/validate: dump annotated shader with error msgs Log all the errors, and at the end dump the shader w/ error annotations to make it easier to see where the problems are. Signed-off-by: Rob Clark Reviewed-by: Eduardo Lima Mitev Reviewed-by: Connor Abbott --- src/compiler/nir/nir_validate.c | 63 - 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 4e786d4..b186fd5 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -69,6 +69,9 @@ typedef struct { /* the current instruction being validated */ nir_instr *instr; + /* the current variable being validated */ + nir_variable *var; + /* the current basic block being validated */ nir_block *block; @@ -95,9 +98,33 @@ typedef struct { /* map of local variable -> function implementation where it is defined */ struct hash_table *var_defs; + + /* map of instruction/var/etc to failed assert string */ + struct hash_table *errors; } validate_state; -#define validate_assert(state, cond) assert(cond) +static void +log_error(validate_state *state, const char *cond, const char *file, int line) +{ + const void *obj; + + if (state->instr) + obj = state->instr; + else if (state->var) + obj = state->var; + else + obj = cond; + + char *msg = ralloc_asprintf(state->errors, "error: %s (%s:%d)", + cond, file, line); + + _mesa_hash_table_insert(state->errors, obj, msg); +} + +#define validate_assert(state, cond) do { \ + if (!(cond))\ + log_error(state, #cond, __FILE__, __LINE__); \ + } while (0) static void validate_src(nir_src *src, validate_state *state); @@ -903,6 +930,8 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state) static void validate_var_decl(nir_variable *var, bool is_global, validate_state *state) { + state->var = var; + validate_assert(state, is_global == nir_variable_is_global(var)); /* Must have exactly one mode set */ @@ -916,6 +945,8 @@ validate_var_decl(nir_variable *var, bool is_global, validate_state *state) if (!is_global) { _mesa_hash_table_insert(state->var_defs, var, state->impl); } + + state->var = NULL; } static bool @@ -1044,7 +1075,12 @@ init_validate_state(validate_state *state) state->regs_found = NULL; state->var_defs = _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); + state->errors = _mesa_hash_table_create(NULL, _mesa_hash_pointer, + _mesa_key_pointer_equal); + state->loop = NULL; + state->instr = NULL; + state->var = NULL; } static void @@ -1055,6 +1091,28 @@ destroy_validate_state(validate_state *state) free(state->ssa_defs_found); free(state->regs_found); _mesa_hash_table_destroy(state->var_defs, NULL); + _mesa_hash_table_destroy(state->errors, NULL); +} + +static void +dump_errors(validate_state *state) +{ + struct hash_table *errors = state->errors; + + fprintf(stderr, "%d errors:\n", _mesa_hash_table_num_entries(errors)); + + nir_print_shader_annotated(state->shader, stderr, errors); + + if (_mesa_hash_table_num_entries(errors) > 0) { + fprintf(stderr, "%d additional errors:\n", + _mesa_hash_table_num_entries(errors)); + struct hash_entry *entry; + hash_table_foreach(errors, entry) { + fprintf(stderr, "%s\n", (char *)entry->data); + } + } + + abort(); } void @@ -1114,6 +1172,9 @@ nir_validate_shader(nir_shader *shader) postvalidate_reg_decl(reg, &state); } + if (_mesa_hash_table_num_entries(state.errors) > 0) + dump_errors(&state); + destroy_validate_state(&state); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: fix comment typo about f2d/d2f
Module: Mesa Branch: master Commit: 8b24f7b440f80cc2cba272b3b479ddd14a07602b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b24f7b440f80cc2cba272b3b479ddd14a07602b Author: Rob Clark Date: Fri May 13 15:26:15 2016 -0400 nir: fix comment typo about f2d/d2f Signed-off-by: Rob Clark Reviewed-by: Kenneth Graunke --- src/compiler/nir/nir_opcodes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 54ea720..8a3a80f 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -177,8 +177,8 @@ unop_convert("b2i", tint32, tbool, "src0 ? 1 : 0") # Boolean-to-int conversion unop_convert("u2f", tfloat32, tuint32, "src0") # Unsigned-to-float conversion. unop_convert("u2d", tfloat64, tuint32, "src0") # Unsigned-to-double conversion. # double-to-float conversion -unop_convert("d2f", tfloat32, tfloat64, "src0") # Single to double precision -unop_convert("f2d", tfloat64, tfloat32, "src0") # Double to single precision +unop_convert("d2f", tfloat32, tfloat64, "src0") # Double to single precision +unop_convert("f2d", tfloat64, tfloat32, "src0") # Single to double precision # Unary floating-point rounding operations. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/ir3: add support for NIR as preferred IR
Module: Mesa Branch: master Commit: 784086f3c1f50ca78fe62f925dfe66fb3aa5f22c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=784086f3c1f50ca78fe62f925dfe66fb3aa5f22c Author: Rob Clark Date: Mon Mar 28 10:28:29 2016 -0400 freedreno/ir3: add support for NIR as preferred IR For now under debug flag, since only suitable for debugging/testing. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/freedreno_screen.c | 20 - src/gallium/drivers/freedreno/freedreno_util.h | 1 + .../drivers/freedreno/ir3/ir3_compiler_nir.c | 8 ++ src/gallium/drivers/freedreno/ir3/ir3_nir.c| 33 +- src/gallium/drivers/freedreno/ir3/ir3_nir.h| 1 + src/gallium/drivers/freedreno/ir3/ir3_shader.c | 16 --- 6 files changed, 61 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 916151c..32db3e2 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -54,6 +54,8 @@ #include "a3xx/fd3_screen.h" #include "a4xx/fd4_screen.h" +#include "ir3/ir3_nir.h" + /* XXX this should go away */ #include "state_tracker/drm_driver.h" @@ -72,6 +74,7 @@ static const struct debug_named_value debug_options[] = { {"shaderdb", FD_DBG_SHADERDB, "Enable shaderdb output"}, {"flush", FD_DBG_FLUSH, "Force flush after every draw"}, {"deqp", FD_DBG_DEQP, "Enable dEQP hacks"}, + {"nir", FD_DBG_NIR,"Prefer NIR as native IR"}, DEBUG_NAMED_VALUE_END }; @@ -447,7 +450,7 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_DFRACEXP_DLDEXP_SUPPORTED: case PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED: -case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: + case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: return 0; case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: return 1; @@ -459,6 +462,8 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: return 16; case PIPE_SHADER_CAP_PREFERRED_IR: + if ((fd_mesa_debug & FD_DBG_NIR) && is_ir3(screen)) + return PIPE_SHADER_IR_NIR; return PIPE_SHADER_IR_TGSI; case PIPE_SHADER_CAP_SUPPORTED_IRS: return 0; @@ -472,6 +477,18 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, return 0; } +static const void * +fd_get_compiler_options(struct pipe_screen *pscreen, + enum pipe_shader_ir ir, unsigned shader) +{ + struct fd_screen *screen = fd_screen(pscreen); + + if (is_ir3(screen)) + return ir3_get_compiler_options(); + + return NULL; +} + boolean fd_screen_bo_get_handle(struct pipe_screen *pscreen, struct fd_bo *bo, @@ -630,6 +647,7 @@ fd_screen_create(struct fd_device *dev) pscreen->get_param = fd_screen_get_param; pscreen->get_paramf = fd_screen_get_paramf; pscreen->get_shader_param = fd_screen_get_shader_param; + pscreen->get_compiler_options = fd_get_compiler_options; fd_resource_screen_init(pscreen); fd_query_screen_init(pscreen); diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h index 34b21a3..330cff9 100644 --- a/src/gallium/drivers/freedreno/freedreno_util.h +++ b/src/gallium/drivers/freedreno/freedreno_util.h @@ -74,6 +74,7 @@ enum adreno_stencil_op fd_stencil_op(unsigned op); #define FD_DBG_SHADERDB 0x0800 #define FD_DBG_FLUSH0x1000 #define FD_DBG_DEQP 0x2000 +#define FD_DBG_NIR 0x4000 extern int fd_mesa_debug; extern bool fd_binning_enabled; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index 5f23272..a81aee3 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -2013,6 +2013,10 @@ setup_input(struct ir3_compile *ctx, nir_variable *in) DBG("; in: slot=%u, len=%ux%u, drvloc=%u", slot, array_len, ncomp, n); + /* let's pretend things other than vec4 don't exist: */ + ncomp = MAX2(ncomp, 4); + compile_assert(ctx, ncomp == 4); + so->inputs[n].slot = slot; so->inputs[n].compmask = (1 << ncomp) - 1; so->inputs_count = MAX2(so->inputs_count, n + 1); @@ -2094,6 +2098,10 @@ setup_output(struct ir3_compile *ctx, ni
Mesa (master): freedreno/ir3: disable TGSI specific hacks in nir case
Module: Mesa Branch: master Commit: 2f1581059b31a99e8f15dff6339a4bd80baebe1b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f1581059b31a99e8f15dff6339a4bd80baebe1b Author: Rob Clark Date: Mon Mar 21 11:42:04 2016 -0400 freedreno/ir3: disable TGSI specific hacks in nir case When we got NIR directly from state tracker (vs using tgsi_to_nir) we need to realize this and skip some TGSI specific hacks. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 1 + src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 4 ++-- src/gallium/drivers/freedreno/ir3/ir3_shader.c | 1 + src/gallium/drivers/freedreno/ir3/ir3_shader.h | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index 7007d20..47bcec4 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -241,6 +241,7 @@ int main(int argc, char **argv) tgsi_dump(toks, 0); nir_shader *nir = ir3_tgsi_to_nir(toks); + s.from_tgsi = true; s.compiler = ir3_compiler_create(NULL, gpu_id); s.nir = ir3_optimize_nir(&s, nir, NULL); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index a81aee3..33b2b7b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -2488,8 +2488,8 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler, /* preserve hack for depth output.. tgsi writes depth to .z, * but what we give the hw is the scalar register: */ - if ((so->type == SHADER_FRAGMENT) && - (so->outputs[i].slot == FRAG_RESULT_DEPTH)) + if (so->shader->from_tgsi && (so->type == SHADER_FRAGMENT) && + (so->outputs[i].slot == FRAG_RESULT_DEPTH)) so->outputs[i].regid += 2; } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index cd596cf..ee0018f 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -294,6 +294,7 @@ ir3_shader_create(struct ir3_compiler *compiler, tgsi_dump(cso->tokens, 0); } nir = ir3_tgsi_to_nir(cso->tokens); + shader->from_tgsi = true; } /* do first pass optimization, ignoring the key: */ shader->nir = ir3_optimize_nir(shader, nir, NULL); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h index 077ba5d..c17a76b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h @@ -252,6 +252,9 @@ struct ir3_shader { uint32_t id; uint32_t variant_count; + /* so we know when we can disable TGSI related hacks: */ + bool from_tgsi; + struct ir3_compiler *compiler; nir_shader *nir; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: forward-declare 'struct gl_shader_program'
Module: Mesa Branch: master Commit: f06343d6eabf8f91e4cfb2b2d7313e9d5ca0797a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f06343d6eabf8f91e4cfb2b2d7313e9d5ca0797a Author: Rob Clark Date: Sat May 14 13:35:54 2016 -0400 nir: forward-declare 'struct gl_shader_program' Drop extra #include which is otherwise unneeded (and makes this header difficult to include from outside of src/mesa). Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand --- src/compiler/nir/glsl_to_nir.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/glsl_to_nir.h b/src/compiler/nir/glsl_to_nir.h index e3fe9b0..14641fc 100644 --- a/src/compiler/nir/glsl_to_nir.h +++ b/src/compiler/nir/glsl_to_nir.h @@ -26,12 +26,13 @@ */ #include "nir.h" -#include "compiler/glsl/glsl_parser_extras.h" #ifdef __cplusplus extern "C" { #endif +struct gl_shader_program; + nir_shader *glsl_to_nir(const struct gl_shader_program *shader_prog, gl_shader_stage stage, const nir_shader_compiler_options *options); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/ir3: small standalone compiler cleanup
Module: Mesa Branch: master Commit: 277818ecfb3d7a2ac840b0c36e3586b2fdac1a52 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=277818ecfb3d7a2ac840b0c36e3586b2fdac1a52 Author: Rob Clark Date: Sat May 14 13:39:57 2016 -0400 freedreno/ir3: small standalone compiler cleanup Don't hard-code the gpu-id anymore. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index 47bcec4..42beb4d 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -48,8 +48,7 @@ static void dump_info(struct ir3_shader_variant *so, const char *str) { uint32_t *bin; const char *type = ir3_shader_stage(so->shader); - // TODO make gpu_id configurable on cmdline - bin = ir3_shader_assemble(so, 320); + bin = ir3_shader_assemble(so, so->shader->compiler->gpu_id); debug_printf("; %s: %s\n", type, str); ir3_shader_disasm(so, bin); free(bin); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: return progress from lower_idiv
Module: Mesa Branch: master Commit: 79d6409a1467127daaea8a98e6d8c14779180a79 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=79d6409a1467127daaea8a98e6d8c14779180a79 Author: Rob Clark Date: Mon May 9 12:36:03 2016 -0400 nir: return progress from lower_idiv With algebraic-opt support for lowering div to shift, the driver would like to be able to run this pass *after* the main opt-loop, and then conditionally re-run the opt-loop if this pass actually lowered some- thing. Signed-off-by: Rob Clark Reviewed-by: Kenneth Graunke --- src/compiler/nir/nir.h| 2 +- src/compiler/nir/nir_lower_idiv.c | 21 +++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index dd91994..2227910 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2379,7 +2379,7 @@ typedef struct nir_lower_tex_options { bool nir_lower_tex(nir_shader *shader, const nir_lower_tex_options *options); -void nir_lower_idiv(nir_shader *shader); +bool nir_lower_idiv(nir_shader *shader); void nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables); void nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables); diff --git a/src/compiler/nir/nir_lower_idiv.c b/src/compiler/nir/nir_lower_idiv.c index f2e7cde..b1e7aeb 100644 --- a/src/compiler/nir/nir_lower_idiv.c +++ b/src/compiler/nir/nir_lower_idiv.c @@ -36,7 +36,7 @@ * branch out to a pre-optimized shader library routine.. */ -static void +static bool convert_instr(nir_builder *bld, nir_alu_instr *alu) { nir_ssa_def *numer, *denom, *af, *bf, *a, *b, *q, *r; @@ -46,7 +46,7 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu) if ((op != nir_op_idiv) && (op != nir_op_udiv) && (op != nir_op_umod)) - return; + return false; is_signed = (op == nir_op_idiv); @@ -115,30 +115,39 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu) assert(alu->dest.dest.is_ssa); nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(q)); + + return true; } -static void +static bool convert_impl(nir_function_impl *impl) { nir_builder b; nir_builder_init(&b, impl); + bool progress = false; nir_foreach_block(block, impl) { nir_foreach_instr_safe(instr, block) { if (instr->type == nir_instr_type_alu) -convert_instr(&b, nir_instr_as_alu(instr)); +progress |= convert_instr(&b, nir_instr_as_alu(instr)); } } nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + + return progress; } -void +bool nir_lower_idiv(nir_shader *shader) { + bool progress = false; + nir_foreach_function(function, shader) { if (function->impl) - convert_impl(function->impl); + progress |= convert_impl(function->impl); } + + return progress; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/ir3: lower fdiv
Module: Mesa Branch: master Commit: f8840f471deb86ee8a545255cea0a889557846e9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8840f471deb86ee8a545255cea0a889557846e9 Author: Rob Clark Date: Sat May 14 13:40:48 2016 -0400 freedreno/ir3: lower fdiv Not sure how we didn't hit this already, but since we want fdiv converted into mul + rcp, we should set this. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_nir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_nir.c index eda8ce2..9365e33 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.c @@ -42,6 +42,7 @@ static const nir_shader_compiler_options options = { .lower_flrp32 = true, .lower_flrp64 = true, .lower_ffract = true, + .lower_fdiv = true, .fuse_ffma = true, .native_integers = true, .vertex_id_zero_based = true, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno/ir3: handle VARYING_SLOT_PNTC
Module: Mesa Branch: master Commit: 53cde5e295077e2a51df3a3d0db474cff5c10313 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=53cde5e295077e2a51df3a3d0db474cff5c10313 Author: Rob Clark Date: Mon Mar 21 13:56:04 2016 -0400 freedreno/ir3: handle VARYING_SLOT_PNTC In the glsl->tgsi path, this already gets translated to VAR8, which matches up with rasterizer->sprite_coord_enable. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 12 1 file changed, 12 insertions(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index 33b2b7b..fc66d7c 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -2031,6 +2031,18 @@ setup_input(struct ir3_compile *ctx, nir_variable *in) so->inputs[n].bary = false; so->frag_coord = true; instr = create_frag_coord(ctx, i); + } else if (slot == VARYING_SLOT_PNTC) { + /* see for example st_get_generic_varying_index().. this is +* maybe a bit mesa/st specific. But we need things to line +* up for this in fdN_program: +*unsigned texmask = 1 << (slot - VARYING_SLOT_VAR0); +*if (emit->sprite_coord_enable & texmask) { +* ... +*} +*/ + so->inputs[n].slot = VARYING_SLOT_VAR8; + so->inputs[n].bary = true; + instr = create_frag_input(ctx, false); } else if (slot == VARYING_SLOT_FACE) { so->inputs[n].bary = false; so->frag_face = true; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: glsl_get_bit_size() should take glsl_type
Module: Mesa Branch: master Commit: 9d3cc80b752b236bc51b78a3d99920748a1a230a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d3cc80b752b236bc51b78a3d99920748a1a230a Author: Rob Clark Date: Wed May 11 15:05:09 2016 -0400 nir: glsl_get_bit_size() should take glsl_type It's what all the call-sites once, so gets rid of a bunch of inlined glsl_get_base_type() at the call-sites. Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand --- src/compiler/nir/glsl_to_nir.cpp| 16 src/compiler/nir/nir.c | 2 +- src/compiler/nir/nir_builder.h | 2 +- src/compiler/nir/nir_lower_locals_to_regs.c | 2 +- src/compiler/nir/nir_lower_var_copies.c | 3 +-- src/compiler/nir/nir_lower_vars_to_ssa.c| 2 +- src/compiler/nir_types.h| 4 ++-- src/compiler/spirv/spirv_to_nir.c | 6 +++--- src/compiler/spirv/vtn_variables.c | 4 ++-- 9 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp index a86b966..aeeba5d 100644 --- a/src/compiler/nir/glsl_to_nir.cpp +++ b/src/compiler/nir/glsl_to_nir.cpp @@ -856,7 +856,7 @@ nir_visitor::visit(ir_call *ir) instr->num_components = type->vector_elements; /* Setup destination register */ - unsigned bit_size = glsl_get_bit_size(type->base_type); + unsigned bit_size = glsl_get_bit_size(type); nir_ssa_dest_init(&instr->instr, &instr->dest, type->vector_elements, bit_size, NULL); @@ -942,7 +942,7 @@ nir_visitor::visit(ir_call *ir) instr->num_components = type->vector_elements; /* Setup destination register */ - unsigned bit_size = glsl_get_bit_size(type->base_type); + unsigned bit_size = glsl_get_bit_size(type); nir_ssa_dest_init(&instr->instr, &instr->dest, type->vector_elements, bit_size, NULL); @@ -1005,7 +1005,7 @@ nir_visitor::visit(ir_call *ir) /* Atomic result */ assert(ir->return_deref); - unsigned bit_size = glsl_get_bit_size(ir->return_deref->type->base_type); + unsigned bit_size = glsl_get_bit_size(ir->return_deref->type); nir_ssa_dest_init(&instr->instr, &instr->dest, ir->return_deref->type->vector_elements, bit_size, NULL); @@ -1186,7 +1186,7 @@ nir_visitor::evaluate_rvalue(ir_rvalue* ir) load_instr->num_components = ir->type->vector_elements; load_instr->variables[0] = this->deref_head; ralloc_steal(load_instr, load_instr->variables[0]); - unsigned bit_size = glsl_get_bit_size(ir->type->base_type); + unsigned bit_size = glsl_get_bit_size(ir->type); add_instr(&load_instr->instr, ir->type->vector_elements, bit_size); } @@ -1207,7 +1207,7 @@ nir_visitor::visit(ir_expression *ir) case ir_binop_ubo_load: { nir_intrinsic_instr *load = nir_intrinsic_instr_create(this->shader, nir_intrinsic_load_ubo); - unsigned bit_size = glsl_get_bit_size(ir->type->base_type); + unsigned bit_size = glsl_get_bit_size(ir->type); load->num_components = ir->type->vector_elements; load->src[0] = nir_src_for_ssa(evaluate_rvalue(ir->operands[0])); load->src[1] = nir_src_for_ssa(evaluate_rvalue(ir->operands[1])); @@ -1276,7 +1276,7 @@ nir_visitor::visit(ir_expression *ir) intrin->intrinsic == nir_intrinsic_interp_var_at_sample) intrin->src[0] = nir_src_for_ssa(evaluate_rvalue(ir->operands[1])); - unsigned bit_size = glsl_get_bit_size(deref->type->base_type); + unsigned bit_size = glsl_get_bit_size(deref->type); add_instr(&intrin->instr, deref->type->vector_elements, bit_size); if (swizzle) { @@ -1496,7 +1496,7 @@ nir_visitor::visit(ir_expression *ir) nir_intrinsic_get_buffer_size); load->num_components = ir->type->vector_elements; load->src[0] = nir_src_for_ssa(evaluate_rvalue(ir->operands[0])); - unsigned bit_size = glsl_get_bit_size(ir->type->base_type); + unsigned bit_size = glsl_get_bit_size(ir->type); add_instr(&load->instr, ir->type->vector_elements, bit_size); return; } @@ -1934,7 +1934,7 @@ nir_visitor::visit(ir_texture *ir) assert(src_number == num_srcs); - unsigned bit_size = glsl_get_bit_size(ir->type->base_type); + unsigned bit_size = glsl_get_bit_size(ir->type); add_instr(&instr->instr, nir_tex_instr_dest_size(instr), bit_size); } diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 867a43c..71adcb3 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/ni
Mesa (master): anv: fix build break
Module: Mesa Branch: master Commit: 5886d1bad13a1c0106b7f42191bbc399fff4a0d9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5886d1bad13a1c0106b7f42191bbc399fff4a0d9 Author: Rob Clark Date: Wed May 11 14:03:24 2016 -0400 anv: fix build break Previous rename of lower-output-to-temps pass predated merging of anv, and apparently vulkan wasn't enabled in my local builds so overlooked this when rebasing. Reported-by: Mark Janes Signed-off-by: Rob Clark --- src/intel/vulkan/anv_pipeline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index ba088b6..5800e68 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -161,7 +161,7 @@ anv_shader_compile_to_nir(struct anv_device *device, nir_remove_dead_variables(nir, nir_var_system_value); nir_validate_shader(nir); - nir_lower_outputs_to_temporaries(entry_point->shader, entry_point); + nir_lower_io_to_temporaries(entry_point->shader, entry_point, true, false); nir_lower_system_values(nir); nir_validate_shader(nir); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa/st: split the type_size calculation into it's own file
Module: Mesa Branch: master Commit: 697382eb61a9091ea0fa8b5836c9e7d281e9e1c5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=697382eb61a9091ea0fa8b5836c9e7d281e9e1c5 Author: Rob Clark Date: Thu Mar 24 14:14:36 2016 -0400 mesa/st: split the type_size calculation into it's own file We'll want to re-use this for NIR. Signed-off-by: Rob Clark Reviewed-by: Marek Olšák --- src/mesa/Makefile.sources | 2 + src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 64 +- src/mesa/state_tracker/st_glsl_types.cpp | 101 + src/mesa/state_tracker/st_glsl_types.h | 44 + 4 files changed, 150 insertions(+), 61 deletions(-) diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 2ffbb15..14022ad 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -491,6 +491,8 @@ STATETRACKER_FILES = \ state_tracker/st_gl_api.h \ state_tracker/st_glsl_to_tgsi.cpp \ state_tracker/st_glsl_to_tgsi.h \ + state_tracker/st_glsl_types.cpp \ + state_tracker/st_glsl_types.h \ state_tracker/st_manager.c \ state_tracker/st_manager.h \ state_tracker/st_mesa_to_tgsi.c \ diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9cf204a..58b6634 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -52,6 +52,7 @@ #include "st_program.h" #include "st_mesa_to_tgsi.h" #include "st_format.h" +#include "st_glsl_types.h" #define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) |\ @@ -1165,72 +1166,13 @@ glsl_to_tgsi_visitor::st_src_reg_for_type(int type, int val) static int attrib_type_size(const struct glsl_type *type, bool is_vs_input) { - unsigned int i; - int size; - - switch (type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - if (type->is_matrix()) { - return type->matrix_columns; - } else { - /* Regardless of size of vector, it gets a vec4. This is bad - * packing for things like floats, but otherwise arrays become a - * mess. Hopefully a later pass over the code can pack scalars - * down if appropriate. - */ - return 1; - } - break; - case GLSL_TYPE_DOUBLE: - if (type->is_matrix()) { - if (type->vector_elements <= 2 || is_vs_input) -return type->matrix_columns; - else -return type->matrix_columns * 2; - } else { - /* For doubles if we have a double or dvec2 they fit in one - * vec4, else they need 2 vec4s. - */ - if (type->vector_elements <= 2 || is_vs_input) -return 1; - else -return 2; - } - break; - case GLSL_TYPE_ARRAY: - assert(type->length > 0); - return attrib_type_size(type->fields.array, is_vs_input) * type->length; - case GLSL_TYPE_STRUCT: - size = 0; - for (i = 0; i < type->length; i++) { - size += attrib_type_size(type->fields.structure[i].type, is_vs_input); - } - return size; - case GLSL_TYPE_SAMPLER: - case GLSL_TYPE_IMAGE: - case GLSL_TYPE_SUBROUTINE: - /* Samplers take up one slot in UNIFORMS[], but they're baked in - * at link time. - */ - return 1; - case GLSL_TYPE_ATOMIC_UINT: - case GLSL_TYPE_INTERFACE: - case GLSL_TYPE_VOID: - case GLSL_TYPE_ERROR: - case GLSL_TYPE_FUNCTION: - assert(!"Invalid type in type_size"); - break; - } - return 0; + return st_glsl_attrib_type_size(type, is_vs_input); } static int type_size(const struct glsl_type *type) { - return attrib_type_size(type, false); + return st_glsl_type_size(type); } /** diff --git a/src/mesa/state_tracker/st_glsl_types.cpp b/src/mesa/state_tracker/st_glsl_types.cpp new file mode 100644 index 000..857e143 --- /dev/null +++ b/src/mesa/state_tracker/st_glsl_types.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 VMware, Inc. All Rights Reserved. + * Copyright © 2010 Intel Corporation + * Copyright © 2011 Bryan Cain + * + * 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 co
Mesa (master): nir: lower-io-types pass
Module: Mesa Branch: master Commit: 5261947260bf63693fc13eaaf8a1e845ab130a57 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5261947260bf63693fc13eaaf8a1e845ab130a57 Author: Rob Clark Date: Fri Mar 25 15:15:44 2016 -0400 nir: lower-io-types pass A pass to lower complex (struct/array/mat) inputs/outputs to primitive types. This allows, for example, linking that removes unused components of a larger type which is not indirectly accessed. In the near term, it is needed for gallium (mesa/st) support for NIR, since only used components of a type are assigned VBO slots, and we otherwise have no way to represent that to the driver backend. But it should be useful for doing shader linking in NIR. v2: use glsl_count_attribute_slots() rather than passing a type_size fxn pointer Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand --- src/compiler/Makefile.sources | 1 + src/compiler/nir/nir.h| 1 + src/compiler/nir/nir_lower_io_types.c | 180 ++ 3 files changed, 182 insertions(+) diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources index 63fbbd0..fabab77 100644 --- a/src/compiler/Makefile.sources +++ b/src/compiler/Makefile.sources @@ -199,6 +199,7 @@ NIR_FILES = \ nir/nir_lower_idiv.c \ nir/nir_lower_indirect_derefs.c \ nir/nir_lower_io.c \ + nir/nir_lower_io_types.c \ nir/nir_lower_outputs_to_temporaries.c \ nir/nir_lower_passthrough_edgeflags.c \ nir/nir_lower_phis_to_scalar.c \ diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 5177341..68f948e 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2293,6 +2293,7 @@ void nir_lower_io(nir_shader *shader, nir_src *nir_get_io_offset_src(nir_intrinsic_instr *instr); nir_src *nir_get_io_vertex_index_src(nir_intrinsic_instr *instr); +void nir_lower_io_types(nir_shader *shader); void nir_lower_vars_to_ssa(nir_shader *shader); bool nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes); diff --git a/src/compiler/nir/nir_lower_io_types.c b/src/compiler/nir/nir_lower_io_types.c new file mode 100644 index 000..6b29f81 --- /dev/null +++ b/src/compiler/nir/nir_lower_io_types.c @@ -0,0 +1,180 @@ +/* + * Copyright © 2016 Red Hat + * + * 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 "nir.h" +#include "nir_builder.h" + +/* Lower complex (struct/array/mat) input and output vars to primitive types + * (vec4) for linking. All indirect input/output access should already be + * lowered (ie. nir_lower_io_to_temporaries). + */ + +struct lower_io_types_state { + nir_shader *shader; + struct exec_list new_ins; + struct exec_list new_outs; +}; + +static nir_variable * +get_new_var(struct lower_io_types_state *state, nir_variable *var, +const struct glsl_type *deref_type, unsigned off) +{ + struct exec_list *list; + + if (var->data.mode == nir_var_shader_in) { + list = &state->new_ins; + } else { + assert(var->data.mode == nir_var_shader_out); + list = &state->new_outs; + } + + nir_foreach_variable(nvar, list) { + if (nvar->data.location == (var->data.location + off)) + return nvar; + } + + /* doesn't already exist, so we need to create a new one: */ + /* TODO figure out if scalar vs vec, and if float/int/uint/(double?) +* do we need to fixup interpolation mode for int vs float components +* of a struct, etc.. +*/ + const struct glsl_type *ntype = + glsl_vector_type(glsl_get_base_type(deref_type), + glsl_get_vector_elements(deref_type)); + nir_variable *nvar = nir_variable_create(state->shader, var->data.mode, +ntype, NULL); + + nvar->name = ralloc_asprintf(nva
Mesa (master): glsl: export accessor for builtin-uniform descriptors
Module: Mesa Branch: master Commit: 0e5a369879e33085fbbd2dfce4e77799c4c95d30 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e5a369879e33085fbbd2dfce4e77799c4c95d30 Author: Rob Clark Date: Fri Jan 29 11:18:11 2016 -0500 glsl: export accessor for builtin-uniform descriptors We'll need this for a nir pass to lower builtin-uniform access. Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand --- src/compiler/glsl/builtin_variables.cpp | 21 - src/compiler/glsl/ir.h | 3 +++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp index f31f9f6..cc32990 100644 --- a/src/compiler/glsl/builtin_variables.cpp +++ b/src/compiler/glsl/builtin_variables.cpp @@ -527,6 +527,16 @@ builtin_variable_generator::add_variable(const char *name, return var; } +extern "C" const struct gl_builtin_uniform_desc * +_mesa_glsl_get_builtin_uniform_desc(const char *name) +{ + for (unsigned i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) { + if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) { + return &_mesa_builtin_uniform_desc[i]; + } + } + return NULL; +} ir_variable * builtin_variable_generator::add_uniform(const glsl_type *type, @@ -534,16 +544,9 @@ builtin_variable_generator::add_uniform(const glsl_type *type, { ir_variable *const uni = add_variable(name, type, ir_var_uniform, -1); - unsigned i; - for (i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) { - if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) { -break; - } - } - - assert(_mesa_builtin_uniform_desc[i].name != NULL); const struct gl_builtin_uniform_desc* const statevar = - &_mesa_builtin_uniform_desc[i]; + _mesa_glsl_get_builtin_uniform_desc(name); + assert(statevar != NULL); const unsigned array_count = type->is_array() ? type->length : 1; diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h index 0c319ea..6e0dc0b 100644 --- a/src/compiler/glsl/ir.h +++ b/src/compiler/glsl/ir.h @@ -2626,6 +2626,9 @@ extern void _mesa_print_ir(FILE *f, struct exec_list *instructions, extern void fprint_ir(FILE *f, const void *instruction); +extern const struct gl_builtin_uniform_desc * +_mesa_glsl_get_builtin_uniform_desc(const char *name); + #ifdef __cplusplus } /* extern "C" */ #endif ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/lower-io: add support for lowering inputs
Module: Mesa Branch: master Commit: dfbabc6bad775e1575ff4a97a3c871341cd57f77 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfbabc6bad775e1575ff4a97a3c871341cd57f77 Author: Rob Clark Date: Fri Mar 25 15:10:50 2016 -0400 nir/lower-io: add support for lowering inputs Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir.h | 3 +- src/compiler/nir/nir_lower_io_to_temporaries.c | 51 ++ src/mesa/drivers/dri/i965/brw_nir.c| 4 +- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 5410f0b..c96eaf9 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2279,7 +2279,8 @@ bool nir_lower_indirect_derefs(nir_shader *shader, nir_variable_mode modes); bool nir_lower_locals_to_regs(nir_shader *shader); -void nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint); +void nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint, + bool outputs, bool inputs); void nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint); diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c index 4b4363b..3153a49 100644 --- a/src/compiler/nir/nir_lower_io_to_temporaries.c +++ b/src/compiler/nir/nir_lower_io_to_temporaries.c @@ -22,9 +22,12 @@ */ /* - * Implements a pass that lowers output variables to a temporary plus an - * output variable with a single copy at each exit point of the shader. - * This way the output variable is only ever written. + * Implements a pass that lowers output and/or input variables to a + * temporary plus an output variable with a single copy at each exit + * point of the shader and/or an input variable with a single copy + * at the entrance point of the shader. This way the output variable + * is only ever written once and/or input is only read once, and there + * are no indirect outut/input accesses. */ #include "nir.h" @@ -33,6 +36,7 @@ struct lower_io_state { nir_shader *shader; nir_function *entrypoint; struct exec_list old_outputs; + struct exec_list old_inputs; }; static void @@ -88,6 +92,16 @@ emit_output_copies_impl(struct lower_io_state *state, nir_function_impl *impl) } } +static void +emit_input_copies_impl(struct lower_io_state *state, nir_function_impl *impl) +{ + if (impl->function == state->entrypoint) { + nir_cursor cursor = nir_before_block(nir_start_block(impl)); + emit_copies(cursor, state->shader, &state->old_inputs, + &state->shader->inputs); + } +} + static nir_variable * create_shadow_temp(struct lower_io_state *state, nir_variable *var) { @@ -103,8 +117,8 @@ create_shadow_temp(struct lower_io_state *state, nir_variable *var) /* Reparent the constant initializer (if any) */ ralloc_steal(nvar, nvar->constant_initializer); - /* Give the output a new name with @out-temp appended */ - const char *mode = "out"; + /* Give the original a new name with @-temp appended */ + const char *mode = (temp->data.mode == nir_var_shader_in) ? "in" : "out"; temp->name = ralloc_asprintf(var, "%s@%s-temp", mode, nvar->name); temp->data.mode = nir_var_global; temp->constant_initializer = NULL; @@ -113,7 +127,8 @@ create_shadow_temp(struct lower_io_state *state, nir_variable *var) } void -nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint) +nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint, +bool outputs, bool inputs) { struct lower_io_state state; @@ -122,7 +137,16 @@ nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint) state.shader = shader; state.entrypoint = entrypoint; - exec_list_move_nodes_to(&shader->outputs, &state.old_outputs); + + if (inputs) + exec_list_move_nodes_to(&shader->inputs, &state.old_inputs); + else + exec_list_make_empty(&state.old_inputs); + + if (outputs) + exec_list_move_nodes_to(&shader->outputs, &state.old_outputs); + else + exec_list_make_empty(&state.old_outputs); /* Walk over all of the outputs turn each output into a temporary and * make a new variable for the actual output. @@ -132,15 +156,26 @@ nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint) exec_list_push_tail(&shader->outputs, &output->node); } + /* and same for inputs: */ + nir_foreach_variable(var, &state.old_inputs) { + nir_variable *input = create_shadow_temp(&state, var); + exec_list_push_tail(&shader->inputs, &input->node); + } + nir_foreach_function(function, shader) { if (function->impl =
Mesa (master): nir: rename lower_outputs_to_temporaries -> lower_io_to_temporaries
Module: Mesa Branch: master Commit: b085016f94721a6c18f7076fc37c450a98e6bdbc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b085016f94721a6c18f7076fc37c450a98e6bdbc Author: Rob Clark Date: Fri Mar 25 13:52:26 2016 -0400 nir: rename lower_outputs_to_temporaries -> lower_io_to_temporaries Since it will gain support to lower inputs, give it a more generic name. Signed-off-by: Rob Clark --- src/compiler/Makefile.sources | 2 +- src/compiler/nir/nir.h| 4 ++-- ...wer_outputs_to_temporaries.c => nir_lower_io_to_temporaries.c} | 8 src/mesa/drivers/dri/i965/brw_nir.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources index fabab77..66fbd84 100644 --- a/src/compiler/Makefile.sources +++ b/src/compiler/Makefile.sources @@ -199,8 +199,8 @@ NIR_FILES = \ nir/nir_lower_idiv.c \ nir/nir_lower_indirect_derefs.c \ nir/nir_lower_io.c \ + nir/nir_lower_io_to_temporaries.c \ nir/nir_lower_io_types.c \ - nir/nir_lower_outputs_to_temporaries.c \ nir/nir_lower_passthrough_edgeflags.c \ nir/nir_lower_phis_to_scalar.c \ nir/nir_lower_returns.c \ diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 68f948e..5410f0b 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2279,8 +2279,8 @@ bool nir_lower_indirect_derefs(nir_shader *shader, nir_variable_mode modes); bool nir_lower_locals_to_regs(nir_shader *shader); -void nir_lower_outputs_to_temporaries(nir_shader *shader, - nir_function *entrypoint); +void nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint); + void nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint); void nir_assign_var_locations(struct exec_list *var_list, diff --git a/src/compiler/nir/nir_lower_outputs_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c similarity index 95% rename from src/compiler/nir/nir_lower_outputs_to_temporaries.c rename to src/compiler/nir/nir_lower_io_to_temporaries.c index 0dfb7b0..bf16aec 100644 --- a/src/compiler/nir/nir_lower_outputs_to_temporaries.c +++ b/src/compiler/nir/nir_lower_io_to_temporaries.c @@ -29,13 +29,13 @@ #include "nir.h" -struct lower_outputs_state { +struct lower_io_state { nir_shader *shader; struct exec_list old_outputs; }; static void -emit_output_copies(nir_cursor cursor, struct lower_outputs_state *state) +emit_output_copies(nir_cursor cursor, struct lower_io_state *state) { assert(exec_list_length(&state->shader->outputs) == exec_list_length(&state->old_outputs)); @@ -55,9 +55,9 @@ emit_output_copies(nir_cursor cursor, struct lower_outputs_state *state) } void -nir_lower_outputs_to_temporaries(nir_shader *shader, nir_function *entrypoint) +nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint) { - struct lower_outputs_state state; + struct lower_io_state state; if (shader->stage == MESA_SHADER_TESS_CTRL) return; diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c index fb658ec..07d24b2 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.c +++ b/src/mesa/drivers/dri/i965/brw_nir.c @@ -563,7 +563,7 @@ brw_create_nir(struct brw_context *brw, /* First, lower the GLSL IR or Mesa IR to NIR */ if (shader_prog) { nir = glsl_to_nir(shader_prog, stage, options); - OPT_V(nir_lower_outputs_to_temporaries, nir_shader_get_entrypoint(nir)); + OPT_V(nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir)); } else { nir = prog_to_nir(prog, options); OPT_V(nir_convert_to_ssa); /* turn registers into SSA */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): gallium: refactor pipe_shader_state to support multiple IR' s
Module: Mesa Branch: master Commit: 425dc4c4b3663c619634de9f9f00c7765e7d0320 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=425dc4c4b3663c619634de9f9f00c7765e7d0320 Author: Rob Clark Date: Sat Oct 17 13:34:24 2015 -0400 gallium: refactor pipe_shader_state to support multiple IR's The goal is to allow the pipe driver to request something other than TGSI, but detect whether what is getting is TGSI vs what it requested. The pipe drivers will always have to support TGSI (and convert that into whatever it is that they prefer), but in some cases we should be able to skip the TGSI intermediate step (such as glsl->nir vs glsl->tgsi->nir). I think pipe_compute_state should get similar treatment. Currently, afaict, it has one user and one consumer, which has allowed it to be sloppy wrt. supporting alternative IR's. Signed-off-by: Rob Clark Reviewed-by: Roland Scheidegger Reviewed-by: Marek Olšák --- src/gallium/auxiliary/hud/hud_context.c | 9 - src/gallium/auxiliary/postprocess/pp_run.c| 3 +-- src/gallium/auxiliary/tgsi/tgsi_ureg.c| 4 +--- src/gallium/auxiliary/util/u_simple_shaders.c | 18 -- src/gallium/auxiliary/util/u_tests.c | 3 ++- src/gallium/include/pipe/p_defines.h | 12 ++-- src/gallium/include/pipe/p_state.h| 26 +- 7 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 146c7cc..7870da5 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -1202,7 +1202,7 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso) }; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; + struct pipe_shader_state state; if (!tgsi_text_translate(fragment_shader_text, tokens, ARRAY_SIZE(tokens))) { assert(0); @@ -1211,7 +1211,7 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso) FREE(hud); return NULL; } - + pipe_shader_state_from_tgsi(&state, tokens); hud->fs_text = pipe->create_fs_state(pipe, &state); } @@ -1249,8 +1249,7 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso) }; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; - + struct pipe_shader_state state; if (!tgsi_text_translate(vertex_shader_text, tokens, ARRAY_SIZE(tokens))) { assert(0); pipe_resource_reference(&hud->font.texture, NULL); @@ -1258,7 +1257,7 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso) FREE(hud); return NULL; } - + pipe_shader_state_from_tgsi(&state, tokens); hud->vs = pipe->create_vs_state(pipe, &state); } diff --git a/src/gallium/auxiliary/postprocess/pp_run.c b/src/gallium/auxiliary/postprocess/pp_run.c index bc79c5a..41fa7ed 100644 --- a/src/gallium/auxiliary/postprocess/pp_run.c +++ b/src/gallium/auxiliary/postprocess/pp_run.c @@ -255,8 +255,7 @@ pp_tgsi_to_state(struct pipe_context *pipe, const char *text, bool isvs, return NULL; } - state.tokens = tokens; - memset(&state.stream_output, 0, sizeof(state.stream_output)); + pipe_shader_state_from_tgsi(&state, tokens); if (isvs) { ret_state = pipe->create_vs_state(pipe, &state); diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 43b8bb1..b67c383 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -2019,14 +2019,12 @@ void *ureg_create_shader( struct ureg_program *ureg, { struct pipe_shader_state state; - state.tokens = ureg_finalize(ureg); + pipe_shader_state_from_tgsi(&state, ureg_finalize(ureg)); if(!state.tokens) return NULL; if (so) state.stream_output = *so; - else - memset(&state.stream_output, 0, sizeof(state.stream_output)); switch (ureg->processor) { case PIPE_SHADER_VERTEX: diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index 5b5c851..1220e18 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -121,12 +121,13 @@ void *util_make_layered_clear_vertex_shader(struct pipe_context *pipe) "MOV OUT[2], SV[0]\n" "END\n"; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; + struct pipe_shader_state state; if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { assert(0); return NULL; } + pipe_shader_state_from_tgsi(&state, tokens); return pipe->create_vs_state(pipe, &state); } @@ -149,12 +150,13 @@ void *util_make_layered
Mesa (master): nir/lower-io: split out some helper fxns
Module: Mesa Branch: master Commit: 595f9d5476764ba29272549bac7ccdf459fe URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=595f9d5476764ba29272549bac7ccdf459fe Author: Rob Clark Date: Fri Mar 25 15:03:40 2016 -0400 nir/lower-io: split out some helper fxns Prep work to reduce the noise in the next patch. Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir_lower_io_to_temporaries.c | 122 ++--- 1 file changed, 70 insertions(+), 52 deletions(-) diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c index bf16aec..4b4363b 100644 --- a/src/compiler/nir/nir_lower_io_to_temporaries.c +++ b/src/compiler/nir/nir_lower_io_to_temporaries.c @@ -31,29 +31,87 @@ struct lower_io_state { nir_shader *shader; + nir_function *entrypoint; struct exec_list old_outputs; }; static void -emit_output_copies(nir_cursor cursor, struct lower_io_state *state) +emit_copies(nir_cursor cursor, nir_shader *shader, struct exec_list *new_vars, + struct exec_list *old_vars) { - assert(exec_list_length(&state->shader->outputs) == - exec_list_length(&state->old_outputs)); + assert(exec_list_length(new_vars) == exec_list_length(old_vars)); - foreach_two_lists(out_node, &state->shader->outputs, - temp_node, &state->old_outputs) { - nir_variable *output = exec_node_data(nir_variable, out_node, node); - nir_variable *temp = exec_node_data(nir_variable, temp_node, node); + foreach_two_lists(new_node, new_vars, old_node, old_vars) { + nir_variable *newv = exec_node_data(nir_variable, new_node, node); + nir_variable *temp = exec_node_data(nir_variable, old_node, node); nir_intrinsic_instr *copy = - nir_intrinsic_instr_create(state->shader, nir_intrinsic_copy_var); - copy->variables[0] = nir_deref_var_create(copy, output); + nir_intrinsic_instr_create(shader, nir_intrinsic_copy_var); + copy->variables[0] = nir_deref_var_create(copy, newv); copy->variables[1] = nir_deref_var_create(copy, temp); nir_instr_insert(cursor, ©->instr); } } +static void +emit_output_copies_impl(struct lower_io_state *state, nir_function_impl *impl) +{ + if (state->shader->stage == MESA_SHADER_GEOMETRY) { + /* For geometry shaders, we have to emit the output copies right + * before each EmitVertex call. + */ + nir_foreach_block(block, impl) { + nir_foreach_instr(instr, block) { +if (instr->type != nir_instr_type_intrinsic) + continue; + +nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); +if (intrin->intrinsic == nir_intrinsic_emit_vertex) { + nir_cursor cursor = nir_before_instr(&intrin->instr); + emit_copies(cursor, state->shader, &state->shader->outputs, + &state->old_outputs); +} + } + } + } else if (impl->function == state->entrypoint) { + /* For all other shader types, we need to do the copies right before + * the jumps to the end block. + */ + struct set_entry *block_entry; + set_foreach(impl->end_block->predecessors, block_entry) { + struct nir_block *block = (void *)block_entry->key; + nir_cursor cursor = nir_after_block_before_jump(block); + emit_copies(cursor, state->shader, &state->shader->outputs, + &state->old_outputs); + } + } +} + +static nir_variable * +create_shadow_temp(struct lower_io_state *state, nir_variable *var) +{ + nir_variable *nvar = ralloc(state->shader, nir_variable); + memcpy(nvar, var, sizeof *nvar); + + /* The original is now the temporary */ + nir_variable *temp = var; + + /* Reparent the name to the new variable */ + ralloc_steal(nvar, nvar->name); + + /* Reparent the constant initializer (if any) */ + ralloc_steal(nvar, nvar->constant_initializer); + + /* Give the output a new name with @out-temp appended */ + const char *mode = "out"; + temp->name = ralloc_asprintf(var, "%s@%s-temp", mode, nvar->name); + temp->data.mode = nir_var_global; + temp->constant_initializer = NULL; + + return nvar; +} + void nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint) { @@ -63,29 +121,14 @@ nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint) return; state.shader = shader; + state.entrypoint = entrypoint; exec_list_move_nodes_to(&shader->outputs, &state.old_outputs); /* Walk over all of the outputs turn each output into a temporary and * make a new variable for the actual output. */ nir_foreach_variable(var, &state.old_outputs) { -
Mesa (master): nir: move callsite of lower_outputs_to_temporaries
Module: Mesa Branch: master Commit: 47fcef9a209e533103a7ecf4d69440a67aa463ed URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=47fcef9a209e533103a7ecf4d69440a67aa463ed Author: Rob Clark Date: Fri Mar 25 13:47:15 2016 -0400 nir: move callsite of lower_outputs_to_temporaries Going to convert this pass to parameterized lower_io_to_temporaries, and we want the user to be able to specify whether to lower outputs or inputs or both. The restriction of running this pass before validate to avoid output reads no longer applies. Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand --- src/compiler/nir/glsl_to_nir.cpp| 2 -- src/compiler/nir/nir_lower_outputs_to_temporaries.c | 4 src/mesa/drivers/dri/i965/brw_nir.c | 1 + 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp index e3fa623..a86b966 100644 --- a/src/compiler/nir/glsl_to_nir.cpp +++ b/src/compiler/nir/glsl_to_nir.cpp @@ -143,8 +143,6 @@ glsl_to_nir(const struct gl_shader_program *shader_prog, v2.run(sh->ir); visit_exec_list(sh->ir, &v1); - nir_lower_outputs_to_temporaries(shader, nir_shader_get_entrypoint(shader)); - shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name); if (shader_prog->Label) shader->info.label = ralloc_strdup(shader, shader_prog->Label); diff --git a/src/compiler/nir/nir_lower_outputs_to_temporaries.c b/src/compiler/nir/nir_lower_outputs_to_temporaries.c index 21bc15b..0dfb7b0 100644 --- a/src/compiler/nir/nir_lower_outputs_to_temporaries.c +++ b/src/compiler/nir/nir_lower_outputs_to_temporaries.c @@ -25,10 +25,6 @@ * Implements a pass that lowers output variables to a temporary plus an * output variable with a single copy at each exit point of the shader. * This way the output variable is only ever written. - * - * Because valid NIR requires that output variables are never read, this - * pass is more of a helper for NIR producers and must be run before the - * shader is ever validated. */ #include "nir.h" diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c index 9414fa6..fb658ec 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.c +++ b/src/mesa/drivers/dri/i965/brw_nir.c @@ -563,6 +563,7 @@ brw_create_nir(struct brw_context *brw, /* First, lower the GLSL IR or Mesa IR to NIR */ if (shader_prog) { nir = glsl_to_nir(shader_prog, stage, options); + OPT_V(nir_lower_outputs_to_temporaries, nir_shader_get_entrypoint(nir)); } else { nir = prog_to_nir(prog, options); OPT_V(nir_convert_to_ssa); /* turn registers into SSA */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: add lowering pass for y-transform
Module: Mesa Branch: master Commit: b26645a00f3bb3100cff167087f6bd84af150986 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b26645a00f3bb3100cff167087f6bd84af150986 Author: Rob Clark Date: Sat Nov 7 10:59:09 2015 -0500 nir: add lowering pass for y-transform Signed-off-by: Rob Clark Reviewed-by: Connor Abbott Reviewed-by: Eric Anholt --- src/compiler/Makefile.sources| 1 + src/compiler/nir/nir.h | 11 + src/compiler/nir/nir_lower_wpos_ytransform.c | 310 +++ 3 files changed, 322 insertions(+) diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources index 2a52319..b542a1a 100644 --- a/src/compiler/Makefile.sources +++ b/src/compiler/Makefile.sources @@ -208,6 +208,7 @@ NIR_FILES = \ nir/nir_lower_vars_to_ssa.c \ nir/nir_lower_var_copies.c \ nir/nir_lower_vec_to_movs.c \ + nir/nir_lower_wpos_ytransform.c \ nir/nir_metadata.c \ nir/nir_move_vec_src_uses_to_dest.c \ nir/nir_normalize_cubemap_coords.c \ diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 8a616d4..474ba63 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2374,6 +2374,17 @@ void nir_lower_two_sided_color(nir_shader *shader); void nir_lower_clamp_color_outputs(nir_shader *shader); +typedef struct nir_lower_wpos_ytransform_options { + int state_tokens[5]; + bool fs_coord_origin_upper_left :1; + bool fs_coord_origin_lower_left :1; + bool fs_coord_pixel_center_integer :1; + bool fs_coord_pixel_center_half_integer :1; +} nir_lower_wpos_ytransform_options; + +bool nir_lower_wpos_ytransform(nir_shader *shader, + const nir_lower_wpos_ytransform_options *options); + void nir_lower_atomics(nir_shader *shader, const struct gl_shader_program *shader_program); void nir_lower_to_source_mods(nir_shader *shader); diff --git a/src/compiler/nir/nir_lower_wpos_ytransform.c b/src/compiler/nir/nir_lower_wpos_ytransform.c new file mode 100644 index 000..1d53530 --- /dev/null +++ b/src/compiler/nir/nir_lower_wpos_ytransform.c @@ -0,0 +1,310 @@ +/* + * Copyright © 2015 Red Hat + * + * 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 "nir.h" +#include "nir_builder.h" + +/* Lower gl_FragCoord (and fddy) to account for driver's requested coordinate- + * origin and pixel-center vs. shader. If transformation is required, a + * gl_FbWposYTransform uniform is inserted (with the specified state-slots) + * and additional instructions are inserted to transform gl_FragCoord (and + * fddy src arg). + * + * This is based on the logic in emit_wpos()/emit_wpos_adjustment() in TGSI + * compiler. + * + * Run before nir_lower_io. + */ + +typedef struct { + const nir_lower_wpos_ytransform_options *options; + nir_shader *shader; + nir_builder b; + nir_variable *transform; +} lower_wpos_ytransform_state; + +static nir_ssa_def * +get_transform(lower_wpos_ytransform_state *state) +{ + if (state->transform == NULL) { + /* NOTE: name must be prefixed w/ "gl_" to trigger slot based + * special handling in uniform setup: + */ + nir_variable *var = nir_variable_create(state->shader, + nir_var_uniform, + glsl_vec4_type(), + "gl_FbWposYTransform"); + + var->num_state_slots = 1; + var->state_slots = ralloc_array(var, nir_state_slot, 1); + memcpy(var->state_slots[0].tokens, state->options->state_tokens, + sizeof(var->state_slots[0].tokens)); + + state->transform = var; + } + return nir_load_var(&state->b, state->transform); +} + +/* NIR equiv of TGSI C
Mesa (master): nir: add lowering pass for glDrawPixels
Module: Mesa Branch: master Commit: 12c18ce4763d3982a52318365f45c4535aac0567 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=12c18ce4763d3982a52318365f45c4535aac0567 Author: Rob Clark Date: Mon Dec 21 21:27:25 2015 -0500 nir: add lowering pass for glDrawPixels Signed-off-by: Rob Clark Reviewed-by: Connor Abbott Reviewed-by: Eric Anholt --- src/compiler/Makefile.sources | 1 + src/compiler/nir/nir.h | 13 ++ src/compiler/nir/nir_lower_drawpixels.c | 254 3 files changed, 268 insertions(+) diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources index b542a1a..9512207 100644 --- a/src/compiler/Makefile.sources +++ b/src/compiler/Makefile.sources @@ -190,6 +190,7 @@ NIR_FILES = \ nir/nir_lower_clip.c \ nir/nir_lower_double_ops.c \ nir/nir_lower_double_packing.c \ + nir/nir_lower_drawpixels.c \ nir/nir_lower_global_vars_to_local.c \ nir/nir_lower_gs_intrinsics.c \ nir/nir_lower_load_const_to_scalar.c \ diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 474ba63..364972d 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2385,6 +2385,19 @@ typedef struct nir_lower_wpos_ytransform_options { bool nir_lower_wpos_ytransform(nir_shader *shader, const nir_lower_wpos_ytransform_options *options); +typedef struct nir_lower_drawpixels_options { + int texcoord_state_tokens[5]; + int scale_state_tokens[5]; + int bias_state_tokens[5]; + unsigned drawpix_sampler; + unsigned pixelmap_sampler; + bool pixel_maps :1; + bool scale_and_bias :1; +} nir_lower_drawpixels_options; + +void nir_lower_drawpixels(nir_shader *shader, + const nir_lower_drawpixels_options *options); + void nir_lower_atomics(nir_shader *shader, const struct gl_shader_program *shader_program); void nir_lower_to_source_mods(nir_shader *shader); diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c new file mode 100644 index 000..7ffaa52 --- /dev/null +++ b/src/compiler/nir/nir_lower_drawpixels.c @@ -0,0 +1,254 @@ +/* + * Copyright © 2015 Red Hat + * + * 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 "nir.h" +#include "nir_builder.h" + +/* Lower glDrawPixels(). + * + * This is based on the logic in st_get_drawpix_shader() in TGSI compiler. + * + * Run before nir_lower_io. + */ + +typedef struct { + const nir_lower_drawpixels_options *options; + nir_shader *shader; + nir_builder b; + nir_variable *texcoord, *scale, *bias; +} lower_drawpixels_state; + +static nir_ssa_def * +get_texcoord(lower_drawpixels_state *state) +{ + if (state->texcoord == NULL) { + nir_variable *texcoord = NULL; + + /* find gl_TexCoord, if it exists: */ + nir_foreach_variable(var, &state->shader->inputs) { + if (var->data.location == VARYING_SLOT_TEX0) { +texcoord = var; +break; + } + } + + /* otherwise create it: */ + if (texcoord == NULL) { + texcoord = nir_variable_create(state->shader, +nir_var_shader_in, +glsl_vec4_type(), +"gl_TexCoord"); + texcoord->data.location = VARYING_SLOT_TEX0; + } + + state->texcoord = texcoord; + } + return nir_load_var(&state->b, state->texcoord); +} + +static nir_variable * +create_uniform(nir_shader *shader, const char *name, const int state_tokens[5]) +{ + nir_variable *var = nir_variable_create(shader, + nir_var_uniform, + glsl_vec4_type(), +
Mesa (master): nir: add lowering pass for glBitmap
Module: Mesa Branch: master Commit: 3a939d034e41755b46b51fbe9071f5d31cdf1f81 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a939d034e41755b46b51fbe9071f5d31cdf1f81 Author: Rob Clark Date: Mon Dec 21 21:54:00 2015 -0500 nir: add lowering pass for glBitmap Signed-off-by: Rob Clark Reviewed-by: Connor Abbott Reviewed-by: Eric Anholt --- src/compiler/Makefile.sources | 1 + src/compiler/nir/nir.h | 7 ++ src/compiler/nir/nir_lower_bitmap.c | 139 3 files changed, 147 insertions(+) diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources index 9512207..903e882 100644 --- a/src/compiler/Makefile.sources +++ b/src/compiler/Makefile.sources @@ -186,6 +186,7 @@ NIR_FILES = \ nir/nir_liveness.c \ nir/nir_lower_alu_to_scalar.c \ nir/nir_lower_atomics.c \ + nir/nir_lower_bitmap.c \ nir/nir_lower_clamp_color_outputs.c \ nir/nir_lower_clip.c \ nir/nir_lower_double_ops.c \ diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 364972d..4075a5f 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2398,6 +2398,13 @@ typedef struct nir_lower_drawpixels_options { void nir_lower_drawpixels(nir_shader *shader, const nir_lower_drawpixels_options *options); +typedef struct nir_lower_bitmap_options { + unsigned sampler; + bool swizzle_; +} nir_lower_bitmap_options; + +void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *options); + void nir_lower_atomics(nir_shader *shader, const struct gl_shader_program *shader_program); void nir_lower_to_source_mods(nir_shader *shader); diff --git a/src/compiler/nir/nir_lower_bitmap.c b/src/compiler/nir/nir_lower_bitmap.c new file mode 100644 index 000..e182579 --- /dev/null +++ b/src/compiler/nir/nir_lower_bitmap.c @@ -0,0 +1,139 @@ +/* + * Copyright © 2015 Red Hat + * + * 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 "nir.h" +#include "nir_builder.h" + +/* Lower glBitmap(). + * + * This is based on the logic in st_get_bitmap_shader() in TGSI compiler. + * From st_cb_bitmap.c: + * + *glBitmaps are drawn as textured quads. The user's bitmap pattern + *is stored in a texture image. An alpha8 texture format is used. + *The fragment shader samples a bit (texel) from the texture, then + *discards the fragment if the bit is off. + * + *Note that we actually store the inverse image of the bitmap to + *simplify the fragment program. An "on" bit gets stored as texel=0x0 + *and an "off" bit is stored as texel=0xff. Then we kill the + *fragment if the negated texel value is less than zero. + * + * Note that the texture format will be, according to what driver supports, + * in order of preference (with swizzle): + * + *I8_UNORM - . + *A8_UNORM - .000x + *L8_UNORM - .xxx1 + * + * If L8_UNORM, options->swizzle_ is true. Otherwise we can just use + * the .w comp. + * + * Run before nir_lower_io. + */ + +static nir_variable * +get_texcoord(nir_shader *shader) +{ + nir_variable *texcoord = NULL; + + /* find gl_TexCoord, if it exists: */ + nir_foreach_variable(var, &shader->inputs) { + if (var->data.location == VARYING_SLOT_TEX0) { + texcoord = var; + break; + } + } + + /* otherwise create it: */ + if (texcoord == NULL) { + texcoord = nir_variable_create(shader, + nir_var_shader_in, + glsl_vec4_type(), + "gl_TexCoord"); + texcoord->data.location = VARYING_SLOT_TEX0; + } + + return texcoord; +} + +static void +lower_bitmap(nir_shader *shader, nir_buil