Mesa (master): gallium: add llvm-related TODOs. (v2)

2012-03-06 Thread Dave Airlie
Module: Mesa
Branch: master
Commit: 357afb68e42f0d2746d0f57a9aeed4188fccd4a1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=357afb68e42f0d2746d0f57a9aeed4188fccd4a1

Author: Dave Airlie airl...@redhat.com
Date:   Sun Mar  4 13:55:43 2012 +

gallium: add llvm-related TODOs. (v2)

This is just a simple text file containing a list of goals for gallivm/llvmpipe
and some info on what is required to get there along with some info on who
is looking at things.

v2: add EXT_texture_array.

Signed-off-by: Dave Airlie airl...@redhat.com
Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/docs/llvm-todo.txt |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/gallium/docs/llvm-todo.txt b/src/gallium/docs/llvm-todo.txt
new file mode 100644
index 000..a5a8c1a
--- /dev/null
+++ b/src/gallium/docs/llvm-todo.txt
@@ -0,0 +1,21 @@
+TODO covering gallivm/llvmpipe
+==
+
+Goal: GL3.0 support in llvmpipe
+---
+
+TXQ opcode support - airlied WIP
+TXF opcode support.
+Integer texture fetch support
+Integer renderbuffer support
+Vertex ID support.
+EXT_transform_feedback support - airlied WIP
+clip distance support - airlied WIP
+vertex clip support - airlied WIP
+EXT_texture_array support - Jakob WIP
+
+Goal: extension parity with softpipe:
+-
+GL3.0 support.
+EXT_timer_query - airlied posted a patch
+

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


Mesa (master): draw/llvm: fix clipvertex setting up clipmask. (v2)

2012-03-06 Thread Dave Airlie
Module: Mesa
Branch: master
Commit: cb4bcbcb1dbe2ad0046e695f771b56b4467e2c85
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb4bcbcb1dbe2ad0046e695f771b56b4467e2c85

Author: Dave Airlie airl...@redhat.com
Date:   Sat Mar  3 16:58:47 2012 +

draw/llvm: fix clipvertex setting up clipmask. (v2)

We incorrectly setup clipmask for gl_ClipVertex, this fixes the clipmask
setup.

v2: fix comment

Signed-off-by: Dave Airlie airl...@redhat.com
Reviewed-by: Brian Paul bri...@vmware.com

fix comment

---

 src/gallium/auxiliary/draw/draw_llvm.c |   41 +++
 1 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index f0646ac..b306515 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1041,7 +1041,7 @@ generate_viewport(struct draw_llvm *llvm,
  * Returns clipmask as 4xi32 bitmask for the 4 vertices
  */
 static LLVMValueRef 
-generate_clipmask(struct gallivm_state *gallivm,
+generate_clipmask(struct draw_llvm *llvm,
   LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS],
   boolean clip_xy,
   boolean clip_z,
@@ -1050,24 +1050,43 @@ generate_clipmask(struct gallivm_state *gallivm,
   unsigned ucp_enable,
   LLVMValueRef context_ptr)
 {
+   struct gallivm_state *gallivm = llvm-gallivm;
LLVMBuilderRef builder = gallivm-builder;
LLVMValueRef mask; /* stores the 4xi32 clipmasks */ 
LLVMValueRef test, temp; 
LLVMValueRef zero, shift;
LLVMValueRef pos_x, pos_y, pos_z, pos_w;
+   LLVMValueRef cv_x, cv_y, cv_z, cv_w;
LLVMValueRef plane1, planes, plane_ptr, sum;
struct lp_type f32_type = lp_type_float_vec(32); 
+   const unsigned pos = draw_current_shader_position_output(llvm-draw);
+   const unsigned cv = draw_current_shader_clipvertex_output(llvm-draw);
 
mask = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 0);
temp = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 0);
zero = lp_build_const_vec(gallivm, f32_type, 0);/* 0.0f 
0.0f 0.0f 0.0f */
shift = lp_build_const_int_vec(gallivm, lp_type_int_vec(32), 1);/* 1 1 
1 1 */
 
-   /* Assuming position stored at output[0] */
-   pos_x = LLVMBuildLoad(builder, outputs[0][0], ); /*x0 x1 x2 x3*/
-   pos_y = LLVMBuildLoad(builder, outputs[0][1], ); /*y0 y1 y2 y3*/
-   pos_z = LLVMBuildLoad(builder, outputs[0][2], ); /*z0 z1 z2 z3*/
-   pos_w = LLVMBuildLoad(builder, outputs[0][3], ); /*w0 w1 w2 w3*/   
+   /*
+* load clipvertex and position from correct locations.
+* if they are the same just load them once.
+*/
+   pos_x = LLVMBuildLoad(builder, outputs[pos][0], ); /*x0 x1 x2 x3*/
+   pos_y = LLVMBuildLoad(builder, outputs[pos][1], ); /*y0 y1 y2 y3*/
+   pos_z = LLVMBuildLoad(builder, outputs[pos][2], ); /*z0 z1 z2 z3*/
+   pos_w = LLVMBuildLoad(builder, outputs[pos][3], ); /*w0 w1 w2 w3*/
+
+   if (clip_user  cv != pos) {
+  cv_x = LLVMBuildLoad(builder, outputs[cv][0], ); /*x0 x1 x2 x3*/
+  cv_y = LLVMBuildLoad(builder, outputs[cv][1], ); /*y0 y1 y2 y3*/
+  cv_z = LLVMBuildLoad(builder, outputs[cv][2], ); /*z0 z1 z2 z3*/
+  cv_w = LLVMBuildLoad(builder, outputs[cv][3], ); /*w0 w1 w2 w3*/
+   } else {
+  cv_x = pos_x;
+  cv_y = pos_y;
+  cv_z = pos_z;
+  cv_w = pos_w;
+   }
 
/* Cliptest, for hardwired planes */
if (clip_xy) {
@@ -1137,27 +1156,27 @@ generate_clipmask(struct gallivm_state *gallivm,
  plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, );
  plane1 = LLVMBuildLoad(builder, plane_ptr, plane_x);
  planes = vec4f_from_scalar(gallivm, plane1, plane4_x);
- sum = LLVMBuildFMul(builder, planes, pos_x, );
+ sum = LLVMBuildFMul(builder, planes, cv_x, );
 
  indices[2] = lp_build_const_int32(gallivm, 1);
  plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, );
  plane1 = LLVMBuildLoad(builder, plane_ptr, plane_y); 
  planes = vec4f_from_scalar(gallivm, plane1, plane4_y);
- test = LLVMBuildFMul(builder, planes, pos_y, );
+ test = LLVMBuildFMul(builder, planes, cv_y, );
  sum = LLVMBuildFAdd(builder, sum, test, );
  
  indices[2] = lp_build_const_int32(gallivm, 2);
  plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, );
  plane1 = LLVMBuildLoad(builder, plane_ptr, plane_z); 
  planes = vec4f_from_scalar(gallivm, plane1, plane4_z);
- test = LLVMBuildFMul(builder, planes, pos_z, );
+ test = LLVMBuildFMul(builder, planes, cv_z, );
  sum = LLVMBuildFAdd(builder, sum, test, );
 
  indices[2] = lp_build_const_int32(gallivm, 3);
  plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, );
  plane1 = LLVMBuildLoad(builder, plane_ptr, plane_w); 
  planes = vec4f_from_scalar(gallivm, plane1, 

Mesa (master): draw/llvm: fix storing of clipvertex and positions into pre_clip_pos (v2)

2012-03-06 Thread Dave Airlie
Module: Mesa
Branch: master
Commit: 9c465a95ac612b346759d35fd58a9edbb79eef67
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c465a95ac612b346759d35fd58a9edbb79eef67

Author: Dave Airlie airl...@redhat.com
Date:   Sat Mar  3 17:07:07 2012 +

draw/llvm: fix storing of clipvertex and positions into pre_clip_pos (v2)

This fixes the rest of the piglit clipvertex tests.

v2: fixup comments.

Signed-off-by: Dave Airlie airl...@redhat.com
Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/auxiliary/draw/draw_llvm.c |   19 +++
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index b306515..d2b6799 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -894,12 +894,14 @@ convert_to_aos(struct gallivm_state *gallivm,
  * Stores original vertex positions in clip coordinates
  * There is probably a more efficient way to do this, 4 floats at once
  * rather than extracting each element one by one.
+ * idx is the output to store things too, if pre_clip_pos is set
+ * we store the pos to the idx, if not we store the clipvertex to it.
  */
 static void
 store_clip(struct gallivm_state *gallivm,
LLVMValueRef io_ptr,   
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS],
-   boolean pre_clip_pos)
+   boolean pre_clip_pos, int idx)
 {
LLVMBuilderRef builder = gallivm-builder;
LLVMValueRef out[4];
@@ -918,17 +920,16 @@ store_clip(struct gallivm_state *gallivm,
indices[0] =
indices[1] = lp_build_const_int32(gallivm, 0);

-   out[0] = LLVMBuildLoad(builder, outputs[0][0], ); /*x0 x1 x2 x3*/
-   out[1] = LLVMBuildLoad(builder, outputs[0][1], ); /*y0 y1 y2 y3*/
-   out[2] = LLVMBuildLoad(builder, outputs[0][2], ); /*z0 z1 z2 z3*/
-   out[3] = LLVMBuildLoad(builder, outputs[0][3], ); /*w0 w1 w2 w3*/  
+   out[0] = LLVMBuildLoad(builder, outputs[idx][0], ); /*x0 x1 x2 x3*/
+   out[1] = LLVMBuildLoad(builder, outputs[idx][1], ); /*y0 y1 y2 y3*/
+   out[2] = LLVMBuildLoad(builder, outputs[idx][2], ); /*z0 z1 z2 z3*/
+   out[3] = LLVMBuildLoad(builder, outputs[idx][3], ); /*w0 w1 w2 w3*/
 
io0_ptr = LLVMBuildGEP(builder, io_ptr, ind0, 1, );
io1_ptr = LLVMBuildGEP(builder, io_ptr, ind1, 1, );
io2_ptr = LLVMBuildGEP(builder, io_ptr, ind2, 1, );
io3_ptr = LLVMBuildGEP(builder, io_ptr, ind3, 1, );
 
-   /* FIXME: this needs updating for clip vertex support */
if (!pre_clip_pos) {
   clip_ptr0 = draw_jit_header_clip(gallivm, io0_ptr);
   clip_ptr1 = draw_jit_header_clip(gallivm, io1_ptr);
@@ -1249,6 +1250,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
variant-key.clip_z  ||
variant-key.clip_user;
LLVMValueRef variant_func;
+   const unsigned pos = draw_current_shader_position_output(llvm-draw);
+   const unsigned cv = draw_current_shader_clipvertex_output(llvm-draw);
 
arg_types[0] = get_context_ptr_type(llvm);   /* context */
arg_types[1] = get_vertex_header_ptr_type(llvm); /* vertex_header */
@@ -1402,8 +1405,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
   variant-key.clamp_vertex_color);
 
   /* store original positions in clip before further manipulation */
-  store_clip(gallivm, io, outputs, 0);
-  store_clip(gallivm, io, outputs, 1);
+  store_clip(gallivm, io, outputs, 0, cv);
+  store_clip(gallivm, io, outputs, 1, pos);
 
   /* do cliptest */
   if (enable_cliptest) {

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


Mesa (master): draw/llvm: add clip distance support

2012-03-06 Thread Dave Airlie
Module: Mesa
Branch: master
Commit: ef3e26c2e43a000d5e5e6b673324b0ebdc918207
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef3e26c2e43a000d5e5e6b673324b0ebdc918207

Author: Dave Airlie airl...@redhat.com
Date:   Sat Mar  3 17:35:43 2012 +

draw/llvm: add clip distance support

This add clipdistance support like the non-llvm draw paths,
if we have a clip distance we compare with it instead of doing
the dot4.

We also have to put the have_clipvertex bit into the emitted
vertex header.

Fixes vs-clip-distance-all-planes-enabled, vs-clip-distance-const-reject,
vs-clip-distance-enables, vs-clip-distance-implicitly-sized,
vs-clip-distance-in-param, vs-clip-distance-uint-index.

Signed-off-by: Dave Airlie airl...@redhat.com
Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/auxiliary/draw/draw_llvm.c |  123 
 1 files changed, 77 insertions(+), 46 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index d2b6799..620d6dc 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -720,7 +720,7 @@ store_aos(struct gallivm_state *gallivm,
   LLVMValueRef io_ptr,
   LLVMValueRef index,
   LLVMValueRef value,
-  LLVMValueRef clipmask)
+  LLVMValueRef clipmask, boolean have_clipdist)
 {
LLVMBuilderRef builder = gallivm-builder;
LLVMValueRef id_ptr = draw_jit_header_id(gallivm, io_ptr);
@@ -737,8 +737,10 @@ store_aos(struct gallivm_state *gallivm,
 * code here.  See struct vertex_header in draw_private.h.
 */
assert(DRAW_TOTAL_CLIP_PLANES==14);
-   /* initialize vertex id:16 = 0x, pad:1 = 0, edgeflag:1 = 1 */
+   /* initialize vertex id:16 = 0x, have_clipdist:1 = 0, edgeflag:1 = 1 */
vertex_id_pad_edgeflag = (0x  16) | (1  DRAW_TOTAL_CLIP_PLANES);
+   if (have_clipdist)
+  vertex_id_pad_edgeflag |= 1  (DRAW_TOTAL_CLIP_PLANES+1);
val = lp_build_const_int32(gallivm, vertex_id_pad_edgeflag);
/* OR with the clipmask */
val = LLVMBuildOr(builder, val, clipmask, );   
@@ -802,7 +804,8 @@ store_aos_array(struct gallivm_state *gallivm,
 LLVMValueRef aos[TGSI_NUM_CHANNELS],
 int attrib,
 int num_outputs,
-LLVMValueRef clipmask)
+LLVMValueRef clipmask,
+boolean have_clipdist)
 {
LLVMBuilderRef builder = gallivm-builder;
LLVMValueRef attr_index = lp_build_const_int32(gallivm, attrib);
@@ -838,10 +841,10 @@ store_aos_array(struct gallivm_state *gallivm,
io_ptr, ind0, ind1, ind2, ind3, clipmask0, clipmask1, 
clipmask2, clipmask3);
 #endif
/* store for each of the 4 vertices */
-   store_aos(gallivm, io0_ptr, attr_index, aos[0], clipmask0);
-   store_aos(gallivm, io1_ptr, attr_index, aos[1], clipmask1);
-   store_aos(gallivm, io2_ptr, attr_index, aos[2], clipmask2);
-   store_aos(gallivm, io3_ptr, attr_index, aos[3], clipmask3);
+   store_aos(gallivm, io0_ptr, attr_index, aos[0], clipmask0, have_clipdist);
+   store_aos(gallivm, io1_ptr, attr_index, aos[1], clipmask1, have_clipdist);
+   store_aos(gallivm, io2_ptr, attr_index, aos[2], clipmask2, have_clipdist);
+   store_aos(gallivm, io3_ptr, attr_index, aos[3], clipmask3, have_clipdist);
 }
 
 
@@ -851,7 +854,7 @@ convert_to_aos(struct gallivm_state *gallivm,
LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS],
LLVMValueRef clipmask,
int num_outputs,
-   int max_vertices)
+   int max_vertices, boolean have_clipdist)
 {
LLVMBuilderRef builder = gallivm-builder;
unsigned chan, attrib;
@@ -882,7 +885,7 @@ convert_to_aos(struct gallivm_state *gallivm,
   aos,
   attrib,
   num_outputs,
-  clipmask);
+  clipmask, have_clipdist);
}
 #if DEBUG_STORE
lp_build_printf(builder,# storing end\n);
@@ -1049,7 +1052,8 @@ generate_clipmask(struct draw_llvm *llvm,
   boolean clip_user,
   boolean clip_halfz,
   unsigned ucp_enable,
-  LLVMValueRef context_ptr)
+  LLVMValueRef context_ptr,
+  boolean *have_clipdist)
 {
struct gallivm_state *gallivm = llvm-gallivm;
LLVMBuilderRef builder = gallivm-builder;
@@ -1062,6 +1066,15 @@ generate_clipmask(struct draw_llvm *llvm,
struct lp_type f32_type = lp_type_float_vec(32); 
const unsigned pos = draw_current_shader_position_output(llvm-draw);
const unsigned cv = draw_current_shader_clipvertex_output(llvm-draw);
+   int num_written_clipdistance = 
llvm-draw-vs.vertex_shader-info.num_written_clipdistance;
+   bool have_cd = false;
+   unsigned cd[2];
+
+   cd[0] = draw_current_shader_clipdistance_output(llvm-draw, 0);
+   cd[1] = draw_current_shader_clipdistance_output(llvm-draw, 1);
+  

Mesa (master): gallivm: Pass in a MCRegisterInfo to MCInstPrinter on llvm-3 .1.

2012-03-06 Thread Vinson Lee
Module: Mesa
Branch: master
Commit: 1633dcd890d97bd5e4d125d57f2f529f04d14477
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1633dcd890d97bd5e4d125d57f2f529f04d14477

Author: Vinson Lee v...@freedesktop.org
Date:   Mon Mar  5 22:00:40 2012 -0800

gallivm: Pass in a MCRegisterInfo to MCInstPrinter on llvm-3.1.

llvm-3.1svn r152043 changes createMCInstPrinter to take an additional
MCRegisterInfo argument.

Signed-off-by: Vinson Lee v...@freedesktop.org
Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/auxiliary/gallivm/lp_bld_debug.cpp |   13 -
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp 
b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
index 11209da..b6849cb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
@@ -243,7 +243,18 @@ lp_disassemble(const void* func)
int AsmPrinterVariant = AsmInfo-getAssemblerDialect();
 #endif
 
-#if HAVE_LLVM = 0x0300
+#if HAVE_LLVM = 0x0301
+   OwningPtrconst MCRegisterInfo MRI(T-createMCRegInfo(Triple));
+   if (!MRI) {
+  debug_printf(error: no register info for target %s\n, Triple.c_str());
+  return;
+   }
+#endif
+
+#if HAVE_LLVM = 0x0301
+   OwningPtrMCInstPrinter Printer(
+ T-createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *MRI, *STI));
+#elif HAVE_LLVM == 0x0300
OwningPtrMCInstPrinter Printer(
  T-createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *STI));
 #elif HAVE_LLVM = 0x0208

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


Mesa (master): dri/nouveau: don't use nested functions

2012-03-06 Thread Francisco Jerez
Module: Mesa
Branch: master
Commit: 4aa1ac5fe94b5696095229ee3568bf4fa7cfed95
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4aa1ac5fe94b5696095229ee3568bf4fa7cfed95

Author: nobled nob...@dreamwidth.org
Date:   Sun Mar  4 15:20:31 2012 -0500

dri/nouveau: don't use nested functions

It's a GNU extension that isn't supported by clang right now:
http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/Nested-Functions.html
http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc

With this, clang now compiles the nouveau classic driver.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44061

(Types changed from e.g. 'unsigned char' to 'GLubyte' so that the types can
be concatenated to form a unique function name without any whitespace
interfering.)

[ Francisco Jerez: give meaningful names to the dispatch functions. ]

---

 src/mesa/drivers/dri/nouveau/nouveau_array.c|   67 +
 src/mesa/drivers/dri/nouveau/nouveau_render_t.c |   75 +++
 2 files changed, 78 insertions(+), 64 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_array.c 
b/src/mesa/drivers/dri/nouveau/nouveau_array.c
index 17e6d16..d9253b0 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_array.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_array.c
@@ -29,54 +29,71 @@
 #include nouveau_array.h
 #include nouveau_bufferobj.h
 
+#define EXTRACT(in_t, out_t) extract_func_##in_t##_to_##out_t
+
+#define EXTRACT_FUNC(in_t, out_t, k)   \
+static out_t EXTRACT(in_t, out_t)  \
+(struct nouveau_array *a, int i, int j) {  \
+   in_t x = ((in_t *)(a-buf + i * a-stride))[j]; \
+   \
+   return (out_t)x / (k);  \
+}
+
+EXTRACT_FUNC(GLchar, unsigned, 1);
+EXTRACT_FUNC(GLchar, float, SCHAR_MAX);
+EXTRACT_FUNC(GLubyte, unsigned, 1);
+EXTRACT_FUNC(GLubyte, float, UCHAR_MAX);
+EXTRACT_FUNC(GLshort, unsigned, 1);
+EXTRACT_FUNC(GLshort, float, SHRT_MAX);
+EXTRACT_FUNC(GLushort, unsigned, 1);
+EXTRACT_FUNC(GLushort, float, USHRT_MAX);
+EXTRACT_FUNC(GLint, unsigned, 1);
+EXTRACT_FUNC(GLint, float, INT_MAX);
+EXTRACT_FUNC(GLuint, unsigned, 1);
+EXTRACT_FUNC(GLuint, float, UINT_MAX);
+EXTRACT_FUNC(GLfloat, unsigned, 1.0 / UINT_MAX);
+EXTRACT_FUNC(GLfloat, float, 1);
+
+#undef EXTRACT_FUNC
+
 static void
 get_array_extract(struct nouveau_array *a, extract_u_t *extract_u,
  extract_f_t *extract_f)
 {
-#define EXTRACT(in_t, out_t, k)
\
-   ({  \
-   auto out_t f(struct nouveau_array *, int, int); \
-   out_t f(struct nouveau_array *a, int i, int j) {\
-   in_t x = ((in_t *)(a-buf + i * a-stride))[j]; \
-   \
-   return (out_t)x / (k);  \
-   };  \
-   f;  \
-   });
-
switch (a-type) {
case GL_BYTE:
-   *extract_u = EXTRACT(char, unsigned, 1);
-   *extract_f = EXTRACT(char, float, SCHAR_MAX);
+   *extract_u = EXTRACT(GLchar, unsigned);
+   *extract_f = EXTRACT(GLchar, float);
break;
case GL_UNSIGNED_BYTE:
-   *extract_u = EXTRACT(unsigned char, unsigned, 1);
-   *extract_f = EXTRACT(unsigned char, float, UCHAR_MAX);
+   *extract_u = EXTRACT(GLubyte, unsigned);
+   *extract_f = EXTRACT(GLubyte, float);
break;
case GL_SHORT:
-   *extract_u = EXTRACT(short, unsigned, 1);
-   *extract_f = EXTRACT(short, float, SHRT_MAX);
+   *extract_u = EXTRACT(GLshort, unsigned);
+   *extract_f = EXTRACT(GLshort, float);
break;
case GL_UNSIGNED_SHORT:
-   *extract_u = EXTRACT(unsigned short, unsigned, 1);
-   *extract_f = EXTRACT(unsigned short, float, USHRT_MAX);
+   *extract_u = EXTRACT(GLushort, unsigned);
+   *extract_f = EXTRACT(GLushort, float);
break;
case GL_INT:
-   *extract_u = EXTRACT(int, unsigned, 1);
-   *extract_f = EXTRACT(int, float, INT_MAX);
+   *extract_u = EXTRACT(GLint, unsigned);
+   *extract_f = EXTRACT(GLint, float);
break;
case GL_UNSIGNED_INT:
-   *extract_u = EXTRACT(unsigned int, unsigned, 1);
-   *extract_f = EXTRACT(unsigned int, float, UINT_MAX);
+   *extract_u = EXTRACT(GLuint, unsigned);
+   *extract_f = EXTRACT(GLuint, float);
break;
case GL_FLOAT:
-   *extract_u = EXTRACT(float, unsigned, 1.0 / 

Mesa (master): i915: move the FALLBACK_DRAW_OFFSET check outside the drawing rect check

2012-03-06 Thread Yuanhan Liu
Module: Mesa
Branch: master
Commit: cf2f9ef015c312ecaa6656519602ae535f7ce9d7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf2f9ef015c312ecaa6656519602ae535f7ce9d7

Author: Yuanhan Liu yuanhan@linux.intel.com
Date:   Tue Mar  6 14:40:32 2012 +0800

i915: move the FALLBACK_DRAW_OFFSET check outside the drawing rect check

We have to do fallback when the 'Clipped Drawing Rectangle X/Y Max'
exceed the hardware's limit no matter the drawing rectangle offset
changed or not.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=46665

NOTE: This is a candidate for stable release branches.

Signed-off-by: Yuanhan Liu yuanhan@linux.intel.com
Reviewed-by: Eric Anholt e...@anholt.net

---

 src/mesa/drivers/dri/i915/i915_vtbl.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c 
b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 11e8a35..e78dbc8 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -665,12 +665,11 @@ i915_set_draw_region(struct intel_context *intel,
 
draw_offset = (draw_y  16) | draw_x;
 
+   FALLBACK(intel, I915_FALLBACK_DRAW_OFFSET,
+(ctx-DrawBuffer-Width + draw_x  2048) ||
+(ctx-DrawBuffer-Height + draw_y  2048));
/* When changing drawing rectangle offset, an MI_FLUSH is first required. */
if (draw_offset != i915-last_draw_offset) {
-  FALLBACK(intel, I915_FALLBACK_DRAW_OFFSET,
-   (ctx-DrawBuffer-Width + draw_x  2048) ||
-   (ctx-DrawBuffer-Height + draw_y  2048));
-
   state-Buffer[I915_DESTREG_DRAWRECT0] = MI_FLUSH | 
INHIBIT_FLUSH_RENDER_CACHE;
   i915-last_draw_offset = draw_offset;
} else

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


Mesa (master): i965: handle gl_PointCoord for Gen4 and Gen5 platforms

2012-03-06 Thread Yuanhan Liu
Module: Mesa
Branch: master
Commit: 43af02ac731dac7d80f7e47feb0c80e4da156769
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=43af02ac731dac7d80f7e47feb0c80e4da156769

Author: Yuanhan Liu yuanhan@linux.intel.com
Date:   Mon Feb 27 15:46:32 2012 +0800

i965: handle gl_PointCoord for Gen4 and Gen5 platforms

This patch add the support of gl_PointCoord gl builtin variable for
platform gen4 and gen5(ILK).

Unlike gen6+, we don't have a hardware support of gl_PointCoord, means
hardware will not calculate the interpolation coefficient for you.
Instead, you should handle it yourself in sf shader stage.

But badly, gl_PointCoord is a FS instead of VS builtin variable, thus
it's not included in c.vue_map generated in VS stage. Thus the current
code doesn't aware of this attribute. And to handle it correctly, we
need add it to c.vue_map manually to let SF shader generate the needed
interpolation coefficient for FS shader. SF stage has it's own copy of
vue_map, thus I think it's safe to do it manually.

Since handling gl_PointCoord for gen4 and gen5 platforms is somehow a
little special, I added a lot of comments and hope I didn't overdo it ;)

v2: add a /* _NEW_BUFFERS */ comment to note the state flag dependency
and also add the _NEW_BUFFERS dirty mask (Eric).

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45975
Piglit: glsl-fs-pointcoord and fbo-gl_pointcoord

NOTE: This is a candidate for stable release branches.

Signed-off-by: Yuanhan Liu yuanhan@linux.intel.com
Reviewed-by: Eric Anholt e...@anholt.net

---

 src/mesa/drivers/dri/i965/brw_context.h |6 ++
 src/mesa/drivers/dri/i965/brw_fs.cpp|9 +
 src/mesa/drivers/dri/i965/brw_sf.c  |   30 +-
 src/mesa/drivers/dri/i965/brw_sf.h  |1 +
 src/mesa/drivers/dri/i965/brw_sf_emit.c |4 
 5 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index a16145b..0c50b6b 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -296,6 +296,12 @@ typedef enum
BRW_VERT_RESULT_NDC = VERT_RESULT_MAX,
BRW_VERT_RESULT_HPOS_DUPLICATE,
BRW_VERT_RESULT_PAD,
+   /*
+* It's actually not a vert_result but just a _mark_ to let sf aware that
+* he need do something special to handle gl_PointCoord builtin variable
+* correctly. see compile_sf_prog() for more info.
+*/
+   BRW_VERT_RESULT_PNTC,
BRW_VERT_RESULT_MAX
 } brw_vert_result;
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index bf59da3..5f3d79d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -710,6 +710,15 @@ fs_visitor::calculate_urb_setup()
   urb_setup[fp_index] = urb_next++;
 }
   }
+
+  /*
+   * It's a FS only attribute, and we did interpolation for this attribute
+   * in SF thread. So, count it here, too.
+   *
+   * See compile_sf_prog() for more info.
+   */
+  if (brw-fragment_program-Base.InputsRead  
BITFIELD64_BIT(FRAG_ATTRIB_PNTC))
+ urb_setup[FRAG_ATTRIB_PNTC] = urb_next++;
}
 
/* Each attribute is 4 setup channels, each of which is half a reg. */
diff --git a/src/mesa/drivers/dri/i965/brw_sf.c 
b/src/mesa/drivers/dri/i965/brw_sf.c
index 6e63583..37d1ee5 100644
--- a/src/mesa/drivers/dri/i965/brw_sf.c
+++ b/src/mesa/drivers/dri/i965/brw_sf.c
@@ -64,6 +64,16 @@ static void compile_sf_prog( struct brw_context *brw,
 
c.key = *key;
c.vue_map = brw-vs.prog_data-vue_map;
+   if (c.key.do_point_coord) {
+  /*
+   * gl_PointCoord is a FS instead of VS builtin variable, thus it's
+   * not included in c.vue_map generated in VS stage. Here we add
+   * it manually to let SF shader generate the needed interpolation
+   * coefficient for FS shader.
+   */
+  c.vue_map.vert_result_to_slot[BRW_VERT_RESULT_PNTC] = 
c.vue_map.num_slots;
+  c.vue_map.slot_to_vert_result[c.vue_map.num_slots++] = 
BRW_VERT_RESULT_PNTC;
+   }
c.urb_entry_read_offset = brw_sf_compute_urb_entry_read_offset(intel);
c.nr_attr_regs = (c.vue_map.num_slots + 1)/2 - c.urb_entry_read_offset;
c.nr_setup_regs = c.nr_attr_regs;
@@ -125,6 +135,8 @@ brw_upload_sf_prog(struct brw_context *brw)
 {
struct gl_context *ctx = brw-intel.ctx;
struct brw_sf_prog_key key;
+   /* _NEW_BUFFERS */
+   bool render_to_fbo = ctx-DrawBuffer-Name != 0;
 
memset(key, 0, sizeof(key));
 
@@ -167,7 +179,15 @@ brw_upload_sf_prog(struct brw_context *brw)
key.point_sprite_coord_replace |= (1  i);
   }
}
-   key.sprite_origin_lower_left = (ctx-Point.SpriteOrigin == GL_LOWER_LEFT);
+   if (brw-fragment_program-Base.InputsRead  
BITFIELD64_BIT(FRAG_ATTRIB_PNTC))
+  key.do_point_coord = 1;
+   /*
+* Window coordinates in a FBO are inverted, which means point
+* sprite origin must