简体   繁体   中英

DirectX11 IASetVertexBuffers with nullptrs or empty buffers

我想对管道进行结构设计,以便每个网格都只能设置位置,法线等元素,并且由于某些网格无法全部包含它们,而某些着色器也不需要全部,所以我希望每个网格都具有属性在不同的缓冲区中,现在我不知道为每个缓冲区设置索引x上的此1个缓冲区调用SetBuffers还是更好,或者有可能一次将所有缓冲区设置为一个数组,但是有些将为null(我想保留插槽号)

IASetVertexBuffers allows you to specify a set of buffers in one call:

ID3D11DeviceContext* Context; // Initialized at creation
ID3D11Buffer* buffers[] = /* Initialized to a set of buffers, unused buffers set to null. */;
UINT Strides[] = /* Initialized to the size of each element in each buffer. */;
UINT Offsets[] = /* Initialized to the offset into each buffer, typically all zeros. */; 
Context->IASetVertexBuffers(0, ARRAYSIZE(buffers), buffers, Strides, Offsets);

See the documentation for more information about each parameter.

Note that this requires your input layouts for all your shaders to match all the meshes that can exist in your pipeline, which could complicate things if you have a shader that requires more parameters than the mesh provides. I'm not exactly certain what DirectX/the GPU will do when presented a null pointer on a required parameter, but I wouldn't assume it'd be good.

The easier option here would be to provide explicit default values for each mesh in the pipeline when the attributes are required but not provided by the source. This way, there's no issue with missing values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM