private void SurfaceUpdated(IntPtr surfaceHandle) { SharpDX.ComObject sharedObject = new SharpDX.ComObject(surfaceHandle); SharpDX.DXGI.Resource sharedResource = sharedObject.QueryInterface <SharpDX.DXGI.Resource>(); SharpDX.Direct3D11.Texture2D nativeRexture = dX11GraphicsContext.DXDevice.OpenSharedResource <SharpDX.Direct3D11.Texture2D>(sharedResource.SharedHandle); var texture = DX11Texture.FromDirectXTexture(dX11GraphicsContext, nativeRexture); var rTDepthTargetDescription = new TextureDescription() { Type = TextureType.Texture2D, Format = PixelFormat.D24_UNorm_S8_UInt, Width = texture.Description.Width, Height = texture.Description.Height, Depth = 1, ArraySize = 1, Faces = 1, Flags = TextureFlags.DepthStencil, CpuAccess = ResourceCpuAccess.None, MipLevels = 1, Usage = ResourceUsage.Default, SampleCount = TextureSampleCount.None, }; var rTDepthTarget = this.dX11GraphicsContext.Factory.CreateTexture(ref rTDepthTargetDescription, "SwapChain_Depth"); var frameBuffer = this.dX11GraphicsContext.Factory.CreateFrameBuffer(new FrameBufferAttachment(rTDepthTarget, 0, 1), new[] { new FrameBufferAttachment(texture, 0, 1) }); frameBuffer.SwapchainAssociated = true; display.FrameBuffer?.Dispose(); display.UpdateFrameBuffer(frameBuffer); }
public void UpdateDX11Resources(DX11RenderContext context) { var invalidate = !_newAccFrameReady.ContainsKey(context) || !DX11Texture.Contains(context); if (invalidate) { UpdateSize(); } if (!invalidate) { invalidate = _newAccFrameReady[context]; } if (_newAccFramePtr != IntPtr.Zero && invalidate) { if (DX11Texture.Contains(context)) { DX11Texture.Dispose(context); } try { DX11Texture[context] = DX11Texture2D.FromSharedHandle(context, _newAccFramePtr); IsTextureValid = true; } catch { IsTextureValid = false; } } if (invalidate) { _newAccFrameReady.UpdateGeneric(context, false); //Browser.Host.SendExternalBeginFrame(); } }