Re: [Mesa-dev] Question about handling RGBA/BGRA in etnaviv driver

2017-02-03 Thread Wladimir
Yes, but it seems suboptimal, incurring overhead on every rendered pixel.

Another way that I just realized would be to convert a texture to BGRA the
first time it's rendered to.

In contrast to the shader solution that has only a one-time overhead. Is
this a stupid idea for any reason?

Wladimir

On Feb 3, 2017 11:00, "Christian Gmeiner" 
wrote:

> Hi,
>
> 2017-02-03 10:56 GMT+01:00 Wladimir J. van der Laan :
> > Hello,
> >
> > With the Etnaviv driver we're running into an issue: The GPU can only
> render *to*
> > BGRA formats. It can however render *from* BGRA as well as RGBA textures.
> >
> > I know that the OpenGL ES standard allows drivers to choose what order
> is most
> > appropriate when being asked for "GL_RGBA" textures. So back when
> etnaviv supported
> > only BGRA, Mesa automatically picked that and everything was okay.
> >
> > However a recent patch added support for RGBA formats in
> etnaviv_format.c.
> >
> > Now, Mesa creates a real GL_RGBA texture when this is requested. This is
> all
> > and well for rendering, however for anything using FBO to render to
> textures
> > this is a problem.
> >
> > Qt, for example, is assuming it can attach the GL_RGBA texture to a FBO.
> This
> > fails now that GL_RGBA textures are really GL_RGBA, and it doesn't
> handle that
> > error to fall back to something else so rendering issues ensue.
> >
> > I'm not sure how to handle this:
> >
> > - The quick fix would be to revert the RGBA formats patch, but the
> hardware
> >   supports rendering *from* RGBA textures fine so this would be throwing
> away a
> >   feature.
> >
> > - Another way would be to try to fix Qt to cope with this, and try e.g.
> GL_BGRA_EXT
> >   when it wants to render to a texture. Burdening the client code with
> this seems
> >   unintuitive to me.
> >
> > - Another hack would be to implement shader variants, and swap R/B in
> the pixel
> >   shader to emulate rendering to RGBA.
> >
>
> In my opinion shader variants are the way to go - almost every driver
> make use of them to
> 'fix' such issues.
>
> greets
> --
> Christian Gmeiner, MSc
>
> https://www.youtube.com/user/AloryOFFICIAL
> https://soundcloud.com/christian-gmeiner
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] Fwd: Question about handling RGBA/BGRA in etnaviv driver

2017-02-03 Thread Wladimir
Sorry for getting the list wrong again. Please reply to mesa-dev not
dri-dev .

-- Forwarded message --
From: "Wladimir J. van der Laan" 
Date: Feb 3, 2017 10:56
Subject: Question about handling RGBA/BGRA in etnaviv driver
To: , 
Cc: "Chris Healy" 

Hello,

With the Etnaviv driver we're running into an issue: The GPU can only
render *to*
BGRA formats. It can however render *from* BGRA as well as RGBA textures.

I know that the OpenGL ES standard allows drivers to choose what order is
most
appropriate when being asked for "GL_RGBA" textures. So back when etnaviv
supported
only BGRA, Mesa automatically picked that and everything was okay.

However a recent patch added support for RGBA formats in etnaviv_format.c.

Now, Mesa creates a real GL_RGBA texture when this is requested. This is all
and well for rendering, however for anything using FBO to render to textures
this is a problem.

Qt, for example, is assuming it can attach the GL_RGBA texture to a FBO.
This
fails now that GL_RGBA textures are really GL_RGBA, and it doesn't handle
that
error to fall back to something else so rendering issues ensue.

I'm not sure how to handle this:

- The quick fix would be to revert the RGBA formats patch, but the hardware
  supports rendering *from* RGBA textures fine so this would be throwing
away a
  feature.

- Another way would be to try to fix Qt to cope with this, and try e.g.
GL_BGRA_EXT
  when it wants to render to a texture. Burdening the client code with this
seems
  unintuitive to me.

- Another hack would be to implement shader variants, and swap R/B in the
pixel
  shader to emulate rendering to RGBA.

Neither seems great. Does anyone have suggestions, do any of the other
(gallium) drivers have this problem?

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCHv2] etnaviv: Add support for ETC2 texture compression

2017-07-06 Thread Wladimir
Hello,

On Tue, Jun 27, 2017 at 5:47 PM, Christian Gmeiner
 wrote:
> 2017-06-27 17:39 GMT+02:00 Wladimir J. van der Laan :
>> On Tue, Jun 27, 2017 at 05:31:52PM +0200, Wladimir J. van der Laan wrote:
>>
>>> > sure if we should advertise the broken formats (on gpus with HALTI0).
>>
>> FWIW, I did check on both GC2000 and GC3000, so HALTI0 should be ok.
>>
>
> Great - could you try piglit's oes_compressed_etc2_texture-miptree_gles3?

Finally got around to installing an Ubuntu rootfs on the units and
getting piglit to compile and run in gbm mode.

GC2000:

spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 r11: pass
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 rg11: pass
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 rgb8: fail
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3
rgb8-punchthrough-alpha1: fail
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 rgba8: fail
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 srgb8: fail
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 srgb8-alpha8: fail
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3
srgb8-punchthrough-alpha1: fail

GC3000:

spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 r11: pass
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 rg11: pass
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 rgb8: pass
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3
rgb8-punchthrough-alpha1: pass
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 rgba8: pass
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 srgb8: fail
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3 srgb8-alpha8: fail
spec/!opengl es 3.0/oes_compressed_etc2_texture-miptree_gles3
srgb8-punchthrough-alpha1: fail

That the SRGB formats fail is expected (they're simply using RGB, this
is mentioned in the patch message), the discrepancy between
gc2000/gc3000 on RGB(A) is interesting, though, I'll look into it.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCHv2] etnaviv: Add support for ETC2 texture compression

2017-07-07 Thread Wladimir
On Thu, Jul 6, 2017 at 4:01 PM, Wladimir  wrote:

> That the SRGB formats fail is expected (they're simply using RGB, this
> is mentioned in the patch message), the discrepancy between
> gc2000/gc3000 on RGB(A) is interesting, though, I'll look into it.

I've not been able to figure this out. I've tried comparing blob
command streams GC2000 versus GC3000 - could find no significant
differences, most notably the format IDs are the same.

Then I looked at the visual output of this test (pngs attached) on both GPUs.

GC3000 is 100% correct. The overall image on GC2000 looks ok, however
some tiles show serious artifacts. My suspicion is starting to be that
there is a hardware bug on GC2000 with the ETC1 decoder.

To know this for sure we'd have to run piglit with the blob drivers on
GC2000. Did you (or anyone else) ever manage to do this?

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] etnaviv: Add support for ETC2 texture compression

2017-07-18 Thread Wladimir
> h (format) {
>
> How about
>
> const struct util_format_description *desc = util_format_description(format);
> return desc->layout == UTIL_FORMAT_LAYOUT_ETC;

I intentionally exclude PIPE_FORMAT_ETC1_RGB8 here because it is
implemented on older hw and has its own feature bit
(ETC1_TEXTURE_COMPRESSION).
But yes that shortens the code at least, thanks.

> There's already a util_format_is_s3tc helper, I don't think it'd be
way out of line to add one for etc as well.

Ok, will add one.

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: Set up GC3000 states, fix point sprite rendering

2017-10-01 Thread Wladimir
On Oct 1, 2017 13:38, "Lucas Stach"  wrote:

Am Sonntag, den 01.10.2017, 12:46 +0200 schrieb Christian Gmeiner:
> 2017-09-26 12:29 GMT+02:00 Wladimir J. van der Laan :
> > Set up new states that the blob started setting for GC3000 consistently.
> >
> > This makes sure that when another test or driver leaves the GPU in
> > unpredictable state, these states are set up correctly for our
> > rendering.
> >
>
> I am not sure if this counts as valid argument to set some of the unknown
states
> back to 0. I can not image that a normal user will run in this kind of
> situation at all.
> Just my opinion. If you insist in having a hand full unknown states
> set back to 0
> I can life with it and will push the patch in its current form.

I think it's actually a good idea to reset the GPU to the expected
state in the context reset. No process should depend on any particular
GPU state between submits, as any other process might leave the GPU
totally screwed.


Agree!


It's a good idea to initialize the state that we don't normally
overwrite during state emission.


Yes! The vivante driver handles clean slate contexts in the kernel but we
have to do it in userspace.


> >
> > Also, setting PA_VIEWPORT_UNK00A84 to fui(8192.0) is necessary
> > to make point sprite rendering on GC3000 work.
>
> I would prefer a patch that only sets PA_VIEWPORT_UNK00A84 to fix point
> sprite rendering on GC3000.

Yeah, splitting up this patch into 2 would be good style.


Ok will split it up. Note that I'm not sure which of the two viewport unk
states exactly are necessary and have no time to figure that out so I'll
continue to group those two.

Wladimir


Regards,
Lucas

> >
> > Signed-off-by: Wladimir J. van der Laan 
> > ---
> >  src/gallium/drivers/etnaviv/etnaviv_context.c | 13 +
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c
b/src/gallium/drivers/etnaviv/etnaviv_context.c
> > index 2ca09ce..67aab6a 100644
> > --- a/src/gallium/drivers/etnaviv/etnaviv_context.c
> > +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
> > @@ -317,6 +317,19 @@ etna_cmd_stream_reset_notify(struct
etna_cmd_stream *stream, void *priv)
> > etna_set_state(stream, VIVS_GL_VERTEX_ELEMENT_CONFIG, 0x0001);
> > etna_set_state(stream, VIVS_RA_EARLY_DEPTH, 0x0031);
> > etna_set_state(stream, VIVS_PA_W_CLIP_LIMIT, 0x3401);
> > +   etna_set_state(stream, VIVS_PA_FLAGS, 0x); /* blob sets
ZCONVERT_BYPASS on GC3000, this messes up z for us */
> > +   etna_set_state(stream, VIVS_RA_UNK00E0C, 0x);
> > +   etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A80, 0x38a01404);
> > +   etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A84, fui(8192.0));
> > +   etna_set_state(stream, VIVS_PA_ZFARCLIPPING, 0x);
> > +   etna_set_state(stream, VIVS_PE_ALPHA_COLOR_EXT0, 0x);
> > +   etna_set_state(stream, VIVS_PE_ALPHA_COLOR_EXT1, 0x);
> > +   etna_set_state(stream, VIVS_RA_HDEPTH_CONTROL, 0x7000);
> > +   etna_set_state(stream, VIVS_PE_STENCIL_CONFIG_EXT2, 0x);
> > +   etna_set_state(stream, VIVS_GL_UNK03834, 0x);
> > +   etna_set_state(stream, VIVS_GL_UNK03838, 0x);
> > +   etna_set_state(stream, VIVS_GL_UNK03854, 0x);
> > +   etna_set_state(stream, VIVS_PS_CONTROL_EXT, 0x);
> >
> > /* Enable SINGLE_BUFFER for resolve, if supported */
> > etna_set_state(stream, VIVS_RS_SINGLE_BUFFER,
COND(ctx->specs.single_buffer, VIVS_RS_SINGLE_BUFFER_ENABLE));
> > --
> > 2.7.4
> >
>
> greets
> --
> Christian Gmeiner, MSc
>
> https://christian-gmeiner.info
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/19] etnaviv: GC7000: Support BLT as recipient for etna_stall

2017-11-05 Thread Wladimir
On Sun, Nov 5, 2017 at 12:47 PM, Christian Gmeiner
 wrote:
> 2017-10-30 17:16 GMT+01:00 Wladimir J. van der Laan :
>> When the BLT is involved as source or target, add an extra BLT
>> enable/disable sequence around the sync sequence.
>>
>
> Does this mean we are doing lazy blit operations? Or why is this needed at 
> all?

How do you mean with "lazy blit"?

This is required. Any syncing with the BLT will otherwise crash. The
Vivante blob does it, also.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08/19] etnaviv: GC7000: Split off RS blit functions

2017-11-05 Thread Wladimir
On Sun, Nov 5, 2017 at 1:09 PM, Christian Gmeiner
 wrote:
> 2017-10-30 17:16 GMT+01:00 Wladimir J. van der Laan :
>> Prepare for BLT-based blitting path by moving RS-based
>> blitting to its own implementation file.
>>
>> Signed-off-by: Wladimir J. van der Laan 
>> ---
>>  src/gallium/drivers/etnaviv/Makefile.sources   |   1 +
>
> src/gallium/drivers/etnaviv/meson.build needs changed too.
>
>>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c   | 553 +--
>>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.h   |   9 +
>>  .../drivers/etnaviv/etnaviv_clear_blit_rs.c| 595 
>> +
>
> Maybe we could move the rs specific stuff directly into
> etnaviv_rs.[ch]? So we end with
> etnaviv_blt.[ch] and etnaviv_rs.[ch]. (Just an idea I had during review).

I also thought about that, but kept the low/high level separation as
it was already there, as I didn't want to make it inconsistent between
RS and BLT. But I think it's a good idea in itself.

When that's done I also think we should move the RS emit code back
into etna_rs.c, that would make it self-contained.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/19] etnaviv: GC7000: No RS align when using BLT

2017-11-05 Thread Wladimir
>> +  if (!ctx->specs.use_blt) {
>> + /* This (ab)uses the RS as a plain buffer memset().
>> +  * Currently uses a fixed row size of 64 bytes. Some benchmarking 
>> with
>> +  * different sizes may be in order. */
>> + struct etna_bo *ts_bo = etna_resource(surf->base.texture)->ts_bo;
>> + etna_compile_rs_state(ctx, &surf->clear_command, &(struct 
>> rs_state) {
>> +.source_format = RS_FORMAT_A8R8G8B8,
>> +.dest_format = RS_FORMAT_A8R8G8B8,
>> +.dest = ts_bo,
>> +.dest_offset = surf->surf.ts_offset,
>> +.dest_stride = 0x40,
>> +.dest_tiling = ETNA_LAYOUT_TILED,
>> +.dither = {0x, 0x},
>> +.width = 16,
>> +.height = etna_align_up(surf->surf.ts_size / 0x40, 4),
>> +.clear_value = {ctx->specs.ts_clear_value},
>> +.clear_mode = VIVS_RS_CLEAR_CONTROL_MODE_ENABLED1,
>> +.clear_bits = 0x
>> + });
>> +  }
>> } else {
>> -  etna_rs_gen_clear_surface(ctx, surf, surf->level->clear_value);
>> +  if (!ctx->specs.use_blt)
>> + etna_rs_gen_clear_surface(ctx, surf, surf->level->clear_value);
>> }
>>
>
> if (!ctx->specs.use_blt) {
> } else {
>if (!ctx->specs.use_blt)
>   ..
> }
>
> Looks funny... btw. do you have a git branch somewhere to look at this sereis?

It looks somewhat funny but I don't think it's wrong.
There's an extra } there. Context is:

if (surf->surf.ts_size) {
  if (!ctx->specs.use_blt) {
...
  }
} else {
if (!ctx->specs.use_blt)
..
}

My current working tree can be found at
https://github.com/laanwj/mesa/tree/gc7000. It contains these patches
(but also some temporary local scaffolding, so be warned).

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] etnaviv: Add sampler TS support

2017-11-07 Thread Wladimir
> +/* Return true if a resource has a TS, and it is valid for at least one 
> level */
> +static bool
> +etna_resource_has_valid_ts(struct pipe_resource *prsc)
> +{
> +   struct etna_resource *rsc = etna_resource(prsc);
> +
> +   if (!rsc->ts_bo)
> +  return false;
> +
> +   for (int level = 0; level <= rsc->base.last_level; level++)
> +  if (rsc->levels[level].ts_valid)
> + return true;
> +   return false;
> +}

>  static void
> -etna_update_sampler_source(struct pipe_sampler_view *view)
> +etna_update_sampler_source(struct etna_context *ctx, struct 
> pipe_sampler_view *view, int num)
>  {
> struct etna_resource *base = etna_resource(view->texture);
> struct etna_resource *to = base, *from = base;
> +   bool enable_sampler_ts = false;
>
> if (base->external && etna_resource_newer(etna_resource(base->external), 
> base))
>from = etna_resource(base->external);
> @@ -128,12 +199,19 @@ etna_update_sampler_source(struct pipe_sampler_view 
> *view)
>etna_copy_resource(view->context, &to->base, &from->base, 0,
>   view->texture->last_level);
>to->seqno = from->seqno;
> -   } else if ((to == from) && etna_resource_needs_flush(to)) {
> -  /* Resolve TS if needed, remove when adding sampler TS */
> -  etna_copy_resource(view->context, &to->base, &from->base, 0,
> - view->texture->last_level);
> -  to->flush_seqno = from->seqno;
> +   } else if ((to == from) &&
> + etna_resource_needs_flush(to) &&
> + etna_resource_has_valid_ts(&to->base)) {

I just realized - would it maybe make sense to roll the call to
etna_resource_has_valid_ts into etna_resource_needs_flush?

etna_resource_needs_flush is only called from two places - here, and
in resource_flush, where it also determines whether to do a
resolve-to-self, but before presenting the image. There it also only
makes sense to do if the resource has at least a valid TS.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] etnaviv: Add TS_SAMPLER formats to etnaviv_format

2017-11-11 Thread Wladimir
On Tue, Nov 7, 2017 at 5:43 PM, Wladimir J. van der Laan
 wrote:
> Sampler TS introduces yet another format enumeration for renderable
> formats. Introduce it into etnaviv_format as unobtrusively as possible.
>
> Signed-off-by: Wladimir J. van der Laan 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_format.c | 19 +++
>  src/gallium/drivers/etnaviv/etnaviv_format.h |  3 +++
>  2 files changed, 22 insertions(+)

I think I found a potential problem with this approach of mapping
name-to-name. Though most of the RS formats map immediately to TS
formats, there are some exceptions, like the depth formats:

  _T(Z16_UNORM,  D16,  SWIZ(X, Y, Z, W), A4R4G4B4),
  _T(X8Z24_UNORM,   D24X8, SWIZ(X, Y, Z, W), A8R8G8B8),
  _T(S8_UINT_Z24_UNORM, D24X8, SWIZ(X, Y, Z, W), A8R8G8B8),

For practical reasons these have been assigned RS formats that happen
to have the same size, which is enough for RS blit.
Sampler TS on the other hand has dedicated formats for depth:

TS_SAMPLER_FORMAT_D24X8
TS_SAMPLER_FORMAT_D16

Not sure how much difference this makes, though... Depth texturing (as
in glmark shadow benchmark) seems to just work.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: Fix point sprite issue on HALTI0

2017-11-16 Thread Wladimir
On Thu, Nov 16, 2017 at 11:29 AM, Lucas Stach  wrote:

> Or maybe we can just scan the input
> varyings and if we find a PCOORD varying assume that we are going to
> render points, but I don't know if this assumption holds for all cases.

What if the PS doesn't use the point coordinate, e.g. to render solid points?

I thought about that, but I don't think it's general enough.

Could we make the blitter label texture coordinates properly?

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: Fix point sprite issue on HALTI0

2017-11-16 Thread Wladimir
>> What if the PS doesn't use the point coordinate, e.g. to render solid
>> points?
>>
>> I thought about that, but I don't think it's general enough.
>>
>> Could we make the blitter label texture coordinates properly?
>
> We could do that, but still most texcoord varyings from actual GLSL
> shaders will end up with SEMANTIC_GENERIC, which will break if the
> application is really using flatshading.

At least OpenGL ES would be covered in that case, as flat shading only
exists in OpenGL ES 1 which has no shaders.

I think it would be reasonable to re-emit the shader state (or maybe
just the varyings) when the primitive type changes from points to
non-points. It virtually never happens that the same shader combo is
used for points and non-points.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: Fix point sprite issue on HALTI0

2017-11-16 Thread Wladimir
> I think it would be reasonable to re-emit the shader state (or maybe
> just the varyings) when the primitive type changes from points to
> non-points. It virtually never happens that the same shader combo is
> used for points and non-points.

Thinking about it, this might even simplify some contorted code we
currently have in the emit sequence with regard to pointsize VS
outputs. Which becomes even worse in GC7000 where there's more (USC /
buffering related) state depending on the exact number of VS outputs.

Hmm that state depends on point_size_per_vertex, not whether we're
rendering points. So I guess we'd want to re-link the shader if:

- switching from point to non-point rendering, or vice versa
- if rendering points AND point_size_per_vertex changes

Though as for the latter I have no clue where vivantes get the point
size from if !point_size_per_vertex, currently we don't handle
pipe_rasterizer_state->point_size at all, we pretty much just assume
point_size_per_vertex.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: make use of TEXTURE_TYPE_1D

2017-10-26 Thread Wladimir
On Thu, Oct 26, 2017 at 9:45 AM, Lucas Stach  wrote:
> Am Donnerstag, den 26.10.2017, 03:17 +0200 schrieb Christian Gmeiner:
>> Signed-off-by: Christian Gmeiner 
>
> Has this been tested on older GPU cores like the GC600?

To be fair, I doubt any of the recent changes have been tested on GC600.

Is anyone doing this? I still have a cubox classic w/ GC600, but no time.

Is there even any upstream support for a SoC w/ https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: make use of TEXTURE_TYPE_1D

2017-10-26 Thread Wladimir
On Thu, Oct 26, 2017 at 4:16 PM, PrasannaKumar Muralidharan
 wrote:
>
> GCW Zero gaming console uses etnaviv for GC860. But they use very old
> version from 2013. It is not based on upstream version I think, does
> that count?

They use my initial version of etnaviv, which *only* had pre-GC2000 support.

I don't think they've ever tried any recent versions, because they
don't have a DRM driver for the display out and mesa has no fbdev
support anymore :)

(would be doable to hack around, but I don't have the time right now)

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: keep track of buffer valid ranges

2017-10-26 Thread Wladimir
On Thu, Oct 19, 2017 at 11:52 AM, Christian Gmeiner
 wrote:

>>> +   if ((usage & PIPE_TRANSFER_WRITE) &&
>>> + prsc->target == PIPE_BUFFER &&
>>> + !util_ranges_intersect(&rsc->valid_buffer_range,
>>> +box->x, box->x + box->width)) {
>>> + /* We are trying to write to a previously uninitialized range. No 
>>> need
>>> +  * to wait.
>>> +  */
>>
>> This unbalances the cpu_prep/fini in the map/unmap path. This isn't
>> allowed and the kernel will start to reject this in the near future.
>>
>
> Good to know that the kernel will reject this behauvior in the near future.

Seems a good idea nevertheless, and very welcome after rework, I've
seen some cases of excessive flushing coming from here.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: bugfix: Don't do resolve-in-place without valid TS

2017-11-01 Thread Wladimir
On Wed, Nov 1, 2017 at 11:35 AM, Eric Engestrom
 wrote:
> On Wednesday, 2017-11-01 11:17:53 +0100, Wladimir J. van der Laan wrote:
>> GC3000 resolve-in-place assumes that the TS state is configured.
>> If it is not, this will result in MMU errors. This is especially
>> apparent when using glGenMipmaps().
>>
>> Fixes a problem introduced in 78ade659569ee6fe9bd244170956139f19dd8c6c.
>
> I can't review your patch because I don't know anything about that code,
> but a quick drive-by comment: the format for this information is

Thanks for the heads-up, I didn't know there was a standard format,
will do that next time.

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v5 06/12] etnaviv: use common pipe_screen ref counting

2017-08-08 Thread Wladimir
On Tue, Aug 8, 2017 at 12:58 AM, Rob Herring  wrote:
> Use the common pipe_screen ref counting and fd hashing functions.
> The mutex can be dropped as the pipe loader serializes the
> create_screen() and destroy() calls.
>
> Signed-off-by: Rob Herring 
> Cc: Christian Gmeiner 
> Cc: Wladimir J. van der Laan 
> Cc: Lucas Stach 

This sure cleans up a lot.

Reviewed-by: Wladimir J. van der Laan 
(will test)

> ---
>  src/gallium/drivers/etnaviv/etnaviv_screen.c   |  1 -
>  src/gallium/drivers/etnaviv/etnaviv_screen.h   |  4 --
>  .../winsys/etnaviv/drm/etnaviv_drm_winsys.c| 81 
> +++---
>  3 files changed, 8 insertions(+), 78 deletions(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index 9aca90642c37..92950c3bfbb5 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -806,7 +806,6 @@ etna_screen_create(struct etna_device *dev, struct 
> etna_gpu *gpu,
> screen->dev = dev;
> screen->gpu = gpu;
> screen->ro = renderonly_dup(ro);
> -   screen->refcnt = 1;
>
> if (!screen->ro) {
>DBG("could not create renderonly object");
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.h 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.h
> index dc57a38dbb80..74b8e98d1695 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.h
> @@ -30,7 +30,6 @@
>
>  #include "etnaviv_internal.h"
>
> -#include "os/os_thread.h"
>  #include "pipe/p_screen.h"
>  #include "renderonly/renderonly.h"
>  #include "util/slab.h"
> @@ -59,9 +58,6 @@ enum viv_features_word {
>  struct etna_screen {
> struct pipe_screen base;
>
> -   int refcnt;
> -   void *winsys_priv;
> -
> struct etna_device *dev;
> struct etna_gpu *gpu;
> struct etna_pipe *pipe;
> diff --git a/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c 
> b/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
> index 8e3f7a06a9a0..09b20389810b 100644
> --- a/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
> +++ b/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
> @@ -28,6 +28,7 @@
>
>  #include "util/u_hash_table.h"
>  #include "util/u_memory.h"
> +#include "util/u_screen.h"
>
>  #include "etnaviv/etnaviv_screen.h"
>  #include "etnaviv/hw/common.xml.h"
> @@ -67,85 +68,19 @@ screen_create(struct renderonly *ro)
> return etna_screen_create(dev, gpu, ro);
>  }
>
> -static struct util_hash_table *etna_tab = NULL;
> -
> -static mtx_t etna_screen_mutex = _MTX_INITIALIZER_NP;
> -
> -static void
> -etna_drm_screen_destroy(struct pipe_screen *pscreen)
> -{
> -   struct etna_screen *screen = etna_screen(pscreen);
> -   boolean destroy;
> -
> -   mtx_lock(&etna_screen_mutex);
> -   destroy = --screen->refcnt == 0;
> -   if (destroy) {
> -  int fd = etna_device_fd(screen->dev);
> -  util_hash_table_remove(etna_tab, intptr_to_pointer(fd));
> -   }
> -   mtx_unlock(&etna_screen_mutex);
> -
> -   if (destroy) {
> -  pscreen->destroy = screen->winsys_priv;
> -  pscreen->destroy(pscreen);
> -   }
> -}
> -
> -static unsigned hash_fd(void *key)
> -{
> -   int fd = pointer_to_intptr(key);
> -   struct stat stat;
> -
> -   fstat(fd, &stat);
> -
> -   return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
> -}
> -
> -static int compare_fd(void *key1, void *key2)
> -{
> -   int fd1 = pointer_to_intptr(key1);
> -   int fd2 = pointer_to_intptr(key2);
> -   struct stat stat1, stat2;
> -
> -   fstat(fd1, &stat1);
> -   fstat(fd2, &stat2);
> -
> -   return stat1.st_dev != stat2.st_dev ||
> -  stat1.st_ino != stat2.st_ino ||
> -  stat1.st_rdev != stat2.st_rdev;
> -}
> -
>  struct pipe_screen *
>  etna_drm_screen_create_renderonly(struct renderonly *ro)
>  {
> -   struct pipe_screen *pscreen = NULL;
> +   struct etna_screen *screen;
> +   struct pipe_screen *pscreen = pipe_screen_reference(ro->gpu_fd);
>
> -   mtx_lock(&etna_screen_mutex);
> -   if (!etna_tab) {
> -  etna_tab = util_hash_table_create(hash_fd, compare_fd);
> -  if (!etna_tab)
> - goto unlock;
> -   }
> +   if (pscreen)
> +  return pscreen;
>
> -   pscreen = util_hash_table_get(etna_tab, intptr_to_pointer(ro->gpu_fd));
> -   if (pscreen) {
> -  etna_screen(pscreen)->refcnt++;
> -   } else {
> -  pscreen = screen_create(ro);
> -  if (pscreen) {
&g

[Mesa-dev] Choosing texture internal format in GLES

2013-09-27 Thread Wladimir
Hello,

Mareko and me had a small discussion about this on IRC.

Basically with GLES (1.0, 2.0 at least) the application has no way to
control the exact internal format [1]. This is intentional give the
hardware more leeway.

See http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml :
"Internalformat specifies the internal format of the texture. Must be one
of the following symbolic constants: GL_ALPHA,
GL_LUMINANCE,GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA."

The driver is free to choose the internal format based on these general
categories. However, with the current implementation mesa doesn't do any
special choosing for GLES. For one, GL_RGB is always converted to RGB8.
This can result in needless format conversion. I was helping to optimize an
application that makes a texture:

glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat =
GL_RGB, width = 256, height = 256, border = 0, format = GL_RGB, type =
GL_UNSIGNED_SHORT_5_6_5, pixels = [binary data, size = 128 kb])

One of these textures is updated every frame. Every time, the image data is
blown up to RGB8 because that's what the internal format became. This seems
wasteful both of CPU/GPU time and memory.

I proposed a crude patch that refines the internal format depending on the
input data type (this happens after GLES input checking that
format==internalFormat)
https://github.com/laanwj/mesa/commit/0c71bcf1c5cc06e26bfed7a72507555fe7e7ad97however
it doesn't take into account that the hardware may not support the
specific formats.

Mareko said it would be better to move the code to
st_choose_matching_format inside the state tracker. This makes sense
because the state tracker knows what formats are supported.

Any other opinions on this?

[1] there is an extension OES_required_internalformat which does give the
application more control, but I'm describing behavior without this extension

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Choosing texture internal format in GLES

2013-09-29 Thread Wladimir
On Sat, Sep 28, 2013 at 9:34 PM, Marek Olšák  wrote:

> No, I said it would be better to use st_choose_matching_format in
> st_ChooseTextureFormat, because st_choose_matching_format does exactly
> what you're trying to do.
>
> I have gone ahead and implemented what I had in mind. See the attached
> patch.
>

Thanks, tested this, it works,

Reviewed-by: Wladimir J. van der Laan 

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] gallium/auxiliary: Add ETC as compressed format

2013-04-05 Thread Wladimir
>From 1b3d69d7749e3b82f529d2a41b80f5cd64447d92 Mon Sep 17 00:00:00 2001
From: "Wladimir J. van der Laan" 
Date: Fri, 5 Apr 2013 18:58:32 +0200
Subject: [PATCH] gallium/auxiliary: Add ETC as compressed format

Add UTIL_FORMAT_LAYOUT_ETC to util_format_is_compressed. It was missing.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/auxiliary/util/u_format.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/auxiliary/util/u_format.h
b/src/gallium/auxiliary/util/u_format.h
index 0030126..ed942fb 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -447,6 +447,7 @@ util_format_is_compressed(enum pipe_format format)
switch (desc->layout) {
case UTIL_FORMAT_LAYOUT_S3TC:
case UTIL_FORMAT_LAYOUT_RGTC:
+   case UTIL_FORMAT_LAYOUT_ETC:
   /* XXX add other formats in the future */
   return TRUE;
default:
-- 
1.7.9.5
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium/auxiliary: Add ETC as compressed format

2013-04-05 Thread Wladimir
Hello Brian,

Reviewed-by: Brian Paul 
>
> Do you need someone to commit this for you?
>

Yes, I'm new here,

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] WL_bind_wayland_display

2013-05-26 Thread Wladimir
Hello all,

I was reading the WL_bind_wayland_display extension spec and noticed the
following:

EGL_TEXTURE_Y_U_V_WL
Three planes, samples Y from the first plane to r in
the shader, U from the second plane to r, and V from
the third plane to r.

EGL_TEXTURE_Y_UV_WL
Two planes, samples Y from the first plane to r in
the shader, U and V from the second plane to rg.

EGL_TEXTURE_Y_XUXV_WL
Two planes, samples Y from the first plane to r in
the shader, U and V from the second plane to g and a.

How does this work? EGL_TEXTURE_Y_U_V_WL puts all planes in r;
EGL_TEXTURE_Y_UV_WL puts a plane in r and one in rg (thus overlapping).

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Question about handling RGBA/BGRA in etnaviv driver

2017-02-08 Thread Wladimir J. van der Laan

> > Another way that I just realized would be to convert a texture to BGRA the
> > first time it's rendered to.
> >
> > In contrast to the shader solution that has only a one-time overhead. Is
> > this a stupid idea for any reason?

> We are doing something similar to convert sampled textures to the
> correct tiling format
> for the multi-pipe GPUs. (sampler can read only from tiled formats but
> the multi-pipe GPU
> can only render to multi-tiled or super-tiled resources). Have a look where
> etna_copy_resource(..) gets used.

I implemented this today, but unfortunately it's not working.

MESA doesn't like the format of the gallium texture changing under it, as it
tracks its own formats. This results in assertion errors later on when it tries
to copy data to the texture (as it assumes it can just use copy_region).

It would be possible to add a "fake" resource res->rtt for rendering to
(similar to how res->texture is used for rendering *from*), then copy and
convert as needed, but I don't think the added complexity is worth it. It would
no longer be a one-time overhead, every frame would be converted - for no good
reason but keep Mesa's higher-level texture handling happy.

If we can't come up with a better solution to this I'd say the most
straightforward solution to that would be to revert "etnaviv: add RGBX/RGBA
pixel formats".

I guess in a way this problem is at a higher level, maybe it should be solved
at the Mesa / GL ES level - applications using OpenGL ES API expect an
abstraction "GL_RGBA" which does not necessarily need to use RGBA layout in
memory.

(On the other hand for desktop GL the internal format is the internal format and
it may be expected behavior that a GPU that doesn't support rendering to
GL_RGBA rejects FBO's set up that way?)

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] etnaviv: keep track of emitted loops

2017-02-08 Thread Wladimir J. van der Laan
On Wed, Feb 08, 2017 at 12:10:24PM +0100, Christian Gmeiner wrote:
> Signed-off-by: Christian Gmeiner 

Sure why not.

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 6 ++
>  src/gallium/drivers/etnaviv/etnaviv_compiler.h | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index 7446a19..af7b64d 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -183,6 +183,8 @@ struct etna_compile {
> unsigned labels_count, labels_sz;
> struct etna_compile_label *labels;
>  
> +   unsigned num_loops;
> +
> /* Code generation */
> int inst_ptr; /* current instruction pointer */
> uint32_t code[ETNA_MAX_INSTRUCTIONS * ETNA_INST_SIZE];
> @@ -1166,6 +1168,8 @@ trans_loop_bgn(const struct instr_translater *t, struct 
> etna_compile *c,
> f->lbl_loop_end = alloc_new_label(c);
>  
> label_place(c, f->lbl_loop_bgn);
> +
> +   c->num_loops++;
>  }
>  
>  static void
> @@ -2418,6 +2422,7 @@ etna_compile_shader(const struct etna_specs *specs,
> shader->processor = c->info.processor;
> shader->code_size = c->inst_ptr * 4;
> shader->code = mem_dup(c->code, c->inst_ptr * 16);
> +   shader->num_loops = c->num_loops;
> shader->num_temps = c->next_free_native;
> shader->vs_pos_out_reg = -1;
> shader->vs_pointsize_out_reg = -1;
> @@ -2455,6 +2460,7 @@ etna_dump_shader(const struct etna_shader *shader)
>  
> etna_disasm(shader->code, shader->code_size, PRINT_RAW);
>  
> +   printf("num loops: %i\n", shader->num_loops);
> printf("num temps: %i\n", shader->num_temps);
> printf("num const: %i\n", shader->uniforms.const_count);
> printf("immediates:\n");
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.h 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.h
> index d310109..211ae1a 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.h
> @@ -59,6 +59,7 @@ struct etna_shader {
> uint processor; /* TGSI_PROCESSOR_... */
> uint32_t code_size; /* code size in uint32 words */
> uint32_t *code;
> +   unsigned num_loops;
> unsigned num_temps;
>  
> struct etna_shader_uniform_info uniforms;
> -- 
> 2.7.4
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] etnaviv: shader-db traces

2017-02-08 Thread Wladimir J. van der Laan
On Wed, Feb 08, 2017 at 12:10:25PM +0100, Christian Gmeiner wrote:
> Signed-off-by: Christian Gmeiner 

Reviewed-By: Wladimir J. van der Laan 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] etnaviv: Update hw header files

2017-02-09 Thread Wladimir J. van der Laan
Update from etnaviv repository rnndb.
---
 src/gallium/drivers/etnaviv/hw/cmdstream.xml.h |   6 +-
 src/gallium/drivers/etnaviv/hw/common.xml.h|  14 +--
 src/gallium/drivers/etnaviv/hw/isa.xml.h   |   6 +-
 src/gallium/drivers/etnaviv/hw/state.xml.h |  30 +++--
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h  | 152 +
 5 files changed, 160 insertions(+), 48 deletions(-)

This adds some newly discovered state for GC3000 (and some GC2000) features.

diff --git a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h 
b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
index c5275db..4e78eba 100644
--- a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
@@ -8,9 +8,9 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- cmdstream.xml (  14094 bytes, from 2016-11-16 18:54:37)
-- copyright.xml (   1597 bytes, from 2016-10-02 14:26:13)
-- common.xml(  23422 bytes, from 2016-11-16 18:54:37)
+- cmdstream.xml (  14313 bytes, from 2016-11-17 18:46:23)
+- copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
+- common.xml(  23473 bytes, from 2016-12-11 10:32:13)
 
 Copyright (C) 2012-2016 by the following authors:
 - Wladimir J. van der Laan 
diff --git a/src/gallium/drivers/etnaviv/hw/common.xml.h 
b/src/gallium/drivers/etnaviv/hw/common.xml.h
index 8d8ef7d..0f99db2 100644
--- a/src/gallium/drivers/etnaviv/hw/common.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/common.xml.h
@@ -8,13 +8,13 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml (  19792 bytes, from 2016-11-16 18:54:37)
-- common.xml(  23422 bytes, from 2016-11-16 18:54:37)
-- state_hi.xml  (  25653 bytes, from 2016-10-02 14:26:13)
-- copyright.xml (   1597 bytes, from 2016-10-02 14:26:13)
-- state_2d.xml  (  51552 bytes, from 2016-10-02 14:26:13)
-- state_3d.xml  (  57579 bytes, from 2016-11-16 18:54:37)
-- state_vg.xml  (   5975 bytes, from 2016-10-02 14:26:13)
+- state.xml (  19930 bytes, from 2016-12-14 15:25:40)
+- common.xml(  23473 bytes, from 2016-12-11 10:32:13)
+- state_hi.xml  (  26403 bytes, from 2016-12-14 06:43:27)
+- copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
+- state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
+- state_3d.xml  (  66957 bytes, from 2016-12-15 11:31:03)
+- state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors:
 - Wladimir J. van der Laan 
diff --git a/src/gallium/drivers/etnaviv/hw/isa.xml.h 
b/src/gallium/drivers/etnaviv/hw/isa.xml.h
index 70cc74a..c604b44 100644
--- a/src/gallium/drivers/etnaviv/hw/isa.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/isa.xml.h
@@ -8,8 +8,8 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- isa.xml   (  24392 bytes, from 2016-11-16 18:54:37)
-- copyright.xml (   1597 bytes, from 2016-10-02 14:26:13)
+- isa.xml   (  30048 bytes, from 2016-12-12 13:26:33)
+- copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors:
 - Wladimir J. van der Laan 
@@ -78,6 +78,7 @@ DEALINGS IN THE SOFTWARE.
 #define INST_OPCODE_CEIL   0x0026
 #define INST_OPCODE_SIGN   0x0027
 #define INST_OPCODE_I2F
0x002d
+#define INST_OPCODE_F2I
0x002e
 #define INST_OPCODE_CMP
0x0031
 #define INST_OPCODE_LOAD   0x0032
 #define INST_OPCODE_STORE  0x0033
@@ -92,6 +93,7 @@ DEALINGS IN THE SOFTWARE.
 #define INST_OPCODE_AND
0x005d
 #define INST_OPCODE_XOR
0x005e
 #define INST_OPCODE_NOT
0x005f
+#define INST_OPCODE_POPCOUNT   0x0061
 #define INST_CONDITION_TRUE0x
 #define INST_CONDITION_GT  0x0001
 #define INST_CONDITION_LT  0x0002
diff --git a/src/gallium/drivers/etnaviv/hw/state.xml.h 
b/src/gallium/drivers/etnaviv/hw/state.xml.h
index d9bb9c4..73ef042 100644
--- a/src/gallium/drivers/etnaviv/hw/state.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/state.xml.h
@@ -8,13 +8,13 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml (  19792 bytes, from 2016-11-16 18:54:37

[Mesa-dev] [PATCH 2/2] etnaviv: Set shader instruction area correctly for GC3000

2017-02-09 Thread Wladimir J. van der Laan
- Use the same instruction area on GC3000 as the Vivante driver.
  This allows the same number of instructions on GC3000 as GC2000
  instead of half.

- Makes sure that the "PE to FE" stall before updating the shader code
  or constants is hit (which is conditional on vs_offset > 0x4000). This
  is necessary on GC3000 too, it increases stability.
---
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index 8c66f79..1507967 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -626,14 +626,30 @@ etna_get_specs(struct etna_screen *screen)
screen->specs.has_new_sin_cos =
   VIV_FEATURE(screen, chipMinorFeatures3, HAS_FAST_TRANSCENDENTALS);
 
-   if (instruction_count > 256) { /* unified instruction memory? */
+   if (VIV_FEATURE(screen, chipMinorFeatures3, INSTRUCTION_CACHE)) {
+  /* GC3000 - this core is capable of loading shaders from
+   * memory. It can also run shaders from registers, as a fallback, but
+   * "max_instructions" does not have the correct value. It has place for
+   * 2*256 instructions just like GC2000, but the offsets are slightly
+   * different.
+   */
   screen->specs.vs_offset = 0xC000;
-  screen->specs.ps_offset = 0xD000; /* like vivante driver */
+  /* State 08000-0C000 mirrors 0C000-0E000, and the Vivante driver uses
+   * this mirror for writing PS instructions, probably safest to do the
+   * same.
+   */
+  screen->specs.ps_offset = 0x8000 + 0x1000;
   screen->specs.max_instructions = 256;
} else {
-  screen->specs.vs_offset = 0x4000;
-  screen->specs.ps_offset = 0x6000;
-  screen->specs.max_instructions = instruction_count / 2;
+  if (instruction_count > 256) { /* unified instruction memory? */
+ screen->specs.vs_offset = 0xC000;
+ screen->specs.ps_offset = 0xD000; /* like vivante driver */
+ screen->specs.max_instructions = 256;
+  } else {
+ screen->specs.vs_offset = 0x4000;
+ screen->specs.ps_offset = 0x6000;
+ screen->specs.max_instructions = instruction_count / 2;
+  }
}
 
if (VIV_FEATURE(screen, chipMinorFeatures1, HALTI0)) {
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] etnaviv: shader-db traces

2017-02-09 Thread Wladimir J. van der Laan
> > >>  /* shader object, for linking */
> > >>  struct etna_shader {
> > >> +   uint32_t id; /* for debug */
> > >
> > > Do you need this? It can certainly be removed from this patch, but I
> > > don't know if you have other stuff building on top of this.
> > >
> > 
> > It gets used in dump_shader_info(..) which was added with this patch.
> 
> My argument was that you could pass that value as an argument to
> dump_shader_info(). I don't see why it needs to be stored inside the
> etna_shader object.

One advantage of storing it is that debug logging that refers to the shader
can use the same number and it can be correlated with the info dumped earlier.

Not that that is part of this patch, but that seems to be the goal.

If not for that there's no real use for a counter anyway: just have whatever
parses the output do the counting based on what is printed first.

But I think it's fine as it is.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] etnaviv: shader-db traces

2017-02-09 Thread Wladimir J. van der Laan
> Okay.. I will add the id member in a later patch to etna_shader
> object. For the moment
> I will pass it as an argument to dump_shader_info(..). Will send a V2
> of that series later the day.

To be honest I think it's nonsense to change this now, if you need an
id in the shader object then add an id to the shader object. It's not like
that overhead is significant and if you're going to add it later anyway
we're pretty much wasting time here by removing it and adding it back...

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] etnaviv: native fence fd support

2017-04-11 Thread Wladimir J. van der Laan
On Fri, Apr 07, 2017 at 02:21:35PM +0200, Philipp Zabel wrote:
> This adds native fence fd support to etnaviv, similarly to commit
> 0b98e84e9ba0 ("freedreno: native fence fd"), enabled for kernel
> driver version 1.1 or later.
> 
> Signed-off-by: Philipp Zabel 

Patch looks good to me,

Reviewed-By: Wladimir J. van der Laan 

> ---
> v2: address review comments
> - always call etna_cmd_stream_flush2
> - remove FIXME comment about in_fence_fd storage
> - simplify version check and add an ETNA_DRM_VERSION_FENCE_FD define
> 
> This depends on libdrm patches [1][2] which may or may not make their
> way into libdrm 2.4.79.
> [1] https://patchwork.kernel.org/patch/9669375/
> [2] https://patchwork.kernel.org/patch/9669377/
> ---
>  configure.ac  |  2 +-
>  src/gallium/drivers/etnaviv/etnaviv_context.c | 14 +++--
>  src/gallium/drivers/etnaviv/etnaviv_context.h |  1 +
>  src/gallium/drivers/etnaviv/etnaviv_fence.c   | 45 
> +--
>  src/gallium/drivers/etnaviv/etnaviv_fence.h   | 14 -
>  src/gallium/drivers/etnaviv/etnaviv_screen.c  | 12 ++-
>  src/gallium/drivers/etnaviv/etnaviv_screen.h  |  2 ++
>  7 files changed, 83 insertions(+), 7 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 7d92b33a0f..e75f4a5ce5 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -80,7 +80,7 @@ LIBDRM_NVVIEUX_REQUIRED=2.4.66
>  LIBDRM_NOUVEAU_REQUIRED=2.4.66
>  LIBDRM_FREEDRENO_REQUIRED=2.4.74
>  LIBDRM_VC4_REQUIRED=2.4.69
> -LIBDRM_ETNAVIV_REQUIRED=2.4.74
> +LIBDRM_ETNAVIV_REQUIRED=2.4.79
>  
>  dnl Versions for external dependencies
>  DRI2PROTO_REQUIRED=2.8
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
> b/src/gallium/drivers/etnaviv/etnaviv_context.c
> index 555aa12765..09f782fc81 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
> @@ -73,6 +73,9 @@ etna_context_destroy(struct pipe_context *pctx)
>  
> slab_destroy_child(&ctx->transfer_pool);
>  
> +   if (ctx->in_fence_fd != -1)
> +  close(ctx->in_fence_fd);
> +
> FREE(pctx);
>  }
>  
> @@ -275,11 +278,14 @@ etna_flush(struct pipe_context *pctx, struct 
> pipe_fence_handle **fence,
> enum pipe_flush_flags flags)
>  {
> struct etna_context *ctx = etna_context(pctx);
> +   int out_fence_fd = -1;
>  
> -   etna_cmd_stream_flush(ctx->stream);
> +   etna_cmd_stream_flush2(ctx->stream, ctx->in_fence_fd,
> +   (flags & PIPE_FLUSH_FENCE_FD) ? &out_fence_fd :
> +   NULL);
>  
> if (fence)
> -  *fence = etna_fence_create(pctx);
> +  *fence = etna_fence_create(pctx, out_fence_fd);
>  }
>  
>  static void
> @@ -353,10 +359,14 @@ etna_context_create(struct pipe_screen *pscreen, void 
> *priv, unsigned flags)
> /*  Set sensible defaults for state */
> etna_cmd_stream_reset_notify(ctx->stream, ctx);
>  
> +   ctx->in_fence_fd = -1;
> +
> pctx->destroy = etna_context_destroy;
> pctx->draw_vbo = etna_draw_vbo;
> pctx->flush = etna_flush;
> pctx->set_debug_callback = etna_set_debug_callback;
> +   pctx->create_fence_fd = etna_create_fence_fd;
> +   pctx->fence_server_sync = etna_fence_server_sync;
>  
> /* creation of compile states */
> pctx->create_blend_state = etna_blend_state_create;
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h 
> b/src/gallium/drivers/etnaviv/etnaviv_context.h
> index 9e00d34d23..56b57b55a8 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.h
> @@ -178,6 +178,7 @@ struct etna_context {
> } stats;
>  
> struct pipe_debug_callback debug;
> +   int in_fence_fd;
>  };
>  
>  static inline struct etna_context *
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_fence.c 
> b/src/gallium/drivers/etnaviv/etnaviv_fence.c
> index 02f520b8b3..65402aaa3b 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_fence.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_fence.c
> @@ -25,6 +25,8 @@
>   *Rob Clark 
>   */
>  
> +#include 
> +
>  #include "etnaviv_fence.h"
>  #include "etnaviv_context.h"
>  #include "etnaviv_screen.h"
> @@ -36,16 +38,25 @@ struct pipe_fence_handle {
> struct pipe_reference reference;
> struct etna_context *ctx;
> struct etna_screen *screen;
> +   int fence_fd;
> uint32_t timestamp;
>  };
>  
>  static void
> +etna_fence_destroy(struct pipe_fence_handle *fence)
> +{
> +   if (fence->fence_fd != -1)
> +  

[Mesa-dev] [PATCH 1/3] etnaviv: Add chipMinorFeatures4 and 5

2017-04-13 Thread Wladimir J. van der Laan
Request chipMinorFeatures bitfields 4 and 5 from the
drm driver.
---
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 12 
 src/gallium/drivers/etnaviv/etnaviv_screen.h |  4 +++-
 2 files changed, 15 insertions(+), 1 deletion(-)

Adds two further chipminorfeatures words - 
viv_chipMinorFeatures4 is necessary to be able to detect SINGLE_BUFFER.
viv_chipMinorFeatures5 isn't, but adding it because it will come in useful 
later.

diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index aa53917..41bacbc 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -800,6 +800,18 @@ etna_screen_create(struct etna_device *dev, struct 
etna_gpu *gpu,
}
screen->features[4] = val;
 
+   if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_5, &val)) {
+  DBG("could not get ETNA_GPU_FEATURES_5");
+  goto fail;
+   }
+   screen->features[5] = val;
+
+   if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_6, &val)) {
+  DBG("could not get ETNA_GPU_FEATURES_6");
+  goto fail;
+   }
+   screen->features[6] = val;
+
if (!etna_get_specs(screen))
   goto fail;
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.h 
b/src/gallium/drivers/etnaviv/etnaviv_screen.h
index c33a9e3..a606e5d 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.h
@@ -44,6 +44,8 @@ enum viv_features_word {
viv_chipMinorFeatures1 = 2,
viv_chipMinorFeatures2 = 3,
viv_chipMinorFeatures3 = 4,
+   viv_chipMinorFeatures4 = 5,
+   viv_chipMinorFeatures5 = 6,
VIV_FEATURES_WORD_COUNT /* Must be last */
 };
 
@@ -69,7 +71,7 @@ struct etna_screen {
 
uint32_t model;
uint32_t revision;
-   uint32_t features[5];
+   uint32_t features[VIV_FEATURES_WORD_COUNT];
 
struct etna_specs specs;
 };
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/3] etnaviv: Update includes from rnndb

2017-04-13 Thread Wladimir J. van der Laan
Update to etna_viv commit 411bd69.
---
 src/gallium/drivers/etnaviv/hw/cmdstream.xml.h |  2 +-
 src/gallium/drivers/etnaviv/hw/common.xml.h| 10 ++--
 src/gallium/drivers/etnaviv/hw/isa.xml.h   | 75 +-
 src/gallium/drivers/etnaviv/hw/state.xml.h | 10 ++--
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h  | 14 ++---
 5 files changed, 91 insertions(+), 20 deletions(-)

Adds many shader instructions, and documents RS single_buffer state

diff --git a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h 
b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
index 4e78eba..d4da030 100644
--- a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
@@ -10,7 +10,7 @@ git clone git://0x04.net/rules-ng-ng
 The rules-ng-ng source files this header was generated from are:
 - cmdstream.xml (  14313 bytes, from 2016-11-17 18:46:23)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
-- common.xml(  23473 bytes, from 2016-12-11 10:32:13)
+- common.xml(  23473 bytes, from 2017-01-07 14:27:54)
 
 Copyright (C) 2012-2016 by the following authors:
 - Wladimir J. van der Laan 
diff --git a/src/gallium/drivers/etnaviv/hw/common.xml.h 
b/src/gallium/drivers/etnaviv/hw/common.xml.h
index 0f99db2..8b73fd8 100644
--- a/src/gallium/drivers/etnaviv/hw/common.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/common.xml.h
@@ -8,15 +8,15 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml (  19930 bytes, from 2016-12-14 15:25:40)
-- common.xml(  23473 bytes, from 2016-12-11 10:32:13)
-- state_hi.xml  (  26403 bytes, from 2016-12-14 06:43:27)
+- state.xml (  19930 bytes, from 2017-01-07 14:27:54)
+- common.xml(  23473 bytes, from 2017-01-07 14:27:54)
+- state_hi.xml  (  26403 bytes, from 2017-01-07 14:27:54)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  66957 bytes, from 2016-12-15 11:31:03)
+- state_3d.xml  (  66964 bytes, from 2017-04-13 12:38:05)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
-Copyright (C) 2012-2016 by the following authors:
+Copyright (C) 2012-2017 by the following authors:
 - Wladimir J. van der Laan 
 - Christian Gmeiner 
 - Lucas Stach 
diff --git a/src/gallium/drivers/etnaviv/hw/isa.xml.h 
b/src/gallium/drivers/etnaviv/hw/isa.xml.h
index c604b44..28803df 100644
--- a/src/gallium/drivers/etnaviv/hw/isa.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/isa.xml.h
@@ -8,10 +8,10 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- isa.xml   (  30048 bytes, from 2016-12-12 13:26:33)
+- isa.xml   (  34392 bytes, from 2017-04-13 12:44:36)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 
-Copyright (C) 2012-2016 by the following authors:
+Copyright (C) 2012-2017 by the following authors:
 - Wladimir J. van der Laan 
 - Christian Gmeiner 
 - Lucas Stach 
@@ -77,14 +77,54 @@ DEALINGS IN THE SOFTWARE.
 #define INST_OPCODE_FLOOR  0x0025
 #define INST_OPCODE_CEIL   0x0026
 #define INST_OPCODE_SIGN   0x0027
+#define INST_OPCODE_ADDLO  0x0028
+#define INST_OPCODE_MULLO  0x0029
+#define INST_OPCODE_BARRIER0x002a
+#define INST_OPCODE_SWIZZLE0x002b
+#define INST_OPCODE_I2I
0x002c
 #define INST_OPCODE_I2F
0x002d
 #define INST_OPCODE_F2I
0x002e
+#define INST_OPCODE_F2IRND 0x002f
+#define INST_OPCODE_F2I7   0x0030
 #define INST_OPCODE_CMP
0x0031
 #define INST_OPCODE_LOAD   0x0032
 #define INST_OPCODE_STORE  0x0033
+#define INST_OPCODE_COPYSIGN   0x0034
+#define INST_OPCODE_GETEXP 0x0035
+#define INST_OPCODE_GETMANT0x0036
+#define INST_OPCODE_NAN
0x0037
+#define INST_OPCODE_NEXTAFTER  0x0038
+#define INST_OPCODE_ROUNDEVEN  0x0039
+#define INST_OPCODE_ROUNDAWAY  0x003a
+#define INST_OPCODE_IADDSAT0x003b
 #define INST_OPCODE_IMULLO0

[Mesa-dev] [PATCH 3/3] etnaviv: SINGLE_BUFFER support on GC3000

2017-04-13 Thread Wladimir J. van der Laan
This patch adds support for the SINGLE_BUFFER feature on GC3000
GPUs, which allows rendering to a single buffer using multiple pixel
pipes.

This feature is always used when it is available, which means that
multi-tiled formats are no longer being used in that case, and all
buffers will be normal (super)tiled. This mimics the behavior of the
blob on GC3000.

- Because the same format can be used to render to and texture from,
  this avoids an extra resolve pass when rendering to texture.

- i.MX6qp includes a PRE which can scan-out directly from tiled formats,
  avoiding untiling overhead.
---
 src/gallium/drivers/etnaviv/etnaviv_context.c  |  3 +++
 src/gallium/drivers/etnaviv/etnaviv_emit.c |  6 --
 src/gallium/drivers/etnaviv/etnaviv_internal.h |  3 +++
 src/gallium/drivers/etnaviv/etnaviv_resource.c |  9 +++-
 src/gallium/drivers/etnaviv/etnaviv_rs.c   | 29 ++
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |  5 +
 src/gallium/drivers/etnaviv/etnaviv_state.c| 10 +++--
 src/gallium/drivers/etnaviv/etnaviv_surface.c  | 21 +--
 8 files changed, 66 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 555aa12..f2f709c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -293,6 +293,9 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream 
*stream, void *priv)
etna_set_state(stream, VIVS_RA_EARLY_DEPTH, 0x0031);
etna_set_state(stream, VIVS_PA_W_CLIP_LIMIT, 0x3401);
 
+   /* Enable SINGLE_BUFFER for resolve, if supported */
+   etna_set_state(stream, VIVS_RS_SINGLE_BUFFER, 
COND(ctx->specs.single_buffer, VIVS_RS_SINGLE_BUFFER_ENABLE));
+
ctx->dirty = ~0L;
 
/* go through all the used resources and clear their status flag */
diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c 
b/src/gallium/drivers/etnaviv/etnaviv_emit.c
index af74cbb..7ced5fc 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_emit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c
@@ -603,10 +603,12 @@ etna_emit_state(struct etna_context *ctx)
if (unlikely(dirty & (ETNA_DIRTY_STENCIL_REF))) {
   /*014A0*/ EMIT_STATE(PE_STENCIL_CONFIG_EXT, 
ctx->stencil_ref.PE_STENCIL_CONFIG_EXT);
}
+   if (unlikely(dirty & (ETNA_DIRTY_BLEND | ETNA_DIRTY_FRAMEBUFFER))) {
+  struct etna_blend_state *blend = etna_blend_state(ctx->blend);
+  /*014A4*/ EMIT_STATE(PE_LOGIC_OP, blend->PE_LOGIC_OP | 
ctx->framebuffer.PE_LOGIC_OP);
+   }
if (unlikely(dirty & (ETNA_DIRTY_BLEND))) {
   struct etna_blend_state *blend = etna_blend_state(ctx->blend);
-
-  /*014A4*/ EMIT_STATE(PE_LOGIC_OP, blend->PE_LOGIC_OP);
   for (int x = 0; x < 2; ++x) {
  /*014A8*/ EMIT_STATE(PE_DITHER(x), blend->PE_DITHER[x]);
   }
diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
b/src/gallium/drivers/etnaviv/etnaviv_internal.h
index 2f09d55..2f8dacb 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
@@ -72,6 +72,8 @@ struct etna_specs {
unsigned has_shader_range_registers : 1;
/* has the new sin/cos functions */
unsigned has_new_sin_cos : 1;
+   /* supports single-buffer rendering with multiple pixel pipes */
+   unsigned single_buffer : 1;
/* can use any kind of wrapping mode on npot textures */
unsigned npot_tex_any_wrap;
/* number of bits per TS tile */
@@ -191,6 +193,7 @@ struct compiled_framebuffer_state {
uint32_t TS_COLOR_CLEAR_VALUE;
struct etna_reloc TS_COLOR_STATUS_BASE;
struct etna_reloc TS_COLOR_SURFACE_BASE;
+   uint32_t PE_LOGIC_OP;
bool msaa_mode; /* adds input (and possible temp) to PS */
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 1f0582c..b4e853f 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -248,9 +248,16 @@ etna_resource_create(struct pipe_screen *pscreen,
   if (util_format_is_compressed(templat->format))
  layout = ETNA_LAYOUT_LINEAR;
} else if (templat->target != PIPE_BUFFER) {
-  bool want_multitiled = screen->specs.pixel_pipes > 1;
+  bool want_multitiled = false;
   bool want_supertiled = screen->specs.can_supertile && 
!DBG_ENABLED(ETNA_DBG_NO_SUPERTILE);
 
+  /* When this GPU supports single-buffer rendering, don't ever enable
+   * multi-tiling. This replicates the blob behavior on GC3000.
+   */
+  if (!screen->specs.single_buffer) {
+ want_multitiled = screen->specs.pixel_pipes > 1;
+  }
+
   /* Keep single byte blocksized resources as tiled, since we
* are unable to use the RS blit to de-tile them. However,
* if they're used as a render target or depth/stencil, they
diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
b/src/gallium/drivers/etna

[Mesa-dev] [PATCH v2 1/3] etnaviv: Add chipMinorFeatures4 and 5

2017-04-14 Thread Wladimir J. van der Laan
Request chipMinorFeatures bitfields 4 and 5 from the
drm driver.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 12 
 src/gallium/drivers/etnaviv/etnaviv_screen.h |  4 +++-
 2 files changed, 15 insertions(+), 1 deletion(-)

no changes from v1 in this patch, just re-submitting the whole series.

diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index aa53917..41bacbc 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -800,6 +800,18 @@ etna_screen_create(struct etna_device *dev, struct 
etna_gpu *gpu,
}
screen->features[4] = val;
 
+   if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_5, &val)) {
+  DBG("could not get ETNA_GPU_FEATURES_5");
+  goto fail;
+   }
+   screen->features[5] = val;
+
+   if (etna_gpu_get_param(screen->gpu, ETNA_GPU_FEATURES_6, &val)) {
+  DBG("could not get ETNA_GPU_FEATURES_6");
+  goto fail;
+   }
+   screen->features[6] = val;
+
if (!etna_get_specs(screen))
   goto fail;
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.h 
b/src/gallium/drivers/etnaviv/etnaviv_screen.h
index c33a9e3..a606e5d 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.h
@@ -44,6 +44,8 @@ enum viv_features_word {
viv_chipMinorFeatures1 = 2,
viv_chipMinorFeatures2 = 3,
viv_chipMinorFeatures3 = 4,
+   viv_chipMinorFeatures4 = 5,
+   viv_chipMinorFeatures5 = 6,
VIV_FEATURES_WORD_COUNT /* Must be last */
 };
 
@@ -69,7 +71,7 @@ struct etna_screen {
 
uint32_t model;
uint32_t revision;
-   uint32_t features[5];
+   uint32_t features[VIV_FEATURES_WORD_COUNT];
 
struct etna_specs specs;
 };
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 2/3] etnaviv: Update includes from rnndb

2017-04-14 Thread Wladimir J. van der Laan
Update to etna_viv commit 411bd69.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/hw/cmdstream.xml.h |  2 +-
 src/gallium/drivers/etnaviv/hw/common.xml.h| 10 ++--
 src/gallium/drivers/etnaviv/hw/isa.xml.h   | 75 +-
 src/gallium/drivers/etnaviv/hw/state.xml.h | 10 ++--
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h  | 14 ++---
 5 files changed, 91 insertions(+), 20 deletions(-)

Same, no changes from v1 (well, Signed-off-by was added to the commit message).

diff --git a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h 
b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
index 4e78eba..d4da030 100644
--- a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
@@ -10,7 +10,7 @@ git clone git://0x04.net/rules-ng-ng
 The rules-ng-ng source files this header was generated from are:
 - cmdstream.xml (  14313 bytes, from 2016-11-17 18:46:23)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
-- common.xml(  23473 bytes, from 2016-12-11 10:32:13)
+- common.xml(  23473 bytes, from 2017-01-07 14:27:54)
 
 Copyright (C) 2012-2016 by the following authors:
 - Wladimir J. van der Laan 
diff --git a/src/gallium/drivers/etnaviv/hw/common.xml.h 
b/src/gallium/drivers/etnaviv/hw/common.xml.h
index 0f99db2..8b73fd8 100644
--- a/src/gallium/drivers/etnaviv/hw/common.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/common.xml.h
@@ -8,15 +8,15 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml (  19930 bytes, from 2016-12-14 15:25:40)
-- common.xml(  23473 bytes, from 2016-12-11 10:32:13)
-- state_hi.xml  (  26403 bytes, from 2016-12-14 06:43:27)
+- state.xml (  19930 bytes, from 2017-01-07 14:27:54)
+- common.xml(  23473 bytes, from 2017-01-07 14:27:54)
+- state_hi.xml  (  26403 bytes, from 2017-01-07 14:27:54)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  66957 bytes, from 2016-12-15 11:31:03)
+- state_3d.xml  (  66964 bytes, from 2017-04-13 12:38:05)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
-Copyright (C) 2012-2016 by the following authors:
+Copyright (C) 2012-2017 by the following authors:
 - Wladimir J. van der Laan 
 - Christian Gmeiner 
 - Lucas Stach 
diff --git a/src/gallium/drivers/etnaviv/hw/isa.xml.h 
b/src/gallium/drivers/etnaviv/hw/isa.xml.h
index c604b44..28803df 100644
--- a/src/gallium/drivers/etnaviv/hw/isa.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/isa.xml.h
@@ -8,10 +8,10 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- isa.xml   (  30048 bytes, from 2016-12-12 13:26:33)
+- isa.xml   (  34392 bytes, from 2017-04-13 12:44:36)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 
-Copyright (C) 2012-2016 by the following authors:
+Copyright (C) 2012-2017 by the following authors:
 - Wladimir J. van der Laan 
 - Christian Gmeiner 
 - Lucas Stach 
@@ -77,14 +77,54 @@ DEALINGS IN THE SOFTWARE.
 #define INST_OPCODE_FLOOR  0x0025
 #define INST_OPCODE_CEIL   0x0026
 #define INST_OPCODE_SIGN   0x0027
+#define INST_OPCODE_ADDLO  0x0028
+#define INST_OPCODE_MULLO  0x0029
+#define INST_OPCODE_BARRIER0x002a
+#define INST_OPCODE_SWIZZLE0x002b
+#define INST_OPCODE_I2I
0x002c
 #define INST_OPCODE_I2F
0x002d
 #define INST_OPCODE_F2I
0x002e
+#define INST_OPCODE_F2IRND 0x002f
+#define INST_OPCODE_F2I7   0x0030
 #define INST_OPCODE_CMP
0x0031
 #define INST_OPCODE_LOAD   0x0032
 #define INST_OPCODE_STORE  0x0033
+#define INST_OPCODE_COPYSIGN   0x0034
+#define INST_OPCODE_GETEXP 0x0035
+#define INST_OPCODE_GETMANT0x0036
+#define INST_OPCODE_NAN
0x0037
+#define INST_OPCODE_NEXTAFTER  0x0038
+#define INST_OPCODE_ROUNDEVEN  0x0039
+#define INST_OPCODE_ROUNDAWAY  0x003a
+#define INST_OPCODE_IADDSAT0x003b
 #define

[Mesa-dev] [PATCH v2 3/3] etnaviv: SINGLE_BUFFER support on GC3000

2017-04-14 Thread Wladimir J. van der Laan
This patch adds support for the SINGLE_BUFFER feature on GC3000
GPUs, which allows rendering to a single buffer using multiple pixel
pipes.

This feature is always used when it is available, which means that
multi-tiled formats are no longer being used in that case, and all
buffers will be normal (super)tiled. This mimics the behavior of the
blob on GC3000.

- Because the same format can be used to render to and texture from,
  this avoids an extra resolve pass when rendering to texture.

- i.MX6qp includes a PRE which can scan-out directly from tiled formats,
  avoiding untiling overhead.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_context.c  |  3 ++
 src/gallium/drivers/etnaviv/etnaviv_emit.c |  6 ++--
 src/gallium/drivers/etnaviv/etnaviv_internal.h |  3 ++
 src/gallium/drivers/etnaviv/etnaviv_resource.c |  8 +-
 src/gallium/drivers/etnaviv/etnaviv_rs.c   | 39 +++---
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |  4 +++
 src/gallium/drivers/etnaviv/etnaviv_state.c| 10 +--
 src/gallium/drivers/etnaviv/etnaviv_surface.c  | 18 
 8 files changed, 63 insertions(+), 28 deletions(-)

Changed for v2:
- Minor code style changes as suggested by Christian Gmeiner and Philipp Zabel
- Remove duplicate code for multi-tiled case in etnaviv_rs.c / 
etnaviv_surface.c (Philipp Zabel)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 555aa12..f2f709c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -293,6 +293,9 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream 
*stream, void *priv)
etna_set_state(stream, VIVS_RA_EARLY_DEPTH, 0x0031);
etna_set_state(stream, VIVS_PA_W_CLIP_LIMIT, 0x3401);
 
+   /* Enable SINGLE_BUFFER for resolve, if supported */
+   etna_set_state(stream, VIVS_RS_SINGLE_BUFFER, 
COND(ctx->specs.single_buffer, VIVS_RS_SINGLE_BUFFER_ENABLE));
+
ctx->dirty = ~0L;
 
/* go through all the used resources and clear their status flag */
diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c 
b/src/gallium/drivers/etnaviv/etnaviv_emit.c
index af74cbb..7ced5fc 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_emit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c
@@ -603,10 +603,12 @@ etna_emit_state(struct etna_context *ctx)
if (unlikely(dirty & (ETNA_DIRTY_STENCIL_REF))) {
   /*014A0*/ EMIT_STATE(PE_STENCIL_CONFIG_EXT, 
ctx->stencil_ref.PE_STENCIL_CONFIG_EXT);
}
+   if (unlikely(dirty & (ETNA_DIRTY_BLEND | ETNA_DIRTY_FRAMEBUFFER))) {
+  struct etna_blend_state *blend = etna_blend_state(ctx->blend);
+  /*014A4*/ EMIT_STATE(PE_LOGIC_OP, blend->PE_LOGIC_OP | 
ctx->framebuffer.PE_LOGIC_OP);
+   }
if (unlikely(dirty & (ETNA_DIRTY_BLEND))) {
   struct etna_blend_state *blend = etna_blend_state(ctx->blend);
-
-  /*014A4*/ EMIT_STATE(PE_LOGIC_OP, blend->PE_LOGIC_OP);
   for (int x = 0; x < 2; ++x) {
  /*014A8*/ EMIT_STATE(PE_DITHER(x), blend->PE_DITHER[x]);
   }
diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
b/src/gallium/drivers/etnaviv/etnaviv_internal.h
index 2f09d55..2f8dacb 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
@@ -72,6 +72,8 @@ struct etna_specs {
unsigned has_shader_range_registers : 1;
/* has the new sin/cos functions */
unsigned has_new_sin_cos : 1;
+   /* supports single-buffer rendering with multiple pixel pipes */
+   unsigned single_buffer : 1;
/* can use any kind of wrapping mode on npot textures */
unsigned npot_tex_any_wrap;
/* number of bits per TS tile */
@@ -191,6 +193,7 @@ struct compiled_framebuffer_state {
uint32_t TS_COLOR_CLEAR_VALUE;
struct etna_reloc TS_COLOR_STATUS_BASE;
struct etna_reloc TS_COLOR_SURFACE_BASE;
+   uint32_t PE_LOGIC_OP;
bool msaa_mode; /* adds input (and possible temp) to PS */
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 1f0582c..8da0b0a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -248,9 +248,15 @@ etna_resource_create(struct pipe_screen *pscreen,
   if (util_format_is_compressed(templat->format))
  layout = ETNA_LAYOUT_LINEAR;
} else if (templat->target != PIPE_BUFFER) {
-  bool want_multitiled = screen->specs.pixel_pipes > 1;
+  bool want_multitiled = false;
   bool want_supertiled = screen->specs.can_supertile && 
!DBG_ENABLED(ETNA_DBG_NO_SUPERTILE);
 
+  /* When this GPU supports single-buffer rendering, don't ever enable
+   * multi-tiling. This replicates the blob behavior on GC3000.
+   */
+  if (!screen->specs.single_buffer)
+ want_multitiled = screen->specs.pixel_pip

Re: [Mesa-dev] [PATCH v2 2/3] etnaviv: Update includes from rnndb

2017-04-14 Thread Wladimir J. van der Laan
On Fri, Apr 14, 2017 at 11:57:21PM +0200, Christian Gmeiner wrote:
> > +#define INST_OPCODE_IMADLOSAT0 0x004e
> > +#define INST_OPCODE_IMADLOSAT0 0x004f
> 
> INST_OPCODE_IMADLOSAT0 got redefined...

Second one should be IMADLOSAT1. Strange, I fixed this but apparently it didn't 
make it to the patch,
messed up with git again :(
https://github.com/etnaviv/etna_viv/blob/master/src/etnaviv/isa.xml.h#L119

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 2/3] etnaviv: Update includes from rnndb

2017-04-14 Thread Wladimir J. van der Laan
On Sat, Apr 15, 2017 at 07:49:53AM +0200, Wladimir J. van der Laan wrote:
> On Fri, Apr 14, 2017 at 11:57:21PM +0200, Christian Gmeiner wrote:
> > > +#define INST_OPCODE_IMADLOSAT0 0x004e
> > > +#define INST_OPCODE_IMADLOSAT0 0x004f
> > 
> > INST_OPCODE_IMADLOSAT0 got redefined...
> 
> Second one should be IMADLOSAT1. Strange, I fixed this but apparently it 
> didn't make it to the patch,
> messed up with git again :(
> https://github.com/etnaviv/etna_viv/blob/master/src/etnaviv/isa.xml.h#L119

I now understand what went wrong: apparently I fixed another instance (IMUL not
IMAD) but not this one.
Strange, hadn't seen a warning for this.
Thanks for the fix,

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] etnaviv: When to use supertiled layout?

2017-04-17 Thread Wladimir J. van der Laan
Hello,

Currently etnaviv chooses supertiled layout always for new resources that can
be rendered to, when this is available:

bool want_supertiled = screen->specs.can_supertile && 
!DBG_ENABLED(ETNA_DBG_NO_SUPERTILE);

However, etnaviv does not support render *from* supertiled textures (GC3000
claims to support SUPERTILED_TEXTURE but we don't use it), only from 4x4-tiled
ones.

This means that with FBO render-to-texture, extra overhead is incurred to
re-tile the texture every frame, which likely doesn't offset the cache benefits
of using supertiled in the first place (as well as using 2x as much video 
memory.)

I'm not sure how to improve this heuristic though: at the time the resource is
do we know whether it will be used to texture from? I don't think so.

Another heuristic option would be to use supertiled only for scan-out surfaces.
These in most cases need a conversion to linear anyway, or (in the case of
gc3000) the PRE supports supertiled as-is.

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] etnaviv: Supertiled texture support on gc3000

2017-04-18 Thread Wladimir J. van der Laan
Support supertiled textures on hardware that has the appropriate
feature flag SUPERTILED_TEXTURE.

Most of the scaffolding was already in place in etna_layout_multiple:

   case ETNA_LAYOUT_SUPER_TILED:
  *paddingX = 64;
  *paddingY = 64;
  *halign = TEXTURE_HALIGN_SUPER_TILED;

So this is just a matter of allowing it.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_resource.c |  9 +++--
 src/gallium/drivers/etnaviv/etnaviv_texture.c  | 10 --
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 7b00d66..035c241 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -230,12 +230,9 @@ etna_resource_create(struct pipe_screen *pscreen,
 {
struct etna_screen *screen = etna_screen(pscreen);
 
-   /* Figure out what tiling to use -- for now, assume that textures cannot be
-* supertiled, and cannot be linear.
-* There is a feature flag SUPERTILED_TEXTURE (not supported on any known 
hw)
-* that may allow this, as well
-* as LINEAR_TEXTURE_SUPPORT (supported on gc880 and gc2000 at least), but
-* not sure how it works.
+   /* Figure out what tiling to use -- for now, assume that texture cannot be 
linear.
+* there is a capability LINEAR_TEXTURE_SUPPORT (supported on gc880 and
+* gc2000 at least), but not sure how it works.
 * Buffers always have LINEAR layout.
 */
unsigned layout = ETNA_LAYOUT_LINEAR;
diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c 
b/src/gallium/drivers/etnaviv/etnaviv_texture.c
index 93b077b..3a84238 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c
@@ -129,12 +129,18 @@ etna_resource_sampler_compatible(struct etna_resource 
*res)
if (util_format_is_compressed(res->base.format))
   return true;
 
-   /* The sampler (as we currently know it) only accepts tiled layouts */
+   struct etna_screen *screen = etna_screen(res->base.screen);
+   /* This GPU supports texturing from supertiled textures? */
+   if (res->layout == ETNA_LAYOUT_SUPER_TILED && VIV_FEATURE(screen, 
chipMinorFeatures2, SUPERTILED_TEXTURE))
+  return true;
+
+   /* TODO: LINEAR_TEXTURE_SUPPORT */
+
+   /* Otherwise, only support tiled layouts */
if (res->layout != ETNA_LAYOUT_TILED)
   return false;
 
/* If we have HALIGN support, we can allow for the RS padding */
-   struct etna_screen *screen = etna_screen(res->base.screen);
if (VIV_FEATURE(screen, chipMinorFeatures1, TEXTURE_HALIGN))
   return true;
 
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] mx6q: Cannot run Cinematic demo correctly

2017-03-14 Thread Wladimir J. van der Laan
On Tue, Mar 14, 2017 at 06:39:32PM +0100, Christian Gmeiner wrote:
> > By only reverting:
> >
> > commit 6c89a728d9e5d072cb504453e73077564c6523d3
> > Author: Wladimir J. van der Laan 
> > Date:   Wed Dec 7 12:59:54 2016 +
> >
> > etnaviv: Cannot render to rb-swapped formats
> >
> > Exposing rb swapped (or other swizzled) formats for rendering would
> > involve swizzing in the pixel shader. This is not the case at the
> > moment, so reject requests for creating such surfaces.
> >
> > (GPUs that need an extra resolve step anyway due to multiple pixel
> > pipes, such as gc2000, might also do this swap in the resolve operation.
> > But this would be tricky to keep track of)
> >
> > CC: 
> > Signed-off-by: Wladimir J. van der Laan 
> > Acked-by: Christian Gmeiner 
> >
> > I can confirm that the Cinematic demo can run successfully. I do not
> > see the black boxes, nor font issues anymore.
> >
> 
> I am a little bit overloaded with my day job (again) and the initial plan was 
> to
> land something in stable for 17.0.1 release failed - but he 17.0.2 will come.
> 
> >
> > Also the previous error messages are gone:
> > QOpenGLFramebufferObject: Unsupported framebuffer format.
> > QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
> > QOpenGLFramebufferObject: Unsupported framebuffer format.
> > QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
> > QOpenGLFramebufferObject: Unsupported framebuffer format.
> > QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
> > QOpenGLFramebufferObject: Unsupported framebuffer format.
> > QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
> >
> > as to your other patch: I do not see commit
> > 89bb5c79e29613ad9a4e43d670654e98a220fc60 in mesa tree.
> >
> > Wladimir/Christian,
> >
> > What would be the proper fix for this problem?
> >
> 
> shader variants - due to lot of people are have this issue I will
> spend some time the next
> days to cleanup my wip patch series. I have too may concurrent etnaviv
> work items running
> in parallel :(

Yea, variants would be the way to render to RGBA succesfully
on vivantes.

Until then it's best to revert those two patches.

Reverting only the one (latest) patch can give red/blue swapped issues when
doing render-to-texture, it was applied in the first place to fix those issues
caused by the first patch, but it didn't really make things better.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/4] etnaviv: add support for swizzled texture formats

2017-06-26 Thread Wladimir J. van der Laan
On Sat, Jun 24, 2017 at 10:41:58AM +0200, Christian Gmeiner wrote:
> Hi
> 
> 2017-06-22 14:39 GMT+02:00 Wladimir J. van der Laan :
> > On Wed, Jun 21, 2017 at 10:36:46PM +0200, Christian Gmeiner wrote:
> >> Passes all ext_texture_swizzle piglits.
> >
> > You seem to have dropped the check in etnaviv_screen.c for HALTI0 when 
> > texture
> > formats have implicit non-identity swizzle.
> > I do think that is necessary as those formats don't work on  >
> 
> Yeah I totally overlooked it :( What do you think about something like this:

Reviewed-By: Wladimir J. van der Laan 

> 
> >8---
> 
> From ad780e77bfac7ed5c5427ad4b850d3b596558f0a Mon Sep 17 00:00:00 2001
> From: Christian Gmeiner 
> Date: Fri, 16 Jun 2017 17:02:29 +0200
> Subject: [PATCH] etnaviv: add support for swizzled texture formats
> 
> Passes all ext_texture_swizzle piglits.
> 
> Signed-off-by: Christian Gmeiner 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_format.c  | 103 
> ++
>  src/gallium/drivers/etnaviv/etnaviv_format.h  |   7 ++
>  src/gallium/drivers/etnaviv/etnaviv_screen.c  |  19 +++--
>  src/gallium/drivers/etnaviv/etnaviv_texture.c |   9 +--
>  4 files changed, 99 insertions(+), 39 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c
> b/src/gallium/drivers/etnaviv/etnaviv_format.c
> index e9cd1040b5..ee50b52962 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_format.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
> @@ -40,6 +40,7 @@ struct etna_format {
> unsigned tex;
> unsigned rs;
> boolean present;
> +   const unsigned char tex_swiz[4];
>  };
> 
>  #define RS_FORMAT_NONE ~0
> @@ -51,22 +52,31 @@ struct etna_format {
>  #define RS_FORMAT_X8B8G8R8(RS_FORMAT_X8R8G8B8 | RS_FORMAT_RB_SWAP)
>  #define RS_FORMAT_A8B8G8R8(RS_FORMAT_A8R8G8B8 | RS_FORMAT_RB_SWAP)
> 
> +#define SWIZ(x,y,z,w) {\
> +   PIPE_SWIZZLE_##x,   \
> +   PIPE_SWIZZLE_##y,   \
> +   PIPE_SWIZZLE_##z,   \
> +   PIPE_SWIZZLE_##w\
> +}
> +
>  /* vertex + texture */
> -#define VT(pipe, vtxfmt, texfmt, rsfmt)   \
> +#define VT(pipe, vtxfmt, texfmt, texswiz, rsfmt)  \
> [PIPE_FORMAT_##pipe] = {   \
>.vtx = VIVS_FE_VERTEX_ELEMENT_CONFIG_TYPE_##vtxfmt, \
>.tex = TEXTURE_FORMAT_##texfmt, \
>.rs = RS_FORMAT_##rsfmt,\
>.present = 1,   \
> +  .tex_swiz = texswiz,\
> }
> 
>  /* texture-only */
> -#define _T(pipe, fmt, rsfmt)   \
> +#define _T(pipe, fmt, swiz, rsfmt) \
> [PIPE_FORMAT_##pipe] = {\
>.vtx = ETNA_NO_MATCH,\
>.tex = TEXTURE_FORMAT_##fmt, \
>.rs = RS_FORMAT_##rsfmt, \
>.present = 1,\
> +  .tex_swiz = swiz,\
> }
> 
>  /* vertex-only */
> @@ -87,9 +97,9 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
> V_(R8_USCALED, UNSIGNED_BYTE, NONE),
> V_(R8_SSCALED, BYTE,  NONE),
> 
> -   _T(A8_UNORM, A8, NONE),
> -   _T(L8_UNORM, L8, NONE),
> -   _T(I8_UNORM, I8, NONE),
> +   _T(A8_UNORM, A8, SWIZ(X, Y, Z, W), NONE),
> +   _T(L8_UNORM, L8, SWIZ(X, Y, Z, W), NONE),
> +   _T(I8_UNORM, I8, SWIZ(X, Y, Z, W), NONE),
> 
> /* 16-bit */
> V_(R16_UNORM,   UNSIGNED_SHORT, NONE),
> @@ -100,15 +110,15 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
> V_(R16_SSCALED, SHORT,  NONE),
> V_(R16_FLOAT,   HALF_FLOAT, NONE),
> 
> -   _T(B4G4R4A4_UNORM, A4R4G4B4, A4R4G4B4),
> -   _T(B4G4R4X4_UNORM, X4R4G4B4, X4R4G4B4),
> +   _T(B4G4R4A4_UNORM, A4R4G4B4, SWIZ(X, Y, Z, W), A4R4G4B4),
> +   _T(B4G4R4X4_UNORM, X4R4G4B4, SWIZ(X, Y, Z, W), X4R4G4B4),
> 
> -   _T(L8A8_UNORM, A8L8, NONE),
> +   _T(L8A8_UNORM, A8L8, SWIZ(X, Y, Z, W), NONE),
> 
> -   _T(Z16_UNORM,  D16,  A4R4G4B4),
> -   _T(B5G6R5_UNORM,   R5G6B5,   R5G6B5),
> -   _T(B5G5R5A1_UNORM, A1R5G5B5, A1R5G5B5),
> -   _T(B5G5R5X1_UNORM, X1R5G5B5, X1R5G5B5),
> +   _T(Z16_UNORM,  D16,  SWIZ(X, Y, Z, W), A4R4G4B4),
> +   _T(B5G6R5_UNORM,   R5G6B5,   SWIZ(X, Y, Z, W), R5G6B5),
> +   _T(B5G5R5A1_UNORM, A1R5G5B5, SWIZ(X, Y, Z, W), A1R5G5B5),
> +   _T(B5G5R5X1_UNORM, X1R5G5B5, SWIZ(X, Y, Z, W), X1R5G5B5),
> 
> V_(R8G8_UNORM,   UNSIGNED_BYTE,  NONE),
> V_(R8G8_SNORM,   BYTE,   NONE),
> @@ -147,25 +157,25 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
> 
> V_(R8G8B8A8_UNORM,   UNSIGNED_BYTE, A8B8G8R8),
> V_(R8G8B8A8_SNORM,   BYTE,  A8B8

Re: [Mesa-dev] [PATCH 01/11] etnaviv: fill in layer_stride for imported resources

2017-06-27 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:18PM +0200, Lucas Stach wrote:
> The layer stride information is used in various parts of the driver,
> so it needs to be present regardless if the driver allocated the
> buffer itself or merely imported it from an external source.

Reviewed-by: Wladimir J. van der Laan 

> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 1c098445b17a..dfd087071193 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -352,6 +352,8 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>  
> level->padded_width = align(level->width, paddingX);
> level->padded_height = align(level->height, paddingY);
> +   level->layer_stride = level->stride * 
> util_format_get_nblocksy(prsc->format,
> +  
> level->padded_height);
>  
> /* The DDX must give us a BO which conforms to our padding size.
>  * The stride of the BO must be greater or equal to our padded
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCHv2] etnaviv: Add support for ETC2 texture compression

2017-06-27 Thread Wladimir J. van der Laan
Add support for ETC2 compressed textures in the etnaviv driver.

One step closer towards GL ES 3 support.

For now, treat SRGB and RGB formats the same. It looks like these are
distinguished using a different bit in sampler state, and not part of
the format, but I have not yet been able to confirm this for sure.
---
 src/gallium/drivers/etnaviv/etnaviv_format.c | 11 +++
 1 file changed, 11 insertions(+)

This is rebased to the new version of the extended texture patchset.

diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c 
b/src/gallium/drivers/etnaviv/etnaviv_format.c
index c7c032a..cb67060 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_format.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
@@ -234,6 +234,17 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
_T(DXT3_RGBA, DXT2_DXT3, SWIZ(X, Y, Z, W), NONE),
_T(DXT5_RGBA, DXT4_DXT5, SWIZ(X, Y, Z, W), NONE),
 
+   _T(ETC2_RGB8,   EXT_NONE | EXT_FORMAT,  SWIZ(X, 
Y, Z, W), NONE), /* Extd. format NONE doubles as ETC2_RGB8 */
+   _T(ETC2_SRGB8,  EXT_NONE | EXT_FORMAT,  SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_RGB8A1, EXT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 | EXT_FORMAT, SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_SRGB8A1,EXT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 | EXT_FORMAT, SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_RGBA8,  EXT_RGBA8_ETC2_EAC | EXT_FORMAT,SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_SRGBA8, EXT_RGBA8_ETC2_EAC | EXT_FORMAT,SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_R11_UNORM,  EXT_R11_EAC | EXT_FORMAT,   SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_R11_SNORM,  EXT_SIGNED_R11_EAC | EXT_FORMAT,SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_RG11_UNORM, EXT_RG11_EAC | EXT_FORMAT,  SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_RG11_SNORM, EXT_SIGNED_RG11_EAC | EXT_FORMAT,   SWIZ(X, 
Y, Z, W), NONE),
+
/* YUV */
_T(YUYV, YUY2, SWIZ(X, Y, Z, W), YUY2),
_T(UYVY, UYVY, SWIZ(X, Y, Z, W), NONE),
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCHv2] etnaviv: Add support for ETC2 texture compression

2017-06-27 Thread Wladimir J. van der Laan
On Tue, Jun 27, 2017 at 02:54:56PM +0200, Wladimir J. van der Laan wrote:
> Add support for ETC2 compressed textures in the etnaviv driver.
> 
> One step closer towards GL ES 3 support.
> 
> For now, treat SRGB and RGB formats the same. It looks like these are
> distinguished using a different bit in sampler state, and not part of
> the format, but I have not yet been able to confirm this for sure.

Signed-off-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_format.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> This is rebased to the new version of the extended texture patchset.
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c 
> b/src/gallium/drivers/etnaviv/etnaviv_format.c
> index c7c032a..cb67060 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_format.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
> @@ -234,6 +234,17 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
> _T(DXT3_RGBA, DXT2_DXT3, SWIZ(X, Y, Z, W), NONE),
> _T(DXT5_RGBA, DXT4_DXT5, SWIZ(X, Y, Z, W), NONE),
>  
> +   _T(ETC2_RGB8,   EXT_NONE | EXT_FORMAT,  
> SWIZ(X, Y, Z, W), NONE), /* Extd. format NONE doubles as ETC2_RGB8 */
> +   _T(ETC2_SRGB8,  EXT_NONE | EXT_FORMAT,  
> SWIZ(X, Y, Z, W), NONE),
> +   _T(ETC2_RGB8A1, EXT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 | EXT_FORMAT, 
> SWIZ(X, Y, Z, W), NONE),
> +   _T(ETC2_SRGB8A1,EXT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 | EXT_FORMAT, 
> SWIZ(X, Y, Z, W), NONE),
> +   _T(ETC2_RGBA8,  EXT_RGBA8_ETC2_EAC | EXT_FORMAT,
> SWIZ(X, Y, Z, W), NONE),
> +   _T(ETC2_SRGBA8, EXT_RGBA8_ETC2_EAC | EXT_FORMAT,
> SWIZ(X, Y, Z, W), NONE),
> +   _T(ETC2_R11_UNORM,  EXT_R11_EAC | EXT_FORMAT,   
> SWIZ(X, Y, Z, W), NONE),
> +   _T(ETC2_R11_SNORM,  EXT_SIGNED_R11_EAC | EXT_FORMAT,
> SWIZ(X, Y, Z, W), NONE),
> +   _T(ETC2_RG11_UNORM, EXT_RG11_EAC | EXT_FORMAT,  
> SWIZ(X, Y, Z, W), NONE),
> +   _T(ETC2_RG11_SNORM, EXT_SIGNED_RG11_EAC | EXT_FORMAT,   
> SWIZ(X, Y, Z, W), NONE),
> +
> /* YUV */
> _T(YUYV, YUY2, SWIZ(X, Y, Z, W), YUY2),
> _T(UYVY, UYVY, SWIZ(X, Y, Z, W), NONE),
> -- 
> 2.7.4
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/11] etnaviv: fix memory leak when BO allocation fails

2017-06-27 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:19PM +0200, Lucas Stach wrote:
> The resource struct is already allocated at this point and should be
> free properly.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index dfd087071193..97e0a15597fa 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -208,7 +208,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
> layout,
> struct etna_bo *bo = etna_bo_new(screen->dev, size, flags);
> if (unlikely(bo == NULL)) {
>BUG("Problem allocating video memory for resource");
> -  return NULL;
> +  goto free_rsc;
> }
>  
> rsc->bo = bo;
> @@ -223,6 +223,10 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> unsigned layout,
> }
>  
> return &rsc->base;
> +
> +free_rsc:
> +   FREE(rsc);
> +   return NULL;
>  }
>  
>  static struct pipe_resource *
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 04/11] etnaviv: pad scanout buffer size to RS alignment

2017-06-27 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:21PM +0200, Lucas Stach wrote:
> This fixes failures to import the scanout buffer with screen resolutions
> that don't satisfy teh RS alignment restrictions, like 1680x1050.

Thanks. I remember having this issue on OLPC, but never came up with a good
solution.

Reviewed-by: Wladimir J. van der Laan

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index c6e7e98837b6..5cd20fafba49 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -215,9 +215,18 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> unsigned layout,
> rsc->ts_bo = 0; /* TS is only created when first bound to surface */
>  
> if (templat->bind & PIPE_BIND_SCANOUT) {
> +  struct pipe_resource scanout_templat = *templat;
>struct winsys_handle handle;
> -  rsc->scanout = renderonly_scanout_for_resource(&rsc->base, screen->ro,
> - &handle);
> +  unsigned padX, padY;
> +
> +  /* pad scanout buffer size to be compatible with the RS */
> +  padX = ETNA_RS_WIDTH_MASK + 1;
> +  padY = (ETNA_RS_HEIGHT_MASK + 1) * screen->specs.pixel_pipes;
> +  scanout_templat.width0 = align(scanout_templat.width0, padX);
> +  scanout_templat.height0 = align(scanout_templat.height0, padY);
> +
> +  rsc->scanout = renderonly_scanout_for_resource(&scanout_templat,
> + screen->ro, &handle);
>if (!rsc->scanout)
>   goto free_rsc;
>  
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 11/11] etnaviv: advertise supported dmabuf modifiers

2017-06-27 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:28PM +0200, Lucas Stach wrote:
> Simply advertise all supported modifiers, independent of the format.
> Special formats, like compressed, which don't support all those modifiers
> are already culled from the dmabuf format list, as we don't support
> the render target binding for them.

The SPLIT formats are only supported on hardware with multiple pixel pipes.

Should this be checked, or is it harmless to advertize them unconditionally?

Reviewed-by: Wladimir J. van der Laan

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_screen.c | 36 
> 
>  1 file changed, 36 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index b70897b6e41f..571f0b3d42d8 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -45,6 +45,8 @@
>  
>  #include "state_tracker/drm_driver.h"
>  
> +#include 
> +
>  #define ETNA_DRM_VERSION(major, minor) ((major) << 16 | (minor))
>  #define ETNA_DRM_VERSION_FENCE_FD  ETNA_DRM_VERSION(1, 1)
>  
> @@ -545,6 +547,39 @@ etna_screen_is_format_supported(struct pipe_screen 
> *pscreen,
> return usage == allowed;
>  }
>  
> +const uint64_t supported_modifiers[] = {
> +   DRM_FORMAT_MOD_LINEAR,
> +   DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED,
> +   DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED,
> +   DRM_FORMAT_MOD_VIVANTE_TILED,
> +   DRM_FORMAT_MOD_VIVANTE_SUPER_TILED,
> +};
> +
> +static void
> +etna_screen_query_dmabuf_modifiers(struct pipe_screen *screen,
> +   enum pipe_format format, int max,
> +   uint64_t *modifiers,
> +   unsigned int *external_only, int *count)
> +{
> +   int i;
> +
> +   if (!max) {
> +  *count = ARRAY_SIZE(supported_modifiers);
> +  return;
> +   }
> +
> +   if (max > ARRAY_SIZE(supported_modifiers))
> +  max = ARRAY_SIZE(supported_modifiers);
> +
> +   for (i = 0; i < max; i++) {
> +  modifiers[i] = supported_modifiers[i];
> +  if (external_only)
> + external_only[i] = 0;
> +   }
> +
> +   *count = i;
> +}
> +
>  static boolean
>  etna_get_specs(struct etna_screen *screen)
>  {
> @@ -839,6 +874,7 @@ etna_screen_create(struct etna_device *dev, struct 
> etna_gpu *gpu,
> pscreen->get_timestamp = etna_screen_get_timestamp;
> pscreen->context_create = etna_context_create;
> pscreen->is_format_supported = etna_screen_is_format_supported;
> +   pscreen->query_dmabuf_modifiers = etna_screen_query_dmabuf_modifiers;
>  
> etna_fence_screen_init(pscreen);
> etna_query_screen_init(pscreen);
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCHv2] etnaviv: Add support for ETC2 texture compression

2017-06-27 Thread Wladimir J. van der Laan
> I can confirm that 11 bit stuff works on the GC2000 . I used piglit's
> oes_compressed_etc2_texture-miptree_gles3 for verification.
> How have you tested these formats?

I rendered the example images from
https://github.com/Ericsson/ETCPACK/tree/master/testing/testvectors_correct/pkm,
which displayed fine, both the 11 and 8 bit variants.

Haven't checked pixel-for-pixel though.

Wladimir

> 
> For instance I get the following fails:
> debian@cubox:~/ac_mesa$
> /home/debian/piglit/bin/oes_compressed_etc2_texture-miptree_gles3 rgb8
> -auto -fbo
> Probe color at (16,0)
>   Left: 0.53 0.20 0.00 1.00
>   Right: 0.87 0.60 0.33 1.00
> PIGLIT: {"result": "fail" }
> debian@cubox:~/ac_mesa$
> /home/debian/piglit/bin/oes_compressed_etc2_texture-miptree_gles3
> rgb8-punchthrough-alpha1 -auto -fbo
> Probe color at (6,0)
>   Left: 0.73 0.40 0.00 1.00
>   Right: 0.13 0.07 0.00 1.00
> PIGLIT: {"result": "fail" }
> 
> With that fact I think we need to find out what is broken with the non
> 11 bit formats on GC2000 and if everything works on your platform. I
> am not
> sure if we should advertise the broken formats (on gpus with HALTI0).
> 
> greets
> --
> Christian Gmeiner, MSc
> 
> https://www.youtube.com/user/AloryOFFICIAL
> https://soundcloud.com/christian-gmeiner
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCHv2] etnaviv: Add support for ETC2 texture compression

2017-06-27 Thread Wladimir J. van der Laan
On Tue, Jun 27, 2017 at 05:31:52PM +0200, Wladimir J. van der Laan wrote:

> > sure if we should advertise the broken formats (on gpus with HALTI0).

FWIW, I did check on both GC2000 and GC3000, so HALTI0 should be ok.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 05/11] etnaviv: increment correct seqno for external resources

2017-06-28 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:22PM +0200, Lucas Stach wrote:
> If we import a dma-buf with a sampler/pixel pipe incompatible modifier,
> the imported buffer will end up in an external resource view. As
> resource_changed signals the change of the imported resource, we need
> to update the external view seqno, instead of the base resource seqno.

Reviewed-by: Wladimir J. van der Laan 

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 5cd20fafba49..43f63f8908a0 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -311,7 +311,10 @@ etna_resource_changed(struct pipe_screen *pscreen, 
> struct pipe_resource *prsc)
>  {
> struct etna_resource *res = etna_resource(prsc);
>  
> -   res->seqno++;
> +   if (res->external)
> +  etna_resource(res->external)->seqno++;
> +   else
> +  res->seqno++;
>  }
>  
>  static void
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/11] etnaviv: also update textures from external resources

2017-06-28 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:23PM +0200, Lucas Stach wrote:
> This reworks the logic in etna_update_sampler_source to select the
> newest resource view for updating the texture view. This should make
> the logic easier to follow and fixes texture updates from imported
> dma-bufs.

Comment in-line

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_texture.c | 23 +++
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c 
> b/src/gallium/drivers/etnaviv/etnaviv_texture.c
> index df77829078c0..b7e424f89bba 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_texture.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c
> @@ -113,16 +113,23 @@ etna_delete_sampler_state(struct pipe_context *pctx, 
> void *ss)
>  static void
>  etna_update_sampler_source(struct pipe_sampler_view *view)
>  {
> +   struct etna_resource *base = etna_resource(view->texture);
> +   struct etna_resource *to = base, *from = base;
>  
> +   if (base->external && etna_resource_newer(etna_resource(base->external), 
> base))
> +  from = etna_resource(base->external);
> +
> +   if (base->texture)
> +  to = etna_resource(base->texture);
> +
> +   if ((to != from) && etna_resource_older(to, from)) {
> +  etna_copy_resource(view->context, &to->base, &from->base, 0,
> + view->texture->last_level);
> +  to->seqno = from->seqno;
> +   } else if ((to == from) && etna_resource_needs_flush(to)) {
> +  etna_copy_resource(view->context, &to->base, &from->base, 0,

Why do this copy if to==from?

>   view->texture->last_level);
> +  to->flush_seqno = from->seqno;
> }
>  }
>  
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08/11] etnaviv: fold etna_screen_bo_get_handle into etna_resource_get_handle

2017-06-28 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:25PM +0200, Lucas Stach wrote:
> There is no point in keeping this indirection. Makes the code easier to
> follow.
> 
> Signed-off-by: Lucas Stach 

Seems to make sense - etna_screen_bo_get_handle doesn't actually do anything
screen specific.

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 14 --
>  src/gallium/drivers/etnaviv/etnaviv_screen.c   | 19 ---
>  src/gallium/drivers/etnaviv/etnaviv_screen.h   |  4 
>  3 files changed, 12 insertions(+), 25 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index f006d24a1bba..66d96aacbbe7 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -471,13 +471,23 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
>   struct winsys_handle *handle, unsigned usage)
>  {
> struct etna_resource *rsc = etna_resource(prsc);
> +   handle->stride = rsc->levels[0].stride;
>  
> if (handle->type == DRM_API_HANDLE_TYPE_KMS &&
> renderonly_get_handle(rsc->scanout, handle))
>return TRUE;
>  
> -   return etna_screen_bo_get_handle(pscreen, rsc->bo, rsc->levels[0].stride,
> -handle);
> +   if (handle->type == DRM_API_HANDLE_TYPE_SHARED) {
> +  return etna_bo_get_name(rsc->bo, &handle->handle) == 0;
> +   } else if (handle->type == DRM_API_HANDLE_TYPE_KMS) {
> +  handle->handle = etna_bo_handle(rsc->bo);
> +  return TRUE;
> +   } else if (handle->type == DRM_API_HANDLE_TYPE_FD) {
> +  handle->handle = etna_bo_dmabuf(rsc->bo);
> +  return TRUE;
> +   } else {
> +  return FALSE;
> +   }
>  }
>  
>  void
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index 6c0735e0fbf2..b70897b6e41f 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -696,25 +696,6 @@ fail:
> return false;
>  }
>  
> -boolean
> -etna_screen_bo_get_handle(struct pipe_screen *pscreen, struct etna_bo *bo,
> -  unsigned stride, struct winsys_handle *whandle)
> -{
> -   whandle->stride = stride;
> -
> -   if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
> -  return etna_bo_get_name(bo, &whandle->handle) == 0;
> -   } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
> -  whandle->handle = etna_bo_handle(bo);
> -  return TRUE;
> -   } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) {
> -  whandle->handle = etna_bo_dmabuf(bo);
> -  return TRUE;
> -   } else {
> -  return FALSE;
> -   }
> -}
> -
>  struct etna_bo *
>  etna_screen_bo_from_handle(struct pipe_screen *pscreen,
> struct winsys_handle *whandle, unsigned 
> *out_stride)
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.h 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.h
> index bec740b0a000..dc57a38dbb80 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.h
> @@ -84,10 +84,6 @@ etna_screen(struct pipe_screen *pscreen)
> return (struct etna_screen *)pscreen;
>  }
>  
> -boolean
> -etna_screen_bo_get_handle(struct pipe_screen *pscreen, struct etna_bo *bo,
> -  unsigned stride, struct winsys_handle *whandle);
> -
>  struct etna_bo *
>  etna_screen_bo_from_handle(struct pipe_screen *pscreen,
> struct winsys_handle *whandle, unsigned 
> *out_stride);
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/11] etnaviv: also update textures from external resources

2017-06-28 Thread Wladimir J. van der Laan
> > Why do this copy if to==from?
> 
> Tile-status resolve. We currently don't support sampler TS (which is

Ah of course.

Might make sense to add a comment mentioning this, it's not straightforward
when reading the code :)

> probably worth implementing, as it has potentially large performance
> gains for the render to texture cases).

Agreed.

Reviewed-by: Wladimir J. van der Laan 

Regards,
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 07/11] etnaviv: implement resource import with modifier

2017-06-28 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:24PM +0200, Lucas Stach wrote:
> This implements resource import with modifier, deriving the correct
> internal layout from the modifier and constructing a render compatible
> base resource if needed.
> 
> This removes the special cases for DDX and renderonly scanout allocated
> buffers, as the linear modifier is enough to trigger correct handling
> of those buffers.

Reviewed-by: Wladimir J. van der Laan 

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 112 
> +
>  1 file changed, 78 insertions(+), 34 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 43f63f8908a0..f006d24a1bba 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -36,6 +36,29 @@
>  #include "util/u_inlines.h"
>  #include "util/u_memory.h"
>  
> +#include 
> +
> +#ifndef DRM_FORMAT_MOD_INVALID
> +#define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1)
> +#endif
> +
> +static unsigned int modifier_to_layout(uint64_t modifier)
> +{
> +   switch (modifier) {
> +   case DRM_FORMAT_MOD_VIVANTE_TILED:
> +  return ETNA_LAYOUT_TILED;
> +   case DRM_FORMAT_MOD_VIVANTE_SUPER_TILED:
> +  return ETNA_LAYOUT_SUPER_TILED;
> +   case DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED:
> +  return ETNA_LAYOUT_MULTI_TILED;
> +   case DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED:
> +  return ETNA_LAYOUT_MULTI_SUPERTILED;
> +   case DRM_FORMAT_MOD_LINEAR:
> +   default:
> +  return ETNA_LAYOUT_LINEAR;
> +   }
> +}
> +
>  /* A tile is 4x4 pixels, having 'screen->specs.bits_per_tile' of tile status.
>   * So, in a buffer of N pixels, there are N / (4 * 4) tiles.
>   * We need N * screen->specs.bits_per_tile / (4 * 4) bits of tile status, or
> @@ -141,6 +164,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
> layout,
>  const struct pipe_resource *templat)
>  {
> struct etna_screen *screen = etna_screen(pscreen);
> +   struct etna_resource *rsc;
> unsigned size;
>  
> DBG_F(ETNA_DBG_RESOURCE_MSGS,
> @@ -186,8 +210,36 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> unsigned layout,
>   paddingY = min_paddingY;
> }
>  
> -   struct etna_resource *rsc = CALLOC_STRUCT(etna_resource);
> +   if (templat->bind & PIPE_BIND_SCANOUT) {
> +  struct pipe_resource scanout_templat = *templat;
> +  struct renderonly_scanout *scanout;
> +  struct winsys_handle handle;
> +  unsigned padX, padY;
>  
> +  /* pad scanout buffer size to be compatible with the RS */
> +  padX = ETNA_RS_WIDTH_MASK + 1;
> +  padY = (ETNA_RS_HEIGHT_MASK + 1) * screen->specs.pixel_pipes;
> +  scanout_templat.width0 = align(scanout_templat.width0, padX);
> +  scanout_templat.height0 = align(scanout_templat.height0, padY);
> +
> +  scanout = renderonly_scanout_for_resource(&scanout_templat,
> +screen->ro, &handle);
> +  if (!scanout)
> + return NULL;
> +
> +  rsc = etna_resource(pscreen->resource_from_handle(pscreen, templat,
> +&handle,
> +
> PIPE_HANDLE_USAGE_WRITE));
> +  close(handle.handle);
> +  if (!rsc)
> + return NULL;
> +
> +  rsc->scanout = scanout;
> +
> +  return &rsc->base;
> +   }
> +
> +   rsc = CALLOC_STRUCT(etna_resource);
> if (!rsc)
>return NULL;
>  
> @@ -214,30 +266,6 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> unsigned layout,
> rsc->bo = bo;
> rsc->ts_bo = 0; /* TS is only created when first bound to surface */
>  
> -   if (templat->bind & PIPE_BIND_SCANOUT) {
> -  struct pipe_resource scanout_templat = *templat;
> -  struct winsys_handle handle;
> -  unsigned padX, padY;
> -
> -  /* pad scanout buffer size to be compatible with the RS */
> -  padX = ETNA_RS_WIDTH_MASK + 1;
> -  padY = (ETNA_RS_HEIGHT_MASK + 1) * screen->specs.pixel_pipes;
> -  scanout_templat.width0 = align(scanout_templat.width0, padX);
> -  scanout_templat.height0 = align(scanout_templat.height0, padY);
> -
> -  rsc->scanout = renderonly_scanout_for_resource(&scanout_templat,
> - screen->ro, &handle);
> -  if (!rsc->scanout)
> - goto free_rsc;
> -
> -  rsc->external = pscreen-

Re: [Mesa-dev] [PATCH 09/11] etnaviv: fill in modifier in etna_resource_get_handle

2017-06-28 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:26PM +0200, Lucas Stach wrote:
> This allows the state trackers to know the tiling layout of the
> resource and pass this through the various userspace protocols.

> Signed-off-by: Lucas Stach 

Comment inline.

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 30 
> +-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 66d96aacbbe7..df5a5700bc19 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -464,6 +464,24 @@ fail:
> return NULL;
>  }
>  
> +static uint64_t layout_to_modifier(unsigned int layout)
> +{
> +   switch (layout) {
> +   case ETNA_LAYOUT_TILED:
> +  return DRM_FORMAT_MOD_VIVANTE_TILED;
> +   case ETNA_LAYOUT_SUPER_TILED:
> +  return DRM_FORMAT_MOD_VIVANTE_SUPER_TILED;
> +   case ETNA_LAYOUT_MULTI_TILED:
> +  return DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED;
> +   case ETNA_LAYOUT_MULTI_SUPERTILED:
> +  return DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED;
> +   case ETNA_LAYOUT_LINEAR:
> +  return DRM_FORMAT_MOD_LINEAR;
> +   default:
> +  return DRM_FORMAT_MOD_INVALID;
> +   }
> +}
> +

It would make sense to put this function after modifier_to_layout
as introduced in 07/11: in the rare case when a tiling layout is added,
both need to be updated, after all. 

>  static boolean
>  etna_resource_get_handle(struct pipe_screen *pscreen,
>   struct pipe_context *pctx,
> @@ -472,10 +490,20 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
>  {
> struct etna_resource *rsc = etna_resource(prsc);
> handle->stride = rsc->levels[0].stride;
> +   handle->modifier = layout_to_modifier(rsc->layout);
>  
> if (handle->type == DRM_API_HANDLE_TYPE_KMS &&
> -   renderonly_get_handle(rsc->scanout, handle))
> +   renderonly_get_handle(rsc->scanout, handle)) {
> +  /*
> +   * If we export the renderonly handle and the scanout BO is attached as
> +   * an external resource we need to fill in the modifier from the 
> external
> +   * resource.
> +   */
> +  if (rsc->external)
> + handle->modifier = 
> layout_to_modifier(etna_resource(rsc->external)->layout);
> +
>return TRUE;
> +   }
>  
> if (handle->type == DRM_API_HANDLE_TYPE_SHARED) {
>return etna_bo_get_name(rsc->bo, &handle->handle) == 0;
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/11] etnaviv: implement resource creation with modifier

2017-06-28 Thread Wladimir J. van der Laan
On Fri, Jun 23, 2017 at 05:50:27PM +0200, Lucas Stach wrote:
> This allows to create buffers with a specific tiling layout, which is 
> primarily
> used by GBM to allocate the EGL back buffers with the correct tiling/modifier
> for use with the scanout engines.
> 
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 97 
> --
>  src/gallium/drivers/etnaviv/etnaviv_resource.h |  2 +-
>  src/gallium/drivers/etnaviv/etnaviv_texture.c  |  2 +-
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c |  2 +-
>  4 files changed, 96 insertions(+), 7 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index df5a5700bc19..8462012b9d5f 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -161,7 +161,7 @@ setup_miptree(struct etna_resource *rsc, unsigned 
> paddingX, unsigned paddingY,
>  /* Create a new resource object, using the given template info */
>  struct pipe_resource *
>  etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
> -const struct pipe_resource *templat)
> +uint64_t modifier, const struct pipe_resource *templat)
>  {
> struct etna_screen *screen = etna_screen(pscreen);
> struct etna_resource *rsc;
> @@ -217,8 +217,13 @@ etna_resource_alloc(struct pipe_screen *pscreen, 
> unsigned layout,
>unsigned padX, padY;
>  
>/* pad scanout buffer size to be compatible with the RS */
> -  padX = ETNA_RS_WIDTH_MASK + 1;
> -  padY = (ETNA_RS_HEIGHT_MASK + 1) * screen->specs.pixel_pipes;
> +  if (modifier != DRM_FORMAT_MOD_LINEAR) {
> + padX = paddingX;
> + padY = paddingY;
> +  } else {
> + padX = ETNA_RS_WIDTH_MASK + 1;
> + padY = (ETNA_RS_HEIGHT_MASK + 1) * screen->specs.pixel_pipes;

We repeat `4 * screen->specs.pixel_pipes`, or in this case
`(ETNA_RS_HEIGHT_MASK + 1) * screen->specs.pixel_pipes` in many places.

Maybe this 'minimum padding for RS' computation logic could factored
out for more readable code.

> +  }
>scanout_templat.width0 = align(scanout_templat.width0, padX);
>scanout_templat.height0 = align(scanout_templat.height0, padY);
>  
> @@ -227,6 +232,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned 
> layout,
>if (!scanout)
>   return NULL;
>  
> +  handle.modifier = modifier;
>rsc = etna_resource(pscreen->resource_from_handle(pscreen, templat,
>  &handle,
>  
> PIPE_HANDLE_USAGE_WRITE));
> @@ -331,7 +337,89 @@ etna_resource_create(struct pipe_screen *pscreen,
> if (templat->target == PIPE_TEXTURE_3D)
>layout = ETNA_LAYOUT_LINEAR;
>  
> -   return etna_resource_alloc(pscreen, layout, templat);
> +   /* modifier is only used for scanout surfaces, so safe to use LINEAR here 
> */
> +   return etna_resource_alloc(pscreen, layout, DRM_FORMAT_MOD_LINEAR, 
> templat);
> +}
> +
> +enum modifier_priority {
> +   MODIFIER_PRIORITY_INVALID = 0,
> +   MODIFIER_PRIORITY_LINEAR,
> +   MODIFIER_PRIORITY_SPLIT_TILED,
> +   MODIFIER_PRIORITY_SPLIT_SUPER_TILED,
> +   MODIFIER_PRIORITY_TILED,
> +   MODIFIER_PRIORITY_SUPER_TILED,
> +};
> +
> +const uint64_t priority_to_modifier[] = {
> +   [MODIFIER_PRIORITY_INVALID] = DRM_FORMAT_MOD_INVALID,
> +   [MODIFIER_PRIORITY_LINEAR] = DRM_FORMAT_MOD_LINEAR,
> +   [MODIFIER_PRIORITY_SPLIT_TILED] = DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED,
> +   [MODIFIER_PRIORITY_SPLIT_SUPER_TILED] = 
> DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED,
> +   [MODIFIER_PRIORITY_TILED] = DRM_FORMAT_MOD_VIVANTE_TILED,
> +   [MODIFIER_PRIORITY_SUPER_TILED] = DRM_FORMAT_MOD_VIVANTE_SUPER_TILED,
> +};
> +
> +static uint64_t
> +select_best_modifier(const struct etna_screen * screen,
> + const uint64_t *modifiers, const unsigned count)
> +{
> +   enum modifier_priority prio = MODIFIER_PRIORITY_INVALID;
> +
> +   for (int i = 0; i < count; i++) {
> +  switch (modifiers[i]) {
> +  case DRM_FORMAT_MOD_VIVANTE_SUPER_TILED:
> + if ((screen->specs.pixel_pipes > 1 && !screen->specs.single_buffer) 
> ||
> + !screen->specs.can_supertile)
> +break;
> + prio = MAX2(prio, MODIFIER_PRIORITY_SUPER_TILED);
> + break;
> +  case DRM_FORMAT_MOD_VIVANTE_TILED:
> + if (screen->specs.pixel_pipes > 1 && !screen->specs.single_buffer)
> +break;
> + prio = MAX2(prio, MODIFIER_PRIORITY_TILED);
> + break;
> +  case DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED:
> + if ((screen->specs.pixel_pipes < 2) || !screen->specs.can_supertile)
> +break;
> + prio = MAX2(prio, MODIFIER_PRIORITY_SPLIT_SUPER_TILED);
> + break;
> +  case DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED:
> + if (screen->specs

[Mesa-dev] [PATCH] etnaviv: Use the correct LOG instruction on GC3000

2017-07-11 Thread Wladimir J. van der Laan
GC3000 has a new LOG instruction, similar to the new SIN and COS instructions.

Generate the new instruction sequence when appropriate; there are
two occasions, as part of LIT and the generator for the LG2
instruction itself.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 63 +++---
 src/gallium/drivers/etnaviv/etnaviv_internal.h |  4 +-
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |  2 +-
 3 files changed, 59 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 07315f7..6435b84 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -1389,12 +1389,27 @@ trans_lit(const struct instr_translater *t, struct 
etna_compile *c,
else
   src_w = swizzle(src[0], SWIZZLE(W, W, W, W));
 
-   struct etna_inst ins[3] = { };
-   ins[0].opcode = INST_OPCODE_LOG;
-   ins[0].dst = etna_native_to_dst(inner_temp, INST_COMPS_X);
-   ins[0].src[2] = src_y;
+   if (c->specs->has_new_transcendentals) { /* Alternative LOG sequence */
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_LOG,
+ .dst = etna_native_to_dst(inner_temp, INST_COMPS_X | INST_COMPS_Y),
+ .src[2] = src_y,
+ .tex = { .amode=1 }, /* Unknown bit needs to be set */
+  });
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MUL,
+ .dst = etna_native_to_dst(inner_temp, INST_COMPS_X),
+ .src[0] = etna_native_to_src(inner_temp, SWIZZLE(X, X, X, X)),
+ .src[1] = etna_native_to_src(inner_temp, SWIZZLE(Y, Y, Y, Y)),
+  });
+   } else {
+  struct etna_inst ins[3] = { };
+  ins[0].opcode = INST_OPCODE_LOG;
+  ins[0].dst = etna_native_to_dst(inner_temp, INST_COMPS_X);
+  ins[0].src[2] = src_y;
 
-   emit_inst(c, &ins[0]);
+  emit_inst(c, &ins[0]);
+   }
emit_inst(c, &(struct etna_inst) {
   .opcode = INST_OPCODE_MUL,
   .sat = 0,
@@ -1450,7 +1465,7 @@ static void
 trans_trig(const struct instr_translater *t, struct etna_compile *c,
const struct tgsi_full_instruction *inst, struct etna_inst_src *src)
 {
-   if (c->specs->has_new_sin_cos) { /* Alternative SIN/COS */
+   if (c->specs->has_new_transcendentals) { /* Alternative SIN/COS */
   /* On newer chips alternative SIN/COS instructions are implemented,
* which:
* - Need their input scaled by 1/pi instead of 2/pi
@@ -1613,6 +1628,40 @@ trans_trig(const struct instr_translater *t, struct 
etna_compile *c,
 }
 
 static void
+trans_lg2(const struct instr_translater *t, struct etna_compile *c,
+const struct tgsi_full_instruction *inst, struct etna_inst_src 
*src)
+{
+   if (c->specs->has_new_transcendentals) {
+  /* On newer chips alternative LOG instruction is implemented,
+   * which outputs an x and y component, which need to be multiplied to
+   * get the result.
+   */
+  struct etna_native_reg temp = etna_compile_get_inner_temp(c); /* only 
using .xy */
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_LOG,
+ .sat = 0,
+ .dst = etna_native_to_dst(temp, INST_COMPS_X | INST_COMPS_Y),
+ .src[2] = src[0],
+ .tex = { .amode=1 }, /* Unknown bit needs to be set */
+  });
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MUL,
+ .sat = inst->Instruction.Saturate,
+ .dst = convert_dst(c, &inst->Dst[0]),
+ .src[0] = etna_native_to_src(temp, SWIZZLE(X, X, X, X)),
+ .src[1] = etna_native_to_src(temp, SWIZZLE(Y, Y, Y, Y)),
+  });
+   } else {
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_LOG,
+ .sat = inst->Instruction.Saturate,
+ .dst = convert_dst(c, &inst->Dst[0]),
+ .src[2] = src[0],
+  });
+   }
+}
+
+static void
 trans_dph(const struct instr_translater *t, struct etna_compile *c,
   const struct tgsi_full_instruction *inst, struct etna_inst_src *src)
 {
@@ -1753,7 +1802,7 @@ static const struct instr_translater 
translaters[TGSI_OPCODE_LAST] = {
INSTR(DST, trans_instr, .opc = INST_OPCODE_DST, .src = {0, 1, -1}),
INSTR(MAD, trans_instr, .opc = INST_OPCODE_MAD, .src = {0, 1, 2}),
INSTR(EX2, trans_instr, .opc = INST_OPCODE_EXP, .src = {2, -1, -1}),
-   INSTR(LG2, trans_instr, .opc = INST_OPCODE_LOG, .src = {2, -1, -1}),
+   INSTR(LG2, trans_lg2),
INSTR(SQRT, trans_instr, .opc = INST_OPCODE_SQRT, .src = {2, -1, -1}),
INSTR(FRC, trans_instr, .opc = INST_OPCODE_FRC, .src = {2, -1, -1}),
INSTR(CEIL, trans_instr, .opc = INST_OPCODE_CEIL, .src = {2, -1, -1}),
diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
b/src/gallium/drivers/etnaviv/etnaviv_internal.h
index 1212fdf..8a31167 100644
--- a/src/gallium/drivers/etnaviv/etna

[Mesa-dev] [PATCH] etnaviv: Reset indexed rendering information when not rendering indexed

2017-07-14 Thread Wladimir J. van der Laan
A dangling bo object would result in memory corruption while
loading a level in ioquake3_opengl2.

Fixes a problem introduced in 330d0607ed60fd3edca192e54b4246310f06652f.
Fix suggested by Lucas Stach.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_context.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index e759095..3437906 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -198,6 +198,12 @@ etna_draw_vbo(struct pipe_context *pctx, const struct 
pipe_draw_info *info)
  BUG("Unsupported or no index buffer");
  return;
   }
+   } else {
+  ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.bo = 0;
+  ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.offset = 0;
+  ctx->index_buffer.FE_INDEX_STREAM_BASE_ADDR.flags = 0;
+  ctx->index_buffer.FE_INDEX_STREAM_CONTROL = 0;
+  ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER;
}
 
struct etna_shader_key key = {};
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] etnaviv: Add support for ETC2 texture compression

2017-07-17 Thread Wladimir J. van der Laan
Add support for ETC2 compressed textures in the etnaviv driver.

One step closer towards GL ES 3 support.

For now, treat SRGB and RGB formats the same. It looks like these are
distinguished using a different bit in sampler state, and not part of
the format, but I have not yet been able to confirm this for sure.

(Only enabled on GC3000+ for now, as the GC2000 ETC2 decoder
implementation is buggy and we don't work around that)

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_format.c | 11 +++
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 27 ++-
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c 
b/src/gallium/drivers/etnaviv/etnaviv_format.c
index c7c032a..cb67060 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_format.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
@@ -234,6 +234,17 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
_T(DXT3_RGBA, DXT2_DXT3, SWIZ(X, Y, Z, W), NONE),
_T(DXT5_RGBA, DXT4_DXT5, SWIZ(X, Y, Z, W), NONE),
 
+   _T(ETC2_RGB8,   EXT_NONE | EXT_FORMAT,  SWIZ(X, 
Y, Z, W), NONE), /* Extd. format NONE doubles as ETC2_RGB8 */
+   _T(ETC2_SRGB8,  EXT_NONE | EXT_FORMAT,  SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_RGB8A1, EXT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 | EXT_FORMAT, SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_SRGB8A1,EXT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 | EXT_FORMAT, SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_RGBA8,  EXT_RGBA8_ETC2_EAC | EXT_FORMAT,SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_SRGBA8, EXT_RGBA8_ETC2_EAC | EXT_FORMAT,SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_R11_UNORM,  EXT_R11_EAC | EXT_FORMAT,   SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_R11_SNORM,  EXT_SIGNED_R11_EAC | EXT_FORMAT,SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_RG11_UNORM, EXT_RG11_EAC | EXT_FORMAT,  SWIZ(X, 
Y, Z, W), NONE),
+   _T(ETC2_RG11_SNORM, EXT_SIGNED_RG11_EAC | EXT_FORMAT,   SWIZ(X, 
Y, Z, W), NONE),
+
/* YUV */
_T(YUYV, YUY2, SWIZ(X, Y, Z, W), YUY2),
_T(UYVY, UYVY, SWIZ(X, Y, Z, W), NONE),
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index ec8de96..3cae16d 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -460,6 +460,26 @@ etna_screen_get_timestamp(struct pipe_screen *pscreen)
 }
 
 static bool
+etna_format_is_etc2(enum pipe_format format)
+{
+   switch (format) {
+  case PIPE_FORMAT_ETC2_RGB8:
+  case PIPE_FORMAT_ETC2_SRGB8:
+  case PIPE_FORMAT_ETC2_RGB8A1:
+  case PIPE_FORMAT_ETC2_SRGB8A1:
+  case PIPE_FORMAT_ETC2_RGBA8:
+  case PIPE_FORMAT_ETC2_SRGBA8:
+  case PIPE_FORMAT_ETC2_R11_UNORM:
+  case PIPE_FORMAT_ETC2_R11_SNORM:
+  case PIPE_FORMAT_ETC2_RG11_UNORM:
+  case PIPE_FORMAT_ETC2_RG11_SNORM:
+ return true;
+  default:
+ return false;
+   }
+}
+
+static bool
 gpu_supports_texure_format(struct etna_screen *screen, uint32_t fmt,
enum pipe_format format)
 {
@@ -474,7 +494,12 @@ gpu_supports_texure_format(struct etna_screen *screen, 
uint32_t fmt,
if (fmt & EXT_FORMAT)
   supported = VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
 
-   if (util_format_is_snorm(format))
+   /* ETC2 is supported on HALTI0, however that implementation is buggy in
+* hardware. The blob driver does per-block patching to work around this.
+* As this is currently not implemented by etnaviv, enable it for HALTI1
+* (GC3000) only.
+*/
+   if (util_format_is_snorm(format) || etna_format_is_etc2(format))
   supported = VIV_FEATURE(screen, chipMinorFeatures2, HALTI1);
 
if (!supported)
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] etnaviv: Avoid duplicates in formats table

2017-07-21 Thread Wladimir J. van der Laan
Remove the following duplicates from the formats table:

- R8G8B8A8_UNORM (V_,_T)
- R8G8B8X8_UNORM (_T,_T)
- DXT3_RGBA (_T,_T)

Only the first has an effect because the _T overrides the V_ initializer,
the latter two were harmless duplications of the same.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_format.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c 
b/src/gallium/drivers/etnaviv/etnaviv_format.c
index 492499a..69e07bc 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_format.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
@@ -155,7 +155,7 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
 
V_(A8B8G8R8_UNORM,   UNSIGNED_BYTE, NONE),
 
-   V_(R8G8B8A8_UNORM,   UNSIGNED_BYTE, A8B8G8R8),
+   VT(R8G8B8A8_UNORM,   UNSIGNED_BYTE, A8B8G8R8, SWIZ(X, Y, Z, W), A8B8G8R8),
V_(R8G8B8A8_SNORM,   BYTE,  A8B8G8R8),
_T(R8G8B8X8_UNORM,   X8B8G8R8,  SWIZ(X, Y, Z, W), X8B8G8R8),
V_(R8G8B8A8_UINT,UNSIGNED_BYTE, A8B8G8R8),
@@ -163,9 +163,6 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
V_(R8G8B8A8_USCALED, UNSIGNED_BYTE, A8B8G8R8),
V_(R8G8B8A8_SSCALED, BYTE,  A8B8G8R8),
 
-   _T(R8G8B8A8_UNORM, A8B8G8R8, SWIZ(X, Y, Z, W), A8B8G8R8),
-   _T(R8G8B8X8_UNORM, X8B8G8R8, SWIZ(X, Y, Z, W), X8B8G8R8),
-
_T(B8G8R8A8_UNORM, A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8),
_T(B8G8R8X8_UNORM, X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8),
 
@@ -230,7 +227,6 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
_T(DXT1_RGB,  DXT1,  SWIZ(X, Y, Z, W), NONE),
_T(DXT1_RGBA, DXT1,  SWIZ(X, Y, Z, W), NONE),
_T(DXT3_RGBA, DXT2_DXT3, SWIZ(X, Y, Z, W), NONE),
-   _T(DXT3_RGBA, DXT2_DXT3, SWIZ(X, Y, Z, W), NONE),
_T(DXT5_RGBA, DXT4_DXT5, SWIZ(X, Y, Z, W), NONE),
 
_T(ETC2_RGB8,   EXT_NONE | EXT_FORMAT,  SWIZ(X, 
Y, Z, W), NONE), /* Extd. format NONE doubles as ETC2_RGB8 */
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: Avoid duplicates in formats table

2017-07-21 Thread Wladimir J. van der Laan
On Fri, Jul 21, 2017 at 02:43:11PM +0200, Lucas Stach wrote:
> Am Freitag, den 21.07.2017, 12:49 +0200 schrieb Wladimir J. van der
> Laan:
> > Remove the following duplicates from the formats table:
> > 
> > - R8G8B8A8_UNORM (V_,_T)
> > - R8G8B8X8_UNORM (_T,_T)
> > - DXT3_RGBA (_T,_T)
> > 
> > Only the first has an effect because the _T overrides the V_ initializer,
> > the latter two were harmless duplications of the same.
> 
> Urgh, well spotted. Has this caused issues in any application?

> > -   V_(R8G8B8A8_UNORM,   UNSIGNED_BYTE, A8B8G8R8),
> > -   _T(R8G8B8A8_UNORM, A8B8G8R8, SWIZ(X, Y, Z, W), A8B8G8R8),
> > +   VT(R8G8B8A8_UNORM,   UNSIGNED_BYTE, A8B8G8R8, SWIZ(X, Y, Z, W), 
> > A8B8G8R8),

Nope, I haven't seen any difference with or without this patch.

Which is surprising to me, as R8G8B8A8_UNORM vertex format is commonly used for
per-vertex coloring. But it's possible Mesa accomodates somehow if this
format is missing.

Regards,
Wladimir

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] etnaviv: Clear lbl_usage array correctly

2017-07-23 Thread Wladimir J. van der Laan
Fill the entire array instead of just a quarter. This avoids
crashes with large shaders.
(currently this never causes a problem because shaders larger than 2048/4
instructions are not supported by this driver on any hardware, but it will
cause problems in the future)

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index cc6bfc9..165ab74 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2353,7 +2353,7 @@ etna_compile_shader(struct etna_shader_variant *v)
if (!c)
   return false;
 
-   memset(&c->lbl_usage, -1, ARRAY_SIZE(c->lbl_usage));
+   memset(&c->lbl_usage, -1, sizeof(c->lbl_usage));
 
const struct tgsi_token *tokens = v->shader->tokens;
 
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/3] etnaviv: Support large shaders on GC3000

2017-07-24 Thread Wladimir J. van der Laan
This patch adds support for large shaders on GC3000. For example the "terrain"
glmark benchmark with a large fragment shader will work after this.

If the GPU supports ICACHE, shaders larger than the available state area will
be uploaded to a bo of their own and instructed to be loaded from memory on
demand. Small shaders will be uploaded in the usual way. This mimics the
behavior of the blob.

On GPUs that don't support ICACHE, this patch should make no difference.

Wladimir J. van der Laan (3):
  etnaviv: Update headers from rnndb
  etnaviv: Unified uniforms support
  etnaviv: Implement ICACHE

 src/gallium/drivers/etnaviv/etnaviv_compiler.c |  3 +-
 src/gallium/drivers/etnaviv/etnaviv_compiler.h |  5 ++
 src/gallium/drivers/etnaviv/etnaviv_emit.c | 71 +++---
 src/gallium/drivers/etnaviv/etnaviv_internal.h | 10 
 src/gallium/drivers/etnaviv/etnaviv_screen.c   | 19 ++-
 src/gallium/drivers/etnaviv/etnaviv_shader.c   | 45 +++-
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h  | 14 +++--
 7 files changed, 140 insertions(+), 27 deletions(-)

-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/3] etnaviv: Unified uniforms support

2017-07-24 Thread Wladimir J. van der Laan
GC3000 has changed from a separate store for VS and PS uniforms
to a single, unified one. There is backwards compatibilty functionalty,
however this does not work correctly together with ICACHE.

This patch adds explicit support, although in the simplest way possible:
the PS/VS uniforms split is still fixed and hardcoded. It should
make no difference on hardware that does not have unified uniform
memory.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_emit.c | 19 +++
 src/gallium/drivers/etnaviv/etnaviv_internal.h |  6 ++
 src/gallium/drivers/etnaviv/etnaviv_screen.c   | 15 +++
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c 
b/src/gallium/drivers/etnaviv/etnaviv_emit.c
index bfff699..273b3d0 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_emit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c
@@ -747,10 +747,17 @@ etna_emit_state(struct etna_context *ctx)
   etna_set_state_multi(stream, ctx->specs.ps_offset,
ctx->shader_state.ps_inst_mem_size,
ctx->shader_state.PS_INST_MEM);
-  /*05000*/ etna_set_state_multi(stream, VIVS_VS_UNIFORMS(0),
+
+  if (ctx->specs.has_unified_uniforms) {
+ etna_set_state(stream, VIVS_VS_UNIFORM_BASE, 0);
+ etna_set_state(stream, VIVS_PS_UNIFORM_BASE, 
ctx->specs.max_vs_uniforms);
+  }
+  etna_set_state(stream, VIVS_VS_UNIFORM_CACHE, 
VIVS_VS_UNIFORM_CACHE_FLUSH);
+  etna_set_state_multi(stream, ctx->specs.vs_uniforms_offset,
  ctx->shader_state.vs_uniforms_size,
  ctx->shader_state.VS_UNIFORMS);
-  /*07000*/ etna_set_state_multi(stream, VIVS_PS_UNIFORMS(0),
+  etna_set_state(stream, VIVS_VS_UNIFORM_CACHE, 
VIVS_VS_UNIFORM_CACHE_FLUSH | VIVS_VS_UNIFORM_CACHE_PS);
+  etna_set_state_multi(stream, ctx->specs.ps_uniforms_offset,
  ctx->shader_state.ps_uniforms_size,
  ctx->shader_state.PS_UNIFORMS);
 
@@ -764,19 +771,23 @@ etna_emit_state(struct etna_context *ctx)
   memcpy(ctx->gpu3d.PS_UNIFORMS, ctx->shader_state.PS_UNIFORMS,
  ctx->shader_state.ps_uniforms_size * 4);
} else {
+  /* ideally this cache would only be flushed if there are VS uniform 
changes */
+  etna_set_state(stream, VIVS_VS_UNIFORM_CACHE, 
VIVS_VS_UNIFORM_CACHE_FLUSH);
   etna_coalesce_start(stream, &coalesce);
   for (int x = 0; x < ctx->shader.vs->uniforms.const_count; ++x) {
  if (ctx->gpu3d.VS_UNIFORMS[x] != ctx->shader_state.VS_UNIFORMS[x]) {
-/*05000*/ EMIT_STATE(VS_UNIFORMS(x), 
ctx->shader_state.VS_UNIFORMS[x]);
+etna_coalsence_emit(stream, &coalesce, 
ctx->specs.vs_uniforms_offset + x*4, ctx->shader_state.VS_UNIFORMS[x]);
 ctx->gpu3d.VS_UNIFORMS[x] = ctx->shader_state.VS_UNIFORMS[x];
  }
   }
   etna_coalesce_end(stream, &coalesce);
 
+  /* ideally this cache would only be flushed if there are PS uniform 
changes */
+  etna_set_state(stream, VIVS_VS_UNIFORM_CACHE, 
VIVS_VS_UNIFORM_CACHE_FLUSH | VIVS_VS_UNIFORM_CACHE_PS);
   etna_coalesce_start(stream, &coalesce);
   for (int x = 0; x < ctx->shader.fs->uniforms.const_count; ++x) {
  if (ctx->gpu3d.PS_UNIFORMS[x] != ctx->shader_state.PS_UNIFORMS[x]) {
-/*07000*/ EMIT_STATE(PS_UNIFORMS(x), 
ctx->shader_state.PS_UNIFORMS[x]);
+etna_coalsence_emit(stream, &coalesce, 
ctx->specs.ps_uniforms_offset + x*4, ctx->shader_state.PS_UNIFORMS[x]);
 ctx->gpu3d.PS_UNIFORMS[x] = ctx->shader_state.PS_UNIFORMS[x];
  }
   }
diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
b/src/gallium/drivers/etnaviv/etnaviv_internal.h
index 8a31167..5c13f23 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
@@ -74,6 +74,8 @@ struct etna_specs {
unsigned has_new_transcendentals : 1;
/* supports single-buffer rendering with multiple pixel pipes */
unsigned single_buffer : 1;
+   /* has unified uniforms memory */
+   unsigned has_unified_uniforms : 1;
/* can use any kind of wrapping mode on npot textures */
unsigned npot_tex_any_wrap;
/* number of bits per TS tile */
@@ -100,6 +102,10 @@ struct etna_specs {
uint32_t vs_offset;
/* pixel shader memory address*/
uint32_t ps_offset;
+   /* vertex shader uniforms address*/
+   uint32_t vs_uniforms_offset;
+   /* pixel shader uniforms address*/
+   uint32_t ps_uniforms_offset;
/* vertex/fragment shader max instructions */
uint32_t max_instructions;
/* maximum number of varyings */
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/e

[Mesa-dev] [PATCH 1/3] etnaviv: Update headers from rnndb

2017-07-24 Thread Wladimir J. van der Laan
Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/hw/state_3d.xml.h | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/hw/state_3d.xml.h 
b/src/gallium/drivers/etnaviv/hw/state_3d.xml.h
index eacd868..d8b7a94 100644
--- a/src/gallium/drivers/etnaviv/hw/state_3d.xml.h
+++ b/src/gallium/drivers/etnaviv/hw/state_3d.xml.h
@@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from 
are:
 - state_hi.xml  (  26403 bytes, from 2017-01-07 14:27:54)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  67249 bytes, from 2017-07-07 06:41:31)
+- state_3d.xml  (  67197 bytes, from 2017-07-23 10:53:21)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2017 by the following authors:
@@ -278,10 +278,10 @@ DEALINGS IN THE SOFTWARE.
 #define VIVS_VS_RANGE_HIGH__SHIFT  16
 #define VIVS_VS_RANGE_HIGH(x)  (((x) << 
VIVS_VS_RANGE_HIGH__SHIFT) & VIVS_VS_RANGE_HIGH__MASK)
 
-#define VIVS_VS_NEW_UNK00860   0x0860
-#define VIVS_VS_NEW_UNK00860_UNK0  0x0001
-#define VIVS_VS_NEW_UNK00860_PS
0x0010
-#define VIVS_VS_NEW_UNK00860_UNK12 0x1000
+#define VIVS_VS_UNIFORM_CACHE  0x0860
+#define VIVS_VS_UNIFORM_CACHE_FLUSH0x0001
+#define VIVS_VS_UNIFORM_CACHE_PS   0x0010
+#define VIVS_VS_UNIFORM_CACHE_UNK120x1000
 
 #define VIVS_VS_UNIFORM_BASE   0x0864
 
@@ -1199,6 +1199,7 @@ DEALINGS IN THE SOFTWARE.
 #define VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_A__MASK
0x0070
 #define VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_A__SHIFT   20
 #define VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_A(x)   (((x) << 
VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_A__SHIFT) & 
VIVS_TE_SAMPLER_CONFIG1_SWIZZLE_A__MASK)
+#define VIVS_TE_SAMPLER_CONFIG1_UNK25  0x0200
 #define VIVS_TE_SAMPLER_CONFIG1_HALIGN__MASK   0x1c00
 #define VIVS_TE_SAMPLER_CONFIG1_HALIGN__SHIFT  26
 #define VIVS_TE_SAMPLER_CONFIG1_HALIGN(x)  (((x) << 
VIVS_TE_SAMPLER_CONFIG1_HALIGN__SHIFT) & VIVS_TE_SAMPLER_CONFIG1_HALIGN__MASK)
@@ -1303,6 +1304,7 @@ DEALINGS IN THE SOFTWARE.
 #define VIVS_NTE_SAMPLER_CONFIG1_SWIZZLE_A__MASK   0x0070
 #define VIVS_NTE_SAMPLER_CONFIG1_SWIZZLE_A__SHIFT  20
 #define VIVS_NTE_SAMPLER_CONFIG1_SWIZZLE_A(x)  (((x) << 
VIVS_NTE_SAMPLER_CONFIG1_SWIZZLE_A__SHIFT) & 
VIVS_NTE_SAMPLER_CONFIG1_SWIZZLE_A__MASK)
+#define VIVS_NTE_SAMPLER_CONFIG1_UNK25 0x0200
 #define VIVS_NTE_SAMPLER_CONFIG1_HALIGN__MASK  0x1c00
 #define VIVS_NTE_SAMPLER_CONFIG1_HALIGN__SHIFT 26
 #define VIVS_NTE_SAMPLER_CONFIG1_HALIGN(x) (((x) << 
VIVS_NTE_SAMPLER_CONFIG1_HALIGN__SHIFT) & VIVS_NTE_SAMPLER_CONFIG1_HALIGN__MASK)
@@ -1313,6 +1315,8 @@ DEALINGS IN THE SOFTWARE.
 
 #define VIVS_NTE_SAMPLER_UNK10500(i0) (0x00010500 + 
0x4*(i0))
 
+#define VIVS_NTE_SAMPLER_UNK10700(i0) (0x00010700 + 
0x4*(i0))
+
 #define VIVS_NTE_SAMPLER_ADDR(i0) (0x00010800 + 
0x40*(i0))
 #define VIVS_NTE_SAMPLER_ADDR__ESIZE   0x0040
 #define VIVS_NTE_SAMPLER_ADDR__LEN 0x0020
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/3] etnaviv: Implement ICACHE

2017-07-24 Thread Wladimir J. van der Laan
This patch adds support for large shaders on GC3000. For example the "terrain"
glmark benchmark with a large fragment shader will work after this.

If the GPU supports ICACHE, shaders larger than the available state area will
be uploaded to a bo of their own and instructed to be loaded from memory on
demand. Small shaders will be uploaded in the usual way. This mimics the
behavior of the blob.

On GPUs that don't support ICACHE, this patch should make no difference.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c |  3 +-
 src/gallium/drivers/etnaviv/etnaviv_compiler.h |  5 +++
 src/gallium/drivers/etnaviv/etnaviv_emit.c | 52 ++
 src/gallium/drivers/etnaviv/etnaviv_internal.h |  4 ++
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |  4 +-
 src/gallium/drivers/etnaviv/etnaviv_shader.c   | 45 +-
 6 files changed, 95 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index fbe66d0..0664d52 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2277,7 +2277,7 @@ etna_compile_check_limits(struct etna_compile *c)
/* round up number of uniforms, including immediates, in units of four */
int num_uniforms = c->imm_base / 4 + (c->imm_size + 3) / 4;
 
-   if (c->inst_ptr > c->specs->max_instructions) {
+   if (!c->specs->has_icache && c->inst_ptr > c->specs->max_instructions) {
   DBG("Number of instructions (%d) exceeds maximum %d", c->inst_ptr,
   c->specs->max_instructions);
   return false;
@@ -2501,6 +2501,7 @@ etna_compile_shader(struct etna_shader_variant *v)
v->vs_pointsize_out_reg = -1;
v->ps_color_out_reg = -1;
v->ps_depth_out_reg = -1;
+   v->needs_icache = c->inst_ptr > c->specs->max_instructions;
copy_uniform_state_to_shader(c, v);
 
if (c->info.processor == PIPE_SHADER_VERTEX) {
diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.h 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.h
index 88a093f..f5c1689 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.h
@@ -94,12 +94,17 @@ struct etna_shader_variant {
/* unknown input property (XX_INPUT_COUNT, field UNK8) */
uint32_t input_count_unk8;
 
+   /* shader is larger than GPU instruction limit, thus needs icache */
+   bool needs_icache;
+
/* shader variants form a linked list */
struct etna_shader_variant *next;
 
/* replicated here to avoid passing extra ptrs everywhere */
struct etna_shader *shader;
struct etna_shader_key key;
+
+   struct etna_bo *bo; /* cached code memory bo handle (for icache) */
 };
 
 struct etna_varying {
diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c 
b/src/gallium/drivers/etnaviv/etnaviv_emit.c
index 273b3d0..c2117d5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_emit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c
@@ -421,9 +421,6 @@ etna_emit_state(struct etna_context *ctx)
if (unlikely(dirty & (ETNA_DIRTY_SHADER))) {
   /*00830*/ EMIT_STATE(VS_LOAD_BALANCING, 
ctx->shader_state.VS_LOAD_BALANCING);
   /*00838*/ EMIT_STATE(VS_START_PC, ctx->shader_state.VS_START_PC);
-  if (ctx->specs.has_shader_range_registers) {
- /*0085C*/ EMIT_STATE(VS_RANGE, (ctx->shader_state.vs_inst_mem_size / 
4 - 1) << 16);
-  }
}
if (unlikely(dirty & (ETNA_DIRTY_VIEWPORT))) {
   /*00A00*/ EMIT_STATE_FIXP(PA_VIEWPORT_SCALE_X, 
ctx->viewport.PA_VIEWPORT_SCALE_X);
@@ -534,10 +531,6 @@ etna_emit_state(struct etna_context *ctx)
   : ctx->shader_state.PS_TEMP_REGISTER_CONTROL);
   /*01010*/ EMIT_STATE(PS_CONTROL, ctx->shader_state.PS_CONTROL);
   /*01018*/ EMIT_STATE(PS_START_PC, ctx->shader_state.PS_START_PC);
-  if (ctx->specs.has_shader_range_registers) {
- /*0101C*/ EMIT_STATE(PS_RANGE, ((ctx->shader_state.ps_inst_mem_size / 
4 - 1 + 0x100) << 16) |
-0x100);
-  }
}
if (unlikely(dirty & (ETNA_DIRTY_ZSA | ETNA_DIRTY_FRAMEBUFFER))) {
   uint32_t val = etna_zsa_state(ctx->zsa)->PE_DEPTH_CONFIG;
@@ -739,14 +732,43 @@ etna_emit_state(struct etna_context *ctx)
if (dirty & (ETNA_DIRTY_SHADER)) {
   /* Special case: a new shader was loaded; simply re-load all uniforms and
* shader code at once */
-  /*04000 or 0C000*/
-  etna_set_state_multi(stream, ctx->specs.vs_offset,
-   ctx->shader_state.vs_inst_mem_size,
-   ctx->shader_state.VS_INST_MEM);
-  /*06000 or 0D000*/
-  etna_set_state_multi(stream, ctx->specs.ps_offset,
-   ctx->shader_state.

Re: [Mesa-dev] [PATCH 1/3] etnaviv: support tile aligned RS blits

2017-09-19 Thread Wladimir J. van der Laan
On Fri, Sep 15, 2017 at 06:00:52PM +0200, Lucas Stach wrote:
> The RS can blit abitrary tile aligned subregions of a resource by
> adjusting the buffer offset.

Thanks for doing this.

Comments inline,

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 75 
> +---
>  1 file changed, 67 insertions(+), 8 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> index 92c91073434a..6734968ee4ed 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> @@ -358,6 +358,38 @@ etna_manual_blit(struct etna_resource *dst, struct 
> etna_resource_level *dst_lev,
> return true;
>  }
>  
> +static inline size_t
> +etna_compute_tileoffset(const struct pipe_box *box, enum pipe_format format,
> +size_t stride, enum etna_surface_layout layout)
> +{
> +   size_t offset;
> +   unsigned x = box->x, y = box->y;
> +
> +   switch (layout) {
> +   case ETNA_LAYOUT_LINEAR:
> +  offset = y * stride + x * util_format_get_blocksize(format);
> +  break;
> +   case ETNA_LAYOUT_MULTI_TILED:
> +  y >>= 1;
> +  /* fall-through */
> +   case ETNA_LAYOUT_TILED:
> +  offset = (y & ~0x03) * stride +
> +   util_format_get_blocksize(format) * ((x & ~0x03) << 2);
> +  break;
> +   case ETNA_LAYOUT_MULTI_SUPERTILED:
> +  y >>= 1;
> +  /* fall-through */
> +   case ETNA_LAYOUT_SUPER_TILED:
> +  offset = (y & ~0x3f) * stride +
> +   util_format_get_blocksize(format) * ((x & ~0x3f) << 6);
> +  break;
> +   default:
> +  unreachable("invalid resource layout");
> +   }
> +
> +   return offset;

Maybe add assertions that the passed-in coordinates are really tile-aligned
for the layout type, this could catch some bugs.

> +}
> +
>  static bool
>  etna_try_rs_blit(struct pipe_context *pctx,
>   const struct pipe_blit_info *blit_info)
> @@ -399,14 +431,32 @@ etna_try_rs_blit(struct pipe_context *pctx,
> unsigned dst_format = etna_compatible_rs_format(blit_info->dst.format);
> if (translate_rs_format(src_format) == ETNA_NO_MATCH ||
> translate_rs_format(dst_format) == ETNA_NO_MATCH ||
> -   blit_info->scissor_enable || blit_info->src.box.x != 0 ||
> -   blit_info->src.box.y != 0 || blit_info->dst.box.x != 0 ||
> -   blit_info->dst.box.y != 0 ||
> +   blit_info->scissor_enable ||
> blit_info->dst.box.depth != blit_info->src.box.depth ||
> blit_info->dst.box.depth != 1) {
>return FALSE;
> }
>  
> +   unsigned w_mask, h_mask;
> +
> +   if (src->layout & ETNA_LAYOUT_BIT_SUPER) {
> +  w_mask = h_mask = 0x3f;
> +   } else {
> +  w_mask = ETNA_RS_WIDTH_MASK;
> +  h_mask = ((ETNA_RS_HEIGHT_MASK + 1) * ctx->screen->specs.pixel_pipes - 
> 1);
> +   }
> +   if ((blit_info->src.box.x & w_mask) || (blit_info->src.box.y & h_mask))
> +  return FALSE;
> +
> +   if (dst->layout & ETNA_LAYOUT_BIT_SUPER) {
> +  w_mask = h_mask = 0x3f;
> +   } else {
> +  w_mask = ETNA_RS_WIDTH_MASK;
> +  h_mask = ((ETNA_RS_HEIGHT_MASK + 1) * ctx->screen->specs.pixel_pipes - 
> 1);
> +   }
> +   if ((blit_info->dst.box.x & w_mask) || (blit_info->dst.box.y & h_mask))
> +  return FALSE;
> +
> /* Ensure that the Z coordinate is sane */
> if (dst->base.target != PIPE_TEXTURE_CUBE)
>assert(blit_info->dst.box.z == 0);
> @@ -426,10 +476,18 @@ etna_try_rs_blit(struct pipe_context *pctx,
> assert(blit_info->dst.box.x + blit_info->dst.box.width <= 
> dst_lev->padded_width);
> assert(blit_info->dst.box.y + blit_info->dst.box.height <= 
> dst_lev->padded_height);
>  
> -   unsigned src_offset =
> -  src_lev->offset + blit_info->src.box.z * src_lev->layer_stride;
> -   unsigned dst_offset =
> -  dst_lev->offset + blit_info->dst.box.z * dst_lev->layer_stride;
> +   unsigned src_offset = src_lev->offset +
> + blit_info->src.box.z * src_lev->layer_stride +
> + etna_compute_tileoffset(&blit_info->src.box,
> + blit_info->src.format,
> + src_lev->stride,
> + src->layout);

Maybe include the z-computation in etna_compute_tileoffset as
well - this would be future-compatible with formats have 3D tiles instead of 
a stack of 2D ones (thinking of ASTC).

> +   unsigned dst_offset = dst_lev->offset +
> + blit_info->dst.box.z * dst_lev->layer_stride +
> + etna_compute_tileoffset(&blit_info->dst.box,
> + blit_info->dst.format,
> + dst_lev->stride,
> + dst->layout);
>  
> if (src_lev->padded_width <= ETNA_RS_W

Re: [Mesa-dev] [PATCH 2/3] etnaviv: add resource subregion copy

2017-09-19 Thread Wladimir J. van der Laan
On Fri, Sep 15, 2017 at 06:00:53PM +0200, Lucas Stach wrote:
> This is useful if we only need to copy part of a larger resource, mostly
> when using the RS engine to de-/tile on pipe transfers.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 27 
> 
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.h |  5 +
>  2 files changed, 32 insertions(+)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> index 6734968ee4ed..4dd86c3506d7 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> @@ -716,6 +716,33 @@ etna_copy_resource(struct pipe_context *pctx, struct 
> pipe_resource *dst,
>  }
>  
>  void
> +etna_copy_resource_box(struct pipe_context *pctx, struct pipe_resource *dst,
> +   struct pipe_resource *src, int level,
> +   struct pipe_box *box)
> +{
> +   assert(src->format == dst->format);
> +   assert(src->array_size == dst->array_size);
> +
> +   struct pipe_blit_info blit = {};
> +   blit.mask = util_format_get_mask(dst->format);
> +   blit.filter = PIPE_TEX_FILTER_NEAREST;
> +   blit.src.resource = src;
> +   blit.src.format = src->format;
> +   blit.src.box = *box;
> +   blit.dst.resource = dst;
> +   blit.dst.format = dst->format;
> +   blit.dst.box = *box;
> +
> +   blit.dst.box.depth = blit.src.box.depth = 1;
> +   blit.src.level = blit.dst.level = level;
> +
> +   for (int layer = 0; layer < dst->array_size; layer++) {
> +  blit.src.box.z = blit.dst.box.z = layer;
> +  pctx->blit(pctx, &blit);
> +   }
> +}
> +
> +void
>  etna_clear_blit_init(struct pipe_context *pctx)
>  {
> pctx->clear = etna_clear;
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.h 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.h
> index 73d07044b2b3..9bba6236b4db 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.h
> @@ -43,6 +43,11 @@ etna_copy_resource(struct pipe_context *pctx, struct 
> pipe_resource *dst,
> struct pipe_resource *src, int first_level, int 
> last_level);
>  
>  void
> +etna_copy_resource_box(struct pipe_context *pctx, struct pipe_resource *dst,
> +   struct pipe_resource *src, int level,
> +   struct pipe_box *box);
> +
> +void
>  etna_clear_blit_init(struct pipe_context *pctx);
>  
>  #endif
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 2/2] etnaviv: remove flat shading workaround

2017-09-19 Thread Wladimir J. van der Laan
On Fri, Sep 15, 2017 at 06:04:50PM +0200, Lucas Stach wrote:
> It turned out not to be a hardware bug, but the shader compiler
> emitting wrong varying component use information. With that fixed
> we can turn flat shading back on.
> 
> Signed-off-by: Lucas Stach 
> Reviewed-by: Philipp Zabel 

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_rasterizer.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> index 4990fd180257..56f2735e8a18 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> @@ -38,10 +38,6 @@ etna_rasterizer_state_create(struct pipe_context *pctx,
> struct etna_rasterizer_state *cs;
> struct etna_context *ctx = etna_context(pctx);
>  
> -/* Disregard flatshading on GC880+, as a HW bug there seem to disable all
> - * varying interpolation if it's enabled */
> -   bool flatshade = ctx->screen->model < 880 ? so->flatshade : false;
> -
> if (so->fill_front != so->fill_back)
>DBG("Different front and back fill mode not supported");
>  
> @@ -51,7 +47,7 @@ etna_rasterizer_state_create(struct pipe_context *pctx,
>  
> cs->base = *so;
>  
> -   cs->PA_CONFIG = (flatshade ? VIVS_PA_CONFIG_SHADE_MODEL_FLAT : 
> VIVS_PA_CONFIG_SHADE_MODEL_SMOOTH) |
> +   cs->PA_CONFIG = (so->flatshade ? VIVS_PA_CONFIG_SHADE_MODEL_FLAT : 
> VIVS_PA_CONFIG_SHADE_MODEL_SMOOTH) |
> translate_cull_face(so->cull_face, so->front_ccw) |
> translate_polygon_mode(so->fill_front) |
> COND(so->point_quad_rasterization, 
> VIVS_PA_CONFIG_POINT_SPRITE_ENABLE) |
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/2] etnaviv: fix varying interpolation

2017-09-19 Thread Wladimir J. van der Laan
On Fri, Sep 15, 2017 at 06:04:49PM +0200, Lucas Stach wrote:
> It seems that newer cores don't use the PA_ATTRIBUTES to decide if the
> varying should bypass the flat shading, but derive this from the component
> use. This fixes flat shading on GC880+.
> 
> VARYING_COMPONENT_USE_POINTCOORD is a bit of a misnomer now, as it isn't
> only used for pointcoords, but missing a better name I left it as-is.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Wladimir J. van der Laan 

> ---
> v2: fix invalid vreg assignment
> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 23 ++-
>  1 file changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index 165ab74298a4..d86d0561503a 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -2607,6 +2607,7 @@ etna_link_shader(struct etna_shader_link_info *info,
>const struct etna_shader_inout *fsio = &fs->infile.reg[idx];
>const struct etna_shader_inout *vsio = etna_shader_vs_lookup(vs, fsio);
>struct etna_varying *varying;
> +  bool interpolate = fsio->semantic.Name != TGSI_SEMANTIC_COLOR;
>  
>assert(fsio->reg > 0 && fsio->reg <= ARRAY_SIZE(info->varyings));
>  
> @@ -2616,28 +2617,24 @@ etna_link_shader(struct etna_shader_link_info *info,
>varying = &info->varyings[fsio->reg - 1];
>varying->num_components = fsio->num_components;
>  
> -  if (fsio->semantic.Name == TGSI_SEMANTIC_COLOR) /* colors affected by 
> flat shading */
> +  if (interpolate) /* colors affected by flat shading */
>   varying->pa_attributes = 0x200;
>else /* texture coord or other bypasses flat shading */
>   varying->pa_attributes = 0x2f1;
>  
> -  if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD) {
> - varying->use[0] = VARYING_COMPONENT_USE_POINTCOORD_X;
> - varying->use[1] = VARYING_COMPONENT_USE_POINTCOORD_Y;
> - varying->use[2] = VARYING_COMPONENT_USE_USED;
> - varying->use[3] = VARYING_COMPONENT_USE_USED;
> - varying->reg = 0; /* replaced by point coord -- doesn't matter */
> +  varying->use[0] = interpolate ? VARYING_COMPONENT_USE_POINTCOORD_X : 
> VARYING_COMPONENT_USE_USED;
> +  varying->use[1] = interpolate ? VARYING_COMPONENT_USE_POINTCOORD_Y : 
> VARYING_COMPONENT_USE_USED;
> +  varying->use[2] = VARYING_COMPONENT_USE_USED;
> +  varying->use[3] = VARYING_COMPONENT_USE_USED;
> +
> +
> +  if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD)
>   continue;
> -  }
>  
>if (vsio == NULL)
>   return true; /* not found -- link error */
>  
> -  varying->use[0] = VARYING_COMPONENT_USE_USED;
> -  varying->use[1] = VARYING_COMPONENT_USE_USED;
> -  varying->use[2] = VARYING_COMPONENT_USE_USED;
> -  varying->use[3] = VARYING_COMPONENT_USE_USED;
> -  varying->reg = vsio->reg;
> +  varying->reg = vsio->reg; /* replaced by point coord -- doesn't matter 
> */
> }
>  
> assert(info->num_varyings == fs->infile.num_reg);
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] etnaviv: move sw get_driver_query_info(..)

2017-09-19 Thread Wladimir J. van der Laan
On Tue, Sep 19, 2017 at 06:16:04PM +0200, Christian Gmeiner wrote:
> This change makes etna_get_driver_query_info(..) more generic
> and puts the knowledge of supported queries directly besides
> the implementation.
> 
> Signed-off-by: Christian Gmeiner 

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_query.c| 15 +++
>  src/gallium/drivers/etnaviv/etnaviv_query_sw.c | 21 +
>  src/gallium/drivers/etnaviv/etnaviv_query_sw.h |  4 
>  3 files changed, 28 insertions(+), 12 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c 
> b/src/gallium/drivers/etnaviv/etnaviv_query.c
> index 617e47562d..16adb8c21f 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_query.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
> @@ -81,21 +81,12 @@ static int
>  etna_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
> struct pipe_driver_query_info *info)
>  {
> -   struct pipe_driver_query_info list[] = {
> -  {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, { 0 }},
> -  {"draw-calls", ETNA_QUERY_DRAW_CALLS, { 0 }},
> -  {"rs-operations", ETNA_QUERY_RS_OPERATIONS, { 0 }},
> -   };
> +   int nr_sw_queries = etna_sw_get_driver_query_info(pscreen, 0, NULL);
>  
> if (!info)
> -  return ARRAY_SIZE(list);
> +  return nr_sw_queries;
>  
> -   if (index >= ARRAY_SIZE(list))
> -  return 0;
> -
> -   *info = list[index];
> -
> -   return 1;
> +   return etna_sw_get_driver_query_info(pscreen, index, info);
>  }
>  
>  static void
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c 
> b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
> index 213c61f38b..90f4a65826 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
> @@ -124,3 +124,24 @@ etna_sw_create_query(struct etna_context *ctx, unsigned 
> query_type)
>  
> return q;
>  }
> +
> +int
> +etna_sw_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
> +  struct pipe_driver_query_info *info)
> +{
> +   static const struct pipe_driver_query_info list[] = {
> +  {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, { 0 }},
> +  {"draw-calls", ETNA_QUERY_DRAW_CALLS, { 0 }},
> +  {"rs-operations", ETNA_QUERY_RS_OPERATIONS, { 0 }},
> +   };
> +
> +   if (!info)
> +  return ARRAY_SIZE(list);
> +
> +   if (index >= ARRAY_SIZE(list))
> +  return 0;
> +
> +   *info = list[index];
> +
> +   return 1;
> +}
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.h 
> b/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
> index 9de2bc60f9..f07d0f5915 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
> @@ -44,4 +44,8 @@ etna_sw_query(struct etna_query *q)
>  struct etna_query *
>  etna_sw_create_query(struct etna_context *ctx, unsigned query_type);
>  
> +int
> +etna_sw_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
> +  struct pipe_driver_query_info *info);
> +
>  #endif
> -- 
> 2.13.5
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] etnaviv: move sw query defines to etnaviv_query_sw.h

2017-09-19 Thread Wladimir J. van der Laan
On Tue, Sep 19, 2017 at 06:16:05PM +0200, Christian Gmeiner wrote:
> Also add new define ETNA_SW_QUERY_BASE.
> 
> Signed-off-by: Christian Gmeiner 

Reviewed-by: Wladimir J. van der Laan  

> ---
>  src/gallium/drivers/etnaviv/etnaviv_query.h| 3 +--
>  src/gallium/drivers/etnaviv/etnaviv_query_sw.h | 3 +++
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.h 
> b/src/gallium/drivers/etnaviv/etnaviv_query.h
> index cebd66238e..e099e10f7c 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_query.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_query.h
> @@ -53,8 +53,7 @@ etna_query(struct pipe_query *pq)
> return (struct etna_query *)pq;
>  }
>  
> -#define ETNA_QUERY_DRAW_CALLS(PIPE_QUERY_DRIVER_SPECIFIC + 0)
> -#define ETNA_QUERY_RS_OPERATIONS (PIPE_QUERY_DRIVER_SPECIFIC + 1)
> +#define ETNA_SW_QUERY_BASE   (PIPE_QUERY_DRIVER_SPECIFIC + 0)
>  
>  void
>  etna_query_screen_init(struct pipe_screen *pscreen);
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.h 
> b/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
> index f07d0f5915..9321147094 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
> @@ -30,6 +30,9 @@
>  
>  #include "etnaviv_query.h"
>  
> +#define ETNA_QUERY_DRAW_CALLS(ETNA_SW_QUERY_BASE + 0)
> +#define ETNA_QUERY_RS_OPERATIONS (ETNA_SW_QUERY_BASE + 1)
> +
>  struct etna_sw_query {
> struct etna_query base;
> uint64_t begin_value, end_value;
> -- 
> 2.13.5
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: fix 16bpp clears

2017-09-22 Thread Wladimir J. van der Laan
On Fri, Sep 22, 2017 at 11:24:08AM +0200, Lucas Stach wrote:
> util_pack_color may leave undefined values in the upper half of the packed
> integer. As our hardware needs the upper 16 bits to mirror the lower 16bits,
> this breaks clears of those formats if the undefined values aren't masked off.
> 
> I've only observed the issue with R5G6B5_UNORM surfaces, other 16bpp
> formats seem to work fine.

Reviewed-by: Wladimir J. van der Laan 

> 
> Fixes: d6aa2ba2b2 (etnaviv: replace translate_clear_color with 
> util_pack_color)
> Cc: mesa-sta...@lists.freedesktop.org
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> index 971403c45476..c85ada926699 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> @@ -106,7 +106,7 @@ pack_rgba(enum pipe_format format, const float *rgba)
> union util_color uc;
> util_pack_color(rgba, format, &uc);
> if (util_format_get_blocksize(format) == 2)
> -  return uc.ui[0] << 16 | uc.ui[0];
> +  return uc.ui[0] << 16 | (uc.ui[0] & 0x);
> else
>return uc.ui[0];
>  }
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] etnaviv: Add missing includes after 6ace0b8

2017-09-22 Thread Wladimir J. van der Laan
Add missing includes after 6ace0b8 (etnaviv: don't enable RT
full-overwrite when logicop is enabled), otherwise the etnaviv driver
won't build because of missing macros.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_blend.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_blend.c 
b/src/gallium/drivers/etnaviv/etnaviv_blend.c
index 7301841..1b432bd 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_blend.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_blend.c
@@ -27,7 +27,9 @@
 #include "etnaviv_blend.h"
 
 #include "etnaviv_context.h"
+#include "etnaviv_screen.h"
 #include "etnaviv_translate.h"
+#include "hw/common.xml.h"
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
 
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] etnaviv: Set up GC3000 states, fix point sprite rendering

2017-09-26 Thread Wladimir J. van der Laan
Set up new states that the blob started setting for GC3000 consistently.

This makes sure that when another test or driver leaves the GPU in
unpredictable state, these states are set up correctly for our
rendering.

Also, setting PA_VIEWPORT_UNK00A84 to fui(8192.0) is necessary
to make point sprite rendering on GC3000 work.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_context.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 2ca09ce..67aab6a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -317,6 +317,19 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream 
*stream, void *priv)
etna_set_state(stream, VIVS_GL_VERTEX_ELEMENT_CONFIG, 0x0001);
etna_set_state(stream, VIVS_RA_EARLY_DEPTH, 0x0031);
etna_set_state(stream, VIVS_PA_W_CLIP_LIMIT, 0x3401);
+   etna_set_state(stream, VIVS_PA_FLAGS, 0x); /* blob sets 
ZCONVERT_BYPASS on GC3000, this messes up z for us */
+   etna_set_state(stream, VIVS_RA_UNK00E0C, 0x);
+   etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A80, 0x38a01404);
+   etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A84, fui(8192.0));
+   etna_set_state(stream, VIVS_PA_ZFARCLIPPING, 0x);
+   etna_set_state(stream, VIVS_PE_ALPHA_COLOR_EXT0, 0x);
+   etna_set_state(stream, VIVS_PE_ALPHA_COLOR_EXT1, 0x);
+   etna_set_state(stream, VIVS_RA_HDEPTH_CONTROL, 0x7000);
+   etna_set_state(stream, VIVS_PE_STENCIL_CONFIG_EXT2, 0x);
+   etna_set_state(stream, VIVS_GL_UNK03834, 0x);
+   etna_set_state(stream, VIVS_GL_UNK03838, 0x);
+   etna_set_state(stream, VIVS_GL_UNK03854, 0x);
+   etna_set_state(stream, VIVS_PS_CONTROL_EXT, 0x);
 
/* Enable SINGLE_BUFFER for resolve, if supported */
etna_set_state(stream, VIVS_RS_SINGLE_BUFFER, 
COND(ctx->specs.single_buffer, VIVS_RS_SINGLE_BUFFER_ENABLE));
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 1/2] etnaviv: fix varying interpolation

2017-09-26 Thread Wladimir J. van der Laan
Hello Lucas,

On Fri, Sep 22, 2017 at 11:27:36AM +0200, Lucas Stach wrote:
> It seems that newer cores don't use the PA_ATTRIBUTES to decide if the
> varying should bypass the flat shading, but derive this from the component
> use. This fixes flat shading on GC880+.
> 
> VARYING_COMPONENT_USE_POINTCOORD is a bit of a misnomer now, as it isn't
> only used for pointcoords, but missing a better name I left it as-is.

I was just looking at recent command streams, and it appears that the blob
uses VARYING_COMPONENT_USE_UNUSED even for active components.
I've not seen it use VARYING_COMPONENT_USE_USED at all anymore.

Maybe that works instead of using the POINTCOORD for this? I'm glad
this solved the issue, and I'm ok with merging this as-is, but I have never
seen the blob use POINTCOORD for non-pointcoords and feel it would potentially
interfere with point sprites in some cases.

Regards,
Wladimir

> 
> Signed-off-by: Lucas Stach 
> Reviewed-by: Philipp Zabel 
> Reviewed-by: Wladimir J. van der Laan 
> ---
> v2: fix invalid vreg assignment
> v3: fix missed negation, improve variable naming
> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 22 ++
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
> b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index 165ab74298a4..0f6a5d23425d 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -2607,6 +2607,7 @@ etna_link_shader(struct etna_shader_link_info *info,
>const struct etna_shader_inout *fsio = &fs->infile.reg[idx];
>const struct etna_shader_inout *vsio = etna_shader_vs_lookup(vs, fsio);
>struct etna_varying *varying;
> +  bool interpolate_always = fsio->semantic.Name != TGSI_SEMANTIC_COLOR;
>  
>assert(fsio->reg > 0 && fsio->reg <= ARRAY_SIZE(info->varyings));
>  
> @@ -2616,27 +2617,24 @@ etna_link_shader(struct etna_shader_link_info *info,
>varying = &info->varyings[fsio->reg - 1];
>varying->num_components = fsio->num_components;
>  
> -  if (fsio->semantic.Name == TGSI_SEMANTIC_COLOR) /* colors affected by 
> flat shading */
> +  if (!interpolate_always) /* colors affected by flat shading */
>   varying->pa_attributes = 0x200;
>else /* texture coord or other bypasses flat shading */
>   varying->pa_attributes = 0x2f1;
>  
> -  if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD) {
> - varying->use[0] = VARYING_COMPONENT_USE_POINTCOORD_X;
> - varying->use[1] = VARYING_COMPONENT_USE_POINTCOORD_Y;
> - varying->use[2] = VARYING_COMPONENT_USE_USED;
> - varying->use[3] = VARYING_COMPONENT_USE_USED;
> - varying->reg = 0; /* replaced by point coord -- doesn't matter */
> +  varying->use[0] = interpolate_always ? 
> VARYING_COMPONENT_USE_POINTCOORD_X : VARYING_COMPONENT_USE_USED;
> +  varying->use[1] = interpolate_always ? 
> VARYING_COMPONENT_USE_POINTCOORD_Y : VARYING_COMPONENT_USE_USED;
> +  varying->use[2] = VARYING_COMPONENT_USE_USED;
> +  varying->use[3] = VARYING_COMPONENT_USE_USED;
> +
> +
> +  /* point coord is position output from VS, so has no dedicated reg */
> +  if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD)
>   continue;
> -  }
>  
>if (vsio == NULL)
>   return true; /* not found -- link error */
>  
> -  varying->use[0] = VARYING_COMPONENT_USE_USED;
> -  varying->use[1] = VARYING_COMPONENT_USE_USED;
> -  varying->use[2] = VARYING_COMPONENT_USE_USED;
> -  varying->use[3] = VARYING_COMPONENT_USE_USED;
>varying->reg = vsio->reg;
> }
>  
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/3] etnaviv: support tile aligned RS blits

2017-09-28 Thread Wladimir J. van der Laan
On Fri, Sep 22, 2017 at 11:31:49AM +0200, Lucas Stach wrote:
> The RS can blit abitrary tile aligned subregions of a resource by
> adjusting the buffer offset.
> 
> Signed-off-by: Lucas Stach 
> ---
> v2:
> - add asserts, so we catch any invalid use of the RS
> - split out tile mask computation, to make it easier to read the code

Thanks!

Reviewed-By: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 86 
> +---
>  1 file changed, 78 insertions(+), 8 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> index 92c91073434a..8030450dd1b0 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> @@ -358,6 +358,59 @@ etna_manual_blit(struct etna_resource *dst, struct 
> etna_resource_level *dst_lev,
> return true;
>  }
>  
> +static inline size_t
> +etna_compute_tileoffset(const struct pipe_box *box, enum pipe_format format,
> +size_t stride, enum etna_surface_layout layout)
> +{
> +   size_t offset;
> +   unsigned int x = box->x, y = box->y;
> +   unsigned int blocksize = util_format_get_blocksize(format);
> +
> +   switch (layout) {
> +   case ETNA_LAYOUT_LINEAR:
> +  offset = y * stride + x * blocksize;
> +  break;
> +   case ETNA_LAYOUT_MULTI_TILED:
> +  y >>= 1;
> +  /* fall-through */
> +   case ETNA_LAYOUT_TILED:
> +  assert(!(x & 0x03) && !(y & 0x03));
> +  offset = (y & ~0x03) * stride + blocksize * ((x & ~0x03) << 2);
> +  break;
> +   case ETNA_LAYOUT_MULTI_SUPERTILED:
> +  y >>= 1;
> +  /* fall-through */
> +   case ETNA_LAYOUT_SUPER_TILED:
> +  assert(!(x & 0x3f) && !(y & 0x3f));
> +  offset = (y & ~0x3f) * stride + blocksize * ((x & ~0x3f) << 6);
> +  break;
> +   default:
> +  unreachable("invalid resource layout");
> +   }
> +
> +   return offset;
> +}
> +
> +static inline void
> +etna_get_rs_alignment_mask(const struct etna_context *ctx,
> +   const enum etna_surface_layout layout,
> +   unsigned int *width_mask, unsigned int 
> *height_mask)
> +{
> +   unsigned int h_align, w_align;
> +
> +   if (layout & ETNA_LAYOUT_BIT_SUPER) {
> +  w_align = h_align = 64;
> +   } else {
> +  w_align = ETNA_RS_WIDTH_MASK + 1;
> +  h_align = ETNA_RS_HEIGHT_MASK + 1;
> +   }
> +
> +   h_align *= ctx->screen->specs.pixel_pipes;
> +
> +   *width_mask = w_align - 1;
> +   *height_mask = h_align -1;
> +}
> +
>  static bool
>  etna_try_rs_blit(struct pipe_context *pctx,
>   const struct pipe_blit_info *blit_info)
> @@ -399,14 +452,22 @@ etna_try_rs_blit(struct pipe_context *pctx,
> unsigned dst_format = etna_compatible_rs_format(blit_info->dst.format);
> if (translate_rs_format(src_format) == ETNA_NO_MATCH ||
> translate_rs_format(dst_format) == ETNA_NO_MATCH ||
> -   blit_info->scissor_enable || blit_info->src.box.x != 0 ||
> -   blit_info->src.box.y != 0 || blit_info->dst.box.x != 0 ||
> -   blit_info->dst.box.y != 0 ||
> +   blit_info->scissor_enable ||
> blit_info->dst.box.depth != blit_info->src.box.depth ||
> blit_info->dst.box.depth != 1) {
>return FALSE;
> }
>  
> +   unsigned w_mask, h_mask;
> +
> +   etna_get_rs_alignment_mask(ctx, src->layout, &w_mask, &h_mask);
> +   if ((blit_info->src.box.x & w_mask) || (blit_info->src.box.y & h_mask))
> +  return FALSE;
> +
> +   etna_get_rs_alignment_mask(ctx, dst->layout, &w_mask, &h_mask);
> +   if ((blit_info->dst.box.x & w_mask) || (blit_info->dst.box.y & h_mask))
> +  return FALSE;
> +
> /* Ensure that the Z coordinate is sane */
> if (dst->base.target != PIPE_TEXTURE_CUBE)
>assert(blit_info->dst.box.z == 0);
> @@ -426,10 +487,18 @@ etna_try_rs_blit(struct pipe_context *pctx,
> assert(blit_info->dst.box.x + blit_info->dst.box.width <= 
> dst_lev->padded_width);
> assert(blit_info->dst.box.y + blit_info->dst.box.height <= 
> dst_lev->padded_height);
>  
> -   unsigned src_offset =
> -  src_lev->offset + blit_info->src.box.z * src_lev->layer_stride;
> -   unsigned dst_offset =
> -  dst_lev->offset + blit_info->dst.box.z * dst_lev->layer_stride;
> +   unsigned src_offset = src_lev->offset +
> + blit_info->

Re: [Mesa-dev] [PATCH v2 3/3] etnaviv: optimize RS transfers

2017-09-28 Thread Wladimir J. van der Laan
On Fri, Sep 22, 2017 at 11:31:51AM +0200, Lucas Stach wrote:
> Currently we are blitting the whole resource when the RS is used to
> de-/tile a resource. This can be very inefficient for large resources
> where the transfer is only changing a small part of the resource
> (happens a lot with glTexSubImage2D).
> 
> Optimize this by only blitting the tile aligned subregion of the
> resource, which the transfer is going to change.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 29 
> ++
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: update HW headers and fix provoking vertex

2017-09-29 Thread Wladimir J. van der Laan
On Fri, Sep 29, 2017 at 03:40:49PM +0200, Lucas Stach wrote:
> Now that the real meaning of the 2 bits in PA_SYSTEM_MODE is known,
> we can set them according to the rasterizer state, which fixes uses
> that are setting provoking vertex first.
> 
> Signed-off-by: Lucas Stach 

Thanks for figuring this one out

Reviewed-by: Wladimir J. van der Laan : Wladimir J. van der 
Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_rasterizer.c |  3 +-
>  src/gallium/drivers/etnaviv/hw/cmdstream.xml.h   |  8 +--
>  src/gallium/drivers/etnaviv/hw/common.xml.h  | 18 +++---
>  src/gallium/drivers/etnaviv/hw/isa.xml.h |  4 +-
>  src/gallium/drivers/etnaviv/hw/state.xml.h   | 14 ++---
>  src/gallium/drivers/etnaviv/hw/state_3d.xml.h| 79 
> +++-
>  6 files changed, 75 insertions(+), 51 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> index 56f2735e8a18..c8627b1a9ab4 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c
> @@ -61,7 +61,8 @@ etna_rasterizer_state_create(struct pipe_context *pctx,
> /* XXX anything else? */
> /* XXX bottom_edge_rule */
> cs->PA_SYSTEM_MODE =
> -  COND(so->half_pixel_center, VIVS_PA_SYSTEM_MODE_UNK0 | 
> VIVS_PA_SYSTEM_MODE_UNK4);
> +  COND(!so->flatshade_first, VIVS_PA_SYSTEM_MODE_PROVOKING_VERTEX_LAST) |
> +  COND(so->half_pixel_center, VIVS_PA_SYSTEM_MODE_HALF_PIXEL_CENTER);
>  
> /* so->scissor overrides the scissor, defaulting to the whole framebuffer,
>  * with the scissor state */
> diff --git a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h 
> b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
> index d4da03016ea5..f8d76b010582 100644
> --- a/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
> +++ b/src/gallium/drivers/etnaviv/hw/cmdstream.xml.h
> @@ -8,11 +8,11 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
>  git clone git://0x04.net/rules-ng-ng
>  
>  The rules-ng-ng source files this header was generated from are:
> -- cmdstream.xml (  14313 bytes, from 2016-11-17 18:46:23)
> -- copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
> -- common.xml(  23473 bytes, from 2017-01-07 14:27:54)
> +- cmdstream.xml (  15289 bytes, from 2017-09-29 11:52:39)
> +- copyright.xml (   1597 bytes, from 2016-12-08 16:37:56)
> +- common.xml(  23529 bytes, from 2017-09-29 11:52:39)
>  
> -Copyright (C) 2012-2016 by the following authors:
> +Copyright (C) 2012-2017 by the following authors:
>  - Wladimir J. van der Laan 
>  - Christian Gmeiner 
>  - Lucas Stach 
> diff --git a/src/gallium/drivers/etnaviv/hw/common.xml.h 
> b/src/gallium/drivers/etnaviv/hw/common.xml.h
> index 8b73fd812896..85c4990b61ae 100644
> --- a/src/gallium/drivers/etnaviv/hw/common.xml.h
> +++ b/src/gallium/drivers/etnaviv/hw/common.xml.h
> @@ -8,13 +8,13 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng
>  git clone git://0x04.net/rules-ng-ng
>  
>  The rules-ng-ng source files this header was generated from are:
> -- state.xml (  19930 bytes, from 2017-01-07 14:27:54)
> -- common.xml(  23473 bytes, from 2017-01-07 14:27:54)
> -- state_hi.xml  (  26403 bytes, from 2017-01-07 14:27:54)
> -- copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
> -- state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
> -- state_3d.xml  (  66964 bytes, from 2017-04-13 12:38:05)
> -- state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
> +- state.xml (  20229 bytes, from 2017-09-29 11:52:39)
> +- common.xml(  23529 bytes, from 2017-09-29 11:52:39)
> +- state_hi.xml  (  26403 bytes, from 2017-03-09 15:43:43)
> +- copyright.xml (   1597 bytes, from 2016-12-08 16:37:56)
> +- state_2d.xml  (  51552 bytes, from 2016-12-08 16:37:56)
> +- state_3d.xml  (  68429 bytes, from 2017-09-29 11:55:19)
> +- state_vg.xml  (   5975 bytes, from 2016-12-08 16:37:56)
>  
>  Copyright (C) 2012-2017 by the following authors:
>  - Wladimir J. van der Laan 
> @@ -247,7 +247,7 @@ DEALINGS IN THE SOFTWARE.
>  #define chipMinorFeatures3_UNK24 0x0100
>  #define chipMinorFeatures3_UNK25 0x0200
>  #define chipMinorFeatures3_NEW_HZ0x0400
> -#define chipMinorFeatures3_UNK27 0x0800
> +#define chipMinorFeatures3_PE_DITHER_FIX 0x0800
>  #define chipMinorFeatures3_UNK28 0x1000
>  #define chipMinorFeatures3_SH_ENHANCEMENTS3  0x2000
>  #define chipMinorFeatures3_UNK30 0x4000
> @@ -269,7 +269,7 @@ DEALING

[Mesa-dev] [PATCH] etnaviv: Do GC3000 resolve-in-place when possible

2017-09-29 Thread Wladimir J. van der Laan
If an RS blit is done with source exactly the same as destination, and
the hardware supports this, do an in-place resolve.

This is the same as the blob does and potentially saves significant
bandwidth when doing i.MX6qp scanout using PRE, and when rendering to
textures (though here using sampler TS would be even better).

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_emit.c |  9 -
 src/gallium/drivers/etnaviv/etnaviv_rs.c   | 16 +---
 src/gallium/drivers/etnaviv/etnaviv_rs.h   |  1 +
 3 files changed, 22 insertions(+), 4 deletions(-)

This depends (for updating the rnndb headers) on Lucas Stach's patch
"etnaviv: update HW headers and fix provoking vertex".

diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c 
b/src/gallium/drivers/etnaviv/etnaviv_emit.c
index c2117d5..707b1e7 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_emit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c
@@ -173,7 +173,14 @@ etna_submit_rs_state(struct etna_context *ctx,
 
ctx->stats.rs_operations++;
 
-   if (screen->specs.pixel_pipes == 1) {
+   if (cs->RS_KICKER_INPLACE) {
+  etna_cmd_stream_reserve(stream, 6);
+  etna_coalesce_start(stream, &coalesce);
+  /* 0/1 */ EMIT_STATE(RS_EXTRA_CONFIG, cs->RS_EXTRA_CONFIG);
+  /* 2/3 */ EMIT_STATE(RS_SOURCE_STRIDE, cs->RS_SOURCE_STRIDE);
+  /* 4/5 */ EMIT_STATE(RS_KICKER_INPLACE, cs->RS_KICKER_INPLACE);
+  etna_coalesce_end(stream, &coalesce);
+   } else if (screen->specs.pixel_pipes == 1) {
   etna_cmd_stream_reserve(stream, 22);
   etna_coalesce_start(stream, &coalesce);
   /* 0/1 */ EMIT_STATE(RS_CONFIG, cs->RS_CONFIG);
diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
b/src/gallium/drivers/etnaviv/etnaviv_rs.c
index 5c108a6..7e90ab7 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_rs.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c
@@ -118,10 +118,20 @@ etna_compile_rs_state(struct etna_context *ctx, struct 
compiled_rs_state *cs,
cs->RS_FILL_VALUE[3] = rs->clear_value[3];
cs->RS_EXTRA_CONFIG = VIVS_RS_EXTRA_CONFIG_AA(rs->aa) |
  VIVS_RS_EXTRA_CONFIG_ENDIAN(rs->endian_mode);
-   /* TODO: cs->RS_UNK016B0 = s->size / 64 ?
-* The blob does this consistently but there seems to be no currently 
supported
-* model that needs it.
+
+   /* Is source the same as destination, if so do an in-place resolve if
+* the hardware supports this.
 */
+   if (ctx->specs.single_buffer && rs->source == rs->dest &&
+ rs->source_offset == rs->dest_offset &&
+ rs->source_format == rs->dest_format &&
+ rs->source_tiling == rs->dest_tiling &&
+ rs->source_stride == rs->dest_stride &&
+ !rs->downsample_x && !rs->downsample_y &&
+ !rs->swap_rb && !rs->flip &&
+ !rs->clear_mode) {
+   cs->RS_KICKER_INPLACE = (rs->width / 4) * (rs->height / 4);
+   }
 }
 
 void
diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.h 
b/src/gallium/drivers/etnaviv/etnaviv_rs.h
index ec5b659..b354a26 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_rs.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_rs.h
@@ -69,6 +69,7 @@ struct compiled_rs_state {
uint32_t RS_FILL_VALUE[4];
uint32_t RS_EXTRA_CONFIG;
uint32_t RS_PIPE_OFFSET[2];
+   uint32_t RS_KICKER_INPLACE; /* Set if source is destination */
 
struct etna_reloc source[2];
struct etna_reloc dest[2];
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: fix bogus flush requests in transfer handling

2017-09-29 Thread Wladimir J. van der Laan
On Fri, Sep 29, 2017 at 03:40:11PM +0200, Lucas Stach wrote:
> The logic to decide if we need to flush the GPU command stream was broken
> and hard to reason about. Fix and clarify this.
> 
> Fixes the data sync subtests from piglit arb_vertex_buffer_object.
> 
> Signed-off-by: Lucas Stach 

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 15 ++-
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: Do GC3000 resolve-in-place when possible

2017-09-29 Thread Wladimir J. van der Laan
On Fri, Sep 29, 2017 at 06:00:13PM +0200, Wladimir J. van der Laan wrote:
> If an RS blit is done with source exactly the same as destination, and
> the hardware supports this, do an in-place resolve.
> 
> This is the same as the blob does and potentially saves significant
> bandwidth when doing i.MX6qp scanout using PRE, and when rendering to
> textures (though here using sampler TS would be even better).
> 
> Signed-off-by: Wladimir J. van der Laan 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_emit.c |  9 -
>  src/gallium/drivers/etnaviv/etnaviv_rs.c   | 16 +---
>  src/gallium/drivers/etnaviv/etnaviv_rs.h   |  1 +
>  3 files changed, 22 insertions(+), 4 deletions(-)
> 

> +   if (ctx->specs.single_buffer && rs->source == rs->dest &&
> + rs->source_offset == rs->dest_offset &&
> + rs->source_format == rs->dest_format &&
> + rs->source_tiling == rs->dest_tiling &&
> + rs->source_stride == rs->dest_stride &&
> + !rs->downsample_x && !rs->downsample_y &&
> + !rs->swap_rb && !rs->flip &&
> + !rs->clear_mode) {
> +   cs->RS_KICKER_INPLACE = (rs->width / 4) * (rs->height / 4);

On second thought this computation is wrong in case of padding, the value we 
need here is
same as the autodisable tile count:

> surf->surf.padded_width * surf->surf.padded_height / 16

Will send a revised patch asap.

Regards
Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] etnaviv: Do GC3000 resolve-in-place when possible

2017-09-30 Thread Wladimir J. van der Laan
If an RS blit is done with source exactly the same as destination, and
the hardware supports this, do an in-place resolve. This only fills in
tiles that have not been rendered to using information from the TS.

This is the same as the blob does and potentially saves significant
bandwidth when doing i.MX6qp scanout using PRE, and when rendering to
textures (though here using sampler TS would be even better).

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_clear_blit.c |  1 +
 src/gallium/drivers/etnaviv/etnaviv_emit.c   |  9 -
 src/gallium/drivers/etnaviv/etnaviv_rs.c | 17 ++---
 src/gallium/drivers/etnaviv/etnaviv_rs.h |  2 ++
 4 files changed, 25 insertions(+), 4 deletions(-)

This depends (for updating the rnndb headers) on Lucas Stach's patch
"etnaviv: update HW headers and fix provoking vertex".

diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
index c85ada9..c62287b 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
@@ -591,6 +591,7 @@ etna_try_rs_blit(struct pipe_context *pctx,
   .source = src->bo,
   .source_offset = src_offset,
   .source_stride = src_lev->stride,
+  .source_padded_width = src_lev->padded_width,
   .source_padded_height = src_lev->padded_height,
   .dest_format = translate_rs_format(dst_format),
   .dest_tiling = dst->layout,
diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.c 
b/src/gallium/drivers/etnaviv/etnaviv_emit.c
index c2117d5..707b1e7 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_emit.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_emit.c
@@ -173,7 +173,14 @@ etna_submit_rs_state(struct etna_context *ctx,
 
ctx->stats.rs_operations++;
 
-   if (screen->specs.pixel_pipes == 1) {
+   if (cs->RS_KICKER_INPLACE) {
+  etna_cmd_stream_reserve(stream, 6);
+  etna_coalesce_start(stream, &coalesce);
+  /* 0/1 */ EMIT_STATE(RS_EXTRA_CONFIG, cs->RS_EXTRA_CONFIG);
+  /* 2/3 */ EMIT_STATE(RS_SOURCE_STRIDE, cs->RS_SOURCE_STRIDE);
+  /* 4/5 */ EMIT_STATE(RS_KICKER_INPLACE, cs->RS_KICKER_INPLACE);
+  etna_coalesce_end(stream, &coalesce);
+   } else if (screen->specs.pixel_pipes == 1) {
   etna_cmd_stream_reserve(stream, 22);
   etna_coalesce_start(stream, &coalesce);
   /* 0/1 */ EMIT_STATE(RS_CONFIG, cs->RS_CONFIG);
diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c 
b/src/gallium/drivers/etnaviv/etnaviv_rs.c
index 5c108a6..c9072c2 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_rs.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c
@@ -118,10 +118,21 @@ etna_compile_rs_state(struct etna_context *ctx, struct 
compiled_rs_state *cs,
cs->RS_FILL_VALUE[3] = rs->clear_value[3];
cs->RS_EXTRA_CONFIG = VIVS_RS_EXTRA_CONFIG_AA(rs->aa) |
  VIVS_RS_EXTRA_CONFIG_ENDIAN(rs->endian_mode);
-   /* TODO: cs->RS_UNK016B0 = s->size / 64 ?
-* The blob does this consistently but there seems to be no currently 
supported
-* model that needs it.
+
+   /* If source the same as destination, and the hardware supports this,
+* do an in-place resolve to fill in unrendered tiles.
 */
+   if (ctx->specs.single_buffer && rs->source == rs->dest &&
+ rs->source_offset == rs->dest_offset &&
+ rs->source_format == rs->dest_format &&
+ rs->source_tiling == rs->dest_tiling &&
+ rs->source_stride == rs->dest_stride &&
+ !rs->downsample_x && !rs->downsample_y &&
+ !rs->swap_rb && !rs->flip &&
+ !rs->clear_mode && rs->source_padded_width) {
+  /* Total number of tiles (same as for autodisable) */
+  cs->RS_KICKER_INPLACE = rs->source_padded_width * 
rs->source_padded_height / 16;
+   }
 }
 
 void
diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.h 
b/src/gallium/drivers/etnaviv/etnaviv_rs.h
index ec5b659..171d3fa 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_rs.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_rs.h
@@ -43,6 +43,7 @@ struct rs_state {
struct etna_bo *source;
uint32_t source_offset;
uint32_t source_stride;
+   uint32_t source_padded_width; /* total padded width (only needed for 
source) */
uint32_t source_padded_height; /* total padded height */
struct etna_bo *dest;
uint32_t dest_offset;
@@ -69,6 +70,7 @@ struct compiled_rs_state {
uint32_t RS_FILL_VALUE[4];
uint32_t RS_EXTRA_CONFIG;
uint32_t RS_PIPE_OFFSET[2];
+   uint32_t RS_KICKER_INPLACE; /* Set if source is destination */
 
struct etna_reloc source[2];
struct etna_reloc dest[2];
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/2] etnaviv: Support opcode bit 6 assembler, add DP2 instruction

2017-10-01 Thread Wladimir J. van der Laan
Support opcodes with bit 6 set in assembler, then use that to add the DP2
instruction, supported with HALTI2.

Wladimir J. van der Laan (2):
  etnaviv: Support opcodes with bit 6 set in assembler
  etnaviv: Add support for DP2 instruction

 src/gallium/drivers/etnaviv/etnaviv_asm.c  | 5 -
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 3 ++-
 src/gallium/drivers/etnaviv/etnaviv_disasm.c   | 1 +
 src/gallium/drivers/etnaviv/etnaviv_internal.h | 2 ++
 src/gallium/drivers/etnaviv/etnaviv_screen.c   | 2 ++
 5 files changed, 11 insertions(+), 2 deletions(-)

-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] etnaviv: Support opcodes with bit 6 set in assembler

2017-10-01 Thread Wladimir J. van der Laan
Support opcodes with bit 6 set in assembler, and assert that only ops
0x00..0x7f are used.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_asm.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_asm.c 
b/src/gallium/drivers/etnaviv/etnaviv_asm.c
index 7d6270c..8ef4dc9 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_asm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_asm.c
@@ -68,7 +68,9 @@ etna_assemble(uint32_t *out, const struct etna_inst *inst)
if (!check_uniforms(inst))
   BUG("error: generating instruction that accesses two different 
uniforms");
 
-   out[0] = VIV_ISA_WORD_0_OPCODE(inst->opcode) |
+   assert(!(inst->opcode&~0x7f));
+
+   out[0] = VIV_ISA_WORD_0_OPCODE(inst->opcode & 0x3f) |
 VIV_ISA_WORD_0_COND(inst->cond) |
 COND(inst->sat, VIV_ISA_WORD_0_SAT) |
 COND(inst->dst.use, VIV_ISA_WORD_0_DST_USE) |
@@ -88,6 +90,7 @@ etna_assemble(uint32_t *out, const struct etna_inst *inst)
 VIV_ISA_WORD_2_SRC0_RGROUP(inst->src[0].rgroup) |
 COND(inst->src[1].use, VIV_ISA_WORD_2_SRC1_USE) |
 VIV_ISA_WORD_2_SRC1_REG(inst->src[1].reg) |
+COND(inst->opcode & 0x40, VIV_ISA_WORD_2_OPCODE_BIT6) |
 VIV_ISA_WORD_2_SRC1_SWIZ(inst->src[1].swiz) |
 COND(inst->src[1].neg, VIV_ISA_WORD_2_SRC1_NEG) |
 COND(inst->src[1].abs, VIV_ISA_WORD_2_SRC1_ABS) |
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] etnaviv: Add support for DP2 instruction

2017-10-01 Thread Wladimir J. van der Laan
A two-component dot product instruction is supported with HALTI2, use it
on hardware that supports it.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 3 ++-
 src/gallium/drivers/etnaviv/etnaviv_disasm.c   | 1 +
 src/gallium/drivers/etnaviv/etnaviv_internal.h | 2 ++
 src/gallium/drivers/etnaviv/etnaviv_screen.c   | 2 ++
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 2a2af45..5d327dd 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -1752,6 +1752,7 @@ static const struct instr_translater 
translaters[TGSI_OPCODE_LAST] = {
INSTR(RSQ, trans_instr, .opc = INST_OPCODE_RSQ, .src = {2, -1, -1}),
INSTR(MUL, trans_instr, .opc = INST_OPCODE_MUL, .src = {0, 1, -1}),
INSTR(ADD, trans_instr, .opc = INST_OPCODE_ADD, .src = {0, 2, -1}),
+   INSTR(DP2, trans_instr, .opc = INST_OPCODE_DP2, .src = {0, 1, -1}),
INSTR(DP3, trans_instr, .opc = INST_OPCODE_DP3, .src = {0, 1, -1}),
INSTR(DP4, trans_instr, .opc = INST_OPCODE_DP4, .src = {0, 1, -1}),
INSTR(DST, trans_instr, .opc = INST_OPCODE_DST, .src = {0, 1, -1}),
@@ -2293,7 +2294,7 @@ etna_compile_shader(struct etna_shader_variant *v)
   .lower_POW = true,
   .lower_EXP = true,
   .lower_LOG = true,
-  .lower_DP2 = true,
+  .lower_DP2 = !specs->has_halti2_instructions,
   .lower_TRUNC = true,
};
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_disasm.c 
b/src/gallium/drivers/etnaviv/etnaviv_disasm.c
index 918d24e..9ae99da 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_disasm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_disasm.c
@@ -513,6 +513,7 @@ static const struct opc_info {
OPC(AND),
OPC(XOR),
OPC(NOT),
+   OPC(DP2),
 };
 
 static void
diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h 
b/src/gallium/drivers/etnaviv/etnaviv_internal.h
index a6544f6..896bbf5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_internal.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h
@@ -72,6 +72,8 @@ struct etna_specs {
unsigned has_shader_range_registers : 1;
/* has the new sin/cos/log functions */
unsigned has_new_transcendentals : 1;
+   /* has the new dp2/dpX_norm instructions, among others */
+   unsigned has_halti2_instructions : 1;
/* supports single-buffer rendering with multiple pixel pipes */
unsigned single_buffer : 1;
/* has unified uniforms memory */
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index ea2581b..84da2a2 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -701,6 +701,8 @@ etna_get_specs(struct etna_screen *screen)
   VIV_FEATURE(screen, chipMinorFeatures1, NON_POWER_OF_TWO);
screen->specs.has_new_transcendentals =
   VIV_FEATURE(screen, chipMinorFeatures3, HAS_FAST_TRANSCENDENTALS);
+   screen->specs.has_halti2_instructions =
+  VIV_FEATURE(screen, chipMinorFeatures4, HALTI2);
 
if (VIV_FEATURE(screen, chipMinorFeatures3, INSTRUCTION_CACHE)) {
   /* GC3000 - this core is capable of loading shaders from
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 2/2] etnaviv: Set up unknown GC3000 states

2017-10-01 Thread Wladimir J. van der Laan
Set up new states that the blob started setting for GC3000 consistently.

This makes sure that when another test or driver leaves the GPU in
unpredictable state, these states are set up correctly for our
rendering.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_context.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 45fc465..67aab6a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -317,8 +317,19 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream 
*stream, void *priv)
etna_set_state(stream, VIVS_GL_VERTEX_ELEMENT_CONFIG, 0x0001);
etna_set_state(stream, VIVS_RA_EARLY_DEPTH, 0x0031);
etna_set_state(stream, VIVS_PA_W_CLIP_LIMIT, 0x3401);
+   etna_set_state(stream, VIVS_PA_FLAGS, 0x); /* blob sets 
ZCONVERT_BYPASS on GC3000, this messes up z for us */
+   etna_set_state(stream, VIVS_RA_UNK00E0C, 0x);
etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A80, 0x38a01404);
etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A84, fui(8192.0));
+   etna_set_state(stream, VIVS_PA_ZFARCLIPPING, 0x);
+   etna_set_state(stream, VIVS_PE_ALPHA_COLOR_EXT0, 0x);
+   etna_set_state(stream, VIVS_PE_ALPHA_COLOR_EXT1, 0x);
+   etna_set_state(stream, VIVS_RA_HDEPTH_CONTROL, 0x7000);
+   etna_set_state(stream, VIVS_PE_STENCIL_CONFIG_EXT2, 0x);
+   etna_set_state(stream, VIVS_GL_UNK03834, 0x);
+   etna_set_state(stream, VIVS_GL_UNK03838, 0x);
+   etna_set_state(stream, VIVS_GL_UNK03854, 0x);
+   etna_set_state(stream, VIVS_PS_CONTROL_EXT, 0x);
 
/* Enable SINGLE_BUFFER for resolve, if supported */
etna_set_state(stream, VIVS_RS_SINGLE_BUFFER, 
COND(ctx->specs.single_buffer, VIVS_RS_SINGLE_BUFFER_ENABLE));
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 1/2] etnaviv: Fix point sprite rendering on GC3000

2017-10-01 Thread Wladimir J. van der Laan
Setting PA_VIEWPORT_UNK state correctly is necessary to make point sprite
rendering on GC3000 work.

Signed-off-by: Wladimir J. van der Laan 
---
 src/gallium/drivers/etnaviv/etnaviv_context.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c 
b/src/gallium/drivers/etnaviv/etnaviv_context.c
index 2ca09ce..45fc465 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -317,6 +317,8 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream 
*stream, void *priv)
etna_set_state(stream, VIVS_GL_VERTEX_ELEMENT_CONFIG, 0x0001);
etna_set_state(stream, VIVS_RA_EARLY_DEPTH, 0x0031);
etna_set_state(stream, VIVS_PA_W_CLIP_LIMIT, 0x3401);
+   etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A80, 0x38a01404);
+   etna_set_state(stream, VIVS_PA_VIEWPORT_UNK00A84, fui(8192.0));
 
/* Enable SINGLE_BUFFER for resolve, if supported */
etna_set_state(stream, VIVS_RS_SINGLE_BUFFER, 
COND(ctx->specs.single_buffer, VIVS_RS_SINGLE_BUFFER_ENABLE));
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 0/2] etnaviv: Set up GC3000 states, fix point sprite rendering

2017-10-01 Thread Wladimir J. van der Laan
Set up new states that the blob started setting for GC3000 consistently.

This makes sure that when another test or driver leaves the GPU in
unpredictable state, these states are set up correctly for our
rendering.

Also, setting PA_VIEWPORT_UNK00A84 to fui(8192.0) is necessary
to make point sprite rendering on GC3000 work.

Wladimir J. van der Laan (2):
  etnaviv: Fix point sprite rendering on GC3000
  etnaviv: Set up unknown GC3000 states

 src/gallium/drivers/etnaviv/etnaviv_context.c | 13 +
 1 file changed, 13 insertions(+)

-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] etnaviv: Set up GC3000 states, fix point sprite rendering

2017-10-01 Thread Wladimir J. van der Laan
On Sun, Oct 01, 2017 at 01:46:05PM +0200, Christian Gmeiner wrote:
> Okay.. hopefully we do not forget to remove them here when it gets
> used during state emission like PE_ALPHA_COLOR_EXT0. But I
> am fine with that change and will shut up.

Yes, it should be removed then. Though if I understand correctly, nothing bad
will happen if we forget, except a one-time-per-frame spurious state emission.

In a way this serves as a reminder to figure out what those states do and move
them with the right state object instead of globally. 

PE_ALPHA_COLOR_EXTx is the exception in the bunch in that we know what it does
(just not when it gets used). Likely you're going to need to set it with the
half-float render targets.

> >> > Also, setting PA_VIEWPORT_UNK00A84 to fui(8192.0) is necessary
> >> > to make point sprite rendering on GC3000 work.
> >>
> >> I would prefer a patch that only sets PA_VIEWPORT_UNK00A84 to fix point
> >> sprite rendering on GC3000.
> >
> > Yeah, splitting up this patch into 2 would be good style.
> >
> 
> It would good style but I take this patch as it is.

Ok, sent a split-up version, up to you which one you take.

Wladimir
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/6] gallium: plumb context priority through to driver

2017-10-05 Thread Wladimir J. van der Laan
On Wed, Oct 04, 2017 at 11:44:32AM -0400, Rob Clark wrote:
> Signed-off-by: Rob Clark 

Reviewed etnaviv change only.

Reviewed-by: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_screen.c|  1 +
>  src/gallium/drivers/freedreno/freedreno_screen.c|  1 +
>  src/gallium/drivers/i915/i915_screen.c  |  1 +
>  src/gallium/drivers/llvmpipe/lp_screen.c|  1 +
>  src/gallium/drivers/nouveau/nv30/nv30_screen.c  |  1 +
>  src/gallium/drivers/nouveau/nv50/nv50_screen.c  |  1 +
>  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c  |  1 +
>  src/gallium/drivers/r300/r300_screen.c  |  1 +
>  src/gallium/drivers/r600/r600_pipe.c|  1 +
>  src/gallium/drivers/radeonsi/si_pipe.c  |  1 +
>  src/gallium/drivers/softpipe/sp_screen.c|  1 +
>  src/gallium/drivers/svga/svga_screen.c  |  1 +
>  src/gallium/drivers/swr/swr_screen.cpp  |  1 +
>  src/gallium/drivers/vc4/vc4_screen.c|  1 +
>  src/gallium/drivers/virgl/virgl_screen.c|  1 +
>  src/gallium/include/pipe/p_defines.h| 21 
> +
>  src/gallium/include/state_tracker/st_api.h  |  2 ++
>  src/gallium/state_trackers/dri/dri_context.c| 11 +++
>  src/gallium/state_trackers/dri/dri_query_renderer.c |  8 +++-
>  src/mesa/state_tracker/st_manager.c |  5 +
>  20 files changed, 61 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
> b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index 42905ab0620..16bd4b7c0fb 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -264,6 +264,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum 
> pipe_cap param)
> case PIPE_CAP_QUERY_SO_OVERFLOW:
> case PIPE_CAP_MEMOBJ:
> case PIPE_CAP_LOAD_CONSTBUF:
> +   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
>return 0;
>  
> /* Stream output. */
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/6] etnaviv: always do cpu_fini in transfer_unmap

2017-05-31 Thread Wladimir J. van der Laan
On Fri, May 19, 2017 at 11:41:07AM +0200, Lucas Stach wrote:
> The cpu_fini() call pushes the buffer back into the GPU domain, which needs
> to be done for all buffers, not just the ones with CPU written content. The
> etnaviv kernel driver currently doesn't validate this, but may start to do
> so at a later point in time. If there is a temporary resource the fini needs
> to happen before the RS uses this one as the source for the upload.
> 
> Also remove an invalid comment about flushing CPU caches, cpu_fini takes
> care of everything involved in this.

Reviewed-By: Wladimir J. van der Laan 

> Fixes: c9e8b49b885 ("etnaviv: gallium driver for Vivante GPUs")
> Cc: mesa-sta...@lists.freedesktop.org
> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index 1a5aa7fc043c..4809b04ff95f 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -70,6 +70,9 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
> pipe_transfer *ptrans)
> if (rsc->texture && !etna_resource_newer(rsc, 
> etna_resource(rsc->texture)))
>rsc = etna_resource(rsc->texture); /* switch to using the texture 
> resource */
>  
> +   if (trans->rsc)
> +  etna_bo_cpu_fini(etna_resource(trans->rsc)->bo);
> +
> if (ptrans->usage & PIPE_TRANSFER_WRITE) {
>if (trans->rsc) {
>   /* We have a temporary resource due to either tile status or
> @@ -105,15 +108,15 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
> pipe_transfer *ptrans)
>}
>  
>rsc->seqno++;
> -  etna_bo_cpu_fini(rsc->bo);
>  
>if (rsc->base.bind & PIPE_BIND_SAMPLER_VIEW) {
> - /* XXX do we need to flush the CPU cache too or start a write 
> barrier
> -  * to make sure the GPU sees it? */
>   ctx->dirty |= ETNA_DIRTY_TEXTURE_CACHES;
>}
> }
>  
> +   if (!trans->rsc)
> +  etna_bo_cpu_fini(rsc->bo);
> +
> pipe_resource_reference(&trans->rsc, NULL);
> pipe_resource_reference(&ptrans->resource, NULL);
> slab_free(&ctx->transfer_pool, trans);
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] etnaviv: don't flush resource to self without TS

2017-06-06 Thread Wladimir J. van der Laan
On Tue, Jun 06, 2017 at 12:38:23PM +0200, Lucas Stach wrote:
> From: Lucas Stach 
> 
> A resolve to self is only necessary if the resource is fast cleared, so
> there is never a need to do so if there is no TS allocated.
> 
> Signed-off-by: Lucas Stach 

Does this take into account the case on GC2000, where there can be a texture 
resource
that is out of date with the rendered-to resource?

If so:
Reviewed-By: Wladimir J. van der Laan 

> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.h
> index a8d42ee1a09f..1084103386ef 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h
> @@ -102,7 +102,7 @@ etna_resource_older(struct etna_resource *a, struct 
> etna_resource *b)
>  static inline bool
>  etna_resource_needs_flush(struct etna_resource *res)
>  {
> -   return (int)(res->seqno - res->flush_seqno) > 0;
> +   return res->ts_bo && ((int)(res->seqno - res->flush_seqno) > 0);
>  }
>  
>  /* is the resource only used on the sampler? */
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/6] etnaviv: slim down resource waiting

2017-06-06 Thread Wladimir J. van der Laan
On Fri, May 19, 2017 at 11:41:08AM +0200, Lucas Stach wrote:
> cpu_prep() already does all the required waiting, so the only thing that
> needs to be done is flushing the commandstream, if a GPU write is pending.

Looks good to me.

Reviewed-By: Wladimir J. van der Laan 

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c |  5 +++--
>  src/gallium/drivers/etnaviv/etnaviv_resource.c   | 16 
>  src/gallium/drivers/etnaviv/etnaviv_resource.h   |  3 ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c   |  5 +++--
>  4 files changed, 6 insertions(+), 23 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c 
> b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> index ae1c5862880f..ea416bf192f3 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c
> @@ -528,8 +528,9 @@ etna_try_rs_blit(struct pipe_context *pctx,
>  
>  manual:
> if (src->layout == ETNA_LAYOUT_TILED && dst->layout == ETNA_LAYOUT_TILED) 
> {
> -  etna_resource_wait(pctx, dst);
> -  etna_resource_wait(pctx, src);
> +  if ((src->status & ETNA_PENDING_WRITE) ||
> +  (dst->status & ETNA_PENDING_WRITE))
> + pctx->flush(pctx, NULL, 0);
>return etna_manual_blit(dst, dst_lev, dst_offset, src, src_lev, 
> src_offset, blit_info);
> }
>  
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 1341e1ea2314..9aa1aa617a51 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -429,22 +429,6 @@ etna_resource_used(struct etna_context *ctx, struct 
> pipe_resource *prsc,
>  }
>  
>  void
> -etna_resource_wait(struct pipe_context *pctx, struct etna_resource *rsc)
> -{
> -   if (rsc->status & ETNA_PENDING_WRITE) {
> -  struct pipe_fence_handle *fence;
> -  struct pipe_screen *pscreen = pctx->screen;
> -
> -  pctx->flush(pctx, &fence, 0);
> -
> -  if (!pscreen->fence_finish(pscreen, pctx, fence, 50ULL))
> - BUG("fence timed out (hung GPU?)");
> -
> -  pscreen->fence_reference(pscreen, &fence, NULL);
> -   }
> -}
> -
> -void
>  etna_resource_screen_init(struct pipe_screen *pscreen)
>  {
> pscreen->can_create_resource = etna_screen_can_create_resource;
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h 
> b/src/gallium/drivers/etnaviv/etnaviv_resource.h
> index a8d42ee1a09f..913316f193c2 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h
> @@ -124,9 +124,6 @@ void
>  etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc,
> enum etna_resource_status status);
>  
> -void
> -etna_resource_wait(struct pipe_context *ctx, struct etna_resource *rsc);
> -
>  static inline void
>  resource_read(struct etna_context *ctx, struct pipe_resource *prsc)
>  {
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index 4809b04ff95f..269bd498f89f 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -199,8 +199,9 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
> /* Always sync if we have the temporary resource.  The PIPE_TRANSFER_READ
>  * case could be optimised if we knew whether the resource has outstanding
>  * rendering. */
> -   if (usage & PIPE_TRANSFER_READ || trans->rsc)
> -  etna_resource_wait(pctx, rsc);
> +   if ((usage & PIPE_TRANSFER_READ || trans->rsc) &&
> +   rsc->status & ETNA_PENDING_WRITE)
> +  pctx->flush(pctx, NULL, 0);
>  
> /* XXX we don't handle PIPE_TRANSFER_FLUSH_EXPLICIT; this flag can be 
> ignored
>  * when mapping in-place,
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/6] etnaviv: honor PIPE_TRANSFER_UNSYNCHRONIZED flag

2017-06-06 Thread Wladimir J. van der Laan
On Fri, May 19, 2017 at 11:41:09AM +0200, Lucas Stach wrote:
> This gets rid of quite a bit of CPU/GPU sync on frequent vertex buffer
> uploads and I haven't seen any of the issues mentioned in the comment,
> so this one seems stale.

Interesting. I don't quite remember what prompted adding this, it may have to
do with other hacks to support single-vertex-stream GPUs which have since been
removed, so it's likely stale.

In any case heeding PIPE_TRANSFER_UNSYNCHRONIZED makes sense. It should not just
be ignored because the driver thinks it knows better.

> Ignore the flag if there exists a temporary resource, as those ones are
> never busy.

OK. 

Reviewed-By: Wladimir J. van der Laan 

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 22 ++
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index 269bd498f89f..a2cd4e6234dd 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -114,7 +114,7 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
> pipe_transfer *ptrans)
>}
> }
>  
> -   if (!trans->rsc)
> +   if (!trans->rsc && !(ptrans->usage & PIPE_TRANSFER_UNSYNCHRONIZED))
>etna_bo_cpu_fini(rsc->bo);
>  
> pipe_resource_reference(&trans->rsc, NULL);
> @@ -260,19 +260,17 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
> (rsc->layout == ETNA_LAYOUT_TILED &&
>  util_format_is_compressed(prsc->format));
>  
> -   /* Ignore PIPE_TRANSFER_UNSYNCHRONIZED and PIPE_TRANSFER_DONTBLOCK here.
> -* It appears that Gallium operates the index/vertex buffers in a
> -* circular fashion, and the CPU can catch up with the GPU and starts
> -* overwriting yet-to-be-processed entries, causing rendering corruption. 
> */
> -   uint32_t prep_flags = 0;
> +   if (trans->rsc || !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
> +  uint32_t prep_flags = 0;
>  
> -   if (usage & PIPE_TRANSFER_READ)
> -  prep_flags |= DRM_ETNA_PREP_READ;
> -   if (usage & PIPE_TRANSFER_WRITE)
> -  prep_flags |= DRM_ETNA_PREP_WRITE;
> +  if (usage & PIPE_TRANSFER_READ)
> + prep_flags |= DRM_ETNA_PREP_READ;
> +  if (usage & PIPE_TRANSFER_WRITE)
> + prep_flags |= DRM_ETNA_PREP_WRITE;
>  
> -   if (etna_bo_cpu_prep(rsc->bo, prep_flags))
> -  goto fail_prep;
> +  if (etna_bo_cpu_prep(rsc->bo, prep_flags))
> + goto fail_prep;
> +   }
>  
> /* map buffer object */
> void *mapped = etna_bo_map(rsc->bo);
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/6] etnaviv: don't read back resource if transfer discards contents

2017-06-06 Thread Wladimir J. van der Laan
On Fri, May 19, 2017 at 11:41:10AM +0200, Lucas Stach wrote:
> Reduces bandwidth usage of transfers which discard the buffer contents,
> as well as skipping unnecessary command stream flushes and CPU/GPU
> synchronization.

Looks obviously correct. The contents of the temporary resource
don't matter if DISCARD_WHOLE_RESOURCE.

Reviewed-By: Wladimir J. van der Laan

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index a2cd4e6234dd..f7871f485371 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -188,7 +188,9 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
>   return NULL;
>}
>  
> -  etna_copy_resource(pctx, trans->rsc, prsc, level, 
> trans->rsc->last_level);
> +  if (!(usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE))
> + etna_copy_resource(pctx, trans->rsc, prsc, level,
> +trans->rsc->last_level);
>  
>/* Switch to using the temporary resource instead */
>rsc = etna_resource(trans->rsc);
> -- 
> 2.11.0
> 
> ___
> etnaviv mailing list
> etna...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/6] etnaviv: simplify transfer tiling handling

2017-06-06 Thread Wladimir J. van der Laan
On Fri, May 19, 2017 at 11:41:11AM +0200, Lucas Stach wrote:
> There is no need to special case compressed resources, as they are already
> marked as linear on allocation. With that out of the way, there is room to
> cut down on the number of if clauses used.

Code change looks good to me. Resource layout is explicit, and not dependent
on the compressed-ness of the texture format.

Reviewed-By: Wladimir J. van der Laan 

> Signed-off-by: Lucas Stach 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 70 
> +++---
>  1 file changed, 29 insertions(+), 41 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c 
> b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index f7871f485371..05cdbc599956 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -85,21 +85,19 @@ etna_transfer_unmap(struct pipe_context *pctx, struct 
> pipe_transfer *ptrans)
>   struct etna_resource_level *res_level = &rsc->levels[ptrans->level];
>   void *mapped = etna_bo_map(rsc->bo) + res_level->offset;
>  
> - if (rsc->layout == ETNA_LAYOUT_LINEAR || rsc->layout == 
> ETNA_LAYOUT_TILED) {
> -if (rsc->layout == ETNA_LAYOUT_TILED && 
> !util_format_is_compressed(rsc->base.format)) {
> -   etna_texture_tile(
> -  mapped + ptrans->box.z * res_level->layer_stride,
> -  trans->staging, ptrans->box.x, ptrans->box.y,
> -  res_level->stride, ptrans->box.width, ptrans->box.height,
> -  ptrans->stride, 
> util_format_get_blocksize(rsc->base.format));
> -} else { /* non-tiled or compressed format */
> -   util_copy_box(mapped, rsc->base.format, res_level->stride,
> - res_level->layer_stride, ptrans->box.x,
> - ptrans->box.y, ptrans->box.z, ptrans->box.width,
> - ptrans->box.height, ptrans->box.depth,
> - trans->staging, ptrans->stride,
> - ptrans->layer_stride, 0, 0, 0 /* src x,y,z */);
> -}

> + if (rsc->layout == ETNA_LAYOUT_TILED) {
> +etna_texture_tile(
> +   mapped + ptrans->box.z * res_level->layer_stride,
> +   trans->staging, ptrans->box.x, ptrans->box.y,
> +   res_level->stride, ptrans->box.width, ptrans->box.height,
> +   ptrans->stride, util_format_get_blocksize(rsc->base.format));
> + } else if (rsc->layout == ETNA_LAYOUT_LINEAR) {
> +util_copy_box(mapped, rsc->base.format, res_level->stride,
> +  res_level->layer_stride, ptrans->box.x,
> +  ptrans->box.y, ptrans->box.z, ptrans->box.width,
> +  ptrans->box.height, ptrans->box.depth,
> +  trans->staging, ptrans->stride,
> +  ptrans->layer_stride, 0, 0, 0 /* src x,y,z */);
>   } else {
>  BUG("unsupported tiling %i", rsc->layout);
>   }
> @@ -255,13 +253,6 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
>PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE is set.
>  */
>  
> -   /* No need to allocate a buffer for copying if the resource is not in use,
> -* and no tiling is needed, can just return a direct pointer.
> -*/
> -   bool in_place = rsc->layout == ETNA_LAYOUT_LINEAR ||
> -   (rsc->layout == ETNA_LAYOUT_TILED &&
> -util_format_is_compressed(prsc->format));
> -
> if (trans->rsc || !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
>uint32_t prep_flags = 0;
>  
> @@ -281,7 +272,7 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
>  
> *out_transfer = ptrans;
>  
> -   if (in_place) {
> +   if (rsc->layout == ETNA_LAYOUT_LINEAR) {
>ptrans->stride = res_level->stride;
>ptrans->layer_stride = res_level->layer_stride;
>  
> @@ -308,24 +299,21 @@ etna_transfer_map(struct pipe_context *pctx, struct 
> pipe_resource *prsc,
>   goto fail;
>  
>if (usage & PIPE_TRANSFER_READ) {
> - /* untile or copy resource for reading */
> - if (rsc->layout == ETNA_LAYOUT_LINEAR || rsc->layout == 
> ETNA_LAYOUT_TILED) {
> -if (rsc->layout == ETNA_LAYOUT_TILED && 
> !util_format

  1   2   3   >