Hello guys, sup
Anti Aliasing in DX11 can be used if I set number of samples equal to 4 and set the sample quality to 1 and set View Dimension of the Dpeth Stencil view desc to D3D11_DSV_DIMENSION_TEXTURE2DMS.
but i have some question about it:
1. I can't apply this on my backbuffer, if i do, i'll get the complete black screen. (don't know what is the reason)
2. the only option i had was Depth/Stencil buffer but after applying these settings, i still didn't receive the correct result from my output. but based on MSDN resource when I create my Texture2D using CreateTexture2D(), the second attribute pInitialData can't be null if i want to use Multi Samples. but i don't know to what I have to set the pSysMem ?
3. since i use RenderToTexture method, am I have to apply these adjustments on those textures that i render my scene on them ?
4. is there any kind of limits for number of AA samples ?
you can take a look at my codes if you want :
//Describe our SwapChain Buffer
DXGI_MODE_DESC bufferDesc;
ZeroMemory(&bufferDesc, sizeof(DXGI_MODE_DESC));
bufferDesc.Width = Width;
bufferDesc.Height = Height;
bufferDesc.RefreshRate.Numerator = 60;
bufferDesc.RefreshRate.Denominator = 1;
//bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
bufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
bufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
bufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
//Describe our SwapChain
DXGI_SWAP_CHAIN_DESC swapChainDesc;
ZeroMemory(&swapChainDesc, sizeof(DXGI_SWAP_CHAIN_DESC));
swapChainDesc.BufferDesc = bufferDesc;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferCount = 1;
swapChainDesc.OutputWindow = hwnd;
swapChainDesc.Windowed = TRUE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
//Create our SwapChain
hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL,
D3D11_SDK_VERSION, &swapChainDesc, &SwapChain, &d3d11Device, NULL, &d3d11DevCon);
//Create our BackBuffer
ID3D11Texture2D* BackBuffer;
hr = SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&BackBuffer);
//Create our Render Target
hr = d3d11Device->CreateRenderTargetView(BackBuffer, NULL, &renderTargetView);
BackBuffer->Release();
//Describe our Depth/Stencil Buffer
D3D11_TEXTURE2D_DESC depthStencilDesc;
depthStencilDesc.Width = Width;
depthStencilDesc.Height = Height;
depthStencilDesc.MipLevels = 1;
depthStencilDesc.ArraySize = 1;
depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilDesc.SampleDesc.Count = 4;
depthStencilDesc.SampleDesc.Quality = 1;
depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthStencilDesc.CPUAccessFlags = 0;
depthStencilDesc.MiscFlags = 0;
D3D11_DEPTH_STENCIL_VIEW_DESC _depthStencilViewDesc;
ZeroMemory(&_depthStencilViewDesc, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC));
_depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
_depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
_depthStencilViewDesc.Texture2D.MipSlice = 0;
//Create the Depth/Stencil View
d3d11Device->CreateTexture2D(&depthStencilDesc, NULL, &depthStencilBuffer);
d3d11Device->CreateDepthStencilView(depthStencilBuffer, &_depthStencilViewDesc, &depthStencilView);