I have already done someting like this for texturecube but here I don't understand what I'm doing wrong. I have the first chance exception error message. Below how I proceed:
- create a texture for depthstencil as texture2Darray (arraysize = 3). works fine
- create a depthstencilarray from this texture. works fine
now I want to create an array of depthstencil to be able to render to them separately without a geometry shader
so I replace 2) like this
2)
ID3D11DepthStencilView* CreateDepthStencilView2DFromArray(ID3D11Texture2D* pText2D, DXGI_FORMAT Format, DWORD Slice)//slice is the index to use in the array
{
ID3D11DepthStencilView* pDSV = NULL;
D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
ZeroMemory(&descDSV, sizeof(descDSV));
descDSV.Format = Format;
descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
descDSV.Texture2DArray.FirstArraySlice = Slice;
descDSV.Texture2DArray.ArraySize = 1;
descDSV.Texture2DArray.MipSlice = 0;
HRESULT hr = gpD11->CreateDepthStencilView(pText2D, &descDSV, &pDSV);
if (FAILED(hr)) return NULL;
return pDSV;
}
of note I don't use mipmaps so I set MipSlice to 0.