Mesa (master): glx: Fix number of property values to read in glXImportContextEXT

2018-06-05 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 6b8f3724c83959e62b1be0330d6d14e58f91dc5b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b8f3724c83959e62b1be0330d6d14e58f91dc5b

Author: Michel Dänzer 
Date:   Fri Jun  1 18:59:36 2018 +0200

glx: Fix number of property values to read in glXImportContextEXT

We were trying to read twice as many as the X server sent us, which
upset XCB:

[xcb] Too much data requested from _XRead
[xcb] This is most likely caused by a broken X extension library
[xcb] Aborting, sorry about that.
glx-free-context: ../../src/xcb_io.c:732: _XRead: Assertion 
`!xcb_xlib_too_much_data_requested' failed.

Fixing this takes 3 GLX piglit tests from crash to pass.

Fixes: 085216295033 "glx: Be more tolerant in glXImportContext (v2)"
Reviewed-by: Adam Jackson 

---

 src/glx/glxcmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 949c2a5931..e8485acd80 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -1463,7 +1463,7 @@ glXImportContextEXT(Display *dpy, GLXContextID contextID)
if (_XReply(dpy, (xReply *) & reply, 0, False) &&
reply.n < (INT32_MAX / 2)) {
 
-  for (i = 0; i < reply.n * 2; i++) {
+  for (i = 0; i < reply.n; i++) {
  int prop[2];
 
  _XRead(dpy, (char *)prop, sizeof(prop));

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


Mesa (master): dri3: Stricter SBC wraparound handling

2018-05-22 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: fe2edb25dd5628c395a65b60998f11e839d2b458
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe2edb25dd5628c395a65b60998f11e839d2b458

Author: Michel Dänzer 
Date:   Tue May  8 11:51:09 2018 +0200

dri3: Stricter SBC wraparound handling

Prevents corrupting the upper 32 bits of draw->recv_sbc when
draw->send_sbc resets to 0 (which currently happens when the window is
unbound from a context and bound to one again), which in turn caused
loader_dri3_swap_buffers_msc to calculate target_msc with corrupted
upper 32 bits. This resulted in hangs with the Xorg modesetting driver
as of xserver 1.20 (older versions and other drivers ignored the upper
32 bits of the target MSC, which is why this wasn't noticed earlier).

Cc: mesa-sta...@lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/106351
Tested-by: Mike Lothian 

---

 src/loader/loader_dri3_helper.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 6db8303d26..f0ff2f07bd 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -370,9 +370,17 @@ dri3_handle_present_event(struct loader_dri3_drawable 
*draw,
* checking for wrap.
*/
   if (ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP) {
- draw->recv_sbc = (draw->send_sbc & 0xLL) | ce->serial;
- if (draw->recv_sbc > draw->send_sbc)
-draw->recv_sbc -= 0x1;
+ uint64_t recv_sbc = (draw->send_sbc & 0xLL) | 
ce->serial;
+
+ /* Only assume wraparound if that results in exactly the previous
+  * SBC + 1, otherwise ignore received SBC > sent SBC (those are
+  * probably from a previous loader_dri3_drawable instance) to avoid
+  * calculating bogus target MSC values in loader_dri3_swap_buffers_msc
+  */
+ if (recv_sbc <= draw->send_sbc)
+draw->recv_sbc = recv_sbc;
+ else if (recv_sbc == (draw->recv_sbc + 0x10001ULL))
+draw->recv_sbc = recv_sbc - 0x1ULL;
 
  /* When moving from flip to copy, we assume that we can allocate in
   * a more optimal way if we don't need to cater for the display

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


Mesa (master): dri3: Only update number of back buffers in loader_dri3_get_buffers

2018-05-09 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 6f81e07ecb8c0793dc482307d5d96fd3df95b7d2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f81e07ecb8c0793dc482307d5d96fd3df95b7d2

Author: Michel Dänzer 
Date:   Fri Apr 27 17:41:48 2018 +0200

dri3: Only update number of back buffers in loader_dri3_get_buffers

And only free no longer needed back buffers there as well.

We want to stick to the same back buffer throughout a frame, otherwise
we can run into various issues.

Bugzilla: https://bugs.freedesktop.org/105906
Bugzilla: https://bugs.freedesktop.org/106399
Fixes: 3160cb86aa92 "egl/x11: Re-allocate buffers if format is suboptimal"
Reported-by: Sergii Romantsov 
Tested-by: Eero Tamminen 
Acked-by: Daniel Stone 

---

 src/loader/loader_dri3_helper.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 23729f7ecb..6db8303d26 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -420,13 +420,6 @@ dri3_handle_present_event(struct loader_dri3_drawable 
*draw,
 
  if (buf && buf->pixmap == ie->pixmap)
 buf->busy = 0;
-
- if (buf && draw->cur_blit_source != b && !buf->busy &&
- (buf->reallocate ||
- (draw->num_back <= b && b < LOADER_DRI3_MAX_BACK))) {
-dri3_free_render_buffer(draw, buf);
-draw->buffers[b] = NULL;
- }
   }
   break;
}
@@ -559,7 +552,6 @@ dri3_find_back(struct loader_dri3_drawable *draw)
/* Check whether we need to reuse the current back buffer as new back.
 * In that case, wait until it's not busy anymore.
 */
-   dri3_update_num_back(draw);
num_to_consider = draw->num_back;
if (!loader_dri3_have_image_blit(draw) && draw->cur_blit_source != -1) {
   num_to_consider = 1;
@@ -1815,6 +1807,7 @@ loader_dri3_get_buffers(__DRIdrawable *driDrawable,
 {
struct loader_dri3_drawable *draw = loaderPrivate;
struct loader_dri3_buffer   *front, *back;
+   int buf_id;
 
buffers->image_mask = 0;
buffers->front = NULL;
@@ -1826,6 +1819,16 @@ loader_dri3_get_buffers(__DRIdrawable *driDrawable,
if (!dri3_update_drawable(driDrawable, draw))
   return false;
 
+   dri3_update_num_back(draw);
+
+   /* Free no longer needed back buffers */
+   for (buf_id = draw->num_back; buf_id < LOADER_DRI3_MAX_BACK; buf_id++) {
+  if (draw->cur_blit_source != buf_id && draw->buffers[buf_id]) {
+ dri3_free_render_buffer(draw, draw->buffers[buf_id]);
+ draw->buffers[buf_id] = NULL;
+  }
+   }
+
/* pixmaps always have front buffers.
 * Exchange swaps also mandate fake front buffers.
 */

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


Mesa (master): r600: consolidate PIPE_BIND_SHARED/SCANOUT handling

2018-03-16 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: f099c3aef1635f05f295969d296375fe9983a53a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f099c3aef1635f05f295969d296375fe9983a53a

Author: Marek Olšák 
Date:   Thu Mar 15 18:39:52 2018 +0100

r600: consolidate PIPE_BIND_SHARED/SCANOUT handling

(Ported from radeonsi commit f70f6baaa3bb0f8b280ac2eaea69bbffaf7de840)

Allows cached BOs to be reused in more cases.

Bugzilla: https://bugs.freedesktop.org/105171
Reviewed-by: Marek Olšák 
Signed-off-by: Michel Dänzer 

---

 src/gallium/drivers/r600/r600_buffer_common.c | 14 --
 src/gallium/drivers/r600/r600_texture.c   |  4 
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_buffer_common.c 
b/src/gallium/drivers/r600/r600_buffer_common.c
index 501b96fa0b..ca19af9b2e 100644
--- a/src/gallium/drivers/r600/r600_buffer_common.c
+++ b/src/gallium/drivers/r600/r600_buffer_common.c
@@ -167,21 +167,15 @@ void r600_init_resource_fields(struct r600_common_screen 
*rscreen,
 RADEON_FLAG_GTT_WC;
}
 
-   /* Only displayable single-sample textures can be shared between
-* processes. */
-   if (res->b.b.target == PIPE_BUFFER ||
-   res->b.b.nr_samples >= 2 ||
-   (rtex->surface.micro_tile_mode != RADEON_MICRO_MODE_DISPLAY &&
-/* Raven doesn't use display micro mode for 32bpp, so check this: 
*/
-!(res->b.b.bind & PIPE_BIND_SCANOUT)))
+   /* Displayable and shareable surfaces are not suballocated. */
+   if (res->b.b.bind & (PIPE_BIND_SHARED | PIPE_BIND_SCANOUT))
+   res->flags |= RADEON_FLAG_NO_SUBALLOC; /* shareable */
+   else
res->flags |= RADEON_FLAG_NO_INTERPROCESS_SHARING;
 
if (rscreen->debug_flags & DBG_NO_WC)
res->flags &= ~RADEON_FLAG_GTT_WC;
 
-   if (res->b.b.bind & PIPE_BIND_SHARED)
-   res->flags |= RADEON_FLAG_NO_SUBALLOC;
-
/* Set expected VRAM and GART usage for the buffer. */
res->vram_usage = 0;
res->gart_usage = 0;
diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index fbcc878a24..806bc278b0 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -953,10 +953,6 @@ r600_texture_create_object(struct pipe_screen *screen,
r600_init_resource_fields(rscreen, resource, rtex->size,
  rtex->surface.surf_alignment);
 
-   /* Displayable surfaces are not suballocated. */
-   if (resource->b.b.bind & PIPE_BIND_SCANOUT)
-   resource->flags |= RADEON_FLAG_NO_SUBALLOC;
-
if (!r600_alloc_resource(rscreen, resource)) {
FREE(rtex);
return NULL;

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


Mesa (master): st/mesa: gl_program::info.system_values_read is a 64-bit-field

2018-03-09 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 2a4596a2f08321f35ec8dc59667ce3a7e7080e7e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a4596a2f08321f35ec8dc59667ce3a7e7080e7e

Author: Michel Dänzer 
Date:   Thu Mar  8 17:32:50 2018 +0100

st/mesa: gl_program::info.system_values_read is a 64-bit-field

We were dropping the upper 32 bits, which caused assertion failures in
some compute shader piglit tests with radeonsi since the commit below.

Fixes: 752e96970303 ("compiler: Add two new system values for subgroups")
Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 8 
 src/mesa/state_tracker/st_mesa_to_tgsi.c   | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index ccf4dabcc9..911c855d43 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6532,10 +6532,10 @@ st_translate_program(
/* Declare misc input registers
 */
{
-  GLbitfield sysInputs = proginfo->info.system_values_read;
+  GLbitfield64 sysInputs = proginfo->info.system_values_read;
 
   for (i = 0; sysInputs; i++) {
- if (sysInputs & (1 << i)) {
+ if (sysInputs & (1ull << i)) {
 enum tgsi_semantic semName = _mesa_sysval_to_semantic(i);
 
 t->systemValues[i] = ureg_DECL_system_value(ureg, semName, 0);
@@ -6567,7 +6567,7 @@ st_translate_program(
emit_wpos(st_context(ctx), t, proginfo, ureg,
  program->wpos_transform_const);
 
-sysInputs &= ~(1 << i);
+sysInputs &= ~(1ull << i);
  }
   }
}
@@ -6864,7 +6864,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
/* This must be done before the uniform storage is associated. */
if (shader->Stage == MESA_SHADER_FRAGMENT &&
(prog->info.inputs_read & VARYING_BIT_POS ||
-prog->info.system_values_read & (1 << SYSTEM_VALUE_FRAG_COORD))) {
+prog->info.system_values_read & (1ull << SYSTEM_VALUE_FRAG_COORD))) {
   static const gl_state_index16 wposTransformState[STATE_LENGTH] = {
  STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
   };
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c 
b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index c76180a579..99cddd6628 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -951,9 +951,9 @@ st_translate_mesa_program(struct gl_context *ctx,
 
/* Declare misc input registers
 */
-   GLbitfield sysInputs = program->info.system_values_read;
+   GLbitfield64 sysInputs = program->info.system_values_read;
for (i = 0; sysInputs; i++) {
-  if (sysInputs & (1 << i)) {
+  if (sysInputs & (1ull << i)) {
  unsigned semName = _mesa_sysval_to_semantic(i);
 
  t->systemValues[i] = ureg_DECL_system_value(ureg, semName, 0);
@@ -985,7 +985,7 @@ st_translate_mesa_program(struct gl_context *ctx,
  semName == TGSI_SEMANTIC_POSITION)
 emit_wpos(st_context(ctx), t, program, ureg);
 
-  sysInputs &= ~(1 << i);
+  sysInputs &= ~(1ull << i);
   }
}
 

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


Mesa (master): st/mesa: Initialize tex_target in compile_tgsi_instruction

2018-02-09 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 171076f0826f932606d35e6a315b74a6598e2d6f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=171076f0826f932606d35e6a315b74a6598e2d6f

Author: Michel Dänzer 
Date:   Thu Feb  8 18:48:45 2018 +0100

st/mesa: Initialize tex_target in compile_tgsi_instruction

Initialize to TGSI_TEXTURE_BUFFER (== 0), same as was done before the
variable type was changed to enum tgsi_texture_type.

Fixes a bunch of piglit failures with radeonsi, e.g.:

gles-3.0-transform-feedback-uniform-buffer-object: 
../../../../src/gallium/auxiliary/tgsi/tgsi_util.c:502: 
tgsi_util_get_texture_coord_dim: Assertion `!"unknown texture target"' failed.

Corresponding compiler warning:

  CXX  state_tracker/st_glsl_to_tgsi.lo
../../../src/mesa/state_tracker/st_glsl_to_tgsi.cpp: In function ‘pipe_error 
st_translate_program(gl_context*, uint, ureg_program*, glsl_to_tgsi_visitor*, 
const gl_program*, GLuint, const ubyte*, const ubyte*, const ubyte*, const 
ubyte*, const ubyte*, GLuint, const ubyte*, const ubyte*, const ubyte*)’:
../../../src/mesa/state_tracker/st_glsl_to_tgsi.cpp:5992:23: warning: 
‘tex_target’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   ureg_memory_insn(ureg, inst->op, dst, num_dst, src, num_src,
   ^~~~
inst->buffer_access,

tex_target, inst->image_format);
~~~
../../../src/mesa/state_tracker/st_glsl_to_tgsi.cpp:5866:27: note: ‘tex_target’ 
was declared here
enum tgsi_texture_type tex_target;
   ^~

Fixes: 9f9ce1625fb3 ("st/mesa: use TGSI enum types in st_glsl_to_tgsi.cpp")
Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 39a81fad62..1f87591893 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5863,7 +5863,7 @@ compile_tgsi_instruction(struct st_translate *t,
 
int num_dst;
int num_src;
-   enum tgsi_texture_type tex_target;
+   enum tgsi_texture_type tex_target = TGSI_TEXTURE_BUFFER;
 
num_dst = num_inst_dst_regs(inst);
num_src = num_inst_src_regs(inst);

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


Mesa (master): winsys/radeon: Compute is_displayable in surf_drm_to_winsys

2018-01-31 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 1cf1bf32eff5ffca0b928c0884b0e792207b61b7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1cf1bf32eff5ffca0b928c0884b0e792207b61b7

Author: Michel Dänzer 
Date:   Fri Jan 26 18:32:32 2018 +0100

winsys/radeon: Compute is_displayable in surf_drm_to_winsys

It was always 0, breaking (at least) DRI3 with Xwayland.

Bugzilla: https://bugs.freedesktop.org/104306
Fixes: 5f2073be3282 ("ac/surface: add ac_surface::is_displayable")
Reviewed-by: Marek Olšák 

---

 src/gallium/winsys/radeon/drm/radeon_drm_surface.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
index 5ee01ff90f..77fb7757c2 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
@@ -215,6 +215,9 @@ static void surf_drm_to_winsys(struct radeon_drm_winsys *ws,
 }
 
 set_micro_tile_mode(surf_ws, &ws->info);
+surf_ws->is_displayable = surf_ws->is_linear ||
+ surf_ws->micro_tile_mode == 
RADEON_MICRO_MODE_DISPLAY ||
+ surf_ws->micro_tile_mode == 
RADEON_MICRO_MODE_ROTATED;
 }
 
 static int radeon_winsys_surface_init(struct radeon_winsys *rws,

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


Mesa (master): loader/dri3: Try to make sure we only process our own NotifyMSC events

2018-01-17 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 7b0e8264dd21ae05521d08d41fecd84139401fef
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b0e8264dd21ae05521d08d41fecd84139401fef

Author: Michel Dänzer 
Date:   Wed Jan  3 12:21:56 2018 +0100

loader/dri3: Try to make sure we only process our own NotifyMSC events

We were using a sequence counter value to wait for a specific NotifyMSC
event. However, we can receive events from other clients as well, which
may already be using higher sequence numbers than us. In that case, we
could stop processing after an event from another client, which could
have been received significantly earlier. This would have multiple
undesirable effects:

* The computed MSC and UST values would be lower than they should be
* We could leave a growing number of NotifyMSC events from ourselves and
  other clients in XCB's special event queue

I ran into this with Firefox and Thunderbird, whose VSync threads both
seem to use the same window. The result was sluggish screen updates and
growing memory consumption in one of them.

Fix this by checking the XCB sequence number and MSC value of NotifyMSC
events, instead of using our own sequence number.

v2:
* Use the Present event ID for the sequence parameter of the
  PresentNotifyMSC request, as another safeguard against processing
  events from other clients
* Rebase on drawable mutex changes

Reviewed-by: Nicolai Hähnle  # v1

---

 src/loader/loader_dri3_helper.c | 36 ++--
 src/loader/loader_dri3_helper.h |  4 
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 8f8efcb646..fbda3d635c 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -382,8 +382,7 @@ dri3_handle_present_event(struct loader_dri3_drawable *draw,
 
  draw->ust = ce->ust;
  draw->msc = ce->msc;
-  } else {
- draw->recv_msc_serial = ce->serial;
+  } else if (ce->serial == draw->eid) {
  draw->notify_ust = ce->ust;
  draw->notify_msc = ce->msc;
   }
@@ -452,28 +451,29 @@ loader_dri3_wait_for_msc(struct loader_dri3_drawable 
*draw,
  int64_t divisor, int64_t remainder,
  int64_t *ust, int64_t *msc, int64_t *sbc)
 {
-   uint32_t msc_serial;
-
-   msc_serial = ++draw->send_msc_serial;
-   xcb_present_notify_msc(draw->conn,
-  draw->drawable,
-  msc_serial,
-  target_msc,
-  divisor,
-  remainder);
+   xcb_void_cookie_t cookie = xcb_present_notify_msc(draw->conn,
+ draw->drawable,
+ draw->eid,
+ target_msc,
+ divisor,
+ remainder);
+   xcb_generic_event_t *ev;
+   unsigned full_sequence;
 
mtx_lock(&draw->mtx);
xcb_flush(draw->conn);
 
/* Wait for the event */
-   if (draw->special_event) {
-  while ((int32_t) (msc_serial - draw->recv_msc_serial) > 0) {
- if (!dri3_wait_for_event_locked(draw)) {
-mtx_unlock(&draw->mtx);
-return false;
- }
+   do {
+  ev = xcb_wait_for_special_event(draw->conn, draw->special_event);
+  if (!ev) {
+ mtx_unlock(&draw->mtx);
+ return false;
   }
-   }
+
+  full_sequence = ev->full_sequence;
+  dri3_handle_present_event(draw, (void *) ev);
+   } while (full_sequence != cookie.sequence || draw->notify_msc < target_msc);
 
*ust = draw->notify_ust;
*msc = draw->notify_msc;
diff --git a/src/loader/loader_dri3_helper.h b/src/loader/loader_dri3_helper.h
index 0dd37e9171..4ce98b8c59 100644
--- a/src/loader/loader_dri3_helper.h
+++ b/src/loader/loader_dri3_helper.h
@@ -137,10 +137,6 @@ struct loader_dri3_drawable {
/* Last received UST/MSC values from present notify msc event */
uint64_t notify_ust, notify_msc;
 
-   /* Serial numbers for tracking wait_for_msc events */
-   uint32_t send_msc_serial;
-   uint32_t recv_msc_serial;
-
struct loader_dri3_buffer *buffers[LOADER_DRI3_NUM_BUFFERS];
int cur_back;
int num_back;

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


Mesa (master): gallivm: Use new LLVM fast-math-flags API

2017-11-08 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 5d61fa4e68b7eb6d481a37efdbb35fdce675a6ad
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5d61fa4e68b7eb6d481a37efdbb35fdce675a6ad

Author: Tobias Droste 
Date:   Wed Nov  8 10:44:19 2017 +0100

gallivm: Use new LLVM fast-math-flags API

LLVM 6 changed the API on the fast-math-flags:
https://reviews.llvm.org/rL317488

NOTE: This also enables the new flag 'ApproxFunc' to allow for
approximations for library functions (sin, cos, ...). I'm not completly
convinced, that this is something mesa should do.

Signed-off-by: Tobias Droste 
Reviewed-by: Marek Olšák 
Reviewed-and-Tested-by: Michel Dänzer 

---

 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp 
b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index d988910a7e..1319407290 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -830,7 +830,11 @@ lp_create_builder(LLVMContextRef ctx, enum lp_float_mode 
float_mode)
   llvm::unwrap(builder)->setFastMathFlags(flags);
   break;
case LP_FLOAT_MODE_UNSAFE_FP_MATH:
+#if HAVE_LLVM >= 0x0600
+  flags.setFast();
+#else
   flags.setUnsafeAlgebra();
+#endif
   llvm::unwrap(builder)->setFastMathFlags(flags);
   break;
}

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


Mesa (master): gallium: Guard assertions by NDEBUG instead of DEBUG

2017-11-07 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: cd3b55ad07dbf1a7cfd3b30109d0562bea692576
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd3b55ad07dbf1a7cfd3b30109d0562bea692576

Author: Michel Dänzer 
Date:   Tue Nov  7 10:48:12 2017 +0100

gallium: Guard assertions by NDEBUG instead of DEBUG

This matches the standard assert.h header.

Reviewed-by: Eric Engestrom 
Reviewed-by: Marek Olšák 

---

 src/gallium/auxiliary/util/u_debug.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_debug.h 
b/src/gallium/auxiliary/util/u_debug.h
index 63940b7225..d2ea89f59c 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -185,7 +185,7 @@ void _debug_assert_fail(const char *expr,
  * For non debug builds the assert macro will expand to a no-op, so do not
  * call functions with side effects in the assert expression.
  */
-#ifdef DEBUG
+#ifndef NDEBUG
 #define debug_assert(expr) ((expr) ? (void)0 : _debug_assert_fail(#expr, 
__FILE__, __LINE__, __FUNCTION__))
 #else
 #define debug_assert(expr) (void)(0 && (expr))

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


Mesa (master): st/osmesa: include u_inlines.h for pipe_resource_reference

2017-10-18 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 8c9e7c9638278687297fbc6ba4344771d61f721e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c9e7c9638278687297fbc6ba4344771d61f721e

Author: Michel Dänzer 
Date:   Wed Oct 18 18:44:58 2017 +0200

st/osmesa: include u_inlines.h for pipe_resource_reference

Fixes build failure due to unresolved symbol.

Fixes: 7561da367bae "st/mesa: Initialize textures array in
 st_framebuffer_validate"

Trivial.

---

 src/gallium/state_trackers/osmesa/osmesa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/osmesa/osmesa.c 
b/src/gallium/state_trackers/osmesa/osmesa.c
index 44a0cc4381..8baec0a0e4 100644
--- a/src/gallium/state_trackers/osmesa/osmesa.c
+++ b/src/gallium/state_trackers/osmesa/osmesa.c
@@ -62,6 +62,7 @@
 #include "util/u_box.h"
 #include "util/u_debug.h"
 #include "util/u_format.h"
+#include "util/u_inlines.h"
 #include "util/u_memory.h"
 
 #include "postprocess/filters.h"

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


Mesa (master): st/mesa: Initialize textures array in st_framebuffer_validate

2017-10-18 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 7561da367baeb49c848dc49b65e252deb6428422
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7561da367baeb49c848dc49b65e252deb6428422

Author: Michel Dänzer 
Date:   Mon Oct 16 16:35:18 2017 +0200

st/mesa: Initialize textures array in st_framebuffer_validate

And just reference pipe_resources to it in the validate callbacks.

Avoids pipe_resource leaks when st_framebuffer_validate ends up calling
the validate callback multiple times, e.g. when a window is resized.

v2:
* Use generic stable tag instead of Fixes: tag, since the problem could
  already happen before the commit referenced in v1 (Thomas Hellstrom)
* Use memset to initialize the array on the stack instead of allocating
  the array with os_calloc.

Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Thomas Hellstrom 

---

 src/gallium/state_trackers/dri/dri_drawable.c | 4 +---
 src/gallium/state_trackers/glx/xlib/xm_st.c   | 4 +---
 src/gallium/state_trackers/hgl/hgl.c  | 4 +---
 src/gallium/state_trackers/osmesa/osmesa.c| 1 +
 src/gallium/state_trackers/wgl/stw_st.c   | 4 +---
 src/mesa/state_tracker/st_manager.c   | 2 ++
 6 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri_drawable.c 
b/src/gallium/state_trackers/dri/dri_drawable.c
index 75a8197d33..d586b7564e 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -99,10 +99,8 @@ dri_st_framebuffer_validate(struct st_context_iface *stctx,
   return TRUE;
 
/* Set the window-system buffers for the state tracker. */
-   for (i = 0; i < count; i++) {
-  out[i] = NULL;
+   for (i = 0; i < count; i++)
   pipe_resource_reference(&out[i], textures[statts[i]]);
-   }
 
return TRUE;
 }
diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c 
b/src/gallium/state_trackers/glx/xlib/xm_st.c
index 0c42e653c7..946b5dcff2 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_st.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
@@ -245,10 +245,8 @@ xmesa_st_framebuffer_validate(struct st_context_iface 
*stctx,
   }
}
 
-   for (i = 0; i < count; i++) {
-  out[i] = NULL;
+   for (i = 0; i < count; i++)
   pipe_resource_reference(&out[i], xstfb->textures[statts[i]]);
-   }
 
return TRUE;
 }
diff --git a/src/gallium/state_trackers/hgl/hgl.c 
b/src/gallium/state_trackers/hgl/hgl.c
index 1b702815a3..bbc477a978 100644
--- a/src/gallium/state_trackers/hgl/hgl.c
+++ b/src/gallium/state_trackers/hgl/hgl.c
@@ -193,10 +193,8 @@ hgl_st_framebuffer_validate(struct st_context_iface 
*stctxi,
//}
}
 
-   for (i = 0; i < count; i++) {
-   out[i] = NULL;
+   for (i = 0; i < count; i++)
pipe_resource_reference(&out[i], buffer->textures[statts[i]]);
-   }
 
return TRUE;
 }
diff --git a/src/gallium/state_trackers/osmesa/osmesa.c 
b/src/gallium/state_trackers/osmesa/osmesa.c
index 2f9558db31..44a0cc4381 100644
--- a/src/gallium/state_trackers/osmesa/osmesa.c
+++ b/src/gallium/state_trackers/osmesa/osmesa.c
@@ -432,6 +432,7 @@ osmesa_st_framebuffer_validate(struct st_context_iface 
*stctx,
 
   templat.format = format;
   templat.bind = bind;
+  pipe_resource_reference(&out[i], NULL);
   out[i] = osbuffer->textures[statts[i]] =
  screen->resource_create(screen, &templat);
}
diff --git a/src/gallium/state_trackers/wgl/stw_st.c 
b/src/gallium/state_trackers/wgl/stw_st.c
index 5e165c89f5..7cf18f0a8b 100644
--- a/src/gallium/state_trackers/wgl/stw_st.c
+++ b/src/gallium/state_trackers/wgl/stw_st.c
@@ -161,10 +161,8 @@ stw_st_framebuffer_validate(struct st_context_iface *stctx,
   stwfb->fb->must_resize = FALSE;
}
 
-   for (i = 0; i < count; i++) {
-  out[i] = NULL;
+   for (i = 0; i < count; i++)
   pipe_resource_reference(&out[i], stwfb->textures[statts[i]]);
-   }
 
stw_framebuffer_unlock(stwfb->fb);
 
diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index aef87ea8b7..eebde62183 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -190,6 +190,8 @@ st_framebuffer_validate(struct st_framebuffer *stfb,
if (stfb->iface_stamp == new_stamp)
   return;
 
+   memset(textures, 0, stfb->num_statts * sizeof(textures[0]));
+
/* validate the fb */
do {
   if (!stfb->iface->validate(&st->iface, stfb->iface, stfb->statts,

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


Mesa (master): configure: Check llvm-config --shared-mode

2017-08-16 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 2c5717a4de2a2406a7e155de641921571a3910c7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c5717a4de2a2406a7e155de641921571a3910c7

Author: Michel Dänzer 
Date:   Tue Aug 15 09:41:57 2017 +0900

configure: Check llvm-config --shared-mode

https://bugs.llvm.org/show_bug.cgi?id=6823 still affects current LLVM.
llvm-config --libs only reports the single shared library if LLVM was
built with -DLLVM_LINK_LLVM_DYLIB=ON. llvm-config --shared-mode reports
"shared" in that case, "static" otherwise (even if LLVM was built with
-DLLVM_BUILD_LLVM_DYLIB=ON).

v2: Keep the LLVM < 4.0 test. (llvm-config --shared-mode is actually
available since LLVM 3.8, but that would make the test too
complicated :)

Fixes: 3d8da1f678e1 ("configure: Trust LLVM >= 4.0 llvm-config --libs
  for shared libraries")
Bugzilla: https://bugs.freedesktop.org/102247
Tested-by: Dieter Nützel 

---

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index e3babd3909..52645bb44f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2646,7 +2646,7 @@ if test "x$enable_llvm" = xyes; then
 LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
 
 if test "x$enable_llvm_shared_libs" = xyes; then
-if test $LLVM_VERSION_MAJOR -lt 4; then
+if test $LLVM_VERSION_MAJOR -lt 4 -o "`$LLVM_CONFIG --shared-mode 
${LLVM_COMPONENTS}`" = static; then
 dnl llvm-config may not give the right answer when llvm is a built 
as a
 dnl single shared library, so we must work the library name out for
 dnl ourselves.

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


Mesa (master): configure: Trust LLVM >= 4.0 llvm-config --libs for shared libraries

2017-08-14 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 3d8da1f678e196af619d74845f7d5f564ce40ea3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d8da1f678e196af619d74845f7d5f564ce40ea3

Author: Michel Dänzer 
Date:   Tue Aug  8 16:20:55 2017 +0900

configure: Trust LLVM >= 4.0 llvm-config --libs for shared libraries

No need to manually look for the library files anymore with current
LLVM. This sidesteps the manual method failing when LLVM was built with
-DLLVM_APPEND_VC_REV=ON.

(This might already work with older versions of LLVM)

Acked-by: Marek Olšák 
Reviewed-by: Emil Velikov 

---

 configure.ac | 58 ++
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/configure.ac b/configure.ac
index f131788e3a..3fe47c7bbc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2623,35 +2623,37 @@ if test "x$enable_llvm" = xyes; then
 fi
 LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
 
-dnl llvm-config may not give the right answer when llvm is a built as a
-dnl single shared library, so we must work the library name out for
-dnl ourselves.
-dnl (See https://llvm.org/bugs/show_bug.cgi?id=6823)
 if test "x$enable_llvm_shared_libs" = xyes; then
-dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
-LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
-AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.$IMP_LIB_EXT"], 
[llvm_have_one_so=yes])
-
-if test "x$llvm_have_one_so" = xyes; then
-dnl LLVM was built using auto*, so there is only one shared object.
-LLVM_LIBS="-l$LLVM_SO_NAME"
-else
-dnl If LLVM was built with CMake, there will be one shared object 
per
-dnl component.
-AS_IF([test ! -f "$LLVM_LIBDIR/libLLVMTarget.$IMP_LIB_EXT"],
-[AC_MSG_ERROR([Could not find llvm shared libraries:
-   Please make sure you have built llvm with the --enable-shared option
-   and that your llvm libraries are installed in $LLVM_LIBDIR
-   If you have installed your llvm libraries to a different directory you
-   can use the --with-llvm-prefix= configure flag to specify this 
directory.
-   NOTE: Mesa is attempting to use llvm shared libraries by default.
-   If you do not want to build with llvm shared libraries and instead want 
to
-   use llvm static libraries then add --disable-llvm-shared-libs to your 
configure
-   invocation and rebuild.])])
-
-   dnl We don't need to update LLVM_LIBS in this case because the LLVM
-   dnl install uses a shared object for each component and we have
-   dnl already added all of these objects to LLVM_LIBS.
+if test $LLVM_VERSION_MAJOR -lt 4; then
+dnl llvm-config may not give the right answer when llvm is a built 
as a
+dnl single shared library, so we must work the library name out for
+dnl ourselves.
+dnl (See https://llvm.org/bugs/show_bug.cgi?id=6823)
+dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
+LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
+AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.$IMP_LIB_EXT"], 
[llvm_have_one_so=yes])
+
+if test "x$llvm_have_one_so" = xyes; then
+   dnl LLVM was built using auto*, so there is only one shared 
object.
+   LLVM_LIBS="-l$LLVM_SO_NAME"
+else
+dnl If LLVM was built with CMake, there will be one shared 
object per
+dnl component.
+AS_IF([test ! -f "$LLVM_LIBDIR/libLLVMTarget.$IMP_LIB_EXT"],
+  [AC_MSG_ERROR([Could not find llvm shared libraries:
+   Please make sure you have built llvm with the 
--enable-shared option
+   and that your llvm libraries are installed in 
$LLVM_LIBDIR
+   If you have installed your llvm libraries to a 
different directory you
+   can use the --with-llvm-prefix= configure flag to 
specify this directory.
+   NOTE: Mesa is attempting to use llvm shared libraries 
by default.
+   If you do not want to build with llvm shared libraries 
and instead want to
+   use llvm static libraries then add 
--disable-llvm-shared-libs to your configure
+   invocation and rebuild.])])
+
+dnl We don't need to update LLVM_LIBS in this case because the 
LLVM
+dnl install uses a shared object for each component and we have
+dnl already added all of these objects to LLVM_LIBS.
+fi
 fi
 else
 AC_MSG_WARN([Building mesa with statically linked LLVM may cause 
compilation issues])


Mesa (master): pipe-loader: Add driver build directory for si_driinfo.h include path

2017-08-03 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: b73d8d4547bbae9562e2bb20e9938bb6604aa036
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b73d8d4547bbae9562e2bb20e9938bb6604aa036

Author: Michel Dänzer 
Date:   Fri Aug  4 12:02:38 2017 +0900

pipe-loader: Add driver build directory for si_driinfo.h include path

Fixes out-of-tree build failure:

.../src/gallium/targets/pipe-loader/pipe_radeonsi.c: In function 
‘drm_configuration’:
.../src/gallium/targets/pipe-loader/pipe_radeonsi.c:38:33: fatal error: 
radeonsi/si_driinfo.h: No such file or directory
 #include "radeonsi/si_driinfo.h"
 ^
compilation terminated.
Makefile:994: recipe for target 'pipe_radeonsi.lo' failed
make[4]: *** [pipe_radeonsi.lo] Error 1

Trivial.

Fixes: 0f8c5de8690e7c ("radeonsi: prepare for driver-specific driconf
options")

---

 src/gallium/targets/pipe-loader/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/targets/pipe-loader/Makefile.am 
b/src/gallium/targets/pipe-loader/Makefile.am
index db492c5023..050dd7d9dc 100644
--- a/src/gallium/targets/pipe-loader/Makefile.am
+++ b/src/gallium/targets/pipe-loader/Makefile.am
@@ -25,6 +25,7 @@ include $(top_srcdir)/src/gallium/Automake.inc
 AM_CPPFLAGS = \
$(GALLIUM_CFLAGS) \
-I$(top_srcdir)/include \
+   -I$(top_builddir)/src/gallium/drivers \
-I$(top_srcdir)/src/gallium/drivers \
-I$(top_srcdir)/src/gallium/winsys \
-I$(top_builddir)/src/util \

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


Mesa (master): st/mesa: Fix inversed test in st_api_destroy_drawable

2017-07-26 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 57132d126f2e129fc2959dcc2c0a8126389d07ba
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=57132d126f2e129fc2959dcc2c0a8126389d07ba

Author: Michel Dänzer 
Date:   Thu Jul 27 11:12:24 2017 +0900

st/mesa: Fix inversed test in st_api_destroy_drawable

Fixes a drawable leak.

Fixes: bbc29393d3be ("st/mesa: create framebuffer iface hash table per
  st manager")
Bugzilla: https://bugs.freedesktop.org/101930
Tested-by: Nick Sarnie 
Reviewed-by: Brian Paul 

---

 src/mesa/state_tracker/st_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_manager.c 
b/src/mesa/state_tracker/st_manager.c
index 6447403fc6..97bf89fc65 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -583,7 +583,7 @@ static void
 st_api_destroy_drawable(struct st_api *stapi,
 struct st_framebuffer_iface *stfbi)
 {
-   if (stfbi)
+   if (!stfbi)
   return;
 
st_framebuffer_iface_remove(stfbi->state_manager, stfbi);

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


Mesa (master): loader/dri3: Use dri3_find_back in loader_dri3_swap_buffers_msc

2017-07-13 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 81fb1547772d42c527318837d4207ecdb6899e5d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=81fb1547772d42c527318837d4207ecdb6899e5d

Author: Thomas Hellstrom 
Date:   Tue Jul  4 12:55:15 2017 +0900

loader/dri3: Use dri3_find_back in loader_dri3_swap_buffers_msc

If the application hasn't done any drawing since the last call, we
would reuse the same back buffer which was used for the previous swap,
which may not have completed yet. This could result in various issues
such as tearing or application hangs.

In the normal case, the behaviour is unchanged.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97957
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101683
Cc: mesa-sta...@lists.freedesktop.org

[Michel Dänzer: Make Thomas' fix from bugzilla actually work as
 intended, write commit log]

---

 src/loader/loader_dri3_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 493a7f5218..1c93e7a96d 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -640,7 +640,7 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable 
*draw,
 
draw->vtable->flush_drawable(draw, flush_flags);
 
-   back = draw->buffers[LOADER_DRI3_BACK_ID(draw->cur_back)];
+   back = draw->buffers[dri3_find_back(draw)];
if (draw->is_different_gpu && back) {
   /* Update the linear buffer before presenting the pixmap */
   draw->ext->image->blitImage(dri_context,

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


Mesa (master): gallium/util: Break recursion in pipe_resource_reference

2017-06-14 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 176e761513f9f9502248c0c8dad133d2d9f28d2d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=176e761513f9f9502248c0c8dad133d2d9f28d2d

Author: Michel Dänzer 
Date:   Tue Jun 13 12:02:59 2017 +0900

gallium/util: Break recursion in pipe_resource_reference

It calling itself recursively prevented it from being inlined, resulting
in a copy being generated in every compilation unit referencing it. This
bloated the text segment of the Gallium mega-driver *_dri.so by ~4%,
and might also have impacted performance.

Fixes: ecd6fce2611e ("mesa/st: support lowering multi-planar YUV")
v2:
* Add comment above pipe_resource_next_reference [Samuel Pitoiset]
v3:
* Use loop to unreference the full chain of resources referenced via
  the next members [Timothy Arceri]
v4:
* Stop chasing ->next chain at the first sub-resource which isn't
  destroyed [Nicolai Hähnle]

Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/auxiliary/util/u_inlines.h | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_inlines.h 
b/src/gallium/auxiliary/util/u_inlines.h
index 6a3d5043cf..4fc683a574 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -137,8 +137,14 @@ pipe_resource_reference(struct pipe_resource **ptr, struct 
pipe_resource *tex)
 
if (pipe_reference_described(&(*ptr)->reference, &tex->reference, 
 
(debug_reference_descriptor)debug_describe_resource)) {
-  pipe_resource_reference(&old_tex->next, NULL);
-  old_tex->screen->resource_destroy(old_tex->screen, old_tex);
+  /* Avoid recursion, which would prevent inlining this function */
+  do {
+ struct pipe_resource *next = old_tex->next;
+
+ old_tex->screen->resource_destroy(old_tex->screen, old_tex);
+ old_tex = next;
+  } while (pipe_reference_described(&old_tex->reference, NULL,
+
(debug_reference_descriptor)debug_describe_resource));
}
*ptr = tex;
 }

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


Mesa (master): mesa: fix 'make check' by moving bindless functions at the right place

2017-06-14 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 1c00af4264d795bf1fb3d13b7a966722a5984c4a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c00af4264d795bf1fb3d13b7a966722a5984c4a

Author: Samuel Pitoiset 
Date:   Wed Jun 14 18:08:09 2017 +0200

mesa: fix 'make check' by moving bindless functions at the right place

Fixes: 5f249b9f05e ("mapi: add GL_ARB_bindless_texture entry points")
Reported-by: Mark Janes 
Signed-off-by: Samuel Pitoiset 
Reviewed-by: Ian Romanick 
Tested-by: Aaron Watry 
Tested-by: Michel Dänzer 

---

 src/mesa/main/tests/dispatch_sanity.cpp | 36 -
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 47d0aa63bf..724c22ee9b 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -965,6 +965,24 @@ const struct function common_desktop_functions_possible[] 
= {
{ "glBufferPageCommitmentARB", 43, -1 },
{ "glNamedBufferPageCommitmentARB", 43, -1 },
 
+   /* GL_ARB_bindless_texture */
+   { "glGetTextureHandleARB", 40, -1 },
+   { "glGetTextureSamplerHandleARB", 40, -1 },
+   { "glMakeTextureHandleResidentARB", 40, -1 },
+   { "glMakeTextureHandleNonResidentARB", 40, -1 },
+   { "glIsTextureHandleResidentARB", 40, -1 },
+   { "glGetImageHandleARB", 40, -1 },
+   { "glMakeImageHandleResidentARB", 40, -1 },
+   { "glMakeImageHandleNonResidentARB", 40, -1 },
+   { "glIsImageHandleResidentARB", 40, -1 },
+   { "glUniformHandleui64ARB", 40, -1 },
+   { "glUniformHandleui64vARB", 40, -1 },
+   { "glProgramUniformHandleui64ARB", 40, -1 },
+   { "glProgramUniformHandleui64vARB", 40, -1 },
+   { "glVertexAttribL1ui64ARB", 40, -1 },
+   { "glVertexAttribL1ui64vARB", 40, -1 },
+   { "glGetVertexAttribLui64vARB", 40, -1 },
+
{ NULL, 0, -1 }
 };
 
@@ -2374,24 +2392,6 @@ const struct function gles2_functions_possible[] = {
/* GL_KHR_blend_equation_advanced */
{ "glBlendBarrierKHR", 20, -1 },
 
-   /* GL_ARB_bindless_texture */
-   { "glGetTextureHandleARB", 40, -1 },
-   { "glGetTextureSamplerHandleARB", 40, -1 },
-   { "glMakeTextureHandleResidentARB", 40, -1 },
-   { "glMakeTextureHandleNonResidentARB", 40, -1 },
-   { "glIsTextureHandleResidentARB", 40, -1 },
-   { "glGetImageHandleARB", 40, -1 },
-   { "glMakeImageHandleResidentARB", 40, -1 },
-   { "glMakeImageHandleNonResidentARB", 40, -1 },
-   { "glIsImageHandleResidentARB", 40, -1 },
-   { "glUniformHandleui64ARB", 40, -1 },
-   { "glUniformHandleui64vARB", 40, -1 },
-   { "glProgramUniformHandleui64ARB", 40, -1 },
-   { "glProgramUniformHandleui64vARB", 40, -1 },
-   { "glVertexAttribL1ui64ARB", 40, -1 },
-   { "glVertexAttribL1ui64vARB", 40, -1 },
-   { "glGetVertexAttribLui64vARB", 40, -1 },
-
{ NULL, 0, -1 }
 };
 

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


Mesa (master): st_glsl_to_tgsi: init index to 0 before get_deref_offsets()

2017-06-13 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 6d8a387f78cdeedc8c404a1b4c116a19023f2e19
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d8a387f78cdeedc8c404a1b4c116a19023f2e19

Author: Samuel Pitoiset 
Date:   Tue Jun 13 10:03:52 2017 +0200

st_glsl_to_tgsi: init index to 0 before get_deref_offsets()

Fixes: 8ec4975cd83 ("st_glsl_to_tgsi: don't try and pass 32-bit values to 
get_deref_offsets")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101401
Signed-off-by: Samuel Pitoiset 
Reviewed-and-Tested-by: Michel Dänzer 

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 798831613f..66f0814ddc 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3776,7 +3776,7 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
 
st_src_reg reladdr;
st_src_reg image(PROGRAM_IMAGE, 0, GLSL_TYPE_UINT);
-   uint16_t index;
+   uint16_t index = 0;
get_deref_offsets(img, &sampler_array_size, &sampler_base,
  &index, &reladdr, true);
 
@@ -4392,7 +4392,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
 
st_src_reg sampler(PROGRAM_SAMPLER, 0, GLSL_TYPE_UINT);
 
-   uint16_t index;
+   uint16_t index = 0;
get_deref_offsets(ir->sampler, &sampler_array_size, &sampler_base,
  &index, &reladdr, true);
 

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


Mesa (master): gallivm: Fix build against LLVM SVN >= r302589

2017-05-10 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 0c67aa84568d4676017d0d309e5ba8832d3b9e1e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c67aa84568d4676017d0d309e5ba8832d3b9e1e

Author: Michel Dänzer 
Date:   Wed May 10 17:26:07 2017 +0900

gallivm: Fix build against LLVM SVN >= r302589

deregisterEHFrames doesn't take any parameters anymore.

Reviewed-by: Vedran Miletić 
Reviewed-by: Marek Olšák 

---

 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp 
b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index 2a388cbfaf..0e4a531089 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -342,14 +342,20 @@ class DelegatingJITMemoryManager : public 
BaseMemoryManager {
   virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t 
Size) {
  mgr()->registerEHFrames(Addr, LoadAddr, Size);
   }
-  virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t 
Size) {
- mgr()->deregisterEHFrames(Addr, LoadAddr, Size);
-  }
 #else
   virtual void registerEHFrames(llvm::StringRef SectionData) {
  mgr()->registerEHFrames(SectionData);
   }
 #endif
+#if HAVE_LLVM >= 0x0500
+  virtual void deregisterEHFrames() {
+ mgr()->deregisterEHFrames();
+  }
+#elif HAVE_LLVM >= 0x0304
+  virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t 
Size) {
+ mgr()->deregisterEHFrames(Addr, LoadAddr, Size);
+  }
+#endif
   virtual void *getPointerToNamedFunction(const std::string &Name,
   bool AbortOnFailure=true) {
  return mgr()->getPointerToNamedFunction(Name, AbortOnFailure);

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


Mesa (master): clover: Fix build against clang SVN >= r299965

2017-04-12 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: a981e68c26dc4079a335101da0033185030207f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a981e68c26dc4079a335101da0033185030207f6

Author: Michel Dänzer 
Date:   Wed Apr 12 17:17:34 2017 +0900

clover: Fix build against clang SVN >= r299965

clang::LangAS::Offset is gone, the behaviour is as if it was 0.

v2: Introduce and use clover::llvm::compat::lang_as_offset (Francisco
Jerez)

Reviewed-by: Francisco Jerez 

---

 src/gallium/state_trackers/clover/llvm/codegen/common.cpp | 2 +-
 src/gallium/state_trackers/clover/llvm/compat.hpp | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp 
b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
index 13ccd591c1..3b0014d879 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
@@ -129,7 +129,7 @@ namespace {
   cast<::llvm::PointerType>(actual_type)->getAddressSpace();
 
if (address_space == address_spaces[clang::LangAS::opencl_local
-   - clang::LangAS::Offset]) {
+   - compat::lang_as_offset]) {
   args.emplace_back(module::argument::local, arg_api_size,
 target_size, target_align,
 module::argument::zero_ext);
diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
b/src/gallium/state_trackers/clover/llvm/compat.hpp
index 906367b314..67d2d0fd54 100644
--- a/src/gallium/state_trackers/clover/llvm/compat.hpp
+++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
@@ -67,6 +67,12 @@ namespace clover {
  typedef ::llvm::TargetLibraryInfo target_library_info;
 #endif
 
+#if HAVE_LLVM >= 0x0500
+ const auto lang_as_offset = 0;
+#else
+ const auto lang_as_offset = clang::LangAS::Offset;
+#endif
+
  inline void
  set_lang_defaults(clang::CompilerInvocation &inv,
clang::LangOptions &lopts, clang::InputKind ik,

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


Mesa (master): gallium/radeon: Add libamd_common.a to TARGET_LIB_DEPS also for r600

2017-02-27 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 936f5407a7da0449926a4f89abd222503ba43eb4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=936f5407a7da0449926a4f89abd222503ba43eb4

Author: Michel Dänzer 
Date:   Tue Feb 28 15:21:39 2017 +0900

gallium/radeon: Add libamd_common.a to TARGET_LIB_DEPS also for r600

Fixes build failure with --enable-opencl --enable-xvmc:

make[4]: Entering directory 
'/home/daenzer/src/mesa-git/mesa/build-amd64/src/gallium/targets/xvmc'
  CXXLDlibXvMCgallium.la
../../../../src/gallium/drivers/r600/.libs/libr600.a(evergreen_compute.o): In 
function `evergreen_create_compute_state':
/home/daenzer/src/mesa-git/mesa/build-amd64/src/gallium/drivers/r600/../../../../../src/gallium/drivers/r600/evergreen_compute.c:254:
 undefined reference to `ac_elf_read'
../../../../src/gallium/drivers/r600/.libs/libr600.a(evergreen_compute.o): In 
function `r600_shader_binary_read_config':
/home/daenzer/src/mesa-git/mesa/build-amd64/src/gallium/drivers/r600/../../../../../src/gallium/drivers/r600/evergreen_compute.c:189:
 undefined reference to `ac_shader_binary_config_start'
/home/daenzer/src/mesa-git/mesa/build-amd64/src/gallium/drivers/r600/../../../../../src/gallium/drivers/r600/evergreen_compute.c:189:
 undefined reference to `ac_shader_binary_config_start'
collect2: error: ld returned 1 exit status
Makefile:760: recipe for target 'libXvMCgallium.la' failed

Fixes: dc4c551a345d ("radeon/ac: switch from radeon_elf_read() to 
ac_elf_read()")
Acked-by: Timothy Arceri 
Tested-by: Timothy Arceri 

---

 src/gallium/drivers/r600/Automake.inc | 5 +
 src/gallium/drivers/radeonsi/Automake.inc | 1 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/Automake.inc 
b/src/gallium/drivers/r600/Automake.inc
index 914eea3..5995433 100644
--- a/src/gallium/drivers/r600/Automake.inc
+++ b/src/gallium/drivers/r600/Automake.inc
@@ -14,3 +14,8 @@ TARGET_RADEON_COMMON = \
$(top_builddir)/src/gallium/drivers/radeon/libradeon.la
 
 endif
+
+if NEED_RADEON_LLVM
+TARGET_LIB_DEPS += \
+$(top_builddir)/src/amd/common/libamd_common.la
+endif
diff --git a/src/gallium/drivers/radeonsi/Automake.inc 
b/src/gallium/drivers/radeonsi/Automake.inc
index de52835..5a9dcfd 100644
--- a/src/gallium/drivers/radeonsi/Automake.inc
+++ b/src/gallium/drivers/radeonsi/Automake.inc
@@ -4,7 +4,6 @@ TARGET_DRIVERS += radeonsi
 TARGET_CPPFLAGS += -DGALLIUM_RADEONSI
 TARGET_LIB_DEPS += \
$(top_builddir)/src/gallium/drivers/radeonsi/libradeonsi.la \
-   $(top_builddir)/src/amd/common/libamd_common.la \
$(RADEON_LIBS) \
$(LIBDRM_LIBS) \
$(AMDGPU_LIBS)

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


Mesa (master): configure.ac: Drop LLVM compiler flags more radically

2017-02-12 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 0f53404565b9ef9da9d7022b5732463acd496742
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f53404565b9ef9da9d7022b5732463acd496742

Author: Michel Dänzer 
Date:   Thu Feb  9 13:00:03 2017 +0900

configure.ac: Drop LLVM compiler flags more radically

Drop all -m*, -W*, -O*, -g* and -f* flags, with the exception of
-fno-rtti, which must be used if it's part of the llvm-config --cxxflags
output. We don't want LLVM to dictate the flags we use, and it can even
cause build failures, e.g. if LLVM and Mesa are built with different
compilers.

While we're at it, eat any whitespace preceding dropped flags as well.

Reviewed-by: Marek Olšák 
Reviewed-by: Emil Velikov 

---

 configure.ac | 33 -
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/configure.ac b/configure.ac
index 121457b..b4ea40f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -901,27 +901,18 @@ llvm_add_target() {
 # $1 is the llvm-config command with arguments.
 strip_unwanted_llvm_flags() {
 # Use \> (marks the end of the word)
-echo `$1` | sed \
--e 's/-march=\S*//g' \
--e 's/-mtune=\S*//g' \
--e 's/-mcpu=\S*//g' \
--e 's/-DNDEBUG\>//g' \
--e 's/-D_GNU_SOURCE\>//g' \
--e 's/-pedantic\>//g' \
--e 's/-Wcovered-switch-default\>//g' \
--e 's/-O.\>//g' \
--e 's/-g\>//g' \
--e 's/-Wall\>//g' \
--e 's/-Wcast-qual\>//g' \
--e 's/-Woverloaded-virtual\>//g' \
--e 's/-fcolor-diagnostics\>//g' \
--e 's/-fdata-sections\>//g' \
--e 's/-ffunction-sections\>//g' \
--e 's/-fno-exceptions\>//g' \
--e 's/-fomit-frame-pointer\>//g' \
--e 's/-fvisibility-inlines-hidden\>//g' \
--e 's/-fPIC\>//g' \
--e 's/-fstack-protector-strong\>//g'
+echo " `$1`" | sed \
+-e 's/\s\+-m\S*//g' \
+-e 's/\s\+-DNDEBUG\>//g' \
+-e 's/\s\+-D_GNU_SOURCE\>//g' \
+-e 's/\s\+-pedantic\>//g' \
+-e 's/\s\+-W\S*//g' \
+-e 's/\s\+-O\S*//g' \
+-e 's/\s\+-g\S*//g' \
+-e 's/-fno-rtti\>/-Fno-rtti/g' \
+-e 's/\s\+-f\S*//g' \
+-e 's/-Fno-rtti\>/-fno-rtti/g' \
+-e 's/^ //'
 }
 
 llvm_set_environment_variables() {

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


Mesa (master): winsys/radeon: Allow visible VRAM size > 256MB with kernel driver >= 2.49

2017-01-31 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 31136eae3ae03615a244496d4f82be50e82d803c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=31136eae3ae03615a244496d4f82be50e82d803c

Author: Michel Dänzer 
Date:   Tue Jan 31 15:33:19 2017 +0900

winsys/radeon: Allow visible VRAM size > 256MB with kernel driver >= 2.49

The kernel driver reports correct values now.

Reviewed-by: Christian König 
Reviewed-by: Samuel Pitoiset 
Reviewed-by: Nicolai Hähnle 
Reviewed-by: Alex Deucher 

---

 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index a8da62f..cacd683 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -372,7 +372,12 @@ static bool do_winsys_init(struct radeon_drm_winsys *ws)
 }
 ws->info.gart_size = gem_info.gart_size;
 ws->info.vram_size = gem_info.vram_size;
-ws->info.vram_vis_size = MIN2(gem_info.vram_visible, 256*1024*1024);
+ws->info.vram_vis_size = gem_info.vram_visible;
+/* Older versions of the kernel driver reported incorrect values, and
+ * didn't support more than 256MB of visible VRAM anyway
+ */
+if (ws->info.drm_minor < 49)
+ws->info.vram_vis_size = MIN2(ws->info.vram_vis_size, 256*1024*1024);
 
 /* Radeon allocates all buffers as contigous, which makes large allocations
  * unlikely to succeed. */

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


Mesa (master): clover: Fix build against clang SVN >= r293097

2017-01-26 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: d9f8bae616dd35f170949200d28105ce29e4b64c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d9f8bae616dd35f170949200d28105ce29e4b64c

Author: Michel Dänzer 
Date:   Thu Jan 26 15:28:12 2017 +0900

clover: Fix build against clang SVN >= r293097

Reviewed-by: Francisco Jerez 

---

 src/gallium/state_trackers/clover/llvm/compat.hpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp 
b/src/gallium/state_trackers/clover/llvm/compat.hpp
index 81592ce..906367b 100644
--- a/src/gallium/state_trackers/clover/llvm/compat.hpp
+++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
@@ -83,7 +83,14 @@ namespace clover {
  inline void
  add_link_bitcode_file(clang::CodeGenOptions &opts,
const std::string &path) {
-#if HAVE_LLVM >= 0x0308
+#if HAVE_LLVM >= 0x0500
+clang::CodeGenOptions::BitcodeFileToLink F;
+
+F.Filename = path;
+F.PropagateAttrs = true;
+F.LinkFlags = ::llvm::Linker::Flags::None;
+opts.LinkBitcodeFiles.emplace_back(F);
+#elif HAVE_LLVM >= 0x0308
 opts.LinkBitcodeFiles.emplace_back(::llvm::Linker::Flags::None, 
path);
 #else
 opts.LinkBitcodeFile = path;

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


Mesa (master): cso: Make sanitize_hash safe for samplers

2016-12-19 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 95eb5e4eed6ef80e44dc4b15f0b8560857dba263
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=95eb5e4eed6ef80e44dc4b15f0b8560857dba263

Author: Michel Dänzer 
Date:   Fri Dec 16 11:17:44 2016 +0900

cso: Make sanitize_hash safe for samplers

Remove currently bound sampler states from the hash table before pruning
entries from the hash table, so they cannot accidentally be deleted by
the pruning.

Reviewed-by: Nicolai Hähnle 

---

 src/gallium/auxiliary/cso_cache/cso_context.c | 44 ++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 6031cfc..469ab9c 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -220,19 +220,61 @@ sanitize_hash(struct cso_hash *hash, enum cso_cache_type 
type,
int hash_size = cso_hash_size(hash);
int max_entries = (max_size > hash_size) ? max_size : hash_size;
int to_remove =  (max_size < max_entries) * max_entries/4;
-   struct cso_hash_iter iter = cso_hash_first_node(hash);
+   struct cso_hash_iter iter;
+   struct cso_sampler **samplers_to_restore = NULL;
+   unsigned to_restore = 0;
+
if (hash_size > max_size)
   to_remove += hash_size - max_size;
+
+   if (to_remove == 0)
+  return;
+
+   if (type == CSO_SAMPLER) {
+  int i, j;
+
+  samplers_to_restore = MALLOC(PIPE_SHADER_TYPES * PIPE_MAX_SAMPLERS *
+   sizeof(*samplers_to_restore));
+
+  /* Temporarily remove currently bound sampler states from the hash
+   * table, to prevent them from being deleted
+   */
+  for (i = 0; i < PIPE_SHADER_TYPES; i++) {
+ for (j = 0; j < ctx->samplers[i].nr_samplers; j++) {
+struct cso_sampler *sampler = ctx->samplers[i].cso_samplers[j];
+
+if (sampler && cso_hash_take(hash, sampler->hash_key))
+   samplers_to_restore[to_restore++] = sampler;
+ }
+  }
+   }
+
+   iter = cso_hash_first_node(hash);
while (to_remove) {
   /*remove elements until we're good */
   /*fixme: currently we pick the nodes to remove at random*/
   void *cso = cso_hash_iter_data(iter);
+
+  if (!cso)
+ break;
+
   if (delete_cso(ctx, cso, type)) {
  iter = cso_hash_erase(hash, iter);
  --to_remove;
   } else
  iter = cso_hash_iter_next(iter);
}
+
+   if (type == CSO_SAMPLER) {
+  /* Put currently bound sampler states back into the hash table */
+  while (to_restore--) {
+ struct cso_sampler *sampler = samplers_to_restore[to_restore];
+
+ cso_hash_insert(hash, sampler->hash_key, sampler);
+  }
+
+  FREE(samplers_to_restore);
+   }
 }
 
 static void cso_init_vbuf(struct cso_context *cso)

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


Mesa (master): cso: Don' t restore nr_samplers in cso_restore_fragment_samplers

2016-12-19 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 3d661a12be5be95da929b19cf4b5976b3c3fb8e9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d661a12be5be95da929b19cf4b5976b3c3fb8e9

Author: Michel Dänzer 
Date:   Fri Dec 16 18:05:58 2016 +0900

cso: Don't restore nr_samplers in cso_restore_fragment_samplers

If info->nr_samplers > ctx->nr_fragment_samplers_saved, the assignment
would prevent cso_single_sampler_done from unbinding the no longer used
samplers from the driver, which could result in use-after-free. This is
probably unlikely to happen in practice though.

Cc: "12.0 13.0" 
Reviewed-by: Nicolai Hähnle 

---

 src/gallium/auxiliary/cso_cache/cso_context.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 127e071..2ee87f9 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -1275,7 +1275,6 @@ cso_restore_fragment_samplers(struct cso_context *ctx)
 {
struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
 
-   info->nr_samplers = ctx->nr_fragment_samplers_saved;
memcpy(info->samplers, ctx->fragment_samplers_saved,
   sizeof(info->samplers));
cso_single_sampler_done(ctx, PIPE_SHADER_FRAGMENT);

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


Mesa (master): Revert "cso: don't release sampler states that are bound"

2016-12-19 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 52098fada7e965479490045684b9897c623f5f76
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=52098fada7e965479490045684b9897c623f5f76

Author: Michel Dänzer 
Date:   Fri Dec 16 12:11:30 2016 +0900

Revert "cso: don't release sampler states that are bound"

This reverts commit 6dc96de303290e8d1fc294da478c4f370be98dea. No longer
necessary with the previous change.

Reviewed-by: Nicolai Hähnle 

---

 src/gallium/auxiliary/cso_cache/cso_cache.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c 
b/src/gallium/auxiliary/cso_cache/cso_cache.c
index 1f3be4b..b240c93 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.c
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.c
@@ -188,9 +188,7 @@ cso_insert_state(struct cso_cache *sc,
  void *state)
 {
struct cso_hash *hash = _cso_hash_for_type(sc, type);
-
-   if (type != CSO_SAMPLER)
-  sanitize_hash(sc, hash, type, sc->max_size);
+   sanitize_hash(sc, hash, type, sc->max_size);
 
return cso_hash_insert(hash, hash_key, state);
 }

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


Mesa (master): cso: Store hash key in struct cso_sampler

2016-12-19 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 745e2eaaec1f938184f3e9a2acfacf7e02ce0da8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=745e2eaaec1f938184f3e9a2acfacf7e02ce0da8

Author: Michel Dänzer 
Date:   Fri Dec 16 11:41:54 2016 +0900

cso: Store hash key in struct cso_sampler

Preparation for following changes, no functional change intended.

Reviewed-by: Nicolai Hähnle 

---

 src/gallium/auxiliary/cso_cache/cso_cache.h   | 1 +
 src/gallium/auxiliary/cso_cache/cso_context.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h 
b/src/gallium/auxiliary/cso_cache/cso_cache.h
index 052245f..ab1e4af 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.h
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.h
@@ -129,6 +129,7 @@ struct cso_sampler {
void *data;
cso_state_callback delete_state;
struct pipe_context *context;
+   unsigned hash_key;
 };
 
 struct cso_velems_state {
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 0f4a333..6031cfc 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -1182,6 +1182,7 @@ cso_single_sampler(struct cso_context *ctx, unsigned 
shader_stage,
  cso->delete_state =
 (cso_state_callback) ctx->pipe->delete_sampler_state;
  cso->context = ctx->pipe;
+ cso->hash_key = hash_key;
 
  iter = cso_insert_state(ctx->cache, hash_key, CSO_SAMPLER, cso);
  if (cso_hash_iter_is_null(iter)) {

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


Mesa (master): cso: Store pointers to struct cso_sampler in struct sampler_info

2016-12-19 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 5e70f80c9969c0adc095ba0a874ec87aad676729
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e70f80c9969c0adc095ba0a874ec87aad676729

Author: Michel Dänzer 
Date:   Fri Dec 16 11:13:26 2016 +0900

cso: Store pointers to struct cso_sampler in struct sampler_info

Preparation for following changes, no functional change intended.

Reviewed-by: Nicolai Hähnle 

---

 src/gallium/auxiliary/cso_cache/cso_context.c | 33 +++
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 2ee87f9..f52969d 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -55,6 +55,7 @@
  */
 struct sampler_info
 {
+   struct cso_sampler *cso_samplers[PIPE_MAX_SAMPLERS];
void *samplers[PIPE_MAX_SAMPLERS];
unsigned nr_samplers;
 };
@@ -79,9 +80,7 @@ struct cso_context {
struct pipe_sampler_view 
*fragment_views_saved[PIPE_MAX_SHADER_SAMPLER_VIEWS];
unsigned nr_fragment_views_saved;
 
-   void *fragment_samplers_saved[PIPE_MAX_SAMPLERS];
-   unsigned nr_fragment_samplers_saved;
-
+   struct sampler_info fragment_samplers_saved;
struct sampler_info samplers[PIPE_SHADER_TYPES];
 
struct pipe_vertex_buffer aux_vertex_buffer_current;
@@ -1164,18 +1163,17 @@ enum pipe_error
 cso_single_sampler(struct cso_context *ctx, unsigned shader_stage,
unsigned idx, const struct pipe_sampler_state *templ)
 {
-   void *handle = NULL;
-
if (templ) {
   unsigned key_size = sizeof(struct pipe_sampler_state);
   unsigned hash_key = cso_construct_key((void*)templ, key_size);
+  struct cso_sampler *cso;
   struct cso_hash_iter iter =
  cso_find_state_template(ctx->cache,
  hash_key, CSO_SAMPLER,
  (void *) templ, key_size);
 
   if (cso_hash_iter_is_null(iter)) {
- struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler));
+ cso = MALLOC(sizeof(struct cso_sampler));
  if (!cso)
 return PIPE_ERROR_OUT_OF_MEMORY;
 
@@ -1190,15 +1188,18 @@ cso_single_sampler(struct cso_context *ctx, unsigned 
shader_stage,
 FREE(cso);
 return PIPE_ERROR_OUT_OF_MEMORY;
  }
-
- handle = cso->data;
   }
   else {
- handle = ((struct cso_sampler *)cso_hash_iter_data(iter))->data;
+ cso = cso_hash_iter_data(iter);
   }
+
+  ctx->samplers[shader_stage].cso_samplers[idx] = cso;
+  ctx->samplers[shader_stage].samplers[idx] = cso->data;
+   } else {
+  ctx->samplers[shader_stage].cso_samplers[idx] = NULL;
+  ctx->samplers[shader_stage].samplers[idx] = NULL;
}
 
-   ctx->samplers[shader_stage].samplers[idx] = handle;
return PIPE_OK;
 }
 
@@ -1263,10 +1264,11 @@ static void
 cso_save_fragment_samplers(struct cso_context *ctx)
 {
struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
+   struct sampler_info *saved = &ctx->fragment_samplers_saved;
 
-   ctx->nr_fragment_samplers_saved = info->nr_samplers;
-   memcpy(ctx->fragment_samplers_saved, info->samplers,
-  sizeof(info->samplers));
+   saved->nr_samplers = info->nr_samplers;
+   memcpy(saved->cso_samplers, info->cso_samplers, sizeof(info->cso_samplers));
+   memcpy(saved->samplers, info->samplers, sizeof(info->samplers));
 }
 
 
@@ -1274,9 +1276,10 @@ static void
 cso_restore_fragment_samplers(struct cso_context *ctx)
 {
struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
+   struct sampler_info *saved = &ctx->fragment_samplers_saved;
 
-   memcpy(info->samplers, ctx->fragment_samplers_saved,
-  sizeof(info->samplers));
+   memcpy(info->cso_samplers, saved->cso_samplers, sizeof(info->cso_samplers));
+   memcpy(info->samplers, saved->samplers, sizeof(info->samplers));
cso_single_sampler_done(ctx, PIPE_SHADER_FRAGMENT);
 }
 

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


Mesa (master): cso: Optimize cso_save/restore_fragment_samplers

2016-12-19 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 9e142386472e599e70856634e4cbd247114af74a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e142386472e599e70856634e4cbd247114af74a

Author: Michel Dänzer 
Date:   Fri Dec 16 18:00:33 2016 +0900

cso: Optimize cso_save/restore_fragment_samplers

Only copy/memset the pointers that actually need to be.

v2:
* Cast info->nr_samplers to int for calculating delta (Nicolai)

Reviewed-by: Nicolai Hähnle 

---

 src/gallium/auxiliary/cso_cache/cso_context.c | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index f52969d..0f4a333 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -1267,8 +1267,10 @@ cso_save_fragment_samplers(struct cso_context *ctx)
struct sampler_info *saved = &ctx->fragment_samplers_saved;
 
saved->nr_samplers = info->nr_samplers;
-   memcpy(saved->cso_samplers, info->cso_samplers, sizeof(info->cso_samplers));
-   memcpy(saved->samplers, info->samplers, sizeof(info->samplers));
+   memcpy(saved->cso_samplers, info->cso_samplers, info->nr_samplers *
+  sizeof(*info->cso_samplers));
+   memcpy(saved->samplers, info->samplers, info->nr_samplers *
+  sizeof(*info->samplers));
 }
 
 
@@ -1277,9 +1279,20 @@ cso_restore_fragment_samplers(struct cso_context *ctx)
 {
struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
struct sampler_info *saved = &ctx->fragment_samplers_saved;
+   int delta = (int)info->nr_samplers - saved->nr_samplers;
+
+   memcpy(info->cso_samplers, saved->cso_samplers,
+  saved->nr_samplers * sizeof(*info->cso_samplers));
+   memcpy(info->samplers, saved->samplers,
+  saved->nr_samplers * sizeof(*info->samplers));
+
+   if (delta > 0) {
+  memset(&info->cso_samplers[saved->nr_samplers], 0,
+ delta * sizeof(*info->cso_samplers));
+  memset(&info->samplers[saved->nr_samplers], 0,
+ delta * sizeof(*info->samplers));
+   }
 
-   memcpy(info->cso_samplers, saved->cso_samplers, sizeof(info->cso_samplers));
-   memcpy(info->samplers, saved->samplers, sizeof(info->samplers));
cso_single_sampler_done(ctx, PIPE_SHADER_FRAGMENT);
 }
 

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


Mesa (master): radeonsi: Fix typo: "llvm.fs.interp" => "llvm.SI.fs.interp"

2016-12-07 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 26ba8c920d2727cae8ab45096db70e4691b00245
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=26ba8c920d2727cae8ab45096db70e4691b00245

Author: Michel Dänzer 
Date:   Thu Dec  8 10:51:03 2016 +0900

radeonsi: Fix typo: "llvm.fs.interp" => "llvm.SI.fs.interp"

Fixes lots of pixel shaders failing to compile with LLVM 3.9 or older.

Trivial.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99013#c4

---

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

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 2365349..9560baf 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1241,7 +1241,7 @@ static LLVMValueRef build_fs_interp(
args[1] = attr_number;
args[2] = params;
args[3] = lp_build_gather_values(gallivm, ij, 2);
-   return lp_build_intrinsic(gallivm->builder, "llvm.fs.interp",
+   return lp_build_intrinsic(gallivm->builder, "llvm.SI.fs.interp",
  ctx->f32, args, 4,
  LP_FUNC_ATTR_READNONE);
}

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


Mesa (master): vulkan/wsi/x11: Destroy Present event context when destroying swapchain

2016-11-29 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 550cd272b4b97fc06dbd3b5fad2bf0e5d526236d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=550cd272b4b97fc06dbd3b5fad2bf0e5d526236d

Author: Michel Dänzer 
Date:   Thu Jul 28 17:54:49 2016 +0900

vulkan/wsi/x11: Destroy Present event context when destroying swapchain

Without this, the X server may accumulate stale Present event contexts
if a client creates and destroys multiple swapchains using the same
window.

v2: Based on Chris Wilson's review:
* Use xcb_present_select_input_checked so that protocol errors
  generated by old X servers can be handled gracefully
* Use xcb_discard_reply() instead of free(xcb_request_check())
v3: Rebased on top of this code having been refactored out of anv

Reviewed-by: Dave Airlie 

---

 src/vulkan/wsi/wsi_common_x11.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 8e0043f..56398ce 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -891,6 +891,8 @@ x11_swapchain_destroy(struct wsi_swapchain *anv_chain,
   const VkAllocationCallbacks *pAllocator)
 {
struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
+   xcb_void_cookie_t cookie;
+
for (uint32_t i = 0; i < chain->image_count; i++)
   x11_image_finish(chain, pAllocator, &chain->images[i]);
 
@@ -904,6 +906,10 @@ x11_swapchain_destroy(struct wsi_swapchain *anv_chain,
}
 
xcb_unregister_for_special_event(chain->conn, chain->special_event);
+   cookie = xcb_present_select_input_checked(chain->conn, chain->event_id,
+ chain->window,
+ XCB_PRESENT_EVENT_MASK_NO_EVENT);
+   xcb_discard_reply(chain->conn, cookie.sequence);
 
vk_free(pAllocator, chain);
 

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


Mesa (master): gallium/radeon: Use flags parameter in radeon_winsys_surface_init

2016-11-04 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 356458363d1ee590fe05afb37ca502c2dd733666
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=356458363d1ee590fe05afb37ca502c2dd733666

Author: Michel Dänzer 
Date:   Wed Nov  2 19:48:35 2016 +0900

gallium/radeon: Use flags parameter in radeon_winsys_surface_init

Fixes valgrind warnings about surf_ws->flags being uninitialized while
starting X.

Reviewed-by: Nicolai Hähnle 

---

 src/gallium/winsys/radeon/drm/radeon_drm_surface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
index 7b85973..6836a1b 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
@@ -228,7 +228,7 @@ static int radeon_winsys_surface_init(struct radeon_winsys 
*rws,
 
 surf_winsys_to_drm(&surf_drm, tex, flags, bpe, mode, surf_ws);
 
-if (!(surf_ws->flags & RADEON_SURF_IMPORTED)) {
+if (!(flags & RADEON_SURF_IMPORTED)) {
r = radeon_surface_best(ws->surf_man, &surf_drm);
if (r)
   return r;

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


Mesa (master): gallium/radeon: Only loop up to last_level for drm<-> winsys conversion

2016-11-04 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 38fb9aa1aa8a25443196a6fdbe21d538ba91a347
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=38fb9aa1aa8a25443196a6fdbe21d538ba91a347

Author: Michel Dänzer 
Date:   Wed Nov  2 18:43:37 2016 +0900

gallium/radeon: Only loop up to last_level for drm<->winsys conversion

Fixes spurious assertion failure in surf_level_drm_to_winsys when
starting X, due to processing a miplevel which was never initialized.

Fixes: e9c76eeeaa67 ("gallium/radeon: remove radeon_surf_level::pitch_bytes")
Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/winsys/radeon/drm/radeon_drm_surface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
index c6fa475..e3eea59 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
@@ -157,7 +157,7 @@ static void surf_winsys_to_drm(struct radeon_surface 
*surf_drm,
 surf_drm->tile_split = surf_ws->tile_split;
 surf_drm->stencil_tile_split = surf_ws->stencil_tile_split;
 
-for (i = 0; i < RADEON_SURF_MAX_LEVELS; i++) {
+for (i = 0; i <= surf_drm->last_level; i++) {
 surf_level_winsys_to_drm(&surf_drm->level[i], &surf_ws->level[i], bpe);
 surf_level_winsys_to_drm(&surf_drm->stencil_level[i],
  &surf_ws->stencil_level[i], bpe);
@@ -192,7 +192,7 @@ static void surf_drm_to_winsys(struct radeon_drm_winsys *ws,
 
 surf_ws->macro_tile_index = cik_get_macro_tile_index(surf_ws);
 
-for (i = 0; i < RADEON_SURF_MAX_LEVELS; i++) {
+for (i = 0; i <= surf_drm->last_level; i++) {
 surf_level_drm_to_winsys(&surf_ws->level[i], &surf_drm->level[i],
  surf_drm->bpe * surf_drm->nsamples);
 surf_level_drm_to_winsys(&surf_ws->stencil_level[i],

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


Mesa (master): gallium/radeon: Only convert stencil info if RADEON_SURF_SBUFFER is set

2016-11-04 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 6f844a30c1616eac4955134ff130aad699a8079c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f844a30c1616eac4955134ff130aad699a8079c

Author: Michel Dänzer 
Date:   Wed Nov  2 19:09:06 2016 +0900

gallium/radeon: Only convert stencil info if RADEON_SURF_SBUFFER is set

Fixes valgrind warnings about using uninitialized memory when starting X.

Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/winsys/radeon/drm/radeon_drm_surface.c | 31 +++---
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
index e3eea59..7b85973 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
@@ -155,15 +155,20 @@ static void surf_winsys_to_drm(struct radeon_surface 
*surf_drm,
 surf_drm->bankh = surf_ws->bankh;
 surf_drm->mtilea = surf_ws->mtilea;
 surf_drm->tile_split = surf_ws->tile_split;
-surf_drm->stencil_tile_split = surf_ws->stencil_tile_split;
 
 for (i = 0; i <= surf_drm->last_level; i++) {
 surf_level_winsys_to_drm(&surf_drm->level[i], &surf_ws->level[i], bpe);
-surf_level_winsys_to_drm(&surf_drm->stencil_level[i],
- &surf_ws->stencil_level[i], bpe);
-
 surf_drm->tiling_index[i] = surf_ws->tiling_index[i];
-surf_drm->stencil_tiling_index[i] = surf_ws->stencil_tiling_index[i];
+}
+
+if (flags & RADEON_SURF_SBUFFER) {
+surf_drm->stencil_tile_split = surf_ws->stencil_tile_split;
+
+for (i = 0; i <= surf_drm->last_level; i++) {
+surf_level_winsys_to_drm(&surf_drm->stencil_level[i],
+ &surf_ws->stencil_level[i], bpe);
+surf_drm->stencil_tiling_index[i] = 
surf_ws->stencil_tiling_index[i];
+}
 }
 }
 
@@ -188,18 +193,24 @@ static void surf_drm_to_winsys(struct radeon_drm_winsys 
*ws,
 surf_ws->bankh = surf_drm->bankh;
 surf_ws->mtilea = surf_drm->mtilea;
 surf_ws->tile_split = surf_drm->tile_split;
-surf_ws->stencil_tile_split = surf_drm->stencil_tile_split;
 
 surf_ws->macro_tile_index = cik_get_macro_tile_index(surf_ws);
 
 for (i = 0; i <= surf_drm->last_level; i++) {
 surf_level_drm_to_winsys(&surf_ws->level[i], &surf_drm->level[i],
  surf_drm->bpe * surf_drm->nsamples);
-surf_level_drm_to_winsys(&surf_ws->stencil_level[i],
- &surf_drm->stencil_level[i], 
surf_drm->nsamples);
-
 surf_ws->tiling_index[i] = surf_drm->tiling_index[i];
-surf_ws->stencil_tiling_index[i] = surf_drm->stencil_tiling_index[i];
+}
+
+if (surf_ws->flags & RADEON_SURF_SBUFFER) {
+surf_ws->stencil_tile_split = surf_drm->stencil_tile_split;
+
+for (i = 0; i <= surf_drm->last_level; i++) {
+surf_level_drm_to_winsys(&surf_ws->stencil_level[i],
+ &surf_drm->stencil_level[i],
+ surf_drm->nsamples);
+surf_ws->stencil_tiling_index[i] = 
surf_drm->stencil_tiling_index[i];
+}
 }
 
 set_micro_tile_mode(surf_ws, &ws->info);

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


Mesa (master): gallium/radeon: Multiply bpe by nsamples in surf_winsys_to_drm

2016-11-04 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 8ce7ef75f5d164bfe9eae23749e83b6a88e2b270
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8ce7ef75f5d164bfe9eae23749e83b6a88e2b270

Author: Michel Dänzer 
Date:   Wed Nov  2 18:54:44 2016 +0900

gallium/radeon: Multiply bpe by nsamples in surf_winsys_to_drm

For symmetry with surf_drm_to_winsys.

Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/winsys/radeon/drm/radeon_drm_surface.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
index 6836a1b..8324d28 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
@@ -157,7 +157,9 @@ static void surf_winsys_to_drm(struct radeon_surface 
*surf_drm,
 surf_drm->tile_split = surf_ws->tile_split;
 
 for (i = 0; i <= surf_drm->last_level; i++) {
-surf_level_winsys_to_drm(&surf_drm->level[i], &surf_ws->level[i], bpe);
+surf_level_winsys_to_drm(&surf_drm->level[i], &surf_ws->level[i],
+ bpe * surf_drm->nsamples);
+
 surf_drm->tiling_index[i] = surf_ws->tiling_index[i];
 }
 
@@ -166,7 +168,8 @@ static void surf_winsys_to_drm(struct radeon_surface 
*surf_drm,
 
 for (i = 0; i <= surf_drm->last_level; i++) {
 surf_level_winsys_to_drm(&surf_drm->stencil_level[i],
- &surf_ws->stencil_level[i], bpe);
+ &surf_ws->stencil_level[i],
+ surf_drm->nsamples);
 surf_drm->stencil_tiling_index[i] = 
surf_ws->stencil_tiling_index[i];
 }
 }

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


Mesa (master): gallium/radeon: Initialize pipe_resource::next to NULL

2016-09-27 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 8d8c440ebf1a41dd235a67f3f1538cf47adec013
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d8c440ebf1a41dd235a67f3f1538cf47adec013

Author: Michel Dänzer 
Date:   Tue Sep 27 18:17:12 2016 +0900

gallium/radeon: Initialize pipe_resource::next to NULL

Fixes lots of piglit tests crashing due to using uninitialized memory.

Fixes: ecd6fce2611e ("mesa/st: support lowering multi-planar YUV")
Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeon/r600_buffer_common.c | 1 +
 src/gallium/drivers/radeon/r600_texture.c   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
b/src/gallium/drivers/radeon/r600_buffer_common.c
index 2e8b6f4..cbbcc29 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -511,6 +511,7 @@ r600_alloc_buffer_struct(struct pipe_screen *screen,
rbuffer = MALLOC_STRUCT(r600_resource);
 
rbuffer->b.b = *templ;
+   rbuffer->b.b.next = NULL;
pipe_reference_init(&rbuffer->b.b.reference, 1);
rbuffer->b.b.screen = screen;
rbuffer->b.vtbl = &r600_buffer_vtbl;
diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index b2ed93c..6ad5f85 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1040,6 +1040,7 @@ r600_texture_create_object(struct pipe_screen *screen,
 
resource = &rtex->resource;
resource->b.b = *base;
+   resource->b.b.next = NULL;
resource->b.vtbl = &r600_texture_vtbl;
pipe_reference_init(&resource->b.b.reference, 1);
resource->b.b.screen = screen;

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


Mesa (master): loader/dri3: Always use at least two back buffers

2016-09-06 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: dc3bb5db8c81e7f08ae12ea5d3ee999e2afcbfd1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dc3bb5db8c81e7f08ae12ea5d3ee999e2afcbfd1

Author: Michel Dänzer 
Date:   Tue Sep  6 11:34:49 2016 +0900

loader/dri3: Always use at least two back buffers

This can make a significant difference for performance with some extreme
test cases such as vblank_mode=0 glxgears.

Fixes: 1e3218bc5ba2 ("loader/dri3: Overhaul dri3_update_num_back")
Cc: "12.0 11.2" 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97549
Reviewed-by: Jason Ekstrand 
Tested-by: Dieter Nützel 

---

 src/loader/loader_dri3_helper.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 86ae5ae..3ce0352 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -70,10 +70,8 @@ dri3_update_num_back(struct loader_dri3_drawable *draw)
 {
if (draw->flipping)
   draw->num_back = 3;
-   else if (draw->vtable->get_swap_interval(draw) != 0)
-  draw->num_back = 2;
else
-  draw->num_back = 1;
+  draw->num_back = 2;
 }
 
 void

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


Mesa (master): loader/dri3: Overhaul dri3_update_num_back

2016-08-25 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 1e3218bc5ba2b739261f0c0bacf4eb662d377236
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e3218bc5ba2b739261f0c0bacf4eb662d377236

Author: Michel Dänzer 
Date:   Wed Aug 17 17:02:04 2016 +0900

loader/dri3: Overhaul dri3_update_num_back

Always use 3 buffers when flipping. With only 2 buffers, we have to wait
for a flip to complete (which takes non-0 time even with asynchronous
flips) before we can start working on the next frame. We were previously
only using 2 buffers for flipping if the X server supports asynchronous
flips, even when we're not using asynchronous flips. This could result
in bad performance (the referenced bug report is an extreme case, where
the inter-frame stalls were preventing the GPU from reaching its maximum
clocks).

I couldn't measure any performance boost using 4 buffers with flipping.
Performance actually seemed to go down slightly, but that might have
been just noise.

Without flipping, a single back buffer is enough for swap interval 0,
but we need to use 2 back buffers when the swap interval is non-0,
otherwise we have to wait for the swap interval to pass before we can
start working on the next frame. This condition was previously reversed.

Cc: "12.0 11.2" 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97260
Reviewed-by: Frank Binns 
Reviewed-by: Eric Anholt 

---

 src/loader/loader_dri3_helper.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index e9fb97b..86ae5ae 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -68,15 +68,12 @@ dri3_fence_await(xcb_connection_t *c, struct 
loader_dri3_buffer *buffer)
 static void
 dri3_update_num_back(struct loader_dri3_drawable *draw)
 {
-   draw->num_back = 1;
-   if (draw->flipping) {
-  if (!draw->is_pixmap &&
-  !(draw->present_capabilities & XCB_PRESENT_CAPABILITY_ASYNC))
- draw->num_back++;
-  draw->num_back++;
-   }
-   if (draw->vtable->get_swap_interval(draw) == 0)
-  draw->num_back++;
+   if (draw->flipping)
+  draw->num_back = 3;
+   else if (draw->vtable->get_swap_interval(draw) != 0)
+  draw->num_back = 2;
+   else
+  draw->num_back = 1;
 }
 
 void

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


Mesa (master): glx: Don't use current context in __glXSendError

2016-08-17 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 4ac640e3d207ab84ee4468c7017e5410b7a05d7a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ac640e3d207ab84ee4468c7017e5410b7a05d7a

Author: Michel Dänzer 
Date:   Tue Aug 16 15:35:44 2016 +0900

glx: Don't use current context in __glXSendError

There's no guarantee that there is one, and we don't need one anyway.

Fixes piglit tests:

glx@glx-fbconfig-bad
glx@glx_ext_import_context@import context, multi process
glx@glx_ext_import_context@import context, single process

Fixes: 2e3f067458e4 ("glx: fix error code when there is no context bound")
Cc: "11.2" 
Reviewed-by: Tapani Pälli 

---

 src/glx/glx_error.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/glx/glx_error.c b/src/glx/glx_error.c
index e098682..653cbeb 100644
--- a/src/glx/glx_error.c
+++ b/src/glx/glx_error.c
@@ -39,11 +39,9 @@ __glXSendError(Display * dpy, int_fast8_t errorCode, 
uint_fast32_t resourceID,
uint_fast16_t minorCode, bool coreX11error)
 {
struct glx_display *glx_dpy = __glXInitialize(dpy);
-   struct glx_context *gc = __glXGetCurrentContext();
xError error;
 
assert(glx_dpy);
-   assert(gc != &dummyContext);
 
LockDisplay(dpy);
 
@@ -59,7 +57,7 @@ __glXSendError(Display * dpy, int_fast8_t errorCode, 
uint_fast32_t resourceID,
error.sequenceNumber = dpy->request;
error.resourceID = resourceID;
error.minorCode = minorCode;
-   error.majorCode = gc ? gc->majorOpcode : 0;
+   error.majorCode = glx_dpy->majorOpcode;
 
_XError(dpy, &error);
 

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


Mesa (master): egl/dri2: dri2_make_current: Release previous context' s display

2016-08-16 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 78e3cea4197802253401766fc44362786898e024
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=78e3cea4197802253401766fc44362786898e024

Author: Nicolas Boichat 
Date:   Thu Aug 11 16:43:32 2016 +0800

egl/dri2: dri2_make_current: Release previous context's display

eglMakeCurrent can also be used to change the active display. In that
case, we need to decrement ref_count of the previous display (possibly
destroying it), and increment it on the next display.

Also, old_dsurf/old_rsurf cannot be non-NULL if old_ctx is NULL, so
we only need to test if old_ctx is non-NULL.

v2: Save the old display before destroying the context.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97214
Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" 
Reported-by: Alexandr Zelinsky 
Tested-by: Alexandr Zelinsky 
Reviewed-and-Tested-by: Michel Dänzer 
Signed-off-by: Nicolas Boichat 

---

 src/egl/drivers/dri2/egl_dri2.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 3205a36..3e3d1c8 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1280,13 +1280,14 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *dsurf,
  drv->API.DestroySurface(drv, disp, old_dsurf);
   if (old_rsurf)
  drv->API.DestroySurface(drv, disp, old_rsurf);
-  if (old_ctx)
- drv->API.DestroyContext(drv, disp, old_ctx);
 
   if (!unbind)
  dri2_dpy->ref_count++;
-  if (old_dsurf || old_rsurf || old_ctx)
- dri2_display_release(disp);
+  if (old_ctx) {
+ EGLDisplay old_disp = _eglGetDisplayHandle(old_ctx->Resource.Display);
+ drv->API.DestroyContext(drv, disp, old_ctx);
+ dri2_display_release(old_disp);
+  }
 
   return EGL_TRUE;
} else {

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


Mesa (master): loader/dri3: Destroy Present event context when destroying drawable v2

2016-08-04 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 5d191bafa26d2a88aa108823a2f3b9a321294fdc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5d191bafa26d2a88aa108823a2f3b9a321294fdc

Author: Michel Dänzer 
Date:   Thu Jul 28 17:44:49 2016 +0900

loader/dri3: Destroy Present event context when destroying drawable v2

Without this, the X server may accumulate stale Present event contexts
if a client ends up creating and destroying DRI drawables for the same
window.

v2: Based on Chris Wilson's review:
* Use xcb_present_select_input_checked so that protocol errors
  generated by old X servers can be handled gracefully
* Use xcb_discard_reply() instead of free(xcb_request_check())

---

 src/loader/loader_dri3_helper.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index 67d0c2c..e9fb97b 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -118,8 +118,14 @@ loader_dri3_drawable_fini(struct loader_dri3_drawable 
*draw)
  dri3_free_render_buffer(draw, draw->buffers[i]);
}
 
-   if (draw->special_event)
+   if (draw->special_event) {
+  xcb_void_cookie_t cookie =
+ xcb_present_select_input_checked(draw->conn, draw->eid, 
draw->drawable,
+  XCB_PRESENT_EVENT_MASK_NO_EVENT);
+
+  xcb_discard_reply(draw->conn, cookie.sequence);
   xcb_unregister_for_special_event(draw->conn, draw->special_event);
+   }
 }
 
 int

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


Mesa (master): vl/dri3: Destroy Present event context when destroying drawable v2

2016-08-04 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 67c5e843b9ae2c72bcf5c84f8744c1bd23fc262a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=67c5e843b9ae2c72bcf5c84f8744c1bd23fc262a

Author: Michel Dänzer 
Date:   Thu Jul 28 17:52:11 2016 +0900

vl/dri3: Destroy Present event context when destroying drawable v2

Without this, the X server may accumulate stale Present event contexts
if a client performs several video decoding sessions using the same
window.

v2: Based on Chris Wilson's review:
* Use xcb_discard_reply() instead of free(xcb_request_check())

Reviewed-and-Tested-by: Leo Liu 

---

 src/gallium/auxiliary/vl/vl_winsys_dri3.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 493e645..61d6205 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -66,6 +66,7 @@ struct vl_dri3_screen
 
uint32_t width, height, depth;
 
+   xcb_present_event_t eid;
xcb_special_event_t *special_event;
 
struct vl_dri3_buffer *back_buffers[BACK_BUFFER_NUM];
@@ -322,7 +323,6 @@ dri3_set_drawable(struct vl_dri3_screen *scrn, Drawable 
drawable)
xcb_get_geometry_reply_t *geom_reply;
xcb_void_cookie_t cookie;
xcb_generic_error_t *error;
-   xcb_present_event_t peid;
bool ret = true;
 
assert(drawable);
@@ -345,12 +345,16 @@ dri3_set_drawable(struct vl_dri3_screen *scrn, Drawable 
drawable)
if (scrn->special_event) {
   xcb_unregister_for_special_event(scrn->conn, scrn->special_event);
   scrn->special_event = NULL;
+  cookie = xcb_present_select_input_checked(scrn->conn, scrn->eid,
+scrn->drawable,
+
XCB_PRESENT_EVENT_MASK_NO_EVENT);
+  xcb_discard_reply(scrn->conn, cookie.sequence);
}
 
scrn->is_pixmap = false;
-   peid = xcb_generate_id(scrn->conn);
+   scrn->eid = xcb_generate_id(scrn->conn);
cookie =
-  xcb_present_select_input_checked(scrn->conn, peid, scrn->drawable,
+  xcb_present_select_input_checked(scrn->conn, scrn->eid, scrn->drawable,
   XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY |
   XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY |
   XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
@@ -369,7 +373,7 @@ dri3_set_drawable(struct vl_dri3_screen *scrn, Drawable 
drawable)
   free(error);
} else
   scrn->special_event =
- xcb_register_for_special_xge(scrn->conn, &xcb_present_id, peid, 0);
+ xcb_register_for_special_xge(scrn->conn, &xcb_present_id, scrn->eid, 
0);
 
dri3_flush_present_events(scrn);
 
@@ -609,8 +613,15 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen)
   }
}
 
-   if (scrn->special_event)
+   if (scrn->special_event) {
+  xcb_void_cookie_t cookie =
+ xcb_present_select_input_checked(scrn->conn, scrn->eid,
+  scrn->drawable,
+  XCB_PRESENT_EVENT_MASK_NO_EVENT);
+
+  xcb_discard_reply(scrn->conn, cookie.sequence);
   xcb_unregister_for_special_event(scrn->conn, scrn->special_event);
+   }
scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(&scrn->base.dev, 1);
FREE(scrn);

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


Mesa (master): configure: add support for LLVM 4.0.0svn static libs

2016-07-29 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: b107169eef92e740180df468d1eae4cc61a52757
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b107169eef92e740180df468d1eae4cc61a52757

Author: Jan Ziak <0xe2.0x9a.0...@gmail.com>
Date:   Wed Jul 27 13:36:16 2016 +0200

configure: add support for LLVM 4.0.0svn static libs

Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0...@gmail.com>
Reviewed-by: Eric Engestrom 
Reviewed-and-Tested-by: Michel Dänzer 

---

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f6b27ae..7d1a9bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2535,7 +2535,7 @@ if test "x$MESA_LLVM" != x0; then
 AC_MSG_WARN([Building mesa with statically linked LLVM may cause 
compilation issues])
 dnl We need to link to llvm system libs when using static libs
 dnl However, only llvm 3.5+ provides --system-libs
-if test $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 5; then
+if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a 
$LLVM_VERSION_MINOR -ge 5; then
 LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --system-libs`"
 fi
 fi

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


Mesa (master): clover: Fix build against clang SVN >= r273191

2016-06-20 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 82e0bbd01abfb2073519941d9893fa6ac05fb58c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=82e0bbd01abfb2073519941d9893fa6ac05fb58c

Author: Vedran Miletić 
Date:   Tue Jun 21 01:17:49 2016 +0200

clover: Fix build against clang SVN >= r273191

setLangDefaults() now requires PreprocessorOptions as an argument.

Reviewed-and-Tested-by: Michel Dänzer 

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index e2cadda..57e 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -207,7 +207,7 @@ namespace {
   c.getDiagnosticOpts().ShowCarets = false;
   c.getInvocation().setLangDefaults(c.getLangOpts(), clang::IK_OpenCL,
 #if HAVE_LLVM >= 0x0309
-llvm::Triple(triple),
+llvm::Triple(triple), 
c.getPreprocessorOpts(),
 #endif
 clang::LangStandard::lang_opencl11);
   c.createDiagnostics(

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


Mesa (master): st/dri: Clear drawable texture_mask in dri2_invalidate_drawable

2016-06-14 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 9ee3f097b65398250e836785a7e87520eda8298d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ee3f097b65398250e836785a7e87520eda8298d

Author: Michel Dänzer 
Date:   Thu Jun  9 15:15:19 2016 +0900

st/dri: Clear drawable texture_mask in dri2_invalidate_drawable

This makes sure that dri_set_tex_buffer2 -> dri_drawable_validate_att
will re-create the front left attachment buffer after the drawable got
invalidated.

Fixes window contents not updating until the window is resized when
using DRI2 PRIME.

Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/state_trackers/dri/dri2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index 28f8078..c22a8cd 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -167,6 +167,7 @@ dri2_invalidate_drawable(__DRIdrawable *dPriv)
 
dri2InvalidateDrawable(dPriv);
drawable->dPriv->lastStamp = drawable->dPriv->dri2.stamp;
+   drawable->texture_mask = 0;
 
p_atomic_inc(&drawable->base.stamp);
 }

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


Mesa (master): clover: Include generated sources in AM_CPPFLAGS

2016-06-13 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: fafe026dbe0680c971bf3ba2452954eea84287f2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fafe026dbe0680c971bf3ba2452954eea84287f2

Author: Aaron Watry 
Date:   Mon Jun 13 21:46:33 2016 -0500

clover: Include generated sources in AM_CPPFLAGS

git_sha1.c is generated in $(top_builddir)/src.

Fixes out-of-tree builds since 4825264f75c83576.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96516
Signed-off-by: Aaron Watry 
Reviewed-and-Tested-by: Michel Dänzer 

---

 src/gallium/state_trackers/clover/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/clover/Makefile.am 
b/src/gallium/state_trackers/clover/Makefile.am
index 4c9d7d9..d0b1914 100644
--- a/src/gallium/state_trackers/clover/Makefile.am
+++ b/src/gallium/state_trackers/clover/Makefile.am
@@ -7,6 +7,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/gallium/drivers \
-I$(top_srcdir)/src/gallium/auxiliary \
-I$(top_srcdir)/src/gallium/winsys \
+   -I$(top_builddir)/src \
-I$(srcdir)
 
 if HAVE_CLOVER_ICD

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


Mesa (master): clover: Fix build against clang SVN >= r267772

2016-04-28 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 860210ccfc0a90a4635fc930cd323bc426db5991
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=860210ccfc0a90a4635fc930cd323bc426db5991

Author: Michel Dänzer 
Date:   Thu Apr 28 12:57:03 2016 +0900

clover: Fix build against clang SVN >= r267772

(Re-pushing previous fix for clang SVN r265359, which was reverted in
the meantime)

Signed-off-by: Michel Dänzer 
Reviewed-by: Tom Stellard 

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index fb75788..96f6a48 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -206,6 +206,9 @@ namespace {
   // http://www.llvm.org/bugs/show_bug.cgi?id=19735
   c.getDiagnosticOpts().ShowCarets = false;
   c.getInvocation().setLangDefaults(c.getLangOpts(), clang::IK_OpenCL,
+#if HAVE_LLVM >= 0x0309
+llvm::Triple(triple),
+#endif
 clang::LangStandard::lang_opencl11);
   c.createDiagnostics(
   new clang::TextDiagnosticPrinter(

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


Mesa (master): st/dri: Fix RGB565 EGLImage creation

2016-04-20 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 8093990ef4a65c4ba69c79263a508df0ddbecae6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8093990ef4a65c4ba69c79263a508df0ddbecae6

Author: Nicolas Dufresne 
Date:   Sat Apr 16 20:49:44 2016 -0400

st/dri: Fix RGB565 EGLImage creation

When creating egl images we do a bytes to pixel conversion by deviding
by 4 regardless of the pixel format. This does not work for RGB565. In
this patch, we avoid useless conversion and use proper API when the
conversion cannot be avoided.

Signed-off-by: Nicolas Dufresne 
Reviewed-by: Michel Dänzer 

---

 src/gallium/state_trackers/dri/dri2.c | 44 +++
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index d46d131..468d056 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -736,7 +736,7 @@ dri2_lookup_egl_image(struct dri_screen *screen, void 
*handle)
 static __DRIimage *
 dri2_create_image_from_winsys(__DRIscreen *_screen,
   int width, int height, int format,
-  struct winsys_handle *whandle, int pitch,
+  struct winsys_handle *whandle,
   void *loaderPrivate)
 {
struct dri_screen *screen = dri_screen(_screen);
@@ -765,7 +765,6 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
templ.depth0 = 1;
templ.array_size = 1;
 
-   whandle->stride = pitch * util_format_get_blocksize(pf);
whandle->offset = 0;
 
img->texture = 
screen->base.screen->resource_from_handle(screen->base.screen,
@@ -790,19 +789,26 @@ dri2_create_image_from_name(__DRIscreen *_screen,
 int name, int pitch, void *loaderPrivate)
 {
struct winsys_handle whandle;
+   enum pipe_format pf;
 
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_SHARED;
whandle.handle = name;
 
+   pf = dri2_format_to_pipe_format (format);
+   if (pf == PIPE_FORMAT_NONE)
+  return NULL;
+
+   whandle.stride = pitch * util_format_get_blocksize(pf);
+
return dri2_create_image_from_winsys(_screen, width, height, format,
-&whandle, pitch, loaderPrivate);
+&whandle, loaderPrivate);
 }
 
 static __DRIimage *
 dri2_create_image_from_fd(__DRIscreen *_screen,
   int width, int height, int format,
-  int fd, int pitch, void *loaderPrivate)
+  int fd, int stride, void *loaderPrivate)
 {
struct winsys_handle whandle;
 
@@ -812,9 +818,10 @@ dri2_create_image_from_fd(__DRIscreen *_screen,
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_FD;
whandle.handle = (unsigned)fd;
+   whandle.stride = stride;
 
return dri2_create_image_from_winsys(_screen, width, height, format,
-&whandle, pitch, loaderPrivate);
+&whandle, loaderPrivate);
 }
 
 static __DRIimage *
@@ -992,7 +999,8 @@ dri2_from_names(__DRIscreen *screen, int width, int height, 
int format,
 void *loaderPrivate)
 {
__DRIimage *img;
-   int stride, dri_components;
+   int dri_components;
+   struct winsys_handle whandle;
 
if (num_names != 1)
   return NULL;
@@ -1003,11 +1011,13 @@ dri2_from_names(__DRIscreen *screen, int width, int 
height, int format,
if (format == -1)
   return NULL;
 
-   /* Strides are in bytes not pixels. */
-   stride = strides[0] /4;
+   memset(&whandle, 0, sizeof(whandle));
+   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
+   whandle.handle = names[0];
+   whandle.stride = strides[0];
 
-   img = dri2_create_image_from_name(screen, width, height, format,
- names[0], stride, loaderPrivate);
+   img = dri2_create_image_from_winsys(screen, width, height, format,
+   &whandle, loaderPrivate);
if (img == NULL)
   return NULL;
 
@@ -1107,7 +1117,7 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, 
int fourcc,
   void *loaderPrivate)
 {
__DRIimage *img;
-   int format, stride, dri_components;
+   int format, dri_components;
 
if (num_fds != 1)
   return NULL;
@@ -1118,11 +1128,8 @@ dri2_from_fds(__DRIscreen *screen, int width, int 
height, int fourcc,
if (format == -1)
   return NULL;
 
-   /* Strides are in bytes not pixels. */
-   stride = strides[0] /4;
-
img = dri2_create_image_from_fd(screen, width, height, format,
-   fds[0], stride, loaderPrivate);
+   fds[0], strides[0], loaderPrivate);
if (img == NULL)
   return NULL;
 
@@ -1143,7 +1150,7 @@ dri2_from_dma_bufs(__DRIscreen *screen,
 

Mesa (master): st/dri: Factor out DRI2 to PIPE_FORMAT conversion

2016-04-20 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 4463f38766061bd058dc668e0ac2820a4cba79e7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4463f38766061bd058dc668e0ac2820a4cba79e7

Author: Nicolas Dufresne 
Date:   Sat Apr 16 20:49:43 2016 -0400

st/dri: Factor out DRI2 to PIPE_FORMAT conversion

This code is already duplicated twice and will be useful again. This
will also help when adding formats.

Signed-off-by: Nicolas Dufresne 
Reviewed-by: Michel Dänzer 

---

 src/gallium/state_trackers/dri/dri2.c | 61 ---
 1 file changed, 27 insertions(+), 34 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index fb0a180..d46d131 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -101,6 +101,31 @@ static int convert_to_fourcc(int format)
return format;
 }
 
+static enum pipe_format dri2_format_to_pipe_format (int format)
+{
+   enum pipe_format pf;
+
+   switch (format) {
+   case __DRI_IMAGE_FORMAT_RGB565:
+  pf = PIPE_FORMAT_B5G6R5_UNORM;
+  break;
+   case __DRI_IMAGE_FORMAT_XRGB:
+  pf = PIPE_FORMAT_BGRX_UNORM;
+  break;
+   case __DRI_IMAGE_FORMAT_ARGB:
+  pf = PIPE_FORMAT_BGRA_UNORM;
+  break;
+   case __DRI_IMAGE_FORMAT_ABGR:
+  pf = PIPE_FORMAT_RGBA_UNORM;
+  break;
+   default:
+  pf = PIPE_FORMAT_NONE;
+  break;
+   }
+
+   return pf;
+}
+
 /**
  * DRI2 flush extension.
  */
@@ -722,23 +747,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
 
tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
 
-   switch (format) {
-   case __DRI_IMAGE_FORMAT_RGB565:
-  pf = PIPE_FORMAT_B5G6R5_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_XRGB:
-  pf = PIPE_FORMAT_BGRX_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_ARGB:
-  pf = PIPE_FORMAT_BGRA_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_ABGR:
-  pf = PIPE_FORMAT_RGBA_UNORM;
-  break;
-   default:
-  pf = PIPE_FORMAT_NONE;
-  break;
-   }
+   pf = dri2_format_to_pipe_format (format);
if (pf == PIPE_FORMAT_NONE)
   return NULL;
 
@@ -845,23 +854,7 @@ dri2_create_image(__DRIscreen *_screen,
   tex_usage |= PIPE_BIND_CURSOR;
}
 
-   switch (format) {
-   case __DRI_IMAGE_FORMAT_RGB565:
-  pf = PIPE_FORMAT_B5G6R5_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_XRGB:
-  pf = PIPE_FORMAT_BGRX_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_ARGB:
-  pf = PIPE_FORMAT_BGRA_UNORM;
-  break;
-   case __DRI_IMAGE_FORMAT_ABGR:
-  pf = PIPE_FORMAT_RGBA_UNORM;
-  break;
-   default:
-  pf = PIPE_FORMAT_NONE;
-  break;
-   }
+   pf = dri2_format_to_pipe_format (format);
if (pf == PIPE_FORMAT_NONE)
   return NULL;
 

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


Mesa (master): clover: Fix build against LLVM SVN >= r266163

2016-04-13 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 171a570f388b2895d14f6d5418c99573cffd6369
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=171a570f388b2895d14f6d5418c99573cffd6369

Author: Michel Dänzer 
Date:   Wed Apr 13 15:57:50 2016 +0900

clover: Fix build against LLVM SVN >= r266163

createInternalizePass now takes a callback instead of a StringSet.

Reviewed-by: Francisco Jerez 

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 4d11c24..fb75788 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -322,6 +322,15 @@ namespace {
   // list of kernel functions to the internalizer.  The internalizer will
   // treat the functions in the list as "main" functions and internalize
   // all of the other functions.
+#if HAVE_LLVM >= 0x0309
+  auto preserve_kernels = [=](const llvm::GlobalValue &GV) {
+ for (const auto &kernel : kernels) {
+if (GV.getName() == kernel->getName())
+   return true;
+ }
+ return false;
+  };
+#else
   std::vector export_list;
   for (std::vector::const_iterator I = kernels.begin(),
  E = kernels.end();
@@ -329,12 +338,17 @@ namespace {
  llvm::Function *kernel = *I;
  export_list.push_back(kernel->getName().data());
   }
+#endif
 #if HAVE_LLVM < 0x0306
   PM.add(new llvm::DataLayoutPass(mod));
 #elif HAVE_LLVM < 0x0307
   PM.add(new llvm::DataLayoutPass());
 #endif
+#if HAVE_LLVM >= 0x0309
+  PM.add(llvm::createInternalizePass(preserve_kernels));
+#else
   PM.add(llvm::createInternalizePass(export_list));
+#endif
 
   llvm::PassManagerBuilder PMB;
   PMB.OptLevel = optimization_level;

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


Mesa (master): Revert "clover: Fix build against clang SVN >= r265359"

2016-04-07 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 715e97e3421ec33c219c9829e7930d135dfe0bf8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=715e97e3421ec33c219c9829e7930d135dfe0bf8

Author: Michel Dänzer 
Date:   Thu Apr  7 15:05:33 2016 +0900

Revert "clover: Fix build against clang SVN >= r265359"

This reverts commit 0daab9878d2b96356cf667591a2c877d912be52d.

The corresponding clang change was reverted.

Trivial.

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 3fb3596..4d11c24 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -206,9 +206,6 @@ namespace {
   // http://www.llvm.org/bugs/show_bug.cgi?id=19735
   c.getDiagnosticOpts().ShowCarets = false;
   c.getInvocation().setLangDefaults(c.getLangOpts(), clang::IK_OpenCL,
-#if HAVE_LLVM >= 0x0309
-llvm::Triple(triple),
-#endif
 clang::LangStandard::lang_opencl11);
   c.createDiagnostics(
   new clang::TextDiagnosticPrinter(

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


Mesa (master): Handle removal of LLVMAddTargetData in SVN revision 260919

2016-02-15 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 0bba5ca468cdcd1f6f9bb6736c8a75e43fbe0cd5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0bba5ca468cdcd1f6f9bb6736c8a75e43fbe0cd5

Author: Matthew Dawson 
Date:   Tue Feb 16 01:25:20 2016 -0500

Handle removal of LLVMAddTargetData in SVN revision 260919

LLVM removed LLVMAddTargetData for the 3.9 release in r260919.  For the two
places in mesa where this is called, only enable the lines when compiling
for less then 3.9.

For the radeon driver, I'm not sure how to check if any other LLVM calls need
to be adjusted.  I think since the target data used is extracted from the
LLVMModule, it isn't necessary to pass it back to LLVM again.

The code does compile, and at least for radeonsi does run OpenGL games.

[ Michel Dänzer: Move #if closer to LLVMAddTargetData in lp_bld_init.c,
  and add HAVE_LLVM < 0x0309 guards around now unused occurrences of TD
  and data_layout ]

Signed-off-by: Matthew Dawson 
Reviewed-and-Tested-by: Michel Dänzer 

---

 src/gallium/auxiliary/gallivm/lp_bld_init.c   | 2 ++
 src/gallium/drivers/radeon/radeon_llvm_util.c | 6 ++
 2 files changed, 8 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c 
b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 96aba73..ab55be4 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -118,8 +118,10 @@ create_pass_manager(struct gallivm_state *gallivm)
 * simple, or constant propagation into them, etc.
 */
 
+#if HAVE_LLVM < 0x0309
// Old versions of LLVM get the DataLayout from the pass manager.
LLVMAddTargetData(gallivm->target, gallivm->passmgr);
+#endif
 
/* Setting the module's DataLayout to an empty string will cause the
 * ExecutionEngine to copy to the DataLayout string from its target
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c 
b/src/gallium/drivers/radeon/radeon_llvm_util.c
index 0dfd9ad..da19533 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.c
@@ -55,8 +55,10 @@ unsigned radeon_llvm_get_num_kernels(LLVMContextRef ctx,
 
 static void radeon_llvm_optimize(LLVMModuleRef mod)
 {
+#if HAVE_LLVM < 0x0309
const char *data_layout = LLVMGetDataLayout(mod);
LLVMTargetDataRef TD = LLVMCreateTargetData(data_layout);
+#endif
LLVMPassManagerBuilderRef builder = LLVMPassManagerBuilderCreate();
LLVMPassManagerRef pass_manager = LLVMCreatePassManager();
 
@@ -77,14 +79,18 @@ static void radeon_llvm_optimize(LLVMModuleRef mod)
}
}
 
+#if HAVE_LLVM < 0x0309
LLVMAddTargetData(TD, pass_manager);
+#endif
LLVMAddAlwaysInlinerPass(pass_manager);
LLVMPassManagerBuilderPopulateModulePassManager(builder, pass_manager);
 
LLVMRunPassManager(pass_manager, mod);
LLVMPassManagerBuilderDispose(builder);
LLVMDisposePassManager(pass_manager);
+#if HAVE_LLVM < 0x0309
LLVMDisposeTargetData(TD);
+#endif
 }
 
 LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef ctx, unsigned index,

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


Mesa (master): winsys/amdgpu: Process RADEON_FLAG_* independently from RADEON_DOMAIN_*

2016-01-28 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 30fcf241e13f82b3b9e3099632358b34cd35bff2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=30fcf241e13f82b3b9e3099632358b34cd35bff2

Author: Michel Dänzer 
Date:   Tue Jan 26 16:38:55 2016 +0900

winsys/amdgpu: Process RADEON_FLAG_* independently from RADEON_DOMAIN_*

In particular, AMDGPU_GEM_CREATE_CPU_GTT_USWC can affect even BOs created
in VRAM if they get evicted to GTT. In general there's no need to
restrict any of the flags to any particular domains.

Reviewed-by: Edward O'Callaghan 
Reviewed-by: Christian König 
Reviewed-by: Marek Olšák 
Reviewed-by: Alex Deucher 

---

 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 1e997d9..59a801b 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -288,18 +288,17 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct 
amdgpu_winsys *ws,
request.alloc_size = size;
request.phys_alignment = alignment;
 
-   if (initial_domain & RADEON_DOMAIN_VRAM) {
+   if (initial_domain & RADEON_DOMAIN_VRAM)
   request.preferred_heap |= AMDGPU_GEM_DOMAIN_VRAM;
-  if (flags & RADEON_FLAG_CPU_ACCESS)
- request.flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
-  if (flags & RADEON_FLAG_NO_CPU_ACCESS)
- request.flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
-   }
-   if (initial_domain & RADEON_DOMAIN_GTT) {
+   if (initial_domain & RADEON_DOMAIN_GTT)
   request.preferred_heap |= AMDGPU_GEM_DOMAIN_GTT;
-  if (flags & RADEON_FLAG_GTT_WC)
- request.flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
-   }
+
+   if (flags & RADEON_FLAG_CPU_ACCESS)
+  request.flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
+   if (flags & RADEON_FLAG_NO_CPU_ACCESS)
+  request.flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
+   if (flags & RADEON_FLAG_GTT_WC)
+  request.flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
 
r = amdgpu_bo_alloc(ws->dev, &request, &buf_handle);
if (r) {

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


Mesa (master): winsys/amdgpu: Handle RADEON_FLAG_NO_CPU_ACCESS

2016-01-28 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 62f837e2ea7b854215efb2e110b176dad61c2af0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=62f837e2ea7b854215efb2e110b176dad61c2af0

Author: Michel Dänzer 
Date:   Tue Jan 26 16:15:59 2016 +0900

winsys/amdgpu: Handle RADEON_FLAG_NO_CPU_ACCESS

Failing to do this was resulting in the kernel driver unnecessarily
leaving open the possibility of CPU access to tiled BOs.

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

(This change shouldn't be backported to stable branches, because
released versions of xf86-video-amdgpu unnecessarily try to map the
front buffer)

Reviewed-by: Edward O'Callaghan 
Reviewed-by: Christian König 
Reviewed-by: Marek Olšák 
Reviewed-by: Alex Deucher 

---

 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 30a1aa8..1e997d9 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -292,6 +292,8 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct 
amdgpu_winsys *ws,
   request.preferred_heap |= AMDGPU_GEM_DOMAIN_VRAM;
   if (flags & RADEON_FLAG_CPU_ACCESS)
  request.flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
+  if (flags & RADEON_FLAG_NO_CPU_ACCESS)
+ request.flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
}
if (initial_domain & RADEON_DOMAIN_GTT) {
   request.preferred_heap |= AMDGPU_GEM_DOMAIN_GTT;

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


Mesa (master): gallium/radeon: Rename do_invalidate_resource to invalidate_buffer

2016-01-18 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: ad20be1f30ef5d11bcacef38a921cb778c504dd2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ad20be1f30ef5d11bcacef38a921cb778c504dd2

Author: Michel Dänzer 
Date:   Fri Jan 15 16:02:22 2016 +0900

gallium/radeon: Rename do_invalidate_resource to invalidate_buffer

And only call it from r600_invalidate_resource for buffer resources.

Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeon/r600_buffer_common.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
b/src/gallium/drivers/radeon/r600_buffer_common.c
index 6592c5b..c7984c4 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -210,8 +210,8 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
 }
 
 static bool
-r600_do_invalidate_resource(struct r600_common_context *rctx,
-   struct r600_resource *rbuffer)
+r600_invalidate_buffer(struct r600_common_context *rctx,
+  struct r600_resource *rbuffer)
 {
/* In AMD_pinned_memory, the user pointer association only gets
 * broken when the buffer is explicitly re-allocated.
@@ -236,7 +236,9 @@ void r600_invalidate_resource(struct pipe_context *ctx,
struct r600_common_context *rctx = (struct r600_common_context*)ctx;
struct r600_resource *rbuffer = r600_resource(resource);
 
-   (void)r600_do_invalidate_resource(rctx, rbuffer);
+   /* We currently only do anyting here for buffers */
+   if (resource->target == PIPE_BUFFER)
+   (void)r600_invalidate_buffer(rctx, rbuffer);
 }
 
 static void *r600_buffer_get_transfer(struct pipe_context *ctx,
@@ -306,7 +308,7 @@ static void *r600_buffer_transfer_map(struct pipe_context 
*ctx,
!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
assert(usage & PIPE_TRANSFER_WRITE);
 
-   if (r600_do_invalidate_resource(rctx, rbuffer)) {
+   if (r600_invalidate_buffer(rctx, rbuffer)) {
/* At this point, the buffer is always idle. */
usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
}

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


Mesa (master): st/dri: Don't call invalidate_resource for NULL depth/ stencil buffers

2016-01-18 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 0491dd1deb46ca77545322c53e90f86ae244cdae
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0491dd1deb46ca77545322c53e90f86ae244cdae

Author: Michel Dänzer 
Date:   Fri Jan 15 15:46:31 2016 +0900

st/dri: Don't call invalidate_resource for NULL depth/stencil buffers

Fixes crash in 4 EGL piglit tests with radeonsi.

Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/state_trackers/dri/dri_drawable.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri_drawable.c 
b/src/gallium/state_trackers/dri/dri_drawable.c
index f0cc4a2..adc5128 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -492,8 +492,10 @@ dri_flush(__DRIcontext *cPriv,
 
   if (pipe->invalidate_resource &&
   (flags & __DRI2_FLUSH_INVALIDATE_ANCILLARY)) {
- pipe->invalidate_resource(pipe, 
drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
- pipe->invalidate_resource(pipe, 
drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL]);
+ if (drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
+pipe->invalidate_resource(pipe, 
drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
+ if (drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL])
+pipe->invalidate_resource(pipe, 
drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL]);
   }
}
 

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


Mesa (master): radeonsi: Avoid warning about LLVM generating R_0286D0_SPI_PS_INPUT_ADDR

2016-01-18 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: a9ab7172a621294f5d7b5dfac3363bed240e20a0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9ab7172a621294f5d7b5dfac3363bed240e20a0

Author: Michel Dänzer 
Date:   Fri Jan 15 12:18:29 2016 +0900

radeonsi: Avoid warning about LLVM generating R_0286D0_SPI_PS_INPUT_ADDR

Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 
Reviewed-by: Alex Deucher 

---

 src/gallium/drivers/radeonsi/si_shader.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 3ab054c..2de7def 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3728,6 +3728,9 @@ void si_shader_binary_read_config(struct 
radeon_shader_binary *binary,
case R_0286CC_SPI_PS_INPUT_ENA:
conf->spi_ps_input_ena = value;
break;
+   case R_0286D0_SPI_PS_INPUT_ADDR:
+   /* Not used yet, but will be in the future */
+   break;
case R_0286E8_SPI_TMPRING_SIZE:
case R_00B860_COMPUTE_TMPRING_SIZE:
/* WAVESIZE is in units of 256 dwords. */

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


Mesa (master): radeonsi: Print "LLVM emitted unknown config register" warning only once

2016-01-18 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 4297259fc87b513f307ba9af3289b98b54f2cbb1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4297259fc87b513f307ba9af3289b98b54f2cbb1

Author: Michel Dänzer 
Date:   Fri Jan 15 12:13:15 2016 +0900

radeonsi: Print "LLVM emitted unknown config register" warning only once

Say "LLVM" instead of "Compiler" for clarity.

Reviewed-by: Nicolai Hähnle 
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_shader.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index cc9718e..3ab054c 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3735,8 +3735,15 @@ void si_shader_binary_read_config(struct 
radeon_shader_binary *binary,
G_00B860_WAVESIZE(value) * 256 * 4 * 1;
break;
default:
-   fprintf(stderr, "Warning: Compiler emitted unknown "
-   "config register: 0x%x\n", reg);
+   {
+   static bool printed;
+
+   if (!printed) {
+   fprintf(stderr, "Warning: LLVM emitted 
unknown "
+   "config register: 0x%x\n", reg);
+   printed = true;
+   }
+   }
break;
}
}

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


Mesa (master): clover: Fix build against LLVM 3.8 SVN >= r255078

2015-12-09 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: b4a03e7f8f4006eb2c5b09a0611fdda153dd8437
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4a03e7f8f4006eb2c5b09a0611fdda153dd8437

Author: Michel Dänzer 
Date:   Wed Dec  9 15:46:46 2015 +0900

clover: Fix build against LLVM 3.8 SVN >= r255078

Reviewed-by: Francisco Jerez 

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp |4 
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 3b37f08..4d11c24 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -661,7 +661,11 @@ namespace {
 
   if (dump_asm) {
  LLVMSetTargetMachineAsmVerbosity(tm, true);
+#if HAVE_LLVM >= 0x0308
+ LLVMModuleRef debug_mod = wrap(llvm::CloneModule(mod).release());
+#else
  LLVMModuleRef debug_mod = wrap(llvm::CloneModule(mod));
+#endif
  emit_code(tm, debug_mod, LLVMAssemblyFile, &out_buffer, r_log);
  buffer_size = LLVMGetBufferSize(out_buffer);
  buffer_data = LLVMGetBufferStart(out_buffer);

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


Mesa (master): targets/xvmc: use the non-inline sw helpers

2015-11-25 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 22d2dda03be32d23bc8e9f5823a4f2469737ddbe
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=22d2dda03be32d23bc8e9f5823a4f2469737ddbe

Author: Michel Dänzer 
Date:   Thu Nov 26 12:14:28 2015 +0900

targets/xvmc: use the non-inline sw helpers

This was missed in commit 59cfb21d ("targets: use the non-inline sw
helpers").

Fixes build failure:

  CXXLDlibXvMCgallium.la
../../../../src/gallium/auxiliary/pipe-loader/.libs/libpipe_loader_static.a(libpipe_loader_static_la-pipe_loader_sw.o):(.data.rel.ro+0x0):
 undefined reference to `sw_screen_create'
collect2: error: ld returned 1 exit status
Makefile:756: recipe for target 'libXvMCgallium.la' failed
make[3]: *** [libXvMCgallium.la] Error 1

Trivial.

---

 src/gallium/targets/xvmc/target.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/targets/xvmc/target.c 
b/src/gallium/targets/xvmc/target.c
index 42b1346..308e23b 100644
--- a/src/gallium/targets/xvmc/target.c
+++ b/src/gallium/targets/xvmc/target.c
@@ -1 +1,2 @@
 #include "target-helpers/drm_helper.h"
+#include "target-helpers/sw_helper.h"

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


Mesa (master): radeon/llvm: Use llvm.AMDIL.exp intrinsic again for now

2015-11-24 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: d09463193608009fa42e046b1fc144435d3533f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d09463193608009fa42e046b1fc144435d3533f6

Author: Michel Dänzer 
Date:   Thu Nov 19 11:30:21 2015 +0900

radeon/llvm: Use llvm.AMDIL.exp intrinsic again for now

llvm.exp2.f32 doesn't work in some cases yet.

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

Reviewed-by: Nicolai Hähnle 

---

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

diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index ac99e73..c94f109 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -1539,7 +1539,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context 
* ctx)
bld_base->op_actions[TGSI_OPCODE_ENDIF].emit = endif_emit;
bld_base->op_actions[TGSI_OPCODE_ENDLOOP].emit = endloop_emit;
bld_base->op_actions[TGSI_OPCODE_EX2].emit = build_tgsi_intrinsic_nomem;
-   bld_base->op_actions[TGSI_OPCODE_EX2].intr_name = "llvm.exp2.f32";
+   bld_base->op_actions[TGSI_OPCODE_EX2].intr_name = "llvm.AMDIL.exp.";
bld_base->op_actions[TGSI_OPCODE_FLR].emit = build_tgsi_intrinsic_nomem;
bld_base->op_actions[TGSI_OPCODE_FLR].intr_name = "llvm.floor.f32";
bld_base->op_actions[TGSI_OPCODE_FMA].emit = build_tgsi_intrinsic_nomem;

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


Mesa (master): Plus 6b21d3c92e5878284c008edb68a0155edfcf89b4.

2015-11-24 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 2c07a5fe70676f6400e5915d3af23a598711dab0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c07a5fe70676f6400e5915d3af23a598711dab0

Author: Michel Dänzer 
Date:   Tue Nov 24 15:40:52 2015 +0900

Plus 6b21d3c92e5878284c008edb68a0155edfcf89b4.

---

 src/gallium/auxiliary/Makefile.sources   |2 +
 src/gallium/auxiliary/util/u_format.csv  |   30 
 src/gallium/auxiliary/util/u_format.h|   65 +---
 src/gallium/auxiliary/util/u_format_pack.py  |2 +-
 src/gallium/auxiliary/util/u_format_table.py |   10 +-
 src/gallium/include/pipe/p_format.h  |   30 
 src/mesa/state_tracker/st_extensions.c   |   32 +---
 src/mesa/state_tracker/st_format.c   |  231 --
 8 files changed, 8 insertions(+), 394 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index 6160192..82ef5ec 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -219,6 +219,8 @@ C_SOURCES := \
util/u_format.h \
util/u_format_etc.c \
util/u_format_etc.h \
+   util/u_format_fake.c \
+   util/u_format_fake.h \
util/u_format_latc.c \
util/u_format_latc.h \
util/u_format_other.c \
diff --git a/src/gallium/auxiliary/util/u_format.csv 
b/src/gallium/auxiliary/util/u_format.csv
index c26d733..d3b77e6 100644
--- a/src/gallium/auxiliary/util/u_format.csv
+++ b/src/gallium/auxiliary/util/u_format.csv
@@ -202,36 +202,6 @@ PIPE_FORMAT_BPTC_SRGBA, bptc, 4, 4, x128, 
, , , xyzw, sr
 PIPE_FORMAT_BPTC_RGB_FLOAT, bptc, 4, 4, x128, , , , xyz1, 
rgb
 PIPE_FORMAT_BPTC_RGB_UFLOAT   , bptc, 4, 4, x128, , , , xyz1, 
rgb
 
-PIPE_FORMAT_ASTC_4x4  , astc, 4, 4, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_5x4  , astc, 5, 4, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_5x5  , astc, 5, 5, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_6x5  , astc, 6, 5, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_6x6  , astc, 6, 6, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_8x5  , astc, 8, 5, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_8x6  , astc, 8, 6, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_8x8  , astc, 8, 8, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_10x5 , astc,10, 5, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_10x6 , astc,10, 6, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_10x8 , astc,10, 8, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_10x10, astc,10,10, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_12x10, astc,12,10, x128, , , , xyzw, 
rgb
-PIPE_FORMAT_ASTC_12x12, astc,12,12, x128, , , , xyzw, 
rgb
-
-PIPE_FORMAT_ASTC_4x4_SRGB , astc, 4, 4, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_5x4_SRGB , astc, 5, 4, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_5x5_SRGB , astc, 5, 5, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_6x5_SRGB , astc, 6, 5, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_6x6_SRGB , astc, 6, 6, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_8x5_SRGB , astc, 8, 5, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_8x6_SRGB , astc, 8, 6, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_8x8_SRGB , astc, 8, 8, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_10x5_SRGB, astc,10, 5, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_10x6_SRGB, astc,10, 6, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_10x8_SRGB, astc,10, 8, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_10x10_SRGB   , astc,10,10, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_12x10_SRGB   , astc,12,10, x128, , , , xyzw, 
srgb
-PIPE_FORMAT_ASTC_12x12_SRGB   , astc,12,12, x128, , , , xyzw, 
srgb
-
 # Straightforward D3D10-like formats (also used for 
 # vertex buffer element description)
 # 
diff --git a/src/gallium/auxiliary/util/u_format.h 
b/src/gallium/auxiliary/util/u_format.h
index ffdb864..a1b1b28 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -84,14 +84,9 @@ enum util_format_layout {
UTIL_FORMAT_LAYOUT_BPTC = 7,
 
/**
-* ASTC
-*/
-   UTIL_FORMAT_LAYOUT_ASTC = 8,
-
-   /**
 * Everything else that doesn't fit in any of the above layouts.
 */
-   UTIL_FORMAT_LAYOUT_OTHER = 9
+   UTIL_FORMAT_LAYOUT_OTHER = 8
 };
 
 
@@ -486,7 +481,6 @@ util_format_is_compressed(enum pipe_format format)
case UTIL_FORMAT_LAYOUT_RGTC:
case UTIL_FORMAT_LAYOUT_ETC:
case UTIL_FORMAT_LAYOUT_BPTC:
-   case UTIL_FORMAT_LAYOUT

Mesa (master): radeon/llvm: Use llvm.AMDIL.exp intrinsic again for now

2015-11-24 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 49765b0c30517e838b0bed05fbb729c9c6bc3f6c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=49765b0c30517e838b0bed05fbb729c9c6bc3f6c

Author: Michel Dänzer 
Date:   Thu Nov 19 11:30:21 2015 +0900

radeon/llvm: Use llvm.AMDIL.exp intrinsic again for now

llvm.exp2.f32 doesn't work in some cases yet.

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

Reviewed-by: Nicolai Hähnle 

---

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

diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index ac99e73..c94f109 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -1539,7 +1539,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context 
* ctx)
bld_base->op_actions[TGSI_OPCODE_ENDIF].emit = endif_emit;
bld_base->op_actions[TGSI_OPCODE_ENDLOOP].emit = endloop_emit;
bld_base->op_actions[TGSI_OPCODE_EX2].emit = build_tgsi_intrinsic_nomem;
-   bld_base->op_actions[TGSI_OPCODE_EX2].intr_name = "llvm.exp2.f32";
+   bld_base->op_actions[TGSI_OPCODE_EX2].intr_name = "llvm.AMDIL.exp.";
bld_base->op_actions[TGSI_OPCODE_FLR].emit = build_tgsi_intrinsic_nomem;
bld_base->op_actions[TGSI_OPCODE_FLR].intr_name = "llvm.floor.f32";
bld_base->op_actions[TGSI_OPCODE_FMA].emit = build_tgsi_intrinsic_nomem;

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


Mesa (master): winsys/radeon: Use CPU page size instead of hardcoding 4096 bytes v3

2015-11-09 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 24abbaff9ad177624c2b4906c7d94f5d91ac3cc0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=24abbaff9ad177624c2b4906c7d94f5d91ac3cc0

Author: Michel Dänzer 
Date:   Thu Aug 21 18:30:44 2014 +0900

winsys/radeon: Use CPU page size instead of hardcoding 4096 bytes v3

Fixes GPUVM conflicts with non-4K page size.

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

v2: Replace sanitization of VM base address alignment with comment why
that's not necessary.
v3: Use unsigned instead of long as the type for the size_align member.
(Marek)

Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Christian König  (v1)
Reviewed-by: Marek Olšák 

---

 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |   30 -
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 2878c8f..7f395b7 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -76,6 +76,9 @@ struct radeon_bomgr {
 bool va;
 uint64_t va_offset;
 struct list_head va_holes;
+
+/* BO size alignment */
+unsigned size_align;
 };
 
 static inline struct radeon_bomgr *radeon_bomgr(struct pb_manager *mgr)
@@ -188,8 +191,10 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr 
*mgr, uint64_t size, ui
 struct radeon_bo_va_hole *hole, *n;
 uint64_t offset = 0, waste = 0;
 
-alignment = MAX2(alignment, 4096);
-size = align(size, 4096);
+/* All VM address space holes will implicitly start aligned to the
+ * size alignment, so we don't need to sanitize the alignment here
+ */
+size = align(size, mgr->size_align);
 
 pipe_mutex_lock(mgr->bo_va_mutex);
 /* first look for a hole */
@@ -246,7 +251,7 @@ static void radeon_bomgr_free_va(struct radeon_bomgr *mgr, 
uint64_t va, uint64_t
 {
 struct radeon_bo_va_hole *hole;
 
-size = align(size, 4096);
+size = align(size, mgr->size_align);
 
 pipe_mutex_lock(mgr->bo_va_mutex);
 if ((va + size) == mgr->va_offset) {
@@ -357,9 +362,9 @@ static void radeon_bo_destroy(struct pb_buffer *_buf)
 pipe_mutex_destroy(bo->map_mutex);
 
 if (bo->initial_domain & RADEON_DOMAIN_VRAM)
-bo->rws->allocated_vram -= align(bo->base.size, 4096);
+bo->rws->allocated_vram -= align(bo->base.size, mgr->size_align);
 else if (bo->initial_domain & RADEON_DOMAIN_GTT)
-bo->rws->allocated_gtt -= align(bo->base.size, 4096);
+bo->rws->allocated_gtt -= align(bo->base.size, mgr->size_align);
 FREE(bo);
 }
 
@@ -644,9 +649,9 @@ static struct pb_buffer *radeon_bomgr_create_bo(struct 
pb_manager *_mgr,
 }
 
 if (rdesc->initial_domains & RADEON_DOMAIN_VRAM)
-rws->allocated_vram += align(size, 4096);
+rws->allocated_vram += align(size, mgr->size_align);
 else if (rdesc->initial_domains & RADEON_DOMAIN_GTT)
-rws->allocated_gtt += align(size, 4096);
+rws->allocated_gtt += align(size, mgr->size_align);
 
 return &bo->base;
 }
@@ -720,6 +725,9 @@ struct pb_manager *radeon_bomgr_create(struct 
radeon_drm_winsys *rws)
 mgr->va_offset = rws->va_start;
 list_inithead(&mgr->va_holes);
 
+/* TTM aligns the BO size to the CPU page size */
+mgr->size_align = sysconf(_SC_PAGESIZE);
+
 return &mgr->base;
 }
 
@@ -882,7 +890,7 @@ radeon_winsys_bo_create(struct radeon_winsys *rws,
  * BOs. Aligning this here helps the cached bufmgr. Especially small BOs,
  * like constant/uniform buffers, can benefit from better and more reuse.
  */
-size = align(size, 4096);
+size = align(size, mgr->size_align);
 
 /* Only set one usage bit each for domains and flags, or the cache manager
  * might consider different sets of domains / flags compatible
@@ -993,7 +1001,7 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct 
radeon_winsys *rws,
 pipe_mutex_unlock(mgr->bo_handles_mutex);
 }
 
-ws->allocated_gtt += align(bo->base.size, 4096);
+ws->allocated_gtt += align(bo->base.size, mgr->size_align);
 
 return (struct pb_buffer*)bo;
 }
@@ -1130,9 +1138,9 @@ done:
 bo->initial_domain = radeon_bo_get_initial_domain((void*)bo);
 
 if (bo->initial_domain & RADEON_DOMAIN_VRAM)
-ws->allocated_vram += align(bo->base.size, 4096);
+ws->allocated_vram += align(bo->base.size, mgr->size_align);
 else if (bo->initial_domain & RADEON_DOMAIN_GTT)
-ws->allocated_gtt += align(bo->base.size, 4096);
+ws->allocated_gtt += align(bo->base.size, mgr->size_align);
 
 return (struct pb_buffer*)bo;
 

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


Mesa (master): clover: fix building fix clang-3.8

2015-10-28 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 37402014e80f991169f9e05c1520667ba3930baf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=37402014e80f991169f9e05c1520667ba3930baf

Author: Laurent Carlier 
Date:   Wed Oct 28 15:47:09 2015 +0100

clover: fix building fix clang-3.8

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

v2.1: use Linker::Flags::None instead of 0 and emplace_back()

Signed-off-by: Laurent Carlier 
Reviewed-by: Francisco Jerez 

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index d74b50d..3b37f08 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -247,8 +247,12 @@ namespace {
   // attribute.  This attribute will prevent Clang from creating
   // illegal uses of barrier() (e.g. Moving barrier() inside a conditional
   // that is no executed by all threads) during its optimizaton passes.
+#if HAVE_LLVM >= 0x0308
+  
c.getCodeGenOpts().LinkBitcodeFiles.emplace_back(llvm::Linker::Flags::None,
+   libclc_path);
+#else
   c.getCodeGenOpts().LinkBitcodeFile = libclc_path;
-
+#endif
   optimization_level = c.getCodeGenOpts().OptimizationLevel;
 
   // Compile the code

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


Mesa (master): st/clover: Fix build against LLVM 3.8 SVN r244928

2015-08-14 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 7f4ad692a10bf0f247dedd4968b7ffe9b07d2af2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f4ad692a10bf0f247dedd4968b7ffe9b07d2af2

Author: Michel Dänzer 
Date:   Fri Aug 14 15:16:12 2015 +0900

st/clover: Fix build against LLVM 3.8 SVN r244928

raw_svector_ostream::flush() is now unnecessary and forbidden:

  CXX  llvm/libclllvm_la-invocation.lo
../../../../../src/gallium/state_trackers/clover/llvm/invocation.cpp: In 
function 'clover::module {anonymous}::build_module_llvm(llvm::Module*, unsigned 
int (&)[7])':
../../../../../src/gallium/state_trackers/clover/llvm/invocation.cpp:574:29: 
error: use of deleted function 'void llvm::raw_svector_ostream::flush()'
   bitcode_ostream.flush();
 ^
In file included from 
/home/daenzer/src/llvm-git/llvm/include/clang/Basic/VirtualFileSystem.h:22:0,
 from 
/home/daenzer/src/llvm-git/llvm/include/clang/Basic/FileManager.h:20,
 from 
/home/daenzer/src/llvm-git/llvm/include/clang/Basic/SourceManager.h:38,
 from 
/home/daenzer/src/llvm-git/llvm/include/clang/Frontend/CompilerInstance.h:16,
 from 
../../../../../src/gallium/state_trackers/clover/llvm/invocation.cpp:25:
/home/daenzer/src/llvm-git/llvm/include/llvm/Support/raw_ostream.h:512:8: note: 
declared here
   void flush() = delete;
^
Makefile:862: recipe for target 'llvm/libclllvm_la-invocation.lo' failed

Reviewed-by: Francisco Jerez 

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 86859af..63c3f8e 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -571,7 +571,9 @@ namespace {
   llvm::raw_svector_ostream bitcode_ostream(llvm_bitcode);
   llvm::BitstreamWriter writer(llvm_bitcode);
   llvm::WriteBitcodeToFile(mod, bitcode_ostream);
+#if HAVE_LLVM < 0x0308
   bitcode_ostream.flush();
+#endif
 
   const std::vector kernels = find_kernels(mod);
   for (unsigned i = 0; i < kernels.size(); ++i) {

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


Mesa (master): glsl: Initialize patch member of glsl_struct_field

2015-08-05 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: f7ac4ef4eeea737115d0b574fed7ecae46426072
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7ac4ef4eeea737115d0b574fed7ecae46426072

Author: Michel Dänzer 
Date:   Wed Aug  5 18:17:14 2015 +0900

glsl: Initialize patch member of glsl_struct_field

There is apparently a subtle difference in C++ between

F f;

and

F f();

The former will use the default constructor.  If there is no default
constructor specified, the compiler provides one that simply invokes the
default constructor for each field.  For built-in basic types, the
default constructor does nothing.  The later will, according to
http://stackoverflow.com/questions/2417065/does-the-default-constructor-initialize-built-in-types)
perform value-initialization of the type.  For built-in types this means
initializing to zero.

The per_vertex_accumulator constructor is:

per_vertex_accumulator::per_vertex_accumulator()
   : fields(),
 num_fields(0)
{
}

This is the second form of constructor, so the glsl_struct_field
objects were previously zero initialized.  With the addition of an empty
default constructor in commit 7ac946e5, per_vertex_accumulator::fields
receive no initialization.

Fixes a bunch of random (mostly tessellation related) piglit failures
since commit 7ac946e5 ("glsl: Add constuctors for the common cases of
glsl_struct_field").

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91544
Reviewed-by: Ian Romanick 

---

 src/glsl/builtin_variables.cpp |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 0ff3a3f..53d3500 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -322,6 +322,7 @@ per_vertex_accumulator::add_field(int slot, const glsl_type 
*type,
this->fields[this->num_fields].interpolation = INTERP_QUALIFIER_NONE;
this->fields[this->num_fields].centroid = 0;
this->fields[this->num_fields].sample = 0;
+   this->fields[this->num_fields].patch = 0;
this->num_fields++;
 }
 
@@ -1159,6 +1160,7 @@ builtin_variable_generator::generate_varyings()
  var->data.interpolation = fields[i].interpolation;
  var->data.centroid = fields[i].centroid;
  var->data.sample = fields[i].sample;
+ var->data.patch = fields[i].patch;
  var->init_interface_type(per_vertex_out_type);
   }
}

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


Mesa (master): radeonsi: Flush when we're asked to return a fence but don' t have one yet

2015-07-22 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 800efb0690e962750b9a072bcbab279fdaae24a1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=800efb0690e962750b9a072bcbab279fdaae24a1

Author: Michel Dänzer 
Date:   Wed Jul 22 16:11:39 2015 +0900

radeonsi: Flush when we're asked to return a fence but don't have one yet

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_hw_context.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c 
b/src/gallium/drivers/radeonsi/si_hw_context.c
index 08cc08e..dc8702e 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -84,7 +84,8 @@ void si_context_gfx_flush(void *context, unsigned flags,
struct radeon_winsys_cs *cs = ctx->b.rings.gfx.cs;
struct radeon_winsys *ws = ctx->b.ws;
 
-   if (cs->cdw == ctx->b.initial_gfx_cs_size) {
+   if (cs->cdw == ctx->b.initial_gfx_cs_size &&
+   (!fence || ctx->last_gfx_fence)) {
if (fence)
ws->fence_reference(fence, ctx->last_gfx_fence);
if (!(flags & RADEON_FLUSH_ASYNC))

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


Mesa (master): radeonsi: Use param export count from si_llvm_export_vs in si_shader_vs

2015-07-06 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 248b26429f52d0f19949a083aa3e0aeebcbe2138
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=248b26429f52d0f19949a083aa3e0aeebcbe2138

Author: Michel Dänzer 
Date:   Mon Jul  6 17:23:07 2015 +0900

radeonsi: Use param export count from si_llvm_export_vs in si_shader_vs

This eliminates the error prone logic in si_shader_vs recalculating this
value.

It also fixes TGSI_SEMANTIC_CLIPDIST outputs incorrectly not being
counted for VS exports. They need to be counted because they are passed
to the pixel shader as parameters as well.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91193
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_shader.c|2 ++
 src/gallium/drivers/radeonsi/si_shader.h|1 +
 src/gallium/drivers/radeonsi/si_state_shaders.c |   25 +++
 3 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 4d97b58..753b238 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1218,6 +1218,8 @@ handle_semantic:
}
}
 
+   shader->nr_param_exports = param_count;
+
/* We need to add the position output manually if it's missing. */
if (!pos_args[0][0]) {
pos_args[0][0] = lp_build_const_int32(base->gallivm, 0xf); /* 
writemask */
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index b4339ae..8d309b4 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -165,6 +165,7 @@ struct si_shader {
 
booluses_instanceid;
unsignednr_pos_exports;
+   unsignednr_param_exports;
boolis_gs_copy_shader;
booldx10_clamp_mode; /* convert NaNs to 0 */
 };
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index eef3baa..a842d9d 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -148,10 +148,9 @@ static void si_shader_gs(struct si_shader *shader)
 
 static void si_shader_vs(struct si_shader *shader)
 {
-   struct tgsi_shader_info *info = &shader->selector->info;
struct si_pm4_state *pm4;
unsigned num_sgprs, num_user_sgprs;
-   unsigned nparams, i, vgpr_comp_cnt;
+   unsigned nparams, vgpr_comp_cnt;
uint64_t va;
unsigned window_space =
   
shader->selector->info.properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION];
@@ -180,26 +179,8 @@ static void si_shader_vs(struct si_shader *shader)
}
assert(num_sgprs <= 104);
 
-   /* Certain attributes (position, psize, etc.) don't count as params.
-* VS is required to export at least one param and 
r600_shader_from_tgsi()
-* takes care of adding a dummy export.
-*/
-   for (nparams = 0, i = 0 ; i < info->num_outputs; i++) {
-   switch (info->output_semantic_name[i]) {
-   case TGSI_SEMANTIC_CLIPVERTEX:
-   case TGSI_SEMANTIC_CLIPDIST:
-   case TGSI_SEMANTIC_CULLDIST:
-   case TGSI_SEMANTIC_POSITION:
-   case TGSI_SEMANTIC_PSIZE:
-   case TGSI_SEMANTIC_EDGEFLAG:
-   break;
-   default:
-   nparams++;
-   }
-   }
-   if (nparams < 1)
-   nparams = 1;
-
+   /* VS is required to export at least one param. */
+   nparams = MAX2(shader->nr_param_exports, 1);
si_pm4_set_reg(pm4, R_0286C4_SPI_VS_OUT_CONFIG,
   S_0286C4_VS_EXPORT_COUNT(nparams - 1));
 

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


Mesa (master): winsys/radeon: Unmap GPU VM address range when destroying BO

2015-06-23 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 7796e8889a9a2cc1b454dc32d8da3d756404339a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7796e8889a9a2cc1b454dc32d8da3d756404339a

Author: Michel Dänzer 
Date:   Thu May 21 10:49:05 2015 +0900

winsys/radeon: Unmap GPU VM address range when destroying BO

But only when doing so is safe according to the
RADEON_INFO_VA_UNMAP_WORKING kernel query.

This avoids kernel GPU VM address range conflicts when the BO has other
references than the GEM handle being closed, e.g. when the BO is shared.

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

Cc: "10.5 10.6" 
Reviewed-by: Christian König 

---

 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |   28 ++---
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c |4 +++
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.h |1 +
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index fe98870..78c95b1 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -305,14 +305,34 @@ static void radeon_bo_destroy(struct pb_buffer *_buf)
 if (bo->ptr)
 os_munmap(bo->ptr, bo->base.size);
 
+if (mgr->va) {
+if (bo->rws->va_unmap_working) {
+struct drm_radeon_gem_va va;
+
+va.handle = bo->handle;
+va.vm_id = 0;
+va.operation = RADEON_VA_UNMAP;
+va.flags = RADEON_VM_PAGE_READABLE |
+   RADEON_VM_PAGE_WRITEABLE |
+   RADEON_VM_PAGE_SNOOPED;
+va.offset = bo->va;
+
+if (drmCommandWriteRead(bo->rws->fd, DRM_RADEON_GEM_VA, &va,
+   sizeof(va)) != 0 &&
+   va.operation == RADEON_VA_RESULT_ERROR) {
+fprintf(stderr, "radeon: Failed to deallocate virtual address 
for buffer:\n");
+fprintf(stderr, "radeon:size  : %d bytes\n", 
bo->base.size);
+fprintf(stderr, "radeon:va: 0x%016llx\n", 
(unsigned long long)bo->va);
+}
+   }
+
+   radeon_bomgr_free_va(mgr, bo->va, bo->base.size);
+}
+
 /* Close object. */
 args.handle = bo->handle;
 drmIoctl(bo->rws->fd, DRM_IOCTL_GEM_CLOSE, &args);
 
-if (mgr->va) {
-radeon_bomgr_free_va(mgr, bo->va, bo->base.size);
-}
-
 pipe_mutex_destroy(bo->map_mutex);
 
 if (bo->initial_domain & RADEON_DOMAIN_VRAM)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index ba8d143..d457f8a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -57,6 +57,8 @@
 #define RADEON_INFO_READ_REG   0x24
 #endif
 
+#define RADEON_INFO_VA_UNMAP_WORKING   0x25
+
 static struct util_hash_table *fd_tab = NULL;
 pipe_static_mutex(fd_tab_mutex);
 
@@ -399,6 +401,8 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
 if (!radeon_get_drm_value(ws->fd, RADEON_INFO_IB_VM_MAX_SIZE, NULL,
   &ib_vm_max_size))
 ws->info.r600_virtual_address = FALSE;
+radeon_get_drm_value(ws->fd, RADEON_INFO_VA_UNMAP_WORKING, NULL,
+ &ws->va_unmap_working);
 }
if (ws->gen == DRV_R600 && !debug_get_bool_option("RADEON_VA", FALSE))
ws->info.r600_virtual_address = FALSE;
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
index 166b6b9..99c8b8a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
@@ -74,6 +74,7 @@ struct radeon_drm_winsys {
 enum radeon_generation gen;
 struct radeon_info info;
 uint32_t va_start;
+uint32_t va_unmap_working;
 uint32_t accel_working2;
 
 struct pb_manager *kman;

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


Mesa (master): radeonsi: Add CIK SDMA support

2015-06-08 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 56e38edc960bf08213cdb0282838ccec3e5ea10e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=56e38edc960bf08213cdb0282838ccec3e5ea10e

Author: Michel Dänzer 
Date:   Tue May 26 16:27:15 2015 +0900

radeonsi: Add CIK SDMA support

Based on the corresponding SI support. Same as that, this is currently
only enabled for one-dimensional buffer copies due to issues with
multi-dimensional SDMA copies.

Reviewed-by: Marek Olšák 
Reviewed-by: Alex Deucher 

---

 src/gallium/drivers/radeonsi/Makefile.sources |1 +
 src/gallium/drivers/radeonsi/cik_sdma.c   |  364 +
 src/gallium/drivers/radeonsi/si_dma.c |   20 --
 src/gallium/drivers/radeonsi/si_pipe.h|9 +
 src/gallium/drivers/radeonsi/si_state.c   |   22 +-
 src/gallium/drivers/radeonsi/si_state.h   |1 +
 src/gallium/drivers/radeonsi/sid.h|   31 +++
 7 files changed, 427 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/Makefile.sources 
b/src/gallium/drivers/radeonsi/Makefile.sources
index 774dc22..2876c0a 100644
--- a/src/gallium/drivers/radeonsi/Makefile.sources
+++ b/src/gallium/drivers/radeonsi/Makefile.sources
@@ -1,4 +1,5 @@
 C_SOURCES := \
+   cik_sdma.c \
si_blit.c \
si_commands.c \
si_compute.c \
diff --git a/src/gallium/drivers/radeonsi/cik_sdma.c 
b/src/gallium/drivers/radeonsi/cik_sdma.c
new file mode 100644
index 000..86111cb
--- /dev/null
+++ b/src/gallium/drivers/radeonsi/cik_sdma.c
@@ -0,0 +1,364 @@
+/*
+ * Copyright 2010 Jerome Glisse 
+ * Copyright 2014,2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *  Jerome Glisse
+ */
+
+#include "sid.h"
+#include "si_pipe.h"
+#include "../radeon/r600_cs.h"
+
+#include "util/u_format.h"
+
+static uint32_t cik_micro_tile_mode(struct si_screen *sscreen, unsigned 
tile_mode)
+{
+   if (sscreen->b.info.si_tile_mode_array_valid) {
+   uint32_t gb_tile_mode = 
sscreen->b.info.si_tile_mode_array[tile_mode];
+
+   return G_009910_MICRO_TILE_MODE_NEW(gb_tile_mode);
+   }
+
+   /* The kernel cannod return the tile mode array. Guess? */
+   return V_009910_ADDR_SURF_THIN_MICRO_TILING;
+}
+
+static void cik_sdma_do_copy_buffer(struct si_context *ctx,
+   struct pipe_resource *dst,
+   struct pipe_resource *src,
+   uint64_t dst_offset,
+   uint64_t src_offset,
+   uint64_t size)
+{
+   struct radeon_winsys_cs *cs = ctx->b.rings.dma.cs;
+   unsigned i, ncopy, csize;
+   struct r600_resource *rdst = (struct r600_resource*)dst;
+   struct r600_resource *rsrc = (struct r600_resource*)src;
+
+   dst_offset += r600_resource(dst)->gpu_address;
+   src_offset += r600_resource(src)->gpu_address;
+
+   ncopy = (size + CIK_SDMA_COPY_MAX_SIZE - 1) / CIK_SDMA_COPY_MAX_SIZE;
+   r600_need_dma_space(&ctx->b, ncopy * 7);
+
+   r600_context_bo_reloc(&ctx->b, &ctx->b.rings.dma, rsrc, 
RADEON_USAGE_READ,
+ RADEON_PRIO_MIN);
+   r600_context_bo_reloc(&ctx->b, &ctx->b.rings.dma, rdst, 
RADEON_USAGE_WRITE,
+ RADEON_PRIO_MIN);
+
+   for (i = 0; i < ncopy; i++) {
+   csize = size < CIK_SDMA_COPY_MAX_SIZE ? size : 
CIK_SDMA_COPY_MAX_SIZE;
+   cs->buf[cs->cdw++] = CIK_SDMA_PACKET(CIK_SDMA_OPCODE_COPY,
+
CIK_SDMA_COPY_SUB_OPCODE_LINEAR,
+0);
+   cs->buf[cs->cdw++] = csize;
+   cs

Mesa (master): r600g,radeonsi: Assert that there' s enough space after flushing

2015-06-08 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 79f2acb8f89704c609dd87d969353a506e03b05e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=79f2acb8f89704c609dd87d969353a506e03b05e

Author: Michel Dänzer 
Date:   Wed Nov 19 15:31:24 2014 +0900

r600g,radeonsi: Assert that there's enough space after flushing

Reviewed-by: Marek Olšák 
Reviewed-by: Alex Deucher 

---

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

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index 42e681d..3def444 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -107,11 +107,10 @@ void r600_draw_rectangle(struct blitter_context *blitter,
 
 void r600_need_dma_space(struct r600_common_context *ctx, unsigned num_dw)
 {
-   /* The number of dwords we already used in the DMA so far. */
-   num_dw += ctx->rings.dma.cs->cdw;
/* Flush if there's not enough space. */
-   if (num_dw > RADEON_MAX_CMDBUF_DWORDS) {
+   if ((num_dw + ctx->rings.dma.cs->cdw) > RADEON_MAX_CMDBUF_DWORDS) {
ctx->rings.dma.flush(ctx, RADEON_FLUSH_ASYNC, NULL);
+   assert((num_dw + ctx->rings.dma.cs->cdw) <= 
RADEON_MAX_CMDBUF_DWORDS);
}
 }
 

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


Mesa (master): gallivm: Fix build against LLVM 3.7 SVN r235265

2015-04-19 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 645f77fe50c1f04eb77d03b3feaaa5fd36d1d1a4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=645f77fe50c1f04eb77d03b3feaaa5fd36d1d1a4

Author: Nick Sarnie 
Date:   Sun Apr 19 23:51:26 2015 -0400

gallivm: Fix build against LLVM 3.7 SVN r235265

LLVM removed JITEmitDebugInfo from TargetOptions since they weren't used

v2: Be consistent with the LLVM version check (Aaron Watry)

Signed-off-by: Nick Sarnie 
Reviewed-and-Tested-by: Michel Dänzer 

---

 src/gallium/auxiliary/gallivm/lp_bld_debug.cpp |2 +-
 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp 
b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
index 65d2896..be3e834 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
@@ -270,7 +270,7 @@ disassemble(const void* func, llvm::raw_ostream & Out)
}
 
TargetOptions options;
-#if defined(DEBUG)
+#if defined(DEBUG) && HAVE_LLVM < 0x0307
options.JITEmitDebugInfo = true;
 #endif
 #if defined(PIPE_ARCH_X86)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp 
b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index 4ede90b..5e8a634 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -429,7 +429,7 @@ 
lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
 #endif
 #endif
 
-#if defined(DEBUG)
+#if defined(DEBUG) && HAVE_LLVM < 0x0307
options.JITEmitDebugInfo = true;
 #endif
 

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


Mesa (master): gbm: Add GBM_BO_USE_LINEAR flag

2015-04-15 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: f78b2c432f31a18794b9f62f0a0cfb8eca256151
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f78b2c432f31a18794b9f62f0a0cfb8eca256151

Author: Flora Cui 
Date:   Tue Mar 24 18:34:29 2015 +0800

gbm: Add GBM_BO_USE_LINEAR flag

Signed-off-by: Flora Cui 
Reviewed-by: Jammy Zhou 
Reviewed-by: Michel Dänzer 
Reviewed-by: Alex Deucher 

---

 src/gbm/backends/dri/gbm_dri.c |2 ++
 src/gbm/main/gbm.h |4 
 2 files changed, 6 insertions(+)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index c513672..62bdf89 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -858,6 +858,8 @@ gbm_dri_bo_create(struct gbm_device *gbm,
   dri_use |= __DRI_IMAGE_USE_SCANOUT;
if (usage & GBM_BO_USE_CURSOR)
   dri_use |= __DRI_IMAGE_USE_CURSOR;
+   if (usage & GBM_BO_USE_LINEAR)
+  dri_use |= __DRI_IMAGE_USE_LINEAR;
 
/* Gallium drivers requires shared in order to get the handle/stride */
dri_use |= __DRI_IMAGE_USE_SHARE;
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index 7b23c26..2708e50 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -209,6 +209,10 @@ enum gbm_bo_flags {
 * with GBM_BO_USE_CURSOR. but may not work for other combinations.
 */
GBM_BO_USE_WRITE= (1 << 3),
+   /**
+* Buffer is linear, i.e. not tiled.
+*/
+   GBM_BO_USE_LINEAR = (1 << 4),
 };
 
 int

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


Mesa (master): gallivm: Fix build against LLVM 3.7 SVN r233648

2015-03-31 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: b8797a78752daf9e1d4c06da81efea4bb85a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8797a78752daf9e1d4c06da81efea4bb85a

Author: Michel Dänzer 
Date:   Tue Mar 31 15:05:01 2015 +0900

gallivm: Fix build against LLVM 3.7 SVN r233648

Reviewed-by: Jose Fonseca 

---

 src/gallium/auxiliary/gallivm/lp_bld_debug.cpp |5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp 
b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
index d4d453d..65d2896 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
@@ -256,8 +256,13 @@ disassemble(const void* func, llvm::raw_ostream & Out)
}
 
 
+#if HAVE_LLVM >= 0x0307
+   OwningPtr Printer(
+ T->createMCInstPrinter(llvm::Triple(Triple), AsmPrinterVariant, 
*AsmInfo, *MII, *MRI));
+#else
OwningPtr Printer(
  T->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *MII, *MRI, 
*STI));
+#endif
if (!Printer) {
   Out << "error: no instruction printer for target " << Triple.c_str() << 
"\n";
   Out.flush();

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


Mesa (master): radeonsi: Cache LLVMTargetMachineRef in context instead of in screen

2015-03-29 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: d64adc3a79e419062432cfa8d1cbc437676a3fbd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d64adc3a79e419062432cfa8d1cbc437676a3fbd

Author: Michel Dänzer 
Date:   Thu Mar 26 11:32:59 2015 +0900

radeonsi: Cache LLVMTargetMachineRef in context instead of in screen

Fixes a crash in genymotion with several threads compiling shaders
concurrently.

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

Cc: 10.5 
Reviewed-by: Tom Stellard 

---

 src/gallium/drivers/radeonsi/si_compute.c   |3 +-
 src/gallium/drivers/radeonsi/si_pipe.c  |   43 ---
 src/gallium/drivers/radeonsi/si_pipe.h  |3 +-
 src/gallium/drivers/radeonsi/si_shader.c|   13 ---
 src/gallium/drivers/radeonsi/si_shader.h|5 +--
 src/gallium/drivers/radeonsi/si_state_shaders.c |4 ++-
 6 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
b/src/gallium/drivers/radeonsi/si_compute.c
index 8609b89..89bef2e 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -130,7 +130,8 @@ static void *si_create_compute_state(
for (i = 0; i < program->num_kernels; i++) {
LLVMModuleRef mod = 
radeon_llvm_get_kernel_module(program->llvm_ctx, i,
 code, 
header->num_bytes);
-   si_compile_llvm(sctx->screen, &program->kernels[i], 
mod);
+   si_compile_llvm(sctx->screen, &program->kernels[i], 
sctx->tm,
+   mod);
LLVMDisposeModule(mod);
}
}
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index d335bda..0eada72 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -69,6 +69,11 @@ static void si_destroy_context(struct pipe_context *context)
si_pm4_cleanup(sctx);
 
r600_common_context_cleanup(&sctx->b);
+
+#if HAVE_LLVM >= 0x0306
+   LLVMDisposeTargetMachine(sctx->tm);
+#endif
+
FREE(sctx);
 }
 
@@ -77,6 +82,12 @@ static struct pipe_context *si_create_context(struct 
pipe_screen *screen, void *
struct si_context *sctx = CALLOC_STRUCT(si_context);
struct si_screen* sscreen = (struct si_screen *)screen;
struct radeon_winsys *ws = sscreen->b.ws;
+   LLVMTargetRef r600_target;
+#if HAVE_LLVM >= 0x0306
+   const char *triple = "amdgcn--";
+#else
+   const char *triple = "r600--";
+#endif
int shader, i;
 
if (sctx == NULL)
@@ -170,6 +181,17 @@ static struct pipe_context *si_create_context(struct 
pipe_screen *screen, void *
 */
sctx->scratch_waves = 32 * sscreen->b.info.max_compute_units;
 
+#if HAVE_LLVM >= 0x0306
+   /* Initialize LLVM TargetMachine */
+   r600_target = radeon_llvm_get_r600_target(triple);
+   sctx->tm = LLVMCreateTargetMachine(r600_target, triple,
+  
r600_get_llvm_processor_name(sscreen->b.family),
+  "+DumpCode,+vgpr-spilling",
+  LLVMCodeGenLevelDefault,
+  LLVMRelocDefault,
+  LLVMCodeModelDefault);
+#endif
+
return &sctx->b.b;
 fail:
si_destroy_context(&sctx->b.b);
@@ -445,12 +467,6 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
if (!sscreen->b.ws->unref(sscreen->b.ws))
return;
 
-#if HAVE_LLVM >= 0x0306
-   // r600_destroy_common_screen() frees sscreen, so we need to make
-   // sure to dispose the TargetMachine before we call it.
-   LLVMDisposeTargetMachine(sscreen->tm);
-#endif
-
r600_destroy_common_screen(&sscreen->b);
 }
 
@@ -508,12 +524,7 @@ static bool si_initialize_pipe_config(struct si_screen 
*sscreen)
 struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 {
struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
-   LLVMTargetRef r600_target;
-#if HAVE_LLVM >= 0x0306
-   const char *triple = "amdgcn--";
-#else
-   const char *triple = "r600--";
-#endif
+
if (sscreen == NULL) {
return NULL;
}
@@ -541,13 +552,5 @@ struct pipe_screen *radeonsi_screen_create(struct 
radeon_winsys *ws)
/* Create the auxiliary context. This must be done last. */
sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, 
NULL);
 
-#if HAVE_LLVM >= 0x0306
-   /* Initialize LLVM TargetMachine */
-   r600_target = radeon_llvm_get_r600_target(triple);
-   sscreen->tm = LLVMCr

Mesa (master): Revert "radeon/llvm: enable unsafe math for graphics shaders"

2015-02-18 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 4db985a5fa9ea985616a726b1770727309502d81
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4db985a5fa9ea985616a726b1770727309502d81

Author: Michel Dänzer 
Date:   Tue Feb 17 17:03:35 2015 +0900

Revert "radeon/llvm: enable unsafe math for graphics shaders"

This reverts commit 0e9cdedd2e3943bdb7f3543a3508b883b167e427.

It caused the grass to disappear in The Talos Principle.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89069
Cc: "10.5 10.4" 
Reviewed-by: Tom Stellard 
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeon/radeon_llvm_emit.c |4 
 1 file changed, 4 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c 
b/src/gallium/drivers/radeon/radeon_llvm_emit.c
index 0f9dbab..624077c 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c
@@ -80,10 +80,6 @@ void radeon_llvm_shader_type(LLVMValueRef F, unsigned type)
sprintf(Str, "%1d", llvm_type);
 
LLVMAddTargetDependentFunctionAttr(F, "ShaderType", Str);
-
-   if (type != TGSI_PROCESSOR_COMPUTE) {
-   LLVMAddTargetDependentFunctionAttr(F, "unsafe-fp-math", "true");
-   }
 }
 
 static void init_r600_target()

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


Mesa (master): st/mesa: Don' t use PIPE_USAGE_STREAM for GL_PIXEL_UNPACK_BUFFER_ARB

2015-02-05 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: a338dc01866ce50bf7555ee8dc08491c7f63b585
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a338dc01866ce50bf7555ee8dc08491c7f63b585

Author: Michel Dänzer 
Date:   Thu Feb  5 12:46:04 2015 +0900

st/mesa: Don't use PIPE_USAGE_STREAM for GL_PIXEL_UNPACK_BUFFER_ARB

The latter currently implies CPU read access, so only PIPE_USAGE_STAGING
can be expected to be fast.

Mesa demos src/tests/streaming_rect on Kaveri (radeonsi):

Unpatched:  42 frames in  1.023 seconds = 41.056 FPS
Patched:   615 frames in  1.000 seconds = 615.000 FPS

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88658
Cc: "10.3 10.4" 
Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_cb_bufferobjects.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c 
b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 55f3644..90f786c 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -256,8 +256,15 @@ st_bufferobj_data(struct gl_context *ctx,
  break;
   case GL_STREAM_DRAW:
   case GL_STREAM_COPY:
- pipe_usage = PIPE_USAGE_STREAM;
- break;
+ /* XXX: Remove this test and fall-through when we have PBO unpacking
+  * acceleration. Right now, PBO unpacking is done by the CPU, so we
+  * have to make sure CPU reads are fast.
+  */
+ if (target != GL_PIXEL_UNPACK_BUFFER_ARB) {
+pipe_usage = PIPE_USAGE_STREAM;
+break;
+ }
+ /* fall through */
   case GL_STATIC_READ:
   case GL_DYNAMIC_READ:
   case GL_STREAM_READ:

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


Mesa (master): st/clover: Pass target instead of target.begin() to std:: string()

2015-01-27 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 5c83a0d2ce41fa4b7b39d13c69d39990f7c926f5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c83a0d2ce41fa4b7b39d13c69d39990f7c926f5

Author: Michel Dänzer 
Date:   Thu Jan 22 12:30:24 2015 +0900

st/clover: Pass target instead of target.begin() to std::string()

Fixes reading beyond allocated memory:

==1936== Invalid read of size 1
==1936==at 0x4C2C1B4: strlen (vg_replace_strmem.c:412)
==1936==by 0x9E00C30: std::basic_string, 
std::allocator >::basic_string(char const*, std::allocator const&) 
(in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20)
==1936==by 0x5B44FAE: clover::compile_program_llvm(clover::compat::string 
const&, clover::compat::vector > const&, pipe_shader_ir, clover::compat::string 
const&, clover::compat::string const&, clover::compat::string&) 
(invocation.cpp:698)
==1936==by 0x5B39A20: 
clover::program::build(clover::ref_vector const&, char const*, 
clover::compat::vector > const&) (program.cpp:63)
==1936==by 0x5B20152: clBuildProgram (program.cpp:182)
==1936==by 0x400F41: main (hello_world.c:109)
==1936==  Address 0x56fee1f is 0 bytes after a block of size 15 alloc'd
==1936==at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==1936==by 0x5B398F0: alloc (compat.hpp:59)
==1936==by 0x5B398F0: vector > (compat.hpp:98)
==1936==by 0x5B398F0: string > (compat.hpp:327)
==1936==by 0x5B398F0: 
clover::program::build(clover::ref_vector const&, char const*, 
clover::compat::vector > const&) (program.cpp:63)
==1936==by 0x5B20152: clBuildProgram (program.cpp:182)
==1936==by 0x400F41: main (hello_world.c:109)

Reviewed-by: Francisco Jerez 

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 7a0be53..edeed56 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -699,9 +699,9 @@ clover::compile_program_llvm(const compat::string &source,
  debug_options, 0);
 
std::vector kernels;
-   size_t processor_str_len = std::string(target.begin()).find_first_of("-");
-   std::string processor(target.begin(), 0, processor_str_len);
-   std::string triple(target.begin(), processor_str_len + 1,
+   size_t processor_str_len = std::string(target).find_first_of("-");
+   std::string processor(target, 0, processor_str_len);
+   std::string triple(target, processor_str_len + 1,
   target.size() - processor_str_len - 1);
clang::LangAS::Map address_spaces;
llvm::LLVMContext llvm_ctx;

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


Mesa (master): r600g,radeonsi: Fix calculation of IR target cap string buffer size

2015-01-27 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: ee31c8d7067ec5a563cdce5a12d8e077db0a7f67
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee31c8d7067ec5a563cdce5a12d8e077db0a7f67

Author: Michel Dänzer 
Date:   Thu Jan 22 12:36:13 2015 +0900

r600g,radeonsi: Fix calculation of IR target cap string buffer size

Fixes writing beyond the allocated buffer:

==31855== Invalid write of size 1
==31855==at 0x50AB2A9: vsprintf (iovsprintf.c:43)
==31855==by 0x508F6F6: sprintf (sprintf.c:32)
==31855==by 0xB59C7EC: r600_get_compute_param (r600_pipe_common.c:526)
==31855==by 0x5B2B7DE: get_compute_param (device.cpp:37)
==31855==by 0x5B2B7DE: clover::device::ir_target() const (device.cpp:201)
==31855==by 0x5B398E0: 
clover::program::build(clover::ref_vector const&, char const*, 
clover::compat::vector > const&) (program.cpp:63)
==31855==by 0x5B20152: clBuildProgram (program.cpp:182)
==31855==by 0x400F41: main (hello_world.c:109)
==31855==  Address 0x56fed5f is 0 bytes after a block of size 15 alloc'd
==31855==at 0x4C29180: operator new(unsigned long) (vg_replace_malloc.c:324)
==31855==by 0x5B2B7C2: allocate (new_allocator.h:104)
==31855==by 0x5B2B7C2: allocate (alloc_traits.h:357)
==31855==by 0x5B2B7C2: _M_allocate (stl_vector.h:170)
==31855==by 0x5B2B7C2: _M_create_storage (stl_vector.h:185)
==31855==by 0x5B2B7C2: _Vector_base (stl_vector.h:136)
==31855==by 0x5B2B7C2: vector (stl_vector.h:278)
==31855==by 0x5B2B7C2: get_compute_param (device.cpp:35)
==31855==by 0x5B2B7C2: clover::device::ir_target() const (device.cpp:201)
==31855==by 0x5B398E0: 
clover::program::build(clover::ref_vector const&, char const*, 
clover::compat::vector > const&) (program.cpp:63)
==31855==by 0x5B20152: clBuildProgram (program.cpp:182)
==31855==by 0x400F41: main (hello_world.c:109)

Reviewed-by: Marek Olšák 
Reviewed-by: Tom Stellard 

---

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

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index f91772e..ddb4142 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -524,9 +524,9 @@ static int r600_get_compute_param(struct pipe_screen 
*screen,
}
if (ret) {
sprintf(ret, "%s-%s", gpu, triple);
-
}
-   return (strlen(triple) + strlen(gpu)) * sizeof(char);
+   /* +2 for dash and terminating NIL byte */
+   return (strlen(triple) + strlen(gpu) + 2) * sizeof(char);
}
case PIPE_COMPUTE_CAP_GRID_DIMENSION:
if (ret) {

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


Mesa (master): Revert "radeonsi: only set BC_OPTIMIZE_DISABLE when necessary"

2015-01-14 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 82b7ee62fc4bbe014f61a60bccf694b706c7247d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=82b7ee62fc4bbe014f61a60bccf694b706c7247d

Author: Michel Dänzer 
Date:   Tue Jan 13 16:38:52 2015 +0900

Revert "radeonsi: only set BC_OPTIMIZE_DISABLE when necessary"

This reverts commit 0543630d0b0d9d9f6eefbc14fbd3385d4de37ba0.

It caused flickering artifacts in Steam games such as Team Fortress 2 or
Left 4 Dead 2.

We could probably only enable this optimization by also making sure the
shader code only uses either SI_PARAM_LINEAR_CENTROID or
SI_PARAM_LINEAR_CENTER, not both. This would probably require a shader
variant.

Sorry I didn't remember this when reviewing the reverted change.

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_pipe.h  |1 -
 src/gallium/drivers/radeonsi/si_state_shaders.c |   20 ++--
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index dfb1cd6..6144fb1 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -169,7 +169,6 @@ struct si_context {
/* shader information */
unsignedsprite_coord_enable;
boolflatshade;
-   boolbc_optimize_disable;
struct si_descriptors   vertex_buffers;
struct si_buffer_resources  const_buffers[SI_NUM_SHADERS];
struct si_buffer_resources  rw_buffers[SI_NUM_SHADERS];
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 817a990..887680f 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -232,7 +232,7 @@ static void si_shader_ps(struct si_shader *shader)
 {
struct tgsi_shader_info *info = &shader->selector->info;
struct si_pm4_state *pm4;
-   unsigned i;
+   unsigned i, spi_ps_in_control;
unsigned num_sgprs, num_user_sgprs;
unsigned spi_baryc_cntl = 0, spi_ps_input_ena;
uint64_t va;
@@ -267,6 +267,9 @@ static void si_shader_ps(struct si_shader *shader)
}
}
 
+   spi_ps_in_control = S_0286D8_NUM_INTERP(shader->nparam) |
+   S_0286D8_BC_OPTIMIZE_DISABLE(1);
+
si_pm4_set_reg(pm4, R_0286E0_SPI_BARYC_CNTL, spi_baryc_cntl);
spi_ps_input_ena = shader->spi_ps_input_ena;
/* we need to enable at least one of them, otherwise we hang the GPU */
@@ -281,6 +284,7 @@ static void si_shader_ps(struct si_shader *shader)
 
si_pm4_set_reg(pm4, R_0286CC_SPI_PS_INPUT_ENA, spi_ps_input_ena);
si_pm4_set_reg(pm4, R_0286D0_SPI_PS_INPUT_ADDR, spi_ps_input_ena);
+   si_pm4_set_reg(pm4, R_0286D8_SPI_PS_IN_CONTROL, spi_ps_in_control);
 
si_pm4_set_reg(pm4, R_028710_SPI_SHADER_Z_FORMAT, 
shader->spi_shader_z_format);
si_pm4_set_reg(pm4, R_028714_SPI_SHADER_COL_FORMAT,
@@ -661,10 +665,6 @@ bcolor:
}
}
 
-   si_pm4_set_reg(pm4, R_0286D8_SPI_PS_IN_CONTROL,
-  S_0286D8_NUM_INTERP(ps->nparam) |
-  S_0286D8_BC_OPTIMIZE_DISABLE(sctx->bc_optimize_disable));
-
si_pm4_set_state(sctx, spi, pm4);
 }
 
@@ -710,7 +710,6 @@ void si_update_shaders(struct si_context *sctx)
 {
struct pipe_context *ctx = (struct pipe_context*)sctx;
struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
-   bool bc_optimize_disable;
 
if (sctx->gs_shader) {
si_shader_select(ctx, sctx->gs_shader);
@@ -775,18 +774,11 @@ void si_update_shaders(struct si_context *sctx)
 
si_pm4_bind_state(sctx, ps, sctx->ps_shader->current->pm4);
 
-   /* Whether CENTER != CENTROID. */
-   bc_optimize_disable = sctx->framebuffer.nr_samples > 1 &&
- rs->multisample_enable &&
- sctx->ps_shader->info.uses_centroid;
-
if (si_pm4_state_changed(sctx, ps) || si_pm4_state_changed(sctx, vs) ||
sctx->sprite_coord_enable != rs->sprite_coord_enable ||
-   sctx->flatshade != rs->flatshade ||
-   sctx->bc_optimize_disable != bc_optimize_disable) {
+   sctx->flatshade != rs->flatshade) {
sctx->sprite_coord_enable = rs->sprite_coord_enable;
sctx->flatshade = rs->flatshade;
-   sctx->bc_optimize_disable = bc_optimize_disable;
si_update_spi_map(sctx);
}
 

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


Mesa (master): st/clover: Adapt to TargetLibraryInfo.h move in LLVM SVN r226078

2015-01-14 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: a6a75f1286e1a2e7a0fb856849802b40474c6336
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6a75f1286e1a2e7a0fb856849802b40474c6336

Author: Michel Dänzer 
Date:   Thu Jan 15 12:57:05 2015 +0900

st/clover: Adapt to TargetLibraryInfo.h move in LLVM SVN r226078

Trivial.

---

 src/gallium/state_trackers/clover/llvm/invocation.cpp |4 
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 5265d10..6cc07b2 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -56,7 +56,11 @@
 
 
 #include 
+#if HAVE_LLVM >= 0x0307
+#include 
+#else
 #include 
+#endif
 #include 
 #include 
 

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


Mesa (master): radeonsi: Don' t modify PA_SC_RASTER_CONFIG register value if rb_mask == 0

2014-12-24 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: b3057f8097f88d9072df6d9c09bcc8c039b88a7c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b3057f8097f88d9072df6d9c09bcc8c039b88a7c

Author: Michel Dänzer 
Date:   Tue Dec  9 17:00:32 2014 +0900

radeonsi: Don't modify PA_SC_RASTER_CONFIG register value if rb_mask == 0

E.g. this could happen on older kernels which don't support the
RADEON_INFO_SI_BACKEND_ENABLED_MASK query yet. The code in
si_write_harvested_raster_configs() doesn't deal with this correctly and
would probably mangle the value badly.

Cc: "10.4 10.3" 
Reviewed-by: Marek Olšák 
Reviewed-by: Tom Stellard 

---

 src/gallium/drivers/radeonsi/si_state.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 097c31c..5a417b0 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -3032,8 +3032,10 @@ void si_init_config(struct si_context *sctx)
break;
}
 
-   /* Always use the default config when all backends are enabled. 
*/
-   if (rb_mask && util_bitcount(rb_mask) >= num_rb) {
+   /* Always use the default config when all backends are enabled
+* (or when we failed to determine the enabled backends).
+*/
+   if (!rb_mask || util_bitcount(rb_mask) >= num_rb) {
si_pm4_set_reg(pm4, R_028350_PA_SC_RASTER_CONFIG,
   raster_config);
} else {

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


Mesa (master): radeonsi: Disable asynchronous DMA except for PIPE_BUFFER

2014-11-16 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: ae4536b4f71cbe76230ea7edc7eb4d6041e651b4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ae4536b4f71cbe76230ea7edc7eb4d6041e651b4

Author: Michel Dänzer 
Date:   Tue Nov 11 16:10:20 2014 +0900

radeonsi: Disable asynchronous DMA except for PIPE_BUFFER

Using the asynchronous DMA engine for multi-dimensional operations seems
to cause random GPU lockups for various people. While the root cause for
this might need to be fixed in the kernel, let's disable it for now.

Before re-enabling this, please make sure you can hit all newly enabled
paths in your testing, preferably with both piglit and real world apps,
and get in touch with people on the bug reports below for stability
testing.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85647
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83500
Cc: "10.3 10.4" 
Reviewed-by: Marek Olšák 
Reviewed-by: Grigori Goronzy 

---

 src/gallium/drivers/radeonsi/si_dma.c |   15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_dma.c 
b/src/gallium/drivers/radeonsi/si_dma.c
index b1bd5e7..db523ee 100644
--- a/src/gallium/drivers/radeonsi/si_dma.c
+++ b/src/gallium/drivers/radeonsi/si_dma.c
@@ -250,6 +250,21 @@ void si_dma_copy(struct pipe_context *ctx,
return;
}
 
+   /* XXX: Using the asynchronous DMA engine for multi-dimensional
+* operations seems to cause random GPU lockups for various people.
+* While the root cause for this might need to be fixed in the kernel,
+* let's disable it for now.
+*
+* Before re-enabling this, please make sure you can hit all newly
+* enabled paths in your testing, preferably with both piglit and real
+* world apps, and get in touch with people on the bug reports below
+* for stability testing.
+*
+* https://bugs.freedesktop.org/show_bug.cgi?id=85647
+* https://bugs.freedesktop.org/show_bug.cgi?id=83500
+*/
+   goto fallback;
+
if (src->format != dst->format || src_box->depth > 1 ||
rdst->dirty_level_mask != 0 ||
rdst->cmask.size || rdst->fmask.size ||

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


Mesa (master): radeon/llvm: Dynamically allocate branch/loop stack arrays

2014-10-29 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 402ab50bedf9fba7654e63a6f2e808714714284d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=402ab50bedf9fba7654e63a6f2e808714714284d

Author: Michel Dänzer 
Date:   Tue Oct 28 11:28:29 2014 +0900

radeon/llvm: Dynamically allocate branch/loop stack arrays

This prevents us from silently overflowing the stack arrays, and allows
arbitrary stack depths.

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

Cc: mesa-sta...@lists.freedesktop.org
Reported-and-Tested-by: Nick Sarnie 
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeon/radeon_llvm.h   |   10 +++---
 .../drivers/radeon/radeon_setup_tgsi_llvm.c|   33 ++--
 2 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_llvm.h 
b/src/gallium/drivers/radeon/radeon_llvm.h
index 00714fb..8612ef8 100644
--- a/src/gallium/drivers/radeon/radeon_llvm.h
+++ b/src/gallium/drivers/radeon/radeon_llvm.h
@@ -33,10 +33,10 @@
 
 #define RADEON_LLVM_MAX_INPUTS 32 * 4
 #define RADEON_LLVM_MAX_OUTPUTS 32 * 4
-#define RADEON_LLVM_MAX_BRANCH_DEPTH 16
-#define RADEON_LLVM_MAX_LOOP_DEPTH 16
 #define RADEON_LLVM_MAX_ARRAYS 16
 
+#define RADEON_LLVM_INITIAL_CF_DEPTH 4
+
 #define RADEON_LLVM_MAX_SYSTEM_VALUES 4
 
 struct radeon_llvm_branch {
@@ -122,11 +122,13 @@ struct radeon_llvm_context {
 
/*=== Private Members ===*/
 
-   struct radeon_llvm_branch branch[RADEON_LLVM_MAX_BRANCH_DEPTH];
-   struct radeon_llvm_loop loop[RADEON_LLVM_MAX_LOOP_DEPTH];
+   struct radeon_llvm_branch *branch;
+   struct radeon_llvm_loop *loop;
 
unsigned branch_depth;
+   unsigned branch_depth_max;
unsigned loop_depth;
+   unsigned loop_depth_max;
 
struct tgsi_declaration_range arrays[RADEON_LLVM_MAX_ARRAYS];
unsigned num_arrays;
diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index 2fa23ed..c30a9d0 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -446,7 +446,19 @@ static void bgnloop_emit(
endloop_block, "LOOP");
LLVMBuildBr(gallivm->builder, loop_block);
LLVMPositionBuilderAtEnd(gallivm->builder, loop_block);
-   ctx->loop_depth++;
+
+   if (++ctx->loop_depth > ctx->loop_depth_max) {
+   unsigned new_max = ctx->loop_depth_max << 1;
+
+   if (!new_max)
+   new_max = RADEON_LLVM_INITIAL_CF_DEPTH;
+
+   ctx->loop = REALLOC(ctx->loop, ctx->loop_depth_max *
+   sizeof(ctx->loop[0]),
+   new_max * sizeof(ctx->loop[0]));
+   ctx->loop_depth_max = new_max;
+   }
+
ctx->loop[ctx->loop_depth - 1].loop_block = loop_block;
ctx->loop[ctx->loop_depth - 1].endloop_block = endloop_block;
 }
@@ -577,7 +589,18 @@ static void if_cond_emit(
LLVMBuildCondBr(gallivm->builder, cond, if_block, else_block);
LLVMPositionBuilderAtEnd(gallivm->builder, if_block);
 
-   ctx->branch_depth++;
+   if (++ctx->branch_depth > ctx->branch_depth_max) {
+   unsigned new_max = ctx->branch_depth_max << 1;
+
+   if (!new_max)
+   new_max = RADEON_LLVM_INITIAL_CF_DEPTH;
+
+   ctx->branch = REALLOC(ctx->branch, ctx->branch_depth_max *
+ sizeof(ctx->branch[0]),
+ new_max * sizeof(ctx->branch[0]));
+   ctx->branch_depth_max = new_max;
+   }
+
ctx->branch[ctx->branch_depth - 1].endif_block = endif_block;
ctx->branch[ctx->branch_depth - 1].if_block = if_block;
ctx->branch[ctx->branch_depth - 1].else_block = else_block;
@@ -1440,4 +1463,10 @@ void radeon_llvm_dispose(struct radeon_llvm_context * 
ctx)
LLVMContextDispose(ctx->soa.bld_base.base.gallivm->context);
FREE(ctx->temps);
ctx->temps = NULL;
+   FREE(ctx->loop);
+   ctx->loop = NULL;
+   ctx->loop_depth_max = 0;
+   FREE(ctx->branch);
+   ctx->branch = NULL;
+   ctx->branch_depth_max = 0;
 }

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


Mesa (master): r600g: Drop references to destroyed blend state

2014-10-22 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: ae879718c4086fc5905070e7f26dfa2757df0c86
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ae879718c4086fc5905070e7f26dfa2757df0c86

Author: Michel Dänzer 
Date:   Tue Oct 21 12:40:15 2014 +0900

r600g: Drop references to destroyed blend state

Fixes use-after-free when the currently bound blend state is destroyed.

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

Reviewed-by: Marek Olšák 
Tested-by: Dieter Nützel 

Cc: mesa-sta...@lists.freedesktop.org

---

 src/gallium/drivers/r600/r600_state_common.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/r600_state_common.c 
b/src/gallium/drivers/r600/r600_state_common.c
index 68365f9..879ec35 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -158,8 +158,10 @@ static void r600_bind_blend_state(struct pipe_context 
*ctx, void *state)
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_blend_state *blend = (struct r600_blend_state *)state;
 
-   if (blend == NULL)
+   if (blend == NULL) {
+   r600_set_cso_state_with_cb(&rctx->blend_state, NULL, NULL);
return;
+   }
 
r600_bind_blend_state_internal(rctx, blend, rctx->force_blend_disable);
 }
@@ -447,8 +449,13 @@ static void r600_delete_sampler_state(struct pipe_context 
*ctx, void *state)
 
 static void r600_delete_blend_state(struct pipe_context *ctx, void *state)
 {
+   struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_blend_state *blend = (struct r600_blend_state*)state;
 
+   if (rctx->blend_state.cso == state) {
+   ctx->bind_blend_state(ctx, NULL);
+   }
+
r600_release_command_buffer(&blend->buffer);
r600_release_command_buffer(&blend->buffer_no_blend);
FREE(blend);

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


Mesa (master): winsys/radeon: Use a single buffer cache manager again

2014-10-17 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: c4db733facd01f8f7503dec662ff79d278b103c1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c4db733facd01f8f7503dec662ff79d278b103c1

Author: Michel Dänzer 
Date:   Thu Oct 16 15:10:20 2014 +0900

winsys/radeon: Use a single buffer cache manager again

The trick is to generate a unique buffer usage value for each possible
combination of domains and flags, with only one bit set each for the
domains and flags. This ensures pb_check_usage() only returns TRUE when
the domains and flags the cached buffer was created for exactly match
the requested ones.

Reviewed-by: Marek Olšák 

---

 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |   23 +---
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c |   30 +
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.h |5 +---
 3 files changed, 21 insertions(+), 37 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 9518e53..2cfa43b 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -816,21 +816,24 @@ radeon_winsys_bo_create(struct radeon_winsys *rws,
 memset(&desc, 0, sizeof(desc));
 desc.base.alignment = alignment;
 
-/* Additional criteria for the cache manager. */
-desc.base.usage = domain;
+/* Only set one usage bit each for domains and flags, or the cache manager
+ * might consider different sets of domains / flags compatible
+ */
+if (domain == RADEON_DOMAIN_VRAM_GTT)
+desc.base.usage = 1 << 2;
+else
+desc.base.usage = domain >> 1;
+assert(flags < sizeof(desc.base.usage) * 8 - 3);
+desc.base.usage |= 1 << (flags + 3);
+
 desc.initial_domains = domain;
 desc.flags = flags;
 
 /* Assign a buffer manager. */
-assert(flags < RADEON_NUM_CACHE_MANAGERS);
-if (use_reusable_pool) {
-if (domain == RADEON_DOMAIN_VRAM)
-provider = ws->cman_vram[flags];
-else
-provider = ws->cman_gtt[flags];
-} else {
+if (use_reusable_pool)
+provider = ws->cman;
+else
 provider = ws->kman;
-}
 
 buffer = provider->create_buffer(provider, size, &desc.base);
 if (!buffer)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index c67549e..caba373 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -441,7 +441,6 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
 static void radeon_winsys_destroy(struct radeon_winsys *rws)
 {
 struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)rws;
-int i;
 
 if (ws->thread) {
 ws->kill_thread = 1;
@@ -454,10 +453,7 @@ static void radeon_winsys_destroy(struct radeon_winsys 
*rws)
 pipe_mutex_destroy(ws->cmask_owner_mutex);
 pipe_mutex_destroy(ws->cs_stack_lock);
 
-for (i = 0; i < RADEON_NUM_CACHE_MANAGERS; i++) {
-ws->cman_gtt[i]->destroy(ws->cman_gtt[i]);
-ws->cman_vram[i]->destroy(ws->cman_vram[i]);
-}
+ws->cman->destroy(ws->cman);
 ws->kman->destroy(ws->kman);
 if (ws->gen >= DRV_R600) {
 radeon_surface_manager_free(ws->surf_man);
@@ -644,7 +640,6 @@ PUBLIC struct radeon_winsys *
 radeon_drm_winsys_create(int fd, radeon_screen_create_t screen_create)
 {
 struct radeon_drm_winsys *ws;
-int i;
 
 pipe_mutex_lock(fd_tab_mutex);
 if (!fd_tab) {
@@ -674,17 +669,10 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t 
screen_create)
 if (!ws->kman)
 goto fail;
 
-for (i = 0; i < RADEON_NUM_CACHE_MANAGERS; i++) {
-ws->cman_vram[i] = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
-   ws->info.vram_size / 8);
-if (!ws->cman_vram[i])
-goto fail;
-
-ws->cman_gtt[i] = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
-  ws->info.gart_size / 8);
-if (!ws->cman_gtt[i])
-goto fail;
-}
+ws->cman = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
+   (ws->info.vram_size + 
ws->info.gart_size) / 8);
+if (!ws->cman)
+goto fail;
 
 if (ws->gen >= DRV_R600) {
 ws->surf_man = radeon_surface_manager_new(fd);
@@ -739,12 +727,8 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t 
screen_create)
 
 fail:
 pipe_mutex_unlock(fd_tab_mutex);
-for (i = 0; i < RADEON_NUM_CACHE_MANAGERS; i++) {
-if (ws->cman_gtt[i])
-ws->cman_gtt[i]->destroy(ws->cman_gtt[i]);
-if (ws->cman_vram[i])
-ws->cman_vram[i]->de

Mesa (master): r600g, radeonsi: Only set use_staging_texture = TRUE once

2014-10-15 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 159f93cf398fd301345f82ee0b10300cc523962b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=159f93cf398fd301345f82ee0b10300cc523962b

Author: Michel Dänzer 
Date:   Wed Oct  8 16:05:36 2014 +0900

r600g,radeonsi: Only set use_staging_texture = TRUE once

No need to check for setting the flag after we set it already.

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeon/r600_texture.c |   13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index 13df495..1d4e966 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -924,19 +924,16 @@ static void *r600_texture_transfer_map(struct 
pipe_context *ctx,
 * the CPU is much happier reading out of cached system memory
 * than uncached VRAM.
 */
-   if (rtex->surface.level[0].mode >= RADEON_SURF_MODE_1D)
+   if (rtex->surface.level[0].mode >= RADEON_SURF_MODE_1D) {
use_staging_texture = TRUE;
-
-   /* Untiled buffers in VRAM, which is slow for CPU reads */
-   if ((usage & PIPE_TRANSFER_READ) && !(usage & 
PIPE_TRANSFER_MAP_DIRECTLY) &&
+   } else if ((usage & PIPE_TRANSFER_READ) && !(usage & 
PIPE_TRANSFER_MAP_DIRECTLY) &&
(rtex->resource.domains == RADEON_DOMAIN_VRAM)) {
+   /* Untiled buffers in VRAM, which is slow for CPU reads */
use_staging_texture = TRUE;
-   }
-
-   /* Use a staging texture for uploads if the underlying BO is busy. */
-   if (!(usage & PIPE_TRANSFER_READ) &&
+   } else if (!(usage & PIPE_TRANSFER_READ) &&
(r600_rings_is_buffer_referenced(rctx, rtex->resource.cs_buf, 
RADEON_USAGE_READWRITE) ||
 rctx->ws->buffer_is_busy(rtex->resource.buf, 
RADEON_USAGE_READWRITE))) {
+   /* Use a staging texture for uploads if the underlying BO is 
busy. */
use_staging_texture = TRUE;
}
 

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


Mesa (master): winsys/radeon: Use separate caching buffer manager for each set of flags

2014-10-15 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 3ede67a4c6d77892296ffc5568ddf3accaa1af99
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ede67a4c6d77892296ffc5568ddf3accaa1af99

Author: Michel Dänzer 
Date:   Wed Oct  8 16:34:46 2014 +0900

winsys/radeon: Use separate caching buffer manager for each set of flags

Otherwise the caching buffer manager may return a buffer which was created
with a different set of flags, which can cause trouble.

Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Marek Olšák 

---

 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |   15 +++
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c |   50 ++---
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.h |8 ++--
 3 files changed, 32 insertions(+), 41 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index e61e9fd..9518e53 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -822,17 +822,12 @@ radeon_winsys_bo_create(struct radeon_winsys *rws,
 desc.flags = flags;
 
 /* Assign a buffer manager. */
+assert(flags < RADEON_NUM_CACHE_MANAGERS);
 if (use_reusable_pool) {
-if (domain == RADEON_DOMAIN_VRAM) {
-if (flags & RADEON_FLAG_GTT_WC)
-provider = ws->cman_vram_gtt_wc;
-else
-provider = ws->cman_vram;
-} else if (flags & RADEON_FLAG_GTT_WC) {
-provider = ws->cman_gtt_wc;
-} else {
-provider = ws->cman_gtt;
-}
+if (domain == RADEON_DOMAIN_VRAM)
+provider = ws->cman_vram[flags];
+else
+provider = ws->cman_gtt[flags];
 } else {
 provider = ws->kman;
 }
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 3b695f9..c67549e 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -441,6 +441,7 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
 static void radeon_winsys_destroy(struct radeon_winsys *rws)
 {
 struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)rws;
+int i;
 
 if (ws->thread) {
 ws->kill_thread = 1;
@@ -453,10 +454,10 @@ static void radeon_winsys_destroy(struct radeon_winsys 
*rws)
 pipe_mutex_destroy(ws->cmask_owner_mutex);
 pipe_mutex_destroy(ws->cs_stack_lock);
 
-ws->cman_vram->destroy(ws->cman_vram);
-ws->cman_vram_gtt_wc->destroy(ws->cman_vram_gtt_wc);
-ws->cman_gtt->destroy(ws->cman_gtt);
-ws->cman_gtt_wc->destroy(ws->cman_gtt_wc);
+for (i = 0; i < RADEON_NUM_CACHE_MANAGERS; i++) {
+ws->cman_gtt[i]->destroy(ws->cman_gtt[i]);
+ws->cman_vram[i]->destroy(ws->cman_vram[i]);
+}
 ws->kman->destroy(ws->kman);
 if (ws->gen >= DRV_R600) {
 radeon_surface_manager_free(ws->surf_man);
@@ -643,6 +644,7 @@ PUBLIC struct radeon_winsys *
 radeon_drm_winsys_create(int fd, radeon_screen_create_t screen_create)
 {
 struct radeon_drm_winsys *ws;
+int i;
 
 pipe_mutex_lock(fd_tab_mutex);
 if (!fd_tab) {
@@ -671,22 +673,18 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t 
screen_create)
 ws->kman = radeon_bomgr_create(ws);
 if (!ws->kman)
 goto fail;
-ws->cman_vram = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
-ws->info.vram_size / 8);
-if (!ws->cman_vram)
-goto fail;
-ws->cman_vram_gtt_wc = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
+
+for (i = 0; i < RADEON_NUM_CACHE_MANAGERS; i++) {
+ws->cman_vram[i] = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
ws->info.vram_size / 8);
-if (!ws->cman_vram_gtt_wc)
-goto fail;
-ws->cman_gtt = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
-   ws->info.gart_size / 8);
-if (!ws->cman_gtt)
-goto fail;
-ws->cman_gtt_wc = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
-  ws->info.gart_size / 8);
-if (!ws->cman_gtt_wc)
-goto fail;
+if (!ws->cman_vram[i])
+goto fail;
+
+ws->cman_gtt[i] = pb_cache_manager_create(ws->kman, 100, 2.0f, 0,
+  ws->info.gart_size / 8);
+if (!ws->cman_gtt[i])
+goto fail;
+}
 
 if (ws->gen >= DRV_R600) {
 ws->surf_man = radeon_surface_manager_new(fd);
@@ -741,14 +739,12 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t 
screen_create)
 
 fail:
 pipe_mute

Mesa (master): r600g,radeonsi: Use staging texture for transfers if any miplevel is tiled

2014-10-15 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 87da286755ea09b6efab591a124c261fde890ba8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=87da286755ea09b6efab591a124c261fde890ba8

Author: Michel Dänzer 
Date:   Wed Oct  8 16:01:47 2014 +0900

r600g,radeonsi: Use staging texture for transfers if any miplevel is tiled

We set the NO_CPU_ACCESS flag for BO allocation in that case, so direct CPU
access may not work.

Reviewed-by: Marek Olšák 

---

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

diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index 17aca01..13df495 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -924,7 +924,7 @@ static void *r600_texture_transfer_map(struct pipe_context 
*ctx,
 * the CPU is much happier reading out of cached system memory
 * than uncached VRAM.
 */
-   if (rtex->surface.level[level].mode >= RADEON_SURF_MODE_1D)
+   if (rtex->surface.level[0].mode >= RADEON_SURF_MODE_1D)
use_staging_texture = TRUE;
 
/* Untiled buffers in VRAM, which is slow for CPU reads */

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


Mesa (master): r600g,radeonsi: Always use GTT again for PIPE_USAGE_STREAM buffers

2014-10-09 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 7b4276d7acf2e0f77044cb50caa6ad936fa78786
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b4276d7acf2e0f77044cb50caa6ad936fa78786

Author: Michel Dänzer 
Date:   Tue Aug 26 18:21:50 2014 +0900

r600g,radeonsi: Always use GTT again for PIPE_USAGE_STREAM buffers

Putting those in VRAM can cause long pauses due to buffers being moved
into / out of VRAM.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
Cc: mesa-sta...@lists.freedesktop.org
Reviewed-by: Alex Deucher 

---

 src/gallium/drivers/radeon/r600_buffer_common.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
b/src/gallium/drivers/radeon/r600_buffer_common.c
index 227a221..b7306d7 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -110,11 +110,13 @@ bool r600_init_resource(struct r600_common_screen 
*rscreen,
enum radeon_bo_flag flags = 0;
 
switch (res->b.b.usage) {
+   case PIPE_USAGE_STREAM:
+   flags = RADEON_FLAG_GTT_WC;
+   /* fall through */
case PIPE_USAGE_STAGING:
/* Transfers are likely to occur more often with these 
resources. */
res->domains = RADEON_DOMAIN_GTT;
break;
-   case PIPE_USAGE_STREAM:
case PIPE_USAGE_DYNAMIC:
/* Older kernels didn't always flush the HDP cache before
 * CS execution

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


Mesa (master): radeonsi: Use dummy pixel shader if compilation of the real shader failed

2014-10-06 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: be0a994fb8689131bf6a717c1e6fa5a42c3d4657
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=be0a994fb8689131bf6a717c1e6fa5a42c3d4657

Author: Michel Dänzer 
Date:   Mon Oct  6 17:05:38 2014 +0900

radeonsi: Use dummy pixel shader if compilation of the real shader failed

Instead of crashing.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79155#c5
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_state.c  |   18 +++---
 src/gallium/drivers/radeonsi/si_state.h  |1 +
 src/gallium/drivers/radeonsi/si_state_draw.c |   10 ++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 57bfa59..0166798 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2373,6 +2373,16 @@ static void si_bind_gs_shader(struct pipe_context *ctx, 
void *state)
sctx->gs_shader = sel;
 }
 
+void si_make_dummy_ps(struct si_context *sctx)
+{
+   if (!sctx->dummy_pixel_shader) {
+   sctx->dummy_pixel_shader =
+   util_make_fragment_cloneinput_shader(&sctx->b.b, 0,
+
TGSI_SEMANTIC_GENERIC,
+
TGSI_INTERPOLATE_CONSTANT);
+   }
+}
+
 static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
 {
struct si_context *sctx = (struct si_context *)ctx;
@@ -2384,13 +2394,7 @@ static void si_bind_ps_shader(struct pipe_context *ctx, 
void *state)
 
/* use a dummy shader if binding a NULL shader */
if (!sel) {
-   if (!sctx->dummy_pixel_shader) {
-   sctx->dummy_pixel_shader =
-   
util_make_fragment_cloneinput_shader(&sctx->b.b, 0,
-
TGSI_SEMANTIC_GENERIC,
-
TGSI_INTERPOLATE_CONSTANT);
-   }
-
+   si_make_dummy_ps(sctx);
sel = sctx->dummy_pixel_shader;
}
 
diff --git a/src/gallium/drivers/radeonsi/si_state.h 
b/src/gallium/drivers/radeonsi/si_state.h
index 7b6de6b..f70bddf 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -257,6 +257,7 @@ boolean si_is_format_supported(struct pipe_screen *screen,
unsigned usage);
 int si_shader_select(struct pipe_context *ctx,
 struct si_shader_selector *sel);
+void si_make_dummy_ps(struct si_context *sctx);
 void si_init_state_functions(struct si_context *sctx);
 void si_init_config(struct si_context *sctx);
 unsigned cik_bank_wh(unsigned bankwh);
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
b/src/gallium/drivers/radeonsi/si_state_draw.c
index e8d84a9..c9e4353 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -662,6 +662,16 @@ static void si_update_derived_state(struct si_context 
*sctx)
 
si_shader_select(ctx, sctx->ps_shader);
 
+   if (!sctx->ps_shader->current) {
+   struct si_shader_selector *sel;
+
+   /* use a dummy shader if compiling the shader (variant) failed 
*/
+   si_make_dummy_ps(sctx);
+   sel = sctx->dummy_pixel_shader;
+   si_shader_select(ctx, sel);
+   sctx->ps_shader->current = sel->current;
+   }
+
if (!sctx->ps_shader->current->pm4)
si_shader_ps(ctx, sctx->ps_shader->current);
 

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


Mesa (master): radeonsi: Clear sampler view flags when binding a buffer

2014-10-02 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: ed03747e6a1a0655bfd0b5e4a52455fbd37f97c5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ed03747e6a1a0655bfd0b5e4a52455fbd37f97c5

Author: Michel Dänzer 
Date:   Thu Oct  2 16:00:26 2014 +0900

radeonsi: Clear sampler view flags when binding a buffer

Fixes assertion failure while running the Unreal Engine 4 Elemental demo:

.../si_blit.c:322:si_decompress_color_textures: Assertion `tex->cmask.size || 
tex->fmask.size' failed.

Cc: "10.2 10.3" 
Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_descriptors.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index fc535d0..9227034 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -422,6 +422,11 @@ static void si_set_sampler_views(struct pipe_context *ctx,
si_set_sampler_view(sctx, shader, 
SI_FMASK_TEX_OFFSET + slot,
NULL, NULL);
}
+   } else {
+   samplers->depth_texture_mask &= ~(1 << slot);
+   samplers->compressed_colortex_mask &= ~(1 << slot);
+   si_set_sampler_view(sctx, shader, SI_FMASK_TEX_OFFSET + 
slot,
+   NULL, NULL);
}
}
 

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


Mesa (master): radeonsi: Pass the slice size to si_dma_copy_buffer

2014-09-30 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 61128d750789fa5e3947cb50b165bac5ebb3265e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=61128d750789fa5e3947cb50b165bac5ebb3265e

Author: Michel Dänzer 
Date:   Tue Sep 30 11:16:52 2014 +0900

radeonsi: Pass the slice size to si_dma_copy_buffer

Otherwise some parts of tiled slices can be missed.

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_dma.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_dma.c 
b/src/gallium/drivers/radeonsi/si_dma.c
index 643ce3f..b1bd5e7 100644
--- a/src/gallium/drivers/radeonsi/si_dma.c
+++ b/src/gallium/drivers/radeonsi/si_dma.c
@@ -231,7 +231,7 @@ void si_dma_copy(struct pipe_context *ctx,
struct si_context *sctx = (struct si_context *)ctx;
struct r600_texture *rsrc = (struct r600_texture*)src;
struct r600_texture *rdst = (struct r600_texture*)dst;
-   unsigned dst_pitch, src_pitch, bpp, dst_mode, src_mode, copy_height;
+   unsigned dst_pitch, src_pitch, bpp, dst_mode, src_mode;
unsigned src_w, dst_w;
unsigned src_x, src_y;
unsigned dst_x = dstx, dst_y = dsty, dst_z = dstz;
@@ -271,7 +271,6 @@ void si_dma_copy(struct pipe_context *ctx,
src_pitch = rsrc->surface.level[src_level].pitch_bytes;
src_w = rsrc->surface.level[src_level].npix_x;
dst_w = rdst->surface.level[dst_level].npix_x;
-   copy_height = src_box->height / rsrc->surface.blk_h;
 
dst_mode = rdst->surface.level[dst_level].mode;
src_mode = rsrc->surface.level[src_level].mode;
@@ -310,11 +309,12 @@ void si_dma_copy(struct pipe_context *ctx,
dst_offset += rdst->surface.level[dst_level].slice_size * dst_z;
dst_offset += dst_y * dst_pitch + dst_x * bpp;
si_dma_copy_buffer(sctx, dst, src, dst_offset, src_offset,
-  copy_height * src_pitch);
+  rsrc->surface.level[src_level].slice_size);
} else {
si_dma_copy_tile(sctx, dst, dst_level, dst_x, dst_y, dst_z,
 src, src_level, src_x, src_y, src_box->z,
-copy_height, dst_pitch, bpp);
+src_box->height / rsrc->surface.blk_h,
+dst_pitch, bpp);
}
return;
 

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


Mesa (master): radeonsi: Fix tiling mode index for stencil resources

2014-09-30 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 761d80ddab9ce854dc964b2023bc4fbc734fafc7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=761d80ddab9ce854dc964b2023bc4fbc734fafc7

Author: Michel Dänzer 
Date:   Wed Sep 10 10:57:58 2014 +0900

radeonsi: Fix tiling mode index for stencil resources

We are currently only dealing with depth-only or stencil-only resources
here, not with resources having both depth and stencil[0]. In both cases,
the tiling mode index is in the tile_mode field, not in the
stencil_tile_mode field.

[0] Add an assertion for that.

Reviewed-by: Marek Olšák 

---

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

diff --git a/src/gallium/drivers/radeonsi/si_dma.c 
b/src/gallium/drivers/radeonsi/si_dma.c
index c067cd9..cd6ff4a 100644
--- a/src/gallium/drivers/radeonsi/si_dma.c
+++ b/src/gallium/drivers/radeonsi/si_dma.c
@@ -162,6 +162,8 @@ static void si_dma_copy_tile(struct si_context *ctx,
tiled_y = detile ? src_y : dst_y;
tiled_z = detile ? src_z : dst_z;
 
+   assert(!util_format_is_depth_and_stencil(rtiled->resource.b.b.format));
+
array_mode = si_array_mode(rtiled->surface.level[tiled_lvl].mode);
slice_tile_max = (rtiled->surface.level[tiled_lvl].nblk_x *
  rtiled->surface.level[tiled_lvl].nblk_y) / (8*8) - 1;
@@ -179,8 +181,7 @@ static void si_dma_copy_tile(struct si_context *ctx,
bank_w = cik_bank_wh(rtiled->surface.bankw);
mt_aspect = cik_macro_tile_aspect(rtiled->surface.mtilea);
tile_split = cik_tile_split(rtiled->surface.tile_split);
-   tile_mode_index = si_tile_mode_index(rtiled, tiled_lvl,
-
util_format_has_stencil(util_format_description(rtiled->resource.b.b.format)));
+   tile_mode_index = si_tile_mode_index(rtiled, tiled_lvl, false);
nbanks = si_num_banks(sscreen, rtiled);
base += rtiled->resource.gpu_address;
addr += rlinear->resource.gpu_address;

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


Mesa (master): radeonsi: Fix si_dma_copy(_tile) for compressed formats

2014-09-30 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: d17b85524dfd74824a2135d5d4112a1fae86ed17
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d17b85524dfd74824a2135d5d4112a1fae86ed17

Author: Michel Dänzer 
Date:   Wed Sep 10 18:43:56 2014 +0900

radeonsi: Fix si_dma_copy(_tile) for compressed formats

Fixes GPUVM faults when running the piglit test "getteximage-formats
init-by-rendering" with R600_DEBUG=forcedma on SI.

Reviewed-by: Marek Olšák 

---

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

diff --git a/src/gallium/drivers/radeonsi/si_dma.c 
b/src/gallium/drivers/radeonsi/si_dma.c
index cd6ff4a..ff64722 100644
--- a/src/gallium/drivers/radeonsi/si_dma.c
+++ b/src/gallium/drivers/radeonsi/si_dma.c
@@ -172,7 +172,7 @@ static void si_dma_copy_tile(struct si_context *ctx,
 * dma packet will be using the copy_height which is always smaller or 
equal
 * to the linear height
 */
-   height = rtiled->surface.level[tiled_lvl].npix_y;
+   height = rtiled->surface.level[tiled_lvl].nblk_y;
base = rtiled->surface.level[tiled_lvl].offset;
addr = rlinear->surface.level[linear_lvl].offset;
addr += rlinear->surface.level[linear_lvl].slice_size * linear_z;
@@ -302,7 +302,7 @@ void si_dma_copy(struct pipe_context *ctx,
dst_offset += rdst->surface.level[dst_level].slice_size * dst_z;
dst_offset += dst_y * dst_pitch + dst_x * bpp;
si_dma_copy_buffer(sctx, dst, src, dst_offset, src_offset,
-   src_box->height * src_pitch);
+  copy_height * src_pitch);
} else {
si_dma_copy_tile(sctx, dst, dst_level, dst_x, dst_y, dst_z,
 src, src_level, src_x, src_y, src_box->z,

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


Mesa (master): radeonsi: Catch more cases that can' t be handled by si_dma_copy_buffer/tile

2014-09-30 Thread Michel Dänzer
Module: Mesa
Branch: master
Commit: 74aeccd701c13851e69120d562fe5e899b10fb93
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=74aeccd701c13851e69120d562fe5e899b10fb93

Author: Michel Dänzer 
Date:   Thu Sep 11 11:49:16 2014 +0900

radeonsi: Catch more cases that can't be handled by si_dma_copy_buffer/tile

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_dma.c |   14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_dma.c 
b/src/gallium/drivers/radeonsi/si_dma.c
index ff64722..643ce3f 100644
--- a/src/gallium/drivers/radeonsi/si_dma.c
+++ b/src/gallium/drivers/radeonsi/si_dma.c
@@ -251,7 +251,9 @@ void si_dma_copy(struct pipe_context *ctx,
}
 
if (src->format != dst->format || src_box->depth > 1 ||
-   rdst->dirty_level_mask != 0) {
+   rdst->dirty_level_mask != 0 ||
+   rdst->cmask.size || rdst->fmask.size ||
+   rsrc->cmask.size || rsrc->fmask.size) {
goto fallback;
}
 
@@ -277,14 +279,20 @@ void si_dma_copy(struct pipe_context *ctx,
src_mode = src_mode == RADEON_SURF_MODE_LINEAR_ALIGNED ? 
RADEON_SURF_MODE_LINEAR : src_mode;
dst_mode = dst_mode == RADEON_SURF_MODE_LINEAR_ALIGNED ? 
RADEON_SURF_MODE_LINEAR : dst_mode;
 
-   if (src_pitch != dst_pitch || src_box->x || dst_x || src_w != dst_w) {
+   if (src_pitch != dst_pitch || src_box->x || dst_x || src_w != dst_w ||
+   src_box->width != src_w ||
+   src_box->height != rsrc->surface.level[src_level].npix_y ||
+   src_box->height != rdst->surface.level[dst_level].npix_y ||
+   rsrc->surface.level[src_level].nblk_y !=
+   rdst->surface.level[dst_level].nblk_y) {
/* FIXME si can do partial blit */
goto fallback;
}
/* the x test here are currently useless (because we don't support 
partial blit)
 * but keep them around so we don't forget about those
 */
-   if ((src_pitch % 8) || (src_box->x % 8) || (dst_x % 8) || (src_box->y % 
8) || (dst_y % 8)) {
+   if ((src_pitch % 8) || (src_box->x % 8) || (dst_x % 8) ||
+   (src_box->y % 8) || (dst_y % 8) || (src_box->height % 8)) {
goto fallback;
}
 

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


  1   2   3   4   5   6   7   8   >