Jump to content

  • Log In with Google      Sign In   
  • Create Account

CreateDepthStencilView() return E_INVALIDARG

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1   Members   


Posted 23 June 2012 - 06:00 AM


Actually I have a double problem with the DepthStencilView creation. On one side when I try to create the depth stencil view with a given D3D11_DEPTH_STENCIL_VIEW_DESC structure I get an "An invalid argument was passed to the returning function." error mesage; and on the other side if I set this parameter to 0, nothing is drawn onto my screen.
Here's the correspoding code snipet:
[source lang="cpp"]D3D11_TEXTURE2D_DESC depthStencil_DESCRIPTOR; ZeroMemory(&depthStencil_DESCRIPTOR, sizeof(D3D11_TEXTURE2D_DESC)); depthStencil_DESCRIPTOR.Width = ClientWidth; depthStencil_DESCRIPTOR.Height = ClientHeight; depthStencil_DESCRIPTOR.MipLevels = 1; depthStencil_DESCRIPTOR.ArraySize = 1; depthStencil_DESCRIPTOR.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthStencil_DESCRIPTOR.SampleDesc.Count = 4; depthStencil_DESCRIPTOR.SampleDesc.Quality = m4xMsaaQuality - 1; depthStencil_DESCRIPTOR.Usage = D3D11_USAGE_DEFAULT; depthStencil_DESCRIPTOR.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthStencil_DESCRIPTOR.CPUAccessFlags = 0; depthStencil_DESCRIPTOR.MiscFlags = 0; ID3D11Texture2D* depthStencilBuffer; result = m_Device->CreateTexture2D(&depthStencil_DESCRIPTOR, 0, &depthStencilBuffer); if (FAILED(result)) return false; D3D11_DEPTH_STENCIL_DESC DepthStencilState_DESCRIPTOR; ZeroMemory(&DepthStencilState_DESCRIPTOR, sizeof(D3D11_DEPTH_STENCIL_DESC)); DepthStencilState_DESCRIPTOR.DepthEnable = true; DepthStencilState_DESCRIPTOR.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; DepthStencilState_DESCRIPTOR.DepthFunc = D3D11_COMPARISON_LESS; DepthStencilState_DESCRIPTOR.StencilEnable = true; DepthStencilState_DESCRIPTOR.StencilReadMask = 0xFF; DepthStencilState_DESCRIPTOR.StencilWriteMask = 0xFF; // Stencil Operations on Front facing pixels DepthStencilState_DESCRIPTOR.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; DepthStencilState_DESCRIPTOR.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR; DepthStencilState_DESCRIPTOR.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; DepthStencilState_DESCRIPTOR.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; // Stencil operations on Back facint pixels DepthStencilState_DESCRIPTOR.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; DepthStencilState_DESCRIPTOR.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR; DepthStencilState_DESCRIPTOR.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; DepthStencilState_DESCRIPTOR.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; result = m_Device->CreateDepthStencilState(&DepthStencilState_DESCRIPTOR, &m_DepthStencilState); if (FAILED(result)) return false; m_Context->OMSetDepthStencilState(m_DepthStencilState, 1); D3D11_DEPTH_STENCIL_VIEW_DESC DepthStencilView_DESCRIPTOR; ZeroMemory(&DepthStencilView_DESCRIPTOR, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC)); DepthStencilView_DESCRIPTOR.Format = depthStencil_DESCRIPTOR.Format; DepthStencilView_DESCRIPTOR.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; DepthStencilView_DESCRIPTOR.Texture2D.MipSlice = 0; result = m_Device->CreateDepthStencilView(depthStencilBuffer, &DepthStencilView_DESCRIPTOR, &m_DepthStencilView); if (FAILED(result)) return false;[/source]

#2   Moderators   


Posted 23 June 2012 - 04:40 PM

Your dimension for the DSV needs to be D3D11_DSV_DIMENSION_TEXTURE2DMS if the Texture2D was created with multisampling. Also if you pass the D3D11_CREATE_DEVICE_DEBUG flag when creating your device you will get descriptive error messages in the debug output window.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.