These are chat archives for libmir/public

May 2016
Petar Kirov
May 13 2016 19:17
Hi guys!
I'm not sure if here's the right place to ask, but I'm thinking about making
a PR to expose the Slice ctor so you can specify the strides manually.

Some context: I'm mmap-ing an image from GPU VRAM into CPU RAM, so I can do a simple mutation,
without the need to execute a shader/kernel just for that (and I'm not concerned about perf
in this part of my app). The problem is that GPU resources like images have special
alignment/padding requirements and I need to be able to specify that,
so I can use ndslice to do the mutation in a more convenient way.

For example I need the following 2x2 image:

void* gpuMem = 0x030A0000
size_t gpuMemSize = 256
size_t gpuRowPitch = 128

uint* pixels = cast(uint*)gpuMem

 0 (used)  1 (used)  3 (padding) ... 31 (padding)
32 (used) 33 (used) 34 (padding) ... 63 (padding)

// So AFAIU, I need the following slice:
Slice!(uint, 2)
._ptr     = pixels
._lengths = [ 2, 2]
._strides = [32, 1]

Ilya Yaroshenko
May 13 2016 19:20
This is already exposed
See photos master or recent Mir
Petar Kirov
May 13 2016 19:21
Ooh thanks
(I am using DMD 2.071)
Nice ;)