Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualHodgman

Posted 24 November 2012 - 11:23 PM

AFAIK (someone correct me if I'm wrong here), the order of your attributes in your "VSInput" struct doesn't have to match up with the order of your attributes in memory.
e.g. in memory, you could have pos, then a, then b. Or, you could have pos and b in one buffer, and a in another buffer.

If your structure was a cbuffer, then yes, the in-memory layout would have to match the HLSL layout. However, HLSL vertex structures are different -- they don't actually exist in memory, they're created at the start of execution of the vertex shader by the "Input Assembler", which reads all the attributes out of the vertex streams.

The "input layout" object is the glue that tells the Input Assembler how to read values out of memory and assemble them into an instance of this structure. When you create an input layout, each element specifies it's layout in memory (which stream, what offset into the stream, what format), and it's location in the HLSL vertex structure (semantic name+index).

I had someting else in mind - what HLSL types are allowed in the Shader code. So - can I have 'float4' in the input struct? Yes as far as I know. Can I have a 'sampler'? Probably not. Some specification that can answer this questions is what I'm looking for.

You can have any type that can be mapped to one of the formats in the "Input assembler vertex buffer resources" I linked to.
e.g. DXGI_FORMAT_R32G32B32A32_FLOAT can represent a float4, but there is no format in the list that can represent a sampler.

#1Hodgman

Posted 24 November 2012 - 11:16 PM

AFAIK (someone correct me if I'm wrong here), the order of your attributes in your "VSInput" struct doesn't have to match up with the order of your attributes in memory.
e.g. in memory, you could have pos, then a, then b. Or, you could have pos and b in one buffer, and a in another buffer.

If your structure was a cbuffer, then yes, the in-memory layout would have to match the HLSL layout. However, HLSL vertex structures are different -- they don't actually exist in memory, they're created at the start of execution of the vertex shader by the "Input Assembler", which reads all the attributes out of the vertex streams.

The "input layout" object is the glue that tells the Input Assembler how to read values out of memory and assemble them into an instance of this structure. When you create an input layout, each element specifies it's layout in memory (which stream, what offset into the stream, what format), and it's location in the HLSL vertex structure (semantic name+index)

PARTNERS