r2d2rigo / MyFirstDirect2D-SharpDX

A simple tutorial on how to draw basic 2D shapes in a Windows Store DirectX app using SharpDX and Direct2D.
MIT License
10 stars 3 forks source link

[SharpDX] D2D + D3DPresenter.Resize(...) exception #1

Closed QuantumDeveloper closed 10 years ago

QuantumDeveloper commented 10 years ago

Hello. I don`t know would you be so kind to help me understand this issue, but I ask for your help.

I faced with issue that when I use D2D on D3D backbuffer and resize swapchainpanel, resizing fails because it always says DXGI ERROR: IDXGISwapChain::ResizeBuffers: Swapchain cannot be resized unless all outstanding buffer references have been released. [ MISCELLANEOUS ERROR #19: ]

But only resource I am using is D2D render target and I dispose it on begin device change event, but inside GraphicsDevice itself during resizing it just crashes on Resize() method. If I dont use D2D, resizing goes well, so I think this is definately because of D2D, but I dont know how to fix it. Here I upload my small test class to demonstrate this issue: https://gist.github.com/469db5ea0270d4524d38.git

Did you face with this error or at least know how to workaround it?

Will be apprechiate for your help.

r2d2rigo commented 10 years ago

What are you referring to when you say "infinite size"? AFAIK traditional cubemap-based skyboxes only need to be drawn before everything else because you can then disable z-testing/writing so they appear as being behind everything.

If on the other hand you want some fillrate optimization by drawing it after the opaque objects but before the transparent ones, then yes, you would have to resort to some z-buffer tricks to position it.

QuantumDeveloper commented 10 years ago

No, no. I mean that I want to make skybox bigger to have possibility to see inside more objects than if it was of little size, but interesting thing here is that when I include my logarithmix z-buffer, cube becomes in front of camera, but not inside it and I could not go inside of that cube. I dont know why this happening, but in any case I stays before it, thats why I see faces disappearance - because I am on the near plane of the cube and its NOT the faces disappearance, its just the border of the cube itself. So, maybe it is possible to make cube really big, but I dont know how to workaround this "bug". Without my custom z-buffer I dont see this issue. Everything works fine, but I limited with the size of cube to my projection matrix in this case.

r2d2rigo commented 10 years ago

I can't tell you what the Direct3D commands for this are since I have only implemented skyboxes in OpenGL but this is what you should follow:

This will make the cube appear as being infinitely big and, since it moves with the camera, you will see it always the same.

QuantumDeveloper commented 10 years ago

I do the same except I add scaling of cube because 1x1x1 is not visible for me) OK, At least its working. This is the main :) Thanks for real help! By the way, dont you mind if we will talking in skype or somewhere else?

r2d2rigo commented 10 years ago

I'm sure the 1x1x1 cube doesn't show because of your current near plane, that's why I told you to change it to 0.

Yeah, I was going to tell you that you can find me on Skype or Hangouts with the same username as here.