Skip to main content
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/
Source Link

Following my question herehere, I decided to create an 2D texture array for all of my depth screen texture so that I can use them for shadows for all my lights.

I'm having an issue setting it up, I'm getting an E_INVALIDARG when I try to create it.

This code is what I use to create the 2D array Texture

D3D11_TEXTURE2D_DESC sTexDesc;
sTexDesc.Width = this->Width;  // 1024
sTexDesc.Height = this->Height;// 1024
sTexDesc.MipLevels = 0;
sTexDesc.ArraySize = arraySize; // The value is 25 here
sTexDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;

HRESULT hr = pd3dDevice->CreateTexture2D(&sTexDesc, NULL, &(this->shadowTexture));
if(FAILED(hr))
    throw std::exception("Failed at creating texture array for shadows");

This is the code that I use to create the depth view

D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(dsvDesc));
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.ArraySize = arraySize; // The value is 25 here
dsvDesc.Texture2DArray.FirstArraySlice = index;
HRESULT hr = pd3dDevice->CreateDepthStencilView(shadowTexture, &dsvDesc, &pDepthMapDSV);
if(FAILED(hr)){ throw std::exception("Error creating 2d texture for shadow"); }

CreateDepthStencilView will return OK for the first texture but it crashes for the second.

What have I done wrong here?

Following my question here, I decided to create an 2D texture array for all of my depth screen texture so that I can use them for shadows for all my lights.

I'm having an issue setting it up, I'm getting an E_INVALIDARG when I try to create it.

This code is what I use to create the 2D array Texture

D3D11_TEXTURE2D_DESC sTexDesc;
sTexDesc.Width = this->Width;  // 1024
sTexDesc.Height = this->Height;// 1024
sTexDesc.MipLevels = 0;
sTexDesc.ArraySize = arraySize; // The value is 25 here
sTexDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;

HRESULT hr = pd3dDevice->CreateTexture2D(&sTexDesc, NULL, &(this->shadowTexture));
if(FAILED(hr))
    throw std::exception("Failed at creating texture array for shadows");

This is the code that I use to create the depth view

D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(dsvDesc));
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.ArraySize = arraySize; // The value is 25 here
dsvDesc.Texture2DArray.FirstArraySlice = index;
HRESULT hr = pd3dDevice->CreateDepthStencilView(shadowTexture, &dsvDesc, &pDepthMapDSV);
if(FAILED(hr)){ throw std::exception("Error creating 2d texture for shadow"); }

CreateDepthStencilView will return OK for the first texture but it crashes for the second.

What have I done wrong here?

Following my question here, I decided to create an 2D texture array for all of my depth screen texture so that I can use them for shadows for all my lights.

I'm having an issue setting it up, I'm getting an E_INVALIDARG when I try to create it.

This code is what I use to create the 2D array Texture

D3D11_TEXTURE2D_DESC sTexDesc;
sTexDesc.Width = this->Width;  // 1024
sTexDesc.Height = this->Height;// 1024
sTexDesc.MipLevels = 0;
sTexDesc.ArraySize = arraySize; // The value is 25 here
sTexDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;

HRESULT hr = pd3dDevice->CreateTexture2D(&sTexDesc, NULL, &(this->shadowTexture));
if(FAILED(hr))
    throw std::exception("Failed at creating texture array for shadows");

This is the code that I use to create the depth view

D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(dsvDesc));
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.ArraySize = arraySize; // The value is 25 here
dsvDesc.Texture2DArray.FirstArraySlice = index;
HRESULT hr = pd3dDevice->CreateDepthStencilView(shadowTexture, &dsvDesc, &pDepthMapDSV);
if(FAILED(hr)){ throw std::exception("Error creating 2d texture for shadow"); }

CreateDepthStencilView will return OK for the first texture but it crashes for the second.

What have I done wrong here?

deleted 19 characters in body
Source Link
Caesar
  • 461
  • 5
  • 22

Following my question here, I decided to create an 2D texture array for all of my depth screen texture so that I can use them for shadows for all my lights.

I'm having an issue setting it up, I'm getting an E_INVALIDARG when I try to create it.

This code is what I use to create the 2D array Texture

D3D11_TEXTURE2D_DESC sTexDesc;
sTexDesc.Width = this->Width;  // 1024
sTexDesc.Height = this->Height;// 1024
sTexDesc.MipLevels = 0;
sTexDesc.ArraySize = cBuffer::numOfLights;arraySize; // The value is 25 here
sTexDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;

HRESULT hr = pd3dDevice->CreateTexture2D(&sTexDesc, NULL, &(this->shadowTexture));
if(FAILED(hr))
    throw std::exception("Failed at creating texture array for shadows");

This is the code that I use to create the depth view

D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(dsvDesc));
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.ArraySize = arraySize; // The value is 25 here
dsvDesc.Texture2DArray.FirstArraySlice = index;
HRESULT hr = pd3dDevice->CreateDepthStencilView(shadowTexture, &dsvDesc, &newObject->D3DInfo.pDepthMapDSV&pDepthMapDSV);
if(FAILED(hr)){ throw std::exception("Error creating 2d texture for shadow"); }

CreateDepthStencilView will return OK for the first texture but it crashes for the second.

What have I done wrong here?

Following my question here, I decided to create an 2D texture array for all of my depth screen texture so that I can use them for shadows for all my lights.

I'm having an issue setting it up, I'm getting an E_INVALIDARG when I try to create it.

This code is what I use to create the 2D array Texture

D3D11_TEXTURE2D_DESC sTexDesc;
sTexDesc.Width = this->Width;
sTexDesc.Height = this->Height;
sTexDesc.MipLevels = 0;
sTexDesc.ArraySize = cBuffer::numOfLights; // The value is 25 here
sTexDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;

HRESULT hr = pd3dDevice->CreateTexture2D(&sTexDesc, NULL, &(this->shadowTexture));
if(FAILED(hr))
    throw std::exception("Failed at creating texture array for shadows");

This is the code that I use to create the depth view

D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(dsvDesc));
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.ArraySize = arraySize; // The value is 25 here
dsvDesc.Texture2DArray.FirstArraySlice = index;
HRESULT hr = pd3dDevice->CreateDepthStencilView(shadowTexture, &dsvDesc, &newObject->D3DInfo.pDepthMapDSV);
if(FAILED(hr)){ throw std::exception("Error creating 2d texture for shadow"); }

CreateDepthStencilView will return OK for the first texture but it crashes for the second.

What have I done wrong here?

Following my question here, I decided to create an 2D texture array for all of my depth screen texture so that I can use them for shadows for all my lights.

I'm having an issue setting it up, I'm getting an E_INVALIDARG when I try to create it.

This code is what I use to create the 2D array Texture

D3D11_TEXTURE2D_DESC sTexDesc;
sTexDesc.Width = this->Width;  // 1024
sTexDesc.Height = this->Height;// 1024
sTexDesc.MipLevels = 0;
sTexDesc.ArraySize = arraySize; // The value is 25 here
sTexDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;

HRESULT hr = pd3dDevice->CreateTexture2D(&sTexDesc, NULL, &(this->shadowTexture));
if(FAILED(hr))
    throw std::exception("Failed at creating texture array for shadows");

This is the code that I use to create the depth view

D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(dsvDesc));
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.ArraySize = arraySize; // The value is 25 here
dsvDesc.Texture2DArray.FirstArraySlice = index;
HRESULT hr = pd3dDevice->CreateDepthStencilView(shadowTexture, &dsvDesc, &pDepthMapDSV);
if(FAILED(hr)){ throw std::exception("Error creating 2d texture for shadow"); }

CreateDepthStencilView will return OK for the first texture but it crashes for the second.

What have I done wrong here?

Source Link
Caesar
  • 461
  • 5
  • 22

Creating a 2D texture array for depth view

Following my question here, I decided to create an 2D texture array for all of my depth screen texture so that I can use them for shadows for all my lights.

I'm having an issue setting it up, I'm getting an E_INVALIDARG when I try to create it.

This code is what I use to create the 2D array Texture

D3D11_TEXTURE2D_DESC sTexDesc;
sTexDesc.Width = this->Width;
sTexDesc.Height = this->Height;
sTexDesc.MipLevels = 0;
sTexDesc.ArraySize = cBuffer::numOfLights; // The value is 25 here
sTexDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;

HRESULT hr = pd3dDevice->CreateTexture2D(&sTexDesc, NULL, &(this->shadowTexture));
if(FAILED(hr))
    throw std::exception("Failed at creating texture array for shadows");

This is the code that I use to create the depth view

D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
ZeroMemory(&dsvDesc, sizeof(dsvDesc));
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.ArraySize = arraySize; // The value is 25 here
dsvDesc.Texture2DArray.FirstArraySlice = index;
HRESULT hr = pd3dDevice->CreateDepthStencilView(shadowTexture, &dsvDesc, &newObject->D3DInfo.pDepthMapDSV);
if(FAILED(hr)){ throw std::exception("Error creating 2d texture for shadow"); }

CreateDepthStencilView will return OK for the first texture but it crashes for the second.

What have I done wrong here?