# 'Quality settings' with D3D10: Multisampling, texture filtering and fullscreen resolution

11 replies to this topic

### #1Xcrypt

New Member

• Members
• 144 posts
• LocationBelgium

Posted 25 February 2012 - 11:22 AM

I would like to add some basic quality settings to a game we're working on:

- AA (multisampling)
- Texture filtering (trilinear, anisotropic)
- Fullscreen resolution

But I'm not sure how to do any of this, I can't seem to find a good explanation either in SDK or internet,
so I was wondering if anyone could help?

For Texture filtering, I was thinking I could make different SamplerStates within HLSL, make multiple techniques which use different SamplerStates, and then pick one technique at runtime. But I'm not sure if this is so performance-friendly?

For AA/Multisampling I thought of changing these 2 params in DXGI_SWAP_CHAIN_DESC, only the swapchain would be created before the user sets these settings (he would choose that in some kind of a menu), so it would have to be recreated with a different setting at runtime, and I don't know how to do that?

For fullscreen resolution, do I draw all data to a backbuffer/DSbuffer that has the size of the chosen resolution, and then scale it across the screen?

Thanks.

### #2Reedbeta

DevMaster Staff

• 5306 posts
• LocationBellevue, WA

Posted 25 February 2012 - 06:59 PM

Having multiple techniques and picking different ones at runtime is actually fine, but in fact there's a simpler way, which is just to modify the SamplerState from the application side. You can use ID3DX11EffectSamplerVariable to to retrieve the built-in sampler state, then create a modified sampler state with just the filtering/aniso settings changed, and replace the one in the effect with yours. You can have a list of the names of sampler variables that should be affected, or just iterate over effect variables to find all the samplers.

When changing resolution or multisampling settings it's very common for the game to require you to restart for the changes to be applied. The settings are in a config file somewhere and when you start up it reads the desired ones from the file. Alternatively, you can architect your application so that the renderer is a separate component that can be shut down and restarted independent of the application.

For fullscreen resolution, yes, that's probably a reasonable way to do it. Stretching the image to desktop resolution at the end won't cost very much performance, and it avoids having to actually change the user's video mode (although you can do that if you want with the ChangeDisplaySettings Windows API). IMO, the most important thing to remember is to make the rendering aspect ratio match the monitor's aspect ratio so you don't end up with your image being stretched or squished, even if e.g. you use a 4:3 resolution on a 16:9 screen or something like that. Unfortunately, dealing with monitors, resolutions, and aspect ratios is all kinds of annoying, especially if you consider users who have multi-monitor systems. See here if you want to jump down the rabbit hole.
reedbeta.com - developer blog, OpenGL demos, and other projects

### #3Xcrypt

New Member

• Members
• 144 posts
• LocationBelgium

Posted 28 February 2012 - 08:30 PM

Question though, you say I should respect the aspect ratio of the screen, however I'm some kind of a balance freak when designing games xD

So, I wouldn't want one player to be able to see more than the other just because he's got a different backbuffer resolution/aspect ratio.
For single player games this isn't really a problem, but it is for multiplayer games.

Do you have any ideas how to handle this?

---

EDIT: also, I have some trouble with the multisampling settings. Some formats allow up to sampleCount 4, but only 0 quality, in which case I see no difference at all. What would be a good format to use for this?

### #4Reedbeta

DevMaster Staff

• 5306 posts
• LocationBellevue, WA

Posted 28 February 2012 - 09:19 PM

Letterboxing is one way to handle the multiple-screen-sizes issue without actually widening the FOV.

As for the multisampling stuff, what format are you trying to use? Are you saying CheckMultisampleQualityLevels is giving you a 0 output? That means that combination of format and sample count isn't supported, but a smaller sample count or a different format might be.
reedbeta.com - developer blog, OpenGL demos, and other projects

### #5Xcrypt

New Member

• Members
• 144 posts
• LocationBelgium

Posted 28 February 2012 - 10:03 PM

DXGI_FORMAT_R8G8B8A8_UNORM
CheckMultisampleQualityLevels Is always giving me either 1 or 0, no matter what sampleCount

---

http://en.wikipedia....pping_235x1.jpg
^Lettterboxing would be something like this? Is there no other way?

### #6Reedbeta

DevMaster Staff

• 5306 posts
• LocationBellevue, WA

Posted 28 February 2012 - 10:35 PM

No other way I can think of. I mean, if you want to display the same sized image for all players, but on different-sized monitors, how else are you going to do it? You have to either scale the image or leave some of the monitor unused for some players. (Of course, you could relax the requirement that all players see the same size of image.)

As for the multisampling, a quality level of 1 doesn't mean the quality will be bad, it just means the hardware only supports a single quality setting, so pick any sample count that gives you a quality level > 0 and you should see the multisampling in effect.
reedbeta.com - developer blog, OpenGL demos, and other projects

### #7Xcrypt

New Member

• Members
• 144 posts
• LocationBelgium

Posted 28 February 2012 - 10:52 PM

For aspect ratio, I thought that maybe I can adjust the FOV of the projection matrix for different AR, although I'm not sure how this will turn out (probably won't work out but never hurts to try, right? ). I'll have to see that later on.

CheckMultisampleQualityLevels returns 1, which means that the maximum quality level allowed is 0 (1 less than the returned value)
I have tried with multiple formats (with sampleCount 1), it always returns either 1, or 0, or some really high value(300000+) which doesn't work at all when I try it.
Even with 4x sampleCount (and quality level 0), I see no difference at all. Do I have to adjust something in the shader maybe?

Thanks again.

### #8Reedbeta

DevMaster Staff

• 5306 posts
• LocationBellevue, WA

Posted 29 February 2012 - 12:19 AM

Well, sure, of course you can adjust the FOV. If you're not letterboxing, the horizontal and vertical FOVs should have the same aspect ratio as the screen. But then, e.g. a 16:9 monitor might have a wider FOV than a 4:3 monitor, which you said you wanted to avoid.

I'm not sure why you're not seeing the multisampling, but you might try looking in the DirectX SDK example demos; I'm sure there's a multisampling one in there.
reedbeta.com - developer blog, OpenGL demos, and other projects

### #9Xcrypt

New Member

• Members
• 144 posts
• LocationBelgium

Posted 29 February 2012 - 08:39 AM

oh cool thx. I forgot about those

### #10}:+()___ (Smile)

Member

• Members
• 169 posts

Posted 29 February 2012 - 02:10 PM

I think that fixed diagonal FOV is the best approach in dealing with different aspect ratio. This way in widescreen you can see more at left & right but less at up & down.
Sorry my broken english!

### #11Xcrypt

New Member

• Members
• 144 posts
• LocationBelgium

Posted 03 March 2012 - 12:01 PM

@}:+()___ (Smile)
How would I set that up? Is that not what happens by default though? When you respect the AR of the screen

Also, I went through the DirectX tutorials but the AA code sample is for D3D9 which has a whole different approach... sigh

### #12}:+()___ (Smile)

Member

• Members
• 169 posts

Posted 03 March 2012 - 12:39 PM

I mean, choosing projection matrix so view angle of screen diagonal is constant independent of screen AR. Something like
float W = 1 / sqrt(cx * cx + cy * cy);
D3DXMatrixPerspectiveLH(&mat, near * W * cx, near * W * cy, near, far);


Sorry my broken english!

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users