st/nine: Support internal compressed format for volumes
authorAxel Davy <davyaxel0@gmail.com>
Wed, 10 Apr 2019 21:05:58 +0000 (23:05 +0200)
committerAxel Davy <davyaxel0@gmail.com>
Tue, 30 Apr 2019 17:18:51 +0000 (19:18 +0200)
Reuse the generic path to support compressed formats.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
src/gallium/state_trackers/nine/volume9.c

index 1d562f5dd8de92e912e04593635466d0749a49b2..ab0a82e288d4125e5e0a07ab9d345dfcce0a1bf5 100644 (file)
@@ -315,19 +315,22 @@ NineVolume9_LockBox( struct NineVolume9 *This,
     if (p_atomic_read(&This->pending_uploads_counter))
         nine_csmt_process(This->base.device);
 
-    if (This->data_internal) {
-        /* For now we only have uncompressed formats here */
-        pLockedVolume->RowPitch = This->stride_internal;
-        pLockedVolume->SlicePitch = This->layer_stride_internal;
-        pLockedVolume->pBits = This->data_internal + box.z * This->layer_stride_internal +
-                               box.y * This->stride_internal +
-                               util_format_get_stride(This->format_internal, box.x);
-    } else if (This->data) {
-        pLockedVolume->RowPitch = This->stride;
-        pLockedVolume->SlicePitch = This->layer_stride;
-        pLockedVolume->pBits = This->data +
-            NineVolume9_GetSystemMemOffset(This->info.format, This->stride,
-                                           This->layer_stride,
+    if (This->data_internal || This->data) {
+        enum pipe_format format = This->info.format;
+        unsigned stride = This->stride;
+        unsigned layer_stride = This->layer_stride;
+        uint8_t *data = This->data;
+        if (This->data_internal) {
+            format = This->format_internal;
+            stride = This->stride_internal;
+            layer_stride = This->layer_stride_internal;
+            data = This->data_internal;
+        }
+        pLockedVolume->RowPitch = stride;
+        pLockedVolume->SlicePitch = layer_stride;
+        pLockedVolume->pBits = data +
+            NineVolume9_GetSystemMemOffset(format, stride,
+                                           layer_stride,
                                            box.x, box.y, box.z);
     } else {
         bool no_refs = !p_atomic_read(&This->base.bind) &&