Jump to content
  • Advertisement
Sign in to follow this  
PatrizioTamorri

Buffer Problem

This topic is 2638 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have a buffer that's created like this



D3D11_BUFFER_DESC DescTest;
DescTest.Usage = D3D11_USAGE_DYNAMIC;
DescTest.BindFlags = D3D11_BIND_SHADER_RESOURCE ;
DescTest.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
DescTest.MiscFlags = 0;
DescTest.ByteWidth = 4000 * 5;
DescTest.StructureByteStride = sizeof(float) * 4;
g_pd3dDevice->CreateBuffer( &DescTest, NULL, &Matrix_Buffer );
//create the buffer and the views for association
D3D11_BUFFER_SRV srvBTest;
srvBTest.ElementOffset = 0;
srvBTest.ElementWidth = 4000 ;
// create a Resource View and attach the Buffer to it
D3D11_SHADER_RESOURCE_VIEW_DESC srvDescTest;
srvDescTest.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
srvDescTest.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
srvDescTest.Buffer = srvBTest;
g_pd3dDevice->CreateShaderResourceView( Matrix_Buffer, &srvDescTest, &Matrix_Buffer_SV0 );
srvBTest.ElementOffset = 4000;
srvBTest.ElementWidth = 4000 ;
// create a Resource View and attach the Buffer to it
srvDescTest.Buffer = srvBTest;
g_pd3dDevice->CreateShaderResourceView( Matrix_Buffer, &srvDescTest, &Matrix_Buffer_SV1 );
srvBTest.ElementOffset = 8000;
srvBTest.ElementWidth = 4000 ;
// create a Resource View and attach the Buffer to it
srvDescTest.Buffer = srvBTest;
g_pd3dDevice->CreateShaderResourceView( Matrix_Buffer, &srvDescTest, &Matrix_Buffer_SV2 );
srvBTest.ElementOffset = 12000;
srvBTest.ElementWidth = 4000 ;
// create a Resource View and attach the Buffer to it
srvDescTest.Buffer = srvBTest;
g_pd3dDevice->CreateShaderResourceView( Matrix_Buffer, &srvDescTest, &Matrix_Buffer_SV3 );
srvBTest.ElementOffset = 16000;
srvBTest.ElementWidth = 4000 ;
// create a Resource View and attach the Buffer to it
srvDescTest.Buffer = srvBTest;
g_pd3dDevice->CreateShaderResourceView( Matrix_Buffer, &srvDescTest, &Matrix_Buffer_SV4 );




to write datas in the buffer i call this



D3D11_MAPPED_SUBRESOURCE ms;
HRESULT hr = g_pImmediateContext->Map(Buffer,0,D3D11_MAP_WRITE_DISCARD,0,&ms );
memcpy(ms.pData,data,size);
g_pImmediateContext->Unmap(Buffer,0);




and i set up things using



g_pImmediateContext->VSSetShaderResources(0,1,&Matrix_Buffer_SV0);
g_pImmediateContext->VSSetShaderResources(1,1,&Matrix_Buffer_SV1);
g_pImmediateContext->VSSetShaderResources(2,1,&Matrix_Buffer_SV2);
g_pImmediateContext->VSSetShaderResources(3,1,&Matrix_Buffer_SV3);
g_pImmediateContext->VSSetShaderResources(4,1,&Matrix_Buffer_SV4);



and in PIX seems like the datas are written correctly after the unmap (datas are visible and i can see using my debugger that all my matrices are ready to go)

in the hlsl i have this



Buffer<float4> Buffer0 : register( c0 );
Buffer<float4> Buffer1 : register( c1 );
Buffer<float4> Buffer2 : register( c2 );
Buffer<float4> Buffer3 : register( c3 );
Buffer<float4> Buffer4 : register( c4 );



and i load the values like this



pos = Number_Matrix_To_Read * 4;

float4 f1 = Buffer0.Load( pos );
float4 f2 = Buffer0.Load( pos + 1 );
float4 f3 = Buffer0.Load( pos + 2 );
float4 f4 = Buffer0.Load( pos + 3 );

float4x4 matrix = float4x4(f1,f2,f3,f4);



the problem is that it always return 0 as the matrix and i can't understand why...

seems like a problem with inizialization

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!