[Mesa-dev] [Bug 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

Karl Tomlinson bugs.freedesk...@karlt.net changed:

   What|Removed |Added

 CC||bugs.freedesk...@karlt.net

--- Comment #7 from Karl Tomlinson bugs.freedesk...@karlt.net 2011-06-14 
23:09:11 PDT ---
Yes, sorry, there are probably a few confounding issues in the one bug report.

Refer to https://bugzilla.mozilla.org/show_bug.cgi?id=659842#c3 for glxinfo in
the configuration involved here.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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 37476] [wine] Devil May Cry 4: TXD tgsi opcode unsupported / translation from TGSI failed / missing vertex shader

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=37476

--- Comment #4 from Dave Airlie airl...@freedesktop.org 2011-06-14 23:58:39 
PDT ---
Hi Mike,

you might have noticed I pushed something that worked, then found this patch,
which I preferred to mine, so I fixed up the code with your authorship on a few
patches derived from this.

Please test and let me know if it works for you, as I have a few differences
from your code.

Dave.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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] i965/gen5, 6: Fix hang when emitting hiz buffer without stencil buffer

2011-06-15 Thread Kenneth Graunke

On 06/14/2011 03:28 PM, Chad Versace wrote:
[snip]

@@ -355,26 +355,48 @@ static void emit_depthbuffer(struct brw_context *brw)
ADVANCE_BATCH();
 }

-   /* Emit hiz buffer. */
 if (hiz_region || stencil_irb) {
-  BEGIN_BATCH(3);
-  OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER  16) | (3 - 2));
-  OUT_BATCH(hiz_region-pitch * hiz_region-cpp - 1);
-  OUT_RELOC(hiz_region-buffer,
-   I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-   0);
-  ADVANCE_BATCH();
-   }
+  /*
+   * In the 3DSTATE_DEPTH_BUFFER batch emitted above, the 'separate
+   * stencil enable' and 'hiz enable' bits were set. Therefore we must
+   * emit 3DSTATE_HIER_DEPTH_BUFFER and 3DSTATE_STENCIL_BUFFER. Even if
+   * there is no stencil buffer, 3DSTATE_STENCIL_BUFFER must be emitted;
+   * failure to do so causes hangs on gen5.
+   */


Extra indentation here?

Otherwise, yes, please :)

Reviewed-by: Kenneth Graunke kenn...@whitecape.org

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


[Mesa-dev] [PATCH 0/9] glsl: Miscellaneous GLSL 1.30 uint/uvec fixes.

2011-06-15 Thread Kenneth Graunke
Today I attempted to run some closed source GLSL 1.30 texturing tests
we have lying around.  I spent the rest of the day fixing unsigned
integer support in our compiler.  Never did get the tests running.

There are more bugs.  But this squashes quite a few of them. :)

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


[Mesa-dev] [PATCH 6/9] glsl: Find the closest signature when there are multiple matches.

2011-06-15 Thread Kenneth Graunke
Previously, ir_function::matching_signature had a fatal bug: if a
function had more than one non-exact match, it would simply return NULL.

This occured, for example, when looking for max(uvec3, uvec3):
- max(vec3, vec3)   - score 1 (found first)
- max(ivec3, ivec3) - score 1 (found second...used to return NULL here)
- max(uvec3, uvec3) - score 0 (exact match...the right answer)

This did not occur for max(ivec3, ivec3) since the second match found
was an exact match.

The new behavior is to return a match with the lowest score.  If there
is an exact match, that will be returned.  Otherwise, a match with the
least number of implicit conversions is chosen.

Fixes piglit test max-uvec3.vert.

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/glsl/ir_function.cpp |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp
index caee929..ef8d4fc 100644
--- a/src/glsl/ir_function.cpp
+++ b/src/glsl/ir_function.cpp
@@ -165,6 +165,7 @@ ir_function_signature *
 ir_function::matching_signature(const exec_list *actual_parameters)
 {
ir_function_signature *match = NULL;
+   int matched_score;
 
foreach_iter(exec_list_iterator, iter, signatures) {
   ir_function_signature *const sig =
@@ -173,14 +174,14 @@ ir_function::matching_signature(const exec_list 
*actual_parameters)
   const int score = parameter_lists_match( sig-parameters,
  actual_parameters);
 
+  /* If we found an exact match, simply return it */
   if (score == 0)
 return sig;
 
-  if (score  0) {
-if (match != NULL)
-   return NULL;
-
+  /* If we found a match with fewer conversions, use that instead */
+  if (score  0  (match == NULL || score  matched_score)) {
 match = sig;
+matched_score = score;
   }
}
 
-- 
1.7.5.4

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


[Mesa-dev] [PATCH 8/8] i965: Enable extension GL_ARB_shader_texture_lod.

2011-06-15 Thread Kenneth Graunke
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=36987

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/drivers/dri/intel/intel_extensions.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c 
b/src/mesa/drivers/dri/intel/intel_extensions.c
index 3fd987a..64c996c 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -172,6 +172,7 @@ static const struct dri_extension brw_extensions[] = {
{ GL_ARB_occlusion_query,GL_ARB_occlusion_query_functions },
{ GL_ARB_point_sprite,  NULL },
{ GL_ARB_seamless_cube_map,  NULL },
+   { GL_ARB_shader_texture_lod, NULL },
{ GL_ARB_shadow, NULL },
 #ifdef TEXTURE_FLOAT_ENABLED
{ GL_ARB_texture_float,  NULL },
-- 
1.7.5.4

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


[Mesa-dev] A gallium XA state tracker

2011-06-15 Thread Thomas Hellstrom

Hi!

I just pushed an initial commit of an X Acceleration state tracker to 
the xa_branch.


The idea is that in the long run it will be replacing the Xorg state 
tracker, which can then move back to a modular xf86-video-modesetting. 
It will also be responsible for the acceleration part of an updated 
vmwgfx X driver


From the README:

8--
The XA state tracker is intended as a versioned interface to gallium for
xorg driver writers. Initially it's mostly based on Zack Rusin's
composite / video work for the Xorg state tracker.

The motivation behind this state tracker is that the Xorg state tracker has
a number of interfaces to work with:

1) The Xorg sdk (versioned)
2) Gallium3D (not versioned)
3) KMS modesetting (versioned)
4) Driver-private (hopefully versioned)

Since Gallium3D is versioned, the Xorg state tracker needs to be compiled
with Gallium, but it's really beneficial to be able to compile xorg drivers
standalone.

Therefore the xa state tracker is intended to supply the following
functionality:

1) Versioning.
2) Surface functionality (creation and copying for a basic dri2 
implementation)

3) YUV blits for textured Xv.

and coming up:
4) Solid fills with ROP functionality.
5) Copies with ROP functionality, format conversion and - reinterpretation.
6) Xrender- type compositing for general acceleration.

4-6 is not implemented yet since they are currently not directly used by the
vmwgfx driver.

The first user will be the vmwgfx xorg driver. When there are more users,
we need to be able to load the appropriate gallium pipe driver, and we
should investigate sharing the loadig mechanism with the EGL state tracker.

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


[Mesa-dev] [Bug 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

--- Comment #18 from Tony Mechelynck antoine.mechely...@gmail.com 2011-06-15 
08:08:45 PDT ---
Created an attachment (id=48001)
 -- (https://bugs.freedesktop.org/attachment.cgi?id=48001)
firefox.bin.trace

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

--- Comment #19 from Tony Mechelynck antoine.mechely...@gmail.com 2011-06-15 
08:10:04 PDT ---
Created an attachment (id=48002)
 -- (https://bugs.freedesktop.org/attachment.cgi?id=48002)
firefox-bin.1.trace

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

--- Comment #20 from Tony Mechelynck antoine.mechely...@gmail.com 2011-06-15 
08:11:48 PDT ---
Created an attachment (id=48003)
 -- (https://bugs.freedesktop.org/attachment.cgi?id=48003)
minefield.log

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

--- Comment #22 from Tony Mechelynck antoine.mechely...@gmail.com 2011-06-15 
08:21:35 PDT ---
(In reply to comment #16)
 Tony, if you have time, could you please try running firefox with apitrace as
 explained in comment 13?
 
 Note: you'll need to install cmake and you'll need to cd to the apitrace
 directory you just cloned before running cmake.
 
 Please use a debug build of Firefox for that, for example the latest build I
 made for you, as we need to see where that WARNING: Error resizing offscreen
 framebuffer -- framebuffer not complete was printed and it's only printed in
 debug builds. Please keep MOZ_X_SYNC=1 but no need for MOZ_GL_DEBUG_VERBOSE=1
 as apitrace replaces that.

(In reply to comment #13)
[...]
   git clone https://github.com/apitrace/apitrace.git
   cmake .
   make
   LD_PRELOAD=$PWD/glxtrace.so /path/to/firefox
 
 and firefox*.trace will be generated.

cmake 2.8.3-5.2 is already installed
git clone... cmake... make... done
LD_PRELOAD=$PWD/glxtrace.so MOZ_X_SYNC=1 ~/Minefield/firefox/firefox --sync -P
virgin -no-remote 21|tee ~/Minefield/minefield.log
...firefox opens
...look at a few tabs, they seem normal
...Ctrl+Q
...Breakpad comes up, a little comment, [ Quit Firefox ]
ls -l *.trace
-rw-r--r-- 1 root root 11131 Jun 15 16:53 firefox-bin.1.trace
-rw-r--r-- 1 root root  1179 Jun 15 16:50 firefox-bin.trace
ls -l ~/Minefield/minefield.log
-rw-r--r-- 1 root root 30450 Jun 15 16:53 minefield.log
ls -l ~/.mozilla/firefox/Crash\ Reports/submitted
...the oldest one is:
-rw-r--r-- 1 root root  50 Jun 15 16:53
bp-47314ac3-428f-4bab-af98-b88c12110615.txt
meaning that more info about the crash will be found at
https://crash-stats.mozilla.com/report/index/47314ac3-428f-4bab-af98-b88c12110615

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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] [PATCH 2/7] Add productions to GLSL grammar for switch statement

2011-06-15 Thread Dan McCabe
The grammar is modified to support switch statements. Rather than follow the
grammar in the appendix, which allows case labels to be placed ANYWHERE
as a regular statement, we follow the development of the grammar as
described in the body of the GLSL.

In this variation, the switch statement has a body which consists of a list
of case statements. A case statement is preceded by a list of case labels and
ends with a list of statements.
---
 src/glsl/glsl_parser.yy |   64 --
 1 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 2c0498e..b3727ce 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -206,6 +206,12 @@
 %type declaration struct_declarator_list
 %type node selection_statement
 %type selection_rest_statement selection_rest_statement
+%type node switch_statement
+%type node switch_body
+%type node case_label
+%type node case_label_list
+%type node case_statement
+%type node case_statement_list
 %type node iteration_statement
 %type node condition
 %type node conditionopt
@@ -1519,8 +1525,7 @@ simple_statement:
declaration_statement
| expression_statement
| selection_statement
-   | switch_statement  { $$ = NULL; }
-   | case_label{ $$ = NULL; }
+   | switch_statement
| iteration_statement
| jump_statement
;
@@ -1642,15 +1647,68 @@ condition:
}
;
 
+/*
+ * siwtch_statement grammar is based on the syntax described in the body
+ * of the GLSL spec, not in it's appendix!!!
+ */
 switch_statement:
-   SWITCH '(' expression ')' compound_statement
+   SWITCH '(' expression ')' switch_body
+   {
+  $$ = NULL;
+   }
+   ;
+
+switch_body:
+   '{' '}'
+   {
+  $$ = NULL;
+   }
+   | '{' case_statement_list '}'
+   {
+  $$ = NULL;
+   }
;
 
 case_label:
CASE expression ':'
+   {
+  $$ = NULL;
+   }
| DEFAULT ':'
+   {
+  $$ = NULL;
+   }
;
 
+case_label_list:
+   case_label
+   {
+  $$ = NULL;
+   }
+   | case_label_list case_label
+   {
+  $$ = NULL;
+   }
+   ;
+
+case_statement:
+   case_label_list statement_list
+   {
+  $$ = NULL;
+   }
+   ;
+
+case_statement_list:
+   case_statement
+   {
+  $$ = NULL;
+   }
+   | case_statement_list case_statement
+   {
+  $$ = NULL;
+   }
+   ;
+   
 iteration_statement:
WHILE '(' condition ')' statement_no_new_scope
{
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 3/7] Create AST structs corresping to new productions in grammar

2011-06-15 Thread Dan McCabe
Previously we added productions for:
switch_body
case_label_list
case_statement
case_statement_list
Now add AST structs corresponding to those productions.
---
 src/glsl/ast.h |   49 +
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 48d1795..626a8df 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -641,6 +641,55 @@ public:
 };
 
 
+class ast_case_label_list : public ast_node {
+public:
+   ast_case_label_list(void);
+   virtual void print(void) const;
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
+   exec_list labels;
+};
+
+
+class ast_case_statement : public ast_node {
+public:
+   ast_case_statement(ast_case_label_list *labels);
+   virtual void print(void) const;
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
+   ast_case_label_list *labels;
+   exec_list stmts;
+};
+
+
+class ast_case_statement_list : public ast_node {
+public:
+   ast_case_statement_list(void);
+   virtual void print(void) const;
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
+   exec_list cases;
+};
+
+
+class ast_switch_body : public ast_node {
+public:
+   ast_switch_body(ast_case_statement_list *stmts);
+   virtual void print(void) const;
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
+   ast_case_statement_list *stmts;
+};
+
+
 class ast_selection_statement : public ast_node {
 public:
ast_selection_statement(ast_expression *condition,
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 4/7] Reference data structure ctors in grammar

2011-06-15 Thread Dan McCabe
We now tie the grammar to the ctors of the ASTs they reference.

This requires that we actually have definitions of the ctors.

In addition, we also need to define print and hir methods for the AST
classes. At this stage of the development, we simply stub out the print
and hir methods and flesh them out later.

Also, since actual class instances get returned by the productions in the
grammar, we also need to designate the type of the productions that
reference those instances.
---
 src/glsl/ast_to_hir.cpp |   54 
 src/glsl/glsl_parser.yy |   58 ++
 src/glsl/glsl_parser_extras.cpp |   74 +++
 3 files changed, 170 insertions(+), 16 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 3b87f0d..553e459 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3274,6 +3274,60 @@ ast_selection_statement::hir(exec_list *instructions,
 }
 
 
+ir_rvalue *
+ast_switch_statement::hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+   // TODO - implement me!!!
+   return NULL;
+}
+
+
+ir_rvalue *
+ast_switch_body::hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+   // TODO - implement me!!!
+   return NULL;
+}
+
+
+ir_rvalue *
+ast_case_statement::hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+   // TODO - implement me!!!
+   return NULL;
+}
+
+
+ir_rvalue *
+ast_case_statement_list::hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+   // TODO - implement me!!!
+   return NULL;
+}
+
+
+ir_rvalue *
+ast_case_label::hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+   // TODO - implement me!!!
+   return NULL;
+}
+
+
+ir_rvalue *
+ast_case_label_list::hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+   // TODO - implement me!!!
+   return NULL;
+}
+
+
 void
 ast_iteration_statement::condition_to_hir(ir_loop *stmt,
  struct _mesa_glsl_parse_state *state)
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index b3727ce..3ba3282 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -67,6 +67,11 @@
ast_declarator_list *declarator_list;
ast_struct_specifier *struct_specifier;
ast_declaration *declaration;
+   ast_switch_body *switch_body;
+   ast_case_label *case_label;
+   ast_case_label_list *case_label_list;
+   ast_case_statement *case_statement;
+   ast_case_statement_list *case_statement_list;
 
struct {
   ast_node *cond;
@@ -207,11 +212,11 @@
 %type node selection_statement
 %type selection_rest_statement selection_rest_statement
 %type node switch_statement
-%type node switch_body
-%type node case_label
-%type node case_label_list
-%type node case_statement
-%type node case_statement_list
+%type switch_body switch_body
+%type case_label_list case_label_list
+%type case_label case_label
+%type case_statement case_statement
+%type case_statement_list case_statement_list
 %type node iteration_statement
 %type node condition
 %type node conditionopt
@@ -1654,58 +1659,79 @@ condition:
 switch_statement:
SWITCH '(' expression ')' switch_body
{
-  $$ = NULL;
+  void *ctx = state;
+  $$ = new(ctx) ast_switch_statement($3, $5);
}
;
 
 switch_body:
'{' '}'
{
-  $$ = NULL;
+  void *ctx = state;
+  $$ = new(ctx) ast_switch_body(NULL);
+  $$-set_location(yylloc);
}
| '{' case_statement_list '}'
{
-  $$ = NULL;
+  void *ctx = state;
+  $$ = new(ctx) ast_switch_body($2);
+  $$-set_location(yylloc);
}
;
 
 case_label:
CASE expression ':'
{
-  $$ = NULL;
+  $$ = new(state) ast_case_label($2);
}
| DEFAULT ':'
{
-  $$ = NULL;
+  $$ = new(state) ast_case_label(NULL);
}
;
 
 case_label_list:
case_label
{
-  $$ = NULL;
+  ast_case_label_list *labels = new(state) ast_case_label_list();
+
+  labels-labels.push_tail( $1-link);
+  $$ = labels;
}
| case_label_list case_label
{
-  $$ = NULL;
+  $$ = $1;
+  $$-labels.push_tail( $2-link);
}
;
 
 case_statement:
-   case_label_list statement_list
+   case_label_list statement
{
-  $$ = NULL;
+  ast_case_statement *stmts = new(state) ast_case_statement($1);
+
+  stmts-stmts.push_tail( $2-link);
+  $$ = stmts
+   }
+   | case_statement statement
+   {
+  $$ = $1;
+  $$-stmts.push_tail( $2-link);
}
;
 
 case_statement_list:
  

[Mesa-dev] [PATCH 5/7] Flesh out AST print methods

2011-06-15 Thread Dan McCabe
Pretty trivial stuff. Simply print the structure of the ASTs. No magic here.
---
 src/glsl/glsl_parser_extras.cpp |   38 --
 1 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index a351e12..f2ed518 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -695,7 +695,11 @@ 
ast_selection_statement::ast_selection_statement(ast_expression *condition,
 void
 ast_switch_statement::print(void) const
 {
-   printf(TODO - implement me!!!);
+   printf(switch ( );
+   test_expression-print();
+   printf() );
+
+   body-print();
 }
 
 
@@ -710,7 +714,11 @@ ast_switch_statement::ast_switch_statement(ast_expression 
*test_expression,
 void 
 ast_switch_body::print(void) const
 {
-   printf(TODO - implement me!!!);
+   printf({\n);
+   if (stmts != NULL) {
+  stmts-print();
+   }
+   printf(}\n);
 }
 
 
@@ -722,7 +730,13 @@ ast_switch_body::ast_switch_body(ast_case_statement_list 
*stmts)
 
 void ast_case_label::print(void) const
 {
-   printf(TODO - implement me!!!);
+   if (test_value != NULL) {
+  printf(case );
+  test_value-print();
+  printf(: );
+   } else {
+  printf(default: );
+   }
 }
 
 
@@ -734,7 +748,11 @@ ast_case_label::ast_case_label(ast_expression *test_value)
 
 void ast_case_label_list::print(void) const
 {
-   printf(TODO - implement me!!!);
+   foreach_list_const(n,  this-labels) {
+  ast_node *ast = exec_node_data(ast_node, n, link);
+  ast-print();
+   }
+   printf(\n);
 }
 
 
@@ -745,7 +763,12 @@ ast_case_label_list::ast_case_label_list(void)
 
 void ast_case_statement::print(void) const
 {
-   printf(TODO - implement me!!!);
+   labels-print();
+   foreach_list_const(n,  this-stmts) {
+  ast_node *ast = exec_node_data(ast_node, n, link);
+  ast-print();
+  printf(\n);
+   }
 }
 
 
@@ -757,7 +780,10 @@ ast_case_statement::ast_case_statement(ast_case_label_list 
*labels)
 
 void ast_case_statement_list::print(void) const
 {
-   printf(TODO - implement me!!!);
+   foreach_list_const(n,  this-cases) {
+  ast_node *ast = exec_node_data(ast_node, n, link);
+  ast-print();
+   }
 }
 
 
-- 
1.7.4.1

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


[Mesa-dev] [PATCH 6/7] Generate IR for switch statements

2011-06-15 Thread Dan McCabe
Beware! Here be dragons!

Up until now modyfing the GLSL compiler has been pretty straightforward.
This is where things get interesting.

Switch statement processing leverages infrastructure that was previously
created (specifically for break statements, which are encountered in both
loops and switch statements). Rather than generating new IR constructs,
which also requires creating new code generation and optimization, we take
advantage of the existing infrastructure and IR. Fortunately, the bread
crumbs that were left in the code from previous work suggested a solution
to processing switch statements.

The basic concept is that a switch statement generates a loop. The test
expression is evaluated and save in a temporary variable, which is used
for comparing the subsequent case labels. We also manage a fallthru state
that allows us to maintain the sequential semantics of the switch statement,
where cases fall through to the next case in the absence of a break statement.
The loop itself also has an explicit break instruction appended at the end
to force the termination of the loop (the subject of this commit).

Case labels and default cases manipulate the fallthru state. If a case label
equals the test expression, a fall through condition is encountered and the
fallthru state is set to true. Similarly, if a default case is encountered,
the fallthru state is set to true. Note that the fallthru state must be
initialized at the start of the switch statement (at the start of the loop)
to be false. Thereafter, the fallthru state will only ever monotonically
transition to true if a case is matched or if a default case is encountered.
It will never transition from true to false.

The statements associated with each case are then guarded by the fallthru
state. Only if the fallthru state is true do case statements get executed.

We will illustrate the analogous loop and conditional code that a switch
statement corresponds to by examining an example.

Consider the following switch statement:
switch (42) {
case 0:
case 1:
gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);
case 2:
case 3:
gl_FragColor = vec4(4.0, 3.0, 2.0, 1.0);
break;
case 4:
default:
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}

Note that case 0 and case 1 fall through to cases 2 and 3 if they occur.

Note that case 4 and the default case must be reached explicitly, since cases
2 and 3 break at the end of their case.

Finally, note that case 4 and the default case don't break but simply fall
through to the end of the switch.

For this code, the equivalent code can be expressed as:
do {
int test = 42; // capture test expression
bool fallthru = false; // prevent initial fall throughs

if (test == 0) // case 0
fallthru = true;
if (test == 1)  // case 1
fallthru = true;
if (fallthru) {
gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);
}

if (test == 2)  // case 2
fallthru = true;
if (test == 3) // case 3
fallthru = true;
if (fallthru) {
gl_FragColor = vec4(4.0, 3.0, 2.0, 1.0);
break; // most AST/IR processing previously in place
}

if (test == 4)  // case 4
fallthru = true;
fallthru = true; // default case
if (fallthru) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}

break; // implicit exit from loop at end of switch
} while (true);

Although we expressed our transformation into a do/while loop, we could
have used any other loop structure to explain the concept. However, we do
want to point out the existance of the last break statement which gets
implicitly generated to force loop termination at the end of the switch
statement.
---
 src/glsl/ast_to_hir.cpp |  227 +++
 src/glsl/glsl_parser_extras.cpp |3 +-
 src/glsl/glsl_parser_extras.h   |4 +-
 3 files changed, 184 insertions(+), 50 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 553e459..c409c2d 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3184,39 +3184,37 @@ ast_jump_statement::hir(exec_list *instructions,
 
case ast_break:
case ast_continue:
-  /* FINISHME: Handle switch-statements.  They cannot contain 'continue',
-   * FINISHME: and they use a different IR instruction for 'break'.
-   */
-  /* FINISHME: Correctly handle the nesting.  If a switch-statement is
-   * FINISHME: inside a loop, a 'continue' is valid and will bind to the
-   * FINISHME: loop.
-   */
-  if 

Re: [Mesa-dev] [PATCH 7/8] i965/fs: Add support for TXD with shadow comparisons on gen4-6.

2011-06-15 Thread Kenneth Graunke

On 06/15/2011 08:27 AM, Eric Anholt wrote:

On Wed, 15 Jun 2011 01:24:54 -0700, Kenneth Graunkekenn...@whitecape.org  
wrote:

Gen4-6 don't have a sample_d_c message, so we have to do a regular
sample_d and emit instructions to manually perform the comparison.

This requires a state dependent recompile whenever ctx-Depth.Func
changes.  do_wm_prog looks for a compiled program in the cache based off
of brw_wm_prog_key, and if it doesn't find one, recompiles.  So we
simply need to add the depth comparison function to the key; the
_NEW_DEPTH dirty bit was already in-place.



diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 03687ce..67344bd 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -744,7 +744,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, 
fs_reg coordinate,
 }
 mlen += ir-coordinate-type-vector_elements * reg_width;

-   if (ir-shadow_comparitor) {
+   if (ir-shadow_comparitor  ir-op != ir_txd) {
mlen = MAX2(mlen, header_present + 4 * reg_width);

this-result = reg_undef;
@@ -934,6 +934,21 @@ fs_visitor::visit(ir_texture *ir)
 int sampler = _mesa_get_sampler_uniform_value(ir-sampler, prog,fp-Base);
 sampler = fp-Base.SamplerUnits[sampler];

+   /* Pre-Ivybridge doesn't have a sample_d_c message, so shadow compares
+* for textureGrad/TXD need to be emulated with instructions.
+*/
+   bool hw_compare_supported = ir-op != ir_txd || intel-gen  7;
+   if (ir-shadow_comparitor  !hw_compare_supported) {
+  /* Mark that this program is only valid for the current glDepthFunc */
+  c-key.depth_compare_func = ctx-Depth.Func;


The compiler is only called if the key wasn't found in the cache, so you
can't set the key inside the compiler :)


You're right, of course.  Unfortunately, I really want to!  Only shaders 
using shadow2DGradARB need to be recompiled when glDepthFunc changes, so 
I really want to leave it as 0 for most shaders.  Otherwise the common 
case will have completely pointless recompiles.


Unfortunately, I only know whether or not I need it at compile time...

This -almost- works...it just means we'll recompile shaders using 
shadow2DGradARB every time, since they'll never be found in the cache. 
Stupid.  I'll reply with a patch which works around this.



+
+  /* No need to even sample for GL_ALWAYS or GL_NEVER...bail early */
+  if (ctx-Depth.Func == GL_ALWAYS)
+return swizzle_shadow_result(ir, fs_reg(1.0f), sampler);
+  else if (ctx-Depth.Func == GL_NEVER)
+return swizzle_shadow_result(ir, fs_reg(0.0f), sampler);
+   }


Generally I use c-key. values to make it obvious that state dependent
recompiles are in place, instead of ctx-.


Good idea.  Updated.


diff --git a/src/mesa/drivers/dri/i965/brw_wm.h 
b/src/mesa/drivers/dri/i965/brw_wm.h
index e244b55..0b284b6 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -67,6 +67,7 @@ struct brw_wm_prog_key {
 GLuint alpha_test:1;
 GLuint clamp_fragment_color:1;
 GLuint line_aa:2;
+   uint8_t depth_compare_func; /* 0 if irrelevant, GL_LESS etc. otherwise */


Wow, those do happen to fit in 8 bits.  Might comment that explicitly --
leaving out bits when storing GLenums has been a common bug and seeing
things like this make me paranoid and go check :)


:) Makes sense; commented.  I figured we really want to pack the key.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] :( fail. (i965 TXD state dependent recompiles)

2011-06-15 Thread Kenneth Graunke
On first compile...
- brw_prepare_wm_prog populates the key with depth_compare_func = 0
  and searches the cache.  No hit.
- It then sets depth_compare_func and searches the cache again.  No hit.
  (This is an additional cost.)
- It resets depth_compare_func to 0 and compiles.
- During compilation, emit_texture_gen5 will set key-depth_compare_func
  only if manual shadow comparisons are required (otherwise it stays 0).
- The newly compiled shader is added to the cache.

Subsequently...
- For most shaders:
  - brw_prepare_wm_prog searches the cache with depth_compare_func = 0.
The shader is immediately found (no additional cost).
- If manual compares are required:
  - brw_prepare_wm_prog searches the cache with depth_compare_func = 0.
No hit.  It then depth_compare_func and searches again.  If we've
seen this DepthFunc before, we find the shader.  Total cost is two
cache searches.  If we haven't seen DepthFunc before, compile.
---
 src/mesa/drivers/dri/i965/brw_wm.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 1aebd12..ffbc3b3 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -484,6 +484,14 @@ static void brw_prepare_wm_prog(struct brw_context *brw)
  key, sizeof(key),
  brw-wm.prog_data);
if (brw-wm.prog_bo == NULL) {
+  key-depth_compare_func = ctx-Depth.Func;
+  brw-wm.prog_bo = brw_search_cache(brw-cache, BRW_WM_PROG,
+key, sizeof(key),
+brw-wm.prog_data);
+   }
+
+   if (brw-wm.prog_bo == NULL) {
+  key-depth_compare_func = 0;
   bool success = do_wm_prog(brw, ctx-Shader.CurrentFragmentProgram, fp,
key);
   assert(success);
-- 
1.7.5.4

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


[Mesa-dev] line anti aliasing on r700 and r600

2011-06-15 Thread Jeffrey Collins

Does line anti aliasing work for r600 and r700 processors? It does not seem to 
change anything visually when I set PA_SC_AA_MASK.u32All, 
PA_SC_AA_SAMPLE_LOCS_MCTX.u32All, PA_SC_AA_SAMPLE_LOCS_8S_WD1_MCTX.u32All and 
PA_SC_AA_CONFIG.u32All to what would seem to be reasonable values in 
r700InitState.
Jeff Collins  ___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/8] i965/fs: Add support for TXD with shadow comparisons on gen4-6.

2011-06-15 Thread Ian Romanick
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 06/15/2011 11:00 AM, Kenneth Graunke wrote:
 On 06/15/2011 08:27 AM, Eric Anholt wrote:
 On Wed, 15 Jun 2011 01:24:54 -0700, Kenneth
 Graunkekenn...@whitecape.org  wrote:
 Gen4-6 don't have a sample_d_c message, so we have to do a regular
 sample_d and emit instructions to manually perform the comparison.

 This requires a state dependent recompile whenever ctx-Depth.Func
 changes.  do_wm_prog looks for a compiled program in the cache based off
 of brw_wm_prog_key, and if it doesn't find one, recompiles.  So we
 simply need to add the depth comparison function to the key; the
 _NEW_DEPTH dirty bit was already in-place.

 diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 index 03687ce..67344bd 100644
 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 @@ -744,7 +744,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir,
 fs_reg dst, fs_reg coordinate,
  }
  mlen += ir-coordinate-type-vector_elements * reg_width;

 -   if (ir-shadow_comparitor) {
 +   if (ir-shadow_comparitor  ir-op != ir_txd) {
 mlen = MAX2(mlen, header_present + 4 * reg_width);

 this-result = reg_undef;
 @@ -934,6 +934,21 @@ fs_visitor::visit(ir_texture *ir)
  int sampler = _mesa_get_sampler_uniform_value(ir-sampler,
 prog,fp-Base);
  sampler = fp-Base.SamplerUnits[sampler];

 +   /* Pre-Ivybridge doesn't have a sample_d_c message, so shadow
 compares
 +* for textureGrad/TXD need to be emulated with instructions.
 +*/
 +   bool hw_compare_supported = ir-op != ir_txd || intel-gen  7;
 +   if (ir-shadow_comparitor  !hw_compare_supported) {
 +  /* Mark that this program is only valid for the current
 glDepthFunc */
 +  c-key.depth_compare_func = ctx-Depth.Func;

 The compiler is only called if the key wasn't found in the cache, so you
 can't set the key inside the compiler :)
 
 You're right, of course.  Unfortunately, I really want to!  Only shaders
 using shadow2DGradARB need to be recompiled when glDepthFunc changes, so
 I really want to leave it as 0 for most shaders.  Otherwise the common
 case will have completely pointless recompiles.
 
 Unfortunately, I only know whether or not I need it at compile time...
 
 This -almost- works...it just means we'll recompile shaders using
 shadow2DGradARB every time, since they'll never be found in the cache.
 Stupid.  I'll reply with a patch which works around this.

We could always add a flag in the gl_shader_program that the program
uses TXD.  You could force c-key.depth_compare_func to 0 whenever that
flag is zero.  Or we could put a similar flag in the brw_fs structure
and do a preprocessing step to set it.  Right?

 +
 +  /* No need to even sample for GL_ALWAYS or GL_NEVER...bail
 early */
 +  if (ctx-Depth.Func == GL_ALWAYS)
 + return swizzle_shadow_result(ir, fs_reg(1.0f), sampler);
 +  else if (ctx-Depth.Func == GL_NEVER)
 + return swizzle_shadow_result(ir, fs_reg(0.0f), sampler);
 +   }

 Generally I use c-key. values to make it obvious that state dependent
 recompiles are in place, instead of ctx-.
 
 Good idea.  Updated.
 
 diff --git a/src/mesa/drivers/dri/i965/brw_wm.h
 b/src/mesa/drivers/dri/i965/brw_wm.h
 index e244b55..0b284b6 100644
 --- a/src/mesa/drivers/dri/i965/brw_wm.h
 +++ b/src/mesa/drivers/dri/i965/brw_wm.h
 @@ -67,6 +67,7 @@ struct brw_wm_prog_key {
  GLuint alpha_test:1;
  GLuint clamp_fragment_color:1;
  GLuint line_aa:2;
 +   uint8_t depth_compare_func; /* 0 if irrelevant, GL_LESS etc.
 otherwise */

 Wow, those do happen to fit in 8 bits.  Might comment that explicitly --
 leaving out bits when storing GLenums has been a common bug and seeing
 things like this make me paranoid and go check :)
 
 :) Makes sense; commented.  I figured we really want to pack the key.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk34/DQACgkQX1gOwKyEAw9KsACgk/L9OPEOdduhPeaYTyFyEK4U
L04Ani+R/agfr/dxurd0+poca4EP1Uru
=b63p
-END PGP SIGNATURE-
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] line anti aliasing on r700 and r600

2011-06-15 Thread Alex Deucher
On Wed, Jun 15, 2011 at 2:14 PM, Jeffrey Collins tilde...@hotmail.com wrote:
 Does line anti aliasing work for r600 and r700 processors? It does not seem
 to change anything visually when I
 set PA_SC_AA_MASK.u32All, PA_SC_AA_SAMPLE_LOCS_MCTX.u32All, PA_SC_AA_SAMPLE_LOCS_8S_WD1_MCTX.u32All
 and PA_SC_AA_CONFIG.u32All to what would seem to be reasonable values in
 r700InitState.

Those regs are for MSAA.  For primitive AA (lines, points, etc.), you
need to add instructions to the fragment shader.  It works similarly
to r3xx-r5xx.  See section 10.7 of the r5xx acceleration guide:
http://www.x.org/docs/AMD/R5xx_Acceleration_v1.5.pdf

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


Re: [Mesa-dev] [PATCH 1/7] Create AST data structures for switch statement and case label

2011-06-15 Thread Kenneth Graunke

On 06/15/2011 09:33 AM, Dan McCabe wrote:

Data structures for switch statement and case label are created that parallel
the structure of other AST data.
---
  src/glsl/ast.h |   27 +++
  1 files changed, 23 insertions(+), 4 deletions(-)


Dan, thanks for sending this out!  A few comments below...


diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 878f48b..48d1795 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -628,13 +628,19 @@ public:

  class ast_case_label : public ast_node {
  public:
+   ast_case_label(ast_expression *test_value);
+   virtual void print(void) const;
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);

 /**
-* An expression of NULL means 'default'.
+* An test value of NULL means 'default'.
  */
-   ast_expression *expression;
+   ast_expression *test_value;
  };

+
  class ast_selection_statement : public ast_node {
  public:
 ast_selection_statement(ast_expression *condition,
@@ -653,8 +659,21 @@ public:

  class ast_switch_statement : public ast_node {
  public:
-   ast_expression *expression;
-   exec_list statements;
+   ast_switch_statement(ast_expression *test_expression,
+   ast_node *body);
+   virtual void print(void) const;
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
+   ast_expression *test_expression;
+   ast_node *body;
+
+   ir_variable *test_var;


Presumably this is x in switch (x) { ... }?  That can be an 
arbitrary scalar integer expression, not just a variable.



+   ir_variable *fallthru_var;
+
+protected:
+   void test_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *);
  };


I don't think we should be putting ir_variables (or any HIR code!) in 
the AST structures.  The AST should really just be an abstract syntax 
tree, representing the text and structure of the program, but 
independent of any IR code we might generate.


I had imagined creating some kind of IR structure along the lines of:

class ir_switch : public ir_instruction
{
ir_rvalue *switch_value; // switch (...) - arbitrary expression

exec_list cases; // list of ir_case
};

class ir_case : public exec_node
{
ir_rvalue *test_value; // case X: ... NULL means default:
exec_list body; // statements inside this case
// possibly a bool has_break or falls_through, if helpful
};

This seems pretty straightforward to generate at AST-HIR time.

Then there would be a lowering pass (see lower_*.cpp) based on an 
ir_hierarchical_visitor that visits ir_switch, replacing it with the 
loop/if structure.  ir_variable *fallthru_var would fit nicely as a 
member of that visitor.  visit(ir_switch *) would create/emit it, and 
visit(ir_case *) would reference it.


Of course, there may be another solution; it's just an idea.

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


[Mesa-dev] Trying to tickle swrast's depth read fastpaths

2011-06-15 Thread Eric Anholt
s_readpix.c looks bogus in the depth fastpaths, where it's changing
GetRow results based on rb-Format instead of only looking at
rb-DataType vs type.  I came up with these tests trying to hit those,
but they're passing for me.  Have I missed something obvious?

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


[Mesa-dev] [PATCH 1/2] fbo-readpixels-depth-formats: New test for glReadPixels(GL_DEPTH_COMPONENT, *).

2011-06-15 Thread Eric Anholt
We have a few tests that read depth, but they all read GL_FLOAT, so
they don't cover the fast paths in swrast.
---
 tests/all.tests  |1 +
 tests/fbo/CMakeLists.gl.txt  |1 +
 tests/fbo/fbo-readpixels-depth-formats.c |  279 ++
 3 files changed, 281 insertions(+), 0 deletions(-)
 create mode 100644 tests/fbo/fbo-readpixels-depth-formats.c

diff --git a/tests/all.tests b/tests/all.tests
index f404083..f74b74b 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -162,6 +162,7 @@ add_plain_test(fbo, 'fbo-nostencil-test')
 add_plain_test(fbo, 'fbo-pbo-readpixels-small')
 add_plain_test(fbo, 'fbo-readdrawpix')
 add_plain_test(fbo, 'fbo-readpixels')
+add_plain_test(fbo, 'fbo-readpixels-depth-formats')
 add_plain_test(fbo, 'fbo-scissor-bitmap')
 add_plain_test(fbo, 'fbo-srgb')
 add_plain_test(fbo, 'fbo-srgb-blit')
diff --git a/tests/fbo/CMakeLists.gl.txt b/tests/fbo/CMakeLists.gl.txt
index fb63172..bd71050 100644
--- a/tests/fbo/CMakeLists.gl.txt
+++ b/tests/fbo/CMakeLists.gl.txt
@@ -64,6 +64,7 @@ add_executable (fbo-mipmap-copypix fbo-mipmap-copypix.c)
 add_executable (fbo-nodepth-test fbo-nodepth-test.c)
 add_executable (fbo-nostencil-test fbo-nostencil-test.c)
 add_executable (fbo-readpixels fbo-readpixels.c)
+add_executable (fbo-readpixels-depth-formats fbo-readpixels-depth-formats.c)
 add_executable (fbo-rg fbo-rg.c)
 add_executable (fbo-srgb fbo-srgb.c)
 add_executable (fbo-srgb-blit fbo-srgb-blit.c)
diff --git a/tests/fbo/fbo-readpixels-depth-formats.c 
b/tests/fbo/fbo-readpixels-depth-formats.c
new file mode 100644
index 000..3de06f6
--- /dev/null
+++ b/tests/fbo/fbo-readpixels-depth-formats.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright © 2011 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.
+ */
+
+/** @file fbo-readpixels-depth-formats.c
+ *
+ * Tests that various formats of depth renderbuffers can be read
+ * correctly using glReadPixels() with various format/type
+ * combinations.
+ */
+
+#include piglit-util.h
+
+#define BUF_WIDTH 15
+#define BUF_HEIGHT 15
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+int piglit_width = BUF_WIDTH;
+int piglit_height = BUF_WIDTH;
+
+/* Width of our stripes of z = 0.0, 0.5, 1.0 */
+static int w = BUF_WIDTH / 3;
+
+int depth_bits;
+
+static bool
+test_float(int x, int y, void *values)
+{
+   float value = ((float *)values)[y * BUF_WIDTH + x];
+   float expected;
+   float limit;
+
+   if (x  w)
+   expected = 0.0;
+   else if (x  w * 2)
+   expected = 0.5;
+   else
+   expected = 1.0;
+
+   /* Default OpenGL 1 in 10^5 */
+   limit = .1;
+   /* Framebuffer precision */
+   if (depth_bits  24)
+   limit = 1.0 / (1  depth_bits);
+
+   if (fabs(value - expected)  limit) {
+   fprintf(stderr,
+   GL_FLOAT: 
+   Expected %f at (%d,%d), found %f\n,
+   expected, x, y, value);
+   return false;
+   }
+
+   return true;
+}
+
+static bool
+test_unsigned_int(int x, int y, void *values)
+{
+   uint32_t value = ((uint32_t *)values)[y * BUF_WIDTH + x];
+   uint32_t expected;
+   uint32_t high_bits, low_bits;
+
+   if (x  w)
+   expected = 0x0;
+   else if (x  w * 2)
+   expected = 0x8000;
+   else
+   expected = 0x;
+
+   low_bits = (1  (32 - depth_bits)) - 1;
+   high_bits = ~low_bits;
+
+   expected = high_bits;
+   expected |= expected  depth_bits;
+
+   if ((int32_t)(value - expected)  1  (32 - depth_bits)) {
+   fprintf(stderr,
+   GL_UNSIGNED_INT: 
+   Expected 0x%08x at (%d,%d), found 0x%08x\n,
+   expected, x, y, value);
+   return false;
+   }
+
+

[Mesa-dev] [PATCH 2/2] ext_packed_depth_stencil/readpixels-24_8: New test for packed fbo readpixels.

2011-06-15 Thread Eric Anholt
The existing glean test only covers window system framebuffers, not an
actual packed depth/stencil FBO like this.
---
 tests/all.tests|1 +
 tests/spec/CMakeLists.txt  |1 +
 .../ext_packed_depth_stencil/CMakeLists.gl.txt |   17 ++
 tests/spec/ext_packed_depth_stencil/CMakeLists.txt |1 +
 .../ext_packed_depth_stencil/readpixels-24_8.c |  162 
 5 files changed, 182 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/ext_packed_depth_stencil/CMakeLists.gl.txt
 create mode 100644 tests/spec/ext_packed_depth_stencil/CMakeLists.txt
 create mode 100644 tests/spec/ext_packed_depth_stencil/readpixels-24_8.c

diff --git a/tests/all.tests b/tests/all.tests
index f74b74b..69c6477 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -881,6 +881,7 @@ add_fbo_depth_test(ext_packed_depth_stencil, 
'GL_DEPTH24_STENCIL8')
 add_fbo_generatemipmap_extension(ext_packed_depth_stencil, 
'GL_EXT_packed_depth_stencil', 'fbo-generatemipmap-formats')
 add_fbo_clear_extension(ext_packed_depth_stencil, 
'GL_EXT_packed_depth_stencil', 'fbo-clear-formats')
 add_texwrap_test2(ext_packed_depth_stencil, '2D', 'GL_DEPTH24_STENCIL8')
+ext_packed_depth_stencil['readpixels-24_8'] = 
PlainExecTest(['ext_packed_depth_stencil-readpixels-24_8', '-auto'])
 
 ext_texture_compression_latc = Group()
 spec['EXT_texture_compression_latc'] = ext_texture_compression_latc
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 3b57487..e17a09a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -10,6 +10,7 @@ add_subdirectory (ati_draw_buffers)
 add_subdirectory (arb_texture_float)
 add_subdirectory (ati_envmap_bumpmap)
 add_subdirectory (ext_fog_coord)
+add_subdirectory (ext_packed_depth_stencil)
 add_subdirectory (nv_conditional_render)
 add_subdirectory (nv_texture_barrier)
 add_subdirectory (arb_draw_elements_base_vertex)
diff --git a/tests/spec/ext_packed_depth_stencil/CMakeLists.gl.txt 
b/tests/spec/ext_packed_depth_stencil/CMakeLists.gl.txt
new file mode 100644
index 000..7fd1cc1
--- /dev/null
+++ b/tests/spec/ext_packed_depth_stencil/CMakeLists.gl.txt
@@ -0,0 +1,17 @@
+include_directories(
+   ${GLEXT_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+   ${GLUT_INCLUDE_DIR}
+   ${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+   piglitutil
+   ${OPENGL_gl_LIBRARY}
+   ${OPENGL_glu_LIBRARY}
+   ${GLUT_glut_LIBRARY}
+)
+
+add_executable (ext_packed_depth_stencil-readpixels-24_8 readpixels-24_8.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/ext_packed_depth_stencil/CMakeLists.txt 
b/tests/spec/ext_packed_depth_stencil/CMakeLists.txt
new file mode 100644
index 000..144a306
--- /dev/null
+++ b/tests/spec/ext_packed_depth_stencil/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c 
b/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
new file mode 100644
index 000..2e8c7a8
--- /dev/null
+++ b/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright © 2011 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.
+ */
+
+/** @file fbo-readpixels-depth-formats.c
+ *
+ * Tests that various formats of depth renderbuffers can be read
+ * correctly using glReadPixels() with various format/type
+ * combinations.
+ */
+
+#include piglit-util.h
+
+#define BUF_WIDTH 15
+#define BUF_HEIGHT 15
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+int piglit_width = BUF_WIDTH;
+int piglit_height = BUF_WIDTH;
+
+/* Width of our stripes of z = 0.0, 0.5, 1.0 */
+static int w = BUF_WIDTH / 3;
+
+int depth_bits;
+
+static bool
+test_pixel(int x, int y, uint32_t value)
+{
+   uint32_t expected;
+
+   if (x  w)
+   expected = 0x;
+   else if (x  w * 2)
+   

[Mesa-dev] [Bug 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

--- Comment #28 from Benoit Jacob bja...@mozilla.com 2011-06-15 14:12:39 PDT 
---
(In reply to comment #27)
 Created an attachment (id=48014)
 -- (https://bugs.freedesktop.org/attachment.cgi?id=48014)
 minefield.log.bz2 (no crash at the end)

Thanks a lot!

The log shows that glGetIntegerv(FRAMEBUFFER_BINDING, result) always returns
0. Even right after glBindFramebuffer called with a value just returned by
glGenFramebuffers. Even when a glFramebufferRenderbuffer call succeeds, which
is incompatible with the FB binding being 0.

 No crash on closedown.

\o/ !!!

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

--- Comment #30 from Benoit Jacob bja...@mozilla.com 2011-06-15 14:14:21 PDT 
---
Note that with the NVIDIA driver, nonzero FB bindings are correctly reported by
this build.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

--- Comment #31 from Brian Paul brian.e.p...@gmail.com 2011-06-15 14:25:18 
PDT ---
(In reply to comment #28)
 (In reply to comment #27)
  Created an attachment (id=48014)
 -- (https://bugs.freedesktop.org/attachment.cgi?id=48014)
  minefield.log.bz2 (no crash at the end)
 
 Thanks a lot!
 
 The log shows that glGetIntegerv(FRAMEBUFFER_BINDING, result) always returns
 0. Even right after glBindFramebuffer called with a value just returned by
 glGenFramebuffers. Even when a glFramebufferRenderbuffer call succeeds, which
 is incompatible with the FB binding being 0.

I just hacked a piglit fbo test to query GL_FRAMEBUFFER_BINDING after
glBindFramebuffer() and assert that the value returned matches the bind call. 
It works fine here.  I don't know what's going on in your test.  Which version
of Mesa are you using?

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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] Status of the GLSL-TGSI translator

2011-06-15 Thread Bryan Cain
My work on the GLSL IR to TGSI translator I announced on the list this
April is now at the point where I think it is ready to be merged into
Mesa.  It is stable and doesn't regress any piglit tests on softpipe or
nv50.

It adds native integer support as required by GLSL 1.30, although it is
currently disabled for all drivers since GLSL 1.30 support is not
complete yet and most Gallium drivers haven't implemented the TGSI
integer opcodes.  (This would be a good time for Gallium driver
developers to add support for TGSI's integer opcodes, which are
currently only implemented in softpipe.)

Developing this necessitated significant changes elsewhere in Mesa, and
some small changes in Gallium.  This means that some of the commits in
my branch probably need to be reviewed by the developers of those
components.

If I had commit access to Mesa, I would create a branch for this work in
the main Mesa repository.  But since I am still waiting on my
freedesktop.org account to be created, I have pushed the latest version
to the glsl-to-tgsi branch of my personal Mesa repository on GitHub:

Git clone URL: git://github.com/Plombo/mesa.git
Web interface for viewing commits:
https://github.com/Plombo/mesa/commits/glsl-to-tgsi

Hopefully my freedesktop.org account will be created soon (I have
already had my account request approved), so that I can push this to a
branch in the central repository.

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


[Mesa-dev] [Bug 38312] Swrast doesn't really know whether a Framebuffer object is bound

2011-06-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=38312

--- Comment #34 from Tony Mechelynck antoine.mechely...@gmail.com 2011-06-15 
14:46:19 PDT ---
(In reply to comment #32)
 (In reply to comment #31)
  I just hacked a piglit fbo test to query GL_FRAMEBUFFER_BINDING after
  glBindFramebuffer() and assert that the value returned matches the bind 
  call. 
  It works fine here.  I don't know what's going on in your test.  Which 
  version
  of Mesa are you using?
 
 See comment 1, Tony is using Mesa 7.10.2.

and (see comment #8 /in fine/) it's the newest version I can use until or
unless openSUSE decides to distribute an upgraded version. If necessary, a bug
can be opened at bugzilla.novell.com if the Mesa 7.10.3 is found to fix a
possible crash (let's say in firefox-aurora). IIUC the liaison officer between
Mozilla and SuSE is Wolfgang Rosenauer. I don't know if he's registered at
bugs.freedesktop.org.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- 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] Status of the GLSL-TGSI translator

2011-06-15 Thread Dave Airlie
On Thu, Jun 16, 2011 at 7:38 AM, Bryan Cain bryanca...@gmail.com wrote:
 My work on the GLSL IR to TGSI translator I announced on the list this
 April is now at the point where I think it is ready to be merged into
 Mesa.  It is stable and doesn't regress any piglit tests on softpipe or
 nv50.

For anyone not github aware, I've just pushed the latest branch to
glsl-to-tgsi in the main mesa repo.

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


Re: [Mesa-dev] [PATCH 1/6] configure.ac: remove redundant option --enable-gallium-egl

2011-06-15 Thread Marek Olšák
On Tue, Jun 14, 2011 at 10:35 PM, Benjamin Franzke
benjaminfran...@googlemail.com wrote:
 Removing this flag seems right to me, but always building the egl
 state tracker when gallium and egl is enabled not.
 So when --with-state-trackers is also removed, we'd need a new
 --with-egl-drivers=auto|gallium,dri2,glx or so.

Isn't --with-egl-platforms good enough to select among fbdev, wayland,
one-day-maybe dri, ...? I don't see a reason for another option. You
can choose between dri and xlib (st/glx) already using
--with-driver=dri|xlib.

I believe that most people (i.e. non-devs) don't want to
enable/disable Gallium, most people don't even know what that actually
means. But they certainly want two things: choose drivers for their
hardware and choose public APIs for them. Whether a driver is classic
or Gallium shouldn't matter. Gallium has absolutely nothing to do with
public APIs, it's an internal thing and should stay internal. I assume
the word gallium in --with-gallium-drivers is just transitional.

So if I choose --with-gallium-drivers=r300 --enable-egl
--enable-openvg, I expect OpenGL and OpenVG support in EGL (with
default EGL platforms) for r300g, and the OpenGL DRI driver for r300g
(because DRI is enabled by default).

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


[Mesa-dev] [PATCH] glx: implement drawable refcounting.

2011-06-15 Thread Stéphane Marchesin
The current dri context unbind logic will leak drawables until the process
dies (they will then get released by the GEM code). There are two ways to fix
this: either always call driReleaseDrawables every time we unbind a context
(but that costs us round trips to the X server at getbuffers() time) or
implement proper drawable refcounting. This patch implements the latter.

Signed-off-by: Antoine Labour pi...@chromium.org
Signed-off-by: Stéphane Marchesin marc...@chromium.org
---
 src/glx/dri2_glx.c   |5 ++---
 src/glx/dri_common.c |   26 +++---
 src/glx/dri_glx.c|6 --
 src/glx/drisw_glx.c  |6 --
 src/glx/glxclient.h  |1 +
 src/glx/glxcurrent.c |   14 +++---
 6 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 506754c..e7c18ff 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -143,6 +143,8 @@ dri2_bind_context(struct glx_context *context, struct 
glx_context *old,
pdraw = (struct dri2_drawable *) driFetchDrawable(context, draw);
pread = (struct dri2_drawable *) driFetchDrawable(context, read);
 
+   driReleaseDrawables(pcp-base);
+
if (pdraw == NULL || pread == NULL)
   return GLXBadDrawable;
 
@@ -170,9 +172,6 @@ dri2_unbind_context(struct glx_context *context, struct 
glx_context *new)
struct dri2_screen *psc = (struct dri2_screen *) pcp-base.psc;
 
(*psc-core-unbindContext) (pcp-driContext);
-
-   if (context == new)
-  driReleaseDrawables(pcp-base);
 }
 
 static struct glx_context *
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 06a73e4..bac0c9e 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -369,8 +369,10 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable 
glxDrawable)
if (priv-drawHash == NULL)
   return NULL;
 
-   if (__glxHashLookup(priv-drawHash, glxDrawable, (void *) pdraw) == 0)
+   if (__glxHashLookup(priv-drawHash, glxDrawable, (void *) pdraw) == 0) {
+  pdraw-refcount ++;
   return pdraw;
+   }
 
pdraw = psc-driScreen-createDrawable(psc, glxDrawable,
   glxDrawable, gc-config);
@@ -378,6 +380,7 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable 
glxDrawable)
   (*pdraw-destroyDrawable) (pdraw);
   return NULL;
}
+   pdraw-refcount = 1;
 
return pdraw;
 }
@@ -394,19 +397,28 @@ driReleaseDrawables(struct glx_context *gc)
if (__glxHashLookup(priv-drawHash,
   gc-currentDrawable, (void *) pdraw) == 0) {
   if (pdraw-drawable == pdraw-xDrawable) {
-(*pdraw-destroyDrawable)(pdraw);
-__glxHashDelete(priv-drawHash, gc-currentDrawable);
+pdraw-refcount --;
+if (pdraw-refcount == 0) {
+   (*pdraw-destroyDrawable)(pdraw);
+   __glxHashDelete(priv-drawHash, gc-currentDrawable);
+}
   }
}
 
-   if (gc-currentDrawable != gc-currentReadable 
-   __glxHashLookup(priv-drawHash,
+   if (__glxHashLookup(priv-drawHash,
   gc-currentReadable, (void *) pdraw) == 0) {
   if (pdraw-drawable == pdraw-xDrawable) {
-(*pdraw-destroyDrawable)(pdraw);
-__glxHashDelete(priv-drawHash, gc-currentReadable);
+pdraw-refcount --;
+if (pdraw-refcount == 0) {
+   (*pdraw-destroyDrawable)(pdraw);
+   __glxHashDelete(priv-drawHash, gc-currentReadable);
+}
   }
}
+
+   gc-currentDrawable = None;
+   gc-currentReadable = None;
+
 }
 
 #endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index ff027dc..d59784c 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -503,6 +503,8 @@ dri_destroy_context(struct glx_context * context)
struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) context-psc;
 
+   driReleaseDrawables(pcp-base);
+
if (context-xid)
   glx_send_destroy_context(psc-base.dpy, context-xid);
 
@@ -526,6 +528,8 @@ dri_bind_context(struct glx_context *context, struct 
glx_context *old,
pdraw = (struct dri_drawable *) driFetchDrawable(context, draw);
pread = (struct dri_drawable *) driFetchDrawable(context, read);
 
+   driReleaseDrawables(pcp-base);
+
if (pdraw == NULL || pread == NULL)
   return GLXBadDrawable;
 
@@ -543,8 +547,6 @@ dri_unbind_context(struct glx_context *context, struct 
glx_context *new)
struct dri_screen *psc = (struct dri_screen *) pcp-base.psc;
 
(*psc-core-unbindContext) (pcp-driContext);
-
-   driReleaseDrawables(pcp-base);
 }
 
 static const struct glx_context_vtable dri_context_vtable = {
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index 2eaa3c5..0075695 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -242,6 +242,8 @@ drisw_destroy_context(struct glx_context *context)
struct drisw_context *pcp = (struct drisw_context *) context;
struct drisw_screen *psc = (struct drisw_screen *) context-psc;
 
+ 

Re: [Mesa-dev] Status of the GLSL-TGSI translator

2011-06-15 Thread Bryan Cain
On 06/15/2011 04:59 PM, Kenneth Graunke wrote:
 Bryan,

 Thanks for your work on this!  I'm glad to see GLSL IR-TGSI happening.

 A few quick comments on mesa,st/mesa: add native support for integers
 in shaders...

 glsl_type::get_vec4_type(base) is equivalent to
 glsl_type::get_instance(base, 4, 1) except that it returns error_type
 instead of NULL.  You might want to use get_instance directly or
 implement get_vec4_type on top of it.

Thanks, I didn't notice get_instance.  I'll go ahead and make a commit
that removes get_vec4_type and uses get_instance directly instead.


 For the ir_unop_u2f, ir_unop_bit_not, ir_binop_lshift,
 ir_binop_rshift, ir_binop_bit_and, ir_binop_bit_xor, and
 ir_binop_bit_or cases...you don't need the glsl_version = 130 check. 
 These were first introduced in GLSL 1.30 and should never occur in
 prior versions.  (If anything, I'd assert instead of emitting nothing.)

Actually, they already assert when the GLSL version is less than GLSL
1.30 in order to match the behavior of ir_to_mesa.  It might not be
obvious from reading that code the first time, but the break for each of
those cases is inside the glsl_version = 130 block.  When the GLSL
version is 120 or lower for any of those cases, it falls through to the
assertion after ir_binop_round_even.

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


[Mesa-dev] [PATCH] intel: Fix region refcounting in intel_alloc_renderbuffer_storage

2011-06-15 Thread Chad Versace
Replace instances of
irb-region = region
with
intel_region_reference(irb-region, region)

Signed-off-by: Chad Versace c...@chad-versace.us
---
 src/mesa/drivers/dri/intel/intel_fbo.c |   49 ++-
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
b/src/mesa/drivers/dri/intel/intel_fbo.c
index e7c23f0..76c84a8 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -184,33 +184,40 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, 
struct gl_renderbuffer
* If we neglect to double the pitch, then drm_intel_gem_bo_map_gtt()
* maps the memory incorrectly.
*/
-  irb-region = intel_region_alloc(intel-intelScreen,
-  I915_TILING_Y,
-  cpp * 2,
-  width,
-  height / 2,
-  GL_TRUE);
+  struct intel_region *region = intel_region_alloc(intel-intelScreen,
+  I915_TILING_Y,
+  cpp * 2,
+  width,
+  height / 2,
+  true);
+  if (!region) {
+return false;
+  }
+  intel_region_reference(irb-region, region);
+
} else {
-  irb-region = intel_region_alloc(intel-intelScreen, tiling, cpp,
-  width, height, GL_TRUE);
+  struct intel_region *region =
+intel_region_alloc(intel-intelScreen, tiling, cpp,
+   width, height, true);
+  if (!region) {
+return false;
+  }
+  intel_region_reference(irb-region, region);
}
 
-   if (!irb-region)
-  return GL_FALSE;   /* out of memory? */
-
-   ASSERT(irb-region-buffer);
-
if (intel-vtbl.is_hiz_depth_format(intel, rb-Format)) {
-  irb-hiz_region = intel_region_alloc(intel-intelScreen,
-   I915_TILING_Y,
-   irb-region-cpp,
-   irb-region-width,
-   irb-region-height,
-   GL_TRUE);
-  if (!irb-hiz_region) {
+  struct intel_region *hiz_region =
+intel_region_alloc(intel-intelScreen,
+   I915_TILING_Y,
+   irb-region-cpp,
+   irb-region-width,
+   irb-region-height,
+   true);
+  if (!hiz_region) {
  intel_region_release(irb-region);
- return GL_FALSE;
+ return false;
   }
+  intel_region_reference(irb-hiz_region, hiz_region);
}
 
rb-Width = width;
-- 
1.7.5.2

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


[Mesa-dev] [PATCH 2/2] glsl: never enable unsupported extensions (bug 38015)

2011-06-15 Thread Paul Berry
For some extensions, _mesa_glsl_process_extension() only checked
whether the extension was supported *after* enabling it.  Modified the
logic to always check first, and only enable supported extensions.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=38015 and piglit
test glsl-link-bug38015.
---
 src/glsl/glsl_parser_extras.cpp |  117 +++
 1 files changed, 70 insertions(+), 47 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index d9aa300..afd8679 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -211,73 +211,96 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE 
*name_locp,
 state-ARB_draw_buffers_warn = (ext_mode == extension_warn);
   }
} else if (strcmp(name, GL_ARB_draw_instanced) == 0) {
-  state-ARB_draw_instanced_enable = (ext_mode != extension_disable);
-  state-ARB_draw_instanced_warn = (ext_mode == extension_warn);
-
   /* This extension is only supported in vertex shaders.
*/
-  unsupported = (state-target != vertex_shader)
-||  !state-extensions-ARB_draw_instanced;
+  if ((state-target != vertex_shader)
+  ||  !state-extensions-ARB_draw_instanced) {
+ unsupported = true;
+  } else {
+ state-ARB_draw_instanced_enable = (ext_mode != extension_disable);
+ state-ARB_draw_instanced_warn = (ext_mode == extension_warn);
+  }
} else if (strcmp(name, GL_ARB_explicit_attrib_location) == 0) {
-  state-ARB_explicit_attrib_location_enable =
-(ext_mode != extension_disable);
-  state-ARB_explicit_attrib_location_warn =
-(ext_mode == extension_warn);
-
-  unsupported = !state-extensions-ARB_explicit_attrib_location;
+  if (!state-extensions-ARB_explicit_attrib_location) {
+ unsupported = true;
+  } else {
+ state-ARB_explicit_attrib_location_enable =
+(ext_mode != extension_disable);
+ state-ARB_explicit_attrib_location_warn =
+(ext_mode == extension_warn);
+  }
} else if (strcmp(name, GL_ARB_fragment_coord_conventions) == 0) {
-  state-ARB_fragment_coord_conventions_enable =
-(ext_mode != extension_disable);
-  state-ARB_fragment_coord_conventions_warn =
-(ext_mode == extension_warn);
-
-  unsupported = !state-extensions-ARB_fragment_coord_conventions;
+  if (!state-extensions-ARB_fragment_coord_conventions) {
+ unsupported = true;
+  } else {
+ state-ARB_fragment_coord_conventions_enable =
+(ext_mode != extension_disable);
+ state-ARB_fragment_coord_conventions_warn =
+(ext_mode == extension_warn);
+  }
} else if (strcmp(name, GL_ARB_texture_rectangle) == 0) {
   state-ARB_texture_rectangle_enable = (ext_mode != extension_disable);
   state-ARB_texture_rectangle_warn = (ext_mode == extension_warn);
} else if (strcmp(name, GL_EXT_texture_array) == 0) {
-  state-EXT_texture_array_enable = (ext_mode != extension_disable);
-  state-EXT_texture_array_warn = (ext_mode == extension_warn);
-
-  unsupported = !state-extensions-EXT_texture_array;
+  if (!state-extensions-EXT_texture_array) {
+ unsupported = true;
+  } else {
+ state-EXT_texture_array_enable = (ext_mode != extension_disable);
+ state-EXT_texture_array_warn = (ext_mode == extension_warn);
+  }
} else if (strcmp(name, GL_ARB_shader_texture_lod) == 0) {
-  /* Force ARB_texture_rectangle to be on so sampler2DRects are defined */
-  state-ARB_texture_rectangle_enable = true;
-
-  state-ARB_shader_texture_lod_enable = (ext_mode != extension_disable);
-  state-ARB_shader_texture_lod_warn = (ext_mode == extension_warn);
+  if (!state-extensions-ARB_shader_texture_lod) {
+ unsupported = true;
+  } else {
+ /* Force ARB_texture_rectangle to be on so sampler2DRects are defined
+  */
+ state-ARB_texture_rectangle_enable = true;
 
-  unsupported = !state-extensions-ARB_shader_texture_lod;
+ state-ARB_shader_texture_lod_enable
+= (ext_mode != extension_disable);
+ state-ARB_shader_texture_lod_warn = (ext_mode == extension_warn);
+  }
} else if (strcmp(name, GL_ARB_shader_stencil_export) == 0) {
-  state-ARB_shader_stencil_export_enable = (ext_mode != 
extension_disable);
-  state-ARB_shader_stencil_export_warn = (ext_mode == extension_warn);
-
   /* This extension is only supported in fragment shaders.
*/
-  unsupported = (state-target != fragment_shader)
-|| !state-extensions-ARB_shader_stencil_export;
+  if ((state-target != fragment_shader)
+  || !state-extensions-ARB_shader_stencil_export) {
+ unsupported = true;
+  } else {
+ state-ARB_shader_stencil_export_enable
+= (ext_mode != extension_disable);
+ 

[Mesa-dev] [PATCH 0/7] mesa, intel: Support s8z24 pure renderbuffers when using separate stencil

2011-06-15 Thread Chad Versace
Only patch 1 affects core mesa; the remaining patches are in the intel shared 
driver.

Patch 6 is just a clean-up leading to patch 7.

Chad Versace (7):
  mesa: Add field gl_renderbuffer.Unwrapped
  intel: Unconditionally enable support for S8_Z24 texture format
  intel: Support renderbuffer unwrappers in intel_get_renderbuffer()
  intel: Fix intel_framebuffer_map/unamp to use intel_get_renderbuffer()
  intel: Fix region refcounting in intel_alloc_renderbuffer_storage
  intel: Unobfuscate intel_alloc_renderbuffer_storage
  intel: Support s8z24 pure renderbuffers when using separate stencil

 src/mesa/drivers/dri/intel/intel_context.c |2 +-
 src/mesa/drivers/dri/intel/intel_fbo.c |  139 ++--
 src/mesa/drivers/dri/intel/intel_fbo.h |   21 -
 src/mesa/drivers/dri/intel/intel_span.c|6 +-
 src/mesa/main/fbobject.c   |   26 +-
 src/mesa/main/framebuffer.c|   54 ---
 src/mesa/main/mtypes.h |   11 ++
 src/mesa/main/renderbuffer.c   |6 +
 8 files changed, 213 insertions(+), 52 deletions(-)

-- 
1.7.5.2

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


[Mesa-dev] [PATCH 3/7] intel: Support renderbuffer unwrappers in intel_get_renderbuffer()

2011-06-15 Thread Chad Versace
Now, if the renderbuffer contains an unwrapper for the requested
attachment, intel_get_renderbuffer returns the unwrapper.

Signed-off-by: Chad Versace c...@chad-versace.us
---
 src/mesa/drivers/dri/intel/intel_fbo.h |   21 +
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h 
b/src/mesa/drivers/dri/intel/intel_fbo.h
index 509f588..e220ef8 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -76,13 +76,26 @@ intel_renderbuffer(struct gl_renderbuffer *rb)
 
 
 /**
- * Return a framebuffer's renderbuffer, named by a BUFFER_x index.
+ * \brief Return the framebuffer attachment specified by attIndex.
+ *
+ * If the framebuffer lacks the specified attachment, then return null.
+ * If the renderbuffer attachment contains an unwrapper for attIndex,
+ * then return the unwrapper.
  */
 static INLINE struct intel_renderbuffer *
-intel_get_renderbuffer(struct gl_framebuffer *fb, int attIndex)
+intel_get_renderbuffer(struct gl_framebuffer *fb, gl_buffer_index attIndex)
 {
-   if (attIndex = 0)
-  return intel_renderbuffer(fb-Attachment[attIndex].Renderbuffer);
+   struct gl_renderbuffer *rb = NULL;
+
+   if (attIndex = 0) {
+  rb = fb-Attachment[attIndex].Renderbuffer;
+  if (rb  rb-Unwrapped[attIndex]) {
+rb = rb-Unwrapped[attIndex];
+  }
+   }
+
+   if (rb)
+  return intel_renderbuffer(rb);
else
   return NULL;
 }
-- 
1.7.5.2

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


[Mesa-dev] [PATCH 4/7] intel: Fix intel_framebuffer_map/unamp to use intel_get_renderbuffer()

2011-06-15 Thread Chad Versace
If Attachment[X] was a wrapper (s8_z24) around separate depth (x8_z24) and
stencil (s8) buffers, then intel_renderbuffer_map was passed the wrapper
instead of the real renderbuffer. This was no good; the wrapper has no
intel_region.

Using intel_get_renderbuffer() ensures that we map the real renderbuffer.

Signed-off-by: Chad Versace c...@chad-versace.us
---
 src/mesa/drivers/dri/intel/intel_span.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_span.c 
b/src/mesa/drivers/dri/intel/intel_span.c
index fdf687a..9e49b35 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -223,7 +223,8 @@ intel_framebuffer_map(struct intel_context *intel, struct 
gl_framebuffer *fb)
int i;
 
for (i = 0; i  BUFFER_COUNT; i++) {
-  intel_renderbuffer_map(intel, fb-Attachment[i].Renderbuffer);
+  struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, i);
+  intel_renderbuffer_map(intel, irb-Base);
}
 
intel_check_front_buffer_rendering(intel);
@@ -235,7 +236,8 @@ intel_framebuffer_unmap(struct intel_context *intel, struct 
gl_framebuffer *fb)
int i;
 
for (i = 0; i  BUFFER_COUNT; i++) {
-  intel_renderbuffer_unmap(intel, fb-Attachment[i].Renderbuffer);
+  struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, i);
+  intel_renderbuffer_unmap(intel, irb-Base);
}
 }
 
-- 
1.7.5.2

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


[Mesa-dev] [PATCH 5/7] intel: Fix region refcounting in intel_alloc_renderbuffer_storage

2011-06-15 Thread Chad Versace
Replace instances of
irb-region = region
with
intel_region_reference(irb-region, region)

Signed-off-by: Chad Versace c...@chad-versace.us
---
 src/mesa/drivers/dri/intel/intel_fbo.c |   49 ++-
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c 
b/src/mesa/drivers/dri/intel/intel_fbo.c
index e7c23f0..76c84a8 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -184,33 +184,40 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, 
struct gl_renderbuffer
* If we neglect to double the pitch, then drm_intel_gem_bo_map_gtt()
* maps the memory incorrectly.
*/
-  irb-region = intel_region_alloc(intel-intelScreen,
-  I915_TILING_Y,
-  cpp * 2,
-  width,
-  height / 2,
-  GL_TRUE);
+  struct intel_region *region = intel_region_alloc(intel-intelScreen,
+  I915_TILING_Y,
+  cpp * 2,
+  width,
+  height / 2,
+  true);
+  if (!region) {
+return false;
+  }
+  intel_region_reference(irb-region, region);
+
} else {
-  irb-region = intel_region_alloc(intel-intelScreen, tiling, cpp,
-  width, height, GL_TRUE);
+  struct intel_region *region =
+intel_region_alloc(intel-intelScreen, tiling, cpp,
+   width, height, true);
+  if (!region) {
+return false;
+  }
+  intel_region_reference(irb-region, region);
}
 
-   if (!irb-region)
-  return GL_FALSE;   /* out of memory? */
-
-   ASSERT(irb-region-buffer);
-
if (intel-vtbl.is_hiz_depth_format(intel, rb-Format)) {
-  irb-hiz_region = intel_region_alloc(intel-intelScreen,
-   I915_TILING_Y,
-   irb-region-cpp,
-   irb-region-width,
-   irb-region-height,
-   GL_TRUE);
-  if (!irb-hiz_region) {
+  struct intel_region *hiz_region =
+intel_region_alloc(intel-intelScreen,
+   I915_TILING_Y,
+   irb-region-cpp,
+   irb-region-width,
+   irb-region-height,
+   true);
+  if (!hiz_region) {
  intel_region_release(irb-region);
- return GL_FALSE;
+ return false;
   }
+  intel_region_reference(irb-hiz_region, hiz_region);
}
 
rb-Width = width;
-- 
1.7.5.2

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


[Mesa-dev] [PATCH 1/6] mesa: Add field gl_renderbuffer.Unwrapped

2011-06-15 Thread Chad Versace
If a renderbuffer wraps multiple renderbuffers, then Unwrapped points to
the them.

For example, if hardware requires separate depth and stencil buffers
(X8_Z24 and S8), then glRenderbufferStorage(GL_DEPTH24_STENCIL8) may
create a fake S8_Z24 renderbuffer for which Unwrapped[BUFFER_DEPTH] and
Unwrapped[BUFFER_STENCIL] point to the real X8_Z24 and S8 renderbuffers.

Alter the following function to take Unwrapped into account:
_mesa_framebuffer_renderbuffer
_mesa_update_depth_buffer
_mesa_update_stencil_buffer
_mesa_reference_renderbuffer

Signed-off-by: Chad Versace c...@chad-versace.us
---
 src/mesa/main/fbobject.c |   26 +---
 src/mesa/main/framebuffer.c  |   54 +++---
 src/mesa/main/mtypes.h   |   11 
 src/mesa/main/renderbuffer.c |6 
 4 files changed, 79 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 2230b26..61a0619 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -379,10 +379,28 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
if (rb) {
   _mesa_set_renderbuffer_attachment(ctx, att, rb);
   if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
- /* do stencil attachment here (depth already done above) */
- att = _mesa_get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT);
- assert(att);
- _mesa_set_renderbuffer_attachment(ctx, att, rb);
+struct gl_renderbuffer_attachment *depth_att =
+   _mesa_get_attachment(ctx, fb, GL_DEPTH_ATTACHMENT);
+struct gl_renderbuffer_attachment *stencil_att =
+   _mesa_get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT);
+struct gl_renderbuffer *depth_rb;
+struct gl_renderbuffer *stencil_rb;
+
+/* Set depth attachment. */
+if (rb-Unwrapped[BUFFER_DEPTH]) {
+   depth_rb = rb-Unwrapped[BUFFER_DEPTH];
+} else {
+   depth_rb = rb;
+}
+_mesa_set_renderbuffer_attachment(ctx, depth_att, depth_rb);
+
+/* Set stencil attachment. */
+if (rb-Unwrapped[BUFFER_STENCIL]) {
+   stencil_rb = rb-Unwrapped[BUFFER_STENCIL];
+} else {
+   stencil_rb = rb;
+}
+_mesa_set_renderbuffer_attachment(ctx, stencil_att, stencil_rb);
   }
   rb-AttachedAnytime = GL_TRUE;
}
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 66c9bd9..6e1f1f1 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -604,14 +604,20 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
 
 
 /**
- * Update the framebuffer's _DepthBuffer field using the renderbuffer
- * found at the given attachment index.
+ * \brief Update gl_framebuffer._DepthBuffer.
  *
- * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
- * create and install a depth wrapper/adaptor.
+ * Set gl_framebuffer._DepthBuffer to the attachment's renderbuffer, unless
+ * the renderbuffer has packed depth/stencil format.
+ *
+ * Renderbuffers with packed depth/stencil format are a special case. If the
+ * attachment's renderbuffer contains a depth unwrapper (that is,
+ * gl_renderbuffer.Unwrapper[BUFFER_DEPTH != NULL), then install the
+ * unwrapper. Otherwise, create and install a x8_z24 depth wrapper.
  *
  * \param fb  the framebuffer whose _DepthBuffer field to update
  * \param attIndex  indicates the renderbuffer to possibly wrap
+ *
+ * \see _mesa_new_z24_renderbuffer_wrapper
  */
 void
 _mesa_update_depth_buffer(struct gl_context *ctx,
@@ -627,9 +633,16 @@ _mesa_update_depth_buffer(struct gl_context *ctx,
 
if (depthRb  _mesa_is_format_packed_depth_stencil(depthRb-Format)) {
   /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
-  if (!fb-_DepthBuffer
-  || fb-_DepthBuffer-Wrapped != depthRb
-  || _mesa_get_format_base_format(fb-_DepthBuffer-Format) != 
GL_DEPTH_COMPONENT) {
+  struct gl_renderbuffer *unwrapper = depthRb-Unwrapped[BUFFER_DEPTH];
+  if (unwrapper) {
+if (fb-_DepthBuffer != unwrapper) {
+   _mesa_reference_renderbuffer(fb-_DepthBuffer, unwrapper);
+}
+  }
+  else if (!fb-_DepthBuffer
+  || fb-_DepthBuffer-Wrapped != depthRb
+  || _mesa_get_format_base_format(fb-_DepthBuffer-Format)
+ != GL_DEPTH_COMPONENT) {
  /* need to update wrapper */
  struct gl_renderbuffer *wrapper
 = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
@@ -645,14 +658,20 @@ _mesa_update_depth_buffer(struct gl_context *ctx,
 
 
 /**
- * Update the framebuffer's _StencilBuffer field using the renderbuffer
- * found at the given attachment index.
+ * \brief Update gl_framebuffer._StencilBuffer.
  *
- * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
- * create and install a stencil wrapper/adaptor.
+ * Set gl_framebuffer._StencilBuffer to the 

Re: [Mesa-dev] [PATCH] intel: Fix region refcounting in intel_alloc_renderbuffer_storage

2011-06-15 Thread Eric Anholt
On Wed, 15 Jun 2011 15:54:13 -0700, Chad Versace c...@chad-versace.us wrote:
 Replace instances of
 irb-region = region
 with
 intel_region_reference(irb-region, region)
 
 Signed-off-by: Chad Versace c...@chad-versace.us

intel_region_alloc returns something with a refcount of 1 -- the
reference you got from the return value.  You're now increasing its
reference on assignment, without decrementing its reference when you
exit the function and no longer need the reference inside the function.
In other words, this change doesn't make sense to me, as it looks like
you'll just leak a ref.


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


Re: [Mesa-dev] [PATCH 1/6] configure.ac: remove redundant option --enable-gallium-egl

2011-06-15 Thread Marek Olšák
On Thu, Jun 16, 2011 at 1:21 AM, Chia-I Wu olva...@gmail.com wrote:
 On Thu, Jun 16, 2011 at 7:04 AM, Marek Olšák mar...@gmail.com wrote:
 On Tue, Jun 14, 2011 at 10:35 PM, Benjamin Franzke
 benjaminfran...@googlemail.com wrote:
 Removing this flag seems right to me, but always building the egl
 state tracker when gallium and egl is enabled not.
 So when --with-state-trackers is also removed, we'd need a new
 --with-egl-drivers=auto|gallium,dri2,glx or so.

 Isn't --with-egl-platforms good enough to select among fbdev, wayland,
 one-day-maybe dri, ...? I don't see a reason for another option. You
 can choose between dri and xlib (st/glx) already using
 --with-driver=dri|xlib.
 OpenGL can be supported via both egl_dri2 and egl_gallium EGL drivers.
  The former is generally preferred for various reasons.  However, when
 both drivers exist, there is no automatic way to make EGL chooses the
 former.  Thus it is desirable to be able to disable egl_gallium in the
 first place.

Why not to use egl_dri2 for all drivers, the classic and gallium ones?

Why not to build a single fully-replaceable binary for a driver, like
classic swrast_dri.so can be replaced by swrastg_dri.so from Gallium?
Like radeon_drv.so from xf86-video-ati can be replaced by r300_drv.so
from Gallium?

I thought it had been agreed long ago that Gallium is a private
unstable interface inside drivers and shouldn't be exposed publicly in
any way. With that, I see no reason for egl_gallium.so to exist.

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


Re: [Mesa-dev] Status of the GLSL-TGSI translator

2011-06-15 Thread Tom Stellard
On Wed, Jun 15, 2011 at 04:38:07PM -0500, Bryan Cain wrote:
 My work on the GLSL IR to TGSI translator I announced on the list this
 April is now at the point where I think it is ready to be merged into
 Mesa.  It is stable and doesn't regress any piglit tests on softpipe or
 nv50.
 

Hi,

First of all, nice work on this.  It's great to have one less IR to deal
with.  Just two comments:

1. This branch causes a few piglit regressions on R300 because there is no
optimization pass equivalent to _mesa_simplify_cmp() in st_glsl_to_tgsi(I
guess technically it's not really an optimization pass, since R300
needs it to function).  Would you be able to add something similar
in st_glsl_to_tgsi?  It should be really easy.  You can ping me on irc
(tstellar) if you have any questions about it.

2. There are a number of whitespace errors.  Things like spaces and tabs
on empty lines or a mixture of tabs and spaces for indentation.  It
looks like a number of them were inherited from st_mesa_to_tgsi.c, and
I don't think you need to worry about fixing them, but it's
something to keep in mind as you are making more changes.  If you add:

Hilight trailing whitespace
:highlight ExtraWhitespace ctermbg=red guibg=red
:autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/

to your .vimrc, you'll see what I'm talking about.

-Tom


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


Re: [Mesa-dev] leak of gem_objects on intel i965

2011-06-15 Thread Chad Versace
On Wed, 15 Jun 2011 10:53:13 +0200, Lampersperger Andreas 
lampersperger.andr...@heidenhain.de wrote:
 Hello,
 
 I've tried 2.6.39.1 and the gem_objects leak still exists.
 
 I found the leak also on a i915 not only on a i965.

I recommend focusing your debugging efforts on i965. If we solve the
problem in the new driver, and still find that the leaks occur in the
old driver, only then should we begin digging through the old driver.
 
 It only disappears if I set LIBGL_ALLWAYS_SOFTWARE (not really an
 opinion ;-).

Nope ;)
 
 Now I can try to update user space libraries, what lib would you suspect most?
 
 libdrm 2.4.23
 xorg-server 1.10.2
 xf86-video-intel-2.15
 gtkglext-1.2.0
 mesa-7.10.2

xorg-server: I highly doubt this is guilty.

libdrm: All calls out to libdrm are made directly by xf86-video-intel or
mesa. So, if a problem exists with libdrm, that problem will be solved
by debugging xf86-video-intel or mesa.

gtkglext: Can't say.

xf86-video-intel and mesa: Likely culprits. I am more suspicious of Mesa
than the X driver.
 
 Or I can continue debugging, if anyone can give me a hint to the
 following question:

Great!

 In which function are the buffers freed, which are received 
 from xserver via DRI2GetBuffersWithFormat(..) at dri2.c:431?
 -Andreas

Ah... In Mesa, the buffers are never freed, actually. Mesa just
decrements the gem buffer's refcount with drm_intel_bo_unreference(),
and the kernel does the freeing at garbage collection. (Chris,
correct me if I'm wrong here.)

The buffers obtained by DRI2GetBuffersWithFormat get referenced in
exactly one location. Here's the callstack, as I understand it. gem_bo
means gem buffer object.

intel_udpate_renderbuffers
intel_query_dri2_buffers_no_separate_stencil
dri2GetBuffersWithFormat
DRI2GetBuffersWithFormat # Referencing happens later
intel_process_dri2_buffers_no_separate_stencil
intel_region_alloc_for_handle
intel_bo_gem_create_from_name
drm_intel_gem_bo_reference # Reference gem buffer
intel_renderbuffer_set_region
intel_region_reference # Reference current region
intel_region_release # Release old region
drm_intel_bo_unreference # Release old gem buffer

The buffers can get released from two possible paths: 1) The
intel_update_renderbuffers path above, and 2) from within
intel_delete_renderbuffer().

Good luck chasing this down. And don't prematurely eliminate the
possiblity that the problem may lie in xf86-video-intel or gtkglext.

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


Re: [Mesa-dev] leak of gem_objects on intel i965

2011-06-15 Thread Stéphane Marchesin
On Wed, Jun 15, 2011 at 01:53, Lampersperger Andreas 
lampersperger.andr...@heidenhain.de wrote:

 Hello,

 I've tried 2.6.39.1 and the gem_objects leak still exists.

 I found the leak also on a i915 not only on a i965.

 It only disappears if I set LIBGL_ALLWAYS_SOFTWARE (not really an opinion
 ;-).

 Now I can try to update user space libraries, what lib would you suspect
 most?

 libdrm 2.4.23
 xorg-server 1.10.2
 xf86-video-intel-2.15
 gtkglext-1.2.0
 mesa-7.10.2

 Or I can continue debugging, if anyone can give me a hint to the following
 question:

 In which function are the buffers freed, which are received
 from xserver via DRI2GetBuffersWithFormat(..) at dri2.c:431?


This sounds familiar. You may want to try the patch I posted earlied today
(glx: implement drawable refcounting).

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


Re: [Mesa-dev] [PATCH 1/6] configure.ac: remove redundant option --enable-gallium-egl

2011-06-15 Thread Chia-I Wu
On Thu, Jun 16, 2011 at 10:20 AM, Marek Olšák mar...@gmail.com wrote:
 On Thu, Jun 16, 2011 at 1:21 AM, Chia-I Wu olva...@gmail.com wrote:
 On Thu, Jun 16, 2011 at 7:04 AM, Marek Olšák mar...@gmail.com wrote:
 On Tue, Jun 14, 2011 at 10:35 PM, Benjamin Franzke
 benjaminfran...@googlemail.com wrote:
 Removing this flag seems right to me, but always building the egl
 state tracker when gallium and egl is enabled not.
 So when --with-state-trackers is also removed, we'd need a new
 --with-egl-drivers=auto|gallium,dri2,glx or so.

 Isn't --with-egl-platforms good enough to select among fbdev, wayland,
 one-day-maybe dri, ...? I don't see a reason for another option. You
 can choose between dri and xlib (st/glx) already using
 --with-driver=dri|xlib.
 OpenGL can be supported via both egl_dri2 and egl_gallium EGL drivers.
  The former is generally preferred for various reasons.  However, when
 both drivers exist, there is no automatic way to make EGL chooses the
 former.  Thus it is desirable to be able to disable egl_gallium in the
 first place.

 Why not to use egl_dri2 for all drivers, the classic and gallium ones?

 Why not to build a single fully-replaceable binary for a driver, like
 classic swrast_dri.so can be replaced by swrastg_dri.so from Gallium?
 Like radeon_drv.so from xf86-video-ati can be replaced by r300_drv.so
 from Gallium?

 I thought it had been agreed long ago that Gallium is a private
 unstable interface inside drivers and shouldn't be exposed publicly in
 any way. With that, I see no reason for egl_gallium.so to exist.
egl_gallium supports OpenVG and some EGL extensions not supported by
egl_dri2.  SCons's build of egl_gallium does not expose any internal
interface.  I can(/should have) adjust autoconf-based build not to
too.

Maybe we can have egl_dri2 enabled and egl_gallium disabled when
--enable-egl, and has the option to enable egl_gallium?  Then maybe
have --enable-openvg depend on egl_gallium?

 Marek


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