Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 22 Nov 2011
Offline Last Active Jun 12 2014 08:04 PM

Topics I've Started

Rotate around model's axes

14 May 2014 - 11:55 PM

I want to rotate around model's y-axis, but I do not know how to do it. There is a same topic but I do not completely understand and it is closed. There is a function name D3DXMatrixRotationAxis in DX, but the problem is how to set the vector value, to rotate around, after loading a model.

Cannot save values into fragment using unordered access view buffer

27 March 2014 - 08:22 AM

I am trying to modify a value before saving a fragment into an UAV but it does not work.


HLSL source code

struct FragmentData
     uint ID;

struct FragmentLink
     FragmentData Data;
     uint nNext;

float4 PS(ScenePS_Input input) : SV_TARGET
     uint x = input.Position.x;        // [0,g_nFrameWidth]
     uint y = input.Position.y;        // [0,g_nFrameHeight]

     // Create fragment data.
     FragmentLink element;
     element.fragmentData.ID = 5;

     // Increment and get current pixel count.
    uint nPixelCount= FLBuffer.IncrementCounter();

    // Read and update Start Offset Buffer.
    uint nIndex = y * g_nFrameWidth + x;
    uint nStartOffsetAddress = 4 * nIndex;
    uint nOldStartOffset;
        nStartOffsetAddress, nPixelCount, nOldStartOffset );

    // Store fragment link.
    element.nNext = nOldStartOffset;
    FLBuffer[ nPixelCount ] = element;

    return float4(1.0f, 0.0f, 0.0f, 1.0f);

In main source code, 

        HRESULT hr;
        ID3D11Buffer* pDebugBuf = CreateAndCopyToDebugBuf( pDevice, pD3DContext, pFragmentLink );
        D3D11_MAPPED_SUBRESOURCE MappedResource;     
        V( pD3DContext->Map( pDebugBuf, 0, D3D11_MAP_READ, 0, &MappedResource ) );
        FragmentLink* pData = reinterpret_cast< FragmentLink* >( MappedResource.pData );
        int nSize = pBackBufferDesc->Width * pBackBufferDesc->Height * 8;
        for( int i=0; i<nSize; ++i ) 	
            FragmentLink data = pData[ i ];
            if( data.nNext == 0xFFFFFFFF ) {
                int nBreak = 0;
	        if (data.fragmentData.ID != 5)				
		    int a = 1;
        pD3DContext->Unmap( pDebugBuf, 0 );
        SAFE_RELEASE( pDebugBuf ); 

there are some fragments' ID are 0, the rest are 5. I do not understand the reason why fragments' ID are 0. Is there anybody experience this problem before? Help me, please. Thanks.

Problem with mapping a constant buffer resource

16 March 2014 - 09:12 PM

I am implementing for my paper. However, there is a vague problem which I do not know exact reason. As debugging, the windows is frozen for a while, then goes black and it stops at code which mapping a constant buffer. The constant buffer is not null, but it is data is null after mapping.

        D3D11_MAPPED_SUBRESOURCE MappedResource3;  
	HR( gpImmediateContext->Map( mCBPS_ID, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource3 ) );
	PS_CB_ID* pPSID = ( PS_CB_ID* )MappedResource3.pData;

	char DebugString[100];
	sprintf_s(DebugString,"ID_constant buffer is: %p\n", mCBPS_ID);
	pPSID->g_iID = 0; // pPSID is null

	gpImmediateContext->Unmap( mCBPS_ID, 0 );	    
	gpImmediateContext->PSSetConstantBuffers( 3, 1, &mCBPS_ID );

Have anybody experienced this problem before? Please, help me. Thanks in advanced

Is there possible to use dynamic index in shader model 5.0?

14 November 2013 - 08:33 PM

I have an array of textures in the shader such as Texture2D pTextures[30], and I want to use a dynamic index instead of a specified index. Is there possible to do such thing? and how to do it?.


For example:


Use pTextures[ID] with ID is computed at runtime, instead of pTextures[x] with x is a specified value.

How to load a texture in ppm format in DX11?

01 September 2013 - 07:33 PM

I am trying to load mesh in obj format in DX11, and there is a problem with loading ppm texture. I have tried to use D3DX11CreateShaderResourceViewFromFile function to load but it failed. Is there anybody knows how to solve it?


Please, help me. Thanks