[Mesa-dev] [PATCH] Use probed $LLVM_CONFIG value instead of hard-coding it

2012-06-28 Thread Luca Tettamanti
It makes it easier to use a non-default llvm-config binary.

Signed-off-by: Luca Tettamanti kronos...@gmail.com
---
 configure.ac |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 46265a2..4572ee3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1866,7 +1866,7 @@ if test x$enable_gallium_llvm = xyes; then
else
LLVM_LIBS=`$LLVM_CONFIG --libs engine bitwriter`
 if test x$enable_opencl = xyes; then
-LLVM_LIBS=${LLVM_LIBS} `llvm-config --libs ipo linker 
instrumentation`
+LLVM_LIBS=${LLVM_LIBS} `$LLVM_CONFIG --libs ipo linker 
instrumentation`
 fi
fi
LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
@@ -2024,7 +2024,7 @@ if test x$with_gallium_drivers != x; then
 USE_R600_LLVM_COMPILER=yes;
 fi
 if test x$enable_opencl = xyes -a x$with_llvm_shared_libs = 
xno; then
-LLVM_LIBS=${LLVM_LIBS} `llvm-config --libs bitreader 
asmparser`
+LLVM_LIBS=${LLVM_LIBS} `$LLVM_CONFIG --libs bitreader 
asmparser`
 fi
 gallium_check_st radeon/drm dri-r600 xorg-r600  
xvmc-r600 vdpau-r600 va-r600
 ;;
-- 
1.7.10

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


[Mesa-dev] [PATCH] gallivm: Fix potential buffer overflowing in strncat.

2012-06-28 Thread Johannes Obermayr
---
 src/gallium/auxiliary/gallivm/lp_bld_printf.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c 
b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
index 16ef25a..35e9197 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
@@ -118,16 +118,16 @@ lp_build_print_value(struct gallivm_state *gallivm,
 
params[1] = lp_build_const_string(gallivm, msg);
if (length == 1) {
-  util_strncat(format, type_fmt, sizeof format);
+  util_strncat(format, type_fmt, sizeof(format)-strlen(format)-1);
   params[2] = value;
} else {
   for (i = 0; i  length; ++i) {
- util_strncat(format, type_fmt, sizeof format);
+ util_strncat(format, type_fmt, sizeof(format)-strlen(format)-1);
  params[2 + i] = LLVMBuildExtractElement(builder, value, 
lp_build_const_int32(gallivm, i), );
   }
}
 
-   util_strncat(format, \n, sizeof format);
+   util_strncat(format, \n, sizeof(format)-strlen(format)-1);
 
params[0] = lp_build_const_string(gallivm, format);
return lp_build_print_args(gallivm, 2 + length, params);
-- 
1.7.7

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


Re: [Mesa-dev] [PATCH] gallivm: Fix potential buffer overflowing in strncat.

2012-06-28 Thread Jose Fonseca
Pushed. Thanks.

Jose

- Original Message -
 ---
  src/gallium/auxiliary/gallivm/lp_bld_printf.c |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c
 b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
 index 16ef25a..35e9197 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c
 @@ -118,16 +118,16 @@ lp_build_print_value(struct gallivm_state
 *gallivm,
  
 params[1] = lp_build_const_string(gallivm, msg);
 if (length == 1) {
 -  util_strncat(format, type_fmt, sizeof format);
 +  util_strncat(format, type_fmt,
 sizeof(format)-strlen(format)-1);
params[2] = value;
 } else {
for (i = 0; i  length; ++i) {
 - util_strncat(format, type_fmt, sizeof format);
 + util_strncat(format, type_fmt,
 sizeof(format)-strlen(format)-1);
   params[2 + i] = LLVMBuildExtractElement(builder, value,
   lp_build_const_int32(gallivm, i), );
}
 }
  
 -   util_strncat(format, \n, sizeof format);
 +   util_strncat(format, \n, sizeof(format)-strlen(format)-1);
  
 params[0] = lp_build_const_string(gallivm, format);
 return lp_build_print_args(gallivm, 2 + length, params);
 --
 1.7.7
 
 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 51515] New: eglmesaext.h isn't installed on a gallium setup

2012-06-28 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=51515

 Bug #: 51515
   Summary: eglmesaext.h isn't installed on a gallium setup
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: x86-64 (AMD64)
OS/Version: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: m...@fireburn.co.uk


Created attachment 63559
  -- https://bugs.freedesktop.org/attachment.cgi?id=63559
i965 + r600g

eglmesaext.h isn't installed when I only build with gallium and r600 - it works
fine on the same setup with i965 and classic added too - both have egl switched
on

Was only noticed as kwin requires the file

I'm including the build logs in case it helps

-- 
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 51515] eglmesaext.h isn't installed on a gallium setup

2012-06-28 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=51515

--- Comment #1 from Mike Lothian m...@fireburn.co.uk 2012-06-28 03:59:42 PDT 
---
Created attachment 63560
  -- https://bugs.freedesktop.org/attachment.cgi?id=63560
r600g on it's own

-- 
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] lp_build_lod_selector: Disable brilinear folding on explicit lod.

2012-06-28 Thread Jose Fonseca
- Original Message -
 On Wed, Jun 27, 2012 at 03:17:05AM -0700, Jose Fonseca wrote:
  I took a look at the results, and it seems to me that bri linear
  code is fine -- the test is merely too strict, and doesnot forgive
  the gravitation towards integer lod that brilinear implements.
 
 Yes, the current code maps [0,.25] to 0, [0.25,0.75] to [0-1] and
 [0.75,1] to 1.  So you you need an error tolerance of 0.20 given how
 the test is done on multiples of 0.2.

Thanks for confirming.
 
 What's your criteria to decide that a precision is good enough?

It's subjective.

My suggestion is to set GALLIVM_DEBUG=no_brilinear when running piglit for now, 
and when time permits, make the brilinear code conditional upon the contents of 
the textures (i.e., disbale brilinear when successive miplevels have totally 
different content) which would mean that the error would be visually very 
small, and that all tests would pass (was they typically don't meet the 
requirements). I believe this is what other drivers/hardware that uses 
brilinear also do.

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


Re: [Mesa-dev] [PATCH] clover: Increment an object's reference count in ret_object()

2012-06-28 Thread Tom Stellard
On Thu, Jun 28, 2012 at 01:09:20AM +0200, Francisco Jerez wrote:
 Tom Stellard tstel...@gmail.com writes:
 
  We need to increment the reference count for objects, like cl_event,
  that the user is responsible for destroying when they are returned from
  the API.  Otherwise, the object will be destroyed when clover is done with
  it, even though the user will still have a reference to it.  For example:
 
  1. clEnqueueNDRangeKernel(queue, ... , event)
- create an event object
- refcount = 1
 
  2. clFlush(queue)
- event object is removed from the queue and its reference count is
  decremented.
- refcount = 0, event is deleted
 
  3. clGetEventInfo(event, ...)
- segfault
 
 I don't think this could cause the problem you've seen...  After step 1
 the event object ends up queued in queue-queued_events, a ref_ptr
 list that holds additional references to each object it contains, so,
 after step 1 refcount is supposed to be 2 already...  You're probably
 hitting something more subtle, try the attached patch.


I missed that part about ref_ptr.  I'll have to look at that again.
However that sequence is causing a segfault in clGetEventInfo in all
of the AMD OpenCL SDK examples (or at least all of them that make it
that far), and it is because the event is being deleted too early.

-Tom

 
 PS: Can you CC me when you send clover-related patches to the mailing
 list?  I'm likely to miss them otherwise.
 
  ---
   src/gallium/state_trackers/clover/api/util.hpp |4 +++-
   1 files changed, 3 insertions(+), 1 deletions(-)
 
  diff --git a/src/gallium/state_trackers/clover/api/util.hpp 
  b/src/gallium/state_trackers/clover/api/util.hpp
  index 2f9ec1f..5cfc528 100644
  --- a/src/gallium/state_trackers/clover/api/util.hpp
  +++ b/src/gallium/state_trackers/clover/api/util.hpp
  @@ -156,8 +156,10 @@ namespace clover {
  templatetypename T, typename S
  void
  ret_object(T p, S v) {
  -  if (p)
  +  if (p) {
*p = v;
  + v-retain();
  +  }
 else
v-release();
  }
 

 diff --git a/src/gallium/state_trackers/clover/core/base.hpp 
 b/src/gallium/state_trackers/clover/core/base.hpp
 index 19053f3..2a2e26a 100644
 --- a/src/gallium/state_trackers/clover/core/base.hpp
 +++ b/src/gallium/state_trackers/clover/core/base.hpp
 @@ -88,8 +88,7 @@ namespace clover {
   reset(q);
}
  
 -  templatetypename S
 -  ref_ptr(const ref_ptrS ref) : p(NULL) {
 +  ref_ptr(const ref_ptrT ref) : p(NULL) {
   reset(ref.p);
}
  




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


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


Re: [Mesa-dev] [PATCH] msaa: Make meta-ops save and restore state of GL_MULTISAMPLE.

2012-06-28 Thread Brian Paul

On 06/27/2012 05:51 PM, Paul Berry wrote:

The meta-ops _mesa_meta_Clear() and _mesa_meta_glsl_Clear() need to
ignore the state of GL_SAMPLE_ALPHA_TO_COVERAGE,
GL_SAMPLE_ALPHA_TO_ONE, GL_SAMPLE_COVERAGE, GL_SAMPLE_COVERAGE_VALUE,
and GL_SAMPLE_COVERAGE_INVERT when clearing multisampled buffers.  The
easiest way to accomplish this is to disable GL_MULTISAMPLE during the
clear meta-ops.

Note: this patch also causes GL_MULTISAMPLE to be disabled during
_mesa_meta_GenerateMipmap() and _mesa_meta_GetTexImage() (since those
two meta-ops use MESA_META_ALL).  Arguably this isn't strictly
necessary, since those meta-ops use their own non-MSAA fbo's, but it
shouldn't do any harm.

Fixes Piglit tests EXT_framebuffer_multisample/clear {2,4}
{color,stencil} on i965.
---
  src/mesa/drivers/common/meta.c |   17 -
  src/mesa/drivers/common/meta.h |1 +
  2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index be7141a..5e9d795 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -181,6 +181,9 @@ struct save_state
 struct gl_feedback Feedback;
  #endif

+   /** MESA_META_MULTISAMPLE */
+   GLboolean MultisampleEnabled;
+
 /** Miscellaneous (always disabled) */
 GLboolean Lighting;
 GLboolean RasterDiscard;
@@ -733,6 +736,12 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
 }
  #endif

+   if (state  MESA_META_MULTISAMPLE) {
+  save-MultisampleEnabled = ctx-Multisample.Enabled;
+  if (ctx-Multisample.Enabled)
+ _mesa_set_enable(ctx, GL_MULTISAMPLE, GL_FALSE);
+   }
+
 /* misc */
 {
save-Lighting = ctx-Light.Enabled;
@@ -1018,6 +1027,11 @@ _mesa_meta_end(struct gl_context *ctx)
 }
  #endif

+   if (state  MESA_META_MULTISAMPLE) {
+  if (ctx-Multisample.Enabled != save-MultisampleEnabled)
+ _mesa_set_enable(ctx, GL_MULTISAMPLE, save-MultisampleEnabled);
+   }
+
 /* misc */
 if (save-Lighting) {
_mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE);
@@ -1902,7 +1916,8 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield 
buffers)
   MESA_META_VERTEX |
   MESA_META_VIEWPORT |
   MESA_META_CLIP |
-  MESA_META_CLAMP_FRAGMENT_COLOR);
+  MESA_META_CLAMP_FRAGMENT_COLOR |
+   MESA_META_MULTISAMPLE);

 if (!(buffers  BUFFER_BITS_COLOR)) {
/* We'll use colormask to disable color writes.  Otherwise,
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 7a80b1d..d8dfb56 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -55,6 +55,7 @@
  #define MESA_META_CONDITIONAL_RENDER0x2
  #define MESA_META_CLIP  0x4
  #define MESA_META_SELECT_FEEDBACK   0x8
+#define MESA_META_MULTISAMPLE  0x10
  /**\}*/

  extern void


Looks good.

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


Re: [Mesa-dev] [PATCH] clover: Add a function internalizer pass before LTO

2012-06-28 Thread Francisco Jerez
Tom Stellard thomas.stell...@amd.com writes:

 I'll commit this tomorrow unless there are objections.

Looks OK to me, aside from the std::vector's being passed around by
value instead of by const reference.

 -Tom

 On Thu, Jun 21, 2012 at 02:05:24PM -0400, Tom Stellard wrote:
 The function internalizer pass marks non-kernel functions as internal,
 which enables optimizations like function inlining and global dead-code
 elimination.
 ---
  .../state_trackers/clover/llvm/invocation.cpp  |   58 
 
  1 files changed, 48 insertions(+), 10 deletions(-)
 
 diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
 b/src/gallium/state_trackers/clover/llvm/invocation.cpp
 index 27276bc..2d155d5 100644
 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
 +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
 @@ -36,6 +36,7 @@
  #include llvm/Support/MemoryBuffer.h
  #include llvm/Support/PathV1.h
  #include llvm/Target/TargetData.h
 +#include llvm/Transforms/IPO.h
  #include llvm/Transforms/IPO/PassManagerBuilder.h
  
  #include pipe/p_state.h
 @@ -134,7 +135,18 @@ namespace {
 }
  
 void
 -   link(llvm::Module *mod, const std::string triple) {
 +   find_kernels(llvm::Module *mod, std::vectorllvm::Function * kernels) {
 +  const llvm::NamedMDNode *kernel_node =
 + mod-getNamedMetadata(opencl.kernels);
 +  for (unsigned i = 0; i  kernel_node-getNumOperands(); ++i) {
 + kernels.push_back(llvm::dyn_castllvm::Function(
 +
 kernel_node-getOperand(i)-getOperand(0)));
 +  }
 +   }
 +
 +   void
 +   link(llvm::Module *mod, const std::string triple,
 +std::vectorllvm::Function * kernels) {
  
llvm::PassManager PM;
llvm::PassManagerBuilder Builder;
 @@ -145,14 +157,37 @@ namespace {
linker.LinkInFile(llvm::sys::Path(LIBCLC_PATH + triple + 
 /lib/builtins.bc), isNative);
mod = linker.releaseModule();
  
 +  // Add a function internalizer pass.
 +  //
 +  // By default, the function internalizer pass will look for a function
 +  // called main and then mark all other functions as internal.  
 Marking
 +  // functions as internal enables the optimizer to perform 
 optimizations
 +  // like function inlining and global dead-code elimination.
 +  //
 +  // When there is no main function in a module, the internalize pass 
 will
 +  // treat the module like a library, and it won't internalize any 
 functions.
 +  // Since there is no main function in our kernels, we need to tell
 +  // the internalizer pass that this module is not a library by passing 
 a
 +  // list of kernel functions to the internalizer.  The internalizer 
 will
 +  // treat the functions in the list as main functions and internalize
 +  // all of the other functions.
 +  std::vectorconst char* export_list;
 +  for (std::vectorllvm::Function *::iterator I = kernels.begin(),
 +   E = kernels.end();
 +   I != E; ++I) {
 + llvm::Function *kernel = *I;
 + export_list.push_back(kernel-getName().data());
 +  }
 +  PM.add(llvm::createInternalizePass(export_list));
 +
// Run link time optimizations
 -  Builder.populateLTOPassManager(PM, false, true);
Builder.OptLevel = 2;
 +  Builder.populateLTOPassManager(PM, false, true);
PM.run(*mod);
 }
  
 module
 -   build_module_llvm(llvm::Module *mod) {
 +   build_module_llvm(llvm::Module *mod, std::vectorllvm::Function * 
 kernels) {
  
module m;
struct pipe_llvm_program_header header;
 @@ -163,15 +198,14 @@ namespace {
llvm::WriteBitcodeToFile(mod, bitcode_ostream);
bitcode_ostream.flush();
  
 +  llvm::Function * kernel_func;
std::string kernel_name;
compat::vectormodule::argument args;
 -  const llvm::NamedMDNode *kernel_node =
 - mod-getNamedMetadata(opencl.kernels);
 +
// XXX: Support more than one kernel
 -  assert(kernel_node-getNumOperands() = 1);
 +  assert(kernels.size() == 1);
  
 -  llvm::Function *kernel_func = llvm::dyn_castllvm::Function(
 -   
 kernel_node-getOperand(0)-getOperand(0));
 +  kernel_func = kernels[0];
kernel_name = kernel_func-getName();
  
for (llvm::Function::arg_iterator I = kernel_func-arg_begin(),
 @@ -219,9 +253,13 @@ clover::compile_program_llvm(const compat::string 
 source,
   enum pipe_shader_ir ir,
   const compat::string triple) {
  
 +   std::vectorllvm::Function * kernels;
 +
 llvm::Module *mod = compile(source, cl_input, triple);
  
 -   link(mod, triple);
 +   find_kernels(mod, kernels);
 +
 +   link(mod, triple, kernels);
  
 // Build the clover::module
 

Re: [Mesa-dev] [PATCH] clover: Increment an object's reference count in ret_object()

2012-06-28 Thread Francisco Jerez
Tom Stellard thomas.stell...@amd.com writes:

 On Thu, Jun 28, 2012 at 01:09:20AM +0200, Francisco Jerez wrote:
 Tom Stellard tstel...@gmail.com writes:
 
  We need to increment the reference count for objects, like cl_event,
  that the user is responsible for destroying when they are returned from
  the API.  Otherwise, the object will be destroyed when clover is done with
  it, even though the user will still have a reference to it.  For example:
 
  1. clEnqueueNDRangeKernel(queue, ... , event)
- create an event object
- refcount = 1
 
  2. clFlush(queue)
- event object is removed from the queue and its reference count is
  decremented.
- refcount = 0, event is deleted
 
  3. clGetEventInfo(event, ...)
- segfault
 
 I don't think this could cause the problem you've seen...  After step 1
 the event object ends up queued in queue-queued_events, a ref_ptr
 list that holds additional references to each object it contains, so,
 after step 1 refcount is supposed to be 2 already...  You're probably
 hitting something more subtle, try the attached patch.


 I missed that part about ref_ptr.  I'll have to look at that again.
 However that sequence is causing a segfault in clGetEventInfo in all
 of the AMD OpenCL SDK examples (or at least all of them that make it
 that far), and it is because the event is being deleted too early.

Yes, probably because the user-defined copy constructor of
ref_ptrhard_event is not being used by the event queue because it's
defined as a template, try the patch I attached.

[...]


pgpm8jKAGMAyR.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] r600g: improve flushed depth texture handling v2

2012-06-28 Thread Vadim Girlin
On Tue, 2012-06-26 at 19:40 -0400, Alex Deucher wrote:
 On Tue, Jun 26, 2012 at 7:34 PM, Vadim Girlin vadimgir...@gmail.com wrote:
  Use r600_resource_texture::flished_depth_texture for GPU access, and
  allocate it in the VRAM. For transfers we'll allocate untiled texture in the
  GTT and store it in the r600_transfer::staging.
 
  Improves performance when flushed depth texture is frequently used by the
  GPU (about 30% for Lightsmark).
 
  Signed-off-by: Vadim Girlin vadimgir...@gmail.com
  ---
 
  Fixes fbo-clear-formats, fbo-generatemipmap-formats, no regressions on
  evergreen
 
 This looks similar to Fredrik's patch:
 http://people.freedesktop.org/~fredrik/0001-r600g-be-smarter-about-domain-selection-for-depth-te.patch

Yes, generally the idea is the same. My patch also drops
R600_RESOURCE_FLAG_TRANSFER for the VRAM case, resulting in further
performance improvement. I've noticed 2x-3x fps boost in some scenes of
the Lightsmark after dropping this flag (e.g. hard shadows scene, also
the scene right after penumbra shadows), though I'm not sure yet why
it's so significant, will look into it. 

Vadim

 Although I think your patch cleans things up a bit nicer.
 
 Alex
 
 
   src/gallium/drivers/r600/evergreen_state.c |5 +-
   src/gallium/drivers/r600/r600_blit.c   |   21 +++---
   src/gallium/drivers/r600/r600_pipe.h   |4 +-
   src/gallium/drivers/r600/r600_resource.h   |6 +-
   src/gallium/drivers/r600/r600_state.c  |2 +-
   src/gallium/drivers/r600/r600_texture.c|  106 
  
   6 files changed, 83 insertions(+), 61 deletions(-)
 
  diff --git a/src/gallium/drivers/r600/evergreen_state.c 
  b/src/gallium/drivers/r600/evergreen_state.c
  index f0fdd2b..2aa5ccb 100644
  --- a/src/gallium/drivers/r600/evergreen_state.c
  +++ b/src/gallium/drivers/r600/evergreen_state.c
  @@ -988,7 +988,7 @@ static struct pipe_sampler_view 
  *evergreen_create_sampler_view(struct pipe_conte
 }
 
 if (tmp-is_depth  !tmp-is_flushing_texture) {
  -   r600_init_flushed_depth_texture(ctx, texture);
  +   r600_init_flushed_depth_texture(ctx, texture, NULL);
 tmp = tmp-flushed_depth_texture;
 if (!tmp) {
 FREE(view);
  @@ -1314,7 +1314,8 @@ static void evergreen_cb(struct r600_context *rctx, 
  struct r600_pipe_state *rsta
 rctx-have_depth_fb = TRUE;
 
 if (rtex-is_depth  !rtex-is_flushing_texture) {
  -   r600_init_flushed_depth_texture(rctx-context, 
  state-cbufs[cb]-texture);
  +   r600_init_flushed_depth_texture(rctx-context,
  +   state-cbufs[cb]-texture, NULL);
 rtex = rtex-flushed_depth_texture;
 assert(rtex);
 }
  diff --git a/src/gallium/drivers/r600/r600_blit.c 
  b/src/gallium/drivers/r600/r600_blit.c
  index 031cd39..90d1992 100644
  --- a/src/gallium/drivers/r600/r600_blit.c
  +++ b/src/gallium/drivers/r600/r600_blit.c
  @@ -114,13 +114,17 @@ static unsigned u_num_layers(struct pipe_resource *r, 
  unsigned level)
 }
   }
 
  -void r600_blit_uncompress_depth(struct pipe_context *ctx, struct 
  r600_resource_texture *texture)
  +void r600_blit_uncompress_depth(struct pipe_context *ctx,
  +   struct r600_resource_texture *texture,
  +   struct r600_resource_texture *staging)
   {
 struct r600_context *rctx = (struct r600_context *)ctx;
 unsigned layer, level;
 float depth = 1.0f;
  +   struct r600_resource_texture *flushed_depth_texture = staging ?
  +   staging : texture-flushed_depth_texture;
 
  -   if (!texture-dirty_db)
  +   if (!staging  !texture-dirty_db)
 return;
 
 if (rctx-family == CHIP_RV610 || rctx-family == CHIP_RV630 ||
  @@ -141,10 +145,10 @@ void r600_blit_uncompress_depth(struct pipe_context 
  *ctx, struct r600_resource_t
 
 zsurf = ctx-create_surface(ctx, 
  texture-resource.b.b, surf_tmpl);
 
  -   surf_tmpl.format = 
  texture-flushed_depth_texture-real_format;
  +   surf_tmpl.format = 
  flushed_depth_texture-real_format;
 surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
 cbsurf = ctx-create_surface(ctx,
  -   (struct 
  pipe_resource*)texture-flushed_depth_texture, surf_tmpl);
  +   (struct 
  pipe_resource*)flushed_depth_texture, surf_tmpl);
 
 r600_blitter_begin(ctx, R600_DECOMPRESS);
 util_blitter_custom_depth_stencil(rctx-blitter, 
  zsurf, cbsurf, rctx-custom_dsa_flush, depth);
  @@ -155,7 +159,8 @@ void r600_blit_uncompress_depth(struct pipe_context 
  *ctx, struct r600_resource_t
 }
 }
 
  -   texture-dirty_db = FALSE;
  +   if (!staging)
  +   

[Mesa-dev] [PATCH] clover: Add a function internalizer pass before LTO v2

2012-06-28 Thread Tom Stellard
The function internalizer pass marks non-kernel functions as internal,
which enables optimizations like function inlining and global dead-code
elimination.

v2:
  - Pass vector arguments by const reference
---
 .../state_trackers/clover/llvm/invocation.cpp  |   59 ---
 1 files changed, 49 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 27276bc..be15e96 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -36,6 +36,7 @@
 #include llvm/Support/MemoryBuffer.h
 #include llvm/Support/PathV1.h
 #include llvm/Target/TargetData.h
+#include llvm/Transforms/IPO.h
 #include llvm/Transforms/IPO/PassManagerBuilder.h
 
 #include pipe/p_state.h
@@ -134,7 +135,18 @@ namespace {
}
 
void
-   link(llvm::Module *mod, const std::string triple) {
+   find_kernels(llvm::Module *mod, std::vectorllvm::Function * kernels) {
+  const llvm::NamedMDNode *kernel_node =
+ mod-getNamedMetadata(opencl.kernels);
+  for (unsigned i = 0; i  kernel_node-getNumOperands(); ++i) {
+ kernels.push_back(llvm::dyn_castllvm::Function(
+
kernel_node-getOperand(i)-getOperand(0)));
+  }
+   }
+
+   void
+   link(llvm::Module *mod, const std::string triple,
+const std::vectorllvm::Function * kernels) {
 
   llvm::PassManager PM;
   llvm::PassManagerBuilder Builder;
@@ -145,14 +157,38 @@ namespace {
   linker.LinkInFile(llvm::sys::Path(LIBCLC_PATH + triple + 
/lib/builtins.bc), isNative);
   mod = linker.releaseModule();
 
+  // Add a function internalizer pass.
+  //
+  // By default, the function internalizer pass will look for a function
+  // called main and then mark all other functions as internal.  Marking
+  // functions as internal enables the optimizer to perform optimizations
+  // like function inlining and global dead-code elimination.
+  //
+  // When there is no main function in a module, the internalize pass 
will
+  // treat the module like a library, and it won't internalize any 
functions.
+  // Since there is no main function in our kernels, we need to tell
+  // the internalizer pass that this module is not a library by passing a
+  // list of kernel functions to the internalizer.  The internalizer will
+  // treat the functions in the list as main functions and internalize
+  // all of the other functions.
+  std::vectorconst char* export_list;
+  for (std::vectorllvm::Function *::const_iterator I = kernels.begin(),
+ E = kernels.end();
+ I != E; ++I) {
+ llvm::Function *kernel = *I;
+ export_list.push_back(kernel-getName().data());
+  }
+  PM.add(llvm::createInternalizePass(export_list));
+
   // Run link time optimizations
-  Builder.populateLTOPassManager(PM, false, true);
   Builder.OptLevel = 2;
+  Builder.populateLTOPassManager(PM, false, true);
   PM.run(*mod);
}
 
module
-   build_module_llvm(llvm::Module *mod) {
+   build_module_llvm(llvm::Module *mod,
+ const std::vectorllvm::Function * kernels) {
 
   module m;
   struct pipe_llvm_program_header header;
@@ -163,15 +199,14 @@ namespace {
   llvm::WriteBitcodeToFile(mod, bitcode_ostream);
   bitcode_ostream.flush();
 
+  llvm::Function *kernel_func;
   std::string kernel_name;
   compat::vectormodule::argument args;
-  const llvm::NamedMDNode *kernel_node =
- mod-getNamedMetadata(opencl.kernels);
+
   // XXX: Support more than one kernel
-  assert(kernel_node-getNumOperands() = 1);
+  assert(kernels.size() == 1);
 
-  llvm::Function *kernel_func = llvm::dyn_castllvm::Function(
-   kernel_node-getOperand(0)-getOperand(0));
+  kernel_func = kernels[0];
   kernel_name = kernel_func-getName();
 
   for (llvm::Function::arg_iterator I = kernel_func-arg_begin(),
@@ -219,9 +254,13 @@ clover::compile_program_llvm(const compat::string source,
  enum pipe_shader_ir ir,
  const compat::string triple) {
 
+   std::vectorllvm::Function * kernels;
+
llvm::Module *mod = compile(source, cl_input, triple);
 
-   link(mod, triple);
+   find_kernels(mod, kernels);
+
+   link(mod, triple, kernels);
 
// Build the clover::module
switch (ir) {
@@ -230,6 +269,6 @@ clover::compile_program_llvm(const compat::string source,
  assert(0);
  return module();
   default:
- return build_module_llvm(mod);
+ return build_module_llvm(mod, kernels);
}
 }
-- 
1.7.7.6


Re: [Mesa-dev] GL_ARB_ubo spec question

2012-06-28 Thread Brian Paul

On 06/27/2012 12:01 PM, Eric Anholt wrote:

How should glBindBufferBase and glBindBufferRange treat bad buffer
arguments?  I see two relevant pieces of spec:

 The error INVALID_OPERATION is generated by BindBufferRange and
  BindBufferBase ifbuffer  is not the name of a valid buffer
  object.

and

(60) When using this extension with OpenGL 2.1/3.0, do we require
 that uniform buffer object names must be generated with glGenBuffers
 to be used with these new entry points?

 For OpenGL 3.1 core, there is a blanket requirement to call glGen
 for object names.

 For OpenGL 2.x, there is not a requirement to call glGen but in
 3.0, user-generated names have been deprecated.

 For 3.0, we added two new object types (FBO/VAO) that
 required the user to call glGen, but existing object types
 (textures/renderbuffers/buffer objects) could be used
 without calling glGen.

 We need to decide what to do with this when exporting
 this extension on 2.1 and 3.0.

 RESOLUTION: Resolved, this extension does not govern the creation of
 buffer objects.  That's done by BindBuffer, which is not altered
 by this spec, so on 2.1 and 3.0 you'd be able to use any name,
 whereas on 3.1 you'd be required to call GenBuffers.

Does this mean that only glBindBuffer does the automatic Gen behavior,
and not glBindBufferBase or glBindBufferRange?  That seems strange.  If
so, how about if the buffer has been Genned but not glBindBuffer()ed yet
-- is it still a bad argument?  Also, note that EXT_transform_feedback
doesn't specify the error forbuffer  not being a valid buffer for
glBindBufferBase/glBindBufferRange.


Coincidentally, this is being discussed by the ARB right now.

It sounds like AMD's driver generates GL_INVALID_OPERATION if there's 
no buffer object already defined when glBindBufferBase/Range() are 
called.  That seems to make sense since the buffer's size is used to 
do error checking for glBindBufferRange() so if there's no previously 
defined buffer, the error check would always fail.


But NVIDIA generates a new buffer object if one doesn't already exist. 
 The above-mentioned buffer offset/size check is practically 
meaningless since the buffer size can change later by calling 
glBufferData().


Since the spec isn't clear and other implementations vary, I'd 
probably go for the more forward-looking approach and require that 
buffer is previously gen'd.  I'd probably leave the offset/size check 
in place too, until/if the ARB says differently.


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


Re: [Mesa-dev] [PATCH] clover: Increment an object's reference count in ret_object()

2012-06-28 Thread Tom Stellard
On Thu, Jun 28, 2012 at 03:47:23PM +0200, Francisco Jerez wrote:
 Tom Stellard thomas.stell...@amd.com writes:
 
  On Thu, Jun 28, 2012 at 01:09:20AM +0200, Francisco Jerez wrote:
  Tom Stellard tstel...@gmail.com writes:
  
   We need to increment the reference count for objects, like cl_event,
   that the user is responsible for destroying when they are returned from
   the API.  Otherwise, the object will be destroyed when clover is done 
   with
   it, even though the user will still have a reference to it.  For example:
  
   1. clEnqueueNDRangeKernel(queue, ... , event)
 - create an event object
 - refcount = 1
  
   2. clFlush(queue)
 - event object is removed from the queue and its reference count is
   decremented.
 - refcount = 0, event is deleted
  
   3. clGetEventInfo(event, ...)
 - segfault
  
  I don't think this could cause the problem you've seen...  After step 1
  the event object ends up queued in queue-queued_events, a ref_ptr
  list that holds additional references to each object it contains, so,
  after step 1 refcount is supposed to be 2 already...  You're probably
  hitting something more subtle, try the attached patch.
 
 
  I missed that part about ref_ptr.  I'll have to look at that again.
  However that sequence is causing a segfault in clGetEventInfo in all
  of the AMD OpenCL SDK examples (or at least all of them that make it
  that far), and it is because the event is being deleted too early.
 
 Yes, probably because the user-defined copy constructor of
 ref_ptrhard_event is not being used by the event queue because it's
 defined as a template, try the patch I attached.
 
 [...]


Your patch works.  Thanks.

-Tom

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


[Mesa-dev] [Bug 51531] New: `make distclean` fails in wayland-drm/

2012-06-28 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=51531

 Bug #: 51531
   Summary: `make distclean` fails in wayland-drm/
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: All
OS/Version: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
AssignedTo: mesa-dev@lists.freedesktop.org
ReportedBy: nob...@dreamwidth.org


make[4]: Entering directory `/mesa/src/egl/wayland/wayland-drm'
Makefile:678: *** missing separator.  Stop.

Line 678 in the automake-generated Makefile just:

@wayland_scanner_rules@

-- 
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] [libdrm PATCH 1/4] libkms/intel.c: Fix a memory leak and a dead assignment as well as cleanup code a bit.

2012-06-28 Thread Johannes Obermayr
---
 libkms/intel.c |   23 ---
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libkms/intel.c b/libkms/intel.c
index 8b8249b..7bf1f76 100644
--- a/libkms/intel.c
+++ b/libkms/intel.c
@@ -93,14 +93,18 @@ intel_bo_create(struct kms_driver *kms,
if (!bo)
return -ENOMEM;
 
-   if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) {
+   switch (type) {
+   case KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8:
pitch = 64 * 4;
size = 64 * 64 * 4;
-   } else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) {
+   break;
+   case KMS_BO_TYPE_SCANOUT_X8R8G8B8:
pitch = width * 4;
pitch = (pitch + 512 - 1)  ~(512 - 1);
size = pitch * ((height + 4 - 1)  ~(4 - 1));
-   } else {
+   break;
+   default:
+   free(bo);
return -EINVAL;
}
 
@@ -108,8 +112,10 @@ intel_bo_create(struct kms_driver *kms,
arg.size = size;
 
ret = drmCommandWriteRead(kms-fd, DRM_I915_GEM_CREATE, arg, 
sizeof(arg));
-   if (ret)
-   goto err_free;
+   if (ret) {
+   free(bo);
+   return ret;
+   }
 
bo-base.kms = kms;
bo-base.handle = arg.handle;
@@ -124,9 +130,8 @@ intel_bo_create(struct kms_driver *kms,
tile.handle = bo-base.handle;
tile.tiling_mode = I915_TILING_X;
tile.stride = bo-base.pitch;
-
-   ret = drmCommandWriteRead(kms-fd, DRM_I915_GEM_SET_TILING, 
tile, sizeof(tile));
 #if 0
+   ret = drmCommandWriteRead(kms-fd, DRM_I915_GEM_SET_TILING, 
tile, sizeof(tile));
if (ret) {
kms_bo_destroy(out);
return ret;
@@ -135,10 +140,6 @@ intel_bo_create(struct kms_driver *kms,
}
 
return 0;
-
-err_free:
-   free(bo);
-   return ret;
 }
 
 static int
-- 
1.7.7

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


[Mesa-dev] [libdrm PATCH 2/4] libkms/nouveau.c: Fix a memory leak and cleanup code a bit.

2012-06-28 Thread Johannes Obermayr
---
 libkms/nouveau.c |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/libkms/nouveau.c b/libkms/nouveau.c
index 0e24a15..4cbca96 100644
--- a/libkms/nouveau.c
+++ b/libkms/nouveau.c
@@ -94,14 +94,18 @@ nouveau_bo_create(struct kms_driver *kms,
if (!bo)
return -ENOMEM;
 
-   if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) {
+   switch (type) {
+   case KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8:
pitch = 64 * 4;
size = 64 * 64 * 4;
-   } else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) {
+   break;
+   case KMS_BO_TYPE_SCANOUT_X8R8G8B8:
pitch = width * 4;
pitch = (pitch + 512 - 1)  ~(512 - 1);
size = pitch * height;
-   } else {
+   break;
+   default:
+   free(bo);
return -EINVAL;
}
 
@@ -114,8 +118,10 @@ nouveau_bo_create(struct kms_driver *kms,
arg.channel_hint = 0;
 
ret = drmCommandWriteRead(kms-fd, DRM_NOUVEAU_GEM_NEW, arg, 
sizeof(arg));
-   if (ret)
-   goto err_free;
+   if (ret) {
+   free(bo);
+   return ret;
+   }
 
bo-base.kms = kms;
bo-base.handle = arg.info.handle;
@@ -126,10 +132,6 @@ nouveau_bo_create(struct kms_driver *kms,
*out = bo-base;
 
return 0;
-
-err_free:
-   free(bo);
-   return ret;
 }
 
 static int
-- 
1.7.7

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


[Mesa-dev] [libdrm PATCH 3/4] nouveau/nouveau.c: Fix two memory leaks.

2012-06-28 Thread Johannes Obermayr
---
 nouveau/nouveau.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
index 5aa4107..e91287f 100644
--- a/nouveau/nouveau.c
+++ b/nouveau/nouveau.c
@@ -95,6 +95,7 @@ nouveau_device_wrap(int fd, int close, struct nouveau_device 
**pdev)
(dev-drm_version   0x0100 ||
 dev-drm_version = 0x0200)) {
nouveau_device_del(dev);
+   free(nvdev);
return -EINVAL;
}
 
@@ -105,6 +106,7 @@ nouveau_device_wrap(int fd, int close, struct 
nouveau_device **pdev)
ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, gart);
if (ret) {
nouveau_device_del(dev);
+   free(nvdev);
return ret;
}
 
-- 
1.7.7

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


[Mesa-dev] [libdrm PATCH 4/4] xf86drm.c: Make more code UDEV unrelevant and fix a memory leak.

2012-06-28 Thread Johannes Obermayr
---
 xf86drm.c |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/xf86drm.c b/xf86drm.c
index 6ea068f..798f1fd 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -255,6 +255,7 @@ static int drmMatchBusID(const char *id1, const char *id2, 
int pci_domain_ok)
 return 0;
 }
 
+#if !defined(UDEV)
 /**
  * Handles error checking for chown call.
  *
@@ -284,6 +285,7 @@ static int chown_check_return(const char *path, uid_t 
owner, gid_t group)
path, errno, strerror(errno));
return -1;
 }
+#endif
 
 /**
  * Open the DRM device, creating it if necessary.
@@ -303,13 +305,15 @@ static int drmOpenDevice(long dev, int minor, int type)
 stat_t  st;
 charbuf[64];
 int fd;
+
+sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, 
minor);
+drmMsg(drmOpenDevice: node name is %s\n, buf);
+
+#if !defined(UDEV)
 mode_t  devmode = DRM_DEV_MODE, serv_mode;
 int isroot  = !geteuid();
 uid_t   user= DRM_DEV_UID;
 gid_t   group   = DRM_DEV_GID, serv_group;
-
-sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, 
minor);
-drmMsg(drmOpenDevice: node name is %s\n, buf);
 
 if (drm_server_info) {
drm_server_info-get_perms(serv_group, serv_mode);
@@ -318,7 +322,6 @@ static int drmOpenDevice(long dev, int minor, int type)
group = (serv_group = 0) ? serv_group : DRM_DEV_GID;
 }
 
-#if !defined(UDEV)
 if (stat(DRM_DIR_NAME, st)) {
if (!isroot)
return DRM_ERR_NOT_ROOT;
@@ -1395,8 +1398,10 @@ drm_context_t *drmGetReservedContextList(int fd, int 
*count)
 }
 
 res.contexts = list;
-if (drmIoctl(fd, DRM_IOCTL_RES_CTX, res))
+if (drmIoctl(fd, DRM_IOCTL_RES_CTX, res)) {
+   drmFree(retval);
return NULL;
+}
 
 for (i = 0; i  res.count; i++)
retval[i] = list[i].handle;
-- 
1.7.7

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


[Mesa-dev] [PATCH] r600g: Update number of gprs when adding a vertex instruction

2012-06-28 Thread Tom Stellard
---
 src/gallium/drivers/r600/r600_asm.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_asm.c 
b/src/gallium/drivers/r600/r600_asm.c
index b0cda3a..2341bec 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -1609,6 +1609,10 @@ int r600_bytecode_add_vtx(struct r600_bytecode *bc, 
const struct r600_bytecode_v
bc-ndw += 4;
if ((bc-cf_last-ndw / 4) = 
r600_bytecode_num_tex_and_vtx_instructions(bc))
bc-force_add_cf = 1;
+
+   bc-ngpr = MAX2(bc-ngpr, vtx-src_gpr + 1);
+   bc-ngpr = MAX2(bc-ngpr, vtx-dst_gpr + 1);
+
return 0;
 }
 
-- 
1.7.7.6

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


[Mesa-dev] [PATCH] clover: Handle NULL devs argument in clBuildProgram

2012-06-28 Thread Tom Stellard
If devs is NULL, then the kernel should be compiled for all devices
associated with the program's context.
---
 src/gallium/state_trackers/clover/api/program.cpp |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
b/src/gallium/state_trackers/clover/api/program.cpp
index e874c51..e863e00 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -142,12 +142,16 @@ clBuildProgram(cl_program prog, cl_uint count, const 
cl_device_id *devs,
(!pfn_notify  user_data))
   throw error(CL_INVALID_VALUE);
 
-   if (any_of([](const cl_device_id dev) {
-return !prog-ctx.has_device(dev);
- }, devs, devs + count))
-  throw error(CL_INVALID_DEVICE);
-
-   prog-build({ devs, devs + count });
+   if (devs) {
+  if (any_of([](const cl_device_id dev) {
+   return !prog-ctx.has_device(dev);
+}, devs, devs + count))
+ throw error(CL_INVALID_DEVICE);
+
+  prog-build({ devs, devs + count });
+   } else {
+  prog-build({ prog-ctx.devs.begin(), prog-ctx.devs.end() });
+   }
return CL_SUCCESS;
 
 } catch (error e) {
-- 
1.7.7.6

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


Re: [Mesa-dev] [PATCH] msaa: Make meta-ops save and restore state of GL_MULTISAMPLE.

2012-06-28 Thread Anuj Phogat
On Wed, Jun 27, 2012 at 4:51 PM, Paul Berry stereotype...@gmail.com wrote:
 The meta-ops _mesa_meta_Clear() and _mesa_meta_glsl_Clear() need to
 ignore the state of GL_SAMPLE_ALPHA_TO_COVERAGE,
 GL_SAMPLE_ALPHA_TO_ONE, GL_SAMPLE_COVERAGE, GL_SAMPLE_COVERAGE_VALUE,
 and GL_SAMPLE_COVERAGE_INVERT when clearing multisampled buffers.  The
 easiest way to accomplish this is to disable GL_MULTISAMPLE during the
 clear meta-ops.

 Note: this patch also causes GL_MULTISAMPLE to be disabled during
 _mesa_meta_GenerateMipmap() and _mesa_meta_GetTexImage() (since those
 two meta-ops use MESA_META_ALL).  Arguably this isn't strictly
 necessary, since those meta-ops use their own non-MSAA fbo's, but it
 shouldn't do any harm.

 Fixes Piglit tests EXT_framebuffer_multisample/clear {2,4}
 {color,stencil} on i965.
 ---
  src/mesa/drivers/common/meta.c |   17 -
  src/mesa/drivers/common/meta.h |    1 +
  2 files changed, 17 insertions(+), 1 deletions(-)

 diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
 index be7141a..5e9d795 100644
 --- a/src/mesa/drivers/common/meta.c
 +++ b/src/mesa/drivers/common/meta.c
 @@ -181,6 +181,9 @@ struct save_state
    struct gl_feedback Feedback;
  #endif

 +   /** MESA_META_MULTISAMPLE */
 +   GLboolean MultisampleEnabled;
 +
    /** Miscellaneous (always disabled) */
    GLboolean Lighting;
    GLboolean RasterDiscard;
 @@ -733,6 +736,12 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield 
 state)
    }
  #endif

 +   if (state  MESA_META_MULTISAMPLE) {
 +      save-MultisampleEnabled = ctx-Multisample.Enabled;
 +      if (ctx-Multisample.Enabled)
 +         _mesa_set_enable(ctx, GL_MULTISAMPLE, GL_FALSE);
 +   }
 +
    /* misc */
    {
       save-Lighting = ctx-Light.Enabled;
 @@ -1018,6 +1027,11 @@ _mesa_meta_end(struct gl_context *ctx)
    }
  #endif

 +   if (state  MESA_META_MULTISAMPLE) {
 +      if (ctx-Multisample.Enabled != save-MultisampleEnabled)
 +         _mesa_set_enable(ctx, GL_MULTISAMPLE, save-MultisampleEnabled);
 +   }
 +
    /* misc */
    if (save-Lighting) {
       _mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE);
 @@ -1902,7 +1916,8 @@ _mesa_meta_glsl_Clear(struct gl_context *ctx, 
 GLbitfield buffers)
               MESA_META_VERTEX |
               MESA_META_VIEWPORT |
               MESA_META_CLIP |
 -              MESA_META_CLAMP_FRAGMENT_COLOR);
 +              MESA_META_CLAMP_FRAGMENT_COLOR |
 +               MESA_META_MULTISAMPLE);

    if (!(buffers  BUFFER_BITS_COLOR)) {
       /* We'll use colormask to disable color writes.  Otherwise,
 diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
 index 7a80b1d..d8dfb56 100644
 --- a/src/mesa/drivers/common/meta.h
 +++ b/src/mesa/drivers/common/meta.h
 @@ -55,6 +55,7 @@
  #define MESA_META_CONDITIONAL_RENDER    0x2
  #define MESA_META_CLIP                  0x4
  #define MESA_META_SELECT_FEEDBACK       0x8
 +#define MESA_META_MULTISAMPLE          0x10
  /**\}*/

  extern void
 --
 1.7.7.6

Reviewed-by: Anuj Phogat anuj.pho...@gmail.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [libdrm PATCH 3/4] nouveau/nouveau.c: Fix two memory leaks.

2012-06-28 Thread Marcin Slusarz
On Thu, Jun 28, 2012 at 09:51:57PM +0200, Johannes Obermayr wrote:
 ---
  nouveau/nouveau.c |2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)
 
 diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
 index 5aa4107..e91287f 100644
 --- a/nouveau/nouveau.c
 +++ b/nouveau/nouveau.c
 @@ -95,6 +95,7 @@ nouveau_device_wrap(int fd, int close, struct 
 nouveau_device **pdev)
   (dev-drm_version   0x0100 ||
dev-drm_version = 0x0200)) {
   nouveau_device_del(dev);
 + free(nvdev);
   return -EINVAL;
   }
  
 @@ -105,6 +106,7 @@ nouveau_device_wrap(int fd, int close, struct 
 nouveau_device **pdev)
   ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, gart);
   if (ret) {
   nouveau_device_del(dev);
 + free(nvdev);
   return ret;
   }
  
 -- 

nouveau_device_del already does it.
NAK

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


Re: [Mesa-dev] [libdrm PATCH 3/4] nouveau/nouveau.c: Fix two memory leaks.

2012-06-28 Thread Johannes Obermayr
Am Donnerstag, 28. Juni 2012, 23:06:10 schrieb Marcin Slusarz:
 On Thu, Jun 28, 2012 at 09:51:57PM +0200, Johannes Obermayr wrote:
  ---
   nouveau/nouveau.c |2 ++
   1 files changed, 2 insertions(+), 0 deletions(-)
  
  diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
  index 5aa4107..e91287f 100644
  --- a/nouveau/nouveau.c
  +++ b/nouveau/nouveau.c
  @@ -95,6 +95,7 @@ nouveau_device_wrap(int fd, int close, struct 
  nouveau_device **pdev)
  (dev-drm_version   0x0100 ||
   dev-drm_version = 0x0200)) {
  nouveau_device_del(dev);
  +   free(nvdev);
  return -EINVAL;
  }
   
  @@ -105,6 +106,7 @@ nouveau_device_wrap(int fd, int close, struct 
  nouveau_device **pdev)
  ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, gart);
  if (ret) {
  nouveau_device_del(dev);
  +   free(nvdev);
  return ret;
  }
   
 
 nouveau_device_del already does it.
 NAK
 
 Marcin

nvdev != dev or I am wrong?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [libdrm PATCH 2/4] libkms/nouveau.c: Fix a memory leak and cleanup code a bit.

2012-06-28 Thread Marcin Slusarz
On Thu, Jun 28, 2012 at 09:51:56PM +0200, Johannes Obermayr wrote:
 ---
  libkms/nouveau.c |   20 +++-
  1 files changed, 11 insertions(+), 9 deletions(-)
 
 diff --git a/libkms/nouveau.c b/libkms/nouveau.c
 index 0e24a15..4cbca96 100644
 --- a/libkms/nouveau.c
 +++ b/libkms/nouveau.c
 @@ -94,14 +94,18 @@ nouveau_bo_create(struct kms_driver *kms,
   if (!bo)
   return -ENOMEM;
  
 - if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) {
 + switch (type) {
 + case KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8:
   pitch = 64 * 4;
   size = 64 * 64 * 4;
 - } else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) {
 + break;
 + case KMS_BO_TYPE_SCANOUT_X8R8G8B8:
   pitch = width * 4;
   pitch = (pitch + 512 - 1)  ~(512 - 1);
   size = pitch * height;
 - } else {
 + break;
 + default:
 + free(bo);
   return -EINVAL;
   }
  
 @@ -114,8 +118,10 @@ nouveau_bo_create(struct kms_driver *kms,
   arg.channel_hint = 0;
  
   ret = drmCommandWriteRead(kms-fd, DRM_NOUVEAU_GEM_NEW, arg, 
 sizeof(arg));
 - if (ret)
 - goto err_free;
 + if (ret) {
 + free(bo);
 + return ret;
 + }
  
   bo-base.kms = kms;
   bo-base.handle = arg.info.handle;
 @@ -126,10 +132,6 @@ nouveau_bo_create(struct kms_driver *kms,
   *out = bo-base;
  
   return 0;
 -
 -err_free:
 - free(bo);
 - return ret;
  }
  
  static int
 -- 

Looks good, but moving bo allocation after type check would be simplier
(-3+3 lines patch) and have the same effect.

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


Re: [Mesa-dev] [libdrm PATCH 1/4] libkms/intel.c: Fix a memory leak and a dead assignment as well as cleanup code a bit.

2012-06-28 Thread Marcin Slusarz
On Thu, Jun 28, 2012 at 09:51:55PM +0200, Johannes Obermayr wrote:
 ---
  libkms/intel.c |   23 ---
  1 files changed, 12 insertions(+), 11 deletions(-)
 
 diff --git a/libkms/intel.c b/libkms/intel.c
 index 8b8249b..7bf1f76 100644
 --- a/libkms/intel.c
 +++ b/libkms/intel.c
 @@ -93,14 +93,18 @@ intel_bo_create(struct kms_driver *kms,
   if (!bo)
   return -ENOMEM;
  
 - if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) {
 + switch (type) {
 + case KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8:
   pitch = 64 * 4;
   size = 64 * 64 * 4;
 - } else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) {
 + break;
 + case KMS_BO_TYPE_SCANOUT_X8R8G8B8:
   pitch = width * 4;
   pitch = (pitch + 512 - 1)  ~(512 - 1);
   size = pitch * ((height + 4 - 1)  ~(4 - 1));
 - } else {
 + break;
 + default:
 + free(bo);
   return -EINVAL;
   }
  
 @@ -108,8 +112,10 @@ intel_bo_create(struct kms_driver *kms,
   arg.size = size;
  
   ret = drmCommandWriteRead(kms-fd, DRM_I915_GEM_CREATE, arg, 
 sizeof(arg));
 - if (ret)
 - goto err_free;
 + if (ret) {
 + free(bo);
 + return ret;
 + }
  
   bo-base.kms = kms;
   bo-base.handle = arg.handle;

The same comment as in nouveau patch.

 @@ -124,9 +130,8 @@ intel_bo_create(struct kms_driver *kms,
   tile.handle = bo-base.handle;
   tile.tiling_mode = I915_TILING_X;
   tile.stride = bo-base.pitch;
 -
 - ret = drmCommandWriteRead(kms-fd, DRM_I915_GEM_SET_TILING, 
 tile, sizeof(tile));
  #if 0
 + ret = drmCommandWriteRead(kms-fd, DRM_I915_GEM_SET_TILING, 
 tile, sizeof(tile));
   if (ret) {
   kms_bo_destroy(out);
   return ret;

This is wrong. You want to ignore the return value, not remove whole ioctl call.
See commit 8838bb1d63bdb8ffa808cd41b7e0ffd2e62ff7bc.


 @@ -135,10 +140,6 @@ intel_bo_create(struct kms_driver *kms,
   }
  
   return 0;
 -
 -err_free:
 - free(bo);
 - return ret;
  }
  
  static int
 -- 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [libdrm PATCH 3/4] nouveau/nouveau.c: Fix two memory leaks.

2012-06-28 Thread Marcin Slusarz
On Thu, Jun 28, 2012 at 11:11:51PM +0200, Johannes Obermayr wrote:
 Am Donnerstag, 28. Juni 2012, 23:06:10 schrieb Marcin Slusarz:
  On Thu, Jun 28, 2012 at 09:51:57PM +0200, Johannes Obermayr wrote:
   ---
nouveau/nouveau.c |2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
   
   diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
   index 5aa4107..e91287f 100644
   --- a/nouveau/nouveau.c
   +++ b/nouveau/nouveau.c
   @@ -95,6 +95,7 @@ nouveau_device_wrap(int fd, int close, struct 
   nouveau_device **pdev)
 (dev-drm_version   0x0100 ||
  dev-drm_version = 0x0200)) {
 nouveau_device_del(dev);
   + free(nvdev);
 return -EINVAL;
 }

   @@ -105,6 +106,7 @@ nouveau_device_wrap(int fd, int close, struct 
   nouveau_device **pdev)
 ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, gart);
 if (ret) {
 nouveau_device_del(dev);
   + free(nvdev);
 return ret;
 }

  
  nouveau_device_del already does it.
  NAK
  
  Marcin
 
 nvdev != dev or I am wrong?

dev is a prefix of nvdev.
Just read the code...

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


Re: [Mesa-dev] [PATCH] msaa: Make meta-ops save and restore state of GL_MULTISAMPLE.

2012-06-28 Thread Chad Versace
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 06/27/2012 04:51 PM, Paul Berry wrote:
 The meta-ops _mesa_meta_Clear() and _mesa_meta_glsl_Clear() need to ignore
 the state of GL_SAMPLE_ALPHA_TO_COVERAGE, GL_SAMPLE_ALPHA_TO_ONE,
 GL_SAMPLE_COVERAGE, GL_SAMPLE_COVERAGE_VALUE, and GL_SAMPLE_COVERAGE_INVERT
 when clearing multisampled buffers.  The easiest way to accomplish this is
 to disable GL_MULTISAMPLE during the clear meta-ops.
 
 Note: this patch also causes GL_MULTISAMPLE to be disabled during 
 _mesa_meta_GenerateMipmap() and _mesa_meta_GetTexImage() (since those two
 meta-ops use MESA_META_ALL).  Arguably this isn't strictly necessary, since
 those meta-ops use their own non-MSAA fbo's, but it shouldn't do any harm.
 
 Fixes Piglit tests EXT_framebuffer_multisample/clear {2,4} 
 {color,stencil} on i965. --- src/mesa/drivers/common/meta.c |   17
 - src/mesa/drivers/common/meta.h |1 + 2 files changed,
 17 insertions(+), 1 deletions(-)


Looks good.
Reviewed-by: Chad Versace chad.vers...@linux.intel.com




-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJP7NQXAAoJEAIvNt057x8iaO0QAJZafXu2AB2XCOVK+IHbWnxu
GqSHPGfMR1aWeX0RWd/QroVlI5udPyGLe7loZhHrZfyWiuoBashyQuZoJJP78Sfv
saiKZE6lpAKIweWOQCEvwQCHSuOpjPVjDYPEZdEoZAzB975ZUTc2Y6AE322+9v6k
0UglD/2fI++pAjq/YHaIHf0N6oB4tfWajSYq8jzkwy5lxGvFuJ+JOFHmgts1x7fl
fU7KX8zvK+97Trrg2enzsL1+PgducXAPmLjmWtGqoLIe44t1TNeKR8NDnl0mS0hD
sdxAFduIrK3etpo2WbGFu3Esll/jY3jTvP21lGiRopGXE10H49/g24oPg2HtlDMI
vXh9Xoj5QGbWCcaecaPEQBq9L1xsKfpteLXf/R5O6sSC+tISFcIGVstglxWKffiz
WhDueOs5KqVLu4vOWVA5dyjsVmpsSoi0Y9+YGFXQVTc9Fx9g+tUNwTMvL/kS0r+l
2vPhvDIo1egQWg3LomuvNKm5zhfZlmPWZ5I7T5JldSjgGqyMrfR6qDx7yzl9Ti2v
Li+g5eTsHm27aiecFPJoHZs45frlLnZY54kvbHmm1L+7J6vwgFbD5mzvftlPMC0P
2gkcKfD4Hd7EYFmTmSoq9aJUjP28rvQj+6fFLeRdw3i9WyRm/JgJYFzB/0GwWcki
BgbNahxhiQb4vFK4vEtk
=7mtJ
-END PGP SIGNATURE-
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [libdrm PATCH 4/4] xf86drm.c: Make more code UDEV unrelevant and fix a memory leak.

2012-06-28 Thread Marcin Slusarz
On Thu, Jun 28, 2012 at 09:51:58PM +0200, Johannes Obermayr wrote:

These patches should be sent to dri-devel, not mesa-dev.

 ---
  xf86drm.c |   15 ++-
  1 files changed, 10 insertions(+), 5 deletions(-)
 
 diff --git a/xf86drm.c b/xf86drm.c
 index 6ea068f..798f1fd 100644
 --- a/xf86drm.c
 +++ b/xf86drm.c
 @@ -255,6 +255,7 @@ static int drmMatchBusID(const char *id1, const char 
 *id2, int pci_domain_ok)
  return 0;
  }
  
 +#if !defined(UDEV)
  /**
   * Handles error checking for chown call.
   *
 @@ -284,6 +285,7 @@ static int chown_check_return(const char *path, uid_t 
 owner, gid_t group)
   path, errno, strerror(errno));
   return -1;
  }
 +#endif
  
  /**
   * Open the DRM device, creating it if necessary.
 @@ -303,13 +305,15 @@ static int drmOpenDevice(long dev, int minor, int type)
  stat_t  st;
  charbuf[64];
  int fd;
 +
 +sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, 
 minor);
 +drmMsg(drmOpenDevice: node name is %s\n, buf);
 +
 +#if !defined(UDEV)
  mode_t  devmode = DRM_DEV_MODE, serv_mode;
  int isroot  = !geteuid();
  uid_t   user= DRM_DEV_UID;
  gid_t   group   = DRM_DEV_GID, serv_group;
 -
 -sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, 
 minor);
 -drmMsg(drmOpenDevice: node name is %s\n, buf);
  
  if (drm_server_info) {
   drm_server_info-get_perms(serv_group, serv_mode);
 @@ -318,7 +322,6 @@ static int drmOpenDevice(long dev, int minor, int type)
   group = (serv_group = 0) ? serv_group : DRM_DEV_GID;
  }
  
 -#if !defined(UDEV)
  if (stat(DRM_DIR_NAME, st)) {
   if (!isroot)
   return DRM_ERR_NOT_ROOT;

You should not mix code with declarations.
However, UDEV and non-UDEV codepaths share very little code. I'm wondering
whether it would be better to organize it like:

static int drmOpenDevice(long dev, int minor, int type)
{
#if defined(UDEV)
...
#else
...
#endif
}

 @@ -1395,8 +1398,10 @@ drm_context_t *drmGetReservedContextList(int fd, int 
 *count)
  }
  
  res.contexts = list;
 -if (drmIoctl(fd, DRM_IOCTL_RES_CTX, res))
 +if (drmIoctl(fd, DRM_IOCTL_RES_CTX, res)) {
 + drmFree(retval);
   return NULL;
 +}
  
  for (i = 0; i  res.count; i++)
   retval[i] = list[i].handle;
 -- 

This is not enough. list will leak too.

Make it a separate patch please.

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


Re: [Mesa-dev] [PATCH] clover: Handle NULL devs argument in clBuildProgram

2012-06-28 Thread Francisco Jerez
Tom Stellard tstel...@gmail.com writes:

 If devs is NULL, then the kernel should be compiled for all devices
 associated with the program's context.
 ---
  src/gallium/state_trackers/clover/api/program.cpp |   16 ++--
  1 files changed, 10 insertions(+), 6 deletions(-)

 diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
 b/src/gallium/state_trackers/clover/api/program.cpp
 index e874c51..e863e00 100644
 --- a/src/gallium/state_trackers/clover/api/program.cpp
 +++ b/src/gallium/state_trackers/clover/api/program.cpp
 @@ -142,12 +142,16 @@ clBuildProgram(cl_program prog, cl_uint count, const 
 cl_device_id *devs,
 (!pfn_notify  user_data))
throw error(CL_INVALID_VALUE);
  
 -   if (any_of([](const cl_device_id dev) {
 -return !prog-ctx.has_device(dev);
 - }, devs, devs + count))
 -  throw error(CL_INVALID_DEVICE);
 -
 -   prog-build({ devs, devs + count });
 +   if (devs) {
 +  if (any_of([](const cl_device_id dev) {
 +   return !prog-ctx.has_device(dev);
 +}, devs, devs + count))
 + throw error(CL_INVALID_DEVICE);
 +
 +  prog-build({ devs, devs + count });
 +   } else {
 +  prog-build({ prog-ctx.devs.begin(), prog-ctx.devs.end() });

How about 'prog-build(prog-ctx.devs);'?

The spec doesn't seem very clear on what should happen in that case, but
isn't this wrong for programs created with 'clCreateProgramWithBinary'
that are associated with a specific subset of devices from the program
context?

 +   }
 return CL_SUCCESS;
  
  } catch (error e) {


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


[Mesa-dev] [PATCH] i965: fix transform feedback with primitive restart

2012-06-28 Thread Jordan Justen
When querying GL_PRIMITIVES_GENERATED, if primitive restart
is also used, then take the software primitive restart
path so GL_PRIMITIVES_GENERATED is returned correctly.

GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN is also updated
since it will also affected by the same issue.

As noted in brw_primitive_restart.c, with further work we
should be able to move this situation back to a hardware
handled path.

Signed-off-by: Jordan Justen jordan.l.jus...@intel.com
---
 src/mesa/drivers/dri/i965/brw_context.h   |2 ++
 src/mesa/drivers/dri/i965/brw_primitive_restart.c |   12 
 src/mesa/drivers/dri/i965/brw_queryobj.c  |4 
 3 files changed, 18 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 2c9f5ad..ee860f3 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1037,7 +1037,9 @@ struct brw_context
   uint32_t svbi_0_max_index;
   uint32_t offset_0_batch_start;
   uint32_t primitives_generated;
+  bool counting_primitives_generated;
   uint32_t primitives_written;
+  bool counting_primitives_written;
} sol;
 
uint32_t render_target_format[MESA_FORMAT_COUNT];
diff --git a/src/mesa/drivers/dri/i965/brw_primitive_restart.c 
b/src/mesa/drivers/dri/i965/brw_primitive_restart.c
index 962ff18..02deba4 100644
--- a/src/mesa/drivers/dri/i965/brw_primitive_restart.c
+++ b/src/mesa/drivers/dri/i965/brw_primitive_restart.c
@@ -69,6 +69,18 @@ can_cut_index_handle_prims(struct gl_context *ctx,
GLuint nr_prims,
const struct _mesa_index_buffer *ib)
 {
+   struct brw_context *brw = brw_context(ctx);
+
+   if (brw-sol.counting_primitives_generated ||
+   brw-sol.counting_primitives_written) {
+  /* Counting primitives generated in hardware is not currently
+   * supported, so take the software path. We need to investigate
+   * the *_PRIMITIVES_COUNT registers to allow this to be handled
+   * entirely in hardware.
+   */
+  return false;
+   }
+
if (!can_cut_index_handle_restart_index(ctx, ib)) {
   /* The primitive restart index can't be handled, so take
* the software path
diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c 
b/src/mesa/drivers/dri/i965/brw_queryobj.c
index 72b83f4..240fe32 100644
--- a/src/mesa/drivers/dri/i965/brw_queryobj.c
+++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
@@ -171,6 +171,7 @@ brw_begin_query(struct gl_context *ctx, struct 
gl_query_object *q)
* it a software counter.  So just reset the counter.
*/
   brw-sol.primitives_generated = 0;
+  brw-sol.counting_primitives_generated = true;
   break;
 
case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
@@ -178,6 +179,7 @@ brw_begin_query(struct gl_context *ctx, struct 
gl_query_object *q)
* it a software counter.  So just reset the counter.
*/
   brw-sol.primitives_written = 0;
+  brw-sol.counting_primitives_written = true;
   break;
 
default:
@@ -249,6 +251,7 @@ brw_end_query(struct gl_context *ctx, struct 
gl_query_object *q)
* the query object.
*/
   query-Base.Result = brw-sol.primitives_generated;
+  brw-sol.counting_primitives_generated = false;
 
   /* And set brw-query.obj to NULL so that this query won't try to wait
* for any rendering to complete.
@@ -262,6 +265,7 @@ brw_end_query(struct gl_context *ctx, struct 
gl_query_object *q)
* the query object.
*/
   query-Base.Result = brw-sol.primitives_written;
+  brw-sol.counting_primitives_written = false;
 
   /* And set brw-query.obj to NULL so that this query won't try to wait
* for any rendering to complete.
-- 
1.7.9.5

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