<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 21, 2017 at 8:33 AM, 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"><div class="HOEnZb"><div class="h5">On 17-03-21 08:07:22, Jason Ekstrand wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, Mar 21, 2017 at 8:04 AM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br>
wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, Mar 20, 2017 at 8:35 PM, Ben Widawsky <<a href="mailto:ben@bwidawsk.net" target="_blank">ben@bwidawsk.net</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This patch begins introducing how we'll actually handle the potentially<br>
many modifiers coming in from the API, how we'll store them, and the<br>
structure in the code to support it.<br>
<br>
Prior to this patch, the Y-tiled modifier would be entirely ignored. It<br>
shouldn't actually be used until this point because we've not bumped the<br>
DRIimage extension version (which is a requirement to use modifiers).<br>
<br>
Measuring later in the series with kmscbe:<br>
Linear:<br>
Read bandwidth: 1048.44 MiB/s<br>
Write bandwidth: 1483.17 MiB/s<br>
<br>
Y-tiled:<br>
Read bandwidth: 471.13 MiB/s<br>
Write bandwidth: 589.10 MiB/s<br>
<br>
Similar functionality was introduced and then reverted here:<br>
<br>
commit 6a0d036483caf87d43ebe2edd19058<wbr>73446c9589<br>
Author: Ben Widawsky <<a href="mailto:ben@bwidawsk.net" target="_blank">ben@bwidawsk.net</a>><br>
Date: Thu Apr 21 20:14:58 2016 -0700<br>
<br>
i965: Always use Y-tiled buffers on SKL+<br>
<br>
v2: Use last set bit instead of first set bit in modifiers to address<br>
bug found by Daniel Stone.<br>
<br>
v3: Use the new priority modifier selection thing. This nullifies the<br>
bug fixed by v2 also.<br>
<br>
Signed-off-by: Ben Widawsky <<a href="mailto:benjamin.widawsky@intel.com" target="_blank">benjamin.widawsky@intel.com</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 | 18 ++++++++++++++++<br>
src/mesa/drivers/dri/i965/int<wbr>el_screen.c | 36<br>
++++++++++++++++++++++++++++--<wbr>--<br>
2 files changed, 50 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/gbm/backends/dri/gbm_dri<wbr>.c<br>
b/src/gbm/backends/dri/gbm_dri<wbr>.c<br>
index a7ac149365..a78ea89fca 100644<br>
--- a/src/gbm/backends/dri/gbm_dri<wbr>.c<br>
+++ b/src/gbm/backends/dri/gbm_dri<wbr>.c<br>
@@ -1143,6 +1143,15 @@ gbm_dri_bo_create(struct gbm_device *gbm,<br>
goto failed;<br>
}<br>
<br>
+ if (modifiers) {<br>
+ for (int i = 0; i < count; i++)<br>
+ if (modifiers[i] == DRM_FORMAT_MOD_INVALID) {<br>
+ fprintf(stderr, "Invalid modifier passed in<br>
DRM_FORMAT_MOD_INVALID");<br>
+ errno = EINVAL;<br>
+ goto failed;<br>
+ }<br>
+ }<br>
+<br>
bo->image =<br>
dri->image->createImageWithMod<wbr>ifiers(dri->screen,<br>
width, height,<br>
@@ -1240,6 +1249,15 @@ gbm_dri_surface_create(struct gbm_device *gbm,<br>
return NULL;<br>
}<br>
<br>
+ if (modifiers) {<br>
+ for (int i = 0; i < count; i++)<br>
+ if (modifiers[i] == DRM_FORMAT_MOD_INVALID) {<br>
+ fprintf(stderr, "Invalid modifier passed in<br>
DRM_FORMAT_MOD_INVALID");<br>
+ errno = EINVAL;<br>
+ return NULL;<br>
+ }<br>
+ }<br>
<br>
</blockquote>
<br>
This could be its own patch but I don't care too much.<br>
<br>
</blockquote>
<br>
Also, you don't need this anymore now that MOD_INVALID just falls through<br>
and doesn't assert below. Feel free to drop it, pull it into its own<br>
patch, or leave it here. (I have a mild preference for dropping it and<br>
just ignoring MOD_INVALID but don't care too much). With that, series is<br>
<br>
Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br>
<br>
<br>
</blockquote>
<br></div></div>
intel_create_image_with_modifi<wbr>ers() (which will be called by this) will assert<br>
if INVALID modifier slips through - which is what I wanted. I don't want any dri<br>
implementation to have to deal with INVALID modifiers. So I think it needs to be<br>
here. Did I misunderstand you?</blockquote><div><br></div><div>That's a problem because the user could provide a list of modifiers none of which we support. If this happens, we'll return INVALID from select_best_modifier anyway. There's no way that a higher layer can possibly know whether or not a list of modifiers contains something that we can handle unless we require LINEAR to be in the list (which seems a bit harsh). I think we should just fail to create the image in that case and set errno to -EINVAL or something like that.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
surf = calloc(1, sizeof *surf);<br>
if (surf == NULL) {<br>
errno = ENOMEM;<br>
diff --git a/src/mesa/drivers/dri/i965/in<wbr>tel_screen.c<br>
b/src/mesa/drivers/dri/i965/in<wbr>tel_screen.c<br>
index 14e60ef1a1..e4f858ed33 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>
@@ -23,6 +23,7 @@<br>
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
*/<br>
<br>
+#include <drm_fourcc.h><br>
#include <errno.h><br>
#include <time.h><br>
#include <unistd.h><br>
@@ -518,11 +519,13 @@ intel_destroy_image(__DRIimage *image)<br>
enum modifier_priority {<br>
MODIFIER_PRIORITY_INVALID = 0,<br>
MODIFIER_PRIORITY_LINEAR,<br>
+ MODIFIER_PRIORITY_Y,<br>
};<br>
<br>
const uint64_t priority_to_modifier[] = {<br>
[MODIFIER_PRIORITY_INVALID] = DRM_FORMAT_MOD_INVALID,<br>
[MODIFIER_PRIORITY_LINEAR] = DRM_FORMAT_MOD_LINEAR,<br>
+ [MODIFIER_PRIORITY_Y] = I915_FORMAT_MOD_Y_TILED,<br>
};<br>
<br>
static uint64_t<br>
@@ -530,11 +533,13 @@ select_best_modifier(struct gen_device_info<br>
*devinfo,<br>
const uint64_t *modifiers,<br>
const unsigned count)<br>
{<br>
-<br>
enum modifier_priority prio = MODIFIER_PRIORITY_INVALID;<br>
<br>
for (int i = 0; i < count; i++) {<br>
switch (modifiers[i]) {<br>
+ case I915_FORMAT_MOD_Y_TILED:<br>
+ prio = MAX2(prio, MODIFIER_PRIORITY_Y);<br>
+ break;<br>
case DRM_FORMAT_MOD_LINEAR:<br>
prio = MAX2(prio, MODIFIER_PRIORITY_LINEAR);<br>
break;<br>
@@ -575,6 +580,9 @@ intel_create_image_common(__DR<wbr>Iscreen *dri_screen,<br>
case DRM_FORMAT_MOD_LINEAR:<br>
tiling = I915_TILING_NONE;<br>
break;<br>
+ case I915_FORMAT_MOD_Y_TILED:<br>
+ tiling = I915_TILING_Y;<br>
+ break;<br>
case DRM_FORMAT_MOD_INVALID:<br>
default:<br>
break;<br>
@@ -626,8 +634,26 @@ intel_create_image_with_modifi<wbr>ers(__DRIscreen<br>
*dri_screen,<br>
const unsigned count,<br>
void *loaderPrivate)<br>
{<br>
- return intel_create_image_common(dri_<wbr>screen, width, height, format,<br>
0, NULL,<br>
- 0, loaderPrivate);<br>
+ uint64_t local_mods[count];<br>
+ int local_count = 0;<br>
+<br>
+ /* This compacts the actual modifiers to the ones we know how to<br>
handle */<br>
+ for (int i = 0; i < count; i++) {<br>
+ switch (modifiers[i]) {<br>
+ case I915_FORMAT_MOD_Y_TILED:<br>
+ case DRM_FORMAT_MOD_LINEAR:<br>
+ local_mods[local_count++] = modifiers[i];<br>
+ break;<br>
+ case DRM_FORMAT_MOD_INVALID:<br>
+ unreachable("Invalid modifiers specified\n");<br>
+ default:<br>
+ /* Modifiers from other vendors would land here. */<br>
+ break;<br>
+ }<br>
+ }<br>
+<br>
+ return intel_create_image_common(dri_<wbr>screen, width, height, format,<br>
0,<br>
+ local_mods, local_count,<br>
loaderPrivate);<br>
}<br>
<br>
static GLboolean<br>
@@ -1997,7 +2023,9 @@ intelAllocateBuffer(__DRIscree<wbr>n *dri_screen,<br>
if (intelBuffer == NULL)<br>
return NULL;<br>
<br>
- /* The front and back buffers are color buffers, which are X tiled. */<br>
+ /* The front and back buffers are color buffers, which are X tiled.<br>
GEN9+<br>
+ * supports Y tiled and compressed buffers, but there is no way to<br>
plumb that<br>
+ * through to here. */<br>
uint32_t tiling = I915_TILING_X;<br>
unsigned long pitch;<br>
int cpp = format / 8;<br>
--<br>
2.12.0<br>
<br>
<br>
</blockquote>
<br>
</blockquote></blockquote>
</div></div></blockquote></div><br></div></div>