Answered by:
problem with SRV when I using ID3D11Texture2d with NV12_FORMAT

Question
-
Hi!
I use a texture2D with NV12 format:
D3D11_TEXTURE2D_DESC desc; ZeroMemory( &desc, sizeof(desc) ); desc.Width = 1920; desc.Height = 1088; desc.MipLevels = 1; desc.ArraySize = 1; desc.Format = DXGI_FORMAT_NV12; desc.SampleDesc.Count = 1; desc.Usage = D3D11_USAGE_DEFAULT; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; pRenderTarget = NULL; m_pD3D11Device->CreateTexture2D( &desc, NULL, &pRenderTarget );
And i create two shader ressource view with format R8_UNORM and R8G8_UNORM :
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; srvDesc.Format=DXGI_FORMAT_R8_UNORM; srvDesc.ViewDimension=D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2DArray.MostDetailedMip=0; srvDesc.Texture2DArray.MipLevels=1; m_pD3D11Device->CreateShaderResourceView(pRenderTarget,&srvDesc,&m_textureRV); srvDesc.Format=DXGI_FORMAT_R8G8_UNORM; m_pD3D11Device->CreateShaderResourceView(pRenderTarget,&srvDesc,&m_textureRV1);
But i dont know display luminance and chrominance. My hlsl file :
Texture2D colorMap_ : register( t0 ); Texture2D colorMap1_ : register( t1 ); SamplerState colorSampler_ : register( s0 ); struct VS_Input { float4 pos : POSITION; float2 tex0 : TEXCOORD0; }; struct PS_Input { float4 pos : SV_POSITION; float2 tex0 : TEXCOORD0; }; PS_Input VS_Main( VS_Input vertex ) { PS_Input vsOut = ( PS_Input )0; vsOut.pos = vertex.pos; vsOut.tex0 = vertex.tex0; return vsOut; } float4 PS_Main( PS_Input frag ) : SV_TARGET { return colorMap_.Sample( colorSampler_, frag.tex0 )*colorMap1_.Sample( colorSampler_, frag.tex0); }
And my instruction for the srv :
m_pD3D11Ctx->PSSetShaderResources(0, 1, &m_textureRV); m_pD3D11Ctx->PSSetShaderResources(1,1, &m_textureRV1);
- Edited by pizani1 Wednesday, May 15, 2013 1:31 PM
Wednesday, May 15, 2013 1:30 PM
Answers
-
You just do multiple texture look-ups in the pixel shader to get the Y and UV values all at once.
- Marked as answer by Jesse JiangModerator Wednesday, May 22, 2013 6:30 AM
Friday, May 17, 2013 8:01 PM
All replies
-
What are you trying to display exactly? Direct3D 11 will not directly output YUV data. Your shader has to convert it to RGB in some fashion...Wednesday, May 15, 2013 11:01 PM
-
Yeah I can convert it but only the chrominance and luminance. When I see this :
DXGI_FORMAT_NV12
Most common YUV 4:2:0 video resource format. Valid luminance data view formats for this video resource format are DXGI_FORMAT_R8_UNORM and DXGI_FORMAT_R8_UINT. Valid chrominance data view formats (width and height are each 1/2 of luminance view) for this video resource format are DXGI_FORMAT_R8G8_UNORM and DXGI_FORMAT_R8G8_UINT. Supported view types are SRV, RTV, and UAV. For luminance data view, the mapping to the view channel is Y->R8. For chrominance data view, the mapping to the view channel is U->R8 and V->G8.
I have chrominance and luminance with 2 shader( DXGI_FORMAT_R8_UNORM and DXGI_FORMAT_R8G8_UNORM ) but i can't find how to meet to show my image YUV. I can show separately the luminance and chrominance.
- Edited by pizani1 Thursday, May 16, 2013 1:36 PM
Thursday, May 16, 2013 7:06 AM -
You just do multiple texture look-ups in the pixel shader to get the Y and UV values all at once.
- Marked as answer by Jesse JiangModerator Wednesday, May 22, 2013 6:30 AM
Friday, May 17, 2013 8:01 PM