<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 23, 2017 at 10:21 PM, Ben Widawsky <span dir="ltr"><<a href="mailto:ben@bwidawsk.net" target="_blank">ben@bwidawsk.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Replace the naive, 'save all the modifiers' with a proper query for just<br>
the modifier that was selected. To accomplish this, two new query tokens<br>
are added to the extension:<br>
__DRI_IMAGE_ATTRIB_MODIFIER_UP<wbr>PER<br>
__DRI_IMAGE_ATTRIB_MODIFIER_LO<wbr>WER<br>
<br>
The query extension only supported 32b queries, and modifiers are 64b,<br>
so we needed two of them.<br>
<br>
NOTE: The extension version is still set to 13, so none of this will<br>
actually be called.<br>
<br>
v2: Use stored modifiers from create instead of queryImage<br>
<br>
v3: Make sure not to query modifiers for dumb buffers (Daniel)<br>
Fixed comments in functions.<br>
<br>
Cc: Daniel Stone <<a href="mailto:daniel@fooishbar.org" target="_blank">daniel@fooishbar.org</a>><br>
Signed-off-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net" target="_blank">ben@bwidawsk.net</a>><br>
Reviewed-by: Eric Engestrom <<a href="mailto:eric.engestrom@imgtec.com" target="_blank">eric.engestrom@imgtec.com</a>><br>
Acked-by: Daniel Stone <<a href="mailto:daniels@collabora.com" target="_blank">daniels@collabora.com</a>><br>
---<br>
src/gbm/backends/dri/gbm_dri.<wbr>c | 37 ++++++++++++++++++++++++------<wbr>--<br>
src/gbm/gbm-symbols-check | 1 +<br>
src/gbm/main/gbm.c | 19 ++++++++++++++++<br>
src/gbm/main/gbm.h | 3 +++<br>
src/gbm/main/gbmint.h | 5 +----<br>
src/mesa/drivers/dri/i965/int<wbr>el_screen.c | 6 ++++++<br>
6 files changed, 58 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/src/gbm/backends/dri/gbm_dri<wbr>.c b/src/gbm/backends/dri/gbm_dri<wbr>.c<br>
index a777f1a984..d5b458aa38 100644<br>
--- a/src/gbm/backends/dri/gbm_dri<wbr>.c<br>
+++ b/src/gbm/backends/dri/gbm_dri<wbr>.c<br>
@@ -38,6 +38,7 @@<br>
#include <unistd.h><br>
#include <dlfcn.h><br>
#include <xf86drm.h><br>
+#include <drm_fourcc.h><br>
<br>
#include <GL/gl.h> /* dri_interface needs GL types */<br>
#include <GL/internal/dri_interface.h><br>
@@ -732,6 +733,32 @@ gbm_dri_bo_get_offset(struct gbm_bo *_bo, int plane)<br>
return (uint32_t)offset;<br>
}<br>
<br>
+static uint64_t<br>
+gbm_dri_bo_get_modifier(struc<wbr>t 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 (!dri->image || dri->image->base.version < 14) {<br>
+ errno = ENOSYS;<br>
+ return 0;<br></blockquote><div><br></div><div>Do we want to return the invalid modifier in the error case? I thought 0 was "linear"<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+<br>
+ /* Dumb buffers have no modifiers */<br>
+ if (!bo->image)<br>
+ return 0; <br></blockquote><div><br></div><div>Same here. I'm not really sure that this is an error, but saying it's linear might be a lie. I guess this is a static function so maybe it doesn't matter?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ uint64_t ret = 0;<br>
+ int mod;<br>
+ dri->image->queryImage(bo->im<wbr>age, __DRI_IMAGE_ATTRIB_MODIFIER_UP<wbr>PER, &mod);<br>
+ ret = (uint64_t)mod << 32;<br>
+<br>
+ dri->image->queryImage(bo->im<wbr>age, __DRI_IMAGE_ATTRIB_MODIFIER_LO<wbr>WER, &mod);<br>
+ ret |= mod;<br>
+<br>
+ return ret;<br>
+}<br>
+<br>
static void<br>
gbm_dri_bo_destroy(struct gbm_bo *_bo)<br>
{<br>
@@ -1074,15 +1101,6 @@ gbm_dri_bo_create(struct gbm_device *gbm,<br>
if (bo->image == NULL)<br>
goto failed;<br>
<br>
- bo->base.base.modifiers = calloc(count, sizeof(*modifiers));<br>
- if (count && !bo->base.base.modifiers) {<br>
- dri->image->destroyImage(bo->i<wbr>mage);<br>
- goto failed;<br>
- }<br>
-<br>
- bo->base.base.count = count;<br>
- memcpy(bo->base.base.modifier<wbr>s, modifiers, count * sizeof(*modifiers));<br>
-<br></blockquote><div><br></div><div>What's going on here? Is this in the right patch?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
dri->image->queryImage(bo->ima<wbr>ge, __DRI_IMAGE_ATTRIB_HANDLE,<br>
&bo->base.base.handle.s32);<br>
dri->image->queryImage(bo->ima<wbr>ge, __DRI_IMAGE_ATTRIB_STRIDE,<br>
@@ -1230,6 +1248,7 @@ dri_device_create(int fd)<br>
dri->base.base.bo_get_handle = gbm_dri_bo_get_handle_for_plan<wbr>e;<br>
dri->base.base.bo_get_stride = gbm_dri_bo_get_stride;<br>
dri->base.base.bo_get_offset = gbm_dri_bo_get_offset;<br>
+ dri->base.base.bo_get_modifie<wbr>r = gbm_dri_bo_get_modifier;<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 c137c6cd93..c72fb66b03 100755<br>
--- a/src/gbm/gbm-symbols-check<br>
+++ b/src/gbm/gbm-symbols-check<br>
@@ -23,6 +23,7 @@ gbm_bo_get_handle<br>
gbm_bo_get_fd<br>
gbm_bo_get_plane_count<br>
gbm_bo_get_handle_for_plane<br>
+gbm_bo_get_modifier<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 bfdd009bef..8780b41914 100644<br>
--- a/src/gbm/main/gbm.c<br>
+++ b/src/gbm/main/gbm.c<br>
@@ -280,6 +280,25 @@ gbm_bo_get_handle_for_plane(st<wbr>ruct gbm_bo *bo, int plane)<br>
return bo->gbm->bo_get_handle(bo, plane);<br>
}<br>
<br>
+/**<br>
+ * Get the chosen modifier for the buffer object<br>
+ *<br>
+ * This function returns the modifier that was chosen for the object. These<br>
+ * properties may be generic, or platform/implementation dependent.<br>
+ *<br>
+ * \param bo The buffer object<br>
+ * \return Returns the selected modifier (chosen by the implementation) for the<br>
+ * BO.<br>
+ * \sa gbm_bo_create_with_modifiers() where possible modifiers are set<br>
+ * \sa gbm_surface_create_with_modifi<wbr>ers() where possible modifiers are set<br>
+ * \sa define DRM_FORMAT_MOD_* in drm_fourcc.h for possible modifiers<br>
+ */<br>
+GBM_EXPORT uint64_t<br>
+gbm_bo_get_modifier(struct gbm_bo *bo)<br>
+{<br>
+ return bo->gbm->bo_get_modifier(bo);<br>
+}<br>
+<br>
/** Write data into the buffer object<br>
*<br>
* If the buffer object was created with the GBM_BO_USE_WRITE flag,<br>
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h<br>
index 39fb9d2d29..b52137ed01 100644<br>
--- a/src/gbm/main/gbm.h<br>
+++ b/src/gbm/main/gbm.h<br>
@@ -327,6 +327,9 @@ gbm_bo_get_handle(struct gbm_bo *bo);<br>
int<br>
gbm_bo_get_fd(struct gbm_bo *bo);<br>
<br>
+uint64_t<br>
+gbm_bo_get_modifier(struct gbm_bo *bo);<br>
+<br>
int<br>
gbm_bo_get_plane_count(struct gbm_bo *bo);<br>
<br>
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h<br>
index cd437df021..c27a7a560a 100644<br>
--- a/src/gbm/main/gbmint.h<br>
+++ b/src/gbm/main/gbmint.h<br>
@@ -82,6 +82,7 @@ struct gbm_device {<br>
union gbm_bo_handle (*bo_get_handle)(struct gbm_bo *bo, int plane);<br>
uint32_t (*bo_get_stride)(struct gbm_bo *bo, int plane);<br>
uint32_t (*bo_get_offset)(struct gbm_bo *bo, int plane);<br>
+ uint64_t (*bo_get_modifier)(struct gbm_bo *bo);<br>
void (*bo_destroy)(struct gbm_bo *bo);<br>
<br>
struct gbm_surface *(*surface_create)(struct gbm_device *gbm,<br>
@@ -107,10 +108,6 @@ struct gbm_bo {<br>
uint32_t height;<br>
uint32_t stride;<br>
uint32_t format;<br>
- struct {<br>
- uint64_t *modifiers;<br>
- unsigned int count;<br>
- };<br></blockquote><div><br></div><div>Same here.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
union gbm_bo_handle handle;<br>
void *user_data;<br>
void (*destroy_user_data)(struct gbm_bo *, void *);<br>
diff --git a/src/mesa/drivers/dri/i965/in<wbr>tel_screen.c b/src/mesa/drivers/dri/i965/in<wbr>tel_screen.c<br>
index eb4f3d7e6b..91b89f0a93 100644<br>
--- a/src/mesa/drivers/dri/i965/in<wbr>tel_screen.c<br>
+++ b/src/mesa/drivers/dri/i965/in<wbr>tel_screen.c<br>
@@ -743,6 +743,12 @@ intel_query_image(__DRIimage *image, int attrib, int *value)<br>
case __DRI_IMAGE_ATTRIB_OFFSET:<br>
*value = image->offset;<br>
return true;<br>
+ case __DRI_IMAGE_ATTRIB_MODIFIER_LO<wbr>WER:<br>
+ *value = (image->modifier & 0xffffffff);<br>
+ return true;<br>
+ case __DRI_IMAGE_ATTRIB_MODIFIER_UP<wbr>PER:<br>
+ *value = ((image->modifier >> 32) & 0xffffffff);<br>
+ return true;<br>
<br>
default:<br>
return false;<br>
<span class="m_-554358207546748929m_-6217723562595345352HOEnZb"><font color="#888888">--<br>
2.11.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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>