This project has moved and is read-only. For the latest updates, please go here.

PrimitiveBatch max vertex size?

Dec 19, 2012 at 5:54 AM

Does the PrimitiveBatch have a max vertex size? I made a basic .obj importer and it is able to draw a cube and other objects successfully, but when I have it draw an object with 18960 vertices it crashes in this code block.

void Draw(D3D11_PRIMITIVE_TOPOLOGY topology, _In_reads_(vertexCount) TVertex const* vertices, size_t vertexCount)
            void* mappedVertices;

            PrimitiveBatchBase::Draw(topology, false, nullptr, 0, vertexCount, &mappedVertices);

            memcpy(mappedVertices, vertices, vertexCount * sizeof(TVertex));


Does the PrimitiveBatch have a size limitation for the number of vertices it can draw?

Dec 19, 2012 at 7:35 PM
Edited Dec 19, 2012 at 7:50 PM

Feature Level 9.1 only supports 16-bit indices, so it's limited to addressing 65535 vertices. Feature Level 9.1 is also limited to 65535 primitives.


The problem is likely that you used the default constructor which assumes a batch size of 2048. You should provide your own max indices and max vertices value:

PrimitiveBatch(_In_ ID3D11DeviceContext* deviceContext, size_t maxIndices = DefaultBatchSize * 3, size_t maxVertices = DefaultBatchSize)


Note that in general you should not be using PrimitiveBatch to draw meshes. Meshes are static and as such they should be using their own static VB/IBs rather than dynamic submission. PrimitiveBatch is really intended for things like terrain, complex CPU-based skinning, or debug geometry.


BTW, I'm updating the PrimitiveBatch doc page now

Dec 19, 2012 at 8:39 PM
In article <>,
"walbourn" <> writes:

> aspx The problem is likely that you used the default constructor which
> assumes a batch size of 2048.

Is this something that can assert on input arguments that exceed the
batch size in a debug build?
"The Direct3D Graphics Pipeline" free book <>
The Computer Graphics Museum <>
The Terminals Wiki <>
Legalize Adulthood! (my blog) <>
Dec 19, 2012 at 9:21 PM
Edited Dec 19, 2012 at 9:30 PM

An exception should've been thrown...  In fact, that might be the 'crash' he saw.

RKennedy9064 should make sure /EHsc is set for his application.

See How to: Break When an Exception is Thrown