-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Antialiasing Support (GraphicsDevice.PreferMultiSampling) #358
Comments
I'm not sure our implementation of iOS ever had AA enabled. If it did I think it might have been by accident rather than design. It is very nice to have if the GPU does it for free, and we just need to flip some switches. I don't know how the other team members feel about this, but I would suggest pushing this back to 3.0 release. Other AA implementations to thinks about are.. But they would be CPU bound atm. But I always thought maybe this can be an option to toggle on if you are on desktop, perhaps, if we can find an elegant way to do it. |
Agreed. 3.0 it is. As for the toggle to enable/disable AA, is a different solution from GraphicsDeviceManager.PreferMultisampling needed? |
I totally forgot about that option :S |
I think we might need to bump this to post 3.0 |
I posted a bug report about this way back in June I think. @tomspilman responded to it and was looking at it I think. The platform GPUs have their own custom full screen AA that you can enable. nVidia's is CSAA, PowerVR is likely some other thing. You should definitely NOT implement a software version of this as it would perform poorly. |
That has been suggested and i agree MonoGame should never include shader based AA. Still i see the point of this ticket is to enable the standard MSAA that is implemented in hardware on most GPUs. That is something that should be rather simple... 5 to 10 lines of code for DX11. |
Moved it to the 3.x milestone. |
In my investigations yesterday (where I discovered BGR565 is not supported |
Lame. I guess that sort of makes sense... the OS probably does special stuff with it that we're not aware of. Well... one less platform to worry about then. Win8 users will need to use one of the other shader based AA techniques. |
Note that this is the same with Windows Phone 8 at this time. You cannot use MSAA. |
Hi. I'm writing an XNA game for WP7/WP8/Win8 - and I found this which was published last month - http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681697(v=vs.105).aspx - basically explaining how you can use MSAA in WP8 by setting up a render target that has MSAA specified. I'd be willing to have a go at implementing that if someone were able to give me a couple of small pointers as to where in the code base would be the best fit... |
In theory you should be able to create a RenderTarget2D passing it a multisample count greater than 1 and it should work. I can't say I've ever tried it, but I did hook up the code to create MSAA targets. If that doesn't work I suggest you start a new issue here and lets investigate. |
Ok, so I tried it out. I created a RenderTarget2D (in my game code) with a multisample count of 8, then drew that to the screen with a SpriteBatch. I validated the approach in my Win32 build (by setting the back buffer multisampling off) and the result was as you'd expect - multi-sampled goodness. I had a dig around and found that the Texture2D constructor was always setting SampleDescription to {1, 0} - so I added a parameter to the internal constructor to pass down the preferredMultiSampleCount from the RenderTarget2D constructor, and set up the sample description exactly as it is for the depth buffer in RenderTarget2D (preferredMultiSampleCount, SharpDX.Direct3D11.StandardMultisampleQualityLevels.StandardMultisamplePattern). Now on WP8 that blew up - I couldn't find any combination of values for the SampleDescription that didn't result in a SharpDXException with 'The parameter is incorrect'. On W8 Metro it created the texture & render target just fine. However, it still wasn't multi-sampled. Using the debugger to look at the 'Description' member of the _texture object for the suggested that the sample description was correct {8,-1}. So - given that, do you want me to go ahead and create a new issue about MSAA on render targets? Edit -> sorry, forgot to mention - the RenderTarget2D I used had a DepthFormat of None - just to avoid confusion. |
Yes... lets move this to an issue specific to it. |
I did a bit of further work on this and got it working in Win8, at least. This is the commit: duncangrist@0f7540a I have no idea if that fits in with the 'right way', or even if there is such a thing? |
Confirming that your change worked on Win8 but not WinRT (Surface RT). |
@alexyakobovich Not sure if you saw - I made a further commit last night because my friend noticed the same. I don't have one so wasn't able to verify the fix and he wasn't available. That commit is here: duncangrist@74e149f I will be looking at it further on Thursday evening, and hopefully persuading some sort of AA to work on Surface RT - because the Tegra 3 doesn't support MSAA, but supposedly does support NVidia's own CSAA. |
Did anyone touch this since the last post? |
Not I. |
I did fix up the code in that branch a bit, so it's at a point where I'm happy with it. I couldn't find any combination of parameters that would persuade AA to work on Surface RT, unfortunately. However, I can't submit a pull request because I look at framework sources all the time - which forbids me from submitting pull requests. If I've misunderstood the rules, let me know and I will have a go. |
I suspect the trick for getting Win8 to give you a AA surface isn't XNA specific in any way. Can you just tell us here what that one or two lines of code is? |
All I did was follow the article I mentioned above: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681697(v=vs.105).aspx And that works fine for Win8 - I just couldn't find any combination of values for the SampleDesc that resulted in an AA surface on Surface RT. However, it's pretty simple to make it degrade gracefully - you just call CheckMultisampleQualityLevels with a decreasing multi-sample count until pNumQualityLevels is > 0. Under SharpDX, that value is returned from CheckMultisampleQualityLevels. |
That makes sense. To be clear when you say Win8 do you mean "Windows Store App" or do you mean "Windows 8 Desktop"? |
I mean Windows Store App. Our game uses what I wrote, runs happily as a Windows Store App on both Win8 and Surface RT - you just don't get any AA on Surface RT. |
Thanks. So another reason to support offscreen render targets to deal with orientation on WP8. I don't think they could have made things more complex if they tried. |
Agreed. I'd be very happy to help with the WP8 orientation testing, I have a device and a build that targets WP8 so please do call on me if you need assistance. |
I'm using DirectX11 and changing |
I'm using DirectX11 too, Any value other than 1 causes this to happen. |
Latest build still has this issue. |
@SeriousMartin On what platform and are you using render targets? #5477 fixes only one small part of AA issues. |
@SeriousMartin You mean for a DirectX project? If so can you check the value of
All three of these should work for DirectX (there's some issues with the last two options for DesktopGL because the |
This issue is about multisampling on the back buffer, there's separate issues for |
Yes, DirectX. What I'm trying to do is to activate/deactivate multi sampling during runtime. I have create a new MonoGame project rendering only a sprite onto the screen.
The game starts with multi sampling deactivated. When I press M once the sprite is no longer visible. When I press N it's visible again. If I start the game with multi sampling activated it's vice versa. I'd expect this to work. Did I get something wrong? |
No, that should work. This is still bugged then... |
@SeriousMartin Would you mind uploading that sample somewhere? |
@zigzag312 https://www.dropbox.com/s/yzlbem61wtp09rn/Game1.zip?dl=0 |
@SeriousMartin Thanks for the sample. I have found source of your problem. In GraphicsDevice.DirectX.cs -> CreateSizeDependentResources() I'll create PR fix for this. |
* concrete Song .ctor * Song FromUri(...) * SongReader * iOSPlatformInitialize
All platforms need to have antialiasing (re-?)enabled. Pointers here and here.
The text was updated successfully, but these errors were encountered: