Re: [Mesa-dev] [PATCH] [RFC] egl: propose simple EGL_MESA_image_dma_buf_export v2.2

2015-03-03 Thread Daniel Stone
Hi,

On Tuesday, March 3, 2015, Dave Airlie  wrote:
>
> +EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
> +  EGLImageKHR image,
> + int *fourcc,
> + int *num_planes);
>

Shouldn't this contain the modifier(s) as well?

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


Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Jose Fonseca

On 28/02/15 00:24, Rob Clark wrote:

On Fri, Feb 27, 2015 at 5:05 PM, Emil Velikov  wrote:

- src/gallium/drivers/rbug: -- do people use it? does it work?  it
predates apitrace GL + GUI, which sort of enables a lot of the same
things, but without the issue of having to hit moving target, which is
what gallium interfaces are



So it looks from the replies that rbug and rbug-gui is still useful.


If we're going to keep this should we move the rbug-gui tool within the
mesa tree ? It would be nice to spare some of the "sigh... it does not
build" and let you guys just use it.



+1



It sounds a good idea FWIW.  I believe that rbug-gui depends on the 
gallium interface, and we don't maintain backwards compatibility, so 
moving it rbug-gui into somewhere like src/gallium/tools/ and have it 
built by default should enable to keep it in sync more easily.


That said, integrating rbug-gui into Mesa tree is beyond my immediate 
goals/needs.  So I'll let those who do use rbug + rbug-gui to take that 
task on.



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


Re: [Mesa-dev] [PATCH 2/2] configure: Leverage gcc warn options to enable safe use of C99 features where possible.

2015-03-03 Thread Jose Fonseca

On 02/03/15 19:42, Kenneth Graunke wrote:

On Monday, March 02, 2015 03:24:18 PM Jose Fonseca wrote:

On 28/02/15 00:25, Kenneth Graunke wrote:

On Friday, February 27, 2015 09:58:51 PM Jose Fonseca wrote:

Sorry, this didn't pop up when I built it here.  And I'm afraid I won't have 
time to look into this today, and possibly the weekend.

If there's not an obvious fix feel free to push a commit commiting out the  
.MSVC2013_COMPAT_*FLAGS= in configure.ac

I'll act on other reviews too as soon as I can.

Jose


Strange.  It didn't pop up when I tried it either - maybe I failed to do
a clean build.  But I'm definitely hitting the same breakage, with these
flags:

git clean -fdx; CFLAGS='-g -fno-omit-frame-pointer' CXXFLAGS='-g 
-fno-omit-frame-pointer' ./autogen.sh --enable-gles2 --enable-glx-tls 
--with-egl-platforms=x11,drm --with-gallium-drivers= --with-dri-drivers=i965 
--enable-debug

Ben also hit this.

I've reverted the patch for now - hopefully we can land a v2 soon.



I believe that Matt's change
https://urldefense.proofpoint.com/v2/url?u=http-3A__cgit.freedesktop.org_mesa_mesa_commit_-3Fid-3D76cd0f00f44c0935dc7d6a0e14e0515f08a8e1dc&d=AwICAg&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=ks5wQTUHiwIa619HqiroFOtoTtuNCqTuaZXBeUZfBB0&s=m1w-fmCs2IJNcfvI_o94wMZZcEukEQkUFlYOcHFaPwg&e=
should fix this.

Those who hit the issue, could you please re-apply
79daa510c7a871a33797308a2ccb4b83a067ffbe if that was the end of it or
whether there are more errors?

Jose



I tested {debug,release} x {64-bit,32-bit} builds, using git clean -fdx each 
time.
They all appear to work fine for me.

Sorry for the trouble - I didn't realize the fix would be so tiny.


No prob.  Thanks for confirming.

I'll push the change again.

Jose

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


Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Emil Velikov
On 3 March 2015 at 09:36, Jose Fonseca  wrote:
> On 28/02/15 00:24, Rob Clark wrote:
>>
>> On Fri, Feb 27, 2015 at 5:05 PM, Emil Velikov 
>> wrote:

 - src/gallium/drivers/rbug: -- do people use it? does it work?  it
 predates apitrace GL + GUI, which sort of enables a lot of the same
 things, but without the issue of having to hit moving target, which is
 what gallium interfaces are

>
> So it looks from the replies that rbug and rbug-gui is still useful.
>
>>> If we're going to keep this should we move the rbug-gui tool within the
>>> mesa tree ? It would be nice to spare some of the "sigh... it does not
>>> build" and let you guys just use it.
>>
>>
>>
>> +1
>>
>
> It sounds a good idea FWIW.  I believe that rbug-gui depends on the gallium
> interface, and we don't maintain backwards compatibility, so moving it
> rbug-gui into somewhere like src/gallium/tools/ and have it built by default
> should enable to keep it in sync more easily.
>
Indeed that was the reason I brought it up.

> That said, integrating rbug-gui into Mesa tree is beyond my immediate
> goals/needs.  So I'll let those who do use rbug + rbug-gui to take that task
> on.
>
Ouch... did not mean to come across as "you should do it" or anything
along those lines. I'll need to read up a bit on how to preserve the
history, but it's already on my list :-)

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


Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Jose Fonseca

On 03/03/15 11:59, Emil Velikov wrote:

On 3 March 2015 at 09:36, Jose Fonseca  wrote:

On 28/02/15 00:24, Rob Clark wrote:


On Fri, Feb 27, 2015 at 5:05 PM, Emil Velikov 
wrote:


- src/gallium/drivers/rbug: -- do people use it? does it work?  it
predates apitrace GL + GUI, which sort of enables a lot of the same
things, but without the issue of having to hit moving target, which is
what gallium interfaces are



So it looks from the replies that rbug and rbug-gui is still useful.


If we're going to keep this should we move the rbug-gui tool within the
mesa tree ? It would be nice to spare some of the "sigh... it does not
build" and let you guys just use it.




+1



It sounds a good idea FWIW.  I believe that rbug-gui depends on the gallium
interface, and we don't maintain backwards compatibility, so moving it
rbug-gui into somewhere like src/gallium/tools/ and have it built by default
should enable to keep it in sync more easily.


Indeed that was the reason I brought it up.


That said, integrating rbug-gui into Mesa tree is beyond my immediate
goals/needs.  So I'll let those who do use rbug + rbug-gui to take that task
on.


Ouch... did not mean to come across as "you should do it" or anything
along those lines.


No prob.  I just want to make sure that, by agreeing, I wasn't 
volunteering :)



I'll need to read up a bit on how to preserve the
history, but it's already on my list :-)


I tried to do that sort of "git-history-rewriting/spliting" acrobatics 
in the past. And I have mixed feelings from my experience: being able to 
do `git blame` on the new tree is indeed nice, but it's hard to get the 
history right, in particular it's pretty hard to ensure that things 
build at arbitrary commits, which can create troubles when bisecting 
(particularly because there is no option for "git bisect 
--ignore-changes-in-this-path src/gallium/tools/rbug-gui"...)


The alternative would be to make 
http://cgit.freedesktop.org/mesa/rbug-gui/ read-only, or just slap a big 
notice in description/read-me saying "this code is unmaintained and 
moved to XYZ", import rbug-gui as a single commit, and mention which 
rbu-gui commit this was taken from in the mesa commit message.


Jose

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


Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Jose Fonseca

On 27/02/15 15:16, Jose Fonseca wrote:

As we're gaining momentum cleanup Mesa code, I think it would help if we
also removed some stale components.

What do people feel about removing:

- src/mesa/drivers/windows/gdi -- the old SW rasterizer for Windows -- I
haven't used in a very long time, and given that the old SW rasterizer
is so far behind compared gallium based softpipe/llvmpipe rasterizers,
it's hard to imagine this will ever be useful again

- src/gallium/drivers/rbug: -- do people use it? does it work?  it
predates apitrace GL + GUI, which sort of enables a lot of the same
things, but without the issue of having to hit moving target, which is
what gallium interfaces are

- src/gallium/state_trackers/vega/,src/mapi/vgapi/ -- OpenVG API seems
to have dwindled away. I recall Zack himself saying that much. The code
would still be interesting if we wanted to implement NV_path_rendering
[1], but given the trend of the next gen graphics APIs, it seems
unlikely that this becomes ARB or core.

- src/gallium/state_trackers/egl/ -- yeah, I know I was against it, but
since then I discovered WGL/GLX_EXT_create_context_es_profile, and the
odds of us (VMware) needing this again are dimmer than last time, so I
have to admit it does seem unlikely we or anybody will need it again,
and we can always revert it from history..


Anything else?


Thanks for all the replies.  So in summary, I'll post patches to remove:

- src/mesa/drivers/windows/gdi

- src/gallium/state_trackers/vega/,src/mapi/vgapi/

- src/gallium/state_trackers/egl/ plus whatever modules get orphaned as 
result of that



I'll try to do one component at a time (in case we want to revert), but 
if keeping things in a building state ends up being too tricky then I 
might squash them together.



Components that people explicitly showed interest in maintaining 
(therefore left alone) are:


- src/gallium/drivers/rbug/
- src/mesa/drivers/x11/
- src/mesa/drivers/osmesa/


Things that haven't been mentioned but might be considering for a 2nd 
round are:


- src/gallium/drivers/noop

  Do people use it?

- src/gallium/drivers/galahad/

  Again, this also tends to get broken.  Architecturally it's the right 
thing to do, but I ended up giving up on enabling it, as it causes 
crashes.  If nobody uses it, might as well face reality here.



As I said, layered drivers are nice conceptually, but there are serious 
challenges with them in practice:
  - the gallium interface is always changing, so they do get broken 
easily, particularly when they are not frequently used (ie, enabled by 
default)
  - some state trackers have private interfaces with pipe drivers, 
making it impossible to use layered drivers.


In other words, we have to make a good analysis which layered drivers 
are or not worth maintaining, and make a effort to keep those that are 
deem to be useful in running condition.  Because keeping them around 
half-heartedly is the worse outcome: time is spent maintaining them, but 
they are never good enough to be useful/trusted...



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


[Mesa-dev] [PATCH] nir: Use helper macros for dealing with VLAs.

2015-03-03 Thread Jose Fonseca
v2:
- Single statement, by using memset return value as suggested by Ian
Romanick.
- No internal declaration, as suggested by Jason Ekstrand.
- Move macros to a header.
---
 src/glsl/nir/nir_from_ssa.c  | 23 ++-
 src/glsl/nir/nir_live_variables.c|  4 +--
 src/glsl/nir/nir_lower_vars_to_ssa.c | 12 +++-
 src/glsl/nir/nir_vla.h   | 54 
 4 files changed, 69 insertions(+), 24 deletions(-)
 create mode 100644 src/glsl/nir/nir_vla.h

diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 66339f3..c3090fb 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -26,7 +26,7 @@
  */
 
 #include "nir.h"
-#include "c99_alloca.h"
+#include "nir_vla.h"
 
 /*
  * This file implements an out-of-SSA pass as described in "Revisiting
@@ -182,7 +182,7 @@ merge_merge_sets(merge_set *a, merge_set *b)
 static bool
 merge_sets_interfere(merge_set *a, merge_set *b)
 {
-   merge_node **dom = alloca((a->size + b->size) * sizeof *dom);
+   NIR_VLA(merge_node *, dom, a->size + b->size);
int dom_idx = -1;
 
struct exec_node *an = exec_list_get_head(&a->nodes);
@@ -674,21 +674,16 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
}
 
/* The register/source corresponding to the given index */
-   nir_src *values = alloca(num_copies * 2 * sizeof *values);
-   memset(values, 0, num_copies * 2 * sizeof *values);
+   NIR_VLA_ZERO(nir_src, values, num_copies * 2);
 
-   /* The current location of a given piece of data */
-   int *loc = alloca(num_copies * 2 * sizeof *loc);
+   /* The current location of a given piece of data.  We will use -1 for 
"null" */
+   NIR_VLA_FILL(int, loc, num_copies * 2, -1);
 
-   /* The piece of data that the given piece of data is to be copied from */
-   int *pred = alloca(num_copies * 2 * sizeof *pred);
-
-   /* Initialize loc and pred.  We will use -1 for "null" */
-   memset(loc, -1, num_copies * 2 * sizeof *loc);
-   memset(pred, -1, num_copies * 2 * sizeof *pred);
+   /* The piece of data that the given piece of data is to be copied from.  We 
will use -1 for "null" */
+   NIR_VLA_FILL(int, pred, num_copies * 2, -1);
 
/* The destinations we have yet to properly fill */
-   int *to_do = alloca(num_copies * 2 * sizeof *to_do);
+   NIR_VLA(int, to_do, num_copies * 2);
int to_do_idx = -1;
 
/* Now we set everything up:
@@ -738,7 +733,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
}
 
/* Currently empty destinations we can go ahead and fill */
-   int *ready = alloca(num_copies * 2 * sizeof *ready);
+   NIR_VLA(int, ready, num_copies * 2);
int ready_idx = -1;
 
/* Mark the ones that are ready for copying.  We know an index is a
diff --git a/src/glsl/nir/nir_live_variables.c 
b/src/glsl/nir/nir_live_variables.c
index b57ca3a..1c96dcf 100644
--- a/src/glsl/nir/nir_live_variables.c
+++ b/src/glsl/nir/nir_live_variables.c
@@ -26,7 +26,7 @@
 
 #include "nir.h"
 #include "nir_worklist.h"
-#include "c99_alloca.h"
+#include "nir_vla.h"
 
 /*
  * Basic liveness analysis.  This works only in SSA form.
@@ -131,7 +131,7 @@ static bool
 propagate_across_edge(nir_block *pred, nir_block *succ,
   struct live_variables_state *state)
 {
-   BITSET_WORD *live = alloca(state->bitset_words * sizeof *live);
+   NIR_VLA(BITSET_WORD, live, state->bitset_words);
memcpy(live, succ->live_in, state->bitset_words * sizeof *live);
 
nir_foreach_instr(succ, instr) {
diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c 
b/src/glsl/nir/nir_lower_vars_to_ssa.c
index f54d1b7..9e9a418 100644
--- a/src/glsl/nir/nir_lower_vars_to_ssa.c
+++ b/src/glsl/nir/nir_lower_vars_to_ssa.c
@@ -26,8 +26,7 @@
  */
 
 #include "nir.h"
-
-#include "c99_alloca.h"
+#include "nir_vla.h"
 
 
 struct deref_node {
@@ -902,8 +901,8 @@ rename_variables_block(nir_block *block, struct 
lower_variables_state *state)
 static void
 insert_phi_nodes(struct lower_variables_state *state)
 {
-   unsigned *work = alloca(state->impl->num_blocks * sizeof *work);
-   unsigned *has_already = alloca(state->impl->num_blocks * sizeof 
*has_already);
+   NIR_VLA_ZERO(unsigned, work, state->impl->num_blocks);
+   NIR_VLA_ZERO(unsigned, has_already, state->impl->num_blocks);
 
/*
 * Since the work flags already prevent us from inserting a node that has
@@ -913,10 +912,7 @@ insert_phi_nodes(struct lower_variables_state *state)
 * function. So all we need to handle W is an array and a pointer to the
 * next element to be inserted and the next element to be removed.
 */
-   nir_block **W = alloca(state->impl->num_blocks * sizeof *W);
-
-   memset(work, 0, state->impl->num_blocks * sizeof *work);
-   memset(has_already, 0, state->impl->num_blocks * sizeof *has_already);
+   NIR_VLA(nir_block *, W, state->impl->num_blocks);
 
unsigned w_start, w_end;
unsigned iter_count = 0;
diff --git a/src/glsl/nir/nir_vla.h b/src/glsl/nir/nir_vla.h
new file mode 100644
index 000

Re: [Mesa-dev] [PATCH 1/2] nir: Use alloca instead of variable length arrays.

2015-03-03 Thread Jose Fonseca

On 02/03/15 20:03, Jason Ekstrand wrote:



On Mon, Mar 2, 2015 at 8:02 AM, Jose Fonseca mailto:jfons...@vmware.com>> wrote:

On 27/02/15 16:15, Brian Paul wrote:

On 02/27/2015 09:10 AM, Ian Romanick wrote:

On 02/26/2015 10:07 AM, Brian Paul wrote:

On 02/26/2015 09:51 AM, Jose Fonseca wrote:


[...]


It occurs to me that this may be the only reasonable
use-case in all
history of memset returning the pointer that you pass to it:

  unsigned *work = memset(alloca(work_size), 0, work_size);


That's cool!


Yes, indeed, that can save another source line.


FWIW, I also tried to prototype a few macros for dealing with VLAs:

http://cgit.freedesktop.org/~__jrfonseca/mesa/commit/?h=nir-__vla



On one hand, they save quite a bit of typing, even compared with
vanilla C99 VLAs.  On the other hand, being macros it's always a bit
magical and tricky to read..


I'm OK with the macro magic.  I have two qualms, however.  First, I'm
not sure I like the fact that it defines a second size variable behind
your back.  Second, I'd like to keep it to one line if we can and
require the user to provide the semicolon.  Since we already have the
type from the user, this shouldn't be hard as we can do

_type *_name = alloca((_length) * sizeof(_type))

Then we don't have to worry about when the variable is declared vs. when
the sizeof happens.


Sure. I've just posted a review request that does this.

A semi-colon is already required (I was only using semi-colon for all 
but the last statements), but with the Ian's memset trick we can indeed 
squeeze everything into a single statement.


The only drawback of not declaring an additional variable with the size 
is that we'll need to evaluate the size twice for VLA_FILL/ZERO 
variants, therefore care must be taken to never use expressions with 
side effects (+=, ++, --, funcions, etc).


> Also, hiding it in a macro means that we could do


_type _name[_length]

for GCC/clang builds if we wanted to.


I also thought about it, but unfortunately that would prevent using 
-Werror=vla, and therefore prevent catching instances where people might 
inadvertently use VLA directly without these macros.


But at least having these macro means, when one day MSVC supports VLA, 
it's trivial to refactor the code to use them.


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


Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Marek Olšák
Please keep drivers/noop. It's useful sometimes and it's very easy to maintain.

Marek

On Tue, Mar 3, 2015 at 1:31 PM, Jose Fonseca  wrote:
> On 27/02/15 15:16, Jose Fonseca wrote:
>>
>> As we're gaining momentum cleanup Mesa code, I think it would help if we
>> also removed some stale components.
>>
>> What do people feel about removing:
>>
>> - src/mesa/drivers/windows/gdi -- the old SW rasterizer for Windows -- I
>> haven't used in a very long time, and given that the old SW rasterizer
>> is so far behind compared gallium based softpipe/llvmpipe rasterizers,
>> it's hard to imagine this will ever be useful again
>>
>> - src/gallium/drivers/rbug: -- do people use it? does it work?  it
>> predates apitrace GL + GUI, which sort of enables a lot of the same
>> things, but without the issue of having to hit moving target, which is
>> what gallium interfaces are
>>
>> - src/gallium/state_trackers/vega/,src/mapi/vgapi/ -- OpenVG API seems
>> to have dwindled away. I recall Zack himself saying that much. The code
>> would still be interesting if we wanted to implement NV_path_rendering
>> [1], but given the trend of the next gen graphics APIs, it seems
>> unlikely that this becomes ARB or core.
>>
>> - src/gallium/state_trackers/egl/ -- yeah, I know I was against it, but
>> since then I discovered WGL/GLX_EXT_create_context_es_profile, and the
>> odds of us (VMware) needing this again are dimmer than last time, so I
>> have to admit it does seem unlikely we or anybody will need it again,
>> and we can always revert it from history..
>>
>>
>> Anything else?
>
>
> Thanks for all the replies.  So in summary, I'll post patches to remove:
>
> - src/mesa/drivers/windows/gdi
>
> - src/gallium/state_trackers/vega/,src/mapi/vgapi/
>
> - src/gallium/state_trackers/egl/ plus whatever modules get orphaned as
> result of that
>
>
> I'll try to do one component at a time (in case we want to revert), but if
> keeping things in a building state ends up being too tricky then I might
> squash them together.
>
>
> Components that people explicitly showed interest in maintaining (therefore
> left alone) are:
>
> - src/gallium/drivers/rbug/
> - src/mesa/drivers/x11/
> - src/mesa/drivers/osmesa/
>
>
> Things that haven't been mentioned but might be considering for a 2nd round
> are:
>
> - src/gallium/drivers/noop
>
>   Do people use it?
>
> - src/gallium/drivers/galahad/
>
>   Again, this also tends to get broken.  Architecturally it's the right
> thing to do, but I ended up giving up on enabling it, as it causes crashes.
> If nobody uses it, might as well face reality here.
>
>
> As I said, layered drivers are nice conceptually, but there are serious
> challenges with them in practice:
>   - the gallium interface is always changing, so they do get broken easily,
> particularly when they are not frequently used (ie, enabled by default)
>   - some state trackers have private interfaces with pipe drivers, making it
> impossible to use layered drivers.
>
> In other words, we have to make a good analysis which layered drivers are or
> not worth maintaining, and make a effort to keep those that are deem to be
> useful in running condition.  Because keeping them around half-heartedly is
> the worse outcome: time is spent maintaining them, but they are never good
> enough to be useful/trusted...
>
>
> Jose
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] c99_alloca.h: Include stdlib.h on all non-Windows.

2015-03-03 Thread Brian Paul

On 03/02/2015 10:25 PM, Alan Coopersmith wrote:

On 03/ 2/15 08:20 AM, Brian Paul wrote:

On 03/01/2015 02:00 PM, Alan Coopersmith wrote:

On 03/ 1/15 12:52 PM, Vinson Lee wrote:

Fix build on FreeBSD.

Bugzilla:
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D89364&d=AwIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=hAYbphGOl9qk5ZTtilbIV6JTR05VlIItJHubG_2VpBQ&s=R-R_SJeKgYFdNDUJIZ4sVeiM8wE49k5Pq4h5nhO2drk&e=


Signed-off-by: Vinson Lee 
---
  include/c99_alloca.h | 6 +-
  1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/c99_alloca.h b/include/c99_alloca.h
index 7a81c50..575f719 100644
--- a/include/c99_alloca.h
+++ b/include/c99_alloca.h
@@ -35,13 +35,9 @@

  #  define alloca _alloca

-#elif defined(__MINGW32__)
-
-#  include 
-
  #else /* !defined(_MSC_VER) */

-#  include 
+#  include 

  #endif /* !defined(_MSC_VER) */


Solaris defines alloca() in , not 


Alan, is there an #ifdef we can use on Solaris to pull in the right
header?


Because compiler standard #defines last longer than corporations,

#elif defined(__sun)

# include 

should work.   (git grep will show you checks for __sun in a bunch of other
Mesa files already.  All compilers support __sun, gcc also provides __sun__
to fit in with it's normal naming scheme.)


OK, I'll prepare a patch.  I had grepped earlier for "sunos" and 
"solaris" but didn't see anything and didn't dig deeper.


-Brian

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


[Mesa-dev] [PATCH] c99_alloca.h: add case for __sun

2015-03-03 Thread Brian Paul
---
 include/c99_alloca.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/c99_alloca.h b/include/c99_alloca.h
index 575f719..ed66fda 100644
--- a/include/c99_alloca.h
+++ b/include/c99_alloca.h
@@ -35,6 +35,10 @@
 
 #  define alloca _alloca
 
+#elif defined(__sun)
+
+#  include 
+
 #else /* !defined(_MSC_VER) */
 
 #  include 
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH excerpt] mesa: Wrap unlikely() around conditions leading to _mesa_error().

2015-03-03 Thread Brian Paul

On 03/02/2015 06:56 PM, Matt Turner wrote:

On Mon, Mar 2, 2015 at 4:37 PM, Brian Paul  wrote:

On 03/02/2015 04:03 PM, Eric Anholt wrote:


Kenneth Graunke  writes:


Generated by the following Coccinelle semantic patch:

@@
expression E;
@@
if (
-E
+unlikely(E)
   )
{ ... _mesa_error(...) ... }

Improves performance in OglBatch7 (a CPU-bound microbenchmark) on
an i7 4750HQ (Haswell) by 1.08546% +/- 0.519734% (n=292).

Signed-off-by: Kenneth Graunke 



Neat!

I think you're supposed to be able to get the same result by marking
_mesa_error as attribute cold.  Then nobody can forget to mark their
conditions as unlikely in the future.



I suspect unlikely() would be supported by more compilers than 'cold'.


FWIW, this link [0] says MSVC doesn't implement hot/cold nor unlikely.


Thanks for checking on that.  I was thinking that MSVC had something 
like unlikely/expect but I guess I was misremembering.


MSVC is the compiler I had in mind in my reply to Eric's message.



Other than MSVC... there's really gcc and clang. I'd opt for the ~10
line patch :)


Sounds good then.

-Brian

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


Re: [Mesa-dev] [PATCH] c99_alloca.h: add case for __sun

2015-03-03 Thread Alan Coopersmith

On 03/ 3/15 07:10 AM, Brian Paul wrote:

---
  include/c99_alloca.h | 4 
  1 file changed, 4 insertions(+)

diff --git a/include/c99_alloca.h b/include/c99_alloca.h
index 575f719..ed66fda 100644
--- a/include/c99_alloca.h
+++ b/include/c99_alloca.h
@@ -35,6 +35,10 @@

  #  define alloca _alloca

+#elif defined(__sun)
+
+#  include 
+
  #else /* !defined(_MSC_VER) */

  #  include 



Reviewed-by: Alan Coopersmith 

--
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl: Report correct GBM formats

2015-03-03 Thread Alex Deucher
On Mon, Mar 2, 2015 at 9:23 AM, Tom Stellard  wrote:
> From: Daniel Stone 
>
> This fixes almost all piglit regressions when running with
> PIGLIT_PLATFORM=gbm
>
> Tom Stellard:
>   - Fix ARGB2101010 format
>
> Cc: "10.4 10.5" 

Looks reasonable to me.

Reviewed-by: Alex Deucher 

> ---
>
> I'm not sure if the commit message makes sense, I'm open to suggestions.
>
> src/egl/drivers/dri2/platform_drm.c | 16 +++-
>  1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/platform_drm.c 
> b/src/egl/drivers/dri2/platform_drm.c
> index 02e87f7..bf205be 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -668,15 +668,21 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
>
> for (i = 0; dri2_dpy->driver_configs[i]; i++) {
>EGLint format, attr_list[3];
> -  unsigned int mask;
> +  unsigned int red, alpha;
>
>dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
> -   __DRI_ATTRIB_RED_MASK, &mask);
> -  if (mask == 0x3ff0)
> +   __DRI_ATTRIB_RED_MASK, &red);
> +  dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
> +   __DRI_ATTRIB_ALPHA_MASK, &alpha);
> +  if (red == 0x3ff0 && alpha == 0x)
>   format = GBM_FORMAT_XRGB2101010;
> -  else if (mask == 0x00ff)
> +  else if (red == 0x3ff0 && alpha == 0xc000)
> + format = GBM_FORMAT_ARGB2101010;
> +  else if (red == 0x00ff && alpha == 0x)
>   format = GBM_FORMAT_XRGB;
> -  else if (mask == 0xf800)
> +  else if (red == 0x00ff && alpha == 0xff00)
> + format = GBM_FORMAT_ARGB;
> +  else if (red == 0xf800)
>   format = GBM_FORMAT_RGB565;
>else
>   continue;
> --
> 2.0.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 89364] c99_alloca.h:40:22: fatal error: alloca.h: No such file or directory

2015-03-03 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89364

--- Comment #7 from Brian Paul  ---
Vinson, can you retest with the latest code and close this bug if things check
out?  Thanks.

-- 
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
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] configure: ax_check_python_mako_module.m4 sets output variable

2015-03-03 Thread Kai Wasserbäch
Samuel Iglesias Gonsalvez wrote on 03.03.2015 08:56:
> This output variables gives more flexibility for future changes
> in autoconf to detect if it is needed to auto-generate files and
> check for the auto-generation dependencies.
> 
> It is still returning error when Python is not installed.
> 
> Signed-off-by: Samuel Iglesias Gonsalvez 
> ---
>  configure.ac  | 9 -
>  m4/ax_check_python_mako_module.m4 | 4 ++--
>  2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 2ba79ef..ff7d6c9 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -114,7 +114,14 @@ if test "x$INDENT" != "xcat"; then
>  fi
>  fi
>  
> -AX_CHECK_PYTHON_MAKO_MODULE(0.3.4)
> +PYTHON_MAKO_REQUIRED=0.3.4

Can you put that up into the section where all the other minimum versions are
defined? That would be more consistent.

Cheers,
Kai



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


[Mesa-dev] replace __FUNCTION__ with __func__ task

2015-03-03 Thread Brian Paul
We're using both of these in Mesa/gallium.  It would be nice to 
consistently just use C99's __func__ everywhere.  This would be any easy 
task for someone looking for something simple to do.


We could then get rid of this (broken) chunk seen in both compiler.h and 
p_compiler.h:


#ifndef __FUNCTION__
#  define __FUNCTION__ __func__
#endif

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


Re: [Mesa-dev] replace __FUNCTION__ with __func__ task

2015-03-03 Thread Jose Fonseca

On 03/03/15 15:57, Brian Paul wrote:

We're using both of these in Mesa/gallium.  It would be nice to
consistently just use C99's __func__ everywhere.  This would be any easy
task for someone looking for something simple to do.

We could then get rid of this (broken) chunk seen in both compiler.h and
p_compiler.h:

#ifndef __FUNCTION__
#  define __FUNCTION__ __func__
#endif


Sounds good to me.  Note that MSVC doesn't support __func__, only 
__FUNCTION__, so we need to ensure that c99_compat.h gets included 
everywhere.


Jose

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


Re: [Mesa-dev] replace __FUNCTION__ with __func__ task

2015-03-03 Thread Brian Paul

On 03/03/2015 09:56 AM, Jose Fonseca wrote:

On 03/03/15 15:57, Brian Paul wrote:

We're using both of these in Mesa/gallium.  It would be nice to
consistently just use C99's __func__ everywhere.  This would be any easy
task for someone looking for something simple to do.

We could then get rid of this (broken) chunk seen in both compiler.h and
p_compiler.h:

#ifndef __FUNCTION__
#  define __FUNCTION__ __func__
#endif


Sounds good to me.  Note that MSVC doesn't support __func__, only
__FUNCTION__, so we need to ensure that c99_compat.h gets included
everywhere.


Right.  That should already be the case since it's included by 
src/mesa/main/compiler.h which gets included almost everywhere already.


-Brian


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


Re: [Mesa-dev] [PATCH] main/base_tex_format: Properly handle STENCIL_INDEX1/4/16

2015-03-03 Thread Neil Roberts
Jason Ekstrand  writes:

> On Mon, Mar 2, 2015 at 11:33 AM, Ilia Mirkin  wrote:
>
>> On Mon, Mar 2, 2015 at 2:32 PM, Jason Ekstrand 
>> wrote:
>> >
>> >
>> > On Mon, Mar 2, 2015 at 11:18 AM, Ilia Mirkin 
>> wrote:
>> >>
>> >> Hmmm... I was just looking at this code in connection to attepmting to
>> >> enable ARB_texture_stencil8, and it _seems_ like that should be if
>> >> (ARB_texture_stencil8) -- I didn't see what in ARB_stencil_texturing
>> >> had to do with being able to have a GL_STENCIL_INDEX* internal
>> >> format...
>> >
>> >
>> > I just pushed it because it does fix a bug...  However, you do raise a
>> good
>> > point.  Maybe we should change the i965 driver to use GL_STENCIL_INDEX
>> for
>> > the internal format for our internal stencil buffers.
>>
>> How do you end up with a GL_STENCIL_INDEX internal format in the first
>> place? Without ARB_texture_stencil8 that's not a thing, is it?
>>
>
> We're using it internally for doing stencil blits.  I'm going to Cc Neil
> and he can explain what's going on there better than I can as he was the
> one who wrote most of that code.

Do you mean the code to do the meta stencil blit? I haven't touched
that. Maybe I can pass the buck on to Topi :)

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


Re: [Mesa-dev] [PATCH] configure: simplify visibility compiler flag detection

2015-03-03 Thread Emil Velikov
On 3 March 2015 at 05:21, Alan Coopersmith  wrote:
> On 03/ 1/15 02:31 PM, Emil Velikov wrote:
>>
>>   - Considering the lack of -fvisibility, what is the normal visibility
>> "level" - hidden or default ? If the latter this means that every
>> library/module built exports a ton of internal symbols.
>
>
> Default, unless you pass the -xldscope=hidden flag to Studio, as the
> Xserver does:
>
> http://cgit.freedesktop.org/xorg/xserver/tree/configure.ac?id=xorg-server-1.17.1#n1840
>
Would you mind rolling a similar patch for mesa, and testing it out.
I'm suspecting that mesa is missing a few PUBLIC annotations. I will
roll a similar one for libdrm, as I'm pretty sure it ought to be safe.

Btw did we manage to get through with all the build issues for mesa
10.4/10.5 ? If there is something blocking it, please do shout/file a
bug - when you have the time of course :-)


>>   - Using the __has_attribute macro looks great, although I would suspect
>> that it will take a while for GCC and others to adopt(?).
>
>
> Probably, which is why X.Org uses it in addition to, instead of as a
> replacement for, the gcc version checks for now:
>
Ouch.. caffeine deprived brain read your earlier comment as "to replace" :-\


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


Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Jose Fonseca

On 03/03/15 12:31, Jose Fonseca wrote:

On 27/02/15 15:16, Jose Fonseca wrote:

As we're gaining momentum cleanup Mesa code, I think it would help if we
also removed some stale components.

What do people feel about removing:

- src/mesa/drivers/windows/gdi -- the old SW rasterizer for Windows -- I
haven't used in a very long time, and given that the old SW rasterizer
is so far behind compared gallium based softpipe/llvmpipe rasterizers,
it's hard to imagine this will ever be useful again

- src/gallium/drivers/rbug: -- do people use it? does it work?  it
predates apitrace GL + GUI, which sort of enables a lot of the same
things, but without the issue of having to hit moving target, which is
what gallium interfaces are

- src/gallium/state_trackers/vega/,src/mapi/vgapi/ -- OpenVG API seems
to have dwindled away. I recall Zack himself saying that much. The code
would still be interesting if we wanted to implement NV_path_rendering
[1], but given the trend of the next gen graphics APIs, it seems
unlikely that this becomes ARB or core.

- src/gallium/state_trackers/egl/ -- yeah, I know I was against it, but
since then I discovered WGL/GLX_EXT_create_context_es_profile, and the
odds of us (VMware) needing this again are dimmer than last time, so I
have to admit it does seem unlikely we or anybody will need it again,
and we can always revert it from history..


Anything else?


Thanks for all the replies.  So in summary, I'll post patches to remove:

- src/mesa/drivers/windows/gdi

- src/gallium/state_trackers/vega/,src/mapi/vgapi/

- src/gallium/state_trackers/egl/ plus whatever modules get orphaned as
result of that


I've prototyped this in

  http://cgit.freedesktop.org/~jrfonseca/mesa/log/?h=remove-st-egl

The changes are massive, so I'm not sure it's even worth spamming the 
list with them.


Could you please give a look and let me know if there are any concerns?

The only snafu is Android.mk -- it will be broken with gallium drivers 
until somebody familiar with that infrastructure updates it to use 
egl_dri2. But it should build fine without gallium drivers.



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


Re: [Mesa-dev] [PATCH] nir: Use helper macros for dealing with VLAs.

2015-03-03 Thread Jason Ekstrand
LGTM.  I would still rather do the allocation in live_variables not on the
stack, but I can clean that up later.

Reviewed-by: Jason Ekstrand 

On Tue, Mar 3, 2015 at 5:19 AM, Jose Fonseca  wrote:

> v2:
> - Single statement, by using memset return value as suggested by Ian
> Romanick.
> - No internal declaration, as suggested by Jason Ekstrand.
> - Move macros to a header.
> ---
>  src/glsl/nir/nir_from_ssa.c  | 23 ++-
>  src/glsl/nir/nir_live_variables.c|  4 +--
>  src/glsl/nir/nir_lower_vars_to_ssa.c | 12 +++-
>  src/glsl/nir/nir_vla.h   | 54
> 
>  4 files changed, 69 insertions(+), 24 deletions(-)
>  create mode 100644 src/glsl/nir/nir_vla.h
>
> diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
> index 66339f3..c3090fb 100644
> --- a/src/glsl/nir/nir_from_ssa.c
> +++ b/src/glsl/nir/nir_from_ssa.c
> @@ -26,7 +26,7 @@
>   */
>
>  #include "nir.h"
> -#include "c99_alloca.h"
> +#include "nir_vla.h"
>
>  /*
>   * This file implements an out-of-SSA pass as described in "Revisiting
> @@ -182,7 +182,7 @@ merge_merge_sets(merge_set *a, merge_set *b)
>  static bool
>  merge_sets_interfere(merge_set *a, merge_set *b)
>  {
> -   merge_node **dom = alloca((a->size + b->size) * sizeof *dom);
> +   NIR_VLA(merge_node *, dom, a->size + b->size);
> int dom_idx = -1;
>
> struct exec_node *an = exec_list_get_head(&a->nodes);
> @@ -674,21 +674,16 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
> }
>
> /* The register/source corresponding to the given index */
> -   nir_src *values = alloca(num_copies * 2 * sizeof *values);
> -   memset(values, 0, num_copies * 2 * sizeof *values);
> +   NIR_VLA_ZERO(nir_src, values, num_copies * 2);
>
> -   /* The current location of a given piece of data */
> -   int *loc = alloca(num_copies * 2 * sizeof *loc);
> +   /* The current location of a given piece of data.  We will use -1 for
> "null" */
> +   NIR_VLA_FILL(int, loc, num_copies * 2, -1);
>
> -   /* The piece of data that the given piece of data is to be copied from
> */
> -   int *pred = alloca(num_copies * 2 * sizeof *pred);
> -
> -   /* Initialize loc and pred.  We will use -1 for "null" */
> -   memset(loc, -1, num_copies * 2 * sizeof *loc);
> -   memset(pred, -1, num_copies * 2 * sizeof *pred);
> +   /* The piece of data that the given piece of data is to be copied
> from.  We will use -1 for "null" */
> +   NIR_VLA_FILL(int, pred, num_copies * 2, -1);
>
> /* The destinations we have yet to properly fill */
> -   int *to_do = alloca(num_copies * 2 * sizeof *to_do);
> +   NIR_VLA(int, to_do, num_copies * 2);
> int to_do_idx = -1;
>
> /* Now we set everything up:
> @@ -738,7 +733,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
> }
>
> /* Currently empty destinations we can go ahead and fill */
> -   int *ready = alloca(num_copies * 2 * sizeof *ready);
> +   NIR_VLA(int, ready, num_copies * 2);
> int ready_idx = -1;
>
> /* Mark the ones that are ready for copying.  We know an index is a
> diff --git a/src/glsl/nir/nir_live_variables.c
> b/src/glsl/nir/nir_live_variables.c
> index b57ca3a..1c96dcf 100644
> --- a/src/glsl/nir/nir_live_variables.c
> +++ b/src/glsl/nir/nir_live_variables.c
> @@ -26,7 +26,7 @@
>
>  #include "nir.h"
>  #include "nir_worklist.h"
> -#include "c99_alloca.h"
> +#include "nir_vla.h"
>
>  /*
>   * Basic liveness analysis.  This works only in SSA form.
> @@ -131,7 +131,7 @@ static bool
>  propagate_across_edge(nir_block *pred, nir_block *succ,
>struct live_variables_state *state)
>  {
> -   BITSET_WORD *live = alloca(state->bitset_words * sizeof *live);
> +   NIR_VLA(BITSET_WORD, live, state->bitset_words);
> memcpy(live, succ->live_in, state->bitset_words * sizeof *live);
>
> nir_foreach_instr(succ, instr) {
> diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c
> b/src/glsl/nir/nir_lower_vars_to_ssa.c
> index f54d1b7..9e9a418 100644
> --- a/src/glsl/nir/nir_lower_vars_to_ssa.c
> +++ b/src/glsl/nir/nir_lower_vars_to_ssa.c
> @@ -26,8 +26,7 @@
>   */
>
>  #include "nir.h"
> -
> -#include "c99_alloca.h"
> +#include "nir_vla.h"
>
>
>  struct deref_node {
> @@ -902,8 +901,8 @@ rename_variables_block(nir_block *block, struct
> lower_variables_state *state)
>  static void
>  insert_phi_nodes(struct lower_variables_state *state)
>  {
> -   unsigned *work = alloca(state->impl->num_blocks * sizeof *work);
> -   unsigned *has_already = alloca(state->impl->num_blocks * sizeof
> *has_already);
> +   NIR_VLA_ZERO(unsigned, work, state->impl->num_blocks);
> +   NIR_VLA_ZERO(unsigned, has_already, state->impl->num_blocks);
>
> /*
>  * Since the work flags already prevent us from inserting a node that
> has
> @@ -913,10 +912,7 @@ insert_phi_nodes(struct lower_variables_state *state)
>  * function. So all we need to handle W is an array and a pointer to
> the
>  * next element to be inserted and the next element to be remo

Re: [Mesa-dev] [PATCH 2/2] egl: implement EGL_MESA_transparent_alpha for x11 and wayland

2015-03-03 Thread Chad Versace
On 02/23/2015 06:32 AM, Jonny Lamb wrote:
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67676
> ---
>  include/EGL/eglmesaext.h|  5 +
>  src/egl/drivers/dri2/platform_wayland.c |  9 +++--
>  src/egl/drivers/dri2/platform_x11.c | 22 +-
>  src/egl/main/eglapi.c   | 13 +
>  src/egl/main/eglconfig.c|  3 ++-
>  5 files changed, 40 insertions(+), 12 deletions(-)
> 
> diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h
> index 5fcc527..3fa7c9c 100644
> --- a/include/EGL/eglmesaext.h
> +++ b/include/EGL/eglmesaext.h
> @@ -170,6 +170,11 @@ typedef EGLBoolean (EGLAPIENTRYP 
> PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EG
>  #define EGL_NO_CONFIG_MESA   ((EGLConfig)0)
>  #endif
>  
> +#ifndef EGL_MESA_transparent_alpha
> +#define EGL_MESA_transparent_alpha 1
> +#define EGL_TRANSPARENT_ALPHA_MESA   0x31E9
> +#endif

According to the EGL registry today, 0x31E9 is owned by Hitachi. The first 
unused enum
in Mesa's reserved range is 0x31D9, so you should use that.

> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/src/egl/drivers/dri2/platform_wayland.c 
> b/src/egl/drivers/dri2/platform_wayland.c
> index 3c34e07..ba071a5 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -965,6 +965,10 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay 
> *disp)
>{ 0xff, 0xff00, 0xff, 0xff00 };
> static const unsigned int rgb_masks[4] = { 0xff, 0xff00, 0xff, 0 };
> static const unsigned int rgb565_masks[4] = { 0xf800, 0x07e0, 0x001f, 0 };
> +   static const EGLint argb_attrs[] = {
> +   EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_ALPHA_MESA,
> +   EGL_NONE
> +   };
>  
> loader_set_logger(_eglLog);
>  
> @@ -1044,8 +1048,9 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay 
> *disp)
>config = dri2_dpy->driver_configs[i];
>if (dri2_dpy->formats & HAS_XRGB)
>dri2_add_config(disp, config, i + 1, types, NULL, rgb_masks);
> -  if (dri2_dpy->formats & HAS_ARGB)
> -  dri2_add_config(disp, config, i + 1, types, NULL, argb_masks);
> +  if (dri2_dpy->formats & HAS_ARGB) {
> +  dri2_add_config(disp, config, i + 1, types, argb_attrs, argb_masks);
> +  }
>if (dri2_dpy->formats & HAS_RGB565)
>  dri2_add_config(disp, config, i + 1, types, NULL, rgb565_masks);
> }

I tested this patch with X11 and Mesa, and it works as advertised. BUT...

Pre-patch, Wayland applications who requested an EGLConfig with alpha
received one. The EGLSurface had compositor-transparent alpha, which
the application may not have expected. But the alpha configs *were*
available.

Post-patch, existing Wayland applications that request an EGLConfig with
alpha will no longer receive one, because the existing applications
do not yet know about EGL_TRANSPARENT_ALPHA_MESA.

I believe a correct solution is to continue create EGLConfigs
with EGL_ALPHA and without EGL_TRANSPARENT_TYPE, as Mesa does today,
but tell the compositor to ignore the alpha channel. The alpha channel
will be used for client-side alpha-blending but not for compositing.
Jason says that should be possible by telling the compositor that
the buffer format is WL_DRM_FORMAT_XRGB. And in addition to the existing
EGLConfigs, also create new EGLConfigs with EGL_TRANSPARENT_ALPHA_MESA, as
this patch already does.

By the way, the X11 portion of the patch looks good to me.









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


Re: [Mesa-dev] [PATCH] i965: Fix uint64_t overflow in intel_client_wait_sync()

2015-03-03 Thread Chad Versace
On 03/02/2015 04:27 PM, Kristian Høgsberg wrote:
> DRM_IOCTL_I915_GEM_WAIT takes an int64_t for the timeout value but
> GL_ARB_sync takes an uint64_t.  Further, the ioctl used to wait
> indefinitely when passed a negative timeout, but it's been broken and
> now returns immediately in that case.  Thus, if an application passes
> UINT64_MAX to wait forever, we overflow to -1LL and return immediately.
> Work around this mess by clamping the wait timeout to INT64_MAX.
> 
> Signed-off-by: Kristian Høgsberg 

Reviewed-by: Chad Versace 




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


Re: [Mesa-dev] [PATCH 1/2] egl: add EGL_MESA_transparent_alpha extension

2015-03-03 Thread Chad Versace
On 02/23/2015 06:32 AM, Jonny Lamb wrote:
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67676
> Reviewed-by: Chad Versace 
> ---
>  docs/specs/EGL_MESA_transparent_alpha.txt | 120 
> ++
>  1 file changed, 120 insertions(+)
>  create mode 100644 docs/specs/EGL_MESA_transparent_alpha.txt
> 
> diff --git a/docs/specs/EGL_MESA_transparent_alpha.txt 
> b/docs/specs/EGL_MESA_transparent_alpha.txt
> new file mode 100644
> index 000..f3d1fec
> --- /dev/null
> +++ b/docs/specs/EGL_MESA_transparent_alpha.txt
> @@ -0,0 +1,120 @@
> +Name


> +New Tokens
> +
> +Accepted as the value of the EGLConfig attribute EGL_TRANSPARENT_TYPE:
> +
> +EGL_TRANSPARENT_ALPHA_MESA0x
 ^^
You need to fill in the enum value. Other than that, the spec looks good to me.




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


Re: [Mesa-dev] [PATCH] i965: Fix uint64_t overflow in intel_client_wait_sync()

2015-03-03 Thread Matt Turner
On Mon, Mar 2, 2015 at 4:27 PM, Kristian Høgsberg  wrote:
> DRM_IOCTL_I915_GEM_WAIT takes an int64_t for the timeout value but
> GL_ARB_sync takes an uint64_t.  Further, the ioctl used to wait
> indefinitely when passed a negative timeout, but it's been broken and
> now returns immediately in that case.  Thus, if an application passes
> UINT64_MAX to wait forever, we overflow to -1LL and return immediately.
> Work around this mess by clamping the wait timeout to INT64_MAX.
>
> Signed-off-by: Kristian Høgsberg 
> ---
>
>
>  src/mesa/drivers/dri/i965/intel_syncobj.c | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_syncobj.c 
> b/src/mesa/drivers/dri/i965/intel_syncobj.c
> index 9cde152..fb95892 100644
> --- a/src/mesa/drivers/dri/i965/intel_syncobj.c
> +++ b/src/mesa/drivers/dri/i965/intel_syncobj.c
> @@ -84,6 +84,13 @@ static void intel_client_wait_sync(struct gl_context *ctx, 
> struct gl_sync_object
>  {
> struct intel_sync_object *sync = (struct intel_sync_object *)s;
>
> +   /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and returns
> +* immediately for timeouts <= 0.  The best we can do is to clamp the
> +* timeout to INT64_MAX.  This limits the maximum timeout from 584 years 
> to
> +* 292 years - likely not a big deal. */

 */ on its own line.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] egl: Report correct GBM formats

2015-03-03 Thread Chad Versace
On 03/02/2015 06:23 AM, Tom Stellard wrote:
> From: Daniel Stone 
> 
> This fixes almost all piglit regressions when running with
> PIGLIT_PLATFORM=gbm
> 
> Tom Stellard:
>   - Fix ARGB2101010 format
> 
> Cc: "10.4 10.5" 

Reviewed-by: Chad Versace 




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


Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Emil Velikov
On 3 March 2015 at 17:16, Jose Fonseca  wrote:
...
>
> I've prototyped this in
>
>   http://cgit.freedesktop.org/~jrfonseca/mesa/log/?h=remove-st-egl
>
> The changes are massive, so I'm not sure it's even worth spamming the list
> with them.
>
> Could you please give a look and let me know if there are any concerns?
>
I've spotted a few trivial bits:

 - windows/gdi: Remove.
Drop drivers/windows from src/mesa/Makefile.am:EXTRA_DIST
The driver had interesting api/wrapper similar to osmesa. Did not know that :-)

-  st/egl: Remove.
Update the src/egl/main/Sconscript to create a SharedLibrary, add
versioning, create symlink - copy the bits from egl-static.
Drop st/egl and targets/egl-static from src/gallium/Makefile.am:EXTRA_DIST
Remove the _EGL_BUILT_IN_DRIVER_GALLIUM define from src/egl/main/Android.mk.

 - st/vega: Remove.
A few "openvg" references left - one in configure.ac another one in
docs/contents.html


> The only snafu is Android.mk -- it will be broken with gallium drivers until
> somebody familiar with that infrastructure updates it to use egl_dri2. But
> it should build fine without gallium drivers.
>
The Android build is mostly limping around mesa 10.4. I've pinged the
Android-x86 guys, but but might get to it soon(ish). Don't worry too
much about it.

I'm guessing that the scons and automake build do not point out
anything unusual ?

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


Re: [Mesa-dev] [PATCH] [RFC] egl: propose simple EGL_MESA_image_dma_buf_export v2.2

2015-03-03 Thread Chad Versace
On 03/03/2015 12:13 AM, Daniel Stone wrote:
> Hi,
> 
> On Tuesday, March 3, 2015, Dave Airlie  > wrote:
> 
> +EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
> +  EGLImageKHR image,
> + int *fourcc,
> + int *num_planes);
> 
> 
> Shouldn't this contain the modifier(s) as well?

What is the motivation for defining two export calls, and exporting
a subset of information from each call? I don't understand why the
fourcc values are exported by one call, but the strides exported a
separate call.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] egl dma-buf export extension again

2015-03-03 Thread Chad Versace
On 03/02/2015 09:36 PM, Dave Airlie wrote:
> On 3 March 2015 at 13:57, Dave Airlie  wrote:
>>
>> Okay I've revised this to add some more info to the interface,
>> essentially I need to get the fourcc back so I can later pass
>> it across the "wire" to the EGL_EXT_image_dma_buf_import, also
>> the number of planes (though for my usecase I don't care so much).
>>
>> The problem with EGL_MESA_drm_image is that I've no idea how to retrieve
>> the internal format of an image so I know what to tell the other side,
>> since I just create a normal 2D texture and want to export it,
>> I need to know what format mesa internally picked for it. This works
>> out the fourcc and returns it.
>>
> 
> While talking to krh on irc he mentioned that maybe I should skip egl images
> 
> and go straight to the texture id->dma-buf extension,
> 
> again any opinions from anyone in the area would be useful.

Please use EGLImages as the import/export object. That provides
consistency with existing similar EGL APIs. And it allows a clean
separation between EGL-aware code and GL-aware code in applications
and compositors.

For what it's worth, extensions in this area being developed by Google's
Chrome OS team also use EGLImages as the transport object.

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


Re: [Mesa-dev] [PATCH 2/2] egl: implement EGL_MESA_transparent_alpha for x11 and wayland

2015-03-03 Thread Jason Ekstrand
On Tue, Mar 3, 2015 at 10:07 AM, Chad Versace 
wrote:

> On 02/23/2015 06:32 AM, Jonny Lamb wrote:
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67676
> > ---
> >  include/EGL/eglmesaext.h|  5 +
> >  src/egl/drivers/dri2/platform_wayland.c |  9 +++--
> >  src/egl/drivers/dri2/platform_x11.c | 22 +-
> >  src/egl/main/eglapi.c   | 13 +
> >  src/egl/main/eglconfig.c|  3 ++-
> >  5 files changed, 40 insertions(+), 12 deletions(-)
> >
> > diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h
> > index 5fcc527..3fa7c9c 100644
> > --- a/include/EGL/eglmesaext.h
> > +++ b/include/EGL/eglmesaext.h
> > @@ -170,6 +170,11 @@ typedef EGLBoolean (EGLAPIENTRYP
> PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EG
> >  #define EGL_NO_CONFIG_MESA   ((EGLConfig)0)
> >  #endif
> >
> > +#ifndef EGL_MESA_transparent_alpha
> > +#define EGL_MESA_transparent_alpha 1
> > +#define EGL_TRANSPARENT_ALPHA_MESA   0x31E9
> > +#endif
>
> According to the EGL registry today, 0x31E9 is owned by Hitachi. The first
> unused enum
> in Mesa's reserved range is 0x31D9, so you should use that.
>
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/src/egl/drivers/dri2/platform_wayland.c
> b/src/egl/drivers/dri2/platform_wayland.c
> > index 3c34e07..ba071a5 100644
> > --- a/src/egl/drivers/dri2/platform_wayland.c
> > +++ b/src/egl/drivers/dri2/platform_wayland.c
> > @@ -965,6 +965,10 @@ dri2_initialize_wayland(_EGLDriver *drv,
> _EGLDisplay *disp)
> >{ 0xff, 0xff00, 0xff, 0xff00 };
> > static const unsigned int rgb_masks[4] = { 0xff, 0xff00, 0xff, 0
> };
> > static const unsigned int rgb565_masks[4] = { 0xf800, 0x07e0,
> 0x001f, 0 };
> > +   static const EGLint argb_attrs[] = {
> > +   EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_ALPHA_MESA,
> > +   EGL_NONE
> > +   };
> >
> > loader_set_logger(_eglLog);
> >
> > @@ -1044,8 +1048,9 @@ dri2_initialize_wayland(_EGLDriver *drv,
> _EGLDisplay *disp)
> >config = dri2_dpy->driver_configs[i];
> >if (dri2_dpy->formats & HAS_XRGB)
> >dri2_add_config(disp, config, i + 1, types, NULL, rgb_masks);
> > -  if (dri2_dpy->formats & HAS_ARGB)
> > -  dri2_add_config(disp, config, i + 1, types, NULL, argb_masks);
> > +  if (dri2_dpy->formats & HAS_ARGB) {
> > +  dri2_add_config(disp, config, i + 1, types, argb_attrs,
> argb_masks);
> > +  }
> >if (dri2_dpy->formats & HAS_RGB565)
> >  dri2_add_config(disp, config, i + 1, types, NULL, rgb565_masks);
> > }
>
> I tested this patch with X11 and Mesa, and it works as advertised. BUT...
>
> Pre-patch, Wayland applications who requested an EGLConfig with alpha
> received one. The EGLSurface had compositor-transparent alpha, which
> the application may not have expected. But the alpha configs *were*
> available.
>
> Post-patch, existing Wayland applications that request an EGLConfig with
> alpha will no longer receive one, because the existing applications
> do not yet know about EGL_TRANSPARENT_ALPHA_MESA.
>
> I believe a correct solution is to continue create EGLConfigs
> with EGL_ALPHA and without EGL_TRANSPARENT_TYPE, as Mesa does today,
> but tell the compositor to ignore the alpha channel. The alpha channel
> will be used for client-side alpha-blending but not for compositing.
> Jason says that should be possible by telling the compositor that
> the buffer format is WL_DRM_FORMAT_XRGB. And in addition to the
> existing
> EGLConfigs, also create new EGLConfigs with EGL_TRANSPARENT_ALPHA_MESA, as
> this patch already does.
>

Yes, XRGB would be the correct *technical* way to handle that, but it
still makes me wonder... What about Wayland apps that expect to get
transparency by simply asking for alpha now?  Won't this break them?  I
guess we have to break one class of apps or the other.
--Jason

By the way, the X11 portion of the patch looks good to me.
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] intel: fix EGLImage renderbuffer _BaseFormat

2015-03-03 Thread Chad Versace
On 02/19/2015 03:09 PM, Frank Henigman wrote:
> Correctly set _BaseFormat field when creating a gl_renderbuffer
> with EGLImage storage.
> 
> Signed-off-by: Frank Henigman 
> Reviewed-by: Stéphane Marchesin 
> ---
>  src/mesa/drivers/dri/i915/intel_fbo.c | 3 +--
>  src/mesa/drivers/dri/i965/intel_fbo.c | 2 +-
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> Otherwise, when using gles, _BaseFormat is set to 0 and a glReadPixels
> from the buffer hits an assert.
> Tested on i965.  Compiled for i915.

Reviewed-by: Chad Versace 
And committed.

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


Re: [Mesa-dev] [PATCH] [RFC] egl: propose simple EGL_MESA_image_dma_buf_export v2.2

2015-03-03 Thread Daniel Stone
Hi,

On 3 March 2015 at 18:40, Chad Versace  wrote:
> On 03/03/2015 12:13 AM, Daniel Stone wrote:
>> On Tuesday, March 3, 2015, Dave Airlie > > wrote:
>> +EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
>> +  EGLImageKHR image,
>> + int *fourcc,
>> + int *num_planes);
>>
>>
>> Shouldn't this contain the modifier(s) as well?
>
> What is the motivation for defining two export calls, and exporting
> a subset of information from each call? I don't understand why the
> fourcc values are exported by one call, but the strides exported a
> separate call.

Querying the image gives you what you need in order to know if you can
actually deal with the image, before you go to all the effort of
exporting it.

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


Re: [Mesa-dev] [PATCH] [RFC] egl: propose simple EGL_MESA_image_dma_buf_export v2.2

2015-03-03 Thread Chad Versace
On 03/03/2015 11:01 AM, Daniel Stone wrote:
> Hi,
> 
> On 3 March 2015 at 18:40, Chad Versace  wrote:
>> On 03/03/2015 12:13 AM, Daniel Stone wrote:
>>> On Tuesday, March 3, 2015, Dave Airlie >> > wrote:
>>> +EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
>>> +  EGLImageKHR image,
>>> + int *fourcc,
>>> + int *num_planes);
>>>
>>>
>>> Shouldn't this contain the modifier(s) as well?
>>
>> What is the motivation for defining two export calls, and exporting
>> a subset of information from each call? I don't understand why the
>> fourcc values are exported by one call, but the strides exported a
>> separate call.
> 
> Querying the image gives you what you need in order to know if you can
> actually deal with the image, before you go to all the effort of
> exporting it.

Thanks. That makes sense.

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


Re: [Mesa-dev] [PATCH 2/2] egl: implement EGL_MESA_transparent_alpha for x11 and wayland

2015-03-03 Thread Daniel Stone
Hi,

On 3 March 2015 at 18:56, Jason Ekstrand  wrote:
> On Tue, Mar 3, 2015 at 10:07 AM, Chad Versace 
> wrote:
>> On 02/23/2015 06:32 AM, Jonny Lamb wrote:
>> > +   static const EGLint argb_attrs[] = {
>> > +   EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_ALPHA_MESA,
>> > +   EGL_NONE
>> > +   };
>> >
>>
>> I tested this patch with X11 and Mesa, and it works as advertised. BUT...
>>
>> Pre-patch, Wayland applications who requested an EGLConfig with alpha
>> received one. The EGLSurface had compositor-transparent alpha, which
>> the application may not have expected. But the alpha configs *were*
>> available.
>>
>> Post-patch, existing Wayland applications that request an EGLConfig with
>> alpha will no longer receive one, because the existing applications
>> do not yet know about EGL_TRANSPARENT_ALPHA_MESA.
>>
>> I believe a correct solution is to continue create EGLConfigs
>> with EGL_ALPHA and without EGL_TRANSPARENT_TYPE, as Mesa does today,
>> but tell the compositor to ignore the alpha channel. The alpha channel
>> will be used for client-side alpha-blending but not for compositing.
>> Jason says that should be possible by telling the compositor that
>> the buffer format is WL_DRM_FORMAT_XRGB. And in addition to the
>> existing
>> EGLConfigs, also create new EGLConfigs with EGL_TRANSPARENT_ALPHA_MESA, as
>> this patch already does.
>
> Yes, XRGB would be the correct *technical* way to handle that, but it
> still makes me wonder... What about Wayland apps that expect to get
> transparency by simply asking for alpha now?  Won't this break them?  I
> guess we have to break one class of apps or the other.

Yeah, it will break them. But then again, we had the same flag day for
X11 in that exact Bugzilla discussion, when X11 apps which requested
ALPHA_SIZE == 8 went from getting ARGB32 drawables which would be
blended by the compositor, to not - a change which was deemed totally
fine to enforce on people because it improved performance and matched
the spec.

Perhaps a better interim solution is to assume for Wayland that
EGL_TRANSPARENT_TYPE == EGL_DONT_CARE means that applications will get
a format determined by ALPHA_SIZE (i.e. size 8 means ARGB32, size 0
means XRGB32), but respect explicit demands for
TRANSPARENT_{NONE,ALPHA}.

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


Re: [Mesa-dev] [PATCH] [RFC] egl: propose simple EGL_MESA_image_dma_buf_export v2.2

2015-03-03 Thread Dave Airlie
On 4 March 2015 at 05:06, Chad Versace  wrote:
> On 03/03/2015 11:01 AM, Daniel Stone wrote:
>> Hi,
>>
>> On 3 March 2015 at 18:40, Chad Versace  wrote:
>>> On 03/03/2015 12:13 AM, Daniel Stone wrote:
 On Tuesday, March 3, 2015, Dave Airlie >>> > wrote:
 +EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
 +  EGLImageKHR image,
 + int *fourcc,
 + int *num_planes);


 Shouldn't this contain the modifier(s) as well?
>>>
>>> What is the motivation for defining two export calls, and exporting
>>> a subset of information from each call? I don't understand why the
>>> fourcc values are exported by one call, but the strides exported a
>>> separate call.
>>
>> Querying the image gives you what you need in order to know if you can
>> actually deal with the image, before you go to all the effort of
>> exporting it.
>
> Thanks. That makes sense.

Also you need the number of planes to correctly size the arrays for
the second call to put the results into.

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


Re: [Mesa-dev] [PATCH] [RFC] egl: propose simple EGL_MESA_image_dma_buf_export v2.2

2015-03-03 Thread Chad Versace
On 03/03/2015 11:13 AM, Dave Airlie wrote:
> On 4 March 2015 at 05:06, Chad Versace  wrote:
>> On 03/03/2015 11:01 AM, Daniel Stone wrote:
>>> Hi,
>>>
>>> On 3 March 2015 at 18:40, Chad Versace  wrote:
 On 03/03/2015 12:13 AM, Daniel Stone wrote:
> On Tuesday, March 3, 2015, Dave Airlie  > wrote:
> +EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
> +  EGLImageKHR image,
> + int *fourcc,
> + int *num_planes);
>
>
> Shouldn't this contain the modifier(s) as well?

 What is the motivation for defining two export calls, and exporting
 a subset of information from each call? I don't understand why the
 fourcc values are exported by one call, but the strides exported a
 separate call.
>>>
>>> Querying the image gives you what you need in order to know if you can
>>> actually deal with the image, before you go to all the effort of
>>> exporting it.
>>
>> Thanks. That makes sense.
> 
> Also you need the number of planes to correctly size the arrays for
> the second call to put the results into.

Right, I understood that you needed to know the number of planes before
submitting the array. I was mostly confused by why fourcc was in this call,
not num_planes.

My real feedback: It's probably best to rename num_planes to num_fds,
because you're not guaranteed num_fds != num_planes for interleaved formats.
And, using the name 'num_fds' allows us to avoid awkwardness if we need to
create future layered extensions
that export auxilliary buffers that may not correspond YUV planes. (There's
been a lot of lunch talk about exporting aux buffers at Intel).
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [GSoC] Improved application of GLSL complier optimizations

2015-03-03 Thread Alexander Mezin
Hello.

I plan to participate in GSoC this year as a student. And I've found a
project idea which I like very much on X.Org's ideas page. It's called
"Improved application of GLSL compiler optimizations".

For me, it looks mostly like an optimization problem in mathematical
meaning. Benchmark could be treated as a function that computes a
score taking a sequence of passes as input. If I'm not mistaken, there
are more than 30 passes, so even trying all permutations will take a
long time, even if we imagine we can measure shader "quality"
immediately. I think it's worth to try various heuristic optimization
techniques like simulated annealing or genetic algorithm.

Furthermore, looks like the same pass sequence could give different
results on different shaders, so it won't be possible to determine
single optimal sequence. But some limited randomization could help
dealing with it, probably.

Overall this project looks more like research than coding. I like it,
but I have few concerns:
1. Probably the final result will look very stupid, like "do
everything twice in any order, everything else doesn't matter". Though
it will be proved at least.
2. What to do next depends on results of the previous step. I'll
hardly be able to do very detailed plan.

So, do you think it's worth trying?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] replace __FUNCTION__ with __func__ task

2015-03-03 Thread Jan Vesely
On Tue, 2015-03-03 at 10:07 -0700, Brian Paul wrote:
> On 03/03/2015 09:56 AM, Jose Fonseca wrote:
> > On 03/03/15 15:57, Brian Paul wrote:
> >> We're using both of these in Mesa/gallium.  It would be nice to
> >> consistently just use C99's __func__ everywhere.  This would be any easy
> >> task for someone looking for something simple to do.
> >>
> >> We could then get rid of this (broken) chunk seen in both compiler.h and
> >> p_compiler.h:
> >>
> >> #ifndef __FUNCTION__
> >> #  define __FUNCTION__ __func__
> >> #endif
> >
> > Sounds good to me.  Note that MSVC doesn't support __func__, only
> > __FUNCTION__, so we need to ensure that c99_compat.h gets included
> > everywhere.
> 
> Right.  That should already be the case since it's included by 
> src/mesa/main/compiler.h which gets included almost everywhere already.

would it make sense to add -imacros/-include cmdline options for these
headers?
I have no idea whether these are supported by other compilers (at least
-include is supported by clang)

jan

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


-- 
Jan Vesely 


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


Re: [Mesa-dev] [PATCH] main/base_tex_format: Properly handle STENCIL_INDEX1/4/16

2015-03-03 Thread Kenneth Graunke
On Monday, March 02, 2015 02:33:31 PM Ilia Mirkin wrote:
> On Mon, Mar 2, 2015 at 2:32 PM, Jason Ekstrand  wrote:
> >
> >
> > On Mon, Mar 2, 2015 at 11:18 AM, Ilia Mirkin  wrote:
> >>
> >> Hmmm... I was just looking at this code in connection to attepmting to
> >> enable ARB_texture_stencil8, and it _seems_ like that should be if
> >> (ARB_texture_stencil8) -- I didn't see what in ARB_stencil_texturing
> >> had to do with being able to have a GL_STENCIL_INDEX* internal
> >> format...
> >
> >
> > I just pushed it because it does fix a bug...  However, you do raise a good
> > point.  Maybe we should change the i965 driver to use GL_STENCIL_INDEX for
> > the internal format for our internal stencil buffers.
> 
> How do you end up with a GL_STENCIL_INDEX internal format in the first
> place? Without ARB_texture_stencil8 that's not a thing, is it?

Eric added a ctx->Driver.BindRenderbufferTexImage hook which takes a
(non-texture) renderbuffer and wraps it in a fake texture image.

We use this in Meta's BlitFramebuffer implementation to be able to blit
from non-texture renderbuffers.  i965 also has a custom meta blit path
for stencil, which uses the same approach.  Thus, stencil textures :)


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


Re: [Mesa-dev] [PATCH] main/base_tex_format: Properly handle STENCIL_INDEX1/4/16

2015-03-03 Thread Ilia Mirkin
On Tue, Mar 3, 2015 at 3:58 PM, Kenneth Graunke  wrote:
> On Monday, March 02, 2015 02:33:31 PM Ilia Mirkin wrote:
>> On Mon, Mar 2, 2015 at 2:32 PM, Jason Ekstrand  wrote:
>> >
>> >
>> > On Mon, Mar 2, 2015 at 11:18 AM, Ilia Mirkin  wrote:
>> >>
>> >> Hmmm... I was just looking at this code in connection to attepmting to
>> >> enable ARB_texture_stencil8, and it _seems_ like that should be if
>> >> (ARB_texture_stencil8) -- I didn't see what in ARB_stencil_texturing
>> >> had to do with being able to have a GL_STENCIL_INDEX* internal
>> >> format...
>> >
>> >
>> > I just pushed it because it does fix a bug...  However, you do raise a good
>> > point.  Maybe we should change the i965 driver to use GL_STENCIL_INDEX for
>> > the internal format for our internal stencil buffers.
>>
>> How do you end up with a GL_STENCIL_INDEX internal format in the first
>> place? Without ARB_texture_stencil8 that's not a thing, is it?
>
> Eric added a ctx->Driver.BindRenderbufferTexImage hook which takes a
> (non-texture) renderbuffer and wraps it in a fake texture image.
>
> We use this in Meta's BlitFramebuffer implementation to be able to blit
> from non-texture renderbuffers.  i965 also has a custom meta blit path
> for stencil, which uses the same approach.  Thus, stencil textures :)

None of which has to do with ARB_stencil_texturing being enabled as
far as mesa/main is concerned, right? IOW, why is that condition
there?

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


Re: [Mesa-dev] [PATCH] main/base_tex_format: Properly handle STENCIL_INDEX1/4/16

2015-03-03 Thread Jason Ekstrand
On Tue, Mar 3, 2015 at 1:00 PM, Ilia Mirkin  wrote:

> On Tue, Mar 3, 2015 at 3:58 PM, Kenneth Graunke 
> wrote:
> > On Monday, March 02, 2015 02:33:31 PM Ilia Mirkin wrote:
> >> On Mon, Mar 2, 2015 at 2:32 PM, Jason Ekstrand 
> wrote:
> >> >
> >> >
> >> > On Mon, Mar 2, 2015 at 11:18 AM, Ilia Mirkin 
> wrote:
> >> >>
> >> >> Hmmm... I was just looking at this code in connection to attepmting
> to
> >> >> enable ARB_texture_stencil8, and it _seems_ like that should be if
> >> >> (ARB_texture_stencil8) -- I didn't see what in ARB_stencil_texturing
> >> >> had to do with being able to have a GL_STENCIL_INDEX* internal
> >> >> format...
> >> >
> >> >
> >> > I just pushed it because it does fix a bug...  However, you do raise
> a good
> >> > point.  Maybe we should change the i965 driver to use
> GL_STENCIL_INDEX for
> >> > the internal format for our internal stencil buffers.
> >>
> >> How do you end up with a GL_STENCIL_INDEX internal format in the first
> >> place? Without ARB_texture_stencil8 that's not a thing, is it?
> >
> > Eric added a ctx->Driver.BindRenderbufferTexImage hook which takes a
> > (non-texture) renderbuffer and wraps it in a fake texture image.
> >
> > We use this in Meta's BlitFramebuffer implementation to be able to blit
> > from non-texture renderbuffers.  i965 also has a custom meta blit path
> > for stencil, which uses the same approach.  Thus, stencil textures :)
>
> None of which has to do with ARB_stencil_texturing being enabled as
> far as mesa/main is concerned, right? IOW, why is that condition
> there?
>

Well, the blit path does require it because it requires us to be able to
sample from stencil.  Why does it require the internal format?  That's
another question.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] main/base_tex_format: Properly handle STENCIL_INDEX1/4/16

2015-03-03 Thread Ilia Mirkin
On Tue, Mar 3, 2015 at 4:31 PM, Jason Ekstrand  wrote:
>
>
> On Tue, Mar 3, 2015 at 1:00 PM, Ilia Mirkin  wrote:
>>
>> On Tue, Mar 3, 2015 at 3:58 PM, Kenneth Graunke 
>> wrote:
>> > On Monday, March 02, 2015 02:33:31 PM Ilia Mirkin wrote:
>> >> On Mon, Mar 2, 2015 at 2:32 PM, Jason Ekstrand 
>> >> wrote:
>> >> >
>> >> >
>> >> > On Mon, Mar 2, 2015 at 11:18 AM, Ilia Mirkin 
>> >> > wrote:
>> >> >>
>> >> >> Hmmm... I was just looking at this code in connection to attepmting
>> >> >> to
>> >> >> enable ARB_texture_stencil8, and it _seems_ like that should be if
>> >> >> (ARB_texture_stencil8) -- I didn't see what in ARB_stencil_texturing
>> >> >> had to do with being able to have a GL_STENCIL_INDEX* internal
>> >> >> format...
>> >> >
>> >> >
>> >> > I just pushed it because it does fix a bug...  However, you do raise
>> >> > a good
>> >> > point.  Maybe we should change the i965 driver to use
>> >> > GL_STENCIL_INDEX for
>> >> > the internal format for our internal stencil buffers.
>> >>
>> >> How do you end up with a GL_STENCIL_INDEX internal format in the first
>> >> place? Without ARB_texture_stencil8 that's not a thing, is it?
>> >
>> > Eric added a ctx->Driver.BindRenderbufferTexImage hook which takes a
>> > (non-texture) renderbuffer and wraps it in a fake texture image.
>> >
>> > We use this in Meta's BlitFramebuffer implementation to be able to blit
>> > from non-texture renderbuffers.  i965 also has a custom meta blit path
>> > for stencil, which uses the same approach.  Thus, stencil textures :)
>>
>> None of which has to do with ARB_stencil_texturing being enabled as
>> far as mesa/main is concerned, right? IOW, why is that condition
>> there?
>
>
> Well, the blit path does require it because it requires us to be able to
> sample from stencil.  Why does it require the internal format?  That's
> another question.

Right... so I totally believe you that this is necessary to not crash
your driver :) I'm just questioning whether this is the right fix, or
the right condition, or whatever. If I understand correctly, it will
happily let me create a GL_STENCIL_INDEX texture even though that's
not allowed without ARB_texture_stencil8. A driver which enables
ARB_stencil_texturing (like st/mesa) will probably become confused at
this and fail.

Someone already added a ARB_texture_stencil8 bool to gl_extensions
even though the extension is not fully-enableable... perhaps it was
for this? Or perhaps there should be a driver-specific hook to the
base function which enables this sort of logic. Or some other
solution.

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


Re: [Mesa-dev] replace __FUNCTION__ with __func__ task

2015-03-03 Thread Jose Fonseca

On 03/03/15 20:56, Jan Vesely wrote:

On Tue, 2015-03-03 at 10:07 -0700, Brian Paul wrote:

On 03/03/2015 09:56 AM, Jose Fonseca wrote:

On 03/03/15 15:57, Brian Paul wrote:

We're using both of these in Mesa/gallium.  It would be nice to
consistently just use C99's __func__ everywhere.  This would be any easy
task for someone looking for something simple to do.

We could then get rid of this (broken) chunk seen in both compiler.h and
p_compiler.h:

#ifndef __FUNCTION__
#  define __FUNCTION__ __func__
#endif


Sounds good to me.  Note that MSVC doesn't support __func__, only
__FUNCTION__, so we need to ensure that c99_compat.h gets included
everywhere.


Right.  That should already be the case since it's included by
src/mesa/main/compiler.h which gets included almost everywhere already.


would it make sense to add -imacros/-include cmdline options for these
headers?
I have no idea whether these are supported by other compilers (at least
-include is supported by clang)

jan


Yes, that's a thought.

MSVC has the /FI.h option.  We could  indeed pass it universally 
to ensure __func__/inline and friends are always there.  But if 
c99_compat.h is already included everywhere, that's fine too.



BTW, looking at MSVC 14..2015 notes [1], it will:

- support __func__.
- support snprintf (instead of _snprintf)

Unfortunately, not much more C99/C11 support.

Jose

[1] http://support.microsoft.com/kb/2967191


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


Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Jose Fonseca

On 03/03/15 18:39, Emil Velikov wrote:

On 3 March 2015 at 17:16, Jose Fonseca  wrote:
...


I've prototyped this in

   
https://urldefense.proofpoint.com/v2/url?u=http-3A__cgit.freedesktop.org_-7Ejrfonseca_mesa_log_-3Fh-3Dremove-2Dst-2Degl&d=AwIBaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=DBmTkQmzY89vDw_KLOol0FBhKxmBTyqNfsx_ly5H-ZU&s=zhIQc271rsRkCQHGsaFYKm3SFwRTGWAib63t3Fjdhyo&e=

The changes are massive, so I'm not sure it's even worth spamming the list
with them.

Could you please give a look and let me know if there are any concerns?


I've spotted a few trivial bits:

>

  - windows/gdi: Remove.
Drop drivers/windows from src/mesa/Makefile.am:EXTRA_DIST
The driver had interesting api/wrapper similar to osmesa. Did not know that :-)

-  st/egl: Remove.
Update the src/egl/main/Sconscript to create a SharedLibrary, add
versioning, create symlink - copy the bits from egl-static.



Drop st/egl and targets/egl-static from src/gallium/Makefile.am:EXTRA_DIST



Remove the _EGL_BUILT_IN_DRIVER_GALLIUM define from src/egl/main/Android.mk.
  - st/vega: Remove.
A few "openvg" references left - one in configure.ac another one in
docs/contents.html


Thanks. I pushed a new version of the branch with all issues fixed.





The only snafu is Android.mk -- it will be broken with gallium drivers until
somebody familiar with that infrastructure updates it to use egl_dri2. But
it should build fine without gallium drivers.


The Android build is mostly limping around mesa 10.4. I've pinged the
Android-x86 guys, but but might get to it soon(ish). Don't worry too
much about it.

I'm guessing that the scons and automake build do not point out
anything unusual ?


Right. automake, scons/linux and scons/windows all build happily. Of 
course, automake has many options, and I only tested one (with dri and 
gallium sw rasterizers).


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


Re: [Mesa-dev] [PATCH] [RFC] egl: propose simple EGL_MESA_image_dma_buf_export v2.2

2015-03-03 Thread Dave Airlie
On 4 March 2015 at 05:23, Chad Versace  wrote:
> On 03/03/2015 11:13 AM, Dave Airlie wrote:
>> On 4 March 2015 at 05:06, Chad Versace  wrote:
>>> On 03/03/2015 11:01 AM, Daniel Stone wrote:
 Hi,

 On 3 March 2015 at 18:40, Chad Versace  wrote:
> On 03/03/2015 12:13 AM, Daniel Stone wrote:
>> On Tuesday, March 3, 2015, Dave Airlie > > wrote:
>> +EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
>> +  EGLImageKHR image,
>> + int *fourcc,
>> + int *num_planes);
>>
>>
>> Shouldn't this contain the modifier(s) as well?
>
> What is the motivation for defining two export calls, and exporting
> a subset of information from each call? I don't understand why the
> fourcc values are exported by one call, but the strides exported a
> separate call.

 Querying the image gives you what you need in order to know if you can
 actually deal with the image, before you go to all the effort of
 exporting it.
>>>
>>> Thanks. That makes sense.
>>
>> Also you need the number of planes to correctly size the arrays for
>> the second call to put the results into.
>
> Right, I understood that you needed to know the number of planes before
> submitting the array. I was mostly confused by why fourcc was in this call,
> not num_planes.
>
> My real feedback: It's probably best to rename num_planes to num_fds,
> because you're not guaranteed num_fds != num_planes for interleaved formats.
> And, using the name 'num_fds' allows us to avoid awkwardness if we need to
> create future layered extensions
> that export auxilliary buffers that may not correspond YUV planes. (There's
> been a lot of lunch talk about exporting aux buffers at Intel).


But num_planes sizes fds, strides and offsets, which seems like
we should either just return the same fd for each plane or one fd in slot0
and -1, -1 in the others if we need one fd per multi-planar..

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


Re: [Mesa-dev] egl dma-buf export extension again

2015-03-03 Thread Kristian Høgsberg
On Tue, Mar 3, 2015 at 10:43 AM, Chad Versace  wrote:
> On 03/02/2015 09:36 PM, Dave Airlie wrote:
>> On 3 March 2015 at 13:57, Dave Airlie  wrote:
>>>
>>> Okay I've revised this to add some more info to the interface,
>>> essentially I need to get the fourcc back so I can later pass
>>> it across the "wire" to the EGL_EXT_image_dma_buf_import, also
>>> the number of planes (though for my usecase I don't care so much).
>>>
>>> The problem with EGL_MESA_drm_image is that I've no idea how to retrieve
>>> the internal format of an image so I know what to tell the other side,
>>> since I just create a normal 2D texture and want to export it,
>>> I need to know what format mesa internally picked for it. This works
>>> out the fourcc and returns it.
>>>
>>
>> While talking to krh on irc he mentioned that maybe I should skip egl images
>>
>> and go straight to the texture id->dma-buf extension,
>>
>> again any opinions from anyone in the area would be useful.
>
> Please use EGLImages as the import/export object. That provides
> consistency with existing similar EGL APIs. And it allows a clean
> separation between EGL-aware code and GL-aware code in applications
> and compositors.
>
> For what it's worth, extensions in this area being developed by Google's
> Chrome OS team also use EGLImages as the transport object.

We can't both implement EGLImages in a compliant way *and* use them
for cross-process sharing like we do.  The spec language around
orphaning and siblings is obscure, but the idea is that whenever you
add a sibling (another client API object, eg a texture or a vg
renderbuffer) the contents become invalid.  The intended use case is
that you create all siblings up front and then start using them.  For
example, to share an image between VG and GL, you create the VG
buffer, then the EGLImage and then the GL texture.  Implementations
will defer allocation until all the siblings are set up and then only
once you start rendering allocate the memory.  This allows the
implementation to accommodate constraints from all siblings. If you
add another sibling, the implementation may have to reallocate storage
to satisfy new constraints.  This clearly isn't compatible with how we
create and share EGLImages left and right across process boundaries.
Khronos specifically developed EGLStreams as a cross-process color
buffer sharing mechanism without pulling in EGLImage as a dependency.

Anyway, the damage is done and we can continue digging ourselves
deeper into this hole, but we should at least 1) have a good reason
why the extra EGLImage indirection is necessary (it also rules out GLX
usage) and 2) acknowledge that we're going to continue to rely on our
broken EGLImage semantics.

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


[Mesa-dev] [PATCH] [RFC] egl: propose simple EGL_MESA_image_dma_buf_export v2.3

2015-03-03 Thread Dave Airlie
From: Dave Airlie 

At the moment to get an EGL image to a dma-buf file descriptor,
you have to use EGL_MESA_drm_image, and then use libdrm to
convert this to a file descriptor.

This extension just provides an API modelled on EGL_MESA_drm_image,
to return a dma-buf file descriptor.

v2: update spec for new API proposal
add internal queries to get the fourcc back from intel driver.

v2.1: add gallium pieces.

v2.2: add offsets to spec and API, rename fd->fds, stride->strides
in API. rewrite spec a bit more, add some q/a

v2.3:
add modifiers to query interface and 64-bit type for that (Daniel Stone)
specifiy what happens to num fds vs num planes differences. (Chad Versace)

Signed-off-by: Dave Airlie 
---
 docs/specs/MESA_image_dma_buf_export.txt | 142 +++
 include/EGL/eglmesaext.h |   8 ++
 include/GL/internal/dri_interface.h  |   4 +-
 src/egl/drivers/dri2/egl_dri2.c  |  59 -
 src/egl/main/eglapi.c|  48 +++
 src/egl/main/eglapi.h|  10 +++
 src/egl/main/egldisplay.h|   2 +
 src/egl/main/eglfallbacks.c  |   5 ++
 src/egl/main/eglmisc.c   |   2 +
 src/gallium/state_trackers/dri/dri2.c|  32 ++-
 src/mesa/drivers/dri/i965/intel_screen.c |  25 +-
 11 files changed, 332 insertions(+), 5 deletions(-)
 create mode 100644 docs/specs/MESA_image_dma_buf_export.txt

diff --git a/docs/specs/MESA_image_dma_buf_export.txt 
b/docs/specs/MESA_image_dma_buf_export.txt
new file mode 100644
index 000..1824cdb
--- /dev/null
+++ b/docs/specs/MESA_image_dma_buf_export.txt
@@ -0,0 +1,142 @@
+Name
+
+MESA_image_dma_buf_export
+
+Name Strings
+
+EGL_MESA_image_dma_buf_export
+
+Contributors
+
+Dave Airlie
+
+Contact
+
+Dave Airlie (airlied 'at' redhat 'dot' com)
+
+Status
+
+Proposal
+
+Version
+
+Version 2
+
+Number
+
+ 
+
+Dependencies
+
+Reguires EGL 1.4 or later.  This extension is written against the
+wording of the EGL 1.4 specification.
+
+EGL_KHR_base_image is required.
+
+The EGL implementation must be running on a Linux kernel supported the
+dma_buf buffer sharing mechanism.
+
+Overview
+
+This extension provides entry points for integrating EGLImage with the
+dma-buf infrastructure.  The extension allows creating a Linux dma_buf
+file descriptor or multiple file descriptors, in the case of multi-plane
+YUV image, from an EGLImage.
+
+It is designed to provide the opposing functionality to 
EGL_EXT_image_dma_buf_import.
+
+IP Status
+
+Open-source; freely implementable.
+
+New Types
+
+This is a 64 bit unsigned integer.
+
+typedef khronos_uint64_t EGLuint64MESA;
+
+
+New Procedures and Functions
+
+EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
+  EGLImageKHR image,
+ int *fourcc,
+ int *num_planes,
+ EGLuint64MESA *modifiers);
+
+EGLBoolean eglExportDMABUFImageMESA(EGLDisplay dpy,
+EGLImageKHR image,
+int *fds,
+   EGLint *strides,
+   EGLint *offsets);
+
+New Tokens
+
+None
+
+
+Additions to the EGL 1.4 Specification:
+
+To mirror the import extension, this extension attempts to return
+enough information to enable an exported dma-buf to be imported
+via eglCreateImageKHR and EGL_LINUX_DMA_BUF_EXT token.
+
+Retrieving the information is a two step process, so two APIs
+are required.
+
+The first entrypoint
+   EGLBoolean eglExportDMABUFImageQueryMESA(EGLDisplay dpy,
+  EGLImageKHR image,
+ int *fourcc,
+ int *num_planes,
+ EGLuint64MESA *modifiers);
+
+is used to retrieve the pixel format of the buffer, as specified by
+drm_fourcc.h, the number of planes in the image and the Linux
+drm modifiers. ,  and  may be NULL,
+in which case no value is retrieved.
+
+The second entrypoint retrieves the dma_buf file descriptors,
+strides and offsets for the image. The caller should pass
+arrays sized according to the num_planes values retrieved previously.
+Passing arrays of the wrong size will have undefined results.
+If the number of fds is less than the number of planes, then
+subsequence fd slots should contain -1.
+
+EGLBoolean eglExportDMABUFImageMESA(EGLDisplay dpy,
+ EGLImageKHR image,
+int *fds,
+ EGLint *strides,
+ EGLint *offsets);
+
+, ,  can be NULL if the infomatation isn't
+required by the caller.
+
+Issues

[Mesa-dev] [PATCH 2/2] r300g: Check return value of snprintf().

2015-03-03 Thread Matt Turner
Would have at least prevented the crash the previous patch fixed.

Cc: 10.4, 10.5 
Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970
---
 src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c 
b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
index 422bdb0..04c01f1 100644
--- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
+++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
@@ -541,9 +541,14 @@ unsigned load_program(
unsigned *count;
char **string_store;
unsigned i = 0;
+   int n;
 
memset(line, 0, sizeof(line));
-   snprintf(path, PATH_MAX, TEST_PATH "/%s", filename);
+   n = snprintf(path, PATH_MAX, TEST_PATH "/%s", filename);
+   if (n < 0 || n >= PATH_MAX) {
+   return 0;
+   }
+
file = fopen(path, "r");
if (!file) {
return 0;
-- 
2.0.5

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


[Mesa-dev] [PATCH 1/2] r300g: Use PATH_MAX instead of limiting ourselves to 100 chars.

2015-03-03 Thread Matt Turner
When built with Gentoo's package manager, the Mesa source directory
exists seven directories deep. The path to the .test file is too long
and is silently truncated, leading to a crash. Just use PATH_MAX.

Cc: 10.4, 10.5 
Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970
---
 src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c 
b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
index 7c9d177..422bdb0 100644
--- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
+++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
@@ -28,6 +28,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -528,7 +529,6 @@ void init_compiler(
 }
 
 #define MAX_LINE_LENGTH 100
-#define MAX_PATH_LENGTH 100
 
 unsigned load_program(
struct radeon_compiler *c,
@@ -536,14 +536,14 @@ unsigned load_program(
const char *filename)
 {
char line[MAX_LINE_LENGTH];
-   char path[MAX_PATH_LENGTH];
+   char path[PATH_MAX];
FILE *file;
unsigned *count;
char **string_store;
unsigned i = 0;
 
memset(line, 0, sizeof(line));
-   snprintf(path, MAX_PATH_LENGTH, TEST_PATH "/%s", filename);
+   snprintf(path, PATH_MAX, TEST_PATH "/%s", filename);
file = fopen(path, "r");
if (!file) {
return 0;
-- 
2.0.5

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


Re: [Mesa-dev] [PATCH 2/3] i965/fs: Consider cmod when propagating to inst with different type.

2015-03-03 Thread Kenneth Graunke
On Friday, February 27, 2015 11:34:06 AM Matt Turner wrote:
> We can safely propagate the conditional mod to an instruction with a
> different type if the conditional mod does not involve comparing for
> equality with zero (or probably NaN, but ignore that for now).
> 
> This is because -0.0 and +0.0 are both test equal to zero, but their
> integer representations do not.
> 
> Cc: 10.5 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89317
> ---
>  .../drivers/dri/i965/brw_fs_cmod_propagation.cpp   |  8 +++
>  .../drivers/dri/i965/test_fs_cmod_propagation.cpp  | 67 
> ++
>  2 files changed, 75 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp
> index c6384ab..a92eef6 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp
> @@ -80,6 +80,14 @@ opt_cmod_propagation_local(fs_visitor *v, bblock_t *block)
>  scan_inst->dst.reg_offset != inst->src[0].reg_offset)
> break;
>  
> +/* Testing equality with zero is different for ints and floats */
> +if (scan_inst->dst.type != inst->dst.type &&
> +(inst->conditional_mod == BRW_CONDITIONAL_Z ||
> + inst->conditional_mod == BRW_CONDITIONAL_NZ ||
> + inst->conditional_mod == BRW_CONDITIONAL_GE ||
> + inst->conditional_mod == BRW_CONDITIONAL_LE))
> +   break;
> +
>  /* If the instruction generating inst's source also wrote the
>   * flag, and inst is doing a simple .nz comparison, then inst
>   * is redundant - the appropriate value is already in the flag
> diff --git a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp 
> b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
> index fbe4fd9..0287161 100644
> --- a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
> +++ b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
> @@ -415,3 +415,70 @@ TEST_F(cmod_propagation_test, movnz)
> EXPECT_EQ(BRW_OPCODE_CMP, instruction(block0, 0)->opcode);
> EXPECT_EQ(BRW_CONDITIONAL_GE, instruction(block0, 0)->conditional_mod);
>  }
> +
> +TEST_F(cmod_propagation_test, different_types)
> +{
> +   fs_reg dest = v->vgrf(glsl_type::int_type);
> +   fs_reg src0 = v->vgrf(glsl_type::int_type);
> +   fs_reg src1 = v->vgrf(glsl_type::int_type);
> +   fs_reg zero(0.0f);
> +   v->emit(BRW_OPCODE_ADD, dest, src0, src1);
> +   v->emit(BRW_OPCODE_CMP, v->reg_null_f, retype(dest, BRW_REGISTER_TYPE_F),
> +  zero)
> +  ->conditional_mod = BRW_CONDITIONAL_G;
> +
> +   /* = Before =
> +*
> +* 0: add(8)dest:D  src0:D  src1:D
> +* 1: cmp.g.f0(8)   null:F  dest:F  0.0f
> +*
> +* = After =
> +* 0: add.g.f0(8)   dest:D  src0:D  src1:D
> +*/

This is wrong - you're adding two integers and doing an integer compare
with 0, rather than a float comparison.

I verified that in C, (-0.0 > 0.0) == false.  I then modified your
Piglit test to be:

if (uintBitsToFloat(a + b) > 0.0)
frag_color = vec4(1.0, 0.0, 0.0, 1.0);
else
frag_color = vec4(0.0, 1.0, 0.0, 1.0);

(> instead of ==, swap red/green).

This fails with your code, because it ends up doing:
  0x8000 > 0x0
   => 0x8000 - 0x0 > 0x0.
   => 0x8000 > 0
   => True

It passes if you eliminate the conditional_mod checks and just do:

   if (scan_inst->dst.type != inst->dst.type)
  break;

Assuming you make that change, and drop/fix this unit test, you can put
my R-b on it.  Good find :)

> +
> +   v->calculate_cfg();
> +   bblock_t *block0 = v->cfg->blocks[0];
> +
> +   EXPECT_EQ(0, block0->start_ip);
> +   EXPECT_EQ(1, block0->end_ip);
> +
> +   EXPECT_TRUE(cmod_propagation(v));
> +   EXPECT_EQ(0, block0->start_ip);
> +   EXPECT_EQ(0, block0->end_ip);
> +   EXPECT_EQ(BRW_OPCODE_ADD, instruction(block0, 0)->opcode);
> +   EXPECT_EQ(BRW_CONDITIONAL_G, instruction(block0, 0)->conditional_mod);
> +}
> +
> +TEST_F(cmod_propagation_test, different_types_cmod_with_zero)
> +{
> +   fs_reg dest = v->vgrf(glsl_type::int_type);
> +   fs_reg src0 = v->vgrf(glsl_type::int_type);
> +   fs_reg src1 = v->vgrf(glsl_type::int_type);
> +   fs_reg zero(0.0f);
> +   v->emit(BRW_OPCODE_ADD, dest, src0, src1);
> +   v->emit(BRW_OPCODE_CMP, v->reg_null_f, retype(dest, BRW_REGISTER_TYPE_F),
> +  zero)
> +  ->conditional_mod = BRW_CONDITIONAL_GE;
> +
> +   /* = Before =
> +*
> +* 0: add(8)dest:D  src0:D  src1:D
> +* 1: cmp.ge.f0(8)  null:F  dest:F  0.0f
> +*
> +* = After =
> +* (no changes)
> +*/
> +
> +   v->calculate_cfg();
> +   bblock_t *block0 = v->cfg->blocks[0];
> +
> +   EXPECT_EQ(0, block0->start_ip);
> +   EXPECT_EQ(1, block0->end_ip);
> +
> +   EXPECT_FALSE(cmod_propagati

Re: [Mesa-dev] [PATCH 1/6] main: Check for NULL in texturesubimage.

2015-03-03 Thread Anuj Phogat
On Fri, Feb 27, 2015 at 4:07 PM, Laura Ekstrand  wrote:
> ---
>  src/mesa/main/teximage.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 6e45cc9..dfad9ed 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -3688,6 +3688,8 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
>/* Copy in each face. */
>for (i = 0; i < 6; ++i) {
>   texImage = texObj->Image[i][level];
> + if (!texImage)
> +return;
This check is already done in _mesa_cube_level_complete(), failing which
causes invalid operation before returning. I think you should add
assert(texImage) here.

>   _mesa_texture_sub_image(ctx, 3, texObj, texImage, texObj->Target,
>   level, xoffset, yoffset, zoffset,
>   width, height, 1, format,
> --
> 2.1.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/6] main: Check for NULL in texturesubimage.

2015-03-03 Thread Anuj Phogat
On Tue, Mar 3, 2015 at 4:15 PM, Anuj Phogat  wrote:
> On Fri, Feb 27, 2015 at 4:07 PM, Laura Ekstrand  wrote:
>> ---
>>  src/mesa/main/teximage.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
>> index 6e45cc9..dfad9ed 100644
>> --- a/src/mesa/main/teximage.c
>> +++ b/src/mesa/main/teximage.c
>> @@ -3688,6 +3688,8 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
>>/* Copy in each face. */
>>for (i = 0; i < 6; ++i) {
>>   texImage = texObj->Image[i][level];
>> + if (!texImage)
>> +return;
> This check is already done in _mesa_cube_level_complete(), failing which
> causes invalid operation before returning. I think you should add
> assert(texImage) here.
>
and in the else { } block.
>>   _mesa_texture_sub_image(ctx, 3, texObj, texImage, texObj->Target,
>>   level, xoffset, yoffset, zoffset,
>>   width, height, 1, format,
>> --
>> 2.1.0
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] r300g: Use PATH_MAX instead of limiting ourselves to 100 chars.

2015-03-03 Thread Tom Stellard
On Tue, Mar 03, 2015 at 04:12:56PM -0800, Matt Turner wrote:
> When built with Gentoo's package manager, the Mesa source directory
> exists seven directories deep. The path to the .test file is too long
> and is silently truncated, leading to a crash. Just use PATH_MAX.
> 
> Cc: 10.4, 10.5 
> Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970

Both patches:

Reviewed-by: Tom Stellard 

Thanks!

> ---
>  src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c 
> b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
> index 7c9d177..422bdb0 100644
> --- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
> +++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
> @@ -28,6 +28,7 @@
>   */
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -528,7 +529,6 @@ void init_compiler(
>  }
>  
>  #define MAX_LINE_LENGTH 100
> -#define MAX_PATH_LENGTH 100
>  
>  unsigned load_program(
>   struct radeon_compiler *c,
> @@ -536,14 +536,14 @@ unsigned load_program(
>   const char *filename)
>  {
>   char line[MAX_LINE_LENGTH];
> - char path[MAX_PATH_LENGTH];
> + char path[PATH_MAX];
>   FILE *file;
>   unsigned *count;
>   char **string_store;
>   unsigned i = 0;
>  
>   memset(line, 0, sizeof(line));
> - snprintf(path, MAX_PATH_LENGTH, TEST_PATH "/%s", filename);
> + snprintf(path, PATH_MAX, TEST_PATH "/%s", filename);
>   file = fopen(path, "r");
>   if (!file) {
>   return 0;
> -- 
> 2.0.5
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/6] main: Add TEXTURE_CUBE_MAP support for glCompressedTextureSubImage3D.

2015-03-03 Thread Anuj Phogat
On Fri, Feb 27, 2015 at 4:07 PM, Laura Ekstrand  wrote:
> ---
>  src/mesa/main/teximage.c | 204 
> ---
>  src/mesa/main/teximage.h |   3 +-
>  2 files changed, 179 insertions(+), 28 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index dfad9ed..d454dd9 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -4747,30 +4747,19 @@ _mesa_CompressedTexImage3D(GLenum target, GLint level,
>  void
>  _mesa_compressed_texture_sub_image(struct gl_context *ctx, GLuint dims,
> struct gl_texture_object *texObj,
> +   struct gl_texture_image *texImage,
> GLenum target, GLint level,
> GLint xoffset, GLint yoffset,
> GLint zoffset,
> GLsizei width, GLsizei height,
> GLsizei depth,
> GLenum format, GLsizei imageSize,
> -   const GLvoid *data, bool dsa)
> +   const GLvoid *data)
>  {
> -   struct gl_texture_image *texImage;
> -
> -   if (compressed_subtexture_error_check(ctx, dims, texObj, target,
> - level, xoffset, yoffset, zoffset,
> - width, height, depth,
> - format, imageSize, dsa)) {
> -  return;
> -   }
> -
> FLUSH_VERTICES(ctx, 0);
>
> _mesa_lock_texture(ctx, texObj);
> {
> -  texImage = _mesa_select_tex_image(texObj, target, level);
> -  assert(texImage);
> -
>if (width > 0 && height > 0 && depth > 0) {
>   ctx->Driver.CompressedTexSubImage(ctx, dims, texImage,
> xoffset, yoffset, zoffset,
> @@ -4794,6 +4783,8 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint 
> level, GLint xoffset,
>GLsizei imageSize, const GLvoid *data)
>  {
> struct gl_texture_object *texObj;
> +   struct gl_texture_image *texImage;
> +
> GET_CURRENT_CONTEXT(ctx);
>
> if (compressed_subtexture_target_check(ctx, target, 1, format, false,
> @@ -4805,9 +4796,20 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint 
> level, GLint xoffset,
> if (!texObj)
>return;
>
> -   _mesa_compressed_texture_sub_image(ctx, 1, texObj, target, level,
> +   if (compressed_subtexture_error_check(ctx, 1, texObj, target,
> + level, xoffset, 0, 0,
> + width, 1, 1,
> + format, imageSize, false)) {
> +  return;
> +   }
> +
> +   texImage = _mesa_select_tex_image(texObj, target, level);
> +   if (!texImage)
> +  return;
> +
compressed_subtexture_error_check() already does this check. Instead add
assert(texImage) here and all other places in this patch. Otherwise patch looks
good to me.

> +   _mesa_compressed_texture_sub_image(ctx, 1, texObj, texImage, target, 
> level,
>xoffset, 0, 0, width, 1, 1,
> -  format, imageSize, data, false);
> +  format, imageSize, data);
>  }
>
>  void GLAPIENTRY
> @@ -4816,6 +4818,8 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint 
> level, GLint xoffset,
>GLsizei imageSize, const GLvoid *data)
>  {
> struct gl_texture_object *texObj;
> +   struct gl_texture_image *texImage;
> +
> GET_CURRENT_CONTEXT(ctx);
>
> texObj = _mesa_lookup_texture_err(ctx, texture,
> @@ -4829,9 +4833,21 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, 
> GLint level, GLint xoffset,
>return;
> }
>
> -   _mesa_compressed_texture_sub_image(ctx, 1, texObj, texObj->Target, level,
> +   if (compressed_subtexture_error_check(ctx, 1, texObj, texObj->Target,
> + level, xoffset, 0, 0,
> + width, 1, 1,
> + format, imageSize, true)) {
> +  return;
> +   }
> +
> +   texImage = _mesa_select_tex_image(texObj, texObj->Target, level);
> +   if (!texImage)
> +  return;
> +
> +   _mesa_compressed_texture_sub_image(ctx, 1, texObj, texImage,
> +  texObj->Target, level,
>xoffset, 0, 0, width, 1, 1,
> -  format, imageSize, data, true);
> +  format, imageSize, data);
>  }
>
>
> @@ -4842,6 +4858,8 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint 
> level, GLint xoffset,
>const GLvoid *data)
>  {
> struct gl_texture_object *texObj;
> +   struct gl_texture_image *texImage;

Re: [Mesa-dev] RFC: Prune stale components

2015-03-03 Thread Emil Velikov
On 03/03/15 22:04, Jose Fonseca wrote:
> On 03/03/15 18:39, Emil Velikov wrote:
>> On 3 March 2015 at 17:16, Jose Fonseca  wrote:
>> ...
>>>
>>> I've prototyped this in
>>>
>>>   
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__cgit.freedesktop.org_-7Ejrfonseca_mesa_log_-3Fh-3Dremove-2Dst-2Degl&d=AwIBaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=DBmTkQmzY89vDw_KLOol0FBhKxmBTyqNfsx_ly5H-ZU&s=zhIQc271rsRkCQHGsaFYKm3SFwRTGWAib63t3Fjdhyo&e=
>>>
>>>
>>> The changes are massive, so I'm not sure it's even worth spamming the
>>> list
>>> with them.
>>>
>>> Could you please give a look and let me know if there are any concerns?
>>>
>> I've spotted a few trivial bits:
>>
>>   - windows/gdi: Remove.
>> Drop drivers/windows from src/mesa/Makefile.am:EXTRA_DIST
>> The driver had interesting api/wrapper similar to osmesa. Did not know
>> that :-)
>>
>> -  st/egl: Remove.
>> Update the src/egl/main/Sconscript to create a SharedLibrary, add
>> versioning, create symlink - copy the bits from egl-static.
> 
>> Drop st/egl and targets/egl-static from
>> src/gallium/Makefile.am:EXTRA_DIST
> 
>> Remove the _EGL_BUILT_IN_DRIVER_GALLIUM define from
>> src/egl/main/Android.mk.
>>   - st/vega: Remove.
>> A few "openvg" references left - one in configure.ac another one in
>> docs/contents.html
> 
> Thanks. I pushed a new version of the branch with all issues fixed.
> 
I'm guessing you made a typo in src/egl/main/SConscript

+egl = env.InstallSharedLibrary(egl, version=(1, 0, 0))

Shouldn't the version be 1.4 ?

> 
>>
>>> The only snafu is Android.mk -- it will be broken with gallium
>>> drivers until
>>> somebody familiar with that infrastructure updates it to use
>>> egl_dri2. But
>>> it should build fine without gallium drivers.
>>>
>> The Android build is mostly limping around mesa 10.4. I've pinged the
>> Android-x86 guys, but but might get to it soon(ish). Don't worry too
>> much about it.
>>
>> I'm guessing that the scons and automake build do not point out
>> anything unusual ?
> 
> Right. automake, scons/linux and scons/windows all build happily. Of
> course, automake has many options, and I only tested one (with dri and
> gallium sw rasterizers).
> 
These components are rather nicely isolated, so it should not matter
that much.

I'm suspecting that scons does not link against all libs for libEGL.
Adding -Wl,--no-undefined/-Wl,-z,defs to SHLINKFLAGS should clear it up,
yet feel free to do it as a follow up. I would highly recommend adding
it (-Wl...) for every SharedLibrary in scons. Using the version scripts
like autotools, to restrict the exported symbols, will be great.

With the versioning question addressed, feel free to add
Reviewed-by: Emil Velikov 

Please drop a couple of lines in the release notes, when you're finished
removing all the old/unused bits.


-Emil

P.S. Strange. After spending so much time fixing the builds, it feels so
nice as various chunks of it end up removed :-P

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


Re: [Mesa-dev] [PATCH 3/6] main: Checking for cube completeness in GetCompressedTextureImage.

2015-03-03 Thread Anuj Phogat
On Fri, Feb 27, 2015 at 4:07 PM, Laura Ekstrand  wrote:
> ---
>  src/mesa/main/texgetimage.c | 51 
> -
>  1 file changed, 50 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
> index 24df5b6..327a397 100644
> --- a/src/mesa/main/texgetimage.c
> +++ b/src/mesa/main/texgetimage.c
> @@ -1339,7 +1339,56 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint 
> level,
>
> /* Must handle special case GL_TEXTURE_CUBE_MAP. */
> if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
> -  assert(texObj->NumLayers >= 6);
> +
> +  /* Error checking */
> +  if (texObj->NumLayers < 6) {
> + /* Not enough image planes for a cube map.  The spec does not say
> +  * what should happen in this case because the user has always
> +  * specified each cube face separately (using
> +  * GL_TEXTURE_CUBE_MAP_POSITIVE_X+i) in previous GL versions.
> +  * This is addressed in Khronos Bug 13223.
> +  */
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "glGetCompressedTextureImage("
> + "insufficient cube map storage)");
> + return;
> +  }
> +
> +  /*
> +   * What do we do if the user created a texture with the following code
> +   * and then called this function with its handle?
> +   *
> +   *GLuint tex;
> +   *glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &tex);
> +   *glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
> +   *glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, ...);
> +   *glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, ...);
> +   *glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, ...);
> +   *// Note: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y not set, or given the
> +   *// wrong format, or given the wrong size, etc.
> +   *glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, ...);
> +   *glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, ...);
> +   *
> +   * A bug has been filed against the spec for this case.  In the
> +   * meantime, we will check for cube completeness.
> +   *
> +   * According to Section 8.17 Texture Completeness in the OpenGL 4.5
> +   * Core Profile spec (30.10.2014):
> +   *"[A] cube map texture is cube complete if the
> +   *following conditions all hold true: The [base level] texture
> +   *images of each of the six cube map faces have identical, 
> positive,
> +   *and square dimensions. The [base level] images were each 
> specified
> +   *with the same internal format."
> +   *
> +   * It seems reasonable to check for cube completeness of an arbitrary
> +   * level here so that the returned data has a consistent format and 
> size
> +   * and therefore fits in the user's buffer.
> +   */
Above comment already exist in two files teximage.c and texgetimage.c.  Point to
the existing one instead of duplicating at more places. Better would be to move
the existing comments to above _mesa_cube_level_complete() definition. This
comment also applies to Patch 2/6.

> +  if (!_mesa_cube_level_complete(texObj, level)) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "glGetCompressedTextureImage(cube map incomplete)");
> + return;
> +  }
>
>/* Copy each face. */
>for (i = 0; i < 6; ++i) {
> --
> 2.1.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/6] main: Add utility function _mesa_lookup_bufferobj_err.

2015-03-03 Thread Anuj Phogat
On Fri, Feb 27, 2015 at 4:07 PM, Laura Ekstrand  wrote:
> ---
>  src/mesa/main/bufferobj.c | 19 +++
>  src/mesa/main/bufferobj.h |  4 
>  2 files changed, 23 insertions(+)
>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index f026fc3..617242b 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -1006,6 +1006,25 @@ _mesa_lookup_bufferobj_locked(struct gl_context *ctx, 
> GLuint buffer)
>_mesa_HashLookupLocked(ctx->Shared->BufferObjects, buffer);
>  }
>
> +/**
> + * A convenience function for direct state access functions that throws
> + * GL_INVALID_OPERATION if buffer is not the name of a buffer object in the
> + * hash table.
> + */
> +struct gl_buffer_object *
> +_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
> +   const char *caller)
> +{
> +   struct gl_buffer_object *bufObj;
> +
> +   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
> +   if (!bufObj)
> +  _mesa_error(ctx, GL_INVALID_OPERATION,
> +  "%s(non-generated buffer name %u)", caller, buffer);
> +
> +   return bufObj;
> +}
> +
>
>  void
>  _mesa_begin_bufferobj_lookups(struct gl_context *ctx)
> diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
> index fe294fc..8e53bfd 100644
> --- a/src/mesa/main/bufferobj.h
> +++ b/src/mesa/main/bufferobj.h
> @@ -89,6 +89,10 @@ _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint 
> buffer);
>  extern struct gl_buffer_object *
>  _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer);
>
> +extern struct gl_buffer_object *
> +_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
> +   const char *caller);
> +
This function is used just inside teximage.c in patch 5/6. So, it can be made
static.

>  extern void
>  _mesa_begin_bufferobj_lookups(struct gl_context *ctx);
>
> --
> 2.1.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/6] main: Add utility function _mesa_lookup_bufferobj_err.

2015-03-03 Thread Fredrik Höglund
On Wednesday 04 March 2015, Anuj Phogat wrote:
> On Fri, Feb 27, 2015 at 4:07 PM, Laura Ekstrand  wrote:
> > ---
> >  src/mesa/main/bufferobj.c | 19 +++
> >  src/mesa/main/bufferobj.h |  4 
> >  2 files changed, 23 insertions(+)
> >
> > diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> > index f026fc3..617242b 100644
> > --- a/src/mesa/main/bufferobj.c
> > +++ b/src/mesa/main/bufferobj.c
> > @@ -1006,6 +1006,25 @@ _mesa_lookup_bufferobj_locked(struct gl_context 
> > *ctx, GLuint buffer)
> >_mesa_HashLookupLocked(ctx->Shared->BufferObjects, buffer);
> >  }
> >
> > +/**
> > + * A convenience function for direct state access functions that throws
> > + * GL_INVALID_OPERATION if buffer is not the name of a buffer object in the
> > + * hash table.
> > + */
> > +struct gl_buffer_object *
> > +_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
> > +   const char *caller)
> > +{
> > +   struct gl_buffer_object *bufObj;
> > +
> > +   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
> > +   if (!bufObj)
> > +  _mesa_error(ctx, GL_INVALID_OPERATION,
> > +  "%s(non-generated buffer name %u)", caller, buffer);
> > +
> > +   return bufObj;
> > +}
> > +
> >
> >  void
> >  _mesa_begin_bufferobj_lookups(struct gl_context *ctx)
> > diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
> > index fe294fc..8e53bfd 100644
> > --- a/src/mesa/main/bufferobj.h
> > +++ b/src/mesa/main/bufferobj.h
> > @@ -89,6 +89,10 @@ _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint 
> > buffer);
> >  extern struct gl_buffer_object *
> >  _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer);
> >
> > +extern struct gl_buffer_object *
> > +_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
> > +   const char *caller);
> > +
> This function is used just inside teximage.c in patch 5/6. So, it can be made
> static.

No, I'm using it in arrayobj.c in my arb-direct-state-access branch.

> >  extern void
> >  _mesa_begin_bufferobj_lookups(struct gl_context *ctx);
> >
> > --
> > 2.1.0
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 

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


[Mesa-dev] [PATCH] i965/fs: Use unsigned for CS/VS atomics pixel mask immediate data

2015-03-03 Thread Jordan Justen
brw_imm_ud(0x) should have been converted to fs_reg(0xu) to
make sure the uint32_t fs_reg constructor was matched.

commit 49a938a265f5959c9b558995cc658f80acb6eb18
Author: Jordan Justen 
Date:   Fri Feb 20 12:12:25 2015 -0800
i965/fs: Use fs_reg for CS/VS atomics pixel mask immediate data

Signed-off-by: Jordan Justen 
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 57c4d66..51a1e03 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -3113,7 +3113,7 @@ fs_visitor::emit_untyped_atomic(unsigned atomic_op, 
unsigned surf_index,
*/
   assert(stage == MESA_SHADER_VERTEX || stage == MESA_SHADER_COMPUTE);
   emit(MOV(component(sources[0], 7),
-   fs_reg(0x)))->force_writemask_all = true;
+   fs_reg(0xu)))->force_writemask_all = true;
}
length++;
 
@@ -3176,7 +3176,7 @@ fs_visitor::emit_untyped_surface_read(unsigned 
surf_index, fs_reg dst,
*/
   assert(stage == MESA_SHADER_VERTEX || stage == MESA_SHADER_COMPUTE);
   emit(MOV(component(sources[0], 7),
-   fs_reg(0x)))->force_writemask_all = true;
+   fs_reg(0xu)))->force_writemask_all = true;
}
 
/* Set the surface read offset. */
-- 
2.1.4

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


[Mesa-dev] [PATCH] i965/gen6 gs: Convert brw_imm_ud/brw_imm_d to src_reg

2015-03-03 Thread Jordan Justen
Same idea as this patch, only for gen6_gs_visitor:

commit 49a938a265f5959c9b558995cc658f80acb6eb18
Author: Jordan Justen 
Date:   Fri Feb 20 12:12:25 2015 -0800
i965/fs: Use fs_reg for CS/VS atomics pixel mask immediate data

Suggested-by: Matt Turner 
Signed-off-by: Jordan Justen 
---
 src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp 
b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
index 564b4cb..782687a 100644
--- a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
@@ -254,7 +254,7 @@ gen6_gs_visitor::visit(ir_end_primitive *)
* vertex.
*/
   src_reg offset(this, glsl_type::uint_type);
-  emit(ADD(dst_reg(offset), this->vertex_output_offset, brw_imm_d(-1)));
+  emit(ADD(dst_reg(offset), this->vertex_output_offset, src_reg(-1)));
 
   src_reg dst(this->vertex_output);
   dst.reladdr = ralloc(mem_ctx, src_reg);
@@ -384,7 +384,7 @@ gen6_gs_visitor::emit_thread_end()
  dst_reg(this->temp), this->prim_count, this->svbi);
   } else {
  inst = emit(GS_OPCODE_FF_SYNC,
- dst_reg(this->temp), this->prim_count, brw_imm_ud(0u));
+ dst_reg(this->temp), this->prim_count, src_reg(0u));
   }
   inst->base_mrf = base_mrf;
 
@@ -487,8 +487,8 @@ gen6_gs_visitor::emit_thread_end()
if (c->prog_data.gen6_xfb_enabled) {
   /* When emitting EOT, set SONumPrimsWritten Increment Value. */
   src_reg data(this, glsl_type::uint_type);
-  emit(AND(dst_reg(data), this->sol_prim_written, brw_imm_ud(0xu)));
-  emit(SHL(dst_reg(data), data, brw_imm_ud(16u)));
+  emit(AND(dst_reg(data), this->sol_prim_written, src_reg(0xu)));
+  emit(SHL(dst_reg(data), data, src_reg(16u)));
   emit(GS_OPCODE_SET_DWORD_2, dst_reg(MRF, base_mrf), data);
}
 
@@ -624,7 +624,7 @@ gen6_gs_visitor::xfb_write()
 * transform feedback is in interleaved or separate attribs mode.
 */
src_reg sol_temp(this, glsl_type::uvec4_type);
-   emit(ADD(dst_reg(sol_temp), this->svbi, brw_imm_ud(num_verts)));
+   emit(ADD(dst_reg(sol_temp), this->svbi, src_reg(num_verts)));
 
/* Compare SVBI calculated number with the maximum value, which is
 * in R1.4 (previously saved in this->max_svbi) for gen6.
@@ -671,7 +671,7 @@ gen6_gs_visitor::xfb_program(unsigned vertex, unsigned 
num_verts)
 * (all vertices). Otherwise, avoid writing any vertices for it
 */
emit(ADD(dst_reg(sol_temp), this->sol_prim_written, 1u));
-   emit(MUL(dst_reg(sol_temp), sol_temp, brw_imm_ud(num_verts)));
+   emit(MUL(dst_reg(sol_temp), sol_temp, src_reg(num_verts)));
emit(ADD(dst_reg(sol_temp), sol_temp, this->svbi));
emit(CMP(dst_null_d(), sol_temp, this->max_svbi, BRW_CONDITIONAL_LE));
emit(IF(BRW_PREDICATE_NORMAL));
@@ -736,7 +736,7 @@ gen6_gs_visitor::xfb_program(unsigned vertex, unsigned 
num_verts)
  */
 emit(ADD(dst_reg(this->destination_indices),
  this->destination_indices,
- brw_imm_ud(num_verts)));
+ src_reg(num_verts)));
 emit(ADD(dst_reg(this->sol_prim_written),
  this->sol_prim_written, 1u));
  }
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH] i965/gen6 gs: Convert brw_imm_ud/brw_imm_d to src_reg

2015-03-03 Thread Chris Forbes
Reviewed-by: Chris Forbes 

On Wed, Mar 4, 2015 at 2:25 PM, Jordan Justen  wrote:
> Same idea as this patch, only for gen6_gs_visitor:
>
> commit 49a938a265f5959c9b558995cc658f80acb6eb18
> Author: Jordan Justen 
> Date:   Fri Feb 20 12:12:25 2015 -0800
> i965/fs: Use fs_reg for CS/VS atomics pixel mask immediate data
>
> Suggested-by: Matt Turner 
> Signed-off-by: Jordan Justen 
> ---
>  src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp 
> b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
> index 564b4cb..782687a 100644
> --- a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
> @@ -254,7 +254,7 @@ gen6_gs_visitor::visit(ir_end_primitive *)
> * vertex.
> */
>src_reg offset(this, glsl_type::uint_type);
> -  emit(ADD(dst_reg(offset), this->vertex_output_offset, brw_imm_d(-1)));
> +  emit(ADD(dst_reg(offset), this->vertex_output_offset, src_reg(-1)));
>
>src_reg dst(this->vertex_output);
>dst.reladdr = ralloc(mem_ctx, src_reg);
> @@ -384,7 +384,7 @@ gen6_gs_visitor::emit_thread_end()
>   dst_reg(this->temp), this->prim_count, this->svbi);
>} else {
>   inst = emit(GS_OPCODE_FF_SYNC,
> - dst_reg(this->temp), this->prim_count, brw_imm_ud(0u));
> + dst_reg(this->temp), this->prim_count, src_reg(0u));
>}
>inst->base_mrf = base_mrf;
>
> @@ -487,8 +487,8 @@ gen6_gs_visitor::emit_thread_end()
> if (c->prog_data.gen6_xfb_enabled) {
>/* When emitting EOT, set SONumPrimsWritten Increment Value. */
>src_reg data(this, glsl_type::uint_type);
> -  emit(AND(dst_reg(data), this->sol_prim_written, brw_imm_ud(0xu)));
> -  emit(SHL(dst_reg(data), data, brw_imm_ud(16u)));
> +  emit(AND(dst_reg(data), this->sol_prim_written, src_reg(0xu)));
> +  emit(SHL(dst_reg(data), data, src_reg(16u)));
>emit(GS_OPCODE_SET_DWORD_2, dst_reg(MRF, base_mrf), data);
> }
>
> @@ -624,7 +624,7 @@ gen6_gs_visitor::xfb_write()
>  * transform feedback is in interleaved or separate attribs mode.
>  */
> src_reg sol_temp(this, glsl_type::uvec4_type);
> -   emit(ADD(dst_reg(sol_temp), this->svbi, brw_imm_ud(num_verts)));
> +   emit(ADD(dst_reg(sol_temp), this->svbi, src_reg(num_verts)));
>
> /* Compare SVBI calculated number with the maximum value, which is
>  * in R1.4 (previously saved in this->max_svbi) for gen6.
> @@ -671,7 +671,7 @@ gen6_gs_visitor::xfb_program(unsigned vertex, unsigned 
> num_verts)
>  * (all vertices). Otherwise, avoid writing any vertices for it
>  */
> emit(ADD(dst_reg(sol_temp), this->sol_prim_written, 1u));
> -   emit(MUL(dst_reg(sol_temp), sol_temp, brw_imm_ud(num_verts)));
> +   emit(MUL(dst_reg(sol_temp), sol_temp, src_reg(num_verts)));
> emit(ADD(dst_reg(sol_temp), sol_temp, this->svbi));
> emit(CMP(dst_null_d(), sol_temp, this->max_svbi, BRW_CONDITIONAL_LE));
> emit(IF(BRW_PREDICATE_NORMAL));
> @@ -736,7 +736,7 @@ gen6_gs_visitor::xfb_program(unsigned vertex, unsigned 
> num_verts)
>   */
>  emit(ADD(dst_reg(this->destination_indices),
>   this->destination_indices,
> - brw_imm_ud(num_verts)));
> + src_reg(num_verts)));
>  emit(ADD(dst_reg(this->sol_prim_written),
>   this->sol_prim_written, 1u));
>   }
> --
> 2.1.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 10/38] main: Add entry points for glNamedFramebufferTexture[Layer].

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml | 15 +++
 src/mesa/main/fbobject.c   | 62 ++
 src/mesa/main/fbobject.h   |  8 
 src/mesa/main/tests/dispatch_sanity.cpp|  2 +
 4 files changed, 87 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index b954343..19d029d 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -125,6 +125,21 @@
   

 
+   
+  
+  
+  
+  
+   
+
+   
+  
+  
+  
+  
+  
+   
+

 

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 2ac9903..f634aed 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2832,6 +2832,35 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum 
attachment,
  layer, layered, "glFramebufferTextureLayer");
 }
 
+void GLAPIENTRY
+_mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
+   GLuint texture, GLint level, GLint layer)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb;
+   struct gl_texture_object *texObj;
+   GLboolean layered = GL_FALSE;
+
+   /* Get the framebuffer object */
+   fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferTextureLayer");
+   if (!fb)
+  return;
+
+   /* Get the texture object */
+   if (!get_texture_for_framebuffer(ctx, texture, 0, level, layer,
+&layered,
+"glNamedFramebufferTextureLayer",
+&texObj)) {
+  /* Error already recorded */
+  return;
+   }
+
+   _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ layer, layered,
+ "glNamedFramebufferTextureLayer");
+}
+
 
 void GLAPIENTRY
 _mesa_FramebufferTexture(GLenum target, GLenum attachment,
@@ -2869,6 +2898,39 @@ _mesa_FramebufferTexture(GLenum target, GLenum 
attachment,
  0, layered, "glFramebufferTexture");
 }
 
+void GLAPIENTRY
+_mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
+  GLuint texture, GLint level)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb;
+   struct gl_texture_object *texObj;
+   GLboolean layered = GL_TRUE;
+
+   if (!_mesa_has_geometry_shaders(ctx)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "unsupported function (glNamedFramebufferTexture) called");
+  return;
+   }
+
+   /* Get the framebuffer object */
+   fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferTexture");
+   if (!fb)
+  return;
+
+   /* Get the texture object */
+   if (!get_texture_for_framebuffer(ctx, texture, 0, level, 0,
+&layered, "glNamedFramebufferTexture",
+&texObj)) {
+  /* Error already recorded */
+  return;
+   }
+
+   _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ 0, layered, "glNamedFramebufferTexture");
+}
+
 
 void
 _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 4304215..7487f02 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -197,10 +197,18 @@ _mesa_FramebufferTextureLayer(GLenum target, GLenum 
attachment,
  GLuint texture, GLint level, GLint layer);
 
 extern void GLAPIENTRY
+_mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
+   GLuint texture, GLint level, GLint layer);
+
+extern void GLAPIENTRY
 _mesa_FramebufferTexture(GLenum target, GLenum attachment,
  GLuint texture, GLint level);
 
 extern void GLAPIENTRY
+_mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
+  GLuint texture, GLint level);
+
+extern void GLAPIENTRY
 _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
  GLenum renderbuffertarget,
  GLuint renderbuffer);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index c370a80..d72a04c 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -972,6 +972,8 @@ const struct function gl_core_functions_possible[] = {
{ "glGetNamedBufferSubData", 45, -1 },
{ "glCreateFramebuffers", 45, -1 },
{ "glNamedFramebufferRenderbuffer", 45, -1 },
+   { "glNamedFramebufferTexture", 45, -1 },
+   { "glNamedFramebufferTextureLayer", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTexture

[Mesa-dev] [PATCH 17/38] main: Refactor _mesa_update_framebuffer.

2015-03-03 Thread Laura Ekstrand
_mesa_update_framebuffer now operates on arbitrary read and draw framebuffers.
This allows BlitNamedFramebuffer to update the state of its arbitrary read and
draw framebuffers.
---
 src/mesa/drivers/dri/i915/i830_vtbl.c   |  2 +-
 src/mesa/drivers/dri/i915/i915_vtbl.c   |  2 +-
 src/mesa/drivers/dri/r200/r200_state.c  |  2 +-
 src/mesa/drivers/dri/radeon/radeon_common.c |  2 +-
 src/mesa/drivers/dri/radeon/radeon_state.c  |  2 +-
 src/mesa/main/framebuffer.c | 11 ---
 src/mesa/main/framebuffer.h |  4 +++-
 src/mesa/main/state.c   |  2 +-
 8 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c 
b/src/mesa/drivers/dri/i915/i830_vtbl.c
index 91da977..4fff29e 100644
--- a/src/mesa/drivers/dri/i915/i830_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -730,7 +730,7 @@ i830_update_draw_buffer(struct intel_context *intel)
 */
if (ctx->NewState & _NEW_BUFFERS) {
   /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
-  _mesa_update_framebuffer(ctx);
+  _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
   /* this updates the DrawBuffer's Width/Height if it's a FBO */
   _mesa_update_draw_buffer_bounds(ctx);
}
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c 
b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 706e0c3..9ed298c 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -732,7 +732,7 @@ i915_update_draw_buffer(struct intel_context *intel)
 */
if (ctx->NewState & _NEW_BUFFERS) {
   /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
-  _mesa_update_framebuffer(ctx);
+  _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
   /* this updates the DrawBuffer's Width/Height if it's a FBO */
   _mesa_update_draw_buffer_bounds(ctx);
}
diff --git a/src/mesa/drivers/dri/r200/r200_state.c 
b/src/mesa/drivers/dri/r200/r200_state.c
index 8327187..b020439 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -2214,7 +2214,7 @@ GLboolean r200ValidateState( struct gl_context *ctx )
GLuint new_state = rmesa->radeon.NewGLState;
 
if (new_state & _NEW_BUFFERS) {
-  _mesa_update_framebuffer(ctx);
+  _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
   /* this updates the DrawBuffer's Width/Height if it's a FBO */
   _mesa_update_draw_buffer_bounds(ctx);
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c 
b/src/mesa/drivers/dri/radeon/radeon_common.c
index 3bcc7f2..84c8066 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -220,7 +220,7 @@ void radeon_draw_buffer(struct gl_context *ctx, struct 
gl_framebuffer *fb)
 */
if (ctx->NewState & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, 
etc */
-   _mesa_update_framebuffer(ctx);
+   _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
_mesa_update_draw_buffer_bounds(ctx);
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c 
b/src/mesa/drivers/dri/radeon/radeon_state.c
index e83a34d..2c0a99a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1993,7 +1993,7 @@ GLboolean radeonValidateState( struct gl_context *ctx )
GLuint new_state = rmesa->radeon.NewGLState;
 
if (new_state & _NEW_BUFFERS) {
- _mesa_update_framebuffer(ctx);
+ _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
  /* this updates the DrawBuffer's Width/Height if it's a FBO */
  _mesa_update_draw_buffer_bounds(ctx);
  RADEON_STATECHANGE(rmesa, ctx);
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 5df1ecc..31d05f8 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -678,17 +678,14 @@ update_framebuffer(struct gl_context *ctx, struct 
gl_framebuffer *fb)
 
 
 /**
- * Update state related to the current draw/read framebuffers.
+ * Update state related to the draw/read framebuffers.
  */
 void
-_mesa_update_framebuffer(struct gl_context *ctx)
+_mesa_update_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb)
 {
-   struct gl_framebuffer *drawFb;
-   struct gl_framebuffer *readFb;
-
assert(ctx);
-   drawFb = ctx->DrawBuffer;
-   readFb = ctx->ReadBuffer;
 
update_framebuffer(ctx, drawFb);
if (readFb != drawFb)
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index a427421..d3b7e58 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -84,7 +84,9 @@ _mesa_up

[Mesa-dev] [PATCH 30/38] main: Fake entry point for glClearNamedFramebufferfi.

2015-03-03 Thread Laura Ekstrand
Mesa's ClearBuffer framework is very complicated and thoroughly married to the
object binding model.  Moreover, the OpenGL spec for ClearBuffer is also very
complicated.  At some point, we should implement buffer clearing for arbitrary
framebuffer objects, but for now, we will just wrap ClearBuffer.
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/clear.c  | 17 +
 src/mesa/main/clear.h  |  4 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 29 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 4cdf2f6..3f8ce50 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -177,6 +177,13 @@
   

 
+   
+  
+  
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index b5e22e3..eb283d9 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -679,3 +679,20 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
   ctx->Stencil.Clear = clearStencilSave;
}
 }
+
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
+  GLfloat depth, GLint stencil)
+{
+   GLint oldfb;
+
+   _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+   _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+   _mesa_ClearBufferfi(buffer, 0, depth, stencil);
+   _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
diff --git a/src/mesa/main/clear.h b/src/mesa/main/clear.h
index 582159f..c298506 100644
--- a/src/mesa/main/clear.h
+++ b/src/mesa/main/clear.h
@@ -73,4 +73,8 @@ extern void GLAPIENTRY
 _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
 GLfloat depth, GLint stencil);
 
+extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
+  GLfloat depth, GLint stencil);
+
 #endif
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index d5a3773..91989ee 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -979,6 +979,7 @@ const struct function gl_core_functions_possible[] = {
{ "glClearNamedFramebufferiv", 45, -1 },
{ "glClearNamedFramebufferuiv", 45, -1 },
{ "glClearNamedFramebufferfv", 45, -1 },
+   { "glClearNamedFramebufferfi", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 18/38] main: Refactor _mesa_[update|get]_clamp_vertex_color.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/blend.c   | 13 -
 src/mesa/main/blend.h   |  7 +--
 src/mesa/main/framebuffer.c |  2 +-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 774fc88..ee76b47 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -769,7 +769,7 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
   }
   FLUSH_VERTICES(ctx, _NEW_LIGHT);
   ctx->Light.ClampVertexColor = clamp;
-  _mesa_update_clamp_vertex_color(ctx);
+  _mesa_update_clamp_vertex_color(ctx, ctx->DrawBuffer);
   break;
case GL_CLAMP_FRAGMENT_COLOR_ARB:
   if (ctx->API == API_OPENGL_CORE &&
@@ -814,9 +814,10 @@ _mesa_get_clamp_fragment_color(const struct gl_context 
*ctx)
 }
 
 GLboolean
-_mesa_get_clamp_vertex_color(const struct gl_context *ctx)
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
 {
-   return get_clamp_color(ctx->DrawBuffer, ctx->Light.ClampVertexColor);
+   return get_clamp_color(drawFb, ctx->Light.ClampVertexColor);
 }
 
 GLboolean
@@ -848,9 +849,11 @@ _mesa_update_clamp_fragment_color(struct gl_context *ctx)
  * Update the ctx->Color._ClampVertexColor field
  */
 void
-_mesa_update_clamp_vertex_color(struct gl_context *ctx)
+_mesa_update_clamp_vertex_color(struct gl_context *ctx,
+const struct gl_framebuffer *drawFb)
 {
-   ctx->Light._ClampVertexColor = _mesa_get_clamp_vertex_color(ctx);
+   ctx->Light._ClampVertexColor =
+ _mesa_get_clamp_vertex_color(ctx, drawFb);
 }
 
 /**
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index fe31a74..9c1ef7e 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -37,6 +37,7 @@
 #include "formats.h"
 
 struct gl_context;
+struct gl_framebuffer;
 
 
 extern void GLAPIENTRY
@@ -104,7 +105,8 @@ extern GLboolean
 _mesa_get_clamp_fragment_color(const struct gl_context *ctx);
 
 extern GLboolean
-_mesa_get_clamp_vertex_color(const struct gl_context *ctx);
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
 
 extern GLboolean
 _mesa_get_clamp_read_color(const struct gl_context *ctx);
@@ -113,7 +115,8 @@ extern void
 _mesa_update_clamp_fragment_color(struct gl_context *ctx);
 
 extern void
-_mesa_update_clamp_vertex_color(struct gl_context *ctx);
+_mesa_update_clamp_vertex_color(struct gl_context *ctx,
+const struct gl_framebuffer *drawFb);
 
 extern mesa_format
 _mesa_get_render_format(const struct gl_context *ctx, mesa_format format);
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 31d05f8..22db72a 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -691,7 +691,7 @@ _mesa_update_framebuffer(struct gl_context *ctx,
if (readFb != drawFb)
   update_framebuffer(ctx, readFb);
 
-   _mesa_update_clamp_vertex_color(ctx);
+   _mesa_update_clamp_vertex_color(ctx, drawFb);
_mesa_update_clamp_fragment_color(ctx);
 }
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 12/38] main: Fix indents in former get_texture_for_framebuffer functions.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/fbobject.c | 82 
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 4df0b6b..1435576 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2469,32 +2469,32 @@ check_layered_texture_target(struct gl_context *ctx, 
GLenum target,
 {
*layered = true;
 
- switch (target) {
- case GL_TEXTURE_3D:
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_ARRAY:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
-return true;
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_RECTANGLE:
- case GL_TEXTURE_2D_MULTISAMPLE:
-/* These texture types are valid to pass to
- * glFramebufferTexture(), but since they aren't layered, it
- * is equivalent to calling glFramebufferTexture{1D,2D}().
- *
- * textarget can remain 0 since CUBE MAP is not valid here.
- */
-*layered = false;
-return true;
- }
+   switch (target) {
+   case GL_TEXTURE_3D:
+   case GL_TEXTURE_1D_ARRAY_EXT:
+   case GL_TEXTURE_2D_ARRAY_EXT:
+   case GL_TEXTURE_CUBE_MAP:
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+  return true;
+   case GL_TEXTURE_1D:
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_RECTANGLE:
+   case GL_TEXTURE_2D_MULTISAMPLE:
+  /* These texture types are valid to pass to
+   * glFramebufferTexture(), but since they aren't layered, it
+   * is equivalent to calling glFramebufferTexture{1D,2D}().
+   *
+   * textarget can remain 0 since CUBE MAP is not valid here.
+   */
+  *layered = false;
+  return true;
+   }
 
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  "%s(invalid texture target %s)", caller,
-  _mesa_lookup_enum_by_nr(target));
-  return false;
+   _mesa_error(ctx, GL_INVALID_OPERATION,
+   "%s(invalid texture target %s)", caller,
+   _mesa_lookup_enum_by_nr(target));
+   return false;
 }
 
 /**
@@ -2507,23 +2507,23 @@ static bool
 check_texture_target(struct gl_context *ctx, GLenum target,
  const char *caller)
 {
- /* We're being called by glFramebufferTextureLayer() and
-  * textarget is not used.  The only legal texture types for
-  * that function are 3D and 1D/2D arrays textures.
-  */
- switch (target) {
- case GL_TEXTURE_3D:
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_TEXTURE_CUBE_MAP_ARRAY:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
-return true;
- }
+   /* We're being called by glFramebufferTextureLayer() and
+* textarget is not used.  The only legal texture types for
+* that function are 3D and 1D/2D arrays textures.
+*/
+   switch (target) {
+   case GL_TEXTURE_3D:
+   case GL_TEXTURE_1D_ARRAY_EXT:
+   case GL_TEXTURE_2D_ARRAY_EXT:
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
+   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+  return true;
+   }
 
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  "%s(invalid texture target %s)", caller,
-  _mesa_lookup_enum_by_nr(target));
-  return false;
+   _mesa_error(ctx, GL_INVALID_OPERATION,
+   "%s(invalid texture target %s)", caller,
+   _mesa_lookup_enum_by_nr(target));
+   return false;
 }
 
 /**
-- 
2.1.0

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


[Mesa-dev] [PATCH 11/38] main: Major refactor of get_texture_for_framebuffer.

2015-03-03 Thread Laura Ekstrand
This splits off the (still) rather large chunk that is
get_texture_for_framebuffer into lots of smaller functions specialized to
service the wide variety of unique needs of *FramebufferTexture* entry points.
The result is much cleaner because, rather than having a pile of branches and
confusing conditions (like the boolean layered), the uniqueness is baked into
the entry points. The entry points know whether or not they are layered or use
a textarget.
---
 src/mesa/main/fbobject.c | 457 +--
 src/mesa/main/fbobject.h |   2 +-
 2 files changed, 247 insertions(+), 212 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f634aed..4df0b6b 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2415,14 +2415,7 @@ reuse_framebuffer_texture_attachment(struct 
gl_framebuffer *fb,
 
 /**
  * Common code called by gl*FramebufferTexture*() to retrieve the correct
- * texture object pointer and check for associated errors.
- *
- * \param textarget is the textarget that was passed to the
- * glFramebufferTexture...() function, or 0 if the corresponding function
- * doesn't have a textarget parameter.
- *
- * \param layered is true if this function was called from
- * gl*FramebufferTexture(), false otherwise.
+ * texture object pointer.
  *
  * \param texObj where the pointer to the texture object is returned.  Note
  * that a successful call may return texObj = NULL.
@@ -2430,20 +2423,12 @@ reuse_framebuffer_texture_attachment(struct 
gl_framebuffer *fb,
  * \return true if no errors, false if errors
  */
 static bool
-get_texture_for_framebuffer(struct gl_context *ctx,
-GLuint texture, GLenum textarget,
-GLint level, GLuint zoffset, GLboolean *layered,
-const char *caller,
+get_texture_for_framebuffer(struct gl_context *ctx, GLuint texture,
+bool layered, const char *caller,
 struct gl_texture_object **texObj)
 {
-   GLenum maxLevelsTarget;
-   GLboolean err = GL_TRUE;
-
*texObj = NULL; /* This will get returned if texture = 0. */
 
-   /* The textarget, level, and zoffset parameters are only validated if
-* texture is non-zero.
-*/
if (!texture)
   return true;
 
@@ -2458,27 +2443,40 @@ get_texture_for_framebuffer(struct gl_context *ctx,
* value, while the other commands throw invalid operation (where
* *layered = GL_FALSE).
*/
-  GLenum no_texobj_err = *layered ? GL_INVALID_VALUE :
+  GLenum no_texobj_err = layered ? GL_INVALID_VALUE :
  GL_INVALID_OPERATION;
   _mesa_error(ctx, no_texobj_err,
   "%s(non-generated texture %u)", caller, texture);
   return false;
}
 
-   if (textarget == 0) {
-  if (*layered) {
- /* We're being called by gl*FramebufferTexture() and textarget
-  * is not used.
-  */
- switch ((*texObj)->Target) {
+   return true;
+}
+
+/**
+ * Common code called by gl*FramebufferTexture() to verify the texture target
+ * and decide whether or not the attachment should truly be considered
+ * layered.
+ *
+ * \param layered true if attachment should be considered layered, false if
+ * not
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_layered_texture_target(struct gl_context *ctx, GLenum target,
+ const char *caller, bool *layered)
+{
+   *layered = true;
+
+ switch (target) {
  case GL_TEXTURE_3D:
  case GL_TEXTURE_1D_ARRAY_EXT:
  case GL_TEXTURE_2D_ARRAY_EXT:
  case GL_TEXTURE_CUBE_MAP:
  case GL_TEXTURE_CUBE_MAP_ARRAY:
  case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
-err = false;
-break;
+return true;
  case GL_TEXTURE_1D:
  case GL_TEXTURE_2D:
  case GL_TEXTURE_RECTANGLE:
@@ -2486,41 +2484,139 @@ get_texture_for_framebuffer(struct gl_context *ctx,
 /* These texture types are valid to pass to
  * glFramebufferTexture(), but since they aren't layered, it
  * is equivalent to calling glFramebufferTexture{1D,2D}().
+ *
+ * textarget can remain 0 since CUBE MAP is not valid here.
  */
-err = false;
 *layered = false;
-textarget = (*texObj)->Target;
-break;
- default:
-err = true;
-break;
+return true;
  }
-  } else {
+
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(invalid texture target %s)", caller,
+  _mesa_lookup_enum_by_nr(target));
+  return false;
+}
+
+/**
+ * Common code called by gl*FramebufferTextureLayer() to verify the texture
+ * target.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_texture_target(struct gl_context 

[Mesa-dev] [PATCH 31/38] main: Add stubs for [Get]NamedFramebufferParameteri[v].

2015-03-03 Thread Laura Ekstrand
The ARB_direct_state_access specification says (as of 2015.02.05):
   "Interactions with OpenGL 4.3 or ARB_framebuffer_no_attachments

   If neither OpenGL 4.3 nor ARB_framebuffer_no_attachments are supported,
   ignore the support for NamedFramebufferParameteri and
   GetNamedFramebufferParameteriv."
This commit adds stubs for these entry points.
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml | 12 +++
 src/mesa/main/fbobject.c   | 30 ++
 src/mesa/main/fbobject.h   |  8 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  2 ++
 4 files changed, 52 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 3f8ce50..025a1a8 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -125,6 +125,12 @@
   

 
+   
+  
+  
+  
+   
+

   
   
@@ -205,6 +211,12 @@
   

 
+   
+  
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 72d87db..fc11017 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3466,6 +3466,36 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint 
framebuffer,
   "glGetNamedFramebufferAttachmentParameteriv");
 }
 
+void GLAPIENTRY
+_mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
+ GLint param)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   (void) framebuffer;
+   (void) pname;
+   (void) param;
+
+   _mesa_error(ctx, GL_INVALID_OPERATION,
+   "glNamedFramebufferParameteri not supported "
+   "(ARB_framebuffer_no_attachments not implemented)");
+}
+
+void GLAPIENTRY
+_mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
+ GLint *param)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   (void) framebuffer;
+   (void) pname;
+   (void) param;
+
+   _mesa_error(ctx, GL_INVALID_OPERATION,
+   "glGetNamedFramebufferParameteriv not supported "
+   "(ARB_framebuffer_no_attachments not implemented)");
+}
+
 
 static void
 invalidate_framebuffer_storage(struct gl_context *ctx,
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index f71e885..fe9e5a8 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -240,6 +240,14 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint 
framebuffer,
GLenum pname, GLint *params);
 
 extern void GLAPIENTRY
+_mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
+ GLint param);
+
+extern void GLAPIENTRY
+_mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
+ GLint *param);
+
+extern void GLAPIENTRY
 _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
GLsizei width, GLsizei height);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 91989ee..01a3d14 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -972,6 +972,7 @@ const struct function gl_core_functions_possible[] = {
{ "glGetNamedBufferSubData", 45, -1 },
{ "glCreateFramebuffers", 45, -1 },
{ "glNamedFramebufferRenderbuffer", 45, -1 },
+   { "glNamedFramebufferParameteri", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
@@ -982,6 +983,7 @@ const struct function gl_core_functions_possible[] = {
{ "glClearNamedFramebufferfi", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
+   { "glGetNamedFramebufferParameteriv", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTextureStorage1D", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 25/38] main: Complete error conditions for glInvalidate*Framebuffer.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/fbobject.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 7a1684c..0b4cabe 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3476,12 +3476,29 @@ invalidate_framebuffer_storage(struct gl_context *ctx,
 {
int i;
 
+   /* Section 17.4 Whole Framebuffer Operations of the OpenGL 4.5 Core
+* Spec (2.2.2015, PDF page 522) says:
+*"An INVALID_VALUE error is generated if numAttachments, width, or
+*height is negative."
+*/
if (numAttachments < 0) {
   _mesa_error(ctx, GL_INVALID_VALUE,
   "%s(numAttachments < 0)", name);
   return;
}
 
+   if (width < 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "%s(width < 0)", name);
+  return;
+   }
+
+   if (height < 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "%s(height < 0)", name);
+  return;
+   }
+
/* The GL_ARB_invalidate_subdata spec says:
 *
 * "If an attachment is specified that does not exist in the
@@ -3574,7 +3591,8 @@ invalidate_framebuffer_storage(struct gl_context *ctx,
return;
 
 invalid_enum:
-   _mesa_error(ctx, GL_INVALID_ENUM, "%s(attachment)", name);
+   _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", name,
+   _mesa_lookup_enum_by_nr(attachments[i]));
return;
 }
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 09/38] main: Fix indentation in get_texture_for_framebuffer.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/fbobject.c | 148 +++
 1 file changed, 74 insertions(+), 74 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f86e1a0..2ac9903 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2465,87 +2465,87 @@ get_texture_for_framebuffer(struct gl_context *ctx,
   return false;
}
 
- if (textarget == 0) {
-if (*layered) {
-   /* We're being called by gl*FramebufferTexture() and textarget
-* is not used.
-*/
-   switch ((*texObj)->Target) {
-   case GL_TEXTURE_3D:
-   case GL_TEXTURE_1D_ARRAY_EXT:
-   case GL_TEXTURE_2D_ARRAY_EXT:
-   case GL_TEXTURE_CUBE_MAP:
-   case GL_TEXTURE_CUBE_MAP_ARRAY:
-   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
-  err = false;
-  break;
-   case GL_TEXTURE_1D:
-   case GL_TEXTURE_2D:
-   case GL_TEXTURE_RECTANGLE:
-   case GL_TEXTURE_2D_MULTISAMPLE:
-  /* These texture types are valid to pass to
-   * glFramebufferTexture(), but since they aren't layered, it
-   * is equivalent to calling glFramebufferTexture{1D,2D}().
-   */
-  err = false;
-  *layered = false;
-  textarget = (*texObj)->Target;
-  break;
-   default:
-  err = true;
-  break;
-   }
-} else {
-   /* We're being called by glFramebufferTextureLayer() and
-* textarget is not used.  The only legal texture types for
-* that function are 3D and 1D/2D arrays textures.
-*/
-   err = ((*texObj)->Target != GL_TEXTURE_3D) &&
-  ((*texObj)->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
-  ((*texObj)->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
-  ((*texObj)->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
-  ((*texObj)->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
-}
- }
- else {
-/* Make sure textarget is consistent with the texture's type */
-err = ((*texObj)->Target == GL_TEXTURE_CUBE_MAP)
-? !_mesa_is_cube_face(textarget)
-: ((*texObj)->Target != textarget);
+   if (textarget == 0) {
+  if (*layered) {
+ /* We're being called by gl*FramebufferTexture() and textarget
+  * is not used.
+  */
+ switch ((*texObj)->Target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+err = false;
+break;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+/* These texture types are valid to pass to
+ * glFramebufferTexture(), but since they aren't layered, it
+ * is equivalent to calling glFramebufferTexture{1D,2D}().
+ */
+err = false;
+*layered = false;
+textarget = (*texObj)->Target;
+break;
+ default:
+err = true;
+break;
  }
-
-  if (err) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid or mismatched texture target)", caller);
- return false;
+  } else {
+ /* We're being called by glFramebufferTextureLayer() and
+  * textarget is not used.  The only legal texture types for
+  * that function are 3D and 1D/2D arrays textures.
+  */
+ err = ((*texObj)->Target != GL_TEXTURE_3D) &&
+((*texObj)->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
+((*texObj)->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
+((*texObj)->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
+((*texObj)->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
   }
+   }
+   else {
+  /* Make sure textarget is consistent with the texture's type */
+  err = ((*texObj)->Target == GL_TEXTURE_CUBE_MAP)
+  ? !_mesa_is_cube_face(textarget)
+  : ((*texObj)->Target != textarget);
+   }
 
-  if ((*texObj)->Target == GL_TEXTURE_3D) {
- const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
- if (zoffset >= maxSize) {
-_mesa_error(ctx, GL_INVALID_VALUE,
-"%s(invalid zoffset %u)", caller, zoffset);
-return false;
- }
-  }
-  else if (((*texObj)->Target == GL_TEXTURE_1D_ARRAY_EXT) ||
-   ((*texObj)->Target == GL_TEXTURE_2D_ARRAY_EXT) ||
-   ((*texObj)->Targ

[Mesa-dev] [PATCH 20/38] main: Refactor _mesa_get_clamp_read_color.

2015-03-03 Thread Laura Ekstrand
This wasn't neccessary for ARB_direct_state_access, but felt like a good idea
for the sake of completeness.
---
 src/mesa/main/blend.c   | 5 +++--
 src/mesa/main/blend.h   | 3 ++-
 src/mesa/main/readpix.c | 4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 2342555..d869fa2 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -821,9 +821,10 @@ _mesa_get_clamp_vertex_color(const struct gl_context *ctx,
 }
 
 GLboolean
-_mesa_get_clamp_read_color(const struct gl_context *ctx)
+_mesa_get_clamp_read_color(const struct gl_context *ctx,
+   const struct gl_framebuffer *readFb)
 {
-   return get_clamp_color(ctx->ReadBuffer, ctx->Color.ClampReadColor);
+   return get_clamp_color(readFb, ctx->Color.ClampReadColor);
 }
 
 /**
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index 58e6673..8ab9e02 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -110,7 +110,8 @@ _mesa_get_clamp_vertex_color(const struct gl_context *ctx,
  const struct gl_framebuffer *drawFb);
 
 extern GLboolean
-_mesa_get_clamp_read_color(const struct gl_context *ctx);
+_mesa_get_clamp_read_color(const struct gl_context *ctx,
+   const struct gl_framebuffer *readFb);
 
 extern void
 _mesa_update_clamp_fragment_color(struct gl_context *ctx,
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index ed0104c..df46f83 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -83,7 +83,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, 
mesa_format texFormat,
if (uses_blit) {
   /* For blit-based ReadPixels packing, the clamping is done automatically
* unless the type is float. */
-  if (_mesa_get_clamp_read_color(ctx) &&
+  if (_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) &&
   (type == GL_FLOAT || type == GL_HALF_FLOAT)) {
  transferOps |= IMAGE_CLAMP_BIT;
   }
@@ -91,7 +91,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, 
mesa_format texFormat,
else {
   /* For CPU-based ReadPixels packing, the clamping must always be done
* for non-float types, */
-  if (_mesa_get_clamp_read_color(ctx) ||
+  if (_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) ||
   (type != GL_FLOAT && type != GL_HALF_FLOAT)) {
  transferOps |= IMAGE_CLAMP_BIT;
   }
-- 
2.1.0

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


[Mesa-dev] [PATCH 16/38] main: Refactor glBlitFramebuffer.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/blit.c | 119 ---
 src/mesa/main/blit.h |   7 +++
 2 files changed, 73 insertions(+), 53 deletions(-)

diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index 899dd45..b6d6d75 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -147,39 +147,24 @@ is_valid_blit_filter(const struct gl_context *ctx, GLenum 
filter)
 }
 
 
-/**
- * Blit rectangular region, optionally from one framebuffer to another.
- *
- * Note, if the src buffer is multisampled and the dest is not, this is
- * when the samples must be resolved to a single color.
- */
-void GLAPIENTRY
-_mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter)
+void
+_mesa_blit_framebuffer(struct gl_context *ctx,
+   struct gl_framebuffer *readFb,
+   struct gl_framebuffer *drawFb,
+   GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+   GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+   GLbitfield mask, GLenum filter, const char *func)
 {
const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT |
  GL_DEPTH_BUFFER_BIT |
  GL_STENCIL_BUFFER_BIT);
-   const struct gl_framebuffer *readFb, *drawFb;
-   GET_CURRENT_CONTEXT(ctx);
 
FLUSH_VERTICES(ctx, 0);
 
-   if (MESA_VERBOSE & VERBOSE_API)
-  _mesa_debug(ctx,
-  "glBlitFramebuffer(%d, %d, %d, %d,  %d, %d, %d, %d, 0x%x, 
%s)\n",
-  srcX0, srcY0, srcX1, srcY1,
-  dstX0, dstY0, dstX1, dstY1,
-  mask, _mesa_lookup_enum_by_nr(filter));
-
if (ctx->NewState) {
   _mesa_update_state(ctx);
}
 
-   readFb = ctx->ReadBuffer;
-   drawFb = ctx->DrawBuffer;
-
if (!readFb || !drawFb) {
   /* This will normally never happen but someday we may want to
* support MakeCurrent() with no drawables.
@@ -191,12 +176,12 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT ||
readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
   _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
-  "glBlitFramebufferEXT(incomplete draw/read buffers)");
+  "%s(incomplete draw/read buffers)", func);
   return;
}
 
if (!is_valid_blit_filter(ctx, filter)) {
-  _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(%s)",
+  _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid filter %s)", func,
   _mesa_lookup_enum_by_nr(filter));
   return;
}
@@ -204,13 +189,13 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
if ((filter == GL_SCALED_RESOLVE_FASTEST_EXT ||
 filter == GL_SCALED_RESOLVE_NICEST_EXT) &&
 (readFb->Visual.samples == 0 || drawFb->Visual.samples > 0)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(%s)",
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(%s: invalid samples)", func,
   _mesa_lookup_enum_by_nr(filter));
   return;
}
 
if (mask & ~legalMaskBits) {
-  _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)");
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid mask bits set)", func);
   return;
}
 
@@ -218,13 +203,13 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT))
 && filter != GL_NEAREST) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter)");
+ "%s(depth/stencil requires GL_NEAREST filter)", func);
   return;
}
 
/* get color read/draw renderbuffers */
if (mask & GL_COLOR_BUFFER_BIT) {
-  const GLuint numColorDrawBuffers = ctx->DrawBuffer->_NumColorDrawBuffers;
+  const GLuint numColorDrawBuffers = drawFb->_NumColorDrawBuffers;
   const struct gl_renderbuffer *colorReadRb = readFb->_ColorReadBuffer;
   const struct gl_renderbuffer *colorDrawRb = NULL;
   GLuint i;
@@ -240,7 +225,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
   }
   else {
  for (i = 0; i < numColorDrawBuffers; i++) {
-colorDrawRb = ctx->DrawBuffer->_ColorDrawBuffers[i];
+colorDrawRb = drawFb->_ColorDrawBuffers[i];
 if (!colorDrawRb)
continue;
 
@@ -256,15 +241,15 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
  */
 if (_mesa_is_gles3(ctx) && (colorDrawRb == colorReadRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
-   "glBlitFramebuffer(source and destination color "
-   

[Mesa-dev] [PATCH 13/38] main: Add entry point for CheckNamedFramebufferStatus.

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  6 +++
 src/mesa/main/fbobject.c   | 73 --
 src/mesa/main/fbobject.h   |  7 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 72 insertions(+), 15 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 19d029d..20c2e7b 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -140,6 +140,12 @@
   

 
+   
+  
+  
+  
+   
+

 

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 1435576..6ed82d5 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2351,24 +2351,12 @@ _mesa_CreateFramebuffers(GLsizei n, GLuint 
*framebuffers)
 }
 
 
-GLenum GLAPIENTRY
-_mesa_CheckFramebufferStatus(GLenum target)
+GLenum
+_mesa_check_framebuffer_status(struct gl_context *ctx,
+   struct gl_framebuffer *buffer)
 {
-   struct gl_framebuffer *buffer;
-   GET_CURRENT_CONTEXT(ctx);
-
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
 
-   if (MESA_VERBOSE & VERBOSE_API)
-  _mesa_debug(ctx, "glCheckFramebufferStatus(%s)\n",
-  _mesa_lookup_enum_by_nr(target));
-
-   buffer = get_framebuffer_target(ctx, target);
-   if (!buffer) {
-  _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)");
-  return 0;
-   }
-
if (_mesa_is_winsys_fbo(buffer)) {
   /* EGL_KHR_surfaceless_context allows the winsys FBO to be incomplete. */
   if (buffer != &IncompleteFramebuffer) {
@@ -2387,6 +2375,61 @@ _mesa_CheckFramebufferStatus(GLenum target)
return buffer->_Status;
 }
 
+GLenum GLAPIENTRY
+_mesa_CheckFramebufferStatus(GLenum target)
+{
+   struct gl_framebuffer *fb;
+   GET_CURRENT_CONTEXT(ctx);
+
+   fb = get_framebuffer_target(ctx, target);
+   if (!fb) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "glCheckFramebufferStatus(invalid target %s)",
+  _mesa_lookup_enum_by_nr(target));
+  return 0;
+   }
+
+   return _mesa_check_framebuffer_status(ctx, fb);
+}
+
+GLenum GLAPIENTRY
+_mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target)
+{
+   struct gl_framebuffer *fb;
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* Validate the target (for conformance's sake) and grab a reference to the
+* default framebuffer in case framebuffer = 0.
+* Section 9.4 Framebuffer Completeness of the OpenGL 4.5 core spec
+* (30.10.2014, PDF page 336) says:
+*"If framebuffer is zero, then the status of the default read or
+*draw framebuffer (as determined by target) is returned."
+*/
+   switch (target) {
+  case GL_DRAW_FRAMEBUFFER:
+  case GL_FRAMEBUFFER:
+ fb = ctx->WinSysDrawBuffer;
+ break;
+  case GL_READ_FRAMEBUFFER:
+ fb = ctx->WinSysReadBuffer;
+ break;
+  default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCheckNamedFramebufferStatus(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return 0;
+   }
+
+   if (framebuffer) {
+  fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+"glCheckNamedFramebufferStatus");
+  if (!fb)
+ return 0;
+   }
+
+   return _mesa_check_framebuffer_status(ctx, fb);
+}
+
 
 /**
  * Replicate the src attachment point. Used by framebuffer_texture() when
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 96d39a7..f078097 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -122,6 +122,10 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct 
gl_framebuffer *fb,
   GLint level, GLuint zoffset, bool layered,
   const char *caller);
 
+extern GLenum
+_mesa_check_framebuffer_status(struct gl_context *ctx,
+   struct gl_framebuffer *fb);
+
 
 extern GLboolean GLAPIENTRY
 _mesa_IsRenderbuffer(GLuint renderbuffer);
@@ -179,6 +183,9 @@ _mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers);
 extern GLenum GLAPIENTRY
 _mesa_CheckFramebufferStatus(GLenum target);
 
+extern GLenum GLAPIENTRY
+_mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target);
+
 extern void GLAPIENTRY
 _mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
   GLenum textarget, GLuint texture, GLint level);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index d72a04c..4dfac5c 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -974,6 +974,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferRenderbuffer", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
+   { "glCh

[Mesa-dev] [PATCH 07/38] main: Split framebuffer_texture.

2015-03-03 Thread Laura Ekstrand
Split apart utility function framebuffer_texture to better prepare for
implementing NamedFramebufferTexture and NamedFramebufferTextureLayer.  This
should also pave the way for some future cleanup work.
---
 src/mesa/main/fbobject.c | 270 ++-
 src/mesa/main/fbobject.h |   8 ++
 2 files changed, 204 insertions(+), 74 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 5062033..143c6b4 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2414,39 +2414,31 @@ reuse_framebuffer_texture_attachment(struct 
gl_framebuffer *fb,
 
 
 /**
- * Common code called by glFramebufferTexture1D/2D/3D() and
- * glFramebufferTextureLayer().
+ * Common code called by gl*FramebufferTexture*() to retrieve the correct
+ * texture object pointer and check for associated errors.
  *
  * \param textarget is the textarget that was passed to the
  * glFramebufferTexture...() function, or 0 if the corresponding function
  * doesn't have a textarget parameter.
  *
  * \param layered is true if this function was called from
- * glFramebufferTexture(), false otherwise.
+ * gl*FramebufferTexture(), false otherwise.
+ *
+ * \param texObj where the pointer to the texture object is returned.  Note
+ * that a successful call may return texObj = NULL.
+ *
+ * \return true if no errors, false if errors
  */
-static void
-framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
-GLenum attachment, GLenum textarget, GLuint texture,
-GLint level, GLuint zoffset, GLboolean layered)
+static bool
+get_texture_for_framebuffer(struct gl_context *ctx,
+GLuint texture, GLenum textarget,
+GLint level, GLuint zoffset, GLboolean *layered,
+const char *caller,
+struct gl_texture_object **texObj)
 {
-   struct gl_renderbuffer_attachment *att;
-   struct gl_texture_object *texObj = NULL;
-   struct gl_framebuffer *fb;
GLenum maxLevelsTarget;
 
-   fb = get_framebuffer_target(ctx, target);
-   if (!fb) {
-  _mesa_error(ctx, GL_INVALID_ENUM,
-  "glFramebufferTexture%s(target=0x%x)", caller, target);
-  return;
-   }
-
-   /* check framebuffer binding */
-   if (_mesa_is_winsys_fbo(fb)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  "glFramebufferTexture%s", caller);
-  return;
-   }
+   *texObj = NULL; /* This will get returned if texture = 0. */
 
/* The textarget, level, and zoffset parameters are only validated if
 * texture is non-zero.
@@ -2454,14 +2446,14 @@ framebuffer_texture(struct gl_context *ctx, const char 
*caller, GLenum target,
if (texture) {
   GLboolean err = GL_TRUE;
 
-  texObj = _mesa_lookup_texture(ctx, texture);
-  if (texObj != NULL) {
+  *texObj = _mesa_lookup_texture(ctx, texture);
+  if (*texObj != NULL) {
  if (textarget == 0) {
-if (layered) {
-   /* We're being called by glFramebufferTexture() and textarget
+if (*layered) {
+   /* We're being called by gl*FramebufferTexture() and textarget
 * is not used.
 */
-   switch (texObj->Target) {
+   switch ((*texObj)->Target) {
case GL_TEXTURE_3D:
case GL_TEXTURE_1D_ARRAY_EXT:
case GL_TEXTURE_2D_ARRAY_EXT:
@@ -2479,8 +2471,8 @@ framebuffer_texture(struct gl_context *ctx, const char 
*caller, GLenum target,
* is equivalent to calling glFramebufferTexture{1D,2D}().
*/
   err = false;
-  layered = false;
-  textarget = texObj->Target;
+  *layered = false;
+  textarget = (*texObj)->Target;
   break;
default:
   err = true;
@@ -2491,67 +2483,95 @@ framebuffer_texture(struct gl_context *ctx, const char 
*caller, GLenum target,
 * textarget is not used.  The only legal texture types for
 * that function are 3D and 1D/2D arrays textures.
 */
-   err = (texObj->Target != GL_TEXTURE_3D) &&
-  (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
-  (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
-  (texObj->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
-  (texObj->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
+   err = ((*texObj)->Target != GL_TEXTURE_3D) &&
+  ((*texObj)->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
+  ((*texObj)->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
+  ((*texObj)->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
+  ((*texObj)->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
 }
  }
  else {
 /* Make sure textarget

[Mesa-dev] [PATCH 06/38] main: Removed tabs in framebuffer_texture.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/fbobject.c | 49 
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 3895328..5062033 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2565,34 +2565,35 @@ framebuffer_texture(struct gl_context *ctx, const char 
*caller, GLenum target,
   _mesa_tex_target_to_face(textarget) ==
   fb->Attachment[BUFFER_STENCIL].CubeMapFace &&
   zoffset == fb->Attachment[BUFFER_STENCIL].Zoffset) {
-/* The texture object is already attached to the stencil attachment
- * point. Don't create a new renderbuffer; just reuse the stencil
- * attachment's. This is required to prevent a GL error in
- * glGetFramebufferAttachmentParameteriv(GL_DEPTH_STENCIL).
- */
-reuse_framebuffer_texture_attachment(fb, BUFFER_DEPTH,
- BUFFER_STENCIL);
+ /* The texture object is already attached to the stencil attachment
+  * point. Don't create a new renderbuffer; just reuse the stencil
+  * attachment's. This is required to prevent a GL error in
+  * glGetFramebufferAttachmentParameteriv(GL_DEPTH_STENCIL).
+  */
+ reuse_framebuffer_texture_attachment(fb, BUFFER_DEPTH,
+  BUFFER_STENCIL);
   } else if (attachment == GL_STENCIL_ATTACHMENT &&
-texObj == fb->Attachment[BUFFER_DEPTH].Texture &&
+ texObj == fb->Attachment[BUFFER_DEPTH].Texture &&
  level == fb->Attachment[BUFFER_DEPTH].TextureLevel &&
  _mesa_tex_target_to_face(textarget) ==
  fb->Attachment[BUFFER_DEPTH].CubeMapFace &&
  zoffset == fb->Attachment[BUFFER_DEPTH].Zoffset) {
-/* As above, but with depth and stencil transposed. */
-reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL,
- BUFFER_DEPTH);
+ /* As above, but with depth and stencil transposed. */
+ reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL,
+  BUFFER_DEPTH);
   } else {
-set_texture_attachment(ctx, fb, att, texObj, textarget,
- level, zoffset, layered);
-if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
-   /* Above we created a new renderbuffer and attached it to the
-* depth attachment point. Now attach it to the stencil attachment
-* point too.
-*/
-   assert(att == &fb->Attachment[BUFFER_DEPTH]);
-   reuse_framebuffer_texture_attachment(fb,BUFFER_STENCIL,
-BUFFER_DEPTH);
-}
+ set_texture_attachment(ctx, fb, att, texObj, textarget,
+level, zoffset, layered);
+
+ if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
+/* Above we created a new renderbuffer and attached it to the
+ * depth attachment point. Now attach it to the stencil attachment
+ * point too.
+ */
+assert(att == &fb->Attachment[BUFFER_DEPTH]);
+reuse_framebuffer_texture_attachment(fb,BUFFER_STENCIL,
+BUFFER_DEPTH);
+ }
   }
 
   /* Set the render-to-texture flag.  We'll check this flag in
@@ -2608,8 +2609,8 @@ framebuffer_texture(struct gl_context *ctx, const char 
*caller, GLenum target,
else {
   remove_attachment(ctx, att);
   if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
-assert(att == &fb->Attachment[BUFFER_DEPTH]);
-remove_attachment(ctx, &fb->Attachment[BUFFER_STENCIL]);
+ assert(att == &fb->Attachment[BUFFER_DEPTH]);
+ remove_attachment(ctx, &fb->Attachment[BUFFER_STENCIL]);
   }
}
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 08/38] main: Refactor get_texture_for_framebuffer.

2015-03-03 Thread Laura Ekstrand
This moves a few blocks around so that the control flow is more obvious.  If
the texture is 0, just return true at the beginning of the function.
Likewise, if the texObj is NULL, return true at the beginning of the funciton
as well.
---
 src/mesa/main/fbobject.c | 43 +--
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 143c6b4..f86e1a0 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2437,17 +2437,34 @@ get_texture_for_framebuffer(struct gl_context *ctx,
 struct gl_texture_object **texObj)
 {
GLenum maxLevelsTarget;
+   GLboolean err = GL_TRUE;
 
*texObj = NULL; /* This will get returned if texture = 0. */
 
/* The textarget, level, and zoffset parameters are only validated if
 * texture is non-zero.
 */
-   if (texture) {
-  GLboolean err = GL_TRUE;
+   if (!texture)
+  return true;
+
+   *texObj = _mesa_lookup_texture(ctx, texture);
+   if (!texObj) {
+  /* Can't render to a non-existant texture object.
+   *
+   * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
+   * Managing Framebuffer Objects specifies a different error
+   * depending upon the calling function (PDF pages 325-328).
+   * *FramebufferTexture (where *layered = GL_TRUE) throws invalid
+   * value, while the other commands throw invalid operation (where
+   * *layered = GL_FALSE).
+   */
+  GLenum no_texobj_err = *layered ? GL_INVALID_VALUE :
+ GL_INVALID_OPERATION;
+  _mesa_error(ctx, no_texobj_err,
+  "%s(non-generated texture %u)", caller, texture);
+  return false;
+   }
 
-  *texObj = _mesa_lookup_texture(ctx, texture);
-  if (*texObj != NULL) {
  if (textarget == 0) {
 if (*layered) {
/* We're being called by gl*FramebufferTexture() and textarget
@@ -2496,23 +2513,6 @@ get_texture_for_framebuffer(struct gl_context *ctx,
 ? !_mesa_is_cube_face(textarget)
 : ((*texObj)->Target != textarget);
  }
-  }
-  else {
- /* Can't render to a non-existant texture object.
-  *
-  * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
-  * Managing Framebuffer Objects specifies a different error
-  * depending upon the calling function (PDF pages 325-328).
-  * *FramebufferTexture (where *layered = GL_TRUE) throws invalid
-  * value, while the other commands throw invalid operation (where
-  * *layered = GL_FALSE).
-  */
- GLenum no_texobj_err = *layered ? GL_INVALID_VALUE :
-GL_INVALID_OPERATION;
- _mesa_error(ctx, no_texobj_err,
- "%s(non-generated texture %u)", caller, texture);
- return false;
-  }
 
   if (err) {
  _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -2546,7 +2546,6 @@ get_texture_for_framebuffer(struct gl_context *ctx,
  "%s(invalid level %d)", caller, level);
  return false;
   }
-   }
 
return true;
 }
-- 
2.1.0

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


[Mesa-dev] [PATCH 35/38] main: Refactor _mesa_ReadBuffer.

2015-03-03 Thread Laura Ekstrand
This could have added a new DD table entry for ReadBuffer that takes an
arbitrary read buffer, but, after looking at the existing DD functions,
Kenneth Graunke recommended that we just skip calling the DD functions in the
case of ARB_direct_state_access.  The DD implementations for ReadBuffer
have limited functionality, especially with respect to
ARB_direct_state_access.
---
 src/mesa/main/buffers.c | 45 +
 src/mesa/main/buffers.h |  7 ++-
 src/mesa/main/context.c |  2 +-
 3 files changed, 32 insertions(+), 22 deletions(-)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 8d95c68..e244d1e 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -624,11 +624,10 @@ _mesa_update_draw_buffers(struct gl_context *ctx)
  * \param bufferIndex  the numerical index corresponding to 'buffer'
  */
 void
-_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex)
+_mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, GLint bufferIndex)
 {
-   struct gl_framebuffer *fb = ctx->ReadBuffer;
-
-   if (_mesa_is_winsys_fbo(fb)) {
+   if ((fb == ctx->ReadBuffer) && _mesa_is_winsys_fbo(fb)) {
   /* Only update the per-context READ_BUFFER state if we're bound to
* a window-system framebuffer.
*/
@@ -647,23 +646,17 @@ _mesa_readbuffer(struct gl_context *ctx, GLenum buffer, 
GLint bufferIndex)
  * Called by glReadBuffer to set the source renderbuffer for reading pixels.
  * \param mode color buffer such as GL_FRONT, GL_BACK, etc.
  */
-void GLAPIENTRY
-_mesa_ReadBuffer(GLenum buffer)
+void
+_mesa_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+  GLenum buffer, const char *caller)
 {
-   struct gl_framebuffer *fb;
GLbitfield supportedMask;
GLint srcBuffer;
-   GET_CURRENT_CONTEXT(ctx);
 
FLUSH_VERTICES(ctx, 0);
 
if (MESA_VERBOSE & VERBOSE_API)
-  _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
-
-   fb = ctx->ReadBuffer;
-
-   if (MESA_VERBOSE & VERBOSE_API)
-  _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+  _mesa_debug(ctx, "%s %s\n", caller, _mesa_lookup_enum_by_nr(buffer));
 
if (buffer == GL_NONE) {
   /* This is legal--it means that no buffer should be bound for reading. */
@@ -674,24 +667,36 @@ _mesa_ReadBuffer(GLenum buffer)
   srcBuffer = read_buffer_enum_to_index(buffer);
   if (srcBuffer == -1) {
  _mesa_error(ctx, GL_INVALID_ENUM,
- "glReadBuffer(buffer=0x%x)", buffer);
+ "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
  return;
   }
   supportedMask = supported_buffer_bitmask(ctx, fb);
   if (((1 << srcBuffer) & supportedMask) == 0) {
  _mesa_error(ctx, GL_INVALID_OPERATION,
- "glReadBuffer(buffer=0x%x)", buffer);
+ "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
  return;
   }
}
 
/* OK, all error checking has been completed now */
 
-   _mesa_readbuffer(ctx, buffer, srcBuffer);
+   _mesa_readbuffer(ctx, fb, buffer, srcBuffer);
 
/*
-* Call device driver function.
+* Call the device driver function only if caller is the traditional entry
+* point.
 */
-   if (ctx->Driver.ReadBuffer)
-  (*ctx->Driver.ReadBuffer)(ctx, buffer);
+   if (strcmp(caller, "glReadBuffer") == 0) {
+  if (ctx->Driver.ReadBuffer)
+ (*ctx->Driver.ReadBuffer)(ctx, buffer);
+   }
+}
+
+void GLAPIENTRY
+_mesa_ReadBuffer(GLenum buffer)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   _mesa_read_buffer(ctx, ctx->ReadBuffer, buffer, "glReadBuffer");
 }
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index 12d5743..ca7ad19 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -57,12 +57,17 @@ _mesa_drawbuffers(struct gl_context *ctx, struct 
gl_framebuffer *fb,
   const GLbitfield *destMask);
 
 extern void
-_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex);
+_mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, GLint bufferIndex);
 
 extern void
 _mesa_update_draw_buffers(struct gl_context *ctx);
 
 
+extern void
+_mesa_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+  GLenum buffer, const char *caller);
+
 extern void GLAPIENTRY
 _mesa_ReadBuffer( GLenum mode );
 
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index b285d51..8ea9e33 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1581,7 +1581,7 @@ handle_first_current(struct gl_context *ctx)
 bufferIndex = BUFFER_FRONT_LEFT;
  }
 
- _mesa_readbuffer(ctx, buffer, bufferIndex);
+ _mesa_readbuffer(ctx, ctx->ReadBuffer, buffer, bufferIndex);
   }
}
 
-- 

[Mesa-dev] [PATCH 02/38] main: Add glCreateFramebuffers.

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +
 src/mesa/main/fbobject.c   | 40 ++
 src/mesa/main/fbobject.h   |  3 ++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 641e68f..85ef1f6 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -111,6 +111,13 @@
   

 
+   
+
+   
+  
+  
+   
+

 

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8c2eb25..b361967 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2274,15 +2274,23 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint 
*framebuffers)
 }
 
 
-void GLAPIENTRY
-_mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
+/**
+ * This is the implementation for glGenFramebuffers and glCreateFramebuffers.
+ * It is not exposed to the rest of Mesa to encourage the use of
+ * nameless buffers in driver internals.
+ */
+static void
+create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa)
 {
GET_CURRENT_CONTEXT(ctx);
GLuint first;
GLint i;
+   struct gl_framebuffer *fb;
+
+   const char *func = dsa ? "glCreateFramebuffers" : "glGenFramebuffers";
 
if (n < 0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)");
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
   return;
}
 
@@ -2294,13 +2302,35 @@ _mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
for (i = 0; i < n; i++) {
   GLuint name = first + i;
   framebuffers[i] = name;
-  /* insert dummy placeholder into hash table */
+
+  if (dsa) {
+ fb = ctx->Driver.NewFramebuffer(ctx, framebuffers[i]);
+ if (!fb) {
+_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
+return;
+ }
+  }
+  else
+ fb = &DummyFramebuffer;
+
   mtx_lock(&ctx->Shared->Mutex);
-  _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer);
+  _mesa_HashInsert(ctx->Shared->FrameBuffers, name, fb);
   mtx_unlock(&ctx->Shared->Mutex);
}
 }
 
+void GLAPIENTRY
+_mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
+{
+   create_framebuffers(n, framebuffers, false);
+}
+
+void GLAPIENTRY
+_mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers)
+{
+   create_framebuffers(n, framebuffers, true);
+}
+
 
 GLenum GLAPIENTRY
 _mesa_CheckFramebufferStatus(GLenum target)
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 7aa5205..6bd8968 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -153,6 +153,9 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint 
*framebuffers);
 extern void GLAPIENTRY
 _mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers);
 
+extern void GLAPIENTRY
+_mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers);
+
 extern GLenum GLAPIENTRY
 _mesa_CheckFramebufferStatus(GLenum target);
 
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 69fb8d0..ee8b20f 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -970,6 +970,7 @@ const struct function gl_core_functions_possible[] = {
{ "glGetNamedBufferParameteri64v", 45, -1 },
{ "glGetNamedBufferPointerv", 45, -1 },
{ "glGetNamedBufferSubData", 45, -1 },
+   { "glCreateFramebuffers", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTextureStorage1D", 45, -1 },
{ "glTextureStorage2D", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 27/38] main: Fake entry point for glClearNamedFramebufferiv.

2015-03-03 Thread Laura Ekstrand
Mesa's ClearBuffer framework is very complicated and thoroughly married to the
object binding model.  Moreover, the OpenGL spec for ClearBuffer is also very
complicated.  At some point, we should implement buffer clearing for arbitrary
framebuffer objects, but for now, we will just wrap ClearBuffer.
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/clear.c  | 19 +++
 src/mesa/main/clear.h  |  4 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 31 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 0939b8b..0ab0db4 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -156,6 +156,13 @@
   

 
+   
+  
+  
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 8d707bc..40bf0be 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -34,6 +34,8 @@
 #include "clear.h"
 #include "context.h"
 #include "enums.h"
+#include "fbobject.h"
+#include "get.h"
 #include "macros.h"
 #include "mtypes.h"
 #include "state.h"
@@ -398,6 +400,23 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
}
 }
 
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
+  GLint drawbuffer, const GLint *value)
+{
+   GLint oldfb;
+
+   _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+   _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+   _mesa_ClearBufferiv(buffer, drawbuffer, value);
+   _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
 
 /**
  * New in GL 3.0
diff --git a/src/mesa/main/clear.h b/src/mesa/main/clear.h
index 96ce47b..d0b6133 100644
--- a/src/mesa/main/clear.h
+++ b/src/mesa/main/clear.h
@@ -52,6 +52,10 @@ extern void GLAPIENTRY
 _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value);
 
 extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
+  GLint drawbuffer, const GLint *value);
+
+extern void GLAPIENTRY
 _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value);
 
 extern void GLAPIENTRY
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 312e253..a24f571 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -976,6 +976,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
+   { "glClearNamedFramebufferiv", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 01/38] main: Add utility function _mesa_lookup_framebuffer_err.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/fbobject.c | 18 ++
 src/mesa/main/fbobject.h |  4 
 2 files changed, 22 insertions(+)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f8d0d92..8c2eb25 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -136,6 +136,24 @@ _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id)
return fb;
 }
 
+/**
+ * A convenience function for direct state access that throws
+ * GL_INVALID_OPERATION if the framebuffer id is not found in the hash table.
+ */
+struct gl_framebuffer *
+_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func)
+{
+   struct gl_framebuffer *fb;
+
+   fb = _mesa_lookup_framebuffer(ctx, id);
+   if (!fb)
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(non-generated framebuffer name=%u)", func, id);
+
+   return fb;
+}
+
 
 /**
  * Mark the given framebuffer as invalid.  This will force the
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 77fdef4..7aa5205 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -67,6 +67,10 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id);
 extern struct gl_framebuffer *
 _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);
 
+extern struct gl_framebuffer *
+_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func);
+
 
 void
 _mesa_update_texture_renderbuffer(struct gl_context *ctx,
-- 
2.1.0

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


[Mesa-dev] [PATCH 33/38] main: Refactor _mesa_DrawBuffer.

2015-03-03 Thread Laura Ekstrand
This could have added a new DD table entry for DrawBuffer that takes an
arbitrary draw buffer, but, after looking at the existing DD functions,
Kenneth Graunke recommended that we just skip calling the DD functions in the
case of ARB_direct_state_access.  The DD implementations for DrawBuffer(s)
have limited functionality, especially with respect to
ARB_direct_state_access.
---
 src/mesa/main/buffers.c | 39 ---
 src/mesa/main/buffers.h |  4 
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 4fdd97e..023d7dd 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -242,16 +242,16 @@ read_buffer_enum_to_index(GLenum buffer)
  *
  * See the GL_EXT_framebuffer_object spec for more info.
  */
-void GLAPIENTRY
-_mesa_DrawBuffer(GLenum buffer)
+void
+_mesa_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+  GLenum buffer, const char *caller)
 {
GLbitfield destMask;
-   GET_CURRENT_CONTEXT(ctx);
 
FLUSH_VERTICES(ctx, 0);
 
if (MESA_VERBOSE & VERBOSE_API) {
-  _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+  _mesa_debug(ctx, "%s %s\n", caller, _mesa_lookup_enum_by_nr(buffer));
}
 
if (buffer == GL_NONE) {
@@ -259,33 +259,42 @@ _mesa_DrawBuffer(GLenum buffer)
}
else {
   const GLbitfield supportedMask
- = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
+ = supported_buffer_bitmask(ctx, fb);
   destMask = draw_buffer_enum_to_bitmask(ctx, buffer);
   if (destMask == BAD_MASK) {
  /* totally bogus buffer */
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glDrawBuffer(buffer=0x%x)", buffer);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
  return;
   }
   destMask &= supportedMask;
   if (destMask == 0x0) {
  /* none of the named color buffers exist! */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawBuffer(buffer=0x%x)", buffer);
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffer));
  return;
   }
}
 
/* if we get here, there's no error so set new state */
-   _mesa_drawbuffers(ctx, ctx->DrawBuffer, 1, &buffer, &destMask);
+   _mesa_drawbuffers(ctx, fb, 1, &buffer, &destMask);
 
/*
-* Call device driver function.
+* Call device driver function only if calling the traditional entry point.
 */
-   if (ctx->Driver.DrawBuffers)
-  ctx->Driver.DrawBuffers(ctx, 1, &buffer);
-   else if (ctx->Driver.DrawBuffer)
-  ctx->Driver.DrawBuffer(ctx, buffer);
+   if (strcmp(caller, "glDrawBuffer") == 0) {
+  if (ctx->Driver.DrawBuffers)
+ ctx->Driver.DrawBuffers(ctx, 1, &buffer);
+  else if (ctx->Driver.DrawBuffer)
+ ctx->Driver.DrawBuffer(ctx, buffer);
+   }
+}
+
+void GLAPIENTRY
+_mesa_DrawBuffer(GLenum buffer)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   _mesa_draw_buffer(ctx, ctx->DrawBuffer, buffer, "glDrawBuffer");
 }
 
 
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index bc6d74a..4192afd 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -38,6 +38,10 @@
 struct gl_context;
 struct gl_framebuffer;
 
+extern void
+_mesa_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+  GLenum buffer, const char *caller);
+
 extern void GLAPIENTRY
 _mesa_DrawBuffer( GLenum mode );
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 37/38] main: Refactor DrawBuffers.

2015-03-03 Thread Laura Ekstrand
This could have added a new DD table entry for DrawBuffers that takes an
arbitrary draw buffer, but, after looking at the existing DD functions,
Kenneth Graunke recommended that we just skip calling the DD functions in the
case of ARB_direct_state_access.  The DD implementations for DrawBuffer(s)
have limited functionality, especially with respect to
ARB_direct_state_access.
---
 src/mesa/main/buffers.c | 70 +
 src/mesa/main/buffers.h |  4 +++
 2 files changed, 51 insertions(+), 23 deletions(-)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index d0627b5..32986f5 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -325,13 +325,13 @@ _mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, 
GLenum buf)
  * names cannot specify more than one buffer.  For example,
  * GL_FRONT_AND_BACK is illegal.
  */
-void GLAPIENTRY
-_mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
+void
+_mesa_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+   GLsizei n, const GLenum *buffers, const char *caller)
 {
GLuint output;
GLbitfield usedBufferMask, supportedMask;
GLbitfield destMask[MAX_DRAW_BUFFERS];
-   GET_CURRENT_CONTEXT(ctx);
 
FLUSH_VERTICES(ctx, 0);
 
@@ -342,12 +342,18 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
 * "An INVALID_VALUE error is generated if n is greater than
 *  MAX_DRAW_BUFFERS."
 */
-   if (n < 0 || n > (GLsizei) ctx->Const.MaxDrawBuffers) {
-  _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)");
+   if (n < 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", caller);
+  return;
+   }
+
+   if (n > (GLsizei) ctx->Const.MaxDrawBuffers) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "%s(n > maximum number of draw buffers)", caller);
   return;
}
 
-   supportedMask = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
+   supportedMask = supported_buffer_bitmask(ctx, fb);
usedBufferMask = 0x0;
 
/* From the ES 3.0 specification, page 180:
@@ -355,9 +361,9 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
 *  and the constant must be BACK or NONE."
 * (same restriction applies with GL_EXT_draw_buffers specification)
 */
-   if (ctx->API == API_OPENGLES2 && _mesa_is_winsys_fbo(ctx->DrawBuffer) &&
+   if (ctx->API == API_OPENGLES2 && _mesa_is_winsys_fbo(fb) &&
(n != 1 || (buffers[0] != GL_NONE && buffers[0] != GL_BACK))) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid buffers)", caller);
   return;
}
 
@@ -389,9 +395,11 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
   * or equal to the value of MAX_COLOR_ATTACHMENTS, then the error
   * INVALID_OPERATION results."
   */
- if (_mesa_is_user_fbo(ctx->DrawBuffer) && buffers[output] >=
+ if (_mesa_is_user_fbo(fb) && buffers[output] >=
  GL_COLOR_ATTACHMENT0 + ctx->Const.MaxDrawBuffers) {
-_mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffersARB(buffer)");
+_mesa_error(ctx, GL_INVALID_OPERATION,
+"%s(buffers[%d] >= maximum number of draw buffers)",
+caller, output);
 return;
  }
 
@@ -402,9 +410,10 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
   *  4.5 or 4.6.  Otherwise, an INVALID_ENUM error is generated.
   */
  if (destMask[output] == BAD_MASK) {
-_mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)");
+_mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)",
+caller, _mesa_lookup_enum_by_nr(buffers[output]));
 return;
- } 
+ }
 
  /* From the OpenGL 4.0 specification, page 256:
   * "For both the default framebuffer and framebuffer objects, the
@@ -417,7 +426,8 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
   *  but the Khronos conformance tests expect INVALID_ENUM.
   */
  if (_mesa_bitcount(destMask[output]) > 1) {
-_mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)");
+_mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)",
+caller, _mesa_lookup_enum_by_nr(buffers[output]));
 return;
  }
 
@@ -434,7 +444,8 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
  destMask[output] &= supportedMask;
  if (destMask[output] == 0) {
 _mesa_error(ctx, GL_INVALID_OPERATION,
-"glDrawBuffersARB(unsupported buffer)");
+"%s(unsupported buffer %s)",
+caller, _mesa_lookup_enum_by_nr(buffers[output]));
 return;
  }
 
@@ -443,10 +454,12 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
  

[Mesa-dev] [PATCH 03/38] main: Add utility function _mesa_lookup_renderbuffer_err.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/fbobject.c | 18 ++
 src/mesa/main/fbobject.h |  4 
 2 files changed, 22 insertions(+)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index b361967..8bc7ec7 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -119,6 +119,24 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint 
id)
return rb;
 }
 
+/**
+ * A convenience function for direct state access that throws
+ * GL_INVALID_OPERATION if the renderbuffer id is not found in the hash table.
+ */
+struct gl_renderbuffer *
+_mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id,
+  const char *func)
+{
+   struct gl_renderbuffer *rb;
+
+   rb = _mesa_lookup_renderbuffer(ctx, id);
+   if (!rb)
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(non-generated renderbuffer name=%u)", func, id);
+
+   return rb;
+}
+
 
 /**
  * Helper routine for getting a gl_framebuffer.
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 6bd8968..5143743 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -64,6 +64,10 @@ _mesa_get_incomplete_framebuffer(void);
 extern struct gl_renderbuffer *
 _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id);
 
+extern struct gl_renderbuffer *
+_mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id,
+  const char *func);
+
 extern struct gl_framebuffer *
 _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 14/38] main: Add entry point GetNamedFramebufferAttachmentParameteriv.

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |   7 ++
 src/mesa/main/fbobject.c   | 131 -
 src/mesa/main/fbobject.h   |  10 ++
 src/mesa/main/tests/dispatch_sanity.cpp|   1 +
 4 files changed, 103 insertions(+), 46 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 20c2e7b..36de3c1 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -146,6 +146,13 @@
   

 
+   
+  
+  
+  
+  
+   
+

 

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 6ed82d5..467a8cd 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3142,25 +3142,18 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, 
GLenum attachment,
 }
 
 
-void GLAPIENTRY
-_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
-  GLenum pname, GLint *params)
+void
+_mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
+   struct gl_framebuffer *buffer,
+   GLenum attachment, GLenum pname,
+   GLint *params, const char *caller)
 {
const struct gl_renderbuffer_attachment *att;
-   struct gl_framebuffer *buffer;
GLenum err;
-   GET_CURRENT_CONTEXT(ctx);
 
/* The error differs in GL and GLES. */
err = _mesa_is_desktop_gl(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
 
-   buffer = get_framebuffer_target(ctx, target);
-   if (!buffer) {
-  _mesa_error(ctx, GL_INVALID_ENUM,
-  "glGetFramebufferAttachmentParameteriv(target)");
-  return;
-   }
-
if (_mesa_is_winsys_fbo(buffer)) {
   /* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec
* says:
@@ -3175,15 +3168,15 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum 
target, GLenum attachment,
   if ((!_mesa_is_desktop_gl(ctx) ||
!ctx->Extensions.ARB_framebuffer_object)
   && !_mesa_is_gles3(ctx)) {
-_mesa_error(ctx, GL_INVALID_OPERATION,
-"glGetFramebufferAttachmentParameteriv(bound FBO = 0)");
-return;
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(bound FBO = 0)", caller);
+ return;
   }
 
   if (_mesa_is_gles3(ctx) && attachment != GL_BACK &&
   attachment != GL_DEPTH && attachment != GL_STENCIL) {
  _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(attachment)");
+ "%s(invalid attachment %s)", caller,
+ _mesa_lookup_enum_by_nr(attachment));
  return;
   }
   /* the default / window-system FBO */
@@ -3195,8 +3188,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, 
GLenum attachment,
}
 
if (att == NULL) {
-  _mesa_error(ctx, GL_INVALID_ENUM,
-  "glGetFramebufferAttachmentParameteriv(attachment)");
+  _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
+  _mesa_lookup_enum_by_nr(attachment));
   return;
}
 
@@ -3210,9 +3203,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, 
GLenum attachment,
   *attachment, since it does not have a single format."
   */
  _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv("
- "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
- " is invalid for depth+stencil attachment)");
+ "%s(GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
+ " is invalid for depth+stencil attachment)", caller);
  return;
   }
   /* the depth and stencil attachments must point to the same buffer */
@@ -3220,8 +3212,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, 
GLenum attachment,
   stencilAtt = get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT);
   if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) {
  _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv(DEPTH/STENCIL"
- " attachments differ)");
+ "%s(DEPTH/STENCIL attachments differ)", caller);
  return;
   }
}
@@ -3235,10 +3226,10 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum 
target, GLenum attachment,
   return;
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
   if (att->Type == GL_RENDERBUFFER_EXT) {
-*params = att->Renderbuffer->Name;
+ *params = att->Renderbuffer->Name;
   }
   else if (att->Type == GL_TEXTURE) {
-*params = att->Texture->Name;
+ *params = att->Texture->Name;
   }
   else {
  assert(att->Type == GL_NONE);
@@ -3251,11 +3242,11 @@ _me

[Mesa-dev] [PATCH 05/38] main: Add entry point for NamedFramebufferRenderbuffer.

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |   7 ++
 src/mesa/main/fbobject.c   | 139 +
 src/mesa/main/fbobject.h   |  12 +++
 src/mesa/main/tests/dispatch_sanity.cpp|   1 +
 4 files changed, 115 insertions(+), 44 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 85ef1f6..b954343 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -118,6 +118,13 @@
   

 
+   
+  
+  
+  
+  
+   
+

 

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 948ac91..3895328 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2748,71 +2748,37 @@ _mesa_FramebufferTexture(GLenum target, GLenum 
attachment,
 }
 
 
-void GLAPIENTRY
-_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
-  GLenum renderbufferTarget,
-  GLuint renderbuffer)
+void
+_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
+   struct gl_framebuffer *fb,
+   GLenum attachment,
+   struct gl_renderbuffer *rb,
+   const char *func)
 {
struct gl_renderbuffer_attachment *att;
-   struct gl_framebuffer *fb;
-   struct gl_renderbuffer *rb;
-   GET_CURRENT_CONTEXT(ctx);
-
-   fb = get_framebuffer_target(ctx, target);
-   if (!fb) {
-  _mesa_error(ctx, GL_INVALID_ENUM,
-  "glFramebufferRenderbuffer(target)");
-  return;
-   }
-
-   if (renderbufferTarget != GL_RENDERBUFFER_EXT) {
-  _mesa_error(ctx, GL_INVALID_ENUM,
-  "glFramebufferRenderbuffer(renderbufferTarget)");
-  return;
-   }
 
if (_mesa_is_winsys_fbo(fb)) {
   /* Can't attach new renderbuffers to a window system framebuffer */
-  _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbuffer");
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(default framebuffer bound)", func);
   return;
}
 
att = get_attachment(ctx, fb, attachment);
if (att == NULL) {
   _mesa_error(ctx, GL_INVALID_ENUM,
-  "glFramebufferRenderbuffer(invalid attachment %s)",
+  "%s(invalid attachment %s)", func,
   _mesa_lookup_enum_by_nr(attachment));
   return;
}
 
-   if (renderbuffer) {
-  rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
-  if (!rb) {
-_mesa_error(ctx, GL_INVALID_OPERATION,
-"glFramebufferRenderbuffer(non-existant"
- " renderbuffer %u)", renderbuffer);
-return;
-  }
-  else if (rb == &DummyRenderbuffer) {
-_mesa_error(ctx, GL_INVALID_OPERATION,
-"glFramebufferRenderbuffer(renderbuffer %u)",
- renderbuffer);
-return;
-  }
-   }
-   else {
-  /* remove renderbuffer attachment */
-  rb = NULL;
-   }
-
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT &&
rb && rb->Format != MESA_FORMAT_NONE) {
   /* make sure the renderbuffer is a depth/stencil format */
   const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
   if (baseFormat != GL_DEPTH_STENCIL) {
  _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferRenderbuffer(renderbuffer"
- " is not DEPTH_STENCIL format)");
+ "%s(renderbuffer is not DEPTH_STENCIL format)", func);
  return;
   }
}
@@ -2828,6 +2794,91 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum 
attachment,
_mesa_update_framebuffer_visual(ctx, fb);
 }
 
+void GLAPIENTRY
+_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
+  GLenum renderbuffertarget,
+  GLuint renderbuffer)
+{
+   struct gl_framebuffer *fb;
+   struct gl_renderbuffer *rb;
+   GET_CURRENT_CONTEXT(ctx);
+
+   fb = get_framebuffer_target(ctx, target);
+   if (!fb) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "glFramebufferRenderbuffer(invalid target %s)",
+  _mesa_lookup_enum_by_nr(target));
+  return;
+   }
+
+   if (renderbuffertarget != GL_RENDERBUFFER_EXT) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "glFramebufferRenderbuffer(renderbuffer target is not "
+  "GL_RENDERBUFFER)");
+  return;
+   }
+
+   if (renderbuffer) {
+  rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer,
+ "glFramebufferRenderbuffer");
+  if (!rb)
+ return;
+  else if (rb == &DummyRenderbuffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glFramebufferRenderbuffer(renderbuffer=%u never bound)",
+ renderbuffer);
+ retur

[Mesa-dev] [PATCH 34/38] main: Add entry point for NamedFramebufferDrawBuffer.

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  5 +
 src/mesa/main/buffers.c| 18 ++
 src/mesa/main/buffers.h|  3 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 27 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 025a1a8..c472163 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -146,6 +146,11 @@
   

 
+   
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 023d7dd..8d95c68 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -297,6 +297,24 @@ _mesa_DrawBuffer(GLenum buffer)
_mesa_draw_buffer(ctx, ctx->DrawBuffer, buffer, "glDrawBuffer");
 }
 
+void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb;
+
+   if (framebuffer) {
+  fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+"glNamedFramebufferDrawBuffer");
+  if (!fb)
+ return;
+   }
+   else
+  fb = ctx->WinSysDrawBuffer;
+
+   _mesa_draw_buffer(ctx, fb, buf, "glNamedFramebufferDrawBuffer");
+}
+
 
 /**
  * Called by glDrawBuffersARB; specifies the destination color renderbuffers
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index 4192afd..12d5743 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -46,6 +46,9 @@ extern void GLAPIENTRY
 _mesa_DrawBuffer( GLenum mode );
 
 extern void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf);
+
+extern void GLAPIENTRY
 _mesa_DrawBuffers(GLsizei n, const GLenum *buffers);
 
 extern void
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 01a3d14..16caf24 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -975,6 +975,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferParameteri", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
+   { "glNamedFramebufferDrawBuffer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
{ "glClearNamedFramebufferiv", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 32/38] main: Refactor _mesa_drawbuffers.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/drivers/common/meta.c |  3 ++-
 src/mesa/main/buffers.c| 25 -
 src/mesa/main/buffers.h|  4 +++-
 src/mesa/main/context.c|  3 ++-
 src/mesa/main/framebuffer.c|  2 +-
 5 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index fdc4cf1..6bd5ab4 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1210,7 +1210,8 @@ _mesa_meta_end(struct gl_context *ctx)
   _mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);
 
if (state & MESA_META_DRAW_BUFFERS) {
-  _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, 
save->ColorDrawBuffers, NULL);
+  _mesa_drawbuffers(ctx, ctx->DrawBuffer, ctx->Const.MaxDrawBuffers,
+save->ColorDrawBuffers, NULL);
}
 
ctx->Meta->SaveStackDepth--;
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 37a9790..4fdd97e 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -277,7 +277,7 @@ _mesa_DrawBuffer(GLenum buffer)
}
 
/* if we get here, there's no error so set new state */
-   _mesa_drawbuffers(ctx, 1, &buffer, &destMask);
+   _mesa_drawbuffers(ctx, ctx->DrawBuffer, 1, &buffer, &destMask);
 
/*
 * Call device driver function.
@@ -440,7 +440,7 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
}
 
/* OK, if we get here, there were no errors so set the new state */
-   _mesa_drawbuffers(ctx, n, buffers, destMask);
+   _mesa_drawbuffers(ctx, ctx->DrawBuffer, n, buffers, destMask);
 
/*
 * Call device driver function.  Note that n can be equal to 0,
@@ -459,12 +459,11 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
  * actual change.
  */
 static void
-updated_drawbuffers(struct gl_context *ctx)
+updated_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb)
 {
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
 
if (ctx->API == API_OPENGL_COMPAT && 
!ctx->Extensions.ARB_ES2_compatibility) {
-  struct gl_framebuffer *fb = ctx->DrawBuffer;
 
   /* Flag the FBO as requiring validation. */
   if (_mesa_is_user_fbo(fb)) {
@@ -482,6 +481,7 @@ updated_drawbuffers(struct gl_context *ctx)
  * so nothing should go wrong at this point.
  *
  * \param ctx  current context
+ * \param fb   the desired draw buffer
  * \param nnumber of color outputs to set
  * \param buffers  array[n] of colorbuffer names, like GL_LEFT.
  * \param destMask  array[n] of BUFFER_BIT_* bitmasks which correspond to the
@@ -489,10 +489,9 @@ updated_drawbuffers(struct gl_context *ctx)
  *  BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
  */
 void
-_mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
-  const GLbitfield *destMask)
+_mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+  GLuint n, const GLenum *buffers, const GLbitfield *destMask)
 {
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
GLbitfield mask[MAX_DRAW_BUFFERS];
GLuint buf;
 
@@ -518,7 +517,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const 
GLenum *buffers,
   while (destMask0) {
  GLint bufIndex = ffs(destMask0) - 1;
  if (fb->_ColorDrawBufferIndexes[count] != bufIndex) {
-updated_drawbuffers(ctx);
+updated_drawbuffers(ctx, fb);
 fb->_ColorDrawBufferIndexes[count] = bufIndex;
  }
  count++;
@@ -535,14 +534,14 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const 
GLenum *buffers,
 /* only one bit should be set in the destMask[buf] field */
 assert(_mesa_bitcount(destMask[buf]) == 1);
 if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) {
-  updated_drawbuffers(ctx);
+  updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = bufIndex;
 }
 count = buf + 1;
  }
  else {
 if (fb->_ColorDrawBufferIndexes[buf] != -1) {
-  updated_drawbuffers(ctx);
+  updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = -1;
 }
  }
@@ -554,7 +553,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const 
GLenum *buffers,
/* set remaining outputs to -1 (GL_NONE) */
for (buf = fb->_NumColorDrawBuffers; buf < ctx->Const.MaxDrawBuffers; 
buf++) {
   if (fb->_ColorDrawBufferIndexes[buf] != -1) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
  fb->_ColorDrawBufferIndexes[buf] = -1;
   }
}
@@ -566,7 +565,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const 
GLenum *buffers,
   /* also set context drawbuffer state */
   for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
  if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) {
-   updated_drawbuffers(ctx);
+   updated_drawbuffe

[Mesa-dev] [PATCH 21/38] main: Refactor _mesa_update_draw_buffer_bounds.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/drivers/dri/i915/i830_vtbl.c   | 2 +-
 src/mesa/drivers/dri/i915/i915_vtbl.c   | 2 +-
 src/mesa/drivers/dri/r200/r200_state.c  | 2 +-
 src/mesa/drivers/dri/radeon/radeon_common.c | 2 +-
 src/mesa/drivers/dri/radeon/radeon_state.c  | 2 +-
 src/mesa/main/framebuffer.c | 6 +++---
 src/mesa/main/framebuffer.h | 3 ++-
 src/mesa/main/state.c   | 2 +-
 8 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c 
b/src/mesa/drivers/dri/i915/i830_vtbl.c
index 4fff29e..8ed8ff5 100644
--- a/src/mesa/drivers/dri/i915/i830_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -732,7 +732,7 @@ i830_update_draw_buffer(struct intel_context *intel)
   /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
   _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
   /* this updates the DrawBuffer's Width/Height if it's a FBO */
-  _mesa_update_draw_buffer_bounds(ctx);
+  _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
}
 
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c 
b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 9ed298c..3d77303 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -734,7 +734,7 @@ i915_update_draw_buffer(struct intel_context *intel)
   /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
   _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
   /* this updates the DrawBuffer's Width/Height if it's a FBO */
-  _mesa_update_draw_buffer_bounds(ctx);
+  _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
}
 
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
diff --git a/src/mesa/drivers/dri/r200/r200_state.c 
b/src/mesa/drivers/dri/r200/r200_state.c
index b020439..5c0f8a4 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -2216,7 +2216,7 @@ GLboolean r200ValidateState( struct gl_context *ctx )
if (new_state & _NEW_BUFFERS) {
   _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
   /* this updates the DrawBuffer's Width/Height if it's a FBO */
-  _mesa_update_draw_buffer_bounds(ctx);
+  _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
 
   R200_STATECHANGE(rmesa, ctx);
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c 
b/src/mesa/drivers/dri/radeon/radeon_common.c
index 84c8066..5ba5953 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -222,7 +222,7 @@ void radeon_draw_buffer(struct gl_context *ctx, struct 
gl_framebuffer *fb)
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, 
etc */
_mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
-   _mesa_update_draw_buffer_bounds(ctx);
+   _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
}
 
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c 
b/src/mesa/drivers/dri/radeon/radeon_state.c
index 2c0a99a..75caa97 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1995,7 +1995,7 @@ GLboolean radeonValidateState( struct gl_context *ctx )
if (new_state & _NEW_BUFFERS) {
  _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
  /* this updates the DrawBuffer's Width/Height if it's a FBO */
- _mesa_update_draw_buffer_bounds(ctx);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
  RADEON_STATECHANGE(rmesa, ctx);
}
 
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index eee457d..6cb13d3 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -312,7 +312,7 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct 
gl_framebuffer *fb,
 
if (ctx) {
   /* update scissor / window bounds */
-  _mesa_update_draw_buffer_bounds(ctx);
+  _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
   /* Signal new buffer state so that swrast will update its clipping
* info (the CLIP_BIT flag).
*/
@@ -413,9 +413,9 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
  * \param ctx  the GL context.
  */
 void
-_mesa_update_draw_buffer_bounds(struct gl_context *ctx)
+_mesa_update_draw_buffer_bounds(struct gl_context *ctx,
+struct gl_framebuffer *buffer)
 {
-   struct gl_framebuffer *buffer = ctx->DrawBuffer;
int bbox[4];
 
if (!buffer)
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index d3b7e58..d02b86f 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -77,7 +77,8 @@ _mesa_scissor_bounding_box

[Mesa-dev] [PATCH 04/38] main: Rename framebuffer renderbuffer software fallback.

2015-03-03 Thread Laura Ekstrand
Rename _mesa_framebuffer_renderbuffer to _mesa_FramebufferRenderbuffer_sw in
preparation for adding the ARB_direct_state_access backend function for
FramebufferRenderbuffer and NamedFramebufferRenderbuffer to share.
---
 src/mesa/drivers/common/driverfuncs.c  | 2 +-
 src/mesa/drivers/dri/i915/intel_fbo.c  | 2 +-
 src/mesa/drivers/dri/nouveau/nouveau_fbo.c | 2 +-
 src/mesa/drivers/dri/radeon/radeon_fbo.c   | 2 +-
 src/mesa/main/fbobject.c   | 7 ---
 src/mesa/main/fbobject.h   | 7 ---
 src/mesa/state_tracker/st_cb_fbo.c | 2 +-
 src/mesa/swrast/s_texrender.c  | 2 +-
 8 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 0d094dd..71c1a76 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -172,7 +172,7 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
driver->UnmapRenderbuffer = _swrast_unmap_soft_renderbuffer;
driver->RenderTexture = _swrast_render_texture;
driver->FinishRenderTexture = _swrast_finish_render_texture;
-   driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
+   driver->FramebufferRenderbuffer = _mesa_FramebufferRenderbuffer_sw;
driver->ValidateFramebuffer = _mesa_validate_framebuffer;
 
driver->BlitFramebuffer = _swrast_BlitFramebuffer;
diff --git a/src/mesa/drivers/dri/i915/intel_fbo.c 
b/src/mesa/drivers/dri/i915/intel_fbo.c
index 8ce1dbf..5b02508 100644
--- a/src/mesa/drivers/dri/i915/intel_fbo.c
+++ b/src/mesa/drivers/dri/i915/intel_fbo.c
@@ -427,7 +427,7 @@ intel_framebuffer_renderbuffer(struct gl_context * ctx,
 {
DBG("Intel FramebufferRenderbuffer %u %u\n", fb->Name, rb ? rb->Name : 0);
 
-   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+   _mesa_FramebufferRenderbuffer_sw(ctx, fb, attachment, rb);
intel_draw_buffer(ctx);
 }
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c 
b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index 6c479f5..c78d4ba 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -242,7 +242,7 @@ static void
 nouveau_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer 
*fb,
 GLenum attachment, struct gl_renderbuffer *rb)
 {
-   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+   _mesa_FramebufferRenderbuffer_sw(ctx, fb, attachment, rb);
 
context_dirty(ctx, FRAMEBUFFER);
 }
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c 
b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 110b030..27fa851 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -723,7 +723,7 @@ radeon_framebuffer_renderbuffer(struct gl_context * ctx,
"%s(%p, fb %p, rb %p) \n",
__func__, ctx, fb, rb);
 
-   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+   _mesa_FramebufferRenderbuffer_sw(ctx, fb, attachment, rb);
radeon_draw_buffer(ctx, fb);
 }
 
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8bc7ec7..948ac91 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -515,9 +515,10 @@ set_renderbuffer_attachment(struct gl_context *ctx,
  * Attach a renderbuffer object to a framebuffer object.
  */
 void
-_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
-   struct gl_framebuffer *fb,
-   GLenum attachment, struct gl_renderbuffer *rb)
+_mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb)
 {
struct gl_renderbuffer_attachment *att;
 
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 5143743..10ae242 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -82,9 +82,10 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
   struct gl_renderbuffer_attachment *att);
 
 extern void
-_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
-   struct gl_framebuffer *fb,
-   GLenum attachment, struct gl_renderbuffer *rb);
+_mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb);
 
 extern void
 _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
diff --git a/src/mesa/state_tracker/st_cb_fbo.c 
b/src/mesa/state_tracker/st_cb_fbo.c
index 296ea1e..0399eef 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -842,7 +842,7 @@ void st_init_fbo_functions(struct dd_function_

[Mesa-dev] [PATCH 28/38] main: Fake entry point for glClearNamedFramebufferuiv.

2015-03-03 Thread Laura Ekstrand
Mesa's ClearBuffer framework is very complicated and thoroughly married to the
object binding model.  Moreover, the OpenGL spec for ClearBuffer is also very
complicated.  At some point, we should implement buffer clearing for arbitrary
framebuffer objects, but for now, we will just wrap ClearBuffer.
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/clear.c  | 17 +
 src/mesa/main/clear.h  |  4 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 29 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 0ab0db4..52b4d34 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -163,6 +163,13 @@
   

 
+   
+  
+  
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 40bf0be..3357d54 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -489,6 +489,23 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, 
const GLuint *value)
}
 }
 
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
+   GLint drawbuffer, const GLuint *value)
+{
+   GLint oldfb;
+
+   _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+   _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+   _mesa_ClearBufferuiv(buffer, drawbuffer, value);
+   _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
 
 /**
  * New in GL 3.0
diff --git a/src/mesa/main/clear.h b/src/mesa/main/clear.h
index d0b6133..b74c227 100644
--- a/src/mesa/main/clear.h
+++ b/src/mesa/main/clear.h
@@ -59,6 +59,10 @@ extern void GLAPIENTRY
 _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value);
 
 extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
+   GLint drawbuffer, const GLuint *value);
+
+extern void GLAPIENTRY
 _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value);
 
 extern void GLAPIENTRY
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index a24f571..a1875b9 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -977,6 +977,7 @@ const struct function gl_core_functions_possible[] = {
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
{ "glClearNamedFramebufferiv", 45, -1 },
+   { "glClearNamedFramebufferuiv", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 23/38] main: _mesa_blit_framebuffer updates its arbitrary framebuffers.

2015-03-03 Thread Laura Ekstrand
Previously, we used _mesa_update_state to update the currently bound
framebuffers prior to performing a blit.  Now that _mesa_blit_framebuffer
uses arbitrary framebuffers, _mesa_update_state is not specific enough.
---
 src/mesa/main/blit.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index e03b5dc..1569004 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -33,6 +33,7 @@
 #include "enums.h"
 #include "blit.h"
 #include "fbobject.h"
+#include "framebuffer.h"
 #include "glformats.h"
 #include "mtypes.h"
 #include "state.h"
@@ -161,9 +162,11 @@ _mesa_blit_framebuffer(struct gl_context *ctx,
 
FLUSH_VERTICES(ctx, 0);
 
-   if (ctx->NewState) {
-  _mesa_update_state(ctx);
-   }
+   /* Update completeness status of readFb and drawFb. */
+   _mesa_update_framebuffer(ctx, readFb, drawFb);
+
+   /* Make sure drawFb has an initialized bounding box. */
+   _mesa_update_draw_buffer_bounds(ctx, drawFb);
 
if (!readFb || !drawFb) {
   /* This will normally never happen but someday we may want to
-- 
2.1.0

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


[Mesa-dev] [PATCH 36/38] main: Add entry point for NamedFramebufferReadBuffer.

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  5 +
 src/mesa/main/buffers.c| 18 ++
 src/mesa/main/buffers.h|  3 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 27 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index c472163..1bdb29c 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -151,6 +151,11 @@
   

 
+   
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index e244d1e..d0627b5 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -700,3 +700,21 @@ _mesa_ReadBuffer(GLenum buffer)
GET_CURRENT_CONTEXT(ctx);
_mesa_read_buffer(ctx, ctx->ReadBuffer, buffer, "glReadBuffer");
 }
+
+void GLAPIENTRY
+_mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb;
+
+   if (framebuffer) {
+  fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+"glNamedFramebufferReadBuffer");
+  if (!fb)
+ return;
+   }
+   else
+  fb = ctx->WinSysReadBuffer;
+
+   _mesa_read_buffer(ctx, fb, src, "glNamedFramebufferReadBuffer");
+}
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index ca7ad19..52a2318 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -71,5 +71,8 @@ _mesa_read_buffer(struct gl_context *ctx, struct 
gl_framebuffer *fb,
 extern void GLAPIENTRY
 _mesa_ReadBuffer( GLenum mode );
 
+extern void GLAPIENTRY
+_mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src);
+
 
 #endif
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 16caf24..0afb650 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -976,6 +976,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glNamedFramebufferDrawBuffer", 45, -1 },
+   { "glNamedFramebufferReadBuffer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
{ "glClearNamedFramebufferiv", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 22/38] main: Add entry point for BlitNamedFramebuffer.

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml | 15 
 src/mesa/main/blit.c   | 50 ++
 src/mesa/main/blit.h   |  6 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 72 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 36de3c1..4e5ba0b 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -140,6 +140,21 @@
   

 
+   
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index b6d6d75..e03b5dc 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -524,3 +524,53 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
   dstX0, dstY0, dstX1, dstY1,
   mask, filter, "glBlitFramebuffer");
 }
+
+void GLAPIENTRY
+_mesa_BlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer,
+   GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+   GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+   GLbitfield mask, GLenum filter)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *readFb, *drawFb;
+
+   if (MESA_VERBOSE & VERBOSE_API)
+  _mesa_debug(ctx,
+  "glBlitNamedFramebuffer(%u %u %d, %d, %d, %d, "
+  " %d, %d, %d, %d, 0x%x, %s)\n",
+  readFramebuffer, drawFramebuffer,
+  srcX0, srcY0, srcX1, srcY1,
+  dstX0, dstY0, dstX1, dstY1,
+  mask, _mesa_lookup_enum_by_nr(filter));
+
+   /*
+* According to PDF page 533 of the OpenGL 4.5 core spec (30.10.2014,
+* Section 18.3 Copying Pixels):
+*   "... if readFramebuffer or drawFramebuffer is zero (for
+*   BlitNamedFramebuffer), then the default read or draw framebuffer is
+*   used as the corresponding source or destination framebuffer,
+*   respectively."
+*/
+   if (readFramebuffer) {
+  readFb = _mesa_lookup_framebuffer_err(ctx, readFramebuffer,
+"glBlitNamedFramebuffer");
+  if (!readFb)
+ return;
+   }
+   else
+  readFb = ctx->WinSysReadBuffer;
+
+   if (drawFramebuffer) {
+  drawFb = _mesa_lookup_framebuffer_err(ctx, drawFramebuffer,
+"glBlitNamedFramebuffer");
+  if (!drawFb)
+ return;
+   }
+   else
+  drawFb = ctx->WinSysDrawBuffer;
+
+   _mesa_blit_framebuffer(ctx, readFb, drawFb,
+  srcX0, srcY0, srcX1, srcY1,
+  dstX0, dstY0, dstX1, dstY1,
+  mask, filter, "glBlitNamedFramebuffer");
+}
diff --git a/src/mesa/main/blit.h b/src/mesa/main/blit.h
index b854f5f..54b946e 100644
--- a/src/mesa/main/blit.h
+++ b/src/mesa/main/blit.h
@@ -41,5 +41,11 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, 
GLint srcY1,
  GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
  GLbitfield mask, GLenum filter);
 
+extern void GLAPIENTRY
+_mesa_BlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer,
+   GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+   GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+   GLbitfield mask, GLenum filter);
+
 
 #endif /* BLIT_H */
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index a6d8523..891ae0f 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -974,6 +974,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferRenderbuffer", 45, -1 },
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
+   { "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
{ "glCreateTextures", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 38/38] main: Add entry point for NamedFramebufferDrawBuffers.

2015-03-03 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  6 ++
 src/mesa/main/buffers.c| 19 +++
 src/mesa/main/buffers.h|  4 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 30 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 1bdb29c..87483a0 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -151,6 +151,12 @@
   

 
+   
+  
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 32986f5..6305cdf 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -504,6 +504,25 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
_mesa_draw_buffers(ctx, ctx->DrawBuffer, n, buffers, "glDrawBuffers");
 }
 
+void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
+  const GLenum *bufs)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb;
+
+   if (framebuffer) {
+  fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+"glNamedFramebufferDrawBuffers");
+  if (!fb)
+ return;
+   }
+   else
+  fb = ctx->WinSysDrawBuffer;
+
+   _mesa_draw_buffers(ctx, fb, n, bufs, "glNamedFramebufferDrawBuffers");
+}
+
 
 /**
  * Performs necessary state updates when _mesa_drawbuffers makes an
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index 66871d7..5aa79fd 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -55,6 +55,10 @@ _mesa_draw_buffers(struct gl_context *ctx, struct 
gl_framebuffer *fb,
 extern void GLAPIENTRY
 _mesa_DrawBuffers(GLsizei n, const GLenum *buffers);
 
+extern void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
+  const GLenum *bufs);
+
 extern void
 _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
   GLuint n, const GLenum *buffers,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 0afb650..e9a26ca 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -976,6 +976,7 @@ const struct function gl_core_functions_possible[] = {
{ "glNamedFramebufferTexture", 45, -1 },
{ "glNamedFramebufferTextureLayer", 45, -1 },
{ "glNamedFramebufferDrawBuffer", 45, -1 },
+   { "glNamedFramebufferDrawBuffers", 45, -1 },
{ "glNamedFramebufferReadBuffer", 45, -1 },
{ "glInvalidateNamedFramebufferSubData", 45, -1 },
{ "glInvalidateNamedFramebufferData", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 29/38] main: Fake entry point for glClearNamedFramebufferfv.

2015-03-03 Thread Laura Ekstrand
Mesa's ClearBuffer framework is very complicated and thoroughly married to the
object binding model.  Moreover, the OpenGL spec for ClearBuffer is also very
complicated.  At some point, we should implement buffer clearing for arbitrary
framebuffer objects, but for now, we will just wrap ClearBuffer.
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/clear.c  | 17 +
 src/mesa/main/clear.h  |  4 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 29 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 52b4d34..4cdf2f6 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -170,6 +170,13 @@
   

 
+   
+  
+  
+  
+  
+   
+

   
   
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 3357d54..b5e22e3 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -599,6 +599,23 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
}
 }
 
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
+  GLint drawbuffer, const GLfloat *value)
+{
+   GLint oldfb;
+
+   _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+   _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+   _mesa_ClearBufferfv(buffer, drawbuffer, value);
+   _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
 
 /**
  * New in GL 3.0
diff --git a/src/mesa/main/clear.h b/src/mesa/main/clear.h
index b74c227..582159f 100644
--- a/src/mesa/main/clear.h
+++ b/src/mesa/main/clear.h
@@ -66,6 +66,10 @@ extern void GLAPIENTRY
 _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value);
 
 extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
+  GLint drawbuffer, const GLfloat *value);
+
+extern void GLAPIENTRY
 _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
 GLfloat depth, GLint stencil);
 
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index a1875b9..d5a3773 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -978,6 +978,7 @@ const struct function gl_core_functions_possible[] = {
{ "glInvalidateNamedFramebufferData", 45, -1 },
{ "glClearNamedFramebufferiv", 45, -1 },
{ "glClearNamedFramebufferuiv", 45, -1 },
+   { "glClearNamedFramebufferfv", 45, -1 },
{ "glBlitNamedFramebuffer", 45, -1 },
{ "glCheckNamedFramebufferStatus", 45, -1 },
{ "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 15/38] main: Fix whitespace in blit.c

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/blit.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index 2898723..899dd45 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -305,7 +305,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
* ignored."
*/
   if ((readRb == NULL) || (drawRb == NULL)) {
-mask &= ~GL_STENCIL_BUFFER_BIT;
+ mask &= ~GL_STENCIL_BUFFER_BIT;
   }
   else {
  int read_z_bits, draw_z_bits;
@@ -359,7 +359,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
* ignored."
*/
   if ((readRb == NULL) || (drawRb == NULL)) {
-mask &= ~GL_DEPTH_BUFFER_BIT;
+ mask &= ~GL_DEPTH_BUFFER_BIT;
   }
   else {
  int read_s_bit, draw_s_bit;
@@ -457,23 +457,23 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
   GLuint i = 0;
 
   printf("glBlitFramebuffer(%d, %d, %d, %d,  %d, %d, %d, %d,"
-" 0x%x, 0x%x)\n",
-srcX0, srcY0, srcX1, srcY1,
-dstX0, dstY0, dstX1, dstY1,
-mask, filter);
+ " 0x%x, 0x%x)\n",
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
   if (colorReadRb) {
  const struct gl_renderbuffer_attachment *att;
 
  att = find_attachment(readFb, colorReadRb);
  printf("  Src FBO %u  RB %u (%dx%d)  ",
-   readFb->Name, colorReadRb->Name,
-   colorReadRb->Width, colorReadRb->Height);
+readFb->Name, colorReadRb->Name,
+colorReadRb->Width, colorReadRb->Height);
  if (att && att->Texture) {
 printf("Tex %u  tgt 0x%x  level %u  face %u",
-  att->Texture->Name,
-  att->Texture->Target,
-  att->TextureLevel,
-  att->CubeMapFace);
+   att->Texture->Name,
+   att->Texture->Target,
+   att->TextureLevel,
+   att->CubeMapFace);
  }
  printf("\n");
 
@@ -485,14 +485,14 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint 
srcX1, GLint srcY1,
 
 att = find_attachment(drawFb, colorDrawRb);
 printf("  Dst FBO %u  RB %u (%dx%d)  ",
-  drawFb->Name, colorDrawRb->Name,
-  colorDrawRb->Width, colorDrawRb->Height);
+   drawFb->Name, colorDrawRb->Name,
+   colorDrawRb->Width, colorDrawRb->Height);
 if (att && att->Texture) {
printf("Tex %u  tgt 0x%x  level %u  face %u",
- att->Texture->Name,
- att->Texture->Target,
- att->TextureLevel,
- att->CubeMapFace);
+  att->Texture->Name,
+  att->Texture->Target,
+  att->TextureLevel,
+  att->CubeMapFace);
 }
 printf("\n");
  }
-- 
2.1.0

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


[Mesa-dev] [PATCH 19/38] main: Refactor _mesa_[update|get]_clamp_fragment_color.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/blend.c | 19 ++-
 src/mesa/main/blend.h |  6 --
 src/mesa/main/framebuffer.c   |  2 +-
 src/mesa/main/get.c   |  8 
 src/mesa/main/texenv.c|  2 +-
 src/mesa/main/texparam.c  |  2 +-
 src/mesa/program/prog_statevars.c |  4 ++--
 7 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index ee76b47..2342555 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -778,7 +778,7 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
   }
   FLUSH_VERTICES(ctx, _NEW_FRAG_CLAMP);
   ctx->Color.ClampFragmentColor = clamp;
-  _mesa_update_clamp_fragment_color(ctx);
+  _mesa_update_clamp_fragment_color(ctx, ctx->DrawBuffer);
   break;
case GL_CLAMP_READ_COLOR_ARB:
   ctx->Color.ClampReadColor = clamp;
@@ -807,10 +807,10 @@ get_clamp_color(const struct gl_framebuffer *fb, GLenum 
clamp)
 }
 
 GLboolean
-_mesa_get_clamp_fragment_color(const struct gl_context *ctx)
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx,
+   const struct gl_framebuffer *drawFb)
 {
-   return get_clamp_color(ctx->DrawBuffer,
-ctx->Color.ClampFragmentColor);
+   return get_clamp_color(drawFb, ctx->Color.ClampFragmentColor);
 }
 
 GLboolean
@@ -830,19 +830,20 @@ _mesa_get_clamp_read_color(const struct gl_context *ctx)
  * Update the ctx->Color._ClampFragmentColor field
  */
 void
-_mesa_update_clamp_fragment_color(struct gl_context *ctx)
+_mesa_update_clamp_fragment_color(struct gl_context *ctx,
+  const struct gl_framebuffer *drawFb)
 {
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
-
/* Don't clamp if:
 * - there is no colorbuffer
 * - all colorbuffers are unsigned normalized, so clamping has no effect
 * - there is an integer colorbuffer
 */
-   if (!fb || !fb->_HasSNormOrFloatColorBuffer || fb->_IntegerColor)
+   if (!drawFb || !drawFb->_HasSNormOrFloatColorBuffer ||
+   drawFb->_IntegerColor)
   ctx->Color._ClampFragmentColor = GL_FALSE;
else
-  ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx);
+  ctx->Color._ClampFragmentColor =
+ _mesa_get_clamp_fragment_color(ctx, drawFb);
 }
 
 /**
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index 9c1ef7e..58e6673 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -102,7 +102,8 @@ extern void GLAPIENTRY
 _mesa_ClampColor(GLenum target, GLenum clamp);
 
 extern GLboolean
-_mesa_get_clamp_fragment_color(const struct gl_context *ctx);
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx,
+   const struct gl_framebuffer *drawFb);
 
 extern GLboolean
 _mesa_get_clamp_vertex_color(const struct gl_context *ctx,
@@ -112,7 +113,8 @@ extern GLboolean
 _mesa_get_clamp_read_color(const struct gl_context *ctx);
 
 extern void
-_mesa_update_clamp_fragment_color(struct gl_context *ctx);
+_mesa_update_clamp_fragment_color(struct gl_context *ctx,
+  const struct gl_framebuffer *drawFb);
 
 extern void
 _mesa_update_clamp_vertex_color(struct gl_context *ctx,
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 22db72a..eee457d 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -692,7 +692,7 @@ _mesa_update_framebuffer(struct gl_context *ctx,
   update_framebuffer(ctx, readFb);
 
_mesa_update_clamp_vertex_color(ctx, drawFb);
-   _mesa_update_clamp_fragment_color(ctx);
+   _mesa_update_clamp_fragment_color(ctx, drawFb);
 }
 
 
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index a881bc5..c37d9db 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -909,13 +909,13 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
   break;
 
case GL_FOG_COLOR:
-  if (_mesa_get_clamp_fragment_color(ctx))
+  if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
  COPY_4FV(v->value_float_4, ctx->Fog.Color);
   else
  COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped);
   break;
case GL_COLOR_CLEAR_VALUE:
-  if (_mesa_get_clamp_fragment_color(ctx)) {
+  if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
  v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F);
  v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F);
  v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F);
@@ -924,13 +924,13 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
  COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f);
   break;
case GL_BLEND_COLOR_EXT:
-  if (_mesa_get_clamp_fragment_color(ctx))
+  if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
  COPY_4FV(v->value_float_4, ctx->Color.BlendColor

[Mesa-dev] [PATCH 24/38] main: Refactor invalidate_framebuffer_storage.

2015-03-03 Thread Laura Ekstrand
---
 src/mesa/main/fbobject.c | 38 +++---
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 467a8cd..7a1684c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3468,19 +3468,13 @@ _mesa_GetNamedFramebufferAttachmentParameteriv(GLuint 
framebuffer,
 
 
 static void
-invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
+invalidate_framebuffer_storage(struct gl_context *ctx,
+   struct gl_framebuffer *fb,
+   GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
GLsizei width, GLsizei height, const char *name)
 {
int i;
-   struct gl_framebuffer *fb;
-   GET_CURRENT_CONTEXT(ctx);
-
-   fb = get_framebuffer_target(ctx, target);
-   if (!fb) {
-  _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", name);
-  return;
-   }
 
if (numAttachments < 0) {
   _mesa_error(ctx, GL_INVALID_VALUE,
@@ -3590,7 +3584,18 @@ _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei 
numAttachments,
const GLenum *attachments, GLint x, GLint y,
GLsizei width, GLsizei height)
 {
-   invalidate_framebuffer_storage(target, numAttachments, attachments,
+   struct gl_framebuffer *fb;
+   GET_CURRENT_CONTEXT(ctx);
+
+   fb = get_framebuffer_target(ctx, target);
+   if (!fb) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "glInvalidateSubFramebuffer(invalid target %s)",
+  _mesa_lookup_enum_by_nr(target));
+  return;
+   }
+
+   invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
   x, y, width, height,
   "glInvalidateSubFramebuffer");
 }
@@ -3600,6 +3605,17 @@ void GLAPIENTRY
 _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
 const GLenum *attachments)
 {
+   struct gl_framebuffer *fb;
+   GET_CURRENT_CONTEXT(ctx);
+
+   fb = get_framebuffer_target(ctx, target);
+   if (!fb) {
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "glInvalidateFramebuffer(invalid target %s)",
+  _mesa_lookup_enum_by_nr(target));
+  return;
+   }
+
/* The GL_ARB_invalidate_subdata spec says:
 *
 * "The command
@@ -3612,7 +3628,7 @@ _mesa_InvalidateFramebuffer(GLenum target, GLsizei 
numAttachments,
 * ,  equal to 0, 0, ,
 *  respectively."
 */
-   invalidate_framebuffer_storage(target, numAttachments, attachments,
+   invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
   0, 0,
   MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT,
   "glInvalidateFramebuffer");
-- 
2.1.0

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


  1   2   >