locked
ResolveSubresource on a MSAA Texture array RRS feed

  • Question

  • Hello,

    I used with success a Texture2DArray to render cascaded shadow maps, with no MSAA (MSAA count of 1). This texture array was used to render the depth of the scene (m_pRenderTargetTexture).

    Now I am trying to get it working with MSAA enabled (count >=2) and to do so I tried to use the UpdateSubresource to convert this depth texture into a non-MSAA texture.

    if(m_pCopyResolveTexture)
    		pContext->ResolveSubresource(m_pCopyResolveTexture, 0, m_pRenderTargetTexture, 0, DXGI_FORMAT_R32G32B32A32_FLOAT);

    You will find below he code to initialize the textures and the resource views. However, it seems that only the first array slice of my MSAA texture (m_pRenderTargetTexture) is converted, which causes incorrect rendering of the shadows when I use MSAA. Did someone manage before to use UpdateSubresouce on a MSAA Texture 2D resource or am I doing something wrong ?

    Also, I tried to bind the MSAA shader resource directly, without calling UpdateSubresource. Quite surprisingly, it worked. The code in the shader to access the texture is the following:

    Texture2DArray<float4> aCascadedDepthBuffer : register(t6);
    
    depthValue = aCascadedDepthBuffer.Sample(LinearSamplerClamp, float3(projectTexCoord, iCascadeIndex)).r;

    Best regards

    // Initialize the render target texture description.
    	ZeroMemory(&textureDesc, sizeof(textureDesc));
    
    	// Setup the render target texture description.
    	textureDesc.Width = m_iBufferSize;
    	textureDesc.Height = m_iBufferSize;
    	textureDesc.MipLevels = 1;
    	textureDesc.ArraySize = MAX_CASCADES;
    	textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
    	textureDesc.SampleDesc.Count = 1;
    	textureDesc.SampleDesc.Quality = 0;
    	textureDesc.Usage = D3D11_USAGE_DEFAULT;
    	textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
    	textureDesc.CPUAccessFlags = 0;
    
    	ID3D11Device *pDevice = __GetD3D11Device();
    
    	HRESULT hr = S_OK;
    	if(pRenderingEngine->GetMSAACount() > 1)
    	{
    		hr = pDevice->CreateTexture2D(&textureDesc, NULL, &m_pCopyResolveTexture);
    		__TestD3D11HRESULT(hr);
    		hr = pDevice->CreateShaderResourceView( m_pCopyResolveTexture, nullptr, &m_pCopyResolveTextureSRV);
    		__TestD3D11HRESULT(hr);
    	}
    
    	textureDesc.SampleDesc.Count = pRenderingEngine->GetMSAACount();
    	textureDesc.SampleDesc.Quality = pRenderingEngine->GetMSAAQuality(textureDesc.SampleDesc.Count, textureDesc.Format);
    
    	// Create the render target texture.
    	hr = pDevice->CreateTexture2D(&textureDesc, NULL, &m_pRenderTargetTexture);
    	__TestD3D11HRESULT(hr);
    	
    	// Create the shader resource view.
    	hr = pDevice->CreateShaderResourceView(m_pRenderTargetTexture, nullptr, &m_pSRV);
    	__TestD3D11HRESULT(hr);






    • Edited by Anveena Sunday, September 29, 2013 8:49 AM
    Saturday, September 28, 2013 7:58 PM

Answers