[Mesa-dev] [PATCH 11/75] st/nine: Allocate more space for ATI1

Axel Davy axel.davy at ens.fr
Wed Oct 5 20:08:44 UTC 2016


From: Patrick Rudolph <siro at das-labor.org>

ATIx are "unknown" formats that do not follow block format conventions.
Tests showed that pitch*height bytes are allocated.
apitrace used to depend on this behaviour.
It used to copy more bytes than it has to for the ATI1 block format,
but it didn't crash on Windows.

Increase buffersize for ATI1 to fix this crash.
The same issue was present in WINE but a patch has been sent by me.

Signed-off-by: Patrick Rudolph <siro at das-labor.org>
Reviewed-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/nine_pipe.h | 21 +++++++++++++++++----
 src/gallium/state_trackers/nine/surface9.c  |  2 --
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h
index 3472193..1b5a83c 100644
--- a/src/gallium/state_trackers/nine/nine_pipe.h
+++ b/src/gallium/state_trackers/nine/nine_pipe.h
@@ -44,6 +44,8 @@ void nine_convert_sampler_state(struct cso_context *, int idx, const DWORD *);
 
 void nine_pipe_context_clear(struct NineDevice9 *);
 
+#define is_ATI1_ATI2(format) (format == PIPE_FORMAT_RGTC1_UNORM || format == PIPE_FORMAT_RGTC2_UNORM)
+
 static inline void
 rect_to_pipe_box(struct pipe_box *dst, const RECT *src)
 {
@@ -728,8 +730,14 @@ static inline unsigned nine_format_get_level_alloc_size(enum pipe_format format,
 
     w = u_minify(width, level);
     h = u_minify(height, level);
-    size = nine_format_get_stride(format, w) *
-        util_format_get_nblocksy(format, h);
+    if (is_ATI1_ATI2(format)) {
+        /* For "unknown" formats like ATIx use width * height bytes */
+        size = w * h;
+    } else {
+        size = nine_format_get_stride(format, w) *
+            util_format_get_nblocksy(format, h);
+    }
+
     return size;
 }
 
@@ -745,8 +753,13 @@ static inline unsigned nine_format_get_size_and_offsets(enum pipe_format format,
         w = u_minify(width, l);
         h = u_minify(height, l);
         offsets[l] = size;
-        size += nine_format_get_stride(format, w) *
-            util_format_get_nblocksy(format, h);
+        if (is_ATI1_ATI2(format)) {
+            /* For "unknown" formats like ATIx use width * height bytes */
+            size += w * h;
+        } else {
+            size += nine_format_get_stride(format, w) *
+                util_format_get_nblocksy(format, h);
+        }
     }
 
     return size;
diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c
index 0cedd4e..4d54309 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -42,8 +42,6 @@
 
 #define DBG_CHANNEL DBG_SURFACE
 
-#define is_ATI1_ATI2(format) (format == PIPE_FORMAT_RGTC1_UNORM || format == PIPE_FORMAT_RGTC2_UNORM)
-
 HRESULT
 NineSurface9_ctor( struct NineSurface9 *This,
                    struct NineUnknownParams *pParams,
-- 
2.10.0



More information about the mesa-dev mailing list