ybatra

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

155 Neutral

About ybatra

  • Rank
    Member
  1. http://msdn.microsoft.com/en-us/library/windows/desktop/bb509647(v=vs.85).aspx#VS | Read this document carefully. Passing data between graphics pipeline stages is well defined. 
  2. even I disabled the Z testing, still I was getting the same results.
  3. I tried rendering some geometry on to the back buffer, with enabling Z testing. but I found that "ClearRenderTargetView()" is clearing the render target(Backbuffer), but draw call was not successful. I meant primitives are not drawing onto the backbuffer.  
  4. // Initialize D3D bool D3DRenderer::Initialize() { HRESULT hr; D3D_DRIVER_TYPE m_pDriverType; D3D_FEATURE_LEVEL       m_pFeatureLevel;   D3D_DRIVER_TYPE driverTypes[] =     {         D3D_DRIVER_TYPE_HARDWARE,         D3D_DRIVER_TYPE_WARP,         D3D_DRIVER_TYPE_REFERENCE,     }; UINT numDriverTypes = ARRAYSIZE( driverTypes );   // Create the D3D device     D3D_FEATURE_LEVEL featureLevel[]=  { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0, }; int num= ARRAYSIZE(featureLevel);       // Create device, context and swapchain     DXGI_SWAP_CHAIN_DESC sdDesc;     ZeroMemory(&sdDesc, sizeof(sdDesc)); sdDesc.BufferDesc.ScanlineOrdering=DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; sdDesc.BufferDesc.Scaling=DXGI_MODE_SCALING_UNSPECIFIED; sdDesc.BufferDesc.RefreshRate.Numerator   = 60;     sdDesc.BufferDesc.RefreshRate.Denominator = 1; sdDesc.BufferDesc.Width                   = m_pWindow->GetWidth();     sdDesc.BufferDesc.Height                  = m_pWindow->GetHeight();     sdDesc.BufferDesc.Format                  = DXGI_FORMAT_R8G8B8A8_UNORM;     sdDesc.BufferCount                        = 1; sdDesc.BufferUsage                        = DXGI_USAGE_RENDER_TARGET_OUTPUT;     sdDesc.SampleDesc.Count                   = 1;     sdDesc.SampleDesc.Quality                 = 0;     sdDesc.OutputWindow                       = m_pWindow->GetHwnd();     sdDesc.Windowed                           = TRUE;      for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )     {         m_pDriverType = driverTypes[driverTypeIndex]; hr = D3D11CreateDeviceAndSwapChain( NULL, m_pDriverType, NULL, NULL, featureLevel, num, D3D11_SDK_VERSION, &sdDesc, &m_pSwapChain, &m_pDevice, &m_pFeatureLevel, &m_pDeviceContext );         if( SUCCEEDED( hr ) )             break;     } if(FAILED(hr)) return FALSE;       // Make and set D3D11 render target objects     hr = m_pSwapChain->GetBuffer(0, __uuidof(*m_pRTTexture2D), reinterpret_cast<void**>(&m_pRTTexture2D));     CHECK_FAILURE(hr, "Could not create render target texture.");       hr = m_pDevice->CreateRenderTargetView(m_pRTTexture2D, NULL, &m_pRTView);     CHECK_FAILURE(hr, "Could not create render target view.");         // Make and set depth stencil     D3D11_TEXTURE2D_DESC dsTexDesc; ZeroMemory(&dsTexDesc, sizeof(dsTexDesc));     dsTexDesc.Width              = m_pWindow->GetWidth();     dsTexDesc.Height             = m_pWindow->GetHeight();     dsTexDesc.MipLevels          = 1;     dsTexDesc.ArraySize          = 1;     dsTexDesc.Format             = DXGI_FORMAT_D32_FLOAT;     dsTexDesc.SampleDesc.Count   = 1;     dsTexDesc.SampleDesc.Quality = 0;     dsTexDesc.Usage              = D3D11_USAGE_DEFAULT;     dsTexDesc.BindFlags          = D3D11_BIND_DEPTH_STENCIL;     dsTexDesc.CPUAccessFlags     = 0;     dsTexDesc.MiscFlags          = 0;     hr = m_pDevice->CreateTexture2D(&dsTexDesc, NULL, &m_pDSTexture2D);     CHECK_FAILURE(hr, "Could not create depth stencil texture.");   hr = m_pDevice->CreateDepthStencilView(m_pDSTexture2D, NULL, &m_pDSView);     CHECK_FAILURE(hr, "Could not create depth stencil view.");   m_pDeviceContext->OMSetRenderTargets(1, &m_pRTView, m_pDSView);   // Set depth stencil state     D3D11_DEPTH_STENCIL_DESC depthStencilDesc; ZeroMemory(&depthStencilDesc, sizeof(depthStencilDesc)); depthStencilDesc.DepthEnable                  = TRUE;     depthStencilDesc.DepthWriteMask               = D3D11_DEPTH_WRITE_MASK_ALL;     depthStencilDesc.DepthFunc                    = D3D11_COMPARISON_ALWAYS;     depthStencilDesc.StencilEnable                = FALSE;     hr = m_pDevice->CreateDepthStencilState(&depthStencilDesc, &m_pDSState);     CHECK_FAILURE(hr, "Could not create depth stencil state.");     m_pDeviceContext->OMSetDepthStencilState(m_pDSState,0);       // Setup the viewport     D3D11_VIEWPORT vp; ZeroMemory(&vp, sizeof(vp));     vp.Width = m_pWindow->GetWidth();     vp.Height =m_pWindow->GetHeight();     vp.MinDepth = 0.0f;     vp.MaxDepth = 1.0f;     vp.TopLeftX = 0;     vp.TopLeftY = 0;     m_pDeviceContext->RSSetViewports( 1, &vp );   // Compile the vertex shader     ID3DBlob* pVSBlob = NULL;     hr = CompileShaderFromFile( L"Main.fx", "VS", "vs_4_0", &pVSBlob );     CHECK_FAILURE(hr, "Could not Compile Vertex Shader");   // Create the vertex shader hr = m_pDevice->CreateVertexShader( pVSBlob->GetBufferPointer(), pVSBlob->GetBufferSize(), NULL, &m_pVertexShader ); CHECK_FAILURE(hr, "Could not Create Vertex Shader");       // Define the input layout     D3D11_INPUT_ELEMENT_DESC layout[] =     {         { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },         { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },     };     UINT numElements = sizeof( layout ) / sizeof( layout[0] );       // Create the input layout hr = m_pDevice->CreateInputLayout( layout, numElements, pVSBlob->GetBufferPointer(),                                           pVSBlob->GetBufferSize(), &m_pVertexLayout ); pVSBlob->Release(); CHECK_FAILURE(hr, "Could not create ");       // Set the input layout     m_pDeviceContext->IASetInputLayout( m_pVertexLayout );   // Compile the pixel shader ID3DBlob* pPSBlob = NULL;     hr = CompileShaderFromFile( L"Main.fx", "PS", "ps_4_0", &pPSBlob );     CHECK_FAILURE(hr, "Could not Compile Pixel Shader");   // Create the pixel shader hr = m_pDevice->CreatePixelShader( pPSBlob->GetBufferPointer(), pPSBlob->GetBufferSize(), NULL, &m_pPixelShader); pPSBlob->Release();     CHECK_FAILURE(hr, "Could not create Pixel Shader");       // Create vertex buffer     SimpleVertex vertices[] =     { { XMFLOAT3( -1.0f, 1.0f, 0.0f ), XMFLOAT4( 1.0f, 0.0f, 0.0f, 1.0f ) },         { XMFLOAT3( 1.0f, 1.0f, 0.0f ), XMFLOAT4( 1.0f, 0.0f, 0.0f, 1.0f ) },         { XMFLOAT3( -1.0f,-1.0f, 1.0f ), XMFLOAT4( 1.0f, 0.0f, 0.0f, 1.0f ) },         { XMFLOAT3( -1.0f, -1.0f, 1.0f ), XMFLOAT4( 1.0f, 0.0f, 0.0f, 1.0f ) },         { XMFLOAT3( 1.0f, 1.0f, 0.0f ), XMFLOAT4( 1.0f, 0.0f, 0.0f, 1.0f ) },         { XMFLOAT3( 1.0f,-1.0f, 1.0f ), XMFLOAT4( 1.0f, 0.0f, 0.0f, 1.0f ) },           { XMFLOAT3( -1.0f, 1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ) },         { XMFLOAT3( 1.0f, 1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ) },         { XMFLOAT3( -1.0f,-1.0f, 1.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ) },         { XMFLOAT3( -1.0f, -1.0f, 1.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ) },         { XMFLOAT3( 1.0f, 1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 0.0f, 1.0f ) },         { XMFLOAT3( 1.0f,-1.0f, 1.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ) },     };       D3D11_BUFFER_DESC bd; ZeroMemory(&bd, sizeof(bd));     bd.Usage = D3D11_USAGE_DEFAULT;     bd.ByteWidth = sizeof( SimpleVertex ) *12;     bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;     bd.CPUAccessFlags = 0;     bd.MiscFlags = 0;       D3D11_SUBRESOURCE_DATA InitData;     InitData.pSysMem = vertices;     hr = m_pDevice->CreateBuffer( &bd, &InitData, &m_pVertexBuffer );     CHECK_FAILURE(hr, "Could not create Vertex Buffer.");       // Set vertex buffer     UINT stride = sizeof( SimpleVertex );     UINT offset = 0;     m_pDeviceContext->IASetVertexBuffers( 0, 1, &m_pVertexBuffer, &stride, &offset );       // Set primitive topology     m_pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);     D3D11_RASTERIZER_DESC RSdesc; ZeroMemory(&RSdesc, sizeof(RSdesc)); RSdesc.CullMode=D3D11_CULL_NONE; RSdesc.MultisampleEnable=FALSE; RSdesc.AntialiasedLineEnable=FALSE; RSdesc.DepthClipEnable=TRUE; RSdesc.FillMode=D3D11_FILL_SOLID; RSdesc.FrontCounterClockwise=FALSE; RSdesc.ScissorEnable=FALSE;   m_pDevice->CreateRasterizerState(&RSdesc, &m_pRasterStateNoCulling);   m_pDeviceContext->RSSetState(m_pRasterStateNoCulling);   //Create TExture for Staging resource     D3D11_TEXTURE2D_DESC descStaging; ZeroMemory(&descStaging, sizeof(descStaging));     descStaging.Width = m_pWindow->GetWidth();;     descStaging.Height= m_pWindow->GetHeight();;     descStaging.MipLevels = 1;     descStaging.ArraySize = 1;     descStaging.Format = DXGI_FORMAT_R8G8B8A8_UNORM;     descStaging.SampleDesc.Count = 1;     descStaging.SampleDesc.Quality = 0;     descStaging.Usage = D3D11_USAGE_STAGING;     descStaging.BindFlags = 0;     descStaging.CPUAccessFlags = D3D11_CPU_ACCESS_READ;     descStaging.MiscFlags = 0;     hr=m_pDevice->CreateTexture2D(&descStaging,NULL,&m_sRTTexture2D);     CHECK_FAILURE(hr, "Could not create texture for staging resource."); return true; }   //-------------------------------------------------------------------------------------- // Helper for compiling shaders with D3DX11 //-------------------------------------------------------------------------------------- HRESULT D3DRenderer::CompileShaderFromFile( WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut ) {     HRESULT hr = S_OK;       DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS; #if defined( DEBUG ) || defined( _DEBUG )     // Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.     // Setting this flag improves the shader debugging experience, but still allows      // the shaders to be optimized and to run exactly the way they will run in      // the release configuration of this program.     dwShaderFlags |= D3DCOMPILE_DEBUG; #endif       ID3DBlob* pErrorBlob;     hr = D3DCompileFromFile(szFileName, NULL, NULL, szEntryPoint, szShaderModel,          dwShaderFlags, 0, ppBlobOut, &pErrorBlob);     if( FAILED(hr) )     {         if( pErrorBlob != NULL )             OutputDebugStringA( (char*)pErrorBlob->GetBufferPointer() );         if( pErrorBlob ) pErrorBlob->Release();         return hr;     }     if( pErrorBlob ) pErrorBlob->Release();       return S_OK; } Run(TestCase* pTest) {     strcpy_s(m_lastError, "");     ClearRenderTargetView();     ClearDepthStencilView();       // Render before NVAPI test enabled m_pDeviceContext->VSSetShader( m_pVertexShader, NULL, 0 ); m_pDeviceContext->PSSetShader( m_pPixelShader, NULL, 0 );     m_pDeviceContext->Draw( 6, 0 ); }
  5. No I found the solution, it is failing because  D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX flag support feature level 10.1 and I have to create it using device1. 
  6. D3D10_TEXTURE2D_DESC desc; ZeroMemory( &desc, sizeof( desc ) ); desc.Width=width; desc.Height=height; desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM; desc.Usage=D3D10_USAGE_DEFAULT; desc.MipLevels=1; desc.ArraySize = 1; desc.SampleDesc.Count=1; desc.SampleDesc.Quality=0; desc.BindFlags=D3D10_BIND_RENDER_TARGET; desc.MiscFlags = D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX;   hr=g_pd3dDevice->CreateTexture2D( &desc, NULL, &g_pRenderTargetShared); if(FAILED(hr)) return FALSE; I'm trying to use above texture as shared resource but create texture call is unsuccessful to create shared texture. 
  7. thanks pierre1 and GuardianX. :)
  8. Hi, I'm trying to use D3DXMATRIX and D3DVECTOR3 in dx10 application, my current sdk is upgraded to WINDOWS sdk 8. Can anyone tell me what can be the alternative of these two structures in latest SDK?
  9. thanks, Yes I'm getting the expected results. 
  10. I meant both the surfaces S1 and S2 will have the same pixel values or not? 
  11. Hi all group members,  I'm a beginner in DIrectX and I have following doubt, hope I can get the answer at this group.  Let say Texture (T1) is an alias of render target surface (s1) and I have rendered a triangle on the RT surface( s1), I want to render texture's(T1) data onto a render target surface(S2) using texture lookup into pixel shader in second draw call. So in the end S1 and S2 should have same data or not?