Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

166 Neutral

About Curin

  • Rank

Personal Information

  • Interests
  1. Curin

    SwapChain Present Issue

    Thank you very much Jesse. I hadn't turned on the Debug layer as I was doing quick tests and forgot. It led me to realize I forgot a bunch of steps that I had put in different spots of my old code, like creating my rendertargets, not just their heaps, and reseting the command list and allocator every frame.   Appreciate your Help, Curin
  2. Hey everyone,  I'm having a small problem when attempting to move to a UWP code base for SharpDX. I've fixed all problems so far but it errors out with:      "The GPU device instance has been suspended. Use GetDeviceRemovedReason to determine the appropriate action." on the following line from TestImageSource.cs in the Present() Function: _chain.Present(1, PresentFlags.None, new PresentParameters()); I do know that the Swapchain.Present() suggests using Swapchain.Present1(), but that isn't an available function in any Swapchain version. Thanks for any help,      Curin   MainPage.cs: [spoiler] public sealed partial class MainPage : Page { private TestImageSource _source; public MainPage() { this.InitializeComponent(); } private void SwapChainPanel_OnLoaded(object sender, RoutedEventArgs e) { _source = new TestImageSource(SwapChainPanel); CompositionTarget.Rendering += CompositionTarget_Rendering; } private void CompositionTarget_Rendering(object sender, object e) { _source.List.ClearRenderTargetView(_source._cpuHandle, SharpDX.Color.CornflowerBlue); _source.Present(); } } [/spoiler] TestImageSource.cs: [spoiler] using System; using System.Threading; using Windows.ApplicationModel; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using SharpDX; using SharpDX.Direct3D12; using SharpDX.DXGI; using Device = SharpDX.Direct3D12.Device; using DXGIDevice = SharpDX.DXGI.Device3; using Adapter = SharpDX.DXGI.Adapter3; using Resource = SharpDX.Direct3D12.Resource; using SwapChain = SharpDX.DXGI.SwapChain3; using Factory = SharpDX.DXGI.Factory4; using FeatureLevel = SharpDX.Direct3D.FeatureLevel; ... public class TestImageSource { const byte FRAMECOUNT = 2; private static Factory _fact = new Factory(); private long _currentFence; private Device _devD3D; private DescriptorHeap _rtvHeap; private CommandQueue _queue; private SwapChain _chain; private Adapter _adapt; private Resource[] _rtv = new Resource[FRAMECOUNT]; private CommandList _ComList; private Fence _fen; private AutoResetEvent _event; private DXGIDevice _devDXGI; private SwapChainPanel _swapPanel; private int _width; private int _height; private int _rtvDescSize; private float _pixelSize; private int _frameIndex; public CpuDescriptorHandle _cpuHandle; private SwapChainDescription1 _chainDesc; private DescriptorHeapDescription _rtvHeapDesc; private bool _isUsingWarp; public GraphicsCommandList List; public CommandAllocator Allocator; public TestImageSource(SwapChainPanel swapPanel) { _swapPanel = swapPanel; _pixelSize = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi/96.0f; _width = (int)(swapPanel.RenderSize.Width * _pixelSize); _height = (int)(swapPanel.RenderSize.Height * _pixelSize); CreateDeviceResources(); Application.Current.Suspending += OnSuspending; } private void CreateDeviceResources() { LoadPipeline(); LoadAssets(); } private void LoadPipeline() { if (_devD3D == null) { try { _isUsingWarp = false; using (SharpDX.DXGI.Adapter adapt = _fact.GetAdapter(0)) _adapt = adapt.QueryInterface<Adapter>(); _devD3D = new Device(_adapt, FeatureLevel.Level_12_1); } finally { _isUsingWarp = true; using (SharpDX.DXGI.Adapter adapt = _fact.GetWarpAdapter()) _adapt = adapt.QueryInterface<Adapter>(); _devD3D = new Device(_adapt, FeatureLevel.Level_12_1); } } _queue = _devD3D.CreateCommandQueue(new CommandQueueDescription(CommandListType.Direct)); _chainDesc = new SwapChainDescription1() { AlphaMode = AlphaMode.Ignore, BufferCount = FRAMECOUNT, Format = Format.B8G8R8A8_UNorm, Height = _height, Width = _width, SampleDescription = new SampleDescription(1, 0), Scaling = Scaling.Stretch, Stereo = false, SwapEffect = SwapEffect.FlipSequential, Usage = Usage.BackBuffer | Usage.RenderTargetOutput }; _devDXGI = new Device3(_devD3D.NativePointer); using (Factory3 fact = _adapt.GetParent<Factory3>()) using (SwapChain1 chain = new SwapChain1(fact, _queue, ref _chainDesc)) _chain = chain.QueryInterface<SwapChain3>(); using (ISwapChainPanelNative nativeObject = ComObject.As<ISwapChainPanelNative>(_swapPanel)) nativeObject.SwapChain = _chain; _rtvHeapDesc = new DescriptorHeapDescription() { DescriptorCount = FRAMECOUNT, Type = DescriptorHeapType.RenderTargetView, Flags = DescriptorHeapFlags.None }; _rtvHeap = _devD3D.CreateDescriptorHeap(_rtvHeapDesc); _rtvDescSize = _devD3D.GetDescriptorHandleIncrementSize(DescriptorHeapType.RenderTargetView); _cpuHandle = _rtvHeap.CPUDescriptorHandleForHeapStart; Allocator = _devD3D.CreateCommandAllocator(CommandListType.Direct); List = _devD3D.CreateCommandList(CommandListType.Direct, Allocator, null); } private void LoadAssets() { _fen = _devD3D.CreateFence(0, FenceFlags.None); _currentFence = 1; _event = new AutoResetEvent(false); WaitForPrevFrame(); } private void WaitForPrevFrame() { long localFence = _currentFence; _queue.Signal(_fen, localFence); _currentFence++; if (_fen.CompletedValue < localFence) { _fen.SetEventOnCompletion(localFence, _event.GetSafeWaitHandle().DangerousGetHandle()); _event.WaitOne(); } _frameIndex = _chain.CurrentBackBufferIndex; _cpuHandle = _rtvHeap.CPUDescriptorHandleForHeapStart; _cpuHandle += _frameIndex * _rtvDescSize; } public void Present() { _queue.ExecuteCommandList(List); _chain.Present(1, PresentFlags.None, new PresentParameters()); WaitForPrevFrame(); } private void OnSuspending(object sender, SuspendingEventArgs e) { throw new NotImplementedException(); } } } [/spoiler]
  3. I'm just curious what the difference between ID2D1DeviceContext::DrawImage and ID2D1DeviceContext::DrawBitmap is and whether there is a reason to use one over the other. I realize Drawimage can use an effect, and DrawBitmap cannot, but other than that what are the uses of each as if DrawBitmap wasn't better in some respect I would doubt it would still exist in the library or that Drawimage wouldn't just take over drawbitmap.   Thanks in Advance, Curin
  4. okay found out my issue. I wan't using Brgasupport creationflag. Thanks so much for your help Drake
  5. Okay I attempted it using 2.6.3 DirectX11_2-net40 and I got the same error   The only problem with the dxgidevice is that the output FrameStatistics, GammaControl, and Gammacontrol Capabilities are throwing exceptions. The outputs are in the adapter
  6. I appreciate all your help, but I still have a problem with your solution Lordadmiral Drake.The line var d2DDevice = new SharpDX.Direct2D1.Device(dxgiDevice2); produces the error Additional information: HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect. I'm not sure why either.   Here is my code [STAThread] static void Main() { RenderForm form = new RenderForm("TEST APP"); Factory fact = new Factory(); Device dev = new Device(fact.Adapters[0]); SwapChain chain = new SwapChain(fact, dev, new SwapChainDescription() { BufferCount = 1, Flags = SwapChainFlags.AllowModeSwitch, IsWindowed = true, ModeDescription = new ModeDescription(800, 600, new Rational(1, 60), Format.B8G8R8A8_UNorm), OutputHandle = form.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }); Texture2D backbuffer = Texture2D.FromSwapChain<Texture2D>(chain, 0); RenderTargetView rtv = new RenderTargetView(dev, backbuffer); SharpDX.Direct3D11.DeviceContext context = dev.ImmediateContext; Surface surf = chain.GetBackBuffer<Surface>(0); Factory2 fact2 = new Factory2(FactoryType.SingleThreaded, DebugLevel.Information); // Query for the adapter and more advanced DXGI objects. var dxgiDevice2 = dev.QueryInterface<SharpDX.DXGI.Device>(); // Get the default Direct2D device and create a context. var d2DDevice = new SharpDX.Direct2D1.Device(dxgiDevice2); var _d2DContext = new SharpDX.Direct2D1.DeviceContext(d2DDevice, DeviceContextOptions.None); _d2DContext.PrimitiveBlend = PrimitiveBlend.SourceOver; var properties = new BitmapProperties1(new PixelFormat(Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), 96, 96, BitmapOptions.Target | BitmapOptions.CannotDraw); var _targ = new Bitmap1(_d2DContext, chain.GetBackBuffer<Surface>(0), properties); _d2DContext.Target = _targ; } Also what version are you using I'm using 3.0.0 and the DirectX11_2-signed-net40   Thanks Again, Curin
  7.      I've been trying to create a direct2d render target from a swapchain. I have tried to mimic the solution from this thread: http://www.gamedev.net/topic/639578-d2d-d3d11-help-me-to-make-them-work-together/, but it does not work. I get an invalid argument error, and I've eliminated all the other possibilities except the surface I've given it. I am currently using Surface1.FromSwapChain to get my surface for my render target but that does not work. I've tried many ways of getting the surface but nothing seems to work. If anyone can point me in a direction it would be very useful.   Thanks very much, Curin
  8.      I have converted the sample from Directx10 SlimDX to work with Directx11. The initial testing was promising witht the fact that I can assign the base color, but when I try to run an effect the program doesn't actually draw the vertices.   The render code is as follows public void Render(int arg) { D3DDevice.ImmediateContext.OutputMerger.SetTargets(SampleDepthView, SampleRenderView); D3DDevice.ImmediateContext.Rasterizer.SetViewports(new Viewport(0, 0, WindowWidth, WindowHeight, 0.0f, 1.0f)); D3DDevice.ImmediateContext.ClearDepthStencilView(SampleDepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); float c = ((float)(arg % 1000)) / 999.0f; D3DDevice.ImmediateContext.ClearRenderTargetView(SampleRenderView, new SlimDX.Color4(1.0f, c, c, c)); D3DDevice.ImmediateContext.InputAssembler.InputLayout = SampleLayout; D3DDevice.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; D3DDevice.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(SampleVertices, 32, 0)); EffectTechnique technique = SampleEffect.GetTechniqueByIndex(0); EffectPass pass = technique.GetPassByIndex(0); for (int i = 0; i < technique.Description.PassCount; ++i) { pass.Apply(D3DDevice.ImmediateContext); D3DDevice.ImmediateContext.Draw(3, 0); } D3DDevice.ImmediateContext.Flush(); } If anyone can help me find out what is wrong. I know that the shader I'm using works as I have used it in place of the minitri11 sample's shader and it worked fine.     Thanks in advance, Curin
  9. So I've used Slimdx Directx 11 and am getting used to it, but a problem aroused from going fullscreen. When I tab out to look at my code it goes back to a windowed mode which is clear(Which as far as I've heard is normal), but then I have no way to regain control of the form. Does anyone know how to deal with this?
  10. Thank You very much MJP =)
  11. In Slimdx, I'm trying to find out how to make a window go fullscreen to a specific monitor with no luck so far. Any help would be appreciated.   Thanks in advance =)
  12.      I've heard there was a library that mimicked the xna classes in slimdx. I want to know if anyone knows where I can find this library or something similar. Any help would be appreciated.   Thank you in advance, Curin
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!