Real-time 3D terrain engines using C ++ and DX9 translation 6

Source: Internet
Author: User

Index cache and vertex Cache
Index cache and vertex cache resources are frequently used in the example engine and are useful as independent resources. For most of the data in our engine, it is our basic requirement to retain them when traditional models do not provide indexes and vertex caches and then overwrite the entire model at some point. Indexing and vertex caching are especially useful for dynamic data. When using devices to rely on resources, they must be processed with caution. Using the dynamic vertex and index cache enables us to create a ry or animation of an existing object on the CPU at any time. We use these two methods when building a terrain engine.
To clarify, what we call dynamic means completely replacement. Locking a vertex or index cache to change some random values will result in poor performance that is staggered on most graphics cards. Therefore, these resources are not supported in our interfaces. In our engine, we replace the entire dynamic cache every time we need to update it. This allows the driver to maintain a single-direction dynamic data. Once the data is transferred back to the video card, it will not try to read the data into the system memory to update some special values.
Class objects cvertexbuffer and cindexbuffer provide the basic operations required by our cache. These objects also contain our regular cache and dynamic cache. To support dynamic (can be considered as a replacement) caching of data, we use the best method recognized by nvidia and Microsoft to update dynamic data.
This function uses a super large cache to store dynamic data. For example, if your dynamic data is composed of 10 vertices, you will create a dynamic cache that can hold 100 data. With this large space, you can use only 10 vertex data at a time. In the first frame, you use vertex 0 ~ 9. Index 10 ~ 19 is used in the second frame and continues. When you use all the space, the entire cached content will be destroyed and processed from vertex 0. This sliding window scheme is considered friendly because it can interrupt the most direct memory access (DMA) operations. Listing 4.5 shows how to use Algorithm Pseudo code.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.