<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 21, 2017 at 1:45 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">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 kmscube:<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">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">benjamin.widawsky@intel.com</a>><br>
Reviewed-by: Eric Engestrom <<a href="mailto:eric.engestrom@imgtec.com">eric.engestrom@imgtec.com</a>><br>
Acked-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
---<br>
src/mesa/drivers/dri/i965/<wbr>intel_screen.c | 36 ++++++++++++++++++++++++++++--<wbr>--<br>
1 file changed, 32 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
index 8ba90f0a0c..8bb3aca946 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_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 *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(__<wbr>DRIscreen *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>
if (modifiers)<br>
return NULL;<br>
@@ -628,8 +636,26 @@ intel_create_image_with_<wbr>modifiers(__DRIscreen *dri_screen,<br>
const unsigned count,<br>
void *loaderPrivate)<br>
{<br>
- return intel_create_image_common(dri_<wbr>screen, width, height, format, 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 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></blockquote><div><br></div><div>I don't think you want unreachable here. The higher layers only check modifier zero. They don't walk the entire list.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ default:<br>
+ /* Modifiers from other vendors would land here. */<br>
+ break;<br>
+ }<br>
+ }<br></blockquote><div><br></div><div>Also, what's the benifit of the local modifiers thing? The select_best_modifier can handle an arbitrarily long list so I don't see what this is gaining us.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ return intel_create_image_common(dri_<wbr>screen, width, height, format, 0,<br>
+ local_mods, local_count, loaderPrivate);<br>
}<br>
<br>
static GLboolean<br>
@@ -1999,7 +2025,9 @@ intelAllocateBuffer(__<wbr>DRIscreen *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. GEN9+<br>
+ * supports Y tiled and compressed buffers, but there is no way to plumb that<br>
+ * through to here. */<br>
uint32_t tiling = I915_TILING_X;<br>
unsigned long pitch;<br>
int cpp = format / 8;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.12.0<br>
<br>
</font></span></blockquote></div><br></div></div>