How to do L16 texture with /dx9ex?

I have a dynamic plugin where I’m creating an L16 texture, like so:

return new Texture(device, texW, texH, 1, Usage.None, Format.L16, Pool.Managed);

This does not work with /dx9ex, as noted in another thread, and no texture is created. That thread say to change “Pool.Managed” needs to “Pool.Default”. When I do that:

return new Texture(device, texW, texH, 1, Usage.None, Format.L16, Pool.Default);

The texture gets created, but I only get a black texture out. Here’s how it’s being filled:

unsafe protected override void UpdateTexture(int Slice, Texture texture)
    {
        FCurrentSlice = Slice;

        var rect = texture.LockRectangle(0, LockFlags.Discard).Data;
        rect.WriteRange(bitmapptr, texH * texW * 2);
        texture.UnlockRectangle(0);
    }

I looked at TextureUtils.CreateTexture, but can’t see how to make an L16. Any ideas? Thanks!

have a look at https://github.com/vvvv/vvvv-sdk/blob/develop/vvvv45/addonpack/src/nodes/plugins/Devices/OpenNI/Depth.cs l238 to see how to fill a texture in /dx9ex mode. it is important to use the textures pitch instead of its width!

Ayup, that did it. Thanks! Here’s the code for others that might look here:

protected override Texture CreateTexture(int Slice, SlimDX.Direct3D9.Device device)
{
    var pool = Pool.Managed;
    var usage = Usage.None;
    if (device is DeviceEx)
    {
        pool = Pool.Default;
        usage = Usage.Dynamic;
    }

    return new Texture(device, FTexWidth, FTexHeight, 1, usage, Format.L16, pool);
}