Re: [Mesa-dev] [PATCH] draw: always call and move util_cpu_detect() to draw context creation.

2013-07-24 Thread Vinson Lee
On Tue, Jul 23, 2013 at 2:52 PM,  srol...@vmware.com wrote:
 From: Roland Scheidegger srol...@vmware.com

 CPU detection is not really x86 specific, the ifdef in particular didn't
 even catch x86_64.
 Also move to draw context creation which seems a lot cleaner, and just
 call it always (which seems like a better idea than rely on drivers doing this
 especially if drivers otherwise don't need it).
 This fixes https://bugs.freedesktop.org/show_bug.cgi?id=66806.
 (Because util_cpu_caps wasn't initialized when first calling 
 util_fpstate_get()
 hence it returning zero, but it would later get initialized by rtasm translate
 code hence when draw call returned it unmasked all exceptions by calling
 util_fpstate_set(). This was happening only with DRAW_USE_LLVM=0 or not
 compiling with llvm, otherwise the llvm init code was calling it on time too.)
 ---
  src/gallium/auxiliary/draw/draw_context.c |5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

 diff --git a/src/gallium/auxiliary/draw/draw_context.c 
 b/src/gallium/auxiliary/draw/draw_context.c
 index 4a08765..26af984 100644
 --- a/src/gallium/auxiliary/draw/draw_context.c
 +++ b/src/gallium/auxiliary/draw/draw_context.c
 @@ -57,8 +57,7 @@ draw_get_option_use_llvm(void)
value = debug_get_bool_option(DRAW_USE_LLVM, TRUE);

  #ifdef PIPE_ARCH_X86
 -  util_cpu_detect();
 -  /* require SSE2 due to LLVM PR6960. */
 +  /* require SSE2 due to LLVM PR6960. XXX Might be fixed by now? */
if (!util_cpu_caps.has_sse2)
   value = FALSE;
  #endif
 @@ -78,6 +77,8 @@ draw_create_context(struct pipe_context *pipe, boolean 
 try_llvm)
 if (draw == NULL)
goto err_out;

 +   util_cpu_detect();
 +
  #if HAVE_LLVM
 if (try_llvm  draw_get_option_use_llvm()) {
draw-llvm = draw_llvm_create(draw);
 --
 1.7.9.5

With this patch, glxgears runs again for me with softpipe.

Tested-by: Vinson Lee v...@freedesktop.org
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] clover: Added missing address space checking of kernel parameters

2013-07-24 Thread Francisco Jerez
Tom Stellard t...@stellard.net writes:

 On Mon, Jul 22, 2013 at 09:24:12AM -0400, Jonathan Charest wrote:
 To have non-static buffers in local memory, it is necessary to pass them
 as arguments to the kernel. This was almost supported but the address
 space mapping was missing to perform the check (thanks to tstellar for
 pointing me in the right direction).
 
 ---
  .../state_trackers/clover/llvm/invocation.cpp  | 31
 ++

 Reviewed-by: Tom Stellard thomas.stell...@amd.com

Looks OK to me, but the patch doesn't apply because of the line
wrapping.  Also make sure you place block braces consistently and
respect the 80-column limit as far as possible.

  1 file changed, 20 insertions(+), 11 deletions(-)
 
 diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp
 b/src/gallium/state_trackers/clover/llvm/invocation.cpp
 index dae61f7..5cb5724 100644
 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
 +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
 @@ -26,6 +26,7 @@
  #include clang/Frontend/TextDiagnosticBuffer.h
  #include clang/Frontend/TextDiagnosticPrinter.h
  #include clang/CodeGen/CodeGenAction.h
 +#include clang/Basic/TargetInfo.h
  #include llvm/Bitcode/BitstreamWriter.h
  #include llvm/Bitcode/ReaderWriter.h
  #include llvm/Linker.h
 @@ -113,7 +114,7 @@ namespace {
 llvm::Module *
 compile(const std::string source, const std::string name,
 const std::string triple, const std::string processor,
 -   const std::string opts) {
 +   const std::string opts, clang::LangAS::Map address_spaces) {
 
clang::CompilerInstance c;
clang::CompilerInvocation invocation;
 @@ -204,6 +205,9 @@ namespace {
if (!c.ExecuteAction(act))
   throw build_error(log);
 
 +  // Get address spaces map to be able to find kernel argument
 address spaces
 +  memcpy(address_spaces, c.getTarget().getAddressSpaceMap(),
 sizeof(address_spaces));
 +
return act.takeModule();
 }
 
 @@ -282,7 +286,8 @@ namespace {
 
 module
 build_module_llvm(llvm::Module *mod,
 - const std::vectorllvm::Function * kernels) {
 + const std::vectorllvm::Function * kernels,
 + clang::LangAS::Map address_spaces) {
 
module m;
struct pipe_llvm_program_header header;
 @@ -318,14 +323,17 @@ namespace {
  }
 
  if (arg_type-isPointerTy()) {
 -   // XXX: Figure out LLVM-OpenCL address space mappings
 for each
 -   // target.  I think we need to ask clang what these are.
  For now,
 -   // pretend everything is in the global address space.
 unsigned address_space =
 llvm::castllvm::PointerType(arg_type)-getAddressSpace();
 -   switch (address_space) {
 -  default:
 -
 args.push_back(module::argument(module::argument::global, arg_size));
 - break;
 +   if (address_space ==
 +   address_spaces[clang::LangAS::opencl_local -
 clang::LangAS::Offset]) {
 +
 args.push_back(module::argument(module::argument::local, arg_size));
 +   }
 +   else if (address_space ==
 +address_spaces[clang::LangAS::opencl_constant -
 clang::LangAS::Offset]) {
 +
 args.push_back(module::argument(module::argument::constant, arg_size));
 +   }
 +   else {
 +
 args.push_back(module::argument(module::argument::global, arg_size));
 }
  } else {
 
 args.push_back(module::argument(module::argument::scalar, arg_size));
 @@ -358,10 +366,11 @@ clover::compile_program_llvm(const compat::string
 source,
 std::string processor(target.begin(), 0, processor_str_len);
 std::string triple(target.begin(), processor_str_len + 1,
target.size() - processor_str_len - 1);
 +   clang::LangAS::Map address_spaces;
 
 // The input file name must have the .cl extension in order for the
 // CompilerInvocation class to recognize it as an OpenCL source file.
 -   llvm::Module *mod = compile(source, input.cl, triple, processor,
 opts);
 +   llvm::Module *mod = compile(source, input.cl, triple, processor,
 opts, address_spaces);
 
 find_kernels(mod, kernels);
 
 @@ -374,6 +383,6 @@ clover::compile_program_llvm(const compat::string
 source,
   assert(0);
   return module();
default:
 - return build_module_llvm(mod, kernels);
 + return build_module_llvm(mod, kernels, address_spaces);
 }
  }
 -- 1.8.3.2
 
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev


pgph8HDL3NlD0.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] gallium/util: Fix detection of AVX cpu caps

2013-07-24 Thread Andre Heider
On Wed, Jul 24, 2013 at 12:11 AM, Jose Fonseca jfons...@vmware.com wrote:


 - Original Message -
 On Tue, Jul 23, 2013 at 8:57 PM, Roland Scheidegger srol...@vmware.com
 wrote:
  Am 23.07.2013 19:08, schrieb Andre Heider:
  For AVX it's not sufficient to only rely on the cpuid flags. If the CPU
  supports these extensions, but the OS doesn't, issuing these insns will
  trigger an undefined opcode exception.
 
  In addition to the AVX cpuid bit we also need to:
  * test cpuid for OSXSAVE support
  * XGETBV to check if the OS saves/restores AVX regs on context switches
 
  See Detecting Availability and Support at
  http://software.intel.com/en-us/articles/introduction-to-intel-advanced-vector-extensions
 
  Signed-off-by: Andre Heider a.hei...@gmail.com
  ---
   src/gallium/auxiliary/util/u_cpu_detect.c | 27
   +--
   1 file changed, 25 insertions(+), 2 deletions(-)
 
  diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c
  b/src/gallium/auxiliary/util/u_cpu_detect.c
  index b118fc8..588fc7c 100644
  --- a/src/gallium/auxiliary/util/u_cpu_detect.c
  +++ b/src/gallium/auxiliary/util/u_cpu_detect.c
  @@ -67,7 +67,7 @@
 
   #if defined(PIPE_OS_WINDOWS)
   #include windows.h
  -#if defined(MSVC)
  +#if defined(PIPE_CC_MSVC)
   #include intrin.h
   #endif
   #endif
  @@ -211,6 +211,27 @@ cpuid(uint32_t ax, uint32_t *p)
  p[3] = 0;
   #endif
   }
  +
  +static INLINE uint64_t xgetbv(void)
  +{
  +#if defined(PIPE_CC_GCC)
  +   uint32_t eax, edx;
  +
  +   __asm __volatile (
  + .byte 0x0f, 0x01, 0xd0 // xgetbv isn't supported on gcc  4.4
  + : =a(eax),
  +   =d(edx)
  + : c(0)
  +   );
  +
  +   return ((uint64_t)edx  32) | eax;
  +#elif defined(PIPE_CC_MSVC)  defined(_MSC_FULL_VER) 
  defined(_XCR_XFEATURE_ENABLED_MASK)
  +   return _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
  +#else
  +   return 0;
  +#endif
  +
  +}
   #endif /* X86 or X86_64 */
 
   void
  @@ -284,7 +305,9 @@ util_cpu_detect(void)
util_cpu_caps.has_sse4_1 = (regs2[2]  19)  1;
util_cpu_caps.has_sse4_2 = (regs2[2]  20)  1;
util_cpu_caps.has_popcnt = (regs2[2]  23)  1;
  - util_cpu_caps.has_avx= (regs2[2]  28)  1;
  + util_cpu_caps.has_avx= ((regs2[2]  28)  1)  // AVX
  +((regs2[2]  27)  1)  // OSXSAVE
  +((xgetbv()  6) == 6);// XMM 
  YMM
util_cpu_caps.has_f16c   = (regs2[2]  29)  1;
util_cpu_caps.has_mmx2   = util_cpu_caps.has_sse; /* SSE cpus
supports mmxext too */
 
 
 
  Looks good to me though

 Looks good to me too. Thanks.

  it's a pity detection depends on compiler.
  Granted it looks like icc currently won't work but still...
  I guess that technically the test for sse(x) isn't correct neither as
  that too requires OS support, I don't know off-hand though how to check
  for it (and we'd be talking ANCIENT os here...).

 Ancient indeed ;)

 But with AVX the problem becomes more urgent: All SSE versions used
 the same registers, AVX extended those.
 Now we recently got a AVX enabled vSphere server, and exposing that to
 XP guests doesn't go too well with llvmpipe without this patch.

 I don't know of many llvmpipe windows users, specially XP.   If it's not 
 confidential, how are you using it?

I think the situation can be compared to GNOME Shell/Chrome/Qt5: Its
used for remote sessions and serves as a fallback in case the native
GL driver sucks too much.
According to our render guy: While there's a MS software renderer, it
only implements GL 1.1. No multi texturing, npot restrictions,
additional code paths, testing those paths...  llvmpipe makes life
easier there.

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


[Mesa-dev] [Bug 67120] Dota 2 crashes sporadically on Intel/Mesa git (full backtrace with mesa symbols included)

2013-07-24 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=67120

Vedran Rodic vro...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |NOTOURBUG

--- Comment #11 from Vedran Rodic vro...@gmail.com ---
Updated Dota 2 Test client seems to fix the issue. It seems it's not related to
Mesa. Sorry for the spam.

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


[Mesa-dev] [v8] EXT_image_dma_buf_import for intel

2013-07-24 Thread Topi Pohjolainen
The set introduces new target for 'eglCreateImageKHR()' allowing one
to create EGL images out of externally allocated buffers. For now
only natively supported RGB formatted buffers are accepted.

This revision ties the dma-buffer import extension tightly with the
image external extension. One can access the dma-buffers only for
reading and via the image external sampler. Image external extension
itseff is not previously supported and here it is enabled solely for
imported dma-buffers and for nothing else.

I left the generic plumbing for YUV specific attributes in place as
people spent quite a bit of time reviewing it and it is likely to be
useful later on.

v2:
   - added support for treating buffers having packed format
 separately from the planar (that require special care)
   intel: allow packed prime buffers to be treated normally

   - tried to address all Eric's comments:  
   intel: refactor planar format lookup
   intel: prepare for dri images having more than plane

   - added missing check for explicit no context
   egl: definitions for EXT_image_dma_buf_import

v3-4:
   - close the file descriptors as the ownership is transferred
 to EGL
   - declare the extension as EGL (not GLES)
   - import EGL definitions from khronos
   - no not break DRI image ABI, but introduce new entry and update
 the version of the interface

v5-6:
   - clarified the use of regions-array (Chad)
   - omit duplication of image with no regions (Chad)
   - distinguish invalid drm format from unsupported (Chad)
   - fix the rejection of all hints (Chad)
   - report invalid context as EGL_BAD_PARAMETER instead of as
 EGL_BAD_CONTEXT (Eric)

v7:
   - native RGB formats only and only via image external sampler

v8:
   - fixed return EGL errors codes, documentation and plane
 attribute checking

Topi Pohjolainen (9):
  intel: allow packed prime buffers to be treated normally
  intel: do not create renderbuffers out of planar images
  intel: refactor planar format lookup
  intel: set dri image dimensions even when creating out of primes
  dri: propagate extra dma_buf import attributes to the drivers
  egl: definitions for EXT_image_dma_buf_import
  intel: restrict dma-buf-import images to external sampling only
  egl/dri2: support for creating images out of dma buffers
  i965: enable image external sampling for imported dma-buffers

 include/GL/internal/dri_interface.h  |  39 +++-
 src/egl/drivers/dri2/egl_dri2.c  | 262 +++
 src/egl/main/eglapi.c|   5 +
 src/egl/main/egldisplay.h|   1 +
 src/egl/main/eglimage.c  |  76 
 src/egl/main/eglimage.h  |  15 ++
 src/egl/main/eglmisc.c   |   1 +
 src/mesa/drivers/dri/i965/intel_extensions.c |   1 +
 src/mesa/drivers/dri/i965/intel_fbo.c|  14 ++
 src/mesa/drivers/dri/i965/intel_regions.h|  14 ++
 src/mesa/drivers/dri/i965/intel_screen.c |  88 +++--
 src/mesa/drivers/dri/i965/intel_tex_image.c  |  18 ++
 12 files changed, 517 insertions(+), 17 deletions(-)

-- 
1.8.1.2

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


[Mesa-dev] [v8 4/9] intel: set dri image dimensions even when creating out of primes

2013-07-24 Thread Topi Pohjolainen
Otherwise 'intel_set_texture_image_region()' won't have enough
details to work with.

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
Reviewed-by: Chad Versace chad.vers...@linux.intel.com
---
 src/mesa/drivers/dri/i965/intel_screen.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 0738cf6..3a3efc0 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -679,6 +679,8 @@ intel_create_image_from_fds(__DRIscreen *screen,
   image-strides[index] = strides[index];
}
 
+   intel_setup_image_from_dimensions(image);
+
return image;
 }
 
-- 
1.8.1.2

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


[Mesa-dev] [v8 5/9] dri: propagate extra dma_buf import attributes to the drivers

2013-07-24 Thread Topi Pohjolainen
v2: do not break ABI, but instead introduce new entry point for
dma buffers and bump up the dri-interface version to eight

v3 (Chad): allow the hook to specify an error originating from the
   driver. For now only unsupported format is considered.
   I thought about rejecting the hints also as they are
   addressing only YUV sampling which is not supported at
   the moment but then thought against it as the spec is
   not saying one way or the other.

v4 (Eric, Chad): restrict to rgb formatted only

v5: rebased on top of i915/i965 split

v6 (Chad): document using full extension name

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
Reviewed-by: Chad Versace chad.vers...@linux.intel.com
---
 include/GL/internal/dri_interface.h   | 39 -
 src/mesa/drivers/dri/i965/intel_regions.h |  7 +
 src/mesa/drivers/dri/i965/intel_screen.c  | 48 +--
 3 files changed, 91 insertions(+), 3 deletions(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 5c99d55..be31bb8 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -940,7 +940,7 @@ struct __DRIdri2ExtensionRec {
  * extensions.
  */
 #define __DRI_IMAGE DRI_IMAGE
-#define __DRI_IMAGE_VERSION 7
+#define __DRI_IMAGE_VERSION 8
 
 /**
  * These formats correspond to the similarly named MESA_FORMAT_*
@@ -1027,6 +1027,25 @@ struct __DRIdri2ExtensionRec {
 * 7+. Each query will return a
 * new fd. */
 
+enum __DRIYUVColorSpace {
+   __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
+   __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
+   __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
+   __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
+};
+
+enum __DRISampleRange {
+   __DRI_YUV_RANGE_UNDEFINED = 0,
+   __DRI_YUV_FULL_RANGE = 0x3282,
+   __DRI_YUV_NARROW_RANGE = 0x3283
+};
+
+enum __DRIChromaSiting {
+   __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
+   __DRI_YUV_CHROMA_SITING_0 = 0x3284,
+   __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
+};
+
 /**
  * \name Reasons that __DRIimageExtensionRec::createImageFromTexture might fail
  */
@@ -1132,6 +1151,24 @@ struct __DRIimageExtensionRec {
  int *fds, int num_fds,
  int *strides, int *offsets,
  void *loaderPrivate);
+
+   /**
+* Like createImageFromFds, but takes additional attributes.
+*
+* For EGL_EXT_image_dma_buf_import.
+*
+* \since 8
+*/
+   __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
+ int width, int height, int fourcc,
+ int *fds, int num_fds,
+ int *strides, int *offsets,
+ enum __DRIYUVColorSpace color_space,
+ enum __DRISampleRange sample_range,
+ enum __DRIChromaSiting horiz_siting,
+ enum __DRIChromaSiting vert_siting,
+ unsigned *error,
+ void *loaderPrivate);
 };
 
 
diff --git a/src/mesa/drivers/dri/i965/intel_regions.h 
b/src/mesa/drivers/dri/i965/intel_regions.h
index 428f4dc..ebb5488 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.h
+++ b/src/mesa/drivers/dri/i965/intel_regions.h
@@ -40,6 +40,7 @@
 
 #include main/mtypes.h
 #include intel_bufmgr.h
+#include GL/internal/dri_interface.h
 
 #ifdef __cplusplus
 extern C {
@@ -149,6 +150,12 @@ struct __DRIimageRec {
GLuint tile_y;
bool has_depthstencil;
 
+   /* Provided by EGL_EXT_image_dma_buf_import */
+   enum __DRIYUVColorSpace yuv_color_space;
+   enum __DRISampleRange sample_range;
+   enum __DRIChromaSiting horizontal_siting;
+   enum __DRIChromaSiting vertical_siting;
+
void *data;
 };
 
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 3a3efc0..12a96c0 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -684,6 +684,49 @@ intel_create_image_from_fds(__DRIscreen *screen,
return image;
 }
 
+static __DRIimage *
+intel_create_image_from_dma_bufs(__DRIscreen *screen,
+ int width, int height, int fourcc,
+ int *fds, int num_fds,
+ int *strides, int *offsets,
+ enum __DRIYUVColorSpace yuv_color_space,
+ enum __DRISampleRange sample_range,
+ enum __DRIChromaSiting horizontal_siting,
+ enum __DRIChromaSiting vertical_siting,
+ unsigned 

[Mesa-dev] [v8 7/9] intel: restrict dma-buf-import images to external sampling only

2013-07-24 Thread Topi Pohjolainen
Memory originating outside mesa stack is meant to be for reading
only. In addition, the restrictions imposed by the image external
extension should apply. For example, users shouldn't be allowed
to generare mip-trees based on these images.

v2 (Chad): document using full extension names, fix the comment
   style itself and emit description of error

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
---
 src/mesa/drivers/dri/i965/intel_fbo.c   |  7 +++
 src/mesa/drivers/dri/i965/intel_regions.h   |  9 -
 src/mesa/drivers/dri/i965/intel_screen.c|  1 +
 src/mesa/drivers/dri/i965/intel_tex_image.c | 11 +++
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c 
b/src/mesa/drivers/dri/i965/intel_fbo.c
index 059b3ea..4540904 100644
--- a/src/mesa/drivers/dri/i965/intel_fbo.c
+++ b/src/mesa/drivers/dri/i965/intel_fbo.c
@@ -268,6 +268,13 @@ intel_image_target_renderbuffer_storage(struct gl_context 
*ctx,
   return;
}
 
+   /* Buffers originating from outside are for read-only. */
+   if (image-dma_buf_imported) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+glEGLImageTargetRenderbufferStorage(dma buffers are read-only));
+  return;
+   }
+
/* __DRIimage is opaque to the core so it has to be checked here */
switch (image-format) {
case MESA_FORMAT_RGBA_REV:
diff --git a/src/mesa/drivers/dri/i965/intel_regions.h 
b/src/mesa/drivers/dri/i965/intel_regions.h
index ebb5488..f08a113 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.h
+++ b/src/mesa/drivers/dri/i965/intel_regions.h
@@ -150,7 +150,14 @@ struct __DRIimageRec {
GLuint tile_y;
bool has_depthstencil;
 
-   /* Provided by EGL_EXT_image_dma_buf_import */
+   /**
+* Provided by EGL_EXT_image_dma_buf_import.
+* 
+* The flag is set in order to restrict the use of the image later on.
+*
+* See intel_image_target_texture_2d()
+*/
+   bool dma_buf_imported;
enum __DRIYUVColorSpace yuv_color_space;
enum __DRISampleRange sample_range;
enum __DRIChromaSiting horizontal_siting;
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 12a96c0..4ee8602 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -719,6 +719,7 @@ intel_create_image_from_dma_bufs(__DRIscreen *screen,
   return NULL;
}
 
+   image-dma_buf_imported = true;
image-yuv_color_space = yuv_color_space;
image-sample_range = sample_range;
image-horizontal_siting = horizontal_siting;
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c 
b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 9c5d234..7d478d1 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -367,6 +367,17 @@ intel_image_target_texture_2d(struct gl_context *ctx, 
GLenum target,
if (image == NULL)
   return;
 
+   /**
+* Images originating via EGL_EXT_image_dma_buf_import can be used only
+* with GL_OES_EGL_image_external only.
+*/
+   if (image-dma_buf_imported  target != GL_TEXTURE_EXTERNAL_OES) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+glEGLImageTargetTexture2DOES(dma buffers can be used with 
+   GL_OES_EGL_image_external only);
+  return;
+   }
+
/* Disallow depth/stencil textures: we don't have a way to pass the
 * separate stencil miptree of a GL_DEPTH_STENCIL texture through.
 */
-- 
1.8.1.2

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


[Mesa-dev] [v8 6/9] egl: definitions for EXT_image_dma_buf_import

2013-07-24 Thread Topi Pohjolainen
As specified in:

http://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt

Checking for the valid fourcc values is left for drivers avoiding
dependency to drm header files here.

v2: enforce EGL_NO_CONTEXT

v3: declare the extension as EGL (not GLES)

v4: do not update eglext.h manually but rely on update from
Khronos instead

v5: (Eric) report invalid context as EGL_BAD_PARAMETER instead of as
EGL_BAD_CONTEXT

v6: (Chad) fix the checking for valid hints. Before all values were
rejected.

v7: (Chad) comment style change from

/**
 * Multi-
 * line

into

/* Multi-
 * line

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
Reviewed-by: Chad Versace chad.vers...@linux.intel.com
---
 src/egl/main/eglapi.c |  5 
 src/egl/main/egldisplay.h |  1 +
 src/egl/main/eglimage.c   | 76 +++
 src/egl/main/eglimage.h   | 15 ++
 src/egl/main/eglmisc.c|  1 +
 5 files changed, 98 insertions(+)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 4a9831b..96c9e06 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -1344,6 +1344,11 @@ eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, 
EGLenum target,
   RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR);
if (!context  ctx != EGL_NO_CONTEXT)
   RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
+   /* If target is EGL_LINUX_DMA_BUF_EXT, dpy must be a valid display,
+*  ctx must be EGL_NO_CONTEXT...
+*/
+   if (ctx != EGL_NO_CONTEXT  target == EGL_LINUX_DMA_BUF_EXT)
+  RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR);
 
img = drv-API.CreateImageKHR(drv,
  disp, context, target, buffer, attr_list);
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index f990300..fefd19c 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -116,6 +116,7 @@ struct _egl_extensions
EGLBoolean EXT_create_context_robustness;
EGLBoolean EXT_buffer_age;
EGLBoolean EXT_swap_buffers_with_damage;
+   EGLBoolean EXT_image_dma_buf_import;
 };
 
 
diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c
index bfae709..818b597 100644
--- a/src/egl/main/eglimage.c
+++ b/src/egl/main/eglimage.c
@@ -93,6 +93,82 @@ _eglParseImageAttribList(_EGLImageAttribs *attrs, 
_EGLDisplay *dpy,
  attrs-PlaneWL = val;
  break;
 
+  case EGL_LINUX_DRM_FOURCC_EXT:
+ attrs-DMABufFourCC.Value = val;
+ attrs-DMABufFourCC.IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE0_FD_EXT:
+ attrs-DMABufPlaneFds[0].Value = val;
+ attrs-DMABufPlaneFds[0].IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE0_OFFSET_EXT:
+ attrs-DMABufPlaneOffsets[0].Value = val;
+ attrs-DMABufPlaneOffsets[0].IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE0_PITCH_EXT:
+ attrs-DMABufPlanePitches[0].Value = val;
+ attrs-DMABufPlanePitches[0].IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE1_FD_EXT:
+ attrs-DMABufPlaneFds[1].Value = val;
+ attrs-DMABufPlaneFds[1].IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE1_OFFSET_EXT:
+ attrs-DMABufPlaneOffsets[1].Value = val;
+ attrs-DMABufPlaneOffsets[1].IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE1_PITCH_EXT:
+ attrs-DMABufPlanePitches[1].Value = val;
+ attrs-DMABufPlanePitches[1].IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE2_FD_EXT:
+ attrs-DMABufPlaneFds[2].Value = val;
+ attrs-DMABufPlaneFds[2].IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE2_OFFSET_EXT:
+ attrs-DMABufPlaneOffsets[2].Value = val;
+ attrs-DMABufPlaneOffsets[2].IsPresent = EGL_TRUE;
+ break;
+  case EGL_DMA_BUF_PLANE2_PITCH_EXT:
+ attrs-DMABufPlanePitches[2].Value = val;
+ attrs-DMABufPlanePitches[2].IsPresent = EGL_TRUE;
+ break;
+  case EGL_YUV_COLOR_SPACE_HINT_EXT:
+ if (val != EGL_ITU_REC601_EXT  val != EGL_ITU_REC709_EXT 
+ val != EGL_ITU_REC2020_EXT) {
+err = EGL_BAD_ATTRIBUTE;
+ } else {
+attrs-DMABufYuvColorSpaceHint.Value = val;
+attrs-DMABufYuvColorSpaceHint.IsPresent = EGL_TRUE;
+ }
+ break;
+  case EGL_SAMPLE_RANGE_HINT_EXT:
+ if (val != EGL_YUV_FULL_RANGE_EXT  val != EGL_YUV_NARROW_RANGE_EXT) 
{
+err = EGL_BAD_ATTRIBUTE;
+ } else {
+attrs-DMABufSampleRangeHint.Value = val;
+attrs-DMABufSampleRangeHint.IsPresent = EGL_TRUE;
+ }
+ break;
+  case EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT:
+ if (val != EGL_YUV_CHROMA_SITING_0_EXT 
+ val != EGL_YUV_CHROMA_SITING_0_5_EXT) {
+err = EGL_BAD_ATTRIBUTE;
+ } else {
+

[Mesa-dev] [v8 8/9] egl/dri2: support for creating images out of dma buffers

2013-07-24 Thread Topi Pohjolainen
v2:
   - upon success close the given file descriptors

v3:
   - use specific entry for dma buffers instead of the basic for
 primes, and enable the extension based on the availability
 of the hook

v4 (Chad):
   - use ARRAY_SIZE
   - improve the comment about the number of file descriptors
   - in case of invalid format report EGL_BAD_ATTRIBUTE instead
 of EGL_BAD_MATCH
   - take into account specific error set by the driver.

v5:
   - fix error handling

v6 (Chad):
   - fix invalid plane count checking

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
---
 src/egl/drivers/dri2/egl_dri2.c | 262 
 1 file changed, 262 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 52fcb3f..dbe1e98 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -34,6 +34,7 @@
 #include errno.h
 #include unistd.h
 #include xf86drm.h
+#include drm_fourcc.h
 #include GL/gl.h
 #include GL/internal/dri_interface.h
 #include sys/types.h
@@ -507,6 +508,10 @@ dri2_setup_screen(_EGLDisplay *disp)
  disp-Extensions.KHR_gl_texture_2D_image = EGL_TRUE;
  disp-Extensions.KHR_gl_texture_cubemap_image = EGL_TRUE;
   }
+  if (dri2_dpy-image-base.version = 8 
+  dri2_dpy-image-createImageFromDmaBufs) {
+ disp-Extensions.EXT_image_dma_buf_import = EGL_TRUE;
+  }
}
 }
 
@@ -1340,6 +1345,261 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, 
_EGLContext *ctx,
return dri2_img-base;
 }
 
+static EGLBoolean
+dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
+{
+   unsigned i;
+
+   /**
+ * The spec says:
+ *
+ * Required attributes and their values are as follows:
+ *
+ *  * EGL_WIDTH  EGL_HEIGHT: The logical dimensions of the buffer in 
pixels
+ *
+ *  * EGL_LINUX_DRM_FOURCC_EXT: The pixel format of the buffer, as 
specified
+ *by drm_fourcc.h and used as the pixel_format parameter of the
+ *drm_mode_fb_cmd2 ioctl.
+ *
+ * and
+ *
+ * * If target is EGL_LINUX_DMA_BUF_EXT, and the list of attributes is
+ *incomplete, EGL_BAD_PARAMETER is generated.
+ */
+   if (attrs-Width = 0 || attrs-Height = 0 ||
+  !attrs-DMABufFourCC.IsPresent) {
+  _eglError(EGL_BAD_PARAMETER, attribute(s) missing);
+  return EGL_FALSE;
+   }
+
+   /**
+* Also:
+*
+* If target is EGL_LINUX_DMA_BUF_EXT and one or more of the values
+*  specified for a plane's pitch or offset isn't supported by EGL,
+*  EGL_BAD_ACCESS is generated.
+*/
+   for (i = 0; i  ARRAY_SIZE(attrs-DMABufPlanePitches); ++i) {
+  if (attrs-DMABufPlanePitches[i].IsPresent 
+ attrs-DMABufPlanePitches[i].Value = 0) {
+ _eglError(EGL_BAD_ACCESS, invalid pitch);
+ return EGL_FALSE;
+  }
+   }
+
+   return EGL_TRUE;
+}
+
+/* Returns the total number of file descriptors. Zero indicates an error. */
+static unsigned
+dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
+{
+   unsigned i, plane_n;
+
+   switch (attrs-DMABufFourCC.Value) {
+   case DRM_FORMAT_RGB332:
+   case DRM_FORMAT_BGR233:
+   case DRM_FORMAT_XRGB:
+   case DRM_FORMAT_XBGR:
+   case DRM_FORMAT_RGBX:
+   case DRM_FORMAT_BGRX:
+   case DRM_FORMAT_ARGB:
+   case DRM_FORMAT_ABGR:
+   case DRM_FORMAT_RGBA:
+   case DRM_FORMAT_BGRA:
+   case DRM_FORMAT_XRGB1555:
+   case DRM_FORMAT_XBGR1555:
+   case DRM_FORMAT_RGBX5551:
+   case DRM_FORMAT_BGRX5551:
+   case DRM_FORMAT_ARGB1555:
+   case DRM_FORMAT_ABGR1555:
+   case DRM_FORMAT_RGBA5551:
+   case DRM_FORMAT_BGRA5551:
+   case DRM_FORMAT_RGB565:
+   case DRM_FORMAT_BGR565:
+   case DRM_FORMAT_RGB888:
+   case DRM_FORMAT_BGR888:
+   case DRM_FORMAT_XRGB:
+   case DRM_FORMAT_XBGR:
+   case DRM_FORMAT_RGBX:
+   case DRM_FORMAT_BGRX:
+   case DRM_FORMAT_ARGB:
+   case DRM_FORMAT_ABGR:
+   case DRM_FORMAT_RGBA:
+   case DRM_FORMAT_BGRA:
+   case DRM_FORMAT_XRGB2101010:
+   case DRM_FORMAT_XBGR2101010:
+   case DRM_FORMAT_RGBX1010102:
+   case DRM_FORMAT_BGRX1010102:
+   case DRM_FORMAT_ARGB2101010:
+   case DRM_FORMAT_ABGR2101010:
+   case DRM_FORMAT_RGBA1010102:
+   case DRM_FORMAT_BGRA1010102:
+   case DRM_FORMAT_YUYV:
+   case DRM_FORMAT_YVYU:
+   case DRM_FORMAT_UYVY:
+   case DRM_FORMAT_VYUY:
+  plane_n = 1;
+  break;
+   case DRM_FORMAT_NV12:
+   case DRM_FORMAT_NV21:
+   case DRM_FORMAT_NV16:
+   case DRM_FORMAT_NV61:
+  plane_n = 2;
+  break;
+   case DRM_FORMAT_YUV410:
+   case DRM_FORMAT_YVU410:
+   case DRM_FORMAT_YUV411:
+   case DRM_FORMAT_YVU411:
+   case DRM_FORMAT_YUV420:
+   case DRM_FORMAT_YVU420:
+   case DRM_FORMAT_YUV422:
+   case DRM_FORMAT_YVU422:
+   case DRM_FORMAT_YUV444:
+   case DRM_FORMAT_YVU444:
+  plane_n = 3;
+  break;
+   default:
+  _eglError(EGL_BAD_ATTRIBUTE, invalid format);
+  return 0;
+   }
+
+   /**
+ * The spec says:
+ *
+  

[Mesa-dev] [v8 9/9] i965: enable image external sampling for imported dma-buffers

2013-07-24 Thread Topi Pohjolainen
Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
---
 src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
 src/mesa/drivers/dri/i965/intel_tex_image.c  | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 409d40b..655467c 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -122,6 +122,7 @@ intelInitExtensions(struct gl_context *ctx)
ctx-Extensions.OES_EGL_image = true;
ctx-Extensions.OES_draw_texture = true;
ctx-Extensions.OES_standard_derivatives = true;
+   ctx-Extensions.OES_EGL_image_external = true;
 
if (brw-gen = 6)
   ctx-Const.GLSLVersion = 140;
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c 
b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 7d478d1..0f0a27d 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -378,6 +378,13 @@ intel_image_target_texture_2d(struct gl_context *ctx, 
GLenum target,
   return;
}
 
+   if (target == GL_TEXTURE_EXTERNAL_OES  !image-dma_buf_imported) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+glEGLImageTargetTexture2DOES(external target is enabled only 
+   for images created with EGL_EXT_image_dma_buf_import);
+  return;
+   }
+
/* Disallow depth/stencil textures: we don't have a way to pass the
 * separate stencil miptree of a GL_DEPTH_STENCIL texture through.
 */
-- 
1.8.1.2

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


[Mesa-dev] [PATCH 1/3] mesa: handle 2D texture arrays in get_tex_rgba_compressed()

2013-07-24 Thread Brian Paul
If we call glGetTexImage() for a compressed 2D texture array we need
to loop over all the slices.

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

NOTE: This is a candidate for the 9.x branches.
Cc: mesa-sta...@lists.freedesktop.org
---
 src/mesa/main/texgetimage.c |   52 ---
 1 file changed, 24 insertions(+), 28 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 4c672e3..7050f10 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -233,8 +233,8 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint 
dimensions,
const GLuint width = texImage-Width;
const GLuint height = texImage-Height;
const GLuint depth = texImage-Depth;
-   GLfloat *tempImage, *srcRow;
-   GLuint row;
+   GLfloat *tempImage, *tempSlice, *srcRow;
+   GLuint row, slice;
 
/* Decompress into temp float buffer, then pack into user buffer */
tempImage = malloc(width * height * depth
@@ -244,20 +244,22 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint 
dimensions,
   return;
}
 
-   /* Decompress the texture image - results in 'tempImage' */
-   {
+   /* Decompress the texture image slices - results in 'tempImage' */
+   for (slice = 0; slice  depth; slice++) {
   GLubyte *srcMap;
   GLint srcRowStride;
 
-  ctx-Driver.MapTextureImage(ctx, texImage, 0,
+  tempSlice = tempImage + slice * 4 * width * height;
+
+  ctx-Driver.MapTextureImage(ctx, texImage, slice,
   0, 0, width, height,
   GL_MAP_READ_BIT,
   srcMap, srcRowStride);
   if (srcMap) {
  _mesa_decompress_image(texFormat, width, height,
-srcMap, srcRowStride, tempImage);
+srcMap, srcRowStride, tempSlice);
 
- ctx-Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx-Driver.UnmapTextureImage(ctx, texImage, slice);
   }
   else {
  _mesa_error(ctx, GL_OUT_OF_MEMORY, glGetTexImage);
@@ -294,15 +296,19 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint 
dimensions,
   rebaseFormat);
}
 
-   srcRow = tempImage;
-   for (row = 0; row  height; row++) {
-  void *dest = _mesa_image_address(dimensions, ctx-Pack, pixels,
-   width, height, format, type,
-   0, row, 0);
-
-  _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) srcRow,
- format, type, dest, ctx-Pack, transferOps);
-  srcRow += width * 4;
+   tempSlice = tempImage;
+   for (slice = 0; slice  depth; slice++) {
+  srcRow = tempSlice;
+  for (row = 0; row  height; row++) {
+ void *dest = _mesa_image_address(dimensions, ctx-Pack, pixels,
+  width, height, format, type,
+  slice, row, 0);
+
+ _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) srcRow,
+format, type, dest, ctx-Pack, 
transferOps);
+ srcRow += 4 * width;
+  }
+  tempSlice += 4 * width * height;
}
 
free(tempImage);
@@ -616,18 +622,8 @@ _mesa_get_teximage(struct gl_context *ctx,
GLenum format, GLenum type, GLvoid *pixels,
struct gl_texture_image *texImage)
 {
-   GLuint dimensions;
-
-   switch (texImage-TexObject-Target) {
-   case GL_TEXTURE_1D:
-  dimensions = 1;
-  break;
-   case GL_TEXTURE_3D:
-  dimensions = 3;
-  break;
-   default:
-  dimensions = 2;
-   }
+   const GLuint dimensions =
+  _mesa_get_texture_dimensions(texImage-TexObject-Target);
 
/* map dest buffer, if PBO */
if (_mesa_is_bufferobj(ctx-Pack.BufferObj)) {
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 3/3] mesa: implement mipmap generation for compressed 2D array textures

2013-07-24 Thread Brian Paul
We weren't looping over all the slices in the array.  The updated
code should also correctly handle 3D compressed textures too, whenever
we have that feature.

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

NOTE: This is a candidate for the 9.x branches
Cc: mesa-sta...@lists.freedesktop.org
---
 src/mesa/main/mipmap.c |   59 +++-
 1 file changed, 43 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index edf7257..5839632 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -2020,13 +2020,15 @@ generate_mipmap_compressed(struct gl_context *ctx, 
GLenum target,
GLuint level;
gl_format temp_format;
GLint components;
-   GLuint temp_src_stride; /* in bytes */
+   GLuint temp_src_row_stride, temp_src_img_stride; /* in bytes */
GLubyte *temp_src = NULL, *temp_dst = NULL;
GLenum temp_datatype;
GLenum temp_base_format;
+   GLubyte **temp_src_slices, **temp_dst_slices;
 
/* only two types of compressed textures at this time */
assert(texObj-Target == GL_TEXTURE_2D ||
+ texObj-Target == GL_TEXTURE_2D_ARRAY ||
  texObj-Target == GL_TEXTURE_CUBE_MAP_ARB);
 
/*
@@ -2051,15 +2053,24 @@ generate_mipmap_compressed(struct gl_context *ctx, 
GLenum target,
 
 
/* allocate storage for the temporary, uncompressed image */
-   /* 20 extra bytes, just be safe when calling last FetchTexel */
-   temp_src_stride = _mesa_format_row_stride(temp_format, srcImage-Width);
-   temp_src = malloc(temp_src_stride * srcImage-Height + 20);
-   if (!temp_src) {
+   temp_src_row_stride = _mesa_format_row_stride(temp_format, srcImage-Width);
+   temp_src_img_stride = _mesa_format_image_size(temp_format, srcImage-Width,
+ srcImage-Height, 1);
+   temp_src = malloc(temp_src_img_stride * srcImage-Depth);
+
+   /* Allocate storage for arrays of slice pointers */
+   temp_src_slices = malloc(srcImage-Depth * sizeof(GLubyte *));
+   temp_dst_slices = malloc(srcImage-Depth * sizeof(GLubyte *));
+
+   if (!temp_src || !temp_src_slices || !temp_dst_slices) {
+  free(temp_src);
+  free(temp_src_slices);
+  free(temp_dst_slices);
   _mesa_error(ctx, GL_OUT_OF_MEMORY, generate mipmaps);
   return;
}
 
-   /* decompress base image to the temporary */
+   /* decompress base image to the temporary src buffer */
{
   /* save pixel packing mode */
   struct gl_pixelstore_attrib save = ctx-Pack;
@@ -2075,7 +2086,6 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum 
target,
   ctx-Pack = save;
}
 
-
for (level = texObj-BaseLevel; level  maxLevel; level++) {
   /* generate image[level+1] from image[level] */
   const struct gl_texture_image *srcImage;
@@ -2084,7 +2094,8 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum 
target,
   GLint dstWidth, dstHeight, dstDepth;
   GLint border;
   GLboolean nextLevel;
-  GLuint temp_dst_stride; /* in bytes */
+  GLuint temp_dst_row_stride, temp_dst_img_stride; /* in bytes */
+  GLuint i;
 
   /* get src image parameters */
   srcImage = _mesa_select_tex_image(ctx, texObj, target, level);
@@ -2100,9 +2111,12 @@ generate_mipmap_compressed(struct gl_context *ctx, 
GLenum target,
   if (!nextLevel)
 break;
 
-  temp_dst_stride = _mesa_format_row_stride(temp_format, dstWidth);
+  /* Compute dst image strides and alloc memory on first iteration */
+  temp_dst_row_stride = _mesa_format_row_stride(temp_format, dstWidth);
+  temp_dst_img_stride = _mesa_format_image_size(temp_format, dstWidth,
+dstHeight, 1);
   if (!temp_dst) {
-temp_dst = malloc(temp_dst_stride * dstHeight);
+temp_dst = malloc(temp_dst_img_stride * dstDepth);
 if (!temp_dst) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, generate mipmaps);
break;
@@ -2117,13 +2131,23 @@ generate_mipmap_compressed(struct gl_context *ctx, 
GLenum target,
  return;
   }
 
-  /* rescale src image to dest image */
+  /* for 2D arrays, setup array[depth] of slice pointers */
+  for (i = 0; i  srcDepth; i++) {
+ temp_src_slices[i] = temp_src + temp_src_img_stride * i;
+  }
+  for (i = 0; i  dstDepth; i++) {
+ temp_dst_slices[i] = temp_dst + temp_dst_img_stride * i;
+  }
+
+  /* Rescale src image to dest image.
+   * This will loop over the slices of a 2D array.
+   */
   _mesa_generate_mipmap_level(target, temp_datatype, components, border,
   srcWidth, srcHeight, srcDepth,
-  (const GLubyte **) temp_src,
-  temp_src_stride,
+  (const GLubyte **) temp_src_slices,
+  temp_src_row_stride,
   

Re: [Mesa-dev] [PATCH 3/3] mesa: implement mipmap generation for compressed 2D array textures

2013-07-24 Thread Jose Fonseca
Series looks alright AFAICT.

Jose

- Original Message -
 We weren't looping over all the slices in the array.  The updated
 code should also correctly handle 3D compressed textures too, whenever
 we have that feature.
 
 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66850
 
 NOTE: This is a candidate for the 9.x branches
 Cc: mesa-sta...@lists.freedesktop.org
 ---
  src/mesa/main/mipmap.c |   59
  +++-
  1 file changed, 43 insertions(+), 16 deletions(-)
 
 diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
 index edf7257..5839632 100644
 --- a/src/mesa/main/mipmap.c
 +++ b/src/mesa/main/mipmap.c
 @@ -2020,13 +2020,15 @@ generate_mipmap_compressed(struct gl_context *ctx,
 GLenum target,
 GLuint level;
 gl_format temp_format;
 GLint components;
 -   GLuint temp_src_stride; /* in bytes */
 +   GLuint temp_src_row_stride, temp_src_img_stride; /* in bytes */
 GLubyte *temp_src = NULL, *temp_dst = NULL;
 GLenum temp_datatype;
 GLenum temp_base_format;
 +   GLubyte **temp_src_slices, **temp_dst_slices;
  
 /* only two types of compressed textures at this time */
 assert(texObj-Target == GL_TEXTURE_2D ||
 +   texObj-Target == GL_TEXTURE_2D_ARRAY ||
 texObj-Target == GL_TEXTURE_CUBE_MAP_ARB);
  
 /*
 @@ -2051,15 +2053,24 @@ generate_mipmap_compressed(struct gl_context *ctx,
 GLenum target,
  
  
 /* allocate storage for the temporary, uncompressed image */
 -   /* 20 extra bytes, just be safe when calling last FetchTexel */
 -   temp_src_stride = _mesa_format_row_stride(temp_format, srcImage-Width);
 -   temp_src = malloc(temp_src_stride * srcImage-Height + 20);
 -   if (!temp_src) {
 +   temp_src_row_stride = _mesa_format_row_stride(temp_format,
 srcImage-Width);
 +   temp_src_img_stride = _mesa_format_image_size(temp_format,
 srcImage-Width,
 + srcImage-Height, 1);
 +   temp_src = malloc(temp_src_img_stride * srcImage-Depth);
 +
 +   /* Allocate storage for arrays of slice pointers */
 +   temp_src_slices = malloc(srcImage-Depth * sizeof(GLubyte *));
 +   temp_dst_slices = malloc(srcImage-Depth * sizeof(GLubyte *));
 +
 +   if (!temp_src || !temp_src_slices || !temp_dst_slices) {
 +  free(temp_src);
 +  free(temp_src_slices);
 +  free(temp_dst_slices);
_mesa_error(ctx, GL_OUT_OF_MEMORY, generate mipmaps);
return;
 }
  
 -   /* decompress base image to the temporary */
 +   /* decompress base image to the temporary src buffer */
 {
/* save pixel packing mode */
struct gl_pixelstore_attrib save = ctx-Pack;
 @@ -2075,7 +2086,6 @@ generate_mipmap_compressed(struct gl_context *ctx,
 GLenum target,
ctx-Pack = save;
 }
  
 -
 for (level = texObj-BaseLevel; level  maxLevel; level++) {
/* generate image[level+1] from image[level] */
const struct gl_texture_image *srcImage;
 @@ -2084,7 +2094,8 @@ generate_mipmap_compressed(struct gl_context *ctx,
 GLenum target,
GLint dstWidth, dstHeight, dstDepth;
GLint border;
GLboolean nextLevel;
 -  GLuint temp_dst_stride; /* in bytes */
 +  GLuint temp_dst_row_stride, temp_dst_img_stride; /* in bytes */
 +  GLuint i;
  
/* get src image parameters */
srcImage = _mesa_select_tex_image(ctx, texObj, target, level);
 @@ -2100,9 +2111,12 @@ generate_mipmap_compressed(struct gl_context *ctx,
 GLenum target,
if (!nextLevel)
break;
  
 -  temp_dst_stride = _mesa_format_row_stride(temp_format, dstWidth);
 +  /* Compute dst image strides and alloc memory on first iteration */
 +  temp_dst_row_stride = _mesa_format_row_stride(temp_format, dstWidth);
 +  temp_dst_img_stride = _mesa_format_image_size(temp_format, dstWidth,
 +dstHeight, 1);
if (!temp_dst) {
 -  temp_dst = malloc(temp_dst_stride * dstHeight);
 +  temp_dst = malloc(temp_dst_img_stride * dstDepth);
if (!temp_dst) {
   _mesa_error(ctx, GL_OUT_OF_MEMORY, generate mipmaps);
   break;
 @@ -2117,13 +2131,23 @@ generate_mipmap_compressed(struct gl_context *ctx,
 GLenum target,
   return;
}
  
 -  /* rescale src image to dest image */
 +  /* for 2D arrays, setup array[depth] of slice pointers */
 +  for (i = 0; i  srcDepth; i++) {
 + temp_src_slices[i] = temp_src + temp_src_img_stride * i;
 +  }
 +  for (i = 0; i  dstDepth; i++) {
 + temp_dst_slices[i] = temp_dst + temp_dst_img_stride * i;
 +  }
 +
 +  /* Rescale src image to dest image.
 +   * This will loop over the slices of a 2D array.
 +   */
_mesa_generate_mipmap_level(target, temp_datatype, components, border,
srcWidth, srcHeight, srcDepth,
 -  (const GLubyte **) temp_src,
 -  

[Mesa-dev] [PATCH] i965: Initialize inout_offset parameter to brw_search_cache().

2013-07-24 Thread Paul Berry
Two callers of brw_search_cache() weren't initializing that function's
inout_offset parameter: brw_blorp_const_color_params::get_wm_prog()
and brw_blorp_const_color_params::get_wm_prog().

That's a benign problem, since the only effect of not initializing
inout_offset prior to calling brw_search_cache() is that the bit
corresponding to cache_id in brw-state.dirty.cache may not be set
reliably.  This is ok, since the cache_id's used by
brw_blorp_const_color_params::get_wm_prog() and
brw_blorp_blit_params::get_wm_prog() (BRW_BLORP_CONST_COLOR_PROG and
BRW_BLORP_BLIT_PROG, respectively) correspond to dirty bits that are
not used.

However, failing to initialize this parameter causes valgrind to
complain.  So let's go ahead and fix it to reduce valgrind noise.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66779
---
 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp  | 2 +-
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 6610ef0..bce2d4d 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -2280,7 +2280,7 @@ uint32_t
 brw_blorp_blit_params::get_wm_prog(struct brw_context *brw,
brw_blorp_prog_data **prog_data) const
 {
-   uint32_t prog_offset;
+   uint32_t prog_offset = 0;
if (!brw_search_cache(brw-cache, BRW_BLORP_BLIT_PROG,
  this-wm_prog_key, sizeof(this-wm_prog_key),
  prog_offset, prog_data)) {
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index 6588b7f..f26f39d 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -342,7 +342,7 @@ brw_blorp_const_color_params::get_wm_prog(struct 
brw_context *brw,
   brw_blorp_prog_data **prog_data)
const
 {
-   uint32_t prog_offset;
+   uint32_t prog_offset = 0;
if (!brw_search_cache(brw-cache, BRW_BLORP_CONST_COLOR_PROG,
  this-wm_prog_key, sizeof(this-wm_prog_key),
  prog_offset, prog_data)) {
-- 
1.8.3.3

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


Re: [Mesa-dev] [PATCH] glsl: Handle empty if statement encountered during loop analysis.

2013-07-24 Thread Kenneth Graunke

On 07/24/2013 08:17 AM, Paul Berry wrote:

The is_loop_terminator() function was asserting that the following
kind of if statement could never occur:

 if (...) { } else { }

(presumably based on the assumption that such an if statement would be
eliminated by previous optimization stages).  But that isn't the
case--it's possible that previous optimization stages might simplify
more complex code down to this empty if statement, in which case it
won't be eliminated until the next time through the optimization loop.

So is_loop_terminator() needs to handle it.  Fortunately it's easy to
handle--it's not a loop terminator because it does nothing.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64330
CC: mesa-sta...@lists.freedesktop.org
---
  src/glsl/loop_analysis.cpp | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp
index 191e92d..40897bb 100644
--- a/src/glsl/loop_analysis.cpp
+++ b/src/glsl/loop_analysis.cpp
@@ -503,7 +503,8 @@ is_loop_terminator(ir_if *ir)

 ir_instruction *const inst =
(ir_instruction *) ir-then_instructions.get_head();
-   assert(inst != NULL);
+   if (inst == NULL)
+  return false;

 if (inst-ir_type != ir_type_loop_jump)
return false;



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

This would have been a bit more obvious if 'diff' had included a few 
more lines of context.  Immediately above this hunk, there is:


   if (!ir-else_instructions.is_empty())
  return false;

which already guarantees the else block is empty, so it really is just 
the noop if (...) {} {} statement.


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


[Mesa-dev] ES3 conformance regressions

2013-07-24 Thread Kenneth Graunke

Hey Ian,

I'm seeing three regressions in es3conform:

GL3Tests/depth24/depth24_basic.test
GL3Tests/depth24/depth24_precision.test
GL3Tests/rgb8_rgba8/rgb8_rgba8_rgb.test

9.1.4 worked, but 9.1.5 and master are both broken.  Bisecting tracked 
it down to:


commit c170c901d0f5384e5ab8b79b827663fa28439b0b
Author: Ian Romanick ian.d.roman...@intel.com
Date:   Fri Jun 7 17:05:22 2013 -0700

glsl: Move all var decls to the front of the IR list in reverse order

Reverting that commit on master fixes the regressions.

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


[Mesa-dev] [PATCH] draw: fix vertex id computation

2013-07-24 Thread Zack Rusin
vertex id has to be unaffected by the start index (i.e. when calling
draw arrays with start_index = 5, the first vertex_id has to still
be 0, not 5) and it has to be equal to the index when performing
indexed rendering (in which case it has to be unaffected by the
index bias). This fixes our behavior.

Signed-off-by: Zack Rusin za...@vmware.com
---
 src/gallium/auxiliary/draw/draw_llvm.c |   36 +++-
 src/gallium/auxiliary/draw/draw_llvm.h |6 ++--
 src/gallium/auxiliary/draw/draw_private.h  |1 +
 src/gallium/auxiliary/draw/draw_pt.c   |1 +
 .../draw/draw_pt_fetch_shade_pipeline_llvm.c   |6 ++--
 5 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index a3174b4..c195a2b 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1486,7 +1486,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
struct gallivm_state *gallivm = variant-gallivm;
LLVMContextRef context = gallivm-context;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
-   LLVMTypeRef arg_types[9];
+   LLVMTypeRef arg_types[10];
unsigned num_arg_types =
   elts ? Elements(arg_types) : Elements(arg_types) - 1;
LLVMTypeRef func_type;
@@ -1496,6 +1496,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
struct lp_type vs_type;
LLVMValueRef end, start;
LLVMValueRef count, fetch_elts, fetch_elt_max, fetch_count;
+   LLVMValueRef vertex_id_offset;
LLVMValueRef stride, step, io_itr;
LLVMValueRef io_ptr, vbuffers_ptr, vb_ptr;
LLVMValueRef zero = lp_build_const_int32(gallivm, 0);
@@ -1541,6 +1542,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
arg_types[i++] = int32_type; /* stride */
arg_types[i++] = get_vb_ptr_type(variant);   /* pipe_vertex_buffer's */
arg_types[i++] = int32_type; /* instance_id */
+   arg_types[i++] = int32_type; /* vertex_id_offset */
 
func_type = LLVMFunctionType(int32_type, arg_types, num_arg_types, 0);
 
@@ -1565,6 +1567,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
stride= LLVMGetParam(variant_func, 5 + (elts ? 1 : 0));
vb_ptr= LLVMGetParam(variant_func, 6 + (elts ? 1 : 0));
system_values.instance_id = LLVMGetParam(variant_func, 7 + (elts ? 1 : 0));
+   vertex_id_offset  = LLVMGetParam(variant_func, 8 + (elts ? 1 : 0));
 
lp_build_name(context_ptr, context);
lp_build_name(io_ptr, io);
@@ -1572,6 +1575,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
lp_build_name(stride, stride);
lp_build_name(vb_ptr, vb);
lp_build_name(system_values.instance_id, instance_id);
+   lp_build_name(vertex_id_offset, vertex_id_offset);
 
if (elts) {
   fetch_elts= LLVMGetParam(variant_func, 3);
@@ -1646,22 +1650,19 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
 #endif
   system_values.vertex_id = lp_build_zero(gallivm, lp_type_uint_vec(32, 
32*vector_length));
   for (i = 0; i  vector_length; ++i) {
- LLVMValueRef true_index =
+ LLVMValueRef vert_index =
 LLVMBuildAdd(builder,
  lp_loop.counter,
  lp_build_const_int32(gallivm, i), );
- true_index = LLVMBuildAdd(builder, start, true_index, );
+ LLVMValueRef true_index =
+LLVMBuildAdd(builder, start, vert_index, );
+ LLVMValueRef vertex_id;
 
  /* make sure we're not out of bounds which can happen
   * if fetch_count % 4 != 0, because on the last iteration
   * a few of the 4 vertex fetches will be out of bounds */
  true_index = lp_build_min(bld, true_index, fetch_max);
 
- system_values.vertex_id = LLVMBuildInsertElement(
-gallivm-builder,
-system_values.vertex_id, true_index,
-lp_build_const_int32(gallivm, i), );
-
  if (elts) {
 LLVMValueRef fetch_ptr;
 LLVMValueRef index_overflowed;
@@ -1673,7 +1674,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
 index_overflowed = LLVMBuildICmp(builder, LLVMIntUGT,
  true_index, fetch_elt_max,
  index_overflowed);
-
+
 lp_build_if(if_ctx, gallivm, index_overflowed);
 {
/* Generate maximum possible index so that
@@ -1698,6 +1699,23 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant,
 lp_build_endif(if_ctx);
 true_index = LLVMBuildLoad(builder, index_ptr, 

Re: [Mesa-dev] ES3 conformance regressions

2013-07-24 Thread Ian Romanick

On 07/24/2013 02:15 PM, Kenneth Graunke wrote:

Hey Ian,

I'm seeing three regressions in es3conform:

GL3Tests/depth24/depth24_basic.test
GL3Tests/depth24/depth24_precision.test
GL3Tests/rgb8_rgba8/rgb8_rgba8_rgb.test


I didn't observer that failure when I pushed that commit, but it does 
appear to fail now.  WTF?  There was another test that failed 
(stencil_plane_operation), and that required 329cd6a9.


Have you had a chance to do any analysis of the cause of the failure? 
Do any other drivers fail, or is it just i965?



9.1.4 worked, but 9.1.5 and master are both broken.  Bisecting tracked
it down to:

commit c170c901d0f5384e5ab8b79b827663fa28439b0b
Author: Ian Romanick ian.d.roman...@intel.com
Date:   Fri Jun 7 17:05:22 2013 -0700

 glsl: Move all var decls to the front of the IR list in reverse order

Reverting that commit on master fixes the regressions.

--Ken


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


Re: [Mesa-dev] ES3 conformance regressions

2013-07-24 Thread Kenneth Graunke

On 07/24/2013 02:26 PM, Ian Romanick wrote:

On 07/24/2013 02:15 PM, Kenneth Graunke wrote:

Hey Ian,

I'm seeing three regressions in es3conform:

GL3Tests/depth24/depth24_basic.test
GL3Tests/depth24/depth24_precision.test
GL3Tests/rgb8_rgba8/rgb8_rgba8_rgb.test


I didn't observer that failure when I pushed that commit, but it does
appear to fail now.  WTF?  There was another test that failed
(stencil_plane_operation), and that required 329cd6a9.


Right.  Perhaps it's just exposing another bug.


Have you had a chance to do any analysis of the cause of the failure? Do
any other drivers fail, or is it just i965?


I haven't had a chance to analyze it yet...and with it being an ES3 
test, running on other drivers is a bit trickier.  (r600g supports ES3 I 
think, but I don't have that handy...)


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


[Mesa-dev] vdpau/vl 422 chroma width/height mix up

2013-07-24 Thread Andy Furniss
I was looking into some minor 422 issues/discrepencies I noticed long 
ago using vdpau on my rv790.


I noticed that there is code that is halving height rather than width - 
422 is full height AFAIK.


Making the changes below doesn't actually make any noticable difference 
to what I was looking into.


Maybe there are more but here's three I've found so far -

diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c

index 1eb9708..de890fe 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -1063,8 +1063,8 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
   dec-chroma_height = dec-base.height / 2;
   dec-num_blocks = dec-num_blocks * 2;
} else if (dec-base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
-  dec-chroma_width = dec-base.width;
-  dec-chroma_height = dec-base.height / 2;
+  dec-chroma_width = dec-base.width / 2;
+  dec-chroma_height = dec-base.height;
   dec-num_blocks = dec-num_blocks * 2 + dec-num_blocks;
} else {
   dec-chroma_width = dec-base.width;
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c 
b/src/gallium/auxiliary/vl/vl_video_buffer.c

index 6ef95e4..9600ce9 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.c
@@ -239,7 +239,7 @@ vl_video_buffer_template(struct pipe_resource *templ,
  templ-width0 /= 2;
  templ-height0 /= 2;
   } else if (tmpl-chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
- templ-height0 /= 2;
+ templ-width0 /= 2;
   }
}
 }
diff --git a/src/gallium/state_trackers/vdpau/surface.c 
b/src/gallium/state_trackers/vdpau/surface.c

index bd11fc3..1bebe6c 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -172,7 +172,7 @@ vlVdpVideoSurfaceSize(vlVdpSurface *p_surf, int 
component,

  *width /= 2;
  *height /= 2;
   } else if (p_surf-templat.chroma_format == 
PIPE_VIDEO_CHROMA_FORMAT_422) {

- *height /= 2;
+ *width /= 2;
   }
}
if (p_surf-templat.interlaced)

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


Re: [Mesa-dev] [PATCH vmwgfx] update for XA API changes

2013-07-24 Thread Jakob Bornecrantz
On Thu, Jul 11, 2013 at 1:58 AM, Jakob Bornecrantz wallbra...@gmail.comwrote:

 Just tried this out, on your XA branch, and I'm getting rendering
 issues in gnome-terminal. It looks like some text is offset by
 one or two lines, and the rest looks a bit like pitch issues.

 http://i.imgur.com/mdivF0q.png

 I can't really see anything in the patch that would cause this,
 going to take a extra look at the xa patches on the mesa sida.


Okay, I did some testing and reverted the commit
b89ac75 xa: fix dma copy function and I saw no rendering errors.

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


Re: [Mesa-dev] [PATCH vmwgfx] update for XA API changes

2013-07-24 Thread Rob Clark
On Wed, Jul 24, 2013 at 6:33 PM, Jakob Bornecrantz wallbra...@gmail.com wrote:
 On Thu, Jul 11, 2013 at 1:58 AM, Jakob Bornecrantz wallbra...@gmail.com
 wrote:

 Just tried this out, on your XA branch, and I'm getting rendering
 issues in gnome-terminal. It looks like some text is offset by
 one or two lines, and the rest looks a bit like pitch issues.

 http://i.imgur.com/mdivF0q.png

 I can't really see anything in the patch that would cause this,
 going to take a extra look at the xa patches on the mesa sida.


 Okay, I did some testing and reverted the commit
 b89ac75 xa: fix dma copy function and I saw no rendering errors.

cool, then if it is ok I'll push the rest minus the freedreno ones
(until I have a chance to create a loader for xa)..

BR,
-R

 Cheers, Jakob.

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


Re: [Mesa-dev] [PATCH] draw: fix vertex id computation

2013-07-24 Thread Roland Scheidegger
Am 24.07.2013 23:22, schrieb Zack Rusin:
 vertex id has to be unaffected by the start index (i.e. when calling
 draw arrays with start_index = 5, the first vertex_id has to still
 be 0, not 5) and it has to be equal to the index when performing
 indexed rendering (in which case it has to be unaffected by the
 index bias). This fixes our behavior.
 
 Signed-off-by: Zack Rusin za...@vmware.com
 ---
  src/gallium/auxiliary/draw/draw_llvm.c |   36 
 +++-
  src/gallium/auxiliary/draw/draw_llvm.h |6 ++--
  src/gallium/auxiliary/draw/draw_private.h  |1 +
  src/gallium/auxiliary/draw/draw_pt.c   |1 +
  .../draw/draw_pt_fetch_shade_pipeline_llvm.c   |6 ++--
  5 files changed, 37 insertions(+), 13 deletions(-)
 
 diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
 b/src/gallium/auxiliary/draw/draw_llvm.c
 index a3174b4..c195a2b 100644
 --- a/src/gallium/auxiliary/draw/draw_llvm.c
 +++ b/src/gallium/auxiliary/draw/draw_llvm.c
 @@ -1486,7 +1486,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
 draw_llvm_variant *variant,
 struct gallivm_state *gallivm = variant-gallivm;
 LLVMContextRef context = gallivm-context;
 LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
 -   LLVMTypeRef arg_types[9];
 +   LLVMTypeRef arg_types[10];
 unsigned num_arg_types =
elts ? Elements(arg_types) : Elements(arg_types) - 1;
 LLVMTypeRef func_type;
 @@ -1496,6 +1496,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
 draw_llvm_variant *variant,
 struct lp_type vs_type;
 LLVMValueRef end, start;
 LLVMValueRef count, fetch_elts, fetch_elt_max, fetch_count;
 +   LLVMValueRef vertex_id_offset;
 LLVMValueRef stride, step, io_itr;
 LLVMValueRef io_ptr, vbuffers_ptr, vb_ptr;
 LLVMValueRef zero = lp_build_const_int32(gallivm, 0);
 @@ -1541,6 +1542,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
 draw_llvm_variant *variant,
 arg_types[i++] = int32_type; /* stride */
 arg_types[i++] = get_vb_ptr_type(variant);   /* pipe_vertex_buffer's 
 */
 arg_types[i++] = int32_type; /* instance_id */
 +   arg_types[i++] = int32_type; /* vertex_id_offset */
  
 func_type = LLVMFunctionType(int32_type, arg_types, num_arg_types, 0);
  
 @@ -1565,6 +1567,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
 draw_llvm_variant *variant,
 stride= LLVMGetParam(variant_func, 5 + (elts ? 1 : 
 0));
 vb_ptr= LLVMGetParam(variant_func, 6 + (elts ? 1 : 
 0));
 system_values.instance_id = LLVMGetParam(variant_func, 7 + (elts ? 1 : 
 0));
 +   vertex_id_offset  = LLVMGetParam(variant_func, 8 + (elts ? 1 : 
 0));
  
 lp_build_name(context_ptr, context);
 lp_build_name(io_ptr, io);
 @@ -1572,6 +1575,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
 draw_llvm_variant *variant,
 lp_build_name(stride, stride);
 lp_build_name(vb_ptr, vb);
 lp_build_name(system_values.instance_id, instance_id);
 +   lp_build_name(vertex_id_offset, vertex_id_offset);
  
 if (elts) {
fetch_elts= LLVMGetParam(variant_func, 3);
 @@ -1646,22 +1650,19 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
 draw_llvm_variant *variant,
  #endif
system_values.vertex_id = lp_build_zero(gallivm, lp_type_uint_vec(32, 
 32*vector_length));
for (i = 0; i  vector_length; ++i) {
 - LLVMValueRef true_index =
 + LLVMValueRef vert_index =
  LLVMBuildAdd(builder,
   lp_loop.counter,
   lp_build_const_int32(gallivm, i), );
 - true_index = LLVMBuildAdd(builder, start, true_index, );
 + LLVMValueRef true_index =
 +LLVMBuildAdd(builder, start, vert_index, );
 + LLVMValueRef vertex_id;
  
   /* make sure we're not out of bounds which can happen
* if fetch_count % 4 != 0, because on the last iteration
* a few of the 4 vertex fetches will be out of bounds */
   true_index = lp_build_min(bld, true_index, fetch_max);
  
 - system_values.vertex_id = LLVMBuildInsertElement(
 -gallivm-builder,
 -system_values.vertex_id, true_index,
 -lp_build_const_int32(gallivm, i), );
 -
   if (elts) {
  LLVMValueRef fetch_ptr;
  LLVMValueRef index_overflowed;
 @@ -1673,7 +1674,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
 draw_llvm_variant *variant,
  index_overflowed = LLVMBuildICmp(builder, LLVMIntUGT,
   true_index, fetch_elt_max,
   index_overflowed);
 -
 +
  lp_build_if(if_ctx, gallivm, index_overflowed);
  {
 /* Generate maximum possible index so that
 @@ -1698,6 +1699,23 @@ draw_llvm_generate(struct 

Re: [Mesa-dev] [v8 2/9] intel: do not create renderbuffers out of planar images

2013-07-24 Thread Chad Versace

On 07/24/2013 03:23 AM, Topi Pohjolainen wrote:

v2 (Chad): emit 'GL_INVALID_OPERATION' and description of error

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
---
  src/mesa/drivers/dri/i965/intel_fbo.c | 7 +++
  1 file changed, 7 insertions(+)


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

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


Re: [Mesa-dev] [v8 7/9] intel: restrict dma-buf-import images to external sampling only

2013-07-24 Thread Chad Versace

On 07/24/2013 03:23 AM, Topi Pohjolainen wrote:

Memory originating outside mesa stack is meant to be for reading
only. In addition, the restrictions imposed by the image external
extension should apply. For example, users shouldn't be allowed
to generare mip-trees based on these images.

v2 (Chad): document using full extension names, fix the comment
style itself and emit description of error

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
---
  src/mesa/drivers/dri/i965/intel_fbo.c   |  7 +++
  src/mesa/drivers/dri/i965/intel_regions.h   |  9 -
  src/mesa/drivers/dri/i965/intel_screen.c|  1 +
  src/mesa/drivers/dri/i965/intel_tex_image.c | 11 +++
  4 files changed, 27 insertions(+), 1 deletion(-)


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

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


Re: [Mesa-dev] [v8 9/9] i965: enable image external sampling for imported dma-buffers

2013-07-24 Thread Chad Versace

This patch is
Reviewed-by: Chad Versace chad.vers...@linux.intel.com
with the understanding that it depends on previous patches.

I'll begin reviewing your Piglit tests now.

On 07/24/2013 03:23 AM, Topi Pohjolainen wrote:

Signed-off-by: Topi Pohjolainen topi.pohjolai...@intel.com
---
  src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
  src/mesa/drivers/dri/i965/intel_tex_image.c  | 7 +++
  2 files changed, 8 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 409d40b..655467c 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -122,6 +122,7 @@ intelInitExtensions(struct gl_context *ctx)
 ctx-Extensions.OES_EGL_image = true;
 ctx-Extensions.OES_draw_texture = true;
 ctx-Extensions.OES_standard_derivatives = true;
+   ctx-Extensions.OES_EGL_image_external = true;

 if (brw-gen = 6)
ctx-Const.GLSLVersion = 140;
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c 
b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 7d478d1..0f0a27d 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -378,6 +378,13 @@ intel_image_target_texture_2d(struct gl_context *ctx, 
GLenum target,
return;
 }

+   if (target == GL_TEXTURE_EXTERNAL_OES  !image-dma_buf_imported) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+glEGLImageTargetTexture2DOES(external target is enabled only 
+   for images created with EGL_EXT_image_dma_buf_import);
+  return;
+   }
+
 /* Disallow depth/stencil textures: we don't have a way to pass the
  * separate stencil miptree of a GL_DEPTH_STENCIL texture through.
  */



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


[Mesa-dev] [PATCH] gallium/vl: add prime support

2013-07-24 Thread Dave Airlie
From: Dave Airlie airl...@redhat.com

This fixes the dri2 opening to check if DRI_PRIME is set,
and picks the correct drm device path to open, this along
with a change to libvdpau allows vdpauinfo to work at least,

Martin Peres tested with nouveau, and there seems to be a
further issue with final displaying, it only works sometimes,
but this patch is at least necessary to help debug further.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 src/gallium/auxiliary/vl/vl_winsys_dri.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 88e17fe..7aec3fe 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -32,8 +32,10 @@
 #include fcntl.h
 
 #include X11/Xlib-xcb.h
+#include X11/extensions/dri2tokens.h
 #include xcb/dri2.h
 #include xf86drm.h
+#include errno.h
 
 #include pipe/p_screen.h
 #include pipe/p_context.h
@@ -305,6 +307,7 @@ vl_screen_create(Display *display, int screen)
xcb_generic_error_t *error = NULL;
char *device_name;
int fd, device_name_length;
+   unsigned int driverType;
 
drm_magic_t magic;
 
@@ -332,7 +335,22 @@ vl_screen_create(Display *display, int screen)
s = xcb_setup_roots_iterator(xcb_get_setup(scrn-conn));
while (screen--)
xcb_screen_next(s);
-   connect_cookie = xcb_dri2_connect_unchecked(scrn-conn, s.data-root, 
XCB_DRI2_DRIVER_TYPE_DRI);
+   driverType = XCB_DRI2_DRIVER_TYPE_DRI;
+#ifdef DRI2DriverPrimeShift
+   {
+  char *prime = getenv(DRI_PRIME);
+  if (prime) {
+ unsigned int primeid;
+ errno = 0;
+ primeid = strtoul(prime, NULL, 0);
+ if (errno == 0)
+driverType |=
+   ((primeid  DRI2DriverPrimeMask)  DRI2DriverPrimeShift);
+  }
+   }
+#endif
+
+   connect_cookie = xcb_dri2_connect_unchecked(scrn-conn, s.data-root, 
driverType);
connect = xcb_dri2_connect_reply(scrn-conn, connect_cookie, NULL);
if (connect == NULL || connect-driver_name_length + 
connect-device_name_length == 0)
   goto free_screen;
-- 
1.8.3.1

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