<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 1, 2016 at 2:09 PM, Ben Widawsky <span dir="ltr"><<a href="mailto:benjamin.widawsky@intel.com" target="_blank">benjamin.widawsky@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
<br>
This will be used by clients that need to know the number of planes<br>
allocated for them on behalf of the GL or other API. The best current<br>
example of this is when an extra "plane" is allocated to store<br>
compression data for the primary plane.<br>
<br>
Cc: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
Signed-off-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
---<br>
src/gbm/backends/dri/gbm_dri.c | 25 +++++++++++++++++++++++++<br>
src/gbm/gbm-symbols-check | 1 +<br>
src/gbm/main/gbm.c | 10 ++++++++++<br>
src/gbm/main/gbm.h | 3 +++<br>
src/gbm/main/gbmint.h | 1 +<br>
5 files changed, 40 insertions(+)<br>
<br>
diff --git a/src/gbm/backends/dri/gbm_<wbr>dri.c b/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
index 45cb42a..c61d56b 100644<br>
--- a/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
+++ b/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
@@ -598,6 +598,30 @@ gbm_dri_bo_get_fd(struct gbm_bo *_bo)<br>
return fd;<br>
}<br>
<br>
+static int<br>
+get_number_planes(struct gbm_dri_device *dri, __DRIimage *image)<br>
+{<br>
+ int num_planes = 0;<br>
+ dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_NUM_PLANES, &num_planes);<br></blockquote><div><br></div><div>Do we need to do any error checking here? Do we need to check for the right dri image extension version? Do we need to check queryImage != NULL? Do we need to check a return value?<br><br></div><div>I ask because I genuinely don't know how this stuff is supposed to work. Returning a default of 1 seems reasonable.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ if (num_planes <= 0)<br>
+ num_planes = 1;<br>
+<br>
+ return num_planes;<br>
+}<br>
+<br>
+static int<br>
+gbm_dri_bo_get_planes(struct gbm_bo *_bo)<br>
+{<br>
+ struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);<br>
+ struct gbm_dri_bo *bo = gbm_dri_bo(_bo);<br>
+<br>
+ if (bo->image == NULL)<br>
+ return -1;<br>
+<br>
+ return get_number_planes(dri, bo->image);<br>
+}<br>
+<br>
static void<br>
gbm_dri_bo_destroy(struct gbm_bo *_bo)<br>
{<br>
@@ -1055,6 +1079,7 @@ dri_device_create(int fd)<br>
dri->base.base.is_format_<wbr>supported = gbm_dri_is_format_supported;<br>
dri->base.base.bo_write = gbm_dri_bo_write;<br>
dri->base.base.bo_get_fd = gbm_dri_bo_get_fd;<br>
+ dri->base.base.bo_get_planes = gbm_dri_bo_get_planes;<br>
dri->base.base.bo_destroy = gbm_dri_bo_destroy;<br>
dri->base.base.destroy = dri_destroy;<br>
dri->base.base.surface_create = gbm_dri_surface_create;<br>
diff --git a/src/gbm/gbm-symbols-check b/src/gbm/gbm-symbols-check<br>
index 5a333ff..8c4da1b 100755<br>
--- a/src/gbm/gbm-symbols-check<br>
+++ b/src/gbm/gbm-symbols-check<br>
@@ -18,6 +18,7 @@ gbm_bo_get_format<br>
gbm_bo_get_device<br>
gbm_bo_get_handle<br>
gbm_bo_get_fd<br>
+gbm_bo_get_plane_count<br>
gbm_bo_write<br>
gbm_bo_set_user_data<br>
gbm_bo_get_user_data<br>
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c<br>
index 00113fa..b5e0316 100644<br>
--- a/src/gbm/main/gbm.c<br>
+++ b/src/gbm/main/gbm.c<br>
@@ -223,6 +223,16 @@ gbm_bo_get_fd(struct gbm_bo *bo)<br>
return bo->gbm->bo_get_fd(bo);<br>
}<br>
<br>
+/** Get the number of planes for the given bo.<br>
+ *<br>
+ * \param bo The buffer object<br>
+ * \return The number of planes<br>
+ */<br>
+GBM_EXPORT int<br>
+gbm_bo_get_plane_count(struct gbm_bo *bo)<br>
+{<br>
+ return bo->gbm->bo_get_planes(bo);<br>
+}<br>
<br>
/** Write data into the buffer object<br>
*<br>
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h<br>
index efb329e..b4873ab 100644<br>
--- a/src/gbm/main/gbm.h<br>
+++ b/src/gbm/main/gbm.h<br>
@@ -316,6 +316,9 @@ int<br>
gbm_bo_get_fd(struct gbm_bo *bo);<br>
<br>
int<br>
+gbm_bo_get_plane_count(struct gbm_bo *bo);<br>
+<br>
+int<br>
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);<br>
<br>
void<br>
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h<br>
index cfef5ee..c6a6701 100644<br>
--- a/src/gbm/main/gbmint.h<br>
+++ b/src/gbm/main/gbmint.h<br>
@@ -76,6 +76,7 @@ struct gbm_device {<br>
void (*bo_unmap)(struct gbm_bo *bo, void *map_data);<br>
int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);<br>
int (*bo_get_fd)(struct gbm_bo *bo);<br>
+ int (*bo_get_planes)(struct gbm_bo *bo);<br>
void (*bo_destroy)(struct gbm_bo *bo);<br>
<br>
struct gbm_surface *(*surface_create)(struct gbm_device *gbm,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.10.2<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>