-->

多重采样和Direct3D10 / D3DImage互操作(Multisampling and Di

2019-10-16 14:18发布

我试图实现使用Direct3D 10的(SlimDX)和WPF一个renderengine。

创建我的设备和正确的多重采样参数(1,0 / 2,0和4,0上班)rendertargetview

        this.multiSamplingDescription = new SampleDescription(sampleCount, qualityLevel - 1); // 4,1

        Texture2DDescription colordesc = new Texture2DDescription();
        colordesc.BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource;
        colordesc.Format = this.renderTargetViewFormat; // Format.B8G8R8A8_UNorm
        colordesc.Width = width;
        colordesc.Height = height;
        colordesc.MipLevels = 1;
        colordesc.SampleDescription = multiSamplingDescription;
        colordesc.Usage = ResourceUsage.Default;
        colordesc.OptionFlags = ResourceOptionFlags.Shared;
        colordesc.CpuAccessFlags = CpuAccessFlags.None;
        colordesc.ArraySize = 4;[/code]

然后试图创建D3DImage共享质地我有一个问题...

        this.Direct3D9Context = new Direct3DEx();
        this.presentParams = new PresentParameters();
        this.presentParams.Windowed = true;
        this.presentParams.SwapEffect = SwapEffect.Discard;
        this.presentParams.DeviceWindowHandle = GetDesktopWindow();
        this.presentParams.PresentationInterval = PresentInterval.Immediate;
        this.presentParams.Multisample = MultisampleType.None;
        this.presentParams.MultisampleQuality = 0;

        this.Device = new DeviceEx(this.Direct3D9Context, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve, this.presentParams);

...

        this.presentParams.Multisample = sampleCount; // = 4
        this.presentParams.MultisampleQuality = 0;
        this.Device.Reset(this.presentParams);

...

        this.SharedTexture = new Texture(this.Device, texture.Description.Width, texture.Description.Height, 1, Usage.RenderTarget, format, Pool.Default, ref Handle);

// format = Format.A8R8G8B8
// Width = 1244 , same as colordesc
// height = 699, same as colordesc

我失去了一些东西?

文章来源: Multisampling and Direct3D10 / D3DImage interop