Skip to main content
added 42 characters in body
Source Link
philB
  • 333
  • 2
  • 11

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:

  1. create a texture for depthstencil as texture2Darray (arraysize = 3). works fine
  2. 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.

I have already done someting like this for texturecube but here I don't understand what I'm doing wrong. Below how I proceed:

  1. create a texture for depthstencil as texture2Darray (arraysize = 3). works fine
  2. 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.

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:

  1. create a texture for depthstencil as texture2Darray (arraysize = 3). works fine
  2. 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.

Source Link
philB
  • 333
  • 2
  • 11

How to create array of Depthstencil2D from texture2Darray

I have already done someting like this for texturecube but here I don't understand what I'm doing wrong. Below how I proceed:

  1. create a texture for depthstencil as texture2Darray (arraysize = 3). works fine
  2. 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.