+/**
+ * \brief Get tiling format for a DRI buffer.
+ *
+ * \param attachment is the buffer's attachmet point, such as
+ * __DRI_BUFFER_DEPTH.
+ * \param out_tiling is the returned tiling format for buffer.
+ * \return false if attachment is unrecognized or is incompatible with screen.
+ */
+static bool
+intel_get_dri_buffer_tiling(struct intel_screen *screen,
+ uint32_t attachment,
+ uint32_t *out_tiling)
+{
+ if (screen->gen < 4) {
+ *out_tiling = I915_TILING_X;
+ return true;
+ }
+
+ switch (attachment) {
+ case __DRI_BUFFER_DEPTH:
+ case __DRI_BUFFER_DEPTH_STENCIL:
+ case __DRI_BUFFER_HIZ:
+ *out_tiling = I915_TILING_Y;
+ return true;
+ case __DRI_BUFFER_ACCUM:
+ case __DRI_BUFFER_FRONT_LEFT:
+ case __DRI_BUFFER_FRONT_RIGHT:
+ case __DRI_BUFFER_BACK_LEFT:
+ case __DRI_BUFFER_BACK_RIGHT:
+ case __DRI_BUFFER_FAKE_FRONT_LEFT:
+ case __DRI_BUFFER_FAKE_FRONT_RIGHT:
+ *out_tiling = I915_TILING_X;
+ return true;
+ case __DRI_BUFFER_STENCIL:
+ /* The stencil buffer is W tiled. However, we request from the kernel
+ * a non-tiled buffer because the GTT is incapable of W fencing.
+ */
+ *out_tiling = I915_TILING_NONE;
+ return true;
+ default:
+ if(unlikely(INTEL_DEBUG & DEBUG_DRI)) {
+ fprintf(stderr, "error: %s: unrecognized DRI buffer attachment 0x%x\n",
+ __FUNCTION__, attachment);
+ }
+ return false;
+ }
+}
+