PrimitiveBatch max vertex size?

Dec 19, 2012 at 4: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?

Coordinator
Dec 19, 2012 at 6:35 PM
Edited Dec 19, 2012 at 6: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.

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876(v=vs.85).aspx

 

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 7:39 PM
In article <CO1MSFTVADM02xc1o8y00000027@discussions.codeplex.com>,
"walbourn" <notifications@codeplex.com> writes:

> http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876(v=vs.85).
> 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 <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Coordinator
Dec 19, 2012 at 8:21 PM
Edited Dec 19, 2012 at 8: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