[Mesa-dev] [PATCH] radeon: Fix memory leak in radeonCreateScreen2.

2012-11-30 Thread Vinson Lee
Fixes a memory leak defect reported by Coverity.

Signed-off-by: Vinson Lee v...@freedesktop.org
---
 src/mesa/drivers/dri/radeon/radeon_screen.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 6f4750a..2e6cf3c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -510,8 +510,10 @@ radeonCreateScreen2(__DRIscreen *sPriv)
}
 
ret = radeon_set_screen_flags(screen, device_id);
-   if (ret == -1)
+   if (ret == -1) {
+ free(screen);
  return NULL;
+   }
 
if (getenv(RADEON_NO_TCL))
   screen-chip_flags = ~RADEON_CHIPSET_TCL;
-- 
1.8.0

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


[Mesa-dev] [PATCH] dri_glx: fix use after free report

2012-11-30 Thread Dave Airlie
the critical error would use driverName.

Found by internal RH coverity scan.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/glx/dri_glx.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index de777fb..f42db79 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -805,7 +805,6 @@ driCreateScreen(int screen, struct glx_display *priv)
}
 
psc-driver = driOpenDriver(driverName);
-   free(driverName);
if (psc-driver == NULL)
   goto cleanup;
 
@@ -847,11 +846,15 @@ driCreateScreen(int screen, struct glx_display *priv)
psp-setSwapInterval = driSetSwapInterval;
psp-getSwapInterval = driGetSwapInterval;
 
+   free(driverName);
+
return psc-base;
 
 cleanup:
CriticalErrorMessageF(failed to load driver: %s\n, driverName);
 
+   free(driverName);
+
if (psc-driver)
   dlclose(psc-driver);
glx_screen_cleanup(psc-base);
-- 
1.7.11.7

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


[Mesa-dev] [PATCH] android: fix bison warning of conflicting outputs to file

2012-11-30 Thread groleo
From: Adrian Marius Negreanu adrian.m.negre...@intel.com

Bison -o parameter expects a .c file.
The corresponding .h filename is obtained
by removing the extension of the initial .c.

This was breaking compilation on Ubuntu 12.04

libmesa_dricore_intermediates/libmesa_dricore.a(program_parse.tab.o):
In function `_mesa_parse_arb_program':
external/mesa/src/mesa/program/program_parse.y:2682: multiple definition
of `_mesa_parse_arb_program'
libmesa_dricore_intermediates/libmesa_dricore.a(lex.yy.o):external/mesa/src/mesa/program/program_parse.y:2682:
first defined here

Signed-off-by: Adrian Marius Negreanu adrian.m.negre...@intel.com
---
 src/mesa/program/Android.mk | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/mesa/program/Android.mk b/src/mesa/program/Android.mk
index 5eb0439..7125061 100644
--- a/src/mesa/program/Android.mk
+++ b/src/mesa/program/Android.mk
@@ -65,9 +65,6 @@ LOCAL_GENERATED_SOURCES := \
 $(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program_parse.y
$(mesa_local-y-to-c-and-h)
 
-$(intermediates)/program/program_parse.tab.h: $(LOCAL_PATH)/program_parse.y
-   $(mesa_local-y-to-c-and-h)
-
 $(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program_lexer.l
$(local-l-to-c)
 
-- 
1.8.0

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


[Mesa-dev] [PATCH] glsl: fix cut-n-paste error in error handling. (v2)

2012-11-30 Thread Dave Airlie
Reported by coverity scan.

v2: fix second case

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/glsl/ir_validate.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index af0b576..ad57a31 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -120,7 +120,7 @@ ir_visitor_status
 ir_validate::visit_leave(ir_loop *ir)
 {
if (ir-counter != NULL) {
-  if ((ir-from == NULL) || (ir-from == NULL) || (ir-increment == NULL)) 
{
+  if ((ir-from == NULL) || (ir-to == NULL) || (ir-increment == NULL)) {
 printf(ir_loop has invalid loop controls:\n
counter:   %p\n
from:  %p\n
@@ -136,7 +136,7 @@ ir_validate::visit_leave(ir_loop *ir)
 abort();
   }
} else {
-  if ((ir-from != NULL) || (ir-from != NULL) || (ir-increment != NULL)) 
{
+  if ((ir-from != NULL) || (ir-to != NULL) || (ir-increment != NULL)) {
 printf(ir_loop has invalid loop controls:\n
counter:   %p\n
from:  %p\n
-- 
1.7.11.7

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


[Mesa-dev] [PATCH] glsl: fix cut-n-paste error in error handling.

2012-11-30 Thread Dave Airlie
Reported by coverity scan.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/glsl/ir_validate.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index af0b576..5ac0ad3 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -120,7 +120,7 @@ ir_visitor_status
 ir_validate::visit_leave(ir_loop *ir)
 {
if (ir-counter != NULL) {
-  if ((ir-from == NULL) || (ir-from == NULL) || (ir-increment == NULL)) 
{
+  if ((ir-from == NULL) || (ir-to == NULL) || (ir-increment == NULL)) {
 printf(ir_loop has invalid loop controls:\n
counter:   %p\n
from:  %p\n
-- 
1.7.11.7

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


Re: [Mesa-dev] [PATCH] glsl: fix cut-n-paste error in error handling. (v2)

2012-11-30 Thread Matt Turner
On Fri, Nov 30, 2012 at 12:34 AM, Dave Airlie airl...@gmail.com wrote:
 Reported by coverity scan.

 v2: fix second case

 Signed-off-by: Dave Airlie airl...@redhat.com
 ---
  src/glsl/ir_validate.cpp | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
 index af0b576..ad57a31 100644
 --- a/src/glsl/ir_validate.cpp
 +++ b/src/glsl/ir_validate.cpp
 @@ -120,7 +120,7 @@ ir_visitor_status
  ir_validate::visit_leave(ir_loop *ir)
  {
 if (ir-counter != NULL) {
 -  if ((ir-from == NULL) || (ir-from == NULL) || (ir-increment == 
 NULL)) {
 +  if ((ir-from == NULL) || (ir-to == NULL) || (ir-increment == NULL)) 
 {
  printf(ir_loop has invalid loop controls:\n
 counter:   %p\n
 from:  %p\n
 @@ -136,7 +136,7 @@ ir_validate::visit_leave(ir_loop *ir)
  abort();
}
 } else {
 -  if ((ir-from != NULL) || (ir-from != NULL) || (ir-increment != 
 NULL)) {
 +  if ((ir-from != NULL) || (ir-to != NULL) || (ir-increment != NULL)) 
 {
  printf(ir_loop has invalid loop controls:\n
 counter:   %p\n
 from:  %p\n
 --
 1.7.11.7

Wow, nice. This code has been like this for more than two years now.

Reviewed-by: Matt Turner matts...@gmail.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] android: fix bison warning of conflicting outputs to file

2012-11-30 Thread Tapani Pälli
On 11/30/2012 09:52 AM, gro...@gmail.com wrote:
 From: Adrian Marius Negreanu adrian.m.negre...@intel.com
 
 Bison -o parameter expects a .c file.
 The corresponding .h filename is obtained
 by removing the extension of the initial .c.
 
 This was breaking compilation on Ubuntu 12.04
 
 libmesa_dricore_intermediates/libmesa_dricore.a(program_parse.tab.o):
 In function `_mesa_parse_arb_program':
 external/mesa/src/mesa/program/program_parse.y:2682: multiple definition
 of `_mesa_parse_arb_program'
 libmesa_dricore_intermediates/libmesa_dricore.a(lex.yy.o):external/mesa/src/mesa/program/program_parse.y:2682:
 first defined here
 
 Signed-off-by: Adrian Marius Negreanu adrian.m.negre...@intel.com

Works for me.

Reviewed-by: Tapani Pälli tapani.pa...@intel.com


 ---
  src/mesa/program/Android.mk | 3 ---
  1 file changed, 3 deletions(-)
 
 diff --git a/src/mesa/program/Android.mk b/src/mesa/program/Android.mk
 index 5eb0439..7125061 100644
 --- a/src/mesa/program/Android.mk
 +++ b/src/mesa/program/Android.mk
 @@ -65,9 +65,6 @@ LOCAL_GENERATED_SOURCES := \
  $(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program_parse.y
   $(mesa_local-y-to-c-and-h)
  
 -$(intermediates)/program/program_parse.tab.h: $(LOCAL_PATH)/program_parse.y
 - $(mesa_local-y-to-c-and-h)
 -
  $(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program_lexer.l
   $(local-l-to-c)
  
 




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] suspect rcp code in llvmpipe

2012-11-30 Thread Dave Airlie
coverity pointed out the below as suspect, since num_iterations = 0,
and we do a loop from 0..0

Dave.

 if (FALSE  ((util_cpu_caps.has_sse  type.width == 32 
type.length == 4) ||
 (util_cpu_caps.has_avx  type.width == 32  type.length == 8))){
  const unsigned num_iterations = 0;
  LLVMValueRef res;
  unsigned i;
  const char *intrinsic = NULL;

  if (type.length == 4) {
 intrinsic = llvm.x86.sse.rcp.ps;
  }
  else {
 intrinsic = llvm.x86.avx.rcp.ps.256;
  }

  res = lp_build_intrinsic_unary(builder, intrinsic, bld-vec_type, a);

  for (i = 0; i  num_iterations; ++i) {
 res = lp_build_rcp_refine(bld, a, res);
  }
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] leak in loop_analysis

2012-11-30 Thread Dave Airlie
Coverity pointed out
src/glsl/loop_analysis.cpp

loop_analysis::loop_analysis()
{
   this-loops = new loop_state;


This loops is never freed anywhere, probably need a destructor.

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


[Mesa-dev] [PATCH 1/2] glsl: initialise killed_all field.

2012-11-30 Thread Dave Airlie
coverity pointed out this field was being used uninitialised.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/glsl/opt_constant_propagation.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/glsl/opt_constant_propagation.cpp 
b/src/glsl/opt_constant_propagation.cpp
index c5ae36b..a038119 100644
--- a/src/glsl/opt_constant_propagation.cpp
+++ b/src/glsl/opt_constant_propagation.cpp
@@ -92,6 +92,7 @@ public:
ir_constant_propagation_visitor()
{
   progress = false;
+  killed_all = false;
   mem_ctx = ralloc_context(0);
   this-acp = new(mem_ctx) exec_list;
   this-kills = new(mem_ctx) exec_list;
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 2/2] glsl: fix uninitialised variable from constructor

2012-11-30 Thread Dave Airlie
Coverity pointed out this uninitialised class member.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/glsl/ir_function_detect_recursion.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/glsl/ir_function_detect_recursion.cpp 
b/src/glsl/ir_function_detect_recursion.cpp
index 0a5e647..4b39f97 100644
--- a/src/glsl/ir_function_detect_recursion.cpp
+++ b/src/glsl/ir_function_detect_recursion.cpp
@@ -173,6 +173,7 @@ public:
has_recursion_visitor()
   : current(NULL)
{
+  progress = false;
   this-mem_ctx = ralloc_context(NULL);
   this-function_hash = hash_table_ctor(0, hash_table_pointer_hash,
hash_table_pointer_compare);
-- 
1.7.11.7

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


Re: [Mesa-dev] No luck with tstellar/llvm on HD4890

2012-11-30 Thread Andy Furniss

Andy Furniss wrote:

Andy Furniss wrote:

Tom Stellard wrote:

On Wed, Nov 07, 2012 at 09:24:13PM +, Andy Furniss wrote:

Vincent Lejeune wrote:

git seems to have trouble sending my patch to ML atm, can you
manually apply it ? It fixes lock up here

diff --git a/src/gallium/drivers/r600/r600_asm.c
b/src/gallium/drivers/r600/r600_asm.c
index 5f2548e..f06af44 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -2961,6 +2961,6 @@ void r600_bytecode_export_read(struct
r600_bytecode_output *output, uint32_t wor
   output-swizzle_w = G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_W(word1);
   output-burst_count =
G_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT(word1);
   output-end_of_program =
G_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(word1);
-output-inst =
EG_S_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(word1));


+output-inst =
R600_S_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(word1));


   output-barrier = G_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(word1);
   }
--


This helps - on mesa head, demos/openarena/nexuiz run OK (nexuiz
stutters a bit initially compared to R600_LLVM=0, but then I am running
a debug build of llvm).

etqw now locks GPU as soon as it loads when using llvm.



Is this a regression caused by the same commit?


Yes, but etqw has problems anyway.

Reset mesa to 84b437213294ff4e1a3bcae2f9cbb36a9b4955c4 applied patch and
it gives GPU reset.

Reset mesa to the commit before that + no patch and it runs, but gives
the page allocation fails etc. that I posted earlier in the thread.

Even with R600_LLVM=0 or llvm 3.1 etqw has some isssues with current
mesa, but they are not the same as these.


I've found a more trivial case to reset GPU.

I see the patch went in and I am testing on mesa head -

The mesa demo dissolve will cause a reset, all other demos in that dir
work.


Dissolve and etqw are working now with current llvm and mesa.


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


[Mesa-dev] [PATCH] svga: remove pointless assert on unsigned = 0

2012-11-30 Thread Dave Airlie
all unsigneds are = 0 :-)

There may be an argument for leaving this in, in case someone
changes min_lod to an integer, so feel free to apply or drop.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/gallium/drivers/svga/svga_sampler_view.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/gallium/drivers/svga/svga_sampler_view.c 
b/src/gallium/drivers/svga/svga_sampler_view.c
index 281a44f..efbc138 100644
--- a/src/gallium/drivers/svga/svga_sampler_view.c
+++ b/src/gallium/drivers/svga/svga_sampler_view.c
@@ -65,7 +65,6 @@ svga_get_tex_sampler_view(struct pipe_context *pipe,
boolean view = TRUE;
 
assert(pt);
-   assert(min_lod = 0);
assert(min_lod = max_lod);
assert(max_lod = pt-last_level);
 
-- 
1.7.11.7

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


Re: [Mesa-dev] [PATCH 1/2] radeon/llvm: switch instructions matching fmul and int_AMDGPU_mul

2012-11-30 Thread Michel Dänzer
On Don, 2012-11-29 at 21:58 +0100, Vincent Lejeune wrote: 
 diff --git a/lib/Target/AMDGPU/R600Instructions.td 
 b/lib/Target/AMDGPU/R600Instructions.td
 index b0c1628..9259680 100644
 --- a/lib/Target/AMDGPU/R600Instructions.td
 +++ b/lib/Target/AMDGPU/R600Instructions.td
 @@ -553,8 +553,8 @@ let Predicates = [isR600toCayman] in {
  
  def ADD : R600_2OP_Helper 0x0, ADD, fadd;
  // Non-IEEE MUL: 0 * anything = 0
 -def MUL : R600_2OP_Helper 0x1, MUL NON-IEEE, int_AMDGPU_mul;
 -def MUL_IEEE : R600_2OP_Helper 0x2, MUL_IEEE, fmul;
 +def MUL : R600_2OP_Helper 0x1, MUL NON-IEEE, fmul;
 +def MUL_IEEE : R600_2OP_Helper 0x2, MUL_IEEE, int_AMDGPU_mul;
  def MAX : R600_2OP_Helper 0x3, MAX, AMDGPUfmax;
  def MIN : R600_2OP_Helper 0x4, MIN, AMDGPUfmin;

Why are you swapping these? Doesn't fmul really require IEEE semantics,
whereas int_AMDGPU_mul does not?


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] radeonsi: Bitcast result of packf16 intrinsic to float for export intrinsic.

2012-11-30 Thread Michel Dänzer
On Don, 2012-11-29 at 08:45 -0800, Tom Stellard wrote: 
 On Tue, Nov 27, 2012 at 07:55:05PM +0100, Michel Dänzer wrote:
  diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c 
  b/src/gallium/drivers/radeonsi/radeonsi_shader.c
  index d6e37ac..d5d56c4 100644
  --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
  +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
  @@ -496,7 +496,11 @@ static void si_llvm_init_export_args(struct 
  lp_build_tgsi_context *bld_base,
  
  LLVMInt32TypeInContext(base-gallivm-context),
  args, 2,
  LLVMReadNoneAttribute);
  -   args[chan + 7] = args[chan + 5];
  +   args[chan + 7] = args[chan + 5] =
  +   LLVMBuildBitCast(base-gallivm-builder,
  +args[chan + 5],
  +
  LLVMFloatTypeInContext(base-gallivm-context),
  +);
  }
 
 I think a better fix would be to change the return type of llvm.SI.packf16
 intrinsic from i32 to v2f16.  This is more correct and would allow us to
 use the intrinsic elsewhere if needed.

Makes sense.


 This will also require a new export intrinsic to handle the packed floats,
 and you'll need to add the v2f16 type to the register class definitions.

Not sure about this, though. Given the various export targets / formats,
I'm afraid this would result in a combinatorial explosion of export
intrinsics. I wonder if it might not be better to make the export
intrinsic take i32s instead (or whatever type is best for generic 32 bit
values), and have the driver bitcast as appropriate.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Proposal: allow hidden security bugs on Mesa's Bugzilla

2012-11-30 Thread Benoit Jacob
On 12-11-23 02:21 PM, Benoit Jacob wrote:
 On 12-11-21 12:48 PM, Chad Versace wrote:
 On 11/20/2012 09:29 AM, Benoit Jacob wrote:

 Any questions?
 Do you support or oppose me asking FD.o admins to allow hidden bugs on
 Mesa's bugzilla?

 Benoit
 I support this. It seems a sensible proposal for addressing security bugs.

 Thanks. I have just sent the request to FD.o admins.

 Benoit

This option is now turned on on Bugzilla.

See the new checkbox: Mesa Security Group

Thanks!
Benoit


 ___
 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] r300g: fix comparison of hyperz flush time.

2012-11-30 Thread Marek Olšák
Hi Dave,

thanks for pointing it out. The conditional should be:
else if (r300-hyperz_time_of_last_flush  200) {

With that, this is:

Reviewed-by: Marek Olšák mar...@gmail.com

Marek

On Fri, Nov 30, 2012 at 9:28 AM, Dave Airlie airl...@gmail.com wrote:
 I haven't confirmed this is doing the correct thing, but at
 least this might make someone review it!

 Reported by internal RH coverity scan.

 Signed-off-by: Dave Airlie airl...@redhat.com
 ---
  src/gallium/drivers/r300/r300_flush.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/gallium/drivers/r300/r300_flush.c 
 b/src/gallium/drivers/r300/r300_flush.c
 index 2266b48..5d09db5 100644
 --- a/src/gallium/drivers/r300/r300_flush.c
 +++ b/src/gallium/drivers/r300/r300_flush.c
 @@ -107,7 +107,7 @@ void r300_flush(struct pipe_context *pipe,
  /* Update Hyper-Z status. */
  if (r300-num_z_clears) {
  r300-hyperz_time_of_last_flush = os_time_get();
 -} else if (!r300-hyperz_time_of_last_flush  200) {
 +} else if (!(r300-hyperz_time_of_last_flush  200)) {
  /* 2 seconds without a Z clear pretty much means a dead context
   * for HyperZ. */

 --
 1.7.11.7

 ___
 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] Proposal: allow hidden security bugs on Mesa's Bugzilla

2012-11-30 Thread Marek Olšák
I can see that the security test bug is assigned to mesa-dev by
default, so all comments go to the mailing list. I don't thínk that's
desirable.

Marek

On Fri, Nov 30, 2012 at 1:43 PM, Benoit Jacob bja...@mozilla.com wrote:
 On 12-11-23 02:21 PM, Benoit Jacob wrote:
 On 12-11-21 12:48 PM, Chad Versace wrote:
 On 11/20/2012 09:29 AM, Benoit Jacob wrote:

 Any questions?
 Do you support or oppose me asking FD.o admins to allow hidden bugs on
 Mesa's bugzilla?

 Benoit
 I support this. It seems a sensible proposal for addressing security bugs.

 Thanks. I have just sent the request to FD.o admins.

 Benoit

 This option is now turned on on Bugzilla.

 See the new checkbox: Mesa Security Group

 Thanks!
 Benoit


 ___
 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] [Bug 57733] New: read-after-free with llvmpipe in try_update_scene_state

2012-11-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=57733

  Priority: medium
 Group: Mesa Security
Bug ID: 57733
CC: bri...@vmware.com, jfons...@vmware.com
  Assignee: mesa-dev@lists.freedesktop.org
   Summary: read-after-free with llvmpipe in
try_update_scene_state
  Severity: normal
Classification: Unclassified
OS: Linux (All)
  Reporter: bja...@mozilla.com
  Hardware: x86-64 (AMD64)
Status: NEW
   Version: unspecified
 Component: Other
   Product: Mesa

Created attachment 70829
  -- https://bugs.freedesktop.org/attachment.cgi?id=70829action=edit
apitrace trace

This was originally https://bugzilla.mozilla.org/show_bug.cgi?id=791905 and is
what is causing the Mozilla security team to want to blacklist llvmpipe.

This is a use-after-free in llvmpipe in try_update_scene_state, and from
looking at the call stacks in Valgrind, it looks like it might be a reference
counting error.

I am attaching an apitrace that allows to consistently reproduce in Valgrind.

The error is:

==4016== Invalid read of size 8
==4016==at 0x402F180: memcpy@@GLIBC_2.14 (mc_replace_strmem.c:877)
==4016==by 0x4C81573: try_update_scene_state (lp_setup.c:869)
==4016==by 0x4C7FE91: begin_binning (lp_setup.c:197)
==4016==by 0x4C8011C: execute_clears (lp_setup.c:262)
==4016==by 0x4C80254: set_scene_state (lp_setup.c:310)
==4016==by 0x4C8034E: lp_setup_flush (lp_setup.c:342)
==4016==by 0x4C71E07: llvmpipe_flush (lp_flush.c:55)
==4016==by 0x4C71390: do_flush (lp_context.c:103)
==4016==by 0x4DD6AB0: st_flush (st_cb_flush.c:86)
==4016==by 0x4DD6B71: st_glFlush (st_cb_flush.c:120)
==4016==by 0x4D011BE: _mesa_flush (context.c:1612)
==4016==by 0x4D012A0: _mesa_Flush (context.c:1644)
==4016==  Address 0xce19ff0 is 0 bytes inside a block of size 64 free'd
==4016==at 0x402C5F9: free (vg_replace_malloc.c:446)
==4016==by 0x4CFB98D: _mesa_align_free (imports.c:176)
==4016==by 0x4DCEF0B: _mesa_free_parameter_list (prog_parameter.c:87)
==4016==by 0x4DC8822: _mesa_delete_program (program.c:357)
==4016==by 0x4EC3D53: st_delete_program (st_cb_program.c:169)
==4016==by 0x4DC8A36: _mesa_reference_program_ (program.c:422)
==4016==by 0x4EB4BDF: _mesa_reference_program (program.h:102)
==4016==by 0x4EB4C9C: st_reference_fragprog (st_program.h:265)
==4016==by 0x4EB4E23: update_fp (st_atom_shader.c:93)
==4016==by 0x4EAF9D6: st_validate_state (st_atom.c:203)
==4016==by 0x4EBBE1E: st_Clear (st_cb_clear.c:464)
==4016==by 0x4E1880A: _mesa_Clear (clear.c:231)
==4016== 

The command I use to replay the apitrace in Valgrind is:

LD_PRELOAD=/hack/mesa/build/linux-x86_64-debug/gallium/targets/libgl-xlib/libGL.so.1
LD_LIBRARY_PATH=/hack/mesa/build/linux-x86_64-debug/gallium/targets/libgl-xlib
valgrind --smc-check=all-non-file ../apitrace/build/glretrace -v
firefox.2.trace

As far as avoiding currently llvmpipe blacklisting in browsers goes, here is
what would be useful:
 - either a work-around
 - or a careful assessment of the security implications, proving that this is
not security-critical (i.e. does not actually allow an attacker to read
memory).

Alternatively getting this fixed would allow to un-blacklist at least some
newer versions.

-- 
You are receiving this mail because:
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] Proposal: allow hidden security bugs on Mesa's Bugzilla

2012-11-30 Thread Benoit Jacob
Aaargh

On 12-11-30 07:55 AM, Marek Olšák wrote:
 I can see that the security test bug is assigned to mesa-dev by
 default, so all comments go to the mailing list. I don't thínk that's
 desirable.

 Marek

 On Fri, Nov 30, 2012 at 1:43 PM, Benoit Jacob bja...@mozilla.com wrote:
 On 12-11-23 02:21 PM, Benoit Jacob wrote:
 On 12-11-21 12:48 PM, Chad Versace wrote:
 On 11/20/2012 09:29 AM, Benoit Jacob wrote:

 Any questions?
 Do you support or oppose me asking FD.o admins to allow hidden bugs on
 Mesa's bugzilla?

 Benoit
 I support this. It seems a sensible proposal for addressing security bugs.

 Thanks. I have just sent the request to FD.o admins.

 Benoit
 This option is now turned on on Bugzilla.

 See the new checkbox: Mesa Security Group

 Thanks!
 Benoit

 ___
 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


Re: [Mesa-dev] [PATCH] dri_glx: fix use after free report

2012-11-30 Thread Alex Deucher
On Fri, Nov 30, 2012 at 2:48 AM, Dave Airlie airl...@gmail.com wrote:
 the critical error would use driverName.

 Found by internal RH coverity scan.

 Signed-off-by: Dave Airlie airl...@redhat.com

Reviewed-by: Alex Deucher alexander.deuc...@amd.com

 ---
  src/glx/dri_glx.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

 diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
 index de777fb..f42db79 100644
 --- a/src/glx/dri_glx.c
 +++ b/src/glx/dri_glx.c
 @@ -805,7 +805,6 @@ driCreateScreen(int screen, struct glx_display *priv)
 }

 psc-driver = driOpenDriver(driverName);
 -   free(driverName);
 if (psc-driver == NULL)
goto cleanup;

 @@ -847,11 +846,15 @@ driCreateScreen(int screen, struct glx_display *priv)
 psp-setSwapInterval = driSetSwapInterval;
 psp-getSwapInterval = driGetSwapInterval;

 +   free(driverName);
 +
 return psc-base;

  cleanup:
 CriticalErrorMessageF(failed to load driver: %s\n, driverName);

 +   free(driverName);
 +
 if (psc-driver)
dlclose(psc-driver);
 glx_screen_cleanup(psc-base);
 --
 1.7.11.7

 ___
 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] dri_glx: fix use after free report

2012-11-30 Thread Brian Paul

On 11/30/2012 07:21 AM, Alex Deucher wrote:

On Fri, Nov 30, 2012 at 2:48 AM, Dave Airlieairl...@gmail.com  wrote:

the critical error would use driverName.

Found by internal RH coverity scan.

Signed-off-by: Dave Airlieairl...@redhat.com


Reviewed-by: Alex Deucheralexander.deuc...@amd.com


Candidate for stable branches?

-Brian

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


Re: [Mesa-dev] [PATCH] svga: remove pointless assert on unsigned = 0

2012-11-30 Thread Brian Paul

On 11/30/2012 03:05 AM, Dave Airlie wrote:

all unsigneds are= 0 :-)

There may be an argument for leaving this in, in case someone
changes min_lod to an integer, so feel free to apply or drop.

Signed-off-by: Dave Airlieairl...@redhat.com
---
  src/gallium/drivers/svga/svga_sampler_view.c | 1 -
  1 file changed, 1 deletion(-)

diff --git a/src/gallium/drivers/svga/svga_sampler_view.c 
b/src/gallium/drivers/svga/svga_sampler_view.c
index 281a44f..efbc138 100644
--- a/src/gallium/drivers/svga/svga_sampler_view.c
+++ b/src/gallium/drivers/svga/svga_sampler_view.c
@@ -65,7 +65,6 @@ svga_get_tex_sampler_view(struct pipe_context *pipe,
 boolean view = TRUE;

 assert(pt);
-   assert(min_lod= 0);
 assert(min_lod= max_lod);
 assert(max_lod= pt-last_level);



Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] suspect rcp code in llvmpipe

2012-11-30 Thread Brian Paul

On 11/30/2012 03:10 AM, Dave Airlie wrote:

coverity pointed out the below as suspect, since num_iterations = 0,
and we do a loop from 0..0

Dave.

  if (FALSE  ((util_cpu_caps.has_sse  type.width == 32
type.length == 4) ||
  (util_cpu_caps.has_avx  type.width == 32  type.length == 8))){
   const unsigned num_iterations = 0;
   LLVMValueRef res;
   unsigned i;
   const char *intrinsic = NULL;

   if (type.length == 4) {
  intrinsic = llvm.x86.sse.rcp.ps;
   }
   else {
  intrinsic = llvm.x86.avx.rcp.ps.256;
   }

   res = lp_build_intrinsic_unary(builder, intrinsic, bld-vec_type, a);

   for (i = 0; i  num_iterations; ++i) {
  res = lp_build_rcp_refine(bld, a, res);
   }
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


I guess we could set num_iterations = 1 for now but it doesn't really 
matter since this block of code is disabled (note the if (FALSE) part).


Jose, I think you wrote that code.

-Brian

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


Re: [Mesa-dev] [PATCH 1/2] glsl: initialise killed_all field.

2012-11-30 Thread Brian Paul

On 11/30/2012 03:25 AM, Dave Airlie wrote:

coverity pointed out this field was being used uninitialised.

Signed-off-by: Dave Airlieairl...@redhat.com
---
  src/glsl/opt_constant_propagation.cpp | 1 +
  1 file changed, 1 insertion(+)

diff --git a/src/glsl/opt_constant_propagation.cpp 
b/src/glsl/opt_constant_propagation.cpp
index c5ae36b..a038119 100644
--- a/src/glsl/opt_constant_propagation.cpp
+++ b/src/glsl/opt_constant_propagation.cpp
@@ -92,6 +92,7 @@ public:
 ir_constant_propagation_visitor()
 {
progress = false;
+  killed_all = false;
mem_ctx = ralloc_context(0);
this-acp = new(mem_ctx) exec_list;
this-kills = new(mem_ctx) exec_list;


Both LGTM.  Candidates for stable branches?

Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] radeon: Fix memory leak in radeonCreateScreen2.

2012-11-30 Thread Brian Paul

On 11/30/2012 12:25 AM, Vinson Lee wrote:

Fixes a memory leak defect reported by Coverity.

Signed-off-by: Vinson Leev...@freedesktop.org
---
  src/mesa/drivers/dri/radeon/radeon_screen.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c 
b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 6f4750a..2e6cf3c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -510,8 +510,10 @@ radeonCreateScreen2(__DRIscreen *sPriv)
 }

 ret = radeon_set_screen_flags(screen, device_id);
-   if (ret == -1)
+   if (ret == -1) {
+ free(screen);
   return NULL;
+   }

 if (getenv(RADEON_NO_TCL))
   screen-chip_flags= ~RADEON_CHIPSET_TCL;



Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] suspect rcp code in llvmpipe

2012-11-30 Thread Jose Fonseca
- Original Message -
 On 11/30/2012 03:10 AM, Dave Airlie wrote:
  coverity pointed out the below as suspect, since num_iterations =
  0,
  and we do a loop from 0..0
 
  Dave.
 
if (FALSE  ((util_cpu_caps.has_sse  type.width == 32
  type.length == 4) ||
(util_cpu_caps.has_avx  type.width == 32  type.length
== 8))){
 const unsigned num_iterations = 0;
 LLVMValueRef res;
 unsigned i;
 const char *intrinsic = NULL;
 
 if (type.length == 4) {
intrinsic = llvm.x86.sse.rcp.ps;
 }
 else {
intrinsic = llvm.x86.avx.rcp.ps.256;
 }
 
 res = lp_build_intrinsic_unary(builder, intrinsic,
 bld-vec_type, a);
 
 for (i = 0; i  num_iterations; ++i) {
res = lp_build_rcp_refine(bld, a, res);
 }
  ___
  mesa-dev mailing list
  mesa-dev@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 
 I guess we could set num_iterations = 1 for now but it doesn't really
 matter since this block of code is disabled (note the if (FALSE)
 part).
 
 Jose, I think you wrote that code.

The code is correct with  num_iterations = 0. This means no Newton-Raphson 
iterations.

But as Brian said, this is disabled, because RCP + Newton-Raphson gives wrong 
results for 0 / Inf, which causes bad rendering on certain apps. So we just use 
DIV. But I'd rather keep the code there fore reference, as these things might 
change. (In particular, in certain cases we can be sure that input is not 
0/Inf/Nan, so we could use this there).

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


[Mesa-dev] [PATCH mesa] egl/wayland: Don't invalidate drawable on swap buffers

2012-11-30 Thread Ander Conselvan de Oliveira
We used to invalidate the drawable after a call to eglSwapBuffers(),
so that a wl_egl_window_resize() would take effect for the next frame.
However, that leads to calling dri2_get_buffers() when eglMakeCurrent()
is called with the current context and surface, and a later call to
wl_egl_window_resize() would not take effect until the next buffer
swap.

Instead, add a callback from wl_egl_window_resize() back to the wayland
egl platform, and invalidate the drawable only when it is resized.

This solves a bug on wayland clients when going back to windowed mode
from fullscreen when clicking a pop up menu, where the window size
after this would be the fullscreen size.

Note: this is a candidate for stable branches.
CC: wayland-de...@lists.freedesktop.org
---
 src/egl/drivers/dri2/platform_wayland.c|   20 +++-
 src/egl/wayland/wayland-egl/wayland-egl-priv.h |3 +++
 src/egl/wayland/wayland-egl/wayland-egl.c  |5 +
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index 8df22c0..e55f92b 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -97,6 +97,16 @@ static struct wl_buffer_listener wl_buffer_listener = {
wl_buffer_release
 };
 
+static void
+resize_callback(struct wl_egl_window *wl_win, void *data)
+{
+   struct dri2_egl_surface *dri2_surf = data;
+   struct dri2_egl_display *dri2_dpy =
+  dri2_egl_display(dri2_surf-base.Resource.Display);
+
+   (*dri2_dpy-flush-invalidate)(dri2_surf-dri_drawable);
+}
+
 /**
  * Called via eglCreateWindowSurface(), drv-API.CreateWindowSurface().
  */
@@ -142,6 +152,9 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
case EGL_WINDOW_BIT:
   dri2_surf-wl_win = (struct wl_egl_window *) window;
 
+  dri2_surf-wl_win-private = dri2_surf;
+  dri2_surf-wl_win-resize_callback = resize_callback;
+
   dri2_surf-base.Width =  -1;
   dri2_surf-base.Height = -1;
   break;
@@ -216,6 +229,12 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf)
if (dri2_surf-frame_callback)
   wl_callback_destroy(dri2_surf-frame_callback);
 
+
+   if (dri2_surf-base.Type == EGL_WINDOW_BIT) {
+  dri2_surf-wl_win-private = NULL;
+  dri2_surf-wl_win-resize_callback = NULL;
+   }
+
free(surf);
 
return EGL_TRUE;
@@ -592,7 +611,6 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *draw)
}
 
(*dri2_dpy-flush-flush)(dri2_surf-dri_drawable);
-   (*dri2_dpy-flush-invalidate)(dri2_surf-dri_drawable);
 
return EGL_TRUE;
 }
diff --git a/src/egl/wayland/wayland-egl/wayland-egl-priv.h 
b/src/egl/wayland/wayland-egl/wayland-egl-priv.h
index bdbf32a..da25be9 100644
--- a/src/egl/wayland/wayland-egl/wayland-egl-priv.h
+++ b/src/egl/wayland/wayland-egl/wayland-egl-priv.h
@@ -24,6 +24,9 @@ struct wl_egl_window {
 
int attached_width;
int attached_height;
+
+   void *private;
+   void (*resize_callback)(struct wl_egl_window *, void *);
 };
 
 #ifdef  __cplusplus
diff --git a/src/egl/wayland/wayland-egl/wayland-egl.c 
b/src/egl/wayland/wayland-egl/wayland-egl.c
index c61fb4f..8bd49cf 100644
--- a/src/egl/wayland/wayland-egl/wayland-egl.c
+++ b/src/egl/wayland/wayland-egl/wayland-egl.c
@@ -13,6 +13,9 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
egl_window-height = height;
egl_window-dx = dx;
egl_window-dy = dy;
+
+   if (egl_window-resize_callback)
+   egl_window-resize_callback(egl_window, egl_window-private);
 }
 
 WL_EGL_EXPORT struct wl_egl_window *
@@ -26,6 +29,8 @@ wl_egl_window_create(struct wl_surface *surface,
return NULL;
 
egl_window-surface = surface;
+   egl_window-private = NULL;
+   egl_window-resize_callback = NULL;
wl_egl_window_resize(egl_window, width, height, 0, 0);
egl_window-attached_width  = 0;
egl_window-attached_height = 0;
-- 
1.7.10.4

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


Re: [Mesa-dev] [PATCH mesa] egl/wayland: Don't invalidate drawable on swap buffers

2012-11-30 Thread Kristian Høgsberg
On Fri, Nov 30, 2012 at 05:41:02PM +0200, Ander Conselvan de Oliveira wrote:
 We used to invalidate the drawable after a call to eglSwapBuffers(),
 so that a wl_egl_window_resize() would take effect for the next frame.
 However, that leads to calling dri2_get_buffers() when eglMakeCurrent()
 is called with the current context and surface, and a later call to
 wl_egl_window_resize() would not take effect until the next buffer
 swap.
 
 Instead, add a callback from wl_egl_window_resize() back to the wayland
 egl platform, and invalidate the drawable only when it is resized.
 
 This solves a bug on wayland clients when going back to windowed mode
 from fullscreen when clicking a pop up menu, where the window size
 after this would be the fullscreen size.

Yes, this is good, it's the right fix for that problem.  And with the
resize callback we can avoid the getbuffers callback every frame which
should save a few cycles as well.

Thanks, applied.
Kristian

 Note: this is a candidate for stable branches.
 CC: wayland-de...@lists.freedesktop.org
 ---
  src/egl/drivers/dri2/platform_wayland.c|   20 +++-
  src/egl/wayland/wayland-egl/wayland-egl-priv.h |3 +++
  src/egl/wayland/wayland-egl/wayland-egl.c  |5 +
  3 files changed, 27 insertions(+), 1 deletion(-)
 
 diff --git a/src/egl/drivers/dri2/platform_wayland.c 
 b/src/egl/drivers/dri2/platform_wayland.c
 index 8df22c0..e55f92b 100644
 --- a/src/egl/drivers/dri2/platform_wayland.c
 +++ b/src/egl/drivers/dri2/platform_wayland.c
 @@ -97,6 +97,16 @@ static struct wl_buffer_listener wl_buffer_listener = {
 wl_buffer_release
  };
  
 +static void
 +resize_callback(struct wl_egl_window *wl_win, void *data)
 +{
 +   struct dri2_egl_surface *dri2_surf = data;
 +   struct dri2_egl_display *dri2_dpy =
 +  dri2_egl_display(dri2_surf-base.Resource.Display);
 +
 +   (*dri2_dpy-flush-invalidate)(dri2_surf-dri_drawable);
 +}
 +
  /**
   * Called via eglCreateWindowSurface(), drv-API.CreateWindowSurface().
   */
 @@ -142,6 +152,9 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
 EGLint type,
 case EGL_WINDOW_BIT:
dri2_surf-wl_win = (struct wl_egl_window *) window;
  
 +  dri2_surf-wl_win-private = dri2_surf;
 +  dri2_surf-wl_win-resize_callback = resize_callback;
 +
dri2_surf-base.Width =  -1;
dri2_surf-base.Height = -1;
break;
 @@ -216,6 +229,12 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
 _EGLSurface *surf)
 if (dri2_surf-frame_callback)
wl_callback_destroy(dri2_surf-frame_callback);
  
 +
 +   if (dri2_surf-base.Type == EGL_WINDOW_BIT) {
 +  dri2_surf-wl_win-private = NULL;
 +  dri2_surf-wl_win-resize_callback = NULL;
 +   }
 +
 free(surf);
  
 return EGL_TRUE;
 @@ -592,7 +611,6 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, 
 _EGLSurface *draw)
 }
  
 (*dri2_dpy-flush-flush)(dri2_surf-dri_drawable);
 -   (*dri2_dpy-flush-invalidate)(dri2_surf-dri_drawable);
  
 return EGL_TRUE;
  }
 diff --git a/src/egl/wayland/wayland-egl/wayland-egl-priv.h 
 b/src/egl/wayland/wayland-egl/wayland-egl-priv.h
 index bdbf32a..da25be9 100644
 --- a/src/egl/wayland/wayland-egl/wayland-egl-priv.h
 +++ b/src/egl/wayland/wayland-egl/wayland-egl-priv.h
 @@ -24,6 +24,9 @@ struct wl_egl_window {
  
   int attached_width;
   int attached_height;
 +
 + void *private;
 + void (*resize_callback)(struct wl_egl_window *, void *);
  };
  
  #ifdef  __cplusplus
 diff --git a/src/egl/wayland/wayland-egl/wayland-egl.c 
 b/src/egl/wayland/wayland-egl/wayland-egl.c
 index c61fb4f..8bd49cf 100644
 --- a/src/egl/wayland/wayland-egl/wayland-egl.c
 +++ b/src/egl/wayland/wayland-egl/wayland-egl.c
 @@ -13,6 +13,9 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
   egl_window-height = height;
   egl_window-dx = dx;
   egl_window-dy = dy;
 +
 + if (egl_window-resize_callback)
 + egl_window-resize_callback(egl_window, egl_window-private);
  }
  
  WL_EGL_EXPORT struct wl_egl_window *
 @@ -26,6 +29,8 @@ wl_egl_window_create(struct wl_surface *surface,
   return NULL;
  
   egl_window-surface = surface;
 + egl_window-private = NULL;
 + egl_window-resize_callback = NULL;
   wl_egl_window_resize(egl_window, width, height, 0, 0);
   egl_window-attached_width  = 0;
   egl_window-attached_height = 0;
 -- 
 1.7.10.4
 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600g: Use default mul/mad function for tgsi-to-llvm

2012-11-30 Thread Tom Stellard
On Thu, Nov 29, 2012 at 11:48:39PM +0100, Vincent Lejeune wrote:
 ---
  src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 12 
  1 file changed, 4 insertions(+), 8 deletions(-)


Reviewed-by: Tom Stellard thomas.stell...@amd.com
 
 diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
 b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 index 5e3d6c2..00c068d 100644
 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 @@ -547,12 +547,12 @@ static void emit_prepare_cube_coords(
   mad_args[2] = LLVMConstReal(type, 1.5);
  
   mad_args[0] = coords[0];
 - coords[0] = build_intrinsic(builder, llvm.AMDIL.mad.,
 - type, mad_args, 3, LLVMReadNoneAttribute);
 + coords[0] = lp_build_emit_llvm_ternary(bld_base, TGSI_OPCODE_MAD,
 + mad_args[0], mad_args[1], mad_args[2]);
  
   mad_args[0] = coords[1];
 - coords[1] = build_intrinsic(builder, llvm.AMDIL.mad.,
 - type, mad_args, 3, LLVMReadNoneAttribute);
 + coords[1] = lp_build_emit_llvm_ternary(bld_base, TGSI_OPCODE_MAD,
 + mad_args[0], mad_args[1], mad_args[2]);
  
   /* apply yxwy swizzle to cooords */
   coords[2] = coords[3];
 @@ -1123,15 +1123,11 @@ void radeon_llvm_context_init(struct 
 radeon_llvm_context * ctx)
   bld_base-op_actions[TGSI_OPCODE_LG2].intr_name = llvm.log2.f32;
   bld_base-op_actions[TGSI_OPCODE_LRP].emit = build_tgsi_intrinsic_nomem;
   bld_base-op_actions[TGSI_OPCODE_LRP].intr_name = llvm.AMDGPU.lrp;
 - bld_base-op_actions[TGSI_OPCODE_MAD].emit = build_tgsi_intrinsic_nomem;
 - bld_base-op_actions[TGSI_OPCODE_MAD].intr_name = llvm.AMDIL.mad.;
   bld_base-op_actions[TGSI_OPCODE_MAX].emit = build_tgsi_intrinsic_nomem;
   bld_base-op_actions[TGSI_OPCODE_MAX].intr_name = llvm.AMDIL.max.;
   bld_base-op_actions[TGSI_OPCODE_MOD].emit = emit_mod;
   bld_base-op_actions[TGSI_OPCODE_MIN].emit = build_tgsi_intrinsic_nomem;
   bld_base-op_actions[TGSI_OPCODE_MIN].intr_name = llvm.AMDIL.min.;
 - bld_base-op_actions[TGSI_OPCODE_MUL].emit = build_tgsi_intrinsic_nomem;
 - bld_base-op_actions[TGSI_OPCODE_MUL].intr_name = llvm.AMDGPU.mul;
   bld_base-op_actions[TGSI_OPCODE_NOT].emit = emit_not;
   bld_base-op_actions[TGSI_OPCODE_OR].emit = emit_or;
   bld_base-op_actions[TGSI_OPCODE_POW].emit = 
 build_tgsi_intrinsic_readonly;
 -- 
 1.8.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] gallivm: have a default emit function for fdiv/rcp

2012-11-30 Thread Tom Stellard
On Thu, Nov 29, 2012 at 11:50:22PM +0100, Vincent Lejeune wrote:
 ---
  src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 24 
 ++
  1 file changed, 24 insertions(+)

 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c 
 b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
 index 17f288f..ff21879 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
 @@ -584,6 +584,28 @@ mul_emit(
 emit_data-args[0], emit_data-args[1]);
  }
  
 +/*.TGSI_OPCODE_DIV.*/
 +static void fdiv_emit(
 +   const struct lp_build_tgsi_action * action,
 +   struct lp_build_tgsi_context * bld_base,
 +   struct lp_build_emit_data * emit_data)
 +{
 +   emit_data-output[emit_data-chan] = lp_build_div(bld_base-base,
 +   emit_data-args[0], emit_data-args[1]);

I don't like using the lp_build_* helpers for default operations, because
they can sometimes produce SSE intrinsics.  I think we should use LLVMBuildFDiv
here.

 +}
 +
 +/*.TGSI_OPCODE_RCP.*/
 +static void rcp_emit(
 +   const struct lp_build_tgsi_action * action,
 +   struct lp_build_tgsi_context * bld_base,
 +   struct lp_build_emit_data * emit_data)
 +{
 +   LLVMValueRef one;
 +   one = lp_build_const_float(bld_base-base.gallivm, 1.0f);
 +   emit_data-output[emit_data-chan] = lp_build_div(bld_base-base,
 +   one, emit_data-args[0]);

Instead of lp_build_div, we should use lp_build_emit_llvm_binary() with
TGSI_OPCODE_DIV.

 +}
 +
  /* TGSI_OPCODE_POW */
  
  static void
 @@ -811,6 +833,8 @@ lp_set_default_actions(struct lp_build_tgsi_context * 
 bld_base)
 bld_base-op_actions[TGSI_OPCODE_MAD].emit = mad_emit;
 bld_base-op_actions[TGSI_OPCODE_MOV].emit = mov_emit;
 bld_base-op_actions[TGSI_OPCODE_MUL].emit = mul_emit;
 +   bld_base-op_actions[TGSI_OPCODE_DIV].emit = fdiv_emit;
 +   bld_base-op_actions[TGSI_OPCODE_RCP].emit = rcp_emit;
 bld_base-op_actions[TGSI_OPCODE_SFL].emit = sfl_emit;
 bld_base-op_actions[TGSI_OPCODE_STR].emit = str_emit;
 bld_base-op_actions[TGSI_OPCODE_SUB].emit = sub_emit;
 -- 
 1.8.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 2/2] r600g: use default action for fdiv/rcp opcode

2012-11-30 Thread Tom Stellard
On Thu, Nov 29, 2012 at 11:50:23PM +0100, Vincent Lejeune wrote:
 ---
  src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 7 +--
  1 file changed, 1 insertion(+), 6 deletions(-)


Reviewed-by: Tom Stellard thomas.stell...@amd.com
 
 diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
 b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 index 00c068d..2521582 100644
 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 @@ -540,8 +540,7 @@ static void emit_prepare_cube_coords(
  
   coords[2] = build_intrinsic(builder, fabs,
   type, coords[2], 1, LLVMReadNoneAttribute);
 - coords[2] = build_intrinsic(builder, llvm.AMDGPU.rcp,
 - type, coords[2], 1, LLVMReadNoneAttribute);
 + coords[2] = lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_RCP, 
 coords[2]);
  
   mad_args[1] = coords[2];
   mad_args[2] = LLVMConstReal(type, 1.5);
 @@ -1088,8 +1087,6 @@ void radeon_llvm_context_init(struct 
 radeon_llvm_context * ctx)
   bld_base-op_actions[TGSI_OPCODE_DDX].fetch_args = tex_fetch_args;
   bld_base-op_actions[TGSI_OPCODE_DDY].intr_name = llvm.AMDGPU.ddy;
   bld_base-op_actions[TGSI_OPCODE_DDY].fetch_args = tex_fetch_args;
 - bld_base-op_actions[TGSI_OPCODE_DIV].emit = build_tgsi_intrinsic_nomem;
 - bld_base-op_actions[TGSI_OPCODE_DIV].intr_name = llvm.AMDGPU.div;
   bld_base-op_actions[TGSI_OPCODE_ELSE].emit = else_emit;
   bld_base-op_actions[TGSI_OPCODE_ENDIF].emit = endif_emit;
   bld_base-op_actions[TGSI_OPCODE_ENDLOOP].emit = endloop_emit;
 @@ -1132,8 +1129,6 @@ void radeon_llvm_context_init(struct 
 radeon_llvm_context * ctx)
   bld_base-op_actions[TGSI_OPCODE_OR].emit = emit_or;
   bld_base-op_actions[TGSI_OPCODE_POW].emit = 
 build_tgsi_intrinsic_readonly;
   bld_base-op_actions[TGSI_OPCODE_POW].intr_name = llvm.pow.f32;
 - bld_base-op_actions[TGSI_OPCODE_RCP].emit = build_tgsi_intrinsic_nomem;
 - bld_base-op_actions[TGSI_OPCODE_RCP].intr_name = llvm.AMDGPU.rcp;
   bld_base-op_actions[TGSI_OPCODE_ROUND].emit = 
 build_tgsi_intrinsic_nomem;
   bld_base-op_actions[TGSI_OPCODE_ROUND].intr_name = 
 llvm.AMDIL.round.nearest.;
   bld_base-op_actions[TGSI_OPCODE_SGE].emit = emit_cmp;
 -- 
 1.8.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] gallivm: Have a default emit function for min/max opcode

2012-11-30 Thread Tom Stellard
On Thu, Nov 29, 2012 at 11:51:32PM +0100, Vincent Lejeune wrote:
 ---
  src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 31 
 ++
  1 file changed, 31 insertions(+)
 
 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c 
 b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
 index ff21879..070945c 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
 @@ -743,6 +743,34 @@ umul_emit(
 emit_data-args[0], emit_data-args[1]);
  }
  
 +/* TGSI_OPCODE_MAX */
 +static void fmax_emit(
 +   const struct lp_build_tgsi_action * action,
 +   struct lp_build_tgsi_context * bld_base,
 +   struct lp_build_emit_data * emit_data)
 +{
 +   LLVMValueRef comparison;
 +   comparison = lp_build_cmp(bld_base-base, PIPE_FUNC_GEQUAL, 
 emit_data-args[0],
 +   emit_data-args[1]);
 +   emit_data-output[emit_data-chan] = lp_build_select(bld_base-base,
 +   comparison, emit_data-args[0],
 +   emit_data-args[1]);
 +}

What you had in the previous patch was fine, the lp_build_cmp() function may
generate SSE intrinsics.

 +
 +/* TGSI_OPCODE_MIN */
 +static void fmin_emit(
 +   const struct lp_build_tgsi_action * action,
 +   struct lp_build_tgsi_context * bld_base,
 +   struct lp_build_emit_data * emit_data)
 +{
 +  LLVMValueRef comparison;
 +  comparison = lp_build_cmp(bld_base-base, PIPE_FUNC_GEQUAL, 
 emit_data-args[0],
 +  emit_data-args[1]);
 +  emit_data-output[emit_data-chan] = lp_build_select(bld_base-base,
 +  comparison, emit_data-args[1],
 +  emit_data-args[0]);
 +}

Same here too.

 +
  /* TGSI_OPCODE_XPD */
  
  static void
 @@ -843,6 +871,9 @@ lp_set_default_actions(struct lp_build_tgsi_context * 
 bld_base)
 bld_base-op_actions[TGSI_OPCODE_U2F].emit = u2f_emit;
 bld_base-op_actions[TGSI_OPCODE_UMAD].emit = umad_emit;
 bld_base-op_actions[TGSI_OPCODE_UMUL].emit = umul_emit;
 +
 +   bld_base-op_actions[TGSI_OPCODE_MAX].emit = fmax_emit;
 +   bld_base-op_actions[TGSI_OPCODE_MIN].emit = fmin_emit;
  }
  
  /* CPU Only default actions */
 -- 
 1.8.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 2/2] r600g: use default action for min/max opcode in tgsi to llvm

2012-11-30 Thread Tom Stellard
On Thu, Nov 29, 2012 at 11:51:33PM +0100, Vincent Lejeune wrote:
 ---
  src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 4 
  1 file changed, 4 deletions(-)


I think it would be good to replace the MIN/MAX patterns in
{R600,SI}Instructions.td to match LLVM IR rather than the
old intrinsics and also to update the test cases in test/CodeGen/R600

Reviewed-by: Tom Stellard thomas.stell...@amd.com
 
 diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
 b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 index 2521582..9cb0e9a 100644
 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
 @@ -1120,11 +1120,7 @@ void radeon_llvm_context_init(struct 
 radeon_llvm_context * ctx)
   bld_base-op_actions[TGSI_OPCODE_LG2].intr_name = llvm.log2.f32;
   bld_base-op_actions[TGSI_OPCODE_LRP].emit = build_tgsi_intrinsic_nomem;
   bld_base-op_actions[TGSI_OPCODE_LRP].intr_name = llvm.AMDGPU.lrp;
 - bld_base-op_actions[TGSI_OPCODE_MAX].emit = build_tgsi_intrinsic_nomem;
 - bld_base-op_actions[TGSI_OPCODE_MAX].intr_name = llvm.AMDIL.max.;
   bld_base-op_actions[TGSI_OPCODE_MOD].emit = emit_mod;
 - bld_base-op_actions[TGSI_OPCODE_MIN].emit = build_tgsi_intrinsic_nomem;
 - bld_base-op_actions[TGSI_OPCODE_MIN].intr_name = llvm.AMDIL.min.;
   bld_base-op_actions[TGSI_OPCODE_NOT].emit = emit_not;
   bld_base-op_actions[TGSI_OPCODE_OR].emit = emit_or;
   bld_base-op_actions[TGSI_OPCODE_POW].emit = 
 build_tgsi_intrinsic_readonly;
 -- 
 1.8.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 2/2] radeon/llvm: replace int_AMDGPU_rcp by fdiv (1.0, x) in RECIP pattern

2012-11-30 Thread Tom Stellard
On Thu, Nov 29, 2012 at 09:58:40PM +0100, Vincent Lejeune wrote:
 ---
  lib/Target/AMDGPU/R600Instructions.td | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/lib/Target/AMDGPU/R600Instructions.td 
 b/lib/Target/AMDGPU/R600Instructions.td
 index 9259680..d75c32e 100644
 --- a/lib/Target/AMDGPU/R600Instructions.td
 +++ b/lib/Target/AMDGPU/R600Instructions.td
 @@ -898,8 +898,8 @@ class RECIP_CLAMPED_Common bits11 inst : R600_1OP 
inst, RECIP_CLAMPED, []
  ;
  
 -class RECIP_IEEE_Common bits11 inst : R600_1OP_Helper 
 -  inst, RECIP_IEEE, int_AMDGPU_rcp
 +class RECIP_IEEE_Common bits11 inst : R600_1OP 
 +  inst, RECIP_IEEE, [(set R600_Reg32:$dst, (fdiv FP_ONE, 
 R600_Reg32:$src0))]
  ;

We should update the pattern in SIInstructions.td too.
  
  class RECIP_UINT_Common bits11 inst : R600_1OP_Helper 
 -- 
 1.8.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] Proposal: allow hidden security bugs on Mesa's Bugzilla

2012-11-30 Thread Jerome Glisse
On Fri, Nov 30, 2012 at 7:43 AM, Benoit Jacob bja...@mozilla.com wrote:
 On 12-11-23 02:21 PM, Benoit Jacob wrote:
 On 12-11-21 12:48 PM, Chad Versace wrote:
 On 11/20/2012 09:29 AM, Benoit Jacob wrote:

 Any questions?
 Do you support or oppose me asking FD.o admins to allow hidden bugs on
 Mesa's bugzilla?

 Benoit
 I support this. It seems a sensible proposal for addressing security bugs.

 Thanks. I have just sent the request to FD.o admins.

 Benoit

 This option is now turned on on Bugzilla.

 See the new checkbox: Mesa Security Group

 Thanks!
 Benoit


How does one get into the security group ?

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


Re: [Mesa-dev] Please test the automake-gallium4 branch

2012-11-30 Thread Tom Stellard
On Wed, Nov 28, 2012 at 07:50:02PM +0100, Andreas Boll wrote:
 2012/11/28 Michel Dänzer mic...@daenzer.net:
  On Fre, 2012-11-23 at 22:23 +0100, Andreas Boll wrote:
 
  Please help Matt and me to test the automake-gallium4 branch [1] !
 
  Here you have a list of things you could test:
  [...]
  - radeonsi
 
  make[4]: Entering directory 
  `/home/daenzer/src/mesa-git/mesa/src/gallium/drivers/radeon'
GENSIRegisterGetHWRegNum.inc
  make[4]: ***   GENR600RegisterInfo.td
GENSIRegisterInfo.td
  No rule to make target `R600IntrinsicsNoOpenCL.td', needed by 
  `AMDGPUGenRegisterInfo.inc'.  Stop.
 
 
 Tom, could you look at this issue?


I've attached two patches that fix this issue, but I'm now seeing the old
duplicate symbols bug when linking egl-static.  See attached build.log
and configure script.

-Tom
 
 
  Note that in current master, src/gallium/drivers/radeon requires the
  backend from Tom's LLVM (3.2) tree and doesn't use some of the files in
  src/gallium/drivers/radeon.
 
 
  - Vega (OpenVG)
 
  make[3]: Entering directory `/home/daenzer/src/mesa-git/mesa/src/mapi/vgapi'
  make[3]: *** No rule to make target `/src/mapi/mapi/entry.c', needed by 
  `entry.lo'.  Stop.
 
 
 I've pushed a fix for the vgapi build failure to my branch.
 
 Thanks for testing Michel!
 
 Andreas.
From fce04fe8ce93b9d4574df32c0a95e9e5ed856dcf Mon Sep 17 00:00:00 2001
From: Tom Stellard thomas.stell...@amd.com
Date: Thu, 29 Nov 2012 10:19:45 -0500
Subject: [PATCH 1/2] radeon/llvm: Stop supporting patched LLVM 3.1 installs

Compute support no longer depends on a patched version of LLVM, so we
can remove all the Makefile logic to determine if the current version
of LLVM has been patched.
---
 configure.ac   |4 ---
 src/gallium/drivers/radeon/.gitignore  |1 -
 src/gallium/drivers/radeon/Makefile.sources|3 --
 src/gallium/drivers/radeon/R600IntrinsicsOpenCL.td |   26 
 4 files changed, 0 insertions(+), 34 deletions(-)
 delete mode 100644 src/gallium/drivers/radeon/R600IntrinsicsOpenCL.td

diff --git a/configure.ac b/configure.ac
index e64f643..9acdd08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1812,9 +1812,6 @@ if test x$with_gallium_drivers != x; then
 if test x$enable_opencl = xyes -a x$with_llvm_shared_libs = xno; then
 LLVM_LIBS=${LLVM_LIBS} `$LLVM_CONFIG --libs bitreader asmparser`
 fi
-if grep '\IntrinsicsR600.td\' $LLVM_INCLUDEDIR/llvm/Intrinsics.td /dev/null 21; then
-HAVE_R600_LLVM_INTRINSICS=yes;
-fi
 gallium_check_st radeon/drm dri-r600 xorg-r600  xvmc-r600 vdpau-r600
 ;;
 xradeonsi)
@@ -1920,7 +1917,6 @@ AM_CONDITIONAL(HAVE_IDENTITY_GALLIUM, test x$HAVE_IDENTITY_GALLIUM = xyes)
 AM_CONDITIONAL(HAVE_NOOP_GALLIUM, test x$HAVE_NOOP_GALLIUM = xyes)
 AM_CONDITIONAL(NEED_RADEON_GALLIUM, test x$NEED_RADEON_GALLIUM = xyes)
 AM_CONDITIONAL(USE_R600_LLVM_COMPILER, test x$USE_R600_LLVM_COMPILER = xyes)
-AM_CONDITIONAL(HAVE_R600_LLVM_INTRINSICS, test x$HAVE_R600_LLVM_INTRINSICS = xyes)
 AM_CONDITIONAL(HAVE_LOADER_GALLIUM, test x$enable_gallium_loader = xyes)
 AM_CONDITIONAL(HAVE_DRM_LOADER_GALLIUM, test x$enable_gallium_drm_loader = xyes)
 AM_CONDITIONAL(HAVE_GALLIUM_COMPUTE, test x$enable_opencl = xyes)
diff --git a/src/gallium/drivers/radeon/.gitignore b/src/gallium/drivers/radeon/.gitignore
index 98c586a..077c1c5 100644
--- a/src/gallium/drivers/radeon/.gitignore
+++ b/src/gallium/drivers/radeon/.gitignore
@@ -22,7 +22,6 @@ AMDILGenIntrinsics.inc
 AMDILGenRegisterInfo.inc
 AMDILGenSubtargetInfo.inc
 R600HwRegInfo.include
-R600Intrinsics.td
 R600RegisterInfo.td
 SIRegisterGetHWRegNum.inc
 SIRegisterInfo.td
diff --git a/src/gallium/drivers/radeon/Makefile.sources b/src/gallium/drivers/radeon/Makefile.sources
index 4c1380f..9c142b4 100644
--- a/src/gallium/drivers/radeon/Makefile.sources
+++ b/src/gallium/drivers/radeon/Makefile.sources
@@ -12,8 +12,6 @@ TD_FILES :=\
 	Processors.td			\
 	R600Instructions.td		\
 	R600Intrinsics.td		\
-	R600IntrinsicsNoOpenCL.td	\
-	R600IntrinsicsOpenCL.td		\
 	R600RegisterInfo.td		\
 	R600Schedule.td			\
 	SIInstrFormats.td		\
@@ -24,7 +22,6 @@ TD_FILES :=\
 	SISchedule.td
 
 LLVM_GENERATED_FILES :=		\
-	R600Intrinsics.td		\
 	R600RegisterInfo.td		\
 	SIRegisterInfo.td		\
 	SIRegisterGetHWRegNum.inc	\
diff --git a/src/gallium/drivers/radeon/R600IntrinsicsOpenCL.td b/src/gallium/drivers/radeon/R600IntrinsicsOpenCL.td
deleted file mode 100644
index 00877ca..000
--- a/src/gallium/drivers/radeon/R600IntrinsicsOpenCL.td
+++ /dev/null
@@ -1,26 +0,0 @@
-//===-- R600Intrinsics.td - TODO: Add brief description ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//

[Mesa-dev] [PATCH 1/2] llvmpipe: Recompute the fs shader key when framebuffer varies.

2012-11-30 Thread jfonseca
From: José Fonseca jfons...@vmware.com

The fs shader now depends on the color buffer formats. The shader key was
extended to accommodate this, but llvmpipe_update_derived needs to be
updated to check the framebuffer dirty flag.

This fixes bug 57674.
---
 src/gallium/drivers/llvmpipe/lp_state_derived.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c 
b/src/gallium/drivers/llvmpipe/lp_state_derived.c
index 056e163..5bb5a7a 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_derived.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c
@@ -145,6 +145,7 @@ void llvmpipe_update_derived( struct llvmpipe_context 
*llvmpipe )
   compute_vertex_info( llvmpipe );
 
if (llvmpipe-dirty  (LP_NEW_FS |
+  LP_NEW_FRAMEBUFFER |
   LP_NEW_BLEND |
   LP_NEW_SCISSOR |
   LP_NEW_DEPTH_STENCIL_ALPHA |
-- 
1.7.9.5

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


[Mesa-dev] [PATCH 2/2] llvmpipe: Improve color buffer loads/stores alignment.

2012-11-30 Thread jfonseca
From: José Fonseca jfons...@vmware.com

Tell LLVM the exact alignment we can guarantee, based on the fs block
dimensions, pixel format, and the alignment of the resource base pointer
and stride.
---
 src/gallium/drivers/llvmpipe/lp_state_fs.c |   31 +++-
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 2d2e346..6819d33 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -839,7 +839,8 @@ load_unswizzled_block(struct gallivm_state *gallivm,
   unsigned block_height,
   LLVMValueRef* dst,
   struct lp_type dst_type,
-  unsigned dst_count)
+  unsigned dst_count,
+  unsigned dst_alignment)
 {
LLVMBuilderRef builder = gallivm-builder;
unsigned row_size = dst_count / block_height;
@@ -866,9 +867,7 @@ load_unswizzled_block(struct gallivm_state *gallivm,
 
   dst[i] = LLVMBuildLoad(builder, dst_ptr, );
 
-  if ((dst_type.length % 3) == 0) {
- lp_set_load_alignment(dst[i], dst_type.width / 8);
-  }
+  lp_set_load_alignment(dst[i], dst_alignment);
}
 }
 
@@ -884,7 +883,8 @@ store_unswizzled_block(struct gallivm_state *gallivm,
unsigned block_height,
LLVMValueRef* src,
struct lp_type src_type,
-   unsigned src_count)
+   unsigned src_count,
+   unsigned src_alignment)
 {
LLVMBuilderRef builder = gallivm-builder;
unsigned row_size = src_count / block_height;
@@ -893,6 +893,8 @@ store_unswizzled_block(struct gallivm_state *gallivm,
/* Ensure src exactly fits into block */
assert((block_width * block_height) % src_count == 0);
 
+
+
for (i = 0; i  src_count; ++i) {
   unsigned x = i % row_size;
   unsigned y = i / row_size;
@@ -911,9 +913,7 @@ store_unswizzled_block(struct gallivm_state *gallivm,
 
   src_ptr = LLVMBuildStore(builder, src[i], src_ptr);
 
-  if ((src_type.length % 3) == 0) {
- lp_set_store_alignment(src_ptr, src_type.width / 8);
-  }
+  lp_set_store_alignment(src_ptr, src_alignment);
}
 }
 
@@ -1333,6 +1333,8 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
 
const struct util_format_description* out_format_desc = 
util_format_description(out_format);
 
+   unsigned dst_alignment;
+
bool pad_inline = is_arithmetic_format(out_format_desc);
bool has_alpha = false;
 
@@ -1340,6 +1342,13 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
mask_type = lp_int32_vec4_type();
mask_type.length = fs_type.length;
 
+   /* Compute the alignment of the destination pointer in bytes */
+   dst_alignment = (block_width * out_format_desc-block.bits + 
7)/(out_format_desc-block.width * 8);
+   /* Force power-of-two alignment by extracting only the 
least-significant-bit */
+   dst_alignment = 1  (ffs(dst_alignment) - 1);
+   /* Resource base and stride pointers are aligned to 16 bytes, so that's the 
maximum alignment we can guarantee */
+   dst_alignment = MIN2(dst_alignment, 16);
+
/* Do not bother executing code when mask is empty.. */
if (do_branch) {
   check_mask = LLVMConstNull(lp_build_int_vec_type(gallivm, mask_type));
@@ -1616,7 +1625,8 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
 
dst_type.length *= 16 / dst_count;
 
-   load_unswizzled_block(gallivm, color_ptr, stride, block_width, 
block_height, dst, dst_type, dst_count);
+   load_unswizzled_block(gallivm, color_ptr, stride, block_width, block_height,
+ dst, dst_type, dst_count, dst_alignment);
 
 
/*
@@ -1681,7 +1691,8 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
/*
 * Store blend result to memory
 */
-   store_unswizzled_block(gallivm, color_ptr, stride, block_width, 
block_height, dst, dst_type, dst_count);
+   store_unswizzled_block(gallivm, color_ptr, stride, block_width, 
block_height,
+  dst, dst_type, dst_count, dst_alignment);
 
if (do_branch) {
   lp_build_mask_end(mask_ctx);
-- 
1.7.9.5

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


[Mesa-dev] [Bug 57241] Gallium drivers should support forward-compatible contexts

2012-11-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=57241

--- Comment #8 from Ian Romanick i...@freedesktop.org ---
(In reply to comment #7)
 This is not a bug. Failing to create a forward compatible context is allowed
 by the specification.

Right... which is why I changed the subject and changed the severity to
enhancement.  It is, in fact, an enhancement request. :)  It doesn't matter
because you've already implemented support for it.

-- 
You are receiving this mail because:
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] glsl: fix cut-n-paste error in error handling. (v2)

2012-11-30 Thread Ian Romanick

On 11/30/2012 12:34 AM, Dave Airlie wrote:

Reported by coverity scan.

v2: fix second case

Signed-off-by: Dave Airlie airl...@redhat.com


This should also go into stable branches.  It should only affect debug 
builds.


Reviewed-by: Ian Romanick ian.d.roman...@intel.com


---
  src/glsl/ir_validate.cpp | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index af0b576..ad57a31 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -120,7 +120,7 @@ ir_visitor_status
  ir_validate::visit_leave(ir_loop *ir)
  {
 if (ir-counter != NULL) {
-  if ((ir-from == NULL) || (ir-from == NULL) || (ir-increment == NULL)) 
{
+  if ((ir-from == NULL) || (ir-to == NULL) || (ir-increment == NULL)) {
 printf(ir_loop has invalid loop controls:\n
counter:   %p\n
from:  %p\n
@@ -136,7 +136,7 @@ ir_validate::visit_leave(ir_loop *ir)
 abort();
}
 } else {
-  if ((ir-from != NULL) || (ir-from != NULL) || (ir-increment != NULL)) 
{
+  if ((ir-from != NULL) || (ir-to != NULL) || (ir-increment != NULL)) {
 printf(ir_loop has invalid loop controls:\n
counter:   %p\n
from:  %p\n



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


Re: [Mesa-dev] [PATCH] android: fix bison warning of conflicting outputs to file

2012-11-30 Thread Ian Romanick

On 11/29/2012 11:52 PM, gro...@gmail.com wrote:

From: Adrian Marius Negreanu adrian.m.negre...@intel.com

Bison -o parameter expects a .c file.
The corresponding .h filename is obtained
by removing the extension of the initial .c.

This was breaking compilation on Ubuntu 12.04

libmesa_dricore_intermediates/libmesa_dricore.a(program_parse.tab.o):
In function `_mesa_parse_arb_program':
external/mesa/src/mesa/program/program_parse.y:2682: multiple definition
of `_mesa_parse_arb_program'
libmesa_dricore_intermediates/libmesa_dricore.a(lex.yy.o):external/mesa/src/mesa/program/program_parse.y:2682:
first defined here

Signed-off-by: Adrian Marius Negreanu adrian.m.negre...@intel.com
---
  src/mesa/program/Android.mk | 3 ---
  1 file changed, 3 deletions(-)

diff --git a/src/mesa/program/Android.mk b/src/mesa/program/Android.mk
index 5eb0439..7125061 100644
--- a/src/mesa/program/Android.mk
+++ b/src/mesa/program/Android.mk
@@ -65,9 +65,6 @@ LOCAL_GENERATED_SOURCES := \
  $(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program_parse.y
$(mesa_local-y-to-c-and-h)

-$(intermediates)/program/program_parse.tab.h: $(LOCAL_PATH)/program_parse.y
-   $(mesa_local-y-to-c-and-h)
-


Isn't it possible that removing this dependency will break parallel 
builds in some cases?



  $(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program_lexer.l
$(local-l-to-c)




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


Re: [Mesa-dev] [PATCH] mesa: move some helper functions from fboobject.c to glformats.c

2012-11-30 Thread Ian Romanick

On 11/28/2012 04:32 PM, Marek Olšák wrote:

On Thu, Nov 29, 2012 at 1:23 AM, Ian Romanick i...@freedesktop.org wrote:

On 11/28/2012 10:07 AM, Marek Olšák wrote:

It looks reasonable enough, but... why?  Is there a follow-up patch that
uses it them in some other file?


Brian suggested it just in case somebody else needs to use the
functions.


Okay, that makes sense.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

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


[Mesa-dev] [PATCH 01/26] mesa: Add ARB_ES3_compatibility flag.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Adding this now makes it easier to develop and test GLES3 features, since we
can do initial development and testing using desktop GL.  Later GLSL compiler
patches check for either ctx-Extensions.ARB_ES3_compatibility or
_mesa_is_gles3 to allow certain features (i.e., #version 300 es).

[v2, idr]: Just edits to the commit message.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/builtins/tools/generate_builtins.py | 1 +
 src/glsl/standalone_scaffolding.cpp  | 1 +
 src/mesa/main/extensions.c   | 1 +
 src/mesa/main/mtypes.h   | 1 +
 4 files changed, 4 insertions(+)

diff --git a/src/glsl/builtins/tools/generate_builtins.py 
b/src/glsl/builtins/tools/generate_builtins.py
index 7eccb7d..d7c393e 100755
--- a/src/glsl/builtins/tools/generate_builtins.py
+++ b/src/glsl/builtins/tools/generate_builtins.py
@@ -176,6 +176,7 @@ read_builtins(GLenum target, const char *protos, const char 
**functions, unsigne
fakeCtx.API = API_OPENGL;
fakeCtx.Const.GLSLVersion = 140;
fakeCtx.Extensions.ARB_ES2_compatibility = true;
+   fakeCtx.Extensions.ARB_ES3_compatibility = true;
fakeCtx.Const.ForceGLSLExtensionsWarn = false;
gl_shader *sh = _mesa_new_shader(NULL, 0, target);
struct _mesa_glsl_parse_state *st =
diff --git a/src/glsl/standalone_scaffolding.cpp 
b/src/glsl/standalone_scaffolding.cpp
index 120ee95..33d3804 100644
--- a/src/glsl/standalone_scaffolding.cpp
+++ b/src/glsl/standalone_scaffolding.cpp
@@ -73,6 +73,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, 
gl_api api)
ctx-Extensions.dummy_false = false;
ctx-Extensions.dummy_true = true;
ctx-Extensions.ARB_ES2_compatibility = true;
+   ctx-Extensions.ARB_ES3_compatibility = false;
ctx-Extensions.ARB_draw_instanced = true;
ctx-Extensions.ARB_fragment_coord_conventions = true;
ctx-Extensions.EXT_texture_array = true;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index d5a7886..50919bf 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -80,6 +80,7 @@ struct extension {
 static const struct extension extension_table[] = {
/* ARB Extensions */
{ GL_ARB_ES2_compatibility,   o(ARB_ES2_compatibility),   
GL, 2009 },
+   { GL_ARB_ES3_compatibility,   o(ARB_ES3_compatibility),   
GL, 2012 },
{ GL_ARB_base_instance,   o(ARB_base_instance),   
GL, 2011 },
{ GL_ARB_blend_func_extended, o(ARB_blend_func_extended), 
GL, 2009 },
{ GL_ARB_color_buffer_float,  o(ARB_color_buffer_float),  
GL, 2004 },
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index da72da9..69518b7 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2939,6 +2939,7 @@ struct gl_extensions
GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
GLboolean ANGLE_texture_compression_dxt;
GLboolean ARB_ES2_compatibility;
+   GLboolean ARB_ES3_compatibility;
GLboolean ARB_base_instance;
GLboolean ARB_blend_func_extended;
GLboolean ARB_color_buffer_float;
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 02/26] glsl: Simplify symbol table version checking.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Previously, we stored the GLSL language version in the
glsl_symbol_table struct.  But this was unnecessary--all
glsl_symbol_table needs to know is whether functions and variables
have separate namespaces (they do in GLSL 1.10 only).

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/ast_function.cpp| 3 ++-
 src/glsl/ast_to_hir.cpp  | 2 +-
 src/glsl/builtins/tools/generate_builtins.py | 2 +-
 src/glsl/glsl_symbol_table.cpp   | 6 +++---
 src/glsl/glsl_symbol_table.h | 3 ++-
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index ea3282c..c0e05ad 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -324,7 +324,8 @@ match_function_by_name(const char *name,
   goto done; /* no match */
 
/* Is the function hidden by a variable (impossible in 1.10)? */
-   if (state-language_version != 110  state-symbols-get_variable(name))
+   if (!state-symbols-separate_function_namespace
+state-symbols-get_variable(name))
   goto done; /* no match */
 
if (f != NULL) {
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index d450aa1..75b551b 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -66,7 +66,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct 
_mesa_glsl_parse_state *state)
 {
_mesa_glsl_initialize_variables(instructions, state);
 
-   state-symbols-language_version = state-language_version;
+   state-symbols-separate_function_namespace = state-language_version == 
110;
 
state-current_function = NULL;
 
diff --git a/src/glsl/builtins/tools/generate_builtins.py 
b/src/glsl/builtins/tools/generate_builtins.py
index d7c393e..cd6229e 100755
--- a/src/glsl/builtins/tools/generate_builtins.py
+++ b/src/glsl/builtins/tools/generate_builtins.py
@@ -183,7 +183,7 @@ read_builtins(GLenum target, const char *protos, const char 
**functions, unsigne
   new(sh) _mesa_glsl_parse_state(fakeCtx, target, sh);
 
st-language_version = 140;
-   st-symbols-language_version = 140;
+   st-symbols-separate_function_namespace = false;
st-ARB_texture_rectangle_enable = true;
st-EXT_texture_array_enable = true;
st-OES_EGL_image_external_enable = true;
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index bcb65d3..f934ea8 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -52,7 +52,7 @@ public:
 
 glsl_symbol_table::glsl_symbol_table()
 {
-   this-language_version = 120;
+   this-separate_function_namespace = false;
this-table = _mesa_symbol_table_ctor();
this-mem_ctx = ralloc_context(NULL);
 }
@@ -80,7 +80,7 @@ bool glsl_symbol_table::name_declared_this_scope(const char 
*name)
 
 bool glsl_symbol_table::add_variable(ir_variable *v)
 {
-   if (this-language_version == 110) {
+   if (this-separate_function_namespace) {
   /* In 1.10, functions and variables have separate namespaces. */
   symbol_table_entry *existing = get_entry(v-name);
   if (name_declared_this_scope(v-name)) {
@@ -120,7 +120,7 @@ bool glsl_symbol_table::add_type(const char *name, const 
glsl_type *t)
 
 bool glsl_symbol_table::add_function(ir_function *f)
 {
-   if (this-language_version == 110  name_declared_this_scope(f-name)) {
+   if (this-separate_function_namespace  name_declared_this_scope(f-name)) 
{
   /* In 1.10, functions and variables have separate namespaces. */
   symbol_table_entry *existing = get_entry(f-name);
   if ((existing-f == NULL)  (existing-t == NULL)) {
diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h
index 637bc03..9f56027 100644
--- a/src/glsl/glsl_symbol_table.h
+++ b/src/glsl/glsl_symbol_table.h
@@ -77,7 +77,8 @@ public:
glsl_symbol_table();
~glsl_symbol_table();
 
-   unsigned int language_version;
+   /* In 1.10, functions and variables have separate namespaces. */
+   bool separate_function_namespace;
 
void push_scope();
void pop_scope();
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 04/26] glsl: Compute version_string on the fly.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Fixes a bug where version_string would be left uninitialized if no
GLSL #version directive was used.
---
 src/glsl/ast_to_hir.cpp   |  6 +++---
 src/glsl/glsl_parser.yy   | 13 +
 src/glsl/glsl_parser_extras.h | 11 ++-
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 75b551b..adada30 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -449,7 +449,7 @@ modulus_result_type(const struct glsl_type *type_a,
if (state-language_version  130) {
   _mesa_glsl_error(loc, state,
operator '%%' is reserved in %s,
-   state-version_string);
+   state-get_version_string());
   return glsl_type::error_type;
}
 
@@ -2618,13 +2618,13 @@ ast_declarator_list::hir(exec_list *instructions,
_mesa_glsl_error( loc, state,
 `out' qualifier in declaration of `%s' 
 only valid for function parameters in %s.,
-decl-identifier, state-version_string);
+decl-identifier, state-get_version_string());
 }
 if (this-type-qualifier.flags.q.in) {
_mesa_glsl_error( loc, state,
 `in' qualifier in declaration of `%s' 
 only valid for function parameters in %s.,
-decl-identifier, state-version_string);
+decl-identifier, state-get_version_string());
 }
 /* FINISHME: Test for other invalid qualifiers. */
   }
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 03e05ff..e68a601 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -289,14 +289,11 @@ version_statement:
   }
 
   state-language_version = $2;
-  state-version_string =
-  glsl_compute_version_string(state, state-es_shader,
-  state-language_version);
 
   if (!supported) {
  _mesa_glsl_error( @2, state, %s is not supported. 
   Supported versions are: %s\n,
-  state-version_string,
+  state-get_version_string(),
   state-supported_version_string);
   }
 
@@ -316,7 +313,7 @@ pragma_statement:
   if (state-language_version == 110) {
  _mesa_glsl_warning( @1, state,
 pragma `invariant(all)' not supported in %s,
-state-version_string);
+state-get_version_string());
   } else {
  state-all_invariant = true;
   }
@@ -1501,7 +1498,7 @@ precision_qualifier:
 precision qualifier forbidden 
 in %s (1.30 or later 
 required)\n,
-state-version_string);
+state-get_version_string());
 
 $$ = ast_precision_high;
  }
@@ -1511,7 +1508,7 @@ precision_qualifier:
 precision qualifier forbidden 
 in %s (1.30 or later 
 required)\n,
-state-version_string);
+state-get_version_string());
 
 $$ = ast_precision_medium;
  }
@@ -1521,7 +1518,7 @@ precision_qualifier:
 precision qualifier forbidden 
 in %s (1.30 or later 
 required)\n,
-state-version_string);
+state-get_version_string());
 
 $$ = ast_precision_low;
  }
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 5bad5a9..26fdee1 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -80,6 +80,16 @@ struct _mesa_glsl_parse_state {
   ralloc_free(mem);
}
 
+   /**
+* Generate a string representing the GLSL version currently being compiled
+* (useful for error messages).
+*/
+   const char *get_version_string()
+   {
+  return glsl_compute_version_string(this, this-es_shader,
+ this-language_version);
+   }
+
struct gl_context *const ctx;
void *scanner;
exec_list translation_unit;
@@ -91,7 +101,6 @@ struct _mesa_glsl_parse_state {
 
bool es_shader;
unsigned language_version;
-   const char *version_string;
enum 

[Mesa-dev] [PATCH 03/26] glsl: Make a function to express a GLSL version ir human-readable form.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

This will be useful in generating more helpful error messages,
especially with the addition of GLSL 3.00 ES support.

[v2, idr]: Rename ctx parameter to mem_ctx

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glsl_parser.yy |  6 ++
 src/glsl/glsl_parser_extras.cpp | 10 ++
 src/glsl/glsl_parser_extras.h   |  3 +++
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 407dbbe..03e05ff 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -290,10 +290,8 @@ version_statement:
 
   state-language_version = $2;
   state-version_string =
- ralloc_asprintf(state, GLSL%s %d.%02d,
- state-es_shader ?  ES : ,
- state-language_version / 100,
- state-language_version % 100);
+  glsl_compute_version_string(state, state-es_shader,
+  state-language_version);
 
   if (!supported) {
  _mesa_glsl_error( @2, state, %s is not supported. 
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index f1fdd3a..3e19203 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -37,6 +37,16 @@ extern C {
 #include ir_optimization.h
 #include loop_analysis.h
 
+/**
+ * Format a short human-readable description of the given GLSL version.
+ */
+const char *
+glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version)
+{
+   return ralloc_asprintf(mem_ctx, GLSL%s %d.%02d, is_es ?  ES : ,
+  version / 100, version % 100);
+}
+
 _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
   GLenum target, void *mem_ctx)
  : ctx(_ctx)
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 0b208f6..5bad5a9 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -56,6 +56,9 @@ struct glsl_switch_state {
bool is_switch_innermost; // if switch stmt is closest to break, ...
 };
 
+const char *
+glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version);
+
 struct _mesa_glsl_parse_state {
_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
  void *mem_ctx);
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 06/26] glsl: Make use of new _mesa_glsl_parse_state::is_version() function.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/ast_function.cpp |  2 +-
 src/glsl/ast_to_hir.cpp   | 40 ++--
 src/glsl/glsl_lexer.ll|  4 ++--
 src/glsl/glsl_parser.yy   |  5 +++--
 src/glsl/glsl_types.cpp   |  8 +---
 5 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index c0e05ad..5e1c891 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -277,7 +277,7 @@ generate_call(exec_list *instructions, 
ir_function_signature *sig,
 *
 * Function calls were first allowed to be constant expressions in GLSL 
1.20.
 */
-   if (state-language_version = 120) {
+   if (state-is_version(120, 0)) {
   ir_constant *value = sig-constant_expression_value(actual_parameters, 
NULL);
   if (value != NULL) {
 return value;
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index adada30..79e4be8 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -121,7 +121,7 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * 
from,
/* This conversion was added in GLSL 1.20.  If the compilation mode is
 * GLSL 1.10, the conversion is skipped.
 */
-   if (state-language_version  120)
+   if (!state-is_version(120, 0))
   return false;
 
/* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec:
@@ -1660,15 +1660,18 @@ ast_expression::hir(exec_list *instructions,
   array-type-element_type()-is_sampler() 
   const_index == NULL) {
 
-if (state-language_version == 100) {
-   _mesa_glsl_warning(loc, state,
-  sampler arrays indexed with non-constant 
-  expressions is optional in GLSL ES 1.00);
-} else if (state-language_version  130) {
-   _mesa_glsl_warning(loc, state,
-  sampler arrays indexed with non-constant 
-  expressions is forbidden in GLSL 1.30 and 
-  later);
+ if (!state-is_version(130, 100)) {
+if (state-es_shader) {
+   _mesa_glsl_warning(loc, state,
+  sampler arrays indexed with non-constant 
+  expressions is optional in %s,
+  state-get_version_string());
+} else {
+   _mesa_glsl_warning(loc, state,
+  sampler arrays indexed with non-constant 
+  expressions will be forbidden in GLSL 1.30 
and 
+  later);
+}
 } else {
_mesa_glsl_error(loc, state,
 sampler arrays indexed with non-constant 
@@ -2288,7 +2291,7 @@ get_variable_being_redeclared(ir_variable *var, 
ast_declaration *decl,
** gl_Color
** gl_SecondaryColor
*/
-   } else if (state-language_version = 130
+   } else if (state-is_version(130, 0)
   (strcmp(var-name, gl_FrontColor) == 0
  || strcmp(var-name, gl_BackColor) == 0
  || strcmp(var-name, gl_FrontSecondaryColor) == 0
@@ -2611,7 +2614,7 @@ ast_declarator_list::hir(exec_list *instructions,
* This is relaxed in GLSL 1.30.  It is also relaxed by any extension
* that adds the 'layout' keyword.
*/
-  if ((state-language_version  130)
+  if (!state-is_version(130, 0)
   !state-ARB_explicit_attrib_location_enable
   !state-ARB_fragment_coord_conventions_enable) {
 if (this-type-qualifier.flags.q.out) {
@@ -2712,7 +2715,7 @@ ast_declarator_list::hir(exec_list *instructions,
   break;
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
-  if (state-language_version  120)
+  if (state-is_version(120, 0))
  break;
   /* FALLTHROUGH */
default:
@@ -2741,7 +2744,7 @@ ast_declarator_list::hir(exec_list *instructions,
*vector, then it must be qualified with the interpolation qualifier
*flat.
*/
-  if (state-language_version = 130
+  if (state-is_version(130, 0)
state-target == vertex_shader
state-current_function == NULL
var-type-is_integer()
@@ -2761,7 +2764,7 @@ ast_declarator_list::hir(exec_list *instructions,
*centroid in, out, or centroid out in a declaration. They do not 
apply
*to the deprecated storage qualifiers varying or centroid varying.
*/
-  if (state-language_version = 130
+  if (state-is_version(130, 0)
this-type-qualifier.has_interpolation()
this-type-qualifier.flags.q.varying) {
 
@@ -2787,7 +2790,7 @@ ast_declarator_list::hir(exec_list *instructions,
*shader (in) can be further 

[Mesa-dev] [PATCH 07/26] glsl: Make use of new _mesa_glsl_parse_state::check_version() function.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Previous to this patch, we were not very consistent about the errors
we generate when a shader tried to use a feature that is prohibited in
the current GLSL version.  Some error messages failed to mention the
GLSL version currently in use (or did so inaccurately), and some error
messages failed to mention the first GLSL version in which the given
feature is allowed.

This patch reworks all of the error checks to use the check_version()
function, which produces error messages in a standard form
(approximately $FEATURE forbidden in $CURRENT_GLSL_VERSION
($REQUIRED_GLSL_VERSION required).).

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/ast_function.cpp| 15 
 src/glsl/ast_to_hir.cpp  | 74 +++-
 src/glsl/glsl_parser.yy  | 21 ++--
 src/glsl/glsl_parser_extras.h| 11 ++
 src/glsl/hir_field_selection.cpp |  3 +-
 5 files changed, 50 insertions(+), 74 deletions(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 5e1c891..8a5979f 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -1243,9 +1243,8 @@ ast_function_expression::hir(exec_list *instructions,
   }
 
   if (constructor_type-is_array()) {
-if (state-language_version = 110) {
-   _mesa_glsl_error( loc, state,
-array constructors forbidden in GLSL 1.10);
+ if (!state-check_version(120, 0, loc,
+   array constructors forbidden)) {
return ir_rvalue::error_value(ctx);
 }
 
@@ -1368,11 +1367,11 @@ ast_function_expression::hir(exec_list *instructions,
*It is an error to construct matrices from other matrices. This
*is reserved for future use.
*/
-  if (state-language_version == 110  matrix_parameters  0
-  constructor_type-is_matrix()) {
-_mesa_glsl_error( loc, state, cannot construct `%s' from a 
- matrix in GLSL 1.10,
- constructor_type-name);
+  if (matrix_parameters  0
+   constructor_type-is_matrix()
+   !state-check_version(120, 100, loc,
+   cannot construct `%s' from a matrix,
+   constructor_type-name)) {
 return ir_rvalue::error_value(ctx);
   }
 
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 79e4be8..394a7ef 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -390,8 +390,7 @@ bit_logic_result_type(const struct glsl_type *type_a,
   ast_operators op,
   struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
 {
-if (state-language_version  130) {
-   _mesa_glsl_error(loc, state, bit operations require GLSL 1.30);
+if (!state-check_bitwise_operations_allowed(loc)) {
return glsl_type::error_type;
 }
 
@@ -446,10 +445,7 @@ modulus_result_type(const struct glsl_type *type_a,
const struct glsl_type *type_b,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
 {
-   if (state-language_version  130) {
-  _mesa_glsl_error(loc, state,
-   operator '%%' is reserved in %s,
-   state-get_version_string());
+   if (!state-check_version(130, 0, loc, operator '%%' is reserved)) {
   return glsl_type::error_type;
}
 
@@ -553,8 +549,7 @@ shift_result_type(const struct glsl_type *type_a,
   ast_operators op,
   struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
 {
-   if (state-language_version  130) {
-  _mesa_glsl_error(loc, state, bit operations require GLSL 1.30);
+   if (!state-check_bitwise_operations_allowed(loc)) {
   return glsl_type::error_type;
}
 
@@ -694,15 +689,15 @@ do_assignment(exec_list *instructions, struct 
_mesa_glsl_parse_state *state,
   lhs-variable_referenced()-name);
  error_emitted = true;
 
-  } else if (state-language_version = 110  lhs-type-is_array()) {
+  } else if (lhs-type-is_array() 
+ !state-check_version(120, 0, lhs_loc,
+   whole array assignment forbidden)) {
 /* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
  *
  *Other binary or unary expressions, non-dereferenced
  * arrays, function names, swizzles with repeated fields,
  * and constants cannot be l-values.
  */
-_mesa_glsl_error(lhs_loc, state, whole array assignment is not 
- allowed in GLSL 1.10 or GLSL ES 1.00.);
 error_emitted = true;
   } else if (!lhs-is_lvalue()) {
 _mesa_glsl_error( lhs_loc, state, non-lvalue in assignment);
@@ -1099,9 +1094,7 @@ ast_expression::hir(exec_list *instructions,
 
case ast_lshift:
case ast_rshift:
-  

[Mesa-dev] [PATCH 08/26] glsl: Rework lexer keyword handling in preparation for GLSL 3.00 ES.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

This patch expands the lexer KEYWORD macro to take two additional
arguments: the GLSL ES versions in which the given keyword was first
reserved, and supported, respectively.  This will allow us to
trivially add support for GLSL 3.00 ES keywords, even though the set
of GLSL 3.00 ES keywords is neither a subset or a superset of the
keywords corresponding to any desktop GLSL version.

The new KEYWORD macro makes use of the
_mesa_glsl_parse_state::is_version() function, so it accepts 0 as
meaning unsupported (rather than 999, which we used previously).

Note that a few keywords (packed and row_major) are supported
*either* when GLSL 1.40 is in use or when ARB_uniform_buffer_obj
support is enabled.  Previously, we handled these by cleverly taking
advantage of the fact that the KEYWORD macro didn't parenthesize its
arguments in the usual way.  Now they are handled more
straightforwardly, with a new macro, KEYWORD_WITH_ALT.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glsl_lexer.ll | 268 +
 1 file changed, 136 insertions(+), 132 deletions(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index d2c8c31..ef1402b 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -48,20 +48,34 @@ static int classify_identifier(struct 
_mesa_glsl_parse_state *, const char *);
  *
  * Certain words start out as identifiers, become reserved words in
  * later language revisions, and finally become language keywords.
+ * This may happen at different times in desktop GLSL and GLSL ES.
  *
  * For example, consider the following lexer rule:
- * samplerBuffer   KEYWORD(130, 140, SAMPLERBUFFER)
+ * samplerBuffer   KEYWORD(130, 0, 140, 0, SAMPLERBUFFER)
  *
  * This means that samplerBuffer will be treated as:
  * - a keyword (SAMPLERBUFFER token) ...in GLSL = 1.40
  * - a reserved word - error ...in GLSL = 1.30
- * - an identifier   ...in GLSL   1.30
+ * - an identifier   ...in GLSL   1.30 or GLSL ES
  */
-#define KEYWORD(reserved_version, allowed_version, token)  \
+#define KEYWORD(reserved_glsl, reserved_glsl_es,   \
+allowed_glsl, allowed_glsl_es, token)  \
+   KEYWORD_WITH_ALT(reserved_glsl, reserved_glsl_es,   \
+allowed_glsl, allowed_glsl_es, false, token)
+
+/**
+ * Like the KEYWORD macro, but the word is also treated as a keyword
+ * if the given boolean expression is true.
+ */
+#define KEYWORD_WITH_ALT(reserved_glsl, reserved_glsl_es,  \
+ allowed_glsl, allowed_glsl_es,
\
+ alt_expr, token)  \
do {
\
-  if (yyextra-language_version = allowed_version) {  \
+  if (yyextra-is_version(allowed_glsl, allowed_glsl_es)   \
+  || alt_expr) {   \
 return token;  \
-  } else if (yyextra-language_version = reserved_version) {  \
+  } else if (yyextra-is_version(reserved_glsl,\
+ reserved_glsl_es)) {  \
 _mesa_glsl_error(yylloc, yyextra,  \
  Illegal use of reserved word `%s', yytext); \
 return ERROR_TOK;  \
@@ -71,16 +85,6 @@ static int classify_identifier(struct _mesa_glsl_parse_state 
*, const char *);
   }
\
} while (0)
 
-/* The ES macro can be used in KEYWORD checks:
- *
- *word  KEYWORD(110 || ES, 400, TOKEN)
- * ...means the word is reserved in GLSL ES 1.00, while
- *
- *word  KEYWORD(110, 130 || ES, TOKEN)
- * ...means the word is a legal keyword in GLSL ES 1.00.
- */
-#define ES yyextra-es_shader
-
 static int
 literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
YYSTYPE *lval, YYLTYPE *lloc, int base)
@@ -224,7 +228,7 @@ const   return CONST_TOK;
 bool   return BOOL_TOK;
 float  return FLOAT_TOK;
 intreturn INT_TOK;
-uint   KEYWORD(130, 130, UINT_TOK);
+uint   KEYWORD(130, 0, 130, 0, UINT_TOK);
 
 break  return BREAK;
 continue   return CONTINUE;
@@ -242,59 +246,59 @@ bvec4 return BVEC4;
 ivec2  return IVEC2;
 ivec3  return IVEC3;
 ivec4  return IVEC4;
-uvec2  KEYWORD(130, 130, UVEC2);
-uvec3  KEYWORD(130, 130, UVEC3);
-uvec4  KEYWORD(130, 130, UVEC4);
+uvec2  KEYWORD(130, 0, 130, 0, UVEC2);
+uvec3  KEYWORD(130, 0, 130, 0, UVEC3);

[Mesa-dev] [PATCH 09/26] glsl: parse GLSL ES 3.00 keywords correctly.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.

Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.

A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.

This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glsl_lexer.ll  | 189 
 src/glsl/glsl_parser.yy |   3 +
 2 files changed, 114 insertions(+), 78 deletions(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index ef1402b..e667e71 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -85,6 +85,21 @@ static int classify_identifier(struct _mesa_glsl_parse_state 
*, const char *);
   }
\
} while (0)
 
+/**
+ * A macro for handling keywords that have been present in GLSL since
+ * its origin, but were changed into reserved words in GLSL 3.00 ES.
+ */
+#define DEPRECATED_ES_KEYWORD(token)   \
+   do {
\
+  if (yyextra-is_version(0, 300)) {   \
+_mesa_glsl_error(yylloc, yyextra,  \
+ Illegal use of reserved word `%s', yytext); \
+return ERROR_TOK;  \
+  } else { \
+ return token; \
+  }
\
+   } while (0)
+
 static int
 literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
YYSTYPE *lval, YYLTYPE *lloc, int base)
@@ -223,12 +238,12 @@ HASH  ^{SPC}#{SPC}
 
 \n { yylineno++; yycolumn = 0; }
 
-attribute  return ATTRIBUTE;
+attribute  DEPRECATED_ES_KEYWORD(ATTRIBUTE);
 const  return CONST_TOK;
 bool   return BOOL_TOK;
 float  return FLOAT_TOK;
 intreturn INT_TOK;
-uint   KEYWORD(130, 0, 130, 0, UINT_TOK);
+uint   KEYWORD(130, 300, 130, 300, UINT_TOK);
 
 break  return BREAK;
 continue   return CONTINUE;
@@ -246,59 +261,59 @@ bvec4 return BVEC4;
 ivec2  return IVEC2;
 ivec3  return IVEC3;
 ivec4  return IVEC4;
-uvec2  KEYWORD(130, 0, 130, 0, UVEC2);
-uvec3  KEYWORD(130, 0, 130, 0, UVEC3);
-uvec4  KEYWORD(130, 0, 130, 0, UVEC4);
+uvec2  KEYWORD(130, 300, 130, 300, UVEC2);
+uvec3  KEYWORD(130, 300, 130, 300, UVEC3);
+uvec4  KEYWORD(130, 300, 130, 300, UVEC4);
 vec2   return VEC2;
 vec3   return VEC3;
 vec4   return VEC4;
 mat2   return MAT2X2;
 mat3   return MAT3X3;
 mat4   return MAT4X4;
-mat2x2 KEYWORD(120, 0, 120, 0, MAT2X2);
-mat2x3 KEYWORD(120, 0, 120, 0, MAT2X3);
-mat2x4 KEYWORD(120, 0, 120, 0, MAT2X4);
-mat3x2 KEYWORD(120, 0, 120, 0, MAT3X2);
-mat3x3 KEYWORD(120, 0, 120, 0, MAT3X3);
-mat3x4 KEYWORD(120, 0, 120, 0, MAT3X4);
-mat4x2 KEYWORD(120, 0, 120, 0, MAT4X2);
-mat4x3 KEYWORD(120, 0, 120, 0, MAT4X3);
-mat4x4 KEYWORD(120, 0, 120, 0, MAT4X4);
+mat2x2 KEYWORD(120, 300, 120, 300, MAT2X2);
+mat2x3 KEYWORD(120, 300, 120, 300, MAT2X3);
+mat2x4 KEYWORD(120, 300, 120, 300, MAT2X4);
+mat3x2 KEYWORD(120, 300, 120, 300, MAT3X2);
+mat3x3 KEYWORD(120, 300, 120, 300, MAT3X3);
+mat3x4 KEYWORD(120, 300, 120, 300, MAT3X4);
+mat4x2 KEYWORD(120, 300, 120, 300, MAT4X2);
+mat4x3 KEYWORD(120, 300, 120, 300, MAT4X3);
+mat4x4 KEYWORD(120, 300, 120, 300, MAT4X4);
 
 in return IN_TOK;
 outreturn OUT_TOK;
 inout  return INOUT_TOK;
 uniformreturn UNIFORM;
-varyingreturn VARYING;
-centroid   KEYWORD(120, 0, 120, 0, CENTROID);
+varyingDEPRECATED_ES_KEYWORD(VARYING);
+centroid   KEYWORD(120, 300, 120, 300, CENTROID);
 invariant  KEYWORD(120, 100, 120, 100, INVARIANT);
-flat   KEYWORD(130, 100, 130, 0, FLAT);
-smooth KEYWORD(130, 0, 130, 0, SMOOTH);
-noperspective  KEYWORD(130, 0, 130, 0, NOPERSPECTIVE);
+flat   KEYWORD(130, 100, 130, 300, FLAT);
+smooth KEYWORD(130, 300, 130, 300, SMOOTH);
+noperspective  KEYWORD(130, 300, 130, 0, 

[Mesa-dev] [PATCH 11/26] glsl/preprocessor: Extract version directive processing into a function.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Version directive handling is going to have to be used within two
parser rules, one for desktop-style version directives (e.g. #version
130) and one for the new ES-style version directive (e.g. #version
300 es), so this patch moves it to a function that can be called from
both rules.

No functional change.

[mattst88] v2: Use intmax_t instead of int for version argument. Would
otherwise write garbage after #version since PRIiMAX was reading 64-bits
instead of 32.

[idr] v3: A later commit fixes the caller of
_glcpp_parser_handle_version_declaration to pass the correct number of
parameters.  Fix it in the patch that changes the interface instead.
---
 src/glsl/glcpp/glcpp-parse.y | 49 +++-
 1 file changed, 30 insertions(+), 19 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index b0537c3..f021c73 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -133,6 +133,10 @@ _glcpp_parser_skip_stack_change_if (glcpp_parser_t 
*parser, YYLTYPE *loc,
 static void
 _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
 
+static void
+_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t 
version,
+ const char *ident);
+
 static int
 glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
 
@@ -334,25 +338,7 @@ control_line:
_glcpp_parser_skip_stack_pop (parser,  @1);
} NEWLINE
 |  HASH_VERSION integer_constant NEWLINE {
-   macro_t *macro = hash_table_find (parser-defines, 
__VERSION__);
-   if (macro) {
-   hash_table_remove (parser-defines, __VERSION__);
-   ralloc_free (macro);
-   }
-   add_builtin_define (parser, __VERSION__, $2);
-
-   if ($2 == 100)
-   add_builtin_define (parser, GL_ES, 1);
-
-   /* Currently, all ES2 implementations support highp in the
-* fragment shader, so we always define this macro in ES2.
-* If we ever get a driver that doesn't support highp, we'll
-* need to add a flag to the gl_context and check that here.
-*/
-   if ($2 = 130 || $2 == 100)
-   add_builtin_define (parser, 
GL_FRAGMENT_PRECISION_HIGH, 1);
-
-   ralloc_asprintf_rewrite_tail (parser-output, 
parser-output_length, #version % PRIiMAX, $2);
+   _glcpp_parser_handle_version_declaration(parser, $2, NULL);
}
 |  HASH NEWLINE
 ;
@@ -1971,3 +1957,28 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, 
YYLTYPE *loc)
parser-skip_stack = node-next;
ralloc_free (node);
 }
+
+static void
+_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t 
version,
+ const char *es_identifier)
+{
+   macro_t *macro = hash_table_find (parser-defines, __VERSION__);
+   if (macro) {
+   hash_table_remove (parser-defines, __VERSION__);
+   ralloc_free (macro);
+   }
+   add_builtin_define (parser, __VERSION__, version);
+
+   if (version == 100)
+   add_builtin_define (parser, GL_ES, 1);
+
+   /* Currently, all ES2 implementations support highp in the
+* fragment shader, so we always define this macro in ES2.
+* If we ever get a driver that doesn't support highp, we'll
+* need to add a flag to the gl_context and check that here.
+*/
+   if (version = 130 || version == 100)
+   add_builtin_define (parser, GL_FRAGMENT_PRECISION_HIGH, 1);
+
+   ralloc_asprintf_rewrite_tail (parser-output, parser-output_length, 
#version % PRIiMAX, version);
+}
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 10/26] glsl: Enable GLSL ES 3.00 features inherited from desktop GLSL.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

This patch turns on the following features for GLSL ES 3.00:

- Array constructors, whole array assignment, and array comparisons.
- Second and third operands of ?: may be arrays.
- Use of in and out qualifiers on globals.
- Bitwise and modulus operators.
- Integral vertex shader inputs.
- Range-checking of literal integers.
- array.length method.
- Function calls may be constant expressions.
- Integral varyings must be qualified with flat.
- Interpolation and centroid qualifiers may not be applied to vertex
  shader inputs.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/ast_function.cpp|  7 +++---
 src/glsl/ast_to_hir.cpp  | 51 +++-
 src/glsl/glsl_lexer.ll   |  2 +-
 src/glsl/glsl_parser_extras.h|  2 +-
 src/glsl/hir_field_selection.cpp |  2 +-
 5 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 8a5979f..b56a3c7 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -275,9 +275,10 @@ generate_call(exec_list *instructions, 
ir_function_signature *sig,
/* If the function call is a constant expression, don't generate any
 * instructions; just generate an ir_constant.
 *
-* Function calls were first allowed to be constant expressions in GLSL 
1.20.
+* Function calls were first allowed to be constant expressions in GLSL
+* 1.20 and GLSL ES 3.00.
 */
-   if (state-is_version(120, 0)) {
+   if (state-is_version(120, 300)) {
   ir_constant *value = sig-constant_expression_value(actual_parameters, 
NULL);
   if (value != NULL) {
 return value;
@@ -1243,7 +1244,7 @@ ast_function_expression::hir(exec_list *instructions,
   }
 
   if (constructor_type-is_array()) {
- if (!state-check_version(120, 0, loc,
+ if (!state-check_version(120, 300, loc,
array constructors forbidden)) {
return ir_rvalue::error_value(ctx);
 }
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 394a7ef..94b63f6 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -445,7 +445,7 @@ modulus_result_type(const struct glsl_type *type_a,
const struct glsl_type *type_b,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
 {
-   if (!state-check_version(130, 0, loc, operator '%%' is reserved)) {
+   if (!state-check_version(130, 300, loc, operator '%%' is reserved)) {
   return glsl_type::error_type;
}
 
@@ -690,13 +690,15 @@ do_assignment(exec_list *instructions, struct 
_mesa_glsl_parse_state *state,
  error_emitted = true;
 
   } else if (lhs-type-is_array() 
- !state-check_version(120, 0, lhs_loc,
+ !state-check_version(120, 300, lhs_loc,
whole array assignment forbidden)) {
 /* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
  *
  *Other binary or unary expressions, non-dereferenced
  * arrays, function names, swizzles with repeated fields,
  * and constants cannot be l-values.
+  *
+  * The restriction on arrays is lifted in GLSL 1.20 and GLSL ES 3.00.
  */
 error_emitted = true;
   } else if (!lhs-is_lvalue()) {
@@ -1149,7 +1151,7 @@ ast_expression::hir(exec_list *instructions,
  type, (this-oper == ast_equal) ? == : !=);
 error_emitted = true;
   } else if ((op[0]-type-is_array() || op[1]-type-is_array()) 
- !state-check_version(120, 0, loc,
+ !state-check_version(120, 300, loc,
array comparisons forbidden)) {
 error_emitted = true;
   }
@@ -1416,7 +1418,7 @@ ast_expression::hir(exec_list *instructions,
*be of any type other than an array.
*/
   if (type-is_array() 
-  !state-check_version(120, 0, loc,
+  !state-check_version(120, 300, loc,
 Second and third operands of ?: operator 
 cannot be arrays)) {
 error_emitted = true;
@@ -2602,10 +2604,10 @@ ast_declarator_list::hir(exec_list *instructions,
*
* Local variables can only use the qualifier const.
*
-   * This is relaxed in GLSL 1.30.  It is also relaxed by any extension
-   * that adds the 'layout' keyword.
+   * This is relaxed in GLSL 1.30 and GLSL ES 3.00.  It is also relaxed by
+   * any extension that adds the 'layout' keyword.
*/
-  if (!state-is_version(130, 0)
+  if (!state-is_version(130, 300)
   !state-ARB_explicit_attrib_location_enable
   !state-ARB_fragment_coord_conventions_enable) {
 if (this-type-qualifier.flags.q.out) {
@@ -2697,6 +2699,13 @@ 

[Mesa-dev] [PATCH 12/26] glsl/preprocessor: Handle #version 300 es directive.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glcpp/glcpp-parse.y | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index f021c73..f62cbe4 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -340,6 +340,9 @@ control_line:
 |  HASH_VERSION integer_constant NEWLINE {
_glcpp_parser_handle_version_declaration(parser, $2, NULL);
}
+|  HASH_VERSION integer_constant IDENTIFIER NEWLINE {
+   _glcpp_parser_handle_version_declaration(parser, $2, $3);
+   }
 |  HASH NEWLINE
 ;
 
@@ -1962,6 +1965,11 @@ static void
 _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t 
version,
  const char *es_identifier)
 {
+   /* Note: We assume that if any identifier is present, it means ES.
+ * The GLSL parser will double-check that the identifier is correct.
+*/
+   bool is_es = es_identifier != NULL;
+
macro_t *macro = hash_table_find (parser-defines, __VERSION__);
if (macro) {
hash_table_remove (parser-defines, __VERSION__);
@@ -1970,15 +1978,20 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
*parser, intmax_t versio
add_builtin_define (parser, __VERSION__, version);
 
if (version == 100)
+   is_es = true;
+   if (is_es)
add_builtin_define (parser, GL_ES, 1);
 
-   /* Currently, all ES2 implementations support highp in the
-* fragment shader, so we always define this macro in ES2.
+   /* Currently, all ES2/ES3 implementations support highp in the
+* fragment shader, so we always define this macro in ES2/ES3.
 * If we ever get a driver that doesn't support highp, we'll
 * need to add a flag to the gl_context and check that here.
 */
-   if (version = 130 || version == 100)
+   if (version = 130 || is_es)
add_builtin_define (parser, GL_FRAGMENT_PRECISION_HIGH, 1);
 
-   ralloc_asprintf_rewrite_tail (parser-output, parser-output_length, 
#version % PRIiMAX, version);
+   ralloc_asprintf_rewrite_tail (parser-output, parser-output_length,
+  #version % PRIiMAX %s%s, version,
+  es_identifier ?   : ,
+  es_identifier ? es_identifier : );
 }
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 13/26] glsl/parser: Extract version directive processing into a function.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Version directive handling is going to have to be used within two
parser rules, one for desktop-style version directives (e.g. #version
130) and one for the new ES-style version directive (e.g. #version
300 es), so this patch moves it to a function that can be called from
both rules.

No functional change.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glsl_parser.yy | 43 +-
 src/glsl/glsl_parser_extras.cpp | 52 +
 src/glsl/glsl_parser_extras.h   |  2 ++
 3 files changed, 55 insertions(+), 42 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 6cc1a51..b15e1d1 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -261,48 +261,7 @@ version_statement:
/* blank - no #version specified: defaults are already set */
| VERSION_TOK INTCONSTANT EOL
{
-  bool supported = false;
-
-  switch ($2) {
-  case 100:
- state-es_shader = true;
- supported = state-ctx-API == API_OPENGLES2 ||
- state-ctx-Extensions.ARB_ES2_compatibility;
- break;
-  case 110:
-  case 120:
- /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
-  * the OpenGL 3.2 Core context is supported, this logic will need
-  * change.  Older versions of GLSL are no longer supported
-  * outside the compatibility contexts of 3.x.
-  */
-  case 130:
-  case 140:
-  case 150:
-  case 330:
-  case 400:
-  case 410:
-  case 420:
- supported = _mesa_is_desktop_gl(state-ctx) 
- ((unsigned) $2) = state-ctx-Const.GLSLVersion;
- break;
-  default:
- supported = false;
- break;
-  }
-
-  state-language_version = $2;
-
-  if (!supported) {
- _mesa_glsl_error( @2, state, %s is not supported. 
-  Supported versions are: %s\n,
-  state-get_version_string(),
-  state-supported_version_string);
-  }
-
-  if (state-language_version = 140) {
- state-ARB_uniform_buffer_object_enable = true;
-  }
+   state-process_version_directive(@2, $2);
}
;
 
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 14589b0..cc33a07 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -174,6 +174,58 @@ _mesa_glsl_parse_state::check_version(unsigned 
required_glsl_version,
return false;
 }
 
+/**
+ * Process a GLSL #version directive.
+ *
+ * \param version is the integer that follows the #version token.
+ */
+void
+_mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version)
+{
+   bool supported = false;
+
+   switch (version) {
+   case 100:
+  this-es_shader = true;
+  supported = this-ctx-API == API_OPENGLES2 ||
+ this-ctx-Extensions.ARB_ES2_compatibility;
+  break;
+   case 110:
+   case 120:
+  /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
+   * the OpenGL 3.2 Core context is supported, this logic will need
+   * change.  Older versions of GLSL are no longer supported
+   * outside the compatibility contexts of 3.x.
+   */
+   case 130:
+   case 140:
+   case 150:
+   case 330:
+   case 400:
+   case 410:
+   case 420:
+  supported = _mesa_is_desktop_gl(this-ctx) 
+ ((unsigned) version) = this-ctx-Const.GLSLVersion;
+  break;
+   default:
+  supported = false;
+  break;
+   }
+
+   this-language_version = version;
+
+   if (!supported) {
+  _mesa_glsl_error(locp, this, %s is not supported. 
+   Supported versions are: %s\n,
+   this-get_version_string(),
+   this-supported_version_string);
+   }
+
+   if (this-language_version = 140) {
+  this-ARB_uniform_buffer_object_enable = true;
+   }
+}
+
 const char *
 _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target)
 {
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 20ed7b8..5ee7bc1 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -136,6 +136,8 @@ struct _mesa_glsl_parse_state {
   return check_version(130, 300, locp, bit-wise operations are 
forbidden);
}
 
+   void process_version_directive(YYLTYPE *locp, int version);
+
struct gl_context *const ctx;
void *scanner;
exec_list translation_unit;
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 15/26] glsl: Record in gl_shader whether the shader uses GLSL ES.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Previously we recorded just the GLSL version, with the knowledge that
100 means GLSL 1.00 ES.  With the advent of GLSL 3.00 ES, this is
going to get more complex, and eventually will probably become
ambiguous (GLSL 4.00 already exists, and GLSL 4.00 ES is likely to be
created some day).

To reduce confusion, this patch simply records whether the shader is
GLSL ES as an explicit boolean.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/main.cpp  | 1 +
 src/mesa/main/mtypes.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index 04143ad..77b8eca 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -190,6 +190,7 @@ compile_shader(struct gl_context *ctx, struct gl_shader 
*shader)
shader-symbols = state-symbols;
shader-CompileStatus = !state-error;
shader-Version = state-language_version;
+   shader-IsEsShader = state-es_shader;
memcpy(shader-builtins_to_link, state-builtins_to_link,
  sizeof(shader-builtins_to_link[0]) * state-num_builtins_to_link);
shader-num_builtins_to_link = state-num_builtins_to_link;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 69518b7..f364ae1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2184,6 +2184,7 @@ struct gl_shader
struct gl_sl_pragmas Pragmas;
 
unsigned Version;   /** GLSL version used for linking */
+   GLboolean IsEsShader; /** True if this shader uses GLSL ES */
 
/**
 * \name Sampler tracking
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 14/26] glsl/parser: Handle #version 300 es directive.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Note that GLSL 1.00 is selected using #version 100, so #version 100
es is prohibited.

v2: Check for GLES3 before allowing '#version 300 es'

Signed-off-by: Paul Berry stereotype...@gmail.com
Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glsl_parser.yy |  6 ++-
 src/glsl/glsl_parser_extras.cpp | 86 -
 src/glsl/glsl_parser_extras.h   |  3 +-
 3 files changed, 67 insertions(+), 28 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index b15e1d1..d938765 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -261,8 +261,12 @@ version_statement:
/* blank - no #version specified: defaults are already set */
| VERSION_TOK INTCONSTANT EOL
{
-   state-process_version_directive(@2, $2);
+   state-process_version_directive(@2, $2, NULL);
}
+| VERSION_TOK INTCONSTANT any_identifier EOL
+{
+   state-process_version_directive(@2, $2, $3);
+}
;
 
 pragma_statement:
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index cc33a07..2d356cf 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -178,38 +178,72 @@ _mesa_glsl_parse_state::check_version(unsigned 
required_glsl_version,
  * Process a GLSL #version directive.
  *
  * \param version is the integer that follows the #version token.
+ *
+ * \param ident is a string identifier that follows the integer, if any is
+ * present.  Otherwise NULL.
  */
 void
-_mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version)
+_mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
+  const char *ident)
 {
+   bool es_token_present = false;
+   if (ident) {
+  if (strcmp(ident, es) == 0) {
+ es_token_present = true;
+  } else {
+ _mesa_glsl_error(locp, this,
+  Illegal text following version number\n);
+  }
+   }
+
bool supported = false;
 
-   switch (version) {
-   case 100:
+   if (es_token_present) {
   this-es_shader = true;
-  supported = this-ctx-API == API_OPENGLES2 ||
- this-ctx-Extensions.ARB_ES2_compatibility;
-  break;
-   case 110:
-   case 120:
-  /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
-   * the OpenGL 3.2 Core context is supported, this logic will need
-   * change.  Older versions of GLSL are no longer supported
-   * outside the compatibility contexts of 3.x.
-   */
-   case 130:
-   case 140:
-   case 150:
-   case 330:
-   case 400:
-   case 410:
-   case 420:
-  supported = _mesa_is_desktop_gl(this-ctx) 
- ((unsigned) version) = this-ctx-Const.GLSLVersion;
-  break;
-   default:
-  supported = false;
-  break;
+  switch (version) {
+  case 100:
+ _mesa_glsl_error(locp, this,
+  GLSL 1.00 ES should be selected using 
+  `#version 100'\n);
+ supported = this-ctx-API == API_OPENGLES2 ||
+this-ctx-Extensions.ARB_ES2_compatibility;
+ break;
+  case 300:
+ supported = _mesa_is_gles3(this-ctx) ||
+   this-ctx-Extensions.ARB_ES3_compatibility;
+ break;
+  default:
+ supported = false;
+ break;
+  }
+   } else {
+  switch (version) {
+  case 100:
+ this-es_shader = true;
+ supported = this-ctx-API == API_OPENGLES2 ||
+this-ctx-Extensions.ARB_ES2_compatibility;
+ break;
+  case 110:
+  case 120:
+ /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
+  * the OpenGL 3.2 Core context is supported, this logic will need
+  * change.  Older versions of GLSL are no longer supported
+  * outside the compatibility contexts of 3.x.
+  */
+  case 130:
+  case 140:
+  case 150:
+  case 330:
+  case 400:
+  case 410:
+  case 420:
+ supported = _mesa_is_desktop_gl(this-ctx) 
+((unsigned) version) = this-ctx-Const.GLSLVersion;
+ break;
+  default:
+ supported = false;
+ break;
+  }
}
 
this-language_version = version;
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 5ee7bc1..210f262 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -136,7 +136,8 @@ struct _mesa_glsl_parse_state {
   return check_version(130, 300, locp, bit-wise operations are 
forbidden);
}
 
-   void process_version_directive(YYLTYPE *locp, int version);
+   void process_version_directive(YYLTYPE *locp, int version,
+  const char *ident);
 
struct gl_context *const ctx;
void *scanner;
-- 
1.7.11.7

___

[Mesa-dev] [PATCH 16/26] glsl: Clean up shading language mixing check for GLSL 3.00 ES.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Previously, we prohibited mixing of shading language versions if
min_version == 100 or max_version = 130.  This was technically
correct (since desktop GLSL 1.30 and beyond prohibit mixing of shading
language versions, as does GLSL 1.00 ES), but it was confusing.  Also,
we asserted that all shading language versions were between 1.00 and
1.40, which was unnecessary (since the parser already checks shading
language versions) and doesn't work for GLSL 3.00 ES.

This patch changes the code to explicitly check that (a) ES shaders
aren't mixed with desktop shaders, (b) shaders aren't mixed between ES
versions, and (c) shaders aren't mixed between desktop GLSL versions
when at least one shader is GLSL 1.30 or greater.  Also, it removes
the unnecessary assertion.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/linker.cpp | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 3b2ab96..1bae043 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2421,9 +2421,19 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
 
unsigned min_version = UINT_MAX;
unsigned max_version = 0;
+   bool is_es_prog = false;
for (unsigned i = 0; i  prog-NumShaders; i++) {
   min_version = MIN2(min_version, prog-Shaders[i]-Version);
   max_version = MAX2(max_version, prog-Shaders[i]-Version);
+  if (i == 0) {
+ is_es_prog = prog-Shaders[i]-IsEsShader;
+  } else {
+ if (prog-Shaders[i]-IsEsShader != is_es_prog) {
+linker_error(prog, all shaders must use same shading 
+ language version\n);
+goto done;
+ }
+  }
 
   switch (prog-Shaders[i]-Type) {
   case GL_VERTEX_SHADER:
@@ -2444,10 +2454,10 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
/* Previous to GLSL version 1.30, different compilation units could mix and
 * match shading language versions.  With GLSL 1.30 and later, the versions
 * of all shaders must match.
+*
+* GLSL ES has never allowed mixing of shading language versions.
 */
-   assert(min_version = 100);
-   assert(max_version = 140);
-   if ((max_version = 130 || min_version == 100)
+   if ((is_es_prog || max_version = 130)
 min_version != max_version) {
   linker_error(prog, all shaders must use same shading 
   language version\n);
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 17/26] glsl: Record in gl_shader_program whether the program uses GLSL ES.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Previously we recorded just the GLSL version (or the max version, if
GLSL 1.10 and GLSL 1.20 programs were linked together).

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/linker.cpp| 1 +
 src/mesa/main/mtypes.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 1bae043..d74911f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2465,6 +2465,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 
prog-Version = max_version;
+   prog-IsEsProg = is_es_prog;
 
for (unsigned int i = 0; i  MESA_SHADER_TYPES; i++) {
   if (prog-_LinkedShaders[i] != NULL)
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f364ae1..4e5be1f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2387,6 +2387,7 @@ struct gl_shader_program
GLchar *InfoLog;
 
unsigned Version;   /** GLSL version used for linking */
+   GLboolean IsEsProg; /** True if this program uses GLSL ES */
 
/**
 * Per-stage shaders resulting from the first stage of linking.
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 05/26] glsl: Add GLSL version query functions.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

With the advent of GLSL 3.00 ES, the version checks we perform in the
GLSL compiler (to determine which language features are present) will
become more complicated.  To reduce the complexity, this patch adds
functions check_version() and is_version() to _mesa_glsl_parse_state.
These functions take two version numbers: a desktop GLSL version and a
GLSL ES version, and return a boolean indicating whether the GLSL
version being compiled is at least the required version.  So, for
example, is_version(130, 300) returns true if the GLSL version being
compiled is at least desktop GLSL 1.30 or GLSL 3.00.

The check_version() function additionally produces an error message if
the version check fails, informing the user of which GLSL version(s)
support the given feature.

[v2, idr]: Add PRINTFLIKE annotation to the new method.  The numbering of th
parameters is correct because GCC is silly.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glsl_parser_extras.cpp | 51 +
 src/glsl/glsl_parser_extras.h   | 45 
 2 files changed, 86 insertions(+), 10 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 3e19203..14589b0 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -123,6 +123,57 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this-default_uniform_qualifier-flags.q.column_major = 1;
 }
 
+/**
+ * Determine whether the current GLSL version is sufficiently high to support
+ * a certain feature, and generate an error message if it isn't.
+ *
+ * \param required_glsl_version and \c required_glsl_es_version are
+ * interpreted as they are in _mesa_glsl_parse_state::is_version().
+ *
+ * \param locp is the parser location where the error should be reported.
+ *
+ * \param fmt (and additional arguments) constitute a printf-style error
+ * message to report if the version check fails.  Information about the
+ * current and required GLSL versions will be appended.  So, for example, if
+ * the GLSL version being compiled is 1.20, and check_version(130, 300, locp,
+ * foo unsupported) is called, the error message will be foo unsupported in
+ * GLSL 1.20 (GLSL 1.30 or GLSL 3.00 ES required).
+ */
+bool
+_mesa_glsl_parse_state::check_version(unsigned required_glsl_version,
+  unsigned required_glsl_es_version,
+  YYLTYPE *locp, const char *fmt, ...)
+{
+   if (this-is_version(required_glsl_version, required_glsl_es_version))
+  return true;
+
+   va_list args;
+   va_start(args, fmt);
+   char *problem = ralloc_vasprintf(ctx, fmt, args);
+   va_end(args);
+   const char *glsl_version_string
+  = glsl_compute_version_string(ctx, false, required_glsl_version);
+   const char *glsl_es_version_string
+  = glsl_compute_version_string(ctx, true, required_glsl_es_version);
+   const char *requirement_string = ;
+   if (required_glsl_version  required_glsl_es_version) {
+  requirement_string = ralloc_asprintf(ctx,  (%s or %s required),
+   glsl_version_string,
+   glsl_es_version_string);
+   } else if (required_glsl_version) {
+  requirement_string = ralloc_asprintf(ctx,  (%s required),
+   glsl_version_string);
+   } else if (required_glsl_es_version) {
+  requirement_string = ralloc_asprintf(ctx,  (%s required),
+   glsl_es_version_string);
+   }
+   _mesa_glsl_error(locp, this, %s in %s%s.,
+problem, this-get_version_string(),
+requirement_string);
+
+   return false;
+}
+
 const char *
 _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target)
 {
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 26fdee1..d4ab587 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -59,6 +59,16 @@ struct glsl_switch_state {
 const char *
 glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version);
 
+typedef struct YYLTYPE {
+   int first_line;
+   int first_column;
+   int last_line;
+   int last_column;
+   unsigned source;
+} YYLTYPE;
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+
 struct _mesa_glsl_parse_state {
_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
  void *mem_ctx);
@@ -90,6 +100,31 @@ struct _mesa_glsl_parse_state {
  this-language_version);
}
 
+   /**
+* Determine whether the current GLSL version is sufficiently high to
+* support a certain feature.
+*
+* \param required_glsl_version is the desktop GLSL version that is
+* required to support the feature, or 0 if no version of desktop GLSL
+   

[Mesa-dev] [PATCH 18/26] glsl: Fix linker checks for GLSL ES 3.00.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

This patch updates the following linker checks to do the right thing
in GLSL 3.00 ES:

- Failing to write to gl_Position is allowed in GLSL 1.40+ as well as
  GLSL 3.00 ES.

- It is an error to write to both gl_ClipVertex and gl_ClipDistance in
  GLSL 1.30+.  This does not apply to GLSL 3.00 ES.

- GLSL 3.00 ES uses the same varying counting rules as GLSL 1.00 ES.

- In GLSL 1.30 and GLSL 3.00 ES, discard terminates the shader.

- In GLSL 1.00 ES and GLSL 3.00 ES, both a fragment and a vertex
  shader must be present.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/linker.cpp | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index d74911f..e2cd625 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -289,8 +289,11 @@ validate_vertex_shader_executable(struct gl_shader_program 
*prog,
 *  operations, if present, that operate on primitives after
 *  vertex processing has occurred. Its value is undefined if
 *  the vertex shader executable does not write gl_Position.
+*
+* GLSL ES 3.00 is similar to GLSL 1.40--failing to write to gl_Position is
+* not an error.
 */
-   if (prog-Version  140) {
+   if (prog-Version  (prog-IsEsProg ? 300 : 140)) {
   find_assignment_visitor find(gl_Position);
   find.run(shader-ir);
   if (!find.variable_found()) {
@@ -301,12 +304,15 @@ validate_vertex_shader_executable(struct 
gl_shader_program *prog,
 
prog-Vert.ClipDistanceArraySize = 0;
 
-   if (prog-Version = 130) {
+   if (!prog-IsEsProg  prog-Version = 130) {
   /* From section 7.1 (Vertex Shader Special Variables) of the
* GLSL 1.30 spec:
*
*   It is an error for a shader to statically write both
*   gl_ClipVertex and gl_ClipDistance.
+   *
+   * This does not apply to GLSL ES shaders, since GLSL ES defines neither
+   * gl_ClipVertex not gl_ClipDistance.
*/
   find_assignment_visitor clip_vertex(gl_ClipVertex);
   find_assignment_visitor clip_distance(gl_ClipDistance);
@@ -2144,7 +2150,7 @@ assign_varying_locations(struct gl_context *ctx,
   }
}
 
-   if (ctx-API == API_OPENGLES2 || prog-Version == 100) {
+   if (ctx-API == API_OPENGLES2 || prog-IsEsProg) {
   if (varying_vectors  ctx-Const.MaxVarying) {
  if (ctx-Const.GLSLSkipStrictMaxVaryingLimitCheck) {
 linker_warning(prog, shader uses too many varying vectors 
@@ -2539,8 +2545,10 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
/* Implement the GLSL 1.30+ rule for discard vs infinite loops Do
 * it before optimization because we want most of the checks to get
 * dropped thanks to constant propagation.
+*
+* This rule also applies to GLSL ES 3.00.
 */
-   if (max_version = 130) {
+   if (max_version = (is_es_prog ? 300 : 130)) {
   struct gl_shader *sh = prog-_LinkedShaders[MESA_SHADER_FRAGMENT];
   if (sh) {
 lower_discard_flow(sh-ir);
@@ -2684,11 +2692,11 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
   goto done;
 
/* OpenGL ES requires that a vertex shader and a fragment shader both be
-* present in a linked program.  By checking for use of shading language
-* version 1.00, we also catch the GL_ARB_ES2_compatibility case.
+* present in a linked program.  By checking prog-IsEsProg, we also
+* catch the GL_ARB_ES2_compatibility case.
 */
if (!prog-InternalSeparateShader 
-   (ctx-API == API_OPENGLES2 || prog-Version == 100)) {
+   (ctx-API == API_OPENGLES2 || prog-IsEsProg)) {
   if (prog-_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
 linker_error(prog, program lacks a vertex shader\n);
   } else if (prog-_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) {
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 19/26] glsl: Make {Min, Max}ProgramTexelOffset available to compiler.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

These constants need to be made available to shaders in GLSL 3.00 ES.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/glsl_parser_extras.cpp | 2 ++
 src/glsl/glsl_parser_extras.h   | 4 
 2 files changed, 6 insertions(+)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 2d356cf..80f15a6 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -92,6 +92,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this-Const.MaxCombinedTextureImageUnits = 
ctx-Const.MaxCombinedTextureImageUnits;
this-Const.MaxTextureImageUnits = ctx-Const.MaxTextureImageUnits;
this-Const.MaxFragmentUniformComponents = 
ctx-Const.FragmentProgram.MaxUniformComponents;
+   this-Const.MinProgramTexelOffset = ctx-Const.MinProgramTexelOffset;
+   this-Const.MaxProgramTexelOffset = ctx-Const.MaxProgramTexelOffset;
 
this-Const.MaxDrawBuffers = ctx-Const.MaxDrawBuffers;
 
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 210f262..1246dd2 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -190,6 +190,10 @@ struct _mesa_glsl_parse_state {
 
   /* ARB_draw_buffers */
   unsigned MaxDrawBuffers;
+
+  /* 3.00 ES */
+  int MinProgramTexelOffset;
+  int MaxProgramTexelOffset;
} Const;
 
/**
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 21/26] glsl: Add builtin variables for GLSL 3.00 ES.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

This patch also adds assertions so that when we add new GLSL versions,
we'll notice that we need to update the builtin variables.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/builtin_variables.cpp | 193 -
 1 file changed, 151 insertions(+), 42 deletions(-)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 353805b..d10613d 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -61,6 +61,17 @@ static const builtin_variable builtin_100ES_fs_variables[] = 
{
{ ir_var_in,  FRAG_ATTRIB_PNTC,   vec2,   gl_PointCoord },
 };
 
+static const builtin_variable builtin_300ES_vs_variables[] = {
+   { ir_var_system_value,  SYSTEM_VALUE_VERTEX_ID, int,   gl_VertexID },
+};
+
+static const builtin_variable builtin_300ES_fs_variables[] = {
+   { ir_var_in,  FRAG_ATTRIB_WPOS,  vec4,  gl_FragCoord },
+   { ir_var_in,  FRAG_ATTRIB_FACE,  bool,  gl_FrontFacing },
+   { ir_var_out, FRAG_RESULT_DEPTH, float, gl_FragDepth },
+   { ir_var_in,  FRAG_ATTRIB_PNTC,   vec2,   gl_PointCoord },
+};
+
 static const builtin_variable builtin_110_fs_variables[] = {
{ ir_var_out, FRAG_RESULT_DEPTH, float, gl_FragDepth },
 };
@@ -499,12 +510,15 @@ add_builtin_constant(exec_list *instructions, 
glsl_symbol_table *symtab,
return var;
 }
 
-/* Several constants in GLSL ES have different names than normal desktop GLSL.
+/**
+ * Uniforms that are common to all GLSL ES implementations.
+ *
+ * Several constants in GLSL ES have different names than normal desktop GLSL.
  * Therefore, this function should only be called on the ES path.
  */
 static void
-generate_100ES_uniforms(exec_list *instructions,
-struct _mesa_glsl_parse_state *state)
+generate_common_ES_uniforms(exec_list *instructions,
+struct _mesa_glsl_parse_state *state)
 {
glsl_symbol_table *const symtab = state-symbols;
 
@@ -512,8 +526,6 @@ generate_100ES_uniforms(exec_list *instructions,
state-Const.MaxVertexAttribs);
add_builtin_constant(instructions, symtab, gl_MaxVertexUniformVectors,
state-Const.MaxVertexUniformComponents);
-   add_builtin_constant(instructions, symtab, gl_MaxVaryingVectors,
-   state-Const.MaxVaryingFloats / 4);
add_builtin_constant(instructions, symtab, gl_MaxVertexTextureImageUnits,
state-Const.MaxVertexTextureImageUnits);
add_builtin_constant(instructions, symtab, 
gl_MaxCombinedTextureImageUnits,
@@ -528,6 +540,36 @@ generate_100ES_uniforms(exec_list *instructions,
 }
 
 static void
+generate_100ES_uniforms(exec_list *instructions,
+struct _mesa_glsl_parse_state *state)
+{
+   generate_common_ES_uniforms(instructions, state);
+
+   glsl_symbol_table *const symtab = state-symbols;
+
+   add_builtin_constant(instructions, symtab, gl_MaxVaryingVectors,
+   state-Const.MaxVaryingFloats / 4);
+}
+
+static void
+generate_300ES_uniforms(exec_list *instructions,
+struct _mesa_glsl_parse_state *state)
+{
+   generate_common_ES_uniforms(instructions, state);
+
+   glsl_symbol_table *const symtab = state-symbols;
+
+   add_builtin_constant(instructions, symtab, gl_MaxVertexOutputVectors,
+   state-Const.MaxVaryingFloats / 4);
+   add_builtin_constant(instructions, symtab, gl_MaxFrabmentInputVectors,
+   state-Const.MaxVaryingFloats / 4);
+   add_builtin_constant(instructions, symtab, gl_MinProgramTexelOffset,
+state-Const.MinProgramTexelOffset);
+   add_builtin_constant(instructions, symtab, gl_MaxProgramTexelOffset,
+state-Const.MaxProgramTexelOffset);
+}
+
+static void
 generate_110_uniforms(exec_list *instructions,
  struct _mesa_glsl_parse_state *state,
  bool add_deprecated)
@@ -657,6 +699,26 @@ generate_100ES_vs_variables(exec_list *instructions,
   vertex_shader);
 }
 
+static void
+generate_300ES_vs_variables(exec_list *instructions,
+struct _mesa_glsl_parse_state *state)
+{
+   for (unsigned i = 0; i  Elements(builtin_core_vs_variables); i++) {
+  add_builtin_variable(instructions, state-symbols,
+   builtin_core_vs_variables[i]);
+   }
+
+   for (unsigned i = 0; i  Elements(builtin_300ES_vs_variables); i++) {
+  add_builtin_variable(instructions, state-symbols,
+   builtin_300ES_vs_variables[i]);
+   }
+
+   generate_300ES_uniforms(instructions, state);
+
+   generate_ARB_draw_buffers_variables(instructions, state, false,
+  vertex_shader);
+}
+
 
 static void
 generate_110_vs_variables(exec_list *instructions,
@@ -760,23 +822,36 @@ static void
 initialize_vs_variables(exec_list *instructions,

[Mesa-dev] [PATCH 20/26] glsl: Populate built-in types correctly for GLSL 3.00 ES.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

This patch implements all of the built-in types for GLSL 3.00 ES.
This is almost exactly the same as the set of built-in types for GLSL
1.30, except ate 1D samplers are skipped, and samplerCubeShadow is
added.

This patch also addes an assertion so that when we add new GLSL
versions, we'll notice that we need to update the types.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/builtin_types.h |   5 ++
 src/glsl/glsl_types.cpp  | 132 ---
 src/glsl/glsl_types.h|  11 ++--
 3 files changed, 103 insertions(+), 45 deletions(-)

diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h
index 92427d8..a4c995f 100644
--- a/src/glsl/builtin_types.h
+++ b/src/glsl/builtin_types.h
@@ -31,6 +31,11 @@ const glsl_type glsl_type::_sampler3D_type =
glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT,
 sampler3D);
 
+const glsl_type glsl_type::_samplerCubeShadow_type =
+   glsl_type(GL_SAMPLER_CUBE_SHADOW,
+GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT,
+ samplerCubeShadow);
+
 const glsl_type *const glsl_type::error_type =  glsl_type::_error_type;
 const glsl_type *const glsl_type::void_type =  glsl_type::_void_type;
 
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 9edb712..71b1850 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -102,11 +102,16 @@ glsl_type::glsl_type(const glsl_struct_field *fields, 
unsigned num_fields,
 static void
 add_types_to_symbol_table(glsl_symbol_table *symtab,
  const struct glsl_type *types,
- unsigned num_types, bool warn)
+ unsigned num_types, bool warn,
+  bool skip_1d)
 {
(void) warn;
 
for (unsigned i = 0; i  num_types; i++) {
+  if (skip_1d  types[i].base_type == GLSL_TYPE_SAMPLER
+   types[i].sampler_dimensionality == GLSL_SAMPLER_DIM_1D)
+ continue;
+
   symtab-add_type(types[i].name,  types[i]);
}
 }
@@ -158,49 +163,68 @@ glsl_type::sampler_index() const
 void
 glsl_type::generate_100ES_types(glsl_symbol_table *symtab)
 {
+   bool skip_1d = false;
add_types_to_symbol_table(symtab, builtin_core_types,
 Elements(builtin_core_types),
-false);
+false, skip_1d);
add_types_to_symbol_table(symtab, builtin_structure_types,
 Elements(builtin_structure_types),
-false);
-   add_types_to_symbol_table(symtab, void_type, 1, false);
+false, skip_1d);
+   add_types_to_symbol_table(symtab, void_type, 1, false, skip_1d);
+}
+
+void
+glsl_type::generate_300ES_types(glsl_symbol_table *symtab)
+{
+   /* GLSL 3.00 ES types are the same as GLSL 1.30 types, except that 1D
+* samplers are skipped, and samplerCubeShadow is added.
+*/
+   bool add_deprecated = false;
+   bool skip_1d = true;
+
+   generate_130_types(symtab, add_deprecated, skip_1d);
+
+   add_types_to_symbol_table(symtab, _samplerCubeShadow_type, 1, false,
+ skip_1d);
 }
 
 void
-glsl_type::generate_110_types(glsl_symbol_table *symtab, bool add_deprecated)
+glsl_type::generate_110_types(glsl_symbol_table *symtab, bool add_deprecated,
+  bool skip_1d)
 {
generate_100ES_types(symtab);
 
add_types_to_symbol_table(symtab, builtin_110_types,
 Elements(builtin_110_types),
-false);
-   add_types_to_symbol_table(symtab, _sampler3D_type, 1, false);
+false, skip_1d);
+   add_types_to_symbol_table(symtab, _sampler3D_type, 1, false, skip_1d);
if (add_deprecated) {
   add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types,

Elements(builtin_110_deprecated_structure_types),
-   false);
+   false, skip_1d);
}
 }
 
 
 void
-glsl_type::generate_120_types(glsl_symbol_table *symtab, bool add_deprecated)
+glsl_type::generate_120_types(glsl_symbol_table *symtab, bool add_deprecated,
+  bool skip_1d)
 {
-   generate_110_types(symtab, add_deprecated);
+   generate_110_types(symtab, add_deprecated, skip_1d);
 
add_types_to_symbol_table(symtab, builtin_120_types,
-Elements(builtin_120_types), false);
+Elements(builtin_120_types), false, skip_1d);
 }
 
 
 void
-glsl_type::generate_130_types(glsl_symbol_table *symtab, bool add_deprecated)
+glsl_type::generate_130_types(glsl_symbol_table *symtab, bool add_deprecated,
+  bool skip_1d)
 {
-   generate_120_types(symtab, add_deprecated);
+   generate_120_types(symtab, add_deprecated, skip_1d);
 

[Mesa-dev] [PATCH 22/26] glsl: Make builtin function profiles for GLSL ES use es in the filename.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/builtins/profiles/100.frag  |   6 -
 src/glsl/builtins/profiles/100.glsl  | 296 ---
 src/glsl/builtins/profiles/100.vert  |   6 -
 src/glsl/builtins/profiles/100es.frag|   6 +
 src/glsl/builtins/profiles/100es.glsl| 296 +++
 src/glsl/builtins/profiles/100es.vert|   6 +
 src/glsl/builtins/tools/generate_builtins.py |   6 +-
 7 files changed, 313 insertions(+), 309 deletions(-)
 delete mode 100644 src/glsl/builtins/profiles/100.frag
 delete mode 100644 src/glsl/builtins/profiles/100.glsl
 delete mode 100644 src/glsl/builtins/profiles/100.vert
 create mode 100644 src/glsl/builtins/profiles/100es.frag
 create mode 100644 src/glsl/builtins/profiles/100es.glsl
 create mode 100644 src/glsl/builtins/profiles/100es.vert

diff --git a/src/glsl/builtins/profiles/100.frag 
b/src/glsl/builtins/profiles/100.frag
deleted file mode 100644
index 904aa30..000
--- a/src/glsl/builtins/profiles/100.frag
+++ /dev/null
@@ -1,6 +0,0 @@
-#version 100
-vec4 texture2D   (sampler2D sampler, vec2 coord, float bias);
-vec4 texture2DProj   (sampler2D sampler, vec3 coord, float bias);
-vec4 texture2DProj   (sampler2D sampler, vec4 coord, float bias);
-
-vec4 textureCube (samplerCube sampler, vec3 coord, float bias);
diff --git a/src/glsl/builtins/profiles/100.glsl 
b/src/glsl/builtins/profiles/100.glsl
deleted file mode 100644
index 0d60a7f..000
--- a/src/glsl/builtins/profiles/100.glsl
+++ /dev/null
@@ -1,296 +0,0 @@
-#version 100
-/*
- * 8.1 - Angle and Trigonometry Functions
- */
-float radians(float degrees);
-vec2  radians(vec2  degrees);
-vec3  radians(vec3  degrees);
-vec4  radians(vec4  degrees);
-
-float degrees(float radians);
-vec2  degrees(vec2  radians);
-vec3  degrees(vec3  radians);
-vec4  degrees(vec4  radians);
-
-float sin(float angle);
-vec2  sin(vec2  angle);
-vec3  sin(vec3  angle);
-vec4  sin(vec4  angle);
-
-float cos(float angle);
-vec2  cos(vec2  angle);
-vec3  cos(vec3  angle);
-vec4  cos(vec4  angle);
-
-float tan(float angle);
-vec2  tan(vec2  angle);
-vec3  tan(vec3  angle);
-vec4  tan(vec4  angle);
-
-float asin(float angle);
-vec2  asin(vec2  angle);
-vec3  asin(vec3  angle);
-vec4  asin(vec4  angle);
-
-float acos(float angle);
-vec2  acos(vec2  angle);
-vec3  acos(vec3  angle);
-vec4  acos(vec4  angle);
-
-float atan(float y, float x);
-vec2  atan(vec2  y, vec2  x);
-vec3  atan(vec3  y, vec3  x);
-vec4  atan(vec4  y, vec4  x);
-
-float atan(float y_over_x);
-vec2  atan(vec2  y_over_x);
-vec3  atan(vec3  y_over_x);
-vec4  atan(vec4  y_over_x);
-
-/*
- * 8.2 - Exponential Functions
- */
-float pow(float x, float y);
-vec2  pow(vec2  x, vec2  y);
-vec3  pow(vec3  x, vec3  y);
-vec4  pow(vec4  x, vec4  y);
-
-float exp(float x);
-vec2  exp(vec2  x);
-vec3  exp(vec3  x);
-vec4  exp(vec4  x);
-
-float log(float x);
-vec2  log(vec2  x);
-vec3  log(vec3  x);
-vec4  log(vec4  x);
-
-float exp2(float x);
-vec2  exp2(vec2  x);
-vec3  exp2(vec3  x);
-vec4  exp2(vec4  x);
-
-float log2(float x);
-vec2  log2(vec2  x);
-vec3  log2(vec3  x);
-vec4  log2(vec4  x);
-
-float sqrt(float x);
-vec2  sqrt(vec2  x);
-vec3  sqrt(vec3  x);
-vec4  sqrt(vec4  x);
-
-float inversesqrt(float x);
-vec2  inversesqrt(vec2  x);
-vec3  inversesqrt(vec3  x);
-vec4  inversesqrt(vec4  x);
-
-/*
- * 8.3 - Common Functions
- */
-float abs(float x);
-vec2  abs(vec2  x);
-vec3  abs(vec3  x);
-vec4  abs(vec4  x);
-
-float sign(float x);
-vec2  sign(vec2  x);
-vec3  sign(vec3  x);
-vec4  sign(vec4  x);
-
-float floor(float x);
-vec2  floor(vec2  x);
-vec3  floor(vec3  x);
-vec4  floor(vec4  x);
-
-float ceil(float x);
-vec2  ceil(vec2  x);
-vec3  ceil(vec3  x);
-vec4  ceil(vec4  x);
-
-float fract(float x);
-vec2  fract(vec2  x);
-vec3  fract(vec3  x);
-vec4  fract(vec4  x);
-
-float mod(float x, float y);
-vec2  mod(vec2  x, float y);
-vec3  mod(vec3  x, float y);
-vec4  mod(vec4  x, float y);
-
-vec2  mod(vec2  x, vec2  y);
-vec3  mod(vec3  x, vec3  y);
-vec4  mod(vec4  x, vec4  y);
-
-float min(float x, float y);
-vec2  min(vec2  x, vec2  y);
-vec3  min(vec3  x, vec3  y);
-vec4  min(vec4  x, vec4  y);
-
-vec2  min(vec2  x, float y);
-vec3  min(vec3  x, float y);
-vec4  min(vec4  x, float y);
-
-float max(float x, float y);
-vec2  max(vec2  x, vec2  y);
-vec3  max(vec3  x, vec3  y);
-vec4  max(vec4  x, vec4  y);
-
-vec2  max(vec2  x, float y);
-vec3  max(vec3  x, float y);
-vec4  max(vec4  x, float y);
-
-float clamp(float x, float minVal, float maxVal);
-vec2  clamp(vec2  x, vec2  minVal, vec2  maxVal);
-vec3  clamp(vec3  x, vec3  minVal, vec3  maxVal);
-vec4  clamp(vec4  x, vec4  minVal, vec4  maxVal);
-
-vec2  clamp(vec2  x, float minVal, float maxVal);
-vec3  clamp(vec3  x, float minVal, float maxVal);
-vec4  clamp(vec4  x, float minVal, float maxVal);
-
-float mix(float x, float y, float a);
-vec2  mix(vec2  x, vec2  y, vec2  

[Mesa-dev] [PATCH 24/26] glsl: Create builtin function profiles for GLSL 3.00 ES.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Nearly all of the builtin functions in GLSL 3.00 ES are already
implemented in Mesa; this patch enables them.

A few functions are not implemented yet; those have been commented
out, with a FIXME comment to act as a reminder of what still needs to
be implemented.  Here is the complete list: packSnorm2x16,
unpackSnorm2x16, packUnorm2x16, unpackUnorm2x16, packHalf2x16,
unpackHalf2x16.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/builtins/profiles/300es.frag |  84 
 src/glsl/builtins/profiles/300es.glsl | 749 ++
 src/glsl/main.cpp |   1 +
 3 files changed, 834 insertions(+)
 create mode 100644 src/glsl/builtins/profiles/300es.frag
 create mode 100644 src/glsl/builtins/profiles/300es.glsl

diff --git a/src/glsl/builtins/profiles/300es.frag 
b/src/glsl/builtins/profiles/300es.frag
new file mode 100644
index 000..38589f7
--- /dev/null
+++ b/src/glsl/builtins/profiles/300es.frag
@@ -0,0 +1,84 @@
+#version 300 es
+
+/* texture - bias variants */
+ vec4 texture( sampler2D sampler, vec2 P, float bias);
+ivec4 texture(isampler2D sampler, vec2 P, float bias);
+uvec4 texture(usampler2D sampler, vec2 P, float bias);
+
+ vec4 texture( sampler3D sampler, vec3 P, float bias);
+ivec4 texture(isampler3D sampler, vec3 P, float bias);
+uvec4 texture(usampler3D sampler, vec3 P, float bias);
+
+ vec4 texture( samplerCube sampler, vec3 P, float bias);
+ivec4 texture(isamplerCube sampler, vec3 P, float bias);
+uvec4 texture(usamplerCube sampler, vec3 P, float bias);
+
+float texture(sampler2DShadow   sampler, vec3 P, float bias);
+float texture(samplerCubeShadow sampler, vec4 P, float bias);
+
+ vec4 texture( sampler2DArray sampler, vec3 P, float bias);
+ivec4 texture(isampler2DArray sampler, vec3 P, float bias);
+uvec4 texture(usampler2DArray sampler, vec3 P, float bias);
+
+float texture(sampler2DArrayShadow sampler, vec4 P, float bias);
+
+/* textureProj - bias variants */
+ vec4 textureProj( sampler2D sampler, vec3 P, float bias);
+ivec4 textureProj(isampler2D sampler, vec3 P, float bias);
+uvec4 textureProj(usampler2D sampler, vec3 P, float bias);
+ vec4 textureProj( sampler2D sampler, vec4 P, float bias);
+ivec4 textureProj(isampler2D sampler, vec4 P, float bias);
+uvec4 textureProj(usampler2D sampler, vec4 P, float bias);
+
+ vec4 textureProj( sampler3D sampler, vec4 P, float bias);
+ivec4 textureProj(isampler3D sampler, vec4 P, float bias);
+uvec4 textureProj(usampler3D sampler, vec4 P, float bias);
+
+float textureProj(sampler2DShadow sampler, vec4 P, float bias);
+
+/* textureOffset - bias variants */
+ vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset, float bias);
+ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset, float bias);
+uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset, float bias);
+
+ vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset, float bias);
+ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset, float bias);
+uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset, float bias);
+
+float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias);
+
+ vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset, float bias);
+ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset, float bias);
+uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset, float bias);
+
+/* textureProjOffsetOffset - bias variants */
+ vec4 textureProjOffset( sampler2D sampler, vec3 P, ivec2 offset, float bias);
+ivec4 textureProjOffset(isampler2D sampler, vec3 P, ivec2 offset, float bias);
+uvec4 textureProjOffset(usampler2D sampler, vec3 P, ivec2 offset, float bias);
+ vec4 textureProjOffset( sampler2D sampler, vec4 P, ivec2 offset, float bias);
+ivec4 textureProjOffset(isampler2D sampler, vec4 P, ivec2 offset, float bias);
+uvec4 textureProjOffset(usampler2D sampler, vec4 P, ivec2 offset, float bias);
+
+ vec4 textureProjOffset( sampler3D sampler, vec4 P, ivec3 offset, float bias);
+ivec4 textureProjOffset(isampler3D sampler, vec4 P, ivec3 offset, float bias);
+uvec4 textureProjOffset(usampler3D sampler, vec4 P, ivec3 offset, float bias);
+
+float textureProjOffset(sampler2DShadow s, vec4 P, ivec2 offset, float bias);
+
+/*
+ * 8.9 - Fragment Processing Functions
+ */
+float dFdx(float p);
+vec2  dFdx(vec2  p);
+vec3  dFdx(vec3  p);
+vec4  dFdx(vec4  p);
+
+float dFdy(float p);
+vec2  dFdy(vec2  p);
+vec3  dFdy(vec3  p);
+vec4  dFdy(vec4  p);
+
+float fwidth(float p);
+vec2  fwidth(vec2  p);
+vec3  fwidth(vec3  p);
+vec4  fwidth(vec4  p);
diff --git a/src/glsl/builtins/profiles/300es.glsl 
b/src/glsl/builtins/profiles/300es.glsl
new file mode 100644
index 000..45212b3
--- /dev/null
+++ b/src/glsl/builtins/profiles/300es.glsl
@@ -0,0 +1,749 @@
+#version 300 es
+/*
+ * 8.1 - Angle and Trigonometry Functions
+ */
+float radians(float degrees);
+vec2  radians(vec2  degrees);
+vec3  radians(vec3  degrees);

[Mesa-dev] [PATCH 23/26] glsl: add determinant() functions.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

These functions are defined in GLSL 1.50 and GLES 3.00 ES.

The formulas have been extracted from the existing implementation of
inverse().

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/builtins/glsl/determinant.glsl | 70 +
 1 file changed, 70 insertions(+)
 create mode 100644 src/glsl/builtins/glsl/determinant.glsl

diff --git a/src/glsl/builtins/glsl/determinant.glsl 
b/src/glsl/builtins/glsl/determinant.glsl
new file mode 100644
index 000..32695a8
--- /dev/null
+++ b/src/glsl/builtins/glsl/determinant.glsl
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#version 120
+float determinant(mat2 m)
+{
+   return m[0][0] * m[1][1] - m[1][0] * m[0][1];
+}
+
+float determinant(mat3 m)
+{
+   return (+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
+   - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
+   + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]));
+}
+
+float determinant(mat4 m)
+{
+   float SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
+   float SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
+   float SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
+   float SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
+   float SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
+   float SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
+   float SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
+   float SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
+   float SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
+   float SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
+   float SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
+   float SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
+   float SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
+   float SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
+   float SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
+   float SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
+   float SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
+   float SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
+   float SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
+
+   vec4 adj_0;
+
+   adj_0[0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * 
SubFactor02);
+   adj_0[1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * 
SubFactor04);
+   adj_0[2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * 
SubFactor05);
+   adj_0[3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * 
SubFactor05);
+
+   return (+ m[0][0] * adj_0[0]
+   + m[0][1] * adj_0[1]
+   + m[0][2] * adj_0[2]
+   + m[0][3] * adj_0[3]);
+}
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 26/26] glsl: Support unsigned integer constants in layout qualifiers.

2012-11-30 Thread Ian Romanick
From: Kenneth Graunke kenn...@whitecape.org

Fixes es3conform's explicit_attrib_location_integer_constants.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Eric Anholt e...@anholt.net
---
 src/glsl/glsl_parser.yy | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index f123368..d849466 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1088,6 +1088,7 @@ layout_qualifier_id_list:
 integer_constant:
INTCONSTANT { $$ = $1; }
| UINTCONSTANT { $$ = $1; }
+   ;
 
 layout_qualifier_id:
any_identifier
-- 
1.7.11.7

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


[Mesa-dev] [PATCH 25/26] glsl: Allow layout qualifiers in GLSL 3.00 ES

2012-11-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Note that while 'packed' is a reserved word in GLSL ES, row_major is not.
This means that we have to use the string-based matching for that.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
---
 src/glsl/glsl_lexer.ll  | 2 +-
 src/glsl/glsl_parser.yy | 2 ++
 src/glsl/glsl_parser_extras.cpp | 4 
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index af39512..2f66c58 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -437,7 +437,7 @@ enumKEYWORD(110, 100, 0, 0, ENUM);
 typedefKEYWORD(110, 100, 0, 0, TYPEDEF);
 template   KEYWORD(110, 100, 0, 0, TEMPLATE);
 this   KEYWORD(110, 100, 0, 0, THIS);
-packed KEYWORD_WITH_ALT(110, 100, 140, 0, 
yyextra-ARB_uniform_buffer_object_enable, PACKED_TOK);
+packed KEYWORD_WITH_ALT(110, 100, 140, 300, 
yyextra-ARB_uniform_buffer_object_enable, PACKED_TOK);
 goto   KEYWORD(110, 100, 0, 0, GOTO);
 switch KEYWORD(110, 100, 130, 300, SWITCH);
 defaultKEYWORD(110, 100, 130, 300, DEFAULT);
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index d938765..f123368 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1143,6 +1143,8 @@ layout_qualifier_id:
 $$.flags.q.shared = 1;
  } else if (strcmp($1, column_major) == 0) {
 $$.flags.q.column_major = 1;
+ } else if (strcmp($1, row_major) == 0) {
+$$.flags.q.row_major = 1;
  }
 
  if ($$.flags.i  state-ARB_uniform_buffer_object_warn) {
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 80f15a6..4c8d6a9 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -260,6 +260,10 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE 
*locp, int version,
if (this-language_version = 140) {
   this-ARB_uniform_buffer_object_enable = true;
}
+
+   if (this-language_version == 300  this-es_shader) {
+  this-ARB_explicit_attrib_location_enable = true;
+   }
 }
 
 const char *
-- 
1.7.11.7

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


[Mesa-dev] [PATCH] llvmpipe: Refactor convert_to/from_blend_type to convert in place.

2012-11-30 Thread jfonseca
From: José Fonseca jfons...@vmware.com

This fixes the Source and destination overlap in memcpy valgrind
warnings.
---
 src/gallium/drivers/llvmpipe/lp_state_fs.c |   20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 6819d33..9b10800 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -1077,10 +1077,10 @@ convert_to_blend_type(struct gallivm_state *gallivm,
   const struct util_format_description *src_fmt,
   struct lp_type src_type,
   struct lp_type dst_type,
-  LLVMValueRef* src,
-  unsigned num_srcs,
-  LLVMValueRef* dst)
+  LLVMValueRef* src, // and dst
+  unsigned num_srcs)
 {
+   LLVMValueRef *dst = src;
LLVMBuilderRef builder = gallivm-builder;
struct lp_type blend_type;
struct lp_type mem_type;
@@ -1088,8 +1088,6 @@ convert_to_blend_type(struct gallivm_state *gallivm,
unsigned pixels = 16 / num_srcs;
bool is_arith;
 
-   memcpy(dst, src, sizeof(LLVMValueRef) * num_srcs);
-
lp_mem_type_from_format_desc(src_fmt, mem_type);
lp_blend_type_from_format_desc(src_fmt, blend_type);
 
@@ -1179,10 +1177,10 @@ convert_from_blend_type(struct gallivm_state *gallivm,
 const struct util_format_description *src_fmt,
 struct lp_type src_type,
 struct lp_type dst_type,
-LLVMValueRef* src,
-unsigned num_srcs,
-LLVMValueRef* dst)
+LLVMValueRef* src, // and dst
+unsigned num_srcs)
 {
+   LLVMValueRef* dst = src;
unsigned i, j, k;
struct lp_type mem_type;
struct lp_type blend_type;
@@ -1190,8 +1188,6 @@ convert_from_blend_type(struct gallivm_state *gallivm,
unsigned pixels = 16 / num_srcs;
bool is_arith;
 
-   memcpy(dst, src, sizeof(LLVMValueRef) * num_srcs);
-
lp_mem_type_from_format_desc(src_fmt, mem_type);
lp_blend_type_from_format_desc(src_fmt, blend_type);
 
@@ -1646,7 +1642,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
/*
 * Blending
 */
-   convert_to_blend_type(gallivm, out_format_desc, dst_type, row_type, dst, 
src_count, dst);
+   convert_to_blend_type(gallivm, out_format_desc, dst_type, row_type, dst, 
src_count);
 
for (i = 0; i  src_count; ++i) {
   dst[i] = lp_build_blend_aos(gallivm,
@@ -1664,7 +1660,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
   pad_inline ? 4 : dst_channels);
}
 
-   convert_from_blend_type(gallivm, out_format_desc, row_type, dst_type, dst, 
src_count, dst);
+   convert_from_blend_type(gallivm, out_format_desc, row_type, dst_type, dst, 
src_count);
 
/* Split the blend rows back to memory rows */
if (dst_count  src_count) {
-- 
1.7.9.5

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


Re: [Mesa-dev] leak in loop_analysis

2012-11-30 Thread Ian Romanick

On 11/30/2012 02:20 AM, Dave Airlie wrote:

Coverity pointed out
src/glsl/loop_analysis.cpp

loop_analysis::loop_analysis()
{
this-loops = new loop_state;


This loops is never freed anywhere, probably need a destructor.


Aw crap.  Could you submit a bug for that, and assign it to me?


Dave.
___
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 1/3] mesa: pass context parameter to gl_renderbuffer::Delete()

2012-11-30 Thread Brian Paul
We sometimes need a rendering context when deleting renderbuffers.
Pass it explicitly instead of trying to grab a current context
(which might be NULL).  The next patch will make use of this.

Note: this is a candidate for the stable branches.
---
 src/mesa/drivers/dri/intel/intel_fbo.c |4 ++--
 src/mesa/drivers/dri/nouveau/nouveau_fbo.c |4 ++--
 src/mesa/drivers/dri/radeon/radeon_fbo.c   |4 ++--
 src/mesa/drivers/dri/swrast/swrast.c   |4 ++--
 src/mesa/drivers/osmesa/osmesa.c   |4 ++--
 src/mesa/drivers/windows/gdi/wmesa.c   |4 ++--
 src/mesa/drivers/x11/xm_buffer.c   |2 +-
 src/mesa/main/fbobject.c   |2 +-
 src/mesa/main/mtypes.h |2 +-
 src/mesa/main/renderbuffer.c   |8 ++--
 src/mesa/main/renderbuffer.h   |2 +-
 src/mesa/main/shared.c |3 ++-
 src/mesa/state_tracker/st_cb_fbo.c |4 ++--
 src/mesa/swrast/s_renderbuffer.c   |4 ++--
 src/mesa/swrast/s_texrender.c  |2 +-
 15 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
b/src/mesa/drivers/dri/intel/intel_fbo.c
index 96f6c32..6a66521 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -87,7 +87,7 @@ intel_new_framebuffer(struct gl_context * ctx, GLuint name)
 
 /** Called by gl_renderbuffer::Delete() */
 static void
-intel_delete_renderbuffer(struct gl_renderbuffer *rb)
+intel_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
@@ -95,7 +95,7 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb)
 
intel_miptree_release(irb-mt);
 
-   _mesa_delete_renderbuffer(rb);
+   _mesa_delete_renderbuffer(ctx, rb);
 }
 
 /**
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c 
b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
index c3e2341..c47bce8 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c
@@ -102,12 +102,12 @@ nouveau_renderbuffer_storage(struct gl_context *ctx, 
struct gl_renderbuffer *rb,
 }
 
 static void
-nouveau_renderbuffer_del(struct gl_renderbuffer *rb)
+nouveau_renderbuffer_del(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
struct nouveau_surface *s = to_nouveau_renderbuffer(rb)-surface;
 
nouveau_surface_ref(NULL, s);
-   _mesa_delete_renderbuffer(rb);
+   _mesa_delete_renderbuffer(ctx, rb);
 }
 
 static struct gl_renderbuffer *
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c 
b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 291f2b7..9ab74c4 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -54,7 +54,7 @@ radeon_new_framebuffer(struct gl_context *ctx, GLuint name)
 }
 
 static void
-radeon_delete_renderbuffer(struct gl_renderbuffer *rb)
+radeon_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
   struct radeon_renderbuffer *rrb = radeon_renderbuffer(rb);
 
@@ -67,7 +67,7 @@ radeon_delete_renderbuffer(struct gl_renderbuffer *rb)
   if (rrb  rrb-bo) {
 radeon_bo_unref(rrb-bo);
   }
-  _mesa_delete_renderbuffer(rb);
+  _mesa_delete_renderbuffer(ctx, rb);
 }
 
 #if defined(RADEON_R100)
diff --git a/src/mesa/drivers/dri/swrast/swrast.c 
b/src/mesa/drivers/dri/swrast/swrast.c
index 3a47cdb..2474ed8 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -251,14 +251,14 @@ choose_pixel_format(const struct gl_config *v)
 }
 
 static void
-swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
+swrast_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
 struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb);
 
 TRACE;
 
 free(xrb-Base.Buffer);
-_mesa_delete_renderbuffer(rb);
+_mesa_delete_renderbuffer(ctx, rb);
 }
 
 /* see bytes_per_line in libGL */
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index e02b2f3..c206d64 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -386,9 +386,9 @@ compute_row_addresses( OSMesaContext osmesa )
  * Don't use _mesa_delete_renderbuffer since we can't free rb-Buffer.
  */
 static void
-osmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+osmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
-   free(rb);
+   _mesa_delete_renderbuffer(ctx, rb);
 }
 
 
diff --git a/src/mesa/drivers/windows/gdi/wmesa.c 
b/src/mesa/drivers/windows/gdi/wmesa.c
index 9f6f750..50347cf 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -426,9 +426,9 @@ static void clear(struct gl_context *ctx, GLbitfield mask)
 
 
 static void
-wmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+wmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer 

[Mesa-dev] [PATCH 2/3] util: added pipe_surface_release() function

2012-11-30 Thread Brian Paul
To fix a pipe_context::surface_destroy() use-after-free problem.
We previously added pipe_sampler_view_release() for similar reasons.

Note: this is a candidate for the stable branches.
---
 src/gallium/auxiliary/util/u_inlines.h |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_inlines.h 
b/src/gallium/auxiliary/util/u_inlines.h
index 6ef5fec..cb06ee2 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -114,6 +114,22 @@ pipe_surface_reference(struct pipe_surface **ptr, struct 
pipe_surface *surf)
*ptr = surf;
 }
 
+/**
+ * Similar to pipe_surface_reference() but always set the pointer to NULL
+ * and pass in an explicit context.  The explicit context avoids the problem
+ * of using a deleted context's surface_destroy() method when freeing a surface
+ * that's shared by multiple contexts.
+ */
+static INLINE void
+pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr)
+{
+   if (pipe_reference_described((*ptr)-reference, NULL,
+
(debug_reference_descriptor)debug_describe_surface))
+  pipe-surface_destroy(pipe, *ptr);
+   *ptr = NULL;
+}
+
+
 static INLINE void
 pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
 {
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 3/3] st/mesa: fix context use-after-free problem in st_renderbuffer_delete()

2012-11-30 Thread Brian Paul
The use-after-free happened when the renderbuffer was shared by multiple
contexts and we tried to delete the renderbuffer using a context which
was previously deleted.

Note: this is a candidate for the stable branches.
---
 src/mesa/state_tracker/st_cb_fbo.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_fbo.c 
b/src/mesa/state_tracker/st_cb_fbo.c
index 05a1dc6..04907c9 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -228,8 +228,10 @@ static void
 st_renderbuffer_delete(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
struct st_renderbuffer *strb = st_renderbuffer(rb);
-   ASSERT(strb);
-   pipe_surface_reference(strb-surface, NULL);
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st-pipe;
+
+   pipe_surface_release(pipe, strb-surface);
pipe_resource_reference(strb-texture, NULL);
free(strb-data);
_mesa_delete_renderbuffer(ctx, rb);
@@ -434,7 +436,7 @@ st_render_texture(struct gl_context *ctx,
 
pipe_resource_reference( strb-texture, pt );
 
-   pipe_surface_reference(strb-surface, NULL);
+   pipe_surface_release(pipe, strb-surface);
 
assert(strb-rtt_level = strb-texture-last_level);
 
-- 
1.7.3.4

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


Re: [Mesa-dev] [PATCH 2/2] llvmpipe: Improve color buffer loads/stores alignment.

2012-11-30 Thread Roland Scheidegger
Am 30.11.2012 18:43, schrieb jfons...@vmware.com:
 From: José Fonseca jfons...@vmware.com
 
 Tell LLVM the exact alignment we can guarantee, based on the fs block
 dimensions, pixel format, and the alignment of the resource base pointer
 and stride.
 ---
  src/gallium/drivers/llvmpipe/lp_state_fs.c |   31 
 +++-
  1 file changed, 21 insertions(+), 10 deletions(-)
 
 diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
 b/src/gallium/drivers/llvmpipe/lp_state_fs.c
 index 2d2e346..6819d33 100644
 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
 +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
 @@ -839,7 +839,8 @@ load_unswizzled_block(struct gallivm_state *gallivm,
unsigned block_height,
LLVMValueRef* dst,
struct lp_type dst_type,
 -  unsigned dst_count)
 +  unsigned dst_count,
 +  unsigned dst_alignment)
  {
 LLVMBuilderRef builder = gallivm-builder;
 unsigned row_size = dst_count / block_height;
 @@ -866,9 +867,7 @@ load_unswizzled_block(struct gallivm_state *gallivm,
  
dst[i] = LLVMBuildLoad(builder, dst_ptr, );
  
 -  if ((dst_type.length % 3) == 0) {
 - lp_set_load_alignment(dst[i], dst_type.width / 8);
 -  }
 +  lp_set_load_alignment(dst[i], dst_alignment);
 }
  }
  
 @@ -884,7 +883,8 @@ store_unswizzled_block(struct gallivm_state *gallivm,
 unsigned block_height,
 LLVMValueRef* src,
 struct lp_type src_type,
 -   unsigned src_count)
 +   unsigned src_count,
 +   unsigned src_alignment)
  {
 LLVMBuilderRef builder = gallivm-builder;
 unsigned row_size = src_count / block_height;
 @@ -893,6 +893,8 @@ store_unswizzled_block(struct gallivm_state *gallivm,
 /* Ensure src exactly fits into block */
 assert((block_width * block_height) % src_count == 0);
  
 +
 +
extra whitespace.

 for (i = 0; i  src_count; ++i) {
unsigned x = i % row_size;
unsigned y = i / row_size;
 @@ -911,9 +913,7 @@ store_unswizzled_block(struct gallivm_state *gallivm,
  
src_ptr = LLVMBuildStore(builder, src[i], src_ptr);
  
 -  if ((src_type.length % 3) == 0) {
 - lp_set_store_alignment(src_ptr, src_type.width / 8);
 -  }
 +  lp_set_store_alignment(src_ptr, src_alignment);
 }
  }
  
 @@ -1333,6 +1333,8 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
  
 const struct util_format_description* out_format_desc = 
 util_format_description(out_format);
  
 +   unsigned dst_alignment;
 +
 bool pad_inline = is_arithmetic_format(out_format_desc);
 bool has_alpha = false;
  
 @@ -1340,6 +1342,13 @@ generate_unswizzled_blend(struct gallivm_state 
 *gallivm,
 mask_type = lp_int32_vec4_type();
 mask_type.length = fs_type.length;
  
 +   /* Compute the alignment of the destination pointer in bytes */
 +   dst_alignment = (block_width * out_format_desc-block.bits + 
 7)/(out_format_desc-block.width * 8);
 +   /* Force power-of-two alignment by extracting only the 
 least-significant-bit */
 +   dst_alignment = 1  (ffs(dst_alignment) - 1);
 +   /* Resource base and stride pointers are aligned to 16 bytes, so that's 
 the maximum alignment we can guarantee */
 +   dst_alignment = MIN2(dst_alignment, 16);
I wonder if this is all necessary. block_width is a constant and pot,
and the formats are all pot-sized too, so trying to align this to pot
won't really do much.
So unless this somehow should handle non-pot block_width (and I don't
think this makes sense) this should probably be simplified.

 +
 /* Do not bother executing code when mask is empty.. */
 if (do_branch) {
check_mask = LLVMConstNull(lp_build_int_vec_type(gallivm, mask_type));
 @@ -1616,7 +1625,8 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
  
 dst_type.length *= 16 / dst_count;
  
 -   load_unswizzled_block(gallivm, color_ptr, stride, block_width, 
 block_height, dst, dst_type, dst_count);
 +   load_unswizzled_block(gallivm, color_ptr, stride, block_width, 
 block_height,
 + dst, dst_type, dst_count, dst_alignment);
  
  
 /*
 @@ -1681,7 +1691,8 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
 /*
  * Store blend result to memory
  */
 -   store_unswizzled_block(gallivm, color_ptr, stride, block_width, 
 block_height, dst, dst_type, dst_count);
 +   store_unswizzled_block(gallivm, color_ptr, stride, block_width, 
 block_height,
 +  dst, dst_type, dst_count, dst_alignment);
  
 if (do_branch) {
lp_build_mask_end(mask_ctx);
 

Otherwise, this (and rest of series) looks good to me.

Roland

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


[Mesa-dev] [PATCH] glcpp: Add support to #line for a filnename, not just a source string number

2012-11-30 Thread Carl Worth
Such as:

#line 23 foo.c

Having a filename here is quite useful and many other OpenGL implementations
allow this.

Note that for GLES we take the hard line and insist on a numeric source string
number as per the specification and which glcpp has always supported:

#line 23 3
---

This is something of a proof-of-concept for now.

Ian mentioned to me yesterday that he would like to have support for '#line XX
filename.c' has described above. And this is my quickest implementation of
that.

This is simple in that the string literal is not actually interpreted, (escape
sequences aren't converted into their representations). The escape sequences
are properly captured by a regular expression, but all just sucked up
literally. This was easier to write, and is also what we want for re-emitting
the #line directive, (with all of the escape sequences in place).

This is slightly bogus for emitting the error messages, though. You'll get a
C-formatted string literal instead of a filename. At a minimum this will look
like:

foo.c:25: Syntax error

So there are extra quotation marks there. And it will appear uglier if there
are further escape sequences in the string. Fixing this would mean writing a
fair amount of code to decode the C string literal, and then additional code
to re-encode it to emit the #line directive.

It's not totally clear to me whether that's all worth it. (Note that the code
does exist in many implementations of C grammars, so it would be easy to find
a version that we could legitimately copy into our implementation.)

Meanwhile, the bigger issue that makes this just a proof-of-concept is that
only the pre-processor is changed here. And unlike something like #define, the
downstream compiler still sees #line directives emitted by the
pre-processor. So a complete implementation of the feature of interest here
requires augmenting the downstream code that is handling #line.

I'll look at that next, but just wanted to mention the issue of string
interpretation here first.

And yes, it is silly that we are parsing #line in two different places of the
code. Someday we'll have to integrate the GLSL compiler's parser with the
output of the preprocessor, (drop the GLSL compiler's separate lexer, and make
the preprocessor emit tokens rather than strings). When we do that, a feature
like this one will be simpler.

-Carl

 src/glsl/glcpp/glcpp-lex.l   |   15 ++-
 src/glsl/glcpp/glcpp-parse.y |   34 ++
 src/glsl/glcpp/glcpp.h   |8 
 src/glsl/glcpp/pp.c  |4 ++--
 4 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index 783c545..893ce66 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -44,20 +44,20 @@ void glcpp_set_column (int  column_no , yyscan_t yyscanner);
do {\
if (parser-has_new_line_number)\
yylineno = parser-new_line_number; \
-   if (parser-has_new_source_number)  \
-   yylloc-source = parser-new_source_number; \
+   if (parser-has_new_source) \
+   yylloc-source = parser-new_source;\
yylloc-first_column = yycolumn + 1;\
yylloc-first_line = yylineno;  \
yycolumn += yyleng; \
parser-has_new_line_number = 0;\
-   parser-has_new_source_number = 0;  \
+   parser-has_new_source = 0; \
  } while(0);
 
 #define YY_USER_INIT   \
do {\
yylineno = 1;   \
yycolumn = 1;   \
-   yylloc-source = 0; \
+   yylloc-source = 0;   \
} while(0)
 %}
 
@@ -84,7 +84,7 @@ strings, we have to be careful to avoid OTHER matching and 
hiding
 something that CPP does care about. So we simply exclude all
 characters that appear in any other expressions. */
 
-OTHER  [^][_#[:space:]#a-zA-Z0-9(){}.*~!/%^|;,=+-]
+OTHER  [^][_#[:space:]#a-zA-Z0-9(){}.*~!/%^|;,=+-]
 
 DIGITS [0-9][0-9]*
 DECIMAL_INTEGER[1-9][0-9]*[uU]?
@@ -120,6 +120,11 @@ HEXADECIMAL_INTEGER0[xX][0-9a-fA-F]+[uU]?
return SPACE;
 }
 
+\(\\.|[^\\\n])*\ {
+   yylval-str = ralloc_strdup (yyextra, yytext);
+   return STRING_LITERAL;
+}
+
 {HASH}version {
yylval-str = ralloc_strdup (yyextra, yytext);
yyextra-space_tokens = 0;
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index bdf7e17..7d7499d 100644
--- 

Re: [Mesa-dev] [PATCH] llvmpipe: Refactor convert_to/from_blend_type to convert in place.

2012-11-30 Thread Roland Scheidegger
Am 30.11.2012 19:08, schrieb jfons...@vmware.com:
 From: José Fonseca jfons...@vmware.com
 
 This fixes the Source and destination overlap in memcpy valgrind
 warnings.
 ---
  src/gallium/drivers/llvmpipe/lp_state_fs.c |   20 
  1 file changed, 8 insertions(+), 12 deletions(-)
 
 diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
 b/src/gallium/drivers/llvmpipe/lp_state_fs.c
 index 6819d33..9b10800 100644
 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
 +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
 @@ -1077,10 +1077,10 @@ convert_to_blend_type(struct gallivm_state *gallivm,
const struct util_format_description *src_fmt,
struct lp_type src_type,
struct lp_type dst_type,
 -  LLVMValueRef* src,
 -  unsigned num_srcs,
 -  LLVMValueRef* dst)
 +  LLVMValueRef* src, // and dst
 +  unsigned num_srcs)
  {
 +   LLVMValueRef *dst = src;
 LLVMBuilderRef builder = gallivm-builder;
 struct lp_type blend_type;
 struct lp_type mem_type;
 @@ -1088,8 +1088,6 @@ convert_to_blend_type(struct gallivm_state *gallivm,
 unsigned pixels = 16 / num_srcs;
 bool is_arith;
  
 -   memcpy(dst, src, sizeof(LLVMValueRef) * num_srcs);
 -
 lp_mem_type_from_format_desc(src_fmt, mem_type);
 lp_blend_type_from_format_desc(src_fmt, blend_type);
  
 @@ -1179,10 +1177,10 @@ convert_from_blend_type(struct gallivm_state *gallivm,
  const struct util_format_description *src_fmt,
  struct lp_type src_type,
  struct lp_type dst_type,
 -LLVMValueRef* src,
 -unsigned num_srcs,
 -LLVMValueRef* dst)
 +LLVMValueRef* src, // and dst
 +unsigned num_srcs)
  {
 +   LLVMValueRef* dst = src;
 unsigned i, j, k;
 struct lp_type mem_type;
 struct lp_type blend_type;
 @@ -1190,8 +1188,6 @@ convert_from_blend_type(struct gallivm_state *gallivm,
 unsigned pixels = 16 / num_srcs;
 bool is_arith;
  
 -   memcpy(dst, src, sizeof(LLVMValueRef) * num_srcs);
 -
 lp_mem_type_from_format_desc(src_fmt, mem_type);
 lp_blend_type_from_format_desc(src_fmt, blend_type);
  
 @@ -1646,7 +1642,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
 /*
  * Blending
  */
 -   convert_to_blend_type(gallivm, out_format_desc, dst_type, row_type, dst, 
 src_count, dst);
 +   convert_to_blend_type(gallivm, out_format_desc, dst_type, row_type, dst, 
 src_count);
  
 for (i = 0; i  src_count; ++i) {
dst[i] = lp_build_blend_aos(gallivm,
 @@ -1664,7 +1660,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
pad_inline ? 4 : dst_channels);
 }
  
 -   convert_from_blend_type(gallivm, out_format_desc, row_type, dst_type, 
 dst, src_count, dst);
 +   convert_from_blend_type(gallivm, out_format_desc, row_type, dst_type, 
 dst, src_count);
  
 /* Split the blend rows back to memory rows */
 if (dst_count  src_count) {
 

Reviewed-by: Roland Scheidegger srol...@vmware.com


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


Re: [Mesa-dev] [PATCH mesa] egl/wayland: Don't invalidate drawable on swap buffers

2012-11-30 Thread Kristian Høgsberg
On Fri, Nov 30, 2012 at 11:07:09AM -0500, Kristian Høgsberg wrote:
 On Fri, Nov 30, 2012 at 05:41:02PM +0200, Ander Conselvan de Oliveira wrote:
  We used to invalidate the drawable after a call to eglSwapBuffers(),
  so that a wl_egl_window_resize() would take effect for the next frame.
  However, that leads to calling dri2_get_buffers() when eglMakeCurrent()
  is called with the current context and surface, and a later call to
  wl_egl_window_resize() would not take effect until the next buffer
  swap.
  
  Instead, add a callback from wl_egl_window_resize() back to the wayland
  egl platform, and invalidate the drawable only when it is resized.
  
  This solves a bug on wayland clients when going back to windowed mode
  from fullscreen when clicking a pop up menu, where the window size
  after this would be the fullscreen size.
 
 Yes, this is good, it's the right fix for that problem.  And with the
 resize callback we can avoid the getbuffers callback every frame which
 should save a few cycles as well.
 
 Thanks, applied.
 Kristian

And now I'm banging my head against the table... since we always swap
buffers in wayland, we always need to invalidate after swap, so the
driver will ask for the new back buffer.  I pushed a fixup-commit to just
add the invalidate call back in dri2_swap_buffers().

Kristian

  Note: this is a candidate for stable branches.
  CC: wayland-de...@lists.freedesktop.org
  ---
   src/egl/drivers/dri2/platform_wayland.c|   20 +++-
   src/egl/wayland/wayland-egl/wayland-egl-priv.h |3 +++
   src/egl/wayland/wayland-egl/wayland-egl.c  |5 +
   3 files changed, 27 insertions(+), 1 deletion(-)
  
  diff --git a/src/egl/drivers/dri2/platform_wayland.c 
  b/src/egl/drivers/dri2/platform_wayland.c
  index 8df22c0..e55f92b 100644
  --- a/src/egl/drivers/dri2/platform_wayland.c
  +++ b/src/egl/drivers/dri2/platform_wayland.c
  @@ -97,6 +97,16 @@ static struct wl_buffer_listener wl_buffer_listener = {
  wl_buffer_release
   };
   
  +static void
  +resize_callback(struct wl_egl_window *wl_win, void *data)
  +{
  +   struct dri2_egl_surface *dri2_surf = data;
  +   struct dri2_egl_display *dri2_dpy =
  +  dri2_egl_display(dri2_surf-base.Resource.Display);
  +
  +   (*dri2_dpy-flush-invalidate)(dri2_surf-dri_drawable);
  +}
  +
   /**
* Called via eglCreateWindowSurface(), drv-API.CreateWindowSurface().
*/
  @@ -142,6 +152,9 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
  EGLint type,
  case EGL_WINDOW_BIT:
 dri2_surf-wl_win = (struct wl_egl_window *) window;
   
  +  dri2_surf-wl_win-private = dri2_surf;
  +  dri2_surf-wl_win-resize_callback = resize_callback;
  +
 dri2_surf-base.Width =  -1;
 dri2_surf-base.Height = -1;
 break;
  @@ -216,6 +229,12 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay 
  *disp, _EGLSurface *surf)
  if (dri2_surf-frame_callback)
 wl_callback_destroy(dri2_surf-frame_callback);
   
  +
  +   if (dri2_surf-base.Type == EGL_WINDOW_BIT) {
  +  dri2_surf-wl_win-private = NULL;
  +  dri2_surf-wl_win-resize_callback = NULL;
  +   }
  +
  free(surf);
   
  return EGL_TRUE;
  @@ -592,7 +611,6 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, 
  _EGLSurface *draw)
  }
   
  (*dri2_dpy-flush-flush)(dri2_surf-dri_drawable);
  -   (*dri2_dpy-flush-invalidate)(dri2_surf-dri_drawable);
   
  return EGL_TRUE;
   }
  diff --git a/src/egl/wayland/wayland-egl/wayland-egl-priv.h 
  b/src/egl/wayland/wayland-egl/wayland-egl-priv.h
  index bdbf32a..da25be9 100644
  --- a/src/egl/wayland/wayland-egl/wayland-egl-priv.h
  +++ b/src/egl/wayland/wayland-egl/wayland-egl-priv.h
  @@ -24,6 +24,9 @@ struct wl_egl_window {
   
  int attached_width;
  int attached_height;
  +
  +   void *private;
  +   void (*resize_callback)(struct wl_egl_window *, void *);
   };
   
   #ifdef  __cplusplus
  diff --git a/src/egl/wayland/wayland-egl/wayland-egl.c 
  b/src/egl/wayland/wayland-egl/wayland-egl.c
  index c61fb4f..8bd49cf 100644
  --- a/src/egl/wayland/wayland-egl/wayland-egl.c
  +++ b/src/egl/wayland/wayland-egl/wayland-egl.c
  @@ -13,6 +13,9 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
  egl_window-height = height;
  egl_window-dx = dx;
  egl_window-dy = dy;
  +
  +   if (egl_window-resize_callback)
  +   egl_window-resize_callback(egl_window, egl_window-private);
   }
   
   WL_EGL_EXPORT struct wl_egl_window *
  @@ -26,6 +29,8 @@ wl_egl_window_create(struct wl_surface *surface,
  return NULL;
   
  egl_window-surface = surface;
  +   egl_window-private = NULL;
  +   egl_window-resize_callback = NULL;
  wl_egl_window_resize(egl_window, width, height, 0, 0);
  egl_window-attached_width  = 0;
  egl_window-attached_height = 0;
  -- 
  1.7.10.4
  
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

Re: [Mesa-dev] [PATCH 2/2] llvmpipe: Improve color buffer loads/stores alignment.

2012-11-30 Thread Jose Fonseca


- Original Message -
 Am 30.11.2012 18:43, schrieb jfons...@vmware.com:
  From: José Fonseca jfons...@vmware.com
  
  Tell LLVM the exact alignment we can guarantee, based on the fs
  block
  dimensions, pixel format, and the alignment of the resource base
  pointer
  and stride.
  ---
   src/gallium/drivers/llvmpipe/lp_state_fs.c |   31
   +++-
   1 file changed, 21 insertions(+), 10 deletions(-)
  
  diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c
  b/src/gallium/drivers/llvmpipe/lp_state_fs.c
  index 2d2e346..6819d33 100644
  --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
  +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
  @@ -839,7 +839,8 @@ load_unswizzled_block(struct gallivm_state
  *gallivm,
 unsigned block_height,
 LLVMValueRef* dst,
 struct lp_type dst_type,
  -  unsigned dst_count)
  +  unsigned dst_count,
  +  unsigned dst_alignment)
   {
  LLVMBuilderRef builder = gallivm-builder;
  unsigned row_size = dst_count / block_height;
  @@ -866,9 +867,7 @@ load_unswizzled_block(struct gallivm_state
  *gallivm,
   
 dst[i] = LLVMBuildLoad(builder, dst_ptr, );
   
  -  if ((dst_type.length % 3) == 0) {
  - lp_set_load_alignment(dst[i], dst_type.width / 8);
  -  }
  +  lp_set_load_alignment(dst[i], dst_alignment);
  }
   }
   
  @@ -884,7 +883,8 @@ store_unswizzled_block(struct gallivm_state
  *gallivm,
  unsigned block_height,
  LLVMValueRef* src,
  struct lp_type src_type,
  -   unsigned src_count)
  +   unsigned src_count,
  +   unsigned src_alignment)
   {
  LLVMBuilderRef builder = gallivm-builder;
  unsigned row_size = src_count / block_height;
  @@ -893,6 +893,8 @@ store_unswizzled_block(struct gallivm_state
  *gallivm,
  /* Ensure src exactly fits into block */
  assert((block_width * block_height) % src_count == 0);
   
  +
  +
 extra whitespace.
 
  for (i = 0; i  src_count; ++i) {
 unsigned x = i % row_size;
 unsigned y = i / row_size;
  @@ -911,9 +913,7 @@ store_unswizzled_block(struct gallivm_state
  *gallivm,
   
 src_ptr = LLVMBuildStore(builder, src[i], src_ptr);
   
  -  if ((src_type.length % 3) == 0) {
  - lp_set_store_alignment(src_ptr, src_type.width / 8);
  -  }
  +  lp_set_store_alignment(src_ptr, src_alignment);
  }
   }
   
  @@ -1333,6 +1333,8 @@ generate_unswizzled_blend(struct
  gallivm_state *gallivm,
   
  const struct util_format_description* out_format_desc =
  util_format_description(out_format);
   
  +   unsigned dst_alignment;
  +
  bool pad_inline = is_arithmetic_format(out_format_desc);
  bool has_alpha = false;
   
  @@ -1340,6 +1342,13 @@ generate_unswizzled_blend(struct
  gallivm_state *gallivm,
  mask_type = lp_int32_vec4_type();
  mask_type.length = fs_type.length;
   
  +   /* Compute the alignment of the destination pointer in bytes */
  +   dst_alignment = (block_width * out_format_desc-block.bits +
  7)/(out_format_desc-block.width * 8);
  +   /* Force power-of-two alignment by extracting only the
  least-significant-bit */
  +   dst_alignment = 1  (ffs(dst_alignment) - 1);
  +   /* Resource base and stride pointers are aligned to 16 bytes,
  so that's the maximum alignment we can guarantee */
  +   dst_alignment = MIN2(dst_alignment, 16);
 I wonder if this is all necessary. block_width is a constant and pot,
 and the formats are all pot-sized too, 

Formats are not necessarily pot-sized: R8G8B8, R16G16B16, etc.

For example, for R8G8B8, 4*3 = 12 bytes. So if we need to round this down to 4 
bytes.

 so trying to align this to pot
 won't really do much.
 So unless this somehow should handle non-pot block_width (and I don't
 think this makes sense) this should probably be simplified.
 
  +
  /* Do not bother executing code when mask is empty.. */
  if (do_branch) {
 check_mask = LLVMConstNull(lp_build_int_vec_type(gallivm,
 mask_type));
  @@ -1616,7 +1625,8 @@ generate_unswizzled_blend(struct
  gallivm_state *gallivm,
   
  dst_type.length *= 16 / dst_count;
   
  -   load_unswizzled_block(gallivm, color_ptr, stride, block_width,
  block_height, dst, dst_type, dst_count);
  +   load_unswizzled_block(gallivm, color_ptr, stride, block_width,
  block_height,
  + dst, dst_type, dst_count, dst_alignment);
   
   
  /*
  @@ -1681,7 +1691,8 @@ generate_unswizzled_blend(struct
  gallivm_state *gallivm,
  /*
   * Store blend result to memory
   */
  -   store_unswizzled_block(gallivm, color_ptr, stride, block_width,
  block_height, dst, dst_type, dst_count);
  +   store_unswizzled_block(gallivm, color_ptr, stride, block_width,
  block_height,
  +  

Re: [Mesa-dev] [PATCH 3/3] st/mesa: fix context use-after-free problem in st_renderbuffer_delete()

2012-11-30 Thread Jose Fonseca
Series looks good to me.

Jose

- Original Message -
 The use-after-free happened when the renderbuffer was shared by
 multiple
 contexts and we tried to delete the renderbuffer using a context
 which
 was previously deleted.
 
 Note: this is a candidate for the stable branches.
 ---
  src/mesa/state_tracker/st_cb_fbo.c |8 +---
  1 files changed, 5 insertions(+), 3 deletions(-)
 
 diff --git a/src/mesa/state_tracker/st_cb_fbo.c
 b/src/mesa/state_tracker/st_cb_fbo.c
 index 05a1dc6..04907c9 100644
 --- a/src/mesa/state_tracker/st_cb_fbo.c
 +++ b/src/mesa/state_tracker/st_cb_fbo.c
 @@ -228,8 +228,10 @@ static void
  st_renderbuffer_delete(struct gl_context *ctx, struct
  gl_renderbuffer *rb)
  {
 struct st_renderbuffer *strb = st_renderbuffer(rb);
 -   ASSERT(strb);
 -   pipe_surface_reference(strb-surface, NULL);
 +   struct st_context *st = st_context(ctx);
 +   struct pipe_context *pipe = st-pipe;
 +
 +   pipe_surface_release(pipe, strb-surface);
 pipe_resource_reference(strb-texture, NULL);
 free(strb-data);
 _mesa_delete_renderbuffer(ctx, rb);
 @@ -434,7 +436,7 @@ st_render_texture(struct gl_context *ctx,
  
 pipe_resource_reference( strb-texture, pt );
  
 -   pipe_surface_reference(strb-surface, NULL);
 +   pipe_surface_release(pipe, strb-surface);
  
 assert(strb-rtt_level = strb-texture-last_level);
  
 --
 1.7.3.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] mesa: Use _mesa_lookup_enum_by_nr in tex*_error_check

2012-11-30 Thread Matt Turner
---
 src/mesa/main/teximage.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 347b3e2..6401824 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1949,7 +1949,8 @@ texture_error_check( struct gl_context *ctx,
if (err != GL_NO_ERROR) {
   _mesa_error(ctx, err,
   glTexImage%dD(incompatible format 0x%x, type 0x%x),
-  dimensions, format, type);
+  dimensions, _mesa_lookup_enum_by_nr(format),
+ _mesa_lookup_enum_by_nr(type));
   return GL_TRUE;
}
 
@@ -1962,7 +1963,8 @@ texture_error_check( struct gl_context *ctx,
(_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) 
{
   _mesa_error(ctx, GL_INVALID_OPERATION,
   glTexImage%dD(incompatible internalFormat 0x%x, format 
0x%x),
-  dimensions, internalFormat, format);
+  dimensions, _mesa_lookup_enum_by_nr(internalFormat),
+ _mesa_lookup_enum_by_nr(format));
   return GL_TRUE;
}
 
@@ -2265,7 +2267,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
dimensions,
if (err != GL_NO_ERROR) {
   _mesa_error(ctx, err,
   glTexSubImage%dD(incompatible format 0x%x, type 0x%x),
-  dimensions, format, type);
+  dimensions, _mesa_lookup_enum_by_nr(format),
+ _mesa_lookup_enum_by_nr(type));
   return GL_TRUE;
}
 
-- 
1.7.8.6

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


Re: [Mesa-dev] [PATCH] mesa: Use _mesa_lookup_enum_by_nr in tex*_error_check

2012-11-30 Thread Matt Turner
On Fri, Nov 30, 2012 at 11:26 AM, Matt Turner matts...@gmail.com wrote:
 ---
  src/mesa/main/teximage.c |9 ++---
  1 files changed, 6 insertions(+), 3 deletions(-)

 diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
 index 347b3e2..6401824 100644
 --- a/src/mesa/main/teximage.c
 +++ b/src/mesa/main/teximage.c
 @@ -1949,7 +1949,8 @@ texture_error_check( struct gl_context *ctx,
 if (err != GL_NO_ERROR) {
_mesa_error(ctx, err,
glTexImage%dD(incompatible format 0x%x, type 0x%x),
 -  dimensions, format, type);
 +  dimensions, _mesa_lookup_enum_by_nr(format),
 + _mesa_lookup_enum_by_nr(type));
return GL_TRUE;
 }

 @@ -1962,7 +1963,8 @@ texture_error_check( struct gl_context *ctx,
 (_mesa_is_dudv_format(internalFormat) != 
 _mesa_is_dudv_format(format))) {
_mesa_error(ctx, GL_INVALID_OPERATION,
glTexImage%dD(incompatible internalFormat 0x%x, format 
 0x%x),
 -  dimensions, internalFormat, format);
 +  dimensions, _mesa_lookup_enum_by_nr(internalFormat),
 + _mesa_lookup_enum_by_nr(format));
return GL_TRUE;
 }

 @@ -2265,7 +2267,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
 dimensions,
 if (err != GL_NO_ERROR) {
_mesa_error(ctx, err,
glTexSubImage%dD(incompatible format 0x%x, type 0x%x),
 -  dimensions, format, type);
 +  dimensions, _mesa_lookup_enum_by_nr(format),
 + _mesa_lookup_enum_by_nr(type));
return GL_TRUE;
 }

 --
 1.7.8.6


Whoops, didn't s/%x/%s/. Consider that fixed.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] gallivm: drop border wrap clamping code

2012-11-30 Thread sroland
From: Roland Scheidegger srol...@vmware.com

The border clamping code is unnecessary, since we don't care if a wrapped
coord value is -1 or -1 (same for length vs. length), in either case the
border handling code will mask out the offset and replace the texel value with
the border color.
Note that technically this is not entirely correct. Omitting clamping on the
float coords means that flt-int conversion may result in undefined values for
values of very large magnitude.
However there's no reason we should honor this here since:
a) we don't care for that for ordinary wrap modes in the aos code when
   converting coords and the problem is worse there (as we've got only
   effectively 24 instead of 32bits)
b) at least in some cases the clamping was done already in int space hence
   doing nothing to fix that problem.
c) with sse2 flt-int conversion with such values results in 0x8000 which
   is just perfect (for clamp to border - not so much for the ordinary clamp to
   edge).
---
 src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |   49 +++--
 1 file changed, 16 insertions(+), 33 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 659de9b..ba265b2 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -351,20 +351,16 @@ lp_build_sample_wrap_linear(struct 
lp_build_sample_context *bld,
   }
 
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
-  {
- LLVMValueRef min;
- if (bld-static_state-normalized_coords) {
-/* scale coord to length */
-coord = lp_build_mul(coord_bld, coord, length_f);
- }
- /* was: clamp to [-0.5, length + 0.5], then sub 0.5 */
- coord = lp_build_sub(coord_bld, coord, half);
- min = lp_build_const_vec(bld-gallivm, coord_bld-type, -1.0F);
- coord = lp_build_clamp(coord_bld, coord, min, length_f);
- /* convert to int, compute lerp weight */
- lp_build_ifloor_fract(coord_bld, coord, coord0, weight);
- coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld-one);
+  if (bld-static_state-normalized_coords) {
+ /* scale coord to length */
+ coord = lp_build_mul(coord_bld, coord, length_f);
   }
+  /* was: clamp to [-0.5, length + 0.5], then sub 0.5 */
+  /* can skip clamp (though might not work for very large coord values */
+  coord = lp_build_sub(coord_bld, coord, half);
+  /* convert to int, compute lerp weight */
+  lp_build_ifloor_fract(coord_bld, coord, coord0, weight);
+  coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld-one);
   break;
 
case PIPE_TEX_WRAP_MIRROR_REPEAT:
@@ -438,9 +434,9 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context 
*bld,
  }
 
  /* was: clamp to [-0.5, length + 0.5] then sub 0.5 */
- /* skip -0.5 clamp (always positive), do sub first */
+ /* skip clamp - always positive, and other side
+only potentially matters for very large coords */
  coord = lp_build_sub(coord_bld, coord, half);
- coord = lp_build_min(coord_bld, coord, length_f);
 
  /* convert to int, compute lerp weight */
  lp_build_ifloor_fract(coord_bld, coord, coord0, weight);
@@ -514,22 +510,12 @@ lp_build_sample_wrap_nearest(struct 
lp_build_sample_context *bld,
   break;
 
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
-  /* Note: this is the same as CLAMP_TO_EDGE, except min = -1 */
-  {
- LLVMValueRef min, max;
-
- if (bld-static_state-normalized_coords) {
-/* scale coord to length */
-coord = lp_build_mul(coord_bld, coord, length_f);
- }
-
- icoord = lp_build_ifloor(coord_bld, coord);
-
- /* clamp to [-1, length] */
- min = lp_build_negate(int_coord_bld, int_coord_bld-one);
- max = length;
- icoord = lp_build_clamp(int_coord_bld, icoord, min, max);
+  if (bld-static_state-normalized_coords) {
+ /* scale coord to length */
+ coord = lp_build_mul(coord_bld, coord, length_f);
   }
+  /* no clamp necessary, border masking will handle this */
+  icoord = lp_build_ifloor(coord_bld, coord);
   break;
 
case PIPE_TEX_WRAP_MIRROR_REPEAT:
@@ -573,9 +559,6 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context 
*bld,
 
   /* itrunc == ifloor here */
   icoord = lp_build_itrunc(coord_bld, coord);
-
-  /* clamp to [0, length] */
-  icoord = lp_build_min(int_coord_bld, icoord, length);
   break;
 
default:
-- 
1.7.9.5

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


[Mesa-dev] [PATCH] glsl/parser: Handle #version 300 es directive.

2012-11-30 Thread Ian Romanick
From: Paul Berry stereotype...@gmail.com

Note that GLSL 1.00 is selected using #version 100, so #version 100
es is prohibited.

v2: Check for GLES3 before allowing '#version 300 es'

v3: Make sure a correct language_version is set in
_mesa_glsl_parse_state::process_version_directive.

Signed-off-by: Paul Berry stereotype...@gmail.com
Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
This fixes the invalid-version.vert recently posted to the piglit
mailing list.  A later patch adds (valid) assertions in
_mesa_glsl_parse_state::process_version_directive that fail if
language_version is bogus.  I plan to post some unit tests for
_mesa_glsl_parse_state::process_version_directive shortly.

 src/glsl/glsl_parser.yy |   6 ++-
 src/glsl/glsl_parser_extras.cpp | 105 ++--
 src/glsl/glsl_parser_extras.h   |   3 +-
 3 files changed, 86 insertions(+), 28 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index b15e1d1..d938765 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -261,8 +261,12 @@ version_statement:
/* blank - no #version specified: defaults are already set */
| VERSION_TOK INTCONSTANT EOL
{
-   state-process_version_directive(@2, $2);
+   state-process_version_directive(@2, $2, NULL);
}
+| VERSION_TOK INTCONSTANT any_identifier EOL
+{
+   state-process_version_directive(@2, $2, $3);
+}
;
 
 pragma_statement:
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index cc33a07..9efeb12 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -178,38 +178,72 @@ _mesa_glsl_parse_state::check_version(unsigned 
required_glsl_version,
  * Process a GLSL #version directive.
  *
  * \param version is the integer that follows the #version token.
+ *
+ * \param ident is a string identifier that follows the integer, if any is
+ * present.  Otherwise NULL.
  */
 void
-_mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version)
+_mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
+  const char *ident)
 {
+   bool es_token_present = false;
+   if (ident) {
+  if (strcmp(ident, es) == 0) {
+ es_token_present = true;
+  } else {
+ _mesa_glsl_error(locp, this,
+  Illegal text following version number\n);
+  }
+   }
+
bool supported = false;
 
-   switch (version) {
-   case 100:
+   if (es_token_present) {
   this-es_shader = true;
-  supported = this-ctx-API == API_OPENGLES2 ||
- this-ctx-Extensions.ARB_ES2_compatibility;
-  break;
-   case 110:
-   case 120:
-  /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
-   * the OpenGL 3.2 Core context is supported, this logic will need
-   * change.  Older versions of GLSL are no longer supported
-   * outside the compatibility contexts of 3.x.
-   */
-   case 130:
-   case 140:
-   case 150:
-   case 330:
-   case 400:
-   case 410:
-   case 420:
-  supported = _mesa_is_desktop_gl(this-ctx) 
- ((unsigned) version) = this-ctx-Const.GLSLVersion;
-  break;
-   default:
-  supported = false;
-  break;
+  switch (version) {
+  case 100:
+ _mesa_glsl_error(locp, this,
+  GLSL 1.00 ES should be selected using 
+  `#version 100'\n);
+ supported = this-ctx-API == API_OPENGLES2 ||
+this-ctx-Extensions.ARB_ES2_compatibility;
+ break;
+  case 300:
+ supported = _mesa_is_gles3(this-ctx) ||
+   this-ctx-Extensions.ARB_ES3_compatibility;
+ break;
+  default:
+ supported = false;
+ break;
+  }
+   } else {
+  switch (version) {
+  case 100:
+ this-es_shader = true;
+ supported = this-ctx-API == API_OPENGLES2 ||
+this-ctx-Extensions.ARB_ES2_compatibility;
+ break;
+  case 110:
+  case 120:
+ /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
+  * the OpenGL 3.2 Core context is supported, this logic will need
+  * change.  Older versions of GLSL are no longer supported
+  * outside the compatibility contexts of 3.x.
+  */
+  case 130:
+  case 140:
+  case 150:
+  case 330:
+  case 400:
+  case 410:
+  case 420:
+ supported = _mesa_is_desktop_gl(this-ctx) 
+((unsigned) version) = this-ctx-Const.GLSLVersion;
+ break;
+  default:
+ supported = false;
+ break;
+  }
}
 
this-language_version = version;
@@ -219,6 +253,25 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE 
*locp, int version)
Supported versions are: %s\n,
this-get_version_string(),
   

Re: [Mesa-dev] [PATCH] mesa: Use _mesa_lookup_enum_by_nr in tex*_error_check

2012-11-30 Thread Brian Paul

On 11/30/2012 12:26 PM, Matt Turner wrote:

---
  src/mesa/main/teximage.c |9 ++---
  1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 347b3e2..6401824 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1949,7 +1949,8 @@ texture_error_check( struct gl_context *ctx,
 if (err != GL_NO_ERROR) {
_mesa_error(ctx, err,
glTexImage%dD(incompatible format 0x%x, type 0x%x),
-  dimensions, format, type);
+  dimensions, _mesa_lookup_enum_by_nr(format),
+ _mesa_lookup_enum_by_nr(type));
return GL_TRUE;
 }

@@ -1962,7 +1963,8 @@ texture_error_check( struct gl_context *ctx,
 (_mesa_is_dudv_format(internalFormat) != 
_mesa_is_dudv_format(format))) {
_mesa_error(ctx, GL_INVALID_OPERATION,
glTexImage%dD(incompatible internalFormat 0x%x, format 
0x%x),
-  dimensions, internalFormat, format);
+  dimensions, _mesa_lookup_enum_by_nr(internalFormat),
+ _mesa_lookup_enum_by_nr(format));
return GL_TRUE;
 }

@@ -2265,7 +2267,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
dimensions,
 if (err != GL_NO_ERROR) {
_mesa_error(ctx, err,
glTexSubImage%dD(incompatible format 0x%x, type 0x%x),
-  dimensions, format, type);
+  dimensions, _mesa_lookup_enum_by_nr(format),
+ _mesa_lookup_enum_by_nr(type));
return GL_TRUE;
 }



Reviewed-by: Brian Paul bri...@vmware.com

BTW, I think we were interested in renaming _mesa_lookup_enum_by_nr() 
to something nicer a while back.

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


Re: [Mesa-dev] [PATCH 01/26] mesa: Add ARB_ES3_compatibility flag.

2012-11-30 Thread Ian Romanick
This represents a rebase of the gles3 branch that moves the completed 
GLSL to be first.  I'd like to get these bits merged to master sooner 
rather than later.  Once these bits land, I'll rebase and send out the 
next logical block.


I have also pushed this branch to the gles3 branch of my personal GIT 
repo on fd.o.  Could people working on the gles3 branch take a look to 
make sure no work got lost?  I'd like to force-push this to origin/gles3 
today.


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


Re: [Mesa-dev] Proposal: allow hidden security bugs on Mesa's Bugzilla

2012-11-30 Thread Benoit Jacob
On 12-11-30 12:13 PM, Jerome Glisse wrote:
 On Fri, Nov 30, 2012 at 7:43 AM, Benoit Jacob bja...@mozilla.com wrote:
 On 12-11-23 02:21 PM, Benoit Jacob wrote:
 On 12-11-21 12:48 PM, Chad Versace wrote:
 On 11/20/2012 09:29 AM, Benoit Jacob wrote:

 Any questions?
 Do you support or oppose me asking FD.o admins to allow hidden bugs on
 Mesa's bugzilla?

 Benoit
 I support this. It seems a sensible proposal for addressing security bugs.

 Thanks. I have just sent the request to FD.o admins.

 Benoit
 This option is now turned on on Bugzilla.

 See the new checkbox: Mesa Security Group

 Thanks!
 Benoit

 How does one get into the security group ?

Don't ask me --- obviously I amn't part of it. I suppose you should have
that conversation among core Mesa developers and FD.o admins.

Benoit


 Cheers,
 Jerome

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


[Mesa-dev] [PATCH 1/6] i965/vs: Fix uninitialized shader pointer used in debug output.

2012-11-30 Thread Eric Anholt
---
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index 12694e2..5637b22 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -141,6 +141,8 @@ vec4_generator::vec4_generator(struct brw_context *brw,
intel = brw-intel;
vp = c-vp-program;
 
+   shader = prog ? prog-_LinkedShaders[MESA_SHADER_VERTEX] : NULL;
+
p = rzalloc(mem_ctx, struct brw_compile);
brw_init_compile(brw, p, mem_ctx);
 }
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 3/6] i965: Don't leak the IR annotation into later instructions.

2012-11-30 Thread Eric Anholt
After walking our IR instructions (Mesa or GLSL), we don't want to also
mark the start of the FB/URB writes or whatever as being that IR.  This
can end up being misleading when the end of the IR visit got copy
propagated out to a later instruction in the URB writes.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp   |1 +
 src/mesa/drivers/dri/i965/brw_vec4.cpp |1 +
 2 files changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index ee3b7fd..b777172 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2158,6 +2158,7 @@ fs_visitor::run()
   } else {
  emit_fragment_program_code();
   }
+  base_ir = NULL;
   if (failed)
 return false;
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 34c34d7..1a199d6 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1052,6 +1052,7 @@ vec4_visitor::run()
} else {
   emit_vertex_program_code();
}
+   base_ir = NULL;
 
if (c-key.userclip_active  !c-key.uses_clip_distance)
   setup_uniform_clipplane_values();
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 2/6] i965/vp: Fix crashes with INTEL_DEBUG=vs.

2012-11-30 Thread Eric Anholt
The VP generation doesn't set up the output reg strings, so if you
didn't happen to get these values as 0 on the stack, you'd lose.
---
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index aaf932f..544974a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2824,6 +2824,7 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
 
this-base_ir = NULL;
this-current_annotation = NULL;
+   memset(this-output_reg_annotation, 0, sizeof(this-output_reg_annotation));
 
this-c = c;
this-vp = c-vp-program;
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 4/6] i965: Include codegen time in the INTEL_DEBUG=perf stall detection.

2012-11-30 Thread Eric Anholt
In the VS case, we were missing the entire compile time in the stall
detection!
---
 src/mesa/drivers/dri/i965/brw_fs.cpp   |9 ++---
 src/mesa/drivers/dri/i965/brw_vec4.cpp |   21 -
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index b777172..e143e7a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2287,6 +2287,11 @@ brw_wm_fs_emit(struct brw_context *brw, struct 
brw_wm_compile *c,
 
c-prog_data.dispatch_width = 8;
 
+   fs_generator g(brw, c, prog, fp, v.dual_src_output.file != BAD_FILE);
+   const unsigned *generated = g.generate_assembly(v.instructions,
+   simd16_instructions,
+   final_assembly_size);
+
if (unlikely(INTEL_DEBUG  DEBUG_PERF)  shader) {
   if (shader-compiled_once)
  brw_wm_debug_recompile(brw, prog, c-key);
@@ -2298,9 +2303,7 @@ brw_wm_fs_emit(struct brw_context *brw, struct 
brw_wm_compile *c,
   }
}
 
-   fs_generator g(brw, c, prog, fp, v.dual_src_output.file != BAD_FILE);
-   return g.generate_assembly(v.instructions, simd16_instructions,
-  final_assembly_size);
+   return generated;
 }
 
 bool
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 1a199d6..5200daa 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1159,6 +1159,17 @@ brw_vs_emit(struct brw_context *brw,
   }
}
 
+   vec4_visitor v(brw, c, prog, shader, mem_ctx);
+   if (!v.run()) {
+  prog-LinkStatus = false;
+  ralloc_strcat(prog-InfoLog, v.fail_msg);
+  return NULL;
+   }
+
+   vec4_generator g(brw, c, prog, mem_ctx);
+   const unsigned *generated =g.generate_assembly(v.instructions,
+  final_assembly_size);
+
if (unlikely(INTEL_DEBUG  DEBUG_PERF)  shader) {
   if (shader-compiled_once) {
  brw_vs_debug_recompile(brw, prog, c-key);
@@ -1170,15 +1181,7 @@ brw_vs_emit(struct brw_context *brw,
   shader-compiled_once = true;
}
 
-   vec4_visitor v(brw, c, prog, shader, mem_ctx);
-   if (!v.run()) {
-  prog-LinkStatus = false;
-  ralloc_strcat(prog-InfoLog, v.fail_msg);
-  return NULL;
-   }
-
-   vec4_generator g(brw, c, prog, mem_ctx);
-   return g.generate_assembly(v.instructions, final_assembly_size);
+   return generated;
 }
 
 } /* extern C */
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 5/6] i965: Add a flag for instructions with normal writemasking disabled.

2012-11-30 Thread Eric Anholt
For getting values from the new timestamp register, the channels we
load have nothing to do with the pixels dispatched.
---
 src/mesa/drivers/dri/i965/brw_fs.h  |1 +
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp   |1 +
 src/mesa/drivers/dri/i965/brw_vec4.h|1 +
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |1 +
 4 files changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 86c33bc..dc85592 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -172,6 +172,7 @@ public:
bool shadow_compare;
bool force_uncompressed;
bool force_sechalf;
+   bool force_writemask_all;
uint32_t offset; /* spill/unspill offset */
 
/** @{
diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
index 9a1f360..498b720 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
@@ -829,6 +829,7 @@ fs_generator::generate_code(exec_list *instructions)
   brw_set_predicate_control(p, inst-predicate);
   brw_set_predicate_inverse(p, inst-predicate_inverse);
   brw_set_saturate(p, inst-saturate);
+  brw_set_mask_control(p, inst-force_writemask_all);
 
   if (inst-force_uncompressed || dispatch_width == 8) {
 brw_set_compression_control(p, BRW_COMPRESSION_NONE);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index d060941..8c6f56a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -171,6 +171,7 @@ public:
src_reg src[3];
 
bool saturate;
+   bool force_writemask_all;
 
int conditional_mod; /** BRW_CONDITIONAL_* */
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index 5637b22..b8a1b59 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -721,6 +721,7 @@ vec4_generator::generate_code(exec_list *instructions)
   brw_set_predicate_control(p, inst-predicate);
   brw_set_predicate_inverse(p, inst-predicate_inverse);
   brw_set_saturate(p, inst-saturate);
+  brw_set_mask_control(p, inst-force_writemask_all);
 
   switch (inst-opcode) {
   case BRW_OPCODE_MOV:
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 6/6] i965: Add a debug flag for counting cycles spent in each compiled shader.

2012-11-30 Thread Eric Anholt
This can be used for two purposes: Using hand-coded shaders to determine
per-instruction timings, or figuring out which shader to optimize in a
whole application.  On the psychonauts trace, we see:

type   ID  cycles spent   % of total
...
fs16  543: 339343898369 ( 339.34 Gcycles)   9.2%
fs16  521: 532215110990 ( 532.22 Gcycles)  14.4%
fs16  524:1036231987390 (1036.23 Gcycles)  28.0%

confirming our previous understanding that fragment shaders are where
it's all at.  But on GLBenchmark 2.7, we get:

fs16   69: 205928219888 ( 205.93 Gcycles)   7.5%
fs16   75: 364066413095 ( 364.07 Gcycles)  13.2%
vs 87:1107217698878 (1107.22 Gcycles)  40.3%

That's interesting.  I should look into that.

Note that this doesn't cover the instructions that set up the message to
the URB/FB write -- we'd need to convert the MRF usage in these
instructions to GRFs so that our offsets/times don't overwrite our
shader outputs.
---
 src/mesa/drivers/dri/i965/brw_context.c  |3 +
 src/mesa/drivers/dri/i965/brw_context.h  |   28 -
 src/mesa/drivers/dri/i965/brw_defines.h  |   20 +++-
 src/mesa/drivers/dri/i965/brw_eu.h   |6 +-
 src/mesa/drivers/dri/i965/brw_eu_emit.c  |   55 +-
 src/mesa/drivers/dri/i965/brw_fs.cpp |  101 +
 src/mesa/drivers/dri/i965/brw_fs.h   |7 ++
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp|4 +
 src/mesa/drivers/dri/i965/brw_program.c  |  128 ++
 src/mesa/drivers/dri/i965/brw_vec4.cpp   |   81 ++
 src/mesa/drivers/dri/i965/brw_vec4.h |7 ++
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp  |4 +
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c |   10 ++
 src/mesa/drivers/dri/i965/brw_vtbl.c |   14 +++
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |7 ++
 src/mesa/drivers/dri/intel/intel_context.c   |6 +
 src/mesa/drivers/dri/intel/intel_context.h   |1 +
 17 files changed, 475 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 4b1b247..5665a3a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -383,6 +383,9 @@ brwCreateContext(int api,
 
brw_fs_alloc_reg_sets(brw);
 
+   if (INTEL_DEBUG  DEBUG_SHADER_TIME)
+  brw_init_shader_time(brw);
+
return true;
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 1abaee3..dc25cab 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -559,14 +559,15 @@ struct brw_vs_prog_data {
 #define SURF_INDEX_FRAG_CONST_BUFFER (BRW_MAX_DRAW_BUFFERS + 1)
 #define SURF_INDEX_TEXTURE(t)(BRW_MAX_DRAW_BUFFERS + 2 + (t))
 #define SURF_INDEX_WM_UBO(u) (SURF_INDEX_TEXTURE(BRW_MAX_TEX_UNIT) + u)
-
+#define SURF_INDEX_WM_SHADER_TIME(SURF_INDEX_WM_UBO(12))
 /** Maximum size of the binding table. */
-#define BRW_MAX_WM_SURFACES  SURF_INDEX_WM_UBO(BRW_MAX_WM_UBOS)
+#define BRW_MAX_WM_SURFACES  (SURF_INDEX_WM_SHADER_TIME + 1)
 
 #define SURF_INDEX_VERT_CONST_BUFFER (0)
 #define SURF_INDEX_VS_TEXTURE(t) (SURF_INDEX_VERT_CONST_BUFFER + 1 + (t))
 #define SURF_INDEX_VS_UBO(u) (SURF_INDEX_VS_TEXTURE(BRW_MAX_TEX_UNIT) 
+ u)
-#define BRW_MAX_VS_SURFACES  SURF_INDEX_VS_UBO(BRW_MAX_VS_UBOS)
+#define SURF_INDEX_VS_SHADER_TIME(SURF_INDEX_VS_UBO(12))
+#define BRW_MAX_VS_SURFACES  (SURF_INDEX_VS_SHADER_TIME + 1)
 
 #define SURF_INDEX_SOL_BINDING(t)((t))
 #define BRW_MAX_GS_SURFACES  
SURF_INDEX_SOL_BINDING(BRW_MAX_SOL_BINDINGS)
@@ -651,6 +652,13 @@ struct brw_tracked_state {
void (*emit)( struct brw_context *brw );
 };
 
+enum shader_time_shader_type {
+   ST_NONE,
+   ST_VS,
+   ST_FS8,
+   ST_FS16,
+};
+
 /* Flags for brw-state.cache.
  */
 #define CACHE_NEW_BLEND_STATE(1BRW_BLEND_STATE)
@@ -1089,6 +1097,16 @@ struct brw_context
 
uint32_t num_instances;
int basevertex;
+
+   struct {
+  drm_intel_bo *bo;
+  struct gl_shader_program **programs;
+  enum shader_time_shader_type *types;
+  uint64_t *cumulative;
+  int num_entries;
+  int max_entries;
+  double report_time;
+   } shader_time;
 };
 
 /*==
@@ -1144,7 +1162,9 @@ void brwInitFragProgFuncs( struct dd_function_table 
*functions );
 int brw_get_scratch_size(int size);
 void brw_get_scratch_bo(struct intel_context *intel,
drm_intel_bo **scratch_bo, int size);
-
+void brw_init_shader_time(struct brw_context *brw);
+void brw_collect_and_report_shader_time(struct brw_context *brw);
+void brw_destroy_shader_time(struct brw_context *brw);
 
 /* brw_urb.c
  */
diff --git a/src/mesa/drivers/dri/i965/brw_defines.h 

Re: [Mesa-dev] [PATCH 1/2] llvmpipe: Recompute the fs shader key when framebuffer varies.

2012-11-30 Thread Dave Airlie
On Sat, Dec 1, 2012 at 3:43 AM,  jfons...@vmware.com wrote:
 From: José Fonseca jfons...@vmware.com

 The fs shader now depends on the color buffer formats. The shader key was
 extended to accommodate this, but llvmpipe_update_derived needs to be
 updated to check the framebuffer dirty flag.

 This fixes bug 57674.

Looks good to me,

Reviewed-by: Dave Airlie airl...@redhat.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/26] mesa: Add ARB_ES3_compatibility flag.

2012-11-30 Thread Paul Berry
On 30 November 2012 12:11, Ian Romanick i...@freedesktop.org wrote:

 This represents a rebase of the gles3 branch that moves the completed GLSL
 to be first.  I'd like to get these bits merged to master sooner rather
 than later.  Once these bits land, I'll rebase and send out the next
 logical block.

 I have also pushed this branch to the gles3 branch of my personal GIT repo
 on fd.o.  Could people working on the gles3 branch take a look to make sure
 no work got lost?  I'd like to force-push this to origin/gles3 today.


FYI, I've pushed a minor rebase on that branch to gles3 on git://
github.com/stereotype441/mesa.git.  The only change is that I modified
patches mesa: Add new MESA_FORMATs for ETC2 compressed textures through
mesa: Add decoding functions for
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 to avoid some transient build
failures.  There's no diff between the tips of the branches.

Ian, feel free to push my rebase to fd.o (assuming no one finds other
problems).

Paul




 __**_
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/**mailman/listinfo/mesa-devhttp://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 57746] New: build test failure: nouveau_fbo.c:198:3: error: too few arguments to function 'nouveau_renderbuffer_del'

2012-11-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=57746

  Priority: medium
Bug ID: 57746
  Assignee: mesa-dev@lists.freedesktop.org
   Summary: build test failure:  nouveau_fbo.c:198:3: error: too
few arguments to function 'nouveau_renderbuffer_del'
  Severity: normal
Classification: Unclassified
OS: All
  Reporter: dar...@chaosreigns.com
  Hardware: Other
Status: NEW
   Version: git
 Component: Other
   Product: Mesa

c73245882c7ff1277b190b97f093f7b423a22f10 is the first bad commit (according to
git bisect run):

Author: Brian Paul bri...@vmware.com
Date:   Fri Nov 30 10:04:48 2012 -0700

mesa: pass context parameter to gl_renderbuffer::Delete()


Output I'm getting:

make[6]: Entering directory
`/home/darxus/source.test.master/mesa/src/mesa/drivers/dri/nouveau'
...
  CC nouveau_state.lo
nouveau_fbo.c: In function 'nouveau_renderbuffer_dri_new':
nouveau_fbo.c:198:3: warning: passing argument 1 of 'nouveau_renderbuffer_del'
from incompatible pointer type [enabled by default]
nouveau_fbo.c:105:1: note: expected 'struct gl_context *' but argument is of
type 'struct gl_renderbuffer *'
nouveau_fbo.c:198:3: error: too few arguments to function
'nouveau_renderbuffer_del'
nouveau_fbo.c:105:1: note: declared here


I am doing a git clean -xfd for each build.

Building with:  ./autogen.sh --prefix=$installdir --enable-gles2
--disable-gallium-egl --with-egl-platforms=wayland,x11,drm --enable-gbm
--enable-shared-glapi --with-gallium-drivers=r300,r600,swrast,nouveau,svga

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


[Mesa-dev] [Bug 57746] build test failure: nouveau_fbo.c:198:3: error: too few arguments to function 'nouveau_renderbuffer_del'

2012-11-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=57746

Darxus dar...@chaosreigns.com changed:

   What|Removed |Added

 CC||dar...@chaosreigns.com

-- 
You are receiving this mail because:
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] glsl/parser: Handle #version 300 es directive.

2012-11-30 Thread Paul Berry
On 30 November 2012 11:52, Ian Romanick i...@freedesktop.org wrote:

 From: Paul Berry stereotype...@gmail.com

 Note that GLSL 1.00 is selected using #version 100, so #version 100
 es is prohibited.

 v2: Check for GLES3 before allowing '#version 300 es'

 v3: Make sure a correct language_version is set in
 _mesa_glsl_parse_state::process_version_directive.

 Signed-off-by: Paul Berry stereotype...@gmail.com
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 ---
 This fixes the invalid-version.vert recently posted to the piglit
 mailing list.  A later patch adds (valid) assertions in
 _mesa_glsl_parse_state::process_version_directive that fail if
 language_version is bogus.  I plan to post some unit tests for
 _mesa_glsl_parse_state::process_version_directive shortly.


This fix looks good to me.



  src/glsl/glsl_parser.yy |   6 ++-
  src/glsl/glsl_parser_extras.cpp | 105
 ++--
  src/glsl/glsl_parser_extras.h   |   3 +-
  3 files changed, 86 insertions(+), 28 deletions(-)

 diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
 index b15e1d1..d938765 100644
 --- a/src/glsl/glsl_parser.yy
 +++ b/src/glsl/glsl_parser.yy
 @@ -261,8 +261,12 @@ version_statement:
 /* blank - no #version specified: defaults are already set */
 | VERSION_TOK INTCONSTANT EOL
 {
 -   state-process_version_directive(@2, $2);
 +   state-process_version_directive(@2, $2, NULL);
 }
 +| VERSION_TOK INTCONSTANT any_identifier EOL
 +{
 +   state-process_version_directive(@2, $2, $3);
 +}
 ;

  pragma_statement:
 diff --git a/src/glsl/glsl_parser_extras.cpp
 b/src/glsl/glsl_parser_extras.cpp
 index cc33a07..9efeb12 100644
 --- a/src/glsl/glsl_parser_extras.cpp
 +++ b/src/glsl/glsl_parser_extras.cpp
 @@ -178,38 +178,72 @@ _mesa_glsl_parse_state::check_version(unsigned
 required_glsl_version,
   * Process a GLSL #version directive.
   *
   * \param version is the integer that follows the #version token.
 + *
 + * \param ident is a string identifier that follows the integer, if any is
 + * present.  Otherwise NULL.
   */
  void
 -_mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int
 version)
 +_mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int
 version,
 +  const char *ident)
  {
 +   bool es_token_present = false;
 +   if (ident) {
 +  if (strcmp(ident, es) == 0) {
 + es_token_present = true;
 +  } else {
 + _mesa_glsl_error(locp, this,
 +  Illegal text following version number\n);
 +  }
 +   }
 +
 bool supported = false;

 -   switch (version) {
 -   case 100:
 +   if (es_token_present) {
this-es_shader = true;
 -  supported = this-ctx-API == API_OPENGLES2 ||
 - this-ctx-Extensions.ARB_ES2_compatibility;
 -  break;
 -   case 110:
 -   case 120:
 -  /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
 -   * the OpenGL 3.2 Core context is supported, this logic will need
 -   * change.  Older versions of GLSL are no longer supported
 -   * outside the compatibility contexts of 3.x.
 -   */
 -   case 130:
 -   case 140:
 -   case 150:
 -   case 330:
 -   case 400:
 -   case 410:
 -   case 420:
 -  supported = _mesa_is_desktop_gl(this-ctx) 
 - ((unsigned) version) = this-ctx-Const.GLSLVersion;
 -  break;
 -   default:
 -  supported = false;
 -  break;
 +  switch (version) {
 +  case 100:
 + _mesa_glsl_error(locp, this,
 +  GLSL 1.00 ES should be selected using 
 +  `#version 100'\n);
 + supported = this-ctx-API == API_OPENGLES2 ||
 +this-ctx-Extensions.ARB_ES2_compatibility;
 + break;
 +  case 300:
 + supported = _mesa_is_gles3(this-ctx) ||
 +   this-ctx-Extensions.ARB_ES3_compatibility;
 + break;
 +  default:
 + supported = false;
 + break;
 +  }
 +   } else {
 +  switch (version) {
 +  case 100:
 + this-es_shader = true;
 + supported = this-ctx-API == API_OPENGLES2 ||
 +this-ctx-Extensions.ARB_ES2_compatibility;
 + break;
 +  case 110:
 +  case 120:
 + /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
 +  * the OpenGL 3.2 Core context is supported, this logic will need
 +  * change.  Older versions of GLSL are no longer supported
 +  * outside the compatibility contexts of 3.x.
 +  */
 +  case 130:
 +  case 140:
 +  case 150:
 +  case 330:
 +  case 400:
 +  case 410:
 +  case 420:
 + supported = _mesa_is_desktop_gl(this-ctx) 
 +((unsigned) version) = this-ctx-Const.GLSLVersion;
 + break;
 +  default:
 + supported = false;
 + break;
 +  }
 }

 

Re: [Mesa-dev] [PATCH] glcpp: Rewrite line-continuation support to act globally.

2012-11-30 Thread Kenneth Graunke

On 11/29/2012 03:44 PM, Carl Worth wrote:

Previously, we were only supporting line-continuation backslash characters
within lines of pre-processor directives, (as per the specification). With
OpenGL 4.3, line continuations are now supported anywhere within a shader.


OpenGL 4.2, actually.

I'm also not sure if we decided we can get away with changing this 
behavior.  I'd really like to, as the new rules are much more sensible, 
consistent, and efficient...



While changing this, also fix a bug where the preprocessor was ignoring line
continuation characters when a line ended in multiple backslash characters.

The new code is also more efficient than the old. Previously, we would perform
a ralloc copy at each newline. We now perform copies only at each occurrence
of a line-continuation.
---
  src/glsl/glcpp/pp.c |  108 ---
  1 file changed, 42 insertions(+), 66 deletions(-)

diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c
index 11b2941..1135570 100644
--- a/src/glsl/glcpp/pp.c
+++ b/src/glsl/glcpp/pp.c
@@ -70,82 +70,58 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const 
char *fmt, ...)
 parser-info_log_length, \n);
  }

-/* Searches backwards for '^ *#' from a given starting point. */
-static int
-in_directive(const char *shader, const char *ptr)
-{
-   assert(ptr = shader);
-
-   /* Search backwards for '#'. If we find a \n first, it doesn't count */
-   for (; ptr = shader  *ptr != '#'; ptr--) {
-   if (*ptr == '\n')
-   return 0;
-   }
-   if (ptr = shader) {
-   /* Found '#'...look for spaces preceded by a newline */
-   for (ptr--; ptr = shader  isblank(*ptr); ptr--);
-   // FIXME: I don't think the '\n' case can happen
-   if (ptr  shader || *ptr == '\n')
-   return 1;
-   }
-   return 0;
-}
-
-/* Remove any line continuation characters in preprocessing directives.
- * However, ignore any in GLSL code, as There is no line continuation
- * character (1.30 page 9) in GLSL.
+/* Remove any line continuation characters in the shader, (whether in
+ * preprocessing directives or in GLSL code).
   */
  static char *
  remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
  {
-   int in_continued_line = 0;
-   int extra_newlines = 0;
char *clean = ralloc_strdup(ctx, );
-   const char *search_start = shader;
-   const char *newline;
-   while ((newline = strchr(search_start, '\n')) != NULL) {
-   const char *backslash = NULL;
-
-   /* # of characters preceding the newline. */
-   int n = newline - shader;
-
-   /* Find the preceding '\', if it exists */
-   if (n = 1  newline[-1] == '\\')
-   backslash = newline - 1;
-   else if (n = 2  newline[-1] == '\r'  newline[-2] == '\\')
-   backslash = newline - 2;
-
-   /* Double backslashes don't count (the backslash is escaped) */
-   if (backslash != NULL  backslash[-1] == '\\') {
-   backslash = NULL;
-   }
-
-   if (backslash != NULL) {
-   /* We found a line continuation, but do we care? */
-   if (!in_continued_line) {
-   if (in_directive(shader, backslash)) {
-   in_continued_line = 1;
-   extra_newlines = 0;
-   }
-   }
-   if (in_continued_line) {
-   /* Copy everything before the \ */
-   ralloc_strncat(clean, shader, backslash - 
shader);
+   const char *backslash, *newline;
+   int collapsed_newlines = 0;
+
+   while (1) {


while (true) ?


+   backslash = strchr(shader, '\\');
+
+   /* If we have previously collapsed any
+* line-continuations, then we want to insert
+* additional newlines at the next occurrence of a
+* newline character to avoid changing any line
+* numbers. */


Please move the */ to its own line.  I'd also wrap the lines later 
(78-ish?), but that's just me...



+   if (collapsed_newlines) {
+   newline = strchr(shader, '\n');
+   if (newline 
+   (backslash == NULL || newline  backslash))
+   {
+   ralloc_strncat(clean, shader,
+  newline - shader + 1);
+   while (collapsed_newlines--)
+   ralloc_strcat(clean, \n);
shader = newline + 1;
-   

Re: [Mesa-dev] [PATCH 2/4] glx/dri2: add and use new driver hook flush_with_flags

2012-11-30 Thread Eric Anholt
The mixing of the factoring out of the protocol bits with the flush
change in this commit is irritating, but I'm fine with the overall flush
interface of this series for the current loader implementation.

Long term, I think for what you're working towards you'll want the
dispatch threading that Paul has been working on, and dri.next for
communicating swaps to the server, then push the whole swapbuffers
request out of the loader and into that thread.  At that point, all this
flush interface would be replaced with the swap request to the driver.


pgpD6jbBNv52V.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


  1   2   >