summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2019-04-10 22:53:02 +0200
committerAxel Davy <[email protected]>2019-04-30 19:18:51 +0200
commit22c41d2d81efd233b2cde33d6664acc5b48323da (patch)
treefc76bc4d3012a275672e63876f5c5756b32a32d1 /src/gallium
parent85c9d92067d28ce07c3a0c41f4ea225b3768db9c (diff)
st/nine: Refactor volume GetSystemMemPointer
It will make it easier to reuse in another place. Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/nine/volume9.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c
index 3857124be20..1d562f5dd8d 100644
--- a/src/gallium/state_trackers/nine/volume9.c
+++ b/src/gallium/state_trackers/nine/volume9.c
@@ -232,15 +232,16 @@ NineVolume9_AddDirtyRegion( struct NineVolume9 *This,
}
}
-static inline uint8_t *
-NineVolume9_GetSystemMemPointer(struct NineVolume9 *This, int x, int y, int z)
+static inline unsigned
+NineVolume9_GetSystemMemOffset(enum pipe_format format, unsigned stride,
+ unsigned layer_stride,
+ int x, int y, int z)
{
- unsigned x_offset = util_format_get_stride(This->info.format, x);
+ unsigned x_offset = util_format_get_stride(format, x);
- y = util_format_get_nblocksy(This->info.format, y);
+ y = util_format_get_nblocksy(format, y);
- assert(This->data);
- return This->data + (z * This->layer_stride + y * This->stride + x_offset);
+ return z * layer_stride + y * stride + x_offset;
}
HRESULT NINE_WINAPI
@@ -324,8 +325,10 @@ NineVolume9_LockBox( struct NineVolume9 *This,
} else if (This->data) {
pLockedVolume->RowPitch = This->stride;
pLockedVolume->SlicePitch = This->layer_stride;
- pLockedVolume->pBits =
- NineVolume9_GetSystemMemPointer(This, box.x, box.y, box.z);
+ pLockedVolume->pBits = This->data +
+ NineVolume9_GetSystemMemOffset(This->info.format, This->stride,
+ This->layer_stride,
+ box.x, box.y, box.z);
} else {
bool no_refs = !p_atomic_read(&This->base.bind) &&
!p_atomic_read(&This->base.container->bind);