I'm rendering textured quads to an orthographic view in XNA through hardware instancing. On Nvidia graphics cards, this all works, tested on 3 machines. On ATI cards, it doesn't work at all, tested on 2 machines.
How come? Culling perhaps?
My orthographic view is set up like this:
Matrix projection = Matrix.CreateOrthographicOffCenter(0, graphicsDevice.Viewport.Width, -graphicsDevice.Viewport.Height, 0, 0, 1);
And my elements are rendered with the Z-coordinate 0.
Edit:
I just figured out something weird.
If I do not call this spritebatch code above doing my textured quad rendering code, then it won't work on Nvidia cards either. Could that be due to culling information or something like that?
Batch.Instance.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
...
spriteBatch.End();
Edit 2:
Here's the full code for my instancing call.
public void DrawTextures()
{
Batch.Instance.SpriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, textureEffect);
while (texturesToDraw.Count > 0)
{
TextureJob texture = texturesToDraw.Dequeue();
spriteBatch.Draw(texture.Texture, texture.DestinationRectangle, texture.TintingColor);
}
spriteBatch.End();
#if !NOTEXTUREINSTANCING
// no work to do
if (positionInBufferTextured > 0)
{
device.BlendState = BlendState.Opaque;
textureEffect.CurrentTechnique = textureEffect.Techniques["Technique1"];
textureEffect.Parameters["Texture"].SetValue(darkTexture);
textureEffect.CurrentTechnique.Passes[0].Apply();
if ((textureInstanceBuffer == null) ||
(positionInBufferTextured > textureInstanceBuffer.VertexCount))
{
if (textureInstanceBuffer != null)
textureInstanceBuffer.Dispose();
textureInstanceBuffer = new DynamicVertexBuffer(device, texturedInstanceVertexDeclaration, positionInBufferTextured, BufferUsage.WriteOnly);
}
if (positionInBufferTextured > 0)
{
textureInstanceBuffer.SetData(texturedInstances, 0, positionInBufferTextured, SetDataOptions.Discard);
}
device.Indices = textureIndexBuffer;
device.SetVertexBuffers(textureGeometryBuffer, new VertexBufferBinding(textureInstanceBuffer, 0, 1));
device.DrawInstancedPrimitives(PrimitiveType.TriangleStrip, 0, 0, textureGeometryBuffer.VertexCount, 0, 2, positionInBufferTextured);
// now that we've drawn, it's ok to reset positionInBuffer back to zero,
// and write over any vertices that may have been set previously.
positionInBufferTextured = 0;
}
#endif
}