[GPU programming] asynchronous data transmission based on the volume rendering acceleration technology

Source: Internet
Author: User

First, we will introduce the cache hierarchies on mainstream GPUs:


Level 1 cache: Local Texture Cache

Level 2 Cache: local video memory

Level 3 cache: AGP memory

Texture data, preferably the closer to the GPU: Level 1 or Level 2 cache. VBO and PbO in OpenGL adopt a flexible mechanism to solve this problem. However, the closer the data is to the GPU, the more difficult the CPU is to access the data. In this way, if the CPU needs to change the data frequently, it is best to store the data in the third-level cache. If the data rarely changes, it is best to have a second-level cache. The GPU's internal texture cache (internal texture cache) is automatically managed by the GPU, and there are no APIs for operating data stored in the first level of cache. However, there are also some mechanisms to ensure that the texture cache is effectively used.


Asynchronous Data TransmissionData transmission is allowed without the involvement of the CPU. For example, the CPU can continue to complete other tasks during data transmission. After the CPU starts the transfer operation, the DMA controller completes the transfer operation.

If the body data is large and cannot be fully stored in the GPU memory space, the data block needs to be reloaded to the GPU memory during rendering. To achieve optimal performance during the loading process, data blocks need to be stored in the primary storage in some way so that they can be transmitted to the GPU as continuous blocks.

When the command gltexsubimage3d () is used for texture data transmission, the CPU copies the data until all the data is transmitted to the GPU. As a result, all subsequent OpenGL commands are stopped. In OpenGL, PbO (Pixel Buffer object) allows the DMA method to asynchronously transmit data to the GPU, so that the CPU will not stop other tasks during data transmission. However, the premise is that the data must be stored in the AGP memory in the internal format required by the GPU.

PbO Introduction Reference: PbO (Pixel Buffer object)

For more information about AGP memory, see

However, some graphics cards use a rescheduled internal format to store 3D textures to increase the locality of adjacent data. This causes the CPU to reschedule the data format in the master memory before loading the data block to the GPU. One possible solution to this problem is to store data in the GPU internal format in the main memory, and then notify the driver that the data is ready in the required format. However, there is no official OpenGL mechanism that supports this function currently.

Npot (non-power-of-two) textures are integers whose dimensions are not the power of 2 and do not need to be rescheduled before being loaded to the GPU. Therefore, npot textures can asynchronously transmit data with bandwidth close to the theoretical limit.

For more information about npot texture, see npot texture.

Note that this npot texture should be relatively small, so that it will not be caused by different performance from the perspective. We recommend that you use near 64*64*64 body data, such as 64*64*63.


The following is an example of code that uses asynchronous transmission to add carrier data. Data is the data read from a raw data file.

        //asynchronous data upload : using PBOGLuint texBuffer;//create and bind texture image buffer objectglGenBuffers(1,&texBuffer);glBindBuffer(GL_PIXEL_UNPACK_BUFFER,texBuffer);glBufferData(GL_PIXEL_UNPACK_BUFFER,size,NULL,GL_STREAM_DRAW);//map the texture image buffervoid *pboMemory = glMapBuffer(GL_PIXEL_UNPACK_BUFFER,GL_WRITE_ONLY);memcpy(pboMemory,data,size);if (!glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER)){cout << "ERROR : Unmap PBO failed" << endl;exit(1);}glTexImage3D(GL_TEXTURE_3D, 0, GL_INTENSITY, WIDTH, HEIGHT, DEPTH, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE,BUFFER_OFFSET(0));

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.