Jump to content
  • Advertisement
Sign in to follow this  

Using a Buffer as a shader variable

This topic is 3033 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

The idea is to use Stream Out to get certain vertex information, then pass that back into another technique as a Buffer variable. I'm doing the exact same thing as in the Skinning10 sample, yet I keep getting annoying errors.

D3D10: ERROR: ID3D10Device::CreateShaderResourceView: A ShaderResourceView cannot be created of a Resource that did not specify the D3D10_BIND_SHADER_RESOURCE BindFlag. [ STATE_CREATION ERROR #129: CREATESHADERRESOURCEVIEW_INVALIDRESOURCE ]
D3D10: ERROR: ID3D10Device::CreateShaderResourceView: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #131: CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN ]
D3D10: ERROR: ID3D10Buffer::Map: Map cannot be called with MAP_WRITE_DISCARD access, because the Resource was not created with the D3D10_CPU_ACCESS_WRITE flag. [ RESOURCE_MANIPULATION ERROR #295: BUFFER_MAP_INVALIDMAPTYPE ]

This is my code
		m_Buffers[tile] = m_pStreamOutBuffer;
m_pStreamOutBuffer = NULL;
pBuffers[0] = NULL;

// Turn off stream out
GETD3D10DEVICE->SOSetTargets( 1, pBuffers, offsets );

ID3D10ShaderResourceView* g_pBoneBufferRV = NULL;
// Again, we need a resource view to use it in the shader
ZeroMemory( &SRVDesc, sizeof( SRVDesc ) );
SRVDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
SRVDesc.Buffer.ElementOffset = 0;
SRVDesc.Buffer.ElementWidth = 255 * 4; // Same value as Skinning10 sample
GETD3D10DEVICE->CreateShaderResourceView( m_Buffers[tile], &SRVDesc, &g_pBoneBufferRV ) ;
m_BufferResources[tile] = g_pBoneBufferRV;

m_Buffers[tile]->Map( D3D10_MAP_WRITE_DISCARD, 0, (void**) &m_Buffers[tile] );
//m_Buffers[tile]->Map( D3D10_MAP_WRITE_DISCARD, 0, ( void** )&pMatrices ) ; // from sample


My geometry shader stream out is 2 float3s.
Buffer<float3> g_MeshBuffer;
GeometryShader gsStreamOut = ConstructGSWithSO( CompileShader( gs_4_0, gs_GeometryStreamOut() ), "POSITION.xyz; NORMAL.xyz" );

I already tried editing certain values like the errors suggest but it still keeps giving the same errors. Why does this work in the sample but not here?
What am I doing wrong??

Thanks in advance.

Share this post

Link to post
Share on other sites
When you create the buffer resource, it must have the D3D10_BIND_SHADER_RESOURCE and the D3D10_BIND_STREAM_OUTPUT bind flags set if you want to bind them in those locations. Once you a create the resource with these, try it out again and repost what else isn't working properly and we can work on it from there.

Share this post

Link to post
Share on other sites
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!