Re: [Mesa-dev] [PATCH] mesa: remove remaining tabs in api_validate.c

2016-06-17 Thread Timothy Arceri
On Fri, 2016-06-17 at 16:09 +0200, ⚛ wrote:
> Hello. Are you editing those files by hand?

Recently as I've come across tabs I do a quick check to see how many
are in the file, if its not many then I remove them.

I don't think there would be much interests in doing a batch conversion
as this would just make rebasing difficult. Also sometimes a tab
doesn't always match up to 8 spaces as you would expect.

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


Re: [Mesa-dev] [PATCH] st/vdpau: use bicubic filter for scaling

2016-06-17 Thread Nayan Deshmukh
Hi Christian,

Thanks for the review.

I don't understand the compositor code fully yet. How can I create a
unscaled image with it?

Regards,
Nayan.

On Fri, Jun 17, 2016 at 9:15 PM, Christian König 
wrote:

> Really nice work. I now understand where your problem is with the scaled
> surface.
>
> Please see the further comments below.
>
>
> Am 16.06.2016 um 20:15 schrieb Nayan Deshmukh:
>
>> v2: fix a typo and add a newline to code
>>
>> Signed-off-by: Nayan Deshmukh 
>> ---
>>   src/gallium/state_trackers/vdpau/mixer.c | 53
>> +---
>>   src/gallium/state_trackers/vdpau/vdpau_private.h |  6 +++
>>   2 files changed, 54 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/gallium/state_trackers/vdpau/mixer.c
>> b/src/gallium/state_trackers/vdpau/mixer.c
>> index 65c3ce2..751c7e5 100644
>> --- a/src/gallium/state_trackers/vdpau/mixer.c
>> +++ b/src/gallium/state_trackers/vdpau/mixer.c
>> @@ -82,7 +82,6 @@ vlVdpVideoMixerCreate(VdpDevice device,
>> switch (features[i]) {
>> /* they are valid, but we doesn't support them */
>> case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
>> -  case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
>> case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
>> case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
>> case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
>> @@ -110,6 +109,9 @@ vlVdpVideoMixerCreate(VdpDevice device,
>>vmixer->luma_key.supported = true;
>>break;
>>   +  case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
>> + vmixer->bicubic.supported = true;
>> + break;
>> default: goto no_params;
>> }
>>  }
>> @@ -202,6 +204,11 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
>> vl_matrix_filter_cleanup(vmixer->sharpness.filter);
>> FREE(vmixer->sharpness.filter);
>>  }
>> +
>> +   if (vmixer->bicubic.filter) {
>> +  vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
>> +  FREE(vmixer->bicubic.filter);
>> +   }
>>  pipe_mutex_unlock(vmixer->device->mutex);
>>  DeviceReference(>device, NULL);
>>   @@ -344,7 +351,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
>>  }
>>vl_compositor_set_dst_clip(>cstate,
>> RectToPipe(destination_rect, ));
>> -   if (!vmixer->noise_reduction.filter && !vmixer->sharpness.filter)
>> +   if (!vmixer->noise_reduction.filter && !vmixer->sharpness.filter &&
>> !vmixer->bicubic.filter)
>> vlVdpSave4DelayedRendering(vmixer->device, destination_surface,
>> >cstate);
>>  else {
>> vl_compositor_render(>cstate, compositor, dst->surface,
>> >dirty_area, true);
>> @@ -359,6 +366,10 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
>> if (vmixer->sharpness.filter)
>>vl_matrix_filter_render(vmixer->sharpness.filter,
>>dst->sampler_view, dst->surface);
>> +
>> +  if (vmixer->bicubic.filter)
>> + vl_bicubic_filter_render(vmixer->bicubic.filter,
>> + dst->sampler_view, dst->surface);
>>
>
> What you do here is first using the compositor to merge and scale the
> surfaces and then apply bicubic filtering on the already scaled surface.
>
> That is rather suboptimal. It would be better to let the compositor create
> an unscaled image and then scale it using bicubic filtering.
>
> Regards,
> Christian.
>
>
>  }
>>  pipe_mutex_unlock(vmixer->device->mutex);
>>   @@ -461,6 +472,28 @@
>> vlVdpVideoMixerUpdateSharpnessFilter(vlVdpVideoMixer *vmixer)
>>   }
>> /**
>> + * Update the bicubic filter
>> + */
>> +static void
>> +vlVdpVideoMixerUpdateBicubicFilter(vlVdpVideoMixer *vmixer)
>> +{
>> +   assert(vmixer);
>> +
>> +   /* if present remove the old filter first */
>> +   if (vmixer->bicubic.filter) {
>> +  vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
>> +  FREE(vmixer->bicubic.filter);
>> +  vmixer->bicubic.filter = NULL;
>> +   }
>> +   /* and create a new filter as needed */
>> +   if (vmixer->bicubic.enabled) {
>> +  vmixer->bicubic.filter = MALLOC(sizeof(struct vl_bicubic_filter));
>> +  vl_bicubic_filter_init(vmixer->bicubic.filter,
>> vmixer->device->context,
>> +vmixer->video_width, vmixer->video_height);
>> +   }
>> +}
>> +
>> +/**
>>* Retrieve whether features were requested at creation time.
>>*/
>>   VdpStatus
>> @@ -483,7 +516,6 @@ vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
>> switch (features[i]) {
>> /* they are valid, but we doesn't support them */
>> case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
>> -  case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
>> case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
>> case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
>> case 

[Mesa-dev] [PATCH] egl: Fix the bad surface attributes combination checking for pbuffers.

2016-06-17 Thread Guillaume Charifi
Fixes a regression induced by commit a0674ce5:
When EGL_TEXTURE_FORMAT and EGL_TEXTURE_TARGET were both specified (and
both != EGL_NO_TEXTURE), an error was instantly triggered, before the
other one had even a chance to be checked, which is obviously not the
intended behaviour.

Signed-off-by: Guillaume Charifi 
---
 src/egl/main/eglsurface.c | 34 +++---
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 99e24dd..61e7d47 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -73,6 +73,8 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint 
*attrib_list)
EGLint i, err = EGL_SUCCESS;
EGLint tex_target = -1;
EGLint tex_format = -1;
+   EGLint attr = EGL_NONE;
+   EGLint val = EGL_NONE;
 
if (!attrib_list)
   return EGL_SUCCESS;
@@ -81,8 +83,8 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint 
*attrib_list)
   texture_type |= EGL_PIXMAP_BIT;
 
for (i = 0; attrib_list[i] != EGL_NONE; i++) {
-  EGLint attr = attrib_list[i++];
-  EGLint val = attrib_list[i];
+  attr = attrib_list[i++];
+  val = attrib_list[i];
 
   switch (attr) {
   /* common attributes */
@@ -235,25 +237,27 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const 
EGLint *attrib_list)
  break;
   }
 
-  if (type == EGL_PBUFFER_BIT) {
- if (tex_target == -1)
-tex_target = surf->TextureTarget;
+  if (err != EGL_SUCCESS)
+ break;
+   }
 
- if (tex_format == -1)
-tex_format = surf->TextureFormat;
+   if (err == EGL_SUCCESS && type == EGL_PBUFFER_BIT) {
+  if (tex_target == -1)
+ tex_target = surf->TextureTarget;
 
- if ((tex_target == EGL_NO_TEXTURE && tex_format != EGL_NO_TEXTURE) ||
- (tex_format == EGL_NO_TEXTURE && tex_target != EGL_NO_TEXTURE)) {
-err = EGL_BAD_MATCH;
- }
-  }
+  if (tex_format == -1)
+ tex_format = surf->TextureFormat;
 
-  if (err != EGL_SUCCESS) {
- _eglLog(_EGL_WARNING, "bad surface attribute 0x%04x", attr);
- break;
+  if ((tex_target == EGL_NO_TEXTURE && tex_format != EGL_NO_TEXTURE) ||
+  (tex_format == EGL_NO_TEXTURE && tex_target != EGL_NO_TEXTURE)) {
+ attr = tex_target == EGL_NO_TEXTURE ? EGL_TEXTURE_TARGET : 
EGL_TEXTURE_FORMAT;
+ err = EGL_BAD_MATCH;
   }
}
 
+   if (err != EGL_SUCCESS)
+  _eglLog(_EGL_WARNING, "bad surface attribute 0x%04x", attr);
+
return err;
 }
 
-- 
2.7.4

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


[Mesa-dev] [Bug 96410] [Perf] Pre validate _mesa_sampler_uniforms_pipeline_are_valid like _mesa_sampler_uniforms_are_valid

2016-06-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96410

--- Comment #2 from Timothy Arceri  ---
(In reply to gregory.hainaut from comment #1)
> Currently looking at the code of single program flow namely
> _mesa_update_shader_textures_used
> 
> The current check fails to detect wrongly reused sampler in multiple shader
> stage. The spec seems to imply that is must be checked in the full program
> (all stages).
> 
> <<
>  Errors
>   It is not allowed to have variables of different sampler types pointing to
>   the same texture image unit within a program object. This situation can
> only
>   be detected at the next rendering command issued which triggers shader
> invo-
>   cations, and an INVALID_OPERATION error will then be generated.
> >>
> 
> Here a typical example of an invalid program that will wrongly run fine.
> 
> * Vertex Shader
> layout(binding = 0) uniform sampler1D sampler_1d;
> 
> * Fragment Shader
> layout(binding = 0) uniform sampler2D sampler_2d;

See the FIXME I added when I mostly fixed this a while ago:
https://cgit.freedesktop.org/mesa/mesa/tree/src/mesa/main/uniform_query.cpp#n1095

The problem is the spec requires samplers to default to 0. So unless we manage
to eliminate everything that is unused (including early array elements) we will
likely trigger errors in programs that run fine elsewhere (since last time I
checked Nvidia doesn't do this validation at all)

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 15/64] isl/state: Return an extent3d from the halign/valign helper

2016-06-17 Thread Jason Ekstrand
On Thu, Jun 16, 2016 at 10:57 AM, Chad Versace 
wrote:

> On Thu 16 Jun 2016, Jason Ekstrand wrote:
> > On Thu, Jun 16, 2016 at 10:39 AM, Chad Versace 
> > wrote:
> >
> > > On Sat 11 Jun 2016, Jason Ekstrand wrote:
> > > > ---
> > > >  src/intel/isl/isl_surface_state.c | 28 
> > > >  1 file changed, 8 insertions(+), 20 deletions(-)
> > > >
> > > > diff --git a/src/intel/isl/isl_surface_state.c
> > > b/src/intel/isl/isl_surface_state.c
> > > > index 50570aa..1e94e60 100644
> > > > --- a/src/intel/isl/isl_surface_state.c
> > > > +++ b/src/intel/isl/isl_surface_state.c
> > > > @@ -110,9 +110,8 @@ get_surftype(enum isl_surf_dim dim,
> > > isl_surf_usage_flags_t usage)
> > > >  /*
> > > >   * Get the values to pack into
> > > RENDER_SUFFACE_STATE.SurfaceHorizontalAlignment
> > > >   * and SurfaceVerticalAlignment.
> > > >   */
> > > > -static void
> > > > -get_halign_valign(const struct isl_surf *surf,
> > > > -  uint32_t *halign, uint32_t *valign)
> > > > +static struct isl_extent3d
> > > > +get_image_alignment(const struct isl_surf *surf)
> > >
> > >
> > > The function comment is incorrect post-patch. It should say something
> to
> > > the tune of "Returns indices into isl_to_gen_halign,
> isl_to_gen_valign".
> > > Specifically, the function comment needs to clarify (with as few words
> > > as possible) that the units of the returned extent is neither samples,
> > > pixels, nor elements, but something entirely different--array indices--
> > > because it's not really an extent at all.
> > >
> >
> > Right.  It's the "logical" halign/valign values not the actual hardware
> > enums.
>
> But even the term "logical values" is overly ambiguous. Logical values
> of *what*? On some gens, the returned value is in units of surface
> samples; other gens, surface elements. So, in effect, the returned value
> is a *unitless* array index.
>

I've updated the comment to the following:

Get the horizontal and vertical alignment in the units expected by the
hardware.  Note that this does NOT give you the actual hardware enum values
but an index into the isl_to_gen_[hv]align arrays above.

I use the term "units expected by the hardware" because they are integer
values and a unit conversion is involved in their evaluation.  I was
careful, however, to not exactly how they should be used.  Good enough?

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


Re: [Mesa-dev] [PATCH 08/64] i965/blorp: Only set src_z for gen8+ 3D textures

2016-06-17 Thread Jason Ekstrand
On Thu, Jun 16, 2016 at 10:08 AM, Chad Versace 
wrote:

> On Sat 11 Jun 2016, Jason Ekstrand wrote:
> > Otherwise, we end up with a bogus value in the third component.  On
> gen6-7
> > where we always use 2D textures, this can cause problems if the
> > SurfaceArray bit is set in the SURFACE_STATE.
>
> Enlighten me. Why does blorp use 3D surfaces on gen >= 8 but not
> earlier?
>

History?  TBH, I'm not really sure.  Probably because SKL 3-D is different
but you'd have to ask topi to be sure.


>
> > ---
> >  src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 11 +--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> > index 782d285..cdb6b33 100644
> > --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> > +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> > @@ -1846,8 +1846,15 @@ brw_blorp_blit_miptrees(struct brw_context *brw,
> > brw_blorp_setup_coord_transform(_push_consts.y_transform,
> > src_y0, src_y1, dst_y0, dst_y1,
> mirror_y);
> >
> > -   params.wm_push_consts.src_z =
> > -  params.src.mt->target == GL_TEXTURE_3D ? params.src.layer : 0;
> > +   if (brw->gen >= 8 && params.src.mt->target == GL_TEXTURE_3D) {
> > +  /* On gen8+ we use actual 3-D textures so we need to pass the
> layer
> > +   * through to the sampler.
> > +   */
> > +  params.wm_push_consts.src_z = params.src.layer;
> > +   } else {
> > +  /* On gen7 and earlier, we fake everything with 2-D textures */
> > +  params.wm_push_consts.src_z = 0;
> > +   }
> >
> > if (params.dst.num_samples <= 1 && dst_mt->num_samples > 1) {
> >/* We must expand the rectangle we send through the rendering
> pipeline,
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: Export all GLES 3.1 functions in libGLESv2.so

2016-06-17 Thread Kenneth Graunke
On Friday, June 17, 2016 5:58:21 PM PDT Ilia Mirkin wrote:
> On Fri, Jun 17, 2016 at 5:48 PM, Emil Velikov  
> wrote:
> > On 17 June 2016 at 22:22, Jason Ekstrand  wrote:
> >> On Fri, Jun 17, 2016 at 2:09 PM, Emil Velikov 
> >> wrote:
> >>>
> >>> On 17 June 2016 at 21:12, Mike Gorchak  wrote:
> >>> > Please understand me right, we are not talking about desktop hardware
> >>> > and
> >>> > libraries, only about embedded in case of GL ES.
> >>> GLES hasn't been "embedded only" for a while I believe.
> >>
> >>
> >> No, but Mike is 100% correct that looking at AMD and NVIDIA isn't 
> >> sufficient
> >> in the gles case.  AMD doesn't matter (they don't do GLES) and NVIDIA is
> >> only one vendor.  If the majority of *other* vendors (and there are a lot 
> >> of
> >> them) export the symbols, that does mean something.
> >>
> > My ideas are the following:
> >  - First and foremost: Can we make things saner/more robust or is it
> > too late [since most vendors are exporting the symbols] ?
> >  - Can we confirm that's the case for Linux platforms ?
> >
> > I'm not trying to start a fight here, but to point out that
> > "everybody's doing it" type of argument does not mean that "it" is a
> > wise idea. IMHO one should establish exactly who "everybody" is (both
> > vendors and platforms), consider for the consequences and then make a
> > decision.
> 
> I don't think Emil has said this explicitly, and I don't want to put
> words into his mouth, but at least I think it sucks to have this
> non-fixed ABI for libGLESv2.so, which is otherwise (effectively)
> unversioned. Perhaps we can version it like have a libGLESv2.so.3.1.0
> or whatever which will have the ABI required for GLES 3.1, and
> libGLESv2.so.3.0.0 which has the ABI required for GLES 3.0 (and
> libGLESv2.so.2.0.0 which has the GLES 2.0 symbols).

IIRC, this is similar to what we'd discussed for the new OpenGL ABI
as well.  The new libOpenGL.so would expose all symbols from core
OpenGL versions without the need for GetProcAddress.  Extensions
would still be supported via GetProcAddress.

I believe we were going to bump the .so number for major GL versions,
i.e.  libOpenGL.so.4.5 would expose the entry points for GL 4.5.  But
I might be mistaken about that.

> But then what does mesa generate? Do freedreno, which supports GLES
> 3.0, and vc4, which supports GLES 2.0, ship a libGLESv2.so.3.1.0
> because that's what core mesa supports? I guess that's not the end of
> the world.

Exactly.  It just means that the dispatch layer is hooked up and you
have the entry points.  It doesn't mean that the driver necessarily
supports all functionality (it may just INVALID_OPERATION at you).

> But of course then people who linked against libGLESv2.so.2 which is
> what we ship now will be in trouble...

That might be a problem.  I'll gladly defer to distro people who are
much more experienced with this than I am.

> Not sure what the right answer is, but IMHO this merits a discussion.
> 
>   -ilia

Another point: in GL, the ABI said to only expose a small set of
functionality, and use GetProcAddress for the rest.  We accidentally
exposed far too much, and other vendors did likewise.  So we opted
not to retract that functionality to avoid breaking things just to
follow the spec.

Here, the ES ABI is clear that we should expose /more/ than we have
been.  There are other shipping implementations, and Mike's emails
suggest that people generally expect this.  I think we need to follow
the spec.  There are plenty of cases where I think GL specs are crazy,
and would love to change them, but I don't always get to do that.

--Ken


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 05/14] swr: [rasterizer jitter] cleanup supporting different llvm versions

2016-06-17 Thread Rowley, Timothy O
Looks like some major rework of this commit is in order; I’ll get on it.

> On Jun 17, 2016, at 3:36 PM, Emil Velikov  wrote:
> 
> Hi Tim,
> 
> Does this commit allows us to have generic generated files or it's
> solely workaround the VPERMD intrinsic argument swap ?

Since the arguments are both llvm::Value*, either version of the generated 
files would work.  See further discussion later on...

> 
> On 17 June 2016 at 20:25, Tim Rowley  wrote:
> 
>> @@ -31,8 +31,8 @@
>> #pragma warning(disable: 4800 4146 4244 4267 4355 4996)
>> #endif
>> 
>> -#include "jit_api.h"
>> #include "JitManager.h"
>> +#include "jit_api.h"
>> #include "fetch_jit.h"
>> 
> Is this due to the DEBUG redefinition ? One might want to add a
> comment, to prevent the next person from moving/breaking things.

Someone’s independent discovery of the DEBUG issue, I think.

> 
>> @@ -222,35 +222,6 @@ void JitManager::SetupNewModule()
>> mIsModuleFinalized = false;
>> }
>> 
>> -//
>> -/// @brief Create new LLVM module from IR.
>> -bool JitManager::SetupModuleFromIR(const uint8_t *pIR)
>> -{
>> -std::unique_ptr pMem = 
>> MemoryBuffer::getMemBuffer(StringRef((const char*)pIR), "");
>> -
>> -SMDiagnostic Err;
>> -std::unique_ptr newModule = 
>> parseIR(pMem.get()->getMemBufferRef(), Err, mContext);
>> -
>> -if (newModule == nullptr)
>> -{
>> -SWR_ASSERT(0, "Parse failed! Check Err for details.");
>> -return false;
>> -}
>> -
>> -mpCurrentModule = newModule.get();
>> -#if defined(_WIN32)
>> -// Needed for MCJIT on windows
>> -Triple hostTriple(sys::getProcessTriple());
>> -hostTriple.setObjectFormat(Triple::ELF);
>> -newModule->setTargetTriple(hostTriple.getTriple());
>> -#endif // _WIN32
>> -
>> -mpExec->addModule(std::move(newModule));
>> -mIsModuleFinalized = false;
>> -
>> -return true;
>> -}
>> -
>> 
> This (and the respective prototype) seems to be completely unrelated cleanup.

This method had a change which wasn’t building, but as it was unused code it 
seemed simpler to just drop it.

>> -#if HAVE_LLVM == 0x306
>> +#if HAVE_LLVM <= 0x306
> SWR requires LLVM 3.6 so all of these changes are not needed.

Fair point.

>> // llvm 3.7+ reuses "DEBUG" as an enum value
>> +#if defined(DEBUG)
>> #pragma push_macro("DEBUG")
>> #undef DEBUG
>> +#define _DEBUG_COLLISSION
>> +#endif // DEBUG
>> 
> I believe Jose mentioned a slightly better way to handle this (see
> src/gallium/auxiliary/gallivm/lp_bld_misc.cpp). Or that does not apply
> here ? Also it would be nice to keep it a separate patch as you did
> earlier.

Will clean up.

>> #ifndef HAVE_LLVM
>> -#define HAVE_LLVM (LLVM_VERSION_MAJOR << 8) || LLVM_VERSION_MINOR
>> +#define HAVE_LLVM ((LLVM_VERSION_MAJOR << 8) | LLVM_VERSION_MINOR)
>> #endif
>> 
> Unrelated bugfix, stable material.

Doesn’t affect Mesa as the build system defines HAVE_LLVM.  But definitely a 
“whoops” to fix.

>> @@ -322,6 +322,32 @@ CallInst *Builder::CALL(Value *Callee, const 
>> std::initializer_list 
>> return CALLA(Callee, args);
>> }
>> 
>> +#if HAVE_LLVM > 0x306
>> +CallInst *Builder::CALL(Value *Callee, Value* arg)
>> +{
>> +   std::vector args;
>> +   args.push_back(arg);
>> +   return CALLA(Callee, args);
>> +}
>> +
>> +CallInst *Builder::CALL2(Value *Callee, Value* arg1, Value* arg2)
>> +{
>> +   std::vector args;
>> +   args.push_back(arg1);
>> +   args.push_back(arg2);
>> +   return CALLA(Callee, args);
>> +}
>> +
>> +CallInst *Builder::CALL3(Value *Callee, Value* arg1, Value* arg2, Value* 
>> arg3)
>> +{
>> +   std::vector args;
>> +   args.push_back(arg1);
>> +   args.push_back(arg2);
>> +   args.push_back(arg3);
>> +   return CALLA(Callee, args);
>> +}
>> +#endif
>> +
> These seem unused ?

Here I have to give the answer you hate: unused by the public rasterizer, used 
by some internal code.  These seemed small enough generic helper methods that 
might have future use by us as well that I thought it simpler to leave them in.

>> @@ -726,8 +752,12 @@ Value *Builder::PERMD(Value* a, Value* idx)
>> // use avx2 permute instruction if available
>> if(JM()->mArch.AVX2())
>> {
>> -// llvm 3.6.0 swapped the order of the args to vpermd
>> -res = VPERMD(idx, a);
>> +#if (HAVE_LLVM == 0x306) && (LLVM_VERSION_PATCH == 0)
>> +   // llvm 3.6.0 swapped the order of the args to vpermd
>> +   res = VPERMD(idx, a);
>> +#else
>> +   res = VPERMD(a, idx);
>> +#endif
> Something feels rather fishy here -  atm generator was always creates
> one 'version' of the intrinsic and the code directly uses is.
> 
> With this patch (taking that I understood the python script correctly):
> - Here we swap the order depending of the LLVM used to compile SWR
> - In the generator (below) we also swap 

[Mesa-dev] [PATCH] vc4: add hash table look-up for exported dmabufs

2016-06-17 Thread Rob Herring
It is necessary to reuse existing BOs when dmabufs are imported. There
are 2 cases that need to be handled. dmabufs can be created/exported and
imported by the same process and can be imported multiple times.
Copying other drivers, add a hash table to track exported BOs so the
BOs get reused.

Cc: Eric Anholt 
Signed-off-by: Rob Herring 
---
With this and the fd hashing to get a single screen, the flickery screen 
is gone and Android is somewhat working. Several apps though hang, don't 
render, and then exit. I also see CMA allocation errors, but not 
correlating to the app problems.

Also, flink names need similar hash table look-up as well. Maybe that's 
a don't care for vc4? In any case, I don't have the setup to test that.

Rob

 src/gallium/drivers/vc4/vc4_bufmgr.c | 20 +++-
 src/gallium/drivers/vc4/vc4_bufmgr.h | 12 +++-
 src/gallium/drivers/vc4/vc4_screen.c | 15 +++
 src/gallium/drivers/vc4/vc4_screen.h |  3 +++
 4 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c 
b/src/gallium/drivers/vc4/vc4_bufmgr.c
index 21e3bde..d91157b 100644
--- a/src/gallium/drivers/vc4/vc4_bufmgr.c
+++ b/src/gallium/drivers/vc4/vc4_bufmgr.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 
+#include "util/u_hash_table.h"
 #include "util/u_memory.h"
 #include "util/ralloc.h"
 
@@ -329,10 +330,19 @@ vc4_bo_open_handle(struct vc4_screen *screen,
uint32_t winsys_stride,
uint32_t handle, uint32_t size)
 {
-struct vc4_bo *bo = CALLOC_STRUCT(vc4_bo);
+struct vc4_bo *bo;
 
 assert(size);
 
+pipe_mutex_lock(screen->bo_handles_mutex);
+
+bo = util_hash_table_get(screen->bo_handles, (void*)(uintptr_t)handle);
+if (bo) {
+pipe_reference(NULL, >reference);
+goto done;
+}
+
+bo = CALLOC_STRUCT(vc4_bo);
 pipe_reference_init(>reference, 1);
 bo->screen = screen;
 bo->handle = handle;
@@ -347,6 +357,10 @@ vc4_bo_open_handle(struct vc4_screen *screen,
 bo->map = malloc(bo->size);
 #endif
 
+util_hash_table_set(screen->bo_handles, (void *)(uintptr_t)handle, bo);
+
+done:
+pipe_mutex_unlock(screen->bo_handles_mutex);
 return bo;
 }
 
@@ -401,6 +415,10 @@ vc4_bo_get_dmabuf(struct vc4_bo *bo)
 }
 bo->private = false;
 
+pipe_mutex_lock(bo->screen->bo_handles_mutex);
+util_hash_table_set(bo->screen->bo_handles, (void 
*)(uintptr_t)bo->handle, bo);
+pipe_mutex_unlock(bo->screen->bo_handles_mutex);
+
 return fd;
 }
 
diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.h 
b/src/gallium/drivers/vc4/vc4_bufmgr.h
index b77506e..0896b30 100644
--- a/src/gallium/drivers/vc4/vc4_bufmgr.h
+++ b/src/gallium/drivers/vc4/vc4_bufmgr.h
@@ -25,6 +25,7 @@
 #define VC4_BUFMGR_H
 
 #include 
+#include "util/u_hash_table.h"
 #include "util/u_inlines.h"
 #include "vc4_qir.h"
 
@@ -87,11 +88,20 @@ vc4_bo_reference(struct vc4_bo *bo)
 static inline void
 vc4_bo_unreference(struct vc4_bo **bo)
 {
+struct vc4_screen *screen;
 if (!*bo)
 return;
 
-if (pipe_reference(&(*bo)->reference, NULL))
+screen = (*bo)->screen;
+pipe_mutex_lock(screen->bo_handles_mutex);
+
+if (pipe_reference(&(*bo)->reference, NULL)) {
 vc4_bo_last_unreference(*bo);
+util_hash_table_remove(screen->bo_handles,
+   (void *)(uintptr_t)(*bo)->handle);
+}
+
+pipe_mutex_unlock(screen->bo_handles_mutex);
 *bo = NULL;
 }
 
diff --git a/src/gallium/drivers/vc4/vc4_screen.c 
b/src/gallium/drivers/vc4/vc4_screen.c
index ecc797c..d97dbee 100644
--- a/src/gallium/drivers/vc4/vc4_screen.c
+++ b/src/gallium/drivers/vc4/vc4_screen.c
@@ -30,6 +30,7 @@
 #include "util/u_debug.h"
 #include "util/u_memory.h"
 #include "util/u_format.h"
+#include "util/u_hash_table.h"
 #include "util/ralloc.h"
 
 #include "vc4_screen.h"
@@ -489,6 +490,18 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen,
 return retval == usage;
 }
 
+#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
+
+static unsigned handle_hash(void *key)
+{
+return PTR_TO_UINT(key);
+}
+
+static int handle_compare(void *key1, void *key2)
+{
+return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
+}
+
 struct pipe_screen *
 vc4_screen_create(int fd)
 {
@@ -506,6 +519,8 @@ vc4_screen_create(int fd)
 
 screen->fd = fd;
 list_inithead(>bo_cache.time_list);
+pipe_mutex_init(screen->bo_handles_mutex);
+screen->bo_handles = util_hash_table_create(handle_hash, 
handle_compare);
 
 vc4_fence_init(screen);
 
diff --git a/src/gallium/drivers/vc4/vc4_screen.h 
b/src/gallium/drivers/vc4/vc4_screen.h
index 03f76b2..281d254 100644
--- a/src/gallium/drivers/vc4/vc4_screen.h
+++ b/src/gallium/drivers/vc4/vc4_screen.h
@@ -73,6 

[Mesa-dev] [PATCH] virgl: add exported dmabuf to BO hash table

2016-06-17 Thread Rob Herring
Exported dmabufs can get imported by the same process, but the handle was
not getting added to the hash table on export. Add the handle to the hash
table on export.

Cc: Dave Airlie 
Signed-off-by: Rob Herring 
---
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c 
b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index cbd416c..8336a33 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -486,6 +486,9 @@ static boolean virgl_drm_winsys_resource_get_handle(struct 
virgl_winsys *qws,
} else if (whandle->type == DRM_API_HANDLE_TYPE_FD) {
   if (drmPrimeHandleToFD(qdws->fd, res->bo_handle, DRM_CLOEXEC, 
(int*)>handle))
 return FALSE;
+  pipe_mutex_lock(qdws->bo_handles_mutex);
+  util_hash_table_set(qdws->bo_handles, (void *)(uintptr_t)res->bo_handle, 
res);
+  pipe_mutex_unlock(qdws->bo_handles_mutex);
}
whandle->stride = stride;
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] [PATCH 02/11] nir: Add a pass for propagating invariant decorations

2016-06-17 Thread Kenneth Graunke
On Friday, June 17, 2016 1:53:19 PM PDT Jason Ekstrand wrote:
> This pass is similar to propagate_invariance in the GLSL compiler.  The
> real "output" of this pass is that any algebraic operations which are
> eventually consumed by an invariant variable get marked as "exact".
> 
> Signed-off-by: Jason Ekstrand 
> Cc: "12.0" 
> Cc: Kenneth Graunke 

Patches 2-8 are:
Reviewed-by: Kenneth Graunke 


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: Export all GLES 3.1 functions in libGLESv2.so

2016-06-17 Thread Ilia Mirkin
On Fri, Jun 17, 2016 at 5:48 PM, Emil Velikov  wrote:
> On 17 June 2016 at 22:22, Jason Ekstrand  wrote:
>> On Fri, Jun 17, 2016 at 2:09 PM, Emil Velikov 
>> wrote:
>>>
>>> On 17 June 2016 at 21:12, Mike Gorchak  wrote:
>>> > Please understand me right, we are not talking about desktop hardware
>>> > and
>>> > libraries, only about embedded in case of GL ES.
>>> GLES hasn't been "embedded only" for a while I believe.
>>
>>
>> No, but Mike is 100% correct that looking at AMD and NVIDIA isn't sufficient
>> in the gles case.  AMD doesn't matter (they don't do GLES) and NVIDIA is
>> only one vendor.  If the majority of *other* vendors (and there are a lot of
>> them) export the symbols, that does mean something.
>>
> My ideas are the following:
>  - First and foremost: Can we make things saner/more robust or is it
> too late [since most vendors are exporting the symbols] ?
>  - Can we confirm that's the case for Linux platforms ?
>
> I'm not trying to start a fight here, but to point out that
> "everybody's doing it" type of argument does not mean that "it" is a
> wise idea. IMHO one should establish exactly who "everybody" is (both
> vendors and platforms), consider for the consequences and then make a
> decision.

I don't think Emil has said this explicitly, and I don't want to put
words into his mouth, but at least I think it sucks to have this
non-fixed ABI for libGLESv2.so, which is otherwise (effectively)
unversioned. Perhaps we can version it like have a libGLESv2.so.3.1.0
or whatever which will have the ABI required for GLES 3.1, and
libGLESv2.so.3.0.0 which has the ABI required for GLES 3.0 (and
libGLESv2.so.2.0.0 which has the GLES 2.0 symbols).

But then what does mesa generate? Do freedreno, which supports GLES
3.0, and vc4, which supports GLES 2.0, ship a libGLESv2.so.3.1.0
because that's what core mesa supports? I guess that's not the end of
the world.

But of course then people who linked against libGLESv2.so.2 which is
what we ship now will be in trouble...

Not sure what the right answer is, but IMHO this merits a discussion.

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


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: Export all GLES 3.1 functions in libGLESv2.so

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 22:22, Jason Ekstrand  wrote:
> On Fri, Jun 17, 2016 at 2:09 PM, Emil Velikov 
> wrote:
>>
>> On 17 June 2016 at 21:12, Mike Gorchak  wrote:
>> > Please understand me right, we are not talking about desktop hardware
>> > and
>> > libraries, only about embedded in case of GL ES.
>> GLES hasn't been "embedded only" for a while I believe.
>
>
> No, but Mike is 100% correct that looking at AMD and NVIDIA isn't sufficient
> in the gles case.  AMD doesn't matter (they don't do GLES) and NVIDIA is
> only one vendor.  If the majority of *other* vendors (and there are a lot of
> them) export the symbols, that does mean something.
>
My ideas are the following:
 - First and foremost: Can we make things saner/more robust or is it
too late [since most vendors are exporting the symbols] ?
 - Can we confirm that's the case for Linux platforms ?

I'm not trying to start a fight here, but to point out that
"everybody's doing it" type of argument does not mean that "it" is a
wise idea. IMHO one should establish exactly who "everybody" is (both
vendors and platforms), consider for the consequences and then make a
decision.

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


Re: [Mesa-dev] [PATCH 01/11] anv: Add support for INTEL_DEBUG=sync, state

2016-06-17 Thread Kenneth Graunke
On Friday, June 17, 2016 1:53:18 PM PDT Jason Ekstrand wrote:
> Signed-off-by: Jason Ekstrand 
> Cc: "12.0" 
> ---
>  src/intel/vulkan/gen8_cmd_buffer.c | 9 +
>  src/intel/vulkan/genX_cmd_buffer.c | 9 +
>  2 files changed, 18 insertions(+)
> 
> diff --git a/src/intel/vulkan/gen8_cmd_buffer.c 
> b/src/intel/vulkan/gen8_cmd_buffer.c
> index df4036a..2600615 100644
> --- a/src/intel/vulkan/gen8_cmd_buffer.c
> +++ b/src/intel/vulkan/gen8_cmd_buffer.c
> @@ -365,6 +365,15 @@ genX(cmd_buffer_flush_compute_state)(struct 
> anv_cmd_buffer *cmd_buffer)
>  
> assert(pipeline->active_stages == VK_SHADER_STAGE_COMPUTE_BIT);
>  
> +   if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
> +  cmd_buffer->state.pending_pipe_bits =
> + ANV_PIPE_FLUSH_BITS | ANV_PIPE_INVALIDATE_BITS | 
> ANV_PIPE_CS_STALL_BIT;
> +   }
> +
> +   if (unlikely(INTEL_DEBUG & DEBUG_STATE)) {
> +  cmd_buffer->state.dirty = ~0;
> +   }
> +
> genX(cmd_buffer_config_l3)(cmd_buffer, pipeline);
>  
> genX(flush_pipeline_select_gpgpu)(cmd_buffer);
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
> b/src/intel/vulkan/genX_cmd_buffer.c
> index d9acf58..10ed73a 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -417,6 +417,15 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer 
> *cmd_buffer)
>  
> assert((pipeline->active_stages & VK_SHADER_STAGE_COMPUTE_BIT) == 0);
>  
> +   if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
> +  cmd_buffer->state.pending_pipe_bits =
> + ANV_PIPE_FLUSH_BITS | ANV_PIPE_INVALIDATE_BITS | 
> ANV_PIPE_CS_STALL_BIT;
> +   }
> +
> +   if (unlikely(INTEL_DEBUG & DEBUG_STATE)) {
> +  cmd_buffer->state.dirty = ~0;
> +   }
> +
> genX(cmd_buffer_config_l3)(cmd_buffer, pipeline);
>  
> genX(flush_pipeline_select_3d)(cmd_buffer);
> 

NAK.  This reuses established INTEL_DEBUG environment variable flags
but has a completely different meaning for both of them.

In i965, INTEL_DEBUG=sync means: when you flush a batchbuffer and submit
it to the GPU...use i915_gem_object_wait_rendering() to stall until the
GPU has completely finished that batchbuffer's rendering.  Only then
will it return from the glDrawFoo() API call.

This seems more like always_flush_cache=true, which is a driconf option
for some reason.  I don't know why that's a driconf option, as we'd
never want to set it in /etc/drirc.  I suppose we could change that.

In i965, INTEL_DEBUG=state means: periodically print out statistics
about how frequently state is dirtied, i.e.

0x0020:  429 (BRW_NEW_SURFACES) 
0x0040:  429 (BRW_NEW_BINDING_TABLE_POINTERS)   
0x0080:  572 (BRW_NEW_INDICES)  
0x0100:  572 (BRW_NEW_VERTICES) 
0x0400:   48 (BRW_NEW_BATCH)

I am definitely a fan of creating an INTEL_DEBUG option for "re-emit all
state"...I've wanted one of those in the i965 driver too.  (Our code for
this is just an if (0) currently.)  Perhaps INTEL_DEBUG=reemit?


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: Export all GLES 3.1 functions in libGLESv2.so

2016-06-17 Thread Jason Ekstrand
On Fri, Jun 17, 2016 at 2:09 PM, Emil Velikov 
wrote:

> On 17 June 2016 at 21:12, Mike Gorchak  wrote:
> > Please understand me right, we are not talking about desktop hardware and
> > libraries, only about embedded in case of GL ES.
> GLES hasn't been "embedded only" for a while I believe.
>

No, but Mike is 100% correct that looking at AMD and NVIDIA isn't
sufficient in the gles case.  AMD doesn't matter (they don't do GLES) and
NVIDIA is only one vendor.  If the majority of *other* vendors (and there
are a lot of them) export the symbols, that does mean something.


>
> > What's common for desktop
> > usually uncommon for embedded and vice versa.
> True. And dare I say it, the embedded world tends to have more and
> nastier hacks than the desktop one :-P
>
> > We are currently ship
> > libraries from many silicon vendors: Imagination RGX, Mali, Vivante,
> nVidia
> > - all have GLES 3.1 and 3.2 functions in libGLESv2.so .
> >
> Quick look for 'we' shows QNX (in case someone like myself is wondering).
>
> Hmm looking at the Mali one makes me uneasy - singe binary that
> provides the OpenCL, EGL GBM, wayland-egl and OpenGLES* APIs.
> 
> Let's not forget that much needed symbols such as ConvertUTF8toUTF16
> (+ friends) and abstraction layers around dl, sem, mutex, sync_object,
> and threads must also be exported.
> 
>
> Would be great if we get another confirmation if other vendors have
> butchered it so nicely. I believe there's a sound logic behind my
> suggestion, but if the cat is out of the bag (sort of speak) and we
> cannot do anything mitigate things so be it.
>
> Regards,
> Emil
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glcpp: Only expose ARB_enhanced_layouts if it's supported.

2016-06-17 Thread Dylan Baker
Quoting Jason Ekstrand (2016-06-17 11:15:54)
> 
> On Jun 17, 2016 11:07 AM, "Dylan Baker"  wrote:
> >
> > Quoting Ian Romanick (2016-06-16 20:07:14)
> > > This patch is
> > >
> > > Reviewed-by: Ian Romanick 
> > >
> > > On 06/16/2016 06:15 PM, Dylan Baker wrote:
> > > > This fixes the following piglit tests:
> > > > spec/arb_enhanced_layouts/preprocessor/disabled-defined-core.*
> > > >
> > > > Signed-off-by: Dylan Baker 
> > > > ---
> > > >  src/compiler/glsl/glcpp/glcpp-parse.y | 4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/
> glcpp/glcpp-parse.y
> > > > index 2cfa6a6..76cba07 100644
> > > > --- a/src/compiler/glsl/glcpp/glcpp-parse.y
> > > > +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
> > > > @@ -2338,12 +2338,14 @@ _glcpp_parser_handle_version_declaration
> (glcpp_parser_t *parser, intmax_t versio
> > > >        }
> > > >     } else {
> > > >        add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
> > > > -      add_builtin_define(parser, "GL_ARB_enhanced_layouts", 1);
> > > >        add_builtin_define(parser, "GL_ARB_separate_shader_objects", 1);
> > > >        add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
> > > >        add_builtin_define(parser, "GL_AMD_shader_trinary_minmax", 1);
> > > >
> > > >        if (extensions != NULL) {
> > > > +         if (extensions->ARB_enhanced_layouts)
> > > > +             add_builtin_define(parser, "GL_ARB_enhanced_layouts", 1);
> > > > +
> > > >           if (extensions->EXT_texture_array)
> > > >              add_builtin_define(parser, "GL_EXT_texture_array", 1);
> > > >
> > >
> >
> > I don't have commit access, would you mind pushing this for me too?
> 
> You have 37 patches in Mesa. Probably time to apply for commit access.
> 
> > Dylan
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
> 

Okay, bug filed: https://bugs.freedesktop.org/show_bug.cgi?id=96566


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


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: Export all GLES 3.1 functions in libGLESv2.so

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 21:12, Mike Gorchak  wrote:
> Please understand me right, we are not talking about desktop hardware and
> libraries, only about embedded in case of GL ES.
GLES hasn't been "embedded only" for a while I believe.

> What's common for desktop
> usually uncommon for embedded and vice versa.
True. And dare I say it, the embedded world tends to have more and
nastier hacks than the desktop one :-P

> We are currently ship
> libraries from many silicon vendors: Imagination RGX, Mali, Vivante, nVidia
> - all have GLES 3.1 and 3.2 functions in libGLESv2.so .
>
Quick look for 'we' shows QNX (in case someone like myself is wondering).

Hmm looking at the Mali one makes me uneasy - singe binary that
provides the OpenCL, EGL GBM, wayland-egl and OpenGLES* APIs.

Let's not forget that much needed symbols such as ConvertUTF8toUTF16
(+ friends) and abstraction layers around dl, sem, mutex, sync_object,
and threads must also be exported.


Would be great if we get another confirmation if other vendors have
butchered it so nicely. I believe there's a sound logic behind my
suggestion, but if the cat is out of the bag (sort of speak) and we
cannot do anything mitigate things so be it.

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


[Mesa-dev] [PATCH 04/11] anv/pipeline: Do invariance propagation on SPIR-V shaders

2016-06-17 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
Cc: Kenneth Graunke 
---
 src/intel/vulkan/anv_pipeline.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index b41e11e..1c54081 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -165,6 +165,9 @@ anv_shader_compile_to_nir(struct anv_device *device,
   nir_remove_dead_variables(nir, nir_var_system_value);
   nir_validate_shader(nir);
 
+  nir_propagate_invariant(nir);
+  nir_validate_shader(nir);
+
   nir_lower_io_to_temporaries(entry_point->shader, entry_point, true, 
false);
 
   nir_lower_system_values(nir);
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 08/11] anv: Add proper support for depth clamping

2016-06-17 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
Cc: Kenneth Graunke 
---
 src/intel/vulkan/anv_device.c  | 2 +-
 src/intel/vulkan/anv_meta_clear.c  | 1 +
 src/intel/vulkan/anv_pipeline.c| 2 ++
 src/intel/vulkan/anv_private.h | 5 -
 src/intel/vulkan/gen7_pipeline.c   | 1 +
 src/intel/vulkan/gen8_cmd_buffer.c | 7 ---
 src/intel/vulkan/gen8_pipeline.c   | 6 +++---
 src/intel/vulkan/genX_cmd_buffer.c | 8 ++--
 8 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index f864248..97300c3 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -380,7 +380,7 @@ void anv_GetPhysicalDeviceFeatures(
   .logicOp  = true,
   .multiDrawIndirect= false,
   .drawIndirectFirstInstance= false,
-  .depthClamp   = false,
+  .depthClamp   = true,
   .depthBiasClamp   = false,
   .fillModeNonSolid = true,
   .depthBounds  = false,
diff --git a/src/intel/vulkan/anv_meta_clear.c 
b/src/intel/vulkan/anv_meta_clear.c
index fe750c8..7ec0608 100644
--- a/src/intel/vulkan/anv_meta_clear.c
+++ b/src/intel/vulkan/anv_meta_clear.c
@@ -173,6 +173,7 @@ create_pipeline(struct anv_device *device,
 .cullMode = VK_CULL_MODE_NONE,
 .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE,
 .depthBiasEnable = false,
+.depthClampEnable = true,
  },
  .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
 .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 1c54081..295b48c 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1165,6 +1165,8 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
pipeline->batch.relocs = >batch_relocs;
 
copy_non_dynamic_state(pipeline, pCreateInfo);
+   pipeline->depth_clamp_enable = pCreateInfo->pRasterizationState &&
+  
pCreateInfo->pRasterizationState->depthClampEnable;
 
pipeline->use_repclear = extra && extra->use_repclear;
 
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index f5500c5..052ced4 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1360,7 +1360,8 @@ VkResult
 anv_cmd_buffer_new_binding_table_block(struct anv_cmd_buffer *cmd_buffer);
 
 void gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer);
-void gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer);
+void gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer,
+ bool depth_clamp_enable);
 void gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer);
 
 void anv_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer);
@@ -1485,6 +1486,8 @@ struct anv_pipeline {
 
uint32_t cs_right_mask;
 
+   bool depth_clamp_enable;
+
struct {
   uint32_t  sf[7];
   uint32_t  depth_stencil_state[3];
diff --git a/src/intel/vulkan/gen7_pipeline.c b/src/intel/vulkan/gen7_pipeline.c
index f069db9..dd34d71 100644
--- a/src/intel/vulkan/gen7_pipeline.c
+++ b/src/intel/vulkan/gen7_pipeline.c
@@ -196,6 +196,7 @@ genX(graphics_pipeline_create)(
   clip.ClipEnable   = !(extra && extra->use_rectlist),
   clip.APIMode  = APIMODE_OGL,
   clip.ViewportXYClipTestEnable = true,
+  clip.ViewportZClipTestEnable  = !pipeline->depth_clamp_enable,
   clip.ClipMode = CLIPMODE_NORMAL,
 
   clip.TriangleStripListProvokingVertexSelect   = 0,
diff --git a/src/intel/vulkan/gen8_cmd_buffer.c 
b/src/intel/vulkan/gen8_cmd_buffer.c
index 9983cf8..52e5324 100644
--- a/src/intel/vulkan/gen8_cmd_buffer.c
+++ b/src/intel/vulkan/gen8_cmd_buffer.c
@@ -77,7 +77,8 @@ gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer 
*cmd_buffer)
 }
 
 void
-gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer)
+gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer,
+bool depth_clamp_enable)
 {
uint32_t count = cmd_buffer->state.dynamic.viewport.count;
const VkViewport *viewports = cmd_buffer->state.dynamic.viewport.viewports;
@@ -88,8 +89,8 @@ gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer 
*cmd_buffer)
   const VkViewport *vp = [i];
 
   struct GENX(CC_VIEWPORT) cc_viewport = {
- .MinimumDepth = vp->minDepth,
- .MaximumDepth = vp->maxDepth,
+

[Mesa-dev] [PATCH 07/11] anv/cmd_buffer: Split emit_viewport in two

2016-06-17 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
Cc: Kenneth Graunke 
---
 src/intel/vulkan/anv_private.h |  1 +
 src/intel/vulkan/gen8_cmd_buffer.c | 38 ++
 src/intel/vulkan/genX_cmd_buffer.c |  4 +++-
 3 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index cd3588a..f5500c5 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1360,6 +1360,7 @@ VkResult
 anv_cmd_buffer_new_binding_table_block(struct anv_cmd_buffer *cmd_buffer);
 
 void gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer);
+void gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer);
 void gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer);
 
 void anv_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer);
diff --git a/src/intel/vulkan/gen8_cmd_buffer.c 
b/src/intel/vulkan/gen8_cmd_buffer.c
index 2600615..9983cf8 100644
--- a/src/intel/vulkan/gen8_cmd_buffer.c
+++ b/src/intel/vulkan/gen8_cmd_buffer.c
@@ -40,8 +40,6 @@ gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer 
*cmd_buffer)
const VkViewport *viewports = cmd_buffer->state.dynamic.viewport.viewports;
struct anv_state sf_clip_state =
   anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 64, 64);
-   struct anv_state cc_state =
-  anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 8, 32);
 
for (uint32_t i = 0; i < count; i++) {
   const VkViewport *vp = [i];
@@ -65,29 +63,45 @@ gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer 
*cmd_buffer)
  .YMaxViewPort = vp->y + vp->height - 1,
   };
 
+  GENX(SF_CLIP_VIEWPORT_pack)(NULL, sf_clip_state.map + i * 64,
+ _clip_viewport);
+   }
+
+   if (!cmd_buffer->device->info.has_llc)
+  anv_state_clflush(sf_clip_state);
+
+   anv_batch_emit(_buffer->batch,
+  GENX(3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP), clip) {
+  clip.SFClipViewportPointer = sf_clip_state.offset;
+   }
+}
+
+void
+gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer *cmd_buffer)
+{
+   uint32_t count = cmd_buffer->state.dynamic.viewport.count;
+   const VkViewport *viewports = cmd_buffer->state.dynamic.viewport.viewports;
+   struct anv_state cc_state =
+  anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 8, 32);
+
+   for (uint32_t i = 0; i < count; i++) {
+  const VkViewport *vp = [i];
+
   struct GENX(CC_VIEWPORT) cc_viewport = {
  .MinimumDepth = vp->minDepth,
- .MaximumDepth = vp->maxDepth
+ .MaximumDepth = vp->maxDepth,
   };
 
-  GENX(SF_CLIP_VIEWPORT_pack)(NULL, sf_clip_state.map + i * 64,
- _clip_viewport);
   GENX(CC_VIEWPORT_pack)(NULL, cc_state.map + i * 8, _viewport);
}
 
-   if (!cmd_buffer->device->info.has_llc) {
-  anv_state_clflush(sf_clip_state);
+   if (!cmd_buffer->device->info.has_llc)
   anv_state_clflush(cc_state);
-   }
 
anv_batch_emit(_buffer->batch,
   GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), cc) {
   cc.CCViewportPointer = cc_state.offset;
}
-   anv_batch_emit(_buffer->batch,
-  GENX(3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP), clip) {
-  clip.SFClipViewportPointer = sf_clip_state.offset;
-   }
 }
 #endif
 
diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
b/src/intel/vulkan/genX_cmd_buffer.c
index d0b28a9..666920e 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -534,8 +534,10 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer 
*cmd_buffer)
if (dirty)
   gen7_cmd_buffer_emit_descriptor_pointers(cmd_buffer, dirty);
 
-   if (cmd_buffer->state.dirty & ANV_CMD_DIRTY_DYNAMIC_VIEWPORT)
+   if (cmd_buffer->state.dirty & ANV_CMD_DIRTY_DYNAMIC_VIEWPORT) {
   gen8_cmd_buffer_emit_viewport(cmd_buffer);
+  gen8_cmd_buffer_emit_depth_viewport(cmd_buffer);
+   }
 
if (cmd_buffer->state.dirty & ANV_CMD_DIRTY_DYNAMIC_SCISSOR)
   gen7_cmd_buffer_emit_scissor(cmd_buffer);
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 03/11] nir/alu_to_scalar: Respect the exact ALU operation qualifier

2016-06-17 Thread Jason Ekstrand
Just setting builder->exact isn't sufficient because that only applies to
instructions that are built with the builder but instructions created
manually and only inserted using the builder are left alone.

Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
Cc: Kenneth Graunke 
---
 src/compiler/nir/nir_lower_alu_to_scalar.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compiler/nir/nir_lower_alu_to_scalar.c 
b/src/compiler/nir/nir_lower_alu_to_scalar.c
index b491791..4f72cf7 100644
--- a/src/compiler/nir/nir_lower_alu_to_scalar.c
+++ b/src/compiler/nir/nir_lower_alu_to_scalar.c
@@ -56,6 +56,7 @@ lower_reduction(nir_alu_instr *instr, nir_op chan_op, nir_op 
merge_op,
  nir_alu_src_copy(>src[1], >src[1], chan);
  chan->src[1].swizzle[0] = chan->src[1].swizzle[i];
   }
+  chan->exact = instr->exact;
 
   nir_builder_instr_insert(builder, >instr);
 
@@ -229,6 +230,7 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b)
   nir_alu_ssa_dest_init(lower, 1, instr->dest.dest.ssa.bit_size);
   lower->dest.saturate = instr->dest.saturate;
   comps[chan] = >dest.dest.ssa;
+  lower->exact = instr->exact;
 
   nir_builder_instr_insert(b, >instr);
}
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 05/11] anv/cmd_buffer: Don't crash if push constants are provided for missing stages

2016-06-17 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
---
 src/intel/vulkan/anv_cmd_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_cmd_buffer.c 
b/src/intel/vulkan/anv_cmd_buffer.c
index 5be5f3e..24c18fe 100644
--- a/src/intel/vulkan/anv_cmd_buffer.c
+++ b/src/intel/vulkan/anv_cmd_buffer.c
@@ -1038,7 +1038,7 @@ anv_cmd_buffer_push_constants(struct anv_cmd_buffer 
*cmd_buffer,
   cmd_buffer->state.pipeline->prog_data[stage];
 
/* If we don't actually have any push constants, bail. */
-   if (data == NULL || prog_data->nr_params == 0)
+   if (data == NULL || prog_data == NULL || prog_data->nr_params == 0)
   return (struct anv_state) { .offset = 0 };
 
struct anv_state state =
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 06/11] anv/cmd_buffer: Set depth/stencil extent based on the image

2016-06-17 Thread Jason Ekstrand
It used to be based on the framebuffer which isn't quite right.

Signed-off-by: Jason Ekstrand 
Cc: Chad Versace 
Cc: "12.0" 
---
 src/intel/vulkan/genX_cmd_buffer.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
b/src/intel/vulkan/genX_cmd_buffer.c
index 10ed73a..d0b28a9 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1033,11 +1033,11 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer 
*cmd_buffer)
  db.DepthBufferObjectControlState = GENX(MOCS),
 
  db.SurfacePitch = image->depth_surface.isl.row_pitch - 1;
- db.Height   = fb->height - 1;
- db.Width= fb->width - 1;
- db.LOD  = 0;
- db.Depth= 1 - 1;
- db.MinimumArrayElement  = 0;
+ db.Height   = image->extent.height - 1;
+ db.Width= image->extent.width - 1;
+ db.LOD  = iview->base_mip;
+ db.Depth= image->array_size - 1; /* FIXME: 3-D */
+ db.MinimumArrayElement  = iview->base_layer;
 
 #if GEN_GEN >= 8
  db.SurfaceQPitch =
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 09/11] anv: Add an allocator for scratch buffers

2016-06-17 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
Cc: Francisco Jerez 
---
 src/intel/vulkan/anv_allocator.c | 76 
 src/intel/vulkan/anv_private.h   | 13 +++
 2 files changed, 89 insertions(+)

diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index 088b461..f268e72 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -876,3 +876,79 @@ anv_bo_pool_free(struct anv_bo_pool *pool, const struct 
anv_bo *bo_in)
VG(VALGRIND_MEMPOOL_FREE(pool, bo.map));
anv_ptr_free_list_push(>free_list[bucket], link);
 }
+
+// Scratch pool
+
+void
+anv_scratch_pool_init(struct anv_device *device, struct anv_scratch_pool *pool)
+{
+   memset(pool, 0, sizeof(*pool));
+}
+
+void
+anv_scratch_pool_finish(struct anv_device *device, struct anv_scratch_pool 
*pool)
+{
+   for (unsigned s = 0; s < MESA_SHADER_STAGES; s++) {
+  for (unsigned i = 0; i < 16; i++) {
+ struct anv_bo *bo = >bos[i][s];
+ if (bo->size > 0)
+anv_gem_close(device, bo->gem_handle);
+  }
+   }
+}
+
+struct anv_bo *
+anv_scratch_pool_alloc(struct anv_device *device, struct anv_scratch_pool 
*pool,
+   gl_shader_stage stage, unsigned per_thread_scratch)
+{
+   if (per_thread_scratch == 0)
+  return NULL;
+
+   unsigned scratch_size_log2 = ffs(per_thread_scratch / 2048);
+   assert(scratch_size_log2 < 16);
+
+   struct anv_bo *bo = >bos[scratch_size_log2][stage];
+
+   /* From now on, we go into a critical section.  In order to remain
+* thread-safe, we use the bo size as a lock.  A value of 0 means we don't
+* have a valid BO yet.  A value of 1 means locked.  A value greater than 1
+* means we have a bo of the given size.
+*/
+
+   if (bo->size > 1)
+  return bo;
+
+   uint64_t size = __sync_val_compare_and_swap(>size, 0, 1);
+   if (size == 0) {
+  /* We own the lock.  Allocate a buffer */
+
+  struct brw_device_info *devinfo = >info;
+  uint32_t max_threads[] = {
+ [MESA_SHADER_VERTEX]  = devinfo->max_vs_threads,
+ [MESA_SHADER_TESS_CTRL]   = devinfo->max_hs_threads,
+ [MESA_SHADER_TESS_EVAL]   = devinfo->max_ds_threads,
+ [MESA_SHADER_GEOMETRY]= devinfo->max_gs_threads,
+ [MESA_SHADER_FRAGMENT]= devinfo->max_wm_threads,
+ [MESA_SHADER_COMPUTE] = devinfo->max_cs_threads,
+  };
+
+  size = per_thread_scratch * max_threads[stage];
+
+  struct anv_bo new_bo;
+  anv_bo_init_new(_bo, device, size);
+
+  bo->gem_handle = new_bo.gem_handle;
+
+  /* Set the size last because we use it as a lock */
+  __sync_synchronize();
+  bo->size = size;
+
+  futex_wake((uint32_t *)>size, INT_MAX);
+   } else {
+  /* Someone else got here first */
+  while (bo->size == 1)
+ futex_wait((uint32_t *)>size, 1);
+   }
+
+   return bo;
+}
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 052ced4..d3a0ec2 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -475,6 +475,19 @@ VkResult anv_bo_pool_alloc(struct anv_bo_pool *pool, 
struct anv_bo *bo,
uint32_t size);
 void anv_bo_pool_free(struct anv_bo_pool *pool, const struct anv_bo *bo);
 
+struct anv_scratch_pool {
+   /* Indexed by Per-Thread Scratch Space number (the hardware value) and 
stage */
+   struct anv_bo bos[16][MESA_SHADER_STAGES];
+};
+
+void anv_scratch_pool_init(struct anv_device *device,
+   struct anv_scratch_pool *pool);
+void anv_scratch_pool_finish(struct anv_device *device,
+ struct anv_scratch_pool *pool);
+struct anv_bo *anv_scratch_pool_alloc(struct anv_device *device,
+  struct anv_scratch_pool *pool,
+  gl_shader_stage stage,
+  unsigned per_thread_scratch);
 
 void *anv_resolve_entrypoint(uint32_t index);
 
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 10/11] genxml: Make ScratchSpaceBasePointer an address instead of an offset

2016-06-17 Thread Jason Ekstrand
While we're here, we also fixup MEDIA_VFE_STATE and rename the field in
3DSTATE_VS on gen6-7.5 to be consistent with the others.

Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
Cc: Francisco Jerez 
---
 src/intel/genxml/gen6.xml|  8 
 src/intel/genxml/gen7.xml| 12 ++--
 src/intel/genxml/gen75.xml   | 12 ++--
 src/intel/genxml/gen8.xml| 13 ++---
 src/intel/genxml/gen9.xml| 13 ++---
 src/intel/vulkan/gen7_pipeline.c | 18 +++---
 src/intel/vulkan/gen8_pipeline.c | 15 ---
 src/intel/vulkan/genX_pipeline.c |  6 --
 8 files changed, 59 insertions(+), 38 deletions(-)

diff --git a/src/intel/genxml/gen6.xml b/src/intel/genxml/gen6.xml
index 7525fce..44e2804 100644
--- a/src/intel/genxml/gen6.xml
+++ b/src/intel/genxml/gen6.xml
@@ -971,7 +971,7 @@
 
 
 
-
+
 
 
 
@@ -1346,7 +1346,7 @@
 
 
 
-
+
 
 
 
@@ -1378,7 +1378,7 @@
 
 
 
-
+
 
 
 
@@ -1578,7 +1578,7 @@
 
 
 
-
+
 
 
 
diff --git a/src/intel/genxml/gen7.xml b/src/intel/genxml/gen7.xml
index 6f3e8cc..09d816d 100644
--- a/src/intel/genxml/gen7.xml
+++ b/src/intel/genxml/gen7.xml
@@ -1113,7 +1113,7 @@
 
 
 
-
+
 
 
 
@@ -1153,7 +1153,7 @@
 
 
 
-
+
 
 
 
@@ -1220,7 +1220,7 @@
 
 
 
-
+
 
 
 
@@ -1354,7 +1354,7 @@
 
 
 
-
+
 
 
 
@@ -1858,7 +1858,7 @@
 
 
 
-
+
 
 
 
@@ -2109,7 +2109,7 @@
 
 
 
-
+
 
 
 
diff --git a/src/intel/genxml/gen75.xml b/src/intel/genxml/gen75.xml
index ac1b6e4..1ff5cac 100644
--- a/src/intel/genxml/gen75.xml
+++ b/src/intel/genxml/gen75.xml
@@ -1231,7 +1231,7 @@
 
 
 
-
+
 
 
 
@@ -1362,7 +1362,7 @@
 
 
 
-
+
 
 
 
@@ -1435,7 +1435,7 @@
 
 
 
-
+
 
 
 
@@ -1573,7 +1573,7 @@
 
 
 
-
+
 
 
 
@@ -2121,7 +2121,7 @@
 
 
 
-
+
 
 
 
@@ -2396,7 +2396,7 @@
 
 
 
-
+
 
 
 
diff --git a/src/intel/genxml/gen8.xml b/src/intel/genxml/gen8.xml
index 1d6a43f..028f8b4 100644
--- a/src/intel/genxml/gen8.xml
+++ b/src/intel/genxml/gen8.xml
@@ -1265,7 +1265,7 @@
 
 
 
-
+
 
 
 
@@ -1405,7 +1405,7 @@
 
 
 
-
+
 
 
 
@@ -1484,7 +1484,7 @@
 
 
 
-
+
 
 
 
@@ -1607,7 +1607,7 @@
 
 
 
-
+
 
 
 
@@ -2265,7 +2265,7 @@
 
 
 
-
+
 
 
 
@@ -2601,10 +2601,9 @@
 
 
 
-
+
 
 
-
 
 
 
diff --git a/src/intel/genxml/gen9.xml b/src/intel/genxml/gen9.xml
index 2c01c56..ace6ef3 100644
--- a/src/intel/genxml/gen9.xml
+++ b/src/intel/genxml/gen9.xml
@@ -1320,7 +1320,7 @@
 
 
 
-
+
 
 
 
@@ -1507,7 +1507,7 @@
 
 
 
-
+
 
 
 
@@ -1587,7 +1587,7 @@
 
 
 
-
+
 
 
 
@@ -1717,7 +1717,7 @@
 
 
 
-
+
 
 
 
@@ -2519,7 +2519,7 @@
 
 
 
-
+
 
 
 
@@ -2868,10 +2868,9 @@
 
 
 
-
+
 
 
-
 
 
 
diff --git a/src/intel/vulkan/gen7_pipeline.c b/src/intel/vulkan/gen7_pipeline.c
index dd34d71..56e59a4 100644
--- a/src/intel/vulkan/gen7_pipeline.c
+++ b/src/intel/vulkan/gen7_pipeline.c
@@ -250,7 +250,11 @@ genX(graphics_pipeline_create)(
else
   anv_batch_emit(>batch, GENX(3DSTATE_VS), vs) {
  vs.KernelStartPointer = pipeline->vs_vec4;
- vs.ScratchSpaceBaseOffset = 
pipeline->scratch_start[MESA_SHADER_VERTEX];
+
+ vs.ScratchSpaceBasePointer = (struct anv_address) {
+.bo = NULL,
+.offset = pipeline->scratch_start[MESA_SHADER_VERTEX],
+ };
  vs.PerThreadScratchSpace  = 
scratch_space(_prog_data->base.base);
 
  vs.DispatchGRFStartRegisterforURBData=
@@ -270,7 +274,11 @@ genX(graphics_pipeline_create)(
} else {
   anv_batch_emit(>batch, GENX(3DSTATE_GS), gs) {
  gs.KernelStartPointer = pipeline->gs_kernel;
- gs.ScratchSpaceBasePointer= 
pipeline->scratch_start[MESA_SHADER_GEOMETRY];
+
+ gs.ScratchSpaceBasePointer = (struct anv_address) {
+.bo = NULL,
+.offset = pipeline->scratch_start[MESA_SHADER_GEOMETRY],
+ };
  gs.PerThreadScratchSpace  = 
scratch_space(_prog_data->base.base);
 
  gs.OutputVertexSize   = 
gs_prog_data->output_vertex_size_hwords * 2 - 1;
@@ -328,7 +336,11 @@ genX(graphics_pipeline_create)(
 
   

[Mesa-dev] [PATCH 11/11] anv: Use different BOs for different scratch sizes and stages

2016-06-17 Thread Jason Ekstrand
This solves a race condition where we can end up having different stages
stomp on each other because they're all trying to scratch in the same BO
but they have different views of its layout.

Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
Cc: Francisco Jerez 
---
 src/intel/vulkan/anv_device.c  |  4 ++--
 src/intel/vulkan/anv_pipeline.c| 20 
 src/intel/vulkan/anv_private.h |  4 +---
 src/intel/vulkan/gen7_pipeline.c   | 18 --
 src/intel/vulkan/gen8_pipeline.c   | 18 --
 src/intel/vulkan/genX_cmd_buffer.c | 15 +--
 src/intel/vulkan/genX_pipeline.c   |  8 
 7 files changed, 32 insertions(+), 55 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 97300c3..ea8e875 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -878,7 +878,7 @@ VkResult anv_CreateDevice(
 
anv_bo_init_new(>workaround_bo, device, 1024);
 
-   anv_block_pool_init(>scratch_block_pool, device, 0x1);
+   anv_scratch_pool_init(device, >scratch_pool);
 
anv_queue_init(device, >queue);
 
@@ -947,7 +947,7 @@ void anv_DestroyDevice(
anv_block_pool_finish(>instruction_block_pool);
anv_state_pool_finish(>surface_state_pool);
anv_block_pool_finish(>surface_state_block_pool);
-   anv_block_pool_finish(>scratch_block_pool);
+   anv_scratch_pool_finish(device, >scratch_pool);
 
close(device->fd);
 
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 295b48c..29747cf 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -397,22 +397,8 @@ anv_pipeline_add_compiled_stage(struct anv_pipeline 
*pipeline,
 const struct brw_stage_prog_data *prog_data,
 struct anv_pipeline_bind_map *map)
 {
-   struct brw_device_info *devinfo = >device->info;
-   uint32_t max_threads[] = {
-  [MESA_SHADER_VERTEX]  = devinfo->max_vs_threads,
-  [MESA_SHADER_TESS_CTRL]   = devinfo->max_hs_threads,
-  [MESA_SHADER_TESS_EVAL]   = devinfo->max_ds_threads,
-  [MESA_SHADER_GEOMETRY]= devinfo->max_gs_threads,
-  [MESA_SHADER_FRAGMENT]= devinfo->max_wm_threads,
-  [MESA_SHADER_COMPUTE] = devinfo->max_cs_threads,
-   };
-
pipeline->prog_data[stage] = prog_data;
pipeline->active_stages |= mesa_to_vk_shader_stage(stage);
-   pipeline->scratch_start[stage] = pipeline->total_scratch;
-   pipeline->total_scratch =
-  align_u32(pipeline->total_scratch, 1024) +
-  prog_data->total_scratch * max_threads[stage];
pipeline->bindings[stage] = *map;
 }
 
@@ -1176,7 +1162,6 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
 * of various prog_data pointers.  Make them NULL by default.
 */
memset(pipeline->prog_data, 0, sizeof(pipeline->prog_data));
-   memset(pipeline->scratch_start, 0, sizeof(pipeline->scratch_start));
memset(pipeline->bindings, 0, sizeof(pipeline->bindings));
 
pipeline->vs_simd8 = NO_KERNEL;
@@ -1185,7 +1170,6 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
pipeline->ps_ksp0 = NO_KERNEL;
 
pipeline->active_stages = 0;
-   pipeline->total_scratch = 0;
 
const VkPipelineShaderStageCreateInfo *pStages[MESA_SHADER_STAGES] = { 0, };
struct anv_shader_module *modules[MESA_SHADER_STAGES] = { 0, };
@@ -1278,10 +1262,6 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
if (extra && extra->use_rectlist)
   pipeline->topology = _3DPRIM_RECTLIST;
 
-   while (anv_block_pool_size(>scratch_block_pool) <
-  pipeline->total_scratch)
-  anv_block_pool_alloc(>scratch_block_pool);
-
return VK_SUCCESS;
 }
 
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index d3a0ec2..e7f0e52 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -711,7 +711,7 @@ struct anv_device {
 
 struct anv_queuequeue;
 
-struct anv_block_pool   scratch_block_pool;
+struct anv_scratch_pool scratch_pool;
 
 uint32_tdefault_mocs;
 
@@ -1473,8 +1473,6 @@ struct anv_pipeline {
bool needs_data_cache;
 
const struct brw_stage_prog_data *   prog_data[MESA_SHADER_STAGES];
-   uint32_t 
scratch_start[MESA_SHADER_STAGES];
-   uint32_t total_scratch;
struct {
   uint32_t  start[MESA_SHADER_GEOMETRY + 
1];
   uint32_t  size[MESA_SHADER_GEOMETRY + 1];
diff --git a/src/intel/vulkan/gen7_pipeline.c b/src/intel/vulkan/gen7_pipeline.c
index 56e59a4..89cb51f 100644
--- 

[Mesa-dev] [PATCH 01/11] anv: Add support for INTEL_DEBUG=sync, state

2016-06-17 Thread Jason Ekstrand
Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
---
 src/intel/vulkan/gen8_cmd_buffer.c | 9 +
 src/intel/vulkan/genX_cmd_buffer.c | 9 +
 2 files changed, 18 insertions(+)

diff --git a/src/intel/vulkan/gen8_cmd_buffer.c 
b/src/intel/vulkan/gen8_cmd_buffer.c
index df4036a..2600615 100644
--- a/src/intel/vulkan/gen8_cmd_buffer.c
+++ b/src/intel/vulkan/gen8_cmd_buffer.c
@@ -365,6 +365,15 @@ genX(cmd_buffer_flush_compute_state)(struct anv_cmd_buffer 
*cmd_buffer)
 
assert(pipeline->active_stages == VK_SHADER_STAGE_COMPUTE_BIT);
 
+   if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
+  cmd_buffer->state.pending_pipe_bits =
+ ANV_PIPE_FLUSH_BITS | ANV_PIPE_INVALIDATE_BITS | 
ANV_PIPE_CS_STALL_BIT;
+   }
+
+   if (unlikely(INTEL_DEBUG & DEBUG_STATE)) {
+  cmd_buffer->state.dirty = ~0;
+   }
+
genX(cmd_buffer_config_l3)(cmd_buffer, pipeline);
 
genX(flush_pipeline_select_gpgpu)(cmd_buffer);
diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
b/src/intel/vulkan/genX_cmd_buffer.c
index d9acf58..10ed73a 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -417,6 +417,15 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer 
*cmd_buffer)
 
assert((pipeline->active_stages & VK_SHADER_STAGE_COMPUTE_BIT) == 0);
 
+   if (unlikely(INTEL_DEBUG & DEBUG_SYNC)) {
+  cmd_buffer->state.pending_pipe_bits =
+ ANV_PIPE_FLUSH_BITS | ANV_PIPE_INVALIDATE_BITS | 
ANV_PIPE_CS_STALL_BIT;
+   }
+
+   if (unlikely(INTEL_DEBUG & DEBUG_STATE)) {
+  cmd_buffer->state.dirty = ~0;
+   }
+
genX(cmd_buffer_config_l3)(cmd_buffer, pipeline);
 
genX(flush_pipeline_select_3d)(cmd_buffer);
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 02/11] nir: Add a pass for propagating invariant decorations

2016-06-17 Thread Jason Ekstrand
This pass is similar to propagate_invariance in the GLSL compiler.  The
real "output" of this pass is that any algebraic operations which are
eventually consumed by an invariant variable get marked as "exact".

Signed-off-by: Jason Ekstrand 
Cc: "12.0" 
Cc: Kenneth Graunke 
---
 src/compiler/Makefile.sources  |   1 +
 src/compiler/nir/nir.h |   2 +
 src/compiler/nir/nir_propagate_invariant.c | 196 +
 3 files changed, 199 insertions(+)
 create mode 100644 src/compiler/nir/nir_propagate_invariant.c

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 5c4ea65..0ff9b23 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -231,6 +231,7 @@ NIR_FILES = \
nir/nir_phi_builder.c \
nir/nir_phi_builder.h \
nir/nir_print.c \
+   nir/nir_propagate_invariant.c \
nir/nir_remove_dead_variables.c \
nir/nir_repair_ssa.c \
nir/nir_search.c \
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index ec7b0c7..1725ee3 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2290,6 +2290,8 @@ bool nir_lower_returns(nir_shader *shader);
 
 bool nir_inline_functions(nir_shader *shader);
 
+bool nir_propagate_invariant(nir_shader *shader);
+
 void nir_lower_var_copy_instr(nir_intrinsic_instr *copy, void *mem_ctx);
 void nir_lower_var_copies(nir_shader *shader);
 
diff --git a/src/compiler/nir/nir_propagate_invariant.c 
b/src/compiler/nir/nir_propagate_invariant.c
new file mode 100644
index 000..7b5bd6c
--- /dev/null
+++ b/src/compiler/nir/nir_propagate_invariant.c
@@ -0,0 +1,196 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "nir.h"
+
+static void
+add_src(nir_src *src, struct set *invariants)
+{
+   if (src->is_ssa) {
+  _mesa_set_add(invariants, src->ssa);
+   } else {
+  _mesa_set_add(invariants, src->reg.reg);
+   }
+}
+
+static bool
+add_src_cb(nir_src *src, void *state)
+{
+   add_src(src, state);
+   return true;
+}
+
+static bool
+dest_is_invariant(nir_dest *dest, struct set *invariants)
+{
+   if (dest->is_ssa) {
+  return _mesa_set_search(invariants, >ssa);
+   } else {
+  return _mesa_set_search(invariants, dest->reg.reg);
+   }
+}
+
+static void
+add_cf_node(nir_cf_node *cf, struct set *invariants)
+{
+   if (cf->type == nir_cf_node_if) {
+  nir_if *if_stmt = nir_cf_node_as_if(cf);
+  add_src(_stmt->condition, invariants);
+   }
+
+   if (cf->parent)
+  add_cf_node(cf->parent, invariants);
+}
+
+static void
+add_var(nir_variable *var, struct set *invariants)
+{
+   _mesa_set_add(invariants, var);
+}
+
+static bool
+var_is_invariant(nir_variable *var, struct set * invariants)
+{
+   return var->data.invariant || _mesa_set_search(invariants, var);
+}
+
+static void
+propagate_invariant_instr(nir_instr *instr, struct set *invariants)
+{
+   switch (instr->type) {
+   case nir_instr_type_alu: {
+  nir_alu_instr *alu = nir_instr_as_alu(instr);
+  if (!dest_is_invariant(>dest.dest, invariants))
+ break;
+
+  alu->exact = true;
+  nir_foreach_src(instr, add_src_cb, invariants);
+  break;
+   }
+
+   case nir_instr_type_tex: {
+  nir_tex_instr *tex = nir_instr_as_tex(instr);
+  if (dest_is_invariant(>dest, invariants))
+ nir_foreach_src(instr, add_src_cb, invariants);
+  break;
+   }
+
+   case nir_instr_type_intrinsic: {
+  nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+  switch (intrin->intrinsic) {
+  case nir_intrinsic_copy_var:
+ /* If the destination is invariant then so is the source */
+ if (var_is_invariant(intrin->variables[0]->var, invariants))
+add_var(intrin->variables[1]->var, invariants);
+   

[Mesa-dev] [PATCH 5/5] anv/dump: Add support for dumping framebuffers

2016-06-17 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_dump.c| 127 +
 src/intel/vulkan/anv_private.h |  10 +++
 src/intel/vulkan/genX_cmd_buffer.c |   4 ++
 3 files changed, 141 insertions(+)

diff --git a/src/intel/vulkan/anv_dump.c b/src/intel/vulkan/anv_dump.c
index 59a6f2a..1dc5079 100644
--- a/src/intel/vulkan/anv_dump.c
+++ b/src/intel/vulkan/anv_dump.c
@@ -23,11 +23,16 @@
 
 #include "anv_private.h"
 
+#include "util/list.h"
+#include "util/ralloc.h"
+
 /* This file contains utility functions for help debugging.  They can be
  * called from GDB or similar to help inspect images and buffers.
  */
 
 struct dump_image {
+   struct list_head link;
+
const char *filename;
 
VkExtent2D extent;
@@ -288,3 +293,125 @@ anv_dump_image_to_ppm(struct anv_device *device,
dump_image_write_to_ppm(device, );
dump_image_finish(device, );
 }
+
+static pthread_mutex_t dump_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static enum anv_dump_action dump_actions = 0;
+
+/* Used to prevent recursive dumping */
+static enum anv_dump_action dump_old_actions;
+
+struct list_head dump_list;
+static void *dump_ctx;
+static struct anv_device *dump_device;
+static unsigned dump_count;
+
+void
+anv_dump_start(struct anv_device *device, enum anv_dump_action actions)
+{
+   pthread_mutex_lock(_mutex);
+
+   dump_device = device;
+   dump_actions = actions;
+   list_inithead(_list);
+   dump_ctx = ralloc_context(NULL);
+   dump_count = 0;
+
+   pthread_mutex_unlock(_mutex);
+}
+
+void
+anv_dump_finish()
+{
+   anv_DeviceWaitIdle(anv_device_to_handle(dump_device));
+
+   pthread_mutex_lock(_mutex);
+
+   list_for_each_entry(struct dump_image, dump, _list, link) {
+  dump_image_write_to_ppm(dump_device, dump);
+  dump_image_finish(dump_device, dump);
+   }
+
+   dump_actions = 0;
+   dump_device = NULL;
+   list_inithead(_list);
+
+   ralloc_free(dump_ctx);
+   dump_ctx = NULL;
+
+   pthread_mutex_unlock(_mutex);
+}
+
+static bool
+dump_lock(enum anv_dump_action action)
+{
+   if (likely((dump_actions & action) == 0))
+  return false;
+
+   pthread_mutex_lock(_mutex);
+
+   /* Prevent recursive dumping */
+   dump_old_actions = dump_actions;
+   dump_actions = 0;
+
+   return true;
+}
+
+static void
+dump_unlock()
+{
+   dump_actions = dump_old_actions;
+   pthread_mutex_unlock(_mutex);
+}
+
+static void
+dump_add_image(struct anv_cmd_buffer *cmd_buffer, struct anv_image *image,
+   VkImageAspectFlagBits aspect,
+   unsigned miplevel, unsigned array_layer, const char *filename)
+{
+   const uint32_t width = anv_minify(image->extent.width, miplevel);
+   const uint32_t height = anv_minify(image->extent.height, miplevel);
+
+   struct dump_image *dump = ralloc(dump_ctx, struct dump_image);
+
+   dump_image_init(cmd_buffer->device, dump, width, height, filename);
+   dump_image_do_blit(cmd_buffer->device, dump, cmd_buffer, image,
+  aspect, miplevel, array_layer);
+
+   list_addtail(>link, _list);
+}
+
+void
+anv_dump_add_framebuffer(struct anv_cmd_buffer *cmd_buffer,
+ struct anv_framebuffer *fb)
+{
+   if (!dump_lock(ANV_DUMP_FRAMEBUFFERS_BIT))
+  return;
+
+   unsigned dump_idx = dump_count++;
+
+   for (unsigned i = 0; i < fb->attachment_count; i++) {
+  struct anv_image_view *iview = fb->attachments[i];
+
+  uint32_t b;
+  for_each_bit(b, iview->image->aspects) {
+ VkImageAspectFlagBits aspect = (1 << b);
+ char suffix;
+ switch (aspect) {
+ case VK_IMAGE_ASPECT_COLOR_BIT: suffix = 'c'; break;
+ case VK_IMAGE_ASPECT_DEPTH_BIT: suffix = 'd'; break;
+ case VK_IMAGE_ASPECT_STENCIL_BIT:   suffix = 's'; break;
+ default:
+unreachable("Invalid aspect");
+ }
+
+ char *filename = ralloc_asprintf(dump_ctx, "framebuffer%04d-%d%c.ppm",
+  dump_idx, i, suffix);
+
+ dump_add_image(cmd_buffer, (struct anv_image *)iview->image, aspect,
+iview->base_mip, iview->base_layer, filename);
+  }
+   }
+
+   dump_unlock();
+}
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 443fda9..6f4db31 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1834,6 +1834,16 @@ void anv_dump_image_to_ppm(struct anv_device *device,
unsigned array_layer, VkImageAspectFlagBits aspect,
const char *filename);
 
+enum anv_dump_action {
+   ANV_DUMP_FRAMEBUFFERS_BIT = 0x1,
+};
+
+void anv_dump_start(struct anv_device *device, enum anv_dump_action actions);
+void anv_dump_finish(void);
+
+void anv_dump_add_framebuffer(struct anv_cmd_buffer *cmd_buffer,
+  struct anv_framebuffer *fb);
+
 #define ANV_DEFINE_HANDLE_CASTS(__anv_type, __VkType)  \
\

[Mesa-dev] [PATCH 4/5] anv/dump: Add a barrier for the source image

2016-06-17 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_dump.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/src/intel/vulkan/anv_dump.c b/src/intel/vulkan/anv_dump.c
index 0fee93c..59a6f2a 100644
--- a/src/intel/vulkan/anv_dump.c
+++ b/src/intel/vulkan/anv_dump.c
@@ -90,6 +90,28 @@ dump_image_do_blit(struct anv_device *device, struct 
dump_image *image,
VkImageAspectFlagBits aspect,
unsigned miplevel, unsigned array_layer)
 {
+   ANV_CALL(CmdPipelineBarrier)(anv_cmd_buffer_to_handle(cmd_buffer),
+  VK_PIPELINE_STAGE_TRANSFER_BIT,
+  VK_PIPELINE_STAGE_TRANSFER_BIT,
+  0, 0, NULL, 0, NULL, 1,
+  &(VkImageMemoryBarrier) {
+ .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
+ .srcAccessMask = ~0,
+ .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
+ .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
+ .newLayout = VK_IMAGE_LAYOUT_GENERAL,
+ .srcQueueFamilyIndex = 0,
+ .dstQueueFamilyIndex = 0,
+ .image = anv_image_to_handle(src),
+ .subresourceRange = (VkImageSubresourceRange) {
+.aspectMask = aspect,
+.baseMipLevel = miplevel,
+.levelCount = 1,
+.baseArrayLayer = array_layer,
+.layerCount = 1,
+ },
+  });
+
/* We need to do a blit so the image needs to be declared as sampled.  The
 * only thing these are used for is making sure we create the correct
 * views, so it should be find to just stomp it and set it back.
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 0/5] anv: add better debug resourde dumping

2016-06-17 Thread Jason Ekstrand
A while ago while debugging some driver errors, I added a basic image
dumping mechanism to dump images to PPM files.  This little series improves
things and adds support for dumping the framebuffer at the end of every
renderpass.  With these patches, you can dump rendering for a frame as
follows:

 1) Start the application in GDB
 2) Run until you get to the point where the rendering errors occur
 3) Pause in GDB and set a breakpoint in anv_QueuePresentKHR
 4) Continue until it reaches anv_QueuePresentKHR
 5) Call anv_dump_start(queue->device, ANV_DUMP_FRAMEBUFFERS_BIT)
 6) Continue until the next anv_QueuePresentKHR call
 7) Call anv_dump_finish() to complete the dump and write files

While it's a bit manual, the process does allow you to do some very
valuable debugging by dumping every render target at the end of every
render pass.  It's worth noting that this assumes that the application
creates all of the command buffers more-or-less in-order and between the
two anv_QueuePresentKHR calls.

Jason Ekstrand (5):
  anv/dump: Take an aspect in dump_image_to_ppm
  anv/dump: Use anv_minify instead of hand-rolling it
  anv/dump: Refactor the guts into helpers
  anv/dump: Add a barrier for the source image
  anv/dump: Add support for dumping framebuffers

 src/intel/vulkan/anv_dump.c| 356 +
 src/intel/vulkan/anv_private.h |  13 +-
 src/intel/vulkan/genX_cmd_buffer.c |   4 +
 3 files changed, 298 insertions(+), 75 deletions(-)

-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 3/5] anv/dump: Refactor the guts into helpers

2016-06-17 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_dump.c | 224 +++-
 1 file changed, 139 insertions(+), 85 deletions(-)

diff --git a/src/intel/vulkan/anv_dump.c b/src/intel/vulkan/anv_dump.c
index ffb892c..0fee93c 100644
--- a/src/intel/vulkan/anv_dump.c
+++ b/src/intel/vulkan/anv_dump.c
@@ -27,83 +27,79 @@
  * called from GDB or similar to help inspect images and buffers.
  */
 
-void
-anv_dump_image_to_ppm(struct anv_device *device,
-  struct anv_image *image, unsigned miplevel,
-  unsigned array_layer, VkImageAspectFlagBits aspect,
-  const char *filename)
+struct dump_image {
+   const char *filename;
+
+   VkExtent2D extent;
+   VkImage image;
+   VkDeviceMemory memory;
+};
+
+static void
+dump_image_init(struct anv_device *device, struct dump_image *image,
+uint32_t width, uint32_t height, const char *filename)
 {
VkDevice vk_device = anv_device_to_handle(device);
MAYBE_UNUSED VkResult result;
 
-   VkExtent2D extent = {
-  anv_minify(image->extent.width, miplevel),
-  anv_minify(image->extent.height, miplevel),
-   };
+   image->filename = filename;
+   image->extent = (VkExtent2D) { width, height };
 
-   VkImage copy_image;
result = anv_CreateImage(vk_device,
   &(VkImageCreateInfo) {
  .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
  .imageType = VK_IMAGE_TYPE_2D,
  .format = VK_FORMAT_R8G8B8A8_UNORM,
- .extent = (VkExtent3D) { extent.width, extent.height, 1 },
+ .extent = (VkExtent3D) { width, height, 1 },
  .mipLevels = 1,
  .arrayLayers = 1,
  .samples = 1,
  .tiling = VK_IMAGE_TILING_LINEAR,
  .usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT,
  .flags = 0,
-  }, NULL, _image);
+  }, NULL, >image);
assert(result == VK_SUCCESS);
 
VkMemoryRequirements reqs;
-   anv_GetImageMemoryRequirements(vk_device, copy_image, );
+   anv_GetImageMemoryRequirements(vk_device, image->image, );
 
-   VkDeviceMemory memory;
result = anv_AllocateMemory(vk_device,
   &(VkMemoryAllocateInfo) {
  .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
  .allocationSize = reqs.size,
  .memoryTypeIndex = 0,
-  }, NULL, );
+  }, NULL, >memory);
assert(result == VK_SUCCESS);
 
-   result = anv_BindImageMemory(vk_device, copy_image, memory, 0);
-   assert(result == VK_SUCCESS);
-
-   VkCommandPool commandPool;
-   result = anv_CreateCommandPool(vk_device,
-  &(VkCommandPoolCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
- .queueFamilyIndex = 0,
- .flags = 0,
-  }, NULL, );
+   result = anv_BindImageMemory(vk_device, image->image, image->memory, 0);
assert(result == VK_SUCCESS);
+}
 
-   VkCommandBuffer cmd;
-   result = anv_AllocateCommandBuffers(vk_device,
-  &(VkCommandBufferAllocateInfo) {
- .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
- .commandPool = commandPool,
- .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
- .commandBufferCount = 1,
-  }, );
-   assert(result == VK_SUCCESS);
+static void
+dump_image_finish(struct anv_device *device, struct dump_image *image)
+{
+   VkDevice vk_device = anv_device_to_handle(device);
 
-   result = anv_BeginCommandBuffer(cmd,
-  &(VkCommandBufferBeginInfo) {
- .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
- .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
-  });
-   assert(result == VK_SUCCESS);
+   anv_DestroyImage(vk_device, image->image, NULL);
+   anv_FreeMemory(vk_device, image->memory, NULL);
+}
 
-   VkImageUsageFlags old_usage = image->usage;
-   image->usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
+static void
+dump_image_do_blit(struct anv_device *device, struct dump_image *image,
+   struct anv_cmd_buffer *cmd_buffer, struct anv_image *src,
+   VkImageAspectFlagBits aspect,
+   unsigned miplevel, unsigned array_layer)
+{
+   /* We need to do a blit so the image needs to be declared as sampled.  The
+* only thing these are used for is making sure we create the correct
+* views, so it should be find to just stomp it and set it back.
+*/
+   VkImageUsageFlags old_usage = src->usage;
+   src->usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
 
-   anv_CmdBlitImage(cmd,
-  anv_image_to_handle(image), VK_IMAGE_LAYOUT_GENERAL,
-  copy_image, VK_IMAGE_LAYOUT_GENERAL, 1,
+   anv_CmdBlitImage(anv_cmd_buffer_to_handle(cmd_buffer),
+  anv_image_to_handle(src), VK_IMAGE_LAYOUT_GENERAL,
+  image->image, VK_IMAGE_LAYOUT_GENERAL, 1,
   &(VkImageBlit) {
  .srcSubresource = {
 .aspectMask = aspect,
@@ -113,7 +109,7 @@ anv_dump_image_to_ppm(struct anv_device *device,
  },
  .srcOffsets = {
 { 0, 0, 0 },
-{ extent.width, extent.height, 1 },
+{ image->extent.width, 

[Mesa-dev] [PATCH 2/5] anv/dump: Use anv_minify instead of hand-rolling it

2016-06-17 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_dump.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_dump.c b/src/intel/vulkan/anv_dump.c
index 307e501..ffb892c 100644
--- a/src/intel/vulkan/anv_dump.c
+++ b/src/intel/vulkan/anv_dump.c
@@ -36,11 +36,10 @@ anv_dump_image_to_ppm(struct anv_device *device,
VkDevice vk_device = anv_device_to_handle(device);
MAYBE_UNUSED VkResult result;
 
-   VkExtent2D extent = { image->extent.width, image->extent.height };
-   for (unsigned i = 0; i < miplevel; i++) {
-  extent.width = MAX2(1, extent.width / 2);
-  extent.height = MAX2(1, extent.height / 2);
-   }
+   VkExtent2D extent = {
+  anv_minify(image->extent.width, miplevel),
+  anv_minify(image->extent.height, miplevel),
+   };
 
VkImage copy_image;
result = anv_CreateImage(vk_device,
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 1/5] anv/dump: Take an aspect in dump_image_to_ppm

2016-06-17 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_dump.c| 10 --
 src/intel/vulkan/anv_private.h |  3 ++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_dump.c b/src/intel/vulkan/anv_dump.c
index 63ad2cd..307e501 100644
--- a/src/intel/vulkan/anv_dump.c
+++ b/src/intel/vulkan/anv_dump.c
@@ -30,7 +30,8 @@
 void
 anv_dump_image_to_ppm(struct anv_device *device,
   struct anv_image *image, unsigned miplevel,
-  unsigned array_layer, const char *filename)
+  unsigned array_layer, VkImageAspectFlagBits aspect,
+  const char *filename)
 {
VkDevice vk_device = anv_device_to_handle(device);
MAYBE_UNUSED VkResult result;
@@ -98,12 +99,15 @@ anv_dump_image_to_ppm(struct anv_device *device,
   });
assert(result == VK_SUCCESS);
 
+   VkImageUsageFlags old_usage = image->usage;
+   image->usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
+
anv_CmdBlitImage(cmd,
   anv_image_to_handle(image), VK_IMAGE_LAYOUT_GENERAL,
   copy_image, VK_IMAGE_LAYOUT_GENERAL, 1,
   &(VkImageBlit) {
  .srcSubresource = {
-.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
+.aspectMask = aspect,
 .mipLevel = miplevel,
 .baseArrayLayer = array_layer,
 .layerCount = 1,
@@ -124,6 +128,8 @@ anv_dump_image_to_ppm(struct anv_device *device,
  },
   }, VK_FILTER_NEAREST);
 
+   image->usage = old_usage;
+
ANV_CALL(CmdPipelineBarrier)(cmd,
   VK_PIPELINE_STAGE_TRANSFER_BIT,
   VK_PIPELINE_STAGE_TRANSFER_BIT,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index cd3588a..443fda9 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1831,7 +1831,8 @@ void *anv_lookup_entrypoint(const char *name);
 
 void anv_dump_image_to_ppm(struct anv_device *device,
struct anv_image *image, unsigned miplevel,
-   unsigned array_layer, const char *filename);
+   unsigned array_layer, VkImageAspectFlagBits aspect,
+   const char *filename);
 
 #define ANV_DEFINE_HANDLE_CASTS(__anv_type, __VkType)  \
\
-- 
2.5.0.400.gff86faf

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


Re: [Mesa-dev] [PATCH 05/14] swr: [rasterizer jitter] cleanup supporting different llvm versions

2016-06-17 Thread Emil Velikov
Hi Tim,

Does this commit allows us to have generic generated files or it's
solely workaround the VPERMD intrinsic argument swap ?

On 17 June 2016 at 20:25, Tim Rowley  wrote:

> @@ -31,8 +31,8 @@
>  #pragma warning(disable: 4800 4146 4244 4267 4355 4996)
>  #endif
>
> -#include "jit_api.h"
>  #include "JitManager.h"
> +#include "jit_api.h"
>  #include "fetch_jit.h"
>
Is this due to the DEBUG redefinition ? One might want to add a
comment, to prevent the next person from moving/breaking things.


> @@ -222,35 +222,6 @@ void JitManager::SetupNewModule()
>  mIsModuleFinalized = false;
>  }
>
> -//
> -/// @brief Create new LLVM module from IR.
> -bool JitManager::SetupModuleFromIR(const uint8_t *pIR)
> -{
> -std::unique_ptr pMem = 
> MemoryBuffer::getMemBuffer(StringRef((const char*)pIR), "");
> -
> -SMDiagnostic Err;
> -std::unique_ptr newModule = 
> parseIR(pMem.get()->getMemBufferRef(), Err, mContext);
> -
> -if (newModule == nullptr)
> -{
> -SWR_ASSERT(0, "Parse failed! Check Err for details.");
> -return false;
> -}
> -
> -mpCurrentModule = newModule.get();
> -#if defined(_WIN32)
> -// Needed for MCJIT on windows
> -Triple hostTriple(sys::getProcessTriple());
> -hostTriple.setObjectFormat(Triple::ELF);
> -newModule->setTargetTriple(hostTriple.getTriple());
> -#endif // _WIN32
> -
> -mpExec->addModule(std::move(newModule));
> -mIsModuleFinalized = false;
> -
> -return true;
> -}
> -
>
This (and the respective prototype) seems to be completely unrelated cleanup.


> -#if HAVE_LLVM == 0x306
> +#if HAVE_LLVM <= 0x306
SWR requires LLVM 3.6 so all of these changes are not needed.


>  // llvm 3.7+ reuses "DEBUG" as an enum value
> +#if defined(DEBUG)
>  #pragma push_macro("DEBUG")
>  #undef DEBUG
> +#define _DEBUG_COLLISSION
> +#endif // DEBUG
>
I believe Jose mentioned a slightly better way to handle this (see
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp). Or that does not apply
here ? Also it would be nice to keep it a separate patch as you did
earlier.


>  #ifndef HAVE_LLVM
> -#define HAVE_LLVM (LLVM_VERSION_MAJOR << 8) || LLVM_VERSION_MINOR
> +#define HAVE_LLVM ((LLVM_VERSION_MAJOR << 8) | LLVM_VERSION_MINOR)
>  #endif
>
Unrelated bugfix, stable material.


> @@ -322,6 +322,32 @@ CallInst *Builder::CALL(Value *Callee, const 
> std::initializer_list 
>  return CALLA(Callee, args);
>  }
>
> +#if HAVE_LLVM > 0x306
> +CallInst *Builder::CALL(Value *Callee, Value* arg)
> +{
> +   std::vector args;
> +   args.push_back(arg);
> +   return CALLA(Callee, args);
> +}
> +
> +CallInst *Builder::CALL2(Value *Callee, Value* arg1, Value* arg2)
> +{
> +   std::vector args;
> +   args.push_back(arg1);
> +   args.push_back(arg2);
> +   return CALLA(Callee, args);
> +}
> +
> +CallInst *Builder::CALL3(Value *Callee, Value* arg1, Value* arg2, Value* 
> arg3)
> +{
> +   std::vector args;
> +   args.push_back(arg1);
> +   args.push_back(arg2);
> +   args.push_back(arg3);
> +   return CALLA(Callee, args);
> +}
> +#endif
> +
These seem unused ?


> @@ -726,8 +752,12 @@ Value *Builder::PERMD(Value* a, Value* idx)
>  // use avx2 permute instruction if available
>  if(JM()->mArch.AVX2())
>  {
> -// llvm 3.6.0 swapped the order of the args to vpermd
> -res = VPERMD(idx, a);
> +#if (HAVE_LLVM == 0x306) && (LLVM_VERSION_PATCH == 0)
> +   // llvm 3.6.0 swapped the order of the args to vpermd
> +   res = VPERMD(idx, a);
> +#else
> +   res = VPERMD(a, idx);
> +#endif
Something feels rather fishy here -  atm generator was always creates
one 'version' of the intrinsic and the code directly uses is.

With this patch (taking that I understood the python script correctly):
 - Here we swap the order depending of the LLVM used to compile SWR
 - In the generator (below) we also swap the order.

If the same version of LLVM is used to generate and compile. if not
things just go boom. Considering that this is the gist of the patch,
wouldn't it be nice to have a bit more comprehensive comment be that
here, below and/or in the commit message ?


> @@ -374,8 +374,17 @@ def main():
>  parser.add_argument("--gen_cpp", "-gen_cpp", help="Generate 
> builder_gen.cpp", action="store_true", default=False)
>  parser.add_argument("--gen_x86_h", "-gen_x86_h", help="Generate x86 
> intrinsics. No input is needed.", action="store_true", default=False)
>  parser.add_argument("--gen_x86_cpp", "-gen_x86_cpp", help="Generate x86 
> intrinsics. No input is needed.", action="store_true", default=False)
> +parser.add_argument("--llvm-version", help="What LLVM version to 
> generate for", action="store", default="3.6.0")
> +
>  args = parser.parse_args()
>
> +if args.llvm_version == "3.6.0":
> +# Swap args for VPERMD
> 

Re: [Mesa-dev] [RFC 7/7] radeon: remove screen ref counting

2016-06-17 Thread Rob Herring
On Fri, Jun 17, 2016 at 2:49 PM, Emil Velikov  wrote:
> On 17 June 2016 at 20:05, Rob Herring  wrote:
>> On Fri, Jun 17, 2016 at 1:45 PM, Emil Velikov  
>> wrote:
>>> On 17 June 2016 at 18:45, Rob Herring  wrote:
 Now that the pipe-loader is reference counting the screen creation, it
 is unnecessary to do in it the winsys/driver.
>>
>> [...]
>>
 -static unsigned hash_dev(void *key)
 -{
 -#if defined(PIPE_ARCH_X86_64)
 -   return pointer_to_intptr(key) ^ (pointer_to_intptr(key) >> 32);
 -#else
 -   return pointer_to_intptr(key);
 -#endif
 -}
 -
>>> As you can see above the hashing algo is different for AMDGPU. Not
>>> familiar with the story behind any of this, so hopefully the AMD folk
>>> will give you some insights.
>>
>> They are also hashing the fd in libdrm amdgpu_device_initialize(), so
>> I thought this was redundant (unless you have an old libdrm).
>>
>>> FWIW I'm inclined to keep the winsys/radeon and winsys/amdgpu
>>> differences separate, although not sure if that's possible.
>>
>> I had planned to, but the unref() function ptr in struct radeon_winsys
>> is shared.
>>
>>> Note that vmwgfx has almost(?) identical implementation that one could nuke.
>>
>> I missed that one...
>>
> As did I a few times :-)
>
>>> Last but not least the biggest and a bit annoying part. As-is the
>>> series will break GL/VDPAU interiop - the 'thing' that inspired all
>>> this work initially.
>>
>> Yeah, I've read thru the bug on that now and am not really clear on
>> the magic that happens there to make it work. If you load 2 libraries
>> with an identical symbol in both only 1 version of the symbol will
>> ever be used?
>>
> Precisely. Only the first "version" of the symbol will be used
> regardless if we have 1 or 101 libraries that reference/have it. Thus
> is how we expose/share the existing device.

So why not just export pipe_loader_drm_probe_fd and
pipe_loader_create_screen or perhaps just
pipe_loader_drm_create_screen?

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


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: Export all GLES 3.1 functions in libGLESv2.so

2016-06-17 Thread Mike Gorchak
Please understand me right, we are not talking about desktop hardware and
libraries, only about embedded in case of GL ES. What's common for desktop
usually uncommon for embedded and vice versa. We are currently ship
libraries from many silicon vendors: Imagination RGX, Mali, Vivante, nVidia
- all have GLES 3.1 and 3.2 functions in libGLESv2.so .

Thanks!


On Fri, Jun 17, 2016 at 2:15 PM, Emil Velikov 
wrote:

> On 17 June 2016 at 18:20, Ian Romanick  wrote:
> > From: Ian Romanick 
> >
> > Khronos recommends that the GLES 3.1 library also be called libGLESv2.
> > It also requires that functions be statically linkable from that
> > library.
> >
> > NOTE: Mesa has supported the EGL_KHR_get_all_proc_addresses extension
> > since at least Mesa 10.5, so applications targeting Linux should use
> > eglGetProcAddress to avoid problems running binaries on systems with
> > older, non-GLES 3.1 libGLESv2 libraries.
> >
> Fwiw I'm inclined that we should go the "opposite direction". Namely:
> don't expose new symbols and stick to a predefined version (3.0 being
> the personal favour of choice).
>
> Why, you might ask - for a couple of reasons:
>  - If the list continues to grow programs will have unstable ABI -
> sort of how libGL ended up. Applications are going to link against 3.1
> or later symbols [1], even if they only optionally use them. Thus
> things will quite hairy and fragile.
>  - The other desktop GLES* provider NVIDIA does not export even a
> single GLES 3.1/3.2 entry point (still going through the 3.0 list) in
> their libGLESv2.so.2 binary.
>
> So what to do with GLES (3.0?)/3.1 and later:
>  - tweak the spec so that said version of the API is only supported if
> the implementation can get core symbols via eglGetProcAddress. Be that
> props to the EGL_KHR_get_all_proc_addresses extension or EGL 1.5 [2].
>
> How does this sound ? I guess the best way would be to check with
> other implementations (note Catalyst still seems to be missing
> libGLES*) and choose the more common route ?
>
>
> Regards,
> Emil
>
> [1] Yes, in practise they should use libepoxy or a similar library,
> but from practise we all know that even those tend to have bugs. Sadly
> libepoxy in particular hasn't seen much action in a while.
>
> [2] https://github.com/anholt/libepoxy/issues/21
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 09/14] swr: [rasterizer core] conservative rasterization frontend support

2016-06-17 Thread Rowley, Timothy O
Good spotting.  Whoops, will do that.

-Tim

> On Jun 17, 2016, at 2:59 PM, Emil Velikov  wrote:
> 
> On 17 June 2016 at 20:25, Tim Rowley  wrote:
> 
>> create mode 100644 src/gallium/drivers/swr/rasterizer/core/conservativeRast.h
>> 
> Please mention the new file in the CORE_CXX_SOURCES list in
> Makefile.sources (alphabetically).
> 
> Thanks
> Emil

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


Re: [Mesa-dev] [PATCH 09/14] swr: [rasterizer core] conservative rasterization frontend support

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 20:25, Tim Rowley  wrote:

>  create mode 100644 src/gallium/drivers/swr/rasterizer/core/conservativeRast.h
>
Please mention the new file in the CORE_CXX_SOURCES list in
Makefile.sources (alphabetically).

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


Re: [Mesa-dev] [RFC 7/7] radeon: remove screen ref counting

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 20:05, Rob Herring  wrote:
> On Fri, Jun 17, 2016 at 1:45 PM, Emil Velikov  
> wrote:
>> On 17 June 2016 at 18:45, Rob Herring  wrote:
>>> Now that the pipe-loader is reference counting the screen creation, it
>>> is unnecessary to do in it the winsys/driver.
>
> [...]
>
>>> -static unsigned hash_dev(void *key)
>>> -{
>>> -#if defined(PIPE_ARCH_X86_64)
>>> -   return pointer_to_intptr(key) ^ (pointer_to_intptr(key) >> 32);
>>> -#else
>>> -   return pointer_to_intptr(key);
>>> -#endif
>>> -}
>>> -
>> As you can see above the hashing algo is different for AMDGPU. Not
>> familiar with the story behind any of this, so hopefully the AMD folk
>> will give you some insights.
>
> They are also hashing the fd in libdrm amdgpu_device_initialize(), so
> I thought this was redundant (unless you have an old libdrm).
>
>> FWIW I'm inclined to keep the winsys/radeon and winsys/amdgpu
>> differences separate, although not sure if that's possible.
>
> I had planned to, but the unref() function ptr in struct radeon_winsys
> is shared.
>
>> Note that vmwgfx has almost(?) identical implementation that one could nuke.
>
> I missed that one...
>
As did I a few times :-)

>> Last but not least the biggest and a bit annoying part. As-is the
>> series will break GL/VDPAU interiop - the 'thing' that inspired all
>> this work initially.
>
> Yeah, I've read thru the bug on that now and am not really clear on
> the magic that happens there to make it work. If you load 2 libraries
> with an identical symbol in both only 1 version of the symbol will
> ever be used?
>
Precisely. Only the first "version" of the symbol will be used
regardless if we have 1 or 101 libraries that reference/have it. Thus
is how we expose/share the existing device.

>> To avoid that, we need to promote the fd_hash symbol to public, in
>> combination with the lock (if needed) and ideally a version (for
>> sanity checking). As we do that we should replace all the existing
>> symbols in src/gallium/targets/dri-vdpau.dyn with the new one.
>
> Is there any versioning problem with old libraries to worry about here?
>
Currently foo_dri.so and libvdpau_foo.so from the exact same build are
supported. If you mix them (say DRI from mesa 11.1.1 and VDPAU from
11.2.1) nothing will check and/or warn and you'll get a nasty
corruption and crash down the line. So the version is sort of 'the
cherry on top'. If you're not too sure about it just leave it - we'll
sort it out at a later stage.

>> Plus
>> one should short circuit the nouveau/radeon/amdgpu machinery to avoid
>> intermittently breaking things. Don't know how much we care about that
>> last one ;-)
>
> You mean keep it bisectable, right.
>
As-is your series should (haven't checked fully) build fine and be
perfectly bisectable. I'm was wondering if having both hashing
mechanisms won't stomp one another - thus breaking interop. Then again
I'm not sure why I even mentioned it ... things should work just fine.

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


Re: [Mesa-dev] [Mesa-stable] [PATCH] swr: switch from overriding -march to selecting features

2016-06-17 Thread Rowley, Timothy O

> On Jun 17, 2016, at 2:25 PM, Emil Velikov  wrote:
> 
> On 17 June 2016 at 14:06, Chuck Atkins  wrote:
>> Using these adjusted flags, I can verify SWR running on Intel SandyBridge,
>> Intel Haswell, and AMD Interlagos.
>> 
> Not only building but running as well (on AMD hardware) - nice :-) If
> any issues arise one could tweak things up a bit - but until then this
> looks great.

Chuck’s email is the first feedback we’ve had about running on AMD; good to 
hear it’s working.

> Thanks guys !
> Emil
> P.S. Tim, please keep the Cc: mesa-stable ... line within the commit summary.

Ah, missed that bit of nominating a patch for stable.  Sorry about that.

-Tim

> ___
> mesa-stable mailing list
> mesa-sta...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-stable

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


[Mesa-dev] [PATCH 11/14] swr: [rasterizer core] track whether GS outputs viewport array index

2016-06-17 Thread Tim Rowley
So we can skip the index gather in PA.
---
 src/gallium/drivers/swr/rasterizer/core/state.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h 
b/src/gallium/drivers/swr/rasterizer/core/state.h
index 29048f1..bfa9929 100644
--- a/src/gallium/drivers/swr/rasterizer/core/state.h
+++ b/src/gallium/drivers/swr/rasterizer/core/state.h
@@ -676,6 +676,9 @@ struct SWR_GS_STATE
 // geometry shader emits PrimitiveID
 bool emitsPrimitiveID;
 
+// geometry shader emits ViewportArrayIndex
+bool emitsViewportArrayIndex;
+
 // if true, geometry shader emits a single stream, with separate cut 
buffer.
 // if false, geometry shader emits vertices for multiple streams to the 
stream buffer, with a separate StreamID buffer
 // to map vertices to streams
-- 
1.9.1

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


[Mesa-dev] [PATCH 09/14] swr: [rasterizer core] conservative rasterization frontend support

2016-06-17 Thread Tim Rowley
---
 src/gallium/drivers/swr/rasterizer/core/api.cpp|  13 +-
 src/gallium/drivers/swr/rasterizer/core/clip.h |   4 +-
 .../drivers/swr/rasterizer/core/conservativeRast.h | 120 +++
 src/gallium/drivers/swr/rasterizer/core/context.h  |   2 +
 .../drivers/swr/rasterizer/core/frontend.cpp   | 163 +++--
 src/gallium/drivers/swr/rasterizer/core/frontend.h |  43 +-
 .../drivers/swr/rasterizer/core/rasterizer.h   |   8 +
 src/gallium/drivers/swr/rasterizer/core/state.h|   4 +-
 src/gallium/drivers/swr/rasterizer/core/utils.h|  30 
 9 files changed, 324 insertions(+), 63 deletions(-)
 create mode 100644 src/gallium/drivers/swr/rasterizer/core/conservativeRast.h

diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp 
b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 22a94fb..cec4519 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -780,10 +780,7 @@ void SetupPipeline(DRAW_CONTEXT *pDC)
 const bool bMultisampleEnable = ((rastState.sampleCount > 
SWR_MULTISAMPLE_1X) || rastState.forcedSampleCount) ? 1 : 0;
 const uint32_t centroid = ((psState.barycentricsMask & 
SWR_BARYCENTRIC_CENTROID_MASK) > 0) ? 1 : 0;
 const uint32_t canEarlyZ = (psState.forceEarlyZ || 
(!psState.writesODepth && !psState.usesSourceDepth && !psState.usesUAV)) ? 1 : 
0;
-
-// currently only support 'normal' input coverage
-SWR_ASSERT(psState.inputCoverage == SWR_INPUT_COVERAGE_NORMAL ||
-   psState.inputCoverage == SWR_INPUT_COVERAGE_NONE);
+const uint32_t inputCoverage = (psState.inputCoverage != 
SWR_INPUT_COVERAGE_NONE);
  
 SWR_BARYCENTRICS_MASK barycentricsMask = 
(SWR_BARYCENTRICS_MASK)psState.barycentricsMask;
 
@@ -795,20 +792,20 @@ void SetupPipeline(DRAW_CONTEXT *pDC)
 {
 // always need to generate I & J per sample for Z interpolation
 barycentricsMask = (SWR_BARYCENTRICS_MASK)(barycentricsMask | 
SWR_BARYCENTRIC_PER_SAMPLE_MASK);
-backendFuncs.pfnBackend = 
gBackendPixelRateTable[rastState.sampleCount][rastState.samplePattern][psState.inputCoverage][centroid][forcedSampleCount][canEarlyZ];
+backendFuncs.pfnBackend = 
gBackendPixelRateTable[rastState.sampleCount][rastState.samplePattern][inputCoverage][centroid][forcedSampleCount][canEarlyZ];
 }
 else
 {
 // always need to generate I & J per pixel for Z interpolation
 barycentricsMask = (SWR_BARYCENTRICS_MASK)(barycentricsMask | 
SWR_BARYCENTRIC_PER_PIXEL_MASK);
-backendFuncs.pfnBackend = 
gBackendSingleSample[psState.inputCoverage][centroid][canEarlyZ];
+backendFuncs.pfnBackend = 
gBackendSingleSample[inputCoverage][centroid][canEarlyZ];
 }
 break;
 case SWR_SHADING_RATE_SAMPLE:
 SWR_ASSERT(rastState.samplePattern == SWR_MSAA_STANDARD_PATTERN);
 // always need to generate I & J per sample for Z interpolation
 barycentricsMask = (SWR_BARYCENTRICS_MASK)(barycentricsMask | 
SWR_BARYCENTRIC_PER_SAMPLE_MASK);
-backendFuncs.pfnBackend = 
gBackendSampleRateTable[rastState.sampleCount][psState.inputCoverage][centroid][canEarlyZ];
+backendFuncs.pfnBackend = 
gBackendSampleRateTable[rastState.sampleCount][inputCoverage][centroid][canEarlyZ];
 break;
 default:
 SWR_ASSERT(0 && "Invalid shading rate");
@@ -833,7 +830,7 @@ void SetupPipeline(DRAW_CONTEXT *pDC)
 break;
 default:
 pState->pfnProcessPrims = ClipTriangles;
-pfnBinner = BinTriangles;
+pfnBinner = GetBinTrianglesFunc((rastState.conservativeRast > 0));
 break;
 };
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/clip.h 
b/src/gallium/drivers/swr/rasterizer/core/clip.h
index 67a4c4f..1a6fc6d 100644
--- a/src/gallium/drivers/swr/rasterizer/core/clip.h
+++ b/src/gallium/drivers/swr/rasterizer/core/clip.h
@@ -385,7 +385,7 @@ public:
 PRIMITIVE_TOPOLOGY clipTopology = TOP_UNKNOWN;
 if (NumVertsPerPrim == 3)
 {
-pfnBinFunc = BinTriangles;
+pfnBinFunc = 
GetBinTrianglesFunc((pa.pDC->pState->state.rastState.conservativeRast > 0));
 clipTopology = TOP_TRIANGLE_FAN;
 
 // so that the binner knows to bloat wide points later
@@ -519,7 +519,7 @@ public:
 pfnBinner = BinLines;
 break;
 default:
-pfnBinner = BinTriangles;
+pfnBinner = 
GetBinTrianglesFunc((pa.pDC->pState->state.rastState.conservativeRast > 0));
 break;
 };
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/conservativeRast.h 
b/src/gallium/drivers/swr/rasterizer/core/conservativeRast.h
new file mode 100644
index 000..f8aa8df
--- /dev/null
+++ 

[Mesa-dev] [PATCH 12/14] swr: [rasterizer jitter] add support for component packing for 'odd' formats

2016-06-17 Thread Tim Rowley
Add early-out if no components are enabled. Add asserts.
---
 .../drivers/swr/rasterizer/jitter/fetch_jit.cpp| 27 ++
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp 
b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
index 1b9b141..ff27130 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
@@ -270,6 +270,9 @@ void FetchJit::JitLoadVertices(const FETCH_COMPILE_STATE 
, Value* fet
 uint32_tnumComponents = info.numComps;
 uint32_t bpc = info.bpp / info.numComps;  ///@todo Code below assumes 
all components are same size. Need to fix.
 
+// load path doesn't support component packing
+SWR_ASSERT(ied.ComponentPacking == ComponentEnable::XYZW, "Fetch load 
path doesn't support component packing.");
+
 vectors.clear();
 
 Value *vCurIndices;
@@ -700,6 +703,13 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE 
, Value* f
 for(uint32_t nInputElt = 0; nInputElt < fetchState.numAttribs; ++nInputElt)
 {
 const INPUT_ELEMENT_DESC& ied = fetchState.layout[nInputElt];
+
+// skip element if all components are disabled
+if (ied.ComponentPacking == ComponentEnable::NONE)
+{
+continue;
+}
+
 const SWR_FORMAT_INFO  = GetFormatInfo((SWR_FORMAT)ied.Format);
 SWR_ASSERT((info.bpp != 0), "Unsupported format in 
JitGatherVertices.");
 uint32_t bpc = info.bpp / info.numComps;  ///@todo Code below assumes 
all components are same size. Need to fix.
@@ -790,14 +800,23 @@ void FetchJit::JitGatherVertices(const 
FETCH_COMPILE_STATE , Value* f
 // Special gather/conversion for formats without equal component sizes
 if (IsOddFormat((SWR_FORMAT)ied.Format))
 {
-// Only full 4 component fetch is supported for odd formats
-SWR_ASSERT(compMask == XYZW);
 Value* pResults[4];
 CreateGatherOddFormats((SWR_FORMAT)ied.Format, pStreamBase, 
vOffsets, pResults);
 ConvertFormat((SWR_FORMAT)ied.Format, pResults);
 
-StoreVertexElements(pVtxOut, outputElt++, 4, pResults);
-currentVertexElement = 0;
+for (uint32_t c = 0; c < 4; ++c)
+{
+if (isComponentEnabled(compMask, c))
+{
+vVertexElements[currentVertexElement++] = pResults[c];
+if (currentVertexElement > 3)
+{
+StoreVertexElements(pVtxOut, outputElt++, 4, 
vVertexElements);
+// reset to the next vVertexElement to output
+currentVertexElement = 0;
+}
+}
+}
 }
 else if(info.type[0] == SWR_TYPE_FLOAT)
 {
-- 
1.9.1

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


[Mesa-dev] [PATCH 05/14] swr: [rasterizer jitter] cleanup supporting different llvm versions

2016-06-17 Thread Tim Rowley
---
 src/gallium/drivers/swr/Makefile.am|  2 +
 .../drivers/swr/rasterizer/jitter/JitManager.cpp   | 33 +---
 .../drivers/swr/rasterizer/jitter/JitManager.h | 22 ---
 .../drivers/swr/rasterizer/jitter/blend_jit.cpp| 13 ++-
 .../drivers/swr/rasterizer/jitter/builder_misc.cpp | 44 ++
 .../drivers/swr/rasterizer/jitter/builder_misc.h   |  8 +++-
 .../drivers/swr/rasterizer/jitter/fetch_jit.cpp| 18 ++---
 .../jitter/scripts/gen_llvm_ir_macros.py   | 11 +-
 .../swr/rasterizer/jitter/streamout_jit.cpp|  9 +
 9 files changed, 84 insertions(+), 76 deletions(-)

diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index d896154..92e03fb 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -98,6 +98,7 @@ rasterizer/jitter/builder_x86.h: 
rasterizer/jitter/scripts/gen_llvm_ir_macros.py
$(MKDIR_GEN)
$(PYTHON_GEN) \
$(srcdir)/rasterizer/jitter/scripts/gen_llvm_ir_macros.py \
+   --llvm-version $(LLVM_VERSION) \
--output rasterizer/jitter/builder_x86.h \
--gen_x86_h
 
@@ -105,6 +106,7 @@ rasterizer/jitter/builder_x86.cpp: 
rasterizer/jitter/scripts/gen_llvm_ir_macros.
$(MKDIR_GEN)
$(PYTHON_GEN) \
$(srcdir)/rasterizer/jitter/scripts/gen_llvm_ir_macros.py \
+   --llvm-version $(LLVM_VERSION) \
--output rasterizer/jitter/builder_x86.cpp \
--gen_x86_cpp
 
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp 
b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp
index 4bbd9ad..03b616e 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp
@@ -31,8 +31,8 @@
 #pragma warning(disable: 4800 4146 4244 4267 4355 4996)
 #endif
 
-#include "jit_api.h"
 #include "JitManager.h"
+#include "jit_api.h"
 #include "fetch_jit.h"
 
 #if defined(_WIN32)
@@ -222,35 +222,6 @@ void JitManager::SetupNewModule()
 mIsModuleFinalized = false;
 }
 
-//
-/// @brief Create new LLVM module from IR.
-bool JitManager::SetupModuleFromIR(const uint8_t *pIR)
-{
-std::unique_ptr pMem = 
MemoryBuffer::getMemBuffer(StringRef((const char*)pIR), "");
-
-SMDiagnostic Err;
-std::unique_ptr newModule = parseIR(pMem.get()->getMemBufferRef(), 
Err, mContext);
-
-if (newModule == nullptr)
-{
-SWR_ASSERT(0, "Parse failed! Check Err for details.");
-return false;
-}
-
-mpCurrentModule = newModule.get();
-#if defined(_WIN32)
-// Needed for MCJIT on windows
-Triple hostTriple(sys::getProcessTriple());
-hostTriple.setObjectFormat(Triple::ELF);
-newModule->setTargetTriple(hostTriple.getTriple());
-#endif // _WIN32
-
-mpExec->addModule(std::move(newModule));
-mIsModuleFinalized = false;
-
-return true;
-}
-
 
 //
 /// @brief Dump function x86 assembly to file.
@@ -281,7 +252,7 @@ void JitManager::DumpAsm(Function* pFunction, const char* 
fileName)
 sprintf(fName, "%s.%s.asm", funcName, fileName);
 #endif
 
-#if HAVE_LLVM == 0x306
+#if HAVE_LLVM <= 0x306
 raw_fd_ostream fd(fName, EC, llvm::sys::fs::F_None);
 formatted_raw_ostream filestream(fd);
 #else
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.h 
b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.h
index 14ba893..aaedf89 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.h
+++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.h
@@ -29,16 +29,16 @@
 **/
 #pragma once
 
-#include "common/os.h"
-#include "common/isa.hpp"
-
 #if defined(_WIN32)
 #pragma warning(disable : 4146 4244 4267 4800 4996)
 #endif
 
 // llvm 3.7+ reuses "DEBUG" as an enum value
+#if defined(DEBUG)
 #pragma push_macro("DEBUG")
 #undef DEBUG
+#define _DEBUG_COLLISSION
+#endif // DEBUG
 
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Instructions.h"
@@ -54,7 +54,7 @@
 #endif
 
 #ifndef HAVE_LLVM
-#define HAVE_LLVM (LLVM_VERSION_MAJOR << 8) || LLVM_VERSION_MINOR
+#define HAVE_LLVM ((LLVM_VERSION_MAJOR << 8) | LLVM_VERSION_MINOR)
 #endif
 
 #include "llvm/IR/Verifier.h"
@@ -64,10 +64,14 @@
 
 #include "llvm/Analysis/Passes.h"
 
-#if HAVE_LLVM == 0x306
+#if HAVE_LLVM <= 0x306
 #include "llvm/PassManager.h"
+using FunctionPassManager = llvm::FunctionPassManager;
+using PassManager = llvm::PassManager;
 #else
 #include "llvm/IR/LegacyPassManager.h"
+using FunctionPassManager = llvm::legacy::FunctionPassManager;
+using PassManager = llvm::legacy::PassManager;
 #endif
 
 #include "llvm/CodeGen/Passes.h"
@@ -79,7 +83,14 @@
 #include "llvm/Support/Host.h"
 
 
+#if 

[Mesa-dev] [PATCH 08/14] swr: [rasterizer core] stop single threaded crash exit crash

2016-06-17 Thread Tim Rowley
Function static destructors were getting called by exit
handlers before context teardown.
---
 src/gallium/drivers/swr/rasterizer/core/api.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp 
b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 2e6f8b3..22a94fb 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -181,6 +181,8 @@ void WakeAllThreads(SWR_CONTEXT *pContext)
 pContext->FifosNotEmpty.notify_all();
 }
 
+static TileSet gSingleThreadLockedTiles;
+
 template
 void QueueWork(SWR_CONTEXT *pContext)
 {
@@ -213,10 +215,9 @@ void QueueWork(SWR_CONTEXT *pContext)
 
 if (IsDraw)
 {
-static TileSet lockedTiles;
 uint64_t curDraw[2] = { pContext->pCurDrawContext->drawId, 
pContext->pCurDrawContext->drawId };
 WorkOnFifoFE(pContext, 0, curDraw[0]);
-WorkOnFifoBE(pContext, 0, curDraw[1], lockedTiles, 0, 0);
+WorkOnFifoBE(pContext, 0, curDraw[1], gSingleThreadLockedTiles, 0, 
0);
 }
 else
 {
-- 
1.9.1

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


[Mesa-dev] [PATCH 07/14] swr: [rasterizer jitter] small fetch jit cleanup

2016-06-17 Thread Tim Rowley
Handle SGV stores separate from the stream fetch code.

Because of this change, there is a potential to jit an extra unused store.
---
 .../drivers/swr/rasterizer/jitter/fetch_jit.cpp| 170 +
 1 file changed, 36 insertions(+), 134 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp 
b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
index ec873a1..1b9b141 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
@@ -62,12 +62,11 @@ struct FetchJit : public Builder
 // package up Shuffle*bpcGatherd args into a tuple for convenience
 typedef std::tuple 
Shuffle8bpcArgs;
+const uint32_t(&)[4]> Shuffle8bpcArgs;
 void Shuffle8bpcGatherd(Shuffle8bpcArgs );
 
 typedef std::tuple Shuffle16bpcArgs;
+uint32_t&, uint32_t&, const ComponentEnable, const 
ComponentControl(&)[4], Value*(&)[4]> Shuffle16bpcArgs;
 void Shuffle16bpcGather(Shuffle16bpcArgs );
 
 void StoreVertexElements(Value* pVtxOut, const uint32_t outputElt, const 
uint32_t numEltsToStore, Value* ()[4]);
@@ -83,6 +82,7 @@ struct FetchJit : public Builder
 void CreateGatherOddFormats(SWR_FORMAT format, Value* pBase, Value* 
offsets, Value* result[4]);
 void ConvertFormat(SWR_FORMAT format, Value *texels[4]);
 
+void StoreSGVs(const FETCH_COMPILE_STATE& fetchState, Value* pFetchInfo, 
Value* pVtxOut);
 };
 
 Function* FetchJit::Create(const FETCH_COMPILE_STATE& fetchState)
@@ -175,6 +175,9 @@ Function* FetchJit::Create(const FETCH_COMPILE_STATE& 
fetchState)
 (fetchState.bDisableVGATHER) ? JitLoadVertices(fetchState, fetchInfo, 
streams, vIndices, pVtxOut)
  : JitGatherVertices(fetchState, fetchInfo, 
streams, vIndices, pVtxOut);
 
+// Store out SGVs if enabled
+StoreSGVs(fetchState, fetchInfo, pVtxOut);
+
 RET_VOID();
 
 JitManager::DumpToFile(fetch, "src");
@@ -212,11 +215,29 @@ Function* FetchJit::Create(const FETCH_COMPILE_STATE& 
fetchState)
 return fetch;
 }
 
+// store vertex ID and instance ID if enabled
+void FetchJit::StoreSGVs(const FETCH_COMPILE_STATE& fetchState, Value* 
pFetchInfo, Value* pVtxOut)
+{
+if (fetchState.InstanceIdEnable)
+{
+Value* pId = BITCAST(VBROADCAST(LOAD(GEP(pFetchInfo, { 0, 
SWR_FETCH_CONTEXT_CurInstance }))), mSimdFP32Ty);
+Value* pDest = GEP(pVtxOut, C(fetchState.InstanceIdElementOffset * 4 + 
fetchState.InstanceIdComponentNumber), "instanceID");
+STORE(pId, pDest);
+}
+
+if (fetchState.VertexIdEnable)
+{
+Value* pId = BITCAST(LOAD(GEP(pFetchInfo, { 0, 
SWR_FETCH_CONTEXT_VertexID })), mSimdFP32Ty);
+Value* pDest = GEP(pVtxOut, C(fetchState.VertexIdElementOffset * 4 + 
fetchState.VertexIdComponentNumber), "vertexID");
+STORE(pId, pDest);
+}
+}
+
 //
 /// @brief Loads attributes from memory using LOADs, shuffling the 
 /// components into SOA form. 
 /// *Note* currently does not support component control,
-/// component packing, instancing, InstanceID SGVs, or VertexID SGVs
+/// component packing, instancing
 /// @param fetchState - info about attributes to be fetched from memory
 /// @param streams - value pointer to the current vertex stream
 /// @param vIndices - vector value of indices to load
@@ -775,23 +796,6 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE 
, Value* f
 CreateGatherOddFormats((SWR_FORMAT)ied.Format, pStreamBase, 
vOffsets, pResults);
 ConvertFormat((SWR_FORMAT)ied.Format, pResults);
 
-// check for InstanceID SGV
-if (fetchState.InstanceIdEnable && 
(fetchState.InstanceIdElementOffset == nInputElt))
-{
-SWR_ASSERT(fetchState.InstanceIdComponentNumber < 
(sizeof(pResults) / sizeof(pResults[0])));
-
-// Load a SIMD of InstanceIDs
-pResults[fetchState.InstanceIdComponentNumber] = 
VBROADCAST(LOAD(GEP(fetchInfo, { 0, SWR_FETCH_CONTEXT_CurInstance })));// 
InstanceID
-}
-// check for VertexID SGV
-else if (fetchState.VertexIdEnable && 
(fetchState.VertexIdElementOffset == nInputElt))
-{
-SWR_ASSERT(fetchState.VertexIdComponentNumber < 
(sizeof(pResults) / sizeof(pResults[0])));
-
-// Load a SIMD of VertexIDs
-pResults[fetchState.VertexIdComponentNumber] = 

[Mesa-dev] [PATCH 10/14] swr: [rasterizer core] GS viewport array index attribute

2016-06-17 Thread Tim Rowley
Only adds the attribute mapping to the jitter; no implementation yet.
---
 src/gallium/drivers/swr/rasterizer/core/knobs.h | 2 +-
 src/gallium/drivers/swr/rasterizer/core/state.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/knobs.h 
b/src/gallium/drivers/swr/rasterizer/core/knobs.h
index 2629276..bac2525 100644
--- a/src/gallium/drivers/swr/rasterizer/core/knobs.h
+++ b/src/gallium/drivers/swr/rasterizer/core/knobs.h
@@ -77,7 +77,7 @@
 #define KNOB_NUM_STREAMS32
 
 // Maximum supported number of attributes per vertex
-#define KNOB_NUM_ATTRIBUTES 38
+#define KNOB_NUM_ATTRIBUTES 39
 
 // Maximum supported active viewports and scissors
 #define KNOB_NUM_VIEWPORTS_SCISSORS 16
diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h 
b/src/gallium/drivers/swr/rasterizer/core/state.h
index 05735b3..29048f1 100644
--- a/src/gallium/drivers/swr/rasterizer/core/state.h
+++ b/src/gallium/drivers/swr/rasterizer/core/state.h
@@ -197,6 +197,7 @@ enum SWR_OUTER_TESSFACTOR_ID
 #define VERTEX_CLIPCULL_DIST_LO_SLOT 35 // VS writes lower 4 clip/cull dist
 #define VERTEX_CLIPCULL_DIST_HI_SLOT 36 // VS writes upper 4 clip/cull dist
 #define VERTEX_POINT_SIZE_SLOT 37   // VS writes point size here
+#define VERTEX_VIEWPORT_ARRAY_INDEX_SLOT 38
 // SoAoSoA
 struct simdvertex
 {
-- 
1.9.1

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


[Mesa-dev] [PATCH 06/14] swr: [rasterizer core] remove old comment

2016-06-17 Thread Tim Rowley
---
 src/gallium/drivers/swr/rasterizer/core/frontend.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp 
b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
index 6e1bc0e..f86f8fa 100644
--- a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
@@ -1613,7 +1613,6 @@ void BinTriangles(
 const SWR_GS_STATE& gsState = state.gsState;
 MacroTileMgr *pTileMgr = pDC->pTileMgr;
 
-// Simple wireframe mode for debugging purposes only
 
 simdscalar vRecipW0 = _simd_set1_ps(1.0f);
 simdscalar vRecipW1 = _simd_set1_ps(1.0f);
-- 
1.9.1

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


[Mesa-dev] [PATCH 04/14] swr: [rasterizer jitter] unitialized component fix in fetch jit

2016-06-17 Thread Tim Rowley
Was trying to store an extra uninitialized component.
Only affects component packing, which isn't enabled (yet).
---
 src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp 
b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
index 71f1a3a..bae0f24 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
@@ -1073,7 +1073,7 @@ void FetchJit::JitGatherVertices(const 
FETCH_COMPILE_STATE , Value* f
 
 // if we have a partially filled vVertexElement struct, output it
 if(currentVertexElement > 0){
-StoreVertexElements(pVtxOut, outputElt++, currentVertexElement+1, 
vVertexElements);
+StoreVertexElements(pVtxOut, outputElt++, currentVertexElement, 
vVertexElements);
 }
 }
 
-- 
1.9.1

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


[Mesa-dev] [PATCH 13/14] swr: [rasterizer core] use wrap-around safe compares for dependency checking

2016-06-17 Thread Tim Rowley
Move drawIDs from 64-bit to 32-bit to increase perf.
---
 src/gallium/drivers/swr/rasterizer/core/api.cpp|  4 +-
 src/gallium/drivers/swr/rasterizer/core/context.h  |  6 +--
 .../drivers/swr/rasterizer/core/ringbuffer.h   |  8 ++--
 .../drivers/swr/rasterizer/core/threads.cpp| 54 +-
 src/gallium/drivers/swr/rasterizer/core/threads.h  |  6 +--
 .../drivers/swr/rasterizer/scripts/knob_defs.py|  5 +-
 6 files changed, 46 insertions(+), 37 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp 
b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index cec4519..b63d547 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -215,13 +215,13 @@ void QueueWork(SWR_CONTEXT *pContext)
 
 if (IsDraw)
 {
-uint64_t curDraw[2] = { pContext->pCurDrawContext->drawId, 
pContext->pCurDrawContext->drawId };
+uint32_t curDraw[2] = { pContext->pCurDrawContext->drawId, 
pContext->pCurDrawContext->drawId };
 WorkOnFifoFE(pContext, 0, curDraw[0]);
 WorkOnFifoBE(pContext, 0, curDraw[1], gSingleThreadLockedTiles, 0, 
0);
 }
 else
 {
-uint64_t curDispatch = pContext->pCurDrawContext->drawId;
+uint32_t curDispatch = pContext->pCurDrawContext->drawId;
 WorkOnCompute(pContext, 0, curDispatch);
 }
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h 
b/src/gallium/drivers/swr/rasterizer/core/context.h
index 3204352..512a112 100644
--- a/src/gallium/drivers/swr/rasterizer/core/context.h
+++ b/src/gallium/drivers/swr/rasterizer/core/context.h
@@ -381,13 +381,13 @@ struct DRAW_STATE
 struct DRAW_CONTEXT
 {
 SWR_CONTEXT*pContext;
-uint64_tdrawId;
-union
+uint32_tdrawId;
+   uint32_tdependency;
+   union
 {
 MacroTileMgr*   pTileMgr;
 DispatchQueue*  pDispatch;  // Queue for thread groups. (isCompute)
 };
-uint64_tdependency;
 DRAW_STATE* pState;
 CachingArena*   pArena;
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h 
b/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
index b9076de..97f75c6 100644
--- a/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
+++ b/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
@@ -90,13 +90,13 @@ public:
 return (numEnqueued == mNumEntries);
 }
 
-INLINE uint64_t GetTail() volatile { return mRingTail; }
-INLINE uint64_t GetHead() volatile { return mRingHead; }
+INLINE uint32_t GetTail() volatile { return mRingTail; }
+INLINE uint32_t GetHead() volatile { return mRingHead; }
 
 protected:
 T* mpRingBuffer;
 uint32_t mNumEntries;
 
-OSALIGNLINE(volatile uint64_t) mRingHead;  // Consumer Counter
-OSALIGNLINE(volatile uint64_t) mRingTail;  // Producer Counter
+OSALIGNLINE(volatile uint32_t) mRingHead;  // Consumer Counter
+OSALIGNLINE(volatile uint32_t) mRingTail;  // Producer Counter
 };
diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp 
b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
index 17bf616..a2c4e56 100644
--- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
@@ -294,22 +294,30 @@ void bindThread(uint32_t threadId, uint32_t procGroupId = 
0, bool bindProcGroup=
 }
 
 INLINE
-uint64_t GetEnqueuedDraw(SWR_CONTEXT *pContext)
+uint32_t GetEnqueuedDraw(SWR_CONTEXT *pContext)
 {
 return pContext->dcRing.GetHead();
 }
 
 INLINE
-DRAW_CONTEXT *GetDC(SWR_CONTEXT *pContext, uint64_t drawId)
+DRAW_CONTEXT *GetDC(SWR_CONTEXT *pContext, uint32_t drawId)
 {
 return >dcRing[(drawId-1) % KNOB_MAX_DRAWS_IN_FLIGHT];
 }
 
+INLINE
+bool IDComparesLess(uint32_t a, uint32_t b)
+{
+   // Use signed delta to ensure that wrap-around to 0 is correctly 
handled.
+   int32_t delta = int32_t(a - b);
+   return (delta < 0);
+}
+
 // returns true if dependency not met
 INLINE
-bool CheckDependency(SWR_CONTEXT *pContext, DRAW_CONTEXT *pDC, uint64_t 
lastRetiredDraw)
+bool CheckDependency(SWR_CONTEXT *pContext, DRAW_CONTEXT *pDC, uint32_t 
lastRetiredDraw)
 {
-return (pDC->dependency > lastRetiredDraw);
+return IDComparesLess(lastRetiredDraw, pDC->dependency);
 }
 
 // inlined-only version
@@ -345,11 +353,11 @@ int64_t CompleteDrawContext(SWR_CONTEXT* pContext, 
DRAW_CONTEXT* pDC)
 return CompleteDrawContextInl(pContext, pDC);
 }
 
-INLINE bool FindFirstIncompleteDraw(SWR_CONTEXT* pContext, uint64_t& 
curDrawBE, uint64_t& drawEnqueued)
+INLINE bool FindFirstIncompleteDraw(SWR_CONTEXT* pContext, uint32_t& 
curDrawBE, uint32_t& drawEnqueued)
 {
 // increment our current draw id to the first incomplete draw
 drawEnqueued = GetEnqueuedDraw(pContext);
-while (curDrawBE < drawEnqueued)
+while (IDComparesLess(curDrawBE, drawEnqueued))
 {
 DRAW_CONTEXT *pDC = 

[Mesa-dev] [PATCH 14/14] swr: [rasterizer core] fix dependency bug

2016-06-17 Thread Tim Rowley
Never be dependent on "draw 0", instead have a bool that makes the draw
dependent on the previous draw or not dependent at all.
---
 src/gallium/drivers/swr/rasterizer/core/api.cpp  | 6 +++---
 src/gallium/drivers/swr/rasterizer/core/context.h| 6 +++---
 src/gallium/drivers/swr/rasterizer/core/ringbuffer.h | 8 
 src/gallium/drivers/swr/rasterizer/core/threads.cpp  | 2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp 
b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index b63d547..edde918 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -322,7 +322,7 @@ DRAW_CONTEXT* GetDrawContext(SWR_CONTEXT *pContext, bool 
isSplitDraw = false)
 
 SWR_ASSERT(pCurDrawContext->pArena->IsEmpty() == true);
 
-pCurDrawContext->dependency = 0;
+pCurDrawContext->dependent = false;
 pCurDrawContext->pContext = pContext;
 pCurDrawContext->isCompute = false; // Dispatch has to set this to 
true.
 
@@ -406,7 +406,7 @@ void SwrSync(HANDLE hContext, PFN_CALLBACK_FUNC pfnFunc, 
uint64_t userData, uint
 pDC->FeWork.desc.sync.userData3 = userData3;
 
 // cannot execute until all previous draws have completed
-pDC->dependency = pDC->drawId - 1;
+pDC->dependent = true;
 
 //enqueue
 QueueDraw(pContext);
@@ -1500,7 +1500,7 @@ void SwrGetStats(
 pDC->FeWork.desc.queryStats.pStats = pStats;
 
 // cannot execute until all previous draws have completed
-pDC->dependency = pDC->drawId - 1;
+pDC->dependent = true;
 
 //enqueue
 QueueDraw(pContext);
diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h 
b/src/gallium/drivers/swr/rasterizer/core/context.h
index 512a112..d83490f 100644
--- a/src/gallium/drivers/swr/rasterizer/core/context.h
+++ b/src/gallium/drivers/swr/rasterizer/core/context.h
@@ -381,8 +381,6 @@ struct DRAW_STATE
 struct DRAW_CONTEXT
 {
 SWR_CONTEXT*pContext;
-uint32_tdrawId;
-   uint32_tdependency;
union
 {
 MacroTileMgr*   pTileMgr;
@@ -391,7 +389,9 @@ struct DRAW_CONTEXT
 DRAW_STATE* pState;
 CachingArena*   pArena;
 
-boolisCompute;  // Is this DC a compute context?
+   uint32_tdrawId;
+booldependent;
+   boolisCompute;  // Is this DC a compute context?
 boolcleanupState;   // True if this is the last draw using an 
entry in the state ring.
 volatile bool   doneFE; // Is FE work done for this draw?
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h 
b/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
index 97f75c6..fa6feef 100644
--- a/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
+++ b/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
@@ -46,6 +46,7 @@ public:
 void Init(uint32_t numEntries)
 {
 SWR_ASSERT(numEntries > 0);
+   SWR_ASSERT(((1ULL << 32) % numEntries) == 0, "%d is not evenly 
divisible into 2 ^ 32.  Wrap errors will occur!", numEntries);
 mNumEntries = numEntries;
 mpRingBuffer = (T*)AlignedMalloc(sizeof(T)*numEntries, 64);
 SWR_ASSERT(mpRingBuffer != nullptr);
@@ -67,6 +68,8 @@ public:
 INLINE void Enqueue()
 {
 mRingHead++; // There's only one producer.
+   // Assert to find wrap-around cases, NEVER ENABLE DURING 
CHECKIN!!
+// SWR_REL_ASSERT(mRingHead);
 }
 
 INLINE void Dequeue()
@@ -81,10 +84,7 @@ public:
 
 INLINE bool IsFull()
 {
-///@note We don't handle wrap case due to using 64-bit indices.
-///  It would take 11 million years to wrap at 50,000 DCs per sec.
-///  If we used 32-bit indices then its about 23 hours to wrap.
-uint64_t numEnqueued = GetHead() - GetTail();
+uint32_t numEnqueued = GetHead() - GetTail();
 SWR_ASSERT(numEnqueued <= mNumEntries);
 
 return (numEnqueued == mNumEntries);
diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp 
b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
index a2c4e56..13ab92e 100644
--- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
@@ -317,7 +317,7 @@ bool IDComparesLess(uint32_t a, uint32_t b)
 INLINE
 bool CheckDependency(SWR_CONTEXT *pContext, DRAW_CONTEXT *pDC, uint32_t 
lastRetiredDraw)
 {
-return IDComparesLess(lastRetiredDraw, pDC->dependency);
+return pDC->dependent && IDComparesLess(lastRetiredDraw, pDC->drawId - 1);
 }
 
 // inlined-only version
-- 
1.9.1

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


[Mesa-dev] [PATCH 01/14] swr: [rasterizer common] workaround clang for windows __cpuid() bug

2016-06-17 Thread Tim Rowley
---
 src/gallium/drivers/swr/rasterizer/common/isa.hpp | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/common/isa.hpp 
b/src/gallium/drivers/swr/rasterizer/common/isa.hpp
index ef38179..31ea787 100644
--- a/src/gallium/drivers/swr/rasterizer/common/isa.hpp
+++ b/src/gallium/drivers/swr/rasterizer/common/isa.hpp
@@ -30,7 +30,11 @@
 #include 
 #include 
 
-#if defined(_WIN32)
+// Clang for Windows does supply an intrin.h with __cpuid intrinsics, 
however...
+// It seems to not realize that a write to "b" (ebx) will kill the value in 
rbx.
+// This attempts to use the "native" clang / gcc intrinsics instead of the 
windows
+// compatible ones.
+#if defined(_MSC_VER) && !defined(__clang__)
 #include 
 #else
 #include 
@@ -128,7 +132,7 @@ private:
 
 // Calling __cpuid with 0x0 as the function_id argument
 // gets the number of the highest valid function ID.
-#if defined(_WIN32)
+#if defined(_MSC_VER) && !defined(__clang__)
 __cpuid(cpui.data(), 0);
 nIds_ = cpui[0];
 #else
@@ -137,8 +141,8 @@ private:
 
 for (int i = 0; i <= nIds_; ++i)
 {
-#if defined(_WIN32)
-__cpuidex(cpui.data(), i, 0);
+#if defined(_MSC_VER) && !defined(__clang__)
+   __cpuidex(cpui.data(), i, 0);
 #else
 int *data = cpui.data();
 __cpuid_count(i, 0, data[0], data[1], data[2], data[3]);
@@ -178,8 +182,8 @@ private:
 
 // Calling __cpuid with 0x8000 as the function_id argument
 // gets the number of the highest valid extended ID.
-#if defined(_WIN32)
-__cpuid(cpui.data(), 0x8000);
+#if defined(_MSC_VER) && !defined(__clang__)
+   __cpuid(cpui.data(), 0x8000);
 nExIds_ = cpui[0];
 #else
 nExIds_ = __get_cpuid_max(0x8000, NULL);
@@ -190,8 +194,8 @@ private:
 
 for (unsigned i = 0x8000; i <= nExIds_; ++i)
 {
-#if defined(_WIN32)
-__cpuidex(cpui.data(), i, 0);
+#if defined(_MSC_VER) && !defined(__clang__)
+   __cpuidex(cpui.data(), i, 0);
 #else
 int *data = cpui.data();
 __cpuid_count(i, 0, data[0], data[1], data[2], data[3]);
-- 
1.9.1

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


[Mesa-dev] [PATCH 00/14] update swr rasterizer

2016-06-17 Thread Tim Rowley
Mostly bug fixes and cleanups.

Tim Rowley (14):
  swr: [rasterizer common] workaround clang for windows __cpuid() bug
  swr: [rasterizer common] fix include for Intel compiler
  swr: [rasterizer] add support for building avx512 version
  swr: [rasterizer jitter] unitialized component fix in fetch jit
  swr: [rasterizer jitter] cleanup supporting different llvm versions
  swr: [rasterizer core] remove old comment
  swr: [rasterizer jitter] small fetch jit cleanup
  swr: [rasterizer core] stop single threaded crash exit crash
  swr: [rasterizer core] conservative rasterization frontend support
  swr: [rasterizer core] GS viewport array index attribute
  swr: [rasterizer core] track whether GS outputs viewport array index
  swr: [rasterizer jitter] add support for component packing for 'odd'
formats
  swr: [rasterizer core] use wrap-around safe compares for dependency
checking
  swr: [rasterizer core] fix dependency bug

 src/gallium/drivers/swr/Makefile.am|   2 +
 src/gallium/drivers/swr/rasterizer/common/isa.hpp  |  20 +-
 src/gallium/drivers/swr/rasterizer/common/os.h |   2 +-
 .../drivers/swr/rasterizer/common/simdintrin.h |   4 +-
 src/gallium/drivers/swr/rasterizer/core/api.cpp|  28 ++-
 src/gallium/drivers/swr/rasterizer/core/clip.h |   4 +-
 .../drivers/swr/rasterizer/core/conservativeRast.h | 120 
 src/gallium/drivers/swr/rasterizer/core/context.h  |  10 +-
 .../drivers/swr/rasterizer/core/format_types.h |   8 +-
 .../drivers/swr/rasterizer/core/frontend.cpp   | 164 ++--
 src/gallium/drivers/swr/rasterizer/core/frontend.h |  43 +
 src/gallium/drivers/swr/rasterizer/core/knobs.h|  17 +-
 .../drivers/swr/rasterizer/core/rasterizer.h   |   8 +
 .../drivers/swr/rasterizer/core/ringbuffer.h   |  16 +-
 src/gallium/drivers/swr/rasterizer/core/state.h|   8 +-
 .../drivers/swr/rasterizer/core/threads.cpp|  54 +++---
 src/gallium/drivers/swr/rasterizer/core/threads.h  |   6 +-
 src/gallium/drivers/swr/rasterizer/core/utils.h|  30 +++
 .../drivers/swr/rasterizer/jitter/JitManager.cpp   |  33 +---
 .../drivers/swr/rasterizer/jitter/JitManager.h |  22 ++-
 .../drivers/swr/rasterizer/jitter/blend_jit.cpp|  13 +-
 .../drivers/swr/rasterizer/jitter/builder_misc.cpp |  44 -
 .../drivers/swr/rasterizer/jitter/builder_misc.h   |   8 +-
 .../drivers/swr/rasterizer/jitter/fetch_jit.cpp| 213 ++---
 .../jitter/scripts/gen_llvm_ir_macros.py   |  11 +-
 .../swr/rasterizer/jitter/streamout_jit.cpp|   9 +-
 .../drivers/swr/rasterizer/memory/Convert.h|   4 +-
 .../drivers/swr/rasterizer/memory/StoreTile.cpp|   4 +-
 .../drivers/swr/rasterizer/scripts/knob_defs.py|   5 +-
 29 files changed, 561 insertions(+), 349 deletions(-)
 create mode 100644 src/gallium/drivers/swr/rasterizer/core/conservativeRast.h

-- 
1.9.1

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


[Mesa-dev] [PATCH 03/14] swr: [rasterizer] add support for building avx512 version

2016-06-17 Thread Tim Rowley
Currently, most code paths between AVX2 and AVX512 are identical
(see changes to knobs.h).
---
 src/gallium/drivers/swr/rasterizer/common/simdintrin.h  |  4 ++--
 src/gallium/drivers/swr/rasterizer/core/format_types.h  |  8 
 src/gallium/drivers/swr/rasterizer/core/knobs.h | 15 ++-
 src/gallium/drivers/swr/rasterizer/memory/Convert.h |  4 ++--
 src/gallium/drivers/swr/rasterizer/memory/StoreTile.cpp |  4 ++--
 5 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/common/simdintrin.h 
b/src/gallium/drivers/swr/rasterizer/common/simdintrin.h
index 5ec1f71..cc29b5d 100644
--- a/src/gallium/drivers/swr/rasterizer/common/simdintrin.h
+++ b/src/gallium/drivers/swr/rasterizer/common/simdintrin.h
@@ -1002,7 +1002,7 @@ static INLINE simdscalar _simd_abs_ps(simdscalar a)
 INLINE
 UINT pdep_u32(UINT a, UINT mask)
 {
-#if KNOB_ARCH==KNOB_ARCH_AVX2
+#if KNOB_ARCH >= KNOB_ARCH_AVX2
 return _pdep_u32(a, mask);
 #else
 UINT result = 0;
@@ -1035,7 +1035,7 @@ UINT pdep_u32(UINT a, UINT mask)
 INLINE
 UINT pext_u32(UINT a, UINT mask)
 {
-#if KNOB_ARCH==KNOB_ARCH_AVX2
+#if KNOB_ARCH >= KNOB_ARCH_AVX2
 return _pext_u32(a, mask);
 #else
 UINT result = 0;
diff --git a/src/gallium/drivers/swr/rasterizer/core/format_types.h 
b/src/gallium/drivers/swr/rasterizer/core/format_types.h
index afb6337..6612c83 100644
--- a/src/gallium/drivers/swr/rasterizer/core/format_types.h
+++ b/src/gallium/drivers/swr/rasterizer/core/format_types.h
@@ -98,7 +98,7 @@ struct PackTraits<8, false>
 __m256i result = _mm256_castsi128_si256(resLo);
 result = _mm256_insertf128_si256(result, resHi, 1);
 return _mm256_castsi256_ps(result);
-#elif KNOB_ARCH==KNOB_ARCH_AVX2
+#elif KNOB_ARCH>=KNOB_ARCH_AVX2
 return 
_mm256_castsi256_ps(_mm256_cvtepu8_epi32(_mm_castps_si128(_mm256_castps256_ps128(in;
 #endif
 #else
@@ -161,7 +161,7 @@ struct PackTraits<8, true>
 __m256i result = _mm256_castsi128_si256(resLo);
 result = _mm256_insertf128_si256(result, resHi, 1);
 return _mm256_castsi256_ps(result);
-#elif KNOB_ARCH==KNOB_ARCH_AVX2
+#elif KNOB_ARCH>=KNOB_ARCH_AVX2
 return 
_mm256_castsi256_ps(_mm256_cvtepi8_epi32(_mm_castps_si128(_mm256_castps256_ps128(in;
 #endif
 #else
@@ -223,7 +223,7 @@ struct PackTraits<16, false>
 __m256i result = _mm256_castsi128_si256(resLo);
 result = _mm256_insertf128_si256(result, resHi, 1);
 return _mm256_castsi256_ps(result);
-#elif KNOB_ARCH==KNOB_ARCH_AVX2
+#elif KNOB_ARCH>=KNOB_ARCH_AVX2
 return 
_mm256_castsi256_ps(_mm256_cvtepu16_epi32(_mm_castps_si128(_mm256_castps256_ps128(in;
 #endif
 #else
@@ -285,7 +285,7 @@ struct PackTraits<16, true>
 __m256i result = _mm256_castsi128_si256(resLo);
 result = _mm256_insertf128_si256(result, resHi, 1);
 return _mm256_castsi256_ps(result);
-#elif KNOB_ARCH==KNOB_ARCH_AVX2
+#elif KNOB_ARCH>=KNOB_ARCH_AVX2
 return 
_mm256_castsi256_ps(_mm256_cvtepi16_epi32(_mm_castps_si128(_mm256_castps256_ps128(in;
 #endif
 #else
diff --git a/src/gallium/drivers/swr/rasterizer/core/knobs.h 
b/src/gallium/drivers/swr/rasterizer/core/knobs.h
index 55a22a6..2629276 100644
--- a/src/gallium/drivers/swr/rasterizer/core/knobs.h
+++ b/src/gallium/drivers/swr/rasterizer/core/knobs.h
@@ -52,11 +52,16 @@
 #define KNOB_SIMD_WIDTH 8
 #define KNOB_SIMD_BYTES 32
 #elif (KNOB_ARCH == KNOB_ARCH_AVX512)
-#define KNOB_ARCH_ISA AVX512F
-#define KNOB_ARCH_STR "AVX512"
-#define KNOB_SIMD_WIDTH 16
-#define KNOB_SIMD_BYTES 64
-#error "AVX512 not yet supported"
+#define KNOB_ARCH_ISA AVX2
+#define KNOB_ARCH_STR "AVX2"
+#define KNOB_SIMD_WIDTH 8
+#define KNOB_SIMD_BYTES 32
+// Disable AVX512 for now...
+//#define KNOB_ARCH_ISA AVX512F
+//#define KNOB_ARCH_STR "AVX512"
+//#define KNOB_SIMD_WIDTH 16
+//#define KNOB_SIMD_BYTES 64
+//#error "AVX512 not yet supported"
 #else
 #error "Unknown architecture"
 #endif
diff --git a/src/gallium/drivers/swr/rasterizer/memory/Convert.h 
b/src/gallium/drivers/swr/rasterizer/memory/Convert.h
index 42b973c..b790d35 100644
--- a/src/gallium/drivers/swr/rasterizer/memory/Convert.h
+++ b/src/gallium/drivers/swr/rasterizer/memory/Convert.h
@@ -336,7 +336,7 @@ static void ConvertPixelFromFloat(
 // Convert from 32-bit float to 16-bit float using _mm_cvtps_ph
 // @todo 16bit float instruction support is orthogonal to avx 
support.  need to
 // add check for F16C support instead.
-#if KNOB_ARCH == KNOB_ARCH_AVX2
+#if KNOB_ARCH >= KNOB_ARCH_AVX2
 __m128 src128 = _mm_set1_ps(src);
 __m128i srci128 = _mm_cvtps_ph(src128, _MM_FROUND_TRUNC);
 UINT value = _mm_extract_epi16(srci128, 0);
@@ -519,7 +519,7 @@ INLINE static void ConvertPixelToFloat(
 float dst;
 if (FormatTraits::GetBPC(comp) == 16)
 {
-#if KNOB_ARCH == KNOB_ARCH_AVX2
+#if KNOB_ARCH >= 

[Mesa-dev] [PATCH 02/14] swr: [rasterizer common] fix include for Intel compiler

2016-06-17 Thread Tim Rowley
---
 src/gallium/drivers/swr/rasterizer/common/os.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h 
b/src/gallium/drivers/swr/rasterizer/common/os.h
index 370c619..45517f6 100644
--- a/src/gallium/drivers/swr/rasterizer/common/os.h
+++ b/src/gallium/drivers/swr/rasterizer/common/os.h
@@ -34,7 +34,7 @@
 #ifndef NOMINMAX
 #define NOMINMAX
 #endif
-#include "Windows.h"
+#include 
 #include 
 #include 
 
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH] swr: switch from overriding -march to selecting features

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 14:06, Chuck Atkins  wrote:
> Using these adjusted flags, I can verify SWR running on Intel SandyBridge,
> Intel Haswell, and AMD Interlagos.
>
Not only building but running as well (on AMD hardware) - nice :-) If
any issues arise one could tweak things up a bit - but until then this
looks great.

Thanks guys !
Emil
P.S. Tim, please keep the Cc: mesa-stable ... line within the commit summary.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 31/64] genxml: Put append counter fields before MCS in RENDER_SURFACE_STATE on gen7

2016-06-17 Thread Chad Versace
Granted you fix patch 28 so that it builds, patches 28 through 31 are
Reviewed-by: Chad Versace 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC 7/7] radeon: remove screen ref counting

2016-06-17 Thread Rob Herring
On Fri, Jun 17, 2016 at 1:45 PM, Emil Velikov  wrote:
> On 17 June 2016 at 18:45, Rob Herring  wrote:
>> Now that the pipe-loader is reference counting the screen creation, it
>> is unnecessary to do in it the winsys/driver.

[...]

>> -static unsigned hash_dev(void *key)
>> -{
>> -#if defined(PIPE_ARCH_X86_64)
>> -   return pointer_to_intptr(key) ^ (pointer_to_intptr(key) >> 32);
>> -#else
>> -   return pointer_to_intptr(key);
>> -#endif
>> -}
>> -
> As you can see above the hashing algo is different for AMDGPU. Not
> familiar with the story behind any of this, so hopefully the AMD folk
> will give you some insights.

They are also hashing the fd in libdrm amdgpu_device_initialize(), so
I thought this was redundant (unless you have an old libdrm).

> FWIW I'm inclined to keep the winsys/radeon and winsys/amdgpu
> differences separate, although not sure if that's possible.

I had planned to, but the unref() function ptr in struct radeon_winsys
is shared.

> Note that vmwgfx has almost(?) identical implementation that one could nuke.

I missed that one...

> Last but not least the biggest and a bit annoying part. As-is the
> series will break GL/VDPAU interiop - the 'thing' that inspired all
> this work initially.

Yeah, I've read thru the bug on that now and am not really clear on
the magic that happens there to make it work. If you load 2 libraries
with an identical symbol in both only 1 version of the symbol will
ever be used?

> To avoid that, we need to promote the fd_hash symbol to public, in
> combination with the lock (if needed) and ideally a version (for
> sanity checking). As we do that we should replace all the existing
> symbols in src/gallium/targets/dri-vdpau.dyn with the new one.

Is there any versioning problem with old libraries to worry about here?

> Plus
> one should short circuit the nouveau/radeon/amdgpu machinery to avoid
> intermittently breaking things. Don't know how much we care about that
> last one ;-)

You mean keep it bisectable, right.

>
> All that aside, thanks again for looking into this.
> Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 27/64] isl/state: Add assertions for buffer surface restrictions

2016-06-17 Thread Chad Versace
Acked-by: Chad Versace 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 26/64] isl/state: Don't set SurfacePitch for gen9 1-D textures

2016-06-17 Thread Chad Versace
Patch 26 is
Reviewed-by: Chad Versace 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 25/64] isl/state: Use TILEWALK_XMAJOR for linear surfaces on gen7

2016-06-17 Thread Chad Versace
Patches 24 and 25 are
Reviewed-by: Chad Versace 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC 2/7] pipe-loader-drm: Add common pipe_screen refcounting

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 19:28, Rob Clark  wrote:
> On Fri, Jun 17, 2016 at 2:23 PM, Emil Velikov  
> wrote:
>> Hi Rob,
>>
>> On 17 June 2016 at 18:45, Rob Herring  wrote:
>>
>>>  struct pipe_screen {
>>> +   int refcnt;
>> Can you please use struct pipe_reference throughout and the respective
>> pipe_reference API from src/gallium/auxiliary/util/u_inlines.h.
>
> jfyi, the original per-driver implementation didn't use pipe_reference
> since (iirc) there were some assumptions somewhere or other that
> pipe_reference was the first struct member.
Precisely - the pipe_reference member must be the first one in the
struct. There aren't any other assumptions/reasons that I know of.

>  But yeah, now that we can
> move it to the top of pipe_screen, we should do it properly
>
... and since Rob was (such a star) to moved it at start of
pipe_screen I've went ahead and pushed my luck - suggesting
pipe_reference.
If he's not interested/doesn't have time that's fine. Things should
work without it afaict.

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


Re: [Mesa-dev] [PATCH] st/mesa: Remove tautological check (v2)

2016-06-17 Thread Francesco Ansanelli
Hi Erik,
Thanks for your feedback.
Can you suggest a better subject?
After some thinking, should I cast gl_buffer_index before calling the
function?
Thanks
Francesco
Il 17 giu 2016 12:39, "Erik Faye-Lund"  ha scritto:

> Now the subject no longer makes any sense.
>
> On Thu, Jun 16, 2016 at 7:02 AM,   wrote:
> > From: Francesco Ansanelli 
> >
> > ---
> >  src/mesa/state_tracker/st_cb_fbo.c |2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/state_tracker/st_cb_fbo.c
> b/src/mesa/state_tracker/st_cb_fbo.c
> > index a53b95a..950ec3e 100644
> > --- a/src/mesa/state_tracker/st_cb_fbo.c
> > +++ b/src/mesa/state_tracker/st_cb_fbo.c
> > @@ -704,7 +704,7 @@ st_DrawBuffers(struct gl_context *ctx, GLsizei
> count, const GLenum *buffers)
> >
> > /* add the renderbuffers on demand */
> > for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
> > -  gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i];
> > +  GLint idx = fb->_ColorDrawBufferIndexes[i];
> >
> >if (idx >= 0) {
> >   st_manager_add_color_renderbuffer(st, fb, idx);
> > --
> > 1.7.9.5
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 23/64] isl/state: Only set cube face enables if usage includes CUBE_BIT

2016-06-17 Thread Chad Versace
Patches 22 and 23 are
Reviewed-by: Chad Versace 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC 7/7] radeon: remove screen ref counting

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 18:45, Rob Herring  wrote:
> Now that the pipe-loader is reference counting the screen creation, it
> is unnecessary to do in it the winsys/driver.
>
> Signed-off-by: Rob Herring 
> Cc: "Marek Olšák" 
> Cc: Ilia Mirkin 
> ---
>  src/gallium/drivers/r300/r300_screen.c|  3 -
>  src/gallium/drivers/r600/r600_pipe.c  |  6 --
>  src/gallium/drivers/radeon/radeon_winsys.h|  8 ---
>  src/gallium/drivers/radeonsi/si_pipe.c|  6 --
>  src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 66 +--
>  src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h |  1 -
>  src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 80 
> +--
>  7 files changed, 3 insertions(+), 167 deletions(-)
>
> diff --git a/src/gallium/drivers/r300/r300_screen.c 
> b/src/gallium/drivers/r300/r300_screen.c
> index 681681b..5d2d955 100644
> --- a/src/gallium/drivers/r300/r300_screen.c
> +++ b/src/gallium/drivers/r300/r300_screen.c
> @@ -674,9 +674,6 @@ static void r300_destroy_screen(struct pipe_screen* 
> pscreen)
>  struct r300_screen* r300screen = r300_screen(pscreen);
>  struct radeon_winsys *rws = radeon_winsys(pscreen);
>
> -if (rws && !rws->unref(rws))
> -  return;
> -
>  pipe_mutex_destroy(r300screen->cmask_mutex);
>
>  if (rws)
> diff --git a/src/gallium/drivers/r600/r600_pipe.c 
> b/src/gallium/drivers/r600/r600_pipe.c
> index a49b00f..66cb78c 100644
> --- a/src/gallium/drivers/r600/r600_pipe.c
> +++ b/src/gallium/drivers/r600/r600_pipe.c
> @@ -566,12 +566,6 @@ static void r600_destroy_screen(struct pipe_screen* 
> pscreen)
>  {
> struct r600_screen *rscreen = (struct r600_screen *)pscreen;
>
> -   if (!rscreen)
> -   return;
> -
> -   if (!rscreen->b.ws->unref(rscreen->b.ws))
> -   return;
> -
> if (rscreen->global_pool) {
> compute_memory_pool_delete(rscreen->global_pool);
> }
> diff --git a/src/gallium/drivers/radeon/radeon_winsys.h 
> b/src/gallium/drivers/radeon/radeon_winsys.h
> index c2d1f9e..ffe0d83 100644
> --- a/src/gallium/drivers/radeon/radeon_winsys.h
> +++ b/src/gallium/drivers/radeon/radeon_winsys.h
> @@ -416,14 +416,6 @@ struct radeon_winsys {
>  struct pipe_screen *screen;
>
>  /**
> - * Decrement the winsys reference count.
> - *
> - * \param ws  The winsys this function is called for.
> - * \returnTrue if the winsys and screen should be destroyed.
> - */
> -bool (*unref)(struct radeon_winsys *ws);
> -
> -/**
>   * Destroy this winsys.
>   *
>   * \param wsThe winsys this function is called from.
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
> b/src/gallium/drivers/radeonsi/si_pipe.c
> index 0c601da..f3256fc 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.c
> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
> @@ -628,12 +628,6 @@ static void si_destroy_screen(struct pipe_screen* 
> pscreen)
> };
> unsigned i;
>
> -   if (!sscreen)
> -   return;
> -
> -   if (!sscreen->b.ws->unref(sscreen->b.ws))
> -   return;
> -
> /* Free shader parts. */
> for (i = 0; i < ARRAY_SIZE(parts); i++) {
> while (parts[i]) {
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c 
> b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> index 7016221..39b4a11 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> @@ -34,7 +34,6 @@
>  #include "amdgpu_cs.h"
>  #include "amdgpu_public.h"
>
> -#include "util/u_hash_table.h"
>  #include 
>  #include 
>  #include 
> @@ -59,9 +58,6 @@
>  #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_8X16   16
>  #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16  17
>
> -static struct util_hash_table *dev_tab = NULL;
> -pipe_static_mutex(dev_tab_mutex);
> -
>  static unsigned cik_get_num_tile_pipes(struct amdgpu_gpu_info *info)
>  {
> unsigned mode2d = info->gb_tile_mode[CIK_TILE_MODE_COLOR_2D];
> @@ -386,20 +382,6 @@ static bool amdgpu_read_registers(struct radeon_winsys 
> *rws,
> 0x, 0, out) == 0;
>  }
>
> -static unsigned hash_dev(void *key)
> -{
> -#if defined(PIPE_ARCH_X86_64)
> -   return pointer_to_intptr(key) ^ (pointer_to_intptr(key) >> 32);
> -#else
> -   return pointer_to_intptr(key);
> -#endif
> -}
> -
As you can see above the hashing algo is different for AMDGPU. Not
familiar with the story behind any of this, so hopefully the AMD folk
will give you some insights.

FWIW I'm inclined to keep the winsys/radeon and winsys/amdgpu
differences separate, although not sure if that's possible.
Note that vmwgfx has almost(?) identical implementation that one could nuke.

Last but not least the biggest and a bit annoying part. As-is the
series will break GL/VDPAU interiop - the 'thing' that 

Re: [Mesa-dev] [PATCH 2/2] radeonsi: use trapezoid distribution for tess on Fiji and Polaris

2016-06-17 Thread Alex Deucher
On Fri, Jun 17, 2016 at 2:10 PM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> This yields a small performance improvement in Unigine Heaven.

For the series:
Reviewed-by: Alex Deucher 

> ---
>  src/gallium/drivers/radeonsi/si_state.c | 22 +-
>  src/gallium/drivers/radeonsi/si_state_shaders.c | 10 +++---
>  2 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state.c 
> b/src/gallium/drivers/radeonsi/si_state.c
> index 6be2f4b..1cef1dc 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -3839,16 +3839,28 @@ static void si_init_config(struct si_context *sctx)
> }
>
> if (sctx->b.chip_class >= VI) {
> +   unsigned vgt_tess_distribution;
> +
> si_pm4_set_reg(pm4, R_028424_CB_DCC_CONTROL,
>
> S_028424_OVERWRITE_COMBINER_MRT_SHARING_DISABLE(1) |
>S_028424_OVERWRITE_COMBINER_WATERMARK(4));
> si_pm4_set_reg(pm4, R_028C58_VGT_VERTEX_REUSE_BLOCK_CNTL, 30);
> si_pm4_set_reg(pm4, R_028C5C_VGT_OUT_DEALLOC_CNTL, 32);
> -   si_pm4_set_reg(pm4, R_028B50_VGT_TESS_DISTRIBUTION,
> -  S_028B50_ACCUM_ISOLINE(32) |
> -  S_028B50_ACCUM_TRI(11) |
> -  S_028B50_ACCUM_QUAD(11) |
> -  S_028B50_DONUT_SPLIT(16));
> +
> +   vgt_tess_distribution =
> +   S_028B50_ACCUM_ISOLINE(32) |
> +   S_028B50_ACCUM_TRI(11) |
> +   S_028B50_ACCUM_QUAD(11) |
> +   S_028B50_DONUT_SPLIT(16);
> +
> +   /* Testing with Unigine Heaven extreme tesselation yielded 
> best results
> +* with TRAP_SPLIT = 3.
> +*/
> +   if (sctx->b.family == CHIP_FIJI ||
> +   sctx->b.family >= CHIP_POLARIS10)
> +   vgt_tess_distribution |= S_028B50_TRAP_SPLIT(3);
> +
> +   si_pm4_set_reg(pm4, R_028B50_VGT_TESS_DISTRIBUTION, 
> vgt_tess_distribution);
> }
>
> if (sctx->b.family == CHIP_STONEY)
> diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
> b/src/gallium/drivers/radeonsi/si_state_shaders.c
> index a7af76d..daef49d 100644
> --- a/src/gallium/drivers/radeonsi/si_state_shaders.c
> +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
> @@ -300,9 +300,13 @@ static void si_set_tesseval_regs(struct si_screen 
> *sscreen,
> else
> topology = V_028B6C_OUTPUT_TRIANGLE_CW;
>
> -   if (sscreen->b.chip_class >= VI)
> -   distribution_mode = V_028B6C_DISTRIBUTION_MODE_DONUTS;
> -   else
> +   if (sscreen->b.chip_class >= VI) {
> +   if (sscreen->b.family == CHIP_FIJI ||
> +   sscreen->b.family >= CHIP_POLARIS10)
> +   distribution_mode = 
> V_028B6C_DISTRIBUTION_MODE_TRAPEZOIDS;
> +   else
> +   distribution_mode = V_028B6C_DISTRIBUTION_MODE_DONUTS;
> +   } else
> distribution_mode = V_028B6C_DISTRIBUTION_MODE_NO_DIST;
>
> si_pm4_set_reg(pm4, R_028B6C_VGT_TF_PARAM,
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] swr: Update screen->context pointer with multiple contexts.

2016-06-17 Thread Rowley, Timothy O
Reviewed-by: Tim Rowley 

> On Jun 17, 2016, at 12:14 PM, Bruce Cherniak  wrote:
> 
> A pipe pointer in the screen allows for access to current device context
> in flush_frontbuffer and resource_destroy.  This wasn't tracking current
> context in multi-context situations.
> 
> v2: More caffeine.  Corrected compare, removed unnecessary set of
> screen-pipe in create_context, and added a few comments.
> ---
> src/gallium/drivers/swr/swr_context.cpp |6 +++---
> src/gallium/drivers/swr/swr_state.cpp   |4 
> 2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/drivers/swr/swr_context.cpp 
> b/src/gallium/drivers/swr/swr_context.cpp
> index 3a5d9e0..1f3a14c 100644
> --- a/src/gallium/drivers/swr/swr_context.cpp
> +++ b/src/gallium/drivers/swr/swr_context.cpp
> @@ -322,8 +322,10 @@ swr_destroy(struct pipe_context *pipe)
> 
>swr_destroy_scratch_buffers(ctx);
> 
> +   /* Only update screen->pipe if current context is being destroyed */
>assert(screen);
> -   screen->pipe = NULL;
> +   if (screen->pipe == pipe)
> +  screen->pipe = NULL;
> 
>FREE(ctx);
> }
> @@ -346,7 +348,6 @@ struct pipe_context *
> swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags)
> {
>struct swr_context *ctx = CALLOC_STRUCT(swr_context);
> -   struct swr_screen *screen = swr_screen(p_screen);
>ctx->blendJIT =
>   new std::unordered_map;
> 
> @@ -366,7 +367,6 @@ swr_create_context(struct pipe_screen *p_screen, void 
> *priv, unsigned flags)
>if (ctx->swrContext == NULL)
>   goto fail;
> 
> -   screen->pipe = >pipe;
>ctx->pipe.screen = p_screen;
>ctx->pipe.destroy = swr_destroy;
>ctx->pipe.priv = priv;
> diff --git a/src/gallium/drivers/swr/swr_state.cpp 
> b/src/gallium/drivers/swr/swr_state.cpp
> index 3eeb98d..1f34365 100644
> --- a/src/gallium/drivers/swr/swr_state.cpp
> +++ b/src/gallium/drivers/swr/swr_state.cpp
> @@ -776,6 +776,10 @@ swr_update_derived(struct pipe_context *pipe,
>struct swr_context *ctx = swr_context(pipe);
>struct swr_screen *screen = swr_screen(ctx->pipe.screen);
> 
> +   /* Update screen->pipe to current pipe context. */
> +   if (screen->pipe != pipe)
> +  screen->pipe = pipe;
> +
>/* Any state that requires dirty flags to be re-triggered sets this mask */
>/* For example, user_buffer vertex and index buffers. */
>unsigned post_update_dirty_flags = 0;
> -- 
> 1.7.1
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

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


Re: [Mesa-dev] [RFC 2/7] pipe-loader-drm: Add common pipe_screen refcounting

2016-06-17 Thread Rob Clark
On Fri, Jun 17, 2016 at 2:23 PM, Emil Velikov  wrote:
> Hi Rob,
>
> On 17 June 2016 at 18:45, Rob Herring  wrote:
>
>>  struct pipe_screen {
>> +   int refcnt;
> Can you please use struct pipe_reference throughout and the respective
> pipe_reference API from src/gallium/auxiliary/util/u_inlines.h.

jfyi, the original per-driver implementation didn't use pipe_reference
since (iirc) there were some assumptions somewhere or other that
pipe_reference was the first struct member.  But yeah, now that we can
move it to the top of pipe_screen, we should do it properly


BR,
-R

> Thank you very much for doing this !
> Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC 2/7] pipe-loader-drm: Add common pipe_screen refcounting

2016-06-17 Thread Emil Velikov
Hi Rob,

On 17 June 2016 at 18:45, Rob Herring  wrote:

>  struct pipe_screen {
> +   int refcnt;
Can you please use struct pipe_reference throughout and the respective
pipe_reference API from src/gallium/auxiliary/util/u_inlines.h.

Thank you very much for doing this !
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glcpp: Only expose ARB_enhanced_layouts if it's supported.

2016-06-17 Thread Jason Ekstrand
On Jun 17, 2016 11:07 AM, "Dylan Baker"  wrote:
>
> Quoting Ian Romanick (2016-06-16 20:07:14)
> > This patch is
> >
> > Reviewed-by: Ian Romanick 
> >
> > On 06/16/2016 06:15 PM, Dylan Baker wrote:
> > > This fixes the following piglit tests:
> > > spec/arb_enhanced_layouts/preprocessor/disabled-defined-core.*
> > >
> > > Signed-off-by: Dylan Baker 
> > > ---
> > >  src/compiler/glsl/glcpp/glcpp-parse.y | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y
b/src/compiler/glsl/glcpp/glcpp-parse.y
> > > index 2cfa6a6..76cba07 100644
> > > --- a/src/compiler/glsl/glcpp/glcpp-parse.y
> > > +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
> > > @@ -2338,12 +2338,14 @@
_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t
versio
> > >}
> > > } else {
> > >add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
> > > -  add_builtin_define(parser, "GL_ARB_enhanced_layouts", 1);
> > >add_builtin_define(parser, "GL_ARB_separate_shader_objects",
1);
> > >add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
> > >add_builtin_define(parser, "GL_AMD_shader_trinary_minmax", 1);
> > >
> > >if (extensions != NULL) {
> > > + if (extensions->ARB_enhanced_layouts)
> > > + add_builtin_define(parser, "GL_ARB_enhanced_layouts",
1);
> > > +
> > >   if (extensions->EXT_texture_array)
> > >  add_builtin_define(parser, "GL_EXT_texture_array", 1);
> > >
> >
>
> I don't have commit access, would you mind pushing this for me too?

You have 37 patches in Mesa. Probably time to apply for commit access.

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


Re: [Mesa-dev] [Mesa-stable] [PATCH] mapi: Export all GLES 3.1 functions in libGLESv2.so

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 18:20, Ian Romanick  wrote:
> From: Ian Romanick 
>
> Khronos recommends that the GLES 3.1 library also be called libGLESv2.
> It also requires that functions be statically linkable from that
> library.
>
> NOTE: Mesa has supported the EGL_KHR_get_all_proc_addresses extension
> since at least Mesa 10.5, so applications targeting Linux should use
> eglGetProcAddress to avoid problems running binaries on systems with
> older, non-GLES 3.1 libGLESv2 libraries.
>
Fwiw I'm inclined that we should go the "opposite direction". Namely:
don't expose new symbols and stick to a predefined version (3.0 being
the personal favour of choice).

Why, you might ask - for a couple of reasons:
 - If the list continues to grow programs will have unstable ABI -
sort of how libGL ended up. Applications are going to link against 3.1
or later symbols [1], even if they only optionally use them. Thus
things will quite hairy and fragile.
 - The other desktop GLES* provider NVIDIA does not export even a
single GLES 3.1/3.2 entry point (still going through the 3.0 list) in
their libGLESv2.so.2 binary.

So what to do with GLES (3.0?)/3.1 and later:
 - tweak the spec so that said version of the API is only supported if
the implementation can get core symbols via eglGetProcAddress. Be that
props to the EGL_KHR_get_all_proc_addresses extension or EGL 1.5 [2].

How does this sound ? I guess the best way would be to check with
other implementations (note Catalyst still seems to be missing
libGLES*) and choose the more common route ?


Regards,
Emil

[1] Yes, in practise they should use libepoxy or a similar library,
but from practise we all know that even those tend to have bugs. Sadly
libepoxy in particular hasn't seen much action in a while.

[2] https://github.com/anholt/libepoxy/issues/21
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] radeonsi: use trapezoid distribution for tess on Fiji and Polaris

2016-06-17 Thread Nicolai Hähnle
From: Nicolai Hähnle 

This yields a small performance improvement in Unigine Heaven.
---
 src/gallium/drivers/radeonsi/si_state.c | 22 +-
 src/gallium/drivers/radeonsi/si_state_shaders.c | 10 +++---
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 6be2f4b..1cef1dc 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -3839,16 +3839,28 @@ static void si_init_config(struct si_context *sctx)
}
 
if (sctx->b.chip_class >= VI) {
+   unsigned vgt_tess_distribution;
+
si_pm4_set_reg(pm4, R_028424_CB_DCC_CONTROL,
   
S_028424_OVERWRITE_COMBINER_MRT_SHARING_DISABLE(1) |
   S_028424_OVERWRITE_COMBINER_WATERMARK(4));
si_pm4_set_reg(pm4, R_028C58_VGT_VERTEX_REUSE_BLOCK_CNTL, 30);
si_pm4_set_reg(pm4, R_028C5C_VGT_OUT_DEALLOC_CNTL, 32);
-   si_pm4_set_reg(pm4, R_028B50_VGT_TESS_DISTRIBUTION,
-  S_028B50_ACCUM_ISOLINE(32) |
-  S_028B50_ACCUM_TRI(11) |
-  S_028B50_ACCUM_QUAD(11) |
-  S_028B50_DONUT_SPLIT(16));
+
+   vgt_tess_distribution =
+   S_028B50_ACCUM_ISOLINE(32) |
+   S_028B50_ACCUM_TRI(11) |
+   S_028B50_ACCUM_QUAD(11) |
+   S_028B50_DONUT_SPLIT(16);
+
+   /* Testing with Unigine Heaven extreme tesselation yielded best 
results
+* with TRAP_SPLIT = 3.
+*/
+   if (sctx->b.family == CHIP_FIJI ||
+   sctx->b.family >= CHIP_POLARIS10)
+   vgt_tess_distribution |= S_028B50_TRAP_SPLIT(3);
+
+   si_pm4_set_reg(pm4, R_028B50_VGT_TESS_DISTRIBUTION, 
vgt_tess_distribution);
}
 
if (sctx->b.family == CHIP_STONEY)
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index a7af76d..daef49d 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -300,9 +300,13 @@ static void si_set_tesseval_regs(struct si_screen *sscreen,
else
topology = V_028B6C_OUTPUT_TRIANGLE_CW;
 
-   if (sscreen->b.chip_class >= VI)
-   distribution_mode = V_028B6C_DISTRIBUTION_MODE_DONUTS;
-   else
+   if (sscreen->b.chip_class >= VI) {
+   if (sscreen->b.family == CHIP_FIJI ||
+   sscreen->b.family >= CHIP_POLARIS10)
+   distribution_mode = 
V_028B6C_DISTRIBUTION_MODE_TRAPEZOIDS;
+   else
+   distribution_mode = V_028B6C_DISTRIBUTION_MODE_DONUTS;
+   } else
distribution_mode = V_028B6C_DISTRIBUTION_MODE_NO_DIST;
 
si_pm4_set_reg(pm4, R_028B6C_VGT_TF_PARAM,
-- 
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] radeonsi/sid: add Fiji+ tesselation distribution mode

2016-06-17 Thread Nicolai Hähnle
From: Nicolai Hähnle 

---
 src/gallium/drivers/radeonsi/sid.h | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/sid.h 
b/src/gallium/drivers/radeonsi/sid.h
index a6d5c05..1363a44 100644
--- a/src/gallium/drivers/radeonsi/sid.h
+++ b/src/gallium/drivers/radeonsi/sid.h
@@ -7962,9 +7962,12 @@
 #define   S_028B50_ACCUM_QUAD(x)  
(((unsigned)(x) & 0xFF) << 16)
 #define   G_028B50_ACCUM_QUAD(x)  (((x) >> 
16) & 0xFF)
 #define   C_028B50_ACCUM_QUAD 
0xFF00
-#define   S_028B50_DONUT_SPLIT(x) 
(((unsigned)(x) & 0xFF) << 24)
-#define   G_028B50_DONUT_SPLIT(x) (((x) >> 
24) & 0xFF)
-#define   C_028B50_DONUT_SPLIT
0x00FF
+#define   S_028B50_DONUT_SPLIT(x) 
(((unsigned)(x) & 0x1F) << 24)
+#define   G_028B50_DONUT_SPLIT(x) (((x) >> 
24) & 0x1F)
+#define   C_028B50_DONUT_SPLIT
0xE0FF
+#define   S_028B50_TRAP_SPLIT(x)  
(((unsigned)(x) & 0x7) << 29) /* Fiji+ */
+#define   G_028B50_TRAP_SPLIT(x)  (((x) >> 
29) & 0x7)
+#define   C_028B50_TRAP_SPLIT 
0x1FFF
 /**/
 #define R_028B54_VGT_SHADER_STAGES_EN   
0x028B54
 #define   S_028B54_LS_EN(x)   
(((unsigned)(x) & 0x03) << 0)
@@ -8085,6 +8088,7 @@
 #define V_028B6C_DISTRIBUTION_MODE_NO_DIST  0x00
 #define V_028B6C_DISTRIBUTION_MODE_PATCHES  0x01
 #define V_028B6C_DISTRIBUTION_MODE_DONUTS   0x02
+#define V_028B6C_DISTRIBUTION_MODE_TRAPEZOIDS   0x03 /* 
Fiji+ */
 #define   S_028B6C_MTYPE(x)   
(((unsigned)(x) & 0x03) << 19)
 #define   G_028B6C_MTYPE(x)   (((x) >> 
19) & 0x03)
 #define   C_028B6C_MTYPE  
0xFFE7
-- 
2.7.4

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


Re: [Mesa-dev] [RFC 0/7] Common pipe screen ref counting

2016-06-17 Thread Christian König
Clearly a good idea to move this into common code, but there is just one 
important thing you are missing here.


We intentional export the *_winsys_create() in the created libraries to 
have only one global file descriptor for all libraries. See the 
following files as well:

src/gallium/targets/vdpau/vdpau.sym
src/gallium/targets/dri-vdpau.dyn
src/gallium/targets/dri/dri.sym

I'm not sure if that is needed any more or will keep working if you 
change the code like this.


Regards,
Christian.

Am 17.06.2016 um 19:45 schrieb Rob Herring:

I needed to add screen ref counting to vc4 driver, so rather than yet
another copy of the same fd hashing and ref counting code, I implemented
it in the pipe-loader. AFAICT, the pipe-loader is the only place the
winsys create screen functions are called and seemed to be the best
location to put this. The tricky part is the destroy path and not
freeing the screen before reference counting. I think I found all the
callers of pipe_screen->destroy.

This is tested on virgl and freedreno on Android and radeon is build
tested only.

Rob

Rob Herring (7):
   gallium: move pipe_screen destroy into pipe-loader
   pipe-loader-drm: Add common pipe_screen refcounting
   Revert "virgl: reuse screen when fd is already open"
   Revert "virgl: mark function as static"
   nouveau: remove screen ref counting
   freedreno: remove screen ref counting
   radeon: remove screen ref counting

  src/gallium/auxiliary/pipe-loader/pipe_loader.h|  1 +
  .../auxiliary/pipe-loader/pipe_loader_drm.c| 71 -
  src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c |  6 ++
  src/gallium/auxiliary/target-helpers/drm_helper.h  |  7 +-
  src/gallium/auxiliary/vl/vl_winsys_dri.c   |  1 -
  src/gallium/auxiliary/vl/vl_winsys_dri3.c  |  1 -
  src/gallium/auxiliary/vl/vl_winsys_drm.c   |  1 -
  src/gallium/drivers/freedreno/freedreno_screen.c   |  1 -
  src/gallium/drivers/freedreno/freedreno_screen.h   | 10 ---
  src/gallium/drivers/nouveau/nouveau_screen.h   |  2 -
  src/gallium/drivers/r300/r300_screen.c |  3 -
  src/gallium/drivers/r600/r600_pipe.c   |  6 --
  src/gallium/drivers/radeon/radeon_winsys.h |  8 --
  src/gallium/drivers/radeonsi/si_pipe.c |  6 --
  src/gallium/drivers/virgl/virgl_screen.c   |  1 -
  src/gallium/drivers/virgl/virgl_screen.h   |  6 --
  src/gallium/include/pipe/p_screen.h|  1 +
  src/gallium/state_trackers/clover/core/device.cpp  |  4 +-
  src/gallium/state_trackers/dri/dri_screen.c|  3 -
  src/gallium/state_trackers/xa/xa_tracker.c |  2 -
  src/gallium/tests/trivial/compute.c|  1 -
  src/gallium/tests/trivial/quad-tex.c   |  1 -
  src/gallium/tests/trivial/tri.c|  1 -
  src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c  | 66 +---
  src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h  |  1 -
  .../winsys/freedreno/drm/freedreno_drm_winsys.c| 89 +-
  .../winsys/nouveau/drm/nouveau_drm_winsys.c| 84 +---
  src/gallium/winsys/radeon/drm/radeon_drm_winsys.c  | 80 +--
  src/gallium/winsys/virgl/drm/virgl_drm_public.h|  4 +-
  src/gallium/winsys/virgl/drm/virgl_drm_winsys.c| 89 +-
  30 files changed, 95 insertions(+), 462 deletions(-)



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


Re: [Mesa-dev] [PATCH] glcpp: Only expose ARB_enhanced_layouts if it's supported.

2016-06-17 Thread Dylan Baker
Quoting Ian Romanick (2016-06-16 20:07:14)
> This patch is
> 
> Reviewed-by: Ian Romanick 
> 
> On 06/16/2016 06:15 PM, Dylan Baker wrote:
> > This fixes the following piglit tests:
> > spec/arb_enhanced_layouts/preprocessor/disabled-defined-core.*
> > 
> > Signed-off-by: Dylan Baker 
> > ---
> >  src/compiler/glsl/glcpp/glcpp-parse.y | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y 
> > b/src/compiler/glsl/glcpp/glcpp-parse.y
> > index 2cfa6a6..76cba07 100644
> > --- a/src/compiler/glsl/glcpp/glcpp-parse.y
> > +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
> > @@ -2338,12 +2338,14 @@ 
> > _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t 
> > versio
> >}
> > } else {
> >add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
> > -  add_builtin_define(parser, "GL_ARB_enhanced_layouts", 1);
> >add_builtin_define(parser, "GL_ARB_separate_shader_objects", 1);
> >add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
> >add_builtin_define(parser, "GL_AMD_shader_trinary_minmax", 1);
> >  
> >if (extensions != NULL) {
> > + if (extensions->ARB_enhanced_layouts)
> > + add_builtin_define(parser, "GL_ARB_enhanced_layouts", 1);
> > +
> >   if (extensions->EXT_texture_array)
> >  add_builtin_define(parser, "GL_EXT_texture_array", 1);
> >  
> 

I don't have commit access, would you mind pushing this for me too?

Dylan


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


[Mesa-dev] [Bug 96410] [Perf] Pre validate _mesa_sampler_uniforms_pipeline_are_valid like _mesa_sampler_uniforms_are_valid

2016-06-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96410

--- Comment #1 from gregory.hain...@gmail.com ---
Currently looking at the code of single program flow namely
_mesa_update_shader_textures_used

The current check fails to detect wrongly reused sampler in multiple shader
stage. The spec seems to imply that is must be checked in the full program (all
stages).

<<
 Errors
  It is not allowed to have variables of different sampler types pointing to
  the same texture image unit within a program object. This situation can only
  be detected at the next rendering command issued which triggers shader invo-
  cations, and an INVALID_OPERATION error will then be generated.
>>

Here a typical example of an invalid program that will wrongly run fine.

* Vertex Shader
layout(binding = 0) uniform sampler1D sampler_1d;

* Fragment Shader
layout(binding = 0) uniform sampler2D sampler_2d;

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/11] mesa: Add flush_vertices argument to _mesa_bind_vertex_buffer.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Similar to _mesa_update_array_format add an argument to
avoid calling FLUSH_VERTICES in certain cases.
This will be used with the following change.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/common/meta.c | 16 +---
 src/mesa/main/varray.c | 16 ++--
 src/mesa/main/varray.h |  2 +-
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index be671b4..5962aaa 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -328,7 +328,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x), true);
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
-  *buf_obj, 0, sizeof(struct vertex));
+  *buf_obj, 0, sizeof(struct vertex), true);
  _mesa_enable_vertex_array_attrib(ctx, array_obj,
   VERT_ATTRIB_GENERIC(0));
  if (texcoord_size > 0) {
@@ -337,7 +337,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   GL_FALSE, GL_FALSE, GL_FALSE,
   offsetof(struct vertex, tex), false);
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
- *buf_obj, 0, sizeof(struct vertex));
+ *buf_obj, 0, sizeof(struct vertex), true);
 _mesa_enable_vertex_array_attrib(ctx, array_obj,
  VERT_ATTRIB_GENERIC(1));
  }
@@ -347,7 +347,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x), true);
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
-  *buf_obj, 0, sizeof(struct vertex));
+  *buf_obj, 0, sizeof(struct vertex), true);
  _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
 
  if (texcoord_size > 0) {
@@ -356,7 +356,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   GL_FALSE, GL_FALSE,
   offsetof(struct vertex, tex), false);
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0),
- *buf_obj, 0, sizeof(struct vertex));
+ *buf_obj, 0, sizeof(struct vertex), true);
 _mesa_enable_vertex_array_attrib(ctx, array_obj, 
VERT_ATTRIB_TEX(0));
  }
 
@@ -366,7 +366,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   GL_FALSE, GL_FALSE,
   offsetof(struct vertex, r), false);
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0,
- *buf_obj, 0, sizeof(struct vertex));
+ *buf_obj, 0, sizeof(struct vertex), true);
 _mesa_enable_vertex_array_attrib(ctx, array_obj, 
VERT_ATTRIB_COLOR0);
  }
   }
@@ -3325,7 +3325,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
 GL_FALSE, GL_FALSE,
 offsetof(struct vertex, x), true);
   _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
-   drawtex->buf_obj, 0, sizeof(struct vertex));
+   drawtex->buf_obj, 0,
+   sizeof(struct vertex), true);
   _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
 
 
@@ -3335,7 +3336,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, st[i]), true);
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(i),
-  drawtex->buf_obj, 0, sizeof(struct vertex));
+  drawtex->buf_obj, 0,
+  sizeof(struct vertex), true);
  _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(i));
   }
}
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index c2bf295..5cd7324 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -164,7 +164,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
  struct gl_vertex_array_object *vao,
  GLuint index,
  struct gl_buffer_object *vbo,
-  

[Mesa-dev] [PATCH 00/11] Make more use of state already tracked in the VAO.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Hi,

The first two patches fix a bug in tracking the VAO internal
state. The majority of the changeset makes more use of the
state currently tracked in the VAO and transitions to use
more of the first order information found in the VAO instead
of relying on the gl_client_array members that mirror the
VAO fields. The last two patches rip out members from
gl_client_array that are set but no longer used.

Please review,

Thanks

Mathias


Mathias Fröhlich (11):
  mesa: Add flush_vertices argument to _mesa_bind_vertex_buffer.
  mesa: Unbind deleted vbo using _mesa_bind_vertex_buffer.
  mesa: Implement _mesa_all_varyings_in_vbos.
  vbo: Walk the VAO to see if all varyings are in vbos.
  vbo: Walk the VAO to check for mapped buffers.
  mesa: Walk the VAO in _mesa_print_arrays.
  vbo: Walk the VAO in print_draw_arrays.
  vbo: Walk the VAO in check_array_data.
  vbo: Use the VAO array enabled flags in vbo_exec_array.
  mesa: Remove set but not used gl_client_array::Enabled.
  mesa: Remove set but not used gl_client_array::Stride.

 src/mesa/drivers/common/meta.c   |  16 ++--
 src/mesa/main/arrayobj.c |  35 
 src/mesa/main/arrayobj.h |   4 +
 src/mesa/main/bufferobj.c|  11 ++-
 src/mesa/main/mtypes.h   |   2 -
 src/mesa/main/varray.c   |  70 +++
 src/mesa/main/varray.h   |   4 +-
 src/mesa/state_tracker/st_cb_rasterpos.c |   2 -
 src/mesa/vbo/vbo_context.c   |   2 -
 src/mesa/vbo/vbo_exec_array.c| 141 ++-
 src/mesa/vbo/vbo_exec_draw.c |   2 -
 src/mesa/vbo/vbo_save_draw.c |   2 -
 src/mesa/vbo/vbo_split_copy.c|   8 +-
 13 files changed, 171 insertions(+), 128 deletions(-)

-- 
2.5.5

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


[Mesa-dev] [PATCH 02/11] mesa: Unbind deleted vbo using _mesa_bind_vertex_buffer.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

When a vertex buffer object gets deleted, it is unbound
at the VAO. To do this use _mesa_bind_vertex_buffer instead
of plain unreferencing the buffer object. This keeps the VAOs
internal state consistent. In this case it showed up with
gl_vertex_array_object::VertexAttribBufferMask getting out of
sync.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/bufferobj.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 795cb16..71d1841 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -44,6 +44,7 @@
 #include "glformats.h"
 #include "texstore.h"
 #include "transformfeedback.h"
+#include "varray.h"
 
 
 /* Debug flags */
@@ -1199,11 +1200,13 @@ _mesa_multi_bind_lookup_bufferobj(struct gl_context 
*ctx,
  */
 static void
 unbind(struct gl_context *ctx,
-   struct gl_buffer_object **ptr,
+   struct gl_vertex_array_object *vao, unsigned index,
struct gl_buffer_object *obj)
 {
-   if (*ptr == obj) {
-  _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj);
+   if (vao->VertexBinding[index].BufferObj == obj) {
+  _mesa_bind_vertex_buffer(ctx, vao, index, ctx->Shared->NullBufferObj,
+   vao->VertexBinding[index].Offset,
+   vao->VertexBinding[index].Stride, false);
}
 }
 
@@ -1302,7 +1305,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
 
  /* unbind any vertex pointers bound to this buffer */
  for (j = 0; j < ARRAY_SIZE(vao->VertexBinding); j++) {
-unbind(ctx, >VertexBinding[j].BufferObj, bufObj);
+unbind(ctx, vao, j, bufObj);
  }
 
  if (ctx->Array.ArrayBufferObj == bufObj) {
-- 
2.5.5

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


[Mesa-dev] [PATCH 11/11] mesa: Remove set but not used gl_client_array::Stride.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

The field is only read for printing today and
there it was probably a leftover.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/mtypes.h   | 1 -
 src/mesa/main/varray.c   | 1 -
 src/mesa/main/varray.h   | 1 -
 src/mesa/state_tracker/st_cb_rasterpos.c | 1 -
 src/mesa/vbo/vbo_context.c   | 1 -
 src/mesa/vbo/vbo_exec_draw.c | 1 -
 src/mesa/vbo/vbo_save_draw.c | 1 -
 src/mesa/vbo/vbo_split_copy.c| 3 +--
 8 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f7f797b..26bc2e8 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1320,7 +1320,6 @@ struct gl_client_array
GLint Size;  /**< components per element (1,2,3,4) */
GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
GLenum Format;   /**< default: GL_RGBA, but may be GL_BGRA */
-   GLsizei Stride; /**< user-specified stride */
GLsizei StrideB;/**< actual stride in bytes */
GLuint _ElementSize; /**< size of each element in bytes */
const GLubyte *Ptr;  /**< Points to array data */
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 6eb2265..b092117 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2319,7 +2319,6 @@ _mesa_copy_client_array(struct gl_context *ctx,
dst->Size = src->Size;
dst->Type = src->Type;
dst->Format = src->Format;
-   dst->Stride = src->Stride;
dst->StrideB = src->StrideB;
dst->Ptr = src->Ptr;
dst->Normalized = src->Normalized;
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index cacb093..638408b 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -62,7 +62,6 @@ _mesa_update_client_array(struct gl_context *ctx,
dst->Size = src->Size;
dst->Type = src->Type;
dst->Format = src->Format;
-   dst->Stride = src->Stride;
dst->StrideB = binding->Stride;
dst->Ptr = _mesa_vertex_attrib_address(src, binding);
dst->Normalized = src->Normalized;
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c 
b/src/mesa/state_tracker/st_cb_rasterpos.c
index fc7c07d..29c1484 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -196,7 +196,6 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct 
draw_context *draw)
   rs->array[i].Size = 4;
   rs->array[i].Type = GL_FLOAT;
   rs->array[i].Format = GL_RGBA;
-  rs->array[i].Stride = 0;
   rs->array[i].StrideB = 0;
   rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
   rs->array[i].Normalized = GL_TRUE;
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 9bceaf4..7a5bd51 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -55,7 +55,6 @@ init_array(struct gl_context *ctx, struct gl_client_array *cl,
cl->Size = size;
cl->Type = GL_FLOAT;
cl->Format = GL_RGBA;
-   cl->Stride = 0;
cl->StrideB = 0;
cl->_ElementSize = cl->Size * sizeof(GLfloat);
cl->Ptr = pointer;
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 7f3e1e8..f6ae863 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -247,7 +247,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
  }
 arrays[attr].Size = exec->vtx.attrsz[src];
 arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
-arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat);
 arrays[attr].Type = exec->vtx.attrtype[src];
 arrays[attr].Integer =
vbo_attrtype_to_integer_flag(exec->vtx.attrtype[src]);
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 3424b78..507ab82 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -196,7 +196,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
 arrays[attr].Ptr = (const GLubyte *) NULL + buffer_offset;
 arrays[attr].Size = node_attrsz[src];
 arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat);
-arrays[attr].Stride = node->vertex_size * sizeof(GLfloat);
  arrays[attr].Type = node_attrtype[src];
  arrays[attr].Integer =
vbo_attrtype_to_integer_flag(node_attrtype[src]);
diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c
index 084110c..daa09c2 100644
--- a/src/mesa/vbo/vbo_split_copy.c
+++ b/src/mesa/vbo/vbo_split_copy.c
@@ -161,7 +161,7 @@ dump_draw_info(struct gl_context *ctx,
arrays[j]->Size, arrays[j]->Type, arrays[j]->StrideB);
  if (0) {
 GLint k = prims[i].start + prims[i].count - 1;
-GLfloat *last = (GLfloat *) (arrays[j]->Ptr + arrays[j]->Stride * 
k);
+GLfloat *last = (GLfloat *) 

[Mesa-dev] [PATCH 09/11] vbo: Use the VAO array enabled flags in vbo_exec_array.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Instead of gl_client_array::Enabled inside a VAO,
directly use the gl_vertex_attrib_array::Enabled value
which is the origin of the above.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_exec_array.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 8de3e0c..f371890 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -295,6 +295,7 @@ recalculate_input_bindings(struct gl_context *ctx)
 {
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = >exec;
+   const struct gl_vertex_attrib_array *array = ctx->Array.VAO->VertexAttrib;
struct gl_client_array *vertexAttrib = ctx->Array.VAO->_VertexAttrib;
const struct gl_client_array **inputs = >array.inputs[0];
GLbitfield64 const_inputs = 0x0;
@@ -308,7 +309,7 @@ recalculate_input_bindings(struct gl_context *ctx)
* are available as per-vertex attributes.
*/
   for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
-if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
+if (array[VERT_ATTRIB_FF(i)].Enabled)
inputs[i] = [VERT_ATTRIB_FF(i)];
 else {
inputs[i] = >currval[VBO_ATTRIB_POS+i];
@@ -348,9 +349,9 @@ recalculate_input_bindings(struct gl_context *ctx)
* slots are considered "magic."
*/
   if (ctx->API == API_OPENGL_COMPAT) {
- if (vertexAttrib[VERT_ATTRIB_GENERIC0].Enabled)
+ if (array[VERT_ATTRIB_GENERIC0].Enabled)
 inputs[0] = [VERT_ATTRIB_GENERIC0];
- else if (vertexAttrib[VERT_ATTRIB_POS].Enabled)
+ else if (array[VERT_ATTRIB_POS].Enabled)
 inputs[0] = [VERT_ATTRIB_POS];
  else {
 inputs[0] = >currval[VBO_ATTRIB_POS];
@@ -358,7 +359,7 @@ recalculate_input_bindings(struct gl_context *ctx)
  }
 
  for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) {
-if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
+if (array[VERT_ATTRIB_FF(i)].Enabled)
inputs[i] = [VERT_ATTRIB_FF(i)];
 else {
inputs[i] = >currval[VBO_ATTRIB_POS+i];
@@ -367,7 +368,7 @@ recalculate_input_bindings(struct gl_context *ctx)
  }
 
  for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {
-if (vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
+if (array[VERT_ATTRIB_GENERIC(i)].Enabled)
inputs[VERT_ATTRIB_GENERIC(i)] =
   [VERT_ATTRIB_GENERIC(i)];
 else {
@@ -385,14 +386,14 @@ recalculate_input_bindings(struct gl_context *ctx)
   * be enabled.
   */
  for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
-assert(!vertexAttrib[VERT_ATTRIB_FF(i)].Enabled);
+assert(!array[VERT_ATTRIB_FF(i)].Enabled);
 
 inputs[i] = >currval[VBO_ATTRIB_POS+i];
 const_inputs |= VERT_BIT_FF(i);
  }
 
  for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
-if (vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
+if (array[VERT_ATTRIB_GENERIC(i)].Enabled)
inputs[VERT_ATTRIB_GENERIC(i)] =
   [VERT_ATTRIB_GENERIC(i)];
 else {
-- 
2.5.5

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


[Mesa-dev] [PATCH 08/11] vbo: Walk the VAO in check_array_data.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_exec_array.c | 49 +--
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 48182ab..8de3e0c 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -98,26 +98,30 @@ check_buffers_are_unmapped(struct gl_context *ctx)
  * For debugging purposes; not normally used.
  */
 static void
-check_array_data(struct gl_context *ctx, struct gl_client_array *array,
+check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao,
  GLuint attrib, GLuint j)
 {
+   const struct gl_vertex_attrib_array *array = >VertexAttrib[attrib];
if (array->Enabled) {
+  const struct gl_vertex_buffer_binding *binding =
+ >VertexBinding[array->VertexBinding];
+  struct gl_buffer_object *bo = binding->BufferObj;
   const void *data = array->Ptr;
-  if (_mesa_is_bufferobj(array->BufferObj)) {
- if (!array->BufferObj->Mappings[MAP_INTERNAL].Pointer) {
+  if (_mesa_is_bufferobj(bo)) {
+ if (!bo->Mappings[MAP_INTERNAL].Pointer) {
 /* need to map now */
-array->BufferObj->Mappings[MAP_INTERNAL].Pointer =
-   ctx->Driver.MapBufferRange(ctx, 0, array->BufferObj->Size,
- GL_MAP_READ_BIT, array->BufferObj,
+bo->Mappings[MAP_INTERNAL].Pointer =
+   ctx->Driver.MapBufferRange(ctx, 0, bo->Size,
+ GL_MAP_READ_BIT, bo,
   MAP_INTERNAL);
  }
- data = ADD_POINTERS(data,
- array->BufferObj->Mappings[MAP_INTERNAL].Pointer);
+ data = ADD_POINTERS(_mesa_vertex_attrib_address(array, binding),
+ bo->Mappings[MAP_INTERNAL].Pointer);
   }
   switch (array->Type) {
   case GL_FLOAT:
  {
-GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j);
+GLfloat *f = (GLfloat *) ((GLubyte *) data + binding->Stride * j);
 GLint k;
 for (k = 0; k < array->Size; k++) {
if (IS_INF_OR_NAN(f[k]) ||
@@ -126,9 +130,9 @@ check_array_data(struct gl_context *ctx, struct 
gl_client_array *array,
   printf("  Element[%u].%u = %f\n", j, k, f[k]);
   printf("  Array %u at %p\n", attrib, (void* ) array);
   printf("  Type 0x%x, Size %d, Stride %d\n",
-array->Type, array->Size, array->Stride);
+array->Type, array->Size, binding->Stride);
   printf("  Address/offset %p in Buffer Object %u\n",
-array->Ptr, array->BufferObj->Name);
+array->Ptr, bo->Name);
   f[k] = 1.0F; /* XXX replace the bad value! */
}
/*assert(!IS_INF_OR_NAN(f[k]));*/
@@ -146,12 +150,17 @@ check_array_data(struct gl_context *ctx, struct 
gl_client_array *array,
  * Unmap the buffer object referenced by given array, if mapped.
  */
 static void
-unmap_array_buffer(struct gl_context *ctx, struct gl_client_array *array)
+unmap_array_buffer(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+   GLuint attrib)
 {
-   if (array->Enabled &&
-   _mesa_is_bufferobj(array->BufferObj) &&
-   _mesa_bufferobj_mapped(array->BufferObj, MAP_INTERNAL)) {
-  ctx->Driver.UnmapBuffer(ctx, array->BufferObj, MAP_INTERNAL);
+   const struct gl_vertex_attrib_array *array = >VertexAttrib[attrib];
+   if (array->Enabled) {
+  const struct gl_vertex_buffer_binding *binding =
+ >VertexBinding[array->VertexBinding];
+  struct gl_buffer_object *bo = binding->BufferObj;
+  if (_mesa_is_bufferobj(bo) && _mesa_bufferobj_mapped(bo, MAP_INTERNAL)) {
+ ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
+  }
}
 }
 
@@ -197,8 +206,8 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei 
count, GLenum elemType,
   }
 
   /* check element j of each enabled array */
-  for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) {
- check_array_data(ctx, >_VertexAttrib[k], k, j);
+  for (k = 0; k < VERT_ATTRIB_MAX; k++) {
+ check_array_data(ctx, vao, k, j);
   }
}
 
@@ -207,8 +216,8 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei 
count, GLenum elemType,
   MAP_INTERNAL);
}
 
-   for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) {
-  unmap_array_buffer(ctx, >_VertexAttrib[k]);
+   for (k = 0; k < VERT_ATTRIB_MAX; k++) {
+  unmap_array_buffer(ctx, vao, k);
}
 }
 
-- 
2.5.5


[Mesa-dev] [PATCH 06/11] mesa: Walk the VAO in _mesa_print_arrays.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO. Also make use of gl_vert_attrib_name.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/varray.c | 52 +++---
 1 file changed, 20 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 5cd7324..577f5ab 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2364,44 +2364,32 @@ _mesa_copy_vertex_buffer_binding(struct gl_context *ctx,
 }
 
 /**
- * Print vertex array's fields.
- */
-static void
-print_array(const char *name, GLint index, const struct gl_client_array *array)
-{
-   if (index >= 0)
-  fprintf(stderr, "  %s[%d]: ", name, index);
-   else
-  fprintf(stderr, "  %s: ", name);
-   fprintf(stderr, "Ptr=%p, Type=%s, Size=%d, ElemSize=%u, Stride=%d, 
Buffer=%u(Size %lu)\n",
-   array->Ptr, _mesa_enum_to_string(array->Type), array->Size,
-   array->_ElementSize, array->StrideB, array->BufferObj->Name,
-   (unsigned long) array->BufferObj->Size);
-}
-
-
-/**
  * Print current vertex object/array info.  For debug.
  */
 void
 _mesa_print_arrays(struct gl_context *ctx)
 {
-   struct gl_vertex_array_object *vao = ctx->Array.VAO;
-   GLuint i;
+   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
 
-   printf("Array Object %u\n", vao->Name);
-   if (vao->_VertexAttrib[VERT_ATTRIB_POS].Enabled)
-  print_array("Vertex", -1, >_VertexAttrib[VERT_ATTRIB_POS]);
-   if (vao->_VertexAttrib[VERT_ATTRIB_NORMAL].Enabled)
-  print_array("Normal", -1, >_VertexAttrib[VERT_ATTRIB_NORMAL]);
-   if (vao->_VertexAttrib[VERT_ATTRIB_COLOR0].Enabled)
-  print_array("Color", -1, >_VertexAttrib[VERT_ATTRIB_COLOR0]);
-   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
-  if (vao->_VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled)
- print_array("TexCoord", i, >_VertexAttrib[VERT_ATTRIB_TEX(i)]);
-   for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++)
-  if (vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
- print_array("Attrib", i, >_VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
+   fprintf(stderr, "Array Object %u\n", vao->Name);
+
+   unsigned i;
+   for (i = 0; i < VERT_ATTRIB_MAX; ++i) {
+  const struct gl_vertex_attrib_array *array = >VertexAttrib[i];
+  if (!array->Enabled)
+ continue;
+
+  const struct gl_vertex_buffer_binding *binding =
+ >VertexBinding[array->VertexBinding];
+  const struct gl_buffer_object *bo = binding->BufferObj;
+
+  fprintf(stderr, "  %s: Ptr=%p, Type=%s, Size=%d, ElemSize=%u, "
+  "Stride=%d, Buffer=%u(Size %lu)\n",
+  gl_vert_attrib_name((gl_vert_attrib)i),
+  array->Ptr, _mesa_enum_to_string(array->Type), array->Size,
+  array->_ElementSize, binding->Stride, bo->Name,
+  (unsigned long) bo->Size);
+   }
 }
 
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 07/11] vbo: Walk the VAO in print_draw_arrays.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO. Also make use of gl_vert_attrib_name.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_exec_array.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 2d5b0dc..48182ab 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -230,37 +230,37 @@ static void
 print_draw_arrays(struct gl_context *ctx,
   GLenum mode, GLint start, GLsizei count)
 {
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = >exec;
-   struct gl_vertex_array_object *vao = ctx->Array.VAO;
-   int i;
+   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
 
printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n",
  mode, start, count);
 
-   for (i = 0; i < 32; i++) {
-  struct gl_buffer_object *bufObj = exec->array.inputs[i]->BufferObj;
-  GLuint bufName = bufObj->Name;
-  GLint stride = exec->array.inputs[i]->Stride;
-  printf("attr %2d: size %d stride %d  enabled %d  "
+   unsigned i;
+   for (i = 0; i < VERT_ATTRIB_MAX; ++i) {
+  const struct gl_vertex_attrib_array *array = >VertexAttrib[i];
+  if (!array->Enabled)
+ continue;
+
+  const struct gl_vertex_buffer_binding *binding =
+ >VertexBinding[array->VertexBinding];
+  struct gl_buffer_object *bufObj = binding->BufferObj;
+
+  printf("attr %s: size %d stride %d  enabled %d  "
 "ptr %p  Bufobj %u\n",
-i,
-exec->array.inputs[i]->Size,
-stride,
-/*exec->array.inputs[i]->Enabled,*/
-vao->_VertexAttrib[VERT_ATTRIB_FF(i)].Enabled,
-exec->array.inputs[i]->Ptr,
-bufName);
-
-  if (bufName) {
+ gl_vert_attrib_name((gl_vert_attrib)i),
+array->Size, binding->Stride, array->Enabled,
+ array->Ptr, bufObj->Name);
+
+  if (_mesa_is_bufferobj(bufObj)) {
  GLubyte *p = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size,
 GL_MAP_READ_BIT, bufObj,
  MAP_INTERNAL);
- int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr;
+ int offset = (int) (GLintptr)
+_mesa_vertex_attrib_address(array, binding);
  float *f = (float *) (p + offset);
  int *k = (int *) f;
  int i;
- int n = (count * stride) / 4;
+ int n = (count * binding->Stride) / 4;
  if (n > 32)
 n = 32;
  printf("  Data at offset %d:\n", offset);
-- 
2.5.5

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


[Mesa-dev] [PATCH 05/11] vbo: Walk the VAO to check for mapped buffers.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Similarily to _mesa_all_varyings_in_vbos walk the VAO
to check if we have an illegal mapped buffer object
instead of walking all gl_client_arrays.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_exec_array.c | 33 +++--
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index b75c772..2d5b0dc 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -47,16 +47,29 @@
  * to draw.
  */
 static bool
-check_input_buffers_are_unmapped(const struct gl_client_array **inputs)
+check_input_buffers_are_unmapped(const struct gl_vertex_array_object *vao)
 {
-   GLuint i;
-
-   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
-  if (inputs[i]) {
- struct gl_buffer_object *obj = inputs[i]->BufferObj;
- if (_mesa_check_disallowed_mapping(obj))
-return false;
-  }
+   /* Walk the enabled arrays that have a vbo attached */
+   GLbitfield64 mask = vao->_Enabled & vao->VertexAttribBufferMask;
+
+   while (mask) {
+  int i = ffsll(mask) - 1;
+  const struct gl_vertex_attrib_array *attrib_array =
+ >VertexAttrib[i];
+  const struct gl_vertex_buffer_binding *buffer_binding =
+ >VertexBinding[attrib_array->VertexBinding];
+
+  /* Only enabled arrays shall appear in the _Enabled bitmask */
+  assert(attrib_array->Enabled);
+  /* We have already masked with vao->VertexAttribBufferMask  */
+  assert(_mesa_is_bufferobj(buffer_binding->BufferObj));
+
+  /* Bail out once we find the first disallowed mapping */
+  if (_mesa_check_disallowed_mapping(buffer_binding->BufferObj))
+ return false;
+
+  /* We have handled everything that is bound to this buffer_binding. */
+  mask &= ~buffer_binding->_BoundArrays;
}
 
return true;
@@ -75,7 +88,7 @@ check_buffers_are_unmapped(struct gl_context *ctx)
 
/* check the current vertex arrays */
return !_mesa_check_disallowed_mapping(exec->vtx.bufferobj) &&
-  check_input_buffers_are_unmapped(exec->array.inputs);
+  check_input_buffers_are_unmapped(ctx->Array.VAO);
 }
 
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 04/11] vbo: Walk the VAO to see if all varyings are in vbos.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

In vbo_draw_transform_feedback we currently look at
exec->array.inputs to determine if all varying
vertex attributes reside in vbos. But the vbo_bind_arrays
call only happens past the vbo_all_varyings_in_vbos
query. Thus we may work on a stale set of client arrays.
Using the current VAOs content for this query feels much
more logical to me.
Additionally with this change mesa makes more use of the
information already tracked in the VAO instead of looping
across VERT_ATTRIB_MAX vertex arrays.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_exec_array.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 87ed7f7..b75c772 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -27,6 +27,7 @@
  **/
 
 #include 
+#include "main/arrayobj.h"
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/state.h"
@@ -1290,7 +1291,6 @@ vbo_draw_transform_feedback(struct gl_context *ctx, 
GLenum mode,
 GLuint stream, GLuint numInstances)
 {
struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = >exec;
struct _mesa_prim prim[2];
 
if (!_mesa_validate_DrawTransformFeedback(ctx, mode, obj, stream,
@@ -1300,7 +1300,7 @@ vbo_draw_transform_feedback(struct gl_context *ctx, 
GLenum mode,
 
if (ctx->Driver.GetTransformFeedbackVertexCount &&
(ctx->Const.AlwaysUseGetTransformFeedbackVertexCount ||
-!vbo_all_varyings_in_vbos(exec->array.inputs))) {
+!_mesa_all_varyings_in_vbos(ctx->Array.VAO))) {
   GLsizei n = ctx->Driver.GetTransformFeedbackVertexCount(ctx, obj, 
stream);
   vbo_draw_arrays(ctx, mode, 0, n, numInstances, 0);
   return;
-- 
2.5.5

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


[Mesa-dev] [PATCH 10/11] mesa: Remove set but not used gl_client_array::Enabled.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

The way it is used today does not care about the
Enabled flag anymore.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/mtypes.h   | 1 -
 src/mesa/main/varray.c   | 1 -
 src/mesa/main/varray.h   | 1 -
 src/mesa/state_tracker/st_cb_rasterpos.c | 1 -
 src/mesa/vbo/vbo_context.c   | 1 -
 src/mesa/vbo/vbo_exec_draw.c | 1 -
 src/mesa/vbo/vbo_save_draw.c | 1 -
 src/mesa/vbo/vbo_split_copy.c| 5 ++---
 8 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 87e3c0c..f7f797b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1324,7 +1324,6 @@ struct gl_client_array
GLsizei StrideB;/**< actual stride in bytes */
GLuint _ElementSize; /**< size of each element in bytes */
const GLubyte *Ptr;  /**< Points to array data */
-   GLboolean Enabled;  /**< Enabled flag is a boolean */
GLboolean Normalized;/**< GL_ARB_vertex_program */
GLboolean Integer;   /**< Integer-valued? */
GLboolean Doubles;   /**< double precision values are not converted to 
floats */
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 577f5ab..6eb2265 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2322,7 +2322,6 @@ _mesa_copy_client_array(struct gl_context *ctx,
dst->Stride = src->Stride;
dst->StrideB = src->StrideB;
dst->Ptr = src->Ptr;
-   dst->Enabled = src->Enabled;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
dst->Doubles = src->Doubles;
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 18bfe19..cacb093 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -65,7 +65,6 @@ _mesa_update_client_array(struct gl_context *ctx,
dst->Stride = src->Stride;
dst->StrideB = binding->Stride;
dst->Ptr = _mesa_vertex_attrib_address(src, binding);
-   dst->Enabled = src->Enabled;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
dst->Doubles = src->Doubles;
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c 
b/src/mesa/state_tracker/st_cb_rasterpos.c
index eec72f8..fc7c07d 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -199,7 +199,6 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct 
draw_context *draw)
   rs->array[i].Stride = 0;
   rs->array[i].StrideB = 0;
   rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
-  rs->array[i].Enabled = GL_TRUE;
   rs->array[i].Normalized = GL_TRUE;
   rs->array[i].BufferObj = NULL;
   rs->arrays[i] = >array[i];
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index ae5d265..9bceaf4 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -59,7 +59,6 @@ init_array(struct gl_context *ctx, struct gl_client_array *cl,
cl->StrideB = 0;
cl->_ElementSize = cl->Size * sizeof(GLfloat);
cl->Ptr = pointer;
-   cl->Enabled = 1;
 
_mesa_reference_buffer_object(ctx, >BufferObj,
  ctx->Shared->NullBufferObj);
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 8d1b2c0..7f3e1e8 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -252,7 +252,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
 arrays[attr].Integer =
vbo_attrtype_to_integer_flag(exec->vtx.attrtype[src]);
  arrays[attr].Format = GL_RGBA;
-arrays[attr].Enabled = 1;
  arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat);
  _mesa_reference_buffer_object(ctx,
[attr].BufferObj,
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 7881ce1..3424b78 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -201,7 +201,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
  arrays[attr].Integer =
vbo_attrtype_to_integer_flag(node_attrtype[src]);
  arrays[attr].Format = GL_RGBA;
-arrays[attr].Enabled = 1;
  arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat);
  _mesa_reference_buffer_object(ctx,
[attr].BufferObj,
diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c
index cb27ef9..084110c 100644
--- a/src/mesa/vbo/vbo_split_copy.c
+++ b/src/mesa/vbo/vbo_split_copy.c
@@ -156,8 +156,8 @@ dump_draw_info(struct gl_context *ctx,
   printf("  IB: %p\n", (void*) ib);
   for (j = 0; j < VERT_ATTRIB_MAX; j++) {
  printf("array %d at %p:\n", j, (void*) arrays[j]);
- printf("  enabled %d, ptr %p, size %d, type 0x%x, stride %d\n",
-   arrays[j]->Enabled, 

[Mesa-dev] [PATCH 03/11] mesa: Implement _mesa_all_varyings_in_vbos.

2016-06-17 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Implement the equivalent of vbo_all_varyings_in_vbos for
vertex array objects.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/arrayobj.c | 35 +++
 src/mesa/main/arrayobj.h |  4 
 2 files changed, 39 insertions(+)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 9c3451e..041ee63 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -359,6 +359,41 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx,
 }
 
 
+bool
+_mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao)
+{
+   /* Walk those enabled arrays that have the default vbo attached */
+   GLbitfield64 mask = vao->_Enabled & ~vao->VertexAttribBufferMask;
+
+   while (mask) {
+  /** We do not use u_bit_scan64 as we can here walk
+   *  multiple attrib arrays at once
+   */
+  const int i = ffsll(mask) - 1;
+  const struct gl_vertex_attrib_array *attrib_array =
+ >VertexAttrib[i];
+  const struct gl_vertex_buffer_binding *buffer_binding =
+ >VertexBinding[attrib_array->VertexBinding];
+
+  /* Only enabled arrays shall appear in the _Enabled bitmask */
+  assert(attrib_array->Enabled);
+  /* We have already masked out vao->VertexAttribBufferMask  */
+  assert(!_mesa_is_bufferobj(buffer_binding->BufferObj));
+
+  /* Bail out once we find the first non vbo with a non zero stride */
+  if (buffer_binding->Stride != 0)
+ return false;
+
+  /* Note that we cannot use the xor variant since the _BoundArray mask
+   * may contain array attributes that are bound but not enabled.
+   */
+  mask &= ~buffer_binding->_BoundArrays;
+   }
+
+   return true;
+}
+
+
 /**/
 /* API Functions  */
 /**/
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 6a4247f..d30c85c 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -81,6 +81,10 @@ extern void
 _mesa_update_vao_client_arrays(struct gl_context *ctx,
struct gl_vertex_array_object *vao);
 
+/* Returns true if all varying arrays reside in vbos */
+extern bool
+_mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao);
+
 /*
  * API functions
  */
-- 
2.5.5

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


Re: [Mesa-dev] [RFC 2/7] pipe-loader-drm: Add common pipe_screen refcounting

2016-06-17 Thread Ilia Mirkin
On Fri, Jun 17, 2016 at 1:45 PM, Rob Herring  wrote:
> Some gallium drivers have implemented reference counting of pipe_screen
> to avoid creating multiple screens for a device. Move this into the
> pipe-loader where it can be shared.
>
> Not completely sure, but it should not necessary to dup() the fd as
> dri2_create_screen does that for us already.

Definitely necessary for nouveau, pretty sure for everyone. See
commits a59f2bb17 and a98600b0eb.

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


[Mesa-dev] [RFC 7/7] radeon: remove screen ref counting

2016-06-17 Thread Rob Herring
Now that the pipe-loader is reference counting the screen creation, it
is unnecessary to do in it the winsys/driver.

Signed-off-by: Rob Herring 
Cc: "Marek Olšák" 
Cc: Ilia Mirkin 
---
 src/gallium/drivers/r300/r300_screen.c|  3 -
 src/gallium/drivers/r600/r600_pipe.c  |  6 --
 src/gallium/drivers/radeon/radeon_winsys.h|  8 ---
 src/gallium/drivers/radeonsi/si_pipe.c|  6 --
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 66 +--
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h |  1 -
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 80 +--
 7 files changed, 3 insertions(+), 167 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_screen.c 
b/src/gallium/drivers/r300/r300_screen.c
index 681681b..5d2d955 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -674,9 +674,6 @@ static void r300_destroy_screen(struct pipe_screen* pscreen)
 struct r300_screen* r300screen = r300_screen(pscreen);
 struct radeon_winsys *rws = radeon_winsys(pscreen);
 
-if (rws && !rws->unref(rws))
-  return;
-
 pipe_mutex_destroy(r300screen->cmask_mutex);
 
 if (rws)
diff --git a/src/gallium/drivers/r600/r600_pipe.c 
b/src/gallium/drivers/r600/r600_pipe.c
index a49b00f..66cb78c 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -566,12 +566,6 @@ static void r600_destroy_screen(struct pipe_screen* 
pscreen)
 {
struct r600_screen *rscreen = (struct r600_screen *)pscreen;
 
-   if (!rscreen)
-   return;
-
-   if (!rscreen->b.ws->unref(rscreen->b.ws))
-   return;
-
if (rscreen->global_pool) {
compute_memory_pool_delete(rscreen->global_pool);
}
diff --git a/src/gallium/drivers/radeon/radeon_winsys.h 
b/src/gallium/drivers/radeon/radeon_winsys.h
index c2d1f9e..ffe0d83 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -416,14 +416,6 @@ struct radeon_winsys {
 struct pipe_screen *screen;
 
 /**
- * Decrement the winsys reference count.
- *
- * \param ws  The winsys this function is called for.
- * \returnTrue if the winsys and screen should be destroyed.
- */
-bool (*unref)(struct radeon_winsys *ws);
-
-/**
  * Destroy this winsys.
  *
  * \param wsThe winsys this function is called from.
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index 0c601da..f3256fc 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -628,12 +628,6 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
};
unsigned i;
 
-   if (!sscreen)
-   return;
-
-   if (!sscreen->b.ws->unref(sscreen->b.ws))
-   return;
-
/* Free shader parts. */
for (i = 0; i < ARRAY_SIZE(parts); i++) {
while (parts[i]) {
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 7016221..39b4a11 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -34,7 +34,6 @@
 #include "amdgpu_cs.h"
 #include "amdgpu_public.h"
 
-#include "util/u_hash_table.h"
 #include 
 #include 
 #include 
@@ -59,9 +58,6 @@
 #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_8X16   16
 #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16  17
 
-static struct util_hash_table *dev_tab = NULL;
-pipe_static_mutex(dev_tab_mutex);
-
 static unsigned cik_get_num_tile_pipes(struct amdgpu_gpu_info *info)
 {
unsigned mode2d = info->gb_tile_mode[CIK_TILE_MODE_COLOR_2D];
@@ -386,20 +382,6 @@ static bool amdgpu_read_registers(struct radeon_winsys 
*rws,
0x, 0, out) == 0;
 }
 
-static unsigned hash_dev(void *key)
-{
-#if defined(PIPE_ARCH_X86_64)
-   return pointer_to_intptr(key) ^ (pointer_to_intptr(key) >> 32);
-#else
-   return pointer_to_intptr(key);
-#endif
-}
-
-static int compare_dev(void *key1, void *key2)
-{
-   return key1 != key2;
-}
-
 void amdgpu_ws_queue_cs(struct amdgpu_winsys *ws, struct amdgpu_cs *cs)
 {
pipe_semaphore_wait(>cs_queue_has_space);
@@ -448,26 +430,6 @@ static PIPE_THREAD_ROUTINE(amdgpu_cs_thread_func, param)
 DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", TRUE)
 static PIPE_THREAD_ROUTINE(amdgpu_cs_thread_func, param);
 
-static bool amdgpu_winsys_unref(struct radeon_winsys *rws)
-{
-   struct amdgpu_winsys *ws = (struct amdgpu_winsys*)rws;
-   bool destroy;
-
-   /* When the reference counter drops to zero, remove the device pointer
-* from the table.
-* This must happen while the mutex is locked, so that
-* amdgpu_winsys_create in another thread doesn't get the winsys
-* from the table 

[Mesa-dev] [RFC 4/7] Revert "virgl: mark function as static"

2016-06-17 Thread Rob Herring
This reverts commit e7a27f70b91e202ad9afc3e67e1080572d4d4a0b.
Cc: Emil Velikov 
Cc: Dave Airlie 
---
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c 
b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index e03e8bd..cbd416c 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -757,7 +757,7 @@ static void virgl_fence_reference(struct virgl_winsys *vws,
 }
 
 
-static struct virgl_winsys *
+struct virgl_winsys *
 virgl_drm_winsys_create(int drmFD)
 {
struct virgl_drm_winsys *qdws;
-- 
2.7.4

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


[Mesa-dev] [RFC 2/7] pipe-loader-drm: Add common pipe_screen refcounting

2016-06-17 Thread Rob Herring
Some gallium drivers have implemented reference counting of pipe_screen
to avoid creating multiple screens for a device. Move this into the
pipe-loader where it can be shared.

Not completely sure, but it should not necessary to dup() the fd as
dri2_create_screen does that for us already.

Signed-off-by: Rob Herring 
Cc: Emil Velikov 
---
 .../auxiliary/pipe-loader/pipe_loader_drm.c| 66 +-
 src/gallium/include/pipe/p_screen.h|  1 +
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 62f109f..71169ed 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "loader.h"
 #include "target-helpers/drm_helper_public.h"
@@ -41,9 +42,12 @@
 #include "pipe_loader_priv.h"
 #include "pipe/p_screen.h"
 
+#include "os/os_thread.h"
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "util/u_debug.h"
+#include "util/u_pointer.h"
+#include "util/u_hash_table.h"
 
 #define DRM_RENDER_NODE_DEV_NAME_FORMAT "%s/renderD%d"
 #define DRM_RENDER_NODE_MAX_NODES 63
@@ -266,14 +270,50 @@ pipe_loader_drm_probe(struct pipe_loader_device **devs, 
int ndev)
return j;
 }
 
+static struct util_hash_table *fd_tab = NULL;
+pipe_static_mutex(loader_mutex);
+static int refcnt;
+
+static unsigned hash_fd(void *key)
+{
+   int fd = pointer_to_intptr(key);
+   struct stat stat;
+   fstat(fd, );
+
+   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, );
+   fstat(fd2, );
+
+   return stat1.st_dev != stat2.st_dev ||
+ stat1.st_ino != stat2.st_ino ||
+ stat1.st_rdev != stat2.st_rdev;
+}
+
 static void
 pipe_loader_drm_release(struct pipe_loader_device **dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev);
struct pipe_screen *pscreen = ddev->base.pscreen;
+   int fd = ddev->fd;
 
-   pscreen->destroy(pscreen);
+   pipe_mutex_lock(loader_mutex);
+   if (pscreen) {
+  if (--pscreen->refcnt != 0) {
+ pipe_mutex_unlock(loader_mutex);
+ return;
+  }
 
+  pscreen->destroy(pscreen);
+
+  util_hash_table_remove(fd_tab, intptr_to_pointer(fd));
+   }
 #ifndef GALLIUM_STATIC_TARGETS
if (ddev->lib)
   util_dl_close(ddev->lib);
@@ -283,6 +323,8 @@ pipe_loader_drm_release(struct pipe_loader_device **dev)
FREE(ddev->base.driver_name);
FREE(ddev);
*dev = NULL;
+
+   pipe_mutex_unlock(loader_mutex);
 }
 
 static const struct drm_conf_ret *
@@ -301,10 +343,30 @@ static struct pipe_screen *
 pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
+   int fd = ddev->fd;
struct pipe_screen *pscreen = NULL;
 
-   pscreen = ddev->dd->create_screen(fd);
+   pipe_mutex_lock(loader_mutex);
+   if (!fd_tab) {
+  fd_tab = util_hash_table_create(hash_fd, compare_fd);
+  if (!fd_tab)
+ goto unlock;
+   }
+
+   pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
+   if (pscreen) {
+  pscreen->refcnt++;
+  goto unlock;
+   } else {
+  pscreen = ddev->dd->create_screen(fd);
+  if (pscreen)
+ util_hash_table_set(fd_tab, intptr_to_pointer(fd), pscreen);
+  pscreen->refcnt = 1;
+   }
+
+unlock:
ddev->base.pscreen = pscreen;
+   pipe_mutex_unlock(loader_mutex);
return pscreen;
 }
 
diff --git a/src/gallium/include/pipe/p_screen.h 
b/src/gallium/include/pipe/p_screen.h
index 755291a..28a3f71 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -66,6 +66,7 @@ struct pipe_memory_info;
  * context.
  */
 struct pipe_screen {
+   int refcnt;
void (*destroy)( struct pipe_screen * );
 
const char *(*get_name)( struct pipe_screen * );
-- 
2.7.4

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


[Mesa-dev] [RFC 6/7] freedreno: remove screen ref counting

2016-06-17 Thread Rob Herring
Now that the pipe-loader is reference counting the screen creation, it
is unnecessary to do in it the winsys/driver.

Signed-off-by: Rob Herring 
Cc: Rob Clark 
---
 src/gallium/drivers/freedreno/freedreno_screen.c   |  1 -
 src/gallium/drivers/freedreno/freedreno_screen.h   | 10 ---
 .../winsys/freedreno/drm/freedreno_drm_winsys.c| 89 +-
 3 files changed, 2 insertions(+), 98 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index c258074..cd7748f 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -561,7 +561,6 @@ fd_screen_create(struct fd_device *dev)
pscreen = >base;
 
screen->dev = dev;
-   screen->refcnt = 1;
 
// maybe this should be in context?
screen->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h 
b/src/gallium/drivers/freedreno/freedreno_screen.h
index a81c778..8dcacca 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.h
+++ b/src/gallium/drivers/freedreno/freedreno_screen.h
@@ -42,16 +42,6 @@ struct fd_bo;
 struct fd_screen {
struct pipe_screen base;
 
-   /* it would be tempting to use pipe_reference here, but that
-* really doesn't work well if it isn't the first member of
-* the struct, so not quite so awesome to be adding refcnting
-* further down the inheritance hierarchy:
-*/
-   int refcnt;
-
-   /* place for winsys to stash it's own stuff: */
-   void *winsys_priv;
-
uint32_t gmemsize_bytes;
uint32_t device_id;
uint32_t gpu_id; /* 220, 305, etc */
diff --git a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c 
b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
index e4785f8..81cdadf 100644
--- a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
+++ b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
@@ -26,102 +26,17 @@
  *Rob Clark 
  */
 
-#include 
-
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
-#include "util/u_format.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-#include "util/u_hash_table.h"
-#include "os/os_thread.h"
 
 #include "freedreno_drm_public.h"
 
 #include "freedreno/freedreno_screen.h"
 
-static struct util_hash_table *fd_tab = NULL;
-
-pipe_static_mutex(fd_screen_mutex);
-
-static void
-fd_drm_screen_destroy(struct pipe_screen *pscreen)
-{
-   struct fd_screen *screen = fd_screen(pscreen);
-   boolean destroy;
-
-   pipe_mutex_lock(fd_screen_mutex);
-   destroy = --screen->refcnt == 0;
-   if (destroy) {
-   int fd = fd_device_fd(screen->dev);
-   util_hash_table_remove(fd_tab, intptr_to_pointer(fd));
-   }
-   pipe_mutex_unlock(fd_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, );
-
-   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, );
-   fstat(fd2, );
-
-   return stat1.st_dev != stat2.st_dev ||
-   stat1.st_ino != stat2.st_ino ||
-   stat1.st_rdev != stat2.st_rdev;
-}
-
 struct pipe_screen *
 fd_drm_screen_create(int fd)
 {
-   struct pipe_screen *pscreen = NULL;
-
-   pipe_mutex_lock(fd_screen_mutex);
-   if (!fd_tab) {
-   fd_tab = util_hash_table_create(hash_fd, compare_fd);
-   if (!fd_tab)
-   goto unlock;
-   }
-
-   pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
-   if (pscreen) {
-   fd_screen(pscreen)->refcnt++;
-   } else {
-   struct fd_device *dev = fd_device_new_dup(fd);
-   if (!dev)
-   goto unlock;
-
-   pscreen = fd_screen_create(dev);
-   if (pscreen) {
-   int fd = fd_device_fd(dev);
-
-   util_hash_table_set(fd_tab, intptr_to_pointer(fd), 
pscreen);
-
-   /* Bit of a hack, to avoid circular linkage dependency,
-* ie. pipe driver having to call in to winsys, we
-* override the pipe drivers screen->destroy():
-*/
-   fd_screen(pscreen)->winsys_priv = pscreen->destroy;
-   pscreen->destroy = fd_drm_screen_destroy;
-   }
-   }
+   struct fd_device *dev = fd_device_new(fd);
 
-unlock:
-   

[Mesa-dev] [RFC 3/7] Revert "virgl: reuse screen when fd is already open"

2016-06-17 Thread Rob Herring
This reverts commit f87330dbce3f67cb531194f63a5db59685dcbbd3.
Cc: Emil Velikov 
Cc: Dave Airlie 
---
 src/gallium/auxiliary/target-helpers/drm_helper.h |  7 +-
 src/gallium/drivers/virgl/virgl_screen.c  |  1 -
 src/gallium/drivers/virgl/virgl_screen.h  |  6 --
 src/gallium/winsys/virgl/drm/virgl_drm_public.h   |  4 +-
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c   | 87 ---
 5 files changed, 8 insertions(+), 97 deletions(-)

diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h 
b/src/gallium/auxiliary/target-helpers/drm_helper.h
index 90820d3..332b1cb 100644
--- a/src/gallium/auxiliary/target-helpers/drm_helper.h
+++ b/src/gallium/auxiliary/target-helpers/drm_helper.h
@@ -226,9 +226,14 @@ pipe_freedreno_create_screen(int fd)
 struct pipe_screen *
 pipe_virgl_create_screen(int fd)
 {
+   struct virgl_winsys *vws;
struct pipe_screen *screen;
 
-   screen = virgl_drm_screen_create(fd);
+   vws = virgl_drm_winsys_create(fd);
+   if (!vws)
+  return NULL;
+
+   screen = virgl_create_screen(vws);
return screen ? debug_screen_wrap(screen) : NULL;
 }
 
diff --git a/src/gallium/drivers/virgl/virgl_screen.c 
b/src/gallium/drivers/virgl/virgl_screen.c
index 919b64e..1ad7ffe 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -573,7 +573,6 @@ virgl_create_screen(struct virgl_winsys *vws)
 
vws->get_caps(vws, >caps);
 
-   screen->refcnt = 1;
 
util_format_s3tc_init();
return >base;
diff --git a/src/gallium/drivers/virgl/virgl_screen.h 
b/src/gallium/drivers/virgl/virgl_screen.h
index 8cac38d..52e72ca 100644
--- a/src/gallium/drivers/virgl/virgl_screen.h
+++ b/src/gallium/drivers/virgl/virgl_screen.h
@@ -28,12 +28,6 @@
 
 struct virgl_screen {
struct pipe_screen base;
-
-   int refcnt;
-
-   /* place for winsys to stash it's own stuff: */
-   void *winsys_priv;
-
struct virgl_winsys *vws;
 
struct virgl_drm_caps caps;
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_public.h 
b/src/gallium/winsys/virgl/drm/virgl_drm_public.h
index f70f0e5..be01021 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_public.h
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_public.h
@@ -23,8 +23,8 @@
 #ifndef VIRGL_DRM_PUBLIC_H
 #define VIRGL_DRM_PUBLIC_H
 
-struct pipe_screen;
+struct virgl_winsys;
 
-struct pipe_screen *virgl_drm_screen_create(int fd);
+struct virgl_winsys *virgl_drm_winsys_create(int drmFD);
 
 #endif
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c 
b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index 81afa84..e03e8bd 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "os/os_mman.h"
 #include "os/os_time.h"
@@ -34,8 +33,6 @@
 #include "util/u_hash_table.h"
 #include "util/u_inlines.h"
 #include "state_tracker/drm_driver.h"
-#include "virgl/virgl_screen.h"
-#include "virgl/virgl_public.h"
 
 #include 
 #include "virtgpu_drm.h"
@@ -801,87 +798,3 @@ virgl_drm_winsys_create(int drmFD)
return >base;
 
 }
-
-static struct util_hash_table *fd_tab = NULL;
-pipe_static_mutex(virgl_screen_mutex);
-
-static void
-virgl_drm_screen_destroy(struct pipe_screen *pscreen)
-{
-   struct virgl_screen *screen = virgl_screen(pscreen);
-   boolean destroy;
-
-   pipe_mutex_lock(virgl_screen_mutex);
-   destroy = --screen->refcnt == 0;
-   if (destroy) {
-  int fd = virgl_drm_winsys(screen->vws)->fd;
-  util_hash_table_remove(fd_tab, intptr_to_pointer(fd));
-   }
-   pipe_mutex_unlock(virgl_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, );
-
-   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, );
-   fstat(fd2, );
-
-   return stat1.st_dev != stat2.st_dev ||
- stat1.st_ino != stat2.st_ino ||
- stat1.st_rdev != stat2.st_rdev;
-}
-
-struct pipe_screen *
-virgl_drm_screen_create(int fd)
-{
-   struct pipe_screen *pscreen = NULL;
-
-   pipe_mutex_lock(virgl_screen_mutex);
-   if (!fd_tab) {
-  fd_tab = util_hash_table_create(hash_fd, compare_fd);
-  if (!fd_tab)
- goto unlock;
-   }
-
-   pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
-   if (pscreen) {
-  virgl_screen(pscreen)->refcnt++;
-   } else {
-  struct virgl_winsys *vws;
-  int dup_fd = dup(fd);
-
-  vws = virgl_drm_winsys_create(dup_fd);
-
-  pscreen = virgl_create_screen(vws);
-  if (pscreen) {
- util_hash_table_set(fd_tab, intptr_to_pointer(dup_fd), pscreen);
-
- /* Bit of a hack, to avoid 

[Mesa-dev] [RFC 1/7] gallium: move pipe_screen destroy into pipe-loader

2016-06-17 Thread Rob Herring
In preparation to add reference counting of pipe_screen in the pipe-loader,
pipe_loader_release needs to destroy the pipe_screen instead of state
trackers.

Signed-off-by: Rob Herring 
Cc: Emil Velikov 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader.h | 1 +
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 9 -
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c  | 6 ++
 src/gallium/auxiliary/vl/vl_winsys_dri.c| 1 -
 src/gallium/auxiliary/vl/vl_winsys_dri3.c   | 1 -
 src/gallium/auxiliary/vl/vl_winsys_drm.c| 1 -
 src/gallium/state_trackers/clover/core/device.cpp   | 4 +---
 src/gallium/state_trackers/dri/dri_screen.c | 3 ---
 src/gallium/state_trackers/xa/xa_tracker.c  | 2 --
 src/gallium/tests/trivial/compute.c | 1 -
 src/gallium/tests/trivial/quad-tex.c| 1 -
 src/gallium/tests/trivial/tri.c | 1 -
 12 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 690d088..25cd4d1 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -65,6 +65,7 @@ struct pipe_loader_device {
 
char *driver_name;
const struct pipe_loader_ops *ops;
+   struct pipe_screen *pscreen;
 };
 
 /**
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 994a284..62f109f 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -39,6 +39,7 @@
 #include "target-helpers/drm_helper_public.h"
 #include "state_tracker/drm_driver.h"
 #include "pipe_loader_priv.h"
+#include "pipe/p_screen.h"
 
 #include "util/u_memory.h"
 #include "util/u_dl.h"
@@ -269,6 +270,9 @@ static void
 pipe_loader_drm_release(struct pipe_loader_device **dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev);
+   struct pipe_screen *pscreen = ddev->base.pscreen;
+
+   pscreen->destroy(pscreen);
 
 #ifndef GALLIUM_STATIC_TARGETS
if (ddev->lib)
@@ -297,8 +301,11 @@ static struct pipe_screen *
 pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
+   struct pipe_screen *pscreen = NULL;
 
-   return ddev->dd->create_screen(ddev->fd);
+   pscreen = ddev->dd->create_screen(fd);
+   ddev->base.pscreen = pscreen;
+   return pscreen;
 }
 
 static const struct pipe_loader_ops pipe_loader_drm_ops = {
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index c8e1f13..25d1695 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -27,6 +27,7 @@
 
 #include "pipe_loader_priv.h"
 
+#include "pipe/p_screen.h"
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "sw/dri/dri_sw_winsys.h"
@@ -267,6 +268,9 @@ static void
 pipe_loader_sw_release(struct pipe_loader_device **dev)
 {
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
+   struct pipe_screen *pscreen = sdev->base.pscreen;
+
+   pscreen->destroy(pscreen);
 
 #ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
@@ -294,6 +298,8 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev)
if (!screen)
   sdev->ws->destroy(sdev->ws);
 
+   sdev->base.pscreen = screen;
+
return screen;
 }
 
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 9ecc216..db90c54 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -461,7 +461,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen)
}
 
vl_dri2_destroy_drawable(scrn);
-   scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(>base.dev, 1);
FREE(scrn);
 }
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index f7f572e..87ecd2e 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -610,7 +610,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen)
 
if (scrn->special_event)
   xcb_unregister_for_special_event(scrn->conn, scrn->special_event);
-   scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(>base.dev, 1);
FREE(scrn);
 
diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c 
b/src/gallium/auxiliary/vl/vl_winsys_drm.c
index 6a759ae..aa690a2 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -80,7 +80,6 @@ vl_drm_screen_destroy(struct vl_screen *vscreen)
 {
assert(vscreen);
 
-   vscreen->pscreen->destroy(vscreen->pscreen);
pipe_loader_release(>dev, 1);
FREE(vscreen);
 }
diff --git 

[Mesa-dev] [RFC 5/7] nouveau: remove screen ref counting

2016-06-17 Thread Rob Herring
Now that the pipe-loader is reference counting the screen creation, it
is unnecessary to do in it the winsys/driver.

Signed-off-by: Rob Herring 
Cc: Alexandre Courbot 
---
 src/gallium/drivers/nouveau/nouveau_screen.h   |  2 -
 .../winsys/nouveau/drm/nouveau_drm_winsys.c| 84 +-
 2 files changed, 2 insertions(+), 84 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h 
b/src/gallium/drivers/nouveau/nouveau_screen.h
index 28c4760..3e17472 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.h
+++ b/src/gallium/drivers/nouveau/nouveau_screen.h
@@ -23,8 +23,6 @@ struct nouveau_screen {
struct nouveau_client *client;
struct nouveau_pushbuf *pushbuf;
 
-   int refcount;
-
unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired */
unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired */
unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB */
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c 
b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
index 598ffcb..179d25a 100644
--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c
@@ -1,12 +1,9 @@
-#include 
 #include 
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 #include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
-#include "util/u_hash_table.h"
-#include "os/os_thread.h"
 
 #include "nouveau_drm_public.h"
 
@@ -16,47 +13,6 @@
 #include 
 #include 
 
-static struct util_hash_table *fd_tab = NULL;
-
-pipe_static_mutex(nouveau_screen_mutex);
-
-bool nouveau_drm_screen_unref(struct nouveau_screen *screen)
-{
-   int ret;
-   if (screen->refcount == -1)
-   return true;
-
-   pipe_mutex_lock(nouveau_screen_mutex);
-   ret = --screen->refcount;
-   assert(ret >= 0);
-   if (ret == 0)
-   util_hash_table_remove(fd_tab, 
intptr_to_pointer(screen->drm->fd));
-   pipe_mutex_unlock(nouveau_screen_mutex);
-   return ret == 0;
-}
-
-static unsigned hash_fd(void *key)
-{
-int fd = pointer_to_intptr(key);
-struct stat stat;
-fstat(fd, );
-
-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, );
-fstat(fd2, );
-
-return stat1.st_dev != stat2.st_dev ||
-   stat1.st_ino != stat2.st_ino ||
-   stat1.st_rdev != stat2.st_rdev;
-}
-
 PUBLIC struct pipe_screen *
 nouveau_drm_screen_create(int fd)
 {
@@ -64,36 +20,9 @@ nouveau_drm_screen_create(int fd)
struct nouveau_device *dev = NULL;
struct nouveau_screen *(*init)(struct nouveau_device *);
struct nouveau_screen *screen = NULL;
-   int ret, dupfd;
-
-   pipe_mutex_lock(nouveau_screen_mutex);
-   if (!fd_tab) {
-   fd_tab = util_hash_table_create(hash_fd, compare_fd);
-   if (!fd_tab) {
-   pipe_mutex_unlock(nouveau_screen_mutex);
-   return NULL;
-   }
-   }
-
-   screen = util_hash_table_get(fd_tab, intptr_to_pointer(fd));
-   if (screen) {
-   screen->refcount++;
-   pipe_mutex_unlock(nouveau_screen_mutex);
-   return >base;
-   }
-
-   /* Since the screen re-use is based on the device node and not the fd,
-* create a copy of the fd to be owned by the device. Otherwise a
-* scenario could occur where two screens are created, and the first
-* one is shut down, along with the fd being closed. The second
-* (identical) screen would now have a reference to the closed fd. We
-* avoid this by duplicating the original fd. Note that
-* nouveau_device_wrap does not close the fd in case of a device
-* creation error.
-*/
-   dupfd = dup(fd);
+   int ret;
 
-   ret = nouveau_drm_new(dupfd, );
+   ret = nouveau_drm_new(fd, );
if (ret)
goto err;
 
@@ -135,13 +64,6 @@ nouveau_drm_screen_create(int fd)
if (!screen || !screen->base.context_create)
goto err;
 
-   /* Use dupfd in hash table, to avoid errors if the original fd gets
-* closed by its owner. The hash key needs to live at least as long as
-* the screen.
-*/
-   util_hash_table_set(fd_tab, intptr_to_pointer(dupfd), screen);
-   screen->refcount = 1;
-   pipe_mutex_unlock(nouveau_screen_mutex);
return >base;
 
 err:
@@ -150,8 +72,6 @@ err:
} else {
nouveau_device_del();
nouveau_drm_del();
-   close(dupfd);
}
-   pipe_mutex_unlock(nouveau_screen_mutex);
return NULL;
 }
-- 
2.7.4

___

[Mesa-dev] [RFC 0/7] Common pipe screen ref counting

2016-06-17 Thread Rob Herring
I needed to add screen ref counting to vc4 driver, so rather than yet 
another copy of the same fd hashing and ref counting code, I implemented 
it in the pipe-loader. AFAICT, the pipe-loader is the only place the 
winsys create screen functions are called and seemed to be the best 
location to put this. The tricky part is the destroy path and not 
freeing the screen before reference counting. I think I found all the 
callers of pipe_screen->destroy.

This is tested on virgl and freedreno on Android and radeon is build 
tested only.

Rob

Rob Herring (7):
  gallium: move pipe_screen destroy into pipe-loader
  pipe-loader-drm: Add common pipe_screen refcounting
  Revert "virgl: reuse screen when fd is already open"
  Revert "virgl: mark function as static"
  nouveau: remove screen ref counting
  freedreno: remove screen ref counting
  radeon: remove screen ref counting

 src/gallium/auxiliary/pipe-loader/pipe_loader.h|  1 +
 .../auxiliary/pipe-loader/pipe_loader_drm.c| 71 -
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c |  6 ++
 src/gallium/auxiliary/target-helpers/drm_helper.h  |  7 +-
 src/gallium/auxiliary/vl/vl_winsys_dri.c   |  1 -
 src/gallium/auxiliary/vl/vl_winsys_dri3.c  |  1 -
 src/gallium/auxiliary/vl/vl_winsys_drm.c   |  1 -
 src/gallium/drivers/freedreno/freedreno_screen.c   |  1 -
 src/gallium/drivers/freedreno/freedreno_screen.h   | 10 ---
 src/gallium/drivers/nouveau/nouveau_screen.h   |  2 -
 src/gallium/drivers/r300/r300_screen.c |  3 -
 src/gallium/drivers/r600/r600_pipe.c   |  6 --
 src/gallium/drivers/radeon/radeon_winsys.h |  8 --
 src/gallium/drivers/radeonsi/si_pipe.c |  6 --
 src/gallium/drivers/virgl/virgl_screen.c   |  1 -
 src/gallium/drivers/virgl/virgl_screen.h   |  6 --
 src/gallium/include/pipe/p_screen.h|  1 +
 src/gallium/state_trackers/clover/core/device.cpp  |  4 +-
 src/gallium/state_trackers/dri/dri_screen.c|  3 -
 src/gallium/state_trackers/xa/xa_tracker.c |  2 -
 src/gallium/tests/trivial/compute.c|  1 -
 src/gallium/tests/trivial/quad-tex.c   |  1 -
 src/gallium/tests/trivial/tri.c|  1 -
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c  | 66 +---
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h  |  1 -
 .../winsys/freedreno/drm/freedreno_drm_winsys.c| 89 +-
 .../winsys/nouveau/drm/nouveau_drm_winsys.c| 84 +---
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c  | 80 +--
 src/gallium/winsys/virgl/drm/virgl_drm_public.h|  4 +-
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c| 89 +-
 30 files changed, 95 insertions(+), 462 deletions(-)

-- 
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] egl: only store device name when Wayland support is built

2016-06-17 Thread Frank Binns
The device name is only needed for WL_bind_wayland_display so make this clear
by only storing the device name when Wayland support is built.

Signed-off-by: Frank Binns 
---
 src/egl/drivers/dri2/egl_dri2.c  |  5 -
 src/egl/drivers/dri2/egl_dri2.h  |  2 +-
 src/egl/drivers/dri2/platform_drm.c  |  3 ++-
 src/egl/drivers/dri2/platform_x11.c  | 21 ++---
 src/egl/drivers/dri2/platform_x11_dri3.c | 11 +++
 5 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index bfde640..95703fb 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -823,9 +823,12 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
   close(dri2_dpy->fd);
if (dri2_dpy->driver)
   dlclose(dri2_dpy->driver);
-   free(dri2_dpy->device_name);
free(dri2_dpy->driver_name);
 
+#ifdef HAVE_WAYLAND_PLATFORM
+   free(dri2_dpy->device_name);
+#endif
+
switch (disp->Platform) {
 #ifdef HAVE_X11_PLATFORM
case _EGL_PLATFORM_X11:
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 925294b..54e58e1 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -187,7 +187,6 @@ struct dri2_egl_display
struct gbm_dri_device*gbm_dri;
 #endif
 
-   char *device_name;
char *driver_name;
 
__DRIdri2LoaderExtensiondri2_loader_extension;
@@ -213,6 +212,7 @@ struct dri2_egl_display
int  authenticated;
int  formats;
uint32_t  capabilities;
+   char *device_name;
 #endif
 
int  is_render_node;
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 9373496..91dde72 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -639,7 +639,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
   goto cleanup;
 
dri2_dpy->fd = fd;
-   dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
dri2_dpy->driver_name = strdup(dri2_dpy->gbm_dri->base.driver_name);
 
dri2_dpy->dri_screen = dri2_dpy->gbm_dri->screen;
@@ -701,6 +700,8 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
 
 #ifdef HAVE_WAYLAND_PLATFORM
if (dri2_dpy->image) {
+   dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
+
if (dri2_dpy->image->base.version >= 10 &&
dri2_dpy->image->getCapabilities != NULL) {
int capabilities;
diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index 1b50889..d7d6b8a 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -665,23 +665,16 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy)
 
device_name = xcb_dri2_connect_device_name (connect);
 
-   dri2_dpy->device_name =
-  strndup(device_name,
-  xcb_dri2_connect_device_name_length(connect));
-
-   dri2_dpy->fd = loader_open_device(dri2_dpy->device_name);
+   dri2_dpy->fd = loader_open_device(device_name);
if (dri2_dpy->fd == -1) {
   _eglLog(_EGL_WARNING,
-  "DRI2: could not open %s (%s)", dri2_dpy->device_name,
-  strerror(errno));
-  free(dri2_dpy->device_name);
+  "DRI2: could not open %s (%s)", device_name, strerror(errno));
   free(connect);
   return EGL_FALSE;
}
 
if (!dri2_x11_local_authenticate(dri2_dpy)) {
   close(dri2_dpy->fd);
-  free(dri2_dpy->device_name);
   free(connect);
   return EGL_FALSE;
}
@@ -700,13 +693,19 @@ dri2_x11_connect(struct dri2_egl_display *dri2_dpy)
  xcb_dri2_connect_driver_name_length(connect));
}
 
-   if (dri2_dpy->device_name == NULL || dri2_dpy->driver_name == NULL) {
+   if (dri2_dpy->driver_name == NULL) {
   close(dri2_dpy->fd);
-  free(dri2_dpy->device_name);
   free(dri2_dpy->driver_name);
   free(connect);
   return EGL_FALSE;
}
+
+#ifdef HAVE_WAYLAND_PLATFORM
+   dri2_dpy->device_name =
+  strndup(device_name,
+  xcb_dri2_connect_device_name_length(connect));
+#endif
+
free(connect);
 
return EGL_TRUE;
diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c 
b/src/egl/drivers/dri2/platform_x11_dri3.c
index f996750..31649fe 100644
--- a/src/egl/drivers/dri2/platform_x11_dri3.c
+++ b/src/egl/drivers/dri2/platform_x11_dri3.c
@@ -229,6 +229,7 @@ dri3_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
 static int
 dri3_authenticate(_EGLDisplay *disp, uint32_t id)
 {
+#ifdef HAVE_WAYLAND_PLATFORM
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
 
if (dri2_dpy->device_name) {
@@ -239,6 +240,7 @@ dri3_authenticate(_EGLDisplay *disp, uint32_t id)
 
_eglLog(_EGL_WARNING,
"Wayland client primary node 

[Mesa-dev] [PATCH 1/3] egl/x11_dri3: disable WL_bind_wayland_display for devices without render nodes

2016-06-17 Thread Frank Binns
Up until now, DRI3 was only used for devices that have render nodes, unless
overridden via an environment variable, with it falling back to DRI2 otherwise.
This limitation was there in order to support WL_bind_wayland_display as it
requires client opened device node fds to be authenticated, which isn't possible
when using DRI3. This is an unfortunate compromise as DRI3 provides security
benefits over DRI2.

Instead, allow DRI3 to be used for devices without render nodes but don't
advertise WL_bind_wayland_display in this case. Applications that need this
extension can still be run by disabling DRI3 support via the LIBGL_DRI3_DISABLE
environment variable.

Signed-off-by: Frank Binns 
---
 src/egl/drivers/dri2/platform_x11.c  |  3 ++-
 src/egl/drivers/dri2/platform_x11_dri3.c | 33 +---
 2 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index c0a4005..1b50889 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1335,7 +1335,8 @@ dri2_initialize_x11_dri3(_EGLDriver *drv, _EGLDisplay 
*disp)
disp->Extensions.EXT_buffer_age = EGL_TRUE;
 
 #ifdef HAVE_WAYLAND_PLATFORM
-   disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
+   if (dri2_dpy->device_name)
+  disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
 #endif
 
if (dri2_dpy->conn) {
diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c 
b/src/egl/drivers/dri2/platform_x11_dri3.c
index 9363a8a..b781987 100644
--- a/src/egl/drivers/dri2/platform_x11_dri3.c
+++ b/src/egl/drivers/dri2/platform_x11_dri3.c
@@ -437,29 +437,6 @@ struct dri2_egl_display_vtbl dri3_x11_display_vtbl = {
.get_dri_drawable = dri3_get_dri_drawable,
 };
 
-static char *
-dri3_get_device_name(int fd)
-{
-   char *ret = NULL;
-
-   ret = drmGetRenderDeviceNameFromFd(fd);
-   if (ret)
-  return ret;
-
-   /* For dri3, render node support is required for WL_bind_wayland_display.
-* In order not to regress on older systems without kernel or libdrm
-* support, fall back to dri2. User can override it with environment
-* variable if they don't need to use that extension.
-*/
-   if (getenv("EGL_FORCE_DRI3") == NULL) {
-  _eglLog(_EGL_WARNING, "Render node support not available, falling back 
to dri2");
-  _eglLog(_EGL_WARNING, "If you want to force dri3, set EGL_FORCE_DRI3 
environment variable");
-   } else
-  ret = loader_get_device_name_for_fd(fd);
-
-   return ret;
-}
-
 EGLBoolean
 dri3_x11_connect(struct dri2_egl_display *dri2_dpy)
 {
@@ -539,11 +516,11 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy)
   return EGL_FALSE;
}
 
-   dri2_dpy->device_name = dri3_get_device_name(dri2_dpy->fd);
-   if (!dri2_dpy->device_name) {
-  close(dri2_dpy->fd);
-  return EGL_FALSE;
-   }
+   /* Only try to get a render device name since it's only needed for
+* WL_bind_wayland_display and dri3 doesn't provide a mechanism for
+* authenticating client opened device node fds. If this fails then
+* don't advertise the extension. */
+   dri2_dpy->device_name = drmGetRenderDeviceNameFromFd(dri2_dpy->fd);
 
return EGL_TRUE;
 }
-- 
2.7.4

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


  1   2   >