Mesa (master): i915g: fix incorrect gl_FragCoord value

2016-10-10 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 64435fd888ec5932024292d87b0afcecbe5fb818
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=64435fd888ec5932024292d87b0afcecbe5fb818

Author: Nicholas Bishop 
Date:   Thu Aug 25 19:31:53 2016 -0400

i915g: fix incorrect gl_FragCoord value

On Intel Pineview M hardware, the i915 gallium driver doesn't output
the correct gl_FragCoord. It seems to always have an X coord of 0.0
and a Y coord of the window's height in pixels, e.g. 600.0f or such.

I believe this is a regression caused in part by this commit:
afa035031ff9e0c07a2297d864e46c76f7bfff58

The old behavior used the output at index zero, while the new behavior
uses actual zeroes. In the case of gl_FragCoord the output at index
zero happened to be the correct one, so the behavior appeared correct
although the code already had a bug.

Fixed by checking for I915_SEMANTIC_POS when setting up texCoords. If
the generic_mapping is I915_SEMANTIC_POS, look for the
TGSI_SEMANTIC_POSITION instead of a TGSI_SEMANTIC_GENERIC output.

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

Reviewed-by: Stéphane Marchesin 
Tested-by: Stéphane Marchesin 

---

 src/gallium/drivers/i915/i915_state_derived.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/i915/i915_state_derived.c 
b/src/gallium/drivers/i915/i915_state_derived.c
index 177b854..dbfbc84 100644
--- a/src/gallium/drivers/i915/i915_state_derived.c
+++ b/src/gallium/drivers/i915/i915_state_derived.c
@@ -145,7 +145,12 @@ static void calculate_vertex_layout(struct i915_context 
*i915)
   uint hwtc;
   if (texCoords[i]) {
  hwtc = TEXCOORDFMT_4D;
- src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_GENERIC, 
fs->generic_mapping[i]);
+ if (fs->generic_mapping[i] == I915_SEMANTIC_POS) {
+src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_POSITION, 
0);
+ }
+ else {
+src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_GENERIC, 
fs->generic_mapping[i]);
+ }
  draw_emit_vertex_attr(, EMIT_4F, src);
   }
   else {

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


Mesa (master): i915g: Implement EGL_EXT_image_dma_buf_import

2015-04-01 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 70eed78cacd711e663068e78a8430372cc5fabf1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=70eed78cacd711e663068e78a8430372cc5fabf1

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Apr  1 20:00:08 2015 -0700

i915g: Implement EGL_EXT_image_dma_buf_import

This adds all the plumbing to get EGL_EXT_image_dma_buf_import in
i915g.

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 .../auxiliary/target-helpers/inline_drm_helper.h   |2 +-
 src/gallium/drivers/i915/i915_resource_texture.c   |2 +-
 src/gallium/drivers/i915/i915_winsys.h |1 +
 src/gallium/targets/pipe-loader/pipe_i915.c|   25 +++-
 src/gallium/winsys/i915/drm/i915_drm_buffer.c  |   15 
 5 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h 
b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
index 54c1c6c..542ad43 100644
--- a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
@@ -430,7 +430,7 @@ dd_configuration(enum drm_conf conf)
 
 #if defined(GALLIUM_I915)
if (strcmp(driver_name, i915) == 0)
-  return NULL;
+  return configuration_query(conf);
else
 #endif
 #if defined(GALLIUM_ILO)
diff --git a/src/gallium/drivers/i915/i915_resource_texture.c 
b/src/gallium/drivers/i915/i915_resource_texture.c
index 36fb3e2..dc8f4d1c9 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -989,7 +989,7 @@ i915_texture_from_handle(struct pipe_screen * screen,
 
assert(screen);
 
-   buffer = iws-buffer_from_handle(iws, whandle, tiling, stride);
+   buffer = iws-buffer_from_handle(iws, whandle, template-height0, tiling, 
stride);
 
/* Only supports one type */
if ((template-target != PIPE_TEXTURE_2D 
diff --git a/src/gallium/drivers/i915/i915_winsys.h 
b/src/gallium/drivers/i915/i915_winsys.h
index 6cf802f..509e6cc 100644
--- a/src/gallium/drivers/i915/i915_winsys.h
+++ b/src/gallium/drivers/i915/i915_winsys.h
@@ -176,6 +176,7 @@ struct i915_winsys {
struct i915_winsys_buffer *
   (*buffer_from_handle)(struct i915_winsys *iws,
 struct winsys_handle *whandle,
+unsigned height,
 enum i915_winsys_buffer_tile *tiling,
 unsigned *stride);
 
diff --git a/src/gallium/targets/pipe-loader/pipe_i915.c 
b/src/gallium/targets/pipe-loader/pipe_i915.c
index 85662cb..b0da613 100644
--- a/src/gallium/targets/pipe-loader/pipe_i915.c
+++ b/src/gallium/targets/pipe-loader/pipe_i915.c
@@ -23,5 +23,28 @@ create_screen(int fd)
return screen;
 }
 
+static const struct drm_conf_ret throttle_ret = {
+   .type = DRM_CONF_INT,
+   .val.val_int = 2,
+};
+
+static const struct drm_conf_ret share_fd_ret = {
+   .type = DRM_CONF_BOOL,
+   .val.val_int = true,
+};
+
+static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
+{
+   switch (conf) {
+   case DRM_CONF_THROTTLE:
+  return throttle_ret;
+   case DRM_CONF_SHARE_FD:
+  return share_fd_ret;
+   default:
+  break;
+   }
+   return NULL;
+}
+
 PUBLIC
-DRM_DRIVER_DESCRIPTOR(i915, i915, create_screen, NULL)
+DRM_DRIVER_DESCRIPTOR(i915, i915, create_screen, drm_configuration)
diff --git a/src/gallium/winsys/i915/drm/i915_drm_buffer.c 
b/src/gallium/winsys/i915/drm/i915_drm_buffer.c
index 38e0619..c069852 100644
--- a/src/gallium/winsys/i915/drm/i915_drm_buffer.c
+++ b/src/gallium/winsys/i915/drm/i915_drm_buffer.c
@@ -1,4 +1,3 @@
-
 #include state_tracker/drm_driver.h
 #include i915_drm_winsys.h
 #include util/u_memory.h
@@ -72,7 +71,7 @@ i915_drm_buffer_create_tiled(struct i915_winsys *iws,
 
buf-bo = drm_intel_bo_alloc_tiled(idws-gem_manager,
   i915_drm_type_to_name(type),
- *stride, height, 1,
+  *stride, height, 1,
   tiling_mode, pitch, 0);
 
if (!buf-bo)
@@ -91,6 +90,7 @@ err:
 static struct i915_winsys_buffer *
 i915_drm_buffer_from_handle(struct i915_winsys *iws,
 struct winsys_handle *whandle,
+unsigned height,
 enum i915_winsys_buffer_tile *tiling,
 unsigned *stride)
 {
@@ -98,7 +98,7 @@ i915_drm_buffer_from_handle(struct i915_winsys *iws,
struct i915_drm_buffer *buf;
uint32_t tile = 0, swizzle = 0;
 
-   if (whandle-type != DRM_API_HANDLE_TYPE_SHARED)
+   if ((whandle-type != DRM_API_HANDLE_TYPE_SHARED)  (whandle-type != 
DRM_API_HANDLE_TYPE_FD))
   return NULL;
 
buf = CALLOC_STRUCT(i915_drm_buffer);
@@ -106,7 +106,14 @@ i915_drm_buffer_from_handle(struct i915_winsys *iws,
   return NULL;
 
buf-magic = 0xDEAD1337;
-   buf-bo = 

Mesa (master): i915g: Fix maxlod computation.

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 2ed24b2c317a38627bee8704064c7c362811eda0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ed24b2c317a38627bee8704064c7c362811eda0

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:09:24 2014 -0800

i915g: Fix maxlod computation.

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_state_sampler.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state_sampler.c 
b/src/gallium/drivers/i915/i915_state_sampler.c
index eb62479..c874361 100644
--- a/src/gallium/drivers/i915/i915_state_sampler.c
+++ b/src/gallium/drivers/i915/i915_state_sampler.c
@@ -304,11 +304,11 @@ static void update_map(struct i915_context *i915,
 {
const struct pipe_resource *pt = tex-b.b;
uint width = pt-width0, height = pt-height0, depth = pt-depth0;
-   const uint num_levels = pt-last_level;
-   uint format, pitch;
-   unsigned max_lod = num_levels * 4;
int first_level = view-u.tex.first_level;
+   const uint num_levels = pt-last_level - first_level;
+   unsigned max_lod = num_levels * 4;
bool is_npot = (!util_is_power_of_two(pt-width0) || 
!util_is_power_of_two(pt-height0)); 
+   uint format, pitch;
 
/*
 * This is a bit messy. i915 doesn't support NPOT with mipmaps, but we can

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


Mesa (master): i915g: Fix typos

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 675019584c9dea1aca690225f1d83bda7e910eb8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=675019584c9dea1aca690225f1d83bda7e910eb8

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:10:00 2014 -0800

i915g: Fix typos

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_surface.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_surface.c 
b/src/gallium/drivers/i915/i915_surface.c
index 61c5441..7317e3a 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -73,7 +73,7 @@ i915_util_blitter_save_states(struct i915_context *i915)
 i915-num_fragment_sampler_views,
 i915-fragment_sampler_views);
 }
-#
+
 static void
 i915_surface_copy_render(struct pipe_context *pipe,
  struct pipe_resource *dst, unsigned dst_level,
@@ -117,7 +117,7 @@ i915_surface_copy_render(struct pipe_context *pipe,
 fallback:
util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
  src, src_level, src_box);
- }
+}
 
 static void
 i915_clear_render_target_render(struct pipe_context *pipe,

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


Mesa (master): i915g: Don't hardcode array size for phase count

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 5f61744adba322eaec9a357f09f5ed3bee29226b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f61744adba322eaec9a357f09f5ed3bee29226b

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:07:52 2014 -0800

i915g: Don't hardcode array size for phase count

This is an array of temp registers, so use I915_MAX_TEMPORARY for the size.

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_fpc.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/i915/i915_fpc.h 
b/src/gallium/drivers/i915/i915_fpc.h
index 8711630..a4dbcb4 100644
--- a/src/gallium/drivers/i915/i915_fpc.h
+++ b/src/gallium/drivers/i915/i915_fpc.h
@@ -72,7 +72,7 @@ struct i915_fp_compile {
uint temp_flag;   /** Tracks temporary regs which are in use */
uint utemp_flag;  /** Tracks TYPE_U temporary regs which are in use */
 
-   uint register_phases[16];
+   uint register_phases[I915_MAX_TEMPORARY];
uint nr_tex_indirect;
uint nr_tex_insn;
uint nr_alu_insn;

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


Mesa (master): i915g: Don't limit blitter to POT textures

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 1e47510df72ccc43fde33e5026bcf71f201d90ae
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e47510df72ccc43fde33e5026bcf71f201d90ae

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:10:50 2014 -0800

i915g: Don't limit blitter to POT textures

Now that we have NPOT support for u_blitter, there is no reason to
limit this any longer.

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_surface.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_surface.c 
b/src/gallium/drivers/i915/i915_surface.c
index 7317e3a..b516172 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -90,9 +90,8 @@ i915_surface_copy_render(struct pipe_context *pipe,
struct pipe_sampler_view src_templ, *src_view;
struct pipe_surface dst_templ, *dst_view;
 
-   /* Fallback for buffers and npot. */
-   if ((dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER) ||
-   !util_is_power_of_two(src_width0) || !util_is_power_of_two(src_height0))
+   /* Fallback for buffers. */
+   if ((dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER))
   goto fallback;
 
util_blitter_default_dst_texture(dst_templ, dst, dst_level, dstz);

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


Mesa (master): i915g: Add back 4444 and 5551 formats

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 90207340c7ea0d729c8738fd0171316ada6f0ad7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=90207340c7ea0d729c8738fd0171316ada6f0ad7

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:11:21 2014 -0800

i915g: Add back  and 5551 formats

Now that we have the transfers working, we can re-add those formats.

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/TODO  |2 --
 src/gallium/drivers/i915/i915_screen.c |4 
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/TODO b/src/gallium/drivers/i915/TODO
index cf4414a..8856a7e 100644
--- a/src/gallium/drivers/i915/TODO
+++ b/src/gallium/drivers/i915/TODO
@@ -34,7 +34,5 @@ Random list of problems with i915g:
 
 - Fix fragment discard
 
-- Fix  and 5551 formats
-
 Other bugs can be found here:
 
https://bugs.freedesktop.org/buglist.cgi?bug_status=NEWbug_status=ASSIGNEDbug_status=REOPENEDcomponent=Drivers/Gallium/i915g
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index e9f10bc..1c60499 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -362,7 +362,9 @@ i915_is_format_supported(struct pipe_screen *screen,
   PIPE_FORMAT_B8G8R8X8_UNORM,
   PIPE_FORMAT_R8G8B8A8_UNORM,
   PIPE_FORMAT_R8G8B8X8_UNORM,
+  PIPE_FORMAT_B4G4R4A4_UNORM,
   PIPE_FORMAT_B5G6R5_UNORM,
+  PIPE_FORMAT_B5G5R5A1_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
   PIPE_FORMAT_L8_UNORM,
   PIPE_FORMAT_A8_UNORM,
@@ -386,6 +388,8 @@ i915_is_format_supported(struct pipe_screen *screen,
   PIPE_FORMAT_R8G8B8A8_UNORM,
   PIPE_FORMAT_R8G8B8X8_UNORM,
   PIPE_FORMAT_B5G6R5_UNORM,
+  PIPE_FORMAT_B5G5R5A1_UNORM,
+  PIPE_FORMAT_B4G4R4A4_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
   PIPE_FORMAT_L8_UNORM,
   PIPE_FORMAT_A8_UNORM,

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


Mesa (master): i915g: Fallback copy_render for ZS formats

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 3d9c1a9dd64282ab10a01cfa87a4e6b877faf8b3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d9c1a9dd64282ab10a01cfa87a4e6b877faf8b3

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:11:40 2014 -0800

i915g: Fallback copy_render for ZS formats

These don't work out of the box, need more work, maybe with a proxy
format?

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_surface.c |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/i915/i915_surface.c 
b/src/gallium/drivers/i915/i915_surface.c
index b516172..24e0156 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -89,9 +89,19 @@ i915_surface_copy_render(struct pipe_context *pipe,
struct pipe_box dstbox;
struct pipe_sampler_view src_templ, *src_view;
struct pipe_surface dst_templ, *dst_view;
+   const struct util_format_description *desc;
 
/* Fallback for buffers. */
-   if ((dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER))
+   if (dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER)
+  goto fallback;
+
+   /* Fallback for depthstencil. XXX: see if we can use a proxy format */
+   desc = util_format_description(src-format);
+   if (desc-colorspace == UTIL_FORMAT_COLORSPACE_ZS)
+  goto fallback;
+
+   desc = util_format_description(dst-format);
+   if (desc-colorspace == UTIL_FORMAT_COLORSPACE_ZS)
   goto fallback;
 
util_blitter_default_dst_texture(dst_templ, dst, dst_level, dstz);

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


Mesa (master): i915g: Don't write constants past I915_MAX_CONSTANT

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: a9b07870764db617f199745573bfccddf9b378f9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9b07870764db617f199745573bfccddf9b378f9

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:08:24 2014 -0800

i915g: Don't write constants past I915_MAX_CONSTANT

This happens with glsl-convolution-1, where we have 64 constants. This
doesn't make the test pass (we don't have 64 constants anyway, only
32) but this prevents it from crashing.

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_fpc_translate.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c 
b/src/gallium/drivers/i915/i915_fpc_translate.c
index 124c586..4f5fdd8 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -1128,7 +1128,7 @@ static void i915_translate_token(struct i915_fp_compile 
*p,
== TGSI_FILE_CONSTANT) {
  uint i;
  for (i = token-FullDeclaration.Range.First;
-  i = token-FullDeclaration.Range.Last;
+  i = MIN2(token-FullDeclaration.Range.Last, I915_MAX_CONSTANT - 
1);
   i++) {
 assert(ifs-constant_flags[i] == 0x0);
 ifs-constant_flags[i] = I915_CONSTFLAG_USER;

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


Mesa (master): i915g: Fix offset for level != 0

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 0220a428d7e8df487e3cbd8c6cdd8ca2f39117ad
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0220a428d7e8df487e3cbd8c6cdd8ca2f39117ad

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:08:56 2014 -0800

i915g: Fix offset for level != 0

For NPOT texture layouts, we want to be able to access texture levels
other than 0 directly. Since the hw doesn't support that, We do it by
adding the offset directly.

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_context.h  |2 +-
 src/gallium/drivers/i915/i915_resource.h |2 +-
 src/gallium/drivers/i915/i915_resource_texture.c |2 +-
 src/gallium/drivers/i915/i915_state_emit.c   |4 +++-
 src/gallium/drivers/i915/i915_state_sampler.c|   25 ++
 5 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index ec8cbbf..40abf3c 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -157,7 +157,7 @@ struct i915_state
unsigned sampler_enable_nr;
 
/* texture image buffers */
-   unsigned texbuffer[I915_TEX_UNITS][2];
+   unsigned texbuffer[I915_TEX_UNITS][3];
 
/** Describes the current hardware vertex layout */
struct vertex_info vertex_info;
diff --git a/src/gallium/drivers/i915/i915_resource.h 
b/src/gallium/drivers/i915/i915_resource.h
index 46241c9..ef99cfb 100644
--- a/src/gallium/drivers/i915/i915_resource.h
+++ b/src/gallium/drivers/i915/i915_resource.h
@@ -86,7 +86,7 @@ struct i915_texture {
struct i915_winsys_buffer *buffer;
 };
 
-unsigned i915_texture_offset(struct i915_texture *tex,
+unsigned i915_texture_offset(const struct i915_texture *tex,
  unsigned level, unsigned layer);
 void i915_init_screen_resource_functions(struct i915_screen *is);
 void i915_init_resource_functions(struct i915_context *i915);
diff --git a/src/gallium/drivers/i915/i915_resource_texture.c 
b/src/gallium/drivers/i915/i915_resource_texture.c
index 6430c4b..8abb99f 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -143,7 +143,7 @@ i915_texture_set_level_info(struct i915_texture *tex,
tex-image_offset[level][0].nblocksy = 0;
 }
 
-INLINE unsigned i915_texture_offset(struct i915_texture *tex,
+unsigned i915_texture_offset(const struct i915_texture *tex,
 unsigned level, unsigned layer)
 {
unsigned x, y;
diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 6244f48..92751f3 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -326,11 +326,13 @@ emit_map(struct i915_context *i915)
  if (enabled  (1  unit)) {
 struct i915_texture *texture = 
i915_texture(i915-fragment_sampler_views[unit]-texture);
 struct i915_winsys_buffer *buf = texture-buffer;
+unsigned offset = i915-current.texbuffer[unit][2];
+
 assert(buf);
 
 count++;
 
-OUT_RELOC(buf, I915_USAGE_SAMPLER, 0);
+OUT_RELOC(buf, I915_USAGE_SAMPLER, offset);
 OUT_BATCH(i915-current.texbuffer[unit][0]); /* MS3 */
 OUT_BATCH(i915-current.texbuffer[unit][1]); /* MS4 */
  }
diff --git a/src/gallium/drivers/i915/i915_state_sampler.c 
b/src/gallium/drivers/i915/i915_state_sampler.c
index 52f8b00..eb62479 100644
--- a/src/gallium/drivers/i915/i915_state_sampler.c
+++ b/src/gallium/drivers/i915/i915_state_sampler.c
@@ -63,7 +63,7 @@ static void update_map(struct i915_context *i915,
const struct i915_texture *tex,
const struct i915_sampler_state *sampler,
const struct pipe_sampler_view* view,
-   uint state[2]);
+   uint state[3]);
 
 
 
@@ -300,13 +300,25 @@ static void update_map(struct i915_context *i915,
const struct i915_texture *tex,
const struct i915_sampler_state *sampler,
const struct pipe_sampler_view* view,
-   uint state[2])
+   uint state[3])
 {
const struct pipe_resource *pt = tex-b.b;
-   uint format, pitch;
-   const uint width = pt-width0, height = pt-height0, depth = pt-depth0;
+   uint width = pt-width0, height = pt-height0, depth = pt-depth0;
const uint num_levels = pt-last_level;
+   uint format, pitch;
unsigned max_lod = num_levels * 4;
+   int first_level = view-u.tex.first_level;
+   bool is_npot = (!util_is_power_of_two(pt-width0) || 
!util_is_power_of_two(pt-height0)); 
+
+   /*
+* This is a bit messy. i915 doesn't support NPOT with mipmaps, but we can
+* still texture from a single level. This is useful 

Mesa (master): i915g: Align all texture dimensions to the next POT

2014-11-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: e30c799da920f6c6f502cbd05380235b791e05fd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e30c799da920f6c6f502cbd05380235b791e05fd

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Nov 22 00:10:23 2014 -0800

i915g: Align all texture dimensions to the next POT

This creates a usable layout for all NPOT textures. Of course these
still have lots of limitations, but at least we can render to a
level.

Signed-off-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_resource_texture.c |   57 +++---
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_resource_texture.c 
b/src/gallium/drivers/i915/i915_resource_texture.c
index 8abb99f..36fb3e2 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -295,7 +295,8 @@ static void
 i9x5_texture_layout_cube(struct i915_texture *tex)
 {
struct pipe_resource *pt = tex-b.b;
-   const unsigned nblocks = util_format_get_nblocksx(pt-format, pt-width0);
+   unsigned width = util_next_power_of_two(pt-width0);
+   const unsigned nblocks = util_format_get_nblocksx(pt-format, width);
unsigned level;
unsigned face;
 
@@ -333,15 +334,15 @@ i915_texture_layout_2d(struct i915_texture *tex)
 {
struct pipe_resource *pt = tex-b.b;
unsigned level;
-   unsigned width = pt-width0;
-   unsigned height = pt-height0;
-   unsigned nblocksy = util_format_get_nblocksy(pt-format, pt-width0);
+   unsigned width = util_next_power_of_two(pt-width0);
+   unsigned height = util_next_power_of_two(pt-height0);
+   unsigned nblocksy = util_format_get_nblocksy(pt-format, width);
unsigned align_y = 2;
 
if (util_format_is_s3tc(pt-format))
   align_y = 1;
 
-   tex-stride = align(util_format_get_stride(pt-format, pt-width0), 4);
+   tex-stride = align(util_format_get_stride(pt-format, width), 4);
tex-total_nblocksy = 0;
 
for (level = 0; level = pt-last_level; level++) {
@@ -362,15 +363,15 @@ i915_texture_layout_3d(struct i915_texture *tex)
struct pipe_resource *pt = tex-b.b;
unsigned level;
 
-   unsigned width = pt-width0;
-   unsigned height = pt-height0;
-   unsigned depth = pt-depth0;
-   unsigned nblocksy = util_format_get_nblocksy(pt-format, pt-height0);
+   unsigned width = util_next_power_of_two(pt-width0);
+   unsigned height = util_next_power_of_two(pt-height0);
+   unsigned depth = util_next_power_of_two(pt-depth0);
+   unsigned nblocksy = util_format_get_nblocksy(pt-format, height);
unsigned stack_nblocksy = 0;
 
/* Calculate the size of a single slice. 
 */
-   tex-stride = align(util_format_get_stride(pt-format, pt-width0), 4);
+   tex-stride = align(util_format_get_stride(pt-format, width), 4);
 
/* XXX: hardware expects/requires 9 levels at minimum.
 */
@@ -398,7 +399,7 @@ i915_texture_layout_3d(struct i915_texture *tex)
 * remarkable how wasteful of memory the i915 texture layouts
 * are.  They are largely fixed in the i945.
 */
-   tex-total_nblocksy = stack_nblocksy * pt-depth0;
+   tex-total_nblocksy = stack_nblocksy * util_next_power_of_two(pt-depth0);
 }
 
 static boolean
@@ -439,17 +440,17 @@ i945_texture_layout_2d(struct i915_texture *tex)
unsigned level;
unsigned x = 0;
unsigned y = 0;
-   unsigned width = pt-width0;
-   unsigned height = pt-height0;
-   unsigned nblocksx = util_format_get_nblocksx(pt-format, pt-width0);
-   unsigned nblocksy = util_format_get_nblocksy(pt-format, pt-height0);
+   unsigned width = util_next_power_of_two(pt-width0);
+   unsigned height = util_next_power_of_two(pt-height0);
+   unsigned nblocksx = util_format_get_nblocksx(pt-format, width);
+   unsigned nblocksy = util_format_get_nblocksy(pt-format, height);
 
if (util_format_is_s3tc(pt-format)) {
   align_x = 1;
   align_y = 1;
}
 
-   tex-stride = align(util_format_get_stride(pt-format, pt-width0), 4);
+   tex-stride = align(util_format_get_stride(pt-format, width), 4);
 
/* May need to adjust pitch to accomodate the placement of
 * the 2nd mipmap level.  This occurs when the alignment
@@ -458,8 +459,8 @@ i945_texture_layout_2d(struct i915_texture *tex)
 */
if (pt-last_level  0) {
   unsigned mip1_nblocksx =
- align_nblocksx(pt-format, u_minify(pt-width0, 1), align_x) +
- util_format_get_nblocksx(pt-format, u_minify(pt-width0, 2));
+ align_nblocksx(pt-format, u_minify(width, 1), align_x) +
+ util_format_get_nblocksx(pt-format, u_minify(width, 2));
 
   if (mip1_nblocksx  nblocksx)
  tex-stride = mip1_nblocksx * util_format_get_blocksize(pt-format);
@@ -498,15 +499,15 @@ static void
 i945_texture_layout_3d(struct i915_texture *tex)
 {
struct pipe_resource *pt = tex-b.b;
-   unsigned width = pt-width0;
-   unsigned height = pt-height0;
-   unsigned depth = pt-depth0;
-   unsigned nblocksy = 

Mesa (master): i915g: Remove 4444 and 5551 formats

2014-06-05 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 1751a9ba2656b1a716b04b8eb870de8e7f10af24
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1751a9ba2656b1a716b04b8eb870de8e7f10af24

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu May 29 20:22:02 2014 -0700

i915g: Remove  and 5551 formats

They don't seem to work 100%, I need to investigate but in the
meantime let's remove them.

---

 src/gallium/drivers/i915/TODO  |2 ++
 src/gallium/drivers/i915/i915_screen.c |4 
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/i915/TODO b/src/gallium/drivers/i915/TODO
index 8856a7e..cf4414a 100644
--- a/src/gallium/drivers/i915/TODO
+++ b/src/gallium/drivers/i915/TODO
@@ -34,5 +34,7 @@ Random list of problems with i915g:
 
 - Fix fragment discard
 
+- Fix  and 5551 formats
+
 Other bugs can be found here:
 
https://bugs.freedesktop.org/buglist.cgi?bug_status=NEWbug_status=ASSIGNEDbug_status=REOPENEDcomponent=Drivers/Gallium/i915g
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 6ce6090..79d8659 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -327,9 +327,7 @@ i915_is_format_supported(struct pipe_screen *screen,
   PIPE_FORMAT_B8G8R8X8_UNORM,
   PIPE_FORMAT_R8G8B8A8_UNORM,
   PIPE_FORMAT_R8G8B8X8_UNORM,
-  PIPE_FORMAT_B4G4R4A4_UNORM,
   PIPE_FORMAT_B5G6R5_UNORM,
-  PIPE_FORMAT_B5G5R5A1_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
   PIPE_FORMAT_L8_UNORM,
   PIPE_FORMAT_A8_UNORM,
@@ -353,8 +351,6 @@ i915_is_format_supported(struct pipe_screen *screen,
   PIPE_FORMAT_R8G8B8A8_UNORM,
   PIPE_FORMAT_R8G8B8X8_UNORM,
   PIPE_FORMAT_B5G6R5_UNORM,
-  PIPE_FORMAT_B5G5R5A1_UNORM,
-  PIPE_FORMAT_B4G4R4A4_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
   PIPE_FORMAT_L8_UNORM,
   PIPE_FORMAT_A8_UNORM,

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


Mesa (master): i915g: Support B5G5R5A1 render targets and textures

2014-05-28 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: c0bd206a148b8fcda253359efe8c95871f89bd05
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c0bd206a148b8fcda253359efe8c95871f89bd05

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed May 28 14:15:07 2014 -0700

i915g: Support B5G5R5A1 render targets and textures

---

 src/gallium/drivers/i915/i915_screen.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index fea768c..ad8a23c 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -328,6 +328,7 @@ i915_is_format_supported(struct pipe_screen *screen,
   PIPE_FORMAT_R8G8B8X8_UNORM,
   PIPE_FORMAT_B4G4R4A4_UNORM,
   PIPE_FORMAT_B5G6R5_UNORM,
+  PIPE_FORMAT_B5G5R5A1_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
   PIPE_FORMAT_L8_UNORM,
   PIPE_FORMAT_A8_UNORM,
@@ -351,6 +352,7 @@ i915_is_format_supported(struct pipe_screen *screen,
   PIPE_FORMAT_R8G8B8A8_UNORM,
   PIPE_FORMAT_R8G8B8X8_UNORM,
   PIPE_FORMAT_B5G6R5_UNORM,
+  PIPE_FORMAT_B5G5R5A1_UNORM,
   PIPE_FORMAT_B4G4R4A4_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
   PIPE_FORMAT_L8_UNORM,

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


Mesa (master): i915g: Fix copy region code

2014-05-28 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 9e59c91a73903638eb5b807950d59fdf2dd981ce
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e59c91a73903638eb5b807950d59fdf2dd981ce

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed May 28 10:29:40 2014 -0700

i915g: Fix copy region code

This fixes a few issues with it, also cleans up the code.

---

 src/gallium/drivers/i915/i915_surface.c |   48 +--
 1 file changed, 14 insertions(+), 34 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_surface.c 
b/src/gallium/drivers/i915/i915_surface.c
index 8afe8d0..61c5441 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -73,7 +73,7 @@ i915_util_blitter_save_states(struct i915_context *i915)
 i915-num_fragment_sampler_views,
 i915-fragment_sampler_views);
 }
-
+#
 static void
 i915_surface_copy_render(struct pipe_context *pipe,
  struct pipe_resource *dst, unsigned dst_level,
@@ -81,53 +81,28 @@ i915_surface_copy_render(struct pipe_context *pipe,
  struct pipe_resource *src, unsigned src_level,
  const struct pipe_box *src_box)
 {
-   struct pipe_screen *screen = pipe-screen;
struct i915_context *i915 = i915_context(pipe);
-   struct i915_texture *dst_tex = i915_texture(dst);
-   struct i915_texture *src_tex = i915_texture(src);
unsigned src_width0 = src-width0;
unsigned src_height0 = src-height0;
unsigned dst_width0 = dst-width0;
unsigned dst_height0 = dst-height0;
-   unsigned layout;
struct pipe_box dstbox;
struct pipe_sampler_view src_templ, *src_view;
struct pipe_surface dst_templ, *dst_view;
 
/* Fallback for buffers and npot. */
if ((dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER) ||
-   !util_is_power_of_two(src_width0) || 
!util_is_power_of_two(src_height0)) {
-  util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
-src, src_level, src_box);
-  return;
-   }
-
-   layout = util_format_description(dst_templ.format)-layout;
- 
-   if (!util_blitter_is_copy_supported(i915-blitter, dst, src)) {
-  switch (util_format_get_blocksize(dst_templ.format)) {
- case 1:
-dst_templ.format = PIPE_FORMAT_I8_UNORM;
-break;
- case 2:
-dst_templ.format = PIPE_FORMAT_B5G6R5_UNORM;
-break;
- case 4:
-dst_templ.format = PIPE_FORMAT_B8G8R8A8_UNORM;
-break;
- default:
-debug_printf(i915: copy_region: Unhandled format: %s. Falling 
back to software.\n
- i915: copy_region: Software fallback doesn't work 
for tiled textures.\n,
- util_format_short_name(dst_templ.format));
-  }
-  src_templ.format = dst_templ.format;
-   }
-
-   i915_util_blitter_save_states(i915);
+   !util_is_power_of_two(src_width0) || !util_is_power_of_two(src_height0))
+  goto fallback;
 
util_blitter_default_dst_texture(dst_templ, dst, dst_level, dstz);
util_blitter_default_src_texture(src_templ, src, src_level);
 
+   if (!util_blitter_is_copy_supported(i915-blitter, dst, src))
+  goto fallback;
+
+   i915_util_blitter_save_states(i915);
+
dst_view = i915_create_surface_custom(pipe, dst, dst_templ, dst_width0, 
dst_height0);
src_view = i915_create_sampler_view_custom(pipe, src, src_templ, 
src_width0, src_height0);
 
@@ -137,7 +112,12 @@ i915_surface_copy_render(struct pipe_context *pipe,
util_blitter_blit_generic(i915-blitter, dst_view, dstbox,
  src_view, src_box, src_width0, src_height0,
  PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL);
-}
+   return;
+
+fallback:
+   util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
+ src, src_level, src_box);
+ }
 
 static void
 i915_clear_render_target_render(struct pipe_context *pipe,

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


Mesa (master): i915g: Support R4G4B4A4 render targets and textures

2014-05-28 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 569c02652004b6090cf81722b478f55c2f328c80
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=569c02652004b6090cf81722b478f55c2f328c80

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed May 28 14:00:20 2014 -0700

i915g: Support R4G4B4A4 render targets and textures

---

 src/gallium/drivers/i915/i915_screen.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index dfd7a2e..fea768c 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -326,6 +326,7 @@ i915_is_format_supported(struct pipe_screen *screen,
   PIPE_FORMAT_B8G8R8X8_UNORM,
   PIPE_FORMAT_R8G8B8A8_UNORM,
   PIPE_FORMAT_R8G8B8X8_UNORM,
+  PIPE_FORMAT_B4G4R4A4_UNORM,
   PIPE_FORMAT_B5G6R5_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
   PIPE_FORMAT_L8_UNORM,
@@ -350,6 +351,7 @@ i915_is_format_supported(struct pipe_screen *screen,
   PIPE_FORMAT_R8G8B8A8_UNORM,
   PIPE_FORMAT_R8G8B8X8_UNORM,
   PIPE_FORMAT_B5G6R5_UNORM,
+  PIPE_FORMAT_B4G4R4A4_UNORM,
   PIPE_FORMAT_B10G10R10A2_UNORM,
   PIPE_FORMAT_L8_UNORM,
   PIPE_FORMAT_A8_UNORM,

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


Mesa (master): i915g: Fix shader disasm code

2014-05-26 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 328e7e77424e9019b7c978fdc78da723fe079102
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=328e7e77424e9019b7c978fdc78da723fe079102

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon May 26 22:12:17 2014 -0700

i915g: Fix shader disasm code

This broke when I separated declarations/shader.

---

 src/gallium/drivers/i915/i915_debug_fp.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/src/gallium/drivers/i915/i915_debug_fp.c 
b/src/gallium/drivers/i915/i915_debug_fp.c
index 44e0dc9..c4ffade 100644
--- a/src/gallium/drivers/i915/i915_debug_fp.c
+++ b/src/gallium/drivers/i915/i915_debug_fp.c
@@ -339,7 +339,6 @@ i915_disassemble_program(struct debug_stream *stream,
 
assert((program[0]  0x1ff) + 2 == sz);
 
-   program++;
for (i = 1; i  sz; i += 3, program += 3) {
   unsigned opcode = program[0]  (0x1f  24);
 

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


Mesa (master): i915g: handle more formats in copy

2014-05-26 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: b419ca937a666b0e5a6aca4cf179d8d43e0a3996
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b419ca937a666b0e5a6aca4cf179d8d43e0a3996

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon May 26 06:48:11 2014 -0700

i915g: handle more formats in copy

We can handle depth, luminance,... copies by simply replacing the
format with a known format of the same bpp.

---

 src/gallium/drivers/i915/i915_state.c   |   21 +
 src/gallium/drivers/i915/i915_state.h   |6 +++
 src/gallium/drivers/i915/i915_surface.c |   75 ++-
 3 files changed, 91 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index b2f52d5..c90fcfd 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -42,6 +42,7 @@
 #include i915_state_inlines.h
 #include i915_fpc.h
 #include i915_resource.h
+#include i915_state.h
 
 /* The i915 (and related graphics cores) do not support GL_CLAMP.  The
  * Intel drivers for other operating systems implement GL_CLAMP as
@@ -812,6 +813,26 @@ i915_set_sampler_views(struct pipe_context *pipe, unsigned 
shader,
 }
 
 
+struct pipe_sampler_view *
+i915_create_sampler_view_custom(struct pipe_context *pipe,
+struct pipe_resource *texture,
+const struct pipe_sampler_view *templ,
+unsigned width0,
+unsigned height0)
+{
+   struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+   if (view) {
+  *view = *templ;
+  view-reference.count = 1;
+  view-texture = NULL;
+  pipe_resource_reference(view-texture, texture);
+  view-context = pipe;
+   }
+
+   return view;
+}
+
 static struct pipe_sampler_view *
 i915_create_sampler_view(struct pipe_context *pipe,
  struct pipe_resource *texture,
diff --git a/src/gallium/drivers/i915/i915_state.h 
b/src/gallium/drivers/i915/i915_state.h
index f529329..56ebb2d 100644
--- a/src/gallium/drivers/i915/i915_state.h
+++ b/src/gallium/drivers/i915/i915_state.h
@@ -53,5 +53,11 @@ extern struct i915_tracked_state i915_hw_constants;
 
 void i915_update_derived(struct i915_context *i915);
 void i915_emit_hardware_state(struct i915_context *i915);
+struct pipe_sampler_view *
+i915_create_sampler_view_custom(struct pipe_context *pipe,
+struct pipe_resource *texture,
+const struct pipe_sampler_view *templ,
+unsigned width0,
+unsigned height0);
 
 #endif
diff --git a/src/gallium/drivers/i915/i915_surface.c 
b/src/gallium/drivers/i915/i915_surface.c
index df66287..6e9558e 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -39,6 +39,12 @@
 #include util/u_pack_color.h
 #include util/u_surface.h
 
+static struct pipe_surface *
+i915_create_surface_custom(struct pipe_context *ctx,
+   struct pipe_resource *pt,
+   const struct pipe_surface *surf_tmpl,
+   unsigned width0,
+   unsigned height0);
 /*
  * surface functions using the render engine
  */
@@ -75,25 +81,61 @@ i915_surface_copy_render(struct pipe_context *pipe,
  struct pipe_resource *src, unsigned src_level,
  const struct pipe_box *src_box)
 {
+   struct pipe_screen *screen = pipe-screen;
struct i915_context *i915 = i915_context(pipe);
+   struct i915_texture *dst_tex = i915_texture(dst);
+   struct i915_texture *src_tex = i915_texture(src);
+   unsigned src_width0 = src-width0;
+   unsigned src_height0 = src-height0;
+   unsigned dst_width0 = dst-width0;
+   unsigned dst_height0 = dst-height0;
+   unsigned layout;
+   struct pipe_box dstbox;
+   struct pipe_sampler_view src_templ, *src_view;
+   struct pipe_surface dst_templ, *dst_view;
 
/* Fallback for buffers. */
-   if (dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER) {
+   if ((dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER)) {
   util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
 src, src_level, src_box);
   return;
}
 
+   layout = util_format_description(dst_templ.format)-layout;
+ 
if (!util_blitter_is_copy_supported(i915-blitter, dst, src)) {
-  util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
-src, src_level, src_box);
-  return;
+  switch (util_format_get_blocksize(dst_templ.format)) {
+ case 1:
+dst_templ.format = PIPE_FORMAT_I8_UNORM;
+break;
+ case 2:
+dst_templ.format = PIPE_FORMAT_B5G6R5_UNORM;
+break;
+ case 4:
+dst_templ.format = 

Mesa (master): i915g: Fallback to sw for npot copies

2014-05-26 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 82a76e61e7bee68bc3dcc1cca94db94ce21ea268
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=82a76e61e7bee68bc3dcc1cca94db94ce21ea268

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon May 26 17:31:57 2014 -0700

i915g: Fallback to sw for npot copies

i915g's npot support is incomplete, so let's not use it for copies.
This fixes a bunch of piglit tests.

---

 src/gallium/drivers/i915/i915_surface.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_surface.c 
b/src/gallium/drivers/i915/i915_surface.c
index 6e9558e..8afe8d0 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -94,8 +94,9 @@ i915_surface_copy_render(struct pipe_context *pipe,
struct pipe_sampler_view src_templ, *src_view;
struct pipe_surface dst_templ, *dst_view;
 
-   /* Fallback for buffers. */
-   if ((dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER)) {
+   /* Fallback for buffers and npot. */
+   if ((dst-target == PIPE_BUFFER  src-target == PIPE_BUFFER) ||
+   !util_is_power_of_two(src_width0) || 
!util_is_power_of_two(src_height0)) {
   util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
 src, src_level, src_box);
   return;

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


Mesa (master): i915g: support more PIPE_CAPs

2014-01-28 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 023a50dd9b368fba5b53dca347e90b46893c0348
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=023a50dd9b368fba5b53dca347e90b46893c0348

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Jan 28 18:28:56 2014 -0800

i915g: support more PIPE_CAPs

---

 src/gallium/drivers/i915/i915_screen.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 0583651..302992f 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -187,8 +187,6 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_USER_INDEX_BUFFERS:
case PIPE_CAP_USER_CONSTANT_BUFFERS:
   return 1;
-   case PIPE_CAP_TGSI_TEXCOORD:
-  return 0;
 
/* Unsupported features (boolean caps). */
case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
@@ -215,14 +213,19 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_TEXTURE_MULTISAMPLE:
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
+   case PIPE_CAP_CUBE_MAP_ARRAY:
+   case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
+   case PIPE_CAP_TGSI_TEXCOORD:
+   case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
   return 0;
+
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_TGSI_VS_LAYER:
-   return 0;
+  return 0;
 
case PIPE_CAP_GLSL_FEATURE_LEVEL:
   return 120;

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


Mesa (master): i915g: Fix assert

2013-10-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 5ceeeb360ea5d199263eeb20edc12a0f10b324cf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5ceeeb360ea5d199263eeb20edc12a0f10b324cf

Author: Stephane Marchesin stephane.marche...@gmail.com
Date:   Sat Oct 12 11:38:14 2013 -0700

i915g: Fix assert

Now that we support start, assert on start + num  max samplers

Reported by xexaxo

---

 src/gallium/drivers/i915/i915_state.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index a858a25..f722e2d 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -300,7 +300,7 @@ i915_bind_vertex_sampler_states(struct pipe_context *pipe,
struct i915_context *i915 = i915_context(pipe);
unsigned i;
 
-   assert(num = Elements(i915-vertex_samplers));
+   assert(start + num = Elements(i915-vertex_samplers));
 
/* Check for no-op */
if (num == i915-num_vertex_samplers 

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


Mesa (master): i915g: Rename sampler to fragment_sampler

2013-10-07 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 20bf508a42b0fdd5b094842b1bbeb412ce3f8505
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=20bf508a42b0fdd5b094842b1bbeb412ce3f8505

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon Oct  7 20:49:35 2013 -0700

i915g: Rename sampler to fragment_sampler

Otherwise it is fairly confusing.

---

 src/gallium/drivers/i915/i915_context.h   |4 ++--
 src/gallium/drivers/i915/i915_state.c |6 +++---
 src/gallium/drivers/i915/i915_state_sampler.c |6 +++---
 src/gallium/drivers/i915/i915_surface.c   |2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index 0c0555c..c786fef 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -227,8 +227,8 @@ struct i915_context {
/* The most recent drawing state as set by the driver:
 */
const struct i915_blend_state   *blend;
-   const struct i915_sampler_state *sampler[PIPE_MAX_SAMPLERS];
-   struct pipe_sampler_state *vertex_samplers[PIPE_MAX_SAMPLERS];
+   const struct i915_sampler_state 
*fragment_sampler[PIPE_MAX_SAMPLERS];
+   struct pipe_sampler_state   *vertex_samplers[PIPE_MAX_SAMPLERS];
const struct i915_depth_stencil_state   *depth_stencil;
const struct i915_rasterizer_state  *rasterizer;
 
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index ae4ad04..a858a25 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -337,17 +337,17 @@ static void i915_bind_fragment_sampler_states(struct 
pipe_context *pipe,
 
/* Check for no-op */
if (num == i915-num_samplers 
-   !memcmp(i915-sampler + start, samplers,
+   !memcmp(i915-fragment_sampler + start, samplers,
num * sizeof(void *)))
   return;
 
for (i = 0; i  num; ++i)
-  i915-sampler[i + start] = samplers[i];
+  i915-fragment_sampler[i + start] = samplers[i];
 
/* find highest non-null samplers[] entry */
{
   unsigned j = MAX2(i915-num_samplers, start + num);
-  while (j  0  i915-sampler[j - 1] == NULL)
+  while (j  0  i915-fragment_sampler[j - 1] == NULL)
  j--;
   i915-num_samplers = j;
}
diff --git a/src/gallium/drivers/i915/i915_state_sampler.c 
b/src/gallium/drivers/i915/i915_state_sampler.c
index a6e4724..86234fc 100644
--- a/src/gallium/drivers/i915/i915_state_sampler.c
+++ b/src/gallium/drivers/i915/i915_state_sampler.c
@@ -161,13 +161,13 @@ static void update_samplers(struct i915_context *i915)
 
  update_sampler(i915,
 unit,
-i915-sampler[unit],  /* sampler state */
+i915-fragment_sampler[unit], /* sampler state */
 texture,  /* texture */
 i915-current.sampler[unit]); /* the result */
  update_map(i915,
 unit,
 texture, /* texture */
-i915-sampler[unit], /* sampler state */
+i915-fragment_sampler[unit],/* sampler state */
 i915-fragment_sampler_views[unit],  /* sampler view */
 i915-current.texbuffer[unit]);  /* the result */
 
@@ -357,7 +357,7 @@ static void update_maps(struct i915_context *i915)
  update_map(i915,
 unit,
 texture,/* texture */
-i915-sampler[unit],/* sampler state */
+i915-fragment_sampler[unit],   /* sampler state */
 i915-fragment_sampler_views[unit], /* sampler view */
 i915-current.texbuffer[unit]);
   }
diff --git a/src/gallium/drivers/i915/i915_surface.c 
b/src/gallium/drivers/i915/i915_surface.c
index 48d4857..bd20a53 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -62,7 +62,7 @@ i915_util_blitter_save_states(struct i915_context *i915)
 
util_blitter_save_fragment_sampler_states(i915-blitter,
  i915-num_samplers,
- (void**)i915-sampler);
+ (void**)i915-fragment_sampler);
util_blitter_save_fragment_sampler_views(i915-blitter,
 i915-num_fragment_sampler_views,
 i915-fragment_sampler_views);

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


Mesa (master): i915g: Fix the sampler bind function

2013-10-07 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 8c6594074e798e8d5e13dc49720f7b8b4b381bbb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c6594074e798e8d5e13dc49720f7b8b4b381bbb

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon Oct  7 20:33:31 2013 -0700

i915g: Fix the sampler bind function

The new sampler bind sends us NULL samplers, so we need to count
the number of valid samplers ourselves. This fixes ~500 piglit
regressions from the sampler rework.

While we're at it, let's also support start.

---

 src/gallium/drivers/i915/i915_state.c |   49 -
 1 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 70cba8b..ae4ad04 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -293,25 +293,31 @@ i915_create_sampler_state(struct pipe_context *pipe,
 
 static void
 i915_bind_vertex_sampler_states(struct pipe_context *pipe,
-unsigned num_samplers,
+unsigned start,
+unsigned num,
 void **samplers)
 {
struct i915_context *i915 = i915_context(pipe);
unsigned i;
 
-   assert(num_samplers = Elements(i915-vertex_samplers));
+   assert(num = Elements(i915-vertex_samplers));
 
/* Check for no-op */
-   if (num_samplers == i915-num_vertex_samplers 
-   !memcmp(i915-vertex_samplers, samplers, num_samplers * sizeof(void *)))
+   if (num == i915-num_vertex_samplers 
+   !memcmp(i915-vertex_samplers + start, samplers,
+  num * sizeof(void *)))
   return;
 
-   for (i = 0; i  num_samplers; ++i)
-  i915-vertex_samplers[i] = samplers[i];
-   for (i = num_samplers; i  Elements(i915-vertex_samplers); ++i)
-  i915-vertex_samplers[i] = NULL;
+   for (i = 0; i  num; ++i)
+  i915-vertex_samplers[i + start] = samplers[i];
 
-   i915-num_vertex_samplers = num_samplers;
+   /* find highest non-null samplers[] entry */
+   {
+  unsigned j = MAX2(i915-num_vertex_samplers, start + num);
+  while (j  0  i915-vertex_samplers[j - 1] == NULL)
+ j--;
+  i915-num_vertex_samplers = j;
+   }
 
draw_set_samplers(i915-draw,
  PIPE_SHADER_VERTEX,
@@ -322,22 +328,29 @@ i915_bind_vertex_sampler_states(struct pipe_context *pipe,
 
 
 static void i915_bind_fragment_sampler_states(struct pipe_context *pipe,
- unsigned num, void **sampler)
+  unsigned start,
+  unsigned num,
+  void **samplers)
 {
struct i915_context *i915 = i915_context(pipe);
unsigned i;
 
/* Check for no-op */
if (num == i915-num_samplers 
-   !memcmp(i915-sampler, sampler, num * sizeof(void *)))
+   !memcmp(i915-sampler + start, samplers,
+   num * sizeof(void *)))
   return;
 
for (i = 0; i  num; ++i)
-  i915-sampler[i] = sampler[i];
-   for (i = num; i  PIPE_MAX_SAMPLERS; ++i)
-  i915-sampler[i] = NULL;
+  i915-sampler[i + start] = samplers[i];
 
-   i915-num_samplers = num;
+   /* find highest non-null samplers[] entry */
+   {
+  unsigned j = MAX2(i915-num_samplers, start + num);
+  while (j  0  i915-sampler[j - 1] == NULL)
+ j--;
+  i915-num_samplers = j;
+   }
 
i915-dirty |= I915_NEW_SAMPLER;
 }
@@ -348,14 +361,12 @@ i915_bind_sampler_states(struct pipe_context *pipe, 
unsigned shader,
  unsigned start, unsigned num_samplers,
  void **samplers)
 {
-   assert(start == 0);
-
switch (shader) {
case PIPE_SHADER_VERTEX:
-  i915_bind_vertex_sampler_states(pipe, num_samplers, samplers);
+  i915_bind_vertex_sampler_states(pipe, start, num_samplers, samplers);
   break;
case PIPE_SHADER_FRAGMENT:
-  i915_bind_fragment_sampler_states(pipe, num_samplers, samplers);
+  i915_bind_fragment_sampler_states(pipe, start, num_samplers, samplers);
   break;
default:
   ;

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


Mesa (master): i915g: Handle i915-batch == NULL correctly in flush

2013-09-06 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 519a2cf9507275d4a3e9926072b07a3f98f0095a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=519a2cf9507275d4a3e9926072b07a3f98f0095a

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Sep  6 10:55:16 2013 -0700

i915g: Handle i915-batch == NULL correctly in flush

Fixes warning reported by Coverity.

---

 src/gallium/drivers/i915/i915_flush.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_flush.c 
b/src/gallium/drivers/i915/i915_flush.c
index 0dca722..8cc31a8 100644
--- a/src/gallium/drivers/i915/i915_flush.c
+++ b/src/gallium/drivers/i915/i915_flush.c
@@ -45,10 +45,13 @@ static void i915_flush_pipe( struct pipe_context *pipe,
struct i915_context *i915 = i915_context(pipe);
enum i915_winsys_flush_flags winsys_flags = I915_FLUSH_ASYNC;
 
+   if (!i915-batch)
+  return;
+
/* Only shortcut this if we have no fence, otherwise we must flush the
 * empty batchbuffer to get our fence back.
 */
-   if (!fence  i915-batch  (i915-batch-map == i915-batch-ptr)) {
+   if (!fence  (i915-batch-map == i915-batch-ptr)) {
   return;
}
 

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


Mesa (master): i915g: Fix initial array index

2013-09-06 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 7125af295751c504063644f61f19c0d70a6b1b3e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7125af295751c504063644f61f19c0d70a6b1b3e

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Sep  6 10:45:27 2013 -0700

i915g: Fix initial array index

Fixes Out-of-bounds read defect reported by Coverity.

---

 src/gallium/drivers/i915/i915_state_emit.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 9c16e59..71ac326 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -142,7 +142,7 @@ static uint target_fixup(struct pipe_surface *p, int 
component)
   { PIPE_FORMAT_A8_UNORM,   { 0, 0, 0, S5_WRITEDISABLE_RED | 
S5_WRITEDISABLE_GREEN | S5_WRITEDISABLE_BLUE | S5_WRITEDISABLE_ALPHA}},
   { 0,  { S5_WRITEDISABLE_RED, 
S5_WRITEDISABLE_GREEN, S5_WRITEDISABLE_BLUE, S5_WRITEDISABLE_ALPHA}}
};
-   int i = sizeof(fixup_mask) / sizeof(*fixup_mask);
+   int i = sizeof(fixup_mask) / sizeof(*fixup_mask) - 1;
 
if (p)
   for(i = 0; fixup_mask[i].format != 0; i++)

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


Mesa (master): i915g: Document fall-through switch

2013-09-06 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: f9b37f7183ca2df228f2b7382ac9e2d0f74cb904
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9b37f7183ca2df228f2b7382ac9e2d0f74cb904

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Sep  6 11:02:25 2013 -0700

i915g: Document fall-through switch

Fixes warning reported by Coverity.

---

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

diff --git a/src/gallium/drivers/i915/i915_fpc_emit.c 
b/src/gallium/drivers/i915/i915_fpc_emit.c
index 683cef0..f4de1f1 100644
--- a/src/gallium/drivers/i915/i915_fpc_emit.c
+++ b/src/gallium/drivers/i915/i915_fpc_emit.c
@@ -200,16 +200,15 @@ uint i915_emit_texld( struct i915_fp_compile *p,
 * a swizzle for no reason below. */
switch(num_coord) {
   case 0:
- /* Ignore x */
  ignore |= (0xf  UREG_CHANNEL_X_SHIFT);
+ /* fall-through */
   case 1:
- /* Ignore y */
  ignore |= (0xf  UREG_CHANNEL_Y_SHIFT);
+ /* fall-through */
   case 2:
- /* Ignore z */
  ignore |= (0xf  UREG_CHANNEL_Z_SHIFT);
+ /* fall-through */
   case 3:
- /* Ignore w */
  ignore |= (0xf  UREG_CHANNEL_W_SHIFT);
}
 

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


Mesa (master): i915g: Remove useless comparison

2013-09-06 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 9e14895884b129fd9e144970e705b8cb5a5f70c4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e14895884b129fd9e144970e705b8cb5a5f70c4

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Sep  6 10:52:44 2013 -0700

i915g: Remove useless comparison

Fixes Macro compares unsigned to 0 defect reported by Coverity.

---

 src/gallium/drivers/i915/i915_debug.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_debug.c 
b/src/gallium/drivers/i915/i915_debug.c
index b6c442d..b072031 100644
--- a/src/gallium/drivers/i915/i915_debug.c
+++ b/src/gallium/drivers/i915/i915_debug.c
@@ -913,7 +913,7 @@ i915_dump_batchbuffer( struct i915_winsys_batchbuffer 
*batch )
   debug_printf( \n\nBATCH: ???\n);
   return;
}
-   
+
debug_printf( \n\nBATCH: (%d)\n, (int)bytes / 4);
 
while (!done 
@@ -922,8 +922,7 @@ i915_dump_batchbuffer( struct i915_winsys_batchbuffer 
*batch )
   if (!i915_debug_packet( stream ))
 break;
 
-  assert(stream.offset = bytes 
-stream.offset = 0);
+  assert(stream.offset = bytes);
}
 
debug_printf( END-BATCH\n\n\n);

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


Mesa (master): i915g: Add more optimizations

2013-09-04 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 4e861ac4a1f1bdbd28f66e3f15eb45aa45a47bad
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e861ac4a1f1bdbd28f66e3f15eb45aa45a47bad

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Sep  4 12:03:10 2013 -0700

i915g: Add more optimizations

This patch adds liveness analysis to i915g and a couple
optimizations which benefit from it. One interesting
optimization turns (fake) indirect texture accesses into direct
texture accesses (the i915 supports a maximum of 4 indirect
texture accesses). Among other things this fixes a bunch of
piglit tests.

---

 src/gallium/drivers/i915/i915_fpc.h   |4 +-
 src/gallium/drivers/i915/i915_fpc_optimize.c  |  408 ++---
 src/gallium/drivers/i915/i915_fpc_translate.c |   17 +-
 3 files changed, 371 insertions(+), 58 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc.h 
b/src/gallium/drivers/i915/i915_fpc.h
index e915822..ff740d4 100644
--- a/src/gallium/drivers/i915/i915_fpc.h
+++ b/src/gallium/drivers/i915/i915_fpc.h
@@ -322,6 +322,8 @@ struct i915_token_list
 
 extern struct i915_token_list* i915_optimize(const struct tgsi_token *tokens);
 
-extern void i915_optimize_free(struct i915_token_list* tokens);
+extern void i915_optimize_free(struct i915_token_list *tokens);
+
+extern uint i915_num_coords(uint tex);
 
 #endif
diff --git a/src/gallium/drivers/i915/i915_fpc_optimize.c 
b/src/gallium/drivers/i915/i915_fpc_optimize.c
index ff27d50..e0134a7 100644
--- a/src/gallium/drivers/i915/i915_fpc_optimize.c
+++ b/src/gallium/drivers/i915/i915_fpc_optimize.c
@@ -35,8 +35,15 @@
 #include util/u_string.h
 #include tgsi/tgsi_parse.h
 #include tgsi/tgsi_dump.h
+#include tgsi/tgsi_exec.h
 
-static boolean same_src_dst_reg(struct i915_full_src_register* s1, struct 
i915_full_dst_register* d1)
+struct i915_optimize_context
+{
+   int first_write[TGSI_EXEC_NUM_TEMPS];
+   int last_read[TGSI_EXEC_NUM_TEMPS];
+};
+
+static boolean same_src_dst_reg(struct i915_full_src_register *s1, struct 
i915_full_dst_register *d1)
 {
return (s1-Register.File == d1-Register.File 
s1-Register.Indirect == d1-Register.Indirect 
@@ -44,7 +51,7 @@ static boolean same_src_dst_reg(struct 
i915_full_src_register* s1, struct i915_f
s1-Register.Index == d1-Register.Index);
 }
 
-static boolean same_dst_reg(struct i915_full_dst_register* d1, struct 
i915_full_dst_register* d2)
+static boolean same_dst_reg(struct i915_full_dst_register *d1, struct 
i915_full_dst_register *d2)
 {
return (d1-Register.File == d2-Register.File 
d1-Register.Indirect == d2-Register.Indirect 
@@ -52,7 +59,7 @@ static boolean same_dst_reg(struct i915_full_dst_register* 
d1, struct i915_full_
d1-Register.Index == d2-Register.Index);
 }
 
-static boolean same_src_reg(struct i915_full_src_register* d1, struct 
i915_full_src_register* d2)
+static boolean same_src_reg(struct i915_full_src_register *d1, struct 
i915_full_src_register *d2)
 {
return (d1-Register.File == d2-Register.File 
d1-Register.Indirect == d2-Register.Indirect 
@@ -62,16 +69,99 @@ static boolean same_src_reg(struct i915_full_src_register* 
d1, struct i915_full_
d1-Register.Negate == d2-Register.Negate);
 }
 
-static boolean has_destination(unsigned opcode)
+const static struct {
+   boolean is_texture;
+   boolean commutes;
+   unsigned neutral_element;
+   unsigned num_dst;
+   unsigned num_src;
+} op_table [TGSI_OPCODE_LAST] = {
+   [ TGSI_OPCODE_ABS ] = { false,  false,  0,  1,  1 },
+   [ TGSI_OPCODE_ADD ] = { false,   true,  TGSI_SWIZZLE_ZERO,  1,  2 },
+   [ TGSI_OPCODE_CEIL] = { false,  false,  0,  1,  1 },
+   [ TGSI_OPCODE_CMP ] = { false,  false,  0,  1,  2 },
+   [ TGSI_OPCODE_COS ] = { false,  false,  0,  1,  1 },
+   [ TGSI_OPCODE_DDX ] = { false,  false,  0,  1,  0 },
+   [ TGSI_OPCODE_DDY ] = { false,  false,  0,  1,  0 },
+   [ TGSI_OPCODE_DP2 ] = { false,   true,   TGSI_SWIZZLE_ONE,  1,  2 },
+   [ TGSI_OPCODE_DP3 ] = { false,   true,   TGSI_SWIZZLE_ONE,  1,  2 },
+   [ TGSI_OPCODE_DP4 ] = { false,   true,   TGSI_SWIZZLE_ONE,  1,  2 },
+   [ TGSI_OPCODE_DPH ] = { false,  false,  0,  1,  2 },
+   [ TGSI_OPCODE_DST ] = { false,  false,  0,  1,  2 },
+   [ TGSI_OPCODE_END ] = { false,  false,  0,  0,  0 },
+   [ TGSI_OPCODE_EX2 ] = { false,  false,  0,  1,  1 },
+   [ TGSI_OPCODE_FLR ] = { false,  false,  0,  1,  1 },
+   [ TGSI_OPCODE_FRC ] = { false,  false,  0,  1,  1 },
+   [ TGSI_OPCODE_KILL_IF ] = { false,  false,  0,  0,  1 },
+   [ TGSI_OPCODE_KILL] = { false,  false,  0,  0,  0 },
+   [ TGSI_OPCODE_LG2 ] = { false,  false,  0,  1,  1 },
+   [ TGSI_OPCODE_LIT ] = { 

Mesa (master): i915g: Stop calling draw_prepare_shader_outputs

2013-09-04 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: b1461acf15ab450fa0d360ec5e03c90d0797a6d4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1461acf15ab450fa0d360ec5e03c90d0797a6d4

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Sep  4 14:44:49 2013 -0700

i915g: Stop calling draw_prepare_shader_outputs

It's not useful on i915g since we don't support primid. Fixes
piglit point tests on i915g.

---

 src/gallium/drivers/i915/i915_state_derived.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state_derived.c 
b/src/gallium/drivers/i915/i915_state_derived.c
index e1d1840..e01f16e 100644
--- a/src/gallium/drivers/i915/i915_state_derived.c
+++ b/src/gallium/drivers/i915/i915_state_derived.c
@@ -67,8 +67,6 @@ static void calculate_vertex_layout(struct i915_context *i915)
colors[0] = colors[1] = fog = needW = face = FALSE;
memset(vinfo, 0, sizeof(vinfo));
 
-   draw_prepare_shader_outputs(i915-draw);
-
/* Determine which fragment program inputs are needed.  Setup HW vertex
 * layout below, in the HW-specific attribute order.
 */

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


Mesa (master): i915g: Implement writemask fixup

2013-09-04 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 8709e2b6c564435111545c470da8796c81f020c4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8709e2b6c564435111545c470da8796c81f020c4

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Sep  4 17:55:21 2013 -0700

i915g: Implement writemask fixup

The fixup code emulates non-BGRA render targets by adding an
extra instruction at the end of fragment shaders to swizzle the
output. To do this, we also swizzle the blend function. However
an oversight until now was that the writemask wasn't getting
swizzled. This patch fixes that which fixes a bunch of piglit
tests.

---

 src/gallium/drivers/i915/i915_state.c|   15 ++---
 src/gallium/drivers/i915/i915_state_emit.c   |   85 +-
 src/gallium/drivers/i915/i915_state_static.c |   28 
 3 files changed, 90 insertions(+), 38 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 06d4d3b..8ca69fc 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -94,7 +94,6 @@ static unsigned translate_mip_filter( unsigned filter )
}
 }
 
-
 /* None of this state is actually used for anything yet.
  */
 static void *
@@ -117,10 +116,10 @@ i915_create_blend_state(struct pipe_context *pipe,
*/
 
   if (srcA != srcRGB ||
- dstA != dstRGB ||
- eqA != eqRGB) {
+  dstA != dstRGB ||
+  eqA != eqRGB) {
 
-cso_data-iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
+ cso_data-iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
   IAB_MODIFY_ENABLE |
   IAB_ENABLE |
   IAB_MODIFY_FUNC |
@@ -131,7 +130,7 @@ i915_create_blend_state(struct pipe_context *pipe,
   (i915_translate_blend_func(eqA)  IAB_FUNC_SHIFT));
   }
   else {
-cso_data-iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
+ cso_data-iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
   IAB_MODIFY_ENABLE |
   0);
   }
@@ -147,7 +146,7 @@ i915_create_blend_state(struct pipe_context *pipe,
if (blend-dither)
   cso_data-LIS5 |= S5_COLOR_DITHER_ENABLE;
 
-   /* XXX here take the target fixup into account */
+   /* We potentially do some fixup at emission for non-BGRA targets */
if ((blend-rt[0].colormask  PIPE_MASK_R) == 0)
   cso_data-LIS5 |= S5_WRITEDISABLE_RED;
 
@@ -276,7 +275,7 @@ i915_create_sampler_state(struct pipe_context *pipe,
   maxlod = CLAMP(maxlod, 0, 16 * 11);
 
   if (minlod  maxlod)
-maxlod = minlod;
+ maxlod = minlod;
 
   cso-minlod = minlod;
   cso-maxlod = maxlod;
@@ -499,7 +498,7 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
   (func  S6_DEPTH_TEST_FUNC_SHIFT));
 
   if (depth_stencil-depth.writemask)
-cso-depth_LIS6 |= S6_DEPTH_WRITE_ENABLE;
+ cso-depth_LIS6 |= S6_DEPTH_WRITE_ENABLE;
}
 
if (depth_stencil-alpha.enabled) {
diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 554e967..9c16e59 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -128,6 +128,70 @@ validate_immediate(struct i915_context *i915, unsigned 
*batch_space)
*batch_space = 1 + util_bitcount(dirty);
 }
 
+static uint target_fixup(struct pipe_surface *p, int component)
+{
+   const struct
+   {
+  enum pipe_format format;
+  uint hw_mask[4];
+   } fixup_mask[] = {
+  { PIPE_FORMAT_R8G8B8A8_UNORM, { S5_WRITEDISABLE_BLUE, 
S5_WRITEDISABLE_GREEN, S5_WRITEDISABLE_RED, S5_WRITEDISABLE_ALPHA}},
+  { PIPE_FORMAT_R8G8B8X8_UNORM, { S5_WRITEDISABLE_BLUE, 
S5_WRITEDISABLE_GREEN, S5_WRITEDISABLE_RED, S5_WRITEDISABLE_ALPHA}},
+  { PIPE_FORMAT_L8_UNORM,   { S5_WRITEDISABLE_RED | 
S5_WRITEDISABLE_GREEN | S5_WRITEDISABLE_BLUE, 0, 0, S5_WRITEDISABLE_ALPHA}},
+  { PIPE_FORMAT_I8_UNORM,   { S5_WRITEDISABLE_RED | 
S5_WRITEDISABLE_GREEN | S5_WRITEDISABLE_BLUE, 0, 0, S5_WRITEDISABLE_ALPHA}},
+  { PIPE_FORMAT_A8_UNORM,   { 0, 0, 0, S5_WRITEDISABLE_RED | 
S5_WRITEDISABLE_GREEN | S5_WRITEDISABLE_BLUE | S5_WRITEDISABLE_ALPHA}},
+  { 0,  { S5_WRITEDISABLE_RED, 
S5_WRITEDISABLE_GREEN, S5_WRITEDISABLE_BLUE, S5_WRITEDISABLE_ALPHA}}
+   };
+   int i = sizeof(fixup_mask) / sizeof(*fixup_mask);
+
+   if (p)
+  for(i = 0; fixup_mask[i].format != 0; i++)
+ if (p-format == fixup_mask[i].format)
+return fixup_mask[i].hw_mask[component];
+
+   /* Just return default masks */
+   return fixup_mask[i].hw_mask[component];
+}
+
+static void emit_immediate_s5(struct i915_context *i915, uint imm)
+{
+   /* Fixup write mask for non-BGRA render targets */
+   uint fixup_imm = imm  ~( S5_WRITEDISABLE_RED | S5_WRITEDISABLE_GREEN |
+ 

Mesa (master): mesa: Fix bug in unclamped float to ubyte conversion.

2013-06-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: bf2c074a2fb122bafbbe0f3c7978b89685f2698b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf2c074a2fb122bafbbe0f3c7978b89685f2698b

Author: Manfred Ernst ern...@chromium.org
Date:   Wed Jun 12 20:03:02 2013 -0700

mesa: Fix bug in unclamped float to ubyte conversion.

Problem: The IEEE float optimized version of UNCLAMPED_FLOAT_TO_UBYTE
in macros.h computed incorrect results for inputs in the range
0x3f7f (=0.99609375) to 0x3f7f7f80 (=0.99803924560546875)
inclusive.  0x3f7f7f80 is the IEEE float value that results in 254.5
when multiplied by 255.  With rounding mode round to closest even
integer, this is the largest float in the range 0.0-1.0 that is
converted to 254 by the generic implementation of
UNCLAMPED_FLOAT_TO_UBYTE.  The IEEE float optimized version
incorrectly defined the cut-off for mapping to 255 as 0x3f7f
(=255.0/256.0). The same bug was present in the function
float_to_ubyte in u_math.h.

Fix: The proposed fix replaces the incorrect cut-off value by
0x3f80, which is the IEEE float representation of 1.0f. 0x3f7f7f81
(or any value in between) would also work, but 1.0f is probably
cleaner.

The patch does not regress piglit on llvmpipe and on i965 on sandy
bridge.

Tested-by Stéphane Marchesin marc...@chromium.org
Reviewed-by Stéphane Marchesin marc...@chromium.org
Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/auxiliary/util/u_math.h |3 +--
 src/mesa/main/macros.h  |3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_math.h 
b/src/gallium/auxiliary/util/u_math.h
index 607fbec..64d16cb 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -540,14 +540,13 @@ ubyte_to_float(ubyte ub)
 static INLINE ubyte
 float_to_ubyte(float f)
 {
-   const int ieee_0996 = 0x3f7f;   /* 0.996 or so */
union fi tmp;
 
tmp.f = f;
if (tmp.i  0) {
   return (ubyte) 0;
}
-   else if (tmp.i = ieee_0996) {
+   else if (tmp.i = 0x3f80 /* 1.0f */) {
   return (ubyte) 255;
}
else {
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index ac02438..ddfeee2 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -141,7 +141,6 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
  *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]
  ***/
 #if defined(USE_IEEE)  !defined(DEBUG)
-#define IEEE_0996 0x3f7f   /* 0.996 or so */
 /* This function/macro is sensitive to precision.  Test very carefully
  * if you change it!
  */
@@ -151,7 +150,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
__tmp.f = (F);  \
if (__tmp.i  0)\
   UB = (GLubyte) 0;
\
-   else if (__tmp.i = IEEE_0996)  \
+   else if (__tmp.i = IEEE_ONE)   \
   UB = (GLubyte) 255;  \
else {  \
   __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F;  \

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


Mesa (master): st/xlib: Fix upside down coordinates for CopySubBuffer

2013-06-07 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 4e5416b0e2e0aedbed48acabe31a68fe1b37b61a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e5416b0e2e0aedbed48acabe31a68fe1b37b61a

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri May 10 18:29:52 2013 -0700

st/xlib: Fix upside down coordinates for CopySubBuffer

The coordinates need to be inverted between glX and gallium.

NOTE: This is a candidate for stable release branches.

Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/state_trackers/glx/xlib/xm_api.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c 
b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 66d29a5..c39968d 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -1255,7 +1255,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int 
width, int height )
 {
xmesa_copy_st_framebuffer(b-stfb,
  ST_ATTACHMENT_BACK_LEFT, ST_ATTACHMENT_FRONT_LEFT,
- x, y, width, height);
+ x, b-height - y - height, width, height);
 }
 
 

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


Mesa (master): st/xlib: Flush the front buffer before doing CopySubBuffer

2013-06-07 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 4f905d4900ea962876eb5933dd00d4b251767f71
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f905d4900ea962876eb5933dd00d4b251767f71

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri May 10 18:30:46 2013 -0700

st/xlib: Flush the front buffer before doing CopySubBuffer

We flush pending rendering before running CopySubBuffer, which
ensures that the right bits get to the screen.

NOTE: This is a candidate for stable release branches.

Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/state_trackers/glx/xlib/xm_api.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c 
b/src/gallium/state_trackers/glx/xlib/xm_api.c
index c39968d..b758c8e 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -1253,6 +1253,10 @@ void XMesaSwapBuffers( XMesaBuffer b )
  */
 void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
 {
+   XMesaContext xmctx = XMesaGetCurrentContext();
+
+   xmctx-st-flush( xmctx-st, ST_FLUSH_FRONT, NULL);
+
xmesa_copy_st_framebuffer(b-stfb,
  ST_ATTACHMENT_BACK_LEFT, ST_ATTACHMENT_FRONT_LEFT,
  x, b-height - y - height, width, height);

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


Mesa (master): i915g: Add more PIPE_CAP_* support

2013-05-08 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 7f7c7fda83eced002a4dbff483cded2e31313acd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f7c7fda83eced002a4dbff483cded2e31313acd

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sun Nov 11 02:10:29 2012 -0800

i915g: Add more PIPE_CAP_* support

---

 src/gallium/drivers/i915/i915_screen.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index dfb76b3..2d0cc78 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -215,6 +215,15 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
   return 0;
+   case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
+   case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
+   case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
+   case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
+   case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
+   return 0;
+
+   case PIPE_CAP_GLSL_FEATURE_LEVEL:
+  return 120;
 
case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
   return 16;

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


Mesa (master): i915g: Optimize batchbuffer sizes

2013-05-08 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: fc24c7aedeff6639e9438dbe7b91ca3775511223
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc24c7aedeff6639e9438dbe7b91ca3775511223

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat May  4 18:59:35 2013 -0700

i915g: Optimize batchbuffer sizes

Now that we don't throttle at every batchbuffer, we can shrink
the size of batchbuffers to achieve early flushing. This gives
a significant speed boost in a lot of games (on the order of
20%).

---

 src/gallium/drivers/i915/i915_prim_vbuf.c |8 +---
 src/gallium/winsys/i915/drm/i915_drm_winsys.c |2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_prim_vbuf.c 
b/src/gallium/drivers/i915/i915_prim_vbuf.c
index 4e57eea..f9cd71b 100644
--- a/src/gallium/drivers/i915/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915/i915_prim_vbuf.c
@@ -704,12 +704,14 @@ i915_vbuf_render_create(struct i915_context *i915)
 
i915_render-i915 = i915;
 
-   i915_render-base.max_vertex_buffer_bytes = 16*4096;
+   i915_render-base.max_vertex_buffer_bytes = 4*4096;
 
/* NOTE: it must be such that state and vertices indices fit in a single 
-* batch buffer.
+* batch buffer. 4096 is one batch buffer and 430 is the max amount of 
+* state in dwords. The result is the number of 16-bit indices which can
+* fit in a single batch buffer.
 */
-   i915_render-base.max_indices = 16*1024;
+   i915_render-base.max_indices = (4096 - 430 * 4) / 2;
 
i915_render-base.get_vertex_info = i915_vbuf_render_get_vertex_info;
i915_render-base.allocate_vertices = i915_vbuf_render_allocate_vertices;
diff --git a/src/gallium/winsys/i915/drm/i915_drm_winsys.c 
b/src/gallium/winsys/i915/drm/i915_drm_winsys.c
index 6c8a10d..9e16f40 100644
--- a/src/gallium/winsys/i915/drm/i915_drm_winsys.c
+++ b/src/gallium/winsys/i915/drm/i915_drm_winsys.c
@@ -56,7 +56,7 @@ i915_drm_winsys_create(int drmFD)
 
idws-fd = drmFD;
idws-base.pci_id = deviceID;
-   idws-max_batch_size = 16 * 4096;
+   idws-max_batch_size = 1 * 4096;
 
idws-base.destroy = i915_drm_winsys_destroy;
 

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


Mesa (master): i915: Use Y tiling for textures

2013-05-08 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 38d2a16c0113b905c46804695c4fafd1b5865d08
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=38d2a16c0113b905c46804695c4fafd1b5865d08

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat May  4 14:06:12 2013 -0700

i915: Use Y tiling for textures

This basically reverts commit
2acc7193743199701f8f6d1877a59ece0ec4fa5b.

With the previous change, we're not batchbuffer limited any
longer. So we actually start seeing a performance difference
between X and Y tiling. X tiling is funny because it is
faster for screen-aligned quads but slower in games. So let's
use Y tiling which is 10% faster overall.

---

 src/gallium/drivers/i915/i915_resource_texture.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_resource_texture.c 
b/src/gallium/drivers/i915/i915_resource_texture.c
index d9f58c0..3d61794 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -181,8 +181,13 @@ i915_texture_tiling(struct i915_screen *is, struct 
i915_texture *tex)
if (tex-b.b.target == PIPE_TEXTURE_1D)
   return I915_TILE_NONE;
 
-   /* Use X tiling for 2D, 3D and compressed textures */
-   return I915_TILE_X;
+   if (util_format_is_s3tc(tex-b.b.format))
+  return I915_TILE_X;
+
+   if (is-debug.use_blitter)
+  return I915_TILE_X;
+   else
+  return I915_TILE_Y;
 }
 
 

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


Mesa (master): draw/llvm: Add additional llvm optimization passes

2013-05-08 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 1c56fc1025e14827b69e4dd354aea4c9e487c0dd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c56fc1025e14827b69e4dd354aea4c9e487c0dd

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sun May  5 04:34:40 2013 -0700

draw/llvm: Add additional llvm optimization passes

It helps a bit with vertex shader performance on i915g
(a couple percent faster with openarena).

I have tried most other passes, and they weren't showing
any measurable improvement. Note that my vertex shaders
didn't have loops, so maybe the loop optimizations could
still be useful in the future.

Reviewed-by: Brian Paul bri...@vmware.com

---

 src/gallium/auxiliary/gallivm/lp_bld_init.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c 
b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 673c16e..4a428ee 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -147,7 +147,10 @@ create_pass_manager(struct gallivm_state *gallivm)
* but there are more on SVN.
* TODO: Add more passes.
*/
+  LLVMAddScalarReplAggregatesPass(gallivm-passmgr);
+  LLVMAddLICMPass(gallivm-passmgr);
   LLVMAddCFGSimplificationPass(gallivm-passmgr);
+  LLVMAddReassociatePass(gallivm-passmgr);
 
   if (HAVE_LLVM = 0x207  sizeof(void*) == 4) {
  /* For LLVM = 2.7 and 32-bit build, use this order of passes to

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


Mesa (master): i915g: Release old fragment shader sampler views with current pipe

2013-04-17 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 1a59cc777fb6c0383ed0c745000ca7409b1027d9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a59cc777fb6c0383ed0c745000ca7409b1027d9

Author: Stuart Abercrombie sabercrom...@chromium.org
Date:   Thu Apr 11 10:57:43 2013 -0700

i915g: Release old fragment shader sampler views with current pipe

We were trying to use a destroy method from a deleted context.
This fix is based on what's in the svga driver.

Reviewed-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/drivers/i915/i915_state.c |   11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 37ad1ed..4a4faa5 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -711,13 +711,18 @@ static void i915_set_fragment_sampler_views(struct 
pipe_context *pipe,
!memcmp(i915-fragment_sampler_views, views, num * sizeof(struct 
pipe_sampler_view *)))
   return;
 
-   for (i = 0; i  num; i++)
+   for (i = 0; i  num; i++) {
+  /* Note: we're using pipe_sampler_view_release() here to work around
+   * a possible crash when the old view belongs to another context that
+   * was already destroyed.
+   */
+  pipe_sampler_view_release(pipe, i915-fragment_sampler_views[i]);
   pipe_sampler_view_reference(i915-fragment_sampler_views[i],
   views[i]);
+   }
 
for (i = num; i  i915-num_fragment_sampler_views; i++)
-  pipe_sampler_view_reference(i915-fragment_sampler_views[i],
-  NULL);
+  pipe_sampler_view_release(pipe, i915-fragment_sampler_views[i]);
 
i915-num_fragment_sampler_views = num;
 

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


Mesa (master): ACTIVE_UNIFORM_MAX_LENGTH should include 3 extra characters for arrays.

2013-04-01 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: bc0cc2944ff13549df8276b856acc79254c5db07
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc0cc2944ff13549df8276b856acc79254c5db07

Author: Haixia Shi h...@chromium.org
Date:   Mon Apr  1 13:24:55 2013 -0700

ACTIVE_UNIFORM_MAX_LENGTH should include 3 extra characters for arrays.

If the active uniform is an array, then the length of the uniform name should
include the three extra characters for the [0] suffix, which is required by
the GL 4.2 spec to be appended to the uniform name in glGetActiveUniform().

This avoids the situation where the output buffer does not have enough space
to hold the [0] suffix, resulting in an incomplete array specification like
foobar[0.

NOTE: This is a candidate for the 9.1 branch.

Change-Id: I41e87ba347a7169eec8c575596cc3416adbe0728
Signed-off-by: Haixia Shi h...@chromium.org
Reviewed-by: Stéphane Marchesin marc...@chromium.org
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

---

 src/mesa/main/shaderapi.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index be69467..2c307e7 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -518,9 +518,11 @@ get_programiv(struct gl_context *ctx, GLuint program, 
GLenum pname, GLint *param
   GLint max_len = 0;
 
   for (i = 0; i  shProg-NumUserUniformStorage; i++) {
-/* Add one for the terminating NUL character.
+/* Add one for the terminating NUL character for a non-array, and
+ * 4 for the [0] and the NUL for an array.
  */
-const GLint len = strlen(shProg-UniformStorage[i].name) + 1;
+const GLint len = strlen(shProg-UniformStorage[i].name) + 1 +
+((shProg-UniformStorage[i].array_elements != 0) ? 3 : 0);
 
 if (len  max_len)
max_len = len;

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


Mesa (master): i915g: Update TODO

2013-03-08 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: d815e8af3944bca5eac7a0638da5529596735aef
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d815e8af3944bca5eac7a0638da5529596735aef

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Mar  8 16:16:33 2013 -0800

i915g: Update TODO

---

 src/gallium/drivers/i915/TODO |   13 +
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/i915/TODO b/src/gallium/drivers/i915/TODO
index c72f09a..8856a7e 100644
--- a/src/gallium/drivers/i915/TODO
+++ b/src/gallium/drivers/i915/TODO
@@ -1,19 +1,11 @@
 Random list of problems with i915g:
 
-- Add support for PIPE_CAP_POINT_SPRITE either via the draw module or directly
-  via the hardware, look at the classic driver, more advanced.
-
 - What does this button do? Figure out LIS7 with regards to depth offset.
 
 - Dies with BadDrawable on GLXFBconfig changes/destruction. Makes piglit 
totally
   unusable :( Upgrading xserver helped here, it doesn't crash anymore. Still
   broken, it doesn't update the viewport/get new buffers.
 
-- Kills the chip in 3D_PRIMITIVE LINELIST with mesa-demos/fbotexture in
-  wireframe mode. Changing the cullmode to cw from none mitigates the crash. As
-  does emitting only one line segment (2 indices) per 3D_PRIMITIVE command in
-  the batch.
-
 - Y-tiling is even more fun. i915c doesn't use it, maybe there's a reason?
   Texture sampling from Y-tiled buffers seems to work, though (save above
   problems).
@@ -34,16 +26,13 @@ Random list of problems with i915g:
 
 - Replace constants and immediates which are 0,1,-1 or a combination of those 
with a swizzle.
 
-- i915_delete_fs_state doesn't call draw_delete_fragment_shader. Why?
-
 - Schedule instructions to minimize the number of phases. One way is to replace
   R registers responsible for a boundary with U registers to avoid phase
   boundaries.
 
 - Continue a previous primitive when there are no state changes
 
-- Switch to the blitter for those buggy blit copies
-- Or state save/restore has a bug with u_blitter, fix it.
+- Fix fragment discard
 
 Other bugs can be found here:
 
https://bugs.freedesktop.org/buglist.cgi?bug_status=NEWbug_status=ASSIGNEDbug_status=REOPENEDcomponent=Drivers/Gallium/i915g

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


Mesa (master): i915g: Use PIPE_FLUSH_END_OF_FRAME to trigger throttling

2013-03-08 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 1662178863d7b715530274148aa57e6494f935a8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1662178863d7b715530274148aa57e6494f935a8

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Mar  8 13:32:55 2013 -0800

i915g: Use PIPE_FLUSH_END_OF_FRAME to trigger throttling

This helps with jittering, instead of throttling at every command
buffer we only throttle once a frame.

---

 src/gallium/drivers/i915/i915_batch.h  |8 +---
 src/gallium/drivers/i915/i915_blit.c   |8 
 src/gallium/drivers/i915/i915_clear.c  |6 +++---
 src/gallium/drivers/i915/i915_flush.c  |   16 ++--
 src/gallium/drivers/i915/i915_prim_emit.c  |2 +-
 src/gallium/drivers/i915/i915_prim_vbuf.c  |6 +++---
 src/gallium/drivers/i915/i915_state_emit.c |4 ++--
 src/gallium/drivers/i915/i915_winsys.h |9 -
 src/gallium/winsys/i915/drm/i915_drm_batchbuffer.c |8 +---
 src/gallium/winsys/i915/sw/i915_sw_batchbuffer.c   |3 ++-
 10 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_batch.h 
b/src/gallium/drivers/i915/i915_batch.h
index 0cb5801..5f2b324 100644
--- a/src/gallium/drivers/i915/i915_batch.h
+++ b/src/gallium/drivers/i915/i915_batch.h
@@ -47,12 +47,14 @@
 #define OUT_RELOC_FENCED(buf, usage, offset) \
i915_winsys_batchbuffer_reloc(i915-batch, buf, usage, offset, true)
 
-#define FLUSH_BATCH(fence) \
-   i915_flush(i915, fence)
+#define FLUSH_BATCH(fence, flags) \
+   i915_flush(i915, fence, flags)
 
 /
  * i915_flush.c
  */
-void i915_flush(struct i915_context *i915, struct pipe_fence_handle **fence);
+extern void i915_flush(struct i915_context *i915,
+   struct pipe_fence_handle **fence,
+   enum pipe_flush_flags flags);
 
 #endif
diff --git a/src/gallium/drivers/i915/i915_blit.c 
b/src/gallium/drivers/i915/i915_blit.c
index baaed37..ff81439 100644
--- a/src/gallium/drivers/i915/i915_blit.c
+++ b/src/gallium/drivers/i915/i915_blit.c
@@ -50,7 +50,7 @@ i915_fill_blit(struct i915_context *i915,
 __FUNCTION__, dst_buffer, dst_pitch, dst_offset, x, y, w, h);
 
if(!i915_winsys_validate_buffers(i915-batch, dst_buffer, 1)) {
-  FLUSH_BATCH(NULL);
+  FLUSH_BATCH(NULL, I915_FLUSH_ASYNC);
   assert(i915_winsys_validate_buffers(i915-batch, dst_buffer, 1));
}
 
@@ -72,7 +72,7 @@ i915_fill_blit(struct i915_context *i915,
}
 
if (!BEGIN_BATCH(6)) {
-  FLUSH_BATCH(NULL);
+  FLUSH_BATCH(NULL, I915_FLUSH_ASYNC);
   assert(BEGIN_BATCH(6));
}
OUT_BATCH(CMD);
@@ -111,7 +111,7 @@ i915_copy_blit(struct i915_context *i915,
 dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h);
 
if(!i915_winsys_validate_buffers(i915-batch, buffers, 2)) {
-  FLUSH_BATCH(NULL);
+  FLUSH_BATCH(NULL, I915_FLUSH_ASYNC);
   assert(i915_winsys_validate_buffers(i915-batch, buffers, 2));
}
 
@@ -144,7 +144,7 @@ i915_copy_blit(struct i915_context *i915,
assert (dst_pitch  0  src_pitch  0);
 
if (!BEGIN_BATCH(8)) {
-  FLUSH_BATCH(NULL);
+  FLUSH_BATCH(NULL, I915_FLUSH_ASYNC);
   assert(BEGIN_BATCH(8));
}
OUT_BATCH(CMD);
diff --git a/src/gallium/drivers/i915/i915_clear.c 
b/src/gallium/drivers/i915/i915_clear.c
index 30a3926..af75b85 100644
--- a/src/gallium/drivers/i915/i915_clear.c
+++ b/src/gallium/drivers/i915/i915_clear.c
@@ -123,7 +123,7 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
  i915_emit_hardware_state(i915);
 
   if (!BEGIN_BATCH(1 + 2*(7 + 7))) {
- FLUSH_BATCH(NULL);
+ FLUSH_BATCH(NULL, I915_FLUSH_ASYNC);
 
  i915_emit_hardware_state(i915);
  i915-vbo_flushed = 1;
@@ -174,7 +174,7 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
  i915_emit_hardware_state(i915);
 
   if (!BEGIN_BATCH(1 + 7 + 7)) {
- FLUSH_BATCH(NULL);
+ FLUSH_BATCH(NULL, I915_FLUSH_ASYNC);
 
  i915_emit_hardware_state(i915);
  i915-vbo_flushed = 1;
@@ -206,7 +206,7 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
/* Flush after clear, its expected to be a costly operation.
 * This is not required, just a heuristic, but without the flush we'd need 
to
 * clobber the SCISSOR_ENABLE dynamic state. */
-   FLUSH_BATCH(NULL);
+   FLUSH_BATCH(NULL, I915_FLUSH_ASYNC);
 
i915-last_fired_vertices = i915-fired_vertices;
i915-fired_vertices = 0;
diff --git a/src/gallium/drivers/i915/i915_flush.c 
b/src/gallium/drivers/i915/i915_flush.c
index d44b6f7..3db6ca1 100644
--- a/src/gallium/drivers/i915/i915_flush.c
+++ b/src/gallium/drivers/i915/i915_flush.c
@@ -33,9 +33,9 @@
 #include pipe/p_defines.h
 #include draw/draw_context.h
 #include i915_context.h
-#include i915_reg.h
 #include 

Mesa (master): glx: Check that swap_buffers_reply is non-NULL before using it

2013-01-29 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 67e7263e4567f36e59009a1ca076a2854a6c1b0e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=67e7263e4567f36e59009a1ca076a2854a6c1b0e

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon Jan 28 15:04:00 2013 -0800

glx: Check that swap_buffers_reply is non-NULL before using it

Check that the return value from xcb_dri2_swap_buffers_reply is
non-NULL before accessing the struct members.

Note: This is a candidate for the 9.0 branch.

Reviewed-by: Brian Paul bri...@vmware.com

---

 src/glx/dri2_glx.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index a51716f..78a2a42 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -789,9 +789,11 @@ dri2XcbSwapBuffers(Display *dpy,
 
swap_buffers_reply =
   xcb_dri2_swap_buffers_reply(c, swap_buffers_cookie, NULL);
-   ret = merge_counter(swap_buffers_reply-swap_hi,
-   swap_buffers_reply-swap_lo);
-   free(swap_buffers_reply);
+   if (swap_buffers_reply) {
+  ret = merge_counter(swap_buffers_reply-swap_hi,
+  swap_buffers_reply-swap_lo);
+  free(swap_buffers_reply);
+   }
return ret;
 }
 

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


Mesa (master): mesa: add bounds checking for uniform array access

2012-12-21 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 46e3aeb07702f57d389fbfcade9d4ef66218dc53
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=46e3aeb07702f57d389fbfcade9d4ef66218dc53

Author: Frank Henigman fjhenig...@google.com
Date:   Fri Dec 14 15:52:17 2012 -0500

mesa: add bounds checking for uniform array access

No piglit regressions and now passes glsl-uniform-out-of-bounds-2.

validate_uniform_parameters now checks that the array index is
valid.  This means if an index is out of bounds, glGetUniform* now
fails with GL_INVALID_OPERATION, as it should.
_mesa_uniform and _mesa_uniform_matrix also call
validate_uniform_parameters so the bounds checks there became
redundant and were removed.

The test in glGetUniformLocation is modified to check array bounds
so it now returns GL_INVALID_INDEX (-1) if you ask for the location
of a non-existent array element, as it should.

Signed-off-by: Frank Henigman fjhenig...@google.com
Reviewed-by: Stéphane Marchesin marc...@chromium.org

---

 src/mesa/main/uniform_query.cpp |   26 +-
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index b6b73d1..142ad1f 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -241,11 +241,14 @@ validate_uniform_parameters(struct gl_context *ctx,
   return false;
}
 
-   /* This case should be impossible.  The implication is that a call like
-* glGetUniformLocation(prog, foo[8]) was successful but foo is not an
-* array.
+   /* If the uniform is an array, check that array_index is in bounds.
+* If not an array, check that array_index is zero.
+* array_index is unsigned so no need to check for less than zero.
 */
-   if (*array_index != 0  shProg-UniformStorage[*loc].array_elements == 0) {
+   unsigned limit = shProg-UniformStorage[*loc].array_elements;
+   if (limit == 0)
+  limit = 1;
+   if (*array_index = limit) {
   _mesa_error(ctx, GL_INVALID_OPERATION, %s(location=%d),
  caller, location);
   return false;
@@ -732,9 +735,6 @@ _mesa_uniform(struct gl_context *ctx, struct 
gl_shader_program *shProg,
 * will have already generated an error.
 */
if (uni-array_elements != 0) {
-  if (offset = uni-array_elements)
-return;
-
   count = MIN2(count, (int) (uni-array_elements - offset));
}
 
@@ -889,9 +889,6 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct 
gl_shader_program *shProg,
 * will have already generated an error.
 */
if (uni-array_elements != 0) {
-  if (offset = uni-array_elements)
-return;
-
   count = MIN2(count, (int) (uni-array_elements - offset));
}
 
@@ -1025,10 +1022,13 @@ _mesa_get_uniform_location(struct gl_context *ctx,
if (!found)
   return GL_INVALID_INDEX;
 
-   /* Since array_elements is 0 for non-arrays, this causes look-ups of 'a[0]'
-* to (correctly) fail if 'a' is not an array.
+   /* If the uniform is an array, fail if the index is out of bounds.
+* (A negative index is caught above.)  This also fails if the uniform
+* is not an array, but the user is trying to index it, because
+* array_elements is zero and offset = 0.
 */
-   if (array_lookup  shProg-UniformStorage[location].array_elements == 0) {
+   if (array_lookup
+ offset = shProg-UniformStorage[location].array_elements) {
   return GL_INVALID_INDEX;
}
 

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


Mesa (master): llvmpipe: Fix build break from 75da95c50

2012-11-29 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 4430d44eac524e4910a01736edec34a0fbd428aa
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4430d44eac524e4910a01736edec34a0fbd428aa

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Nov 29 19:49:44 2012 -0800

llvmpipe: Fix build break from 75da95c50

The Makefile looks for a file which is gone (lp_tile_soa.c)

http://bugs.freedesktop.org/show_bug.cgi?id=57713

---

 src/gallium/drivers/llvmpipe/Makefile |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/Makefile 
b/src/gallium/drivers/llvmpipe/Makefile
index d8d136e..213cc26 100644
--- a/src/gallium/drivers/llvmpipe/Makefile
+++ b/src/gallium/drivers/llvmpipe/Makefile
@@ -45,8 +45,7 @@ C_SOURCES = \
lp_surface.c \
lp_tex_sample.c \
lp_texture.c \
-   lp_tile_image.c \
-   lp_tile_soa.c
+   lp_tile_image.c
 
 CPP_SOURCES = \
 

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


Mesa (master): i915g: Don't clobber I915_NEW_FS on new framebuffer.

2012-10-08 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 437a2560b19c97ee709fa31ed644f948229df637
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=437a2560b19c97ee709fa31ed644f948229df637

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon Oct  8 12:30:46 2012 -0700

i915g: Don't clobber I915_NEW_FS on new framebuffer.

This snuck in with a previous commit.

---

 src/gallium/drivers/i915/i915_state.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index aa2971c..a00e2fb 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -797,7 +797,7 @@ static void i915_set_framebuffer_state(struct pipe_context 
*pipe,
}
pipe_surface_reference(i915-framebuffer.zsbuf, fb-zsbuf);
 
-   i915-dirty |= I915_NEW_FRAMEBUFFER | I915_NEW_FS;
+   i915-dirty |= I915_NEW_FRAMEBUFFER;
 }
 
 

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


Mesa (master): i915g: Call draw_set_mapped_vertex_buffer from draw_vbo

2012-10-06 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 6ef37f71b0a0460808bb68a9102c15f313492c9f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ef37f71b0a0460808bb68a9102c15f313492c9f

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Oct  6 13:08:36 2012 -0700

i915g: Call draw_set_mapped_vertex_buffer from draw_vbo

This regressed with the draw rework. Fixes glest and vdrift crash.

---

 src/gallium/drivers/i915/i915_context.c |   18 +-
 src/gallium/drivers/i915/i915_state.c   |   14 --
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.c 
b/src/gallium/drivers/i915/i915_context.c
index 42d90ff..0ee6c0e 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -54,7 +54,7 @@ i915_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
struct i915_context *i915 = i915_context(pipe);
struct draw_context *draw = i915-draw;
const void *mapped_indices = NULL;
-
+   unsigned i;
 
/*
 * Ack vs contants here, helps ipers a lot.
@@ -65,6 +65,16 @@ i915_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
   i915_update_derived(i915);
 
/*
+* Map vertex buffers
+*/
+   for (i = 0; i  i915-nr_vertex_buffers; i++) {
+  const void *buf = i915-vertex_buffers[i].user_buffer;
+  if (!buf)
+buf = i915_buffer(i915-vertex_buffers[i].buffer)-data;
+  draw_set_mapped_vertex_buffer(draw, i, buf);
+   }
+
+   /*
 * Map index buffer, if present
 */
if (info-indexed) {
@@ -92,6 +102,12 @@ i915_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
 */
draw_vbo(i915-draw, info);
 
+   /*
+* unmap vertex/index buffers
+*/
+   for (i = 0; i  i915-nr_vertex_buffers; i++) {
+  draw_set_mapped_vertex_buffer(i915-draw, i, NULL);
+   }
if (mapped_indices)
   draw_set_indexes(draw, NULL, 0);
 
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 74a5df4..aa2971c 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -936,24 +936,10 @@ static void i915_set_vertex_buffers(struct pipe_context 
*pipe,
util_copy_vertex_buffers(i915-vertex_buffers,
 i915-nr_vertex_buffers,
 buffers, count);
-#if 0
-   /* XXX doesn't look like this is needed */
-   /* unmap old */
-   for (i = 0; i  i915-num_vertex_buffers; i++) {
-  draw_set_mapped_vertex_buffer(draw, i, NULL);
-   }
-#endif
 
/* pass-through to draw module */
draw_set_vertex_buffers(draw, count, buffers);
 
-   /* map new */
-   for (i = 0; i  count; i++) {
-  const void *buf = buffers[i].user_buffer;
-  if (!buf)
-buf = i915_buffer(buffers[i].buffer)-data;
-  draw_set_mapped_vertex_buffer(draw, i, buf);
-   }
 }
 
 static void *

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


Mesa (master): Revert i915g: Don't bind 0-length programs

2012-10-05 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 762ac0a218552d7861bdae350eaa3f2cd9241606
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=762ac0a218552d7861bdae350eaa3f2cd9241606

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Oct  5 12:43:49 2012 -0700

Revert i915g: Don't bind 0-length programs

This reverts commit 8c28a9bd733f5b51ab459c6bc626a5aaac5a6c0c.

---

 src/gallium/drivers/i915/i915_state_emit.c |   10 ++
 1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 7b4b02e..590a1ba 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -370,11 +370,6 @@ validate_program(struct i915_context *i915, unsigned 
*batch_space)
 {
uint additional_size = 0;
 
-   if (!i915-fs-program_len) {
-  *batch_space = 0;
-  return;
-   }
-
additional_size += i915-current.target_fixup_format ? 3 : 0;
 
/* we need more batch space if we want to emulate rgba framebuffers */
@@ -387,13 +382,12 @@ emit_program(struct i915_context *i915)
uint additional_size = 0;
uint i;
 
-   if (!i915-fs-program_len)
-  return;
-
/* count how much additional space we'll need */
validate_program(i915, additional_size);
additional_size -= i915-fs-decl_len + i915-fs-program_len;
 
+   /* we should always have, at least, a pass-through program */
+   assert(i915-fs-program_len  0);
 
/* output the declarations */
{

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


Mesa (master): i915g: Don't update I915_HW_PROGRAM in update_framebuffer

2012-10-05 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 98600c5ff674431fd325acec30ec42909c3ad8ed
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=98600c5ff674431fd325acec30ec42909c3ad8ed

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Oct  4 17:33:22 2012 -0700

i915g: Don't update I915_HW_PROGRAM in update_framebuffer

It's already going to be updated in update_dst_buf_vars.

---

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

diff --git a/src/gallium/drivers/i915/i915_state_static.c 
b/src/gallium/drivers/i915/i915_state_static.c
index 4d02097..41fe222 100644
--- a/src/gallium/drivers/i915/i915_state_static.c
+++ b/src/gallium/drivers/i915/i915_state_static.c
@@ -151,8 +151,7 @@ static void update_framebuffer(struct i915_context *i915)
   i915-static_dirty |= I915_DST_RECT;
}
 
-   /* we also send a new program to make sure the fixup for RGBA surfaces 
happens */
-   i915-hardware_dirty |= I915_HW_STATIC | I915_HW_PROGRAM;
+   i915-hardware_dirty |= I915_HW_STATIC;
 
/* flush the cache in case we sample from the old renderbuffers */
i915_set_flush_dirty(i915, I915_FLUSH_CACHE);
@@ -244,6 +243,7 @@ static void update_dst_buf_vars(struct i915_context *i915)
  i915-current.fixup_swizzle != fixup) {
   i915-current.target_fixup_format = need_fixup;
   i915-current.fixup_swizzle = fixup;
+  /* we also send a new program to make sure the fixup for RGBA surfaces 
happens */
   i915-hardware_dirty |= I915_HW_PROGRAM;
}
 }

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


Mesa (master): i915g: Remove the i915_context-saved_* stuff.

2012-10-05 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: dca9e3c4779936970dac796872a2399cd0437f63
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dca9e3c4779936970dac796872a2399cd0437f63

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Oct  4 17:37:37 2012 -0700

i915g: Remove the i915_context-saved_* stuff.

When using u_blitter, the state was being saved from saved_*, but we
don't use that. So after u_blitter resumed we got some corrupted
state in.

So let's just remove the saved_* stuff. I thought it was weird but
harmless, it's actually broken.

---

 src/gallium/drivers/i915/i915_context.h |   16 +
 src/gallium/drivers/i915/i915_state.c   |   35 +++---
 src/gallium/drivers/i915/i915_surface.c |   18 
 3 files changed, 23 insertions(+), 46 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index 4141a3d..719a0e8 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -234,6 +234,12 @@ struct i915_context {
 
struct i915_fragment_shader *fs;
 
+   void *vs;
+
+   struct i915_velems_state *velems;
+   unsigned nr_vertex_buffers;
+   struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
+
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
@@ -285,19 +291,9 @@ struct i915_context {
struct blitter_context* blitter;
 
/** State tracking needed by u_blitter for save/restore. */
-   void *saved_fs;
void (*saved_bind_fs_state)(struct pipe_context *pipe, void *shader);
-   void *saved_vs;
-   struct pipe_clip_state saved_clip;
-   struct i915_velems_state *saved_velems;
-   unsigned saved_nr_vertex_buffers;
-   struct pipe_vertex_buffer saved_vertex_buffers[PIPE_MAX_ATTRIBS];
-   unsigned saved_nr_samplers;
-   void *saved_samplers[PIPE_MAX_SAMPLERS];
void (*saved_bind_sampler_states)(struct pipe_context *pipe,
  unsigned num, void **sampler);
-   unsigned saved_nr_sampler_views;
-   struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS];
void (*saved_set_sampler_views)(struct pipe_context *pipe,
unsigned num, struct pipe_sampler_view 
**views);
 };
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 410615f..d3e62c9 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -296,9 +296,6 @@ static void i915_fixup_bind_sampler_states(struct 
pipe_context *pipe,
 {
struct i915_context *i915 = i915_context(pipe);
 
-   i915-saved_nr_samplers = num;
-   memcpy(i915-saved_samplers, sampler, sizeof(void *) * num);
-
i915-saved_bind_sampler_states(pipe, num, sampler);
 }
 
@@ -586,11 +583,6 @@ i915_fixup_bind_fs_state(struct pipe_context *pipe, void 
*shader)
 {
struct i915_context *i915 = i915_context(pipe);
 
-   if (i915-saved_fs == shader)
-  return;
-
-   i915-saved_fs = shader;
-
i915-saved_bind_fs_state(pipe, shader);
 }
 
@@ -645,10 +637,10 @@ static void i915_bind_vs_state(struct pipe_context *pipe, 
void *shader)
 {
struct i915_context *i915 = i915_context(pipe);
 
-   if (i915-saved_vs == shader)
+   if (i915-vs == shader)
   return;
 
-   i915-saved_vs = shader;
+   i915-vs = shader;
 
/* just pass-through to draw module */
draw_bind_vertex_shader(i915-draw, (struct draw_vertex_shader *) shader);
@@ -726,17 +718,6 @@ i915_fixup_set_fragment_sampler_views(struct pipe_context 
*pipe,
   struct pipe_sampler_view **views)
 {
struct i915_context *i915 = i915_context(pipe);
-   int i;
-
-   for (i = 0; i  num; i++)
-  pipe_sampler_view_reference(i915-saved_sampler_views[i],
-  views[i]);
-
-   for (i = num; i  i915-saved_nr_sampler_views; i++)
-  pipe_sampler_view_reference(i915-saved_sampler_views[i],
-  NULL);
-
-   i915-saved_nr_sampler_views = num;
 
i915-saved_set_sampler_views(pipe, num, views);
 }
@@ -842,7 +823,7 @@ static void i915_set_framebuffer_state(struct pipe_context 
*pipe,
}
pipe_surface_reference(i915-framebuffer.zsbuf, fb-zsbuf);
 
-   i915-dirty |= I915_NEW_FRAMEBUFFER;
+   i915-dirty |= I915_NEW_FRAMEBUFFER | I915_NEW_FS;
 }
 
 
@@ -852,7 +833,7 @@ static void i915_set_clip_state( struct pipe_context *pipe,
 {
struct i915_context *i915 = i915_context(pipe);
 
-   i915-saved_clip = *clip;
+   i915-clip = *clip;
 
draw_set_clip_state(i915-draw, clip);
 
@@ -978,8 +959,8 @@ static void i915_set_vertex_buffers(struct pipe_context 
*pipe,
struct draw_context *draw = i915-draw;
int i;
 
-   util_copy_vertex_buffers(i915-saved_vertex_buffers,
-i915-saved_nr_vertex_buffers,
+   util_copy_vertex_buffers(i915-vertex_buffers,
+i915-nr_vertex_buffers,
 

Mesa (master): i915g: Get rid of the fixup state functions.

2012-10-05 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 74b6ea49dfc1b8921de1768da937557150ee7893
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=74b6ea49dfc1b8921de1768da937557150ee7893

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Oct  4 17:57:31 2012 -0700

i915g: Get rid of the fixup state functions.

Now that the saved_* state is gone, we don't need those any longer.

---

 src/gallium/drivers/i915/i915_context.c |3 --
 src/gallium/drivers/i915/i915_context.h |8 --
 src/gallium/drivers/i915/i915_state.c   |   37 ---
 3 files changed, 0 insertions(+), 48 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.c 
b/src/gallium/drivers/i915/i915_context.c
index 1f2ca84..42d90ff 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -198,9 +198,6 @@ i915_create_context(struct pipe_screen *screen, void *priv)
draw_install_aapoint_stage(i915-draw, i915-base);
draw_enable_point_sprites(i915-draw, TRUE);
 
-   /* augmented draw pipeline clobbers state functions */
-   i915_init_fixup_state_functions(i915);
-
i915-dirty = ~0;
i915-hardware_dirty = ~0;
i915-immediate_dirty = ~0;
diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index 719a0e8..0c0555c 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -289,13 +289,6 @@ struct i915_context {
 
/** blitter/hw-clear */
struct blitter_context* blitter;
-
-   /** State tracking needed by u_blitter for save/restore. */
-   void (*saved_bind_fs_state)(struct pipe_context *pipe, void *shader);
-   void (*saved_bind_sampler_states)(struct pipe_context *pipe,
- unsigned num, void **sampler);
-   void (*saved_set_sampler_views)(struct pipe_context *pipe,
-   unsigned num, struct pipe_sampler_view 
**views);
 };
 
 /* A flag for each state_tracker state object:
@@ -400,7 +393,6 @@ void i915_clear_emit(struct pipe_context *pipe, unsigned 
buffers,
  * 
  */
 void i915_init_state_functions( struct i915_context *i915 );
-void i915_init_fixup_state_functions( struct i915_context *i915 );
 void i915_init_flush_functions( struct i915_context *i915 );
 void i915_init_string_functions( struct i915_context *i915 );
 
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index d3e62c9..74a5df4 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -291,14 +291,6 @@ i915_create_sampler_state(struct pipe_context *pipe,
return cso;
 }
 
-static void i915_fixup_bind_sampler_states(struct pipe_context *pipe,
-   unsigned num, void **sampler)
-{
-   struct i915_context *i915 = i915_context(pipe);
-
-   i915-saved_bind_sampler_states(pipe, num, sampler);
-}
-
 static void
 i915_bind_vertex_sampler_states(struct pipe_context *pipe,
 unsigned num_samplers,
@@ -579,14 +571,6 @@ i915_create_fs_state(struct pipe_context *pipe,
 }
 
 static void
-i915_fixup_bind_fs_state(struct pipe_context *pipe, void *shader)
-{
-   struct i915_context *i915 = i915_context(pipe);
-
-   i915-saved_bind_fs_state(pipe, shader);
-}
-
-static void
 i915_bind_fs_state(struct pipe_context *pipe, void *shader)
 {
struct i915_context *i915 = i915_context(pipe);
@@ -712,16 +696,6 @@ static void i915_set_constant_buffer(struct pipe_context 
*pipe,
 }
 
 
-static void
-i915_fixup_set_fragment_sampler_views(struct pipe_context *pipe,
-  unsigned num,
-  struct pipe_sampler_view **views)
-{
-   struct i915_context *i915 = i915_context(pipe);
-
-   i915-saved_set_sampler_views(pipe, num, views);
-}
-
 static void i915_set_fragment_sampler_views(struct pipe_context *pipe,
 unsigned num,
 struct pipe_sampler_view **views)
@@ -1085,14 +1059,3 @@ i915_init_state_functions( struct i915_context *i915 )
i915-base.set_vertex_buffers = i915_set_vertex_buffers;
i915-base.set_index_buffer = i915_set_index_buffer;
 }
-
-void
-i915_init_fixup_state_functions( struct i915_context *i915 )
-{
-   i915-saved_bind_fs_state = i915-base.bind_fs_state;
-   i915-base.bind_fs_state = i915_fixup_bind_fs_state;
-   i915-saved_bind_sampler_states = i915-base.bind_fragment_sampler_states;
-   i915-base.bind_fragment_sampler_states = i915_fixup_bind_sampler_states;
-   i915-saved_set_sampler_views = i915-base.set_fragment_sampler_views;
-   i915-base.set_fragment_sampler_views = 
i915_fixup_set_fragment_sampler_views;
-}

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


Mesa (master): i915g: Don't bind 0-length programs

2012-10-04 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 8c28a9bd733f5b51ab459c6bc626a5aaac5a6c0c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c28a9bd733f5b51ab459c6bc626a5aaac5a6c0c

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Oct  3 21:06:56 2012 -0700

i915g: Don't bind 0-length programs

Since we started doing fixups for different render target formats,
this has been an issue. Instead just don't do anything, when the
program gets emitted later it'll get the correct fixup.

Fixes a bunch of piglit tests.

---

 src/gallium/drivers/i915/i915_state_emit.c |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 590a1ba..7b4b02e 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -370,6 +370,11 @@ validate_program(struct i915_context *i915, unsigned 
*batch_space)
 {
uint additional_size = 0;
 
+   if (!i915-fs-program_len) {
+  *batch_space = 0;
+  return;
+   }
+
additional_size += i915-current.target_fixup_format ? 3 : 0;
 
/* we need more batch space if we want to emulate rgba framebuffers */
@@ -382,12 +387,13 @@ emit_program(struct i915_context *i915)
uint additional_size = 0;
uint i;
 
+   if (!i915-fs-program_len)
+  return;
+
/* count how much additional space we'll need */
validate_program(i915, additional_size);
additional_size -= i915-fs-decl_len + i915-fs-program_len;
 
-   /* we should always have, at least, a pass-through program */
-   assert(i915-fs-program_len  0);
 
/* output the declarations */
{

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


Mesa (master): i915g: Use X tiling for textures

2012-10-02 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 2acc7193743199701f8f6d1877a59ece0ec4fa5b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2acc7193743199701f8f6d1877a59ece0ec4fa5b

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon Sep 10 20:56:29 2012 -0700

i915g: Use X tiling for textures

This is what the classic driver does, and it allows faster
texture uploads.

---

 src/gallium/drivers/i915/i915_resource_texture.c |9 ++---
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_resource_texture.c 
b/src/gallium/drivers/i915/i915_resource_texture.c
index 603a379..83437af 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -181,13 +181,8 @@ i915_texture_tiling(struct i915_screen *is, struct 
i915_texture *tex)
if (tex-b.b.target == PIPE_TEXTURE_1D)
   return I915_TILE_NONE;
 
-   if (util_format_is_s3tc(tex-b.b.format))
-  return I915_TILE_X;
-
-   if (is-debug.use_blitter)
-  return I915_TILE_X;
-   else
-  return I915_TILE_Y;
+   /* Use X tiling for 2D, 3D and compressed textures */
+   return I915_TILE_X;
 }
 
 

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


Mesa (master): i915g: Implement srgb textures the easy way.

2012-10-02 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: fe3aeb7ea38770fce59b8261d8e2d37d4f68708f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe3aeb7ea38770fce59b8261d8e2d37d4f68708f

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon Oct  1 01:57:33 2012 -0700

i915g: Implement srgb textures the easy way.

Since the hw can do it, let's use the hw. It's less accurate
but doesn't have the shader instruction count shortcomings.

---

 src/gallium/drivers/i915/i915_context.h   |2 -
 src/gallium/drivers/i915/i915_state_emit.c|  101 +
 src/gallium/drivers/i915/i915_state_sampler.c |8 +-
 3 files changed, 9 insertions(+), 102 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index c9198e2..4141a3d 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -155,8 +155,6 @@ struct i915_state
unsigned sampler[I915_TEX_UNITS][3];
unsigned sampler_enable_flags;
unsigned sampler_enable_nr;
-   boolean sampler_srgb[I915_TEX_UNITS];
-   int srgb_const_offset;
 
/* texture image buffers */
unsigned texbuffer[I915_TEX_UNITS][2];
diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index ac99979..590a1ba 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -314,41 +314,12 @@ emit_sampler(struct i915_context *i915)
}
 }
 
-static boolean is_tex_instruction(uint32_t* instruction)
-{
-   uint32_t op = instruction[0] 0xFF00;
-   return ( (op == T0_TEXLD) ||
-(op == T0_TEXLDP) ||
-(op == T0_TEXLDB));
-}
-
-static uint32_t tex_sampler(uint32_t* instruction)
-{
-   return ( instruction[0]  T0_SAMPLER_NR_MASK);
-}
-
-static uint additional_constants(struct i915_context *i915)
-{
-   int i;
-
-   for (i = 0 ; i  i915-fs-program_len; i+=3) {
-  if ( is_tex_instruction(i915-fs-program + i)) {
-   int sampler = tex_sampler(i915-fs-program + i);
-   assert(sampler  I915_TEX_UNITS);
-   if ( i915-current.sampler_srgb[sampler] )
-  return 1;
-  }
-   }
-   return 0;
-}
-
 static void
 validate_constants(struct i915_context *i915, unsigned *batch_space)
 {
int nr = i915-fs-num_constants ?
   2 + 4*i915-fs-num_constants : 0;
 
-   nr += 4*additional_constants(i915);
*batch_space = nr;
 }
 
@@ -358,11 +329,10 @@ emit_constants(struct i915_context *i915)
/* Collate the user-defined constants with the fragment shader's
 * immediates according to the constant_flags[] array.
 */
-   const uint nr = i915-fs-num_constants + additional_constants(i915);
+   const uint nr = i915-fs-num_constants;
 
assert(nr  I915_MAX_CONSTANT);
if (nr) {
-  const float srgb_constants[4] = {1.0/1.055, 0.055/1.055, 2.4, 0.0822};
   uint i;
 
   OUT_BATCH( _3DSTATE_PIXEL_SHADER_CONSTANTS | (nr * 4) );
@@ -375,16 +345,9 @@ emit_constants(struct i915_context *i915)
 c = (uint *) 
i915_buffer(i915-constants[PIPE_SHADER_FRAGMENT])-data;
 c += 4 * i;
  }
- else if (i  i915-fs-num_constants) {
+ else {
 /* emit program constant */
 c = (uint *) i915-fs-constants[i];
- } else {
-/* emit constants for sRGB */
-
-/* save const position in context for use in shader emit */
-i915-current.srgb_const_offset = i;
-
-c = (uint *) srgb_constants;
  }
 #if 0 /* debug */
  {
@@ -405,64 +368,14 @@ emit_constants(struct i915_context *i915)
 static void
 validate_program(struct i915_context *i915, unsigned *batch_space)
 {
-   uint additional_size = 0, i;
+   uint additional_size = 0;
 
additional_size += i915-current.target_fixup_format ? 3 : 0;
 
-   for (i = 0 ; i  i915-fs-program_len; i+=3)
-  if ( is_tex_instruction(i915-fs-program + i) 
-   i915-current.sampler_srgb[tex_sampler(i915-fs-program+i)] )
- additional_size += 3 * 8 /* 8 instructions for srgb emulation */;
-
-   /* we need more batch space if we want to emulate rgba framebuffers
-* or sRGB textures */
+   /* we need more batch space if we want to emulate rgba framebuffers */
*batch_space = i915-fs-decl_len + i915-fs-program_len + additional_size;
 }
 
-static void emit_instruction(struct i915_context *i915,
- int op,
- int dst_mask,
-int dst_reg,
- int src0_reg,
- int src1_reg,
- int src2_reg)
-{
-   OUT_BATCH(op |
- dst_mask |
- 0 | /* saturate */
- A0_DEST(dst_reg) |
- A0_SRC0(src0_reg)
- );
-   OUT_BATCH(A1_SRC0(src0_reg) | A1_SRC1(src1_reg));
-   OUT_BATCH(A2_SRC1(src1_reg) | A2_SRC2(src2_reg));
-}
-
-static void
-emit_srgb_fixup(struct 

Mesa (master): glsl/linker: Avoid buffer over-run in parcel_out_uniform_storage::visit_field

2012-08-23 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: ff996cafce511dd8a6c4e066e409c23e147a670c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff996cafce511dd8a6c4e066e409c23e147a670c

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Aug 14 17:15:54 2012 -0700

glsl/linker: Avoid buffer over-run in parcel_out_uniform_storage::visit_field

When too may uniforms are used, the error will be caught in
check_resources (src/glsl/linker.cpp).

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Stéphane Marchesin marc...@chromium.org
Reviewed-by: Ian Romanick ian.d.roman...@intel.com
Tested-by: Benoit Jacob bja...@mozilla.com

---

 src/glsl/link_uniforms.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 25dc1d7..eef9025 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -313,7 +313,7 @@ private:
 const gl_texture_index target = base_type-sampler_index();
 const unsigned shadow = base_type-sampler_shadow;
 for (unsigned i = this-uniforms[id].sampler
-; i  this-next_sampler
+; i  MIN2(this-next_sampler, MAX_SAMPLERS)
 ; i++) {
this-targets[i] = target;
this-shader_samplers_used |= 1U  i;

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


Mesa (master): i915g: Implement sRGB textures

2012-06-27 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 45fc069600ddbfe07a0a0cd5280161a8c7c55dd0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=45fc069600ddbfe07a0a0cd5280161a8c7c55dd0

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon Jun 25 19:45:56 2012 -0700

i915g: Implement sRGB textures

Since we don't have them in hw we emulate them in the shader. Although not
recommended by the spec it is legit.

As a side effect we also get GL 2.1. I think this is as far as we can take
the i915.

---

 src/gallium/drivers/i915/i915_context.h   |2 +
 src/gallium/drivers/i915/i915_screen.c|5 +-
 src/gallium/drivers/i915/i915_state_emit.c|  128 +++--
 src/gallium/drivers/i915/i915_state_sampler.c |3 +
 src/gallium/drivers/i915/i915_state_static.c  |2 +-
 5 files changed, 128 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index b019c9f..16b0c57 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -155,6 +155,8 @@ struct i915_state
unsigned sampler[I915_TEX_UNITS][3];
unsigned sampler_enable_flags;
unsigned sampler_enable_nr;
+   boolean sampler_srgb[I915_TEX_UNITS];
+   int srgb_const_offset;
 
/* texture image buffers */
unsigned texbuffer[I915_TEX_UNITS][2];
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 9f29339..ff35203 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -110,7 +110,9 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned 
shader, enum pipe_sha
 return PIPE_MAX_VERTEX_SAMPLERS;
  else
 return 0;
-  default:
+  case PIPE_SHADER_CAP_INTEGERS:
+ return 1;
+   default:
  return draw_get_shader_param(shader, cap);
   }
case PIPE_SHADER_FRAGMENT:
@@ -290,6 +292,7 @@ i915_is_format_supported(struct pipe_screen *screen,
 {
static const enum pipe_format tex_supported[] = {
   PIPE_FORMAT_B8G8R8A8_UNORM,
+  PIPE_FORMAT_B8G8R8A8_SRGB,
   PIPE_FORMAT_B8G8R8X8_UNORM,
   PIPE_FORMAT_R8G8B8A8_UNORM,
   PIPE_FORMAT_R8G8B8X8_UNORM,
diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 8ab8fb8..ac99979 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -30,6 +30,7 @@
 #include i915_context.h
 #include i915_batch.h
 #include i915_debug.h
+#include i915_fpc.h
 #include i915_resource.h
 
 #include pipe/p_context.h
@@ -313,11 +314,42 @@ emit_sampler(struct i915_context *i915)
}
 }
 
+static boolean is_tex_instruction(uint32_t* instruction)
+{
+   uint32_t op = instruction[0] 0xFF00;
+   return ( (op == T0_TEXLD) ||
+(op == T0_TEXLDP) ||
+(op == T0_TEXLDB));
+}
+
+static uint32_t tex_sampler(uint32_t* instruction)
+{
+   return ( instruction[0]  T0_SAMPLER_NR_MASK);
+}
+
+static uint additional_constants(struct i915_context *i915)
+{
+   int i;
+
+   for (i = 0 ; i  i915-fs-program_len; i+=3) {
+  if ( is_tex_instruction(i915-fs-program + i)) {
+   int sampler = tex_sampler(i915-fs-program + i);
+   assert(sampler  I915_TEX_UNITS);
+   if ( i915-current.sampler_srgb[sampler] )
+  return 1;
+  }
+   }
+   return 0;
+}
+
 static void
 validate_constants(struct i915_context *i915, unsigned *batch_space)
 {
-   *batch_space = i915-fs-num_constants ?
+   int nr = i915-fs-num_constants ?
   2 + 4*i915-fs-num_constants : 0;
+
+   nr += 4*additional_constants(i915);
+   *batch_space = nr;
 }
 
 static void
@@ -326,8 +358,11 @@ emit_constants(struct i915_context *i915)
/* Collate the user-defined constants with the fragment shader's
 * immediates according to the constant_flags[] array.
 */
-   const uint nr = i915-fs-num_constants;
+   const uint nr = i915-fs-num_constants + additional_constants(i915);
+
+   assert(nr  I915_MAX_CONSTANT);
if (nr) {
+  const float srgb_constants[4] = {1.0/1.055, 0.055/1.055, 2.4, 0.0822};
   uint i;
 
   OUT_BATCH( _3DSTATE_PIXEL_SHADER_CONSTANTS | (nr * 4) );
@@ -340,9 +375,16 @@ emit_constants(struct i915_context *i915)
 c = (uint *) 
i915_buffer(i915-constants[PIPE_SHADER_FRAGMENT])-data;
 c += 4 * i;
  }
- else {
+ else if (i  i915-fs-num_constants) {
 /* emit program constant */
 c = (uint *) i915-fs-constants[i];
+ } else {
+/* emit constants for sRGB */
+
+/* save const position in context for use in shader emit */
+i915-current.srgb_const_offset = i;
+
+c = (uint *) srgb_constants;
  }
 #if 0 /* debug */
  {
@@ -363,18 +405,74 @@ emit_constants(struct i915_context *i915)
 static void
 validate_program(struct i915_context *i915, 

Mesa (master): i915g: More ops commute.

2012-06-15 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 841eee5d44b222a5819804726187683033eb71db
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=841eee5d44b222a5819804726187683033eb71db

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Jun 13 10:00:57 2012 -0700

i915g: More ops commute.

This allows using the optimizations more broadly.

---

 src/gallium/drivers/i915/TODO|3 +++
 src/gallium/drivers/i915/i915_fpc_optimize.c |   25 +++--
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/i915/TODO b/src/gallium/drivers/i915/TODO
index d52c1c0..c72f09a 100644
--- a/src/gallium/drivers/i915/TODO
+++ b/src/gallium/drivers/i915/TODO
@@ -42,5 +42,8 @@ Random list of problems with i915g:
 
 - Continue a previous primitive when there are no state changes
 
+- Switch to the blitter for those buggy blit copies
+- Or state save/restore has a bug with u_blitter, fix it.
+
 Other bugs can be found here:
 
https://bugs.freedesktop.org/buglist.cgi?bug_status=NEWbug_status=ASSIGNEDbug_status=REOPENEDcomponent=Drivers/Gallium/i915g
diff --git a/src/gallium/drivers/i915/i915_fpc_optimize.c 
b/src/gallium/drivers/i915/i915_fpc_optimize.c
index b09f18b..ce1c5f9 100644
--- a/src/gallium/drivers/i915/i915_fpc_optimize.c
+++ b/src/gallium/drivers/i915/i915_fpc_optimize.c
@@ -87,17 +87,30 @@ static boolean is_unswizzled(struct i915_full_src_register* 
r,
 
 static boolean op_commutes(unsigned opcode)
 {
-   if (opcode == TGSI_OPCODE_ADD) return TRUE;
-   if (opcode == TGSI_OPCODE_MUL) return TRUE;
+   switch(opcode)
+   {
+  case TGSI_OPCODE_ADD:
+  case TGSI_OPCODE_MUL:
+  case TGSI_OPCODE_DP2:
+  case TGSI_OPCODE_DP3:
+  case TGSI_OPCODE_DP4:
+ return TRUE;
+   }
return FALSE;
 }
 
 static unsigned op_neutral_element(unsigned opcode)
 {
-   if (opcode == TGSI_OPCODE_ADD)
-  return TGSI_SWIZZLE_ZERO;
-   if (opcode == TGSI_OPCODE_MUL)
-  return TGSI_SWIZZLE_ONE;
+   switch(opcode)
+   {
+  case TGSI_OPCODE_ADD:
+ return TGSI_SWIZZLE_ZERO;
+  case TGSI_OPCODE_MUL:
+  case TGSI_OPCODE_DP2:
+  case TGSI_OPCODE_DP3:
+  case TGSI_OPCODE_DP4:
+ return TGSI_SWIZZLE_ONE;
+   }
 
debug_printf(Unknown opcode %d\n,opcode);
return TGSI_SWIZZLE_ZERO;

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


Mesa (master): meta: Cleanup the resources we allocate.

2012-06-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 53feb8ecdc74502c940a749b9ce89e68625c69a5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=53feb8ecdc74502c940a749b9ce89e68625c69a5

Author: Antoine Labour pi...@chromium.org
Date:   Thu May 24 18:08:27 2012 -0700

meta: Cleanup the resources we allocate.

When we have multiple shared contexts, and one of them is
long-running, this will lead to never freeing those resources
since they are shared. Instead, free them right away on context
destruction since we know the other context isn't using them.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

NOTE: This is a candidate for the 8.0 branch.

---

 src/mesa/drivers/common/meta.c |   72 ---
 1 files changed, 66 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 8d7e901..be7141a 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -319,6 +319,10 @@ struct gl_meta_state
struct drawtex_state DrawTex;  /** For _mesa_meta_DrawTex() */
 };
 
+static void meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state 
*blit);
+static void cleanup_temp_texture(struct gl_context *ctx, struct temp_texture 
*tex);
+static void meta_glsl_clear_cleanup(struct gl_context *ctx, struct clear_state 
*clear);
+
 static GLuint
 compile_shader_with_debug(struct gl_context *ctx, GLenum target, const 
GLcharARB *source)
 {
@@ -335,12 +339,16 @@ compile_shader_with_debug(struct gl_context *ctx, GLenum 
target, const GLcharARB
   return shader;
 
_mesa_GetShaderiv(shader, GL_INFO_LOG_LENGTH, size);
-   if (size == 0)
+   if (size == 0) {
+  _mesa_DeleteObjectARB(shader);
   return 0;
+   }
 
info = malloc(size);
-   if (!info)
+   if (!info) {
+  _mesa_DeleteObjectARB(shader);
   return 0;
+   }
 
_mesa_GetProgramInfoLog(shader, size, NULL, info);
_mesa_problem(ctx,
@@ -349,6 +357,7 @@ compile_shader_with_debug(struct gl_context *ctx, GLenum 
target, const GLcharARB
 info, source);
 
free(info);
+   _mesa_DeleteObjectARB(shader);
 
return 0;
 }
@@ -401,10 +410,15 @@ _mesa_meta_init(struct gl_context *ctx)
 void
 _mesa_meta_free(struct gl_context *ctx)
 {
-   /* Note: Any textures, VBOs, etc, that we allocate should get
-* freed by the normal context destruction code.  But this would be
-* the place to free other meta data someday.
-*/
+   GET_CURRENT_CONTEXT(old_context);
+   _mesa_make_current(ctx, NULL, NULL);
+   meta_glsl_blit_cleanup(ctx, ctx-Meta-Blit);
+   meta_glsl_clear_cleanup(ctx, ctx-Meta-Clear);
+   cleanup_temp_texture(ctx, ctx-Meta-TempTex);
+   if (old_context)
+  _mesa_make_current(old_context, old_context-WinSysDrawBuffer, 
old_context-WinSysReadBuffer);
+   else
+  _mesa_make_current(NULL, NULL, NULL);
free(ctx-Meta);
ctx-Meta = NULL;
 }
@@ -1068,6 +1082,15 @@ init_temp_texture(struct gl_context *ctx, struct 
temp_texture *tex)
_mesa_GenTextures(1, tex-TexObj);
 }
 
+static void
+cleanup_temp_texture(struct gl_context *ctx, struct temp_texture *tex)
+{
+   if (!tex-TexObj)
+ return;
+   _mesa_DeleteTextures(1, tex-TexObj);
+   tex-TexObj = 0;
+}
+
 
 /**
  * Return pointer to temp_texture info for non-bitmap ops.
@@ -1604,6 +1627,21 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
}
 }
 
+static void
+meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit)
+{
+   if (blit-ArrayObj) {
+  _mesa_DeleteVertexArraysAPPLE(1, blit-ArrayObj);
+  blit-ArrayObj = 0;
+  _mesa_DeleteBuffersARB(1, blit-VBO);
+  blit-VBO = 0;
+   }
+   if (blit-DepthFP) {
+  _mesa_DeletePrograms(1, blit-DepthFP);
+  blit-DepthFP = 0;
+   }
+}
+
 
 /**
  * Meta implementation of ctx-Driver.Clear() in terms of polygon rendering.
@@ -1786,7 +1824,9 @@ meta_glsl_clear_init(struct gl_context *ctx, struct 
clear_state *clear)
 
clear-ShaderProg = _mesa_CreateProgramObjectARB();
_mesa_AttachShader(clear-ShaderProg, fs);
+   _mesa_DeleteObjectARB(fs);
_mesa_AttachShader(clear-ShaderProg, vs);
+   _mesa_DeleteObjectARB(vs);
_mesa_BindAttribLocationARB(clear-ShaderProg, 0, position);
_mesa_LinkProgramARB(clear-ShaderProg);
 
@@ -1799,7 +1839,9 @@ meta_glsl_clear_init(struct gl_context *ctx, struct 
clear_state *clear)
 
   clear-IntegerShaderProg = _mesa_CreateProgramObjectARB();
   _mesa_AttachShader(clear-IntegerShaderProg, fs);
+  _mesa_DeleteObjectARB(fs);
   _mesa_AttachShader(clear-IntegerShaderProg, vs);
+  _mesa_DeleteObjectARB(vs);
   _mesa_BindAttribLocationARB(clear-IntegerShaderProg, 0, position);
 
   /* Note that user-defined out attributes get automatically assigned
@@ -1814,6 +1856,24 @@ meta_glsl_clear_init(struct gl_context *ctx, struct 
clear_state *clear)
}
 }
 
+static void
+meta_glsl_clear_cleanup(struct gl_context *ctx, struct clear_state *clear)
+{
+   if (clear-ArrayObj == 0)
+  return;
+   

Mesa (master): mesa: Free uniforms correclty.

2012-06-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: e2e9b4b10fcf3ba6358b9be54638f850523af82e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e2e9b4b10fcf3ba6358b9be54638f850523af82e

Author: Antoine Labour pi...@chromium.org
Date:   Thu May 24 18:15:44 2012 -0700

mesa: Free uniforms correclty.

This is an array of uniforms, not a single one.

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

NOTE: This is a candidate for the 8.0 branch.

---

 src/mesa/main/shaderobj.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 7eb6f0b..d5ebf54 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -278,7 +278,8 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
 struct gl_shader_program *shProg)
 {
if (shProg-UniformStorage) {
-  _mesa_uniform_detach_all_driver_storage(shProg-UniformStorage);
+  for (unsigned i = 0; i  shProg-NumUserUniformStorage; ++i)
+ _mesa_uniform_detach_all_driver_storage(shProg-UniformStorage[i]);
   ralloc_free(shProg-UniformStorage);
   shProg-NumUserUniformStorage = 0;
   shProg-UniformStorage = NULL;

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


Mesa (master): mesa: Fix hash table leak

2012-06-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 3c9fab88226af8360817c01ecde38348284e6ce7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3c9fab88226af8360817c01ecde38348284e6ce7

Author: Antoine Labour pi...@chromium.org
Date:   Thu May 24 18:17:50 2012 -0700

mesa: Fix hash table leak

When a value was replaced, the new key was strdup'd and leaked.
To fix this, we modify the hash table implementation to return
whether the value was replaced and free() the (now useless)
duplicate string.

---

 src/mesa/program/hash_table.c |5 +++--
 src/mesa/program/hash_table.h |   16 
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/mesa/program/hash_table.c b/src/mesa/program/hash_table.c
index dc8563a..7dabadc 100644
--- a/src/mesa/program/hash_table.c
+++ b/src/mesa/program/hash_table.c
@@ -149,7 +149,7 @@ hash_table_insert(struct hash_table *ht, void *data, const 
void *key)
 insert_at_head( ht-buckets[bucket],  node-link);
 }
 
-void
+bool
 hash_table_replace(struct hash_table *ht, void *data, const void *key)
 {
 const unsigned hash_value = (*ht-hash)(key);
@@ -162,7 +162,7 @@ hash_table_replace(struct hash_table *ht, void *data, const 
void *key)
 
if ((*ht-compare)(hn-key, key) == 0) {
  hn-data = data;
- return;
+ return true;
}
 }
 
@@ -172,6 +172,7 @@ hash_table_replace(struct hash_table *ht, void *data, const 
void *key)
 hn-key = key;
 
 insert_at_head( ht-buckets[bucket],  hn-link);
+return false;
 }
 
 void
diff --git a/src/mesa/program/hash_table.h b/src/mesa/program/hash_table.h
index bcf65df..a14bf13 100644
--- a/src/mesa/program/hash_table.h
+++ b/src/mesa/program/hash_table.h
@@ -114,6 +114,10 @@ extern void hash_table_insert(struct hash_table *ht, void 
*data,
 /**
  * Add an element to a hash table with replacement
  *
+ * \return
+ * 1 if it did replace the the value (in which case the old key is kept), 0 if
+ * it did not replace the value (in which case the new key is kept).
+ *
  * \warning
  * If \c key is already in the hash table, \c data will \b replace the most
  * recently inserted \c data (see the warning in \c hash_table_insert) for
@@ -121,7 +125,7 @@ extern void hash_table_insert(struct hash_table *ht, void 
*data,
  *
  * \sa hash_table_insert
  */
-extern void hash_table_replace(struct hash_table *ht, void *data,
+extern int hash_table_replace(struct hash_table *ht, void *data,
 const void *key);
 
 /**
@@ -219,6 +223,7 @@ public:
 */
void clear()
{
+  hash_table_call_foreach(this-ht, delete_key, NULL);
   hash_table_clear(this-ht);
}
 
@@ -258,9 +263,12 @@ public:
* because UINT_MAX+1 = 0.
*/
   assert(value != UINT_MAX);
-  hash_table_replace(this-ht,
-(void *) (intptr_t) (value + 1),
-strdup(key));
+  char *dup_key = strdup(key);
+  int result = hash_table_replace(this-ht,
+ (void *) (intptr_t) (value + 1),
+ dup_key);
+  if (result)
+free(dup_key);
}
 
 private:

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


Mesa (master): mesa: Fix bool-int mismatch

2012-06-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: a74c4fb89dee398a955415f0b5641bd9c5888c75
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a74c4fb89dee398a955415f0b5641bd9c5888c75

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Jun 12 15:11:21 2012 -0700

mesa: Fix bool-int mismatch

Also include stdbool for windows.

---

 src/mesa/program/hash_table.h |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/mesa/program/hash_table.h b/src/mesa/program/hash_table.h
index a14bf13..e95fc49 100644
--- a/src/mesa/program/hash_table.h
+++ b/src/mesa/program/hash_table.h
@@ -32,6 +32,7 @@
 #define HASH_TABLE_H
 
 #include string.h
+#include stdbool.h
 #include stdlib.h
 #include stdint.h
 #include limits.h
@@ -125,7 +126,7 @@ extern void hash_table_insert(struct hash_table *ht, void 
*data,
  *
  * \sa hash_table_insert
  */
-extern int hash_table_replace(struct hash_table *ht, void *data,
+extern bool hash_table_replace(struct hash_table *ht, void *data,
 const void *key);
 
 /**
@@ -264,9 +265,9 @@ public:
*/
   assert(value != UINT_MAX);
   char *dup_key = strdup(key);
-  int result = hash_table_replace(this-ht,
- (void *) (intptr_t) (value + 1),
- dup_key);
+  bool result = hash_table_replace(this-ht,
+  (void *) (intptr_t) (value + 1),
+  dup_key);
   if (result)
 free(dup_key);
}

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


Mesa (master): Revert i915g: Remove unused poly stipple state.

2012-04-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 05265bee8554241d98e741643d62ad2f8d270192
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=05265bee8554241d98e741643d62ad2f8d270192

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Apr 12 18:30:59 2012 -0700

Revert i915g: Remove unused poly stipple state.

This reverts commit be6a02266d1a934c6eff9aaf12fc618588b2d586.

---

 src/gallium/drivers/i915/i915_context.h   |1 +
 src/gallium/drivers/i915/i915_state_dynamic.c |   53 +
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index 5790a2d..b019c9f 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -239,6 +239,7 @@ struct i915_context {
struct pipe_clip_state clip;
struct pipe_resource *constants[PIPE_SHADER_TYPES];
struct pipe_framebuffer_state framebuffer;
+   struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_SAMPLERS];
diff --git a/src/gallium/drivers/i915/i915_state_dynamic.c 
b/src/gallium/drivers/i915/i915_state_dynamic.c
index 7e17597..1a21433 100644
--- a/src/gallium/drivers/i915/i915_state_dynamic.c
+++ b/src/gallium/drivers/i915/i915_state_dynamic.c
@@ -194,6 +194,58 @@ const struct i915_tracked_state i915_upload_DEPTHSCALE = {
 
 
 /***
+ * Polygon stipple
+ *
+ * The i915 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern.
+ *
+ * XXX: does stipple pattern need to be adjusted according to
+ * the window position?
+ *
+ * XXX: possibly need workaround for conform paths test.
+ */
+static void upload_STIPPLE(struct i915_context *i915)
+{
+   unsigned st[2];
+
+   st[0] = _3DSTATE_STIPPLE;
+   st[1] = 0;
+
+   /* I915_NEW_RASTERIZER
+*/
+   st[1] |= i915-rasterizer-st;
+
+   /* I915_NEW_STIPPLE
+*/
+   {
+  const ubyte *mask = (const ubyte *)i915-poly_stipple.stipple;
+  ubyte p[4];
+
+  p[0] = mask[12]  0xf;
+  p[1] = mask[8]  0xf;
+  p[2] = mask[4]  0xf;
+  p[3] = mask[0]  0xf;
+
+  /* Not sure what to do about fallbacks, so for now just dont:
+   */
+  st[1] |= ((p[0]  0) |
+(p[1]  4) |
+(p[2]  8) |
+(p[3]  12));
+   }
+
+   set_dynamic_array(i915, I915_DYNAMIC_STP_0, st, 2);
+}
+
+const struct i915_tracked_state i915_upload_STIPPLE = {
+   STIPPLE,
+   upload_STIPPLE,
+   I915_NEW_RASTERIZER | I915_NEW_STIPPLE
+};
+
+
+
+/***
  * Scissor enable
  */
 static void upload_SCISSOR_ENABLE( struct i915_context *i915 )
@@ -243,6 +295,7 @@ static const struct i915_tracked_state *atoms[] = {
i915_upload_BLENDCOLOR,
i915_upload_IAB,
i915_upload_DEPTHSCALE,
+   i915_upload_STIPPLE,
i915_upload_SCISSOR_ENABLE,
i915_upload_SCISSOR_RECT
 };

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


Mesa (master): Revert i915g: Implement stipple with draw.

2012-04-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 368878cc5f9a09afc6c254bcb73c2267633a5d6d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=368878cc5f9a09afc6c254bcb73c2267633a5d6d

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Apr 12 18:31:10 2012 -0700

Revert i915g: Implement stipple with draw.

This reverts commit 3cff45fdb182a1327f6b89fdc4e0ddc5d680372a.

---

 src/gallium/drivers/i915/i915_context.c |1 -
 src/gallium/drivers/i915/i915_state.c   |2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.c 
b/src/gallium/drivers/i915/i915_context.c
index 5e0ced2..052a059 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -184,7 +184,6 @@ i915_create_context(struct pipe_screen *screen, void *priv)
 
draw_install_aaline_stage(i915-draw, i915-base);
draw_install_aapoint_stage(i915-draw, i915-base);
-   draw_install_pstipple_stage(i915-draw, i915-base);
draw_enable_point_sprites(i915-draw, TRUE);
 
/* augmented draw pipeline clobbers state functions */
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index f7ebfcd..4c284d9 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -553,7 +553,7 @@ static void i915_set_scissor_state( struct pipe_context 
*pipe,
 
 
 static void i915_set_polygon_stipple( struct pipe_context *pipe,
-  const struct pipe_poly_stipple *stipple )
+   const struct pipe_poly_stipple *stipple )
 {
 }
 

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


Mesa (master): i915g: Fix fallout from 8e4540ec2a82e72be491bc8fe23c10551d29a96c

2012-02-24 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 6512bc4e67f0f2b53805d050e11f6a336b505f40
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6512bc4e67f0f2b53805d050e11f6a336b505f40

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Feb 24 15:17:27 2012 -0800

i915g: Fix fallout from 8e4540ec2a82e72be491bc8fe23c10551d29a96c

Fixes piglit regressions from that change.

---

 src/gallium/drivers/i915/i915_fpc_translate.c |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c 
b/src/gallium/drivers/i915/i915_fpc_translate.c
index 1adbbe5..94c0c69 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -49,7 +49,7 @@
  * Simple pass-through fragment shader to use when we don't have
  * a real shader (or it fails to compile for some reason).
  */
-static unsigned passthrough[] =
+static unsigned passthrough_decl[] =
 {
_3DSTATE_PIXEL_SHADER_PROGRAM | ((2*3)-1),
 
@@ -61,7 +61,10 @@ static unsigned passthrough[] =
 D0_CHANNEL_ALL),
0,
0,
+};
 
+static unsigned passthrough_program[] =
+{
/* move to output color:
 */
(A0_MOV |
@@ -125,10 +128,13 @@ negate(int reg, int x, int y, int z, int w)
 static void
 i915_use_passthrough_shader(struct i915_fragment_shader *fs)
 {
-   fs-program = (uint *) MALLOC(sizeof(passthrough));
+   fs-program = (uint *) MALLOC(sizeof(passthrough_program));
+   fs-decl = (uint *) MALLOC(sizeof(passthrough_decl));
if (fs-program) {
-  memcpy(fs-program, passthrough, sizeof(passthrough));
-  fs-program_len = Elements(passthrough);
+  memcpy(fs-program, passthrough_program, sizeof(passthrough_program));
+  memcpy(fs-decl, passthrough_decl, sizeof(passthrough_decl));
+  fs-program_len = Elements(passthrough_program);
+  fs-decl_len = Elements(passthrough_decl);
}
fs-num_constants = 0;
 }

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


Mesa (master): i915g: Separate declarations and program in the fragment program struct.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 8e4540ec2a82e72be491bc8fe23c10551d29a96c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8e4540ec2a82e72be491bc8fe23c10551d29a96c

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sun Jan 22 02:22:20 2012 -0800

i915g: Separate declarations and program in the fragment program struct.

We need this later to fixup fragment programs properly.

---

 src/gallium/drivers/i915/i915_context.h   |3 +++
 src/gallium/drivers/i915/i915_fpc_translate.c |   19 ++-
 src/gallium/drivers/i915/i915_state.c |6 ++
 src/gallium/drivers/i915/i915_state_emit.c|   12 
 4 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index e39c7cc..b019c9f 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -104,6 +104,9 @@ struct i915_fragment_shader
 
struct draw_fragment_shader *draw_data;
 
+   uint *decl;
+   uint decl_len;
+
uint *program;
uint program_len;
 
diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c 
b/src/gallium/drivers/i915/i915_fpc_translate.c
index 5bfbfa0..a82ad14 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -1277,17 +1277,26 @@ i915_fini_compile(struct i915_context *i915, struct 
i915_fp_compile *p)
 
   /* Copy compilation results to fragment program struct: 
*/
+  assert(!ifs-decl);
   assert(!ifs-program);
+
+  ifs-decl
+ = (uint *) MALLOC(decl_size * sizeof(uint));
   ifs-program
- = (uint *) MALLOC((program_size + decl_size) * sizeof(uint));
-  if (ifs-program) {
- ifs-program_len = program_size + decl_size;
+ = (uint *) MALLOC(program_size * sizeof(uint));
 
- memcpy(ifs-program,
+  if (ifs-decl) {
+ ifs-decl_len = decl_size;
+
+ memcpy(ifs-decl,
 p-declarations,
 decl_size * sizeof(uint));
+  }
+
+  if (ifs-program) {
+ ifs-program_len = program_size;
 
- memcpy(ifs-program + decl_size,
+ memcpy(ifs-program,
 p-program,
 program_size * sizeof(uint));
   }
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 853468c..d0063e3 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -608,6 +608,11 @@ void i915_delete_fs_state(struct pipe_context *pipe, void 
*shader)
 {
struct i915_fragment_shader *ifs = (struct i915_fragment_shader *) shader;
 
+   if (ifs-decl) {
+  FREE(ifs-decl);
+  ifs-decl = NULL;
+   }
+
if (ifs-program) {
   FREE(ifs-program);
   ifs-program = NULL;
@@ -615,6 +620,7 @@ void i915_delete_fs_state(struct pipe_context *pipe, void 
*shader)
   ifs-state.tokens = NULL;
}
ifs-program_len = 0;
+   ifs-decl_len = 0;
 
FREE(ifs);
 }
diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 9c941ae..2aed3f1 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -366,7 +366,7 @@ validate_program(struct i915_context *i915, unsigned 
*batch_space)
uint additional_size = i915-current.target_fixup_format ? 1 : 0;
 
/* we need more batch space if we want to emulate rgba framebuffers */
-   *batch_space = i915-fs-program_len + 3 * additional_size;
+   *batch_space = i915-fs-decl_len + i915-fs-program_len + 3 * 
additional_size;
 }
 
 static void
@@ -378,15 +378,19 @@ emit_program(struct i915_context *i915)
/* we should always have, at least, a pass-through program */
assert(i915-fs-program_len  0);
 
+   /* output the declarations */
{
   /* first word has the size, we have to adjust that */
-  uint size = (i915-fs-program[0]);
+  uint size = (i915-fs-decl[0]);
   size += need_target_fixup * 3;
   OUT_BATCH(size);
}
 
-   /* output the declarations and the program */
-   for (i = 1 ; i  i915-fs-program_len; i++)
+   for (i = 1 ; i  i915-fs-decl_len; i++)
+  OUT_BATCH(i915-fs-decl[i]);
+
+   /* output the program */
+   for (i = 0 ; i  i915-fs-program_len; i++)
   OUT_BATCH(i915-fs-program[i]);
 
/* we emit an additional mov with swizzle to fake RGBA framebuffers */

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


Mesa (master): i915g: Fix comment.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 175adf0776d8df066a908b06055f243bd1325a34
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=175adf0776d8df066a908b06055f243bd1325a34

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sun Jan 22 23:44:31 2012 -0800

i915g: Fix comment.

---

 src/gallium/drivers/i915/i915_fpc_translate.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c 
b/src/gallium/drivers/i915/i915_fpc_translate.c
index a82ad14..1adbbe5 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -528,7 +528,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
   i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0);
 
   /* 
-   * t0.xy = MUL x.xx11, x.x  ; x^2, x, 1, 1
+   * t0.xy = MUL x.xx11, x.x111  ; x^2, x, 1, 1
* t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, 1
* t0 = MUL t0.xxz1 t0.z111; x^6 x^4 x^2 1
* result = DP4 t0, cos_constants

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


Mesa (master): i915g: Move ureg defines to the header so we can share them.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 4dc0425261fbd62e38eb5fac7f88e88d50d0cc7b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4dc0425261fbd62e38eb5fac7f88e88d50d0cc7b

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Feb  7 04:57:04 2012 +0100

i915g: Move ureg defines to the header so we can share them.

---

 src/gallium/drivers/i915/i915_fpc.h  |   32 ++
 src/gallium/drivers/i915/i915_fpc_emit.c |   32 --
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc.h 
b/src/gallium/drivers/i915/i915_fpc.h
index 26cf2fb..9e4a7ea 100644
--- a/src/gallium/drivers/i915/i915_fpc.h
+++ b/src/gallium/drivers/i915/i915_fpc.h
@@ -151,6 +151,38 @@ swizzle(int reg, uint x, uint y, uint z, uint w)
 }
 
 
+#define A0_DEST( reg ) (((reg)UREG_TYPE_NR_MASK)UREG_A0_DEST_SHIFT_LEFT)
+#define D0_DEST( reg ) (((reg)UREG_TYPE_NR_MASK)UREG_A0_DEST_SHIFT_LEFT)
+#define T0_DEST( reg ) (((reg)UREG_TYPE_NR_MASK)UREG_A0_DEST_SHIFT_LEFT)
+#define A0_SRC0( reg ) (((reg)UREG_MASK)UREG_A0_SRC0_SHIFT_LEFT)
+#define A1_SRC0( reg ) (((reg)UREG_MASK)UREG_A1_SRC0_SHIFT_RIGHT)
+#define A1_SRC1( reg ) (((reg)UREG_MASK)UREG_A1_SRC1_SHIFT_LEFT)
+#define A2_SRC1( reg ) (((reg)UREG_MASK)UREG_A2_SRC1_SHIFT_RIGHT)
+#define A2_SRC2( reg ) (((reg)UREG_MASK)UREG_A2_SRC2_SHIFT_LEFT)
+
+/* These are special, and don't have swizzle/negate bits.
+ */
+#define T0_SAMPLER( reg ) (GET_UREG_NR(reg)T0_SAMPLER_NR_SHIFT)
+#define T1_ADDRESS_REG( reg ) ((GET_UREG_NR(reg)T1_ADDRESS_REG_NR_SHIFT) | \
+  (GET_UREG_TYPE(reg)T1_ADDRESS_REG_TYPE_SHIFT))
+
+
+/* Macros for translating UREG's into the various register fields used
+ * by the I915 programmable unit.
+ */
+#define UREG_A0_DEST_SHIFT_LEFT  (UREG_TYPE_SHIFT - A0_DEST_TYPE_SHIFT)
+#define UREG_A0_SRC0_SHIFT_LEFT  (UREG_TYPE_SHIFT - A0_SRC0_TYPE_SHIFT)
+#define UREG_A1_SRC0_SHIFT_RIGHT (A1_SRC0_CHANNEL_W_SHIFT - 
UREG_CHANNEL_W_SHIFT)
+#define UREG_A1_SRC1_SHIFT_LEFT  (UREG_TYPE_SHIFT - A1_SRC1_TYPE_SHIFT)
+#define UREG_A2_SRC1_SHIFT_RIGHT (A2_SRC1_CHANNEL_W_SHIFT - 
UREG_CHANNEL_W_SHIFT)
+#define UREG_A2_SRC2_SHIFT_LEFT  (UREG_TYPE_SHIFT - A2_SRC2_TYPE_SHIFT)
+
+#define UREG_MASK 0xff00
+#define UREG_TYPE_NR_MASK ((REG_TYPE_MASK  UREG_TYPE_SHIFT) | \
+  (REG_NR_MASK  UREG_NR_SHIFT))
+
+
+
 
 /***
  * Public interface for the compiler
diff --git a/src/gallium/drivers/i915/i915_fpc_emit.c 
b/src/gallium/drivers/i915/i915_fpc_emit.c
index eff0937..683cef0 100644
--- a/src/gallium/drivers/i915/i915_fpc_emit.c
+++ b/src/gallium/drivers/i915/i915_fpc_emit.c
@@ -30,38 +30,6 @@
 #include i915_fpc.h
 #include util/u_math.h
 
-
-#define A0_DEST( reg ) (((reg)UREG_TYPE_NR_MASK)UREG_A0_DEST_SHIFT_LEFT)
-#define D0_DEST( reg ) (((reg)UREG_TYPE_NR_MASK)UREG_A0_DEST_SHIFT_LEFT)
-#define T0_DEST( reg ) (((reg)UREG_TYPE_NR_MASK)UREG_A0_DEST_SHIFT_LEFT)
-#define A0_SRC0( reg ) (((reg)UREG_MASK)UREG_A0_SRC0_SHIFT_LEFT)
-#define A1_SRC0( reg ) (((reg)UREG_MASK)UREG_A1_SRC0_SHIFT_RIGHT)
-#define A1_SRC1( reg ) (((reg)UREG_MASK)UREG_A1_SRC1_SHIFT_LEFT)
-#define A2_SRC1( reg ) (((reg)UREG_MASK)UREG_A2_SRC1_SHIFT_RIGHT)
-#define A2_SRC2( reg ) (((reg)UREG_MASK)UREG_A2_SRC2_SHIFT_LEFT)
-
-/* These are special, and don't have swizzle/negate bits.
- */
-#define T0_SAMPLER( reg ) (GET_UREG_NR(reg)T0_SAMPLER_NR_SHIFT)
-#define T1_ADDRESS_REG( reg ) ((GET_UREG_NR(reg)T1_ADDRESS_REG_NR_SHIFT) | \
-  (GET_UREG_TYPE(reg)T1_ADDRESS_REG_TYPE_SHIFT))
-
-
-/* Macros for translating UREG's into the various register fields used
- * by the I915 programmable unit.
- */
-#define UREG_A0_DEST_SHIFT_LEFT  (UREG_TYPE_SHIFT - A0_DEST_TYPE_SHIFT)
-#define UREG_A0_SRC0_SHIFT_LEFT  (UREG_TYPE_SHIFT - A0_SRC0_TYPE_SHIFT)
-#define UREG_A1_SRC0_SHIFT_RIGHT (A1_SRC0_CHANNEL_W_SHIFT - 
UREG_CHANNEL_W_SHIFT)
-#define UREG_A1_SRC1_SHIFT_LEFT  (UREG_TYPE_SHIFT - A1_SRC1_TYPE_SHIFT)
-#define UREG_A2_SRC1_SHIFT_RIGHT (A2_SRC1_CHANNEL_W_SHIFT - 
UREG_CHANNEL_W_SHIFT)
-#define UREG_A2_SRC2_SHIFT_LEFT  (UREG_TYPE_SHIFT - A2_SRC2_TYPE_SHIFT)
-
-#define UREG_MASK 0xff00
-#define UREG_TYPE_NR_MASK ((REG_TYPE_MASK  UREG_TYPE_SHIFT) | \
-  (REG_NR_MASK  UREG_NR_SHIFT))
-
-
 uint
 i915_get_temp(struct i915_fp_compile *p)
 {

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


Mesa (master): i915g: Implement stipple with draw.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 3cff45fdb182a1327f6b89fdc4e0ddc5d680372a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3cff45fdb182a1327f6b89fdc4e0ddc5d680372a

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Feb  7 14:42:30 2012 -0800

i915g: Implement stipple with draw.

---

 src/gallium/drivers/i915/i915_context.c |1 +
 src/gallium/drivers/i915/i915_state.c   |5 -
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.c 
b/src/gallium/drivers/i915/i915_context.c
index 5ad5bff..394e1f3 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -186,6 +186,7 @@ i915_create_context(struct pipe_screen *screen, void *priv)
 
draw_install_aaline_stage(i915-draw, i915-base);
draw_install_aapoint_stage(i915-draw, i915-base);
+   draw_install_pstipple_stage(i915-draw, i915-base);
draw_enable_point_sprites(i915-draw, TRUE);
 
/* augmented draw pipeline clobbers state functions */
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index d0063e3..764547e 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -553,8 +553,11 @@ static void i915_set_scissor_state( struct pipe_context 
*pipe,
 
 
 static void i915_set_polygon_stipple( struct pipe_context *pipe,
-   const struct pipe_poly_stipple *stipple )
+  const struct pipe_poly_stipple *stipple )
 {
+   struct i915_context *i915 = i915_context(pipe);
+
+   draw_flush(i915-draw);
 }
 
 

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


Mesa (master): i915g: Remove unused poly stipple state.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: be6a02266d1a934c6eff9aaf12fc618588b2d586
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=be6a02266d1a934c6eff9aaf12fc618588b2d586

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Feb  7 14:33:12 2012 -0800

i915g: Remove unused poly stipple state.

---

 src/gallium/drivers/i915/i915_context.h   |1 -
 src/gallium/drivers/i915/i915_state_dynamic.c |   53 -
 2 files changed, 0 insertions(+), 54 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index b019c9f..5790a2d 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -239,7 +239,6 @@ struct i915_context {
struct pipe_clip_state clip;
struct pipe_resource *constants[PIPE_SHADER_TYPES];
struct pipe_framebuffer_state framebuffer;
-   struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_SAMPLERS];
diff --git a/src/gallium/drivers/i915/i915_state_dynamic.c 
b/src/gallium/drivers/i915/i915_state_dynamic.c
index 1a21433..7e17597 100644
--- a/src/gallium/drivers/i915/i915_state_dynamic.c
+++ b/src/gallium/drivers/i915/i915_state_dynamic.c
@@ -194,58 +194,6 @@ const struct i915_tracked_state i915_upload_DEPTHSCALE = {
 
 
 /***
- * Polygon stipple
- *
- * The i915 supports a 4x4 stipple natively, GL wants 32x32.
- * Fortunately stipple is usually a repeating pattern.
- *
- * XXX: does stipple pattern need to be adjusted according to
- * the window position?
- *
- * XXX: possibly need workaround for conform paths test.
- */
-static void upload_STIPPLE(struct i915_context *i915)
-{
-   unsigned st[2];
-
-   st[0] = _3DSTATE_STIPPLE;
-   st[1] = 0;
-
-   /* I915_NEW_RASTERIZER
-*/
-   st[1] |= i915-rasterizer-st;
-
-   /* I915_NEW_STIPPLE
-*/
-   {
-  const ubyte *mask = (const ubyte *)i915-poly_stipple.stipple;
-  ubyte p[4];
-
-  p[0] = mask[12]  0xf;
-  p[1] = mask[8]  0xf;
-  p[2] = mask[4]  0xf;
-  p[3] = mask[0]  0xf;
-
-  /* Not sure what to do about fallbacks, so for now just dont:
-   */
-  st[1] |= ((p[0]  0) |
-(p[1]  4) |
-(p[2]  8) |
-(p[3]  12));
-   }
-
-   set_dynamic_array(i915, I915_DYNAMIC_STP_0, st, 2);
-}
-
-const struct i915_tracked_state i915_upload_STIPPLE = {
-   STIPPLE,
-   upload_STIPPLE,
-   I915_NEW_RASTERIZER | I915_NEW_STIPPLE
-};
-
-
-
-/***
  * Scissor enable
  */
 static void upload_SCISSOR_ENABLE( struct i915_context *i915 )
@@ -295,7 +243,6 @@ static const struct i915_tracked_state *atoms[] = {
i915_upload_BLENDCOLOR,
i915_upload_IAB,
i915_upload_DEPTHSCALE,
-   i915_upload_STIPPLE,
i915_upload_SCISSOR_ENABLE,
i915_upload_SCISSOR_RECT
 };

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


Mesa (master): i915g: Don't emit state when it's already bound.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: c1896cdc9182af45a4a1fea087f013f29fca4008
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c1896cdc9182af45a4a1fea087f013f29fca4008

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Feb  7 14:33:31 2012 -0800

i915g: Don't emit state when it's already bound.

---

 src/gallium/drivers/i915/i915_state.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 764547e..02cb3ea 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -177,6 +177,10 @@ static void i915_bind_blend_state(struct pipe_context 
*pipe,
   void *blend)
 {
struct i915_context *i915 = i915_context(pipe);
+
+   if (i915-blend == blend)
+  return;
+
draw_flush(i915-draw);
 
i915-blend = (struct i915_blend_state*)blend;
@@ -194,6 +198,10 @@ static void i915_set_blend_color( struct pipe_context 
*pipe,
   const struct pipe_blend_color *blend_color )
 {
struct i915_context *i915 = i915_context(pipe);
+
+   if (!blend_color)
+  return;
+
draw_flush(i915-draw);
 
i915-blend_color = *blend_color;
@@ -205,6 +213,7 @@ static void i915_set_stencil_ref( struct pipe_context *pipe,
   const struct pipe_stencil_ref *stencil_ref )
 {
struct i915_context *i915 = i915_context(pipe);
+
draw_flush(i915-draw);
 
i915-stencil_ref = *stencil_ref;
@@ -527,6 +536,10 @@ static void i915_bind_depth_stencil_state(struct 
pipe_context *pipe,
   void *depth_stencil)
 {
struct i915_context *i915 = i915_context(pipe);
+
+   if (i915-depth_stencil == depth_stencil)
+  return;
+
draw_flush(i915-draw);
 
i915-depth_stencil = (const struct i915_depth_stencil_state 
*)depth_stencil;
@@ -545,6 +558,7 @@ static void i915_set_scissor_state( struct pipe_context 
*pipe,
  const struct pipe_scissor_state *scissor )
 {
struct i915_context *i915 = i915_context(pipe);
+
draw_flush(i915-draw);
 
memcpy( i915-scissor, scissor, sizeof(*scissor) );
@@ -586,6 +600,10 @@ static void
 i915_fixup_bind_fs_state(struct pipe_context *pipe, void *shader)
 {
struct i915_context *i915 = i915_context(pipe);
+
+   if (i915-saved_fs == shader)
+  return;
+
draw_flush(i915-draw);
 
i915-saved_fs = shader;
@@ -597,6 +615,10 @@ static void
 i915_bind_fs_state(struct pipe_context *pipe, void *shader)
 {
struct i915_context *i915 = i915_context(pipe);
+
+   if (i915-fs == shader)
+  return;
+
draw_flush(i915-draw);
 
i915-fs = (struct i915_fragment_shader*) shader;
@@ -643,6 +665,9 @@ static void i915_bind_vs_state(struct pipe_context *pipe, 
void *shader)
 {
struct i915_context *i915 = i915_context(pipe);
 
+   if (i915-saved_vs == shader)
+  return;
+
i915-saved_vs = shader;
 
/* just pass-through to draw module */
@@ -848,6 +873,7 @@ static void i915_set_clip_state( struct pipe_context *pipe,
 const struct pipe_clip_state *clip )
 {
struct i915_context *i915 = i915_context(pipe);
+
draw_flush(i915-draw);
 
i915-saved_clip = *clip;
@@ -949,6 +975,9 @@ static void i915_bind_rasterizer_state( struct pipe_context 
*pipe,
 {
struct i915_context *i915 = i915_context(pipe);
 
+   if (i915-rasterizer == raster)
+  return;
+
i915-rasterizer = (struct i915_rasterizer_state *)raster;
 
/* pass-through to draw module */
@@ -1016,6 +1045,9 @@ i915_bind_vertex_elements_state(struct pipe_context *pipe,
struct i915_context *i915 = i915_context(pipe);
struct i915_velems_state *i915_velems = (struct i915_velems_state *) velems;
 
+   if (i915-saved_velems == velems)
+  return;
+
i915-saved_velems = velems;
 
/* pass-through to draw module */

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


Mesa (master): i915g: Add a way to profile the contents of command buffers.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 633f21652aacbcd7eebe28597cac1dc556ea2b45
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=633f21652aacbcd7eebe28597cac1dc556ea2b45

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Feb  8 22:43:14 2012 -0800

i915g: Add a way to profile the contents of command buffers.

---

 src/gallium/drivers/i915/i915_state_emit.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 2aed3f1..8ab8fb8 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -429,10 +429,22 @@ i915_validate_state(struct i915_context *i915, unsigned 
*batch_space)
else
   *batch_space = 0;
 
+#if 0
+static int counter_total = 0;
+#define VALIDATE_ATOM(atom, hw_dirty) \
+   if (i915-hardware_dirty  hw_dirty) { \
+  static int counter_##atom = 0;\
+  validate_##atom(i915, tmp); \
+  *batch_space += tmp;\
+  counter_##atom += tmp;\
+  counter_total += tmp;\
+  printf(%s: \t%d/%d \t%2.2f\n,#atom, counter_##atom, counter_total, 
counter_##atom*100.f/counter_total);}
+#else
 #define VALIDATE_ATOM(atom, hw_dirty) \
if (i915-hardware_dirty  hw_dirty) { \
   validate_##atom(i915, tmp); \
   *batch_space += tmp; }
+#endif
VALIDATE_ATOM(flush, I915_HW_FLUSH);
VALIDATE_ATOM(immediate, I915_HW_IMMEDIATE);
VALIDATE_ATOM(dynamic, I915_HW_DYNAMIC);

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


Mesa (master): i915g: Fix comments.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 8b3e0b27157aeea6e82941843d8446d2848b2218
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b3e0b27157aeea6e82941843d8446d2848b2218

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Feb  7 15:09:26 2012 -0800

i915g: Fix comments.

---

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

diff --git a/src/gallium/drivers/i915/i915_state_sampler.c 
b/src/gallium/drivers/i915/i915_state_sampler.c
index 9eadf31..19d3c83 100644
--- a/src/gallium/drivers/i915/i915_state_sampler.c
+++ b/src/gallium/drivers/i915/i915_state_sampler.c
@@ -46,13 +46,13 @@
  * max_lod = last_level == true
  *
  *
- * This is all fine and dandy if it where for the fact that max_lod
+ * This is all fine and dandy if it were for the fact that max_lod
  * is set on the map state instead of the sampler state. That is
  * the max_lod we submit on map is:
  * max_lod = MIN2(last_level, max_lod);
  *
  * So we need to update the map state when we change samplers and
- * we need to be change the sampler state when map state is changed.
+ * we need to change the sampler state when map state is changed.
  * The first part is done by calling update_texture in update_samplers
  * and the second part is done else where in code tracking the state
  * changes.

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


Mesa (master): gallivm: Replace architecture test with PIPE_ARCH_*

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: d2c54fb5223efee699862bef56177027edc140bc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d2c54fb5223efee699862bef56177027edc140bc

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Feb  9 19:50:59 2012 -0800

gallivm: Replace architecture test with PIPE_ARCH_*

X86Target is a variable, and therefore isn't defined at compile time. So
 LLVM_NATIVE_ARCH == X86Target
is translated into
 0 == 0
and since X86 is first, we always pick it.

Therefore we replace the logic with PIPE_ARCH_*.

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

---

 src/gallium/auxiliary/gallivm/lp_bld_debug.cpp |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp 
b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
index 5d98763..7f4d227 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
@@ -207,15 +207,17 @@ lp_disassemble(const void* func)
 
 #if HAVE_LLVM = 0x0208
InitializeNativeTargetAsmPrinter();
-#elif LLVM_NATIVE_ARCH == X86Target
+#elif defined(PIPE_ARCH_X86)
LLVMInitializeX86AsmPrinter();
-#elif LLVM_NATIVE_ARCH == ARMTarget
+#elif defined(PIPE_ARCH_ARM)
LLVMInitializeARMAsmPrinter();
+#elif defined(PIPE_ARCH_PPC)
+   LLVMInitializePowerPCAsmPrinter();
 #endif
 
-#if (LLVM_NATIVE_ARCH == X86 || LLVM_NATIVE_ARCH == X86Target)
+#if defined(PIPE_ARCH_X86)
LLVMInitializeX86Disassembler();
-#elif (LLVM_NATIVE_ARCH == ARM || LLVM_NATIVE_ARCH == ARMTarget)
+#elif defined(PIPE_ARCH_ARM)
LLVMInitializeARMDisassembler();
 #endif
 

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


Mesa (master): i915g: Remove useless draw calls.

2012-02-12 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: a2caf952a150a8da395f4cf1fd30e8c867b0064e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a2caf952a150a8da395f4cf1fd30e8c867b0064e

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Feb  9 20:39:00 2012 -0800

i915g: Remove useless draw calls.

---

 src/gallium/drivers/i915/i915_context.c |5 +--
 src/gallium/drivers/i915/i915_flush.c   |2 -
 src/gallium/drivers/i915/i915_state.c   |   36 ---
 3 files changed, 2 insertions(+), 41 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.c 
b/src/gallium/drivers/i915/i915_context.c
index 394e1f3..8197629 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -94,9 +94,8 @@ i915_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
   i915_cleanup_vertex_sampling(i915);
 
/*
-* TODO: Flush only when a user vertex/index buffer is present
-* (or even better, modify draw module to do this
-* internally when this condition is seen?)
+* Instead of flushing on every state change, we flush once here
+* when we fire the vbo.
 */
draw_flush(i915-draw);
 }
diff --git a/src/gallium/drivers/i915/i915_flush.c 
b/src/gallium/drivers/i915/i915_flush.c
index 0a0ca78..50d6642 100644
--- a/src/gallium/drivers/i915/i915_flush.c
+++ b/src/gallium/drivers/i915/i915_flush.c
@@ -43,8 +43,6 @@ static void i915_flush_pipe( struct pipe_context *pipe,
 {
struct i915_context *i915 = i915_context(pipe);
 
-   draw_flush(i915-draw);
-
/* Only shortcut this if we have no fence, otherwise we must flush the
 * empty batchbuffer to get our fence back.
 */
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index 02cb3ea..f7ebfcd 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -181,8 +181,6 @@ static void i915_bind_blend_state(struct pipe_context *pipe,
if (i915-blend == blend)
   return;
 
-   draw_flush(i915-draw);
-
i915-blend = (struct i915_blend_state*)blend;
 
i915-dirty |= I915_NEW_BLEND;
@@ -202,8 +200,6 @@ static void i915_set_blend_color( struct pipe_context *pipe,
if (!blend_color)
   return;
 
-   draw_flush(i915-draw);
-
i915-blend_color = *blend_color;
 
i915-dirty |= I915_NEW_BLEND;
@@ -214,8 +210,6 @@ static void i915_set_stencil_ref( struct pipe_context *pipe,
 {
struct i915_context *i915 = i915_context(pipe);
 
-   draw_flush(i915-draw);
-
i915-stencil_ref = *stencil_ref;
 
i915-dirty |= I915_NEW_DEPTH_STENCIL;
@@ -323,8 +317,6 @@ i915_bind_vertex_sampler_states(struct pipe_context *pipe,
!memcmp(i915-vertex_samplers, samplers, num_samplers * sizeof(void *)))
   return;
 
-   draw_flush(i915-draw);
-
for (i = 0; i  num_samplers; ++i)
   i915-vertex_samplers[i] = samplers[i];
for (i = num_samplers; i  PIPE_MAX_VERTEX_SAMPLERS; ++i)
@@ -350,8 +342,6 @@ static void i915_bind_fragment_sampler_states(struct 
pipe_context *pipe,
!memcmp(i915-sampler, sampler, num * sizeof(void *)))
   return;
 
-   draw_flush(i915-draw);
-
for (i = 0; i  num; ++i)
   i915-sampler[i] = sampler[i];
for (i = num; i  PIPE_MAX_SAMPLERS; ++i)
@@ -540,8 +530,6 @@ static void i915_bind_depth_stencil_state(struct 
pipe_context *pipe,
if (i915-depth_stencil == depth_stencil)
   return;
 
-   draw_flush(i915-draw);
-
i915-depth_stencil = (const struct i915_depth_stencil_state 
*)depth_stencil;
 
i915-dirty |= I915_NEW_DEPTH_STENCIL;
@@ -559,8 +547,6 @@ static void i915_set_scissor_state( struct pipe_context 
*pipe,
 {
struct i915_context *i915 = i915_context(pipe);
 
-   draw_flush(i915-draw);
-
memcpy( i915-scissor, scissor, sizeof(*scissor) );
i915-dirty |= I915_NEW_SCISSOR;
 }
@@ -569,9 +555,6 @@ static void i915_set_scissor_state( struct pipe_context 
*pipe,
 static void i915_set_polygon_stipple( struct pipe_context *pipe,
   const struct pipe_poly_stipple *stipple )
 {
-   struct i915_context *i915 = i915_context(pipe);
-
-   draw_flush(i915-draw);
 }
 
 
@@ -604,8 +587,6 @@ i915_fixup_bind_fs_state(struct pipe_context *pipe, void 
*shader)
if (i915-saved_fs == shader)
   return;
 
-   draw_flush(i915-draw);
-
i915-saved_fs = shader;
 
i915-saved_bind_fs_state(pipe, shader);
@@ -619,8 +600,6 @@ i915_bind_fs_state(struct pipe_context *pipe, void *shader)
if (i915-fs == shader)
   return;
 
-   draw_flush(i915-draw);
-
i915-fs = (struct i915_fragment_shader*) shader;
 
draw_bind_fragment_shader(i915-draw,  (i915-fs ? i915-fs-draw_data : 
NULL));
@@ -722,12 +701,6 @@ static void i915_set_constant_buffer(struct pipe_context 
*pipe,
   diff = i915-current.num_user_constants[shader] != 0;
}
 
-   /*
-* flush before updateing the state.
-*/
-   if (diff  shader == PIPE_SHADER_FRAGMENT)
-  

Mesa (master): draw: Don't revalidate pipeline on backend flushes

2012-01-26 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: eb65ccbc21670d16813b53e0f8d94cb4e037d39c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb65ccbc21670d16813b53e0f8d94cb4e037d39c

Author: Jakob Bornecrantz wallbra...@gmail.com
Date:   Sun Dec  5 21:20:59 2010 +0100

draw: Don't revalidate pipeline on backend flushes

Reviewed-by: Stéphane Marchesin marc...@chromium.org
Tested-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/auxiliary/draw/draw_pipe.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pipe.c 
b/src/gallium/auxiliary/draw/draw_pipe.c
index f1b0171..d754504 100644
--- a/src/gallium/auxiliary/draw/draw_pipe.c
+++ b/src/gallium/auxiliary/draw/draw_pipe.c
@@ -344,5 +344,6 @@ void draw_pipeline_flush( struct draw_context *draw,
   unsigned flags )
 {
draw-pipeline.first-flush( draw-pipeline.first, flags );
-   draw-pipeline.first = draw-pipeline.validate;
+   if (!(flags  DRAW_FLUSH_BACKEND))
+  draw-pipeline.first = draw-pipeline.validate;
 }

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


Mesa (master): draw: Remove reduced_prim

2012-01-26 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 4a79545bdfb9e948329a761ef350eb83a3d87496
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a79545bdfb9e948329a761ef350eb83a3d87496

Author: Jakob Bornecrantz wallbra...@gmail.com
Date:   Sun Dec  5 21:19:12 2010 +0100

draw: Remove reduced_prim

Conflicts:

src/gallium/auxiliary/draw/draw_context.c

Reviewed-by: Stéphane Marchesin marc...@chromium.org
Tested-by: Stéphane Marchesin marc...@chromium.org

---

 src/gallium/auxiliary/draw/draw_context.c |4 
 src/gallium/auxiliary/draw/draw_private.h |2 --
 src/gallium/auxiliary/draw/draw_pt.c  |6 --
 3 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index 7e554dc..4ce4445 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -155,8 +155,6 @@ boolean draw_init(struct draw_context *draw)
draw-clip_z = TRUE;
 
draw-pt.user.planes = (float (*) [DRAW_TOTAL_CLIP_PLANES][4]) 
(draw-plane[0]);
-   draw-reduced_prim = ~0; /* != any of PIPE_PRIM_x */
-
 
if (!draw_pipeline_init( draw ))
   return FALSE;
@@ -656,8 +654,6 @@ void draw_do_flush( struct draw_context *draw, unsigned 
flags )
 
   draw_pipeline_flush( draw, flags );
 
-  draw-reduced_prim = ~0; /* is reduced_prim needed any more? */
-  
   draw-flushing = FALSE;
}
 }
diff --git a/src/gallium/auxiliary/draw/draw_private.h 
b/src/gallium/auxiliary/draw/draw_private.h
index 31beb4b..1a0286d 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -290,8 +290,6 @@ struct draw_context
   uint slot[10];
} extra_shader_outputs;
 
-   unsigned reduced_prim;
-
unsigned instance_id;
 
 #ifdef HAVE_LLVM
diff --git a/src/gallium/auxiliary/draw/draw_pt.c 
b/src/gallium/auxiliary/draw/draw_pt.c
index 080e03d..9a017fd 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -420,7 +420,6 @@ void
 draw_vbo(struct draw_context *draw,
  const struct pipe_draw_info *info)
 {
-   unsigned reduced_prim = u_reduced_prim(info-mode);
unsigned instance;
unsigned index_limit;
 
@@ -435,11 +434,6 @@ draw_vbo(struct draw_context *draw,
draw-pt.user.min_index = info-min_index;
draw-pt.user.max_index = info-max_index;
 
-   if (reduced_prim != draw-reduced_prim) {
-  draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
-  draw-reduced_prim = reduced_prim;
-   }
-
if (0)
   debug_printf(draw_vbo(mode=%u start=%u count=%u):\n,
info-mode, info-start, info-count);

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


Mesa (master): i915g: Fix indentation and comment.

2012-01-19 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 2f9df215a2994eafa29f4ff646934eb698e902cd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f9df215a2994eafa29f4ff646934eb698e902cd

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Jan 19 16:28:23 2012 -0800

i915g: Fix indentation and comment.

---

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

diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 9d487cf..9c941ae 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -385,8 +385,8 @@ emit_program(struct i915_context *i915)
   OUT_BATCH(size);
}
 
-   /* output the declarations of the program */
-   for (i=1 ; i  i915-fs-program_len; i++)
+   /* output the declarations and the program */
+   for (i = 1 ; i  i915-fs-program_len; i++)
   OUT_BATCH(i915-fs-program[i]);
 
/* we emit an additional mov with swizzle to fake RGBA framebuffers */

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


Mesa (master): i915g: Fix indentation.

2012-01-19 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 63dbd3fefba93ccfb984ed589795f6784bb4d1e3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=63dbd3fefba93ccfb984ed589795f6784bb4d1e3

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Jan 19 17:18:55 2012 -0800

i915g: Fix indentation.

---

 src/gallium/drivers/i915/i915_fpc_emit.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_emit.c 
b/src/gallium/drivers/i915/i915_fpc_emit.c
index d295396..eff0937 100644
--- a/src/gallium/drivers/i915/i915_fpc_emit.c
+++ b/src/gallium/drivers/i915/i915_fpc_emit.c
@@ -245,7 +245,7 @@ uint i915_emit_texld( struct i915_fp_compile *p,
  ignore |= (0xf  UREG_CHANNEL_W_SHIFT);
}
 
-   if ( (coord ~ignore ) != (k  ~ignore) ) {
+   if ( (coord  ~ignore ) != (k  ~ignore) ) {
   /* texcoord is swizzled or negated.  Need to allocate a new temporary
* register (a utemp / unpreserved temp) won't do.
*/

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


Mesa (master): st/dri: Remove useless flush front.

2012-01-18 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 81da773f841aa69debc473537750c475e6261e37
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=81da773f841aa69debc473537750c475e6261e37

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Jan 18 13:03:56 2012 -0800

st/dri: Remove useless flush front.

In the following scenario:
- CreateContext C1
- MakeCurrent C1
- DestroyContext C1 (does not actually destroy the first context, postponed
 until the next MakeCurrent)
 - CreateContext C2
 - MakeCurrent C2
MakeCurrent will call flush on a half destroyed context, leading to crashes.
Since the other paths (destroy and makecurrent) already flush the context,
there is no need to flush here, so we remove this useless flush front call.

This fixes GPU crashes with Chrome and gallium drivers.

---

 .../state_trackers/dri/common/dri_context.c|9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_context.c 
b/src/gallium/state_trackers/dri/common/dri_context.c
index b47d8d9..52c8f4a 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -166,7 +166,7 @@ dri_destroy_context(__DRIcontext * cPriv)
FREE(ctx-optionCache.values);
 
/* No particular reason to wait for command completion before
-* destroying a context, but it is probably worthwhile flushing it
+* destroying a context, but we flush the context here
 * to avoid having to add code elsewhere to cope with flushing a
 * partially destroyed context.
 */
@@ -188,7 +188,11 @@ dri_unbind_context(__DRIcontext * cPriv)
 
if (--ctx-bind_count == 0) {
   if (ctx-st == ctx-stapi-get_current(ctx-stapi)) {
- ctx-st-flush(ctx-st, ST_FLUSH_FRONT, NULL);
+ /* For conformance, unbind is supposed to flush the context.
+  * However, if we do it here we might end up flushing a partially
+  * destroyed context. Instead, we flush in dri_make_current and
+  * in dri_destroy_context which should cover all the cases.
+  */
  stapi-make_current(stapi, NULL, NULL, NULL);
   }
}
@@ -207,6 +211,7 @@ dri_make_current(__DRIcontext * cPriv,
struct dri_drawable *read = dri_drawable(driReadPriv);
struct st_context_iface *old_st = ctx-stapi-get_current(ctx-stapi);
 
+   /* Flush the old context here so we don't have to flush on unbind() */
if (old_st  old_st != ctx-st)
   old_st-flush(old_st, ST_FLUSH_FRONT, NULL);
 

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


Mesa (master): i915g: Don't invert signalled/unsignalled fences

2012-01-18 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 2b4afdba05abe3408f6347be82465b6420f50aab
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b4afdba05abe3408f6347be82465b6420f50aab

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Jan 18 19:23:48 2012 -0800

i915g: Don't invert signalled/unsignalled fences

NOTE: This is a candidate for the 8.0 branch.

---

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

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 525..6fc854f 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -368,7 +368,7 @@ i915_fence_signalled(struct pipe_screen *screen,
 {
struct i915_screen *is = i915_screen(screen);
 
-   return is-iws-fence_signalled(is-iws, fence) == 0;
+   return is-iws-fence_signalled(is-iws, fence) == 1;
 }
 
 static boolean
@@ -378,7 +378,7 @@ i915_fence_finish(struct pipe_screen *screen,
 {
struct i915_screen *is = i915_screen(screen);
 
-   return is-iws-fence_finish(is-iws, fence) == 0;
+   return is-iws-fence_finish(is-iws, fence) == 1;
 }
 
 

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


Mesa (master): i915g: Don't avoid flushing when we have a pending fence.

2012-01-18 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 32b07bb1496f5772ca16e719bb87e1702ceff196
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=32b07bb1496f5772ca16e719bb87e1702ceff196

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Jan 18 19:24:18 2012 -0800

i915g: Don't avoid flushing when we have a pending fence.

Otherwise the fence will never arrive.
Also check for a NULL i915-batch.

NOTE: This is a candidate for the 8.0 branch.

---

 src/gallium/drivers/i915/i915_flush.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_flush.c 
b/src/gallium/drivers/i915/i915_flush.c
index 5d8e3c8..0a0ca78 100644
--- a/src/gallium/drivers/i915/i915_flush.c
+++ b/src/gallium/drivers/i915/i915_flush.c
@@ -45,7 +45,10 @@ static void i915_flush_pipe( struct pipe_context *pipe,
 
draw_flush(i915-draw);
 
-   if (i915-batch-map == i915-batch-ptr) {
+   /* Only shortcut this if we have no fence, otherwise we must flush the
+* empty batchbuffer to get our fence back.
+*/
+   if (!fence  i915-batch  (i915-batch-map == i915-batch-ptr)) {
   return;
}
 

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


Mesa (master): i915g: Fix the blending for the A8 destination buffer case.

2012-01-15 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 23d4a0569dcb70bdfd748bf7e1f5102289bfad6b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=23d4a0569dcb70bdfd748bf7e1f5102289bfad6b

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sun Jan 15 23:32:59 2012 -0800

i915g: Fix the blending for the A8 destination buffer case.

The i915 GPU can't do A8 dst, so we abuse GREEN8 buffers for that
purpose. However, things get hairy as we start to do blending,
because then GL_DST_*_ALPHA should be replaced with GL_DST_*_COLOR.
This is what we do here.

Fixes piglt fbo-alpha.

---

 src/gallium/drivers/i915/i915_clear.c|2 +-
 src/gallium/drivers/i915/i915_context.h  |2 +-
 src/gallium/drivers/i915/i915_state_emit.c   |   29 -
 src/gallium/drivers/i915/i915_state_static.c |8 +++---
 4 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_clear.c 
b/src/gallium/drivers/i915/i915_clear.c
index 7341156..d6e6f56 100644
--- a/src/gallium/drivers/i915/i915_clear.c
+++ b/src/gallium/drivers/i915/i915_clear.c
@@ -74,7 +74,7 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
   }
 
   /* correctly swizzle clear value */
-  if (i915-current.need_target_fixup)
+  if (i915-current.target_fixup_format)
  util_pack_color(color-f, cbuf-format, u_color);
   else
  util_pack_color(color-f, PIPE_FORMAT_B8G8R8A8_UNORM, u_color);
diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index fb51185..e39c7cc 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -167,7 +167,7 @@ struct i915_state
unsigned dst_buf_vars;
uint32_t draw_offset;
uint32_t draw_size;
-   unsigned need_target_fixup;
+   uint32_t target_fixup_format;
uint32_t fixup_swizzle;
 
unsigned id;/* track lost context events */
diff --git a/src/gallium/drivers/i915/i915_state_emit.c 
b/src/gallium/drivers/i915/i915_state_emit.c
index 426c683..9d487cf 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -151,8 +151,25 @@ emit_immediate(struct i915_context *i915)
}
 
for (i = 1; i  I915_MAX_IMMEDIATE; i++) {
-  if (dirty  (1  i))
- OUT_BATCH(i915-current.immediate[i]);
+  if (dirty  (1  i)) {
+ /* Fixup blend function for A8 dst buffers.
+  * When we blend to an A8 buffer, the GPU thinks it's a G8 buffer,
+  * and therefore we need to use the color factor for alphas. */
+ if ((i == I915_IMMEDIATE_S6) 
+ (i915-current.target_fixup_format == PIPE_FORMAT_A8_UNORM)) {
+uint32_t imm = i915-current.immediate[i];
+uint32_t srcRGB = (imm  S6_CBUF_SRC_BLEND_FACT_SHIFT)  
BLENDFACT_MASK;
+if (srcRGB == BLENDFACT_DST_ALPHA)
+   srcRGB = BLENDFACT_DST_COLR;
+else if (srcRGB == BLENDFACT_INV_DST_ALPHA)
+   srcRGB = BLENDFACT_INV_DST_COLR;
+imm = ~SRC_BLND_FACT(BLENDFACT_MASK);
+imm |= SRC_BLND_FACT(srcRGB);
+OUT_BATCH(imm);
+ } else {
+OUT_BATCH(i915-current.immediate[i]);
+ }
+  }
}
 }
 
@@ -346,7 +363,7 @@ emit_constants(struct i915_context *i915)
 static void
 validate_program(struct i915_context *i915, unsigned *batch_space)
 {
-   uint additional_size = i915-current.need_target_fixup;
+   uint additional_size = i915-current.target_fixup_format ? 1 : 0;
 
/* we need more batch space if we want to emulate rgba framebuffers */
*batch_space = i915-fs-program_len + 3 * additional_size;
@@ -355,7 +372,7 @@ validate_program(struct i915_context *i915, unsigned 
*batch_space)
 static void
 emit_program(struct i915_context *i915)
 {
-   uint target_fixup = i915-current.need_target_fixup;
+   uint need_target_fixup = i915-current.target_fixup_format ? 1 : 0;
uint i;
 
/* we should always have, at least, a pass-through program */
@@ -364,7 +381,7 @@ emit_program(struct i915_context *i915)
{
   /* first word has the size, we have to adjust that */
   uint size = (i915-fs-program[0]);
-  size += target_fixup * 3;
+  size += need_target_fixup * 3;
   OUT_BATCH(size);
}
 
@@ -373,7 +390,7 @@ emit_program(struct i915_context *i915)
   OUT_BATCH(i915-fs-program[i]);
 
/* we emit an additional mov with swizzle to fake RGBA framebuffers */
-   if (target_fixup) {
+   if (need_target_fixup) {
   /* mov out_color, out_color.zyxw */
   OUT_BATCH(A0_MOV |
 (REG_TYPE_OC  A0_DEST_TYPE_SHIFT) |
diff --git a/src/gallium/drivers/i915/i915_state_static.c 
b/src/gallium/drivers/i915/i915_state_static.c
index 9370f3d..9587dec 100644
--- a/src/gallium/drivers/i915/i915_state_static.c
+++ b/src/gallium/drivers/i915/i915_state_static.c
@@ -177,7 +177,7 @@ static const struct
{ PIPE_FORMAT_NONE,   

Mesa (master): i915g: Fix bugs in the shader optimizer.

2012-01-11 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 3235435e801122fb6d28c0bcc232ddaeb6b9c568
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3235435e801122fb6d28c0bcc232ddaeb6b9c568

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Jan 11 02:24:34 2012 -0800

i915g: Fix bugs in the shader optimizer.

---

 src/gallium/drivers/i915/i915_fpc_optimize.c |  126 --
 1 files changed, 80 insertions(+), 46 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_optimize.c 
b/src/gallium/drivers/i915/i915_fpc_optimize.c
index d9b4c46..b09f18b 100644
--- a/src/gallium/drivers/i915/i915_fpc_optimize.c
+++ b/src/gallium/drivers/i915/i915_fpc_optimize.c
@@ -66,6 +66,8 @@ static boolean has_destination(unsigned opcode)
 {
return (opcode != TGSI_OPCODE_NOP 
opcode != TGSI_OPCODE_KIL 
+   opcode != TGSI_OPCODE_KILP 
+   opcode != TGSI_OPCODE_END 
opcode != TGSI_OPCODE_RET);
 }
 
@@ -130,6 +132,50 @@ static void set_neutral_element_swizzle(struct 
i915_full_src_register* r,
   r-Register.SwizzleW = TGSI_SWIZZLE_W;
 }
 
+static void copy_src_reg(struct i915_src_register* o, const struct 
tgsi_src_register* i)
+{
+   o-File  = i-File;
+   o-Indirect  = i-Indirect;
+   o-Dimension = i-Dimension;
+   o-Index = i-Index;
+   o-SwizzleX  = i-SwizzleX;
+   o-SwizzleY  = i-SwizzleY;
+   o-SwizzleZ  = i-SwizzleZ;
+   o-SwizzleW  = i-SwizzleW;
+   o-Absolute  = i-Absolute;
+   o-Negate= i-Negate;
+}
+
+static void copy_dst_reg(struct i915_dst_register* o, const struct 
tgsi_dst_register* i)
+{
+   o-File  = i-File;
+   o-WriteMask = i-WriteMask;
+   o-Indirect  = i-Indirect;
+   o-Dimension = i-Dimension;
+   o-Index = i-Index;
+}
+
+static void copy_instruction(struct i915_full_instruction* o, const struct 
tgsi_full_instruction* i)
+{
+   memcpy(o-Instruction, i-Instruction, sizeof(o-Instruction));
+   memcpy(o-Texture, i-Texture, sizeof(o-Texture));
+
+   copy_dst_reg(o-Dst[0].Register, i-Dst[0].Register);
+
+   copy_src_reg(o-Src[0].Register, i-Src[0].Register);
+   copy_src_reg(o-Src[1].Register, i-Src[1].Register);
+   copy_src_reg(o-Src[2].Register, i-Src[2].Register);
+}
+
+static void copy_token(union i915_full_token* o, union tgsi_full_token* i)
+{
+   if (i-Token.Type != TGSI_TOKEN_TYPE_INSTRUCTION)
+  memcpy(o, i, sizeof(*o));
+   else
+  copy_instruction(o-FullInstruction, i-FullInstruction);
+
+}
+
 /*
  * Optimize away things like:
  *MUL OUT[0].xyz, TEMP[1], TEMP[2]
@@ -147,6 +193,7 @@ static void i915_fpc_optimize_mov_after_alu(union 
i915_full_token* current, unio
 next-FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV 
 same_dst_reg(next-FullInstruction.Dst[0], 
current-FullInstruction.Dst[0]) 
 same_src_reg(next-FullInstruction.Src[0], 
current-FullInstruction.Src[1]) 
+!same_src_dst_reg(next-FullInstruction.Src[0], 
current-FullInstruction.Dst[0]) 
 is_unswizzled(current-FullInstruction.Src[0], 
current-FullInstruction.Dst[0].Register.WriteMask) 
 is_unswizzled(current-FullInstruction.Src[1], 
current-FullInstruction.Dst[0].Register.WriteMask) 
 is_unswizzled(next-FullInstruction.Src[0], 
next-FullInstruction.Dst[0].Register.WriteMask) )
@@ -170,6 +217,7 @@ static void i915_fpc_optimize_mov_after_alu(union 
i915_full_token* current, unio
 next-FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV 
 same_dst_reg(next-FullInstruction.Dst[0], 
current-FullInstruction.Dst[0]) 
 same_src_reg(next-FullInstruction.Src[0], 
current-FullInstruction.Src[0]) 
+!same_src_dst_reg(next-FullInstruction.Src[0], 
current-FullInstruction.Dst[0]) 
 is_unswizzled(current-FullInstruction.Src[0], 
current-FullInstruction.Dst[0].Register.WriteMask) 
 is_unswizzled(current-FullInstruction.Src[1], 
current-FullInstruction.Dst[0].Register.WriteMask) 
 is_unswizzled(next-FullInstruction.Src[0], 
next-FullInstruction.Dst[0].Register.WriteMask) )
@@ -189,12 +237,36 @@ static void i915_fpc_optimize_mov_after_alu(union 
i915_full_token* current, unio
 
 /*
  * Optimize away things like:
+ *MOV TEMP[0].xyz TEMP[0].xyzx
+ * into:
+ *NOP
+ */
+static boolean i915_fpc_useless_mov(union tgsi_full_token* tgsi_current)
+{
+   union i915_full_token current;
+   copy_token(current , tgsi_current);
+   if ( current.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  
+current.FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV 
+has_destination(current.FullInstruction.Instruction.Opcode) 
+current.FullInstruction.Instruction.Saturate == TGSI_SAT_NONE 
+current.FullInstruction.Src[0].Register.Absolute == 0 
+current.FullInstruction.Src[0].Register.Negate == 0 
+is_unswizzled(current.FullInstruction.Src[0], 
current.FullInstruction.Dst[0].Register.WriteMask) 
+same_src_dst_reg(current.FullInstruction.Src[0], 
current.FullInstruction.Dst[0]) )
+   {
+  return TRUE;
+   

Mesa (master): i915g: Allocate tmp for KILP

2011-12-30 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 0e57b66fa1d7f4317f20571f19fd2ceb3593f04f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e57b66fa1d7f4317f20571f19fd2ceb3593f04f

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Dec 30 01:33:26 2011 -0800

i915g: Allocate tmp for KILP

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=44297

---

 src/gallium/drivers/i915/i915_fpc_translate.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c 
b/src/gallium/drivers/i915/i915_fpc_translate.c
index beb0e0d..5bfbfa0 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -658,6 +658,8 @@ i915_translate_instruction(struct i915_fp_compile *p,
   /* We emit an unconditional kill; we may want to revisit
* if we ever implement conditionals.
*/
+  tmp = i915_get_utemp(p);
+
   i915_emit_texld(p,
   tmp,   /* dest reg: a 
dummy reg */
   A0_DEST_CHANNEL_ALL,   /* dest writemask 
*/

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


Mesa (master): llvmpipe: Remove useless draw_install_pstipple_stage call.

2011-12-29 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: ded02bd54b5925ee222d7f426850312236b4f59d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ded02bd54b5925ee222d7f426850312236b4f59d

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Dec 28 17:34:56 2011 -0800

llvmpipe: Remove useless draw_install_pstipple_stage call.

It is #ifdef'd out, and is already called unconditionnaly a couple lines above.

Reviewed-By: Jose Fonseca jfons...@vmware.com

---

 src/gallium/drivers/llvmpipe/lp_context.c |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_context.c 
b/src/gallium/drivers/llvmpipe/lp_context.c
index b6ac068..c19272f 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.c
+++ b/src/gallium/drivers/llvmpipe/lp_context.c
@@ -229,11 +229,6 @@ llvmpipe_create_context( struct pipe_screen *screen, void 
*priv )
draw_wide_point_threshold(llvmpipe-draw, 1.0);
draw_wide_line_threshold(llvmpipe-draw, 1.0);
 
-#if USE_DRAW_STAGE_PSTIPPLE
-   /* Do polygon stipple w/ texture map + frag prog? */
-   draw_install_pstipple_stage(llvmpipe-draw, llvmpipe-pipe);
-#endif
-
lp_reset_counters();
 
gallivm_register_garbage_collector_callback(garbage_collect_callback,

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


Mesa (master): i915g: Add missing draw_flush call.

2011-12-28 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 11cdf24d15763131a7ab4b366cad78116884d045
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=11cdf24d15763131a7ab4b366cad78116884d045

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Dec 28 12:35:41 2011 -0800

i915g: Add missing draw_flush call.

Fixes a bunch of corruption bugs, especially some missing clipped triangles.

---

 src/gallium/drivers/i915/i915_context.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.c 
b/src/gallium/drivers/i915/i915_context.c
index 5a61740..5ad5bff 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -92,6 +92,13 @@ i915_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
 
if (i915-num_vertex_sampler_views  0)
   i915_cleanup_vertex_sampling(i915);
+
+   /*
+* TODO: Flush only when a user vertex/index buffer is present
+* (or even better, modify draw module to do this
+* internally when this condition is seen?)
+*/
+   draw_flush(i915-draw);
 }
 
 

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


Mesa (master): i915g: Only apply the optimization to output vars.

2011-12-27 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: b50d250e02457f367c195ee1808b061e0dfe2d00
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b50d250e02457f367c195ee1808b061e0dfe2d00

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Dec 22 18:17:54 2011 -0800

i915g: Only apply the optimization to output vars.

This is a bit overkill, but otherwise we need to rename subsequent uses, which 
is a future TODO.
Reported by CME.

---

 src/gallium/drivers/i915/i915_fpc_optimize.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_optimize.c 
b/src/gallium/drivers/i915/i915_fpc_optimize.c
index 0d680fb..d9b4c46 100644
--- a/src/gallium/drivers/i915/i915_fpc_optimize.c
+++ b/src/gallium/drivers/i915/i915_fpc_optimize.c
@@ -203,6 +203,7 @@ static void i915_fpc_optimize_useless_mov(union 
i915_full_token* current, union
 next-FullInstruction.Instruction.Saturate == TGSI_SAT_NONE 
 next-FullInstruction.Src[0].Register.Absolute == 0 
 next-FullInstruction.Src[0].Register.Negate == 0 
+next-FullInstruction.Dst[0].Register.File == TGSI_FILE_OUTPUT 
 is_unswizzled(next-FullInstruction.Src[0], 
next-FullInstruction.Dst[0].Register.WriteMask) 
 current-FullInstruction.Dst[0].Register.WriteMask == 
next-FullInstruction.Dst[0].Register.WriteMask 
 same_src_dst_reg(next-FullInstruction.Src[0], 
current-FullInstruction.Dst[0]) )

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


Mesa (master): i915g: Add two unsupported caps.

2011-12-19 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 3c01aefe5f9b8ffb31bbdd9ed5b200e830478a81
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3c01aefe5f9b8ffb31bbdd9ed5b200e830478a81

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Dec 15 11:10:32 2011 -0800

i915g: Add two unsupported caps.

---

 src/gallium/drivers/i915/i915_screen.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 991f03b..712fef9 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -199,6 +199,8 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
case PIPE_CAP_CONDITIONAL_RENDER:
case PIPE_CAP_TEXTURE_BARRIER:
+   case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS:
+   case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
   return 0;
 
/* Features we can lie about (boolean caps). */

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


Mesa (master): i915g: Implement KILP.

2011-12-19 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: c661843ab6adc97b54debaccfb29b897b12ab76d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c661843ab6adc97b54debaccfb29b897b12ab76d

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Dec 15 12:31:36 2011 -0800

i915g: Implement KILP.

---

 src/gallium/drivers/i915/i915_fpc_translate.c |   15 ---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c 
b/src/gallium/drivers/i915/i915_fpc_translate.c
index 8877215..beb0e0d 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -510,9 +510,9 @@ i915_translate_instruction(struct i915_fp_compile *p,
   src0 = src_vector(p, inst-Src[0], fs);
   src1 = src_vector(p, inst-Src[1], fs);
   src2 = src_vector(p, inst-Src[2], fs);
-  i915_emit_arith(p, A0_CMP, 
+  i915_emit_arith(p, A0_CMP,
   get_result_vector(p, inst-Dst[0]),
-  get_result_flags(inst), 
+  get_result_flags(inst),
   0, src0, src2, src1);   /* NOTE: order of src2, src1 */
   break;
 
@@ -655,7 +655,16 @@ i915_translate_instruction(struct i915_fp_compile *p,
   break;
 
case TGSI_OPCODE_KILP:
-  assert(0); /* not tested yet */
+  /* We emit an unconditional kill; we may want to revisit
+   * if we ever implement conditionals.
+   */
+  i915_emit_texld(p,
+  tmp,   /* dest reg: a 
dummy reg */
+  A0_DEST_CHANNEL_ALL,   /* dest writemask 
*/
+  0, /* sampler */
+  negate(swizzle(0, ONE, ONE, ONE, ONE), 1, 1, 1, 1), /* 
coord */
+  T0_TEXKILL,/* opcode */
+  1);/* num_coord */
   break;
 
case TGSI_OPCODE_LG2:

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


Mesa (master): i915g: Make the pipe_sampler_state struct non const and get rid of useless memcpy .

2011-12-19 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: a7534d8943d74e81299b2ee4edc462baac9d1331
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a7534d8943d74e81299b2ee4edc462baac9d1331

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Dec 15 12:59:58 2011 -0800

i915g: Make the pipe_sampler_state struct non const and get rid of useless 
memcpy.

---

 src/gallium/drivers/i915/i915_context.h |2 +-
 src/gallium/drivers/i915/i915_state.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index bb1b3b1..fb51185 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -202,7 +202,7 @@ struct i915_rasterizer_state {
 };
 
 struct i915_sampler_state {
-   const struct pipe_sampler_state templ;
+   struct pipe_sampler_state templ;
unsigned state[3];
unsigned minlod;
unsigned maxlod;
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index fc0c868..853468c 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -223,7 +223,7 @@ i915_create_sampler_state(struct pipe_context *pipe,
unsigned minFilt, magFilt;
unsigned mipFilt;
 
-   memcpy(cso-templ, sampler, sizeof(struct pipe_sampler_state));
+   cso-templ = *sampler;
 
mipFilt = translate_mip_filter(sampler-min_mip_filter);
minFilt = translate_img_filter( sampler-min_img_filter );

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


Mesa (master): i915g: Add unsupported caps.

2011-12-19 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 67e6a40605c482617afa9bd698003ea15e8f8f6e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=67e6a40605c482617afa9bd698003ea15e8f8f6e

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Dec 15 12:55:18 2011 -0800

i915g: Add unsupported caps.

---

 src/gallium/drivers/i915/i915_screen.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 712fef9..2a64ba4 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -195,6 +195,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_SM3:
case PIPE_CAP_SEAMLESS_CUBE_MAP:
case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
+   case PIPE_CAP_SCALED_RESOLVE:
case PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL:
case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
case PIPE_CAP_CONDITIONAL_RENDER:
@@ -223,6 +224,9 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
   return I915_MAX_TEXTURE_2D_LEVELS;
case PIPE_CAP_MIN_TEXEL_OFFSET:
case PIPE_CAP_MAX_TEXEL_OFFSET:
+   case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
+   case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
+   case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
   return 0;
 
/* Render targets. */

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


Mesa (master): i915g: Turn an assert into a debug message, print more debug info for missing depth swz.

2011-12-19 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 1981042341c6942bbd4d61508a47226c789bc25b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1981042341c6942bbd4d61508a47226c789bc25b

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Dec 15 16:19:46 2011 -0800

i915g: Turn an assert into a debug message, print more debug info for missing 
depth swz.

Also fix indentation a bit.

---

 src/gallium/drivers/i915/i915_state_sampler.c |   10 +++---
 src/gallium/drivers/i915/i915_state_static.c  |3 ++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_state_sampler.c 
b/src/gallium/drivers/i915/i915_state_sampler.c
index 5c74ffd..9eadf31 100644
--- a/src/gallium/drivers/i915/i915_state_sampler.c
+++ b/src/gallium/drivers/i915/i915_state_sampler.c
@@ -193,8 +193,8 @@ static uint translate_texture_format(enum pipe_format 
pipeFormat,
  view-swizzle_g != PIPE_SWIZZLE_GREEN ||
  view-swizzle_b != PIPE_SWIZZLE_BLUE ||
  view-swizzle_a != PIPE_SWIZZLE_ALPHA ) 
-pipeFormat != PIPE_FORMAT_Z24_UNORM_S8_UINT 
-pipeFormat != PIPE_FORMAT_Z24X8_UNORM )
+ pipeFormat != PIPE_FORMAT_Z24_UNORM_S8_UINT 
+ pipeFormat != PIPE_FORMAT_Z24X8_UNORM )
   debug_printf(i915: unsupported texture swizzle for format %d\n, 
pipeFormat);
 
switch (pipeFormat) {
@@ -258,7 +258,11 @@ static uint translate_texture_format(enum pipe_format 
pipeFormat,
   view-swizzle_b == PIPE_SWIZZLE_ZERO 
   view-swizzle_a == PIPE_SWIZZLE_RED)
 return (MAPSURF_32BIT | MT_32BIT_xL824);
- debug_printf(i915: unsupported depth swizzle\n);
+ debug_printf(i915: unsupported depth swizzle %d %d %d %d\n,
+  view-swizzle_r,
+  view-swizzle_g,
+  view-swizzle_b,
+  view-swizzle_a);
  return (MAPSURF_32BIT | MT_32BIT_xL824);
   }
default:
diff --git a/src/gallium/drivers/i915/i915_state_static.c 
b/src/gallium/drivers/i915/i915_state_static.c
index f41c32e..9370f3d 100644
--- a/src/gallium/drivers/i915/i915_state_static.c
+++ b/src/gallium/drivers/i915/i915_state_static.c
@@ -126,7 +126,8 @@ static void update_framebuffer(struct i915_context *i915)
   unsigned offset = i915_texture_offset(tex, depth_surface-u.tex.level,
 depth_surface-u.tex.first_layer);
   assert(tex);
-  assert(offset == 0);
+  if (offset != 0)
+ debug_printf(Depth offset is %d\n,offset);
 
   i915-current.depth_bo = tex-buffer;
   i915-current.depth_flags = BUF_3D_ID_DEPTH |

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


Mesa (master): i915g: Update TODO.

2011-12-13 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: f41fd6b6c36c825179d509d0763d23bff8cd0c30
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f41fd6b6c36c825179d509d0763d23bff8cd0c30

Author: Stéphane Marchesin marc...@chromium.org
Date:   Fri Nov  4 16:13:50 2011 -0700

i915g: Update TODO.

---

 src/gallium/drivers/i915/TODO |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/TODO b/src/gallium/drivers/i915/TODO
index f97af86..d52c1c0 100644
--- a/src/gallium/drivers/i915/TODO
+++ b/src/gallium/drivers/i915/TODO
@@ -40,5 +40,7 @@ Random list of problems with i915g:
   R registers responsible for a boundary with U registers to avoid phase
   boundaries.
 
+- Continue a previous primitive when there are no state changes
+
 Other bugs can be found here:
 
https://bugs.freedesktop.org/buglist.cgi?bug_status=NEWbug_status=ASSIGNEDbug_status=REOPENEDcomponent=Drivers/Gallium/i915g

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


Mesa (master): i915g: Roll back to the previous shader limits.

2011-12-13 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 642d11da207e9becfa26a9e038db1c7520ec2aee
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=642d11da207e9becfa26a9e038db1c7520ec2aee

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Dec  8 19:22:13 2011 -0800

i915g: Roll back to the previous shader limits.

Those shader limits seem to be responsible for a piglit hang.

---

 src/gallium/drivers/i915/i915_fpc.h|2 +-
 src/gallium/drivers/i915/i915_reg.h|4 
 src/gallium/drivers/i915/i915_screen.c |2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc.h 
b/src/gallium/drivers/i915/i915_fpc.h
index bfd658f..26cf2fb 100644
--- a/src/gallium/drivers/i915/i915_fpc.h
+++ b/src/gallium/drivers/i915/i915_fpc.h
@@ -37,7 +37,7 @@
 
 #include tgsi/tgsi_parse.h
 
-#define I915_PROGRAM_SIZE (3 * I915_MAX_INSN)
+#define I915_PROGRAM_SIZE 192
 
 /* Use those indices for pos/face routing, must be = num of inputs */
 #define I915_SEMANTIC_POS  100
diff --git a/src/gallium/drivers/i915/i915_reg.h 
b/src/gallium/drivers/i915/i915_reg.h
index 620c64e..e48a942 100644
--- a/src/gallium/drivers/i915/i915_reg.h
+++ b/src/gallium/drivers/i915/i915_reg.h
@@ -488,10 +488,6 @@
 #define I915_MAX_DECL_INSN27
 #define I915_MAX_TEMPORARY16
 
-#define I915_MAX_INSN  (I915_MAX_DECL_INSN + \
-   I915_MAX_TEX_INSN + \
-   I915_MAX_ALU_INSN)
-
 
 /* Each instruction is 3 dwords long, though most don't require all
  * this space.  Maximum of 123 instructions.  Smaller maxes per insn
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 7ef24f5..991f03b 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -114,7 +114,7 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned 
shader, enum pipe_sha
  return draw_get_shader_param(shader, cap);
   }
case PIPE_SHADER_FRAGMENT:
-  /* XXX: these are just shader model 2.0 values, fix this! */
+  /* XXX: some of these are just shader model 2.0 values, fix this! */
   switch(cap) {
   case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
  return I915_MAX_ALU_INSN + I915_MAX_TEX_INSN;

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


Mesa (master): i915g: Fix wrong indices for LINE_LOOP case

2011-12-11 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 13632e64a0da67149d81bef2da42f159f8ddb1ea
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=13632e64a0da67149d81bef2da42f159f8ddb1ea

Author: Fatih Aşıcı fatih.as...@gmail.com
Date:   Sun Dec 11 13:21:53 2011 -0800

i915g: Fix wrong indices for LINE_LOOP case

---

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

diff --git a/src/gallium/drivers/i915/i915_prim_vbuf.c 
b/src/gallium/drivers/i915/i915_prim_vbuf.c
index 79db3b6..3f85466 100644
--- a/src/gallium/drivers/i915/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915/i915_prim_vbuf.c
@@ -400,8 +400,8 @@ draw_arrays_generate_indices(struct vbuf_render *render,
case PIPE_PRIM_LINE_LOOP:
   if (nr = 2) {
  for (i = start + 1; i  end; i++)
-OUT_BATCH((i-0) | (i+0)  16);
- OUT_BATCH((i-0) | ( start)  16);
+OUT_BATCH((i-1) | (i+0)  16);
+ OUT_BATCH((i-1) | ( start)  16);
   }
   break;
case PIPE_PRIM_QUADS:

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


Mesa (master): i915g: fix debug dump on 64 bit systems

2011-12-11 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 592323de1ea5b9e5eab8b66690c8aecc6901c5de
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=592323de1ea5b9e5eab8b66690c8aecc6901c5de

Author: Michael Karcher freedesktop-bugzi...@mkarcher.dialup.fu-berlin.de
Date:   Sun Dec 11 13:24:10 2011 -0800

i915g: fix debug dump on 64 bit systems

---

 src/gallium/drivers/i915/i915_debug.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_debug.c 
b/src/gallium/drivers/i915/i915_debug.c
index 295c47e..b6c442d 100644
--- a/src/gallium/drivers/i915/i915_debug.c
+++ b/src/gallium/drivers/i915/i915_debug.c
@@ -232,7 +232,7 @@ BITS(
 ... )
 {
va_list  args;
-   unsigned himask = ~0UL  (31 - (hi));
+   unsigned himask = 0xUL  (31 - (hi));
 
PRINTF(stream, \t\t );
 

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


Mesa (master): i915g: Add unsupported PIPE_SHADER_CAP_OUTPUT_READ to silence warnings.

2011-12-01 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: d269ce0a3940a650d6808b5893222a5596ebf36e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d269ce0a3940a650d6808b5893222a5596ebf36e

Author: Stéphane Marchesin marc...@chromium.org
Date:   Thu Dec  1 18:09:18 2011 -0800

i915g: Add unsupported PIPE_SHADER_CAP_OUTPUT_READ to silence warnings.

---

 src/gallium/drivers/i915/i915_screen.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 9341fa9..7ef24f5 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -151,6 +151,8 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned 
shader, enum pipe_sha
  return 0;
   case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
  return I915_TEX_UNITS;
+  case PIPE_SHADER_CAP_OUTPUT_READ:
+ return 0;
   default:
  debug_printf(%s: Unknown cap %u.\n, __FUNCTION__, cap);
  return 0;

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


Mesa (master): i915g: Implement GL_STREAM_* for textures by using untiled textures.

2011-12-01 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 52b75c6165f2b100fe3f8a55ea3f91fbc79e1bf5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=52b75c6165f2b100fe3f8a55ea3f91fbc79e1bf5

Author: Stéphane Marchesin marc...@chromium.org
Date:   Wed Nov  9 16:46:24 2011 -0800

i915g: Implement GL_STREAM_* for textures by using untiled textures.

---

 src/gallium/drivers/i915/i915_resource_texture.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_resource_texture.c 
b/src/gallium/drivers/i915/i915_resource_texture.c
index 0b6424f..8ff733a 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -958,7 +958,7 @@ i915_texture_create(struct pipe_screen *screen,
pipe_reference_init(tex-b.b.reference, 1);
tex-b.b.screen = screen;
 
-   if (force_untiled)
+   if ( (force_untiled) || (template-usage == PIPE_USAGE_STREAM) )
   tex-tiling = I915_TILE_NONE;
else
   tex-tiling = i915_texture_tiling(is, tex);

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


Mesa (master): i915g: Flesh out TODO idea.

2011-10-25 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 2b4ab1435f296e85103e8b0482d416824c5c1e64
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b4ab1435f296e85103e8b0482d416824c5c1e64

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Oct 18 10:25:02 2011 -0700

i915g: Flesh out TODO idea.

---

 src/gallium/drivers/i915/TODO |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/i915/TODO b/src/gallium/drivers/i915/TODO
index e10f473..f97af86 100644
--- a/src/gallium/drivers/i915/TODO
+++ b/src/gallium/drivers/i915/TODO
@@ -36,7 +36,9 @@ Random list of problems with i915g:
 
 - i915_delete_fs_state doesn't call draw_delete_fragment_shader. Why?
 
-- Schedule instructions to minimize the number of phases.
+- Schedule instructions to minimize the number of phases. One way is to replace
+  R registers responsible for a boundary with U registers to avoid phase
+  boundaries.
 
 Other bugs can be found here:
 
https://bugs.freedesktop.org/buglist.cgi?bug_status=NEWbug_status=ASSIGNEDbug_status=REOPENEDcomponent=Drivers/Gallium/i915g

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


Mesa (master): i915g: Cleanup the vertex sampler interface a bit.

2011-10-25 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: b1d93d2aa8395608e77f1c538aa2234ced3dda75
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1d93d2aa8395608e77f1c538aa2234ced3dda75

Author: Stéphane Marchesin marc...@chromium.org
Date:   Tue Oct 18 10:26:04 2011 -0700

i915g: Cleanup the vertex sampler interface a bit.

---

 src/gallium/drivers/i915/i915_context.c |4 +---
 src/gallium/drivers/i915/i915_context.h |4 +---
 src/gallium/drivers/i915/i915_state.c   |6 +++---
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_context.c 
b/src/gallium/drivers/i915/i915_context.c
index ff6d715..5a61740 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -80,9 +80,7 @@ i915_draw_vbo(struct pipe_context *pipe, const struct 
pipe_draw_info *info)
   draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, NULL, 0);
 
if (i915-num_vertex_sampler_views  0)
-  i915_prepare_vertex_sampling(i915,
-   i915-num_vertex_sampler_views,
-   i915-vertex_sampler_views);
+  i915_prepare_vertex_sampling(i915);
 
/*
 * Do the drawing
diff --git a/src/gallium/drivers/i915/i915_context.h 
b/src/gallium/drivers/i915/i915_context.h
index 7f67f5f..7406b7e 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -370,9 +370,7 @@ struct draw_stage *i915_draw_vbuf_stage( struct 
i915_context *i915 );
 /***
  * i915_state.c:
  */
-void i915_prepare_vertex_sampling(struct i915_context *i915,
-  unsigned num,
-  struct pipe_sampler_view **views);
+void i915_prepare_vertex_sampling(struct i915_context *i915);
 void i915_cleanup_vertex_sampling(struct i915_context *i915);
 
 
diff --git a/src/gallium/drivers/i915/i915_state.c 
b/src/gallium/drivers/i915/i915_state.c
index f018f52..bb4089e 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -364,15 +364,15 @@ static void i915_delete_sampler_state(struct pipe_context 
*pipe,
  * Called before drawing VBO to map vertex samplers and hand them to draw
  */
 void
-i915_prepare_vertex_sampling(struct i915_context *i915,
- unsigned num,
- struct pipe_sampler_view **views)
+i915_prepare_vertex_sampling(struct i915_context *i915)
 {
struct i915_winsys *iws = i915-iws;
unsigned i,j;
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS];
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS];
const void* data[PIPE_MAX_TEXTURE_LEVELS];
+   unsigned num = i915-num_vertex_sampler_views;
+   struct pipe_sampler_view **views = i915-vertex_sampler_views;
 
assert(num = PIPE_MAX_VERTEX_SAMPLERS);
if (!num)

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


Mesa (master): i915g: Add TODO.

2011-10-17 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 3637b5f0dd7e4b514f446c264827d80d7ac14289
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3637b5f0dd7e4b514f446c264827d80d7ac14289

Author: Stéphane Marchesin marc...@chromium.org
Date:   Sat Oct 15 23:12:05 2011 -0700

i915g: Add TODO.

---

 src/gallium/drivers/i915/TODO |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/i915/TODO b/src/gallium/drivers/i915/TODO
index 0e511ab..e10f473 100644
--- a/src/gallium/drivers/i915/TODO
+++ b/src/gallium/drivers/i915/TODO
@@ -36,5 +36,7 @@ Random list of problems with i915g:
 
 - i915_delete_fs_state doesn't call draw_delete_fragment_shader. Why?
 
+- Schedule instructions to minimize the number of phases.
+
 Other bugs can be found here:
 
https://bugs.freedesktop.org/buglist.cgi?bug_status=NEWbug_status=ASSIGNEDbug_status=REOPENEDcomponent=Drivers/Gallium/i915g

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


Mesa (master): i915g: Use the right shader limits.

2011-10-17 Thread Stephane Marchesin
Module: Mesa
Branch: master
Commit: 0b3842edb1a0bc1a2163571ef476e080f7c40b0f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b3842edb1a0bc1a2163571ef476e080f7c40b0f

Author: Stéphane Marchesin marc...@chromium.org
Date:   Mon Oct 17 21:43:19 2011 -0700

i915g: Use the right shader limits.

---

 src/gallium/drivers/i915/i915_fpc.h|2 +-
 src/gallium/drivers/i915/i915_reg.h|4 
 src/gallium/drivers/i915/i915_screen.c |8 
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/i915/i915_fpc.h 
b/src/gallium/drivers/i915/i915_fpc.h
index 26cf2fb..bfd658f 100644
--- a/src/gallium/drivers/i915/i915_fpc.h
+++ b/src/gallium/drivers/i915/i915_fpc.h
@@ -37,7 +37,7 @@
 
 #include tgsi/tgsi_parse.h
 
-#define I915_PROGRAM_SIZE 192
+#define I915_PROGRAM_SIZE (3 * I915_MAX_INSN)
 
 /* Use those indices for pos/face routing, must be = num of inputs */
 #define I915_SEMANTIC_POS  100
diff --git a/src/gallium/drivers/i915/i915_reg.h 
b/src/gallium/drivers/i915/i915_reg.h
index e48a942..620c64e 100644
--- a/src/gallium/drivers/i915/i915_reg.h
+++ b/src/gallium/drivers/i915/i915_reg.h
@@ -488,6 +488,10 @@
 #define I915_MAX_DECL_INSN27
 #define I915_MAX_TEMPORARY16
 
+#define I915_MAX_INSN  (I915_MAX_DECL_INSN + \
+   I915_MAX_TEX_INSN + \
+   I915_MAX_ALU_INSN)
+
 
 /* Each instruction is 3 dwords long, though most don't require all
  * this space.  Maximum of 123 instructions.  Smaller maxes per insn
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 4e14b2f..75545f4 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -117,11 +117,11 @@ i915_get_shader_param(struct pipe_screen *screen, 
unsigned shader, enum pipe_sha
   /* XXX: these are just shader model 2.0 values, fix this! */
   switch(cap) {
   case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
- return 96;
+ return I915_MAX_ALU_INSN + I915_MAX_TEX_INSN;
   case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS:
- return 64;
+ return I915_MAX_ALU_INSN;
   case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS:
- return 32;
+ return I915_MAX_TEX_INSN;
   case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS:
  return 8;
   case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
@@ -150,7 +150,7 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned 
shader, enum pipe_sha
   case PIPE_SHADER_CAP_INTEGERS:
  return 0;
   case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
- return 8;
+ return I915_TEX_UNITS;
   default:
  debug_printf(%s: Unknown cap %u.\n, __FUNCTION__, cap);
  return 0;

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


  1   2   3   >