# D3D9 Multisampling Question

## Recommended Posts

discman1028    212
Hi, Can anyone tell me what the value of MaxSampleQualities means, after this call? (I gave the variable that name... but I'm not exactly sure what it means. I'm getting a "3" returned in there.
if( SUCCEEDED( glob_pD3D->CheckDeviceMultiSampleType(
devCaps.DeviceType,	// HAL most likely (not REF)
d3ddm.Format,		// Surface format (same as desktop)
TRUE,			// Windowed
&MaxSampleQualities )))


Also, if someone could clear up what "D3DMULTISAMPLE_NONMASKABLE" means, that would be helpful. All I've been able to gather is that you can change the "quality" levels when it is the chosen method. A quote from somewhere:
Quote:
 ...the only enumeration where all multisampling types are exposed to the application is D3DMULTISAMPLE_NONMASKABLE.
Also, this quote is interesting:
Quote:
 In my engine I went for the simplistic solution of having a slider to let the user choose among the various D3DMULTISAMPLE_NONMASKABLE levels. IMO this is better than restricting the user to D3DMULTISAMPLE_N_SAMPLES configurations (for NVIDIA only 2x and 4x) like many games seem to do.
Is it equivalent to use "D3DMULTISAMPLE_NONMASKABLE" + a quality level, to using a "D3DMULTISAMPLE_N_SAMPLES" value? What are the differences? I might as well ask this as well: what does it mean to have 2 to 16 samples? i.e.....
typedef enum _D3DMULTISAMPLE_TYPE {
D3DMULTISAMPLE_NONE = 0,
D3DMULTISAMPLE_2_SAMPLES = 2,
D3DMULTISAMPLE_3_SAMPLES = 3,
D3DMULTISAMPLE_4_SAMPLES = 4,
D3DMULTISAMPLE_5_SAMPLES = 5,
D3DMULTISAMPLE_6_SAMPLES = 6,
D3DMULTISAMPLE_7_SAMPLES = 7,
D3DMULTISAMPLE_8_SAMPLES = 8,
D3DMULTISAMPLE_9_SAMPLES = 9,
D3DMULTISAMPLE_10_SAMPLES = 10,
D3DMULTISAMPLE_11_SAMPLES = 11,
D3DMULTISAMPLE_12_SAMPLES = 12,
D3DMULTISAMPLE_13_SAMPLES = 13,
D3DMULTISAMPLE_14_SAMPLES = 14,
D3DMULTISAMPLE_15_SAMPLES = 15,
D3DMULTISAMPLE_16_SAMPLES = 16,
D3DMULTISAMPLE_FORCE_DWORD = 0xffffffff
} D3DMULTISAMPLE_TYPE;


In the case from this article, is this "D3DMULTISAMPLE_4_SAMPLES"? (1 pixel subdivided into 4). If so, how does "_5_" work?? In summary, questions are bolded! :) Thanks! [Edited by - discman1028 on March 17, 2006 10:01:40 PM]

##### Share on other sites
Demirug    884
Every multisampling mode can support different levels of quality. This can be an improved sample mask or a better down filter. In the case of non mask able buffers the quality can stand for different numbers of samples, too. But two different quality’s can still have the same sample count.

Direct3D defines no direct matching between the quality levels og non mask able buffers and the different mask able buffers. nVidia GPUs as example can use 2 and 4 sample mask able modes but support 4 different non mask able modes.

If your card supports D3DMULTISAMPLE_5_SAMPLES it uses 5 subsamples per pixel. It is the same with all other modes.

##### Share on other sites
discman1028    212

Quote:
 Original post by DemirugIf your card supports D3DMULTISAMPLE_5_SAMPLES it uses 5 subsamples per pixel. It is the same with all other modes.

(Q1) Four makes sense to me, as it splits a pixel into 4 squares. But what method do they use for 5? Maybe I'm thinking too simplistically.

Quote:
 Original post by DemirugI am had used mask able multisampling buffers to add an anti aliasing effect for alpha tests. If you create a non mask able buffer you can’t use this mask and the multisampling buffer is only used for default anti aliasing.

(Q2) Makes sense, but still unclear about AA... so, say my goal was to do AA only. It sounds like either maskable or nonmaskable are both valid options? Are they both okay for both fullscreen and windowed AA?

Also, A couple other questions came up:

(Q3) On my Nvidia control panel, my options show:

AF chocies:

Off
2x
4x
8x

AA choices:

Off
2x
2xQ
4x
8xS

So what do the "Q" and "S" values signify?

(Q4) And as far as values in D3DXCAPS9 (MaxAnisotropy, = 8 for me) and the max sample quality obtained from the following code (MaxSampleQualities = 4 for me):

if( SUCCEEDED( glob_pD3D->CheckDeviceMultiSampleType(   devCaps.AdapterOrdinal,	// Default card   devCaps.DeviceType,	// HAL most likely (not REF)   d3ddm.Format,		// Surface format (same as desktop)   TRUE,			// Windowed   D3DMULTISAMPLE_NONMASKABLE,   &MaxSampleQualities )))

...how do these relate to "1X", "2X", etc? I would just want to enumerate what is available for a given card. "Up to 8X AF, up to 8X AA" would be sufficient in the case of my card.

My guesses about these numbers are:

For AA (nVidia): 0,1,2,3 -> off, 2x, 4x, 8x
For AA (ATI): 0,1,2,3 -> off, 2x, 4x, 6x
For AF: 1,2,3,4,5,6,7,8 -> off, 2x, 4x, 8x, ???

Thanks again! ( Questions in bold :) )

BTW, if anyone has a great link explaining all this, let me know. But it seems arcane to me.

##### Share on other sites
Demirug    884
1: The samples are points (real mathematical points without a size) inside the pixel rectangle and can be placed at any position. This makes it possible to use any number of sample count. In Direct3D 9 it is limited to 16. Direct3D 10 improve this to 32.

2: If you want only AA you can use mask able and non mask able. There is no difference between window or full screen mode but you should always use IDirect3D9::CheckDeviceMultiSampleType to check the available modes.

3:
2xQ is an AA Mode with 2 samples per pixel but a special down filter called Quincunx. It add some blur. Some people like some hate it.
8xS is an AA Mode with 8 samples per pixel but instead of only calculate one color for all 8 samples it calculate 2 color values for every 4 samples. Because of this it is called a mixed (supersampling + multisampling) mode.

4: MaxAnisotropy is not used for the multisampling buffer. MaxAnisotropy is the maximum numbers of texture samples that can be used for texture filter.

##### Share on other sites
discman1028    212
Thanks again, Demirug.

Again, though; Do you know how I could enumerate that these options are available for my card? (Code sample or link maybe?)

AF chocies:

Off
2x
4x
8x

AA choices:

Off
2x
2xQ
4x
8xS

Thanks!