Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 22 Nov 2011
Offline Last Active Apr 20 2015 12:50 AM

Topics I've Started

How to use geometry shader instances to divide the output data?

16 March 2015 - 07:47 PM

In geometry shader, I want to output about 108 vertices from 3 vertices (a triangle), and each output vertex has 12 scalar values. For example

struct VS_OUTPUT
     float4 Pos;
     float2 TextureUV;
     float3 Normal;
     float3 Data;

The problem is I cannot output all vertices because of the limitation of geometry shader output which does not allow output more than 1024 registers. Is there possible to use 2 instances of a geometry shader to solve this problem such as the first instance outputs the half of data and the second one outputs the other half?. I have searched on the internet, but there is nothing and have tried it but it does not work.


For example

GS_OUTPUT GS(triangle VS_OUTPUT input[3], inout TriangleStream<GS_OUTPUT> Output,
	      uint InstanceID : SV_GSInstanceID)
       GS_OUTPUT vertex;
       if (InstanceID == 0)
             vertex.Pos = ....
             vertex.TextureUV = ........
       else // InstanceID = 1
             vertex.Normal = ....
             vertex.Data = .....

       // Output data

Why is a result different with output value in hlsl?

30 November 2014 - 09:17 PM

I am trying to debug but there is a problem with output value. The problem is the result I got is different with output value. For instance, the output value is float4(0.75, 0.5, 0, 1), so the result must be (191, 128, 0, 1), but the result is (225, 188, 0, 1). Is there anybody experienced this problem? Please help me.

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