Re: [Mesa-dev] [PATCH v4 2/2] driconf: Update Catalan translation

2015-02-24 Thread Eric Anholt
Alex Henrie  writes:

> Signed-off-by: Alex Henrie 

Pushed.  Thanks!  Sorry for the delay.

For the future, we tend to record the patch version changes in the main
commit log, so that when the patch is applied it's obvious which version
got applied.  This also helps record why the code ended up the way it
did when there were multiple options, and the deliberation that went
into it.


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


[Mesa-dev] About sRGB encoding/decoding while blitting

2015-02-24 Thread Antía Puentes
Hi!

I have been looking into the dEQP test failures that deal with blitting
between sRGB and linear color spaces, and vice versa (in total 37
tests).

OpenGL ES 3.0 and OpenGL 4.4 specifications clearly state that
linearization should happen when reading from sRGB buffers, and sRGB
encoding should be done when writing to sRGB buffers during the blit
operation. In the case OpenGL 4.4 specification this encoding/decoding
is dependent on the value of the GL_FRAMEBUFFER_SRGB enable flag; OpenGL
ES 3.0 acts as if this setting was always enabled.

 - From section 4.3.3 ("Copying Pixels") of the OpenGL ES 3.0
specification (page 198):

"When values are taken from the read buffer, if the value of
FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer
attachment corresponding to the read buffer is SRGB (see section
6.1.13), the red, green, and blue components are converted from
the non-linear sRGB color space according to equation 3.24.

When values are written to the draw buffers, blit operations
bypass the fragment pipeline. The only fragment operations which
affect a blit are the pixel ownership test, the scissor test,
and sRGB conversion (see section 4.1.8). Color, depth, and
stencil masks (see section 4.2.2) are ignored."

 - From section 18.3.1 ("Blitting Pixel Rectangles") of the OpenGL 4.4
core specification (page 485):

"When values are taken from the read buffer, if FRAMEBUFFER_SRGB
is enabled and the value of
FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer
attachment corresponding to the read buffer is SRGB (see section
9.2.3), the red, green, and blue components are converted from
the non-linear sRGB color space according to equation 8.14.

When values are written to the draw buffers, blit operations
bypass most of the fragment pipeline. The only fragment
operations which affect a blit are the pixel ownership test, the
scissor test, and sRGB conversion (see section 17.3.9). Color,
depth, and stencil masks (see section 17.4.2) are ignored."

However, the implementation in Mesa preserves the underlying binary
representation of the pixels,
regardless the color space. This is related to the fact that the OpenGL
4.3 specification was not consistent regarding blits involving sRGB
buffers; for more information see [1]. Apart from this, it was suggested
in some comments in the code (specifically comments [1] and [2]), that
existing games and applications rely on the current behaviour, not
expecting sRGB encoding/decoding to be done.

In summary, the current implementation does not respect the OpenGL 4.4
and OpenGL ES 3.0 specs, however, it seems to be the implementation that
some applications / games expect, so it is unclear to me if we want to
re-implement this according to what the specs dictate or leave it as it
is now. Any thoughts?

Regards.


[1] Piglit: comments in tests/spec/arb_framebuffer_srgb/blit.c source
file and the log of the commit abd189966d39648c00f3204c58fef217e94a8703

[2] Mesa: comments in src/mesa/drivers/common/meta_blit.c source file
("blitframebuffer_texture" function).


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


[Mesa-dev] [PATCH 4/8] glsl: Delete dead discard conditions in constant folding.

2015-02-24 Thread Kenneth Graunke
opt_constant_folding() already detects conditional assignments where the
condition is constant, and either deletes the assignment or the
condition.

Make it handle discards in the same fashion.

Spotted happening in the wild in Tropico 5 shaders.

Signed-off-by: Kenneth Graunke 
---
 src/glsl/opt_constant_folding.cpp | 24 
 1 file changed, 24 insertions(+)

diff --git a/src/glsl/opt_constant_folding.cpp 
b/src/glsl/opt_constant_folding.cpp
index 74b855e..4aae3f0 100644
--- a/src/glsl/opt_constant_folding.cpp
+++ b/src/glsl/opt_constant_folding.cpp
@@ -50,6 +50,7 @@ public:
   /* empty */
}
 
+   virtual ir_visitor_status visit_enter(ir_discard *ir);
virtual ir_visitor_status visit_enter(ir_assignment *ir);
virtual ir_visitor_status visit_enter(ir_call *ir);
 
@@ -94,6 +95,29 @@ ir_constant_folding_visitor::handle_rvalue(ir_rvalue 
**rvalue)
 }
 
 ir_visitor_status
+ir_constant_folding_visitor::visit_enter(ir_discard *ir)
+{
+   if (ir->condition) {
+  ir->condition->accept(this);
+  handle_rvalue(&ir->condition);
+
+  ir_constant *const_val = ir->condition->as_constant();
+  /* If the condition is constant, either remove the condition or
+   * remove the never-executed assignment.
+   */
+  if (const_val) {
+ if (const_val->value.b[0])
+ir->condition = NULL;
+ else
+ir->remove();
+ this->progress = true;
+  }
+   }
+
+   return visit_continue_with_parent;
+}
+
+ir_visitor_status
 ir_constant_folding_visitor::visit_enter(ir_assignment *ir)
 {
ir->rhs->accept(this);
-- 
2.2.2

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


Re: [Mesa-dev] [PATCH 8/8] i965: Remove redundant discard jumps.

2015-02-24 Thread Eric Anholt
Kenneth Graunke  writes:

> With the previous optimization in place, some shaders wind up with
> multiple discard jumps in a row, or jumps directly to the next
> instruction.  We can remove those.
>
> Without NIR on Haswell:
> total instructions in shared programs: 5777258 -> 5775872 (-0.02%)
> instructions in affected programs: 20312 -> 18926 (-6.82%)
> helped:716
>
> With NIR on Haswell:
> total instructions in shared programs: 5773163 -> 5771785 (-0.02%)
> instructions in affected programs: 21040 -> 19662 (-6.55%)
> helped:717
>
> v2: Use the CFG rather than the old instructions list.  Presumably
> the placeholder halt will be in the last basic block.
>
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 42 
> 
>  src/mesa/drivers/dri/i965/brw_fs.h   |  1 +
>  2 files changed, 43 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 9df1650..21e1e82 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -2558,6 +2558,47 @@ fs_visitor::opt_register_renaming()
> return progress;
>  }
>  
> +/**
> + * Remove redundant or useless discard jumps.
> + *
> + * For example, we can eliminate jumps in the following sequence:
> + *
> + * discard-jump   (redundant with the next jump)
> + * discard-jump   (useless; jumps to the next instruction)
> + * placeholder-halt
> + */
> +bool
> +fs_visitor::opt_redundant_discard_jumps()
> +{
> +   bool progress = false;
> +
> +   bblock_t *last_bblock = cfg->blocks[cfg->num_blocks - 1];
> +
> +   fs_inst *placeholder_halt = NULL;
> +   foreach_inst_in_block_reverse(fs_inst, inst, last_bblock) {
> +  if (inst->opcode == FS_OPCODE_PLACEHOLDER_HALT) {
> + placeholder_halt = inst;
> + break;
> +  }
> +   }
> +
> +   if (!placeholder_halt)
> +  return false;
> +
> +   /* Delete any HALTs immediately before the placeholder halt. */
> +   for (fs_inst *prev = (fs_inst *) placeholder_halt->prev;
> +prev->opcode == FS_OPCODE_DISCARD_JUMP;
> +prev = (fs_inst *) placeholder_halt->prev) {
> +  prev->remove(last_bblock);
> +  progress = true;
> +   }

My only question in this series was "what if the placeholder halt is the
first instruction in the block?"  Shouldn't you be checking for a start
sentinel?

Other than that, this series is:

Reviewed-by: Eric Anholt 

and I look forward to using the NIR intrinsic in my TGSI support.


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


[Mesa-dev] [PATCH] install-lib-links: remove the .install-lib-links file

2015-02-24 Thread Emil Velikov
With earlier commit (install-lib-links: don't depend on .libs directory)
we moved the location of the file from .libs/ to the current dir.
Although we did not attribute that in the former case autotools was
doing us a favour and removing the file. Explicitly remove the file at
clean-local time, otherwise we'll end up with dangling files.

Cc: "10.3 10.4 10.5" 
Cc: Matt Turner 
Cc: Lucas Stach 
Signed-off-by: Emil Velikov 
---
 install-lib-links.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/install-lib-links.mk b/install-lib-links.mk
index 3545b26..5fe9141 100644
--- a/install-lib-links.mk
+++ b/install-lib-links.mk
@@ -19,6 +19,7 @@ clean-local:
for f in $(notdir $(lib_LTLIBRARIES:%.la=.libs/%.$(LIB_EXT)*)); do \
$(RM) $(top_builddir)/$(LIB_DIR)/$$f;   \
done;
+   $(RM) .install-mesa-links
 
 endif
 endif
-- 
2.3.0

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


Re: [Mesa-dev] [PATCH] osmesa: Add gallium include dirs

2015-02-24 Thread Brian Paul

On 02/24/2015 12:36 AM, Martin Peres wrote:


On 23/02/15 17:51, Brian Paul wrote:

On 02/23/2015 01:31 AM, Martin Peres wrote:

Signed-off-by: Martin Peres 
---
  src/mesa/drivers/osmesa/Makefile.am | 2 ++
  src/mesa/drivers/osmesa/SConscript  | 2 ++
  2 files changed, 4 insertions(+)

diff --git a/src/mesa/drivers/osmesa/Makefile.am
b/src/mesa/drivers/osmesa/Makefile.am
index 589b5ee..590dd66 100644
--- a/src/mesa/drivers/osmesa/Makefile.am
+++ b/src/mesa/drivers/osmesa/Makefile.am
@@ -29,6 +29,8 @@ AM_CPPFLAGS = \
  -I$(top_srcdir)/src/mapi \
  -I$(top_builddir)/src/mapi \
  -I$(top_srcdir)/src/mesa/ \
+-I$(top_srcdir)/src/gallium/include \
+-I$(top_srcdir)/src/gallium/auxiliary \
  $(DEFINES)
  AM_CFLAGS = $(PTHREAD_CFLAGS) \
  $(VISIBILITY_CFLAGS)
diff --git a/src/mesa/drivers/osmesa/SConscript
b/src/mesa/drivers/osmesa/SConscript
index caa14d3..f836da5 100644
--- a/src/mesa/drivers/osmesa/SConscript
+++ b/src/mesa/drivers/osmesa/SConscript
@@ -6,6 +6,8 @@ env.Prepend(CPPPATH = [
  '#src',
  '#src/mapi',
  '#src/mesa',
+'#src/gallium/include',
+'#src/gallium/auxiliary',
  Dir('../../../mapi'), # src/mapi build path for
python-generated GL API files/headers
  ])




As with my patch for the xlib driver, I didn't have to change the
SConscript file.  osmesa was building fine as-is.  Did you test that?


I could not test it on windows (where it is mostly used, I presume) so I
did not try.


Scons works fine on Linux too.

-Brian


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


[Mesa-dev] [PATCH] st/omx/dec/h264: fix picture out-of-order with poc type 0 v2

2015-02-24 Thread Leo Liu
poc counter should be reset with IDR frame,
otherwise there would be a re-order issue with
frames before and after IDR

v2: add commit message

Signed-off-by: Leo Liu 
Reviewed-by: Christian König 
Cc: "10.4 10.5" 
---
 src/gallium/state_trackers/omx/vid_dec_h264.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/state_trackers/omx/vid_dec_h264.c 
b/src/gallium/state_trackers/omx/vid_dec_h264.c
index 7b57785..e01e873 100644
--- a/src/gallium/state_trackers/omx/vid_dec_h264.c
+++ b/src/gallium/state_trackers/omx/vid_dec_h264.c
@@ -706,6 +706,11 @@ static void slice_header(vid_dec_PrivateType *priv, struct 
vl_rbsp *rbsp,
   if (pic_order_cnt_lsb != priv->codec_data.h264.pic_order_cnt_lsb)
  vid_dec_h264_EndFrame(priv);
 
+  if (IdrPicFlag) {
+ priv->codec_data.h264.pic_order_cnt_msb = 0;
+ priv->codec_data.h264.pic_order_cnt_lsb = 0;
+  }
+
   if ((pic_order_cnt_lsb < priv->codec_data.h264.pic_order_cnt_lsb) &&
   (priv->codec_data.h264.pic_order_cnt_lsb - pic_order_cnt_lsb) >= 
(max_pic_order_cnt_lsb / 2))
  pic_order_cnt_msb = priv->codec_data.h264.pic_order_cnt_msb + 
max_pic_order_cnt_lsb;
-- 
2.1.0

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


Re: [Mesa-dev] [PATCH 1/2] gallium: include util/macros.h

2015-02-24 Thread Tobias Klausmann

On 24.02.2015 14:57, Mark Janes wrote:

Hi Tobias,

FYI, This commit failed build-test after it was pushed.


Whoops, did not build that driver, right! Sorry for that!


   Eric fixed it
up in 1d1e820.

-Mark


Thanks for the quick fix :)

Greetings,
Tobias



Tobias Klausmann  writes:


snip


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


Re: [Mesa-dev] [PATCH 7/8] glsl: Optimize "if (cond) discard; " to a conditional discard.

2015-02-24 Thread Jason Ekstrand
On Tue, Feb 24, 2015 at 2:19 AM, Kenneth Graunke 
wrote:

> st_glsl_to_tgsi and ir_to_mesa have handled conditional discards for a
> long time; the previous patch added that capability to i965.
>
> i965 (Haswell) shader-db stats:
>
> Without NIR:
> total instructions in shared programs: 5792133 -> 5776360 (-0.27%)
> instructions in affected programs: 737585 -> 721812 (-2.14%)
> helped:6300
> HURT:  68
> GAINED:2
>
> With NIR:
> total instructions in shared programs: 5787538 -> 5769569 (-0.31%)
> instructions in affected programs: 767843 -> 749874 (-2.34%)
> helped:6522
> HURT:  35
> GAINED:6
>

What all do you have in that branch?  Last I checked (10 minutes ago), NIR
wasn't beating GLSL IR yet.
--Jason


> Signed-off-by: Kenneth Graunke 
> ---
>  src/glsl/Makefile.sources|  1 +
>  src/glsl/glsl_parser_extras.cpp  |  1 +
>  src/glsl/ir_optimization.h   |  1 +
>  src/glsl/opt_conditional_discard.cpp | 81
> 
>  4 files changed, 84 insertions(+)
>  create mode 100644 src/glsl/opt_conditional_discard.cpp
>
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index d0210d1..b876642 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -157,6 +157,7 @@ LIBGLSL_FILES = \
> lower_ubo_reference.cpp \
> opt_algebraic.cpp \
> opt_array_splitting.cpp \
> +   opt_conditional_discard.cpp \
> opt_constant_folding.cpp \
> opt_constant_propagation.cpp \
> opt_constant_variable.cpp \
> diff --git a/src/glsl/glsl_parser_extras.cpp
> b/src/glsl/glsl_parser_extras.cpp
> index 9f79313..f19804b 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -1627,6 +1627,7 @@ do_common_optimization(exec_list *ir, bool linked,
> }
> progress = do_if_simplification(ir) || progress;
> progress = opt_flatten_nested_if_blocks(ir) || progress;
> +   progress = opt_conditional_discard(ir) || progress;
> progress = do_copy_propagation(ir) || progress;
> progress = do_copy_propagation_elements(ir) || progress;
>
> diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
> index 7eb861a..e6939f3 100644
> --- a/src/glsl/ir_optimization.h
> +++ b/src/glsl/ir_optimization.h
> @@ -77,6 +77,7 @@ bool do_common_optimization(exec_list *ir, bool linked,
>  bool do_rebalance_tree(exec_list *instructions);
>  bool do_algebraic(exec_list *instructions, bool native_integers,
>const struct gl_shader_compiler_options *options);
> +bool opt_conditional_discard(exec_list *instructions);
>  bool do_constant_folding(exec_list *instructions);
>  bool do_constant_variable(exec_list *instructions);
>  bool do_constant_variable_unlinked(exec_list *instructions);
> diff --git a/src/glsl/opt_conditional_discard.cpp
> b/src/glsl/opt_conditional_discard.cpp
> new file mode 100644
> index 000..0905188
> --- /dev/null
> +++ b/src/glsl/opt_conditional_discard.cpp
> @@ -0,0 +1,81 @@
> +/*
> + * Copyright © 2010 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the
> "Software"),
> + * to deal in the Software without restriction, including without
> limitation
> + * the rights to use, copy, modify, merge, publish, distribute,
> sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the
> next
> + * paragraph) shall be included in all copies or substantial portions of
> the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
> SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +/**
> + * \file opt_conditional_discard.cpp
> + *
> + * Replace
> + *
> + *if (cond) discard;
> + *
> + * with
> + *
> + *(discard )
> + */
> +
> +#include "glsl_types.h"
> +#include "ir.h"
> +
> +namespace {
> +
> +class opt_conditional_discard_visitor : public ir_hierarchical_visitor {
> +public:
> +   opt_conditional_discard_visitor()
> +   {
> +  progress = false;
> +   }
> +
> +   ir_visitor_status visit_leave(ir_if *);
> +
> +   bool progress;
> +};
> +
> +} /* anonymous namespace */
> +
> +bool
> +opt_conditional_disc

[Mesa-dev] Mesa 10.5.0 release candidate 2

2015-02-24 Thread Emil Velikov
Mesa 10.5.0 release candidate 2 is now available for testing. The
current plan is to have an additional release candidate every Friday
until the eventual 10.5.0 release on Mar 6th.

The tag in the git repository for Mesa 10.5.0-rc2 is 'mesa-10.5.0-rc2'.

Mesa 10.5.0 release candidate 2 is available for download from
ftp://freedesktop.org/pub/mesa/10.5.0/

sha256sums:

a4c152987462d0888c56c10fd6fb1d230fa658dd3208574c90af83603609d107  
mesa-10.5.0-rc2.tar.gz
313493fe5616815775b5a883c466fa101e6aa4bd1c5075a5027761a412445ba3  
mesa-10.5.0-rc2.tar.xz

Note the following are planned, permanent changes:
 - The tarball name has changed - s/MesaLib/mesa/
 - A tar.xz tarball is available.
 - The tar.bz2 and zip tarball have been depreciated and will no longer be
available.

If you have any comments and/or spot any problems with this release kindly
let me know.


-Emil

--

Changes from 10.5.0-rc1 to 10.5.0-rc2:

Alan Coopersmith (5):
  Bracket arguments to tr so they work with Solaris tr
  Remove extraneous ; after DECL_TYPE usage
  Avoid fighting with Solaris headers over isnormal()
  Use __typeof instead of typeof with Solaris Studio compilers
  Make _mesa_swizzle_and_convert argument types in .c match those in .h

Brian Paul (2):
  swrast: fix multiple color buffer writing
  st/mesa: fix sampler view reference counting bug in glDraw/CopyPixels

Carl Worth (1):
  Revert use of Mesa IR optimizer for ARB_fragment_programs

Eduardo Lima Mitev (1):
  mesa: Fix error validating args for TexSubImage3D

Emil Velikov (6):
  cherry-ignore: ignore commits picked without -x
  automake: Use AM_DISTCHECK_CONFIGURE_FLAGS
  auxiliary/vl: Build vl_winsys_dri.c only when needed.
  auxiliary/vl: honour the DRI2PROTO_CFLAGS
  install-lib-links: remove the .install-lib-links file
  Increment version to 10.5.0-rc2

Iago Toral Quiroga (2):
  mesa: Handle transferOps in texstore_rgba
  mesa: Fix element count for byte-swaps in texstore, readpix and 
texgetimage

Ilia Mirkin (3):
  nvc0: bail out of 2d blits with non-A8_UNORM alpha formats
  st/mesa: treat resource-less xfb buffers as if they weren't there
  nvc0: allow holes in xfb target lists

Kenneth Graunke (5):
  i965: Override swizzles for integer luminance formats.
  i965: Use a gl_color_union for sampler border color.
  i965: Fix integer border color on Haswell.
  glsl: Reduce memory consumption of copy propagation passes.
  i965: Prefer Meta over the BLT for BlitFramebuffer.

Laura Ekstrand (1):
  main: Fixed _mesa_GetCompressedTexImage_sw to copy slices correctly.

Lucas Stach (1):
  install-lib-links: don't depend on .libs directory

Marek Olšák (6):
  radeonsi: small fix in SPI state
  mesa: fix AtomicBuffer typo in _mesa_DeleteBuffers
  radeonsi: fix a crash if a stencil ref state is set before a DSA state
  radeonsi: don't use SQC_CACHES to flush ICACHE and KCACHE on SI
  vbo: fix an unitialized-variable warning
  radeonsi: fix point sprites

Matt Turner (6):
  i965/vec4/vp: Use vec4_visitor::CMP.
  i965/fs: Add unit tests for saturate propagation pass.
  i965/fs: Use fs_inst::overwrites_reg() in saturate propagation.
  i965/fs: Consider MOV.SAT to interfere if it has a source modifier.
  i965/vec4: Add and use byte-MOV instruction for unpack 4x8.
  i965: Link test programs with gtest before pthreads.

Michel Dänzer (1):
  Revert "radeon/llvm: enable unsafe math for graphics shaders"

Neil Roberts (1):
  meta: Fix saving the results of the current occlusion query

Tapani Pälli (1):
  mesa: fix OES_texture_float texture render target behavior

Vivek Kasireddy (1):
  egl, wayland: RGB565 format support on Back-buffer



signature.asc
Description: OpenPGP digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 04/14] meta: Create temporary pbo in _mesa_meta_pbo_GetTexSubImage()

2015-02-24 Thread Neil Roberts
Anuj Phogat  writes:

> using a flag passed in as function parameter. This will enable
> _mesa_meta_pbo_GetTexSubImage to be used for reading in to
> non-pbo buffers.
>
> This will be useful to support reading from YF/YS tiled surfaces
> in Skylake.
>
> Signed-off-by: Anuj Phogat 
> ---
>  src/mesa/drivers/common/meta.h   |  1 +
>  src/mesa/drivers/common/meta_tex_subimage.c  | 18 --
>  src/mesa/drivers/dri/i965/intel_pixel_read.c |  9 -
>  src/mesa/drivers/dri/i965/intel_tex_image.c  |  3 ++-
>  4 files changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
> index e7d894d..3de0d87 100644
> --- a/src/mesa/drivers/common/meta.h
> +++ b/src/mesa/drivers/common/meta.h
> @@ -542,6 +542,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> GLuint dims,
>int xoffset, int yoffset, int zoffset,
>int width, int height, int depth,
>GLenum format, GLenum type, const void *pixels,
> +  bool create_pbo,
>const struct gl_pixelstore_attrib *packing);
>  
>  extern void
> diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
> b/src/mesa/drivers/common/meta_tex_subimage.c
> index 68c8273..cd87a72 100644
> --- a/src/mesa/drivers/common/meta_tex_subimage.c
> +++ b/src/mesa/drivers/common/meta_tex_subimage.c
> @@ -34,6 +34,7 @@
>  #include "macros.h"
>  #include "meta.h"
>  #include "pbo.h"
> +#include "readpix.h"
>  #include "shaderapi.h"
>  #include "state.h"
>  #include "teximage.h"
> @@ -246,6 +247,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> GLuint dims,
>int xoffset, int yoffset, int zoffset,
>int width, int height, int depth,
>GLenum format, GLenum type, const void *pixels,
> +  bool create_pbo,
>const struct gl_pixelstore_attrib *packing)
>  {
> GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 };
> @@ -257,7 +259,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> GLuint dims,
> /* XXX: This should probably be passed in from somewhere */
> const char *where = "_mesa_meta_pbo_GetTexSubImage";
>  
> -   if (!_mesa_is_bufferobj(packing->BufferObj))
> +   if (!_mesa_is_bufferobj(packing->BufferObj) && !create_pbo)
>return false;
>  
> if (format == GL_DEPTH_COMPONENT ||
> @@ -282,7 +284,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> GLuint dims,
>return true;
> }
>  
> -   pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER,
> +   pbo_tex_image = create_texture_for_pbo(ctx, create_pbo, 
> GL_PIXEL_PACK_BUFFER,
>width, height, depth,
>format, type, pixels, packing,
>&pbo, &pbo_tex);
> @@ -348,6 +350,18 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> GLuint dims,
>   GL_COLOR_BUFFER_BIT, GL_NEAREST);
> }
>  
> +   /* If we created a temporary pbo in meta to read the pixel data, that
> +* data will now get copied to memory allocated by client.
> +*/
> +   if (create_pbo) {

I think this should be changed to something like the below:

 if (create_pbo && !_mesa_is_bufferobj(packing->BufferObj))

It looks like the meaning of create_pbo in create_texture_for_pbo is
‘create pbo unless there is already a pbo’. With this patch
_mesa_meta_pbo_GetTexSubImage seems to interpret it to mean that it will
always create the pbo and if there already was a pbo it would end up
clobbering the state.

> +  /* Unbind the pbo from pack binding. */
> +  _mesa_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);

I don't think this unbind is necessary. create_texture_for_pbo is
careful not to modify the PBO binding state and once that function is
finished the PBO is only accessed via the texture so we shouldn't need
to touch the PBO binding.

> +  _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[1]);
> +  _mesa_update_state(ctx);
> +  _mesa_readpixels(ctx, 0, 0, width, height, format, type,
> +   packing, (void *) pixels);

Doesn't this only read the last slice of the texture? Maybe this patch
should wait until this patch from Laura Ekstrand is landed:

http://lists.freedesktop.org/archives/mesa-dev/2015-February/077487.html

Regards,
- Neil


pgpaogQNb9zCf.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 10/14] i965: Make a function to check the conditions to use the blitter

2015-02-24 Thread Neil Roberts
Anuj Phogat  writes:

> No functional changes in the patch. Just makes the code look cleaner.
>
> Signed-off-by: Anuj Phogat 
> ---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 40 
> +++
>  1 file changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index abf20c9..147097b 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -2305,6 +2305,34 @@ can_blit_slice(struct intel_mipmap_tree *mt,
> return true;
>  }
>  
> +static bool
> +use_intel_mipree_map_blit(struct brw_context *brw,
> +  struct intel_mipmap_tree *mt,
> +  GLbitfield mode,
> +  unsigned int level,
> +  unsigned int slice)
> +{
> +   if (brw->has_llc &&
> +  /* It's probably not worth swapping to the blit ring because of
> +   * all the overhead involved.
> +   */
> +   !(mode & GL_MAP_WRITE_BIT) &&
> +   !mt->compressed &&
> +   (mt->tiling == I915_TILING_X ||
> +   /* Prior to Sandybridge, the blitter can't handle Y tiling */
> +   (brw->gen >= 6 && mt->tiling == I915_TILING_Y)) &&

This line used to have an extra space of indentation in the old version
which made it clearer that it is inside the brackets above. I think the
space should be added back here.

The patch is an improvement so I think it's worth landing but I wonder
if now that's in a separate function it might be worth tidying it up a
bit to make the logic easier to follow.

Either way, if the space is added back then it is

Reviewed-by: Neil Roberts 

Regards,
- Neil


pgpJNvsWcsFNX.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 12/14] meta: Return if pixels == null and no pixel unpack buffer set

2015-02-24 Thread Neil Roberts
It seems like it would be better to fold this into patch 4 because it
is fixing a problem that is effectively introduced by that patch,
isn't it?

Regards,
- Neil


pgphPhjb7Gl0I.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 01/14] meta: Remove duplicate power of two samples check

2015-02-24 Thread Neil Roberts
All of these patches except 4, 10 and 12 look good to me and are:

Reviewed-by: Neil Roberts 

However, I'm still relatively new to this so maybe my review should be
taken with a pinch of salt.

I've replied with comments for the three patches mentioned.

Regards,
- Neil


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


Re: [Mesa-dev] [PATCH 1/8] glsl: Make ir_validate check the type of ir_discard::condition.

2015-02-24 Thread Matt Turner
On Tue, Feb 24, 2015 at 2:19 AM, Kenneth Graunke  wrote:
> Copy and pasted from the ir_if::condition handling, plus a NULL check.
>
> Signed-off-by: Kenneth Graunke 
> ---

There's just a single comment on the last patch, but with that the
series is R-b me and Eric

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

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


Re: [Mesa-dev] [PATCH 8/8] i965: Remove redundant discard jumps.

2015-02-24 Thread Matt Turner
On Tue, Feb 24, 2015 at 2:19 AM, Kenneth Graunke  wrote:
> With the previous optimization in place, some shaders wind up with
> multiple discard jumps in a row, or jumps directly to the next
> instruction.  We can remove those.
>
> Without NIR on Haswell:
> total instructions in shared programs: 5777258 -> 5775872 (-0.02%)
> instructions in affected programs: 20312 -> 18926 (-6.82%)
> helped:716
>
> With NIR on Haswell:
> total instructions in shared programs: 5773163 -> 5771785 (-0.02%)
> instructions in affected programs: 21040 -> 19662 (-6.55%)
> helped:717
>
> v2: Use the CFG rather than the old instructions list.  Presumably
> the placeholder halt will be in the last basic block.
>
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 42 
> 
>  src/mesa/drivers/dri/i965/brw_fs.h   |  1 +
>  2 files changed, 43 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 9df1650..21e1e82 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -2558,6 +2558,47 @@ fs_visitor::opt_register_renaming()
> return progress;
>  }
>
> +/**
> + * Remove redundant or useless discard jumps.
> + *
> + * For example, we can eliminate jumps in the following sequence:
> + *
> + * discard-jump   (redundant with the next jump)
> + * discard-jump   (useless; jumps to the next instruction)
> + * placeholder-halt
> + */
> +bool
> +fs_visitor::opt_redundant_discard_jumps()
> +{
> +   bool progress = false;
> +
> +   bblock_t *last_bblock = cfg->blocks[cfg->num_blocks - 1];
> +
> +   fs_inst *placeholder_halt = NULL;
> +   foreach_inst_in_block_reverse(fs_inst, inst, last_bblock) {
> +  if (inst->opcode == FS_OPCODE_PLACEHOLDER_HALT) {
> + placeholder_halt = inst;
> + break;
> +  }
> +   }
> +
> +   if (!placeholder_halt)
> +  return false;
> +
> +   /* Delete any HALTs immediately before the placeholder halt. */
> +   for (fs_inst *prev = (fs_inst *) placeholder_halt->prev;
> +prev->opcode == FS_OPCODE_DISCARD_JUMP;
> +prev = (fs_inst *) placeholder_halt->prev) {
> +  prev->remove(last_bblock);
> +  progress = true;

I've read this code about four times and finally gotten what's going
on. We're not really iterating over the instructions and removing
them, we're just always deleting the one immediately previous the
placeholder halt while it's a discard jump. Tricky, but cool.

Yeah, seems like Eric's comment is valid -- should probably add a
!prev->is_head_sentinel() && to the condition.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/12] mesa: replace FREXPF, LDEXPF with frexpf, ldexpf

2015-02-24 Thread Brian Paul
Start getting rid of some imports.h macros.  Use the c99 functions instead.
---
 include/c99_math.h  | 11 +++
 src/mesa/main/imports.h |  6 --
 src/mesa/math/m_debug_util.h|  9 ++---
 src/mesa/program/prog_execute.c |  5 +++--
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/include/c99_math.h b/include/c99_math.h
index 6680f54..e60e7d3 100644
--- a/include/c99_math.h
+++ b/include/c99_math.h
@@ -82,6 +82,17 @@ static inline float logf( float f )
return (float) log( (double) f );
 }
 
+static inline float frexpf(float x, float y)
+{
+   return (float) frexp(x, y);
+}
+
+static inline float ldexpf(float x, int exp)
+{
+   return (float) ldexp(x, exp);
+}
+
+
 #else
 /* Work-around an extra semi-colon in VS 2005 logf definition */
 #ifdef logf
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 0fcba4f..cb87148 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -209,8 +209,6 @@ static inline GLfloat LOG2(GLfloat x)
  *** FABSF: absolute value of float
  *** LOGF: the natural logarithm (base e) of the value
  *** EXPF: raise e to the value
- *** LDEXPF: multiply value by an integral power of two
- *** FREXPF: extract mantissa and exponent from value
  ***/
 #if defined(__gnu_linux__)
 /* C99 functions */
@@ -219,16 +217,12 @@ static inline GLfloat LOG2(GLfloat x)
 #define FABSF(x)   fabsf(x)
 #define LOGF(x)logf(x)
 #define EXPF(x)expf(x)
-#define LDEXPF(x,y)  ldexpf(x,y)
-#define FREXPF(x,y)  frexpf(x,y)
 #else
 #define CEILF(x)   ((GLfloat) ceil(x))
 #define FLOORF(x)  ((GLfloat) floor(x))
 #define FABSF(x)   ((GLfloat) fabs(x))
 #define LOGF(x)((GLfloat) log(x))
 #define EXPF(x)((GLfloat) exp(x))
-#define LDEXPF(x,y)  ((GLfloat) ldexp(x,y))
-#define FREXPF(x,y)  ((GLfloat) frexp(x,y))
 #endif
 
 
diff --git a/src/mesa/math/m_debug_util.h b/src/mesa/math/m_debug_util.h
index d05da89..25ee029 100644
--- a/src/mesa/math/m_debug_util.h
+++ b/src/mesa/math/m_debug_util.h
@@ -32,6 +32,9 @@
 #ifdef DEBUG_MATH  /* This code only used for debugging */
 
 
+#include "c99_math.h"
+
+
 /* Comment this out to deactivate the cycle counter.
  * NOTE: it works only on CPUs which know the 'rdtsc' command (586 or higher)
  * (hope, you don't try to debug Mesa on a 386 ;)
@@ -286,9 +289,9 @@ static int significand_match( GLfloat a, GLfloat b )
   return 0;
}
 
-   FREXPF( a, &a_ex );
-   FREXPF( b, &b_ex );
-   FREXPF( d, &d_ex );
+   frexpf( a, &a_ex );
+   frexpf( b, &b_ex );
+   frexpf( d, &d_ex );
 
if ( a_ex < b_ex ) {
   return a_ex - d_ex;
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index 8f83c31..05c5f29 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -35,6 +35,7 @@
  */
 
 
+#include "c99_math.h"
 #include "main/glheader.h"
 #include "main/colormac.h"
 #include "main/macros.h"
@@ -718,7 +719,7 @@ _mesa_execute_program(struct gl_context * ctx,
q[2] = 0.0F;
 }
 else {
-   q[0] = LDEXPF(1.0, (int) floor_t0);
+   q[0] = ldexpf(1.0, (int) floor_t0);
/* Note: GL_NV_vertex_program expects 
 * result.z = result.x * APPX(result.y)
 * We do what the ARB extension says.
@@ -884,7 +885,7 @@ _mesa_execute_program(struct gl_context * ctx,
}
else {
   int exponent;
-  GLfloat mantissa = FREXPF(t[0], &exponent);
+  GLfloat mantissa = frexpf(t[0], &exponent);
   q[0] = (GLfloat) (exponent - 1);
   q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) 
*/
 
-- 
1.9.1

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


[Mesa-dev] [PATCH 12/12] mesa: remove INV_SQRTF() macro

2015-02-24 Thread Brian Paul
---
 src/mesa/main/imports.h | 9 -
 src/mesa/main/light.c   | 4 ++--
 src/mesa/main/macros.h  | 2 +-
 src/mesa/math/m_debug_norm.c| 5 +++--
 src/mesa/math/m_norm_tmp.h  | 6 +++---
 src/mesa/math/m_xform.c | 1 +
 src/mesa/program/prog_execute.c | 2 +-
 src/mesa/tnl/t_rasterpos.c  | 2 +-
 src/mesa/tnl/t_vb_points.c  | 2 +-
 src/mesa/tnl/t_vb_texgen.c  | 4 ++--
 10 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index da373b0..df6a3fe 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -119,15 +119,6 @@ static inline int isblank(int ch) { return ch == ' ' || ch 
== '\t'; }
 #endif
 
 
-/** single-precision inverse square root */
-static inline float
-INV_SQRTF(float x)
-{
-   /* XXX we could try Quake's fast inverse square root function here */
-   return 1.0F / sqrtf(x);
-}
-
-
 /***
  *** LOG2: Log base 2 of float
  ***/
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 9db0bff..c4d3a53 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1026,9 +1026,9 @@ update_modelview_scale( struct gl_context *ctx )
   GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
   if (f < 1e-12) f = 1.0;
   if (ctx->_NeedEyeCoords)
-ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f);
+ctx->_ModelViewInvScale = 1.0f / sqrtf(f);
   else
-ctx->_ModelViewInvScale = (GLfloat) sqrtf(f);
+ctx->_ModelViewInvScale = sqrtf(f);
}
 }
 
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 11e3b2a..470d396 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -775,7 +775,7 @@ NORMALIZE_3FV(GLfloat v[3])
 {
GLfloat len = (GLfloat) LEN_SQUARED_3FV(v);
if (len) {
-  len = INV_SQRTF(len);
+  len = 1.0f / sqrtf(len);
   v[0] *= len;
   v[1] *= len;
   v[2] *= len;
diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
index 00e72be..197b43c 100644
--- a/src/mesa/math/m_debug_norm.c
+++ b/src/mesa/math/m_debug_norm.c
@@ -26,6 +26,7 @@
  *Gareth Hughes
  */
 
+#include "c99_math.h"
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/macros.h"
@@ -165,7 +166,7 @@ static void ref_norm_transform_normalize( const GLmatrix 
*mat,
/* Hmmm, don't know how we could test the precalculated
 * length case...
 */
-scale = INV_SQRTF( len );
+scale = 1.0f / sqrtf(len);
SCALE_SCALAR_3V( out[i], scale, t );
  } else {
 out[i][0] = out[i][1] = out[i][2] = 0;
@@ -241,7 +242,7 @@ static int test_norm_function( normal_func func, int mtype, 
long *cycles )
   ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
   for ( j = 0 ; j < 3 ; j++ )
  s[i][j] = rnd();
-  length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
+  length[i] = 1.0f / sqrtf( LEN_SQUARED_3FV( s[i] ) );
}
 
source->data = (GLfloat(*)[4]) s;
diff --git a/src/mesa/math/m_norm_tmp.h b/src/mesa/math/m_norm_tmp.h
index 339c03f..c8fab0e 100644
--- a/src/mesa/math/m_norm_tmp.h
+++ b/src/mesa/math/m_norm_tmp.h
@@ -68,7 +68,7 @@ TAG(transform_normalize_normals)( const GLmatrix *mat,
 {
GLdouble len = tx*tx + ty*ty + tz*tz;
if (len > 1e-20) {
-  GLfloat scale = INV_SQRTF(len);
+  GLfloat scale = 1.0f / sqrtf(len);
   out[i][0] = tx * scale;
   out[i][1] = ty * scale;
   out[i][2] = tz * scale;
@@ -135,7 +135,7 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix 
*mat,
 {
GLdouble len = tx*tx + ty*ty + tz*tz;
if (len > 1e-20) {
-  GLfloat scale = INV_SQRTF(len);
+  GLfloat scale = 1.0f / sqrtf(len);
   out[i][0] = tx * scale;
   out[i][1] = ty * scale;
   out[i][2] = tz * scale;
@@ -322,7 +322,7 @@ TAG(normalize_normals)( const GLmatrix *mat,
 const GLfloat x = from[0], y = from[1], z = from[2];
 GLdouble len = x * x + y * y + z * z;
 if (len > 1e-50) {
-   len = INV_SQRTF(len);
+   len = 1.0f / sqrtf(len);
out[i][0] = (GLfloat)(x * len);
out[i][1] = (GLfloat)(y * len);
out[i][2] = (GLfloat)(z * len);
diff --git a/src/mesa/math/m_xform.c b/src/mesa/math/m_xform.c
index 14d1c64..718ad49 100644
--- a/src/mesa/math/m_xform.c
+++ b/src/mesa/math/m_xform.c
@@ -33,6 +33,7 @@
  * 3. Transformation of a point p by a matrix M is: p' = M * p
  */
 
+#include "c99_math.h"
 #include "main/glheader.h"
 #include "main/macros.h"
 
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index de3a53b..ac81332 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -1085,7 +1085,7 @@ _mesa_execute_program(struct gl_context * ctx,
 GLfloat a[4], result[4];
 fetch_vector1(&ins

[Mesa-dev] [PATCH 05/12] mesa: replace FABSF with fabsf

2015-02-24 Thread Brian Paul
---
 src/mesa/drivers/dri/radeon/radeon_fog.c |  3 ++-
 src/mesa/main/imports.h  | 11 ---
 src/mesa/math/m_matrix.c | 17 +
 src/mesa/program/prog_execute.c  | 30 +++---
 src/mesa/swrast/s_fog.c  |  4 ++--
 src/mesa/swrast/s_span.c |  9 +
 src/mesa/swrast/s_texfilter.c| 15 ---
 src/mesa/swrast_setup/ss_triangle.c  |  1 +
 src/mesa/swrast_setup/ss_tritmp.h|  4 ++--
 src/mesa/tnl/t_vb_fog.c  |  4 ++--
 src/mesa/tnl/t_vb_points.c   |  3 ++-
 11 files changed, 48 insertions(+), 53 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_fog.c 
b/src/mesa/drivers/dri/radeon/radeon_fog.c
index df95575..d5c6537 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fog.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fog.c
@@ -32,6 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
  *   Keith Whitwell 
  */
 
+#include "c99_math.h"
 #include "main/glheader.h"
 #include "main/imports.h"
 #include "main/context.h"
@@ -97,7 +98,7 @@ radeonComputeFogBlendFactor( struct gl_context *ctx, GLfloat 
fogcoord )
 {
GLfloat end  = ctx->Fog.End;
GLfloat d, temp;
-   const GLfloat z = FABSF(fogcoord);
+   const GLfloat z = fabsf(fogcoord);
 
switch (ctx->Fog.Mode) {
case GL_LINEAR:
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 9dee565..3384583 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -203,17 +203,6 @@ static inline GLfloat LOG2(GLfloat x)
 #endif
 
 
-/***
- *** FABSF: absolute value of float
- ***/
-#if defined(__gnu_linux__)
-/* C99 functions */
-#define FABSF(x)   fabsf(x)
-#else
-#define FABSF(x)   ((GLfloat) fabs(x))
-#endif
-
-
 /**
  * Convert float to int by rounding to nearest integer, away from zero.
  */
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index 9c9310d..9d51021 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -34,6 +34,7 @@
  */
 
 
+#include "c99_math.h"
 #include "main/glheader.h"
 #include "main/imports.h"
 #include "main/macros.h"
@@ -376,9 +377,9 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
 
/* choose pivot - or die */
-   if (FABSF(r3[0])>FABSF(r2[0])) SWAP_ROWS(r3, r2);
-   if (FABSF(r2[0])>FABSF(r1[0])) SWAP_ROWS(r2, r1);
-   if (FABSF(r1[0])>FABSF(r0[0])) SWAP_ROWS(r1, r0);
+   if (fabsf(r3[0])>fabsf(r2[0])) SWAP_ROWS(r3, r2);
+   if (fabsf(r2[0])>fabsf(r1[0])) SWAP_ROWS(r2, r1);
+   if (fabsf(r1[0])>fabsf(r0[0])) SWAP_ROWS(r1, r0);
if (0.0 == r0[0])  return GL_FALSE;
 
/* eliminate first variable */
@@ -396,8 +397,8 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
 
/* choose pivot - or die */
-   if (FABSF(r3[1])>FABSF(r2[1])) SWAP_ROWS(r3, r2);
-   if (FABSF(r2[1])>FABSF(r1[1])) SWAP_ROWS(r2, r1);
+   if (fabsf(r3[1])>fabsf(r2[1])) SWAP_ROWS(r3, r2);
+   if (fabsf(r2[1])>fabsf(r1[1])) SWAP_ROWS(r2, r1);
if (0.0 == r1[1])  return GL_FALSE;
 
/* eliminate second variable */
@@ -410,7 +411,7 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
 
/* choose pivot - or die */
-   if (FABSF(r3[2])>FABSF(r2[2])) SWAP_ROWS(r3, r2);
+   if (fabsf(r3[2])>fabsf(r2[2])) SWAP_ROWS(r3, r2);
if (0.0 == r2[2])  return GL_FALSE;
 
/* eliminate third variable */
@@ -508,7 +509,7 @@ static GLboolean invert_matrix_3d_general( GLmatrix *mat )
 
det = pos + neg;
 
-   if (FABSF(det) < 1e-25)
+   if (fabsf(det) < 1e-25)
   return GL_FALSE;
 
det = 1.0F / det;
@@ -1069,7 +1070,7 @@ _math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, 
GLfloat z )
m[2] *= x;   m[6] *= y;   m[10] *= z;
m[3] *= x;   m[7] *= y;   m[11] *= z;
 
-   if (FABSF(x - y) < 1e-8 && FABSF(x - z) < 1e-8)
+   if (fabsf(x - y) < 1e-8 && fabsf(x - z) < 1e-8)
   mat->flags |= MAT_FLAG_UNIFORM_SCALE;
else
   mat->flags |= MAT_FLAG_GENERAL_SCALE;
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index 8ae015f..de3a53b 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -202,10 +202,10 @@ fetch_vector4(const struct prog_src_register *source,
}
 
if (source->Abs) {
-  result[0] = FABSF(result[0]);
-  result[1] = FABSF(result[1]);
-  result[2] = FABSF(result[2]);
-  result[3] = FABSF(result[3]);
+  result[0] = fabsf(result[0]);
+  result[1] = fabsf(result[1]);
+  result[2] = fabsf(result[2]);
+  result[3] = fabsf(result[3]);
}
if (source->Negate) {
   assert(source->Negate == NEGATE_XYZW);
@@ -260,10 +260,10 @@ fetch_vector4_deriv(struct gl_context * ctx,
   result[3] = deriv[GET_SWZ(source->Swizzle, 3)];
   
 

[Mesa-dev] [PATCH] st/mesa: remove struct qualifier from st_src_reg parameter

2015-02-24 Thread Brian Paul
It's a class.  Silences MSVC warning.
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 50a810c..b305507 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4659,7 +4659,7 @@ dst_register(struct st_translate *t,
  * Map a glsl_to_tgsi src register to a TGSI ureg_src register.
  */
 static struct ureg_src
-src_register(struct st_translate *t, const struct st_src_reg *reg)
+src_register(struct st_translate *t, const st_src_reg *reg)
 {
switch(reg->file) {
case PROGRAM_UNDEFINED:
-- 
1.9.1

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


Re: [Mesa-dev] glCompressedTex(Sub)Image(2,3) on mapped PBOs

2015-02-24 Thread Eduardo Lima Mitev
On 02/20/2015 08:12 PM, Ian Romanick wrote:
> On 02/20/2015 08:13 AM, Eduardo Lima Mitev wrote:
>>
>> In the spec GLES 3.1 spec, page 57, there is this: (and similar wording
>> in GL 4.5 spec, page 76)
>>
>> "6.3.2 Effects of Mapping Buffers on Other GL Commands
>>
>> "Any GL command which attempts to read from, write to, or change the
>> state of a buffer object may generate an INVALID_OPERATION error if all
>> or part of the buffer object is mapped. However, only commands which
>> explicitly describe this error are required to do so. If an error is not
>> generated, using such commands to perform invalid reads, writes, or
>> state changes will have undefined results and may result in GL
>> interruption or termination."
> 
> This language is intentionally loose.  It is often perfectly safe to
> have a portion of a buffer mapped while a GL command operates on a
> different part of the buffer.  Determining whether a particular
> operation is safe can be expensive.  Imagine trying to determine whether
> a glDrawElements command will source data from a mapped region of a
> vertex buffer object.  Many vendors objected to having to put expensive
> (or cheap) checks in performance critical paths.
> 
> I don't think an of the TexSubImage commands are performance critical
> enough to warrant excluding the test.  I believe some benchmarks use
> some of the TexSubImage commands, so it's probably worth measuring them
> on, say, Baytrail with and without the checks.  My expectation is that
> there's enough CPU wasted in those paths that the checks will be lost in
> the noise.  We won't know until we measure.
> 
>> There is no further restriction in gl(Compressed)Tex(Sub)Image(2,3)D
>> that makes throwing an error mandatory, hence I suspect these tests
>> might be wrong.
> 
> I'm also inclined to think they are wrong... or at least overly strict.
> 
> Do you know of any commands that require this error be generated?
> 

In GLES 3.1, there is explicit mention to this error for
glBufferSubData, glCopyBufferSubData at least. Similar for GL 4.5 but
only if the buffer was not mapped with the MAP_PERSISTENT_BIT set:

"An INVALID_OPERATION error is generated if the source buffer
 object is currently mapped, unless it was mapped with
 MAP_PERSISTENT_BIT set in the Map*BufferRange access flags."

>>
>> Also, shouldn't this restriction be moved to common API entry points, or
>> are there drivers that do write to PBOs while they are mapped?
> 
> Looking at that function, I find it odd that either of the errors it
> generates are generated there.  We should either do these checks in a
> single, common place, or we should not do them at all.
> 

From yours and Jason's comments, it looks like we should at least move
those checks out of the driver's code.

Regarding the checks for overlapping, it seems doable but I wonder if
that effort pays off. Even if we manage to implement it with negligible
or none overhead, how many applications will actually use that? Right
now these potential applications have to unmap the buffer, so it will
require changing the code, re-building, etc. I guess it will all depend
on the performance gain from operating in several parts of a buffer in
parallel versus doing it synchronously.

So, what I propose:

1) We write a patch to move the checks to API entry points (I have that
partially done already), and remove current checks in the driver. It
would be done for both compressed and non-compressed Tex(Sub)Image APIs.

2) We implement the checks for buffer overlapping as a 2nd step, if we
decide is worth.

For 1) I can provide a patch this week, perhaps coordinating with Jason
since he already gave it a thought. For 2) I could use some help.

cheers,
Eduardo

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


Re: [Mesa-dev] [PATCH 01/12] mesa: replace FREXPF, LDEXPF with frexpf, ldexpf

2015-02-24 Thread Matt Turner
On Tue, Feb 24, 2015 at 8:57 AM, Brian Paul  wrote:
> Start getting rid of some imports.h macros.  Use the c99 functions instead.
> ---
>  include/c99_math.h  | 11 +++
>  src/mesa/main/imports.h |  6 --
>  src/mesa/math/m_debug_util.h|  9 ++---
>  src/mesa/program/prog_execute.c |  5 +++--
>  4 files changed, 20 insertions(+), 11 deletions(-)
>
> diff --git a/include/c99_math.h b/include/c99_math.h
> index 6680f54..e60e7d3 100644
> --- a/include/c99_math.h
> +++ b/include/c99_math.h
> @@ -82,6 +82,17 @@ static inline float logf( float f )
> return (float) log( (double) f );
>  }
>
> +static inline float frexpf(float x, float y)
> +{
> +   return (float) frexp(x, y);

frexp takes a pointer as the second argument. I'd have to think more
about frexp and ldexp to make myself sure that passing floats to the
double function actually give the results you'd get from frexpf... but
I guess that'd work?

Similar concerns about ldexp, but I guess we've been doing it for years.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/12] mesa: replace FREXPF, LDEXPF with frexpf, ldexpf

2015-02-24 Thread Brian Paul

On 02/24/2015 10:17 AM, Matt Turner wrote:

On Tue, Feb 24, 2015 at 8:57 AM, Brian Paul  wrote:

Start getting rid of some imports.h macros.  Use the c99 functions instead.
---
  include/c99_math.h  | 11 +++
  src/mesa/main/imports.h |  6 --
  src/mesa/math/m_debug_util.h|  9 ++---
  src/mesa/program/prog_execute.c |  5 +++--
  4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/include/c99_math.h b/include/c99_math.h
index 6680f54..e60e7d3 100644
--- a/include/c99_math.h
+++ b/include/c99_math.h
@@ -82,6 +82,17 @@ static inline float logf( float f )
 return (float) log( (double) f );
  }

+static inline float frexpf(float x, float y)
+{
+   return (float) frexp(x, y);


frexp takes a pointer as the second argument.


Hmm, I didn't see an error on the MSVC build.  I'll fix it though.



I'd have to think more
about frexp and ldexp to make myself sure that passing floats to the
double function actually give the results you'd get from frexpf... but
I guess that'd work?

Similar concerns about ldexp, but I guess we've been doing it for years.


Yeah, should be no functional change.

-Brian

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


Re: [Mesa-dev] [PATCH 01/12] mesa: replace FREXPF, LDEXPF with frexpf, ldexpf

2015-02-24 Thread Brian Paul

On 02/24/2015 10:25 AM, Matt Turner wrote:

On Tue, Feb 24, 2015 at 8:57 AM, Brian Paul  wrote:

Start getting rid of some imports.h macros.  Use the c99 functions instead.
---


Thanks a bunch, Brian! The C99 platforms thank you :)

I expected this patch, or an additional one that removed the last
macro from the "Work-arounds for platforms that lack C99 math
functions" of imports.h (sqrtf).


Yeah, there's more to do.  Not sure if I'll get to it today.



I had one comment on 1/12 that's easily addressed. With that fixed,
the whole series is

Reviewed-by: Matt Turner 



Thanks.

-Brian

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


[Mesa-dev] [PATCH 0/9] Another series fixing dEQP failing tests

2015-02-24 Thread Eduardo Lima Mitev
Hello,

This is another set of patches fixing 274 dEQP failing tests from the GLES3 
module.
Patches were written against Mesa 10.4.4 and were tested on i965. No piglit 
regressions observed.

There is a git tree with this series rebased against current master to ease 
bulk testing:

https://github.com/Igalia/mesa/commits/deqp-fixes-batch5-rebased

cheers,
Eduardo

Iago Toral Quiroga (5):
  i965: Fix textureGrad with cube samplers
  glsl: Add variables to symbol table also for single declarations
  glsl: Add function parameter declarations to the symbol table
  i965/blorp: Improve precission of blitting coordinates when clipping
  mesa: Fix GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE for default
framebuffer.

Samuel Iglesias Gonsalvez (4):
  glsl: don't lower fragdata array if the output data types don't match
  mesa: fix deletion of inactive bound transform feedback object
  glsl: mark named uniform block arrays as active if defined with shared
or std140 layout qualifier
  glsl: optimize (0 cmp x + y) into (-x cmp y).

 src/glsl/glsl_parser.yy|   8 +
 src/glsl/link_uniform_blocks.cpp   |  26 +++
 src/glsl/opt_algebraic.cpp |  15 +-
 src/glsl/opt_dead_builtin_varyings.cpp |  10 +
 .../dri/i965/brw_lower_texture_gradients.cpp   |  26 ++-
 src/mesa/drivers/dri/i965/brw_meta_util.c  | 224 +++--
 src/mesa/main/fbobject.c   |  11 +-
 src/mesa/main/transformfeedback.c  |  13 +-
 8 files changed, 259 insertions(+), 74 deletions(-)

-- 
2.1.3

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


[Mesa-dev] [PATCH 3/9] glsl: Add variables to symbol table also for single declarations

2015-02-24 Thread Eduardo Lima Mitev
From: Iago Toral Quiroga 

We were doing this for all variables in a declaration list, but not
when there was just a single declaration. As a consequence, when we
used a single variable declaration to redeclare a type that existed
in a previous scope we would get a parsing error, so this would work:

struct S { int val; };
void main()
{
   int Z, S;
   S = 1;
}

but this wouldn't:

struct S { int val; };
void main()
{
   int S;
   S = 1;
}

Fixes the following 4 dEQP tests:
dEQP-GLES3.functional.shaders.scoping.valid.local_int_variable_hides_struct_type_vertex
dEQP-GLES3.functional.shaders.scoping.valid.local_int_variable_hides_struct_type_fragment
dEQP-GLES3.functional.shaders.scoping.valid.local_struct_variable_hides_struct_type_vertex
dEQP-GLES3.functional.shaders.scoping.valid.local_struct_variable_hides_struct_type_fragment
---
 src/glsl/glsl_parser.yy | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 7fb8c38..17422ed 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1070,6 +1070,7 @@ single_declaration:
   $$ = new(ctx) ast_declarator_list($1);
   $$->set_location_range(@1, @2);
   $$->declarations.push_tail(&decl->link);
+  state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
}
| fully_specified_type any_identifier array_specifier
{
@@ -1080,6 +1081,7 @@ single_declaration:
   $$ = new(ctx) ast_declarator_list($1);
   $$->set_location_range(@1, @3);
   $$->declarations.push_tail(&decl->link);
+  state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
}
| fully_specified_type any_identifier array_specifier '=' initializer
{
@@ -1090,6 +1092,7 @@ single_declaration:
   $$ = new(ctx) ast_declarator_list($1);
   $$->set_location_range(@1, @3);
   $$->declarations.push_tail(&decl->link);
+  state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
}
| fully_specified_type any_identifier '=' initializer
{
@@ -1100,6 +1103,7 @@ single_declaration:
   $$ = new(ctx) ast_declarator_list($1);
   $$->set_location_range(@1, @2);
   $$->declarations.push_tail(&decl->link);
+  state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
}
| INVARIANT variable_identifier
{
@@ -1112,6 +1116,7 @@ single_declaration:
   $$->invariant = true;
 
   $$->declarations.push_tail(&decl->link);
+  state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
}
| PRECISE variable_identifier
{
@@ -1124,6 +1129,7 @@ single_declaration:
   $$->precise = true;
 
   $$->declarations.push_tail(&decl->link);
+  state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
}
;
 
-- 
2.1.3

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


[Mesa-dev] [PATCH 8/9] mesa: Fix GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE for default framebuffer.

2015-02-24 Thread Eduardo Lima Mitev
From: Iago Toral Quiroga 

From section 9.2. Binding and Managing Framebuffer Objects:

"Upon successful return from Get*FramebufferAttachmentParameteriv, if
pname is FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, then params will contain
one of NONE, FRAMEBUFFER_DEFAULT, TEXTURE, or RENDERBUFFER, identifying
the type of object which contains the attached image."

And then it clarifies further:

"If the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is NONE, then
either no framebuffer is bound to target; or the default framebuffer is
bound, attachment is DEPTH or STENCIL, and the number of depth or stencil
bits, respectively, is zero"

Currently, if the default framebuffer is bound, we always return
GL_FRAMEBUFFER_DEFAULT for FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, but
according to the spec, when GL_DEPTH or GL_STENCIL attachments are
the ones being queried, we should return GL_NONE if they don't exist.

Fixes the following dEQP test:
dEQP-GLES3.functional.state_query.fbo.framebuffer_attachment_x_size_initial
---
 src/mesa/main/fbobject.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 3305151..e4fac4c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2837,7 +2837,16 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, 
GLenum attachment,
 
switch (pname) {
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
-  *params = _mesa_is_winsys_fbo(buffer)
+  /* From the OpenGL spec, 9.2. Binding and Managing Framebuffer Objects:
+   *
+   * "If the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is NONE, then
+   *  either no framebuffer is bound to target; or the default framebuffer
+   *  is bound, attachment is DEPTH or STENCIL, and the number of depth or
+   *  stencil bits, respectively, is zero."
+   */
+  *params = (_mesa_is_winsys_fbo(buffer) &&
+ ((attachment != GL_DEPTH && attachment != GL_STENCIL) ||
+  (att->Type != GL_NONE)))
  ? GL_FRAMEBUFFER_DEFAULT : att->Type;
   return;
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
-- 
2.1.3

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


[Mesa-dev] [PATCH 1/9] glsl: don't lower fragdata array if the output data types don't match

2015-02-24 Thread Eduardo Lima Mitev
From: Samuel Iglesias Gonsalvez 

Commit 7e414b58640aee6e243d337e72cea290c354f632 broke the gl_FragData array
into separate gl_FragData[i] variables, so drivers can eliminate useless
writes to gl_FragData improving their performance.

The problem occurs when GLSL IR code is linked in the following case:

* The FS output variable base data type does not match gl_FragData one (float
  vector)
* The FS output variable is replaced by gl_out_FragDataX because of commit
  7e414b58640aee6 with X from 0 to GL_MAX_DRAW_BUFFERS.

Then the FS output variable base data type is lost in the resulting GLSL IR,
making that the driver does a wrong assignment to gl_out_FragData components
because of unmatching data types.

This patch reverts the fragdata array lowering when the output var base data 
type
doesn't match gl_out_FragData, i.e., when output variable base data type is
not a float or a float vector.

This patch fixes 250 dEQP tests (tested in an Intel Haswell machine)

dEQP-GLES3.functional.fragment_out.random.* (22 failed tests)
dEQP-GLES3.functional.fragment_out.array.uint.* (120 failed tests)
dEQP-GLES3.functional.fragment_out.array.int.* (108 failed tests)

Signed-off-by: Samuel Iglesias Gonsalvez 
---
 src/glsl/opt_dead_builtin_varyings.cpp | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/glsl/opt_dead_builtin_varyings.cpp 
b/src/glsl/opt_dead_builtin_varyings.cpp
index 50c8aa7..4919c8b 100644
--- a/src/glsl/opt_dead_builtin_varyings.cpp
+++ b/src/glsl/opt_dead_builtin_varyings.cpp
@@ -99,6 +99,16 @@ public:
  }
  else {
 this->fragdata_usage |= 1 << index->get_uint_component(0);
+/* Don't lowered fragdata array if the output variable
+ * is not a float variable (or float vector) because it will
+ * generate wrong register assignments because of different
+ * data types.
+ */
+if (var->type->gl_type != GL_FLOAT &&
+var->type->gl_type != GL_FLOAT_VEC2 &&
+var->type->gl_type != GL_FLOAT_VEC3 &&
+var->type->gl_type != GL_FLOAT_VEC4)
+   this->lower_fragdata_array = false;
  }
 
  /* Don't visit the leaves of ir_dereference_array. */
-- 
2.1.3

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


[Mesa-dev] [PATCH 7/9] i965/blorp: Improve precission of blitting coordinates when clipping

2015-02-24 Thread Eduardo Lima Mitev
From: Iago Toral Quiroga 

We do this in two steps: first we clip the dst rect and adjust the src
rect accordingly. Then we do it the other way around. In both passes
the adjustment part involves multiplying by a scale factor that can lead
to a small precision loss. This is breaking a few dEQP tests.

Specifically, the problem happens when we need to clip the same coordinate
twice. For example, if srcX0 and dstX0 need both to be clipped we want to
avoid the situation where we clip srcX0 first, then adjust dstX0 accordingly
but then we realize that the resulting dstX0 still needs to be clipped, so
we clip dstX0 and adjust srcX0 again. Each of these two passes can lead
to precission loss. What we want to do here is detect the rect that leads
to the largest clip (accounting for the scale factor involved), clip that
rect and adjust the other one. With this we ensure that the adjusted
coordinate does not need to be clipped again and we can skip a second pass,
improving precision.

Fixes the following 4 dEQP tests:
dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_reverse_src_x_nearest
dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_reverse_src_x_linear
dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_reverse_dst_x_nearest
dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_reverse_dst_x_linear
---
 src/mesa/drivers/dri/i965/brw_meta_util.c | 224 ++
 1 file changed, 163 insertions(+), 61 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_meta_util.c 
b/src/mesa/drivers/dri/i965/brw_meta_util.c
index a3b0604..b250d8a 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_util.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_util.c
@@ -41,65 +41,111 @@ fixup_mirroring(bool *mirror, float *coord0, float *coord1)
 }
 
 /**
- * Adjust {src,dst}_x{0,1} to account for clipping and scissoring of
- * destination coordinates.
+ * Compute the number of pixels to clip for each side of a rect
  *
- * Return true if there is still blitting to do, false if all pixels got
- * rejected by the clip and/or scissor.
+ * \param x0 The rect's left coordinate
+ * \param y0 The rect's bottom coordinate
+ * \param x1 The rect's right coordinate
+ * \param y1 The rect's top coordinate
+ * \param min_x The clipping region's left coordinate
+ * \param min_y The clipping region's bottom coordinate
+ * \param max_x The clipping region's right coordinate
+ * \param max_y The clipping region's top coordinate
+ * \param clipped_x0 The number of pixels to clip from the left side
+ * \param clipped_y0 The number of pixels to clip from the bottom side
+ * \param clipped_x1 The number of pixels to clip from the right side
+ * \param clipped_y1 The number of pixels to clip from the top side
  *
- * For clarity, the nomenclature of this function assumes we are clipping and
- * scissoring the X coordinate; the exact same logic applies for Y
- * coordinates.
- *
- * Note: this function may also be used to account for clipping of source
- * coordinates, by swapping the roles of src and dst.
+ * \return false if we clip everything away, true otherwise
  */
 static inline bool
-clip_or_scissor(bool mirror,
-GLfloat *src_x0, GLfloat *src_x1,
-GLfloat *dst_x0, GLfloat *dst_x1,
-GLfloat fb_xmin, GLfloat fb_xmax)
+compute_pixels_clipped(float x0, float y0, float x1, float y1,
+   float min_x, float min_y, float max_x, float max_y,
+   float *clipped_x0, float *clipped_y0, float 
*clipped_x1, float *clipped_y1)
 {
-   float scale = (float) (*src_x1 - *src_x0) / (*dst_x1 - *dst_x0);
-   /* If we are going to scissor everything away, stop. */
-   if (!(fb_xmin < fb_xmax &&
- *dst_x0 < fb_xmax &&
- fb_xmin < *dst_x1 &&
- *dst_x0 < *dst_x1)) {
+   /* If we are going to clip everything away, stop. */
+   if (!(min_x <= max_x &&
+ min_y <= max_y &&
+ x0 <= max_x &&
+ y0 <= max_y &&
+ min_x <= x1 &&
+ min_y <= y1 &&
+ x0 <= x1 &&
+ y0 <= y1)) {
   return false;
}
 
-   /* Clip the destination rectangle, and keep track of how many pixels we
-* clipped off of the left and right sides of it.
-*/
-   int pixels_clipped_left = 0;
-   int pixels_clipped_right = 0;
-   if (*dst_x0 < fb_xmin) {
-  pixels_clipped_left = fb_xmin - *dst_x0;
-  *dst_x0 = fb_xmin;
-   }
-   if (fb_xmax < *dst_x1) {
-  pixels_clipped_right = *dst_x1 - fb_xmax;
-  *dst_x1 = fb_xmax;
-   }
+   if (x0 < min_x)
+  *clipped_x0 = min_x - x0;
+   else
+  *clipped_x0 = 0;
+   if (max_x < x1)
+  *clipped_x1 = x1 - max_x;
+   else
+  *clipped_x1 = 0;
 
-   /* If we are mirrored, then before applying pixels_clipped_{left,right} to
-* the source coordinates, we need to flip them to account for the
-* mirroring.
-*/
-   if (mirror) {
-  int tmp = pixels_clipped_left;
-  pixels_clipped_left = pixels_clipped_right;
-  pixels_clipped_right = tmp;
-   }
+  

[Mesa-dev] [PATCH 4/9] glsl: Add function parameter declarations to the symbol table

2015-02-24 Thread Eduardo Lima Mitev
From: Iago Toral Quiroga 

So they can hide declarations with the same name in other scopes.
Otherwise we get a parsing error for things like:

struct S { int val; };
int func (int S) { return S; }

Fixes the following 2 dEQP tests:
dEQP-GLES3.functional.shaders.scoping.valid.function_parameter_hides_struct_type_vertex
dEQP-GLES3.functional.shaders.scoping.valid.function_parameter_hides_struct_type_fragment
---
 src/glsl/glsl_parser.yy | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 17422ed..dc2b846 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -908,6 +908,7 @@ parameter_declarator:
   $$->type->set_location(@1);
   $$->type->specifier = $1;
   $$->identifier = $2;
+  state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
}
| type_specifier any_identifier array_specifier
{
@@ -919,6 +920,7 @@ parameter_declarator:
   $$->type->specifier = $1;
   $$->identifier = $2;
   $$->array_specifier = $3;
+  state->symbols->add_variable(new(state) ir_variable(NULL, $2, 
ir_var_auto));
}
;
 
-- 
2.1.3

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


Re: [Mesa-dev] [PATCH 6/8] i965/fs: Handle conditional discards.

2015-02-24 Thread Connor Abbott
On Tue, Feb 24, 2015 at 5:19 AM, Kenneth Graunke  wrote:
> For conditional discards, we can call emit_bool_to_cond_code to generate
> the condition in f0.0.  However, we want it in f0.1.  The flag value is
> always produced by the last instruction emit_bool_to_cond_code
> generates, so we can simply get the last instruction and patch it up.

Is this left over from an earlier version? It seems to me like we're
just doing the dumb thing (rather than emit_bool_to_cond_code()) here
and letting the i965 optimizer clean it up for both GLSL IR and NIR.

>
> Nothing generates these today, but that will change shortly.
>
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 22 ++
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 21 -
>  2 files changed, 26 insertions(+), 17 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 90eecae..6354bde 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -1149,16 +1149,22 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr 
> *instr)
> bool has_indirect = false;
>
> switch (instr->intrinsic) {
> -   case nir_intrinsic_discard: {
> +   case nir_intrinsic_discard:
> +   case nir_intrinsic_discard_if: {
>/* We track our discarded pixels in f0.1.  By predicating on it, we can
> -   * update just the flag bits that aren't yet discarded.  By emitting a
> -   * CMP of g0 != g0, all our currently executing channels will get 
> turned
> -   * off.
> +   * update just the flag bits that aren't yet discarded.  If there's no
> +   * condition, we emit a CMP of g0 != g0, so all currently executing
> +   * channels will get turned off.
> */
> -  fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
> -BRW_REGISTER_TYPE_UW));
> -  fs_inst *cmp = emit(CMP(reg_null_f, some_reg, some_reg,
> -  BRW_CONDITIONAL_NZ));
> +  fs_inst *cmp;
> +  if (instr->intrinsic == nir_intrinsic_discard_if) {
> + cmp = emit(CMP(reg_null_f, get_nir_src(instr->src[0]),
> +fs_reg(0), BRW_CONDITIONAL_Z));
> +  } else {
> + fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
> +   BRW_REGISTER_TYPE_UW));
> + cmp = emit(CMP(reg_null_f, some_reg, some_reg, BRW_CONDITIONAL_NZ));
> +  }
>cmp->predicate = BRW_PREDICATE_NORMAL;
>cmp->flag_subreg = 1;
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> index b1b75821..75254a1 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -2415,17 +2415,20 @@ fs_visitor::visit(ir_swizzle *ir)
>  void
>  fs_visitor::visit(ir_discard *ir)
>  {
> -   assert(ir->condition == NULL); /* FINISHME */
> -
> /* We track our discarded pixels in f0.1.  By predicating on it, we can
> -* update just the flag bits that aren't yet discarded.  By emitting a
> -* CMP of g0 != g0, all our currently executing channels will get turned
> -* off.
> +* update just the flag bits that aren't yet discarded.  If there's no
> +* condition, we emit a CMP of g0 != g0, so all currently executing
> +* channels will get turned off.
>  */
> -   fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
> -   BRW_REGISTER_TYPE_UW));
> -   fs_inst *cmp = emit(CMP(reg_null_f, some_reg, some_reg,
> -   BRW_CONDITIONAL_NZ));
> +   fs_inst *cmp;
> +   if (ir->condition) {
> +  ir->condition->accept(this);
> +  cmp = emit(CMP(reg_null_f, this->result, fs_reg(0), 
> BRW_CONDITIONAL_Z));
> +   } else {
> +  fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
> +  BRW_REGISTER_TYPE_UW));
> +  cmp = emit(CMP(reg_null_f, some_reg, some_reg, BRW_CONDITIONAL_NZ));
> +   }
> cmp->predicate = BRW_PREDICATE_NORMAL;
> cmp->flag_subreg = 1;
>
> --
> 2.2.2
>
> ___
> 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 7/8] glsl: Optimize "if (cond) discard; " to a conditional discard.

2015-02-24 Thread Matt Turner
On Tue, Feb 24, 2015 at 10:31 AM, Connor Abbott  wrote:
> On Tue, Feb 24, 2015 at 11:39 AM, Matt Turner  wrote:
>> On Tue, Feb 24, 2015 at 7:53 AM, Jason Ekstrand  wrote:
>>> On Tue, Feb 24, 2015 at 2:19 AM, Kenneth Graunke 
>>> wrote:

 st_glsl_to_tgsi and ir_to_mesa have handled conditional discards for a
 long time; the previous patch added that capability to i965.

 i965 (Haswell) shader-db stats:

 Without NIR:
 total instructions in shared programs: 5792133 -> 5776360 (-0.27%)
 instructions in affected programs: 737585 -> 721812 (-2.14%)
 helped:6300
 HURT:  68
 GAINED:2

 With NIR:
 total instructions in shared programs: 5787538 -> 5769569 (-0.31%)
 instructions in affected programs: 767843 -> 749874 (-2.34%)
 helped:6522
 HURT:  35
 GAINED:6
>>>
>>>
>>> What all do you have in that branch?  Last I checked (10 minutes ago), NIR
>>> wasn't beating GLSL IR yet.
>>> --Jason
>>
>> I think you misread. Those stats are just for this patch, and they
>> show NIR generating more instructions than non-NIR.
>
>> Without NIR:
>> total instructions in shared programs: 5792133 -> 5776360 (-0.27%)
>
>> With NIR:
>> total instructions in shared programs: 5787538 -> 5769569 (-0.31%)
>
> So either I fail at reading comprehension, or the stats show us
> generating more instructions with non-NIR than with NIR. Maybe Ken ran
> the comparison on top of his Mesa IR -> NIR series? We get some
> *serious* improvements in the ARB shaders when we run them through
> NIR, so I wouldn't be too surprised if NIR starts beating non-NIR
> after we start using the NIR path for those.

Oh you're right. I was just looking at the affected program numbers it seems.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/9] i965: Fix textureGrad with cube samplers

2015-02-24 Thread Roland Scheidegger
As a side note (not really directly related to the patch) I think this
could benefit from some optimization, unless there's some passes
somewhere which can already do this.

The non-scalar (non-cube) calculation does this:
lod_info.lod = log2(max(sqrt(dot1), sqrt(dot2)))
The second sqrt can be trivially eliminated:
= log2(sqrt(max(dot1, dot2)))
And furthermore the remaining sqrt can be killed off too thanks to
n*log2(x) = log2(x^n)
= 0.5*log2(max(dot1, dot2)))

I don't really know anything about the hw, but I would think this should
be faster not only on the 1 mathbox-per-gpu ancient igps ;-).

Roland


Am 24.02.2015 um 19:02 schrieb Eduardo Lima Mitev:
> From: Iago Toral Quiroga 
> 
> We can't use sampler messages with gradient information (like
> sample_g or sample_d) to deal with this scenario because according
> to the PRM:
> 
> "The r coordinate and its gradients are required only for surface
> types that use the third coordinate. Usage of this message type on
> cube surfaces assumes that the u, v, and gradients have already been
> transformed onto the appropriate face, but still in [-1,+1] range.
> The r coordinate contains the faceid, and the r gradients are ignored
> by hardware."
> 
> Instead, we should lower this to compute the LOD manually based on the
> gradients and use a different sample message that takes the computed
> LOD instead of the gradients. This is already being done in
> brw_lower_texture_gradients.cpp, but it is restricted to shadow
> samplers only, although there is a comment stating that we should
> probably do this also for samplerCube and samplerCubeArray.
> 
> Because of this, both dEQP and Piglit test cases for textureGrad with
> cube maps currently fail.
> 
> This patch does two things:
> 1) Activates the texturegrad lowering pass for all cube samplers.
> 2) Corrects the computation of the LOD value for cube samplers.
> 
> I had to do 2) because for cube maps the calculations implemented
> in the lowering pass always compute a value of rho that is twice
> the value we want (so we get a LOD value one unit larger than we
> want). This only happens for cube map samplers (all kinds). I am
> not sure about why we need to do this, but I suspect that it is
> related to the fact that cube map coordinates, when transported
> to a specific face in the cube, are in the range [-1, 1] instead of
> [0, 1] so we probably need to divide the derivatives by 2 when
> we compute the LOD. Doing that would produce the same result as
> dividing the final rho computation by 2 (or removing a unit
> from the computed LOD, which is what we are doing here).
> 
> Fixes the following piglit tests:
> bin/tex-miplevel-selection textureGrad Cube -auto -fbo
> bin/tex-miplevel-selection textureGrad CubeArray -auto -fbo
> bin/tex-miplevel-selection textureGrad CubeShadow -auto -fbo
> 
> Fixes 10 dEQP tests in the following category:
> dEQP-GLES3.functional.shaders.texture_functions.texturegrad.*cube*
> ---
>  .../dri/i965/brw_lower_texture_gradients.cpp   | 26 
> +++---
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp 
> b/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp
> index 9679d28..878a54e 100644
> --- a/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_lower_texture_gradients.cpp
> @@ -89,19 +89,18 @@ txs_type(const glsl_type *type)
>  ir_visitor_status
>  lower_texture_grad_visitor::visit_leave(ir_texture *ir)
>  {
> -   /* Only lower textureGrad with shadow samplers */
> -   if (ir->op != ir_txd || !ir->shadow_comparitor)
> +   /* Only lower textureGrad with cube maps or shadow samplers */
> +   if (ir->op != ir_txd ||
> +  (ir->sampler->type->sampler_dimensionality != GLSL_SAMPLER_DIM_CUBE &&
> +   !ir->shadow_comparitor))
>return visit_continue;
>  
> -   /* Lower textureGrad() with samplerCubeShadow even if we have the 
> sample_d_c
> +   /* Lower textureGrad() with samplerCube* even if we have the sample_d_c
>  * message.  GLSL provides gradients for the 'r' coordinate.  
> Unfortunately:
>  *
>  * From the Ivybridge PRM, Volume 4, Part 1, sample_d message description:
>  * "The r coordinate contains the faceid, and the r gradients are ignored
>  *  by hardware."
> -*
> -* We likely need to do a similar treatment for samplerCube and
> -* samplerCubeArray, but we have insufficient testing for that at the 
> moment.
>  */
> bool need_lowering = !has_sample_d_c ||
>ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE;
> @@ -153,9 +152,20 @@ lower_texture_grad_visitor::visit_leave(ir_texture *ir)
>  expr(ir_unop_sqrt, dot(dPdy, dPdy)));
> }
>  
> -   /* lambda_base = log2(rho).  We're ignoring GL state biases for now. */
> +   /* lambda_base = log2(rho).  We're ignoring GL state biases for now.
> +*
> +* For cube maps the result of t

Re: [Mesa-dev] [PATCH 1/8] glsl: Make ir_validate check the type of ir_discard::condition.

2015-02-24 Thread Connor Abbott
Except for the comment on patch 6, patches 1-7 are

Reviewed-by: Connor Abbott 

I'm not familiar enough with the code patch 8 is modifying, and Matt
and Eric have already commented on it.

On Tue, Feb 24, 2015 at 5:19 AM, Kenneth Graunke  wrote:
> Copy and pasted from the ir_if::condition handling, plus a NULL check.
>
> Signed-off-by: Kenneth Graunke 
> ---
>  src/glsl/ir_validate.cpp | 15 +++
>  1 file changed, 15 insertions(+)
>
> Piglit tested on Haswell, with and without NIR.  I touch tested classic
> swrast (I ran a few discard tests), and have not tested TGSI based
> drivers.  I did verify that st_glsl_to_tgsi has code that supposedly
> handles ir_discard::condition, however.
>
> diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
> index 6678894..7a7688c 100644
> --- a/src/glsl/ir_validate.cpp
> +++ b/src/glsl/ir_validate.cpp
> @@ -61,6 +61,7 @@ public:
> virtual ir_visitor_status visit(ir_variable *v);
> virtual ir_visitor_status visit(ir_dereference_variable *ir);
>
> +   virtual ir_visitor_status visit_enter(ir_discard *ir);
> virtual ir_visitor_status visit_enter(ir_if *ir);
>
> virtual ir_visitor_status visit_enter(ir_function *ir);
> @@ -133,6 +134,20 @@ ir_validate::visit_enter(class ir_dereference_array *ir)
>  }
>
>  ir_visitor_status
> +ir_validate::visit_enter(ir_discard *ir)
> +{
> +   if (ir->condition && ir->condition->type != glsl_type::bool_type) {
> +  printf("ir_discard condition %s type instead of bool.\n",
> +ir->condition->type->name);
> +  ir->print();
> +  printf("\n");
> +  abort();
> +   }
> +
> +   return visit_continue;
> +}
> +
> +ir_visitor_status
>  ir_validate::visit_enter(ir_if *ir)
>  {
> if (ir->condition->type != glsl_type::bool_type) {
> --
> 2.2.2
>
> ___
> 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


[Mesa-dev] [PATCH 2/2] glx: Fix returned values of GLX_RENDERER_PREFERRED_PROFILE_MESA

2015-02-24 Thread Andreas Boll
If the renderer supports the core profile the query returned incorrectly
0x8 as value, because it was using (1U << __DRI_API_OPENGL_CORE) for the
returned value.

The same happened with the compatibility profile. It returned 0x1
(1U << __DRI_API_OPENGL) instead of 0x2.

Internal DRI defines:
   dri_interface.h: #define __DRI_API_OPENGL   0
   dri_interface.h: #define __DRI_API_OPENGL_CORE  3

Those two bits are supposed for internal usage only and should be
translated to GLX_CONTEXT_CORE_PROFILE_BIT_ARB (0x1) for a preferred
core context profile and GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB (0x2)
for a preferred compatibility context profile.

This patch implements the above translation in the glx module.

v2: Fix the incorrect behavior in the glx module

Cc: "10.3 10.4 10.5" 
Cc: Ian Romanick 
Signed-off-by: Andreas Boll 
---

I've noticed this wrong behavior while testing Adam's glxinfo changes [1]
(glxinfo: Add support for GLX_MESA_query_renderer)

For reproducing this bug and/or testing this and the previous patch just run
  glxinfo | grep "Preferred profile"

Andreas.

  [1] 
http://cgit.freedesktop.org/mesa/demos/commit/?id=999b6950c644266bb871e79438751bdba2fa2a08

 src/glx/dri_common_query_renderer.c | 36 ++--
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/glx/dri_common_query_renderer.c 
b/src/glx/dri_common_query_renderer.c
index d598b12..b3e107d 100644
--- a/src/glx/dri_common_query_renderer.c
+++ b/src/glx/dri_common_query_renderer.c
@@ -65,10 +65,23 @@ dri2_convert_glx_query_renderer_attribs(int attribute)
return -1;
 }
 
+/* Convert internal dri context profile bits into GLX context profile bits */
+static inline void
+dri_convert_context_profile_bits(int attribute, unsigned int *value)
+{
+   if (attribute == GLX_RENDERER_PREFERRED_PROFILE_MESA) {
+  if (value[0] == (1U << __DRI_API_OPENGL_CORE))
+ value[0] = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
+  else if (value[0] == (1U << __DRI_API_OPENGL))
+ value[0] = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+   }
+}
+
 _X_HIDDEN int
 dri2_query_renderer_integer(struct glx_screen *base, int attribute,
 unsigned int *value)
 {
+   int ret;
struct dri2_screen *const psc = (struct dri2_screen *) base;
 
/* Even though there are invalid values (and
@@ -81,8 +94,11 @@ dri2_query_renderer_integer(struct glx_screen *base, int 
attribute,
if (psc->rendererQuery == NULL)
   return -1;
 
-   return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
-   value);
+   ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
+  value);
+   dri_convert_context_profile_bits(attribute, value);
+
+   return ret;
 }
 
 _X_HIDDEN int
@@ -108,6 +124,7 @@ _X_HIDDEN int
 dri3_query_renderer_integer(struct glx_screen *base, int attribute,
 unsigned int *value)
 {
+   int ret;
struct dri3_screen *const psc = (struct dri3_screen *) base;
 
/* Even though there are invalid values (and
@@ -120,8 +137,11 @@ dri3_query_renderer_integer(struct glx_screen *base, int 
attribute,
if (psc->rendererQuery == NULL)
   return -1;
 
-   return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
-   value);
+   ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
+  value);
+   dri_convert_context_profile_bits(attribute, value);
+
+   return ret;
 }
 
 _X_HIDDEN int
@@ -147,6 +167,7 @@ _X_HIDDEN int
 drisw_query_renderer_integer(struct glx_screen *base, int attribute,
  unsigned int *value)
 {
+   int ret;
struct drisw_screen *const psc = (struct drisw_screen *) base;
 
/* Even though there are invalid values (and
@@ -159,8 +180,11 @@ drisw_query_renderer_integer(struct glx_screen *base, int 
attribute,
if (psc->rendererQuery == NULL)
   return -1;
 
-   return psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
-   value);
+   ret = psc->rendererQuery->queryInteger(psc->driScreen, dri_attribute,
+  value);
+   dri_convert_context_profile_bits(attribute, value);
+
+   return ret;
 }
 
 _X_HIDDEN int
-- 
2.1.4

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


[Mesa-dev] [PATCH 1/2] dri/common: Update comment about driQueryRendererIntegerCommon

2015-02-24 Thread Andreas Boll
Since 87d3ae0b45b6b6bb50b583dafa55eb109449a005
driQueryRendererIntegerCommon handles __DRI2_RENDERER_PREFFERED_PROFILE
too.

Cc: Ian Romanick 
Signed-off-by: Andreas Boll 
---
 src/mesa/drivers/dri/common/utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/common/utils.c 
b/src/mesa/drivers/dri/common/utils.c
index f2e63c0..ccdc971 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -485,6 +485,7 @@ driIndexConfigAttrib(const __DRIconfig *config, int index,
  * Currently only the following queries are supported by this function:
  *
  * - \c __DRI2_RENDERER_VERSION
+ * - \c __DRI2_RENDERER_PREFERRED_PROFILE
  * - \c __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION
  * - \c __DRI2_RENDERER_OPENGL_COMPATIBLITY_PROFILE_VERSION
  * - \c __DRI2_RENDERER_ES_PROFILE_VERSION
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH 1/8] glsl: Make ir_validate check the type of ir_discard::condition.

2015-02-24 Thread Ian Romanick
Patches 1, 2, and 4 are

Reviewed-by: Ian Romanick 

I want to look more closely at the others.

On 02/24/2015 02:19 AM, Kenneth Graunke wrote:
> Copy and pasted from the ir_if::condition handling, plus a NULL check.
> 
> Signed-off-by: Kenneth Graunke 
> ---
>  src/glsl/ir_validate.cpp | 15 +++
>  1 file changed, 15 insertions(+)
> 
> Piglit tested on Haswell, with and without NIR.  I touch tested classic
> swrast (I ran a few discard tests), and have not tested TGSI based
> drivers.  I did verify that st_glsl_to_tgsi has code that supposedly
> handles ir_discard::condition, however.
> 
> diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
> index 6678894..7a7688c 100644
> --- a/src/glsl/ir_validate.cpp
> +++ b/src/glsl/ir_validate.cpp
> @@ -61,6 +61,7 @@ public:
> virtual ir_visitor_status visit(ir_variable *v);
> virtual ir_visitor_status visit(ir_dereference_variable *ir);
>  
> +   virtual ir_visitor_status visit_enter(ir_discard *ir);
> virtual ir_visitor_status visit_enter(ir_if *ir);
>  
> virtual ir_visitor_status visit_enter(ir_function *ir);
> @@ -133,6 +134,20 @@ ir_validate::visit_enter(class ir_dereference_array *ir)
>  }
>  
>  ir_visitor_status
> +ir_validate::visit_enter(ir_discard *ir)
> +{
> +   if (ir->condition && ir->condition->type != glsl_type::bool_type) {
> +  printf("ir_discard condition %s type instead of bool.\n",
> +  ir->condition->type->name);
> +  ir->print();
> +  printf("\n");
> +  abort();
> +   }
> +
> +   return visit_continue;
> +}
> +
> +ir_visitor_status
>  ir_validate::visit_enter(ir_if *ir)
>  {
> if (ir->condition->type != glsl_type::bool_type) {
> 

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


[Mesa-dev] [PATCH] glsl: Rewrite and fix min/max to saturate optimization.

2015-02-24 Thread Matt Turner
There were some bugs, and the code was really difficult to follow. We
would optimize

   min(max(x, b), 1.0) into max(sat(x), b)

but not pay attention to the order of min/max and also do

   max(min(x, b), 1.0) into max(sat(x), b)

Corrects four shaders from Champions of Regnum that do

   min(max(x, 1), 10)

Cc: "10.5" 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89180
---
 src/glsl/opt_algebraic.cpp | 75 --
 1 file changed, 46 insertions(+), 29 deletions(-)

diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 6784242..c3f3842 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -744,48 +744,65 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
* a saturate operation
*/
   for (int op = 0; op < 2; op++) {
- ir_expression *minmax = op_expr[op];
+ ir_expression *inner_expr = op_expr[op];
  ir_constant *outer_const = op_const[1 - op];
  ir_expression_operation op_cond = (ir->operation == ir_binop_max) ?
 ir_binop_min : ir_binop_max;
 
- if (!minmax || !outer_const || (minmax->operation != op_cond))
+ if (!inner_expr || !outer_const || (inner_expr->operation != op_cond))
 continue;
 
+ /* One of these has to be a constant */
+ if (!inner_expr->operands[0]->as_constant() &&
+ !inner_expr->operands[1]->as_constant())
+break;
+
  /* Found a min(max) combination. Now try to see if its operands
   * meet our conditions that we can do just a single saturate operation
   */
  for (int minmax_op = 0; minmax_op < 2; minmax_op++) {
-ir_rvalue *inner_val_a = minmax->operands[minmax_op];
-ir_rvalue *inner_val_b = minmax->operands[1 - minmax_op];
+ir_rvalue *x = inner_expr->operands[minmax_op];
+ir_rvalue *y = inner_expr->operands[1 - minmax_op];
 
-if (!inner_val_a || !inner_val_b)
+ir_constant *inner_const = y->as_constant();
+if (!inner_const)
continue;
 
-/* Found a {min|max} ({max|min} (x, 0.0), 1.0) operation and its 
variations */
-if ((outer_const->is_one() && inner_val_a->is_zero()) ||
-(inner_val_a->is_one() && outer_const->is_zero()))
-   return saturate(inner_val_b);
-
-/* Found a {min|max} ({max|min} (x, 0.0), b) where b < 1.0
- * and its variations
- */
-if (is_less_than_one(outer_const) && inner_val_b->is_zero())
-   return expr(ir_binop_min, saturate(inner_val_a), outer_const);
-
-if (!inner_val_b->as_constant())
-   continue;
-
-if (is_less_than_one(inner_val_b->as_constant()) && 
outer_const->is_zero())
-   return expr(ir_binop_min, saturate(inner_val_a), inner_val_b);
-
-/* Found a {min|max} ({max|min} (x, b), 1.0), where b > 0.0
- * and its variations
- */
-if (outer_const->is_one() && 
is_greater_than_zero(inner_val_b->as_constant()))
-   return expr(ir_binop_max, saturate(inner_val_a), inner_val_b);
-if (inner_val_b->as_constant()->is_one() && 
is_greater_than_zero(outer_const))
-   return expr(ir_binop_max, saturate(inner_val_a), outer_const);
+/* min(max(x, 0.0), 1.0) is sat(x) */
+if (ir->operation == ir_binop_min &&
+inner_const->is_zero() &&
+outer_const->is_one())
+   return saturate(x);
+
+/* max(min(x, 1.0), 0.0) is sat(x) */
+if (ir->operation == ir_binop_max &&
+inner_const->is_one() &&
+outer_const->is_zero())
+   return saturate(x);
+
+/* min(max(x, 0.0), b) where b < 1.0 is sat(min(x, b)) */
+if (ir->operation == ir_binop_min &&
+inner_const->is_zero() &&
+is_less_than_one(outer_const))
+   return saturate(expr(ir_binop_min, x, outer_const));
+
+/* max(min(x, b), 0.0) where b < 1.0 is sat(min(x, b)) */
+if (ir->operation == ir_binop_max &&
+is_less_than_one(inner_const) &&
+outer_const->is_zero())
+   return saturate(expr(ir_binop_min, x, inner_const));
+
+/* max(min(x, 1.0), b) where b > 0.0 is sat(max(x, b)) */
+if (ir->operation == ir_binop_max &&
+inner_const->is_one() &&
+is_greater_than_zero(outer_const))
+   return saturate(expr(ir_binop_max, x, outer_const));
+
+/* min(max(x, b), 1.0) where b > 0.0 is sat(max(x, b)) */
+if (ir->operation == ir_binop_min &&
+is_greater_than_zero(inner_const) &&
+outer_const->is_one())
+   return saturate(expr(ir_binop_max, x, inner_const)

Re: [Mesa-dev] [PATCH 6/8] i965/fs: Handle conditional discards.

2015-02-24 Thread Kenneth Graunke
On Tuesday, February 24, 2015 01:25:18 PM Connor Abbott wrote:
> On Tue, Feb 24, 2015 at 5:19 AM, Kenneth Graunke  
> wrote:
> > For conditional discards, we can call emit_bool_to_cond_code to generate
> > the condition in f0.0.  However, we want it in f0.1.  The flag value is
> > always produced by the last instruction emit_bool_to_cond_code
> > generates, so we can simply get the last instruction and patch it up.
> 
> Is this left over from an earlier version? It seems to me like we're
> just doing the dumb thing (rather than emit_bool_to_cond_code()) here
> and letting the i965 optimizer clean it up for both GLSL IR and NIR.

Oops.  Yes :)  I was originally doing:

emit_bool_to_cond_code(new(mem_ctx) ir_expression(ir_unop_logic_not,
  ir->condition))
cmp = (fs_inst *) this->instructions.get_tail();

but that seemed more fragile for no real benefit - it actually emitted
ir->condition as a boolean, then did an AND.z  1D to produce the
condition code (making cmp an AND!).  Same number of instructions.

I'll fix up the commit message.

> >
> > Nothing generates these today, but that will change shortly.
> >
> > Signed-off-by: Kenneth Graunke 
> > ---
> >  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 22 ++
> >  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 21 -
> >  2 files changed, 26 insertions(+), 17 deletions(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
> > b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> > index 90eecae..6354bde 100644
> > --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> > +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> > @@ -1149,16 +1149,22 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr 
> > *instr)
> > bool has_indirect = false;
> >
> > switch (instr->intrinsic) {
> > -   case nir_intrinsic_discard: {
> > +   case nir_intrinsic_discard:
> > +   case nir_intrinsic_discard_if: {
> >/* We track our discarded pixels in f0.1.  By predicating on it, we 
> > can
> > -   * update just the flag bits that aren't yet discarded.  By emitting 
> > a
> > -   * CMP of g0 != g0, all our currently executing channels will get 
> > turned
> > -   * off.
> > +   * update just the flag bits that aren't yet discarded.  If there's 
> > no
> > +   * condition, we emit a CMP of g0 != g0, so all currently executing
> > +   * channels will get turned off.
> > */
> > -  fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
> > -BRW_REGISTER_TYPE_UW));
> > -  fs_inst *cmp = emit(CMP(reg_null_f, some_reg, some_reg,
> > -  BRW_CONDITIONAL_NZ));
> > +  fs_inst *cmp;
> > +  if (instr->intrinsic == nir_intrinsic_discard_if) {
> > + cmp = emit(CMP(reg_null_f, get_nir_src(instr->src[0]),
> > +fs_reg(0), BRW_CONDITIONAL_Z));
> > +  } else {
> > + fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
> > +   BRW_REGISTER_TYPE_UW));
> > + cmp = emit(CMP(reg_null_f, some_reg, some_reg, 
> > BRW_CONDITIONAL_NZ));
> > +  }
> >cmp->predicate = BRW_PREDICATE_NORMAL;
> >cmp->flag_subreg = 1;
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
> > b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> > index b1b75821..75254a1 100644
> > --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> > +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> > @@ -2415,17 +2415,20 @@ fs_visitor::visit(ir_swizzle *ir)
> >  void
> >  fs_visitor::visit(ir_discard *ir)
> >  {
> > -   assert(ir->condition == NULL); /* FINISHME */
> > -
> > /* We track our discarded pixels in f0.1.  By predicating on it, we can
> > -* update just the flag bits that aren't yet discarded.  By emitting a
> > -* CMP of g0 != g0, all our currently executing channels will get turned
> > -* off.
> > +* update just the flag bits that aren't yet discarded.  If there's no
> > +* condition, we emit a CMP of g0 != g0, so all currently executing
> > +* channels will get turned off.
> >  */
> > -   fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
> > -   BRW_REGISTER_TYPE_UW));
> > -   fs_inst *cmp = emit(CMP(reg_null_f, some_reg, some_reg,
> > -   BRW_CONDITIONAL_NZ));
> > +   fs_inst *cmp;
> > +   if (ir->condition) {
> > +  ir->condition->accept(this);
> > +  cmp = emit(CMP(reg_null_f, this->result, fs_reg(0), 
> > BRW_CONDITIONAL_Z));
> > +   } else {
> > +  fs_reg some_reg = fs_reg(retype(brw_vec8_grf(0, 0),
> > +  BRW_REGISTER_TYPE_UW));
> > +  cmp = emit(CMP(reg_null_f, some_reg, some_reg, BRW_CONDITIONAL_NZ));
> > +   }
> > cmp->predicate = BRW_PREDICATE_NORMAL;
> > cmp->flag_subreg = 1;
> >
> > --
> > 2.2.2
> >
> > ___
> > mesa-d

Re: [Mesa-dev] [PATCH] glsl: Rewrite and fix min/max to saturate optimization.

2015-02-24 Thread Matt Turner
On Tue, Feb 24, 2015 at 11:22 AM, Matt Turner  wrote:
> There were some bugs, and the code was really difficult to follow. We
> would optimize
>
>min(max(x, b), 1.0) into max(sat(x), b)
>
> but not pay attention to the order of min/max and also do
>
>max(min(x, b), 1.0) into max(sat(x), b)
>
> Corrects four shaders from Champions of Regnum that do
>
>min(max(x, 1), 10)

And I should say pending test for the bug report, bad rendering in
Mass Effect under VMware Workstation.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/8] glsl: Optimize "if (cond) discard; " to a conditional discard.

2015-02-24 Thread Ian Romanick
On 02/24/2015 02:19 AM, Kenneth Graunke wrote:
> st_glsl_to_tgsi and ir_to_mesa have handled conditional discards for a
> long time; the previous patch added that capability to i965.
> 
> i965 (Haswell) shader-db stats:
> 
> Without NIR:
> total instructions in shared programs: 5792133 -> 5776360 (-0.27%)
> instructions in affected programs: 737585 -> 721812 (-2.14%)
> helped:6300
> HURT:  68
> GAINED:2
> 
> With NIR:
> total instructions in shared programs: 5787538 -> 5769569 (-0.31%)
> instructions in affected programs: 767843 -> 749874 (-2.34%)
> helped:6522
> HURT:  35
> GAINED:6
> 
> Signed-off-by: Kenneth Graunke 
> ---
>  src/glsl/Makefile.sources|  1 +
>  src/glsl/glsl_parser_extras.cpp  |  1 +
>  src/glsl/ir_optimization.h   |  1 +
>  src/glsl/opt_conditional_discard.cpp | 81 
> 
>  4 files changed, 84 insertions(+)
>  create mode 100644 src/glsl/opt_conditional_discard.cpp
> 
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index d0210d1..b876642 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -157,6 +157,7 @@ LIBGLSL_FILES = \
>   lower_ubo_reference.cpp \
>   opt_algebraic.cpp \
>   opt_array_splitting.cpp \
> + opt_conditional_discard.cpp \
>   opt_constant_folding.cpp \
>   opt_constant_propagation.cpp \
>   opt_constant_variable.cpp \
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
> index 9f79313..f19804b 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -1627,6 +1627,7 @@ do_common_optimization(exec_list *ir, bool linked,
> }
> progress = do_if_simplification(ir) || progress;
> progress = opt_flatten_nested_if_blocks(ir) || progress;
> +   progress = opt_conditional_discard(ir) || progress;
> progress = do_copy_propagation(ir) || progress;
> progress = do_copy_propagation_elements(ir) || progress;
>  
> diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
> index 7eb861a..e6939f3 100644
> --- a/src/glsl/ir_optimization.h
> +++ b/src/glsl/ir_optimization.h
> @@ -77,6 +77,7 @@ bool do_common_optimization(exec_list *ir, bool linked,
>  bool do_rebalance_tree(exec_list *instructions);
>  bool do_algebraic(exec_list *instructions, bool native_integers,
>const struct gl_shader_compiler_options *options);
> +bool opt_conditional_discard(exec_list *instructions);
>  bool do_constant_folding(exec_list *instructions);
>  bool do_constant_variable(exec_list *instructions);
>  bool do_constant_variable_unlinked(exec_list *instructions);
> diff --git a/src/glsl/opt_conditional_discard.cpp 
> b/src/glsl/opt_conditional_discard.cpp
> new file mode 100644
> index 000..0905188
> --- /dev/null
> +++ b/src/glsl/opt_conditional_discard.cpp
> @@ -0,0 +1,81 @@
> +/*
> + * Copyright © 2010 Intel Corporation

You've been sitting on this patch for a long time, eh? :)

> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +/**
> + * \file opt_conditional_discard.cpp
> + *
> + * Replace
> + *
> + *if (cond) discard;
> + *
> + * with
> + *
> + *(discard )
> + */
> +
> +#include "glsl_types.h"
> +#include "ir.h"
> +
> +namespace {
> +
> +class opt_conditional_discard_visitor : public ir_hierarchical_visitor {
> +public:
> +   opt_conditional_discard_visitor()
> +   {
> +  progress = false;

Did we ever decide whether it was better to initialize members like this
or like

   opt_conditional_discard_visitor()
  : progress(false)
   {
   }

I honestly don't remember.  I know we talked about it.

Either way, with the copyright date fi

Re: [Mesa-dev] [PATCH 8/8] i965: Remove redundant discard jumps.

2015-02-24 Thread Kenneth Graunke
On Tuesday, February 24, 2015 12:20:08 PM Eric Anholt wrote:
> Kenneth Graunke  writes:
> 
> > With the previous optimization in place, some shaders wind up with
> > multiple discard jumps in a row, or jumps directly to the next
> > instruction.  We can remove those.
> >
> > Without NIR on Haswell:
> > total instructions in shared programs: 5777258 -> 5775872 (-0.02%)
> > instructions in affected programs: 20312 -> 18926 (-6.82%)
> > helped:716
> >
> > With NIR on Haswell:
> > total instructions in shared programs: 5773163 -> 5771785 (-0.02%)
> > instructions in affected programs: 21040 -> 19662 (-6.55%)
> > helped:717
> >
> > v2: Use the CFG rather than the old instructions list.  Presumably
> > the placeholder halt will be in the last basic block.
> >
> > Signed-off-by: Kenneth Graunke 
> > ---
> >  src/mesa/drivers/dri/i965/brw_fs.cpp | 42 
> > 
> >  src/mesa/drivers/dri/i965/brw_fs.h   |  1 +
> >  2 files changed, 43 insertions(+)
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> > b/src/mesa/drivers/dri/i965/brw_fs.cpp
> > index 9df1650..21e1e82 100644
> > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> > @@ -2558,6 +2558,47 @@ fs_visitor::opt_register_renaming()
> > return progress;
> >  }
> >  
> > +/**
> > + * Remove redundant or useless discard jumps.
> > + *
> > + * For example, we can eliminate jumps in the following sequence:
> > + *
> > + * discard-jump   (redundant with the next jump)
> > + * discard-jump   (useless; jumps to the next instruction)
> > + * placeholder-halt
> > + */
> > +bool
> > +fs_visitor::opt_redundant_discard_jumps()
> > +{
> > +   bool progress = false;
> > +
> > +   bblock_t *last_bblock = cfg->blocks[cfg->num_blocks - 1];
> > +
> > +   fs_inst *placeholder_halt = NULL;
> > +   foreach_inst_in_block_reverse(fs_inst, inst, last_bblock) {
> > +  if (inst->opcode == FS_OPCODE_PLACEHOLDER_HALT) {
> > + placeholder_halt = inst;
> > + break;
> > +  }
> > +   }
> > +
> > +   if (!placeholder_halt)
> > +  return false;
> > +
> > +   /* Delete any HALTs immediately before the placeholder halt. */
> > +   for (fs_inst *prev = (fs_inst *) placeholder_halt->prev;
> > +prev->opcode == FS_OPCODE_DISCARD_JUMP;
> > +prev = (fs_inst *) placeholder_halt->prev) {
> > +  prev->remove(last_bblock);
> > +  progress = true;
> > +   }
> 
> My only question in this series was "what if the placeholder halt is the
> first instruction in the block?"  Shouldn't you be checking for a start
> sentinel?

Yep.  It's certainly not common.  But void main() {} hits that case.

I've changed the loop condition to:
!prev->is_head_sentinel() && prev->opcode == FS_OPCODE_DISCARD_JUMP;

> Other than that, this series is:
> 
> Reviewed-by: Eric Anholt 
> 
> and I look forward to using the NIR intrinsic in my TGSI support.

Thanks!


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/8] glsl: Make ir_validate check the type of ir_discard::condition.

2015-02-24 Thread Ian Romanick
On 02/24/2015 11:32 AM, Matt Turner wrote:
> On Tue, Feb 24, 2015 at 11:20 AM, Ian Romanick  wrote:
>> Patches 1, 2, and 4 are
>>
>> Reviewed-by: Ian Romanick 
>>
>> I want to look more closely at the others.
> 
> Okay, but three people have already reviewed them.

So there's probably no reason to wait on me. :)  Thunderbird has this
annoying habit of putting replies to message 1/n at the bottom instead
of directly below message 1/n.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 7/8] glsl: Optimize "if (cond) discard; " to a conditional discard.

2015-02-24 Thread Kenneth Graunke
On Tuesday, February 24, 2015 11:33:30 AM Ian Romanick wrote:
> On 02/24/2015 02:19 AM, Kenneth Graunke wrote:
> > st_glsl_to_tgsi and ir_to_mesa have handled conditional discards for a
> > long time; the previous patch added that capability to i965.
> > 
> > i965 (Haswell) shader-db stats:
> > 
> > Without NIR:
> > total instructions in shared programs: 5792133 -> 5776360 (-0.27%)
> > instructions in affected programs: 737585 -> 721812 (-2.14%)
> > helped:6300
> > HURT:  68
> > GAINED:2
> > 
> > With NIR:
> > total instructions in shared programs: 5787538 -> 5769569 (-0.31%)
> > instructions in affected programs: 767843 -> 749874 (-2.34%)
> > helped:6522
> > HURT:  35
> > GAINED:6
> > 
> > Signed-off-by: Kenneth Graunke 
> > ---
> >  src/glsl/Makefile.sources|  1 +
> >  src/glsl/glsl_parser_extras.cpp  |  1 +
> >  src/glsl/ir_optimization.h   |  1 +
> >  src/glsl/opt_conditional_discard.cpp | 81 
> > 
> >  4 files changed, 84 insertions(+)
> >  create mode 100644 src/glsl/opt_conditional_discard.cpp
> > 
> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> > index d0210d1..b876642 100644
> > --- a/src/glsl/Makefile.sources
> > +++ b/src/glsl/Makefile.sources
> > @@ -157,6 +157,7 @@ LIBGLSL_FILES = \
> > lower_ubo_reference.cpp \
> > opt_algebraic.cpp \
> > opt_array_splitting.cpp \
> > +   opt_conditional_discard.cpp \
> > opt_constant_folding.cpp \
> > opt_constant_propagation.cpp \
> > opt_constant_variable.cpp \
> > diff --git a/src/glsl/glsl_parser_extras.cpp 
> > b/src/glsl/glsl_parser_extras.cpp
> > index 9f79313..f19804b 100644
> > --- a/src/glsl/glsl_parser_extras.cpp
> > +++ b/src/glsl/glsl_parser_extras.cpp
> > @@ -1627,6 +1627,7 @@ do_common_optimization(exec_list *ir, bool linked,
> > }
> > progress = do_if_simplification(ir) || progress;
> > progress = opt_flatten_nested_if_blocks(ir) || progress;
> > +   progress = opt_conditional_discard(ir) || progress;
> > progress = do_copy_propagation(ir) || progress;
> > progress = do_copy_propagation_elements(ir) || progress;
> >  
> > diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
> > index 7eb861a..e6939f3 100644
> > --- a/src/glsl/ir_optimization.h
> > +++ b/src/glsl/ir_optimization.h
> > @@ -77,6 +77,7 @@ bool do_common_optimization(exec_list *ir, bool linked,
> >  bool do_rebalance_tree(exec_list *instructions);
> >  bool do_algebraic(exec_list *instructions, bool native_integers,
> >const struct gl_shader_compiler_options *options);
> > +bool opt_conditional_discard(exec_list *instructions);
> >  bool do_constant_folding(exec_list *instructions);
> >  bool do_constant_variable(exec_list *instructions);
> >  bool do_constant_variable_unlinked(exec_list *instructions);
> > diff --git a/src/glsl/opt_conditional_discard.cpp 
> > b/src/glsl/opt_conditional_discard.cpp
> > new file mode 100644
> > index 000..0905188
> > --- /dev/null
> > +++ b/src/glsl/opt_conditional_discard.cpp
> > @@ -0,0 +1,81 @@
> > +/*
> > + * Copyright © 2010 Intel Corporation
> 
> You've been sitting on this patch for a long time, eh? :)

Haha, oops :)  Yeah, that should be 2014 (October 2014).  Still a while!

> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > + * copy of this software and associated documentation files (the 
> > "Software"),
> > + * to deal in the Software without restriction, including without 
> > limitation
> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the 
> > next
> > + * paragraph) shall be included in all copies or substantial portions of 
> > the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
> > OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
> > OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> > + * DEALINGS IN THE SOFTWARE.
> > + */
> > +
> > +/**
> > + * \file opt_conditional_discard.cpp
> > + *
> > + * Replace
> > + *
> > + *if (cond) discard;
> > + *
> > + * with
> > + *
> > + *(discard )
> > + */
> > +
> > +#include "glsl_types.h"
> > +#include "ir.h"
> > +
> > +namespace {
> > +
> > +class opt_condition

Re: [Mesa-dev] [PATCH] glsl: Rewrite and fix min/max to saturate optimization.

2015-02-24 Thread Matt Turner
On Tue, Feb 24, 2015 at 11:47 AM, Ian Romanick  wrote:
> On 02/24/2015 11:22 AM, Matt Turner wrote:
>> There were some bugs, and the code was really difficult to follow. We
>> would optimize
>>
>>min(max(x, b), 1.0) into max(sat(x), b)
>>
>> but not pay attention to the order of min/max and also do
>>
>>max(min(x, b), 1.0) into max(sat(x), b)
>>
>> Corrects four shaders from Champions of Regnum that do
>>
>>min(max(x, 1), 10)
>>
>> Cc: "10.5" 
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89180
>
> Based on the bug report, I think this same issue exists in 10.4.
> There's going to be one more 10.4 release, so we should tag this patch
> for 10.4 too.

Good point. In that case I'll send 49e04312 for 10.4 as well.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: add a missing GS support check in GetActiveUniformBlockiv

2015-02-24 Thread Marek Olšák
I'm not aware of any radeon parts capable of UBOs and not capable of GS.

Marek

On Tue, Feb 24, 2015 at 8:10 PM, Ian Romanick  wrote:
> Nice catch... are there still any platforms in Mesa that support UBOs
> (part of OpenGL 3.1) but not geometry shaders (part of OpenGL 3.2)?  I
> guess there are a couple Intel platforms where we could probably enable
> UBOs but will never have geometry shaders (Iron Lake)...
>
> Either way,
>
> Reviewed-by: Ian Romanick 
>
> On 02/23/2015 12:02 PM, Marek Olšák wrote:
>> From: Marek Olšák 
>>
>> ---
>>  src/mesa/main/uniforms.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
>> index e471b87..4bb3dfb 100644
>> --- a/src/mesa/main/uniforms.c
>> +++ b/src/mesa/main/uniforms.c
>> @@ -1142,6 +1142,8 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
>>return;
>>
>> case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER:
>> +  if (!_mesa_has_geometry_shaders(ctx))
>> + break;
>>params[0] = 
>> shProg->UniformBlockStageIndex[MESA_SHADER_GEOMETRY][uniformBlockIndex] != 
>> -1;
>>return;
>>
>>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 9/9] glsl: optimize (0 cmp x + y) into (-x cmp y).

2015-02-24 Thread Ian Romanick
This patch is

Reviewed-by: Ian Romanick 

Please also add the following to the commit message:

Cc: "10.4 10.5" 

If you guys have the time, I'd also really appreciate a piglit test or
two for this case.

On 02/24/2015 10:02 AM, Eduardo Lima Mitev wrote:
> From: Samuel Iglesias Gonsalvez 
> 
> The optimization done by commit 34ec1a24d did not take it into account.
> 
> Fixes:
> 
> dEQP-GLES3.functional.shaders.random.all_features.fragment.20
> 
> Signed-off-by: Samuel Iglesias Gonsalvez 
> ---
>  src/glsl/opt_algebraic.cpp | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
> index c6f4a9c..8183d57 100644
> --- a/src/glsl/opt_algebraic.cpp
> +++ b/src/glsl/opt_algebraic.cpp
> @@ -578,9 +578,18 @@ ir_algebraic_visitor::handle_expression(ir_expression 
> *ir)
>   if (!is_vec_zero(zero))
>  continue;
>  
> - return new(mem_ctx) ir_expression(ir->operation,
> -   add->operands[0],
> -   neg(add->operands[1]));
> + /* Depending of the zero position we want to optimize
> +  * (0 cmp x+y) into (-x cmp y) or (x+y cmp 0) into (x cmp -y)
> +  */
> + if (add_pos == 1) {
> +return new(mem_ctx) ir_expression(ir->operation,
> +  neg(add->operands[0]),
> +  add->operands[1]);
> + } else {
> +return new(mem_ctx) ir_expression(ir->operation,
> +  add->operands[0],
> +  neg(add->operands[1]));
> + }
>}
>break;
>  
> 

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


[Mesa-dev] [PATCH 2/2] Revert "i965/fs: Remove force_writemask_all assertion for execsize < 8."

2015-02-24 Thread Matt Turner
This reverts commit 0d8f27eab7b7e8b7a16e76aabd3f6a0ab4880497.

"This doesn't seem to be necessary." <- I was wrong!
---
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 86cc667..cbe6191 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1596,6 +1596,7 @@ fs_generator::generate_code(const cfg_t *cfg, int 
dispatch_width)
   case 1:
   case 2:
   case 4:
+ assert(inst->force_writemask_all);
  brw_set_default_compression_control(p, BRW_COMPRESSION_NONE);
  break;
   case 8:
-- 
2.0.5

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


[Mesa-dev] [PATCH 1/2] i965/fs: Emit MOV(1) instructions with force_writemask_all.

2015-02-24 Thread Matt Turner
Fixes rendering with Dolphin.
---
 src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
index 6acd3fe..7ddb253 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
@@ -270,6 +270,7 @@ fs_visitor::opt_combine_constants()
   struct imm *imm = &table.imm[i];
 
   fs_inst *mov = MOV(reg, fs_reg(imm->val));
+  mov->force_writemask_all = true;
   if (imm->inst) {
  imm->inst->insert_before(imm->block, mov);
   } else {
-- 
2.0.5

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


Re: [Mesa-dev] [PATCH 1/2] dri/common: Update comment about driQueryRendererIntegerCommon

2015-02-24 Thread Ian Romanick
Series is

Reviewed-by: Ian Romanick 

On 02/24/2015 11:08 AM, Andreas Boll wrote:
> Since 87d3ae0b45b6b6bb50b583dafa55eb109449a005
> driQueryRendererIntegerCommon handles __DRI2_RENDERER_PREFFERED_PROFILE
> too.
> 
> Cc: Ian Romanick 
> Signed-off-by: Andreas Boll 
> ---
>  src/mesa/drivers/dri/common/utils.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/mesa/drivers/dri/common/utils.c 
> b/src/mesa/drivers/dri/common/utils.c
> index f2e63c0..ccdc971 100644
> --- a/src/mesa/drivers/dri/common/utils.c
> +++ b/src/mesa/drivers/dri/common/utils.c
> @@ -485,6 +485,7 @@ driIndexConfigAttrib(const __DRIconfig *config, int index,
>   * Currently only the following queries are supported by this function:
>   *
>   * - \c __DRI2_RENDERER_VERSION
> + * - \c __DRI2_RENDERER_PREFERRED_PROFILE
>   * - \c __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION
>   * - \c __DRI2_RENDERER_OPENGL_COMPATIBLITY_PROFILE_VERSION
>   * - \c __DRI2_RENDERER_ES_PROFILE_VERSION
> 

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


Re: [Mesa-dev] [PATCH 4/4] i965: Force miptrees for BOs to have all slices in each lod.

2015-02-24 Thread Laura Ekstrand
Ken and I discussed doing this only for when mt->first_layer ==
mt->last_layer
and decided to try this instead.  In testing, it didn't seem to impact
other platforms (I used jenkins).

Still, after poking at this again today and talking with Jason, I think
that the best long term solution is to send a v2 such as you suggested
where I eliminate any chance that the user will try to create an array
texture for the pbo in meta_texsubimage.  This will most likely involve
reverting commits such as 404660e.

As far as this particular patch is concerned, since it doesn't actually fix
a known issue, let's discard it for now.

On Mon, Feb 23, 2015 at 11:57 AM, Neil Roberts  wrote:

> Is this patch no longer relevant considering the earlier patches make it
> no longer use array textures?
>
> Otherwise, does this work for gens other than 7? If I've understood the
> bspec correctly, only Gen7 has the surface array spacing option in the
> surface state so it's not possible to choose this layout on other gens.
> I think on Gen6 this layout gets chosen for you depending on certain
> circumstances. On Gen8+ you can get the same benefit as this layout by
> just picking your own qpitch value that doesn't include space for the
> mipmaps. I have posted a patch for Skylake which effectively implements
> this by using mt->total_height for the qpitch value as this will either
> have space for the mipmaps or not depending on the values of
> mt->first_level and mt->last_level.
>
> http://lists.freedesktop.org/archives/mesa-dev/2015-February/077607.html
>
> We might want to do something like your patch for Gen7 but in
> intel_miptree_create_layout instead of intel_miptree_create_for_bo. We
> can make it pick the ALL_SLICES_AT_EACH_LOD layout whenever
> mt->first_level==mt->last_level in addition to the other cases where it
> is chosen.
>
> For Gen8 I think setting that will magically make it pick a qpitch value
> that will make it work, but it'd be a bit weird because it won't really
> be using the ALL_SLICES_AT_EACH_LOD layout and it will only be correct
> if there are no mipmaps. Instead it might be better to handle it
> directly when picking the qpitch value like the Skylake patch.
>
> Regards,
> - Neil
>
> Laura Ekstrand  writes:
>
> > Textures made expressly for internal buffer objects shouldn't have extra
> > padding around them, but should be densely packed.
> > ---
> >  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > index 0e3888f..b46532d 100644
> > --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > @@ -724,7 +724,7 @@ intel_miptree_create_for_bo(struct brw_context *brw,
> > mt = intel_miptree_create_layout(brw, target, format,
> >  0, 0,
> >  width, height, depth,
> > -true, 0, false);
> > +true, 0, true);
> > if (!mt) {
> >free(mt);
> >return mt;
> > --
> > 2.1.0
> >
> > ___
> > 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 3/4] st/mesa: remove unused/broken function st_print_shaders

2015-02-24 Thread Brian Paul

On 02/24/2015 01:16 PM, Marek Olšák wrote:

The function is pretty old. I don't know if anybody still needs it.

Brian, what do you think about this patch?


I'm OK with removing it.  I haven't used it in a long time and I can 
always fish it out of git if I need it again.


-Brian



There is a similar function that does more or less the same thing and
is more explicit about gdb usage (st_debug.c):

/**
  * Print current state.  May be called from inside gdb to see currently
  * bound vertex/fragment shaders and associated constants.
  */
void
st_print_current(void)

Marek

On Tue, Feb 24, 2015 at 5:06 AM, Michel Dänzer  wrote:

On 24.02.2015 05:02, Marek Olšák wrote:

From: Marek Olšák 

---
  src/mesa/state_tracker/st_program.c | 45 -
  src/mesa/state_tracker/st_program.h |  4 
  2 files changed, 49 deletions(-)

diff --git a/src/mesa/state_tracker/st_program.c 
b/src/mesa/state_tracker/st_program.c
index ec123fb..744543f 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1219,51 +1219,6 @@ st_get_gp_variant(struct st_context *st,
  }


-
-
-/**
- * Debug- print current shader text
- */
-void
-st_print_shaders(struct gl_context *ctx)


I think the idea is to be able to call this function from a debugger.


--
Earthling Michel Dänzer   |   
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.amd.com&d=AwIFaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=LoZp-V4O30MRAvvjnbyUAG7D_cc8LD29EAoUOsiATqk&s=vKevzSHJdAckIcmZZ4H4aQ3KXY2Ij2AWKwleP19uHn8&e=
Libre software enthusiast | Mesa and X developer


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


Re: [Mesa-dev] [PATCH] auxilary/os: correct sysctl use in os_get_total_physical_memory()

2015-02-24 Thread Jonathan Gray
On Tue, Feb 24, 2015 at 04:53:03PM +, Emil Velikov wrote:
> On 22 February 2015 at 08:19, Jonathan Gray  wrote:
> > The length argument passed to sysctl was the size of the pointer
> > not the type.  The result of this is sysctl calls would fail on
> > 32 bit BSD/Mac OS X.
> >
> > Additionally the wrong pointer was passed as an argument to store
> > the result of the sysctl call.
> >
> > Cc: "10.4, 10.5" 
> > Signed-off-by: Jonathan Gray 
> Seems like my attempt was enough but not quite there yet.
> Thanks for fixing my goof-up.
> 
> Reviewed-by: Emil Velikov 
> 
> I'll push this in a couple of days unless there are any objections.
> 
> Cheers
> Emil

It should be possible to use the sysconf path in more places
as well.  Classic swrast for example doesn't use sysctl at all.

OpenBSD/FreeBSD have _SC_PHYS_PAGES/_SC_PAGE_SIZE
NetBSD/Mac OS X don't document _SC_PAGE_SIZE but do document
_SC_PAGESIZE, though I wouldn't be surprised if they
had _SC_PAGE_SIZE in their headers.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] common: Correct texture init for meta pbo uploads and downloads.

2015-02-24 Thread Laura Ekstrand
This moves the line setting immutability for the texture to after
_mesa_initialize_texture_object so that the initializer function will not
cancel it out. Moreover, because of the ARB_texture_view extension, immutable
textures must have NumLayers > 0, or depth will equal (0-1)=0x during
SURFACE_STATE setup, which triggers assertions.

v2: Review from Kenneth Graunke:
   - Include more explanation in the commit message.
   - Make texture setup bug fixes into a separate patch.
---
 src/mesa/drivers/common/meta_tex_subimage.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
b/src/mesa/drivers/common/meta_tex_subimage.c
index 68c8273..2d2b9d8 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -100,8 +100,11 @@ create_texture_for_pbo(struct gl_context *ctx, bool 
create_pbo,
_mesa_GenTextures(1, tmp_tex);
tex_obj = _mesa_lookup_texture(ctx, *tmp_tex);
tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
-   tex_obj->Immutable = GL_TRUE;
_mesa_initialize_texture_object(ctx, tex_obj, *tmp_tex, GL_TEXTURE_2D);
+   /* This must be set after _mesa_initialize_texture_object, not before. */
+   tex_obj->Immutable = GL_TRUE;
+   /* This is required for interactions with ARB_texture_view. */
+   tex_obj->NumLayers = 1;
 
internal_format = _mesa_get_format_base_format(pbo_format);
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 2/2] common: Correct PBO 2D_ARRAY handling.

2015-02-24 Thread Laura Ekstrand
Changes PBO uploads and downloads to use a tall (height * depth) 2D texture
for blitting. This fixes the bug where 2D_ARRAY, 3D, and CUBE_MAP_ARRAY
textures are not properly uploaded and downloaded.

Removes the option to use a 2D ARRAY texture for the PBO during upload and
download.  This option didn't work because the miptree couldn't be set up
reliably.

v2: Review from Jason Ekstrand and Neil Roberts:
   -Delete the depth parameter from create_texture_for_pbo
   -Abandon the option to create a 2D ARRAY texture in create_texture_for_pbo
---
 src/mesa/drivers/common/meta_tex_subimage.c | 26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
b/src/mesa/drivers/common/meta_tex_subimage.c
index 2d2b9d8..b659426 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -44,7 +44,7 @@
 
 static struct gl_texture_image *
 create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,
-   GLenum pbo_target, int width, int height, int depth,
+   GLenum pbo_target, int width, int height,
GLenum format, GLenum type, const void *pixels,
const struct gl_pixelstore_attrib *packing,
GLuint *tmp_pbo, GLuint *tmp_tex)
@@ -57,8 +57,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool 
create_pbo,
struct gl_texture_image *tex_image;
bool read_only;
 
-   if ((packing->ImageHeight != 0 && packing->ImageHeight != height) ||
-   packing->SwapBytes ||
+   if (packing->SwapBytes ||
packing->LsbFirst ||
packing->Invert)
   return NULL;
@@ -99,7 +98,6 @@ create_texture_for_pbo(struct gl_context *ctx, bool 
create_pbo,
 
_mesa_GenTextures(1, tmp_tex);
tex_obj = _mesa_lookup_texture(ctx, *tmp_tex);
-   tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
_mesa_initialize_texture_object(ctx, tex_obj, *tmp_tex, GL_TEXTURE_2D);
/* This must be set after _mesa_initialize_texture_object, not before. */
tex_obj->Immutable = GL_TRUE;
@@ -109,7 +107,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool 
create_pbo,
internal_format = _mesa_get_format_base_format(pbo_format);
 
tex_image = _mesa_get_tex_image(ctx, tex_obj, tex_obj->Target, 0);
-   _mesa_init_teximage_fields(ctx, tex_image, width, height, depth,
+   _mesa_init_teximage_fields(ctx, tex_image, width, height, 1,
   0, internal_format, pbo_format);
 
read_only = pbo_target == GL_PIXEL_UNPACK_BUFFER;
@@ -169,9 +167,14 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint 
dims,
   return true;
}
 
+   /* Only accept tightly packed pixels from the user. */
+   if (packing->ImageHeight != 0 && packing->ImageHeight != height)
+  return false;
+
+   /* For arrays, use a tall (height * depth) 2D texture. */
pbo_tex_image = create_texture_for_pbo(ctx, create_pbo,
   GL_PIXEL_UNPACK_BUFFER,
-  width, height, depth,
+  width, height * depth,
   format, type, pixels, packing,
   &pbo, &pbo_tex);
if (!pbo_tex_image)
@@ -225,7 +228,7 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint 
dims,
   _mesa_update_state(ctx);
 
   _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
- 0, 0, width, height,
+ 0, z * height, width, (z + 1) * height,
  xoffset, yoffset,
  xoffset + width, yoffset + height,
  GL_COLOR_BUFFER_BIT, GL_NEAREST);
@@ -285,8 +288,13 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
   return true;
}
 
+   /* Only accept tightly packed pixels from the user. */
+   if (packing->ImageHeight != 0 && packing->ImageHeight != height)
+  return false;
+
+   /* For arrays, use a tall (height * depth) 2D texture. */
pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER,
-  width, height, depth,
+  width, height * depth,
   format, type, pixels, packing,
   &pbo, &pbo_tex);
if (!pbo_tex_image)
@@ -347,7 +355,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
GLuint dims,
   _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
  xoffset, yoffset,
  xoffset + width, yoffset + height,
- 0, 0, width, height,
+ 0, z * height, width, (z + 1) * height,
 

[Mesa-dev] [PATCH 5/6] mesa: remove MAX_GLUSHORT, move MAX_GLUINT

2015-02-24 Thread Brian Paul
The later is only used in one place in swrast.
---
 src/mesa/main/imports.h | 3 ---
 src/mesa/swrast/s_tritemp.h | 5 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 82b3213..356f0e1 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -83,9 +83,6 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
  * Math macros
  */
 
-#define MAX_GLUSHORT   0x
-#define MAX_GLUINT 0x
-
 /* Degrees to radians conversion: */
 #define DEG2RAD (M_PI/180.0)
 
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index f0281e4..fb73b2d 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -91,6 +91,11 @@
  */
 
 
+#ifndef MAX_GLUINT
+#define MAX_GLUINT 0x
+#endif
+
+
 /*
  * Some code we unfortunately need to prevent negative interpolated colors.
  */
-- 
1.9.1

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


[Mesa-dev] [PATCH 1/6] mesa: remove sqrtf macro

2015-02-24 Thread Brian Paul
---
 src/mesa/main/imports.h | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index df6a3fe..7fb9381 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -90,17 +90,6 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
 #define DEG2RAD (M_PI/180.0)
 
 
-/**
- * \name Work-arounds for platforms that lack C99 math functions
- */
-/*@{*/
-#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && 
!defined(_ISOC99_SOURCE) \
-   && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \
-   && (!defined(_MSC_VER) || (_MSC_VER < 1400))
-
-#define sqrtf(f) ((float) sqrt(f))
-#endif
-
 #if defined(_MSC_VER)
 #if _MSC_VER < 1800  /* Not req'd on VS2013 and above */
 static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; }
-- 
1.9.1

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


[Mesa-dev] [PATCH 2/6] glcpp: remove unneeded #include of core.h

2015-02-24 Thread Brian Paul
isblank() is not used in the code.
---
 src/glsl/glcpp/pp.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c
index a54bcbe..160c666 100644
--- a/src/glsl/glcpp/pp.c
+++ b/src/glsl/glcpp/pp.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include "glcpp.h"
-#include "main/core.h" /* for isblank() on MSVC */
 
 void
 glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
-- 
1.9.1

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


[Mesa-dev] [PATCH 6/6] mesa: remove DEG2RAD macro

2015-02-24 Thread Brian Paul
---
 src/mesa/main/imports.h  | 8 
 src/mesa/main/light.c| 2 +-
 src/mesa/math/m_matrix.c | 4 ++--
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 356f0e1..d886427 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -79,14 +79,6 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
 
 
 
-/**
- * Math macros
- */
-
-/* Degrees to radians conversion: */
-#define DEG2RAD (M_PI/180.0)
-
-
 #if defined(_MSC_VER)
 #if _MSC_VER < 1800  /* Not req'd on VS2013 and above */
 #define strtoll(p, e, b) _strtoi64(p, e, b)
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index c4d3a53..4021dbe 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -156,7 +156,7 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum 
pname, const GLfloat *pa
  return;
   FLUSH_VERTICES(ctx, _NEW_LIGHT);
   light->SpotCutoff = params[0];
-  light->_CosCutoff = (GLfloat) (cos(light->SpotCutoff * DEG2RAD));
+  light->_CosCutoff = (GLfloat) (cos(light->SpotCutoff * M_PI / 180.0));
   if (light->_CosCutoff < 0)
  light->_CosCutoff = 0;
   if (light->SpotCutoff != 180.0F)
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index 9d51021..0475a7a 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -799,8 +799,8 @@ _math_matrix_rotate( GLmatrix *mat,
GLfloat m[16];
GLboolean optimized;
 
-   s = (GLfloat) sin( angle * DEG2RAD );
-   c = (GLfloat) cos( angle * DEG2RAD );
+   s = (GLfloat) sin( angle * M_PI / 180.0 );
+   c = (GLfloat) cos( angle * M_PI / 180.0 );
 
memcpy(m, Identity, sizeof(GLfloat)*16);
optimized = GL_FALSE;
-- 
1.9.1

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


[Mesa-dev] [PATCH 4/6] mesa: move signbit() macro to c99_math.h

2015-02-24 Thread Brian Paul
---
 include/c99_math.h  | 8 
 src/mesa/main/imports.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/c99_math.h b/include/c99_math.h
index 147bcee..9e31d06 100644
--- a/include/c99_math.h
+++ b/include/c99_math.h
@@ -202,4 +202,12 @@ llrintf(float f)
 #endif /* C99 */
 
 
+/*
+ * signbit() is a macro on Linux.  Not available on Windows.
+ */
+#ifndef signbit
+#define signbit(x) ((x) < 0.0f)
+#endif
+
+
 #endif /* #define _C99_MATH_H_ */
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index a6e4d9e..82b3213 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -99,14 +99,6 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
 /*@}*/
 
 
-/*
- * signbit() is a macro on Linux.  Not available on Windows.
- */
-#ifndef signbit
-#define signbit(x) ((x) < 0.0f)
-#endif
-
-
 /***
  *** LOG2: Log base 2 of float
  ***/
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH 1/6] mesa: remove sqrtf macro

2015-02-24 Thread Matt Turner
This series is also

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


Re: [Mesa-dev] [PATCH 05/16] main: Added entry point for glTransformFeedbackBufferBase

2015-02-24 Thread Laura Ekstrand
Looks good to me.

Reviewed-by: Laura Ekstrand 

On Mon, Feb 23, 2015 at 6:47 AM, Martin Peres 
wrote:

> v2: Review from Laura Ekstrand
> - give more helpful error messages
> - factor the lookup code for the xfb and objBuf
> - replace some already-existing tabs with spaces
> - add comments to explain the cases where xfb == 0 or buffer == 0
> - fix the condition for binding the transform buffer or not
>
> v3: Review from Laura Ekstrand
> - rename _mesa_lookup_bufferobj_err to
>   _mesa_lookup_transform_feedback_bufferobj_err and make it static to
> avoid a
>   future conflict
> - make _mesa_lookup_transform_feedback_object_err static
>
> v4: Review from Laura Ekstrand
> - add the pdf page number when quoting the spec
> - rename some of the symbols to follow the public/private conventions
>
> v5: Review from Laura Ekstrand
> - properly rename some of the symbols to follow the public/private
> conventions
> - fix some alignments
> - add quotes around a spec citation
> - add back a newline I accidentally deleted
> - add spaces around the ternary operator usages
>
> Signed-off-by: Martin Peres 
> ---
>  src/mapi/glapi/gen/ARB_direct_state_access.xml |   6 ++
>  src/mesa/main/bufferobj.c  |   9 +-
>  src/mesa/main/tests/dispatch_sanity.cpp|   1 +
>  src/mesa/main/transformfeedback.c  | 138
> +++--
>  src/mesa/main/transformfeedback.h  |  10 +-
>  5 files changed, 129 insertions(+), 35 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> index 15b00c2..35d6906 100644
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> @@ -14,6 +14,12 @@
>
> 
>
> +   
> +  
> +  
> +  
> +   
> +
> 
>
> 
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index b372c68..96d43c8 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -3575,8 +3575,9 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
>
> switch (target) {
> case GL_TRANSFORM_FEEDBACK_BUFFER:
> -  _mesa_bind_buffer_range_transform_feedback(ctx, index, bufObj,
> -offset, size);
> +  _mesa_bind_buffer_range_transform_feedback(ctx,
> +
>  ctx->TransformFeedback.CurrentObject,
> + index, bufObj, offset,
> size);
>return;
> case GL_UNIFORM_BUFFER:
>bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size);
> @@ -3640,7 +3641,9 @@ _mesa_BindBufferBase(GLenum target, GLuint index,
> GLuint buffer)
>
> switch (target) {
> case GL_TRANSFORM_FEEDBACK_BUFFER:
> -  _mesa_bind_buffer_base_transform_feedback(ctx, index, bufObj);
> +  _mesa_bind_buffer_base_transform_feedback(ctx,
> +
> ctx->TransformFeedback.CurrentObject,
> +index, bufObj, false);
>return;
> case GL_UNIFORM_BUFFER:
>bind_buffer_base_uniform_buffer(ctx, index, bufObj);
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp
> b/src/mesa/main/tests/dispatch_sanity.cpp
> index c37ce95..3195abb 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -956,6 +956,7 @@ const struct function gl_core_functions_possible[] = {
>
> /* GL_ARB_direct_state_access */
> { "glCreateTransformFeedbacks", 45, -1 },
> +   { "glTransformFeedbackBufferBase", 45, -1 },
> { "glCreateTextures", 45, -1 },
> { "glTextureStorage1D", 45, -1 },
> { "glTextureStorage2D", 45, -1 },
> diff --git a/src/mesa/main/transformfeedback.c
> b/src/mesa/main/transformfeedback.c
> index 10bb6a1..159fa62 100644
> --- a/src/mesa/main/transformfeedback.c
> +++ b/src/mesa/main/transformfeedback.c
> @@ -514,22 +514,24 @@ _mesa_EndTransformFeedback(void)
>   * Helper used by BindBufferRange() and BindBufferBase().
>   */
>  static void
> -bind_buffer_range(struct gl_context *ctx, GLuint index,
> +bind_buffer_range(struct gl_context *ctx,
> +  struct gl_transform_feedback_object *obj,
> +  GLuint index,
>struct gl_buffer_object *bufObj,
> -  GLintptr offset, GLsizeiptr size)
> +  GLintptr offset, GLsizeiptr size,
> +  bool dsa)
>  {
> -   struct gl_transform_feedback_object *obj =
> -  ctx->TransformFeedback.CurrentObject;
> -
> /* Note: no need to FLUSH_VERTICES or flag NewTransformFeedback,
> because
>  * transform feedback buffers can't be changed while transform
> feedback is
>  * active.
>  */
>
> -   /* The general binding point */
> -   _mesa_reference_buffer_object(ctx,
> - &ctx->TransformFeedback.CurrentBuffer,
> - bufObj);
> +   if (!dsa) {
> +  /* The general binding point */
> +  _mesa_refer

Re: [Mesa-dev] [PATCH 1/2] common: Correct texture init for meta pbo uploads and downloads.

2015-02-24 Thread Ian Romanick
Series is

Reviewed-by: Ian Romanick 

Should probably wait for Anuj, Neil, or Jason to respond to patch 2.
They know the code here much better than I.

On 02/24/2015 03:20 PM, Laura Ekstrand wrote:
> This moves the line setting immutability for the texture to after
> _mesa_initialize_texture_object so that the initializer function will not
> cancel it out. Moreover, because of the ARB_texture_view extension, immutable
> textures must have NumLayers > 0, or depth will equal (0-1)=0x during
> SURFACE_STATE setup, which triggers assertions.
> 
> v2: Review from Kenneth Graunke:
>- Include more explanation in the commit message.
>- Make texture setup bug fixes into a separate patch.
> ---
>  src/mesa/drivers/common/meta_tex_subimage.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
> b/src/mesa/drivers/common/meta_tex_subimage.c
> index 68c8273..2d2b9d8 100644
> --- a/src/mesa/drivers/common/meta_tex_subimage.c
> +++ b/src/mesa/drivers/common/meta_tex_subimage.c
> @@ -100,8 +100,11 @@ create_texture_for_pbo(struct gl_context *ctx, bool 
> create_pbo,
> _mesa_GenTextures(1, tmp_tex);
> tex_obj = _mesa_lookup_texture(ctx, *tmp_tex);
> tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
> -   tex_obj->Immutable = GL_TRUE;
> _mesa_initialize_texture_object(ctx, tex_obj, *tmp_tex, GL_TEXTURE_2D);
> +   /* This must be set after _mesa_initialize_texture_object, not before. */
> +   tex_obj->Immutable = GL_TRUE;
> +   /* This is required for interactions with ARB_texture_view. */
> +   tex_obj->NumLayers = 1;
>  
> internal_format = _mesa_get_format_base_format(pbo_format);
>  
> 

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


Re: [Mesa-dev] [PATCH 1/2] common: Correct texture init for meta pbo uploads and downloads.

2015-02-24 Thread Jason Ekstrand
On Tue, Feb 24, 2015 at 4:17 PM, Ian Romanick  wrote:

> Series is
>
> Reviewed-by: Ian Romanick 
>
> Should probably wait for Anuj, Neil, or Jason to respond to patch 2.
> They know the code here much better than I.
>

Heh... I was waiting for someone else to look at it before I gave an R-B
and scarred them off.  I wanted a second set of eyes.  So here's mine now.

Reviewed-by: Jason Ekstrand 

for the series.
--Jason


> On 02/24/2015 03:20 PM, Laura Ekstrand wrote:
> > This moves the line setting immutability for the texture to after
> > _mesa_initialize_texture_object so that the initializer function will not
> > cancel it out. Moreover, because of the ARB_texture_view extension,
> immutable
> > textures must have NumLayers > 0, or depth will equal (0-1)=0x
> during
> > SURFACE_STATE setup, which triggers assertions.
> >
> > v2: Review from Kenneth Graunke:
> >- Include more explanation in the commit message.
> >- Make texture setup bug fixes into a separate patch.
> > ---
> >  src/mesa/drivers/common/meta_tex_subimage.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/drivers/common/meta_tex_subimage.c
> b/src/mesa/drivers/common/meta_tex_subimage.c
> > index 68c8273..2d2b9d8 100644
> > --- a/src/mesa/drivers/common/meta_tex_subimage.c
> > +++ b/src/mesa/drivers/common/meta_tex_subimage.c
> > @@ -100,8 +100,11 @@ create_texture_for_pbo(struct gl_context *ctx, bool
> create_pbo,
> > _mesa_GenTextures(1, tmp_tex);
> > tex_obj = _mesa_lookup_texture(ctx, *tmp_tex);
> > tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
> > -   tex_obj->Immutable = GL_TRUE;
> > _mesa_initialize_texture_object(ctx, tex_obj, *tmp_tex,
> GL_TEXTURE_2D);
> > +   /* This must be set after _mesa_initialize_texture_object, not
> before. */
> > +   tex_obj->Immutable = GL_TRUE;
> > +   /* This is required for interactions with ARB_texture_view. */
> > +   tex_obj->NumLayers = 1;
> >
> > internal_format = _mesa_get_format_base_format(pbo_format);
> >
> >
>
> ___
> 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 1/2] i965/fs: Emit MOV(1) instructions with force_writemask_all.

2015-02-24 Thread Markus Wick

Am 2015-02-24 21:26, schrieb Matt Turner:

Fixes rendering with Dolphin.
---
 src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
index 6acd3fe..7ddb253 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
@@ -270,6 +270,7 @@ fs_visitor::opt_combine_constants()
   struct imm *imm = &table.imm[i];

   fs_inst *mov = MOV(reg, fs_reg(imm->val));
+  mov->force_writemask_all = true;
   if (imm->inst) {
  imm->inst->insert_before(imm->block, mov);
   } else {


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


[Mesa-dev] [PATCH v6] mesa: use fi_type in vertex attribute code

2015-02-24 Thread marius . predut
From: Marius Predut 

For 32-bit builds, floating point operations use x86 FPU registers,
not SSE registers.  If we're actually storing an integer in a float
variable, the value might get modified when written to memory.  This
patch changes the VBO code to use the fi_type (float/int union) to
store/copy vertex attributes.

Also, this can improve performance on x86 because moving floats with
integer registers instead of FP registers is faster.

Neil Roberts review:
- include changes on all places that are storing attribute values.
- check with and without -O3 compiler flag.
Brian Paul review:
- use fi_type type instead gl_constant_value type
- fix a bunch of nit-picks.
- fix compiler warnings

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82668
Signed-off-by: Marius Predut 
---
 src/mesa/main/context.c   |3 ++-
 src/mesa/main/macros.h|   34 ++
 src/mesa/vbo/vbo_attrib_tmp.h |   22 ++
 src/mesa/vbo/vbo_context.h|   14 +++---
 src/mesa/vbo/vbo_exec.h   |   11 ++-
 src/mesa/vbo/vbo_exec_api.c   |   36 ++--
 src/mesa/vbo/vbo_exec_draw.c  |8 
 src/mesa/vbo/vbo_exec_eval.c  |   24 +---
 src/mesa/vbo/vbo_save.h   |   18 +-
 src/mesa/vbo/vbo_save_api.c   |   34 +-
 src/mesa/vbo/vbo_save_draw.c  |   10 +-
 11 files changed, 117 insertions(+), 97 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 63d30a2..f0597e2 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -134,6 +134,7 @@
 #include "math/m_matrix.h"
 #include "main/dispatch.h" /* for _gloffset_COUNT */
 #include "uniforms.h"
+#include "macros.h"
 
 #ifdef USE_SPARC_ASM
 #include "sparc/sparc.h"
@@ -656,7 +657,7 @@ _mesa_init_constants(struct gl_constants *consts, gl_api 
api)
consts->MaxSamples = 0;
 
/* GLSL default if NativeIntegers == FALSE */
-   consts->UniformBooleanTrue = FLT_AS_UINT(1.0f);
+   consts->UniformBooleanTrue = FLOAT_AS_UNION(1.0f).u;
 
/* GL_ARB_sync */
consts->MaxServerWaitTimeout = 0x1fff7fffULL;
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 2d59c6f..70d0556 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -170,25 +170,25 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
ub = ((GLubyte) F_TO_I((f) * 255.0F))
 #endif
 
-static inline GLfloat INT_AS_FLT(GLint i)
+static fi_type UINT_AS_UNION(GLuint u)
 {
fi_type tmp;
-   tmp.i = i;
-   return tmp.f;
+   tmp.u = u;
+   return tmp;
 }
 
-static inline GLfloat UINT_AS_FLT(GLuint u)
+static inline fi_type INT_AS_UNION(GLint i)
 {
fi_type tmp;
-   tmp.u = u;
-   return tmp.f;
+   tmp.i = i;
+   return tmp;
 }
 
-static inline unsigned FLT_AS_UINT(float f)
+static inline fi_type FLOAT_AS_UNION(GLfloat f)
 {
fi_type tmp;
tmp.f = f;
-   return tmp.u;
+   return tmp;
 }
 
 /**
@@ -620,24 +620,26 @@ do {  \
  * The default values are chosen based on \p type.
  */
 static inline void
-COPY_CLEAN_4V_TYPE_AS_FLOAT(GLfloat dst[4], int sz, const GLfloat src[4],
+COPY_CLEAN_4V_TYPE_AS_UNION(fi_type dst[4], int sz, const fi_type src[4],
 GLenum type)
 {
switch (type) {
case GL_FLOAT:
-  ASSIGN_4V(dst, 0, 0, 0, 1);
+  ASSIGN_4V(dst, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0),
+FLOAT_AS_UNION(0), FLOAT_AS_UNION(1));
   break;
case GL_INT:
-  ASSIGN_4V(dst, INT_AS_FLT(0), INT_AS_FLT(0),
- INT_AS_FLT(0), INT_AS_FLT(1));
+  ASSIGN_4V(dst, INT_AS_UNION(0), INT_AS_UNION(0),
+INT_AS_UNION(0), INT_AS_UNION(1));
   break;
case GL_UNSIGNED_INT:
-  ASSIGN_4V(dst, UINT_AS_FLT(0), UINT_AS_FLT(0),
- UINT_AS_FLT(0), UINT_AS_FLT(1));
+  ASSIGN_4V(dst, UINT_AS_UNION(0), UINT_AS_UNION(0),
+UINT_AS_UNION(0), UINT_AS_UNION(1));
   break;
default:
-  ASSIGN_4V(dst, 0.0f, 0.0f, 0.0f, 1.0f); /* silence warnings */
-  ASSERT(!"Unexpected type in COPY_CLEAN_4V_TYPE_AS_FLOAT macro");
+  ASSIGN_4V(dst, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0),
+FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); /* silence warnings */
+  ASSERT(!"Unexpected type in COPY_CLEAN_4V_TYPE_AS_UNION macro");
}
COPY_SZ_4V(dst, sz, src);
 }
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index ec66934..80e8aaf 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -28,6 +28,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "util/u_format_r11g11b10f.h"
 #include "main/varray.h"
 
+
+/* ATTR */
+#define ATTR( A, N, T, V0, V1, V2, V3 ) \
+ATTR_##T((A), (N), (T), (V0), (V1), (V2), (V3))
+
+#define ATTR_GL_UNSIGNED_INT( A, N, T, V0, V1, V2, V3 ) \
+ATTR_UNION(A, N, T, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \
+UINT_AS

Re: [Mesa-dev] [PATCH v5] mesa: use fi_type in vertex attribute code

2015-02-24 Thread Predut, Marius
> -Original Message-
> From: Brian Paul [mailto:bri...@vmware.com]
> Sent: Friday, February 20, 2015 5:49 PM
> To: Predut, Marius; mesa-dev@lists.freedesktop.org
> Subject: Re: [Mesa-dev] [PATCH v5] mesa: use fi_type in vertex attribute code
> 
> On 02/19/2015 11:42 AM, marius.pre...@intel.com wrote:
> > From: Marius Predut 
> >
> > For 32-bit builds, floating point operations use x86 FPU registers,
> > not SSE registers.  If we're actually storing an integer in a float
> > variable, the value might get modified when written to memory.  This
> > patch changes the VBO code to use the fi_type (float/int union) to
> > store/copy vertex attributes.
> >
> > Also, this can improve performance on x86 because moving floats with
> > integer registers instead of FP registers is faster.
> >
> > Neil Roberts review:
> > - include changes on all places that are storing attribute values.
> > - check with and without -O3 compiler flag.
> > Brian Paul review:
> > - use fi_type type instead gl_constant_value type
> > - fix a bunch of nit-picks.
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82668
> > Signed-off-by: Marius Predut 
> 
> Looks good.  Thanks.
> 
> Unfortunately, there's a few new compiler warnings after applying the patch.
> I'll try to fix those up before I push the patch.  I'll also do some piglit
> testing...

I am happy to hard that :-). I am looking to see it upstream!

Yes, I see, I forgot some Floats instead file_type especially on 
_playback_copy_to_current but not only.
I will send a new patch that, additionally, add "fi_type" type instead glfloat 
where I escaped.

Marius

> 
> -Brian
> 

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


Re: [Mesa-dev] [PATCH 04/14] meta: Create temporary pbo in _mesa_meta_pbo_GetTexSubImage()

2015-02-24 Thread Anuj Phogat
On Tue, Feb 24, 2015 at 8:31 AM, Neil Roberts  wrote:
> Anuj Phogat  writes:
>
>> using a flag passed in as function parameter. This will enable
>> _mesa_meta_pbo_GetTexSubImage to be used for reading in to
>> non-pbo buffers.
>>
>> This will be useful to support reading from YF/YS tiled surfaces
>> in Skylake.
>>
>> Signed-off-by: Anuj Phogat 
>> ---
>>  src/mesa/drivers/common/meta.h   |  1 +
>>  src/mesa/drivers/common/meta_tex_subimage.c  | 18 --
>>  src/mesa/drivers/dri/i965/intel_pixel_read.c |  9 -
>>  src/mesa/drivers/dri/i965/intel_tex_image.c  |  3 ++-
>>  4 files changed, 23 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
>> index e7d894d..3de0d87 100644
>> --- a/src/mesa/drivers/common/meta.h
>> +++ b/src/mesa/drivers/common/meta.h
>> @@ -542,6 +542,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
>> GLuint dims,
>>int xoffset, int yoffset, int zoffset,
>>int width, int height, int depth,
>>GLenum format, GLenum type, const void 
>> *pixels,
>> +  bool create_pbo,
>>const struct gl_pixelstore_attrib *packing);
>>
>>  extern void
>> diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
>> b/src/mesa/drivers/common/meta_tex_subimage.c
>> index 68c8273..cd87a72 100644
>> --- a/src/mesa/drivers/common/meta_tex_subimage.c
>> +++ b/src/mesa/drivers/common/meta_tex_subimage.c
>> @@ -34,6 +34,7 @@
>>  #include "macros.h"
>>  #include "meta.h"
>>  #include "pbo.h"
>> +#include "readpix.h"
>>  #include "shaderapi.h"
>>  #include "state.h"
>>  #include "teximage.h"
>> @@ -246,6 +247,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
>> GLuint dims,
>>int xoffset, int yoffset, int zoffset,
>>int width, int height, int depth,
>>GLenum format, GLenum type, const void 
>> *pixels,
>> +  bool create_pbo,
>>const struct gl_pixelstore_attrib *packing)
>>  {
>> GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 };
>> @@ -257,7 +259,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
>> GLuint dims,
>> /* XXX: This should probably be passed in from somewhere */
>> const char *where = "_mesa_meta_pbo_GetTexSubImage";
>>
>> -   if (!_mesa_is_bufferobj(packing->BufferObj))
>> +   if (!_mesa_is_bufferobj(packing->BufferObj) && !create_pbo)
>>return false;
>>
>> if (format == GL_DEPTH_COMPONENT ||
>> @@ -282,7 +284,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
>> GLuint dims,
>>return true;
>> }
>>
>> -   pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER,
>> +   pbo_tex_image = create_texture_for_pbo(ctx, create_pbo, 
>> GL_PIXEL_PACK_BUFFER,
>>width, height, depth,
>>format, type, pixels, packing,
>>&pbo, &pbo_tex);
>> @@ -348,6 +350,18 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
>> GLuint dims,
>>   GL_COLOR_BUFFER_BIT, GL_NEAREST);
>> }
>>
>> +   /* If we created a temporary pbo in meta to read the pixel data, that
>> +* data will now get copied to memory allocated by client.
>> +*/
>> +   if (create_pbo) {
>
> I think this should be changed to something like the below:
>
>  if (create_pbo && !_mesa_is_bufferobj(packing->BufferObj))
>
> It looks like the meaning of create_pbo in create_texture_for_pbo is
> ‘create pbo unless there is already a pbo’. With this patch
> _mesa_meta_pbo_GetTexSubImage seems to interpret it to mean that it will
> always create the pbo and if there already was a pbo it would end up
> clobbering the state.
>
I agree. I will make this change.
>> +  /* Unbind the pbo from pack binding. */
>> +  _mesa_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
>
> I don't think this unbind is necessary. create_texture_for_pbo is
> careful not to modify the PBO binding state and once that function is
> finished the PBO is only accessed via the texture so we shouldn't need
> to touch the PBO binding.
>
>> +  _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[1]);
>> +  _mesa_update_state(ctx);
>> +  _mesa_readpixels(ctx, 0, 0, width, height, format, type,
>> +   packing, (void *) pixels);
>
> Doesn't this only read the last slice of the texture? Maybe this patch
> should wait until this patch from Laura Ekstrand is landed:
>
> http://lists.freedesktop.org/archives/mesa-dev/2015-February/077487.html
>
I'll hold this patch until her changes land and send out a v2.

> Regards,
> - Neil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://list

Re: [Mesa-dev] [PATCH 04/14] meta: Create temporary pbo in _mesa_meta_pbo_GetTexSubImage()

2015-02-24 Thread Jason Ekstrand
On Tue, Feb 24, 2015 at 7:01 PM, Anuj Phogat  wrote:

> On Tue, Feb 24, 2015 at 8:31 AM, Neil Roberts 
> wrote:
> > Anuj Phogat  writes:
> >
> >> using a flag passed in as function parameter. This will enable
> >> _mesa_meta_pbo_GetTexSubImage to be used for reading in to
> >> non-pbo buffers.
> >>
> >> This will be useful to support reading from YF/YS tiled surfaces
> >> in Skylake.
> >>
> >> Signed-off-by: Anuj Phogat 
> >> ---
> >>  src/mesa/drivers/common/meta.h   |  1 +
> >>  src/mesa/drivers/common/meta_tex_subimage.c  | 18 --
> >>  src/mesa/drivers/dri/i965/intel_pixel_read.c |  9 -
> >>  src/mesa/drivers/dri/i965/intel_tex_image.c  |  3 ++-
> >>  4 files changed, 23 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/src/mesa/drivers/common/meta.h
> b/src/mesa/drivers/common/meta.h
> >> index e7d894d..3de0d87 100644
> >> --- a/src/mesa/drivers/common/meta.h
> >> +++ b/src/mesa/drivers/common/meta.h
> >> @@ -542,6 +542,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context
> *ctx, GLuint dims,
> >>int xoffset, int yoffset, int zoffset,
> >>int width, int height, int depth,
> >>GLenum format, GLenum type, const void
> *pixels,
> >> +  bool create_pbo,
> >>const struct gl_pixelstore_attrib
> *packing);
> >>
> >>  extern void
> >> diff --git a/src/mesa/drivers/common/meta_tex_subimage.c
> b/src/mesa/drivers/common/meta_tex_subimage.c
> >> index 68c8273..cd87a72 100644
> >> --- a/src/mesa/drivers/common/meta_tex_subimage.c
> >> +++ b/src/mesa/drivers/common/meta_tex_subimage.c
> >> @@ -34,6 +34,7 @@
> >>  #include "macros.h"
> >>  #include "meta.h"
> >>  #include "pbo.h"
> >> +#include "readpix.h"
> >>  #include "shaderapi.h"
> >>  #include "state.h"
> >>  #include "teximage.h"
> >> @@ -246,6 +247,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context
> *ctx, GLuint dims,
> >>int xoffset, int yoffset, int zoffset,
> >>int width, int height, int depth,
> >>GLenum format, GLenum type, const void
> *pixels,
> >> +  bool create_pbo,
> >>const struct gl_pixelstore_attrib
> *packing)
> >>  {
> >> GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 };
> >> @@ -257,7 +259,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context
> *ctx, GLuint dims,
> >> /* XXX: This should probably be passed in from somewhere */
> >> const char *where = "_mesa_meta_pbo_GetTexSubImage";
> >>
> >> -   if (!_mesa_is_bufferobj(packing->BufferObj))
> >> +   if (!_mesa_is_bufferobj(packing->BufferObj) && !create_pbo)
> >>return false;
> >>
> >> if (format == GL_DEPTH_COMPONENT ||
> >> @@ -282,7 +284,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context
> *ctx, GLuint dims,
> >>return true;
> >> }
> >>
> >> -   pbo_tex_image = create_texture_for_pbo(ctx, false,
> GL_PIXEL_PACK_BUFFER,
> >> +   pbo_tex_image = create_texture_for_pbo(ctx, create_pbo,
> GL_PIXEL_PACK_BUFFER,
> >>width, height, depth,
> >>format, type, pixels,
> packing,
> >>&pbo, &pbo_tex);
> >> @@ -348,6 +350,18 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context
> *ctx, GLuint dims,
> >>   GL_COLOR_BUFFER_BIT, GL_NEAREST);
> >> }
> >>
> >> +   /* If we created a temporary pbo in meta to read the pixel data,
> that
> >> +* data will now get copied to memory allocated by client.
> >> +*/
> >> +   if (create_pbo) {
> >
> > I think this should be changed to something like the below:
> >
> >  if (create_pbo && !_mesa_is_bufferobj(packing->BufferObj))
> >
> > It looks like the meaning of create_pbo in create_texture_for_pbo is
> > ‘create pbo unless there is already a pbo’. With this patch
> > _mesa_meta_pbo_GetTexSubImage seems to interpret it to mean that it will
> > always create the pbo and if there already was a pbo it would end up
> > clobbering the state.
> >
> I agree. I will make this change.
> >> +  /* Unbind the pbo from pack binding. */
> >> +  _mesa_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
> >
> > I don't think this unbind is necessary. create_texture_for_pbo is
> > careful not to modify the PBO binding state and once that function is
> > finished the PBO is only accessed via the texture so we shouldn't need
> > to touch the PBO binding.
> >
> >> +  _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[1]);
> >> +  _mesa_update_state(ctx);
> >> +  _mesa_readpixels(ctx, 0, 0, width, height, format, type,
> >> +   packing, (void *) pixels);
> >
> > Doesn't this only read the last slice of the texture? Maybe this patch
> > should wait until this patch from Laura Ekstrand is landed:
> >
> > http://list

[Mesa-dev] [PATCH] i965: Issue perf_debug messages for unsynchronized maps on !LLC systems.

2015-02-24 Thread Kenneth Graunke
We haven't implemented proper unsynchronized map support on !LLC systems
(pre-SNB, Atom).  MapBufferRange with GL_MAP_UNSYNCHRONIZE_BIT will
actually do a synchronized map, probably killing performance.

Also warn on BufferSubData, when we should be doing an unsynchronized
upload, but instead have to do a synchronous map.

v2: Only complain if the buffer is actually busy - we use unsynchronized
maps internally for vertex upload and such, but expect those to not
be busy.

Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/dri/i965/intel_buffer_objects.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c 
b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
index f2d2bcb..39a7147 100644
--- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
@@ -254,9 +254,9 @@ brw_buffer_subdata(struct gl_context *ctx,
 * (otherwise, an app that might occasionally stall but mostly not will end
 * up with blitting all the time, at the cost of bandwidth)
 */
-   if (brw->has_llc) {
-  if (offset + size <= intel_obj->gpu_active_start ||
-  intel_obj->gpu_active_end <= offset) {
+   if (offset + size <= intel_obj->gpu_active_start ||
+   intel_obj->gpu_active_end <= offset) {
+  if (brw->has_llc) {
  drm_intel_gem_bo_map_unsynchronized(intel_obj->buffer);
  memcpy(intel_obj->buffer->virtual + offset, data, size);
  drm_intel_bo_unmap(intel_obj->buffer);
@@ -264,6 +264,8 @@ brw_buffer_subdata(struct gl_context *ctx,
  if (intel_obj->gpu_active_end > intel_obj->gpu_active_start)
 intel_obj->prefer_stall_to_blit = true;
  return;
+  } else {
+ perf_debug("BufferSubData could be unsynchronized, but !LLC doesn't 
support it yet\n");
   }
}
 
@@ -437,9 +439,13 @@ brw_map_buffer_range(struct gl_context *ctx,
   return obj->Mappings[index].Pointer;
}
 
-   if (access & GL_MAP_UNSYNCHRONIZED_BIT)
+   if (access & GL_MAP_UNSYNCHRONIZED_BIT) {
+  if (!brw->has_llc && brw->perf_debug &&
+  drm_intel_bo_busy(intel_obj->buffer)) {
+ perf_debug("MapBufferRange with GL_MAP_UNSYNCHRONIZED_BIT stalling 
(it's actually synchronized on non-LLC platforms)\n");
+  }
   drm_intel_gem_bo_map_unsynchronized(intel_obj->buffer);
-   else if (!brw->has_llc && (!(access & GL_MAP_READ_BIT) ||
+   } else if (!brw->has_llc && (!(access & GL_MAP_READ_BIT) ||
   (access & GL_MAP_PERSISTENT_BIT))) {
   drm_intel_gem_bo_map_gtt(intel_obj->buffer);
   mark_buffer_inactive(intel_obj);
-- 
2.1.2

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


Re: [Mesa-dev] [PATCH 1/6] i965/skl: Layout 3D textures the same as array textures

2015-02-24 Thread Ben Widawsky
On Fri, Feb 20, 2015 at 10:31:03PM +, Neil Roberts wrote:
> On Gen9+ the 3D textures use the same mipmap layout as 2D array
> textures.
> ---
>  src/mesa/drivers/dri/i965/brw_tex_layout.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c 
> b/src/mesa/drivers/dri/i965/brw_tex_layout.c
> index 0e2841f..57922e9 100644
> --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
> +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
> @@ -224,6 +224,9 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt)
>  
>width  = minify(width, 1);
>height = minify(height, 1);
> +
> +  if (mt->target == GL_TEXTURE_3D)
> + depth = minify(depth, 1);
> }
>  }

assert(brw->gen >= 9)? (up to you, I'm very assert happy)

>  
> @@ -263,7 +266,7 @@ brw_miptree_layout_texture_array(struct brw_context *brw,
>if (mt->compressed)
>   img_height /= mt->align_h;
>  
> -  for (int q = 0; q < mt->physical_depth0; q++) {
> +  for (int q = 0; q < mt->level[level].depth; q++) {
>   if (mt->array_layout == ALL_SLICES_AT_EACH_LOD) {
>  intel_miptree_set_image_offset(mt, level, q, 0, q * img_height);
>   } else {

Can you remind me how you can have different depths per level? Assuming they're
the same, I prefer this hunk removed because it's much clearer the old way in my
opinion.

> @@ -368,7 +371,10 @@ brw_miptree_layout(struct brw_context *brw, struct 
> intel_mipmap_tree *mt)
>break;
>  
> case GL_TEXTURE_3D:
> -  brw_miptree_layout_texture_3d(brw, mt);
> +  if (brw->gen >= 9)
> + brw_miptree_layout_texture_array(brw, mt);
> +  else
> + brw_miptree_layout_texture_3d(brw, mt);
>break;
>  
> case GL_TEXTURE_1D_ARRAY:

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


Re: [Mesa-dev] [PATCH] r600g: Use R600_MAX_VIEWPORTS instead of 16

2015-02-24 Thread Ilia Mirkin
On Wed, Feb 25, 2015 at 1:34 AM, Alexandre Demers
 wrote:
> Lets define R600_MAX_VIEWPORTS instead of using 16 here and there
> in the code when looping through viewports and scissors. It is
> easier to understand what this number represents.
>
> Signed-off-by: Alexandre Demers 
> ---
>  src/gallium/drivers/r600/evergreen_state.c | 10 +-
>  src/gallium/drivers/r600/r600_hw_context.c |  2 +-
>  src/gallium/drivers/r600/r600_pipe.c   |  2 +-
>  src/gallium/drivers/r600/r600_pipe.h   |  6 --
>  src/gallium/drivers/r600/r600_state.c  |  4 ++--
>  5 files changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/evergreen_state.c 
> b/src/gallium/drivers/r600/evergreen_state.c
> index 8aa8082..f0b04f0 100644
> --- a/src/gallium/drivers/r600/evergreen_state.c
> +++ b/src/gallium/drivers/r600/evergreen_state.c
> @@ -2293,8 +2293,8 @@ static void cayman_init_atom_start_cs(struct 
> r600_context *rctx)
> r600_store_context_reg(cb, R_028200_PA_SC_WINDOW_OFFSET, 0);
> r600_store_context_reg(cb, R_02820C_PA_SC_CLIPRECT_RULE, 0x);
>
> -   r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16);
> -   for (tmp = 0; tmp < 16; tmp++) {
> +   r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 
> R600_MAX_VIEWPORTS);
> +   for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) {
> r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */
> r600_store_value(cb, fui(1.0)); /* 
> R_0282D4_PA_SC_VPORT_ZMAX_0 */
> }
> @@ -2727,8 +2727,8 @@ void evergreen_init_atom_start_cs(struct r600_context 
> *rctx)
> r600_store_context_reg(cb, R_02820C_PA_SC_CLIPRECT_RULE, 0x);
> r600_store_context_reg(cb, R_028230_PA_SC_EDGERULE, 0x);
>
> -   r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16);
> -   for (tmp = 0; tmp < 16; tmp++) {
> +   r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 
> R600_MAX_VIEWPORTS);
> +   for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) {
> r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */
> r600_store_value(cb, fui(1.0)); /* 
> R_0282D4_PA_SC_VPORT_ZMAX_0 */
> }
> @@ -3458,7 +3458,7 @@ void evergreen_init_state_functions(struct r600_context 
> *rctx)
> r600_init_atom(rctx, &rctx->dsa_state.atom, id++, 
> r600_emit_cso_state, 0);
> r600_init_atom(rctx, &rctx->poly_offset_state.atom, id++, 
> evergreen_emit_polygon_offset, 6);
> r600_init_atom(rctx, &rctx->rasterizer_state.atom, id++, 
> r600_emit_cso_state, 0);
> -   for (i = 0; i < 16; i++) {
> +   for (i = 0; i < R600_MAX_VIEWPORTS; i++) {
> r600_init_atom(rctx, &rctx->viewport[i].atom, id++, 
> r600_emit_viewport_state, 8);
> r600_init_atom(rctx, &rctx->scissor[i].atom, id++, 
> evergreen_emit_scissor_state, 4);
> rctx->viewport[i].idx = i;
> diff --git a/src/gallium/drivers/r600/r600_hw_context.c 
> b/src/gallium/drivers/r600/r600_hw_context.c
> index cd57eed..7961a96 100644
> --- a/src/gallium/drivers/r600/r600_hw_context.c
> +++ b/src/gallium/drivers/r600/r600_hw_context.c
> @@ -307,7 +307,7 @@ void r600_begin_new_cs(struct r600_context *ctx)
> ctx->poly_offset_state.atom.dirty = true;
> ctx->vgt_state.atom.dirty = true;
> ctx->sample_mask.atom.dirty = true;
> -   for (i = 0; i < 16; i++) {
> +   for (i = 0; i < R600_MAX_VIEWPORTS; i++) {
> ctx->scissor[i].atom.dirty = true;
> ctx->viewport[i].atom.dirty = true;
> }
> diff --git a/src/gallium/drivers/r600/r600_pipe.c 
> b/src/gallium/drivers/r600/r600_pipe.c
> index c8a0e9c..24d901e 100644
> --- a/src/gallium/drivers/r600/r600_pipe.c
> +++ b/src/gallium/drivers/r600/r600_pipe.c
> @@ -374,7 +374,7 @@ static int r600_get_param(struct pipe_screen* pscreen, 
> enum pipe_cap param)
> return 8;
>
> case PIPE_CAP_MAX_VIEWPORTS:
> -   return 16;
> +   return R600_MAX_VIEWPORTS;
>
> /* Timer queries, present when the clock frequency is non zero. */
> case PIPE_CAP_QUERY_TIME_ELAPSED:
> diff --git a/src/gallium/drivers/r600/r600_pipe.h 
> b/src/gallium/drivers/r600/r600_pipe.h
> index 7237854..ac69895 100644
> --- a/src/gallium/drivers/r600/r600_pipe.h
> +++ b/src/gallium/drivers/r600/r600_pipe.h
> @@ -38,6 +38,8 @@
>
>  #define R600_NUM_ATOMS 73
>
> +#define R600_MAX_VIEWPORTS 16
> +
>  /* read caches */
>  #define R600_CONTEXT_INV_VERTEX_CACHE  (R600_CONTEXT_PRIVATE_FLAG << 
> 0)
>  #define R600_CONTEXT_INV_TEX_CACHE (R600_CONTEXT_PRIVATE_FLAG << 
> 1)
> @@ -443,12 +445,12 @@ struct r600_context {
> struct r600_poly_offset_state   poly_offset_state;
> struct r600_cso_state   rasterizer_state;
> struct r600_sample_mask sample_mask;
> -   struct r600_scissor_state   scissor[16

Re: [Mesa-dev] [PATCH] r600g: Use R600_MAX_VIEWPORTS instead of 16

2015-02-24 Thread Alexandre Demers

You are right, I missed that one. I'll send a v2 to fix it.

Alexandre Demers

On 2015-02-25 01:36, Ilia Mirkin wrote:

On Wed, Feb 25, 2015 at 1:34 AM, Alexandre Demers
 wrote:

Lets define R600_MAX_VIEWPORTS instead of using 16 here and there
in the code when looping through viewports and scissors. It is
easier to understand what this number represents.

Signed-off-by: Alexandre Demers 
---
  src/gallium/drivers/r600/evergreen_state.c | 10 +-
  src/gallium/drivers/r600/r600_hw_context.c |  2 +-
  src/gallium/drivers/r600/r600_pipe.c   |  2 +-
  src/gallium/drivers/r600/r600_pipe.h   |  6 --
  src/gallium/drivers/r600/r600_state.c  |  4 ++--
  5 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 8aa8082..f0b04f0 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -2293,8 +2293,8 @@ static void cayman_init_atom_start_cs(struct r600_context 
*rctx)
 r600_store_context_reg(cb, R_028200_PA_SC_WINDOW_OFFSET, 0);
 r600_store_context_reg(cb, R_02820C_PA_SC_CLIPRECT_RULE, 0x);

-   r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16);
-   for (tmp = 0; tmp < 16; tmp++) {
+   r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 
R600_MAX_VIEWPORTS);
+   for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) {
 r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */
 r600_store_value(cb, fui(1.0)); /* R_0282D4_PA_SC_VPORT_ZMAX_0 
*/
 }
@@ -2727,8 +2727,8 @@ void evergreen_init_atom_start_cs(struct r600_context 
*rctx)
 r600_store_context_reg(cb, R_02820C_PA_SC_CLIPRECT_RULE, 0x);
 r600_store_context_reg(cb, R_028230_PA_SC_EDGERULE, 0x);

-   r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 16);
-   for (tmp = 0; tmp < 16; tmp++) {
+   r600_store_context_reg_seq(cb, R_0282D0_PA_SC_VPORT_ZMIN_0, 2 * 
R600_MAX_VIEWPORTS);
+   for (tmp = 0; tmp < R600_MAX_VIEWPORTS; tmp++) {
 r600_store_value(cb, 0); /* R_0282D0_PA_SC_VPORT_ZMIN_0 */
 r600_store_value(cb, fui(1.0)); /* R_0282D4_PA_SC_VPORT_ZMAX_0 
*/
 }
@@ -3458,7 +3458,7 @@ void evergreen_init_state_functions(struct r600_context 
*rctx)
 r600_init_atom(rctx, &rctx->dsa_state.atom, id++, r600_emit_cso_state, 
0);
 r600_init_atom(rctx, &rctx->poly_offset_state.atom, id++, 
evergreen_emit_polygon_offset, 6);
 r600_init_atom(rctx, &rctx->rasterizer_state.atom, id++, 
r600_emit_cso_state, 0);
-   for (i = 0; i < 16; i++) {
+   for (i = 0; i < R600_MAX_VIEWPORTS; i++) {
 r600_init_atom(rctx, &rctx->viewport[i].atom, id++, 
r600_emit_viewport_state, 8);
 r600_init_atom(rctx, &rctx->scissor[i].atom, id++, 
evergreen_emit_scissor_state, 4);
 rctx->viewport[i].idx = i;
diff --git a/src/gallium/drivers/r600/r600_hw_context.c 
b/src/gallium/drivers/r600/r600_hw_context.c
index cd57eed..7961a96 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -307,7 +307,7 @@ void r600_begin_new_cs(struct r600_context *ctx)
 ctx->poly_offset_state.atom.dirty = true;
 ctx->vgt_state.atom.dirty = true;
 ctx->sample_mask.atom.dirty = true;
-   for (i = 0; i < 16; i++) {
+   for (i = 0; i < R600_MAX_VIEWPORTS; i++) {
 ctx->scissor[i].atom.dirty = true;
 ctx->viewport[i].atom.dirty = true;
 }
diff --git a/src/gallium/drivers/r600/r600_pipe.c 
b/src/gallium/drivers/r600/r600_pipe.c
index c8a0e9c..24d901e 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -374,7 +374,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
 return 8;

 case PIPE_CAP_MAX_VIEWPORTS:
-   return 16;
+   return R600_MAX_VIEWPORTS;

 /* Timer queries, present when the clock frequency is non zero. */
 case PIPE_CAP_QUERY_TIME_ELAPSED:
diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index 7237854..ac69895 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -38,6 +38,8 @@

  #define R600_NUM_ATOMS 73

+#define R600_MAX_VIEWPORTS 16
+
  /* read caches */
  #define R600_CONTEXT_INV_VERTEX_CACHE  (R600_CONTEXT_PRIVATE_FLAG << 
0)
  #define R600_CONTEXT_INV_TEX_CACHE (R600_CONTEXT_PRIVATE_FLAG << 
1)
@@ -443,12 +445,12 @@ struct r600_context {
 struct r600_poly_offset_state   poly_offset_state;
 struct r600_cso_state   rasterizer_state;
 struct r600_sample_mask sample_mask;
-   struct r600_scissor_state   scissor[16];
+   struct r600_scissor_state   scissor[R6

[Mesa-dev] [Bug 89311] [HSW, regression, bisected] dEQP: Added entry points for glCompressedTextureSubImage*D.

2015-02-24 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89311

Samuel Iglesias  changed:

   What|Removed |Added

 CC||la...@jlekstrand.net,
   ||sigles...@igalia.com

-- 
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 89312] [regression, bisected] main: Added entry points for CopyTextureSubImage*D. (d6b7c40cecfe01)

2015-02-24 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89312

Bug ID: 89312
   Summary: [regression, bisected] main: Added entry points for
CopyTextureSubImage*D. (d6b7c40cecfe01)
   Product: Mesa
   Version: git
  Hardware: Other
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: sigles...@igalia.com
QA Contact: mesa-dev@lists.freedesktop.org

The following two dEQP tests start to fail after commit d6b7c40cecfe01 landed
in master branch:

   dEQP-GLES3.functional.negative_api.texture.copytexsubimage2d_invalid_target
   dEQP-GLES3.functional.negative_api.texture.copytexsubimage3d

This is the commit log:

commit d6b7c40cecfe01ec8545974b01cca16da2856ac2
Author: Laura Ekstrand 
Date:   Tue Jan 6 10:05:40 2015 -0800

main: Added entry points for CopyTextureSubImage*D.

Reviewed-by: Anuj Phogat 

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
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 89312] [regression, bisected] main: Added entry points for CopyTextureSubImage*D. (d6b7c40cecfe01)

2015-02-24 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89312

--- Comment #1 from Samuel Iglesias  ---
Steps to reproduce:

$ cd 
$ cd modules/gles3
$ ./deqp-gles3 -n
dEQP-GLES3.functional.negative_api.texture.copytexsubimage2d_invalid_target
$ ./deqp-gles3 -n dEQP-GLES3.functional.negative_api.texture.copytexsubimage3d

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