[Mesa-dev] Request for "Developer" of mesa project.
Hi, I'm Hyunjun Ko, working on Mesa actively nowadays. I've been working for over 1 year since I dived into this attractive project and mainly focusing on freedreno. Now I feel it's the right time to request to grant access. You can see my works in the past: https://cgit.freedesktop.org/mesa/mesa/log/?qt=author=zzoon And also there are several pending patches for mediump, which is expected to land soon. I would like to appreciate it if this request is approved. Thanks. PS. Now I can't even label "turnip" on the issue! https://gitlab.freedesktop.org/mesa/mesa/issues/2514 XD ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] freedreno: implements get_sample_position
Since 1285f71d3e landed, it needs to provide apps with proper sample position for MSAA. Currently no way to query this to hw, these are taken from blob driver. Fixes: dEQP-GLES31.functional.texture.multisample.samples_#.sample_position --- .../drivers/freedreno/freedreno_resource.c| 43 +++ 1 file changed, 43 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 54d7385896..5047c43700 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -1192,6 +1192,50 @@ fd_resource_screen_init(struct pipe_screen *pscreen) screen->setup_slices = fd_setup_slices; } +static void +fd_get_sample_position(struct pipe_context *context, + unsigned sample_count, unsigned sample_index, + float *pos_out) +{ + /* The following is copied from nouveau/nv50 except for position +* values, which are taken from blob driver */ + static const uint8_t pos1[1][2] = { { 0x8, 0x8 } }; + static const uint8_t pos2[2][2] = { + { 0xc, 0xc }, { 0x4, 0x4 } }; + static const uint8_t pos4[4][2] = { + { 0x6, 0x2 }, { 0xe, 0x6 }, + { 0x2, 0xa }, { 0xa, 0xe } }; + /* TODO needs to be verified on supported hw */ + static const uint8_t pos8[8][2] = { + { 0x9, 0x5 }, { 0x7, 0xb }, + { 0xd, 0x9 }, { 0x5, 0x3 }, + { 0x3, 0xd }, { 0x1, 0x7 }, + { 0xb, 0xf }, { 0xf, 0x1 } }; + + const uint8_t (*ptr)[2]; + + switch (sample_count) { + case 1: + ptr = pos1; + break; + case 2: + ptr = pos2; + break; + case 4: + ptr = pos4; + break; + case 8: + ptr = pos8; + break; + default: + assert(0); + return; + } + + pos_out[0] = ptr[sample_index][0] / 16.0f; + pos_out[1] = ptr[sample_index][1] / 16.0f; +} + void fd_resource_context_init(struct pipe_context *pctx) { @@ -1206,4 +1250,5 @@ fd_resource_context_init(struct pipe_context *pctx) pctx->blit = fd_blit; pctx->flush_resource = fd_flush_resource; pctx->invalidate_resource = fd_invalidate_resource; + pctx->get_sample_position = fd_get_sample_position; } ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] freedreno: implements get_sample_position
Since 1285f71d3e landed, it needs to provide apps with proper sample position for MSAA. Currently no way to query this to hw, these are taken from blob driver. Fixes: dEQP-GLES31.functional.texture.multisample.samples_#.sample_position --- .../drivers/freedreno/freedreno_resource.c| 43 +++ 1 file changed, 43 insertions(+) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 54d7385896..5047c43700 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -1192,6 +1192,50 @@ fd_resource_screen_init(struct pipe_screen *pscreen) screen->setup_slices = fd_setup_slices; } +static void +fd_get_sample_position(struct pipe_context *context, + unsigned sample_count, unsigned sample_index, + float *pos_out) +{ + /* The following is copied from nouveau/nv50 except for position +* values, which are taken from blob driver */ + static const uint8_t pos1[1][2] = { { 0x8, 0x8 } }; + static const uint8_t pos2[2][2] = { + { 0xc, 0xc }, { 0x4, 0x4 } }; + static const uint8_t pos4[4][2] = { + { 0x6, 0x2 }, { 0xe, 0x6 }, + { 0x2, 0xa }, { 0xa, 0xe } }; + /* TODO needs to be verified on supported hw */ + static const uint8_t pos8[8][2] = { + { 0x9, 0x5 }, { 0x7, 0xb }, + { 0xd, 0x9 }, { 0x5, 0x3 }, + { 0x3, 0xd }, { 0x1, 0x7 }, + { 0xb, 0xf }, { 0xf, 0x1 } }; + + const uint8_t (*ptr)[2]; + + switch (sample_count) { + case 1: + ptr = pos1; + break; + case 2: + ptr = pos2; + break; + case 4: + ptr = pos4; + break; + case 8: + ptr = pos8; + break; + default: + assert(0); + return; + } + + pos_out[0] = ptr[sample_index][0] * 0.0625f; + pos_out[1] = ptr[sample_index][1] * 0.0625f; +} + void fd_resource_context_init(struct pipe_context *pctx) { @@ -1206,4 +1250,5 @@ fd_resource_context_init(struct pipe_context *pctx) pctx->blit = fd_blit; pctx->flush_resource = fd_flush_resource; pctx->invalidate_resource = fd_invalidate_resource; + pctx->get_sample_position = fd_get_sample_position; } ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] freedreno: take reg->num out of union in ir3_register
To avoid wrong result when identifying the type of register. Ie. If the reg is an array, it might be identified as address or predicate register. --- src/gallium/drivers/freedreno/ir3/ir3.h | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index 3055c10f1d..1f47cef7e0 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -95,12 +95,13 @@ struct ir3_register { IR3_REG_ARRAY = 0x8000, } flags; + + /* normal registers: +* the component is in the low two bits of the reg #, so +* rN.x becomes: (N << 2) | x +*/ + int num; union { - /* normal registers: -* the component is in the low two bits of the reg #, so -* rN.x becomes: (N << 2) | x -*/ - int num; /* immediate: */ int32_t iim_val; uint32_t uim_val; -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] freedreno: ir3: fix wrong return if reg is an array
On 10/24/18 11:05 PM, Rob Clark wrote: On Tue, Oct 23, 2018 at 9:57 PM Hyunjun Ko wrote: Since ir3_register struct has union, it could return true even if it's an array register accidentally when checking whether it is address/predicate register. Fixes: dEQP-GLES31.functional.ssbo.layout.random.arrays_of_arrays.6 --- src/gallium/drivers/freedreno/ir3/ir3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index 3055c10f1d..db94603558 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -739,7 +739,7 @@ static inline bool writes_addr(struct ir3_instruction *instr) { if (instr->regs_count > 0) { struct ir3_register *dst = instr->regs[0]; - return reg_num(dst) == REG_A0; + return (reg_num(dst) == REG_A0) && !(dst->flags & IR3_REG_ARRAY); hmm, good catch.. although I wonder if writes_gpr() in ir3_ra.c has the same issue. Or anywhere else? (Otoh, I guess checking for CONST and IMMED in writes_gpr() is a bit silly) From a quick look at the IR3_REG_* flags, I think IR3_REG_ARRAY is the only problematic case.. but this is a bit more fragile than it should be. Maybe we should just move 'int num' out of the union? Maybe that was too much premature optimization? BR, -R Didn't figure out writes_gpr() might have same issue. I think taking num out of union should avoid other similar issues if we don't think that would increase memory footprint that much. Working on this. } return false; } @@ -748,7 +748,7 @@ static inline bool writes_pred(struct ir3_instruction *instr) { if (instr->regs_count > 0) { struct ir3_register *dst = instr->regs[0]; - return reg_num(dst) == REG_P0; + return (reg_num(dst) == REG_P0) && !(dst->flags & IR3_REG_ARRAY); } return false; } -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] freedreno: use fd_bc_alloc_batch instead of fd_batch_create.
Following the commit 2385d7b066 and 8e798e28f7, for resource dependancy tracking. Fixes: dEQP-GLES31.functional.image_load_store.early_fragment_tests.no_early_fragment_tests_depth_fbo with FD_MESA_DEBUG=inorder --- src/gallium/drivers/freedreno/a5xx/fd5_blitter.c | 2 +- src/gallium/drivers/freedreno/freedreno_batch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c index 6e8177d344..09ff2b71ec 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c @@ -459,7 +459,7 @@ fd5_blitter_blit(struct fd_context *ctx, const struct pipe_blit_info *info) return; } - batch = fd_batch_create(ctx, true); + batch = fd_bc_alloc_batch(>screen->batch_cache, ctx, true); fd5_emit_restore(batch, batch->draw); fd5_emit_lrz_flush(batch->draw); diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index 487176cc63..c83466d176 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -360,7 +360,7 @@ fd_batch_flush(struct fd_batch *batch, bool sync, bool force) */ new_batch = NULL; } else { - new_batch = fd_batch_create(ctx, false); + new_batch = fd_bc_alloc_batch(>screen->batch_cache, ctx, false); util_copy_framebuffer_state(_batch->framebuffer, >framebuffer); } -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] freedreno: ir3: fix wrong return if reg is an array
Since ir3_register struct has union, it could return true even if it's an array register accidentally when checking whether it is address/predicate register. Fixes: dEQP-GLES31.functional.ssbo.layout.random.arrays_of_arrays.6 --- src/gallium/drivers/freedreno/ir3/ir3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index 3055c10f1d..db94603558 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -739,7 +739,7 @@ static inline bool writes_addr(struct ir3_instruction *instr) { if (instr->regs_count > 0) { struct ir3_register *dst = instr->regs[0]; - return reg_num(dst) == REG_A0; + return (reg_num(dst) == REG_A0) && !(dst->flags & IR3_REG_ARRAY); } return false; } @@ -748,7 +748,7 @@ static inline bool writes_pred(struct ir3_instruction *instr) { if (instr->regs_count > 0) { struct ir3_register *dst = instr->regs[0]; - return reg_num(dst) == REG_P0; + return (reg_num(dst) == REG_P0) && !(dst->flags & IR3_REG_ARRAY); } return false; } -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] freedreno: allocate batches from the cache in launch_grid
Needs to allocate batches from the cache so that it could get a valid index and make resource dependancy tracking right. In addition this fixes assertion on debug build since the commit 1a40faa8 landed. --- src/gallium/drivers/freedreno/freedreno_draw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index e130895aac..fe026a5fd8 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -459,7 +459,7 @@ fd_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) struct fd_batch *batch, *save_batch = NULL; unsigned i; - batch = fd_batch_create(ctx, true); + batch = fd_bc_alloc_batch(>screen->batch_cache, ctx, true); fd_batch_reference(_batch, ctx->batch); fd_batch_reference(>batch, batch); @@ -506,6 +506,7 @@ fd_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) fd_batch_reference(>batch, save_batch); fd_batch_reference(_batch, NULL); + fd_batch_reference(, NULL); } void -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] freedreno: adds nondraw param to fd_bc_alloc_batch
Needs to specify nondraw when creating a batch through fd_bc_alloc_batch since it'd better create a batch through it rather than fd_batch_create. --- src/gallium/drivers/freedreno/a6xx/fd6_blitter.c | 2 +- src/gallium/drivers/freedreno/freedreno_batch_cache.c | 6 +++--- src/gallium/drivers/freedreno/freedreno_batch_cache.h | 2 +- src/gallium/drivers/freedreno/freedreno_context.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index bd37005d50..c962fe7997 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -486,7 +486,7 @@ fd6_blit(struct pipe_context *pctx, const struct pipe_blit_info *info) return; } - batch = fd_bc_alloc_batch(>screen->batch_cache, ctx); + batch = fd_bc_alloc_batch(>screen->batch_cache, ctx, true); fd6_emit_restore(batch, batch->draw); fd6_emit_lrz_flush(batch->draw); diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c index 9d046f205b..a8b32d9bd0 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c +++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c @@ -270,7 +270,7 @@ fd_bc_invalidate_resource(struct fd_resource *rsc, bool destroy) } struct fd_batch * -fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx) +fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx, bool nondraw) { struct fd_batch *batch; uint32_t idx; @@ -333,7 +333,7 @@ fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx) idx--; /* bit zero returns 1 for ffs() */ - batch = fd_batch_create(ctx, false); + batch = fd_batch_create(ctx, nondraw); if (!batch) goto out; @@ -365,7 +365,7 @@ batch_from_key(struct fd_batch_cache *cache, struct key *key, return batch; } - batch = fd_bc_alloc_batch(cache, ctx); + batch = fd_bc_alloc_batch(cache, ctx, false); #ifdef DEBUG DBG("%p: hash=0x%08x, %ux%u, %u layers, %u samples", batch, hash, key->width, key->height, key->layers, key->samples); diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.h b/src/gallium/drivers/freedreno/freedreno_batch_cache.h index 348418e187..0f2c40ba8d 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch_cache.h +++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.h @@ -68,7 +68,7 @@ void fd_bc_flush_deferred(struct fd_batch_cache *cache, struct fd_context *ctx); void fd_bc_invalidate_context(struct fd_context *ctx); void fd_bc_invalidate_batch(struct fd_batch *batch, bool destroy); void fd_bc_invalidate_resource(struct fd_resource *rsc, bool destroy); -struct fd_batch * fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx); +struct fd_batch * fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx, bool nondraw); struct fd_batch * fd_batch_from_fb(struct fd_batch_cache *cache, struct fd_context *ctx, const struct pipe_framebuffer_state *pfb); diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index 55e978073a..c540d6d143 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -316,7 +316,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, pctx->const_uploader = pctx->stream_uploader; if (!ctx->screen->reorder) - ctx->batch = fd_bc_alloc_batch(>batch_cache, ctx); + ctx->batch = fd_bc_alloc_batch(>batch_cache, ctx, false); slab_create_child(>transfer_pool, >transfer_pool); -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] freedreno: allocate batches from the cache in launch_grid
Needs to allocate batches from the cache so that it could get a valid index and make resource dependancy tracking right. And it doesn't need to flush the batch in each launch_grid from this approach. Also it could make it avoid potential memory leak of the batches. In addition this fixes assertion on debug build since the commit 1a40faa8 landed. --- src/gallium/drivers/freedreno/freedreno_draw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index e130895aac..bd902ef5a9 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -459,7 +459,7 @@ fd_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) struct fd_batch *batch, *save_batch = NULL; unsigned i; - batch = fd_batch_create(ctx, true); + batch = fd_bc_alloc_batch(>screen->batch_cache, ctx); fd_batch_reference(_batch, ctx->batch); fd_batch_reference(>batch, batch); @@ -502,10 +502,9 @@ fd_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) batch->needs_flush = true; ctx->launch_grid(ctx, info); - fd_batch_flush(batch, false, false); - fd_batch_reference(>batch, save_batch); fd_batch_reference(_batch, NULL); + fd_batch_reference(, NULL); } void -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] freedreno: don't do flush unless needed.
The commit 4b847b38 introduced some crashes of deqp gles31 cts, since it always tries to flush if the flag flushed is false, which is the initial state. This sometimes makes it trying unnecessary drawing when context is being destroyed for example. Fixes: dEQP-GLES31.functional.fbo.no_attachments.interaction.17x512ms4_default_16x16ms2 and other 5 relevant cts. --- src/gallium/drivers/freedreno/freedreno_batch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index ff8298e82a..8c9439bb9a 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -286,7 +286,7 @@ batch_flush(struct fd_batch *batch, bool force) { DBG("%p: needs_flush=%d", batch, batch->needs_flush); - if (batch->flushed) + if (!batch->needs_flush || batch->flushed) return; batch->needs_flush = false; -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] freedreno: don't do flush unless needed.
The commit 4b847b38 introduced some crashes of deqp gles31 cts, since it always tries to flush if the flag flushed is false, which is the initial state. This sometimes makes it trying unnecessary drawing when context is being destroyed for example. Fixes: dEQP-GLES31.functional.fbo.no_attachments.interaction.17x512ms4_default_16x16ms2 and other 5 relevant cts. --- src/gallium/drivers/freedreno/freedreno_batch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index ff8298e82a..8c9439bb9a 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -286,7 +286,7 @@ batch_flush(struct fd_batch *batch, bool force) { DBG("%p: needs_flush=%d", batch, batch->needs_flush); - if (batch->flushed) + if (!batch->needs_flush || batch->flushed) return; batch->needs_flush = false; -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] freedreno: fix a typo in launch_grid
--- src/gallium/drivers/freedreno/freedreno_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 0a472c78b1..0b7f9ffe5e 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -467,7 +467,7 @@ fd_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) * read vs written, so just assume the worst */ foreach_bit(i, ctx->shaderbuf[PIPE_SHADER_COMPUTE].enabled_mask) - resource_read(batch, ctx->shaderbuf[PIPE_SHADER_COMPUTE].sb[i].buffer); + resource_written(batch, ctx->shaderbuf[PIPE_SHADER_COMPUTE].sb[i].buffer); foreach_bit(i, ctx->shaderimg[PIPE_SHADER_COMPUTE].enabled_mask) { struct pipe_image_view *img = -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/4] freedreno: synchronize when flushing batches in launch_grid
Since the commit 4b847b38 landed, there has been a race condition in launch_grid, which is between fdX_launch_grid and rendering in batch flush. This leads many cts to unstable results, especially for those using compute shader. Fixes: many cts for compute shader including dEQP-GLES31.functional.compute.* --- src/gallium/drivers/freedreno/freedreno_draw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index f55905e7bf..0a472c78b1 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -500,7 +500,8 @@ fd_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) batch->needs_flush = true; ctx->launch_grid(ctx, info); - fd_batch_flush(batch, false, false); + /* TODO: flush with sync might affect performance, need to get improved */ + fd_batch_flush(batch, true, false); fd_batch_reference(>batch, save_batch); fd_batch_reference(_batch, NULL); -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] freedreno/ir3: fix the param order of cmpxchg
According to the following definition, int AtomicCompSwap(inout int mem, uint compare, uint data); the preceding one in atomic_comp_swap of NIR is compare and data is followed, while src0 for cmpxchg needs vec2(data, compare) So for ssbo/image deref comp_swap, that should be reversed. Fixes: dEQP-GLES31.functional.image_load_store.*.atomic.comp_swap* --- src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index 79314140d8..8f749f4110 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -1626,8 +1626,8 @@ emit_intrinsic_atomic_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr) case nir_intrinsic_ssbo_atomic_comp_swap: /* for cmpxchg, src0 is [ui]vec2(data, compare): */ src0 = create_collect(ctx, (struct ir3_instruction*[]){ - src0, get_src(ctx, >src[3])[0], + src0, }, 2); atomic = ir3_ATOMIC_CMPXCHG_G(b, ssbo, 0, src0, 0, src1, 0, src2, 0); break; @@ -2095,8 +2095,8 @@ emit_intrinsic_atomic_image(struct ir3_context *ctx, nir_intrinsic_instr *intr) case nir_intrinsic_image_deref_atomic_comp_swap: /* for cmpxchg, src0 is [ui]vec2(data, compare): */ src0 = create_collect(ctx, (struct ir3_instruction*[]){ - src0, get_src(ctx, >src[4])[0], + src0, }, 2); atomic = ir3_ATOMIC_CMPXCHG_G(b, image, 0, src0, 0, src1, 0, src2, 0); break; -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] freedreno: don't do flush unless needed.
The commit 4b847b38 introduced some crashes of deqp gles31 cts, since it always tries to flush if the flag flushed is false, which is the initial state. This sometimes makes it trying unnecessary drawing when context is being destroyed for example. Fixes: dEQP-GLES31.functional.fbo.no_attachments.interaction.17x512ms4_default_16x16ms2 and other 5 relevant cts. --- src/gallium/drivers/freedreno/freedreno_batch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index ff8298e82a..987348a09f 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -286,7 +286,7 @@ batch_flush(struct fd_batch *batch, bool force) { DBG("%p: needs_flush=%d", batch, batch->needs_flush); - if (batch->flushed) + if (!batch->needs_flush || bathc->flushed) return; batch->needs_flush = false; -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 0/4] fix crashes and failures of deqp gles31
This series fixes crashes/failures of tests from deqp gles31 on freedreno. Thanks for review. Hyunjun Ko (4): freedreno/ir3: fix the param order of cmpxchg freedreno: don't do flush unless needed. freedreno: synchronize when flushing batches in launch_grid freedreno: fix a typo in launch_grid src/gallium/drivers/freedreno/freedreno_batch.c | 2 +- src/gallium/drivers/freedreno/freedreno_draw.c | 5 +++-- src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 0/2] freedreno: fix crashes of deqp gles31
This series fixes some crashes of tests from deqp gles31 on freedreno. Thanks for review. Hyunjun Ko (2): freedreno/ir3: make immediates array dynamic freedreno/ir3: insert mov if same instruction in the outputs. .../drivers/freedreno/ir3/ir3_compiler_nir.c | 14 ++ src/gallium/drivers/freedreno/ir3/ir3_cp.c | 7 +++ src/gallium/drivers/freedreno/ir3/ir3_shader.c | 2 ++ src/gallium/drivers/freedreno/ir3/ir3_shader.h | 3 ++- 4 files changed, 25 insertions(+), 1 deletion(-) -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] freedreno/ir3: make immediates array dynamic
Since most shaders wouldn't need that large array of immediates, making the array dynamic could save unnecessary spaces. In addition, sometimes we can potentially have a much larger array of immediates to be lowered, which might be more than 64. --- src/gallium/drivers/freedreno/ir3/ir3_cp.c | 7 +++ src/gallium/drivers/freedreno/ir3/ir3_shader.c | 2 ++ src/gallium/drivers/freedreno/ir3/ir3_shader.h | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cp.c b/src/gallium/drivers/freedreno/ir3/ir3_cp.c index 0ee8ea2e0e..ea92f6b857 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cp.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cp.c @@ -286,6 +286,13 @@ lower_immed(struct ir3_cp_ctx *ctx, struct ir3_register *reg, unsigned new_flags new_flags &= ~IR3_REG_FNEG; } + /* Reallocate for 4 more elements whenever it's necessary */ + if (ctx->immediate_idx == ctx->so->immediates_size * 4) { + ctx->so->immediates_size += 4; + ctx->so->immediates = realloc (ctx->so->immediates, + ctx->so->immediates_size * sizeof (ctx->so->immediates[0])); + } + for (i = 0; i < ctx->immediate_idx; i++) { swiz = i % 4; idx = i / 4; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index 7bb4263b17..125bf3b983 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -54,6 +54,8 @@ delete_variant(struct ir3_shader_variant *v) ir3_destroy(v->ir); if (v->bo) fd_bo_del(v->bo); + if (v->immediates) + free(v->immediates); free(v); } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h index 288e9fa4e7..456701be7d 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h @@ -325,9 +325,10 @@ struct ir3_shader_variant { } constbase; unsigned immediates_count; + unsigned immediates_size; struct { uint32_t val[4]; - } immediates[64]; + } *immediates; /* for astc srgb workaround, the number/base of additional * alpha tex states we need, and index of original tex states -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] freedreno/ir3: insert mov if same instruction in the outputs.
For example, result0 = texture(sampler[indexBase + 5], coords); result1 = texture(sampler[indexBase + 0], coords); result2 = texture(sampler[indexBase + 0], coords); out_result0 = result0; out_result1 = result1; out_result2 = result2; In this kind of case we need to insert an extra mov to the outputs so that the result could be assigned to each register respectively. --- .../drivers/freedreno/ir3/ir3_compiler_nir.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index e4979a60a0..9f29a8afea 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -3637,6 +3637,20 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler, ir3_cp(ir, so); + /* Insert mov if there's same instruction for each output. +* eg. dEQP-GLES31.functional.shaders.opaque_type_indexing.sampler.const_expression.vertex.sampler2dshadow +*/ + for (int i = ir->noutputs - 1; i >= 0; i--) { + if (!ir->outputs[i]) + continue; + for (unsigned j = 0; j < i; j++) { + if (ir->outputs[i] == ir->outputs[j]) { + ir->outputs[i] = + ir3_MOV(ir->outputs[i]->block, ir->outputs[i], TYPE_F32); + } + } + } + if (fd_mesa_debug & FD_DBG_OPTMSGS) { printf("BEFORE GROUPING:\n"); ir3_print(ir); -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev