小编Jen*_*lte的帖子

SharpDX:从DataStream初始化Texture2D失败(虽然Texture1D工作正常)

我正在尝试从内存数据创建SharpDX.Direct3D11.Texture2D但总是得到SharpDXException(HRESULT:0x80070057,"参数不正确.").我为此目的使用了Texture1D,之前可以毫无问题地创建它.

我已将代码减少到此样本,但仍会产生异常:

using (var device = new Device(DriverType.Hardware, DeviceCreationFlags.Debug)) {
    // empty stream sufficient for example
    var stream = new DataStream(16 * 4, true, true);

    var description1D = new Texture1DDescription() {
        Width = 16,
        ArraySize = 1,
        Format = Format.R8G8B8A8_UNorm,
        MipLevels = 1,
    };
    using (var texture1D = new Texture1D(device, description1D, new[] { new DataBox(stream.DataPointer) })) {
        // no exception on Texture1D
    }

    var description2D = new Texture2DDescription() {
        Width = 8,
        Height = 2,
        ArraySize = 1,
        MipLevels = …
Run Code Online (Sandbox Code Playgroud)

c# directx textures directx-11 sharpdx

2
推荐指数
1
解决办法
3321
查看次数

标签 统计

c# ×1

directx ×1

directx-11 ×1

sharpdx ×1

textures ×1