Mesa (master): clover: Adapt libclc' s INCLUDEDIR and LIBEXECDIR to make use of the new introduced libclc.pc.

2013-01-08 Thread Tom Stellard
Module: Mesa
Branch: master
Commit: 959e83d65075513f989cb1fe634dca314a7e185f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=959e83d65075513f989cb1fe634dca314a7e185f

Author: Johannes Obermayr 
Date:   Fri Nov 30 01:44:56 2012 +0100

clover: Adapt libclc's INCLUDEDIR and LIBEXECDIR to make use of the new 
introduced libclc.pc.

Tom Stellard:
  -Keep --with-libclc-path and mark it deprecated.

Reviewed-by: Tom Stellard 

---

 configs/current.in |3 ++-
 configure.ac   |   18 --
 src/gallium/state_trackers/clover/Makefile.am  |3 ++-
 .../state_trackers/clover/llvm/invocation.cpp  |4 ++--
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/configs/current.in b/configs/current.in
index dc8e63f..9bd07c1 100644
--- a/configs/current.in
+++ b/configs/current.in
@@ -183,7 +183,8 @@ VA_LIB_INSTALL_DIR=@VA_LIB_INSTALL_DIR@
 XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@
 
 # Path to OpenCL C library libclc
-LIBCLC_PATH = @LIBCLC_PATH@
+LIBCLC_INCLUDEDIR = @LIBCLC_INCLUDEDIR@
+LIBCLC_LIBEXECDIR = @LIBCLC_LIBEXECDIR@
 
 # pkg-config substitutions
 GL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@
diff --git a/configure.ac b/configure.ac
index 1414ce8..dd731b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1452,17 +1452,27 @@ dnl
 
 AC_ARG_WITH([libclc-path],
[AS_HELP_STRING([--with-libclc-path],
- [Path to libclc builtins library.  Example: 
--with-libclc-path=\$HOME/libclc/])],
+ [DEPRECATED: See 
http://dri.freedesktop.org/wiki/GalliumCompute#How_to_Install])],
[LIBCLC_PATH="$withval"],
[LIBCLC_PATH=""])
 
+if test "x$LIBCLC_PATH" != x; then
+   AC_MSG_ERROR([The --with-libclc-path option has been deprecated.
+  Please review the updated build instructions for clover:
+ http://dri.freedesktop.org/wiki/GalliumCompute])
+fi
+
+
 AC_ARG_WITH([clang-libdir],
[AS_HELP_STRING([--with-clang-libdir],
  [Path to Clang libraries @<:@default=llvm-config --libdir@:>@])],
[CLANG_LIBDIR="$withval"],
[CLANG_LIBDIR=""])
 
-AC_SUBST([LIBCLC_PATH])
+LIBCLC_INCLUDEDIR=`pkg-config --variable=includedir libclc`
+LIBCLC_LIBEXECDIR=`pkg-config --variable=libexecdir libclc`
+AC_SUBST([LIBCLC_INCLUDEDIR])
+AC_SUBST([LIBCLC_LIBEXECDIR])
 
 if test "x$enable_opencl" = xyes; then
 if test "x$with_gallium_drivers" = x; then
@@ -1473,6 +1483,10 @@ if test "x$enable_opencl" = xyes; then
 AC_MSG_ERROR([gcc >= 4.6 is required to build clover])
 fi
 
+if test "x$LIBCLC_INCLUDEDIR" == x || test "x$LIBCLC_LIBEXECDIR" == x; then
+AC_MSG_ERROR([pkg-config cannot use libclc.pc which is required to 
build clover])
+fi
+
 GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS clover"
 GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS opencl"
 enable_gallium_loader=yes
diff --git a/src/gallium/state_trackers/clover/Makefile.am 
b/src/gallium/state_trackers/clover/Makefile.am
index ee69f89..863d136 100644
--- a/src/gallium/state_trackers/clover/Makefile.am
+++ b/src/gallium/state_trackers/clover/Makefile.am
@@ -23,7 +23,8 @@ libclllvm_la_CXXFLAGS = \
-std=c++98 \
$(LLVM_CPPFLAGS) \
$(DEFINES) \
-   -DLIBCLC_PATH=\"$(LIBCLC_PATH)/\" \
+   -DLIBCLC_INCLUDEDIR=\"$(LIBCLC_INCLUDEDIR)/\" \
+   -DLIBCLC_LIBEXECDIR=\"$(LIBCLC_LIBEXECDIR)/\" \
-DCLANG_RESOURCE_DIR=\"$(CLANG_RESOURCE_DIR)\"
 
 libclllvm_la_SOURCES = \
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index c997367..0bd8e22 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -149,7 +149,7 @@ namespace {
   c.getHeaderSearchOpts().ResourceDir = CLANG_RESOURCE_DIR;
 
   // Add libclc generic search path
-  c.getHeaderSearchOpts().AddPath(LIBCLC_PATH "/generic/include/",
+  c.getHeaderSearchOpts().AddPath(LIBCLC_INCLUDEDIR,
   clang::frontend::Angled,
   false, false, false);
 
@@ -205,7 +205,7 @@ namespace {
   llvm::Linker linker("clover", mod);
 
   // Link the kernel with libclc
-  linker.LinkInFile(llvm::sys::Path(LIBCLC_PATH + triple + 
"/lib/builtins.bc"), isNative);
+  linker.LinkInFile(llvm::sys::Path(LIBCLC_LIBEXECDIR + triple + ".bc"), 
isNative);
   mod = linker.releaseModule();
 
   // Add a function internalizer pass.

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


Mesa (master): i965/fs: Fix struct vs. class in acp_entry definitions.

2013-01-08 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: a5265f7536538ca9af770ef90262c836a324dbc0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a5265f7536538ca9af770ef90262c836a324dbc0

Author: Kenneth Graunke 
Date:   Mon Jan  7 19:42:38 2013 -0800

i965/fs: Fix struct vs. class in acp_entry definitions.

---

 src/mesa/drivers/dri/i965/brw_fs.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index bcf38f3..b47b0d0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -52,7 +52,7 @@ extern "C" {
 
 class bblock_t;
 namespace {
-   class acp_entry;
+   struct acp_entry;
 }
 
 enum register_file {

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


Mesa (master): glsl: Don't add structure fields to the symbol table

2013-01-08 Thread Kenneth Graunke
Module: Mesa
Branch: master
Commit: ed3f237e09a42bdb55afb58d1536affad9000d76
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ed3f237e09a42bdb55afb58d1536affad9000d76

Author: Ian Romanick 
Date:   Thu Dec  6 14:57:01 2012 -0800

glsl: Don't add structure fields to the symbol table

I erroneously added this back in January 2011 in commit 88421589.
Looking at the commit message, I have no idea why I added it.  It only
added non-array structure fields to the symbol table, so array structure
fields are treated correctly.

Fixes piglit tests structure-and-field-have-same-name.vert and
structure-and-field-have-same-name-nested.vert.  It should also fix
WebGL conformance tests shader-with-non-reserved-words.

NOTE: This is a candidate for the stable release branches.

Signed-off-by: Ian Romanick 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=57622
Reviewed-by: Kenneth Graunke 

---

 src/glsl/glsl_parser.yy |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index d849466..88aae64 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1542,7 +1542,6 @@ struct_declarator:
   void *ctx = state;
   $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
   $$->set_location(yylloc);
-  state->symbols->add_variable(new(state) ir_variable(NULL, $1, 
ir_var_auto));
}
| any_identifier '[' constant_expression ']'
{

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


Mesa (master): r600g: implement buffer copying using CP DMA for R7xx, Evergreen, Cayman

2013-01-08 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: a70e5e2b94194da3f4102a9f8e3c8ed5ca6dd8b8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a70e5e2b94194da3f4102a9f8e3c8ed5ca6dd8b8

Author: Marek Olšák 
Date:   Sat Dec 22 19:33:47 2012 +0100

r600g: implement buffer copying using CP DMA for R7xx, Evergreen, Cayman

R6xx doesn't work - the issue seems to be with flushing (sometimes
the destination buffer contains garbage). There are no hangs, so we're good.

R7xx doesn't seem to have any alignment restriction despite our initial
thinking. Everything just works.

Reviewed-by: Alex Deucher 

---

 src/gallium/drivers/r600/evergreen_compute.c |2 +-
 src/gallium/drivers/r600/evergreen_state.c   |4 +-
 src/gallium/drivers/r600/r600.h  |   11 +++-
 src/gallium/drivers/r600/r600_blit.c |   13 +++--
 src/gallium/drivers/r600/r600_hw_context.c   |   85 --
 src/gallium/drivers/r600/r600_pipe.h |3 +-
 src/gallium/drivers/r600/r600_state.c|6 +-
 src/gallium/drivers/r600/r600_state_common.c |6 +-
 src/gallium/drivers/r600/r600d.h |   34 ++
 9 files changed, 140 insertions(+), 24 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c 
b/src/gallium/drivers/r600/evergreen_compute.c
index 8d3050b..ed5055b 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -329,7 +329,7 @@ static void compute_emit_cs(struct r600_context *ctx, const 
uint *block_layout,
 */
r600_emit_command_buffer(ctx->cs, &ctx->start_compute_cs_cmd);
 
-   ctx->flags |= R600_CONTEXT_WAIT_IDLE | R600_CONTEXT_FLUSH_AND_INV;
+   ctx->flags |= R600_CONTEXT_WAIT_3D_IDLE | R600_CONTEXT_FLUSH_AND_INV;
r600_flush_emit(ctx);
 
/* Emit colorbuffers. */
diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 7635f86..d0402c2 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -1570,14 +1570,14 @@ static void evergreen_set_framebuffer_state(struct 
pipe_context *ctx,
uint32_t i, log_samples;
 
if (rctx->framebuffer.state.nr_cbufs) {
-   rctx->flags |= R600_CONTEXT_WAIT_IDLE | 
R600_CONTEXT_FLUSH_AND_INV;
+   rctx->flags |= R600_CONTEXT_WAIT_3D_IDLE | 
R600_CONTEXT_FLUSH_AND_INV;
 
if (rctx->framebuffer.state.cbufs[0]->texture->nr_samples > 1) {
rctx->flags |= R600_CONTEXT_FLUSH_AND_INV_CB_META;
}
}
if (rctx->framebuffer.state.zsbuf) {
-   rctx->flags |= R600_CONTEXT_WAIT_IDLE | 
R600_CONTEXT_FLUSH_AND_INV;
+   rctx->flags |= R600_CONTEXT_WAIT_3D_IDLE | 
R600_CONTEXT_FLUSH_AND_INV;
}
 
util_copy_framebuffer_state(&rctx->framebuffer.state, state);
diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index 260536e..93604fb 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -147,9 +147,10 @@ struct r600_so_target {
 
 #define R600_CONTEXT_INVAL_READ_CACHES (1 << 0)
 #define R600_CONTEXT_STREAMOUT_FLUSH   (1 << 1)
-#define R600_CONTEXT_WAIT_IDLE (1 << 2)
-#define R600_CONTEXT_FLUSH_AND_INV (1 << 3)
-#define R600_CONTEXT_FLUSH_AND_INV_CB_META (1 << 4)
+#define R600_CONTEXT_WAIT_3D_IDLE  (1 << 2)
+#define R600_CONTEXT_WAIT_CP_DMA_IDLE  (1 << 3)
+#define R600_CONTEXT_FLUSH_AND_INV (1 << 4)
+#define R600_CONTEXT_FLUSH_AND_INV_CB_META (1 << 5)
 
 struct r600_context;
 struct r600_screen;
@@ -170,6 +171,10 @@ void r600_context_streamout_begin(struct r600_context 
*ctx);
 void r600_context_streamout_end(struct r600_context *ctx);
 void r600_need_cs_space(struct r600_context *ctx, unsigned num_dw, boolean 
count_draw_in);
 void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block 
*block, unsigned pkt_flags);
+void r600_cp_dma_copy_buffer(struct r600_context *rctx,
+struct pipe_resource *dst, unsigned dst_offset,
+struct pipe_resource *src, unsigned src_offset,
+unsigned size);
 
 int evergreen_context_init(struct r600_context *ctx);
 
diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index b348aa7..c4ce7f7 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -503,15 +503,18 @@ static void r600_clear_depth_stencil(struct pipe_context 
*ctx,
r600_blitter_end(ctx);
 }
 
-void r600_copy_buffer(struct pipe_context *ctx, struct
- pipe_resource *dst, unsigned dstx,
+void r600_copy_buffer(struct pipe_context *ctx, struct pipe_resource *dst, 
unsigned dstx,
  struct pipe_resource *src, const struct pipe_box *src_box)
 {
struct r600_context *rc

Mesa (master): st/mesa: fix possible MSVC build error v2

2013-01-08 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: 2d3d0d3a5ae3829260f914462f4e63b2ff4aadbc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d3d0d3a5ae3829260f914462f4e63b2ff4aadbc

Author: Marek Olšák 
Date:   Tue Jan  8 20:39:55 2013 +0100

st/mesa: fix possible MSVC build error v2

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

Using GLubyte as per Brian's suggestion.

---

 src/mesa/state_tracker/st_cb_texture.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 02fc675..7f07b74 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -759,7 +759,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
struct pipe_transfer *src_trans;
-   GLvoid *texDest;
+   GLubyte *texDest;
enum pipe_transfer_usage transfer_usage;
void *map;
unsigned dst_width = width;
@@ -884,7 +884,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
 texImage->_BaseFormat, 
 texImage->TexFormat, 
 dstRowStride,
-(GLubyte **) &texDest,
+&texDest,
 width, height, 1,
 GL_RGBA, GL_FLOAT, tempSrc, /* src */
 &unpack);

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


Mesa (master): glsl: Pack flat "varyings" of mixed types together.

2013-01-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: c35abcd1b0d0e0059c60781bd21558872020553d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c35abcd1b0d0e0059c60781bd21558872020553d

Author: Paul Berry 
Date:   Tue Dec 18 16:37:52 2012 -0800

glsl: Pack flat "varyings" of mixed types together.

This patch enhances the varying packing code so that flat varyings of
uint, int, and float types can be packed together.

We accomplish this in lower_packed_varyings.cpp by making the type of
all flat varyings ivec4, and then using information-preserving type
conversions (e.g. ir_unop_bitcast_f2i) to convert all other types to
ints.

The varying_matches::compute_packing_class() function is updated to
reflect the fact that varying packing no longer needs to segregate
varyings of different base types.

Fixes piglit test varying-packing-mixed-types.

Reviewed-by: Kenneth Graunke 

v2: Split lower_packed_varyings_visitor::bitwise_assign into
pack/unpack variants.

---

 src/glsl/link_varyings.cpp |   20 +--
 src/glsl/lower_packed_varyings.cpp |   95 +---
 2 files changed, 101 insertions(+), 14 deletions(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index b9c3f5d..5c27f23 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -777,17 +777,25 @@ varying_matches::store_locations(unsigned producer_base,
 unsigned
 varying_matches::compute_packing_class(ir_variable *var)
 {
-   /* In this initial implementation we conservatively assume that variables
-* can only be packed if their base type (float/int/uint/bool) matches and
-* their interpolation and centroid qualifiers match.
+   /* Without help from the back-end, there is no way to pack together
+* variables with different interpolation types, because
+* lower_packed_varyings must choose exactly one interpolation type for
+* each packed varying it creates.
 *
-* TODO: relax these restrictions when the driver back-end permits.
+* However, we can safely pack together floats, ints, and uints, because:
+*
+* - varyings of base type "int" and "uint" must use the "flat"
+*   interpolation type, which can only occur in GLSL 1.30 and above.
+*
+* - On platforms that support GLSL 1.30 and above, lower_packed_varyings
+*   can store flat floats as ints without losing any information (using
+*   the ir_unop_bitcast_* opcodes).
+*
+* Therefore, the packing class depends only on the interpolation type.
 */
unsigned packing_class = var->centroid ? 1 : 0;
packing_class *= 4;
packing_class += var->interpolation;
-   packing_class *= GLSL_TYPE_ERROR;
-   packing_class += var->type->get_scalar_type()->base_type;
return packing_class;
 }
 
diff --git a/src/glsl/lower_packed_varyings.cpp 
b/src/glsl/lower_packed_varyings.cpp
index 09c551c..9e7f274 100644
--- a/src/glsl/lower_packed_varyings.cpp
+++ b/src/glsl/lower_packed_varyings.cpp
@@ -66,6 +66,10 @@
  * performance.  However, hopefully in most cases the performance loss will
  * either be absorbed by a later optimization pass, or it will be offset by
  * memory bandwidth savings (because fewer varyings are used).
+ *
+ * This lowering pass also packs flat floats, ints, and uints together, by
+ * using ivec4 as the base type of flat "varyings", and using appropriate
+ * casts to convert floats and uints into ints.
  */
 
 #include "glsl_symbol_table.h"
@@ -90,6 +94,8 @@ public:
void run(exec_list *instructions);
 
 private:
+   ir_assignment *bitwise_assign_pack(ir_rvalue *lhs, ir_rvalue *rhs);
+   ir_assignment *bitwise_assign_unpack(ir_rvalue *lhs, ir_rvalue *rhs);
unsigned lower_rvalue(ir_rvalue *rvalue, unsigned fine_location,
  ir_variable *unpacked_var, const char *name);
unsigned lower_arraylike(ir_rvalue *rvalue, unsigned array_size,
@@ -181,6 +187,75 @@ lower_packed_varyings_visitor::run(exec_list *instructions)
}
 }
 
+
+/**
+ * Make an ir_assignment from \c rhs to \c lhs, performing appropriate
+ * bitcasts if necessary to match up types.
+ *
+ * This function is called when packing varyings.
+ */
+ir_assignment *
+lower_packed_varyings_visitor::bitwise_assign_pack(ir_rvalue *lhs,
+   ir_rvalue *rhs)
+{
+   if (lhs->type->base_type != rhs->type->base_type) {
+  /* Since we only mix types in flat varyings, and we always store flat
+   * varyings as type ivec4, we need only produce conversions from (uint
+   * or float) to int.
+   */
+  assert(lhs->type->base_type == GLSL_TYPE_INT);
+  switch (rhs->type->base_type) {
+  case GLSL_TYPE_UINT:
+ rhs = new(this->mem_ctx)
+ir_expression(ir_unop_u2i, lhs->type, rhs);
+ break;
+  case GLSL_TYPE_FLOAT:
+ rhs = new(this->mem_ctx)
+ir_expression(ir_unop_bitcast_f2i, lhs->type, rhs);
+ break;
+  default:
+ assert(!"Unexpected type conv

Mesa (master): glsl: Prohibit structs and bools from being used as " varyings".

2013-01-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 18720555dd2da779ad6907e8f6aa083e7b4d1841
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=18720555dd2da779ad6907e8f6aa083e7b4d1841

Author: Paul Berry 
Date:   Tue Dec 18 15:24:39 2012 -0800

glsl: Prohibit structs and bools from being used as "varyings".

The GLSL 1.30 spec only allows vertex shader outputs and fragment
shader inputs ("varyings" in pre-GLSL-1.30 parlance) to be of type
int, uint, float, or vectors, matrices, or arrays thereof.  Bools,
bvec's, and structs are prohibited.  (Integral varyings were
prohibited prior to GLSL 1.30).

Previously, Mesa only performed this check on variables declared with
the "varying" keyword, and it always performed the check according to
the pre-GLSL-1.30 rules.  As a result, bools and structs were allowed
to slip through, provided they were declared using the new in/out
syntax.

This patch modifies the error check so that it occurs after "varying"
is converted to "in/out", and corrects it to properly account for GLSL
version.

Fixes piglit tests:
  in-bool-prohibited.frag
  in-bvec2-prohibited.frag
  in-bvec3-prohibited.frag
  in-bvec4-prohibited.frag
  in-struct-prohibited.frag
  out-bool-prohibited.vert
  out-bvec2-prohibited.vert
  out-bvec3-prohibited.vert
  out-bvec4-prohibited.vert
  out-struct-prohibited.vert

Reviewed-by: Kenneth Graunke 

---

 src/glsl/ast_to_hir.cpp |   92 ---
 1 files changed, 71 insertions(+), 21 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index a14fe7d..f934c8e 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1910,6 +1910,29 @@ ast_type_specifier::glsl_type(const char **name,
 }
 
 
+/**
+ * Determine whether a toplevel variable declaration declares a varying.  This
+ * function operates by examining the variable's mode and the shader target,
+ * so it correctly identifies linkage variables regardless of whether they are
+ * declared using the deprecated "varying" syntax or the new "in/out" syntax.
+ *
+ * Passing a non-toplevel variable declaration (e.g. a function parameter) to
+ * this function will produce undefined results.
+ */
+static bool
+is_varying_var(ir_variable *var, _mesa_glsl_parser_targets target)
+{
+   switch (target) {
+   case vertex_shader:
+  return var->mode == ir_var_out;
+   case fragment_shader:
+  return var->mode == ir_var_in;
+   default:
+  return var->mode == ir_var_out || var->mode == ir_var_in;
+   }
+}
+
+
 static void
 apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
 ir_variable *var,
@@ -1945,27 +1968,6 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
   _mesa_glsl_shader_target_name(state->target));
}
 
-   /* From page 25 (page 31 of the PDF) of the GLSL 1.10 spec:
-*
-* "The varying qualifier can be used only with the data types
-* float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of
-* these."
-*/
-   if (qual->flags.q.varying) {
-  const glsl_type *non_array_type;
-
-  if (var->type && var->type->is_array())
-non_array_type = var->type->fields.array;
-  else
-non_array_type = var->type;
-
-  if (non_array_type && non_array_type->base_type != GLSL_TYPE_FLOAT) {
-var->type = glsl_type::error_type;
-_mesa_glsl_error(loc, state,
- "varying variables must be of base type float");
-  }
-   }
-
/* If there is no qualifier that changes the mode of the variable, leave
 * the setting alone.
 */
@@ -1980,6 +1982,54 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
else if (qual->flags.q.uniform)
   var->mode = ir_var_uniform;
 
+   if (!is_parameter && is_varying_var(var, state->target)) {
+  /* This variable is being used to link data between shader stages (in
+   * pre-glsl-1.30 parlance, it's a "varying").  Check that it has a type
+   * that is allowed for such purposes.
+   *
+   * From page 25 (page 31 of the PDF) of the GLSL 1.10 spec:
+   *
+   * "The varying qualifier can be used only with the data types
+   * float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of
+   * these."
+   *
+   * This was relaxed in GLSL version 1.30 and GLSL ES version 3.00.  From
+   * page 31 (page 37 of the PDF) of the GLSL 1.30 spec:
+   *
+   * "Fragment inputs can only be signed and unsigned integers and
+   * integer vectors, float, floating-point vectors, matrices, or
+   * arrays of these. Structures cannot be input.
+   *
+   * Similar text exists in the section on vertex shader outputs.
+   *
+   * Similar text exists in the GLSL ES 3.00 spec, except that the GLSL ES
+   * 3.00 spec claims to allow structs as well.  However, this is likely
+   * an error, since section 11 o

Mesa (master): glsl: Plumb through is_parameter to apply_type_qualifier_to_variable()

2013-01-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: c33be485c58dace2a691042703f50cc6defe960d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c33be485c58dace2a691042703f50cc6defe960d

Author: Paul Berry 
Date:   Tue Dec 18 14:49:34 2012 -0800

glsl: Plumb through is_parameter to apply_type_qualifier_to_variable()

This patch adds logic to allow the ast_to_hir function
apply_type_qualifier_to_variable() to tell whether it is acting on a
variable declaration or a function parameter.  This will allow it to
correctly interpret the meaning of "out" and "in" keywords (which have
different meanings in those two contexts).

Reviewed-by: Kenneth Graunke 

---

 src/glsl/ast_to_hir.cpp |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 94b63f6..a14fe7d 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1915,7 +1915,8 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
 ir_variable *var,
 struct _mesa_glsl_parse_state *state,
 YYLTYPE *loc,
-bool ubo_qualifiers_valid)
+bool ubo_qualifiers_valid,
+ bool is_parameter)
 {
if (qual->flags.q.invariant) {
   if (var->used) {
@@ -2626,7 +2627,7 @@ ast_declarator_list::hir(exec_list *instructions,
   }
 
   apply_type_qualifier_to_variable(& this->type->qualifier, var, state,
-  & loc, this->ubo_qualifiers_valid);
+  & loc, this->ubo_qualifiers_valid, 
false);
 
   if (this->type->qualifier.flags.q.invariant) {
 if ((state->target == vertex_shader) && !(var->mode == ir_var_out ||
@@ -3065,7 +3066,7 @@ ast_parameter_declarator::hir(exec_list *instructions,
 * for function parameters the default mode is 'in'.
 */
apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc,
-   false);
+   false, true);
 
/* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
 *

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


Mesa (master): glsl: Separate varying linking code to its own file.

2013-01-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 4b11b57ab47b98b335a7212080dbccef04542805
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b11b57ab47b98b335a7212080dbccef04542805

Author: Paul Berry 
Date:   Mon Dec 17 14:20:35 2012 -0800

glsl: Separate varying linking code to its own file.

linker.cpp is getting pretty big, and we're about to add even more
varying packing code, so split out the linker code that concerns
varyings to its own file.

Reviewed-by: Kenneth Graunke 

---

 src/glsl/Makefile.sources  |1 +
 src/glsl/link_varyings.cpp | 1043 
 src/glsl/link_varyings.h   |  186 
 src/glsl/linker.cpp| 1125 +---
 src/glsl/linker.h  |9 +
 5 files changed, 1240 insertions(+), 1124 deletions(-)

Diff:   
http://cgit.freedesktop.org/mesa/mesa/diff/?id=4b11b57ab47b98b335a7212080dbccef04542805
___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Add ALIGN() macro to main/macros.h.

2013-01-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 8706395f25228d0e622cc56346c7181ba102edf4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8706395f25228d0e622cc56346c7181ba102edf4

Author: Paul Berry 
Date:   Mon Dec 17 13:48:21 2012 -0800

mesa: Add ALIGN() macro to main/macros.h.

Previously this macro existed in 3 separate places, some inside the
intel driver and some outside of it.  It makes more sense to have it
in main/macros.h

Reviewed-by: Brian Paul 
Reviewed-by: Kenneth Graunke 

---

 src/glsl/linker.cpp|2 --
 src/mesa/drivers/dri/i965/brw_context.h|1 +
 src/mesa/drivers/dri/intel/intel_context.h |   13 -
 src/mesa/main/extensions.c |3 +--
 src/mesa/main/macros.h |   13 +
 5 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index be08156..c5c462b 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -76,8 +76,6 @@ extern "C" {
 #include "main/shaderobj.h"
 }
 
-#define ALIGN(value, alignment)  (((value) + alignment - 1) & ~(alignment - 1))
-
 /**
  * Visitor that determines whether or not a variable is ever written.
  */
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index eba9eb5..c7fc586 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -36,6 +36,7 @@
 #include "intel_context.h"
 #include "brw_structs.h"
 #include "main/imports.h"
+#include "main/macros.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/mesa/drivers/dri/intel/intel_context.h 
b/src/mesa/drivers/dri/intel/intel_context.h
index 8d544dc..dbc5ea0 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -350,19 +350,6 @@ extern char *__progname;
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 
 /**
- * Align a value up to an alignment value
- *
- * If \c value is not already aligned to the requested alignment value, it
- * will be rounded up.
- *
- * \param value  Value to be rounded
- * \param alignment  Alignment value to be used.  This must be a power of two.
- *
- * \sa ROUND_DOWN_TO()
- */
-#define ALIGN(value, alignment)  (((value) + alignment - 1) & ~(alignment - 1))
-
-/**
  * Align a value down to an alignment value
  *
  * If \c value is not already aligned to the requested alignment value, it
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 98711b3..3486b65 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -34,11 +34,10 @@
 #include "imports.h"
 #include "context.h"
 #include "extensions.h"
+#include "macros.h"
 #include "mfeatures.h"
 #include "mtypes.h"
 
-#define ALIGN(value, alignment)  (((value) + alignment - 1) & ~(alignment - 1))
-
 enum {
DISABLE = 0,
GLL = 1 << API_OPENGL_COMPAT,   /* GL Legacy / Compatibility */
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 14a5d5f..d1e81fe 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -656,6 +656,19 @@ INTERP_4F(GLfloat t, GLfloat dst[4], const GLfloat out[4], 
const GLfloat in[4])
 #define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C))
 #define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
 
+/**
+ * Align a value up to an alignment value
+ *
+ * If \c value is not already aligned to the requested alignment value, it
+ * will be rounded up.
+ *
+ * \param value  Value to be rounded
+ * \param alignment  Alignment value to be used.  This must be a power of two.
+ *
+ * \sa ROUND_DOWN_TO()
+ */
+#define ALIGN(value, alignment)  (((value) + alignment - 1) & ~(alignment - 1))
+
 
 
 /** Cross product of two 3-element vectors */

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


Mesa (master): glsl: Fix loop bounds detection.

2013-01-08 Thread Paul Berry
Module: Mesa
Branch: master
Commit: 09df6bb96d5d7b987de6cd48d87d175e5cd2ccf3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=09df6bb96d5d7b987de6cd48d87d175e5cd2ccf3

Author: Paul Berry 
Date:   Mon Jan  7 18:10:30 2013 -0800

glsl: Fix loop bounds detection.

When analyzing a loop where the loop condition is expressed in the
non-standard order (e.g. "4 > i" instead of "i < 4"), we were
reversing the condition incorrectly, leading to a loop bound that was
off by 1.

Fixes piglit tests {vs,fs}-loop-bounds-unrolled.shader_test.

Reviewed-by: Kenneth Graunke 
Reviewed-by: Matt Turner 
Reviewed-by: Eric Anholt 

---

 src/glsl/loop_controls.cpp |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
index 9acbadc..79c8204 100644
--- a/src/glsl/loop_controls.cpp
+++ b/src/glsl/loop_controls.cpp
@@ -222,10 +222,10 @@ loop_control_visitor::visit_leave(ir_loop *ir)
limit = cond->operands[0]->as_constant();
 
switch (cmp) {
-   case ir_binop_less:cmp = ir_binop_gequal;  break;
-   case ir_binop_greater: cmp = ir_binop_lequal;  break;
-   case ir_binop_lequal:  cmp = ir_binop_greater; break;
-   case ir_binop_gequal:  cmp = ir_binop_less;break;
+   case ir_binop_less:cmp = ir_binop_greater; break;
+   case ir_binop_greater: cmp = ir_binop_less;break;
+   case ir_binop_lequal:  cmp = ir_binop_gequal;  break;
+   case ir_binop_gequal:  cmp = ir_binop_lequal;  break;
default: assert(!"Should not get here.");
}
 }

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


Mesa (master): winsys/radeon: bump the size of relocation hashlist

2013-01-08 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: 844d14ebee3522281252da03615ac96df7440610
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=844d14ebee3522281252da03615ac96df7440610

Author: Marek Olšák 
Date:   Tue Jan  8 16:38:10 2013 +0100

winsys/radeon: bump the size of relocation hashlist

This should reduce the number of hash collisions in ETQW.

---

 src/gallium/winsys/radeon/drm/radeon_drm_cs.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h 
b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
index 286eb6a..a88fba5 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
@@ -47,8 +47,8 @@ struct radeon_cs_context {
 struct drm_radeon_cs_reloc  *relocs;
 
 /* 0 = BO not added, 1 = BO added */
-charis_handle_added[256];
-unsignedreloc_indices_hashlist[256];
+charis_handle_added[512];
+unsignedreloc_indices_hashlist[512];
 
 unsignedused_vram;
 unsignedused_gart;

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


Mesa (master): nvc0: catch too high GENERIC indices to prevent GRAPH traps

2013-01-08 Thread Christoph Bumiller
Module: Mesa
Branch: master
Commit: 18f3f7b95898e7db20cdb24181bc24f91cc24fe6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=18f3f7b95898e7db20cdb24181bc24f91cc24fe6

Author: Christoph Bumiller 
Date:   Mon Jan  7 15:46:31 2013 +0100

nvc0: catch too high GENERIC indices to prevent GRAPH traps

---

 src/gallium/drivers/nvc0/nvc0_program.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_program.c 
b/src/gallium/drivers/nvc0/nvc0_program.c
index 8bcb206..39393a1 100644
--- a/src/gallium/drivers/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nvc0/nvc0_program.c
@@ -43,8 +43,14 @@ nvc0_mesa_varying_hack(struct nv50_ir_varying *var)
   for (c = 0; c < 4; ++c)
  var->slot[c] = (0x2e0 + c * 0x4) / 4;
else
+   if (var->si <= 39)
   for (c = 0; c < 4; ++c) /* move down user varyings (first has index 8) */
  var->slot[c] -= 0x80 / 4;
+   else {
+  NOUVEAU_ERR("too many varyings / invalid location: %u !\n", var->si);
+  for (c = 0; c < 4; ++c)
+ var->slot[c] = (0x270 + c * 0x4) / 4; /* catch invalid indices */
+   }
 }
 
 static uint32_t

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


Mesa (master): nvc0: use correct resource target to select blit shader

2013-01-08 Thread Christoph Bumiller
Module: Mesa
Branch: master
Commit: b9c8a98e216f4613dc0a40e26d08f2c1cb760e76
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b9c8a98e216f4613dc0a40e26d08f2c1cb760e76

Author: Christoph Bumiller 
Date:   Mon Jan  7 22:12:28 2013 +0100

nvc0: use correct resource target to select blit shader

---

 src/gallium/drivers/nvc0/nvc0_surface.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c 
b/src/gallium/drivers/nvc0/nvc0_surface.c
index 2f81cf5..591f67c 100644
--- a/src/gallium/drivers/nvc0/nvc0_surface.c
+++ b/src/gallium/drivers/nvc0/nvc0_surface.c
@@ -544,7 +544,7 @@ nvc0_blit_select_fp(struct nvc0_blitctx *ctx, const struct 
pipe_blit_info *info)
struct nvc0_blitter *blitter = ctx->nvc0->screen->blitter;
 
const enum pipe_texture_target ptarg =
-  nv50_blit_reinterpret_pipe_texture_target(info->dst.resource->target);
+  nv50_blit_reinterpret_pipe_texture_target(info->src.resource->target);
 
const unsigned targ = nv50_blit_texture_type(ptarg);
const unsigned mode = ctx->mode;
@@ -553,7 +553,7 @@ nvc0_blit_select_fp(struct nvc0_blitctx *ctx, const struct 
pipe_blit_info *info)
   pipe_mutex_lock(blitter->mutex);
   if (!blitter->fp[targ][mode])
  blitter->fp[targ][mode] =
-nv50_blitter_make_fp(&ctx->nvc0->base.pipe, mode, targ);
+nv50_blitter_make_fp(&ctx->nvc0->base.pipe, mode, ptarg);
   pipe_mutex_unlock(blitter->mutex);
}
ctx->fp = blitter->fp[targ][mode];

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


Mesa (master): nvc0: add missing call to map edge flag in push_vbo

2013-01-08 Thread Christoph Bumiller
Module: Mesa
Branch: master
Commit: 41e105d5beb78c42993a602cc58d0f990739b088
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=41e105d5beb78c42993a602cc58d0f990739b088

Author: Christoph Bumiller 
Date:   Mon Jan  7 20:18:06 2013 +0100

nvc0: add missing call to map edge flag in push_vbo

Note: this is a candidate for the 9.0 stable branch.

---

 src/gallium/drivers/nvc0/nvc0_vbo_translate.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_vbo_translate.c 
b/src/gallium/drivers/nvc0/nvc0_vbo_translate.c
index 42d9e05..033a5d0 100644
--- a/src/gallium/drivers/nvc0/nvc0_vbo_translate.c
+++ b/src/gallium/drivers/nvc0/nvc0_vbo_translate.c
@@ -439,6 +439,9 @@ nvc0_push_vbo(struct nvc0_context *nvc0, const struct 
pipe_draw_info *info)
 
nvc0_vertex_configure_translate(nvc0, info->index_bias);
 
+   if (unlikely(ctx.edgeflag.enabled))
+  nvc0_push_map_edgeflag(&ctx, nvc0, info->index_bias);
+
ctx.prim_restart = info->primitive_restart;
ctx.restart_index = info->restart_index;
 

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


Mesa (master): nv50/ir: wrap assertion using typeid in #ifndef NDEBUG

2013-01-08 Thread Christoph Bumiller
Module: Mesa
Branch: master
Commit: be75a9373a6d0f9e2ef35ac376a541e60d72d306
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=be75a9373a6d0f9e2ef35ac376a541e60d72d306

Author: Christoph Bumiller 
Date:   Mon Jan  7 15:50:19 2013 +0100

nv50/ir: wrap assertion using typeid in #ifndef NDEBUG

Note: this is a candidate for the 9.0 stable branch.

---

 src/gallium/drivers/nv50/codegen/nv50_ir.cpp |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp 
b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
index 335e9e0..146dbbb 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
@@ -715,7 +715,9 @@ Instruction::clone(ClonePolicy& pol, Instruction 
*i) const
 {
if (!i)
   i = new_Instruction(pol.context(), op, dType);
+#ifndef NDEBUG // non-conformant assert, so this is required
assert(typeid(*i) == typeid(*this));
+#endif
 
pol.set(this, i);
 

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


Mesa (master): nvc0: fix out of bounds writes for unaligned sizes in push_data

2013-01-08 Thread Christoph Bumiller
Module: Mesa
Branch: master
Commit: 076f4ced8b7bbf2074cf932e653b1da6db2e2380
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=076f4ced8b7bbf2074cf932e653b1da6db2e2380

Author: Christoph Bumiller 
Date:   Tue Jan  8 13:46:24 2013 +0100

nvc0: fix out of bounds writes for unaligned sizes in push_data

---

 src/gallium/drivers/nvc0/nvc0_transfer.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_transfer.c 
b/src/gallium/drivers/nvc0/nvc0_transfer.c
index 66753c9..16467ce 100644
--- a/src/gallium/drivers/nvc0/nvc0_transfer.c
+++ b/src/gallium/drivers/nvc0/nvc0_transfer.c
@@ -201,7 +201,7 @@ nvc0_m2mf_push_linear(struct nouveau_context *nv,
   PUSH_DATAh(push, dst->offset + offset);
   PUSH_DATA (push, dst->offset + offset);
   BEGIN_NVC0(push, NVC0_M2MF(LINE_LENGTH_IN), 2);
-  PUSH_DATA (push, nr * 4);
+  PUSH_DATA (push, MIN2(size, nr * 4));
   PUSH_DATA (push, 1);
   BEGIN_NVC0(push, NVC0_M2MF(EXEC), 1);
   PUSH_DATA (push, 0x100111);
@@ -213,6 +213,7 @@ nvc0_m2mf_push_linear(struct nouveau_context *nv,
   count -= nr;
   src += nr;
   offset += nr * 4;
+  size -= nr * 4;
}
 
nouveau_bufctx_reset(nvc0->bufctx, 0);
@@ -246,7 +247,7 @@ nve4_p2mf_push_linear(struct nouveau_context *nv,
   PUSH_DATAh(push, dst->offset + offset);
   PUSH_DATA (push, dst->offset + offset);
   BEGIN_NVC0(push, NVE4_P2MF(LINE_LENGTH_IN), 2);
-  PUSH_DATA (push, nr * 4);
+  PUSH_DATA (push, MIN2(size, nr * 4));
   PUSH_DATA (push, 1);
   /* must not be interrupted (trap on QUERY fence, 0x50 works however) */
   BEGIN_1IC0(push, NVE4_P2MF(EXEC), nr + 1);
@@ -256,6 +257,7 @@ nve4_p2mf_push_linear(struct nouveau_context *nv,
   count -= nr;
   src += nr;
   offset += nr * 4;
+  size -= nr * 4;
}
 
nouveau_bufctx_reset(nvc0->bufctx, 0);

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


Mesa (master): nouveau: increase max order of suballocated buffers by 1

2013-01-08 Thread Christoph Bumiller
Module: Mesa
Branch: master
Commit: 39fe03e2de655aee9939cb51d08cac8aa491bb6e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=39fe03e2de655aee9939cb51d08cac8aa491bb6e

Author: Christoph Bumiller 
Date:   Tue Jan  8 12:35:25 2013 +0100

nouveau: increase max order of suballocated buffers by 1

This is really a hack to make TF2 (considerably, up to 20 -> 70 fps
at low res) faster.

---

 src/gallium/drivers/nouveau/nouveau_mm.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_mm.c 
b/src/gallium/drivers/nouveau/nouveau_mm.c
index 6045af6..439c0fb 100644
--- a/src/gallium/drivers/nouveau/nouveau_mm.c
+++ b/src/gallium/drivers/nouveau/nouveau_mm.c
@@ -9,8 +9,15 @@
 #include "nouveau_screen.h"
 #include "nouveau_mm.h"
 
+/* TODO: Higher orders can waste a lot of space for npot size buffers, should
+ * add an extra cache for such buffer objects.
+ *
+ * HACK: Max order == 21 to accommodate TF2's 1.5 MiB, frequently reallocated
+ * vertex buffer (VM flush (?) decreases performance dramatically).
+ */
+
 #define MM_MIN_ORDER 7 /* >= 6 to not violate ARB_map_buffer_alignment */
-#define MM_MAX_ORDER 20
+#define MM_MAX_ORDER 21
 
 #define MM_NUM_BUCKETS (MM_MAX_ORDER - MM_MIN_ORDER + 1)
 
@@ -102,7 +109,7 @@ mm_default_slab_size(unsigned chunk_order)
 {
static const int8_t slab_order[MM_MAX_ORDER - MM_MIN_ORDER + 1] =
{
-  12, 12, 13, 14, 14, 17, 17, 17, 17, 19, 19, 20, 21, 22
+  12, 12, 13, 14, 14, 17, 17, 17, 17, 19, 19, 20, 21, 22, 22
};
 
assert(chunk_order <= MM_MAX_ORDER && chunk_order >= MM_MIN_ORDER);

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


Mesa (master): nouveau: improve buffer transfers

2013-01-08 Thread Christoph Bumiller
Module: Mesa
Branch: master
Commit: 48a45ec24ae74c00d1487552e94d9f824a428f58
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=48a45ec24ae74c00d1487552e94d9f824a428f58

Author: Christoph Bumiller 
Date:   Tue Jan  8 16:13:11 2013 +0100

nouveau: improve buffer transfers

Save double memcpy on uploads to VRAM in most cases.
Properly handle FLUSH_EXPLICIT.
Reallocate on DISCARD_WHOLE_RESOURCE to avoid sync.

---

 src/gallium/drivers/nouveau/nouveau_buffer.c  |  399 +
 src/gallium/drivers/nouveau/nouveau_buffer.h  |3 +
 src/gallium/drivers/nouveau/nouveau_context.h |   23 ++
 src/gallium/drivers/nouveau/nouveau_screen.h  |4 +-
 src/gallium/drivers/nouveau/nouveau_winsys.h  |3 +
 src/gallium/drivers/nv30/nv30_context.c   |   78 +-
 src/gallium/drivers/nv50/nv50_context.c   |   82 +
 src/gallium/drivers/nv50/nv50_screen.c|2 +-
 src/gallium/drivers/nv50/nv50_screen.h|3 +-
 src/gallium/drivers/nvc0/nvc0_context.c   |   86 ++
 src/gallium/drivers/nvc0/nvc0_screen.c|2 +-
 src/gallium/drivers/nvc0/nvc0_screen.h|3 +-
 12 files changed, 551 insertions(+), 137 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c 
b/src/gallium/drivers/nouveau/nouveau_buffer.c
index 0ecd53a..fd5 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -10,8 +10,15 @@
 #include "nouveau_buffer.h"
 #include "nouveau_mm.h"
 
+#define NOUVEAU_TRANSFER_PUSHBUF_THRESHOLD 192
+
 struct nouveau_transfer {
struct pipe_transfer base;
+
+   uint8_t *map;
+   struct nouveau_bo *bo;
+   struct nouveau_mm_allocation *mm;
+   uint32_t offset;
 };
 
 static INLINE struct nouveau_transfer *
@@ -21,6 +28,14 @@ nouveau_transfer(struct pipe_transfer *transfer)
 }
 
 static INLINE boolean
+nouveau_buffer_malloc(struct nv04_resource *buf)
+{
+   if (!buf->data)
+  buf->data = align_malloc(buf->base.width0, NOUVEAU_MIN_BUFFER_MAP_ALIGN);
+   return !!buf->data;
+}
+
+static INLINE boolean
 nouveau_buffer_allocate(struct nouveau_screen *screen,
 struct nv04_resource *buf, unsigned domain)
 {
@@ -40,13 +55,10 @@ nouveau_buffer_allocate(struct nouveau_screen *screen,
 &buf->bo, &buf->offset);
   if (!buf->bo)
  return FALSE;
-   }
-   if (domain != NOUVEAU_BO_GART) {
-  if (!buf->data) {
- buf->data = align_malloc(buf->base.width0, 64);
- if (!buf->data)
-return FALSE;
-  }
+   } else {
+  assert(domain == 0);
+  if (!nouveau_buffer_malloc(buf))
+ return FALSE;
}
buf->domain = domain;
if (buf->bo)
@@ -80,6 +92,11 @@ nouveau_buffer_reallocate(struct nouveau_screen *screen,
 {
nouveau_buffer_release_gpu_storage(buf);
 
+   nouveau_fence_ref(NULL, &buf->fence);
+   nouveau_fence_ref(NULL, &buf->fence_wr);
+
+   buf->status &= NOUVEAU_BUFFER_STATUS_REALLOC_MASK;
+
return nouveau_buffer_allocate(screen, buf, domain);
 }
 
@@ -100,73 +117,75 @@ nouveau_buffer_destroy(struct pipe_screen *pscreen,
FREE(res);
 }
 
-/* Maybe just migrate to GART right away if we actually need to do this. */
-boolean
-nouveau_buffer_download(struct nouveau_context *nv, struct nv04_resource *buf,
-unsigned start, unsigned size)
+static uint8_t *
+nouveau_transfer_staging(struct nouveau_context *nv,
+ struct nouveau_transfer *tx, boolean permit_pb)
 {
-   struct nouveau_mm_allocation *mm;
-   struct nouveau_bo *bounce = NULL;
-   uint32_t offset;
+   const unsigned adj = tx->base.box.x & NOUVEAU_MIN_BUFFER_MAP_ALIGN_MASK;
+   const unsigned size = align(tx->base.box.width, 4) + adj;
 
-   assert(buf->domain == NOUVEAU_BO_VRAM);
+   if ((size <= NOUVEAU_TRANSFER_PUSHBUF_THRESHOLD) && permit_pb) {
+  tx->map = align_malloc(size, NOUVEAU_MIN_BUFFER_MAP_ALIGN);
+  if (tx->map)
+ tx->map += adj;
+   } else {
+  tx->mm =
+ nouveau_mm_allocate(nv->screen->mm_GART, size, &tx->bo, &tx->offset);
+  if (tx->bo) {
+ tx->offset += adj;
+ if (!nouveau_bo_map(tx->bo, 0, NULL))
+tx->map = (uint8_t *)tx->bo->map + tx->offset;
+  }
+   }
+   return tx->map;
+}
 
-   mm = nouveau_mm_allocate(nv->screen->mm_GART, size, &bounce, &offset);
-   if (!bounce)
-  return FALSE;
+/* Maybe just migrate to GART right away if we actually need to do this. */
+static boolean
+nouveau_transfer_read(struct nouveau_context *nv, struct nouveau_transfer *tx)
+{
+   struct nv04_resource *buf = nv04_resource(tx->base.resource);
+   const unsigned base = tx->base.box.x;
+   const unsigned size = tx->base.box.width;
 
-   nv->copy_data(nv, bounce, offset, NOUVEAU_BO_GART,
- buf->bo, buf->offset + start, NOUVEAU_BO_VRAM, size);
+   nv->copy_data(nv, tx->bo, tx->offset, NOUVEAU_BO_GART,
+ buf->bo, buf->offset + base, buf->domain, size);
 
-   if

Mesa (master): r300g: fix assertion failure in emit_dsa_state

2013-01-08 Thread Marek Olšák
Module: Mesa
Branch: master
Commit: a75ddfd55d24363046f11b2fd2de25563698fa39
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a75ddfd55d24363046f11b2fd2de25563698fa39

Author: Marek Olšák 
Date:   Tue Jan  8 14:32:41 2013 +0100

r300g: fix assertion failure in emit_dsa_state

Broken by 8ed6b1400bc8a78f46340f41aaf2e88b24c23267.

---

 src/gallium/drivers/r300/r300_cs.h   |4 ++--
 src/gallium/drivers/r300/r300_emit.c |4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_cs.h 
b/src/gallium/drivers/r300/r300_cs.h
index c208e67..744e19e 100644
--- a/src/gallium/drivers/r300/r300_cs.h
+++ b/src/gallium/drivers/r300/r300_cs.h
@@ -96,8 +96,8 @@
 OUT_CS(CP_PACKET3(op, count))
 
 #define OUT_CS_TABLE(values, count) do { \
-memcpy(cs_copy->buf + cs_copy->cdw, values, count * 4); \
-cs_copy->cdw += count; \
+memcpy(cs_copy->buf + cs_copy->cdw, (values), (count) * 4); \
+cs_copy->cdw += (count); \
 CS_USED_DW(count); \
 } while (0)
 
diff --git a/src/gallium/drivers/r300/r300_emit.c 
b/src/gallium/drivers/r300/r300_emit.c
index 3f61444..4163d2d 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -100,8 +100,10 @@ void r300_emit_dsa_state(struct r300_context* r300, 
unsigned size, void* state)
   R300_FG_ALPHA_FUNC_CFG_3_OF_6;
 }
 
+BEGIN_CS(size);
 OUT_CS_REG(R300_FG_ALPHA_FUNC, alpha_func);
-WRITE_CS_TABLE(fb->zsbuf ? &dsa->cb_begin : dsa->cb_zb_no_readwrite, 
size-2);
+OUT_CS_TABLE(fb->zsbuf ? &dsa->cb_begin : dsa->cb_zb_no_readwrite, 8);
+END_CS;
 }
 
 static void get_rc_constant_state(

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