OSDN Git Service

minigbm/msm: Correct NV12 UBWC buffer allocation
[android-x86/external-minigbm.git] / msm.c
diff --git a/msm.c b/msm.c
index 7399d30..b291090 100644 (file)
--- a/msm.c
+++ b/msm.c
@@ -83,11 +83,14 @@ static void msm_calculate_layout(struct bo *bo)
                y_stride = ALIGN(width, VENUS_STRIDE_ALIGN);
                uv_stride = ALIGN(width, VENUS_STRIDE_ALIGN);
                y_scanline = ALIGN(height, VENUS_SCANLINE_ALIGN * 2);
-               uv_scanline = ALIGN(DIV_ROUND_UP(height, 2), VENUS_SCANLINE_ALIGN);
+               uv_scanline = ALIGN(DIV_ROUND_UP(height, 2),
+                       VENUS_SCANLINE_ALIGN * (bo->meta.tiling ? 2 : 1));
                y_plane = y_stride * y_scanline;
                uv_plane = uv_stride * uv_scanline;
 
                if (bo->meta.tiling == MSM_UBWC_TILING) {
+                       y_plane = ALIGN(y_plane, PLANE_SIZE_ALIGN);
+                       uv_plane = ALIGN(uv_plane, PLANE_SIZE_ALIGN);
                        y_plane += get_ubwc_meta_size(width, height, 32, 8);
                        uv_plane += get_ubwc_meta_size(width >> 1, height >> 1, 16, 8);
                        extra_padding = NV12_UBWC_PADDING(y_stride);
@@ -186,7 +189,7 @@ static int msm_init(struct driver *drv)
        struct format_metadata metadata;
        uint64_t render_use_flags = BO_USE_RENDER_MASK | BO_USE_SCANOUT;
        uint64_t texture_use_flags = BO_USE_TEXTURE_MASK | BO_USE_HW_VIDEO_DECODER;
-       uint64_t sw_flags = (BO_USE_RENDERSCRIPT | BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_OFTEN |
+       uint64_t sw_flags = (BO_USE_RENDERSCRIPT | BO_USE_SW_MASK |
                             BO_USE_LINEAR | BO_USE_PROTECTED);
 
        drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
@@ -224,35 +227,11 @@ static int msm_init(struct driver *drv)
        render_use_flags &= ~sw_flags;
        texture_use_flags &= ~sw_flags;
 
-       /* TODO(hoegsberg): Disable UBWC while we roll out support for
-        * passing modifiers from ARC++.  cros-gralloc actuallly
-        * allocates UBWC buffers in ARC++, but mesa EGL imports
-        * without a modifier and the ARC++ wayland_service hardcodes
-        * modifier 0 (DRM_FORMAT_MOD_LINEAR).  As a result, both
-        * sides think that they have a linear buffer and happly read
-        * and write linear.  It "works" even though the buffer was
-        * allocated as UBWC, since UBWC really just results in a
-        * slightly larger buffer than what we'd allocate for linear.
-        *
-        * As we land support in mesa for importing with modifers,
-        * mesa will start writing UBWC buffers.  Once we land the
-        * wayland_service change in ARC++, exo will start receiving
-        * the right modifier and read the buffers as UBWC.  We can't
-        * synchronize landing these changes and as they land out of
-        * order, the result is corrupted buffers for a while.  To
-        * avoid breakage in the interim, we disable UBWC while the
-        * changes land and then turn it back on when things settle
-        * down.
-        */
-       if (false) {
-               msm_add_ubwc_combinations(drv, render_target_formats,
-                                         ARRAY_SIZE(render_target_formats),
-                                         &metadata, render_use_flags);
-
-               msm_add_ubwc_combinations(drv, texture_source_formats,
-                                         ARRAY_SIZE(texture_source_formats),
-                                         &metadata, texture_use_flags);
-       }
+       msm_add_ubwc_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
+                                 &metadata, render_use_flags);
+
+       msm_add_ubwc_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
+                                 &metadata, texture_use_flags);
 
        return 0;
 }