Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is there a way to determine, or preferably calculate/predict, the the stride of a line of a DirectX 11 Texture2D resource when using SharpDX?

(E.g. Can we say the stride of a line is always a power of 2?)

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

I don't know in which case you would like to do this, though I have two cases in mind:

  1. If you are creating a Texture2D with an initial DataRectangle, the Pitch must be set to the number of bytes per row and is theoretically equal to TextureWidth * SharpDX.DXGI.FormatHelper.SizeOfInBytes(Format.XXX), unless you are laying out your data differently in memory.
  2. If your are using DeviceContext.MapSubresource, you can't determine in advance what would be the stride and you need to use the Pitch returned by the DataBox.RowPitch. The stride could be hardware dependent, depending on the layout on the GPU memory.
share|improve this answer
    
This is for updating the content of textures where the stride is not equivalent (due to the size) to the TextureWidth * TexelSize, so RowPitch is what I need - Thank you! –  sebf Jan 16 '12 at 9:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.