[D3D12]Why can't I create a MSAA resource while checkfeature call returns msquality=1?

Started by
2 comments, last by Lemonade101 2 years, 9 months ago

Hi, guys. I'm tring to use MSAA in d3d12 and i want to create a MSAA texture as my render target.

So, following the guides, i first check the MSAA feature support like this:

D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS msql;

msql.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

msql.SampleCount = mssample;

msql.Flags = D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE;

msql.NumQualityLevels = 0;

re = d3dev->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &msql, sizeof(msql));

here in my demo the mssample is 8. The function returns S_OK and msql.NumQualityLevels is changed to 1.

Next , i create my MSAA texture like this:

D3D12_RESOURCE_DESC msrtvdesc = {};

msrtvdesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;

msrtvdesc.Width = scrw;

msrtvdesc.Height = scrh;

msrtvdesc.DepthOrArraySize = 1;

msrtvdesc.MipLevels = 1;

msrtvdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

msrtvdesc.SampleDesc.Count = mssample;

msrtvdesc.SampleDesc.Quality = msquality;

msrtvdesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;

msrtvdesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;

D3D12_HEAP_PROPERTIES msrtvheapprop = {};

msrtvheapprop.Type = D3D12_HEAP_TYPE_DEFAULT;

msrtvheapprop.CreationNodeMask = 1;

msrtvheapprop.VisibleNodeMask = 1;

msrtvheapprop.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;

msrtvheapprop.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;

D3D12_CLEAR_VALUE msrtvdef = {};

msrtvdef.Format = msrtvdesc.Format;

re = d3dev->CreateCommittedResource(&msrtvheapprop, D3D12_HEAP_FLAG_NONE, &msrtvdesc, D3D12_RESOURCE_STATE_COMMON, &msrtvdef, IID_PPV_ARGS(&msrtvbuffer));

And it always fails with the error output by debug layer like this:

D3D12 ERROR: ID3D12Device::CreateCommittedResource: The multisample quality value is not supported. Support for each sample count value and format must be verified. DXGI_SAMPLE_DESC::Count is 8, DXGI_SAMPLE_DESC::Quality is 1, D3D12_RESOURCE_DESC::Format is R8G8B8A8_UNORM. D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS::NumQualityLevels is 1 when calling CheckFeatureSupport with D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS. [ STATE_CREATION ERROR #723: CREATERESOURCE_INVALIDSAMPLEDESC]

But isn't it contradictory? If i get the NumQualityLevels returned by 1, it means the device CAN support MSAA in this count and format right?

Also , my GPU is AMD RX Vega64 with D3D FEATURE LEVEL 12 1 . So according to microsoft's requirement it can definitely support 8x MSAA in R8G8B8A8 UNOM .

I'm totally confused. where do i make a mistake?

Advertisement

You want to use a quality level of 0, not 1. The quality levels start at 0, so when the device says 1 level is supported that means you can use 0 and no values higher than that. ?

(the one exception to this is the “standard” multisample quality levels: D3D12_STANDARD_MULTISAMPLE_PATTERN and D3D12_CENTER_MULTISAMPLE_PATTERN. But you don't usually need to worry about those unless you're doing something fancy).

@MJP Thank you for your reply. It helped me a lot. I've successfully applied msaa to my app.

Then i think it must have a big mistake (or at least misleading) in my textbook lol

This topic is closed to new replies.

Advertisement