Re: [Mesa-dev] [PATCH 2/2] drisw: Use separate drisw_loader_funcs for shm

2018-11-23 Thread Emil Velikov
Hi Michal,

On 2018/11/23, Michal Srb wrote:
> The original code was modifying the global drisw_lf variable, which is bad
> when there are multiple contexts in single process, each initialized with
> different loader. One may support put_image_shm and the other not.
> 
> Since there are currently only two possible combinations, lets create two
> global tables, one for each. Lets make them const, since we won't change them
> and they can be shared.
> 
When possible, please mention the commit which "breaks" things, like
below. It helps highlight exactly where a backport/cherry-pick is
applicable.

Fixes: 63c427fa71a ("drisw: use putImageShm if available")

> Signed-off-by: Michal Srb 
> ---
> This fixes crash in VLC. It used two GL contexts (each in different thread), 
> one
> was initialized by its Qt GUI, the other by its video output plugin. The first
> one set the put_image_shm=drisw_put_image_shm, the second did not, but
> since the same structure was used, the drisw_put_image_shm was used too. Then
> it crashed because the second loader did not have putImageShm set.
> 
> Downstream bug:
> https://bugzilla.opensuse.org/show_bug.cgi?id=1113533
> 
Personally, I'd keep the extra note about VLC and downstream bug in the
commit message. Although if you prefer let's keep it as-is.

For the series:
Reviewed-by: Emil Velikov 

I'll push this early/mid next weeks, unless someone beats me to it.

Thanks
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/7] radv: add radv_image_view_can_fast_clear() helper

2018-11-23 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_meta_clear.c | 47 ++--
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index d9acd194ce5..9c124c9b677 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -909,6 +909,31 @@ radv_image_can_fast_clear(struct radv_device *device,  
struct radv_image *image)
return true;
 }
 
+/**
+ * Determine if the given image view can be fast cleared.
+ */
+static bool
+radv_image_view_can_fast_clear(struct radv_device *device,
+  const struct radv_image_view *iview)
+{
+   struct radv_image *image = iview->image;
+
+   /* Only fast clear if the image itself can be fast cleared. */
+   if (!radv_image_can_fast_clear(device, image))
+   return false;
+
+   /* Only fast clear if all layers are bound. */
+   if (iview->base_layer > 0 ||
+   iview->layer_count != image->info.array_size)
+   return false;
+
+   /* Only fast clear if the view covers the whole image. */
+   if (!radv_image_extent_compare(image, >extent))
+   return false;
+
+   return true;
+}
+
 static bool
 emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
  const VkClearAttachment *clear_att,
@@ -926,21 +951,12 @@ emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
uint32_t clear_word, flush_bits;
uint32_t htile_mask;
 
-   if (!radv_image_can_fast_clear(cmd_buffer->device, iview->image))
+   if (!radv_image_view_can_fast_clear(cmd_buffer->device, iview))
return false;
 
if (!radv_layout_is_htile_compressed(iview->image, image_layout, 
radv_image_queue_family_mask(iview->image, cmd_buffer->queue_family_index, 
cmd_buffer->queue_family_index)))
return false;
 
-   /* all layers are bound */
-   if (iview->base_layer > 0)
-   return false;
-   if (iview->image->info.array_size != iview->layer_count)
-   return false;
-
-   if (!radv_image_extent_compare(iview->image, >extent))
-   return false;
-
if (clear_rect->rect.offset.x || clear_rect->rect.offset.y ||
clear_rect->rect.extent.width != iview->image->info.width ||
clear_rect->rect.extent.height != iview->image->info.height)
@@ -1369,21 +1385,12 @@ emit_fast_color_clear(struct radv_cmd_buffer 
*cmd_buffer,
uint32_t cmask_clear_value;
bool ret;
 
-   if (!radv_image_can_fast_clear(cmd_buffer->device, iview->image))
+   if (!radv_image_view_can_fast_clear(cmd_buffer->device, iview))
return false;
 
if (!radv_layout_can_fast_clear(iview->image, image_layout, 
radv_image_queue_family_mask(iview->image, cmd_buffer->queue_family_index, 
cmd_buffer->queue_family_index)))
return false;
 
-   /* all layers are bound */
-   if (iview->base_layer > 0)
-   return false;
-   if (iview->image->info.array_size != iview->layer_count)
-   return false;
-
-   if (!radv_image_extent_compare(iview->image, >extent))
-   return false;
-
if (clear_rect->rect.offset.x || clear_rect->rect.offset.y ||
clear_rect->rect.extent.width != iview->image->info.width ||
clear_rect->rect.extent.height != iview->image->info.height)
-- 
2.19.1

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


[Mesa-dev] [PATCH 1/7] radv: remove useless check in emit_fast_color_clear()

2018-11-23 Thread Samuel Pitoiset
The driver doesn't support DCC/CMASK for mipmapped textures.

Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_meta_clear.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index f2f5cb32eb9..26bc5e75ef3 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -1366,9 +1366,6 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
if (iview->image->info.array_size != iview->layer_count)
return false;
 
-   if (iview->image->info.levels > 1)
-   return false;
-
if (!radv_image_extent_compare(iview->image, >extent))
return false;
 
-- 
2.19.1

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


[Mesa-dev] [PATCH 6/7] radv: refactor the fast clear path for better re-use

2018-11-23 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_meta_clear.c | 78 
 1 file changed, 40 insertions(+), 38 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 37b743e994a..d4da614584b 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -973,27 +973,18 @@ radv_can_fast_clear_depth(struct radv_cmd_buffer 
*cmd_buffer,
return true;
 }
 
-static bool
-emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
+static void
+radv_fast_clear_depth(struct radv_cmd_buffer *cmd_buffer,
+ const struct radv_image_view *iview,
  const VkClearAttachment *clear_att,
- const VkClearRect *clear_rect,
  enum radv_cmd_flush_bits *pre_flush,
  enum radv_cmd_flush_bits *post_flush)
 {
-   const struct radv_subpass *subpass = cmd_buffer->state.subpass;
-   const uint32_t pass_att = subpass->depth_stencil_attachment.attachment;
-   VkImageLayout image_layout = subpass->depth_stencil_attachment.layout;
-   const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
-   const struct radv_image_view *iview = 
fb->attachments[pass_att].attachment;
VkClearDepthStencilValue clear_value = 
clear_att->clearValue.depthStencil;
VkImageAspectFlags aspects = clear_att->aspectMask;
uint32_t clear_word, flush_bits;
uint32_t htile_mask;
 
-   if (!radv_can_fast_clear_depth(cmd_buffer, iview, image_layout, aspects,
-  clear_rect, clear_value))
-   return false;
-
clear_word = radv_get_htile_fast_clear_value(iview->image, clear_value);
htile_mask = radv_get_htile_mask(iview->image, aspects);
 
@@ -1021,8 +1012,6 @@ emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
if (post_flush) {
*post_flush |= flush_bits;
}
-
-   return true;
 }
 
 static nir_shader *
@@ -1440,28 +1429,18 @@ radv_can_fast_clear_color(struct radv_cmd_buffer 
*cmd_buffer,
 }
 
 
-static bool
-emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
+static void
+radv_fast_clear_color(struct radv_cmd_buffer *cmd_buffer,
+ const struct radv_image_view *iview,
  const VkClearAttachment *clear_att,
- const VkClearRect *clear_rect,
+ uint32_t subpass_att,
  enum radv_cmd_flush_bits *pre_flush,
- enum radv_cmd_flush_bits *post_flush,
-  uint32_t view_mask)
+ enum radv_cmd_flush_bits *post_flush)
 {
-   const struct radv_subpass *subpass = cmd_buffer->state.subpass;
-   const uint32_t subpass_att = clear_att->colorAttachment;
-   const uint32_t pass_att = 
subpass->color_attachments[subpass_att].attachment;
-   VkImageLayout image_layout = 
subpass->color_attachments[subpass_att].layout;
-   const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
-   const struct radv_image_view *iview = 
fb->attachments[pass_att].attachment;
VkClearColorValue clear_value = clear_att->clearValue.color;
uint32_t clear_color[2], flush_bits = 0;
uint32_t cmask_clear_value;
 
-   if (!radv_can_fast_clear_color(cmd_buffer, iview, image_layout,
-  clear_rect, clear_value, view_mask))
-   return false;
-
if (pre_flush) {
cmd_buffer->state.flush_bits |= (RADV_CMD_FLAG_FLUSH_AND_INV_CB 
|
 
RADV_CMD_FLAG_FLUSH_AND_INV_CB_META) & ~ *pre_flush;
@@ -1508,8 +1487,6 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
 
radv_update_color_clear_metadata(cmd_buffer, iview->image, subpass_att,
 clear_color);
-
-   return true;
 }
 
 /**
@@ -1523,16 +1500,41 @@ emit_clear(struct radv_cmd_buffer *cmd_buffer,
enum radv_cmd_flush_bits *post_flush,
uint32_t view_mask)
 {
-   if (clear_att->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) {
-   if (!emit_fast_color_clear(cmd_buffer, clear_att, clear_rect,
-  pre_flush, post_flush, view_mask))
+   const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
+   const struct radv_subpass *subpass = cmd_buffer->state.subpass;
+   VkImageAspectFlags aspects = clear_att->aspectMask;
+
+   if (aspects & VK_IMAGE_ASPECT_COLOR_BIT) {
+   const uint32_t subpass_att = clear_att->colorAttachment;
+   const uint32_t pass_att = 
subpass->color_attachments[subpass_att].attachment;
+   VkImageLayout image_layout = 
subpass->color_attachments[subpass_att].layout;
+   const struct radv_image_view *iview = 
fb->attachments[pass_att].attachment;
+   

[Mesa-dev] [PATCH 2/7] radv: add radv_image_can_fast_clear() helper

2018-11-23 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_meta_clear.c | 68 ++--
 1 file changed, 39 insertions(+), 29 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 26bc5e75ef3..d9acd194ce5 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -872,6 +872,43 @@ 
radv_is_fast_clear_stencil_allowed(VkClearDepthStencilValue value)
return value.stencil == 0;
 }
 
+/**
+ * Determine if the given image can be fast cleared.
+ */
+static bool
+radv_image_can_fast_clear(struct radv_device *device,  struct radv_image 
*image)
+{
+   if (device->instance->debug_flags & RADV_DEBUG_NO_FAST_CLEARS)
+   return false;
+
+   if (vk_format_is_color(image->vk_format)) {
+   if (!radv_image_has_cmask(image) && !radv_image_has_dcc(image))
+   return false;
+
+   /* RB+ doesn't work with CMASK fast clear on Stoney. */
+   if (!radv_image_has_dcc(image) &&
+   device->physical_device->rad_info.family == CHIP_STONEY)
+   return false;
+   } else {
+   if (!radv_image_has_htile(image))
+   return false;
+
+   /* GFX8 only supports 32-bit depth surfaces but we can enable
+* TC-compat HTILE for 16-bit surfaces if no Z planes are
+* compressed. Though, fast HTILE clears don't seem to work.
+*/
+   if (device->physical_device->rad_info.chip_class == VI &&
+   image->vk_format == VK_FORMAT_D16_UNORM)
+   return false;
+   }
+
+   /* Do not fast clears 3D images. */
+   if (image->type == VK_IMAGE_TYPE_3D)
+   return false;
+
+   return true;
+}
+
 static bool
 emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
  const VkClearAttachment *clear_att,
@@ -889,19 +926,12 @@ emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
uint32_t clear_word, flush_bits;
uint32_t htile_mask;
 
-   if (!radv_image_has_htile(iview->image))
-   return false;
-
-   if (cmd_buffer->device->instance->debug_flags & 
RADV_DEBUG_NO_FAST_CLEARS)
+   if (!radv_image_can_fast_clear(cmd_buffer->device, iview->image))
return false;
 
if (!radv_layout_is_htile_compressed(iview->image, image_layout, 
radv_image_queue_family_mask(iview->image, cmd_buffer->queue_family_index, 
cmd_buffer->queue_family_index)))
return false;
 
-   /* don't fast clear 3D */
-   if (iview->image->type == VK_IMAGE_TYPE_3D)
-   return false;
-
/* all layers are bound */
if (iview->base_layer > 0)
return false;
@@ -933,14 +963,6 @@ emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
 !radv_is_fast_clear_stencil_allowed(clear_value)))
return false;
 
-   /* GFX8 only supports 32-bit depth surfaces but we can enable TC-compat
-* HTILE for 16-bit surfaces if no Z planes are compressed. Though,
-* fast HTILE clears don't seem to work.
-*/
-   if (cmd_buffer->device->physical_device->rad_info.chip_class == VI &&
-   iview->image->vk_format == VK_FORMAT_D16_UNORM)
-   return false;
-
clear_word = radv_get_htile_fast_clear_value(iview->image, clear_value);
htile_mask = radv_get_htile_mask(iview->image, aspects);
 
@@ -1347,19 +1369,12 @@ emit_fast_color_clear(struct radv_cmd_buffer 
*cmd_buffer,
uint32_t cmask_clear_value;
bool ret;
 
-   if (!radv_image_has_cmask(iview->image) && 
!radv_image_has_dcc(iview->image))
-   return false;
-
-   if (cmd_buffer->device->instance->debug_flags & 
RADV_DEBUG_NO_FAST_CLEARS)
+   if (!radv_image_can_fast_clear(cmd_buffer->device, iview->image))
return false;
 
if (!radv_layout_can_fast_clear(iview->image, image_layout, 
radv_image_queue_family_mask(iview->image, cmd_buffer->queue_family_index, 
cmd_buffer->queue_family_index)))
return false;
 
-   /* don't fast clear 3D */
-   if (iview->image->type == VK_IMAGE_TYPE_3D)
-   return false;
-
/* all layers are bound */
if (iview->base_layer > 0)
return false;
@@ -1382,11 +1397,6 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
if (!view_mask && clear_rect->layerCount != 
iview->image->info.array_size)
return false;
 
-   /* RB+ doesn't work with CMASK fast clear on Stoney. */
-   if (!radv_image_has_dcc(iview->image) &&
-   cmd_buffer->device->physical_device->rad_info.family == CHIP_STONEY)
-   return false;
-
/* DCC */
ret = radv_format_pack_clear_color(iview->vk_format,
   clear_color, _value);
-- 

[Mesa-dev] [PATCH 5/7] radv: simplify a check in emit_fast_color_clear()

2018-11-23 Thread Samuel Pitoiset
Currently only true if RADV_PERFTEST=dccmsaa is set.

Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_meta_clear.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 6c8ef4958f2..37b743e994a 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -1483,9 +1483,7 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
 _value, _value,
 _avoid_fast_clear_elim);
 
-   if (iview->image->info.samples > 1) {
-   assert(radv_image_has_cmask(iview->image));
-
+   if (radv_image_has_cmask(iview->image)) {
flush_bits = radv_clear_cmask(cmd_buffer, iview->image,
  cmask_clear_value);
 
-- 
2.19.1

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


[Mesa-dev] [PATCH 4/7] radv: add radv_can_fast_clear_{color, depth}() helpers

2018-11-23 Thread Samuel Pitoiset
For further optimisations.

Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_meta_clear.c | 133 +--
 1 file changed, 89 insertions(+), 44 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 9c124c9b677..6c8ef4958f2 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -935,22 +935,13 @@ radv_image_view_can_fast_clear(struct radv_device *device,
 }
 
 static bool
-emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
- const VkClearAttachment *clear_att,
- const VkClearRect *clear_rect,
- enum radv_cmd_flush_bits *pre_flush,
- enum radv_cmd_flush_bits *post_flush)
+radv_can_fast_clear_depth(struct radv_cmd_buffer *cmd_buffer,
+ const struct radv_image_view *iview,
+ VkImageLayout image_layout,
+ VkImageAspectFlags aspects,
+ const VkClearRect *clear_rect,
+ const VkClearDepthStencilValue clear_value)
 {
-   const struct radv_subpass *subpass = cmd_buffer->state.subpass;
-   const uint32_t pass_att = subpass->depth_stencil_attachment.attachment;
-   VkImageLayout image_layout = subpass->depth_stencil_attachment.layout;
-   const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
-   const struct radv_image_view *iview = 
fb->attachments[pass_att].attachment;
-   VkClearDepthStencilValue clear_value = 
clear_att->clearValue.depthStencil;
-   VkImageAspectFlags aspects = clear_att->aspectMask;
-   uint32_t clear_word, flush_bits;
-   uint32_t htile_mask;
-
if (!radv_image_view_can_fast_clear(cmd_buffer->device, iview))
return false;
 
@@ -979,6 +970,30 @@ emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
 !radv_is_fast_clear_stencil_allowed(clear_value)))
return false;
 
+   return true;
+}
+
+static bool
+emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
+ const VkClearAttachment *clear_att,
+ const VkClearRect *clear_rect,
+ enum radv_cmd_flush_bits *pre_flush,
+ enum radv_cmd_flush_bits *post_flush)
+{
+   const struct radv_subpass *subpass = cmd_buffer->state.subpass;
+   const uint32_t pass_att = subpass->depth_stencil_attachment.attachment;
+   VkImageLayout image_layout = subpass->depth_stencil_attachment.layout;
+   const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
+   const struct radv_image_view *iview = 
fb->attachments[pass_att].attachment;
+   VkClearDepthStencilValue clear_value = 
clear_att->clearValue.depthStencil;
+   VkImageAspectFlags aspects = clear_att->aspectMask;
+   uint32_t clear_word, flush_bits;
+   uint32_t htile_mask;
+
+   if (!radv_can_fast_clear_depth(cmd_buffer, iview, image_layout, aspects,
+  clear_rect, clear_value))
+   return false;
+
clear_word = radv_get_htile_fast_clear_value(iview->image, clear_value);
htile_mask = radv_get_htile_mask(iview->image, aspects);
 
@@ -1367,23 +1382,14 @@ static void vi_get_fast_clear_parameters(VkFormat 
format,
 }
 
 static bool
-emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
- const VkClearAttachment *clear_att,
- const VkClearRect *clear_rect,
- enum radv_cmd_flush_bits *pre_flush,
- enum radv_cmd_flush_bits *post_flush,
-  uint32_t view_mask)
+radv_can_fast_clear_color(struct radv_cmd_buffer *cmd_buffer,
+ const struct radv_image_view *iview,
+ VkImageLayout image_layout,
+ const VkClearRect *clear_rect,
+ VkClearColorValue clear_value,
+ uint32_t view_mask)
 {
-   const struct radv_subpass *subpass = cmd_buffer->state.subpass;
-   const uint32_t subpass_att = clear_att->colorAttachment;
-   const uint32_t pass_att = 
subpass->color_attachments[subpass_att].attachment;
-   VkImageLayout image_layout = 
subpass->color_attachments[subpass_att].layout;
-   const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
-   const struct radv_image_view *iview = 
fb->attachments[pass_att].attachment;
-   VkClearColorValue clear_value = clear_att->clearValue.color;
-   uint32_t clear_color[2], flush_bits = 0;
-   uint32_t cmask_clear_value;
-   bool ret;
+   uint32_t clear_color[2];
 
if (!radv_image_view_can_fast_clear(cmd_buffer->device, iview))
return false;
@@ -1405,9 +1411,55 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
return false;
 
/* DCC */
-   ret = 

[Mesa-dev] [PATCH 7/7] radv: optimize CmdClear{Color, DepthStencil}Image() for layered textures

2018-11-23 Thread Samuel Pitoiset
If all layers are bound we can perform a fast color or depth clear
instead of iterating over all layers. This has the advantage
to avoid trashing the framebuffer for nothing if you we end up by
doing a fast clear when calling radv_clear_image_layer(), and
clearing all layers in one shot is obviously faster.

Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_meta_clear.c | 90 ++--
 1 file changed, 86 insertions(+), 4 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index d4da614584b..83d4b071d52 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -1776,6 +1776,75 @@ radv_clear_image_layer(struct radv_cmd_buffer 
*cmd_buffer,
radv_DestroyFramebuffer(device_h, fb,
_buffer->pool->alloc);
 }
+
+/**
+ * Return TRUE if a fast color or depth clear has been performed.
+ */
+static bool
+radv_fast_clear_range(struct radv_cmd_buffer *cmd_buffer,
+ struct radv_image *image,
+ VkFormat format,
+ VkImageLayout image_layout,
+ const VkImageSubresourceRange *range,
+ const VkClearValue *clear_val)
+{
+   struct radv_image_view iview;
+
+   radv_image_view_init(, cmd_buffer->device,
+&(VkImageViewCreateInfo) {
+   .sType = 
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
+   .image = radv_image_to_handle(image),
+   .viewType = 
radv_meta_get_view_type(image),
+   .format = image->vk_format,
+   .subresourceRange = {
+   .aspectMask = range->aspectMask,
+   .baseMipLevel = range->baseMipLevel,
+   .levelCount = range->levelCount,
+   .baseArrayLayer = range->baseArrayLayer,
+   .layerCount = range->layerCount,
+  },
+});
+
+   VkClearRect clear_rect = {
+   .rect = {
+   .offset = { 0, 0 },
+   .extent = {
+   radv_minify(image->info.width, 
range->baseMipLevel),
+   radv_minify(image->info.height, 
range->baseMipLevel),
+   },
+   },
+   .baseArrayLayer = range->baseArrayLayer,
+   .layerCount = range->layerCount,
+   };
+
+   VkClearAttachment clear_att = {
+   .aspectMask = range->aspectMask,
+   .colorAttachment = 0,
+   .clearValue = *clear_val,
+   };
+
+   if (vk_format_is_color(format)) {
+   if (radv_can_fast_clear_color(cmd_buffer, ,
+ image_layout, _rect,
+ clear_att.clearValue.color, 0)) {
+   radv_fast_clear_color(cmd_buffer, , _att,
+ clear_att.colorAttachment,
+ NULL, NULL);
+   return true;
+   }
+   } else {
+   if (radv_can_fast_clear_depth(cmd_buffer, , image_layout,
+ range->aspectMask, _rect,
+ 
clear_att.clearValue.depthStencil)) {
+   radv_fast_clear_depth(cmd_buffer, , _att,
+ NULL, NULL);
+   return true;
+   }
+   }
+
+   return false;
+}
+
 static void
 radv_cmd_clear_image(struct radv_cmd_buffer *cmd_buffer,
 struct radv_image *image,
@@ -1803,18 +1872,31 @@ radv_cmd_clear_image(struct radv_cmd_buffer *cmd_buffer,
internal_clear_value.color.uint32[0] = (r << 4) | (g & 0xf);
}
 
+   if (format == VK_FORMAT_R32G32B32_UINT ||
+   format == VK_FORMAT_R32G32B32_SINT ||
+   format == VK_FORMAT_R32G32B32_SFLOAT)
+   cs = true;
+
for (uint32_t r = 0; r < range_count; r++) {
const VkImageSubresourceRange *range = [r];
+
+   /* Try to perform a fast clear first, otherwise fallback to
+* the legacy path.
+*/
+   if (!cs &&
+   radv_fast_clear_range(cmd_buffer, image, format,
+ image_layout, range,
+ _clear_value)) {
+   continue;
+   }
+
for (uint32_t l = 0; l < radv_get_levelCount(image, range); 
++l) {
const uint32_t layer_count = 

Re: [Mesa-dev] [PATCH 2/2] glsl: free or reuse memory allocated for TF varying

2018-11-23 Thread Tapani Pälli

Hi;

On 11/23/18 10:29 AM, Gert Wollny wrote:

Hello Tapani,

since you wrote the original code, could you have a look at this patch?



Sure. I was able to reproduce this leak with Piglit's 
"ext_transform_feedback-points" and fix LGTM;


Reviewed-by: Tapani Pälli 



Many thanks,
Gert

Am Freitag, den 16.11.2018, 19:12 +0100 schrieb Gert Wollny:

From: Gert Wollny 

When a shader program is de-serialized the gl_shader_program passed
in
may actually still hold memory allocations for the transform feedback
varyings. If that is the case, free the varying names and reallocate
the new storage for the names array.

This fixes a memory leak:
Direct leak of 48 byte(s) in 6 object(s) allocated from:
  in malloc (/usr/lib64/gcc/x86_64-pc-linux-
gnu/7.3.0/libasan.so+0xdb880)
  in transform_feedback_varyings
../../samba/mesa/src/mesa/main/transformfeedback.c:875
  in _mesa_TransformFeedbackVaryings
../../samba/mesa/src/mesa/main/transformfeedback.c:985
  ...
Indirect leak of 42 byte(s) in 6 object(s) allocated from:
   in __interceptor_strdup (/usr/lib64/gcc/x86_64-pc-linux-
gnu/7.3.0/libasan.so+0x761c8)
   in transform_feedback_varyings
../../samba/mesa/src/mesa/main/transformfeedback.c:887
   in _mesa_TransformFeedbackVaryings
../../samba/mesa/src/mesa/main/transformfeedback.c:985

Fixes: ab2643e4b06f63c93a57624003679903442634a8
glsl: serialize data from glTransformFeedbackVaryings

Signed-off-by: Gert Wollny 
---
  src/compiler/glsl/serialize.cpp | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/serialize.cpp
b/src/compiler/glsl/serialize.cpp
index 267700e7e7..26d8ec4b75 100644
--- a/src/compiler/glsl/serialize.cpp
+++ b/src/compiler/glsl/serialize.cpp
@@ -360,13 +360,20 @@ read_xfb(struct blob_reader *metadata, struct
gl_shader_program *shProg)
 if (xfb_stage == ~0u)
return;
  
+   if (shProg->TransformFeedback.VaryingNames)  {

+  for (unsigned i = 0; i < shProg->TransformFeedback.NumVarying;
++i)
+ free(shProg->TransformFeedback.VaryingNames[i]);
+   }
+
 /* Data set by glTransformFeedbackVaryings. */
 shProg->TransformFeedback.BufferMode =
blob_read_uint32(metadata);
 blob_copy_bytes(metadata, 

TransformFeedback.BufferStride,

 sizeof(shProg->TransformFeedback.BufferStride));
 shProg->TransformFeedback.NumVarying =
blob_read_uint32(metadata);
+
 shProg->TransformFeedback.VaryingNames = (char **)
-  malloc(shProg->TransformFeedback.NumVarying * sizeof(GLchar
*));
+  realloc(shProg->TransformFeedback.VaryingNames,
+ shProg->TransformFeedback.NumVarying * sizeof(GLchar
*));
 /* Note, malloc used with VaryingNames. */
 for (unsigned i = 0; i < shProg->TransformFeedback.NumVarying;
i++)
shProg->TransformFeedback.VaryingNames[i] =

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


Re: [Mesa-dev] [PATCH mesa 00/13] Make standard function available on non-standard platforms

2018-11-23 Thread Jose Fonseca

On 21/11/2018 21:17, Ian Romanick wrote:

On 11/21/2018 12:16 PM, Jose Fonseca wrote:

    util: use standard name for strncat()



    util: use standard name for strncmp()
    util: use standard name for strcmp()
    util: use standard name for strchr()
    util: use standard name for sprintf()
    util: use standard name for vasprintf()
    util: use standard name for vsprintf()
    util: use standard name for snprintf()
    util: use standard name for vsnprintf()



Generally I agree with the principle of using standard functions, and
provide drop-in replacements for the systems where they are broken.  It
leads to less friction, less need to learn new things.


But C string functions is IMO a special case, because the standard
functions are so poorly designed, and make writing correct and secure
code so dawm difficult:

- snprintf doesn't write the null char

- strncat n parameter is awkard to use

-  vasprintf have different return codes on different systems.
According to GNU manpages, it's not even C or POSIX.


And a standard for the sake of standard is just silly.


So IMO, if people care and have the time to uniformize these things, I
think they should move away standard C functions, and write some sane C
string manipulation abstraction/helpers.  And we should make GCC throw
warnings every time people try to use the standard C string functions.



  All of these functions appear to have been added by 131a1fbc91725.  I've

added Jose to CC since he wrote it.  [...]



  That doesn't give much insight. :(




:(



*sigh*


The reason for adding was in b1922de9f3478869c6788ef4e954c06c20e7aa9c .


Right... I was more thinking about the str* functions than the *printf
functions.  Locale problems with scanf / printf are real on every
platform.  We had issues with this in the GLSL parser due to "." vs ","
as the ones to tenths separator in floating point numbers.  Other
*printf portability problems are real too.  I don't think there's any
variation with strchr or strstr, though. :)

Specifically, I (and I guess Emil also) propose removing the wrappers for:

  - strchr
  - strstr
  - strcmp (does this have locale issues?)
  - strncmp (does this have locale issues?)
  - strncat

And leave the rest for at least the time being.


For those, yes, it should be fine.

I'm not 100% sure if MSVC provides them all, but we can always fallback 
to a #define where not.


strcmp/strncmp don't seem to consider locale, and we typically only use 
them for ASCII string equality comparison anyway.


Jose


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


Re: [Mesa-dev] [PATCH 2/2] radv: correctly use vulkan 1.0 by default

2018-11-23 Thread Eric Engestrom
On Friday, 2018-11-23 00:32:29 +0100, Niklas Haas wrote:
> From the vulkan spec 3.2 "Instances":
> 
> "Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an
> apiVersion of 0 is equivalent to providing an apiVersion of
> VK_MAKE_VERSION(1,0,0)."
> ---
>  src/amd/vulkan/radv_device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index 70084a2b60..c258599888 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -525,7 +525,7 @@ VkResult radv_CreateInstance(
>   pCreateInfo->pApplicationInfo->apiVersion != 0) {
>   client_version = pCreateInfo->pApplicationInfo->apiVersion;
>   } else {
> - radv_EnumerateInstanceVersion(_version);
> + client_version = VK_API_VERSION_1_0;

This is essentially reverting Bas' (cc'ed) ffa15861ef7c924a33e1f, so:
Fixes: ffa15861ef7c924a33e1f "radv: UseEnumerateInstanceVersion for the default 
version."

Bas, I double-checked the spec and Niklas is right; why did you change
it to use the icd version instead? Was is fixing an issue somewhere?

Unless Bas objects, this is:
Reviewed-by: Eric Engestrom 

>   }
>  
>   instance = vk_zalloc2(_alloc, pAllocator, sizeof(*instance), 8,
> -- 
> 2.19.1
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 108848] 3d image broken in Dragon age: origins

2018-11-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108848

ilia  changed:

   What|Removed |Added

 Attachment #142590|0   |1
is obsolete||

--- Comment #4 from ilia  ---
Created attachment 142594
  --> https://bugs.freedesktop.org/attachment.cgi?id=142594=edit
Better bakctrace

Rerun with dbg version of libd3dadapter9-mesa

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


Re: [Mesa-dev] [Mesa-announce] [ANNOUNCE] mesa 18.3.0-rc4

2018-11-23 Thread Emil Velikov
On 2018/11/22, Marek Olšák wrote:
> Also this one is probably a blocker:
> https://patchwork.freedesktop.org/patch/262760/
> 
> Without it, the computer may run out of memory depending on the window
> system.
> 
Thanks Marek. Added to the list, will keep a close eye on it.

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


[Mesa-dev] [PATCH v2 2/2] drisw: Use separate drisw_loader_funcs for shm

2018-11-23 Thread Michal Srb
The original code was modifying the global drisw_lf variable, which is bad
when there are multiple contexts in single process, each initialized with
different loader. One may support put_image_shm and the other not.

Since there are currently only two possible combinations, lets create two
global tables, one for each. Lets make them const, since we won't change them
and they can be shared.

This fixes crash in VLC. It used two GL contexts (each in different thread), one
was initialized by its Qt GUI, the other by its video output plugin. The first
one set the put_image_shm=drisw_put_image_shm, the second did not, but
since the same structure was used, the drisw_put_image_shm was used too. Then
it crashed because the second loader did not have putImageShm set.

Downstream bug:
https://bugzilla.opensuse.org/show_bug.cgi?id=1113533

v2: Added Fixes and described the VLC bug.

Fixes: 63c427fa71a ("drisw: use putImageShm if available")
Signed-off-by: Michal Srb 
---

 src/gallium/state_trackers/dri/drisw.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drisw.c 
b/src/gallium/state_trackers/dri/drisw.c
index 886f94dc02..5a0d2e1354 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -421,12 +421,19 @@ static const __DRIextension *drisw_screen_extensions[] = {
NULL
 };
 
-static struct drisw_loader_funcs drisw_lf = {
+static const struct drisw_loader_funcs drisw_lf = {
.get_image = drisw_get_image,
.put_image = drisw_put_image,
.put_image2 = drisw_put_image2
 };
 
+static const struct drisw_loader_funcs drisw_shm_lf = {
+   .get_image = drisw_get_image,
+   .put_image = drisw_put_image,
+   .put_image2 = drisw_put_image2,
+   .put_image_shm = drisw_put_image_shm
+};
+
 static const __DRIconfig **
 drisw_init_screen(__DRIscreen * sPriv)
 {
@@ -434,6 +441,7 @@ drisw_init_screen(__DRIscreen * sPriv)
const __DRIconfig **configs;
struct dri_screen *screen;
struct pipe_screen *pscreen = NULL;
+   const struct drisw_loader_funcs *lf = _lf;
 
screen = CALLOC_STRUCT(dri_screen);
if (!screen)
@@ -448,10 +456,10 @@ drisw_init_screen(__DRIscreen * sPriv)
sPriv->extensions = drisw_screen_extensions;
if (loader->base.version >= 4) {
   if (loader->putImageShm)
- drisw_lf.put_image_shm = drisw_put_image_shm;
+ lf = _shm_lf;
}
 
-   if (pipe_loader_sw_probe_dri(>dev, _lf)) {
+   if (pipe_loader_sw_probe_dri(>dev, lf)) {
   dri_init_options(screen);
 
   pscreen = pipe_loader_create_screen(screen->dev);
-- 
2.16.4

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


[Mesa-dev] [PATCH] egl/wayland: bail out when drmGetMagic fails

2018-11-23 Thread Emil Velikov
From: Emil Velikov 

Currently as the function fails, we pass uninitialized data to the
authentication function. Stop doing that and print an warning when
the function fails.

Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Emil Velikov 
---
 src/egl/drivers/dri2/platform_wayland.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index cda6f25a7e0..f2dc26d5850 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1134,7 +1134,10 @@ drm_handle_device(void *data, struct wl_drm *drm, const 
char *device)
if (drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER) {
   dri2_dpy->authenticated = true;
} else {
-  drmGetMagic(dri2_dpy->fd, );
+  if (drmGetMagic(dri2_dpy->fd, )) {
+ _eglLog(_EGL_WARNING, "wayland-egl: drmGetMagic failed");
+ return;
+  }
   wl_drm_authenticate(dri2_dpy->wl_drm, magic);
}
 }
-- 
2.19.1

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


Re: [Mesa-dev] [Mesa-stable] [PATCH 1/2] anv: Put robust buffer access in the pipeline hash

2018-11-23 Thread Juan A. Suarez Romero
On Wed, 2018-11-21 at 17:20 -0600, Jason Ekstrand wrote:
> It affects apply_pipeline_layout.  Shaders compiled with the wrong value
> will work but they may not be robust as requested by the app.
> 
> Cc: mesa-sta...@lists.freedesktop.org


Hi, Jason.

This patch does not apply cleanly in 18.2 branch. As the fix wasn't as trivial
as usual, it would be great if you can check the resolution at 


https://gitlab.freedesktop.org/mesa/mesa/commit/35379ec233353d19d94994dfa43b205a6b5622b2


Thanks in advance!

J.A.

> ---
>  src/intel/vulkan/anv_pipeline.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
> index ad0f08253e7..f170366d030 100644
> --- a/src/intel/vulkan/anv_pipeline.c
> +++ b/src/intel/vulkan/anv_pipeline.c
> @@ -446,6 +446,9 @@ anv_pipeline_hash_graphics(struct anv_pipeline *pipeline,
> if (layout)
>_mesa_sha1_update(, layout->sha1, sizeof(layout->sha1));
>  
> +   const bool rba = pipeline->device->robust_buffer_access;
> +   _mesa_sha1_update(, , sizeof(rba));
> +
> for (unsigned s = 0; s < MESA_SHADER_STAGES; s++) {
>if (stages[s].entrypoint)
>   anv_pipeline_hash_shader(, [s]);
> @@ -466,6 +469,9 @@ anv_pipeline_hash_compute(struct anv_pipeline *pipeline,
> if (layout)
>_mesa_sha1_update(, layout->sha1, sizeof(layout->sha1));
>  
> +   const bool rba = pipeline->device->robust_buffer_access;
> +   _mesa_sha1_update(, , sizeof(rba));
> +
> anv_pipeline_hash_shader(, stage);
>  
> _mesa_sha1_final(, sha1_out);

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


Re: [Mesa-dev] [PATCH] egl/wayland: bail out when drmGetMagic fails

2018-11-23 Thread Tapani Pälli

Similar warning is done in platform_x11.c;

Reviewed-by: Tapani Pälli 

On 11/23/18 2:59 PM, Emil Velikov wrote:

From: Emil Velikov 

Currently as the function fails, we pass uninitialized data to the
authentication function. Stop doing that and print an warning when
the function fails.

Cc: mesa-sta...@lists.freedesktop.org
Signed-off-by: Emil Velikov 
---
  src/egl/drivers/dri2/platform_wayland.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c 
b/src/egl/drivers/dri2/platform_wayland.c
index cda6f25a7e0..f2dc26d5850 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1134,7 +1134,10 @@ drm_handle_device(void *data, struct wl_drm *drm, const 
char *device)
 if (drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER) {
dri2_dpy->authenticated = true;
 } else {
-  drmGetMagic(dri2_dpy->fd, );
+  if (drmGetMagic(dri2_dpy->fd, )) {
+ _eglLog(_EGL_WARNING, "wayland-egl: drmGetMagic failed");
+ return;
+  }
wl_drm_authenticate(dri2_dpy->wl_drm, magic);
 }
  }


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


Re: [Mesa-dev] [PATCH 06/18] mapi/new: use the static_data offsets in the new generator

2018-11-23 Thread Emil Velikov
On 2018/11/21, Dylan Baker wrote:
> Quoting Emil Velikov (2018-11-21 04:04:03)

> >  
> > +import os
> > +GLAPI = os.path.join(os.path.dirname(sys.argv[0]), "..", "glapi/gen")
> 
> you should use __file__ instead of sys.argv[0], also don't hardcode '/' into
> there, join 'glapi' and 'gen' for windows
> 
> > +sys.path.append(GLAPI)
> 
> also, use sys.path.insert(0, GLAPI), as python looks through paths in order, 
> and
> insert is always faster.
> 
Fwiw the code above is copy/paste from src/mapi/mapi_abi.py. With a
similar hunk in src/mesa/main/get_hash_generator.py

Not sure how it works on Windows ... will address those files with a
small prep series and update this hunk.


> > +
> > +if slot_set == False and name[-3:] != "ARB":
> 
> use 'is' with singletons like True, False, and None instead '=='. You might 
> also
> consider using .startswith() and .endswith(), as they're clearer than random
> subslice.
> 
Sub slices are so much shorter hence why I opted for it. But will
rework with v2.

Thanks
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 12/18] meson: wire the new generator for es1 and es2

2018-11-23 Thread Emil Velikov
On 2018/11/21, Dylan Baker wrote:

> > diff --git a/src/mapi/glapi/gen/meson.build b/src/mapi/glapi/gen/meson.build
> > index f494e9707b6..fa06c7c5458 100644
> > --- a/src/mapi/glapi/gen/meson.build
> > +++ b/src/mapi/glapi/gen/meson.build
> > @@ -18,6 +18,13 @@
> >  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
> > IN THE
> >  # SOFTWARE.
> >  
> > +glapi_gen_gl_xml = files('../registry/gl.xml')
> 
> the gl_enum.py generate could use this as well.
> 
Not sure what you mean here. I cannot find any file called gl_enum.py
and `git grep gl_enum.py` returns nothing.

> > +glapi_gen_mapi_deps = [
> > +  glapi_gen_gl_xml,
> > +  files('../../new/genCommon.py'),
> > +  glapi_gen_gl_xml,
> > +]
> > +
> >  gl_and_es_api_files = files('gl_and_es_API.xml')
> >  
> >  api_xml_files = files(
> > diff --git a/src/mapi/meson.build b/src/mapi/meson.build
> > index 798586bfb0c..e7a6685576b 100644
> > --- a/src/mapi/meson.build
> > +++ b/src/mapi/meson.build
> > @@ -25,6 +25,7 @@ files_mapi_util = files(
> >'u_execmem.h',
> >  )
> >  
> > +glapi_gen_mapi_script = files('new/gen_gldispatch_mapi.py')
> 
> All of the other generated scripts are "${foo}_py", can we continue to use 
> that
> format please?
> 
Sure thing. To keep things obvious, I've left them identical for across
all builds.

Thanks
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 12/18] meson: wire the new generator for es1 and es2

2018-11-23 Thread Emil Velikov
On 2018/11/23, Emil Velikov wrote:
> On 2018/11/21, Dylan Baker wrote:
> 
> > > diff --git a/src/mapi/glapi/gen/meson.build 
> > > b/src/mapi/glapi/gen/meson.build
> > > index f494e9707b6..fa06c7c5458 100644
> > > --- a/src/mapi/glapi/gen/meson.build
> > > +++ b/src/mapi/glapi/gen/meson.build
> > > @@ -18,6 +18,13 @@
> > >  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
> > > IN THE
> > >  # SOFTWARE.
> > >  
> > > +glapi_gen_gl_xml = files('../registry/gl.xml')
> > 
> > the gl_enum.py generate could use this as well.
> > 
> Not sure what you mean here. I cannot find any file called gl_enum.py
> and `git grep gl_enum.py` returns nothing.
> 
Just realised the s (in enums) is missing. Sure it's possible to reuse
the upstream gl.xml - but the plan is the address that as follow-up.

-Emil

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


[Mesa-dev] [PATCH 1/2] gallium: Constify drisw_loader_funcs struct

2018-11-23 Thread Michal Srb
The content is not expected to change.

Signed-off-by: Michal Srb 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader.h| 2 +-
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 2 +-
 src/gallium/winsys/sw/dri/dri_sw_winsys.c  | 4 ++--
 src/gallium/winsys/sw/dri/dri_sw_winsys.h  | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 05be94cae3..9b26414534 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -142,7 +142,7 @@ pipe_loader_release(struct pipe_loader_device **devs, int 
ndev);
  */
 bool
 pipe_loader_sw_probe_dri(struct pipe_loader_device **devs,
- struct drisw_loader_funcs *drisw_lf);
+ const struct drisw_loader_funcs *drisw_lf);
 
 /**
  * Initialize a kms backed sw device given an fd.
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index d387ce90d3..587b6f8567 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -132,7 +132,7 @@ pipe_loader_sw_probe_teardown_common(struct 
pipe_loader_sw_device *sdev)
 
 #ifdef HAVE_PIPE_LOADER_DRI
 bool
-pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct 
drisw_loader_funcs *drisw_lf)
+pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, const struct 
drisw_loader_funcs *drisw_lf)
 {
struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
int i;
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c 
b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
index d519bcfedd..cd44b036c6 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
@@ -62,7 +62,7 @@ struct dri_sw_winsys
 {
struct sw_winsys base;
 
-   struct drisw_loader_funcs *lf;
+   const struct drisw_loader_funcs *lf;
 };
 
 static inline struct dri_sw_displaytarget *
@@ -282,7 +282,7 @@ dri_destroy_sw_winsys(struct sw_winsys *winsys)
 }
 
 struct sw_winsys *
-dri_create_sw_winsys(struct drisw_loader_funcs *lf)
+dri_create_sw_winsys(const struct drisw_loader_funcs *lf)
 {
struct dri_sw_winsys *ws;
 
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.h 
b/src/gallium/winsys/sw/dri/dri_sw_winsys.h
index 329ac06a05..47e3777d4c 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.h
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.h
@@ -33,6 +33,6 @@
 
 struct sw_winsys;
 
-struct sw_winsys *dri_create_sw_winsys(struct drisw_loader_funcs *lf);
+struct sw_winsys *dri_create_sw_winsys(const struct drisw_loader_funcs *lf);
 
 #endif
-- 
2.16.4

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


[Mesa-dev] [PATCH 2/2] drisw: Use separate drisw_loader_funcs for shm

2018-11-23 Thread Michal Srb
The original code was modifying the global drisw_lf variable, which is bad
when there are multiple contexts in single process, each initialized with
different loader. One may support put_image_shm and the other not.

Since there are currently only two possible combinations, lets create two
global tables, one for each. Lets make them const, since we won't change them
and they can be shared.

Signed-off-by: Michal Srb 
---
This fixes crash in VLC. It used two GL contexts (each in different thread), one
was initialized by its Qt GUI, the other by its video output plugin. The first
one set the put_image_shm=drisw_put_image_shm, the second did not, but
since the same structure was used, the drisw_put_image_shm was used too. Then
it crashed because the second loader did not have putImageShm set.

Downstream bug:
https://bugzilla.opensuse.org/show_bug.cgi?id=1113533

 src/gallium/state_trackers/dri/drisw.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drisw.c 
b/src/gallium/state_trackers/dri/drisw.c
index 886f94dc02..5a0d2e1354 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -421,12 +421,19 @@ static const __DRIextension *drisw_screen_extensions[] = {
NULL
 };
 
-static struct drisw_loader_funcs drisw_lf = {
+static const struct drisw_loader_funcs drisw_lf = {
.get_image = drisw_get_image,
.put_image = drisw_put_image,
.put_image2 = drisw_put_image2
 };
 
+static const struct drisw_loader_funcs drisw_shm_lf = {
+   .get_image = drisw_get_image,
+   .put_image = drisw_put_image,
+   .put_image2 = drisw_put_image2,
+   .put_image_shm = drisw_put_image_shm
+};
+
 static const __DRIconfig **
 drisw_init_screen(__DRIscreen * sPriv)
 {
@@ -434,6 +441,7 @@ drisw_init_screen(__DRIscreen * sPriv)
const __DRIconfig **configs;
struct dri_screen *screen;
struct pipe_screen *pscreen = NULL;
+   const struct drisw_loader_funcs *lf = _lf;
 
screen = CALLOC_STRUCT(dri_screen);
if (!screen)
@@ -448,10 +456,10 @@ drisw_init_screen(__DRIscreen * sPriv)
sPriv->extensions = drisw_screen_extensions;
if (loader->base.version >= 4) {
   if (loader->putImageShm)
- drisw_lf.put_image_shm = drisw_put_image_shm;
+ lf = _shm_lf;
}
 
-   if (pipe_loader_sw_probe_dri(>dev, _lf)) {
+   if (pipe_loader_sw_probe_dri(>dev, lf)) {
   dri_init_options(screen);
 
   pscreen = pipe_loader_create_screen(screen->dev);
-- 
2.16.4

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


Re: [Mesa-dev] [PATCH 3/6] mesa/st: Factor out array and buffer setup from st_atom_array.c.

2018-11-23 Thread Chris Wilson
Quoting mathias.froehl...@gmx.net (2018-11-23 08:07:29)
> From: Mathias Fröhlich 
> 
> Factor out vertex array setup routines from the array state atom.
> The factored functions will be used in feedback rendering in the
> next change.
> 
> Signed-off-by: Mathias Fröhlich 
> ---
>  src/mesa/state_tracker/st_atom.h   | 17 ++
>  src/mesa/state_tracker/st_atom_array.c | 79 +++---
>  2 files changed, 74 insertions(+), 22 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_atom.h 
> b/src/mesa/state_tracker/st_atom.h
> index 9f3ca38c19..901e9b6d43 100644
> --- a/src/mesa/state_tracker/st_atom.h
> +++ b/src/mesa/state_tracker/st_atom.h
> @@ -37,6 +37,10 @@
>  #include "main/glheader.h"
>  
>  struct st_context;
> +struct st_vertex_program;
> +struct st_vp_variant;
> +struct pipe_vertex_buffer;
> +struct pipe_vertex_element;
>  
>  /**
>   * Enumeration of state tracker pipelines.
> @@ -57,6 +61,19 @@ GLuint st_compare_func_to_pipe(GLenum func);
>  enum pipe_format
>  st_pipe_vertex_format(const struct gl_vertex_format *glformat);
>  
> +void
> +st_setup_arrays(struct st_context *st,
> +const struct st_vertex_program *vp,
> +const struct st_vp_variant *vp_variant,
> +struct pipe_vertex_element *velements,
> +struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
> +
> +void
> +st_setup_current(struct st_context *st,
> + const struct st_vertex_program *vp,
> + const struct st_vp_variant *vp_variant,
> + struct pipe_vertex_element *velements,
> + struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
>  
>  /* Define ST_NEW_xxx_INDEX */
>  enum {
> diff --git a/src/mesa/state_tracker/st_atom_array.c 
> b/src/mesa/state_tracker/st_atom_array.c
> index cd00529ddf..ac9bd727df 100644
> --- a/src/mesa/state_tracker/st_atom_array.c
> +++ b/src/mesa/state_tracker/st_atom_array.c
> @@ -384,25 +384,17 @@ set_vertex_attribs(struct st_context *st,
>  }
>  
>  void
> -st_update_array(struct st_context *st)
> +st_setup_arrays(struct st_context *st,
> +const struct st_vertex_program *vp,
> +const struct st_vp_variant *vp_variant,
> +struct pipe_vertex_element *velements,
> +struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
>  {
> struct gl_context *ctx = st->ctx;
> -   /* vertex program validation must be done before this */
> -   const struct st_vertex_program *vp = st->vp;
> -   /* _NEW_PROGRAM, ST_NEW_VS_STATE */
> -   const GLbitfield inputs_read = st->vp_variant->vert_attrib_mask;
> const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
> +   const GLbitfield inputs_read = vp_variant->vert_attrib_mask;
> const ubyte *input_to_index = vp->input_to_index;
>  
> -   struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
> -   struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
> -   unsigned num_vbuffers = 0;
> -
> -   st->vertex_array_out_of_memory = FALSE;
> -   st->draw_needs_minmax_index = false;
> -
> -   /* _NEW_PROGRAM */
> -   /* ST_NEW_VERTEX_ARRAYS alias ctx->DriverFlags.NewArray */
> /* Process attribute array data. */
> GLbitfield mask = inputs_read & _mesa_draw_array_bits(ctx);
> while (mask) {
> @@ -410,7 +402,7 @@ st_update_array(struct st_context *st)
>const gl_vert_attrib i = ffs(mask) - 1;
>const struct gl_vertex_buffer_binding *const binding
>   = _mesa_draw_buffer_binding(vao, i);
> -  const unsigned bufidx = num_vbuffers++;
> +  const unsigned bufidx = (*num_vbuffers)++;
>  
>if (_mesa_is_bufferobj(binding->BufferObj)) {
>   struct st_buffer_object *stobj = 
> st_buffer_object(binding->BufferObj);
> @@ -452,16 +444,28 @@ st_update_array(struct st_context *st)
> input_to_index[attr]);
>}
> }
> +}
> +
> +void
> +st_setup_current(struct st_context *st,
> + const struct st_vertex_program *vp,
> + const struct st_vp_variant *vp_variant,
> + struct pipe_vertex_element *velements,
> + struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
> +{
> +   struct gl_context *ctx = st->ctx;
> +   const GLbitfield inputs_read = vp_variant->vert_attrib_mask;
>  
> -   const unsigned first_current_vbuffer = num_vbuffers;
> -   /* _NEW_PROGRAM | _NEW_CURRENT_ATTRIB */
> /* Process values that should have better been uniforms in the 
> application */
> GLbitfield curmask = inputs_read & _mesa_draw_current_bits(ctx);
> if (curmask) {
> +  /* vertex program validation must be done before this */
> +  const struct st_vertex_program *vp = st->vp;
> +  const ubyte *input_to_index = vp->input_to_index;
>/* For each attribute, upload the maximum possible size. */
>GLubyte data[VERT_ATTRIB_MAX * sizeof(GLdouble) * 4];
>GLubyte *cursor = data;
> -  

Re: [Mesa-dev] [PATCH 6/6] mesa/main: fix incorrect detph-error

2018-11-23 Thread Juan A. Suarez Romero
On Thu, 2018-11-22 at 17:48 +0100, Erik Faye-Lund wrote:

Typo in the subject (s/detph/depth)

> If glGetTexImage or glGetnTexImage is called with a level that doesn't
> exist, we get an error message on this form:
> 
> Mesa: User error: GL_INVALID_VALUE in glGetTexImage(depth = 0)
> 
> This is clearly nonsensical, because these APIs don't even have a
> depth-parameter. The reason is that get_texture_image_dims() return
> all-zero dimensions for non-existent texture-images, and we go on to
> validate these dimensions as if they were user-input, because
> glGetTextureSubImage requires checking.
> 
> So let's split this logic in two, so glGetTextureSubImage can have
> stricter input-validation. All arguments that are no longer validated
> are generated internally by mesa, so there's no use in validating them.
> 
> Fixes: 42891dbaa12 "gettextsubimage: verify zoffset and depth are correct"
> Signed-off-by: Erik Faye-Lund 
> ---
>  src/mesa/main/texgetimage.c | 57 -
>  1 file changed, 50 insertions(+), 7 deletions(-)
> 
> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
> index 190f53d62fe..dabfcd06a52 100644
> --- a/src/mesa/main/texgetimage.c
> +++ b/src/mesa/main/texgetimage.c
> @@ -1255,7 +1255,6 @@ static bool
>  getteximage_error_check(struct gl_context *ctx,
>  struct gl_texture_object *texObj,
>  GLenum target, GLint level,
> -GLint xoffset, GLint yoffset, GLint zoffset,
>  GLsizei width, GLsizei height, GLsizei depth,
>  GLenum format, GLenum type, GLsizei bufSize,
>  GLvoid *pixels, const char *caller)
> @@ -1269,6 +1268,49 @@ getteximage_error_check(struct gl_context *ctx,
>return true;
> }
>  
> +   if (width == 0 || height == 0 || depth == 0) {
> +  /* Not an error, but nothing to do.  Return 'true' so that the
> +   * caller simply returns.
> +   */
> +  return true;
> +   }
> +
> +   if (pbo_error_check(ctx, target, width, height, depth,
> +   format, type, bufSize, pixels, caller)) {
> +  return true;
> +   }
> +
> +   texImage = select_tex_image(texObj, target, level, 0);
> +   if (teximage_error_check(ctx, texImage, format, caller)) {
> +  return true;
> +   }
> +
> +   return false;
> +}
> +
> +
> +/**
> + * Do error checking for all (non-compressed) get-texture-image functions.
> + * \return true if any error, false if no errors.
> + */
> +static bool
> +gettexsubimage_error_check(struct gl_context *ctx,
> +   struct gl_texture_object *texObj,
> +   GLenum target, GLint level,
> +   GLint xoffset, GLint yoffset, GLint zoffset,
> +   GLsizei width, GLsizei height, GLsizei depth,
> +   GLenum format, GLenum type, GLsizei bufSize,
> +   GLvoid *pixels, const char *caller)
> +{
> +   struct gl_texture_image *texImage;
> +
> +   assert(texObj);
> +
> +   if (common_error_check(ctx, texObj, target, level, width, height, depth,
> +  format, type, bufSize, pixels, caller)) {
> +  return true;
> +   }
> +
> if (dimensions_error_check(ctx, texObj, target, level,
>xoffset, yoffset, zoffset,
>width, height, depth, caller)) {
> @@ -1417,7 +1459,7 @@ _mesa_GetnTexImage(GLenum target, GLint level, GLenum 
> format, GLenum type,
> get_texture_image_dims(texObj, target, level, , , );
>  
> if (getteximage_error_check(ctx, texObj, target, level,
> -   0, 0, 0, width, height, depth,
> +   width, height, depth,
> format, type, bufSize, pixels, caller)) {
>return;
> }
> @@ -1448,7 +1490,7 @@ _mesa_GetTexImage(GLenum target, GLint level, GLenum 
> format, GLenum type,
> get_texture_image_dims(texObj, target, level, , , );
>  
> if (getteximage_error_check(ctx, texObj, target, level,
> -   0, 0, 0, width, height, depth,
> +   width, height, depth,
> format, type, INT_MAX, pixels, caller)) {
>return;
> }
> @@ -1482,7 +1524,7 @@ _mesa_GetTextureImage(GLuint texture, GLint level, 
> GLenum format, GLenum type,
>, , );
>  
> if (getteximage_error_check(ctx, texObj, texObj->Target, level,
> -   0, 0, 0, width, height, depth,
> +   width, height, depth,
> format, type, bufSize, pixels, caller)) {
>return;
> }
> @@ -1515,9 +1557,10 @@ _mesa_GetTextureSubImage(GLuint texture, GLint level,
>return;
> }
>  
> -   if (getteximage_error_check(ctx, texObj, texObj->Target, level,
> -   

Re: [Mesa-dev] [PATCH 0/6] glGetTexImage fixes

2018-11-23 Thread Juan A. Suarez Romero
On Thu, 2018-11-22 at 17:48 +0100, Erik Faye-Lund wrote:
> I was recently investigating a gl-error that appears some times while
> using virgl, where I got a pretty nonsensical GL-error:
> 
> Mesa: User error: GL_INVALID_VALUE in glGetnTexImageARB(depth = 0)
> 
> Now, the reason why this is nonsensical, is that glGetnTexImage doesn't 
> have a 'depth'-argument, this value is generated internally in mesa.
> 
> What happens is that virgl ends up asking for the teximage for a
> non-existen mipmap-level. Whoops, that shouldn't be done, but while 
> we're in this area, let's clean this up.
> 
> My first fix was to revert 42891dbaa12 ("gettextsubimage: verify zoffset
> and depth are correct"). But that would render that commit moot, but it
> actually does fix something. So I'd rather not; it's a good change, but
> this logic should only apply to glGetTextureSubImage.
> 
> So I decided to give glGetTextureSubImage its own error checking.
> 
> While working on this, I also realized that the error introduced in
> b37b35a5d26 ("getteximage: assume texture image is empty for non defined
> levels") was flawed; it shouldn't apply in the case where *all* of
> width, xoffset and the texture's width are zero. And since we end up
> checking explicitly for these conditions later, this should simply be a
> no-op as per the spec. And we already have some support-code for this.
> 
> No regressions found in piglit.


The series looks good to me. 


Reviewed-by: Juan A. Suarez 


> 
> Erik Faye-Lund (6):
>   mesa/main: remove ARB suffix from glGetnTexImage
>   mesa/main: remove bogus error for zero-sized images
>   mesa/main: factor out tex-image error-checking
>   mesa/main: factor out common error-checking
>   mesa/main: check cube-completeness in common code
>   mesa/main: fix incorrect detph-error
> 
>  src/mapi/glapi/gen/ARB_robustness.xml |   2 +-
>  src/mapi/glapi/gen/gl_API.xml |   9 +
>  src/mesa/main/texgetimage.c   | 273 --
>  src/mesa/main/texgetimage.h   |   4 +-
>  4 files changed, 179 insertions(+), 109 deletions(-)
> 

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


[Mesa-dev] [Bug 108530] [Tracker] Mesa 18.3 Release Tracker

2018-11-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108530

--- Comment #1 from Emil Velikov  ---
As requested by Marek on the ML [1] we'd want this [2] memory leak fix.


[1] https://lists.freedesktop.org/archives/mesa-dev/2018-November/210206.html
[2] https://patchwork.freedesktop.org/patch/262760/

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


Re: [Mesa-dev] [PATCH] draw: fix infinite loop in line stippling

2018-11-23 Thread Jose Fonseca

On 23/11/2018 01:34, srol...@vmware.com wrote:

From: Roland Scheidegger 

The calculated length of a line may be infinite, if the coords we
get are bogus. This leads to an infinite loop in line stippling.
To prevent this test for this explicitly (although technically
on at least x86 sse it would actually work without the explicit
test, as long as we use the int-converted length value).
While here also get rid of some always-true condition.

Note this does not actually solve the root cause, which is that
the coords we receive are bogus after clipping. This seems a difficult
problem to solve. One issue is that due to float arithmetic, clip w
may become 0 after clipping if the incoming geometry is
"sufficiently degenerate", hence x/y/z ndc (and window) coords will
be all inf (or nan). Even with w not quite 0, I believe it's possible
we produce values which are actually outside the view volume.
(Also, x=y=z=w=0 coords in clipspace would be not considered subject
to clipping, and similarly result in all NaN coords.) We just hope for
now other draw stages (and rasterizers) can handle those relatively
safely (llvmpipe itself should be sort of robust against this, certainly
converstion to fixed point will produce garbage, it might fail a couple
assertions but should neither hang nor crash otherwise).
---
  .../auxiliary/draw/draw_pipe_stipple.c| 26 +++
  1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c 
b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index d30572cc61..386b7649e4 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -48,8 +48,8 @@
  struct stipple_stage {
 struct draw_stage stage;
 float counter;
-   uint pattern;
-   uint factor;
+   ushort pattern;
+   ushort factor;
 bool smooth;
  };
  
@@ -110,7 +110,7 @@ emit_segment(struct draw_stage *stage, struct prim_header *header,
  
  
  static inline bool

-stipple_test(int counter, ushort pattern, int factor)
+stipple_test(int counter, ushort pattern, ushort factor)
  {
 int b = (counter / factor) & 0xf;
 return !!((1 << b) & pattern);
@@ -136,6 +136,10 @@ stipple_line(struct draw_stage *stage, struct prim_header 
*header)
  
 float length;

 int i;
+   int intlength;
+
+   if (header->flags & DRAW_PIPE_RESET_STIPPLE)
+  stipple->counter = 0;
  
 if (stipple->smooth) {

float dx = x1 - x0;
@@ -147,21 +151,21 @@ stipple_line(struct draw_stage *stage, struct prim_header 
*header)
length = MAX2(dx, dy);
 }
  
-   if (header->flags & DRAW_PIPE_RESET_STIPPLE)

-  stipple->counter = 0;
+   if (util_is_inf_or_nan(length))
+  intlength = 0;
+   else
+  intlength = ceilf(length);
  
 /* XXX ToDo: instead of iterating pixel-by-pixel, use a look-up table.

  */
-   for (i = 0; i < length; i++) {
+   for (i = 0; i < intlength; i++) {
bool result = stipple_test((int)stipple->counter + i,
- (ushort)stipple->pattern, stipple->factor);
+ stipple->pattern, stipple->factor);
if (result != state) {
   /* changing from "off" to "on" or vice versa */
   if (state) {
-if (start != i) {
-   /* finishing an "on" segment */
-   emit_segment(stage, header, start / length, i / length);
-}
+/* finishing an "on" segment */
+emit_segment(stage, header, start / length, i / length);
   }
   else {
  /* starting an "on" segment */



Reviewed-by: Jose Fonseca 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 0/6] glGetTexImage fixes

2018-11-23 Thread Erik Faye-Lund
On Fri, 2018-11-23 at 15:50 +0100, Juan A. Suarez Romero wrote:
> On Thu, 2018-11-22 at 17:48 +0100, Erik Faye-Lund wrote:
> > I was recently investigating a gl-error that appears some times
> > while
> > using virgl, where I got a pretty nonsensical GL-error:
> > 
> > Mesa: User error: GL_INVALID_VALUE in glGetnTexImageARB(depth = 0)
> > 
> > Now, the reason why this is nonsensical, is that glGetnTexImage
> > doesn't 
> > have a 'depth'-argument, this value is generated internally in
> > mesa.
> > 
> > What happens is that virgl ends up asking for the teximage for a
> > non-existen mipmap-level. Whoops, that shouldn't be done, but
> > while 
> > we're in this area, let's clean this up.
> > 
> > My first fix was to revert 42891dbaa12 ("gettextsubimage: verify
> > zoffset
> > and depth are correct"). But that would render that commit moot,
> > but it
> > actually does fix something. So I'd rather not; it's a good change,
> > but
> > this logic should only apply to glGetTextureSubImage.
> > 
> > So I decided to give glGetTextureSubImage its own error checking.
> > 
> > While working on this, I also realized that the error introduced in
> > b37b35a5d26 ("getteximage: assume texture image is empty for non
> > defined
> > levels") was flawed; it shouldn't apply in the case where *all* of
> > width, xoffset and the texture's width are zero. And since we end
> > up
> > checking explicitly for these conditions later, this should simply
> > be a
> > no-op as per the spec. And we already have some support-code for
> > this.
> > 
> > No regressions found in piglit.
> 
> The series looks good to me. 
> 
> 
> Reviewed-by: Juan A. Suarez 
> 

Thanks a lot :)

I've fixed up the subject-typo locally, and I'll let this sit over the
weekend until I push it out (unless someone finds a problem in the mean
time, of course).

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


Re: [Mesa-dev] [Mesa-stable] [PATCH 1/2] anv: Put robust buffer access in the pipeline hash

2018-11-23 Thread Jason Ekstrand
Looks good

On Fri, Nov 23, 2018 at 8:29 AM Juan A. Suarez Romero 
wrote:

> On Wed, 2018-11-21 at 17:20 -0600, Jason Ekstrand wrote:
> > It affects apply_pipeline_layout.  Shaders compiled with the wrong value
> > will work but they may not be robust as requested by the app.
> >
> > Cc: mesa-sta...@lists.freedesktop.org
>
>
> Hi, Jason.
>
> This patch does not apply cleanly in 18.2 branch. As the fix wasn't as
> trivial
> as usual, it would be great if you can check the resolution at
>
>
>
> https://gitlab.freedesktop.org/mesa/mesa/commit/35379ec233353d19d94994dfa43b205a6b5622b2
>
>
> Thanks in advance!
>
> J.A.
>
> > ---
> >  src/intel/vulkan/anv_pipeline.c | 6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/src/intel/vulkan/anv_pipeline.c
> b/src/intel/vulkan/anv_pipeline.c
> > index ad0f08253e7..f170366d030 100644
> > --- a/src/intel/vulkan/anv_pipeline.c
> > +++ b/src/intel/vulkan/anv_pipeline.c
> > @@ -446,6 +446,9 @@ anv_pipeline_hash_graphics(struct anv_pipeline
> *pipeline,
> > if (layout)
> >_mesa_sha1_update(, layout->sha1, sizeof(layout->sha1));
> >
> > +   const bool rba = pipeline->device->robust_buffer_access;
> > +   _mesa_sha1_update(, , sizeof(rba));
> > +
> > for (unsigned s = 0; s < MESA_SHADER_STAGES; s++) {
> >if (stages[s].entrypoint)
> >   anv_pipeline_hash_shader(, [s]);
> > @@ -466,6 +469,9 @@ anv_pipeline_hash_compute(struct anv_pipeline
> *pipeline,
> > if (layout)
> >_mesa_sha1_update(, layout->sha1, sizeof(layout->sha1));
> >
> > +   const bool rba = pipeline->device->robust_buffer_access;
> > +   _mesa_sha1_update(, , sizeof(rba));
> > +
> > anv_pipeline_hash_shader(, stage);
> >
> > _mesa_sha1_final(, sha1_out);
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] drisw: Use separate drisw_loader_funcs for shm

2018-11-23 Thread Michal Srb
On pátek 23. listopadu 2018 16:41:33 CET Emil Velikov wrote:
> Hi Michal,
> 
> On 2018/11/23, Michal Srb wrote:
> > The original code was modifying the global drisw_lf variable, which is bad
> > when there are multiple contexts in single process, each initialized with
> > different loader. One may support put_image_shm and the other not.
> > 
> > Since there are currently only two possible combinations, lets create two
> > global tables, one for each. Lets make them const, since we won't change
> > them and they can be shared.
> 
> When possible, please mention the commit which "breaks" things, like
> below. It helps highlight exactly where a backport/cherry-pick is
> applicable.
> 
> Fixes: 63c427fa71a ("drisw: use putImageShm if available")
> 
> > Signed-off-by: Michal Srb 
> > ---
> > This fixes crash in VLC. It used two GL contexts (each in different
> > thread), one was initialized by its Qt GUI, the other by its video output
> > plugin. The first one set the put_image_shm=drisw_put_image_shm, the
> > second did not, but since the same structure was used, the
> > drisw_put_image_shm was used too. Then it crashed because the second
> > loader did not have putImageShm set.
> > 
> > Downstream bug:
> > https://bugzilla.opensuse.org/show_bug.cgi?id=1113533
> 
> Personally, I'd keep the extra note about VLC and downstream bug in the
> commit message. Although if you prefer let's keep it as-is.
> 
> For the series:
> Reviewed-by: Emil Velikov 
> 
> I'll push this early/mid next weeks, unless someone beats me to it.

Thank you for the review. I'll send v2 with the Fixes and the note moved to 
the commit message.

Br,
Michal


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


[Mesa-dev] [PATCH] radv: only allocate HTILE if depth/stencil attachment usage is used

2018-11-23 Thread Samuel Pitoiset
Apparently some games allocate depth buffers without rendering
to them, this will avoid wasting memory if that image usage
flag is not set.

Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_image.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 7492bf48b51..a293834c4c3 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -923,7 +923,8 @@ radv_image_can_enable_fmask(struct radv_image *image)
 static inline bool
 radv_image_can_enable_htile(struct radv_image *image)
 {
-   return image->info.levels == 1 &&
+   return image->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT &&
+  image->info.levels == 1 &&
   vk_format_is_depth(image->vk_format) &&
   image->info.width * image->info.height >= 8 * 8;
 }
-- 
2.19.1

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


Re: [Mesa-dev] [PATCH 3/6] mesa/st: Factor out array and buffer setup from st_atom_array.c.

2018-11-23 Thread Mathias Fröhlich
Hi Chris,

On Friday, 23 November 2018 16:12:38 CET Chris Wilson wrote:
> 
> Something to note here is that valgrind reports
> (piglit/bin/drawoverhead):
> 
> ==492== Use of uninitialised value of size 8
> ==492==at 0x6EB8FA9: cso_hash_find_node (cso_hash.c:198)
> ==492==by 0x6EB9026: cso_hash_insert (cso_hash.c:213)
> ==492==by 0x6EB6730: cso_set_vertex_elements (cso_context.c:1092)
> ==492==by 0x714C76F: set_vertex_attribs (st_atom_array.c:384)
> ==492==by 0x714C76F: st_update_array (st_atom_array.c:512)
> ==492==by 0x71073F3: st_validate_state (st_atom.c:261)
> ==492==by 0x70615D1: prepare_draw (st_draw.c:123)
> ==492==by 0x70615D1: st_draw_vbo (st_draw.c:149)
> ==492==by 0x70F5BF4: _mesa_validated_drawrangeelements (draw.c:850)
> ==492==by 0x70F5BF4: _mesa_validated_drawrangeelements (draw.c:782)
> ==492==by 0x70F5F32: _mesa_DrawElements (draw.c:1004)
> ==492==by 0x48F6C74: stub_glDrawElements (piglit-dispatch-gen.c:12618)
> ==492==by 0x10B3F4: draw (drawoverhead.c:275)
> ==492==by 0x10D070: perf_measure_rate (common.c:56)
> ==492==by 0x10C69E: perf_run (drawoverhead.c:645)
> ==492==  Uninitialised value was created by a stack allocation
> ==492==at 0x714C25D: st_update_array (st_atom_array.c:389)
> 
> from velements being used sparsely.
> 
> Does your patch prevent this?

I tried to reproduce this, but valgrind does not show any failures with 
drawoverhead
on radeonsi.
What driver backend do you use?

best
Mathias

> -Chris




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


[Mesa-dev] [Bug 108848] 3d image broken in Dragon age: origins

2018-11-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108848

--- Comment #1 from ilia  ---
Created attachment 142587
  --> https://bugs.freedesktop.org/attachment.cgi?id=142587=edit
Log with nine enabled

Game running with
GALLIUM_HUD="fps,requested-VRAM" LIBGL_DEBUG=verbose GALLIUM_PRINT_OPTIONS=all
ST_DEBUG=constants EGL_LOG_LEVEL=debug MESA_DEBUG=3 NINE_DEBUG=all
WINEDEBUG=d3d9nine,d3d9

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


[Mesa-dev] [PATCH 1/2] radv: add device->instance extension dependencies

2018-11-23 Thread Niklas Haas
From the vulkan spec 33.3 "Extension Dependencies":

"Any device extension that has an instance extension dependency that is
not enabled by vkCreateInstance is considered to be unsupported, hence
it must not be returned by vkEnumerateDeviceExtensionProperties for any
VkPhysicalDevice child of the instance."

Therefore we need to check whether the instance-level extensions are
actually enabled when deciding to support a device-level extension or
not.

Furthermore, we need to do this for all instance-level extensions of any
(transitive) device-level extension dependency, due to the following
paragraph:

"If an extension is supported (as queried by
vkEnumerateInstanceExtensionProperties or
vkEnumerateDeviceExtensionProperties), then required extensions of that
extension must also be supported for the same instance or physical
device."

Finally, because some of these vulkan extensions may be implicitly
promoted to future vulkan core API versions, we can also satisfy the
dependency if the vulkan API version is high enough.
---
 src/amd/vulkan/radv_extensions.py | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/src/amd/vulkan/radv_extensions.py 
b/src/amd/vulkan/radv_extensions.py
index 6bdf988d11..da130082bd 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -182,6 +182,32 @@ def _init_exts_from_xml(xml):
 
 ext = ext_name_map[ext_name]
 ext.type = ext_elem.attrib['type']
+ext.promotedto = ext_elem.attrib.get('promotedto', None)
+try:
+ext.requires = ext_elem.attrib['requires'].split(',')
+except KeyError:
+ext.requires = []
+
+def extra_deps(ext):
+if ext.type == 'instance':
+check = 'instance->enabled_extensions.{}'.format(ext.name[3:])
+if ext.promotedto is not None:
+# the xml contains values like VK_VERSION_1_1, but we need to
+# translate them to VK_API_VERSION_1_1 for the apiVersion check
+api_ver = ext.promotedto.replace('VK_VER', 'VK_API_VER')
+check = '({} || instance->apiVersion >= {})'.format(check, 
api_ver)
+return set([check])
+
+deps = set()
+for dep in ext.requires:
+deps |= extra_deps(ext_name_map[dep])
+
+return deps
+
+for ext in EXTENSIONS:
+if ext.type == 'device':
+for dep in extra_deps(ext):
+ext.enable += ' && ' + dep
 
 _TEMPLATE_H = Template(COPYRIGHT + """
 #ifndef RADV_EXTENSIONS_H
@@ -276,6 +302,7 @@ const struct radv_instance_extension_table 
radv_supported_instance_extensions =
 void radv_fill_device_extension_table(const struct radv_physical_device 
*device,
   struct radv_device_extension_table* 
table)
 {
+const struct radv_instance *instance = device->instance;
 %for ext in device_extensions:
table->${ext.name[3:]} = ${ext.enable};
 %endfor
-- 
2.19.1

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


[Mesa-dev] [PATCH 2/2] radv: correctly use vulkan 1.0 by default

2018-11-23 Thread Niklas Haas
From the vulkan spec 3.2 "Instances":

"Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an
apiVersion of 0 is equivalent to providing an apiVersion of
VK_MAKE_VERSION(1,0,0)."
---
 src/amd/vulkan/radv_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 70084a2b60..c258599888 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -525,7 +525,7 @@ VkResult radv_CreateInstance(
pCreateInfo->pApplicationInfo->apiVersion != 0) {
client_version = pCreateInfo->pApplicationInfo->apiVersion;
} else {
-   radv_EnumerateInstanceVersion(_version);
+   client_version = VK_API_VERSION_1_0;
}
 
instance = vk_zalloc2(_alloc, pAllocator, sizeof(*instance), 8,
-- 
2.19.1

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


[Mesa-dev] [Bug 108848] 3d image broken in Dragon age: origins

2018-11-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108848

--- Comment #2 from ilia  ---
Created attachment 142588
  --> https://bugs.freedesktop.org/attachment.cgi?id=142588=edit
Log with nine disabled

Same env variables as with nine enabled.

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


[Mesa-dev] [PATCH v2 07/29] mesa/main: use _mesa_has_FOO_bar for compressed format checks

2018-11-23 Thread Erik Faye-Lund
_mesa_has_FOO_bar() knows about the APIs these extensions should be
supported under, so let's use that to simplify these checks a bit.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 7f49e53b8dc..a5eb0dabb3b 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1354,8 +1354,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format)
case GL_RGBA4_S3TC:
   return _mesa_has_S3_s3tc(ctx);
case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
-  return ctx->API == API_OPENGL_COMPAT
- && ctx->Extensions.ATI_texture_compression_3dc;
+  return _mesa_has_ATI_texture_compression_3dc(ctx);
case GL_PALETTE4_RGB8_OES:
case GL_PALETTE4_RGBA8_OES:
case GL_PALETTE4_R5_G6_B5_OES:
@@ -1381,22 +1380,17 @@ _mesa_is_compressed_format(const struct gl_context 
*ctx, GLenum format)
 _mesa_has_S3_s3tc(ctx);
   }
case MESA_FORMAT_LAYOUT_FXT1:
-  return _mesa_is_desktop_gl(ctx)
- && ctx->Extensions.TDFX_texture_compression_FXT1;
+  return _mesa_has_3DFX_texture_compression_FXT1(ctx);
case MESA_FORMAT_LAYOUT_RGTC:
-  return _mesa_is_desktop_gl(ctx)
- && ctx->Extensions.ARB_texture_compression_rgtc;
+  return _mesa_has_ARB_texture_compression_rgtc(ctx);
case MESA_FORMAT_LAYOUT_LATC:
-  return ctx->API == API_OPENGL_COMPAT
- && ctx->Extensions.EXT_texture_compression_latc;
+  return _mesa_has_EXT_texture_compression_latc(ctx);
case MESA_FORMAT_LAYOUT_ETC1:
-  return _mesa_is_gles(ctx)
- && ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
+  return _mesa_has_OES_compressed_ETC1_RGB8_texture(ctx);
case MESA_FORMAT_LAYOUT_ETC2:
   return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility;
case MESA_FORMAT_LAYOUT_BPTC:
-  return _mesa_is_desktop_gl(ctx) &&
- ctx->Extensions.ARB_texture_compression_bptc;
+  return _mesa_has_ARB_texture_compression_bptc(ctx);
case MESA_FORMAT_LAYOUT_ASTC:
   return ctx->Extensions.KHR_texture_compression_astc_ldr;
default:
-- 
2.19.1

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


Re: [Mesa-dev] [PATCH 2/2] glsl: free or reuse memory allocated for TF varying

2018-11-23 Thread Gert Wollny
Hello Tapani, 

since you wrote the original code, could you have a look at this patch?

Many thanks, 
Gert

Am Freitag, den 16.11.2018, 19:12 +0100 schrieb Gert Wollny:
> From: Gert Wollny 
> 
> When a shader program is de-serialized the gl_shader_program passed
> in
> may actually still hold memory allocations for the transform feedback
> varyings. If that is the case, free the varying names and reallocate
> the new storage for the names array.
> 
> This fixes a memory leak:
> Direct leak of 48 byte(s) in 6 object(s) allocated from:
>  in malloc (/usr/lib64/gcc/x86_64-pc-linux-
> gnu/7.3.0/libasan.so+0xdb880)
>  in transform_feedback_varyings
> ../../samba/mesa/src/mesa/main/transformfeedback.c:875
>  in _mesa_TransformFeedbackVaryings
> ../../samba/mesa/src/mesa/main/transformfeedback.c:985
>  ...
> Indirect leak of 42 byte(s) in 6 object(s) allocated from:
>   in __interceptor_strdup (/usr/lib64/gcc/x86_64-pc-linux-
> gnu/7.3.0/libasan.so+0x761c8)
>   in transform_feedback_varyings
> ../../samba/mesa/src/mesa/main/transformfeedback.c:887
>   in _mesa_TransformFeedbackVaryings
> ../../samba/mesa/src/mesa/main/transformfeedback.c:985
> 
> Fixes: ab2643e4b06f63c93a57624003679903442634a8
>glsl: serialize data from glTransformFeedbackVaryings
> 
> Signed-off-by: Gert Wollny 
> ---
>  src/compiler/glsl/serialize.cpp | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/serialize.cpp
> b/src/compiler/glsl/serialize.cpp
> index 267700e7e7..26d8ec4b75 100644
> --- a/src/compiler/glsl/serialize.cpp
> +++ b/src/compiler/glsl/serialize.cpp
> @@ -360,13 +360,20 @@ read_xfb(struct blob_reader *metadata, struct
> gl_shader_program *shProg)
> if (xfb_stage == ~0u)
>return;
>  
> +   if (shProg->TransformFeedback.VaryingNames)  {
> +  for (unsigned i = 0; i < shProg->TransformFeedback.NumVarying; 
> ++i)
> + free(shProg->TransformFeedback.VaryingNames[i]);
> +   }
> +
> /* Data set by glTransformFeedbackVaryings. */
> shProg->TransformFeedback.BufferMode =
> blob_read_uint32(metadata);
> blob_copy_bytes(metadata, 
> >TransformFeedback.BufferStride,
> sizeof(shProg->TransformFeedback.BufferStride));
> shProg->TransformFeedback.NumVarying =
> blob_read_uint32(metadata);
> +
> shProg->TransformFeedback.VaryingNames = (char **)
> -  malloc(shProg->TransformFeedback.NumVarying * sizeof(GLchar
> *));
> +  realloc(shProg->TransformFeedback.VaryingNames,
> + shProg->TransformFeedback.NumVarying * sizeof(GLchar
> *));
> /* Note, malloc used with VaryingNames. */
> for (unsigned i = 0; i < shProg->TransformFeedback.NumVarying;
> i++)
>shProg->TransformFeedback.VaryingNames[i] =
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 00/13] query validation fixes

2018-11-23 Thread Erik Faye-Lund
On Fri, 2018-11-23 at 07:45 +0200, Tapani Pälli wrote:
> Ping, this series has not landed yet, planning to land it soon?
> 

Sorry for the delay, pushed now!

> On 11/9/18 7:58 AM, Tapani Pälli wrote:
> > Thanks, _mesa_has makes things a lot cleaner and simpler to manage;
> > 
> > Reviewed-by: Tapani Pälli 
> > 
> > On 11/8/18 2:42 PM, Erik Faye-Lund wrote:
> > > Here's v2 of this series. Changes are as follows:
> > > 
> > > - 5/13: also check for ARB_occlusion_query2, for core-contexts
> > > - 8/13: also check for EXT_disjoint_timer_query, for gles-
> > > contexts
> > > - 9/13: also check for OES_geometry_shader, for gles-contexts
> > > - 12/13: also check for EXT_disjoint_timer_query, for gles-
> > > contexts
> > > 
> > > In addition, there's regression in a piglit-test, but that test
> > > is wrong
> > > and uses invalid queries on GLES. A patch for that test has been
> > > sent to
> > > the piglit mailing list, here:
> > > 
> > > https://patchwork.freedesktop.org/series/52216/
> > > 
> > > Thanks to Tapani Pälli for testing this on the intel-ci system :)
> > > 
> > > Erik Faye-Lund (13):
> > >mesa/main: correct requirement for EXT_occlusion_query_boolean
> > >mesa/main: correct year for EXT_occlusion_query_boolean
> > >mesa/main: use non-prefixed enums for consistency
> > >mesa/main: simplify pipeline-statistics query validation
> > >mesa/main: fix validation of GL_SAMPLES_PASSED
> > >mesa/main: fix validation of GL_ANY_SAMPLES_PASSED
> > >mesa/main: fix validation of
> > > GL_ANY_SAMPLES_PASSED_CONSERVATIVE
> > >mesa/main: fix validation of GL_TIME_ELAPSED
> > >mesa/main: fix validation of transform-feedback queries
> > >mesa/main: fix validation of transform-feedback overflow
> > > queries
> > >mesa/main: fix validation of ARB_query_buffer_object
> > >mesa/main: fix validation of GL_TIMESTAMP
> > >mesa/main: remove overly strict query-validation
> > > 
> > >   src/mesa/main/extensions_table.h |   2 +-
> > >   src/mesa/main/queryobj.c | 112 ++
> > > -
> > >   2 files changed, 52 insertions(+), 62 deletions(-)
> > > 

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


Re: [Mesa-dev] [PATCH 2/2] radv: ignore subpass self-dependencies for CreateRenderPass() too

2018-11-23 Thread Bas Nieuwenhuizen
Reviewed-by: Bas Nieuwenhuizen 

for both.
On Fri, Nov 23, 2018 at 9:45 AM Samuel Pitoiset
 wrote:
>
> We really need to refactor this...
>
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/amd/vulkan/radv_pass.c | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/src/amd/vulkan/radv_pass.c b/src/amd/vulkan/radv_pass.c
> index f8e5ea40954..b41ae89deec 100644
> --- a/src/amd/vulkan/radv_pass.c
> +++ b/src/amd/vulkan/radv_pass.c
> @@ -180,7 +180,17 @@ VkResult radv_CreateRenderPass(
> }
>
> for (unsigned i = 0; i < pCreateInfo->dependencyCount; ++i) {
> +   uint32_t src = pCreateInfo->pDependencies[i].srcSubpass;
> uint32_t dst = pCreateInfo->pDependencies[i].dstSubpass;
> +
> +   /* Ignore subpass self-dependencies as they allow the app to
> +* call vkCmdPipelineBarrier() inside the render pass and the
> +* driver should only do the barrier when called, not when
> +* starting the render pass.
> +*/
> +   if (src == dst)
> +   continue;
> +
> if (dst == VK_SUBPASS_EXTERNAL) {
> pass->end_barrier.src_stage_mask = 
> pCreateInfo->pDependencies[i].srcStageMask;
> pass->end_barrier.src_access_mask = 
> pCreateInfo->pDependencies[i].srcAccessMask;
> --
> 2.19.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 108848] 3d image broken in Dragon age: origins

2018-11-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108848

Bug ID: 108848
   Summary: 3d image broken in Dragon age: origins
   Product: Mesa
   Version: 18.2
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Gallium/StateTracker/galliumnine
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: infer...@gmail.com
QA Contact: mesa-dev@lists.freedesktop.org

Created attachment 142586
  --> https://bugs.freedesktop.org/attachment.cgi?id=142586=edit
Game main menu

Picture is bad with nine enabled and good when nine disabled.
Intro video displays correct, also gallium HUD displays correct to.

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


Re: [Mesa-dev] [PATCH 29/30] mesa/main: do not require float-texture filtering for es3

2018-11-23 Thread Erik Faye-Lund
On Thu, 2018-11-22 at 13:26 +0100, Mathias Fröhlich wrote:
> Hi Erik,
> 
> The series looks very reasonable and I could not spot loosing any
> negating ! in the
> query logic. Even if I have not been able time wise to double checked
> every move when
> which texture format got introduced in which ES GL version.
> So, what can I tell now? Is that already a reviewed by?

I dunno, I think that's up to you :P

I'll send out a v2 of the series soon with the fixes from Francesco's
comments in place, and the last patch dropped.

> What tests did you run on the series?

I ran the piglit quick_gl tests

> May be I can convince myself to go forward using this testing
> information ...
> 
> Well - and given the amount of discussion about #30, I mean #1-#29.

Yeah, patch #30 is out :)


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


[Mesa-dev] [PATCH 2/6] mesa/st: Only unmap the uploader that was actually used.

2018-11-23 Thread Mathias . Froehlich
From: Mathias Fröhlich 

In st_atom_array, we only need to unmap the upload buffer that
was actually used.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/state_tracker/st_atom_array.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_atom_array.c 
b/src/mesa/state_tracker/st_atom_array.c
index 9831045b34..cd00529ddf 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -499,7 +499,8 @@ st_update_array(struct st_context *st)
 [bufidx].buffer_offset,
 [bufidx].buffer.resource);
 
-  if (!ctx->Const.AllowMappedBuffersDuringExecution) {
+  if (!ctx->Const.AllowMappedBuffersDuringExecution &&
+  !st->can_bind_const_buffer_as_vertex) {
  u_upload_unmap(st->pipe->stream_uploader);
   }
}
-- 
2.17.2

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


[Mesa-dev] [PATCH 5/6] mesa/st: Use binding information from the VAO in feedback rendering.

2018-11-23 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Use VAO binding information in feedback rendering. In theory
it should reduce the amount of buffer objects scheduled for rendering.
Feedback rendering is implemented in a crude way anyhow, so I do not
expect much gain here. But for the sake of code reuse we should
use the same code for the same task. And finally if feeback rendering
may get improved the array setup is already well done there.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/state_tracker/st_atom.h  |  7 ++
 src/mesa/state_tracker/st_atom_array.c| 30 
 src/mesa/state_tracker/st_draw_feedback.c | 93 ---
 3 files changed, 68 insertions(+), 62 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index 901e9b6d43..d36f0180fa 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -75,6 +75,13 @@ st_setup_current(struct st_context *st,
  struct pipe_vertex_element *velements,
  struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
 
+void
+st_setup_current_user(struct st_context *st,
+  const struct st_vertex_program *vp,
+  const struct st_vp_variant *vp_variant,
+  struct pipe_vertex_element *velements,
+  struct pipe_vertex_buffer *vbuffer, unsigned 
*num_vbuffers);
+
 /* Define ST_NEW_xxx_INDEX */
 enum {
 #define ST_STATE(FLAG, st_update) FLAG##_INDEX,
diff --git a/src/mesa/state_tracker/st_atom_array.c 
b/src/mesa/state_tracker/st_atom_array.c
index ac9bd727df..1073e76c3e 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -510,6 +510,36 @@ st_setup_current(struct st_context *st,
}
 }
 
+void
+st_setup_current_user(struct st_context *st,
+  const struct st_vertex_program *vp,
+  const struct st_vp_variant *vp_variant,
+  struct pipe_vertex_element *velements,
+  struct pipe_vertex_buffer *vbuffer, unsigned 
*num_vbuffers)
+{
+   struct gl_context *ctx = st->ctx;
+   const GLbitfield inputs_read = vp_variant->vert_attrib_mask;
+   const ubyte *input_to_index = vp->input_to_index;
+
+   /* Process values that should have better been uniforms in the application 
*/
+   GLbitfield curmask = inputs_read & _mesa_draw_current_bits(ctx);
+   /* For each attribute, make an own user buffer binding. */
+   while (curmask) {
+  const gl_vert_attrib attr = u_bit_scan();
+  const struct gl_array_attributes *const attrib
+ = _mesa_draw_current_attrib(ctx, attr);
+  const unsigned bufidx = (*num_vbuffers)++;
+
+  init_velement_lowered(vp, velements, >Format, 0, 0,
+bufidx, input_to_index[attr]);
+
+  vbuffer[bufidx].is_user_buffer = true;
+  vbuffer[bufidx].buffer.user = attrib->Ptr;
+  vbuffer[bufidx].buffer_offset = 0;
+  vbuffer[bufidx].stride = 0;
+   }
+}
+
 void
 st_update_array(struct st_context *st)
 {
diff --git a/src/mesa/state_tracker/st_draw_feedback.c 
b/src/mesa/state_tracker/st_draw_feedback.c
index 82f2feb86e..6ec6d5c16f 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -127,12 +127,14 @@ st_feedback_draw_vbo(struct gl_context *ctx,
struct pipe_context *pipe = st->pipe;
struct draw_context *draw = st_get_draw_context(st);
const struct st_vertex_program *vp;
+   struct st_vp_variant *vp_variant;
const struct pipe_shader_state *vs;
struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS];
+   unsigned num_vbuffers = 0;
struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {NULL};
struct pipe_transfer *ib_transfer = NULL;
-   GLuint attr, i;
+   GLuint i;
const void *mapped_indices = NULL;
 
if (!draw)
@@ -148,10 +150,11 @@ st_feedback_draw_vbo(struct gl_context *ctx,
 
/* must get these after state validation! */
vp = st->vp;
-   vs = >vp_variant->tgsi;
+   vp_variant = st->vp_variant;
+   vs = _variant->tgsi;
 
-   if (!st->vp_variant->draw_shader) {
-  st->vp_variant->draw_shader = draw_create_vertex_shader(draw, vs);
+   if (!vp_variant->draw_shader) {
+  vp_variant->draw_shader = draw_create_vertex_shader(draw, vs);
}
 
/*
@@ -164,64 +167,30 @@ st_feedback_draw_vbo(struct gl_context *ctx,
draw_set_viewport_states(draw, 0, 1, >state.viewport[0]);
draw_set_clip_state(draw, >state.clip);
draw_set_rasterizer_state(draw, >state.rasterizer, NULL);
-   draw_bind_vertex_shader(draw, st->vp_variant->draw_shader);
+   draw_bind_vertex_shader(draw, vp_variant->draw_shader);
set_feedback_vertex_format(ctx);
 
-   /* loop over TGSI shader inputs to determine vertex buffer
-* and attribute info
-*/
-   for (attr = 0; attr < vp->num_inputs; attr++) {
-  const GLuint mesaAttr = 

[Mesa-dev] [PATCH 3/6] mesa/st: Factor out array and buffer setup from st_atom_array.c.

2018-11-23 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Factor out vertex array setup routines from the array state atom.
The factored functions will be used in feedback rendering in the
next change.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/state_tracker/st_atom.h   | 17 ++
 src/mesa/state_tracker/st_atom_array.c | 79 +++---
 2 files changed, 74 insertions(+), 22 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index 9f3ca38c19..901e9b6d43 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -37,6 +37,10 @@
 #include "main/glheader.h"
 
 struct st_context;
+struct st_vertex_program;
+struct st_vp_variant;
+struct pipe_vertex_buffer;
+struct pipe_vertex_element;
 
 /**
  * Enumeration of state tracker pipelines.
@@ -57,6 +61,19 @@ GLuint st_compare_func_to_pipe(GLenum func);
 enum pipe_format
 st_pipe_vertex_format(const struct gl_vertex_format *glformat);
 
+void
+st_setup_arrays(struct st_context *st,
+const struct st_vertex_program *vp,
+const struct st_vp_variant *vp_variant,
+struct pipe_vertex_element *velements,
+struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
+
+void
+st_setup_current(struct st_context *st,
+ const struct st_vertex_program *vp,
+ const struct st_vp_variant *vp_variant,
+ struct pipe_vertex_element *velements,
+ struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
 
 /* Define ST_NEW_xxx_INDEX */
 enum {
diff --git a/src/mesa/state_tracker/st_atom_array.c 
b/src/mesa/state_tracker/st_atom_array.c
index cd00529ddf..ac9bd727df 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -384,25 +384,17 @@ set_vertex_attribs(struct st_context *st,
 }
 
 void
-st_update_array(struct st_context *st)
+st_setup_arrays(struct st_context *st,
+const struct st_vertex_program *vp,
+const struct st_vp_variant *vp_variant,
+struct pipe_vertex_element *velements,
+struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
 {
struct gl_context *ctx = st->ctx;
-   /* vertex program validation must be done before this */
-   const struct st_vertex_program *vp = st->vp;
-   /* _NEW_PROGRAM, ST_NEW_VS_STATE */
-   const GLbitfield inputs_read = st->vp_variant->vert_attrib_mask;
const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
+   const GLbitfield inputs_read = vp_variant->vert_attrib_mask;
const ubyte *input_to_index = vp->input_to_index;
 
-   struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
-   struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
-   unsigned num_vbuffers = 0;
-
-   st->vertex_array_out_of_memory = FALSE;
-   st->draw_needs_minmax_index = false;
-
-   /* _NEW_PROGRAM */
-   /* ST_NEW_VERTEX_ARRAYS alias ctx->DriverFlags.NewArray */
/* Process attribute array data. */
GLbitfield mask = inputs_read & _mesa_draw_array_bits(ctx);
while (mask) {
@@ -410,7 +402,7 @@ st_update_array(struct st_context *st)
   const gl_vert_attrib i = ffs(mask) - 1;
   const struct gl_vertex_buffer_binding *const binding
  = _mesa_draw_buffer_binding(vao, i);
-  const unsigned bufidx = num_vbuffers++;
+  const unsigned bufidx = (*num_vbuffers)++;
 
   if (_mesa_is_bufferobj(binding->BufferObj)) {
  struct st_buffer_object *stobj = st_buffer_object(binding->BufferObj);
@@ -452,16 +444,28 @@ st_update_array(struct st_context *st)
input_to_index[attr]);
   }
}
+}
+
+void
+st_setup_current(struct st_context *st,
+ const struct st_vertex_program *vp,
+ const struct st_vp_variant *vp_variant,
+ struct pipe_vertex_element *velements,
+ struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
+{
+   struct gl_context *ctx = st->ctx;
+   const GLbitfield inputs_read = vp_variant->vert_attrib_mask;
 
-   const unsigned first_current_vbuffer = num_vbuffers;
-   /* _NEW_PROGRAM | _NEW_CURRENT_ATTRIB */
/* Process values that should have better been uniforms in the application 
*/
GLbitfield curmask = inputs_read & _mesa_draw_current_bits(ctx);
if (curmask) {
+  /* vertex program validation must be done before this */
+  const struct st_vertex_program *vp = st->vp;
+  const ubyte *input_to_index = vp->input_to_index;
   /* For each attribute, upload the maximum possible size. */
   GLubyte data[VERT_ATTRIB_MAX * sizeof(GLdouble) * 4];
   GLubyte *cursor = data;
-  const unsigned bufidx = num_vbuffers++;
+  const unsigned bufidx = (*num_vbuffers)++;
   unsigned max_alignment = 1;
 
   while (curmask) {
@@ -504,12 +508,43 @@ st_update_array(struct st_context *st)
  u_upload_unmap(st->pipe->stream_uploader);
   }
}
+}
 
-   const unsigned 

[Mesa-dev] [PATCH 4/6] mesa/st: Avoid extra references in the feedback draw function scope.

2018-11-23 Thread Mathias . Froehlich
From: Mathias Fröhlich 

The change removes the reference that is held on the entries of the
vbuffers[] array. The new code does not do that anymore as following
the code into draw_set_vertex_buffers() the draw context holds an
other reference as long as it is reset down the function again.
So it should be already by that argument save to remove that
additional reference count.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/state_tracker/st_draw_feedback.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_draw_feedback.c 
b/src/mesa/state_tracker/st_draw_feedback.c
index 11097b4cac..82f2feb86e 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -185,7 +185,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
 
  vbuffers[attr].buffer.resource = NULL;
  vbuffers[attr].is_user_buffer = false;
- pipe_resource_reference([attr].buffer.resource, 
stobj->buffer);
+ vbuffers[attr].buffer.resource = stobj->buffer;
  vbuffers[attr].buffer_offset = _mesa_draw_binding_offset(binding);
  velements[attr].src_offset =
 _mesa_draw_attributes_relative_offset(attrib);
@@ -275,7 +275,6 @@ st_feedback_draw_vbo(struct gl_context *ctx,
   if (vb_transfer[attr])
  pipe_buffer_unmap(pipe, vb_transfer[attr]);
   draw_set_mapped_vertex_buffer(draw, attr, NULL, 0);
-  pipe_vertex_buffer_unreference([attr]);
}
draw_set_vertex_buffers(draw, 0, vp->num_inputs, NULL);
 }
-- 
2.17.2

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


[Mesa-dev] [PATCH 1/6] mesa/st: Only care about the uploader if it was used.

2018-11-23 Thread Mathias . Froehlich
From: Mathias Fröhlich 

In st_atom_array, we only need to care for unmapping the upload buffer
if we actually used it.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/state_tracker/st_atom_array.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_array.c 
b/src/mesa/state_tracker/st_atom_array.c
index 19a5ef29a9..9831045b34 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -498,10 +498,10 @@ st_update_array(struct st_context *st)
 0, cursor - data, max_alignment, data,
 [bufidx].buffer_offset,
 [bufidx].buffer.resource);
-   }
 
-   if (!ctx->Const.AllowMappedBuffersDuringExecution) {
-  u_upload_unmap(st->pipe->stream_uploader);
+  if (!ctx->Const.AllowMappedBuffersDuringExecution) {
+ u_upload_unmap(st->pipe->stream_uploader);
+  }
}
 
const unsigned num_inputs = st->vp_variant->num_inputs;
-- 
2.17.2

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


[Mesa-dev] [PATCH 6/6] mesa/st: Make st_pipe_vertex_format static.

2018-11-23 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/state_tracker/st_atom.h   | 3 ---
 src/mesa/state_tracker/st_atom_array.c | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index d36f0180fa..ccf58b10e9 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -58,9 +58,6 @@ void st_destroy_atoms( struct st_context *st );
 void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
 GLuint st_compare_func_to_pipe(GLenum func);
 
-enum pipe_format
-st_pipe_vertex_format(const struct gl_vertex_format *glformat);
-
 void
 st_setup_arrays(struct st_context *st,
 const struct st_vertex_program *vp,
diff --git a/src/mesa/state_tracker/st_atom_array.c 
b/src/mesa/state_tracker/st_atom_array.c
index 1073e76c3e..7a63d7504f 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -237,7 +237,7 @@ static const uint16_t vertex_formats[][4][4] = {
 /**
  * Return a PIPE_FORMAT_x for the given GL datatype and size.
  */
-enum pipe_format
+static enum pipe_format
 st_pipe_vertex_format(const struct gl_vertex_format *vformat)
 {
const GLubyte size = vformat->Size;
-- 
2.17.2

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


[Mesa-dev] [PATCH 0/6] Use common code for gallium array setup.

2018-11-23 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Hi,

The series unifies functions for array setup into gallium.
Instead of just walking all VAO attributes we can make use of
the enabled and required attribute arrays also for feedback
rendering.
Along that way cleanup duplicate references and unneeded
calls to the uploader.
Beside unifying common code, the series prepare the gallium
side of the removal of intermediately introduced methods
for VAO/current value array access.

The changes were tested with llvmpipe and radeonsi and piglit
without regresseions by this series.

please review

Thanks in advance and best
Mathias



Mathias Fröhlich (6):
  mesa/st: Only care about the uploader if it was used.
  mesa/st: Only unmap the uploader that was actually used.
  mesa/st: Factor out array and buffer setup from st_atom_array.c.
  mesa/st: Avoid extra references in the feedback draw function scope.
  mesa/st: Use binding information from the VAO in feedback rendering.
  mesa/st: Make st_pipe_vertex_format static.

 src/mesa/state_tracker/st_atom.h  |  27 -
 src/mesa/state_tracker/st_atom_array.c| 116 +-
 src/mesa/state_tracker/st_draw_feedback.c |  94 ++
 3 files changed, 146 insertions(+), 91 deletions(-)

-- 
2.17.2

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


Re: [Mesa-dev] [PATCH] meson: Bump version to 0.46 for python module

2018-11-23 Thread Eero Tamminen

Hi,

On 21.11.2018 20.13, Dylan Baker wrote:

From: Arfrever Frehtes Taifersar Arahesis 

Meson has two modules for finding python, the python3 module and the
python module. Python3 is older, and has some corner cases, python is
newer, has no known corner cases and can detect python2. Things have
generally seemed to work okay for us using python3, but there are cases
where things fall down (such as if you have python 3.4 as your default
python3.

Debian provides 0.48.x in buster (testing)
fedora has 0.47.x in 27 and 28
fedora has 0.48.x in 29
arch has 0.48.x


Ubuntu 18.04 LTS has meson v0.45.1 (and LLVM v6 & kernel v4.15).

First HW enabling packages from 18.10 (kernel v4.18, LLVM v7,
meson v0.47.2) are scheduled for next February 2019.

It would be nice if build breakage would be postponed enough
that deps would be available there too.


- Eero



cc: matts...@gmail.com
distro-bug: https://bugs.gentoo.org/671308
Reviewed-by: Dylan Baker 
---
  docs/meson.html | 2 +-
  meson.build | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/meson.html b/docs/meson.html
index 68f80d6ac42..af109d3d8b0 100644
--- a/docs/meson.html
+++ b/docs/meson.html
@@ -24,7 +24,7 @@ for production
  The meson build is tested on Linux, macOS, Cygwin and Haiku, FreeBSD,
  DragonflyBSD, NetBSD, and should work on OpenBSD.
  
-Mesa requires Meson >= 0.45.0 to build.

+Mesa requires Meson >= 0.46.0 to build.
  
  Some older versions of meson do not check that they are too old and will error

  out in odd ways.
diff --git a/meson.build b/meson.build
index 33f4e5ad3cf..ee2d1a82984 100644
--- a/meson.build
+++ b/meson.build
@@ -25,7 +25,7 @@ project(
  [find_program('python', 'python2', 'python3'), 'bin/meson_get_version.py']
).stdout(),
license : 'MIT',
-  meson_version : '>= 0.45',
+  meson_version : '>= 0.46',
default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 
'c_std=c99', 'cpp_std=c++11']
  )
  
@@ -709,7 +709,7 @@ if with_platform_haiku

pre_args += '-DHAVE_HAIKU_PLATFORM'
  endif
  
-prog_python = import('python3').find_python()

+prog_python = import('python').find_installation('python3')
  has_mako = run_command(
prog_python, '-c',
'''



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


[Mesa-dev] [Bug 108848] 3d image broken in Dragon age: origins

2018-11-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=108848

--- Comment #3 from ilia  ---
Created attachment 142590
  --> https://bugs.freedesktop.org/attachment.cgi?id=142590=edit
Wine backtrace of game segfault

In doubt is this relevant, but game also segfaults with this backtrace when
pressing "New game".

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


[Mesa-dev] [PATCH 2/2] radv: ignore subpass self-dependencies for CreateRenderPass() too

2018-11-23 Thread Samuel Pitoiset
We really need to refactor this...

Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_pass.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/amd/vulkan/radv_pass.c b/src/amd/vulkan/radv_pass.c
index f8e5ea40954..b41ae89deec 100644
--- a/src/amd/vulkan/radv_pass.c
+++ b/src/amd/vulkan/radv_pass.c
@@ -180,7 +180,17 @@ VkResult radv_CreateRenderPass(
}
 
for (unsigned i = 0; i < pCreateInfo->dependencyCount; ++i) {
+   uint32_t src = pCreateInfo->pDependencies[i].srcSubpass;
uint32_t dst = pCreateInfo->pDependencies[i].dstSubpass;
+
+   /* Ignore subpass self-dependencies as they allow the app to
+* call vkCmdPipelineBarrier() inside the render pass and the
+* driver should only do the barrier when called, not when
+* starting the render pass.
+*/
+   if (src == dst)
+   continue;
+
if (dst == VK_SUBPASS_EXTERNAL) {
pass->end_barrier.src_stage_mask = 
pCreateInfo->pDependencies[i].srcStageMask;
pass->end_barrier.src_access_mask = 
pCreateInfo->pDependencies[i].srcAccessMask;
-- 
2.19.1

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


[Mesa-dev] [PATCH 1/2] radv: remove useless before CmdClear{Color, DepthStencil}Image()

2018-11-23 Thread Samuel Pitoiset
We don't need to flush anything before these two commands as well.
This is because they have to be externally synchronized, so the
app should have called CmdPipelineBarrier() prior to that and the
driver should have flushed the caches.

Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_meta_clear.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index e82b6fd2f58..db62fdf65f9 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -954,9 +954,7 @@ emit_fast_htile_clear(struct radv_cmd_buffer *cmd_buffer,
cmd_buffer->state.flush_bits |= (RADV_CMD_FLAG_FLUSH_AND_INV_DB 
|
 
RADV_CMD_FLAG_FLUSH_AND_INV_DB_META) & ~ *pre_flush;
*pre_flush |= cmd_buffer->state.flush_bits;
-   } else
-   cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_DB |
-   
RADV_CMD_FLAG_FLUSH_AND_INV_DB_META;
+   }
 
if (htile_mask == UINT_MAX) {
/* Clear the whole HTILE buffer. */
@@ -1410,9 +1408,7 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
cmd_buffer->state.flush_bits |= (RADV_CMD_FLAG_FLUSH_AND_INV_CB 
|
 
RADV_CMD_FLAG_FLUSH_AND_INV_CB_META) & ~ *pre_flush;
*pre_flush |= cmd_buffer->state.flush_bits;
-   } else
-   cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_CB |
-   
RADV_CMD_FLAG_FLUSH_AND_INV_CB_META;
+   }
 
cmask_clear_value = radv_get_cmask_fast_clear_value(iview->image);
 
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 18/29] mesa/main: do not allow EXT_texture_shared_exponent enums before gles3

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.EXT_texture_shared_exponent is set regardless of the
API that's used, so checking for those direcly will always allow the
enums from this extensions when they are supported by the driver.

We also need to make sure this is enabled on OpenGL ES 3. Because the
check is repeated, let's introduce a helper.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h   | 6 ++
 src/mesa/main/glformats.c | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index af81717d9bd..7db3b94e0b6 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -367,6 +367,12 @@ _mesa_has_rg_textures(const struct gl_context *ctx)
return _mesa_has_ARB_texture_rg(ctx) || _mesa_is_gles3(ctx);
 }
 
+static inline bool
+_mesa_has_texture_shared_exponent(const struct gl_context *ctx)
+{
+   return _mesa_has_EXT_texture_shared_exponent(ctx) || _mesa_is_gles3(ctx);
+}
+
 /**
  * Checks if the context supports geometry shaders.
  */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 33c2f6ce68d..9e63845f0e4 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1966,7 +1966,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
return (ctx->API == API_OPENGLES2)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 case GL_UNSIGNED_INT_5_9_9_9_REV:
-   return ctx->Extensions.EXT_texture_shared_exponent
+   return _mesa_has_texture_shared_exponent(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 case GL_UNSIGNED_INT_10F_11F_11F_REV:
return _mesa_has_packed_float(ctx)
@@ -2589,7 +2589,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.EXT_texture_shared_exponent) {
+   if (_mesa_has_texture_shared_exponent(ctx)) {
   switch (internalFormat) {
   case GL_RGB9_E5_EXT:
  return GL_RGB;
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 20/29] mesa/main: do not allow type_2_10_10_10_REV enums before gles3

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.EXT_texture_type_2_10_10_10_REV is set regardless of
the API that's used, so checking for those direcly will always enable
extensions when they are supported by the driver.

There's no corresponding extension for OpenGL ES 1.x/2.0, so we
shouldn't allow these enums there.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h   | 7 +++
 src/mesa/main/glformats.c | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 7db3b94e0b6..071bd5b0818 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -373,6 +373,13 @@ _mesa_has_texture_shared_exponent(const struct gl_context 
*ctx)
return _mesa_has_EXT_texture_shared_exponent(ctx) || _mesa_is_gles3(ctx);
 }
 
+static inline bool
+_mesa_has_texture_type_2_10_10_10_REV(const struct gl_context *ctx)
+{
+   return _mesa_is_desktop_gl(ctx) ||
+  _mesa_has_EXT_texture_type_2_10_10_10_REV(ctx);
+}
+
 /**
  * Checks if the context supports geometry shaders.
  */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 7b86c1db9d0..2ac3110187f 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2194,7 +2194,7 @@ _mesa_es_error_check_format_and_type(const struct 
gl_context *ctx,
 || type == GL_UNSIGNED_SHORT_5_5_5_1
 || type == GL_FLOAT
 || type == GL_HALF_FLOAT_OES
-|| (ctx->Extensions.EXT_texture_type_2_10_10_10_REV &&
+|| (_mesa_has_texture_type_2_10_10_10_REV(ctx) &&
 type == GL_UNSIGNED_INT_2_10_10_10_REV));
   break;
 
@@ -2874,7 +2874,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
  case GL_RGBA:
  case GL_RGB10_A2:
  case GL_RGB5_A1:
-if (!ctx->Extensions.EXT_texture_type_2_10_10_10_REV)
+if (!_mesa_has_texture_type_2_10_10_10_REV(ctx))
return GL_INVALID_OPERATION;
 break;
  default:
@@ -3052,7 +3052,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
  * GLES3 doesn't, and GL_OES_required_internalformat extends that
  * to allow the sized RGB internalformats as well.
  */
-if (!ctx->Extensions.EXT_texture_type_2_10_10_10_REV)
+if (!_mesa_has_texture_type_2_10_10_10_REV(ctx))
return GL_INVALID_OPERATION;
 break;
  default:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 21/29] mesa/main: do not allow floating-point texture enums on gles1

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.OES_texture_float is set regardless of the API
that's used, so checking for those direcly will always allow the
enums from this extensions when they are supported by the driver.

There's no extension enabling floating-point textures for OpenGL
ES 1.x, so we shouldn't allow those enums there.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 2ac3110187f..453465fb1c8 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2895,7 +2895,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
return GL_INVALID_OPERATION;
 break;
  case GL_RGBA:
-if (ctx->Extensions.OES_texture_float && internalFormat == format)
+if (_mesa_has_OES_texture_float(ctx) && internalFormat == format)
break;
  default:
 return GL_INVALID_OPERATION;
@@ -2903,7 +2903,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
  break;
 
   case GL_HALF_FLOAT_OES:
- if (ctx->Extensions.OES_texture_half_float && internalFormat == 
format)
+ if (_mesa_has_OES_texture_half_float(ctx) && internalFormat == format)
 break;
   default:
  return GL_INVALID_OPERATION;
@@ -3030,7 +3030,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
return GL_INVALID_OPERATION;
 break;
  case GL_RGB:
-if (ctx->Extensions.OES_texture_float && internalFormat == format)
+if (_mesa_has_OES_texture_float(ctx) && internalFormat == format)
break;
  default:
 return GL_INVALID_OPERATION;
@@ -3038,7 +3038,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
  break;
 
   case GL_HALF_FLOAT_OES:
- if (!ctx->Extensions.OES_texture_half_float || internalFormat != 
format)
+ if (!_mesa_has_OES_texture_half_float(ctx) || internalFormat != 
format)
 return GL_INVALID_OPERATION;
  break;
 
@@ -3138,7 +3138,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
break;
 case GL_RG:
if (_mesa_has_rg_textures(ctx) &&
-   ctx->Extensions.OES_texture_half_float)
+   _mesa_has_OES_texture_half_float(ctx))
   break;
 /* fallthrough */
 default:
@@ -3153,7 +3153,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
 break;
  case GL_RG:
 if (_mesa_has_rg_textures(ctx) &&
-ctx->Extensions.OES_texture_float)
+_mesa_has_OES_texture_float(ctx))
break;
 /* fallthrough */
  default:
@@ -3242,7 +3242,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
  case GL_RG:
  case GL_RED:
 if (_mesa_has_rg_textures(ctx) &&
-ctx->Extensions.OES_texture_half_float)
+_mesa_has_OES_texture_half_float(ctx))
break;
 /* fallthrough */
  default:
@@ -3257,7 +3257,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
 break;
  case GL_RED:
 if (_mesa_has_rg_textures(ctx) &&
-ctx->Extensions.OES_texture_float)
+_mesa_has_OES_texture_float(ctx))
break;
 /* fallthrough */
  default:
@@ -3369,11 +3369,11 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
case GL_LUMINANCE_ALPHA:
   switch (type) {
   case GL_FLOAT:
- if (!ctx->Extensions.OES_texture_float || internalFormat != format)
+ if (!_mesa_has_OES_texture_float(ctx) || internalFormat != format)
 return GL_INVALID_OPERATION;
  break;
   case GL_HALF_FLOAT_OES:
- if (!ctx->Extensions.OES_texture_half_float || internalFormat != 
format)
+ if (!_mesa_has_OES_texture_half_float(ctx) || internalFormat != 
format)
 return GL_INVALID_OPERATION;
  break;
   case GL_UNSIGNED_BYTE:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 14/29] mesa/main: do not allow integer-texture enums before gles3

2018-11-23 Thread Erik Faye-Lund
Integer textures shouldn't be implicitly exposed on OpenGL ES 1.x and
2.x, but because the code checked against a driver-capability rather
than using an extension-check helper, we ended up accidentally allowing
these enums on older versions when the driver supports it.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index e5b453cd5bc..ad8f6a17cf2 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2142,7 +2142,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_SHORT:
 case GL_INT:
 case GL_UNSIGNED_INT:
-   return ctx->Extensions.EXT_texture_integer
+   return _mesa_has_integer_textures(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
@@ -2508,7 +2508,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.EXT_texture_integer) {
+   if (_mesa_has_integer_textures(ctx)) {
   switch (internalFormat) {
   case GL_ALPHA8UI_EXT:
   case GL_ALPHA16UI_EXT:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 10/29] mesa/main: do not allow astc enums on gles1

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.KHR_texture_compression_astc_ldr is set regardless of
the API that's used, so checking for those direcly will always enable
extensions when they are supported by the driver.

But there's no extension enabling ASTC for OpenGL ES 1.x, so we
shouldn't allow those enums there.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 2e2ef9a05bb..b715af1a468 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1389,7 +1389,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format)
case MESA_FORMAT_LAYOUT_BPTC:
   return _mesa_has_ARB_texture_compression_bptc(ctx);
case MESA_FORMAT_LAYOUT_ASTC:
-  return ctx->Extensions.KHR_texture_compression_astc_ldr;
+  return _mesa_has_KHR_texture_compression_astc_ldr(ctx);
default:
   return GL_FALSE;
}
@@ -2373,9 +2373,9 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
 return base_compressed;
}
 
-   if ((ctx->Extensions.KHR_texture_compression_astc_ldr &&
+   if ((_mesa_has_KHR_texture_compression_astc_ldr(ctx) &&
 is_astc_2d_format(internalFormat)) ||
-   (ctx->Extensions.OES_texture_compression_astc &&
+   (_mesa_has_OES_texture_compression_astc(ctx) &&
 is_astc_3d_format(internalFormat)))
 return GL_RGBA;
 
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 27/29] mesa/main: require EXT_texture_sRGB for gles3

2018-11-23 Thread Erik Faye-Lund
sRGB textures is a requirement for OpenGL ES 3.0, so let's make sure
we don't incorrectly enable a too high version.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/version.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index b3c68bb865c..210caad097e 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -517,6 +517,7 @@ compute_version_es2(const struct gl_extensions *extensions,
  extensions->EXT_packed_float &&
  extensions->EXT_texture_array &&
  extensions->EXT_texture_shared_exponent &&
+ extensions->EXT_texture_sRGB &&
  extensions->EXT_transform_feedback &&
  extensions->ARB_draw_instanced &&
  extensions->ARB_uniform_buffer_object &&
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 23/29] mesa/main: do not allow sRGB texture enums before gles3

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.EXT_texture_sRGB is set regardless of the API that's
used, so checking for those direcly will always allow the enums from
this extensions when they are supported by the driver.

There's no extension adding support for this on OpenGL ES before
version 3.0, so let's tighten the check.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 0a42d3dd9a0..6c9d8b88d79 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2450,7 +2450,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.EXT_texture_sRGB) {
+   if (_mesa_has_EXT_texture_sRGB(ctx) || _mesa_is_gles3(ctx)) {
   switch (internalFormat) {
   case GL_SRGB_EXT:
   case GL_SRGB8_EXT:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 19/29] mesa/main: do not allow MESA_ycbcr_texture enums on gles

2018-11-23 Thread Erik Faye-Lund
This extension requies OpenGL, and shouldn't be available on OpenGL ES.
So let's not allow the enums from it either.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 9e63845f0e4..7b86c1db9d0 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2037,7 +2037,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
  }
 
   case GL_YCBCR_MESA:
- if (!ctx->Extensions.MESA_ycbcr_texture)
+ if (!_mesa_has_MESA_ycbcr_texture(ctx))
 return GL_INVALID_ENUM;
  if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
  type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
@@ -2381,7 +2381,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
 is_astc_3d_format(internalFormat)))
 return GL_RGBA;
 
-   if (ctx->Extensions.MESA_ycbcr_texture) {
+   if (!_mesa_has_MESA_ycbcr_texture(ctx)) {
   if (internalFormat == GL_YCBCR_MESA)
  return GL_YCBCR_MESA;
}
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 26/29] mesa/main: require EXT_texture_type_2_10_10_10_REV for gles3

2018-11-23 Thread Erik Faye-Lund
OpenGL ES 3.0 require this functionality, so we should also test for it
to avoid incorrectly exposing a too high GLES version.

On desktop, this has been required since all the way back in OpenGL 1.2
anyway.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/version.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 610ba2f08c5..b3c68bb865c 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -522,7 +522,8 @@ compute_version_es2(const struct gl_extensions *extensions,
  extensions->ARB_uniform_buffer_object &&
  extensions->EXT_texture_snorm &&
  extensions->NV_primitive_restart &&
- extensions->OES_depth_texture_cube_map);
+ extensions->OES_depth_texture_cube_map &&
+ extensions->EXT_texture_type_2_10_10_10_REV);
const bool es31_compute_shader =
   consts->MaxComputeWorkGroupInvocations >= 128;
const bool ver_3_1 = (ver_3_0 &&
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 15/29] mesa/main: do not allow ARB_depth_buffer_float enums before gles3

2018-11-23 Thread Erik Faye-Lund
Floating-point depth buffers are only supported on OpenGL 3.0, OpenGL ES
3.0, or if ARB_depth_buffer_float is supported. Because we checked a
driver capability rather than using an extension-check helper, we ended
up incorrectly allowing this on OpenGL ES 1.x and 2.x.

Since this logic is repeated, let's make a helper for it.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h   | 6 ++
 src/mesa/main/glformats.c | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index c51b3c17c0d..14f9a6b8987 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -349,6 +349,12 @@ _mesa_has_texture_rgb10_a2ui(const struct gl_context *ctx)
return _mesa_has_ARB_texture_rgb10_a2ui(ctx) || _mesa_is_gles3(ctx);
 }
 
+static inline bool
+_mesa_has_float_depth_buffer(const struct gl_context *ctx)
+{
+   return _mesa_has_ARB_depth_buffer_float(ctx) || _mesa_is_gles3(ctx);
+}
+
 /**
  * Checks if the context supports geometry shaders.
  */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index ad8f6a17cf2..a26876b909a 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1849,7 +1849,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
   return GL_NO_ERROR;
 
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
-  if (!ctx->Extensions.ARB_depth_buffer_float) {
+  if (!_mesa_has_float_depth_buffer(ctx)) {
  return GL_INVALID_ENUM;
   }
   if (format != GL_DEPTH_STENCIL) {
@@ -2048,7 +2048,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
   case GL_DEPTH_STENCIL:
  if (type == GL_UNSIGNED_INT_24_8)
 return GL_NO_ERROR;
- else if (ctx->Extensions.ARB_depth_buffer_float &&
+ else if (_mesa_has_float_depth_buffer(ctx) &&
  type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
 return GL_NO_ERROR;
  else
@@ -2607,7 +2607,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.ARB_depth_buffer_float) {
+   if (_mesa_has_float_depth_buffer(ctx)) {
   switch (internalFormat) {
   case GL_DEPTH_COMPONENT32F:
  return GL_DEPTH_COMPONENT;
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 25/29] mesa/main: split float-texture support checking in two

2018-11-23 Thread Erik Faye-Lund
On OpenGL ES 2.0, there's separate extensions adding support for
half-float and float textures. So we need to validate the enums
separately as well.

This also prevents these enums from incorrectly being allowed on
OpenGL ES 1.x, where there's no extension that enables this in the
first place.

While we're at it, remove the pointless default-case, and the seemingly
stale fallthrough comment.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h   | 14 ++
 src/mesa/main/glformats.c | 39 +++
 2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 071bd5b0818..cdda8cf2012 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -343,6 +343,20 @@ _mesa_has_integer_textures(const struct gl_context *ctx)
return _mesa_has_EXT_texture_integer(ctx) || _mesa_is_gles3(ctx);
 }
 
+static inline bool
+_mesa_has_half_float_textures(const struct gl_context *ctx)
+{
+   return _mesa_has_ARB_texture_float(ctx) ||
+  _mesa_has_OES_texture_half_float(ctx) || _mesa_is_gles3(ctx);
+}
+
+static inline bool
+_mesa_has_float_textures(const struct gl_context *ctx)
+{
+   return _mesa_has_ARB_texture_float(ctx) ||
+  _mesa_has_OES_texture_float(ctx) || _mesa_is_gles3(ctx);
+ }
+
 static inline bool
 _mesa_has_texture_rgb10_a2ui(const struct gl_context *ctx)
 {
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index d79bcedffd9..d5962cd47ec 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2386,28 +2386,37 @@ _mesa_base_tex_format(const struct gl_context *ctx, 
GLint internalFormat)
  return GL_YCBCR_MESA;
}
 
-   if (ctx->Extensions.ARB_texture_float) {
+   if (_mesa_has_half_float_textures(ctx)) {
   switch (internalFormat) {
   case GL_ALPHA16F_ARB:
-  case GL_ALPHA32F_ARB:
  return GL_ALPHA;
   case GL_RGBA16F_ARB:
-  case GL_RGBA32F_ARB:
  return GL_RGBA;
   case GL_RGB16F_ARB:
-  case GL_RGB32F_ARB:
  return GL_RGB;
   case GL_INTENSITY16F_ARB:
-  case GL_INTENSITY32F_ARB:
  return GL_INTENSITY;
   case GL_LUMINANCE16F_ARB:
-  case GL_LUMINANCE32F_ARB:
  return GL_LUMINANCE;
   case GL_LUMINANCE_ALPHA16F_ARB:
+ return GL_LUMINANCE_ALPHA;
+  }
+   }
+
+   if (_mesa_has_float_textures(ctx)) {
+  switch (internalFormat) {
+  case GL_ALPHA32F_ARB:
+ return GL_ALPHA;
+  case GL_RGBA32F_ARB:
+ return GL_RGBA;
+  case GL_RGB32F_ARB:
+ return GL_RGB;
+  case GL_INTENSITY32F_ARB:
+ return GL_INTENSITY;
+  case GL_LUMINANCE32F_ARB:
+ return GL_LUMINANCE;
   case GL_LUMINANCE_ALPHA32F_ARB:
  return GL_LUMINANCE_ALPHA;
-  default:
- ; /* fallthrough */
   }
}
 
@@ -2546,9 +2555,12 @@ _mesa_base_tex_format(const struct gl_context *ctx, 
GLint internalFormat)
if (_mesa_has_rg_textures(ctx)) {
   switch (internalFormat) {
   case GL_R16F:
+ if (!_mesa_has_half_float_textures(ctx))
+break;
+ return GL_RED;
   case GL_R32F:
-if (!ctx->Extensions.ARB_texture_float)
-   break;
+ if (!_mesa_has_float_textures(ctx))
+break;
  return GL_RED;
   case GL_R8I:
   case GL_R8UI:
@@ -2566,9 +2578,12 @@ _mesa_base_tex_format(const struct gl_context *ctx, 
GLint internalFormat)
  return GL_RED;
 
   case GL_RG16F:
+ if (!_mesa_has_half_float_textures(ctx))
+break;
+ return GL_RG;
   case GL_RG32F:
-if (!ctx->Extensions.ARB_texture_float)
-   break;
+ if (!_mesa_has_float_textures(ctx))
+break;
  return GL_RG;
   case GL_RG8I:
   case GL_RG8UI:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 16/29] mesa/main: do not allow EXT_packed_float enums before gles3

2018-11-23 Thread Erik Faye-Lund
EXT_packed_float isn't supported on OpenGL ES, we shouldn't allow
these enums there, before OpenGL ES 3.0 which also introduce support
for these enums.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h   | 6 ++
 src/mesa/main/glformats.c | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 14f9a6b8987..84dbcb748c9 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -355,6 +355,12 @@ _mesa_has_float_depth_buffer(const struct gl_context *ctx)
return _mesa_has_ARB_depth_buffer_float(ctx) || _mesa_is_gles3(ctx);
 }
 
+static inline bool
+_mesa_has_packed_float(const struct gl_context *ctx)
+{
+   return _mesa_has_EXT_packed_float(ctx) || _mesa_is_gles3(ctx);
+}
+
 /**
  * Checks if the context supports geometry shaders.
  */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index a26876b909a..7d79e14e248 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1858,7 +1858,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
   return GL_NO_ERROR;
 
case GL_UNSIGNED_INT_10F_11F_11F_REV:
-  if (!ctx->Extensions.EXT_packed_float) {
+  if (!_mesa_has_packed_float(ctx)) {
  return GL_INVALID_ENUM;
   }
   if (format != GL_RGB) {
@@ -1969,7 +1969,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
return ctx->Extensions.EXT_texture_shared_exponent
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 case GL_UNSIGNED_INT_10F_11F_11F_REV:
-   return ctx->Extensions.EXT_packed_float
+   return _mesa_has_packed_float(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
@@ -2598,7 +2598,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.EXT_packed_float) {
+   if (_mesa_has_packed_float(ctx)) {
   switch (internalFormat) {
   case GL_R11F_G11F_B10F_EXT:
  return GL_RGB;
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 13/29] mesa/main: do not allow ARB_texture_rgb10_a2ui enums before gles3

2018-11-23 Thread Erik Faye-Lund
ARB_texture_rgb10_a2ui isn't supported on OpenGL ES, we shouldn't expose
it there even if the driver supports it.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h   |  6 ++
 src/mesa/main/glformats.c | 12 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index d4fe774577e..c51b3c17c0d 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -343,6 +343,12 @@ _mesa_has_integer_textures(const struct gl_context *ctx)
return _mesa_has_EXT_texture_integer(ctx) || _mesa_is_gles3(ctx);
 }
 
+static inline bool
+_mesa_has_texture_rgb10_a2ui(const struct gl_context *ctx)
+{
+   return _mesa_has_ARB_texture_rgb10_a2ui(ctx) || _mesa_is_gles3(ctx);
+}
+
 /**
  * Checks if the context supports geometry shaders.
  */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index a2bd5a7881b..e5b453cd5bc 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1800,7 +1800,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
  break; /* OK */
   }
   if (format == GL_RGB_INTEGER_EXT &&
-  ctx->Extensions.ARB_texture_rgb10_a2ui) {
+  _mesa_has_texture_rgb10_a2ui(ctx)) {
  break; /* OK */
   }
   return GL_INVALID_OPERATION;
@@ -1815,7 +1815,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
  break; /* OK */
   }
   if ((format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) &&
-  ctx->Extensions.ARB_texture_rgb10_a2ui) {
+  _mesa_has_texture_rgb10_a2ui(ctx)) {
  break; /* OK */
   }
   return GL_INVALID_OPERATION;
@@ -1829,7 +1829,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
  break; /* OK */
   }
   if ((format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) &&
-  ctx->Extensions.ARB_texture_rgb10_a2ui) {
+  _mesa_has_texture_rgb10_a2ui(ctx)) {
  break; /* OK */
   }
   if (type == GL_UNSIGNED_INT_2_10_10_10_REV && format == GL_RGB &&
@@ -2087,7 +2087,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_BYTE_2_3_3_REV:
 case GL_UNSIGNED_SHORT_5_6_5:
 case GL_UNSIGNED_SHORT_5_6_5_REV:
-   return ctx->Extensions.ARB_texture_rgb10_a2ui
+   return _mesa_has_texture_rgb10_a2ui(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
@@ -2127,7 +2127,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_INT_8_8_8_8_REV:
 case GL_UNSIGNED_INT_10_10_10_2:
 case GL_UNSIGNED_INT_2_10_10_10_REV:
-   return ctx->Extensions.ARB_texture_rgb10_a2ui
+   return _mesa_has_texture_rgb10_a2ui(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
@@ -2501,7 +2501,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.ARB_texture_rgb10_a2ui) {
+   if (_mesa_has_texture_rgb10_a2ui(ctx)) {
   switch (internalFormat) {
   case GL_RGB10_A2UI:
  return GL_RGBA;
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 05/29] mesa/main: clean up ES2_compatibility check

2018-11-23 Thread Erik Faye-Lund
This makes the logic a little bit easier to follow; this is *either*
about ES2 compatibility *or* about gles. GL_RGB565 was added already in
OpenGL ES 1.0.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index a47263a6525..d837bfc1aca 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2325,7 +2325,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.ARB_ES2_compatibility) {
+   if (_mesa_has_ARB_ES2_compatibility(ctx) || _mesa_is_gles(ctx)) {
   switch (internalFormat) {
   case GL_RGB565:
  return GL_RGB;
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 01/29] mesa/main: make _mesa_has_tessellation return bool

2018-11-23 Thread Erik Faye-Lund
All other _mesa_has_foo functions return bool rather than GLboolean, so
let's follow that style here as well.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index d50438fd7f9..d8a548f1b1b 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -361,7 +361,7 @@ _mesa_has_compute_shaders(const struct gl_context *ctx)
 /**
  * Checks if the context supports tessellation.
  */
-static inline GLboolean
+static inline bool
 _mesa_has_tessellation(const struct gl_context *ctx)
 {
/* _mesa_has_EXT_tessellation_shader(ctx) is redundant with the OES
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 03/29] mesa/main: clean up S3_s3tc check

2018-11-23 Thread Erik Faye-Lund
S3_s3tc is the extension that enables this functionality on desktop, so
let's check for that one. The _mesa_has_S3_s3tc() helper already
verifies the API according to the extension-table.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 9a507d11b96..b2c18aa6d94 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1352,8 +1352,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format)
case GL_RGB4_S3TC:
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
-  return _mesa_is_desktop_gl(ctx) &&
- ctx->Extensions.ANGLE_texture_compression_dxt;
+  return _mesa_has_S3_s3tc(ctx);
case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
   return ctx->API == API_OPENGL_COMPAT
  && ctx->Extensions.ATI_texture_compression_3dc;
@@ -1378,9 +1377,8 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format)
   */
  return ctx->Extensions.ANGLE_texture_compression_dxt;
   } else {
- return _mesa_is_desktop_gl(ctx)
-&& ctx->Extensions.EXT_texture_sRGB
-&& ctx->Extensions.EXT_texture_compression_s3tc;
+ return _mesa_has_EXT_texture_sRGB(ctx) &&
+_mesa_has_S3_s3tc(ctx);
   }
case MESA_FORMAT_LAYOUT_FXT1:
   return _mesa_is_desktop_gl(ctx)
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 12/29] mesa/main: do not allow stencil-texture enums on gles1

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.ARB_texture_stencil8 is set regardless of the API
that's used, so checking for those direcly will always allow the
enums from this extensions when they are supported by the driver.

So let's instead check for both ARB_texture_stencil8 and
OES_texture_stencil8, so we support depth textures on OpenGL and
OpenGL ES 2.0+. There's no extension enabling stencil-textures for
OpenGL ES 1.x, so we shouldn't allow those enums there.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 8d75a78538a..a2bd5a7881b 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2337,7 +2337,8 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.ARB_texture_stencil8) {
+   if (_mesa_has_ARB_texture_stencil8(ctx) ||
+   _mesa_has_OES_texture_stencil8(ctx)) {
   switch (internalFormat) {
   case GL_STENCIL_INDEX:
   case GL_STENCIL_INDEX1:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 08/29] mesa/main: do not allow s3tc enums on gles1

2018-11-23 Thread Erik Faye-Lund
There's no extension enabling S3TC formats on OpenGL ES 1.x, so we
shouldn't allow these even if the driver can support it. So let's check
for EXT_texture_compression_s3tc instead of ANGLE_texture_compression_dxt,
which is supported on all other OpenGL variations.

We also need to use _mesa_has_EXT_texture_compression_s3tc() instead of
checking the driver cap directly, otherwise we end up enabling this on
OpenGL ES 1.x, as the API isn't checked.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index a5eb0dabb3b..964235bb72f 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1371,10 +1371,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format)
switch (_mesa_get_format_layout(m_format)) {
case MESA_FORMAT_LAYOUT_S3TC:
   if (_mesa_get_format_color_encoding(m_format) == GL_LINEAR) {
- /* Assume that the ANGLE flag will always be set if the
-  * EXT flag is set.
-  */
- return ctx->Extensions.ANGLE_texture_compression_dxt;
+ return _mesa_has_EXT_texture_compression_s3tc(ctx);
   } else {
  return _mesa_has_EXT_texture_sRGB(ctx) &&
 _mesa_has_S3_s3tc(ctx);
@@ -2802,7 +2799,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
/* The GLES variant of EXT_texture_compression_s3tc is very vague and
 * doesn't list valid types. Just do exactly what the spec says.
 */
-   if (ctx->Extensions.EXT_texture_compression_s3tc &&
+   if (_mesa_has_EXT_texture_compression_s3tc(ctx) &&
(internalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
 internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
 internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ||
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 04/29] mesa/main: clean up OES_texture_float_linear check

2018-11-23 Thread Erik Faye-Lund
Using the _mesa_has_FOO_bar helpers is generally more safe and should
generally be prefered over checking driver-caps like this code did,
because the _mesa_has_FOO_bar helpers also verify the API type and
version.

This shouldn't have any practical effect here, as this function only
gets called for OpenGL ES 3.x right now. But if this was to change in
the future, this makes the function behave a lot more predictable.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index b2c18aa6d94..a47263a6525 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -3853,7 +3853,7 @@ _mesa_is_es3_texture_filterable(const struct gl_context 
*ctx,
* internal formats to base internal formats ... and use cases ...'')
* for the R32F, RG32F, RGB32F, and RGBA32F formats."
*/
-  return ctx->Extensions.OES_texture_float_linear;
+  return _mesa_has_OES_texture_float_linear(ctx);
default:
   return false;
}
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 09/29] mesa/main: do not allow etc2 enums on gles1

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.ARB_ES3_compatibility is set regardless of the API
that's used, so checking for those direcly will always enable
extensions when they are supported by the driver.

But there's no extension enabling ETC2 for OpenGL ES 1.x, so we
shouldn't allow those enums there.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 964235bb72f..2e2ef9a05bb 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1385,7 +1385,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, 
GLenum format)
case MESA_FORMAT_LAYOUT_ETC1:
   return _mesa_has_OES_compressed_ETC1_RGB8_texture(ctx);
case MESA_FORMAT_LAYOUT_ETC2:
-  return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility;
+  return _mesa_is_gles3(ctx) || _mesa_has_ARB_ES3_compatibility(ctx);
case MESA_FORMAT_LAYOUT_BPTC:
   return _mesa_has_ARB_texture_compression_bptc(ctx);
case MESA_FORMAT_LAYOUT_ASTC:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 17/29] mesa/main: do not allow rg-textures enums before gles3

2018-11-23 Thread Erik Faye-Lund
EXT_packed_float isn't supported on OpenGL ES, we shouldn't allow
these enums there, before OpenGL ES 3.0 which also introduce support
for these enums.

Since this check is repeated a lot, let's make a helper for this.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h   |  6 ++
 src/mesa/main/glformats.c | 22 +++---
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 84dbcb748c9..af81717d9bd 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -361,6 +361,12 @@ _mesa_has_packed_float(const struct gl_context *ctx)
return _mesa_has_EXT_packed_float(ctx) || _mesa_is_gles3(ctx);
 }
 
+static inline bool
+_mesa_has_rg_textures(const struct gl_context *ctx)
+{
+   return _mesa_has_ARB_texture_rg(ctx) || _mesa_is_gles3(ctx);
+}
+
 /**
  * Checks if the context supports geometry shaders.
  */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 7d79e14e248..33c2f6ce68d 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -1876,7 +1876,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
  return GL_NO_ERROR;
   case GL_RG:
   case GL_RED:
-if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_texture_rg)
+ if (_mesa_has_rg_textures(ctx))
 return GL_NO_ERROR;
   default:
  return GL_INVALID_OPERATION;
@@ -1930,8 +1930,8 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
  }
 
   case GL_RG:
-if (!ctx->Extensions.ARB_texture_rg)
-   return GL_INVALID_ENUM;
+ if (!_mesa_has_rg_textures(ctx))
+return GL_INVALID_ENUM;
  switch (type) {
 case GL_BYTE:
 case GL_UNSIGNED_BYTE:
@@ -2170,7 +2170,7 @@ _mesa_es_error_check_format_and_type(const struct 
gl_context *ctx,
switch (format) {
case GL_RED:
case GL_RG:
-  if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_texture_rg)
+  if (!_mesa_has_rg_textures(ctx))
  return GL_INVALID_VALUE;
   /* fallthrough */
case GL_ALPHA:
@@ -2543,7 +2543,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.ARB_texture_rg) {
+   if (_mesa_has_rg_textures(ctx)) {
   switch (internalFormat) {
   case GL_R16F:
   case GL_R32F:
@@ -3105,7 +3105,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
   break;
 
case GL_RG:
-  if (!ctx->Extensions.ARB_texture_rg)
+  if (!_mesa_has_rg_textures(ctx))
  return GL_INVALID_OPERATION;
   switch (type) {
   case GL_UNSIGNED_BYTE:
@@ -3137,7 +3137,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
   return GL_INVALID_OPERATION;
break;
 case GL_RG:
-   if (ctx->Extensions.ARB_texture_rg &&
+   if (_mesa_has_rg_textures(ctx) &&
ctx->Extensions.OES_texture_half_float)
   break;
 /* fallthrough */
@@ -3152,7 +3152,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
  case GL_RG32F:
 break;
  case GL_RG:
-if (ctx->Extensions.ARB_texture_rg &&
+if (_mesa_has_rg_textures(ctx) &&
 ctx->Extensions.OES_texture_float)
break;
 /* fallthrough */
@@ -3206,7 +3206,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
   break;
 
case GL_RED:
-  if (!ctx->Extensions.ARB_texture_rg)
+  if (!_mesa_has_rg_textures(ctx))
  return GL_INVALID_OPERATION;
   switch (type) {
   case GL_UNSIGNED_BYTE:
@@ -3241,7 +3241,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
 break;
  case GL_RG:
  case GL_RED:
-if (ctx->Extensions.ARB_texture_rg &&
+if (_mesa_has_rg_textures(ctx) &&
 ctx->Extensions.OES_texture_half_float)
break;
 /* fallthrough */
@@ -3256,7 +3256,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
  case GL_R32F:
 break;
  case GL_RED:
-if (ctx->Extensions.ARB_texture_rg &&
+if (_mesa_has_rg_textures(ctx) &&
 ctx->Extensions.OES_texture_float)
break;
 /* fallthrough */
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 22/29] mesa/main: do not allow snorm-texture enums before gles3

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.EXT_texture_snorm is set regardless of the API
that's used, so checking for those direcly will always allow the
enums from this extensions when they are supported by the driver.

There's no extension adding support for this on OpenGL ES before
version 3.0, so let's tighten the check.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 453465fb1c8..0a42d3dd9a0 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2411,7 +2411,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.EXT_texture_snorm) {
+   if (_mesa_has_EXT_texture_snorm(ctx) || _mesa_is_gles3(ctx)) {
   switch (internalFormat) {
   case GL_RED_SNORM:
   case GL_R8_SNORM:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 06/29] mesa/main: clean up integer texture check

2018-11-23 Thread Erik Faye-Lund
This makes the logic a little bit easier to follow, and reduce a bit of
repetition.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/context.h   |  6 ++
 src/mesa/main/glformats.c | 27 +++
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index d8a548f1b1b..d4fe774577e 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -337,6 +337,12 @@ _mesa_is_no_error_enabled(const struct gl_context *ctx)
 }
 
 
+static inline bool
+_mesa_has_integer_textures(const struct gl_context *ctx)
+{
+   return _mesa_has_EXT_texture_integer(ctx) || _mesa_is_gles3(ctx);
+}
+
 /**
  * Checks if the context supports geometry shaders.
  */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index d837bfc1aca..7f49e53b8dc 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2076,8 +2076,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_SHORT:
 case GL_INT:
 case GL_UNSIGNED_INT:
-   return (ctx->Version >= 30 ||
-   ctx->Extensions.EXT_texture_integer)
+   return _mesa_has_integer_textures(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
@@ -2091,8 +2090,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_SHORT:
 case GL_INT:
 case GL_UNSIGNED_INT:
-   return (ctx->Version >= 30 ||
-   ctx->Extensions.EXT_texture_integer)
+   return _mesa_has_integer_textures(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 case GL_UNSIGNED_BYTE_3_3_2:
 case GL_UNSIGNED_BYTE_2_3_3_REV:
@@ -2113,8 +2111,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_INT:
 case GL_UNSIGNED_INT:
 /* NOTE: no packed formats w/ BGR format */
-   return (ctx->Version >= 30 ||
-   ctx->Extensions.EXT_texture_integer)
+   return _mesa_has_integer_textures(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
@@ -2129,8 +2126,7 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_SHORT:
 case GL_INT:
 case GL_UNSIGNED_INT:
-   return (ctx->Version >= 30 ||
-   ctx->Extensions.EXT_texture_integer)
+   return _mesa_has_integer_textures(ctx)
   ? GL_NO_ERROR : GL_INVALID_ENUM;
 case GL_UNSIGNED_SHORT_4_4_4_4:
 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
@@ -2493,8 +2489,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Version >= 30 ||
-   ctx->Extensions.EXT_texture_integer) {
+   if (_mesa_has_integer_textures(ctx)) {
   switch (internalFormat) {
   case GL_RGBA8UI_EXT:
   case GL_RGBA16UI_EXT:
@@ -2568,9 +2563,9 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   case GL_R16UI:
   case GL_R32I:
   case GL_R32UI:
-if (ctx->Version < 30 && !ctx->Extensions.EXT_texture_integer)
-   break;
-/* FALLTHROUGH */
+ if (!_mesa_has_integer_textures(ctx))
+break;
+ /* FALLTHROUGH */
   case GL_R8:
   case GL_R16:
   case GL_RED:
@@ -2588,9 +2583,9 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   case GL_RG16UI:
   case GL_RG32I:
   case GL_RG32UI:
-if (ctx->Version < 30 && !ctx->Extensions.EXT_texture_integer)
-   break;
-/* FALLTHROUGH */
+ if (!_mesa_has_integer_textures(ctx))
+break;
+ /* FALLTHROUGH */
   case GL_RG:
   case GL_RG8:
   case GL_RG16:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 11/29] mesa/main: do not allow depth-texture enums on gles1

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.ARB_depth_texture is set regardless of the API that's
used, so checking for those direcly will always allow the enums from
this extensions when they are supported by the driver.

So let's instead check for both ARB_depth_texture and OES_depth_texture,
so we support depth textures on OpenGL and OpenGL ES 2.0+. There's no
extension enabling depth-textures for OpenGL ES 1.x, so we shouldn't
allow those enums there.

This fixes oes_packed_depth_stencil-depth-stencil-texture_gles1 on i965

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index b715af1a468..8d75a78538a 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2321,7 +2321,8 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.ARB_depth_texture) {
+   if (_mesa_has_ARB_depth_texture(ctx) || _mesa_has_OES_depth_texture(ctx) ||
+   ctx->API == API_OPENGL_CORE) {
   switch (internalFormat) {
   case GL_DEPTH_COMPONENT:
   case GL_DEPTH_COMPONENT16:
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 24/29] mesa/main: do not allow EXT_texture_sRGB_R8 enums before gles3

2018-11-23 Thread Erik Faye-Lund
ctx->Extensions.EXT_texture_sRGB_R8 is set regardless of the API
that's used, so checking for those direcly will always allow the
enums from this extensions when they are supported by the driver.

There's no extension adding support for this on OpenGL ES before
version 3.0, so let's tighten the check.

Signed-off-by: Erik Faye-Lund 
Reviewed-By: Gert Wollny 
---
 src/mesa/main/glformats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 6c9d8b88d79..d79bcedffd9 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2473,7 +2473,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
   }
}
 
-   if (ctx->Extensions.EXT_texture_sRGB_R8) {
+   if (_mesa_has_EXT_texture_sRGB_R8(ctx)) {
   switch (internalFormat) {
   case GL_SR8_EXT:
  return GL_RED;
@@ -3212,7 +3212,7 @@ _mesa_gles_error_check_format_and_type(const struct 
gl_context *ctx,
   case GL_UNSIGNED_BYTE:
  if (internalFormat == GL_R8 ||
  ((internalFormat == GL_SR8_EXT) &&
-  ctx->Extensions.EXT_texture_sRGB_R8))
+  _mesa_has_EXT_texture_sRGB_R8(ctx)))
 break;
  return GL_INVALID_OPERATION;
 
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 28/29] mesa/st: do not probe for the same texture-formats twice

2018-11-23 Thread Erik Faye-Lund
This should be equalent of what we did before.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/state_tracker/st_extensions.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 16889074f66..b0fc824e30c 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -771,10 +771,6 @@ void st_init_extensions(struct pipe_screen *screen,
 
/* Required: render target and sampler support */
static const struct st_extension_format_mapping rendertarget_mapping[] = {
-  { { o(ARB_texture_float) },
-{ PIPE_FORMAT_R32G32B32A32_FLOAT,
-  PIPE_FORMAT_R16G16B16A16_FLOAT } },
-
   { { o(OES_texture_float) },
 { PIPE_FORMAT_R32G32B32A32_FLOAT } },
 
@@ -1461,6 +1457,10 @@ void st_init_extensions(struct pipe_screen *screen,
   }
}
 
+   extensions->ARB_texture_float =
+  extensions->OES_texture_half_float &&
+  extensions->OES_texture_float;
+
if (extensions->EXT_texture_filter_anisotropic &&
screen->get_paramf(screen, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY) >= 16.0)
   extensions->ARB_texture_filter_anisotropic = GL_TRUE;
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 29/29] mesa/main: do not require float-texture filtering for es3

2018-11-23 Thread Erik Faye-Lund
The OpenGL ES 3.0 specification, table 3.13 lists half-float textures as
filterable, but not float textures. So we shouldn't depend on
ARB_float_texture, which requires full filtering support for both.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/version.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 210caad097e..fb5e816db32 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -509,7 +509,9 @@ compute_version_es2(const struct gl_extensions *extensions,
  extensions->ARB_internalformat_query &&
  extensions->ARB_map_buffer_range &&
  extensions->ARB_shader_texture_lod &&
- extensions->ARB_texture_float &&
+ extensions->OES_texture_float &&
+ extensions->OES_texture_half_float &&
+ extensions->OES_texture_half_float_linear &&
  extensions->ARB_texture_rg &&
  extensions->ARB_depth_buffer_float &&
  /* extensions->ARB_framebuffer_object && */
-- 
2.19.1

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


[Mesa-dev] [PATCH v2 00/29] do not allow invalid texture-format enums

2018-11-23 Thread Erik Faye-Lund
OK, so here's a v2 of this series. These are the changes since v1:
- Removed double-semicolons in patch #25
- Removed default-case and questionable comment in patch #25
- Dropped patch #30, as it would regress functionality on two drivers

Please review :)

Erik Faye-Lund (29):
  mesa/main: make _mesa_has_tessellation return bool
  mesa/main: rename format-check function
  mesa/main: clean up S3_s3tc check
  mesa/main: clean up OES_texture_float_linear check
  mesa/main: clean up ES2_compatibility check
  mesa/main: clean up integer texture check
  mesa/main: use _mesa_has_FOO_bar for compressed format checks
  mesa/main: do not allow s3tc enums on gles1
  mesa/main: do not allow etc2 enums on gles1
  mesa/main: do not allow astc enums on gles1
  mesa/main: do not allow depth-texture enums on gles1
  mesa/main: do not allow stencil-texture enums on gles1
  mesa/main: do not allow ARB_texture_rgb10_a2ui enums before gles3
  mesa/main: do not allow integer-texture enums before gles3
  mesa/main: do not allow ARB_depth_buffer_float enums before gles3
  mesa/main: do not allow EXT_packed_float enums before gles3
  mesa/main: do not allow rg-textures enums before gles3
  mesa/main: do not allow EXT_texture_shared_exponent enums before gles3
  mesa/main: do not allow MESA_ycbcr_texture enums on gles
  mesa/main: do not allow type_2_10_10_10_REV enums before gles3
  mesa/main: do not allow floating-point texture enums on gles1
  mesa/main: do not allow snorm-texture enums before gles3
  mesa/main: do not allow sRGB texture enums before gles3
  mesa/main: do not allow EXT_texture_sRGB_R8 enums before gles3
  mesa/main: split float-texture support checking in two
  mesa/main: require EXT_texture_type_2_10_10_10_REV for gles3
  mesa/main: require EXT_texture_sRGB for gles3
  mesa/st: do not probe for the same texture-formats twice
  mesa/main: do not require float-texture filtering for es3

 src/mesa/main/context.h|  59 ++-
 src/mesa/main/glformats.c  | 221 +
 src/mesa/main/glformats.h  |   6 +-
 src/mesa/main/teximage.c   |   4 +-
 src/mesa/main/version.c|   8 +-
 src/mesa/state_tracker/st_extensions.c |   8 +-
 6 files changed, 184 insertions(+), 122 deletions(-)

-- 
2.19.1

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


[Mesa-dev] [PATCH v2 02/29] mesa/main: rename format-check function

2018-11-23 Thread Erik Faye-Lund
_mesa_es3_error_check_format_and_type isn't specific to OpenGL ES 3.x,
it applies to all versions of OpenGL ES. So let's rename it to reflect
this.

While we're at it, let's also rename a helper function it uses similarly.
As the helper is static, we can also remove the namespacing-prefix from
the name.

Signed-off-by: Erik Faye-Lund 
---
 src/mesa/main/glformats.c | 12 ++--
 src/mesa/main/glformats.h |  6 +++---
 src/mesa/main/teximage.c  |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 6cdc7818756..9a507d11b96 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2653,8 +2653,8 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint 
internalFormat)
  * \param type the texture type
  */
 static GLenum
-_mesa_es3_effective_internal_format_for_format_and_type(GLenum format,
-GLenum type)
+gles_effective_internal_format_for_format_and_type(GLenum format,
+   GLenum type)
 {
switch (type) {
case GL_UNSIGNED_BYTE:
@@ -2767,9 +2767,9 @@ 
_mesa_es3_effective_internal_format_for_format_and_type(GLenum format,
  * \return error code, or GL_NO_ERROR.
  */
 GLenum
-_mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
-  GLenum format, GLenum type,
-  GLenum internalFormat)
+_mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
+   GLenum format, GLenum type,
+   GLenum internalFormat)
 {
/* If internalFormat is an unsized format, then the effective internal
 * format derived from format and type should be used instead. Page 127,
@@ -2787,7 +2787,7 @@ _mesa_es3_error_check_format_and_type(const struct 
gl_context *ctx,
 */
if (_mesa_is_enum_format_unsized(internalFormat)) {
   GLenum effectiveInternalFormat =
- _mesa_es3_effective_internal_format_for_format_and_type(format, type);
+ gles_effective_internal_format_for_format_and_type(format, type);
 
   if (effectiveInternalFormat == GL_NONE)
  return GL_INVALID_OPERATION;
diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h
index 0aefdf50fef..487e7fe80e8 100644
--- a/src/mesa/main/glformats.h
+++ b/src/mesa/main/glformats.h
@@ -138,9 +138,9 @@ _mesa_es_error_check_format_and_type(const struct 
gl_context *ctx,
  unsigned dimensions);
 
 extern GLenum
-_mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
-  GLenum format, GLenum type,
-  GLenum internalFormat);
+_mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
+   GLenum format, GLenum type,
+   GLenum internalFormat);
 extern GLint
 _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat );
 
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 6805b47c728..21415b48490 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1798,8 +1798,8 @@ static bool
 texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
 GLenum type, GLenum internalFormat, const char 
*callerName)
 {
-   GLenum err = _mesa_es3_error_check_format_and_type(ctx, format, type,
-  internalFormat);
+   GLenum err = _mesa_gles_error_check_format_and_type(ctx, format, type,
+   internalFormat);
if (err != GL_NO_ERROR) {
   _mesa_error(ctx, err,
   "%s(format = %s, type = %s, internalformat = %s)",
-- 
2.19.1

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


Re: [Mesa-dev] [PATCH 3/6] mesa/st: Factor out array and buffer setup from st_atom_array.c.

2018-11-23 Thread Mathias Fröhlich
Hi,

On Friday, 23 November 2018 18:38:26 CET Chris Wilson wrote:
> > I tried to reproduce this, but valgrind does not show any failures with 
> > drawoverhead
> > on radeonsi.
> > What driver backend do you use?
> 
> iris, but we don't hit backends before the error on this path.

I know, I thought may be due to different caps present in different
backends. But iris is beyond my test systems. Sorry!

> Thanks for checking.
You're welcome!

best

Mathias



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


Re: [Mesa-dev] [PATCH 1/2] winsys/amdgpu: add amdgpu_winsys_bo::lock

2018-11-23 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Wed, Nov 21, 2018 at 12:57 PM Nicolai Hähnle  wrote:

> From: Nicolai Hähnle 
>
> We'll use it in the upcoming mapping change. Sparse buffers have always
> had one.
> ---
>  src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 19 +--
>  src/gallium/winsys/amdgpu/drm/amdgpu_bo.h |  4 ++--
>  src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 10 +-
>  3 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> index f49fb47b80e..9f0d4c12482 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> @@ -196,20 +196,21 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf)
>ws->allocated_gtt -= align64(bo->base.size,
> ws->info.gart_page_size);
>
> if (bo->u.real.map_count >= 1) {
>if (bo->initial_domain & RADEON_DOMAIN_VRAM)
>   ws->mapped_vram -= bo->base.size;
>else if (bo->initial_domain & RADEON_DOMAIN_GTT)
>   ws->mapped_gtt -= bo->base.size;
>ws->num_mapped_buffers--;
> }
>
> +   simple_mtx_destroy(>lock);
> FREE(bo);
>  }
>
>  static void amdgpu_bo_destroy_or_cache(struct pb_buffer *_buf)
>  {
> struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
>
> assert(bo->bo); /* slab buffers have a separate vtbl */
>
> if (bo->u.real.use_reusable_pool)
> @@ -461,20 +462,21 @@ static struct amdgpu_winsys_bo
> *amdgpu_create_bo(struct amdgpu_winsys *ws,
> AMDGPU_VM_PAGE_EXECUTABLE;
>
> if (!(flags & RADEON_FLAG_READ_ONLY))
> vm_flags |= AMDGPU_VM_PAGE_WRITEABLE;
>
> r = amdgpu_bo_va_op_raw(ws->dev, buf_handle, 0, size, va, vm_flags,
>AMDGPU_VA_OP_MAP);
> if (r)
>goto error_va_map;
>
> +   simple_mtx_init(>lock, mtx_plain);
> pipe_reference_init(>base.reference, 1);
> bo->base.alignment = alignment;
> bo->base.usage = 0;
> bo->base.size = size;
> bo->base.vtbl = _winsys_bo_vtbl;
> bo->ws = ws;
> bo->bo = buf_handle;
> bo->va = va;
> bo->u.real.va_handle = va_handle;
> bo->initial_domain = initial_domain;
> @@ -564,20 +566,21 @@ struct pb_slab *amdgpu_bo_slab_alloc(void *priv,
> unsigned heap,
> if (!slab->entries)
>goto fail_buffer;
>
> LIST_INITHEAD(>base.free);
>
> base_id = __sync_fetch_and_add(>next_bo_unique_id,
> slab->base.num_entries);
>
> for (unsigned i = 0; i < slab->base.num_entries; ++i) {
>struct amdgpu_winsys_bo *bo = >entries[i];
>
> +  simple_mtx_init(>lock, mtx_plain);
>bo->base.alignment = entry_size;
>bo->base.usage = slab->buffer->base.usage;
>bo->base.size = entry_size;
>bo->base.vtbl = _winsys_bo_slab_vtbl;
>bo->ws = ws;
>bo->va = slab->buffer->va + i * entry_size;
>bo->initial_domain = domains;
>bo->unique_id = base_id + i;
>bo->u.slab.entry.slab = >base;
>bo->u.slab.entry.group_index = group_index;
> @@ -592,22 +595,24 @@ fail_buffer:
> amdgpu_winsys_bo_reference(>buffer, NULL);
>  fail:
> FREE(slab);
> return NULL;
>  }
>
>  void amdgpu_bo_slab_free(void *priv, struct pb_slab *pslab)
>  {
> struct amdgpu_slab *slab = amdgpu_slab(pslab);
>
> -   for (unsigned i = 0; i < slab->base.num_entries; ++i)
> +   for (unsigned i = 0; i < slab->base.num_entries; ++i) {
>amdgpu_bo_remove_fences(>entries[i]);
> +  simple_mtx_destroy(>entries[i].lock);
> +   }
>
> FREE(slab->entries);
> amdgpu_winsys_bo_reference(>buffer, NULL);
> FREE(slab);
>  }
>
>  #if DEBUG_SPARSE_COMMITS
>  static void
>  sparse_dump(struct amdgpu_winsys_bo *bo, const char *func)
>  {
> @@ -851,22 +856,22 @@ static void amdgpu_bo_sparse_destroy(struct
> pb_buffer *_buf)
> }
>
> while (!list_empty(>u.sparse.backing)) {
>struct amdgpu_sparse_backing *dummy = NULL;
>sparse_free_backing_buffer(bo,
>   container_of(bo->u.sparse.backing.next,
>dummy, list));
> }
>
> amdgpu_va_range_free(bo->u.sparse.va_handle);
> -   simple_mtx_destroy(>u.sparse.commit_lock);
> FREE(bo->u.sparse.commitments);
> +   simple_mtx_destroy(>lock);
> FREE(bo);
>  }
>
>  static const struct pb_vtbl amdgpu_winsys_bo_sparse_vtbl = {
> amdgpu_bo_sparse_destroy
> /* other functions are never called */
>  };
>
>  static struct pb_buffer *
>  amdgpu_bo_sparse_create(struct amdgpu_winsys *ws, uint64_t size,
> @@ -882,37 +887,37 @@ amdgpu_bo_sparse_create(struct amdgpu_winsys *ws,
> uint64_t size,
>  * that exceed this limit. This is not really a restriction: we don't
> have
>  * that much virtual address space anyway.
>  */
> if (size > (uint64_t)INT32_MAX * RADEON_SPARSE_PAGE_SIZE)
>return NULL;
>
> bo = CALLOC_STRUCT(amdgpu_winsys_bo);
> if (!bo)
>return NULL;
>
> +   

Re: [Mesa-dev] [PATCH] egl/wayland: bail out when drmGetMagic fails

2018-11-23 Thread Eric Engestrom
On Friday, 2018-11-23 12:59:52 +, Emil Velikov wrote:
> From: Emil Velikov 
> 
> Currently as the function fails, we pass uninitialized data to the
> authentication function. Stop doing that and print an warning when
> the function fails.
> 
> Cc: mesa-sta...@lists.freedesktop.org
> Signed-off-by: Emil Velikov 
> ---
>  src/egl/drivers/dri2/platform_wayland.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_wayland.c 
> b/src/egl/drivers/dri2/platform_wayland.c
> index cda6f25a7e0..f2dc26d5850 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -1134,7 +1134,10 @@ drm_handle_device(void *data, struct wl_drm *drm, 
> const char *device)
> if (drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER) {
>dri2_dpy->authenticated = true;
> } else {
> -  drmGetMagic(dri2_dpy->fd, );
> +  if (drmGetMagic(dri2_dpy->fd, )) {
> + _eglLog(_EGL_WARNING, "wayland-egl: drmGetMagic failed");
> + return;
> +  }

This looked familiar... turns out I sent this exact patch a couple years
ago, but never got around to addressing your comments :P
https://patchwork.freedesktop.org/patch/98132/

Anyway, with the close(fd) and free(device_name) you mentioned, this is:
Reviewed-by: Eric Engestrom 

(While at it, free(device_name) is also missing from the `if (fd == -1)`
branch.)

>wl_drm_authenticate(dri2_dpy->wl_drm, magic);
> }
>  }
> -- 
> 2.19.1
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] meson: Bump version to 0.46 for python module

2018-11-23 Thread Dylan Baker
Hi Eero,

I'm not sure how to avoid build breakages, as currently using the python3 module
is broken if the python3 file/link is < 3.5, however, trying to do a simple
`find_program('python3')` will not work on Windows or OSX. I guess we could do
an if `meson_version < 0.46` thing.

Dylan

Quoting Eero Tamminen (2018-11-23 01:40:22)
> Hi,
> 
> On 21.11.2018 20.13, Dylan Baker wrote:
> > From: Arfrever Frehtes Taifersar Arahesis 
> > 
> > Meson has two modules for finding python, the python3 module and the
> > python module. Python3 is older, and has some corner cases, python is
> > newer, has no known corner cases and can detect python2. Things have
> > generally seemed to work okay for us using python3, but there are cases
> > where things fall down (such as if you have python 3.4 as your default
> > python3.
> > 
> > Debian provides 0.48.x in buster (testing)
> > fedora has 0.47.x in 27 and 28
> > fedora has 0.48.x in 29
> > arch has 0.48.x
> 
> Ubuntu 18.04 LTS has meson v0.45.1 (and LLVM v6 & kernel v4.15).
> 
> First HW enabling packages from 18.10 (kernel v4.18, LLVM v7,
> meson v0.47.2) are scheduled for next February 2019.
> 
> It would be nice if build breakage would be postponed enough
> that deps would be available there too.
> 
> 
> - Eero
> 
> 
> > cc: matts...@gmail.com
> > distro-bug: https://bugs.gentoo.org/671308
> > Reviewed-by: Dylan Baker 
> > ---
> >   docs/meson.html | 2 +-
> >   meson.build | 4 ++--
> >   2 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/docs/meson.html b/docs/meson.html
> > index 68f80d6ac42..af109d3d8b0 100644
> > --- a/docs/meson.html
> > +++ b/docs/meson.html
> > @@ -24,7 +24,7 @@ for production
> >   The meson build is tested on Linux, macOS, Cygwin and Haiku, FreeBSD,
> >   DragonflyBSD, NetBSD, and should work on OpenBSD.
> >   
> > -Mesa requires Meson >= 0.45.0 to build.
> > +Mesa requires Meson >= 0.46.0 to build.
> >   
> >   Some older versions of meson do not check that they are too old and will 
> > error
> >   out in odd ways.
> > diff --git a/meson.build b/meson.build
> > index 33f4e5ad3cf..ee2d1a82984 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -25,7 +25,7 @@ project(
> >   [find_program('python', 'python2', 'python3'), 
> > 'bin/meson_get_version.py']
> > ).stdout(),
> > license : 'MIT',
> > -  meson_version : '>= 0.45',
> > +  meson_version : '>= 0.46',
> > default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 
> > 'c_std=c99', 'cpp_std=c++11']
> >   )
> >   
> > @@ -709,7 +709,7 @@ if with_platform_haiku
> > pre_args += '-DHAVE_HAIKU_PLATFORM'
> >   endif
> >   
> > -prog_python = import('python3').find_python()
> > +prog_python = import('python').find_installation('python3')
> >   has_mako = run_command(
> > prog_python, '-c',
> > '''
> > 
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


Re: [Mesa-dev] [PATCH 06/18] mapi/new: use the static_data offsets in the new generator

2018-11-23 Thread Dylan Baker
Quoting Emil Velikov (2018-11-23 05:35:31)
> On 2018/11/21, Dylan Baker wrote:
> > Quoting Emil Velikov (2018-11-21 04:04:03)
> 
> > >  
> > > +import os
> > > +GLAPI = os.path.join(os.path.dirname(sys.argv[0]), "..", "glapi/gen")
> > 
> > you should use __file__ instead of sys.argv[0], also don't hardcode '/' into
> > there, join 'glapi' and 'gen' for windows
> > 
> > > +sys.path.append(GLAPI)
> > 
> > also, use sys.path.insert(0, GLAPI), as python looks through paths in 
> > order, and
> > insert is always faster.
> > 
> Fwiw the code above is copy/paste from src/mapi/mapi_abi.py. With a
> similar hunk in src/mesa/main/get_hash_generator.py
> 
> Not sure how it works on Windows ... will address those files with a
> small prep series and update this hunk.

That code is really old, it's doing the obvious, but not optimal thing.

> 
> 
> > > +
> > > +if slot_set == False and name[-3:] != "ARB":
> > 
> > use 'is' with singletons like True, False, and None instead '=='. You might 
> > also
> > consider using .startswith() and .endswith(), as they're clearer than random
> > subslice.
> > 
> Sub slices are so much shorter hence why I opted for it. But will
> rework with v2.
> 
> Thanks
> Emil


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


Re: [Mesa-dev] [RFC 12/13] fixup! wip

2018-11-23 Thread Jason Ekstrand
That is the lamest commit message I think I've ever seen.

On Fri, Nov 23, 2018 at 4:29 PM Dylan Baker  wrote:

> ---
>  src/mapi/glapi/gen/khr_xml.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mapi/glapi/gen/khr_xml.py b/src/mapi/glapi/gen/khr_xml.py
> index 7909afb922d..c3efa5007d9 100644
> --- a/src/mapi/glapi/gen/khr_xml.py
> +++ b/src/mapi/glapi/gen/khr_xml.py
> @@ -182,7 +182,7 @@ class Param(object):
>  if self.suffix:
>  vals.append(self.suffix)
>  vals.append(self.name)
> -return ' '.join(str(v) for v in vals)
> +return ' '.join(six.text_type(v) for v in vals)
>
>
>  @attr.s
> --
> 2.19.2
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/6] mesa/st: Factor out array and buffer setup from st_atom_array.c.

2018-11-23 Thread Chris Wilson
Quoting Mathias Fröhlich (2018-11-23 17:14:45)
> Hi Chris,
> 
> On Friday, 23 November 2018 16:12:38 CET Chris Wilson wrote:
> > 
> > Something to note here is that valgrind reports
> > (piglit/bin/drawoverhead):
> > 
> > ==492== Use of uninitialised value of size 8
> > ==492==at 0x6EB8FA9: cso_hash_find_node (cso_hash.c:198)
> > ==492==by 0x6EB9026: cso_hash_insert (cso_hash.c:213)
> > ==492==by 0x6EB6730: cso_set_vertex_elements (cso_context.c:1092)
> > ==492==by 0x714C76F: set_vertex_attribs (st_atom_array.c:384)
> > ==492==by 0x714C76F: st_update_array (st_atom_array.c:512)
> > ==492==by 0x71073F3: st_validate_state (st_atom.c:261)
> > ==492==by 0x70615D1: prepare_draw (st_draw.c:123)
> > ==492==by 0x70615D1: st_draw_vbo (st_draw.c:149)
> > ==492==by 0x70F5BF4: _mesa_validated_drawrangeelements (draw.c:850)
> > ==492==by 0x70F5BF4: _mesa_validated_drawrangeelements (draw.c:782)
> > ==492==by 0x70F5F32: _mesa_DrawElements (draw.c:1004)
> > ==492==by 0x48F6C74: stub_glDrawElements (piglit-dispatch-gen.c:12618)
> > ==492==by 0x10B3F4: draw (drawoverhead.c:275)
> > ==492==by 0x10D070: perf_measure_rate (common.c:56)
> > ==492==by 0x10C69E: perf_run (drawoverhead.c:645)
> > ==492==  Uninitialised value was created by a stack allocation
> > ==492==at 0x714C25D: st_update_array (st_atom_array.c:389)
> > 
> > from velements being used sparsely.
> > 
> > Does your patch prevent this?
> 
> I tried to reproduce this, but valgrind does not show any failures with 
> drawoverhead
> on radeonsi.
> What driver backend do you use?

iris, but we don't hit backends before the error on this path. It may
just be a bug fixed not yet merged into iris. Hmm, or a local patch,
perhaps:

commit 3492e5dfd8e8a7b0f37a3be2a18010628d46f695
Author: Kenneth Graunke 
Date:   Fri Aug 24 15:06:35 2018 -0700

gallium, st/mesa: Support edge flags as a vertex element property

Thanks for checking.
-Chris
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] winsys/amdgpu: fix a buffer leak in amdgpu_bo_from_handle

2018-11-23 Thread Marek Olšák
Ping

On Mon, Nov 19, 2018 at 6:24 PM Marek Olšák  wrote:

> From: Marek Olšák 
>
> Cc: 18.2 18.3 
> ---
>  src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> index f49fb47b80e..3ee38b8a79f 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> @@ -1303,20 +1303,26 @@ static struct pb_buffer
> *amdgpu_bo_from_handle(struct radeon_winsys *rws,
>
> simple_mtx_lock(>bo_export_table_lock);
> bo = util_hash_table_get(ws->bo_export_table, result.buf_handle);
>
> /* If the amdgpu_winsys_bo instance already exists, bump the reference
>  * counter and return it.
>  */
> if (bo) {
>p_atomic_inc(>base.reference.count);
>simple_mtx_unlock(>bo_export_table_lock);
> +
> +  /* Release the buffer handle, because we don't need it anymore.
> +   * This function is returning an existing buffer, which has its own
> +   * handle.
> +   */
> +  amdgpu_bo_free(result.buf_handle);
>return >base;
> }
>
> /* Get initial domains. */
> r = amdgpu_bo_query_info(result.buf_handle, );
> if (r)
>goto error;
>
> r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
>   result.alloc_size, 1 << 20, 0, ,
> _handle,
> --
> 2.17.1
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 12/18] meson: wire the new generator for es1 and es2

2018-11-23 Thread Dylan Baker
Quoting Emil Velikov (2018-11-23 05:26:18)
> On 2018/11/21, Dylan Baker wrote:
> 
> > > diff --git a/src/mapi/glapi/gen/meson.build 
> > > b/src/mapi/glapi/gen/meson.build
> > > index f494e9707b6..fa06c7c5458 100644
> > > --- a/src/mapi/glapi/gen/meson.build
> > > +++ b/src/mapi/glapi/gen/meson.build
> > > @@ -18,6 +18,13 @@
> > >  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
> > > IN THE
> > >  # SOFTWARE.
> > >  
> > > +glapi_gen_gl_xml = files('../registry/gl.xml')
> > 
> > the gl_enum.py generate could use this as well.
> > 
> Not sure what you mean here. I cannot find any file called gl_enum.py
> and `git grep gl_enum.py` returns nothing.

I may have mis-remembered the name, grep file files('../registre/gl.xml'),
there's another case of this in that meson.build file that could be replaced
with the glapi_gen_gl_xml variable.

> 
> > > +glapi_gen_mapi_deps = [
> > > +  glapi_gen_gl_xml,
> > > +  files('../../new/genCommon.py'),
> > > +  glapi_gen_gl_xml,
> > > +]
> > > +
> > >  gl_and_es_api_files = files('gl_and_es_API.xml')
> > >  
> > >  api_xml_files = files(
> > > diff --git a/src/mapi/meson.build b/src/mapi/meson.build
> > > index 798586bfb0c..e7a6685576b 100644
> > > --- a/src/mapi/meson.build
> > > +++ b/src/mapi/meson.build
> > > @@ -25,6 +25,7 @@ files_mapi_util = files(
> > >'u_execmem.h',
> > >  )
> > >  
> > > +glapi_gen_mapi_script = files('new/gen_gldispatch_mapi.py')
> > 
> > All of the other generated scripts are "${foo}_py", can we continue to use 
> > that
> > format please?
> > 
> Sure thing. To keep things obvious, I've left them identical for across
> all builds.
> 
> Thanks
> Emil


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


Re: [Mesa-dev] [PATCH 2/2] winsys/amdgpu: explicitly declare whether buffer_map is permanent or not

2018-11-23 Thread Marek Olšák
On Thu, Nov 22, 2018 at 6:24 AM Nicolai Hähnle  wrote:

> On 21.11.18 21:27, Marek Olšák wrote:
> > On Wed, Nov 21, 2018 at 12:57 PM Nicolai Hähnle  > > wrote:
> >
> > From: Nicolai Hähnle  > >
> >
> > Introduce a new driver-private transfer flag
> RADEON_TRANSFER_TEMPORARY
> > that specifies whether the caller will use buffer_unmap or not. The
> > default behavior is set to permanent maps, because that's what
> drivers
> > do for Gallium buffer maps.
> >
> > This should eliminate the need for hacks in libdrm. Assertions are
> added
> > to catch when the buffer_unmap calls don't match the (temporary)
> > buffer_map calls.
> >
> > I did my best to update r600 and r300 as well for completeness (yes,
> > it's a no-op for r300 because it never calls buffer_unmap), even
> though
> > the radeon winsys ignores the new flag.
> >
> >
> > You didn't make any changes to r300.
>
> Yeah, that's what I wrote :)
>
>
> > You can also drop all r600 changes, because the radeon winsys doesn't
> care.
>
> I don't think it's a good idea, though. The interface of the two winsys
> is different, yes, but it's largely the same and it makes sense to keep
> it that way conceptually. Not that it matters much for the code itself.
>
>
> [snip]
> > +enum radeon_transfer_flags {
> > +   /* Indicates that the caller will unmap the buffer.
> > +*
> > +* Not unmapping buffers is an important performance
> > optimization for
> > +* OpenGL (avoids kernel overhead for frequently mapped
> > buffers). However,
> > +* if you only map a buffer once and then use it indefinitely
> > from the GPU,
> > +* it is much better to unmap it so that the kernel is free to
> > move it to
> > +* non-visible VRAM.
> >
> >
> > The second half of the comment is misleading. The kernel will move
> > buffers to invisible VRAM regardless of whether they're mapped, so CPU
> > mappings have no effect on the placement. Buffers are only moved back to
> > CPU-accessible memory on a CPU page fault. If a buffer is mapped and
> > there no CPU access, it will stay in invisible VRAM forever. The general
> > recommendation is to keep those buffers mapped for CPU access just like
> > GTT buffers.
>
> Yeah, I'll change that.
>
>
> > +*/
> > +   RADEON_TRANSFER_TEMPORARY = (PIPE_TRANSFER_DRV_PRV << 0),
> > +};
> > +
> >   #define RADEON_SPARSE_PAGE_SIZE (64 * 1024)
> >
> >   enum ring_type {
> >   RING_GFX = 0,
> >   RING_COMPUTE,
> >   RING_DMA,
> >   RING_UVD,
> >   RING_VCE,
> >   RING_UVD_ENC,
> >   RING_VCN_DEC,
> > @@ -287,23 +299,26 @@ struct radeon_winsys {
> >   struct pb_buffer *(*buffer_create)(struct radeon_winsys *ws,
> >  uint64_t size,
> >  unsigned alignment,
> >  enum radeon_bo_domain
> domain,
> >  enum radeon_bo_flag flags);
> >
> >   /**
> >* Map the entire data store of a buffer object into the
> > client's address
> >* space.
> >*
> > + * Callers are expected to unmap buffers again if and only if
> the
> > + * RADEON_TRANSFER_TEMPORARY flag is set in \p usage.
> > + *
> >* \param buf   A winsys buffer object to map.
> >* \param csA command stream to flush if the buffer is
> > referenced by it.
> > - * \param usage A bitmask of the PIPE_TRANSFER_* flags.
> > + * \param usage A bitmask of the PIPE_TRANSFER_* and
> > RADEON_TRANSFER_* flags.
> >* \return  The pointer at the beginning of the buffer.
> >*/
> >   void *(*buffer_map)(struct pb_buffer *buf,
> >   struct radeon_cmdbuf *cs,
> >   enum pipe_transfer_usage usage);
> >
> >   /**
> >* Unmap a buffer object from the client's address space.
> >*
> >* \param buf   A winsys buffer object to unmap.
> > diff --git a/src/gallium/drivers/radeonsi/si_shader.c
> > b/src/gallium/drivers/radeonsi/si_shader.c
> > index 19522cc97b1..d455fb5db6a 100644
> > --- a/src/gallium/drivers/radeonsi/si_shader.c
> > +++ b/src/gallium/drivers/radeonsi/si_shader.c
> > @@ -5286,21 +5286,22 @@ int si_shader_binary_upload(struct si_screen
> > *sscreen, struct si_shader *shader)
> >  0 :
> > SI_RESOURCE_FLAG_READ_ONLY,
> > PIPE_USAGE_IMMUTABLE,
> > align(bo_size,
> > SI_CPDMA_ALIGNMENT),
> >  

[Mesa-dev] [PATCH mesa] anv: correctly use vulkan 1.0 by default

2018-11-23 Thread Eric Engestrom
Per chapter 3.2 "Instances":
> Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing
> an apiVersion of 0 is equivalent to providing an apiVersion of
> VK_MAKE_VERSION(1,0,0).

Reported-by: Niklas Haas 
Fixes: 8c048af5890d43578ca4 "anv: Copy the appliation info into the instance"
Signed-off-by: Eric Engestrom 
---
 src/intel/vulkan/anv_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index f35a61fa0817a505a8f0..45ba2c1b10b6ee505be2 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -636,7 +636,7 @@ VkResult anv_CreateInstance(
}
 
if (instance->app_info.api_version == 0)
-  anv_EnumerateInstanceVersion(>app_info.api_version);
+  instance->app_info.api_version = VK_API_VERSION_1_0;
 
instance->enabled_extensions = enabled_extensions;
 
-- 
Cheers,
  Eric

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


[Mesa-dev] [RFC 07/13] mapi/glapi/gen: Add python module with abstractions from Khronos XML

2018-11-23 Thread Dylan Baker
These helpers form an abstraction over the krhonos XML and help deal
with some of the warts of the XML format, as well as generally making
the XML easier to work with.
---
 src/mapi/glapi/gen/Makefile.am |   3 +-
 src/mapi/glapi/gen/khr_xml.py  | 180 +
 2 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 src/mapi/glapi/gen/khr_xml.py

diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index 8158dffd719..2e37060da95 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -92,7 +92,8 @@ EXTRA_DIST= \
SConscript \
gl_API.dtd \
meson.build \
-   mesa_data.py
+   mesa_data.py \
+   khr_xml.py
 
 ##
 
diff --git a/src/mapi/glapi/gen/khr_xml.py b/src/mapi/glapi/gen/khr_xml.py
new file mode 100644
index 000..784931b5059
--- /dev/null
+++ b/src/mapi/glapi/gen/khr_xml.py
@@ -0,0 +1,180 @@
+# encoding=utf-8
+# Copyright © 2018 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+"""Representations of the Khronos XML.
+
+This module contains classes to represent the data encoded in the Khronos XML,
+and to work around some less than optimal representations
+"""
+
+from __future__ import absolute_import, division, print_function, 
unicode_literals
+
+import attr
+import six
+
+import mesa_data
+
+
+@attr.s
+class Length(object):
+
+"""Represents the length parameter in the Khronos XML.
+
+This is a non-trivial parameter, it can be a number, an anonymous function,
+a declared function, or a string referencing another parameter.
+
+:param int value: If the length of the parameter is static, this is the 
number
+:param str count: If the length of the parameter is is based on another
+parameter, this is the name of that parameter
+:param int scale: If there is a scaling factor for count, this is that
+factor. Note that this means nothing if count is None
+:param List[str] computed: If the value is computed from one or more
+paramters this list is those parameters
+"""
+
+value = attr.ib(default=None) # type: Optional[int]
+count = attr.ib(default=None) # type: Optional[str]
+scale = attr.ib(default=None) # type: Optional[int]
+computed = attr.ib(default=None)  # type: Optional[List[str]]
+
+def is_static(self):
+return self.value is not None
+
+def is_dynamic(self):
+return bool(self.count or self.computed)
+
+def __nonzero__(self):
+return bool(self.value or self.count or self.computed)
+
+@classmethod
+def from_xml(cls, string):
+"""Converts a string from the Khronos XML into a Length instance.
+
+:param Optional[str] string: A string or None to be converted.
+"""
+if string is None:
+return cls()
+elif string.isdigit():
+return cls(value=int(string))
+elif string.startswith('COMPSIZE'):
+string = string.lstrip('COMPSIZE(').rstrip(')')
+return cls(computed=string.split(','))
+elif '*' in string:
+count, scale = string.split('*')
+return cls(count=count, scale=int(scale))
+assert string, 'Wat?'
+return cls(count=string, scale=1)
+
+
+@attr.s(str=False)
+class Param(object):
+
+"""Represents an function parameter."""
+
+name = attr.ib(type=six.text_type)
+type = attr.ib(type=six.text_type)
+prefix = attr.ib()  # type: Optional[six.text_type]
+suffix = attr.ib()  # type: Optional[six.text_type]
+len = attr.ib() # type: Optional[six.text_type]
+
+def is_pointer(self):
+if self.suffix is not None:
+return '*' in self.suffix
+return False
+
+def __str__(self):
+vals = []
+if self.prefix:
+vals.append(self.prefix)
+

[Mesa-dev] [RFC 10/13] wip

2018-11-23 Thread Dylan Baker
---
 src/mapi/glapi/gen/khr_xml.py | 81 +--
 1 file changed, 78 insertions(+), 3 deletions(-)

diff --git a/src/mapi/glapi/gen/khr_xml.py b/src/mapi/glapi/gen/khr_xml.py
index 784931b5059..7909afb922d 100644
--- a/src/mapi/glapi/gen/khr_xml.py
+++ b/src/mapi/glapi/gen/khr_xml.py
@@ -33,6 +33,80 @@ import six
 import mesa_data
 
 
+@attr.s
+class CType(object):
+
+"""Represents a C Type."""
+
+name = attr.ib(type=six.text_type)
+size = attr.ib(type=int)
+
+
+C_TYPES = {
+c.name: c for c in [
+CType('void', 1),
+CType('char', 1),
+CType('short', 2),
+CType('int', 4),
+CType('long', 4),
+CType('float', 4),
+CType('double', 8),
+CType('enum', 4),
+]
+}
+
+
+@six.python_2_unicode_compatible
+@attr.s(str=False)
+class GLType(object):
+
+"""Represents a GLType."""
+
+name = attr.ib(type=six.text_type)
+ctype = attr.ib(type=CType)
+
+@property
+def size(self):
+return self.ctype.size
+
+def __str__(self):
+return self.name
+
+
+GL_TYPES = {
+g.name: g for g in [
+# For the purposes of this list an unsigned and a signed are equivalent
+GLType('GLenum', C_TYPES['int']),
+GLType('GLboolean', C_TYPES['char']),
+GLType('GLbitfield', C_TYPES['int']),
+GLType('GLbyte', C_TYPES['char']),
+GLType('GLshort', C_TYPES['short']),
+GLType('GLint', C_TYPES['int']),
+GLType('GLclampx', C_TYPES['int']),
+GLType('GLubyte', C_TYPES['char']),
+GLType('GLushort', C_TYPES['short']),
+GLType('GLhalfNV', C_TYPES['short']),
+GLType('GLuint', C_TYPES['int']),
+GLType('GLsizei', C_TYPES['int']),
+GLType('GLfloat', C_TYPES['float']),
+GLType('GLclampf', C_TYPES['float']),
+GLType('GLdouble', C_TYPES['double']),
+GLType('GLclampd', C_TYPES['double']),
+GLType('GLchar', C_TYPES['char']),
+GLType('GLcharARB', C_TYPES['char']),
+GLType('GLfixed', C_TYPES['int']),
+
+# XXX: everything after this are pretty sketchy
+GLType('GLuint64', C_TYPES['int']),
+GLType('GLuint64EXT', C_TYPES['int']),
+GLType('GLhandleARB', C_TYPES['int']),
+GLType('void', C_TYPES['void']),
+GLType('GLeglClientBufferEXT', C_TYPES['void']),
+GLType('GLeglImageOES', C_TYPES['void']),
+]
+}
+
+
 @attr.s
 class Length(object):
 
@@ -93,7 +167,7 @@ class Param(object):
 type = attr.ib(type=six.text_type)
 prefix = attr.ib()  # type: Optional[six.text_type]
 suffix = attr.ib()  # type: Optional[six.text_type]
-len = attr.ib() # type: Optional[six.text_type]
+len = attr.ib() # type: Optional[Length]
 
 def is_pointer(self):
 if self.suffix is not None:
@@ -108,7 +182,7 @@ class Param(object):
 if self.suffix:
 vals.append(self.suffix)
 vals.append(self.name)
-return ' '.join(vals)
+return ' '.join(str(v) for v in vals)
 
 
 @attr.s
@@ -164,7 +238,6 @@ def make_functions(xml):
 len_ = Length.from_xml(param.attrib.get('len'))
 
 if not type_:
-
 split = prefix.split(' ')
 assert 1 < len(split) <= 3
 if len(split) == 3:
@@ -175,6 +248,8 @@ def make_functions(xml):
 else:
 prefix, type_ = split
 
+type_ = GL_TYPES.get(type_, type_)
+
 params.append(Param(name, type_, prefix, suffix, len_))
 
 yield Function(proto, params, mesa_data.FUNCTIONS.get(proto.name))
-- 
2.19.2

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


[Mesa-dev] [RFC 05/13] gen_mesa_data: script to convert mesa xml into mesa_data entries

2018-11-23 Thread Dylan Baker
---
 src/mapi/glapi/gen/gen_mesa_data.py | 62 +
 1 file changed, 62 insertions(+)
 create mode 100755 src/mapi/glapi/gen/gen_mesa_data.py

diff --git a/src/mapi/glapi/gen/gen_mesa_data.py 
b/src/mapi/glapi/gen/gen_mesa_data.py
new file mode 100755
index 000..6e9d0629660
--- /dev/null
+++ b/src/mapi/glapi/gen/gen_mesa_data.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+from __future__ import print_function
+import xml.etree.ElementTree as et
+from xml.etree import ElementInclude
+
+import mesa_data
+import static_data
+
+
+def main():
+tree = et.parse('gl_and_es_API.xml')
+root = tree.getroot()
+ElementInclude.include(root)
+ElementInclude.include(root)
+
+print('_FUNCTIONS = [')
+
+for elem in root.findall('.//function'):
+name = elem.attrib['name']
+attribs = {}
+if 'exec' in elem.attrib:
+if elem.attrib['exec'] == 'dynamic':
+attribs['exectype'] = mesa_data.ExecType.DYNAMIC
+elif elem.attrib['exec'] == 'skip':
+attribs['exectype'] = mesa_data.ExecType.SKIP
+else:
+raise Exception('Unknown ExecType: ' + elem.attrib['exec'])
+
+if 'marshal' in elem.attrib:
+if elem.attrib['marshal'] == 'custom':
+attribs['marshal'] = mesa_data.MarshalType.CUSTOM
+elif elem.attrib['marshal'] == 'sync':
+attribs['marshal'] = mesa_data.MarshalType.SYNC
+elif elem.attrib['marshal'] == 'async':
+attribs['marshal'] = mesa_data.MarshalType.ASYNC
+elif elem.attrib['marshal'] == 'draw':
+attribs['marshal'] = mesa_data.MarshalType.DRAW
+else:
+raise Exception('Unknown MarshalType: ' + 
elem.attrib['marshal'])
+
+if 'alias' in elem.attrib:
+attribs['alias'] = True
+
+attribs['offset'] = static_data.offsets.get(name)
+
+params = []
+for param in elem.findall('./param'):
+params.append(mesa_data.Parameter(
+param.attrib['name'],
+bool(param.get('output', False)),
+bool(param.get('img_null_flag', False
+
+print('', end='')
+print(str(mesa_data.Function(name, params, **attribs)), end=',\n')
+
+print(']')
+print('FUNCTIONS = {f.name: f for f in _FUNCTIONS}', end='')
+
+
+if __name__ == '__main__':
+main()
-- 
2.19.2

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


[Mesa-dev] [RFC 09/13] begin generalizing gl_marshal_h.py for doing both.

2018-11-23 Thread Dylan Baker
This is undiffed, but does generate successfully.
---
 src/mapi/glapi/gen/gl_marshal_h.py | 166 +
 src/mesa/main/meson.build  |   3 +-
 2 files changed, 145 insertions(+), 24 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_marshal_h.py 
b/src/mapi/glapi/gen/gl_marshal_h.py
index abc6afc4cdf..ac39d121b61 100644
--- a/src/mapi/glapi/gen/gl_marshal_h.py
+++ b/src/mapi/glapi/gen/gl_marshal_h.py
@@ -33,7 +33,7 @@ from mesa_data import ExecType, MarshalType
 import khr_xml
 
 
-TEMPLATE = """\
+HEADER_TEMPLATE = """\
 <%namespace name="helpers" file="helpers.mako"/>
 <%include file="copyright.mako"/>
 
@@ -42,18 +42,104 @@ ${helpers.start_guard(guard)}
 enum marshal_dispatch_cmd_id
 {
 % for func in functions:
-   DISPATCH_CMD_${func},
+   DISPATCH_CMD_${func.name},
 % endfor
 };
 
 ${helpers.end_guard(guard)}
 """
 
+CODE_TEMPLATE = """\
+<%namespace name="helpers" file="helpers.mako"/>
+<%include file="copyright.mako"/>
+
+#include "api_exec.h"
+#include "context.h"
+#include "dispatch.h"
+#include "glthread.h"
+#include "marshal.h"
+#include "marshal_generated.h"
+
+static inline int safe_mul(int a, int b)
+{
+if (a < 0 || b < 0) return -1;
+if (a == 0 || b == 0) return 0;
+if (a > INT_MAX / b) return -1;
+return a * b;
+}
+
+% for func, marshal in functions:
+
+  % if marshal is MarshalType.SYNC:
+/* ${func.name}: marshalled synchronously */
+static ${func.return_type} GLAPIENTRY
+_mesa_marshal_${func.name}(${', '.join(str(p) for p in func.params)})
+{
+  GET_CURRENT_CONTEXT(ctx);
+  _mesa_glthread_finish(ctx);
+  debug_print_sync("${func.name}");
+  ${'return ' if func.return_type != 'void' else 
''}CALL_${func.name}(ctx->CurrentServerdispatch, (${', '.join([p.name for p in 
func.params])}));
+}
+  % else:
+/* ${func.name}: marshalled asynchronously */
+struct marshal_cmd_${func.name}
+{
+struct marshal_cmd_base cmd_base;
+% for p in (a for a in func.params if not a.len.is_dynamic()):
+  % if not p.len:
+${p.type} ${p.name};
+  % else:
+${p.type} ${p.name}[${p.len.value}];
+  % endif
+% endfor
+% for p, m in zip(func.params, func.mesa.params):
+  % if p.len.is_dynamic() and m.img_null_flag:
+bool ${func.name}_null; /* If set, no data follows for ${func.name} */
+  % endif
+% endfor
+# TODO: about next N bytes
+};
+static inline void
+_mesa_unmarshal_${func.name}(struct gl_context *ctx, const struct 
marshl_cmd_${func.name} *cmd)
+{
+% for p in (a for a in func.params if not a.len.is_dynamic()):
+  % if p.len.is_static():
+const ${p.type} * ${p.name} = cmd->${p.name};
+  % else:
+const ${p.type} ${p.name} = cmd->${p.name};
+  % endif
+% endfor
+% if any(p.len.is_dynamic() for p in func.params):
+  % for p in (a for a in func.params if a.len.is_dynamic()):
+const ${p.type} * ${p.name};
+  % endfor
+const char *variable_data = (const char *) (cmd + 1);
+  % for p, m in zip(func.params, func.mesa.params):
+<% if not p.len.is_dynamic(): continue %>
+${p.name} = (const ${p.type} *) variable_data;
+% if m.img_null_flag:
+if (cmd->${p.name}_null) {
+${p.name} = NULL;
+} else {
+/* TODO: variable_data += */
+}
+% else:
+/* TODO: variable_data += */
+% endif
+  % endfor
+% endif
+CALL_${func.name}(ctx->CurrentServerdispatch, (${', '.join([p.name for 
p in func.params])}));
+};
+  % endif
+% endfor
+"""
+
 
 def gen_functions(xml):
-"""Generator that gets the name of each command in OpenGL and yeilds it.
+"""Generator that returns each function and it's actual marshal type
 
-Ignores commands with special marshaling requirements.
+Ignores commands with special marshaling requirements and that are not
+implemented.
 """
 for func in khr_xml.make_functions(xml):
 # If the function is not in our records we don't implement it, at all,
@@ -65,52 +151,88 @@ def gen_functions(xml):
 if func.mesa.alias:
 continue
 
-if func.mesa.marshal is MarshalType.SYNC:
-continue
-
 if func.mesa.marshal not in [MarshalType.DEFAULT, MarshalType.DRAW]:
-yield func.name
+yield func, func.mesa.marshal
 continue
 
 if func.mesa.exectype is ExecType.SKIP:
 continue
 
 if func.return_type != 'void':
+yield func, MarshalType.SYNC
 continue
 
-if func.mesa.output:
+flagged = False
+for param in func.mesa.params:
+if param.mutates:
+yield func, MarshalType.SYNC
+flagged = True
+break
+if flagged:
 continue
 
+flagged = False
 for param in func.params:
-if 

[Mesa-dev] [PATCH 3/7] winsys/amdgpu: optimize slab allocation for 2 MB amdgpu page tables

2018-11-23 Thread Marek Olšák
From: Marek Olšák 

- the slab buffer size increased from 128 KB to 2 MB (PTE fragment size)
- the max suballocated buffer size increased from 64 KB to 256 KB,
  this increases memory usage because it wastes memory
- the number of suballocators increased from 1 to 3 and they are layered
  on top of each other to minimize unused space in slabs

The final increase in memory usage is:
  DeusEx:MD:  1.8%
  DOTA 2: 1.75%
  DiRT Rally: 0.2%

The kernel driver will also receive fewer buffers.
---
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 8 
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 2 +-
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 9c5e5e1ebc1..a9271c33ee9 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -573,20 +573,28 @@ struct pb_slab *amdgpu_bo_slab_alloc(void *priv, unsigned 
heap,
   return NULL;
 
/* Determine the slab buffer size. */
for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++) {
   struct pb_slabs *slabs = >bo_slabs[i];
   unsigned max_entry_size = 1 << (slabs->min_order + slabs->num_orders - 
1);
 
   if (entry_size <= max_entry_size) {
  /* The slab size is twice the size of the largest possible entry. */
  slab_size = max_entry_size * 2;
+
+ /* The largest slab should have the same size as the PTE fragment
+  * size to get faster address translation.
+  */
+ if (i == NUM_SLAB_ALLOCATORS - 1 &&
+ slab_size < ws->info.pte_fragment_size)
+slab_size = ws->info.pte_fragment_size;
+ break;
   }
}
assert(slab_size != 0);
 
slab->buffer = amdgpu_winsys_bo(amdgpu_bo_create(>base,
 slab_size, slab_size,
 domains, flags));
if (!slab->buffer)
   goto fail;
 
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 91120e3c474..6b7f484f239 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -304,21 +304,21 @@ amdgpu_winsys_create(int fd, const struct 
pipe_screen_config *config,
if (!do_winsys_init(ws, config, fd))
   goto fail_alloc;
 
/* Create managers. */
pb_cache_init(>bo_cache, RADEON_MAX_CACHED_HEAPS,
  50, ws->check_vm ? 1.0f : 2.0f, 0,
  (ws->info.vram_size + ws->info.gart_size) / 8,
  amdgpu_bo_destroy, amdgpu_bo_can_reclaim);
 
unsigned min_slab_order = 9;  /* 512 bytes */
-   unsigned max_slab_order = 16; /* 64 KB - higher numbers increase memory 
usage */
+   unsigned max_slab_order = 18; /* 256 KB - higher numbers increase memory 
usage */
unsigned num_slab_orders_per_allocator = (max_slab_order - min_slab_order) /
 NUM_SLAB_ALLOCATORS;
 
/* Divide the size order range among slab managers. */
for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++) {
   unsigned min_order = min_slab_order;
   unsigned max_order = MIN2(min_order + num_slab_orders_per_allocator,
 max_slab_order);
 
   if (!pb_slabs_init(>bo_slabs[i],
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h 
b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
index fc8f04544a9..5ae1d3e55a3 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
@@ -31,21 +31,21 @@
 #include "pipebuffer/pb_cache.h"
 #include "pipebuffer/pb_slab.h"
 #include "gallium/drivers/radeon/radeon_winsys.h"
 #include "addrlib/addrinterface.h"
 #include "util/simple_mtx.h"
 #include "util/u_queue.h"
 #include 
 
 struct amdgpu_cs;
 
-#define NUM_SLAB_ALLOCATORS 1
+#define NUM_SLAB_ALLOCATORS 3
 
 struct amdgpu_winsys {
struct radeon_winsys base;
struct pipe_reference reference;
struct pb_cache bo_cache;
 
/* Each slab buffer can only contain suballocations of equal sizes, so we
 * need to layer the allocators, so that we don't waste too much memory.
 */
struct pb_slabs bo_slabs[NUM_SLAB_ALLOCATORS];
-- 
2.17.1

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


[Mesa-dev] [PATCH 2/7] radeonsi: generalize the slab allocator code to allow layered slab allocators

2018-11-23 Thread Marek Olšák
From: Marek Olšák 

There is no change in behavior. It just makes it easier to change the number
of slab allocators.
---
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 60 +++
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 40 +
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 10 ++--
 3 files changed, 86 insertions(+), 24 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 49de30bb57c..9c5e5e1ebc1 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -213,21 +213,23 @@ static void amdgpu_bo_destroy_or_cache(struct pb_buffer 
*_buf)
assert(bo->bo); /* slab buffers have a separate vtbl */
 
if (bo->u.real.use_reusable_pool)
   pb_cache_add_buffer(>u.real.cache_entry);
else
   amdgpu_bo_destroy(_buf);
 }
 
 static void amdgpu_clean_up_buffer_managers(struct amdgpu_winsys *ws)
 {
-   pb_slabs_reclaim(>bo_slabs);
+   for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++)
+  pb_slabs_reclaim(>bo_slabs[i]);
+
pb_cache_release_all_buffers(>bo_cache);
 }
 
 static void *amdgpu_bo_map(struct pb_buffer *buf,
struct radeon_cmdbuf *rcs,
enum pipe_transfer_usage usage)
 {
struct amdgpu_winsys_bo *bo = (struct amdgpu_winsys_bo*)buf;
struct amdgpu_winsys_bo *real;
struct amdgpu_cs *cs = (struct amdgpu_cs*)rcs;
@@ -521,56 +523,80 @@ bool amdgpu_bo_can_reclaim(struct pb_buffer *_buf)
 }
 
 bool amdgpu_bo_can_reclaim_slab(void *priv, struct pb_slab_entry *entry)
 {
struct amdgpu_winsys_bo *bo = NULL; /* fix container_of */
bo = container_of(entry, bo, u.slab.entry);
 
return amdgpu_bo_can_reclaim(>base);
 }
 
+static struct pb_slabs *get_slabs(struct amdgpu_winsys *ws, uint64_t size)
+{
+   /* Find the correct slab allocator for the given size. */
+   for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++) {
+  struct pb_slabs *slabs = >bo_slabs[i];
+
+  if (size <= 1 << (slabs->min_order + slabs->num_orders - 1))
+ return slabs;
+   }
+
+   assert(0);
+   return NULL;
+}
+
 static void amdgpu_bo_slab_destroy(struct pb_buffer *_buf)
 {
struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
 
assert(!bo->bo);
 
-   pb_slab_free(>ws->bo_slabs, >u.slab.entry);
+   pb_slab_free(get_slabs(bo->ws, bo->base.size), >u.slab.entry);
 }
 
 static const struct pb_vtbl amdgpu_winsys_bo_slab_vtbl = {
amdgpu_bo_slab_destroy
/* other functions are never called */
 };
 
 struct pb_slab *amdgpu_bo_slab_alloc(void *priv, unsigned heap,
  unsigned entry_size,
  unsigned group_index)
 {
struct amdgpu_winsys *ws = priv;
struct amdgpu_slab *slab = CALLOC_STRUCT(amdgpu_slab);
enum radeon_bo_domain domains = radeon_domain_from_heap(heap);
enum radeon_bo_flag flags = radeon_flags_from_heap(heap);
uint32_t base_id;
+   unsigned slab_size = 0;
 
if (!slab)
   return NULL;
 
-   unsigned slab_size = 1 << AMDGPU_SLAB_BO_SIZE_LOG2;
+   /* Determine the slab buffer size. */
+   for (unsigned i = 0; i < NUM_SLAB_ALLOCATORS; i++) {
+  struct pb_slabs *slabs = >bo_slabs[i];
+  unsigned max_entry_size = 1 << (slabs->min_order + slabs->num_orders - 
1);
+
+  if (entry_size <= max_entry_size) {
+ /* The slab size is twice the size of the largest possible entry. */
+ slab_size = max_entry_size * 2;
+  }
+   }
+   assert(slab_size != 0);
+
slab->buffer = amdgpu_winsys_bo(amdgpu_bo_create(>base,
 slab_size, slab_size,
 domains, flags));
if (!slab->buffer)
   goto fail;
 
-   assert(slab->buffer->bo);
-
slab->base.num_entries = slab->buffer->base.size / entry_size;
slab->base.num_free = slab->base.num_entries;
slab->entries = CALLOC(slab->base.num_entries, sizeof(*slab->entries));
if (!slab->entries)
   goto fail_buffer;
 
LIST_INITHEAD(>base.free);
 
base_id = __sync_fetch_and_add(>next_bo_unique_id, 
slab->base.num_entries);
 
@@ -580,21 +606,29 @@ struct pb_slab *amdgpu_bo_slab_alloc(void *priv, unsigned 
heap,
   bo->base.alignment = entry_size;
   bo->base.usage = slab->buffer->base.usage;
   bo->base.size = entry_size;
   bo->base.vtbl = _winsys_bo_slab_vtbl;
   bo->ws = ws;
   bo->va = slab->buffer->va + i * entry_size;
   bo->initial_domain = domains;
   bo->unique_id = base_id + i;
   bo->u.slab.entry.slab = >base;
   bo->u.slab.entry.group_index = group_index;
-  bo->u.slab.real = slab->buffer;
+
+  if (slab->buffer->bo) {
+ /* The slab is not suballocated. */
+ bo->u.slab.real = slab->buffer;
+  } else {
+ /* The slab is allocated out of a bigger slab. */
+ bo->u.slab.real = slab->buffer->u.slab.real;
+ 

[Mesa-dev] [PATCH 4/7] winsys/amdgpu: clean up code around BO VM alignment

2018-11-23 Thread Marek Olšák
From: Marek Olšák 

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

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index a9271c33ee9..36e2c4ec0dc 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -449,24 +449,29 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct 
amdgpu_winsys *ws,
r = amdgpu_bo_alloc(ws->dev, , _handle);
if (r) {
   fprintf(stderr, "amdgpu: Failed to allocate a buffer:\n");
   fprintf(stderr, "amdgpu:size  : %"PRIu64" bytes\n", size);
   fprintf(stderr, "amdgpu:alignment : %u bytes\n", alignment);
   fprintf(stderr, "amdgpu:domains   : %u\n", initial_domain);
   goto error_bo_alloc;
}
 
va_gap_size = ws->check_vm ? MAX2(4 * alignment, 64 * 1024) : 0;
+
+   unsigned vm_alignment = alignment;
+
+   /* Increase the VM alignment for faster address translation. */
if (size > ws->info.pte_fragment_size)
-  alignment = MAX2(alignment, ws->info.pte_fragment_size);
+  vm_alignment = MAX2(vm_alignment, ws->info.pte_fragment_size);
+
r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
- size + va_gap_size, alignment, 0, , _handle,
+ size + va_gap_size, vm_alignment, 0, , 
_handle,
  (flags & RADEON_FLAG_32BIT ? 
AMDGPU_VA_RANGE_32_BIT : 0) |
 AMDGPU_VA_RANGE_HIGH);
if (r)
   goto error_va_alloc;
 
unsigned vm_flags = AMDGPU_VM_PAGE_READABLE |
AMDGPU_VM_PAGE_EXECUTABLE;
 
if (!(flags & RADEON_FLAG_READ_ONLY))
vm_flags |= AMDGPU_VM_PAGE_WRITEABLE;
-- 
2.17.1

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


  1   2   >