1 / 21

CS179: GPU Programming

CS179: GPU Programming. Lecture 6: CUDA & Graphics. Today. CUDA and Graphics Textures Buffers. Graphics. Oftentimes a good candidate for parallelism …which is why the graphics card exists! Examples of large data in graphics: Image processing (operate per-pixel)

odina
Download Presentation

CS179: GPU Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS179: GPU Programming Lecture 6: CUDA & Graphics

  2. Today • CUDA and Graphics • Textures • Buffers

  3. Graphics • Oftentimes a good candidate for parallelism • …which is why the graphics card exists! • Examples of large data in graphics: • Image processing (operate per-pixel) • Mesh processing (operate per-vertex) • Simulation (operates per-element) • These translate well into CUDA problems: • Image processing: each thread handles a pixel • Mesh processing: each thread handles a vertex • Simulation: each thread handles an element

  4. Graphics • Image Processing

  5. Graphics • Mesh Processing

  6. Graphics • Simulation

  7. Textures • Storage format for graphics data • Efficient: stored in texture memory, not on CPU • Faster & bigger than arrays • Arrays a limited in memory -- usually a few kB • Textures can be much bigger • Can be 1D, 2D, or 3D

  8. Textures • Uses: • Mapping R3to R2 (mesh parameterization) • Color maps • Bump maps • Large data storage/manipulation • Render to texture • Image processing • General purpose data manipulation

  9. Textures • Color mapping

  10. Textures • Bump mapping

  11. Textures • Render to texture

  12. Textures • Image processing

  13. Buffers • Similar to textures • Basically just data storage • Buffers have more function-specific applications • Many different kinds: • Framebuffers • Vertex buffers • Renderbuffers, depth buffers, stencil buffers, etc.

  14. Buffers • Some buffer hints: • Read/write modes: • READ - read, no write • WRITE - write, no read • COPY - no write, no read • Access frequency modes • STATIC - set only once • DYNAMIC - occasional changes • STREAM - constant, or near constant changes

  15. Framebuffers • Used as a destination for rendering • OpenGL uses many of these for rendering to screen

  16. Render to Texture • Using framebuffers to manipulate textures • Idea: Render into texture data instead of frame • Texture can be drawn in scene now

  17. Render To Texture • Basic steps: • 1.) Create FBO • 2.) Attach other necessary buffers (depth buffer, render buffer) • 3.) Bind texture to FBO • 4.) Render object

  18. Render to Texture • RTT for image processing: • Load image into texture • Run processing algorithm on texture in CUDA • Output processed image • The catch: cannot read and write to same texture • Concurrency issues occur • Pingponging: solving this problem • Create 2 textures • Read from one, write into other • Swap when done to iterate

  19. Pingponging • Example tex1 tex2 tex1 tex2 read from 2 write into 1 read from 1 write into 2 read from 1 write into 2

  20. Vertex Buffers • Stores vertex data • Position, normal, color, etc. • Creates a faster way to render meshes • All data is now on GPU already • Lab 3 will see VBO’s for particle data

  21. Next Time • Lab 3 review • OpenGL, CUDA, and you! • Flocking simulations

More Related